From f2f4785a6dc711618f7cf5f9ad29efb7b163cf3c Mon Sep 17 00:00:00 2001 From: Daniel Hougaard Date: Thu, 29 Aug 2024 03:43:28 +0400 Subject: [PATCH] Finishing touches --- .gitignore | 3 +- package-lock.json | 47 ++++++- package.json | 10 +- test/filtered-spec.json | 292 ---------------------------------------- test/index.js | 17 +++ test/openapitools.json | 7 - tsconfig.json | 15 +++ 7 files changed, 86 insertions(+), 305 deletions(-) delete mode 100644 test/filtered-spec.json create mode 100644 test/index.js delete mode 100644 test/openapitools.json create mode 100644 tsconfig.json diff --git a/.gitignore b/.gitignore index e6a6175..f67aa48 100644 --- a/.gitignore +++ b/.gitignore @@ -129,4 +129,5 @@ dist .yarn/install-state.gz .pnp.* -/src/api/infisical/model/*.ts \ No newline at end of file +/src/api/infisical/model/*.ts +/lib \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 91454ab..06b6464 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,10 +13,13 @@ "@aws-sdk/credential-provider-node": "^3.637.0", "@aws-sdk/credential-providers": "^3.637.0", "@aws-sdk/signature-v4": "^3.374.0", - "axios": "^1.7.5" + "axios": "^1.7.5", + "typescript": "^5.5.4" }, "devDependencies": { - "@openapitools/openapi-generator-cli": "^2.13.5" + "@openapitools/openapi-generator-cli": "^2.13.5", + "@types/node": "^22.5.1", + "tsc": "^2.0.4" } }, "node_modules/@aws-crypto/crc32": { @@ -1703,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", @@ -2895,6 +2908,16 @@ "tree-kill": "cli.js" } }, + "node_modules/tsc": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/tsc/-/tsc-2.0.4.tgz", + "integrity": "sha512-fzoSieZI5KKJVBYGvwbVZs/J5za84f2lSTLPYf6AGiIf43tZ3GNrI1QzTLcjtyDDP4aLxd46RTZq1nQxe7+k5Q==", + "dev": true, + "license": "MIT", + "bin": { + "tsc": "bin/tsc" + } + }, "node_modules/tslib": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", @@ -2914,6 +2937,19 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/typescript": { + "version": "5.5.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.4.tgz", + "integrity": "sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==", + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, "node_modules/uid": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/uid/-/uid-2.0.2.tgz", @@ -2927,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 1ab7d28..bfc8f58 100644 --- a/package.json +++ b/package.json @@ -3,20 +3,24 @@ "version": "1.0.0", "main": "index.js", "scripts": { - "generate-api:infisical": "openapi-generator-cli generate -i https://app.infisical.com/api/docs/json -g typescript-axios -o ./src/api/infisical/ --skip-validate-spec --additional-properties=useSingleRequestParameter=true" + "generate-api:infisical": "openapi-generator-cli generate -i https://app.infisical.com/api/docs/json -g typescript-axios -o ./src/api/infisical/ --skip-validate-spec --additional-properties=useSingleRequestParameter=true", + "build": "tsc" }, "keywords": [], "author": "", "license": "ISC", "description": "", "devDependencies": { - "@openapitools/openapi-generator-cli": "^2.13.5" + "@openapitools/openapi-generator-cli": "^2.13.5", + "@types/node": "^22.5.1", + "tsc": "^2.0.4" }, "dependencies": { "@aws-crypto/sha256-js": "^5.2.0", "@aws-sdk/credential-provider-node": "^3.637.0", "@aws-sdk/credential-providers": "^3.637.0", "@aws-sdk/signature-v4": "^3.374.0", - "axios": "^1.7.5" + "axios": "^1.7.5", + "typescript": "^5.5.4" } } 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"] +}