@tim-smart/openapi-gen 0.3.13 → 0.3.15
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/main.js +54 -14
- package/package.json +1 -1
package/main.js
CHANGED
|
@@ -8524,6 +8524,7 @@ var identity = (a) => a;
|
|
|
8524
8524
|
var constant = (value5) => () => value5;
|
|
8525
8525
|
var constTrue = /* @__PURE__ */ constant(true);
|
|
8526
8526
|
var constFalse = /* @__PURE__ */ constant(false);
|
|
8527
|
+
var constNull = /* @__PURE__ */ constant(null);
|
|
8527
8528
|
var constUndefined = /* @__PURE__ */ constant(void 0);
|
|
8528
8529
|
var constVoid = constUndefined;
|
|
8529
8530
|
function pipe(a, ab, bc, cd, de, ef, fg, gh, hi) {
|
|
@@ -9360,6 +9361,7 @@ var getOrElse = /* @__PURE__ */ dual(2, (self, onNone) => isNone2(self) ? onNone
|
|
|
9360
9361
|
var orElse = /* @__PURE__ */ dual(2, (self, that) => isNone2(self) ? that() : self);
|
|
9361
9362
|
var orElseSome = /* @__PURE__ */ dual(2, (self, onNone) => isNone2(self) ? some2(onNone()) : self);
|
|
9362
9363
|
var fromNullable = (nullableValue) => nullableValue == null ? none2() : some2(nullableValue);
|
|
9364
|
+
var getOrNull = /* @__PURE__ */ getOrElse(constNull);
|
|
9363
9365
|
var getOrUndefined = /* @__PURE__ */ getOrElse(constUndefined);
|
|
9364
9366
|
var liftThrowable = (f) => (...a) => {
|
|
9365
9367
|
try {
|
|
@@ -34844,11 +34846,19 @@ var make63 = gen2(function* () {
|
|
|
34844
34846
|
const topLevelSource = (importName, name2, schema) => {
|
|
34845
34847
|
const isClass = classes.has(name2);
|
|
34846
34848
|
const isEnum = enums.has(name2);
|
|
34847
|
-
|
|
34849
|
+
const topLevel = transformer.supportsTopLevel({
|
|
34850
|
+
importName,
|
|
34851
|
+
schema,
|
|
34852
|
+
name: name2,
|
|
34853
|
+
isClass,
|
|
34854
|
+
isEnum
|
|
34855
|
+
});
|
|
34856
|
+
return toSource(importName, schema, name2, topLevel).pipe(
|
|
34848
34857
|
map2(
|
|
34849
34858
|
(source) => transformer.onTopLevel({
|
|
34850
34859
|
importName,
|
|
34851
34860
|
schema,
|
|
34861
|
+
description: fromNullable(schema.description),
|
|
34852
34862
|
name: name2,
|
|
34853
34863
|
source,
|
|
34854
34864
|
isClass,
|
|
@@ -34895,6 +34905,7 @@ var make63 = gen2(function* () {
|
|
|
34895
34905
|
map2(
|
|
34896
34906
|
(source) => transformer.onProperty({
|
|
34897
34907
|
importName,
|
|
34908
|
+
description: fromNullable(schema2.description),
|
|
34898
34909
|
key,
|
|
34899
34910
|
source,
|
|
34900
34911
|
isOptional,
|
|
@@ -34963,15 +34974,23 @@ var make63 = gen2(function* () {
|
|
|
34963
34974
|
topLevel
|
|
34964
34975
|
);
|
|
34965
34976
|
} else if ("anyOf" in schema || "oneOf" in schema) {
|
|
34966
|
-
const
|
|
34977
|
+
const items = pipe(
|
|
34967
34978
|
"anyOf" in schema ? schema.anyOf : schema.oneOf,
|
|
34968
34979
|
filterMap2(
|
|
34969
|
-
(_) => toSource(importName, _, currentIdentifier + "Enum")
|
|
34980
|
+
(_) => toSource(importName, _, currentIdentifier + "Enum").pipe(
|
|
34981
|
+
map2(
|
|
34982
|
+
(source) => ({
|
|
34983
|
+
description: fromNullable(_.description),
|
|
34984
|
+
title: fromNullable(_.title),
|
|
34985
|
+
source
|
|
34986
|
+
})
|
|
34987
|
+
)
|
|
34988
|
+
)
|
|
34970
34989
|
)
|
|
34971
34990
|
);
|
|
34972
|
-
if (
|
|
34973
|
-
else if (
|
|
34974
|
-
return some2(transformer.onUnion({ importName,
|
|
34991
|
+
if (items.length === 0) return none2();
|
|
34992
|
+
else if (items.length === 1) return some2(items[0].source);
|
|
34993
|
+
return some2(transformer.onUnion({ importName, items, topLevel }));
|
|
34975
34994
|
} else if ("const" in schema) {
|
|
34976
34995
|
return some2(
|
|
34977
34996
|
transformer.onEnum({
|
|
@@ -35066,6 +35085,9 @@ var layerTransformerSchema = sync6(JsonSchemaTransformer, () => {
|
|
|
35066
35085
|
};
|
|
35067
35086
|
const pipeSource = (modifers) => modifers.length === 0 ? "" : `.pipe(${modifers.join(", ")})`;
|
|
35068
35087
|
return JsonSchemaTransformer.of({
|
|
35088
|
+
supportsTopLevel({ isClass, isEnum }) {
|
|
35089
|
+
return isClass || isEnum;
|
|
35090
|
+
},
|
|
35069
35091
|
onTopLevel({ importName, schema, name: name2, source, isClass }) {
|
|
35070
35092
|
const isObject2 = "properties" in schema;
|
|
35071
35093
|
if (!isObject2 || !isClass) {
|
|
@@ -35147,20 +35169,23 @@ var layerTransformerSchema = sync6(JsonSchemaTransformer, () => {
|
|
|
35147
35169
|
}
|
|
35148
35170
|
return `${importName}.${nonEmpty ? "NonEmpty" : ""}Array(${item})${pipeSource(modifiers)}`;
|
|
35149
35171
|
},
|
|
35150
|
-
onUnion({ importName,
|
|
35151
|
-
return `${importName}.Union(${
|
|
35172
|
+
onUnion({ importName, items }) {
|
|
35173
|
+
return `${importName}.Union(${items.map((_) => _.source).join(", ")})`;
|
|
35152
35174
|
}
|
|
35153
35175
|
});
|
|
35154
35176
|
});
|
|
35155
35177
|
var layerTransformerTs = succeed10(
|
|
35156
35178
|
JsonSchemaTransformer,
|
|
35157
35179
|
JsonSchemaTransformer.of({
|
|
35158
|
-
|
|
35159
|
-
return
|
|
35180
|
+
supportsTopLevel() {
|
|
35181
|
+
return true;
|
|
35182
|
+
},
|
|
35183
|
+
onTopLevel({ name: name2, source, schema, description }) {
|
|
35184
|
+
return source[0] === "{" ? "oneOf" in schema ? `${toComment(description)}export enum ${name2} ${source}` : `${toComment(description)}export interface ${name2} ${source}` : `${toComment(description)}export type ${name2} = ${source}`;
|
|
35160
35185
|
},
|
|
35161
35186
|
propertySeparator: ";\n ",
|
|
35162
|
-
onProperty
|
|
35163
|
-
return
|
|
35187
|
+
onProperty(options3) {
|
|
35188
|
+
return `${toComment(options3.description)}readonly "${options3.key}"${options3.isOptional ? "?" : ""}: ${options3.source}${options3.isNullable ? " | null" : ""}`;
|
|
35164
35189
|
},
|
|
35165
35190
|
onRef({ name: name2 }) {
|
|
35166
35191
|
return name2;
|
|
@@ -35191,11 +35216,22 @@ var layerTransformerTs = succeed10(
|
|
|
35191
35216
|
onArray({ item }) {
|
|
35192
35217
|
return `ReadonlyArray<${item}>`;
|
|
35193
35218
|
},
|
|
35194
|
-
onUnion({
|
|
35195
|
-
|
|
35219
|
+
onUnion({ items, topLevel }) {
|
|
35220
|
+
const useEnum = topLevel && !items.some((_) => isNone2(_.title));
|
|
35221
|
+
if (!useEnum) {
|
|
35222
|
+
return items.map((_) => _.source).join(" | ");
|
|
35223
|
+
}
|
|
35224
|
+
return `{
|
|
35225
|
+
${items.map(({ description, title, source }) => `${toComment(description)}${JSON.stringify(getOrNull(title))} = ${source}`).join(",\n ")}}
|
|
35226
|
+
`;
|
|
35196
35227
|
}
|
|
35197
35228
|
})
|
|
35198
35229
|
);
|
|
35230
|
+
var toComment = match2({
|
|
35231
|
+
onNone: () => "",
|
|
35232
|
+
onSome: (description) => `/** ${description} */
|
|
35233
|
+
`
|
|
35234
|
+
});
|
|
35199
35235
|
function mergeSchemas(self, other) {
|
|
35200
35236
|
if ("properties" in self && "properties" in other) {
|
|
35201
35237
|
return {
|
|
@@ -35422,6 +35458,7 @@ var OpenApiTransformer = class extends Tag2("OpenApiTransformer")() {
|
|
|
35422
35458
|
};
|
|
35423
35459
|
var layerTransformerSchema2 = sync6(OpenApiTransformer, () => {
|
|
35424
35460
|
const operationsToInterface = (name2, operations) => `export interface ${name2} {
|
|
35461
|
+
readonly httpClient: HttpClient.HttpClient
|
|
35425
35462
|
${operations.map(operationToMethod).join("\n ")}
|
|
35426
35463
|
}`;
|
|
35427
35464
|
const operationToMethod = (operation) => {
|
|
@@ -35481,6 +35518,7 @@ var layerTransformerSchema2 = sync6(OpenApiTransformer, () => {
|
|
|
35481
35518
|
options.transformClient ? options.transformClient(client) : Effect.succeed(client)
|
|
35482
35519
|
const decodeError = <A, I, R>(response: HttpClientResponse.HttpClientResponse, schema: S.Schema<A, I, R>) => Effect.flatMap(HttpClientResponse.schemaBodyJson(schema)(response), Effect.fail)
|
|
35483
35520
|
return {
|
|
35521
|
+
httpClient,
|
|
35484
35522
|
${operations.map(operationToImpl).join(",\n ")}
|
|
35485
35523
|
}
|
|
35486
35524
|
}`;
|
|
@@ -35554,6 +35592,7 @@ var layerTransformerSchema2 = sync6(OpenApiTransformer, () => {
|
|
|
35554
35592
|
}).pipe(merge7(layerTransformerSchema));
|
|
35555
35593
|
var layerTransformerTs2 = sync6(OpenApiTransformer, () => {
|
|
35556
35594
|
const operationsToInterface = (name2, operations) => `export interface ${name2} {
|
|
35595
|
+
readonly httpClient: HttpClient.HttpClient
|
|
35557
35596
|
${operations.map((s) => operationToMethod(name2, s)).join("\n ")}
|
|
35558
35597
|
}
|
|
35559
35598
|
|
|
@@ -35668,6 +35707,7 @@ export const ${name2}Error = <Tag extends string, E>(
|
|
|
35668
35707
|
)
|
|
35669
35708
|
}
|
|
35670
35709
|
return {
|
|
35710
|
+
httpClient,
|
|
35671
35711
|
${operations.map(operationToImpl).join(",\n ")}
|
|
35672
35712
|
}
|
|
35673
35713
|
}`;
|