symmetria 2.2.0 → 2.3.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.
Files changed (43) hide show
  1. package/README.md +28 -27
  2. package/dist/better-auth.js +1 -1
  3. package/dist/bun.d.ts +2 -2
  4. package/dist/cohere.d.ts +1 -1
  5. package/dist/cohere.js +1 -1
  6. package/dist/{compile-CLksO6-D.js → compile-R1_PBIgc.js} +3 -3
  7. package/dist/{compile-CLksO6-D.js.map → compile-R1_PBIgc.js.map} +1 -1
  8. package/dist/{core-Bu8-BTNf.js → core-DxXVTy9r.js} +101 -10
  9. package/dist/core-DxXVTy9r.js.map +1 -0
  10. package/dist/driver.d.ts +3 -3
  11. package/dist/google.d.ts +1 -1
  12. package/dist/google.js +1 -1
  13. package/dist/index.d.ts +1 -1
  14. package/dist/index.js +30 -95
  15. package/dist/index.js.map +1 -1
  16. package/dist/{inspection-CYlzNdVg.js → inspection-BlOMPoif.js} +2 -2
  17. package/dist/{inspection-CYlzNdVg.js.map → inspection-BlOMPoif.js.map} +1 -1
  18. package/dist/internal.d.ts +1 -1
  19. package/dist/internal.js +1 -1
  20. package/dist/jina.d.ts +1 -1
  21. package/dist/jina.js +1 -1
  22. package/dist/mistral.d.ts +1 -1
  23. package/dist/mistral.js +1 -1
  24. package/dist/ollama.d.ts +1 -1
  25. package/dist/ollama.js +1 -1
  26. package/dist/openai.d.ts +1 -1
  27. package/dist/openai.js +1 -1
  28. package/dist/{pg-B7bJIFw0.d.ts → pg-BP8Z91xx.d.ts} +3 -3
  29. package/dist/pg.d.ts +3 -3
  30. package/dist/{pool-x45tVc5q.d.ts → pool-yxHoV4wf.d.ts} +2 -2
  31. package/dist/{search-CwBcdihW.js → search-BEk0Ff_y.js} +3 -3
  32. package/dist/{search-CwBcdihW.js.map → search-BEk0Ff_y.js.map} +1 -1
  33. package/dist/search.d.ts +1 -1
  34. package/dist/search.js +1 -1
  35. package/dist/{table-Lbap-R_E.js → table-Bx_6J15y.js} +2 -2
  36. package/dist/{table-Lbap-R_E.js.map → table-Bx_6J15y.js.map} +1 -1
  37. package/dist/{types-Dki1Ej7A.d.ts → types-pQCOrPh-.d.ts} +30 -16
  38. package/dist/vector.d.ts +1 -1
  39. package/dist/vector.js +1 -1
  40. package/dist/voyage.d.ts +1 -1
  41. package/dist/voyage.js +1 -1
  42. package/package.json +1 -1
  43. package/dist/core-Bu8-BTNf.js.map +0 -1
package/README.md CHANGED
@@ -127,21 +127,21 @@ import { createDatabase } from "symmetria";
127
127
  import { postgres } from "symmetria/bun";
128
128
  import { appSchema } from "./schema.ts";
129
129
 
