@volter/world-core 2.0.37 → 3.0.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 (205) hide show
  1. package/README.md +4 -5
  2. package/app-route.cjs +12 -6
  3. package/app-route.d.cts +1 -1
  4. package/dist/app-route.cjs +12 -6
  5. package/dist/app-route.d.cts +1 -1
  6. package/dist/generated/pack-facts.json +1410 -3069
  7. package/dist/inject.cjs +64 -9
  8. package/dist/pack-facts.cjs +44 -0
  9. package/dist/src/actions.d.ts +3 -3
  10. package/dist/src/actions.js +22 -16
  11. package/dist/src/ancestry.d.ts +14 -2
  12. package/dist/src/ancestry.js +92 -2
  13. package/dist/src/anthropic-wire.d.ts +39 -0
  14. package/dist/src/anthropic-wire.js +136 -0
  15. package/dist/src/bytes.d.ts +7 -0
  16. package/dist/src/bytes.js +35 -0
  17. package/dist/src/changeset.d.ts +1 -1
  18. package/dist/src/changeset.js +0 -0
  19. package/dist/src/clickhouse/index.d.ts +3 -0
  20. package/dist/src/clickhouse/index.js +6 -0
  21. package/dist/src/clickhouse/sql.d.ts +233 -0
  22. package/dist/src/clickhouse/sql.js +4329 -0
  23. package/dist/src/clickhouse/types.d.ts +18 -0
  24. package/dist/src/clickhouse/types.js +47 -0
  25. package/dist/src/clickhouse/values.d.ts +146 -0
  26. package/dist/src/clickhouse/values.js +858 -0
  27. package/dist/src/client-bundle.js +2 -3
  28. package/dist/src/cors.d.ts +15 -0
  29. package/dist/src/cors.js +31 -0
  30. package/dist/src/derived-core.d.ts +487 -24
  31. package/dist/src/derived-core.js +788 -144
  32. package/dist/src/derived-real.d.ts +13 -0
  33. package/dist/src/derived-real.js +518 -0
  34. package/dist/src/derived.d.ts +35 -1
  35. package/dist/src/derived.js +61 -9
  36. package/dist/src/emit.js +1 -2
  37. package/dist/src/events.d.ts +206 -0
  38. package/dist/src/events.js +341 -0
  39. package/dist/src/executor.d.ts +3 -0
  40. package/dist/src/executor.js +19 -2
  41. package/dist/src/file-response.d.ts +6 -0
  42. package/dist/src/file-response.js +30 -0
  43. package/dist/src/fork.js +3 -2
  44. package/dist/src/git/history.d.ts +7 -0
  45. package/dist/src/git/history.js +24 -0
  46. package/dist/src/git/index.d.ts +1 -0
  47. package/dist/src/git/index.js +1 -0
  48. package/dist/src/git/lfs.d.ts +28 -0
  49. package/dist/src/git/lfs.js +66 -0
  50. package/dist/src/git/objects.js +3 -8
  51. package/dist/src/git/smart-http.d.ts +3 -1
  52. package/dist/src/git/smart-http.js +67 -6
  53. package/dist/src/graphql-wire.d.ts +29 -0
  54. package/dist/src/graphql-wire.js +101 -0
  55. package/dist/src/grpc-wire.d.ts +67 -0
  56. package/dist/src/grpc-wire.js +170 -0
  57. package/dist/src/h2.d.ts +40 -0
  58. package/dist/src/h2.js +656 -0
  59. package/dist/src/head.d.ts +32 -3
  60. package/dist/src/head.js +161 -40
  61. package/dist/src/history.d.ts +1 -1
  62. package/dist/src/history.js +6 -6
  63. package/dist/src/hpack.json +1 -0
  64. package/dist/src/index.d.ts +64 -75
  65. package/dist/src/index.js +58 -101
  66. package/dist/src/log.js +28 -19
  67. package/dist/src/machines.d.ts +50 -0
  68. package/dist/src/machines.js +151 -0
  69. package/dist/src/managed-database.d.ts +86 -0
  70. package/dist/src/managed-database.js +283 -0
  71. package/dist/src/multipart.d.ts +11 -0
  72. package/dist/src/multipart.js +51 -0
  73. package/dist/src/observe.d.ts +15 -5
  74. package/dist/src/observe.js +23 -9
  75. package/dist/src/openai-wire.d.ts +108 -0
  76. package/dist/src/openai-wire.js +337 -0
  77. package/dist/src/pack-assets.d.ts +3 -4
  78. package/dist/src/pack-assets.js +15 -10
  79. package/dist/src/pack-fetch.d.ts +77 -0
  80. package/dist/src/pack-fetch.js +449 -0
  81. package/dist/src/pack-paths.d.ts +12 -0
  82. package/dist/src/pack-paths.js +86 -0
  83. package/dist/src/packRegistry.d.ts +69 -162
  84. package/dist/src/packRegistry.js +55 -20
  85. package/dist/src/people.d.ts +13 -0
  86. package/dist/src/people.js +18 -0
  87. package/dist/src/placeholder-image.d.ts +5 -0
  88. package/dist/src/placeholder-image.js +114 -0
  89. package/dist/src/protobuf.d.ts +28 -0
  90. package/dist/src/protobuf.js +332 -0
  91. package/dist/src/redis/engine.js +1 -1
  92. package/dist/src/request-scope.d.ts +1 -1
  93. package/dist/src/request-scope.js +6 -4
  94. package/dist/src/resource-blob.d.ts +5 -0
  95. package/dist/src/resource-blob.js +11 -0
  96. package/dist/src/runtime.d.ts +85 -0
  97. package/dist/src/runtime.js +104 -0
  98. package/dist/src/s3/wire.d.ts +60 -0
  99. package/dist/src/s3/wire.js +157 -0
  100. package/dist/src/scenario.d.ts +3 -0
  101. package/dist/src/scenario.js +2 -0
  102. package/dist/src/schema-sample.d.ts +1 -0
  103. package/dist/src/schema-sample.js +21 -0
  104. package/dist/src/sealed-box.d.ts +14 -0
  105. package/dist/src/sealed-box.js +225 -0
  106. package/dist/src/serve-http.d.ts +14 -0
  107. package/dist/src/serve-http.js +27 -3
  108. package/dist/src/serve.d.ts +6 -0
  109. package/dist/src/serve.js +69 -14
  110. package/dist/src/signing.d.ts +135 -0
  111. package/dist/src/signing.js +222 -0
  112. package/dist/src/sigv4.d.ts +48 -0
  113. package/dist/src/sigv4.js +167 -0
  114. package/dist/src/smtp.d.ts +16 -0
  115. package/dist/src/smtp.js +72 -0
  116. package/dist/src/sockets.d.ts +51 -0
  117. package/dist/src/sockets.js +90 -0
  118. package/dist/src/state-system.d.ts +1 -0
  119. package/dist/src/state-system.js +1 -1
  120. package/dist/src/storage.d.ts +1 -1
  121. package/dist/src/storage.js +3 -3
  122. package/dist/src/trace-context.js +1 -1
  123. package/dist/src/twin-fetch.d.ts +0 -7
  124. package/dist/src/twin-fetch.js +0 -14
  125. package/dist/src/vendor-call.d.ts +6 -0
  126. package/dist/src/vendor-call.js +41 -0
  127. package/dist/src/world-store.js +1 -1
  128. package/dist/vendor-hosts.cjs +36 -125
  129. package/dist/vendor-hosts.d.cts +8 -0
  130. package/generated/pack-facts.json +1410 -3069
  131. package/inject.cjs +64 -9
  132. package/pack-facts.cjs +44 -0
  133. package/package.json +17 -3
  134. package/src/actions.ts +23 -16
  135. package/src/ancestry.ts +74 -2
  136. package/src/anthropic-wire.ts +137 -0
  137. package/src/bytes.ts +42 -0
  138. package/src/changeset.ts +5 -5
  139. package/src/clickhouse/index.ts +6 -0
  140. package/src/clickhouse/sql.ts +3059 -0
  141. package/src/clickhouse/types.ts +44 -0
  142. package/src/clickhouse/values.ts +697 -0
  143. package/src/client-bundle.ts +2 -3
  144. package/src/cors.ts +34 -0
  145. package/src/derived-core.ts +1013 -146
  146. package/src/derived-real.ts +434 -0
  147. package/src/derived.ts +73 -3
  148. package/src/emit.ts +1 -2
  149. package/src/events.ts +449 -0
  150. package/src/executor.ts +24 -2
  151. package/src/file-response.ts +27 -0
  152. package/src/fork.ts +3 -2
  153. package/src/git/history.ts +19 -0
  154. package/src/git/index.ts +1 -0
  155. package/src/git/lfs.ts +67 -0
  156. package/src/git/objects.ts +3 -5
  157. package/src/git/smart-http.ts +56 -6
  158. package/src/graphql-wire.ts +106 -0
  159. package/src/grpc-wire.ts +159 -0
  160. package/src/h2.ts +627 -0
  161. package/src/head.ts +132 -41
  162. package/src/history.ts +6 -6
  163. package/src/hpack.json +1 -0
  164. package/src/index.ts +82 -329
  165. package/src/log.ts +27 -18
  166. package/src/machines.ts +151 -0
  167. package/src/managed-database.ts +299 -0
  168. package/src/multipart.ts +51 -0
  169. package/src/observe.ts +31 -15
  170. package/src/openai-wire.ts +371 -0
  171. package/src/pack-assets.ts +15 -11
  172. package/src/pack-fetch.ts +458 -0
  173. package/src/pack-paths.ts +72 -0
  174. package/src/packRegistry.ts +79 -167
  175. package/src/people.ts +31 -0
  176. package/src/placeholder-image.ts +88 -0
  177. package/src/protobuf.ts +251 -0
  178. package/src/redis/engine.ts +1 -1
  179. package/src/request-scope.ts +8 -4
  180. package/src/resource-blob.ts +13 -0
  181. package/src/runtime.ts +344 -0
  182. package/src/s3/wire.ts +172 -0
  183. package/src/scenario.ts +4 -0
  184. package/src/schema-sample.ts +24 -0
  185. package/src/sealed-box.ts +182 -0
  186. package/src/serve-http.ts +31 -3
  187. package/src/serve.ts +58 -14
  188. package/src/signing.ts +231 -0
  189. package/src/sigv4.ts +158 -0
  190. package/src/smtp.ts +76 -0
  191. package/src/sockets.ts +140 -0
  192. package/src/state-system.ts +2 -2
  193. package/src/storage.ts +3 -3
  194. package/src/trace-context.ts +1 -1
  195. package/src/twin-fetch.ts +0 -20
  196. package/src/vendor-call.ts +41 -0
  197. package/src/world-store.ts +1 -1
  198. package/vendor-hosts.cjs +36 -125
  199. package/vendor-hosts.d.cts +8 -0
  200. package/dist/src/mirror-shell.d.ts +0 -2
  201. package/dist/src/mirror-shell.js +0 -13
  202. package/dist/src/v1-removed.d.ts +0 -159
  203. package/dist/src/v1-removed.js +0 -124
  204. package/src/mirror-shell.ts +0 -15
  205. package/src/v1-removed.ts +0 -172
