@rocicorp/zero 0.24.2025093001 → 0.24.2025100800

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 (55) hide show
  1. package/out/{chunk-QCPDXNFF.js → chunk-ASFIXQH7.js} +2 -4
  2. package/out/chunk-ASFIXQH7.js.map +7 -0
  3. package/out/{chunk-L2ZHMO4E.js → chunk-QROPZW7G.js} +2 -2
  4. package/out/chunk-X7SAVR5O.js +220 -0
  5. package/out/chunk-X7SAVR5O.js.map +7 -0
  6. package/out/react-native.js +5 -208
  7. package/out/react-native.js.map +3 -3
  8. package/out/react.js +1 -1
  9. package/out/replicache/src/sqlite.d.ts +3 -0
  10. package/out/replicache/src/sqlite.d.ts.map +1 -0
  11. package/out/solid.js +2 -2
  12. package/out/sqlite.js +14 -0
  13. package/out/sqlite.js.map +7 -0
  14. package/out/zero/package.json +14 -10
  15. package/out/zero/src/adapters/drizzle.d.ts +2 -0
  16. package/out/zero/src/adapters/drizzle.d.ts.map +1 -0
  17. package/out/zero/src/adapters/drizzle.js +2 -0
  18. package/out/zero/src/adapters/drizzle.js.map +1 -0
  19. package/out/zero/src/adapters/pg.d.ts +2 -0
  20. package/out/zero/src/adapters/pg.d.ts.map +1 -0
  21. package/out/zero/src/adapters/pg.js +2 -0
  22. package/out/zero/src/adapters/pg.js.map +1 -0
  23. package/out/zero/src/sqlite.d.ts +2 -0
  24. package/out/zero/src/sqlite.d.ts.map +1 -0
  25. package/out/zero/src/zero-cache-dev.js +10 -4
  26. package/out/zero/src/zero-cache-dev.js.map +1 -1
  27. package/out/zero-cache/src/scripts/deploy-permissions.js +1 -1
  28. package/out/zero-cache/src/services/change-source/pg/logical-replication/stream.d.ts.map +1 -1
  29. package/out/zero-cache/src/services/change-source/pg/logical-replication/stream.js +15 -14
  30. package/out/zero-cache/src/services/change-source/pg/logical-replication/stream.js.map +1 -1
  31. package/out/zero-client/src/client/zero.d.ts.map +1 -1
  32. package/out/zero-server/src/adapters/drizzle.d.ts +64 -0
  33. package/out/zero-server/src/adapters/drizzle.d.ts.map +1 -0
  34. package/out/zero-server/src/adapters/drizzle.js +109 -0
  35. package/out/zero-server/src/adapters/drizzle.js.map +1 -0
  36. package/out/zero-server/src/adapters/pg.d.ts +53 -0
  37. package/out/zero-server/src/adapters/pg.d.ts.map +1 -0
  38. package/out/zero-server/src/adapters/pg.js +79 -0
  39. package/out/zero-server/src/adapters/pg.js.map +1 -0
  40. package/out/zero-server/src/adapters/postgresjs.d.ts +41 -12
  41. package/out/zero-server/src/adapters/postgresjs.d.ts.map +1 -1
  42. package/out/zero-server/src/adapters/postgresjs.js +27 -10
  43. package/out/zero-server/src/adapters/postgresjs.js.map +1 -1
  44. package/out/zero.js +2 -2
  45. package/package.json +14 -10
  46. package/out/chunk-QCPDXNFF.js.map +0 -7
  47. package/out/zero/src/adapters/drizzle-pg.d.ts +0 -2
  48. package/out/zero/src/adapters/drizzle-pg.d.ts.map +0 -1
  49. package/out/zero/src/adapters/drizzle-pg.js +0 -2
  50. package/out/zero/src/adapters/drizzle-pg.js.map +0 -1
  51. package/out/zero-server/src/adapters/drizzle-pg.d.ts +0 -22
  52. package/out/zero-server/src/adapters/drizzle-pg.d.ts.map +0 -1
  53. package/out/zero-server/src/adapters/drizzle-pg.js +0 -39
  54. package/out/zero-server/src/adapters/drizzle-pg.js.map +0 -1
  55. /package/out/{chunk-L2ZHMO4E.js.map → chunk-QROPZW7G.js.map} +0 -0
