@brianbuie/node-kit 0.2.2 → 0.2.4
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/TypeWriter.d.ts +452 -0
- package/.dist/TypeWriter.js +42 -0
- package/.dist/_index.d.ts +1 -0
- package/.dist/_index.js +1 -0
- package/package.json +3 -2
- package/src/Fetcher.test.ts +9 -9
- package/src/Jwt.test.ts +1 -1
- package/src/Log.test.ts +4 -4
- package/src/TypeWriter.test.ts +21 -0
- package/src/TypeWriter.ts +47 -0
- package/src/_index.ts +1 -0
- package/src/snapshot.test.ts +4 -4
|
@@ -0,0 +1,452 @@
|
|
|
1
|
+
import * as qt from 'quicktype-core';
|
|
2
|
+
export declare class TypeWriter {
|
|
3
|
+
moduleName: string;
|
|
4
|
+
input: qt.JSONInput<string>;
|
|
5
|
+
outDir: string;
|
|
6
|
+
qtSettings: {
|
|
7
|
+
lang: string;
|
|
8
|
+
rendererOptions: {
|
|
9
|
+
'just-types': boolean;
|
|
10
|
+
'prefer-types': boolean;
|
|
11
|
+
};
|
|
12
|
+
inferEnums: boolean;
|
|
13
|
+
inferDateTimes: boolean;
|
|
14
|
+
} & {
|
|
15
|
+
allPropertiesOptional?: boolean | undefined;
|
|
16
|
+
alphabetizeProperties?: boolean | undefined;
|
|
17
|
+
checkProvenance?: boolean | undefined;
|
|
18
|
+
debugPrintGatherNames?: boolean | undefined;
|
|
19
|
+
debugPrintGraph?: boolean | undefined;
|
|
20
|
+
debugPrintReconstitution?: boolean | undefined;
|
|
21
|
+
debugPrintSchemaResolving?: boolean | undefined;
|
|
22
|
+
debugPrintTimes?: boolean | undefined;
|
|
23
|
+
debugPrintTransformations?: boolean | undefined;
|
|
24
|
+
fixedTopLevels?: boolean | undefined;
|
|
25
|
+
indentation?: string | undefined;
|
|
26
|
+
inputData?: qt.InputData | undefined;
|
|
27
|
+
lang?: "cjson" | "cJSON" | "c++" | "cpp" | "cplusplus" | "crystal" | "cr" | "crystallang" | "cs" | "csharp" | "dart" | "elixir" | "elm" | "flow" | "go" | "golang" | "haskell" | "java" | "javascript" | "js" | "jsx" | "javascript-prop-types" | "schema" | "json-schema" | "kotlin" | "objc" | "objective-c" | "objectivec" | "php" | "pike" | "pikelang" | "python" | "py" | "ruby" | "rust" | "rs" | "rustlang" | "scala3" | "smithy4a" | "swift" | "swift4" | "typescript" | "ts" | "tsx" | "typescript-effect-schema" | "typescript-zod" | qt.TargetLanguage<import("quicktype-core/dist/TargetLanguage.js").LanguageConfig> | undefined;
|
|
28
|
+
leadingComments?: import("quicktype-core/dist/support/Comments.js").Comment[] | undefined;
|
|
29
|
+
noRender?: boolean | undefined;
|
|
30
|
+
outputFilename?: string | undefined;
|
|
31
|
+
rendererOptions?: qt.RendererOptions<"cjson" | "cJSON" | "c++" | "cpp" | "cplusplus" | "crystal" | "cr" | "crystallang" | "cs" | "csharp" | "dart" | "elixir" | "elm" | "flow" | "go" | "golang" | "haskell" | "java" | "javascript" | "js" | "jsx" | "javascript-prop-types" | "schema" | "json-schema" | "kotlin" | "objc" | "objective-c" | "objectivec" | "php" | "pike" | "pikelang" | "python" | "py" | "ruby" | "rust" | "rs" | "rustlang" | "scala3" | "smithy4a" | "swift" | "swift4" | "typescript" | "ts" | "tsx" | "typescript-effect-schema" | "typescript-zod", import("quicktype-core/dist/RendererOptions/types.js").OptionMap<{
|
|
32
|
+
typeSourceStyle: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"source-style", {
|
|
33
|
+
readonly "single-source": true;
|
|
34
|
+
readonly "multi-source": false;
|
|
35
|
+
}, "single-source" | "multi-source">;
|
|
36
|
+
typeIntegerSize: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"integer-size", {
|
|
37
|
+
readonly int8_t: "int8_t";
|
|
38
|
+
readonly int16_t: "int16_t";
|
|
39
|
+
readonly int32_t: "int32_t";
|
|
40
|
+
readonly int64_t: "int64_t";
|
|
41
|
+
}, "int8_t" | "int16_t" | "int32_t" | "int64_t">;
|
|
42
|
+
hashtableSize: import("quicktype-core/dist/RendererOptions/index.js").StringOption<"hashtable-size">;
|
|
43
|
+
addTypedefAlias: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"typedef-alias", {
|
|
44
|
+
readonly "no-typedef": false;
|
|
45
|
+
readonly "add-typedef": true;
|
|
46
|
+
}, "no-typedef" | "add-typedef">;
|
|
47
|
+
printStyle: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"print-style", {
|
|
48
|
+
readonly "print-formatted": false;
|
|
49
|
+
readonly "print-unformatted": true;
|
|
50
|
+
}, "print-formatted" | "print-unformatted">;
|
|
51
|
+
typeNamingStyle: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"type-style", {
|
|
52
|
+
readonly "pascal-case": "pascal";
|
|
53
|
+
readonly "underscore-case": "underscore";
|
|
54
|
+
readonly "camel-case": "camel";
|
|
55
|
+
readonly "upper-underscore-case": "upper-underscore";
|
|
56
|
+
readonly "pascal-case-upper-acronyms": "pascal-upper-acronyms";
|
|
57
|
+
readonly "camel-case-upper-acronyms": "camel-upper-acronyms";
|
|
58
|
+
}, "pascal-case" | "underscore-case" | "camel-case" | "upper-underscore-case" | "pascal-case-upper-acronyms" | "camel-case-upper-acronyms">;
|
|
59
|
+
memberNamingStyle: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"member-style", {
|
|
60
|
+
readonly "pascal-case": "pascal";
|
|
61
|
+
readonly "underscore-case": "underscore";
|
|
62
|
+
readonly "camel-case": "camel";
|
|
63
|
+
readonly "upper-underscore-case": "upper-underscore";
|
|
64
|
+
readonly "pascal-case-upper-acronyms": "pascal-upper-acronyms";
|
|
65
|
+
readonly "camel-case-upper-acronyms": "camel-upper-acronyms";
|
|
66
|
+
}, "pascal-case" | "underscore-case" | "camel-case" | "upper-underscore-case" | "pascal-case-upper-acronyms" | "camel-case-upper-acronyms">;
|
|
67
|
+
enumeratorNamingStyle: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"enumerator-style", {
|
|
68
|
+
readonly "pascal-case": "pascal";
|
|
69
|
+
readonly "underscore-case": "underscore";
|
|
70
|
+
readonly "camel-case": "camel";
|
|
71
|
+
readonly "upper-underscore-case": "upper-underscore";
|
|
72
|
+
readonly "pascal-case-upper-acronyms": "pascal-upper-acronyms";
|
|
73
|
+
readonly "camel-case-upper-acronyms": "camel-upper-acronyms";
|
|
74
|
+
}, "pascal-case" | "underscore-case" | "camel-case" | "upper-underscore-case" | "pascal-case-upper-acronyms" | "camel-case-upper-acronyms">;
|
|
75
|
+
}> | import("quicktype-core/dist/RendererOptions/types.js").OptionMap<{
|
|
76
|
+
typeSourceStyle: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"source-style", {
|
|
77
|
+
readonly "single-source": true;
|
|
78
|
+
readonly "multi-source": false;
|
|
79
|
+
}, "single-source" | "multi-source">;
|
|
80
|
+
includeLocation: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"include-location", {
|
|
81
|
+
readonly "local-include": true;
|
|
82
|
+
readonly "global-include": false;
|
|
83
|
+
}, "local-include" | "global-include">;
|
|
84
|
+
codeFormat: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"code-format", {
|
|
85
|
+
readonly "with-struct": false;
|
|
86
|
+
readonly "with-getter-setter": true;
|
|
87
|
+
}, "with-struct" | "with-getter-setter">;
|
|
88
|
+
wstring: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"wstring", {
|
|
89
|
+
readonly "use-string": false;
|
|
90
|
+
readonly "use-wstring": true;
|
|
91
|
+
}, "use-string" | "use-wstring">;
|
|
92
|
+
westConst: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"const-style", {
|
|
93
|
+
readonly "west-const": true;
|
|
94
|
+
readonly "east-const": false;
|
|
95
|
+
}, "west-const" | "east-const">;
|
|
96
|
+
justTypes: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"just-types">;
|
|
97
|
+
namespace: import("quicktype-core/dist/RendererOptions/index.js").StringOption<"namespace">;
|
|
98
|
+
enumType: import("quicktype-core/dist/RendererOptions/index.js").StringOption<"enum-type">;
|
|
99
|
+
typeNamingStyle: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"type-style", {
|
|
100
|
+
readonly "pascal-case": "pascal";
|
|
101
|
+
readonly "underscore-case": "underscore";
|
|
102
|
+
readonly "camel-case": "camel";
|
|
103
|
+
readonly "upper-underscore-case": "upper-underscore";
|
|
104
|
+
readonly "pascal-case-upper-acronyms": "pascal-upper-acronyms";
|
|
105
|
+
readonly "camel-case-upper-acronyms": "camel-upper-acronyms";
|
|
106
|
+
}, "pascal-case" | "underscore-case" | "camel-case" | "upper-underscore-case" | "pascal-case-upper-acronyms" | "camel-case-upper-acronyms">;
|
|
107
|
+
memberNamingStyle: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"member-style", {
|
|
108
|
+
readonly "pascal-case": "pascal";
|
|
109
|
+
readonly "underscore-case": "underscore";
|
|
110
|
+
readonly "camel-case": "camel";
|
|
111
|
+
readonly "upper-underscore-case": "upper-underscore";
|
|
112
|
+
readonly "pascal-case-upper-acronyms": "pascal-upper-acronyms";
|
|
113
|
+
readonly "camel-case-upper-acronyms": "camel-upper-acronyms";
|
|
114
|
+
}, "pascal-case" | "underscore-case" | "camel-case" | "upper-underscore-case" | "pascal-case-upper-acronyms" | "camel-case-upper-acronyms">;
|
|
115
|
+
enumeratorNamingStyle: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"enumerator-style", {
|
|
116
|
+
readonly "pascal-case": "pascal";
|
|
117
|
+
readonly "underscore-case": "underscore";
|
|
118
|
+
readonly "camel-case": "camel";
|
|
119
|
+
readonly "upper-underscore-case": "upper-underscore";
|
|
120
|
+
readonly "pascal-case-upper-acronyms": "pascal-upper-acronyms";
|
|
121
|
+
readonly "camel-case-upper-acronyms": "camel-upper-acronyms";
|
|
122
|
+
}, "pascal-case" | "underscore-case" | "camel-case" | "upper-underscore-case" | "pascal-case-upper-acronyms" | "camel-case-upper-acronyms">;
|
|
123
|
+
boost: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"boost">;
|
|
124
|
+
hideNullOptional: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"hide-null-optional">;
|
|
125
|
+
}> | import("quicktype-core/dist/RendererOptions/types.js").OptionMap<{}> | import("quicktype-core/dist/RendererOptions/types.js").OptionMap<{
|
|
126
|
+
readonly framework: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"framework", {
|
|
127
|
+
readonly NewtonSoft: "NewtonSoft";
|
|
128
|
+
readonly SystemTextJson: "SystemTextJson";
|
|
129
|
+
}, "NewtonSoft" | "SystemTextJson">;
|
|
130
|
+
readonly useList: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"array-type", {
|
|
131
|
+
readonly array: false;
|
|
132
|
+
readonly list: true;
|
|
133
|
+
}, "array" | "list">;
|
|
134
|
+
readonly dense: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"density", {
|
|
135
|
+
readonly normal: false;
|
|
136
|
+
readonly dense: true;
|
|
137
|
+
}, "normal" | "dense">;
|
|
138
|
+
readonly namespace: import("quicktype-core/dist/RendererOptions/index.js").StringOption<"namespace">;
|
|
139
|
+
readonly version: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"csharp-version", {
|
|
140
|
+
readonly "5": 5;
|
|
141
|
+
readonly "6": 6;
|
|
142
|
+
}, "5" | "6">;
|
|
143
|
+
readonly virtual: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"virtual">;
|
|
144
|
+
readonly typeForAny: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"any-type", {
|
|
145
|
+
readonly object: "object";
|
|
146
|
+
readonly dynamic: "dynamic";
|
|
147
|
+
}, "object" | "dynamic">;
|
|
148
|
+
readonly useDecimal: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"number-type", {
|
|
149
|
+
readonly double: false;
|
|
150
|
+
readonly decimal: true;
|
|
151
|
+
}, "decimal" | "double">;
|
|
152
|
+
readonly features: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"features", {
|
|
153
|
+
readonly complete: {
|
|
154
|
+
readonly namespaces: true;
|
|
155
|
+
readonly helpers: true;
|
|
156
|
+
readonly attributes: true;
|
|
157
|
+
};
|
|
158
|
+
readonly "attributes-only": {
|
|
159
|
+
readonly namespaces: true;
|
|
160
|
+
readonly helpers: false;
|
|
161
|
+
readonly attributes: true;
|
|
162
|
+
};
|
|
163
|
+
readonly "just-types-and-namespace": {
|
|
164
|
+
readonly namespaces: true;
|
|
165
|
+
readonly helpers: false;
|
|
166
|
+
readonly attributes: false;
|
|
167
|
+
};
|
|
168
|
+
readonly "just-types": {
|
|
169
|
+
readonly namespaces: true;
|
|
170
|
+
readonly helpers: false;
|
|
171
|
+
readonly attributes: false;
|
|
172
|
+
};
|
|
173
|
+
}, "complete" | "just-types" | "attributes-only" | "just-types-and-namespace">;
|
|
174
|
+
readonly baseclass: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"base-class", {
|
|
175
|
+
readonly EntityData: "EntityData";
|
|
176
|
+
readonly Object: undefined;
|
|
177
|
+
}, "EntityData" | "Object">;
|
|
178
|
+
readonly checkRequired: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"check-required">;
|
|
179
|
+
readonly keepPropertyName: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"keep-property-name">;
|
|
180
|
+
}> | import("quicktype-core/dist/RendererOptions/types.js").OptionMap<{
|
|
181
|
+
nullSafety: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"null-safety">;
|
|
182
|
+
justTypes: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"just-types">;
|
|
183
|
+
codersInClass: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"coders-in-class">;
|
|
184
|
+
methodNamesWithMap: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"from-map">;
|
|
185
|
+
requiredProperties: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"required-props">;
|
|
186
|
+
finalProperties: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"final-props">;
|
|
187
|
+
generateCopyWith: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"copy-with">;
|
|
188
|
+
useFreezed: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"use-freezed">;
|
|
189
|
+
useHive: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"use-hive">;
|
|
190
|
+
useJsonAnnotation: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"use-json-annotation">;
|
|
191
|
+
partName: import("quicktype-core/dist/RendererOptions/index.js").StringOption<"part-name">;
|
|
192
|
+
}> | import("quicktype-core/dist/RendererOptions/types.js").OptionMap<{
|
|
193
|
+
justTypes: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"just-types">;
|
|
194
|
+
namespace: import("quicktype-core/dist/RendererOptions/index.js").StringOption<"namespace">;
|
|
195
|
+
}> | import("quicktype-core/dist/RendererOptions/types.js").OptionMap<{
|
|
196
|
+
justTypes: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"just-types">;
|
|
197
|
+
useList: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"array-type", {
|
|
198
|
+
readonly array: false;
|
|
199
|
+
readonly list: true;
|
|
200
|
+
}, "array" | "list">;
|
|
201
|
+
moduleName: import("quicktype-core/dist/RendererOptions/index.js").StringOption<"module">;
|
|
202
|
+
}> | import("quicktype-core/dist/RendererOptions/types.js").OptionMap<{
|
|
203
|
+
acronymStyle: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"acronym-style", {
|
|
204
|
+
readonly original: import("quicktype-core/dist/support/Acronyms.js").AcronymStyleOptions.Original;
|
|
205
|
+
readonly pascal: import("quicktype-core/dist/support/Acronyms.js").AcronymStyleOptions.Pascal;
|
|
206
|
+
readonly camel: import("quicktype-core/dist/support/Acronyms.js").AcronymStyleOptions.Camel;
|
|
207
|
+
readonly lowerCase: import("quicktype-core/dist/support/Acronyms.js").AcronymStyleOptions.Lower;
|
|
208
|
+
}, import("quicktype-core/dist/support/Acronyms.js").AcronymStyleOptions>;
|
|
209
|
+
runtimeTypecheck: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"runtime-typecheck">;
|
|
210
|
+
runtimeTypecheckIgnoreUnknownProperties: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"runtime-typecheck-ignore-unknown-properties">;
|
|
211
|
+
converters: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"converters", {
|
|
212
|
+
readonly "top-level": import("quicktype-core/dist/support/Converters.js").ConvertersOptions.TopLevel;
|
|
213
|
+
readonly "all-objects": import("quicktype-core/dist/support/Converters.js").ConvertersOptions.AllObjects;
|
|
214
|
+
}, import("quicktype-core/dist/support/Converters.js").ConvertersOptions>;
|
|
215
|
+
rawType: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"raw-type", {
|
|
216
|
+
readonly json: "json";
|
|
217
|
+
readonly any: "any";
|
|
218
|
+
}, "json" | "any">;
|
|
219
|
+
} & {
|
|
220
|
+
justTypes: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"just-types">;
|
|
221
|
+
nicePropertyNames: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"nice-property-names">;
|
|
222
|
+
declareUnions: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"explicit-unions">;
|
|
223
|
+
preferUnions: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"prefer-unions">;
|
|
224
|
+
preferTypes: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"prefer-types">;
|
|
225
|
+
preferConstValues: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"prefer-const-values">;
|
|
226
|
+
readonly: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"readonly">;
|
|
227
|
+
}> | import("quicktype-core/dist/RendererOptions/types.js").OptionMap<{
|
|
228
|
+
justTypes: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"just-types">;
|
|
229
|
+
justTypesAndPackage: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"just-types-and-package">;
|
|
230
|
+
packageName: import("quicktype-core/dist/RendererOptions/index.js").StringOption<"package">;
|
|
231
|
+
multiFileOutput: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"multi-file-output">;
|
|
232
|
+
fieldTags: import("quicktype-core/dist/RendererOptions/index.js").StringOption<"field-tags">;
|
|
233
|
+
omitEmpty: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"omit-empty">;
|
|
234
|
+
}> | import("quicktype-core/dist/RendererOptions/types.js").OptionMap<{
|
|
235
|
+
justTypes: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"just-types">;
|
|
236
|
+
useList: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"array-type", {
|
|
237
|
+
readonly array: false;
|
|
238
|
+
readonly list: true;
|
|
239
|
+
}, "array" | "list">;
|
|
240
|
+
moduleName: import("quicktype-core/dist/RendererOptions/index.js").StringOption<"module">;
|
|
241
|
+
}> | import("quicktype-core/dist/RendererOptions/types.js").OptionMap<{
|
|
242
|
+
useList: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"array-type", {
|
|
243
|
+
readonly array: false;
|
|
244
|
+
readonly list: true;
|
|
245
|
+
}, "array" | "list">;
|
|
246
|
+
justTypes: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"just-types">;
|
|
247
|
+
dateTimeProvider: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"datetime-provider", {
|
|
248
|
+
readonly java8: "java8";
|
|
249
|
+
readonly legacy: "legacy";
|
|
250
|
+
}, "java8" | "legacy">;
|
|
251
|
+
acronymStyle: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"acronym-style", {
|
|
252
|
+
readonly original: import("quicktype-core/dist/support/Acronyms.js").AcronymStyleOptions.Original;
|
|
253
|
+
readonly pascal: import("quicktype-core/dist/support/Acronyms.js").AcronymStyleOptions.Pascal;
|
|
254
|
+
readonly camel: import("quicktype-core/dist/support/Acronyms.js").AcronymStyleOptions.Camel;
|
|
255
|
+
readonly lowerCase: import("quicktype-core/dist/support/Acronyms.js").AcronymStyleOptions.Lower;
|
|
256
|
+
}, import("quicktype-core/dist/support/Acronyms.js").AcronymStyleOptions>;
|
|
257
|
+
packageName: import("quicktype-core/dist/RendererOptions/index.js").StringOption<"package">;
|
|
258
|
+
lombok: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"lombok">;
|
|
259
|
+
lombokCopyAnnotations: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"lombok-copy-annotations">;
|
|
260
|
+
}> | import("quicktype-core/dist/RendererOptions/types.js").OptionMap<{
|
|
261
|
+
acronymStyle: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"acronym-style", {
|
|
262
|
+
readonly original: import("quicktype-core/dist/support/Acronyms.js").AcronymStyleOptions.Original;
|
|
263
|
+
readonly pascal: import("quicktype-core/dist/support/Acronyms.js").AcronymStyleOptions.Pascal;
|
|
264
|
+
readonly camel: import("quicktype-core/dist/support/Acronyms.js").AcronymStyleOptions.Camel;
|
|
265
|
+
readonly lowerCase: import("quicktype-core/dist/support/Acronyms.js").AcronymStyleOptions.Lower;
|
|
266
|
+
}, import("quicktype-core/dist/support/Acronyms.js").AcronymStyleOptions>;
|
|
267
|
+
runtimeTypecheck: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"runtime-typecheck">;
|
|
268
|
+
runtimeTypecheckIgnoreUnknownProperties: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"runtime-typecheck-ignore-unknown-properties">;
|
|
269
|
+
converters: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"converters", {
|
|
270
|
+
readonly "top-level": import("quicktype-core/dist/support/Converters.js").ConvertersOptions.TopLevel;
|
|
271
|
+
readonly "all-objects": import("quicktype-core/dist/support/Converters.js").ConvertersOptions.AllObjects;
|
|
272
|
+
}, import("quicktype-core/dist/support/Converters.js").ConvertersOptions>;
|
|
273
|
+
rawType: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"raw-type", {
|
|
274
|
+
readonly json: "json";
|
|
275
|
+
readonly any: "any";
|
|
276
|
+
}, "json" | "any">;
|
|
277
|
+
}> | import("quicktype-core/dist/RendererOptions/types.js").OptionMap<{
|
|
278
|
+
acronymStyle: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"acronym-style", {
|
|
279
|
+
readonly original: import("quicktype-core/dist/support/Acronyms.js").AcronymStyleOptions.Original;
|
|
280
|
+
readonly pascal: import("quicktype-core/dist/support/Acronyms.js").AcronymStyleOptions.Pascal;
|
|
281
|
+
readonly camel: import("quicktype-core/dist/support/Acronyms.js").AcronymStyleOptions.Camel;
|
|
282
|
+
readonly lowerCase: import("quicktype-core/dist/support/Acronyms.js").AcronymStyleOptions.Lower;
|
|
283
|
+
}, import("quicktype-core/dist/support/Acronyms.js").AcronymStyleOptions>;
|
|
284
|
+
converters: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"converters", {
|
|
285
|
+
readonly "top-level": import("quicktype-core/dist/support/Converters.js").ConvertersOptions.TopLevel;
|
|
286
|
+
readonly "all-objects": import("quicktype-core/dist/support/Converters.js").ConvertersOptions.AllObjects;
|
|
287
|
+
}, import("quicktype-core/dist/support/Converters.js").ConvertersOptions>;
|
|
288
|
+
moduleSystem: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"module-system", {
|
|
289
|
+
readonly "common-js": false;
|
|
290
|
+
readonly es6: true;
|
|
291
|
+
}, "common-js" | "es6">;
|
|
292
|
+
}> | import("quicktype-core/dist/RendererOptions/types.js").OptionMap<{
|
|
293
|
+
framework: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"framework", {
|
|
294
|
+
readonly "just-types": "None";
|
|
295
|
+
readonly jackson: "Jackson";
|
|
296
|
+
readonly klaxon: "Klaxon";
|
|
297
|
+
readonly kotlinx: "KotlinX";
|
|
298
|
+
}, "just-types" | "jackson" | "klaxon" | "kotlinx">;
|
|
299
|
+
acronymStyle: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"acronym-style", {
|
|
300
|
+
readonly original: import("quicktype-core/dist/support/Acronyms.js").AcronymStyleOptions.Original;
|
|
301
|
+
readonly pascal: import("quicktype-core/dist/support/Acronyms.js").AcronymStyleOptions.Pascal;
|
|
302
|
+
readonly camel: import("quicktype-core/dist/support/Acronyms.js").AcronymStyleOptions.Camel;
|
|
303
|
+
readonly lowerCase: import("quicktype-core/dist/support/Acronyms.js").AcronymStyleOptions.Lower;
|
|
304
|
+
}, import("quicktype-core/dist/support/Acronyms.js").AcronymStyleOptions>;
|
|
305
|
+
packageName: import("quicktype-core/dist/RendererOptions/index.js").StringOption<"package">;
|
|
306
|
+
}> | import("quicktype-core/dist/RendererOptions/types.js").OptionMap<{
|
|
307
|
+
features: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"features", {
|
|
308
|
+
readonly all: {
|
|
309
|
+
readonly interface: true;
|
|
310
|
+
readonly implementation: true;
|
|
311
|
+
};
|
|
312
|
+
readonly interface: {
|
|
313
|
+
readonly interface: true;
|
|
314
|
+
readonly implementation: false;
|
|
315
|
+
};
|
|
316
|
+
readonly implementation: {
|
|
317
|
+
readonly interface: false;
|
|
318
|
+
readonly implementation: true;
|
|
319
|
+
};
|
|
320
|
+
}, "all" | "interface" | "implementation">;
|
|
321
|
+
justTypes: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"just-types">;
|
|
322
|
+
marshallingFunctions: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"functions">;
|
|
323
|
+
classPrefix: import("quicktype-core/dist/RendererOptions/index.js").StringOption<"class-prefix">;
|
|
324
|
+
extraComments: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"extra-comments">;
|
|
325
|
+
}> | import("quicktype-core/dist/RendererOptions/types.js").OptionMap<{
|
|
326
|
+
withGet: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"with-get">;
|
|
327
|
+
fastGet: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"fast-get">;
|
|
328
|
+
withSet: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"with-set">;
|
|
329
|
+
withClosing: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"with-closing">;
|
|
330
|
+
acronymStyle: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"acronym-style", {
|
|
331
|
+
readonly original: import("quicktype-core/dist/support/Acronyms.js").AcronymStyleOptions.Original;
|
|
332
|
+
readonly pascal: import("quicktype-core/dist/support/Acronyms.js").AcronymStyleOptions.Pascal;
|
|
333
|
+
readonly camel: import("quicktype-core/dist/support/Acronyms.js").AcronymStyleOptions.Camel;
|
|
334
|
+
readonly lowerCase: import("quicktype-core/dist/support/Acronyms.js").AcronymStyleOptions.Lower;
|
|
335
|
+
}, import("quicktype-core/dist/support/Acronyms.js").AcronymStyleOptions>;
|
|
336
|
+
}> | import("quicktype-core/dist/RendererOptions/types.js").OptionMap<{
|
|
337
|
+
features: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"python-version", {
|
|
338
|
+
readonly "3.5": {
|
|
339
|
+
readonly typeHints: false;
|
|
340
|
+
readonly dataClasses: false;
|
|
341
|
+
};
|
|
342
|
+
readonly "3.6": {
|
|
343
|
+
readonly typeHints: true;
|
|
344
|
+
readonly dataClasses: false;
|
|
345
|
+
};
|
|
346
|
+
readonly "3.7": {
|
|
347
|
+
readonly typeHints: true;
|
|
348
|
+
readonly dataClasses: true;
|
|
349
|
+
};
|
|
350
|
+
}, "3.5" | "3.6" | "3.7">;
|
|
351
|
+
justTypes: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"just-types">;
|
|
352
|
+
nicePropertyNames: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"nice-property-names">;
|
|
353
|
+
pydanticBaseModel: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"pydantic-base-model">;
|
|
354
|
+
}> | import("quicktype-core/dist/RendererOptions/types.js").OptionMap<{
|
|
355
|
+
justTypes: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"just-types">;
|
|
356
|
+
strictness: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"strictness", {
|
|
357
|
+
readonly strict: import("quicktype-core/dist/language/Ruby/utils.js").Strictness.Strict;
|
|
358
|
+
readonly coercible: import("quicktype-core/dist/language/Ruby/utils.js").Strictness.Coercible;
|
|
359
|
+
readonly none: import("quicktype-core/dist/language/Ruby/utils.js").Strictness.None;
|
|
360
|
+
}, "none" | "strict" | "coercible">;
|
|
361
|
+
namespace: import("quicktype-core/dist/RendererOptions/index.js").StringOption<"namespace">;
|
|
362
|
+
}> | import("quicktype-core/dist/RendererOptions/types.js").OptionMap<{
|
|
363
|
+
readonly density: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"density", {
|
|
364
|
+
readonly normal: import("quicktype-core/dist/language/Rust/utils.js").Density.Normal;
|
|
365
|
+
readonly dense: import("quicktype-core/dist/language/Rust/utils.js").Density.Dense;
|
|
366
|
+
}, "normal" | "dense">;
|
|
367
|
+
readonly visibility: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"visibility", {
|
|
368
|
+
readonly private: import("quicktype-core/dist/language/Rust/utils.js").Visibility.Private;
|
|
369
|
+
readonly crate: import("quicktype-core/dist/language/Rust/utils.js").Visibility.Crate;
|
|
370
|
+
readonly public: import("quicktype-core/dist/language/Rust/utils.js").Visibility.Public;
|
|
371
|
+
}, "private" | "public" | "crate">;
|
|
372
|
+
readonly deriveDebug: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"derive-debug">;
|
|
373
|
+
readonly deriveClone: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"derive-clone">;
|
|
374
|
+
readonly derivePartialEq: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"derive-partial-eq">;
|
|
375
|
+
readonly skipSerializingNone: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"skip-serializing-none">;
|
|
376
|
+
readonly edition2018: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"edition-2018">;
|
|
377
|
+
readonly leadingComments: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"leading-comments">;
|
|
378
|
+
}> | import("quicktype-core/dist/RendererOptions/types.js").OptionMap<{
|
|
379
|
+
framework: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"framework", {
|
|
380
|
+
readonly "just-types": "None";
|
|
381
|
+
readonly circe: "Circe";
|
|
382
|
+
readonly upickle: "Upickle";
|
|
383
|
+
}, "just-types" | "circe" | "upickle">;
|
|
384
|
+
packageName: import("quicktype-core/dist/RendererOptions/index.js").StringOption<"package">;
|
|
385
|
+
}> | import("quicktype-core/dist/RendererOptions/types.js").OptionMap<{
|
|
386
|
+
framework: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"framework", {
|
|
387
|
+
readonly "just-types": import("quicktype-core/dist/language/Smithy4s/language.js").Framework;
|
|
388
|
+
}, "just-types">;
|
|
389
|
+
packageName: import("quicktype-core/dist/RendererOptions/index.js").StringOption<"package">;
|
|
390
|
+
}> | import("quicktype-core/dist/RendererOptions/types.js").OptionMap<{
|
|
391
|
+
justTypes: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"just-types">;
|
|
392
|
+
convenienceInitializers: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"initializers">;
|
|
393
|
+
explicitCodingKeys: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"coding-keys">;
|
|
394
|
+
codingKeysProtocol: import("quicktype-core/dist/RendererOptions/index.js").StringOption<"coding-keys-protocol">;
|
|
395
|
+
alamofire: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"alamofire">;
|
|
396
|
+
namedTypePrefix: import("quicktype-core/dist/RendererOptions/index.js").StringOption<"type-prefix">;
|
|
397
|
+
useClasses: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"struct-or-class", {
|
|
398
|
+
readonly struct: false;
|
|
399
|
+
readonly class: true;
|
|
400
|
+
}, "class" | "struct">;
|
|
401
|
+
mutableProperties: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"mutable-properties">;
|
|
402
|
+
acronymStyle: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"acronym-style", {
|
|
403
|
+
readonly original: import("quicktype-core/dist/support/Acronyms.js").AcronymStyleOptions.Original;
|
|
404
|
+
readonly pascal: import("quicktype-core/dist/support/Acronyms.js").AcronymStyleOptions.Pascal;
|
|
405
|
+
readonly camel: import("quicktype-core/dist/support/Acronyms.js").AcronymStyleOptions.Camel;
|
|
406
|
+
readonly lowerCase: import("quicktype-core/dist/support/Acronyms.js").AcronymStyleOptions.Lower;
|
|
407
|
+
}, import("quicktype-core/dist/support/Acronyms.js").AcronymStyleOptions>;
|
|
408
|
+
dense: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"density", {
|
|
409
|
+
readonly dense: true;
|
|
410
|
+
readonly normal: false;
|
|
411
|
+
}, "normal" | "dense">;
|
|
412
|
+
linux: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"support-linux">;
|
|
413
|
+
objcSupport: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"objective-c-support">;
|
|
414
|
+
optionalEnums: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"optional-enums">;
|
|
415
|
+
swift5Support: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"swift-5-support">;
|
|
416
|
+
sendable: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"sendable">;
|
|
417
|
+
multiFileOutput: import("quicktype-core/dist/RendererOptions/index.js").BooleanOption<"multi-file-output">;
|
|
418
|
+
accessLevel: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"access-level", {
|
|
419
|
+
readonly internal: "internal";
|
|
420
|
+
readonly public: "public";
|
|
421
|
+
}, "internal" | "public">;
|
|
422
|
+
protocol: import("quicktype-core/dist/RendererOptions/index.js").EnumOption<"protocol", {
|
|
423
|
+
readonly none: {
|
|
424
|
+
readonly equatable: false;
|
|
425
|
+
readonly hashable: false;
|
|
426
|
+
};
|
|
427
|
+
readonly equatable: {
|
|
428
|
+
readonly equatable: true;
|
|
429
|
+
readonly hashable: false;
|
|
430
|
+
};
|
|
431
|
+
readonly hashable: {
|
|
432
|
+
readonly equatable: false;
|
|
433
|
+
readonly hashable: true;
|
|
434
|
+
};
|
|
435
|
+
}, "none" | "equatable" | "hashable">;
|
|
436
|
+
}>> | undefined;
|
|
437
|
+
inferMaps?: boolean | undefined;
|
|
438
|
+
inferEnums?: boolean | undefined;
|
|
439
|
+
inferUuids?: boolean | undefined;
|
|
440
|
+
inferDateTimes?: boolean | undefined;
|
|
441
|
+
inferIntegerStrings?: boolean | undefined;
|
|
442
|
+
inferBooleanStrings?: boolean | undefined;
|
|
443
|
+
combineClasses?: boolean | undefined;
|
|
444
|
+
ignoreJsonRefs?: boolean | undefined;
|
|
445
|
+
};
|
|
446
|
+
constructor(moduleName: string, settings?: {
|
|
447
|
+
outDir?: string;
|
|
448
|
+
} & Partial<qt.Options>);
|
|
449
|
+
addMember(name: string, _samples: any[]): Promise<void>;
|
|
450
|
+
toString(): Promise<string>;
|
|
451
|
+
toFile(): Promise<void>;
|
|
452
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import { merge } from 'lodash-es';
|
|
3
|
+
import * as qt from 'quicktype-core';
|
|
4
|
+
export class TypeWriter {
|
|
5
|
+
moduleName;
|
|
6
|
+
input = qt.jsonInputForTargetLanguage('typescript');
|
|
7
|
+
outDir;
|
|
8
|
+
qtSettings;
|
|
9
|
+
constructor(moduleName, settings = {}) {
|
|
10
|
+
this.moduleName = moduleName;
|
|
11
|
+
const { outDir, ...qtSettings } = settings;
|
|
12
|
+
this.outDir = outDir || './types';
|
|
13
|
+
const defaultSettings = {
|
|
14
|
+
lang: 'typescript',
|
|
15
|
+
rendererOptions: {
|
|
16
|
+
'just-types': true,
|
|
17
|
+
'prefer-types': true,
|
|
18
|
+
},
|
|
19
|
+
inferEnums: false,
|
|
20
|
+
inferDateTimes: false,
|
|
21
|
+
};
|
|
22
|
+
this.qtSettings = merge(defaultSettings, qtSettings);
|
|
23
|
+
}
|
|
24
|
+
async addMember(name, _samples) {
|
|
25
|
+
const samples = _samples.map((s) => (typeof s === 'string' ? s : JSON.stringify(s)));
|
|
26
|
+
await this.input.addSource({ name, samples });
|
|
27
|
+
}
|
|
28
|
+
async toString() {
|
|
29
|
+
const inputData = new qt.InputData();
|
|
30
|
+
inputData.addInput(this.input);
|
|
31
|
+
const result = await qt.quicktype({
|
|
32
|
+
inputData,
|
|
33
|
+
...this.qtSettings,
|
|
34
|
+
});
|
|
35
|
+
return result.lines.join('\n');
|
|
36
|
+
}
|
|
37
|
+
async toFile() {
|
|
38
|
+
const result = await this.toString();
|
|
39
|
+
fs.mkdirSync(this.outDir, { recursive: true });
|
|
40
|
+
fs.writeFileSync(`${this.outDir}/${this.moduleName}.d.ts`, result);
|
|
41
|
+
}
|
|
42
|
+
}
|
package/.dist/_index.d.ts
CHANGED
package/.dist/_index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brianbuie/node-kit",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -31,7 +31,8 @@
|
|
|
31
31
|
"chalk": "^5.6.2",
|
|
32
32
|
"extract-domain": "^5.0.2",
|
|
33
33
|
"jsonwebtoken": "^9.0.2",
|
|
34
|
-
"lodash-es": "^4.17.21"
|
|
34
|
+
"lodash-es": "^4.17.21",
|
|
35
|
+
"quicktype-core": "^23.2.6"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
38
|
"typescript": "^5.9.3"
|
package/src/Fetcher.test.ts
CHANGED
|
@@ -5,13 +5,13 @@ import { Fetcher } from './Fetcher.js';
|
|
|
5
5
|
describe('Fetcher', () => {
|
|
6
6
|
const statusApi = new Fetcher({ base: 'https://mock.httpstatus.io' });
|
|
7
7
|
|
|
8
|
-
it('
|
|
8
|
+
it('Makes URL', () => {
|
|
9
9
|
const route = '/example/route';
|
|
10
10
|
const [url] = statusApi.buildUrl(route);
|
|
11
11
|
assert(url.href.includes(route));
|
|
12
12
|
});
|
|
13
13
|
|
|
14
|
-
it('
|
|
14
|
+
it('Throws when URL is invalid', () => {
|
|
15
15
|
try {
|
|
16
16
|
const empty = new Fetcher();
|
|
17
17
|
empty.buildUrl('/');
|
|
@@ -21,42 +21,42 @@ describe('Fetcher', () => {
|
|
|
21
21
|
throw new Error('Ignored invalid URL');
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
-
it('
|
|
24
|
+
it('Identifies the correct domain', () => {
|
|
25
25
|
const test = new Fetcher({ base: 'https://subdomain.example.org' });
|
|
26
26
|
const [_, domain] = test.buildUrl('');
|
|
27
27
|
assert(domain === 'example.org');
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
it('
|
|
30
|
+
it('Handles query parameters', () => {
|
|
31
31
|
const [url] = statusApi.buildUrl('/', { query: { key: 'value' } });
|
|
32
32
|
assert(url.href.includes('?key=value'));
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
-
it('
|
|
35
|
+
it('Handles undefined query params', () => {
|
|
36
36
|
const [url] = statusApi.buildUrl('/', { query: { key: undefined } });
|
|
37
37
|
assert(!url.href.includes('key'));
|
|
38
38
|
});
|
|
39
39
|
|
|
40
|
-
it('
|
|
40
|
+
it('Keeps falsey query params', () => {
|
|
41
41
|
const [url] = statusApi.buildUrl('/', { query: { zero: 0, false: false, null: null } });
|
|
42
42
|
assert(url.href.includes('zero=0'));
|
|
43
43
|
assert(url.href.includes('false=false'));
|
|
44
44
|
assert(url.href.includes('null=null'));
|
|
45
45
|
});
|
|
46
46
|
|
|
47
|
-
it('
|
|
47
|
+
it('Handles no query params', () => {
|
|
48
48
|
const route = '/';
|
|
49
49
|
const [url] = statusApi.buildUrl(route);
|
|
50
50
|
assert(url.href === statusApi.defaultOptions.base + route);
|
|
51
51
|
});
|
|
52
52
|
|
|
53
|
-
it('
|
|
53
|
+
it('Handles array query param', () => {
|
|
54
54
|
const [url] = statusApi.buildUrl('/', { query: { multiple: [1, 2] } });
|
|
55
55
|
assert(url.href.includes('multiple=1'));
|
|
56
56
|
assert(url.href.includes('multiple=2'));
|
|
57
57
|
});
|
|
58
58
|
|
|
59
|
-
it('
|
|
59
|
+
it('Throws on bad request', async () => {
|
|
60
60
|
try {
|
|
61
61
|
await statusApi.fetch('/404', { retries: 0 });
|
|
62
62
|
} catch (e) {
|
package/src/Jwt.test.ts
CHANGED
package/src/Log.test.ts
CHANGED
|
@@ -3,7 +3,7 @@ import assert from 'node:assert';
|
|
|
3
3
|
import { Log } from './Log.js';
|
|
4
4
|
|
|
5
5
|
describe('Log', () => {
|
|
6
|
-
it('
|
|
6
|
+
it('Throws error', () => {
|
|
7
7
|
try {
|
|
8
8
|
Log.error('Test error');
|
|
9
9
|
} catch (e) {
|
|
@@ -12,16 +12,16 @@ describe('Log', () => {
|
|
|
12
12
|
assert(false, 'Did not throw error');
|
|
13
13
|
});
|
|
14
14
|
|
|
15
|
-
it('
|
|
15
|
+
it('Recognizes this is a test', () => {
|
|
16
16
|
assert(Log.isTest);
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
it('
|
|
19
|
+
it('Uses first argument as message when string', () => {
|
|
20
20
|
const result = Log.prepare('test', { something: 'else' });
|
|
21
21
|
assert(result.message === 'test');
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
-
it('
|
|
24
|
+
it('Uses message prop when provided', () => {
|
|
25
25
|
const result = Log.prepare({ message: 'test', something: 'else' });
|
|
26
26
|
assert(result.message === 'test');
|
|
27
27
|
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { describe, it } from 'node:test';
|
|
2
|
+
import assert from 'node:assert';
|
|
3
|
+
import { TypeWriter } from './TypeWriter.js';
|
|
4
|
+
|
|
5
|
+
describe('TypeWriter', () => {
|
|
6
|
+
const test = new TypeWriter('Test');
|
|
7
|
+
|
|
8
|
+
it('Creates expected types', async () => {
|
|
9
|
+
await test.addMember('Member', [
|
|
10
|
+
{
|
|
11
|
+
str: 'example string',
|
|
12
|
+
num: 2,
|
|
13
|
+
bool: true,
|
|
14
|
+
},
|
|
15
|
+
]);
|
|
16
|
+
const output = await test.toString();
|
|
17
|
+
assert(/str:\s+string/.test(output));
|
|
18
|
+
assert(/num:\s+number/.test(output));
|
|
19
|
+
assert(/bool:\s+boolean/.test(output));
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import { merge } from 'lodash-es';
|
|
3
|
+
import * as qt from 'quicktype-core';
|
|
4
|
+
|
|
5
|
+
export class TypeWriter {
|
|
6
|
+
moduleName;
|
|
7
|
+
input = qt.jsonInputForTargetLanguage('typescript');
|
|
8
|
+
outDir;
|
|
9
|
+
qtSettings;
|
|
10
|
+
|
|
11
|
+
constructor(moduleName: string, settings: { outDir?: string } & Partial<qt.Options> = {}) {
|
|
12
|
+
this.moduleName = moduleName;
|
|
13
|
+
const { outDir, ...qtSettings } = settings;
|
|
14
|
+
this.outDir = outDir || './types';
|
|
15
|
+
const defaultSettings = {
|
|
16
|
+
lang: 'typescript',
|
|
17
|
+
rendererOptions: {
|
|
18
|
+
'just-types': true,
|
|
19
|
+
'prefer-types': true,
|
|
20
|
+
},
|
|
21
|
+
inferEnums: false,
|
|
22
|
+
inferDateTimes: false,
|
|
23
|
+
};
|
|
24
|
+
this.qtSettings = merge(defaultSettings, qtSettings);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async addMember(name: string, _samples: any[]) {
|
|
28
|
+
const samples = _samples.map((s) => (typeof s === 'string' ? s : JSON.stringify(s)));
|
|
29
|
+
await this.input.addSource({ name, samples });
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async toString() {
|
|
33
|
+
const inputData = new qt.InputData();
|
|
34
|
+
inputData.addInput(this.input);
|
|
35
|
+
const result = await qt.quicktype({
|
|
36
|
+
inputData,
|
|
37
|
+
...this.qtSettings,
|
|
38
|
+
});
|
|
39
|
+
return result.lines.join('\n');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async toFile() {
|
|
43
|
+
const result = await this.toString();
|
|
44
|
+
fs.mkdirSync(this.outDir, { recursive: true });
|
|
45
|
+
fs.writeFileSync(`${this.outDir}/${this.moduleName}.d.ts`, result);
|
|
46
|
+
}
|
|
47
|
+
}
|
package/src/_index.ts
CHANGED
package/src/snapshot.test.ts
CHANGED
|
@@ -3,7 +3,7 @@ import assert from 'node:assert';
|
|
|
3
3
|
import { snapshot } from './snapshot.js';
|
|
4
4
|
|
|
5
5
|
describe('snapshot', () => {
|
|
6
|
-
it('
|
|
6
|
+
it('Captures Error details', () => {
|
|
7
7
|
try {
|
|
8
8
|
throw new Error('Test Error');
|
|
9
9
|
} catch (e) {
|
|
@@ -13,21 +13,21 @@ describe('snapshot', () => {
|
|
|
13
13
|
}
|
|
14
14
|
});
|
|
15
15
|
|
|
16
|
-
it('
|
|
16
|
+
it('Captures Map values', () => {
|
|
17
17
|
const test = new Map<string, string>();
|
|
18
18
|
test.set('key', 'value');
|
|
19
19
|
const shot = JSON.parse(JSON.stringify(snapshot(test))) as Record<string, string>;
|
|
20
20
|
assert(shot.key === 'value');
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
-
it('
|
|
23
|
+
it('Captures Request values', () => {
|
|
24
24
|
const test = new Request('https://www.google.com', { headers: { example: 'value' } });
|
|
25
25
|
const shot = JSON.parse(JSON.stringify(snapshot(test))) as Record<string, any>;
|
|
26
26
|
assert(shot.url !== undefined);
|
|
27
27
|
assert(shot.headers.example === 'value');
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
it('
|
|
30
|
+
it('Ignores functions', () => {
|
|
31
31
|
const test = { func: () => null };
|
|
32
32
|
const shot = snapshot(test) as Record<string, any>;
|
|
33
33
|
assert(shot.func === undefined);
|