@ddd-ts-kit/http 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 (194) hide show
  1. package/README.md +204 -3
  2. package/dist/cache/assert-cache-declaration.d.ts +9 -0
  3. package/dist/cache/assert-cache-declaration.d.ts.map +1 -0
  4. package/dist/cache/assert-cache-declaration.js +82 -0
  5. package/dist/cache/assert-cache-declaration.js.map +1 -0
  6. package/dist/cache/cache-control-of.d.ts +4 -0
  7. package/dist/cache/cache-control-of.d.ts.map +1 -0
  8. package/dist/cache/cache-control-of.js +22 -0
  9. package/dist/cache/cache-control-of.js.map +1 -0
  10. package/dist/cache/cache-declaration.d.ts +14 -0
  11. package/dist/cache/cache-declaration.d.ts.map +1 -0
  12. package/dist/cache/cache-declaration.js +2 -0
  13. package/dist/cache/cache-declaration.js.map +1 -0
  14. package/dist/cache/cache-policy.d.ts +39 -0
  15. package/dist/cache/cache-policy.d.ts.map +1 -0
  16. package/dist/cache/cache-policy.js +2 -0
  17. package/dist/cache/cache-policy.js.map +1 -0
  18. package/dist/cache/cache-scope.d.ts +11 -0
  19. package/dist/cache/cache-scope.d.ts.map +1 -0
  20. package/dist/cache/cache-scope.js +10 -0
  21. package/dist/cache/cache-scope.js.map +1 -0
  22. package/dist/cache/cache-seconds.d.ts +4 -0
  23. package/dist/cache/cache-seconds.d.ts.map +1 -0
  24. package/dist/cache/cache-seconds.js +17 -0
  25. package/dist/cache/cache-seconds.js.map +1 -0
  26. package/dist/cache/cache-tag-header.d.ts +12 -0
  27. package/dist/cache/cache-tag-header.d.ts.map +1 -0
  28. package/dist/cache/cache-tag-header.js +11 -0
  29. package/dist/cache/cache-tag-header.js.map +1 -0
  30. package/dist/cache/cache-tag-source.d.ts +17 -0
  31. package/dist/cache/cache-tag-source.d.ts.map +1 -0
  32. package/dist/cache/cache-tag-source.js +2 -0
  33. package/dist/cache/cache-tag-source.js.map +1 -0
  34. package/dist/cache/entity-tag-source.d.ts +9 -0
  35. package/dist/cache/entity-tag-source.d.ts.map +1 -0
  36. package/dist/cache/entity-tag-source.js +2 -0
  37. package/dist/cache/entity-tag-source.js.map +1 -0
  38. package/dist/cache/if-match.d.ts +11 -0
  39. package/dist/cache/if-match.d.ts.map +1 -0
  40. package/dist/cache/if-match.js +10 -0
  41. package/dist/cache/if-match.js.map +1 -0
  42. package/dist/cache/vary-of.d.ts +3 -0
  43. package/dist/cache/vary-of.d.ts.map +1 -0
  44. package/dist/cache/vary-of.js +11 -0
  45. package/dist/cache/vary-of.js.map +1 -0
  46. package/dist/controller/controller-routes.d.ts.map +1 -1
  47. package/dist/controller/controller-routes.js +27 -10
  48. package/dist/controller/controller-routes.js.map +1 -1
  49. package/dist/controller/controller-spec.d.ts +6 -0
  50. package/dist/controller/controller-spec.d.ts.map +1 -1
  51. package/dist/controller/declared-route.d.ts +3 -0
  52. package/dist/controller/declared-route.d.ts.map +1 -1
  53. package/dist/controller/declared-route.js +9 -0
  54. package/dist/controller/declared-route.js.map +1 -1
  55. package/dist/controller/route-group-options.d.ts +6 -0
  56. package/dist/controller/route-group-options.d.ts.map +1 -1
  57. package/dist/error/default-error-mapping.d.ts.map +1 -1
  58. package/dist/error/default-error-mapping.js +2 -0
  59. package/dist/error/default-error-mapping.js.map +1 -1
  60. package/dist/error/precondition-required-error.d.ts +8 -0
  61. package/dist/error/precondition-required-error.d.ts.map +1 -0
  62. package/dist/error/precondition-required-error.js +8 -0
  63. package/dist/error/precondition-required-error.js.map +1 -0
  64. package/dist/express/mount-express.d.ts.map +1 -1
  65. package/dist/express/mount-express.js +2 -0
  66. package/dist/express/mount-express.js.map +1 -1
  67. package/dist/fastify/mount-fastify.d.ts.map +1 -1
  68. package/dist/fastify/mount-fastify.js +2 -0
  69. package/dist/fastify/mount-fastify.js.map +1 -1
  70. package/dist/index.d.ts +7 -0
  71. package/dist/index.d.ts.map +1 -1
  72. package/dist/index.js +4 -0
  73. package/dist/index.js.map +1 -1
  74. package/dist/openapi/cache-response-headers.d.ts +7 -0
  75. package/dist/openapi/cache-response-headers.d.ts.map +1 -0
  76. package/dist/openapi/cache-response-headers.js +35 -0
  77. package/dist/openapi/cache-response-headers.js.map +1 -0
  78. package/dist/openapi/cache-tags-extension.d.ts +9 -0
  79. package/dist/openapi/cache-tags-extension.d.ts.map +1 -0
  80. package/dist/openapi/cache-tags-extension.js +15 -0
  81. package/dist/openapi/cache-tags-extension.js.map +1 -0
  82. package/dist/openapi/conditional-parameters.d.ts +5 -0
  83. package/dist/openapi/conditional-parameters.d.ts.map +1 -0
  84. package/dist/openapi/conditional-parameters.js +26 -0
  85. package/dist/openapi/conditional-parameters.js.map +1 -0
  86. package/dist/openapi/path-items.d.ts.map +1 -1
  87. package/dist/openapi/path-items.js +4 -0
  88. package/dist/openapi/path-items.js.map +1 -1
  89. package/dist/openapi/responses.d.ts.map +1 -1
  90. package/dist/openapi/responses.js +23 -1
  91. package/dist/openapi/responses.js.map +1 -1
  92. package/dist/pipeline/assert-cached-routes.d.ts +11 -0
  93. package/dist/pipeline/assert-cached-routes.d.ts.map +1 -0
  94. package/dist/pipeline/assert-cached-routes.js +54 -0
  95. package/dist/pipeline/assert-cached-routes.js.map +1 -0
  96. package/dist/pipeline/cache-headers-of.d.ts +9 -0
  97. package/dist/pipeline/cache-headers-of.d.ts.map +1 -0
  98. package/dist/pipeline/cache-headers-of.js +24 -0
  99. package/dist/pipeline/cache-headers-of.js.map +1 -0
  100. package/dist/pipeline/cache-tags-of.d.ts +10 -0
  101. package/dist/pipeline/cache-tags-of.d.ts.map +1 -0
  102. package/dist/pipeline/cache-tags-of.js +20 -0
  103. package/dist/pipeline/cache-tags-of.js.map +1 -0
  104. package/dist/pipeline/conditional-answer.d.ts +10 -0
  105. package/dist/pipeline/conditional-answer.d.ts.map +1 -0
  106. package/dist/pipeline/conditional-answer.js +33 -0
  107. package/dist/pipeline/conditional-answer.js.map +1 -0
  108. package/dist/pipeline/entity-tag-of.d.ts +9 -0
  109. package/dist/pipeline/entity-tag-of.d.ts.map +1 -0
  110. package/dist/pipeline/entity-tag-of.js +25 -0
  111. package/dist/pipeline/entity-tag-of.js.map +1 -0
  112. package/dist/pipeline/execute-options.d.ts +23 -0
  113. package/dist/pipeline/execute-options.d.ts.map +1 -1
  114. package/dist/pipeline/execute-route.d.ts.map +1 -1
  115. package/dist/pipeline/execute-route.js +21 -2
  116. package/dist/pipeline/execute-route.js.map +1 -1
  117. package/dist/pipeline/expected-version-of.d.ts +10 -0
  118. package/dist/pipeline/expected-version-of.d.ts.map +1 -0
  119. package/dist/pipeline/expected-version-of.js +33 -0
  120. package/dist/pipeline/expected-version-of.js.map +1 -0
  121. package/dist/pipeline/is-not-modified.d.ts +8 -0
  122. package/dist/pipeline/is-not-modified.d.ts.map +1 -0
  123. package/dist/pipeline/is-not-modified.js +27 -0
  124. package/dist/pipeline/is-not-modified.js.map +1 -0
  125. package/dist/pipeline/last-modified-of.d.ts +3 -0
  126. package/dist/pipeline/last-modified-of.d.ts.map +1 -0
  127. package/dist/pipeline/last-modified-of.js +15 -0
  128. package/dist/pipeline/last-modified-of.js.map +1 -0
  129. package/dist/pipeline/tagged-answer.d.ts +19 -0
  130. package/dist/pipeline/tagged-answer.d.ts.map +1 -0
  131. package/dist/pipeline/tagged-answer.js +32 -0
  132. package/dist/pipeline/tagged-answer.js.map +1 -0
  133. package/dist/purgers/cache-purge-error.d.ts +11 -0
  134. package/dist/purgers/cache-purge-error.d.ts.map +1 -0
  135. package/dist/purgers/cache-purge-error.js +12 -0
  136. package/dist/purgers/cache-purge-error.js.map +1 -0
  137. package/dist/purgers/chunks-of.d.ts +3 -0
  138. package/dist/purgers/chunks-of.d.ts.map +1 -0
  139. package/dist/purgers/chunks-of.js +9 -0
  140. package/dist/purgers/chunks-of.js.map +1 -0
  141. package/dist/purgers/cloudflare-cache-purger.d.ts +20 -0
  142. package/dist/purgers/cloudflare-cache-purger.d.ts.map +1 -0
  143. package/dist/purgers/cloudflare-cache-purger.js +28 -0
  144. package/dist/purgers/cloudflare-cache-purger.js.map +1 -0
  145. package/dist/purgers/fastly-cache-purger.d.ts +19 -0
  146. package/dist/purgers/fastly-cache-purger.d.ts.map +1 -0
  147. package/dist/purgers/fastly-cache-purger.js +29 -0
  148. package/dist/purgers/fastly-cache-purger.js.map +1 -0
  149. package/dist/purgers/purge-request.d.ts +8 -0
  150. package/dist/purgers/purge-request.d.ts.map +1 -0
  151. package/dist/purgers/purge-request.js +2 -0
  152. package/dist/purgers/purge-request.js.map +1 -0
  153. package/dist/purgers/send-purge.d.ts +4 -0
  154. package/dist/purgers/send-purge.d.ts.map +1 -0
  155. package/dist/purgers/send-purge.js +19 -0
  156. package/dist/purgers/send-purge.js.map +1 -0
  157. package/dist/purgers/varnish-cache-purger.d.ts +27 -0
  158. package/dist/purgers/varnish-cache-purger.d.ts.map +1 -0
  159. package/dist/purgers/varnish-cache-purger.js +34 -0
  160. package/dist/purgers/varnish-cache-purger.js.map +1 -0
  161. package/dist/purgers/varnish-purge-mode.d.ts +13 -0
  162. package/dist/purgers/varnish-purge-mode.d.ts.map +1 -0
  163. package/dist/purgers/varnish-purge-mode.js +12 -0
  164. package/dist/purgers/varnish-purge-mode.js.map +1 -0
  165. package/dist/purgers.d.ts +6 -0
  166. package/dist/purgers.d.ts.map +1 -0
  167. package/dist/purgers.js +6 -0
  168. package/dist/purgers.js.map +1 -0
  169. package/dist/route/define-route.d.ts.map +1 -1
  170. package/dist/route/define-route.js +2 -0
  171. package/dist/route/define-route.js.map +1 -1
  172. package/dist/route/request-context.d.ts +2 -0
  173. package/dist/route/request-context.d.ts.map +1 -1
  174. package/dist/route/route-spec.d.ts +12 -0
  175. package/dist/route/route-spec.d.ts.map +1 -1
  176. package/dist/support/header-text.d.ts +3 -0
  177. package/dist/support/header-text.d.ts.map +1 -0
  178. package/dist/support/header-text.js +8 -0
  179. package/dist/support/header-text.js.map +1 -0
  180. package/dist/support/values-at.d.ts +6 -0
  181. package/dist/support/values-at.d.ts.map +1 -0
  182. package/dist/support/values-at.js +19 -0
  183. package/dist/support/values-at.js.map +1 -0
  184. package/dist/tenancy/first-tenant-of.d.ts +4 -1
  185. package/dist/tenancy/first-tenant-of.d.ts.map +1 -1
  186. package/dist/tenancy/first-tenant-of.js +7 -2
  187. package/dist/tenancy/first-tenant-of.js.map +1 -1
  188. package/dist/tenancy/tenant-from-header.d.ts +4 -1
  189. package/dist/tenancy/tenant-from-header.d.ts.map +1 -1
  190. package/dist/tenancy/tenant-from-header.js +6 -2
  191. package/dist/tenancy/tenant-from-header.js.map +1 -1
  192. package/dist/tenancy/tenant-resolver.d.ts +10 -1
  193. package/dist/tenancy/tenant-resolver.d.ts.map +1 -1
  194. package/package.json +8 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-not-modified.d.ts","sourceRoot":"","sources":["../../src/pipeline/is-not-modified.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAM1D;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,OAAO,CAWhH"}
