@devrev/typescript-sdk 1.0.2

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 (44) hide show
  1. package/.eslintignore +2 -0
  2. package/.github/workflows/npm-publish.yml +27 -0
  3. package/.prettierignore +4 -0
  4. package/.prettierrc +15 -0
  5. package/.vscode/extensions.json +8 -0
  6. package/.vscode/launch.json +17 -0
  7. package/.vscode/settings.json +31 -0
  8. package/README.md +69 -0
  9. package/USER_README.md +16 -0
  10. package/nodemon.json +5 -0
  11. package/package.json +61 -0
  12. package/src/auto-generated/beta/beta-devrev-sdk.ts +1826 -0
  13. package/src/auto-generated/internal/private-internal-devrev-sdk.ts +54739 -0
  14. package/src/auto-generated/public-devrev-sdk.ts +4009 -0
  15. package/src/beta-data-contracts.json +3271 -0
  16. package/src/client_setup.ts +64 -0
  17. package/src/private-internal-data-contracts.json +98025 -0
  18. package/src/public-data-contracts.json +6922 -0
  19. package/src/workflow/workflow.test.ts +26 -0
  20. package/src/workflow/workflow.ts +54 -0
  21. package/templates/README.md +17 -0
  22. package/templates/base/README.md +8 -0
  23. package/templates/base/data-contract-jsdoc.ejs +37 -0
  24. package/templates/base/data-contracts.ejs +28 -0
  25. package/templates/base/enum-data-contract.ejs +12 -0
  26. package/templates/base/http-client.ejs +3 -0
  27. package/templates/base/http-clients/axios-http-client.ejs +138 -0
  28. package/templates/base/http-clients/fetch-http-client.ejs +224 -0
  29. package/templates/base/interface-data-contract.ejs +10 -0
  30. package/templates/base/object-field-jsdoc.ejs +28 -0
  31. package/templates/base/route-docs.ejs +30 -0
  32. package/templates/base/route-name.ejs +43 -0
  33. package/templates/base/route-type.ejs +22 -0
  34. package/templates/base/type-data-contract.ejs +15 -0
  35. package/templates/default/README.md +7 -0
  36. package/templates/default/api.ejs +64 -0
  37. package/templates/default/procedure-call.ejs +100 -0
  38. package/templates/default/route-types.ejs +26 -0
  39. package/templates/modular/README.md +7 -0
  40. package/templates/modular/api.ejs +28 -0
  41. package/templates/modular/procedure-call.ejs +100 -0
  42. package/templates/modular/route-types.ejs +18 -0
  43. package/tsconfig.eslint.json +4 -0
  44. package/tsconfig.json +25 -0
package/.eslintignore ADDED
@@ -0,0 +1,2 @@
1
+ ./src/auto-generated/**/*
2
+ node_modules/**/*
@@ -0,0 +1,27 @@
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}}
@@ -0,0 +1,4 @@
1
+ # Add files here to ignore them from prettier formatting
2
+
3
+ /dist
4
+
package/.prettierrc ADDED
@@ -0,0 +1,15 @@
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
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "recommendations": [
3
+ "dbaeumer.vscode-eslint",
4
+ "esbenp.prettier-vscode",
5
+ "firsttris.vscode-jest-runner",
6
+ "pmneo.tsimporter"
7
+ ]
8
+ }
@@ -0,0 +1,17 @@
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
+ }
@@ -0,0 +1,31 @@
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/README.md ADDED
@@ -0,0 +1,69 @@
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
+ # Authorization
10
+
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
+ ```
18
+
19
+ Example Usage of the Public SDK
20
+
21
+ ```
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
+ })();
30
+ ```
31
+
32
+ # Run tests:
33
+
34
+ ```
35
+ npm test
36
+ ```
37
+
38
+ Check package.json for more options
39
+
40
+ #To setup the client:
41
+
42
+ ```
43
+ import * as sdk from '../auto-generated/public-devrev-sdk';
44
+ import * as client from "../client_setup";
45
+
46
+ const devrevSDK = client.setup()
47
+ const betaSDK = client.setupBeta()
48
+ ```
49
+
50
+ Examples how to create a work item can be found in tests/works.ts
51
+
52
+ # Create a new test:
53
+
54
+ [Jest Documentation](https://jestjs.io/docs/expect)
55
+
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
58
+
59
+ **Example test pipeline for works.ts:**
60
+
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)
68
+
69
+ -- test readme change
package/USER_README.md ADDED
@@ -0,0 +1,16 @@
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 ADDED
@@ -0,0 +1,5 @@
1
+ {
2
+ "execMap": {
3
+ "ts": "ts-node"
4
+ }
5
+ }
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@devrev/typescript-sdk",
3
+ "version": "1.0.2",
4
+ "description": "## SDK Generation",
5
+ "main": "./dist/index.js",
6
+ "scripts": {
7
+ "lint": "eslint --ignore-path .gitignore .",
8
+ "lint:fix": "eslint --fix --ignore-path .gitignore .",
9
+ "build": "rimraf ./dist && tsc",
10
+ "build:watch": "tsc --watch",
11
+ "start": "ts-node ./src/main.ts",
12
+ "start:watch": "nodemon ./src/main.ts",
13
+ "start:production": "node dist/main.js",
14
+ "start:works": "nodemon ./src/works.ts",
15
+ "start:parts": "nodemon ./src/parts.ts",
16
+ "test": "jest",
17
+ "test:watch": "jest --watch"
18
+ },
19
+ "keywords": [],
20
+ "author": "devrev",
21
+ "license": "ISC",
22
+ "devDependencies": {
23
+ "@babel/core": "^7.20.12",
24
+ "@babel/preset-env": "^7.21.4",
25
+ "@babel/preset-typescript": "^7.18.6",
26
+ "@types/jest": "^29.4.0",
27
+ "@types/node": "^18.13.0",
28
+ "@typescript-eslint/eslint-plugin": "^5.51.0",
29
+ "babel-jest": "^29.4.2",
30
+ "eslint": "^8.33.0",
31
+ "eslint-config-airbnb-base": "^15.0.0",
32
+ "eslint-config-airbnb-typescript": "^17.0.0",
33
+ "eslint-plugin-import": "^2.27.5",
34
+ "eslint-plugin-prettier": "^4.2.1",
35
+ "jest": "^29.5.0",
36
+ "nodemon": "^2.0.20",
37
+ "prettier": "^2.8.3",
38
+ "prettier-plugin-organize-imports": "^3.2.2",
39
+ "rimraf": "^4.1.2",
40
+ "ts-jest": "^29.0.5",
41
+ "ts-node": "^10.9.1",
42
+ "typescript": "^4.9.5"
43
+ },
44
+ "dependencies": {
45
+ "@types/yargs": "^17.0.22",
46
+ "axios": "^1.3.6",
47
+ "dotenv": "^16.0.3",
48
+ "yargs": "^17.6.2"
49
+ },
50
+ "repository": {
51
+ "type": "git",
52
+ "url": "git+https://github.com/devrev/devrev-sdk-typescript.git"
53
+ },
54
+ "bugs": {
55
+ "url": "https://github.com/devrev/devrev-sdk-typescript/issues"
56
+ },
57
+ "homepage": "https://github.com/devrev/devrev-sdk-typescript#readme",
58
+ "publishConfig": {
59
+ "registry": "https://registry.npmjs.org/"
60
+ }
61
+ }