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