@nxgt/typespec 0.7.0 → 0.9.0
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 +81 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +123 -1
- package/dist/index.js.map +10 -5
- package/dist/linter.d.ts +2 -0
- package/dist/linter.d.ts.map +1 -0
- package/dist/operation-ids.d.ts +9 -0
- package/dist/operation-ids.d.ts.map +1 -1
- package/dist/rules/error-body-shape.d.ts +4 -0
- package/dist/rules/error-body-shape.d.ts.map +1 -0
- package/dist/rules/list-returns-page.d.ts +4 -0
- package/dist/rules/list-returns-page.d.ts.map +1 -0
- package/dist/rules/service-operation-ids.d.ts +4 -0
- package/dist/rules/service-operation-ids.d.ts.map +1 -0
- package/dist/rules/written.d.ts +8 -0
- package/dist/rules/written.d.ts.map +1 -0
- package/docs/README.md +2 -0
- package/docs/guide/getting-started.md +277 -0
- package/docs/guide/linter.md +257 -0
- package/docs/roadmap.md +24 -4
- package/docs/troubleshooting.md +194 -0
- package/package.json +2 -1
- package/templates/nxgt/README.md +33 -0
- package/templates/nxgt/main.tsp +68 -0
- package/templates/nxgt/openapi-codegen.config.ts +7 -0
- package/templates/scaffolding.json +37 -0
package/README.md
CHANGED
|
@@ -8,6 +8,10 @@ Each shape here is one the `@nxgt/*` packages already send on the wire.
|
|
|
8
8
|
|
|
9
9
|
## Install
|
|
10
10
|
|
|
11
|
+
A new project needs no install of its own: `tsp init` with the package's
|
|
12
|
+
template installs everything ([Start a project](#start-a-project)). For an
|
|
13
|
+
existing project, install the library and its peers:
|
|
14
|
+
|
|
11
15
|
```sh
|
|
12
16
|
bun add -d @nxgt/typespec @typespec/compiler @typespec/http @typespec/openapi @typespec/openapi3 @nxgt/openapi-codegen
|
|
13
17
|
```
|
|
@@ -16,6 +20,8 @@ bun add -d @nxgt/typespec @typespec/compiler @typespec/http @typespec/openapi @t
|
|
|
16
20
|
are peer dependencies,
|
|
17
21
|
and `typescript` 6 too, as for every `@nxgt` package. `@typespec/openapi3`
|
|
18
22
|
compiles the spec, and `@nxgt/openapi-codegen` generates the code from it.
|
|
23
|
+
The generator's CLI, `nxgt-openapi`, runs on [Bun](https://bun.sh): it needs
|
|
24
|
+
`bun` on the PATH, even when called through `npx` or an npm script.
|
|
19
25
|
Emit OpenAPI 3.1 or 3.2 in `tspconfig.yaml`: `@typespec/openapi3` emits 3.0
|
|
20
26
|
by default, and the generator refuses it. Every convention here is compiled
|
|
21
27
|
to both in CI, and generates the same code from either.
|
|
@@ -33,6 +39,35 @@ options:
|
|
|
33
39
|
|
|
34
40
|
## Usage
|
|
35
41
|
|
|
42
|
+
### Start a project
|
|
43
|
+
|
|
44
|
+
`tsp init` with the package's template starts an API project with these
|
|
45
|
+
conventions in place. Run it in an empty directory, with
|
|
46
|
+
[Bun](https://bun.sh) on the PATH for the generator:
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
npx --package=@typespec/compiler tsp init https://unpkg.com/@nxgt/typespec/templates/scaffolding.json \
|
|
50
|
+
--template nxgt -y --project-name petstore
|
|
51
|
+
npx tsp compile .
|
|
52
|
+
npx nxgt-openapi generate
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
It installs the compiler, `@typespec/http`, `@typespec/openapi`,
|
|
56
|
+
`@typespec/openapi3`, this package and `@nxgt/openapi-codegen`, and writes:
|
|
57
|
+
|
|
58
|
+
- `tspconfig.yaml`: the linter's recommended rules, and OpenAPI 3.1 written
|
|
59
|
+
to `openapi/openapi.yaml`;
|
|
60
|
+
- `main.tsp`: the service in the namespace `Api`, with `@operationIds`, and a
|
|
61
|
+
`Users` resource with a paged, sorted list, `get`, `create`, `update` and
|
|
62
|
+
`delete`, and their error aliases;
|
|
63
|
+
- `openapi-codegen.config.ts`: the generator's input, and `src/generated`
|
|
64
|
+
with the Hono routes;
|
|
65
|
+
- `README.md`: the `api` and `api:check` scripts to add to `package.json`.
|
|
66
|
+
|
|
67
|
+
Drop `-y` and its options to be asked instead. The next steps, serving the
|
|
68
|
+
routes and renaming the resource, are in
|
|
69
|
+
[Getting started](docs/guide/getting-started.md).
|
|
70
|
+
|
|
36
71
|
### A spec split across files
|
|
37
72
|
|
|
38
73
|
A spec that grows is split by role: one file per resource's models, one per
|
|
@@ -381,6 +416,34 @@ The verbs `verbs` adds are not checked, nor an operation with its own
|
|
|
381
416
|
`@operationId`. More, with each verb's methods, in
|
|
382
417
|
[Operation ids](docs/guide/operation-ids.md).
|
|
383
418
|
|
|
419
|
+
### Linter
|
|
420
|
+
|
|
421
|
+
Extend the library's ruleset in `tspconfig.yaml`, and `tsp compile` warns
|
|
422
|
+
where the spec strays from these conventions. Nothing runs without it:
|
|
423
|
+
|
|
424
|
+
```yaml
|
|
425
|
+
# api/tspconfig.yaml
|
|
426
|
+
linter:
|
|
427
|
+
extends:
|
|
428
|
+
- '@nxgt/typespec/recommended'
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
| Rule | Warns when | Fix |
|
|
432
|
+
| --- | --- | --- |
|
|
433
|
+
| `list-returns-page` | an operation named `list`, `search` or `query`, alone or before a capital letter (`listUsers`, not `listing`), answers an array | return `Page<Item>` or `CursorPage<Item>` |
|
|
434
|
+
| `service-operation-ids` | a `@service` namespace has no `@operationIds`, on itself or on a namespace around it | mark the namespace with `@operationIds` |
|
|
435
|
+
| `error-body-shape` | a reply of status 400 or above, or `default`, has a body without `status`, `message` and `timestamp` | declare one of the library's errors, or a body that spreads or extends `ErrorBody<Status>` |
|
|
436
|
+
|
|
437
|
+
```text
|
|
438
|
+
warning @nxgt/typespec/list-returns-page: listAll returns an array: return Page<Item> or CursorPage<Item>, which can carry a total or a next cursor.
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
A reply without a body, such as `AuthenticationRequired`, passes
|
|
442
|
+
`error-body-shape`. Turn a rule off for the spec under `linter: disable:`
|
|
443
|
+
with a reason, or for one operation with
|
|
444
|
+
`#suppress "@nxgt/typespec/<rule>" "<reason>"`. More, with a failing and a
|
|
445
|
+
passing example of each rule, in [Linter](docs/guide/linter.md).
|
|
446
|
+
|
|
384
447
|
## API
|
|
385
448
|
|
|
386
449
|
### Decorators
|
|
@@ -403,6 +466,17 @@ overrides verbs, on a namespace or an interface.
|
|
|
403
466
|
| `merged-status-reply` | warning: an operation declares two replies with a body of one status code, which the emitter merges under the first one's description |
|
|
404
467
|
| `verb-method-mismatch` | warning: an operation `@operationIds` names after one of the library's verbs, in an interface, is sent with a method that verb does not name: `create` with a `GET` |
|
|
405
468
|
|
|
469
|
+
### Linter rules
|
|
470
|
+
|
|
471
|
+
In the ruleset `@nxgt/typespec/recommended`; each is a warning, and named
|
|
472
|
+
`@nxgt/typespec/<rule>` in `tspconfig.yaml` and `#suppress`.
|
|
473
|
+
|
|
474
|
+
| Rule | Reported when |
|
|
475
|
+
| --- | --- |
|
|
476
|
+
| `list-returns-page` | an operation named `list`, `search` or `query`, alone or before a capital letter, has a success reply whose body is an array |
|
|
477
|
+
| `service-operation-ids` | a `@service` namespace is not marked with `@operationIds`, itself or by a namespace around it |
|
|
478
|
+
| `error-body-shape` | a reply of status 400 or above, of a range from 400 up, or `default`, has a body that is not a model with `status`, `message` and `timestamp` |
|
|
479
|
+
|
|
406
480
|
### Models
|
|
407
481
|
|
|
408
482
|
| Model | What it is |
|
|
@@ -474,6 +548,9 @@ envelope and the rate limit's headers.
|
|
|
474
548
|
|
|
475
549
|
## Traps
|
|
476
550
|
|
|
551
|
+
- **`nxgt-openapi` fails with `env: 'bun': No such file or directory`**
|
|
552
|
+
without Bun on the PATH: install it, `curl -fsSL https://bun.sh/install | bash`
|
|
553
|
+
([troubleshooting](docs/troubleshooting.md#env-bun-no-such-file-or-directory)).
|
|
477
554
|
- **Do not declare a schema named `ValidationErrorBody`.** The generator
|
|
478
555
|
declares it itself, and two schemas of that name fail with
|
|
479
556
|
`name_collision`. `BadRequestBody` carries the `issues` instead.
|
|
@@ -531,6 +608,8 @@ envelope and the rate limit's headers.
|
|
|
531
608
|
|
|
532
609
|
## Documentation
|
|
533
610
|
|
|
611
|
+
- [Getting started](docs/guide/getting-started.md): the `tsp init`
|
|
612
|
+
template, the files it writes, and the steps from the spec to a Hono route;
|
|
534
613
|
- [Error replies](docs/guide/errors.md): the envelope, each response, the
|
|
535
614
|
aliases by verb, and what the generator makes of them;
|
|
536
615
|
- [Pagination](docs/guide/pagination.md): offset and cursor pages, and
|
|
@@ -546,6 +625,8 @@ envelope and the rate limit's headers.
|
|
|
546
625
|
- [Operation ids](docs/guide/operation-ids.md): `@operationIds`, each
|
|
547
626
|
operation named as written or a verb with its resource, the method each
|
|
548
627
|
verb is sent with, the options, and the ids it refuses;
|
|
628
|
+
- [Linter](docs/guide/linter.md): the ruleset `@nxgt/typespec/recommended`,
|
|
629
|
+
each rule with a failing and a passing spec, and how to turn one off;
|
|
549
630
|
- [troubleshooting](docs/troubleshooting.md);
|
|
550
631
|
- [the roadmap](docs/roadmap.md): what is coming.
|
|
551
632
|
|
package/dist/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import type { Program } from '@typespec/compiler';
|
|
10
10
|
import { operationIds } from './operation-ids';
|
|
11
11
|
export { $lib } from './lib';
|
|
12
|
+
export { $linter } from './linter';
|
|
12
13
|
export declare function $onValidate(program: Program): void;
|
|
13
14
|
export declare const $decorators: {
|
|
14
15
|
Nxgt: {
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,YAAY,EAAwB,MAAM,iBAAiB,CAAC;AAGrE,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,YAAY,EAAwB,MAAM,iBAAiB,CAAC;AAGrE,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEnC,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAMlD;AAED,eAAO,MAAM,WAAW;;;;CAEvB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -351,6 +351,127 @@ function validateVerbMethods(program) {
|
|
|
351
351
|
}
|
|
352
352
|
}
|
|
353
353
|
}
|
|
354
|
+
// src/linter.ts
|
|
355
|
+
import { defineLinter } from "@typespec/compiler";
|
|
356
|
+
|
|
357
|
+
// src/rules/error-body-shape.ts
|
|
358
|
+
import {
|
|
359
|
+
createRule,
|
|
360
|
+
isVoidType as isVoidType2,
|
|
361
|
+
paramMessage as paramMessage2,
|
|
362
|
+
walkPropertiesInherited
|
|
363
|
+
} from "@typespec/compiler";
|
|
364
|
+
import { getHttpOperation } from "@typespec/http";
|
|
365
|
+
|
|
366
|
+
// src/rules/written.ts
|
|
367
|
+
import { isTemplateDeclaration } from "@typespec/compiler";
|
|
368
|
+
function isWritten(operation) {
|
|
369
|
+
const container = operation.interface;
|
|
370
|
+
return isEmitted(operation) && !isTemplateDeclaration(operation) && (container === undefined || !isTemplateDeclaration(container));
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
// src/rules/error-body-shape.ts
|
|
374
|
+
var ENVELOPE = ["status", "message", "timestamp"];
|
|
375
|
+
function isEnvelope(body) {
|
|
376
|
+
const names = new Set([...walkPropertiesInherited(body)].map(({ name }) => name));
|
|
377
|
+
return ENVELOPE.every((name) => names.has(name));
|
|
378
|
+
}
|
|
379
|
+
function statusOf2(code) {
|
|
380
|
+
return typeof code === "object" ? `${code.start}-${code.end}` : `${code}`;
|
|
381
|
+
}
|
|
382
|
+
var errorBodyShape = createRule({
|
|
383
|
+
name: "error-body-shape",
|
|
384
|
+
severity: "warning",
|
|
385
|
+
description: "An error reply has the nxgt envelope: status, message and timestamp.",
|
|
386
|
+
messages: {
|
|
387
|
+
default: paramMessage2`${"operation"} answers ${"status"} with a body that is not the nxgt envelope: declare BadRequest, NotFound or another of the library's errors, or a body that spreads or extends ErrorBody<Status>.`
|
|
388
|
+
},
|
|
389
|
+
create: (context) => ({
|
|
390
|
+
operation(operation) {
|
|
391
|
+
if (!isWritten(operation))
|
|
392
|
+
return;
|
|
393
|
+
const [http] = getHttpOperation(context.program, operation);
|
|
394
|
+
for (const { statusCodes, responses } of http.responses) {
|
|
395
|
+
const error = statusCodes === "*" || (typeof statusCodes === "number" ? statusCodes >= 400 : statusCodes.start >= 400);
|
|
396
|
+
if (!error)
|
|
397
|
+
continue;
|
|
398
|
+
const wrong = responses.some(({ body }) => {
|
|
399
|
+
if (body === undefined || isVoidType2(body.type))
|
|
400
|
+
return false;
|
|
401
|
+
return body.type.kind !== "Model" || !isEnvelope(body.type);
|
|
402
|
+
});
|
|
403
|
+
if (!wrong)
|
|
404
|
+
continue;
|
|
405
|
+
context.reportDiagnostic({
|
|
406
|
+
format: { operation: operation.name, status: statusOf2(statusCodes) },
|
|
407
|
+
target: operation
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
})
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
// src/rules/list-returns-page.ts
|
|
415
|
+
import { createRule as createRule2, isArrayModelType, paramMessage as paramMessage3 } from "@typespec/compiler";
|
|
416
|
+
import { getHttpOperation as getHttpOperation2 } from "@typespec/http";
|
|
417
|
+
var LIST = /^(list|search|query)(?=[A-Z]|$)/;
|
|
418
|
+
var listReturnsPage = createRule2({
|
|
419
|
+
name: "list-returns-page",
|
|
420
|
+
severity: "warning",
|
|
421
|
+
description: "A list, search or query returns Page<Item> or CursorPage<Item>.",
|
|
422
|
+
messages: {
|
|
423
|
+
default: paramMessage3`${"operation"} returns an array: return Page<Item> or CursorPage<Item>, which can carry a total or a next cursor.`
|
|
424
|
+
},
|
|
425
|
+
create: (context) => ({
|
|
426
|
+
operation(operation) {
|
|
427
|
+
if (!isWritten(operation) || !LIST.test(operation.name))
|
|
428
|
+
return;
|
|
429
|
+
const [http] = getHttpOperation2(context.program, operation);
|
|
430
|
+
const array = http.responses.some(({ statusCodes, responses }) => typeof statusCodes === "number" && statusCodes >= 200 && statusCodes < 300 && responses.some(({ body }) => body?.type.kind === "Model" && isArrayModelType(body.type)));
|
|
431
|
+
if (!array)
|
|
432
|
+
return;
|
|
433
|
+
context.reportDiagnostic({
|
|
434
|
+
format: { operation: operation.name },
|
|
435
|
+
target: operation
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
})
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
// src/rules/service-operation-ids.ts
|
|
442
|
+
import { createRule as createRule3, isService as isService2, paramMessage as paramMessage4 } from "@typespec/compiler";
|
|
443
|
+
var serviceOperationIds = createRule3({
|
|
444
|
+
name: "service-operation-ids",
|
|
445
|
+
severity: "warning",
|
|
446
|
+
description: "A service namespace marks its operation ids with @operationIds.",
|
|
447
|
+
messages: {
|
|
448
|
+
default: paramMessage4`The service ${"service"} has no @operationIds: its ids are the emitter's, such as Users_list. Mark the namespace with @operationIds.`
|
|
449
|
+
},
|
|
450
|
+
create: (context) => ({
|
|
451
|
+
namespace(namespace) {
|
|
452
|
+
const { program } = context;
|
|
453
|
+
if (!isService2(program, namespace))
|
|
454
|
+
return;
|
|
455
|
+
if (isMarkedNamespace(program, namespace))
|
|
456
|
+
return;
|
|
457
|
+
context.reportDiagnostic({
|
|
458
|
+
format: { service: namespace.name },
|
|
459
|
+
target: namespace
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
})
|
|
463
|
+
});
|
|
464
|
+
|
|
465
|
+
// src/linter.ts
|
|
466
|
+
var rules = [listReturnsPage, serviceOperationIds, errorBodyShape];
|
|
467
|
+
var $linter = defineLinter({
|
|
468
|
+
rules,
|
|
469
|
+
ruleSets: {
|
|
470
|
+
recommended: {
|
|
471
|
+
enable: Object.fromEntries(rules.map(({ name }) => [`@nxgt/typespec/${name}`, true]))
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
});
|
|
354
475
|
|
|
355
476
|
// src/index.ts
|
|
356
477
|
function $onValidate(program) {
|
|
@@ -364,8 +485,9 @@ var $decorators = {
|
|
|
364
485
|
export {
|
|
365
486
|
$decorators,
|
|
366
487
|
$lib,
|
|
488
|
+
$linter,
|
|
367
489
|
$onValidate
|
|
368
490
|
};
|
|
369
491
|
|
|
370
|
-
//# debugId=
|
|
492
|
+
//# debugId=FB766460AB7EEFAD64756E2164756E21
|
|
371
493
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/one-reply-per-status.ts", "../src/lib.ts", "../src/operation-ids.ts", "../src/verbs.ts", "../src/resource.ts", "../src/verb-methods.ts", "../src/index.ts"],
|
|
3
|
+
"sources": ["../src/one-reply-per-status.ts", "../src/lib.ts", "../src/operation-ids.ts", "../src/verbs.ts", "../src/resource.ts", "../src/verb-methods.ts", "../src/linter.ts", "../src/rules/error-body-shape.ts", "../src/rules/written.ts", "../src/rules/list-returns-page.ts", "../src/rules/service-operation-ids.ts", "../src/index.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"/**\n * One reply per status: `@typespec/openapi3` merges two replies of one\n * status into one without a word. A reply without a body beside one with a\n * body is lost in the merge, an error; a `void` body is none, as the emitter\n * sees it. Two bodies of one content type are merged under the first reply's\n * description, a warning where the status is a code. Under `*` or a range,\n * where undocumented `@error` models share one description, they pass.\n * Bodies of different content types are one reply, negotiated, and pass.\n */\nimport { isVoidType, type Operation, type Program } from '@typespec/compiler';\nimport {\n\tgetAllHttpServices,\n\ttype HttpOperationResponse,\n\ttype HttpStatusCodesEntry,\n} from '@typespec/http';\nimport { $lib } from './lib';\n\nfunction statusOf(code: HttpStatusCodesEntry): string {\n\treturn typeof code === 'object' ? `${code.start}-${code.end}` : `${code}`;\n}\n\n/** What the emitter's merge costs: a reply, a description, or nothing. */\nfunction mergeOf({\n\tstatusCodes,\n\tresponses,\n}: HttpOperationResponse):\n\t| 'duplicate-status-reply'\n\t| 'merged-status-reply'\n\t| undefined {\n\tconst bodies = responses.flatMap(({ body }) =>\n\t\tbody && !isVoidType(body.type) ? [body] : [],\n\t);\n\tif (bodies.length > 0 && bodies.length < responses.length) {\n\t\treturn 'duplicate-status-reply';\n\t}\n\tif (typeof statusCodes !== 'number') return undefined;\n\tconst seen = new Set<string>();\n\tfor (const body of bodies) {\n\t\tif (body.contentTypes.some((type) => seen.has(type))) {\n\t\t\treturn 'merged-status-reply';\n\t\t}\n\t\tfor (const type of body.contentTypes) seen.add(type);\n\t}\n\treturn undefined;\n}\n\n/**\n * Checks each operation of each service, as the emitter sees it, once: a\n * service nested in another is listed in both. The services' own\n * diagnostics are the emitter's to report.\n */\nexport function validateOneReplyPerStatus(program: Program): void {\n\tconst [services] = getAllHttpServices(program);\n\tconst checked = new Set<Operation>();\n\tfor (const service of services) {\n\t\tfor (const operation of service.operations) {\n\t\t\tif (checked.has(operation.operation)) continue;\n\t\t\tchecked.add(operation.operation);\n\t\t\tfor (const response of operation.responses) {\n\t\t\t\tconst code = mergeOf(response);\n\t\t\t\tif (code === undefined) continue;\n\t\t\t\t$lib.reportDiagnostic(program, {\n\t\t\t\t\tcode,\n\t\t\t\t\tformat: {\n\t\t\t\t\t\toperation: operation.operation.name,\n\t\t\t\t\t\tstatus: statusOf(response.statusCodes),\n\t\t\t\t\t},\n\t\t\t\t\ttarget: operation.operation,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n}\n",
|
|
6
6
|
"/** The library's definition: its name, diagnostics and state keys. */\nimport { createTypeSpecLibrary, paramMessage } from '@typespec/compiler';\n\nexport const $lib = createTypeSpecLibrary({\n\tname: '@nxgt/typespec',\n\tdiagnostics: {\n\t\t'duplicate-operation-id': {\n\t\t\tseverity: 'error',\n\t\t\tmessages: {\n\t\t\t\tdefault: paramMessage`Two operations are named ${'id'}: an OpenAPI operation id must be unique.`,\n\t\t\t},\n\t\t},\n\t\t'resource-name-on-namespace': {\n\t\t\tseverity: 'error',\n\t\t\tmessages: {\n\t\t\t\tdefault:\n\t\t\t\t\t\"`singular` and `plural` name an interface's resource: a namespace has none. Put them on the interface.\",\n\t\t\t},\n\t\t},\n\t\t'verb-method-mismatch': {\n\t\t\tseverity: 'warning',\n\t\t\tmessages: {\n\t\t\t\tdefault: paramMessage`${'operation'} is sent with ${'method'}, where its verb ${'verb'} is sent with ${'expected'}. Give it that method, or a name that is not a verb.`,\n\t\t\t},\n\t\t},\n\t\t'duplicate-status-reply': {\n\t\t\tseverity: 'error',\n\t\t\tmessages: {\n\t\t\t\tdefault: paramMessage`${'operation'} declares a reply without a body and one with a body of status ${'status'}: the emitter merges them into one, and the reply without a body is lost. Declare the one the route sends.`,\n\t\t\t},\n\t\t},\n\t\t'merged-status-reply': {\n\t\t\tseverity: 'warning',\n\t\t\tmessages: {\n\t\t\t\tdefault: paramMessage`${'operation'} declares two replies with a body of status ${'status'}: the emitter merges their bodies under the first one's description. Declare the one the route sends.`,\n\t\t\t},\n\t\t},\n\t},\n\tstate: {\n\t\toperationIds: {\n\t\t\tdescription: 'The interfaces and namespaces marked with @operationIds',\n\t\t},\n\t\toperationIdsOptions: {\n\t\t\tdescription:\n\t\t\t\t\"Each marked interface's or namespace's @operationIds options\",\n\t\t},\n\t},\n});\n",
|
|
7
|
-
"/**\n * `@operationIds`: the id of each operation is its name, as written:\n * `@get findPostComments()` is `findPostComments`, where `@typespec/openapi3`\n * would write `Posts_findPostComments`. In an interface, a known verb takes\n * the interface's resource: `create` in `Users` is `createUser` (`verbs.ts`).\n */\nimport {\n\ttype DecoratorContext,\n\ttype Interface,\n\tisService,\n\tisTemplateInstance,\n\tlistServices,\n\ttype Namespace,\n\tnavigateProgram,\n\ttype Operation,\n\ttype Program,\n} from '@typespec/compiler';\nimport {\n\tgetOperationId,\n\tresolveOperationId,\n\tsetOperationId,\n} from '@typespec/openapi';\nimport { $lib } from './lib';\nimport { idOf, type OperationIdsOptions } from './resource';\n\n/**\n * Marks the interface or the namespace; its ids are set once the program is\n * checked. On a template, TypeSpec runs it on each instance, which\n * `isMarkedInterface` follows to the interfaces extending it. A namespace\n * has no resource to name: `singular` and `plural` are an interface's.\n */\nexport function operationIds(\n\tcontext: DecoratorContext,\n\ttarget: Interface | Namespace,\n\toptions: OperationIdsOptions = {},\n): void {\n\tconst { program } = context;\n\tprogram.stateSet($lib.stateKeys.operationIds).add(target);\n\tprogram.stateMap($lib.stateKeys.operationIdsOptions).set(target, options);\n\tif (\n\t\ttarget.kind === 'Namespace' &&\n\t\t(options.singular !== undefined || options.plural !== undefined)\n\t) {\n\t\t$lib.reportDiagnostic(program, {\n\t\t\tcode: 'resource-name-on-namespace',\n\t\t\ttarget: context.decoratorTarget,\n\t\t});\n\t}\n}\n\n/** Marked itself, or in a marked namespace, however deep. */\
|
|
7
|
+
"/**\n * `@operationIds`: the id of each operation is its name, as written:\n * `@get findPostComments()` is `findPostComments`, where `@typespec/openapi3`\n * would write `Posts_findPostComments`. In an interface, a known verb takes\n * the interface's resource: `create` in `Users` is `createUser` (`verbs.ts`).\n */\nimport {\n\ttype DecoratorContext,\n\ttype Interface,\n\tisService,\n\tisTemplateInstance,\n\tlistServices,\n\ttype Namespace,\n\tnavigateProgram,\n\ttype Operation,\n\ttype Program,\n} from '@typespec/compiler';\nimport {\n\tgetOperationId,\n\tresolveOperationId,\n\tsetOperationId,\n} from '@typespec/openapi';\nimport { $lib } from './lib';\nimport { idOf, type OperationIdsOptions } from './resource';\n\n/**\n * Marks the interface or the namespace; its ids are set once the program is\n * checked. On a template, TypeSpec runs it on each instance, which\n * `isMarkedInterface` follows to the interfaces extending it. A namespace\n * has no resource to name: `singular` and `plural` are an interface's.\n */\nexport function operationIds(\n\tcontext: DecoratorContext,\n\ttarget: Interface | Namespace,\n\toptions: OperationIdsOptions = {},\n): void {\n\tconst { program } = context;\n\tprogram.stateSet($lib.stateKeys.operationIds).add(target);\n\tprogram.stateMap($lib.stateKeys.operationIdsOptions).set(target, options);\n\tif (\n\t\ttarget.kind === 'Namespace' &&\n\t\t(options.singular !== undefined || options.plural !== undefined)\n\t) {\n\t\t$lib.reportDiagnostic(program, {\n\t\t\tcode: 'resource-name-on-namespace',\n\t\t\ttarget: context.decoratorTarget,\n\t\t});\n\t}\n}\n\n/** Marked itself, or in a marked namespace, however deep. */\nexport function isMarkedNamespace(\n\tprogram: Program,\n\ttarget: Namespace | undefined,\n): boolean {\n\tfor (let at = target; at !== undefined; at = at.namespace) {\n\t\tif (program.stateSet($lib.stateKeys.operationIds).has(at)) return true;\n\t}\n\treturn false;\n}\n\n/** Marked itself, or extending a marked interface: an instance of a marked template included. */\nfunction isMarkedInterface(program: Program, target: Interface): boolean {\n\treturn (\n\t\tprogram.stateSet($lib.stateKeys.operationIds).has(target) ||\n\t\ttarget.sourceInterfaces.some((source) => isMarkedInterface(program, source))\n\t);\n}\n\n/**\n * Whether `@operationIds` names the operation's id, or checks it: its\n * interface or one of its namespaces is marked. An interface template's\n * instance is never emitted; only the interfaces extending it are.\n */\nexport function isNamed(program: Program, operation: Operation): boolean {\n\tconst container = operation.interface;\n\tif (container === undefined) {\n\t\treturn isMarkedNamespace(program, operation.namespace);\n\t}\n\treturn (\n\t\t!isTemplateInstance(container) &&\n\t\t(isMarkedInterface(program, container) ||\n\t\t\tisMarkedNamespace(program, container.namespace))\n\t);\n}\n\n/**\n * Whether the emitter writes the operation: not an instance of an operation\n * template, `Read<Pet>`, nor an operation of an interface template's\n * instance. An interface extending an instance copies its operations, which\n * are instances too, and emitted.\n */\nexport function isEmitted(operation: Operation): boolean {\n\tconst container = operation.interface;\n\tif (container === undefined) return !isTemplateInstance(operation);\n\treturn !isTemplateInstance(container);\n}\n\n/**\n * The services whose document the operation is in: each `@service`\n * namespace around it, a nested one and the one outside it both. None, in a\n * program without a service, is the one document the emitter writes; in a\n * program with one, no document at all.\n */\nfunction servicesOf(program: Program, operation: Operation): Namespace[] {\n\tconst services: Namespace[] = [];\n\tfor (\n\t\tlet at = operation.interface?.namespace ?? operation.namespace;\n\t\tat !== undefined;\n\t\tat = at.namespace\n\t) {\n\t\tif (isService(program, at)) services.push(at);\n\t}\n\treturn services;\n}\n\n/**\n * Sets the ids, after every decorator, so the order of `@operationId` and\n * `@operationIds` in the source does not matter. Two operations with one id\n * in one service's document, one of them named by `@operationIds`, are an\n * error: one name in two interfaces, an interface that `extends` another and\n * so copies its operations, or an `@operationId` written elsewhere.\n * `@typespec/openapi3` would emit both without a word. An operation\n * template's instance, such as `Read<Pet>`, is never emitted; only the\n * operations declared from it (`op readPet is Read<Pet>`) are.\n */\nexport function validateOperationIds(program: Program): void {\n\tconst seen = new Map<Namespace | undefined, Map<string, boolean>>();\n\tconst hasServices = listServices(program).length > 0;\n\tnavigateProgram(program, {\n\t\toperation(operation) {\n\t\t\tif (!isEmitted(operation)) return;\n\t\t\tconst named = isNamed(program, operation);\n\t\t\tconst own = getOperationId(program, operation);\n\t\t\t// Elsewhere, only checked: the id `@typespec/openapi3` gives under its\n\t\t\t// default strategy.\n\t\t\tconst id =\n\t\t\t\town ??\n\t\t\t\t(named\n\t\t\t\t\t? idOf(program, operation)\n\t\t\t\t\t: resolveOperationId(program, operation));\n\t\t\tconst services = servicesOf(program, operation);\n\t\t\t// Outside every service of a program that has one: in no document.\n\t\t\tconst emitted = services.length > 0 || !hasServices;\n\t\t\tlet duplicate = false;\n\t\t\tfor (const service of services.length > 0 ? services : [undefined]) {\n\t\t\t\tconst ids = seen.get(service) ?? new Map<string, boolean>();\n\t\t\t\tseen.set(service, ids);\n\t\t\t\tif (emitted && ids.has(id) && (named || ids.get(id))) duplicate = true;\n\t\t\t\tids.set(id, named || (ids.get(id) ?? false));\n\t\t\t}\n\t\t\tif (duplicate) {\n\t\t\t\t$lib.reportDiagnostic(program, {\n\t\t\t\t\tcode: 'duplicate-operation-id',\n\t\t\t\t\tformat: { id },\n\t\t\t\t\ttarget: operation,\n\t\t\t\t});\n\t\t\t}\n\t\t\t// Only the ids it gives: an explicit id on any other operation would\n\t\t\t// override the emitter's `operation-id-strategy`.\n\t\t\tif (named && own === undefined) setOperationId(program, operation, id);\n\t\t},\n\t});\n}\n",
|
|
8
8
|
"/**\n * The verbs `@operationIds` completes with an interface's resource: `create`\n * in `Users` is `createUser`, `list` is `listUsers`, and `findById` is\n * `findUserById`. Any other name is the id as written.\n */\n\n/** Whether a verb takes the resource's singular or its plural. */\nexport type Grammar = 'singular' | 'plural';\n\n/** A resource's two names: `User` and `Users`. */\nexport interface Resource {\n\treadonly singular: string;\n\treadonly plural: string;\n}\n\n/** The library's own verbs. */\nexport const VERBS: Readonly<Record<string, Grammar>> = {\n\tlist: 'plural',\n\tread: 'plural',\n\tfind: 'plural',\n\tsearch: 'plural',\n\tquery: 'plural',\n\tcount: 'plural',\n\tcreateMany: 'plural',\n\tupdateMany: 'plural',\n\tdeleteMany: 'plural',\n\tget: 'singular',\n\tcreate: 'singular',\n\tupdate: 'singular',\n\tpatch: 'singular',\n\treplace: 'singular',\n\tupsert: 'singular',\n\tdelete: 'singular',\n};\n\n/**\n * The HTTP methods each of the library's verbs is sent with: a read is a\n * `GET` (or a `HEAD`), a search may carry its criteria in a `POST` body, a\n * bulk delete its ids. `QUERY` joins `search` and `query` once\n * `@typespec/http` declares it.\n */\nexport const METHODS: Readonly<Record<string, readonly string[]>> = {\n\tlist: ['get', 'head'],\n\tread: ['get', 'head'],\n\tfind: ['get', 'head'],\n\tcount: ['get', 'head'],\n\tget: ['get', 'head'],\n\tsearch: ['get', 'post'],\n\tquery: ['get', 'post'],\n\tcreate: ['post'],\n\tcreateMany: ['post'],\n\tupdate: ['put', 'patch'],\n\tupdateMany: ['put', 'patch'],\n\tpatch: ['patch'],\n\treplace: ['put'],\n\tupsert: ['put'],\n\tdelete: ['delete'],\n\tdeleteMany: ['delete', 'post'],\n};\n\n/** Plurals the rules below get wrong, by their singular. */\nconst IRREGULAR: Readonly<Record<string, string>> = {\n\tpeople: 'person',\n\tchildren: 'child',\n\tmen: 'man',\n\twomen: 'woman',\n\tmice: 'mouse',\n\tfeet: 'foot',\n\tteeth: 'tooth',\n\tgeese: 'goose',\n\tmovies: 'movie',\n\tcookies: 'cookie',\n\tseries: 'series',\n\tspecies: 'species',\n\tnews: 'news',\n};\n\n/** `-es` plurals of a singular in `-us`: `Statuses`, not `Houses`. */\nconst US_ES = /(stat|bon|camp|vir|b|foc|cens|corp|radi|syllab)uses$/i;\n\n/** `-es` plurals of a singular in a sibilant: `Boxes`, `Matches`, `Wishes`. */\nconst SIBILANT_ES = /(ss|x|zz|sh|tch|nch|rch|oach)es$/i;\n\n/**\n * The singular of a plural name, by a short English rule on its last word:\n * `Users`, `BlogPosts`, `Categories`, `Addresses`, `Statuses`, `People`. A\n * guess: it misses some (`Heroes`, `Analysis`), which `singular` names.\n */\nexport function singularOf(plural: string): string {\n\tconst word = /[A-Z]?[a-z0-9]*$/.exec(plural)?.[0] ?? '';\n\tconst head = plural.slice(0, plural.length - word.length);\n\tconst key = word.toLowerCase();\n\tconst irregular = Object.hasOwn(IRREGULAR, key) ? IRREGULAR[key] : undefined;\n\tif (irregular !== undefined) {\n\t\tconst cased = word[0] === word[0]?.toUpperCase();\n\t\treturn `${head}${cased ? irregular[0]?.toUpperCase() + irregular.slice(1) : irregular}`;\n\t}\n\tif (/ies$/.test(word) && word.length > 4)\n\t\treturn `${head}${word.slice(0, -3)}y`;\n\tif (US_ES.test(word) || SIBILANT_ES.test(word)) {\n\t\treturn `${head}${word.slice(0, -2)}`;\n\t}\n\tif (/[^su]s$/.test(word)) return `${head}${word.slice(0, -1)}`;\n\treturn plural;\n}\n\n/**\n * The verb a name starts with, and the rest: the whole name, `list`, or the\n * verb before a `By`, `findById`. `undefined` when the name is neither.\n */\nexport function verbIn(\n\tname: string,\n\tverbs: Readonly<Record<string, Grammar>>,\n): { readonly verb: string; readonly rest: string } | undefined {\n\tif (Object.hasOwn(verbs, name)) return { verb: name, rest: '' };\n\tfor (const by of name.matchAll(/By[A-Z]/g)) {\n\t\tconst verb = name.slice(0, by.index);\n\t\tif (verb !== '' && Object.hasOwn(verbs, verb)) {\n\t\t\treturn { verb, rest: name.slice(by.index) };\n\t\t}\n\t}\n\treturn undefined;\n}\n\n/**\n * The id of an operation of a resource: the verb and the resource's singular\n * or plural, or the verb, the resource and the rest of a `By` name:\n * `findById` to `findUserById`, the singular, but `deleteManyByTeam` to\n * `deleteManyUsersByTeam`, the plural of a `*Many` verb. `undefined` when\n * the name is none of them. The resource is taken only then.\n */\nexport function idWithVerb(\n\tname: string,\n\tresource: () => Resource,\n\tverbs: Readonly<Record<string, Grammar>>,\n): string | undefined {\n\tconst found = verbIn(name, verbs);\n\tif (found === undefined) return undefined;\n\tconst { verb, rest } = found;\n\tconst names = resource();\n\tconst noun =\n\t\trest === ''\n\t\t\t? names[verbs[verb] as Grammar]\n\t\t\t: verb.endsWith('Many')\n\t\t\t\t? names.plural\n\t\t\t\t: names.singular;\n\treturn `${verb}${noun}${rest}`;\n}\n",
|
|
9
9
|
"/**\n * What `@operationIds` names an operation of an interface after: the\n * interface's resource, its singular and plural, and the verbs that take\n * them, layered from the library's, the namespaces', and the interface's.\n */\nimport type {\n\tInterface,\n\tNamespace,\n\tOperation,\n\tProgram,\n} from '@typespec/compiler';\nimport { $lib } from './lib';\nimport {\n\ttype Grammar,\n\tidWithVerb,\n\ttype Resource,\n\tsingularOf,\n\tVERBS,\n\tverbIn,\n} from './verbs';\n\n/** `@operationIds`' options, as `OperationIdsOptions` declares them. */\nexport interface OperationIdsOptions {\n\treadonly singular?: string;\n\treadonly plural?: string;\n\treadonly verbs?: Readonly<Record<string, Grammar>>;\n}\n\nfunction optionsOf(\n\tprogram: Program,\n\ttarget: Interface | Namespace,\n): OperationIdsOptions | undefined {\n\treturn program.stateMap($lib.stateKeys.operationIdsOptions).get(target);\n}\n\n/** The interface, then those it extends, however deep. */\nfunction lineageOf(target: Interface): Interface[] {\n\treturn [target, ...target.sourceInterfaces.flatMap(lineageOf)];\n}\n\n/**\n * The verbs an interface's operations take: the library's, then each marked\n * namespace's around it, outermost first, then its lineage's, its own last,\n * each overriding the one before.\n */\nfunction verbsOf(program: Program, target: Interface): Record<string, Grammar> {\n\tconst namespaces: Namespace[] = [];\n\tfor (let at = target.namespace; at !== undefined; at = at.namespace) {\n\t\tnamespaces.unshift(at);\n\t}\n\tconst layers = [...namespaces, ...lineageOf(target).reverse()];\n\treturn Object.assign(\n\t\t{},\n\t\tVERBS,\n\t\t...layers.map((layer) => optionsOf(program, layer)?.verbs ?? {}),\n\t);\n}\n\n/**\n * An interface's resource: its own `plural`, or its name, and its own\n * `singular`, or the plural's singular. Never an interface it extends: two\n * interfaces extending one would share its names, and collide.\n */\nfunction resourceOf(program: Program, target: Interface): Resource {\n\tconst options = optionsOf(program, target);\n\tconst plural = options?.plural || target.name;\n\treturn { plural, singular: options?.singular || singularOf(plural) };\n}\n\n/** The id `@operationIds` gives: the name as written, or a verb with its resource. */\nexport function idOf(program: Program, operation: Operation): string {\n\tconst container = operation.interface;\n\tif (container === undefined) return operation.name;\n\treturn (\n\t\tidWithVerb(\n\t\t\toperation.name,\n\t\t\t() => resourceOf(program, container),\n\t\t\tverbsOf(program, container),\n\t\t) ?? operation.name\n\t);\n}\n\n/** The verb an operation of an interface is named with, `find` in `findById`. */\nexport function verbOf(\n\tprogram: Program,\n\toperation: Operation,\n): string | undefined {\n\tconst container = operation.interface;\n\tif (container === undefined) return undefined;\n\treturn verbIn(operation.name, verbsOf(program, container))?.verb;\n}\n",
|
|
10
10
|
"/**\n * A verb names what an operation does, and its method says the same:\n * `create` in `Users` is `createUser`, and a `GET` would tell a cache, a\n * proxy or a retry it is safe. An operation `@operationIds` names after one\n * of the library's verbs is sent with that verb's methods (`verbs.ts`), or\n * warned of. A verb `verbs` adds has no method to check, and an operation's\n * own `@operationId` is an id that is no verb. It runs before\n * `validateOperationIds` sets the others.\n */\nimport type { Operation, Program } from '@typespec/compiler';\nimport { getAllHttpServices } from '@typespec/http';\nimport { getOperationId } from '@typespec/openapi';\nimport { $lib } from './lib';\nimport { isNamed } from './operation-ids';\nimport { verbOf } from './resource';\nimport { METHODS } from './verbs';\n\n/** `PUT or PATCH`. */\nfunction methodsOf(methods: readonly string[]): string {\n\treturn methods.map((method) => method.toUpperCase()).join(' or ');\n}\n\n/** Checks each operation of each service once, as the emitter sends it. */\nexport function validateVerbMethods(program: Program): void {\n\tconst [services] = getAllHttpServices(program);\n\tconst checked = new Set<Operation>();\n\tfor (const service of services) {\n\t\tfor (const { operation, verb: method } of service.operations) {\n\t\t\tif (checked.has(operation)) continue;\n\t\t\tchecked.add(operation);\n\t\t\tif (!isNamed(program, operation)) continue;\n\t\t\tif (getOperationId(program, operation) !== undefined) continue;\n\t\t\tconst verb = verbOf(program, operation);\n\t\t\tif (verb === undefined || !Object.hasOwn(METHODS, verb)) continue;\n\t\t\tconst expected = METHODS[verb] as readonly string[];\n\t\t\tif (expected.includes(method)) continue;\n\t\t\t$lib.reportDiagnostic(program, {\n\t\t\t\tcode: 'verb-method-mismatch',\n\t\t\t\tformat: {\n\t\t\t\t\toperation: operation.name,\n\t\t\t\t\tmethod: method.toUpperCase(),\n\t\t\t\t\tverb,\n\t\t\t\t\texpected: methodsOf(expected),\n\t\t\t\t},\n\t\t\t\ttarget: operation,\n\t\t\t});\n\t\t}\n\t}\n}\n",
|
|
11
|
-
"/**\n * The
|
|
11
|
+
"/**\n * The library's linter: rules a spec opts into in its `tspconfig.yaml`,\n * each a warning, each one it can turn off.\n *\n * ```yaml\n * linter:\n * extends:\n * - \"@nxgt/typespec/recommended\"\n * ```\n */\nimport { defineLinter } from '@typespec/compiler';\nimport { errorBodyShape } from './rules/error-body-shape';\nimport { listReturnsPage } from './rules/list-returns-page';\nimport { serviceOperationIds } from './rules/service-operation-ids';\n\nconst rules = [listReturnsPage, serviceOperationIds, errorBodyShape];\n\nexport const $linter = defineLinter({\n\trules,\n\truleSets: {\n\t\trecommended: {\n\t\t\tenable: Object.fromEntries(\n\t\t\t\trules.map(({ name }) => [`@nxgt/typespec/${name}`, true]),\n\t\t\t),\n\t\t},\n\t},\n});\n",
|
|
12
|
+
"/**\n * An error reply's body is the envelope `@nxgt/openapi-hono` sends: a\n * `status`, a `message` and a `timestamp`, as `ErrorBody<Status>` declares\n * them. A reply without a body passes: `AuthenticationRequired` has none.\n */\nimport {\n\tcreateRule,\n\tisVoidType,\n\ttype Model,\n\tparamMessage,\n\twalkPropertiesInherited,\n} from '@typespec/compiler';\nimport { getHttpOperation } from '@typespec/http';\nimport { isWritten } from './written';\n\nconst ENVELOPE = ['status', 'message', 'timestamp'];\n\n/** Its own properties and those of the models it extends. */\nfunction isEnvelope(body: Model): boolean {\n\tconst names = new Set(\n\t\t[...walkPropertiesInherited(body)].map(({ name }) => name),\n\t);\n\treturn ENVELOPE.every((name) => names.has(name));\n}\n\nfunction statusOf(code: number | { start: number; end: number } | '*'): string {\n\treturn typeof code === 'object' ? `${code.start}-${code.end}` : `${code}`;\n}\n\nexport const errorBodyShape = createRule({\n\tname: 'error-body-shape',\n\tseverity: 'warning',\n\tdescription:\n\t\t'An error reply has the nxgt envelope: status, message and timestamp.',\n\tmessages: {\n\t\tdefault: paramMessage`${'operation'} answers ${'status'} with a body that is not the nxgt envelope: declare BadRequest, NotFound or another of the library's errors, or a body that spreads or extends ErrorBody<Status>.`,\n\t},\n\tcreate: (context) => ({\n\t\toperation(operation) {\n\t\t\tif (!isWritten(operation)) return;\n\t\t\tconst [http] = getHttpOperation(context.program, operation);\n\t\t\tfor (const { statusCodes, responses } of http.responses) {\n\t\t\t\tconst error =\n\t\t\t\t\tstatusCodes === '*' ||\n\t\t\t\t\t(typeof statusCodes === 'number'\n\t\t\t\t\t\t? statusCodes >= 400\n\t\t\t\t\t\t: statusCodes.start >= 400);\n\t\t\t\tif (!error) continue;\n\t\t\t\tconst wrong = responses.some(({ body }) => {\n\t\t\t\t\tif (body === undefined || isVoidType(body.type)) return false;\n\t\t\t\t\treturn body.type.kind !== 'Model' || !isEnvelope(body.type);\n\t\t\t\t});\n\t\t\t\tif (!wrong) continue;\n\t\t\t\tcontext.reportDiagnostic({\n\t\t\t\t\tformat: { operation: operation.name, status: statusOf(statusCodes) },\n\t\t\t\t\ttarget: operation,\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t}),\n});\n",
|
|
13
|
+
"/**\n * Whether the emitter writes an operation: not a template's declaration,\n * nor its instance (`Read<Pet>`), nor an operation of an interface\n * template's. Only the operations declared from them are checked.\n */\nimport { isTemplateDeclaration, type Operation } from '@typespec/compiler';\nimport { isEmitted } from '../operation-ids';\n\nexport function isWritten(operation: Operation): boolean {\n\tconst container = operation.interface;\n\treturn (\n\t\tisEmitted(operation) &&\n\t\t!isTemplateDeclaration(operation) &&\n\t\t(container === undefined || !isTemplateDeclaration(container))\n\t);\n}\n",
|
|
14
|
+
"/**\n * A list returns a page: `Page<Item>` or `CursorPage<Item>`, never a bare\n * array, which cannot grow a `total` or a `nextCursor` without breaking its\n * clients. A list is an operation named `list`, `search` or `query`, alone\n * or followed by more: `listUsers`, `searchPosts`.\n */\nimport { createRule, isArrayModelType, paramMessage } from '@typespec/compiler';\nimport { getHttpOperation } from '@typespec/http';\nimport { isWritten } from './written';\n\nconst LIST = /^(list|search|query)(?=[A-Z]|$)/;\n\nexport const listReturnsPage = createRule({\n\tname: 'list-returns-page',\n\tseverity: 'warning',\n\tdescription:\n\t\t'A list, search or query returns Page<Item> or CursorPage<Item>.',\n\tmessages: {\n\t\tdefault: paramMessage`${'operation'} returns an array: return Page<Item> or CursorPage<Item>, which can carry a total or a next cursor.`,\n\t},\n\tcreate: (context) => ({\n\t\toperation(operation) {\n\t\t\tif (!isWritten(operation) || !LIST.test(operation.name)) return;\n\t\t\tconst [http] = getHttpOperation(context.program, operation);\n\t\t\tconst array = http.responses.some(\n\t\t\t\t({ statusCodes, responses }) =>\n\t\t\t\t\ttypeof statusCodes === 'number' &&\n\t\t\t\t\tstatusCodes >= 200 &&\n\t\t\t\t\tstatusCodes < 300 &&\n\t\t\t\t\tresponses.some(\n\t\t\t\t\t\t({ body }) =>\n\t\t\t\t\t\t\tbody?.type.kind === 'Model' && isArrayModelType(body.type),\n\t\t\t\t\t),\n\t\t\t);\n\t\t\tif (!array) return;\n\t\t\tcontext.reportDiagnostic({\n\t\t\t\tformat: { operation: operation.name },\n\t\t\t\ttarget: operation,\n\t\t\t});\n\t\t},\n\t}),\n});\n",
|
|
15
|
+
"/**\n * A service without `@operationIds` gets the emitter's ids: `Users_list`,\n * which the generated client's methods are named after.\n */\nimport { createRule, isService, paramMessage } from '@typespec/compiler';\nimport { isMarkedNamespace } from '../operation-ids';\n\nexport const serviceOperationIds = createRule({\n\tname: 'service-operation-ids',\n\tseverity: 'warning',\n\tdescription:\n\t\t'A service namespace marks its operation ids with @operationIds.',\n\tmessages: {\n\t\tdefault: paramMessage`The service ${'service'} has no @operationIds: its ids are the emitter's, such as Users_list. Mark the namespace with @operationIds.`,\n\t},\n\tcreate: (context) => ({\n\t\tnamespace(namespace) {\n\t\t\tconst { program } = context;\n\t\t\tif (!isService(program, namespace)) return;\n\t\t\tif (isMarkedNamespace(program, namespace)) return;\n\t\t\tcontext.reportDiagnostic({\n\t\t\t\tformat: { service: namespace.name },\n\t\t\t\ttarget: namespace,\n\t\t\t});\n\t\t},\n\t}),\n});\n",
|
|
16
|
+
"/**\n * The JavaScript side of the `@nxgt/typespec` library, which `lib/main.tsp`\n * imports from `dist/`: its name and diagnostics, and the decorators a\n * template cannot express. The conventions themselves are in `lib/`.\n *\n * A decorator is exported only through `$decorators`: a top-level `$name`\n * export would declare it a second time, in the global namespace.\n */\nimport type { Program } from '@typespec/compiler';\nimport { validateOneReplyPerStatus } from './one-reply-per-status';\nimport { operationIds, validateOperationIds } from './operation-ids';\nimport { validateVerbMethods } from './verb-methods';\n\nexport { $lib } from './lib';\nexport { $linter } from './linter';\n\nexport function $onValidate(program: Program): void {\n\t// Before the ids are set: only an `@operationId` written in the spec is\n\t// one then, and the operation it names is not checked.\n\tvalidateVerbMethods(program);\n\tvalidateOperationIds(program);\n\tvalidateOneReplyPerStatus(program);\n}\n\nexport const $decorators = {\n\tNxgt: { operationIds },\n};\n"
|
|
12
17
|
],
|
|
13
|
-
"mappings": ";AASA;AACA;AAAA;AAAA;;;ACTA;AAEO,IAAM,OAAO,sBAAsB;AAAA,EACzC,MAAM;AAAA,EACN,aAAa;AAAA,IACZ,0BAA0B;AAAA,MACzB,UAAU;AAAA,MACV,UAAU;AAAA,QACT,SAAS,wCAAwC;AAAA,MAClD;AAAA,IACD;AAAA,IACA,8BAA8B;AAAA,MAC7B,UAAU;AAAA,MACV,UAAU;AAAA,QACT,SACC;AAAA,MACF;AAAA,IACD;AAAA,IACA,wBAAwB;AAAA,MACvB,UAAU;AAAA,MACV,UAAU;AAAA,QACT,SAAS,eAAe,4BAA4B,4BAA4B,uBAAuB;AAAA,MACxG;AAAA,IACD;AAAA,IACA,0BAA0B;AAAA,MACzB,UAAU;AAAA,MACV,UAAU;AAAA,QACT,SAAS,eAAe,6EAA6E;AAAA,MACtG;AAAA,IACD;AAAA,IACA,uBAAuB;AAAA,MACtB,UAAU;AAAA,MACV,UAAU;AAAA,QACT,SAAS,eAAe,0DAA0D;AAAA,MACnF;AAAA,IACD;AAAA,EACD;AAAA,EACA,OAAO;AAAA,IACN,cAAc;AAAA,MACb,aAAa;AAAA,IACd;AAAA,IACA,qBAAqB;AAAA,MACpB,aACC;AAAA,IACF;AAAA,EACD;AACD,CAAC;;;AD9BD,SAAS,QAAQ,CAAC,MAAoC;AAAA,EACrD,OAAO,OAAO,SAAS,WAAW,GAAG,KAAK,S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AG;AAAA,MACpC,IAAI,kBAAkB,SAAS,SAAS;AAAA,QAAG;AAAA,MAC3C,QAAQ,iBAAiB;AAAA,QACxB,QAAQ,EAAE,SAAS,UAAU,KAAK;AAAA,QAClC,QAAQ;AAAA,MACT,CAAC;AAAA;AAAA,EAEH;AACD,CAAC;;;AJXD,IAAM,QAAQ,CAAC,iBAAiB,qBAAqB,cAAc;AAE5D,IAAM,UAAU,aAAa;AAAA,EACnC;AAAA,EACA,UAAU;AAAA,IACT,aAAa;AAAA,MACZ,QAAQ,OAAO,YACd,MAAM,IAAI,GAAG,WAAW,CAAC,kBAAkB,QAAQ,IAAI,CAAC,CACzD;AAAA,IACD;AAAA,EACD;AACD,CAAC;;;AKVM,SAAS,WAAW,CAAC,SAAwB;AAAA,EAGnD,oBAAoB,OAAO;AAAA,EAC3B,qBAAqB,OAAO;AAAA,EAC5B,0BAA0B,OAAO;AAAA;AAG3B,IAAM,cAAc;AAAA,EAC1B,MAAM,EAAE,aAAa;AACtB;",
|
|
19
|
+
"debugId": "FB766460AB7EEFAD64756E2164756E21",
|
|
15
20
|
"names": []
|
|
16
21
|
}
|
package/dist/linter.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"linter.d.ts","sourceRoot":"","sources":["../src/linter.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,OAAO,+CASlB,CAAC"}
|
package/dist/operation-ids.d.ts
CHANGED
|
@@ -13,12 +13,21 @@ import { type OperationIdsOptions } from './resource';
|
|
|
13
13
|
* has no resource to name: `singular` and `plural` are an interface's.
|
|
14
14
|
*/
|
|
15
15
|
export declare function operationIds(context: DecoratorContext, target: Interface | Namespace, options?: OperationIdsOptions): void;
|
|
16
|
+
/** Marked itself, or in a marked namespace, however deep. */
|
|
17
|
+
export declare function isMarkedNamespace(program: Program, target: Namespace | undefined): boolean;
|
|
16
18
|
/**
|
|
17
19
|
* Whether `@operationIds` names the operation's id, or checks it: its
|
|
18
20
|
* interface or one of its namespaces is marked. An interface template's
|
|
19
21
|
* instance is never emitted; only the interfaces extending it are.
|
|
20
22
|
*/
|
|
21
23
|
export declare function isNamed(program: Program, operation: Operation): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Whether the emitter writes the operation: not an instance of an operation
|
|
26
|
+
* template, `Read<Pet>`, nor an operation of an interface template's
|
|
27
|
+
* instance. An interface extending an instance copies its operations, which
|
|
28
|
+
* are instances too, and emitted.
|
|
29
|
+
*/
|
|
30
|
+
export declare function isEmitted(operation: Operation): boolean;
|
|
22
31
|
/**
|
|
23
32
|
* Sets the ids, after every decorator, so the order of `@operationId` and
|
|
24
33
|
* `@operationIds` in the source does not matter. Two operations with one id
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation-ids.d.ts","sourceRoot":"","sources":["../src/operation-ids.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACN,KAAK,gBAAgB,EACrB,KAAK,SAAS,EAId,KAAK,SAAS,EAEd,KAAK,SAAS,EACd,KAAK,OAAO,EACZ,MAAM,oBAAoB,CAAC;AAO5B,OAAO,EAAQ,KAAK,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAE5D;;;;;GAKG;AACH,wBAAgB,YAAY,CAC3B,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,SAAS,GAAG,SAAS,EAC7B,OAAO,GAAE,mBAAwB,GAC/B,IAAI,CAaN;
|
|
1
|
+
{"version":3,"file":"operation-ids.d.ts","sourceRoot":"","sources":["../src/operation-ids.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACN,KAAK,gBAAgB,EACrB,KAAK,SAAS,EAId,KAAK,SAAS,EAEd,KAAK,SAAS,EACd,KAAK,OAAO,EACZ,MAAM,oBAAoB,CAAC;AAO5B,OAAO,EAAQ,KAAK,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAE5D;;;;;GAKG;AACH,wBAAgB,YAAY,CAC3B,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,SAAS,GAAG,SAAS,EAC7B,OAAO,GAAE,mBAAwB,GAC/B,IAAI,CAaN;AAED,6DAA6D;AAC7D,wBAAgB,iBAAiB,CAChC,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,SAAS,GAAG,SAAS,GAC3B,OAAO,CAKT;AAUD;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,GAAG,OAAO,CAUvE;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAIvD;AAoBD;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAqC3D"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const errorBodyShape: import("@typespec/compiler").LinterRuleDefinition<"error-body-shape", {
|
|
2
|
+
readonly default: import("@typespec/compiler").CallableMessage<["operation", "status"]>;
|
|
3
|
+
}, Record<string, never>>;
|
|
4
|
+
//# sourceMappingURL=error-body-shape.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-body-shape.d.ts","sourceRoot":"","sources":["../../src/rules/error-body-shape.ts"],"names":[],"mappings":"AA6BA,eAAO,MAAM,cAAc;;yBA+BzB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-returns-page.d.ts","sourceRoot":"","sources":["../../src/rules/list-returns-page.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,eAAe;;yBA6B1B,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const serviceOperationIds: import("@typespec/compiler").LinterRuleDefinition<"service-operation-ids", {
|
|
2
|
+
readonly default: import("@typespec/compiler").CallableMessage<["service"]>;
|
|
3
|
+
}, Record<string, never>>;
|
|
4
|
+
//# sourceMappingURL=service-operation-ids.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-operation-ids.d.ts","sourceRoot":"","sources":["../../src/rules/service-operation-ids.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,mBAAmB;;yBAmB9B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether the emitter writes an operation: not a template's declaration,
|
|
3
|
+
* nor its instance (`Read<Pet>`), nor an operation of an interface
|
|
4
|
+
* template's. Only the operations declared from them are checked.
|
|
5
|
+
*/
|
|
6
|
+
import { type Operation } from '@typespec/compiler';
|
|
7
|
+
export declare function isWritten(operation: Operation): boolean;
|
|
8
|
+
//# sourceMappingURL=written.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"written.d.ts","sourceRoot":"","sources":["../../src/rules/written.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAyB,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG3E,wBAAgB,SAAS,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAOvD"}
|
package/docs/README.md
CHANGED
|
@@ -4,6 +4,7 @@ The [package README](../README.md) is the short version.
|
|
|
4
4
|
|
|
5
5
|
| Page | Read it when |
|
|
6
6
|
| --- | --- |
|
|
7
|
+
| [Getting started](guide/getting-started.md) | starting a new API project from the `tsp init` template, up to a Hono route |
|
|
7
8
|
| [Error replies](guide/errors.md) | declaring what an operation answers when it fails |
|
|
8
9
|
| [Pagination](guide/pagination.md) | listing a collection a page at a time |
|
|
9
10
|
| [Authentication](guide/auth.md) | protecting an operation with a `@nxgt/janus` session |
|
|
@@ -11,5 +12,6 @@ The [package README](../README.md) is the short version.
|
|
|
11
12
|
| [Headers](guide/headers.md) | making a write idempotent, or declaring a rate limit |
|
|
12
13
|
| [Sorting](guide/sorting.md) | letting a client filter and sort a list |
|
|
13
14
|
| [Operation ids](guide/operation-ids.md) | naming each operation, and so the generated client's method: `list` in `Users` as `listUsers`, any other name as written |
|
|
15
|
+
| [Linter](guide/linter.md) | checking a spec against these conventions in `tsp compile`, or turning one rule off |
|
|
14
16
|
| [Troubleshooting](troubleshooting.md) | the compiler or the generator refused the spec |
|
|
15
17
|
| [Roadmap](roadmap.md) | wondering what is coming |
|