@azure-tools/typespec-azure-core 0.64.0 → 0.65.0-dev.1

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.
Files changed (28) hide show
  1. package/dist/src/decorators/unique-items.d.ts.map +1 -1
  2. package/dist/src/decorators/unique-items.js +2 -2
  3. package/dist/src/decorators/unique-items.js.map +1 -1
  4. package/package.json +13 -12
  5. package/dist/src/decorators/lro-status.test.d.ts +0 -2
  6. package/dist/src/decorators/lro-status.test.d.ts.map +0 -1
  7. package/dist/src/decorators/lro-status.test.js +0 -216
  8. package/dist/src/decorators/lro-status.test.js.map +0 -1
  9. package/dist/src/decorators/operation-links.test.d.ts +0 -2
  10. package/dist/src/decorators/operation-links.test.d.ts.map +0 -1
  11. package/dist/src/decorators/operation-links.test.js +0 -171
  12. package/dist/src/decorators/operation-links.test.js.map +0 -1
  13. package/dist/src/decorators/polling-operation.test.d.ts +0 -2
  14. package/dist/src/decorators/polling-operation.test.d.ts.map +0 -1
  15. package/dist/src/decorators/polling-operation.test.js +0 -50
  16. package/dist/src/decorators/polling-operation.test.js.map +0 -1
  17. package/dist/src/decorators/preview-version.test.d.ts +0 -2
  18. package/dist/src/decorators/preview-version.test.d.ts.map +0 -1
  19. package/dist/src/decorators/preview-version.test.js +0 -60
  20. package/dist/src/decorators/preview-version.test.js.map +0 -1
  21. package/dist/src/decorators/unique-items.test.d.ts +0 -2
  22. package/dist/src/decorators/unique-items.test.d.ts.map +0 -1
  23. package/dist/src/decorators/unique-items.test.js +0 -65
  24. package/dist/src/decorators/unique-items.test.js.map +0 -1
  25. package/dist/src/decorators/use-final-state-via.test.d.ts +0 -2
  26. package/dist/src/decorators/use-final-state-via.test.d.ts.map +0 -1
  27. package/dist/src/decorators/use-final-state-via.test.js +0 -60
  28. package/dist/src/decorators/use-final-state-via.test.js.map +0 -1
