@azure-tools/typespec-ts 0.29.0 → 0.30.0-alpha.20240628.1
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/CHANGELOG.md +15 -0
- package/dist/src/contextManager.d.ts +70 -0
- package/dist/src/contextManager.d.ts.map +1 -0
- package/dist/src/contextManager.js +59 -0
- package/dist/src/contextManager.js.map +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +38 -28
- package/dist/src/index.js.map +1 -1
- package/dist/src/lib.d.ts +2 -1
- package/dist/src/lib.d.ts.map +1 -1
- package/dist/src/lib.js +3 -2
- package/dist/src/lib.js.map +1 -1
- package/dist/src/metaTree.d.ts +12 -0
- package/dist/src/metaTree.d.ts.map +1 -0
- package/dist/src/metaTree.js +2 -0
- package/dist/src/metaTree.js.map +1 -0
- package/dist/src/modular/buildClassicalClient.d.ts +1 -1
- package/dist/src/modular/buildClassicalClient.d.ts.map +1 -1
- package/dist/src/modular/buildClassicalClient.js +22 -16
- package/dist/src/modular/buildClassicalClient.js.map +1 -1
- package/dist/src/modular/buildClassicalOperationGroups.d.ts +3 -2
- package/dist/src/modular/buildClassicalOperationGroups.d.ts.map +1 -1
- package/dist/src/modular/buildClassicalOperationGroups.js +5 -5
- package/dist/src/modular/buildClassicalOperationGroups.js.map +1 -1
- package/dist/src/modular/buildClientContext.d.ts +1 -1
- package/dist/src/modular/buildClientContext.d.ts.map +1 -1
- package/dist/src/modular/buildClientContext.js +7 -6
- package/dist/src/modular/buildClientContext.js.map +1 -1
- package/dist/src/modular/buildCodeModel.d.ts +2 -2
- package/dist/src/modular/buildCodeModel.d.ts.map +1 -1
- package/dist/src/modular/buildCodeModel.js +69 -43
- package/dist/src/modular/buildCodeModel.js.map +1 -1
- package/dist/src/modular/buildHelperSerializers.d.ts +3 -0
- package/dist/src/modular/buildHelperSerializers.d.ts.map +1 -0
- package/dist/src/modular/buildHelperSerializers.js +60 -0
- package/dist/src/modular/buildHelperSerializers.js.map +1 -0
- package/dist/src/modular/buildLroFiles.d.ts +1 -1
- package/dist/src/modular/buildLroFiles.d.ts.map +1 -1
- package/dist/src/modular/buildLroFiles.js +25 -31
- package/dist/src/modular/buildLroFiles.js.map +1 -1
- package/dist/src/modular/buildOperations.d.ts +3 -2
- package/dist/src/modular/buildOperations.d.ts.map +1 -1
- package/dist/src/modular/buildOperations.js +25 -12
- package/dist/src/modular/buildOperations.js.map +1 -1
- package/dist/src/modular/buildPagingFiles.d.ts.map +1 -1
- package/dist/src/modular/buildPagingFiles.js.map +1 -1
- package/dist/src/modular/buildProjectFiles.d.ts.map +1 -1
- package/dist/src/modular/buildProjectFiles.js.map +1 -1
- package/dist/src/modular/buildRootIndex.d.ts.map +1 -1
- package/dist/src/modular/buildRootIndex.js +1 -1
- package/dist/src/modular/buildRootIndex.js.map +1 -1
- package/dist/src/modular/buildSerializeUtils.d.ts +2 -2
- package/dist/src/modular/buildSerializeUtils.d.ts.map +1 -1
- package/dist/src/modular/buildSerializeUtils.js +15 -8
- package/dist/src/modular/buildSerializeUtils.js.map +1 -1
- package/dist/src/modular/buildSubpathIndex.d.ts.map +1 -1
- package/dist/src/modular/buildSubpathIndex.js +6 -0
- package/dist/src/modular/buildSubpathIndex.js.map +1 -1
- package/dist/src/modular/emitModels.d.ts +5 -5
- package/dist/src/modular/emitModels.d.ts.map +1 -1
- package/dist/src/modular/emitModels.js +78 -21
- package/dist/src/modular/emitModels.js.map +1 -1
- package/dist/src/modular/helpers/classicalOperationHelpers.d.ts +3 -1
- package/dist/src/modular/helpers/classicalOperationHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/classicalOperationHelpers.js +32 -15
- package/dist/src/modular/helpers/classicalOperationHelpers.js.map +1 -1
- package/dist/src/modular/helpers/clientHelpers.d.ts +3 -2
- package/dist/src/modular/helpers/clientHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/clientHelpers.js +14 -5
- package/dist/src/modular/helpers/clientHelpers.js.map +1 -1
- package/dist/src/modular/helpers/namingHelpers.d.ts +5 -1
- package/dist/src/modular/helpers/namingHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/namingHelpers.js +25 -1
- package/dist/src/modular/helpers/namingHelpers.js.map +1 -1
- package/dist/src/modular/helpers/operationHelpers.d.ts +11 -3
- package/dist/src/modular/helpers/operationHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/operationHelpers.js +160 -66
- package/dist/src/modular/helpers/operationHelpers.js.map +1 -1
- package/dist/src/modular/helpers/typeHelpers.d.ts +3 -0
- package/dist/src/modular/helpers/typeHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/typeHelpers.js +50 -19
- package/dist/src/modular/helpers/typeHelpers.js.map +1 -1
- package/dist/src/modular/modularCodeModel.d.ts +9 -5
- package/dist/src/modular/modularCodeModel.d.ts.map +1 -1
- package/dist/src/modular/serialization/buildSerializerFunction.d.ts +4 -0
- package/dist/src/modular/serialization/buildSerializerFunction.d.ts.map +1 -0
- package/dist/src/modular/serialization/buildSerializerFunction.js +160 -0
- package/dist/src/modular/serialization/buildSerializerFunction.js.map +1 -0
- package/dist/src/modular/serialization/collectionUtils.d.ts +3 -0
- package/dist/src/modular/serialization/collectionUtils.d.ts.map +1 -0
- package/dist/src/modular/serialization/collectionUtils.js +17 -0
- package/dist/src/modular/serialization/collectionUtils.js.map +1 -0
- package/dist/src/modular/serialization/index.d.ts +5 -0
- package/dist/src/modular/serialization/index.d.ts.map +1 -0
- package/dist/src/modular/serialization/index.js +156 -0
- package/dist/src/modular/serialization/index.js.map +1 -0
- package/dist/src/modular/serialization/operationHelpers.d.ts +37 -0
- package/dist/src/modular/serialization/operationHelpers.d.ts.map +1 -0
- package/dist/src/modular/serialization/operationHelpers.js +457 -0
- package/dist/src/modular/serialization/operationHelpers.js.map +1 -0
- package/dist/src/modular/serialization/serializeArray.d.ts +5 -0
- package/dist/src/modular/serialization/serializeArray.d.ts.map +1 -0
- package/dist/src/modular/serialization/serializeArray.js +33 -0
- package/dist/src/modular/serialization/serializeArray.js.map +1 -0
- package/dist/src/modular/serialization/serializeDateTime.d.ts +4 -0
- package/dist/src/modular/serialization/serializeDateTime.d.ts.map +1 -0
- package/dist/src/modular/serialization/serializeDateTime.js +19 -0
- package/dist/src/modular/serialization/serializeDateTime.js.map +1 -0
- package/dist/src/modular/serialization/serializeHeaders.d.ts +7 -0
- package/dist/src/modular/serialization/serializeHeaders.d.ts.map +1 -0
- package/dist/src/modular/serialization/serializeHeaders.js +44 -0
- package/dist/src/modular/serialization/serializeHeaders.js.map +1 -0
- package/dist/src/modular/serialization/serializers.d.ts +17 -0
- package/dist/src/modular/serialization/serializers.d.ts.map +1 -0
- package/dist/src/modular/serialization/serializers.js +176 -0
- package/dist/src/modular/serialization/serializers.js.map +1 -0
- package/dist/src/modular/serialization/util.d.ts +26 -0
- package/dist/src/modular/serialization/util.d.ts.map +1 -0
- package/dist/src/modular/serialization/util.js +112 -0
- package/dist/src/modular/serialization/util.js.map +1 -0
- package/dist/src/reify/index.d.ts +12 -0
- package/dist/src/reify/index.d.ts.map +1 -0
- package/dist/src/reify/index.js +22 -0
- package/dist/src/reify/index.js.map +1 -0
- package/dist/src/testing/index.d.ts +2 -0
- package/dist/src/testing/index.d.ts.map +1 -0
- package/dist/src/testing/index.js +7 -0
- package/dist/src/testing/index.js.map +1 -0
- package/dist/src/transform/transform.d.ts +1 -1
- package/dist/src/transform/transform.d.ts.map +1 -1
- package/dist/src/transform/transform.js +11 -11
- package/dist/src/transform/transform.js.map +1 -1
- package/dist/src/transform/transformApiVersionInfo.d.ts +1 -1
- package/dist/src/transform/transformApiVersionInfo.d.ts.map +1 -1
- package/dist/src/transform/transformApiVersionInfo.js +16 -6
- package/dist/src/transform/transformApiVersionInfo.js.map +1 -1
- package/dist/src/transform/transformHelperFunctionDetails.d.ts +1 -1
- package/dist/src/transform/transformHelperFunctionDetails.d.ts.map +1 -1
- package/dist/src/transform/transformHelperFunctionDetails.js +1 -1
- package/dist/src/transform/transformHelperFunctionDetails.js.map +1 -1
- package/dist/src/transform/transformParameters.d.ts +1 -1
- package/dist/src/transform/transformParameters.d.ts.map +1 -1
- package/dist/src/transform/transformParameters.js +3 -3
- package/dist/src/transform/transformParameters.js.map +1 -1
- package/dist/src/transform/transformPaths.d.ts +1 -1
- package/dist/src/transform/transformPaths.d.ts.map +1 -1
- package/dist/src/transform/transformPaths.js +3 -4
- package/dist/src/transform/transformPaths.js.map +1 -1
- package/dist/src/transform/transformResponses.d.ts +1 -1
- package/dist/src/transform/transformResponses.d.ts.map +1 -1
- package/dist/src/transform/transformResponses.js +12 -9
- package/dist/src/transform/transformResponses.js.map +1 -1
- package/dist/src/transform/transformSchemas.d.ts.map +1 -1
- package/dist/src/transform/transformSchemas.js +10 -4
- package/dist/src/transform/transformSchemas.js.map +1 -1
- package/dist/src/transform/transformTelemetryInfo.d.ts.map +1 -1
- package/dist/src/transform/transformTelemetryInfo.js +1 -1
- package/dist/src/transform/transformTelemetryInfo.js.map +1 -1
- package/dist/src/transform/transfromRLCOptions.d.ts.map +1 -1
- package/dist/src/transform/transfromRLCOptions.js +11 -5
- package/dist/src/transform/transfromRLCOptions.js.map +1 -1
- package/dist/src/utils/clientUtils.js.map +1 -1
- package/dist/src/utils/emitUtil.d.ts +1 -2
- package/dist/src/utils/emitUtil.d.ts.map +1 -1
- package/dist/src/utils/emitUtil.js.map +1 -1
- package/dist/src/utils/importHelper.d.ts +10 -0
- package/dist/src/utils/importHelper.d.ts.map +1 -0
- package/dist/src/utils/importHelper.js +54 -0
- package/dist/src/utils/importHelper.js.map +1 -0
- package/dist/src/utils/modelUtils.d.ts +1 -1
- package/dist/src/utils/modelUtils.d.ts.map +1 -1
- package/dist/src/utils/modelUtils.js +41 -25
- package/dist/src/utils/modelUtils.js.map +1 -1
- package/dist/src/utils/namespaceUtils.d.ts.map +1 -1
- package/dist/src/utils/namespaceUtils.js.map +1 -1
- package/dist/src/utils/operationUtil.d.ts +3 -4
- package/dist/src/utils/operationUtil.d.ts.map +1 -1
- package/dist/src/utils/operationUtil.js +4 -5
- package/dist/src/utils/operationUtil.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +55 -35
- package/src/contextManager.ts +99 -0
- package/src/index.ts +66 -55
- package/src/lib.ts +6 -4
- package/src/metaTree.ts +14 -0
- package/src/modular/buildClassicalClient.ts +36 -18
- package/src/modular/buildClassicalOperationGroups.ts +16 -8
- package/src/modular/buildClientContext.ts +13 -12
- package/src/modular/buildCodeModel.ts +141 -99
- package/src/modular/buildHelperSerializers.ts +71 -0
- package/src/modular/buildLroFiles.ts +29 -33
- package/src/modular/buildOperations.ts +70 -32
- package/src/modular/buildPagingFiles.ts +1 -1
- package/src/modular/buildProjectFiles.ts +1 -1
- package/src/modular/buildRootIndex.ts +1 -1
- package/src/modular/buildSerializeUtils.ts +33 -25
- package/src/modular/buildSubpathIndex.ts +10 -0
- package/src/modular/emitModels.ts +115 -32
- package/src/modular/helpers/classicalOperationHelpers.ts +48 -11
- package/src/modular/helpers/clientHelpers.ts +19 -6
- package/src/modular/helpers/namingHelpers.ts +59 -4
- package/src/modular/helpers/operationHelpers.ts +247 -111
- package/src/modular/helpers/typeHelpers.ts +54 -17
- package/src/modular/modularCodeModel.ts +17 -5
- package/src/modular/serialization/buildSerializerFunction.ts +224 -0
- package/src/modular/serialization/collectionUtils.ts +20 -0
- package/src/modular/serialization/index.ts +263 -0
- package/src/modular/serialization/operationHelpers.ts +660 -0
- package/src/modular/serialization/serializeArray.ts +51 -0
- package/src/modular/serialization/serializeDateTime.ts +22 -0
- package/src/modular/serialization/serializeHeaders.ts +64 -0
- package/src/modular/serialization/serializers.ts +304 -0
- package/src/modular/serialization/util.ts +167 -0
- package/src/reify/index.ts +41 -0
- package/src/testing/index.ts +10 -0
- package/src/transform/transform.ts +15 -15
- package/src/transform/transformApiVersionInfo.ts +29 -16
- package/src/transform/transformHelperFunctionDetails.ts +8 -8
- package/src/transform/transformParameters.ts +15 -15
- package/src/transform/transformPaths.ts +12 -12
- package/src/transform/transformResponses.ts +21 -18
- package/src/transform/transformSchemas.ts +17 -8
- package/src/transform/transformTelemetryInfo.ts +4 -4
- package/src/transform/transfromRLCOptions.ts +14 -7
- package/src/utils/clientUtils.ts +2 -2
- package/src/utils/emitUtil.ts +6 -3
- package/src/utils/importHelper.ts +64 -0
- package/src/utils/modelUtils.ts +79 -47
- package/src/utils/namespaceUtils.ts +1 -1
- package/src/utils/operationUtil.ts +22 -24
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { NameType } from "@azure-tools/rlc-common";
|
|
2
|
+
import { importLroCoreDependencies } from "./buildLroFiles.js";
|
|
3
|
+
import { importModels, importPagingDependencies } from "./buildOperations.js";
|
|
2
4
|
import { getClassicalOperation } from "./helpers/classicalOperationHelpers.js";
|
|
3
5
|
import { getClassicalLayerPrefix } from "./helpers/namingHelpers.js";
|
|
4
|
-
|
|
5
|
-
import { importLroCoreDependencies } from "./buildLroFiles.js";
|
|
6
|
-
export function buildClassicOperationFiles(codeModel, client) {
|
|
6
|
+
export function buildClassicOperationFiles(dpgContext, codeModel, client) {
|
|
7
7
|
var _a, _b;
|
|
8
8
|
const classicOperationFiles = new Map();
|
|
9
9
|
for (const operationGroup of client.operationGroups) {
|
|
@@ -16,7 +16,7 @@ export function buildClassicOperationFiles(codeModel, client) {
|
|
|
16
16
|
const subfolder = client.subfolder;
|
|
17
17
|
const srcPath = codeModel.modularOptions.sourceRoot;
|
|
18
18
|
const classicFile = (_a = classicOperationFiles.get(classicOperationFileName)) !== null && _a !== void 0 ? _a : codeModel.project.createSourceFile(`${srcPath}/${subfolder && subfolder !== "" ? subfolder + "/" : ""}classic/${classicOperationFileName}.ts`);
|
|
19
|
-
getClassicalOperation(
|
|
19
|
+
getClassicalOperation(dpgContext, client, classicFile, operationGroup);
|
|
20
20
|
// Import models used from ./models.ts
|
|
21
21
|
// We SHOULD keep this because otherwise ts-morph will "helpfully" try to import models from the rest layer when we call fixMissingImports().
|
|
22
22
|
importModels(srcPath, classicFile, codeModel.project, subfolder, operationGroup.namespaceHierarchies.length);
|
|
@@ -40,7 +40,7 @@ export function buildClassicOperationFiles(codeModel, client) {
|
|
|
40
40
|
const subfolder = client.subfolder;
|
|
41
41
|
const srcPath = codeModel.modularOptions.sourceRoot;
|
|
42
42
|
const classicFile = (_b = classicOperationFiles.get(classicOperationFileName)) !== null && _b !== void 0 ? _b : codeModel.project.createSourceFile(`${srcPath}/${subfolder && subfolder !== "" ? subfolder + "/" : ""}classic/${classicOperationFileName}.ts`);
|
|
43
|
-
getClassicalOperation(
|
|
43
|
+
getClassicalOperation(dpgContext, client, classicFile, operationGroup, layer);
|
|
44
44
|
// Import models used from ./models.ts
|
|
45
45
|
// We SHOULD keep this because otherwise ts-morph will "helpfully" try to import models from the rest layer when we call fixMissingImports().
|
|
46
46
|
importModels(srcPath, classicFile, codeModel.project, subfolder, layer);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildClassicalOperationGroups.js","sourceRoot":"","sources":["../../../src/modular/buildClassicalOperationGroups.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"buildClassicalOperationGroups.js","sourceRoot":"","sources":["../../../src/modular/buildClassicalOperationGroups.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAEnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAC/E,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAQrE,MAAM,UAAU,0BAA0B,CACxC,UAAsB,EACtB,SAA2B,EAC3B,MAAc;;IAEd,MAAM,qBAAqB,GAA4B,IAAI,GAAG,EAG3D,CAAC;IACJ,KAAK,MAAM,cAAc,IAAI,MAAM,C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GAAG,OAAO,CAAC,uBAAuB,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE;QAC1E,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;IAEH,MAAM,cAAc,GAAG,WAAW,CAAC,qBAAqB,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE;QACtE,OAAO,CAAC;aACL,uBAAuB,EAAE;aACzB,QAAQ,CAAC,UAAU,wBAAwB,EAAE,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACN,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;QAC3C,WAAW,CAAC,oBAAoB,CAAC;YAC/B,eAAe,EAAE,GAAG,KAAK,CAAC,MAAM,CAC9B,cAAc,CAAC,oBAAoB,CAAC,MAAM,GAAG,CAAC,CAC/C,OAAO,wBAAwB,KAAK;YACrC,YAAY,EAAE,QAAQ;SACvB,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SourceFile } from "ts-morph";
|
|
2
|
-
import { Client, ModularCodeModel } from "./modularCodeModel.js";
|
|
3
2
|
import { SdkContext } from "../utils/interfaces.js";
|
|
3
|
+
import { Client, ModularCodeModel } from "./modularCodeModel.js";
|
|
4
4
|
/**
|
|
5
5
|
* This function creates the file containing the modular client context
|
|
6
6
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildClientContext.d.ts","sourceRoot":"","sources":["../../../src/modular/buildClientContext.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"buildClientContext.d.ts","sourceRoot":"","sources":["../../../src/modular/buildClientContext.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AASpD,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEjE;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,gBAAgB,GAC1B,UAAU,CAiHZ"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getClientName } from "./helpers/namingHelpers.js";
|
|
1
|
+
import { getImportSpecifier, NameType, normalizeName } from "@azure-tools/rlc-common";
|
|
3
2
|
import { isRLCMultiEndpoint } from "../utils/clientUtils.js";
|
|
4
|
-
import { getDocsFromDescription } from "./helpers/docsHelpers.js";
|
|
5
3
|
import { importModels } from "./buildOperations.js";
|
|
6
|
-
import {
|
|
4
|
+
import { getClientParameters, importCredential } from "./helpers/clientHelpers.js";
|
|
5
|
+
import { getDocsFromDescription } from "./helpers/docsHelpers.js";
|
|
6
|
+
import { getClientName } from "./helpers/namingHelpers.js";
|
|
7
7
|
import { getType } from "./helpers/typeHelpers.js";
|
|
8
8
|
/**
|
|
9
9
|
* This function creates the file containing the modular client context
|
|
@@ -11,7 +11,7 @@ import { getType } from "./helpers/typeHelpers.js";
|
|
|
11
11
|
export function buildClientContext(client, dpgContext, codeModel) {
|
|
12
12
|
const { description, subfolder } = client;
|
|
13
13
|
const name = getClientName(client);
|
|
14
|
-
const params = getClientParameters(client);
|
|
14
|
+
const params = getClientParameters(client, dpgContext);
|
|
15
15
|
const srcPath = codeModel.modularOptions.sourceRoot;
|
|
16
16
|
const clientContextFile = codeModel.project.createSourceFile(`${srcPath}/${subfolder && subfolder !== "" ? subfolder + "/" : ""}/api/${normalizeName(name, NameType.File)}Context.ts`);
|
|
17
17
|
let factoryFunction;
|
|
@@ -36,7 +36,8 @@ export function buildClientContext(client, dpgContext, codeModel) {
|
|
|
36
36
|
hasQuestionToken: true,
|
|
37
37
|
docs: getDocsFromDescription(p.description)
|
|
38
38
|
};
|
|
39
|
-
})
|
|
39
|
+
}),
|
|
40
|
+
docs: ["Optional parameters for the client."]
|
|
40
41
|
});
|
|
41
42
|
if (isRLCMultiEndpoint(dpgContext)) {
|
|
42
43
|
clientContextFile.addImportDeclaration({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildClientContext.js","sourceRoot":"","sources":["../../../src/modular/buildClientContext.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"buildClientContext.js","sourceRoot":"","sources":["../../../src/modular/buildClientContext.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,QAAQ,EACR,aAAa,EACd,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAGnD;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAChC,MAAc,EACd,UAAsB,EACtB,SAA2B;IAE3B,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC;IAC1C,MAAM,IAAI,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IACnC,MAAM,MAAM,GAAG,mBAAmB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACvD,MAAM,OAAO,GAAG,SAAS,CAAC,cAAc,CAAC,UAAU,CAAC;IACpD,MAAM,iBAAiB,GAAG,SAAS,CAAC,OAAO,CAAC,gBAAgB,CAC1D,GAAG,OAAO,IACR,SAAS,IAAI,SAAS,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,GAAG,G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CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAC7C,MAAM,kBAAkB,GAAG,mCAAmC,UAAU,CAAC,IAAI,CAC3E,GAAG,CACJ,GAAG,CAAC;IAEL,eAAe,CAAC,aAAa,CAAC,CAAC,kBAAkB,EAAE,uBAAuB,CAAC,CAAC,CAAC;IAE7E,IAAI,kBAAkB,CAAC,UAAU,CAAC,EAAE,CAAC;QACnC,iBAAiB,CAAC,qBAAqB,CAAC;YACtC;gBACE,eAAe,EAAE,cAAc,SAAS,WAAW;gBACnD,YAAY,EAAE,CAAC,2BAA2B,CAAC;aAC5C;SACF,CAAC,CAAC;IACL,CAAC;SAAM,CAAC;QACN,iBAAiB,CAAC,qBAAqB,CAAC;YACtC;gBACE,eAAe,EAAE,GACf,SAAS,IAAI,SAAS,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAC1C,kBAAkB;gBAClB,aAAa,EAAE,WAAW;aAC3B;SACF,CAAC,CAAC;IACL,CAAC;IAED,iBAAiB,CAAC,iBAAiB,CACjC,EAAE,EACF,EAAE,2BAA2B,EAAE,IAAI,EAAE,CACtC,CAAC;IAEF,iBAAiB,CAAC,oBAAoB,EAAE,CAAC;IACzC,OAAO,iBAAiB,CAAC;AAC3B,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ModularCodeModel } from "./modularCodeModel.js";
|
|
2
1
|
import { RLCModel } from "@azure-tools/rlc-common";
|
|
3
|
-
import { SdkContext } from "../utils/interfaces.js";
|
|
4
2
|
import { Project } from "ts-morph";
|
|
3
|
+
import { SdkContext } from "../utils/interfaces.js";
|
|
4
|
+
import { ModularCodeModel } from "./modularCodeModel.js";
|
|
5
5
|
export interface EmitterOptions {
|
|
6
6
|
"basic-setup-py"?: boolean;
|
|
7
7
|
"package-version"?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildCodeModel.d.ts","sourceRoot":"","sources":["../../../src/modular/buildCodeModel.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"buildCodeModel.d.ts","sourceRoot":"","sources":["../../../src/modular/buildCodeModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,QAAQ,EACT,MAAM,yBAAyB,CAAC;AA0EjC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAGnC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAsBpD,OAAO,EAGL,gBAAgB,EAOjB,MAAM,uBAAuB,CAAC;AAuB/B,MAAM,WAAW,cAAc;IAC7B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAiqDD,wBAAgB,aAAa,CAC3B,UAAU,EAAE,UAAU,EACtB,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,EACnC,kBAAkB,EAAE,MAAM,EAC1B,OAAO,EAAE,OAAO,EAChB,OAAO,GAAE;IAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAAA;CAAwB,GAC3D,gBAAgB,CA0DlB"}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { buildRuntimeImports, getClientName, NameType, normalizeName } from "@azure-tools/rlc-common";
|
|
2
|
+
import { getLroMetadata, getPagedResult } from "@azure-tools/typespec-azure-core";
|
|
3
|
+
import { getAllModels, getClientNamespaceString, getClientType, getDefaultApiVersion, getLibraryName, getSdkBuiltInType, getSdkUnion, getWireName, isApiVersion, listClients, listOperationGroups, listOperationsInOperationGroup } from "@azure-tools/typespec-client-generator-core";
|
|
4
|
+
import { getDiscriminator, getDoc, getEncode, getFriendlyName, getMaxItems, getMaxLength, getMaxValue, getMinItems, getMinLength, getMinValue, getPattern, getPropertyType, getSummary, getVisibility, ignoreDiagnostics, isErrorModel, isNeverType, isNullType, isNumericType, isStringType, isTemplateDeclarationOrInstance, isType, isVoidType, listServices, UsageFlags } from "@typespec/compiler";
|
|
5
|
+
import { getAuthentication, getHttpOperation, getServers, isSharedRoute } from "@typespec/http";
|
|
4
6
|
import { getAddedOnVersions } from "@typespec/versioning";
|
|
5
|
-
import {
|
|
6
|
-
import { buildCoreTypeInfo, getBodyType, getDefaultApiVersionString, getEffectiveSchemaType, isAzureCoreErrorType, isSchemaProperty } from "../utils/modelUtils.js";
|
|
7
|
+
import { reportDiagnostic } from "../lib.js";
|
|
7
8
|
import { camelToSnakeCase, toCamelCase } from "../utils/casingUtils.js";
|
|
8
|
-
import {
|
|
9
|
-
import { getOperationGroupName, getOperationName, isBinaryPayload, isIgnoredHeaderParam, isLongRunningOperation, parseItemName, parseNextLinkName } from "../utils/operationUtil.js";
|
|
10
|
-
import { buildRuntimeImports } from "@azure-tools/rlc-common";
|
|
9
|
+
import { buildCoreTypeInfo, getBodyType, getDefaultApiVersionString, getEffectiveSchemaType, isAzureCoreErrorType, isSchemaProperty } from "../utils/modelUtils.js";
|
|
11
10
|
import { getModelNamespaceName } from "../utils/namespaceUtils.js";
|
|
12
|
-
import {
|
|
13
|
-
import { getType as getTypeName } from "./helpers/typeHelpers.js";
|
|
11
|
+
import { extractPagedMetadataNested, getOperationGroupName, getOperationName, isBinaryPayload, isIgnoredHeaderParam, isLongRunningOperation, parseItemName, parseNextLinkName } from "../utils/operationUtil.js";
|
|
14
12
|
import { isModelWithAdditionalProperties } from "./emitModels.js";
|
|
13
|
+
import { getType as getTypeName } from "./helpers/typeHelpers.js";
|
|
14
|
+
import { useContext } from "../contextManager.js";
|
|
15
15
|
let CASING = "snake";
|
|
16
16
|
function applyCasing(name, options = { casing: "snake" }) {
|
|
17
17
|
if (options.casing === "camel") {
|
|
@@ -143,6 +143,7 @@ function isEmptyAnonymousModel(type) {
|
|
|
143
143
|
}
|
|
144
144
|
function getType(context, type, options = {}) {
|
|
145
145
|
var _a, _b;
|
|
146
|
+
const modularMetatree = useContext("modularMetaTree");
|
|
146
147
|
// don't cache simple type(string, int, etc) since decorators may change the result
|
|
147
148
|
const enableCache = !isSimpleType(context.program, type);
|
|
148
149
|
const effectiveModel = !options.disableEffectiveModel &&
|
|
@@ -166,6 +167,11 @@ function getType(context, type, options = {}) {
|
|
|
166
167
|
if (type.kind === "ModelProperty" || type.kind === "Scalar") {
|
|
167
168
|
newValue = applyEncoding(context.program, type, newValue);
|
|
168
169
|
}
|
|
170
|
+
if (isTypespecType(type)) {
|
|
171
|
+
newValue.tcgcType = getClientType(context, type);
|
|
172
|
+
newValue.__raw = type;
|
|
173
|
+
modularMetatree.set(type, newValue);
|
|
174
|
+
}
|
|
169
175
|
if (enableCache) {
|
|
170
176
|
if (!options.disableEffectiveModel) {
|
|
171
177
|
typesMap.set(effectiveModel, newValue);
|
|
@@ -187,7 +193,8 @@ function getType(context, type, options = {}) {
|
|
|
187
193
|
}
|
|
188
194
|
}
|
|
189
195
|
else {
|
|
190
|
-
const
|
|
196
|
+
const { __raw, tcgcType, ...keyableValue } = newValue;
|
|
197
|
+
const key = JSON.stringify(keyableValue);
|
|
191
198
|
const value = simpleTypesMap.get(key);
|
|
192
199
|
if (value) {
|
|
193
200
|
newValue = value;
|
|
@@ -209,6 +216,9 @@ function getType(context, type, options = {}) {
|
|
|
209
216
|
}
|
|
210
217
|
return newValue;
|
|
211
218
|
}
|
|
219
|
+
function isTypespecType(type) {
|
|
220
|
+
return type.kind !== "Credential" && type.kind !== "CredentialTypeUnion";
|
|
221
|
+
}
|
|
212
222
|
// To pass the yaml dump
|
|
213
223
|
function getAddedOnVersion(p, t) {
|
|
214
224
|
var _a, _b;
|
|
@@ -243,29 +253,33 @@ function emitParamBase(context, parameter) {
|
|
|
243
253
|
clientName: applyCasing(name, { casing: CASING }),
|
|
244
254
|
restApiName,
|
|
245
255
|
inOverload: false,
|
|
246
|
-
format
|
|
256
|
+
format,
|
|
257
|
+
tcgcType: getClientType(context, parameter)
|
|
247
258
|
};
|
|
248
259
|
}
|
|
249
260
|
function emitBodyParameter(context, httpOperation) {
|
|
250
261
|
var _a;
|
|
251
262
|
const params = httpOperation.parameters;
|
|
252
263
|
const body = params.body;
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
contentTypes
|
|
264
|
+
if (body.bodyKind === "single") {
|
|
265
|
+
const base = emitParamBase(context, (_a = body.parameter) !== null && _a !== void 0 ? _a : body.type);
|
|
266
|
+
let contentTypes = body.contentTypes;
|
|
267
|
+
if (contentTypes.length === 0) {
|
|
268
|
+
contentTypes = ["application/json"];
|
|
269
|
+
}
|
|
270
|
+
const type = getType(context, getBodyType(context.program, httpOperation), {
|
|
271
|
+
disableEffectiveModel: true,
|
|
272
|
+
usage: UsageFlags.Input
|
|
273
|
+
});
|
|
274
|
+
return {
|
|
275
|
+
contentTypes,
|
|
276
|
+
type,
|
|
277
|
+
location: "body",
|
|
278
|
+
...base,
|
|
279
|
+
isBinaryPayload: isBinaryPayload(context, body.type, contentTypes)
|
|
280
|
+
};
|
|
257
281
|
}
|
|
258
|
-
|
|
259
|
-
disableEffectiveModel: true,
|
|
260
|
-
usage: UsageFlags.Input
|
|
261
|
-
});
|
|
262
|
-
return {
|
|
263
|
-
contentTypes,
|
|
264
|
-
type,
|
|
265
|
-
location: "body",
|
|
266
|
-
...base,
|
|
267
|
-
isBinaryPayload: isBinaryPayload(context, body.type, contentTypes)
|
|
268
|
-
};
|
|
282
|
+
return undefined;
|
|
269
283
|
}
|
|
270
284
|
function emitParameter(context, parameter, implementation) {
|
|
271
285
|
var _a;
|
|
@@ -637,7 +651,7 @@ function getName(program, type) {
|
|
|
637
651
|
type.templateMapper.args &&
|
|
638
652
|
type.templateMapper.args.length > 0) {
|
|
639
653
|
return (type.name +
|
|
640
|
-
type.templateMapper.args
|
|
654
|
+
type.templateMapper.args.filter((it) => isType(it))
|
|
641
655
|
.map((it) => (it.kind === "Model" ? it.name : ""))
|
|
642
656
|
.join(""));
|
|
643
657
|
}
|
|
@@ -675,7 +689,7 @@ function emitModel(context, type, usage) {
|
|
|
675
689
|
type.templateMapper.args.length > 0 &&
|
|
676
690
|
getPagedResult(context.program, type)) {
|
|
677
691
|
modelName =
|
|
678
|
-
type.templateMapper.args
|
|
692
|
+
type.templateMapper.args.filter((it) => isType(it))
|
|
679
693
|
.map((it) => {
|
|
680
694
|
switch (it.kind) {
|
|
681
695
|
case "Model":
|
|
@@ -688,9 +702,11 @@ function emitModel(context, type, usage) {
|
|
|
688
702
|
})
|
|
689
703
|
.join("") + "List";
|
|
690
704
|
}
|
|
705
|
+
const page = extractPagedMetadataNested(context.program, type);
|
|
706
|
+
const isPaging = page && page.itemsSegments && page.itemsSegments.length > 0;
|
|
691
707
|
return {
|
|
692
708
|
type: "model",
|
|
693
|
-
name: modelName
|
|
709
|
+
name: `${isPaging ? "_" : ""}${modelName}`,
|
|
694
710
|
description: getDocStr(context.program, type),
|
|
695
711
|
parents: baseModel ? [baseModel] : [],
|
|
696
712
|
discriminatedSubtypes: [],
|
|
@@ -724,10 +740,13 @@ function emitEnum(context, type) {
|
|
|
724
740
|
description: getDocStr(program, m)
|
|
725
741
|
});
|
|
726
742
|
}
|
|
743
|
+
const name = normalizeName(getLibraryName(context, type) ? getLibraryName(context, type) : type.name, NameType.Interface);
|
|
727
744
|
return {
|
|
728
745
|
type: "enum",
|
|
729
|
-
name
|
|
730
|
-
description: getDocStr(program, type)
|
|
746
|
+
name,
|
|
747
|
+
description: getDocStr(program, type) === ""
|
|
748
|
+
? `Type of ${name}`
|
|
749
|
+
: getDocStr(program, type),
|
|
731
750
|
valueType: { type: enumMemberType(type.members.values().next().value) },
|
|
732
751
|
values: enumValues,
|
|
733
752
|
isFixed: true,
|
|
@@ -949,8 +968,12 @@ function mapTypeSpecType(context, type, usage) {
|
|
|
949
968
|
}
|
|
950
969
|
}
|
|
951
970
|
function emitUnion(context, type, usage) {
|
|
952
|
-
var _a;
|
|
953
|
-
|
|
971
|
+
var _a, _b, _c;
|
|
972
|
+
let sdkType = getSdkUnion(context, type);
|
|
973
|
+
const isNull = false;
|
|
974
|
+
if (sdkType.kind === "nullable") {
|
|
975
|
+
sdkType = sdkType.type;
|
|
976
|
+
}
|
|
954
977
|
const nonNullOptions = getNonNullOptions(type);
|
|
955
978
|
if (sdkType === undefined) {
|
|
956
979
|
throw Error("Should not have an empty union");
|
|
@@ -971,7 +994,7 @@ function emitUnion(context, type, usage) {
|
|
|
971
994
|
? normalizeName(unionName, NameType.Interface)
|
|
972
995
|
: undefined;
|
|
973
996
|
return {
|
|
974
|
-
nullable:
|
|
997
|
+
nullable: isNull,
|
|
975
998
|
name: unionTypeName,
|
|
976
999
|
description: `Type of ${unionTypeName}`,
|
|
977
1000
|
internal: true,
|
|
@@ -983,7 +1006,8 @@ function emitUnion(context, type, usage) {
|
|
|
983
1006
|
alias: unionName === "" || unionName === undefined ? undefined : unionName,
|
|
984
1007
|
aliasType: unionName === "" || unionName === undefined
|
|
985
1008
|
? undefined
|
|
986
|
-
: variantTypes.map((x) => getTypeName(x).name).join(" | ")
|
|
1009
|
+
: variantTypes.map((x) => getTypeName(x).name).join(" | "),
|
|
1010
|
+
tcgcType: sdkType
|
|
987
1011
|
};
|
|
988
1012
|
}
|
|
989
1013
|
else if (sdkType.kind === "enum") {
|
|
@@ -997,13 +1021,14 @@ function emitUnion(context, type, usage) {
|
|
|
997
1021
|
: undefined;
|
|
998
1022
|
return {
|
|
999
1023
|
name: typeName,
|
|
1000
|
-
nullable:
|
|
1024
|
+
nullable: isNull,
|
|
1001
1025
|
description: sdkType.description || `Type of ${typeName}`,
|
|
1002
1026
|
internal: true,
|
|
1003
1027
|
type: sdkType.kind,
|
|
1004
1028
|
valueType: emitSimpleType(context, sdkType.valueType),
|
|
1005
1029
|
values: sdkType.values.map((x) => emitEnumMember(context, x)),
|
|
1006
1030
|
isFixed: sdkType.isFixed,
|
|
1031
|
+
isNonExhaustive: (_c = (_b = context.rlcOptions) === null || _b === void 0 ? void 0 : _b.experimentalExtensibleEnums) !== null && _c !== void 0 ? _c : false,
|
|
1007
1032
|
xmlMetadata: {},
|
|
1008
1033
|
usage
|
|
1009
1034
|
};
|
|
@@ -1011,13 +1036,13 @@ function emitUnion(context, type, usage) {
|
|
|
1011
1036
|
else if (nonNullOptions.length === 1 && nonNullOptions[0]) {
|
|
1012
1037
|
return {
|
|
1013
1038
|
...emitType(context, nonNullOptions[0], usage),
|
|
1014
|
-
nullable:
|
|
1039
|
+
nullable: isNull
|
|
1015
1040
|
};
|
|
1016
1041
|
}
|
|
1017
1042
|
else {
|
|
1018
1043
|
return {
|
|
1019
1044
|
...emitType(context, sdkType.__raw, usage),
|
|
1020
|
-
nullable:
|
|
1045
|
+
nullable: isNull
|
|
1021
1046
|
};
|
|
1022
1047
|
}
|
|
1023
1048
|
}
|
|
@@ -1049,7 +1074,7 @@ function emitSimpleType(context, type) {
|
|
|
1049
1074
|
sdkType = type;
|
|
1050
1075
|
}
|
|
1051
1076
|
return {
|
|
1052
|
-
nullable: sdkType.
|
|
1077
|
+
nullable: isNullType(sdkType.__raw),
|
|
1053
1078
|
type: sdkType.kind === "string" ? "string" : "number", // TODO: handle other types
|
|
1054
1079
|
doc: "",
|
|
1055
1080
|
apiVersions: [],
|
|
@@ -1358,7 +1383,7 @@ function getNamespaces(context) {
|
|
|
1358
1383
|
return namespaces;
|
|
1359
1384
|
}
|
|
1360
1385
|
export function emitCodeModel(dpgContext, rlcModelsMap, modularSourcesRoot, project, options = { casing: "snake" }) {
|
|
1361
|
-
var _a, _b, _c, _d, _e;
|
|
1386
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1362
1387
|
CASING = (_a = options.casing) !== null && _a !== void 0 ? _a : CASING;
|
|
1363
1388
|
const clientNamespaceString = (_b = getClientNamespaceString(dpgContext)) === null || _b === void 0 ? void 0 : _b.toLowerCase();
|
|
1364
1389
|
// Get types
|
|
@@ -1366,14 +1391,15 @@ export function emitCodeModel(dpgContext, rlcModelsMap, modularSourcesRoot, proj
|
|
|
1366
1391
|
options: (_c = dpgContext.rlcOptions) !== null && _c !== void 0 ? _c : {},
|
|
1367
1392
|
modularOptions: {
|
|
1368
1393
|
sourceRoot: modularSourcesRoot,
|
|
1369
|
-
compatibilityMode: !!((_d = dpgContext.rlcOptions) === null || _d === void 0 ? void 0 : _d.compatibilityMode)
|
|
1394
|
+
compatibilityMode: !!((_d = dpgContext.rlcOptions) === null || _d === void 0 ? void 0 : _d.compatibilityMode),
|
|
1395
|
+
experimentalExtensibleEnums: !!((_e = dpgContext.rlcOptions) === null || _e === void 0 ? void 0 : _e.experimentalExtensibleEnums)
|
|
1370
1396
|
},
|
|
1371
1397
|
namespace: clientNamespaceString,
|
|
1372
1398
|
subnamespaceToClients: {},
|
|
1373
1399
|
clients: [],
|
|
1374
1400
|
types: [],
|
|
1375
1401
|
project,
|
|
1376
|
-
runtimeImports: buildRuntimeImports((
|
|
1402
|
+
runtimeImports: buildRuntimeImports((_f = dpgContext.rlcOptions) === null || _f === void 0 ? void 0 : _f.flavor)
|
|
1377
1403
|
};
|
|
1378
1404
|
typesMap.clear();
|
|
1379
1405
|
simpleTypesMap.clear();
|