@atscript/db 0.1.117 → 0.1.119
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/plugin.cjs +4 -3
- package/dist/plugin.d.cts +4 -1
- package/dist/plugin.d.mts +4 -1
- package/dist/plugin.mjs +4 -3
- package/dist/sync.d.cts +4 -4
- package/dist/sync.d.mts +4 -4
- package/package.json +1 -1
package/dist/plugin.cjs
CHANGED
|
@@ -98,7 +98,8 @@ async function generateModelManifest(options, output, format, repo) {
|
|
|
98
98
|
spaces.set(e.space, group);
|
|
99
99
|
}
|
|
100
100
|
const spaceKeys = [...spaces.keys()].toSorted((a, b) => a === "default" ? -1 : b === "default" ? 1 : a.localeCompare(b));
|
|
101
|
-
const list = (items) =>
|
|
101
|
+
const list = (items) => `[${items.join(", ")}] as const`;
|
|
102
|
+
const spaceGroups = spaceKeys.length === 1 ? [` ${JSON.stringify(spaceKeys[0])}: atscriptModels,`] : spaceKeys.map((key) => ` ${JSON.stringify(key)}: ${list(spaces.get(key))},`);
|
|
102
103
|
const content = [
|
|
103
104
|
"/* oxlint-disable */",
|
|
104
105
|
"/* eslint-disable */",
|
|
@@ -113,10 +114,10 @@ async function generateModelManifest(options, output, format, repo) {
|
|
|
113
114
|
`export const dbTables = ${list(tables)}`,
|
|
114
115
|
`export const dbViews = ${list(views)}`,
|
|
115
116
|
"/** Every @db.table / @db.view model in this project. */",
|
|
116
|
-
|
|
117
|
+
"export const atscriptModels = [...dbTables, ...dbViews] as const",
|
|
117
118
|
"/** Models grouped by @db.space (absent annotation → \"default\"). */",
|
|
118
119
|
"export const modelsBySpace = {",
|
|
119
|
-
...
|
|
120
|
+
...spaceGroups,
|
|
120
121
|
"} as const",
|
|
121
122
|
""
|
|
122
123
|
].join("\n");
|
package/dist/plugin.d.cts
CHANGED
|
@@ -3,7 +3,10 @@ import { TAtscriptPlugin } from "@atscript/core";
|
|
|
3
3
|
//#region src/plugin/manifest.d.ts
|
|
4
4
|
/** Options for the generated model manifest (see {@link dbPlugin}). */
|
|
5
5
|
interface TDbManifestOptions {
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Output path for the generated module, relative to the config's `rootDir`
|
|
8
|
+
* (with `rootDir: "src"`, `"models.gen.ts"` emits `src/models.gen.ts`).
|
|
9
|
+
*/
|
|
7
10
|
path: string;
|
|
8
11
|
}
|
|
9
12
|
//#endregion
|
package/dist/plugin.d.mts
CHANGED
|
@@ -3,7 +3,10 @@ import { TAtscriptPlugin } from "@atscript/core";
|
|
|
3
3
|
//#region src/plugin/manifest.d.ts
|
|
4
4
|
/** Options for the generated model manifest (see {@link dbPlugin}). */
|
|
5
5
|
interface TDbManifestOptions {
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Output path for the generated module, relative to the config's `rootDir`
|
|
8
|
+
* (with `rootDir: "src"`, `"models.gen.ts"` emits `src/models.gen.ts`).
|
|
9
|
+
*/
|
|
7
10
|
path: string;
|
|
8
11
|
}
|
|
9
12
|
//#endregion
|
package/dist/plugin.mjs
CHANGED
|
@@ -63,7 +63,8 @@ async function generateModelManifest(options, output, format, repo) {
|
|
|
63
63
|
spaces.set(e.space, group);
|
|
64
64
|
}
|
|
65
65
|
const spaceKeys = [...spaces.keys()].toSorted((a, b) => a === "default" ? -1 : b === "default" ? 1 : a.localeCompare(b));
|
|
66
|
-
const list = (items) =>
|
|
66
|
+
const list = (items) => `[${items.join(", ")}] as const`;
|
|
67
|
+
const spaceGroups = spaceKeys.length === 1 ? [` ${JSON.stringify(spaceKeys[0])}: atscriptModels,`] : spaceKeys.map((key) => ` ${JSON.stringify(key)}: ${list(spaces.get(key))},`);
|
|
67
68
|
const content = [
|
|
68
69
|
"/* oxlint-disable */",
|
|
69
70
|
"/* eslint-disable */",
|
|
@@ -78,10 +79,10 @@ async function generateModelManifest(options, output, format, repo) {
|
|
|
78
79
|
`export const dbTables = ${list(tables)}`,
|
|
79
80
|
`export const dbViews = ${list(views)}`,
|
|
80
81
|
"/** Every @db.table / @db.view model in this project. */",
|
|
81
|
-
|
|
82
|
+
"export const atscriptModels = [...dbTables, ...dbViews] as const",
|
|
82
83
|
"/** Models grouped by @db.space (absent annotation → \"default\"). */",
|
|
83
84
|
"export const modelsBySpace = {",
|
|
84
|
-
...
|
|
85
|
+
...spaceGroups,
|
|
85
86
|
"} as const",
|
|
86
87
|
""
|
|
87
88
|
].join("\n");
|
package/dist/sync.d.cts
CHANGED
|
@@ -287,7 +287,7 @@ declare class SchemaSync {
|
|
|
287
287
|
/**
|
|
288
288
|
* Runs schema synchronization with distributed locking.
|
|
289
289
|
*/
|
|
290
|
-
run(types: TAtscriptAnnotatedType[], opts?: TSyncOptions): Promise<TSyncResult>;
|
|
290
|
+
run(types: readonly TAtscriptAnnotatedType[], opts?: TSyncOptions): Promise<TSyncResult>;
|
|
291
291
|
/**
|
|
292
292
|
* Surfaces the run outcome per the `onError` policy. Reporting must never be
|
|
293
293
|
* silently lost to the NoopLogger default — when no real logger is
|
|
@@ -298,7 +298,7 @@ declare class SchemaSync {
|
|
|
298
298
|
/**
|
|
299
299
|
* Computes a dry-run plan showing what `run()` would do, without executing any DDL.
|
|
300
300
|
*/
|
|
301
|
-
plan(types: TAtscriptAnnotatedType[], opts?: Pick<TSyncOptions, "force" | "safe">): Promise<TSyncPlan>;
|
|
301
|
+
plan(types: readonly TAtscriptAnnotatedType[], opts?: Pick<TSyncOptions, "force" | "safe">): Promise<TSyncPlan>;
|
|
302
302
|
/** Fallback typeMapper for snapshot-based Path B: compares designType directly, skips unions. */
|
|
303
303
|
private resolveTypeMapper;
|
|
304
304
|
private planTable;
|
|
@@ -388,7 +388,7 @@ declare function hasForeignKeyChanges(diff: TForeignKeyDiff): boolean;
|
|
|
388
388
|
* @param types - Atscript annotated types to synchronize.
|
|
389
389
|
* @param opts - Lock TTL, wait timeout, force mode, etc.
|
|
390
390
|
*/
|
|
391
|
-
declare function syncSchema(space: DbSpace, types: TAtscriptAnnotatedType[], opts?: TSyncOptions): Promise<TSyncResult>;
|
|
391
|
+
declare function syncSchema(space: DbSpace, types: readonly TAtscriptAnnotatedType[], opts?: TSyncOptions): Promise<TSyncResult>;
|
|
392
392
|
/**
|
|
393
393
|
* Computes a dry-run plan showing what {@link syncSchema} would do, without
|
|
394
394
|
* executing any DDL. Wraps {@link SchemaSync.plan}.
|
|
@@ -410,6 +410,6 @@ declare function syncSchema(space: DbSpace, types: TAtscriptAnnotatedType[], opt
|
|
|
410
410
|
* Note: reading the stored baseline still requires a live DB connection (the
|
|
411
411
|
* snapshot lives in the `__atscript_control` table).
|
|
412
412
|
*/
|
|
413
|
-
declare function planSchema(space: DbSpace, types: TAtscriptAnnotatedType[], opts?: Pick<TSyncOptions, "force" | "safe">): Promise<TSyncPlan>;
|
|
413
|
+
declare function planSchema(space: DbSpace, types: readonly TAtscriptAnnotatedType[], opts?: Pick<TSyncOptions, "force" | "safe">): Promise<TSyncPlan>;
|
|
414
414
|
//#endregion
|
|
415
415
|
export { SchemaSync, SyncEntry, type TFieldSnapshot, type TForeignKeyDiff, type TForeignKeySnapshot, type TSyncColors, type TSyncEntryStatus, type TSyncOptions, type TSyncPlan, type TSyncResult, type TTableSnapshot, type TViewSnapshot, computeColumnDiff, computeForeignKeyDiff, computeSchemaHash, computeTableHash, computeTableOptionDiff, computeTableSnapshot, computeViewSnapshot, fkKey, hasForeignKeyChanges, planSchema, readStoredSnapshot, snapshotToExistingColumns, snapshotToExistingTableOptions, syncSchema };
|
package/dist/sync.d.mts
CHANGED
|
@@ -287,7 +287,7 @@ declare class SchemaSync {
|
|
|
287
287
|
/**
|
|
288
288
|
* Runs schema synchronization with distributed locking.
|
|
289
289
|
*/
|
|
290
|
-
run(types: TAtscriptAnnotatedType[], opts?: TSyncOptions): Promise<TSyncResult>;
|
|
290
|
+
run(types: readonly TAtscriptAnnotatedType[], opts?: TSyncOptions): Promise<TSyncResult>;
|
|
291
291
|
/**
|
|
292
292
|
* Surfaces the run outcome per the `onError` policy. Reporting must never be
|
|
293
293
|
* silently lost to the NoopLogger default — when no real logger is
|
|
@@ -298,7 +298,7 @@ declare class SchemaSync {
|
|
|
298
298
|
/**
|
|
299
299
|
* Computes a dry-run plan showing what `run()` would do, without executing any DDL.
|
|
300
300
|
*/
|
|
301
|
-
plan(types: TAtscriptAnnotatedType[], opts?: Pick<TSyncOptions, "force" | "safe">): Promise<TSyncPlan>;
|
|
301
|
+
plan(types: readonly TAtscriptAnnotatedType[], opts?: Pick<TSyncOptions, "force" | "safe">): Promise<TSyncPlan>;
|
|
302
302
|
/** Fallback typeMapper for snapshot-based Path B: compares designType directly, skips unions. */
|
|
303
303
|
private resolveTypeMapper;
|
|
304
304
|
private planTable;
|
|
@@ -388,7 +388,7 @@ declare function hasForeignKeyChanges(diff: TForeignKeyDiff): boolean;
|
|
|
388
388
|
* @param types - Atscript annotated types to synchronize.
|
|
389
389
|
* @param opts - Lock TTL, wait timeout, force mode, etc.
|
|
390
390
|
*/
|
|
391
|
-
declare function syncSchema(space: DbSpace, types: TAtscriptAnnotatedType[], opts?: TSyncOptions): Promise<TSyncResult>;
|
|
391
|
+
declare function syncSchema(space: DbSpace, types: readonly TAtscriptAnnotatedType[], opts?: TSyncOptions): Promise<TSyncResult>;
|
|
392
392
|
/**
|
|
393
393
|
* Computes a dry-run plan showing what {@link syncSchema} would do, without
|
|
394
394
|
* executing any DDL. Wraps {@link SchemaSync.plan}.
|
|
@@ -410,6 +410,6 @@ declare function syncSchema(space: DbSpace, types: TAtscriptAnnotatedType[], opt
|
|
|
410
410
|
* Note: reading the stored baseline still requires a live DB connection (the
|
|
411
411
|
* snapshot lives in the `__atscript_control` table).
|
|
412
412
|
*/
|
|
413
|
-
declare function planSchema(space: DbSpace, types: TAtscriptAnnotatedType[], opts?: Pick<TSyncOptions, "force" | "safe">): Promise<TSyncPlan>;
|
|
413
|
+
declare function planSchema(space: DbSpace, types: readonly TAtscriptAnnotatedType[], opts?: Pick<TSyncOptions, "force" | "safe">): Promise<TSyncPlan>;
|
|
414
414
|
//#endregion
|
|
415
415
|
export { SchemaSync, SyncEntry, type TFieldSnapshot, type TForeignKeyDiff, type TForeignKeySnapshot, type TSyncColors, type TSyncEntryStatus, type TSyncOptions, type TSyncPlan, type TSyncResult, type TTableSnapshot, type TViewSnapshot, computeColumnDiff, computeForeignKeyDiff, computeSchemaHash, computeTableHash, computeTableOptionDiff, computeTableSnapshot, computeViewSnapshot, fkKey, hasForeignKeyChanges, planSchema, readStoredSnapshot, snapshotToExistingColumns, snapshotToExistingTableOptions, syncSchema };
|