@draht/chord 2026.10.20 → 2026.10.23

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 (220) hide show
  1. package/dist/cell.d.ts +122 -0
  2. package/dist/cell.d.ts.map +1 -0
  3. package/dist/cell.js +356 -0
  4. package/dist/cell.js.map +1 -0
  5. package/dist/cluster.d.ts +27 -0
  6. package/dist/cluster.d.ts.map +1 -0
  7. package/dist/cluster.js +230 -0
  8. package/dist/cluster.js.map +1 -0
  9. package/dist/connection.d.ts +270 -0
  10. package/dist/connection.d.ts.map +1 -0
  11. package/dist/connection.js +1216 -0
  12. package/dist/connection.js.map +1 -0
  13. package/dist/context/index.d.ts +20 -1
  14. package/dist/context/index.d.ts.map +1 -1
  15. package/dist/context/index.js +15 -0
  16. package/dist/context/index.js.map +1 -1
  17. package/dist/contract.d.ts +208 -0
  18. package/dist/contract.d.ts.map +1 -0
  19. package/dist/contract.js +246 -0
  20. package/dist/contract.js.map +1 -0
  21. package/dist/declare.d.ts +33 -0
  22. package/dist/declare.d.ts.map +1 -0
  23. package/dist/declare.js +2 -0
  24. package/dist/declare.js.map +1 -0
  25. package/dist/delta/apply-immutable-trusted.js.map +1 -1
  26. package/dist/delta/diff.d.ts +1 -1
  27. package/dist/delta/diff.d.ts.map +1 -1
  28. package/dist/delta/diff.js.map +1 -1
  29. package/dist/delta/index.d.ts +4 -3
  30. package/dist/delta/index.d.ts.map +1 -1
  31. package/dist/delta/index.js +45 -0
  32. package/dist/delta/index.js.map +1 -1
  33. package/dist/delta/revision-validator.d.ts +1 -1
  34. package/dist/delta/revision-validator.d.ts.map +1 -1
  35. package/dist/delta/revision-validator.js.map +1 -1
  36. package/dist/delta/tracker.d.ts +1 -1
  37. package/dist/delta/tracker.d.ts.map +1 -1
  38. package/dist/delta/tracker.js +40 -4
  39. package/dist/delta/tracker.js.map +1 -1
  40. package/dist/errors.d.ts +28 -0
  41. package/dist/errors.d.ts.map +1 -0
  42. package/dist/errors.js +59 -0
  43. package/dist/errors.js.map +1 -0
  44. package/dist/host.d.ts +348 -0
  45. package/dist/host.d.ts.map +1 -0
  46. package/dist/host.js +1000 -0
  47. package/dist/host.js.map +1 -0
  48. package/dist/index.d.ts +17 -10
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/index.js +8 -8
  51. package/dist/index.js.map +1 -1
  52. package/dist/json.d.ts +9 -1
  53. package/dist/json.d.ts.map +1 -1
  54. package/dist/json.js.map +1 -1
  55. package/dist/link.d.ts +109 -0
  56. package/dist/link.d.ts.map +1 -0
  57. package/dist/link.js +375 -0
  58. package/dist/link.js.map +1 -0
  59. package/dist/loader.d.ts +4 -0
  60. package/dist/loader.d.ts.map +1 -0
  61. package/dist/loader.js +73 -0
  62. package/dist/loader.js.map +1 -0
  63. package/dist/manager.d.ts +115 -0
  64. package/dist/manager.d.ts.map +1 -0
  65. package/dist/manager.js +345 -0
  66. package/dist/manager.js.map +1 -0
  67. package/dist/node.d.ts +3 -4
  68. package/dist/node.d.ts.map +1 -1
  69. package/dist/node.js +3 -2
  70. package/dist/node.js.map +1 -1
  71. package/dist/object.d.ts +438 -0
  72. package/dist/object.d.ts.map +1 -0
  73. package/dist/object.js +1571 -0
  74. package/dist/object.js.map +1 -0
  75. package/dist/output.d.ts +91 -0
  76. package/dist/output.d.ts.map +1 -0
  77. package/dist/output.js +360 -0
  78. package/dist/output.js.map +1 -0
  79. package/dist/publish.d.ts +5 -0
  80. package/dist/publish.d.ts.map +1 -0
  81. package/dist/publish.js +40 -0
  82. package/dist/publish.js.map +1 -0
  83. package/dist/registry.d.ts +25 -0
  84. package/dist/registry.d.ts.map +1 -0
  85. package/dist/registry.js +6 -0
  86. package/dist/registry.js.map +1 -0
  87. package/dist/reload.d.ts +126 -0
  88. package/dist/reload.d.ts.map +1 -0
  89. package/dist/reload.js +653 -0
  90. package/dist/reload.js.map +1 -0
  91. package/dist/remote.d.ts +165 -0
  92. package/dist/remote.d.ts.map +1 -0
  93. package/dist/remote.js +612 -0
  94. package/dist/remote.js.map +1 -0
  95. package/dist/schema.d.ts +21 -0
  96. package/dist/schema.d.ts.map +1 -0
  97. package/dist/schema.js +228 -0
  98. package/dist/schema.js.map +1 -0
  99. package/dist/sqlite/cloudflare.d.ts +52 -0
  100. package/dist/sqlite/cloudflare.d.ts.map +1 -0
  101. package/dist/sqlite/cloudflare.js +134 -0
  102. package/dist/sqlite/cloudflare.js.map +1 -0
  103. package/dist/sqlite/database.d.ts +37 -0
  104. package/dist/sqlite/database.d.ts.map +1 -0
  105. package/dist/sqlite/database.js +2 -0
  106. package/dist/sqlite/database.js.map +1 -0
  107. package/dist/sqlite/index.d.ts +4 -0
  108. package/dist/sqlite/index.d.ts.map +1 -0
  109. package/dist/sqlite/index.js +3 -0
  110. package/dist/sqlite/index.js.map +1 -0
  111. package/dist/sqlite/migrations.d.ts +10 -0
  112. package/dist/sqlite/migrations.d.ts.map +1 -0
  113. package/dist/sqlite/migrations.js +33 -0
  114. package/dist/sqlite/migrations.js.map +1 -0
  115. package/dist/sqlite/node.d.ts +38 -0
  116. package/dist/sqlite/node.d.ts.map +1 -0
  117. package/dist/sqlite/node.js +174 -0
  118. package/dist/sqlite/node.js.map +1 -0
  119. package/dist/sqlite/schema.d.ts +3 -0
  120. package/dist/sqlite/schema.d.ts.map +1 -0
  121. package/dist/sqlite/schema.js +10 -0
  122. package/dist/sqlite/schema.js.map +1 -0
  123. package/dist/state.d.ts +92 -0
  124. package/dist/state.d.ts.map +1 -0
  125. package/dist/{services/state.js → state.js} +28 -138
  126. package/dist/state.js.map +1 -0
  127. package/dist/telemetry-sqlite/index.d.ts +24 -0
  128. package/dist/telemetry-sqlite/index.d.ts.map +1 -0
  129. package/dist/telemetry-sqlite/index.js +273 -0
  130. package/dist/telemetry-sqlite/index.js.map +1 -0
  131. package/dist/telemetry-sqlite/store.d.ts +9 -0
  132. package/dist/telemetry-sqlite/store.d.ts.map +1 -0
  133. package/dist/telemetry-sqlite/store.js +110 -0
  134. package/dist/telemetry-sqlite/store.js.map +1 -0
  135. package/dist/types.d.ts +69 -254
  136. package/dist/types.d.ts.map +1 -1
  137. package/dist/types.js.map +1 -1
  138. package/dist/websocket.d.ts +15 -0
  139. package/dist/websocket.d.ts.map +1 -0
  140. package/dist/websocket.js +16 -0
  141. package/dist/websocket.js.map +1 -0
  142. package/dist/wire.d.ts +216 -0
  143. package/dist/wire.d.ts.map +1 -0
  144. package/dist/wire.js +165 -0
  145. package/dist/wire.js.map +1 -0
  146. package/docs/guide.md +814 -0
  147. package/docs/spec.md +288 -0
  148. package/docs/tutorial.md +931 -0
  149. package/package.json +36 -12
  150. package/dist/api.d.ts +0 -20
  151. package/dist/api.d.ts.map +0 -1
  152. package/dist/api.js +0 -77
  153. package/dist/api.js.map +0 -1
  154. package/dist/bundler.d.ts +0 -6
  155. package/dist/bundler.d.ts.map +0 -1
  156. package/dist/bundler.js +0 -3
  157. package/dist/bundler.js.map +0 -1
  158. package/dist/facets/host.d.ts +0 -12
  159. package/dist/facets/host.d.ts.map +0 -1
  160. package/dist/facets/host.js +0 -763
  161. package/dist/facets/host.js.map +0 -1
  162. package/dist/facets/loader.d.ts +0 -3
  163. package/dist/facets/loader.d.ts.map +0 -1
  164. package/dist/facets/loader.js +0 -5
  165. package/dist/facets/loader.js.map +0 -1
  166. package/dist/node/bundle-loader.d.ts +0 -30
  167. package/dist/node/bundle-loader.d.ts.map +0 -1
  168. package/dist/node/bundle-loader.js +0 -377
  169. package/dist/node/bundle-loader.js.map +0 -1
  170. package/dist/node/bundle.d.ts +0 -26
  171. package/dist/node/bundle.d.ts.map +0 -1
  172. package/dist/node/bundle.js +0 -183
  173. package/dist/node/bundle.js.map +0 -1
  174. package/dist/node/manifest.d.ts +0 -36
  175. package/dist/node/manifest.d.ts.map +0 -1
  176. package/dist/node/manifest.js +0 -6
  177. package/dist/node/manifest.js.map +0 -1
  178. package/dist/node/package.d.ts +0 -15
  179. package/dist/node/package.d.ts.map +0 -1
  180. package/dist/node/package.js +0 -199
  181. package/dist/node/package.js.map +0 -1
  182. package/dist/services/consumer.d.ts +0 -11
  183. package/dist/services/consumer.d.ts.map +0 -1
  184. package/dist/services/consumer.js +0 -585
  185. package/dist/services/consumer.js.map +0 -1
  186. package/dist/services/errors.d.ts +0 -8
  187. package/dist/services/errors.d.ts.map +0 -1
  188. package/dist/services/errors.js +0 -22
  189. package/dist/services/errors.js.map +0 -1
  190. package/dist/services/handle.d.ts +0 -15
  191. package/dist/services/handle.d.ts.map +0 -1
  192. package/dist/services/handle.js +0 -101
  193. package/dist/services/handle.js.map +0 -1
  194. package/dist/services/instances.d.ts +0 -26
  195. package/dist/services/instances.d.ts.map +0 -1
  196. package/dist/services/instances.js +0 -140
  197. package/dist/services/instances.js.map +0 -1
  198. package/dist/services/loopback.d.ts +0 -5
  199. package/dist/services/loopback.d.ts.map +0 -1
  200. package/dist/services/loopback.js +0 -15
  201. package/dist/services/loopback.js.map +0 -1
  202. package/dist/services/provider.d.ts +0 -37
  203. package/dist/services/provider.d.ts.map +0 -1
  204. package/dist/services/provider.js +0 -521
  205. package/dist/services/provider.js.map +0 -1
  206. package/dist/services/state-codec.d.ts +0 -15
  207. package/dist/services/state-codec.d.ts.map +0 -1
  208. package/dist/services/state-codec.js +0 -133
  209. package/dist/services/state-codec.js.map +0 -1
  210. package/dist/services/state-internals.d.ts +0 -13
  211. package/dist/services/state-internals.d.ts.map +0 -1
  212. package/dist/services/state-internals.js +0 -10
  213. package/dist/services/state-internals.js.map +0 -1
  214. package/dist/services/state.d.ts +0 -28
  215. package/dist/services/state.d.ts.map +0 -1
  216. package/dist/services/state.js.map +0 -1
  217. package/dist/services/wire.d.ts +0 -63
  218. package/dist/services/wire.d.ts.map +0 -1
  219. package/dist/services/wire.js +0 -186
  220. package/dist/services/wire.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/telemetry-sqlite/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAE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YACC,OAAO,EAAE,CAAC;YACV,UAAU,EAAE;gBACX;kFAC6E;gBAC7E,oEAAoE;gBACpE,qFAAqF;gBACrF,wEAAwE;gBACxE;kHAC6G;aAC7G;SACD;KACD,EACD,EAAE,KAAK,EAAE,kBAAkB,EAAE,CAC7B,CAAC;IACF,OAAO,IAAI,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;AAC9C,CAAC","sourcesContent":["import {\n\ttype InstrumentOptions,\n\tNOOP_TELEMETRY_CONTEXT,\n\ttype SpanAttributes,\n\ttype SpanLink,\n\ttype SpanOptions,\n\ttype SpanStatus,\n\ttype TelemetryCarrier,\n\ttype TelemetryContext,\n\ttype TelemetryMetrics,\n\ttype TelemetryPropagation,\n\ttype TelemetrySpan,\n\ttype TelemetryStore,\n} from \"@draht/telemetry\";\nimport { applySqliteMigrations, type SqliteDatabase, type SqliteValue } from \"../sqlite/index.ts\";\nimport { findMetrics, findTraces, getTrace } from \"./store.ts\";\n\nexport interface SqliteTelemetryOptions {\n\t/** Retain seven days by default. Cleanup runs in the flush transaction. */\n\treadonly retentionMs?: number;\n\t/** Settled spans awaiting commit, including the in-flight batch. Defaults to 10,000.\n\t * Also bounds pending metric interval/series pairs independently. */\n\treadonly maxQueuedSpans?: number;\n}\n\nexport interface SqliteTelemetry extends TelemetryContext, TelemetryStore {\n\treadonly metrics: TelemetryMetrics;\n\treadonly propagation: TelemetryPropagation;\n\treadonly droppedSpans: number;\n\treadonly droppedMeasurements: number;\n\t/** Persist settled spans and completed ten-second metric intervals. */\n\tflush(): Promise<void>;\n\t/** Stop recording and drain, including partial metric intervals. Does not close the database. */\n\tclose(): Promise<void>;\n}\n\ntype Identity = { id: string; traceId: string };\ntype Link = { trace_id: string; span_id: string; attributes?: SpanAttributes };\ntype Metric = {\n\tinterval: number;\n\tkey: string;\n\tname: string;\n\tkind: \"counter\" | \"upDownCounter\" | \"histogram\";\n\tunit: string | null;\n\tattributes: string;\n\tcount: number;\n\tsum: number;\n\tmin: number;\n\tmax: number;\n};\nconst identities = new WeakMap<TelemetryContext, Identity>();\nconst carrierKey = \"pi-sqlite-span\";\nconst traceKey = \"pi-sqlite-trace\";\nconst intervalMs = 10_000;\n\nfunction copyAttributes(attributes?: SpanAttributes): SpanAttributes {\n\treturn Object.fromEntries(\n\t\tObject.entries(attributes ?? {})\n\t\t\t.filter(([, value]) => value !== undefined)\n\t\t\t.map(([key, value]) => [key, Array.isArray(value) ? [...value] : value]),\n\t);\n}\n\nfunction copyLink(link: SpanLink): Link | undefined {\n\tconst identity = identities.get(link.context);\n\treturn identity\n\t\t? { trace_id: identity.traceId, span_id: identity.id, attributes: copyAttributes(link.attributes) }\n\t\t: undefined;\n}\n\nclass Recorder implements SqliteTelemetry, TelemetryPropagation {\n\treadonly propagation: TelemetryPropagation = this;\n\treadonly metrics: TelemetryMetrics = {\n\t\tcounter: (name, options) => ({ add: this.measurement(\"counter\", name, options) }),\n\t\tupDownCounter: (name, options) => ({ add: this.measurement(\"upDownCounter\", name, options) }),\n\t\thistogram: (name, options) => ({ record: this.measurement(\"histogram\", name, options) }),\n\t};\n\tdroppedSpans = 0;\n\tdroppedMeasurements = 0;\n\tprivate readonly db: SqliteDatabase;\n\tprivate readonly retention: number;\n\tprivate readonly capacity: number;\n\tprivate readonly scope = crypto.randomUUID();\n\tprivate sequence = 0;\n\tprivate readonly spans: SqliteValue[][] = [];\n\tprivate readonly measurements = new Map<string, Metric>();\n\tprivate inFlightMeasurements = 0;\n\tprivate readonly timer: ReturnType<typeof setInterval>;\n\tprivate stopped = false;\n\tprivate failed = false;\n\tprivate failure: unknown;\n\tprivate writing?: Promise<void>;\n\tprivate closing?: Promise<void>;\n\n\tconstructor(db: SqliteDatabase, retention: number, capacity: number) {\n\t\tthis.db = db;\n\t\tthis.retention = retention;\n\t\tthis.capacity = capacity;\n\t\tthis.timer = setInterval(() => {\n\t\t\tif (!this.writing) void this.flush().catch(() => {});\n\t\t}, 1000);\n\t\tthis.timer.unref?.();\n\t}\n\n\tstartSpan<T>(options: SpanOptions, callback: (span: TelemetrySpan) => T | Promise<T>): Promise<T> {\n\t\treturn this.start(undefined, options, callback);\n\t}\n\n\tinject(context: TelemetryContext): TelemetryCarrier | undefined {\n\t\tconst identity = identities.get(context);\n\t\treturn identity ? { [carrierKey]: identity.id, [traceKey]: identity.traceId } : undefined;\n\t}\n\n\textract(carrier: TelemetryCarrier | undefined): TelemetryContext {\n\t\tconst id = carrier?.[carrierKey];\n\t\tconst traceId = carrier?.[traceKey];\n\t\tif (typeof id !== \"string\" || typeof traceId !== \"string\") return this;\n\t\tconst identity = { id, traceId };\n\t\tconst parent: TelemetryContext = {\n\t\t\tmetrics: this.metrics,\n\t\t\tpropagation: this,\n\t\t\tstartSpan: (options, callback) => this.start(identity, options, callback),\n\t\t};\n\t\tidentities.set(parent, identity);\n\t\treturn parent;\n\t}\n\n\tprivate inert<T>(options: SpanOptions, callback: (span: TelemetrySpan) => T | Promise<T>): Promise<T> {\n\t\treturn NOOP_TELEMETRY_CONTEXT.startSpan(options, (noop) =>\n\t\t\tcallback({\n\t\t\t\t...noop,\n\t\t\t\tmetrics: this.metrics,\n\t\t\t\tpropagation: this,\n\t\t\t\tstartSpan: (options, callback) => this.inert(options, callback),\n\t\t\t}),\n\t\t);\n\t}\n\n\tprivate async start<T>(\n\t\tparent: Identity | undefined,\n\t\toptions: SpanOptions,\n\t\tcallback: (span: TelemetrySpan) => T | Promise<T>,\n\t): Promise<T> {\n\t\tif (this.stopped) return this.inert(options, callback);\n\t\tconst name = options.name;\n\t\tlet attributes = copyAttributes(options.attributes);\n\t\tconst links: Link[] = [];\n\t\tfor (const link of options.links ?? []) {\n\t\t\tconst copied = copyLink(link);\n\t\t\tif (copied) links.push(copied);\n\t\t}\n\t\tconst id = `${this.scope}:${++this.sequence}`;\n\t\tconst identity = { id, traceId: parent?.traceId ?? id };\n\t\tconst started = Date.now();\n\t\tconst clock = performance.now();\n\t\tconst events: { name: string; time_ms: number; attributes: SpanAttributes }[] = [];\n\t\tlet status: SpanStatus = { status: \"ok\" };\n\t\tlet explicit = false;\n\t\tlet settled = false;\n\t\tconst record = (action: () => void): void => {\n\t\t\tif (!settled && !this.stopped) action();\n\t\t};\n\t\tconst span: TelemetrySpan = {\n\t\t\tmetrics: this.metrics,\n\t\t\tpropagation: this,\n\t\t\tstartSpan: (options, callback) =>\n\t\t\t\tsettled ? this.inert(options, callback) : this.start(identity, options, callback),\n\t\t\taddLink: (link) =>\n\t\t\t\trecord(() => {\n\t\t\t\t\tconst copied = copyLink(link);\n\t\t\t\t\tif (copied) links.push(copied);\n\t\t\t\t}),\n\t\t\taddEvent: (name, attrs) =>\n\t\t\t\trecord(() => {\n\t\t\t\t\tevents.push({ name, time_ms: performance.now() - clock, attributes: copyAttributes(attrs) });\n\t\t\t\t}),\n\t\t\tsetAttributes: (attrs) =>\n\t\t\t\trecord(() => {\n\t\t\t\t\tattributes = { ...attributes, ...copyAttributes(attrs) };\n\t\t\t\t}),\n\t\t\tsetStatus: (value) =>\n\t\t\t\trecord(() => {\n\t\t\t\t\tstatus =\n\t\t\t\t\t\tvalue.status === \"error\" && value.error\n\t\t\t\t\t\t\t? { status: \"error\", error: { ...value.error } }\n\t\t\t\t\t\t\t: { status: value.status };\n\t\t\t\t\texplicit = true;\n\t\t\t\t}),\n\t\t};\n\t\tidentities.set(span, identity);\n\t\ttry {\n\t\t\treturn await callback(span);\n\t\t} catch (error) {\n\t\t\tif (!explicit)\n\t\t\t\tstatus =\n\t\t\t\t\terror instanceof Error\n\t\t\t\t\t\t? { status: \"error\", error: { name: error.name, message: error.message } }\n\t\t\t\t\t\t: { status: \"error\" };\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\tsettled = true;\n\t\t\tif (!this.stopped) {\n\t\t\t\tif (this.spans.length >= this.capacity) this.droppedSpans++;\n\t\t\t\telse\n\t\t\t\t\tthis.spans.push([\n\t\t\t\t\t\tid,\n\t\t\t\t\t\tidentity.traceId,\n\t\t\t\t\t\tparent?.id ?? null,\n\t\t\t\t\t\tname,\n\t\t\t\t\t\tstarted,\n\t\t\t\t\t\tstarted + performance.now() - clock,\n\t\t\t\t\t\tJSON.stringify(attributes),\n\t\t\t\t\t\tJSON.stringify(events),\n\t\t\t\t\t\tJSON.stringify(links),\n\t\t\t\t\t\tJSON.stringify(status),\n\t\t\t\t\t]);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate measurement(\n\t\tkind: Metric[\"kind\"],\n\t\tname: string,\n\t\toptions?: InstrumentOptions,\n\t): (value: number, attributes?: SpanAttributes) => void {\n\t\tconst unit = options?.unit ?? null;\n\t\treturn (value, attributes) => {\n\t\t\tif (this.stopped) return;\n\t\t\tconst copied = copyAttributes(attributes);\n\t\t\tconst encoded = JSON.stringify(\n\t\t\t\tObject.fromEntries(\n\t\t\t\t\tObject.keys(copied)\n\t\t\t\t\t\t.sort()\n\t\t\t\t\t\t.map((key) => [key, copied[key]]),\n\t\t\t\t),\n\t\t\t);\n\t\t\tconst key = JSON.stringify([name, kind, unit, encoded]);\n\t\t\tconst interval = Math.floor(Date.now() / intervalMs) * intervalMs;\n\t\t\tconst pendingKey = `${interval}:${key}`;\n\t\t\tconst previous = this.measurements.get(pendingKey);\n\t\t\tif (!previous && this.measurements.size + this.inFlightMeasurements >= this.capacity) {\n\t\t\t\tthis.droppedMeasurements++;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.measurements.set(pendingKey, {\n\t\t\t\tinterval,\n\t\t\t\tkey,\n\t\t\t\tname,\n\t\t\t\tkind,\n\t\t\t\tunit,\n\t\t\t\tattributes: encoded,\n\t\t\t\tcount: (previous?.count ?? 0) + 1,\n\t\t\t\tsum: (previous?.sum ?? 0) + value,\n\t\t\t\tmin: Math.min(previous?.min ?? value, value),\n\t\t\t\tmax: Math.max(previous?.max ?? value, value),\n\t\t\t});\n\t\t};\n\t}\n\n\t/** Readers use committed rows only; flush first to include newly settled spans. */\n\treadonly getTrace: TelemetryStore[\"getTrace\"] = (traceId) => getTrace(this.db, traceId);\n\treadonly findTraces: TelemetryStore[\"findTraces\"] = (query) => findTraces(this.db, query);\n\treadonly findMetrics: TelemetryStore[\"findMetrics\"] = (query) => findMetrics(this.db, query);\n\n\tflush(): Promise<void> {\n\t\treturn this.closing ?? this.drain(false);\n\t}\n\n\tclose(): Promise<void> {\n\t\tif (!this.closing) {\n\t\t\tthis.stopped = true;\n\t\t\tclearInterval(this.timer);\n\t\t\tthis.closing = this.drain(true);\n\t\t}\n\t\treturn this.closing;\n\t}\n\n\tprivate async drain(partial: boolean): Promise<void> {\n\t\twhile (this.writing) await this.writing;\n\t\tif (this.failed) throw this.failure;\n\t\tconst spans = this.spans.slice();\n\t\tconst metrics: Metric[] = [];\n\t\tconst completed = Math.floor(Date.now() / intervalMs) * intervalMs;\n\t\tfor (const [key, metric] of this.measurements) {\n\t\t\tif (!partial && metric.interval >= completed) continue;\n\t\t\tmetrics.push(metric);\n\t\t\tthis.measurements.delete(key);\n\t\t}\n\t\tthis.inFlightMeasurements = metrics.length;\n\t\tthis.writing = Promise.resolve()\n\t\t\t.then(() =>\n\t\t\t\tthis.db.transaction(async (tx) => {\n\t\t\t\t\tfor (const span of spans)\n\t\t\t\t\t\tawait tx.run(\"INSERT INTO telemetry_spans VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)\", ...span);\n\t\t\t\t\tfor (const metric of metrics)\n\t\t\t\t\t\tawait tx.run(\n\t\t\t\t\t\t\t`INSERT INTO telemetry_metrics VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)\n\t\t\t\tON CONFLICT(interval_ms, series_key) DO UPDATE SET count = count + excluded.count,\n\t\t\t\tsum = sum + excluded.sum, min = min(min, excluded.min), max = max(max, excluded.max)`,\n\t\t\t\t\t\t\tmetric.interval,\n\t\t\t\t\t\t\tmetric.key,\n\t\t\t\t\t\t\tmetric.name,\n\t\t\t\t\t\t\tmetric.kind,\n\t\t\t\t\t\t\tmetric.unit,\n\t\t\t\t\t\t\tmetric.attributes,\n\t\t\t\t\t\t\tmetric.count,\n\t\t\t\t\t\t\tmetric.sum,\n\t\t\t\t\t\t\tmetric.min,\n\t\t\t\t\t\t\tmetric.max,\n\t\t\t\t\t\t);\n\t\t\t\t\tconst cutoff = Date.now() - this.retention;\n\t\t\t\t\tawait tx.run(\"DELETE FROM telemetry_spans WHERE ended_ms < ?\", cutoff);\n\t\t\t\t\tawait tx.run(\"DELETE FROM telemetry_metrics WHERE interval_ms < ?\", cutoff);\n\t\t\t\t}),\n\t\t\t)\n\t\t\t.then(() => {\n\t\t\t\tthis.spans.splice(0, spans.length);\n\t\t\t})\n\t\t\t.catch((error: unknown) => {\n\t\t\t\tthis.failed = this.stopped = true;\n\t\t\t\tthis.failure = error;\n\t\t\t\tthis.spans.length = 0;\n\t\t\t\tthis.measurements.clear();\n\t\t\t\tclearInterval(this.timer);\n\t\t\t\tthrow error;\n\t\t\t})\n\t\t\t.finally(() => {\n\t\t\t\tthis.writing = undefined;\n\t\t\t\tthis.inFlightMeasurements = 0;\n\t\t\t});\n\t\tawait this.writing;\n\t}\n}\n\n/** Portable, buffered SQLite recorder. Recording never performs SQL; flush runs every second.\n * Only settled spans are stored. Metrics aggregate count/sum/min/max per ten-second interval.\n * A write failure permanently stops recording and is reported by flush and close. */\nexport async function createSqliteTelemetry(\n\tdb: SqliteDatabase,\n\toptions: SqliteTelemetryOptions = {},\n): Promise<SqliteTelemetry> {\n\tconst retention = options.retentionMs ?? 7 * 24 * 60 * 60 * 1000;\n\tconst capacity = options.maxQueuedSpans ?? 10_000;\n\tawait applySqliteMigrations(\n\t\tdb,\n\t\t[\n\t\t\t{\n\t\t\t\tversion: 1,\n\t\t\t\tstatements: [\n\t\t\t\t\t`CREATE TABLE telemetry_spans (id TEXT PRIMARY KEY, trace_id TEXT NOT NULL, parent_id TEXT, name TEXT, started_ms REAL,\n\t\t\tended_ms REAL NOT NULL, attributes TEXT, events TEXT, links TEXT, status TEXT)`,\n\t\t\t\t\t\"CREATE INDEX telemetry_spans_ended_ms ON telemetry_spans(ended_ms)\",\n\t\t\t\t\t\"CREATE INDEX telemetry_spans_trace_started ON telemetry_spans(trace_id, started_ms)\",\n\t\t\t\t\t\"CREATE INDEX telemetry_spans_started_ms ON telemetry_spans(started_ms)\",\n\t\t\t\t\t`CREATE TABLE telemetry_metrics (interval_ms INTEGER, series_key TEXT, name TEXT, kind TEXT,\n\t\t\tunit TEXT, attributes TEXT, count INTEGER, sum REAL, min REAL, max REAL, PRIMARY KEY(interval_ms, series_key))`,\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t\t{ table: \"telemetry_schema\" },\n\t);\n\treturn new Recorder(db, retention, capacity);\n}\n"]}
