@c9up/eon 0.1.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 (123) hide show
  1. package/README.md +69 -0
  2. package/dist/EonProvider.d.ts +51 -0
  3. package/dist/EonProvider.d.ts.map +1 -0
  4. package/dist/EonProvider.js +154 -0
  5. package/dist/EonProvider.js.map +1 -0
  6. package/dist/connection/EonConnection.d.ts +116 -0
  7. package/dist/connection/EonConnection.d.ts.map +1 -0
  8. package/dist/connection/EonConnection.js +15 -0
  9. package/dist/connection/EonConnection.js.map +1 -0
  10. package/dist/connection/config.d.ts +56 -0
  11. package/dist/connection/config.d.ts.map +1 -0
  12. package/dist/connection/config.js +14 -0
  13. package/dist/connection/config.js.map +1 -0
  14. package/dist/connection/websocket.d.ts +16 -0
  15. package/dist/connection/websocket.d.ts.map +1 -0
  16. package/dist/connection/websocket.js +383 -0
  17. package/dist/connection/websocket.js.map +1 -0
  18. package/dist/decorators/superTable.d.ts +73 -0
  19. package/dist/decorators/superTable.d.ts.map +1 -0
  20. package/dist/decorators/superTable.js +98 -0
  21. package/dist/decorators/superTable.js.map +1 -0
  22. package/dist/index.d.ts +20 -0
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.js +19 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/ingest/schemaless.d.ts +22 -0
  27. package/dist/ingest/schemaless.d.ts.map +1 -0
  28. package/dist/ingest/schemaless.js +161 -0
  29. package/dist/ingest/schemaless.js.map +1 -0
  30. package/dist/ingest/sql.d.ts +23 -0
  31. package/dist/ingest/sql.d.ts.map +1 -0
  32. package/dist/ingest/sql.js +59 -0
  33. package/dist/ingest/sql.js.map +1 -0
  34. package/dist/ingest/stmt.d.ts +82 -0
  35. package/dist/ingest/stmt.d.ts.map +1 -0
  36. package/dist/ingest/stmt.js +246 -0
  37. package/dist/ingest/stmt.js.map +1 -0
  38. package/dist/metadata-keys.d.ts +17 -0
  39. package/dist/metadata-keys.d.ts.map +1 -0
  40. package/dist/metadata-keys.js +17 -0
  41. package/dist/metadata-keys.js.map +1 -0
  42. package/dist/query/TimeSeriesQuery.d.ts +121 -0
  43. package/dist/query/TimeSeriesQuery.d.ts.map +1 -0
  44. package/dist/query/TimeSeriesQuery.js +291 -0
  45. package/dist/query/TimeSeriesQuery.js.map +1 -0
  46. package/dist/query/native.d.ts +22 -0
  47. package/dist/query/native.d.ts.map +1 -0
  48. package/dist/query/native.js +135 -0
  49. package/dist/query/native.js.map +1 -0
  50. package/dist/repository/SuperTableRepository.d.ts +80 -0
  51. package/dist/repository/SuperTableRepository.d.ts.map +1 -0
  52. package/dist/repository/SuperTableRepository.js +232 -0
  53. package/dist/repository/SuperTableRepository.js.map +1 -0
  54. package/dist/schema/CreateStableSpec.d.ts +140 -0
  55. package/dist/schema/CreateStableSpec.d.ts.map +1 -0
  56. package/dist/schema/CreateStableSpec.js +41 -0
  57. package/dist/schema/CreateStableSpec.js.map +1 -0
  58. package/dist/schema/EonMigrationRunner.d.ts +71 -0
  59. package/dist/schema/EonMigrationRunner.d.ts.map +1 -0
  60. package/dist/schema/EonMigrationRunner.js +295 -0
  61. package/dist/schema/EonMigrationRunner.js.map +1 -0
  62. package/dist/schema/EonSchema.d.ts +128 -0
  63. package/dist/schema/EonSchema.d.ts.map +1 -0
  64. package/dist/schema/EonSchema.js +309 -0
  65. package/dist/schema/EonSchema.js.map +1 -0
  66. package/dist/schema/Migration.d.ts +47 -0
  67. package/dist/schema/Migration.d.ts.map +1 -0
  68. package/dist/schema/Migration.js +55 -0
  69. package/dist/schema/Migration.js.map +1 -0
  70. package/dist/schema/compile.d.ts +33 -0
  71. package/dist/schema/compile.d.ts.map +1 -0
  72. package/dist/schema/compile.js +70 -0
  73. package/dist/schema/compile.js.map +1 -0
  74. package/dist/schema/sync.d.ts +45 -0
  75. package/dist/schema/sync.d.ts.map +1 -0
  76. package/dist/schema/sync.js +102 -0
  77. package/dist/schema/sync.js.map +1 -0
  78. package/dist/services/connection.d.ts +33 -0
  79. package/dist/services/connection.d.ts.map +1 -0
  80. package/dist/services/connection.js +71 -0
  81. package/dist/services/connection.js.map +1 -0
  82. package/dist/testing/Factory.d.ts +43 -0
  83. package/dist/testing/Factory.d.ts.map +1 -0
  84. package/dist/testing/Factory.js +134 -0
  85. package/dist/testing/Factory.js.map +1 -0
  86. package/dist/testing/FakeEonConnection.d.ts +43 -0
  87. package/dist/testing/FakeEonConnection.d.ts.map +1 -0
  88. package/dist/testing/FakeEonConnection.js +315 -0
  89. package/dist/testing/FakeEonConnection.js.map +1 -0
  90. package/dist/testing/index.d.ts +34 -0
  91. package/dist/testing/index.d.ts.map +1 -0
  92. package/dist/testing/index.js +67 -0
  93. package/dist/testing/index.js.map +1 -0
  94. package/index.darwin-arm64.node +0 -0
  95. package/index.darwin-x64.node +0 -0
  96. package/index.linux-arm64-gnu.node +0 -0
  97. package/index.linux-x64-gnu.node +0 -0
  98. package/index.win32-x64-msvc.node +0 -0
  99. package/package.json +65 -0
  100. package/scripts/copy-napi.mjs +72 -0
  101. package/src/EonProvider.ts +222 -0
  102. package/src/connection/EonConnection.ts +146 -0
  103. package/src/connection/config.ts +60 -0
  104. package/src/connection/websocket.ts +436 -0
  105. package/src/decorators/superTable.ts +169 -0
  106. package/src/index.ts +118 -0
  107. package/src/ingest/schemaless.ts +211 -0
  108. package/src/ingest/sql.ts +73 -0
  109. package/src/ingest/stmt.ts +335 -0
  110. package/src/metadata-keys.ts +20 -0
  111. package/src/query/TimeSeriesQuery.ts +480 -0
  112. package/src/query/native.ts +180 -0
  113. package/src/repository/SuperTableRepository.ts +347 -0
  114. package/src/schema/CreateStableSpec.ts +184 -0
  115. package/src/schema/EonMigrationRunner.ts +378 -0
  116. package/src/schema/EonSchema.ts +396 -0
  117. package/src/schema/Migration.ts +66 -0
  118. package/src/schema/compile.ts +109 -0
  119. package/src/schema/sync.ts +142 -0
  120. package/src/services/connection.ts +89 -0
  121. package/src/testing/Factory.ts +186 -0
  122. package/src/testing/FakeEonConnection.ts +351 -0
  123. package/src/testing/index.ts +81 -0