@@ -1 +1 @@
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
+ {"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,oBAwB1B,CAAC;AAEF,eAAO,MAAO,cAAc,sFAAE,cAAc,qFAE3C,CAAC"}
@@ -4,7 +4,7 @@ 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 (!isTypeOrNullableType(entity.type, (t) => t.kind === "Model" && isArrayModelType(program, t))) {
7
+ if (!isTypeOrNullableType(entity.type, (t) => t.kind === "Model" && isArrayModelType(t))) {
8
8
  reportDiagnostic(program, {
9
9
  code: "unique-items-invalid-type",
10
10
  target: entity,
@@ -14,7 +14,7 @@ export const $uniqueItems = (context, entity) => {
14
14
  setUniqueItems(program, entity, true);
15
15
  return;
16
16
  }
17
- if (!isArrayModelType(program, entity)) {
17
+ if (!isArrayModelType(entity)) {
18
18
  reportDiagnostic(program, {
19
19
  code: "unique-items-invalid-type",
20
20
  target: entity,
@@ -1 +1 @@
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;AAE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,EAAE;YACxB,IAAI,EAAE,2BAA2B;YACjC,MAAM,EAAE,MAAM;SACf,CAAC,CAAC;QACH,OAAO;IACT,CAAC;IACD,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;AACxC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,cAAc,CAAC,GAAG,WAAW,CACzD,kBAAkB,CAAC,WAAW,CAC/B,CAAC;AAEF,SAAS,oBAAoB,CAAC,IAAU,EAAE,MAA+B;IACvE,IAAI,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAC1B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAC3C,MAAM,QAAQ,GAAG,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IAC7C,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IAC5C,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AACtC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azure-tools/typespec-azure-core",
3
- "version": "0.64.0",
3
+ "version": "0.65.0-dev.1",
4
4
  "author": "Microsoft Corporation",
5
5
  "description": "TypeSpec Azure Core library",
6
6
  "homepage": "https://azure.github.io/typespec-azure",
@@ -49,28 +49,29 @@
49
49
  "peerDependencies": {
50
50
  "@typespec/compiler": "^1.8.0",
51
51
  "@typespec/http": "^1.8.0",
52
- "@typespec/rest": "^0.78.0"
52
+ "@typespec/rest": "^0.78.0 || >=0.79.0-dev <0.79.0"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@types/node": "~25.0.2",
56
+ "@typespec/compiler": "^1.8.0",
57
+ "@typespec/http": "^1.8.0",
58
+ "@typespec/library-linter": "^0.78.0 || >=0.79.0-dev <0.79.0",
59
+ "@typespec/openapi": "^1.8.0",
60
+ "@typespec/rest": "^0.78.0 || >=0.79.0-dev <0.79.0",
61
+ "@typespec/tspd": "^0.73.3 || >=0.74.0-dev <0.74.0",
62
+ "@typespec/versioning": "^0.78.0 || >=0.79.0-dev <0.79.0",
56
63
  "@vitest/coverage-v8": "^4.0.15",
57
64
  "@vitest/ui": "^4.0.15",
58
65
  "c8": "^10.1.3",
59
66
  "rimraf": "~6.1.2",
60
67
  "typescript": "~5.9.2",
61
- "vitest": "^4.0.15",
62
- "@typespec/compiler": "^1.8.0",
63
- "@typespec/http": "^1.8.0",
64
- "@typespec/library-linter": "^0.78.0",
65
- "@typespec/openapi": "^1.8.0",
66
- "@typespec/rest": "^0.78.0",
67
- "@typespec/tspd": "^0.73.3",
68
- "@typespec/versioning": "^0.78.0"
68
+ "vitest": "^4.0.15"
69
69
  },
70
+ "dependencies": {},
70
71
  "scripts": {
71
72
  "clean": "rimraf ./dist ./temp",
72
- "build": "pnpm run gen-extern-signature && tsc -p . && pnpm run lint-typespec-library",
73
- "watch": "tsc -p . --watch",
73
+ "build": "pnpm run gen-extern-signature && tsc -p tsconfig.build.json && pnpm run lint-typespec-library",
74
+ "watch": "tsc -p tsconfig.build.json --watch",
74
75
  "gen-extern-signature": "tspd --enable-experimental gen-extern-signature .",
75
76
  "lint-typespec-library": "tsp compile . --warn-as-error --import @typespec/library-linter --no-emit",
76
77
  "test": "vitest run",
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=lro-status.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lro-status.test.d.ts","sourceRoot":"","sources":["../../../src/decorators/lro-status.test.ts"],"names":[],"mappings":""}
@@ -1,216 +0,0 @@
1
- import { Tester } from "#test/test-host.js";
2
- import { expectDiagnostics, t } from "@typespec/compiler/testing";
3
- import { deepStrictEqual } from "assert";
4
- import { it } from "vitest";
5
- import { getLongRunningStates } from "./lro-status.js";
6
- it("emits diagnostic if used on wrong type", async () => {
7
- const diagnostics = await Tester.diagnose(`
8
- @lroStatus
9
- op foo(): void;
10
-
11
- @lroStatus
12
- interface Foo {}
13
- `);
14
- expectDiagnostics(diagnostics, [
15
- {
16
- code: "decorator-wrong-target",
17
- message: "Cannot apply @lroStatus decorator to foo since it is not assignable to Enum | Union | ModelProperty",
18
- },
19
- {
20
- code: "decorator-wrong-target",
21
- message: "Cannot apply @lroStatus decorator to Foo since it is not assignable to Enum | Union | ModelProperty",
22
- },
23
- ]);
24
- });
25
- it("emits diagnostic when model property type isn't valid", async () => {
26
- const diagnostics = await Tester.diagnose(`
27
- model BadStatusType {
28
- @lroStatus status: int32;
29
- }
30
-
31
- model BadUnionType {
32
- @lroStatus status: "Succeeded" | int64;
33
- }
34
- `);
35
- expectDiagnostics(diagnostics, [
36
- {
37
- code: "@azure-tools/typespec-azure-core/lro-status-property-invalid-type",
38
- message: "Property type must be a union of strings or an enum.",
39
- },
40
- {
41
- code: "@azure-tools/typespec-azure-core/lro-status-union-non-string",
42
- message: "Union contains non-string value type Scalar.",
43
- },
44
- {
45
- code: "@azure-tools/typespec-azure-core/lro-status-missing",
46
- message: "Terminal long-running operation states are missing: Failed.",
47
- },
48
- ]);
49
- });
50
- it("emits diagnostic when standard terminal states are missing", async () => {
51
- const diagnostics = await Tester.diagnose(`
52
- model UnionMissingStates {
53
- @lroStatus status: "Completed" | "Failed" | "Cancelled" | "Working" | "Extra";
54
- }
55
-
56
- @lroStatus
57
- enum EnumMissingStates {
58
- Succeeded, Error, Cancelled
59
- }
60
- `);
61
- expectDiagnostics(diagnostics, [
62
- {
63
- code: "@azure-tools/typespec-azure-core/lro-status-missing",
64
- message: "Terminal long-running operation states are missing: Succeeded.",
65
- },
66
- {
67
- code: "@azure-tools/typespec-azure-core/lro-status-missing",
68
- message: "Terminal long-running operation states are missing: Failed.",
69
- },
70
- ]);
71
- });
72
- it("returns LRO states from a string union", async () => {
73
- const { StatusModel, program } = await Tester.compile(t.code `
74
- model ${t.model("StatusModel")} {
75
- @lroStatus status: "Succeeded" | "Failed" | "Canceled" | "Working" | "Extra";
76
- }
77
- `);
78
- deepStrictEqual(getLongRunningStates(program, StatusModel.properties.get("status")), {
79
- succeededState: ["Succeeded"],
80
- failedState: ["Failed"],
81
- canceledState: ["Canceled"],
82
- states: ["Succeeded", "Failed", "Canceled", "Working", "Extra"],
83
- });
84
- });
85
- it("returns LRO states from an enum type", async () => {
86
- const { DefaultLroStates, CustomLroStates, program } = await Tester.compile(t.code `
87
- @lroStatus
88
- enum ${t.enum("DefaultLroStates")} {
89
- Succeeded,
90
- Failed,
91
- Canceled,
92
- Extra,
93
- }
94
-
95
- @lroStatus
96
- enum ${t.enum("CustomLroStates")} {
97
- @lroSucceeded Donezo,
98
- @lroFailed Borked,
99
- @lroCanceled Chucked,
100
- HaveAnother,
101
- }
102
- `);
103
- deepStrictEqual(getLongRunningStates(program, DefaultLroStates), {
104
- succeededState: ["Succeeded"],
105
- failedState: ["Failed"],
106
- canceledState: ["Canceled"],
107
- states: ["Succeeded", "Failed", "Canceled", "Extra"],
108
- });
109
- deepStrictEqual(getLongRunningStates(program, CustomLroStates), {
110
- succeededState: ["Donezo"],
111
- failedState: ["Borked"],
112
- canceledState: ["Chucked"],
113
- states: ["Donezo", "Borked", "Chucked", "HaveAnother"],
114
- });
115
- });
116
- it("returns LRO states from an named union type", async () => {
117
- const { DefaultLroStates, CustomLroStates, program } = await Tester.compile(t.code `
118
- @lroStatus
119
- union ${t.union("DefaultLroStates")} {
120
- "Succeeded",
121
- "Failed",
122
- "Canceled",
123
- "Extra",
124
- }
125
-
126
- @lroStatus
127
- union ${t.union("CustomLroStates")} {
128
- @lroSucceeded "Donezo",
129
- @lroFailed "Borked",
130
- @lroCanceled "Chucked",
131
- "HaveAnother",
132
- }
133
- `);
134
- deepStrictEqual(getLongRunningStates(program, DefaultLroStates), {
135
- succeededState: ["Succeeded"],
136
- failedState: ["Failed"],
137
- canceledState: ["Canceled"],
138
- states: ["Succeeded", "Failed", "Canceled", "Extra"],
139
- });
140
- deepStrictEqual(getLongRunningStates(program, CustomLroStates), {
141
- succeededState: ["Donezo"],
142
- failedState: ["Borked"],
143
- canceledState: ["Chucked"],
144
- states: ["Donezo", "Borked", "Chucked", "HaveAnother"],
145
- });
146
- });
147
- it("returns LRO states from an named union type built with enum", async () => {
148
- const { DefaultLroStates, program } = await Tester.compile(t.code `
149
- enum CommonStates {
150
- Succeeded,
151
- Failed,
152
- Canceled
153
- }
154
-
155
- @lroStatus
156
- union ${t.union("DefaultLroStates")} {
157
- CommonStates,
158
- "Extra",
159
- }
160
- `);
161
- deepStrictEqual(getLongRunningStates(program, DefaultLroStates), {
162
- succeededState: ["Succeeded"],
163
- failedState: ["Failed"],
164
- canceledState: ["Canceled"],
165
- states: ["Succeeded", "Failed", "Canceled", "Extra"],
166
- });
167
- });
168
- it("returns LRO states from a string type with known values", async () => {
169
- const { DefaultLroStates, CustomLroStates, program } = await Tester.compile(t.code `
170
- @lroStatus
171
- enum ${t.enum("DefaultLroStates")} {
172
- Succeeded,
173
- Failed,
174
- Canceled,
175
- Extra,
176
- }
177
-
178
- @lroStatus
179
- enum ${t.enum("CustomLroStates")} {
180
- @lroSucceeded Donezo,
181
- @lroFailed Borked,
182
- @lroCanceled Chucked,
183
- HaveAnother,
184
- }
185
- `);
186
- deepStrictEqual(getLongRunningStates(program, DefaultLroStates), {
187
- succeededState: ["Succeeded"],
188
- failedState: ["Failed"],
189
- canceledState: ["Canceled"],
190
- states: ["Succeeded", "Failed", "Canceled", "Extra"],
191
- });
192
- deepStrictEqual(getLongRunningStates(program, CustomLroStates), {
193
- succeededState: ["Donezo"],
194
- failedState: ["Borked"],
195
- canceledState: ["Chucked"],
196
- states: ["Donezo", "Borked", "Chucked", "HaveAnother"],
197
- });
198
- });
199
- it("resolve default state from union variant name", async () => {
200
- const { DefaultLroStates, program } = await Tester.compile(t.code `
201
- @lroStatus
202
- union ${t.union("DefaultLroStates")} {
203
- Succeeded: "uSucceeded",
204
- Failed: "uFailed",
205
- Canceled: "uCancelled",
206
- Extra: "uExtra",
207
- }
208
- `);
209
- deepStrictEqual(getLongRunningStates(program, DefaultLroStates), {
210
- succeededState: ["Succeeded"],
211
- failedState: ["Failed"],
212
- canceledState: ["Canceled"],
213
- states: ["Succeeded", "Failed", "Canceled", "Extra"],
214
- });
215
- });
216
- //# sourceMappingURL=lro-status.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lro-status.test.js","sourceRoot":"","sources":["../../../src/decorators/lro-status.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,CAAC,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAEvD,EAAE,CAAC,wCAAwC,EAAE,KAAK,IAAI,EAAE;IACtD,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC;;;;;;GAMzC,CAAC,CAAC;IAEH,iBAAiB,CAAC,WAAW,EAAE;QAC7B;YACE,IAAI,EAAE,wBAAwB;YAC9B,OAAO,EACL,qGAAqG;SACxG;QACD;YACE,IAAI,EAAE,wBAAwB;YAC9B,OAAO,EACL,qGAAqG;SACxG;KACF,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,uDAAuD,EAAE,KAAK,IAAI,EAAE;IACrE,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC;;;;;;;;GAQzC,CAAC,CAAC;IAEH,iBAAiB,CAAC,WAAW,E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AC,OAAO,EAAE,gBAAgB,CAAC,EAAE;QAC/D,cAAc,EAAE,CAAC,WAAW,CAAC;QAC7B,WAAW,EAAE,CAAC,QAAQ,CAAC;QACvB,aAAa,EAAE,CAAC,UAAU,CAAC;QAC3B,MAAM,EAAE,CAAC,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,CAAC;KACrD,CAAC,CAAC;IAEH,eAAe,CAAC,oBAAoB,CAAC,OAAO,EAAE,eAAe,CAAC,EAAE;QAC9D,cAAc,EAAE,CAAC,QAAQ,CAAC;QAC1B,WAAW,EAAE,CAAC,QAAQ,CAAC;QACvB,aAAa,EAAE,CAAC,SAAS,CAAC;QAC1B,MAAM,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,CAAC;KACvD,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,+CAA+C,EAAE,KAAK,IAAI,EAAE;IAC7D,MAAM,EAAE,gBAAgB,EAAE,OAAO,EAAE,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAA;;YAEvD,CAAC,CAAC,KAAK,CAAC,kBAAkB,CAAC;;;;;;GAMpC,CAAC,CAAC;IAEH,eAAe,CAAC,oBAAoB,CAAC,OAAO,EAAE,gBAAgB,CAAC,EAAE;QAC/D,cAAc,EAAE,CAAC,WAAW,CAAC;QAC7B,WAAW,EAAE,CAAC,QAAQ,CAAC;QACvB,aAAa,EAAE,CAAC,UAAU,CAAC;QAC3B,MAAM,EAAE,CAAC,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,CAAC;KACrD,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=operation-links.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"operation-links.test.d.ts","sourceRoot":"","sources":["../../../src/decorators/operation-links.test.ts"],"names":[],"mappings":""}
@@ -1,171 +0,0 @@
1
- import { Tester, TesterWithService } from "#test/test-host.js";
2
- import { expectDiagnosticEmpty, expectDiagnostics, t } from "@typespec/compiler/testing";
3
- import { ok } from "assert";
4
- import { expect, it } from "vitest";
5
- import { getOperationLinks } from "./operation-link.js";
6
- it("works for sample usage", async () => {
7
- const { Foo, program } = await TesterWithService.compile(t.code `
8
- using Rest.Resource;
9
-
10
- model MyResource {
11
- @key("resourceName")
12
- @segment("resources")
13
- name: string;
14
- };
15
-
16
- model LroResponseWithCompletion<T> {
17
- @statusCode code: "202";
18
- @header("x-ms-operation-id") operationId: string;
19
- }
20
-
21
- model ResourceStatus {
22
- statusId: string;
23
- status: "InProgress" | "Canceled" | "Succeeded" | "Failed";
24
- }
25
-
26
- @autoRoute
27
- interface ${t.interface("Foo")} {
28
- @get read is Azure.Core.StandardResourceOperations.ResourceRead<MyResource>;
29
-
30
- @get status(...KeysOf<MyResource>, @path @segment("statuses") statusId: string) : ResourceStatus | Foundations.ErrorResponse;
31
-
32
- @pollingOperation(Foo.status, {resourceName: RequestParameter<"name">, statusId: ResponseProperty<"operationId">})
33
- @finalOperation(Foo.read, {resourceName: RequestParameter<"name">})
34
- @put createOrUpdate(...KeysOf<MyResource>, @body body: MyResource) : LroResponseWithCompletion<MyResource> | Foundations.ErrorResponse;
35
- }
36
- `);
37
- const result = getOperationLinks(program, Foo.operations.get("createOrUpdate"));
38
- ok(result);
39
- expect(result.get("final")).toBeDefined();
40
- expect(result.get("polling")).toBeDefined();
41
- });
42
- it("raises diagnostic if RequestParameter or ResponseProperty are not used", async () => {
43
- const diagnostics = await Tester.diagnose(`
44
- model FooBody {
45
- id: string;
46
- }
47
-
48
- model FooResult {
49
- resultId: string;
50
- }
51
-
52
- interface Foo {
53
- @get bar(statusId: string) : {status: "Succeeded" | "Failed" | "Canceled"};
54
-
55
- @pollingOperation(Foo.bar, {poll: string})
56
- @put foo(@body body: FooBody): FooResult;
57
- }
58
- `);
59
- expectDiagnostics(diagnostics, {
60
- code: "@azure-tools/typespec-azure-core/operation-link-parameter-invalid",
61
- message: "Parameters must be of template type RequestParameter<T> or ResponseProperty<T>.",
62
- });
63
- });
64
- it("raises diagnostic if parameter does not exist on linked operation", async () => {
65
- const diagnostics = await Tester.diagnose(`
66
- model FooBody {
67
- id: string;
68
- }
69
-
70
- model FooResult {
71
- resultId: string;
72
- }
73
-
74
- interface Foo {
75
- @get bar(statusId: string) : {status: "Succeeded" | "Failed" | "Canceled"};
76
-
77
- @pollingOperation(Foo.bar, {poll: RequestParameter<"resourceName">})
78
- @put foo(@body body: FooBody): FooResult;
79
- }
80
- `);
81
- expectDiagnostics(diagnostics, {
82
- code: "@azure-tools/typespec-azure-core/operation-link-parameter-invalid-target",
83
- message: "Request parameter 'poll' not found in linked operation.",
84
- });
85
- });
86
- it("raises diagnostic if requestParameter does not exist", async () => {
87
- const diagnostics = await Tester.diagnose(`
88
- model FooBody {
89
- id: string;
90
- }
91
-
92
- model FooResult {
93
- resultId: string;
94
- }
95
-
96
- @test
97
- interface Foo {
98
- @get bar(statusId: string) : {status: "Succeeded" | "Failed" | "Canceled"};
99
-
100
- @pollingOperation(Foo.bar, {statusId: RequestParameter<"resourceName">})
101
- @put foo(@body body: FooBody): FooResult;
102
- }
103
- `);
104
- expectDiagnostics(diagnostics, {
105
- code: "@azure-tools/typespec-azure-core/request-parameter-invalid",
106
- message: "Request parameter 'resourceName' not found on request body model.",
107
- });
108
- });
109
- it("passes if requestParameter exists", async () => {
110
- const diagnostics = await Tester.diagnose(`
111
- model FooBody {
112
- id: string;
113
- }
114
-
115
- model FooResult {
116
- resultId: string;
117
- }
118
-
119
- @test
120
- interface Foo {
121
- @get bar(statusId: string) : {status: "Succeeded" | "Failed" | "Canceled"};
122
-
123
- @pollingOperation(Foo.bar, {statusId: RequestParameter<"id">})
124
- @put foo(@body body: FooBody): FooResult;
125
- }
126
- `);
127
- expectDiagnosticEmpty(diagnostics);
128
- });
129
- it("raises diagnostic if responseProperty does not exist", async () => {
130
- const diagnostics = await Tester.diagnose(`
131
- model FooBody {
132
- id: string;
133
- }
134
-
135
- model FooResult {
136
- @statusCode code: 202;
137
- resultId: string;
138
- }
139
-
140
- interface Foo {
141
- @get bar(statusId: string) : {status: "Succeeded" | "Failed" | "Canceled"};
142
-
143
- @pollingOperation(Foo.bar, {statusId: ResponseProperty<"poll">})
144
- @put foo(@body body: FooBody): FooResult | Foundations.ErrorResponse;
145
- }
146
- `);
147
- expectDiagnostics(diagnostics, {
148
- code: "@azure-tools/typespec-azure-core/response-property-invalid",
149
- message: "Response property 'poll' not found on success response model.",
150
- });
151
- });
152
- it("passes if responseProperty exists", async () => {
153
- const diagnostics = await Tester.diagnose(`
154
- model FooBody {
155
- id: string;
156
- }
157
-
158
- model FooResult {
159
- @statusCode code: 202;
160
- resultId: string;
161
- }
162
-
163
- interface Foo {
164
- @get bar(statusId: string) : {status: "Succeeded" | "Failed" | "Canceled"};
165
- @pollingOperation(Foo.bar, {statusId: ResponseProperty<"resultId">})
166
- @put foo(@body body: FooBody): FooResult | Foundations.ErrorResponse;
167
- }
168
- `);
169
- expectDiagnosticEmpty(diagnostics);
170
- });
171
- //# sourceMappingURL=operation-links.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"operation-links.test.js","sourceRoot":"","sources":["../../../src/decorators/operation-links.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,CAAC,EAAE,MAAM,4BAA4B,CAAC;AACzF,OAAO,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,EAAE,CAAC,wBAAwB,EAAE,KAAK,IAAI,EAAE;IACtC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAA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AA4D;QAClE,OAAO,EAAE,mEAAmE;KAC7E,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,mCAAmC,EAAE,KAAK,IAAI,EAAE;IACjD,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC;;;;;;;;;;;;;;;;GAgBzC,CAAC,CAAC;IACH,qBAAqB,CAAC,WAAW,CAAC,CAAC;AACrC,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,sDAAsD,EAAE,KAAK,IAAI,EAAE;IACpE,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC;;;;;;;;;;;;;;;;GAgBzC,CAAC,CAAC;IACH,iBAAiB,CAAC,WAAW,EAAE;QAC7B,IAAI,EAAE,4DAA4D;QAClE,OAAO,EAAE,+DAA+D;KACzE,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,mCAAmC,EAAE,KAAK,IAAI,EAAE;IACjD,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC;;;;;;;;;;;;;;;GAezC,CAAC,CAAC;IACH,qBAAqB,CAAC,WAAW,CAAC,CAAC;AACrC,CAAC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=polling-operation.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"polling-operation.test.d.ts","sourceRoot":"","sources":["../../../src/decorators/polling-operation.test.ts"],"names":[],"mappings":""}
@@ -1,50 +0,0 @@
1
- import { Tester } from "#test/test-host.js";
2
- import { expectDiagnosticEmpty, expectDiagnostics } from "@typespec/compiler/testing";
3
- import { it } from "vitest";
4
- it("emit error if response of operation is a scalar", async () => {
5
- const diagnostics = await Tester.diagnose(`
6
- @pollingOperation(bar)
7
- @put op foo(): string;
8
-
9
- @route("/polling")
10
- @get op bar(): string;
11
- `);
12
- expectDiagnostics(diagnostics, {
13
- code: "@azure-tools/typespec-azure-core/polling-operation-return-model",
14
- message: "An operation annotated with @pollingOperation must return a model or union of model.",
15
- });
16
- });
17
- it("emit error if response of operation is union with a scalar", async () => {
18
- const diagnostics = await Tester.diagnose(`
19
- @pollingOperation(bar)
20
- @put op foo(): {@statusCode _: 200} | string;
21
-
22
- @route("/polling")
23
- @get op bar(): string;
24
- `);
25
- expectDiagnostics(diagnostics, {
26
- code: "@azure-tools/typespec-azure-core/polling-operation-return-model",
27
- message: "An operation annotated with @pollingOperation must return a model or union of model.",
28
- });
29
- });
30
- it("succeed if response is a model", async () => {
31
- const diagnostics = await Tester.diagnose(`
32
- @pollingOperation(bar)
33
- @put op foo(): {};
34
-
35
- @route("/polling")
36
- @get op bar(): {status: "Succeeded" | "Failed" | "Canceled"};
37
- `);
38
- expectDiagnosticEmpty(diagnostics);
39
- });
40
- it("succeed if response is a union of model", async () => {
41
- const diagnostics = await Tester.diagnose(`
42
- @pollingOperation(bar)
43
- @put op foo(): {@statusCode _: 200} | {@statusCode _: 201};
44
-
45
- @route("/polling")
46
- @get op bar(): {status: "Succeeded" | "Failed" | "Canceled"};
47
- `);
48
- expectDiagnosticEmpty(diagnostics);
49
- });
50
- //# sourceMappingURL=polling-operation.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"polling-operation.test.js","sourceRoot":"","sources":["../../../src/decorators/polling-operation.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACtF,OAAO,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE5B,EAAE,CAAC,iDAAiD,EAAE,KAAK,IAAI,EAAE;IAC/D,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC;;;;;;GAMzC,CAAC,CAAC;IACH,iBAAiB,CAAC,WAAW,EAAE;QAC7B,IAAI,EAAE,iEAAiE;QACvE,OAAO,EAAE,sFAAsF;KAChG,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,4DAA4D,EAAE,KAAK,IAAI,EAAE;IAC1E,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC;;;;;;GAMzC,CAAC,CAAC;IACH,iBAAiB,CAAC,WAAW,EAAE;QAC7B,IAAI,EAAE,iEAAiE;QACvE,OAAO,EAAE,sFAAsF;KAChG,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,gCAAgC,EAAE,KAAK,IAAI,EAAE;IAC9C,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC;;;;;;GAMzC,CAAC,CAAC;IACH,qBAAqB,CAAC,WAAW,CAAC,CAAC;AACrC,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,yCAAyC,EAAE,KAAK,IAAI,EAAE;IACvD,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC;;;;;;GAMzC,CAAC,CAAC;IACH,qBAAqB,CAAC,WAAW,CAAC,CAAC;AACrC,CAAC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=preview-version.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"preview-version.test.d.ts","sourceRoot":"","sources":["../../../src/decorators/preview-version.test.ts"],"names":[],"mappings":""}
@@ -1,60 +0,0 @@
1
- import { Tester } from "#test/test-host.js";
2
- import { expectDiagnostics, t } from "@typespec/compiler/testing";
3
- import { expect, it } from "vitest";
4
- import { isPreviewVersion } from "./preview-version.js";
5
- it("emit diagnostic if use on non enum member", async () => {
6
- const diagnostics = await Tester.diagnose(`
7
- @previewVersion
8
- model Foo {}
9
- `);
10
- expectDiagnostics(diagnostics, {
11
- code: "decorator-wrong-target",
12
- message: "Cannot apply @previewVersion decorator to Foo since it is not assignable to EnumMember",
13
- });
14
- });
15
- it("emit diagnostic if use on enum member that is not part of a version enum", async () => {
16
- const diagnostics = await Tester.diagnose(`
17
- enum Foo {
18
- @previewVersion
19
- v1: "1.0",
20
- }
21
- `);
22
- expectDiagnostics(diagnostics, {
23
- code: "@azure-tools/typespec-azure-core/preview-version-invalid-enum-member",
24
- message: "@previewVersion can only be applied to members of a Version enum.",
25
- });
26
- });
27
- it("emit diagnostic if use on enum member that is not the last member", async () => {
28
- const diagnostics = await Tester.diagnose(`
29
- @versioned(Versions)
30
- @service
31
- namespace DemoService;
32
-
33
- enum Versions {
34
- v1,
35
- @Azure.Core.previewVersion
36
- v2Preview: "2.0-preview",
37
- v2: "2.0",
38
- }
39
- `);
40
- expectDiagnostics(diagnostics, {
41
- code: "@azure-tools/typespec-azure-core/preview-version-last-member",
42
- message: "@previewVersion can only be applied to the last member of a Version enum. Having it on other members will cause unstable apis to show up in subsequent stable versions.",
43
- });
44
- });
45
- it("succeeds to decorate the last enum member", async () => {
46
- const { program, v2Preview } = await Tester.compile(t.code `
47
- @versioned(Versions)
48
- @service
49
- namespace DemoService;
50
-
51
- enum Versions {
52
- v1,
53
- @Azure.Core.previewVersion
54
- ${t.enumMember("v2Preview")}: "2.0-preview",
55
- }
56
- `);
57
- expect(v2Preview.name).toBe("v2Preview");
58
- expect(isPreviewVersion(program, v2Preview)).toBe(true);
59
- });
60
- //# sourceMappingURL=preview-version.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"preview-version.test.js","sourceRoot":"","sources":["../../../src/decorators/preview-version.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,CAAC,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,EAAE,CAAC,2CAA2C,EAAE,KAAK,IAAI,EAAE;IACzD,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC;;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ators/unique-items.test.ts"],"names":[],"mappings":""}
@@ -1,65 +0,0 @@
1
- import { Tester } from "#test/test-host.js";
2
- import { expectDiagnostics, t } from "@typespec/compiler/testing";
3
- import assert from "assert";
4
- import { it } from "vitest";
5
- import { hasUniqueItems } from "../decorators.js";
6
- it("correctly detects uniqueItems on an array type property", async () => {
7
- const { bar, program } = await Tester.compile(t.code `
8
- model Foo {
9
- @uniqueItems
10
- @test ${t.modelProperty("bar")}: string[];
11
- }
12
- `);
13
- const unique = hasUniqueItems(program, bar);
14
- assert.deepStrictEqual(unique, true);
15
- });
16
- it("correctly detects uniqueItems on an array type model", async () => {
17
- const { bar, program } = await Tester.compile(t.code `
18
- @uniqueItems
19
- model MyArray is Array<string>;
20
- model Foo {
21
- @test ${t.modelProperty("bar")}: MyArray;
22
- }
23
- `);
24
- const unique = hasUniqueItems(program, bar);
25
- assert.deepStrictEqual(unique, true);
26
- });
27
- it("correctly detects uniqueItems on an Array<T> typed model property", async () => {
28
- const { bar, program } = await Tester.compile(t.code `
29
- model Foo {
30
- @uniqueItems
31
- @test ${t.modelProperty("bar")}: Array<string>;
32
- }
33
- `);
34
- const unique = hasUniqueItems(program, bar);
35
- assert.deepStrictEqual(unique, true);
36
- });
37
- it("emits diagnostic when @uniqueItems decorates a non-array model property", async () => {
38
- const diagnostics = await Tester.diagnose(`
39
- model Foo {
40
- @uniqueItems
41
- bar: string;
42
- }
43
- `);
44
- expectDiagnostics(diagnostics, [
45
- {
46
- code: "@azure-tools/typespec-azure-core/unique-items-invalid-type",
47
- message: "@uniqueItems can only be applied to arrays and array-valued model properties.",
48
- },
49
- ]);
50
- });
51
- it("emits diagnostic when @uniqueItems decorates a non-array model", async () => {
52
- const diagnostics = await Tester.diagnose(`
53
- @uniqueItems
54
- model Foo {
55
- bar: string;
56
- }
57
- `);
58
- expectDiagnostics(diagnostics, [
59
- {
60
- code: "@azure-tools/typespec-azure-core/unique-items-invalid-type",
61
- message: "@uniqueItems can only be applied to arrays and array-valued model properties.",
62
- },
63
- ]);
64
- });
65
- //# sourceMappingURL=unique-items.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"unique-items.test.js","sourceRoot":"","sources":["../../../src/decorators/unique-items.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,CAAC,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,EAAE,CAAC,yDAAyD,EAAE,KAAK,IAAI,EAAE;IACvE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAA;;;cAGxC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC;;GAEjC,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,cAAc,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IAC5C,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AACvC,CAAC,CAAC,CAAC;AACH,EAAE,CAAC,sDAAsD,EAAE,KAAK,IAAI,EAAE;IACpE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAA;;;;cAIxC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC;;GAEjC,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,cAAc,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IAC5C,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AACvC,CAAC,CAAC,CAAC;AACH,EAAE,CAAC,mEAAmE,EAAE,KAAK,IAAI,EAAE;IACjF,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAA;;;cAGxC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC;;GAEjC,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,cAAc,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IAC5C,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AACvC,CAAC,CAAC,CAAC;AACH,EAAE,CAAC,yEAAyE,EAAE,KAAK,IAAI,EAAE;IACvF,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC;;;;;GAKzC,CAAC,CAAC;IAEH,iBAAiB,CAAC,WAAW,EAAE;QAC7B;YACE,IAAI,EAAE,4DAA4D;YAClE,OAAO,EAAE,+EAA+E;SACzF;KACF,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AACH,EAAE,CAAC,gEAAgE,EAAE,KAAK,IAAI,EAAE;IAC9E,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC;;;;;GAKzC,CAAC,CAAC;IAEH,iBAAiB,CAAC,WAAW,EAAE;QAC7B;YACE,IAAI,EAAE,4DAA4D;YAClE,OAAO,EAAE,+EAA+E;SACzF;KACF,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=use-final-state-via.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-final-state-via.test.d.ts","sourceRoot":"","sources":["../../../src/decorators/use-final-state-via.test.ts"],"names":[],"mappings":""}
@@ -1,60 +0,0 @@
1
- import { Tester } from "#test/test-host.js";
2
- import { expectDiagnostics, t } from "@typespec/compiler/testing";
3
- import assert from "assert";
4
- import { it } from "vitest";
5
- import { FinalStateValue, getFinalStateOverride } from "../state/final-state.js";
6
- it("correctly overrides PUT lro final-state-via", async () => {
7
- const { foo, program } = await Tester.compile(t.code `
8
- @pollingOperation(bar)
9
- @useFinalStateVia("operation-location")
10
- @test @put op ${t.op("foo")}(): {@header("Operation-Location") loc: string};
11
-
12
- @route("/polling")
13
- @get op bar(): {status: "Succeeded" | "Failed" | "Cancelled"};
14
- `);
15
- const finalState = getFinalStateOverride(program, foo);
16
- assert.deepStrictEqual(finalState, FinalStateValue.operationLocation);
17
- });
18
- it("emits diagnostic for invalid PUT override", async () => {
19
- const diagnostics = await Tester.diagnose(`
20
- @pollingOperation(bar)
21
- @useFinalStateVia("operation-location")
22
- @test @put op foo(): {loc: string};
23
-
24
- @route("/polling")
25
- @get op bar(): {status: "Succeeded" | "Failed" | "Cancelled"};
26
- `);
27
- expectDiagnostics(diagnostics, {
28
- code: "@azure-tools/typespec-azure-core/invalid-final-state",
29
- message: "There was no header corresponding to the desired final-state-via value 'operation-location'.",
30
- });
31
- });
32
- it("emits error for missing header", async () => {
33
- const diagnostics = await Tester.diagnose(`
34
- @pollingOperation(bar)
35
- @useFinalStateVia("location")
36
- @post op foo(): {};
37
-
38
- @route("/polling")
39
- @get op bar(): {status: "Succeeded" | "Failed" | "Cancelled"};
40
- `);
41
- expectDiagnostics(diagnostics, {
42
- code: "@azure-tools/typespec-azure-core/invalid-final-state",
43
- message: `There was no header corresponding to the desired final-state-via value 'location'.`,
44
- });
45
- });
46
- it("emits error for original-uri on non-PUT request", async () => {
47
- const diagnostics = await Tester.diagnose(`
48
- @pollingOperation(bar)
49
- @useFinalStateVia("original-uri")
50
- @post op foo(): {};
51
-
52
- @route("/polling")
53
- @get op bar(): {status: "Succeeded" | "Failed" | "Cancelled"};
54
- `);
55
- expectDiagnostics(diagnostics, {
56
- code: "@azure-tools/typespec-azure-core/invalid-final-state",
57
- message: "The final state value 'original-uri' can only be used in http PUT operations",
58
- });
59
- });
60
- //# sourceMappingURL=use-final-state-via.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-final-state-via.test.js","sourceRoot":"","sources":["../../../src/decorators/use-final-state-via.test.ts"],"names":[],"mappings":"AAAA,O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