@forinda/kickjs-db 5.4.1 → 5.5.0
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/devtools-events.mjs +1 -1
- package/dist/index.d.mts +64 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +24 -5
- package/dist/index.mjs.map +1 -1
- package/dist/pg.mjs +2 -2
- package/dist/{types-Ddl8seq-.mjs → types-lhPuw2Ra.mjs} +2 -2
- package/dist/{types-Ddl8seq-.mjs.map → types-lhPuw2Ra.mjs.map} +1 -1
- package/package.json +3 -3
package/dist/pg.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs-db v5.
|
|
2
|
+
* @forinda/kickjs-db v5.5.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import{t as ColumnBuilder}from"./types-
|
|
11
|
+
import{t as ColumnBuilder}from"./types-lhPuw2Ra.mjs";var PgEnumColumnBuilder=class extends ColumnBuilder{enumName;values;constructor(enumName,values){super(enumName),this.enumName=enumName,this.values=values}};function pgEnum(name,...values){return Object.assign(()=>new PgEnumColumnBuilder(name,values),{enumName:name,values})}function tsvector(){return new ColumnBuilder(`tsvector`)}function vector(dim){return new ColumnBuilder(dim===void 0?`vector`:`vector(${dim})`)}function citext(){return new ColumnBuilder(`citext`)}function money(){return new ColumnBuilder(`money`)}function inet(){return new ColumnBuilder(`inet`)}function cidr(){return new ColumnBuilder(`cidr`)}function xml(){return new ColumnBuilder(`xml`)}export{PgEnumColumnBuilder,cidr,citext,inet,money,pgEnum,tsvector,vector,xml};
|
|
12
12
|
//# sourceMappingURL=pg.mjs.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs-db v5.
|
|
2
|
+
* @forinda/kickjs-db v5.5.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -9,4 +9,4 @@
|
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
11
|
const KICK_GENERATED=Symbol.for(`@forinda/kickjs-db/Generated`),KICK_NOT_NULL=Symbol.for(`@forinda/kickjs-db/NotNull`);var ColumnBuilder=class{state;constructor(type,defaults={}){this.state={type,nullable:defaults.nullable??!0,default:defaults.default??null,primaryKey:defaults.primaryKey??!1,unique:defaults.unique??!1,references:defaults.references??null}}notNull(){return this.state.nullable=!1,this}primaryKey(){return this.state.primaryKey=!0,this.state.nullable=!1,this}unique(){return this.state.unique=!0,this}array(){return this.state.type=`${this.state.type}[]`,this}references(target,opts={}){return this.state.references={thunk:target,onDelete:opts.onDelete??`no_action`,onUpdate:opts.onUpdate??`no_action`},this}default(value){return this.state.default=value,this}toJSON(name){return{name,type:this.state.type,nullable:this.state.nullable,default:this.state.default,primaryKey:this.state.primaryKey}}__state(){return this.state}};export{KICK_GENERATED as n,KICK_NOT_NULL as r,ColumnBuilder as t};
|
|
12
|
-
//# sourceMappingURL=types-
|
|
12
|
+
//# sourceMappingURL=types-lhPuw2Ra.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types-
|
|
1
|
+
{"version":3,"file":"types-lhPuw2Ra.mjs","names":[],"sources":["../src/dsl/columns/types.ts"],"sourcesContent":["import type { ColumnSnapshot, FkAction } from '../../snapshot/types'\n\n/**\n * Runtime + type representation of a column reference (e.g. `users.id`).\n * Carries the parent table name, the column's own name, plus runtime\n * accessors used by FK thunks and constraint builders.\n *\n * Exported so adopters can annotate self-referencing thunks without\n * spelling the shape inline:\n *\n * parentId: uuid().references((): ColumnRef => categories.id)\n *\n * Without the annotation the initializer of a self-referencing const\n * trips TS7022 — TS needs to infer the const while the initializer\n * already references it.\n */\nexport interface ColumnRef {\n __tableName: string\n __name: string\n __builder: ColumnBuilder\n __state: () => ReturnType<ColumnBuilder['__state']>\n}\n\n/**\n * Resolved FK spec — `table` / `column` are pulled by invoking `thunk()`\n * lazily. The thunk pattern lets self-referencing tables work:\n *\n * const categories = table('categories', {\n * id: uuid().primaryKey().defaultRandom(),\n * parentId: uuid().references((): ColumnRef => categories.id),\n * })\n *\n * If we resolved at `.references()` call time, `categories` would TDZ-fail\n * inside its own initializer. Storing the thunk and resolving on read\n * (extract / render / emit) defers until after the const binding lands.\n */\nexport interface FkSpec {\n thunk: () => ColumnRef\n onDelete: FkAction\n onUpdate: FkAction\n}\n\nexport interface ColumnState {\n type: string\n nullable: boolean\n default: string | null\n primaryKey: boolean\n unique: boolean\n references: FkSpec | null\n}\n\n/**\n * Type-only brand attached to a column when it's auto-assigned by the\n * database (serial / bigserial / smallserial), has a runtime default\n * (`.default(...)`), or carries an expression default\n * (`uuid().defaultRandom()`, `timestamp().defaultNow()`). `SchemaToTypes<S>`\n * reads this marker and wraps the column type in Kysely's `Generated<T>` so\n * adopters can omit the column on insert.\n *\n * Runtime is a no-op — the symbol never reaches a value.\n */\nexport const KICK_GENERATED = Symbol.for('@forinda/kickjs-db/Generated')\nexport type GeneratedBrand = { readonly [KICK_GENERATED]?: true }\n\n/**\n * Type-only brand attached to a column when `.notNull()` or `.primaryKey()`\n * is called. `SchemaToTypes<S>` reads this brand to decide whether the\n * column type is `T` (NOT NULL) or `T | null` (default nullable).\n *\n * Why a brand instead of a class generic: chained methods (notNull,\n * primaryKey) can return `this & NotNullBrand` to narrow nullability while\n * preserving the subclass identity — so `uuid().primaryKey().defaultRandom()`\n * still resolves `defaultRandom()` on `UuidBuilder`. A class generic\n * `<TNullable>` would collapse the subclass back to the parent.\n */\nexport const KICK_NOT_NULL = Symbol.for('@forinda/kickjs-db/NotNull')\nexport type NotNullBrand = { readonly [KICK_NOT_NULL]?: true }\n\n/**\n * Phantom-typed column builder. The `T` generic carries the column's TS\n * value type (number / string / Date / etc.); nullability is tracked via\n * the `NotNullBrand` intersection rather than a class generic so chain\n * methods preserve subclass identity.\n *\n * Both `T` and the brand are erased at runtime; they exist purely so\n * `SchemaToTypes<S>` can pull them out per column.\n */\nexport class ColumnBuilder<T = unknown> {\n // Phantom param shows up in the public surface so the type system sees\n // it. Reading it at runtime is intentionally not supported.\n declare readonly __t?: T\n\n protected state: ColumnState\n\n constructor(type: string, defaults: Partial<ColumnState> = {}) {\n this.state = {\n type,\n nullable: defaults.nullable ?? true,\n default: defaults.default ?? null,\n primaryKey: defaults.primaryKey ?? false,\n unique: defaults.unique ?? false,\n references: defaults.references ?? null,\n }\n }\n\n notNull(): this & NotNullBrand {\n this.state.nullable = false\n return this as this & NotNullBrand\n }\n\n primaryKey(): this & NotNullBrand {\n this.state.primaryKey = true\n this.state.nullable = false\n return this as this & NotNullBrand\n }\n\n unique(): this {\n this.state.unique = true\n return this\n }\n\n array(): ColumnBuilder<T[]> {\n this.state.type = `${this.state.type}[]`\n return this as unknown as ColumnBuilder<T[]>\n }\n\n references(\n target: () => ColumnRef,\n opts: { onDelete?: FkAction; onUpdate?: FkAction } = {},\n ): this {\n // Store the thunk — do NOT invoke it here. Self-referencing tables\n // pass `() => self.id` whose binding does not exist yet.\n this.state.references = {\n thunk: target,\n onDelete: opts.onDelete ?? 'no_action',\n onUpdate: opts.onUpdate ?? 'no_action',\n }\n return this\n }\n\n /**\n * Mark the column as having a runtime / DB-assigned default. The\n * `GeneratedBrand` flows into `SchemaToTypes<S>` so the column wraps\n * in `Generated<T>` — adopters can `INSERT` without specifying it.\n */\n default(value: string): this & GeneratedBrand {\n this.state.default = value\n return this as this & GeneratedBrand\n }\n\n toJSON(name: string): ColumnSnapshot {\n return {\n name,\n type: this.state.type,\n nullable: this.state.nullable,\n default: this.state.default,\n primaryKey: this.state.primaryKey,\n }\n }\n\n // Internal accessor for table()/diff to read full state including unique/references.\n __state(): Readonly<ColumnState> {\n return this.state\n }\n}\n"],"mappings":";;;;;;;;;;AA6DA,MAAa,eAAiB,OAAO,IAAI,+BAA+B,CAc3D,cAAgB,OAAO,IAAI,6BAA6B,CAYrE,IAAa,cAAb,KAAwC,CAKtC,MAEA,YAAY,KAAc,SAAiC,EAAE,CAAE,CAC7D,KAAK,MAAQ,CACX,KACA,SAAU,SAAS,UAAY,GAC/B,QAAS,SAAS,SAAW,KAC7B,WAAY,SAAS,YAAc,GACnC,OAAQ,SAAS,QAAU,GAC3B,WAAY,SAAS,YAAc,KACpC,CAGH,SAA+B,CAE7B,MADA,MAAK,MAAM,SAAW,GACf,KAGT,YAAkC,CAGhC,MAFA,MAAK,MAAM,WAAa,GACxB,KAAK,MAAM,SAAW,GACf,KAGT,QAAe,CAEb,MADA,MAAK,MAAM,OAAS,GACb,KAGT,OAA4B,CAE1B,MADA,MAAK,MAAM,KAAO,GAAG,KAAK,MAAM,KAAK,IAC9B,KAGT,WACE,OACA,KAAqD,EAAE,CACjD,CAQN,MALA,MAAK,MAAM,WAAa,CACtB,MAAO,OACP,SAAU,KAAK,UAAY,YAC3B,SAAU,KAAK,UAAY,YAC5B,CACM,KAQT,QAAQ,MAAsC,CAE5C,MADA,MAAK,MAAM,QAAU,MACd,KAGT,OAAO,KAA8B,CACnC,MAAO,CACL,KACA,KAAM,KAAK,MAAM,KACjB,SAAU,KAAK,MAAM,SACrB,QAAS,KAAK,MAAM,QACpB,WAAY,KAAK,MAAM,WACxB,CAIH,SAAiC,CAC/B,OAAO,KAAK"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forinda/kickjs-db",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.5.0",
|
|
4
4
|
"description": "KickJS-native ORM — code-first schema, reversible migrations, multi-dialect SQL builder",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"kickjs",
|
|
@@ -72,8 +72,8 @@
|
|
|
72
72
|
"kysely": "^0.28.16",
|
|
73
73
|
"pg": "^8.13.1",
|
|
74
74
|
"typescript": "^6.0.3",
|
|
75
|
-
"@forinda/kickjs": "5.
|
|
76
|
-
"@forinda/kickjs
|
|
75
|
+
"@forinda/kickjs-devtools-kit": "5.3.1",
|
|
76
|
+
"@forinda/kickjs": "5.5.0"
|
|
77
77
|
},
|
|
78
78
|
"publishConfig": {
|
|
79
79
|
"access": "public"
|