symmetria 2.3.0 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/dist/better-auth.js +1 -1
  2. package/dist/{binding-BiJH76XX.js → binding-jM09pXvJ.js} +4 -3
  3. package/dist/binding-jM09pXvJ.js.map +1 -0
  4. package/dist/bun.d.ts +2 -2
  5. package/dist/bun.js +4 -3
  6. package/dist/bun.js.map +1 -1
  7. package/dist/cohere.d.ts +1 -1
  8. package/dist/cohere.js +1 -1
  9. package/dist/{compile-R1_PBIgc.js → compile-hFOq0snq.js} +404 -45
  10. package/dist/compile-hFOq0snq.js.map +1 -0
  11. package/dist/{core-DxXVTy9r.js → core-kaO0qvAO.js} +34 -12
  12. package/dist/core-kaO0qvAO.js.map +1 -0
  13. package/dist/driver.d.ts +3 -3
  14. package/dist/driver.js +2 -2
  15. package/dist/google.d.ts +1 -1
  16. package/dist/google.js +1 -1
  17. package/dist/index.d.ts +1 -1
  18. package/dist/index.js +313 -233
  19. package/dist/index.js.map +1 -1
  20. package/dist/{inspection-BlOMPoif.js → inspection-djgix9ya.js} +3 -3
  21. package/dist/{inspection-BlOMPoif.js.map → inspection-djgix9ya.js.map} +1 -1
  22. package/dist/internal.d.ts +1 -1
  23. package/dist/internal.js +3 -3
  24. package/dist/jina.d.ts +1 -1
  25. package/dist/jina.js +1 -1
  26. package/dist/mistral.d.ts +1 -1
  27. package/dist/mistral.js +1 -1
  28. package/dist/ollama.d.ts +1 -1
  29. package/dist/ollama.js +1 -1
  30. package/dist/openai.d.ts +1 -1
  31. package/dist/openai.js +1 -1
  32. package/dist/{pg-Cx2W_Lmd.js → pg-9c7xlOnS.js} +6 -5
  33. package/dist/{pg-Cx2W_Lmd.js.map → pg-9c7xlOnS.js.map} +1 -1
  34. package/dist/{pg-BP8Z91xx.d.ts → pg-B5rodRoT.d.ts} +3 -3
  35. package/dist/pg.d.ts +3 -3
  36. package/dist/pg.js +2 -2
  37. package/dist/{pool-CFas0E3j.js → pool-C3RZQz3X.js} +27 -11
  38. package/dist/pool-C3RZQz3X.js.map +1 -0
  39. package/dist/{pool-yxHoV4wf.d.ts → pool-XG_sgock.d.ts} +2 -2
  40. package/dist/{search-BEk0Ff_y.js → search-jZqgEILM.js} +13 -6
  41. package/dist/search-jZqgEILM.js.map +1 -0
  42. package/dist/search.d.ts +1 -1
  43. package/dist/search.js +1 -1
  44. package/dist/{table-Bx_6J15y.js → table-BOy3SI0b.js} +24 -5
  45. package/dist/table-BOy3SI0b.js.map +1 -0
  46. package/dist/{types-DPWc6nQ9.js → types-BCMCu-EF.js} +28 -5
  47. package/dist/types-BCMCu-EF.js.map +1 -0
  48. package/dist/{types-pQCOrPh-.d.ts → types-C2s_w1LW.d.ts} +139 -105
  49. package/dist/values-CInqtWRn.js +11 -0
  50. package/dist/values-CInqtWRn.js.map +1 -0
  51. package/dist/vector.d.ts +1 -1
  52. package/dist/vector.js +1 -1
  53. package/dist/voyage.d.ts +1 -1
  54. package/dist/voyage.js +1 -1
  55. package/package.json +1 -1
  56. package/dist/binding-BiJH76XX.js.map +0 -1
  57. package/dist/compile-R1_PBIgc.js.map +0 -1
  58. package/dist/core-DxXVTy9r.js.map +0 -1
  59. package/dist/pool-CFas0E3j.js.map +0 -1
  60. package/dist/search-BEk0Ff_y.js.map +0 -1
  61. package/dist/table-Bx_6J15y.js.map +0 -1
  62. package/dist/types-DPWc6nQ9.js.map +0 -1
  63. package/dist/values-C7U6IIQZ.js +0 -10
  64. package/dist/values-C7U6IIQZ.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { _ as not, b as or, l as and } from "./core-DxXVTy9r.js";
