@ultimat3/entity 1.0.0 → 1.1.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/package.json +4 -4
- package/src/column.d.ts +0 -28
- package/src/column.d.ts.map +0 -1
- package/src/column.js +0 -75
- package/src/column.js.map +0 -1
- package/src/columns.d.ts +0 -39
- package/src/columns.d.ts.map +0 -1
- package/src/columns.js +0 -136
- package/src/columns.js.map +0 -1
- package/src/database.d.ts +0 -21
- package/src/database.d.ts.map +0 -1
- package/src/database.js +0 -38
- package/src/database.js.map +0 -1
- package/src/describe.d.ts +0 -16
- package/src/describe.d.ts.map +0 -1
- package/src/describe.js +0 -79
- package/src/describe.js.map +0 -1
- package/src/entity.d.ts +0 -58
- package/src/entity.d.ts.map +0 -1
- package/src/entity.js +0 -160
- package/src/entity.js.map +0 -1
- package/src/errors.d.ts +0 -18
- package/src/errors.d.ts.map +0 -1
- package/src/errors.js +0 -59
- package/src/errors.js.map +0 -1
- package/src/expr.d.ts +0 -41
- package/src/expr.d.ts.map +0 -1
- package/src/expr.js +0 -94
- package/src/expr.js.map +0 -1
- package/src/index.d.ts +0 -23
- package/src/index.d.ts.map +0 -1
- package/src/index.js +0 -12
- package/src/index.js.map +0 -1
- package/src/invariants.d.ts +0 -36
- package/src/invariants.d.ts.map +0 -1
- package/src/invariants.js +0 -53
- package/src/invariants.js.map +0 -1
- package/src/query.d.ts +0 -30
- package/src/query.d.ts.map +0 -1
- package/src/query.js +0 -74
- package/src/query.js.map +0 -1
- package/src/registry.d.ts +0 -45
- package/src/registry.d.ts.map +0 -1
- package/src/registry.js +0 -26
- package/src/registry.js.map +0 -1
- package/src/repo.d.ts +0 -54
- package/src/repo.d.ts.map +0 -1
- package/src/repo.js +0 -203
- package/src/repo.js.map +0 -1
- package/src/seed.d.ts +0 -20
- package/src/seed.d.ts.map +0 -1
- package/src/seed.js +0 -43
- package/src/seed.js.map +0 -1
- package/src/tenancy.d.ts +0 -41
- package/src/tenancy.d.ts.map +0 -1
- package/src/tenancy.js +0 -57
- package/src/tenancy.js.map +0 -1
- package/src/types.d.ts +0 -99
- package/src/types.d.ts.map +0 -1
- package/src/types.js +0 -8
- package/src/types.js.map +0 -1
package/src/types.d.ts
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
/** Postgres types the blessed builders emit. `money` expands to `bigint` + `char(3)`. */
|
|
2
|
-
export type ColumnKind = 'uuid' | 'text' | 'char' | 'boolean' | 'integer' | 'bigint' | 'timestamptz' | 'jsonb' | 'money';
|
|
3
|
-
export type ColumnDefault = {
|
|
4
|
-
readonly kind: 'value';
|
|
5
|
-
readonly value: string | number | boolean | null;
|
|
6
|
-
} | {
|
|
7
|
-
readonly kind: 'generated';
|
|
8
|
-
readonly by: 'uuid-v7' | 'now';
|
|
9
|
-
};
|
|
10
|
-
export type OnDelete = 'cascade' | 'restrict' | 'set null';
|
|
11
|
-
export interface ReferenceOptions {
|
|
12
|
-
readonly onDelete?: OnDelete;
|
|
13
|
-
}
|
|
14
|
-
/** The single value a money column puts on the row. Two physical columns back it. */
|
|
15
|
-
export interface MoneyValue {
|
|
16
|
-
readonly minor: bigint;
|
|
17
|
-
readonly currency: string;
|
|
18
|
-
}
|
|
19
|
-
/** What a writer may hand a money column. An integer `number` widens; a float throws. */
|
|
20
|
-
export interface MoneyInput {
|
|
21
|
-
readonly minor: bigint | number;
|
|
22
|
-
readonly currency: string;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* What the author declared. Where it landed — table, property key, physical name — is the
|
|
26
|
-
* binding `entity()` records (see `column.ts`), so a name is never written twice.
|
|
27
|
-
*/
|
|
28
|
-
export interface ColumnMeta {
|
|
29
|
-
readonly kind: ColumnKind;
|
|
30
|
-
readonly notNull: boolean;
|
|
31
|
-
readonly primaryKey: boolean;
|
|
32
|
-
readonly unique: boolean;
|
|
33
|
-
readonly index: boolean;
|
|
34
|
-
/** Presence of a tenant column is what turns tenancy on. See `tenancy.ts`. */
|
|
35
|
-
readonly tenant: boolean;
|
|
36
|
-
readonly length?: number;
|
|
37
|
-
readonly values?: readonly string[];
|
|
38
|
-
readonly default?: ColumnDefault;
|
|
39
|
-
readonly onUpdate?: ColumnDefault;
|
|
40
|
-
/** Takes the physical name, so a CHECK can be written before that name is known. */
|
|
41
|
-
readonly check?: (column: string) => string;
|
|
42
|
-
/** A thunk: schema modules reference each other in a cycle. */
|
|
43
|
-
readonly references?: () => AnyColumn;
|
|
44
|
-
readonly onDelete?: OnDelete;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* `Optional` is the phantom that says "this column has a default", so an insert may omit it.
|
|
48
|
-
* It is a real boolean at runtime too, so nothing has to be re-derived to check it.
|
|
49
|
-
*/
|
|
50
|
-
export interface Column<T, Optional extends boolean = false> {
|
|
51
|
-
readonly $meta: ColumnMeta;
|
|
52
|
-
/** Runtime guard AND the carrier of the column's TypeScript type. */
|
|
53
|
-
readonly $parse: (value: unknown) => T;
|
|
54
|
-
readonly $optional: Optional;
|
|
55
|
-
/** `boolean`: only a uuid key carries a generated default, so only it becomes optional. */
|
|
56
|
-
primaryKey(): Column<T, boolean>;
|
|
57
|
-
nullable(): Column<T | null, Optional>;
|
|
58
|
-
unique(): Column<T, Optional>;
|
|
59
|
-
/** Marks the tenant column; a query without an org predicate then throws. */
|
|
60
|
-
tenant(): Column<T, Optional>;
|
|
61
|
-
references(target: () => AnyColumn, options?: ReferenceOptions): Column<T, Optional>;
|
|
62
|
-
default(value: T): Column<T, true>;
|
|
63
|
-
}
|
|
64
|
-
/** A uuid primary key is generated (v7) when omitted, which is why it narrows to `true`. */
|
|
65
|
-
export interface UuidColumn<Optional extends boolean = false> extends Column<string, Optional> {
|
|
66
|
-
primaryKey(): Column<string, true>;
|
|
67
|
-
}
|
|
68
|
-
export interface TimestampColumn<Optional extends boolean = false> extends Column<Date, Optional> {
|
|
69
|
-
defaultNow(): TimestampColumn<true>;
|
|
70
|
-
onUpdateNow(): TimestampColumn<Optional>;
|
|
71
|
-
}
|
|
72
|
-
export type AnyColumn = Column<unknown, boolean>;
|
|
73
|
-
export type ColumnMap = Readonly<Record<string, AnyColumn>>;
|
|
74
|
-
export type TypeOf<C> = C extends Column<infer T, boolean> ? T : never;
|
|
75
|
-
/** The row type a column set describes. This derivation is why the package exists. */
|
|
76
|
-
export type RowOf<C extends ColumnMap> = {
|
|
77
|
-
readonly [K in keyof C]: TypeOf<C[K]>;
|
|
78
|
-
};
|
|
79
|
-
type DefaultedKeys<C extends ColumnMap> = {
|
|
80
|
-
[K in keyof C]-?: C[K]['$optional'] extends true ? K : never;
|
|
81
|
-
}[keyof C];
|
|
82
|
-
/** Money is the one column whose write shape is wider than its row shape. */
|
|
83
|
-
type InputOf<T> = T extends MoneyValue ? MoneyInput : T;
|
|
84
|
-
/** What an insert must supply: every column except the ones carrying a default. */
|
|
85
|
-
export type Insertable<C extends ColumnMap> = {
|
|
86
|
-
readonly [K in Exclude<keyof C, DefaultedKeys<C>>]: InputOf<TypeOf<C[K]>>;
|
|
87
|
-
} & {
|
|
88
|
-
readonly [K in DefaultedKeys<C>]?: InputOf<TypeOf<C[K]>>;
|
|
89
|
-
};
|
|
90
|
-
export interface IndexDef {
|
|
91
|
-
readonly name: string;
|
|
92
|
-
readonly columns: readonly string[];
|
|
93
|
-
readonly unique: boolean;
|
|
94
|
-
readonly order?: 'asc' | 'desc';
|
|
95
|
-
/** Partial index predicate — a soft-deleted row is excluded with this. */
|
|
96
|
-
readonly where?: string;
|
|
97
|
-
}
|
|
98
|
-
export {};
|
|
99
|
-
//# sourceMappingURL=types.d.ts.map
|
package/src/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":"AAOA,yFAAyF;AACzF,MAAM,MAAM,UAAU,GAClB,MAAM,GACN,MAAM,GACN,MAAM,GACN,SAAS,GACT,SAAS,GACT,QAAQ,GACR,aAAa,G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EAAE,CAAC,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CACzD,CAAC;AAEF,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IAChC,0EAA0E;IAC1E,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB"}
|
package/src/types.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
// The structural vocabulary of a column. Drizzle is the production backing for the physical
|
|
2
|
-
// layer (see README); declaring the shape we consume instead of depending on an ORM keeps the
|
|
3
|
-
// emitted SQL readable and keeps this package free of a dependency an agent must learn to read.
|
|
4
|
-
//
|
|
5
|
-
// A column carries its TypeScript type in `$parse`, which is what lets the row type be derived
|
|
6
|
-
// from the column set instead of being written a second time as a hand-maintained schema.
|
|
7
|
-
export {};
|
|
8
|
-
//# sourceMappingURL=types.js.map
|
package/src/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,8FAA8F;AAC9F,gGAAgG;AAChG,EAAE;AACF,+FAA+F;AAC/F,0FAA0F"}
|