@typespec/http 0.54.0-dev.5 → 0.54.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/README.md CHANGED
@@ -158,9 +158,9 @@ Specify this property is to be sent or received as an HTTP header.
158
158
 
159
159
  ##### Parameters
160
160
 
161
- | Name | Type | Description |
162
- | ------------------- | --------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
163
- | headerNameOrOptions | `union string \| TypeSpec.Http.HeaderOptions` | Optional name of the header when sent over HTTP or header options.<br />By default the header name will be the property name converted from camelCase to kebab-case. (e.g. `contentType` -> `content-type`) |
161
+ | Name | Type | Description |
162
+ | ------------------- | --------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
163
+ | headerNameOrOptions | `string \| TypeSpec.Http.HeaderOptions` | Optional name of the header when sent over HTTP or header options.<br />By default the header name will be the property name converted from camelCase to kebab-case. (e.g. `contentType` -> `content-type`) |
164
164
 
165
165
  ##### Examples
166
166
 
@@ -196,13 +196,13 @@ Specify if inapplicable metadata should be included in the payload for the given
196
196
 
197
197
  ##### Target
198
198
 
199
- `(intrinsic) unknown`
199
+ `unknown`
200
200
 
201
201
  ##### Parameters
202
202
 
203
- | Name | Type | Description |
204
- | ----- | ------------------------ | --------------------------------------------------------------- |
205
- | value | `valueof scalar boolean` | If true, inapplicable metadata will be included in the payload. |
203
+ | Name | Type | Description |
204
+ | ----- | ----------------- | --------------------------------------------------------------- |
205
+ | value | `valueof boolean` | If true, inapplicable metadata will be included in the payload. |
206
206
 
207
207
  #### `@patch`
208
208
 
@@ -240,9 +240,9 @@ Explicitly specify that this property is to be interpolated as a path parameter.
240
240
 
241
241
  ##### Parameters
242
242
 
243
- | Name | Type | Description |
244
- | --------- | ----------------------- | --------------------------------------------------- |
245
- | paramName | `valueof scalar string` | Optional name of the parameter in the url template. |
243
+ | Name | Type | Description |
244
+ | --------- | ---------------- | --------------------------------------------------- |
245
+ | paramName | `valueof string` | Optional name of the parameter in the url template. |
246
246
 
247
247
  ##### Examples
248
248
 
@@ -309,9 +309,9 @@ Specify this property is to be sent as a query parameter.
309
309
 
310
310
  ##### Parameters
311
311
 
312
- | Name | Type | Description |
313
- | ------------------ | -------------------------------------------- | ------------------------------------------------------------------------------- |
314
- | queryNameOrOptions | `union string \| TypeSpec.Http.QueryOptions` | Optional name of the query when included in the url or query parameter options. |
312
+ | Name | Type | Description |
313
+ | ------------------ | -------------------------------------- | ------------------------------------------------------------------------------- |
314
+ | queryNameOrOptions | `string \| TypeSpec.Http.QueryOptions` | Optional name of the query when included in the url or query parameter options. |
315
315
 
316
316
  ##### Examples
317
317
 
@@ -342,14 +342,14 @@ it will be used as a prefix to the route URI of the operation.
342
342
 
343
343
  ##### Target
344
344
 
345
- `union Namespace | Interface | Operation`
345
+ `Namespace | Interface | Operation`
346
346
 
347
347
  ##### Parameters
348
348
 
349
- | Name | Type | Description |
350
- | ------- | ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
351
- | path | `valueof scalar string` | Relative route path. Cannot include query parameters. |
352
- | options | `model (anonymous model)` | Set of parameters used to configure the route. Supports `{shared: true}` which indicates that the route may be shared by several operations. |
349
+ | Name | Type | Description |
350
+ | ------- | ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
351
+ | path | `valueof string` | Relative route path. Cannot include query parameters. |
352
+ | options | `{...}` | Set of parameters used to configure the route. Supports `{shared: true}` which indicates that the route may be shared by several operations. |
353
353
 
354
354
  ##### Examples
355
355
 
@@ -372,11 +372,11 @@ Specify the endpoint for this service.
372
372
 
373
373
  ##### Parameters
374
374
 
