@microsoft/typespec-msgraph 0.0.1-Preview.6 → 0.0.1-Preview.8
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/annotations.d.ts +5 -5
- package/dist/src/components/annotations.d.ts.map +1 -1
- package/dist/src/components/annotations.js +21 -20
- package/dist/src/components/annotations.js.map +1 -1
- package/dist/src/components/count-restrictions-annotation.d.ts +1 -1
- package/dist/src/components/count-restrictions-annotation.d.ts.map +1 -1
- package/dist/src/components/count-restrictions-annotation.js +2 -2
- package/dist/src/components/count-restrictions-annotation.js.map +1 -1
- package/dist/src/components/expand-restrictions-annotation.d.ts +1 -1
- package/dist/src/components/expand-restrictions-annotation.d.ts.map +1 -1
- package/dist/src/components/expand-restrictions-annotation.js +3 -3
- package/dist/src/components/expand-restrictions-annotation.js.map +1 -1
- package/dist/src/components/filter-restrictions-annotation.d.ts +6 -0
- package/dist/src/components/filter-restrictions-annotation.d.ts.map +1 -0
- package/dist/src/components/filter-restrictions-annotation.js +10 -0
- package/dist/src/components/filter-restrictions-annotation.js.map +1 -0
- package/dist/src/components/immutable-annotation.d.ts +5 -0
- package/dist/src/components/immutable-annotation.d.ts.map +1 -0
- package/dist/src/components/immutable-annotation.js +6 -0
- package/dist/src/components/immutable-annotation.js.map +1 -0
- package/dist/src/components/insert-restrictions-annotation.d.ts +6 -0
- package/dist/src/components/insert-restrictions-annotation.d.ts.map +1 -0
- package/dist/src/components/insert-restrictions-annotation.js +10 -0
- package/dist/src/components/insert-restrictions-annotation.js.map +1 -0
- package/dist/src/components/property-element.d.ts.map +1 -1
- package/dist/src/components/property-element.js +4 -2
- package/dist/src/components/property-element.js.map +1 -1
- package/dist/src/components/schema-element.d.ts.map +1 -1
- package/dist/src/components/schema-element.js +6 -6
- package/dist/src/components/schema-element.js.map +1 -1
- package/dist/src/components/search-restrictions-annotation.d.ts +1 -1
- package/dist/src/components/search-restrictions-annotation.d.ts.map +1 -1
- package/dist/src/components/search-restrictions-annotation.js +2 -2
- package/dist/src/components/search-restrictions-annotation.js.map +1 -1
- package/dist/src/components/skip-supported-annotation.d.ts +1 -1
- package/dist/src/components/skip-supported-annotation.d.ts.map +1 -1
- package/dist/src/components/skip-supported-annotation.js +1 -1
- package/dist/src/components/skip-supported-annotation.js.map +1 -1
- package/dist/src/components/sort-restrictions-annotation.d.ts +1 -1
- package/dist/src/components/sort-restrictions-annotation.d.ts.map +1 -1
- package/dist/src/components/sort-restrictions-annotation.js +3 -3
- package/dist/src/components/sort-restrictions-annotation.js.map +1 -1
- package/dist/src/components/top-supported-annotation.d.ts +1 -1
- package/dist/src/components/top-supported-annotation.d.ts.map +1 -1
- package/dist/src/components/top-supported-annotation.js +2 -2
- package/dist/src/components/top-supported-annotation.js.map +1 -1
- package/dist/src/decorators/action.d.ts +10 -0
- package/dist/src/decorators/action.d.ts.map +1 -0
- package/dist/src/decorators/action.js +16 -0
- package/dist/src/decorators/action.js.map +1 -0
- package/dist/src/decorators/filter.d.ts +11 -0
- package/dist/src/decorators/filter.d.ts.map +1 -0
- package/dist/src/decorators/filter.js +27 -0
- package/dist/src/decorators/filter.js.map +1 -0
- package/dist/src/decorators/graph-route.d.ts +1 -1
- package/dist/src/decorators/graph-route.d.ts.map +1 -1
- package/dist/src/decorators/graph-route.js +12 -7
- package/dist/src/decorators/graph-route.js.map +1 -1
- package/dist/src/decorators/immutable.d.ts +8 -0
- package/dist/src/decorators/immutable.d.ts.map +1 -0
- package/dist/src/decorators/immutable.js +12 -0
- package/dist/src/decorators/immutable.js.map +1 -0
- package/dist/src/decorators/index.d.ts +4 -0
- package/dist/src/decorators/index.d.ts.map +1 -1
- package/dist/src/decorators/index.js +4 -0
- package/dist/src/decorators/index.js.map +1 -1
- package/dist/src/decorators/required-for-create.d.ts +10 -0
- package/dist/src/decorators/required-for-create.d.ts.map +1 -0
- package/dist/src/decorators/required-for-create.js +14 -0
- package/dist/src/decorators/required-for-create.js.map +1 -0
- package/dist/src/entities/annotations.d.ts +20 -17
- package/dist/src/entities/annotations.d.ts.map +1 -1
- package/dist/src/entities/annotations.js +69 -48
- package/dist/src/entities/annotations.js.map +1 -1
- package/dist/src/entities/entity-container.js +1 -1
- package/dist/src/entities/entity-container.js.map +1 -1
- package/dist/src/entities/model.d.ts +1 -0
- package/dist/src/entities/model.d.ts.map +1 -1
- package/dist/src/entities/model.js +2 -1
- package/dist/src/entities/model.js.map +1 -1
- package/dist/src/entities/namespace.d.ts +3 -3
- package/dist/src/entities/namespace.d.ts.map +1 -1
- package/dist/src/entities/namespace.js +34 -8
- package/dist/src/entities/namespace.js.map +1 -1
- package/dist/src/entities/operation.d.ts.map +1 -1
- package/dist/src/entities/operation.js +1 -2
- package/dist/src/entities/operation.js.map +1 -1
- package/dist/src/entities/property.d.ts.map +1 -1
- package/dist/src/entities/property.js +3 -0
- package/dist/src/entities/property.js.map +1 -1
- package/dist/src/entities/revision-definition.d.ts +1 -1
- package/dist/src/entities/revision-definition.js +3 -3
- package/dist/src/lib.d.ts +16 -0
- package/dist/src/lib.d.ts.map +1 -1
- package/dist/src/lib.js +4 -0
- package/dist/src/lib.js.map +1 -1
- package/dist/src/linter.d.ts.map +1 -1
- package/dist/src/linter.js +4 -0
- package/dist/src/linter.js.map +1 -1
- package/dist/src/rules/collection-navigation-properties-not-nullable.d.ts +2 -0
- package/dist/src/rules/collection-navigation-properties-not-nullable.d.ts.map +1 -0
- package/dist/src/rules/collection-navigation-properties-not-nullable.js +28 -0
- package/dist/src/rules/collection-navigation-properties-not-nullable.js.map +1 -0
- package/dist/src/rules/count.js +2 -2
- package/dist/src/rules/count.js.map +1 -1
- package/dist/src/rules/disallowed-typespec-decorators.d.ts +2 -0
- package/dist/src/rules/disallowed-typespec-decorators.d.ts.map +1 -0
- package/dist/src/rules/disallowed-typespec-decorators.js +33 -0
- package/dist/src/rules/disallowed-typespec-decorators.js.map +1 -0
- package/dist/src/rules/extends-on-same-type.d.ts +2 -0
- package/dist/src/rules/extends-on-same-type.d.ts.map +1 -0
- package/dist/src/rules/extends-on-same-type.js +38 -0
- package/dist/src/rules/extends-on-same-type.js.map +1 -0
- package/dist/src/rules/filter.d.ts +4 -0
- package/dist/src/rules/filter.d.ts.map +1 -0
- package/dist/src/rules/filter.js +92 -0
- package/dist/src/rules/filter.js.map +1 -0
- package/dist/src/rules/graph-route.d.ts +5 -0
- package/dist/src/rules/graph-route.d.ts.map +1 -0
- package/dist/src/rules/graph-route.js +39 -0
- package/dist/src/rules/graph-route.js.map +1 -0
- package/dist/src/rules/index.d.ts +7 -3
- package/dist/src/rules/index.d.ts.map +1 -1
- package/dist/src/rules/index.js +7 -89
- package/dist/src/rules/index.js.map +1 -1
- package/dist/src/rules/operation-inside-interface.d.ts +2 -0
- package/dist/src/rules/operation-inside-interface.d.ts.map +1 -0
- package/dist/src/rules/operation-inside-interface.js +25 -0
- package/dist/src/rules/operation-inside-interface.js.map +1 -0
- package/dist/src/rules/order-by.js +2 -2
- package/dist/src/rules/order-by.js.map +1 -1
- package/dist/src/rules/required-for-create.d.ts +2 -0
- package/dist/src/rules/required-for-create.d.ts.map +1 -0
- package/dist/src/rules/required-for-create.js +40 -0
- package/dist/src/rules/required-for-create.js.map +1 -0
- package/dist/src/rules/search.js +2 -2
- package/dist/src/rules/search.js.map +1 -1
- package/dist/src/rules/skip.js +2 -2
- package/dist/src/rules/skip.js.map +1 -1
- package/dist/src/rules/top.js +2 -2
- package/dist/src/rules/top.js.map +1 -1
- package/dist/src/utils.d.ts +16 -4
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +81 -31
- package/dist/src/utils.js.map +1 -1
- package/lib/decorators.tsp +32 -0
- package/lib/lib.tsp +4 -15
- package/package.json +1 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter.js","sourceRoot":"","sources":["../../../src/rules/filter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,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C,EAAE;oBACjC,OAAO;iBACR;gBAED,MAAM,gBAAgB,GAAG,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;gBACvD,IAAI,gBAAgB,CAAC,MAAM,EAAE;oBAC3B,OAAO;iBACR;gBAED,gBAAgB,CAAC,OAAO,EAAE;oBACxB,IAAI,EAAE,uBAAuB;oBAC7B,MAAM,EAAE,SAAS;oBACjB,SAAS,EAAE,UAAU;oBACrB,MAAM,EAAE;wBACN,SAAS,EAAE,SAAS;wBACpB,UAAU,EAAE,mBAAmB;qBAChC;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph-route.d.ts","sourceRoot":"","sources":["../../../src/rules/graph-route.ts"],"names":[],"mappings":"AAKA;;GAEG;AAEH,eAAO,MAAM,0BAA0B,mCAYrC,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { createRule } from "@typespec/lint";
|
|
2
|
+
import { reportDiagnostic } from "../lib.js";
|
|
3
|
+
import { getGraphRoutePath, hasGraphRoute } from "../index.js";
|
|
4
|
+
/**
|
|
5
|
+
* @graphRoute should not have a leading forward slash
|
|
6
|
+
*/
|
|
7
|
+
export const graphRouteLeadingSlashRule = createRule({
|
|
8
|
+
name: "graph-route-leading-slash",
|
|
9
|
+
create({ program }) {
|
|
10
|
+
return {
|
|
11
|
+
interface: (interface_) => {
|
|
12
|
+
applyDiagnostics(program, interface_);
|
|
13
|
+
},
|
|
14
|
+
operation: (operation) => {
|
|
15
|
+
applyDiagnostics(program, operation);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
const applyDiagnostics = (program, target) => {
|
|
21
|
+
if (!hasGraphRoute(program, target)) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const paths = getGraphRoutePath(program, target);
|
|
25
|
+
if (paths === undefined) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (paths[0].startsWith("/")) {
|
|
29
|
+
reportDiagnostic(program, {
|
|
30
|
+
code: "decorator-invalid-use",
|
|
31
|
+
target: target,
|
|
32
|
+
messageId: 'graphRoute',
|
|
33
|
+
format: {
|
|
34
|
+
decorator: "@graphRoute",
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=graph-route.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph-route.js","sourceRoot":"","sources":["../../../src/rules/graph-route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG/D;;GAEG;AAEH,MAAM,CAAC,MAAM,0BAA0B,GAAG,UAAU,CAAC;IACnD,IAAI,EAAE,2BAA2B;IACjC,MAAM,CAAC,EAAE,OAAO,EAAE;QAChB,OAAO;YACL,SAAS,EAAE,CAAC,UAAU,EAAE,EAAE;gBACxB,gBAAgB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;YACxC,CAAC;YACD,SAAS,EAAE,CAAC,SAAS,EAAE,EAAE;gBACvB,gBAAgB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;YACvC,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC;AAEH,MAAM,gBAAgB,GAAG,CAAC,OAAgB,EAAE,MAAY,EAAE,EAAE;IAC1D,IAAG,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE;QAClC,OAAO;KACR;IACD,MAAM,KAAK,GAAG,iBAAiB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC/C,IAAG,KAAK,KAAK,SAAS,EAAE;QACtB,OAAO;KACR;IAED,IAAG,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;QAC3B,gBAAgB,CAAC,OAAO,EAAE;YACxB,IAAI,EAAE,uBAAuB;YAC7B,MAAM,EAAE,MAAM;YACd,SAAS,EAAE,YAAY;YACvB,MAAM,EAAE;gBACN,SAAS,EAAE,aAAa;aACzB;SACF,CAAC,CAAC;KACJ;AACL,CAAC,CAAA"}
|
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
export * from "./abstract.js";
|
|
2
2
|
export * from "./alternate-key.js";
|
|
3
|
+
export * from "./collection-navigation-properties-not-nullable.js";
|
|
3
4
|
export * from "./computed.js";
|
|
4
5
|
export * from "./contains.js";
|
|
5
6
|
export * from "./count.js";
|
|
7
|
+
export * from "./disallowed-typespec-decorators.js";
|
|
6
8
|
export * from "./entity.js";
|
|
7
9
|
export * from "./enum.js";
|
|
8
10
|
export * from "./expand.js";
|
|
11
|
+
export * from "./extends-on-same-type.js";
|
|
12
|
+
export * from "./filter.js";
|
|
9
13
|
export * from "./function.js";
|
|
10
14
|
export * from "./has-stream.js";
|
|
11
15
|
export * from "./open.js";
|
|
16
|
+
export * from "./operation-inside-interface.js";
|
|
12
17
|
export * from "./order-by.js";
|
|
13
18
|
export * from "./references.js";
|
|
19
|
+
export * from "./required-for-create.js";
|
|
14
20
|
export * from "./search.js";
|
|
15
21
|
export * from "./skip.js";
|
|
16
22
|
export * from "./top.js";
|
|
17
|
-
export
|
|
18
|
-
export declare const extendsOnSameTypeRule: import("@typespec/lint").LintRule;
|
|
19
|
-
export declare const operationInsideInterfaceRule: import("@typespec/lint").LintRule;
|
|
23
|
+
export * from "./graph-route.js";
|
|
20
24
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/rules/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/rules/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,oDAAoD,CAAC;AACnE,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,qCAAqC,CAAC;AACpD,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,iCAAiC,CAAC;AAChD,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC"}
|
package/dist/src/rules/index.js
CHANGED
|
@@ -1,106 +1,24 @@
|
|
|
1
|
-
import { createRule } from "@typespec/lint";
|
|
2
|
-
import { isComplex, isEntity } from "../index.js";
|
|
3
|
-
import { reportDiagnostic } from "../lib.js";
|
|
4
|
-
import { isExcludedCoreType } from "../utils.js";
|
|
5
1
|
export * from "./abstract.js";
|
|
6
2
|
export * from "./alternate-key.js";
|
|
3
|
+
export * from "./collection-navigation-properties-not-nullable.js";
|
|
7
4
|
export * from "./computed.js";
|
|
8
5
|
export * from "./contains.js";
|
|
9
6
|
export * from "./count.js";
|
|
7
|
+
export * from "./disallowed-typespec-decorators.js";
|
|
10
8
|
export * from "./entity.js";
|
|
11
9
|
export * from "./enum.js";
|
|
12
10
|
export * from "./expand.js";
|
|
11
|
+
export * from "./extends-on-same-type.js";
|
|
12
|
+
export * from "./filter.js";
|
|
13
13
|
export * from "./function.js";
|
|
14
14
|
export * from "./has-stream.js";
|
|
15
15
|
export * from "./open.js";
|
|
16
|
+
export * from "./operation-inside-interface.js";
|
|
16
17
|
export * from "./order-by.js";
|
|
17
18
|
export * from "./references.js";
|
|
19
|
+
export * from "./required-for-create.js";
|
|
18
20
|
export * from "./search.js";
|
|
19
21
|
export * from "./skip.js";
|
|
20
22
|
export * from "./top.js";
|
|
21
|
-
export
|
|
22
|
-
name: "disallowed-typespec-decorators",
|
|
23
|
-
create({ program }) {
|
|
24
|
-
return {
|
|
25
|
-
decorator: (decorator) => {
|
|
26
|
-
const denyList = [
|
|
27
|
-
"@friendlyName",
|
|
28
|
-
"@secret",
|
|
29
|
-
"@summary",
|
|
30
|
-
"@tag",
|
|
31
|
-
"@visibility",
|
|
32
|
-
"@withVisibility",
|
|
33
|
-
"@withUpdateableProperties",
|
|
34
|
-
"@withDefaultKeyVisibility",
|
|
35
|
-
];
|
|
36
|
-
if (denyList.indexOf(decorator.name) < 0) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
reportDiagnostic(program, {
|
|
40
|
-
code: "decorator-invalid-use",
|
|
41
|
-
target: decorator.target,
|
|
42
|
-
messageId: "disallowedTypeSpecDecorators",
|
|
43
|
-
format: {
|
|
44
|
-
decorator: decorator.name,
|
|
45
|
-
},
|
|
46
|
-
});
|
|
47
|
-
},
|
|
48
|
-
};
|
|
49
|
-
},
|
|
50
|
-
});
|
|
51
|
-
export const extendsOnSameTypeRule = createRule({
|
|
52
|
-
name: "extends-on-same-type",
|
|
53
|
-
create({ program }) {
|
|
54
|
-
return {
|
|
55
|
-
model: (model) => {
|
|
56
|
-
if (!model.baseModel) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
if (isExcludedCoreType(program, model)) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
if (isEntity(program, model) && !isEntity(program, model.baseModel)) {
|
|
63
|
-
reportDiagnostic(program, {
|
|
64
|
-
code: "extends-invalid-use",
|
|
65
|
-
target: model,
|
|
66
|
-
format: {
|
|
67
|
-
type: "@entity",
|
|
68
|
-
},
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
if (isComplex(program, model) && !isComplex(program, model.baseModel)) {
|
|
72
|
-
reportDiagnostic(program, {
|
|
73
|
-
code: "extends-invalid-use",
|
|
74
|
-
target: model,
|
|
75
|
-
format: {
|
|
76
|
-
type: "@complex",
|
|
77
|
-
},
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
};
|
|
82
|
-
},
|
|
83
|
-
});
|
|
84
|
-
export const operationInsideInterfaceRule = createRule({
|
|
85
|
-
name: "operation-inside-interface",
|
|
86
|
-
create({ program }) {
|
|
87
|
-
return {
|
|
88
|
-
operation: (operation) => {
|
|
89
|
-
if (operation.interface) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
if (isExcludedCoreType(program, operation)) {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
return; // TODO: Work out the compiler bug and get it fixed. See #138
|
|
96
|
-
reportDiagnostic(program, {
|
|
97
|
-
code: "element-missing-dependencies",
|
|
98
|
-
target: operation,
|
|
99
|
-
messageId: "operation",
|
|
100
|
-
format: {},
|
|
101
|
-
});
|
|
102
|
-
},
|
|
103
|
-
};
|
|
104
|
-
},
|
|
105
|
-
});
|
|
23
|
+
export * from "./graph-route.js";
|
|
106
24
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/rules/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/rules/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,oDAAoD,CAAC;AACnE,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,qCAAqC,CAAC;AACpD,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,iCAAiC,CAAC;AAChD,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation-inside-interface.d.ts","sourceRoot":"","sources":["../../../src/rules/operation-inside-interface.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,4BAA4B,mCAsBvC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createRule } from "@typespec/lint";
|
|
2
|
+
import { reportDiagnostic } from "../lib.js";
|
|
3
|
+
import { isExcludedCoreType } from "../utils.js";
|
|
4
|
+
export const operationInsideInterfaceRule = createRule({
|
|
5
|
+
name: "operation-inside-interface",
|
|
6
|
+
create({ program }) {
|
|
7
|
+
return {
|
|
8
|
+
operation: (operation) => {
|
|
9
|
+
if (operation.interface) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
if (isExcludedCoreType(program, operation)) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
reportDiagnostic(program, {
|
|
16
|
+
code: "element-missing-dependencies",
|
|
17
|
+
target: operation,
|
|
18
|
+
messageId: "operation",
|
|
19
|
+
format: {},
|
|
20
|
+
});
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=operation-inside-interface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation-inside-interface.js","sourceRoot":"","sources":["../../../src/rules/operation-inside-interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,CAAC,MAAM,4BAA4B,GAAG,UAAU,CAAC;IACrD,IAAI,EAAE,4BAA4B;IAClC,MAAM,CAAC,EAAE,OAAO,EAAE;QAChB,OAAO;YACL,SAAS,EAAE,CAAC,SAAS,EAAE,EAAE;gBACvB,IAAI,SAAS,CAAC,SAAS,EAAE;oBACvB,OAAO;iBACR;gBAED,IAAI,kBAAkB,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE;oBAC1C,OAAO;iBACR;gBAED,gBAAgB,CAAC,OAAO,EAAE;oBACxB,IAAI,EAAE,8BAA8B;oBACpC,MAAM,EAAE,SAAS;oBACjB,SAAS,EAAE,WAAW;oBACtB,MAAM,EAAE,EAAE;iBACX,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -2,7 +2,7 @@ import { walkPropertiesInherited } from "@typespec/compiler";
|
|
|
2
2
|
import { createRule } from "@typespec/lint";
|
|
3
3
|
import { getOperationVerb } from "@typespec/http";
|
|
4
4
|
import { getOrderBy, isContains, isOrderBy, isReferences } from "../index.js";
|
|
5
|
-
import {
|
|
5
|
+
import { isTypeCollection } from "../utils.js";
|
|
6
6
|
import { reportDiagnostic } from "../lib.js";
|
|
7
7
|
import { getNavigationSourceType } from "../utils.js";
|
|
8
8
|
export const orderByAppliesToGetOperationsThatReturnCollectionsRule = createRule({
|
|
@@ -15,7 +15,7 @@ export const orderByAppliesToGetOperationsThatReturnCollectionsRule = createRule
|
|
|
15
15
|
}
|
|
16
16
|
if (getOperationVerb(program, operation) === "get") {
|
|
17
17
|
const returnType = operation.returnType;
|
|
18
|
-
const isCollection =
|
|
18
|
+
const isCollection = isTypeCollection(program, returnType);
|
|
19
19
|
if (isCollection) {
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"order-by.js","sourceRoot":"","sources":["../../../src/rules/order-by.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC9E,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"order-by.js","sourceRoot":"","sources":["../../../src/rules/order-by.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEtD,MAAM,CAAC,MAAM,sDAAsD,GAAG,UAAU,CAAC;IAC/E,IAAI,EAAE,4DAA4D;IAClE,MAAM,CAAC,EAAE,OAAO,EAAE;QAChB,OAAO;YACL,SAAS,EAAE,CAAC,SAAS,EAAE,EAAE;gBACvB,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE;oBAClC,OAAO;iBACR;gBAED,IAAI,gBAAgB,CAAC,OAAO,EAAE,SAAS,CAAC,KAAK,KAAK,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E,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;gBAEpC,MAAM,eAAe,GAAG,OAAO,CAAC,MAAM,CACpC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,uBAAuB,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAC1D,CAAC;gBAEF,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE;oBAC3B,OAAO;iBACR;gBAED,gBAAgB,CAAC,OAAO,EAAE;oBACxB,IAAI,EAAE,uBAAuB;oBAC7B,MAAM,EAAE,SAAS;oBACjB,SAAS,EAAE,mBAAmB;oBAC9B,MAAM,EAAE;wBACN,KAAK,EAAE,SAAS,CAAC,IAAI;wBACrB,UAAU,EAAE,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC;qBACvC;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"required-for-create.d.ts","sourceRoot":"","sources":["../../../src/rules/required-for-create.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,6BAA6B,mCAsCxC,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { createRule } from "@typespec/lint";
|
|
2
|
+
import { isComputed, isRequiredForCreate } from "../index.js";
|
|
3
|
+
import { getIdForType, isTypeNullable } from "../utils.js";
|
|
4
|
+
import { getOperationVerb } from "@typespec/http";
|
|
5
|
+
import { reportDiagnostic } from "../lib.js";
|
|
6
|
+
export const requiredRequestParametersRule = createRule({
|
|
7
|
+
name: "required-request-parameters",
|
|
8
|
+
create({ program }) {
|
|
9
|
+
return {
|
|
10
|
+
interface: (theInterface) => {
|
|
11
|
+
const postOperations = [...theInterface.operations]
|
|
12
|
+
.map(([_, operation]) => operation)
|
|
13
|
+
.filter((operation) => getOperationVerb(program, operation) === "post");
|
|
14
|
+
postOperations.forEach((operation) => {
|
|
15
|
+
if (operation.parameters.properties.has("body")) {
|
|
16
|
+
const body = operation.parameters.properties.get("body");
|
|
17
|
+
const model = body.type;
|
|
18
|
+
[...model.properties].forEach(([_, property]) => {
|
|
19
|
+
if (!(isRequiredForCreate(program, property) ||
|
|
20
|
+
isTypeNullable(program, property.type) ||
|
|
21
|
+
isComputed(program, property) ||
|
|
22
|
+
property.default)) {
|
|
23
|
+
reportDiagnostic(program, {
|
|
24
|
+
code: "element-missing-dependencies",
|
|
25
|
+
target: property,
|
|
26
|
+
messageId: "propertyRequiredForCreate",
|
|
27
|
+
format: {
|
|
28
|
+
property: property.name,
|
|
29
|
+
model: getIdForType(program, property.model),
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
//# sourceMappingURL=required-for-create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"required-for-create.js","sourceRoot":"","sources":["../../../src/rules/required-for-create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C,MAAM,CAAC,MAAM,6BAA6B,GAAG,UAAU,CAAC;IACtD,IAAI,EAAE,6BAA6B;IACnC,MAAM,CAAC,EAAE,OAAO,EAAE;QAChB,OAAO;YACL,SAAS,EAAE,CAAC,YAAY,EAAE,EAAE;gBAC1B,MAAM,cAAc,GAAG,CAAC,GAAG,YAAY,CAAC,UAAU,CAAC;qBAChD,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,E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";
|
|
3
3
|
import { isSearch } from "../index.js";
|
|
4
|
-
import {
|
|
4
|
+
import { isTypeCollection } from "../utils.js";
|
|
5
5
|
import { reportDiagnostic } from "../lib.js";
|
|
6
6
|
/**
|
|
7
7
|
* @search applies to get operations that return collections.
|
|
@@ -16,7 +16,7 @@ export const searchAppliesToGetOperationsThatReturnCollectionsRule = createRule(
|
|
|
16
16
|
}
|
|
17
17
|
if (getOperationVerb(program, operation) === "get") {
|
|
18
18
|
const returnType = operation.returnType;
|
|
19
|
-
const isCollection =
|
|
19
|
+
const isCollection = isTypeCollection(program, returnType);
|
|
20
20
|
if (isCollection) {
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.js","sourceRoot":"","sources":["../../../src/rules/search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"search.js","sourceRoot":"","sources":["../../../src/rules/search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C;;GAEG;AACH,MAAM,CAAC,MAAM,qDAAqD,GAAG,UAAU,CAAC;IAC9E,IAAI,EAAE,0DAA0D;IAChE,MAAM,CAAC,EAAE,OAAO,EAAE;QAChB,OAAO;YACL,SAAS,EAAE,CAAC,SAAS,EAAE,EAAE;gBACvB,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE;oBACjC,OAAO;iBACR;gBAED,IAAI,gBAAgB,CAAC,OAAO,EAAE,SAAS,CAAC,KAAK,KAAK,EAAE;oBAClD,MAAM,UAAU,GAAG,SAAS,CAAC,UAAU,CAAC;oBACxC,MAAM,YAAY,GAAG,gBAAgB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;oBAC3D,IAAI,YAAY,EAAE;wBAChB,OAAO;qBACR;iBACF;gBAED,gBAAgB,CAAC,OAAO,EAAE;oBACxB,IAAI,EAAE,uBAAuB;oBAC7B,MAAM,EAAE,SAAS;oBACjB,SAAS,EAAE,WAAW;oBACtB,MAAM,EAAE;wBACN,SAAS,EAAE,SAAS;wBACpB,MAAM,EAAE,yCAAyC;qBAClD;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
package/dist/src/rules/skip.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRule } from "@typespec/lint";
|
|
2
2
|
import { getOperationVerb } from "@typespec/http";
|
|
3
3
|
import { isSkip } from "../index.js";
|
|
4
|
-
import {
|
|
4
|
+
import { isTypeCollection } from "../utils.js";
|
|
5
5
|
import { reportDiagnostic } from "../lib.js";
|
|
6
6
|
/**
|
|
7
7
|
* @skip applies to get operations that return collections.
|
|
@@ -16,7 +16,7 @@ export const skipAppliesToGetOperationsThatReturnCollectionsRule = createRule({
|
|
|
16
16
|
}
|
|
17
17
|
if (getOperationVerb(program, operation) === "get") {
|
|
18
18
|
const returnType = operation.returnType;
|
|
19
|
-
const isCollection =
|
|
19
|
+
const isCollection = isTypeCollection(program, returnType);
|
|
20
20
|
if (isCollection) {
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skip.js","sourceRoot":"","sources":["../../../src/rules/skip.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAA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dist/src/rules/top.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRule } from "@typespec/lint";
|
|
2
2
|
import { getOperationVerb } from "@typespec/http";
|
|
3
3
|
import { isTop } from "../index.js";
|
|
4
|
-
import {
|
|
4
|
+
import { isTypeCollection } from "../utils.js";
|
|
5
5
|
import { reportDiagnostic } from "../lib.js";
|
|
6
6
|
/**
|
|
7
7
|
* @top applies to get operations that return collections.
|
|
@@ -16,7 +16,7 @@ export const topAppliesToGetOperationsThatReturnCollectionsRule = createRule({
|
|
|
16
16
|
}
|
|
17
17
|
if (getOperationVerb(program, operation) === "get") {
|
|
18
18
|
const returnType = operation.returnType;
|
|
19
|
-
const isCollection =
|
|
19
|
+
const isCollection = isTypeCollection(program, returnType);
|
|
20
20
|
if (isCollection) {
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"top.js","sourceRoot":"","sources":["../../../src/rules/top.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"top.js","sourceRoot":"","sources":["../../../src/rules/top.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C;;GAEG;AACH,MAAM,CAAC,MAAM,kDAAkD,GAAG,UAAU,CAAC;IAC3E,IAAI,EAAE,uDAAuD;IAC7D,MAAM,CAAC,EAAE,OAAO,EAAE;QAChB,OAAO;YACL,SAAS,EAAE,CAAC,SAAS,EAAE,EAAE;gBACvB,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE;oBAC9B,OAAO;iBACR;gBAED,IAAI,gBAAgB,CAAC,OAAO,EAAE,SAAS,CAAC,KAAK,KAAK,EAAE;oBAClD,MAAM,UAAU,GAAG,SAAS,CAAC,UAAU,CAAC;oBACxC,MAAM,YAAY,GAAG,gBAAgB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;oBAC3D,IAAI,YAAY,EAAE;wBAChB,OAAO;qBACR;iBACF;gBAED,gBAAgB,CAAC,OAAO,EAAE;oBACxB,IAAI,EAAE,uBAAuB;oBAC7B,MAAM,EAAE,SAAS;oBACjB,SAAS,EAAE,WAAW;oBACtB,MAAM,EAAE;wBACN,SAAS,EAAE,MAAM;wBACjB,MAAM,EAAE,yCAAyC;qBAClD;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
package/dist/src/utils.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Enum, Interface, Model, ModelProperty, Namespace, Operation, Program, Scalar, Type, Union } from "@typespec/compiler";
|
|
2
2
|
export interface MsGraphInterface {
|
|
3
|
-
key: string;
|
|
4
3
|
theInterface: Interface;
|
|
5
4
|
operations: Operation[];
|
|
5
|
+
path: string;
|
|
6
6
|
}
|
|
7
7
|
export declare function getNameForType(program: Program, type: Type): string;
|
|
8
8
|
export declare function getNameForModelType(program: Program, type: Model | Scalar): string;
|
|
@@ -14,11 +14,11 @@ export declare function isTypeNullable(program: Program, type: Type): boolean;
|
|
|
14
14
|
export declare function extractTypesFromUnion(type: Union): Type[];
|
|
15
15
|
export declare function getSingletonTypeId(program: Program, singletonType: string | null, getOperation: Operation | undefined): string | undefined;
|
|
16
16
|
/**
|
|
17
|
-
* Returns whether a type
|
|
17
|
+
* Returns whether a type matches Graph's definition of a collection
|
|
18
18
|
* @param program
|
|
19
|
-
* @param
|
|
19
|
+
* @param type
|
|
20
20
|
*/
|
|
21
|
-
export declare function
|
|
21
|
+
export declare function isTypeCollection(Program: Program, type: Type): boolean;
|
|
22
22
|
/**
|
|
23
23
|
* Imported from typespec-azure
|
|
24
24
|
* Returns the full namespace name for the given type, if available.
|
|
@@ -38,6 +38,18 @@ export declare function isExcludedCoreType(program: Program, type: Model | Scala
|
|
|
38
38
|
export declare function isExcludedLibraryType(program: Program, type: Model | Scalar | Operation | ModelProperty | Interface | Namespace | Enum): boolean;
|
|
39
39
|
export declare function isNavigationProperty(program: Program, property: ModelProperty): boolean;
|
|
40
40
|
export declare function isNavigationSource(theInterface: Interface): boolean;
|
|
41
|
+
export declare function isTopLevelNavigationSource(program: Program, theInterface: MsGraphInterface): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Check if a @graphRoute returns a single resource of a collection.
|
|
44
|
+
*
|
|
45
|
+
* `Example`
|
|
46
|
+
*
|
|
47
|
+
* @graphRoute("users/{id}")
|
|
48
|
+
* interface UsersById extends Resource<user> {
|
|
49
|
+
* get is GraphOps.GetResource;
|
|
50
|
+
* }
|
|
51
|
+
*/
|
|
52
|
+
export declare function isCollectionResource(program: Program, theInterface: MsGraphInterface): boolean;
|
|
41
53
|
export declare function getInterfaceNavigationSourceType(program: Program, theInterface: Interface): Model | undefined;
|
|
42
54
|
export declare function getNavigationSourceType(program: Program, operation: Operation): Model | undefined;
|
|
43
55
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/src/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EAEJ,SAAS,EAET,KAAK,EACL,aAAa,EACb,SAAS,EACT,SAAS,EACT,OAAO,EACP,MAAM,EACN,IAAI,EACJ,KAAK,EACN,MAAM,oBAAoB,CAA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