@@ -0,0 +1,18 @@
1
+ export type ClickHouseColumn = {
2
+ name: string;
3
+ type: string;
4
+ jsonpath?: string;
5
+ defaultExpr?: string;
6
+ };
7
+ export declare const INT_TYPES: Set<string>;
8
+ export declare const UINT_TYPES: Set<string>;
9
+ export declare const FLOAT_TYPES: Set<string>;
10
+ /** Strip the wrappers a schema line may carry, reporting what they said. */
11
+ export declare function unwrapType(type: string): {
12
+ base: string;
13
+ nullable: boolean;
14
+ array: boolean;
15
+ };
16
+ /** Type names this twin recognises in a `schema` parameter. An UNKNOWN name is refused rather than
17
+ * stored verbatim: a Data Source whose column type is a typo would validate nothing forever. */
18
+ export declare function isModeledSchemaType(type: string): boolean;
@@ -0,0 +1,47 @@
1
+ export const INT_TYPES = new Set(['Int8', 'Int16', 'Int32', 'Int64', 'Int128', 'Int256']);
2
+ export const UINT_TYPES = new Set(['UInt8', 'UInt16', 'UInt32', 'UInt64', 'UInt128', 'UInt256']);
3
+ export const FLOAT_TYPES = new Set(['Float32', 'Float64']);
4
+ /** Strip the wrappers a schema line may carry, reporting what they said. */
5
+ export function unwrapType(type) {
6
+ let t = type.trim();
7
+ let nullable = false;
8
+ let array = false;
9
+ // LowCardinality is a storage hint, not a value domain — peel it and keep going.
10
+ for (let guard = 0; guard < 4; guard++) {
11
+ const low = /^LowCardinality\((.*)\)$/s.exec(t);
12
+ if (low) {
13
+ t = low[1].trim();
14
+ continue;
15
+ }
16
+ const nul = /^Nullable\((.*)\)$/s.exec(t);
17
+ if (nul) {
18
+ nullable = true;
19
+ t = nul[1].trim();
20
+ continue;
21
+ }
22
+ const arr = /^Array\((.*)\)$/s.exec(t);
23
+ if (arr) {
24
+ array = true;
25
+ t = arr[1].trim();
26
+ continue;
27
+ }
28
+ break;
29
+ }
30
+ return { base: t, nullable, array };
31
+ }
32
+ /** Type names this twin recognises in a `schema` parameter. An UNKNOWN name is refused rather than
33
+ * stored verbatim: a Data Source whose column type is a typo would validate nothing forever. */
34
+ export function isModeledSchemaType(type) {
35
+ const { base } = unwrapType(type);
36
+ const head = base.replace(/\(.*\)$/s, '').trim();
37
+ if (KNOWN_TYPE_HEADS.has(head))
38
+ return true;
39
+ return false;
40
+ }
41
+ const KNOWN_TYPE_HEADS = new Set([
42
+ ...INT_TYPES, ...UINT_TYPES, ...FLOAT_TYPES,
43
+ 'String', 'FixedString', 'UUID', 'IPv4', 'IPv6', 'Bool', 'Boolean',
44
+ 'Date', 'Date32', 'DateTime', 'DateTime64', 'JSON',
45
+ 'Decimal', 'Decimal32', 'Decimal64', 'Decimal128', 'Decimal256',
46
+ 'Enum', 'Enum8', 'Enum16', 'Map', 'Tuple', 'Nested', 'AggregateFunction', 'SimpleAggregateFunction',
47
+ ]);
@@ -0,0 +1,146 @@
1
+ /**
2
+ * A DateTime or DateTime64 value: an instant held as exact integer ticks — whole milliseconds since
3
+ * the epoch (`ms`) plus the nanoseconds inside that millisecond (`ns`, 0…999 999) — its scale (the
4
+ * `p` of `DateTime64(p)`, 0 for DateTime) and a display zone. ClickHouse stores DateTime64(p) as an
5
+ * Int64 count of 10^-p second ticks, so every value is truncated to its scale on construction
6
+ * (`makeDT`) and compares exactly.
7
+ */
8
+ export declare class DT {
9
+ readonly ms: number;
10
+ readonly scale: number;
11
+ readonly tz?: string | undefined;
12
+ readonly ns: number;
13
+ constructor(ms: number, scale: number, tz?: string | undefined, ns?: number);
14
+ withTz(tz: string | undefined, scale?: number): DT;
15
+ }
16
+ /** A DT truncated to `scale` digits (ClickHouse's DateTime64 tick), with `ns` normalised into `ms`. */
17
+ export declare function makeDT(ms: number, ns: number, scale: number, tz?: string): DT;
18
+ /** Two instants' order, exactly (ms first, then the sub-millisecond nanoseconds). */
19
+ export declare function compareDT(a: DT, b: DT): number;
20
+ /** A bigint as the engine carries it: a number when safe, else the bigint. */
21
+ export declare function normInt(v: bigint): number | bigint;
22
+ /** Wrap an integer into a sized ClickHouse integer type (two's complement, as CAST/toIntN do). */
23
+ export declare function wrapInt(v: bigint, type: string): number | bigint;
24
+ /** An engine value as an exact integer (a float truncates toward zero, as ClickHouse's cast does). */
25
+ export declare function toBigInt(v: unknown, type?: string): bigint;
26
+ /** Is this an integer type of 64 bits or more (the ones `output_format_json_quote_64bit_integers` quotes)? */
27
+ export declare function isWideIntegerType(type: string): boolean;
28
+ /** JSON.stringify that writes a bigint as a bare JSON number (ClickHouse's unquoted 64-bit output). */
29
+ export declare function stringifyJson(value: unknown): string;
30
+ /** A Date value: a calendar day (days since 1970-01-01), no zone. */
31
+ export declare class DDate {
32
+ readonly days: number;
33
+ constructor(days: number);
34
+ }
35
+ export type IntervalUnit = 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year';
36
+ export declare class Interval {
37
+ readonly unit: IntervalUnit;
38
+ readonly n: number;
39
+ constructor(unit: IntervalUnit, n: number);
40
+ }
41
+ /** A `Map(K, V)` value: its entries in the order they were written (a ClickHouse Map keeps its entries as an array of
42
+ * pairs, https://clickhouse.com/docs/sql-reference/data-types/map). Stored as a JSON object of the entries. */
43
+ export declare class ChMap {
44
+ readonly entries: Array<[unknown, unknown]>;
45
+ constructor(entries: Array<[unknown, unknown]>);
46
+ }
47
+ /** An aggregate function's intermediate state (`minState(x)` → `AggregateFunction(min, T)`). */
48
+ export declare class AggState {
49
+ readonly fn: string;
50
+ readonly value: unknown;
51
+ constructor(fn: string, value: unknown);
52
+ }
53
+ export declare const SERVER_TZ = "UTC";
54
+ /** A query the twin refuses, carrying the status + message the vendor answers with. */
55
+ export declare class ClickHouseError extends Error {
56
+ readonly status: number;
57
+ constructor(message: string, status?: number);
58
+ }
59
+ export { ClickHouseError as EngineError };
60
+ export type Wall = {
61
+ y: number;
62
+ mo: number;
63
+ d: number;
64
+ h: number;
65
+ mi: number;
66
+ s: number;
67
+ ms: number;
68
+ };
69
+ /** The wall-clock fields of an instant in a zone. */
70
+ export declare function wallOf(ms: number, tz?: string): Wall;
71
+ /** The zone's UTC offset at an instant, in ms (local − UTC). */
72
+ export declare function offsetMs(ms: number, tz?: string): number;
73
+ /**
74
+ * The instant a wall-clock time names in a zone. ClickHouse's DateLUT (`makeDateTime`) adds the
75
+ * time of day to the day's start and, from the offset-change moment on, subtracts the change: a
76
+ * wall time inside a spring-forward gap therefore lands BEFORE the gap (`2024-03-10 02:30:00` in
77
+ * America/New_York reads back as `01:30:00` — clickhouse-local 26.10 answers the same), and a
78
+ * repeated fall-back hour resolves to its first occurrence. Two offset probes reproduce both.
79
+ */
80
+ export declare function instantOf(w: Wall, tz?: string): number;
81
+ export declare function daysFromCivil(y: number, mo: number, d: number): number;
82
+ export declare function civilFromDays(days: number): {
83
+ y: number;
84
+ mo: number;
85
+ d: number;
86
+ };
87
+ /** Parse ClickHouse datetime text (and the ISO forms Tinybird's ingest accepts) in a zone, exactly:
88
+ * whole milliseconds plus the nanoseconds a DateTime64(4…9) fraction carries. */
89
+ export declare function parseDateTimeInstant(text: string, tz?: string): {
90
+ ms: number;
91
+ ns: number;
92
+ } | undefined;
93
+ export declare function parseDateText(text: string): number | undefined;
94
+ export declare function formatDate(d: DDate): string;
95
+ export declare function formatDT(v: DT): string;
96
+ /** A DT as a Data Source stores it: wall-clock text in the column's zone, with the zone's offset
97
+ * when that zone is not UTC (so an instant inside a repeated DST hour survives a round trip). */
98
+ export declare function formatStoredDT(v: DT): string;
99
+ /** `formatDateTime(t, fmt)` — ClickHouse's MySQL-style specifiers. */
100
+ export declare function formatDateTimePattern(v: DT | DDate, fmt: string, tz?: string): string;
101
+ /** Peel `LowCardinality(…)` and `Nullable(…)`. */
102
+ export declare function baseType(type: string): {
103
+ base: string;
104
+ nullable: boolean;
105
+ };
106
+ export declare function typeHead(type: string): string;
107
+ /** Split a parameterised type's top-level arguments: `Array(Nullable(String))` → [`Nullable(String)`]. */
108
+ export declare function typeArgs(type: string): string[];
109
+ export declare function isNullableType(type: string): boolean;
110
+ export declare function isIntegerType(type: string): boolean;
111
+ export declare function isUnsignedType(type: string): boolean;
112
+ export declare function isFloatType(type: string): boolean;
113
+ export declare function isNumberType(type: string): boolean;
114
+ /** The zone a `DateTime('tz')` / `DateTime64(n, 'tz')` type names, if any. */
115
+ export declare function typeZone(type: string): string | undefined;
116
+ export declare function typeScale(type: string): number;
117
+ /** A non-Nullable column's default value. */
118
+ export declare function defaultOf(type: string): unknown;
119
+ export type AggKind = 'scalar' | 'sum' | 'avg' | 'set' | 'list' | 'arg';
120
+ export declare function aggKind(fn: string): AggKind | undefined;
121
+ /** A stored (JSON) cell → the engine value for its column type. */
122
+ export declare function fromStored(value: unknown, type: string): unknown;
123
+ /**
124
+ * An engine value → the JSON a Data Source stores for its column type (a materialized view's
125
+ * insert). The value is CAST to the column type the way ClickHouse converts an INSERT … SELECT
126
+ * block: integers wrap to the column's width (`CAST(300 AS UInt8)` = 44) and a string that is not
127
+ * an integer is ClickHouse's parse error, which fails the insert.
128
+ */
129
+ export declare function toStored(value: unknown, type: string): unknown;
130
+ export declare function castDateTime(value: unknown, scale: number, tz?: string): DT;
131
+ /** `toString(x)` — ClickHouse's text form of a value. */
132
+ export declare function valueToText(value: unknown): string;
133
+ /** An element inside an array's text form: strings, dates and times are single-quoted and escaped. */
134
+ export declare function quotedText(v: unknown): string;
135
+ /** An engine value → the JSON a `.json` response carries (a bigint stays exact). */
136
+ export declare function toOutput(value: unknown): unknown;
137
+ /**
138
+ * Compare two non-null values ClickHouse-style. A string meeting a DateTime/Date is parsed in the
139
+ * other side's zone (ClickHouse converts the literal to the column's type).
140
+ */
141
+ export declare function compareValues(a: unknown, b: unknown): number;
142
+ export declare function valuesEqual(a: unknown, b: unknown): boolean;
143
+ /** A hash key under which equal values collide (for GROUP BY, JOIN, IN, uniq). */
144
+ export declare function valueKey(v: unknown): string;
145
+ /** A string literal meeting a DateTime in a hash key must hash as the instant. */
146
+ export declare function valueKeyAs(v: unknown, like: unknown): string;