1
+ import { _ as not, b as or, l as and } from "./core-kaO0qvAO.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}`);
@@ -63,14 +63,14 @@ var QueryError = class extends Error {
63
63
  if (cause && typeof cause === "object") {
64
64
  for (const [key, value] of Object.entries(cause)) if (!RESERVED.has(key)) this[key] = value;
65
65
  }
66
- Object.assign(this, fields);
66
+ Object.assign(this, { column: void 0 }, fields);
67
67
  }
68
68
  };
69
69
  /** SQLSTATE 23505: a unique or primary key already holds the value. */
70
70
  var UniqueViolation = class extends QueryError {
71
71
  name = "UniqueViolation";
72
72
  };
73
- /** SQLSTATE 23503: the referenced row is missing, or a referencing row still exists. */
73
+ /** SQLSTATE 23503, or 23001 from PostgreSQL 18 for a RESTRICT key: the referenced row is missing, or a referencing row still exists. */
74
74
  var ForeignKeyViolation = class extends QueryError {
75
75
  name = "ForeignKeyViolation";
76
76
  };
@@ -167,6 +167,7 @@ const isConnectionError = (error) => {
167
167
  const KINDS = {
168
168
  "23505": "unique",
169
169
  "23503": "foreign-key",
170
+ "23001": "foreign-key",
170
171
  "23502": "not-null",
171
172
  "23514": "check",
172
173
  "23P01": "exclusion",
@@ -242,4 +243,4 @@ const createDatabase = ({ schema: model, driver }) => {
242
243
  //#endregion
243
244
  export { UniqueViolation as C, TooManyRowsError as S, NotNullViolation as _, isRetryableTransactionError as a, SerializationFailure as b, scopeViolationText as c, ConnectionError as d, DeadlockDetected as f, NotFoundError as g, ForeignKeyViolation as h, isConnectionError as i, sqlState as l, ExclusionViolation as m, createDatabase as n, queryError as o, DuplicateConflictKeyError as p, databaseError as r, scopeViolation as s, SCHEMA_BIND as t, CheckViolation as u, OutOfScopeError as v, SymmetriaError as x, QueryError as y };
244
245
 
245
- //# sourceMappingURL=binding-BiJH76XX.js.map
246
+ //# sourceMappingURL=binding-jM09pXvJ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"binding-jM09pXvJ.js","names":[],"sources":["../src/errors.ts","../src/driver/errors.ts","../src/schema/binding.ts"],"sourcesContent":["/**\n * Error classes: Symmetria's own failures carry a `code`, and database\n * failures from the built-in adapters carry what PostgreSQL reported, so both\n * can be told apart with `instanceof`.\n */\nimport type { DatabaseErrorKind } from \"./driver/errors\";\n\n/** A failure Symmetria itself detected; `code` names it for `switch` and logs. */\nexport class SymmetriaError extends Error {\n override name = \"SymmetriaError\";\n readonly code: string;\n\n constructor(message: string, code: string, options?: ErrorOptions) {\n super(message, options);\n this.code = code;\n }\n}\n\n/** `one()`, `get()` or a nested `connect` found no row. */\nexport class NotFoundError extends SymmetriaError {\n override name = \"NotFoundError\";\n readonly table: string;\n\n constructor(message: string, table: string) {\n super(message, \"SYMMETRIA_RECORD_NOT_FOUND\");\n this.table = table;\n }\n}\n\n/** `one()` or `maybeOne()` found more than one row. */\nexport class TooManyRowsError extends SymmetriaError {\n override name = \"TooManyRowsError\";\n readonly table: string;\n\n constructor(message: string, table: string) {\n super(message, \"SYMMETRIA_TOO_MANY_ROWS\");\n this.table = table;\n }\n}\n\n/** A write through a `$scope()` database would leave a row outside the scope. */\nexport class OutOfScopeError extends SymmetriaError {\n override name = \"OutOfScopeError\";\n readonly table: string;\n\n constructor(message: string, table: string, cause: unknown) {\n super(message, \"SYMMETRIA_OUT_OF_SCOPE\", { cause });\n this.table = table;\n }\n}\n\n/** Two rows of one upsert share a conflict key. */\nexport class DuplicateConflictKeyError extends SymmetriaError {\n override name = \"DuplicateConflictKeyError\";\n readonly table: string;\n\n constructor(message: string, table: string) {\n super(message, \"SYMMETRIA_DUPLICATE_CONFLICT_KEY\");\n this.table = table;\n }\n}\n\n/** What `QueryError` takes from the driver error it wraps. */\nexport type QueryErrorFields = {\n readonly kind: DatabaseErrorKind;\n readonly sqlState: string;\n readonly table?: string;\n readonly column?: string;\n readonly constraint?: string;\n readonly detail?: string;\n};\n\nconst RESERVED = new Set([\"name\", \"message\", \"stack\", \"cause\"]);\n\n/**\n * A statement PostgreSQL rejected, or a connection that failed, as the\n * built-in adapters throw it. The driver's own error is the `cause`, and its\n * fields (`code`, `errno`, `hint`, `severity`, …) are copied, so code that\n * read them from the driver error keeps working.\n */\nexport class QueryError extends Error {\n override name = \"QueryError\";\n /** What was violated; `\"other\"` for every SQLSTATE without a class of its own. */\n declare readonly kind: DatabaseErrorKind;\n /** The five-character SQLSTATE, such as `23505`. */\n declare readonly sqlState: string;\n declare readonly table?: string;\n declare readonly column?: string;\n declare readonly constraint?: string;\n /** PostgreSQL's DETAIL, such as `Key (email)=(ada@example.com) already exists.` */\n declare readonly detail?: string;\n\n constructor(message: string, fields: QueryErrorFields, cause: unknown) {\n super(message, { cause });\n\n if (cause && typeof cause === \"object\") {\n for (const [key, value] of Object.entries(cause)) {\n if (!RESERVED.has(key)) {\n (this as Record<string, unknown>)[key] = value;\n }\n }\n }\n\n // JavaScriptCore gives every Error a `column` of its own: where in the\n // source it was created. Unless PostgreSQL named a column, there is none.\n Object.assign(this, { column: undefined }, fields);\n }\n}\n\n/** SQLSTATE 23505: a unique or primary key already holds the value. */\nexport class UniqueViolation extends QueryError {\n override name = \"UniqueViolation\";\n}\n\n/** SQLSTATE 23503, or 23001 from PostgreSQL 18 for a RESTRICT key: the referenced row is missing, or a referencing row still exists. */\nexport class ForeignKeyViolation extends QueryError {\n override name = \"ForeignKeyViolation\";\n}\n\n/** SQLSTATE 23502: NULL in a NOT NULL column. */\nexport class NotNullViolation extends QueryError {\n override name = \"NotNullViolation\";\n}\n\n/** SQLSTATE 23514: a CHECK constraint failed. */\nexport class CheckViolation extends QueryError {\n override name = \"CheckViolation\";\n}\n\n/** SQLSTATE 23P01: an exclusion constraint failed. */\nexport class ExclusionViolation extends QueryError {\n override name = \"ExclusionViolation\";\n}\n\n/** SQLSTATE 40001: a concurrent transaction conflicted; `retries` re-runs it. */\nexport class SerializationFailure extends QueryError {\n override name = \"SerializationFailure\";\n}\n\n/** SQLSTATE 40P01: PostgreSQL ended the transaction to break a deadlock. */\nexport class DeadlockDetected extends QueryError {\n override name = \"DeadlockDetected\";\n}\n\n/** The connection was lost or could not be opened. */\nexport class ConnectionError extends QueryError {\n override name = \"ConnectionError\";\n}\n","/**\n * PostgreSQL error inspection shared by the adapters: SQLSTATE lookup, the\n * conflict classes a transaction may retry and failed `$scope()` write checks.\n */\n\nimport {\n CheckViolation,\n ConnectionError,\n DeadlockDetected,\n ExclusionViolation,\n ForeignKeyViolation,\n NotNullViolation,\n OutOfScopeError,\n QueryError,\n SerializationFailure,\n UniqueViolation,\n} from \"../errors\";\n\n/** The five-character SQLSTATE of a server error (`code` on pg, `errno` on Bun). */\nexport const sqlState = (error: unknown): string | undefined => {\n if (!error || typeof error !== \"object\") {\n return undefined;\n }\n\n const value = error as { code?: unknown; errno?: unknown };\n\n return [value.code, value.errno].find(\n (code): code is string =>\n typeof code === \"string\" && /^[0-9A-Z]{5}$/.test(code),\n );\n};\n\n/**\n * The text a failed `$scope()` write check casts to boolean (see the\n * compiler's scope checks), so PostgreSQL aborts the statement with 22P02 and\n * an error that names the check: the statement's own rows (`insert`, `update`)\n * or the existing row of an upsert conflict (`conflict`), and the table.\n */\nexport const scopeViolationText = (\n check: \"insert\" | \"update\" | \"conflict\",\n table: string,\n): string => `SYMMETRIA_OUT_OF_SCOPE:${check}:${encodeURIComponent(table)}:`;\n\n/** The text in PostgreSQL's message, whose quotes depend on `lc_messages`. */\nconst SCOPE_VIOLATION =\n /SYMMETRIA_OUT_OF_SCOPE:(insert|update|conflict):([^:]*):\\d+/;\n\n/**\n * PostgreSQL's error for a failed scope check as `SYMMETRIA_OUT_OF_SCOPE`,\n * naming the table, with the driver error as its cause; other errors pass\n * through. Writes and transaction scopes both apply it, so a transaction that\n * a caught violation aborted reports the same error.\n */\nexport const scopeViolation = (error: unknown): unknown => {\n const failed =\n sqlState(error) === \"22P02\"\n ? SCOPE_VIOLATION.exec(String((error as { message?: unknown }).message))\n : null;\n\n if (!failed) {\n return error;\n }\n\n const table = decodeURIComponent(failed[2]!);\n\n return new OutOfScopeError(\n failed[1] === \"conflict\"\n ? `symmetria: upsert on \"${table}\" conflicted with a row outside the database scope`\n : `symmetria: ${failed[1]} on \"${table}\" would write a row outside the database scope`,\n table,\n error,\n );\n};\n\n/** serialization_failure and deadlock_detected: the transaction can be re-run from the start. */\nexport const isRetryableTransactionError = (error: unknown): boolean => {\n const state = sqlState(error);\n\n return state === \"40001\" || state === \"40P01\";\n};\n\n/** Connection exceptions (class 08) and the shutdowns that end a session (57P01–57P05). */\nconst connectionState = (state: string): boolean =>\n state.startsWith(\"08\") || /^57P0[1-5]$/.test(state);\n\n/** Socket and pool failures, which carry no SQLSTATE. */\nconst NODE_POSTGRES_CONNECTION =\n /^(Connection terminated|Client has encountered a connection error|Client was closed|timeout exceeded when trying to connect)/;\nconst SOCKET_CODES = new Set([\n \"ECONNREFUSED\",\n \"ECONNRESET\",\n \"ECONNABORTED\",\n \"EPIPE\",\n \"ETIMEDOUT\",\n \"EHOSTUNREACH\",\n \"ENETUNREACH\",\n \"ENOTFOUND\",\n \"EAI_AGAIN\",\n]);\n\n/**\n * Whether the connection itself failed, rather than a statement: the server\n * ended the session (class 08, 57P01–57P05), a socket error, or a client-side\n * connection loss (`Connection terminated unexpectedly` on node-postgres,\n * `ERR_POSTGRES_CONNECTION_CLOSED` and similar on Bun).\n */\nexport const isConnectionError = (error: unknown): boolean => {\n if (!error || typeof error !== \"object\") {\n return false;\n }\n\n const state = sqlState(error);\n\n if (state) {\n return connectionState(state);\n }\n\n const { code, message } = error as { code?: unknown; message?: unknown };\n\n return (\n (typeof code === \"string\" &&\n (SOCKET_CODES.has(code) ||\n /^ERR_POSTGRES_(CONNECTION|IDLE|LIFETIME|TLS)_/.test(code))) ||\n (typeof message === \"string\" && NODE_POSTGRES_CONNECTION.test(message))\n );\n};\n\n/** What a failed statement violated, by SQLSTATE class, or `connection` when the connection was lost. */\nexport type DatabaseErrorKind =\n | \"unique\"\n | \"foreign-key\"\n | \"not-null\"\n | \"check\"\n | \"exclusion\"\n | \"serialization\"\n | \"deadlock\"\n | \"connection\"\n | \"other\";\n\n/** A server error described the same way for node-postgres and Bun.SQL. */\nexport type DatabaseError = {\n readonly kind: DatabaseErrorKind;\n readonly sqlState: string;\n readonly message: string;\n readonly table?: string;\n readonly column?: string;\n readonly constraint?: string;\n /** PostgreSQL's DETAIL, such as `Key (email)=(ada@example.com) already exists.` */\n readonly detail?: string;\n};\n\nconst KINDS: Record<string, DatabaseErrorKind> = {\n \"23505\": \"unique\",\n \"23503\": \"foreign-key\",\n // PostgreSQL 18 reports a RESTRICT foreign key as restrict_violation.\n \"23001\": \"foreign-key\",\n \"23502\": \"not-null\",\n \"23514\": \"check\",\n \"23P01\": \"exclusion\",\n \"40001\": \"serialization\",\n \"40P01\": \"deadlock\",\n};\n\n/** Failures to open a connection, as opposed to losing one. */\nconst UNREACHABLE =\n /^(ECONNREFUSED|EHOSTUNREACH|ENETUNREACH|ENOTFOUND|EAI_AGAIN|ERR_POSTGRES_CONNECTION_(REFUSED|TIMEOUT)|ERR_POSTGRES_TLS_.+)$/;\n\n/** 08001 (unable to connect) or 08006 (connection_failure) for a connection error without a SQLSTATE. */\nconst connectionFailureState = (error: unknown): string | undefined => {\n if (!isConnectionError(error)) {\n return undefined;\n }\n\n const { code, message } = error as { code?: unknown; message?: unknown };\n\n return UNREACHABLE.test(String(code)) ||\n /^timeout exceeded when trying to connect/.test(String(message))\n ? \"08001\"\n : \"08006\";\n};\n\n/**\n * The server error behind a failed query, normalized across both drivers, or\n * undefined for anything else (symmetria errors, programming errors):\n * `if (databaseError(error)?.kind === \"unique\") …`. A lost or refused\n * connection is `kind: \"connection\"` on both drivers; without a server\n * SQLSTATE it reports 08006 (connection_failure) or 08001 (unable to connect).\n */\nexport const databaseError = (error: unknown): DatabaseError | undefined => {\n const state = sqlState(error) ?? connectionFailureState(error);\n\n if (!state) {\n return undefined;\n }\n\n const fields = error as Record<string, unknown>;\n const text = (name: string): string | undefined =>\n typeof fields[name] === \"string\" && fields[name] !== \"\"\n ? (fields[name] as string)\n : undefined;\n const message = error instanceof Error ? error.message : String(error);\n // node-postgres omits the column of a NOT NULL violation; its message names it.\n const column =\n text(\"column\") ?? /null value in column \"([^\"]+)\"/.exec(message)?.[1];\n const table = text(\"table\");\n const constraint = text(\"constraint\");\n const detail = text(\"detail\");\n\n return Object.freeze({\n kind: KINDS[state] ?? (connectionState(state) ? \"connection\" : \"other\"),\n sqlState: state,\n message,\n ...(table ? { table } : {}),\n ...(column ? { column } : {}),\n ...(constraint ? { constraint } : {}),\n ...(detail ? { detail } : {}),\n });\n};\n\nconst CLASSES: Partial<Record<DatabaseErrorKind, typeof QueryError>> = {\n unique: UniqueViolation,\n \"foreign-key\": ForeignKeyViolation,\n \"not-null\": NotNullViolation,\n check: CheckViolation,\n exclusion: ExclusionViolation,\n serialization: SerializationFailure,\n deadlock: DeadlockDetected,\n connection: ConnectionError,\n};\n\n/**\n * A driver's database error as its `QueryError` class, with the driver error\n * as the cause; anything that did not come from the database, and an error\n * that is wrapped already, passes through unchanged.\n */\nexport const queryError = (error: unknown): unknown => {\n if (error instanceof QueryError) {\n return error;\n }\n\n const described = databaseError(error);\n\n if (!described) {\n return error;\n }\n\n const { message, ...fields } = described;\n\n return new (CLASSES[fields.kind] ?? QueryError)(message, fields, error);\n};\n","import type { Driver } from \"../query/plan/types\";\n\n/** Rebind compiled schema metadata without evaluating declaration callbacks again. */\nexport const SCHEMA_BIND = Symbol(\"symmetria.schema.bind\");\nexport type BindableSchema = {\n readonly [SCHEMA_BIND]: (driver: Driver) => unknown;\n};\n\nexport type DatabaseOptions<Model extends BindableSchema> = {\n readonly schema: Model;\n readonly driver: Driver;\n};\n\n/** Bind a reusable schema to a driver, retaining its inferred query API and scopes. */\nexport const createDatabase = <Model extends BindableSchema>({\n schema: model,\n driver,\n}: DatabaseOptions<Model>): ReturnType<Model[typeof SCHEMA_BIND]> => {\n if (!model || typeof model[SCHEMA_BIND] !== \"function\") {\n throw new Error(\n \"symmetria: createDatabase() expects a schema() declaration\",\n );\n }\n\n return model[SCHEMA_BIND](driver) as ReturnType<Model[typeof SCHEMA_BIND]>;\n};\n"],"mappings":";;AAQA,IAAa,iBAAb,cAAoC,MAAM;CACxC,OAAgB;CACh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,GAAI,SAAS,EAAE,OAAO,IAAI,CAAC;CAC7B,CAAC;AACH;AAEA,MAAM,UAAiE;CACrE,QAAQ;CACR,eAAe;CACf,YAAY;CACZ,OAAO;CACP,WAAW;CACX,eAAe;CACf,UAAU;CACV,YAAY;AACd;;;;;;AAOA,MAAa,cAAc,UAA4B;CACrD,IAAI,iBAAiB,YACnB,OAAO;CAGT,MAAM,YAAY,cAAc,KAAK;CAErC,IAAI,CAAC,WACH,OAAO;CAGT,MAAM,EAAE,SAAS,GAAG,WAAW;CAE/B,OAAO,KAAK,QAAQ,OAAO,SAAS,YAAY,SAAS,QAAQ,KAAK;AACxE;;;;ACtPA,MAAa,cAAc,OAAO,uBAAuB;;AAWzD,MAAa,kBAAgD,EAC3D,QAAQ,OACR,aACmE;CACnE,IAAI,CAAC,SAAS,OAAO,MAAM,iBAAiB,YAC1C,MAAM,IAAI,MACR,4DACF;CAGF,OAAO,MAAM,YAAY,CAAC,MAAM;AAClC"}
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-pQCOrPh-.js";
2
- import { t as PostgresDriver } from "./pool-yxHoV4wf.js";
1
+ import { c as SessionDriver, dt as BindableSchema, l as TransactionDriver, nt as QueryProfiler, pt as SCHEMA_BIND, r as Driver } from "./types-C2s_w1LW.js";
2
+ import { t as PostgresDriver } from "./pool-XG_sgock.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/bun.js CHANGED
@@ -1,5 +1,5 @@
1
- import { t as SCHEMA_BIND } from "./binding-BiJH76XX.js";
2
- import { n as postgresParameters, t as createPostgresDriver } from "./pool-CFas0E3j.js";
1
+ import { t as SCHEMA_BIND } from "./binding-jM09pXvJ.js";
2
+ import { n as postgresParameters, t as createPostgresDriver } from "./pool-C3RZQz3X.js";
3
3
  import { SQL } from "bun";
4
4
  //#region src/driver/bun.ts
5
5
  /**
@@ -64,7 +64,8 @@ const postgres = (connection) => {
64
64
  } finally {
65
65
  await cancellation?.close();
66
66
  }
67
- }
67
+ },
68
+ max: options.max ?? 10
68
69
  }, profiler);
69
70
  };
70
71
  //#endregion
package/dist/bun.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"bun.js","names":[],"sources":["../src/driver/bun.ts"],"sourcesContent":["/**\n * `symmetria/bun`: PostgreSQL adapter built on Bun's SQL pool.\n */\nimport { SQL } from \"bun\";\nimport { createPostgresDriver, type PostgresDriver } from \"./pool\";\nimport { postgresParameters } from \"./parameters\";\nimport type { CompiledQuery, ExecutionResult } from \"../query/plan/types\";\nimport type { QueryProfiler } from \"../observability/profiling\";\n\nexport type PostgresOptions = Omit<\n SQL.PostgresOrMySQLOptions,\n \"adapter\" | \"bigint\"\n> & { readonly profiler?: QueryProfiler | undefined };\nexport type { PostgresDriver } from \"./pool\";\n\n/** Bun reports socket-level failures with ERR_POSTGRES_* codes; server errors carry SQLSTATE codes. */\nconst transportFailure = (error: Error): boolean => {\n const code: unknown = (error as { code?: unknown }).code;\n\n return typeof code === \"string\" && code.startsWith(\"ERR_\");\n};\n\nexport const postgres = (\n connection: string | PostgresOptions,\n): PostgresDriver => {\n const { profiler, ...options } =\n typeof connection === \"string\" ? { url: connection } : connection;\n const client = new SQL({ ...options, adapter: \"postgres\", bigint: true });\n let cancellation: SQL | undefined;\n\n const execute = async (\n connection: SQL,\n query: CompiledQuery,\n ): Promise<ExecutionResult> => {\n const result = await connection.unsafe<Record<string, unknown>[]>(\n query.sql,\n postgresParameters(query.parameters),\n );\n\n return {\n rows: Array.from(result),\n affectedRows: (result as { count?: number }).count ?? result.length,\n };\n };\n\n return createPostgresDriver(\n {\n execute: (query) => execute(client, query),\n connect: async () => {\n const reserved = await client.reserve();\n let released = false;\n\n return {\n execute: (query) => execute(reserved, query),\n release: (error) => {\n if (released) {\n return;\n }\n\n released = true;\n\n if (!error || transportFailure(error)) {\n reserved.release();\n\n return;\n }\n\n void reserved\n .unsafe(\"ROLLBACK\")\n .catch(() => {})\n .finally(() => reserved.release());\n },\n // Closing a reserved connection frees its pool slot for a fresh one.\n discard: async () => {\n if (!released) {\n released = true;\n await reserved.close().catch(() => {});\n }\n },\n };\n },\n cancel: async (pid) => {\n cancellation ??= new SQL({\n ...options,\n adapter: \"postgres\",\n bigint: true,\n max: 1,\n });\n\n await cancellation.unsafe(\"SELECT pg_cancel_backend($1)\", [pid]);\n },\n close: async () => {\n try {\n await client.close();\n } finally {\n await cancellation?.close();\n }\n },\n },\n profiler,\n );\n};\n"],"mappings":";;;;;;;;AAgBA,MAAM,oBAAoB,UAA0B;CAClD,MAAM,OAAiB,MAA6B;CAEpD,OAAO,OAAO,SAAS,YAAY,KAAK,WAAW,MAAM;AAC3D;AAEA,MAAa,YACX,eACmB;CACnB,MAAM,EAAE,UAAU,GAAG,YACnB,OAAO,eAAe,WAAW,EAAE,KAAK,WAAW,IAAI;CACzD,MAAM,SAAS,IAAI,IAAI;EAAE,GAAG;EAAS,SAAS;EAAY,QAAQ;CAAK,CAAC;CACxE,IAAI;CAEJ,MAAM,UAAU,OACd,YACA,UAC6B;EAC7B,MAAM,SAAS,MAAM,WAAW,OAC9B,MAAM,KACN,mBAAmB,MAAM,UAAU,CACrC;EAEA,OAAO;GACL,MAAM,MAAM,KAAK,MAAM;GACvB,cAAe,OAA8B,SAAS,OAAO;EAC/D;CACF;CAEA,OAAO,qBACL;EACE,UAAU,UAAU,QAAQ,QAAQ,KAAK;EACzC,SAAS,YAAY;GACnB,MAAM,WAAW,MAAM,OAAO,QAAQ;GACtC,IAAI,WAAW;GAEf,OAAO;IACL,UAAU,UAAU,QAAQ,UAAU,KAAK;IAC3C,UAAU,UAAU;KAClB,IAAI,UACF;KAGF,WAAW;KAEX,IAAI,CAAC,SAAS,iBAAiB,KAAK,GAAG;MACrC,SAAS,QAAQ;MAEjB;KACF;KAEA,SACG,OAAO,UAAU,CAAC,CAClB,YAAY,CAAC,CAAC,CAAC,CACf,cAAc,SAAS,QAAQ,CAAC;IACrC;IAEA,SAAS,YAAY;KACnB,IAAI,CAAC,UAAU;MACb,WAAW;MACX,MAAM,SAAS,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC;KACvC;IACF;GACF;EACF;EACA,QAAQ,OAAO,QAAQ;GACrB,iBAAiB,IAAI,IAAI;IACvB,GAAG;IACH,SAAS;IACT,QAAQ;IACR,KAAK;GACP,CAAC;GAED,MAAM,aAAa,OAAO,gCAAgC,CAAC,GAAG,CAAC;EACjE;EACA,OAAO,YAAY;GACjB,IAAI;IACF,MAAM,OAAO,MAAM;GACrB,UAAU;IACR,MAAM,cAAc,MAAM;GAC5B;EACF;CACF,GACA,QACF;AACF"}
1
+ {"version":3,"file":"bun.js","names":[],"sources":["../src/driver/bun.ts"],"sourcesContent":["/**\n * `symmetria/bun`: PostgreSQL adapter built on Bun's SQL pool.\n */\nimport { SQL } from \"bun\";\nimport { createPostgresDriver, type PostgresDriver } from \"./pool\";\nimport { postgresParameters } from \"./parameters\";\nimport type { CompiledQuery, ExecutionResult } from \"../query/plan/types\";\nimport type { QueryProfiler } from \"../observability/profiling\";\n\nexport type PostgresOptions = Omit<\n SQL.PostgresOrMySQLOptions,\n \"adapter\" | \"bigint\"\n> & { readonly profiler?: QueryProfiler | undefined };\nexport type { PostgresDriver } from \"./pool\";\n\n/** Bun reports socket-level failures with ERR_POSTGRES_* codes; server errors carry SQLSTATE codes. */\nconst transportFailure = (error: Error): boolean => {\n const code: unknown = (error as { code?: unknown }).code;\n\n return typeof code === \"string\" && code.startsWith(\"ERR_\");\n};\n\nexport const postgres = (\n connection: string | PostgresOptions,\n): PostgresDriver => {\n const { profiler, ...options } =\n typeof connection === \"string\" ? { url: connection } : connection;\n const client = new SQL({ ...options, adapter: \"postgres\", bigint: true });\n let cancellation: SQL | undefined;\n\n const execute = async (\n connection: SQL,\n query: CompiledQuery,\n ): Promise<ExecutionResult> => {\n const result = await connection.unsafe<Record<string, unknown>[]>(\n query.sql,\n postgresParameters(query.parameters),\n );\n\n return {\n rows: Array.from(result),\n affectedRows: (result as { count?: number }).count ?? result.length,\n };\n };\n\n return createPostgresDriver(\n {\n execute: (query) => execute(client, query),\n connect: async () => {\n const reserved = await client.reserve();\n let released = false;\n\n return {\n execute: (query) => execute(reserved, query),\n release: (error) => {\n if (released) {\n return;\n }\n\n released = true;\n\n if (!error || transportFailure(error)) {\n reserved.release();\n\n return;\n }\n\n void reserved\n .unsafe(\"ROLLBACK\")\n .catch(() => {})\n .finally(() => reserved.release());\n },\n // Closing a reserved connection frees its pool slot for a fresh one.\n discard: async () => {\n if (!released) {\n released = true;\n await reserved.close().catch(() => {});\n }\n },\n };\n },\n cancel: async (pid) => {\n cancellation ??= new SQL({\n ...options,\n adapter: \"postgres\",\n bigint: true,\n max: 1,\n });\n\n await cancellation.unsafe(\"SELECT pg_cancel_backend($1)\", [pid]);\n },\n close: async () => {\n try {\n await client.close();\n } finally {\n await cancellation?.close();\n }\n },\n // Bun.SQL opens ten connections unless told otherwise.\n max: options.max ?? 10,\n },\n profiler,\n );\n};\n"],"mappings":";;;;;;;;AAgBA,MAAM,oBAAoB,UAA0B;CAClD,MAAM,OAAiB,MAA6B;CAEpD,OAAO,OAAO,SAAS,YAAY,KAAK,WAAW,MAAM;AAC3D;AAEA,MAAa,YACX,eACmB;CACnB,MAAM,EAAE,UAAU,GAAG,YACnB,OAAO,eAAe,WAAW,EAAE,KAAK,WAAW,IAAI;CACzD,MAAM,SAAS,IAAI,IAAI;EAAE,GAAG;EAAS,SAAS;EAAY,QAAQ;CAAK,CAAC;CACxE,IAAI;CAEJ,MAAM,UAAU,OACd,YACA,UAC6B;EAC7B,MAAM,SAAS,MAAM,WAAW,OAC9B,MAAM,KACN,mBAAmB,MAAM,UAAU,CACrC;EAEA,OAAO;GACL,MAAM,MAAM,KAAK,MAAM;GACvB,cAAe,OAA8B,SAAS,OAAO;EAC/D;CACF;CAEA,OAAO,qBACL;EACE,UAAU,UAAU,QAAQ,QAAQ,KAAK;EACzC,SAAS,YAAY;GACnB,MAAM,WAAW,MAAM,OAAO,QAAQ;GACtC,IAAI,WAAW;GAEf,OAAO;IACL,UAAU,UAAU,QAAQ,UAAU,KAAK;IAC3C,UAAU,UAAU;KAClB,IAAI,UACF;KAGF,WAAW;KAEX,IAAI,CAAC,SAAS,iBAAiB,KAAK,GAAG;MACrC,SAAS,QAAQ;MAEjB;KACF;KAEA,SACG,OAAO,UAAU,CAAC,CAClB,YAAY,CAAC,CAAC,CAAC,CACf,cAAc,SAAS,QAAQ,CAAC;IACrC;IAEA,SAAS,YAAY;KACnB,IAAI,CAAC,UAAU;MACb,WAAW;MACX,MAAM,SAAS,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC;KACvC;IACF;GACF;EACF;EACA,QAAQ,OAAO,QAAQ;GACrB,iBAAiB,IAAI,IAAI;IACvB,GAAG;IACH,SAAS;IACT,QAAQ;IACR,KAAK;GACP,CAAC;GAED,MAAM,aAAa,OAAO,gCAAgC,CAAC,GAAG,CAAC;EACjE;EACA,OAAO,YAAY;GACjB,IAAI;IACF,MAAM,OAAO,MAAM;GACrB,UAAU;IACR,MAAM,cAAc,MAAM;GAC5B;EACF;EAEA,KAAK,QAAQ,OAAO;CACtB,GACA,QACF;AACF"}
package/dist/cohere.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { K as EmbeddingModel, cn as SelectedColumn, q as MeaningSearch } from "./types-pQCOrPh-.js";
1
+ import { K as EmbeddingModel, cn as SelectedColumn, q as MeaningSearch } from "./types-C2s_w1LW.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-BEk0Ff_y.js";
1
+ import { r as embedder } from "./search-jZqgEILM.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
  /**