@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.
@@ -1,282 +1,135 @@
1
1
  "use strict";
2
- // This file is auto-generated by @hey-api/openapi-ts
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 = void 0;
78
- var createSseClient = function (_a) {
79
- var onRequest = _a.onRequest, onSseError = _a.onSseError, onSseEvent = _a.onSseEvent, responseTransformer = _a.responseTransformer, responseValidator = _a.responseValidator, sseDefaultRetryDelay = _a.sseDefaultRetryDelay, sseMaxRetryAttempts = _a.sseMaxRetryAttempts, sseMaxRetryDelay = _a.sseMaxRetryDelay, sseSleepFn = _a.sseSleepFn, url = _a.url, options = __rest(_a, ["onRequest", "onSseError", "onSseEvent", "responseTransformer", "responseValidator", "sseDefaultRetryDelay", "sseMaxRetryAttempts", "sseMaxRetryDelay", "sseSleepFn", "url"]);
80
- var lastEventId;
81
- var sleep = sseSleepFn !== null && sseSleepFn !== void 0 ? sseSleepFn : (function (ms) { return new Promise(function (resolve) { return setTimeout(resolve, ms); }); });
82
- var createStream = function () {
83
- return __asyncGenerator(this, arguments, function () {
84
- var retryDelay, attempt, signal, _loop_1, state_1;
85
- var _a, _b, _c;
86
- return __generator(this, function (_d) {
87
- switch (_d.label) {
88
- case 0:
89
- retryDelay = sseDefaultRetryDelay !== null && sseDefaultRetryDelay !== void 0 ? sseDefaultRetryDelay : 3000;
90
- attempt = 0;
91
- signal = (_a = options.signal) !== null && _a !== void 0 ? _a : new AbortController().signal;
92
- _loop_1 = function () {
93
- var headers, requestInit, request, _fetch, response, reader_1, buffer, abortHandler, _e, done, value, chunks, chunks_1, chunks_1_1, chunk, lines, dataLines, eventName, lines_1, lines_1_1, line, parsed, data, parsedJson, rawData, e_1_1, error_1, backoff;
94
- var e_1, _f, e_2, _g;
95
- return __generator(this, function (_h) {
96
- switch (_h.label) {
97
- case 0:
98
- if (signal.aborted)
99
- return [2 /*return*/, "break"];
100
- attempt++;
101
- headers = options.headers instanceof Headers
102
- ? options.headers
103
- : new Headers(options.headers);
104
- if (lastEventId !== undefined) {
105
- headers.set('Last-Event-ID', lastEventId);
106
- }
107
- _h.label = 1;
108
- case 1:
109
- _h.trys.push([1, 24, , 26]);
110
- requestInit = __assign(__assign({ redirect: 'follow' }, options), { body: options.serializedBody, headers: headers, signal: signal });
111
- request = new Request(url, requestInit);
112
- if (!onRequest) return [3 /*break*/, 3];
113
- return [4 /*yield*/, __await(onRequest(url, requestInit))];
114
- case 2:
115
- request = _h.sent();
116
- _h.label = 3;
117
- case 3:
118
- _fetch = (_b = options.fetch) !== null && _b !== void 0 ? _b : globalThis.fetch;
119
- return [4 /*yield*/, __await(_fetch(request))];
120
- case 4:
121
- response = _h.sent();
122
- if (!response.ok)
123
- throw new Error("SSE failed: ".concat(response.status, " ").concat(response.statusText));
124
- if (!response.body)
125
- throw new Error('No body in SSE response');
126
- reader_1 = response.body.pipeThrough(new TextDecoderStream()).getReader();
127
- buffer = '';
128
- abortHandler = function () {
129
- try {
130
- reader_1.cancel();
131
- }
132
- catch (_a) {
133
- // noop
134
- }
135
- };
136
- signal.addEventListener('abort', abortHandler);
137
- _h.label = 5;
138
- case 5:
139
- _h.trys.push([5, , 22, 23]);
140
- _h.label = 6;
141
- case 6:
142
- if (!true) return [3 /*break*/, 21];
143
- return [4 /*yield*/, __await(reader_1.read())];
144
- case 7:
145
- _e = _h.sent(), done = _e.done, value = _e.value;
146
- if (done)
147
- return [3 /*break*/, 21];
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
- _d.label = 1;
266
- case 1:
267
- if (!true) return [3 /*break*/, 3];
268
- return [5 /*yield**/, _loop_1()];
269
- case 2:
270
- state_1 = _d.sent();
271
- if (state_1 === "break")
272
- return [3 /*break*/, 3];
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
- var stream = createStream();
280
- return { stream: 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. converting ISO strings into Date objects.
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,3 +1,3 @@
1
1
  "use strict";
2
- // This file is auto-generated by @hey-api/openapi-ts
2
+ // This file is auto-generated based on the Examplary API schema.
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,111 +1,87 @@
1
1
  "use strict";
2
- // This file is auto-generated by @hey-api/openapi-ts
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
- var pathSerializer_gen_1 = require("./pathSerializer.gen");
6
+ const pathSerializer_gen_1 = require("./pathSerializer.gen");
18
7
  exports.PATH_PARAM_RE = /\{[^{}]+\}/g;
19
- var defaultPathSerializer = function (_a) {
20
- var e_1, _b;
21
- var path = _a.path, _url = _a.url;
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
- try {
26
- for (var matches_1 = __values(matches), matches_1_1 = matches_1.next(); !matches_1_1.done; matches_1_1 = matches_1.next()) {
27
- var match = matches_1_1.value;
28
- var explode = false;
29
- var name_1 = match.substring(1, match.length - 1);
30
- var style = 'simple';
31
- if (name_1.endsWith('*')) {
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
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
73
- finally {
74
- try {
75
- if (matches_1_1 && !matches_1_1.done && (_b = matches_1.return)) _b.call(matches_1);
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
- finally { if (e_1) throw e_1.error; }
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
- var getUrl = function (_a) {
84
- var baseUrl = _a.baseUrl, path = _a.path, query = _a.query, querySerializer = _a.querySerializer, _url = _a.url;
85
- var pathUrl = _url.startsWith('/') ? _url : "/".concat(_url);
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: path, url: url });
64
+ url = (0, exports.defaultPathSerializer)({ path, url });
89
65
  }
90
- var search = query ? querySerializer(query) : '';
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 += "?".concat(search);
71
+ url += `?${search}`;
96
72
  }
97
73
  return url;
98
74
  };
99
75
  exports.getUrl = getUrl;
100
76
  function getValidRequestBody(options) {
101
- var hasBody = options.body !== undefined;
102
- var isSerializedBody = hasBody && options.bodySerializer;
77
+ const hasBody = options.body !== undefined;
78
+ const isSerializedBody = hasBody && options.bodySerializer;
103
79
  if (isSerializedBody) {
104
80
  if ('serializedBody' in options) {
105
- var hasSerializedBody = options.serializedBody !== undefined && options.serializedBody !== '';
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. client-axios)
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, PostPracticeSpacesByIdData, PostPracticeSpacesData, PostQuestionBankData, PostQuestionTypesByIdDisableData, PostQuestionTypesByIdEnableData, PostQuestionTypesData, PostSourceMaterialsByIdSliceData, PostSourceMaterialsByIdSliceResponse, PostSourceMaterialsByIdSliceResponses, PostSourceMaterialsData, PostSourceMaterialsResponse, PostSourceMaterialsResponses, PostTaxonomiesByIdData, PostTaxonomiesData, PostUsersData } from './types.gen';
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';