@volter/world-core 3.0.155 → 3.0.157

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 (150) hide show
  1. package/attach.cjs +2 -0
  2. package/capability-decision.cjs +6 -4
  3. package/dist/attach.cjs +2 -0
  4. package/dist/capability-decision.cjs +6 -4
  5. package/dist/generated/pack-facts.json +204 -4
  6. package/dist/inject.cjs +150 -86
  7. package/dist/network-policy.cjs +11 -1
  8. package/dist/network-policy.d.cts +1 -0
  9. package/dist/pack-facts.d.cts +3 -0
  10. package/dist/required-credential-transport.cjs +29 -0
  11. package/dist/required-credential-transport.d.cts +3 -0
  12. package/dist/src/actions.d.ts +15 -0
  13. package/dist/src/actions.js +82 -21
  14. package/dist/src/ancestry.d.ts +5 -4
  15. package/dist/src/ancestry.js +53 -28
  16. package/dist/src/blob-store.d.ts +16 -0
  17. package/dist/src/blob-store.js +76 -1
  18. package/dist/src/changeset.js +1 -1
  19. package/dist/src/clickhouse/compression.d.ts +28 -0
  20. package/dist/src/clickhouse/compression.js +281 -0
  21. package/dist/src/clickhouse/index.d.ts +1 -0
  22. package/dist/src/clickhouse/index.js +1 -0
  23. package/dist/src/derived-core.d.ts +84 -7
  24. package/dist/src/derived-core.js +336 -61
  25. package/dist/src/derived-real.js +97 -15
  26. package/dist/src/derived.d.ts +5 -0
  27. package/dist/src/derived.js +3 -0
  28. package/dist/src/executor.d.ts +7 -0
  29. package/dist/src/executor.js +15 -1
  30. package/dist/src/fork.js +1 -1
  31. package/dist/src/git/lfs.d.ts +13 -3
  32. package/dist/src/git/lfs.js +41 -9
  33. package/dist/src/grpc-wire.js +2 -1
  34. package/dist/src/h2.js +63 -10
  35. package/dist/src/head.d.ts +5 -0
  36. package/dist/src/head.js +15 -0
  37. package/dist/src/history.d.ts +1 -1
  38. package/dist/src/history.js +7 -7
  39. package/dist/src/index.d.ts +5 -1
  40. package/dist/src/index.js +6 -1
  41. package/dist/src/live/ingest.js +9 -13
  42. package/dist/src/live/rtmp.js +7 -5
  43. package/dist/src/live/segmenter.js +7 -1
  44. package/dist/src/log.d.ts +23 -3
  45. package/dist/src/log.js +160 -37
  46. package/dist/src/machines.js +5 -1
  47. package/dist/src/managed-go-programs.d.ts +55 -0
  48. package/dist/src/managed-go-programs.js +133 -0
  49. package/dist/src/managed-original-inputs.d.ts +101 -0
  50. package/dist/src/managed-original-inputs.js +125 -0
  51. package/dist/src/mongodb/client.d.ts +8 -0
  52. package/dist/src/mongodb/client.js +27 -0
  53. package/dist/src/mongodb/index.d.ts +2 -0
  54. package/dist/src/mongodb/index.js +5 -0
  55. package/dist/src/mongodb/stream.d.ts +97 -0
  56. package/dist/src/mongodb/stream.js +206 -0
  57. package/dist/src/observe.js +1 -1
  58. package/dist/src/pack-fetch.d.ts +6 -1
  59. package/dist/src/pack-fetch.js +69 -14
  60. package/dist/src/pack-paths.d.ts +2 -1
  61. package/dist/src/pack-paths.js +6 -1
  62. package/dist/src/packRegistry.d.ts +10 -14
  63. package/dist/src/packRegistry.js +2 -13
  64. package/dist/src/protocol.d.ts +13 -0
  65. package/dist/src/protocol.js +13 -0
  66. package/dist/src/redis/engine.d.ts +10 -4
  67. package/dist/src/redis/engine.js +103 -32
  68. package/dist/src/redis/member-storage.js +20 -8
  69. package/dist/src/redis/service-times.d.ts +25 -0
  70. package/dist/src/redis/service-times.js +87 -0
  71. package/dist/src/redis/stream.d.ts +2 -1
  72. package/dist/src/redis/stream.js +109 -20
  73. package/dist/src/resource-blob.d.ts +4 -0
  74. package/dist/src/resource-blob.js +8 -1
  75. package/dist/src/runtime-state.d.ts +11 -0
  76. package/dist/src/runtime-state.js +13 -0
  77. package/dist/src/runtime.d.ts +7 -5
  78. package/dist/src/runtime.js +7 -4
  79. package/dist/src/serve-http.d.ts +2 -0
  80. package/dist/src/serve-http.js +73 -6
  81. package/dist/src/serve.d.ts +10 -0
  82. package/dist/src/serve.js +43 -3
  83. package/dist/src/sockets.d.ts +4 -1
  84. package/dist/src/sockets.js +59 -6
  85. package/dist/src/storage.d.ts +2 -1
  86. package/dist/src/storage.js +6 -3
  87. package/dist/src/vendor-call.js +58 -0
  88. package/dist/src/world-boot.d.ts +1 -0
  89. package/dist/src/world-boot.js +6 -0
  90. package/dist/src/world-clock.js +6 -2
  91. package/dist/src/world-store.d.ts +122 -7
  92. package/dist/src/world-store.js +959 -103
  93. package/dist/src/xml.d.ts +30 -0
  94. package/dist/src/xml.js +74 -0
  95. package/generated/pack-facts.json +204 -4
  96. package/inject.cjs +150 -86
  97. package/network-policy.cjs +11 -1
  98. package/network-policy.d.cts +1 -0
  99. package/pack-facts.d.cts +3 -0
  100. package/package.json +27 -1
  101. package/required-credential-transport.cjs +29 -0
  102. package/required-credential-transport.d.cts +3 -0
  103. package/src/actions.ts +78 -21
  104. package/src/ancestry.ts +46 -24
  105. package/src/blob-store.ts +59 -1
  106. package/src/changeset.ts +1 -1
  107. package/src/clickhouse/compression.ts +172 -0
  108. package/src/clickhouse/index.ts +2 -0
  109. package/src/derived-core.ts +356 -61
  110. package/src/derived-real.ts +80 -14
  111. package/src/derived.ts +9 -1
  112. package/src/executor.ts +17 -3
  113. package/src/fork.ts +1 -1
  114. package/src/git/lfs.ts +40 -9
  115. package/src/grpc-wire.ts +2 -1
  116. package/src/h2.ts +46 -5
  117. package/src/head.ts +15 -0
  118. package/src/history.ts +7 -7
  119. package/src/index.ts +7 -1
  120. package/src/live/ingest.ts +7 -3
  121. package/src/live/rtmp.ts +7 -5
  122. package/src/live/segmenter.ts +7 -1
  123. package/src/log.ts +147 -32
  124. package/src/machines.ts +5 -1
  125. package/src/managed-go-programs.ts +146 -0
  126. package/src/managed-original-inputs.ts +163 -0
  127. package/src/mongodb/client.ts +27 -0
  128. package/src/mongodb/index.ts +5 -0
  129. package/src/mongodb/stream.ts +223 -0
  130. package/src/observe.ts +1 -1
  131. package/src/pack-fetch.ts +66 -16
  132. package/src/pack-paths.ts +5 -1
  133. package/src/packRegistry.ts +3 -15
  134. package/src/protocol.ts +13 -0
  135. package/src/redis/engine.ts +100 -57
  136. package/src/redis/member-storage.ts +17 -9
  137. package/src/redis/service-times.ts +81 -0
  138. package/src/redis/stream.ts +66 -14
  139. package/src/resource-blob.ts +9 -1
  140. package/src/runtime-state.ts +14 -0
  141. package/src/runtime.ts +10 -3
  142. package/src/serve-http.ts +65 -6
  143. package/src/serve.ts +45 -3
  144. package/src/sockets.ts +39 -8
  145. package/src/storage.ts +5 -3
  146. package/src/vendor-call.ts +54 -0
  147. package/src/world-boot.ts +6 -0
  148. package/src/world-clock.ts +6 -2
  149. package/src/world-store.ts +768 -91
  150. package/src/xml.ts +71 -0
