neoorm 0.9.6 → 0.9.7
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.
- package/dist/bin/neoorm.d.ts.map +1 -1
- package/dist/bin/neoorm.js +83 -141
- package/dist/bin/neoorm.js.map +1 -1
- package/dist/codegen/column-ts.d.ts.map +1 -1
- package/dist/codegen/column-ts.js +5 -2
- package/dist/codegen/column-ts.js.map +1 -1
- package/dist/codegen/emit-query-types.d.ts.map +1 -1
- package/dist/codegen/emit-query-types.js +35 -0
- package/dist/codegen/emit-query-types.js.map +1 -1
- package/dist/codegen/generate.d.ts +1 -0
- package/dist/codegen/generate.d.ts.map +1 -1
- package/dist/codegen/generate.js +8 -1
- package/dist/codegen/generate.js.map +1 -1
- package/dist/codegen/schema-to-manifest.d.ts.map +1 -1
- package/dist/codegen/schema-to-manifest.js +65 -0
- package/dist/codegen/schema-to-manifest.js.map +1 -1
- package/dist/codegen/validation/from-manifest.d.ts.map +1 -1
- package/dist/codegen/validation/from-manifest.js +12 -2
- package/dist/codegen/validation/from-manifest.js.map +1 -1
- package/dist/dialect/sqlite.test.js +9 -0
- package/dist/dialect/sqlite.test.js.map +1 -1
- package/dist/introspect/mysql/to-manifest.d.ts.map +1 -1
- package/dist/introspect/mysql/to-manifest.js +2 -1
- package/dist/introspect/mysql/to-manifest.js.map +1 -1
- package/dist/introspect/pull.d.ts +5 -0
- package/dist/introspect/pull.d.ts.map +1 -1
- package/dist/introspect/pull.js +160 -22
- package/dist/introspect/pull.js.map +1 -1
- package/dist/introspect/sqlite/to-manifest.d.ts.map +1 -1
- package/dist/introspect/sqlite/to-manifest.js +2 -1
- package/dist/introspect/sqlite/to-manifest.js.map +1 -1
- package/dist/introspect/table-map.d.ts +9 -0
- package/dist/introspect/table-map.d.ts.map +1 -0
- package/dist/introspect/table-map.js +21 -0
- package/dist/introspect/table-map.js.map +1 -0
- package/dist/introspect/to-manifest.d.ts.map +1 -1
- package/dist/introspect/to-manifest.js +2 -1
- package/dist/introspect/to-manifest.js.map +1 -1
- package/dist/migrate/dev-workflow.d.ts +36 -0
- package/dist/migrate/dev-workflow.d.ts.map +1 -0
- package/dist/migrate/dev-workflow.js +96 -0
- package/dist/migrate/dev-workflow.js.map +1 -0
- package/dist/migrate/runner.d.ts.map +1 -1
- package/dist/migrate/runner.js +23 -5
- package/dist/migrate/runner.js.map +1 -1
- package/dist/runtime/driver-sqlite.test.js +115 -0
- package/dist/runtime/driver-sqlite.test.js.map +1 -1
- package/dist/runtime/driver.d.ts +8 -0
- package/dist/runtime/driver.d.ts.map +1 -1
- package/dist/runtime/driver.js +51 -97
- package/dist/runtime/driver.js.map +1 -1
- package/dist/runtime/error-codes.d.ts +3 -0
- package/dist/runtime/error-codes.d.ts.map +1 -1
- package/dist/runtime/error-codes.js +3 -0
- package/dist/runtime/error-codes.js.map +1 -1
- package/dist/runtime/mysql-driver.d.ts.map +1 -1
- package/dist/runtime/mysql-driver.js +5 -1
- package/dist/runtime/mysql-driver.js.map +1 -1
- package/dist/runtime/mysql-family-pool.test.js +14 -1
- package/dist/runtime/mysql-family-pool.test.js.map +1 -1
- package/dist/runtime/mysql-placeholders.d.ts.map +1 -1
- package/dist/runtime/mysql-placeholders.js +12 -0
- package/dist/runtime/mysql-placeholders.js.map +1 -1
- package/dist/runtime/mysql-placeholders.test.js +15 -0
- package/dist/runtime/mysql-placeholders.test.js.map +1 -1
- package/dist/runtime/query/compile-where.d.ts.map +1 -1
- package/dist/runtime/query/compile-where.js +26 -1
- package/dist/runtime/query/compile-where.js.map +1 -1
- package/dist/runtime/query/find-or-create.test.js +19 -0
- package/dist/runtime/query/find-or-create.test.js.map +1 -1
- package/dist/runtime/query/update.d.ts.map +1 -1
- package/dist/runtime/query/update.js +9 -1
- package/dist/runtime/query/update.js.map +1 -1
- package/dist/runtime/query/upsert.d.ts.map +1 -1
- package/dist/runtime/query/upsert.js +12 -3
- package/dist/runtime/query/upsert.js.map +1 -1
- package/dist/runtime/regex-guard.d.ts +28 -0
- package/dist/runtime/regex-guard.d.ts.map +1 -0
- package/dist/runtime/regex-guard.js +124 -0
- package/dist/runtime/regex-guard.js.map +1 -0
- package/dist/runtime/regex-guard.test.d.ts +2 -0
- package/dist/runtime/regex-guard.test.d.ts.map +1 -0
- package/dist/runtime/regex-guard.test.js +63 -0
- package/dist/runtime/regex-guard.test.js.map +1 -0
- package/dist/runtime/sqlite-open.d.ts.map +1 -1
- package/dist/runtime/sqlite-open.js +22 -7
- package/dist/runtime/sqlite-open.js.map +1 -1
- package/dist/runtime/sqlite-open.test.d.ts +2 -0
- package/dist/runtime/sqlite-open.test.d.ts.map +1 -0
- package/dist/runtime/sqlite-open.test.js +66 -0
- package/dist/runtime/sqlite-open.test.js.map +1 -0
- package/dist/sql/split-statements.d.ts +15 -0
- package/dist/sql/split-statements.d.ts.map +1 -0
- package/dist/sql/split-statements.js +132 -0
- package/dist/sql/split-statements.js.map +1 -0
- package/docs/migrate-dev-workflow.md +84 -0
- package/docs/migrations.md +3 -0
- package/docs/sqlite.md +2 -0
- package/llms-full.txt +90 -0
- package/package.json +1 -1
package/llms-full.txt
CHANGED
|
@@ -2378,6 +2378,9 @@ After the transaction commits or rolls back, `query_only` is turned off so later
|
|
|
2378
2378
|
|
|
2379
2379
|
Migration names are slugified (`Add Users` → `add_users`, capped at 50 chars) and prefixed with a timestamp so folders sort in apply order. `--name` is only needed when a migration is created: the CLI prompts on a TTY at that point (after pending migrations are applied in `dev`) and errors in non-interactive runs. Runs with no schema changes (client regeneration only) and pending-apply-only `dev` runs succeed without `--name` and never prompt. Older `*_migration` folders still apply in order.
|
|
2380
2380
|
|
|
2381
|
+
`migrate dev` holds its lock from before pending reconciliation through the optional name prompt, generation, and post-generation reconciliation/application.
|
|
2382
|
+
For the implementation ordering and regression coverage, see [the workflow guide](migrate-dev-workflow.md).
|
|
2383
|
+
|
|
2381
2384
|
When migration is blocked, the CLI explains why — for example unsupported type casts (`alter_column_type_manual`), enum value changes, or destructive drops. Re-run with `--accept-data-loss` to include destructive DDL:
|
|
2382
2385
|
|
|
2383
2386
|
```bash
|
|
@@ -2920,6 +2923,8 @@ const db = createNeoOrmClient(manifest, {
|
|
|
2920
2923
|
|
|
2921
2924
|
`busyTimeout` can also be a millisecond wait (`sqlite: { busyTimeout: 10_000 }`).
|
|
2922
2925
|
|
|
2926
|
+
SQLite runs `search`/`REGEXP` patterns in-process as JavaScript `RegExp`, so a catastrophic-backtracking pattern (e.g. `(a+)+$`) could freeze the whole process. neoorm rejects patterns that nest unbounded quantifiers; pass `sqlite: { unsafeAllowRegex: true }` to allow them anyway.
|
|
2927
|
+
|
|
2923
2928
|
### Custom driver
|
|
2924
2929
|
|
|
2925
2930
|
Pass any object implementing `prepare(sql)`, `exec(sql)`, and `close()` — the `node:sqlite` and `bun:sqlite` APIs both match. Useful for sandboxed runtimes or existing database handles:
|
|
@@ -3387,6 +3392,91 @@ Each entry barrel starts with:
|
|
|
3387
3392
|
- Document generated client output under `neoorm/client`.
|
|
3388
3393
|
- Add runtime behavior changes alongside docstrings.
|
|
3389
3394
|
|
|
3395
|
+
## `migrate dev` Workflow
|
|
3396
|
+
|
|
3397
|
+
This guide records the workflow contract and the implementation changes behind `neoorm migrate dev`. The refactor preserves the command's migration order and user-visible output timing.
|
|
3398
|
+
|
|
3399
|
+
## Runtime contract
|
|
3400
|
+
|
|
3401
|
+
`runMigrateDev` derives `migrationsDir` from `outDir` and runs the complete sequence inside `withMigrateDevLock`:
|
|
3402
|
+
|
|
3403
|
+
1. Read the snapshot, compile the target schema, reconcile pending `CREATE TABLE` migrations against the live database, then apply remaining pending migrations.
|
|
3404
|
+
2. Generate from the current schema. If generation fails with the existing missing-migration-name error, no explicit name was supplied, and the CLI provided an interactive prompt callback, ask once and retry once. Other errors propagate unchanged. If generation needs no migration, it does not prompt.
|
|
3405
|
+
3. Emit the generation summary and warnings, then reconcile a newly written migration against existing tables or apply it when reconciliation did not record it.
|
|
3406
|
+
4. Return whether destructive changes were blocked; the CLI sets `process.exitCode` after the workflow completes.
|
|
3407
|
+
|
|
3408
|
+
The lock covers snapshot reading, both reconciliation/deployment phases, generation, and the optional prompt. Progress events keep the CLI output at the same stage as before: pending-migration output precedes a possible prompt, while generation output precedes post-generation reconciliation/application.
|
|
3409
|
+
|
|
3410
|
+
## File-by-file changes
|
|
3411
|
+
|
|
3412
|
+
### `src/migrate/dev-workflow.ts`
|
|
3413
|
+
|
|
3414
|
+
- **Before:** The ordered `migrate dev` sequence had no dedicated workflow module; the CLI path coordinated it.
|
|
3415
|
+
- **After:** `runMigrateDev` owns snapshot reading, initial reconciliation/deployment, generation, the optional one-shot prompt/retry, and post-generation reconciliation/deployment. A typed progress-event union reports completed stages, while existing migration and code-generation helpers remain responsible for their work. The migration directory is derived from `outDir`.
|
|
3416
|
+
- **Why it is useful:** The lock scope and ordering have one owner, and the workflow can be tested through a small interface without a CLI/TTY harness.
|
|
3417
|
+
|
|
3418
|
+
### `src/bin/neoorm.ts`
|
|
3419
|
+
|
|
3420
|
+
- **Before:** The CLI command path contained the `migrate dev` orchestration alongside the separate `migrate deploy` path.
|
|
3421
|
+
- **After:** `migrate dev` calls `runMigrateDev`, adapts its progress events to the existing console output, supplies the prompt callback only for interactive runs, and handles the returned destructive-blocked status. `migrate deploy` remains on its separate path.
|
|
3422
|
+
- **Why it is useful:** Terminal interaction and presentation stay in the CLI, while moving orchestration does not delay or reorder output around the prompt.
|
|
3423
|
+
|
|
3424
|
+
### `src/codegen/generate.ts`
|
|
3425
|
+
|
|
3426
|
+
- **Before:** The missing-migration-name predicate lived in the CLI even though both regular `generate` and `migrate dev` use it.
|
|
3427
|
+
- **After:** The same predicate lives beside `missingMigrationNameError` in the code-generation module and is shared by both callers.
|
|
3428
|
+
- **Why it is useful:** There is one definition of the narrow prompt-eligibility check; its error conditions are unchanged, not broadened into general error handling.
|
|
3429
|
+
|
|
3430
|
+
### `test/migrate-dev-workflow.test.ts`
|
|
3431
|
+
|
|
3432
|
+
- **Before:** Existing tests covered migration, generation, and lock helpers separately, but not their ordering at the workflow boundary.
|
|
3433
|
+
- **After:** Real in-memory SQLite tests verify that a pending migration is applied and the lock remains held when the controlled name prompt runs, and that an unchanged schema completes without prompting or creating another migration.
|
|
3434
|
+
- **Why it is useful:** The regression coverage checks observable database state and timing rather than mocked helper forwarding or CLI wiring.
|
|
3435
|
+
|
|
3436
|
+
### `docs/migrations.md`
|
|
3437
|
+
|
|
3438
|
+
- **Before:** The migration guide described command behavior but did not state the full `migrate dev` lock interval.
|
|
3439
|
+
- **After:** It documents that the lock starts before pending reconciliation and remains held through the optional name prompt, generation, and post-generation reconciliation/application; it links to this implementation guide.
|
|
3440
|
+
- **Why it is useful:** Readers can reason about concurrency and prompt timing from the documented contract.
|
|
3441
|
+
|
|
3442
|
+
### `llms-full.txt`
|
|
3443
|
+
|
|
3444
|
+
- **Before:** The generated documentation aggregate did not include the updated lock-lifetime note or this guide.
|
|
3445
|
+
- **After:** Regeneration mirrors the migration-guide update and includes the new workflow page.
|
|
3446
|
+
- **Why it is useful:** The aggregate stays aligned with the source documentation instead of presenting stale workflow details.
|
|
3447
|
+
|
|
3448
|
+
### `examples/blog/seed.ts`
|
|
3449
|
+
|
|
3450
|
+
- **Before:** The schema was imported as a runtime value even though it was used only for a type.
|
|
3451
|
+
- **After:** The import is type-only.
|
|
3452
|
+
- **Why it is useful:** TypeScript erases the import from emitted JavaScript, and lint no longer reports the type-only usage.
|
|
3453
|
+
|
|
3454
|
+
### `docs/migrate-dev-workflow.md`
|
|
3455
|
+
|
|
3456
|
+
- **Before:** There was no durable, file-by-file record of the workflow ownership, preserved behavior, and verification.
|
|
3457
|
+
- **After:** This page records the execution contract, concrete before/after changes, and their rationale.
|
|
3458
|
+
- **Why it is useful:** Future maintenance can distinguish an ownership refactor from an intended behavior change.
|
|
3459
|
+
|
|
3460
|
+
## Preserved behavior and scope
|
|
3461
|
+
|
|
3462
|
+
- Pending migrations are reconciled and applied before a missing name can be requested.
|
|
3463
|
+
- The prompt is limited to the existing missing-name condition and is attempted at most once; unchanged schemas do not prompt.
|
|
3464
|
+
- The migrate-dev lock remains held during the prompt and until post-generation reconciliation/application finishes.
|
|
3465
|
+
- The existing second schema compilation remains; this change does not optimize it.
|
|
3466
|
+
- `migrate deploy` keeps its separate execution path.
|
|
3467
|
+
|
|
3468
|
+
## Verification
|
|
3469
|
+
|
|
3470
|
+
The implementation verification below was recorded before this documentation continuation; it was not rerun as part of the documentation-only changes:
|
|
3471
|
+
|
|
3472
|
+
- `bun run build` — passed.
|
|
3473
|
+
- `bun run test` — 128 files passed, 4 skipped; 1,215 tests passed, 42 skipped.
|
|
3474
|
+
- `bun run typecheck` and `bun run lint` — passed; lint was clean.
|
|
3475
|
+
- Focused migration suites — 4 files and 34 tests passed.
|
|
3476
|
+
- CLI fixture smoke — `migrate dev --name initial`, a no-name no-op `migrate dev`, and a no-op `migrate deploy` each exited 0; the SQLite database had the expected table and one applied ledger entry.
|
|
3477
|
+
|
|
3478
|
+
The generated documentation is refreshed with `bun run docs:llms` after editing this page.
|
|
3479
|
+
|
|
3390
3480
|
## Seeding
|
|
3391
3481
|
|
|
3392
3482
|
`neoorm seed` runs a seed script against the database inside a single transaction. Any failure rolls the whole seed back, so failed runs are safe to retry.
|