@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
@@ -0,0 +1,64 @@
1
+ import { AxiosRequestConfig } from 'axios';
2
+ import * as Beta from './auto-generated/beta/beta-devrev-sdk';
3
+ import * as Sdk from './auto-generated/public-devrev-sdk';
4
+
5
+ export function setup(url = 'http://api.devrev.ai', token = process.env.SDK_TOKEN) {
6
+
7
+ const axiosConfig: AxiosRequestConfig = {
8
+ baseURL: url,
9
+ headers: {
10
+ Authorization: token,
11
+ },
12
+ };
13
+ const devrevSDK = new Sdk.Api({
14
+ ...axiosConfig,
15
+ });
16
+
17
+ devrevSDK.instance.interceptors.request.use((config) => {
18
+ for (const key in config.params) {
19
+ // Check if the property is an array
20
+ if (Array.isArray(config.params[key])) {
21
+ // Join the array with a comma
22
+ config.params[key] = config.params[key]
23
+ .map((value: any) => {
24
+ return `"${value}"`;
25
+ })
26
+ .join(',');
27
+ }
28
+ }
29
+ return config;
30
+ });
31
+
32
+ //add this in
33
+ return devrevSDK;
34
+ }
35
+
36
+ export function setupBeta(url = 'http://api.devrev.ai', token = process.env.SDK_TOKEN) {
37
+
38
+ const axiosConfig: AxiosRequestConfig = {
39
+ baseURL: url,
40
+ headers: {
41
+ Authorization: token,
42
+ 'X-Devrev-Scope': 'beta',
43
+ },
44
+ };
45
+ const devrevSDK = new Beta.Api({
46
+ ...axiosConfig,
47
+ });
48
+
49
+ devrevSDK.instance.interceptors.request.use((config) => {
50
+ for (const key in config.params) {
51
+ // Check if the property is an array
52
+ if (Array.isArray(config.params[key])) {
53
+ // Join the array with a comma
54
+ config.params[key] = config.params[key]
55
+ .map((value: any) => {
56
+ return `"${value}"`;
57
+ })
58
+ .join(',');
59
+ }
60
+ }
61
+ return config;
62
+ });
63
+ return devrevSDK;
64
+ }