@astrale-os/kernel-server 0.5.0-beta.7 → 0.5.0-beta.70

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 (215) hide show
  1. package/dist/capture.d.ts +0 -1
  2. package/dist/capture.js +0 -1
  3. package/dist/cors/cors.d.ts +0 -1
  4. package/dist/cors/cors.js +11 -4
  5. package/dist/cors/index.d.ts +0 -1
  6. package/dist/cors/index.js +0 -1
  7. package/dist/cors/types.d.ts +0 -1
  8. package/dist/cors/types.js +0 -1
  9. package/dist/errors/admission.d.ts +7 -0
  10. package/dist/errors/admission.js +22 -0
  11. package/dist/errors/availability.d.ts +0 -1
  12. package/dist/errors/availability.js +0 -1
  13. package/dist/errors/classify.d.ts +8 -1
  14. package/dist/errors/classify.js +15 -1
  15. package/dist/errors/index.d.ts +2 -2
  16. package/dist/errors/index.js +2 -2
  17. package/dist/errors/request-body.d.ts +0 -1
  18. package/dist/errors/request-body.js +0 -1
  19. package/dist/errors/response-body.d.ts +0 -1
  20. package/dist/errors/response-body.js +0 -1
  21. package/dist/index.d.ts +8 -4
  22. package/dist/index.js +7 -3
  23. package/dist/invocation/context.d.ts +3 -3
  24. package/dist/invocation/context.js +2 -2
  25. package/dist/invocation/identity.d.ts +1 -2
  26. package/dist/invocation/identity.js +1 -2
  27. package/dist/invocation/index.d.ts +1 -2
  28. package/dist/invocation/index.js +1 -2
  29. package/dist/invocation/legacy/index.d.ts +20 -0
  30. package/dist/invocation/legacy/index.js +20 -0
  31. package/dist/invocation/{publication-route.d.ts → legacy/publication-route.d.ts} +7 -5
  32. package/dist/invocation/{publication-route.js → legacy/publication-route.js} +7 -13
  33. package/dist/invocation/release-route.d.ts +26 -0
  34. package/dist/invocation/release-route.js +55 -0
  35. package/dist/invocation/types.d.ts +20 -7
  36. package/dist/invocation/types.js +0 -1
  37. package/dist/issuer/exchange.d.ts +0 -1
  38. package/dist/issuer/exchange.js +20 -10
  39. package/dist/issuer/index.d.ts +0 -1
  40. package/dist/issuer/index.js +0 -1
  41. package/dist/issuer/routes.d.ts +0 -1
  42. package/dist/issuer/routes.js +33 -5
  43. package/dist/issuer/types.d.ts +5 -1
  44. package/dist/issuer/types.js +0 -1
  45. package/dist/lifecycle/active.d.ts +4 -1
  46. package/dist/lifecycle/active.js +48 -11
  47. package/dist/lifecycle/index.d.ts +0 -1
  48. package/dist/lifecycle/index.js +0 -1
  49. package/dist/release/delivery/handler.d.ts +13 -0
  50. package/dist/{publication → release}/delivery/handler.js +42 -15
  51. package/dist/{publication → release}/delivery/index.d.ts +0 -1
  52. package/dist/{publication → release}/delivery/index.js +0 -1
  53. package/dist/release/delivery/types.d.ts +21 -0
  54. package/dist/release/delivery/types.js +1 -0
  55. package/dist/release/index.d.ts +3 -0
  56. package/dist/release/index.js +2 -0
  57. package/dist/release/legacy/delivery.d.ts +18 -0
  58. package/dist/release/legacy/delivery.js +2 -0
  59. package/dist/release/legacy/index.d.ts +39 -0
  60. package/dist/release/legacy/index.js +38 -0
  61. package/dist/release/legacy/snapshot.d.ts +26 -0
  62. package/dist/release/legacy/snapshot.js +55 -0
  63. package/dist/release/legacy/table.d.ts +5 -0
  64. package/dist/{publication → release/legacy}/table.js +5 -6
  65. package/dist/release/legacy/types.d.ts +31 -0
  66. package/dist/release/legacy/types.js +1 -0
  67. package/dist/release/served.d.ts +30 -0
  68. package/dist/release/served.js +14 -0
  69. package/dist/release/snapshot.d.ts +26 -0
  70. package/dist/release/snapshot.js +54 -0
  71. package/dist/release/table.d.ts +4 -0
  72. package/dist/release/table.js +11 -0
  73. package/dist/release/types.d.ts +33 -0
  74. package/dist/release/types.js +1 -0
  75. package/dist/routes/index.d.ts +1 -2
  76. package/dist/routes/index.js +1 -2
  77. package/dist/routes/routes.d.ts +9 -7
  78. package/dist/routes/routes.js +256 -123
  79. package/dist/server.d.ts +0 -1
  80. package/dist/server.js +110 -48
  81. package/dist/transport/body.d.ts +0 -1
  82. package/dist/transport/body.js +0 -1
  83. package/dist/transport/codecs.d.ts +2 -3
  84. package/dist/transport/codecs.js +4 -4
  85. package/dist/transport/credential.d.ts +0 -1
  86. package/dist/transport/credential.js +0 -1
  87. package/dist/transport/http/binary-request.d.ts +11 -0
  88. package/dist/transport/http/binary-request.js +102 -0
  89. package/dist/transport/http/handler.d.ts +8 -3
  90. package/dist/transport/http/handler.js +95 -45
  91. package/dist/transport/http/index.d.ts +0 -1
  92. package/dist/transport/http/index.js +0 -1
  93. package/dist/transport/http/render.d.ts +9 -4
  94. package/dist/transport/http/render.js +150 -5
  95. package/dist/transport/index.d.ts +0 -1
  96. package/dist/transport/index.js +0 -1
  97. package/dist/transport/router.d.ts +0 -1
  98. package/dist/transport/router.js +0 -1
  99. package/dist/transport/stream-error.d.ts +0 -1
  100. package/dist/transport/stream-error.js +0 -1
  101. package/dist/transport/types.d.ts +1 -2
  102. package/dist/transport/types.js +0 -1
  103. package/dist/transport/websocket/index.d.ts +0 -1
  104. package/dist/transport/websocket/index.js +0 -1
  105. package/dist/transport/websocket/session.d.ts +3 -3
  106. package/dist/transport/websocket/session.js +30 -30
  107. package/dist/transport/websocket/upgrade.d.ts +2 -3
  108. package/dist/transport/websocket/upgrade.js +7 -7
  109. package/dist/types.d.ts +32 -6
  110. package/dist/types.js +0 -1
  111. package/package.json +12 -15
  112. package/dist/capture.d.ts.map +0 -1
  113. package/dist/capture.js.map +0 -1
  114. package/dist/cors/cors.d.ts.map +0 -1
  115. package/dist/cors/cors.js.map +0 -1
  116. package/dist/cors/index.d.ts.map +0 -1
  117. package/dist/cors/index.js.map +0 -1
  118. package/dist/cors/types.d.ts.map +0 -1
  119. package/dist/cors/types.js.map +0 -1
  120. package/dist/errors/availability.d.ts.map +0 -1
  121. package/dist/errors/availability.js.map +0 -1
  122. package/dist/errors/classify.d.ts.map +0 -1
  123. package/dist/errors/classify.js.map +0 -1
  124. package/dist/errors/index.d.ts.map +0 -1
  125. package/dist/errors/index.js.map +0 -1
  126. package/dist/errors/request-body.d.ts.map +0 -1
  127. package/dist/errors/request-body.js.map +0 -1
  128. package/dist/errors/response-body.d.ts.map +0 -1
  129. package/dist/errors/response-body.js.map +0 -1
  130. package/dist/index.d.ts.map +0 -1
  131. package/dist/index.js.map +0 -1
  132. package/dist/invocation/context.d.ts.map +0 -1
  133. package/dist/invocation/context.js.map +0 -1
  134. package/dist/invocation/identity.d.ts.map +0 -1
  135. package/dist/invocation/identity.js.map +0 -1
  136. package/dist/invocation/index.d.ts.map +0 -1
  137. package/dist/invocation/index.js.map +0 -1
  138. package/dist/invocation/publication-route.d.ts.map +0 -1
  139. package/dist/invocation/publication-route.js.map +0 -1
  140. package/dist/invocation/types.d.ts.map +0 -1
  141. package/dist/invocation/types.js.map +0 -1
  142. package/dist/issuer/exchange.d.ts.map +0 -1
  143. package/dist/issuer/exchange.js.map +0 -1
  144. package/dist/issuer/index.d.ts.map +0 -1
  145. package/dist/issuer/index.js.map +0 -1
  146. package/dist/issuer/routes.d.ts.map +0 -1
  147. package/dist/issuer/routes.js.map +0 -1
  148. package/dist/issuer/types.d.ts.map +0 -1
  149. package/dist/issuer/types.js.map +0 -1
  150. package/dist/lifecycle/active.d.ts.map +0 -1
  151. package/dist/lifecycle/active.js.map +0 -1
  152. package/dist/lifecycle/index.d.ts.map +0 -1
  153. package/dist/lifecycle/index.js.map +0 -1
  154. package/dist/publication/delivery/handler.d.ts +0 -10
  155. package/dist/publication/delivery/handler.d.ts.map +0 -1
  156. package/dist/publication/delivery/handler.js.map +0 -1
  157. package/dist/publication/delivery/index.d.ts.map +0 -1
  158. package/dist/publication/delivery/index.js.map +0 -1
  159. package/dist/publication/delivery/types.d.ts +0 -12
  160. package/dist/publication/delivery/types.d.ts.map +0 -1
  161. package/dist/publication/delivery/types.js +0 -2
  162. package/dist/publication/delivery/types.js.map +0 -1
  163. package/dist/publication/index.d.ts +0 -4
  164. package/dist/publication/index.d.ts.map +0 -1
  165. package/dist/publication/index.js +0 -3
  166. package/dist/publication/index.js.map +0 -1
  167. package/dist/publication/snapshot.d.ts +0 -16
  168. package/dist/publication/snapshot.d.ts.map +0 -1
  169. package/dist/publication/snapshot.js +0 -39
  170. package/dist/publication/snapshot.js.map +0 -1
  171. package/dist/publication/table.d.ts +0 -4
  172. package/dist/publication/table.d.ts.map +0 -1
  173. package/dist/publication/table.js.map +0 -1
  174. package/dist/publication/types.d.ts +0 -23
  175. package/dist/publication/types.d.ts.map +0 -1
  176. package/dist/publication/types.js +0 -2
  177. package/dist/publication/types.js.map +0 -1
  178. package/dist/publication/validator.d.ts +0 -4
  179. package/dist/publication/validator.d.ts.map +0 -1
  180. package/dist/publication/validator.js +0 -17
  181. package/dist/publication/validator.js.map +0 -1
  182. package/dist/routes/index.d.ts.map +0 -1
  183. package/dist/routes/index.js.map +0 -1
  184. package/dist/routes/routes.d.ts.map +0 -1
  185. package/dist/routes/routes.js.map +0 -1
  186. package/dist/server.d.ts.map +0 -1
  187. package/dist/server.js.map +0 -1
  188. package/dist/transport/body.d.ts.map +0 -1
  189. package/dist/transport/body.js.map +0 -1
  190. package/dist/transport/codecs.d.ts.map +0 -1
  191. package/dist/transport/codecs.js.map +0 -1
  192. package/dist/transport/credential.d.ts.map +0 -1
  193. package/dist/transport/credential.js.map +0 -1
  194. package/dist/transport/http/handler.d.ts.map +0 -1
  195. package/dist/transport/http/handler.js.map +0 -1
  196. package/dist/transport/http/index.d.ts.map +0 -1
  197. package/dist/transport/http/index.js.map +0 -1
  198. package/dist/transport/http/render.d.ts.map +0 -1
  199. package/dist/transport/http/render.js.map +0 -1
  200. package/dist/transport/index.d.ts.map +0 -1
  201. package/dist/transport/index.js.map +0 -1
  202. package/dist/transport/router.d.ts.map +0 -1
  203. package/dist/transport/router.js.map +0 -1
  204. package/dist/transport/stream-error.d.ts.map +0 -1
  205. package/dist/transport/stream-error.js.map +0 -1
  206. package/dist/transport/types.d.ts.map +0 -1
  207. package/dist/transport/types.js.map +0 -1
  208. package/dist/transport/websocket/index.d.ts.map +0 -1
  209. package/dist/transport/websocket/index.js.map +0 -1
  210. package/dist/transport/websocket/session.d.ts.map +0 -1
  211. package/dist/transport/websocket/session.js.map +0 -1
  212. package/dist/transport/websocket/upgrade.d.ts.map +0 -1
  213. package/dist/transport/websocket/upgrade.js.map +0 -1
  214. package/dist/types.d.ts.map +0 -1
  215. package/dist/types.js.map +0 -1
