diff --git a/.gitignore b/.gitignore index 0f6b12a..4b8a692 100644 --- a/.gitignore +++ b/.gitignore @@ -129,4 +129,5 @@ dist .yarn/install-state.gz .pnp.* -/src/infisicalapi_client \ No newline at end of file +/src/infisicalapi_client +/lib diff --git a/package-lock.json b/package-lock.json index 673e56f..06b6464 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,6 +18,7 @@ }, "devDependencies": { "@openapitools/openapi-generator-cli": "^2.13.5", + "@types/node": "^22.5.1", "tsc": "^2.0.4" } }, @@ -1705,6 +1706,16 @@ "node": ">=14.0.0" } }, + "node_modules/@types/node": { + "version": "22.5.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.1.tgz", + "integrity": "sha512-KkHsxej0j9IW1KKOOAA/XBA0z08UFSrRQHErzEfA3Vgq57eXIMYboIlHJuYIfd+lwCQjtKqUu3UnmKbtUc9yRw==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~6.19.2" + } + }, "node_modules/agent-base": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.1.tgz", @@ -2952,6 +2963,13 @@ "node": ">=8" } }, + "node_modules/undici-types": { + "version": "6.19.8", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", + "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==", + "dev": true, + "license": "MIT" + }, "node_modules/universalify": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", diff --git a/package.json b/package.json index 5b63739..8501254 100644 --- a/package.json +++ b/package.json @@ -1,16 +1,30 @@ { - "name": "infisical-node-sdk", - "version": "1.0.0", - "main": "index.js", + "name": "@infisical/sdk-v2", + "version": "0.0.0", + "main": "./lib/index.js", + "files": [ + "lib" + ], "scripts": { - "generate-api:infisical": "openapi-generator-cli generate -i https://app.infisical.com/api/docs/json -g typescript-axios -o ./src/infisicalapi_client --skip-validate-spec --additional-properties=useSingleRequestParameter=true,withSeparateModelsAndApi=true,apiPackage=server,modelPackage=model --openapi-normalizer REFACTOR_ALLOF_WITH_PROPERTIES_ONLY=true", "build": "tsc && cp -R ./src/types ./lib" + "generate-api:infisical": "openapi-generator-cli generate -i https://app.infisical.com/api/docs/json -g typescript-axios -o ./src/infisicalapi_client --skip-validate-spec --additional-properties=useSingleRequestParameter=true,withSeparateModelsAndApi=true,apiPackage=server,modelPackage=model --openapi-normalizer REFACTOR_ALLOF_WITH_PROPERTIES_ONLY=true", + "build": "tsc" }, - "keywords": [], - "author": "", + "keywords": [ + "infisical", + "open-source", + "sdk", + "typescript" + ], + "repository": { + "type": "git", + "url": "https://github.com/infisical/infisical-node-sdk" + }, + "author": "Infisical Inc, ", "license": "ISC", "description": "", "devDependencies": { "@openapitools/openapi-generator-cli": "^2.13.5", + "@types/node": "^22.5.1", "tsc": "^2.0.4" }, "dependencies": { diff --git a/test/filtered-spec.json b/test/filtered-spec.json deleted file mode 100644 index 8d33151..0000000 --- a/test/filtered-spec.json +++ /dev/null @@ -1,292 +0,0 @@ -{ - "openapi": "3.0.3", - "info": { - "title": "Infisical API", - "description": "List of all available APIs that can be consumed", - "version": "0.0.1" - }, - "components": { - "securitySchemes": { - "bearerAuth": { - "type": "http", - "scheme": "bearer", - "bearerFormat": "JWT", - "description": "An access token in Infisical" - } - }, - "schemas": {} - }, - "paths": { - "/api/v1/identities": { - "get": { - "description": "List identities", - "parameters": [ - { - "schema": { - "type": "string" - }, - "in": "query", - "name": "orgId", - "required": true, - "description": "The ID of the organization to list identities." - } - ], - "security": [ - { - "bearerAuth": [] - } - ], - "responses": { - "200": { - "description": "Default Response", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "identities": { - "type": "array", - "items": { - "type": "object", - "properties": { - "id": { - "type": "string", - "format": "uuid" - }, - "role": { - "type": "string" - }, - "roleId": { - "type": "string", - "format": "uuid", - "nullable": true - }, - "orgId": { - "type": "string", - "format": "uuid" - }, - "createdAt": { - "type": "string", - "format": "date-time" - }, - "updatedAt": { - "type": "string", - "format": "date-time" - }, - "identityId": { - "type": "string", - "format": "uuid" - }, - "customRole": { - "type": "object", - "properties": { - "id": { - "type": "string", - "format": "uuid" - }, - "name": { - "type": "string" - }, - "slug": { - "type": "string" - }, - "permissions": {}, - "description": { - "type": "string", - "nullable": true - } - }, - "required": [ - "id", - "name", - "slug" - ], - "additionalProperties": false - }, - "identity": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "id": { - "type": "string", - "format": "uuid" - }, - "authMethod": { - "type": "string", - "nullable": true - } - }, - "required": [ - "name", - "id" - ], - "additionalProperties": false - } - }, - "required": [ - "id", - "role", - "orgId", - "createdAt", - "updatedAt", - "identityId", - "identity" - ], - "additionalProperties": false - } - } - }, - "required": [ - "identities" - ], - "additionalProperties": false - } - } - } - } - } - } - }, - "/api/v1/identities/{identityId}": { - "get": { - "description": "Get an identity by id", - "parameters": [ - { - "schema": { - "type": "string" - }, - "in": "path", - "name": "identityId", - "required": true, - "description": "The ID of the identity to get details." - } - ], - "security": [ - { - "bearerAuth": [] - } - ], - "responses": { - "200": { - "description": "Default Response", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "identity": { - "type": "object", - "properties": { - "id": { - "type": "string", - "format": "uuid" - }, - "role": { - "type": "string" - }, - "roleId": { - "type": "string", - "format": "uuid", - "nullable": true - }, - "orgId": { - "type": "string", - "format": "uuid" - }, - "createdAt": { - "type": "string", - "format": "date-time" - }, - "updatedAt": { - "type": "string", - "format": "date-time" - }, - "identityId": { - "type": "string", - "format": "uuid" - }, - "customRole": { - "type": "object", - "properties": { - "id": { - "type": "string", - "format": "uuid" - }, - "name": { - "type": "string" - }, - "slug": { - "type": "string" - }, - "permissions": {}, - "description": { - "type": "string", - "nullable": true - } - }, - "required": [ - "id", - "name", - "slug" - ], - "additionalProperties": false - }, - "identity": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "id": { - "type": "string", - "format": "uuid" - }, - "authMethod": { - "type": "string", - "nullable": true - } - }, - "required": [ - "name", - "id" - ], - "additionalProperties": false - } - }, - "required": [ - "id", - "role", - "orgId", - "createdAt", - "updatedAt", - "identityId", - "identity" - ], - "additionalProperties": false - } - }, - "required": [ - "identity" - ], - "additionalProperties": false - } - } - } - } - } - } - } - }, - "servers": [ - { - "url": "https://app.infisical.com", - "description": "Production server" - }, - { - "url": "http://localhost:8080", - "description": "Local server" - } - ] -} \ No newline at end of file diff --git a/test/index.js b/test/index.js new file mode 100644 index 0000000..6ac50d3 --- /dev/null +++ b/test/index.js @@ -0,0 +1,17 @@ +const { InfisicalSDK } = require("../lib"); + +(async () => { + const client = new InfisicalSDK(); + + await client.auth().universalAuth.login({ + clientId: "CLIENT_ID", + clientSecret: "CLIENT_SECRET" + }); + + const secrets = await client.secrets().listSecrets({ + environment: "dev", + workspaceId: "PROJECT_ID" + }); + + console.log(secrets.secrets); +})(); diff --git a/test/openapitools.json b/test/openapitools.json deleted file mode 100644 index 2f4612c..0000000 --- a/test/openapitools.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "$schema": "./node_modules/@openapitools/openapi-generator-cli/config.schema.json", - "spaces": 2, - "generator-cli": { - "version": "7.8.0" - } -} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..5521551 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + "target": "es6", + "module": "commonjs", + "declaration": true, + "rootDir": "./src", + "outDir": "./lib", + "strict": true, + "resolveJsonModule": true, + "removeComments": true, + "esModuleInterop": true + }, + "include": [".", "src"], + "exclude": ["examples", "node_modules", "lib", "test"] +}