ddd-ts-kit 0.11.0 → 0.12.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.
Files changed (98) hide show
  1. package/README.md +8 -6
  2. package/dist/check/catalogue/eslint-only-rules.d.ts.map +1 -1
  3. package/dist/check/catalogue/eslint-only-rules.js +4 -0
  4. package/dist/check/catalogue/eslint-only-rules.js.map +1 -1
  5. package/dist/check/domain-events/refused-before-commit.js +1 -1
  6. package/dist/check/domain-events/refused-before-commit.js.map +1 -1
  7. package/dist/check/errors/kit-error-codes.d.ts.map +1 -1
  8. package/dist/check/errors/kit-error-codes.js +2 -0
  9. package/dist/check/errors/kit-error-codes.js.map +1 -1
  10. package/dist/check/explain/errors-docs.js +1 -1
  11. package/dist/check/explain/errors-docs.js.map +1 -1
  12. package/dist/check/explain/events-docs.js +1 -1
  13. package/dist/check/explain/events-docs.js.map +1 -1
  14. package/dist/check/fixtures/domain-events-fixtures.d.ts.map +1 -1
  15. package/dist/check/fixtures/domain-events-fixtures.js +18 -0
  16. package/dist/check/fixtures/domain-events-fixtures.js.map +1 -1
  17. package/dist/check/fixtures/standard-fixtures.d.ts.map +1 -1
  18. package/dist/check/fixtures/standard-fixtures.js +8 -0
  19. package/dist/check/fixtures/standard-fixtures.js.map +1 -1
  20. package/dist/check/rules/domain-events-transactional-before-commit.js +1 -1
  21. package/dist/check/rules/domain-events-transactional-before-commit.js.map +1 -1
  22. package/dist/check/standard/parallel-names.d.ts.map +1 -1
  23. package/dist/check/standard/parallel-names.js +6 -0
  24. package/dist/check/standard/parallel-names.js.map +1 -1
  25. package/dist/commands/generate.js +23 -19
  26. package/dist/commands/generate.js.map +1 -1
  27. package/dist/commands/init.d.ts.map +1 -1
  28. package/dist/commands/init.js +3 -0
  29. package/dist/commands/init.js.map +1 -1
  30. package/dist/config/index.d.ts +1 -1
  31. package/dist/config/index.d.ts.map +1 -1
  32. package/dist/config/index.js +1 -1
  33. package/dist/config/index.js.map +1 -1
  34. package/dist/config/parse-stack.d.ts.map +1 -1
  35. package/dist/config/parse-stack.js +2 -1
  36. package/dist/config/parse-stack.js.map +1 -1
  37. package/dist/config/stack.d.ts +7 -0
  38. package/dist/config/stack.d.ts.map +1 -1
  39. package/dist/config/stack.js +1 -0
  40. package/dist/config/stack.js.map +1 -1
  41. package/dist/generate/kind.d.ts +2 -0
  42. package/dist/generate/kind.d.ts.map +1 -1
  43. package/dist/generate/kinds/route/cache-policy-text.d.ts +8 -0
  44. package/dist/generate/kinds/route/cache-policy-text.d.ts.map +1 -0
  45. package/dist/generate/kinds/route/cache-policy-text.js +41 -0
  46. package/dist/generate/kinds/route/cache-policy-text.js.map +1 -0
  47. package/dist/generate/kinds/route/controller-plan.d.ts +2 -0
  48. package/dist/generate/kinds/route/controller-plan.d.ts.map +1 -1
  49. package/dist/generate/kinds/route/controller-vars.js +4 -1
  50. package/dist/generate/kinds/route/controller-vars.js.map +1 -1
  51. package/dist/generate/kinds/route/plan-controller.d.ts.map +1 -1
  52. package/dist/generate/kinds/route/plan-controller.js +4 -1
  53. package/dist/generate/kinds/route/plan-controller.js.map +1 -1
  54. package/dist/generate/kinds/route-kind.d.ts.map +1 -1
  55. package/dist/generate/kinds/route-kind.js +8 -1
  56. package/dist/generate/kinds/route-kind.js.map +1 -1
  57. package/dist/help/usage.d.ts +1 -1
  58. package/dist/help/usage.d.ts.map +1 -1
  59. package/dist/help/usage.js +2 -1
  60. package/dist/help/usage.js.map +1 -1
  61. package/dist/init/files/project-files.d.ts.map +1 -1
  62. package/dist/init/files/project-files.js +3 -1
  63. package/dist/init/files/project-files.js.map +1 -1
  64. package/dist/init/manifest/versions.js +24 -24
  65. package/dist/init/stack/resolve-stack.d.ts.map +1 -1
  66. package/dist/init/stack/resolve-stack.js +10 -1
  67. package/dist/init/stack/resolve-stack.js.map +1 -1
  68. package/dist/init/stack/stack-options.d.ts +2 -0
  69. package/dist/init/stack/stack-options.d.ts.map +1 -1
  70. package/dist/init/template-vars.js +4 -3
  71. package/dist/init/template-vars.js.map +1 -1
  72. package/dist/stack/stack-vars.js +8 -1
  73. package/dist/stack/stack-vars.js.map +1 -1
  74. package/dist/version.d.ts +1 -1
  75. package/dist/version.js +1 -1
  76. package/package.json +2 -2
  77. package/templates/controller/controller.class-validator.ts.tpl +3 -0
  78. package/templates/controller/controller.none.ts.tpl +3 -0
  79. package/templates/controller/controller.search.ts.tpl +3 -0
  80. package/templates/controller/controller.standard-schema.ts.tpl +3 -0
  81. package/templates/controller/controller.zod.ts.tpl +3 -0
  82. package/templates/docs/openapi.json.tpl +9 -0
  83. package/templates/init/docker/docker-compose.yml.tpl +20 -0
  84. package/templates/init/docker/env.example.tpl +10 -0
  85. package/templates/init/docker/varnish.vcl.tpl +74 -0
  86. package/templates/init/e2e/start-application.database.ts.tpl +28 -0
  87. package/templates/init/e2e/start-application.memory.ts.tpl +30 -0
  88. package/templates/init/e2e/test-environment.ts.tpl +5 -0
  89. package/templates/init/main.ts.tpl +13 -0
  90. package/templates/init/platform/auth/http-boundary.ts.tpl +29 -0
  91. package/templates/init/platform/compose-application.tsyringe.ts.tpl +13 -0
  92. package/templates/init/platform/config/app-config.ts.tpl +6 -0
  93. package/templates/init/platform/config/load-config.ts.tpl +12 -0
  94. package/templates/init/platform/create-platform.manual.ts.tpl +31 -0
  95. package/templates/init/platform/platform.manual.ts.tpl +7 -0
  96. package/templates/init/rules/presentation.md.tpl +2 -1
  97. package/templates/pipeline/package-scripts.json +1 -1
  98. package/templates/service/main.ts.tpl +13 -0