130
- const database = createDatabase({
130
+ const db = createDatabase({
131
131
  schema: appSchema,
132
132
  driver: postgres({ url: process.env.DATABASE_URL! }),
133
133
  });
134
134
 
135
135
  try {
136
- await database.users
136
+ await db.users
137
137
  .insert({ name: "Ada", email: "ada@example.com" })
138
138
  .onConflict("email")
139
139
  .doNothing();
140
140
 
141
- const author = await database.users.by.email("ada@example.com").one();
142
- await database.posts.insert({ title: "Typed SQL", authorId: author.id });
141
+ const author = await db.users.get({ email: "ada@example.com" });
142
+ await db.posts.insert({ title: "Typed SQL", authorId: author.id });
143
143
 
144
- const authors = await database.users(({ name, posts }) => ({
144
+ const authors = await db.users(({ name, posts }) => ({
145
145
  name,
146
146
  posts: posts(({ title, views }) => ({ title, views }), {
147
147
  orderBy: ({ id }) => id.descending,
@@ -152,7 +152,7 @@ try {
152
152
 
153
153
  console.log(authors);
154
154
  } finally {
155
- await database.$close();
155
+ await db.$close();
156
156
  }
157
157
  ```
158
158
 
@@ -170,7 +170,7 @@ Each option can be a value or a synchronous callback receiving the same typed
170
170
  source and SQL tools.
171
171
 
172
172
  ```ts
173
- const feed = database.posts(
173
+ const feed = db.posts(
174
174
  ({ title, authorId }, { join }) => ({ title, author: join(authorId).name }),
175
175
  { orderBy: ({ id }) => id.descending },
176
176
  );
@@ -197,8 +197,8 @@ Reusable projections bind to each source occurrence, including aliases and
197
197
  relations:
198
198
 
199
199
  ```ts
200
- const userCard = database.users.shape((user) => ({ name: user.name }));
201
- const feed = database.posts((post) => ({
200
+ const userCard = db.users.shape((user) => ({ name: user.name }));
201
+ const feed = db.posts((post) => ({
202
202
  title: post.title,
203
203
  author: post.author(userCard),
204
204
  }));
@@ -207,14 +207,14 @@ const feed = database.posts((post) => ({
207
207
  `.shape()` stores a synchronous callback and evaluates it on each application. A
208
208
  projection belongs to its defining table, contains at least one selected field
209
209
  and has no `$...` controls. Apply options at use sites, for example
210
- `database.users(userCard, { limit: 20 })`. It can be defined on an offline
211
- schema and used on its connected or transaction-bound tables. To-one selections
212
- are typed as an object or `null`.
210
+ `db.users(userCard, { limit: 20 })`. It can be defined on an offline schema and
211
+ used on its connected or transaction-bound tables. To-one selections are typed
212
+ as an object or `null`.
213
213
 
214
214
  Relations offer `count`, `exists`, `sum`, `average`, `minimum` and `maximum`:
215
215
 
216
216
  ```ts
217
- const totals = database.users(({ name, posts }) => ({
217
+ const totals = db.users(({ name, posts }) => ({
218
218
  name,
219
219
  totalViews: posts.sum.views,
220
220
  latestPost: posts.maximum.createdAt,
@@ -238,7 +238,7 @@ returns `false` for empty inputs.
238
238
  ## Enum mappings
239
239
 
240
240
  ```ts
241
- const labels = database.posts((post) => ({
241
+ const labels = db.posts((post) => ({
242
242
  title: post.title,
243
243
  status: post.state.match({ draft: "Draft", published: "Published" }),
244
244
  visibleViews: post.state.match({ draft: 0n, published: post.views }),
@@ -253,31 +253,32 @@ CTEs.
253
253
  ## Write callbacks
254
254
 
255
255
  ```ts
256
- const updated = await database.posts
256
+ const updated = await db.posts
257
257
  .byId(42)
258
258
  .update((post) => ({ views: post.views.plus(1n) }))
259
- .returning((post) => ({ id: post.id, views: post.views }));
259
+ .returning("id", "views");
260
260
 
261
- const userCard = database.users.shape(({ id, name }) => ({ id, name }));
262
- await database.users.by
261
+ const userCard = db.users.shape(({ id, name }) => ({ id, name }));
262
+ await db.users.by
263
263
  .email("ada@example.com")
264
264
  .update({ name: "Ada Lovelace" })
265
265
  .returning(userCard);
266
266
 
267
- await database.users
267
+ await db.users
268
268
  .insert({ name: "Ada Lovelace", email: "ada@example.com" })
269
269
  .onConflict("email")
270
270
  .doUpdate((user, excluded) => ({ email: user.email, name: excluded.name }));
271
271
 
272
- await database.posts.update({ state: "draft" }).all(); // whole table, spelled out
272
+ await db.posts.update({ state: "draft" }).all(); // whole table, spelled out
273
273
  ```
274
274
 
275
275
  `byId()` and `.by.<key>()` lookups update and delete directly, in one statement.
276
- `returning()` accepts a callback or a row-local reusable projection of the same
277
- table. UPDATE, WHERE and RETURNING callbacks receive the row directly, including
278
- nested-insert RETURNING. Upserts receive the existing row first and the proposed
279
- `excluded` row second. `.doUpdate("name")` copies a field from `excluded`. An
280
- UPDATE or DELETE without `where()` is refused unless `.all()` confirms it.
276
+ `returning()` accepts column names, a callback or a row-local reusable
277
+ projection of the same table. UPDATE, WHERE and RETURNING callbacks receive the
278
+ row directly, including nested-insert RETURNING. Upserts receive the existing
279
+ row first and the proposed `excluded` row second. `.doUpdate("name")` copies a
280
+ field from `excluded`. An UPDATE or DELETE without `where()` is refused unless
281
+ `.all()` confirms it.
281
282
 
282
283
  ## Capabilities
283
284
 
@@ -297,7 +298,7 @@ UPDATE or DELETE without `where()` is refused unless `.all()` confirms it.
297
298
  `exists` / `inspect`, keyset pagination in both directions and `pages()` async
298
299
  iteration; `count()` and `exists()` on any table or filtered source.
299
300
  - Transactions, nested savepoints, isolation options and row locks.
300
- - `Transaction<typeof database>` for schema-specific transaction helpers.
301
+ - `Transaction<typeof db>` for schema-specific transaction helpers.
301
302
  - `$scope()` filters for reads, updates and deletes, including related tables,
302
303
  and checks every row a scoped insert, upsert or update writes, like row-level
303
304
  security's `WITH CHECK` (`SYMMETRIA_OUT_OF_SCOPE`); reused and prepared
@@ -368,7 +369,7 @@ Official drivers ship with `symmetria` and are maintained and released together:
368
369
  import { createDatabase } from "symmetria";
369
370
  import { postgres } from "symmetria/pg";
370
371
 
371
- const database = createDatabase({
372
+ const db = createDatabase({
372
373
  schema: appSchema,
373
374
  driver: postgres({ url: process.env.DATABASE_URL!, max: 10 }),
374
375
  });
@@ -1,4 +1,4 @@
1
- import { _ as not, b as or, l as and } from "./core-Bu8-BTNf.js";
1
+ import { _ as not, b as or, l as and } from "./core-DxXVTy9r.js";
2
2
  import { createAdapterFactory } from "better-auth/adapters";
3
3
  //#region src/entries/better-auth.ts
4
4
  const escapeLike = (value) => String(value).replace(/[\\%_]/g, (character) => `\\${character}`);
package/dist/bun.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { c as SessionDriver, dt as BindableSchema, l as TransactionDriver, nt as QueryProfiler, pt as SCHEMA_BIND, r as Driver } from "./types-Dki1Ej7A.js";
2
- import { t as PostgresDriver } from "./pool-x45tVc5q.js";
1
+ import { c as SessionDriver, dt as BindableSchema, l as TransactionDriver, nt as QueryProfiler, pt as SCHEMA_BIND, r as Driver } from "./types-pQCOrPh-.js";
2
+ import { t as PostgresDriver } from "./pool-yxHoV4wf.js";
3
3
  import { SQL } from "bun";
4
4
  //#region src/driver/bun.d.ts
5
5
  type PostgresOptions = Omit<SQL.PostgresOrMySQLOptions, "adapter" | "bigint"> & {
package/dist/cohere.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { K as EmbeddingModel, cn as SelectedColumn, q as MeaningSearch } from "./types-Dki1Ej7A.js";
1
+ import { K as EmbeddingModel, cn as SelectedColumn, q as MeaningSearch } from "./types-pQCOrPh-.js";
2
2
  //#region src/entries/cohere.d.ts
3
3
  export type CohereOptions = {
4
4
  readonly apiKey?: string;
package/dist/cohere.js CHANGED
@@ -1,4 +1,4 @@
1
- import { r as embedder } from "./search-CwBcdihW.js";
1
+ import { r as embedder } from "./search-BEk0Ff_y.js";
2
2
  import { i as postJson, r as inBatches, t as apiKey } from "./http-o1fpnTNy.js";
3
3
  //#region src/entries/cohere.ts
4
4
  /**
@@ -1,7 +1,7 @@
1
1
  import { a as containsBinding, c as numberedAlias, f as cloneParameter, g as createRowDecoder, o as mergeBindings, s as normalizeResult, t as DEFAULT_VALUE, u as bigintCodec, w as throwDataErrors, y as numericCodec } from "./types-DPWc6nQ9.js";
2
- import { $ as tsvectorSql, G as parameter, J as searchHeadlineSql, K as quoteIdentifier, Q as tsquerySql, U as aliasSql, W as createCompilation, X as searchVectorSql, Y as searchRankSql, Z as sqlString, q as renderContext } from "./table-Lbap-R_E.js";
2
+ import { $ as tsvectorSql, G as parameter, J as searchHeadlineSql, K as quoteIdentifier, Q as tsquerySql, U as aliasSql, W as createCompilation, X as searchVectorSql, Y as searchRankSql, Z as sqlString, q as renderContext } from "./table-Bx_6J15y.js";
3
3
  import { c as scopeViolationText } from "./binding-BiJH76XX.js";
4
- import { A as freeze, D as childNodes, E as expressionSqlType, O as containsNode } from "./core-Bu8-BTNf.js";
4
+ import { I as freeze, M as expressionSqlType, N as childNodes, P as containsNode } from "./core-DxXVTy9r.js";
5
5
  import { AsyncLocalStorage } from "node:async_hooks";
6
6
  import { randomUUID, timingSafeEqual } from "node:crypto";
7
7
  import { createServer } from "node:http";
@@ -1233,4 +1233,4 @@ const rowDecoder = (plan) => {
1233
1233
  //#endregion
1234
1234
  export { currentScopes as a, rowDecoder as c, executorProfiling as d, postgresRenderer as f, compileTemplate as i, batchCollectors as l, compileQuery as n, executeCompiled as o, compileShape as r, executePlan as s, compilePlan as t, createProfiler as u };
1235
1235
 
1236
- //# sourceMappingURL=compile-CLksO6-D.js.map
1236
+ //# sourceMappingURL=compile-R1_PBIgc.js.map