@@ -0,0 +1,26 @@
1
+ import type { Domain } from '@astrale-os/kernel-dsl/v1';
2
+ import type * as publication from '@astrale-os/kernel-protocol/publication';
3
+ import type { Table } from '@astrale-os/kernel-protocol/routes/legacy';
4
+ import type { PublicationSnapshot, PublicationSnapshotInput } from './types.js';
5
+ /** @deprecated Successor: `PreparedReleaseSnapshot`. */
6
+ export interface PreparedPublicationSnapshot {
7
+ readonly kind: 'publication';
8
+ readonly snapshot: PublicationSnapshot;
9
+ readonly publication: publication.Publication;
10
+ readonly publicationBytes: Uint8Array;
11
+ readonly bundle: Uint8Array;
12
+ readonly table: Table;
13
+ readonly domain: Domain;
14
+ }
15
+ /**
16
+ * Admit and detach one revision-coherent serving snapshot.
17
+ *
18
+ * @deprecated Use `prepareReleaseSnapshot` to serve a release and its v3 projection.
19
+ */
20
+ export declare function preparePublicationSnapshot(input: PublicationSnapshotInput): PublicationSnapshot;
21
+ /**
22
+ * Internal proof that a PublicationSource returned a Server-prepared snapshot without cloning it.
23
+ *
24
+ * @deprecated Successor: `readPreparedReleaseSnapshot`.
25
+ */
26
+ export declare function readPreparedPublicationSnapshot(input: unknown): PreparedPublicationSnapshot | undefined;
@@ -0,0 +1,55 @@
1
+ import { bundleUrl } from '@astrale-os/kernel-protocol/publication';
2
+ import { verifyBundleBytes } from '@astrale-os/kernel-protocol/publication/bundle-evidence';
3
+ import { accept as acceptPublication, encode as encodePublication, } from '@astrale-os/kernel-protocol/publication/publication';
4
+ import { admitTable } from './table.js';
5
+ const snapshots = new WeakMap();
6
+ /**
7
+ * Admit and detach one revision-coherent serving snapshot.
8
+ *
9
+ * @deprecated Use `prepareReleaseSnapshot` to serve a release and its v3 projection.
10
+ */
11
+ export function preparePublicationSnapshot(input) {
12
+ if (input === null || typeof input !== 'object' || !(input.bundle instanceof Uint8Array)) {
13
+ throw new TypeError('Publication snapshot input is invalid.');
14
+ }
15
+ const admittedPublication = acceptPublication(input.publication);
16
+ const bundleBytes = new Uint8Array(input.bundle);
17
+ verifyBundleBytes(admittedPublication, bundleBytes);
18
+ const domain = input.domain;
19
+ if (domain.origin !== admittedPublication.origin ||
20
+ domain.revision !== admittedPublication.schema.revision) {
21
+ throw new TypeError('Publication snapshot Domain identity differs from its Publication.');
22
+ }
23
+ const table = admitTable(admittedPublication, input.table, domain);
24
+ const addressed = new URL(bundleUrl(admittedPublication.identity.issuer, admittedPublication.schema.bundle.ref));
25
+ const addressedDirectory = addressed.pathname.slice(0, addressed.pathname.lastIndexOf('/') + 1);
26
+ const servingBundle = new URL(admittedPublication.schema.bundle.href);
27
+ if (servingBundle.origin === addressed.origin &&
28
+ servingBundle.pathname.startsWith(addressedDirectory) &&
29
+ servingBundle.href !== addressed.href) {
30
+ throw new TypeError('Publication bundle URL differs from its artifact digest.');
31
+ }
32
+ const publicationBytes = encodePublication(admittedPublication);
33
+ const snapshot = Object.freeze({ publication: admittedPublication });
34
+ const prepared = Object.freeze({
35
+ kind: 'publication',
36
+ snapshot,
37
+ publication: admittedPublication,
38
+ publicationBytes,
39
+ bundle: bundleBytes,
40
+ table,
41
+ domain,
42
+ });
43
+ snapshots.set(snapshot, prepared);
44
+ return snapshot;
45
+ }
46
+ /**
47
+ * Internal proof that a PublicationSource returned a Server-prepared snapshot without cloning it.
48
+ *
49
+ * @deprecated Successor: `readPreparedReleaseSnapshot`.
50
+ */
51
+ export function readPreparedPublicationSnapshot(input) {
52
+ if (input === null || typeof input !== 'object')
53
+ return undefined;
54
+ return snapshots.get(input);
55
+ }
@@ -0,0 +1,5 @@
1
+ import type { Domain } from '@astrale-os/kernel-dsl/v1';
2
+ import type * as publication from '@astrale-os/kernel-protocol/publication';
3
+ import { type Table } from '@astrale-os/kernel-protocol/routes/legacy';
4
+ /** @deprecated Use `admitTable` in `server/release/table.ts` for release-bound routes. */
5
+ export declare function admitTable(deployed: publication.Publication, input: Table | undefined, domain: Domain): Table;
@@ -1,7 +1,7 @@
1
1
  import { reference } from '@astrale-os/kernel-protocol/publication/reference';