@@ -68,6 +68,8 @@ export type Transition = {
68
68
  export type StateField = {
69
69
  initial: string | boolean;
70
70
  transitions: Transition[];
71
+ /** Plain updates may repeat the current representation without another state move. */
72
+ unchanged?: 'allow';
71
73
  derive?: Array<{
72
74
  state: string;
73
75
  when: {
@@ -139,6 +141,8 @@ export type ResourceDecl = {
139
141
  resource: string;
140
142
  allowDeleted?: boolean;
141
143
  where?: Record<string, string>;
144
+ /** Global subject paths omit the collection's parent labels; tenancy still applies. */
145
+ whenNamed?: true;
142
146
  /** private fields a child observed under its parent keeps from the parent's parameters (`_jurisdiction:
143
147
  * '{jurisdiction}'`), where the child's own read names none and a later read under it needs one ("Refresh") */
144
148
  keep?: Record<string, string>;
@@ -215,7 +219,9 @@ export type ResourceDecl = {
215
219
  * holds this one's id (or vendor `parentKey`), only those with `present` set or `absent` unset when named and without
216
220
  * any matching `unless` field, plus `plus` (a customer's
217
221
  * `next_invoice_sequence` is one past its numbered invoices). `by` may be a dot path; exact field names take
218
- * precedence. The kernel keeps each whenever a child is written. */
222
+ * precedence. The kernel keeps each whenever a child is written, the parent it left too when the write moves it; `of`
223
+ * may name a bookkeeping type no resource declares, written with `ctx.record`. A count is kept by the lane that
224
+ * declares it: a child another lane writes is not counted there. */
219
225
  counts?: Record<string, {
220
226
  of: string;
221
227
  by: string;
@@ -261,6 +267,10 @@ export type ResourceDecl = {
261
267
  } | {
262
268
  get: string;
263
269
  known?: true;
270
+ gone?: {
271
+ status: number;
272
+ says: string;
273
+ };
264
274
  }) & {
265
275
  params?: Record<string, string>;
266
276
  headers?: Record<string, string>;
@@ -376,6 +386,17 @@ export type ErrorSpec = {
376
386
  param?: string;
377
387
  kind?: string;
378
388
  };
389
+ /** How a form value outside its spec's list is refused (DerivedOperation.enums): the error, its message filled with
390
+ * `{param}` (the bracket name) and `{values}` (the values it takes); `documented`, values the vendor documents outside
391
+ * its spec, by operation and path; `version`, the header naming the API version a request is made at and the version
392
+ * the spec is, so a request pinned to another version, whose lists the pack does not hold, is not checked. */
393
+ export type EnumRefusal = ErrorSpec & {
394
+ documented?: Record<string, Record<string, string[]>>;
395
+ version?: {
396
+ header: string;
397
+ served: string;
398
+ };
399
+ };
379
400
  /** A vendor screen a World serves (docs/contributing/architecture.md, "Screens"). A `flow` is a hosted
380
401
  * page an application sends its user through, held to its documented round trip; a `workspace` is a
381
402
  * screen people work in. `demand` says who reaches it; `controls` names what a person acts on, the
@@ -401,6 +422,14 @@ export type ScreenDecl = {
401
422
  * takes, with its demand (an upload bucket a page posts a lease's form to: Reddit's S3 hosts) (architecture, "A page
402
423
  * at a World's place") */
403
424
  takes?: ReadonlyArray<'POST'>;
425
+ /** a workspace page that shows one record: the stored type and the path parameter its id fills (a pull request's
426
+ * page, `{number}`); `?show=<type>:<id>` asked of the pack's workspaces opens it (architecture, "Workspace") */
427
+ shows?: {
428
+ type: string;
429
+ param: string;
430
+ };
431
+ /** the stored types a workspace page lists, where `?show=` lands for a record no page shows by itself */
432
+ lists?: ReadonlyArray<string>;
404
433
  /** the vendor's documentation of the round trip or the screen */
405
434
  source: string;
406
435
  };
@@ -443,6 +472,7 @@ export type DerivedManifest = {
443
472
  body: {
444
473
  form?: {
445
474
  coerce: boolean;
475
+ enumRefusal?: EnumRefusal;
446
476
  };
447
477
  json?: 'always';
448
478
  validation?: {
@@ -458,6 +488,7 @@ export type DerivedManifest = {
458
488
  unknown: string;
459
489
  type: string;
460
490
  range: string;
491
+ arrays?: Record<string, 'string'>;
461
492
  };
462
493
  };
463
494
  /** `acceptProvided`: a create that names its own `id` keeps it (a vendor that seeds by id). The template counts
@@ -469,6 +500,13 @@ export type DerivedManifest = {
469
500
  };
470
501
  /** operations the derived core must not claim though their resource is declared: a gap until someone models them */
471
502
  unmodeled?: string[];
503
+ /** documented variants of a served operation that no demand asks for, by operation: each a parameter present
504
+ * (`pause_collection`), present on any item of a list (`items[].price_data`), or with a value
505
+ * (`payment_method_data.type=sepa_debit`, `payment_method_types[]=sepa_debit`), or holding one entry of a comma-separated
506
+ * value (`tweet.fields~=geo`; a parameter whose name holds a dot is read by that name). A request asking one is answered the
507
+ * manifest's gap before its handler runs, as an operation no handler serves is (architecture, "Creating a pack",
508
+ * step 7), so no pack line answers it */
509
+ variants?: Record<string, string[]>;
472
510
  /** operations that only read though nothing in the spec says so (a POST that returns data):
473
511
  * a read-only twin answers them */
474
512
  reads?: string[];
@@ -506,6 +544,9 @@ export type DerivedManifest = {
506
544
  readOnly: ErrorSpec;
507
545
  /** what a body labelled JSON that does not parse answers; absent, a 400 in the vendor's error body */
508
546
  malformedBody?: ErrorSpec;
547
+ /** the vendor's front merges repeated slashes in a path before it routes (nginx's default `merge_slashes`): a request
548
+ * to `//r/x//about` is `/r/x/about`, merged on arrival before a door, a screen or an operation is matched */
549
+ mergeSlashes?: boolean;
509
550
  /** a request header that selects the vendor's API version, and the answer to a malformed one
510
551
  * (`{value}` in its message is the header's value) */
511
552
  version?: {
@@ -702,7 +743,13 @@ export type DerivedManifest = {
702
743
  method: string;
703
744
  path: string;
704
745
  note?: string;
746
+ redactBody?: string[];
705
747
  }>;
748
+ /** REST refresh binds observed tenant metadata through the root account identity endpoint. */
749
+ refreshIdentity?: {
750
+ operation: string;
751
+ field: string;
752
+ };
706
753
  /** The vendor's GraphQL API beside its REST one (`semantics/graphql.ts` over `generated/graphql-sdl.gen.json`): the
707
754
  * paths it is POSTed to, and the answer to a query selecting a field nothing models (`{field}`, `{type}`). */
708
755
  graphql?: {
@@ -939,8 +986,6 @@ export type SemanticsContext = {
939
986
  /** A mail the vendor sends a person, over SMTP to the route its settings name (smtp.ts), under the World's egress rule;
940
987
  * throws when it cannot be delivered. */
941
988
  mail(route: SmtpRoute, mail: Mail, headers?: Record<string, string>): Promise<void>;
942
- /** who is calling, when the manifest says how to tell */
943
- actor: string | undefined;
944
989
  now(): unknown;
945
990
  /** Render a stored row or vendor view using its resource declaration, retaining the stored subject id fallback. */
946
991
  render(row: Record<string, unknown>, resource?: string): Record<string, unknown>;
@@ -985,13 +1030,28 @@ export type SemanticsContext = {
985
1030
  /** Allocate a stored occurrence and append its fields under one action lock. The optional field factory is pure. */
986
1031
  create(resource: string, fields: Record<string, unknown> | ((id: string) => Record<string, unknown>), operation: string): Promise<Record<string, unknown>>;
987
1032
  /** Create under declared unique keys and the action lock; a collision returns the existing own-field view without a write. */
988
- createUnique(resource: string, fields: Record<string, unknown> | ((id: string) => Record<string, unknown>), operation: string): Promise<{
1033
+ createUnique(resource: string, fields: Record<string, unknown> | ((id: string) => Record<string, unknown>), operation: string, options?: {
1034
+ input: 'omit';
1035
+ }): Promise<{
989
1036
  created: boolean;
990
1037
  row: Record<string, unknown>;
991
1038
  }>;
992
1039
  /** Decide an update from the current live stored row under the action lock; undefined leaves it unchanged. */
993
- change(resource: string, id: string, decide: (row: Record<string, unknown>) => Record<string, unknown> | undefined, operation: string): Promise<Record<string, unknown> | undefined>;
1040
+ change(resource: string, id: string, decide: (row: Record<string, unknown>) => Record<string, unknown> | undefined, operation: string, options?: {
1041
+ input: 'omit';
1042
+ }): Promise<Record<string, unknown> | undefined>;
994
1043
  write(resource: string, id: string, fields: Record<string, unknown>, operation: string): Promise<Record<string, unknown>>;
1044
+ /**
1045
+ * One command's writes as one group (S2 R17; docs/contributing/architecture.md, "A command's writes as one group").
1046
+ * Inside `fn`, `write` stages its write and answers the row as it will stand; `row` and `rowsRaw` read the tree with
1047
+ * the staged writes folded over it, as it will be once they land. When `fn` returns or throws, every staged write
1048
+ * lands, in order, as one append; then its value is answered or its error thrown. Every other way to write, or to
1049
+ * wait on a write, lands the staged writes first; any other read of the tree (`get`, `rows`, `tree`, `history`, ...)
1050
+ * while writes are staged is refused, never answered without them. Each write keeps its own action, id, ordinal,
1051
+ * moment and recorded request. Where the pack has write hooks, events, sockets or counts, a state observer is on,
1052
+ * a head performs, or ids are aliased, `fn` simply runs, each write landing as it is made.
1053
+ */
1054
+ batch<T>(fn: () => Promise<T>): Promise<T>;
995
1055
  /** Add numeric deltas to an existing bookkeeping row under the kernel's atomic write seam. */
996
1056
  accumulate(resource: string, id: string, deltas: Record<string, number>, operation: string): Promise<void>;
997
1057
  /** `write`, with what a live vendor answered when the head performed it */
@@ -1115,6 +1175,16 @@ export type SemanticsContext = {
1115
1175
  put(key: string, bytes: Uint8Array): Promise<void>;
1116
1176
  get(key: string): Promise<Uint8Array | null>;
1117
1177
  remove(key: string): Promise<void>;
1178
+ /** a body written as it arrives (a request's own stream), kept only when `accept` holds for its size and SHA-256:
1179
+ * an upload of a large object never held whole. True when kept */
1180
+ putStream(key: string, body: ReadableStream<Uint8Array> | AsyncIterable<Uint8Array>, accept: (written: {
1181
+ size: number;
1182
+ sha256: string;
1183
+ }) => boolean): Promise<boolean>;
1184
+ /** a blob's length, or null when there is none: a large object is answered without loading it */
1185
+ size(key: string): Promise<number | null>;
1186
+ /** the bytes `start`..`endInclusive` of a blob (a ranged read where the store has one), or null when there is none */
1187
+ range(key: string, start: number, endInclusive: number): Promise<Uint8Array | null>;
1118
1188
  };
1119
1189
  /** A body's fields checked against the operation's declared ones under the manifest's `body.strict`: the fields, or
1120
1190
  * the vendor's refusal of the first that is unknown, of another type or out of its bounds. */
@@ -1141,13 +1211,20 @@ export type HandlerContext = Omit<SemanticsContext, 'now' | 'core' | 'atomically
1141
1211
  };
1142
1212
  /** What a write hook reads: the writing call's context without its ways to write, so a hook that renders an event
1143
1213
  * cannot write again (and run itself again). */
1144
- export type WriteHookContext = Omit<HandlerContext, 'write' | 'create' | 'createUnique' | 'change' | 'issue' | 'record' | 'accumulate' | 'at' | 'over'>;
1214
+ export type WriteHookContext = Omit<HandlerContext, 'write' | 'batch' | 'create' | 'createUnique' | 'change' | 'issue' | 'record' | 'accumulate' | 'at' | 'over'>;
1145
1215
  /** A derived pack's handler: one operation, by its operationId, over the contract's context. */
1146
1216
  export type Handler = (ctx: HandlerContext) => Promise<Response>;
1147
- /** The context the kernel opens for a call (a handler's, a door's, a screen's). Kernel-internal: packs are given it. */
1148
1217
  export declare function contextFor(m: DerivedManifest, call: DerivedCall, scope: CoreScope): Promise<SemanticsContext>;
1149
1218
  /** A pack's semantics handlers as the dispatch's handlers. */
1150
1219
  export declare function bindSemantics(m: DerivedManifest, handlers: Record<string, Semantics>, scope?: CoreScope): Record<string, DerivedHandler>;
1220
+ /** The first of a request's form parameters whose value is not one its spec lists (DerivedOperation.enums), with the
1221
+ * bracket name a form gives it (`spending_controls[spending_limits][0][interval]`) and the values it takes. */
1222
+ export declare function valueOutside(params: Record<string, unknown>, enums: Readonly<Record<string, ReadonlyArray<string>>>): {
1223
+ param: string;
1224
+ values: ReadonlyArray<string>;
1225
+ } | undefined;
1226
+ /** Whether a request's parameters ask one of the operation's undemanded variants (DerivedManifest.variants). */
1227
+ export declare function variantAsked(params: Record<string, unknown>, variants: readonly string[], headers?: Headers): boolean;
1151
1228
  /** The derived core as the dispatch's core: it owns every operation on a resource the manifest declares. */
1152
1229
  export declare function coreFor(m: DerivedManifest, scope?: CoreScope): {
1153
1230
  owns: (o: DerivedOperation) => boolean;