@@ -29,7 +29,8 @@ paths:
29
29
  {{/if}}
30
30
  - No role or ownership test in a controller or a route (`authz/in-application`): a guard of the group asks for a role at the edge, the bus asks for the permission, a policy decides on loaded state.
31
31
  - Request and response types are presentation types, one class or schema per file next to the controller (`*.body.ts`, `*.params.ts`, `*.answer.ts`...; `*.dto.ts` for function routes and under `shared/`): never an aggregate, never a row.
32
+ - A read declares how caches may keep its answer in `cache` (its controller, its route group, or the spec of a function route): `private` for what a caller reads again, with `etag`; `public` only for what is the same for everybody, with `tags` naming the resources it shows. A route that knows its caller is `no-store` unless it says otherwise, and a `public` answer of such a route is refused unless `vary` names who calls (`Authorization`, `Cookie`) or the header its tenant is read from (`presentation/shared-cache-varies`, then the mount): never cache a decision of authorization across actors. A group policy reaches the reads of the group only. A write that must not overwrite a newer version declares `ifMatch` and hands `context.expectedVersion` to its command; the handler calls `expectVersion` (412). A change purges the answers it makes stale from a `before-commit` handler of its domain event, `CacheInvalidation.invalidate([cacheTag(...)])` (`platform.cacheInvalidation` on a platform wired by hand): the purge then runs after the commit, through the outbox. Every event that changes what a kept answer shows, its version included, purges it, not only the one the route is about.
32
33
  - Never put the message of an unexpected failure in a response or a log.
