@examplary/sdk 1.0.0 → 1.0.3

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,190 +1,103 @@
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
- };
14
- var __read = (this && this.__read) || function (o, n) {
15
- var m = typeof Symbol === "function" && o[Symbol.iterator];
16
- if (!m) return o;
17
- var i = m.call(o), r, ar = [], e;
18
- try {
19
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
20
- }
21
- catch (error) { e = { error: error }; }
22
- finally {
23
- try {
24
- if (r && !r.done && (m = i["return"])) m.call(i);
25
- }
26
- finally { if (e) throw e.error; }
27
- }
28
- return ar;
29
- };
2
+ // This file is auto-generated based on the Examplary API schema.
30
3
  Object.defineProperty(exports, "__esModule", { value: true });
31
4
  exports.buildClientParams = void 0;
32
- var extraPrefixesMap = {
5
+ const extraPrefixesMap = {
33
6
  $body_: 'body',
34
7
  $headers_: 'headers',
35
8
  $path_: 'path',
36
9
  $query_: 'query',
37
10
  };
38
- var extraPrefixes = Object.entries(extraPrefixesMap);
39
- var buildKeyMap = function (fields, map) {
40
- var e_1, _a;
11
+ const extraPrefixes = Object.entries(extraPrefixesMap);
12
+ const buildKeyMap = (fields, map) => {
41
13
  if (!map) {
42
14
  map = new Map();
43
15
  }
44
- try {
45
- for (var fields_1 = __values(fields), fields_1_1 = fields_1.next(); !fields_1_1.done; fields_1_1 = fields_1.next()) {
46
- var config = fields_1_1.value;
47
- if ('in' in config) {
48
- if (config.key) {
49
- map.set(config.key, {
50
- in: config.in,
51
- map: config.map,
52
- });
53
- }
54
- }
55
- else if ('key' in config) {
16
+ for (const config of fields) {
17
+ if ('in' in config) {
18
+ if (config.key) {
56
19
  map.set(config.key, {
20
+ in: config.in,
57
21
  map: config.map,
58
22
  });
59
23
  }
60
- else if (config.args) {
61
- buildKeyMap(config.args, map);
62
- }
63
24
  }
64
- }
65
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
66
- finally {
67
- try {
68
- if (fields_1_1 && !fields_1_1.done && (_a = fields_1.return)) _a.call(fields_1);
25
+ else if ('key' in config) {
26
+ map.set(config.key, {
27
+ map: config.map,
28
+ });
29
+ }
30
+ else if (config.args) {
31
+ buildKeyMap(config.args, map);
69
32
  }
70
- finally { if (e_1) throw e_1.error; }
71
33
  }
72
34
  return map;
73
35
  };
74
- var stripEmptySlots = function (params) {
75
- var e_2, _a;
76
- try {
77
- for (var _b = __values(Object.entries(params)), _c = _b.next(); !_c.done; _c = _b.next()) {
78
- var _d = __read(_c.value, 2), slot = _d[0], value = _d[1];
79
- if (value && typeof value === 'object' && !Object.keys(value).length) {
80
- delete params[slot];
81
- }
36
+ const stripEmptySlots = (params) => {
37
+ for (const [slot, value] of Object.entries(params)) {
38
+ if (value && typeof value === 'object' && !Array.isArray(value) && !Object.keys(value).length) {
39
+ delete params[slot];
82
40
  }
83
41
  }
84
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
85
- finally {
86
- try {
87
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
88
- }
89
- finally { if (e_2) throw e_2.error; }
90
- }
91
42
  };
92
- var buildClientParams = function (args, fields) {
93
- var e_3, _a, e_4, _b;
94
- var params = {
43
+ const buildClientParams = (args, fields) => {
44
+ const params = {
95
45
  body: {},
96
46
  headers: {},
97
47
  path: {},
98
48
  query: {},
99
49
  };
100
- var map = buildKeyMap(fields);
101
- var config;
102
- try {
103
- for (var _c = __values(args.entries()), _d = _c.next(); !_d.done; _d = _c.next()) {
104
- var _e = __read(_d.value, 2), index = _e[0], arg = _e[1];
105
- if (fields[index]) {
106
- config = fields[index];
50
+ const map = buildKeyMap(fields);
51
+ let config;
52
+ for (const [index, arg] of args.entries()) {
53
+ if (fields[index]) {
54
+ config = fields[index];
55
+ }
56
+ if (!config) {
57
+ continue;
58
+ }
59
+ if ('in' in config) {
60
+ if (config.key) {
61
+ const field = map.get(config.key);
62
+ const name = field.map || config.key;
63
+ if (field.in) {
64
+ params[field.in][name] = arg;
65
+ }
107
66
  }
108
- if (!config) {
109
- continue;
67
+ else {
68
+ params.body = arg;
110
69
  }
111
- if ('in' in config) {
112
- if (config.key) {
113
- var field = map.get(config.key);
114
- var name_1 = field.map || config.key;
70
+ }
71
+ else {
72
+ for (const [key, value] of Object.entries(arg ?? {})) {
73
+ const field = map.get(key);
74
+ if (field) {
115
75
  if (field.in) {
116
- params[field.in][name_1] = arg;
76
+ const name = field.map || key;
77
+ params[field.in][name] = value;
78
+ }
79
+ else {
80
+ params[field.map] = value;
117
81
  }
118
82
  }
119
83
  else {
120
- params.body = arg;
121
- }
122
- }
123
- else {
124
- var _loop_1 = function (key, value) {
125
- var e_5, _j;
126
- var field = map.get(key);
127
- if (field) {
128
- if (field.in) {
129
- var name_2 = field.map || key;
130
- params[field.in][name_2] = value;
131
- }
132
- else {
133
- params[field.map] = value;
134
- }
84
+ const extra = extraPrefixes.find(([prefix]) => key.startsWith(prefix));
85
+ if (extra) {
86
+ const [prefix, slot] = extra;
87
+ params[slot][key.slice(prefix.length)] = value;
135
88
  }
136
- else {
137
- var extra = extraPrefixes.find(function (_a) {
138
- var _b = __read(_a, 1), prefix = _b[0];
139
- return key.startsWith(prefix);
140
- });
141
- if (extra) {
142
- var _k = __read(extra, 2), prefix = _k[0], slot = _k[1];
143
- params[slot][key.slice(prefix.length)] = value;
144
- }
145
- else if ('allowExtra' in config && config.allowExtra) {
146
- try {
147
- for (var _l = (e_5 = void 0, __values(Object.entries(config.allowExtra))), _m = _l.next(); !_m.done; _m = _l.next()) {
148
- var _o = __read(_m.value, 2), slot = _o[0], allowed = _o[1];
149
- if (allowed) {
150
- params[slot][key] = value;
151
- break;
152
- }
153
- }
154
- }
155
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
156
- finally {
157
- try {
158
- if (_m && !_m.done && (_j = _l.return)) _j.call(_l);
159
- }
160
- finally { if (e_5) throw e_5.error; }
89
+ else if ('allowExtra' in config && config.allowExtra) {
90
+ for (const [slot, allowed] of Object.entries(config.allowExtra)) {
91
+ if (allowed) {
92
+ params[slot][key] = value;
93
+ break;
161
94
  }
162
95
  }
163
96
  }
164
- };
165
- try {
166
- for (var _f = (e_4 = void 0, __values(Object.entries(arg !== null && arg !== void 0 ? arg : {}))), _g = _f.next(); !_g.done; _g = _f.next()) {
167
- var _h = __read(_g.value, 2), key = _h[0], value = _h[1];
168
- _loop_1(key, value);
169
- }
170
- }
171
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
172
- finally {
173
- try {
174
- if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
175
- }
176
- finally { if (e_4) throw e_4.error; }
177
97
  }
178
98
  }
179
99
  }
180
100
  }
181
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
182
- finally {
183
- try {
184
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
185
- }
186
- finally { if (e_3) throw e_3.error; }
187
- }
188
101
  stripEmptySlots(params);
189
102
  return params;
190
103
  };
@@ -1,33 +1,8 @@
1
1
  "use strict";
2
- // This file is auto-generated by @hey-api/openapi-ts
3
- var __read = (this && this.__read) || function (o, n) {
4
- var m = typeof Symbol === "function" && o[Symbol.iterator];
5
- if (!m) return o;
6
- var i = m.call(o), r, ar = [], e;
7
- try {
8
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
9
- }
10
- catch (error) { e = { error: error }; }
11
- finally {
12
- try {
13
- if (r && !r.done && (m = i["return"])) m.call(i);
14
- }
15
- finally { if (e) throw e.error; }
16
- }
17
- return ar;
18
- };
19
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
20
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
21
- if (ar || !(i in from)) {
22
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
23
- ar[i] = from[i];
24
- }
25
- }
26
- return to.concat(ar || Array.prototype.slice.call(from));
27
- };
2
+ // This file is auto-generated based on the Examplary API schema.
28
3
  Object.defineProperty(exports, "__esModule", { value: true });
29
4
  exports.serializeObjectParam = exports.serializePrimitiveParam = exports.serializeArrayParam = exports.separatorObjectExplode = exports.separatorArrayNoExplode = exports.separatorArrayExplode = void 0;
30
- var separatorArrayExplode = function (style) {
5
+ const separatorArrayExplode = (style) => {
31
6
  switch (style) {
32
7
  case 'label':
33
8
  return '.';
@@ -40,7 +15,7 @@ var separatorArrayExplode = function (style) {
40
15
  }
41
16
  };
42
17
  exports.separatorArrayExplode = separatorArrayExplode;
43
- var separatorArrayNoExplode = function (style) {
18
+ const separatorArrayNoExplode = (style) => {
44
19
  switch (style) {
45
20
  case 'form':
46
21
  return ',';
@@ -53,7 +28,7 @@ var separatorArrayNoExplode = function (style) {
53
28
  }
54
29
  };
55
30
  exports.separatorArrayNoExplode = separatorArrayNoExplode;
56
- var separatorObjectExplode = function (style) {
31
+ const separatorObjectExplode = (style) => {
57
32
  switch (style) {
58
33
  case 'label':
59
34
  return '.';
@@ -66,30 +41,29 @@ var separatorObjectExplode = function (style) {
66
41
  }
67
42
  };
68
43
  exports.separatorObjectExplode = separatorObjectExplode;
69
- var serializeArrayParam = function (_a) {
70
- var allowReserved = _a.allowReserved, explode = _a.explode, name = _a.name, style = _a.style, value = _a.value;
44
+ const serializeArrayParam = ({ allowReserved, explode, name, style, value, }) => {
71
45
  if (!explode) {
72
- var joinedValues_1 = (allowReserved ? value : value.map(function (v) { return encodeURIComponent(v); })).join((0, exports.separatorArrayNoExplode)(style));
46
+ const joinedValues = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join((0, exports.separatorArrayNoExplode)(style));
73
47
  switch (style) {
74
48
  case 'label':
75
- return ".".concat(joinedValues_1);
49
+ return `.${joinedValues}`;
76
50
  case 'matrix':
77
- return ";".concat(name, "=").concat(joinedValues_1);
51
+ return `;${name}=${joinedValues}`;
78
52
  case 'simple':
79
- return joinedValues_1;
53
+ return joinedValues;
80
54
  default:
81
- return "".concat(name, "=").concat(joinedValues_1);
55
+ return `${name}=${joinedValues}`;
82
56
  }
83
57
  }
84
- var separator = (0, exports.separatorArrayExplode)(style);
85
- var joinedValues = value
86
- .map(function (v) {
58
+ const separator = (0, exports.separatorArrayExplode)(style);
59
+ const joinedValues = value
60
+ .map((v) => {
87
61
  if (style === 'label' || style === 'simple') {
88
62
  return allowReserved ? v : encodeURIComponent(v);
89
63
  }
90
64
  return (0, exports.serializePrimitiveParam)({
91
- allowReserved: allowReserved,
92
- name: name,
65
+ allowReserved,
66
+ name,
93
67
  value: v,
94
68
  });
95
69
  })
@@ -97,50 +71,44 @@ var serializeArrayParam = function (_a) {
97
71
  return style === 'label' || style === 'matrix' ? separator + joinedValues : joinedValues;
98
72
  };
99
73
  exports.serializeArrayParam = serializeArrayParam;
100
- var serializePrimitiveParam = function (_a) {
101
- var allowReserved = _a.allowReserved, name = _a.name, value = _a.value;
74
+ const serializePrimitiveParam = ({ allowReserved, name, value, }) => {
102
75
  if (value === undefined || value === null) {
103
76
  return '';
104
77
  }
105
78
  if (typeof value === 'object') {
106
79
  throw new Error('Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.');
107
80
  }
108
- return "".concat(name, "=").concat(allowReserved ? value : encodeURIComponent(value));
81
+ return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
109
82
  };
110
83
  exports.serializePrimitiveParam = serializePrimitiveParam;
111
- var serializeObjectParam = function (_a) {
112
- var allowReserved = _a.allowReserved, explode = _a.explode, name = _a.name, style = _a.style, value = _a.value, valueOnly = _a.valueOnly;
84
+ const serializeObjectParam = ({ allowReserved, explode, name, style, value, valueOnly, }) => {
113
85
  if (value instanceof Date) {
114
- return valueOnly ? value.toISOString() : "".concat(name, "=").concat(value.toISOString());
86
+ return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
115
87
  }
116
88
  if (style !== 'deepObject' && !explode) {
117
- var values_1 = [];
118
- Object.entries(value).forEach(function (_a) {
119
- var _b = __read(_a, 2), key = _b[0], v = _b[1];
120
- values_1 = __spreadArray(__spreadArray([], __read(values_1), false), [key, allowReserved ? v : encodeURIComponent(v)], false);
89
+ let values = [];
90
+ Object.entries(value).forEach(([key, v]) => {
91
+ values = [...values, key, allowReserved ? v : encodeURIComponent(v)];
121
92
  });
122
- var joinedValues_2 = values_1.join(',');
93
+ const joinedValues = values.join(',');
123
94
  switch (style) {
124
95
  case 'form':
125
- return "".concat(name, "=").concat(joinedValues_2);
96
+ return `${name}=${joinedValues}`;
126
97
  case 'label':
127
- return ".".concat(joinedValues_2);
98
+ return `.${joinedValues}`;
128
99
  case 'matrix':
129
- return ";".concat(name, "=").concat(joinedValues_2);
100
+ return `;${name}=${joinedValues}`;
130
101
  default:
131
- return joinedValues_2;
102
+ return joinedValues;
132
103
  }
133
104
  }
134
- var separator = (0, exports.separatorObjectExplode)(style);
135
- var joinedValues = Object.entries(value)
136
- .map(function (_a) {
137
- var _b = __read(_a, 2), key = _b[0], v = _b[1];
138
- return (0, exports.serializePrimitiveParam)({
139
- allowReserved: allowReserved,
140
- name: style === 'deepObject' ? "".concat(name, "[").concat(key, "]") : key,
141
- value: v,
142
- });
143
- })
105
+ const separator = (0, exports.separatorObjectExplode)(style);
106
+ const joinedValues = Object.entries(value)
107
+ .map(([key, v]) => (0, exports.serializePrimitiveParam)({
108
+ allowReserved,
109
+ name: style === 'deepObject' ? `${name}[${key}]` : key,
110
+ value: v,
111
+ }))
144
112
  .join(separator);
145
113
  return style === 'label' || style === 'matrix' ? separator + joinedValues : joinedValues;
146
114
  };
@@ -7,7 +7,7 @@ export type JsonValue = null | string | number | boolean | JsonValue[] | {
7
7
  /**
8
8
  * Replacer that converts non-JSON values (bigint, Date, etc.) to safe substitutes.
9
9
  */
10
- export declare const queryKeyJsonReplacer: (_key: string, value: unknown) => unknown;
10
+ export declare const queryKeyJsonReplacer: (_key: string, value: unknown) => {} | null | undefined;
11
11
  /**
12
12
  * Safely stringifies a value and parses it back into a JsonValue.
13
13
  */
@@ -1,38 +1,11 @@
1
1
  "use strict";
2
- // This file is auto-generated by @hey-api/openapi-ts
3
- var __read = (this && this.__read) || function (o, n) {
4
- var m = typeof Symbol === "function" && o[Symbol.iterator];
5
- if (!m) return o;
6
- var i = m.call(o), r, ar = [], e;
7
- try {
8
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
9
- }
10
- catch (error) { e = { error: error }; }
11
- finally {
12
- try {
13
- if (r && !r.done && (m = i["return"])) m.call(i);
14
- }
15
- finally { if (e) throw e.error; }
16
- }
17
- return ar;
18
- };
19
- var __values = (this && this.__values) || function(o) {
20
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
21
- if (m) return m.call(o);
22
- if (o && typeof o.length === "number") return {
23
- next: function () {
24
- if (o && i >= o.length) o = void 0;
25
- return { value: o && o[i++], done: !o };
26
- }
27
- };
28
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
29
- };
2
+ // This file is auto-generated based on the Examplary API schema.
30
3
  Object.defineProperty(exports, "__esModule", { value: true });
31
4
  exports.serializeQueryKeyValue = exports.stringifyToJsonValue = exports.queryKeyJsonReplacer = void 0;
32
5
  /**
33
6
  * Replacer that converts non-JSON values (bigint, Date, etc.) to safe substitutes.
34
7
  */
35
- var queryKeyJsonReplacer = function (_key, value) {
8
+ const queryKeyJsonReplacer = (_key, value) => {
36
9
  if (value === undefined || typeof value === 'function' || typeof value === 'symbol') {
37
10
  return undefined;
38
11
  }
@@ -48,15 +21,15 @@ exports.queryKeyJsonReplacer = queryKeyJsonReplacer;
48
21
  /**
49
22
  * Safely stringifies a value and parses it back into a JsonValue.
50
23
  */
51
- var stringifyToJsonValue = function (input) {
24
+ const stringifyToJsonValue = (input) => {
52
25
  try {
53
- var json = JSON.stringify(input, exports.queryKeyJsonReplacer);
26
+ const json = JSON.stringify(input, exports.queryKeyJsonReplacer);
54
27
  if (json === undefined) {
55
28
  return undefined;
56
29
  }
57
30
  return JSON.parse(json);
58
31
  }
59
- catch (_a) {
32
+ catch {
60
33
  return undefined;
61
34
  }
62
35
  };
@@ -64,53 +37,38 @@ exports.stringifyToJsonValue = stringifyToJsonValue;
64
37
  /**
65
38
  * Detects plain objects (including objects with a null prototype).
66
39
  */
67
- var isPlainObject = function (value) {
40
+ const isPlainObject = (value) => {
68
41
  if (value === null || typeof value !== 'object') {
69
42
  return false;
70
43
  }
71
- var prototype = Object.getPrototypeOf(value);
44
+ const prototype = Object.getPrototypeOf(value);
72
45
  return prototype === Object.prototype || prototype === null;
73
46
  };
74
47
  /**
75
48
  * Turns URLSearchParams into a sorted JSON object for deterministic keys.
76
49
  */
77
- var serializeSearchParams = function (params) {
78
- var e_1, _a;
79
- var entries = Array.from(params.entries()).sort(function (_a, _b) {
80
- var _c = __read(_a, 1), a = _c[0];
81
- var _d = __read(_b, 1), b = _d[0];
82
- return a.localeCompare(b);
83
- });
84
- var result = {};
85
- try {
86
- for (var entries_1 = __values(entries), entries_1_1 = entries_1.next(); !entries_1_1.done; entries_1_1 = entries_1.next()) {
87
- var _b = __read(entries_1_1.value, 2), key = _b[0], value = _b[1];
88
- var existing = result[key];
89
- if (existing === undefined) {
90
- result[key] = value;
91
- continue;
92
- }
93
- if (Array.isArray(existing)) {
94
- existing.push(value);
95
- }
96
- else {
97
- result[key] = [existing, value];
98
- }
50
+ const serializeSearchParams = (params) => {
51
+ const entries = Array.from(params.entries()).sort(([a], [b]) => a.localeCompare(b));
52
+ const result = {};
53
+ for (const [key, value] of entries) {
54
+ const existing = result[key];
55
+ if (existing === undefined) {
56
+ result[key] = value;
57
+ continue;
99
58
  }
100
- }
101
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
102
- finally {
103
- try {
104
- if (entries_1_1 && !entries_1_1.done && (_a = entries_1.return)) _a.call(entries_1);
59
+ if (Array.isArray(existing)) {
60
+ existing.push(value);
61
+ }
62
+ else {
63
+ result[key] = [existing, value];
105
64
  }
106
- finally { if (e_1) throw e_1.error; }
107
65
  }
108
66
  return result;
109
67
  };
110
68
  /**
111
69
  * Normalizes any accepted value into a JSON-friendly shape for query keys.
112
70
  */
113
- var serializeQueryKeyValue = function (value) {
71
+ const serializeQueryKeyValue = (value) => {
114
72
  if (value === null) {
115
73
  return null;
116
74
  }
@@ -68,4 +68,4 @@ export interface StreamEvent<TData = unknown> {
68
68
  export type ServerSentEventsResult<TData = unknown, TReturn = void, TNext = unknown> = {
69
69
  stream: AsyncGenerator<TData extends Record<string, unknown> ? TData[keyof TData] : TData, TReturn, TNext>;
70
70
  };
71
- export declare const createSseClient: <TData = unknown>({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url, ...options }: ServerSentEventsOptions) => ServerSentEventsResult<TData>;
71
+ export declare function createSseClient<TData = unknown>({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url, ...options }: ServerSentEventsOptions): ServerSentEventsResult<TData>;