@ps-aux/api-client-gen 0.7.0-rc.7 → 0.7.0-rc.9
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/generate.cjs +30 -10
- package/dist/generate.mjs +30 -10
- package/package.json +1 -1
package/dist/generate.cjs
CHANGED
|
@@ -11355,6 +11355,10 @@ class ZodSchemaGenerator {
|
|
|
11355
11355
|
"z.string().datetime()",
|
|
11356
11356
|
"z.string().datetime({local: true})"
|
|
11357
11357
|
);
|
|
11358
|
+
generated = generated.replaceAll(
|
|
11359
|
+
"z.iso.datetime()",
|
|
11360
|
+
"z.iso.datetime({ local: true })"
|
|
11361
|
+
);
|
|
11358
11362
|
}
|
|
11359
11363
|
return this.codeFormatter.format(generated);
|
|
11360
11364
|
});
|
|
@@ -13677,10 +13681,10 @@ const toHttpMethodUpper = (method) => {
|
|
|
13677
13681
|
class OperationProjector {
|
|
13678
13682
|
constructor(options) {
|
|
13679
13683
|
this.options = options;
|
|
13680
|
-
__publicField$1(this, "
|
|
13684
|
+
__publicField$1(this, "rawOperationIdsByName", /* @__PURE__ */ new Map());
|
|
13681
13685
|
__publicField$1(this, "typeExprConverter");
|
|
13682
13686
|
__publicField$1(this, "project", (openApi) => {
|
|
13683
|
-
this.
|
|
13687
|
+
this.rawOperationIdsByName.clear();
|
|
13684
13688
|
this.typeExprConverter = new ToTypeExprConverter(
|
|
13685
13689
|
openApi.schemas,
|
|
13686
13690
|
this.options.typeExtraction
|
|
@@ -13689,16 +13693,32 @@ class OperationProjector {
|
|
|
13689
13693
|
this.typeExprConverter.registerAllSchemaDefinitions();
|
|
13690
13694
|
}
|
|
13691
13695
|
const operations = openApi.operations.map((operation) => {
|
|
13692
|
-
const
|
|
13693
|
-
if (!
|
|
13696
|
+
const operationId = (operation.operationId ?? syntheticOperationId(operation.method, operation.path)).trim();
|
|
13697
|
+
if (!operationId) {
|
|
13694
13698
|
throw new Error(
|
|
13695
13699
|
`Operation id is empty for ${operation.method.toUpperCase()} ${operation.path}`
|
|
13696
13700
|
);
|
|
13697
13701
|
}
|
|
13698
|
-
|
|
13699
|
-
|
|
13702
|
+
let operationName;
|
|
13703
|
+
try {
|
|
13704
|
+
operationName = toTsCamelIdentifier(operationId, {
|
|
13705
|
+
leadingDigitPrefix: "operation"
|
|
13706
|
+
});
|
|
13707
|
+
} catch {
|
|
13708
|
+
throw new Error(
|
|
13709
|
+
`Invalid operation id "${operationId}": could not derive a client method name.`
|
|
13710
|
+
);
|
|
13711
|
+
}
|
|
13712
|
+
const existingRawOperationId = this.rawOperationIdsByName.get(operationName);
|
|
13713
|
+
if (existingRawOperationId) {
|
|
13714
|
+
if (existingRawOperationId === operationId) {
|
|
13715
|
+
throw new Error(`Duplicate operation id: ${operationId}`);
|
|
13716
|
+
}
|
|
13717
|
+
throw new Error(
|
|
13718
|
+
`Operation naming collision: "${existingRawOperationId}" and "${operationId}" both normalize to "${operationName}". Rename one of these OpenAPI operation ids to continue.`
|
|
13719
|
+
);
|
|
13700
13720
|
}
|
|
13701
|
-
return this.projectOne(operationName, operation);
|
|
13721
|
+
return this.projectOne(operationId, operationName, operation);
|
|
13702
13722
|
});
|
|
13703
13723
|
return {
|
|
13704
13724
|
api: {
|
|
@@ -13710,8 +13730,8 @@ class OperationProjector {
|
|
|
13710
13730
|
schemaDefinitions: this.typeExprConverter.getSchemaDefinitions()
|
|
13711
13731
|
};
|
|
13712
13732
|
});
|
|
13713
|
-
__publicField$1(this, "projectOne", (operationName, operation) => {
|
|
13714
|
-
this.
|
|
13733
|
+
__publicField$1(this, "projectOne", (operationId, operationName, operation) => {
|
|
13734
|
+
this.rawOperationIdsByName.set(operationName, operationId);
|
|
13715
13735
|
const parameters = [];
|
|
13716
13736
|
const pathParameter = this.projectPathParameter(operation);
|
|
13717
13737
|
const queryParameter = this.projectQueryParameter(operation);
|
|
@@ -13722,7 +13742,7 @@ class OperationProjector {
|
|
|
13722
13742
|
return {
|
|
13723
13743
|
op: {
|
|
13724
13744
|
signature: {
|
|
13725
|
-
doc: this.toOperationDoc(
|
|
13745
|
+
doc: this.toOperationDoc(operationId, operation),
|
|
13726
13746
|
name: operationName,
|
|
13727
13747
|
parameters,
|
|
13728
13748
|
returnType: this.projectReturnType(operation)
|
package/dist/generate.mjs
CHANGED
|
@@ -11333,6 +11333,10 @@ class ZodSchemaGenerator {
|
|
|
11333
11333
|
"z.string().datetime()",
|
|
11334
11334
|
"z.string().datetime({local: true})"
|
|
11335
11335
|
);
|
|
11336
|
+
generated = generated.replaceAll(
|
|
11337
|
+
"z.iso.datetime()",
|
|
11338
|
+
"z.iso.datetime({ local: true })"
|
|
11339
|
+
);
|
|
11336
11340
|
}
|
|
11337
11341
|
return this.codeFormatter.format(generated);
|
|
11338
11342
|
});
|
|
@@ -13655,10 +13659,10 @@ const toHttpMethodUpper = (method) => {
|
|
|
13655
13659
|
class OperationProjector {
|
|
13656
13660
|
constructor(options) {
|
|
13657
13661
|
this.options = options;
|
|
13658
|
-
__publicField$1(this, "
|
|
13662
|
+
__publicField$1(this, "rawOperationIdsByName", /* @__PURE__ */ new Map());
|
|
13659
13663
|
__publicField$1(this, "typeExprConverter");
|
|
13660
13664
|
__publicField$1(this, "project", (openApi) => {
|
|
13661
|
-
this.
|
|
13665
|
+
this.rawOperationIdsByName.clear();
|
|
13662
13666
|
this.typeExprConverter = new ToTypeExprConverter(
|
|
13663
13667
|
openApi.schemas,
|
|
13664
13668
|
this.options.typeExtraction
|
|
@@ -13667,16 +13671,32 @@ class OperationProjector {
|
|
|
13667
13671
|
this.typeExprConverter.registerAllSchemaDefinitions();
|
|
13668
13672
|
}
|
|
13669
13673
|
const operations = openApi.operations.map((operation) => {
|
|
13670
|
-
const
|
|
13671
|
-
if (!
|
|
13674
|
+
const operationId = (operation.operationId ?? syntheticOperationId(operation.method, operation.path)).trim();
|
|
13675
|
+
if (!operationId) {
|
|
13672
13676
|
throw new Error(
|
|
13673
13677
|
`Operation id is empty for ${operation.method.toUpperCase()} ${operation.path}`
|
|
13674
13678
|
);
|
|
13675
13679
|
}
|
|
13676
|
-
|
|
13677
|
-
|
|
13680
|
+
let operationName;
|
|
13681
|
+
try {
|
|
13682
|
+
operationName = toTsCamelIdentifier(operationId, {
|
|
13683
|
+
leadingDigitPrefix: "operation"
|
|
13684
|
+
});
|
|
13685
|
+
} catch {
|
|
13686
|
+
throw new Error(
|
|
13687
|
+
`Invalid operation id "${operationId}": could not derive a client method name.`
|
|
13688
|
+
);
|
|
13689
|
+
}
|
|
13690
|
+
const existingRawOperationId = this.rawOperationIdsByName.get(operationName);
|
|
13691
|
+
if (existingRawOperationId) {
|
|
13692
|
+
if (existingRawOperationId === operationId) {
|
|
13693
|
+
throw new Error(`Duplicate operation id: ${operationId}`);
|
|
13694
|
+
}
|
|
13695
|
+
throw new Error(
|
|
13696
|
+
`Operation naming collision: "${existingRawOperationId}" and "${operationId}" both normalize to "${operationName}". Rename one of these OpenAPI operation ids to continue.`
|
|
13697
|
+
);
|
|
13678
13698
|
}
|
|
13679
|
-
return this.projectOne(operationName, operation);
|
|
13699
|
+
return this.projectOne(operationId, operationName, operation);
|
|
13680
13700
|
});
|
|
13681
13701
|
return {
|
|
13682
13702
|
api: {
|
|
@@ -13688,8 +13708,8 @@ class OperationProjector {
|
|
|
13688
13708
|
schemaDefinitions: this.typeExprConverter.getSchemaDefinitions()
|
|
13689
13709
|
};
|
|
13690
13710
|
});
|
|
13691
|
-
__publicField$1(this, "projectOne", (operationName, operation) => {
|
|
13692
|
-
this.
|
|
13711
|
+
__publicField$1(this, "projectOne", (operationId, operationName, operation) => {
|
|
13712
|
+
this.rawOperationIdsByName.set(operationName, operationId);
|
|
13693
13713
|
const parameters = [];
|
|
13694
13714
|
const pathParameter = this.projectPathParameter(operation);
|
|
13695
13715
|
const queryParameter = this.projectQueryParameter(operation);
|
|
@@ -13700,7 +13720,7 @@ class OperationProjector {
|
|
|
13700
13720
|
return {
|
|
13701
13721
|
op: {
|
|
13702
13722
|
signature: {
|
|
13703
|
-
doc: this.toOperationDoc(
|
|
13723
|
+
doc: this.toOperationDoc(operationId, operation),
|
|
13704
13724
|
name: operationName,
|
|
13705
13725
|
parameters,
|
|
13706
13726
|
returnType: this.projectReturnType(operation)
|