@microsoft/typespec-msgraph 0.0.1-Preview.2 → 0.0.1-Preview.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/dist/src/components/acceptable-media-types-annotation.d.ts +3 -4
- package/dist/src/components/acceptable-media-types-annotation.d.ts.map +1 -1
- package/dist/src/components/acceptable-media-types-annotation.js +2 -6
- package/dist/src/components/acceptable-media-types-annotation.js.map +1 -1
- package/dist/src/components/alternate-keys-annotation.d.ts +4 -4
- package/dist/src/components/alternate-keys-annotation.d.ts.map +1 -1
- package/dist/src/components/alternate-keys-annotation.js +5 -13
- package/dist/src/components/alternate-keys-annotation.js.map +1 -1
- package/dist/src/components/common-elements.d.ts +0 -71
- package/dist/src/components/common-elements.d.ts.map +1 -1
- package/dist/src/components/common-elements.js +10 -24
- package/dist/src/components/common-elements.js.map +1 -1
- package/dist/src/components/computed-annotation.d.ts +3 -4
- package/dist/src/components/computed-annotation.d.ts.map +1 -1
- package/dist/src/components/computed-annotation.js +4 -10
- package/dist/src/components/computed-annotation.js.map +1 -1
- package/dist/src/components/count-restrictions-annotation.d.ts +3 -4
- package/dist/src/components/count-restrictions-annotation.d.ts.map +1 -1
- package/dist/src/components/count-restrictions-annotation.js +2 -6
- package/dist/src/components/count-restrictions-annotation.js.map +1 -1
- package/dist/src/components/description-annotation.d.ts +3 -4
- package/dist/src/components/description-annotation.d.ts.map +1 -1
- package/dist/src/components/description-annotation.js +4 -11
- package/dist/src/components/description-annotation.js.map +1 -1
- package/dist/src/components/entity-container-element.d.ts +6 -0
- package/dist/src/components/entity-container-element.d.ts.map +1 -0
- package/dist/src/components/entity-container-element.js +58 -0
- package/dist/src/components/entity-container-element.js.map +1 -0
- package/dist/src/components/enum-type-element.d.ts +6 -0
- package/dist/src/components/enum-type-element.d.ts.map +1 -0
- package/dist/src/components/enum-type-element.js +17 -0
- package/dist/src/components/enum-type-element.js.map +1 -0
- package/dist/src/components/expand-restrictions-annotation.d.ts +4 -5
- package/dist/src/components/expand-restrictions-annotation.d.ts.map +1 -1
- package/dist/src/components/expand-restrictions-annotation.js +5 -20
- package/dist/src/components/expand-restrictions-annotation.js.map +1 -1
- package/dist/src/components/index.d.ts +2 -14
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +9 -14
- package/dist/src/components/index.js.map +1 -1
- package/dist/src/components/operation-element.d.ts +6 -0
- package/dist/src/components/operation-element.d.ts.map +1 -0
- package/dist/src/components/operation-element.js +70 -0
- package/dist/src/components/operation-element.js.map +1 -0
- package/dist/src/components/permissions-annotation.d.ts +3 -4
- package/dist/src/components/permissions-annotation.d.ts.map +1 -1
- package/dist/src/components/permissions-annotation.js +2 -10
- package/dist/src/components/permissions-annotation.js.map +1 -1
- package/dist/src/components/property-element.d.ts +4 -4
- package/dist/src/components/property-element.d.ts.map +1 -1
- package/dist/src/components/property-element.js +14 -32
- package/dist/src/components/property-element.js.map +1 -1
- package/dist/src/components/revisions-annotation.d.ts +4 -5
- package/dist/src/components/revisions-annotation.d.ts.map +1 -1
- package/dist/src/components/revisions-annotation.js +7 -51
- package/dist/src/components/revisions-annotation.js.map +1 -1
- package/dist/src/components/schema-element.d.ts +6 -0
- package/dist/src/components/schema-element.d.ts.map +1 -0
- package/dist/src/components/schema-element.js +38 -0
- package/dist/src/components/schema-element.js.map +1 -0
- package/dist/src/components/search-restrictions-annotation.d.ts +3 -4
- package/dist/src/components/search-restrictions-annotation.d.ts.map +1 -1
- package/dist/src/components/search-restrictions-annotation.js +2 -6
- package/dist/src/components/search-restrictions-annotation.js.map +1 -1
- package/dist/src/components/skip-supported-annotation.d.ts +3 -4
- package/dist/src/components/skip-supported-annotation.d.ts.map +1 -1
- package/dist/src/components/skip-supported-annotation.js +2 -6
- package/dist/src/components/skip-supported-annotation.js.map +1 -1
- package/dist/src/components/sort-restrictions-annotation.d.ts +4 -5
- package/dist/src/components/sort-restrictions-annotation.d.ts.map +1 -1
- package/dist/src/components/sort-restrictions-annotation.js +5 -20
- package/dist/src/components/sort-restrictions-annotation.js.map +1 -1
- package/dist/src/components/structured-type-element.d.ts +10 -4
- package/dist/src/components/structured-type-element.d.ts.map +1 -1
- package/dist/src/components/structured-type-element.js +18 -58
- package/dist/src/components/structured-type-element.js.map +1 -1
- package/dist/src/components/top-supported-annotation.d.ts +3 -4
- package/dist/src/components/top-supported-annotation.d.ts.map +1 -1
- package/dist/src/components/top-supported-annotation.js +2 -6
- package/dist/src/components/top-supported-annotation.js.map +1 -1
- package/dist/src/decorators/abstract.d.ts.map +1 -1
- package/dist/src/decorators/abstract.js +0 -6
- package/dist/src/decorators/abstract.js.map +1 -1
- package/dist/src/decorators/complex.d.ts.map +1 -1
- package/dist/src/decorators/complex.js +0 -6
- package/dist/src/decorators/complex.js.map +1 -1
- package/dist/src/decorators/decorator-parameter.d.ts +4 -0
- package/dist/src/decorators/decorator-parameter.d.ts.map +1 -0
- package/dist/src/decorators/decorator-parameter.js +2 -0
- package/dist/src/decorators/decorator-parameter.js.map +1 -0
- package/dist/src/decorators/deprecated-definition.d.ts +4 -3
- package/dist/src/decorators/deprecated-definition.d.ts.map +1 -1
- package/dist/src/decorators/deprecated-definition.js +7 -1
- package/dist/src/decorators/deprecated-definition.js.map +1 -1
- package/dist/src/decorators/entity.d.ts.map +1 -1
- package/dist/src/decorators/entity.js +0 -6
- package/dist/src/decorators/entity.js.map +1 -1
- package/dist/src/decorators/expand.d.ts +2 -1
- package/dist/src/decorators/expand.d.ts.map +1 -1
- package/dist/src/decorators/expand.js +1 -1
- package/dist/src/decorators/expand.js.map +1 -1
- package/dist/src/decorators/function.d.ts +11 -0
- package/dist/src/decorators/function.d.ts.map +1 -0
- package/dist/src/decorators/function.js +16 -0
- package/dist/src/decorators/function.js.map +1 -0
- package/dist/src/decorators/handlers/custom/additional-query-parameters.d.ts +2 -1
- package/dist/src/decorators/handlers/custom/additional-query-parameters.d.ts.map +1 -1
- package/dist/src/decorators/handlers/custom/additional-query-parameters.js +3 -1
- package/dist/src/decorators/handlers/custom/additional-query-parameters.js.map +1 -1
- package/dist/src/decorators/handlers/custom/ags-attribute.d.ts +2 -1
- package/dist/src/decorators/handlers/custom/ags-attribute.d.ts.map +1 -1
- package/dist/src/decorators/handlers/custom/ags-attribute.js +3 -3
- package/dist/src/decorators/handlers/custom/ags-attribute.js.map +1 -1
- package/dist/src/decorators/handlers/index.d.ts +4 -3
- package/dist/src/decorators/handlers/index.d.ts.map +1 -1
- package/dist/src/decorators/handlers/index.js +4 -4
- package/dist/src/decorators/handlers/index.js.map +1 -1
- package/dist/src/decorators/has-stream.d.ts +3 -3
- package/dist/src/decorators/has-stream.d.ts.map +1 -1
- package/dist/src/decorators/has-stream.js +2 -15
- package/dist/src/decorators/has-stream.js.map +1 -1
- package/dist/src/decorators/index.d.ts +5 -1
- package/dist/src/decorators/index.d.ts.map +1 -1
- package/dist/src/decorators/index.js +5 -1
- package/dist/src/decorators/index.js.map +1 -1
- package/dist/src/decorators/open.d.ts.map +1 -1
- package/dist/src/decorators/open.js +0 -6
- package/dist/src/decorators/open.js.map +1 -1
- package/dist/src/decorators/{routed-interfaces.d.ts → operation-parameters.d.ts} +3 -11
- package/dist/src/decorators/operation-parameters.d.ts.map +1 -0
- package/dist/src/decorators/operation-parameters.js +15 -0
- package/dist/src/decorators/operation-parameters.js.map +1 -0
- package/dist/src/decorators/order-by.d.ts +2 -1
- package/dist/src/decorators/order-by.d.ts.map +1 -1
- package/dist/src/decorators/order-by.js +1 -1
- package/dist/src/decorators/order-by.js.map +1 -1
- package/dist/src/decorators/private-preview-definition.d.ts +4 -3
- package/dist/src/decorators/private-preview-definition.d.ts.map +1 -1
- package/dist/src/decorators/private-preview-definition.js +6 -1
- package/dist/src/decorators/private-preview-definition.js.map +1 -1
- package/dist/src/decorators/private-preview.d.ts +2 -1
- package/dist/src/decorators/private-preview.d.ts.map +1 -1
- package/dist/src/decorators/private-preview.js +1 -11
- package/dist/src/decorators/private-preview.js.map +1 -1
- package/dist/src/emitter.d.ts.map +1 -1
- package/dist/src/emitter.js +4 -2
- package/dist/src/emitter.js.map +1 -1
- package/dist/src/entities/entity-container.d.ts +35 -0
- package/dist/src/entities/entity-container.d.ts.map +1 -0
- package/dist/src/entities/entity-container.js +132 -0
- package/dist/src/entities/entity-container.js.map +1 -0
- package/dist/src/entities/enum.d.ts +16 -0
- package/dist/src/entities/enum.d.ts.map +1 -0
- package/dist/src/entities/enum.js +22 -0
- package/dist/src/entities/enum.js.map +1 -0
- package/dist/src/entities/model.d.ts +50 -0
- package/dist/src/entities/model.d.ts.map +1 -0
- package/dist/src/entities/model.js +119 -0
- package/dist/src/entities/model.js.map +1 -0
- package/dist/src/entities/namespace.d.ts +14 -0
- package/dist/src/entities/namespace.d.ts.map +1 -0
- package/dist/src/entities/namespace.js +41 -0
- package/dist/src/entities/namespace.js.map +1 -0
- package/dist/src/entities/operation.d.ts +28 -0
- package/dist/src/entities/operation.d.ts.map +1 -0
- package/dist/src/entities/operation.js +88 -0
- package/dist/src/entities/operation.js.map +1 -0
- package/dist/src/entities/property.d.ts +3 -0
- package/dist/src/entities/property.d.ts.map +1 -0
- package/dist/src/entities/property.js +54 -0
- package/dist/src/entities/property.js.map +1 -0
- package/dist/src/entities/revision-definition.d.ts +9 -0
- package/dist/src/entities/revision-definition.d.ts.map +1 -0
- package/dist/src/entities/revision-definition.js +42 -0
- package/dist/src/entities/revision-definition.js.map +1 -0
- package/dist/src/index.d.ts +0 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +0 -3
- package/dist/src/index.js.map +1 -1
- package/dist/src/rules/entity.d.ts +1 -0
- package/dist/src/rules/entity.d.ts.map +1 -1
- package/dist/src/rules/entity.js +36 -0
- package/dist/src/rules/entity.js.map +1 -1
- package/dist/src/rules/enum.d.ts +2 -0
- package/dist/src/rules/enum.d.ts.map +1 -0
- package/dist/src/rules/enum.js +26 -0
- package/dist/src/rules/enum.js.map +1 -0
- package/dist/src/rules/function.d.ts +2 -0
- package/dist/src/rules/function.d.ts.map +1 -0
- package/dist/src/rules/function.js +26 -0
- package/dist/src/rules/function.js.map +1 -0
- package/dist/src/rules/index.d.ts +3 -4
- package/dist/src/rules/index.d.ts.map +1 -1
- package/dist/src/rules/index.js +40 -111
- package/dist/src/rules/index.js.map +1 -1
- package/lib/decorators.tsp +29 -22
- package/package.json +27 -14
- package/dist/src/components/program-context.d.ts +0 -4
- package/dist/src/components/program-context.d.ts.map +0 -1
- package/dist/src/components/program-context.js +0 -3
- package/dist/src/components/program-context.js.map +0 -1
- package/dist/src/csdl.d.ts +0 -8
- package/dist/src/csdl.d.ts.map +0 -1
- package/dist/src/csdl.js +0 -298
- package/dist/src/csdl.js.map +0 -1
- package/dist/src/decorators/routed-interfaces.d.ts.map +0 -1
- package/dist/src/decorators/routed-interfaces.js +0 -43
- package/dist/src/decorators/routed-interfaces.js.map +0 -1
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Model, ModelProperty, Program } from "@typespec/compiler";
|
|
2
|
+
import { RevisionDefinition } from "./revision-definition.js";
|
|
3
|
+
export interface MsGraphModel {
|
|
4
|
+
Properties: EntityType | ComplexType | undefined;
|
|
5
|
+
Kind: MsGraphModelKind;
|
|
6
|
+
}
|
|
7
|
+
export interface EntityType {
|
|
8
|
+
StructuredType: StructuredType;
|
|
9
|
+
KeyProperty: [string, ModelProperty] | undefined;
|
|
10
|
+
Properties: MsGraphModelProperty[];
|
|
11
|
+
AlternateKeys: AlternateKeyProperty[];
|
|
12
|
+
StreamTypes: string[];
|
|
13
|
+
RevisionDefinition: RevisionDefinition | undefined;
|
|
14
|
+
Description: string | undefined;
|
|
15
|
+
}
|
|
16
|
+
export interface ComplexType {
|
|
17
|
+
StructuredType: StructuredType;
|
|
18
|
+
Properties: MsGraphModelProperty[];
|
|
19
|
+
RevisionDefinition: RevisionDefinition | undefined;
|
|
20
|
+
Description: string | undefined;
|
|
21
|
+
}
|
|
22
|
+
export declare enum MsGraphModelKind {
|
|
23
|
+
Unknown = 0,
|
|
24
|
+
Entity = 1,
|
|
25
|
+
Complex = 2
|
|
26
|
+
}
|
|
27
|
+
export interface StructuredType {
|
|
28
|
+
Name: string;
|
|
29
|
+
Abstract?: string;
|
|
30
|
+
BaseType?: string;
|
|
31
|
+
Children?: any;
|
|
32
|
+
[key: string]: any;
|
|
33
|
+
}
|
|
34
|
+
export interface MsGraphModelProperty {
|
|
35
|
+
Name: string;
|
|
36
|
+
IsNavigation: boolean;
|
|
37
|
+
IsNullable: boolean;
|
|
38
|
+
AgsAttributes: Record<string, string>;
|
|
39
|
+
PropertyTypeName: string;
|
|
40
|
+
IsContained: boolean;
|
|
41
|
+
IsComputed: boolean;
|
|
42
|
+
Permission: "Read" | "Write" | null;
|
|
43
|
+
RevisionDefinition: RevisionDefinition | undefined;
|
|
44
|
+
Description: string | undefined;
|
|
45
|
+
}
|
|
46
|
+
export interface AlternateKeyProperty extends ModelProperty {
|
|
47
|
+
IsModel: boolean;
|
|
48
|
+
}
|
|
49
|
+
export declare function GetMsGraphModel(program: Program, model: Model): MsGraphModel;
|
|
50
|
+
//# sourceMappingURL=model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../src/entities/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,OAAO,EAAiB,MAAM,oBAAoB,CAAA;AACjF,OAAO,EAAyB,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAIpF,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,UAAU,GAAG,WAAW,GAAG,SAAS,CAAC;IACjD,IAAI,EAAE,gBAAgB,CAAC;CACxB;AAED,MAAM,WAAW,UAAU;IACzB,cAAc,EAAE,cAAc,CAAA;IAC9B,WAAW,EAAE,CAAC,MAAM,EAAE,aAAa,CAAC,GAAG,SAAS,CAAA;IAChD,UAAU,EAAE,oBAAoB,EAAE,CAAA;IAClC,aAAa,EAAE,oBAAoB,E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|
|
|
1
|
+
import { getDoc, isKey } from "@typespec/compiler";
|
|
2
|
+
import { GetRevisionDefinition } from "./revision-definition.js";
|
|
3
|
+
import { buildAttributes, isContains, isComputed, isReadOnly, isWriteOnly, isAlternateKey, isComplex, getStreamTypes, isEntity, isOpen, hasStream, isAbstract } from "../index.js";
|
|
4
|
+
import { isNavigationProperty, isTypeNullable, getPropertyTypeName, getIdForType } from "../utils.js";
|
|
5
|
+
export var MsGraphModelKind;
|
|
6
|
+
(function (MsGraphModelKind) {
|
|
7
|
+
MsGraphModelKind[MsGraphModelKind["Unknown"] = 0] = "Unknown";
|
|
8
|
+
MsGraphModelKind[MsGraphModelKind["Entity"] = 1] = "Entity";
|
|
9
|
+
MsGraphModelKind[MsGraphModelKind["Complex"] = 2] = "Complex";
|
|
10
|
+
})(MsGraphModelKind = MsGraphModelKind || (MsGraphModelKind = {}));
|
|
11
|
+
export function GetMsGraphModel(program, model) {
|
|
12
|
+
const kind = getModelKind(program, model);
|
|
13
|
+
switch (kind) {
|
|
14
|
+
case MsGraphModelKind.Entity: {
|
|
15
|
+
return {
|
|
16
|
+
Kind: kind,
|
|
17
|
+
Properties: {
|
|
18
|
+
StructuredType: getStructuredType(program, model),
|
|
19
|
+
KeyProperty: [...model.properties].find(([_, property]) => isKey(program, property)),
|
|
20
|
+
Properties: [...model.properties]
|
|
21
|
+
.map(([_, v]) => {
|
|
22
|
+
var _a;
|
|
23
|
+
return {
|
|
24
|
+
Name: v.name,
|
|
25
|
+
IsNavigation: isNavigationProperty(program, v),
|
|
26
|
+
IsNullable: isTypeNullable(program, v.type),
|
|
27
|
+
AgsAttributes: buildAttributes(program, v),
|
|
28
|
+
PropertyTypeName: getPropertyTypeName(program, v.type),
|
|
29
|
+
IsContained: isContains(program, v),
|
|
30
|
+
IsComputed: isComputed(program, v),
|
|
31
|
+
Permission: isReadOnly(program, v)
|
|
32
|
+
? "Read"
|
|
33
|
+
: isWriteOnly(program, v)
|
|
34
|
+
? "Write"
|
|
35
|
+
: null,
|
|
36
|
+
RevisionDefinition: GetRevisionDefinition(program, v, (_a = v.model) === null || _a === void 0 ? void 0 : _a.namespace),
|
|
37
|
+
Description: getDoc(program, v)
|
|
38
|
+
};
|
|
39
|
+
}),
|
|
40
|
+
AlternateKeys: [...model.properties]
|
|
41
|
+
.filter(([_, v]) => isAlternateKey(program, v))
|
|
42
|
+
.map(([_, key]) => {
|
|
43
|
+
const altProp = key;
|
|
44
|
+
altProp.IsModel = key.type.kind === "Model" && !isComplex(program, key.type);
|
|
45
|
+
return altProp;
|
|
46
|
+
}),
|
|
47
|
+
StreamTypes: getStreamTypes(program, model),
|
|
48
|
+
RevisionDefinition: GetRevisionDefinition(program, model, model.namespace),
|
|
49
|
+
Description: getDoc(program, model)
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
case MsGraphModelKind.Complex: {
|
|
54
|
+
return {
|
|
55
|
+
Kind: kind,
|
|
56
|
+
Properties: {
|
|
57
|
+
StructuredType: getStructuredType(program, model),
|
|
58
|
+
Properties: [...model.properties]
|
|
59
|
+
.map(([_, v]) => {
|
|
60
|
+
var _a;
|
|
61
|
+
return {
|
|
62
|
+
Name: v.name,
|
|
63
|
+
IsNavigation: isNavigationProperty(program, v),
|
|
64
|
+
IsNullable: isTypeNullable(program, v.type),
|
|
65
|
+
AgsAttributes: buildAttributes(program, v),
|
|
66
|
+
PropertyTypeName: getPropertyTypeName(program, v.type),
|
|
67
|
+
IsContained: isContains(program, v),
|
|
68
|
+
IsComputed: isComputed(program, v),
|
|
69
|
+
Permission: isReadOnly(program, v)
|
|
70
|
+
? "Read"
|
|
71
|
+
: isWriteOnly(program, v)
|
|
72
|
+
? "Write"
|
|
73
|
+
: null,
|
|
74
|
+
RevisionDefinition: GetRevisionDefinition(program, v, (_a = v.model) === null || _a === void 0 ? void 0 : _a.namespace),
|
|
75
|
+
Description: getDoc(program, v)
|
|
76
|
+
};
|
|
77
|
+
}),
|
|
78
|
+
RevisionDefinition: GetRevisionDefinition(program, model, model.namespace),
|
|
79
|
+
Description: getDoc(program, model)
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
default: {
|
|
84
|
+
return {
|
|
85
|
+
Kind: kind,
|
|
86
|
+
Properties: undefined,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function getModelKind(program, model) {
|
|
92
|
+
if (isEntity(program, model)) {
|
|
93
|
+
return MsGraphModelKind.Entity;
|
|
94
|
+
}
|
|
95
|
+
else if (isComplex(program, model)) {
|
|
96
|
+
return MsGraphModelKind.Complex;
|
|
97
|
+
}
|
|
98
|
+
return MsGraphModelKind.Unknown;
|
|
99
|
+
}
|
|
100
|
+
function getStructuredType(program, model) {
|
|
101
|
+
const props = {
|
|
102
|
+
Name: model.name,
|
|
103
|
+
};
|
|
104
|
+
if (isOpen(program, model)) {
|
|
105
|
+
props.OpenType = "true";
|
|
106
|
+
}
|
|
107
|
+
if (hasStream(program, model)) {
|
|
108
|
+
props.HasStream = "true";
|
|
109
|
+
}
|
|
110
|
+
if (model.baseModel) {
|
|
111
|
+
props.BaseType = getIdForType(program, model.baseModel);
|
|
112
|
+
}
|
|
113
|
+
if (isAbstract(program, model)) {
|
|
114
|
+
props.Abstract = "true";
|
|
115
|
+
}
|
|
116
|
+
const agsAttributes = buildAttributes(program, model);
|
|
117
|
+
return Object.assign(props, agsAttributes);
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../../src/entities/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiC,MAAM,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AACjF,OAAO,EAAE,qBAAqB,EAAsB,MAAM,0BAA0B,CAAA;AACpF,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW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EntityContainer } from "./entity-container.js";
|
|
5
|
+
import { MsGraphOperation } from "./operation.js";
|
|
6
|
+
export interface MsGraphNamespace {
|
|
7
|
+
Name: string;
|
|
8
|
+
Enums: MsGraphEnum[];
|
|
9
|
+
Models: MsGraphModel[];
|
|
10
|
+
EntityContainer: EntityContainer;
|
|
11
|
+
Operations: MsGraphOperation[];
|
|
12
|
+
}
|
|
13
|
+
export declare function GetMsGraphNamespaces(program: Program): MsGraphNamespace[];
|
|
14
|
+
//# sourceMappingURL=namespace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"namespace.d.ts","sourceRoot":"","sources":["../../../src/entities/namespace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,OAAO,EAAQ,MAAM,oBAAoB,CAAC;AAE9D,OAAO,EAA6B,WAAW,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,EAAmB,YAAY,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAsB,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAuB,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvE,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,WAAW,EAAE,CAAC;IACrB,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,eAAe,EAAE,eAAe,CAAC;IACjC,UAAU,EAAE,gBAAgB,EAAE,CAAC;CAChC;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,gBAAgB,EAAE,CAOzE"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { getNamespaceName, isExcludedCoreType } from "../utils.js";
|
|
2
|
+
import { GetMsGraphEnumTypeElement } from "./enum.js";
|
|
3
|
+
import { GetMsGraphModel } from "./model.js";
|
|
4
|
+
import { GetEntityContainer } from "./entity-container.js";
|
|
5
|
+
import { GetMsGraphOperation } from "./operation.js";
|
|
6
|
+
export function GetMsGraphNamespaces(program) {
|
|
7
|
+
const root = program.checker.getGlobalNamespaceType();
|
|
8
|
+
const namespaces = expandNamespaces(root)
|
|
9
|
+
.filter((namespace) => !isExcludedCoreType(program, namespace) && hasChildren(namespace))
|
|
10
|
+
.map((namespace) => getMsGraphNamespace(program, namespace));
|
|
11
|
+
return namespaces;
|
|
12
|
+
}
|
|
13
|
+
function expandNamespaces(namespace) {
|
|
14
|
+
return [namespace, ...[...namespace.namespaces.values()].flatMap(expandNamespaces)];
|
|
15
|
+
}
|
|
16
|
+
function hasChildren(type) {
|
|
17
|
+
switch (type.kind) {
|
|
18
|
+
case "Namespace":
|
|
19
|
+
return type.enums.size || type.models.size || type.interfaces.size || type.operations.size;
|
|
20
|
+
default:
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function getMsGraphNamespace(program, namespace) {
|
|
25
|
+
const models = [...namespace.models].map(([_, m]) => GetMsGraphModel(program, m));
|
|
26
|
+
const enums = [...namespace.enums].map(([_, e]) => GetMsGraphEnumTypeElement(program, e));
|
|
27
|
+
const entityContainer = GetEntityContainer(program, namespace);
|
|
28
|
+
const operations = [...namespace.interfaces]
|
|
29
|
+
.filter(([_, $interface]) => $interface.operations.has("_isOperation"))
|
|
30
|
+
.flatMap(([_, $interface]) => [...$interface.operations])
|
|
31
|
+
.map(([_, operation]) => GetMsGraphOperation(program, operation))
|
|
32
|
+
.filter((o) => !!o);
|
|
33
|
+
return {
|
|
34
|
+
Name: getNamespaceName(program, namespace),
|
|
35
|
+
Enums: enums,
|
|
36
|
+
Models: models,
|
|
37
|
+
EntityContainer: entityContainer,
|
|
38
|
+
Operations: operations,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=namespace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"namespace.js","sourceRoot":"","sources":["../../../src/entities/namespace.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,kBAAk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+
}
|
|
7
|
+
export interface MsGraphOperation {
|
|
8
|
+
Name: string;
|
|
9
|
+
Kind: OperationKind;
|
|
10
|
+
BindingTypeName: string;
|
|
11
|
+
AgsAttributes: Record<string, string>;
|
|
12
|
+
Properties: MsGraphOperationProperty[];
|
|
13
|
+
UnionProperties: MsGraphOperationProperty[][];
|
|
14
|
+
IsVoid: boolean;
|
|
15
|
+
IsNullable: boolean;
|
|
16
|
+
ReturnTypeName: string;
|
|
17
|
+
Description: string | undefined;
|
|
18
|
+
}
|
|
19
|
+
export interface MsGraphOperationProperty {
|
|
20
|
+
Name: string;
|
|
21
|
+
IsNullable: boolean;
|
|
22
|
+
PropertyTypeName: string;
|
|
23
|
+
IsOptional: boolean;
|
|
24
|
+
DefaultValue: Record<string, unknown> | undefined;
|
|
25
|
+
Description: string | undefined;
|
|
26
|
+
}
|
|
27
|
+
export declare function GetMsGraphOperation(program: Program, operation: Operation): MsGraphOperation | undefined;
|
|
28
|
+
//# sourceMappingURL=operation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../../src/entities/operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAA4C,MAAM,oBAAoB,CAAA;AAOjG,oBAAY,aAAa;IACvB,OAAO,IAAA;IACP,MAAM,IAAA;IACN,QAAQ,IAAA;CACT;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,aAAa,CAAA;IACnB,eAAe,EAAE,MAAM,CAAA;IACvB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACrC,UAAU,EAAE,wBAAwB,EAAE,CAAA;IACtC,eAAe,EAAE,wBAAwB,EAAE,EAAE,CAAA;IAC7C,MAAM,EAAE,OAAO,CAAA;IACf,UAAU,EAAE,OAAO,CAAA;IACnB,cAAc,EAAE,MAAM,CAAA;IACtB,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;CAChC;AAED,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,OAAO,CAAA;IACnB,gBAAgB,EAAE,MAAM,CAAA;IACxB,UAAU,EAAE,OAAO,CAAA;IACnB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAA;IACjD,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;CAChC;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,GAAG,gBAAgB,GAAG,SAAS,CAuDxG"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { isVoidType, getDoc } from "@typespec/compiler";
|
|
2
|
+
import { isPathParam } from "@typespec/http";
|
|
3
|
+
import { getAction } from "@typespec/rest";
|
|
4
|
+
import { buildAttributes, getFunction, isOperationParameters } from "../index.js";
|
|
5
|
+
import { isTypeNullable, getPropertyTypeName, extractTypesFromUnion } from "../utils.js";
|
|
6
|
+
import { getDefaultPropertyValue } from "./property.js";
|
|
7
|
+
export var OperationKind;
|
|
8
|
+
(function (OperationKind) {
|
|
9
|
+
OperationKind[OperationKind["Unknown"] = 0] = "Unknown";
|
|
10
|
+
OperationKind[OperationKind["Action"] = 1] = "Action";
|
|
11
|
+
OperationKind[OperationKind["Function"] = 2] = "Function";
|
|
12
|
+
})(OperationKind = OperationKind || (OperationKind = {}));
|
|
13
|
+
export function GetMsGraphOperation(program, operation) {
|
|
14
|
+
const bindingTypeName = getBindingTypeName(program, operation);
|
|
15
|
+
if (!bindingTypeName) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
const element = {
|
|
19
|
+
Name: "",
|
|
20
|
+
Kind: OperationKind.Unknown,
|
|
21
|
+
BindingTypeName: bindingTypeName,
|
|
22
|
+
AgsAttributes: buildAttributes(program, operation),
|
|
23
|
+
Properties: getParameterProperties(program, operation.parameters.properties),
|
|
24
|
+
UnionProperties: new Array,
|
|
25
|
+
IsVoid: isVoidType(operation.returnType),
|
|
26
|
+
IsNullable: false,
|
|
27
|
+
ReturnTypeName: "",
|
|
28
|
+
Description: getDoc(program, operation)
|
|
29
|
+
};
|
|
30
|
+
if (!element.IsVoid) {
|
|
31
|
+
const returnType = operation.returnType.kind === "Model" && !!operation.returnType.templateMapper && !!operation.returnType.templateMapper.args.length
|
|
32
|
+
? operation.returnType.templateMapper.args[0]
|
|
33
|
+
: operation.returnType;
|
|
34
|
+
if (!returnType || isVoidType(returnType)) {
|
|
35
|
+
element.IsVoid = true;
|
|
36
|
+
}
|
|
37
|
+
element.IsNullable = isTypeNullable(program, operation.returnType);
|
|
38
|
+
element.ReturnTypeName = getPropertyTypeName(program, returnType);
|
|
39
|
+
}
|
|
40
|
+
const actionName = getAction(program, operation);
|
|
41
|
+
if (actionName) {
|
|
42
|
+
element.Name = actionName;
|
|
43
|
+
element.Kind = OperationKind.Action;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
const functionName = getFunction(program, operation);
|
|
47
|
+
if (functionName) {
|
|
48
|
+
element.Name = functionName;
|
|
49
|
+
element.Kind = OperationKind.Function;
|
|
50
|
+
const parameterProperty = operation.parameters.properties.get("parameters");
|
|
51
|
+
if (parameterProperty && parameterProperty.type.kind === "Union") {
|
|
52
|
+
const parameterProperties = extractTypesFromUnion(parameterProperty.type)
|
|
53
|
+
.filter((type) => type.kind === "Model")
|
|
54
|
+
.map((m) => getParameterProperties(program, m.properties));
|
|
55
|
+
element.UnionProperties.push(...parameterProperties);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return element;
|
|
60
|
+
}
|
|
61
|
+
function getBindingTypeName(program, operation) {
|
|
62
|
+
var _a, _b;
|
|
63
|
+
const bindingType = (_b = (_a = operation.interface) === null || _a === void 0 ? void 0 : _a.operations.get("_isOperation")) === null || _b === void 0 ? void 0 : _b.returnType;
|
|
64
|
+
if (!bindingType) {
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
return getPropertyTypeName(program, bindingType);
|
|
68
|
+
}
|
|
69
|
+
function getParameterProperties(program, parameters) {
|
|
70
|
+
const properties = [...parameters].flatMap(([, property]) => {
|
|
71
|
+
if (isPathParam(program, property)) {
|
|
72
|
+
return [];
|
|
73
|
+
}
|
|
74
|
+
if (property.type.kind === "Model" && isOperationParameters(program, property.type)) {
|
|
75
|
+
return getParameterProperties(program, property.type.properties);
|
|
76
|
+
}
|
|
77
|
+
return [{
|
|
78
|
+
Name: property.name,
|
|
79
|
+
IsNullable: isTypeNullable(program, property.type),
|
|
80
|
+
PropertyTypeName: getPropertyTypeName(program, property.type),
|
|
81
|
+
IsOptional: property.optional,
|
|
82
|
+
DefaultValue: getDefaultPropertyValue(program, property),
|
|
83
|
+
Description: getDoc(program, property),
|
|
84
|
+
}];
|
|
85
|
+
});
|
|
86
|
+
return properties;
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=operation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation.js","sourceRoot":"","sources":["../../../src/entities/operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,UAAU,EAAE,MAAM,EAAwB,MAAM,oBAAoB,CAAA;AACjG,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AACjF,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AACxF,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAA;AAEvD,MAAM,CAAN,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,uDAAO,CAAA;IACP,qDAAM,CAAA;IACN,yDAAQ,CAAA;AACV,CAAC,EA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AAS,CAuDrC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { getPropertyTypeName } from "../utils.js";
|
|
2
|
+
export function getDefaultPropertyValue(program, property) {
|
|
3
|
+
if (!property.default) {
|
|
4
|
+
return undefined;
|
|
5
|
+
}
|
|
6
|
+
let defaultValueValue = undefined;
|
|
7
|
+
switch (property.default.kind) {
|
|
8
|
+
case "String":
|
|
9
|
+
case "Boolean":
|
|
10
|
+
case "Number":
|
|
11
|
+
defaultValueValue = property.default.value;
|
|
12
|
+
break;
|
|
13
|
+
default:
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
const propType = getPropertyTypeName(program, property.type);
|
|
17
|
+
let defaultValueKey = "String";
|
|
18
|
+
switch (propType) {
|
|
19
|
+
case "Edm.String":
|
|
20
|
+
defaultValueKey = "String";
|
|
21
|
+
break;
|
|
22
|
+
case "Collection(Edm.Byte)":
|
|
23
|
+
defaultValueKey = "Binary";
|
|
24
|
+
break;
|
|
25
|
+
case "Edm.Byte":
|
|
26
|
+
case "Edm.Int16":
|
|
27
|
+
case "Edm.Int32":
|
|
28
|
+
case "Edm.Int64":
|
|
29
|
+
defaultValueKey = "Int";
|
|
30
|
+
break;
|
|
31
|
+
case "Edm.Single":
|
|
32
|
+
case "Edm.Double":
|
|
33
|
+
defaultValueKey = "Single";
|
|
34
|
+
break;
|
|
35
|
+
case "Edm.Date":
|
|
36
|
+
defaultValueKey = "Date";
|
|
37
|
+
break;
|
|
38
|
+
case "Edm.DateTimeOffset":
|
|
39
|
+
defaultValueKey = "DateTimeOffset";
|
|
40
|
+
break;
|
|
41
|
+
case "Edm.Boolean":
|
|
42
|
+
defaultValueKey = "Boolean";
|
|
43
|
+
break;
|
|
44
|
+
case "Edm.Stream":
|
|
45
|
+
defaultValueKey = "Binary";
|
|
46
|
+
break;
|
|
47
|
+
case "Edm.Duration":
|
|
48
|
+
case "Edm.TimeOfDay":
|
|
49
|
+
default:
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
return { [defaultValueKey]: defaultValueValue };
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=property.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"property.js","sourceRoot":"","sources":["../../../src/entities/property.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAElD,MAAM,UAAU,uBAAuB,CACrC,OAAgB,EAChB,QAAuB;IAEvB,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE;QACrB,OAAO,SAAS,CAAC;KAClB;IAED,IAAI,iBAAiB,GAAQ,SAAS,CAAC;IACvC,QAAQ,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE;QAC7B,KAAK,QAAQ,CAAC;QACd,KAAK,SAAS,CAAC;QACf,KAAK,QAAQ;YACX,iBAAiB,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC;YAC3C,MAAM;QACR;YACE,OAAO,SAAS,CAAC;KACpB;IAED,MAAM,QAAQ,GAAG,mBAAmB,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IAE7D,IAAI,eAAe,GAAG,QAAQ,CAAC;IAC/B,QAAQ,QAAQ,EAAE;QAChB,KAAK,YAAY;YACf,eAAe,GAAG,QAAQ,CAAC;YAC3B,MAAM;QACR,KAAK,sBAAsB;YACzB,eAAe,GAAG,QAAQ,CAAC;YAC3B,MAAM;QACR,KAAK,UAAU,CAAC;QAChB,KAAK,WAAW,CAAC;QACjB,KAAK,WAAW,CAAC;QACjB,KAAK,WAAW;YACd,eAAe,GAAG,KAAK,CAAC;YACxB,MAAM;QACR,KAAK,YAAY,CAAC;QAClB,KAAK,YAAY;YACf,eAAe,GAAG,QAAQ,CAAC;YAC3B,MAAM;QACR,KAAK,UAAU;YACb,eAAe,GAAG,MAAM,CAAC;YACzB,MAAM;QACR,KAAK,oBAAoB;YACvB,eAAe,GAAG,gBAAgB,CAAC;YACnC,MAAM;QACR,KAAK,aAAa;YAChB,eAAe,GAAG,SAAS,CAAC;YAC5B,MAAM;QACR,KAAK,YAAY;YACf,eAAe,GAAG,QAAQ,CAAC;YAC3B,MAAM;QACR,KAAK,cAAc,CAAC;QACpB,KAAK,eAAe,CAAC;QACrB;YACE,OAAO,SAAS,CAAC;KACpB;IAED,OAAO,EAAE,CAAC,eAAe,CAAC,EAAE,iBAAiB,EAAE,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Enum, EnumMember, Model, ModelProperty, Namespace, Operation, Program } from "@typespec/compiler";
|
|
2
|
+
export interface RevisionDefinition {
|
|
3
|
+
Date: string;
|
|
4
|
+
Version: string;
|
|
5
|
+
Description?: string;
|
|
6
|
+
RemovalDate: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function GetRevisionDefinition(program: Program, item: Model | ModelProperty | EnumMember | Enum | Operation | Namespace, namespace: Namespace | undefined): RevisionDefinition | undefined;
|
|
9
|
+
//# sourceMappingURL=revision-definition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revision-definition.d.ts","sourceRoot":"","sources":["../../../src/entities/revision-definition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAiB,MAAM,oBAAoB,CAAC;AAG1H,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,KAAK,GAAG,aAAa,GAAG,UAAU,GAAG,IAAI,GAAG,SAAS,GAAG,SAAS,EACvE,SAAS,EAAE,SAAS,GAAG,SAAS,GAC/B,kBAAkB,GAAG,SAAS,CAgBhC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { getDeprecated } from "@typespec/compiler";
|
|
2
|
+
import { getPrivatePreview, getDeprecatedDefinitions, getPrivatePreviewDefinitions } from "../index.js";
|
|
3
|
+
export function GetRevisionDefinition(program, item, namespace) {
|
|
4
|
+
if (!namespace) {
|
|
5
|
+
return undefined;
|
|
6
|
+
}
|
|
7
|
+
const deprecated = getDeprecated(program, item);
|
|
8
|
+
if (deprecated) {
|
|
9
|
+
return getRevisionDefinitionFromDeprecation(program, namespace, deprecated);
|
|
10
|
+
}
|
|
11
|
+
const privatePreview = getPrivatePreview(program, item);
|
|
12
|
+
if (privatePreview) {
|
|
13
|
+
return getRevisionDefinitionFromPrivatePreview(program, namespace, privatePreview);
|
|
14
|
+
}
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
function getRevisionDefinitionFromDeprecation(program, namespace, deprecated) {
|
|
18
|
+
const deprecatedDefinitions = getDeprecatedDefinitions(program, namespace);
|
|
19
|
+
const definition = deprecatedDefinitions.get(deprecated);
|
|
20
|
+
if (!definition) {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
Date: definition.announcementDate,
|
|
25
|
+
RemovalDate: definition.removalDate,
|
|
26
|
+
Version: `${definition.announcementDate.substring(0, 7)}/${definition.category}`,
|
|
27
|
+
Description: definition.description,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function getRevisionDefinitionFromPrivatePreview(program, namespace, deprecated) {
|
|
31
|
+
const privatePreviewDefinitions = getPrivatePreviewDefinitions(program, namespace);
|
|
32
|
+
const definition = privatePreviewDefinitions.get(deprecated);
|
|
33
|
+
if (!definition) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
Date: definition.announcementDate,
|
|
38
|
+
RemovalDate: definition.removalDate,
|
|
39
|
+
Version: `${definition.announcementDate.substring(0, 7)}/PrivatePreview:${definition.name}`,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=revision-definition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revision-definition.js","sourceRoot":"","sources":["../../../src/entities/revision-definition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC1H,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AASxG,MAAM,UAAU,qBAAqB,CACnC,OAAgB,EAChB,IAAuE,EACvE,SAAgC;IAEhC,IAAI,CAAC,SAAS,EAAE;QACd,OAAO,SAAS,CAAA;KACjB;IAED,MAAM,UAAU,GAAG,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAChD,IAAI,UAAU,EAAE;QACd,OAAO,oCAAoC,CAAC,OAAO,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;KAC7E;IAED,MAAM,cAAc,GAAG,iBAAiB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACxD,IAAI,cAAc,EAAE;QAClB,OAAO,uCAAuC,CAAC,OAAO,EAAE,SAAS,EAAE,cAAc,CAAC,CAAC;KACpF;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,oCAAoC,CAC3C,OAAgB,EAChB,SAAoB,EACpB,UAAkB;IAElB,MAAM,qBAAqB,GAAG,wBAAwB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IAC3E,MAAM,UAAU,GAAG,qBAAqB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACzD,IAAI,CAAC,UAAU,EAAE;QACf,OAAO,SAAS,CAAC;KAClB;IAED,OAAO;QACL,IAAI,EAAE,UAAU,CAAC,gBAAgB;QACjC,WAAW,EAAE,UAAU,CAAC,WAAW;QACnC,OAAO,EAAE,GAAG,UAAU,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,UAAU,CAAC,QAAQ,EAAE;QAChF,WAAW,EAAE,UAAU,CAAC,WAAW;KACpC,CAAC;AACJ,CAAC;AAED,SAAS,uCAAuC,CAC9C,OAAgB,EAChB,SAAoB,EACpB,UAAkB;IAElB,MAAM,yBAAyB,GAAG,4BAA4B,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IACnF,MAAM,UAAU,GAAG,yBAAyB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC7D,IAAI,CAAC,UAAU,EAAE;QACf,OAAO,SAAS,CAAC;KAClB;IAED,OAAO;QACL,IAAI,EAAE,UAAU,CAAC,gBAAgB;QACjC,WAAW,EAAE,UAAU,CAAC,WAAW;QACnC,OAAO,EAAE,GAAG,UAAU,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,mBAAmB,UAAU,CAAC,IAAI,EAAE;KAC5F,CAAC;AACJ,CAAC"}
|
package/dist/src/index.d.ts
CHANGED
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC"}
|
package/dist/src/index.js
CHANGED
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../../../src/rules/entity.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../../../src/rules/entity.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,qBAAqB,mCA2BhC,CAAC;AAEH,eAAO,MAAM,+CAA+C,mCAwC1D,CAAC"}
|
package/dist/src/rules/entity.js
CHANGED
|
@@ -2,6 +2,7 @@ import { isKey, walkPropertiesInherited } from "@typespec/compiler";
|
|
|
2
2
|
import { createRule } from "@typespec/lint";
|
|
3
3
|
import { isEntity } from "../index.js";
|
|
4
4
|
import { reportDiagnostic } from "../lib.js";
|
|
5
|
+
import { isTypeNullable } from "../utils.js";
|
|
5
6
|
export const entityMustHaveKeyRule = createRule({
|
|
6
7
|
name: "entity-must-have-key",
|
|
7
8
|
create({ program }) {
|
|
@@ -28,4 +29,39 @@ export const entityMustHaveKeyRule = createRule({
|
|
|
28
29
|
};
|
|
29
30
|
},
|
|
30
31
|
});
|
|
32
|
+
export const keyOnlyOnEntityNonNullablePrimitivePropertyRule = createRule({
|
|
33
|
+
name: "key-only-on-entity-non-nullable-primitive-property",
|
|
34
|
+
create({ program }) {
|
|
35
|
+
return {
|
|
36
|
+
modelProperty: (property) => {
|
|
37
|
+
if (!property.model || !isKey(program, property)) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (!isEntity(program, property.model)) {
|
|
41
|
+
reportDiagnostic(program, {
|
|
42
|
+
code: "decorator-missing-dependencies",
|
|
43
|
+
target: property,
|
|
44
|
+
format: {
|
|
45
|
+
decorator: "@key",
|
|
46
|
+
required: "@entity",
|
|
47
|
+
location: "entity model",
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (isTypeNullable(program, property.type) ||
|
|
53
|
+
property.type.kind !== "Scalar" ||
|
|
54
|
+
property.name === "Array") {
|
|
55
|
+
reportDiagnostic(program, {
|
|
56
|
+
code: "decorator-invalid-use",
|
|
57
|
+
target: property,
|
|
58
|
+
messageId: "key",
|
|
59
|
+
format: {},
|
|
60
|
+
});
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
},
|
|
66
|
+
});
|
|
31
67
|
//# sourceMappingURL=entity.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity.js","sourceRoot":"","sources":["../../../src/rules/entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C,MAAM,CAAC,MAAM,qBAAqB,GAAG,UAAU,CAAC;IAC9C,IAAI,EAAE,sBAAsB;IAC5B,MAAM,CAAC,EAAE,OAAO,EAAE;QAChB,OAAO;YACL,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE;gBACf,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE;oBAC7B,OAAO;iBACR;gBAED,KAAK,MAAM,QAAQ,IAAI,uBAAuB,CAAC,KAAK,CAAC,EAAE;oBACrD,IAAI,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE;wBAC5B,OAAO;qBACR;iBACF;gBAED,gBAAgB,CAAC,OAAO,EAAE;oBACxB,IAAI,EAAE,gCAAgC;oBACtC,MAAM,EAAE,KAAK;oBACb,MAAM,EAAE;wBACN,SAAS,EAAE,SAAS;wBACpB,QAAQ,EAAE,MAAM;wBAChB,QAAQ,EAAE,uBAAuB;qBAClC;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"entity.js","sourceRoot":"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