2
- import { acceptTable } from '@astrale-os/kernel-protocol/routes/admission';
3
- import { verifyTable } from '@astrale-os/kernel-protocol/routes/evidence';
4
- export function admitTable(deployed, input, validator) {
2
+ import { acceptTable, verifyTable } from '@astrale-os/kernel-protocol/routes/legacy';
3
+ /** @deprecated Use `admitTable` in `server/release/table.ts` for release-bound routes. */
4
+ export function admitTable(deployed, input, domain) {
5
5
  if (input === undefined) {
6
6
  if (deployed.routes.length !== 0) {
7
7
  throw new TypeError('A Publication with native routes requires a Route Table.');
@@ -9,9 +9,8 @@ export function admitTable(deployed, input, validator) {
9
9
  return verifyTable(Object.freeze({
10
10
  publication: reference(deployed),
11
11
  entries: Object.freeze([]),
12
- }), deployed, validator);
12
+ }), deployed, domain);
13
13
  }
14
14
  const table = acceptTable(input);
15
- return verifyTable(table, deployed, validator);
15
+ return verifyTable(table, deployed, domain);
16
16
  }
17
- //# sourceMappingURL=table.js.map
@@ -0,0 +1,31 @@
1
+ import type { Domain } from '@astrale-os/kernel-dsl/v1';
2
+ import type * as publication from '@astrale-os/kernel-protocol/publication';
3
+ import type { Table } from '@astrale-os/kernel-protocol/routes/legacy';
4
+ declare const PUBLICATION_SNAPSHOT: unique symbol;
5
+ /** @deprecated Successor: `ReleaseSnapshotInput`, which serves a `DomainRelease`. */
6
+ export interface PublicationSnapshotInput {
7
+ readonly publication: publication.Publication;
8
+ /** Exact artifact served at Publication.schema.bundle.href. */
9
+ readonly bundle: Uint8Array;
10
+ readonly table?: Table;
11
+ readonly domain: Domain;
12
+ }
13
+ /**
14
+ * Immutable admitted serving identity; bundle and compiled routes remain Server-private.
15
+ *
16
+ * @deprecated Successor: `ReleaseSnapshot`, which serves a `DomainRelease` and its v3 projection.
17
+ */
18
+ export interface PublicationSnapshot {
19
+ readonly publication: publication.Publication;
20
+ readonly [PUBLICATION_SNAPSHOT]: true;
21
+ }
22
+ /**
23
+ * Atomically readable source swapped only after a complete snapshot is prepared.
24
+ *
25
+ * @deprecated Successor: `ReleaseSource`.
26
+ */
27
+ export interface PublicationSource {
28
+ /** Undefined until the first revision-coherent snapshot is ready. */
29
+ current(): PublicationSnapshot | undefined;
30
+ }
31
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,30 @@
1
+ import type { IssuerId } from '@astrale-os/kernel-core/auth/issuer';
2
+ import type { DomainRelease } from '@astrale-os/kernel-protocol/release';
3
+ import type { Publication } from '@astrale-os/kernel-protocol/release/legacy';
4
+ import type { PreparedPublicationSnapshot } from './legacy/snapshot.js';
5
+ import type { PublicationSnapshot, PublicationSource } from './legacy/types.js';
6
+ import type { PreparedReleaseSnapshot } from './snapshot.js';
7
+ import type { ReleaseSnapshot, ReleaseSource } from './types.js';
8
+ export type ServingSource = {
9
+ readonly kind: 'release';
10
+ readonly source: ReleaseSource;
11
+ } | {
12
+ readonly kind: 'publication';
13
+ readonly source: PublicationSource;
14
+ };
15
+ export type Served = PreparedReleaseSnapshot | PreparedPublicationSnapshot;
16
+ export interface RequestServing {
17
+ readonly kind: ServingSource['kind'];
18
+ /** The snapshot the request pins; undefined while none is ready or it is withheld. */
19
+ current(): Served | undefined;
20
+ /** The deployment a DEPLOYMENT_RETIRED answer names: the Server's public serving origin. */
21
+ deployment(): IssuerId;
22
+ }
23
+ export declare function readServed(serving: ServingSource): Served | undefined;
24
+ /** A release and its v3 projection share bundles, Delivery endpoints and native routes. */
25
+ export declare function servedDocument(served: Served): DomainRelease | Publication;
26
+ export declare function pinned(served: Served): {
27
+ readonly release: ReleaseSnapshot;
28
+ } | {
29
+ readonly publication: PublicationSnapshot;
30
+ };
@@ -0,0 +1,14 @@
1
+ import { readPreparedPublicationSnapshot } from './legacy/snapshot.js';
2
+ import { readPreparedReleaseSnapshot } from './snapshot.js';
3
+ export function readServed(serving) {
4
+ return serving.kind === 'release'
5
+ ? readPreparedReleaseSnapshot(serving.source.current())
6
+ : readPreparedPublicationSnapshot(serving.source.current());
7
+ }
8
+ /** A release and its v3 projection share bundles, Delivery endpoints and native routes. */
9
+ export function servedDocument(served) {
10
+ return served.kind === 'release' ? served.release : served.publication;
11
+ }
12
+ export function pinned(served) {
13
+ return served.kind === 'release' ? { release: served.snapshot } : { publication: served.snapshot };
14
+ }
@@ -0,0 +1,26 @@
1
+ import type { Domain } from '@astrale-os/kernel-dsl/v1';
2
+ import type { ServedReferences, Table } from '@astrale-os/kernel-protocol/routes';
3
+ import { type DomainRelease } from '@astrale-os/kernel-protocol/release';
4
+ import { type Publication } from '@astrale-os/kernel-protocol/release/legacy';
5
+ import type { ReleaseSnapshot, ReleaseSnapshotInput } from './types.js';
6
+ export interface PreparedReleaseSnapshot {
7
+ readonly kind: 'release';
8
+ readonly snapshot: ReleaseSnapshot;
9
+ readonly release: DomainRelease;
10
+ readonly releaseBytes: Uint8Array;
11
+ /** @deprecated Use `release`. Frozen v3 projection served at `domain.json`. */
12
+ readonly publication: Publication;
13
+ readonly publicationBytes: Uint8Array;
14
+ /** The release and the projection reference native-route If-Match may name. */
15
+ readonly references: ServedReferences;
16
+ readonly bundle: Uint8Array;
17
+ readonly table: Table;
18
+ readonly domain: Domain;
19
+ }
20
+ /**
21
+ * Admit and detach one deployment's serving snapshot before it is served: the release, its exact
22
+ * bundle bytes, its resolved Domain and route Table, and its frozen v3 projection.
23
+ */
24
+ export declare function prepareReleaseSnapshot(input: ReleaseSnapshotInput): ReleaseSnapshot;
25
+ /** Internal proof that a ReleaseSource returned a Server-prepared snapshot without cloning it. */
26
+ export declare function readPreparedReleaseSnapshot(input: unknown): PreparedReleaseSnapshot | undefined;
@@ -0,0 +1,54 @@
1
+ import { accept as acceptRelease, bundleUrl, encode as encodeRelease, verifyBundleBytes, } from '@astrale-os/kernel-protocol/release';
2
+ import { encode as encodePublication, publication as project, reference as publicationReference, } from '@astrale-os/kernel-protocol/release/legacy';
3
+ import { admitTable } from './table.js';
4
+ const snapshots = new WeakMap();
5
+ /**
6
+ * Admit and detach one deployment's serving snapshot before it is served: the release, its exact
7
+ * bundle bytes, its resolved Domain and route Table, and its frozen v3 projection.
8
+ */
9
+ export function prepareReleaseSnapshot(input) {
10
+ if (input === null || typeof input !== 'object' || !(input.bundle instanceof Uint8Array)) {
11
+ throw new TypeError('Release snapshot input is invalid.');
12
+ }
13
+ const release = acceptRelease(input.release);
14
+ const bundleBytes = new Uint8Array(input.bundle);
15
+ verifyBundleBytes(release, bundleBytes);
16
+ const domain = input.domain;
17
+ if (domain.origin !== release.origin || domain.revision !== release.schema.revision) {
18
+ throw new TypeError('Release snapshot Domain identity differs from its release.');
19
+ }
20
+ const table = admitTable(release, input.table, domain);
21
+ const addressed = new URL(bundleUrl(release.identity.issuer, release.schema.bundle.ref));
22
+ const addressedDirectory = addressed.pathname.slice(0, addressed.pathname.lastIndexOf('/') + 1);
23
+ const servingBundle = new URL(release.schema.bundle.href);
24
+ if (servingBundle.origin === addressed.origin &&
25
+ servingBundle.pathname.startsWith(addressedDirectory) &&
26
+ servingBundle.href !== addressed.href) {
27
+ throw new TypeError('Release bundle URL differs from its artifact digest.');
28
+ }
29
+ const projection = project(release);
30
+ const snapshot = Object.freeze({ release, publication: projection });
31
+ const prepared = Object.freeze({
32
+ kind: 'release',
33
+ snapshot,
34
+ release,
35
+ releaseBytes: encodeRelease(release),
36
+ publication: projection,
37
+ publicationBytes: encodePublication(projection),
38
+ references: Object.freeze({
39
+ release: table.release,
40
+ projection: publicationReference(projection),
41
+ }),
42
+ bundle: bundleBytes,
43
+ table,
44
+ domain,
45
+ });
46
+ snapshots.set(snapshot, prepared);
47
+ return snapshot;
48
+ }
49
+ /** Internal proof that a ReleaseSource returned a Server-prepared snapshot without cloning it. */
50
+ export function readPreparedReleaseSnapshot(input) {
51
+ if (input === null || typeof input !== 'object')
52
+ return undefined;
53
+ return snapshots.get(input);
54
+ }
@@ -0,0 +1,4 @@
1
+ import type { Domain } from '@astrale-os/kernel-dsl/v1';
2
+ import type { DomainRelease } from '@astrale-os/kernel-protocol/release';
3
+ import { type Table } from '@astrale-os/kernel-protocol/routes';
4
+ export declare function admitTable(deployed: DomainRelease, input: Table | undefined, domain: Domain): Table;
@@ -0,0 +1,11 @@
1
+ import { reference } from '@astrale-os/kernel-protocol/release';
2
+ import { acceptTable, verifyTable } from '@astrale-os/kernel-protocol/routes';
3
+ export function admitTable(deployed, input, domain) {
4
+ if (input === undefined) {
5
+ if (deployed.routes.length !== 0) {
6
+ throw new TypeError('A release with native routes requires a Route Table.');
7
+ }
8
+ return verifyTable(Object.freeze({ release: reference(deployed), entries: Object.freeze([]) }), deployed, domain);
9
+ }
10
+ return verifyTable(acceptTable(input), deployed, domain);
11
+ }
@@ -0,0 +1,33 @@
1
+ import type { Domain } from '@astrale-os/kernel-dsl/v1';
2
+ import type * as release from '@astrale-os/kernel-protocol/release';
3
+ import type { Table } from '@astrale-os/kernel-protocol/routes';
4
+ declare const RELEASE_SNAPSHOT: unique symbol;
5
+ export interface ReleaseSnapshotInput {
6
+ readonly release: release.DomainRelease;
7
+ /** Exact artifact served at DomainRelease.schema.bundle.href. */
8
+ readonly bundle: Uint8Array;
9
+ /** Route Table bound to this release; required when it declares native routes. */
10
+ readonly table?: Table;
11
+ readonly domain: Domain;
12
+ }
13
+ /**
14
+ * Immutable admitted serving identity of one deployment: the release it serves at `release.json`
15
+ * and the frozen v3 projection it also serves at `domain.json`. Bundle and compiled routes remain
16
+ * Server-private.
17
+ */
18
+ export interface ReleaseSnapshot {
19
+ readonly release: release.DomainRelease;
20
+ /**
21
+ * The frozen v3 projection served at `domain.json` and named by legacy routing witnesses.
22
+ *
23
+ * @deprecated Use `release`.
24
+ */
25
+ readonly publication: release.legacy.Publication;
26
+ readonly [RELEASE_SNAPSHOT]: true;
27
+ }
28
+ /** Atomically readable source swapped only after a complete snapshot is prepared. */
29
+ export interface ReleaseSource {
30
+ /** Undefined until the first snapshot is ready. */
31
+ current(): ReleaseSnapshot | undefined;
32
+ }
33
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1,2 +1 @@
1
- export { currentPublicationSnapshot, mountRoutes, type RouteLimits, type RouteReservation, } from './routes.js';
2
- //# sourceMappingURL=index.d.ts.map
1
+ export { currentServed, mountRoutes, type RouteLimits, type RouteReservation } from './routes.js';
@@ -1,2 +1 @@
1
- export { currentPublicationSnapshot, mountRoutes, } from './routes.js';
2
- //# sourceMappingURL=index.js.map
1
+ export { currentServed, mountRoutes } from './routes.js';
@@ -1,10 +1,9 @@
1
1
  import type { CorsPolicy } from '../cors/index.js';
