@azure-tools/typespec-azure-core 0.62.0-dev.4 → 0.62.0-dev.7
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/decorators/unique-items.d.ts.map +1 -1
- package/dist/src/decorators/unique-items.js +16 -2
- package/dist/src/decorators/unique-items.js.map +1 -1
- package/dist/src/decorators.d.ts +2 -2
- package/dist/src/decorators.d.ts.map +1 -1
- package/dist/src/decorators.js +1 -1
- package/dist/src/decorators.js.map +1 -1
- package/dist/src/rules/no-openapi.d.ts.map +1 -1
- package/dist/src/rules/no-openapi.js +1 -6
- package/dist/src/rules/no-openapi.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unique-items.d.ts","sourceRoot":"","sources":["../../../src/decorators/unique-items.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"unique-items.d.ts","sourceRoot":"","sources":["../../../src/decorators/unique-items.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,IAAI,EACL,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAG/E,eAAO,MAAM,YAAY,EAAE,oBA0B1B,CAAC;AAEF,eAAO,MAAO,cAAc,sFAAE,cAAc,qFAE3C,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { isArrayModelType } from "@typespec/compiler";
|
|
1
|
+
import { isArrayModelType, isNullType, } from "@typespec/compiler";
|
|
2
2
|
import { useStateMap } from "@typespec/compiler/utils";
|
|
3
3
|
import { AzureCoreStateKeys, reportDiagnostic } from "../lib.js";
|
|
4
4
|
export const $uniqueItems = (context, entity) => {
|
|
5
5
|
const { program } = context;
|
|
6
6
|
if (entity.kind === "ModelProperty") {
|
|
7
|
-
if (entity.type.kind
|
|
7
|
+
if (!isTypeOrNullableType(entity.type, (t) => t.kind === "Model" && isArrayModelType(program, t))) {
|
|
8
8
|
reportDiagnostic(program, {
|
|
9
9
|
code: "unique-items-invalid-type",
|
|
10
10
|
target: entity,
|
|
@@ -24,4 +24,18 @@ export const $uniqueItems = (context, entity) => {
|
|
|
24
24
|
setUniqueItems(program, entity, true);
|
|
25
25
|
};
|
|
26
26
|
export const [getUniqueItems, setUniqueItems] = useStateMap(AzureCoreStateKeys.uniqueItems);
|
|
27
|
+
function isTypeOrNullableType(type, filter) {
|
|
28
|
+
if (filter(type)) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
if (type.kind !== "Union") {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
if (type.variants.size !== 2)
|
|
35
|
+
return false;
|
|
36
|
+
const variants = [...type.variants.values()];
|
|
37
|
+
if (!filter(variants[0].type))
|
|
38
|
+
return false;
|
|
39
|
+
return isNullType(variants[1].type);
|
|
40
|
+
}
|
|
27
41
|
//# sourceMappingURL=unique-items.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unique-items.js","sourceRoot":"","sources":["../../../src/decorators/unique-items.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"unique-items.js","sourceRoot":"","sources":["../../../src/decorators/unique-items.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,gBAAgB,EAChB,UAAU,GAIX,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAEjE,MAAM,CAAC,MAAM,YAAY,GAAyB,CAChD,OAAyB,EACzB,MAA6B,EAC7B,EAAE;IACF,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAC5B,IAAI,MAAM,CAAC,IAAI,KAAK,eAAe,EAAE,CAAC;QACpC,IACE,CAAC,oBAAoB,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,EA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AAC,CAAC;AACtC,CAAC"}
|
package/dist/src/decorators.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DecoratorContext, Model, ModelProperty, Program } from "@typespec/compiler";
|
|
1
|
+
import { DecoratorContext, Model, ModelProperty, Program, Type } from "@typespec/compiler";
|
|
2
2
|
export declare const $requestParameter: (context: DecoratorContext, entity: Model, name: string) => void;
|
|
3
3
|
export declare function getRequestParameter(program: Program, entity: ModelProperty): string | undefined;
|
|
4
4
|
export declare const $responseProperty: (context: DecoratorContext, entity: Model, name: string) => void;
|
|
@@ -9,5 +9,5 @@ export declare function getResponseProperty(program: Program, entity: ModelPrope
|
|
|
9
9
|
* @param type The model or model property to check.
|
|
10
10
|
* @returns True if the model or model property has unique items, false otherwise.
|
|
11
11
|
*/
|
|
12
|
-
export declare function hasUniqueItems(program: Program, type:
|
|
12
|
+
export declare function hasUniqueItems(program: Program, type: Type): boolean;
|
|
13
13
|
//# sourceMappingURL=decorators.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../src/decorators.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../src/decorators.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAG3F,eAAO,MAAM,iBAAiB,GAAI,SAAS,gBAAgB,EAAE,QAAQ,KAAK,EAAE,MAAM,MAAM,SAEvF,CAAC;AAEF,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,GAAG,MAAM,GAAG,SAAS,CAM/F;AAED,eAAO,MAAM,iBAAiB,GAAI,SAAS,gBAAgB,EAAE,QAAQ,KAAK,EAAE,MAAM,MAAM,SAEvF,CAAC;AAEF,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,GAAG,MAAM,GAAG,SAAS,CAM/F;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CA4BpE"}
|
package/dist/src/decorators.js
CHANGED
|
@@ -47,7 +47,7 @@ export function hasUniqueItems(program, type) {
|
|
|
47
47
|
type.sourceModels.some((sourceModel) => hasUniqueItemsCached(sourceModel.model))));
|
|
48
48
|
}
|
|
49
49
|
else {
|
|
50
|
-
if (type.
|
|
50
|
+
if (type.kind !== "ModelProperty") {
|
|
51
51
|
return cacheResult(type, false);
|
|
52
52
|
}
|
|
53
53
|
return cacheResult(type, getUniqueItems(program, type) || hasUniqueItemsCached(type.type));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../src/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAG9C,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,OAAyB,EAAE,MAAa,EAAE,IAAY,EAAE,EAAE;IAC1F,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAClF,CAAC,CAAC;AAEF,MAAM,UAAU,mBAAmB,CAAC,OAAgB,EAAE,MAAqB;IACzE,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,KAAK,OAAO;QAAE,OAAO,SAAS,CAAC;IACnD,MAAM,aAAa,GAAuB,OAAO;SAC9C,QAAQ,CAAC,kBAAkB,CAAC,gBAAgB,CAAC;SAC7C,GAAG,CAAC,MAA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AAC,IAAI,CAAC,SAAS,KAAK,SAAS,IAAI,oBAAoB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;gBACtE,CAAC,IAAI,CAAC,WAAW,KAAK,SAAS,IAAI,oBAAoB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;gBAC1E,CAAC,IAAI,CAAC,YAAY,KAAK,SAAS;oBAC9B,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,oBAAoB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CACtF,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,IAAI,IAAI,CAAC,IAAI,KAAK,eAAe,EAAE,CAAC;gBAClC,OAAO,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;YAClC,CAAC;YACD,OAAO,WAAW,CAAC,IAAI,EAAE,cAAc,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC7F,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-openapi.d.ts","sourceRoot":"","sources":["../../../src/rules/no-openapi.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"no-openapi.d.ts","sourceRoot":"","sources":["../../../src/rules/no-openapi.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,aAAa;;;;;EAwCxB,CAAC"}
|
|
@@ -14,8 +14,7 @@ export const noOpenAPIRule = createRule({
|
|
|
14
14
|
for (const dec of type.decorators) {
|
|
15
15
|
if (dec.definition) {
|
|
16
16
|
const id = getTypeName(dec.definition.namespace);
|
|
17
|
-
if (
|
|
18
|
-
!isException(dec.definition, dec)) {
|
|
17
|
+
if (id === "TypeSpec.OpenAPI" || id === "Autorest") {
|
|
19
18
|
context.reportDiagnostic({
|
|
20
19
|
target: dec.node ?? type,
|
|
21
20
|
format: { name: dec.decorator.name },
|
|
@@ -38,10 +37,6 @@ export const noOpenAPIRule = createRule({
|
|
|
38
37
|
};
|
|
39
38
|
},
|
|
40
39
|
});
|
|
41
|
-
// https://github.com/Azure/typespec-azure/issues/687 no alternative for x-ms-identifiers for now
|
|
42
|
-
function isException(dec, application) {
|
|
43
|
-
return dec.name === "@extension" && application.args[0].jsValue === "x-ms-identifiers";
|
|
44
|
-
}
|
|
45
40
|
function getMessageId(dec) {
|
|
46
41
|
switch (dec.name) {
|
|
47
42
|
case "@operationId":
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-openapi.js","sourceRoot":"","sources":["../../../src/rules/no-openapi.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"no-openapi.js","sourceRoot":"","sources":["../../../src/rules/no-openapi.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,UAAU,EACV,WAAW,EACX,YAAY,GACb,MAAM,oBAAoB,CAAC;AAE5B,MAAM,CAAC,MAAM,aAAa,GAAG,UAAU,CAAC;IACtC,IAAI,EAAE,YAAY;IAClB,WAAW,EACT,qGAAqG;IACvG,QAAQ,EAAE,SAAS;IACnB,QAAQ,EAAE;QACR,OAAO,EAAE,YAAY,CAAA,8CAA8C,MAAM,mGAAmG;QAC5K,WAAW,EACT,uGAAuG;QACzG,MAAM,EAAE,oDAAoD;QAC5D,OAAO,EACL,4IAA4I;KAC/I;IACD,MAAM,CAAC,OAAO;QACZ,SAAS,eAAe,CAAC,IAA0B;YACjD,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;gBAClC,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC;oBACnB,MAAM,EAAE,GAAG,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;oBACjD,IAAI,EAAE,KAAK,kBAAkB,IAAI,EAAE,KAAK,UAAU,EAAE,CAAC;wBACnD,OAAO,CAAC,gBAAgB,CAAC;4BACvB,MAAM,EAAE,GAAG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