package/README.md ADDED
@@ -0,0 +1,69 @@
1
+ # @c9up/eon
2
+
3
+ Time-series ORM for Node.js, backed by [TDengine](https://tdengine.com). AdonisJS/Lucid-shaped decorators, a fluent windowed query builder, and injection-safe SQL compiled in Rust.
4
+
5
+ ## Usage
6
+
7
+ Model a super-table declaratively — the same way you model an Atlas entity, plus a `@Tag` decorator for TDengine's tag columns:
8
+
9
+ ```typescript
10
+ import { SuperTable, Timestamp, Column, Tag } from '@c9up/eon'
11
+
12
+ @SuperTable('meters')
13
+ class Meter {
14
+ @Timestamp() declare ts: bigint
15
+ @Column({ type: 'float' }) declare current: number
16
+ @Column({ type: 'int' }) declare voltage: number
17
+ @Tag({ type: 'int' }) declare groupId: number
18
+ @Tag({ type: 'nchar', length: 24 }) declare location: string
19
+ }
20
+ ```
21
+
22
+ Write points through the repository. Child tables are created automatically from each tag set on first insert:
23
+
24
+ ```typescript
25
+ import { SuperTableRepository } from '@c9up/eon'
26
+
27
+ const meters = new SuperTableRepository(Meter, connection)
28
+
29
+ await meters.ingest({ ts: 1700000000000n, current: 10.3, voltage: 219, groupId: 2, location: 'SF' })
30
+ await meters.ingestMany(points) // columnar STMT bulk — the default high-throughput path
31
+ ```
32
+
33
+ Read with a fluent, windowed query builder (Lucid-shaped, plus TDengine's time-window clauses):
34
+
35
+ ```typescript
36
+ const rows = await meters.query()
37
+ .select([{ pseudo: '_wstart' }, { function: 'avg', column: 'voltage', alias: 'avgV' }])
38
+ .whereBetween('ts', [start, end])
39
+ .partitionBy('groupId')
40
+ .interval('1m')
41
+ .fill('prev')
42
+ .orderBy('_wstart', 'asc')
43
+ .limit(100) // thenable — `await` runs it
44
+ ```
45
+
46
+ ## Features
47
+
48
+ - **Decorators** — `@SuperTable`, `@Timestamp`, `@Column`, `@Tag`; metadata-driven schema (`syncSuperTable`, `createChildTable`, `dropSuperTable`) compiled to real TDengine DDL.
49
+ - **Three ingest paths** — `ingestMany` (columnar STMT, default), `ingestSchemaless` (InfluxDB line protocol), `ingestSql` (literal INSERT). Child tables auto-created per tag set.
50
+ - **Windowed query builder** — `where` / `whereBetween` / `select` (functions + `_wstart` / `_wend` / `_wduration` pseudo-columns) / `partitionBy` / `interval` / `sliding` / `fill` / `orderBy` / `limit` / `offset`; thenable; `query(mapPoint)` for typed rows.
51
+ - **Injection-safe by construction** — every identifier and value is compiled and escaped in a Rust `eon-query` core (NAPI); TypeScript never string-builds SQL.
52
+ - **ws-first transport** over `@tdengine/websocket`, with an `EonProvider` boot/shutdown lifecycle and container-token singletons (`eon`, `eon.connection`, `eon:<name>`).
53
+ - **Precision-safe** — nanosecond timestamps and `BIGINT` columns cross the JSON/NAPI boundary and hydrate as `bigint`, never a lossy `number`.
54
+
55
+ ## Subpath exports
56
+
57
+ - `@c9up/eon` — decorators, repository, query builder, schema helpers, `compileStatementNative`.
58
+ - `@c9up/eon/provider` — `EonProvider` (default export) for the Ream container.
59
+ - `@c9up/eon/services/connection` — the module-level connection singleton.
60
+ - `@c9up/eon/testing` — test helpers.
61
+
62
+ ## Pinned versions
63
+
64
+ - TDengine server: `3.3.6.13`
65
+ - `@tdengine/websocket`: `3.5.0`
66
+
67
+ ## License
68
+
69
+ MIT
@@ -0,0 +1,51 @@
1
+ /**
2
+ * EonProvider — Ream provider for the Eon time-series layer.
3
+ *
4
+ * On boot it opens the configured ws-first TDengine connection(s) via
5
+ * `connectWsEon` and registers them in the container (`eon` / `eon.connection`
6
+ * / `eon:<name>`), plus the module-level `services/connection` singleton. The
7
+ * transport-independent compiler is registered under `eon.compiler`. Shutdown
8
+ * closes every connection (fail-open) and releases the singletons.
9
+ *
10
+ * Agnostic leaf: consumes the host framework's app context STRUCTURALLY — it
11
+ * never imports `@c9up/ream`. Any context exposing `config.get(key)` and
12
+ * `container.singleton(token, factory)` satisfies the contract.
13
+ */
14
+ import type { EonConnectionConfig } from "./connection/config.js";
15
+ import type { EonConnection } from "./connection/EonConnection.js";
16
+ import { type CompiledStatement, type EonDialect } from "./query/native.js";
17
+ /**
18
+ * Structural slice of the host framework's app context — only the surface
19
+ * EonProvider uses. Mirrors atlas `AtlasAppContext`. The `token` type mirrors
20
+ * ream's `ServiceToken` union so this can grow into Symbol/ctor tokens without
21
+ * re-coupling to `@c9up/ream`; EonProvider uses `string` tokens today.
22
+ */
23
+ export interface EonAppContext {
24
+ container: {
25
+ singleton(token: string | symbol | (new (...args: never[]) => unknown), factory: () => unknown): void;
26
+ };
27
+ config: {
28
+ get<T = unknown>(key: string): T | undefined;
29
+ };
30
+ }
31
+ /**
32
+ * The transport-independent compiler service registered under `eon.compiler`.
33
+ */
34
+ export interface EonService {
35
+ compile(spec: object, dialect?: EonDialect): CompiledStatement;
36
+ }
37
+ /**
38
+ * How EonProvider opens a connection. Defaults to `connectWsEon`; tests inject a
39
+ * fake so the boot/shutdown wiring is exercised without a live TDengine server
40
+ * (eon has no in-process transport, unlike atlas's sqlite).
41
+ */
42
+ export type EonConnector = (config: EonConnectionConfig) => Promise<EonConnection>;
43
+ export declare class EonProvider {
44
+ #private;
45
+ constructor(app: EonAppContext, connect?: EonConnector);
46
+ register(): void;
47
+ boot(): Promise<void>;
48
+ shutdown(): Promise<void>;
49
+ }
50
+ export default EonProvider;
51
+ //# sourceMappingURL=EonProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EonProvider.d.ts","sourceRoot":"","sources":["../src/EonProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAa,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EACN,KAAK,iBAAiB,EAEtB,KAAK,UAAU,EACf,MAAM,mBAAmB,CAAC;AAE3B;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC7B,SAAS,EAAE;QACV,SAAS,CACR,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,CAAC,KAAK,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,CAAC,EAC5D,OAAO,EAAE,MAAM,OAAO,GACpB,IAAI,CAAC;KACR,CAAC;IACF,MAAM,EAAE;QAAE,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAAA;KAAE,CAAC;CACzD;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,iBAAiB,CAAC;CAC/D;AAED;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,CAC1B,MAAM,EAAE,mBAAmB,KACvB,OAAO,CAAC,aAAa,CAAC,CAAC;AAE5B,qBAAa,WAAW;;gBAQX,GAAG,EAAE,aAAa,EAAE,OAAO,GAAE,YAA2B;IAKpE,QAAQ,IAAI,IAAI;IAEV,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAuFrB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CA4D/B;AAID,eAAe,WAAW,CAAC"}
@@ -0,0 +1,154 @@
1
+ /**
2
+ * EonProvider — Ream provider for the Eon time-series layer.
3
+ *
4
+ * On boot it opens the configured ws-first TDengine connection(s) via
5
+ * `connectWsEon` and registers them in the container (`eon` / `eon.connection`
6
+ * / `eon:<name>`), plus the module-level `services/connection` singleton. The
7
+ * transport-independent compiler is registered under `eon.compiler`. Shutdown
8
+ * closes every connection (fail-open) and releases the singletons.
9
+ *
10
+ * Agnostic leaf: consumes the host framework's app context STRUCTURALLY — it
11
+ * never imports `@c9up/ream`. Any context exposing `config.get(key)` and
12
+ * `container.singleton(token, factory)` satisfies the contract.
13
+ */
14
+ import { connectWsEon } from "./connection/websocket.js";
15
+ import { compileStatementNative, } from "./query/native.js";
16
+ export class EonProvider {
17
+ #app;
18
+ #connect;
19
+ /** connection name → open connection. Populated at boot. */
20
+ #connections = new Map();
21
+ /** Set once a full boot opened connections — guards against a leaking re-boot. */
22
+ #booted = false;
23
+ constructor(app, connect = connectWsEon) {
24
+ this.#app = app;
25
+ this.#connect = connect;
26
+ }
27
+ register() { }
28
+ async boot() {
29
+ if (this.#booted) {
30
+ throw new Error("EonProvider: boot() has already opened connections; a second boot would overwrite and leak them. Call shutdown() first, or construct a new provider.");
31
+ }
32
+ // The compiler is transport-independent — register it unconditionally.
33
+ const service = {
34
+ compile: (spec, dialect) => compileStatementNative(spec, dialect),
35
+ };
36
+ this.#app.container.singleton("eon.compiler", () => service);
37
+ const config = this.#app.config.get("timeseries") ??
38
+ this.#app.config.get("eon");
39
+ if (!config)
40
+ return;
41
+ const { connections, defaultName } = this.#resolveConnections(config);
42
+ // Open every connection in parallel. `allSettled` lets us distinguish
43
+ // successes from failures without leaking the already-opened ones: on any
44
+ // failure we close every success before rethrowing (no partial-boot leak).
45
+ const entries = Object.entries(connections);
46
+ const results = await Promise.allSettled(entries.map(([, settings]) => this.#connect(settings)));
47
+ const failures = [];
48
+ const successes = [];
49
+ results.forEach((result, i) => {
50
+ const entry = entries[i];
51
+ if (!entry)
52
+ return; // unreachable — allSettled preserves length/order
53
+ const [name] = entry;
54
+ if (result.status === "fulfilled") {
55
+ successes.push({ name, conn: result.value });
56
+ }
57
+ else {
58
+ failures.push({ name, error: result.reason });
59
+ }
60
+ });
61
+ const first = failures[0];
62
+ if (first) {
63
+ await Promise.allSettled(successes.map((s) => s.conn.close()));
64
+ const others = failures
65
+ .slice(1)
66
+ .map((f) => `${f.name}: ${String(f.error)}`)
67
+ .join("; ");
68
+ throw new Error(`EonProvider: failed to open ${failures.length} connection(s) — ` +
69
+ `'${first.name}' failed: ${String(first.error)}` +
70
+ (others ? ` (also: ${others})` : ""));
71
+ }
72
+ for (const { name, conn } of successes) {
73
+ this.#connections.set(name, conn);
74
+ }
75
+ const defaultConn = this.#connections.get(defaultName);
76
+ if (!defaultConn) {
77
+ // Same rollback the connect-failure branch does above — close the
78
+ // already-opened sockets before throwing, else they leak (and #booted
79
+ // stays false, so a retry would open even more).
80
+ await Promise.allSettled([...this.#connections.values()].map((conn) => conn.close()));
81
+ this.#connections.clear();
82
+ throw new Error(`EonProvider: default connection '${defaultName}' is not defined in config.timeseries.connections`);
83
+ }
84
+ // Register the container singletons only AFTER validation succeeds. The
85
+ // throw path above registers none, so a failed boot never leaves an
86
+ // `eon:<name>` factory resolving to a now-closed connection.
87
+ for (const { name, conn } of successes) {
88
+ this.#app.container.singleton(`eon:${name}`, () => conn);
89
+ }
90
+ this.#app.container.singleton("eon", () => defaultConn);
91
+ this.#app.container.singleton("eon.connection", () => defaultConn);
92
+ // Populate the `@c9up/eon/services/connection` singleton so apps can
93
+ // `import connection from '@c9up/eon/services/connection'` anywhere. Lazy
94
+ // import so a type-only discovery scan does not pull the module at
95
+ // construction time.
96
+ const { setConnection } = await import("./services/connection.js");
97
+ setConnection(defaultConn);
98
+ this.#booted = true;
99
+ }
100
+ async shutdown() {
101
+ // Close every connection in parallel. `allSettled` (fail-open) so a single
102
+ // stuck close doesn't block the rest, but failures are aggregated and
103
+ // rethrown so supervisors see a non-zero shutdown signal. The map + module
104
+ // singleton are cleared unconditionally (never hand out closed handles).
105
+ const named = [...this.#connections.entries()];
106
+ const results = await Promise.allSettled(named.map(([, c]) => c.close()));
107
+ this.#connections.clear();
108
+ this.#booted = false; // allow a fresh boot() after a clean shutdown
109
+ const { clearConnection } = await import("./services/connection.js");
110
+ for (const [, conn] of named)
111
+ clearConnection(conn);
112
+ const errors = results
113
+ .map((result, i) => result.status === "rejected"
114
+ ? { name: named[i]?.[0] ?? "unknown", error: result.reason }
115
+ : null)
116
+ .filter((x) => x !== null);
117
+ if (errors.length > 0) {
118
+ const summary = errors
119
+ .map((e) => `'${e.name}': ${String(e.error)}`)
120
+ .join("; ");
121
+ throw new AggregateError(errors.map((e) => e.error), `EonProvider: ${errors.length} connection(s) failed to close — ${summary}`);
122
+ }
123
+ }
124
+ /** Normalize the config into a `{ name → EonConnectionConfig }` map + default name. */
125
+ #resolveConnections(config) {
126
+ if (config.connections && Object.keys(config.connections).length > 0) {
127
+ return {
128
+ connections: config.connections,
129
+ defaultName: config.default ?? "primary",
130
+ };
131
+ }
132
+ // Single-connection shape — promote to a one-entry map under "primary"
133
+ // (mirror atlas: copy the connection fields, drop `default`/`connections`).
134
+ return {
135
+ connections: {
136
+ primary: {
137
+ url: config.url,
138
+ user: config.user,
139
+ password: config.password,
140
+ database: config.database,
141
+ token: config.token,
142
+ timeoutMs: config.timeoutMs,
143
+ connectRetries: config.connectRetries,
144
+ connectBackoffMs: config.connectBackoffMs,
145
+ },
146
+ },
147
+ defaultName: "primary",
148
+ };
149
+ }
150
+ }
151
+ // ream's provider loader constructs `new mod.default(app)` (atlas parity:
152
+ // `export default class AtlasProvider`). The named export stays for tests.
153
+ export default EonProvider;
154
+ //# sourceMappingURL=EonProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EonProvider.js","sourceRoot":"","sources":["../src/EonProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAEN,sBAAsB,GAEtB,MAAM,mBAAmB,CAAC;AAkC3B,MAAM,OAAO,WAAW;IACd,IAAI,CAAgB;IACpB,QAAQ,CAAe;IAChC,4DAA4D;IACnD,YAAY,GAAG,IAAI,GAAG,EAAyB,CAAC;IACzD,kFAAkF;IAClF,OAAO,GAAG,KAAK,CAAC;IAEhB,YAAY,GAAkB,EAAE,UAAwB,YAAY;QACnE,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,QAAQ,KAAU,CAAC;IAEnB,KAAK,CAAC,IAAI;QACT,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CACd,sJAAsJ,CACtJ,CAAC;QACH,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I,MAAM,CAAC,WAAW,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtE,OAAO;gBACN,WAAW,EAAE,MAAM,CAAC,WAAW;gBAC/B,WAAW,EAAE,MAAM,CAAC,OAAO,IAAI,SAAS;aACxC,CAAC;QACH,CAAC;QACD,uEAAuE;QACvE,4EAA4E;QAC5E,OAAO;YACN,WAAW,EAAE;gBACZ,OAAO,EAAE;oBACR,GAAG,EAAE,MAAM,CAAC,GAAG;oBACf,IAAI,EAAE,MAAM,CAAC,IAAI;oBACjB,QAAQ,EAAE,MAAM,CAAC,QAAQ;oBACzB,QAAQ,EAAE,MAAM,CAAC,QAAQ;oBACzB,KAAK,EAAE,MAAM,CAAC,KAAK;oBACnB,SAAS,EAAE,MAAM,CAAC,SAAS;oBAC3B,cAAc,EAAE,MAAM,CAAC,cAAc;oBACrC,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;iBACzC;aACD;YACD,WAAW,EAAE,SAAS;SACtB,CAAC;IACH,CAAC;CACD;AAED,0EAA0E;AAC1E,2EAA2E;AAC3E,eAAe,WAAW,CAAC"}
@@ -0,0 +1,116 @@
1
+ /**
2
+ * `EonConnection` — the transport-agnostic seam every eon transport satisfies.
3
+ *
4
+ * The WebSocket implementation (`connectWsEon`) is ONE implementation. A
5
+ * deferred native `taos` implementation (`connectNativeEon`, opt-in, a later
6
+ * story — memory `project_eon_transport_decision`) satisfies this same
7
+ * interface, and the locked columnar bulk-ingest STMT method (spike 58-0 AC4)
8
+ * is added onto a live connection in story 58.4. Neither is built here, but the
9
+ * seam must not preclude them — keep `exec`/`query`/`ping`/`close`
10
+ * transport-neutral (no ws-specific type leaks through).
11
+ *
12
+ * `exec`/`query` take LITERAL SQL only. TDengine binds positional `?`
13
+ * placeholders exclusively through the STMT path (58.4 ingest), so the 58.1
14
+ * compiler's `params` array is NOT threaded through `exec`: a compiled
15
+ * param-free statement runs as literal SQL, a parameterised one waits for STMT.
16
+ */
17
+ export interface EonConnection {
18
+ /**
19
+ * Which transport backs this connection. A future native impl reports
20
+ * `"native"`; the in-memory test double (`FakeEonConnection`, 58.6) reports
21
+ * `"fake"`.
22
+ */
23
+ readonly transport: "websocket" | "native" | "fake";
24
+ /** Run a literal DDL/DML statement (CREATE / USE / INSERT). */
25
+ exec(sql: string): Promise<{
26
+ rowsAffected: number;
27
+ }>;
28
+ /** Run a literal SELECT; rows are mapped to objects keyed by column name. */
29
+ query<T = Record<string, unknown>>(sql: string): Promise<T[]>;
30
+ /** Liveness probe — a cheap round-trip to the server. */
31
+ ping(): Promise<void>;
32
+ /**
33
+ * Columnar STMT bulk ingest (story 58.4) — the default high-throughput write
34
+ * path. Binds each child table's whole-column typed arrays once per batch
35
+ * through the transport's STMT2 API, so no per-row object crosses the
36
+ * boundary (the locked 58.0 columnar contract, kept even on the ws path).
37
+ *
38
+ * It lives on the connection — not as a free function — because only the
39
+ * transport owns the live STMT handle; the `transport` discriminant is a
40
+ * string, never the raw ws socket. A future native impl satisfies this same
41
+ * agnostic contract, so ingest code never imports a ws-specific type.
42
+ */
43
+ ingestColumnar(request: EonColumnarIngest): Promise<{
44
+ rowsAffected: number;
45
+ }>;
46
+ /**
47
+ * Schemaless line-protocol ingest (InfluxDB / OpenTSDB). A documented ~8–10×
48
+ * slower helper than STMT — NOT the default bulk path (AC4). Bypasses SQL
49
+ * entirely; the transport maps the agnostic protocol/precision to its native
50
+ * enums.
51
+ */
52
+ schemaless(lines: readonly string[], options?: EonSchemalessOptions): Promise<void>;
53
+ /** Close THIS connection (never the process-global connector — D6). */
54
+ close(): Promise<void>;
55
+ }
56
+ /**
57
+ * How a bound column's values are typed for the STMT columnar bind path. Mirrors
58
+ * the compiler's `ColumnTypeKind` (camelCase) so ingest code carries the column
59
+ * metadata kind straight through; the transport maps each kind to its native
60
+ * columnar setter. No ws-specific type leaks into this seam.
61
+ */
62
+ export type EonBindKind = "timestamp" | "bool" | "tinyInt" | "smallInt" | "int" | "bigInt" | "float" | "double" | "varchar" | "nchar" | "varbinary" | "json" | "decimal";
63
+ /**
64
+ * One column's values in struct-of-arrays layout plus the kind that selects the
65
+ * transport's typed setter. `values` holds the WHOLE column (N rows) for metric
66
+ * columns, or a single-element array for a child's tag value.
67
+ */
68
+ export interface EonBoundColumn {
69
+ readonly kind: EonBindKind;
70
+ readonly values: unknown[];
71
+ }
72
+ /** One child table's columnar batch: its name, tag values, and metric columns. */
73
+ export interface EonChildBatch {
74
+ /** The (deterministic) child-table name bound via the STMT `?` table slot. */
75
+ readonly table: string;
76
+ /** Tag values (one single-element column per tag), bound before the columns. */
77
+ readonly tags: readonly EonBoundColumn[];
78
+ /** Value columns in prepared order (timestamp first); each holds the column. */
79
+ readonly columns: readonly EonBoundColumn[];
80
+ }
81
+ /**
82
+ * A columnar STMT bulk-ingest request: one prepared template reused across every
83
+ * child batch. `sql` is the compiler-produced STMT template
84
+ * (`INSERT INTO ? USING <stable> (…) TAGS (?) VALUES (?)`).
85
+ */
86
+ export interface EonColumnarIngest {
87
+ readonly sql: string;
88
+ readonly children: readonly EonChildBatch[];
89
+ }
90
+ /** Line-protocol variants for the schemaless path. */
91
+ export type EonLineProtocol = "influxdb" | "opentsdb-telnet" | "opentsdb-json";
92
+ /** Timestamp precision for the schemaless path. */
93
+ export type EonSchemalessPrecision = "hours" | "minutes" | "seconds" | "milliseconds" | "microseconds" | "nanoseconds";
94
+ /** Options for {@link EonConnection.schemaless}. */
95
+ export interface EonSchemalessOptions {
96
+ /** Line-protocol variant. Default `"influxdb"`. */
97
+ readonly protocol?: EonLineProtocol;
98
+ /** Timestamp precision. Default `"milliseconds"`. */
99
+ readonly precision?: EonSchemalessPrecision;
100
+ /** Child-table TTL in days (0 = none). Default `0`. */
101
+ readonly ttl?: number;
102
+ }
103
+ /**
104
+ * Error thrown by an eon transport. When the failure originated in the TDengine
105
+ * connector, `code` carries the connector's numeric error code verbatim (never
106
+ * swallowed), so callers can branch on it.
107
+ */
108
+ export declare class EonConnectionError extends Error {
109
+ /** The underlying TDengine numeric error code, when the failure came from the connector. */
110
+ readonly code?: number;
111
+ constructor(message: string, options?: {
112
+ cause?: unknown;
113
+ code?: number;
114
+ });
115
+ }
116
+ //# sourceMappingURL=EonConnection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EonConnection.d.ts","sourceRoot":"","sources":["../../src/connection/EonConnection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,aAAa;IAC7B;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE,WAAW,GAAG,QAAQ,GAAG,MAAM,CAAC;IACpD,+DAA+D;IAC/D,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACrD,6EAA6E;IAC7E,KAAK,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;IAC9D,yDAAyD;IACzD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB;;;;;;;;;;OAUG;IACH,cAAc,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC;QAAE,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC9E;;;;;OAKG;IACH,UAAU,CACT,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,OAAO,CAAC,EAAE,oBAAoB,GAC5B,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,uEAAuE;IACvE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACvB;AAED;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GACpB,WAAW,GACX,MAAM,GACN,SAAS,GACT,UAAU,GACV,KAAK,GACL,QAAQ,GACR,OAAO,GACP,QAAQ,GACR,SAAS,GACT,OAAO,GACP,WAA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,CAAA;KAAE;CAQzE"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Error thrown by an eon transport. When the failure originated in the TDengine
3
+ * connector, `code` carries the connector's numeric error code verbatim (never
4
+ * swallowed), so callers can branch on it.
5
+ */
6
+ export class EonConnectionError extends Error {
7
+ /** The underlying TDengine numeric error code, when the failure came from the connector. */
8
+ code;
9
+ constructor(message, options) {
10
+ super(message, options?.cause !== undefined ? { cause: options.cause } : undefined);
11
+ this.name = "EonConnectionError";
12
+ this.code = options?.code;
13
+ }
14
+ }
15
+ //# sourceMappingURL=EonConnection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EonConnection.js","sourceRoot":"","sources":["../../src/connection/EonConnection.ts"],"names":[],"mappings":"AAgIA;;;;GAIG;AACH,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC5C,4FAA4F;IACnF,IAAI,CAAU;IAEvB,YAAY,OAAe,EAAE,OAA4C;QACxE,KAAK,CACJ,OAAO,EACP,OAAO,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CACnE,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,IAAI,CAAC,IAAI,GAAG,OAAO,EAAE,IAAI,CAAC;IAC3B,CAAC;CACD"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Eon connection configuration — mirrors atlas `ConnectionConfig` /
3
+ * `AtlasDatabaseConfig` (`AtlasProvider.ts`), adapted for the ws-first TDengine
4
+ * transport: pool sizing / pragmas / migrations / schema-verification are
5
+ * dropped (no pool — D7); URL + auth + a connect-retry knob remain.
6
+ *
7
+ * No env-var reading happens here: the host `config.get("timeseries")` supplies
8
+ * the resolved object (agnostic leaf — eon never touches `process.env`).
9
+ */
10
+ /** One TDengine connection's settings. */
11
+ export interface EonConnectionConfig {
12
+ /** taosAdapter WebSocket URL, e.g. `ws://localhost:6041`. */
13
+ url: string;
14
+ /** Auth user — supplied to the connector via a setter, never embedded in the URL. */
15
+ user?: string;
16
+ /** Auth password. */
17
+ password?: string;
18
+ /** Default database to `USE` on connect. */
19
+ database?: string;
20
+ /** Cloud / bearer token auth (taosAdapter) — alternative to user/password. */
21
+ token?: string;
22
+ /**
23
+ * Per-request timeout in ms, passed to `WSConfig.setTimeOut`. Also used as the
24
+ * overall connect deadline (a stalled WS handshake rejects instead of wedging
25
+ * boot). Unset → no JS-side connect deadline.
26
+ */
27
+ timeoutMs?: number;
28
+ /**
29
+ * Retry the INITIAL connection if it fails — covers a server that starts a
30
+ * moment after the app (docker-compose / k8s cold start). Extra attempts
31
+ * beyond the first (default 0 — single attempt). Not a per-query reconnect
32
+ * (D7: one long-lived connection, no pool).
33
+ */
34
+ connectRetries?: number;
35
+ /** Base backoff in ms between connect attempts (exponential, capped 30s; default 200). */
36
+ connectBackoffMs?: number;
37
+ }
38
+ /**
39
+ * Full eon config — single-connection OR multi-connection (atlas parity).
40
+ *
41
+ * 58.2 ships single-connection end-to-end; the `default` / `connections` shape
42
+ * is structural (mirrors atlas) but not yet exercised — named connections /
43
+ * taosAdapter HA slot behind this same shape in a later story.
44
+ */
45
+ export interface EonConfig extends EonConnectionConfig {
46
+ /** Name of the default connection when `connections` is set. Defaults to `"primary"`. */
47
+ default?: string;
48
+ /**
49
+ * Named connections. When present, the top-level `url` is treated as
50
+ * `connections[default].url`.
51
+ */
52
+ connections?: Record<string, EonConnectionConfig>;
53
+ }
54
+ /** Identity helper for typed config authoring — mirrors atlas `defineConfig`. */
55
+ export declare function defineConfig(config: EonConfig): EonConfig;
56
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/connection/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,0CAA0C;AAC1C,MAAM,WAAW,mBAAmB;IACnC,6DAA6D;IAC7D,GAAG,EAAE,MAAM,CAAC;IACZ,qFAAqF;IACrF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qBAAqB;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,4CAA4C;IAC5C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,8EAA8E;IAC9E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,0FAA0F;IAC1F,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,SAAU,SAAQ,mBAAmB;IACrD,yFAAyF;IACzF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;CAClD;AAED,iFAAiF;AACjF,wBAAgB,YAAY,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,CAEzD"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Eon connection configuration — mirrors atlas `ConnectionConfig` /
3
+ * `AtlasDatabaseConfig` (`AtlasProvider.ts`), adapted for the ws-first TDengine
4
+ * transport: pool sizing / pragmas / migrations / schema-verification are
5
+ * dropped (no pool — D7); URL + auth + a connect-retry knob remain.
6
+ *
7
+ * No env-var reading happens here: the host `config.get("timeseries")` supplies
8
+ * the resolved object (agnostic leaf — eon never touches `process.env`).
9
+ */
10
+ /** Identity helper for typed config authoring — mirrors atlas `defineConfig`. */
11
+ export function defineConfig(config) {
12
+ return config;
13
+ }
14
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/connection/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAgDH,iFAAiF;AACjF,MAAM,UAAU,YAAY,CAAC,MAAiB;IAC7C,OAAO,MAAM,CAAC;AACf,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * WebSocket implementation of `EonConnection` over `@tdengine/websocket` 3.5.0
3
+ * (ws-only via taosAdapter — no libtaos, no native FFI, D1). The spike-proven
4
+ * recipe: `WSConfig` + setters → `sqlConnect`; cursor-decode SELECT rows into
5
+ * column-name-keyed objects; TIMESTAMP / BIGINT stay `BigInt` epoch values (no
6
+ * lossy `Date` coercion — the consuming ORM layer decides, D4).
7
+ */
8
+ import type { EonConnectionConfig } from "./config.js";
9
+ import { type EonConnection } from "./EonConnection.js";
10
+ /**
11
+ * Connect to TDengine over WebSocket and return a transport-agnostic
12
+ * `EonConnection`. Credentials go through `WSConfig` setters, never embedded in
13
+ * the URL. The returned object is a single long-lived connection (no pool, D7).
14
+ */
15
+ export declare function connectWsEon(config: EonConnectionConfig): Promise<EonConnection>;
16
+ //# sourceMappingURL=websocket.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"websocket.d.ts","sourceRoot":"","sources":["../../src/connection/websocket.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAaH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAGN,KAAK,aAAa,EAKlB,MAAM,oBAAoB,CAAC;AA8M5B;;;;GAIG;AACH,wBAAsB,YAAY,CACjC,MAAM,EAAE,mBAAmB,GACzB,OAAO,CAAC,aAAa,CAAC,CAkMxB"}