@devrev/typescript-sdk 1.0.2 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +31 -48
  3. package/package.json +17 -10
  4. package/.eslintignore +0 -2
  5. package/.github/workflows/npm-publish.yml +0 -27
  6. package/.prettierignore +0 -4
  7. package/.prettierrc +0 -15
  8. package/.vscode/extensions.json +0 -8
  9. package/.vscode/launch.json +0 -17
  10. package/.vscode/settings.json +0 -31
  11. package/USER_README.md +0 -16
  12. package/nodemon.json +0 -5
  13. package/src/auto-generated/beta/beta-devrev-sdk.ts +0 -1826
  14. package/src/auto-generated/internal/private-internal-devrev-sdk.ts +0 -54739
  15. package/src/auto-generated/public-devrev-sdk.ts +0 -4009
  16. package/src/beta-data-contracts.json +0 -3271
  17. package/src/client_setup.ts +0 -64
  18. package/src/private-internal-data-contracts.json +0 -98025
  19. package/src/public-data-contracts.json +0 -6922
  20. package/src/workflow/workflow.test.ts +0 -26
  21. package/src/workflow/workflow.ts +0 -54
  22. package/templates/README.md +0 -17
  23. package/templates/base/README.md +0 -8
  24. package/templates/base/data-contract-jsdoc.ejs +0 -37
  25. package/templates/base/data-contracts.ejs +0 -28
  26. package/templates/base/enum-data-contract.ejs +0 -12
  27. package/templates/base/http-client.ejs +0 -3
  28. package/templates/base/http-clients/axios-http-client.ejs +0 -138
  29. package/templates/base/http-clients/fetch-http-client.ejs +0 -224
  30. package/templates/base/interface-data-contract.ejs +0 -10
  31. package/templates/base/object-field-jsdoc.ejs +0 -28
  32. package/templates/base/route-docs.ejs +0 -30
  33. package/templates/base/route-name.ejs +0 -43
  34. package/templates/base/route-type.ejs +0 -22
  35. package/templates/base/type-data-contract.ejs +0 -15
  36. package/templates/default/README.md +0 -7
  37. package/templates/default/api.ejs +0 -64
  38. package/templates/default/procedure-call.ejs +0 -100
  39. package/templates/default/route-types.ejs +0 -26
  40. package/templates/modular/README.md +0 -7
  41. package/templates/modular/api.ejs +0 -28
  42. package/templates/modular/procedure-call.ejs +0 -100
  43. package/templates/modular/route-types.ejs +0 -18
  44. package/tsconfig.eslint.json +0 -4
  45. package/tsconfig.json +0 -25
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 DevRev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,69 +1,52 @@
1
- ### devrev-sdk-typescript
2
-
3
- ## SDK Generation
4
-
5
- `sync_api_contract.sh` is the script which fetches the latest OpenAPI specs from the gateway repo, and generates the i) Public SDK for Public APIs 2) Beta SDK for Beta APIs 3) Internal SDK for internal APIs.
6
-
7
- Code in this repo [specially those exposed via the SDK] must comply with the style guideline below: https://google.github.io/styleguide/tsguide.html
8
-
9
1
  # Authorization
10
2
 
11
- Setup an env variable "DEVREV_SDK_TOKEN" It will be used as an auth token by default, You can also pass in the url and token in client.setup()
12
-
13
- To run main.ts, do:
14
-
15
- ```
16
- npm run start:watch
17
- ```
3
+ Setup an env variable `DEVREV_TOKEN` It will be used as an auth token by default, You can also pass in the url and token in `client.setup()` as a param (see below). It is also required to run tests.
18
4
 
19
- Example Usage of the Public SDK
5
+ # Installation
20
6
 
21
7
  ```
22
- const devrevSDK = client.setup();
23
- (async () => {
24
- const response = await devrevSDK.worksGet({
25
- id: 'don:core:dvrv-us-1:devo/1DYPnPy0f:issue/8',
26
- });
27
-
28
- console.info(response.data.work.title);
29
- })();
8
+ npm install @devrev/typescript-sdk
30
9
  ```
10
+ The version can be found in package.json. The SDK is currently beta.
11
+ Make sure that your project's **package.json** contains `"type":"module"` setting.
31
12
 
32
- # Run tests:
13
+ # Example Usage of the Beta SDK
33
14
 
34
15
  ```
35
- npm test
36
- ```
16
+ import {client, betaSDK} from "@devrev/typescript-sdk";
37
17
 
38
- Check package.json for more options
18
+ const devrevInternalSDK = client.setupBeta({ endpoint: "https://api.devrev.ai",
19
+ token: process.env.DEVREV_TOKEN });
39
20
 
