@fern-api/typescript-dynamic-snippets 0.0.6 → 0.0.8
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/cjs/DynamicSnippetsGenerator.cjs +17 -5508
- package/cjs/DynamicSnippetsGenerator.d.cts +4 -2
- package/cjs/{DynamicSnippetsGeneratorContext-DFkk3dho.d.cts → DynamicSnippetsGeneratorContext-CmDa2k9n.d.cts} +1 -1
- package/cjs/EndpointSnippetGenerator.cjs +17 -3539
- package/cjs/EndpointSnippetGenerator.d.cts +1 -1
- package/cjs/context/DynamicSnippetsGeneratorContext.cjs +17 -4863
- package/cjs/context/DynamicSnippetsGeneratorContext.d.cts +1 -1
- package/cjs/context/DynamicTypeLiteralMapper.cjs +17 -3493
- package/cjs/context/DynamicTypeLiteralMapper.d.cts +1 -1
- package/cjs/context/FilePropertyMapper.cjs +17 -3073
- package/cjs/context/FilePropertyMapper.d.cts +1 -1
- package/cjs/index.cjs +29 -8811
- package/cjs/index.d.cts +2 -1
- package/esm/DynamicSnippetsGenerator.d.ts +4 -2
- package/esm/DynamicSnippetsGenerator.js +1 -12
- package/esm/{DynamicSnippetsGeneratorContext-DFkk3dho.d.ts → DynamicSnippetsGeneratorContext-CmDa2k9n.d.ts} +1 -1
- package/esm/EndpointSnippetGenerator.d.ts +1 -1
- package/esm/EndpointSnippetGenerator.js +1 -8
- package/esm/chunk-3SA25SVX.js +1 -0
- package/esm/chunk-D7ZDXIQ6.js +1 -0
- package/esm/chunk-DJQMPRPJ.js +1 -0
- package/esm/chunk-JGNWFXNM.js +1 -0
- package/esm/chunk-RL2XA35J.js +27 -0
- package/esm/chunk-T2HPPEKP.js +14 -0
- package/esm/chunk-XC2QAVJY.js +1 -0
- package/esm/context/DynamicSnippetsGeneratorContext.d.ts +1 -1
- package/esm/context/DynamicSnippetsGeneratorContext.js +1 -10
- package/esm/context/DynamicTypeLiteralMapper.d.ts +1 -1
- package/esm/context/DynamicTypeLiteralMapper.js +1 -8
- package/esm/context/FilePropertyMapper.d.ts +1 -1
- package/esm/context/FilePropertyMapper.js +1 -7
- package/esm/index.d.ts +2 -1
- package/esm/index.js +13 -3311
- package/package.json +2 -2
- package/esm/chunk-37WY6L3Q.js +0 -551
- package/esm/chunk-6Y2IOBCK.js +0 -501
- package/esm/chunk-KUITDN45.js +0 -538
- package/esm/chunk-MR7ZAFRL.js +0 -819
- package/esm/chunk-PLZLTFT4.js +0 -90
- package/esm/chunk-TKT54OF7.js +0 -86
- package/esm/chunk-WPDO6IRW.js +0 -3060
package/package.json
CHANGED
package/esm/chunk-37WY6L3Q.js
DELETED
|
@@ -1,551 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__objRest,
|
|
3
|
-
__publicField,
|
|
4
|
-
__restKey,
|
|
5
|
-
__spreadProps,
|
|
6
|
-
__spreadValues,
|
|
7
|
-
assertNever,
|
|
8
|
-
init_buffer,
|
|
9
|
-
init_process,
|
|
10
|
-
keys
|
|
11
|
-
} from "./chunk-WPDO6IRW.js";
|
|
12
|
-
|
|
13
|
-
// ../../browser-compatible-base/lib/dynamic-snippets/AbstractDynamicSnippetsGenerator.js
|
|
14
|
-
init_process();
|
|
15
|
-
init_buffer();
|
|
16
|
-
var AbstractDynamicSnippetsGenerator = class {
|
|
17
|
-
constructor(context) {
|
|
18
|
-
__publicField(this, "context");
|
|
19
|
-
this.context = context;
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
// ../../browser-compatible-base/lib/dynamic-snippets/ErrorReporter.js
|
|
24
|
-
init_process();
|
|
25
|
-
init_buffer();
|
|
26
|
-
var Severity = {
|
|
27
|
-
Critical: "CRITICAL",
|
|
28
|
-
Warning: "WARNING"
|
|
29
|
-
};
|
|
30
|
-
var ErrorReporter = class _ErrorReporter {
|
|
31
|
-
constructor() {
|
|
32
|
-
__publicField(this, "errors");
|
|
33
|
-
__publicField(this, "path");
|
|
34
|
-
this.errors = [];
|
|
35
|
-
this.path = [];
|
|
36
|
-
}
|
|
37
|
-
add(err) {
|
|
38
|
-
this.errors.push(__spreadProps(__spreadValues({}, err), {
|
|
39
|
-
path: [...this.path]
|
|
40
|
-
}));
|
|
41
|
-
}
|
|
42
|
-
scope(path) {
|
|
43
|
-
this.path.push(path);
|
|
44
|
-
}
|
|
45
|
-
unscope() {
|
|
46
|
-
this.path.pop();
|
|
47
|
-
}
|
|
48
|
-
getBySeverity(severity) {
|
|
49
|
-
return this.errors.filter((err) => err.severity === severity);
|
|
50
|
-
}
|
|
51
|
-
empty() {
|
|
52
|
-
return this.errors.length === 0;
|
|
53
|
-
}
|
|
54
|
-
size() {
|
|
55
|
-
return this.errors.length;
|
|
56
|
-
}
|
|
57
|
-
clone() {
|
|
58
|
-
const clone = new _ErrorReporter();
|
|
59
|
-
clone.errors = [...this.errors];
|
|
60
|
-
clone.path = [...this.path];
|
|
61
|
-
return clone;
|
|
62
|
-
}
|
|
63
|
-
reset() {
|
|
64
|
-
this.errors = [];
|
|
65
|
-
this.path = [];
|
|
66
|
-
}
|
|
67
|
-
toDynamicSnippetErrors() {
|
|
68
|
-
return this.errors.map((err) => ({
|
|
69
|
-
severity: err.severity,
|
|
70
|
-
path: err.path != null ? this.pathToStringArray(err.path) : void 0,
|
|
71
|
-
message: err.message
|
|
72
|
-
}));
|
|
73
|
-
}
|
|
74
|
-
pathToStringArray(path) {
|
|
75
|
-
const result = [];
|
|
76
|
-
for (const item of path) {
|
|
77
|
-
if (typeof item === "string") {
|
|
78
|
-
result.push(item);
|
|
79
|
-
continue;
|
|
80
|
-
}
|
|
81
|
-
result[result.length - 1] += `[${item.index}]`;
|
|
82
|
-
}
|
|
83
|
-
return result;
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
// ../../browser-compatible-base/lib/dynamic-snippets/AbstractDynamicSnippetsGeneratorContext.js
|
|
88
|
-
init_process();
|
|
89
|
-
init_buffer();
|
|
90
|
-
|
|
91
|
-
// ../../../packages/cli/fern-definition/schema/lib/index.js
|
|
92
|
-
init_process();
|
|
93
|
-
init_buffer();
|
|
94
|
-
|
|
95
|
-
// ../../../packages/cli/fern-definition/schema/lib/utils/HttpEndpointReferenceParser.js
|
|
96
|
-
init_process();
|
|
97
|
-
init_buffer();
|
|
98
|
-
var HttpEndpointReferenceParser = class {
|
|
99
|
-
constructor() {
|
|
100
|
-
//eslint-disable-next-line
|
|
101
|
-
__publicField(this, "REFERENCE_REGEX", /^(GET|POST|PUT|DELETE|PATCH)\s(\/[a-zA-Z0-9\/{}_-]*)$/);
|
|
102
|
-
}
|
|
103
|
-
validate(reference) {
|
|
104
|
-
const validFormat = this.REFERENCE_REGEX.test(reference);
|
|
105
|
-
if (!validFormat) {
|
|
106
|
-
return { type: "invalid" };
|
|
107
|
-
}
|
|
108
|
-
return { type: "valid" };
|
|
109
|
-
}
|
|
110
|
-
tryParse(reference) {
|
|
111
|
-
const validationResponse = this.validate(reference);
|
|
112
|
-
if (validationResponse.type === "invalid") {
|
|
113
|
-
return void 0;
|
|
114
|
-
}
|
|
115
|
-
const match = reference.match(this.REFERENCE_REGEX);
|
|
116
|
-
if (match == null || match[1] == null || match[2] == null) {
|
|
117
|
-
return void 0;
|
|
118
|
-
}
|
|
119
|
-
return {
|
|
120
|
-
method: match[1],
|
|
121
|
-
path: match[2]
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
// ../../browser-compatible-base/lib/dynamic-snippets/AbstractDynamicSnippetsGeneratorContext.js
|
|
127
|
-
var AbstractDynamicSnippetsGeneratorContext = class {
|
|
128
|
-
constructor({ ir, config }) {
|
|
129
|
-
__publicField(this, "config");
|
|
130
|
-
__publicField(this, "errors");
|
|
131
|
-
__publicField(this, "_ir");
|
|
132
|
-
__publicField(this, "httpEndpointReferenceParser");
|
|
133
|
-
this._ir = ir;
|
|
134
|
-
this.config = config;
|
|
135
|
-
this.errors = new ErrorReporter();
|
|
136
|
-
this.httpEndpointReferenceParser = new HttpEndpointReferenceParser();
|
|
137
|
-
}
|
|
138
|
-
associateQueryParametersByWireValue({ parameters, values }) {
|
|
139
|
-
const instances = [];
|
|
140
|
-
for (const [key, value] of Object.entries(values)) {
|
|
141
|
-
this.errors.scope(key);
|
|
142
|
-
try {
|
|
143
|
-
const parameter = parameters.find((param) => param.name.wireValue === key);
|
|
144
|
-
if (parameter == null) {
|
|
145
|
-
throw this.newParameterNotRecognizedError(key);
|
|
146
|
-
}
|
|
147
|
-
const typeInstanceValue = this.isListTypeReference(parameter.typeReference) && !Array.isArray(value) ? [value] : value;
|
|
148
|
-
instances.push({
|
|
149
|
-
name: parameter.name,
|
|
150
|
-
typeReference: parameter.typeReference,
|
|
151
|
-
value: typeInstanceValue
|
|
152
|
-
});
|
|
153
|
-
} finally {
|
|
154
|
-
this.errors.unscope();
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
return instances;
|
|
158
|
-
}
|
|
159
|
-
associateByWireValue({ parameters, values, ignoreMissingParameters }) {
|
|
160
|
-
const instances = [];
|
|
161
|
-
for (const [key, value] of Object.entries(values)) {
|
|
162
|
-
this.errors.scope(key);
|
|
163
|
-
try {
|
|
164
|
-
const parameter = parameters.find((param) => param.name.wireValue === key);
|
|
165
|
-
if (parameter == null) {
|
|
166
|
-
if (ignoreMissingParameters) {
|
|
167
|
-
continue;
|
|
168
|
-
}
|
|
169
|
-
this.errors.add({
|
|
170
|
-
severity: Severity.Critical,
|
|
171
|
-
message: this.newParameterNotRecognizedError(key).message
|
|
172
|
-
});
|
|
173
|
-
continue;
|
|
174
|
-
}
|
|
175
|
-
instances.push({
|
|
176
|
-
name: parameter.name,
|
|
177
|
-
typeReference: parameter.typeReference,
|
|
178
|
-
value
|
|
179
|
-
});
|
|
180
|
-
} finally {
|
|
181
|
-
this.errors.unscope();
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
return instances;
|
|
185
|
-
}
|
|
186
|
-
getSingleFileValue({ property, record }) {
|
|
187
|
-
const fileValue = record[property.wireValue];
|
|
188
|
-
if (fileValue == null) {
|
|
189
|
-
return void 0;
|
|
190
|
-
}
|
|
191
|
-
if (typeof fileValue !== "string") {
|
|
192
|
-
this.errors.add({
|
|
193
|
-
severity: Severity.Critical,
|
|
194
|
-
message: `Expected file value to be a string, got ${typeof fileValue}`
|
|
195
|
-
});
|
|
196
|
-
return void 0;
|
|
197
|
-
}
|
|
198
|
-
return fileValue;
|
|
199
|
-
}
|
|
200
|
-
getFileArrayValues({ property, record }) {
|
|
201
|
-
const fileArrayValue = record[property.wireValue];
|
|
202
|
-
if (fileArrayValue == null) {
|
|
203
|
-
return void 0;
|
|
204
|
-
}
|
|
205
|
-
if (!Array.isArray(fileArrayValue)) {
|
|
206
|
-
this.errors.add({
|
|
207
|
-
severity: Severity.Critical,
|
|
208
|
-
message: `Expected file array value to be an array of strings, got ${typeof fileArrayValue}`
|
|
209
|
-
});
|
|
210
|
-
return void 0;
|
|
211
|
-
}
|
|
212
|
-
const stringValues = [];
|
|
213
|
-
for (const value of fileArrayValue) {
|
|
214
|
-
if (typeof value !== "string") {
|
|
215
|
-
this.errors.add({
|
|
216
|
-
severity: Severity.Critical,
|
|
217
|
-
message: `Expected file array value to be an array of strings, got ${typeof value}`
|
|
218
|
-
});
|
|
219
|
-
return void 0;
|
|
220
|
-
}
|
|
221
|
-
stringValues.push(value);
|
|
222
|
-
}
|
|
223
|
-
return stringValues;
|
|
224
|
-
}
|
|
225
|
-
getRecord(value) {
|
|
226
|
-
if (typeof value !== "object" || Array.isArray(value)) {
|
|
227
|
-
this.errors.add({
|
|
228
|
-
severity: Severity.Critical,
|
|
229
|
-
message: `Expected object with key, value pairs but got: ${Array.isArray(value) ? "array" : typeof value}`
|
|
230
|
-
});
|
|
231
|
-
return void 0;
|
|
232
|
-
}
|
|
233
|
-
if (value == null) {
|
|
234
|
-
return {};
|
|
235
|
-
}
|
|
236
|
-
return value;
|
|
237
|
-
}
|
|
238
|
-
resolveNamedType({ typeId }) {
|
|
239
|
-
const namedType = this._ir.types[typeId];
|
|
240
|
-
if (namedType == null) {
|
|
241
|
-
this.errors.add({
|
|
242
|
-
severity: Severity.Critical,
|
|
243
|
-
message: `Type identified by "${typeId}" could not be found`
|
|
244
|
-
});
|
|
245
|
-
return void 0;
|
|
246
|
-
}
|
|
247
|
-
return namedType;
|
|
248
|
-
}
|
|
249
|
-
resolveDiscriminatedUnionTypeInstance({ discriminatedUnion, value }) {
|
|
250
|
-
const record = this.getRecord(value);
|
|
251
|
-
if (record == null) {
|
|
252
|
-
return void 0;
|
|
253
|
-
}
|
|
254
|
-
const discriminantFieldName = discriminatedUnion.discriminant.wireValue;
|
|
255
|
-
const discriminantValue = record[discriminantFieldName];
|
|
256
|
-
if (discriminantValue == null) {
|
|
257
|
-
this.errors.add({
|
|
258
|
-
severity: Severity.Critical,
|
|
259
|
-
message: this.newParameterNotRecognizedError(discriminantFieldName).message
|
|
260
|
-
});
|
|
261
|
-
return void 0;
|
|
262
|
-
}
|
|
263
|
-
if (typeof discriminantValue !== "string") {
|
|
264
|
-
this.errors.add({
|
|
265
|
-
severity: Severity.Critical,
|
|
266
|
-
message: `Expected discriminant value to be a string but got: ${typeof discriminantValue}`
|
|
267
|
-
});
|
|
268
|
-
return void 0;
|
|
269
|
-
}
|
|
270
|
-
const singleDiscriminatedUnionType = discriminatedUnion.types[discriminantValue];
|
|
271
|
-
if (singleDiscriminatedUnionType == null) {
|
|
272
|
-
this.errors.add({
|
|
273
|
-
severity: Severity.Critical,
|
|
274
|
-
message: `No type found for discriminant value "${discriminantValue}"`
|
|
275
|
-
});
|
|
276
|
-
return void 0;
|
|
277
|
-
}
|
|
278
|
-
const _a = record, { [discriminantFieldName]: _ } = _a, filtered = __objRest(_a, [__restKey(discriminantFieldName)]);
|
|
279
|
-
return {
|
|
280
|
-
singleDiscriminatedUnionType,
|
|
281
|
-
discriminantValue: singleDiscriminatedUnionType.discriminantValue,
|
|
282
|
-
value: filtered
|
|
283
|
-
};
|
|
284
|
-
}
|
|
285
|
-
resolveEndpointOrThrow(rawEndpoint) {
|
|
286
|
-
const parsedEndpoint = this.httpEndpointReferenceParser.tryParse(rawEndpoint);
|
|
287
|
-
if (parsedEndpoint == null) {
|
|
288
|
-
throw new Error(`Failed to parse endpoint reference "${rawEndpoint}"`);
|
|
289
|
-
}
|
|
290
|
-
return this.resolveEndpointLocationOrThrow(parsedEndpoint);
|
|
291
|
-
}
|
|
292
|
-
resolveEndpointLocationOrThrow(location) {
|
|
293
|
-
const endpoints = [];
|
|
294
|
-
for (const endpoint of Object.values(this._ir.endpoints)) {
|
|
295
|
-
if (this.parsedEndpointMatches({ endpoint, parsedEndpoint: location })) {
|
|
296
|
-
endpoints.push(endpoint);
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
if (endpoints.length === 0) {
|
|
300
|
-
throw new Error(`Failed to find endpoint identified by "${location.method} ${location.path}"`);
|
|
301
|
-
}
|
|
302
|
-
return endpoints;
|
|
303
|
-
}
|
|
304
|
-
needsRequestParameter({ request, inlinePathParameters, inlineFileProperties }) {
|
|
305
|
-
var _a;
|
|
306
|
-
if (this.includePathParametersInWrappedRequest({ request, inlinePathParameters })) {
|
|
307
|
-
return true;
|
|
308
|
-
}
|
|
309
|
-
if (request.queryParameters != null && request.queryParameters.length > 0) {
|
|
310
|
-
return true;
|
|
311
|
-
}
|
|
312
|
-
if (request.headers != null && request.headers.length > 0) {
|
|
313
|
-
return true;
|
|
314
|
-
}
|
|
315
|
-
if (request.body != null) {
|
|
316
|
-
return this.includeRequestBodyInWrappedRequest({ body: request.body, inlineFileProperties });
|
|
317
|
-
}
|
|
318
|
-
if ((_a = request.metadata) == null ? void 0 : _a.onlyPathParameters) {
|
|
319
|
-
return false;
|
|
320
|
-
}
|
|
321
|
-
return true;
|
|
322
|
-
}
|
|
323
|
-
includePathParametersInWrappedRequest({ request, inlinePathParameters }) {
|
|
324
|
-
var _a, _b;
|
|
325
|
-
return inlinePathParameters && ((_b = (_a = request.metadata) == null ? void 0 : _a.includePathParameters) != null ? _b : false);
|
|
326
|
-
}
|
|
327
|
-
isFileUploadRequestBody(body) {
|
|
328
|
-
switch (body.type) {
|
|
329
|
-
case "fileUpload":
|
|
330
|
-
return true;
|
|
331
|
-
case "properties":
|
|
332
|
-
case "referenced":
|
|
333
|
-
return false;
|
|
334
|
-
default:
|
|
335
|
-
assertNever(body);
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
resolveEnvironmentName(environmentID) {
|
|
339
|
-
if (this._ir.environments == null) {
|
|
340
|
-
return void 0;
|
|
341
|
-
}
|
|
342
|
-
const environments = this._ir.environments.environments;
|
|
343
|
-
switch (environments.type) {
|
|
344
|
-
case "singleBaseUrl": {
|
|
345
|
-
const environment = environments.environments.find((env) => env.id === environmentID);
|
|
346
|
-
if (environment == null) {
|
|
347
|
-
return void 0;
|
|
348
|
-
}
|
|
349
|
-
return environment.name;
|
|
350
|
-
}
|
|
351
|
-
case "multipleBaseUrls": {
|
|
352
|
-
const environment = environments.environments.find((env) => env.id === environmentID);
|
|
353
|
-
if (environment == null) {
|
|
354
|
-
return void 0;
|
|
355
|
-
}
|
|
356
|
-
return environment.name;
|
|
357
|
-
}
|
|
358
|
-
default:
|
|
359
|
-
assertNever(environments);
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
isSingleEnvironmentID(environment) {
|
|
363
|
-
return typeof environment === "string";
|
|
364
|
-
}
|
|
365
|
-
isMultiEnvironmentValues(environment) {
|
|
366
|
-
return typeof environment === "object";
|
|
367
|
-
}
|
|
368
|
-
validateMultiEnvironmentUrlValues(multiEnvironmentUrlValues) {
|
|
369
|
-
if (this._ir.environments == null) {
|
|
370
|
-
this.errors.add({
|
|
371
|
-
severity: Severity.Critical,
|
|
372
|
-
message: "Multiple environments are not supported for single base URL environments; use the baseUrl option instead"
|
|
373
|
-
});
|
|
374
|
-
return false;
|
|
375
|
-
}
|
|
376
|
-
const environments = this._ir.environments.environments;
|
|
377
|
-
switch (environments.type) {
|
|
378
|
-
case "singleBaseUrl": {
|
|
379
|
-
this.errors.add({
|
|
380
|
-
severity: Severity.Critical,
|
|
381
|
-
message: "Multiple environments are not supported for single base URL environments; use the baseUrl option instead"
|
|
382
|
-
});
|
|
383
|
-
return false;
|
|
384
|
-
}
|
|
385
|
-
case "multipleBaseUrls": {
|
|
386
|
-
const firstEnvironment = environments.environments[0];
|
|
387
|
-
if (firstEnvironment == null) {
|
|
388
|
-
this.errors.add({
|
|
389
|
-
severity: Severity.Critical,
|
|
390
|
-
message: "Multiple environments are not supported; use the baseUrl option instead"
|
|
391
|
-
});
|
|
392
|
-
return false;
|
|
393
|
-
}
|
|
394
|
-
const expectedKeys = new Set(keys(firstEnvironment.urls));
|
|
395
|
-
for (const key of keys(multiEnvironmentUrlValues)) {
|
|
396
|
-
if (expectedKeys.has(key)) {
|
|
397
|
-
expectedKeys.delete(key);
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
if (expectedKeys.size > 0) {
|
|
401
|
-
this.errors.add({
|
|
402
|
-
severity: Severity.Critical,
|
|
403
|
-
message: `The provided environments are invalid; got: [${Object.keys(multiEnvironmentUrlValues).join(", ")}], expected: [${keys(firstEnvironment.urls).join(", ")}]`
|
|
404
|
-
});
|
|
405
|
-
return false;
|
|
406
|
-
}
|
|
407
|
-
return true;
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
getValueAsNumber({ value }) {
|
|
412
|
-
if (typeof value !== "number") {
|
|
413
|
-
this.errors.add({
|
|
414
|
-
severity: Severity.Critical,
|
|
415
|
-
message: this.newTypeMismatchError({ expected: "number", value }).message
|
|
416
|
-
});
|
|
417
|
-
return void 0;
|
|
418
|
-
}
|
|
419
|
-
return value;
|
|
420
|
-
}
|
|
421
|
-
getValueAsBoolean({ value }) {
|
|
422
|
-
if (typeof value !== "boolean") {
|
|
423
|
-
this.errors.add({
|
|
424
|
-
severity: Severity.Critical,
|
|
425
|
-
message: this.newTypeMismatchError({ expected: "boolean", value }).message
|
|
426
|
-
});
|
|
427
|
-
return void 0;
|
|
428
|
-
}
|
|
429
|
-
return value;
|
|
430
|
-
}
|
|
431
|
-
getValueAsString({ value }) {
|
|
432
|
-
if (typeof value !== "string") {
|
|
433
|
-
this.errors.add({
|
|
434
|
-
severity: Severity.Critical,
|
|
435
|
-
message: this.newTypeMismatchError({ expected: "string", value }).message
|
|
436
|
-
});
|
|
437
|
-
return void 0;
|
|
438
|
-
}
|
|
439
|
-
return value;
|
|
440
|
-
}
|
|
441
|
-
newAuthMismatchError({ auth, values }) {
|
|
442
|
-
return new Error(`Expected auth type ${auth.type}, got ${values.type}`);
|
|
443
|
-
}
|
|
444
|
-
newParameterNotRecognizedError(parameterName) {
|
|
445
|
-
return new Error(`"${parameterName}" is not a recognized parameter for this endpoint`);
|
|
446
|
-
}
|
|
447
|
-
newTypeMismatchError({ expected, value }) {
|
|
448
|
-
return new Error(`Expected ${expected}, got ${typeof value}`);
|
|
449
|
-
}
|
|
450
|
-
includeRequestBodyInWrappedRequest({ body, inlineFileProperties }) {
|
|
451
|
-
switch (body.type) {
|
|
452
|
-
case "properties":
|
|
453
|
-
case "referenced":
|
|
454
|
-
return true;
|
|
455
|
-
case "fileUpload":
|
|
456
|
-
return this.includeFileUploadBodyInWrappedRequest({ fileUpload: body, inlineFileProperties });
|
|
457
|
-
default:
|
|
458
|
-
assertNever(body);
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
includeFileUploadBodyInWrappedRequest({ fileUpload, inlineFileProperties }) {
|
|
462
|
-
return this.fileUploadHasBodyProperties({ fileUpload }) || inlineFileProperties && this.fileUploadHasFileProperties({ fileUpload });
|
|
463
|
-
}
|
|
464
|
-
fileUploadHasBodyProperties({ fileUpload }) {
|
|
465
|
-
return fileUpload.properties.some((property) => {
|
|
466
|
-
switch (property.type) {
|
|
467
|
-
case "file":
|
|
468
|
-
case "fileArray":
|
|
469
|
-
return false;
|
|
470
|
-
case "bodyProperty":
|
|
471
|
-
return true;
|
|
472
|
-
default:
|
|
473
|
-
assertNever(property);
|
|
474
|
-
}
|
|
475
|
-
});
|
|
476
|
-
}
|
|
477
|
-
fileUploadHasFileProperties({ fileUpload }) {
|
|
478
|
-
return fileUpload.properties.some((property) => {
|
|
479
|
-
switch (property.type) {
|
|
480
|
-
case "file":
|
|
481
|
-
case "fileArray":
|
|
482
|
-
return true;
|
|
483
|
-
case "bodyProperty":
|
|
484
|
-
return false;
|
|
485
|
-
default:
|
|
486
|
-
assertNever(property);
|
|
487
|
-
}
|
|
488
|
-
});
|
|
489
|
-
}
|
|
490
|
-
isListTypeReference(typeReference) {
|
|
491
|
-
if (typeReference.type === "optional") {
|
|
492
|
-
return this.isListTypeReference(typeReference.value);
|
|
493
|
-
}
|
|
494
|
-
return typeReference.type === "list" || typeReference.type === "set";
|
|
495
|
-
}
|
|
496
|
-
parsedEndpointMatches({ endpoint, parsedEndpoint }) {
|
|
497
|
-
return endpoint.location.method === parsedEndpoint.method && endpoint.location.path === parsedEndpoint.path;
|
|
498
|
-
}
|
|
499
|
-
};
|
|
500
|
-
|
|
501
|
-
// ../../browser-compatible-base/lib/dynamic-snippets/Result.js
|
|
502
|
-
init_process();
|
|
503
|
-
init_buffer();
|
|
504
|
-
var Result = class {
|
|
505
|
-
constructor() {
|
|
506
|
-
__publicField(this, "reporter");
|
|
507
|
-
__publicField(this, "snippet");
|
|
508
|
-
__publicField(this, "err");
|
|
509
|
-
this.snippet = void 0;
|
|
510
|
-
this.reporter = void 0;
|
|
511
|
-
this.err = void 0;
|
|
512
|
-
}
|
|
513
|
-
update({ context, snippet }) {
|
|
514
|
-
if (this.reporter == null || this.reporter.size() > context.errors.size()) {
|
|
515
|
-
this.reporter = context.errors.clone();
|
|
516
|
-
this.snippet = snippet;
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
getResponseOrThrow({ endpoint }) {
|
|
520
|
-
var _a;
|
|
521
|
-
if (this.snippet != null && this.reporter != null) {
|
|
522
|
-
return {
|
|
523
|
-
snippet: this.snippet,
|
|
524
|
-
errors: this.reporter.toDynamicSnippetErrors()
|
|
525
|
-
};
|
|
526
|
-
}
|
|
527
|
-
throw (_a = this.err) != null ? _a : new Error(`Failed to generate snippet for endpoint "${endpoint.method} ${endpoint.path}"`);
|
|
528
|
-
}
|
|
529
|
-
};
|
|
530
|
-
|
|
531
|
-
// ../../browser-compatible-base/lib/dynamic-snippets/Scope.js
|
|
532
|
-
init_process();
|
|
533
|
-
init_buffer();
|
|
534
|
-
var Scope = {
|
|
535
|
-
PathParameters: "pathParameters",
|
|
536
|
-
QueryParameters: "queryParameters",
|
|
537
|
-
Headers: "headers",
|
|
538
|
-
RequestBody: "requestBody"
|
|
539
|
-
};
|
|
540
|
-
|
|
541
|
-
// ../../browser-compatible-base/lib/dynamic-snippets/index.js
|
|
542
|
-
init_process();
|
|
543
|
-
init_buffer();
|
|
544
|
-
|
|
545
|
-
export {
|
|
546
|
-
AbstractDynamicSnippetsGenerator,
|
|
547
|
-
Severity,
|
|
548
|
-
AbstractDynamicSnippetsGeneratorContext,
|
|
549
|
-
Result,
|
|
550
|
-
Scope
|
|
551
|
-
};
|