@@ -1,25 +1,54 @@
1
1
  import type { Schema } from '../../../zero-schema/src/builder/schema-builder.ts';
2
- import type { DBConnection, DBTransaction } from '../../../zql/src/mutate/custom.ts';
2
+ import type { DBConnection, DBTransaction, Row } from '../../../zql/src/mutate/custom.ts';
3
3
  import postgres from 'postgres';
4
4
  import { ZQLDatabase } from '../zql-database.ts';
5
- export declare class PostgresJSConnection<T extends Record<string, unknown>> implements DBConnection<postgres.TransactionSql<T>> {
5
+ /**
6
+ * Helper type for the wrapped transaction used by postgres.js.
7
+ *
8
+ * @typeParam T - The row-shape context bound to the postgres.js client.
9
+ * @remarks Use with `ServerTransaction` as `ServerTransaction<Schema, PostgresJsTransaction>`.
10
+ */
11
+ export type PostgresJsTransaction<T extends Record<string, unknown> = Record<string, unknown>> = postgres.TransactionSql<T>;
12
+ export declare class PostgresJSConnection<T extends Record<string, unknown>> implements DBConnection<PostgresJsTransaction<T>> {
6
13
  #private;
7
14
  constructor(pg: postgres.Sql<T>);
8
- transaction<TRet>(fn: (tx: DBTransaction<postgres.TransactionSql<T>>) => Promise<TRet>): Promise<TRet>;
15
+ transaction<TRet>(fn: (tx: DBTransaction<PostgresJsTransaction<T>>) => Promise<TRet>): Promise<TRet>;
16
+ }
17
+ export declare class PostgresJsTransactionInternal<T extends Record<string, unknown>> implements DBTransaction<PostgresJsTransaction<T>> {
18
+ readonly wrappedTransaction: PostgresJsTransaction<T>;
19
+ constructor(pgTx: PostgresJsTransaction<T>);
20
+ query(sql: string, params: unknown[]): Promise<Row[]>;
9
21
  }
10
22
  /**
11
- * Example usage:
23
+ * Wrap a `postgres` client for Zero ZQL.
24
+ *
25
+ * Provides ZQL querying plus access to the underlying postgres.js transaction.
26
+ * Use {@link PostgresJsTransaction} to type your server mutator transaction.
27
+ *
28
+ * @param schema - Zero schema.
29
+ * @param pg - `postgres` client or connection string.
30
+ *
31
+ * @example
12
32
  * ```ts
13
33
  * import postgres from 'postgres';
14
- * const processor = new PushProcessor(
15
- * zeroPostgresJS(schema, postgres(process.env.ZERO_UPSTREAM_DB as string)),
16
- * );
17
34
  *
18
- * // within your custom mutators you can do:
19
- * const tx = tx.wrappedTransaction();
20
- * // to get ahold of the underlying postgres.js transaction
21
- * // and then drop down to raw SQL if needed.
35
+ * const sql = postgres(process.env.ZERO_UPSTREAM_DB!);
36
+ * const zql = zeroPostgresJS(schema, sql);
37
+ *
38
+ * // Define the server mutator transaction type using the helper
39
+ * type ServerTx = ServerTransaction<
40
+ * Schema,
41
+ * PostgresJsTransaction
42
+ * >;
43
+ *
44
+ * async function createUser(
45
+ * tx: ServerTx,
46
+ * {id, name}: {id: string; name: string},
47
+ * ) {
48
+ * await tx.dbTransaction.wrappedTransaction
49
+ * .unsafe('INSERT INTO "user" (id, name) VALUES ($1, $2)', [id, name]);
50
+ * }
22
51
  * ```
23
52
  */
24
- export declare function zeroPostgresJS<S extends Schema, T extends Record<string, unknown> = Record<string, unknown>>(schema: S, pg: postgres.Sql<T> | string): ZQLDatabase<S, postgres.TransactionSql<T>>;
53
+ export declare function zeroPostgresJS<S extends Schema, T extends Record<string, unknown> = Record<string, unknown>>(schema: S, pg: postgres.Sql<T> | string): ZQLDatabase<S, PostgresJsTransaction<T>>;
25
54
  //# sourceMappingURL=postgresjs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"postgresjs.d.ts","sourceRoot":"","sources":["../../../../../zero-server/src/adapters/postgresjs.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,oDAAoD,CAAC;AAC/E,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EAEd,MAAM,mCAAmC,CAAC;AAC3C,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAC,WAAW,EAAC,MAAM,oBAAoB,CAAC;AAE/C,qBAAa,oBAAoB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CACjE,YAAW,YAAY,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;;gBAGvC,EAAE,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;IAI/B,WAAW,CAAC,IAAI,EACd,EAAE,EAAE,CAAC,EAAE,EAAE,aAAa,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,GACnE,OAAO,CAAC,IAAI,CAAC;CAGjB;AAeD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAC5B,CAAC,SAAS,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B,EAAE,qBAAqB,CAAC,CAAC,CAAC,CAAC;gBAC1C,IAAI,EAAE,qBAAqB,CAAC,CAAC,CAAC;IAI1C,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;CAGtD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,cAAc,CAC5B,CAAC,SAAS,MAAM,EAChB,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC3D,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,4CAKxC"}
@@ -6,10 +6,10 @@ export class PostgresJSConnection {
6
6
  this.#pg = pg;
7
7
  }
8
8
  transaction(fn) {
9
- return this.#pg.begin(pgTx => fn(new Transaction(pgTx)));
9
+ return this.#pg.begin(pgTx => fn(new PostgresJsTransactionInternal(pgTx)));
10
10
  }
11
11
  }
