symmetria 1.1.0 → 2.2.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/README.md +60 -19
- package/dist/better-auth.d.ts +45 -0
- package/dist/better-auth.js +186 -0
- package/dist/better-auth.js.map +1 -0
- package/dist/binding-BiJH76XX.js +245 -0
- package/dist/binding-BiJH76XX.js.map +1 -0
- package/dist/bun.d.ts +2 -3
- package/dist/bun.js +11 -2
- package/dist/bun.js.map +1 -1
- package/dist/cohere.d.ts +19 -0
- package/dist/cohere.js +35 -0
- package/dist/cohere.js.map +1 -0
- package/dist/{compile-B3TD9LbS.js → compile-CLksO6-D.js} +320 -261
- package/dist/compile-CLksO6-D.js.map +1 -0
- package/dist/core-Bu8-BTNf.js +1169 -0
- package/dist/core-Bu8-BTNf.js.map +1 -0
- package/dist/driver.d.ts +3 -3
- package/dist/driver.js +2 -2
- package/dist/google.d.ts +16 -0
- package/dist/google.js +29 -0
- package/dist/google.js.map +1 -0
- package/dist/http-o1fpnTNy.js +33 -0
- package/dist/http-o1fpnTNy.js.map +1 -0
- package/dist/index.d.ts +2 -4
- package/dist/index.js +1759 -467
- package/dist/index.js.map +1 -1
- package/dist/{inspection-DZf70oHB.js → inspection-CYlzNdVg.js} +3 -4
- package/dist/{inspection-DZf70oHB.js.map → inspection-CYlzNdVg.js.map} +1 -1
- package/dist/internal.d.ts +6 -2
- package/dist/internal.js +4 -4
- package/dist/jina.d.ts +16 -0
- package/dist/jina.js +20 -0
- package/dist/jina.js.map +1 -0
- package/dist/mistral.d.ts +16 -0
- package/dist/mistral.js +18 -0
- package/dist/mistral.js.map +1 -0
- package/dist/ollama.d.ts +13 -0
- package/dist/ollama.js +30 -0
- package/dist/ollama.js.map +1 -0
- package/dist/openai.d.ts +19 -0
- package/dist/openai.js +31 -0
- package/dist/openai.js.map +1 -0
- package/dist/pg-B7bJIFw0.d.ts +53 -0
- package/dist/{pg-D4y92gPt.js → pg-Cx2W_Lmd.js} +29 -12
- package/dist/pg-Cx2W_Lmd.js.map +1 -0
- package/dist/pg.d.ts +3 -3
- package/dist/pg.js +2 -2
- package/dist/pool-CFas0E3j.js +354 -0
- package/dist/pool-CFas0E3j.js.map +1 -0
- package/dist/{pool-C9sl2iHw.d.ts → pool-x45tVc5q.d.ts} +5 -2
- package/dist/search-CwBcdihW.js +157 -0
- package/dist/search-CwBcdihW.js.map +1 -0
- package/dist/search.d.ts +2 -0
- package/dist/search.js +1 -0
- package/dist/{assembly-C4GbrzmO.js → table-Lbap-R_E.js} +769 -1429
- package/dist/table-Lbap-R_E.js.map +1 -0
- package/dist/types-DPWc6nQ9.js +389 -0
- package/dist/types-DPWc6nQ9.js.map +1 -0
- package/dist/{types-BB8ndsIR.d.ts → types-Dki1Ej7A.d.ts} +1889 -744
- package/dist/{values-BhrNtVaY.js → values-C7U6IIQZ.js} +2 -3
- package/dist/values-C7U6IIQZ.js.map +1 -0
- package/dist/vector.d.ts +1 -1
- package/dist/vector.js +1 -1
- package/dist/voyage.d.ts +22 -0
- package/dist/voyage.js +26 -0
- package/dist/voyage.js.map +1 -0
- package/package.json +45 -1
- package/dist/assembly-C4GbrzmO.js.map +0 -1
- package/dist/binding-CD-0xNaB.js +0 -12
- package/dist/binding-CD-0xNaB.js.map +0 -1
- package/dist/compile-B3TD9LbS.js.map +0 -1
- package/dist/index-wLTEGtyg.d.ts +0 -29
- package/dist/pg-D4y92gPt.js.map +0 -1
- package/dist/pg-DS7w6m9g.d.ts +0 -12
- package/dist/pool-OKiwLiBZ.js +0 -240
- package/dist/pool-OKiwLiBZ.js.map +0 -1
- package/dist/profiling-CrinWe63.d.ts +0 -56
- package/dist/types-BavtzvoV.js +0 -35
- package/dist/types-BavtzvoV.js.map +0 -1
- package/dist/values-BhrNtVaY.js.map +0 -1
package/README.md
CHANGED
|
@@ -56,6 +56,8 @@ package versions.
|
|
|
56
56
|
import {
|
|
57
57
|
schema,
|
|
58
58
|
table,
|
|
59
|
+
one,
|
|
60
|
+
many,
|
|
59
61
|
int,
|
|
60
62
|
text,
|
|
61
63
|
bigint,
|
|
@@ -67,12 +69,13 @@ const users = table({
|
|
|
67
69
|
id: int.auto,
|
|
68
70
|
name: text,
|
|
69
71
|
email: text.unique,
|
|
72
|
+
posts: many,
|
|
70
73
|
});
|
|
71
74
|
|
|
72
75
|
const posts = table({
|
|
73
76
|
id: int.auto,
|
|
74
77
|
title: text,
|
|
75
|
-
author: users.
|
|
78
|
+
author: one(users.posts),
|
|
76
79
|
views: bigint.default(0n),
|
|
77
80
|
state: oneOf("draft", "published").default("draft"),
|
|
78
81
|
createdAt: timestamptz.now,
|
|
@@ -81,9 +84,12 @@ const posts = table({
|
|
|
81
84
|
export const appSchema = schema({ users, posts });
|
|
82
85
|
```
|
|
83
86
|
|
|
84
|
-
Each table can live in its own module. `author: users.
|
|
85
|
-
key, its index and the `posts.author`
|
|
86
|
-
|
|
87
|
+
Each table can live in its own module. `author: one(users.posts)` declares a
|
|
88
|
+
foreign key, its index and the `posts.author` relationship, and claims the slot
|
|
89
|
+
`posts: many` that `users` declares for the other side; `maybe()` is the
|
|
90
|
+
optional form, `many(tags.posts)` a many-to-many relation with its junction
|
|
91
|
+
table. `author: users.index` is the earlier spelling of the same key. Columns
|
|
92
|
+
are non-null by default. Property names map from camelCase to snake_case.
|
|
87
93
|
`users.by("email")` references a unique column instead of the primary key and
|
|
88
94
|
`users.column("created_by")` keeps a legacy column name. Tables that relate
|
|
89
95
|
through plain columns declare the join predicate instead:
|
|
@@ -224,9 +230,10 @@ const totals = database.users(({ name, posts }) => ({
|
|
|
224
230
|
Plain columns aggregate through properties (`posts.sum.views`); expressions use
|
|
225
231
|
the callback form. Filters and pagination select input rows before aggregation.
|
|
226
232
|
`sum` / `average` return decimal strings or `null`; `minimum` / `maximum`
|
|
227
|
-
preserve the column's value type and codec, plus `null
|
|
228
|
-
|
|
229
|
-
|
|
233
|
+
preserve the column's value type and codec, plus `null`, and order JSON values
|
|
234
|
+
as jsonb does (numbers numerically), booleans, `uuid` and `bytea` too. Empty or
|
|
235
|
+
all-NULL value inputs produce `null`; `count()` returns `0` and `exists()`
|
|
236
|
+
returns `false` for empty inputs.
|
|
230
237
|
|
|
231
238
|
## Enum mappings
|
|
232
239
|
|
|
@@ -274,6 +281,14 @@ UPDATE or DELETE without `where()` is refused unless `.all()` confirms it.
|
|
|
274
281
|
|
|
275
282
|
## Capabilities
|
|
276
283
|
|
|
284
|
+
- Relations declared on both sides (`posts: many`, `author: one(users.posts)`,
|
|
285
|
+
`tags: many(tags.posts)`), checked by the types and when the schema is built.
|
|
286
|
+
- `$batch()`: several reads as one statement, with one snapshot of the data.
|
|
287
|
+
- `get(id)` / `find(id)`, whole-row reads
|
|
288
|
+
(`users({ where: { active: true } })`), object filters and ordering,
|
|
289
|
+
`aggregate()`, `upsert()`, and write filters as options.
|
|
290
|
+
- Error classes for `instanceof`: `NotFoundError`, `UniqueViolation`,
|
|
291
|
+
`ForeignKeyViolation` and the rest, with the constraint, table and column.
|
|
277
292
|
- Shape-first projections, explicit or FK-inferred JOINs, `some`/`none`/`every`.
|
|
278
293
|
- CRUD, bulk writes, upserts, unique-key lookups with direct writes, reusable
|
|
279
294
|
RETURNING projections and atomic nested inserts.
|
|
@@ -283,18 +298,34 @@ UPDATE or DELETE without `where()` is refused unless `.all()` confirms it.
|
|
|
283
298
|
iteration; `count()` and `exists()` on any table or filtered source.
|
|
284
299
|
- Transactions, nested savepoints, isolation options and row locks.
|
|
285
300
|
- `Transaction<typeof database>` for schema-specific transaction helpers.
|
|
286
|
-
- `$scope()` filters for reads, updates and deletes, including related tables
|
|
301
|
+
- `$scope()` filters for reads, updates and deletes, including related tables,
|
|
302
|
+
and checks every row a scoped insert, upsert or update writes, like row-level
|
|
303
|
+
security's `WITH CHECK` (`SYMMETRIA_OUT_OF_SCOPE`); reused and prepared
|
|
304
|
+
queries bind the current tenant at every execution.
|
|
287
305
|
- Bigint, decimal-string, Date and custom codecs, including nested JSON results;
|
|
288
306
|
`smallint`, `real`, `doublePrecision`, `date`, `time`, `interval`, `bytea` and
|
|
289
307
|
`inet` as first-class builders.
|
|
290
308
|
- Conditional upserts: `doUpdate(values, { where: (current, incoming) => … })`.
|
|
291
309
|
- Any SQL names: `casing: "preserve"` for camelCase databases such as Prisma's,
|
|
292
310
|
`.named()` on tables and columns, `.onUpdate.cascade` foreign keys and
|
|
293
|
-
`timestamp(3)` columns read as UTC dates
|
|
294
|
-
|
|
295
|
-
|
|
311
|
+
`timestamp(3)` columns read as UTC dates; enum types named and shared with
|
|
312
|
+
`oneOf(...).typeName("Role")`, collations with `text.collate("C")`,
|
|
313
|
+
`int.auto.byDefault` identities that also accept explicit ids, and derived
|
|
314
|
+
names over 63 bytes shortened with a hash.
|
|
315
|
+
- Exact arithmetic typed as PostgreSQL computes it: `quantity.multiply(price)`
|
|
316
|
+
and `quantity.divide(2)` are `Decimal` (division never truncates),
|
|
317
|
+
`quantity.quotient(2)` is integer division, `real` columns stay floats.
|
|
296
318
|
- `databaseError(error)` describes unique, foreign-key, not-null and check
|
|
297
|
-
violations the same way on both drivers; `one()` errors
|
|
319
|
+
violations and lost connections the same way on both drivers; `one()` errors
|
|
320
|
+
carry a code. Invalid values (out-of-range numbers, invalid `jsonb(schema)`
|
|
321
|
+
input, `null` for NOT NULL columns) reject the query's promise when it runs;
|
|
322
|
+
mistakes in the query's shape throw where it is built.
|
|
323
|
+
- `table.search()`: hybrid search declared on the table, by words (full text or
|
|
324
|
+
BM25) and by meaning (embeddings computed on insert), merged in one statement
|
|
325
|
+
(`symmetria/search`; models from `symmetria/voyage`, `openai`, `cohere`,
|
|
326
|
+
`google`, `mistral`, `jina`, `ollama`)
|
|
327
|
+
- `symmetria/better-auth`: a better-auth adapter; `auth generate` writes the
|
|
328
|
+
auth tables as part of your schema
|
|
298
329
|
- Arrays, full-text search with stored `tsvector` columns, weighted documents,
|
|
299
330
|
ranking and headlines, pgvector embeddings with distance operators and HNSW
|
|
300
331
|
indexes (`symmetria/vector`), typed JSON paths and Standard Schema JSON
|
|
@@ -343,16 +374,26 @@ const database = createDatabase({
|
|
|
343
374
|
});
|
|
344
375
|
```
|
|
345
376
|
|
|
346
|
-
`symmetria/driver` re-exports `symmetria/pg`. Install `pg` when using either
|
|
377
|
+
`symmetria/driver` re-exports `symmetria/pg`. Install `pg` when using either
|
|
378
|
+
(Symmetria declares the pool options itself, so `@types/pg` is not needed);
|
|
347
379
|
`symmetria/bun` needs no external database driver. Each accepts a URL or its
|
|
348
380
|
underlying pool options plus `url` and `profiler`.
|
|
349
381
|
|
|
350
|
-
Both adapters return `{ rows, affectedRows }`,
|
|
351
|
-
precision, support nested transactions and pinned
|
|
352
|
-
operations on close.
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
382
|
+
Both adapters return `{ rows, affectedRows }`, read values the same way,
|
|
383
|
+
preserve bigint/numeric precision, support nested transactions and pinned
|
|
384
|
+
sessions, and drain accepted operations on close. Operations on a transaction or
|
|
385
|
+
session run one at a time in call order. Session settings belong to a
|
|
386
|
+
connection: use `driver.session()` for multi-statement workflows; its connection
|
|
387
|
+
is closed afterwards, so its settings, locks and temporary tables never reach
|
|
388
|
+
other queries. For isolated PostgreSQL test schemas, use `testDatabase()` from
|
|
389
|
+
`symmetria-kit/testing`, optionally passing a `driver` factory.
|
|
390
|
+
|
|
391
|
+
Behind a transaction-mode pooler such as PgBouncer, queries, transactions,
|
|
392
|
+
streams and prepared queries work on both adapters; pass `prepare: false` to
|
|
393
|
+
`symmetria/bun` unless the pooler tracks named statements (PgBouncer 1.21+ with
|
|
394
|
+
`max_prepared_statements`), and set `search_path` on the role rather than in the
|
|
395
|
+
URL. `driver.session()` cannot pin a server connection there. See
|
|
396
|
+
[transaction pooling](https://github.com/nokturnal3301/symmetria/blob/main/docs/reference.md#transaction-pooling-pgbouncer).
|
|
356
397
|
|
|
357
398
|
## License
|
|
358
399
|
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { DBAdapterDebugLogOption } from "better-auth/adapters";
|
|
2
|
+
import { BetterAuthOptions } from "better-auth";
|
|
3
|
+
//#region src/entries/better-auth.d.ts
|
|
4
|
+
export type SymmetriaAdapterOptions = {
|
|
5
|
+
/** Tables are keyed in the plural (`users`, `sessions`). */
|
|
6
|
+
readonly usePlural?: boolean;
|
|
7
|
+
readonly debugLogs?: DBAdapterDebugLogOption;
|
|
8
|
+
};
|
|
9
|
+
type Tables = Record<string, {
|
|
10
|
+
modelName: string;
|
|
11
|
+
fields: Record<string, Field>;
|
|
12
|
+
indexes?: readonly {
|
|
13
|
+
fields: readonly string[];
|
|
14
|
+
unique?: boolean | undefined;
|
|
15
|
+
}[];
|
|
16
|
+
}>;
|
|
17
|
+
type Field = {
|
|
18
|
+
type: string | readonly string[];
|
|
19
|
+
required?: boolean | undefined;
|
|
20
|
+
unique?: boolean | undefined;
|
|
21
|
+
index?: boolean | undefined;
|
|
22
|
+
bigint?: boolean | undefined;
|
|
23
|
+
fieldName?: string | undefined;
|
|
24
|
+
defaultValue?: unknown;
|
|
25
|
+
references?: {
|
|
26
|
+
model: string;
|
|
27
|
+
field: string;
|
|
28
|
+
onDelete?: string | undefined;
|
|
29
|
+
} | undefined;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* The auth tables as a Symmetria schema module, for `npx auth generate`.
|
|
33
|
+
* Tables come out in an order where each one follows the tables it
|
|
34
|
+
* references; spread `authTables` into `schema({ ... })`.
|
|
35
|
+
*/
|
|
36
|
+
export declare const authSchemaSource: (tables: Tables) => string;
|
|
37
|
+
/**
|
|
38
|
+
* `betterAuth({ database: symmetriaAdapter(db) })`. `db` is the database (or a
|
|
39
|
+
* `$scope()` of it) whose schema holds the auth tables; better-auth's own
|
|
40
|
+
* transactions run inside `db.$transaction`.
|
|
41
|
+
*/
|
|
42
|
+
export declare const symmetriaAdapter: (db: object, options?: SymmetriaAdapterOptions) => (betterAuthOptions: BetterAuthOptions) => import("better-auth").DBAdapter<BetterAuthOptions>;
|
|
43
|
+
//#endregion
|
|
44
|
+
export {};
|
|
45
|
+
//# sourceMappingURL=better-auth.d.ts.map
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { _ as not, b as or, l as and } from "./core-Bu8-BTNf.js";
|
|
2
|
+
import { createAdapterFactory } from "better-auth/adapters";
|
|
3
|
+
//#region src/entries/better-auth.ts
|
|
4
|
+
const escapeLike = (value) => String(value).replace(/[\\%_]/g, (character) => `\\${character}`);
|
|
5
|
+
const predicate = (row, clause) => {
|
|
6
|
+
const column = row[clause.field];
|
|
7
|
+
if (!column) throw new Error(`symmetria: better-auth asked for field "${clause.field}", which the table does not have`);
|
|
8
|
+
const insensitive = clause.mode === "insensitive" && typeof clause.value === "string";
|
|
9
|
+
const pattern = (text) => insensitive ? column.ilike(text) : column.like(text);
|
|
10
|
+
switch (clause.operator) {
|
|
11
|
+
case "ne": return insensitive ? not(column.ilike(escapeLike(clause.value))) : column.isNot(clause.value);
|
|
12
|
+
case "in": return column.in(clause.value);
|
|
13
|
+
case "not_in": return column.notIn(clause.value);
|
|
14
|
+
case "gt": return column.above(clause.value);
|
|
15
|
+
case "gte": return column.atLeast(clause.value);
|
|
16
|
+
case "lt": return column.below(clause.value);
|
|
17
|
+
case "lte": return column.atMost(clause.value);
|
|
18
|
+
case "contains": return pattern(`%${escapeLike(clause.value)}%`);
|
|
19
|
+
case "starts_with": return pattern(`${escapeLike(clause.value)}%`);
|
|
20
|
+
case "ends_with": return pattern(`%${escapeLike(clause.value)}`);
|
|
21
|
+
default: return insensitive ? column.ilike(escapeLike(clause.value)) : column.is(clause.value);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
/** better-auth's flat clause list: every AND clause, and at least one of the OR clauses. */
|
|
25
|
+
const filter = (where) => (row) => {
|
|
26
|
+
const clauses = where ?? [];
|
|
27
|
+
const all = clauses.filter((clause) => clause.connector !== "OR").map((clause) => predicate(row, clause));
|
|
28
|
+
const any = clauses.filter((clause) => clause.connector === "OR").map((clause) => predicate(row, clause));
|
|
29
|
+
return and(...all, any.length > 0 ? or(...any) : void 0);
|
|
30
|
+
};
|
|
31
|
+
const COLUMN_TYPES = {
|
|
32
|
+
string: "text",
|
|
33
|
+
boolean: "bool",
|
|
34
|
+
date: "timestamptz",
|
|
35
|
+
json: "jsonb",
|
|
36
|
+
"string[]": "text.array",
|
|
37
|
+
"number[]": "int.array"
|
|
38
|
+
};
|
|
39
|
+
const snakeCase = (name) => name.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
40
|
+
/**
|
|
41
|
+
* The auth tables as a Symmetria schema module, for `npx auth generate`.
|
|
42
|
+
* Tables come out in an order where each one follows the tables it
|
|
43
|
+
* references; spread `authTables` into `schema({ ... })`.
|
|
44
|
+
*/
|
|
45
|
+
const authSchemaSource = (tables) => {
|
|
46
|
+
const builders = /* @__PURE__ */ new Set(["table", "text"]);
|
|
47
|
+
const models = Object.values(tables);
|
|
48
|
+
const nameOf = (model) => tables[model]?.modelName ?? models.find((entry) => entry.modelName === model)?.modelName ?? model;
|
|
49
|
+
const ordered = [];
|
|
50
|
+
const pending = [...models];
|
|
51
|
+
while (pending.length) {
|
|
52
|
+
const next = pending.find((entry) => Object.values(entry.fields).every((field) => !field.references || nameOf(field.references.model) === entry.modelName || ordered.some((done) => done.modelName === nameOf(field.references.model)))) ?? pending[0];
|
|
53
|
+
ordered.push(next);
|
|
54
|
+
pending.splice(pending.indexOf(next), 1);
|
|
55
|
+
}
|
|
56
|
+
const declarations = ordered.map((entry) => {
|
|
57
|
+
const targets = Object.values(entry.fields).flatMap((field) => field.references ? [nameOf(field.references.model)] : []);
|
|
58
|
+
const lines = Object.entries(entry.fields).map(([key, field]) => {
|
|
59
|
+
const named = field.fieldName && field.fieldName !== key && field.fieldName !== snakeCase(key) ? `.named(${JSON.stringify(field.fieldName)})` : "";
|
|
60
|
+
const reference = field.references;
|
|
61
|
+
if (reference && reference.field === "id" && key.endsWith("Id")) {
|
|
62
|
+
const target = nameOf(reference.model);
|
|
63
|
+
const action = reference.onDelete === void 0 || reference.onDelete === "cascade" ? "cascade" : reference.onDelete === "set null" ? "setNull" : void 0;
|
|
64
|
+
const relation = key.slice(0, -2);
|
|
65
|
+
const self = target === entry.modelName;
|
|
66
|
+
if (targets.filter((name) => name === target).length > 1 || self) {
|
|
67
|
+
if (self) builders.add("self");
|
|
68
|
+
return ` ${relation}: ${self ? "self" : target}${field.required === false || action === "setNull" ? ".nullable" : ""}${field.unique ? ".unique" : ".index"}${action ? `.onDelete.${action}` : ""}.inverse(${JSON.stringify(`${entry.modelName}By${relation[0].toUpperCase()}${relation.slice(1)}`)}),`;
|
|
69
|
+
}
|
|
70
|
+
const claim = field.required === false || action === "setNull" ? "maybe" : "one";
|
|
71
|
+
builders.add(claim);
|
|
72
|
+
return ` ${relation}: ${claim}(${target})${action ? `.${action}` : ""}${field.unique ? ".unique" : ""},`;
|
|
73
|
+
}
|
|
74
|
+
let type;
|
|
75
|
+
if (Array.isArray(field.type)) {
|
|
76
|
+
builders.add("oneOf");
|
|
77
|
+
type = `oneOf(${field.type.map((value) => JSON.stringify(value)).join(", ")})`;
|
|
78
|
+
} else if (field.type === "number") type = field.bigint ? "bigint" : "int";
|
|
79
|
+
else type = COLUMN_TYPES[field.type] ?? "text";
|
|
80
|
+
builders.add(type.split(/[.(]/)[0]);
|
|
81
|
+
const fallback = field.defaultValue;
|
|
82
|
+
const literal = typeof fallback === "string" || typeof fallback === "number" || typeof fallback === "boolean" ? `.default(${field.bigint ? `${fallback}n` : JSON.stringify(fallback)})` : "";
|
|
83
|
+
return ` ${key}: ${type}${named}${field.required === false ? ".nullable" : ""}${field.unique ? ".unique" : ""}${field.index && !field.unique ? ".index" : ""}${literal},`;
|
|
84
|
+
});
|
|
85
|
+
const indexes = (entry.indexes ?? []).filter((definition) => definition.fields.length > 1);
|
|
86
|
+
if (indexes.length) builders.add("index");
|
|
87
|
+
return [
|
|
88
|
+
`export const ${entry.modelName} = table({`,
|
|
89
|
+
" id: text,",
|
|
90
|
+
...lines,
|
|
91
|
+
indexes.length ? `}).indexes((${entry.modelName}) => ({\n${indexes.map((definition) => ` ${definition.fields.join("_").replace(/_(\w)/g, (_match, letter) => letter.toUpperCase())}: index(${definition.fields.map((name) => `${entry.modelName}.${name}`).join(", ")})${definition.unique ? ".unique" : ""},`).join("\n")}\n}));` : "});"
|
|
92
|
+
].join("\n");
|
|
93
|
+
});
|
|
94
|
+
return [
|
|
95
|
+
"// Written by `auth generate` through symmetria/better-auth.",
|
|
96
|
+
"// Spread `authTables` into your schema: schema({ ...authTables, posts, … }).",
|
|
97
|
+
`import { ${[...builders].sort().join(", ")} } from "symmetria";`,
|
|
98
|
+
"",
|
|
99
|
+
declarations.join("\n\n"),
|
|
100
|
+
"",
|
|
101
|
+
`export const authTables = { ${ordered.map((entry) => entry.modelName).join(", ")} };`,
|
|
102
|
+
""
|
|
103
|
+
].join("\n");
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* `betterAuth({ database: symmetriaAdapter(db) })`. `db` is the database (or a
|
|
107
|
+
* `$scope()` of it) whose schema holds the auth tables; better-auth's own
|
|
108
|
+
* transactions run inside `db.$transaction`.
|
|
109
|
+
*/
|
|
110
|
+
const symmetriaAdapter = (db, options = {}) => {
|
|
111
|
+
let authOptions;
|
|
112
|
+
const build = (connection) => createAdapterFactory({
|
|
113
|
+
config: {
|
|
114
|
+
adapterId: "symmetria",
|
|
115
|
+
adapterName: "Symmetria",
|
|
116
|
+
usePlural: options.usePlural ?? false,
|
|
117
|
+
debugLogs: options.debugLogs ?? false,
|
|
118
|
+
supportsDates: true,
|
|
119
|
+
supportsBooleans: true,
|
|
120
|
+
supportsJSON: true,
|
|
121
|
+
supportsArrays: true,
|
|
122
|
+
transaction: (callback) => connection.$transaction((transaction) => callback(build(transaction)(authOptions ?? {})))
|
|
123
|
+
},
|
|
124
|
+
adapter: () => {
|
|
125
|
+
const table = (model) => {
|
|
126
|
+
const handle = connection[model];
|
|
127
|
+
if (!handle) throw new Error(`symmetria: better-auth uses a table "${model}" that the schema does not have; run \`npx auth generate\` and add it`);
|
|
128
|
+
return handle;
|
|
129
|
+
};
|
|
130
|
+
const filtered = (mutation, where) => where?.length ? mutation.where(filter(where)) : mutation.all();
|
|
131
|
+
return {
|
|
132
|
+
create: ({ model, data }) => table(model).insert(data).returning(),
|
|
133
|
+
findOne: ({ model, where }) => table(model)({
|
|
134
|
+
where: filter(where),
|
|
135
|
+
limit: 1
|
|
136
|
+
}).first(),
|
|
137
|
+
findMany: ({ model, where, limit, offset, sortBy }) => table(model)({
|
|
138
|
+
where: filter(where),
|
|
139
|
+
limit,
|
|
140
|
+
offset,
|
|
141
|
+
orderBy: sortBy ? { [sortBy.field]: sortBy.direction } : void 0
|
|
142
|
+
}),
|
|
143
|
+
count: ({ model, where }) => table(model)({ where: filter(where) }).count(),
|
|
144
|
+
update: async ({ model, where, update }) => {
|
|
145
|
+
const [row] = await filtered(table(model).update(update), where).returning();
|
|
146
|
+
return row ?? null;
|
|
147
|
+
},
|
|
148
|
+
updateMany: async ({ model, where, update }) => (await filtered(table(model).update(update), where)).affectedRows,
|
|
149
|
+
delete: async ({ model, where }) => {
|
|
150
|
+
await filtered(table(model).delete(), where);
|
|
151
|
+
},
|
|
152
|
+
deleteMany: async ({ model, where }) => (await filtered(table(model).delete(), where)).affectedRows,
|
|
153
|
+
consumeOne: async ({ model, where }) => {
|
|
154
|
+
const found = await table(model)({
|
|
155
|
+
where: filter(where),
|
|
156
|
+
limit: 1
|
|
157
|
+
}).first();
|
|
158
|
+
if (!found) return null;
|
|
159
|
+
const [row] = await table(model).byId(found.id).delete().returning();
|
|
160
|
+
return row ?? null;
|
|
161
|
+
},
|
|
162
|
+
incrementOne: async ({ model, where, increment, set }) => {
|
|
163
|
+
const [row] = await table(model).update((current) => ({
|
|
164
|
+
...set,
|
|
165
|
+
...Object.fromEntries(Object.entries(increment).map(([field, delta]) => [field, current[field].plus(delta)]))
|
|
166
|
+
})).where(filter(where)).returning();
|
|
167
|
+
return row ?? null;
|
|
168
|
+
},
|
|
169
|
+
createSchema: async ({ tables, file }) => ({
|
|
170
|
+
code: authSchemaSource(tables),
|
|
171
|
+
path: file ?? "./auth-schema.ts",
|
|
172
|
+
overwrite: true
|
|
173
|
+
})
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
const adapter = build(db);
|
|
178
|
+
return (betterAuthOptions) => {
|
|
179
|
+
authOptions = betterAuthOptions;
|
|
180
|
+
return adapter(betterAuthOptions);
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
//#endregion
|
|
184
|
+
export { authSchemaSource, symmetriaAdapter };
|
|
185
|
+
|
|
186
|
+
//# sourceMappingURL=better-auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"better-auth.js","names":[],"sources":["../src/entries/better-auth.ts"],"sourcesContent":["/**\n * `symmetria/better-auth`: a better-auth database adapter over a Symmetria\n * database: `betterAuth({ database: symmetriaAdapter(db) })`. The auth tables\n * are tables of your schema, keyed and named the way better-auth names its\n * models and fields (`user.emailVerified`), so they are migrated, related and\n * queried like the rest; `npx auth generate` writes them.\n */\nimport type { BetterAuthOptions } from \"better-auth\";\nimport {\n createAdapterFactory,\n type CleanedWhere,\n type DBAdapterDebugLogOption,\n} from \"better-auth/adapters\";\nimport { and, not, or } from \"../query/expressions\";\n\nexport type SymmetriaAdapterOptions = {\n /** Tables are keyed in the plural (`users`, `sessions`). */\n readonly usePlural?: boolean;\n readonly debugLogs?: DBAdapterDebugLogOption;\n};\n\n// better-auth names tables and fields at run time, so the adapter reaches\n// them by key and leaves the typed API to the application.\ntype Loose = any;\ntype Tables = Record<\n string,\n {\n modelName: string;\n fields: Record<string, Field>;\n indexes?: readonly {\n fields: readonly string[];\n unique?: boolean | undefined;\n }[];\n }\n>;\ntype Field = {\n type: string | readonly string[];\n required?: boolean | undefined;\n unique?: boolean | undefined;\n index?: boolean | undefined;\n bigint?: boolean | undefined;\n fieldName?: string | undefined;\n defaultValue?: unknown;\n references?:\n | { model: string; field: string; onDelete?: string | undefined }\n | undefined;\n};\n\nconst escapeLike = (value: unknown): string =>\n String(value).replace(/[\\\\%_]/g, (character) => `\\\\${character}`);\n\nconst predicate = (row: Loose, clause: CleanedWhere) => {\n const column = row[clause.field];\n\n if (!column) {\n throw new Error(\n `symmetria: better-auth asked for field \"${clause.field}\", which the table does not have`,\n );\n }\n\n const insensitive =\n clause.mode === \"insensitive\" && typeof clause.value === \"string\";\n const pattern = (text: string) =>\n insensitive ? column.ilike(text) : column.like(text);\n\n switch (clause.operator) {\n case \"ne\":\n return insensitive\n ? not(column.ilike(escapeLike(clause.value)))\n : column.isNot(clause.value);\n case \"in\":\n return column.in(clause.value);\n case \"not_in\":\n return column.notIn(clause.value);\n case \"gt\":\n return column.above(clause.value);\n case \"gte\":\n return column.atLeast(clause.value);\n case \"lt\":\n return column.below(clause.value);\n case \"lte\":\n return column.atMost(clause.value);\n case \"contains\":\n return pattern(`%${escapeLike(clause.value)}%`);\n case \"starts_with\":\n return pattern(`${escapeLike(clause.value)}%`);\n case \"ends_with\":\n return pattern(`%${escapeLike(clause.value)}`);\n default:\n return insensitive\n ? column.ilike(escapeLike(clause.value))\n : column.is(clause.value);\n }\n};\n\n/** better-auth's flat clause list: every AND clause, and at least one of the OR clauses. */\nconst filter = (where: readonly CleanedWhere[] | undefined) => (row: Loose) => {\n const clauses = where ?? [];\n const all = clauses\n .filter((clause) => clause.connector !== \"OR\")\n .map((clause) => predicate(row, clause));\n const any = clauses\n .filter((clause) => clause.connector === \"OR\")\n .map((clause) => predicate(row, clause));\n\n return and(...all, any.length > 0 ? or(...any) : undefined);\n};\n\nconst COLUMN_TYPES: Readonly<Record<string, string>> = {\n string: \"text\",\n boolean: \"bool\",\n date: \"timestamptz\",\n json: \"jsonb\",\n \"string[]\": \"text.array\",\n \"number[]\": \"int.array\",\n};\n\nconst snakeCase = (name: string): string =>\n name.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);\n\n/**\n * The auth tables as a Symmetria schema module, for `npx auth generate`.\n * Tables come out in an order where each one follows the tables it\n * references; spread `authTables` into `schema({ ... })`.\n */\nexport const authSchemaSource = (tables: Tables): string => {\n const builders = new Set<string>([\"table\", \"text\"]);\n const models = Object.values(tables);\n const nameOf = (model: string): string =>\n tables[model]?.modelName ??\n models.find((entry) => entry.modelName === model)?.modelName ??\n model;\n const ordered: typeof models = [];\n const pending = [...models];\n\n // References first; a cycle keeps the order better-auth gave.\n while (pending.length) {\n const next =\n pending.find((entry) =>\n Object.values(entry.fields).every(\n (field) =>\n !field.references ||\n nameOf(field.references.model) === entry.modelName ||\n ordered.some(\n (done) => done.modelName === nameOf(field.references!.model),\n ),\n ),\n ) ?? pending[0]!;\n\n ordered.push(next);\n pending.splice(pending.indexOf(next), 1);\n }\n\n const declarations = ordered.map((entry) => {\n const targets = Object.values(entry.fields).flatMap((field) =>\n field.references ? [nameOf(field.references.model)] : [],\n );\n const lines = Object.entries(entry.fields).map(([key, field]) => {\n const named =\n field.fieldName &&\n field.fieldName !== key &&\n field.fieldName !== snakeCase(key)\n ? `.named(${JSON.stringify(field.fieldName)})`\n : \"\";\n const reference = field.references;\n\n if (reference && reference.field === \"id\" && key.endsWith(\"Id\")) {\n const target = nameOf(reference.model);\n // better-auth's own migrations cascade when a reference names no action.\n const action =\n reference.onDelete === undefined || reference.onDelete === \"cascade\"\n ? \"cascade\"\n : reference.onDelete === \"set null\"\n ? \"setNull\"\n : undefined;\n const relation = key.slice(0, -2);\n const self = target === entry.modelName;\n\n // Two keys to one table need names for their reverse sides.\n if (targets.filter((name) => name === target).length > 1 || self) {\n if (self) {\n builders.add(\"self\");\n }\n\n return ` ${relation}: ${self ? \"self\" : target}${field.required === false || action === \"setNull\" ? \".nullable\" : \"\"}${field.unique ? \".unique\" : \".index\"}${action ? `.onDelete.${action}` : \"\"}.inverse(${JSON.stringify(`${entry.modelName}By${relation[0]!.toUpperCase()}${relation.slice(1)}`)}),`;\n }\n\n const claim =\n field.required === false || action === \"setNull\" ? \"maybe\" : \"one\";\n\n builders.add(claim);\n\n return ` ${relation}: ${claim}(${target})${action ? `.${action}` : \"\"}${field.unique ? \".unique\" : \"\"},`;\n }\n\n let type: string;\n\n if (Array.isArray(field.type)) {\n builders.add(\"oneOf\");\n type = `oneOf(${field.type.map((value) => JSON.stringify(value)).join(\", \")})`;\n } else if (field.type === \"number\") {\n type = field.bigint ? \"bigint\" : \"int\";\n } else {\n type = COLUMN_TYPES[field.type as string] ?? \"text\";\n }\n\n builders.add(type.split(/[.(]/)[0]!);\n\n const fallback = field.defaultValue;\n const literal =\n typeof fallback === \"string\" ||\n typeof fallback === \"number\" ||\n typeof fallback === \"boolean\"\n ? `.default(${field.bigint ? `${fallback}n` : JSON.stringify(fallback)})`\n : \"\";\n\n return ` ${key}: ${type}${named}${field.required === false ? \".nullable\" : \"\"}${field.unique ? \".unique\" : \"\"}${field.index && !field.unique ? \".index\" : \"\"}${literal},`;\n });\n const indexes = (entry.indexes ?? []).filter(\n (definition) => definition.fields.length > 1,\n );\n\n if (indexes.length) {\n builders.add(\"index\");\n }\n\n return [\n `export const ${entry.modelName} = table({`,\n \" id: text,\",\n ...lines,\n indexes.length\n ? `}).indexes((${entry.modelName}) => ({\\n${indexes\n .map(\n (definition) =>\n ` ${definition.fields.join(\"_\").replace(/_(\\w)/g, (_match, letter: string) => letter.toUpperCase())}: index(${definition.fields.map((name) => `${entry.modelName}.${name}`).join(\", \")})${definition.unique ? \".unique\" : \"\"},`,\n )\n .join(\"\\n\")}\\n}));`\n : \"});\",\n ].join(\"\\n\");\n });\n\n return [\n \"// Written by `auth generate` through symmetria/better-auth.\",\n \"// Spread `authTables` into your schema: schema({ ...authTables, posts, … }).\",\n `import { ${[...builders].sort().join(\", \")} } from \"symmetria\";`,\n \"\",\n declarations.join(\"\\n\\n\"),\n \"\",\n `export const authTables = { ${ordered.map((entry) => entry.modelName).join(\", \")} };`,\n \"\",\n ].join(\"\\n\");\n};\n\n/**\n * `betterAuth({ database: symmetriaAdapter(db) })`. `db` is the database (or a\n * `$scope()` of it) whose schema holds the auth tables; better-auth's own\n * transactions run inside `db.$transaction`.\n */\nexport const symmetriaAdapter = (\n db: object,\n options: SymmetriaAdapterOptions = {},\n) => {\n // What better-auth hands the adapter, kept for the adapters built around a transaction.\n let authOptions: BetterAuthOptions | undefined;\n\n const build = (connection: Loose): ReturnType<typeof createAdapterFactory> =>\n createAdapterFactory({\n config: {\n adapterId: \"symmetria\",\n adapterName: \"Symmetria\",\n usePlural: options.usePlural ?? false,\n debugLogs: options.debugLogs ?? false,\n supportsDates: true,\n supportsBooleans: true,\n supportsJSON: true,\n supportsArrays: true,\n transaction: (callback) =>\n connection.$transaction((transaction: Loose) =>\n callback(build(transaction)(authOptions ?? {}) as never),\n ),\n },\n adapter: () => {\n const table = (model: string) => {\n const handle = connection[model];\n\n if (!handle) {\n throw new Error(\n `symmetria: better-auth uses a table \"${model}\" that the schema does not have; run \\`npx auth generate\\` and add it`,\n );\n }\n\n return handle;\n };\n // An UPDATE or DELETE without a filter is refused unless spelled\n // out; better-auth means every row when it sends none.\n const filtered = (\n mutation: Loose,\n where: readonly CleanedWhere[] | undefined,\n ) => (where?.length ? mutation.where(filter(where)) : mutation.all());\n\n return {\n create: ({ model, data }) => table(model).insert(data).returning(),\n\n findOne: ({ model, where }) =>\n table(model)({ where: filter(where), limit: 1 }).first(),\n\n findMany: ({ model, where, limit, offset, sortBy }) =>\n table(model)({\n where: filter(where),\n limit,\n offset,\n orderBy: sortBy\n ? { [sortBy.field]: sortBy.direction }\n : undefined,\n }),\n\n count: ({ model, where }) =>\n table(model)({ where: filter(where) }).count(),\n\n update: async ({ model, where, update }) => {\n const [row] = await filtered(\n table(model).update(update),\n where,\n ).returning();\n\n return row ?? null;\n },\n\n updateMany: async ({ model, where, update }) =>\n (await filtered(table(model).update(update), where)).affectedRows,\n\n delete: async ({ model, where }) => {\n await filtered(table(model).delete(), where);\n },\n\n deleteMany: async ({ model, where }) =>\n (await filtered(table(model).delete(), where)).affectedRows,\n\n // One row at most: the DELETE by key decides which of two\n // concurrent callers gets it.\n consumeOne: async ({ model, where }) => {\n const found = await table(model)({\n where: filter(where),\n limit: 1,\n }).first();\n\n if (!found) {\n return null;\n }\n\n const [row] = await table(model)\n .byId(found.id)\n .delete()\n .returning();\n\n return row ?? null;\n },\n\n incrementOne: async ({ model, where, increment, set }) => {\n const [row] = await table(model)\n .update((current: Loose) => ({\n ...set,\n ...Object.fromEntries(\n Object.entries(increment).map(([field, delta]) => [\n field,\n current[field].plus(delta),\n ]),\n ),\n }))\n .where(filter(where))\n .returning();\n\n return row ?? null;\n },\n\n createSchema: async ({ tables, file }) => ({\n code: authSchemaSource(tables as Tables),\n path: file ?? \"./auth-schema.ts\",\n overwrite: true,\n }),\n };\n },\n });\n\n const adapter = build(db);\n\n return (betterAuthOptions: BetterAuthOptions) => {\n authOptions = betterAuthOptions;\n\n return adapter(betterAuthOptions);\n };\n};\n"],"mappings":";;;AAgDA,MAAM,cAAc,UAClB,OAAO,KAAK,CAAC,CAAC,QAAQ,YAAY,cAAc,KAAK,WAAW;AAElE,MAAM,aAAa,KAAY,WAAyB;CACtD,MAAM,SAAS,IAAI,OAAO;CAE1B,IAAI,CAAC,QACH,MAAM,IAAI,MACR,2CAA2C,OAAO,MAAM,iCAC1D;CAGF,MAAM,cACJ,OAAO,SAAS,iBAAiB,OAAO,OAAO,UAAU;CAC3D,MAAM,WAAW,SACf,cAAc,OAAO,MAAM,IAAI,IAAI,OAAO,KAAK,IAAI;CAErD,QAAQ,OAAO,UAAf;EACE,KAAK,MACH,OAAO,cACH,IAAI,OAAO,MAAM,WAAW,OAAO,KAAK,CAAC,CAAC,IAC1C,OAAO,MAAM,OAAO,KAAK;EAC/B,KAAK,MACH,OAAO,OAAO,GAAG,OAAO,KAAK;EAC/B,KAAK,UACH,OAAO,OAAO,MAAM,OAAO,KAAK;EAClC,KAAK,MACH,OAAO,O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