@@ -0,0 +1,27 @@
1
+ import { headerText } from '../support/header-text.js';
2
+ const ANY = '*';
3
+ const WEAK = /^W\//;
4
+ /**
5
+ * Whether the version the caller holds is still the current one (RFC 9110, 13.2.2): `If-None-Match`
6
+ * names the `ETag` of the answer, compared weakly, or, when it is not sent, nothing changed since
7
+ * `If-Modified-Since`, to the second.
8
+ */
9
+ export function isNotModified(request, answered) {
10
+ const noneMatch = headerText(request['if-none-match']);
11
+ if (noneMatch !== undefined) {
12
+ return answered['etag'] !== undefined && namesTag(noneMatch, answered['etag']);
13
+ }
14
+ const since = Date.parse(headerText(request['if-modified-since']) ?? '');
15
+ const modified = Date.parse(answered['last-modified'] ?? '');
16
+ return Number.isFinite(since) && Number.isFinite(modified) && modified <= since;
17
+ }
18
+ function namesTag(list, tag) {
19
+ if (list.trim() === ANY) {
20
+ return true;
21
+ }
22
+ return list.split(',').some((written) => opaque(written.trim()) === opaque(tag));
23
+ }
24
+ function opaque(tag) {
25
+ return tag.replace(WEAK, '');
26
+ }
27
+ //# sourceMappingURL=is-not-modified.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-not-modified.js","sourceRoot":"","sources":["../../src/pipeline/is-not-modified.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEvD,MAAM,GAAG,GAAG,GAAG,CAAC;AAChB,MAAM,IAAI,GAAG,MAAM,CAAC;AAEpB;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,OAA6B,EAAE,QAA0C;IACrG,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC;IAEvD,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC5B,OAAO,QAAQ,CAAC,MAAM,CAAC,KAAK,SAAS,IAAI,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;IACjF,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IACzE,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC,CAAC;IAE7D,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,QAAQ,IAAI,KAAK,CAAC;AAClF,CAAC;AAED,SAAS,QAAQ,CAAC,IAAY,EAAE,GAAW;IACzC,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,GAAG,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;AACnF,CAAC;AAED,SAAS,MAAM,CAAC,GAAW;IACzB,OAAO,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AAC/B,CAAC"}
@@ -0,0 +1,3 @@
1
+ /** The `Last-Modified` of an answer, from the instant its body carries under `field`: a `Date` or ISO 8601 text. */
2
+ export declare function lastModifiedOf(field: string, body: unknown): string;
3
+ //# sourceMappingURL=last-modified-of.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"last-modified-of.d.ts","sourceRoot":"","sources":["../../src/pipeline/last-modified-of.ts"],"names":[],"mappings":"AAKA,oHAAoH;AACpH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,CAanE"}
@@ -0,0 +1,15 @@
1
+ import { ResponseContractError } from '../error/response-contract-error.js';
2
+ import { valuesAt } from '../support/values-at.js';
3
+ const ISO_INSTANT = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:\d{2})$/;
4
+ /** The `Last-Modified` of an answer, from the instant its body carries under `field`: a `Date` or ISO 8601 text. */
5
+ export function lastModifiedOf(field, body) {
6
+ const [written] = valuesAt(body, field);
7
+ const instant = written instanceof Date || (typeof written === 'string' && ISO_INSTANT.test(written))
8
+ ? new Date(written)
9
+ : undefined;
10
+ if (instant === undefined || Number.isNaN(instant.getTime())) {
11
+ throw new ResponseContractError(`The answer carries no instant under "${field}" for its Last-Modified.`);
12
+ }
13
+ return instant.toUTCString();
14
+ }
15
+ //# sourceMappingURL=last-modified-of.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"last-modified-of.js","sourceRoot":"","sources":["../../src/pipeline/last-modified-of.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAEnD,MAAM,WAAW,GAAG,qEAAqE,CAAC;AAE1F,oHAAoH;AACpH,MAAM,UAAU,cAAc,CAAC,KAAa,EAAE,IAAa;IACzD,MAAM,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAExC,MAAM,OAAO,GACX,OAAO,YAAY,IAAI,IAAI,CAAC,OAAO,OAAO,KAAK,QAAQ,IAAI,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACnF,CAAC,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC;QACnB,CAAC,CAAC,SAAS,CAAC;IAEhB,IAAI,OAAO,KAAK,SAAS,IAAI,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;QAC7D,MAAM,IAAI,qBAAqB,CAAC,wCAAwC,KAAK,0BAA0B,CAAC,CAAC;IAC3G,CAAC;IAED,OAAO,OAAO,CAAC,WAAW,EAAE,CAAC;AAC/B,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { CacheTagHeader } from '../cache/cache-tag-header.js';
2
+ import type { Route } from '../route/route.js';
3
+ import { type TaggedParts } from './cache-tags-of.js';
4
+ import type { RouteResponse } from './route-response.js';
5
+ /** What tags an answer: the route, the header of the shared cache, and what the tags are read from. */
6
+ export interface Tagging extends Omit<TaggedParts, 'body'> {
7
+ readonly route: Pick<Route, 'cache'>;
8
+ readonly header: CacheTagHeader | undefined;
9
+ /** Whether the tags are filed under the tenant of the request (`cacheTags.perTenant`). */
10
+ readonly perTenant: boolean;
11
+ }
12
+ /**
13
+ * A successful public answer that declares the resources it shows carries their tags, in the
14
+ * header the shared cache of the application reads them from. Nothing when the application names
15
+ * no header: a private or uncached answer never reaches a shared cache. When the tags are filed
16
+ * per tenant and the request names none, no purge could ever meet the answer: nobody keeps it.
17
+ */
18
+ export declare function taggedAnswer(response: RouteResponse, tagging: Tagging): RouteResponse;
19
+ //# sourceMappingURL=tagged-answer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tagged-answer.d.ts","sourceRoot":"","sources":["../../src/pipeline/tagged-answer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,uGAAuG;AACvG,MAAM,WAAW,OAAQ,SAAQ,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC;IACxD,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACrC,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,SAAS,CAAC;IAC5C,0FAA0F;IAC1F,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC7B;AAMD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO,GAAG,aAAa,CAqBrF"}
@@ -0,0 +1,32 @@
1
+ import { CacheScope } from '../cache/cache-scope.js';
2
+ import { CacheTagHeader } from '../cache/cache-tag-header.js';
3
+ import { cacheTagsOf } from './cache-tags-of.js';
4
+ const SUCCESS_FROM = 200;
5
+ const SUCCESS_TO = 299;
6
+ const COMMA_SEPARATED = [CacheTagHeader.cacheTag, CacheTagHeader.cdnTag];
7
+ /**
8
+ * A successful public answer that declares the resources it shows carries their tags, in the
9
+ * header the shared cache of the application reads them from. Nothing when the application names
10
+ * no header: a private or uncached answer never reaches a shared cache. When the tags are filed
11
+ * per tenant and the request names none, no purge could ever meet the answer: nobody keeps it.
12
+ */
13
+ export function taggedAnswer(response, tagging) {
14
+ const { route, header, perTenant, ...parts } = tagging;
15
+ const { cache } = route;
16
+ if (header === undefined || cache?.scope !== CacheScope.public || cache.tags === undefined || !succeeded(response)) {
17
+ return response;
18
+ }
19
+ if (perTenant && parts.tenantId === undefined) {
20
+ return { ...response, headers: { ...response.headers, 'cache-control': CacheScope.noStore } };
21
+ }
22
+ const tags = cacheTagsOf(cache.tags, { ...parts, body: response.body });
23
+ if (tags.length === 0) {
24
+ return response;
25
+ }
26
+ const separator = COMMA_SEPARATED.includes(header) ? ',' : ' ';
27
+ return { ...response, headers: { [header]: tags.join(separator), ...response.headers } };
28
+ }
29
+ function succeeded({ status }) {
30
+ return status >= SUCCESS_FROM && status <= SUCCESS_TO;
31
+ }
32
+ //# sourceMappingURL=tagged-answer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tagged-answer.js","sourceRoot":"","sources":["../../src/pipeline/tagged-answer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,OAAO,EAAE,WAAW,EAAoB,MAAM,oBAAoB,CAAC;AAWnE,MAAM,YAAY,GAAG,GAAG,CAAC;AACzB,MAAM,UAAU,GAAG,GAAG,CAAC;AACvB,MAAM,eAAe,GAA8B,CAAC,cAAc,CAAC,QAAQ,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;AAEpG;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,QAAuB,EAAE,OAAgB;IACpE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,GAAG,OAAO,CAAC;IACvD,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC;IAExB,IAAI,MAAM,KAAK,SAAS,IAAI,KAAK,EAAE,KAAK,KAAK,UAAU,CAAC,MAAM,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC;QACnH,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,IAAI,SAAS,IAAI,KAAK,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC9C,OAAO,EAAE,GAAG,QAAQ,EAAE,OAAO,EAAE,EAAE,GAAG,QAAQ,CAAC,OAAO,EAAE,eAAe,EAAE,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC;IAChG,CAAC;IAED,MAAM,IAAI,GAAG,WAAW,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IAExE,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,MAAM,SAAS,GAAG,eAAe,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;IAE/D,OAAO,EAAE,GAAG,QAAQ,EAAE,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC;AAC3F,CAAC;AAED,SAAS,SAAS,CAAC,EAAE,MAAM,EAAiB;IAC1C,OAAO,MAAM,IAAI,YAAY,IAAI,MAAM,IAAI,UAAU,CAAC;AACxD,CAAC"}
@@ -0,0 +1,11 @@
1
+ /** A shared cache that did not confirm a purge: unreachable, too slow, or answering a failure. The relay retries the request. */
2
+ export declare class CachePurgeError extends Error {
3
+ /** The status the cache answered; absent when it answered nothing. */
4
+ readonly status?: number | undefined;
5
+ constructor(message: string,
6
+ /** The status the cache answered; absent when it answered nothing. */
7
+ status?: number | undefined, options?: {
8
+ readonly cause?: unknown;
9
+ });
10
+ }
11
+ //# sourceMappingURL=cache-purge-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache-purge-error.d.ts","sourceRoot":"","sources":["../../src/purgers/cache-purge-error.ts"],"names":[],"mappings":"AAAA,iIAAiI;AACjI,qBAAa,eAAgB,SAAQ,KAAK;IAGtC,sEAAsE;IACtE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM;IAH1B,YACE,OAAO,EAAE,MAAM;IACf,sEAAsE;IAC7D,MAAM,CAAC,EAAE,MAAM,YAAA,EACxB,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,EAIvC;CACF"}
@@ -0,0 +1,12 @@
1
+ /** A shared cache that did not confirm a purge: unreachable, too slow, or answering a failure. The relay retries the request. */
2
+ export class CachePurgeError extends Error {
3
+ status;
4
+ constructor(message,
5
+ /** The status the cache answered; absent when it answered nothing. */
6
+ status, options) {
7
+ super(message, options);
8
+ this.status = status;
9
+ this.name = 'CachePurgeError';
10
+ }
11
+ }
12
+ //# sourceMappingURL=cache-purge-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache-purge-error.js","sourceRoot":"","sources":["../../src/purgers/cache-purge-error.ts"],"names":[],"mappings":"AAAA,iIAAiI;AACjI,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAI7B,MAAM;IAHjB,YACE,OAAe;IACf,sEAAsE;IAC7D,MAAe,EACxB,OAAsC;QAEtC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;sBAHf,MAAM;QAIf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF"}
@@ -0,0 +1,3 @@
1
+ /** The tags in groups of at most `size`, for caches that bound the tags of one request. */
2
+ export declare function chunksOf(tags: readonly string[], size: number): string[][];
3
+ //# sourceMappingURL=chunks-of.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunks-of.d.ts","sourceRoot":"","sources":["../../src/purgers/chunks-of.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,wBAAgB,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,CAQ1E"}
@@ -0,0 +1,9 @@
1
+ /** The tags in groups of at most `size`, for caches that bound the tags of one request. */
2
+ export function chunksOf(tags, size) {
3
+ const chunks = [];
4
+ for (let start = 0; start < tags.length; start += size) {
5
+ chunks.push(tags.slice(start, start + size));
6
+ }
7
+ return chunks;
8
+ }
9
+ //# sourceMappingURL=chunks-of.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunks-of.js","sourceRoot":"","sources":["../../src/purgers/chunks-of.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,MAAM,UAAU,QAAQ,CAAC,IAAuB,EAAE,IAAY;IAC5D,MAAM,MAAM,GAAe,EAAE,CAAC;IAE9B,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,KAAK,IAAI,IAAI,EAAE,CAAC;QACvD,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC;IAC/C,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { CachePurger } from '@ddd-ts-kit/kernel';
2
+ export interface CloudflareCachePurgerOptions {
3
+ readonly zoneId: string;
4
+ /** An API token with the `Cache Purge` permission on the zone. */
5
+ readonly token: string;
6
+ /** Default `https://api.cloudflare.com/client/v4`. */
7
+ readonly endpoint?: string;
8
+ /** Default 5000. */
9
+ readonly timeoutMs?: number;
10
+ }
11
+ /**
12
+ * Purges the cache tags of a Cloudflare zone through its API, on every plan; answers carry them
13
+ * in `Cache-Tag`. The account is held to a rate of purge requests (5 a minute on the free plan).
14
+ */
15
+ export declare class CloudflareCachePurger implements CachePurger {
16
+ private readonly options;
17
+ constructor(options: CloudflareCachePurgerOptions);
18
+ purge(tags: readonly string[]): Promise<void>;
19
+ }
20
+ //# sourceMappingURL=cloudflare-cache-purger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cloudflare-cache-purger.d.ts","sourceRoot":"","sources":["../../src/purgers/cloudflare-cache-purger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAItD,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,kEAAkE;IAClE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,sDAAsD;IACtD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,oBAAoB;IACpB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAOD;;;GAGG;AACH,qBAAa,qBAAsB,YAAW,WAAW;IAC3C,OAAO,CAAC,QAAQ,CAAC,OAAO;IAApC,YAA6B,OAAO,EAAE,4BAA4B,EAAI;IAEhE,KAAK,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAclD;CACF"}
@@ -0,0 +1,28 @@
1
+ import { chunksOf } from './chunks-of.js';
2
+ import { sendPurge } from './send-purge.js';
3
+ const DEFAULT_ENDPOINT = 'https://api.cloudflare.com/client/v4';
4
+ const DEFAULT_TIMEOUT_MS = 5_000;
5
+ // The documented bound of one purge request, on every plan: 100 operations.
6
+ const TAGS_PER_REQUEST = 100;
7
+ /**
8
+ * Purges the cache tags of a Cloudflare zone through its API, on every plan; answers carry them
9
+ * in `Cache-Tag`. The account is held to a rate of purge requests (5 a minute on the free plan).
10
+ */
11
+ export class CloudflareCachePurger {
12
+ options;
13
+ constructor(options) {
14
+ this.options = options;
15
+ }
16
+ async purge(tags) {
17
+ const { zoneId, token, endpoint = DEFAULT_ENDPOINT, timeoutMs = DEFAULT_TIMEOUT_MS } = this.options;
18
+ for (const chunk of chunksOf(tags, TAGS_PER_REQUEST)) {
19
+ await sendPurge({
20
+ url: `${endpoint}/zones/${encodeURIComponent(zoneId)}/purge_cache`,
21
+ method: 'POST',
22
+ headers: { authorization: `Bearer ${token}`, 'content-type': 'application/json' },
23
+ body: JSON.stringify({ tags: chunk }),
24
+ }, timeoutMs);
25
+ }
26
+ }
27
+ }
28
+ //# sourceMappingURL=cloudflare-cache-purger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cloudflare-cache-purger.js","sourceRoot":"","sources":["../../src/purgers/cloudflare-cache-purger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAY5C,MAAM,gBAAgB,GAAG,sCAAsC,CAAC;AAChE,MAAM,kBAAkB,GAAG,KAAK,CAAC;AACjC,4EAA4E;AAC5E,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAE7B;;;GAGG;AACH,MAAM,OAAO,qBAAqB;IACH,OAAO;IAApC,YAA6B,OAAqC;uBAArC,OAAO;IAAiC,CAAC;IAEtE,KAAK,CAAC,KAAK,CAAC,IAAuB;QACjC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,GAAG,gBAAgB,EAAE,SAAS,GAAG,kBAAkB,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;QAEpG,KAAK,MAAM,KAAK,IAAI,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC,EAAE,CAAC;YACrD,MAAM,SAAS,CACb;gBACE,GAAG,EAAE,GAAG,QAAQ,UAAU,kBAAkB,CAAC,MAAM,CAAC,cAAc;gBAClE,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE,EAAE,aAAa,EAAE,UAAU,KAAK,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;gBACjF,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;aACtC,EACD,SAAS,CACV,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,19 @@
1
+ import type { CachePurger } from '@ddd-ts-kit/kernel';
2
+ export interface FastlyCachePurgerOptions {
3
+ readonly serviceId: string;
4
+ /** An API token allowed to purge the service (`purge_select` scope). */
5
+ readonly token: string;
6
+ /** Marks the answers stale instead of removing them (`Fastly-Soft-Purge`). */
7
+ readonly soft?: boolean;
8
+ /** Default `https://api.fastly.com`. */
9
+ readonly endpoint?: string;
10
+ /** Default 5000. */
11
+ readonly timeoutMs?: number;
12
+ }
13
+ /** Purges the surrogate keys of a Fastly service through its API; answers carry them in `Surrogate-Key`. */
14
+ export declare class FastlyCachePurger implements CachePurger {
15
+ private readonly options;
16
+ constructor(options: FastlyCachePurgerOptions);
17
+ purge(tags: readonly string[]): Promise<void>;
18
+ }
19
+ //# sourceMappingURL=fastly-cache-purger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fastly-cache-purger.d.ts","sourceRoot":"","sources":["../../src/purgers/fastly-cache-purger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAItD,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,wEAAwE;IACxE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,8EAA8E;IAC9E,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IACxB,wCAAwC;IACxC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,oBAAoB;IACpB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAOD,4GAA4G;AAC5G,qBAAa,iBAAkB,YAAW,WAAW;IACvC,OAAO,CAAC,QAAQ,CAAC,OAAO;IAApC,YAA6B,OAAO,EAAE,wBAAwB,EAAI;IAE5D,KAAK,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBlD;CACF"}
@@ -0,0 +1,29 @@
1
+ import { chunksOf } from './chunks-of.js';
2
+ import { sendPurge } from './send-purge.js';
3
+ const DEFAULT_ENDPOINT = 'https://api.fastly.com';
4
+ const DEFAULT_TIMEOUT_MS = 5_000;
5
+ // The documented bound of one purge request: 256 surrogate keys.
6
+ const KEYS_PER_REQUEST = 256;
7
+ /** Purges the surrogate keys of a Fastly service through its API; answers carry them in `Surrogate-Key`. */
8
+ export class FastlyCachePurger {
9
+ options;
10
+ constructor(options) {
11
+ this.options = options;
12
+ }
13
+ async purge(tags) {
14
+ const { serviceId, token, soft, endpoint = DEFAULT_ENDPOINT, timeoutMs = DEFAULT_TIMEOUT_MS } = this.options;
15
+ for (const chunk of chunksOf(tags, KEYS_PER_REQUEST)) {
16
+ await sendPurge({
17
+ url: `${endpoint}/service/${encodeURIComponent(serviceId)}/purge`,
18
+ method: 'POST',
19
+ headers: {
20
+ 'fastly-key': token,
21
+ 'content-type': 'application/json',
22
+ ...(soft === true ? { 'fastly-soft-purge': '1' } : {}),
23
+ },
24
+ body: JSON.stringify({ surrogate_keys: chunk }),
25
+ }, timeoutMs);
26
+ }
27
+ }
28
+ }
29
+ //# sourceMappingURL=fastly-cache-purger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fastly-cache-purger.js","sourceRoot":"","sources":["../../src/purgers/fastly-cache-purger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAc5C,MAAM,gBAAgB,GAAG,wBAAwB,CAAC;AAClD,MAAM,kBAAkB,GAAG,KAAK,CAAC;AACjC,iEAAiE;AACjE,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAE7B,4GAA4G;AAC5G,MAAM,OAAO,iBAAiB;IACC,OAAO;IAApC,YAA6B,OAAiC;uBAAjC,OAAO;IAA6B,CAAC;IAElE,KAAK,CAAC,KAAK,CAAC,IAAuB;QACjC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,GAAG,gBAAgB,EAAE,SAAS,GAAG,kBAAkB,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;QAE7G,KAAK,MAAM,KAAK,IAAI,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC,EAAE,CAAC;YACrD,MAAM,SAAS,CACb;gBACE,GAAG,EAAE,GAAG,QAAQ,YAAY,kBAAkB,CAAC,SAAS,CAAC,QAAQ;gBACjE,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE;oBACP,YAAY,EAAE,KAAK;oBACnB,cAAc,EAAE,kBAAkB;oBAClC,GAAG,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,mBAAmB,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;iBACvD;gBACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC;aAChD,EACD,SAAS,CACV,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,8 @@
1
+ /** One HTTP request that purges, as a purger builds it. */
2
+ export interface PurgeRequest {
3
+ readonly url: string;
4
+ readonly method: string;
5
+ readonly headers: Readonly<Record<string, string>>;
6
+ readonly body?: string;
7
+ }
8
+ //# sourceMappingURL=purge-request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"purge-request.d.ts","sourceRoot":"","sources":["../../src/purgers/purge-request.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACnD,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=purge-request.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"purge-request.js","sourceRoot":"","sources":["../../src/purgers/purge-request.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ import type { PurgeRequest } from './purge-request.js';
2
+ /** Sends a purge and resolves once the cache confirmed it with a 2xx; anything else is a `CachePurgeError`. */
3
+ export declare function sendPurge(request: PurgeRequest, timeoutMs: number): Promise<void>;
4
+ //# sourceMappingURL=send-purge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"send-purge.d.ts","sourceRoot":"","sources":["../../src/purgers/send-purge.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAKvD,+GAA+G;AAC/G,wBAAsB,SAAS,CAAC,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAevF"}
@@ -0,0 +1,19 @@
1
+ import { CachePurgeError } from './cache-purge-error.js';
2
+ const SUCCESS_FROM = 200;
3
+ const SUCCESS_TO = 299;
4
+ /** Sends a purge and resolves once the cache confirmed it with a 2xx; anything else is a `CachePurgeError`. */
5
+ export async function sendPurge(request, timeoutMs) {
6
+ const answer = await fetch(request.url, {
7
+ method: request.method,
8
+ headers: request.headers,
9
+ ...(request.body === undefined ? {} : { body: request.body }),
10
+ signal: AbortSignal.timeout(timeoutMs),
11
+ }).catch((cause) => {
12
+ throw new CachePurgeError(`${request.method} ${request.url} reached no cache.`, undefined, { cause });
13
+ });
14
+ await answer.body?.cancel();
15
+ if (answer.status < SUCCESS_FROM || answer.status > SUCCESS_TO) {
16
+ throw new CachePurgeError(`${request.method} ${request.url} answered ${answer.status}.`, answer.status);
17
+ }
18
+ }
19
+ //# sourceMappingURL=send-purge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"send-purge.js","sourceRoot":"","sources":["../../src/purgers/send-purge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAGzD,MAAM,YAAY,GAAG,GAAG,CAAC;AACzB,MAAM,UAAU,GAAG,GAAG,CAAC;AAEvB,+GAA+G;AAC/G,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,OAAqB,EAAE,SAAiB;IACtE,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QACtC,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,GAAG,CAAC,OAAO,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC;QAC7D,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,SAAS,CAAC;KACvC,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;QAC1B,MAAM,IAAI,eAAe,CAAC,GAAG,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,GAAG,oBAAoB,EAAE,SAAS,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IACxG,CAAC,CAAC,CAAC;IAEH,MAAM,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC;IAE5B,IAAI,MAAM,CAAC,MAAM,GAAG,YAAY,IAAI,MAAM,CAAC,MAAM,GAAG,UAAU,EAAE,CAAC;QAC/D,MAAM,IAAI,eAAe,CAAC,GAAG,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,GAAG,aAAa,MAAM,CAAC,MAAM,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC1G,CAAC;AACH,CAAC"}
@@ -0,0 +1,27 @@
1
+ import type { CachePurger } from '@ddd-ts-kit/kernel';
2
+ import { VarnishPurgeMode } from './varnish-purge-mode.js';
3
+ export interface VarnishCachePurgerOptions {
4
+ /** Varnish as the application reaches it, `http://varnish:80`. */
5
+ readonly url: string;
6
+ /**
7
+ * The key Varnish was started with (`VARNISH_PURGE_KEY`), sent in `x-purge-key`: the VCL lets
8
+ * a request purge from another address than its own machine only with it.
9
+ */
10
+ readonly key?: string;
11
+ /** `xkey` by default. */
12
+ readonly mode?: VarnishPurgeMode;
13
+ /** With xkey, marks the answers stale instead of removing them: served within their grace while the application answers again. */
14
+ readonly soft?: boolean;
15
+ /** How long a purge may take before it counts as failed. Default 5000. */
16
+ readonly timeoutMs?: number;
17
+ }
18
+ /** Purges Varnish over HTTP, through the VCL `ddd-ts-kit init --http-cache varnish` writes. */
19
+ export declare class VarnishCachePurger implements CachePurger {
20
+ private readonly options;
21
+ private readonly timeoutMs;
22
+ private readonly authorization;
23
+ constructor(options: VarnishCachePurgerOptions);
24
+ purge(tags: readonly string[]): Promise<void>;
25
+ private send;
26
+ }
27
+ //# sourceMappingURL=varnish-cache-purger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"varnish-cache-purger.d.ts","sourceRoot":"","sources":["../../src/purgers/varnish-cache-purger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,MAAM,WAAW,yBAAyB;IACxC,kEAAkE;IAClE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,yBAAyB;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACjC,kIAAkI;IAClI,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IACxB,0EAA0E;IAC1E,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAOD,+FAA+F;AAC/F,qBAAa,kBAAmB,YAAW,WAAW;IAIxC,OAAO,CAAC,QAAQ,CAAC,OAAO;IAHpC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAmC;IAEjE,YAA6B,OAAO,EAAE,yBAAyB,EAG9D;IAEK,KAAK,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAalD;YAEa,IAAI;CAMnB"}
@@ -0,0 +1,34 @@
1
+ import { chunksOf } from './chunks-of.js';
2
+ import { sendPurge } from './send-purge.js';
3
+ import { VarnishPurgeMode } from './varnish-purge-mode.js';
4
+ const DEFAULT_TIMEOUT_MS = 5_000;
5
+ // Varnish bounds a request header at 8 KB by default (http_req_hdr_len): 100 tags stay well below.
6
+ const TAGS_PER_REQUEST = 100;
7
+ const REGEX_SPECIAL = /[.*+?^${}()|[\]\\]/g;
8
+ /** Purges Varnish over HTTP, through the VCL `ddd-ts-kit init --http-cache varnish` writes. */
9
+ export class VarnishCachePurger {
10
+ options;
11
+ timeoutMs;
12
+ authorization;
13
+ constructor(options) {
14
+ this.options = options;
15
+ this.timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
16
+ this.authorization = options.key === undefined ? {} : { 'x-purge-key': options.key };
17
+ }
18
+ async purge(tags) {
19
+ if ((this.options.mode ?? VarnishPurgeMode.xkey) === VarnishPurgeMode.ban) {
20
+ for (const tag of tags) {
21
+ // The VCL writes the tag into a regular expression: its special characters stand for themselves.
22
+ await this.send({ 'x-ban-tag': tag.replace(REGEX_SPECIAL, '\\$&') });
23
+ }
24
+ return;
25
+ }
26
+ for (const chunk of chunksOf(tags, TAGS_PER_REQUEST)) {
27
+ await this.send({ [this.options.soft === true ? 'xkey-softpurge' : 'xkey-purge']: chunk.join(' ') });
28
+ }
29
+ }
30
+ async send(headers) {
31
+ await sendPurge({ url: this.options.url, method: 'PURGE', headers: { ...this.authorization, ...headers } }, this.timeoutMs);
32
+ }
33
+ }
34
+ //# sourceMappingURL=varnish-cache-purger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"varnish-cache-purger.js","sourceRoot":"","sources":["../../src/purgers/varnish-cache-purger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAkB3D,MAAM,kBAAkB,GAAG,KAAK,CAAC;AACjC,mGAAmG;AACnG,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAC7B,MAAM,aAAa,GAAG,qBAAqB,CAAC;AAE5C,+FAA+F;AAC/F,MAAM,OAAO,kBAAkB;IAIA,OAAO;IAHnB,SAAS,CAAS;IAClB,aAAa,CAAmC;IAEjE,YAA6B,OAAkC;uBAAlC,OAAO;QAClC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,kBAAkB,CAAC;QACzD,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC;IACvF,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,IAAuB;QACjC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,gBAAgB,CAAC,IAAI,CAAC,KAAK,gBAAgB,CAAC,GAAG,EAAE,CAAC;YAC1E,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;gBACvB,iGAAiG;gBACjG,MAAM,IAAI,CAAC,IAAI,CAAC,EAAE,WAAW,EAAE,GAAG,CAAC,OAAO,CAAC,aAAa,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;YACvE,CAAC;YAED,OAAO;QACT,CAAC;QAED,KAAK,MAAM,KAAK,IAAI,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC,EAAE,CAAC;YACrD,MAAM,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,YAAY,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACvG,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,IAAI,CAAC,OAAyC;QAC1D,MAAM,SAAS,CACb,EAAE,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,aAAa,EAAE,GAAG,OAAO,EAAE,EAAE,EAC1F,IAAI,CAAC,SAAS,CACf,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * How Varnish is asked to purge: `xkey`, a `PURGE` with the `xkey-purge` header, which vmod_xkey
3
+ * turns into a removal of every object filed under one of the tags, at once; `ban`, a `PURGE` per
4
+ * tag with the `x-ban-tag` header, which the VCL turns into a ban on the `xkey` header the
5
+ * objects keep, applied lazily as they are looked up (for a Varnish without vmod_xkey, with its
6
+ * own VCL).
7
+ */
8
+ export declare const VarnishPurgeMode: {
9
+ readonly xkey: 'xkey';
10
+ readonly ban: 'ban';
11
+ };
12
+ export type VarnishPurgeMode = (typeof VarnishPurgeMode)[keyof typeof VarnishPurgeMode];
13
+ //# sourceMappingURL=varnish-purge-mode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"varnish-purge-mode.d.ts","sourceRoot":"","sources":["../../src/purgers/varnish-purge-mode.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB;aAC3B,IAAI,EAAE,MAAM;aACZ,GAAG,EAAE,KAAK;CACF,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,OAAO,gBAAgB,CAAC,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * How Varnish is asked to purge: `xkey`, a `PURGE` with the `xkey-purge` header, which vmod_xkey
3
+ * turns into a removal of every object filed under one of the tags, at once; `ban`, a `PURGE` per
4
+ * tag with the `x-ban-tag` header, which the VCL turns into a ban on the `xkey` header the
5
+ * objects keep, applied lazily as they are looked up (for a Varnish without vmod_xkey, with its
6
+ * own VCL).
7
+ */
8
+ export const VarnishPurgeMode = {
9
+ xkey: 'xkey',
10
+ ban: 'ban',
11
+ };
12
+ //# sourceMappingURL=varnish-purge-mode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"varnish-purge-mode.js","sourceRoot":"","sources":["../../src/purgers/varnish-purge-mode.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,KAAK;CACF,CAAC"}
@@ -0,0 +1,6 @@
1
+ export { CachePurgeError } from './purgers/cache-purge-error.js';
2
+ export { CloudflareCachePurger, type CloudflareCachePurgerOptions } from './purgers/cloudflare-cache-purger.js';
3
+ export { FastlyCachePurger, type FastlyCachePurgerOptions } from './purgers/fastly-cache-purger.js';
4
+ export { VarnishCachePurger, type VarnishCachePurgerOptions } from './purgers/varnish-cache-purger.js';
5
+ export { VarnishPurgeMode } from './purgers/varnish-purge-mode.js';
6
+ //# sourceMappingURL=purgers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"purgers.d.ts","sourceRoot":"","sources":["../src/purgers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,KAAK,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AAChH,OAAO,EAAE,iBAAiB,EAAE,KAAK,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AACpG,OAAO,EAAE,kBAAkB,EAAE,KAAK,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AACvG,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC"}
@@ -0,0 +1,6 @@
1
+ export { CachePurgeError } from './purgers/cache-purge-error.js';
2
+ export { CloudflareCachePurger } from './purgers/cloudflare-cache-purger.js';
3
+ export { FastlyCachePurger } from './purgers/fastly-cache-purger.js';
4
+ export { VarnishCachePurger } from './purgers/varnish-cache-purger.js';
5
+ export { VarnishPurgeMode } from './purgers/varnish-purge-mode.js';
6
+ //# sourceMappingURL=purgers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"purgers.js","sourceRoot":"","sources":["../src/purgers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAqC,MAAM,sCAAsC,CAAC;AAChH,OAAO,EAAE,iBAAiB,EAAiC,MAAM,kCAAkC,CAAC;AACpG,OAAO,EAAE,kBAAkB,EAAkC,MAAM,mCAAmC,CAAC;AACvG,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"define-route.d.ts","sourceRoot":"","sources":["../../src/route/define-route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,wBAAgB,WAAW,CAAC,KAAK,CAAC,OAAO,SAAS,cAAc,EAAE,KAAK,CAAC,SAAS,SAAS,aAAa,EACrG,IAAI,EAAE,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC,EACnC,OAAO,EAAE,YAAY,CAAC,OAAO,EAAE,SAAS,CAAC,GACxC,KAAK,CAUP"}
1
+ {"version":3,"file":"define-route.d.ts","sourceRoot":"","sources":["../../src/route/define-route.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,wBAAgB,WAAW,CAAC,KAAK,CAAC,OAAO,SAAS,cAAc,EAAE,KAAK,CAAC,SAAS,SAAS,aAAa,EACrG,IAAI,EAAE,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC,EACnC,OAAO,EAAE,YAAY,CAAC,OAAO,EAAE,SAAS,CAAC,GACxC,KAAK,CAWP"}
@@ -1,9 +1,11 @@
1
+ import { assertCacheDeclaration } from '../cache/assert-cache-declaration.js';
1
2
  import { ROUTE_PATH_PATTERN } from './route-path-pattern.js';
2
3
  export function defineRoute(spec, handler) {
3
4
  if (!ROUTE_PATH_PATTERN.test(spec.path)) {
4
5
  throw new Error(`Route "${spec.operationId}": the path "${spec.path}" must be made of literal segments and ":name" parameters.`);
5
6
  }
6
7
  assertSecurityDeclared(spec);
8
+ assertCacheDeclaration(spec);
7
9
  return { ...spec, handle: handler };
8
10
  }
9
11
  // Checked at run time too: a JavaScript caller, or a spec built dynamically, gets no compile error.
@@ -1 +1 @@
1
- {"version":3,"file":"define-route.js","sourceRoot":"","sources":["../../src/route/define-route.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAK7D,MAAM,UAAU,WAAW,CACzB,IAAmC,EACnC,OAAyC;IAEzC,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CACb,UAAU,IAAI,CAAC,WAAW,gBAAgB,IAAI,CAAC,IAAI,4DAA4D,CAChH,CAAC;IACJ,CAAC;IAED,sBAAsB,CAAC,IAAI,CAAC,CAAC;IAE7B,OAAO,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AACtC,CAAC;AAED,oGAAoG;AACpG,SAAS,sBAAsB,CAAC,IAAsE;IACpG,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;IAE1B,IAAI,QAAQ,KAAK,KAAK,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC;QAC3E,OAAO;IACT,CAAC;IAED,MAAM,IAAI,KAAK,CACb,UAAU,IAAI,CAAC,WAAW,4FAA4F,CACvH,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"define-route.js","sourceRoot":"","sources":["../../src/route/define-route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAG9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAK7D,MAAM,UAAU,WAAW,CACzB,IAAmC,EACnC,OAAyC;IAEzC,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CACb,UAAU,IAAI,CAAC,WAAW,gBAAgB,IAAI,CAAC,IAAI,4DAA4D,CAChH,CAAC;IACJ,CAAC;IAED,sBAAsB,CAAC,IAAI,CAAC,CAAC;IAC7B,sBAAsB,CAAC,IAAI,CAAC,CAAC;IAE7B,OAAO,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AACtC,CAAC;AAED,oGAAoG;AACpG,SAAS,sBAAsB,CAAC,IAAsE;IACpG,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;IAE1B,IAAI,QAAQ,KAAK,KAAK,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC;QAC3E,OAAO;IACT,CAAC;IAED,MAAM,IAAI,KAAK,CACb,UAAU,IAAI,CAAC,WAAW,4FAA4F,CACvH,CAAC;AACJ,CAAC"}
@@ -13,6 +13,8 @@ export interface RequestContext {
13
13
  readonly rawHeaders?: RawHeaders;
14
14
  /** The framework's own request object, for the rare case the neutral input is not enough. */
15
15
  readonly raw: unknown;
16
+ /** The version named in `If-Match`, on a route that declares `ifMatch`: absent when the caller named none, or `*`. */
17
+ readonly expectedVersion?: number;
16
18
  /** The body as it arrives, unparsed, for a route declared with `rawBody`. */
17
19
  readonly stream?: Readable;
18
20
  }
@@ -1 +1 @@
1
- {"version":3,"file":"request-context.d.ts","sourceRoot":"","sources":["../../src/route/request-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,QAAQ,CAAC,SAAS,EAAE,gBAAgB,CAAC;IACrC,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC7B,yHAAyH;IACzH,QAAQ,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC;IACjC,6FAA6F;IAC7F,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;IACtB,6EAA6E;IAC7E,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC;CAC5B"}
1
+ {"version":3,"file":"request-context.d.ts","sourceRoot":"","sources":["../../src/route/request-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,QAAQ,CAAC,SAAS,EAAE,gBAAgB,CAAC;IACrC,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC7B,yHAAyH;IACzH,QAAQ,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC;IACjC,6FAA6F;IAC7F,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;IACtB,sHAAsH;IACtH,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,6EAA6E;IAC7E,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC;CAC5B"}
@@ -1,3 +1,5 @@
1
+ import type { CachePolicy } from '../cache/cache-policy.js';
2
+ import type { IfMatch } from '../cache/if-match.js';
1
3
  import type { HttpMethod } from './http-method.js';
2
4
  import type { RequestSchemas } from './request-schemas.js';
3
5
  import type { ResponsesSpec } from './responses-spec.js';
@@ -24,5 +26,15 @@ export interface RouteSpec<Request extends RequestSchemas = RequestSchemas, Resp
24
26
  */
25
27
  readonly security: readonly string[] | false;
26
28
  readonly deprecated?: boolean;
29
+ /**
30
+ * How the caches on the way may keep the answer. Left out, a route that is not public answers
31
+ * `Cache-Control: no-store`, and a public one says nothing.
32
+ */
33
+ readonly cache?: CachePolicy;
34
+ /**
35
+ * A write conditional on the version the client read: the version named in `If-Match` is
36
+ * handed to the handler as `context.expectedVersion`, for the use case to compare.
37
+ */
38
+ readonly ifMatch?: IfMatch;
27
39
  }
28
40
  //# sourceMappingURL=route-spec.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"route-spec.d.ts","sourceRoot":"","sources":["../../src/route/route-spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,MAAM,WAAW,SAAS,CACxB,OAAO,SAAS,cAAc,GAAG,cAAc,EAC/C,SAAS,SAAS,aAAa,GAAG,aAAa;IAE/C,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,mGAAmG;IACnG,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,+GAA+G;IAC/G,QAAQ,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC;IAC7B,yIAAyI;IACzI,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,qFAAqF;IACrF,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,KAAK,CAAC;IAC7C,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;CAC/B"}
1
+ {"version":3,"file":"route-spec.d.ts","sourceRoot":"","sources":["../../src/route/route-spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,MAAM,WAAW,SAAS,CACxB,OAAO,SAAS,cAAc,GAAG,cAAc,EAC/C,SAAS,SAAS,aAAa,GAAG,aAAa;IAE/C,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,mGAAmG;IACnG,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,+GAA+G;IAC/G,QAAQ,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC;IAC7B,yIAAyI;IACzI,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,qFAAqF;IACrF,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,KAAK,CAAC;IAC7C,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IAC9B;;;OAGG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC;IAC7B;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;CAC5B"}
@@ -0,0 +1,3 @@
1
+ /** A request header as one text: repeated lines joined as HTTP joins them, absent when not sent. */
2
+ export declare function headerText(value: string | readonly string[] | undefined): string | undefined;
3
+ //# sourceMappingURL=header-text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"header-text.d.ts","sourceRoot":"","sources":["../../src/support/header-text.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAM5F"}
@@ -0,0 +1,8 @@
1
+ /** A request header as one text: repeated lines joined as HTTP joins them, absent when not sent. */
2
+ export function headerText(value) {
3
+ if (value === undefined) {
4
+ return undefined;
5
+ }
6
+ return typeof value === 'string' ? value : value.join(', ');
7
+ }
8
+ //# sourceMappingURL=header-text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"header-text.js","sourceRoot":"","sources":["../../src/support/header-text.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,MAAM,UAAU,UAAU,CAAC,KAA6C;IACtE,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC9D,CAAC"}