@examplary/sdk 0.0.1 → 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.
- package/dist/generated/client/client/client.gen.js +99 -163
- package/dist/generated/client/client/index.js +1 -1
- package/dist/generated/client/client/types.gen.d.ts +3 -4
- package/dist/generated/client/client/types.gen.js +1 -1
- package/dist/generated/client/client/utils.gen.js +94 -243
- package/dist/generated/client/client.gen.js +1 -1
- package/dist/generated/client/core/auth.gen.js +14 -65
- package/dist/generated/client/core/bodySerializer.gen.d.ts +4 -4
- package/dist/generated/client/core/bodySerializer.gen.js +12 -32
- package/dist/generated/client/core/params.gen.js +58 -145
- package/dist/generated/client/core/pathSerializer.gen.js +34 -66
- package/dist/generated/client/core/queryKeySerializer.gen.d.ts +1 -1
- package/dist/generated/client/core/queryKeySerializer.gen.js +21 -63
- package/dist/generated/client/core/serverSentEvents.gen.d.ts +1 -1
- package/dist/generated/client/core/serverSentEvents.gen.js +129 -276
- package/dist/generated/client/core/types.gen.d.ts +1 -1
- package/dist/generated/client/core/types.gen.js +1 -1
- package/dist/generated/client/core/utils.gen.js +56 -80
- package/dist/generated/client/index.d.ts +2 -2
- package/dist/generated/client/index.js +6 -1
- package/dist/generated/client/sdk.gen.d.ts +181 -3
- package/dist/generated/client/sdk.gen.js +1330 -799
- package/dist/generated/client/types.gen.d.ts +711 -71
- package/dist/src/index.js +26 -60
- package/package.json +8 -14
|
@@ -1,282 +1,135 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// This file is auto-generated
|
|
3
|
-
var __assign = (this && this.__assign) || function () {
|
|
4
|
-
__assign = Object.assign || function(t) {
|
|
5
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
-
s = arguments[i];
|
|
7
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
8
|
-
t[p] = s[p];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
return __assign.apply(this, arguments);
|
|
13
|
-
};
|
|
14
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
15
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
16
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
17
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
18
|
-
function step(op) {
|
|
19
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
20
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
21
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
22
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
23
|
-
switch (op[0]) {
|
|
24
|
-
case 0: case 1: t = op; break;
|
|
25
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
26
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
27
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
28
|
-
default:
|
|
29
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
30
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
31
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
32
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
33
|
-
if (t[2]) _.ops.pop();
|
|
34
|
-
_.trys.pop(); continue;
|
|
35
|
-
}
|
|
36
|
-
op = body.call(thisArg, _);
|
|
37
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
38
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
42
|
-
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
43
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
44
|
-
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
45
|
-
return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
46
|
-
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
|
|
47
|
-
function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
|
|
48
|
-
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
49
|
-
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
50
|
-
function fulfill(value) { resume("next", value); }
|
|
51
|
-
function reject(value) { resume("throw", value); }
|
|
52
|
-
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
53
|
-
};
|
|
54
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
55
|
-
var t = {};
|
|
56
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
57
|
-
t[p] = s[p];
|
|
58
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
59
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
60
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
61
|
-
t[p[i]] = s[p[i]];
|
|
62
|
-
}
|
|
63
|
-
return t;
|
|
64
|
-
};
|
|
65
|
-
var __values = (this && this.__values) || function(o) {
|
|
66
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
67
|
-
if (m) return m.call(o);
|
|
68
|
-
if (o && typeof o.length === "number") return {
|
|
69
|
-
next: function () {
|
|
70
|
-
if (o && i >= o.length) o = void 0;
|
|
71
|
-
return { value: o && o[i++], done: !o };
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
75
|
-
};
|
|
2
|
+
// This file is auto-generated based on the Examplary API schema.
|
|
76
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
77
|
-
exports.createSseClient =
|
|
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
|
-
buffer += value;
|
|
149
|
-
// Normalize line endings: CRLF -> LF, then CR -> LF
|
|
150
|
-
buffer = buffer.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
|
151
|
-
chunks = buffer.split('\n\n');
|
|
152
|
-
buffer = (_c = chunks.pop()) !== null && _c !== void 0 ? _c : '';
|
|
153
|
-
_h.label = 8;
|
|
154
|
-
case 8:
|
|
155
|
-
_h.trys.push([8, 18, 19, 20]);
|
|
156
|
-
chunks_1 = (e_1 = void 0, __values(chunks)), chunks_1_1 = chunks_1.next();
|
|
157
|
-
_h.label = 9;
|
|
158
|
-
case 9:
|
|
159
|
-
if (!!chunks_1_1.done) return [3 /*break*/, 17];
|
|
160
|
-
chunk = chunks_1_1.value;
|
|
161
|
-
lines = chunk.split('\n');
|
|
162
|
-
dataLines = [];
|
|
163
|
-
eventName = void 0;
|
|
164
|
-
try {
|
|
165
|
-
for (lines_1 = (e_2 = void 0, __values(lines)), lines_1_1 = lines_1.next(); !lines_1_1.done; lines_1_1 = lines_1.next()) {
|
|
166
|
-
line = lines_1_1.value;
|
|
167
|
-
if (line.startsWith('data:')) {
|
|
168
|
-
dataLines.push(line.replace(/^data:\s*/, ''));
|
|
169
|
-
}
|
|
170
|
-
else if (line.startsWith('event:')) {
|
|
171
|
-
eventName = line.replace(/^event:\s*/, '');
|
|
172
|
-
}
|
|
173
|
-
else if (line.startsWith('id:')) {
|
|
174
|
-
lastEventId = line.replace(/^id:\s*/, '');
|
|
175
|
-
}
|
|
176
|
-
else if (line.startsWith('retry:')) {
|
|
177
|
-
parsed = Number.parseInt(line.replace(/^retry:\s*/, ''), 10);
|
|
178
|
-
if (!Number.isNaN(parsed)) {
|
|
179
|
-
retryDelay = parsed;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
185
|
-
finally {
|
|
186
|
-
try {
|
|
187
|
-
if (lines_1_1 && !lines_1_1.done && (_g = lines_1.return)) _g.call(lines_1);
|
|
188
|
-
}
|
|
189
|
-
finally { if (e_2) throw e_2.error; }
|
|
190
|
-
}
|
|
191
|
-
data = void 0;
|
|
192
|
-
parsedJson = false;
|
|
193
|
-
if (dataLines.length) {
|
|
194
|
-
rawData = dataLines.join('\n');
|
|
195
|
-
try {
|
|
196
|
-
data = JSON.parse(rawData);
|
|
197
|
-
parsedJson = true;
|
|
198
|
-
}
|
|
199
|
-
catch (_j) {
|
|
200
|
-
data = rawData;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
if (!parsedJson) return [3 /*break*/, 13];
|
|
204
|
-
if (!responseValidator) return [3 /*break*/, 11];
|
|
205
|
-
return [4 /*yield*/, __await(responseValidator(data))];
|
|
206
|
-
case 10:
|
|
207
|
-
_h.sent();
|
|
208
|
-
_h.label = 11;
|
|
209
|
-
case 11:
|
|
210
|
-
if (!responseTransformer) return [3 /*break*/, 13];
|
|
211
|
-
return [4 /*yield*/, __await(responseTransformer(data))];
|
|
212
|
-
case 12:
|
|
213
|
-
data = _h.sent();
|
|
214
|
-
_h.label = 13;
|
|
215
|
-
case 13:
|
|
216
|
-
onSseEvent === null || onSseEvent === void 0 ? void 0 : onSseEvent({
|
|
217
|
-
data: data,
|
|
218
|
-
event: eventName,
|
|
219
|
-
id: lastEventId,
|
|
220
|
-
retry: retryDelay,
|
|
221
|
-
});
|
|
222
|
-
if (!dataLines.length) return [3 /*break*/, 16];
|
|
223
|
-
return [4 /*yield*/, __await(data)];
|
|
224
|
-
case 14: return [4 /*yield*/, _h.sent()];
|
|
225
|
-
case 15:
|
|
226
|
-
_h.sent();
|
|
227
|
-
_h.label = 16;
|
|
228
|
-
case 16:
|
|
229
|
-
chunks_1_1 = chunks_1.next();
|
|
230
|
-
return [3 /*break*/, 9];
|
|
231
|
-
case 17: return [3 /*break*/, 20];
|
|
232
|
-
case 18:
|
|
233
|
-
e_1_1 = _h.sent();
|
|
234
|
-
e_1 = { error: e_1_1 };
|
|
235
|
-
return [3 /*break*/, 20];
|
|
236
|
-
case 19:
|
|
237
|
-
try {
|
|
238
|
-
if (chunks_1_1 && !chunks_1_1.done && (_f = chunks_1.return)) _f.call(chunks_1);
|
|
239
|
-
}
|
|
240
|
-
finally { if (e_1) throw e_1.error; }
|
|
241
|
-
return [7 /*endfinally*/];
|
|
242
|
-
case 20: return [3 /*break*/, 6];
|
|
243
|
-
case 21: return [3 /*break*/, 23];
|
|
244
|
-
case 22:
|
|
245
|
-
signal.removeEventListener('abort', abortHandler);
|
|
246
|
-
reader_1.releaseLock();
|
|
247
|
-
return [7 /*endfinally*/];
|
|
248
|
-
case 23: return [2 /*return*/, "break"];
|
|
249
|
-
case 24:
|
|
250
|
-
error_1 = _h.sent();
|
|
251
|
-
// connection failed or aborted; retry after delay
|
|
252
|
-
onSseError === null || onSseError === void 0 ? void 0 : onSseError(error_1);
|
|
253
|
-
if (sseMaxRetryAttempts !== undefined && attempt >= sseMaxRetryAttempts) {
|
|
254
|
-
return [2 /*return*/, "break"];
|
|
255
|
-
}
|
|
256
|
-
backoff = Math.min(retryDelay * Math.pow(2, (attempt - 1)), sseMaxRetryDelay !== null && sseMaxRetryDelay !== void 0 ? sseMaxRetryDelay : 30000);
|
|
257
|
-
return [4 /*yield*/, __await(sleep(backoff))];
|
|
258
|
-
case 25:
|
|
259
|
-
_h.sent();
|
|
260
|
-
return [3 /*break*/, 26];
|
|
261
|
-
case 26: return [2 /*return*/];
|
|
4
|
+
exports.createSseClient = createSseClient;
|
|
5
|
+
function createSseClient({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url, ...options }) {
|
|
6
|
+
let lastEventId;
|
|
7
|
+
const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
8
|
+
const createStream = async function* () {
|
|
9
|
+
let retryDelay = sseDefaultRetryDelay ?? 3000;
|
|
10
|
+
let attempt = 0;
|
|
11
|
+
const signal = options.signal ?? new AbortController().signal;
|
|
12
|
+
while (true) {
|
|
13
|
+
if (signal.aborted)
|
|
14
|
+
break;
|
|
15
|
+
attempt++;
|
|
16
|
+
const headers = options.headers instanceof Headers
|
|
17
|
+
? options.headers
|
|
18
|
+
: new Headers(options.headers);
|
|
19
|
+
if (lastEventId !== undefined) {
|
|
20
|
+
headers.set('Last-Event-ID', lastEventId);
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
const requestInit = {
|
|
24
|
+
redirect: 'follow',
|
|
25
|
+
...options,
|
|
26
|
+
body: options.serializedBody,
|
|
27
|
+
headers,
|
|
28
|
+
signal,
|
|
29
|
+
};
|
|
30
|
+
let request = new Request(url, requestInit);
|
|
31
|
+
if (onRequest) {
|
|
32
|
+
request = await onRequest(url, requestInit);
|
|
33
|
+
}
|
|
34
|
+
// fetch must be assigned here, otherwise it would throw the error:
|
|
35
|
+
// TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
|
|
36
|
+
const _fetch = options.fetch ?? globalThis.fetch;
|
|
37
|
+
const response = await _fetch(request);
|
|
38
|
+
if (!response.ok)
|
|
39
|
+
throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
|
|
40
|
+
if (!response.body)
|
|
41
|
+
throw new Error('No body in SSE response');
|
|
42
|
+
const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
|
|
43
|
+
let buffer = '';
|
|
44
|
+
const abortHandler = () => {
|
|
45
|
+
try {
|
|
46
|
+
reader.cancel();
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
// noop
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
signal.addEventListener('abort', abortHandler);
|
|
53
|
+
try {
|
|
54
|
+
while (true) {
|
|
55
|
+
const { done, value } = await reader.read();
|
|
56
|
+
if (done)
|
|
57
|
+
break;
|
|
58
|
+
buffer += value;
|
|
59
|
+
buffer = buffer.replace(/\r\n?/g, '\n'); // normalize line endings
|
|
60
|
+
const chunks = buffer.split('\n\n');
|
|
61
|
+
buffer = chunks.pop() ?? '';
|
|
62
|
+
for (const chunk of chunks) {
|
|
63
|
+
const lines = chunk.split('\n');
|
|
64
|
+
const dataLines = [];
|
|
65
|
+
let eventName;
|
|
66
|
+
for (const line of lines) {
|
|
67
|
+
if (line.startsWith('data:')) {
|
|
68
|
+
dataLines.push(line.replace(/^data:\s*/, ''));
|
|
69
|
+
}
|
|
70
|
+
else if (line.startsWith('event:')) {
|
|
71
|
+
eventName = line.replace(/^event:\s*/, '');
|
|
72
|
+
}
|
|
73
|
+
else if (line.startsWith('id:')) {
|
|
74
|
+
lastEventId = line.replace(/^id:\s*/, '');
|
|
262
75
|
}
|
|
76
|
+
else if (line.startsWith('retry:')) {
|
|
77
|
+
const parsed = Number.parseInt(line.replace(/^retry:\s*/, ''), 10);
|
|
78
|
+
if (!Number.isNaN(parsed)) {
|
|
79
|
+
retryDelay = parsed;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
let data;
|
|
84
|
+
let parsedJson = false;
|
|
85
|
+
if (dataLines.length) {
|
|
86
|
+
const rawData = dataLines.join('\n');
|
|
87
|
+
try {
|
|
88
|
+
data = JSON.parse(rawData);
|
|
89
|
+
parsedJson = true;
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
data = rawData;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (parsedJson) {
|
|
96
|
+
if (responseValidator) {
|
|
97
|
+
await responseValidator(data);
|
|
98
|
+
}
|
|
99
|
+
if (responseTransformer) {
|
|
100
|
+
data = await responseTransformer(data);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
onSseEvent?.({
|
|
104
|
+
data,
|
|
105
|
+
event: eventName,
|
|
106
|
+
id: lastEventId,
|
|
107
|
+
retry: retryDelay,
|
|
263
108
|
});
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
return [3 /*break*/, 1];
|
|
274
|
-
case 3: return [2 /*return*/];
|
|
109
|
+
if (dataLines.length) {
|
|
110
|
+
yield data;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
finally {
|
|
116
|
+
signal.removeEventListener('abort', abortHandler);
|
|
117
|
+
reader.releaseLock();
|
|
275
118
|
}
|
|
276
|
-
|
|
277
|
-
|
|
119
|
+
break; // exit loop on normal completion
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
// connection failed or aborted; retry after delay
|
|
123
|
+
onSseError?.(error);
|
|
124
|
+
if (sseMaxRetryAttempts !== undefined && attempt >= sseMaxRetryAttempts) {
|
|
125
|
+
break; // stop after firing error
|
|
126
|
+
}
|
|
127
|
+
// exponential backoff: double retry each attempt, cap at 30s
|
|
128
|
+
const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 30000);
|
|
129
|
+
await sleep(backoff);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
278
132
|
};
|
|
279
|
-
|
|
280
|
-
return { stream
|
|
281
|
-
}
|
|
282
|
-
exports.createSseClient = createSseClient;
|
|
133
|
+
const stream = createStream();
|
|
134
|
+
return { stream };
|
|
135
|
+
}
|
|
@@ -61,7 +61,7 @@ export interface Config {
|
|
|
61
61
|
requestValidator?: (data: unknown) => Promise<unknown>;
|
|
62
62
|
/**
|
|
63
63
|
* A function transforming response data before it's returned. This is useful
|
|
64
|
-
* for post-processing data, e.g
|
|
64
|
+
* for post-processing data, e.g., converting ISO strings into Date objects.
|
|
65
65
|
*/
|
|
66
66
|
responseTransformer?: (data: unknown) => Promise<unknown>;
|
|
67
67
|
/**
|
|
@@ -1,111 +1,87 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// This file is auto-generated
|
|
3
|
-
var __values = (this && this.__values) || function(o) {
|
|
4
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
5
|
-
if (m) return m.call(o);
|
|
6
|
-
if (o && typeof o.length === "number") return {
|
|
7
|
-
next: function () {
|
|
8
|
-
if (o && i >= o.length) o = void 0;
|
|
9
|
-
return { value: o && o[i++], done: !o };
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
13
|
-
};
|
|
2
|
+
// This file is auto-generated based on the Examplary API schema.
|
|
14
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
4
|
exports.getUrl = exports.defaultPathSerializer = exports.PATH_PARAM_RE = void 0;
|
|
16
5
|
exports.getValidRequestBody = getValidRequestBody;
|
|
17
|
-
|
|
6
|
+
const pathSerializer_gen_1 = require("./pathSerializer.gen");
|
|
18
7
|
exports.PATH_PARAM_RE = /\{[^{}]+\}/g;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
var url = _url;
|
|
23
|
-
var matches = _url.match(exports.PATH_PARAM_RE);
|
|
8
|
+
const defaultPathSerializer = ({ path, url: _url }) => {
|
|
9
|
+
let url = _url;
|
|
10
|
+
const matches = _url.match(exports.PATH_PARAM_RE);
|
|
24
11
|
if (matches) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
explode = true;
|
|
33
|
-
name_1 = name_1.substring(0, name_1.length - 1);
|
|
34
|
-
}
|
|
35
|
-
if (name_1.startsWith('.')) {
|
|
36
|
-
name_1 = name_1.substring(1);
|
|
37
|
-
style = 'label';
|
|
38
|
-
}
|
|
39
|
-
else if (name_1.startsWith(';')) {
|
|
40
|
-
name_1 = name_1.substring(1);
|
|
41
|
-
style = 'matrix';
|
|
42
|
-
}
|
|
43
|
-
var value = path[name_1];
|
|
44
|
-
if (value === undefined || value === null) {
|
|
45
|
-
continue;
|
|
46
|
-
}
|
|
47
|
-
if (Array.isArray(value)) {
|
|
48
|
-
url = url.replace(match, (0, pathSerializer_gen_1.serializeArrayParam)({ explode: explode, name: name_1, style: style, value: value }));
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
51
|
-
if (typeof value === 'object') {
|
|
52
|
-
url = url.replace(match, (0, pathSerializer_gen_1.serializeObjectParam)({
|
|
53
|
-
explode: explode,
|
|
54
|
-
name: name_1,
|
|
55
|
-
style: style,
|
|
56
|
-
value: value,
|
|
57
|
-
valueOnly: true,
|
|
58
|
-
}));
|
|
59
|
-
continue;
|
|
60
|
-
}
|
|
61
|
-
if (style === 'matrix') {
|
|
62
|
-
url = url.replace(match, ";".concat((0, pathSerializer_gen_1.serializePrimitiveParam)({
|
|
63
|
-
name: name_1,
|
|
64
|
-
value: value,
|
|
65
|
-
})));
|
|
66
|
-
continue;
|
|
67
|
-
}
|
|
68
|
-
var replaceValue = encodeURIComponent(style === 'label' ? ".".concat(value) : value);
|
|
69
|
-
url = url.replace(match, replaceValue);
|
|
12
|
+
for (const match of matches) {
|
|
13
|
+
let explode = false;
|
|
14
|
+
let name = match.substring(1, match.length - 1);
|
|
15
|
+
let style = 'simple';
|
|
16
|
+
if (name.endsWith('*')) {
|
|
17
|
+
explode = true;
|
|
18
|
+
name = name.substring(0, name.length - 1);
|
|
70
19
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
20
|
+
if (name.startsWith('.')) {
|
|
21
|
+
name = name.substring(1);
|
|
22
|
+
style = 'label';
|
|
23
|
+
}
|
|
24
|
+
else if (name.startsWith(';')) {
|
|
25
|
+
name = name.substring(1);
|
|
26
|
+
style = 'matrix';
|
|
27
|
+
}
|
|
28
|
+
const value = path[name];
|
|
29
|
+
if (value === undefined || value === null) {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
if (Array.isArray(value)) {
|
|
33
|
+
url = url.replace(match, (0, pathSerializer_gen_1.serializeArrayParam)({ explode, name, style, value }));
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (typeof value === 'object') {
|
|
37
|
+
url = url.replace(match, (0, pathSerializer_gen_1.serializeObjectParam)({
|
|
38
|
+
explode,
|
|
39
|
+
name,
|
|
40
|
+
style,
|
|
41
|
+
value: value,
|
|
42
|
+
valueOnly: true,
|
|
43
|
+
}));
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (style === 'matrix') {
|
|
47
|
+
url = url.replace(match, `;${(0, pathSerializer_gen_1.serializePrimitiveParam)({
|
|
48
|
+
name,
|
|
49
|
+
value: value,
|
|
50
|
+
})}`);
|
|
51
|
+
continue;
|
|
76
52
|
}
|
|
77
|
-
|
|
53
|
+
const replaceValue = encodeURIComponent(style === 'label' ? `.${value}` : value);
|
|
54
|
+
url = url.replace(match, replaceValue);
|
|
78
55
|
}
|
|
79
56
|
}
|
|
80
57
|
return url;
|
|
81
58
|
};
|
|
82
59
|
exports.defaultPathSerializer = defaultPathSerializer;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
var url = (baseUrl !== null && baseUrl !== void 0 ? baseUrl : '') + pathUrl;
|
|
60
|
+
const getUrl = ({ baseUrl, path, query, querySerializer, url: _url, }) => {
|
|
61
|
+
const pathUrl = _url.startsWith('/') ? _url : `/${_url}`;
|
|
62
|
+
let url = (baseUrl ?? '') + pathUrl;
|
|
87
63
|
if (path) {
|
|
88
|
-
url = (0, exports.defaultPathSerializer)({ path
|
|
64
|
+
url = (0, exports.defaultPathSerializer)({ path, url });
|
|
89
65
|
}
|
|
90
|
-
|
|
66
|
+
let search = query ? querySerializer(query) : '';
|
|
91
67
|
if (search.startsWith('?')) {
|
|
92
68
|
search = search.substring(1);
|
|
93
69
|
}
|
|
94
70
|
if (search) {
|
|
95
|
-
url +=
|
|
71
|
+
url += `?${search}`;
|
|
96
72
|
}
|
|
97
73
|
return url;
|
|
98
74
|
};
|
|
99
75
|
exports.getUrl = getUrl;
|
|
100
76
|
function getValidRequestBody(options) {
|
|
101
|
-
|
|
102
|
-
|
|
77
|
+
const hasBody = options.body !== undefined;
|
|
78
|
+
const isSerializedBody = hasBody && options.bodySerializer;
|
|
103
79
|
if (isSerializedBody) {
|
|
104
80
|
if ('serializedBody' in options) {
|
|
105
|
-
|
|
81
|
+
const hasSerializedBody = options.serializedBody !== undefined && options.serializedBody !== '';
|
|
106
82
|
return hasSerializedBody ? options.serializedBody : null;
|
|
107
83
|
}
|
|
108
|
-
// not all clients implement a serializedBody property (i.e
|
|
84
|
+
// not all clients implement a serializedBody property (i.e., client-axios)
|
|
109
85
|
return options.body !== '' ? options.body : null;
|
|
110
86
|
}
|
|
111
87
|
// plain/text body
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { ApiKeys, EmbedSessions, Exam, Examplary, Exams, Export, Folders, Items, Items2, Library, Me, Media, Oauth, type Options, Org, Orgs, Permissions, PracticeSpaces, Publishers, QuestionBank, Questions, QuestionTypes, Sessions, SourceMaterials, StudentLevels, Taxonomies, Users } from './sdk.gen';
|
|
2
|
-
export type { ClientOptions, DeleteEmbedSessionsByIdData, DeleteExamsByIdData, DeleteExamsByIdSessionsBySessionIdData, DeleteFoldersByIdData, DeleteLibraryItemsByItemIdData, DeleteLibraryPublishersByPublisherIdData, DeleteOrgData, DeletePermissionsByResourceByActorData, DeletePermissionsByResourceByActorErrors, DeletePermissionsByResourceByActorResponses, DeletePracticeSpacesByIdData, DeleteQuestionBankByIdData, DeleteQuestionTypesByIdData, DeleteSourceMaterialsByIdData, DeleteTaxonomiesByIdData, DeleteUsersByIdData, GetApiKeysData, GetEmbedSessionsByIdData, GetEmbedSessionsByIdResponse, GetEmbedSessionsByIdResponses, GetExamsByIdContextSuggestionsData, GetExamsByIdData, GetExamsByIdSessionsBySessionIdData, GetExamsByIdSessionsData, GetExamsData, GetFoldersData, GetLibraryItemsFeaturedData, GetLibraryPublishersByPublisherIdItemsData, GetLibraryPublishersData, GetLibraryPublishersFeaturedData, GetLibraryPublishersMineData, GetMeData, GetMediaUploadData, GetMediaUploadResponse, GetMediaUploadResponses, GetOauthAuthorizeData, GetOrgData, GetOrgsData, GetPermissionsByResourceByActorData, GetPermissionsByResourceByActorErrors, GetPermissionsByResourceByActorResponse, GetPermissionsByResourceByActorResponses, GetPermissionsByResourceData, GetPermissionsByResourceErrors, GetPermissionsByResourceResponse, GetPermissionsByResourceResponses, GetPracticeSpacesByIdData, GetPracticeSpacesByIdQuestionsPreviewData, GetPracticeSpacesData, GetQuestionBankData, GetQuestionTypesByIdData, GetQuestionTypesByIdExportQti3PciData, GetQuestionTypesData, GetQuestionTypesPublicData, GetSourceMaterialsByIdData, GetSourceMaterialsByIdResponse, GetSourceMaterialsByIdResponses, GetSourceMaterialsData, GetSourceMaterialsResponse, GetSourceMaterialsResponses, GetStudentLevelsData, GetTaxonomiesData, GetUsersData, PatchLibraryItemsByItemIdData, PatchLibraryPublishersByPublisherIdData, PatchMeData, PatchOrgData, PatchQuestionBankByIdData, PatchSourceMaterialsByIdData, PatchUsersByIdData, PostApiKeysResetData, PostEmbedSessionsData, PostEmbedSessionsResponse, PostEmbedSessionsResponses, PostExamsByIdData, PostExamsByIdDuplicateData, PostExamsByIdExportQti21ZipData, PostExamsByIdExportQti21ZipResponse, PostExamsByIdExportQti21ZipResponses, PostExamsByIdExportQti3ZipData, PostExamsByIdExportQti3ZipResponse, PostExamsByIdExportQti3ZipResponses, PostExamsByIdGenerateCancelData, PostExamsByIdGenerateData, PostExamsByIdPrintData, PostExamsByIdQuestionsByQuestionIdGenerateData, PostExamsByIdQuestionsGenerateData, PostExamsByIdQuestionsImportData, PostExamsByIdSessionsBySessionIdFeedbackData, PostExamsByIdSessionsBySessionIdGenerateOverallFeedbackData, PostExamsByIdSessionsBySessionIdOverallFeedbackData, PostExamsByIdSessionsBySessionIdSuggestionsAcceptAllData, PostExamsByIdSessionsBySessionIdSuggestionsByQuestionIdAcceptData, PostExamsByIdSessionsData, PostExamsByIdSessionsScanData, PostExamsData, PostExamsImportData, PostFoldersByIdData, PostFoldersData, PostLibraryPublishersByPublisherIdItemsData, PostLibraryPublishersData, PostOauthTokenData, PostOrgsData, PostPermissionsByResourceData, PostPermissionsByResourceErrors, PostPermissionsByResourceResponse, PostPermissionsByResourceResponses,
|
|
1
|
+
export { ApiKeys, Attributes, CustomDomain, EmbedSessions, Exam, Examplary, Exams, Export, Folders, Items, Items2, Jobs, Library, Me, Media, Oauth, type Options, Org, Orgs, Permissions, PracticeSpaces, Publishers, QuestionBank, Questions, QuestionTypes, Sessions, Sessions2, SourceMaterials, StudentLevels, Students, Taxonomies, Users } from './sdk.gen';
|
|
2
|
+
export type { ClientOptions, DeleteAttributesByIdData, DeleteEmbedSessionsByIdData, DeleteExamsByIdData, DeleteExamsByIdSessionsBySessionIdData, DeleteFoldersByIdData, DeleteJobsByIdData, DeleteLibraryItemsByItemIdData, DeleteLibraryPublishersByPublisherIdData, DeleteOrgData, DeletePermissionsByResourceByActorData, DeletePermissionsByResourceByActorErrors, DeletePermissionsByResourceByActorResponses, DeletePracticeSpacesByIdData, DeleteQuestionBankByIdData, DeleteQuestionTypesByIdData, DeleteRubricsByIdData, DeleteSourceMaterialsByIdData, DeleteTaxonomiesByIdData, DeleteUsersByIdData, GetApiKeysData, GetAttributesData, GetEmbedSessionsByIdData, GetEmbedSessionsByIdResponse, GetEmbedSessionsByIdResponses, GetExamsByIdContextSuggestionsData, GetExamsByIdData, GetExamsByIdQuestionsByQuestionIdData, GetExamsByIdSessionsBySessionIdData, GetExamsByIdSessionsData, GetExamsData, GetFoldersData, GetJobsByIdData, GetLibraryItemsFeaturedData, GetLibraryPublishersByPublisherIdItemsData, GetLibraryPublishersData, GetLibraryPublishersFeaturedData, GetLibraryPublishersMineData, GetMeData, GetMediaUploadData, GetMediaUploadResponse, GetMediaUploadResponses, GetOauthAuthorizeData, GetOrgCustomDomainData, GetOrgData, GetOrgsData, GetPermissionsByResourceByActorData, GetPermissionsByResourceByActorErrors, GetPermissionsByResourceByActorResponse, GetPermissionsByResourceByActorResponses, GetPermissionsByResourceData, GetPermissionsByResourceErrors, GetPermissionsByResourceResponse, GetPermissionsByResourceResponses, GetPracticeSpacesByIdData, GetPracticeSpacesByIdProgressData, GetPracticeSpacesByIdQuestionsPreviewData, GetPracticeSpacesByIdSessionsBySessionIdData, GetPracticeSpacesByIdSessionsMineData, GetPracticeSpacesByIdStudentsByStudentIdData, GetPracticeSpacesByIdStudentsData, GetPracticeSpacesData, GetQuestionBankData, GetQuestionTypesByIdData, GetQuestionTypesByIdExportQti3PciData, GetQuestionTypesData, GetQuestionTypesPublicData, GetRubricsData, GetSourceMaterialsByIdData, GetSourceMaterialsByIdResponse, GetSourceMaterialsByIdResponses, GetSourceMaterialsData, GetSourceMaterialsResponse, GetSourceMaterialsResponses, GetStudentLevelsData, GetTaxonomiesData, GetUsersData, PatchExamsByIdSessionsBySessionIdAnswersByQuestionIdData, PatchLibraryItemsByItemIdData, PatchLibraryPublishersByPublisherIdData, PatchMeData, PatchOrgData, PatchPracticeSpacesByIdData, PatchQuestionBankByIdData, PatchRubricsByIdData, PatchSourceMaterialsByIdData, PatchUsersByIdData, PostApiKeysResetData, PostAttributesByIdData, PostAttributesData, PostAttributesReorderData, PostEmbedSessionsData, PostEmbedSessionsResponse, PostEmbedSessionsResponses, PostExamsByIdData, PostExamsByIdDuplicateData, PostExamsByIdExportQti21ZipData, PostExamsByIdExportQti21ZipResponse, PostExamsByIdExportQti21ZipResponses, PostExamsByIdExportQti3ZipData, PostExamsByIdExportQti3ZipResponse, PostExamsByIdExportQti3ZipResponses, PostExamsByIdGenerateCancelData, PostExamsByIdGenerateData, PostExamsByIdPrintData, PostExamsByIdQuestionsByQuestionIdGenerateData, PostExamsByIdQuestionsGenerateData, PostExamsByIdQuestionsImportData, PostExamsByIdSessionsBySessionIdFeedbackData, PostExamsByIdSessionsBySessionIdGenerateOverallFeedbackData, PostExamsByIdSessionsBySessionIdOverallFeedbackData, PostExamsByIdSessionsBySessionIdSuggestionsAcceptAllData, PostExamsByIdSessionsBySessionIdSuggestionsByQuestionIdAcceptData, PostExamsByIdSessionsData, PostExamsByIdSessionsScanData, PostExamsData, PostExamsImportData, PostFoldersByIdData, PostFoldersData, PostLibraryPublishersByPublisherIdItemsData, PostLibraryPublishersData, PostOauthTokenData, PostOrgCustomDomainData, PostOrgsData, PostPermissionsByResourceData, PostPermissionsByResourceErrors, PostPermissionsByResourceResponse, PostPermissionsByResourceResponses, PostPracticeSpacesByIdCancelGenerateTopicsData, PostPracticeSpacesByIdDuplicateData, PostPracticeSpacesByIdGenerateTopicsData, PostPracticeSpacesByIdProgressTopicFeedbackData, PostPracticeSpacesByIdSessionsBySessionIdAnswersByQuestionIdData, PostPracticeSpacesByIdSessionsData, PostPracticeSpacesData, PostQuestionBankData, PostQuestionTypesByIdDisableData, PostQuestionTypesByIdEnableData, PostQuestionTypesData, PostRubricsData, PostRubricsGenerateData, PostSourceMaterialsByIdSliceData, PostSourceMaterialsByIdSliceResponse, PostSourceMaterialsByIdSliceResponses, PostSourceMaterialsData, PostSourceMaterialsResponse, PostSourceMaterialsResponses, PostTaxonomiesByIdData, PostTaxonomiesData, PostUsersData } from './types.gen';
|