@azure-tools/typespec-ts 0.15.0 → 0.16.0-alpha.20230918.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 +10 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +14 -17
- package/dist/src/index.js.map +1 -1
- package/dist/src/lib.d.ts.map +1 -1
- package/dist/src/lib.js +3 -3
- package/dist/src/lib.js.map +1 -1
- package/dist/src/modular/buildClassicalClient.d.ts +2 -3
- package/dist/src/modular/buildClassicalClient.d.ts.map +1 -1
- package/dist/src/modular/buildClassicalClient.js +26 -12
- package/dist/src/modular/buildClassicalClient.js.map +1 -1
- package/dist/src/modular/buildClientContext.d.ts +3 -3
- package/dist/src/modular/buildClientContext.d.ts.map +1 -1
- package/dist/src/modular/buildClientContext.js +5 -4
- package/dist/src/modular/buildClientContext.js.map +1 -1
- package/dist/src/modular/buildCodeModel.d.ts +3 -2
- package/dist/src/modular/buildCodeModel.d.ts.map +1 -1
- package/dist/src/modular/buildCodeModel.js +163 -69
- package/dist/src/modular/buildCodeModel.js.map +1 -1
- package/dist/src/modular/buildOperations.d.ts +2 -2
- package/dist/src/modular/buildOperations.d.ts.map +1 -1
- package/dist/src/modular/buildOperations.js +15 -8
- package/dist/src/modular/buildOperations.js.map +1 -1
- package/dist/src/modular/buildProjectFiles.js +2 -2
- package/dist/src/modular/buildProjectFiles.js.map +1 -1
- package/dist/src/modular/buildRootIndex.d.ts +4 -4
- package/dist/src/modular/buildRootIndex.d.ts.map +1 -1
- package/dist/src/modular/buildRootIndex.js +12 -5
- package/dist/src/modular/buildRootIndex.js.map +1 -1
- package/dist/src/modular/buildSubpathIndex.d.ts +2 -2
- package/dist/src/modular/buildSubpathIndex.d.ts.map +1 -1
- package/dist/src/modular/buildSubpathIndex.js +7 -4
- package/dist/src/modular/buildSubpathIndex.js.map +1 -1
- package/dist/src/modular/emitModels.d.ts +3 -3
- package/dist/src/modular/emitModels.d.ts.map +1 -1
- package/dist/src/modular/emitModels.js +28 -18
- package/dist/src/modular/emitModels.js.map +1 -1
- package/dist/src/modular/helpers/clientHelpers.js +1 -1
- package/dist/src/modular/helpers/clientHelpers.js.map +1 -1
- package/dist/src/modular/helpers/operationHelpers.d.ts +1 -1
- package/dist/src/modular/helpers/operationHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/operationHelpers.js +167 -88
- package/dist/src/modular/helpers/operationHelpers.js.map +1 -1
- package/dist/src/modular/helpers/typeHelpers.d.ts +2 -2
- package/dist/src/modular/helpers/typeHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/typeHelpers.js +13 -7
- package/dist/src/modular/helpers/typeHelpers.js.map +1 -1
- package/dist/src/modular/modularCodeModel.d.ts +11 -0
- package/dist/src/modular/modularCodeModel.d.ts.map +1 -1
- package/dist/src/transform/transformHelperFunctionDetails.js +3 -4
- package/dist/src/transform/transformHelperFunctionDetails.js.map +1 -1
- package/dist/src/transform/transformParameters.d.ts +0 -10
- package/dist/src/transform/transformParameters.d.ts.map +1 -1
- package/dist/src/transform/transformParameters.js +7 -51
- package/dist/src/transform/transformParameters.js.map +1 -1
- package/dist/src/transform/transformResponses.js +3 -4
- 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 +4 -8
- 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 +3 -10
- 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 +48 -9
- package/dist/src/transform/transfromRLCOptions.js.map +1 -1
- package/dist/src/utils/modelUtils.d.ts +2 -1
- package/dist/src/utils/modelUtils.d.ts.map +1 -1
- package/dist/src/utils/modelUtils.js +83 -73
- package/dist/src/utils/modelUtils.js.map +1 -1
- package/dist/src/utils/operationUtil.d.ts +15 -1
- package/dist/src/utils/operationUtil.d.ts.map +1 -1
- package/dist/src/utils/operationUtil.js +82 -3
- package/dist/src/utils/operationUtil.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -11
- package/src/index.ts +24 -51
- package/src/lib.ts +3 -3
- package/src/modular/buildClassicalClient.ts +29 -16
- package/src/modular/buildClientContext.ts +8 -9
- package/src/modular/buildCodeModel.ts +212 -75
- package/src/modular/buildOperations.ts +16 -11
- package/src/modular/buildProjectFiles.ts +2 -2
- package/src/modular/buildRootIndex.ts +19 -12
- package/src/modular/buildSubpathIndex.ts +10 -8
- package/src/modular/emitModels.ts +35 -24
- package/src/modular/helpers/clientHelpers.ts +1 -1
- package/src/modular/helpers/operationHelpers.ts +256 -127
- package/src/modular/helpers/typeHelpers.ts +19 -7
- package/src/modular/modularCodeModel.ts +11 -0
- package/src/transform/transformHelperFunctionDetails.ts +10 -4
- package/src/transform/transformParameters.ts +15 -57
- package/src/transform/transformResponses.ts +2 -4
- package/src/transform/transformSchemas.ts +5 -9
- package/src/transform/transformTelemetryInfo.ts +4 -18
- package/src/transform/transfromRLCOptions.ts +67 -9
- package/src/utils/modelUtils.ts +81 -72
- package/src/utils/operationUtil.ts +121 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformSchemas.js","sourceRoot":"","sources":["../../../src/transform/transformSchemas.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAEL,mBAAmB,EACnB,8BAA8B,EAC/B,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAwB,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAiB,MAAM,gBAAgB,CAAC;AACjE,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,WAAW,EACX,SAAS,
|
|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Q,CAAC,MAAM,EAAE,CAAC,CAAC;YACrD,IAAI,SAAS,GAAG,KAAK,CAAC;YACtB,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;gBAC9B,IACE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,KAAK,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,KAAK,OAAO,CAAC;oBAChE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC;wBAC5C,CAAC,CAAA,MAAA,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,0CAAE,QAAQ,CAAC,OAAO,CAAC,CAAA,CAAC,EACnE;oBACA,SAAS,GAAG,IAAI,CAAC;oBACjB,kBAAkB,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;iBAC3C;aACF;YACD,IAAI,SAAS,EAAE;gBACb,WAAW,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;aAC7B;SACF;IACH,CAAC;IACD,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,IAAI;QACnD,OAAO,EAAE,GAAG,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;IACvD,CAAC,CAAC,CAAC;IACH,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformTelemetryInfo.d.ts","sourceRoot":"","sources":["../../../src/transform/transformTelemetryInfo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EACL,SAAS,EACT,UAAU,EAGX,MAAM,6CAA6C,CAAC;
|
|
1
|
+
{"version":3,"file":"transformTelemetryInfo.d.ts","sourceRoot":"","sources":["../../../src/transform/transformTelemetryInfo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EACL,SAAS,EACT,UAAU,EAGX,MAAM,6CAA6C,CAAC;AAKrD,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,SAAS,GAChB,aAAa,GAAG,SAAS,CAW3B"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { listOperationGroups, listOperationsInOperationGroup } from "@azure-tools/typespec-client-generator-core";
|
|
2
2
|
import { ignoreDiagnostics } from "@typespec/compiler";
|
|
3
|
+
import { getCustomRequestHeaderNameForOperation } from "../utils/operationUtil.js";
|
|
3
4
|
import { getHttpOperation } from "@typespec/http";
|
|
4
5
|
export function transformTelemetryInfo(dpgContext, client) {
|
|
5
6
|
const customRequestIdHeaderName = getCustomRequestHeaderNameForClient(dpgContext, client);
|
|
@@ -17,7 +18,7 @@ function getCustomRequestHeaderNameForClient(dpgContext, client) {
|
|
|
17
18
|
const operations = listOperationsInOperationGroup(dpgContext, operationGroup);
|
|
18
19
|
for (const op of operations) {
|
|
19
20
|
const headerName = getCustomRequestHeaderNameForOperation(ignoreDiagnostics(getHttpOperation(program, op)));
|
|
20
|
-
if (headerName
|
|
21
|
+
if (headerName !== undefined) {
|
|
21
22
|
return headerName;
|
|
22
23
|
}
|
|
23
24
|
}
|
|
@@ -25,18 +26,10 @@ function getCustomRequestHeaderNameForClient(dpgContext, client) {
|
|
|
25
26
|
const clientOperations = listOperationsInOperationGroup(dpgContext, client);
|
|
26
27
|
for (const clientOp of clientOperations) {
|
|
27
28
|
const headerName = getCustomRequestHeaderNameForOperation(ignoreDiagnostics(getHttpOperation(program, clientOp)));
|
|
28
|
-
if (headerName
|
|
29
|
+
if (headerName !== undefined) {
|
|
29
30
|
return headerName;
|
|
30
31
|
}
|
|
31
32
|
}
|
|
32
33
|
return undefined;
|
|
33
34
|
}
|
|
34
|
-
function getCustomRequestHeaderNameForOperation(route) {
|
|
35
|
-
const CUSTOM_REQUEST_HEADER_NAME = "client-request-id";
|
|
36
|
-
const params = route.parameters.parameters.filter((p) => p.type === "header" && p.name.toLowerCase() === CUSTOM_REQUEST_HEADER_NAME);
|
|
37
|
-
if (params.length > 0) {
|
|
38
|
-
return CUSTOM_REQUEST_HEADER_NAME;
|
|
39
|
-
}
|
|
40
|
-
return undefined;
|
|
41
|
-
}
|
|
42
35
|
//# sourceMappingURL=transformTelemetryInfo.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformTelemetryInfo.js","sourceRoot":"","sources":["../../../src/transform/transformTelemetryInfo.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,mBAAmB,EACnB,8BAA8B,EAC/B,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"transformTelemetryInfo.js","sourceRoot":"","sources":["../../../src/transform/transformTelemetryInfo.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,mBAAmB,EACnB,8BAA8B,EAC/B,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,sCAAsC,EAAE,MAAM,2BAA2B,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,MAAM,UAAU,sBAAsB,CACpC,UAAsB,EACtB,MAAiB;IAEjB,MAAM,yBAAyB,GAAG,mCAAmC,CACnE,UAAU,EACV,MAAM,CACP,CAAC;IACF,IAAI,yBAAyB,EAAE;QAC7B,OAAO;YACL,yBAAyB;SAC1B,CAAC;KACH;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,mCAAmC,CAC1C,UAAsB,EACtB,MAAiB;IAEjB,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC;IACnC,MAAM,eAAe,GAAG,mBAAmB,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IAChE,KAAK,MAAM,cAAc,IAAI,eAAe,EAAE;QAC5C,MAAM,UAAU,GAAG,8BAA8B,CAC/C,UAAU,EACV,cAAc,CACf,CAAC;QACF,KAAK,MAAM,EAAE,IAAI,UAAU,EAAE;YAC3B,MAAM,UAAU,GAAG,sCAAsC,CACvD,iBAAiB,CAAC,gBAAgB,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CACjD,CAAC;YACF,IAAI,UAAU,KAAK,SAAS,EAAE;gBAC5B,OAAO,UAAU,CAAC;aACnB;SACF;KACF;IACD,MAAM,gBAAgB,GAAG,8BAA8B,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IAC5E,KAAK,MAAM,QAAQ,IAAI,gBAAgB,EAAE;QACvC,MAAM,UAAU,GAAG,sCAAsC,CACvD,iBAAiB,CAAC,gBAAgB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CACvD,CAAC;QACF,IAAI,UAAU,KAAK,SAAS,EAAE;YAC5B,OAAO,UAAU,CAAC;SACnB;KACF;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transfromRLCOptions.d.ts","sourceRoot":"","sources":["../../../src/transform/transfromRLCOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,UAAU,EAEX,MAAM,yBAAyB,CAAC;AACjC,OAAO,
|
|
1
|
+
{"version":3,"file":"transfromRLCOptions.d.ts","sourceRoot":"","sources":["../../../src/transform/transfromRLCOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,UAAU,EAEX,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAIL,OAAO,EACR,MAAM,oBAAoB,CAAC;AAK5B,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAOpD,wBAAgB,mBAAmB,CACjC,cAAc,EAAE,UAAU,EAC1B,UAAU,EAAE,UAAU,GACrB,UAAU,CAUZ;AA6MD,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,UAAU;;;;;;EAgC3B"}
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import { NameType, normalizeName } from "@azure-tools/rlc-common";
|
|
2
|
-
import { getDoc, NoTarget } from "@typespec/compiler";
|
|
3
|
-
import { getAuthentication } from "@typespec/http";
|
|
2
|
+
import { getDoc, ignoreDiagnostics, NoTarget } from "@typespec/compiler";
|
|
3
|
+
import { getAuthentication, getHttpOperation } from "@typespec/http";
|
|
4
4
|
import { reportDiagnostic } from "../lib.js";
|
|
5
5
|
import { getDefaultService } from "../utils/modelUtils.js";
|
|
6
6
|
import { getRLCClients } from "../utils/clientUtils.js";
|
|
7
|
+
import { listOperationGroups, listOperationsInOperationGroup } from "@azure-tools/typespec-client-generator-core";
|
|
8
|
+
import { getOperationName } from "../utils/operationUtil.js";
|
|
7
9
|
export function transformRLCOptions(emitterOptions, dpgContext) {
|
|
8
10
|
var _a, _b;
|
|
9
11
|
// Extract the options from emitter option
|
|
10
|
-
const options = extractRLCOptions(dpgContext
|
|
12
|
+
const options = extractRLCOptions(dpgContext, emitterOptions, (_b = (_a = dpgContext.generationPathDetail) === null || _a === void 0 ? void 0 : _a.rootDir) !== null && _b !== void 0 ? _b : "");
|
|
11
13
|
const batch = getRLCClients(dpgContext);
|
|
12
14
|
options.batch = batch;
|
|
13
15
|
return options;
|
|
14
16
|
}
|
|
15
|
-
function extractRLCOptions(
|
|
17
|
+
function extractRLCOptions(dpgContext, emitterOptions, generationRootDir) {
|
|
18
|
+
const program = dpgContext.program;
|
|
16
19
|
const includeShortcuts = getIncludeShortcuts(emitterOptions);
|
|
17
20
|
const packageDetails = getPackageDetails(program, emitterOptions);
|
|
18
21
|
const serviceInfo = getServiceInfo(program);
|
|
@@ -21,7 +24,7 @@ function extractRLCOptions(program, emitterOptions, generationRootDir) {
|
|
|
21
24
|
const generateTest = getGenerateTest(emitterOptions);
|
|
22
25
|
const credentialInfo = getCredentialInfo(program, emitterOptions);
|
|
23
26
|
const azureOutputDirectory = getAzureOutputDirectory(generationRootDir);
|
|
24
|
-
const enableOperationGroup = getEnableOperationGroup(emitterOptions);
|
|
27
|
+
const enableOperationGroup = getEnableOperationGroup(dpgContext, emitterOptions);
|
|
25
28
|
return {
|
|
26
29
|
...emitterOptions,
|
|
27
30
|
...credentialInfo,
|
|
@@ -32,7 +35,7 @@ function extractRLCOptions(program, emitterOptions, generationRootDir) {
|
|
|
32
35
|
azureSdkForJs,
|
|
33
36
|
serviceInfo,
|
|
34
37
|
azureOutputDirectory,
|
|
35
|
-
sourceFrom: "
|
|
38
|
+
sourceFrom: "TypeSpec",
|
|
36
39
|
enableOperationGroup
|
|
37
40
|
};
|
|
38
41
|
}
|
|
@@ -89,10 +92,46 @@ function processAuth(program) {
|
|
|
89
92
|
}
|
|
90
93
|
return securityInfo;
|
|
91
94
|
}
|
|
92
|
-
function getEnableOperationGroup(emitterOptions) {
|
|
93
|
-
if (emitterOptions.enableOperationGroup === true
|
|
94
|
-
|
|
95
|
+
function getEnableOperationGroup(dpgContext, emitterOptions) {
|
|
96
|
+
if (emitterOptions.enableOperationGroup === true ||
|
|
97
|
+
emitterOptions.enableOperationGroup === false) {
|
|
98
|
+
return emitterOptions.enableOperationGroup;
|
|
95
99
|
}
|
|
100
|
+
// Detect if existing name conflicts if customers didn't set the option explicitly
|
|
101
|
+
return detectIfNameConflicts(dpgContext);
|
|
102
|
+
}
|
|
103
|
+
function detectIfNameConflicts(dpgContext) {
|
|
104
|
+
const clients = getRLCClients(dpgContext);
|
|
105
|
+
const program = dpgContext.program;
|
|
106
|
+
const nameSet = new Set();
|
|
107
|
+
for (const client of clients) {
|
|
108
|
+
const operationGroups = listOperationGroups(dpgContext, client);
|
|
109
|
+
for (const operationGroup of operationGroups) {
|
|
110
|
+
const operations = listOperationsInOperationGroup(dpgContext, operationGroup);
|
|
111
|
+
for (const op of operations) {
|
|
112
|
+
const route = ignoreDiagnostics(getHttpOperation(program, op));
|
|
113
|
+
const name = getOperationName(program, route.operation);
|
|
114
|
+
if (nameSet.has(name)) {
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
nameSet.add(name);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const clientOperations = listOperationsInOperationGroup(dpgContext, client);
|
|
123
|
+
for (const clientOp of clientOperations) {
|
|
124
|
+
const route = ignoreDiagnostics(getHttpOperation(program, clientOp));
|
|
125
|
+
const name = getOperationName(program, route.operation);
|
|
126
|
+
if (nameSet.has(name)) {
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
nameSet.add(name);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
// No conflicts if we didn't detect any
|
|
96
135
|
return false;
|
|
97
136
|
}
|
|
98
137
|
function getIncludeShortcuts(emitterOptions) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transfromRLCOptions.js","sourceRoot":"","sources":["../../../src/transform/transfromRLCOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,aAAa,EAId,MAAM,yBAAyB,CAAC;AACjC,OAAO,
|
|
1
|
+
{"version":3,"file":"transfromRLCOptions.js","sourceRoot":"","sources":["../../../src/transform/transfromRLCOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,aAAa,EAId,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,MAAM,EACN,iBAAiB,EACjB,QAAQ,EAET,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAA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;AACJ,CAAC;AAED,SAAS,uBAAuB,CAAC,gBAAwB;IACvD,MAAM,SAAS,GAAG,gBAAgB,CAAC;IACnC,MAAM,eAAe,GAAG,SAAS,aAAT,SAAS,uBAAT,SAAS,CAC7B,OAAO,CAAC,KAAK,EAAE,EAAE,EAClB,KAAK,CAAC,GAAG,EACT,KAAK,CAAC,CAAC,CAAC,EACR,IAAI,CAAC,GAAG,CAAC,CAAC;IACb,OAAO,CAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,MAAK,KAAK;QAC/C,CAAC,CAAC,eAAe;QACjB,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC"}
|
|
@@ -10,7 +10,7 @@ export declare function getEffectiveModelFromType(program: Program, type: Type):
|
|
|
10
10
|
export declare function includeDerivedModel(model: Model): boolean;
|
|
11
11
|
export declare function getTypeName(schema: Schema, usage?: SchemaContext[]): string;
|
|
12
12
|
export declare function getImportedModelName(schema: Schema): string[] | undefined;
|
|
13
|
-
export declare function getFormattedPropertyDoc(program: Program,
|
|
13
|
+
export declare function getFormattedPropertyDoc(program: Program, type: ModelProperty | Type, schemaType: any, sperator?: string): string | undefined;
|
|
14
14
|
export declare function getBodyType(program: Program, route: HttpOperation): Type | undefined;
|
|
15
15
|
/**
|
|
16
16
|
* Predict if the default value exists in param, we would follow the rules:
|
|
@@ -32,4 +32,5 @@ export declare function getDefaultService(program: Program): Service | undefined
|
|
|
32
32
|
*/
|
|
33
33
|
export declare function getEnrichedDefaultApiVersion(program: Program, dpgContext: SdkContext): string | undefined;
|
|
34
34
|
export declare function trimUsage(model: any): any;
|
|
35
|
+
export declare function isAzureCoreErrorType(t?: Type): boolean;
|
|
35
36
|
//# sourceMappingURL=modelUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modelUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/modelUtils.ts"],"names":[],"mappings":"AAGA,OAAO,E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I,GAAG,OAAO,CAetD"}
|
|
@@ -62,7 +62,7 @@ export function enrichBinaryTypeInBody(schema) {
|
|
|
62
62
|
export function getSchemaForType(dpgContext, typeInput, usage, needRef = false, relevantProperty) {
|
|
63
63
|
const program = dpgContext.program;
|
|
64
64
|
const type = getEffectiveModelFromType(program, typeInput);
|
|
65
|
-
const builtinType =
|
|
65
|
+
const builtinType = mapTypeSpecTypeToTypeScript(dpgContext, type, usage);
|
|
66
66
|
if (builtinType !== undefined) {
|
|
67
67
|
// add in description elements for types derived from primitive types (SecureString, etc.)
|
|
68
68
|
const doc = getDoc(program, type);
|
|
@@ -201,7 +201,7 @@ function getSchemaForUnion(dpgContext, union, usage) {
|
|
|
201
201
|
function getSchemaForUnionVariant(dpgContext, variant, usage) {
|
|
202
202
|
return getSchemaForType(dpgContext, variant, usage);
|
|
203
203
|
}
|
|
204
|
-
// An openapi "string" can be defined in several different ways in
|
|
204
|
+
// An openapi "string" can be defined in several different ways in typespec
|
|
205
205
|
function isOasString(type) {
|
|
206
206
|
if (type.kind === "String") {
|
|
207
207
|
// A string literal
|
|
@@ -315,7 +315,7 @@ function validateDiscriminator(program, discriminator, derivedModels) {
|
|
|
315
315
|
* A "schema property" here is a property that is emitted to OpenAPI schema.
|
|
316
316
|
*
|
|
317
317
|
* Headers, parameters, status codes are not schema properties even they are
|
|
318
|
-
* represented as properties in
|
|
318
|
+
* represented as properties in typespec.
|
|
319
319
|
*/
|
|
320
320
|
function isSchemaProperty(program, property) {
|
|
321
321
|
const headerInfo = getHeaderFieldName(program, property);
|
|
@@ -325,9 +325,9 @@ function isSchemaProperty(program, property) {
|
|
|
325
325
|
return !(headerInfo || queryInfo || pathInfo || statusCodeinfo);
|
|
326
326
|
}
|
|
327
327
|
function getSchemaForModel(dpgContext, model, usage, needRef) {
|
|
328
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m
|
|
328
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
329
329
|
const program = dpgContext.program;
|
|
330
|
-
const overridedModelName = (
|
|
330
|
+
const overridedModelName = (_a = getFriendlyName(program, model)) !== null && _a !== void 0 ? _a : getProjectedName(program, model, "json");
|
|
331
331
|
let name = model.name;
|
|
332
332
|
if (!overridedModelName &&
|
|
333
333
|
model.templateMapper &&
|
|
@@ -351,17 +351,12 @@ function getSchemaForModel(dpgContext, model, usage, needRef) {
|
|
|
351
351
|
let modelSchema = {
|
|
352
352
|
name: overridedModelName !== null && overridedModelName !== void 0 ? overridedModelName : name,
|
|
353
353
|
type: "object",
|
|
354
|
-
description: (
|
|
354
|
+
description: (_b = getDoc(program, model)) !== null && _b !== void 0 ? _b : ""
|
|
355
355
|
};
|
|
356
356
|
// normalized the output name
|
|
357
357
|
modelSchema.name = normalizeName(modelSchema.name, NameType.Interface, true /** shouldGuard */);
|
|
358
358
|
modelSchema.typeName = modelSchema.name;
|
|
359
|
-
if ((model
|
|
360
|
-
model.name === "ErrorModel" ||
|
|
361
|
-
model.name === "Error") &&
|
|
362
|
-
model.kind === "Model" &&
|
|
363
|
-
((_d = model.namespace) === null || _d === void 0 ? void 0 : _d.name) === "Foundations" &&
|
|
364
|
-
((_e = model.namespace.namespace) === null || _e === void 0 ? void 0 : _e.name) === "Core") {
|
|
359
|
+
if (isAzureCoreErrorType(model)) {
|
|
365
360
|
modelSchema.fromCore = true;
|
|
366
361
|
}
|
|
367
362
|
if (getPagedResult(program, model)) {
|
|
@@ -369,7 +364,7 @@ function getSchemaForModel(dpgContext, model, usage, needRef) {
|
|
|
369
364
|
if (paged && paged.itemsProperty) {
|
|
370
365
|
const items = paged.itemsProperty;
|
|
371
366
|
if (items && items.templateMapper && items.templateMapper.args) {
|
|
372
|
-
const templateName = (
|
|
367
|
+
const templateName = (_c = items.templateMapper.args) === null || _c === void 0 ? void 0 : _c.map((it) => {
|
|
373
368
|
switch (it.kind) {
|
|
374
369
|
case "Model":
|
|
375
370
|
return it.name;
|
|
@@ -380,7 +375,7 @@ function getSchemaForModel(dpgContext, model, usage, needRef) {
|
|
|
380
375
|
}
|
|
381
376
|
}).join("");
|
|
382
377
|
if (paged.itemsProperty.name === "value" &&
|
|
383
|
-
((
|
|
378
|
+
((_d = paged.nextLinkProperty) === null || _d === void 0 ? void 0 : _d.name) === "nextLink") {
|
|
384
379
|
modelSchema.alias = `Paged<${templateName}>`;
|
|
385
380
|
modelSchema.outputAlias = `Paged<${templateName}Output>`;
|
|
386
381
|
}
|
|
@@ -406,13 +401,13 @@ function getSchemaForModel(dpgContext, model, usage, needRef) {
|
|
|
406
401
|
break;
|
|
407
402
|
}
|
|
408
403
|
}
|
|
409
|
-
(
|
|
410
|
-
(
|
|
404
|
+
(_f = (_e = modelSchema.children) === null || _e === void 0 ? void 0 : _e.all) === null || _f === void 0 ? void 0 : _f.push(childSchema);
|
|
405
|
+
(_h = (_g = modelSchema.children) === null || _g === void 0 ? void 0 : _g.immediate) === null || _h === void 0 ? void 0 : _h.push(childSchema);
|
|
411
406
|
}
|
|
412
407
|
// Enable option `isPolyParent` and discriminator only when it has valid children
|
|
413
408
|
if (discriminator &&
|
|
414
|
-
((
|
|
415
|
-
((
|
|
409
|
+
((_k = (_j = modelSchema === null || modelSchema === void 0 ? void 0 : modelSchema.children) === null || _j === void 0 ? void 0 : _j.all) === null || _k === void 0 ? void 0 : _k.length) &&
|
|
410
|
+
((_m = (_l = modelSchema === null || modelSchema === void 0 ? void 0 : modelSchema.children) === null || _l === void 0 ? void 0 : _l.all) === null || _m === void 0 ? void 0 : _m.length) > 0) {
|
|
416
411
|
if (!validateDiscriminator(program, discriminator, derivedModels)) {
|
|
417
412
|
// appropriate diagnostic is generated in the validate function
|
|
418
413
|
return {};
|
|
@@ -510,69 +505,69 @@ function getSchemaForModel(dpgContext, model, usage, needRef) {
|
|
|
510
505
|
}
|
|
511
506
|
return modelSchema;
|
|
512
507
|
}
|
|
513
|
-
// Map an
|
|
508
|
+
// Map an typespec type to an OA schema. Returns undefined when the resulting
|
|
514
509
|
// OA schema is just a regular object schema.
|
|
515
|
-
function
|
|
516
|
-
switch (
|
|
510
|
+
function mapTypeSpecTypeToTypeScript(dpgContext, type, usage) {
|
|
511
|
+
switch (type.kind) {
|
|
517
512
|
case "Number":
|
|
518
|
-
return { type: `${
|
|
513
|
+
return { type: `${type.value}` };
|
|
519
514
|
case "String":
|
|
520
|
-
return { type: `"${
|
|
515
|
+
return { type: `"${type.value}"` };
|
|
521
516
|
case "Boolean":
|
|
522
|
-
return { type: `${
|
|
517
|
+
return { type: `${type.value}` };
|
|
523
518
|
case "Model":
|
|
524
|
-
return
|
|
519
|
+
return mapTypeSpecStdTypeToTypeScript(dpgContext, type, usage);
|
|
525
520
|
}
|
|
526
|
-
if (
|
|
527
|
-
if (typeof
|
|
528
|
-
return { type: `"${
|
|
521
|
+
if (type.kind === undefined) {
|
|
522
|
+
if (typeof type === "string") {
|
|
523
|
+
return { type: `"${type}"` };
|
|
529
524
|
}
|
|
530
|
-
else if (typeof
|
|
531
|
-
return { type: `${
|
|
525
|
+
else if (typeof type === "number" || typeof type === "boolean") {
|
|
526
|
+
return { type: `${type}` };
|
|
532
527
|
}
|
|
533
528
|
}
|
|
534
529
|
}
|
|
535
|
-
function applyIntrinsicDecorators(program,
|
|
530
|
+
function applyIntrinsicDecorators(program, type, target) {
|
|
536
531
|
const newTarget = { ...target };
|
|
537
|
-
const docStr = getDoc(program,
|
|
538
|
-
const isString = isStringType(program, getPropertyType(
|
|
539
|
-
const isNumeric = isNumericType(program, getPropertyType(
|
|
532
|
+
const docStr = getDoc(program, type);
|
|
533
|
+
const isString = isStringType(program, getPropertyType(type));
|
|
534
|
+
const isNumeric = isNumericType(program, getPropertyType(type));
|
|
540
535
|
if (isString && !target.documentation && docStr) {
|
|
541
536
|
newTarget.description = docStr;
|
|
542
537
|
}
|
|
543
|
-
const restApiName = getProjectedName(program,
|
|
538
|
+
const restApiName = getProjectedName(program, type, "json");
|
|
544
539
|
if (restApiName) {
|
|
545
540
|
newTarget.name = restApiName;
|
|
546
541
|
}
|
|
547
|
-
const summaryStr = getSummary(program,
|
|
542
|
+
const summaryStr = getSummary(program, type);
|
|
548
543
|
if (isString && !target.summary && summaryStr) {
|
|
549
544
|
newTarget.summary = summaryStr;
|
|
550
545
|
}
|
|
551
|
-
const formatStr = getFormat(program,
|
|
546
|
+
const formatStr = getFormat(program, type);
|
|
552
547
|
if (isString && !target.format && formatStr) {
|
|
553
548
|
newTarget.format = formatStr;
|
|
554
549
|
}
|
|
555
|
-
const pattern = getPattern(program,
|
|
550
|
+
const pattern = getPattern(program, type);
|
|
556
551
|
if (isString && !target.pattern && pattern) {
|
|
557
552
|
newTarget.pattern = pattern;
|
|
558
553
|
}
|
|
559
|
-
const minLength = getMinLength(program,
|
|
554
|
+
const minLength = getMinLength(program, type);
|
|
560
555
|
if (isString && !target.minLength && minLength !== undefined) {
|
|
561
556
|
newTarget.minLength = minLength;
|
|
562
557
|
}
|
|
563
|
-
const maxLength = getMaxLength(program,
|
|
558
|
+
const maxLength = getMaxLength(program, type);
|
|
564
559
|
if (isString && !target.maxLength && maxLength !== undefined) {
|
|
565
560
|
newTarget.maxLength = maxLength;
|
|
566
561
|
}
|
|
567
|
-
const minValue = getMinValue(program,
|
|
562
|
+
const minValue = getMinValue(program, type);
|
|
568
563
|
if (isNumeric && !target.minimum && minValue !== undefined) {
|
|
569
564
|
newTarget.minimum = minValue;
|
|
570
565
|
}
|
|
571
|
-
const maxValue = getMaxValue(program,
|
|
566
|
+
const maxValue = getMaxValue(program, type);
|
|
572
567
|
if (isNumeric && !target.maximum && maxValue !== undefined) {
|
|
573
568
|
newTarget.maximum = maxValue;
|
|
574
569
|
}
|
|
575
|
-
if (isSecret(program,
|
|
570
|
+
if (isSecret(program, type)) {
|
|
576
571
|
newTarget.format = "password";
|
|
577
572
|
newTarget["x-ms-secret"] = true;
|
|
578
573
|
}
|
|
@@ -616,12 +611,12 @@ function enumMemberType(member) {
|
|
|
616
611
|
return "string";
|
|
617
612
|
}
|
|
618
613
|
/**
|
|
619
|
-
* Map
|
|
614
|
+
* Map TypeSpec intrinsic models to open api definitions
|
|
620
615
|
*/
|
|
621
|
-
function
|
|
616
|
+
function mapTypeSpecStdTypeToTypeScript(dpgContext, type, usage) {
|
|
622
617
|
var _a, _b, _c;
|
|
623
618
|
const program = dpgContext.program;
|
|
624
|
-
const indexer =
|
|
619
|
+
const indexer = type.indexer;
|
|
625
620
|
if (indexer !== undefined) {
|
|
626
621
|
if (!isNeverType(indexer.key)) {
|
|
627
622
|
const name = indexer.key.name;
|
|
@@ -631,7 +626,7 @@ function mapCadlStdTypeToTypeScript(dpgContext, cadlType, usage) {
|
|
|
631
626
|
schema = {
|
|
632
627
|
type: "dictionary",
|
|
633
628
|
additionalProperties: valueType,
|
|
634
|
-
description: getDoc(program,
|
|
629
|
+
description: getDoc(program, type)
|
|
635
630
|
};
|
|
636
631
|
if (!program.checker.isStdType(indexer.value) &&
|
|
637
632
|
!isUnknownType(indexer.value) &&
|
|
@@ -662,7 +657,7 @@ function mapCadlStdTypeToTypeScript(dpgContext, cadlType, usage) {
|
|
|
662
657
|
schema = {
|
|
663
658
|
type: "array",
|
|
664
659
|
items: getSchemaForType(dpgContext, indexer.value, usage, true),
|
|
665
|
-
description: getDoc(program,
|
|
660
|
+
description: getDoc(program, type)
|
|
666
661
|
};
|
|
667
662
|
if (!program.checker.isStdType(indexer.value) &&
|
|
668
663
|
!isUnknownType(indexer.value) &&
|
|
@@ -717,8 +712,8 @@ function mapCadlStdTypeToTypeScript(dpgContext, cadlType, usage) {
|
|
|
717
712
|
function isUnionType(type) {
|
|
718
713
|
return type.kind === "Union";
|
|
719
714
|
}
|
|
720
|
-
function getSchemaForStdScalar(program,
|
|
721
|
-
if (!program.checker.isStdType(
|
|
715
|
+
function getSchemaForStdScalar(program, type, relevantProperty) {
|
|
716
|
+
if (!program.checker.isStdType(type)) {
|
|
722
717
|
return undefined;
|
|
723
718
|
}
|
|
724
719
|
/**
|
|
@@ -726,83 +721,85 @@ function getSchemaForStdScalar(program, cadlType, relevantProperty) {
|
|
|
726
721
|
* if absent use typespec type (or default way of serializing that type)
|
|
727
722
|
* if present respect type provided in @encode
|
|
728
723
|
*/
|
|
724
|
+
let format = undefined;
|
|
729
725
|
if (relevantProperty) {
|
|
730
726
|
const encodeData = getEncode(program, relevantProperty);
|
|
731
|
-
if (encodeData && isEncodeTypeEffective(
|
|
732
|
-
|
|
727
|
+
if (encodeData && isEncodeTypeEffective(type, encodeData)) {
|
|
728
|
+
type = encodeData.type;
|
|
729
|
+
format = encodeData.encoding;
|
|
733
730
|
}
|
|
734
731
|
}
|
|
735
|
-
const name =
|
|
736
|
-
const description = getSummary(program,
|
|
732
|
+
const name = type.name;
|
|
733
|
+
const description = getSummary(program, type);
|
|
737
734
|
switch (name) {
|
|
738
735
|
case "bytes":
|
|
739
736
|
return { type: "string", format: "byte", description };
|
|
740
737
|
case "integer":
|
|
741
|
-
return applyIntrinsicDecorators(program,
|
|
738
|
+
return applyIntrinsicDecorators(program, type, {
|
|
742
739
|
type: "number"
|
|
743
740
|
});
|
|
744
741
|
case "int8":
|
|
745
|
-
return applyIntrinsicDecorators(program,
|
|
742
|
+
return applyIntrinsicDecorators(program, type, {
|
|
746
743
|
type: "number",
|
|
747
744
|
format: "int8"
|
|
748
745
|
});
|
|
749
746
|
case "int16":
|
|
750
|
-
return applyIntrinsicDecorators(program,
|
|
747
|
+
return applyIntrinsicDecorators(program, type, {
|
|
751
748
|
type: "number",
|
|
752
749
|
format: "int16"
|
|
753
750
|
});
|
|
754
751
|
case "int32":
|
|
755
|
-
return applyIntrinsicDecorators(program,
|
|
752
|
+
return applyIntrinsicDecorators(program, type, {
|
|
756
753
|
type: "number",
|
|
757
754
|
format: "int32"
|
|
758
755
|
});
|
|
759
756
|
case "int64":
|
|
760
|
-
return applyIntrinsicDecorators(program,
|
|
757
|
+
return applyIntrinsicDecorators(program, type, {
|
|
761
758
|
type: "number",
|
|
762
759
|
format: "int64"
|
|
763
760
|
});
|
|
764
761
|
case "safeint":
|
|
765
|
-
return applyIntrinsicDecorators(program,
|
|
762
|
+
return applyIntrinsicDecorators(program, type, {
|
|
766
763
|
type: "number",
|
|
767
764
|
format: "int64"
|
|
768
765
|
});
|
|
769
766
|
case "uint8":
|
|
770
|
-
return applyIntrinsicDecorators(program,
|
|
767
|
+
return applyIntrinsicDecorators(program, type, {
|
|
771
768
|
type: "number",
|
|
772
769
|
format: "uint8"
|
|
773
770
|
});
|
|
774
771
|
case "uint16":
|
|
775
|
-
return applyIntrinsicDecorators(program,
|
|
772
|
+
return applyIntrinsicDecorators(program, type, {
|
|
776
773
|
type: "number",
|
|
777
774
|
format: "uint16"
|
|
778
775
|
});
|
|
779
776
|
case "uint32":
|
|
780
|
-
return applyIntrinsicDecorators(program,
|
|
777
|
+
return applyIntrinsicDecorators(program, type, {
|
|
781
778
|
type: "number",
|
|
782
779
|
format: "uint32"
|
|
783
780
|
});
|
|
784
781
|
case "uint64":
|
|
785
|
-
return applyIntrinsicDecorators(program,
|
|
782
|
+
return applyIntrinsicDecorators(program, type, {
|
|
786
783
|
type: "number",
|
|
787
784
|
format: "uint64"
|
|
788
785
|
});
|
|
789
786
|
case "float64":
|
|
790
|
-
return applyIntrinsicDecorators(program,
|
|
787
|
+
return applyIntrinsicDecorators(program, type, {
|
|
791
788
|
type: "number",
|
|
792
789
|
format: "double"
|
|
793
790
|
});
|
|
794
791
|
case "float32":
|
|
795
|
-
return applyIntrinsicDecorators(program,
|
|
792
|
+
return applyIntrinsicDecorators(program, type, {
|
|
796
793
|
type: "number",
|
|
797
794
|
format: "float"
|
|
798
795
|
});
|
|
799
796
|
case "float":
|
|
800
|
-
return applyIntrinsicDecorators(program,
|
|
797
|
+
return applyIntrinsicDecorators(program, type, {
|
|
801
798
|
type: "number",
|
|
802
799
|
format: "float"
|
|
803
800
|
});
|
|
804
801
|
case "string":
|
|
805
|
-
return applyIntrinsicDecorators(program,
|
|
802
|
+
return applyIntrinsicDecorators(program, type, {
|
|
806
803
|
type: "string"
|
|
807
804
|
});
|
|
808
805
|
case "boolean":
|
|
@@ -810,7 +807,7 @@ function getSchemaForStdScalar(program, cadlType, relevantProperty) {
|
|
|
810
807
|
case "plainDate":
|
|
811
808
|
return {
|
|
812
809
|
type: "string",
|
|
813
|
-
format
|
|
810
|
+
format,
|
|
814
811
|
description,
|
|
815
812
|
typeName: "Date | string",
|
|
816
813
|
outputTypeName: "string"
|
|
@@ -818,7 +815,7 @@ function getSchemaForStdScalar(program, cadlType, relevantProperty) {
|
|
|
818
815
|
case "utcDateTime":
|
|
819
816
|
return {
|
|
820
817
|
type: "string",
|
|
821
|
-
format
|
|
818
|
+
format,
|
|
822
819
|
description,
|
|
823
820
|
typeName: "Date | string",
|
|
824
821
|
outputTypeName: "string"
|
|
@@ -840,7 +837,7 @@ function getSchemaForStdScalar(program, cadlType, relevantProperty) {
|
|
|
840
837
|
outputTypeName: "string"
|
|
841
838
|
};
|
|
842
839
|
case "duration":
|
|
843
|
-
return { type: "string", format
|
|
840
|
+
return { type: "string", format, description };
|
|
844
841
|
}
|
|
845
842
|
}
|
|
846
843
|
function isEncodeTypeEffective(type, encodeData) {
|
|
@@ -902,8 +899,8 @@ function getEnumStringDescription(type) {
|
|
|
902
899
|
}
|
|
903
900
|
return undefined;
|
|
904
901
|
}
|
|
905
|
-
export function getFormattedPropertyDoc(program,
|
|
906
|
-
const propertyDoc = getDoc(program,
|
|
902
|
+
export function getFormattedPropertyDoc(program, type, schemaType, sperator = "\n\n") {
|
|
903
|
+
const propertyDoc = getDoc(program, type);
|
|
907
904
|
const enhancedDocFromType = getEnumStringDescription(schemaType);
|
|
908
905
|
if (propertyDoc && enhancedDocFromType) {
|
|
909
906
|
return `${propertyDoc}${sperator}${enhancedDocFromType}`;
|
|
@@ -1029,4 +1026,17 @@ export function trimUsage(model) {
|
|
|
1029
1026
|
}, {});
|
|
1030
1027
|
return ordered;
|
|
1031
1028
|
}
|
|
1029
|
+
export function isAzureCoreErrorType(t) {
|
|
1030
|
+
var _a;
|
|
1031
|
+
if ((t === null || t === void 0 ? void 0 : t.kind) !== "Model" ||
|
|
1032
|
+
!["error", "errorresponse", "innererror"].includes(t.name.toLowerCase()))
|
|
1033
|
+
return false;
|
|
1034
|
+
const namespaces = ".Azure.Core.Foundations".split(".");
|
|
1035
|
+
while (namespaces.length > 0 &&
|
|
1036
|
+
((t === null || t === void 0 ? void 0 : t.kind) === "Model" || (t === null || t === void 0 ? void 0 : t.kind) === "Namespace") &&
|
|
1037
|
+
((_a = t.namespace) === null || _a === void 0 ? void 0 : _a.name) === namespaces.pop()) {
|
|
1038
|
+
t = t.namespace;
|
|
1039
|
+
}
|
|
1040
|
+
return namespaces.length == 0;
|
|
1041
|
+
}
|
|
1032
1042
|
//# sourceMappingURL=modelUtils.js.map
|