@azure-tools/typespec-ts 0.31.0 → 0.32.0
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 +25 -7
- package/README.md +8 -0
- package/dist/src/contextManager.d.ts +2 -0
- package/dist/src/contextManager.d.ts.map +1 -1
- package/dist/src/contextManager.js.map +1 -1
- package/dist/src/framework/dependency.d.ts +69 -0
- package/dist/src/framework/dependency.d.ts.map +1 -0
- package/dist/src/framework/dependency.js +2 -0
- package/dist/src/framework/dependency.js.map +1 -0
- package/dist/src/framework/hooks/binder.d.ts +8 -2
- package/dist/src/framework/hooks/binder.d.ts.map +1 -1
- package/dist/src/framework/hooks/binder.js +107 -20
- package/dist/src/framework/hooks/binder.js.map +1 -1
- package/dist/src/framework/hooks/useDependencies.d.ts +4 -0
- package/dist/src/framework/hooks/useDependencies.d.ts.map +1 -0
- package/dist/src/framework/hooks/useDependencies.js +13 -0
- package/dist/src/framework/hooks/useDependencies.js.map +1 -0
- package/dist/src/framework/load-static-helpers.d.ts +16 -0
- package/dist/src/framework/load-static-helpers.d.ts.map +1 -0
- package/dist/src/framework/load-static-helpers.js +93 -0
- package/dist/src/framework/load-static-helpers.js.map +1 -0
- package/dist/src/framework/reference.d.ts +1 -1
- package/dist/src/framework/reference.d.ts.map +1 -1
- package/dist/src/framework/reference.js +16 -2
- package/dist/src/framework/reference.js.map +1 -1
- package/dist/src/framework/sample.js +1 -1
- package/dist/src/framework/sample.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +113 -79
- package/dist/src/index.js.map +1 -1
- package/dist/src/lib.d.ts +10 -1
- package/dist/src/lib.d.ts.map +1 -1
- package/dist/src/lib.js +8 -1
- package/dist/src/lib.js.map +1 -1
- package/dist/src/modular/buildClassicalClient.d.ts.map +1 -1
- package/dist/src/modular/buildClassicalClient.js +12 -9
- package/dist/src/modular/buildClassicalClient.js.map +1 -1
- package/dist/src/modular/buildClassicalOperationGroups.d.ts.map +1 -1
- package/dist/src/modular/buildClassicalOperationGroups.js +1 -11
- package/dist/src/modular/buildClassicalOperationGroups.js.map +1 -1
- package/dist/src/modular/buildClientContext.d.ts.map +1 -1
- package/dist/src/modular/buildClientContext.js +73 -52
- package/dist/src/modular/buildClientContext.js.map +1 -1
- package/dist/src/modular/buildCodeModel.d.ts +1 -1
- package/dist/src/modular/buildCodeModel.d.ts.map +1 -1
- package/dist/src/modular/buildCodeModel.js +36 -62
- package/dist/src/modular/buildCodeModel.js.map +1 -1
- package/dist/src/modular/buildHelperSerializers.d.ts.map +1 -1
- package/dist/src/modular/buildHelperSerializers.js.map +1 -1
- package/dist/src/modular/buildOperations.d.ts +1 -3
- package/dist/src/modular/buildOperations.d.ts.map +1 -1
- package/dist/src/modular/buildOperations.js +9 -69
- package/dist/src/modular/buildOperations.js.map +1 -1
- package/dist/src/modular/buildRestorePoller.d.ts +3 -0
- package/dist/src/modular/buildRestorePoller.d.ts.map +1 -0
- package/dist/src/modular/buildRestorePoller.js +203 -0
- package/dist/src/modular/buildRestorePoller.js.map +1 -0
- package/dist/src/modular/buildRootIndex.d.ts.map +1 -1
- package/dist/src/modular/buildRootIndex.js +37 -0
- package/dist/src/modular/buildRootIndex.js.map +1 -1
- package/dist/src/modular/emitLoggerFile.d.ts +4 -0
- package/dist/src/modular/emitLoggerFile.d.ts.map +1 -0
- package/dist/src/modular/emitLoggerFile.js +16 -0
- package/dist/src/modular/emitLoggerFile.js.map +1 -0
- package/dist/src/modular/emitModels.d.ts.map +1 -1
- package/dist/src/modular/emitModels.js +0 -5
- package/dist/src/modular/emitModels.js.map +1 -1
- package/dist/src/modular/external-dependencies.d.ts +26 -0
- package/dist/src/modular/external-dependencies.d.ts.map +1 -0
- package/dist/src/modular/external-dependencies.js +137 -0
- package/dist/src/modular/external-dependencies.js.map +1 -0
- package/dist/src/modular/helpers/clientHelpers.d.ts +13 -6
- package/dist/src/modular/helpers/clientHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/clientHelpers.js +92 -7
- package/dist/src/modular/helpers/clientHelpers.js.map +1 -1
- package/dist/src/modular/helpers/operationHelpers.d.ts +6 -1
- package/dist/src/modular/helpers/operationHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/operationHelpers.js +43 -69
- package/dist/src/modular/helpers/operationHelpers.js.map +1 -1
- package/dist/src/modular/helpers/typeHelpers.d.ts +1 -0
- package/dist/src/modular/helpers/typeHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/typeHelpers.js +6 -0
- package/dist/src/modular/helpers/typeHelpers.js.map +1 -1
- package/dist/src/modular/interfaces.d.ts +1 -0
- package/dist/src/modular/interfaces.d.ts.map +1 -1
- package/dist/src/modular/serialization/buildSerializerFunction.d.ts.map +1 -1
- package/dist/src/modular/serialization/buildSerializerFunction.js +2 -20
- package/dist/src/modular/serialization/buildSerializerFunction.js.map +1 -1
- package/dist/src/modular/static-helpers-metadata.d.ts +72 -0
- package/dist/src/modular/static-helpers-metadata.d.ts.map +1 -0
- package/dist/src/modular/static-helpers-metadata.js +72 -0
- package/dist/src/modular/static-helpers-metadata.js.map +1 -0
- package/dist/src/transform/transfromRLCOptions.d.ts.map +1 -1
- package/dist/src/transform/transfromRLCOptions.js +56 -49
- package/dist/src/transform/transfromRLCOptions.js.map +1 -1
- package/dist/src/utils/credentialUtils.d.ts +10 -0
- package/dist/src/utils/credentialUtils.d.ts.map +1 -0
- package/dist/src/utils/credentialUtils.js +37 -0
- package/dist/src/utils/credentialUtils.js.map +1 -0
- package/dist/src/utils/dirname.d.ts +9 -0
- package/dist/src/utils/dirname.d.ts.map +1 -0
- package/dist/src/utils/dirname.js +12 -0
- package/dist/src/utils/dirname.js.map +1 -0
- package/dist/src/utils/emitUtil.d.ts.map +1 -1
- package/dist/src/utils/emitUtil.js +3 -5
- package/dist/src/utils/emitUtil.js.map +1 -1
- package/dist/src/utils/modelUtils.d.ts +1 -1
- package/dist/src/utils/modelUtils.js +3 -2
- package/dist/src/utils/modelUtils.js.map +1 -1
- package/dist/src/utils/operationUtil.d.ts.map +1 -1
- package/dist/src/utils/operationUtil.js +20 -2
- package/dist/src/utils/operationUtil.js.map +1 -1
- package/dist/src/utils/resolve-project-root.d.ts +7 -0
- package/dist/src/utils/resolve-project-root.d.ts.map +1 -0
- package/dist/src/utils/resolve-project-root.js +22 -0
- package/dist/src/utils/resolve-project-root.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +29 -25
- package/src/contextManager.ts +2 -0
- package/src/framework/dependency.ts +56 -0
- package/src/framework/hooks/binder.ts +144 -27
- package/src/framework/hooks/useDependencies.ts +18 -0
- package/src/framework/load-static-helpers.ts +174 -0
- package/src/framework/reference.ts +27 -3
- package/src/framework/sample.ts +1 -1
- package/src/index.ts +154 -113
- package/src/lib.ts +8 -1
- package/src/modular/buildClassicalClient.ts +14 -12
- package/src/modular/buildClassicalOperationGroups.ts +1 -24
- package/src/modular/buildClientContext.ts +93 -63
- package/src/modular/buildCodeModel.ts +93 -128
- package/src/modular/buildHelperSerializers.ts +1 -0
- package/src/modular/buildOperations.ts +9 -110
- package/src/modular/buildRestorePoller.ts +239 -0
- package/src/modular/buildRootIndex.ts +68 -0
- package/src/modular/emitLoggerFile.ts +28 -0
- package/src/modular/emitModels.ts +0 -8
- package/src/modular/external-dependencies.ts +140 -0
- package/src/modular/helpers/clientHelpers.ts +148 -14
- package/src/modular/helpers/operationHelpers.ts +72 -109
- package/src/modular/helpers/typeHelpers.ts +8 -0
- package/src/modular/interfaces.ts +1 -0
- package/src/modular/serialization/buildSerializerFunction.ts +3 -33
- package/src/modular/static-helpers-metadata.ts +73 -0
- package/src/transform/transfromRLCOptions.ts +61 -53
- package/src/utils/credentialUtils.ts +41 -0
- package/src/utils/dirname.ts +12 -0
- package/src/utils/emitUtil.ts +3 -2
- package/src/utils/modelUtils.ts +4 -4
- package/src/utils/operationUtil.ts +25 -2
- package/src/utils/resolve-project-root.ts +28 -0
- package/static/static-helpers/pagingHelpers.ts +274 -0
- package/static/static-helpers/pollingHelpers.ts +137 -0
- package/static/static-helpers/serialization/build-csv-collection.ts +6 -0
- package/static/static-helpers/serialization/build-multi-collection.ts +13 -0
- package/static/static-helpers/serialization/build-pipe-collection.ts +3 -0
- package/static/static-helpers/serialization/build-ssv-collection.ts +3 -0
- package/static/static-helpers/serialization/build-tsv-collection.ts +3 -0
- package/dist/src/modular/buildLroFiles.d.ts +0 -24
- package/dist/src/modular/buildLroFiles.d.ts.map +0 -1
- package/dist/src/modular/buildLroFiles.js +0 -393
- package/dist/src/modular/buildLroFiles.js.map +0 -1
- package/dist/src/modular/buildPagingFiles.d.ts +0 -4
- package/dist/src/modular/buildPagingFiles.d.ts.map +0 -1
- package/dist/src/modular/buildPagingFiles.js +0 -333
- package/dist/src/modular/buildPagingFiles.js.map +0 -1
- package/src/modular/buildLroFiles.ts +0 -429
- package/src/modular/buildPagingFiles.ts +0 -356
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,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;I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C,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 +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":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAYpD,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,CAkJZ"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { getImportSpecifier, NameType, normalizeName } from "@azure-tools/rlc-common";
|
|
2
|
-
import { isRLCMultiEndpoint } from "../utils/clientUtils.js";
|
|
1
|
+
import { getImportSpecifier, isAzurePackage, NameType, normalizeName } from "@azure-tools/rlc-common";
|
|
3
2
|
import { importModels } from "./buildOperations.js";
|
|
4
|
-
import {
|
|
3
|
+
import { buildGetClientCredentialParam, buildGetClientEndpointParam, buildGetClientOptionsParam, getClientParameters, importCredential } from "./helpers/clientHelpers.js";
|
|
5
4
|
import { getDocsFromDescription } from "./helpers/docsHelpers.js";
|
|
6
5
|
import { getClientName } from "./helpers/namingHelpers.js";
|
|
7
6
|
import { getType } from "./helpers/typeHelpers.js";
|
|
@@ -14,12 +13,16 @@ export function buildClientContext(client, dpgContext, codeModel) {
|
|
|
14
13
|
const params = getClientParameters(client, dpgContext);
|
|
15
14
|
const srcPath = codeModel.modularOptions.sourceRoot;
|
|
16
15
|
const clientContextFile = codeModel.project.createSourceFile(`${srcPath}/${subfolder && subfolder !== "" ? subfolder + "/" : ""}/api/${normalizeName(name, NameType.File)}Context.ts`);
|
|
17
|
-
let factoryFunction;
|
|
18
16
|
importCredential(codeModel.runtimeImports, clientContextFile);
|
|
19
17
|
importModels(srcPath, clientContextFile, codeModel.project, subfolder);
|
|
20
18
|
clientContextFile.addImportDeclaration({
|
|
21
19
|
moduleSpecifier: getImportSpecifier("restClient", codeModel.runtimeImports),
|
|
22
|
-
namedImports: ["ClientOptions"]
|
|
20
|
+
namedImports: ["ClientOptions", "Client", "getClient"]
|
|
21
|
+
});
|
|
22
|
+
clientContextFile.addInterface({
|
|
23
|
+
isExported: true,
|
|
24
|
+
name: `${client.rlcClientName}`,
|
|
25
|
+
extends: ["Client"]
|
|
23
26
|
});
|
|
24
27
|
clientContextFile.addInterface({
|
|
25
28
|
name: `${name}ClientOptionalParams`,
|
|
@@ -39,64 +42,82 @@ export function buildClientContext(client, dpgContext, codeModel) {
|
|
|
39
42
|
}),
|
|
40
43
|
docs: ["Optional parameters for the client."]
|
|
41
44
|
});
|
|
42
|
-
|
|
45
|
+
// TODO use binder here
|
|
46
|
+
// (for now) now logger for unbranded pkgs
|
|
47
|
+
if (isAzurePackage(codeModel)) {
|
|
43
48
|
clientContextFile.addImportDeclaration({
|
|
44
|
-
moduleSpecifier:
|
|
45
|
-
namedImports: [
|
|
46
|
-
});
|
|
47
|
-
clientContextFile.addExportDeclaration({
|
|
48
|
-
moduleSpecifier: `../../rest/${subfolder}/index.js`,
|
|
49
|
-
namedExports: [`Client`]
|
|
50
|
-
});
|
|
51
|
-
factoryFunction = clientContextFile.addFunction({
|
|
52
|
-
docs: getDocsFromDescription(description),
|
|
53
|
-
name: `create${name}`,
|
|
54
|
-
returnType: `Client.${client.name}`,
|
|
55
|
-
parameters: params,
|
|
56
|
-
isExported: true
|
|
49
|
+
moduleSpecifier: codeModel.clients.length > 1 ? "../../logger.js" : "../logger.js",
|
|
50
|
+
namedImports: ["logger"]
|
|
57
51
|
});
|
|
58
52
|
}
|
|
59
|
-
|
|
60
|
-
|
|
53
|
+
const factoryFunction = clientContextFile.addFunction({
|
|
54
|
+
docs: getDocsFromDescription(description),
|
|
55
|
+
name: `create${name}`,
|
|
56
|
+
returnType: `${client.rlcClientName}`,
|
|
57
|
+
parameters: params,
|
|
58
|
+
isExported: true
|
|
59
|
+
});
|
|
60
|
+
const endpointParam = buildGetClientEndpointParam(factoryFunction, client);
|
|
61
|
+
const credentialParam = buildGetClientCredentialParam(client, codeModel);
|
|
62
|
+
const optionsParam = buildGetClientOptionsParam(factoryFunction, codeModel, endpointParam);
|
|
63
|
+
factoryFunction.addStatements(`const clientContext = getClient(${endpointParam}, ${credentialParam}, ${optionsParam});`);
|
|
64
|
+
const { customHttpAuthHeaderName, customHttpAuthSharedKeyPrefix } = codeModel.options;
|
|
65
|
+
if (customHttpAuthHeaderName && customHttpAuthSharedKeyPrefix) {
|
|
61
66
|
clientContextFile.addImportDeclaration({
|
|
62
|
-
moduleSpecifier:
|
|
63
|
-
namedImports: [
|
|
64
|
-
});
|
|
65
|
-
clientContextFile.addExportDeclaration({
|
|
66
|
-
moduleSpecifier: `${subfolder && subfolder !== "" ? "../" : ""}../rest/index.js`,
|
|
67
|
-
namedExports: [`${rlcClientName}`]
|
|
67
|
+
moduleSpecifier: getImportSpecifier("coreAuth", codeModel.runtimeImports),
|
|
68
|
+
namedImports: ["isKeyCredential"]
|
|
68
69
|
});
|
|
69
|
-
factoryFunction
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
70
|
+
factoryFunction.addStatements(`
|
|
71
|
+
if(isKeyCredential(credential)) {
|
|
72
|
+
clientContext.pipeline.addPolicy({
|
|
73
|
+
name: "customKeyCredentialPolicy",
|
|
74
|
+
sendRequest(request, next) {
|
|
75
|
+
request.headers.set("${customHttpAuthHeaderName}", "${customHttpAuthSharedKeyPrefix} " + credential.key);
|
|
76
|
+
return next(request);
|
|
77
|
+
}
|
|
75
78
|
});
|
|
79
|
+
}
|
|
80
|
+
`);
|
|
76
81
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
]);
|
|
84
|
-
if (isRLCMultiEndpoint(dpgContext)) {
|
|
85
|
-
clientContextFile.addImportDeclarations([
|
|
86
|
-
{
|
|
87
|
-
moduleSpecifier: `../../rest/${subfolder}/index.js`,
|
|
88
|
-
namedImports: ["createClient as getClient"]
|
|
82
|
+
let apiVersionPolicyStatement = `clientContext.pipeline.removePolicy({ name: "ApiVersionPolicy" });`;
|
|
83
|
+
if (dpgContext.hasApiVersionInClient) {
|
|
84
|
+
const apiVersionParam = client.parameters.find((x) => x.isApiVersion);
|
|
85
|
+
if ((apiVersionParam === null || apiVersionParam === void 0 ? void 0 : apiVersionParam.location) === "query") {
|
|
86
|
+
if (apiVersionParam.clientDefaultValue) {
|
|
87
|
+
apiVersionPolicyStatement += `const ${apiVersionParam.clientName} = options.${apiVersionParam.clientName} ?? "${apiVersionParam.clientDefaultValue}";`;
|
|
89
88
|
}
|
|
90
|
-
|
|
89
|
+
apiVersionPolicyStatement += `
|
|
90
|
+
clientContext.pipeline.addPolicy({
|
|
91
|
+
name: 'ClientApiVersionPolicy',
|
|
92
|
+
sendRequest: (req, next) => {
|
|
93
|
+
// Use the apiVersion defined in request url directly
|
|
94
|
+
// Append one if there is no apiVersion and we have one at client options
|
|
95
|
+
const url = new URL(req.url);
|
|
96
|
+
if (!url.searchParams.get("api-version")) {
|
|
97
|
+
req.url = \`\${req.url}\${
|
|
98
|
+
Array.from(url.searchParams.keys()).length > 0 ? "&" : "?"
|
|
99
|
+
}api-version=\${${apiVersionParam.clientName}}\`;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return next(req);
|
|
103
|
+
},
|
|
104
|
+
});`;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
else if (isAzurePackage(codeModel)) {
|
|
108
|
+
apiVersionPolicyStatement += `
|
|
109
|
+
if (options.apiVersion) {
|
|
110
|
+
logger.warning("This client does not support client api-version, please change it at the operation level");
|
|
111
|
+
}`;
|
|
91
112
|
}
|
|
92
113
|
else {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
]);
|
|
114
|
+
apiVersionPolicyStatement += `
|
|
115
|
+
if (options.apiVersion) {
|
|
116
|
+
console.warn("This client does not support client api-version, please change it at the operation level");
|
|
117
|
+
}`;
|
|
99
118
|
}
|
|
119
|
+
factoryFunction.addStatements(apiVersionPolicyStatement);
|
|
120
|
+
factoryFunction.addStatements("return clientContext;");
|
|
100
121
|
clientContextFile.fixMissingImports({}, { importModuleSpecifierEnding: "js" });
|
|
101
122
|
clientContextFile.fixUnusedIdentifiers();
|
|
102
123
|
return clientContextFile;
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
1
|
+
{"version":3,"file":"buildClientContext.js","sourceRoot":"","sources":["../../../src/modular/buildClientContext.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,QAAQ,EACR,aAAa,EACd,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EACL,6BAA6B,EAC7B,2BAA2B,EAC3B,0BAA0B,EAC1B,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,sBA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AAc,CAAC,SAAS,CAAC,EAAE,CAAC;QACrC,yBAAyB,IAAI;;;QAGzB,CAAC;IACP,CAAC;SAAM,CAAC;QACN,yBAAyB,IAAI;;;QAGzB,CAAC;IACP,CAAC;IACD,eAAe,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IAEzD,eAAe,CAAC,aAAa,CAAC,uBAAuB,CAAC,CAAC;IAEvD,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";
|
|
1
2
|
import { RLCModel } from "@azure-tools/rlc-common";
|
|
2
3
|
import { Project } from "ts-morph";
|
|
3
4
|
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":"AAoCA,OAAO,EAKL,gBAAgB,EAKjB,MAAM,uBAAuB,CAAC;AAY/B,OAAO,EAEL,QAAQ,EAKT,MAAM,yBAAyB,CAAC;AA2CjC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AA6BpD,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;AA+oDD,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,CA6ClB"}
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getLroMetadata, getPagedResult } from "@azure-tools/typespec-azure-core";
|
|
3
|
-
import { getAllModels, getClientNamespaceString, getClientType, getDefaultApiVersion, getHttpOperationWithCache, 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, isErrorModel, isNeverType, isNullType, isNumericType, isStringType, isTemplateDeclarationOrInstance, isType, isVoidType, listServices, UsageFlags } from "@typespec/compiler";
|
|
1
|
+
import { UsageFlags, getDiscriminator, getDoc, getEncode, getFriendlyName, getMaxItems, getMaxLength, getMaxValue, getMinItems, getMinLength, getMinValue, getPattern, getPropertyType, getSummary, getVisibility, isErrorModel, isNeverType, isNullType, isNumericType, isStringType, isTemplateDeclarationOrInstance, isType, isVoidType, listServices } from "@typespec/compiler";
|
|
5
2
|
import { getAuthentication, getServers, isSharedRoute } from "@typespec/http";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { camelToSnakeCase, toCamelCase } from "../utils/casingUtils.js";
|
|
3
|
+
import { NameType, buildRuntimeImports, getClientName, isAzurePackage, normalizeName } from "@azure-tools/rlc-common";
|
|
4
|
+
import { getAllModels, getClientNamespaceString, getClientType, getDefaultApiVersion, getHttpOperationWithCache, getLibraryName, getSdkUnion, getWireName, isApiVersion, listClients, listOperationGroups, listOperationsInOperationGroup } from "@azure-tools/typespec-client-generator-core";
|
|
9
5
|
import { buildCoreTypeInfo, getBodyType, getDefaultApiVersionString, getEffectiveSchemaType, isAzureCoreErrorType, isSchemaProperty } from "../utils/modelUtils.js";
|
|
10
|
-
import {
|
|
6
|
+
import { camelToSnakeCase, toCamelCase } from "../utils/casingUtils.js";
|
|
11
7
|
import { extractPagedMetadataNested, getOperationGroupName, getOperationName, isBinaryPayload, isIgnoredHeaderParam, isLongRunningOperation, parseItemName, parseNextLinkName } from "../utils/operationUtil.js";
|
|
12
|
-
import {
|
|
8
|
+
import { getLroMetadata, getPagedResult } from "@azure-tools/typespec-azure-core";
|
|
9
|
+
import { getAddedOnVersions } from "@typespec/versioning";
|
|
10
|
+
import { getModelNamespaceName } from "../utils/namespaceUtils.js";
|
|
13
11
|
import { getType as getTypeName } from "./helpers/typeHelpers.js";
|
|
12
|
+
import { isModelWithAdditionalProperties } from "./emitModels.js";
|
|
13
|
+
import { reportDiagnostic } from "../lib.js";
|
|
14
14
|
import { useContext } from "../contextManager.js";
|
|
15
|
+
import { getSupportedHttpAuth } from "../utils/credentialUtils.js";
|
|
15
16
|
let CASING = "snake";
|
|
16
17
|
function applyCasing(name, options = { casing: "snake" }) {
|
|
17
18
|
if (options.casing === "camel") {
|
|
@@ -282,7 +283,7 @@ function emitBodyParameter(context, httpOperation) {
|
|
|
282
283
|
return undefined;
|
|
283
284
|
}
|
|
284
285
|
function emitParameter(context, parameter, implementation) {
|
|
285
|
-
var _a;
|
|
286
|
+
var _a, _b;
|
|
286
287
|
const base = emitParamBase(context, parameter.param);
|
|
287
288
|
let type = getType(context, parameter.param.type, {
|
|
288
289
|
usage: UsageFlags.Input
|
|
@@ -321,6 +322,12 @@ function emitParameter(context, parameter, implementation) {
|
|
|
321
322
|
paramMap.optional = true;
|
|
322
323
|
}
|
|
323
324
|
}
|
|
325
|
+
if (clientDefaultValue === undefined &&
|
|
326
|
+
paramMap.location === "endpointPath" &&
|
|
327
|
+
((_b = parameter.param.defaultValue) === null || _b === void 0 ? void 0 : _b.valueKind) === "StringValue") {
|
|
328
|
+
// For endpoint path params, treat the default value as a client default.
|
|
329
|
+
clientDefaultValue = parameter.param.defaultValue.value;
|
|
330
|
+
}
|
|
324
331
|
return { clientDefaultValue, ...base, ...paramMap };
|
|
325
332
|
}
|
|
326
333
|
function emitFlattenedParameter(bodyParameter, property) {
|
|
@@ -414,8 +421,7 @@ function emitResponse(context, operation, response, innerResponse) {
|
|
|
414
421
|
}
|
|
415
422
|
}
|
|
416
423
|
function emitOperation(context, operation, operationGroupName, rlcModels, hierarchies) {
|
|
417
|
-
|
|
418
|
-
const isAzureFlavor = ((_a = rlcModels.options) === null || _a === void 0 ? void 0 : _a.flavor) === "azure";
|
|
424
|
+
const isAzureFlavor = isAzurePackage(rlcModels);
|
|
419
425
|
const emittedOperation = emitBasicOperation(context, operation, operationGroupName, rlcModels, hierarchies);
|
|
420
426
|
// Skip to extract paging and lro information for non-branded clients.
|
|
421
427
|
if (!isAzureFlavor) {
|
|
@@ -883,14 +889,15 @@ function applyEncoding(program, typespecType, target = {}) {
|
|
|
883
889
|
return target;
|
|
884
890
|
}
|
|
885
891
|
function mergeFormatAndEncoding(format, encoding, encodeAsFormat) {
|
|
892
|
+
var _a, _b;
|
|
886
893
|
switch (format) {
|
|
887
894
|
case undefined:
|
|
888
|
-
return encodeAsFormat !== null && encodeAsFormat !== void 0 ? encodeAsFormat : encoding;
|
|
895
|
+
return (_a = encodeAsFormat !== null && encodeAsFormat !== void 0 ? encodeAsFormat : encoding) !== null && _a !== void 0 ? _a : format;
|
|
889
896
|
case "date-time":
|
|
890
897
|
return encoding;
|
|
891
898
|
case "duration":
|
|
892
899
|
default:
|
|
893
|
-
return encodeAsFormat !== null && encodeAsFormat !== void 0 ? encodeAsFormat : encoding;
|
|
900
|
+
return (_b = encodeAsFormat !== null && encodeAsFormat !== void 0 ? encodeAsFormat : encoding) !== null && _b !== void 0 ? _b : format;
|
|
894
901
|
}
|
|
895
902
|
}
|
|
896
903
|
function applyIntrinsicDecorators(program, type, result) {
|
|
@@ -1034,7 +1041,7 @@ function emitUnion(context, type, usage) {
|
|
|
1034
1041
|
description: sdkType.description || `Type of ${typeName}`,
|
|
1035
1042
|
internal: true,
|
|
1036
1043
|
type: sdkType.kind,
|
|
1037
|
-
valueType: emitSimpleType(
|
|
1044
|
+
valueType: emitSimpleType(sdkType.valueType),
|
|
1038
1045
|
values: sdkType.values.map((x) => emitEnumMember(context, x)),
|
|
1039
1046
|
isFixed: sdkType.isFixed,
|
|
1040
1047
|
isNonExhaustive: (_c = (_b = context.rlcOptions) === null || _b === void 0 ? void 0 : _b.experimentalExtensibleEnums) !== null && _c !== void 0 ? _c : false,
|
|
@@ -1074,17 +1081,10 @@ function emitEnumMember(context, member) {
|
|
|
1074
1081
|
isConstant: true
|
|
1075
1082
|
};
|
|
1076
1083
|
}
|
|
1077
|
-
function emitSimpleType(
|
|
1078
|
-
let sdkType;
|
|
1079
|
-
if (type.kind === "Scalar" || type.kind === "Intrinsic") {
|
|
1080
|
-
sdkType = getSdkBuiltInType(context, type);
|
|
1081
|
-
}
|
|
1082
|
-
else {
|
|
1083
|
-
sdkType = type;
|
|
1084
|
-
}
|
|
1084
|
+
function emitSimpleType(type) {
|
|
1085
1085
|
return {
|
|
1086
|
-
nullable: isNullType(
|
|
1087
|
-
type:
|
|
1086
|
+
nullable: isNullType(type.__raw),
|
|
1087
|
+
type: type.kind === "string" ? "string" : "number", // TODO: handle other types
|
|
1088
1088
|
doc: "",
|
|
1089
1089
|
apiVersions: [],
|
|
1090
1090
|
sdkDefaultValue: undefined,
|
|
@@ -1163,7 +1163,7 @@ function emitOperationGroups(context, client, rlcModels) {
|
|
|
1163
1163
|
});
|
|
1164
1164
|
if (((_f = context.rlcOptions) === null || _f === void 0 ? void 0 : _f.hierarchyClient) === false &&
|
|
1165
1165
|
((_g = context.rlcOptions) === null || _g === void 0 ? void 0 : _g.enableOperationGroup)) {
|
|
1166
|
-
|
|
1166
|
+
appendOperationGroupPrefix(operationGroups);
|
|
1167
1167
|
}
|
|
1168
1168
|
return operationGroups;
|
|
1169
1169
|
}
|
|
@@ -1188,23 +1188,10 @@ function addHierarchyOperationGroup(operations, groupMapping) {
|
|
|
1188
1188
|
}
|
|
1189
1189
|
return [];
|
|
1190
1190
|
}
|
|
1191
|
-
function
|
|
1191
|
+
function appendOperationGroupPrefix(operationGroups) {
|
|
1192
1192
|
if (operationGroups.length < 2) {
|
|
1193
1193
|
return;
|
|
1194
1194
|
}
|
|
1195
|
-
const nameSet = new Set();
|
|
1196
|
-
const hasConflict = operationGroups.some((g) => g.operations.some((op) => {
|
|
1197
|
-
if (nameSet.has(op.name)) {
|
|
1198
|
-
return true;
|
|
1199
|
-
}
|
|
1200
|
-
else {
|
|
1201
|
-
nameSet.add(op.name);
|
|
1202
|
-
return false;
|
|
1203
|
-
}
|
|
1204
|
-
}));
|
|
1205
|
-
if (!hasConflict) {
|
|
1206
|
-
return;
|
|
1207
|
-
}
|
|
1208
1195
|
// Append operation group prefix
|
|
1209
1196
|
operationGroups.forEach((g) => g.operations.forEach((op) => {
|
|
1210
1197
|
op.oriName = op.name;
|
|
@@ -1275,14 +1262,12 @@ function emitCredentialParam(context, namespace) {
|
|
|
1275
1262
|
const auth = getAuthentication(context.program, namespace);
|
|
1276
1263
|
if (auth) {
|
|
1277
1264
|
const credential_types = [];
|
|
1278
|
-
for (const
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
credential_types.push(type);
|
|
1285
|
-
}
|
|
1265
|
+
for (const scheme of getSupportedHttpAuth(context.program, auth)) {
|
|
1266
|
+
const type = {
|
|
1267
|
+
kind: "Credential",
|
|
1268
|
+
scheme: scheme
|
|
1269
|
+
};
|
|
1270
|
+
credential_types.push(type);
|
|
1286
1271
|
}
|
|
1287
1272
|
if (credential_types.length > 0 &&
|
|
1288
1273
|
((_a = context.rlcOptions) === null || _a === void 0 ? void 0 : _a.addCredentials) !== false) {
|
|
@@ -1327,17 +1312,14 @@ function getMethodApiVersionParameter() {
|
|
|
1327
1312
|
};
|
|
1328
1313
|
}
|
|
1329
1314
|
}
|
|
1330
|
-
function emitClients(context,
|
|
1315
|
+
function emitClients(context, rlcModelsMap) {
|
|
1331
1316
|
var _a;
|
|
1332
1317
|
const program = context.program;
|
|
1333
1318
|
const clients = listClients(context);
|
|
1334
1319
|
const retval = [];
|
|
1335
1320
|
methodApiVersionParam = undefined;
|
|
1336
1321
|
for (const client of clients) {
|
|
1337
|
-
const clientName =
|
|
1338
|
-
if (getNamespace(context, client.name) !== namespace) {
|
|
1339
|
-
continue;
|
|
1340
|
-
}
|
|
1322
|
+
const clientName = client.name.replace("Client", "");
|
|
1341
1323
|
const server = getServerHelper(program, client.service);
|
|
1342
1324
|
const rlcModels = rlcModelsMap.get(client.service.name);
|
|
1343
1325
|
if (!rlcModels) {
|
|
@@ -1406,7 +1388,6 @@ export function emitCodeModel(dpgContext, rlcModelsMap, modularSourcesRoot, proj
|
|
|
1406
1388
|
experimentalExtensibleEnums: !!((_e = dpgContext.rlcOptions) === null || _e === void 0 ? void 0 : _e.experimentalExtensibleEnums)
|
|
1407
1389
|
},
|
|
1408
1390
|
namespace: clientNamespaceString,
|
|
1409
|
-
subnamespaceToClients: {},
|
|
1410
1391
|
clients: [],
|
|
1411
1392
|
types: [],
|
|
1412
1393
|
project,
|
|
@@ -1420,19 +1401,12 @@ export function emitCodeModel(dpgContext, rlcModelsMap, modularSourcesRoot, proj
|
|
|
1420
1401
|
}
|
|
1421
1402
|
for (const namespace of getNamespaces(dpgContext)) {
|
|
1422
1403
|
if (namespace === clientNamespaceString) {
|
|
1423
|
-
codeModel.clients = emitClients(dpgContext,
|
|
1404
|
+
codeModel.clients = emitClients(dpgContext, rlcModelsMap);
|
|
1424
1405
|
codeModel.clients.length > 1 &&
|
|
1425
1406
|
codeModel.clients.map((client) => {
|
|
1426
1407
|
client["subfolder"] = normalizeName(client.name.replace("Client", ""), NameType.File);
|
|
1427
1408
|
});
|
|
1428
1409
|
}
|
|
1429
|
-
else {
|
|
1430
|
-
codeModel["subnamespaceToClients"][namespace] = emitClients(dpgContext, namespace, rlcModelsMap);
|
|
1431
|
-
codeModel["subnamespaceToClients"][namespace].length > 1 &&
|
|
1432
|
-
codeModel["subnamespaceToClients"][namespace].map((client) => {
|
|
1433
|
-
client["subfolder"] = normalizeName(client.name, NameType.File);
|
|
1434
|
-
});
|
|
1435
|
-
}
|
|
1436
1410
|
}
|
|
1437
1411
|
codeModel["types"] = [
|
|
1438
1412
|
{ type: "string" },
|