@azure-tools/typespec-ts 0.54.0-alpha.20260601.2 → 0.54.0-dev.4
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 +0 -11
- package/README.md +0 -4
- package/dist/src/contextManager.js +3 -3
- package/dist/src/contextManager.js.map +1 -1
- package/dist/src/framework/hooks/binder.js +19 -20
- package/dist/src/framework/hooks/binder.js.map +1 -1
- package/dist/src/framework/hooks/sdkTypes.js +1 -2
- package/dist/src/framework/hooks/sdkTypes.js.map +1 -1
- package/dist/src/framework/load-static-helpers.js +7 -8
- package/dist/src/framework/load-static-helpers.js.map +1 -1
- package/dist/src/framework/reference.js +1 -1
- package/dist/src/framework/reference.js.map +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +34 -45
- package/dist/src/index.js.map +1 -1
- package/dist/src/modular/buildClassicalClient.js +14 -15
- package/dist/src/modular/buildClassicalClient.js.map +1 -1
- package/dist/src/modular/buildClassicalOperationGroups.js +4 -3
- package/dist/src/modular/buildClassicalOperationGroups.js.map +1 -1
- package/dist/src/modular/buildClientContext.js +1 -2
- package/dist/src/modular/buildClientContext.js.map +1 -1
- package/dist/src/modular/buildModularOptions.js +4 -5
- package/dist/src/modular/buildModularOptions.js.map +1 -1
- package/dist/src/modular/buildOperations.js +1 -2
- package/dist/src/modular/buildOperations.js.map +1 -1
- package/dist/src/modular/buildProjectFiles.js +1 -2
- package/dist/src/modular/buildProjectFiles.js.map +1 -1
- package/dist/src/modular/buildRestorePoller.js +1 -2
- package/dist/src/modular/buildRestorePoller.js.map +1 -1
- package/dist/src/modular/buildRootIndex.d.ts.map +1 -1
- package/dist/src/modular/buildRootIndex.js +9 -14
- package/dist/src/modular/buildRootIndex.js.map +1 -1
- package/dist/src/modular/buildSubpathIndex.js +1 -2
- package/dist/src/modular/buildSubpathIndex.js.map +1 -1
- package/dist/src/modular/emitLoggerFile.js +2 -2
- package/dist/src/modular/emitLoggerFile.js.map +1 -1
- package/dist/src/modular/emitModels.js +32 -46
- package/dist/src/modular/emitModels.js.map +1 -1
- package/dist/src/modular/emitModelsOptions.js +1 -1
- package/dist/src/modular/emitModelsOptions.js.map +1 -1
- package/dist/src/modular/emitSamples.js +34 -30
- package/dist/src/modular/emitSamples.js.map +1 -1
- package/dist/src/modular/emitTests.js +4 -6
- package/dist/src/modular/emitTests.js.map +1 -1
- package/dist/src/modular/helpers/classicalOperationHelpers.js +42 -42
- package/dist/src/modular/helpers/classicalOperationHelpers.js.map +1 -1
- package/dist/src/modular/helpers/clientHelpers.js +20 -25
- package/dist/src/modular/helpers/clientHelpers.js.map +1 -1
- package/dist/src/modular/helpers/clientOptionHelpers.js +1 -1
- package/dist/src/modular/helpers/clientOptionHelpers.js.map +1 -1
- package/dist/src/modular/helpers/exampleValueHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/exampleValueHelpers.js +39 -32
- package/dist/src/modular/helpers/exampleValueHelpers.js.map +1 -1
- package/dist/src/modular/helpers/namingHelpers.js +3 -5
- package/dist/src/modular/helpers/namingHelpers.js.map +1 -1
- package/dist/src/modular/helpers/operationHelpers.js +75 -99
- package/dist/src/modular/helpers/operationHelpers.js.map +1 -1
- package/dist/src/modular/helpers/typeHelpers.js +3 -5
- package/dist/src/modular/helpers/typeHelpers.js.map +1 -1
- package/dist/src/modular/serialization/buildDeserializerFunction.js +11 -14
- package/dist/src/modular/serialization/buildDeserializerFunction.js.map +1 -1
- package/dist/src/modular/serialization/buildSerializerFunction.js +17 -20
- package/dist/src/modular/serialization/buildSerializerFunction.js.map +1 -1
- package/dist/src/modular/serialization/buildXmlSerializerFunction.js +31 -40
- package/dist/src/modular/serialization/buildXmlSerializerFunction.js.map +1 -1
- package/dist/src/modular/serialization/serializeUtils.d.ts.map +1 -1
- package/dist/src/modular/serialization/serializeUtils.js +24 -25
- package/dist/src/modular/serialization/serializeUtils.js.map +1 -1
- package/dist/src/modular/type-expressions/get-enum-expression.js +1 -2
- package/dist/src/modular/type-expressions/get-enum-expression.js.map +1 -1
- package/dist/src/modular/type-expressions/get-model-expression.js +5 -6
- package/dist/src/modular/type-expressions/get-model-expression.js.map +1 -1
- package/dist/src/modular/type-expressions/get-nullable-expression.js +2 -3
- package/dist/src/modular/type-expressions/get-nullable-expression.js.map +1 -1
- package/dist/src/modular/type-expressions/get-type-expression.js +2 -4
- package/dist/src/modular/type-expressions/get-type-expression.js.map +1 -1
- package/dist/src/rlc-common/buildClient.js +26 -30
- package/dist/src/rlc-common/buildClient.js.map +1 -1
- package/dist/src/rlc-common/buildClientDefinitions.js +6 -5
- package/dist/src/rlc-common/buildClientDefinitions.js.map +1 -1
- package/dist/src/rlc-common/buildIndexFile.js +2 -3
- package/dist/src/rlc-common/buildIndexFile.js.map +1 -1
- package/dist/src/rlc-common/buildIsUnexpectedHelper.js +12 -10
- package/dist/src/rlc-common/buildIsUnexpectedHelper.js.map +1 -1
- package/dist/src/rlc-common/buildLogger.js +1 -2
- package/dist/src/rlc-common/buildLogger.js.map +1 -1
- package/dist/src/rlc-common/buildMethodShortcuts.js +1 -1
- package/dist/src/rlc-common/buildMethodShortcuts.js.map +1 -1
- package/dist/src/rlc-common/buildObjectTypes.js +38 -60
- package/dist/src/rlc-common/buildObjectTypes.js.map +1 -1
- package/dist/src/rlc-common/buildParameterTypes.js +12 -15
- package/dist/src/rlc-common/buildParameterTypes.js.map +1 -1
- package/dist/src/rlc-common/buildPollingHelper.js +7 -8
- package/dist/src/rlc-common/buildPollingHelper.js.map +1 -1
- package/dist/src/rlc-common/buildResponseTypes.js +4 -5
- package/dist/src/rlc-common/buildResponseTypes.js.map +1 -1
- package/dist/src/rlc-common/helpers/apiVersionUtil.js +5 -6
- package/dist/src/rlc-common/helpers/apiVersionUtil.js.map +1 -1
- package/dist/src/rlc-common/helpers/importsUtil.js +9 -12
- package/dist/src/rlc-common/helpers/importsUtil.js.map +1 -1
- package/dist/src/rlc-common/helpers/nameConstructors.js +2 -4
- package/dist/src/rlc-common/helpers/nameConstructors.js.map +1 -1
- package/dist/src/rlc-common/helpers/nameUtils.js +9 -10
- package/dist/src/rlc-common/helpers/nameUtils.js.map +1 -1
- package/dist/src/rlc-common/helpers/operationHelpers.js +10 -21
- package/dist/src/rlc-common/helpers/operationHelpers.js.map +1 -1
- package/dist/src/rlc-common/helpers/packageUtil.js +3 -6
- package/dist/src/rlc-common/helpers/packageUtil.js.map +1 -1
- package/dist/src/rlc-common/helpers/schemaHelpers.js +2 -6
- package/dist/src/rlc-common/helpers/schemaHelpers.js.map +1 -1
- package/dist/src/rlc-common/helpers/typeUtil.js +4 -8
- package/dist/src/rlc-common/helpers/typeUtil.js.map +1 -1
- package/dist/src/rlc-common/helpers/valueGenerationUtil.js +4 -7
- package/dist/src/rlc-common/helpers/valueGenerationUtil.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildApiExtractorConfig.js +2 -3
- package/dist/src/rlc-common/metadata/buildApiExtractorConfig.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildChangelogFile.js +1 -2
- package/dist/src/rlc-common/metadata/buildChangelogFile.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildESLintConfig.js +3 -4
- package/dist/src/rlc-common/metadata/buildESLintConfig.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildPackageFile.js +19 -23
- package/dist/src/rlc-common/metadata/buildPackageFile.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildReadmeFile.js +25 -25
- package/dist/src/rlc-common/metadata/buildReadmeFile.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildRollupConfig.js +1 -2
- package/dist/src/rlc-common/metadata/buildRollupConfig.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildSampleEnvFile.js +3 -4
- package/dist/src/rlc-common/metadata/buildSampleEnvFile.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildTestConfig.js +3 -4
- package/dist/src/rlc-common/metadata/buildTestConfig.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildTsConfig.js +6 -8
- package/dist/src/rlc-common/metadata/buildTsConfig.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildVitestConfig.js +2 -3
- package/dist/src/rlc-common/metadata/buildVitestConfig.js.map +1 -1
- package/dist/src/rlc-common/metadata/buildWarpConfig.js +2 -3
- package/dist/src/rlc-common/metadata/buildWarpConfig.js.map +1 -1
- package/dist/src/rlc-common/metadata/packageJson/azurePackageCommon.js +1 -1
- package/dist/src/rlc-common/metadata/packageJson/azurePackageCommon.js.map +1 -1
- package/dist/src/rlc-common/metadata/packageJson/buildAzureMonorepoPackage.js +2 -3
- package/dist/src/rlc-common/metadata/packageJson/buildAzureMonorepoPackage.js.map +1 -1
- package/dist/src/rlc-common/metadata/packageJson/packageCommon.js +2 -2
- package/dist/src/rlc-common/metadata/packageJson/packageCommon.js.map +1 -1
- package/dist/src/rlc-common/metadata/utils.js +1 -2
- package/dist/src/rlc-common/metadata/utils.js.map +1 -1
- package/dist/src/rlc-common/test/buildRecordedClient.js +2 -3
- package/dist/src/rlc-common/test/buildRecordedClient.js.map +1 -1
- package/dist/src/rlc-common/test/buildSampleTest.js +2 -3
- package/dist/src/rlc-common/test/buildSampleTest.js.map +1 -1
- package/dist/src/rlc-common/test/buildSnippets.js +4 -5
- package/dist/src/rlc-common/test/buildSnippets.js.map +1 -1
- package/dist/src/rlc-common/transformSampleGroups.js +23 -23
- package/dist/src/rlc-common/transformSampleGroups.js.map +1 -1
- package/dist/src/transform/transform.js +20 -18
- package/dist/src/transform/transform.js.map +1 -1
- package/dist/src/transform/transformApiVersionInfo.js +7 -7
- package/dist/src/transform/transformApiVersionInfo.js.map +1 -1
- package/dist/src/transform/transformHelperFunctionDetails.js +2 -3
- package/dist/src/transform/transformHelperFunctionDetails.js.map +1 -1
- package/dist/src/transform/transformParameters.js +15 -22
- package/dist/src/transform/transformParameters.js.map +1 -1
- package/dist/src/transform/transformPaths.js +9 -12
- package/dist/src/transform/transformPaths.js.map +1 -1
- package/dist/src/transform/transformResponses.js +10 -14
- package/dist/src/transform/transformResponses.js.map +1 -1
- package/dist/src/transform/transformSchemas.js +17 -22
- package/dist/src/transform/transformSchemas.js.map +1 -1
- package/dist/src/transform/transfromRLCOptions.js +23 -22
- package/dist/src/transform/transfromRLCOptions.js.map +1 -1
- package/dist/src/utils/clientUtils.js +6 -11
- package/dist/src/utils/clientUtils.js.map +1 -1
- package/dist/src/utils/credentialUtils.js +1 -2
- package/dist/src/utils/credentialUtils.js.map +1 -1
- package/dist/src/utils/crossLanguageDef.js +6 -6
- package/dist/src/utils/crossLanguageDef.js.map +1 -1
- package/dist/src/utils/emitUtil.js +1 -1
- package/dist/src/utils/emitUtil.js.map +1 -1
- package/dist/src/utils/fileSystemUtils.d.ts +2 -0
- package/dist/src/utils/fileSystemUtils.d.ts.map +1 -1
- package/dist/src/utils/fileSystemUtils.js +24 -5
- package/dist/src/utils/fileSystemUtils.js.map +1 -1
- package/dist/src/utils/importHelper.js +1 -2
- package/dist/src/utils/importHelper.js.map +1 -1
- package/dist/src/utils/modelUtils.js +78 -104
- package/dist/src/utils/modelUtils.js.map +1 -1
- package/dist/src/utils/namespaceUtils.js +4 -5
- package/dist/src/utils/namespaceUtils.js.map +1 -1
- package/dist/src/utils/operationUtil.js +38 -46
- package/dist/src/utils/operationUtil.js.map +1 -1
- package/dist/src/utils/parameterUtils.js +7 -11
- package/dist/src/utils/parameterUtils.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +38 -41
- package/src/index.ts +11 -10
- package/src/modular/buildRootIndex.ts +0 -1
- package/src/modular/emitSamples.ts +1 -3
- package/src/modular/helpers/exampleValueHelpers.ts +2 -6
- package/src/modular/serialization/serializeUtils.ts +0 -1
- package/src/rlc-common/buildClientDefinitions.ts +1 -0
- package/src/utils/fileSystemUtils.ts +29 -5
- package/static/static-helpers/pollingHelpers.ts +3 -3
- package/static/static-helpers/serialization/get-binary-response-browser.mts +3 -1
- package/static/static-helpers/serialization/get-binary-stream-response-browser.mts +1 -3
- package/static/static-helpers/serialization/xml-helpers.ts +1 -1
- package/static/static-helpers/simplePollerHelpers.ts +1 -1
|
@@ -78,7 +78,6 @@ export function getSendPrivateFunction(dpgContext, method, clientType, client) {
|
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
80
|
export function getDeserializePrivateFunction(context, method) {
|
|
81
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
82
81
|
const operation = method[1];
|
|
83
82
|
const { name } = getOperationName(operation);
|
|
84
83
|
const dependencies = useDependencies();
|
|
@@ -108,11 +107,11 @@ export function getDeserializePrivateFunction(context, method) {
|
|
|
108
107
|
returnType = buildLroReturnType(context, operation);
|
|
109
108
|
}
|
|
110
109
|
}
|
|
111
|
-
else if (isPagingOnly &&
|
|
110
|
+
else if (isPagingOnly && restResponse?.type) {
|
|
112
111
|
// For paging operations, use the full response model (e.g., _OperationListResult)
|
|
113
112
|
// instead of just the array element type
|
|
114
113
|
returnType = {
|
|
115
|
-
name:
|
|
114
|
+
name: restResponse.name ?? "",
|
|
116
115
|
type: getTypeExpression(context, restResponse.type)
|
|
117
116
|
};
|
|
118
117
|
}
|
|
@@ -128,7 +127,7 @@ export function getDeserializePrivateFunction(context, method) {
|
|
|
128
127
|
// the return type must include undefined to reflect that possibility.
|
|
129
128
|
const baseType = getTypeExpression(context, response.type);
|
|
130
129
|
returnType = {
|
|
131
|
-
name:
|
|
130
|
+
name: response.name ?? "",
|
|
132
131
|
type: response.optional ? `${baseType} | undefined` : baseType
|
|
133
132
|
};
|
|
134
133
|
}
|
|
@@ -160,12 +159,12 @@ export function getDeserializePrivateFunction(context, method) {
|
|
|
160
159
|
statements.push(`const expectedStatuses = ${getExpectedStatuses(operation)};`);
|
|
161
160
|
statements.push(`if(!expectedStatuses.includes(result.status)){`, `${getExceptionThrowStatement(context, operation)}`, "}");
|
|
162
161
|
const deserializedType = isLroOnly || isLroAndPaging
|
|
163
|
-
?
|
|
164
|
-
: isPagingOnly &&
|
|
162
|
+
? operation?.lroMetadata?.finalResponse?.result
|
|
163
|
+
: isPagingOnly && restResponse?.type
|
|
165
164
|
? restResponse.type
|
|
166
165
|
: response.type;
|
|
167
166
|
const lroSubSegments = isLroOnly
|
|
168
|
-
?
|
|
167
|
+
? operation?.lroMetadata?.finalResponse?.resultSegments
|
|
169
168
|
: undefined;
|
|
170
169
|
let lroSubPath;
|
|
171
170
|
if (lroSubSegments && lroSubSegments.length > 0) {
|
|
@@ -189,7 +188,7 @@ export function getDeserializePrivateFunction(context, method) {
|
|
|
189
188
|
// This only applies to non-LRO, non-paging operations where the deserialized type
|
|
190
189
|
// comes from response.type (not from LRO metadata or paging).
|
|
191
190
|
const needsBodyGuard = response.optional && !isLroOnly && !isLroAndPaging && !isPagingOnly;
|
|
192
|
-
const contentTypes =
|
|
191
|
+
const contentTypes = operation.operation.responses[0]?.contentTypes ?? [];
|
|
193
192
|
const isXml = isXmlPayload(contentTypes);
|
|
194
193
|
const isDualFormat = hasDualFormatSupport(contentTypes);
|
|
195
194
|
const isMultipart = isMultipartPayload(contentTypes);
|
|
@@ -337,10 +336,9 @@ export function getDeserializePrivateFunction(context, method) {
|
|
|
337
336
|
* or enable-storage-compat is enabled.
|
|
338
337
|
*/
|
|
339
338
|
export function getDeserializeHeadersPrivateFunction(context, operation) {
|
|
340
|
-
var _a, _b;
|
|
341
339
|
const responseHeaders = getResponseHeaders(operation.operation.responses);
|
|
342
|
-
const isResponseHeadersEnabled =
|
|
343
|
-
const isStorageCompatEnabled =
|
|
340
|
+
const isResponseHeadersEnabled = context.rlcOptions?.includeHeadersInResponse === true;
|
|
341
|
+
const isStorageCompatEnabled = context.rlcOptions?.enableStorageCompat === true;
|
|
344
342
|
// Only generate if headers exist and a relevant feature is enabled
|
|
345
343
|
if (responseHeaders.length === 0 ||
|
|
346
344
|
(!isResponseHeadersEnabled && !isStorageCompatEnabled)) {
|
|
@@ -371,7 +369,6 @@ export function getDeserializeHeadersPrivateFunction(context, operation) {
|
|
|
371
369
|
};
|
|
372
370
|
}
|
|
373
371
|
function getExceptionDetails(context, operation) {
|
|
374
|
-
var _a;
|
|
375
372
|
const customized = [];
|
|
376
373
|
let defaultDeserializer;
|
|
377
374
|
let defaultXmlDeserializer;
|
|
@@ -391,7 +388,7 @@ function getExceptionDetails(context, operation) {
|
|
|
391
388
|
}
|
|
392
389
|
// Check if the exception type has XML serialization support
|
|
393
390
|
// Use exception contentTypes when available, otherwise check the type itself
|
|
394
|
-
const exceptionContentTypes =
|
|
391
|
+
const exceptionContentTypes = exception.contentTypes ?? [];
|
|
395
392
|
const exceptionIsXml = isXmlPayload(exceptionContentTypes);
|
|
396
393
|
const exceptionIsDualFormat = hasDualFormatSupport(exceptionContentTypes);
|
|
397
394
|
const typeHasXml = exception.type.kind === "model" && hasXmlSerialization(exception.type);
|
|
@@ -443,13 +440,12 @@ function getExceptionDetails(context, operation) {
|
|
|
443
440
|
* Collects and deduplicates all response headers from operation exceptions.
|
|
444
441
|
*/
|
|
445
442
|
function getExceptionResponseHeaders(exceptions) {
|
|
446
|
-
var _a, _b;
|
|
447
443
|
const headerMap = new Map();
|
|
448
|
-
for (const exception of exceptions
|
|
449
|
-
for (const header of
|
|
444
|
+
for (const exception of exceptions ?? []) {
|
|
445
|
+
for (const header of exception.headers ?? []) {
|
|
450
446
|
if (shouldSkipHeaderSerialization(header))
|
|
451
447
|
continue;
|
|
452
|
-
const key =
|
|
448
|
+
const key = header.serializedName ?? header.name;
|
|
453
449
|
if (!headerMap.has(key)) {
|
|
454
450
|
headerMap.set(key, header);
|
|
455
451
|
}
|
|
@@ -462,8 +458,7 @@ function getExceptionResponseHeaders(exceptions) {
|
|
|
462
458
|
* Only generated when exception headers are present and include-headers-in-response is enabled.
|
|
463
459
|
*/
|
|
464
460
|
export function getDeserializeExceptionHeadersPrivateFunction(context, operation) {
|
|
465
|
-
|
|
466
|
-
const isResponseHeadersEnabled = ((_a = context.rlcOptions) === null || _a === void 0 ? void 0 : _a.includeHeadersInResponse) === true;
|
|
461
|
+
const isResponseHeadersEnabled = context.rlcOptions?.includeHeadersInResponse === true;
|
|
467
462
|
if (!isResponseHeadersEnabled) {
|
|
468
463
|
return undefined;
|
|
469
464
|
}
|
|
@@ -505,11 +500,10 @@ function getExceptionDeserializeExpr(exception) {
|
|
|
505
500
|
return `isXml ? ${exception.xmlDeserializer}(result.body) : ${exception.deserializer}(result.body)`;
|
|
506
501
|
}
|
|
507
502
|
function getExceptionThrowStatement(context, operation) {
|
|
508
|
-
var _a;
|
|
509
503
|
const statements = [];
|
|
510
504
|
const createRestErrorReference = resolveReference(useDependencies().createRestError);
|
|
511
505
|
const { customized, defaultDeserializer, defaultXmlDeserializer, defaultIsXmlOnly } = getExceptionDetails(context, operation);
|
|
512
|
-
const isResponseHeadersEnabled =
|
|
506
|
+
const isResponseHeadersEnabled = context.rlcOptions?.includeHeadersInResponse === true;
|
|
513
507
|
// Check if exception headers function exists and build the call
|
|
514
508
|
const exceptionHeaders = getExceptionResponseHeaders(operation.operation.exceptions);
|
|
515
509
|
const hasExceptionHeaders = isResponseHeadersEnabled && exceptionHeaders.length > 0;
|
|
@@ -605,7 +599,7 @@ function getExceptionThrowStatement(context, operation) {
|
|
|
605
599
|
function buildClientOptionHeadersCall(exceptions) {
|
|
606
600
|
const seenProperties = new Set();
|
|
607
601
|
const assignments = [];
|
|
608
|
-
for (const exception of exceptions
|
|
602
|
+
for (const exception of exceptions ?? []) {
|
|
609
603
|
if (!exception.type || exception.type.kind !== "model") {
|
|
610
604
|
continue;
|
|
611
605
|
}
|
|
@@ -628,7 +622,7 @@ function buildClientOptionHeadersCall(exceptions) {
|
|
|
628
622
|
* based on @clientOption("restErrorCodeHeader", ...) on exception model types.
|
|
629
623
|
*/
|
|
630
624
|
function buildRestErrorCodeAssignment(exceptions) {
|
|
631
|
-
for (const exception of exceptions
|
|
625
|
+
for (const exception of exceptions ?? []) {
|
|
632
626
|
if (!exception.type || exception.type.kind !== "model") {
|
|
633
627
|
continue;
|
|
634
628
|
}
|
|
@@ -641,29 +635,24 @@ if (restErrorCodeValue !== undefined) { error.code = restErrorCodeValue; }`;
|
|
|
641
635
|
return undefined;
|
|
642
636
|
}
|
|
643
637
|
function getOptionalParamsName(parameters) {
|
|
644
|
-
|
|
645
|
-
return ((_b = (_a = parameters.filter((p) => { var _a; return (_a = p.type) === null || _a === void 0 ? void 0 : _a.toString().endsWith("operationOptions__"); })[0]) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : "options");
|
|
638
|
+
return (parameters.filter((p) => p.type?.toString().endsWith("operationOptions__"))[0]?.name ?? "options");
|
|
646
639
|
}
|
|
647
640
|
function getOperationSignatureParameters(context, method, clientType) {
|
|
648
641
|
const operation = method[1];
|
|
649
642
|
const optionsType = resolveReference(refkey(method[1], "operationOptions"));
|
|
650
643
|
const parameters = new Map();
|
|
651
644
|
operation.parameters
|
|
652
|
-
.filter((p) =>
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
!(p.isGeneratedName &&
|
|
664
|
-
(p.name === "contentType" || p.name === "accept")) && // skip tcgc generated contentType and accept header parameter
|
|
665
|
-
getClientOptions(p, "headerCollectionPrefix") === undefined;
|
|
666
|
-
} // skip headers with collection prefix
|
|
645
|
+
.filter((p) => p.onClient === false &&
|
|
646
|
+
p.type.kind !== "constant" &&
|
|
647
|
+
operation.operation.parameters.filter((param) => {
|
|
648
|
+
return (param.methodParameterSegments.length === 1 &&
|
|
649
|
+
param.methodParameterSegments[0]?.length === 1 &&
|
|
650
|
+
param.methodParameterSegments[0]?.[0] === p);
|
|
651
|
+
})[0]?.kind !== "cookie" &&
|
|
652
|
+
!p.optional &&
|
|
653
|
+
!(p.isGeneratedName &&
|
|
654
|
+
(p.name === "contentType" || p.name === "accept")) && // skip tcgc generated contentType and accept header parameter
|
|
655
|
+
getClientOptions(p, "headerCollectionPrefix") === undefined // skip headers with collection prefix
|
|
667
656
|
)
|
|
668
657
|
.map((p) => {
|
|
669
658
|
return {
|
|
@@ -689,7 +678,6 @@ function getOperationSignatureParameters(context, method, clientType) {
|
|
|
689
678
|
* This operation builds and returns the function declaration for an operation.
|
|
690
679
|
*/
|
|
691
680
|
export function getOperationFunction(context, method, clientType) {
|
|
692
|
-
var _a, _b, _c, _d, _e;
|
|
693
681
|
const operation = method[1];
|
|
694
682
|
// Extract required parameters
|
|
695
683
|
const parameters = getOperationSignatureParameters(context, method, clientType);
|
|
@@ -710,8 +698,8 @@ export function getOperationFunction(context, method, clientType) {
|
|
|
710
698
|
const response = operation.response;
|
|
711
699
|
const responseHeaders = getResponseHeaders(operation.operation.responses);
|
|
712
700
|
const hasHeaderOnlyResponse = !response.type && responseHeaders.length > 0;
|
|
713
|
-
const isResponseHeadersEnabled =
|
|
714
|
-
const isStorageCompatEnabled =
|
|
701
|
+
const isResponseHeadersEnabled = context.rlcOptions?.includeHeadersInResponse === true;
|
|
702
|
+
const isStorageCompatEnabled = context.rlcOptions?.enableStorageCompat === true;
|
|
715
703
|
// Track the raw body type separately for storage-compat (before header merging)
|
|
716
704
|
const hasResponseBody = !!response.type;
|
|
717
705
|
let bodyType = "void";
|
|
@@ -738,7 +726,7 @@ export function getOperationFunction(context, method, clientType) {
|
|
|
738
726
|
// Build a composite type that includes both model and additional header properties
|
|
739
727
|
const baseCompositeType = buildCompositeResponseType(context, type, responseHeaders);
|
|
740
728
|
returnType = {
|
|
741
|
-
name:
|
|
729
|
+
name: type.name ?? "",
|
|
742
730
|
type: response.optional
|
|
743
731
|
? `${baseCompositeType} | undefined`
|
|
744
732
|
: baseCompositeType
|
|
@@ -747,7 +735,7 @@ export function getOperationFunction(context, method, clientType) {
|
|
|
747
735
|
else {
|
|
748
736
|
const baseType = getTypeExpression(context, type);
|
|
749
737
|
returnType = {
|
|
750
|
-
name:
|
|
738
|
+
name: type.name ?? "",
|
|
751
739
|
type: response.optional ? `${baseType} | undefined` : baseType
|
|
752
740
|
};
|
|
753
741
|
}
|
|
@@ -824,7 +812,7 @@ export function getOperationFunction(context, method, clientType) {
|
|
|
824
812
|
// doing a UTF-8 decode on the raw bytes.
|
|
825
813
|
// For binary wrap, use getBinaryStreamResponse which preserves blobBody/readableStreamBody properties.
|
|
826
814
|
// For non-wrapped binary, use getBinaryResponse which buffers the body into Uint8Array.
|
|
827
|
-
if (
|
|
815
|
+
if (response?.type?.kind === "bytes" && response.type.encode === "bytes") {
|
|
828
816
|
const streamableMethodVarName = generateLocallyUniqueName("streamableMethod", paramNames);
|
|
829
817
|
statements.push(`const ${streamableMethodVarName} = _${name}Send(${sendParameterList});`);
|
|
830
818
|
const binaryHelper = wrapReturn && wrapReturnIsBinary
|
|
@@ -921,9 +909,9 @@ function getLroOnlyOperationFunction(context, method, clientType, optionalParamN
|
|
|
921
909
|
"original-uri",
|
|
922
910
|
"operation-location"
|
|
923
911
|
];
|
|
924
|
-
const resourceLocationConfig =
|
|
925
|
-
allowedFinalLocation.includes(lroMetadata
|
|
926
|
-
? `resourceLocationConfig: "${lroMetadata
|
|
912
|
+
const resourceLocationConfig = lroMetadata?.finalStateVia &&
|
|
913
|
+
allowedFinalLocation.includes(lroMetadata?.finalStateVia)
|
|
914
|
+
? `resourceLocationConfig: "${lroMetadata?.finalStateVia}",`
|
|
927
915
|
: "";
|
|
928
916
|
const apiVersion = getApiVersionExpression(context, operation);
|
|
929
917
|
const statements = [];
|
|
@@ -945,7 +933,6 @@ function getLroOnlyOperationFunction(context, method, clientType, optionalParamN
|
|
|
945
933
|
};
|
|
946
934
|
}
|
|
947
935
|
function getLroAndPagingOperationFunction(context, method, clientType, optionalParamName = "options") {
|
|
948
|
-
var _a;
|
|
949
936
|
const operation = method[1];
|
|
950
937
|
const parameters = getOperationSignatureParameters(context, method, clientType);
|
|
951
938
|
const { name, fixme = [] } = getOperationName(operation, context);
|
|
@@ -969,7 +956,7 @@ function getLroAndPagingOperationFunction(context, method, clientType, optionalP
|
|
|
969
956
|
"original-uri",
|
|
970
957
|
"operation-location"
|
|
971
958
|
];
|
|
972
|
-
const resourceLocationConfig =
|
|
959
|
+
const resourceLocationConfig = operation.lroMetadata?.finalStateVia &&
|
|
973
960
|
allowedLocations.includes(operation.lroMetadata.finalStateVia)
|
|
974
961
|
? `resourceLocationConfig: "${operation.lroMetadata.finalStateVia}",`
|
|
975
962
|
: "";
|
|
@@ -1033,17 +1020,15 @@ function buildLroReturnType(context, operation) {
|
|
|
1033
1020
|
return { name: "", type: "void" };
|
|
1034
1021
|
}
|
|
1035
1022
|
function buildLroPagingReturnType(context, operation) {
|
|
1036
|
-
|
|
1037
|
-
if (((_a = operation.response.type) === null || _a === void 0 ? void 0 : _a.kind) === "array") {
|
|
1023
|
+
if (operation.response.type?.kind === "array") {
|
|
1038
1024
|
return {
|
|
1039
|
-
name:
|
|
1025
|
+
name: operation.response.type.valueType.name ?? "",
|
|
1040
1026
|
type: getTypeExpression(context, operation.response.type.valueType)
|
|
1041
1027
|
};
|
|
1042
1028
|
}
|
|
1043
1029
|
return { name: "", type: "void" };
|
|
1044
1030
|
}
|
|
1045
1031
|
function getPagingOnlyOperationFunction(context, method, clientType) {
|
|
1046
|
-
var _a;
|
|
1047
1032
|
const operation = method[1];
|
|
1048
1033
|
// Extract required parameters
|
|
1049
1034
|
const parameters = getOperationSignatureParameters(context, method, clientType);
|
|
@@ -1053,7 +1038,7 @@ function getPagingOnlyOperationFunction(context, method, clientType) {
|
|
|
1053
1038
|
if (response.type && response.type.kind === "array") {
|
|
1054
1039
|
const type = response.type;
|
|
1055
1040
|
returnType = {
|
|
1056
|
-
name:
|
|
1041
|
+
name: type.valueType.name ?? "",
|
|
1057
1042
|
type: getTypeExpression(context, type.valueType)
|
|
1058
1043
|
};
|
|
1059
1044
|
}
|
|
@@ -1077,13 +1062,17 @@ function getPagingOnlyOperationFunction(context, method, clientType) {
|
|
|
1077
1062
|
const options = [];
|
|
1078
1063
|
// TODO: follow up on https://github.com/Azure/typespec-azure/issues/2103
|
|
1079
1064
|
const nextLinkSegments = operation.pagingMetadata.nextLinkSegments;
|
|
1080
|
-
const nextLinkName = nextLinkSegments
|
|
1065
|
+
const nextLinkName = nextLinkSegments
|
|
1066
|
+
?.map((property) => {
|
|
1081
1067
|
return property.name;
|
|
1082
|
-
})
|
|
1068
|
+
})
|
|
1069
|
+
.join(".");
|
|
1083
1070
|
const itemSegments = operation.response.resultSegments;
|
|
1084
|
-
const itemName = itemSegments
|
|
1071
|
+
const itemName = itemSegments
|
|
1072
|
+
?.map((property) => {
|
|
1085
1073
|
return property.name;
|
|
1086
|
-
})
|
|
1074
|
+
})
|
|
1075
|
+
.join(".");
|
|
1087
1076
|
// Check for nextLinkVerb from TCGC pagingMetadata (supports @Legacy.nextLinkVerb decorator)
|
|
1088
1077
|
const nextLinkMethod = operation.pagingMetadata.nextLinkVerb;
|
|
1089
1078
|
const apiVersion = getApiVersionExpression(context, operation);
|
|
@@ -1276,9 +1265,8 @@ function buildBodyParameter(context, bodyParameter, optionalParamName = "options
|
|
|
1276
1265
|
return `\nbody: ${serializedBody.startsWith(nullOrUndefinedPrefix) ? "" : nullOrUndefinedPrefix}${serializedBody},`;
|
|
1277
1266
|
}
|
|
1278
1267
|
function getEncodingFormat(type) {
|
|
1279
|
-
var _a;
|
|
1280
1268
|
const supportedFormats = ["base64url", "base64", "byte"];
|
|
1281
|
-
if (!supportedFormats.includes(
|
|
1269
|
+
if (!supportedFormats.includes(type.format ?? "")) {
|
|
1282
1270
|
return "base64";
|
|
1283
1271
|
}
|
|
1284
1272
|
return type.format;
|
|
@@ -1287,7 +1275,6 @@ function getEncodingFormat(type) {
|
|
|
1287
1275
|
* This function helps with renames, translating client names to rest api names
|
|
1288
1276
|
*/
|
|
1289
1277
|
export function getParameterMap(context, param, paramAccessor) {
|
|
1290
|
-
var _a;
|
|
1291
1278
|
// Use lowercase for header names since HTTP headers are case-insensitive
|
|
1292
1279
|
const serializedName = param.kind === "header"
|
|
1293
1280
|
? getHeaderSerializedName(param)
|
|
@@ -1298,7 +1285,7 @@ export function getParameterMap(context, param, paramAccessor) {
|
|
|
1298
1285
|
// Special case for api-version parameters with default values
|
|
1299
1286
|
if (param.isApiVersionParam && param.clientDefaultValue) {
|
|
1300
1287
|
// For multi-service, use only the default value (don't reference context.apiVersion)
|
|
1301
|
-
if (
|
|
1288
|
+
if (context.rlcOptions?.isMultiService) {
|
|
1302
1289
|
return `"${serializedName}": "${param.clientDefaultValue}"`;
|
|
1303
1290
|
}
|
|
1304
1291
|
return `"${serializedName}": ${param.onClient ? "context." : ""}${param.name} ?? "${param.clientDefaultValue}"`;
|
|
@@ -1355,15 +1342,14 @@ function getContentTypeValue(param, optionalParamName = "options") {
|
|
|
1355
1342
|
* For client-level parameters (onClient), preserve the HTTP parameter's own flag.
|
|
1356
1343
|
*/
|
|
1357
1344
|
function getEffectiveOptional(param) {
|
|
1358
|
-
var _a, _b;
|
|
1359
1345
|
// For client-level parameters, the HTTP parameter's optional flag is authoritative
|
|
1360
1346
|
if (param.onClient) {
|
|
1361
1347
|
return Boolean(param.optional);
|
|
1362
1348
|
}
|
|
1363
1349
|
// For method-level parameters with a direct mapping to a single method param,
|
|
1364
1350
|
// use the method parameter's optional flag (correctly reflects @@override changes)
|
|
1365
|
-
if (
|
|
1366
|
-
|
|
1351
|
+
if (param.methodParameterSegments?.length === 1 &&
|
|
1352
|
+
param.methodParameterSegments[0]?.length === 1) {
|
|
1367
1353
|
const methodParam = param.methodParameterSegments[0][0];
|
|
1368
1354
|
if (methodParam) {
|
|
1369
1355
|
return Boolean(methodParam.optional);
|
|
@@ -1428,14 +1414,13 @@ function getDefaultValue(param) {
|
|
|
1428
1414
|
* Extracts the path parameters
|
|
1429
1415
|
*/
|
|
1430
1416
|
function getPathParameters(operation, optionalParamName = "options") {
|
|
1431
|
-
var _a;
|
|
1432
1417
|
if (!operation.operation.parameters) {
|
|
1433
1418
|
return [];
|
|
1434
1419
|
}
|
|
1435
1420
|
const pathParams = [];
|
|
1436
1421
|
for (const param of operation.operation.parameters) {
|
|
1437
1422
|
if (param.kind === "path") {
|
|
1438
|
-
const methodParam =
|
|
1423
|
+
const methodParam = param.methodParameterSegments[0]?.[0];
|
|
1439
1424
|
if (methodParam) {
|
|
1440
1425
|
pathParams.push(`"${param.serializedName}": ${getPathParamExpr(param, getDefaultValue(param), optionalParamName)}`);
|
|
1441
1426
|
}
|
|
@@ -1654,10 +1639,9 @@ export function getSerializationExpression(context, property, propertyPath, enab
|
|
|
1654
1639
|
}
|
|
1655
1640
|
}
|
|
1656
1641
|
export function getRequestModelProperties(context, modelPropertyType, propertyPath = "body", overrides, enableFlatten = true) {
|
|
1657
|
-
var _a;
|
|
1658
1642
|
const props = [];
|
|
1659
1643
|
const allParents = getAllAncestors(modelPropertyType);
|
|
1660
|
-
const properties =
|
|
1644
|
+
const properties = getAllProperties(context, modelPropertyType, allParents) ?? [];
|
|
1661
1645
|
if (properties.length <= 0) {
|
|
1662
1646
|
return [];
|
|
1663
1647
|
}
|
|
@@ -1685,10 +1669,9 @@ export function getRequestModelMapping(context, modelPropertyType, propertyPath
|
|
|
1685
1669
|
return getRequestModelProperties(context, modelPropertyType, propertyPath, overrides, enableFlatten).map(([name, value]) => `"${name}": ${value}`);
|
|
1686
1670
|
}
|
|
1687
1671
|
export function getPropertySerializedName(property) {
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
: property.serializedName)) !== null && _b !== void 0 ? _b : property.name);
|
|
1672
|
+
return ((property.kind === "property"
|
|
1673
|
+
? property.serializationOptions.json?.name
|
|
1674
|
+
: property.serializedName) ?? property.name);
|
|
1692
1675
|
}
|
|
1693
1676
|
/**
|
|
1694
1677
|
* Get the serialized name for a header parameter, normalized to lowercase.
|
|
@@ -1750,7 +1733,6 @@ export function getResponseMapping(context, type, propertyPath = "result.body",
|
|
|
1750
1733
|
* Converts JavaScript values to their serialized wire format for HTTP requests.
|
|
1751
1734
|
*/
|
|
1752
1735
|
export function serializeRequestValue(context, type, clientValue, required, format, serializedName, isTopLevel = false) {
|
|
1753
|
-
var _a, _b, _c, _d, _e;
|
|
1754
1736
|
const getSdkType = useSdkTypes();
|
|
1755
1737
|
const dependencies = useDependencies();
|
|
1756
1738
|
const nullOrUndefinedPrefix = isTypeNullable(type) || getOptionalForType(type) || !required
|
|
@@ -1761,7 +1743,7 @@ export function serializeRequestValue(context, type, clientValue, required, form
|
|
|
1761
1743
|
// plainDate always uses ISO8601 format (YYYY-MM-DD)
|
|
1762
1744
|
return `${nullOrUndefinedPrefix}${clientValue}.toISOString().split('T')[0]`;
|
|
1763
1745
|
case "utcDateTime":
|
|
1764
|
-
switch (
|
|
1746
|
+
switch (type.encode ?? format) {
|
|
1765
1747
|
case "rfc7231":
|
|
1766
1748
|
return `${nullOrUndefinedPrefix}${clientValue}.toUTCString()`;
|
|
1767
1749
|
case "unixTimestamp":
|
|
@@ -1791,7 +1773,7 @@ export function serializeRequestValue(context, type, clientValue, required, form
|
|
|
1791
1773
|
if (format) {
|
|
1792
1774
|
const formatHelper = getCollectionFormatHelper(format);
|
|
1793
1775
|
if (formatHelper) {
|
|
1794
|
-
if (
|
|
1776
|
+
if (format?.toLowerCase() === KnownCollectionFormat.Multi) {
|
|
1795
1777
|
return `${nullOrUndefinedPrefix}${formatHelper}(${serializedValue}, "${serializedName}")`;
|
|
1796
1778
|
}
|
|
1797
1779
|
return `${nullOrUndefinedPrefix}${formatHelper}(${serializedValue})`;
|
|
@@ -1807,8 +1789,8 @@ export function serializeRequestValue(context, type, clientValue, required, form
|
|
|
1807
1789
|
if (format !== "binary" && format !== "bytes") {
|
|
1808
1790
|
const uint8ArrayToStringReference = resolveReference(dependencies.uint8ArrayToString);
|
|
1809
1791
|
return required
|
|
1810
|
-
? `${getNullableCheck(clientValue, type)} ${uint8ArrayToStringReference}(${clientValue}, "${
|
|
1811
|
-
: `${nullOrUndefinedPrefix} ${uint8ArrayToStringReference}(${clientValue}, "${
|
|
1792
|
+
? `${getNullableCheck(clientValue, type)} ${uint8ArrayToStringReference}(${clientValue}, "${getEncodingFormat({ format }) ?? "base64"}")`
|
|
1793
|
+
: `${nullOrUndefinedPrefix} ${uint8ArrayToStringReference}(${clientValue}, "${getEncodingFormat({ format }) ?? "base64"}")`;
|
|
1812
1794
|
}
|
|
1813
1795
|
return clientValue;
|
|
1814
1796
|
case "union":
|
|
@@ -1817,7 +1799,7 @@ export function serializeRequestValue(context, type, clientValue, required, form
|
|
|
1817
1799
|
}
|
|
1818
1800
|
else if (isSpecialHandledUnion({
|
|
1819
1801
|
...type,
|
|
1820
|
-
isNonExhaustive:
|
|
1802
|
+
isNonExhaustive: context.rlcOptions?.experimentalExtensibleEnums ?? false
|
|
1821
1803
|
})) {
|
|
1822
1804
|
const sdkType = getSdkType(type.__raw);
|
|
1823
1805
|
const serializerRefkey = refkey(sdkType, "serializer");
|
|
@@ -1993,7 +1975,7 @@ export function deserializeResponseValue(context, type, restValue, required, for
|
|
|
1993
1975
|
case "bytes":
|
|
1994
1976
|
if (format !== "binary" && format !== "bytes") {
|
|
1995
1977
|
return `${nullOrUndefinedPrefix}typeof ${restValue} === 'string'
|
|
1996
|
-
? ${stringToUint8ArrayReference}(${restValue}, "${format
|
|
1978
|
+
? ${stringToUint8ArrayReference}(${restValue}, "${format ?? "base64"}")
|
|
1997
1979
|
: ${restValue}`;
|
|
1998
1980
|
}
|
|
1999
1981
|
return restValue;
|
|
@@ -2040,7 +2022,7 @@ export function getAllProperties(context, type, parents) {
|
|
|
2040
2022
|
if (!type) {
|
|
2041
2023
|
return [];
|
|
2042
2024
|
}
|
|
2043
|
-
parents
|
|
2025
|
+
parents?.forEach((p) => {
|
|
2044
2026
|
getAllProperties(context, p).forEach((prop) => {
|
|
2045
2027
|
propertiesMap.set(prop.name, prop);
|
|
2046
2028
|
});
|
|
@@ -2165,13 +2147,12 @@ export function getExpectedStatuses(operation) {
|
|
|
2165
2147
|
* @returns The apiVersion expression string, or undefined if no apiVersion query param exists
|
|
2166
2148
|
*/
|
|
2167
2149
|
function getApiVersionExpression(dpgContext, operation) {
|
|
2168
|
-
var _a;
|
|
2169
2150
|
const queryApiVersionParam = operation.operation.parameters.find((p) => p.kind === "query" && p.isApiVersionParam);
|
|
2170
2151
|
if (!queryApiVersionParam) {
|
|
2171
2152
|
return undefined;
|
|
2172
2153
|
}
|
|
2173
2154
|
// For multi-service, use only the default value (don't reference context.apiVersion)
|
|
2174
|
-
if (
|
|
2155
|
+
if (dpgContext.rlcOptions?.isMultiService) {
|
|
2175
2156
|
return queryApiVersionParam.clientDefaultValue
|
|
2176
2157
|
? `"${queryApiVersionParam.clientDefaultValue}"`
|
|
2177
2158
|
: undefined;
|
|
@@ -2188,13 +2169,12 @@ function getApiVersionExpression(dpgContext, operation) {
|
|
|
2188
2169
|
* @returns Array of unique response headers
|
|
2189
2170
|
*/
|
|
2190
2171
|
export function getResponseHeaders(responses) {
|
|
2191
|
-
var _a, _b;
|
|
2192
2172
|
const headerMap = new Map();
|
|
2193
|
-
for (const response of responses
|
|
2194
|
-
for (const header of
|
|
2173
|
+
for (const response of responses ?? []) {
|
|
2174
|
+
for (const header of response.headers ?? []) {
|
|
2195
2175
|
if (shouldSkipHeaderSerialization(header))
|
|
2196
2176
|
continue;
|
|
2197
|
-
const key =
|
|
2177
|
+
const key = header.serializedName ?? header.name;
|
|
2198
2178
|
if (!headerMap.has(key)) {
|
|
2199
2179
|
headerMap.set(key, header);
|
|
2200
2180
|
}
|
|
@@ -2262,8 +2242,7 @@ function buildHeaderOnlyResponseType(context, headers) {
|
|
|
2262
2242
|
*/
|
|
2263
2243
|
function buildHeaderOnlyResponseValue(context, headers) {
|
|
2264
2244
|
const props = headers.map((header) => {
|
|
2265
|
-
|
|
2266
|
-
const headerName = ((_a = header.serializedName) !== null && _a !== void 0 ? _a : header.name).toLowerCase();
|
|
2245
|
+
const headerName = (header.serializedName ?? header.name).toLowerCase();
|
|
2267
2246
|
const key = normalizeModelPropertyName(context, header);
|
|
2268
2247
|
const value = deserializeResponseHeadersValue(context, header.type, `result.headers[${JSON.stringify(headerName)}]`, !header.optional, getEncodeForType(header.type), 0);
|
|
2269
2248
|
return `${key}: ${value}`;
|
|
@@ -2302,12 +2281,11 @@ export function getOperationResponseTypeName(method) {
|
|
|
2302
2281
|
* - any / unknown (no treatAsRecord) → HLC PropertyKind.Primitive
|
|
2303
2282
|
*/
|
|
2304
2283
|
function isWrappableType(context, type) {
|
|
2305
|
-
var _a;
|
|
2306
2284
|
if (type.kind === "array" && type.valueType.kind === "model")
|
|
2307
2285
|
return false;
|
|
2308
2286
|
if (type.kind === "dict" || type.kind === "model")
|
|
2309
2287
|
return false;
|
|
2310
|
-
if (type.kind === "unknown" &&
|
|
2288
|
+
if (type.kind === "unknown" && context.rlcOptions?.treatUnknownAsRecord)
|
|
2311
2289
|
return false;
|
|
2312
2290
|
return true;
|
|
2313
2291
|
}
|
|
@@ -2318,11 +2296,10 @@ function isHeadOperation(operation) {
|
|
|
2318
2296
|
return operation.operation.verb.toLowerCase() === "head";
|
|
2319
2297
|
}
|
|
2320
2298
|
function isHeadAsBooleanOperation(operation) {
|
|
2321
|
-
var _a;
|
|
2322
2299
|
if (!isHeadOperation(operation))
|
|
2323
2300
|
return false;
|
|
2324
2301
|
// @responseAsBool: TCGC promotes response.type to SdkBuiltInType { kind: "boolean" }
|
|
2325
|
-
if (
|
|
2302
|
+
if (operation.response.type?.kind === "boolean")
|
|
2326
2303
|
return true;
|
|
2327
2304
|
return false;
|
|
2328
2305
|
}
|
|
@@ -2331,19 +2308,18 @@ function isHeadAsBooleanOperation(operation) {
|
|
|
2331
2308
|
* Returns an object with `shouldWrap` (whether to wrap) and `isBinary` (whether it's a binary response).
|
|
2332
2309
|
*/
|
|
2333
2310
|
export function checkWrapNonModelReturn(context, operation) {
|
|
2334
|
-
var _a, _b, _c, _d, _e;
|
|
2335
2311
|
const noWrap = { shouldWrap: false, isBinary: false };
|
|
2336
2312
|
// LRO+paging and paging-only operations are not wrapped
|
|
2337
2313
|
if (isLroAndPagingOperation(operation) || isPagingOnlyOperation(operation)) {
|
|
2338
2314
|
return noWrap;
|
|
2339
2315
|
}
|
|
2340
2316
|
// Only if the feature flag is enabled
|
|
2341
|
-
if (!
|
|
2317
|
+
if (!context.rlcOptions?.wrapNonModelReturn) {
|
|
2342
2318
|
return noWrap;
|
|
2343
2319
|
}
|
|
2344
2320
|
// For LRO-only operations, check the final result type from LRO metadata
|
|
2345
2321
|
if (isLroOnlyOperation(operation)) {
|
|
2346
|
-
const lroResultType =
|
|
2322
|
+
const lroResultType = operation.lroMetadata?.finalResponse?.result;
|
|
2347
2323
|
if (!lroResultType) {
|
|
2348
2324
|
return noWrap; // void LRO - no wrap needed
|
|
2349
2325
|
}
|
|
@@ -2360,7 +2336,7 @@ export function checkWrapNonModelReturn(context, operation) {
|
|
|
2360
2336
|
}
|
|
2361
2337
|
return noWrap; // void return type - no wrap needed
|
|
2362
2338
|
}
|
|
2363
|
-
const contentTypes =
|
|
2339
|
+
const contentTypes = operation.operation.responses[0]?.contentTypes ?? [];
|
|
2364
2340
|
// bytes with binary content type → binary wrap (isBinary=true)
|
|
2365
2341
|
// HLC: bytes → binary payload → separate binary handling
|
|
2366
2342
|
if (type.__raw &&
|