@fern-api/typescript-dynamic-snippets 0.0.6 → 0.0.7
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/EndpointSnippetGenerator.cjs +17 -3539
- package/cjs/context/DynamicSnippetsGeneratorContext.cjs +17 -4863
- package/cjs/context/DynamicTypeLiteralMapper.cjs +17 -3493
- package/cjs/context/FilePropertyMapper.cjs +17 -3073
- package/cjs/index.cjs +29 -8811
- package/esm/DynamicSnippetsGenerator.js +1 -12
- package/esm/EndpointSnippetGenerator.js +1 -8
- package/esm/chunk-25TNFA5L.js +14 -0
- package/esm/chunk-736FTN3M.js +1 -0
- package/esm/chunk-CQ55KPJT.js +1 -0
- package/esm/chunk-LX5O4JB7.js +1 -0
- package/esm/chunk-SQLJANKO.js +1 -0
- package/esm/chunk-V6G7NZKW.js +1 -0
- package/esm/chunk-YD6EIACZ.js +27 -0
- package/esm/context/DynamicSnippetsGeneratorContext.js +1 -10
- package/esm/context/DynamicTypeLiteralMapper.js +1 -8
- package/esm/context/FilePropertyMapper.js +1 -7
- 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/esm/chunk-PLZLTFT4.js
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__publicField,
|
|
3
|
-
assertNever,
|
|
4
|
-
init_buffer,
|
|
5
|
-
init_process,
|
|
6
|
-
typescript_exports
|
|
7
|
-
} from "./chunk-WPDO6IRW.js";
|
|
8
|
-
|
|
9
|
-
// src/context/FilePropertyMapper.ts
|
|
10
|
-
init_process();
|
|
11
|
-
init_buffer();
|
|
12
|
-
var FilePropertyMapper = class {
|
|
13
|
-
constructor({ context }) {
|
|
14
|
-
__publicField(this, "context");
|
|
15
|
-
this.context = context;
|
|
16
|
-
}
|
|
17
|
-
getFilePropertyInfo({
|
|
18
|
-
body,
|
|
19
|
-
value
|
|
20
|
-
}) {
|
|
21
|
-
var _a;
|
|
22
|
-
const result = {
|
|
23
|
-
fileFields: [],
|
|
24
|
-
bodyPropertyFields: []
|
|
25
|
-
};
|
|
26
|
-
const record = (_a = this.context.getRecord(value)) != null ? _a : {};
|
|
27
|
-
for (const property of body.properties) {
|
|
28
|
-
switch (property.type) {
|
|
29
|
-
case "file":
|
|
30
|
-
result.fileFields.push({
|
|
31
|
-
name: this.context.getPropertyName(property.name),
|
|
32
|
-
value: this.getSingleFileProperty({ property, record })
|
|
33
|
-
});
|
|
34
|
-
break;
|
|
35
|
-
case "fileArray":
|
|
36
|
-
result.fileFields.push({
|
|
37
|
-
name: this.context.getPropertyName(property.name),
|
|
38
|
-
value: this.getArrayFileProperty({ property, record })
|
|
39
|
-
});
|
|
40
|
-
break;
|
|
41
|
-
case "bodyProperty":
|
|
42
|
-
result.bodyPropertyFields.push({
|
|
43
|
-
name: this.context.getPropertyName(property.name.name),
|
|
44
|
-
value: this.getBodyProperty({ property, record })
|
|
45
|
-
});
|
|
46
|
-
break;
|
|
47
|
-
default:
|
|
48
|
-
assertNever(property);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return result;
|
|
52
|
-
}
|
|
53
|
-
getSingleFileProperty({
|
|
54
|
-
property,
|
|
55
|
-
record
|
|
56
|
-
}) {
|
|
57
|
-
const fileValue = this.context.getSingleFileValue({ property, record });
|
|
58
|
-
if (fileValue == null) {
|
|
59
|
-
return typescript_exports.TypeLiteral.nop();
|
|
60
|
-
}
|
|
61
|
-
return typescript_exports.TypeLiteral.blob(fileValue);
|
|
62
|
-
}
|
|
63
|
-
getArrayFileProperty({
|
|
64
|
-
property,
|
|
65
|
-
record
|
|
66
|
-
}) {
|
|
67
|
-
const fileValues = this.context.getFileArrayValues({ property, record });
|
|
68
|
-
if (fileValues == null) {
|
|
69
|
-
return typescript_exports.TypeLiteral.nop();
|
|
70
|
-
}
|
|
71
|
-
return typescript_exports.TypeLiteral.array({ values: fileValues.map((value) => typescript_exports.TypeLiteral.blob(value)) });
|
|
72
|
-
}
|
|
73
|
-
getBodyProperty({
|
|
74
|
-
property,
|
|
75
|
-
record
|
|
76
|
-
}) {
|
|
77
|
-
const bodyPropertyValue = record[property.name.wireValue];
|
|
78
|
-
if (bodyPropertyValue == null) {
|
|
79
|
-
return typescript_exports.TypeLiteral.nop();
|
|
80
|
-
}
|
|
81
|
-
return this.context.dynamicTypeLiteralMapper.convert({
|
|
82
|
-
typeReference: property.typeReference,
|
|
83
|
-
value: bodyPropertyValue
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
export {
|
|
89
|
-
FilePropertyMapper
|
|
90
|
-
};
|
package/esm/chunk-TKT54OF7.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
EndpointSnippetGenerator
|
|
3
|
-
} from "./chunk-KUITDN45.js";
|
|
4
|
-
import {
|
|
5
|
-
DynamicSnippetsGeneratorContext
|
|
6
|
-
} from "./chunk-MR7ZAFRL.js";
|
|
7
|
-
import {
|
|
8
|
-
AbstractDynamicSnippetsGenerator,
|
|
9
|
-
Result
|
|
10
|
-
} from "./chunk-37WY6L3Q.js";
|
|
11
|
-
import {
|
|
12
|
-
init_buffer,
|
|
13
|
-
init_process
|
|
14
|
-
} from "./chunk-WPDO6IRW.js";
|
|
15
|
-
|
|
16
|
-
// src/DynamicSnippetsGenerator.ts
|
|
17
|
-
init_process();
|
|
18
|
-
init_buffer();
|
|
19
|
-
var DynamicSnippetsGenerator = class extends AbstractDynamicSnippetsGenerator {
|
|
20
|
-
constructor({
|
|
21
|
-
ir,
|
|
22
|
-
config
|
|
23
|
-
}) {
|
|
24
|
-
super(new DynamicSnippetsGeneratorContext({ ir, config }));
|
|
25
|
-
}
|
|
26
|
-
async generate(request) {
|
|
27
|
-
const endpoints = this.context.resolveEndpointLocationOrThrow(request.endpoint);
|
|
28
|
-
if (endpoints.length === 0) {
|
|
29
|
-
throw new Error(`No endpoints found that match "${request.endpoint.method} ${request.endpoint.path}"`);
|
|
30
|
-
}
|
|
31
|
-
const result = new Result();
|
|
32
|
-
for (const endpoint of endpoints) {
|
|
33
|
-
const context = this.context.clone();
|
|
34
|
-
const snippetGenerator = new EndpointSnippetGenerator({
|
|
35
|
-
context
|
|
36
|
-
});
|
|
37
|
-
try {
|
|
38
|
-
const snippet = await snippetGenerator.generateSnippet({ endpoint, request });
|
|
39
|
-
if (context.errors.empty()) {
|
|
40
|
-
return {
|
|
41
|
-
snippet,
|
|
42
|
-
errors: void 0
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
result.update({ context, snippet });
|
|
46
|
-
} catch (error) {
|
|
47
|
-
if (result.err == null) {
|
|
48
|
-
result.err = error;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return result.getResponseOrThrow({ endpoint: request.endpoint });
|
|
53
|
-
}
|
|
54
|
-
generateSync(request) {
|
|
55
|
-
const endpoints = this.context.resolveEndpointLocationOrThrow(request.endpoint);
|
|
56
|
-
if (endpoints.length === 0) {
|
|
57
|
-
throw new Error(`No endpoints found that match "${request.endpoint.method} ${request.endpoint.path}"`);
|
|
58
|
-
}
|
|
59
|
-
const result = new Result();
|
|
60
|
-
for (const endpoint of endpoints) {
|
|
61
|
-
const context = this.context.clone();
|
|
62
|
-
const snippetGenerator = new EndpointSnippetGenerator({
|
|
63
|
-
context
|
|
64
|
-
});
|
|
65
|
-
try {
|
|
66
|
-
const snippet = snippetGenerator.generateSnippetSync({ endpoint, request });
|
|
67
|
-
if (context.errors.empty()) {
|
|
68
|
-
return {
|
|
69
|
-
snippet,
|
|
70
|
-
errors: void 0
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
result.update({ context, snippet });
|
|
74
|
-
} catch (error) {
|
|
75
|
-
if (result.err == null) {
|
|
76
|
-
result.err = error;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return result.getResponseOrThrow({ endpoint: request.endpoint });
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
export {
|
|
85
|
-
DynamicSnippetsGenerator
|
|
86
|
-
};
|