@rocicorp/zero 0.17.2025022800 → 0.17.2025030600
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/out/{chunk-5BT5TJFM.js → chunk-XXZWDMNW.js} +4025 -531
- package/out/chunk-XXZWDMNW.js.map +7 -0
- package/out/react.js +19 -11
- package/out/react.js.map +2 -2
- package/out/shared/src/set-utils.d.ts +1 -1
- package/out/shared/src/set-utils.js +1 -1
- package/out/solid.js +9 -5
- package/out/solid.js.map +2 -2
- package/out/zero-cache/src/auth/read-authorizer.d.ts.map +1 -1
- package/out/zero-cache/src/auth/read-authorizer.js +0 -1
- package/out/zero-cache/src/auth/read-authorizer.js.map +1 -1
- package/out/zero-cache/src/config/zero-config.d.ts +46 -13
- package/out/zero-cache/src/config/zero-config.d.ts.map +1 -1
- package/out/zero-cache/src/config/zero-config.js +76 -32
- package/out/zero-cache/src/config/zero-config.js.map +1 -1
- package/out/zero-cache/src/db/migration-lite.d.ts.map +1 -1
- package/out/zero-cache/src/db/migration-lite.js +12 -6
- package/out/zero-cache/src/db/migration-lite.js.map +1 -1
- package/out/zero-cache/src/db/migration.d.ts +1 -1
- package/out/zero-cache/src/db/migration.d.ts.map +1 -1
- package/out/zero-cache/src/db/migration.js +16 -5
- package/out/zero-cache/src/db/migration.js.map +1 -1
- package/out/zero-cache/src/db/pg-to-lite.d.ts +4 -0
- package/out/zero-cache/src/db/pg-to-lite.d.ts.map +1 -1
- package/out/zero-cache/src/db/pg-to-lite.js +14 -4
- package/out/zero-cache/src/db/pg-to-lite.js.map +1 -1
- package/out/zero-cache/src/scripts/deploy-permissions.js +35 -20
- package/out/zero-cache/src/scripts/deploy-permissions.js.map +1 -1
- package/out/zero-cache/src/scripts/permissions.d.ts +17 -0
- package/out/zero-cache/src/scripts/permissions.d.ts.map +1 -1
- package/out/zero-cache/src/scripts/permissions.js +3 -1
- package/out/zero-cache/src/scripts/permissions.js.map +1 -1
- package/out/zero-cache/src/server/change-streamer.d.ts.map +1 -1
- package/out/zero-cache/src/server/change-streamer.js +11 -10
- package/out/zero-cache/src/server/change-streamer.js.map +1 -1
- package/out/zero-cache/src/server/main.d.ts.map +1 -1
- package/out/zero-cache/src/server/main.js +11 -4
- package/out/zero-cache/src/server/main.js.map +1 -1
- package/out/zero-cache/src/server/multi/config.d.ts +23 -9
- package/out/zero-cache/src/server/multi/config.d.ts.map +1 -1
- package/out/zero-cache/src/server/multi/config.js +2 -4
- package/out/zero-cache/src/server/multi/config.js.map +1 -1
- package/out/zero-cache/src/server/multi/run-worker.d.ts.map +1 -1
- package/out/zero-cache/src/server/multi/run-worker.js +1 -3
- package/out/zero-cache/src/server/multi/run-worker.js.map +1 -1
- package/out/zero-cache/src/server/replicator.js +1 -1
- package/out/zero-cache/src/server/replicator.js.map +1 -1
- package/out/zero-cache/src/server/syncer.d.ts.map +1 -1
- package/out/zero-cache/src/server/syncer.js +14 -12
- package/out/zero-cache/src/server/syncer.js.map +1 -1
- package/out/zero-cache/src/services/change-source/custom/change-source.d.ts +5 -5
- package/out/zero-cache/src/services/change-source/custom/change-source.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/custom/change-source.js +21 -19
- package/out/zero-cache/src/services/change-source/custom/change-source.js.map +1 -1
- package/out/zero-cache/src/services/change-source/custom/sync-schema.d.ts +2 -2
- package/out/zero-cache/src/services/change-source/custom/sync-schema.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/custom/sync-schema.js +2 -2
- package/out/zero-cache/src/services/change-source/custom/sync-schema.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/change-source.d.ts +5 -5
- package/out/zero-cache/src/services/change-source/pg/change-source.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/change-source.js +41 -34
- package/out/zero-cache/src/services/change-source/pg/change-source.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/decommission.d.ts +4 -0
- package/out/zero-cache/src/services/change-source/pg/decommission.d.ts.map +1 -0
- package/out/zero-cache/src/services/change-source/pg/decommission.js +21 -0
- package/out/zero-cache/src/services/change-source/pg/decommission.js.map +1 -0
- package/out/zero-cache/src/services/change-source/pg/initial-sync.d.ts +4 -3
- package/out/zero-cache/src/services/change-source/pg/initial-sync.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/initial-sync.js +45 -25
- package/out/zero-cache/src/services/change-source/pg/initial-sync.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/ddl.d.ts +3 -2
- package/out/zero-cache/src/services/change-source/pg/schema/ddl.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/ddl.js +35 -16
- package/out/zero-cache/src/services/change-source/pg/schema/ddl.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/init.d.ts +4 -3
- package/out/zero-cache/src/services/change-source/pg/schema/init.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/init.js +53 -13
- package/out/zero-cache/src/services/change-source/pg/schema/init.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/published.d.ts +2 -2
- package/out/zero-cache/src/services/change-source/pg/schema/published.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/published.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/shard.d.ts +10 -12
- package/out/zero-cache/src/services/change-source/pg/schema/shard.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/shard.js +52 -53
- package/out/zero-cache/src/services/change-source/pg/schema/shard.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/sync-schema.d.ts +2 -2
- package/out/zero-cache/src/services/change-source/pg/sync-schema.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/sync-schema.js +11 -2
- package/out/zero-cache/src/services/change-source/pg/sync-schema.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/change-streamer-service.d.ts +3 -2
- package/out/zero-cache/src/services/change-streamer/change-streamer-service.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/change-streamer-service.js +11 -11
- package/out/zero-cache/src/services/change-streamer/change-streamer-service.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/schema/init.d.ts +3 -2
- package/out/zero-cache/src/services/change-streamer/schema/init.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/schema/init.js +25 -14
- package/out/zero-cache/src/services/change-streamer/schema/init.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/schema/tables.d.ts +6 -5
- package/out/zero-cache/src/services/change-streamer/schema/tables.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/schema/tables.js +28 -26
- package/out/zero-cache/src/services/change-streamer/schema/tables.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/storer.d.ts +4 -2
- package/out/zero-cache/src/services/change-streamer/storer.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/storer.js +19 -9
- package/out/zero-cache/src/services/change-streamer/storer.js.map +1 -1
- package/out/zero-cache/src/services/litestream/commands.d.ts +1 -1
- package/out/zero-cache/src/services/litestream/commands.d.ts.map +1 -1
- package/out/zero-cache/src/services/litestream/commands.js +3 -3
- package/out/zero-cache/src/services/litestream/commands.js.map +1 -1
- package/out/zero-cache/src/services/mutagen/mutagen.d.ts +3 -2
- package/out/zero-cache/src/services/mutagen/mutagen.d.ts.map +1 -1
- package/out/zero-cache/src/services/mutagen/mutagen.js +14 -16
- package/out/zero-cache/src/services/mutagen/mutagen.js.map +1 -1
- package/out/zero-cache/src/services/replicator/schema/replication-state.d.ts +14 -5
- package/out/zero-cache/src/services/replicator/schema/replication-state.d.ts.map +1 -1
- package/out/zero-cache/src/services/replicator/schema/replication-state.js +29 -1
- package/out/zero-cache/src/services/replicator/schema/replication-state.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/client-handler.d.ts +3 -2
- package/out/zero-cache/src/services/view-syncer/client-handler.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/client-handler.js +5 -3
- package/out/zero-cache/src/services/view-syncer/client-handler.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/cvr-store.d.ts +3 -1
- package/out/zero-cache/src/services/view-syncer/cvr-store.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/cvr-store.js +21 -11
- package/out/zero-cache/src/services/view-syncer/cvr-store.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/cvr.d.ts +5 -3
- package/out/zero-cache/src/services/view-syncer/cvr.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/cvr.js +100 -66
- package/out/zero-cache/src/services/view-syncer/cvr.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/database-storage.d.ts +2 -0
- package/out/zero-cache/src/services/view-syncer/database-storage.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/database-storage.js +8 -3
- package/out/zero-cache/src/services/view-syncer/database-storage.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/pipeline-driver.d.ts +2 -1
- package/out/zero-cache/src/services/view-syncer/pipeline-driver.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/pipeline-driver.js +1 -1
- package/out/zero-cache/src/services/view-syncer/pipeline-driver.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/row-record-cache.d.ts +3 -2
- package/out/zero-cache/src/services/view-syncer/row-record-cache.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/row-record-cache.js +5 -3
- package/out/zero-cache/src/services/view-syncer/row-record-cache.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/schema/cvr.d.ts +3 -5
- package/out/zero-cache/src/services/view-syncer/schema/cvr.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/schema/cvr.js +38 -40
- package/out/zero-cache/src/services/view-syncer/schema/cvr.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/schema/init.d.ts +2 -1
- package/out/zero-cache/src/services/view-syncer/schema/init.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/schema/init.js +7 -6
- package/out/zero-cache/src/services/view-syncer/schema/init.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/schema/types.d.ts +26 -18
- package/out/zero-cache/src/services/view-syncer/schema/types.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/schema/types.js +12 -9
- package/out/zero-cache/src/services/view-syncer/schema/types.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/snapshotter.d.ts +2 -1
- package/out/zero-cache/src/services/view-syncer/snapshotter.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/snapshotter.js +1 -1
- package/out/zero-cache/src/services/view-syncer/snapshotter.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts +18 -1
- package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/view-syncer.js +194 -43
- package/out/zero-cache/src/services/view-syncer/view-syncer.js.map +1 -1
- package/out/zero-cache/src/types/lite.d.ts +2 -2
- package/out/zero-cache/src/types/lite.d.ts.map +1 -1
- package/out/zero-cache/src/types/lite.js +9 -4
- package/out/zero-cache/src/types/lite.js.map +1 -1
- package/out/zero-cache/src/types/pg.d.ts +7 -3
- package/out/zero-cache/src/types/pg.d.ts.map +1 -1
- package/out/zero-cache/src/types/pg.js +11 -5
- package/out/zero-cache/src/types/pg.js.map +1 -1
- package/out/zero-cache/src/types/shards.d.ts +33 -0
- package/out/zero-cache/src/types/shards.d.ts.map +1 -0
- package/out/zero-cache/src/types/shards.js +44 -0
- package/out/zero-cache/src/types/shards.js.map +1 -0
- package/out/zero-cache/src/workers/connection.d.ts.map +1 -1
- package/out/zero-cache/src/workers/connection.js +39 -20
- package/out/zero-cache/src/workers/connection.js.map +1 -1
- package/out/zero-cache/src/workers/replicator.d.ts +2 -1
- package/out/zero-cache/src/workers/replicator.d.ts.map +1 -1
- package/out/zero-cache/src/workers/replicator.js +42 -17
- package/out/zero-cache/src/workers/replicator.js.map +1 -1
- package/out/zero-cache/src/workers/syncer-ws-message-handler.d.ts +4 -4
- package/out/zero-cache/src/workers/syncer-ws-message-handler.d.ts.map +1 -1
- package/out/zero-cache/src/workers/syncer-ws-message-handler.js +5 -2
- package/out/zero-cache/src/workers/syncer-ws-message-handler.js.map +1 -1
- package/out/zero-client/src/client/custom.d.ts +2 -11
- package/out/zero-client/src/client/custom.d.ts.map +1 -1
- package/out/zero-client/src/client/zero.d.ts.map +1 -1
- package/out/zero-client/src/mod.d.ts +1 -0
- package/out/zero-client/src/mod.d.ts.map +1 -1
- package/out/zero-pg/src/custom.d.ts +1 -2
- package/out/zero-pg/src/custom.d.ts.map +1 -1
- package/out/zero-pg/src/custom.js.map +1 -1
- package/out/zero-pg/src/mod.d.ts +2 -2
- package/out/zero-pg/src/mod.d.ts.map +1 -1
- package/out/zero-pg/src/query.d.ts +3 -4
- package/out/zero-pg/src/query.d.ts.map +1 -1
- package/out/zero-pg/src/query.js +5 -7
- package/out/zero-pg/src/query.js.map +1 -1
- package/out/zero-pg/src/web.d.ts +1 -1
- package/out/zero-pg/src/web.d.ts.map +1 -1
- package/out/zero-pg/src/web.js.map +1 -1
- package/out/zero-protocol/src/close-connection.d.ts +16 -0
- package/out/zero-protocol/src/close-connection.d.ts.map +1 -0
- package/out/zero-protocol/src/close-connection.js +17 -0
- package/out/zero-protocol/src/close-connection.js.map +1 -0
- package/out/zero-protocol/src/up.d.ts +1 -1
- package/out/zero-protocol/src/up.d.ts.map +1 -1
- package/out/zero-protocol/src/up.js +2 -1
- package/out/zero-protocol/src/up.js.map +1 -1
- package/out/zero-react/src/use-query.d.ts +11 -2
- package/out/zero-react/src/use-query.d.ts.map +1 -1
- package/out/zero-solid/src/use-query.d.ts +4 -1
- package/out/zero-solid/src/use-query.d.ts.map +1 -1
- package/out/zero.js +1 -2
- package/out/zql/src/ivm/exists.d.ts.map +1 -1
- package/out/zql/src/ivm/exists.js +134 -138
- package/out/zql/src/ivm/exists.js.map +1 -1
- package/out/zql/src/mutate/custom.d.ts +36 -1
- package/out/zql/src/mutate/custom.d.ts.map +1 -1
- package/out/zql/src/mutate/custom.js.map +1 -1
- package/out/zql/src/query/query-impl.d.ts +8 -8
- package/out/zql/src/query/query-impl.d.ts.map +1 -1
- package/out/zql/src/query/query-impl.js +29 -25
- package/out/zql/src/query/query-impl.js.map +1 -1
- package/out/zql/src/query/query-internal.d.ts +2 -2
- package/out/zql/src/query/query-internal.d.ts.map +1 -1
- package/out/zql/src/query/query.d.ts +10 -2
- package/out/zql/src/query/query.d.ts.map +1 -1
- package/out/zql/src/query/query.js +1 -1
- package/out/zql/src/query/query.js.map +1 -1
- package/out/zql/src/query/static-query.d.ts +1 -1
- package/out/zql/src/query/static-query.d.ts.map +1 -1
- package/out/zql/src/query/static-query.js +2 -2
- package/out/zql/src/query/static-query.js.map +1 -1
- package/out/zqlite/src/db.d.ts +3 -1
- package/out/zqlite/src/db.d.ts.map +1 -1
- package/out/zqlite/src/db.js +47 -0
- package/out/zqlite/src/db.js.map +1 -1
- package/package.json +3 -3
- package/out/chunk-5BT5TJFM.js.map +0 -7
- package/out/chunk-P3NUVEQJ.js +0 -3578
- package/out/chunk-P3NUVEQJ.js.map +0 -7
- package/out/pg.js +0 -593
- package/out/pg.js.map +0 -7
- package/out/zero-cache/src/services/change-source/pg/shard-config.d.ts +0 -19
- package/out/zero-cache/src/services/change-source/pg/shard-config.d.ts.map +0 -1
- package/out/zero-cache/src/services/change-source/pg/shard-config.js +0 -2
- package/out/zero-cache/src/services/change-source/pg/shard-config.js.map +0 -1
- package/out/zero-pg/src/db.d.ts +0 -27
- package/out/zero-pg/src/db.d.ts.map +0 -1
- package/out/zero-pg/src/db.js +0 -2
- package/out/zero-pg/src/db.js.map +0 -1
package/out/react.js
CHANGED
|
@@ -67,13 +67,18 @@ function ZeroProvider({ children, zero }) {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
// ../zero-react/src/use-query.tsx
|
|
70
|
-
|
|
70
|
+
var DEFAULT_TTL = 1e4;
|
|
71
|
+
function useQuery(query, options) {
|
|
72
|
+
let enabled = true;
|
|
73
|
+
let ttl;
|
|
74
|
+
if (typeof options === "boolean") {
|
|
75
|
+
enabled = options;
|
|
76
|
+
} else if (options) {
|
|
77
|
+
({ enabled = true, ttl = DEFAULT_TTL } = options);
|
|
78
|
+
}
|
|
79
|
+
const advancedQuery = query;
|
|
71
80
|
const z = useZero();
|
|
72
|
-
const view = viewStore.getView(
|
|
73
|
-
z.clientID,
|
|
74
|
-
q,
|
|
75
|
-
enable
|
|
76
|
-
);
|
|
81
|
+
const view = viewStore.getView(z.clientID, advancedQuery, enabled, ttl);
|
|
77
82
|
return useSyncExternalStore(
|
|
78
83
|
view.subscribeReactInternals,
|
|
79
84
|
view.getSnapshot,
|
|
@@ -111,7 +116,7 @@ var ViewStore = class {
|
|
|
111
116
|
allViews.set(this, this.#views);
|
|
112
117
|
}
|
|
113
118
|
}
|
|
114
|
-
getView(clientID, query, enabled) {
|
|
119
|
+
getView(clientID, query, enabled, ttl) {
|
|
115
120
|
if (!enabled) {
|
|
116
121
|
return {
|
|
117
122
|
getSnapshot: () => getDefaultSnapshot(query.format.singular),
|
|
@@ -123,6 +128,7 @@ var ViewStore = class {
|
|
|
123
128
|
if (!existing) {
|
|
124
129
|
existing = new ViewWrapper(
|
|
125
130
|
query,
|
|
131
|
+
ttl,
|
|
126
132
|
(view) => {
|
|
127
133
|
const lastView = this.#views.get(hash);
|
|
128
134
|
if (lastView && lastView !== view) {
|
|
@@ -147,12 +153,14 @@ var ViewWrapper = class {
|
|
|
147
153
|
#query;
|
|
148
154
|
#snapshot;
|
|
149
155
|
#reactInternals;
|
|
150
|
-
|
|
151
|
-
|
|
156
|
+
#ttl;
|
|
157
|
+
constructor(query, ttl, onMaterialized, onDematerialized) {
|
|
158
|
+
this.#query = query;
|
|
159
|
+
this.#ttl = ttl;
|
|
152
160
|
this.#onMaterialized = onMaterialized;
|
|
153
161
|
this.#onDematerialized = onDematerialized;
|
|
162
|
+
this.#snapshot = getDefaultSnapshot(query.format.singular);
|
|
154
163
|
this.#reactInternals = /* @__PURE__ */ new Set();
|
|
155
|
-
this.#query = query;
|
|
156
164
|
this.#materializeIfNeeded();
|
|
157
165
|
}
|
|
158
166
|
#onData = (snap, resultType) => {
|
|
@@ -166,7 +174,7 @@ var ViewWrapper = class {
|
|
|
166
174
|
if (this.#view) {
|
|
167
175
|
return;
|
|
168
176
|
}
|
|
169
|
-
this.#view = this.#query.materialize();
|
|
177
|
+
this.#view = this.#query.materialize(this.#ttl);
|
|
170
178
|
this.#view.addListener(this.#onData);
|
|
171
179
|
this.#onMaterialized(this);
|
|
172
180
|
};
|
package/out/react.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../zero-react/src/use-query.tsx", "../../shared/src/deep-clone.ts", "../../zero-react/src/use-zero.tsx"],
|
|
4
|
-
"sourcesContent": ["import {useSyncExternalStore} from 'react';\nimport {deepClone} from '../../shared/src/deep-clone.ts';\nimport type {Immutable} from '../../shared/src/immutable.ts';\nimport type {ReadonlyJSONValue} from '../../shared/src/json.ts';\nimport type {Schema} from '../../zero-schema/src/builder/schema-builder.ts';\nimport type {AdvancedQuery} from '../../zql/src/query/query-internal.ts';\nimport type {HumanReadable, Query} from '../../zql/src/query/query.ts';\nimport type {ResultType, TypedView} from '../../zql/src/query/typed-view.ts';\nimport {useZero} from './use-zero.tsx';\n\nexport type QueryResultDetails = Readonly<{\n type: ResultType;\n}>;\n\nexport type QueryResult<TReturn> = readonly [\n HumanReadable<TReturn>,\n QueryResultDetails,\n];\n\nexport function useQuery<\n TSchema extends Schema,\n TTable extends keyof TSchema['tables'] & string,\n TReturn,\n>(\n q: Query<TSchema, TTable, TReturn>,\n enable: boolean = true,\n): QueryResult<TReturn> {\n const z = useZero();\n const view = viewStore.getView(\n z.clientID,\n q as AdvancedQuery<TSchema, TTable, TReturn>,\n enable,\n );\n // https://react.dev/reference/react/useSyncExternalStore\n return useSyncExternalStore(\n view.subscribeReactInternals,\n view.getSnapshot,\n view.getSnapshot,\n );\n}\n\nconst emptyArray: unknown[] = [];\nconst disabledSubscriber = () => () => {};\n\nconst resultTypeUnknown = {type: 'unknown'} as const;\nconst resultTypeComplete = {type: 'complete'} as const;\n\nconst emptySnapshotSingularUnknown = [undefined, resultTypeUnknown] as const;\nconst emptySnapshotSingularComplete = [undefined, resultTypeComplete] as const;\nconst emptySnapshotPluralUnknown = [emptyArray, resultTypeUnknown] as const;\nconst emptySnapshotPluralComplete = [emptyArray, resultTypeComplete] as const;\n\nfunction getDefaultSnapshot<TReturn>(singular: boolean): QueryResult<TReturn> {\n return (\n singular ? emptySnapshotSingularUnknown : emptySnapshotPluralUnknown\n ) as QueryResult<TReturn>;\n}\n\n/**\n * Returns a new snapshot or one of the empty predefined ones. Returning the\n * predefined ones is important to prevent unnecessary re-renders in React.\n */\nfunction getSnapshot<TReturn>(\n singular: boolean,\n data: HumanReadable<TReturn>,\n resultType: string,\n): QueryResult<TReturn> {\n if (singular && data === undefined) {\n return (resultType === 'complete'\n ? emptySnapshotSingularComplete\n : emptySnapshotSingularUnknown) as unknown as QueryResult<TReturn>;\n }\n\n if (!singular && (data as unknown[]).length === 0) {\n return (\n resultType === 'complete'\n ? emptySnapshotPluralComplete\n : emptySnapshotPluralUnknown\n ) as QueryResult<TReturn>;\n }\n\n return [\n data,\n resultType === 'complete' ? resultTypeComplete : resultTypeUnknown,\n ];\n}\n\ndeclare const TESTING: boolean;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype ViewWrapperAny = ViewWrapper<any, any, any>;\n\nconst allViews = new WeakMap<ViewStore, Map<string, ViewWrapperAny>>();\n\nexport function getAllViewsSizeForTesting(store: ViewStore): number {\n if (TESTING) {\n return allViews.get(store)?.size ?? 0;\n }\n return 0;\n}\n\n/**\n * A global store of all active views.\n *\n * React subscribes and unsubscribes to these views\n * via `useSyncExternalStore`.\n *\n * Managing views through `useEffect` or `useLayoutEffect` causes\n * inconsistencies because effects run after render.\n *\n * For example, if useQuery used use*Effect in the component below:\n * ```ts\n * function Foo({issueID}) {\n * const issue = useQuery(z.query.issue.where('id', issueID).one());\n * if (issue?.id !== undefined && issue.id !== issueID) {\n * console.log('MISMATCH!', issue.id, issueID);\n * }\n * }\n * ```\n *\n * `MISMATCH` will be printed whenever the `issueID` prop changes.\n *\n * This is because the component will render once with\n * the old state returned from `useQuery`. Then the effect inside\n * `useQuery` will run. The component will render again with the new\n * state. This inconsistent transition can cause unexpected results.\n *\n * Emulating `useEffect` via `useState` and `if` causes resource leaks.\n * That is:\n *\n * ```ts\n * function useQuery(q) {\n * const [oldHash, setOldHash] = useState();\n * if (hash(q) !== oldHash) {\n * // make new view\n * }\n *\n * useEffect(() => {\n * return () => view.destroy();\n * }, []);\n * }\n * ```\n *\n * I'm not sure why but in strict mode the cleanup function\n * fails to be called for the first instance of the view and only\n * cleans up later instances.\n *\n * Swapping `useState` to `useRef` has similar problems.\n */\nexport class ViewStore {\n #views = new Map<string, ViewWrapperAny>();\n\n constructor() {\n if (TESTING) {\n allViews.set(this, this.#views);\n }\n }\n\n getView<\n TSchema extends Schema,\n TTable extends keyof TSchema['tables'] & string,\n TReturn,\n >(\n clientID: string,\n query: AdvancedQuery<TSchema, TTable, TReturn>,\n enabled: boolean,\n ): {\n getSnapshot: () => QueryResult<TReturn>;\n subscribeReactInternals: (internals: () => void) => () => void;\n } {\n if (!enabled) {\n return {\n getSnapshot: () => getDefaultSnapshot(query.format.singular),\n subscribeReactInternals: disabledSubscriber,\n };\n }\n\n const hash = query.hash() + clientID;\n let existing = this.#views.get(hash);\n if (!existing) {\n existing = new ViewWrapper(\n query,\n view => {\n const lastView = this.#views.get(hash);\n // I don't think this can happen\n // but lets guard against it so we don't\n // leak resources.\n if (lastView && lastView !== view) {\n throw new Error('View already exists');\n }\n this.#views.set(hash, view);\n },\n () => {\n this.#views.delete(hash);\n },\n ) as ViewWrapper<TSchema, TTable, TReturn>;\n this.#views.set(hash, existing);\n }\n return existing as ViewWrapper<TSchema, TTable, TReturn>;\n }\n}\n\nconst viewStore = new ViewStore();\n\n/**\n * This wraps and ref counts a view.\n *\n * The only signal we have from React as to whether or not it is\n * done with a view is when it calls `unsubscribe`.\n *\n * In non-strict-mode we can clean up the view as soon\n * as the listener count goes to 0.\n *\n * In strict-mode, the listener count will go to 0 then a\n * new listener for the same view is immediately added back.\n *\n * This is why the `onMaterialized` and `onDematerialized` callbacks exist --\n * they allow a view which React is still referencing to be added\n * back into the store when React re-subscribes to it.\n *\n * This wrapper also exists to deal with the various\n * `useSyncExternalStore` caveats that cause excessive\n * re-renders and materializations.\n *\n * See: https://react.dev/reference/react/useSyncExternalStore#caveats\n * Especially:\n * 1. The store snapshot returned by getSnapshot must be immutable. If the underlying store has mutable data, return a new immutable snapshot if the data has changed. Otherwise, return a cached last snapshot.\n * 2. If a different subscribe function is passed during a re-render, React will re-subscribe to the store using the newly passed subscribe function. You can prevent this by declaring subscribe outside the component.\n */\nclass ViewWrapper<\n TSchema extends Schema,\n TTable extends keyof TSchema['tables'] & string,\n TReturn,\n> {\n #view: TypedView<HumanReadable<TReturn>> | undefined;\n readonly #onDematerialized;\n readonly #onMaterialized;\n readonly #query: AdvancedQuery<TSchema, TTable, TReturn>;\n #snapshot: QueryResult<TReturn>;\n #reactInternals: Set<() => void>;\n\n constructor(\n query: AdvancedQuery<TSchema, TTable, TReturn>,\n onMaterialized: (view: ViewWrapper<TSchema, TTable, TReturn>) => void,\n onDematerialized: () => void,\n ) {\n this.#snapshot = getDefaultSnapshot(query.format.singular);\n this.#onMaterialized = onMaterialized;\n this.#onDematerialized = onDematerialized;\n this.#reactInternals = new Set();\n this.#query = query;\n this.#materializeIfNeeded();\n }\n\n #onData = (\n snap: Immutable<HumanReadable<TReturn>>,\n resultType: ResultType,\n ) => {\n const data =\n snap === undefined\n ? snap\n : (deepClone(snap as ReadonlyJSONValue) as HumanReadable<TReturn>);\n this.#snapshot = getSnapshot(this.#query.format.singular, data, resultType);\n for (const internals of this.#reactInternals) {\n internals();\n }\n };\n\n #materializeIfNeeded = () => {\n if (this.#view) {\n return;\n }\n\n this.#view = this.#query.materialize();\n this.#view.addListener(this.#onData);\n\n this.#onMaterialized(this);\n };\n\n getSnapshot = () => this.#snapshot;\n\n subscribeReactInternals = (internals: () => void): (() => void) => {\n this.#reactInternals.add(internals);\n this.#materializeIfNeeded();\n return () => {\n this.#reactInternals.delete(internals);\n\n // only schedule a cleanup task if we have no listeners left\n if (this.#reactInternals.size === 0) {\n setTimeout(() => {\n // Someone re-registered a listener on this view before the timeout elapsed.\n // This happens often in strict-mode which forces a component\n // to mount, unmount, remount.\n if (this.#reactInternals.size > 0) {\n return;\n }\n // We already destroyed the view\n if (this.#view === undefined) {\n return;\n }\n this.#view?.destroy();\n this.#view = undefined;\n this.#onDematerialized();\n }, 10);\n }\n };\n };\n}\n", "import {hasOwn} from './has-own.ts';\nimport type {JSONValue, ReadonlyJSONValue} from './json.ts';\n\nexport function deepClone(value: ReadonlyJSONValue): JSONValue {\n const seen: Array<ReadonlyJSONValue> = [];\n return internalDeepClone(value, seen);\n}\n\nexport function internalDeepClone(\n value: ReadonlyJSONValue,\n seen: Array<ReadonlyJSONValue>,\n): JSONValue {\n switch (typeof value) {\n case 'boolean':\n case 'number':\n case 'string':\n case 'undefined':\n return value;\n case 'object': {\n if (value === null) {\n return null;\n }\n if (seen.includes(value)) {\n throw new Error('Cyclic object');\n }\n seen.push(value);\n if (Array.isArray(value)) {\n const rv = value.map(v => internalDeepClone(v, seen));\n seen.pop();\n return rv;\n }\n\n const obj: JSONValue = {};\n\n for (const k in value) {\n if (hasOwn(value, k)) {\n const v = (value as Record<string, ReadonlyJSONValue>)[k];\n if (v !== undefined) {\n obj[k] = internalDeepClone(v, seen);\n }\n }\n }\n seen.pop();\n return obj;\n }\n\n default:\n throw new Error(`Invalid type: ${typeof value}`);\n }\n}\n", "import {createContext, useContext} from 'react';\nimport type {Zero} from '../../zero-client/src/client/zero.ts';\nimport type {Schema} from '../../zero-schema/src/builder/schema-builder.ts';\nimport type {CustomMutatorDefs} from '../../zero-client/src/client/custom.ts';\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nconst ZeroContext = createContext<unknown | undefined>(undefined);\n\nexport function useZero<\n S extends Schema,\n MD extends CustomMutatorDefs<S> | undefined = undefined,\n>(): Zero<S, MD> {\n const zero = useContext(ZeroContext);\n if (zero === undefined) {\n throw new Error('useZero must be used within a ZeroProvider');\n }\n return zero as Zero<S, MD>;\n}\n\nexport function createUseZero<\n S extends Schema,\n MD extends CustomMutatorDefs<S> | undefined = undefined,\n>() {\n return () => useZero<S, MD>();\n}\n\nexport function ZeroProvider<\n S extends Schema,\n MD extends CustomMutatorDefs<S> | undefined = undefined,\n>({children, zero}: {children: React.ReactNode; zero: Zero<S, MD>}) {\n return <ZeroContext.Provider value={zero}>{children}</ZeroContext.Provider>;\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;AAAA,SAAQ,4BAA2B;;;ACG5B,SAAS,UAAU,OAAqC;AAC7D,QAAM,OAAiC,CAAC;AACxC,SAAO,kBAAkB,OAAO,IAAI;AACtC;AAEO,SAAS,kBACd,OACA,MACW;AACX,UAAQ,OAAO,OAAO;AAAA,IACpB,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IACT,KAAK,UAAU;AACb,UAAI,UAAU,MAAM;AAClB,eAAO;AAAA,MACT;AACA,UAAI,KAAK,SAAS,KAAK,GAAG;AACxB,cAAM,IAAI,MAAM,eAAe;AAAA,MACjC;AACA,WAAK,KAAK,KAAK;AACf,UAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,cAAM,KAAK,MAAM,IAAI,OAAK,kBAAkB,GAAG,IAAI,CAAC;AACpD,aAAK,IAAI;AACT,eAAO;AAAA,MACT;AAEA,YAAM,MAAiB,CAAC;AAExB,iBAAW,KAAK,OAAO;AACrB,YAAI,OAAO,OAAO,CAAC,GAAG;AACpB,gBAAM,IAAK,MAA4C,CAAC;AACxD,cAAI,MAAM,QAAW;AACnB,gBAAI,CAAC,IAAI,kBAAkB,GAAG,IAAI;AAAA,UACpC;AAAA,QACF;AAAA,MACF;AACA,WAAK,IAAI;AACT,aAAO;AAAA,IACT;AAAA,IAEA;AACE,YAAM,IAAI,MAAM,iBAAiB,OAAO,KAAK,EAAE;AAAA,EACnD;AACF;;;ACjDA,SAAQ,eAAe,kBAAiB;AA8B/B;AAxBT,IAAM,cAAc,cAAmC,MAAS;AAEzD,SAAS,UAGC;AACf,QAAM,OAAO,WAAW,WAAW;AACnC,MAAI,SAAS,QAAW;AACtB,UAAM,IAAI,MAAM,4CAA4C;AAAA,EAC9D;AACA,SAAO;AACT;AAEO,SAAS,gBAGZ;AACF,SAAO,MAAM,QAAe;AAC9B;AAEO,SAAS,aAGd,EAAC,UAAU,KAAI,GAAmD;AAClE,SAAO,oBAAC,YAAY,UAAZ,EAAqB,OAAO,MAAO,UAAS;AACtD;;;
|
|
4
|
+
"sourcesContent": ["import {useSyncExternalStore} from 'react';\nimport {deepClone} from '../../shared/src/deep-clone.ts';\nimport type {Immutable} from '../../shared/src/immutable.ts';\nimport type {ReadonlyJSONValue} from '../../shared/src/json.ts';\nimport type {Schema} from '../../zero-schema/src/builder/schema-builder.ts';\nimport type {AdvancedQuery} from '../../zql/src/query/query-internal.ts';\nimport type {HumanReadable, Query} from '../../zql/src/query/query.ts';\nimport type {ResultType, TypedView} from '../../zql/src/query/typed-view.ts';\nimport {useZero} from './use-zero.tsx';\n\nexport type QueryResultDetails = Readonly<{\n type: ResultType;\n}>;\n\nexport type QueryResult<TReturn> = readonly [\n HumanReadable<TReturn>,\n QueryResultDetails,\n];\n\nexport type UseQueryOptions = {\n enabled?: boolean | undefined;\n /**\n * Time to live (TTL) in seconds. Controls how long query results are cached\n * after the query is removed. During this time, Zero continues to sync the query.\n * Default is 10 seconds.\n */\n ttl?: number | undefined;\n};\n\nconst DEFAULT_TTL = 10_000;\n\nexport function useQuery<\n TSchema extends Schema,\n TTable extends keyof TSchema['tables'] & string,\n TReturn,\n>(\n query: Query<TSchema, TTable, TReturn>,\n options?: UseQueryOptions | boolean,\n): QueryResult<TReturn> {\n let enabled = true;\n let ttl: number | undefined;\n if (typeof options === 'boolean') {\n enabled = options;\n } else if (options) {\n ({enabled = true, ttl = DEFAULT_TTL} = options);\n }\n const advancedQuery = query as AdvancedQuery<TSchema, TTable, TReturn>;\n\n const z = useZero();\n const view = viewStore.getView(z.clientID, advancedQuery, enabled, ttl);\n // https://react.dev/reference/react/useSyncExternalStore\n return useSyncExternalStore(\n view.subscribeReactInternals,\n view.getSnapshot,\n view.getSnapshot,\n );\n}\n\nconst emptyArray: unknown[] = [];\nconst disabledSubscriber = () => () => {};\n\nconst resultTypeUnknown = {type: 'unknown'} as const;\nconst resultTypeComplete = {type: 'complete'} as const;\n\nconst emptySnapshotSingularUnknown = [undefined, resultTypeUnknown] as const;\nconst emptySnapshotSingularComplete = [undefined, resultTypeComplete] as const;\nconst emptySnapshotPluralUnknown = [emptyArray, resultTypeUnknown] as const;\nconst emptySnapshotPluralComplete = [emptyArray, resultTypeComplete] as const;\n\nfunction getDefaultSnapshot<TReturn>(singular: boolean): QueryResult<TReturn> {\n return (\n singular ? emptySnapshotSingularUnknown : emptySnapshotPluralUnknown\n ) as QueryResult<TReturn>;\n}\n\n/**\n * Returns a new snapshot or one of the empty predefined ones. Returning the\n * predefined ones is important to prevent unnecessary re-renders in React.\n */\nfunction getSnapshot<TReturn>(\n singular: boolean,\n data: HumanReadable<TReturn>,\n resultType: string,\n): QueryResult<TReturn> {\n if (singular && data === undefined) {\n return (resultType === 'complete'\n ? emptySnapshotSingularComplete\n : emptySnapshotSingularUnknown) as unknown as QueryResult<TReturn>;\n }\n\n if (!singular && (data as unknown[]).length === 0) {\n return (\n resultType === 'complete'\n ? emptySnapshotPluralComplete\n : emptySnapshotPluralUnknown\n ) as QueryResult<TReturn>;\n }\n\n return [\n data,\n resultType === 'complete' ? resultTypeComplete : resultTypeUnknown,\n ];\n}\n\ndeclare const TESTING: boolean;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype ViewWrapperAny = ViewWrapper<any, any, any>;\n\nconst allViews = new WeakMap<ViewStore, Map<string, ViewWrapperAny>>();\n\nexport function getAllViewsSizeForTesting(store: ViewStore): number {\n if (TESTING) {\n return allViews.get(store)?.size ?? 0;\n }\n return 0;\n}\n\n/**\n * A global store of all active views.\n *\n * React subscribes and unsubscribes to these views\n * via `useSyncExternalStore`.\n *\n * Managing views through `useEffect` or `useLayoutEffect` causes\n * inconsistencies because effects run after render.\n *\n * For example, if useQuery used use*Effect in the component below:\n * ```ts\n * function Foo({issueID}) {\n * const issue = useQuery(z.query.issue.where('id', issueID).one());\n * if (issue?.id !== undefined && issue.id !== issueID) {\n * console.log('MISMATCH!', issue.id, issueID);\n * }\n * }\n * ```\n *\n * `MISMATCH` will be printed whenever the `issueID` prop changes.\n *\n * This is because the component will render once with\n * the old state returned from `useQuery`. Then the effect inside\n * `useQuery` will run. The component will render again with the new\n * state. This inconsistent transition can cause unexpected results.\n *\n * Emulating `useEffect` via `useState` and `if` causes resource leaks.\n * That is:\n *\n * ```ts\n * function useQuery(q) {\n * const [oldHash, setOldHash] = useState();\n * if (hash(q) !== oldHash) {\n * // make new view\n * }\n *\n * useEffect(() => {\n * return () => view.destroy();\n * }, []);\n * }\n * ```\n *\n * I'm not sure why but in strict mode the cleanup function\n * fails to be called for the first instance of the view and only\n * cleans up later instances.\n *\n * Swapping `useState` to `useRef` has similar problems.\n */\nexport class ViewStore {\n #views = new Map<string, ViewWrapperAny>();\n\n constructor() {\n if (TESTING) {\n allViews.set(this, this.#views);\n }\n }\n\n getView<\n TSchema extends Schema,\n TTable extends keyof TSchema['tables'] & string,\n TReturn,\n >(\n clientID: string,\n query: AdvancedQuery<TSchema, TTable, TReturn>,\n enabled: boolean,\n ttl: number | undefined,\n ): {\n getSnapshot: () => QueryResult<TReturn>;\n subscribeReactInternals: (internals: () => void) => () => void;\n } {\n if (!enabled) {\n return {\n getSnapshot: () => getDefaultSnapshot(query.format.singular),\n subscribeReactInternals: disabledSubscriber,\n };\n }\n\n const hash = query.hash() + clientID;\n let existing = this.#views.get(hash);\n if (!existing) {\n existing = new ViewWrapper(\n query,\n ttl,\n view => {\n const lastView = this.#views.get(hash);\n // I don't think this can happen\n // but lets guard against it so we don't\n // leak resources.\n if (lastView && lastView !== view) {\n throw new Error('View already exists');\n }\n this.#views.set(hash, view);\n },\n () => {\n this.#views.delete(hash);\n },\n ) as ViewWrapper<TSchema, TTable, TReturn>;\n this.#views.set(hash, existing);\n }\n return existing as ViewWrapper<TSchema, TTable, TReturn>;\n }\n}\n\nconst viewStore = new ViewStore();\n\n/**\n * This wraps and ref counts a view.\n *\n * The only signal we have from React as to whether or not it is\n * done with a view is when it calls `unsubscribe`.\n *\n * In non-strict-mode we can clean up the view as soon\n * as the listener count goes to 0.\n *\n * In strict-mode, the listener count will go to 0 then a\n * new listener for the same view is immediately added back.\n *\n * This is why the `onMaterialized` and `onDematerialized` callbacks exist --\n * they allow a view which React is still referencing to be added\n * back into the store when React re-subscribes to it.\n *\n * This wrapper also exists to deal with the various\n * `useSyncExternalStore` caveats that cause excessive\n * re-renders and materializations.\n *\n * See: https://react.dev/reference/react/useSyncExternalStore#caveats\n * Especially:\n * 1. The store snapshot returned by getSnapshot must be immutable. If the underlying store has mutable data, return a new immutable snapshot if the data has changed. Otherwise, return a cached last snapshot.\n * 2. If a different subscribe function is passed during a re-render, React will re-subscribe to the store using the newly passed subscribe function. You can prevent this by declaring subscribe outside the component.\n */\nclass ViewWrapper<\n TSchema extends Schema,\n TTable extends keyof TSchema['tables'] & string,\n TReturn,\n> {\n #view: TypedView<HumanReadable<TReturn>> | undefined;\n readonly #onDematerialized;\n readonly #onMaterialized;\n readonly #query: AdvancedQuery<TSchema, TTable, TReturn>;\n #snapshot: QueryResult<TReturn>;\n #reactInternals: Set<() => void>;\n readonly #ttl: number | undefined;\n\n constructor(\n query: AdvancedQuery<TSchema, TTable, TReturn>,\n ttl: number | undefined,\n onMaterialized: (view: ViewWrapper<TSchema, TTable, TReturn>) => void,\n onDematerialized: () => void,\n ) {\n this.#query = query;\n this.#ttl = ttl;\n this.#onMaterialized = onMaterialized;\n this.#onDematerialized = onDematerialized;\n this.#snapshot = getDefaultSnapshot(query.format.singular);\n this.#reactInternals = new Set();\n this.#materializeIfNeeded();\n }\n\n #onData = (\n snap: Immutable<HumanReadable<TReturn>>,\n resultType: ResultType,\n ) => {\n const data =\n snap === undefined\n ? snap\n : (deepClone(snap as ReadonlyJSONValue) as HumanReadable<TReturn>);\n this.#snapshot = getSnapshot(this.#query.format.singular, data, resultType);\n for (const internals of this.#reactInternals) {\n internals();\n }\n };\n\n #materializeIfNeeded = () => {\n if (this.#view) {\n return;\n }\n\n this.#view = this.#query.materialize(this.#ttl);\n this.#view.addListener(this.#onData);\n\n this.#onMaterialized(this);\n };\n\n getSnapshot = () => this.#snapshot;\n\n subscribeReactInternals = (internals: () => void): (() => void) => {\n this.#reactInternals.add(internals);\n this.#materializeIfNeeded();\n return () => {\n this.#reactInternals.delete(internals);\n\n // only schedule a cleanup task if we have no listeners left\n if (this.#reactInternals.size === 0) {\n setTimeout(() => {\n // Someone re-registered a listener on this view before the timeout elapsed.\n // This happens often in strict-mode which forces a component\n // to mount, unmount, remount.\n if (this.#reactInternals.size > 0) {\n return;\n }\n // We already destroyed the view\n if (this.#view === undefined) {\n return;\n }\n this.#view?.destroy();\n this.#view = undefined;\n this.#onDematerialized();\n }, 10);\n }\n };\n };\n}\n", "import {hasOwn} from './has-own.ts';\nimport type {JSONValue, ReadonlyJSONValue} from './json.ts';\n\nexport function deepClone(value: ReadonlyJSONValue): JSONValue {\n const seen: Array<ReadonlyJSONValue> = [];\n return internalDeepClone(value, seen);\n}\n\nexport function internalDeepClone(\n value: ReadonlyJSONValue,\n seen: Array<ReadonlyJSONValue>,\n): JSONValue {\n switch (typeof value) {\n case 'boolean':\n case 'number':\n case 'string':\n case 'undefined':\n return value;\n case 'object': {\n if (value === null) {\n return null;\n }\n if (seen.includes(value)) {\n throw new Error('Cyclic object');\n }\n seen.push(value);\n if (Array.isArray(value)) {\n const rv = value.map(v => internalDeepClone(v, seen));\n seen.pop();\n return rv;\n }\n\n const obj: JSONValue = {};\n\n for (const k in value) {\n if (hasOwn(value, k)) {\n const v = (value as Record<string, ReadonlyJSONValue>)[k];\n if (v !== undefined) {\n obj[k] = internalDeepClone(v, seen);\n }\n }\n }\n seen.pop();\n return obj;\n }\n\n default:\n throw new Error(`Invalid type: ${typeof value}`);\n }\n}\n", "import {createContext, useContext} from 'react';\nimport type {Zero} from '../../zero-client/src/client/zero.ts';\nimport type {Schema} from '../../zero-schema/src/builder/schema-builder.ts';\nimport type {CustomMutatorDefs} from '../../zero-client/src/client/custom.ts';\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nconst ZeroContext = createContext<unknown | undefined>(undefined);\n\nexport function useZero<\n S extends Schema,\n MD extends CustomMutatorDefs<S> | undefined = undefined,\n>(): Zero<S, MD> {\n const zero = useContext(ZeroContext);\n if (zero === undefined) {\n throw new Error('useZero must be used within a ZeroProvider');\n }\n return zero as Zero<S, MD>;\n}\n\nexport function createUseZero<\n S extends Schema,\n MD extends CustomMutatorDefs<S> | undefined = undefined,\n>() {\n return () => useZero<S, MD>();\n}\n\nexport function ZeroProvider<\n S extends Schema,\n MD extends CustomMutatorDefs<S> | undefined = undefined,\n>({children, zero}: {children: React.ReactNode; zero: Zero<S, MD>}) {\n return <ZeroContext.Provider value={zero}>{children}</ZeroContext.Provider>;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;AAAA,SAAQ,4BAA2B;;;ACG5B,SAAS,UAAU,OAAqC;AAC7D,QAAM,OAAiC,CAAC;AACxC,SAAO,kBAAkB,OAAO,IAAI;AACtC;AAEO,SAAS,kBACd,OACA,MACW;AACX,UAAQ,OAAO,OAAO;AAAA,IACpB,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAA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gBAAgB,IAAI,SAAS;AAClC,SAAK,qBAAqB;AAC1B,WAAO,MAAM;AACX,WAAK,gBAAgB,OAAO,SAAS;AAGrC,UAAI,KAAK,gBAAgB,SAAS,GAAG;AACnC,mBAAW,MAAM;AAIf,cAAI,KAAK,gBAAgB,OAAO,GAAG;AACjC;AAAA,UACF;AAEA,cAAI,KAAK,UAAU,QAAW;AAC5B;AAAA,UACF;AACA,eAAK,OAAO,QAAQ;AACpB,eAAK,QAAQ;AACb,eAAK,kBAAkB;AAAA,QACzB,GAAG,EAAE;AAAA,MACP;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -16,7 +16,7 @@ export declare function equals<T>(a: ReadonlySetLike<T>, b: ReadonlySetLike<T>):
|
|
|
16
16
|
export declare function union<T>(...sets: ReadonlySetLike<T>[]): Set<T>;
|
|
17
17
|
export declare function intersection<T>(a: ReadonlySetLike<T>, b: ReadonlySetLike<T>): Set<T>;
|
|
18
18
|
/**
|
|
19
|
-
* Returns the elements in {@
|
|
19
|
+
* Returns the elements in {@linkcode a} that are not in {@linkcode b}.
|
|
20
20
|
*/
|
|
21
21
|
export declare function difference<T>(a: ReadonlySetLike<T>, b: ReadonlySetLike<T>): Set<T>;
|
|
22
22
|
export declare function symmetricDifferences<T>(a: ReadonlySetLike<T>, b: ReadonlySetLike<T>): [onlyA: Set<T>, onlyB: Set<T>];
|
|
@@ -38,7 +38,7 @@ export function intersection(a, b) {
|
|
|
38
38
|
return result;
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
|
-
* Returns the elements in {@
|
|
41
|
+
* Returns the elements in {@linkcode a} that are not in {@linkcode b}.
|
|
42
42
|
*/
|
|
43
43
|
export function difference(a, b) {
|
|
44
44
|
const result = new Set();
|
package/out/solid.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Zero
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-ULOTOBTC.js";
|
|
5
|
-
import "./chunk-P3NUVEQJ.js";
|
|
3
|
+
} from "./chunk-XXZWDMNW.js";
|
|
6
4
|
import "./chunk-HARIWJ2J.js";
|
|
5
|
+
import "./chunk-ULOTOBTC.js";
|
|
7
6
|
import {
|
|
8
7
|
applyChange
|
|
9
8
|
} from "./chunk-Q6D7EOS6.js";
|
|
@@ -177,11 +176,13 @@ function solidViewFactory(_query, input, format, onDestroy, onTransactionCommit,
|
|
|
177
176
|
}
|
|
178
177
|
|
|
179
178
|
// ../zero-solid/src/use-query.ts
|
|
180
|
-
function useQuery(querySignal) {
|
|
179
|
+
function useQuery(querySignal, options) {
|
|
181
180
|
const view = createMemo(() => {
|
|
181
|
+
const ttl = normalize(options)?.ttl;
|
|
182
182
|
const query = querySignal();
|
|
183
183
|
const view2 = query.materialize(
|
|
184
|
-
solidViewFactory
|
|
184
|
+
solidViewFactory,
|
|
185
|
+
ttl
|
|
185
186
|
);
|
|
186
187
|
onCleanup(() => {
|
|
187
188
|
view2.destroy();
|
|
@@ -190,6 +191,9 @@ function useQuery(querySignal) {
|
|
|
190
191
|
});
|
|
191
192
|
return [() => view().data, () => view().resultDetails];
|
|
192
193
|
}
|
|
194
|
+
function normalize(options) {
|
|
195
|
+
return typeof options === "function" ? options() : options;
|
|
196
|
+
}
|
|
193
197
|
export {
|
|
194
198
|
createZero,
|
|
195
199
|
useQuery
|
package/out/solid.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../zero-solid/src/create-zero.ts", "../../zero-solid/src/use-query.ts", "../../zero-solid/src/solid-view.ts"],
|
|
4
|
-
"sourcesContent": ["import {batch} from 'solid-js';\nimport type {ZeroAdvancedOptions} from '../../zero/src/advanced.ts';\nimport {Zero, type Schema, type ZeroOptions} from '../../zero/src/zero.ts';\n\nexport function createZero<S extends Schema>(options: ZeroOptions<S>): Zero<S> {\n const opts: ZeroAdvancedOptions<S> = {\n ...options,\n batchViewUpdates: batch,\n };\n return new Zero(opts);\n}\n", "import {createMemo, onCleanup, type Accessor} from 'solid-js';\nimport type {\n AdvancedQuery,\n HumanReadable,\n Query,\n} from '../../zero/src/advanced.ts';\nimport type {Schema} from '../../zero/src/zero.ts';\nimport {solidViewFactory, type QueryResultDetails} from './solid-view.ts';\n\nexport type QueryResult<TReturn> = readonly [\n Accessor<HumanReadable<TReturn>>,\n Accessor<QueryResultDetails>,\n];\n\nexport function useQuery<\n TSchema extends Schema,\n TTable extends keyof TSchema['tables'] & string,\n TReturn,\n>(querySignal: () => Query<TSchema, TTable, TReturn
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import {batch} from 'solid-js';\nimport type {ZeroAdvancedOptions} from '../../zero/src/advanced.ts';\nimport {Zero, type Schema, type ZeroOptions} from '../../zero/src/zero.ts';\n\nexport function createZero<S extends Schema>(options: ZeroOptions<S>): Zero<S> {\n const opts: ZeroAdvancedOptions<S> = {\n ...options,\n batchViewUpdates: batch,\n };\n return new Zero(opts);\n}\n", "import {createMemo, onCleanup, type Accessor} from 'solid-js';\nimport type {\n AdvancedQuery,\n HumanReadable,\n Query,\n} from '../../zero/src/advanced.ts';\nimport type {Schema} from '../../zero/src/zero.ts';\nimport {solidViewFactory, type QueryResultDetails} from './solid-view.ts';\n\nexport type QueryResult<TReturn> = readonly [\n Accessor<HumanReadable<TReturn>>,\n Accessor<QueryResultDetails>,\n];\n\nexport type UseQueryOptions = {\n ttl?: number | undefined;\n};\n\nexport function useQuery<\n TSchema extends Schema,\n TTable extends keyof TSchema['tables'] & string,\n TReturn,\n>(\n querySignal: () => Query<TSchema, TTable, TReturn>,\n options?: UseQueryOptions | Accessor<UseQueryOptions>,\n): QueryResult<TReturn> {\n // Wrap in in createMemo to ensure a new view is created if the querySignal changes.\n const view = createMemo(() => {\n const ttl = normalize(options)?.ttl;\n const query = querySignal() as AdvancedQuery<TSchema, TTable, TReturn>;\n\n const view = (query as AdvancedQuery<TSchema, TTable, TReturn>).materialize(\n solidViewFactory,\n ttl,\n );\n\n onCleanup(() => {\n view.destroy();\n });\n return view;\n });\n\n return [() => view().data, () => view().resultDetails];\n}\n\nfunction normalize<T>(\n options?: T | Accessor<T | undefined> | undefined,\n): T | undefined {\n return typeof options === 'function' ? (options as Accessor<T>)() : options;\n}\n", "import {\n createStore,\n produce,\n type SetStoreFunction,\n type Store,\n} from 'solid-js/store';\nimport {\n applyChange,\n type Change,\n type Entry,\n type Format,\n type HumanReadable,\n type Input,\n type Output,\n type Query,\n type ViewFactory,\n} from '../../zero-advanced/src/mod.js';\nimport type {Schema} from '../../zero-schema/src/mod.js';\nimport type {ResultType} from '../../zql/src/query/typed-view.js';\nimport type {Node} from '../../zql/src/ivm/data.ts';\nimport type {ViewChange} from '../../zql/src/ivm/view-apply-change.ts';\nimport type {Stream} from '../../zql/src/ivm/stream.ts';\n\nexport type QueryResultDetails = {\n readonly type: ResultType;\n};\n\ntype State = [Entry, QueryResultDetails];\n\nconst complete = {type: 'complete'} as const;\nconst unknown = {type: 'unknown'} as const;\n\nexport class SolidView<V> implements Output {\n readonly #input: Input;\n readonly #format: Format;\n readonly #onDestroy: () => void;\n\n #state: Store<State>;\n #setState: SetStoreFunction<State>;\n\n // Optimization: if the store is currently empty we build up\n // the view on a plain old JS object stored at #builderRoot, and return\n // that for the new state on transaction commit. This avoids building up\n // large views from scratch via solid produce. The proxy object used by\n // solid produce is slow and in this case we don't care about solid tracking\n // the fine grained changes (everything has changed, it's all new). For a\n // test case with a view with 3000 rows, each row having 2 children, this\n // optimization reduced #applyChanges time from 743ms to 133ms.\n #builderRoot: Entry | undefined;\n #pendingChanges: ViewChange[] = [];\n\n constructor(\n input: Input,\n onTransactionCommit: (cb: () => void) => void,\n format: Format,\n onDestroy: () => void,\n queryComplete: true | Promise<true>,\n ) {\n this.#input = input;\n onTransactionCommit(this.#onTransactionCommit);\n this.#format = format;\n this.#onDestroy = onDestroy;\n input.setOutput(this);\n\n const initialRoot = this.#createEmptyRoot();\n this.#applyChangesToRoot(\n input.fetch({}),\n node => ({type: 'add', node}),\n initialRoot,\n );\n [this.#state, this.#setState] = createStore<State>([\n initialRoot,\n queryComplete === true ? complete : unknown,\n ]);\n if (isEmptyRoot(initialRoot)) {\n this.#builderRoot = this.#createEmptyRoot();\n }\n\n if (queryComplete !== true) {\n void queryComplete.then(() => {\n this.#setState(oldState => [oldState[0], complete]);\n });\n }\n }\n\n get data(): V {\n return this.#state[0][''] as V;\n }\n\n get resultDetails(): QueryResultDetails {\n return this.#state[1];\n }\n\n destroy(): void {\n this.#onDestroy();\n }\n\n #onTransactionCommit = () => {\n const builderRoot = this.#builderRoot;\n if (builderRoot) {\n if (!isEmptyRoot(builderRoot)) {\n this.#setState(oldState => [builderRoot, oldState[1]]);\n this.#builderRoot = undefined;\n }\n } else {\n try {\n this.#applyChanges(this.#pendingChanges, c => c);\n } finally {\n this.#pendingChanges = [];\n }\n }\n };\n\n push(change: Change): void {\n // Delay updating the solid store state until the transaction commit\n // (because each update of the solid store is quite expensive). If\n // this.#builderRoot is defined apply the changes to it (we are building\n // from an empty root), otherwise queue the changes to be applied\n // using produce at the end of the transaction but read the relationships\n // now as they are only valid to read when the push is received.\n if (this.#builderRoot) {\n this.#applyChangeToRoot(change, this.#builderRoot);\n } else {\n this.#pendingChanges.push(materializeRelationships(change));\n }\n }\n\n #applyChanges<T>(changes: Iterable<T>, mapper: (v: T) => ViewChange): void {\n this.#setState(\n produce((draftState: State) => {\n this.#applyChangesToRoot<T>(changes, mapper, draftState[0]);\n if (isEmptyRoot(draftState[0])) {\n this.#builderRoot = this.#createEmptyRoot();\n }\n }),\n );\n }\n\n #applyChangesToRoot<T>(\n changes: Iterable<T>,\n mapper: (v: T) => ViewChange,\n root: Entry,\n ) {\n for (const change of changes) {\n this.#applyChangeToRoot(mapper(change), root);\n }\n }\n\n #applyChangeToRoot(change: ViewChange, root: Entry) {\n applyChange(root, change, this.#input.getSchema(), '', this.#format);\n }\n\n #createEmptyRoot(): Entry {\n return {\n '': this.#format.singular ? undefined : [],\n };\n }\n}\n\nfunction materializeRelationships(change: Change): ViewChange {\n switch (change.type) {\n case 'add':\n return {type: 'add', node: materializeNodeRelationships(change.node)};\n case 'remove':\n return {type: 'remove', node: materializeNodeRelationships(change.node)};\n case 'child':\n return {\n type: 'child',\n node: {row: change.node.row},\n child: {\n relationshipName: change.child.relationshipName,\n change: materializeRelationships(change.child.change),\n },\n };\n case 'edit':\n return {\n type: 'edit',\n node: {row: change.node.row},\n oldNode: {row: change.oldNode.row},\n };\n }\n}\n\nfunction materializeNodeRelationships(node: Node): Node {\n const relationships: Record<string, () => Stream<Node>> = {};\n for (const relationship in node.relationships) {\n const materialized: Node[] = [];\n for (const n of node.relationships[relationship]()) {\n materialized.push(materializeNodeRelationships(n));\n }\n relationships[relationship] = () => materialized;\n }\n return {\n row: node.row,\n relationships,\n };\n}\n\nfunction isEmptyRoot(entry: Entry) {\n const data = entry[''];\n return data === undefined || (Array.isArray(data) && data.length === 0);\n}\n\nexport function solidViewFactory<\n TSchema extends Schema,\n TTable extends keyof TSchema['tables'] & string,\n TReturn,\n>(\n _query: Query<TSchema, TTable, TReturn>,\n input: Input,\n format: Format,\n onDestroy: () => void,\n onTransactionCommit: (cb: () => void) => void,\n queryComplete: true | Promise<true>,\n) {\n return new SolidView<HumanReadable<TReturn>>(\n input,\n onTransactionCommit,\n format,\n onDestroy,\n queryComplete,\n );\n}\n\nsolidViewFactory satisfies ViewFactory<Schema, string, unknown, unknown>;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;AAAA,SAAQ,aAAY;AAIb,SAAS,WAA6B,SAAkC;AAC7E,QAAM,OAA+B;AAAA,IACnC,GAAG;AAAA,IACH,kBAAkB;AAAA,EACpB;AACA,SAAO,IAAI,KAAK,IAAI;AACtB;;;ACVA,SAAQ,YAAY,iBAA+B;;;ACAnD;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AAwBP,IAAM,WAAW,EAAC,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Aa;AACvD;AAEA,SAAS,UACP,SACe;AACf,SAAO,OAAO,YAAY,aAAc,QAAwB,IAAI;AACtE;",
|
|
6
6
|
"names": ["view"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-authorizer.d.ts","sourceRoot":"","sources":["../../../../../zero-cache/src/auth/read-authorizer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,MAAM,CAAC;AAGrC,OAAO,KAAK,EAAC,GAAG,EAAY,MAAM,mCAAmC,CAAC;AACtE,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,kDAAkD,CAAC;AAGxF,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAEjD,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,EAAE,GAAG,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AACF;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACnC,EAAE,EAAE,UAAU,EACd,KAAK,EAAE,GAAG,EACV,eAAe,EAAE,iBAAiB,EAClC,QAAQ,EAAE,UAAU,GAAG,SAAS,EAChC,aAAa,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,GACxC,oBAAoB,
|
|
1
|
+
{"version":3,"file":"read-authorizer.d.ts","sourceRoot":"","sources":["../../../../../zero-cache/src/auth/read-authorizer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,MAAM,CAAC;AAGrC,OAAO,KAAK,EAAC,GAAG,EAAY,MAAM,mCAAmC,CAAC;AACtE,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,kDAAkD,CAAC;AAGxF,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAEjD,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,EAAE,GAAG,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AACF;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACnC,EAAE,EAAE,UAAU,EACd,KAAK,EAAE,GAAG,EACV,eAAe,EAAE,iBAAiB,EAClC,QAAQ,EAAE,UAAU,GAAG,SAAS,EAChC,aAAa,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,GACxC,oBAAoB,CAQtB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,EAAE,EAAE,UAAU,EACd,KAAK,EAAE,GAAG,EACV,eAAe,EAAE,iBAAiB,EAClC,QAAQ,EAAE,UAAU,GAAG,SAAS,GAC/B,GAAG,CASL"}
|
|
@@ -14,7 +14,6 @@ export function transformAndHashQuery(lc, query, permissionRules, authData, inte
|
|
|
14
14
|
const transformed = internalQuery
|
|
15
15
|
? query // application permissions do not apply to internal queries
|
|
16
16
|
: transformQuery(lc, query, permissionRules, authData);
|
|
17
|
-
lc.debug?.(`read authorizer transformed query ${JSON.stringify(query)} to ${JSON.stringify(transformed)} and authData ${JSON.stringify(authData)}`);
|
|
18
17
|
return {
|
|
19
18
|
query: transformed,
|
|
20
19
|
hash: hashOfAST(transformed),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-authorizer.js","sourceRoot":"","sources":["../../../../../zero-cache/src/auth/read-authorizer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,SAAS,EAAC,MAAM,wCAAwC,CAAC;AAGjE,OAAO,EAAC,oBAAoB,EAAC,MAAM,qCAAqC,CAAC;AACzE,OAAO,EAAC,GAAG,EAAC,MAAM,+BAA+B,CAAC;AAOlD;;;;;;;;GAQG;AACH,MAAM,UAAU,qBAAqB,CACnC,EAAc,EACd,KAAU,EACV,eAAkC,EAClC,QAAgC,EAChC,aAAyC;IAEzC,MAAM,WAAW,GAAG,aAAa;QAC/B,CAAC,CAAC,KAAK,CAAC,2DAA2D;QACnE,CAAC,CAAC,cAAc,CAAC,EAAE,EAAE,KAAK,EAAE,eAAe,EAAE,QAAQ,CAAC,CAAC;IACzD,
|
|
1
|
+
{"version":3,"file":"read-authorizer.js","sourceRoot":"","sources":["../../../../../zero-cache/src/auth/read-authorizer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,SAAS,EAAC,MAAM,wCAAwC,CAAC;AAGjE,OAAO,EAAC,oBAAoB,EAAC,MAAM,qCAAqC,CAAC;AACzE,OAAO,EAAC,GAAG,EAAC,MAAM,+BAA+B,CAAC;AAOlD;;;;;;;;GAQG;AACH,MAAM,UAAU,qBAAqB,CACnC,EAAc,EACd,KAAU,EACV,eAAkC,EAClC,QAAgC,EAChC,aAAyC;IAEzC,MAAM,WAAW,GAAG,aAAa;QAC/B,CAAC,CAAC,KAAK,CAAC,2DAA2D;QACnE,CAAC,CAAC,cAAc,CAAC,EAAE,EAAE,KAAK,EAAE,eAAe,EAAE,QAAQ,CAAC,CAAC;IACzD,OAAO;QACL,KAAK,EAAE,WAAW;QAClB,IAAI,EAAE,SAAS,CAAC,WAAW,CAAC;KAC7B,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAC5B,EAAc,EACd,KAAU,EACV,eAAkC,EAClC,QAAgC;IAEhC,MAAM,oBAAoB,GAAG,sBAAsB,CACjD,EAAE,EACF,KAAK,EACL,eAAe,CAChB,CAAC;IACF,OAAO,oBAAoB,CAAC,oBAAoB,EAAE;QAChD,QAAQ,EAAE,QAAqC;KAChD,CAAC,CAAC;AACL,CAAC;AAED,SAAS,sBAAsB,CAC7B,EAAc,EACd,KAAU,EACV,eAAkC;IAElC,IAAI,cAAc,GAAG,eAAe,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC;IAEtE,IAAI,CAAC,cAAc,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACnD,6EAA6E;QAC7E,EAAE,CAAC,IAAI,EAAE,CACP,uCAAuC;YACrC,KAAK,CAAC,KAAK;YACX,oFAAoF,CACvF,CAAC;QACF,cAAc,GAA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KAAK,IAAI;YACP,OAAO;gBACL,GAAG,IAAI;gBACP,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,kBAAkB,CAAC,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;aACtE,CAAC;QACJ,KAAK,oBAAoB,CAAC,CAAC,CAAC;YAC1B,MAAM,KAAK,GAAG,sBAAsB,CAAC,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;YACtE,OAAO;gBACL,GAAG,IAAI;gBACP,OAAO,EAAE;oBACP,GAAG,IAAI,CAAC,OAAO;oBACf,QAAQ,EAAE,KAAK;iBAChB;aACF,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -4,21 +4,38 @@
|
|
|
4
4
|
import { type Config } from '../../../shared/src/options.ts';
|
|
5
5
|
import * as v from '../../../shared/src/valita.ts';
|
|
6
6
|
export type { LogConfig } from '../../../otel/src/log-options.ts';
|
|
7
|
-
|
|
8
|
-
* Configures the view of the upstream database replicated to this zero-cache.
|
|
9
|
-
*/
|
|
10
|
-
declare const shardOptions: {
|
|
7
|
+
export declare const appOptions: {
|
|
11
8
|
id: {
|
|
12
9
|
type: v.Type<string>;
|
|
13
10
|
desc: string[];
|
|
14
|
-
allCaps: boolean;
|
|
15
11
|
};
|
|
16
12
|
publications: {
|
|
17
13
|
type: v.Type<string[]>;
|
|
18
14
|
desc: string[];
|
|
19
15
|
};
|
|
20
16
|
};
|
|
21
|
-
export
|
|
17
|
+
export declare const shardOptions: {
|
|
18
|
+
id: {
|
|
19
|
+
type: v.Optional<string>;
|
|
20
|
+
hidden: boolean;
|
|
21
|
+
};
|
|
22
|
+
num: {
|
|
23
|
+
type: v.Type<number>;
|
|
24
|
+
desc: string[];
|
|
25
|
+
hidden: boolean;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
declare const replicaOptions: {
|
|
29
|
+
file: {
|
|
30
|
+
type: v.Type<string>;
|
|
31
|
+
desc: string[];
|
|
32
|
+
};
|
|
33
|
+
vacuumIntervalHours: {
|
|
34
|
+
type: v.Optional<number>;
|
|
35
|
+
desc: string[];
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export type ReplicaOptions = Config<typeof replicaOptions>;
|
|
22
39
|
declare const perUserMutationLimit: {
|
|
23
40
|
max: {
|
|
24
41
|
type: v.Optional<number>;
|
|
@@ -77,7 +94,7 @@ export declare const zeroOptions: {
|
|
|
77
94
|
};
|
|
78
95
|
cvr: {
|
|
79
96
|
db: {
|
|
80
|
-
type: v.
|
|
97
|
+
type: v.Optional<string>;
|
|
81
98
|
desc: string[];
|
|
82
99
|
};
|
|
83
100
|
maxConns: {
|
|
@@ -95,7 +112,7 @@ export declare const zeroOptions: {
|
|
|
95
112
|
};
|
|
96
113
|
change: {
|
|
97
114
|
db: {
|
|
98
|
-
type: v.
|
|
115
|
+
type: v.Optional<string>;
|
|
99
116
|
desc: string[];
|
|
100
117
|
};
|
|
101
118
|
maxConns: {
|
|
@@ -103,9 +120,15 @@ export declare const zeroOptions: {
|
|
|
103
120
|
desc: string[];
|
|
104
121
|
};
|
|
105
122
|
};
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
123
|
+
replica: {
|
|
124
|
+
file: {
|
|
125
|
+
type: v.Type<string>;
|
|
126
|
+
desc: string[];
|
|
127
|
+
};
|
|
128
|
+
vacuumIntervalHours: {
|
|
129
|
+
type: v.Optional<number>;
|
|
130
|
+
desc: string[];
|
|
131
|
+
};
|
|
109
132
|
};
|
|
110
133
|
log: {
|
|
111
134
|
level: v.Type<"error" | "debug" | "info" | "warn">;
|
|
@@ -126,17 +149,27 @@ export declare const zeroOptions: {
|
|
|
126
149
|
desc: string[];
|
|
127
150
|
};
|
|
128
151
|
};
|
|
129
|
-
|
|
152
|
+
app: {
|
|
130
153
|
id: {
|
|
131
154
|
type: v.Type<string>;
|
|
132
155
|
desc: string[];
|
|
133
|
-
allCaps: boolean;
|
|
134
156
|
};
|
|
135
157
|
publications: {
|
|
136
158
|
type: v.Type<string[]>;
|
|
137
159
|
desc: string[];
|
|
138
160
|
};
|
|
139
161
|
};
|
|
162
|
+
shard: {
|
|
163
|
+
id: {
|
|
164
|
+
type: v.Optional<string>;
|
|
165
|
+
hidden: boolean;
|
|
166
|
+
};
|
|
167
|
+
num: {
|
|
168
|
+
type: v.Type<number>;
|
|
169
|
+
desc: string[];
|
|
170
|
+
hidden: boolean;
|
|
171
|
+
};
|
|
172
|
+
};
|
|
140
173
|
auth: {
|
|
141
174
|
jwk: {
|
|
142
175
|
type: v.Optional<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zero-config.d.ts","sourceRoot":"","sources":["../../../../../zero-cache/src/config/zero-config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAe,KAAK,MAAM,EAAC,MAAM,gCAAgC,CAAC;AACzE,OAAO,KAAK,CAAC,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"zero-config.d.ts","sourceRoot":"","sources":["../../../../../zero-cache/src/config/zero-config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAe,KAAK,MAAM,EAAC,MAAM,gCAAgC,CAAC;AACzE,OAAO,KAAK,CAAC,MAAM,+BAA+B,CAAC;AAOnD,YAAY,EAAC,SAAS,EAAC,MAAM,kCAAkC,CAAC;AAEhE,eAAO,MAAM,UAAU;;;;;;;;;CA8CtB,CAAC;AAEF,eAAO,MAAM,YAAY;;;;;;;;;;CAwBxB,CAAC;AAEF,QAAA,MAAM,cAAc;;;;;;;;;CAmBnB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,cAAc,CAAC,CAAC;AAE3D,QAAA,MAAM,oBAAoB;;;;;;;;;CAczB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAE5D,QAAA,MAAM,WAAW;;;;;;;;;;;;;CAmBhB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,WAAW,CAAC,CAAC;AAKpD,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6SvB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,WAAW,CAAC,CAAC;AAEpD,eAAO,MAAM,mBAAmB,UAAU,CAAC;AAI3C,wBAAgB,aAAa,CAC3B,GAAG,GAAE,MAAM,CAAC,UAAwB,EACpC,IAAI,WAAwB,GAC3B,UAAU,CAUZ"}
|
|
@@ -6,43 +6,90 @@ import { parseOptions } from "../../../shared/src/options.js";
|
|
|
6
6
|
import * as v from "../../../shared/src/valita.js";
|
|
7
7
|
import { runtimeDebugFlags } from "../../../zqlite/src/runtime-debug.js";
|
|
8
8
|
import { singleProcessMode } from "../types/processes.js";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*/
|
|
12
|
-
const shardOptions = {
|
|
9
|
+
import { ALLOWED_APP_ID_CHARACTERS, INVALID_APP_ID_MESSAGE, } from "../types/shards.js";
|
|
10
|
+
export const appOptions = {
|
|
13
11
|
id: {
|
|
14
|
-
type: v
|
|
12
|
+
type: v
|
|
13
|
+
.string()
|
|
14
|
+
.default('zero')
|
|
15
|
+
.assert(id => ALLOWED_APP_ID_CHARACTERS.test(id), INVALID_APP_ID_MESSAGE),
|
|
15
16
|
desc: [
|
|
16
|
-
'Unique identifier for the
|
|
17
|
+
'Unique identifier for the app.',
|
|
18
|
+
'',
|
|
19
|
+
'Multiple zero-cache apps can run on a single upstream database, each of which',
|
|
20
|
+
'is isolated from the others, with its own permissions, sharding (future feature),',
|
|
21
|
+
'and change/cvr databases.',
|
|
17
22
|
'',
|
|
18
|
-
'
|
|
19
|
-
'
|
|
23
|
+
'The metadata of an app is stored in an upstream schema with the same name,',
|
|
24
|
+
'e.g. "zero", and the metadata for each app shard, e.g. client and mutation',
|
|
25
|
+
'ids, is stored in the "\\{app-id\\}_\\{#\\}" schema. (Currently there is only a single',
|
|
26
|
+
'"0" shard, but this will change with sharding).',
|
|
20
27
|
'',
|
|
21
|
-
|
|
22
|
-
|
|
28
|
+
'The CVR and Change data are managed in schemas named "\\{app-id\\}_\\{shard-num\\}/cvr"',
|
|
29
|
+
'and "\\{app-id\\}_\\{shard-num\\}/cdc", respectively, allowing multiple apps and shards',
|
|
30
|
+
'to share the same database instance (e.g. a Postgres "cluster") for CVR and Change management.',
|
|
23
31
|
'',
|
|
24
|
-
'Due to constraints on replication slot names,
|
|
32
|
+
'Due to constraints on replication slot names, an App ID may only consist of',
|
|
25
33
|
'lower-case letters, numbers, and the underscore character.',
|
|
26
34
|
],
|
|
27
|
-
allCaps: true, // so that the flag is --shardID
|
|
28
35
|
},
|
|
29
36
|
publications: {
|
|
30
37
|
type: v.array(v.string()).optional(() => []),
|
|
31
38
|
desc: [
|
|
32
|
-
`Postgres {bold PUBLICATION}s that define the
|
|
33
|
-
`
|
|
39
|
+
`Postgres {bold PUBLICATION}s that define the tables and columns to`,
|
|
40
|
+
`replicate. Publication names may not begin with an underscore,`,
|
|
34
41
|
`as zero reserves that prefix for internal use.`,
|
|
35
42
|
``,
|
|
36
43
|
`If unspecified, zero-cache will create and use an internal publication that`,
|
|
37
44
|
`publishes all tables in the {bold public} schema, i.e.:`,
|
|
38
45
|
``,
|
|
39
|
-
`CREATE PUBLICATION
|
|
46
|
+
`CREATE PUBLICATION _\\{app-id\\}_public_0 FOR TABLES IN SCHEMA public;`,
|
|
40
47
|
``,
|
|
41
|
-
`Note that once
|
|
48
|
+
`Note that once an app has begun syncing data, this list of publications`,
|
|
42
49
|
`cannot be changed, and zero-cache will refuse to start if a specified`,
|
|
43
50
|
`value differs from what was originally synced.`,
|
|
44
51
|
``,
|
|
45
|
-
`To use a different set of publications, a new
|
|
52
|
+
`To use a different set of publications, a new app should be created.`,
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
export const shardOptions = {
|
|
57
|
+
id: {
|
|
58
|
+
type: v
|
|
59
|
+
.string()
|
|
60
|
+
.assert(() => {
|
|
61
|
+
throw new Error(`ZERO_SHARD_ID is deprecated. Please use ZERO_APP_ID instead.`);
|
|
62
|
+
})
|
|
63
|
+
.optional(),
|
|
64
|
+
hidden: true,
|
|
65
|
+
},
|
|
66
|
+
num: {
|
|
67
|
+
type: v.number().default(0),
|
|
68
|
+
desc: [
|
|
69
|
+
`The shard number (from 0 to NUM_SHARDS) of the App. zero will eventually`,
|
|
70
|
+
`support data sharding as a first-class primitive; until then, deploying`,
|
|
71
|
+
`multiple shard-nums creates functionally identical shards. Until sharding is`,
|
|
72
|
+
`actually meaningful, this flag is hidden but available for testing.`,
|
|
73
|
+
],
|
|
74
|
+
hidden: true,
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
const replicaOptions = {
|
|
78
|
+
file: {
|
|
79
|
+
type: v.string(),
|
|
80
|
+
desc: [
|
|
81
|
+
`File path to the SQLite replica that zero-cache maintains.`,
|
|
82
|
+
`This can be lost, but if it is, zero-cache will have to re-replicate next`,
|
|
83
|
+
`time it starts up.`,
|
|
84
|
+
],
|
|
85
|
+
},
|
|
86
|
+
vacuumIntervalHours: {
|
|
87
|
+
type: v.number().optional(),
|
|
88
|
+
desc: [
|
|
89
|
+
`Performs a VACUUM at server startup if the specified number of hours has elapsed`,
|
|
90
|
+
`since the last VACUUM (or initial-sync). The VACUUM operation is heavyweight`,
|
|
91
|
+
`and requires double the size of the db in disk space. If unspecified, VACUUM`,
|
|
92
|
+
`operations are not performed.`,
|
|
46
93
|
],
|
|
47
94
|
},
|
|
48
95
|
};
|
|
@@ -136,12 +183,11 @@ export const zeroOptions = {
|
|
|
136
183
|
},
|
|
137
184
|
cvr: {
|
|
138
185
|
db: {
|
|
139
|
-
type: v.string(),
|
|
186
|
+
type: v.string().optional(),
|
|
140
187
|
desc: [
|
|
141
|
-
`
|
|
142
|
-
`
|
|
143
|
-
`
|
|
144
|
-
`for it to be a separate "database" in the same postgres "cluster".`,
|
|
188
|
+
`The Postgres database used to store CVRs. CVRs (client view records) keep track`,
|
|
189
|
+
`of the data synced to clients in order to determine the diff to send on reconnect.`,
|
|
190
|
+
`If unspecified, the {bold upstream-db} will be used.`,
|
|
145
191
|
],
|
|
146
192
|
},
|
|
147
193
|
maxConns: {
|
|
@@ -168,8 +214,12 @@ export const zeroOptions = {
|
|
|
168
214
|
},
|
|
169
215
|
change: {
|
|
170
216
|
db: {
|
|
171
|
-
type: v.string(),
|
|
172
|
-
desc: [
|
|
217
|
+
type: v.string().optional(),
|
|
218
|
+
desc: [
|
|
219
|
+
`The Postgres database used to store recent replication log entries, in order`,
|
|
220
|
+
`to sync multiple view-syncers without requiring multiple replication slots on`,
|
|
221
|
+
`the upstream database. If unspecified, the {bold upstream-db} will be used.`,
|
|
222
|
+
],
|
|
173
223
|
},
|
|
174
224
|
maxConns: {
|
|
175
225
|
type: v.number().default(5),
|
|
@@ -180,15 +230,9 @@ export const zeroOptions = {
|
|
|
180
230
|
],
|
|
181
231
|
},
|
|
182
232
|
},
|
|
183
|
-
|
|
184
|
-
type: v.string(),
|
|
185
|
-
desc: [
|
|
186
|
-
`File path to the SQLite replica that zero-cache maintains.`,
|
|
187
|
-
`This can be lost, but if it is, zero-cache will have to re-replicate next`,
|
|
188
|
-
`time it starts up.`,
|
|
189
|
-
],
|
|
190
|
-
},
|
|
233
|
+
replica: replicaOptions,
|
|
191
234
|
log: logOptions,
|
|
235
|
+
app: appOptions,
|
|
192
236
|
shard: shardOptions,
|
|
193
237
|
auth: authOptions,
|
|
194
238
|
port: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zero-config.js","sourceRoot":"","sources":["../../../../../zero-cache/src/config/zero-config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAC,UAAU,EAAC,MAAM,kCAAkC,CAAC;AAC5D,OAAO,EAAC,YAAY,EAAc,MAAM,gCAAgC,CAAC;AACzE,OAAO,KAAK,CAAC,MAAM,+BAA+B,CAAC;AACnD,OAAO,EAAC,iBAAiB,EAAC,MAAM,sCAAsC,CAAC;AACvE,OAAO,EAAC,iBAAiB,EAAC,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"zero-config.js","sourceRoot":"","sources":["../../../../../zero-cache/src/config/zero-config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAC,UAAU,EAAC,MAAM,kCAAkC,CAAC;AAC5D,OAAO,EAAC,YAAY,EAAc,MAAM,gCAAgC,CAAC;AACzE,OAAO,KAAK,CAAC,MAAM,+BAA+B,CAAC;AACnD,OAAO,EAAC,iBAAiB,EAAC,MAAM,sCAAsC,CAAC;AACvE,OAAO,EAAC,iBAAiB,EAAC,MAAM,uBAAuB,CAAC;AACxD,OAAO,EACL,yBAAyB,EACzB,sBAAsB,GACvB,MAAM,oBAAoB,CAAC;AAG5B,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,EAAE,EAAE;QACF,IAAI,EAAE,CAAC;aACJ,MAAM,EAAE;aACR,OAAO,CAAC,MAAM,CAAC;aACf,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,yBAAyB,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,sBAAsB,CAAC;QAC3E,IAAI,EAAE;YACJ,gCAAgC;YAChC,EAAE;YACF,+EAA+E;YAC/E,mFAAmF;YACnF,2BAA2B;YAC3B,EAAE;YACF,4EAA4E;YAC5E,4EAA4E;YAC5E,wFAAwF;YACxF,iDAAiD;YACjD,EAAE;YACF,yFAAyF;Y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