@rocicorp/zero 1.2.0-canary.0 → 1.2.0-canary.1

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.
@@ -1,6 +1,6 @@
1
1
  var package_default = {
2
2
  name: "@rocicorp/zero",
3
- version: "1.2.0-canary.0",
3
+ version: "1.2.0-canary.1",
4
4
  description: "Zero is a web framework for serverless web development.",
5
5
  author: "Rocicorp, Inc.",
6
6
  repository: {
@@ -1 +1 @@
1
- {"version":3,"file":"package.js","names":[],"sources":["../../package.json"],"sourcesContent":["{\n \"name\": \"@rocicorp/zero\",\n \"version\": \"1.2.0-canary.0\",\n \"description\": \"Zero is a web framework for serverless web development.\",\n \"author\": \"Rocicorp, Inc.\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/rocicorp/mono.git\",\n \"directory\": \"packages/zero\"\n },\n \"license\": \"Apache-2.0\",\n \"homepage\": \"https://zero.rocicorp.dev\",\n \"bugs\": {\n \"url\": \"https://bugs.rocicorp.dev\"\n },\n \"scripts\": {\n \"build\": \"node --experimental-strip-types --no-warnings tool/build.ts\",\n \"build:watch\": \"node --experimental-strip-types --no-warnings tool/build.ts --watch\",\n \"check-types\": \"tsc -p tsconfig.client.json && tsc -p tsconfig.server.json\",\n \"check-types:client:watch\": \"tsc -p tsconfig.client.json --watch\",\n \"check-types:server:watch\": \"tsc -p tsconfig.server.json --watch\",\n \"format\": \"prettier --write .\",\n \"check-format\": \"prettier --check .\",\n \"lint\": \"oxlint --type-aware src/\",\n \"docs\": \"node --experimental-strip-types --no-warnings tool/generate-docs.ts\",\n \"docs:server\": \"node --watch --experimental-strip-types --no-warnings tool/generate-docs.ts --server\"\n },\n \"dependencies\": {\n \"@badrap/valita\": \"0.3.11\",\n \"@databases/escape-identifier\": \"^1.0.3\",\n \"@databases/sql\": \"^3.3.0\",\n \"@dotenvx/dotenvx\": \"^1.39.0\",\n \"@drdgvhbh/postgres-error-codes\": \"^0.0.6\",\n \"@fastify/cors\": \"^10.0.0\",\n \"@fastify/websocket\": \"^11.0.0\",\n \"@google-cloud/precise-date\": \"^4.0.0\",\n \"@opentelemetry/api\": \"^1.9.0\",\n \"@opentelemetry/api-logs\": \"^0.203.0\",\n \"@opentelemetry/auto-instrumentations-node\": \"^0.62.0\",\n \"@opentelemetry/exporter-metrics-otlp-http\": \"^0.203.0\",\n \"@opentelemetry/resources\": \"^2.0.1\",\n \"@opentelemetry/sdk-metrics\": \"^2.0.1\",\n \"@opentelemetry/sdk-node\": \"^0.203.0\",\n \"@opentelemetry/sdk-trace-node\": \"^2.0.1\",\n \"@postgresql-typed/oids\": \"^0.2.0\",\n \"@rocicorp/lock\": \"^1.0.4\",\n \"@rocicorp/logger\": \"^5.4.0\",\n \"@rocicorp/resolver\": \"^1.0.2\",\n \"@rocicorp/zero-sqlite3\": \"^1.0.15\",\n \"@standard-schema/spec\": \"^1.0.0\",\n \"@types/basic-auth\": \"^1.1.8\",\n \"@types/ws\": \"^8.5.12\",\n \"basic-auth\": \"^2.0.1\",\n \"chalk\": \"^5.3.0\",\n \"chalk-template\": \"^1.1.0\",\n \"chokidar\": \"^4.0.1\",\n \"cloudevents\": \"^10.0.0\",\n \"command-line-args\": \"^6.0.1\",\n \"command-line-usage\": \"^7.0.3\",\n \"compare-utf8\": \"^0.1.1\",\n \"defu\": \"^6.1.4\",\n \"eventemitter3\": \"^5.0.1\",\n \"fastify\": \"^5.0.0\",\n \"is-in-subnet\": \"^4.0.1\",\n \"jose\": \"^5.9.3\",\n \"js-xxhash\": \"^4.0.0\",\n \"json-custom-numbers\": \"^3.1.1\",\n \"kasi\": \"^1.1.0\",\n \"nanoid\": \"^5.1.2\",\n \"parse-prometheus-text-format\": \"^1.1.1\",\n \"pg-format\": \"npm:pg-format-fix@^1.0.5\",\n \"postgres\": \"3.4.7\",\n \"prettier\": \"^3.8.1\",\n \"semver\": \"^7.5.4\",\n \"tsx\": \"^4.21.0\",\n \"url-pattern\": \"^1.0.3\",\n \"urlpattern-polyfill\": \"^10.1.0\",\n \"ws\": \"^8.18.1\"\n },\n \"devDependencies\": {\n \"@op-engineering/op-sqlite\": \">=15\",\n \"@vitest/runner\": \"4.1.2\",\n \"analyze-query\": \"0.0.0\",\n \"ast-to-zql\": \"0.0.0\",\n \"expo-sqlite\": \">=15\",\n \"replicache\": \"15.2.1\",\n \"shared\": \"0.0.0\",\n \"syncpack\": \"^14.2.1\",\n \"typedoc\": \"^0.28.17\",\n \"typedoc-plugin-markdown\": \"^4.10.0\",\n \"typescript\": \"~5.9.3\",\n \"vite\": \"8.0.3\",\n \"vitest\": \"4.1.2\",\n \"zero-cache\": \"0.0.0\",\n \"zero-client\": \"0.0.0\",\n \"zero-pg\": \"0.0.0\",\n \"zero-protocol\": \"0.0.0\",\n \"zero-react\": \"0.0.0\",\n \"zero-server\": \"0.0.0\",\n \"zero-solid\": \"0.0.0\",\n \"zqlite\": \"0.0.0\"\n },\n \"peerDependencies\": {\n \"@op-engineering/op-sqlite\": \">=15\",\n \"expo-sqlite\": \">=15\"\n },\n \"peerDependenciesMeta\": {\n \"expo-sqlite\": {\n \"optional\": true\n },\n \"@op-engineering/op-sqlite\": {\n \"optional\": true\n }\n },\n \"type\": \"module\",\n \"main\": \"out/zero/src/zero.js\",\n \"module\": \"out/zero/src/zero.js\",\n \"types\": \"out/zero/src/zero.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./out/zero/src/zero.d.ts\",\n \"default\": \"./out/zero/src/zero.js\"\n },\n \"./bindings\": {\n \"types\": \"./out/zero/src/bindings.d.ts\",\n \"default\": \"./out/zero/src/bindings.js\"\n },\n \"./change-protocol/v0\": {\n \"types\": \"./out/zero/src/change-protocol/v0.d.ts\",\n \"default\": \"./out/zero/src/change-protocol/v0.js\"\n },\n \"./expo-sqlite\": {\n \"types\": \"./out/zero/src/expo-sqlite.d.ts\",\n \"default\": \"./out/zero/src/expo-sqlite.js\"\n },\n \"./op-sqlite\": {\n \"types\": \"./out/zero/src/op-sqlite.d.ts\",\n \"default\": \"./out/zero/src/op-sqlite.js\"\n },\n \"./pg\": {\n \"types\": \"./out/zero/src/pg.d.ts\",\n \"default\": \"./out/zero/src/pg.js\"\n },\n \"./react\": {\n \"types\": \"./out/zero/src/react.d.ts\",\n \"default\": \"./out/zero/src/react.js\"\n },\n \"./react-native\": {\n \"types\": \"./out/zero/src/react-native.d.ts\",\n \"default\": \"./out/zero/src/react-native.js\"\n },\n \"./server\": {\n \"types\": \"./out/zero/src/server.d.ts\",\n \"default\": \"./out/zero/src/server.js\"\n },\n \"./server/adapters/drizzle\": {\n \"types\": \"./out/zero/src/adapters/drizzle.d.ts\",\n \"default\": \"./out/zero/src/adapters/drizzle.js\"\n },\n \"./server/adapters/prisma\": {\n \"types\": \"./out/zero/src/adapters/prisma.d.ts\",\n \"default\": \"./out/zero/src/adapters/prisma.js\"\n },\n \"./server/adapters/pg\": {\n \"types\": \"./out/zero/src/adapters/pg.d.ts\",\n \"default\": \"./out/zero/src/adapters/pg.js\"\n },\n \"./server/adapters/postgresjs\": {\n \"types\": \"./out/zero/src/adapters/postgresjs.d.ts\",\n \"default\": \"./out/zero/src/adapters/postgresjs.js\"\n },\n \"./solid\": {\n \"types\": \"./out/zero/src/solid.d.ts\",\n \"default\": \"./out/zero/src/solid.js\"\n },\n \"./sqlite\": {\n \"types\": \"./out/zero/src/sqlite.d.ts\",\n \"default\": \"./out/zero/src/sqlite.js\"\n },\n \"./zqlite\": {\n \"types\": \"./out/zero/src/zqlite.d.ts\",\n \"default\": \"./out/zero/src/zqlite.js\"\n }\n },\n \"bin\": {\n \"zero-build-schema\": \"./out/zero/src/build-schema.js\",\n \"zero-cache\": \"./out/zero/src/cli.js\",\n \"zero-cache-dev\": \"./out/zero/src/zero-cache-dev.js\",\n \"zero-deploy-permissions\": \"./out/zero/src/deploy-permissions.js\",\n \"zero-out\": \"./out/zero/src/zero-out.js\",\n \"ast-to-zql\": \"./out/zero/src/ast-to-zql.js\",\n \"analyze-query\": \"./out/zero/src/analyze-query.js\",\n \"transform-query\": \"./out/zero/src/transform-query.js\"\n },\n \"engines\": {\n \"node\": \">=22\"\n },\n \"files\": [\n \"out\",\n \"!*.tsbuildinfo\"\n ]\n}"],"mappings":""}
1
+ {"version":3,"file":"package.js","names":[],"sources":["../../package.json"],"sourcesContent":["{\n \"name\": \"@rocicorp/zero\",\n \"version\": \"1.2.0-canary.1\",\n \"description\": \"Zero is a web framework for serverless web development.\",\n \"author\": \"Rocicorp, Inc.\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/rocicorp/mono.git\",\n \"directory\": \"packages/zero\"\n },\n \"license\": \"Apache-2.0\",\n \"homepage\": \"https://zero.rocicorp.dev\",\n \"bugs\": {\n \"url\": \"https://bugs.rocicorp.dev\"\n },\n \"scripts\": {\n \"build\": \"node --experimental-strip-types --no-warnings tool/build.ts\",\n \"build:watch\": \"node --experimental-strip-types --no-warnings tool/build.ts --watch\",\n \"check-types\": \"tsc -p tsconfig.client.json && tsc -p tsconfig.server.json\",\n \"check-types:client:watch\": \"tsc -p tsconfig.client.json --watch\",\n \"check-types:server:watch\": \"tsc -p tsconfig.server.json --watch\",\n \"format\": \"prettier --write .\",\n \"check-format\": \"prettier --check .\",\n \"lint\": \"oxlint --type-aware src/\",\n \"docs\": \"node --experimental-strip-types --no-warnings tool/generate-docs.ts\",\n \"docs:server\": \"node --watch --experimental-strip-types --no-warnings tool/generate-docs.ts --server\"\n },\n \"dependencies\": {\n \"@badrap/valita\": \"0.3.11\",\n \"@databases/escape-identifier\": \"^1.0.3\",\n \"@databases/sql\": \"^3.3.0\",\n \"@dotenvx/dotenvx\": \"^1.39.0\",\n \"@drdgvhbh/postgres-error-codes\": \"^0.0.6\",\n \"@fastify/cors\": \"^10.0.0\",\n \"@fastify/websocket\": \"^11.0.0\",\n \"@google-cloud/precise-date\": \"^4.0.0\",\n \"@opentelemetry/api\": \"^1.9.0\",\n \"@opentelemetry/api-logs\": \"^0.203.0\",\n \"@opentelemetry/auto-instrumentations-node\": \"^0.62.0\",\n \"@opentelemetry/exporter-metrics-otlp-http\": \"^0.203.0\",\n \"@opentelemetry/resources\": \"^2.0.1\",\n \"@opentelemetry/sdk-metrics\": \"^2.0.1\",\n \"@opentelemetry/sdk-node\": \"^0.203.0\",\n \"@opentelemetry/sdk-trace-node\": \"^2.0.1\",\n \"@postgresql-typed/oids\": \"^0.2.0\",\n \"@rocicorp/lock\": \"^1.0.4\",\n \"@rocicorp/logger\": \"^5.4.0\",\n \"@rocicorp/resolver\": \"^1.0.2\",\n \"@rocicorp/zero-sqlite3\": \"^1.0.15\",\n \"@standard-schema/spec\": \"^1.0.0\",\n \"@types/basic-auth\": \"^1.1.8\",\n \"@types/ws\": \"^8.5.12\",\n \"basic-auth\": \"^2.0.1\",\n \"chalk\": \"^5.3.0\",\n \"chalk-template\": \"^1.1.0\",\n \"chokidar\": \"^4.0.1\",\n \"cloudevents\": \"^10.0.0\",\n \"command-line-args\": \"^6.0.1\",\n \"command-line-usage\": \"^7.0.3\",\n \"compare-utf8\": \"^0.1.1\",\n \"defu\": \"^6.1.4\",\n \"eventemitter3\": \"^5.0.1\",\n \"fastify\": \"^5.0.0\",\n \"is-in-subnet\": \"^4.0.1\",\n \"jose\": \"^5.9.3\",\n \"js-xxhash\": \"^4.0.0\",\n \"json-custom-numbers\": \"^3.1.1\",\n \"kasi\": \"^1.1.0\",\n \"nanoid\": \"^5.1.2\",\n \"parse-prometheus-text-format\": \"^1.1.1\",\n \"pg-format\": \"npm:pg-format-fix@^1.0.5\",\n \"postgres\": \"3.4.7\",\n \"prettier\": \"^3.8.1\",\n \"semver\": \"^7.5.4\",\n \"tsx\": \"^4.21.0\",\n \"url-pattern\": \"^1.0.3\",\n \"urlpattern-polyfill\": \"^10.1.0\",\n \"ws\": \"^8.18.1\"\n },\n \"devDependencies\": {\n \"@op-engineering/op-sqlite\": \">=15\",\n \"@vitest/runner\": \"4.1.2\",\n \"analyze-query\": \"0.0.0\",\n \"ast-to-zql\": \"0.0.0\",\n \"expo-sqlite\": \">=15\",\n \"replicache\": \"15.2.1\",\n \"shared\": \"0.0.0\",\n \"syncpack\": \"^14.2.1\",\n \"typedoc\": \"^0.28.17\",\n \"typedoc-plugin-markdown\": \"^4.10.0\",\n \"typescript\": \"~5.9.3\",\n \"vite\": \"8.0.3\",\n \"vitest\": \"4.1.2\",\n \"zero-cache\": \"0.0.0\",\n \"zero-client\": \"0.0.0\",\n \"zero-pg\": \"0.0.0\",\n \"zero-protocol\": \"0.0.0\",\n \"zero-react\": \"0.0.0\",\n \"zero-server\": \"0.0.0\",\n \"zero-solid\": \"0.0.0\",\n \"zqlite\": \"0.0.0\"\n },\n \"peerDependencies\": {\n \"@op-engineering/op-sqlite\": \">=15\",\n \"expo-sqlite\": \">=15\"\n },\n \"peerDependenciesMeta\": {\n \"expo-sqlite\": {\n \"optional\": true\n },\n \"@op-engineering/op-sqlite\": {\n \"optional\": true\n }\n },\n \"type\": \"module\",\n \"main\": \"out/zero/src/zero.js\",\n \"module\": \"out/zero/src/zero.js\",\n \"types\": \"out/zero/src/zero.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./out/zero/src/zero.d.ts\",\n \"default\": \"./out/zero/src/zero.js\"\n },\n \"./bindings\": {\n \"types\": \"./out/zero/src/bindings.d.ts\",\n \"default\": \"./out/zero/src/bindings.js\"\n },\n \"./change-protocol/v0\": {\n \"types\": \"./out/zero/src/change-protocol/v0.d.ts\",\n \"default\": \"./out/zero/src/change-protocol/v0.js\"\n },\n \"./expo-sqlite\": {\n \"types\": \"./out/zero/src/expo-sqlite.d.ts\",\n \"default\": \"./out/zero/src/expo-sqlite.js\"\n },\n \"./op-sqlite\": {\n \"types\": \"./out/zero/src/op-sqlite.d.ts\",\n \"default\": \"./out/zero/src/op-sqlite.js\"\n },\n \"./pg\": {\n \"types\": \"./out/zero/src/pg.d.ts\",\n \"default\": \"./out/zero/src/pg.js\"\n },\n \"./react\": {\n \"types\": \"./out/zero/src/react.d.ts\",\n \"default\": \"./out/zero/src/react.js\"\n },\n \"./react-native\": {\n \"types\": \"./out/zero/src/react-native.d.ts\",\n \"default\": \"./out/zero/src/react-native.js\"\n },\n \"./server\": {\n \"types\": \"./out/zero/src/server.d.ts\",\n \"default\": \"./out/zero/src/server.js\"\n },\n \"./server/adapters/drizzle\": {\n \"types\": \"./out/zero/src/adapters/drizzle.d.ts\",\n \"default\": \"./out/zero/src/adapters/drizzle.js\"\n },\n \"./server/adapters/prisma\": {\n \"types\": \"./out/zero/src/adapters/prisma.d.ts\",\n \"default\": \"./out/zero/src/adapters/prisma.js\"\n },\n \"./server/adapters/pg\": {\n \"types\": \"./out/zero/src/adapters/pg.d.ts\",\n \"default\": \"./out/zero/src/adapters/pg.js\"\n },\n \"./server/adapters/postgresjs\": {\n \"types\": \"./out/zero/src/adapters/postgresjs.d.ts\",\n \"default\": \"./out/zero/src/adapters/postgresjs.js\"\n },\n \"./solid\": {\n \"types\": \"./out/zero/src/solid.d.ts\",\n \"default\": \"./out/zero/src/solid.js\"\n },\n \"./sqlite\": {\n \"types\": \"./out/zero/src/sqlite.d.ts\",\n \"default\": \"./out/zero/src/sqlite.js\"\n },\n \"./zqlite\": {\n \"types\": \"./out/zero/src/zqlite.d.ts\",\n \"default\": \"./out/zero/src/zqlite.js\"\n }\n },\n \"bin\": {\n \"zero-build-schema\": \"./out/zero/src/build-schema.js\",\n \"zero-cache\": \"./out/zero/src/cli.js\",\n \"zero-cache-dev\": \"./out/zero/src/zero-cache-dev.js\",\n \"zero-deploy-permissions\": \"./out/zero/src/deploy-permissions.js\",\n \"zero-out\": \"./out/zero/src/zero-out.js\",\n \"ast-to-zql\": \"./out/zero/src/ast-to-zql.js\",\n \"analyze-query\": \"./out/zero/src/analyze-query.js\",\n \"transform-query\": \"./out/zero/src/transform-query.js\"\n },\n \"engines\": {\n \"node\": \">=22\"\n },\n \"files\": [\n \"out\",\n \"!*.tsbuildinfo\"\n ]\n}"],"mappings":""}
@@ -2,7 +2,7 @@
2
2
  /**
3
3
  * The current version of Zero.
4
4
  */
5
- var version = "1.2.0-canary.0";
5
+ var version = "1.2.0-canary.1";
6
6
  //#endregion
7
7
  export { version };
8
8
 
@@ -1 +1 @@
1
- {"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../../../zqlite/src/db.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AACjD,OAAO,eAAe,EAAE,EAEtB,KAAK,SAAS,EACd,KAAK,SAAS,IAAI,gBAAgB,EACnC,MAAM,wBAAwB,CAAC;AAehC,qBAAa,QAAS,YAAW,UAAU;;gBAOvC,EAAE,EAAE,UAAU,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,eAAe,CAAC,OAAO,EACjC,kBAAkB,SAAM;IAgB1B,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS;IAc/B,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAIvB,MAAM,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,EAAE;IAQrC,OAAO,CAAC,sBAAsB,EAAE,MAAM;IAyCtC,UAAU,CAAC,MAAM,EAAE,OAAO;IAuB1B,KAAK,IAAI,IAAI;IAcb,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC;IAI9B,IAAI,IAAI,WAEP;IAED,IAAI,aAAa,YAEhB;IAED,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI;CAGzB;AAED,qBAAa,SAAS;;IAKpB,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAC,cAAc,CAAC,CAAC;IACtD,QAAQ,CAAC,eAAe,EAAE,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;gBAG5D,EAAE,EAAE,UAAU,EACd,KAAK,EAAE,UAAU,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AAE,MAAM,CAAC,GAAG,CAAC;IAI9B,IAAI,IAAI,WAEP;IAED,IAAI,aAAa,YAEhB;IAED,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI;CAGzB;AAED,qBAAa,SAAS;;IAKpB,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAC,cAAc,CAAC,CAAC;IACtD,QAAQ,CAAC,eAAe,EAAE,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;gBAG5D,EAAE,EAAE,UAAU,EACd,KAAK,EAAE,UAAU,EACjB,IAAI,EAAE,gBAAgB,EACtB,SAAS,EAAE,MAAM;IAUnB,YAAY,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI;IAKtC,GAAG,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,SAAS;IAYpC,GAAG,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC;IAY/B,GAAG,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE;IAYjC,OAAO,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,gBAAgB,CAAC,CAAC,CAAC;CAQtD;AAkFD;;;;GAIG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;CAAG"}
@@ -74,7 +74,7 @@ var Database = class {
74
74
  }
75
75
  close() {
76
76
  const start = Date.now();
77
- try {
77
+ if (!this.#db.readonly) try {
78
78
  this.#db.pragma("optimize");
79
79
  const elapsed = Date.now() - start;
80
80
  if (elapsed > 2) this.#lc.debug?.(`PRAGMA optimized (${elapsed} ms)`);
@@ -1 +1 @@
1
- {"version":3,"file":"db.js","names":["#db","#threshold","#lc","#pageSize","#run","#bytes","#stmt","#attrs","#it","#start","#sqliteRowTimeSum","#log"],"sources":["../../../../zqlite/src/db.ts"],"sourcesContent":["import {trace, type Attributes} from '@opentelemetry/api';\nimport type {LogContext} from '@rocicorp/logger';\nimport SQLite3Database, {\n SqliteError,\n type RunResult,\n type Statement as SQLite3Statement,\n} from '@rocicorp/zero-sqlite3';\nimport {manualSpan} from '../../otel/src/span.ts';\nimport {version} from '../../otel/src/version.ts';\n\nconst tracer = trace.getTracer('view-syncer', version);\n\n// https://www.sqlite.org/pragma.html#pragma_auto_vacuum\nconst AUTO_VACUUM_INCREMENTAL = 2;\n\nconst MB = 1024 * 1024;\n\nfunction mb(bytes: number): string {\n return (bytes / MB).toFixed(2);\n}\n\nexport class Database implements Disposable {\n readonly #db: SQLite3Database.Database;\n readonly #threshold: number;\n readonly #lc: LogContext;\n readonly #pageSize: number;\n\n constructor(\n lc: LogContext,\n path: string,\n options?: SQLite3Database.Options,\n slowQueryThreshold = 100,\n ) {\n try {\n this.#lc = lc.withContext('class', 'Database').withContext('path', path);\n this.#db = new SQLite3Database(path, options);\n this.#threshold = slowQueryThreshold;\n\n const [{page_size: pageSize}] = this.pragma<{page_size: number}>(\n 'page_size',\n );\n this.#pageSize = pageSize;\n } catch (cause) {\n throw new DatabaseInitError(String(cause), {cause});\n }\n }\n\n prepare(sql: string): Statement {\n return this.#run(\n 'prepare',\n sql,\n () =>\n new Statement(\n this.#lc.withContext('sql', sql),\n {class: 'Statement', sql},\n this.#db.prepare(sql),\n this.#threshold,\n ),\n );\n }\n\n exec(sql: string): void {\n this.#run('exec', sql, () => this.#db.exec(sql));\n }\n\n pragma<T = unknown>(sql: string): T[] {\n return this.#run<T[]>('pragma', sql, () => this.#db.pragma(sql) as T[]);\n }\n\n #bytes(pages: number) {\n return pages * this.#pageSize;\n }\n\n compact(freeableBytesThreshold: number) {\n const [{freelist_count: freelistCount}] = this.pragma<{\n freelist_count: number;\n }>('freelist_count');\n\n const freeable = this.#bytes(freelistCount);\n if (freeable < freeableBytesThreshold) {\n this.#lc.debug?.(\n `Not compacting ${this.#db.name}: ${mb(freeable)} freeable MB`,\n );\n return;\n }\n const [{auto_vacuum: autoVacuumMode}] = this.pragma<{auto_vacuum: number}>(\n 'auto_vacuum',\n );\n if (autoVacuumMode !== AUTO_VACUUM_INCREMENTAL) {\n this.#lc.warn?.(\n `Cannot compact ${mb(freeable)} MB of ` +\n `${this.#db.name} because AUTO_VACUUM mode is ${autoVacuumMode}.`,\n );\n return;\n }\n const start = Date.now();\n const [{page_count: pageCountBefore}] = this.pragma<{page_count: number}>(\n 'page_count',\n );\n\n this.pragma('incremental_vacuum');\n\n const [{page_count: pageCountAfter}] = this.pragma<{page_count: number}>(\n 'page_count',\n );\n\n this.#lc.info?.(\n `Compacted ${this.#db.name} from ` +\n `${mb(this.#bytes(pageCountBefore))} MB to ` +\n `${mb(this.#bytes(pageCountAfter))} MB ` +\n `(${Date.now() - start} ms)`,\n );\n }\n\n unsafeMode(unsafe: boolean) {\n this.#db.unsafeMode(unsafe);\n }\n\n #run<T>(method: string, sql: string, fn: () => T): T {\n const start = performance.now();\n try {\n return fn();\n } catch (e) {\n if (e instanceof SqliteError) {\n e.message += `: ${sql}`;\n }\n throw e;\n } finally {\n logIfSlow(\n this.#lc.withContext('method', method),\n performance.now() - start,\n {method},\n this.#threshold,\n );\n }\n }\n\n close(): void {\n const start = Date.now();\n try {\n this.#db.pragma('optimize');\n const elapsed = Date.now() - start;\n if (elapsed > 2) {\n this.#lc.debug?.(`PRAGMA optimized (${elapsed} ms)`);\n }\n } catch (e) {\n this.#lc.warn?.('error running PRAGMA optimize', e);\n }\n this.#db.close();\n }\n\n transaction<T>(fn: () => T): T {\n return this.#db.transaction(fn)();\n }\n\n get name() {\n return this.#db.name;\n }\n\n get inTransaction() {\n return this.#db.inTransaction;\n }\n\n [Symbol.dispose](): void {\n this.close();\n }\n}\n\nexport class Statement {\n readonly #stmt: SQLite3Statement;\n readonly #lc: LogContext;\n readonly #threshold: number;\n readonly #attrs: Attributes;\n readonly scanStatus: SQLite3Statement['scanStatusV2'];\n readonly scanStatusReset: SQLite3Statement['scanStatusReset'];\n\n constructor(\n lc: LogContext,\n attrs: Attributes,\n stmt: SQLite3Statement,\n threshold: number,\n ) {\n this.#lc = lc.withContext('class', 'Statement');\n this.#attrs = attrs;\n this.#stmt = stmt;\n this.#threshold = threshold;\n this.scanStatus = this.#stmt.scanStatusV2.bind(this.#stmt);\n this.scanStatusReset = this.#stmt.scanStatusReset.bind(this.#stmt);\n }\n\n safeIntegers(useBigInt: boolean): this {\n this.#stmt.safeIntegers(useBigInt);\n return this;\n }\n\n run(...params: unknown[]): RunResult {\n const start = performance.now();\n const ret = this.#stmt.run(...params);\n logIfSlow(\n this.#lc.withContext('method', 'run'),\n performance.now() - start,\n {...this.#attrs, method: 'run'},\n this.#threshold,\n );\n return ret;\n }\n\n get<T>(...params: unknown[]): T {\n const start = performance.now();\n const ret = this.#stmt.get(...params);\n logIfSlow(\n this.#lc.withContext('method', 'get'),\n performance.now() - start,\n {...this.#attrs, method: 'get'},\n this.#threshold,\n );\n return ret as T;\n }\n\n all<T>(...params: unknown[]): T[] {\n const start = performance.now();\n const ret = this.#stmt.all(...params);\n logIfSlow(\n this.#lc.withContext('method', 'all'),\n performance.now() - start,\n {...this.#attrs, method: 'all'},\n this.#threshold,\n );\n return ret as T[];\n }\n\n iterate<T>(...params: unknown[]): IterableIterator<T> {\n return new LoggingIterableIterator(\n this.#lc.withContext('method', 'iterate'),\n this.#attrs,\n this.#stmt.iterate(...params),\n this.#threshold,\n ) as IterableIterator<T>;\n }\n}\n\nclass LoggingIterableIterator<T> implements IterableIterator<T> {\n readonly #lc: LogContext;\n readonly #it: IterableIterator<T>;\n readonly #threshold: number;\n readonly #attrs: Attributes;\n #start: number;\n #sqliteRowTimeSum: number;\n\n constructor(\n lc: LogContext,\n attrs: Attributes,\n it: IterableIterator<T>,\n slowQueryThreshold: number,\n ) {\n this.#lc = lc;\n this.#attrs = attrs;\n this.#it = it;\n this.#start = performance.now();\n this.#threshold = slowQueryThreshold;\n this.#sqliteRowTimeSum = 0;\n }\n\n next(): IteratorResult<T> {\n const start = performance.now();\n const ret = this.#it.next();\n const elapsed = performance.now() - start;\n this.#sqliteRowTimeSum += elapsed;\n if (ret.done) {\n this.#log();\n }\n return ret;\n }\n\n #log() {\n logIfSlow(\n this.#lc.withContext('type', 'total'),\n performance.now() - this.#start,\n {...this.#attrs, type: 'total', method: 'iterate'},\n this.#threshold,\n );\n logIfSlow(\n this.#lc.withContext('type', 'sqlite'),\n this.#sqliteRowTimeSum,\n {...this.#attrs, type: 'sqlite', method: 'iterate'},\n this.#threshold,\n );\n }\n\n [Symbol.iterator](): IterableIterator<T> {\n return this;\n }\n\n return(): IteratorResult<T> {\n this.#log();\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n return this.#it.return?.() as any;\n }\n\n throw(e: unknown): IteratorResult<T> {\n this.#log();\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n return this.#it.throw?.(e) as any;\n }\n}\n\nfunction logIfSlow(\n lc: LogContext,\n elapsed: number,\n attrs: Attributes,\n threshold: number,\n): void {\n if (elapsed >= threshold) {\n for (const [key, value] of Object.entries(attrs)) {\n lc = lc.withContext(key, value);\n }\n lc.warn?.('Slow SQLite query', elapsed);\n manualSpan(tracer, 'db.slow-query', elapsed, attrs);\n }\n}\n\n/**\n * An error indicating that the Database failed to open. This essentially\n * wraps the TypeError thrown by the better-sqlite3 package with something\n * more specific.\n */\nexport class DatabaseInitError extends Error {}\n"],"mappings":";;;;;AAUA,IAAM,SAAS,MAAM,UAAU,eAAe,QAAQ;AAGtD,IAAM,0BAA0B;AAEhC,IAAM,KAAK,OAAO;AAElB,SAAS,GAAG,OAAuB;AACjC,SAAQ,QAAQ,IAAI,QAAQ,EAAE;;AAGhC,IAAa,WAAb,MAA4C;CAC1C;CACA;CACA;CACA;CAEA,YACE,IACA,MACA,SACA,qBAAqB,KACrB;AACA,MAAI;AACF,SAAA,KAAW,GAAG,YAAY,SAAS,WAAW,CAAC,YAAY,QAAQ,KAAK;AACxE,SAAA,KAAW,IAAI,gBAAgB,MAAM,QAAQ;AAC7C,SAAA,YAAkB;GAElB,MAAM,CAAC,EAAC,WAAW,c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AEb,SAAO;;CAGT,OAAO;AACL,YACE,MAAA,GAAS,YAAY,QAAQ,QAAQ,EACrC,YAAY,KAAK,GAAG,MAAA,OACpB;GAAC,GAAG,MAAA;GAAa,MAAM;GAAS,QAAQ;GAAU,EAClD,MAAA,UACD;AACD,YACE,MAAA,GAAS,YAAY,QAAQ,SAAS,EACtC,MAAA,kBACA;GAAC,GAAG,MAAA;GAAa,MAAM;GAAU,QAAQ;GAAU,EACnD,MAAA,UACD;;CAGH,CAAC,OAAO,YAAiC;AACvC,SAAO;;CAGT,SAA4B;AAC1B,QAAA,KAAW;AAEX,SAAO,MAAA,GAAS,UAAU;;CAG5B,MAAM,GAA+B;AACnC,QAAA,KAAW;AAEX,SAAO,MAAA,GAAS,QAAQ,EAAE;;;AAI9B,SAAS,UACP,IACA,SACA,OACA,WACM;AACN,KAAI,WAAW,WAAW;AACxB,OAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,MAAM,CAC9C,MAAK,GAAG,YAAY,KAAK,MAAM;AAEjC,KAAG,OAAO,qBAAqB,QAAQ;AACvC,aAAW,QAAQ,iBAAiB,SAAS,MAAM;;;;;;;;AASvD,IAAa,oBAAb,cAAuC,MAAM"}
1
+ {"version":3,"file":"db.js","names":["#db","#threshold","#lc","#pageSize","#run","#bytes","#stmt","#attrs","#it","#start","#sqliteRowTimeSum","#log"],"sources":["../../../../zqlite/src/db.ts"],"sourcesContent":["import {trace, type Attributes} from '@opentelemetry/api';\nimport type {LogContext} from '@rocicorp/logger';\nimport SQLite3Database, {\n SqliteError,\n type RunResult,\n type Statement as SQLite3Statement,\n} from '@rocicorp/zero-sqlite3';\nimport {manualSpan} from '../../otel/src/span.ts';\nimport {version} from '../../otel/src/version.ts';\n\nconst tracer = trace.getTracer('view-syncer', version);\n\n// https://www.sqlite.org/pragma.html#pragma_auto_vacuum\nconst AUTO_VACUUM_INCREMENTAL = 2;\n\nconst MB = 1024 * 1024;\n\nfunction mb(bytes: number): string {\n return (bytes / MB).toFixed(2);\n}\n\nexport class Database implements Disposable {\n readonly #db: SQLite3Database.Database;\n readonly #threshold: number;\n readonly #lc: LogContext;\n readonly #pageSize: number;\n\n constructor(\n lc: LogContext,\n path: string,\n options?: SQLite3Database.Options,\n slowQueryThreshold = 100,\n ) {\n try {\n this.#lc = lc.withContext('class', 'Database').withContext('path', path);\n this.#db = new SQLite3Database(path, options);\n this.#threshold = slowQueryThreshold;\n\n const [{page_size: pageSize}] = this.pragma<{page_size: number}>(\n 'page_size',\n );\n this.#pageSize = pageSize;\n } catch (cause) {\n throw new DatabaseInitError(String(cause), {cause});\n }\n }\n\n prepare(sql: string): Statement {\n return this.#run(\n 'prepare',\n sql,\n () =>\n new Statement(\n this.#lc.withContext('sql', sql),\n {class: 'Statement', sql},\n this.#db.prepare(sql),\n this.#threshold,\n ),\n );\n }\n\n exec(sql: string): void {\n this.#run('exec', sql, () => this.#db.exec(sql));\n }\n\n pragma<T = unknown>(sql: string): T[] {\n return this.#run<T[]>('pragma', sql, () => this.#db.pragma(sql) as T[]);\n }\n\n #bytes(pages: number) {\n return pages * this.#pageSize;\n }\n\n compact(freeableBytesThreshold: number) {\n const [{freelist_count: freelistCount}] = this.pragma<{\n freelist_count: number;\n }>('freelist_count');\n\n const freeable = this.#bytes(freelistCount);\n if (freeable < freeableBytesThreshold) {\n this.#lc.debug?.(\n `Not compacting ${this.#db.name}: ${mb(freeable)} freeable MB`,\n );\n return;\n }\n const [{auto_vacuum: autoVacuumMode}] = this.pragma<{auto_vacuum: number}>(\n 'auto_vacuum',\n );\n if (autoVacuumMode !== AUTO_VACUUM_INCREMENTAL) {\n this.#lc.warn?.(\n `Cannot compact ${mb(freeable)} MB of ` +\n `${this.#db.name} because AUTO_VACUUM mode is ${autoVacuumMode}.`,\n );\n return;\n }\n const start = Date.now();\n const [{page_count: pageCountBefore}] = this.pragma<{page_count: number}>(\n 'page_count',\n );\n\n this.pragma('incremental_vacuum');\n\n const [{page_count: pageCountAfter}] = this.pragma<{page_count: number}>(\n 'page_count',\n );\n\n this.#lc.info?.(\n `Compacted ${this.#db.name} from ` +\n `${mb(this.#bytes(pageCountBefore))} MB to ` +\n `${mb(this.#bytes(pageCountAfter))} MB ` +\n `(${Date.now() - start} ms)`,\n );\n }\n\n unsafeMode(unsafe: boolean) {\n this.#db.unsafeMode(unsafe);\n }\n\n #run<T>(method: string, sql: string, fn: () => T): T {\n const start = performance.now();\n try {\n return fn();\n } catch (e) {\n if (e instanceof SqliteError) {\n e.message += `: ${sql}`;\n }\n throw e;\n } finally {\n logIfSlow(\n this.#lc.withContext('method', method),\n performance.now() - start,\n {method},\n this.#threshold,\n );\n }\n }\n\n close(): void {\n const start = Date.now();\n if (!this.#db.readonly) {\n try {\n this.#db.pragma('optimize');\n const elapsed = Date.now() - start;\n if (elapsed > 2) {\n this.#lc.debug?.(`PRAGMA optimized (${elapsed} ms)`);\n }\n } catch (e) {\n this.#lc.warn?.('error running PRAGMA optimize', e);\n }\n }\n this.#db.close();\n }\n\n transaction<T>(fn: () => T): T {\n return this.#db.transaction(fn)();\n }\n\n get name() {\n return this.#db.name;\n }\n\n get inTransaction() {\n return this.#db.inTransaction;\n }\n\n [Symbol.dispose](): void {\n this.close();\n }\n}\n\nexport class Statement {\n readonly #stmt: SQLite3Statement;\n readonly #lc: LogContext;\n readonly #threshold: number;\n readonly #attrs: Attributes;\n readonly scanStatus: SQLite3Statement['scanStatusV2'];\n readonly scanStatusReset: SQLite3Statement['scanStatusReset'];\n\n constructor(\n lc: LogContext,\n attrs: Attributes,\n stmt: SQLite3Statement,\n threshold: number,\n ) {\n this.#lc = lc.withContext('class', 'Statement');\n this.#attrs = attrs;\n this.#stmt = stmt;\n this.#threshold = threshold;\n this.scanStatus = this.#stmt.scanStatusV2.bind(this.#stmt);\n this.scanStatusReset = this.#stmt.scanStatusReset.bind(this.#stmt);\n }\n\n safeIntegers(useBigInt: boolean): this {\n this.#stmt.safeIntegers(useBigInt);\n return this;\n }\n\n run(...params: unknown[]): RunResult {\n const start = performance.now();\n const ret = this.#stmt.run(...params);\n logIfSlow(\n this.#lc.withContext('method', 'run'),\n performance.now() - start,\n {...this.#attrs, method: 'run'},\n this.#threshold,\n );\n return ret;\n }\n\n get<T>(...params: unknown[]): T {\n const start = performance.now();\n const ret = this.#stmt.get(...params);\n logIfSlow(\n this.#lc.withContext('method', 'get'),\n performance.now() - start,\n {...this.#attrs, method: 'get'},\n this.#threshold,\n );\n return ret as T;\n }\n\n all<T>(...params: unknown[]): T[] {\n const start = performance.now();\n const ret = this.#stmt.all(...params);\n logIfSlow(\n this.#lc.withContext('method', 'all'),\n performance.now() - start,\n {...this.#attrs, method: 'all'},\n this.#threshold,\n );\n return ret as T[];\n }\n\n iterate<T>(...params: unknown[]): IterableIterator<T> {\n return new LoggingIterableIterator(\n this.#lc.withContext('method', 'iterate'),\n this.#attrs,\n this.#stmt.iterate(...params),\n this.#threshold,\n ) as IterableIterator<T>;\n }\n}\n\nclass LoggingIterableIterator<T> implements IterableIterator<T> {\n readonly #lc: LogContext;\n readonly #it: IterableIterator<T>;\n readonly #threshold: number;\n readonly #attrs: Attributes;\n #start: number;\n #sqliteRowTimeSum: number;\n\n constructor(\n lc: LogContext,\n attrs: Attributes,\n it: IterableIterator<T>,\n slowQueryThreshold: number,\n ) {\n this.#lc = lc;\n this.#attrs = attrs;\n this.#it = it;\n this.#start = performance.now();\n this.#threshold = slowQueryThreshold;\n this.#sqliteRowTimeSum = 0;\n }\n\n next(): IteratorResult<T> {\n const start = performance.now();\n const ret = this.#it.next();\n const elapsed = performance.now() - start;\n this.#sqliteRowTimeSum += elapsed;\n if (ret.done) {\n this.#log();\n }\n return ret;\n }\n\n #log() {\n logIfSlow(\n this.#lc.withContext('type', 'total'),\n performance.now() - this.#start,\n {...this.#attrs, type: 'total', method: 'iterate'},\n this.#threshold,\n );\n logIfSlow(\n this.#lc.withContext('type', 'sqlite'),\n this.#sqliteRowTimeSum,\n {...this.#attrs, type: 'sqlite', method: 'iterate'},\n this.#threshold,\n );\n }\n\n [Symbol.iterator](): IterableIterator<T> {\n return this;\n }\n\n return(): IteratorResult<T> {\n this.#log();\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n return this.#it.return?.() as any;\n }\n\n throw(e: unknown): IteratorResult<T> {\n this.#log();\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n return this.#it.throw?.(e) as any;\n }\n}\n\nfunction logIfSlow(\n lc: LogContext,\n elapsed: number,\n attrs: Attributes,\n threshold: number,\n): void {\n if (elapsed >= threshold) {\n for (const [key, value] of Object.entries(attrs)) {\n lc = lc.withContext(key, value);\n }\n lc.warn?.('Slow SQLite query', elapsed);\n manualSpan(tracer, 'db.slow-query', elapsed, attrs);\n }\n}\n\n/**\n * An error indicating that the Database failed to open. This essentially\n * wraps the TypeError thrown by the better-sqlite3 package with something\n * more specific.\n */\nexport class DatabaseInitError extends Error {}\n"],"mappings":";;;;;AAUA,IAAM,SAAS,MAAM,UAAU,eAAe,QAAQ;AAGtD,IAAM,0BAA0B;AAEhC,IAAM,KAAK,OAAO;AAElB,SAAS,GAAG,OAAuB;AACjC,SAAQ,QAAQ,IAAI,QAAQ,EAAE;;AAGhC,IAAa,WAAb,MAA4C;CAC1C;CACA;CACA;CACA;CAEA,YACE,IACA,MACA,SACA,qBAAqB,KACrB;AACA,MAAI;AACF,SAAA,KAAW,GAAG,YAAY,SAAS,WAAW,CAAC,YAAY,QAAQ,KAAK;AACxE,SAAA,KAAW,IAAI,gBAAgB,MAAM,QAAQ;AAC7C,SAAA,YAAkB;GAElB,MAAM,CAAC,EAAC,WAAW,cAAa,KAAK,OACnC,YACD;AACD,SAAA,WAAiB;WACV,OAAO;AACd,SAAM,IAAI,kBAAkB,OAAO,MAAM,EAAE,EAAC,OAAM,CAAC;;;CAIvD,QAAQ,KAAwB;AAC9B,SAAO,MAAA,IACL,WACA,WAEE,IAAI,UACF,MAAA,GAAS,YAAY,OAAO,IAAI,EAChC;GAAC,OAAO;GAAa;GAAI,EACzB,MAA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,kBACA;GAAC,GAAG,MAAA;GAAa,MAAM;GAAU,QAAQ;GAAU,EACnD,MAAA,UACD;;CAGH,CAAC,OAAO,YAAiC;AACvC,SAAO;;CAGT,SAA4B;AAC1B,QAAA,KAAW;AAEX,SAAO,MAAA,GAAS,UAAU;;CAG5B,MAAM,GAA+B;AACnC,QAAA,KAAW;AAEX,SAAO,MAAA,GAAS,QAAQ,EAAE;;;AAI9B,SAAS,UACP,IACA,SACA,OACA,WACM;AACN,KAAI,WAAW,WAAW;AACxB,OAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,MAAM,CAC9C,MAAK,GAAG,YAAY,KAAK,MAAM;AAEjC,KAAG,OAAO,qBAAqB,QAAQ;AACvC,aAAW,QAAQ,iBAAiB,SAAS,MAAM;;;;;;;;AASvD,IAAa,oBAAb,cAAuC,MAAM"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rocicorp/zero",
3
- "version": "1.2.0-canary.0",
3
+ "version": "1.2.0-canary.1",
4
4
  "description": "Zero is a web framework for serverless web development.",
5
5
  "author": "Rocicorp, Inc.",
6
6
  "repository": {