@relevanceai/sdk 2.0.0 → 2.0.1

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 (37) hide show
  1. package/dist-cjs/generated/VecDBApi.js +1682 -0
  2. package/dist-cjs/generated/_VecDBApiSchemaTypes.js +3 -0
  3. package/dist-cjs/generated/index.js +17 -0
  4. package/dist-cjs/index.js +18 -0
  5. package/dist-cjs/services/discovery/Dataset.js +126 -0
  6. package/dist-cjs/services/discovery/index.js +159 -0
  7. package/dist-cjs/services/index.js +18 -0
  8. package/dist-cjs/services/vecdb/Dataset.js +137 -0
  9. package/dist-cjs/services/vecdb/index.js +137 -0
  10. package/dist-cjs/shared/BaseClient.js +35 -0
  11. package/dist-cjs/shared/generate.js +90 -0
  12. package/dist-cjs/shared/serviceConfigs.js +10 -0
  13. package/dist-es/generated/VecDBApi.js +2579 -0
  14. package/dist-es/generated/_VecDBApiSchemaTypes.js +2 -0
  15. package/dist-es/generated/index.js +1 -0
  16. package/dist-es/index.js +2 -0
  17. package/dist-es/services/discovery/Dataset.js +126 -0
  18. package/dist-es/services/discovery/index.js +159 -0
  19. package/dist-es/services/index.js +2 -0
  20. package/dist-es/services/vecdb/Dataset.js +356 -0
  21. package/dist-es/services/vecdb/index.js +184 -0
  22. package/dist-es/shared/BaseClient.js +82 -0
  23. package/dist-es/shared/generate.js +224 -0
  24. package/dist-es/shared/serviceConfigs.js +7 -0
  25. package/dist-types/generated/VecDBApi.d.ts +632 -0
  26. package/dist-types/generated/_VecDBApiSchemaTypes.d.ts +22299 -0
  27. package/dist-types/generated/index.d.ts +1 -0
  28. package/dist-types/index.d.ts +2 -0
  29. package/dist-types/services/discovery/Dataset.d.ts +0 -0
  30. package/dist-types/services/discovery/index.d.ts +0 -0
  31. package/dist-types/services/index.d.ts +1 -0
  32. package/dist-types/services/vecdb/Dataset.d.ts +52 -0
  33. package/dist-types/services/vecdb/index.d.ts +44 -0
  34. package/dist-types/shared/BaseClient.d.ts +28 -0
  35. package/dist-types/shared/generate.d.ts +1 -0
  36. package/dist-types/shared/serviceConfigs.d.ts +8 -0
  37. package/package.json +1 -1
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const cross_fetch_1 = __importDefault(require("cross-fetch"));
7
+ const fs_1 = require("fs");
8
+ const openapi_typescript_1 = __importDefault(require("openapi-typescript"));
9
+ const serviceConfigs_1 = require("./serviceConfigs");
10
+ // download schema using cross-fetch
11
+ // convert to sdk with typescript, can supply middleware methods that will be run ???
12
+ function GetFlattenedSchema(schema) {
13
+ var _a, _b, _c;
14
+ if (!schema.paths)
15
+ throw new Error('No paths in schema ${config.schema_url}');
16
+ const final = [];
17
+ for (const [path, methods] of Object.entries(schema.paths)) {
18
+ for (const [method, pathData] of Object.entries(methods)) {
19
+ const operation = pathData; // object.entries didnt work here
20
+ const operationSummaryName = (_c = ((_b = (_a = operation === null || operation === void 0 ? void 0 : operation.operationId) !== null && _a !== void 0 ? _a : operation === null || operation === void 0 ? void 0 : operation.summary) !== null && _b !== void 0 ? _b : `${path}-${method}`)) === null || _c === void 0 ? void 0 : _c.replace(/[^A-Za-z0-9]/g, "");
21
+ final.push({ path, method, operation, operationSummaryName });
22
+ }
23
+ }
24
+ return final;
25
+ }
26
+ async function GenerateSDKFromOpenAPISchema({ config }) {
27
+ const openapiSchema = await (await (0, cross_fetch_1.default)(config.schema_url)).json();
28
+ const typescriptOutput = 'interface definitions {[id:string]:any};\n' + (await (0, openapi_typescript_1.default)(openapiSchema));
29
+ let sdkText = '';
30
+ const pipeline = [
31
+ () => {
32
+ sdkText += `import {CommandInput,_GenericClient,CommandOutput,_ClientInput,_GenericMethodOptions} from '../shared/BaseClient';
33
+ import {operations} from './_${config.name}SchemaTypes';
34
+ `;
35
+ },
36
+ () => {
37
+ for (const { path, method, operation, operationSummaryName } of GetFlattenedSchema(openapiSchema)) {
38
+ if (method.toLowerCase() !== 'get' && operation.requestBody) {
39
+ sdkText += `
40
+ export type ${operationSummaryName}Input = operations['${operation.operationId}']['requestBody']['content']['application/json']`;
41
+ }
42
+ else {
43
+ sdkText += `
44
+ export type ${operationSummaryName}Input = {}`;
45
+ }
46
+ sdkText += `
47
+ export type ${operationSummaryName}Output = operations['${operation.operationId}']['responses']['200']['content']['application/json']`;
48
+ }
49
+ },
50
+ () => {
51
+ sdkText += `
52
+ export class ${config.name}Client extends _GenericClient {
53
+ constructor(config:_ClientInput){
54
+ super({...config,service_name:'${config.name}'});
55
+ }`;
56
+ },
57
+ () => {
58
+ for (const { path, method, operationSummaryName } of GetFlattenedSchema(openapiSchema)) {
59
+ sdkText += `
60
+ public async ${operationSummaryName}(
61
+ input: CommandInput<${operationSummaryName}Input>,
62
+ options?: _GenericMethodOptions
63
+ ):Promise<CommandOutput<${operationSummaryName}Output>> {
64
+ return this.SendRequest({
65
+ input,
66
+ method:'${method}',
67
+ path:'${path}',
68
+ options
69
+ });
70
+ }`;
71
+ }
72
+ },
73
+ () => {
74
+ sdkText += '}';
75
+ }
76
+ ];
77
+ for (const fn of pipeline)
78
+ fn();
79
+ await fs_1.promises.writeFile(`./src/generated/${config.name}.ts`, sdkText);
80
+ await fs_1.promises.writeFile(`./src/generated/_${config.name}SchemaTypes.ts`, typescriptOutput);
81
+ }
82
+ async function GenerateSDKS() {
83
+ let indexFileContent = '';
84
+ for (const config of Object.values(serviceConfigs_1.serviceConfigs)) {
85
+ GenerateSDKFromOpenAPISchema({ config });
86
+ indexFileContent += `export * from "./${config.name}";\n`;
87
+ }
88
+ await fs_1.promises.writeFile(`./src/generated/index.ts`, indexFileContent);
89
+ }
90
+ GenerateSDKS();
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serviceConfigs = void 0;
4
+ exports.serviceConfigs = {
5
+ VecDBApi: {
6
+ schema_url: 'https://api-f1db6c.stack.tryrelevance.com/latest/openapi_schema.json',
7
+ endpoint: 'https://api-f1db6c.stack.tryrelevance.com',
8
+ name: 'VecDBApi',
9
+ },
10
+ };