375
- | Name | Type | Description |
376
- | ----------- | ----------------------- | ------------------------------------------------------- |
377
- | url | `valueof scalar string` | Server endpoint |
378
- | description | `valueof scalar string` | Description of the endpoint |
379
- | parameters | `model Record<unknown>` | Optional set of parameters used to interpolate the url. |
375
+ | Name | Type | Description |
376
+ | ----------- | ----------------- | ------------------------------------------------------- |
377
+ | url | `valueof string` | Server endpoint |
378
+ | description | `valueof string` | Description of the endpoint |
379
+ | parameters | `Record<unknown>` | Optional set of parameters used to interpolate the url. |
380
380
 
381
381
  ##### Examples
382
382
 
@@ -455,13 +455,13 @@ Specify authentication for a whole service or specific methods. See the [documen
455
455
 
456
456
  ##### Target
457
457
 
458
- `union Namespace | Interface | Operation`
458
+ `Namespace | Interface | Operation`
459
459
 
460
460
  ##### Parameters
461
461
 
462
- | Name | Type | Description |
463
- | ---- | --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
464
- | auth | `union {} \| Union \| {}[]` | Authentication configuration. Can be a single security scheme, a union(either option is valid authentication) or a tuple (must use all authentication together) |
462
+ | Name | Type | Description |
463
+ | ---- | --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
464
+ | auth | `{} \| Union \| {}[]` | Authentication configuration. Can be a single security scheme, a union(either option is valid authentication) or a tuple (must use all authentication together) |
465
465
 
466
466
  ##### Examples
467
467
 
package/dist/src/lib.d.ts CHANGED
@@ -48,7 +48,7 @@ export declare const $lib: import("@typespec/compiler").TypeSpecLibrary<{
48
48
  readonly default: import("@typespec/compiler").CallableMessage<[string]>;
49
49
  };
50
50
  "shared-inconsistency": {
51
- readonly default: "All shared routes must agree on the value of the shared parameter.";
51
+ readonly default: import("@typespec/compiler").CallableMessage<[string, string]>;
52
52
  };
53
53
  "write-visibility-not-supported": {
54
54
  readonly default: "@visibility(\"write\") is not supported. Use @visibility(\"update\"), @visibility(\"create\") or @visibility(\"create\", \"update\") as appropriate.";
@@ -113,7 +113,7 @@ export declare const reportDiagnostic: <C extends "http-verb-duplicate" | "http-
113
113
  readonly default: import("@typespec/compiler").CallableMessage<[string]>;
114
114
  };
115
115
  "shared-inconsistency": {
116
- readonly default: "All shared routes must agree on the value of the shared parameter.";
116
+ readonly default: import("@typespec/compiler").CallableMessage<[string, string]>;
117
117
  };
118
118
  "write-visibility-not-supported": {
119
119
  readonly default: "@visibility(\"write\") is not supported. Use @visibility(\"update\"), @visibility(\"create\") or @visibility(\"create\", \"update\") as appropriate.";
@@ -177,7 +177,7 @@ export declare const reportDiagnostic: <C extends "http-verb-duplicate" | "http-
177
177
  readonly default: import("@typespec/compiler").CallableMessage<[string]>;
178
178
  };
179
179
  "shared-inconsistency": {
180
- readonly default: "All shared routes must agree on the value of the shared parameter.";
180
+ readonly default: import("@typespec/compiler").CallableMessage<[string, string]>;
181
181
  };
182
182
  "write-visibility-not-supported": {
183
183
  readonly default: "@visibility(\"write\") is not supported. Use @visibility(\"update\"), @visibility(\"create\") or @visibility(\"create\", \"update\") as appropriate.";
@@ -241,7 +241,7 @@ export declare const reportDiagnostic: <C extends "http-verb-duplicate" | "http-
241
241
  readonly default: import("@typespec/compiler").CallableMessage<[string]>;
242
242
  };
243
243
  "shared-inconsistency": {
244
- readonly default: "All shared routes must agree on the value of the shared parameter.";
244
+ readonly default: import("@typespec/compiler").CallableMessage<[string, string]>;
245
245
  };
246
246
  "write-visibility-not-supported": {
247
247
  readonly default: "@visibility(\"write\") is not supported. Use @visibility(\"update\"), @visibility(\"create\") or @visibility(\"create\", \"update\") as appropriate.";
@@ -305,7 +305,7 @@ export declare const reportDiagnostic: <C extends "http-verb-duplicate" | "http-
305
305
  readonly default: import("@typespec/compiler").CallableMessage<[string]>;
306
306
  };
307
307
  "shared-inconsistency": {
308
- readonly default: "All shared routes must agree on the value of the shared parameter.";
308
+ readonly default: import("@typespec/compiler").CallableMessage<[string, string]>;
309
309
  };
310
310
  "write-visibility-not-supported": {
311
311
  readonly default: "@visibility(\"write\") is not supported. Use @visibility(\"update\"), @visibility(\"create\") or @visibility(\"create\", \"update\") as appropriate.";
package/dist/src/lib.js CHANGED
@@ -98,7 +98,7 @@ export const $lib = createTypeSpecLibrary({
98
98
  "shared-inconsistency": {
99
99
  severity: "error",
100
100
  messages: {
101
- default: "All shared routes must agree on the value of the shared parameter.",
101
+ default: paramMessage `Each operation routed at "${"verb"} ${"path"}" needs to have the @sharedRoute decorator.`,
102
102
  },
103
103
  },
104
104
  "write-visibility-not-supported": {
@@ -1 +1 @@
1
- {"version":3,"file":"lib.js","sourceRoot":"","sources":["../../src/lib.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEzE,MAAM,CAAC,MAAM,IAAI,GAAG,qBAAqB,CAAC;IACxC,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE;QACX,qBAAqB,EAAE;YACrB,QAAQ,EAAE,OAAO;YACjB,QAAQ,EAAE;gBACR,OAAO,EAAE,YAAY,CAAA,gCAAgC,YAAY,EAAE;aACpE;SACF;QACD,sBAAsB,EAAE;YACtB,QAAQ,EAAE,OAAO;YACjB,QAAQ,EAAE;gBACR,OAAO,EAAE,YAAY,CAAA,eAAe,MAAM,SAAS,YAAY,EAAE;aAClE;SACF;QACD,oBAAoB,EAAE;YACpB,QAAQ,EAAE,OAAO;YACjB,QAAQ,EAAE;gBACR,OAAO,EAAE,YAAY,CAAA,2BAA2B,OAAO,uCAAuC;aAC/F;SACF;QACD,qBAAqB,EAAE;YACrB,QAAQ,EAAE,OAAO;YACjB,QAAQ,EAAE;gBACR,OAAO,EAAE,YAAY,CAAA,mBAAmB,WAAW,uBAAuB;aAC3E;SACF;QACD,sBAAsB,EAAE;YACtB,QAAQ,EAAE,OAAO;YACjB,QAAQ,EAAE;gBACR,OAAO,EAAE,YAAY,CAAA,kCAAkC,OAAO,wCAAwC;aACvG;SACF;QACD,gBAAgB,EAAE;YAChB,QAAQ,EAAE,OAAO;YACjB,QAAQ,EAAE;gBACR,OAAO,EAAE,kDAAkD;gBAC3D,oBAAoB,EAClB,4FAA4F;gBAC9F,kBAAkB,EAChB,iGAAiG;aACpG;SACF;QACD,2BAA2B,EAAE;YAC3B,QAAQ,EAAE,OAAO;YACjB,QAAQ,EAAE;gBACR,SAAS,EAAE,sEAAsE;aAClF;SACF;QACD,gCAAgC,EA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AAE,EAAE,WAAW,EAAE,+BAA+B,EAAE;QAChE,MAAM,EAAE,EAAE,WAAW,EAAE,iCAAiC,EAAE;QAC1D,KAAK,EAAE,EAAE,WAAW,EAAE,gCAAgC,EAAE;QACxD,IAAI,EAAE,EAAE,WAAW,EAAE,+BAA+B,EAAE;QACtD,IAAI,EAAE,EAAE,WAAW,EAAE,+BAA+B,EAAE;QACtD,UAAU,EAAE,EAAE,WAAW,EAAE,qCAAqC,EAAE;QAClE,KAAK,EAAE,EAAE,WAAW,EAAE,yDAAyD,EAAE;QACjF,OAAO,EAAE,EAAE,WAAW,EAAE,iCAAiC,EAAE;QAC3D,oCAAoC,EAAE;YACpC,WAAW,EAAE,+DAA+D;SAC7E;QAED,WAAW;QACX,kBAAkB,EAAE,EAAE;QACtB,aAAa,EAAE,EAAE;QACjB,MAAM,EAAE,EAAE;QACV,YAAY,EAAE,EAAE,WAAW,EAAE,sCAAsC,EAAE;QACrE,YAAY,EAAE,EAAE;KACjB;CACO,CAAC,CAAC;AAEZ,MAAM,CAAC,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,SAAS,EAAE,aAAa,EAAE,GAAG,IAAI,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAK7C,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,QAsB3C"}
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAM7C,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,QAO3C"}
@@ -7,20 +7,51 @@ export function $onValidate(program) {
7
7
  if (diagnostics.length > 0) {
8
8
  program.reportDiagnostics(diagnostics);
9
9
  }
10
+ validateSharedRouteConsistency(program, services);
11
+ }
12
+ function groupHttpOperations(operations) {
13
+ const paths = new Map();
14
+ for (const operation of operations) {
15
+ const { verb, path } = operation;
16
+ let pathOps = paths.get(path);
17
+ if (pathOps === undefined) {
18
+ pathOps = new Map();
19
+ paths.set(path, pathOps);
20
+ }
21
+ const ops = pathOps.get(verb);
22
+ if (ops === undefined) {
23
+ pathOps.set(verb, [operation]);
24
+ }
25
+ else {
26
+ ops.push(operation);
27
+ }
28
+ }
29
+ return paths;
30
+ }
31
+ function validateSharedRouteConsistency(program, services) {
10
32
  for (const service of services) {
11
- const paths = new Map();
12
- for (const operation of service.operations) {
13
- const path = operation.path;
14
- const shared = isSharedRoute(program, operation.operation);
15
- const val = paths.get(path);
16
- if (shared && val === undefined) {
17
- paths.set(path, shared);
18
- }
19
- else if (val && val !== shared) {
20
- reportDiagnostic(program, {
21
- code: "shared-inconsistency",
22
- target: operation.operation,
23
- });
33
+ const paths = groupHttpOperations(service.operations);
34
+ for (const pathOps of paths.values()) {
35
+ for (const ops of pathOps.values()) {
36
+ let hasShared = false;
37
+ let hasNonShared = false;
38
+ for (const op of ops) {
39
+ if (isSharedRoute(program, op.operation)) {
40
+ hasShared = true;
41
+ }
42
+ else {
43
+ hasNonShared = true;
44
+ }
45
+ }
46
+ if (hasShared && hasNonShared) {
47
+ for (const op of ops) {
48
+ reportDiagnostic(program, {
49
+ code: "shared-inconsistency",
50
+ target: op.operation,
51
+ format: { verb: op.verb, path: op.path },
52
+ });
53
+ }
54
+ }
24
55
  }
25
56
  }
26
57
  }
@@ -1 +1 @@
1
- {"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/validate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,MAAM,UAAU,WAAW,CAAC,OAAgB;IAC1C,0EAA0E;IAC1E,MAAM,CAAC,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I,SAAS,GAAG,KAAK,CAAC;gBACtB,IAAI,YAAY,GAAG,KAAK,CAAC;gBACzB,KAAK,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC;oBACrB,IAAI,aAAa,CAAC,OAAO,EAAE,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC;wBACzC,SAAS,GAAG,IAAI,CAAC;oBACnB,CAAC;yBAAM,CAAC;wBACN,YAAY,GAAG,IAAI,CAAC;oBACtB,CAAC;gBACH,CAAC;gBACD,IAAI,SAAS,IAAI,YAAY,EAAE,CAAC;oBAC9B,KAAK,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC;wBACrB,gBAAgB,CAAC,OAAO,EAAE;4BACxB,IAAI,EAAE,sBAAsB;4BAC5B,MAAM,EAAE,EAAE,CAAC,SAAS;4BACpB,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE;yBACzC,CAAC,CAAC;oBACL,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typespec/http",
3
- "version": "0.54.0-dev.5",
3
+ "version": "0.54.0-dev.7",
4
4
  "author": "Microsoft Corporation",
5
5
  "description": "TypeSpec HTTP protocol binding",
6
6
  "homepage": "https://github.com/microsoft/typespec",