@lunora/d1 1.0.0-alpha.16 → 1.0.0-alpha.18

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.
@@ -1,21 +1,23 @@
1
1
  /**
2
- * The Lunora **D1 dialect** the single source of truth for how `.global()`
3
- * tables are physically shaped in D1.
2
+ * Canonical SQL identifier quoter shared by `@lunora/d1` and `@lunora/do`.
4
3
  *
5
- * Both the runtime (`runD1GlobalTableMigrations` in `d1-ctx-db.ts`, which
6
- * auto-provisions tables) and the `lunora migrate generate` SQL emitter
7
- * (`@lunora/cli`'s `migration-diff.ts`) derive their DDL from these helpers, so
8
- * the table a migration writes is byte-identical to the one the runtime creates.
9
- * Previously each encoded the dialect independently and a comment begged them to
10
- * stay "in lockstep"; this module makes the lockstep structural.
4
+ * Double-quotes a SQL identifier and escapes any embedded double quotes by
5
+ * doubling them (`"` → `""`) the ANSI/SQLite/Postgres rule. This is a
6
+ * security-relevant primitive (it is the sole defense against identifier
7
+ * injection wherever a table/column name is spliced into raw SQL), so it must
8
+ * have exactly ONE definition rather than byte-identical copies that can drift.
11
9
  *
12
- * Exposed as the `@lunora/d1/dialect` subpath. Pure no runtime dependencies
13
- * so the CLI can import it without pulling the D1 runtime.
10
+ * Like `shared/stable-key.ts`, it is deliberately **not** a package: `@lunora/d1`
11
+ * and `@lunora/do` sit on the same tier with no lower-level package to host it,
12
+ * so each imports this file by relative path and the bundler (packem/rollup)
13
+ * inlines it — no runtime dependency edge, duplicated only in emitted output.
14
+ * Keep it genuinely zero-dependency (relative/built-in imports only) or inlining
15
+ * breaks. Consumers must drop `outDir`/`rootDir` from their `tsconfig.json` (a
16
+ * set `rootDir` raises TS6059 for this out-of-package file under `tsc --noEmit`).
14
17
  */
18
+ declare const quoteIdentifier: (name: string) => string;
15
19
  /** SQLite column type affinities Lunora emits. */
16
20
  type SqlAffinity = "BLOB" | "INTEGER" | "REAL" | "TEXT";
17
- /** Double-quote (and escape) a SQL identifier. */
18
- declare const quoteIdentifier: (name: string) => string;
19
21
  /**
20
22
  * SQLite affinity for a column by its validator `kind`, chosen so the value the
21
23
  * D1 layer serializes round-trips intact:
package/dist/dialect.d.ts CHANGED
@@ -1,21 +1,23 @@
1
1
  /**
2
- * The Lunora **D1 dialect** the single source of truth for how `.global()`
3
- * tables are physically shaped in D1.
2
+ * Canonical SQL identifier quoter shared by `@lunora/d1` and `@lunora/do`.
4
3
  *
5
- * Both the runtime (`runD1GlobalTableMigrations` in `d1-ctx-db.ts`, which
6
- * auto-provisions tables) and the `lunora migrate generate` SQL emitter
7
- * (`@lunora/cli`'s `migration-diff.ts`) derive their DDL from these helpers, so
8
- * the table a migration writes is byte-identical to the one the runtime creates.
9
- * Previously each encoded the dialect independently and a comment begged them to
10
- * stay "in lockstep"; this module makes the lockstep structural.
4
+ * Double-quotes a SQL identifier and escapes any embedded double quotes by
5
+ * doubling them (`"` → `""`) the ANSI/SQLite/Postgres rule. This is a
6
+ * security-relevant primitive (it is the sole defense against identifier
7
+ * injection wherever a table/column name is spliced into raw SQL), so it must
8
+ * have exactly ONE definition rather than byte-identical copies that can drift.
11
9
  *
12
- * Exposed as the `@lunora/d1/dialect` subpath. Pure no runtime dependencies
13
- * so the CLI can import it without pulling the D1 runtime.
10
+ * Like `shared/stable-key.ts`, it is deliberately **not** a package: `@lunora/d1`
11
+ * and `@lunora/do` sit on the same tier with no lower-level package to host it,
12
+ * so each imports this file by relative path and the bundler (packem/rollup)
13
+ * inlines it — no runtime dependency edge, duplicated only in emitted output.
14
+ * Keep it genuinely zero-dependency (relative/built-in imports only) or inlining
15
+ * breaks. Consumers must drop `outDir`/`rootDir` from their `tsconfig.json` (a
16
+ * set `rootDir` raises TS6059 for this out-of-package file under `tsc --noEmit`).
14
17
  */
