Skip to content

Commit d67df0b

Browse files
committed
refactor(driver-sql): the by-path readers read the sql-driver facade, so the codemod moves the five path-reader members (#30147 phase 2c)
A new reader, scripts/sql-driver-split-source.mjs, returns SqlDriver as one text: each codemod stub's body replaced by the facet body it calls, the leaf ahead of the class. The five packages/cli generate-* pins and check-keyed-text-bounds read through it, so the codemod empties PATH_READER_PINS and PATH_READER_NEEDLES and writes createColumn's return type. Regenerated from 21510bb: createColumn, createAuditTimestampColumn, varcharColumnChars, ensureShardTable and initObjects move; the registry loses their five rows (73 -> 68). cli declares the modules the reader follows. Claude-Session: https://claude.ai/code/session_01WGufzj4B2cbnRLVdgtLcDZ Co-authored-by: Claude <noreply@anthropic.com>
1 parent bfca0ef commit d67df0b

17 files changed

Lines changed: 1407 additions & 1010 deletions

‎packages/cli/src/commands/generate-builtin-id-column.pin.test.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ import fs from 'node:fs';
8989
import path from 'node:path';
9090
import { fileURLToPath } from 'node:url';
9191

92+
import { readSqlDriverSource } from '../../../../scripts/sql-driver-split-source.mjs';
9293
import { describe, expect, it } from 'vitest';
9394

9495
import { generateMigrationSql, generateMigrationTs } from './generate.js';
@@ -99,7 +100,9 @@ const GENERATE_SOURCE = fs.readFileSync(GENERATE_TS, 'utf8');
99100

100101
/** The authority, read where it lives — never transcribed here. */
101102
const DRIVER_SQL_SRC = path.resolve(HERE, '../../../drivers/driver-sql/src');
102-
const SQL_DRIVER_SOURCE = fs.readFileSync(path.join(DRIVER_SQL_SRC, 'sql-driver.ts'), 'utf8');
103+
// `SqlDriver` as one text: `sql-driver.ts` with each codemod stub's body read
104+
// from the facet module it moved to, and the leaf ahead of the class (#30147).
105+
const SQL_DRIVER_SOURCE = readSqlDriverSource(DRIVER_SQL_SRC).text;
103106

104107
/** The one line the driver emits for a managed table's primary key. */
105108
const DRIVER_ID_COLUMN = "table.string('id').primary();";

‎packages/cli/src/commands/generate-field-type-vocabulary.pin.test.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ import {
136136
REFERENCE_VALUE_TYPES,
137137
STRUCTURED_JSON_TYPES,
138138
} from '@objectstack/spec/data';
139+
import { readSqlDriverSource } from '../../../../scripts/sql-driver-split-source.mjs';
139140
import { describe, expect, it } from 'vitest';
140141

141142
import { generateMigrationSql, generateMigrationTs, generateTypesFromConfig } from './generate.js';
@@ -318,7 +319,9 @@ describe('generate.ts field-type vocabularies (#13871)', () => {
318319

319320
/** `packages/drivers/driver-sql/src` — declared for `@objectstack/cli#test` in `turbo.json`. */
320321
const DRIVER_SQL_SRC = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../drivers/driver-sql/src');
321-
const SQL_DRIVER_SOURCE = fs.readFileSync(path.join(DRIVER_SQL_SRC, 'sql-driver.ts'), 'utf8');
322+
// `SqlDriver` as one text: `sql-driver.ts` with each codemod stub's body read
323+
// from the facet module it moved to, and the leaf ahead of the class (#30147).
324+
const SQL_DRIVER_SOURCE = readSqlDriverSource(DRIVER_SQL_SRC).text;
322325
const SCHEMA_DRIFT_SOURCE = fs.readFileSync(path.join(DRIVER_SQL_SRC, 'schema-drift.ts'), 'utf8');
323326

324327
/**

‎packages/cli/src/commands/generate-file-reference-width.pin.test.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,16 @@ import path from 'node:path';
6767
import { fileURLToPath } from 'node:url';
6868

6969
import { FILE_REFERENCE_TYPES, REFERENCE_VALUE_TYPES } from '@objectstack/spec/data';
70+
import { readSqlDriverSource } from '../../../../scripts/sql-driver-split-source.mjs';
7071
import { describe, expect, it } from 'vitest';
7172

7273
import { generateMigrationSql, generateMigrationTs } from './generate.js';
7374

7475
/** `packages/drivers/driver-sql/src` — declared for `@objectstack/cli#test` in `turbo.json`. */
7576
const DRIVER_SQL_SRC = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../drivers/driver-sql/src');
76-
const SQL_DRIVER_SOURCE = fs.readFileSync(path.join(DRIVER_SQL_SRC, 'sql-driver.ts'), 'utf8');
77+
// `SqlDriver` as one text: `sql-driver.ts` with each codemod stub's body read
78+
// from the facet module it moved to, and the leaf ahead of the class (#30147).
79+
const SQL_DRIVER_SOURCE = readSqlDriverSource(DRIVER_SQL_SRC).text;
7780

7881
/** The control the generator documents, plus the arm the family used to ride. */
7982
const CONTROL_TYPES = ['text', ...REFERENCE_VALUE_TYPES, 'autonumber'] as const;

‎packages/cli/src/commands/generate-multiple-json-column.pin.test.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ import path from 'node:path';
8888
import { fileURLToPath } from 'node:url';
8989

9090
import { isMultiValueField, MULTI_CAPABLE_TYPES, MULTI_OPTION_TYPES } from '@objectstack/spec/data';
91+
import { readSqlDriverSource } from '../../../../scripts/sql-driver-split-source.mjs';
9192
import { describe, expect, it } from 'vitest';
9293

9394
import {
@@ -377,7 +378,8 @@ describe('#14829 — `multiple: true` is one answer across all three surfaces',
377378
// this rule, these fail and whoever moved it re-derives the generators.
378379

379380
it('driver-sql `createColumn` still decides `multiple` BEFORE the type switch', () => {
380-
const source = fs.readFileSync(path.join(DRIVER_SQL_SRC, 'sql-driver.ts'), 'utf8');
381+
// `SqlDriver` as one text, each codemod stub's body read where it moved (#30147).
382+
const source = readSqlDriverSource(DRIVER_SQL_SRC).text;
381383
// Non-vacuity: the file was really read, and the two landmarks really found.
382384
expect(source.length).toBeGreaterThan(10_000);
383385
const start = source.indexOf('protected createColumn(');

‎packages/cli/src/commands/generate-string-family-width.pin.test.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ import {
251251
MULTI_OPTION_TYPES,
252252
STRUCTURED_JSON_TYPES,
253253
} from '@objectstack/spec/data';
254+
import { readSqlDriverSource } from '../../../../scripts/sql-driver-split-source.mjs';
254255
import { afterAll, describe, expect, it } from 'vitest';
255256

256257
import { generateMigrationSql, generateMigrationTs } from './generate.js';
@@ -260,7 +261,9 @@ const GENERATE_SOURCE = fs.readFileSync(path.resolve(HERE, 'generate.ts'), 'utf8
260261

261262
/** The authority, read where it lives — never transcribed here. */
262263
const DRIVER_SQL_SRC = path.resolve(HERE, '../../../drivers/driver-sql/src');
263-
const SQL_DRIVER_SOURCE = fs.readFileSync(path.join(DRIVER_SQL_SRC, 'sql-driver.ts'), 'utf8');
264+
// `SqlDriver` as one text: `sql-driver.ts` with each codemod stub's body read
265+
// from the facet module it moved to, and the leaf ahead of the class (#30147).
266+
const SQL_DRIVER_SOURCE = readSqlDriverSource(DRIVER_SQL_SRC).text;
264267
const SCHEMA_DRIFT_SOURCE = fs.readFileSync(path.join(DRIVER_SQL_SRC, 'schema-drift.ts'), 'utf8');
265268

266269
/** The authority for which types exist at all. Imported, never listed here. */

0 commit comments

Comments
 (0)