From 3ad13b860c35618ee3ad29a53a6587d1e4b50b39 Mon Sep 17 00:00:00 2001 From: Rushil Venkateswar Date: Sat, 22 Feb 2025 21:51:43 +0000 Subject: [PATCH 01/16] create manifest.yaml --- circleci-snap-in/.env.example | 4 ++ circleci-snap-in/.gitignore | 40 ++++++++++++++ circleci-snap-in/manifest.yaml | 95 ++++++++++++++++++++++++++++++++++ 3 files changed, 139 insertions(+) create mode 100644 circleci-snap-in/.env.example create mode 100644 circleci-snap-in/.gitignore create mode 100644 circleci-snap-in/manifest.yaml diff --git a/circleci-snap-in/.env.example b/circleci-snap-in/.env.example new file mode 100644 index 0000000..77001ac --- /dev/null +++ b/circleci-snap-in/.env.example @@ -0,0 +1,4 @@ +CIRCLECI_TOKEN= +DEV_ORG= +USER_EMAIL= +DEVREV_TOKEN= diff --git a/circleci-snap-in/.gitignore b/circleci-snap-in/.gitignore new file mode 100644 index 0000000..70f7f7b --- /dev/null +++ b/circleci-snap-in/.gitignore @@ -0,0 +1,40 @@ +# See http://help.github.com/ignore-files/ for more about ignoring files. + +# compiled output +/dist +/tmp +/out-tsc + +# Testing +coverage/ + +# dependencies +/node_modules + +# IDEs and editors +/.idea +.project +.classpath +.c9/ +*.launch +.settings/ +*.sublime-workspace + +# IDE - VSCode +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json + +# System Files +.DS_Store +Thumbs.db + +deps.json +results.json +before-run-data.json + +node_modules/ +.env + diff --git a/circleci-snap-in/manifest.yaml b/circleci-snap-in/manifest.yaml new file mode 100644 index 0000000..85e3fee --- /dev/null +++ b/circleci-snap-in/manifest.yaml @@ -0,0 +1,95 @@ +version: 2 + +name: CircleCI snap-in +description: A snap-in to connect CircleCI to DevRev and provide AI insights. + + +service_account: + display_name: CircleCI Sync Bot + + +keyrings: + organization: + - name: circleci_api_key + display_name: CircleCI API Key + description: API Key for CircleCI, follow https://circleci.com/docs/managing-api-tokens/ to know how to get one. + types: + - snap_in_secret + + - name: openai_api_key + display_name: OpenAI API Key + description: API Key for using OpenAI ChatGPT, this is optional + types: + - snap_in_secret + + - name: groq_api_key + display_name: Groq API Key + description: API Key for using Groq, follow https://console.groq.com/keys to generate a free API Key + types: + - snap_in_secret + + +inputs: +organization: + - name: project_slug + description: The project slug that identifies the project in CircleCI. + type: string + required: true + default_value: don:core:dvrv-us-1:devo/XXXX/product:XXXX + ui: + display_name: CircleCI Project Slug + + +event_sources: + organization: + - name: circleci-webhook + description: Events related to pipeline/workflow/jobs sent on a Webhook connected to CircleCI. + display_name: CircleCI webhook + type: flow-custom-webhook + setup_instructions: | + - For configuration instructions, refer to the [CircleCI documentation](https://circleci.com/docs/webhooks/). + - You webhook URL is `{{source.trigger_url}}`. + - Your secret is `{{source.config.parameters.secret}}`. + config: + policy: | + package rego + output = {"event": event, "event_key": event_key} { + event := input.request.body + event_key := "circleci.pipeline" + } else = {"response": response } { + response := { + "status_code": 400 + } + } + + +automations: + organization: + - name: Sync on CircleCI Webhook + source: circleci-webhook + event_types: + - "custom:circleci.pipeline" + function: sync_circleci_data + + +commands: + - name: generateInsights + namespace: circleci + description: Generate insights and recommendations based on CircleCI data. + surfaces: + - surface: discussions + object_types: + - issue + - ticket + - part + - conversation + usage_hint: "[pipeline_id] [insight_type]" + function: generate_insights + + +functions: + - name: generate_insights + description: Generate insights based on data pulled from CircleCI. The insights could be one of :- issue_creation OR build_failure_analysis. + + - name: sync_circleci_data + description: Sync CircleCI data to DevRev. \ No newline at end of file From 14340e85b7d9b3ecd84e37164d3e8e96d9a4ab90 Mon Sep 17 00:00:00 2001 From: rushilv14 <34117892-rushilv14@users.noreply.replit.com> Date: Sun, 23 Feb 2025 09:11:07 +0000 Subject: [PATCH 02/16] add sync_circleci_data method and tests --- circleci-snap-in/code/jest.config.js | 16 + circleci-snap-in/code/package-lock.json | 1350 +++++++++++++++++ circleci-snap-in/code/package.json | 16 + circleci-snap-in/code/src/function-factory.ts | 10 + .../sync_circleci_data/index.test.ts | 37 + .../src/functions/sync_circleci_data/index.ts | 64 + .../src/functions/sync_circleci_data/types.ts | 117 ++ .../src/functions/sync_circleci_data/utils.ts | 120 ++ circleci-snap-in/code/src/index.ts | 1 + circleci-snap-in/code/src/main.ts | 27 + .../code/src/test-runner/test-runner.ts | 28 + circleci-snap-in/code/tsconfig.json | 24 + 12 files changed, 1810 insertions(+) create mode 100644 circleci-snap-in/code/jest.config.js create mode 100644 circleci-snap-in/code/package-lock.json create mode 100644 circleci-snap-in/code/package.json create mode 100644 circleci-snap-in/code/src/function-factory.ts create mode 100644 circleci-snap-in/code/src/functions/sync_circleci_data/index.test.ts create mode 100644 circleci-snap-in/code/src/functions/sync_circleci_data/index.ts create mode 100644 circleci-snap-in/code/src/functions/sync_circleci_data/types.ts create mode 100644 circleci-snap-in/code/src/functions/sync_circleci_data/utils.ts create mode 100644 circleci-snap-in/code/src/index.ts create mode 100644 circleci-snap-in/code/src/main.ts create mode 100644 circleci-snap-in/code/src/test-runner/test-runner.ts create mode 100644 circleci-snap-in/code/tsconfig.json diff --git a/circleci-snap-in/code/jest.config.js b/circleci-snap-in/code/jest.config.js new file mode 100644 index 0000000..cb7633f --- /dev/null +++ b/circleci-snap-in/code/jest.config.js @@ -0,0 +1,16 @@ +module.exports = { + roots: ['./src'], + testPathIgnorePatterns: [ + "/node_modules/" + ], + collectCoverage: true, + coverageDirectory: "coverage", + coverageReporters: ["text"], + coverageThreshold: { + "**/*": { + branches: 60, + }, + }, + preset: "ts-jest", + testEnvironment: "node", +}; diff --git a/circleci-snap-in/code/package-lock.json b/circleci-snap-in/code/package-lock.json new file mode 100644 index 0000000..9d72c79 --- /dev/null +++ b/circleci-snap-in/code/package-lock.json @@ -0,0 +1,1350 @@ +{ + "name": "circleci-snap-in", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "circleci-snap-in", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "@devrev/typescript-sdk": "^1.1.53", + "@langchain/groq": "^0.1.3", + "langchain": "^0.3.19" + } + }, + "node_modules/@cfworker/json-schema": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/@cfworker/json-schema/-/json-schema-4.1.1.tgz", + "integrity": "sha512-gAmrUZSGtKc3AiBL71iNWxDsyUC5uMaKKGdvzYsBoTW/xi42JQHl7eKV2OYzCUqvc+D2RCcf7EXY2iCyFIk6og==", + "license": "MIT", + "peer": true + }, + "node_modules/@devrev/typescript-sdk": { + "version": "1.1.53", + "resolved": "https://registry.npmjs.org/@devrev/typescript-sdk/-/typescript-sdk-1.1.53.tgz", + "integrity": "sha512-/cp6EhUYjpmFfT+bJkdCNxNZKIeIOjGbjwEQOgLzdXMDM69PWkfK2nN/xk95FC0Ak/ZAa9dVyySQdLyfg+iZ+A==", + "license": "MIT", + "dependencies": { + "@types/yargs": "^17.0.22", + "axios": "^1.3.6", + "dotenv": "^16.0.3", + "protobufjs": "^7.3.0", + "yargs": "^17.6.2" + } + }, + "node_modules/@langchain/core": { + "version": "0.3.40", + "resolved": "https://registry.npmjs.org/@langchain/core/-/core-0.3.40.tgz", + "integrity": "sha512-RGhJOTzJv6H+3veBAnDlH2KXuZ68CXMEg6B6DPTzL3IGDyd+vLxXG4FIttzUwjdeQKjrrFBwlXpJDl7bkoApzQ==", + "license": "MIT", + "peer": true, + "dependencies": { + "@cfworker/json-schema": "^4.0.2", + "ansi-styles": "^5.0.0", + "camelcase": "6", + "decamelize": "1.2.0", + "js-tiktoken": "^1.0.12", + "langsmith": ">=0.2.8 <0.4.0", + "mustache": "^4.2.0", + "p-queue": "^6.6.2", + "p-retry": "4", + "uuid": "^10.0.0", + "zod": "^3.22.4", + "zod-to-json-schema": "^3.22.3" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@langchain/groq": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@langchain/groq/-/groq-0.1.3.tgz", + "integrity": "sha512-dMzvBVaLf/0IQoHdAOAN8W/PbOcwgbvgUMCn02CqvCC90mxZ45LI0Tipzqnoaam0hiKALR5hLc3dNj1oCYV92w==", + "license": "MIT", + "dependencies": { + "@langchain/openai": "~0.3.0", + "groq-sdk": "^0.5.0", + "zod": "^3.22.4", + "zod-to-json-schema": "^3.22.5" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@langchain/core": ">=0.2.21 <0.4.0" + } + }, + "node_modules/@langchain/groq/node_modules/@langchain/openai": { + "version": "0.3.17", + "resolved": "https://registry.npmjs.org/@langchain/openai/-/openai-0.3.17.tgz", + "integrity": "sha512-uw4po32OKptVjq+CYHrumgbfh4NuD7LqyE+ZgqY9I/LrLc6bHLMc+sisHmI17vgek0K/yqtarI0alPJbzrwyag==", + "license": "MIT", + "dependencies": { + "js-tiktoken": "^1.0.12", + "openai": "^4.77.0", + "zod": "^3.22.4", + "zod-to-json-schema": "^3.22.3" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@langchain/core": ">=0.3.29 <0.4.0" + } + }, + "node_modules/@langchain/openai": { + "version": "0.4.4", + "resolved": "https://registry.npmjs.org/@langchain/openai/-/openai-0.4.4.tgz", + "integrity": "sha512-UZybJeMd8+UX7Kn47kuFYfqKdBCeBUWNqDtmAr6ZUIMMnlsNIb6MkrEEhGgAEjGCpdT4CU8U/DyyddTz+JayOQ==", + "license": "MIT", + "dependencies": { + "js-tiktoken": "^1.0.12", + "openai": "^4.77.0", + "zod": "^3.22.4", + "zod-to-json-schema": "^3.22.3" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@langchain/core": ">=0.3.39 <0.4.0" + } + }, + "node_modules/@langchain/textsplitters": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/@langchain/textsplitters/-/textsplitters-0.1.0.tgz", + "integrity": "sha512-djI4uw9rlkAb5iMhtLED+xJebDdAG935AdP4eRTB02R7OB/act55Bj9wsskhZsvuyQRpO4O1wQOp85s6T6GWmw==", + "license": "MIT", + "dependencies": { + "js-tiktoken": "^1.0.12" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@langchain/core": ">=0.2.21 <0.4.0" + } + }, + "node_modules/@protobufjs/aspromise": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz", + "integrity": "sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ==", + "license": "BSD-3-Clause" + }, + "node_modules/@protobufjs/base64": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@protobufjs/base64/-/base64-1.1.2.tgz", + "integrity": "sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg==", + "license": "BSD-3-Clause" + }, + "node_modules/@protobufjs/codegen": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@protobufjs/codegen/-/codegen-2.0.4.tgz", + "integrity": "sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg==", + "license": "BSD-3-Clause" + }, + "node_modules/@protobufjs/eventemitter": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz", + "integrity": "sha512-j9ednRT81vYJ9OfVuXG6ERSTdEL1xVsNgqpkxMsbIabzSo3goCjDIveeGv5d03om39ML71RdmrGNjG5SReBP/Q==", + "license": "BSD-3-Clause" + }, + "node_modules/@protobufjs/fetch": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/fetch/-/fetch-1.1.0.tgz", + "integrity": "sha512-lljVXpqXebpsijW71PZaCYeIcE5on1w5DlQy5WH6GLbFryLUrBD4932W/E2BSpfRJWseIL4v/KPgBFxDOIdKpQ==", + "license": "BSD-3-Clause", + "dependencies": { + "@protobufjs/aspromise": "^1.1.1", + "@protobufjs/inquire": "^1.1.0" + } + }, + "node_modules/@protobufjs/float": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@protobufjs/float/-/float-1.0.2.tgz", + "integrity": "sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ==", + "license": "BSD-3-Clause" + }, + "node_modules/@protobufjs/inquire": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/inquire/-/inquire-1.1.0.tgz", + "integrity": "sha512-kdSefcPdruJiFMVSbn801t4vFK7KB/5gd2fYvrxhuJYg8ILrmn9SKSX2tZdV6V+ksulWqS7aXjBcRXl3wHoD9Q==", + "license": "BSD-3-Clause" + }, + "node_modules/@protobufjs/path": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@protobufjs/path/-/path-1.1.2.tgz", + "integrity": "sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA==", + "license": "BSD-3-Clause" + }, + "node_modules/@protobufjs/pool": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/pool/-/pool-1.1.0.tgz", + "integrity": "sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw==", + "license": "BSD-3-Clause" + }, + "node_modules/@protobufjs/utf8": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/utf8/-/utf8-1.1.0.tgz", + "integrity": "sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==", + "license": "BSD-3-Clause" + }, + "node_modules/@types/node": { + "version": "18.19.76", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.76.tgz", + "integrity": "sha512-yvR7Q9LdPz2vGpmpJX5LolrgRdWvB67MJKDPSgIIzpFbaf9a1j/f5DnLp5VDyHGMR0QZHlTr1afsD87QCXFHKw==", + "license": "MIT", + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "node_modules/@types/node-fetch": { + "version": "2.6.12", + "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.12.tgz", + "integrity": "sha512-8nneRWKCg3rMtF69nLQJnOYUcbafYeFSjqkw3jCRLsqkWFlHaoQrr5mXmofFGOx3DKn7UfmBMyov8ySvLRVldA==", + "license": "MIT", + "dependencies": { + "@types/node": "*", + "form-data": "^4.0.0" + } + }, + "node_modules/@types/retry": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/@types/retry/-/retry-0.12.0.tgz", + "integrity": "sha512-wWKOClTTiizcZhXnPY4wikVAwmdYHp8q6DmC+EJUzAMsycb7HB32Kh9RN4+0gExjmPmZSAQjgURXIGATPegAvA==", + "license": "MIT" + }, + "node_modules/@types/uuid": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-10.0.0.tgz", + "integrity": "sha512-7gqG38EyHgyP1S+7+xomFtL+ZNHcKv6DwNaCZmJmo1vgMugyF3TCnXVg4t1uk89mLNwnLtnY3TpOpCOyp1/xHQ==", + "license": "MIT" + }, + "node_modules/@types/yargs": { + "version": "17.0.33", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.33.tgz", + "integrity": "sha512-WpxBCKWPLr4xSsHgz511rFJAM+wS28w2zEO1QDNY5zM/S8ok70NNfztH0xwhqKyaK0OHCbN98LDAZuy1ctxDkA==", + "license": "MIT", + "dependencies": { + "@types/yargs-parser": "*" + } + }, + "node_modules/@types/yargs-parser": { + "version": "21.0.3", + "resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-21.0.3.tgz", + "integrity": "sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ==", + "license": "MIT" + }, + "node_modules/abort-controller": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", + "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", + "license": "MIT", + "dependencies": { + "event-target-shim": "^5.0.0" + }, + "engines": { + "node": ">=6.5" + } + }, + "node_modules/agentkeepalive": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/agentkeepalive/-/agentkeepalive-4.6.0.tgz", + "integrity": "sha512-kja8j7PjmncONqaTsB8fQ+wE2mSU2DJ9D4XKoJ5PFWIdRMa6SLSN1ff4mOr4jCbfRSsxR4keIiySJU0N9T5hIQ==", + "license": "MIT", + "dependencies": { + "humanize-ms": "^1.2.1" + }, + "engines": { + "node": ">= 8.0.0" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", + "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "license": "Python-2.0" + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "license": "MIT" + }, + "node_modules/axios": { + "version": "1.7.9", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.9.tgz", + "integrity": "sha512-LhLcE7Hbiryz8oMDdDptSrWowmB4Bl6RCt6sIJKpRB4XtVf0iEgewX3au/pJqm+Py1kCASkb/FFKjxQaLtxJvw==", + "license": "MIT", + "dependencies": { + "follow-redirects": "^1.15.6", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/camelcase": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", + "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/chalk/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/cliui": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", + "license": "ISC", + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "license": "MIT" + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "license": "MIT", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/console-table-printer": { + "version": "2.12.1", + "resolved": "https://registry.npmjs.org/console-table-printer/-/console-table-printer-2.12.1.tgz", + "integrity": "sha512-wKGOQRRvdnd89pCeH96e2Fn4wkbenSP6LMHfjfyNLMbGuHEFbMqQNuxXqd0oXG9caIOQ1FTvc5Uijp9/4jujnQ==", + "license": "MIT", + "dependencies": { + "simple-wcswidth": "^1.0.1" + } + }, + "node_modules/decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "license": "MIT", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/dotenv": { + "version": "16.4.7", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.7.tgz", + "integrity": "sha512-47qPchRCykZC03FhkYAhrvwU4xDBFIj1QPqaarj6mdM/hgUzfPHcpkHJOn3mJAufFeeAxAzeGsr5X0M4k6fLZQ==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "license": "MIT" + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-object-atoms": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz", + "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-set-tostringtag": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz", + "integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.6", + "has-tostringtag": "^1.0.2", + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/escalade": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/event-target-shim": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", + "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/eventemitter3": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz", + "integrity": "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==", + "license": "MIT" + }, + "node_modules/follow-redirects": { + "version": "1.15.9", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz", + "integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "license": "MIT", + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/form-data": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.2.tgz", + "integrity": "sha512-hGfm/slu0ZabnNt4oaRZ6uREyfCj6P4fT/n6A1rGV+Z0VdGXjfOhVUpkn6qVQONHGIFwmveGXyDs75+nr6FM8w==", + "license": "MIT", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "es-set-tostringtag": "^2.1.0", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/form-data-encoder": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/form-data-encoder/-/form-data-encoder-1.7.2.tgz", + "integrity": "sha512-qfqtYan3rxrnCk1VYaA4H+Ms9xdpPqvLZa6xmMgFvhO32x7/3J/ExcTd6qpxM0vH2GdMI+poehyBZvqfMTto8A==", + "license": "MIT" + }, + "node_modules/formdata-node": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/formdata-node/-/formdata-node-4.4.1.tgz", + "integrity": "sha512-0iirZp3uVDjVGt9p49aTaqjk84TrglENEDuqfdlZQ1roC9CWlPk6Avf8EEnZNcAqPonwkG35x4n3ww/1THYAeQ==", + "license": "MIT", + "dependencies": { + "node-domexception": "1.0.0", + "web-streams-polyfill": "4.0.0-beta.3" + }, + "engines": { + "node": ">= 12.20" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "license": "ISC", + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/groq-sdk": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/groq-sdk/-/groq-sdk-0.5.0.tgz", + "integrity": "sha512-RVmhW7qZ+XZoy5fIuSdx/LGQJONpL8MHgZEW7dFwTdgkzStub2XQx6OKv28CHogijdwH41J+Npj/z2jBPu3vmw==", + "license": "Apache-2.0", + "dependencies": { + "@types/node": "^18.11.18", + "@types/node-fetch": "^2.6.4", + "abort-controller": "^3.0.0", + "agentkeepalive": "^4.2.1", + "form-data-encoder": "1.7.2", + "formdata-node": "^4.3.2", + "node-fetch": "^2.6.7", + "web-streams-polyfill": "^3.2.1" + } + }, + "node_modules/groq-sdk/node_modules/web-streams-polyfill": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz", + "integrity": "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==", + "license": "MIT", + "engines": { + "node": ">= 8" + } + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-tostringtag": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", + "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", + "license": "MIT", + "dependencies": { + "has-symbols": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/humanize-ms": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/humanize-ms/-/humanize-ms-1.2.1.tgz", + "integrity": "sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ==", + "license": "MIT", + "dependencies": { + "ms": "^2.0.0" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/js-tiktoken": { + "version": "1.0.19", + "resolved": "https://registry.npmjs.org/js-tiktoken/-/js-tiktoken-1.0.19.tgz", + "integrity": "sha512-XC63YQeEcS47Y53gg950xiZ4IWmkfMe4p2V9OSaBt26q+p47WHn18izuXzSclCI73B7yGqtfRsT6jcZQI0y08g==", + "license": "MIT", + "dependencies": { + "base64-js": "^1.5.1" + } + }, + "node_modules/js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "license": "MIT", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/jsonpointer": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-5.0.1.tgz", + "integrity": "sha512-p/nXbhSEcu3pZRdkW1OfJhpsVtW1gd4Wa1fnQc9YLiTfAjn0312eMKimbdIQzuZl9aa9xUGaRlP9T/CJE/ditQ==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/langchain": { + "version": "0.3.19", + "resolved": "https://registry.npmjs.org/langchain/-/langchain-0.3.19.tgz", + "integrity": "sha512-aGhoTvTBS5ulatA67RHbJ4bcV5zcYRYdm5IH+hpX99RYSFXG24XF3ghSjhYi6sxW+SUnEQ99fJhA5kroVpKNhw==", + "license": "MIT", + "dependencies": { + "@langchain/openai": ">=0.1.0 <0.5.0", + "@langchain/textsplitters": ">=0.0.0 <0.2.0", + "js-tiktoken": "^1.0.12", + "js-yaml": "^4.1.0", + "jsonpointer": "^5.0.1", + "langsmith": ">=0.2.8 <0.4.0", + "openapi-types": "^12.1.3", + "p-retry": "4", + "uuid": "^10.0.0", + "yaml": "^2.2.1", + "zod": "^3.22.4", + "zod-to-json-schema": "^3.22.3" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@langchain/anthropic": "*", + "@langchain/aws": "*", + "@langchain/cerebras": "*", + "@langchain/cohere": "*", + "@langchain/core": ">=0.2.21 <0.4.0", + "@langchain/deepseek": "*", + "@langchain/google-genai": "*", + "@langchain/google-vertexai": "*", + "@langchain/google-vertexai-web": "*", + "@langchain/groq": "*", + "@langchain/mistralai": "*", + "@langchain/ollama": "*", + "@langchain/xai": "*", + "axios": "*", + "cheerio": "*", + "handlebars": "^4.7.8", + "peggy": "^3.0.2", + "typeorm": "*" + }, + "peerDependenciesMeta": { + "@langchain/anthropic": { + "optional": true + }, + "@langchain/aws": { + "optional": true + }, + "@langchain/cerebras": { + "optional": true + }, + "@langchain/cohere": { + "optional": true + }, + "@langchain/deepseek": { + "optional": true + }, + "@langchain/google-genai": { + "optional": true + }, + "@langchain/google-vertexai": { + "optional": true + }, + "@langchain/google-vertexai-web": { + "optional": true + }, + "@langchain/groq": { + "optional": true + }, + "@langchain/mistralai": { + "optional": true + }, + "@langchain/ollama": { + "optional": true + }, + "@langchain/xai": { + "optional": true + }, + "axios": { + "optional": true + }, + "cheerio": { + "optional": true + }, + "handlebars": { + "optional": true + }, + "peggy": { + "optional": true + }, + "typeorm": { + "optional": true + } + } + }, + "node_modules/langsmith": { + "version": "0.3.10", + "resolved": "https://registry.npmjs.org/langsmith/-/langsmith-0.3.10.tgz", + "integrity": "sha512-V6SnJhxKt9AbdVfl86OrEBl8uGwO0/WE2qqDcRXxHxzdCDnj+sV7nstr5VL0a6zxZmyMaw6eBbYwB4PTYKRvvQ==", + "license": "MIT", + "dependencies": { + "@types/uuid": "^10.0.0", + "chalk": "^4.1.2", + "console-table-printer": "^2.12.1", + "p-queue": "^6.6.2", + "p-retry": "4", + "semver": "^7.6.3", + "uuid": "^10.0.0" + }, + "peerDependencies": { + "openai": "*" + }, + "peerDependenciesMeta": { + "openai": { + "optional": true + } + } + }, + "node_modules/long": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/long/-/long-5.3.1.tgz", + "integrity": "sha512-ka87Jz3gcx/I7Hal94xaN2tZEOPoUOEVftkQqZx2EeQRN7LGdfLlI3FvZ+7WDplm+vK2Urx9ULrvSowtdCieng==", + "license": "Apache-2.0" + }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/mustache": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/mustache/-/mustache-4.2.0.tgz", + "integrity": "sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ==", + "license": "MIT", + "peer": true, + "bin": { + "mustache": "bin/mustache" + } + }, + "node_modules/node-domexception": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", + "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/jimmywarting" + }, + { + "type": "github", + "url": "https://paypal.me/jimmywarting" + } + ], + "license": "MIT", + "engines": { + "node": ">=10.5.0" + } + }, + "node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "license": "MIT", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/openai": { + "version": "4.85.4", + "resolved": "https://registry.npmjs.org/openai/-/openai-4.85.4.tgz", + "integrity": "sha512-Nki51PBSu+Aryo7WKbdXvfm0X/iKkQS2fq3O0Uqb/O3b4exOZFid2te1BZ52bbO5UwxQZ5eeHJDCTqtrJLPw0w==", + "license": "Apache-2.0", + "dependencies": { + "@types/node": "^18.11.18", + "@types/node-fetch": "^2.6.4", + "abort-controller": "^3.0.0", + "agentkeepalive": "^4.2.1", + "form-data-encoder": "1.7.2", + "formdata-node": "^4.3.2", + "node-fetch": "^2.6.7" + }, + "bin": { + "openai": "bin/cli" + }, + "peerDependencies": { + "ws": "^8.18.0", + "zod": "^3.23.8" + }, + "peerDependenciesMeta": { + "ws": { + "optional": true + }, + "zod": { + "optional": true + } + } + }, + "node_modules/openapi-types": { + "version": "12.1.3", + "resolved": "https://registry.npmjs.org/openapi-types/-/openapi-types-12.1.3.tgz", + "integrity": "sha512-N4YtSYJqghVu4iek2ZUvcN/0aqH1kRDuNqzcycDxhOUpg7GdvLa2F3DgS6yBNhInhv2r/6I0Flkn7CqL8+nIcw==", + "license": "MIT" + }, + "node_modules/p-finally": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", + "integrity": "sha512-LICb2p9CB7FS+0eR1oqWnHhp0FljGLZCWBE9aix0Uye9W8LTQPwMTYVGWQWIw9RdQiDg4+epXQODwIYJtSJaow==", + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/p-queue": { + "version": "6.6.2", + "resolved": "https://registry.npmjs.org/p-queue/-/p-queue-6.6.2.tgz", + "integrity": "sha512-RwFpb72c/BhQLEXIZ5K2e+AhgNVmIejGlTgiB9MzZ0e93GRvqZ7uSi0dvRF7/XIXDeNkra2fNHBxTyPDGySpjQ==", + "license": "MIT", + "dependencies": { + "eventemitter3": "^4.0.4", + "p-timeout": "^3.2.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-retry": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/p-retry/-/p-retry-4.6.2.tgz", + "integrity": "sha512-312Id396EbJdvRONlngUx0NydfrIQ5lsYu0znKVUzVvArzEIt08V1qhtyESbGVd1FGX7UKtiFp5uwKZdM8wIuQ==", + "license": "MIT", + "dependencies": { + "@types/retry": "0.12.0", + "retry": "^0.13.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/p-timeout": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/p-timeout/-/p-timeout-3.2.0.tgz", + "integrity": "sha512-rhIwUycgwwKcP9yTOOFK/AKsAopjjCakVqLHePO3CC6Mir1Z99xT+R63jZxAT5lFZLa2inS5h+ZS2GvR99/FBg==", + "license": "MIT", + "dependencies": { + "p-finally": "^1.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/protobufjs": { + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-7.4.0.tgz", + "integrity": "sha512-mRUWCc3KUU4w1jU8sGxICXH/gNS94DvI1gxqDvBzhj1JpcsimQkYiOJfwsPUykUI5ZaspFbSgmBLER8IrQ3tqw==", + "hasInstallScript": true, + "license": "BSD-3-Clause", + "dependencies": { + "@protobufjs/aspromise": "^1.1.2", + "@protobufjs/base64": "^1.1.2", + "@protobufjs/codegen": "^2.0.4", + "@protobufjs/eventemitter": "^1.1.0", + "@protobufjs/fetch": "^1.1.0", + "@protobufjs/float": "^1.0.2", + "@protobufjs/inquire": "^1.1.0", + "@protobufjs/path": "^1.1.2", + "@protobufjs/pool": "^1.1.0", + "@protobufjs/utf8": "^1.1.0", + "@types/node": ">=13.7.0", + "long": "^5.0.0" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", + "license": "MIT" + }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/retry": { + "version": "0.13.1", + "resolved": "https://registry.npmjs.org/retry/-/retry-0.13.1.tgz", + "integrity": "sha512-XQBQ3I8W1Cge0Seh+6gjj03LbmRFWuoszgK9ooCpwYIrhhoO80pfq4cUkU5DkknwfOfFteRwlZ56PYOGYyFWdg==", + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, + "node_modules/semver": { + "version": "7.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.1.tgz", + "integrity": "sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA==", + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/simple-wcswidth": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/simple-wcswidth/-/simple-wcswidth-1.0.1.tgz", + "integrity": "sha512-xMO/8eNREtaROt7tJvWJqHBDTMFN4eiQ5I4JRMuilwfnFcV5W9u7RUkueNkdw0jPqGMX36iCywelS5yilTuOxg==", + "license": "MIT" + }, + "node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", + "license": "MIT" + }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "license": "MIT" + }, + "node_modules/uuid": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-10.0.0.tgz", + "integrity": "sha512-8XkAphELsDnEGrDxUOHB3RGvXz6TeuYSGEZBOjtTtPm2lwhGBjLgOzLHB63IUWfBpNucQjND6d3AOudO+H3RWQ==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "license": "MIT", + "bin": { + "uuid": "dist/bin/uuid" + } + }, + "node_modules/web-streams-polyfill": { + "version": "4.0.0-beta.3", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-4.0.0-beta.3.tgz", + "integrity": "sha512-QW95TCTaHmsYfHDybGMwO5IJIM93I/6vTRk+daHTWFPhwh+C8Cg7j7XyKrwrj8Ib6vYXe0ocYNrmzY4xAAN6ug==", + "license": "MIT", + "engines": { + "node": ">= 14" + } + }, + "node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", + "license": "BSD-2-Clause" + }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "license": "MIT", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, + "node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrap-ansi/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "license": "ISC", + "engines": { + "node": ">=10" + } + }, + "node_modules/yaml": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.7.0.tgz", + "integrity": "sha512-+hSoy/QHluxmC9kCIJyL/uyFmLmc+e5CFR5Wa+bpIhIj85LVb9ZH2nVnqrHoSvKogwODv0ClqZkmiSSaIH5LTA==", + "license": "ISC", + "bin": { + "yaml": "bin.mjs" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/yargs": { + "version": "17.7.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", + "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", + "license": "MIT", + "dependencies": { + "cliui": "^8.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.3", + "y18n": "^5.0.5", + "yargs-parser": "^21.1.1" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/zod": { + "version": "3.24.2", + "resolved": "https://registry.npmjs.org/zod/-/zod-3.24.2.tgz", + "integrity": "sha512-lY7CDW43ECgW9u1TcT3IoXHflywfVqDYze4waEz812jR/bZ8FHDsl7pFQoSZTz5N+2NqRXs8GBwnAwo3ZNxqhQ==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/colinhacks" + } + }, + "node_modules/zod-to-json-schema": { + "version": "3.24.2", + "resolved": "https://registry.npmjs.org/zod-to-json-schema/-/zod-to-json-schema-3.24.2.tgz", + "integrity": "sha512-pNUqrcSxuuB3/+jBbU8qKUbTbDqYUaG1vf5cXFjbhGgoUuA1amO/y4Q8lzfOhHU8HNPK6VFJ18lBDKj3OHyDsg==", + "license": "ISC", + "peerDependencies": { + "zod": "^3.24.1" + } + } + } +} diff --git a/circleci-snap-in/code/package.json b/circleci-snap-in/code/package.json new file mode 100644 index 0000000..37da3d3 --- /dev/null +++ b/circleci-snap-in/code/package.json @@ -0,0 +1,16 @@ +{ + "name": "circleci-snap-in", + "version": "1.0.0", + "main": "index.js", + "scripts": { + "test": "jest" + }, + "author": "Rushil Venkateswar", + "license": "ISC", + "description": "", + "dependencies": { + "@devrev/typescript-sdk": "^1.1.53", + "@langchain/groq": "^0.1.3", + "langchain": "^0.3.19" + } +} diff --git a/circleci-snap-in/code/src/function-factory.ts b/circleci-snap-in/code/src/function-factory.ts new file mode 100644 index 0000000..76491e5 --- /dev/null +++ b/circleci-snap-in/code/src/function-factory.ts @@ -0,0 +1,10 @@ +import sync_circleci_data from "./functions/sync_circleci_data"; +// import generate_insights from "./functions/generate_insights"; + +export const functionFactory = { + // Add your functions here + sync_circleci_data, + // generate_insights, +} as const; + +export type FunctionFactoryType = keyof typeof functionFactory; diff --git a/circleci-snap-in/code/src/functions/sync_circleci_data/index.test.ts b/circleci-snap-in/code/src/functions/sync_circleci_data/index.test.ts new file mode 100644 index 0000000..b481be9 --- /dev/null +++ b/circleci-snap-in/code/src/functions/sync_circleci_data/index.test.ts @@ -0,0 +1,37 @@ +import { testRunner } from "../../test-runner/test-runner"; + +describe("Webhook of type-1 (workflow-completed for GitHub OAuth and Bitbucket Cloud)", () => { + it("Testing the method", () => { + testRunner({ + fixturePath: "type1.json", + functionName: "sync_circleci_data", + }); + }); +}); + +describe("Webhook of type-2 (job-completed for GitHub OAuth and Bitbucket Cloud)", () => { + it("Testing the method", () => { + testRunner({ + fixturePath: "type2.json", + functionName: "sync_circleci_data", + }); + }); +}); + +describe("Webhook of type-3 (workflow-completed for GitLab, GitHub App and Bitbucket Data Center)", () => { + it("Testing the method", () => { + testRunner({ + fixturePath: "type3.json", + functionName: "sync_circleci_data", + }); + }); +}); + +describe("Webhook of type-4 (job-completed for GitLab, GitHub App and Bitbucket Data Center)", () => { + it("Testing the method", () => { + testRunner({ + fixturePath: "type4.json", + functionName: "sync_circleci_data", + }); + }); +}); diff --git a/circleci-snap-in/code/src/functions/sync_circleci_data/index.ts b/circleci-snap-in/code/src/functions/sync_circleci_data/index.ts new file mode 100644 index 0000000..15768c6 --- /dev/null +++ b/circleci-snap-in/code/src/functions/sync_circleci_data/index.ts @@ -0,0 +1,64 @@ +import { ApiUtils } from "./utils"; +import { + WorkflowCompletedWebhook, + JobCompletedWebhook, + WebhookType, +} from "./types"; +import { + PartType, + WorkType, +} from "@devrev/typescript-sdk/dist/auto-generated/beta/beta-devrev-sdk"; + +type CircleCIWebhook = WorkflowCompletedWebhook | JobCompletedWebhook; + +async function handleEvent(event: any) { + const token = event.context.secrets["service_account_token"]; + const endpoint = event.execution_metadata.devrev_endpoint; + const dev = event.context.dev_oid; + + const apiUtils = new ApiUtils(endpoint, token); + // parse the event payload as CircleCIWebhook + const payload: CircleCIWebhook = event.payload; + const project_slug = payload.project.slug; + + // create a part for the project + const part = await apiUtils.createPart({ + type: PartType.Product, + name: project_slug, + owned_by: dev, + }); + + const part_id = part.data.id; + let type; + let title; + + if (payload.type === WebhookType.workflow) { + // map Workflow to Issue + type = WorkType.Issue; + title = payload.workflow.name; + } else { + // map Job to Task + type = WorkType.Task; + title = payload.job.name; + + // TODO: figure out how to fetch steps from the job and populate timeline in DevRev + } + + // create work in DevRev + const response = await apiUtils.createIssueOrTask({ + type: type, + applies_to_part: part_id, + owned_by: dev, + title: title, + }); + + return response; +} + +export const run = async (events: any[]) => { + for (const event of events) { + await handleEvent(event); + } +}; + +export default run; diff --git a/circleci-snap-in/code/src/functions/sync_circleci_data/types.ts b/circleci-snap-in/code/src/functions/sync_circleci_data/types.ts new file mode 100644 index 0000000..91ed071 --- /dev/null +++ b/circleci-snap-in/code/src/functions/sync_circleci_data/types.ts @@ -0,0 +1,117 @@ +export interface CircleCIWebhookBase { + id: string; + type: WebhookType; + happened_at: string; // ISO 8601 timestamp + webhook: { + id: string; + name: string; + }; + project: Project; + organization: Organization; + pipeline: Pipeline; +} + +export interface WorkflowCompletedWebhook extends CircleCIWebhookBase { + type: WebhookType.workflow; + workflow: WorkflowWithStatus; +} + +export interface JobCompletedWebhook extends CircleCIWebhookBase { + type: WebhookType.job; + workflow: Workflow; + job: Job; +} + +// Common Sub-Entities +export interface Project { + id: string; + name: string; + slug: string; +} + +export interface Organization { + id: string; + name: string; +} + +export interface Pipeline { + id: string; + number: number; + created_at: string; // ISO 8601 + trigger: Trigger; + vcs?: Vcs; + trigger_parameters?: { + [key: string]: any; // Dynamic parameters + }; +} + +export interface Trigger { + type: "webhook" | "api" | "scheduled_pipeline" | "explicit"; +} + +export interface Vcs { + provider_name: string; + origin_repository_url?: string; + target_repository_url?: string; + revision?: string; + commit?: Commit; + branch?: string; + tag?: string; +} + +export interface Commit { + subject?: string; + body?: string; + author?: Author; + committer?: Author; + authored_at?: string; // ISO 8601 + committed_at?: string; // ISO 8601 +} + +export interface Author { + name?: string; + email?: string; +} + +export interface Job { + id: string; + number: number; + name: string; + status: JobStatus; + started_at: string; // ISO 8601 + stopped_at?: string; // ISO 8601 +} + +export interface Workflow { + id: string; + name: string; + created_at: string; // ISO 8601 + stopped_at?: string; // ISO 8601 + url: string; +} + +export interface WorkflowWithStatus extends Workflow { + status: WorkflowStatus; +} + +// Enums +enum JobStatus { + Success = "success", + Failed = "failed", + Running = "running", + Blocked = "blocked", + Canceled = "canceled", +} + +enum WorkflowStatus { + Success = "success", + Failed = "failed", + Error = "error", + Canceled = "canceled", + Unauthorized = "unauthorized", +} + +export enum WebhookType { + job = "job-completed", + workflow = "workflow-completed", +} diff --git a/circleci-snap-in/code/src/functions/sync_circleci_data/utils.ts b/circleci-snap-in/code/src/functions/sync_circleci_data/utils.ts new file mode 100644 index 0000000..50b22ec --- /dev/null +++ b/circleci-snap-in/code/src/functions/sync_circleci_data/utils.ts @@ -0,0 +1,120 @@ +import { client, betaSDK } from "@devrev/typescript-sdk"; +import { AxiosResponse } from "axios"; + +export type HTTPResponse = { + success: boolean; + message: string; + data: any; +}; + +export const defaultResponse: HTTPResponse = { + data: {}, + message: "", + success: false, +}; + +export class ApiUtils { + public devrevSdk!: betaSDK.Api; + + // Constructor to initialize SDK instances + constructor(endpoint: string, token: string) { + this.devrevSdk = client.setupBeta({ + endpoint: endpoint, + token: token, + }); + } + + // Create a timeline entry for a CircleCI step + async createTimeLine( + payload: betaSDK.TimelineEntriesCreateRequest, + ): Promise { + try { + const response: AxiosResponse = + await this.devrevSdk.timelineEntriesCreate(payload); + return { + data: response.data, + message: "Timeline entry created successfully", + success: true, + }; + } catch (error: any) { + if (error.response) { + const err = `Failed to create timeline entry. Err: ${JSON.stringify(error.response.data)}, Status: ${ + error.response.status + }`; + return { ...defaultResponse, message: err }; + } else { + return { ...defaultResponse, message: error.message }; + } + } + } + + // Update a timeline entry + async updateTimeLine( + payload: betaSDK.TimelineEntriesUpdateRequest, + ): Promise { + try { + const response: AxiosResponse = + await this.devrevSdk.timelineEntriesUpdate(payload); + return { + data: response.data, + message: "Timeline updated successfully", + success: true, + }; + } catch (error: any) { + if (error.response) { + const err = `Failed to update timeline. Err: ${JSON.stringify(error.response.data)}, Status: ${ + error.response.status + }`; + return { ...defaultResponse, message: err }; + } else { + return { ...defaultResponse, message: error.message }; + } + } + } + + // Create an Issue/Task + async createIssueOrTask( + payload: betaSDK.WorksCreateRequest, + ): Promise { + try { + const response: AxiosResponse = await this.devrevSdk.worksCreate(payload); + return { + data: response.data, + message: "Ticket created successfully", + success: true, + }; + } catch (error: any) { + if (error.response) { + const err = `Failed to create ticket. Err: ${JSON.stringify(error.response.data)}, Status: ${ + error.response.status + }`; + return { ...defaultResponse, message: err }; + } else { + return { ...defaultResponse, message: error.message }; + } + } + } + + // TODO: handle the scenario where part is already created + async createPart( + payload: betaSDK.PartsCreateRequest, + ): Promise { + try { + const response: AxiosResponse = await this.devrevSdk.partsCreate(payload); + return { + data: response.data, + message: "Part created successfully", + success: true, + }; + } catch (error: any) { + if (error.response) { + const err = `Failed to create part. Err: ${JSON.stringify(error.response.data)}, Status: ${ + error.response.status + }`; + return { ...defaultResponse, message: err }; + } else { + return { ...defaultResponse, message: error.message }; + } + } + } +} diff --git a/circleci-snap-in/code/src/index.ts b/circleci-snap-in/code/src/index.ts new file mode 100644 index 0000000..8d548a8 --- /dev/null +++ b/circleci-snap-in/code/src/index.ts @@ -0,0 +1 @@ +export * from "./function-factory"; diff --git a/circleci-snap-in/code/src/main.ts b/circleci-snap-in/code/src/main.ts new file mode 100644 index 0000000..617a7ea --- /dev/null +++ b/circleci-snap-in/code/src/main.ts @@ -0,0 +1,27 @@ +import yargs from 'yargs'; +import { hideBin } from 'yargs/helpers'; + +import { FunctionFactoryType } from './function-factory'; +import { testRunner } from './test-runner/test-runner'; + +(async () => { + const argv = await yargs(hideBin(process.argv)).options({ + fixturePath: { + require: true, + type: 'string', + }, + functionName: { + require: true, + type: 'string', + }, + }).argv; + + if (!argv.fixturePath || !argv.functionName) { + console.error('Please make sure you have passed fixturePath & functionName'); + } + + await testRunner({ + fixturePath: argv.fixturePath, + functionName: argv.functionName as FunctionFactoryType, + }); +})(); \ No newline at end of file diff --git a/circleci-snap-in/code/src/test-runner/test-runner.ts b/circleci-snap-in/code/src/test-runner/test-runner.ts new file mode 100644 index 0000000..ba573b7 --- /dev/null +++ b/circleci-snap-in/code/src/test-runner/test-runner.ts @@ -0,0 +1,28 @@ +import * as dotenv from "dotenv"; +import { functionFactory, FunctionFactoryType } from "../function-factory"; + +export interface TestRunnerProps { + functionName: FunctionFactoryType; + fixturePath: string; +} + +export const testRunner = async ({ + functionName, + fixturePath, +}: TestRunnerProps) => { + dotenv.config(); + + if (!functionFactory[functionName]) { + console.error(`${functionName} is not found in the functionFactory`); + console.error("Add your function to the function-factory.ts file"); + throw new Error("Function is not found in the functionFactory"); + } + + //Since the import is loaded dynamically, we need to use require + const run = functionFactory[functionName]; + + // eslint-disable-next-line @typescript-eslint/no-var-requires + const eventFixture = require(`../fixtures/${fixturePath}`); + + await run(eventFixture); +}; diff --git a/circleci-snap-in/code/tsconfig.json b/circleci-snap-in/code/tsconfig.json new file mode 100644 index 0000000..3de219c --- /dev/null +++ b/circleci-snap-in/code/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "target": "es2016", + "module": "commonjs", + "baseUrl": "./", + "paths": { + "*": ["./src/*"] + }, + "outDir": "./dist", + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "strict": true, + "skipLibCheck": true, + "declaration": true, + "allowJs": true, + "allowSyntheticDefaultImports": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true + }, + "include": ["src"], + "exclude": ["node_modules", "dist"] +} From 9c8daf9a50a79127f09f73c1f2adecfa07bcf4e9 Mon Sep 17 00:00:00 2001 From: rushilv14 <34117892-rushilv14@users.noreply.replit.com> Date: Sun, 23 Feb 2025 09:11:48 +0000 Subject: [PATCH 03/16] update manifest.yaml and add test cases --- circleci-snap-in/code/src/fixtures/type1.json | 72 +++++++++++++++ circleci-snap-in/code/src/fixtures/type2.json | 79 +++++++++++++++++ circleci-snap-in/code/src/fixtures/type3.json | 87 +++++++++++++++++++ circleci-snap-in/code/src/fixtures/type4.json | 87 +++++++++++++++++++ circleci-snap-in/manifest.yaml | 2 +- 5 files changed, 326 insertions(+), 1 deletion(-) create mode 100644 circleci-snap-in/code/src/fixtures/type1.json create mode 100644 circleci-snap-in/code/src/fixtures/type2.json create mode 100644 circleci-snap-in/code/src/fixtures/type3.json create mode 100644 circleci-snap-in/code/src/fixtures/type4.json diff --git a/circleci-snap-in/code/src/fixtures/type1.json b/circleci-snap-in/code/src/fixtures/type1.json new file mode 100644 index 0000000..3b5b09a --- /dev/null +++ b/circleci-snap-in/code/src/fixtures/type1.json @@ -0,0 +1,72 @@ +[ + { + "payload": { + "id": "3888f21b-eaa7-38e3-8f3d-75a63bba8895", + "type": "workflow-completed", + "happened_at": "2021-09-01T22:49:34.317Z", + "webhook": { + "id": "cf8c4fdd-0587-4da1-b4ca-4846e9640af9", + "name": "Sample Webhook" + }, + "project": { + "id": "84996744-a854-4f5e-aea3-04e2851dc1d2", + "name": "webhook-service", + "slug": "github/circleci/webhook-service" + }, + "organization": { + "id": "f22b6566-597d-46d5-ba74-99ef5bb3d85c", + "name": "circleci" + }, + "workflow": { + "id": "fda08377-fe7e-46b1-8992-3a7aaecac9c3", + "name": "build-test-deploy", + "created_at": "2021-09-01T22:49:03.616Z", + "stopped_at": "2021-09-01T22:49:34.170Z", + "url": "https://app.circleci.com/pipelines/github/circleci/webhook-service/130/workflows/fda08377-fe7e-46b1-8992-3a7aaecac9c3", + "status": "success" + }, + "pipeline": { + "id": "1285fe1d-d3a6-44fc-8886-8979558254c4", + "number": 130, + "created_at": "2021-09-01T22:49:03.544Z", + "trigger": { + "type": "webhook" + }, + "vcs": { + "provider_name": "github", + "origin_repository_url": "https://github.com/circleci/webhook-service", + "target_repository_url": "https://github.com/circleci/webhook-service", + "revision": "1dc6aa69429bff4806ad6afe58d3d8f57e25973e", + "commit": { + "subject": "Description of change", + "body": "More details about the change", + "author": { + "name": "Author Name", + "email": "author.email@example.com" + }, + "authored_at": "2021-09-01T22:48:53Z", + "committer": { + "name": "Committer Name", + "email": "committer.email@example.com" + }, + "committed_at": "2021-09-01T22:48:53Z" + }, + "branch": "main" + } + } + }, + "context": { + "dev_oid": "don:identity:dvrv-us-1:devo/XXXXXX", + "automation_id": "don:integration:dvrv-us-1:devo/XXXXXX:automation/be9f0869-77a4-4210-9f84-47409e67c781", + "source_id": "don:integration:dvrv-us-1:devo/XXXXXX:automation/be9f0869-77a4-4210-9f84-47409e67c781", + "snap_in_id": "don:integration:dvrv-us-1:devo/XXXXXX:snap_in/641c009b-0476-40ef-b728-f3ce6fb77bb9", + "snap_in_version_id": "don:integration:dvrv-us-1:devo/XXXXXX:snap_in_package/fd20d23b-372c-48ad-ac24-d13c271c63d6:snap_in_version/d506f96a-131f-451c-87d6-e73605fac8df", + "secrets": { + "service_account_token": "TEST-TOKEN" + } + }, + "execution_metadata": { + "devrev_endpoint": "https://api.devrev.ai" + } + } +] \ No newline at end of file diff --git a/circleci-snap-in/code/src/fixtures/type2.json b/circleci-snap-in/code/src/fixtures/type2.json new file mode 100644 index 0000000..220cd5f --- /dev/null +++ b/circleci-snap-in/code/src/fixtures/type2.json @@ -0,0 +1,79 @@ +[ + { + "payload": { + "id": "8bd71c28-4969-3677-8940-3e3a61c46660", + "type": "job-completed", + "happened_at": "2021-09-01T22:49:34.279Z", + "webhook": { + "id": "cf8c4fdd-0587-4da1-b4ca-4846e9640af9", + "name": "Sample Webhook" + }, + "project": { + "id": "84996744-a854-4f5e-aea3-04e2851dc1d2", + "name": "webhook-service", + "slug": "github/circleci/webhook-service" + }, + "organization": { + "id": "f22b6566-597d-46d5-ba74-99ef5bb3d85c", + "name": "circleci" + }, + "pipeline": { + "id": "1285fe1d-d3a6-44fc-8886-8979558254c4", + "number": 130, + "created_at": "2021-09-01T22:49:03.544Z", + "trigger": { + "type": "webhook" + }, + "vcs": { + "provider_name": "github", + "origin_repository_url": "https://github.com/circleci/webhook-service", + "target_repository_url": "https://github.com/circleci/webhook-service", + "revision": "1dc6aa69429bff4806ad6afe58d3d8f57e25973e", + "commit": { + "subject": "Description of change", + "body": "More details about the change", + "author": { + "name": "Author Name", + "email": "author.email@example.com" + }, + "authored_at": "2021-09-01T22:48:53Z", + "committer": { + "name": "Committer Name", + "email": "committer.email@example.com" + }, + "committed_at": "2021-09-01T22:48:53Z" + }, + "branch": "main" + } + }, + "workflow": { + "id": "fda08377-fe7e-46b1-8992-3a7aaecac9c3", + "name": "welcome", + "created_at": "2021-09-01T22:49:03.616Z", + "stopped_at": "2021-09-01T22:49:34.170Z", + "url": "https://app.circleci.com/pipelines/github/circleci/webhook-service/130/workflows/fda08377-fe7e-46b1-8992-3a7aaecac9c3" + }, + "job": { + "id": "8b91f9a8-7975-4e60-916c-f0152ccbc937", + "name": "test", + "started_at": "2021-09-01T22:49:28.841Z", + "stopped_at": "2021-09-01T22:49:34.170Z", + "status": "success", + "number": 136 + } + }, + "context": { + "dev_oid": "don:identity:dvrv-us-1:devo/XXXXXX", + "automation_id": "don:integration:dvrv-us-1:devo/XXXXXX:automation/be9f0869-77a4-4210-9f84-47409e67c781", + "source_id": "don:integration:dvrv-us-1:devo/XXXXXX:automation/be9f0869-77a4-4210-9f84-47409e67c781", + "snap_in_id": "don:integration:dvrv-us-1:devo/XXXXXX:snap_in/641c009b-0476-40ef-b728-f3ce6fb77bb9", + "snap_in_version_id": "don:integration:dvrv-us-1:devo/XXXXXX:snap_in_package/fd20d23b-372c-48ad-ac24-d13c271c63d6:snap_in_version/d506f96a-131f-451c-87d6-e73605fac8df", + "secrets": { + "service_account_token": "TEST-TOKEN" + } + }, + "execution_metadata": { + "devrev_endpoint": "https://api.devrev.ai" + } + } +] diff --git a/circleci-snap-in/code/src/fixtures/type3.json b/circleci-snap-in/code/src/fixtures/type3.json new file mode 100644 index 0000000..94b4371 --- /dev/null +++ b/circleci-snap-in/code/src/fixtures/type3.json @@ -0,0 +1,87 @@ +[ + { + "payload": { + "type": "workflow-completed", + "id": "cbabbb40-6084-4f91-8311-a326c0f4963a", + "happened_at": "2022-05-27T16:20:13.954328Z", + "webhook": { + "id": "e4da0d23-31cf-4047-8a7e-8ffb14cd0100", + "name": "test" + }, + "workflow": { + "id": "c2006ece-778d-49fc-9e6e-b9965f72bee9", + "name": "build", + "created_at": "2022-05-27T16:20:07.631Z", + "stopped_at": "2022-05-27T16:20:13.812Z", + "url": "https://app.circleci.com/pipelines/circleci/DdaVtNusHqi24D4YT3X4eu/6EkDPZoN4ZdMKKZtBkRodt/1/workflows/c2006ece-778d-49fc-9e6e-b9965f72bee9", + "status": "failed" + }, + "pipeline": { + "id": "37c74cb7-d64d-4032-8731-1cb95bfef921", + "number": 1, + "created_at": "2022-04-13T11:10:18.804Z", + "trigger": { + "type": "gitlab" + }, + "trigger_parameters": { + "gitlab": { + "web_url": "https://gitlab.com/circleci/hello-world", + "commit_author_name": "Commit Author", + "user_id": "9534789", + "user_name": "User name", + "user_username": "username", + "branch": "main", + "commit_title": "Update README.md", + "commit_message": "Update README.md", + "total_commits_count": "1", + "repo_url": "git@gitlab.com:circleci/hello-world.git", + "user_avatar": "https://secure.gravatar.com/avatar", + "type": "push", + "project_id": "33852820", + "ref": "refs/heads/main", + "repo_name": "hello-world", + "commit_author_email": "committer.email@example.com", + "checkout_sha": "850a1519f25d14e968649cc420d1bd381715c05c", + "commit_timestamp": "2022-04-13T11:10:16+00:00", + "commit_sha": "850a1519f25d14e968649cc420d1bd381715c05c" + }, + "git": { + "tag": "", + "checkout_sha": "850a1519f25d14e968649cc420d1bd381715c05c", + "ref": "refs/heads/main", + "branch": "main", + "checkout_url": "git@gitlab.com:circleci/hello-world.git" + }, + "circleci": { + "event_time": "2022-04-13T11:10:18.349Z", + "actor_id": "6a19122c-40e0-4d56-a875-aac6ccc27700", + "event_type": "push", + "trigger_type": "gitlab" + } + } + }, + "project": { + "id": "2a68fe5f-2fe5-4d4f-91e1-15f111116743", + "name": "hello-world", + "slug": "circleci/DdaVtNusHqi24D4YT3X4eu/6EkDPZoN4ZdMKKZtBkRodt" + }, + "organization": { + "id": "66491562-90a9-4065-9249-4b0ce3b77452", + "name": "circleci" + } + }, + "context": { + "dev_oid": "don:identity:dvrv-us-1:devo/XXXXXX", + "automation_id": "don:integration:dvrv-us-1:devo/XXXXXX:automation/be9f0869-77a4-4210-9f84-47409e67c781", + "source_id": "don:integration:dvrv-us-1:devo/XXXXXX:automation/be9f0869-77a4-4210-9f84-47409e67c781", + "snap_in_id": "don:integration:dvrv-us-1:devo/XXXXXX:snap_in/641c009b-0476-40ef-b728-f3ce6fb77bb9", + "snap_in_version_id": "don:integration:dvrv-us-1:devo/XXXXXX:snap_in_package/fd20d23b-372c-48ad-ac24-d13c271c63d6:snap_in_version/d506f96a-131f-451c-87d6-e73605fac8df", + "secrets": { + "service_account_token": "TEST-TOKEN" + } + }, + "execution_metadata": { + "devrev_endpoint": "https://api.devrev.ai" + } + } +] \ No newline at end of file diff --git a/circleci-snap-in/code/src/fixtures/type4.json b/circleci-snap-in/code/src/fixtures/type4.json new file mode 100644 index 0000000..d07a652 --- /dev/null +++ b/circleci-snap-in/code/src/fixtures/type4.json @@ -0,0 +1,87 @@ +[ + { + "payload": { + "type": "job-completed", + "id": "47a497be-4498-4da0-a4e8-2dabd889af0f", + "happened_at": "2022-05-27T16:20:13.954328Z", + "webhook": { + "id": "e4da0d23-31cf-4047-8a7e-8ffb14cd0100", + "name": "test" + }, + "job": { + "id": "2fc6977d-7e45-4271-b355-0ea894d82017", + "name": "say-hello", + "started_at": "2022-07-11T12:16:37.435Z", + "stopped_at": "2022-07-11T12:16:59.982Z", + "status": "success", + "number": 1 + }, + "pipeline": { + "id": "37c74cb7-d64d-4032-8731-1cb95bfef921", + "number": 1, + "created_at": "2022-04-13T11:10:18.804Z", + "trigger": { + "type": "gitlab" + }, + "trigger_parameters": { + "gitlab": { + "web_url": "https://gitlab.com/circleci/hello-world", + "commit_author_name": "Commit Author", + "user_id": "9534789", + "user_name": "User name", + "user_username": "username", + "branch": "main", + "commit_title": "Update README.md", + "commit_message": "Update README.md", + "total_commits_count": "1", + "repo_url": "git@gitlab.com:circleci/hello-world.git", + "user_avatar": "https://secure.gravatar.com/avatar", + "type": "push", + "project_id": "33852820", + "ref": "refs/heads/main", + "repo_name": "hello-world", + "commit_author_email": "committer.email@example.com", + "checkout_sha": "850a1519f25d14e968649cc420d1bd381715c05c", + "commit_timestamp": "2022-04-13T11:10:16+00:00", + "commit_sha": "850a1519f25d14e968649cc420d1bd381715c05c" + }, + "git": { + "tag": "", + "checkout_sha": "850a1519f25d14e968649cc420d1bd381715c05c", + "ref": "refs/heads/main", + "branch": "main", + "checkout_url": "git@gitlab.com:circleci/hello-world.git" + }, + "circleci": { + "event_time": "2022-04-13T11:10:18.349Z", + "actor_id": "6a19122c-40e0-4d56-a875-aac6ccc27700", + "event_type": "push", + "trigger_type": "gitlab" + } + } + }, + "project": { + "id": "2a68fe5f-2fe5-4d4f-91e1-15f111116743", + "name": "hello-world", + "slug": "circleci/DdaVtNusHqi24D4YT3X4eu/6EkDPZoN4ZdMKKZtBkRodt" + }, + "organization": { + "id": "66491562-90a9-4065-9249-4b0ce3b77452", + "name": "circleci" + } + }, + "context": { + "dev_oid": "don:identity:dvrv-us-1:devo/XXXXXX", + "automation_id": "don:integration:dvrv-us-1:devo/XXXXXX:automation/be9f0869-77a4-4210-9f84-47409e67c781", + "source_id": "don:integration:dvrv-us-1:devo/XXXXXX:automation/be9f0869-77a4-4210-9f84-47409e67c781", + "snap_in_id": "don:integration:dvrv-us-1:devo/XXXXXX:snap_in/641c009b-0476-40ef-b728-f3ce6fb77bb9", + "snap_in_version_id": "don:integration:dvrv-us-1:devo/XXXXXX:snap_in_package/fd20d23b-372c-48ad-ac24-d13c271c63d6:snap_in_version/d506f96a-131f-451c-87d6-e73605fac8df", + "secrets": { + "service_account_token": "TEST-TOKEN" + } + }, + "execution_metadata": { + "devrev_endpoint": "https://api.devrev.ai" + } + } +] \ No newline at end of file diff --git a/circleci-snap-in/manifest.yaml b/circleci-snap-in/manifest.yaml index 85e3fee..6f9763b 100644 --- a/circleci-snap-in/manifest.yaml +++ b/circleci-snap-in/manifest.yaml @@ -92,4 +92,4 @@ functions: description: Generate insights based on data pulled from CircleCI. The insights could be one of :- issue_creation OR build_failure_analysis. - name: sync_circleci_data - description: Sync CircleCI data to DevRev. \ No newline at end of file + description: Sync CircleCI data to DevRev. From d4b24ec4fda42ae318fef4e07b881d1617ba80ee Mon Sep 17 00:00:00 2001 From: rushilv14 <34117892-rushilv14@users.noreply.replit.com> Date: Sun, 23 Feb 2025 09:13:10 +0000 Subject: [PATCH 04/16] add README --- circleci-snap-in/README.md | 67 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 circleci-snap-in/README.md diff --git a/circleci-snap-in/README.md b/circleci-snap-in/README.md new file mode 100644 index 0000000..b44eb6a --- /dev/null +++ b/circleci-snap-in/README.md @@ -0,0 +1,67 @@ +# CircleCI Snap-in + +Snap-in that syncs pipeline, workflow and jobs to DevRev using webhooks. +There is also a command to generate AI insights from the synced data. The insights could be one of the following: +1. Flaky Test Issue Creation (issue_creation) + 1. The command creates an Issue for the Flaky Test. + 2. The issue includes details from the CircleCI API response like test name, classname, file, times flaked, and the workflow and job information. + 3. The AI agent intelligently assigns the issue to the developer most recently associated with the code or test file, streamlining investigation. +2. Intelligent Build Failure Analysis (build_failure_analysis) + 1. Command pulls build logs from CircleCI. + 2. Analyze the logs to identify root causes, error messages, and potential solutions. + 3. AI agent posts a comment on the associated DevRev issue summarizing the analysis and suggesting troubleshooting steps. + +To run the command : +``` +/generateInsights pipeline_id command_type +``` + +## Requirements +1. CircleCI Account API Key +2. CircleCI Project Slug +3. Configuration of CircleCI Outbound Webhook [refer here](https://circleci.com/docs/webhooks/) + +## Testing locally + +Test the code by adding test events under `src/fixtures` similar to the example event provided. You can add [keyring](https://docs.devrev.ai/snap-ins/references/keyrings) values to the event payload to test API calls as well. + +Once you have added the event, you can test your code by running: + +``` +npm install +npm run start -- --functionName=command_handler --fixturePath=on_command.json +``` + +## Activating Snap-Ins + +Once you are done with the testing, run the following commands to activate your snap_in: + +1. Authenticate to devrev CLI + +``` +devrev profiles authenticate --org --usr +``` + +2. Create a snap_in_version + +``` +devrev snap_in_version create-one --path