33
34
  - Files: the canonical tree of `presentation/http/` (`naming/suffix`, `tree/closed`): a folder per controller, `*.routes.ts` for the groups, `guards/`, `shared/`; function routes stay flat (`*.route.ts`, `*.dto.ts`).
34
35
  - After a change, `npm run docs:generate` regenerates the contract, `openapi/openapi.yaml` (one file per document when `openapi.documents` of `ddd-ts-kit.config.json` splits it; JSON under `openapi.format: json`), committed with the route; CI fails on a difference. Never edit it by hand.{{#if sdk.on}} It regenerates the typed clients under `clients/` too (`npx ddd-ts-kit sdk`), committed with it.{{/if}}
35
- - Contract with `/ddd-ts-kit:document`. Create with `npx ddd-ts-kit generate route <context> <UseCase> --method <M> --path <p> [--group <Name>] [--mapper] [--serializer] --json`, then `generate e2e <context> <UseCase>`; `generate route-group` and `generate guard` write a group and a guard.
36
+ - Contract with `/ddd-ts-kit:document`. Create with `npx ddd-ts-kit generate route <context> <UseCase> --method <M> --path <p> [--group <Name>] [--mapper] [--serializer] [--cache public|private|no-store] --json`, then `generate e2e <context> <UseCase>`; `generate route-group` and `generate guard` write a group and a guard.
@@ -23,7 +23,7 @@
23
23
  "@biomejs/biome": "2.5.15",
24
24
  "@commitlint/cli": "^21.2.3",
25
25
  "@commitlint/config-conventional": "^21.2.3",
26
- "@ddd-ts-kit/eslint-plugin": "^0.11.0",
26
+ "@ddd-ts-kit/eslint-plugin": "^0.12.0",
27
27
  "@eslint/js": "^10.0.1",
28
28
  "@typescript/native": "npm:typescript@~7.0.2",
29
29
  "@vitest/coverage-v8": "5.0.3",
@@ -4,6 +4,10 @@ import { tracing } from '{{alias.platform}}/tracing{{alias.ext}}';
4
4
  // Imported second on purpose: a failure while the rest of the application loads is already reported.
5
5
  import { errors } from '{{alias.platform}}/errors{{alias.ext}}';
6
6
  {{/if}}
7
+ {{#if httpCache.varnish}}
8
+ import { VarnishCachePurger } from '@ddd-ts-kit/http/purgers';
9
+ import { PurgingPublisher } from '@ddd-ts-kit/kernel';
10
+ {{/if}}
7
11
  {{#if http.any}}
8
12
  import { createAuthenticator } from '{{alias.platform}}/auth/create-authenticator{{alias.ext}}';
9
13
  {{/if}}
@@ -67,7 +71,16 @@ await application.start();
67
71
  {{#if events.outbox}}
68
72
  const relay = startOutboxRelay({
69
73
  store: persistence.outbox,
74
+ {{#if httpCache.varnish}}
75
+ // The purge requests the use cases of the context wrote with their commands go to Varnish, every other event to the provider.
76
+ publisher: new PurgingPublisher(
77
+ new VarnishCachePurger({ url: config.varnishUrl, key: config.varnishPurgeKey }),
78
+ application.eventBus,
79
+ ),
80
+ {{/if}}
81
+ {{#unless httpCache.varnish}}
70
82
  publisher: application.eventBus,
83
+ {{/unless}}
71
84
  intervalMs: config.outboxRelayIntervalMs,
72
85
  logger: application.logger,
73
86
  {{#if errors.sentry}}