@@ -0,0 +1,9 @@
1
+ import type { MetricQuery, StoredMetric, StoredTrace, TraceQuery } from "@draht/telemetry";
2
+ import type { SqliteDatabase } from "../sqlite/index.ts";
3
+ export declare function getTrace(db: SqliteDatabase, traceId: string): Promise<StoredTrace | undefined>;
4
+ export declare function findTraces(db: SqliteDatabase, query?: TraceQuery): Promise<{
5
+ traces: readonly StoredTrace[];
6
+ cursor?: string;
7
+ }>;
8
+ export declare function findMetrics(db: SqliteDatabase, query: MetricQuery): Promise<readonly StoredMetric[]>;
9
+ //# sourceMappingURL=store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/telemetry-sqlite/store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,WAAW,EAGX,YAAY,EAEZ,WAAW,EACX,UAAU,EACV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,cAAc,EAAe,MAAM,oBAAoB,CAAC;AAwDtE,wBAAsB,QAAQ,CAAC,EAAE,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CAMpG;AAED,wBAAsB,UAAU,CAC/B,EAAE,EAAE,cAAc,EAClB,KAAK,GAAE,UAAe,GACpB,OAAO,CAAC;IAAE,MAAM,EAAE,SAAS,WAAW,EAAE,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CA0D9D;AAED,wBAAsB,WAAW,CAAC,EAAE,EAAE,cAAc,EAAE,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,SAAS,YAAY,EAAE,CAAC,CAkC1G"}
@@ -0,0 +1,110 @@
1
+ function storedSpan(row) {
2
+ return {
3
+ id: row.id,
4
+ traceId: row.trace_id,
5
+ ...(row.parent_id === null ? {} : { parentId: row.parent_id }),
6
+ name: row.name,
7
+ startedMs: row.started_ms,
8
+ endedMs: row.ended_ms,
9
+ attributes: JSON.parse(row.attributes),
10
+ events: JSON.parse(row.events).map((event) => ({ name: event.name, timeMs: event.time_ms, attributes: event.attributes })),
11
+ links: JSON.parse(row.links).map((link) => ({
12
+ traceId: link.trace_id,
13
+ spanId: link.span_id,
14
+ ...(link.attributes === undefined ? {} : { attributes: link.attributes }),
15
+ })),
16
+ status: JSON.parse(row.status),
17
+ };
18
+ }
19
+ // JSON equality must distinguish boolean true from numeric 1. json_each also handles arbitrary attribute keys.
20
+ function attributesSql(attributes, column, params) {
21
+ return (Object.entries(attributes ?? {})
22
+ .map(([key, value]) => {
23
+ const type = typeof value === "number"
24
+ ? "entry.type IN ('integer', 'real')"
25
+ : typeof value === "boolean"
26
+ ? `entry.type = '${value ? "true" : "false"}'`
27
+ : "entry.type = 'text'";
28
+ params.push(key, typeof value === "boolean" ? Number(value) : value);
29
+ return `EXISTS (SELECT 1 FROM json_each(${column}) entry WHERE entry.key = ? AND ${type} AND entry.value = ?)`;
30
+ })
31
+ .join(" AND ") || "1");
32
+ }
33
+ export async function getTrace(db, traceId) {
34
+ const rows = await db.all("SELECT * FROM telemetry_spans WHERE trace_id = ? ORDER BY started_ms, id", traceId);
35
+ return rows.length ? { traceId, spans: rows.map(storedSpan) } : undefined;
36
+ }
37
+ export async function findTraces(db, query = {}) {
38
+ const limit = query.limit ?? 20;
39
+ const conditions = [];
40
+ const params = [];
41
+ if (query.name !== undefined) {
42
+ conditions.push("(SELECT name FROM telemetry_spans WHERE trace_id = heads.trace_id ORDER BY started_ms, id LIMIT 1) = ?");
43
+ params.push(query.name);
44
+ }
45
+ if (query.startMin !== undefined) {
46
+ conditions.push("started_ms >= ?");
47
+ params.push(query.startMin);
48
+ }
49
+ if (query.startMax !== undefined) {
50
+ conditions.push("started_ms <= ?");
51
+ params.push(query.startMax);
52
+ }
53
+ if (query.errors)
54
+ conditions.push("EXISTS (SELECT 1 FROM telemetry_spans WHERE trace_id = heads.trace_id AND json_extract(status, '$.status') = 'error')");
55
+ if (query.attributes)
56
+ conditions.push(`EXISTS (SELECT 1 FROM telemetry_spans candidate WHERE candidate.trace_id = heads.trace_id AND ${attributesSql(query.attributes, "candidate.attributes", params)})`);
57
+ if (query.cursor !== undefined) {
58
+ const cursor = JSON.parse(query.cursor);
59
+ conditions.push("(started_ms < ? OR (started_ms = ? AND trace_id > ?))");
60
+ params.push(cursor[0], cursor[0], cursor[1]);
61
+ }
62
+ return db.transaction(async (tx) => {
63
+ const heads = await tx.all(`WITH heads AS (
64
+ SELECT trace_id, min(started_ms) started_ms FROM telemetry_spans GROUP BY trace_id
65
+ ) SELECT * FROM heads WHERE ${conditions.join(" AND ") || "1"} ORDER BY started_ms DESC, trace_id LIMIT ?`, ...params, limit + 1);
66
+ const more = heads.length > limit;
67
+ if (more)
68
+ heads.pop();
69
+ if (!heads.length)
70
+ return { traces: [] };
71
+ const rows = await tx.all("SELECT * FROM telemetry_spans WHERE trace_id IN (SELECT value FROM json_each(?)) ORDER BY started_ms, id", JSON.stringify(heads.map((head) => head.trace_id)));
72
+ const grouped = new Map();
73
+ for (const row of rows) {
74
+ const spans = grouped.get(row.trace_id) ?? [];
75
+ spans.push(storedSpan(row));
76
+ grouped.set(row.trace_id, spans);
77
+ }
78
+ const last = heads.at(-1);
79
+ return {
80
+ traces: heads.map((head) => ({ traceId: head.trace_id, spans: grouped.get(head.trace_id) })),
81
+ ...(more ? { cursor: JSON.stringify([last.started_ms, last.trace_id]) } : {}),
82
+ };
83
+ });
84
+ }
85
+ export async function findMetrics(db, query) {
86
+ const params = [query.name];
87
+ const conditions = ["name = ?"];
88
+ if (query.startMin !== undefined) {
89
+ conditions.push("interval_ms >= ?");
90
+ params.push(query.startMin);
91
+ }
92
+ if (query.startMax !== undefined) {
93
+ conditions.push("interval_ms <= ?");
94
+ params.push(query.startMax);
95
+ }
96
+ conditions.push(attributesSql(query.attributes, "attributes", params));
97
+ const rows = await db.all(`SELECT * FROM telemetry_metrics WHERE ${conditions.join(" AND ")} ORDER BY interval_ms, series_key`, ...params);
98
+ return rows.map((row) => ({
99
+ intervalMs: row.interval_ms,
100
+ name: row.name,
101
+ kind: row.kind,
102
+ ...(row.unit === null ? {} : { unit: row.unit }),
103
+ attributes: JSON.parse(row.attributes),
104
+ count: row.count,
105
+ sum: row.sum,
106
+ min: row.min,
107
+ max: row.max,
108
+ }));
109
+ }
110
+ //# sourceMappingURL=store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/telemetry-sqlite/store.ts"],"names":[],"mappings":"AAwBA,SAAS,UAAU,CAAC,GAAY;IAC/B,OAAO;QACN,EAAE,EAAE,GAAG,CAAC,EAAE;QACV,OAAO,EAAE,GAAG,CAAC,QAAQ;QACrB,GAAG,CAAC,GAAG,CAAC,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,GAAG,CAAC,SAAS,EAAE,CAAC;QAC9D,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,SAAS,EAAE,GAAG,CAAC,UAAU;QACzB,OAAO,EAAE,GAAG,CAAC,QAAQ;QACrB,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,CAAmB;QACxD,MAAM,EAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAqE,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AQ,CAAC,CAAC;IAC7B,CAAC;IACD,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,UAAU,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC;IACvE,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,GAAG,CAUtB,yCAAyC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,mCAAmC,EAAE,GAAG,MAAM,CAAC,CAAC;IACpH,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QACzB,UAAU,EAAE,GAAG,CAAC,WAAW;QAC3B,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,GAAG,CAAC,GAAG,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC;QAChD,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,CAAmB;QACxD,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,GAAG,EAAE,GAAG,CAAC,GAAG;QACZ,GAAG,EAAE,GAAG,CAAC,GAAG;QACZ,GAAG,EAAE,GAAG,CAAC,GAAG;KACZ,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type {\n\tMetricQuery,\n\tSpanAttributes,\n\tSpanStatus,\n\tStoredMetric,\n\tStoredSpan,\n\tStoredTrace,\n\tTraceQuery,\n} from \"@draht/telemetry\";\nimport type { SqliteDatabase, SqliteValue } from \"../sqlite/index.ts\";\n\ntype SpanRow = {\n\tid: string;\n\ttrace_id: string;\n\tparent_id: string | null;\n\tname: string;\n\tstarted_ms: number;\n\tended_ms: number;\n\tattributes: string;\n\tevents: string;\n\tlinks: string;\n\tstatus: string;\n};\n\nfunction storedSpan(row: SpanRow): StoredSpan {\n\treturn {\n\t\tid: row.id,\n\t\ttraceId: row.trace_id,\n\t\t...(row.parent_id === null ? {} : { parentId: row.parent_id }),\n\t\tname: row.name,\n\t\tstartedMs: row.started_ms,\n\t\tendedMs: row.ended_ms,\n\t\tattributes: JSON.parse(row.attributes) as SpanAttributes,\n\t\tevents: (JSON.parse(row.events) as { name: string; time_ms: number; attributes: SpanAttributes }[]).map(\n\t\t\t(event) => ({ name: event.name, timeMs: event.time_ms, attributes: event.attributes }),\n\t\t),\n\t\tlinks: (JSON.parse(row.links) as { trace_id: string; span_id: string; attributes?: SpanAttributes }[]).map(\n\t\t\t(link) => ({\n\t\t\t\ttraceId: link.trace_id,\n\t\t\t\tspanId: link.span_id,\n\t\t\t\t...(link.attributes === undefined ? {} : { attributes: link.attributes }),\n\t\t\t}),\n\t\t),\n\t\tstatus: JSON.parse(row.status) as SpanStatus,\n\t};\n}\n\n// JSON equality must distinguish boolean true from numeric 1. json_each also handles arbitrary attribute keys.\nfunction attributesSql(attributes: TraceQuery[\"attributes\"], column: string, params: SqliteValue[]): string {\n\treturn (\n\t\tObject.entries(attributes ?? {})\n\t\t\t.map(([key, value]) => {\n\t\t\t\tconst type =\n\t\t\t\t\ttypeof value === \"number\"\n\t\t\t\t\t\t? \"entry.type IN ('integer', 'real')\"\n\t\t\t\t\t\t: typeof value === \"boolean\"\n\t\t\t\t\t\t\t? `entry.type = '${value ? \"true\" : \"false\"}'`\n\t\t\t\t\t\t\t: \"entry.type = 'text'\";\n\t\t\t\tparams.push(key, typeof value === \"boolean\" ? Number(value) : value);\n\t\t\t\treturn `EXISTS (SELECT 1 FROM json_each(${column}) entry WHERE entry.key = ? AND ${type} AND entry.value = ?)`;\n\t\t\t})\n\t\t\t.join(\" AND \") || \"1\"\n\t);\n}\n\nexport async function getTrace(db: SqliteDatabase, traceId: string): Promise<StoredTrace | undefined> {\n\tconst rows = await db.all<SpanRow>(\n\t\t\"SELECT * FROM telemetry_spans WHERE trace_id = ? ORDER BY started_ms, id\",\n\t\ttraceId,\n\t);\n\treturn rows.length ? { traceId, spans: rows.map(storedSpan) } : undefined;\n}\n\nexport async function findTraces(\n\tdb: SqliteDatabase,\n\tquery: TraceQuery = {},\n): Promise<{ traces: readonly StoredTrace[]; cursor?: string }> {\n\tconst limit = query.limit ?? 20;\n\tconst conditions: string[] = [];\n\tconst params: SqliteValue[] = [];\n\tif (query.name !== undefined) {\n\t\tconditions.push(\n\t\t\t\"(SELECT name FROM telemetry_spans WHERE trace_id = heads.trace_id ORDER BY started_ms, id LIMIT 1) = ?\",\n\t\t);\n\t\tparams.push(query.name);\n\t}\n\tif (query.startMin !== undefined) {\n\t\tconditions.push(\"started_ms >= ?\");\n\t\tparams.push(query.startMin);\n\t}\n\tif (query.startMax !== undefined) {\n\t\tconditions.push(\"started_ms <= ?\");\n\t\tparams.push(query.startMax);\n\t}\n\tif (query.errors)\n\t\tconditions.push(\n\t\t\t\"EXISTS (SELECT 1 FROM telemetry_spans WHERE trace_id = heads.trace_id AND json_extract(status, '$.status') = 'error')\",\n\t\t);\n\tif (query.attributes)\n\t\tconditions.push(\n\t\t\t`EXISTS (SELECT 1 FROM telemetry_spans candidate WHERE candidate.trace_id = heads.trace_id AND ${attributesSql(query.attributes, \"candidate.attributes\", params)})`,\n\t\t);\n\tif (query.cursor !== undefined) {\n\t\tconst cursor = JSON.parse(query.cursor) as [number, string];\n\t\tconditions.push(\"(started_ms < ? OR (started_ms = ? AND trace_id > ?))\");\n\t\tparams.push(cursor[0], cursor[0], cursor[1]);\n\t}\n\treturn db.transaction(async (tx) => {\n\t\tconst heads = await tx.all<{ trace_id: string; started_ms: number }>(\n\t\t\t`WITH heads AS (\n\t\t\tSELECT trace_id, min(started_ms) started_ms FROM telemetry_spans GROUP BY trace_id\n\t\t) SELECT * FROM heads WHERE ${conditions.join(\" AND \") || \"1\"} ORDER BY started_ms DESC, trace_id LIMIT ?`,\n\t\t\t...params,\n\t\t\tlimit + 1,\n\t\t);\n\t\tconst more = heads.length > limit;\n\t\tif (more) heads.pop();\n\t\tif (!heads.length) return { traces: [] };\n\t\tconst rows = await tx.all<SpanRow>(\n\t\t\t\"SELECT * FROM telemetry_spans WHERE trace_id IN (SELECT value FROM json_each(?)) ORDER BY started_ms, id\",\n\t\t\tJSON.stringify(heads.map((head) => head.trace_id)),\n\t\t);\n\t\tconst grouped = new Map<string, StoredSpan[]>();\n\t\tfor (const row of rows) {\n\t\t\tconst spans = grouped.get(row.trace_id) ?? [];\n\t\t\tspans.push(storedSpan(row));\n\t\t\tgrouped.set(row.trace_id, spans);\n\t\t}\n\t\tconst last = heads.at(-1)!;\n\t\treturn {\n\t\t\ttraces: heads.map((head) => ({ traceId: head.trace_id, spans: grouped.get(head.trace_id)! })),\n\t\t\t...(more ? { cursor: JSON.stringify([last.started_ms, last.trace_id]) } : {}),\n\t\t};\n\t});\n}\n\nexport async function findMetrics(db: SqliteDatabase, query: MetricQuery): Promise<readonly StoredMetric[]> {\n\tconst params: SqliteValue[] = [query.name];\n\tconst conditions = [\"name = ?\"];\n\tif (query.startMin !== undefined) {\n\t\tconditions.push(\"interval_ms >= ?\");\n\t\tparams.push(query.startMin);\n\t}\n\tif (query.startMax !== undefined) {\n\t\tconditions.push(\"interval_ms <= ?\");\n\t\tparams.push(query.startMax);\n\t}\n\tconditions.push(attributesSql(query.attributes, \"attributes\", params));\n\tconst rows = await db.all<{\n\t\tinterval_ms: number;\n\t\tname: string;\n\t\tkind: StoredMetric[\"kind\"];\n\t\tunit: string | null;\n\t\tattributes: string;\n\t\tcount: number;\n\t\tsum: number;\n\t\tmin: number;\n\t\tmax: number;\n\t}>(`SELECT * FROM telemetry_metrics WHERE ${conditions.join(\" AND \")} ORDER BY interval_ms, series_key`, ...params);\n\treturn rows.map((row) => ({\n\t\tintervalMs: row.interval_ms,\n\t\tname: row.name,\n\t\tkind: row.kind,\n\t\t...(row.unit === null ? {} : { unit: row.unit }),\n\t\tattributes: JSON.parse(row.attributes) as SpanAttributes,\n\t\tcount: row.count,\n\t\tsum: row.sum,\n\t\tmin: row.min,\n\t\tmax: row.max,\n\t}));\n}\n"]}
package/dist/types.d.ts CHANGED
@@ -1,273 +1,88 @@
1
- import type { Draft, Op } from "./delta/index.ts";
2
- import type { RemoteServiceProvider } from "./services/provider.ts";
3
- export type { RemoteServiceError } from "./services/errors.ts";
4
- export type { RemoteServiceProvider } from "./services/provider.ts";
5
- /** Typed identity for one value carried by a {@link Context}. */
6
- export interface ContextKey<T> {
7
- readonly token: symbol;
8
- /** Type-only marker that prevents keys with different value types from being interchangeable. */
9
- readonly valueType?: (value: T) => T;
10
- }
11
- /** Immutable invocation-scoped values passed explicitly through operations. */
12
- export interface Context {
13
- readonly abortSignal: AbortSignal | undefined;
14
- value<T>(key: ContextKey<T>): T | undefined;
15
- toString(): string;
16
- }
17
- export type JsonValue = null | boolean | number | string | JsonValue[] | {
18
- [key: string]: JsonValue;
19
- };
20
- type IsAny<T> = 0 extends 1 & T ? true : false;
21
- /** Strict-JSON representation of an application data type. Unknown payloads become JsonValue. */
22
- export type JsonRepresentation<T> = IsAny<T> extends true ? JsonValue : unknown extends T ? JsonValue : T extends null | boolean | number | string ? T : T extends readonly (infer TItem)[] ? JsonRepresentation<TItem>[] : T extends object ? {
23
- [TKey in keyof T]: JsonRepresentation<T[TKey]>;
24
- } : never;
25
- export interface ReplicatedStateDelivery {
26
- readonly kind: "hydrate" | "update";
27
- readonly sequence: number;
28
- }
29
- export interface ReplicatedState<T> {
30
- /**
31
- * Contract-immutable value, or undefined until hydration. It is not frozen and may share containers with an
32
- * in-process provider; consumers must not mutate it. Later updates do not mutate previously returned values.
33
- */
34
- readonly value: T | undefined;
1
+ import type { AnyContract, InputOf, Ref } from "./contract.ts";
2
+ import type { Op } from "./delta/index.ts";
3
+ /**
4
+ * Options of `get`. `P` is the app's principal type: a JSON-serializable identity of a caller, mapped to an object key
5
+ * by `createHost({ principalKey })`.
6
+ */
7
+ export interface GetOptions<P = unknown> {
8
+ /** Principal the object is created for. Defaults to the host's own principal (`createHost({ self })`). */
9
+ readonly principal?: P;
35
10
  /**
36
- * Each subscription serializes callbacks, awaiting hydration before updates. Values are immutable and may
37
- * share unchanged revision data. At most 100 deliveries wait behind the running callback; overflow keeps
38
- * only the newest pending value/context/delivery, so update sequences may skip. Failures are reported in
39
- * isolation and delivery continues. Unsubscribe discards pending work without aborting or joining a callback.
11
+ * False: a method-only reference. It receives no state (unless another reference to the same object wants it), and
12
+ * is ready once its object is live.
40
13
  */
41
- subscribe(listener: (value: T, context: Context, delivery: ReplicatedStateDelivery) => Promise<void>): () => void;
42
- subscribe(listener: (value: T, context: Context, delivery: ReplicatedStateDelivery) => void): () => void;
14
+ readonly state?: boolean;
43
15
  }
44
- export interface MutableReplicatedState<T extends object> extends ReplicatedState<T> {
45
- readonly value: T;
46
- /**
47
- * Atomically publish one synchronous overlay mutation. Draft handles are unusable after the callback returns.
48
- * Values placed through the draft are cloned by value; assigning `undefined` to an object property deletes it.
49
- */
50
- change(context: Context, mutate: (draft: Draft<T>) => void): void;
16
+ /**
17
+ * The explicit call context of one root (a short Chord call tree). Calls made with it carry its root id and code
18
+ * version; `get` references are released when the call that received this ctx settles.
19
+ */
20
+ export interface Ctx<P = unknown> {
21
+ readonly signal: AbortSignal;
22
+ readonly rootId: string;
23
+ readonly codeVersion: number;
24
+ /** Who the root acts as: the caller at ingress, the host's own principal inside objects. */
25
+ readonly principal: P;
51
26
  /**
52
- * Atomically take immutable ownership of an alias-free strict-JSON replacement.
53
- * The caller must not mutate the transferred root after this call.
27
+ * A reference for this call, released when the call settles. Resolves once it is ready: live, with every state
28
+ * member of its variant (unless `state: false`). Rejects with the activation error, `aborted` when the ctx is
29
+ * aborted or the call settles first, or `unavailable/ready_timeout` after the host's `readyTimeout`; the reference
30
+ * is released then.
54
31
  */
55
- replace(context: Context, value: T): void;
32
+ get<C extends AnyContract>(type: C, input: InputOf<C>, options?: GetOptions<P>): Promise<Ref<C>>;
56
33
  }
57
- /** One immutable authoritative revision committed after an attachment snapshot. */
58
- export interface ReplicatedStateSourceFrame<T> {
59
- /** Monotonic source cursor. The first frame after a snapshot must be `snapshot.cursor + 1`. */
60
- readonly cursor: number;
61
- /** The exact immutable value produced by this commit. */
34
+ export type StateEvent<T> = {
35
+ readonly type: "snap";
62
36
  readonly value: T;
63
- /** The exact immutable operation batch that produced `value` from the preceding source revision. */
37
+ } | {
38
+ readonly type: "ops";
64
39
  readonly ops: readonly Op[];
65
- readonly context: Context;
66
- }
67
- export interface ReplicatedStateSourceAttachment<T> {
68
- /** Fixed immutable snapshot captured at the atomic attachment boundary. */
69
- readonly snapshot: {
70
- readonly value: T;
71
- readonly cursor: number;
72
- };
73
- /**
74
- * Install the sole listener and synchronously drain every buffered frame in source commit order.
75
- * This method is single-use. After it begins, every new committed frame must also be delivered in order
76
- * until disposal, including commits made reentrantly while a prior frame is being delivered.
77
- */
78
- activate(listener: (frame: ReplicatedStateSourceFrame<T>) => void): void;
79
- /** Stop delivery and release source resources. Disposal must be idempotent. */
80
- dispose(): void;
81
- }
82
- /**
83
- * An authoritative immutable revision source.
84
- *
85
- * `attach()` must synchronously and atomically capture one snapshot and register the returned attachment to buffer
86
- * every later committed frame. The snapshot must include every commit before that boundary; buffered frames must
87
- * include every commit after it, with no overlap or gap. Snapshot values, frame values, and operation batches are
88
- * immutable and remain valid after delivery. Chord only publishes these references; it never applies or re-diffs them.
89
- */
90
- export interface ReplicatedStateSource<T> {
91
- attach(): ReplicatedStateSourceAttachment<T>;
92
- }
93
- export interface ReplicatedStateSourceOptions {
94
- /** Receives source-contract and publication-listener failures without throwing them into the source. */
95
- readonly onError?: (error: Error) => void;
96
- }
97
- /** A synchronously hydrated publication-only state backed by one source attachment. */
98
- export interface AttachedReplicatedState<T> extends ReplicatedState<T> {
99
40
  readonly value: T;
100
- /** Idempotently release the source attachment. The last published value remains readable. */
101
- dispose(): void;
102
- }
103
- declare const SERVICE_TYPE: unique symbol;
104
- export type ServiceMode = "singleton" | "keyed";
105
- /** Stable identity for one shared TypeScript service contract. */
106
- export interface Service<T> {
107
- readonly id: string;
108
- /** Process-local services accept unrestricted object contracts and are never published remotely. */
109
- readonly local: boolean;
110
- readonly [SERVICE_TYPE]?: (value: T) => T;
111
- }
112
- type InvalidJsonPart<T> = IsAny<T> extends true ? T : unknown extends T ? never : [T] extends [JsonValue] ? [JsonValue] extends [T] ? never : InvalidJsonStructure<T> : InvalidJsonStructure<T>;
113
- type InvalidJsonProperty<T> = [Exclude<T, undefined>] extends [never] ? T : InvalidJsonPart<Exclude<T, undefined>>;
114
- type InvalidJsonStructure<T> = T extends null | boolean | number | string ? never : T extends readonly (infer TItem)[] ? InvalidJsonPart<TItem> : T extends (...args: never[]) => unknown ? T : T extends object ? {
115
- [TKey in keyof T]-?: InvalidJsonProperty<T[TKey]>;
116
- }[keyof T] : T;
117
- type InvalidRemoteMember<T> = T extends ReplicatedState<infer TValue> ? InvalidJsonPart<TValue> extends never ? never : "state value is not JSON" : T extends (...args: [...infer TArgs, Context]) => Promise<infer TResult> ? InvalidJsonPart<TArgs[number]> extends never ? TResult extends void ? never : InvalidJsonPart<TResult> extends never ? never : "method result is not JSON or void" : "method argument is not JSON" : "member is not a remote method or ReplicatedState";
118
- type InvalidRemoteMemberNames<T> = {
119
- [TKey in keyof T]-?: InvalidRemoteMember<T[TKey]> extends never ? never : TKey;
120
- }[keyof T];
121
- export type RemoteServiceContract<T> = InvalidRemoteMemberNames<T> extends never ? T : never;
122
- export interface ServiceSpawner<T> {
123
- spawn(key: string, implementation: T): () => void;
124
- }
125
- export interface RemoteServices {
126
- use<T>(service: Service<T>): T;
127
- observe<T>(service: Service<T>, handler: (service: T, context: Context) => void | Promise<void>): () => void;
128
- /** Wait until every currently acquired service has installed its initial snapshot. */
129
- ready(context: Context): Promise<void>;
130
- dispose(context: Context): Promise<void>;
131
- }
132
- export type ServiceCatalogueEntry = {
133
- readonly serviceId: string;
134
- readonly mode: ServiceMode;
135
- };
136
- export type ServiceInstanceAddress = {
137
- readonly key: string;
138
- readonly generation: number;
139
- };
140
- export type ServiceMemberSnapshot = {
141
- readonly name: string;
142
- readonly kind: "method";
143
41
  } | {
144
- readonly name: string;
145
- readonly kind: "state";
146
- readonly sequence: number;
147
- readonly ops: readonly Op[];
148
- };
149
- export type ServiceInstanceSnapshot = {
150
- readonly instance?: ServiceInstanceAddress;
151
- readonly members: readonly ServiceMemberSnapshot[];
152
- };
153
- export type ServiceSubscriptionSnapshot = {
154
- readonly serviceId: string;
155
- readonly mode: ServiceMode;
156
- readonly instances: readonly ServiceInstanceSnapshot[];
157
- };
158
- export type ServiceProviderUpdate = {
159
- readonly type: "state";
160
- readonly instance?: ServiceInstanceAddress;
161
- readonly member: string;
162
- readonly sequence: number;
163
- readonly ops: readonly Op[];
164
- }
165
- /** Full subscription rebaseline after overflow; every state is a root replacement at its new sequence. */
166
- | {
167
42
  readonly type: "reset";
168
- readonly snapshot: ServiceSubscriptionSnapshot;
169
- } | {
170
- readonly type: "unavailable";
171
- } | {
172
- readonly type: "replaced";
173
- readonly snapshot: ServiceInstanceSnapshot;
174
- } | {
175
- readonly type: "spawned";
176
- readonly instance: ServiceInstanceSnapshot;
177
- } | {
178
- readonly type: "closed";
179
- readonly instance: ServiceInstanceAddress;
180
- };
181
- export type ServiceCall = {
182
- readonly serviceId: string;
183
- readonly instance?: ServiceInstanceAddress;
184
- readonly member: string;
185
- /** Borrowed immutable values. Chord validates but does not clone them. */
186
- readonly args: readonly JsonValue[];
43
+ readonly value: T;
187
44
  };
188
- export interface ServiceSubscription {
189
- /** Atomic baseline. Later updates buffer until activation, with a full reset on pending delivery 101. */
190
- readonly snapshot: ServiceSubscriptionSnapshot;
191
- activate(): void;
192
- close(context?: Context): void | Promise<void>;
45
+ /** A readable state source: a cell, a derivation, or a reference's state member. Values are immutable by contract. */
46
+ export interface Readable<T> {
47
+ readonly value: T;
48
+ /** Called with the current value immediately, then with every new value. */
49
+ subscribe(listener: (value: T) => void): () => void;
50
+ /** Delta stream: a snapshot immediately, then ops, or a reset after a migration or rebind. */
51
+ events(listener: (event: StateEvent<T>) => void): () => void;
193
52
  }
194
53
  /**
195
- * Pluggable wire boundary consumed by a remote service binding.
196
- *
197
- * Implementations choose transport, framing, routing, and envelope encoding. Values crossing this
198
- * boundary must remain strict JSON. Chord does not clone values or require a particular application wire protocol;
199
- * adapters own serialization and any isolation copies they require.
200
- *
54
+ * What an implementation may expose as a state member: a cell, a derivation, or a held object's state member (an
55
+ * object goes live only once the members it exposes have their values).
201
56
  */
202
- export interface RemoteServiceTransport {
203
- invoke(call: ServiceCall, context: Context): Promise<JsonValue | undefined>;
204
- subscribe(serviceId: string, mode: ServiceMode, listener: (update: ServiceProviderUpdate, context: Context) => void, context: Context): Promise<ServiceSubscription>;
205
- }
206
- export interface RemoteServiceBindingOptions {
207
- readonly services: readonly {
208
- readonly id: string;
209
- }[];
210
- readonly transport: RemoteServiceTransport;
211
- readonly bound?: boolean;
212
- readonly onError?: (error: Error) => void;
213
- readonly assertAccess?: () => void;
214
- }
215
- export interface RemoteServiceBinding extends RemoteServices {
216
- rebind(bound: boolean, context: Context): Promise<void>;
217
- }
218
- export interface FacetEnvironment {
219
- /** Declare a hard dependency on one singleton service and return its stable handle. */
220
- use<T>(service: Service<T>): T;
221
- /** Declare a hard dependency on a keyed service and observe each live instance. */
222
- observe<T>(service: Service<T>, handler: (service: T, context: Context) => void | Promise<void>): void;
223
- /** Declare and install this facet's singleton implementation of a service. */
224
- provide<T>(service: Service<T>, implementation: NoInfer<T>): void;
225
- /** Declare ownership of a multi-instance service and return its deferred spawning capability. */
226
- provideMany<T>(service: Service<T>): ServiceSpawner<T>;
57
+ export type StateSource<T> = Readable<T>;
58
+ declare const EXPOSED: unique symbol;
59
+ /** A local member backed by a resource (`self.expose(res.x)`): references read the resource's value once live. */
60
+ export interface Exposed<T> {
61
+ readonly [EXPOSED]: T;
62
+ }
63
+ export type RefStatus = "loading" | "live" | "released" | "gone";
64
+ export interface Shape {
65
+ readonly variant: string | undefined;
66
+ readonly members: readonly string[];
67
+ /** Fingerprint of the provider contract. */
68
+ readonly contract: string;
69
+ }
70
+ export interface RefBase<C extends AnyContract> {
71
+ /** The consumer contract token this reference was bound with. */
72
+ readonly contract: C;
73
+ readonly status: RefStatus;
74
+ readonly ready: Promise<void>;
75
+ readonly variant: string | undefined;
76
+ readonly shape: Shape | undefined;
77
+ /** Why the reference is gone, if it is. */
78
+ readonly error: unknown;
79
+ onShape(listener: (shape: Shape) => void): () => void;
227
80
  /**
228
- * Create initialized mutable state by taking immutable ownership of an alias-free strict-JSON root.
229
- * The caller must not mutate `initial` after this call.
81
+ * Called after every status change (`loading` → `live`, `live` → `loading` while a link reconnects, `released`,
82
+ * `gone` with `error`). A UI watches for `gone` to `get` again.
230
83
  */
231
- replicatedState<T extends object>(initial: T): MutableReplicatedState<T>;
232
- /** Give the facet ownership of a resource cleanup function. */
233
- own(disposal: () => void | Promise<void>): void;
234
- /** Register asynchronous initialization after dependencies are bound and ready. */
235
- onActivate(callback: () => void | Promise<void>): void;
236
- /** Register final facet teardown. */
237
- onDeactivate(callback: () => void | Promise<void>): void;
238
- }
239
- export interface Facet {
240
- readonly id: string;
241
- setup(env: FacetEnvironment): void;
242
- }
243
- export interface RemoteServiceSource {
244
- /** Whether this currently unavailable source may provisionally own absent requirements. */
245
- readonly acceptsUnavailableServices: boolean;
246
- catalogue(context: Context): Promise<readonly ServiceCatalogueEntry[]>;
247
- open(options: {
248
- readonly services: readonly {
249
- readonly id: string;
250
- }[];
251
- assertAccess(): void;
252
- onError(error: Error): void;
253
- }): RemoteServices;
254
- }
255
- export interface FacetOptions {
256
- readonly facets: readonly Facet[];
257
- readonly serviceSources?: readonly RemoteServiceSource[];
258
- readonly onError?: (error: Error) => void;
259
- }
260
- export interface FacetHost {
261
- readonly services: RemoteServiceProvider;
262
- /** Activate and replace facets with matching IDs without disconnecting consumer service handles. */
263
- reload(facets: readonly Facet[]): Promise<void>;
264
- dispose(): Promise<void>;
265
- }
266
- export interface LoadedFacets {
267
- readonly facets: readonly Facet[];
268
- dispose(): Promise<void>;
269
- }
270
- export interface FacetLoader {
271
- load(): Promise<LoadedFacets>;
84
+ onStatus(listener: (status: RefStatus, error: unknown) => void): () => void;
85
+ release(): void;
272
86
  }
87
+ export {};
273
88
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAEpE,YAAY,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,YAAY,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAEpE,iEAAiE;AACjE,MAAM,WAAW,UAAU,CAAC,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,iGAAiG;IACjG,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC;CACrC;AAED,+EAA+E;AAC/E,MAAM,WAAW,OAAO;IACvB,QAAQ,CAAC,WAAW,EAAE,WAAW,GAAG,SAAS,CAAC;IAC9C,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;IAC5C,QAAQ,IAAI,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,EAAE,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAEtG,KAAK,KAAK,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,IAAI,GAAG,KAAK,CAAC;AAE/C,iGAAiG;AACjG,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,SAAS,IAAI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