@stacksjs/database 0.75.529 → 0.75.535

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/erd.d.ts CHANGED
@@ -51,7 +51,7 @@ export declare function erdDetailFrom(options: RenderErdOptions): ErdDetail;
51
51
  */
52
52
  export declare function renderErd(models: DiagrammableModel[], options?: RenderErdOptions): string;
53
53
  /** Mermaid's own default `maxTextSize`, past which it draws an error box. */
54
- export declare const MERMAID_MAX_TEXT_SIZE: unknown;
54
+ export declare const MERMAID_MAX_TEXT_SIZE: 50000;
55
55
  /** One model, reduced to what a diagram needs. */
56
56
  export declare interface DiagrammableModel {
57
57
  name: string
@@ -54,7 +54,7 @@ export declare function duplicateMigrationOrdinalsIn(dir: string): Array<Duplica
54
54
  * Ordinals at or above this are `make:migration` timestamps (seconds or
55
55
  * milliseconds since 1970), not positions in a sequence.
56
56
  */
57
- export declare const TIMESTAMP_MIGRATION_ORDINAL: unknown;
57
+ export declare const TIMESTAMP_MIGRATION_ORDINAL: 1000000000;
58
58
  export declare interface DuplicateMigrationOrdinal {
59
59
  ordinal: string
60
60
  files: string[]
@@ -1 +1 @@
1
- import{existsSync,readdirSync,readFileSync}from"node:fs";import{isAbsolute,join,relative}from"node:path";import process from"node:process";const DEFAULT_MIGRATION_DIR="database/migrations";const DEFAULT_SNAPSHOT_DIR="storage/framework/database";export function resolveMigrationDirectory(dialect,options={}){if(dialect==="turso"||dialect==="libsql")dialect="sqlite";const cwd=options.cwd??process.cwd();const configured=process.env.DB_MIGRATIONS_PATH||options.configured||DEFAULT_MIGRATION_DIR;const absoluteConfigured=isAbsolute(configured)?configured:join(cwd,configured);if(configured!==DEFAULT_MIGRATION_DIR||isAbsolute(configured))return absoluteConfigured;const dialectDir=join(absoluteConfigured,dialect);if(existsSync(dialectDir))return dialectDir;if(dialect==="sqlite")return absoluteConfigured;const snapshotDir=isAbsolute(options.snapshotDir||"")?options.snapshotDir:join(cwd,options.snapshotDir||DEFAULT_SNAPSHOT_DIR);let snapshots=[];try{snapshots=readdirSync(snapshotDir)}catch{}const wanted=`model-snapshot.${dialect}.json`;const hasOtherDialect=snapshots.some((file)=>/^model-snapshot\.\w+\.json$/.test(file)&&file!==wanted);if(hasOtherDialect&&ownerOfFlatCorpus(absoluteConfigured)===wireOf(dialect))return absoluteConfigured;return hasOtherDialect?dialectDir:absoluteConfigured}function ownerOfFlatCorpus(directory){let files=[];try{files=readdirSync(directory).filter((file)=>file.endsWith(".sql")).sort()}catch{return null}for(const file of files){let sql;try{sql=readFileSync(join(directory,file),"utf8")}catch{continue}const create=/CREATE\s+TABLE\s+(?:IF\s+NOT\s+EXISTS\s+)?(["`])/i.exec(sql);if(create)return create[1]==="`"?"mysql":"postgres"}return null}function wireOf(dialect){return dialect==="mysql"||dialect==="mariadb"||dialect==="singlestore"||dialect==="vitess"||dialect==="planetscale"?"mysql":"postgres"}export function relativeMigrationDirectory(directory,cwd=process.cwd()){const prefix=`${cwd}/`;return directory.startsWith(prefix)?directory.slice(prefix.length):directory}export function resolveSnapshotDirectory(cwd=process.cwd()){const configured=process.env.DB_SNAPSHOT_PATH||DEFAULT_SNAPSHOT_DIR;return isAbsolute(configured)?configured:join(cwd,configured)}export function snapshotDirForQueryBuilder(cwd=process.cwd()){return relative(cwd,resolveSnapshotDirectory(cwd))||"."}export function snapshotDirectoryIsShared(){return Boolean(process.env.DB_SNAPSHOT_PATH)}
1
+ import{existsSync,readdirSync,readFileSync}from"node:fs";import{isAbsolute,join,relative}from"node:path";import process from"node:process";import{auditMigrationCorpus}from"./migration-dialect";const DEFAULT_MIGRATION_DIR="database/migrations";const DEFAULT_SNAPSHOT_DIR="storage/framework/database";export function resolveMigrationDirectory(dialect,options={}){if(dialect==="turso"||dialect==="libsql")dialect="sqlite";const cwd=options.cwd??process.cwd();const configured=process.env.DB_MIGRATIONS_PATH||options.configured||DEFAULT_MIGRATION_DIR;const absoluteConfigured=isAbsolute(configured)?configured:join(cwd,configured);if(configured!==DEFAULT_MIGRATION_DIR||isAbsolute(configured))return absoluteConfigured;const dialectDir=join(absoluteConfigured,dialect);if(existsSync(dialectDir))return dialectDir;if(dialect==="sqlite")return absoluteConfigured;const snapshotDir=isAbsolute(options.snapshotDir||"")?options.snapshotDir:join(cwd,options.snapshotDir||DEFAULT_SNAPSHOT_DIR);let snapshots=[];try{snapshots=readdirSync(snapshotDir)}catch{}const wanted=`model-snapshot.${dialect}.json`;const hasOtherDialect=snapshots.some((file)=>/^model-snapshot\.\w+\.json$/.test(file)&&file!==wanted);if(hasOtherDialect&&ownsFlatCorpus(absoluteConfigured,dialect))return absoluteConfigured;return hasOtherDialect?dialectDir:absoluteConfigured}function ownsFlatCorpus(directory,dialect){const{inferred}=auditMigrationCorpus({dir:directory,target:dialect==="sqlite"?"sqlite":wireOf(dialect)});if(inferred)return inferred===(dialect==="sqlite"?"sqlite":wireOf(dialect));return ownerOfFlatCorpus(directory)===wireOf(dialect)}function ownerOfFlatCorpus(directory){let files=[];try{files=readdirSync(directory).filter((file)=>file.endsWith(".sql")).sort()}catch{return null}for(const file of files){let sql;try{sql=readFileSync(join(directory,file),"utf8")}catch{continue}const create=/CREATE\s+TABLE\s+(?:IF\s+NOT\s+EXISTS\s+)?(["`])/i.exec(sql);if(create)return create[1]==="`"?"mysql":"postgres"}return null}function wireOf(dialect){return dialect==="mysql"||dialect==="mariadb"||dialect==="singlestore"||dialect==="vitess"||dialect==="planetscale"?"mysql":"postgres"}export function relativeMigrationDirectory(directory,cwd=process.cwd()){const prefix=`${cwd}/`;return directory.startsWith(prefix)?directory.slice(prefix.length):directory}export function resolveSnapshotDirectory(cwd=process.cwd()){const configured=process.env.DB_SNAPSHOT_PATH||DEFAULT_SNAPSHOT_DIR;return isAbsolute(configured)?configured:join(cwd,configured)}export function snapshotDirForQueryBuilder(cwd=process.cwd()){return relative(cwd,resolveSnapshotDirectory(cwd))||"."}export function snapshotDirectoryIsShared(){return Boolean(process.env.DB_SNAPSHOT_PATH)}
@@ -59,7 +59,7 @@ export declare function stagePackageMigrations(options: {
59
59
  *
60
60
  * Still ten digits, so lexicographic order and numeric order agree.
61
61
  */
62
- export declare const PACKAGE_MIGRATION_BAND: unknown;
62
+ export declare const PACKAGE_MIGRATION_BAND: 9000000000;
63
63
  /**
64
64
  * Whether a migration filename belongs to a discovered package.
65
65
  *
@@ -68,7 +68,7 @@ export declare const PACKAGE_MIGRATION_BAND: unknown;
68
68
  * those run in loops over a directory listing where opening each file would be
69
69
  * the expensive part.
70
70
  */
71
- export declare const PACKAGE_MIGRATION_BAND_END: unknown;
71
+ export declare const PACKAGE_MIGRATION_BAND_END: 9999999999;
72
72
  /** One package migration copied into the corpus the runner executes. */
73
73
  export declare interface StagedPackageMigration {
74
74
  package: string
@@ -20,6 +20,6 @@ export declare function resolvePoolConfig(configured: PoolConfig | undefined, en
20
20
  * pre-migration `pg_dump`. Thirty seconds keeps a busy process warm and gives
21
21
  * a quiet one's sessions back.
22
22
  */
23
- export declare const DEFAULT_POOL_IDLE_TIMEOUT_MS: unknown;
23
+ export declare const DEFAULT_POOL_IDLE_TIMEOUT_MS: 30000;
24
24
  declare type PoolEnv = Partial<Record<'DB_POOL_MAX' | 'DB_POOL_IDLE_TIMEOUT_MS' | 'DB_POOL_ACQUIRE_TIMEOUT_MS', unknown>>;
25
25
  export {};
package/dist/schema.d.ts CHANGED
@@ -1,12 +1,4 @@
1
1
  import { Table } from './table';
2
- /**
3
- * @defaultValue
4
- * ```ts
5
- * {
6
- * createTable: (tableName: string, callback: (table: Table) => void) => Promise<void>
7
- * }
8
- * ```
9
- */
10
2
  export declare const Schema: {
11
3
  createTable: (tableName: string, callback: (table: Table) => void) => Promise<void>
12
4
  };
package/dist/seeder.d.ts CHANGED
@@ -1,4 +1,7 @@
1
+ import { db } from './utils';
1
2
  import { faker } from '@stacksjs/faker';
3
+ import { path } from '@stacksjs/path';
4
+ import { relative } from 'node:path';
2
5
  import type { Attribute, Model } from '@stacksjs/types';
3
6
  /**
4
7
  * Run application seeders from `database/seeders` in deterministic path order.
@@ -256,12 +259,29 @@ declare type FactoryFunction = (faker: unknown, attributes: Readonly<Record<stri
256
259
  * work such as creating an initial workspace or assigning roles.
257
260
  */
258
261
  export declare abstract class Seeder {
262
+ /**
263
+ * When this seeder runs, relative to its siblings. Lower runs first.
264
+ *
265
+ * Seeders otherwise run in path order, which is alphabetical and has nothing
266
+ * to do with what depends on what. A `ClubSeeder` that needs a user to own
267
+ * the club sorted before `UserSeeder` and quietly seeded nothing — the kind
268
+ * of failure that looks like the seeder being broken rather than early, and
269
+ * that a second `db:seed` "fixes" without explaining anything.
270
+ *
271
+ * Give anything that reads rows another seeder writes a higher number than
272
+ * the one that writes them. Equal values keep their path order, so existing
273
+ * seeders that never set this behave exactly as before.
274
+ *
275
+ * @default 0
276
+ * @defaultValue 0
277
+ */
259
278
  static order: number;
260
279
  static tags: readonly string[];
261
280
  abstract run(): Promise<void> | void;
262
281
  }
263
282
  /** A `pick()` that could not be satisfied. Never replaced with a default. */
264
283
  export declare class SeedReferenceError extends Error {
284
+ /** @defaultValue 'SeedReferenceError' */
265
285
  name: string;
266
286
  }
267
287
  // Legacy exports for backwards compatibility
package/dist/types.d.ts CHANGED
@@ -29,9 +29,9 @@
29
29
  */
30
30
  export declare function sql(strings: TemplateStringsArray, ...values: unknown[]): Sql;
31
31
  export declare namespace sql {
32
- let raw: (value: string) => { raw: string };
33
- let ref: (column: string) => { raw: string };
34
- let literal: (value: unknown) => { raw: string };
32
+ let raw: (value: string) => unknown;
33
+ let ref: (column: string) => unknown;
34
+ let literal: (value: unknown) => unknown;
35
35
  }
36
36
  /**
37
37
  * Runtime implementation behind `db.fn`. bun-query-builder has no
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/database",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.75.529",
5
+ "version": "0.75.535",
6
6
  "description": "The Stacks database integration.",
7
7
  "author": "Chris Breuer",
8
8
  "contributors": [
@@ -66,26 +66,26 @@
66
66
  "prepublishOnly": "bun run build"
67
67
  },
68
68
  "dependencies": {
69
- "@stacksjs/config": "0.75.529",
70
- "@stacksjs/env": "0.75.529",
71
- "@stacksjs/error-handling": "0.75.529",
72
- "@stacksjs/faker": "0.75.529",
73
- "@stacksjs/features": "0.75.529",
74
- "@stacksjs/logging": "0.75.529",
75
- "@stacksjs/model-meta": "0.75.529",
76
- "@stacksjs/path": "0.75.529",
77
- "@stacksjs/query-builder": "0.75.529",
78
- "@stacksjs/security": "0.75.529",
79
- "@stacksjs/storage": "0.75.529",
80
- "@stacksjs/strings": "0.75.529",
69
+ "@stacksjs/config": "0.75.535",
70
+ "@stacksjs/env": "0.75.535",
71
+ "@stacksjs/error-handling": "0.75.535",
72
+ "@stacksjs/faker": "0.75.535",
73
+ "@stacksjs/features": "0.75.535",
74
+ "@stacksjs/logging": "0.75.535",
75
+ "@stacksjs/model-meta": "0.75.535",
76
+ "@stacksjs/path": "0.75.535",
77
+ "@stacksjs/query-builder": "0.75.535",
78
+ "@stacksjs/security": "0.75.535",
79
+ "@stacksjs/storage": "0.75.535",
80
+ "@stacksjs/strings": "0.75.535",
81
81
  "@stacksjs/ts-validation": "^0.5.7",
82
- "bun-query-builder": "^0.3.38",
82
+ "bun-query-builder": "^0.3.44",
83
83
  "dynamodb-tooling": "^0.3.6"
84
84
  },
85
85
  "devDependencies": {
86
- "@stacksjs/cli": "0.75.529",
87
- "@stacksjs/router": "0.75.529",
88
- "@stacksjs/utils": "0.75.529",
86
+ "@stacksjs/cli": "0.75.535",
87
+ "@stacksjs/router": "0.75.535",
88
+ "@stacksjs/utils": "0.75.535",
89
89
  "better-dx": "^0.2.24"
90
90
  }
91
91
  }