@azure-tools/typespec-ts 0.30.1 → 0.31.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 +19 -0
- package/dist/src/contextManager.d.ts +4 -0
- package/dist/src/contextManager.d.ts.map +1 -1
- package/dist/src/contextManager.js.map +1 -1
- package/dist/src/framework/declaration.d.ts +9 -0
- package/dist/src/framework/declaration.d.ts.map +1 -0
- package/dist/src/framework/declaration.js +28 -0
- package/dist/src/framework/declaration.js.map +1 -0
- package/dist/src/framework/hooks/binder.d.ts +25 -0
- package/dist/src/framework/hooks/binder.d.ts.map +1 -0
- package/dist/src/framework/hooks/binder.js +168 -0
- package/dist/src/framework/hooks/binder.js.map +1 -0
- package/dist/src/framework/hooks/sdkTypes.d.ts +12 -0
- package/dist/src/framework/hooks/sdkTypes.d.ts.map +1 -0
- package/dist/src/framework/hooks/sdkTypes.js +67 -0
- package/dist/src/framework/hooks/sdkTypes.js.map +1 -0
- package/dist/src/framework/reference.d.ts +2 -0
- package/dist/src/framework/reference.d.ts.map +1 -0
- package/dist/src/framework/reference.js +8 -0
- package/dist/src/framework/reference.js.map +1 -0
- package/dist/src/framework/refkey.d.ts +7 -0
- package/dist/src/framework/refkey.d.ts.map +1 -0
- package/dist/src/framework/refkey.js +22 -0
- package/dist/src/framework/refkey.js.map +1 -0
- package/dist/src/framework/sample.d.ts +2 -0
- package/dist/src/framework/sample.d.ts.map +1 -0
- package/dist/src/framework/sample.js +71 -0
- package/dist/src/framework/sample.js.map +1 -0
- package/dist/src/framework/utils/tsmorph-helpers.d.ts +2 -0
- package/dist/src/framework/utils/tsmorph-helpers.d.ts.map +1 -0
- package/dist/src/framework/utils/tsmorph-helpers.js +2 -0
- package/dist/src/framework/utils/tsmorph-helpers.js.map +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +7 -8
- 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 +6 -0
- package/dist/src/lib.js.map +1 -1
- package/dist/src/modular/buildClassicalClient.d.ts.map +1 -1
- package/dist/src/modular/buildClassicalClient.js +6 -5
- package/dist/src/modular/buildClassicalClient.js.map +1 -1
- package/dist/src/modular/buildClientContext.d.ts.map +1 -1
- package/dist/src/modular/buildClientContext.js +8 -4
- package/dist/src/modular/buildClientContext.js.map +1 -1
- package/dist/src/modular/buildCodeModel.d.ts.map +1 -1
- package/dist/src/modular/buildCodeModel.js +22 -11
- package/dist/src/modular/buildCodeModel.js.map +1 -1
- package/dist/src/modular/buildOperations.d.ts +1 -2
- package/dist/src/modular/buildOperations.d.ts.map +1 -1
- package/dist/src/modular/buildOperations.js +3 -9
- package/dist/src/modular/buildOperations.js.map +1 -1
- package/dist/src/modular/buildRootIndex.js +1 -1
- package/dist/src/modular/buildRootIndex.js.map +1 -1
- package/dist/src/modular/buildSerializeUtils.d.ts.map +1 -1
- package/dist/src/modular/buildSerializeUtils.js +2 -1
- package/dist/src/modular/buildSerializeUtils.js.map +1 -1
- package/dist/src/modular/helpers/clientHelpers.d.ts +4 -0
- package/dist/src/modular/helpers/clientHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/clientHelpers.js +15 -1
- package/dist/src/modular/helpers/clientHelpers.js.map +1 -1
- package/dist/src/modular/helpers/namingHelpers.d.ts +1 -0
- package/dist/src/modular/helpers/namingHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/namingHelpers.js +3 -1
- package/dist/src/modular/helpers/namingHelpers.js.map +1 -1
- package/dist/src/modular/helpers/operationHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/operationHelpers.js +60 -40
- package/dist/src/modular/helpers/operationHelpers.js.map +1 -1
- package/dist/src/modular/helpers/typeHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/typeHelpers.js +6 -1
- package/dist/src/modular/helpers/typeHelpers.js.map +1 -1
- package/dist/src/modular/modularCodeModel.d.ts +2 -0
- package/dist/src/modular/modularCodeModel.d.ts.map +1 -1
- package/dist/src/transform/transformApiVersionInfo.d.ts.map +1 -1
- package/dist/src/transform/transformApiVersionInfo.js +3 -5
- package/dist/src/transform/transformApiVersionInfo.js.map +1 -1
- package/dist/src/transform/transformHelperFunctionDetails.d.ts.map +1 -1
- package/dist/src/transform/transformHelperFunctionDetails.js +7 -10
- package/dist/src/transform/transformHelperFunctionDetails.js.map +1 -1
- package/dist/src/transform/transformParameters.d.ts.map +1 -1
- package/dist/src/transform/transformParameters.js +5 -7
- package/dist/src/transform/transformParameters.js.map +1 -1
- package/dist/src/transform/transformPaths.d.ts.map +1 -1
- package/dist/src/transform/transformPaths.js +4 -6
- package/dist/src/transform/transformPaths.js.map +1 -1
- package/dist/src/transform/transformResponses.d.ts.map +1 -1
- package/dist/src/transform/transformResponses.js +70 -16
- 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 +5 -6
- 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 -6
- 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 +5 -6
- package/dist/src/transform/transfromRLCOptions.js.map +1 -1
- package/dist/src/utils/modelUtils.d.ts +3 -3
- package/dist/src/utils/modelUtils.d.ts.map +1 -1
- package/dist/src/utils/modelUtils.js +42 -24
- package/dist/src/utils/modelUtils.js.map +1 -1
- package/dist/src/utils/operationUtil.d.ts +2 -2
- package/dist/src/utils/operationUtil.d.ts.map +1 -1
- package/dist/src/utils/operationUtil.js +5 -7
- package/dist/src/utils/operationUtil.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +23 -23
- package/src/contextManager.ts +4 -0
- package/src/framework/declaration.ts +100 -0
- package/src/framework/hooks/binder.ts +259 -0
- package/src/framework/hooks/sdkTypes.ts +101 -0
- package/src/framework/reference.ts +9 -0
- package/src/framework/refkey.ts +28 -0
- package/src/framework/sample.ts +92 -0
- package/src/framework/utils/tsmorph-helpers.ts +0 -0
- package/src/index.ts +8 -10
- package/src/lib.ts +6 -0
- package/src/modular/buildClassicalClient.ts +11 -4
- package/src/modular/buildClientContext.ts +11 -5
- package/src/modular/buildCodeModel.ts +25 -21
- package/src/modular/buildOperations.ts +13 -41
- package/src/modular/buildRootIndex.ts +1 -1
- package/src/modular/buildSerializeUtils.ts +2 -1
- package/src/modular/helpers/clientHelpers.ts +25 -1
- package/src/modular/helpers/namingHelpers.ts +4 -1
- package/src/modular/helpers/operationHelpers.ts +86 -45
- package/src/modular/helpers/typeHelpers.ts +6 -1
- package/src/modular/modularCodeModel.ts +2 -0
- package/src/transform/transformApiVersionInfo.ts +3 -6
- package/src/transform/transformHelperFunctionDetails.ts +9 -9
- package/src/transform/transformParameters.ts +5 -6
- package/src/transform/transformPaths.ts +5 -9
- package/src/transform/transformResponses.ts +92 -19
- package/src/transform/transformSchemas.ts +6 -5
- package/src/transform/transformTelemetryInfo.ts +3 -5
- package/src/transform/transfromRLCOptions.ts +5 -10
- package/src/utils/modelUtils.ts +49 -39
- package/src/utils/operationUtil.ts +6 -12
- package/dist/src/modular/serialization/collectionUtils.d.ts +0 -3
- package/dist/src/modular/serialization/collectionUtils.d.ts.map +0 -1
- package/dist/src/modular/serialization/collectionUtils.js +0 -17
- package/dist/src/modular/serialization/collectionUtils.js.map +0 -1
- package/dist/src/modular/serialization/index.d.ts +0 -5
- package/dist/src/modular/serialization/index.d.ts.map +0 -1
- package/dist/src/modular/serialization/index.js +0 -155
- package/dist/src/modular/serialization/index.js.map +0 -1
- package/dist/src/modular/serialization/operationHelpers.d.ts +0 -37
- package/dist/src/modular/serialization/operationHelpers.d.ts.map +0 -1
- package/dist/src/modular/serialization/operationHelpers.js +0 -457
- package/dist/src/modular/serialization/operationHelpers.js.map +0 -1
- package/dist/src/modular/serialization/serializeArray.d.ts +0 -5
- package/dist/src/modular/serialization/serializeArray.d.ts.map +0 -1
- package/dist/src/modular/serialization/serializeArray.js +0 -33
- package/dist/src/modular/serialization/serializeArray.js.map +0 -1
- package/dist/src/modular/serialization/serializeDateTime.d.ts +0 -4
- package/dist/src/modular/serialization/serializeDateTime.d.ts.map +0 -1
- package/dist/src/modular/serialization/serializeDateTime.js +0 -19
- package/dist/src/modular/serialization/serializeDateTime.js.map +0 -1
- package/dist/src/modular/serialization/serializeHeaders.d.ts +0 -7
- package/dist/src/modular/serialization/serializeHeaders.d.ts.map +0 -1
- package/dist/src/modular/serialization/serializeHeaders.js +0 -44
- package/dist/src/modular/serialization/serializeHeaders.js.map +0 -1
- package/dist/src/modular/serialization/serializers.d.ts +0 -17
- package/dist/src/modular/serialization/serializers.d.ts.map +0 -1
- package/dist/src/modular/serialization/serializers.js +0 -175
- package/dist/src/modular/serialization/serializers.js.map +0 -1
- package/dist/src/modular/serialization/util.d.ts +0 -27
- package/dist/src/modular/serialization/util.d.ts.map +0 -1
- package/dist/src/modular/serialization/util.js +0 -115
- package/dist/src/modular/serialization/util.js.map +0 -1
- package/dist/src/reify/index.d.ts +0 -12
- package/dist/src/reify/index.d.ts.map +0 -1
- package/dist/src/reify/index.js +0 -22
- package/dist/src/reify/index.js.map +0 -1
- package/src/modular/serialization/collectionUtils.ts +0 -20
- package/src/modular/serialization/index.ts +0 -267
- package/src/modular/serialization/operationHelpers.ts +0 -659
- package/src/modular/serialization/serializeArray.ts +0 -51
- package/src/modular/serialization/serializeDateTime.ts +0 -22
- package/src/modular/serialization/serializeHeaders.ts +0 -64
- package/src/modular/serialization/serializers.ts +0 -304
- package/src/modular/serialization/util.ts +0 -171
- package/src/modular/static/karma.conf.cjs +0 -120
- package/src/reify/index.ts +0 -41
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
|
|
4
4
|
import { SchemaContext } from "@azure-tools/rlc-common";
|
|
5
5
|
import {
|
|
6
|
+
getHttpOperationWithCache,
|
|
6
7
|
listOperationGroups,
|
|
7
8
|
listOperationsInOperationGroup,
|
|
8
9
|
SdkClient
|
|
9
10
|
} from "@azure-tools/typespec-client-generator-core";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
11
|
+
import { Model, Type } from "@typespec/compiler";
|
|
12
|
+
import { getServers, HttpOperation } from "@typespec/http";
|
|
12
13
|
import { SdkContext } from "../utils/interfaces.js";
|
|
13
14
|
import { extractMediaTypes, KnownMediaType } from "../utils/mediaTypes.js";
|
|
14
15
|
import {
|
|
@@ -33,7 +34,7 @@ export function transformSchemas(client: SdkClient, dpgContext: SdkContext) {
|
|
|
33
34
|
const contentTypeMap = new Map<Type, KnownMediaType[]>();
|
|
34
35
|
const clientOperations = listOperationsInOperationGroup(dpgContext, client);
|
|
35
36
|
for (const clientOp of clientOperations) {
|
|
36
|
-
const route =
|
|
37
|
+
const route = getHttpOperationWithCache(dpgContext, clientOp);
|
|
37
38
|
// ignore overload base operation
|
|
38
39
|
if (route.overloads && route.overloads?.length > 0) {
|
|
39
40
|
continue;
|
|
@@ -47,7 +48,7 @@ export function transformSchemas(client: SdkClient, dpgContext: SdkContext) {
|
|
|
47
48
|
operationGroup
|
|
48
49
|
);
|
|
49
50
|
for (const op of operations) {
|
|
50
|
-
const route =
|
|
51
|
+
const route = getHttpOperationWithCache(dpgContext, op);
|
|
51
52
|
// ignore overload base operation
|
|
52
53
|
if (route.overloads && route.overloads?.length > 0) {
|
|
53
54
|
continue;
|
|
@@ -61,7 +62,7 @@ export function transformSchemas(client: SdkClient, dpgContext: SdkContext) {
|
|
|
61
62
|
getGeneratedModels(param.param, SchemaContext.Input);
|
|
62
63
|
}
|
|
63
64
|
}
|
|
64
|
-
const bodyModel = getBodyType(
|
|
65
|
+
const bodyModel = getBodyType(route);
|
|
65
66
|
if (
|
|
66
67
|
bodyModel &&
|
|
67
68
|
(bodyModel.kind === "Model" ||
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { TelemetryInfo } from "@azure-tools/rlc-common";
|
|
2
2
|
import {
|
|
3
|
+
getHttpOperationWithCache,
|
|
3
4
|
listOperationGroups,
|
|
4
5
|
listOperationsInOperationGroup,
|
|
5
6
|
SdkClient,
|
|
6
7
|
SdkContext
|
|
7
8
|
} from "@azure-tools/typespec-client-generator-core";
|
|
8
|
-
import { ignoreDiagnostics } from "@typespec/compiler";
|
|
9
|
-
import { getHttpOperation } from "@typespec/http";
|
|
10
9
|
import { getCustomRequestHeaderNameForOperation } from "../utils/operationUtil.js";
|
|
11
10
|
|
|
12
11
|
export function transformTelemetryInfo(
|
|
@@ -29,11 +28,10 @@ function getCustomRequestHeaderNameForClient(
|
|
|
29
28
|
dpgContext: SdkContext,
|
|
30
29
|
client: SdkClient
|
|
31
30
|
) {
|
|
32
|
-
const program = dpgContext.program;
|
|
33
31
|
const clientOperations = listOperationsInOperationGroup(dpgContext, client);
|
|
34
32
|
for (const clientOp of clientOperations) {
|
|
35
33
|
const headerName = getCustomRequestHeaderNameForOperation(
|
|
36
|
-
|
|
34
|
+
getHttpOperationWithCache(dpgContext, clientOp)
|
|
37
35
|
);
|
|
38
36
|
if (headerName !== undefined) {
|
|
39
37
|
return headerName;
|
|
@@ -47,7 +45,7 @@ function getCustomRequestHeaderNameForClient(
|
|
|
47
45
|
);
|
|
48
46
|
for (const op of operations) {
|
|
49
47
|
const headerName = getCustomRequestHeaderNameForOperation(
|
|
50
|
-
|
|
48
|
+
getHttpOperationWithCache(dpgContext, op)
|
|
51
49
|
);
|
|
52
50
|
if (headerName !== undefined) {
|
|
53
51
|
return headerName;
|
|
@@ -8,16 +8,12 @@ import {
|
|
|
8
8
|
ServiceInfo
|
|
9
9
|
} from "@azure-tools/rlc-common";
|
|
10
10
|
import {
|
|
11
|
+
getHttpOperationWithCache,
|
|
11
12
|
listOperationGroups,
|
|
12
13
|
listOperationsInOperationGroup
|
|
13
14
|
} from "@azure-tools/typespec-client-generator-core";
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
ignoreDiagnostics,
|
|
17
|
-
NoTarget,
|
|
18
|
-
Program
|
|
19
|
-
} from "@typespec/compiler";
|
|
20
|
-
import { getAuthentication, getHttpOperation } from "@typespec/http";
|
|
15
|
+
import { getDoc, NoTarget, Program } from "@typespec/compiler";
|
|
16
|
+
import { getAuthentication } from "@typespec/http";
|
|
21
17
|
import { EmitterOptions, reportDiagnostic } from "../lib.js";
|
|
22
18
|
import { getRLCClients } from "../utils/clientUtils.js";
|
|
23
19
|
import { SdkContext } from "../utils/interfaces.js";
|
|
@@ -201,13 +197,12 @@ function getHierarchyClient(emitterOptions: EmitterOptions) {
|
|
|
201
197
|
|
|
202
198
|
function detectIfNameConflicts(dpgContext: SdkContext) {
|
|
203
199
|
const clients = getRLCClients(dpgContext);
|
|
204
|
-
const program = dpgContext.program;
|
|
205
200
|
for (const client of clients) {
|
|
206
201
|
// only consider it's conflict when there are conflicts in the same client
|
|
207
202
|
const nameSet = new Set<string>();
|
|
208
203
|
const clientOperations = listOperationsInOperationGroup(dpgContext, client);
|
|
209
204
|
for (const clientOp of clientOperations) {
|
|
210
|
-
const route =
|
|
205
|
+
const route = getHttpOperationWithCache(dpgContext, clientOp);
|
|
211
206
|
const name = getOperationName(dpgContext, route.operation);
|
|
212
207
|
if (nameSet.has(name)) {
|
|
213
208
|
return true;
|
|
@@ -222,7 +217,7 @@ function detectIfNameConflicts(dpgContext: SdkContext) {
|
|
|
222
217
|
operationGroup
|
|
223
218
|
);
|
|
224
219
|
for (const op of operations) {
|
|
225
|
-
const route =
|
|
220
|
+
const route = getHttpOperationWithCache(dpgContext, op);
|
|
226
221
|
const name = getOperationName(dpgContext, route.operation);
|
|
227
222
|
if (nameSet.has(name)) {
|
|
228
223
|
return true;
|
package/src/utils/modelUtils.ts
CHANGED
|
@@ -65,13 +65,11 @@ import {
|
|
|
65
65
|
isType
|
|
66
66
|
} from "@typespec/compiler";
|
|
67
67
|
import {
|
|
68
|
-
createMetadataInfo,
|
|
69
68
|
getHeaderFieldName,
|
|
70
69
|
getPathParamName,
|
|
71
70
|
getQueryParamName,
|
|
72
71
|
HttpOperation,
|
|
73
|
-
isStatusCode
|
|
74
|
-
Visibility
|
|
72
|
+
isStatusCode
|
|
75
73
|
} from "@typespec/http";
|
|
76
74
|
import { reportDiagnostic } from "../lib.js";
|
|
77
75
|
import { GetSchemaOptions, SdkContext } from "./interfaces.js";
|
|
@@ -154,7 +152,7 @@ export function getSchemaForType(
|
|
|
154
152
|
) {
|
|
155
153
|
const program = dpgContext.program;
|
|
156
154
|
const { usage } = options ?? {};
|
|
157
|
-
const type = getEffectiveModelFromType(
|
|
155
|
+
const type = getEffectiveModelFromType(dpgContext, typeInput);
|
|
158
156
|
|
|
159
157
|
const builtinType = getSchemaForLiteral(type);
|
|
160
158
|
if (builtinType !== undefined) {
|
|
@@ -243,14 +241,17 @@ export function getSchemaForType(
|
|
|
243
241
|
});
|
|
244
242
|
return undefined;
|
|
245
243
|
}
|
|
246
|
-
export function getEffectiveModelFromType(
|
|
244
|
+
export function getEffectiveModelFromType(
|
|
245
|
+
context: SdkContext,
|
|
246
|
+
type: Type
|
|
247
|
+
): Type {
|
|
247
248
|
/**
|
|
248
249
|
* If type is an anonymous model, tries to find a named model that has the same
|
|
249
250
|
* set of properties when non-schema properties are excluded.
|
|
250
251
|
*/
|
|
251
252
|
if (type.kind === "Model" && type.name === "") {
|
|
252
|
-
const effective = getEffectiveModelType(program, type, (property) =>
|
|
253
|
-
isSchemaProperty(program, property)
|
|
253
|
+
const effective = getEffectiveModelType(context.program, type, (property) =>
|
|
254
|
+
isSchemaProperty(context.program, property)
|
|
254
255
|
);
|
|
255
256
|
if (effective.name) {
|
|
256
257
|
return effective;
|
|
@@ -386,39 +387,47 @@ function getSchemaForUnion(
|
|
|
386
387
|
const [asEnum, _] = getUnionAsEnum(union);
|
|
387
388
|
const variants = Array.from(union.variants.values());
|
|
388
389
|
|
|
389
|
-
|
|
390
|
+
const values = [];
|
|
391
|
+
let namedUnionMember = false;
|
|
390
392
|
|
|
391
|
-
|
|
392
|
-
// We already know it's not a model type
|
|
393
|
-
values.push(
|
|
394
|
-
getSchemaForType(dpgContext, variant.type, { ...options, needRef: false })
|
|
395
|
-
);
|
|
396
|
-
}
|
|
397
|
-
if (asEnum?.open) {
|
|
398
|
-
values = [];
|
|
393
|
+
if (asEnum?.open && asEnum.members.size > 0) {
|
|
399
394
|
for (const [_, member] of asEnum.members.entries()) {
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
)
|
|
395
|
+
const memberType = getSchemaForType(dpgContext, member.type, {
|
|
396
|
+
...options,
|
|
397
|
+
needRef: false
|
|
398
|
+
});
|
|
399
|
+
values.push(memberType);
|
|
400
|
+
if (memberType.name) {
|
|
401
|
+
namedUnionMember = true;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
} else {
|
|
405
|
+
for (const variant of variants) {
|
|
406
|
+
// We already know it's not a model type
|
|
407
|
+
const variantType = getSchemaForType(dpgContext, variant.type, {
|
|
408
|
+
...options,
|
|
409
|
+
needRef: false
|
|
410
|
+
});
|
|
411
|
+
values.push(variantType);
|
|
412
|
+
if (variantType.typeName) {
|
|
413
|
+
namedUnionMember = true;
|
|
414
|
+
}
|
|
406
415
|
}
|
|
407
416
|
}
|
|
408
417
|
const schema: any = {};
|
|
409
418
|
if (values.length > 0) {
|
|
410
419
|
schema.enum = values;
|
|
411
420
|
const unionAlias =
|
|
412
|
-
asEnum?.open && asEnum?.kind
|
|
413
|
-
? asEnum.kind
|
|
421
|
+
asEnum?.open && asEnum?.kind && !namedUnionMember
|
|
422
|
+
? asEnum.kind + (asEnum.nullable ? " | null" : "")
|
|
414
423
|
: values
|
|
415
424
|
.map(
|
|
416
425
|
(item) => `${getTypeName(item, [SchemaContext.Input]) ?? item}`
|
|
417
426
|
)
|
|
418
427
|
.join(" | ");
|
|
419
428
|
const outputUnionAlias =
|
|
420
|
-
asEnum?.open && asEnum?.kind
|
|
421
|
-
? asEnum.kind
|
|
429
|
+
asEnum?.open && asEnum?.kind && !namedUnionMember
|
|
430
|
+
? asEnum.kind + (asEnum.nullable ? " | null" : "")
|
|
422
431
|
: values
|
|
423
432
|
.map(
|
|
424
433
|
(item) => `${getTypeName(item, [SchemaContext.Output]) ?? item}`
|
|
@@ -778,6 +787,9 @@ function getSchemaForModel(
|
|
|
778
787
|
if (!prop.optional) {
|
|
779
788
|
propSchema.required = true;
|
|
780
789
|
}
|
|
790
|
+
if (name === '"propBoolean"') {
|
|
791
|
+
prop;
|
|
792
|
+
}
|
|
781
793
|
const propertyDescription = getFormattedPropertyDoc(
|
|
782
794
|
program,
|
|
783
795
|
prop,
|
|
@@ -1446,7 +1458,16 @@ function getPriorityName(schema: Schema, usage?: SchemaContext[]): string {
|
|
|
1446
1458
|
}
|
|
1447
1459
|
|
|
1448
1460
|
function getEnumStringDescription(type: any) {
|
|
1449
|
-
if (
|
|
1461
|
+
if (
|
|
1462
|
+
(type.name === "string" ||
|
|
1463
|
+
type.alias === "string" ||
|
|
1464
|
+
type.name === "number" ||
|
|
1465
|
+
type.alias === "number" ||
|
|
1466
|
+
type.name === "boolean" ||
|
|
1467
|
+
type.alias === "boolean") &&
|
|
1468
|
+
type.enum &&
|
|
1469
|
+
type.enum.length > 0
|
|
1470
|
+
) {
|
|
1450
1471
|
return `Possible values: ${type.enum
|
|
1451
1472
|
.map((e: Schema) => {
|
|
1452
1473
|
return e.type;
|
|
@@ -1495,19 +1516,8 @@ export function getFormattedPropertyDoc(
|
|
|
1495
1516
|
return propertyDoc ?? enhancedDocFromType;
|
|
1496
1517
|
}
|
|
1497
1518
|
|
|
1498
|
-
export function getBodyType(
|
|
1499
|
-
program: Program,
|
|
1500
|
-
route: HttpOperation
|
|
1501
|
-
): Type | undefined {
|
|
1519
|
+
export function getBodyType(route: HttpOperation): Type | undefined {
|
|
1502
1520
|
const bodyModel = route.parameters.body?.type;
|
|
1503
|
-
if (bodyModel) {
|
|
1504
|
-
const metadataInfo = createMetadataInfo(program);
|
|
1505
|
-
const payloadType = metadataInfo.getEffectivePayloadType(
|
|
1506
|
-
bodyModel,
|
|
1507
|
-
Visibility.All
|
|
1508
|
-
);
|
|
1509
|
-
return payloadType;
|
|
1510
|
-
}
|
|
1511
1521
|
return bodyModel;
|
|
1512
1522
|
}
|
|
1513
1523
|
|
|
@@ -19,20 +19,14 @@ import {
|
|
|
19
19
|
PagedResultMetadata
|
|
20
20
|
} from "@azure-tools/typespec-azure-core";
|
|
21
21
|
import {
|
|
22
|
+
getHttpOperationWithCache,
|
|
22
23
|
getWireName,
|
|
23
24
|
listOperationGroups,
|
|
24
25
|
listOperationsInOperationGroup,
|
|
25
26
|
SdkClient
|
|
26
27
|
} from "@azure-tools/typespec-client-generator-core";
|
|
28
|
+
import { Model, Operation, Program, Type } from "@typespec/compiler";
|
|
27
29
|
import {
|
|
28
|
-
ignoreDiagnostics,
|
|
29
|
-
Model,
|
|
30
|
-
Operation,
|
|
31
|
-
Program,
|
|
32
|
-
Type
|
|
33
|
-
} from "@typespec/compiler";
|
|
34
|
-
import {
|
|
35
|
-
getHttpOperation,
|
|
36
30
|
HttpOperation,
|
|
37
31
|
HttpOperationParameter,
|
|
38
32
|
HttpOperationResponse,
|
|
@@ -310,7 +304,7 @@ export function hasPollingOperations(
|
|
|
310
304
|
const program = dpgContext.program;
|
|
311
305
|
const clientOperations = listOperationsInOperationGroup(dpgContext, client);
|
|
312
306
|
for (const clientOp of clientOperations) {
|
|
313
|
-
const route =
|
|
307
|
+
const route = getHttpOperationWithCache(dpgContext, clientOp);
|
|
314
308
|
// ignore overload base operation
|
|
315
309
|
if (route.overloads && route.overloads?.length > 0) {
|
|
316
310
|
continue;
|
|
@@ -326,7 +320,7 @@ export function hasPollingOperations(
|
|
|
326
320
|
operationGroup
|
|
327
321
|
);
|
|
328
322
|
for (const op of operations) {
|
|
329
|
-
const route =
|
|
323
|
+
const route = getHttpOperationWithCache(dpgContext, op);
|
|
330
324
|
// ignore overload base operation
|
|
331
325
|
if (route.overloads && route.overloads?.length > 0) {
|
|
332
326
|
continue;
|
|
@@ -353,7 +347,7 @@ export function hasPagingOperations(client: SdkClient, dpgContext: SdkContext) {
|
|
|
353
347
|
const program = dpgContext.program;
|
|
354
348
|
const clientOperations = listOperationsInOperationGroup(dpgContext, client);
|
|
355
349
|
for (const clientOp of clientOperations) {
|
|
356
|
-
const route =
|
|
350
|
+
const route = getHttpOperationWithCache(dpgContext, clientOp);
|
|
357
351
|
// ignore overload base operation
|
|
358
352
|
if (route.overloads && route.overloads?.length > 0) {
|
|
359
353
|
continue;
|
|
@@ -369,7 +363,7 @@ export function hasPagingOperations(client: SdkClient, dpgContext: SdkContext) {
|
|
|
369
363
|
operationGroup
|
|
370
364
|
);
|
|
371
365
|
for (const op of operations) {
|
|
372
|
-
const route =
|
|
366
|
+
const route = getHttpOperationWithCache(dpgContext, op);
|
|
373
367
|
// ignore overload base operation
|
|
374
368
|
if (route.overloads && route.overloads?.length > 0) {
|
|
375
369
|
continue;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"collectionUtils.d.ts","sourceRoot":"","sources":["../../../../src/modular/serialization/collectionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AAE/E,wBAAgB,sBAAsB,CACpC,gBAAgB,CAAC,EAAE,gBAAgB,GAClC,MAAM,CAeR"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export function getCollectionSeparator(collectionFormat) {
|
|
2
|
-
switch (collectionFormat) {
|
|
3
|
-
case "csv":
|
|
4
|
-
return ",";
|
|
5
|
-
case "ssv":
|
|
6
|
-
return " ";
|
|
7
|
-
case "tsv":
|
|
8
|
-
return "\t";
|
|
9
|
-
case "pipes":
|
|
10
|
-
return "|";
|
|
11
|
-
case "multi":
|
|
12
|
-
return "&";
|
|
13
|
-
default:
|
|
14
|
-
return ",";
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=collectionUtils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"collectionUtils.js","sourceRoot":"","sources":["../../../../src/modular/serialization/collectionUtils.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,sBAAsB,CACpC,gBAAmC;IAEnC,QAAQ,gBAAgB,EAAE,CAAC;QACzB,KAAK,KAAK;YACR,OAAO,GAAG,CAAC;QACb,KAAK,KAAK;YACR,OAAO,GAAG,CAAC;QACb,KAAK,KAAK;YACR,OAAO,IAAI,CAAC;QACd,KAAK,OAAO;YACV,OAAO,GAAG,CAAC;QACb,KAAK,OAAO;YACV,OAAO,GAAG,CAAC;QACb;YACE,OAAO,GAAG,CAAC;IACf,CAAC;AACH,CAAC"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { SdkContext } from "../../utils/interfaces.js";
|
|
2
|
-
import { Client, ModularCodeModel } from "../modularCodeModel.js";
|
|
3
|
-
import { SerializerMap } from "./util.js";
|
|
4
|
-
export declare function buildSerializers(dpgContext: SdkContext, codeModel: ModularCodeModel, client: Client): SerializerMap;
|
|
5
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/modular/serialization/index.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAKvD,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAOlE,OAAO,EAIL,aAAa,EACd,MAAM,WAAW,CAAC;AAEnB,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,gBAAgB,EAC3B,MAAM,EAAE,MAAM,GACb,aAAa,CA+Ef"}
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import { addImportsToFiles, addImportToSpecifier } from "@azure-tools/rlc-common";
|
|
2
|
-
import { getAllModels, UsageFlags as TCGCUsageFlags } from "@azure-tools/typespec-client-generator-core";
|
|
3
|
-
import { UsageFlags } from "@typespec/compiler";
|
|
4
|
-
import * as path from "path";
|
|
5
|
-
import { toCamelCase, toPascalCase } from "../../utils/casingUtils.js";
|
|
6
|
-
import { getModularModelFilePath, getRLCIndexFilePath } from "../helpers/namingHelpers.js";
|
|
7
|
-
import { serializeEnumFunctionBody, serializeModelPropertiesInline, serializeType, serializeUnionInline } from "./serializers.js";
|
|
8
|
-
import { getUsage, isDefined } from "./util.js";
|
|
9
|
-
export function buildSerializers(dpgContext, codeModel, client) {
|
|
10
|
-
// Root for changes associated with EXPERIMENTAL_TYPESPEC_TS_SERIALIZATION flag
|
|
11
|
-
const unions = codeModel.types
|
|
12
|
-
.filter((type) => type.type === "combined" && isDefined(type.tcgcType))
|
|
13
|
-
.map((type) => type.tcgcType);
|
|
14
|
-
const serializers = createSerializerMetadata(dpgContext, unions);
|
|
15
|
-
const entries = Object.entries(serializers).map(([modularTypeName, meta]) => ({
|
|
16
|
-
...meta,
|
|
17
|
-
modularTypeName
|
|
18
|
-
}));
|
|
19
|
-
const functions = entries
|
|
20
|
-
.flatMap(({ deserializerFunctionName, serializerFunctionName, type }) => [
|
|
21
|
-
serializerFunctionName
|
|
22
|
-
? createSerializerFunctionStructure(dpgContext, UsageFlags.Input, serializers, type, codeModel.runtimeImports)
|
|
23
|
-
: undefined,
|
|
24
|
-
deserializerFunctionName
|
|
25
|
-
? createSerializerFunctionStructure(dpgContext, UsageFlags.Output, serializers, type, codeModel.runtimeImports)
|
|
26
|
-
: undefined
|
|
27
|
-
])
|
|
28
|
-
.filter(isDefined);
|
|
29
|
-
if (!functions.length) {
|
|
30
|
-
return {};
|
|
31
|
-
}
|
|
32
|
-
const utilFilePath = path.join(...[
|
|
33
|
-
codeModel.modularOptions.sourceRoot,
|
|
34
|
-
client.subfolder,
|
|
35
|
-
"utils",
|
|
36
|
-
"serializeUtil.ts"
|
|
37
|
-
].filter(isDefined));
|
|
38
|
-
const sourceFile = codeModel.project.createSourceFile(utilFilePath);
|
|
39
|
-
sourceFile.addFunctions(functions);
|
|
40
|
-
entries.forEach(({ modularTypeName, rlcTypeAlias, rlcTypeName }) => {
|
|
41
|
-
addImportToSpecifier("modularModel", codeModel.runtimeImports, modularTypeName);
|
|
42
|
-
if (rlcTypeName) {
|
|
43
|
-
addImportToSpecifier("rlcIndex", codeModel.runtimeImports, rlcTypeAlias ? `${rlcTypeName} as ${rlcTypeAlias}` : rlcTypeName);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
addImportsToFiles(codeModel.runtimeImports, sourceFile, {
|
|
47
|
-
modularModel: path.relative(path.dirname(utilFilePath), getModularModelFilePath(codeModel, client, "js")),
|
|
48
|
-
rlcIndex: path.relative(path.dirname(utilFilePath), getRLCIndexFilePath(dpgContext, client, "js"))
|
|
49
|
-
});
|
|
50
|
-
return serializers;
|
|
51
|
-
}
|
|
52
|
-
function createSerializerMetadata(dpgContext, unions) {
|
|
53
|
-
const allModels = getAllModels(dpgContext);
|
|
54
|
-
const typesWithSerializers = [...allModels, ...unions].filter(hasSerializeFunction);
|
|
55
|
-
const serializers = Object.fromEntries(typesWithSerializers.map((type) => {
|
|
56
|
-
const serializerType = type;
|
|
57
|
-
const rlcTypeName = serializerType.usage && serializerType.usage & TCGCUsageFlags.Output
|
|
58
|
-
? toPascalCase(`${type.name} Output`)
|
|
59
|
-
: serializerType.usage && serializerType.usage & TCGCUsageFlags.Input
|
|
60
|
-
? type.name
|
|
61
|
-
: undefined;
|
|
62
|
-
const rlcTypeAlias = rlcTypeName
|
|
63
|
-
? toPascalCase(`${type.name} Rest`)
|
|
64
|
-
: undefined;
|
|
65
|
-
const usage = getUsage(dpgContext, type);
|
|
66
|
-
const [serializerFunctionName, deserializerFunctionName] = [UsageFlags.Input, UsageFlags.Output].map((functionType) => functionType & usage
|
|
67
|
-
? toCamelCase(`${functionType === UsageFlags.Input ? "serialize" : "deserialize"} ${type.name}`)
|
|
68
|
-
: undefined);
|
|
69
|
-
return [
|
|
70
|
-
type.name,
|
|
71
|
-
{
|
|
72
|
-
rlcTypeName,
|
|
73
|
-
rlcTypeAlias,
|
|
74
|
-
type,
|
|
75
|
-
serializerFunctionName,
|
|
76
|
-
deserializerFunctionName
|
|
77
|
-
}
|
|
78
|
-
];
|
|
79
|
-
}));
|
|
80
|
-
return serializers;
|
|
81
|
-
}
|
|
82
|
-
function createSerializerFunctionStructure(dpgContext, functionType, serializerMap, type, runtimeImports) {
|
|
83
|
-
var _a, _b, _c;
|
|
84
|
-
const modularTypeName = type.name;
|
|
85
|
-
const serializerMetadata = serializerMap[modularTypeName];
|
|
86
|
-
const functionName = functionType === UsageFlags.Input
|
|
87
|
-
? (_a = serializerMetadata === null || serializerMetadata === void 0 ? void 0 : serializerMetadata.serializerFunctionName) !== null && _a !== void 0 ? _a : "FIXMYNAME"
|
|
88
|
-
: (_b = serializerMetadata === null || serializerMetadata === void 0 ? void 0 : serializerMetadata.deserializerFunctionName) !== null && _b !== void 0 ? _b : "FIXMYNAME";
|
|
89
|
-
const paramName = "o";
|
|
90
|
-
const types = type.isGeneratedName
|
|
91
|
-
? ["any", "any"]
|
|
92
|
-
: [modularTypeName, (_c = serializerMetadata === null || serializerMetadata === void 0 ? void 0 : serializerMetadata.rlcTypeAlias) !== null && _c !== void 0 ? _c : "FIXMYNAME"];
|
|
93
|
-
const [paramType, returnType] = functionType === UsageFlags.Input ? types : types.reverse();
|
|
94
|
-
const parameters = [{ name: paramName, type: paramType }];
|
|
95
|
-
const statements = [];
|
|
96
|
-
switch (true) {
|
|
97
|
-
case !hasSerializeFunction(type): {
|
|
98
|
-
statements.push(`return ${serializeType({
|
|
99
|
-
dpgContext,
|
|
100
|
-
functionType,
|
|
101
|
-
serializerMap,
|
|
102
|
-
type,
|
|
103
|
-
valueExpr: paramName,
|
|
104
|
-
importCallback: (importType, importedName) => addImportToSpecifier(importType, runtimeImports, importedName)
|
|
105
|
-
})};`);
|
|
106
|
-
break;
|
|
107
|
-
}
|
|
108
|
-
case type.kind === "model": {
|
|
109
|
-
statements.push(`return ${serializeModelPropertiesInline({
|
|
110
|
-
dpgContext,
|
|
111
|
-
functionType,
|
|
112
|
-
serializerMap,
|
|
113
|
-
type,
|
|
114
|
-
valueExpr: paramName,
|
|
115
|
-
importCallback: (importType, importedName) => addImportToSpecifier(importType, runtimeImports, importedName)
|
|
116
|
-
})}`);
|
|
117
|
-
break;
|
|
118
|
-
}
|
|
119
|
-
case type.kind === "union": {
|
|
120
|
-
statements.push(`return ${serializeUnionInline({
|
|
121
|
-
dpgContext,
|
|
122
|
-
functionType,
|
|
123
|
-
serializerMap,
|
|
124
|
-
type,
|
|
125
|
-
valueExpr: paramName,
|
|
126
|
-
importCallback: (importType, importedName) => addImportToSpecifier(importType, runtimeImports, importedName)
|
|
127
|
-
})}`);
|
|
128
|
-
break;
|
|
129
|
-
}
|
|
130
|
-
case type.kind === "enum": {
|
|
131
|
-
statements.push(serializeEnumFunctionBody({
|
|
132
|
-
dpgContext,
|
|
133
|
-
functionType,
|
|
134
|
-
serializerMap,
|
|
135
|
-
type,
|
|
136
|
-
valueExpr: paramName,
|
|
137
|
-
importCallback: (importType, importedName) => addImportToSpecifier(importType, runtimeImports, importedName)
|
|
138
|
-
}));
|
|
139
|
-
break;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
const functionDecl = {
|
|
143
|
-
isExported: true,
|
|
144
|
-
name: functionName,
|
|
145
|
-
parameters,
|
|
146
|
-
returnType,
|
|
147
|
-
statements
|
|
148
|
-
};
|
|
149
|
-
return functionDecl;
|
|
150
|
-
}
|
|
151
|
-
function hasSerializeFunction(type) {
|
|
152
|
-
const isValidTypeKind = type.kind === "enum" || type.kind === "model" || type.kind === "union";
|
|
153
|
-
return Boolean(isValidTypeKind && type.name);
|
|
154
|
-
}
|
|
155
|
-
//# sourceMappingURL=index.js.map
|
|
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AAC,UAAU,EAAE,YAAY,EAAE,EAAE,CAC3C,oBAAoB,CAAC,UAAU,EAAE,cAAc,EAAE,YAAY,CAAC;aACjE,CAAC,EAAE,CACL,CAAC;YACF,MAAM;QACR,CAAC;QACD,KAAK,IAAI,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC;YAC1B,UAAU,CAAC,IAAI,CACb,yBAAyB,CAAC;gBACxB,UAAU;gBACV,YAAY;gBACZ,aAAa;gBACb,IAAI;gBACJ,SAAS,EAAE,SAAS;gBACpB,cAAc,EAAE,CAAC,UAAU,EAAE,YAAY,EAAE,EAAE,CAC3C,oBAAoB,CAAC,UAAU,EAAE,cAAc,EAAE,YAAY,CAAC;aACjE,CAAC,CACH,CAAC;YACF,MAAM;QACR,CAAC;IACH,CAAC;IAED,MAAM,YAAY,GAA+C;QAC/D,UAAU,EAAE,IAAI;QAChB,IAAI,EAAE,YAAY;QAClB,UAAU;QACV,UAAU;QACV,UAAU;KACX,CAAC;IACF,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,SAAS,oBAAoB,CAAC,IAAa;IACzC,MAAM,eAAe,GACnB,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,CAAC;IACzE,OAAO,OAAO,CAAC,eAAe,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Imports as RuntimeImports, OperationResponse } from "@azure-tools/rlc-common";
|
|
2
|
-
import { SdkContext } from "@azure-tools/typespec-client-generator-core";
|
|
3
|
-
import { FunctionDeclarationStructure, OptionalKind, ParameterDeclarationStructure } from "ts-morph";
|
|
4
|
-
import { Client, ModularCodeModel, Operation, Type } from "../modularCodeModel.js";
|
|
5
|
-
import { SerializerMap } from "../serialization/util.js";
|
|
6
|
-
export declare function getRLCResponseType(rlcResponse?: OperationResponse): string | undefined;
|
|
7
|
-
export declare function getRLCLroLogicalResponse(rlcResponse?: OperationResponse): string;
|
|
8
|
-
export declare function getSendPrivateFunction(dpgContext: SdkContext, operation: Operation, clientType: string, serializerMap: SerializerMap | undefined, runtimeImports: RuntimeImports): OptionalKind<FunctionDeclarationStructure>;
|
|
9
|
-
export declare function getDeserializePrivateFunction(dpgContext: SdkContext, operation: Operation, needSubClient: boolean, needUnexpectedHelper: boolean, runtimeImports: RuntimeImports, serializerMap: SerializerMap | undefined): OptionalKind<FunctionDeclarationStructure>;
|
|
10
|
-
export declare function getOperationSignatureParameters(operation: Operation, clientType: string): OptionalKind<ParameterDeclarationStructure>[];
|
|
11
|
-
/**
|
|
12
|
-
* This operation builds and returns the function declaration for an operation.
|
|
13
|
-
*/
|
|
14
|
-
export declare function getOperationFunction(operation: Operation, clientType: string): OptionalKind<FunctionDeclarationStructure> & {
|
|
15
|
-
propertyName?: string;
|
|
16
|
-
};
|
|
17
|
-
export declare function buildLroReturnType(operation: Operation): {
|
|
18
|
-
name: string;
|
|
19
|
-
type: string;
|
|
20
|
-
};
|
|
21
|
-
export declare function getPagingOnlyOperationFunction(operation: Operation, clientType: string): {
|
|
22
|
-
statements: string[];
|
|
23
|
-
docs: string[];
|
|
24
|
-
isAsync: boolean;
|
|
25
|
-
isExported: boolean;
|
|
26
|
-
name: string;
|
|
27
|
-
propertyName: string;
|
|
28
|
-
parameters: OptionalKind<ParameterDeclarationStructure>[];
|
|
29
|
-
returnType: string;
|
|
30
|
-
};
|
|
31
|
-
export declare function getOperationOptionsName(operation: Operation, includeGroupName?: boolean): string;
|
|
32
|
-
export declare function isLroOnlyOperation(op: Operation): boolean;
|
|
33
|
-
export declare function hasPagingOnlyOperation(client: Client, needRLC?: boolean): boolean;
|
|
34
|
-
export declare function hasPagingOnlyOperation(codeModel: ModularCodeModel, needRLC?: boolean): boolean;
|
|
35
|
-
export declare function isPagingOnlyOperation(op: Operation): boolean;
|
|
36
|
-
export declare function getAllAncestors(type: Type): Type[];
|
|
37
|
-
//# sourceMappingURL=operationHelpers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"operationHelpers.d.ts","sourceRoot":"","sources":["../../../../src/modular/serialization/operationHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,OAAO,IAAI,cAAc,EAEzB,iBAAiB,EAClB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,6CAA6C,CAAC;AACzE,OAAO,EACL,4BAA4B,EAC5B,YAAY,EACZ,6BAA6B,EAC9B,MAAM,UAAU,CAAC;AAYlB,OAAO,EAEL,MAAM,EACN,gBAAgB,EAChB,SAAS,EAGT,IAAI,EACL,MAAM,wBAAwB,CAAC;AAMhC,OAAO,EAAE,aAAa,EAAa,MAAM,0BAA0B,CAAC;AAEpE,wBAAgB,kBAAkB,CAAC,WAAW,CAAC,EAAE,iBAAiB,sBAejE;AAED,wBAAgB,wBAAwB,CAAC,WAAW,CAAC,EAAE,iBAAiB,UAOvE;AAED,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,aAAa,GAAG,SAAS,EACxC,cAAc,EAAE,cAAc,GAC7B,YAAY,CAAC,4BAA4B,CAAC,CAqC5C;AAED,wBAAgB,6BAA6B,CAC3C,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,SAAS,EACpB,aAAa,EAAE,OAAO,EACtB,oBAAoB,EAAE,OAAO,EAC7B,cAAc,EAAE,cAAc,EAC9B,aAAa,EAAE,aAAa,GAAG,SAAS,GACvC,YAAY,CAAC,4BAA4B,CAAC,CA6G5C;AAED,wBAAgB,+BAA+B,CAC7C,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,MAAM,GACjB,YAAY,CAAC,6BAA6B,CAAC,EAAE,CA2C/C;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,SAAS,E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