idora.js-drizzle 0.0.0-stage → 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jake Seracino
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,153 @@
1
- # Temporary Holding Version
1
+ # idora.js-drizzle
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [Drizzle ORM](https://orm.drizzle.team) columns and filters for
4
+ [Idora](https://github.com/SrKleRAimBot/Idora/tree/main/Idora.JS) identifiers such as
5
+ `usr_01k2f9v8ta7m3x0qbrn4dzeh5c`.
6
+
7
+ ```ts
8
+ import { createdBetween } from 'idora.js-drizzle';
9
+ import { idoraId, idoraPrimaryKey } from 'idora.js-drizzle/pg';
10
+
11
+ export const users = pgTable('users', {
12
+ id: idoraPrimaryKey(ids, User), // varchar(30), filled in on insert
13
+ email: text().notNull(),
14
+ });
15
+
16
+ export const orders = pgTable('orders', {
17
+ id: idoraPrimaryKey(ids, Order),
18
+ userId: idoraId(ids, User).notNull().references(() => users.id),
19
+ });
20
+
21
+ const [user] = await db.insert(users).values({ email }).returning();
22
+ user.id; // 'usr_01k2f9v8ta7m3x0qbrn4dzeh5c'
23
+
24
+ // Everyone who signed up this week, straight off the primary key's index.
25
+ await db.select().from(users).where(createdBetween(users.id, startOfWeek, now));
26
+ ```
27
+
28
+ Primary keys that mint themselves in your process — no database extension, no round trip — in a
29
+ column sized exactly for them, and time-window queries that need no `created_at` column.
30
+
31
+ ---
32
+
33
+ ## Install
34
+
35
+ ```bash
36
+ npm install idora.js-drizzle idora.js drizzle-orm
37
+ ```
38
+
39
+ `idora.js` and `drizzle-orm` (0.44 or later, below 1.0) are peer dependencies, and this package adds
40
+ no others. It is an ES module with TypeScript declarations included.
41
+
42
+ ---
43
+
44
+ ## Columns
45
+
46
+ Drizzle's column types belong to a dialect, so the column helpers do too. Each module has the same
47
+ two functions:
48
+
49
+ | Module | For | Column type |
50
+ | --- | --- | --- |
51
+ | `idora.js-drizzle/pg` | PostgreSQL, and anything speaking its protocol | `varchar(n)` |
52
+ | `idora.js-drizzle/mysql` | MySQL, MariaDB, PlanetScale | `varchar(n)` |
53
+ | `idora.js-drizzle/sqlite` | SQLite, libSQL and Turso, Cloudflare D1, Bun | `text` |
54
+
55
+ `n` is the exact length of the entity's identifiers: its prefix, the separator and a 26-character
56
+ ULID or 32-character UUIDv7, whichever the generator mints. That is `varchar(30)` for `usr` with
57
+ ULIDs — every identifier for one entity type has the same length — and lets the database refuse a
58
+ value that cannot be one. SQLite does not enforce lengths, so there the column is plain `text`.
59
+
60
+ ### `idoraPrimaryKey(ids, Entity, options?)`
61
+
62
+ The table's primary key, not null, filled in by `ids.generate(Entity)` on every insert that does
63
+ not supply one, through Drizzle's `$defaultFn`. A value you supply is kept. drizzle-kit migrations
64
+ show no default, because the identifier is made in your process rather than by the database.
65
+
66
+ Identifiers are time-ordered, so inserts land at the end of the primary key's index instead of
67
+ scattering through it, as random UUIDs do.
68
+
69
+ ### `idoraId(ids, Entity, options?)`
70
+
71
+ A column that holds the entity's identifiers but mints none — a foreign key, typically. Chain
72
+ Drizzle's own modifiers onto it as usual: `.notNull()`, `.references(...)`, `.unique()`.
73
+
74
+ Both throw `EntityPrefixNotRegisteredError` for an entity type `ids` has not registered, when the
75
+ schema module loads — so a forgotten registration stops start-up rather than the first insert.
76
+
77
+ ### Options
78
+
79
+ | Option | Default | |
80
+ | --- | --- | --- |
81
+ | `name` | the property's key | The column's name in the database. |
82
+ | `mode` | `'string'` | `'string'` for the identifier's text; `'parsed'` for an `IdoraId` |
83
+
84
+ With `mode: 'parsed'`, rows are read as `IdoraId` objects — with `createdAt`, `prefix` and the
85
+ natural order to hand — and `IdoraId` objects are written as their text. The database column is
86
+ the same either way. A parsed column checks the entity's prefix in both directions: a row holding
87
+ another entity's identifier throws `InvalidIdError` when read, and so does writing one. It checks
88
+ the format too, since the time filters compute their bounds in the generator's format and would
89
+ silently miss a row in the other one: a UUIDv7 in a ULID column, or the reverse, throws a
90
+ `TypeError` either way. To change strategy, migrate the existing rows along with the column.
91
+
92
+ ```ts
93
+ export const events = pgTable('events', {
94
+ id: idoraPrimaryKey(ids, Event, { mode: 'parsed' }),
95
+ });
96
+
97
+ const [event] = await db.select().from(events).limit(1);
98
+ event.id.createdAt; // a Date
99
+ ```
100
+
101
+ ---
102
+
103
+ ## Filtering by time
104
+
105
+ An identifier begins with the time it was minted, so the identifiers minted in a span of time are a
106
+ contiguous range of strings. These filters turn a span into that range:
107
+
108
+ | Filter | Selects rows minted |
109
+ | --- | --- |
110
+ | `createdBetween(column, from, to)` | from `from` to `to`, both inclusive |
111
+ | `createdAfter(column, instant)` | strictly after `instant` |
112
+ | `createdBefore(column, instant)` | strictly before `instant` |
113
+
114
+ Times are `Date`s or milliseconds since the Unix epoch, compared to the millisecond. They come from
115
+ `idora.js-drizzle` itself and work with every dialect:
116
+
117
+ ```ts
118
+ import { createdAfter, createdBetween } from 'idora.js-drizzle';
119
+
120
+ await db.select().from(users).where(createdBetween(users.id, from, to));
121
+ // select … from "users" where ("users"."id" >= $1 and "users"."id" <= $2)
122
+ // $1 = 'usr_01k226e0g00000000000000000', $2 = 'usr_01k2…zzzzzzzzzzzzzzzz'
123
+ ```
124
+
125
+ The database compares them with the column's collation, so give the column a binary or `C`
126
+ collation. A linguistic collation is safe only if it orders the identifier's characters exactly as
127
+ a byte comparison does, and many do not: Czech and Slovak treat `ch` as one letter, Danish `aa`,
128
+ Lithuanian sorts `y` before `j`, Estonian `z` before `t`, and a numeric ("natural sort")
129
+ collation compares runs of digits as numbers. Any of them can put a bound on the wrong side of a
130
+ row, so the range silently misses it. See
131
+ [§6.4 of the specification](https://github.com/SrKleRAimBot/Idora/blob/main/spec/SPECIFICATION.md#64-range-bounds).
132
+
133
+ The bounds are the lowest and highest identifiers any generator can mint for the column's entity
134
+ type in its format, so the query is an ordinary range over the column and uses its index — the
135
+ primary key's, for a primary key. It is tested against a real PostgreSQL (PGlite) and SQLite,
136
+ including that the PostgreSQL plan is an index scan.
137
+
138
+ The filters read the prefix and format from columns declared with `idoraId` or `idoraPrimaryKey`.
139
+ For any other column of identifiers, say what it holds:
140
+
141
+ ```ts
142
+ createdBetween(legacy.ref, from, to, { prefix: 'usr', format: 'ulid' });
143
+ ```
144
+
145
+ A range compares correctly only in a collation that orders identifiers as bytes, binary or `C`
146
+ (see above). A column holding identifiers of more than one prefix or format is not a range; filter
147
+ each prefix separately.
148
+
149
+ ---
150
+
151
+ ## License
152
+
153
+ MIT — see [LICENSE](https://github.com/SrKleRAimBot/Idora/blob/main/LICENSE).
@@ -0,0 +1,21 @@
1
+ /**
2
+ * What a column's values are in JavaScript.
3
+ *
4
+ * - `'string'` (the default): the identifier's text, as Idora generates it. The column is the
5
+ * dialect's own string type, so drizzle-kit and every query treat it as one.
6
+ * - `'parsed'`: an `IdoraId`, parsed — and checked against the entity's prefix — as each row is
7
+ * read, and written back as its text. For code that wants `createdAt` and the natural order to
8
+ * hand, at the cost of a parse per value.
9
+ */
10
+ export type IdoraColumnMode = 'string' | 'parsed';
11
+ /** Options shared by every column helper. */
12
+ export interface IdoraColumnOptions<TMode extends IdoraColumnMode = IdoraColumnMode, TName extends string = string> {
13
+ /**
14
+ * The column's name in the database. Omit it to use the property's key, as with any Drizzle
15
+ * column declared without a name.
16
+ */
17
+ readonly name?: TName;
18
+ /** What the column's values are in JavaScript. Defaults to `'string'`. See {@link IdoraColumnMode}. */
19
+ readonly mode?: TMode;
20
+ }
21
+ //# sourceMappingURL=columns.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"columns.d.ts","sourceRoot":"","sources":["../src/columns.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAElD,6CAA6C;AAC7C,MAAM,WAAW,kBAAkB,CAAC,KAAK,SAAS,eAAe,GAAG,eAAe,EAAE,KAAK,SAAS,MAAM,GAAG,MAAM;IAChH;;;OAGG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC;IAEtB,uGAAuG;IACvG,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC;CACvB"}
@@ -0,0 +1,83 @@
1
+ import { Idora, IdoraId } from 'idora.js';
2
+ /**
3
+ * The columns this package declared, keyed by their builder's configuration object.
4
+ *
5
+ * Drizzle hands that object on, unchanged, to the column it builds from the builder — the same
6
+ * object, not a copy — so a column found in a table can be traced back to the entity type and
7
+ * generator it was declared for without wrapping or subclassing anything of Drizzle's.
8
+ */
9
+ const declaredColumns = new WeakMap();
10
+ /**
11
+ * Validates a column helper's arguments, failing at schema-definition time rather than on the first
12
+ * insert.
13
+ *
14
+ * @internal
15
+ */
16
+ export function describeColumn(ids, entityType, options) {
17
+ if (!(ids instanceof Idora)) {
18
+ throw new TypeError(`An Idora column needs the Idora generator its entity types are registered with as its first argument, but received ${ids === null ? 'null' : typeof ids}.`);
19
+ }
20
+ const mode = options.mode ?? 'string';
21
+ if (mode !== 'string' && mode !== 'parsed') {
22
+ throw new TypeError(`'${String(mode)}' is not an Idora column mode. Use 'string' (the default) or 'parsed'.`);
23
+ }
24
+ const prefix = ids.registry.getPrefix(entityType);
25
+ return Object.freeze({
26
+ ids,
27
+ entityType,
28
+ prefix,
29
+ format: ids.strategy,
30
+ mode,
31
+ length: prefix.length + 1 + ids.valueLength,
32
+ });
33
+ }
34
+ /** @internal Records that `builder` was declared by this package, and returns it. */
35
+ export function remember(builder, info) {
36
+ declaredColumns.set(configOf(builder), info);
37
+ return builder;
38
+ }
39
+ /** @internal What this package recorded about `column`, if it declared it. */
40
+ export function recall(column) {
41
+ const config = configOf(column);
42
+ return config === undefined ? undefined : declaredColumns.get(config);
43
+ }
44
+ /**
45
+ * @internal The conversions for a `'parsed'` column. Values are checked against the entity's
46
+ * prefix and the column's format in both directions: a row holding another entity's identifier, or
47
+ * one in the other format, fails to read, and writing one fails too, rather than either slipping
48
+ * through. The format matters as much as the prefix: the time filters compute their bounds in the
49
+ * column's format, so a row in the other format would silently fall outside them.
50
+ */
51
+ export function parsedConversions(info) {
52
+ const { ids, entityType, prefix, format } = info;
53
+ const inFormat = (id) => {
54
+ if (id.format !== format) {
55
+ throw new TypeError(`'${id.text}' is a ${id.format} identifier, but this column holds ${format} identifiers, the generator's strategy. ` +
56
+ 'A column holds one format, so that its time filters find every row; migrate existing rows when changing strategy.');
57
+ }
58
+ return id;
59
+ };
60
+ return {
61
+ toDriver: (value) => inFormat(value instanceof IdoraId && value.prefix === prefix
62
+ ? value
63
+ : ids.parse(entityType, value instanceof IdoraId ? value.text : value)).text,
64
+ fromDriver: (value) => inFormat(ids.parse(entityType, value)),
65
+ };
66
+ }
67
+ /** @internal A generator of fresh values for the column: identifiers, or parsed identifiers. */
68
+ export function generatorFor(info) {
69
+ const { ids, entityType } = info;
70
+ return info.mode === 'parsed' ? () => ids.parse(entityType, ids.generate(entityType)) : () => ids.generate(entityType);
71
+ }
72
+ /**
73
+ * Builders and columns both keep their runtime configuration in a `config` property. Drizzle types
74
+ * it as protected, though its own query builders read it freely.
75
+ */
76
+ function configOf(value) {
77
+ if (value === null || typeof value !== 'object') {
78
+ return undefined;
79
+ }
80
+ const config = value.config;
81
+ return config !== null && typeof config === 'object' ? config : undefined;
82
+ }
83
+ //# sourceMappingURL=columns.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"columns.js","sourceRoot":"","sources":["../src/columns.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,EAAE,OAAO,EAAmB,MAAM,UAAU,CAAC;AAoC5E;;;;;;GAMG;AACH,MAAM,eAAe,GAAG,IAAI,OAAO,EAA2B,CAAC;AAE/D;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,GAAU,EAAE,UAAsB,EAAE,OAA2B;IAC5F,IAAI,CAAC,CAAC,GAAG,YAAY,KAAK,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,SAAS,CACjB,sHAAsH,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,GAAG,GAAG,CAC5J,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,QAAQ,CAAC;IACtC,IAAI,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC3C,MAAM,IAAI,SAAS,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,wEAAwE,CAAC,CAAC;IAChH,CAAC;IAED,MAAM,MAAM,GAAG,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IAClD,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,GAAG;QACH,UAAU;QACV,MAAM;QACN,MAAM,EAA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CAAC,CAAC,CAAE,KAA2B,CAAC,CAChG,CAAC,IAAI;QACR,UAAU,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;KAC9D,CAAC;AACJ,CAAC;AAED,gGAAgG;AAChG,MAAM,UAAU,YAAY,CAAC,IAAqB;IAChD,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;IACjC,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,UAAU,EAAE,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;AACzH,CAAC;AAED;;;GAGG;AACH,SAAS,QAAQ,CAAC,KAAc;IAC9B,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAChD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,MAAM,GAAa,KAAuC,CAAC,MAAM,CAAC;IACxE,OAAO,MAAM,KAAK,IAAI,IAAI,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AAC5E,CAAC"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * idora.js-drizzle — Drizzle ORM columns and filters for Idora identifiers such as
3
+ * `usr_01k2f9v8ta7m3x0qbrn4dzeh5c`.
4
+ *
5
+ * The column helpers live in one module per dialect — `idora.js-drizzle/pg`, `/mysql` and
6
+ * `/sqlite` — because Drizzle's column types do. The filters here work with all three.
7
+ *
8
+ * @packageDocumentation
9
+ */
10
+ import { type Column, type SQL } from 'drizzle-orm';
11
+ import { type IdStrategy } from 'idora.js';
12
+ export type { IdoraColumnMode, IdoraColumnOptions } from './columns.js';
13
+ /**
14
+ * The prefix and format of a column that was not declared with this package's helpers, so the
15
+ * filters can still work out its bounds.
16
+ */
17
+ export interface IdRange {
18
+ /** The prefix every identifier in the column carries. */
19
+ readonly prefix: string;
20
+ /** The format of the values in the column. Defaults to `'ulid'`. */
21
+ readonly format?: IdStrategy;
22
+ }
23
+ /**
24
+ * Selects the rows whose identifier was minted between `from` and `to`, both inclusive, to the
25
+ * millisecond:
26
+ *
27
+ * ```ts
28
+ * import { createdBetween } from 'idora.js-drizzle';
29
+ *
30
+ * await db.select().from(users).where(createdBetween(users.id, lastMonday, now));
31
+ * // … WHERE "id" >= 'usr_01k226e0g00000000000000000' AND "id" <= 'usr_01k2…zzzzzzzzzzzzzzzz'
32
+ * ```
33
+ *
34
+ * An identifier begins with the time it was minted, so this is a plain string range over the
35
+ * column: it uses the column's index — the primary key's, for a primary key — and reads no row it
36
+ * does not return. There is no need for a separate `created_at` column just to filter on.
37
+ *
38
+ * The bounds are the lowest and highest identifiers any generator can mint for the column's entity
39
+ * type in its format; see `IdoraId.lowerBound` in `idora.js`. They compare correctly in a collation
40
+ * that orders identifiers as bytes, binary or `C`. Many linguistic collations do not (Czech treats
41
+ * `ch` as one letter, Lithuanian sorts `y` before `j`, a numeric collation compares digit runs as
42
+ * numbers), and can put a bound on the wrong side of a row, so the range silently misses it.
43
+ *
44
+ * @param column A column declared with `idoraId` or `idoraPrimaryKey` from this package — or any
45
+ * column of identifiers, when `range` says what prefix and format it holds.
46
+ * @param from A `Date`, or milliseconds since the Unix epoch.
47
+ * @param to A `Date`, or milliseconds since the Unix epoch.
48
+ * @param range Only for a column not declared with this package's helpers.
49
+ * @throws {RangeError} `from` or `to` is before the Unix epoch, after the year 10889, or not a valid
50
+ * time.
51
+ * @throws {TypeError} The column's prefix and format are unknown, or given twice.
52
+ */
53
+ export declare function createdBetween(column: Column, from: Date | number, to: Date | number, range?: IdRange): SQL;
54
+ /**
55
+ * Selects the rows whose identifier was minted strictly after `instant`, to the millisecond. See
56
+ * {@link createdBetween}.
57
+ *
58
+ * @throws {RangeError} `instant` is before the Unix epoch, after the year 10889, or not a valid time.
59
+ * @throws {TypeError} The column's prefix and format are unknown, or given twice.
60
+ */
61
+ export declare function createdAfter(column: Column, instant: Date | number, range?: IdRange): SQL;
62
+ /**
63
+ * Selects the rows whose identifier was minted strictly before `instant`, to the millisecond. See
64
+ * {@link createdBetween}.
65
+ *
66
+ * @throws {RangeError} `instant` is before the Unix epoch, after the year 10889, or not a valid time.
67
+ * @throws {TypeError} The column's prefix and format are unknown, or given twice.
68
+ */
69
+ export declare function createdBefore(column: Column, instant: Date | number, range?: IdRange): SQL;
70
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAO,KAAK,MAAM,EAAoB,KAAK,GAAG,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAW,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAIpD,YAAY,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAExE;;;GAGG;AACH,MAAM,WAAW,OAAO;IACtB,yDAAyD;IACzD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,oEAAoE;IACpE,QAAQ,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,MAAM,EAAE,EAAE,EAAE,IAAI,GAAG,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,GAAG,CAI3G;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,GAAG,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,GAAG,CAEzF;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,GAAG,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,GAAG,CAE1F"}
package/dist/index.js ADDED
@@ -0,0 +1,100 @@
1
+ /**
2
+ * idora.js-drizzle — Drizzle ORM columns and filters for Idora identifiers such as
3
+ * `usr_01k2f9v8ta7m3x0qbrn4dzeh5c`.
4
+ *
5
+ * The column helpers live in one module per dialect — `idora.js-drizzle/pg`, `/mysql` and
6
+ * `/sqlite` — because Drizzle's column types do. The filters here work with all three.
7
+ *
8
+ * @packageDocumentation
9
+ */
10
+ import { and, gt, gte, lt, lte } from 'drizzle-orm';
11
+ import { IdoraId } from 'idora.js';
12
+ import { recall } from './columns.js';
13
+ /**
14
+ * Selects the rows whose identifier was minted between `from` and `to`, both inclusive, to the
15
+ * millisecond:
16
+ *
17
+ * ```ts
18
+ * import { createdBetween } from 'idora.js-drizzle';
19
+ *
20
+ * await db.select().from(users).where(createdBetween(users.id, lastMonday, now));
21
+ * // … WHERE "id" >= 'usr_01k226e0g00000000000000000' AND "id" <= 'usr_01k2…zzzzzzzzzzzzzzzz'
22
+ * ```
23
+ *
24
+ * An identifier begins with the time it was minted, so this is a plain string range over the
25
+ * column: it uses the column's index — the primary key's, for a primary key — and reads no row it
26
+ * does not return. There is no need for a separate `created_at` column just to filter on.
27
+ *
28
+ * The bounds are the lowest and highest identifiers any generator can mint for the column's entity
29
+ * type in its format; see `IdoraId.lowerBound` in `idora.js`. They compare correctly in a collation
30
+ * that orders identifiers as bytes, binary or `C`. Many linguistic collations do not (Czech treats
31
+ * `ch` as one letter, Lithuanian sorts `y` before `j`, a numeric collation compares digit runs as
32
+ * numbers), and can put a bound on the wrong side of a row, so the range silently misses it.
33
+ *
34
+ * @param column A column declared with `idoraId` or `idoraPrimaryKey` from this package — or any
35
+ * column of identifiers, when `range` says what prefix and format it holds.
36
+ * @param from A `Date`, or milliseconds since the Unix epoch.
37
+ * @param to A `Date`, or milliseconds since the Unix epoch.
38
+ * @param range Only for a column not declared with this package's helpers.
39
+ * @throws {RangeError} `from` or `to` is before the Unix epoch, after the year 10889, or not a valid
40
+ * time.
41
+ * @throws {TypeError} The column's prefix and format are unknown, or given twice.
42
+ */
43
+ export function createdBetween(column, from, to, range) {
44
+ const bounds = boundsFor(column, range);
45
+ // `and` returns undefined only when every condition is undefined, which these never are.
46
+ return and(gte(column, bounds.lower(from)), lte(column, bounds.upper(to)));
47
+ }
48
+ /**
49
+ * Selects the rows whose identifier was minted strictly after `instant`, to the millisecond. See
50
+ * {@link createdBetween}.
51
+ *
52
+ * @throws {RangeError} `instant` is before the Unix epoch, after the year 10889, or not a valid time.
53
+ * @throws {TypeError} The column's prefix and format are unknown, or given twice.
54
+ */
55
+ export function createdAfter(column, instant, range) {
56
+ return gt(column, boundsFor(column, range).upper(instant));
57
+ }
58
+ /**
59
+ * Selects the rows whose identifier was minted strictly before `instant`, to the millisecond. See
60
+ * {@link createdBetween}.
61
+ *
62
+ * @throws {RangeError} `instant` is before the Unix epoch, after the year 10889, or not a valid time.
63
+ * @throws {TypeError} The column's prefix and format are unknown, or given twice.
64
+ */
65
+ export function createdBefore(column, instant, range) {
66
+ return lt(column, boundsFor(column, range).lower(instant));
67
+ }
68
+ /**
69
+ * The bound values to compare `column` with, in the form the column's own mapping expects: the
70
+ * text for a string column, an `IdoraId` for a parsed one. The comparison operators pass each one
71
+ * through the column's mapping, exactly as they would a value you wrote yourself — hence the casts,
72
+ * since the operators' types cannot know which form this column takes.
73
+ */
74
+ function boundsFor(column, range) {
75
+ const info = recall(column);
76
+ if (info !== undefined) {
77
+ if (range !== undefined) {
78
+ throw new TypeError(`The column '${column.name}' was declared with idora.js-drizzle and already knows its prefix and format; leave out the range.`);
79
+ }
80
+ const { prefix, format } = info;
81
+ return info.mode === 'parsed'
82
+ ? {
83
+ lower: (time) => IdoraId.lowerBound(prefix, time, format),
84
+ upper: (time) => IdoraId.upperBound(prefix, time, format),
85
+ }
86
+ : {
87
+ lower: (time) => IdoraId.lowerBound(prefix, time, format).text,
88
+ upper: (time) => IdoraId.upperBound(prefix, time, format).text,
89
+ };
90
+ }
91
+ if (range === undefined) {
92
+ throw new TypeError(`The column '${column.name}' was not declared with idoraId or idoraPrimaryKey from idora.js-drizzle, so its prefix and format are unknown. Declare it with one of them, or say what it holds, as in createdBetween(table.${column.name}, from, to, { prefix: 'usr', format: 'ulid' }).`);
93
+ }
94
+ const { prefix, format = 'ulid' } = range;
95
+ return {
96
+ lower: (time) => IdoraId.lowerBound(prefix, time, format).text,
97
+ upper: (time) => IdoraId.upperBound(prefix, time, format).text,
98
+ };
99
+ }
100
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,GAAG,EAAe,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAY,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAE,OAAO,EAAmB,MAAM,UAAU,CAAC;AAEpD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAetC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,UAAU,cAAc,CAAC,MAAc,EAAE,IAAmB,EAAE,EAAiB,EAAE,KAAe;IACpG,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACxC,yFAAyF;IACzF,OAAO,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAE,CAAC;AAC9E,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,MAAc,EAAE,OAAsB,EAAE,KA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CAAC;IACR,CAAC;IAED,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,SAAS,CACjB,eAAe,MAAM,CAAC,IAAI,iMAAiM,MAAM,CAAC,IAAI,iDAAiD,CACxR,CAAC;IACJ,CAAC;IAED,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,KAAK,CAAC;IAC1C,OAAO;QACL,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,IAAa;QACvE,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,IAAa;KACxE,CAAC;AACJ,CAAC"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Idora identifier columns for MySQL and MariaDB tables (`drizzle-orm/mysql-core`).
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ import type { HasDefault, IsPrimaryKey, NotNull } from 'drizzle-orm';
7
+ import { type ConvertCustomConfig, type MySqlCustomColumnBuilder, type MySqlVarCharBuilderInitial } from 'drizzle-orm/mysql-core';
8
+ import type { EntityType, Idora, IdoraId } from 'idora.js';
9
+ import { type IdoraColumnOptions } from './columns.js';
10
+ export type { IdoraColumnMode, IdoraColumnOptions } from './columns.js';
11
+ /** An identifier column whose values are strings. */
12
+ export type MySqlIdoraIdColumn<TName extends string = ''> = MySqlVarCharBuilderInitial<TName, [string, ...string[]], number>;
13
+ /** An identifier column whose values are parsed `IdoraId` objects. */
14
+ export type MySqlParsedIdoraIdColumn<TName extends string = ''> = MySqlCustomColumnBuilder<ConvertCustomConfig<TName, {
15
+ data: IdoraId;
16
+ driverData: string;
17
+ }>>;
18
+ /**
19
+ * A column holding identifiers for `entityType` — a foreign key, typically:
20
+ *
21
+ * ```ts
22
+ * import { idoraId, idoraPrimaryKey } from 'idora.js-drizzle/mysql';
23
+ *
24
+ * export const orders = mysqlTable('orders', {
25
+ * id: idoraPrimaryKey(ids, Order),
26
+ * userId: idoraId(ids, User).notNull().references(() => users.id),
27
+ * });
28
+ * ```
29
+ *
30
+ * The column is a `varchar` exactly as long as the entity's identifiers — `varchar(30)` for a
31
+ * three-letter prefix and ULIDs — which both documents the format and lets the database refuse a
32
+ * value that cannot be one. It has no default: use {@link idoraPrimaryKey} for the column that
33
+ * mints them.
34
+ *
35
+ * MySQL's default collations ignore case, so the column treats `usr_…` and `USR_…` as equal. That
36
+ * costs nothing here: Idora refuses to register two prefixes that differ only in case, and values
37
+ * are always lowercase.
38
+ *
39
+ * @param ids The generator `entityType` is registered with. Its strategy decides the length.
40
+ * @throws {EntityPrefixNotRegisteredError} `entityType` is not registered with `ids`.
41
+ * @throws {TypeError} `ids` is not an `Idora` generator, or `mode` is not a mode.
42
+ */
43
+ export declare function idoraId<TName extends string = ''>(ids: Idora, entityType: EntityType, options?: IdoraColumnOptions<'string', TName>): MySqlIdoraIdColumn<TName>;
44
+ export declare function idoraId<TName extends string = ''>(ids: Idora, entityType: EntityType, options: IdoraColumnOptions<'parsed', TName>): MySqlParsedIdoraIdColumn<TName>;
45
+ /**
46
+ * The primary key column for `entityType`, filled with a fresh identifier on every insert that does
47
+ * not supply one:
48
+ *
49
+ * ```ts
50
+ * export const users = mysqlTable('users', {
51
+ * id: idoraPrimaryKey(ids, User),
52
+ * email: varchar({ length: 320 }).notNull(),
53
+ * });
54
+ *
55
+ * await db.insert(users).values({ email }); // id: 'usr_01k2f9v8ta7m3x0qbrn4dzeh5c'
56
+ * ```
57
+ *
58
+ * The identifier is generated in your process by `ids.generate(entityType)`, through Drizzle's
59
+ * `$defaultFn`, so it needs no database extension and no round trip, and drizzle-kit migrations
60
+ * show no default. Because identifiers are time-ordered, inserts land at the end of the primary
61
+ * key's index rather than scattering through it.
62
+ *
63
+ * @param ids The generator `entityType` is registered with.
64
+ * @throws {EntityPrefixNotRegisteredError} `entityType` is not registered with `ids`.
65
+ * @throws {TypeError} `ids` is not an `Idora` generator, or `mode` is not a mode.
66
+ */
67
+ export declare function idoraPrimaryKey<TName extends string = ''>(ids: Idora, entityType: EntityType, options?: IdoraColumnOptions<'string', TName>): HasDefault<IsPrimaryKey<NotNull<MySqlIdoraIdColumn<TName>>>>;
68
+ export declare function idoraPrimaryKey<TName extends string = ''>(ids: Idora, entityType: EntityType, options: IdoraColumnOptions<'parsed', TName>): HasDefault<IsPrimaryKey<NotNull<MySqlParsedIdoraIdColumn<TName>>>>;
69
+ //# sourceMappingURL=mysql.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mysql.d.ts","sourceRoot":"","sources":["../src/mysql.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EACL,KAAK,mBAAmB,EAExB,KAAK,wBAAwB,EAC7B,KAAK,0BAA0B,EAEhC,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAE3D,OAAO,EAAgC,KAAK,kBAAkB,EAAuC,MAAM,cAAc,CAAC;AAE1H,YAAY,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAExE,qDAAqD;AACrD,MAAM,MAAM,kBAAkB,CAAC,KAAK,SAAS,MAAM,GAAG,EAAE,IAAI,0BAA0B,CAAC,KAAK,EAAE,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;AAE7H,sEAAsE;AACtE,MAAM,MAAM,wBAAwB,CAAC,KAAK,SAAS,MAAM,GAAG,EAAE,IAAI,wBAAwB,CACxF,mBAAmB,CAAC,KAAK,EAAE;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,CAClE,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,OAAO,CAAC,KAAK,SAAS,MAAM,GAAG,EAAE,EAC/C,GAAG,EAAE,KAAK,EACV,UAAU,EAAE,UAAU,EACtB,OAAO,CAAC,EAAE,kBAAkB,CAAC,QAAQ,EAAE,KAAK,CAAC,GAC5C,kBAAkB,CAAC,KAAK,CAAC,CAAC;AAC7B,wBAAgB,OAAO,CAAC,KAAK,SAAS,MAAM,GAAG,EAAE,EAC/C,GAAG,EAAE,KAAK,EACV,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,kBAAkB,CAAC,QAAQ,EAAE,KAAK,CAAC,GAC3C,wBAAwB,CAAC,KAAK,CAAC,CAAC;AAYnC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,eAAe,CAAC,KAAK,SAAS,MAAM,GAAG,EAAE,EACvD,GAAG,EAAE,KAAK,EACV,UAAU,EAAE,UAAU,EACtB,OAAO,CAAC,EAAE,kBAAkB,CAAC,QAAQ,EAAE,KAAK,CAAC,GAC5C,UAAU,CAAC,YAAY,CAAC,OAAO,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AAChE,wBAAgB,eAAe,CAAC,KAAK,SAAS,MAAM,GAAG,EAAE,EACvD,GAAG,EAAE,KAAK,EACV,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,kBAAkB,CAAC,QAAQ,EAAE,KAAK,CAAC,GAC3C,UAAU,CAAC,YAAY,CAAC,OAAO,CAAC,wBAAwB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC"}
package/dist/mysql.js ADDED
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Idora identifier columns for MySQL and MariaDB tables (`drizzle-orm/mysql-core`).
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ import { customType, varchar, } from 'drizzle-orm/mysql-core';
7
+ import { describeColumn, generatorFor, parsedConversions, recall, remember } from './columns.js';
8
+ export function idoraId(ids, entityType, options = {}) {
9
+ const info = describeColumn(ids, entityType, options);
10
+ const name = options.name ?? '';
11
+ const builder = info.mode === 'parsed'
12
+ ? customType({ dataType: () => `varchar(${info.length})`, ...parsedConversions(info) })(name)
13
+ : varchar(name, { length: info.length });
14
+ return remember(builder, info);
15
+ }
16
+ export function idoraPrimaryKey(ids, entityType, options = {}) {
17
+ const column = idoraId(ids, entityType, options);
18
+ return column.primaryKey().$defaultFn(generatorFor(recall(column)));
19
+ }
20
+ //# sourceMappingURL=mysql.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mysql.js","sourceRoot":"","sources":["../src/mysql.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAEL,UAAU,EAGV,OAAO,GACR,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAE,cAAc,EAAE,YAAY,EAA2B,iBAAiB,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AA+C1H,MAAM,UAAU,OAAO,CAAC,GAAU,EAAE,UAAsB,EAAE,OAAO,GAAuB,EAAE;IAC1F,MAAM,IAAI,GAAG,cAAc,CAAC,GAAG,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;IACtD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC;IAChC,MAAM,OAAO,GACX,IAAI,CAAC,IAAI,KAAK,QAAQ;QACpB,CAAC,CAAC,UAAU,CAAwC,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,WAAW,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,iBAAiB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC;QACpI,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IAE7C,OAAO,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AACjC,CAAC;AAkCD,MAAM,UAAU,eAAe,CAAC,GAAU,EAAE,UAAsB,EAAE,OAAO,GAAuB,EAAE;IAClG,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,UAAU,EAAE,OAAuC,CAAC,CAAC;IACjF,OAAO,MAAM,CAAC,UAAU,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,CAAE,CAAiB,CAAC,CAAC;AACvF,CAAC"}
package/dist/pg.d.ts ADDED
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Idora identifier columns for PostgreSQL tables (`drizzle-orm/pg-core`).
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ import type { HasDefault, IsPrimaryKey, NotNull } from 'drizzle-orm';
7
+ import { type ConvertCustomConfig, type PgCustomColumnBuilder, type PgVarcharBuilderInitial } from 'drizzle-orm/pg-core';
8
+ import type { EntityType, Idora, IdoraId } from 'idora.js';
9
+ import { type IdoraColumnOptions } from './columns.js';
10
+ export type { IdoraColumnMode, IdoraColumnOptions } from './columns.js';
11
+ /** An identifier column whose values are strings. */
12
+ export type PgIdoraIdColumn<TName extends string = ''> = PgVarcharBuilderInitial<TName, [string, ...string[]], number>;
13
+ /** An identifier column whose values are parsed `IdoraId` objects. */
14
+ export type PgParsedIdoraIdColumn<TName extends string = ''> = PgCustomColumnBuilder<ConvertCustomConfig<TName, {
15
+ data: IdoraId;
16
+ driverData: string;
17
+ }>>;
18
+ /**
19
+ * A column holding identifiers for `entityType` — a foreign key, typically:
20
+ *
21
+ * ```ts
22
+ * import { idoraId, idoraPrimaryKey } from 'idora.js-drizzle/pg';
23
+ *
24
+ * export const orders = pgTable('orders', {
25
+ * id: idoraPrimaryKey(ids, Order),
26
+ * userId: idoraId(ids, User).notNull().references(() => users.id),
27
+ * });
28
+ * ```
29
+ *
30
+ * The column is a `varchar` exactly as long as the entity's identifiers — `varchar(30)` for a
31
+ * three-letter prefix and ULIDs — which both documents the format and lets the database refuse a
32
+ * value that cannot be one. It has no default: use {@link idoraPrimaryKey} for the column that
33
+ * mints them.
34
+ *
35
+ * @param ids The generator `entityType` is registered with. Its strategy decides the length.
36
+ * @throws {EntityPrefixNotRegisteredError} `entityType` is not registered with `ids`.
37
+ * @throws {TypeError} `ids` is not an `Idora` generator, or `mode` is not a mode.
38
+ */
39
+ export declare function idoraId<TName extends string = ''>(ids: Idora, entityType: EntityType, options?: IdoraColumnOptions<'string', TName>): PgIdoraIdColumn<TName>;
40
+ export declare function idoraId<TName extends string = ''>(ids: Idora, entityType: EntityType, options: IdoraColumnOptions<'parsed', TName>): PgParsedIdoraIdColumn<TName>;
41
+ /**
42
+ * The primary key column for `entityType`, filled with a fresh identifier on every insert that does
43
+ * not supply one:
44
+ *
45
+ * ```ts
46
+ * export const users = pgTable('users', {
47
+ * id: idoraPrimaryKey(ids, User),
48
+ * email: text().notNull(),
49
+ * });
50
+ *
51
+ * const [user] = await db.insert(users).values({ email }).returning();
52
+ * user.id; // 'usr_01k2f9v8ta7m3x0qbrn4dzeh5c'
53
+ * ```
54
+ *
55
+ * The identifier is generated in your process by `ids.generate(entityType)`, through Drizzle's
56
+ * `$defaultFn`, so it needs no database extension and no round trip, and drizzle-kit migrations
57
+ * show no default. Because identifiers are time-ordered, inserts land at the end of the primary
58
+ * key's index rather than scattering through it.
59
+ *
60
+ * @param ids The generator `entityType` is registered with.
61
+ * @throws {EntityPrefixNotRegisteredError} `entityType` is not registered with `ids`.
62
+ * @throws {TypeError} `ids` is not an `Idora` generator, or `mode` is not a mode.
63
+ */
64
+ export declare function idoraPrimaryKey<TName extends string = ''>(ids: Idora, entityType: EntityType, options?: IdoraColumnOptions<'string', TName>): HasDefault<IsPrimaryKey<NotNull<PgIdoraIdColumn<TName>>>>;
65
+ export declare function idoraPrimaryKey<TName extends string = ''>(ids: Idora, entityType: EntityType, options: IdoraColumnOptions<'parsed', TName>): HasDefault<IsPrimaryKey<NotNull<PgParsedIdoraIdColumn<TName>>>>;
66
+ //# sourceMappingURL=pg.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":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AK,CAAC,GAC3C,qBAAqB,CAAC,KAAK,CAAC,CAAC;AAYhC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,eAAe,CAAC,KAAK,SAAS,MAAM,GAAG,EAAE,EACvD,GAAG,EAAE,KAAK,EACV,UAAU,EAAE,UAAU,EACtB,OAAO,CAAC,EAAE,kBAAkB,CAAC,QAAQ,EAAE,KAAK,CAAC,GAC5C,UAAU,CAAC,YAAY,CAAC,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7D,wBAAgB,eAAe,CAAC,KAAK,SAAS,MAAM,GAAG,EAAE,EACvD,GAAG,EAAE,KAAK,EACV,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,kBAAkB,CAAC,QAAQ,EAAE,KAAK,CAAC,GAC3C,UAAU,CAAC,YAAY,CAAC,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC"}
package/dist/pg.js ADDED
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Idora identifier columns for PostgreSQL tables (`drizzle-orm/pg-core`).
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ import { customType, varchar } from 'drizzle-orm/pg-core';
7
+ import { describeColumn, generatorFor, parsedConversions, recall, remember } from './columns.js';
8
+ export function idoraId(ids, entityType, options = {}) {
9
+ const info = describeColumn(ids, entityType, options);
10
+ const name = options.name ?? '';
11
+ const builder = info.mode === 'parsed'
12
+ ? customType({ dataType: () => `varchar(${info.length})`, ...parsedConversions(info) })(name)
13
+ : varchar(name, { length: info.length });
14
+ return remember(builder, info);
15
+ }
16
+ export function idoraPrimaryKey(ids, entityType, options = {}) {
17
+ const column = idoraId(ids, entityType, options);
18
+ return column.primaryKey().$defaultFn(generatorFor(recall(column)));
19
+ }
20
+ //# sourceMappingURL=pg.js.map
package/dist/pg.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pg.js","sourceRoot":"","sources":["../src/pg.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
+ import type { HasDefault, IsPrimaryKey, NotNull } from 'drizzle-orm';
8
+ import { type ConvertCustomConfig, type SQLiteCustomColumnBuilder, type SQLiteTextBuilderInitial } from 'drizzle-orm/sqlite-core';
9
+ import type { EntityType, Idora, IdoraId } from 'idora.js';
10
+ import { type IdoraColumnOptions } from './columns.js';
11
+ export type { IdoraColumnMode, IdoraColumnOptions } from './columns.js';
12
+ /** An identifier column whose values are strings. */
13
+ export type SQLiteIdoraIdColumn<TName extends string = ''> = SQLiteTextBuilderInitial<TName, [string, ...string[]], number | undefined>;
14
+ /** An identifier column whose values are parsed `IdoraId` objects. */
15
+ export type SQLiteParsedIdoraIdColumn<TName extends string = ''> = SQLiteCustomColumnBuilder<ConvertCustomConfig<TName, {
16
+ data: IdoraId;
17
+ driverData: string;
18
+ }>>;
19
+ /**
20
+ * A column holding identifiers for `entityType` — a foreign key, typically:
21
+ *
22
+ * ```ts
23
+ * import { idoraId, idoraPrimaryKey } from 'idora.js-drizzle/sqlite';
24
+ *
25
+ * export const orders = sqliteTable('orders', {
26
+ * id: idoraPrimaryKey(ids, Order),
27
+ * userId: idoraId(ids, User).notNull().references(() => users.id),
28
+ * });
29
+ * ```
30
+ *
31
+ * The column is `text`: SQLite does not enforce lengths, so declaring one would only mislead. It
32
+ * has no default: use {@link idoraPrimaryKey} for the column that mints them.
33
+ *
34
+ * @param ids The generator `entityType` is registered with.
35
+ * @throws {EntityPrefixNotRegisteredError} `entityType` is not registered with `ids`.
36
+ * @throws {TypeError} `ids` is not an `Idora` generator, or `mode` is not a mode.
37
+ */
38
+ export declare function idoraId<TName extends string = ''>(ids: Idora, entityType: EntityType, options?: IdoraColumnOptions<'string', TName>): SQLiteIdoraIdColumn<TName>;
39
+ export declare function idoraId<TName extends string = ''>(ids: Idora, entityType: EntityType, options: IdoraColumnOptions<'parsed', TName>): SQLiteParsedIdoraIdColumn<TName>;
40
+ /**
41
+ * The primary key column for `entityType`, filled with a fresh identifier on every insert that does
42
+ * not supply one:
43
+ *
44
+ * ```ts
45
+ * export const users = sqliteTable('users', {
46
+ * id: idoraPrimaryKey(ids, User),
47
+ * email: text().notNull(),
48
+ * });
49
+ *
50
+ * const [user] = await db.insert(users).values({ email }).returning();
51
+ * user.id; // 'usr_01k2f9v8ta7m3x0qbrn4dzeh5c'
52
+ * ```
53
+ *
54
+ * The identifier is generated in your process by `ids.generate(entityType)`, through Drizzle's
55
+ * `$defaultFn`, so it needs no database extension and no round trip, and drizzle-kit migrations
56
+ * show no default. Because identifiers are time-ordered, inserts land at the end of the primary
57
+ * key's index rather than scattering through it.
58
+ *
59
+ * @param ids The generator `entityType` is registered with.
60
+ * @throws {EntityPrefixNotRegisteredError} `entityType` is not registered with `ids`.
61
+ * @throws {TypeError} `ids` is not an `Idora` generator, or `mode` is not a mode.
62
+ */
63
+ export declare function idoraPrimaryKey<TName extends string = ''>(ids: Idora, entityType: EntityType, options?: IdoraColumnOptions<'string', TName>): HasDefault<IsPrimaryKey<NotNull<SQLiteIdoraIdColumn<TName>>>>;
64
+ export declare function idoraPrimaryKey<TName extends string = ''>(ids: Idora, entityType: EntityType, options: IdoraColumnOptions<'parsed', TName>): HasDefault<IsPrimaryKey<NotNull<SQLiteParsedIdoraIdColumn<TName>>>>;
65
+ //# sourceMappingURL=sqlite.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sqlite.d.ts","sourceRoot":"","sources":["../src/sqlite.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EACL,KAAK,mBAAmB,EAExB,KAAK,yBAAyB,EAC9B,KAAK,wBAAwB,EAE9B,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAE3D,OAAO,EAAgC,KAAK,kBAAkB,EAAuC,MAAM,cAAc,CAAC;AAE1H,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AS,MAAM,GAAG,EAAE,EACvD,GAAG,EAAE,KAAK,EACV,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,kBAAkB,CAAC,QAAQ,EAAE,KAAK,CAAC,GAC3C,UAAU,CAAC,YAAY,CAAC,OAAO,CAAC,yBAAyB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC"}
package/dist/sqlite.js ADDED
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Idora identifier columns for SQLite tables (`drizzle-orm/sqlite-core`), including libSQL, Turso,
3
+ * Cloudflare D1 and Bun's SQLite.
4
+ *
5
+ * @packageDocumentation
6
+ */
7
+ import { customType, text, } from 'drizzle-orm/sqlite-core';
8
+ import { describeColumn, generatorFor, parsedConversions, recall, remember } from './columns.js';
9
+ export function idoraId(ids, entityType, options = {}) {
10
+ const info = describeColumn(ids, entityType, options);
11
+ const name = options.name ?? '';
12
+ const builder = info.mode === 'parsed'
13
+ ? customType({ dataType: () => 'text', ...parsedConversions(info) })(name)
14
+ : text(name);
15
+ return remember(builder, info);
16
+ }
17
+ export function idoraPrimaryKey(ids, entityType, options = {}) {
18
+ const column = idoraId(ids, entityType, options);
19
+ return column.primaryKey().$defaultFn(generatorFor(recall(column)));
20
+ }
21
+ //# sourceMappingURL=sqlite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sqlite.js","sourceRoot":"","sources":["../src/sqlite.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAEL,UAAU,EAGV,IAAI,GACL,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,cAAc,EAAE,YAAY,EAA2B,iBAAiB,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAyC1H,MAAM,UAAU,OAAO,CAAC,GAAU,EAAE,UAAsB,EAAE,OAAO,GAAuB,EAAE;IAC1F,MAAM,IAAI,GAAG,cAAc,CAAC,GAAG,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;IACtD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC;IAChC,MAAM,OAAO,GACX,IAAI,CAAC,IAAI,KAAK,QAAQ;QACpB,CAAC,CAAC,UAAU,CAAwC,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,GAAG,iBAAiB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC;QACjH,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEjB,OAAO,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AACjC,CAAC;AAmCD,MAAM,UAAU,eAAe,CAAC,GAAU,EAAE,UAAsB,EAAE,OAAO,GAAuB,EAAE;IAClG,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,UAAU,EAAE,OAAuC,CAAC,CAAC;IACjF,OAAO,MAAM,CAAC,UAAU,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,CAAE,CAAiB,CAAC,CAAC;AACvF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,76 @@
1
1
  {
2
2
  "name": "idora.js-drizzle",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.1.0",
4
+ "description": "Drizzle ORM columns for Idora identifiers such as usr_01k2f9v8ta7m3x0qbrn4dzeh5c: primary keys that fill themselves in, correctly sized columns for PostgreSQL, MySQL and SQLite, and created-between filters that use the index.",
5
+ "keywords": [
6
+ "idora",
7
+ "drizzle",
8
+ "drizzle-orm",
9
+ "id",
10
+ "identifier",
11
+ "ulid",
12
+ "uuidv7",
13
+ "prefixed-id",
14
+ "primary-key",
15
+ "postgres",
16
+ "mysql",
17
+ "sqlite"
18
+ ],
19
+ "homepage": "https://github.com/SrKleRAimBot/Idora/tree/main/Idora.JS/extensions/drizzle#readme",
20
+ "bugs": "https://github.com/SrKleRAimBot/Idora/issues",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/SrKleRAimBot/Idora.git",
24
+ "directory": "Idora.JS/extensions/drizzle"
25
+ },
26
+ "license": "MIT",
27
+ "author": "Jake Seracino",
28
+ "type": "module",
29
+ "sideEffects": false,
30
+ "exports": {
31
+ ".": {
32
+ "types": "./dist/index.d.ts",
33
+ "default": "./dist/index.js"
34
+ },
35
+ "./pg": {
36
+ "types": "./dist/pg.d.ts",
37
+ "default": "./dist/pg.js"
38
+ },
39
+ "./mysql": {
40
+ "types": "./dist/mysql.d.ts",
41
+ "default": "./dist/mysql.js"
42
+ },
43
+ "./sqlite": {
44
+ "types": "./dist/sqlite.d.ts",
45
+ "default": "./dist/sqlite.js"
46
+ },
47
+ "./package.json": "./package.json"
48
+ },
49
+ "main": "./dist/index.js",
50
+ "types": "./dist/index.d.ts",
51
+ "files": [
52
+ "dist",
53
+ "!dist/**/*.tsbuildinfo"
54
+ ],
55
+ "engines": {
56
+ "node": ">=20"
57
+ },
58
+ "scripts": {
59
+ "build": "tsc -p tsconfig.json",
60
+ "build:test": "tsc -p tsconfig.test.json",
61
+ "typecheck": "tsc -p tsconfig.test.json --noEmit",
62
+ "test": "npm run build:test && node --test build/test/*.test.js",
63
+ "prepack": "npm run build"
64
+ },
65
+ "peerDependencies": {
66
+ "drizzle-orm": ">=0.44.0 <1.0.0",
67
+ "idora.js": "^1.1.0"
68
+ },
69
+ "devDependencies": {
70
+ "@electric-sql/pglite": "0.6.0",
71
+ "@types/node": "22.20.5",
72
+ "drizzle-orm": "0.45.4",
73
+ "idora.js": "file:../..",
74
+ "typescript": "7.0.2"
75
+ }
76
+ }