12
- class Transaction {
12
+ export class PostgresJsTransactionInternal {
13
13
  wrappedTransaction;
14
14
  constructor(pgTx) {
15
15
  this.wrappedTransaction = pgTx;
@@ -19,17 +19,34 @@ class Transaction {
19
19
  }
20
20
  }
21
21
  /**
22
- * Example usage:
22
+ * Wrap a `postgres` client for Zero ZQL.
23
+ *
24
+ * Provides ZQL querying plus access to the underlying postgres.js transaction.
25
+ * Use {@link PostgresJsTransaction} to type your server mutator transaction.
26
+ *
27
+ * @param schema - Zero schema.
28
+ * @param pg - `postgres` client or connection string.
29
+ *
30
+ * @example
23
31
  * ```ts
24
32
  * import postgres from 'postgres';
25
- * const processor = new PushProcessor(
26
- * zeroPostgresJS(schema, postgres(process.env.ZERO_UPSTREAM_DB as string)),
27
- * );
28
33
  *
29
- * // within your custom mutators you can do:
30
- * const tx = tx.wrappedTransaction();
31
- * // to get ahold of the underlying postgres.js transaction
32
- * // and then drop down to raw SQL if needed.
34
+ * const sql = postgres(process.env.ZERO_UPSTREAM_DB!);
35
+ * const zql = zeroPostgresJS(schema, sql);
36
+ *
37
+ * // Define the server mutator transaction type using the helper
38
+ * type ServerTx = ServerTransaction<
39
+ * Schema,
40
+ * PostgresJsTransaction
41
+ * >;
42
+ *
43
+ * async function createUser(
44
+ * tx: ServerTx,
45
+ * {id, name}: {id: string; name: string},
46
+ * ) {
47
+ * await tx.dbTransaction.wrappedTransaction
48
+ * .unsafe('INSERT INTO "user" (id, name) VALUES ($1, $2)', [id, name]);
49
+ * }
33
50
  * ```
34
51
  */
35
52
  export function zeroPostgresJS(schema, pg) {
@@ -1 +1 @@
1
- {"version":3,"file":"postgresjs.js","sourceRoot":"","sources":["../../../../../zero-server/src/adapters/postgresjs.ts"],"names":[],"mappings":"AAOA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAC,WAAW,EAAC,MAAM,oBAAoB,CAAC;AAE/C,MAAM,OAAO,oBAAoB;IAGtB,GAAG,CAAkB;IAC9B,YAAY,EAAmB;QAC7B,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC;IAChB,CAAC;IAED,WAAW,CACT,EAAoE;QAEpE,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC,CAAkB,CAAC;IAC5E,CAAC;CACF;AAED,MAAM,WAAW;IAGN,kBAAkB,CAA6B;IACxD,YAAY,IAAgC;QAC1C,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC;IACjC,CAAC;IAED,KAAK,CAAC,GAAW,EAAE,MAAiB;QAClC,OAAO,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,GAAG,EAAE,MAAqB,CAAC,CAAC;IACpE,CAAC;CACF;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,cAAc,CAG5B,MAAS,EAAE,EAA4B;IAC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C,CAAC;AAC/D,CAAC"}
package/out/zero.js CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  syncedQuery,
10
10
  syncedQueryWithContext,
11
11
  withValidation
12
- } from "./chunk-L2ZHMO4E.js";
12
+ } from "./chunk-QROPZW7G.js";
13
13
  import {
14
14
  IDBNotFoundError,
15
15
  TransactionClosedError,
@@ -29,7 +29,7 @@ import {
29
29
  transformRequestMessageSchema,
30
30
  transformResponseMessageSchema,
31
31
  update_needed_reason_type_enum_exports
32
- } from "./chunk-QCPDXNFF.js";
32
+ } from "./chunk-ASFIXQH7.js";
33
33
  import "./chunk-ASRS2LFV.js";
34
34
  import {
35
35
  applyChange
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rocicorp/zero",
3
- "version": "0.24.2025093001",
3
+ "version": "0.24.2025100800",
4
4
  "description": "Zero is a web framework for serverless web development.",
5
5
  "author": "Rocicorp, Inc.",
6
6
  "repository": {
@@ -47,7 +47,7 @@
47
47
  "@rocicorp/lock": "^1.0.4",
48
48
  "@rocicorp/logger": "^5.4.0",
49
49
  "@rocicorp/resolver": "^1.0.2",
50
- "@rocicorp/zero-sqlite3": "^1.0.8",
50
+ "@rocicorp/zero-sqlite3": "^1.0.9",
51
51
  "@types/basic-auth": "^1.1.8",
52
52
  "basic-auth": "^2.0.1",
53
53
  "chalk": "^5.3.0",
@@ -76,7 +76,6 @@
76
76
  "ws": "^8.18.1"
77
77
  },
78
78
  "devDependencies": {
79
- "@rocicorp/eslint-config": "^0.7.0",
80
79
  "@rocicorp/prettier-config": "^0.3.0",
81
80
  "@vitest/runner": "3.2.4",
82
81
  "esbuild": "^0.25.0",
@@ -114,12 +113,16 @@
114
113
  "default": "./out/zero/src/server.js"
115
114
  },
116
115
  "./server/adapters/postgresjs": {
117
- "types": "./out/zero-server/src/adapters/postgres.d.ts",
116
+ "types": "./out/zero-server/src/adapters/postgresjs.d.ts",
118
117
  "default": "./out/zero/src/adapters/postgresjs.js"
119
118
  },
120
- "./server/adapters/drizzle-pg": {
121
- "types": "./out/zero-server/src/adapters/drizzle-pg.d.ts",
122
- "default": "./out/zero/src/adapters/drizzle-pg.js"
119
+ "./server/adapters/pg": {
120
+ "types": "./out/zero-server/src/adapters/pg.d.ts",
121
+ "default": "./out/zero/src/adapters/pg.js"
122
+ },
123
+ "./server/adapters/drizzle": {
124
+ "types": "./out/zero-server/src/adapters/drizzle.d.ts",
125
+ "default": "./out/zero/src/adapters/drizzle.js"
123
126
  },
124
127
  "./solid": {
125
128
  "types": "./out/zero-solid/src/mod.d.ts",
@@ -140,6 +143,10 @@
140
143
  "./react-native": {
141
144
  "types": "./out/zero-react-native/src/mod.d.ts",
142
145
  "default": "./out/react-native.js"
146
+ },
147
+ "./sqlite": {
148
+ "types": "./out/zero/src/sqlite.d.ts",
149
+ "default": "./out/sqlite.js"
143
150
  }
144
151
  },
145
152
  "bin": {
@@ -158,8 +165,5 @@
158
165
  "out",
159
166
  "!*.tsbuildinfo"
160
167
  ],
161
- "eslintConfig": {
162
- "extends": "../../eslint-config.json"
163
- },
164
168
  "prettier": "@rocicorp/prettier-config"
165
169
  }