2
2
  import type { NextInvocationId } from '../invocation/index.js';
3
3
  import type { ActiveOperations } from '../lifecycle/index.js';
4
- import type { Provider as DeliveryProvider } from '../publication/delivery/index.js';
5
- import type { PublicationSource } from '../publication/index.js';
4
+ import type { Provider as DeliveryProvider } from '../release/delivery/index.js';
5
+ import type { Served, ServingSource } from '../release/served.js';
6
6
  import { type ApplicationHost, type Handler } from '../invocation/index.js';
7
- import { type PreparedPublicationSnapshot } from '../publication/index.js';
8
7
  import { type ServerRouter } from '../transport/router.js';
9
8
  export interface RouteLimits {
10
9
  readonly maximumRequestBytes: number;
@@ -17,10 +16,13 @@ export interface RouteReservation {
17
16
  readonly path: string;
18
17
  readonly methods: readonly string[];
19
18
  }
20
- export declare function mountRoutes(app: ServerRouter, source: PublicationSource, deliveryProvider: DeliveryProvider | undefined, handler: Handler, active: ActiveOperations, nextInvocation: NextInvocationId, limits: RouteLimits, cors: CorsPolicy, hostFor: (request: Request) => ApplicationHost | undefined, reservations: readonly RouteReservation[], externalIssuer?: string): void;
21
- export declare function currentPublicationSnapshot(source: PublicationSource, limits: Pick<RouteLimits, 'maximumPublicationBytes' | 'maximumBundleBytes'>, serving?: {
19
+ export declare function mountRoutes(app: ServerRouter, source: ServingSource, deliveryProvider: DeliveryProvider | undefined, handler: Handler, active: ActiveOperations, nextInvocation: NextInvocationId, limits: RouteLimits, cors: CorsPolicy, hostFor: (request: Request) => ApplicationHost | undefined, reservations: readonly RouteReservation[], externalIssuer?: string, publicOrigin?: string): void;
20
+ /**
21
+ * Read the one snapshot a request pins, withheld while it exceeds a serving limit, names another
22
+ * serving issuer, or claims a route this Server reserves.
23
+ */
24
+ export declare function currentServed(source: ServingSource, limits: Pick<RouteLimits, 'maximumPublicationBytes' | 'maximumBundleBytes'>, serving?: {
22
25
  readonly origin: string;
23
26
  readonly issuer?: string;
24
27
  readonly reservations: readonly RouteReservation[];
25
- }): PreparedPublicationSnapshot | undefined;
26
- //# sourceMappingURL=routes.d.ts.map
28
+ }): Served | undefined;