18
+ declare const quoteIdentifier: (name: string) => string;
15
19
  /** SQLite column type affinities Lunora emits. */
16
20
  type SqlAffinity = "BLOB" | "INTEGER" | "REAL" | "TEXT";
17
- /** Double-quote (and escape) a SQL identifier. */
18
- declare const quoteIdentifier: (name: string) => string;
19
21
  /**
20
22
  * SQLite affinity for a column by its validator `kind`, chosen so the value the
21
23
  * D1 layer serializes round-trips intact:
package/dist/dialect.mjs CHANGED
@@ -1,4 +1,5 @@
1
- const quoteIdentifier = (name) => `"${name.replaceAll('"', '""')}"`;
1
+ import { quoteIdentifier } from './packem_shared/quoteIdentifier-B-ZeSe1V.mjs';
2
+
2
3
  const sqlAffinityForKind = (kind) => {
3
4
  switch (kind) {
4
5
  case "boolean": {
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { exportGlobalRows, importGlobalRows, selectGlobalTables } from './packem_shared/exportGlobalRows-BGCPm_nA.mjs';
1
+ export { exportGlobalRows, importGlobalRows, selectGlobalTables } from './packem_shared/exportGlobalRows-DR6UiAZ8.mjs';
2
2
  export { D1Client, D1Session } from './packem_shared/D1Client-DA3flo1o.mjs';
3
3
  export { createD1CtxDb, readD1CdcChanges, runD1AggregateMigrations, runD1CdcMigration, runD1GlobalTableMigrations, runD1RankMigrations, runD1SearchMigrations, trimD1CdcChanges } from './packem_shared/createD1CtxDb-BMR8J0dT.mjs';
4
4
  export { facetGlobalColumn, listGlobalTables, readGlobalTablePage } from './packem_shared/facetGlobalColumn-C6u_WMIY.mjs';
@@ -1,7 +1,7 @@
1
+ import { quoteIdentifier } from './quoteIdentifier-B-ZeSe1V.mjs';
1
2
  import { decodeGlobalRow } from '@lunora/sql-store';
2
3
 
3
4
  const DEFAULT_BATCH_SIZE = 200;
4
- const quoteIdentifier = (name) => `"${name.replaceAll('"', '""')}"`;
5
5
  const selectGlobalTables = (schema, requested) => {
6
6
  const isGlobal = (table) => schema.tables[table]?.shardMode?.kind === "global";
7
7
  if (requested && requested.length > 0) {
@@ -0,0 +1,3 @@
1
+ const quoteIdentifier = (name) => `"${name.replaceAll('"', '""')}"`;
2
+
3
+ export { quoteIdentifier };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/d1",
3
- "version": "1.0.0-alpha.16",
3
+ "version": "1.0.0-alpha.18",
4
4
  "description": "D1 adapter for Lunora .global() tables, wrapping the Sessions API for read-your-writes",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -50,8 +50,8 @@
50
50
  "access": "public"
51
51
  },
52
52
  "dependencies": {
53
- "@lunora/do": "1.0.0-alpha.16",
54
- "@lunora/sql-store": "1.0.0-alpha.16",
53
+ "@lunora/do": "1.0.0-alpha.18",
54
+ "@lunora/sql-store": "1.0.0-alpha.18",
55
55
  "drizzle-orm": "^0.45.2"
56
56
  },
57
57
  "engines": {