@devrev/typescript-sdk 1.0.3 → 1.1.4

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 (67) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +31 -48
  3. package/dist/auto-generated/beta/beta-devrev-sdk.d.ts +3731 -0
  4. package/dist/auto-generated/beta/beta-devrev-sdk.js +919 -0
  5. package/dist/auto-generated/public-devrev-sdk.d.ts +2777 -0
  6. package/dist/auto-generated/public-devrev-sdk.js +784 -0
  7. package/dist/client_setup/client.d.ts +11 -0
  8. package/dist/client_setup/client.js +56 -0
  9. package/dist/index.d.ts +3 -0
  10. package/dist/index.js +30 -0
  11. package/dist/main.d.ts +1 -0
  12. package/dist/main.js +21 -0
  13. package/dist/tests/artifacts.d.ts +5 -0
  14. package/dist/tests/artifacts.js +44 -0
  15. package/dist/tests/parts.d.ts +8 -0
  16. package/dist/tests/parts.js +123 -0
  17. package/dist/tests/rev_user.d.ts +10 -0
  18. package/dist/tests/rev_user.js +107 -0
  19. package/dist/tests/test.d.ts +1 -0
  20. package/dist/tests/test.js +100 -0
  21. package/dist/tests/timeline.d.ts +10 -0
  22. package/dist/tests/timeline.js +153 -0
  23. package/dist/tests/works.d.ts +12 -0
  24. package/dist/tests/works.js +204 -0
  25. package/package.json +16 -9
  26. package/.eslintignore +0 -2
  27. package/.github/workflows/npm-publish.yml +0 -27
  28. package/.prettierignore +0 -4
  29. package/.prettierrc +0 -15
  30. package/.vscode/extensions.json +0 -8
  31. package/.vscode/launch.json +0 -17
  32. package/.vscode/settings.json +0 -31
  33. package/USER_README.md +0 -16
  34. package/nodemon.json +0 -5
  35. package/src/auto-generated/beta/beta-devrev-sdk.ts +0 -1826
  36. package/src/auto-generated/internal/private-internal-devrev-sdk.ts +0 -54739
  37. package/src/auto-generated/public-devrev-sdk.ts +0 -4009
  38. package/src/beta-data-contracts.json +0 -3271
  39. package/src/client_setup.ts +0 -64
  40. package/src/private-internal-data-contracts.json +0 -98025
  41. package/src/public-data-contracts.json +0 -6922
  42. package/src/workflow/workflow.test.ts +0 -26
  43. package/src/workflow/workflow.ts +0 -54
  44. package/templates/README.md +0 -17
  45. package/templates/base/README.md +0 -8
  46. package/templates/base/data-contract-jsdoc.ejs +0 -37
  47. package/templates/base/data-contracts.ejs +0 -28
  48. package/templates/base/enum-data-contract.ejs +0 -12
  49. package/templates/base/http-client.ejs +0 -3
  50. package/templates/base/http-clients/axios-http-client.ejs +0 -138
  51. package/templates/base/http-clients/fetch-http-client.ejs +0 -224
  52. package/templates/base/interface-data-contract.ejs +0 -10
  53. package/templates/base/object-field-jsdoc.ejs +0 -28
  54. package/templates/base/route-docs.ejs +0 -30
  55. package/templates/base/route-name.ejs +0 -43
  56. package/templates/base/route-type.ejs +0 -22
  57. package/templates/base/type-data-contract.ejs +0 -15
  58. package/templates/default/README.md +0 -7
  59. package/templates/default/api.ejs +0 -64
  60. package/templates/default/procedure-call.ejs +0 -100
  61. package/templates/default/route-types.ejs +0 -26
  62. package/templates/modular/README.md +0 -7
  63. package/templates/modular/api.ejs +0 -28
  64. package/templates/modular/procedure-call.ejs +0 -100
  65. package/templates/modular/route-types.ejs +0 -18
  66. package/tsconfig.eslint.json +0 -4
  67. 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