40
- #To setup the client:
21
+ async function test(){
22
+ const response = await devrevBetaSDK.worksCreate({title:"New work item!",
23
+ applies_to_part: "PROD-1",
24
+ owned_by:["DEVU-1"],
25
+ type: betaSDK.WorkType.Issue})
26
+ console.log(response)
27
+ }
41
28
 
42
- ```
43
- import * as sdk from '../auto-generated/public-devrev-sdk';
44
- import * as client from "../client_setup";
29
+ test()
45
30
 
46
- const devrevSDK = client.setup()
47
- const betaSDK = client.setupBeta()
48
31
  ```
49
32
 
50
- Examples how to create a work item can be found in tests/works.ts
33
+ # Example Usage of the Public SDK
51
34
 
52
- # Create a new test:
35
+ ```
36
+ import {client, publicSDK} from "@devrev/typescript-sdk";
53
37
 
54
- [Jest Documentation](https://jestjs.io/docs/expect)
38
+ const devrevSDK = client.setup({ endpoint: "https://api.devrev.ai", token: process.env.DEVREV_TOKEN });
55
39
 
56
- - Add a new test file in src/tests/ directory that contains the necessary functions for your tests.
57
- - To the file src/tests/test.ts add the test itself
40
+ async function test(){
41
+ const response = await devrevSDK.worksCreate({title:"New work item!", applies_to_part: "PROD-1", owned_by:["DEVU-16"], type: publicSDK.WorkType.Issue})
42
+ console.log(response.status)
43
+ }
58
44
 
59
- **Example test pipeline for works.ts:**
45
+ test()
46
+ ```
60
47
 
61
- 1. Prepare the environment (get the user, create a part and a tag) in init()
62
- 2. For /works.create endpoint in worksCreateGet create a work item, try getting it.
63
- - Assert the correctness of both calls by expect():
64
- - We check that responses have status 200 or 201, and that the data persists if compared to hard-coded and getResponse.
65
- 3. Repeat for other API endpoints
66
- 4. To check the correctness of /works.delete try deleting a work item twice and expect an error (await expect(works.works_delete_get(id)).rejects.toThrow())
67
- 5. Cleanup the environment (delete the created part and tag)
48
+ # Execute tests in the repo
49
+ ```
50
+ npm test
51
+ ```
68
52
 
69
- -- test readme change
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devrev/typescript-sdk",
3
- "version": "1.0.2",
3
+ "version": "1.1.3",
4
4
  "description": "## SDK Generation",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {
@@ -18,10 +18,10 @@
18
18
  },
19
19
  "keywords": [],
20
20
  "author": "devrev",
21
- "license": "ISC",
21
+ "license": "MIT",
22
22
  "devDependencies": {
23
23
  "@babel/core": "^7.20.12",
24
- "@babel/preset-env": "^7.21.4",
24
+ "@babel/preset-env": "^7.21.5",
25
25
  "@babel/preset-typescript": "^7.18.6",
26
26
  "@types/jest": "^29.4.0",
27
27
  "@types/node": "^18.13.0",
@@ -32,9 +32,9 @@
32
32
  "eslint-config-airbnb-typescript": "^17.0.0",
33
33
  "eslint-plugin-import": "^2.27.5",
34
34
  "eslint-plugin-prettier": "^4.2.1",
35
- "jest": "^29.5.0",
35
+ "jest": "^29.6.1",
36
36
  "nodemon": "^2.0.20",
37
- "prettier": "^2.8.3",
37
+ "prettier": "^2.8.8",
38
38
  "prettier-plugin-organize-imports": "^3.2.2",
39
39
  "rimraf": "^4.1.2",
40
40
  "ts-jest": "^29.0.5",
@@ -49,13 +49,20 @@
49
49
  },
50
50
  "repository": {
51
51
  "type": "git",
52
- "url": "git+https://github.com/devrev/devrev-sdk-typescript.git"
52
+ "url": "git+https://github.com/devrev/typescript-sdk.git"
53
53
  },
54
54
  "bugs": {
55
- "url": "https://github.com/devrev/devrev-sdk-typescript/issues"
55
+ "url": "https://github.com/devrev/typescript-sdk/issues"
56
56
  },
57
- "homepage": "https://github.com/devrev/devrev-sdk-typescript#readme",
57
+ "homepage": "https://github.com/devrev/typescript-sdk#readme",
58
58
  "publishConfig": {
59
- "registry": "https://registry.npmjs.org/"
59
+ "registry": "https://registry.npmjs.org"
60
+ },
61
+ "files": [
62
+ "dist"
63
+ ],
64
+ "types": "./dist/index.d.ts",
65
+ "directories": {
66
+ "examples": "examples"
60
67
  }
