@relevanceai/sdk 1.11.0 → 1.12.0
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.
- package/dist-cjs/generated/DiscoveryApi.js +595 -3
- package/dist-cjs/generated/_DiscoveryApiSchemaTypes.js +1 -4
- package/dist-cjs/generated/index.js +5 -2
- package/dist-cjs/index.js +6 -2
- package/dist-cjs/services/discovery/Dataset.js +125 -115
- package/dist-cjs/services/discovery/index.js +158 -179
- package/dist-cjs/services/index.js +2 -12
- package/dist-cjs/shared/generate.js +1 -1
- package/dist-cjs/shared/serviceConfigs.js +2 -7
- package/dist-es/generated/DiscoveryApi.js +898 -10
- package/dist-es/generated/_DiscoveryApiSchemaTypes.js +1 -4
- package/dist-es/generated/index.js +0 -1
- package/dist-es/index.js +1 -1
- package/dist-es/services/discovery/Dataset.js +126 -309
- package/dist-es/services/discovery/index.js +159 -233
- package/dist-es/services/index.js +3 -1
- package/dist-es/shared/BaseClient.js +9 -9
- package/dist-es/shared/generate.js +21 -20
- package/dist-es/shared/serviceConfigs.js +2 -7
- package/dist-types/generated/DiscoveryApi.d.ts +226 -4
- package/dist-types/generated/_DiscoveryApiSchemaTypes.d.ts +8663 -1056
- package/dist-types/generated/index.d.ts +0 -1
- package/dist-types/index.d.ts +0 -1
- package/dist-types/services/discovery/Dataset.d.ts +0 -50
- package/dist-types/services/discovery/index.d.ts +0 -366
- package/dist-types/services/index.d.ts +0 -1
- package/package.json +2 -2
- package/dist-cjs/generated/VectorApi.js +0 -762
- package/dist-cjs/generated/_VectorApiSchemaTypes.js +0 -6
- package/dist-es/generated/VectorApi.js +0 -1199
- package/dist-es/generated/_VectorApiSchemaTypes.js +0 -5
- package/dist-types/generated/VectorApi.d.ts +0 -287
- package/dist-types/generated/_VectorApiSchemaTypes.d.ts +0 -5781
|
@@ -1,233 +1,159 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
162
|
-
finally {
|
|
163
|
-
try {
|
|
164
|
-
if (args_1_1 && !args_1_1.done && (_a = args_1.return)) _a.call(args_1);
|
|
165
|
-
}
|
|
166
|
-
finally { if (e_1) throw e_1.error; }
|
|
167
|
-
}
|
|
168
|
-
this.body.vectorSearchQuery.push(payload);
|
|
169
|
-
return this;
|
|
170
|
-
};
|
|
171
|
-
_QueryBuilder.prototype.sort = function (field, direction) {
|
|
172
|
-
var _a, _b;
|
|
173
|
-
if (!((_b = (_a = this === null || this === void 0 ? void 0 : this.body) === null || _a === void 0 ? void 0 : _a.sort) === null || _b === void 0 ? void 0 : _b.length))
|
|
174
|
-
this.body.sort = {};
|
|
175
|
-
this.body.sort[field] = direction;
|
|
176
|
-
return this;
|
|
177
|
-
};
|
|
178
|
-
_QueryBuilder.prototype.textSort = function (field, direction) {
|
|
179
|
-
var _a, _b;
|
|
180
|
-
if (!((_b = (_a = this === null || this === void 0 ? void 0 : this.body) === null || _a === void 0 ? void 0 : _a.textSort) === null || _b === void 0 ? void 0 : _b.length))
|
|
181
|
-
this.body.textSort = {};
|
|
182
|
-
this.body.textSort[field] = direction;
|
|
183
|
-
return this;
|
|
184
|
-
};
|
|
185
|
-
_QueryBuilder.prototype.rawOption = function (key, value) {
|
|
186
|
-
this.body[key] = value;
|
|
187
|
-
return this;
|
|
188
|
-
};
|
|
189
|
-
_QueryBuilder.prototype.minimumRelevance = function (value) {
|
|
190
|
-
this.body.minimumRelevance = value;
|
|
191
|
-
return this;
|
|
192
|
-
};
|
|
193
|
-
_QueryBuilder.prototype.page = function (value) {
|
|
194
|
-
this.body.page = value;
|
|
195
|
-
return this;
|
|
196
|
-
};
|
|
197
|
-
_QueryBuilder.prototype.pageSize = function (value) {
|
|
198
|
-
this.body.pageSize = value;
|
|
199
|
-
return this;
|
|
200
|
-
};
|
|
201
|
-
_QueryBuilder.prototype.includeFields = function (fields) {
|
|
202
|
-
this.body.includeFields = fields;
|
|
203
|
-
};
|
|
204
|
-
_QueryBuilder.prototype.excludeFields = function (fields) {
|
|
205
|
-
this.body.excludeFields = fields;
|
|
206
|
-
};
|
|
207
|
-
_QueryBuilder.prototype.includeVectors = function (whetherToInclude) {
|
|
208
|
-
this.body.includeVectors = whetherToInclude;
|
|
209
|
-
};
|
|
210
|
-
_QueryBuilder.prototype.aggregate = function (field, options) {
|
|
211
|
-
var _a, _b, _c;
|
|
212
|
-
(_a = this.body.fieldsToAggregate) === null || _a === void 0 ? void 0 : _a.push(__assign(__assign({ key: field }, options), { fieldsToAggregate: (_c = (_b = options === null || options === void 0 ? void 0 : options.aggregates) === null || _b === void 0 ? void 0 : _b.body.fieldsToAggregate) !== null && _c !== void 0 ? _c : [] }));
|
|
213
|
-
return this;
|
|
214
|
-
};
|
|
215
|
-
_QueryBuilder.prototype.aggregateStats = function (field, interval) {
|
|
216
|
-
var _a;
|
|
217
|
-
(_a = this.body.fieldsToAggregateStats) === null || _a === void 0 ? void 0 : _a.push({ key: field, interval: interval });
|
|
218
|
-
return this;
|
|
219
|
-
};
|
|
220
|
-
return _QueryBuilder;
|
|
221
|
-
}(_FilterBuilder));
|
|
222
|
-
export { _QueryBuilder };
|
|
223
|
-
var DiscoveryClient = /** @class */ (function () {
|
|
224
|
-
function DiscoveryClient(config) {
|
|
225
|
-
this.apiClient = new DiscoveryApiClient(config !== null && config !== void 0 ? config : {});
|
|
226
|
-
}
|
|
227
|
-
DiscoveryClient.prototype.dataset = function (name, options) {
|
|
228
|
-
var dataset = new Dataset(this, name, options);
|
|
229
|
-
return dataset;
|
|
230
|
-
};
|
|
231
|
-
return DiscoveryClient;
|
|
232
|
-
}());
|
|
233
|
-
export { DiscoveryClient };
|
|
1
|
+
"use strict";
|
|
2
|
+
// import { DiscoveryApiClient, BulkInsertInput, BulkInsertOutput } from '../../';
|
|
3
|
+
// import { _ClientInput, CommandInput, CommandOutput, _GenericMethodOptions } from '../../shared/BaseClient';
|
|
4
|
+
// import { operations, components } from '../../generated/_DiscoveryApiSchemaTypes';
|
|
5
|
+
// import { Dataset } from './Dataset';
|
|
6
|
+
// type bodyType = operations['SimpleSearchPost']['requestBody']['content']['application/json'];
|
|
7
|
+
// export function QueryBuilder():_QueryBuilder{
|
|
8
|
+
// return new _QueryBuilder();
|
|
9
|
+
// }
|
|
10
|
+
// export function FilterBuilder():_FilterBuilder{
|
|
11
|
+
// return new _FilterBuilder();
|
|
12
|
+
// }
|
|
13
|
+
// export class _FilterBuilder {
|
|
14
|
+
// body: bodyType;
|
|
15
|
+
// constructor() {
|
|
16
|
+
// this.body = {filters:[],fieldsToAggregate:[],fieldsToAggregateStats:[]};
|
|
17
|
+
// }
|
|
18
|
+
// buildFilters() {
|
|
19
|
+
// return this.body.filters;
|
|
20
|
+
// }
|
|
21
|
+
// rawFilter(filter: components['schemas']['filterListItem']) {
|
|
22
|
+
// this.body.filters?.push(filter);
|
|
23
|
+
// return this;
|
|
24
|
+
// }
|
|
25
|
+
// filter(type: string, key: string, value: string, ...options: any) {
|
|
26
|
+
// this.body.filters?.push({
|
|
27
|
+
// [type]: {
|
|
28
|
+
// key,
|
|
29
|
+
// value,
|
|
30
|
+
// ...options
|
|
31
|
+
// }
|
|
32
|
+
// });
|
|
33
|
+
// return this;
|
|
34
|
+
// }
|
|
35
|
+
// match(field: string, value: any) {
|
|
36
|
+
// this.body.filters?.push({ match: { key: field, value } });
|
|
37
|
+
// return this;
|
|
38
|
+
// }
|
|
39
|
+
// wildcard(field: string, value: any) {
|
|
40
|
+
// this.body.filters?.push({ wildcard: { key: field, value } });
|
|
41
|
+
// return this;
|
|
42
|
+
// }
|
|
43
|
+
// selfreference(fielda: string, fieldb: string, operation: "<=" | ">=" | "<" | ">" | "==" | "!=") {
|
|
44
|
+
// this.body.filters?.push({ selfreference: { a: fielda, b: fieldb, operation } });
|
|
45
|
+
// return this;
|
|
46
|
+
// }
|
|
47
|
+
// range(field: string, options: Omit<components['schemas']['filterListItem']['range'],'key'>) {
|
|
48
|
+
// this.body.filters?.push({ range: { key: field, ...options } });
|
|
49
|
+
// return this;
|
|
50
|
+
// }
|
|
51
|
+
// or(filters: _FilterBuilder[]) {
|
|
52
|
+
// this.body.filters?.push({ or: filters.map(f => f.body.filters ?? []) });
|
|
53
|
+
// return this;
|
|
54
|
+
// }
|
|
55
|
+
// not(filter: _FilterBuilder) {
|
|
56
|
+
// this.body.filters?.push({ not: filter.body?.filters ?? [] });
|
|
57
|
+
// return this;
|
|
58
|
+
// }
|
|
59
|
+
// }
|
|
60
|
+
// export class _QueryBuilder extends _FilterBuilder {
|
|
61
|
+
// defaultQueryValue?: string;
|
|
62
|
+
// shouldPerformTextQuery:boolean;
|
|
63
|
+
// constructor() {
|
|
64
|
+
// super();
|
|
65
|
+
// this.shouldPerformTextQuery = false;
|
|
66
|
+
// }
|
|
67
|
+
// build() {
|
|
68
|
+
// if (!this.shouldPerformTextQuery) return this.body;
|
|
69
|
+
// if (!this.defaultQueryValue) throw new Error("Please set the search query by calling .query('my search query') before performing a text search.");
|
|
70
|
+
// this.body.query = this.defaultQueryValue;
|
|
71
|
+
// return this.body;
|
|
72
|
+
// }
|
|
73
|
+
// query(query:string,fieldsToSearch?: bodyType['fieldsToSearch']) {
|
|
74
|
+
// this.defaultQueryValue = query;
|
|
75
|
+
// if (fieldsToSearch) this.body.fieldsToSearch = fieldsToSearch;
|
|
76
|
+
// return this;
|
|
77
|
+
// }
|
|
78
|
+
// queryConfig(weight:number,options?:bodyType['queryConfig']) {
|
|
79
|
+
// this.body.queryConfig = {weight,...(options??{})};
|
|
80
|
+
// return this;
|
|
81
|
+
// }
|
|
82
|
+
// text(field?:string): _QueryBuilder;
|
|
83
|
+
// text(field?:string,weight?:number):_QueryBuilder{
|
|
84
|
+
// this.shouldPerformTextQuery = true;
|
|
85
|
+
// if (!field) return this; // support searching all fields
|
|
86
|
+
// if (!this.body.fieldsToSearch) this.body.fieldsToSearch = [];
|
|
87
|
+
// if (!weight) this.body.fieldsToSearch.push(field);
|
|
88
|
+
// else this.body.fieldsToSearch.push({field,weight});
|
|
89
|
+
// return this;
|
|
90
|
+
// }
|
|
91
|
+
// vector(field: string, weight?: number): _QueryBuilder;
|
|
92
|
+
// vector(field: string, options?: components['schemas']['vectorSearchQuery']): _QueryBuilder;
|
|
93
|
+
// vector(field: string, weight?: number, options?: components['schemas']['vectorSearchQuery']): _QueryBuilder;
|
|
94
|
+
// vector(field: string, ...args:any[]) {
|
|
95
|
+
// if (!Array.isArray(this.body.vectorSearchQuery)) this.body.vectorSearchQuery = [];
|
|
96
|
+
// let payload:components['schemas']['vectorSearchQuery'] = {field};
|
|
97
|
+
// const inferredModelMatch = field.match(/_(.*)_.*vector_/) // title_text@1-0_vector_ -> text@1-0
|
|
98
|
+
// if (inferredModelMatch && inferredModelMatch[1]) payload.model = inferredModelMatch[1]; // this can be overridden
|
|
99
|
+
// for (const arg of args) {
|
|
100
|
+
// if (typeof arg ==='number') payload.weight = arg; // weight
|
|
101
|
+
// else payload = {...payload,...arg}; // options
|
|
102
|
+
// }
|
|
103
|
+
// this.body.vectorSearchQuery.push(payload);
|
|
104
|
+
// return this;
|
|
105
|
+
// }
|
|
106
|
+
// sort(field: string, direction: 'asc' | 'desc') {
|
|
107
|
+
// if (!this?.body?.sort?.length) this.body.sort = {};
|
|
108
|
+
// this.body.sort[field] = direction;
|
|
109
|
+
// return this;
|
|
110
|
+
// }
|
|
111
|
+
// textSort(field: string, direction: 'asc' | 'desc') {
|
|
112
|
+
// if (!this?.body?.textSort?.length) this.body.textSort = {};
|
|
113
|
+
// this.body.textSort[field] = direction;
|
|
114
|
+
// return this;
|
|
115
|
+
// }
|
|
116
|
+
// rawOption(key: string, value: any) {
|
|
117
|
+
// (this.body as any)[key] = value;
|
|
118
|
+
// return this;
|
|
119
|
+
// }
|
|
120
|
+
// minimumRelevance(value: bodyType['minimumRelevance']) {
|
|
121
|
+
// this.body.minimumRelevance = value;
|
|
122
|
+
// return this;
|
|
123
|
+
// }
|
|
124
|
+
// page(value: bodyType['page']) {
|
|
125
|
+
// this.body.page = value;
|
|
126
|
+
// return this;
|
|
127
|
+
// }
|
|
128
|
+
// pageSize(value: bodyType['pageSize']) {
|
|
129
|
+
// this.body.pageSize = value;
|
|
130
|
+
// return this;
|
|
131
|
+
// }
|
|
132
|
+
// includeFields(fields:bodyType['includeFields']) {
|
|
133
|
+
// this.body.includeFields = fields;
|
|
134
|
+
// }
|
|
135
|
+
// excludeFields(fields:bodyType['excludeFields']) {
|
|
136
|
+
// this.body.excludeFields = fields;
|
|
137
|
+
// }
|
|
138
|
+
// includeVectors(whetherToInclude:bodyType['includeVectors']){
|
|
139
|
+
// this.body.includeVectors = whetherToInclude;
|
|
140
|
+
// }
|
|
141
|
+
// aggregate(field: string, options?: { options?: any, aggregates?: _QueryBuilder }) {
|
|
142
|
+
// this.body.fieldsToAggregate?.push({ field, ...options, fieldsToAggregate: options?.aggregates?.body.fieldsToAggregate ?? [] });
|
|
143
|
+
// return this;
|
|
144
|
+
// }
|
|
145
|
+
// aggregateStats(field: string, interval?: number) {
|
|
146
|
+
// this.body.fieldsToAggregateStats?.push({ field, interval });
|
|
147
|
+
// return this;
|
|
148
|
+
// }
|
|
149
|
+
// }
|
|
150
|
+
// export class DiscoveryClient {
|
|
151
|
+
// apiClient:DiscoveryApiClient;
|
|
152
|
+
// constructor(config?: _ClientInput) {
|
|
153
|
+
// this.apiClient = new DiscoveryApiClient(config ?? {});
|
|
154
|
+
// }
|
|
155
|
+
// dataset(name: string, options?: any) {
|
|
156
|
+
// let dataset = new Dataset(this, name, options);
|
|
157
|
+
// return dataset;
|
|
158
|
+
// }
|
|
159
|
+
// }
|
|
@@ -50,28 +50,28 @@ var _GenericClient = /** @class */ (function () {
|
|
|
50
50
|
var _b, _c, _d, _e, _f;
|
|
51
51
|
var input = _a.input, path = _a.path, method = _a.method, options = _a.options;
|
|
52
52
|
return __awaiter(this, void 0, void 0, function () {
|
|
53
|
-
var settings, final_dataset_id, res, _g, _h, body;
|
|
54
|
-
return __generator(this, function (
|
|
55
|
-
switch (
|
|
53
|
+
var settings, final_dataset_id, res, _g, _h, _j, body;
|
|
54
|
+
return __generator(this, function (_k) {
|
|
55
|
+
switch (_k.label) {
|
|
56
56
|
case 0:
|
|
57
57
|
settings = {
|
|
58
58
|
method: method,
|
|
59
|
-
headers: { authorization: ((_b = this.config.project) !== null && _b !== void 0 ? _b : envVars.project
|
|
59
|
+
headers: { authorization: "".concat((_b = this.config.project) !== null && _b !== void 0 ? _b : envVars.project, ":").concat((_c = this.config.api_key) !== null && _c !== void 0 ? _c : envVars.api_key) },
|
|
60
60
|
};
|
|
61
61
|
if (method.toLowerCase() !== 'get')
|
|
62
62
|
settings.body = JSON.stringify(input);
|
|
63
63
|
final_dataset_id = (_e = (_d = options === null || options === void 0 ? void 0 : options.dataset_id) !== null && _d !== void 0 ? _d : this.config.dataset_id) !== null && _e !== void 0 ? _e : "";
|
|
64
|
-
return [4 /*yield*/, fetch(((_f = this.config.endpoint) !== null && _f !== void 0 ? _f : this.serviceConfig.endpoint
|
|
64
|
+
return [4 /*yield*/, fetch("".concat((_f = this.config.endpoint) !== null && _f !== void 0 ? _f : this.serviceConfig.endpoint, "/latest").concat(path.replace('{dataset_id}', final_dataset_id)), settings)];
|
|
65
65
|
case 1:
|
|
66
|
-
res =
|
|
66
|
+
res = _k.sent();
|
|
67
67
|
if (!!res.ok) return [3 /*break*/, 3];
|
|
68
68
|
_g = Error.bind;
|
|
69
|
-
_h = path
|
|
69
|
+
_j = (_h = "".concat(path, " ").concat(method, " failed with status ").concat(res.status, ": ")).concat;
|
|
70
70
|
return [4 /*yield*/, res.text()];
|
|
71
|
-
case 2: throw new (_g.apply(Error, [void 0, _h
|
|
71
|
+
case 2: throw new (_g.apply(Error, [void 0, _j.apply(_h, [(_k.sent())])]))();
|
|
72
72
|
case 3: return [4 /*yield*/, res.json()];
|
|
73
73
|
case 4:
|
|
74
|
-
body =
|
|
74
|
+
body = _k.sent();
|
|
75
75
|
return [2 /*return*/, { body: body }];
|
|
76
76
|
}
|
|
77
77
|
});
|
|
@@ -80,7 +80,7 @@ function GetFlattenedSchema(schema) {
|
|
|
80
80
|
for (var _j = (e_2 = void 0, __values(Object.entries(methods))), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
81
81
|
var _l = __read(_k.value, 2), method = _l[0], pathData = _l[1];
|
|
82
82
|
var operation = pathData; // object.entries didnt work here
|
|
83
|
-
var operationSummaryName = (_e = ((_d = (_c = operation === null || operation === void 0 ? void 0 : operation.operationId) !== null && _c !== void 0 ? _c : operation === null || operation === void 0 ? void 0 : operation.summary) !== null && _d !== void 0 ? _d : path
|
|
83
|
+
var operationSummaryName = (_e = ((_d = (_c = operation === null || operation === void 0 ? void 0 : operation.operationId) !== null && _c !== void 0 ? _c : operation === null || operation === void 0 ? void 0 : operation.summary) !== null && _d !== void 0 ? _d : "".concat(path, "-").concat(method))) === null || _e === void 0 ? void 0 : _e.replace(/[^A-Za-z0-9]/g, "");
|
|
84
84
|
final.push({ path: path, method: method, operation: operation, operationSummaryName: operationSummaryName });
|
|
85
85
|
}
|
|
86
86
|
}
|
|
@@ -105,21 +105,22 @@ function GetFlattenedSchema(schema) {
|
|
|
105
105
|
function GenerateSDKFromOpenAPISchema(_a) {
|
|
106
106
|
var config = _a.config;
|
|
107
107
|
return __awaiter(this, void 0, void 0, function () {
|
|
108
|
-
var openapiSchema, typescriptOutput, sdkText, pipeline, pipeline_1, pipeline_1_1, fn;
|
|
109
|
-
var e_3,
|
|
110
|
-
return __generator(this, function (
|
|
111
|
-
switch (
|
|
108
|
+
var openapiSchema, typescriptOutput, _b, sdkText, pipeline, pipeline_1, pipeline_1_1, fn;
|
|
109
|
+
var e_3, _c;
|
|
110
|
+
return __generator(this, function (_d) {
|
|
111
|
+
switch (_d.label) {
|
|
112
112
|
case 0: return [4 /*yield*/, fetch(config.schema_url)];
|
|
113
|
-
case 1: return [4 /*yield*/, (
|
|
113
|
+
case 1: return [4 /*yield*/, (_d.sent()).json()];
|
|
114
114
|
case 2:
|
|
115
|
-
openapiSchema =
|
|
115
|
+
openapiSchema = _d.sent();
|
|
116
|
+
_b = 'interface definitions {[id:string]:any};\n';
|
|
116
117
|
return [4 /*yield*/, openapiTS(openapiSchema)];
|
|
117
118
|
case 3:
|
|
118
|
-
typescriptOutput =
|
|
119
|
+
typescriptOutput = _b + (_d.sent());
|
|
119
120
|
sdkText = '';
|
|
120
121
|
pipeline = [
|
|
121
122
|
function () {
|
|
122
|
-
sdkText += "import {CommandInput,_GenericClient,CommandOutput,_ClientInput,_GenericMethodOptions} from '../shared/BaseClient';\n import {operations} from './_"
|
|
123
|
+
sdkText += "import {CommandInput,_GenericClient,CommandOutput,_ClientInput,_GenericMethodOptions} from '../shared/BaseClient';\n import {operations} from './_".concat(config.name, "SchemaTypes';\n");
|
|
123
124
|
},
|
|
124
125
|
function () {
|
|
125
126
|
var e_4, _a;
|
|
@@ -127,12 +128,12 @@ function GenerateSDKFromOpenAPISchema(_a) {
|
|
|
127
128
|
for (var _b = __values(GetFlattenedSchema(openapiSchema)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
128
129
|
var _d = _c.value, path = _d.path, method = _d.method, operation = _d.operation, operationSummaryName = _d.operationSummaryName;
|
|
129
130
|
if (method.toLowerCase() !== 'get' && operation.requestBody) {
|
|
130
|
-
sdkText += "\n export type "
|
|
131
|
+
sdkText += "\n export type ".concat(operationSummaryName, "Input = operations['").concat(operation.operationId, "']['requestBody']['content']['application/json']");
|
|
131
132
|
}
|
|
132
133
|
else {
|
|
133
|
-
sdkText += "\n export type "
|
|
134
|
+
sdkText += "\n export type ".concat(operationSummaryName, "Input = {}");
|
|
134
135
|
}
|
|
135
|
-
sdkText += "\nexport type "
|
|
136
|
+
sdkText += "\nexport type ".concat(operationSummaryName, "Output = operations['").concat(operation.operationId, "']['responses']['200']['content']['application/json']");
|
|
136
137
|
}
|
|
137
138
|
}
|
|
138
139
|
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
@@ -144,14 +145,14 @@ function GenerateSDKFromOpenAPISchema(_a) {
|
|
|
144
145
|
}
|
|
145
146
|
},
|
|
146
147
|
function () {
|
|
147
|
-
sdkText += "\nexport class "
|
|
148
|
+
sdkText += "\nexport class ".concat(config.name, "Client extends _GenericClient {\n constructor(config:_ClientInput){\n super({...config,service_name:'").concat(config.name, "'});\n }");
|
|
148
149
|
},
|
|
149
150
|
function () {
|
|
150
151
|
var e_5, _a;
|
|
151
152
|
try {
|
|
152
153
|
for (var _b = __values(GetFlattenedSchema(openapiSchema)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
153
154
|
var _d = _c.value, path = _d.path, method = _d.method, operationSummaryName = _d.operationSummaryName;
|
|
154
|
-
sdkText += "\n public async "
|
|
155
|
+
sdkText += "\n public async ".concat(operationSummaryName, "(\n input: CommandInput<").concat(operationSummaryName, "Input>,\n options?: _GenericMethodOptions\n ):Promise<CommandOutput<").concat(operationSummaryName, "Output>> {\n return this.SendRequest({\n input,\n method:'").concat(method, "',\n path:'").concat(path, "',\n options\n });\n }");
|
|
155
156
|
}
|
|
156
157
|
}
|
|
157
158
|
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
@@ -175,16 +176,16 @@ function GenerateSDKFromOpenAPISchema(_a) {
|
|
|
175
176
|
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
176
177
|
finally {
|
|
177
178
|
try {
|
|
178
|
-
if (pipeline_1_1 && !pipeline_1_1.done && (
|
|
179
|
+
if (pipeline_1_1 && !pipeline_1_1.done && (_c = pipeline_1.return)) _c.call(pipeline_1);
|
|
179
180
|
}
|
|
180
181
|
finally { if (e_3) throw e_3.error; }
|
|
181
182
|
}
|
|
182
|
-
return [4 /*yield*/, fs.writeFile("./src/generated/"
|
|
183
|
+
return [4 /*yield*/, fs.writeFile("./src/generated/".concat(config.name, ".ts"), sdkText)];
|
|
183
184
|
case 4:
|
|
184
|
-
|
|
185
|
-
return [4 /*yield*/, fs.writeFile("./src/generated/_"
|
|
185
|
+
_d.sent();
|
|
186
|
+
return [4 /*yield*/, fs.writeFile("./src/generated/_".concat(config.name, "SchemaTypes.ts"), typescriptOutput)];
|
|
186
187
|
case 5:
|
|
187
|
-
|
|
188
|
+
_d.sent();
|
|
188
189
|
return [2 /*return*/];
|
|
189
190
|
}
|
|
190
191
|
});
|
|
@@ -202,7 +203,7 @@ function GenerateSDKS() {
|
|
|
202
203
|
for (_a = __values(Object.values(serviceConfigs)), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
203
204
|
config = _b.value;
|
|
204
205
|
GenerateSDKFromOpenAPISchema({ config: config });
|
|
205
|
-
indexFileContent += "export * from \"./"
|
|
206
|
+
indexFileContent += "export * from \"./".concat(config.name, "\";\n");
|
|
206
207
|
}
|
|
207
208
|
}
|
|
208
209
|
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
export var serviceConfigs = {
|
|
2
2
|
DiscoveryApi: {
|
|
3
|
-
schema_url: 'https://
|
|
4
|
-
endpoint: 'https://
|
|
3
|
+
schema_url: 'https://api.ap-southeast-2.relevance.ai/latest/openapi_schema.json',
|
|
4
|
+
endpoint: 'https://api.ap-southeast-2.relevance.ai',
|
|
5
5
|
name: 'DiscoveryApi',
|
|
6
6
|
},
|
|
7
|
-
VectorApi: {
|
|
8
|
-
schema_url: 'https://gateway-api-aueast.relevance.ai/latest/openapi.json',
|
|
9
|
-
endpoint: 'https://gateway-api-aueast.relevance.ai',
|
|
10
|
-
name: 'VectorApi',
|
|
11
|
-
}
|
|
12
7
|
};
|