61
- }
68
+ }
package/.eslintignore DELETED
@@ -1,2 +0,0 @@
1
- ./src/auto-generated/**/*
2
- node_modules/**/*
@@ -1,27 +0,0 @@
1
- # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2
- # For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
3
-
4
- name: Node.js Package
5
-
6
- on:
7
- push:
8
- branches:
9
- - main
10
- release:
11
- types: [created]
12
-
13
- jobs:
14
- publish-npm:
15
- runs-on: ubuntu-latest
16
- if: contains(github.event.head_commit.message, 'publish sdk')
17
- steps:
18
- - uses: actions/checkout@v3
19
- - uses: actions/setup-node@v3
20
- with:
21
- node-version: 16
22
- registry-url: https://registry.npmjs.org/
23
- scope: '@devrev'
24
- - run: npm install
25
- - run: npm publish
26
- env:
27
- NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
package/.prettierignore DELETED
@@ -1,4 +0,0 @@
1
- # Add files here to ignore them from prettier formatting
2
-
3
- /dist
4
-
package/.prettierrc DELETED
@@ -1,15 +0,0 @@
1
- {
2
- "printWidth": 80,
3
- "tabWidth": 2,
4
- "useTabs": false,
5
- "semi": true,
6
- "singleQuote": true,
7
- "trailingComma": "es5",
8
- "bracketSpacing": true,
9
- "jsxSingleQuote": false,
10
- "arrowParens": "always",
11
- "proseWrap": "never",
12
- "htmlWhitespaceSensitivity": "strict",
13
- "endOfLine": "lf",
14
- "organizeImportsSkipDestructiveCodeActions": true
15
- }
@@ -1,8 +0,0 @@
1
- {
2
- "recommendations": [
3
- "dbaeumer.vscode-eslint",
4
- "esbenp.prettier-vscode",
5
- "firsttris.vscode-jest-runner",
6
- "pmneo.tsimporter"
7
- ]
8
- }
@@ -1,17 +0,0 @@
1
- {
2
- "version": "0.2.0",
3
- "configurations": [
4
- {
5
- "type": "node",
6
- "request": "launch",
7
- "name": "Debug TypeScript in Node.js",
8
- "preLaunchTask": "npm: start",
9
- "program": "${workspaceFolder}/src/main.ts",
10
- "protocol": "inspector",
11
- "outFiles": ["${workspaceFolder}/dist/**/*.js"],
12
- "sourceMaps": true,
13
- "smartStep": true,
14
- "internalConsoleOptions": "openOnSessionStart"
15
- }
16
- ]
17
- }
@@ -1,31 +0,0 @@
1
- {
2
- "[javascript]": {
3
- "editor.formatOnSave": true,
4
- "editor.defaultFormatter": "esbenp.prettier-vscode"
5
- },
6
- "[javascriptreact]": {
7
- "editor.formatOnSave": true,
8
- "editor.defaultFormatter": "esbenp.prettier-vscode"
9
- },
10
- "[typescript]": {
11
- "editor.formatOnSave": true,
12
- "editor.defaultFormatter": "vscode.typescript-language-features"
13
- },
14
- "[typescriptreact]": {
15
- "editor.formatOnSave": true,
16
- "editor.defaultFormatter": "esbenp.prettier-vscode"
17
- },
18
- "eslint.validate": [
19
- "javascript",
20
- "javascriptreact",
21
- "typescript",
22
- "typescriptreact"
23
- ],
24
- "editor.formatOnSave": true,
25
- "editor.codeActionsOnSave": {
26
- "source.fixAll.eslint": true,
27
- "source.fixAll": true,
28
- "source.organizeImports": true,
29
- "source.sortMembers": true
30
- }
31
- }
package/USER_README.md DELETED
@@ -1,16 +0,0 @@
1
- # Authorization
2
-
3
- Setup an env variable "SDK_TOKEN" It will be used as an auth token by default, You can also pass in the url and token in client.setup()
4
-
5
- # Example Usage of the Public SDK
6
-
7
- ```
8
- const devrevSDK = client.setup();
9
- (async () => {
10
- const response = await devrevSDK.worksGet({
11
- id: 'don:core:dvrv-us-1:devo/1DYPnPy0f:issue/8',
12
- });
13
-
14
- console.info(response.data.work.title);
15
- })();
16
- ```
package/nodemon.json DELETED
@@ -1,5 +0,0 @@
1
- {
2
- "execMap": {
3
- "ts": "ts-node"
4
- }
5
- }