@rocicorp/zero 0.17.2025022800 → 0.17.2025030300
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-BBNRRMOA.js} +3998 -524
- package/out/chunk-BBNRRMOA.js.map +7 -0
- package/out/shared/src/set-utils.d.ts +1 -1
- package/out/shared/src/set-utils.js +1 -1
- package/out/solid.js +2 -3
- package/out/solid.js.map +1 -1
- package/out/zero-cache/src/config/zero-config.d.ts +24 -8
- package/out/zero-cache/src/config/zero-config.d.ts.map +1 -1
- package/out/zero-cache/src/config/zero-config.js +46 -17
- package/out/zero-cache/src/config/zero-config.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/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 +7 -6
- 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 +3 -2
- package/out/zero-cache/src/server/main.js.map +1 -1
- package/out/zero-cache/src/server/multi/config.d.ts +12 -2
- package/out/zero-cache/src/server/multi/config.d.ts.map +1 -1
- package/out/zero-cache/src/server/multi/config.js +1 -1
- package/out/zero-cache/src/server/multi/config.js.map +1 -1
- package/out/zero-cache/src/server/syncer.d.ts.map +1 -1
- package/out/zero-cache/src/server/syncer.js +4 -3
- 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 +4 -4
- 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 +29 -31
- 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 +3 -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 +12 -17
- 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 +2 -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/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 +13 -15
- package/out/zero-cache/src/services/mutagen/mutagen.js.map +1 -1
- package/out/zero-cache/src/services/replicator/schema/replication-state.d.ts +7 -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.map +1 -1
- package/out/zero-cache/src/services/view-syncer/client-handler.d.ts +2 -1
- 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 +3 -2
- 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 +20 -10
- 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 +6 -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 +106 -63
- package/out/zero-cache/src/services/view-syncer/cvr.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 +10 -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 +159 -31
- package/out/zero-cache/src/services/view-syncer/view-syncer.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-client/src/client/zero.d.ts.map +1 -1
- package/out/zero-pg/src/mod.d.ts +1 -0
- package/out/zero-pg/src/mod.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/query/query-impl.js.map +1 -1
- package/package.json +2 -2
- 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
|
@@ -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-BBNRRMOA.js";
|
|
6
4
|
import "./chunk-HARIWJ2J.js";
|
|
5
|
+
import "./chunk-ULOTOBTC.js";
|
|
7
6
|
import {
|
|
8
7
|
applyChange
|
|
9
8
|
} from "./chunk-Q6D7EOS6.js";
|
package/out/solid.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
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
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>): QueryResult<TReturn> {\n // Wrap in in createMemo to ensure a new view is created if the querySignal changes.\n const view = createMemo(() => {\n const query = querySignal();\n const view = (query as AdvancedQuery<TSchema, TTable, TReturn>).materialize(\n solidViewFactory,\n );\n\n onCleanup(() => {\n view.destroy();\n });\n return view;\n });\n\n return [() => view().data, () => view().resultDetails];\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": "
|
|
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,MAAM,WAAU;AAClC,IAAM,UAAU,EAAC,MAAM,UAAS;AAEzB,IAAM,YAAN,MAAqC;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EAET;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA;AAAA,EACA,kBAAgC,CAAC;AAAA,EAEjC,YACE,OACA,qBACA,QACA,WACA,eACA;AACA,SAAK,SAAS;AACd,wBAAoB,KAAK,oBAAoB;AAC7C,SAAK,UAAU;AACf,SAAK,aAAa;AAClB,UAAM,UAAU,IAAI;AAEpB,UAAM,cAAc,KAAK,iBAAiB;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,eAAe;AAC7C,UAAM,eAAuB,CAAC;AAC9B,eAAW,KAAK,KAAK,cAAc,YAAY,EAAE,GAAG;AAClD,mBAAa,KAAK,6BAA6B,CAAC,CAAC;AAAA,IACnD;AACA,kBAAc,YAAY,IAAI,MAAM;AAAA,EACtC;AACA,SAAO;AAAA,IACL,KAAK,KAAK;AAAA,IACV;AAAA,EACF;AACF;AAEA,SAAS,YAAY,OAAc;AACjC,QAAM,OAAO,MAAM,EAAE;AACrB,SAAO,SAAS,UAAc,MAAM,QAAQ,IAAI,KAAK,KAAK,WAAW;AACvE;AAEO,SAAS,iBAKd,QACA,OACA,QACA,WACA,qBACA,eACA;AACA,SAAO,IAAI;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;;;ADhNO,SAAS,SAId,aAA0E;AAE1E,QAAM,OAAO,WAAW,MAAM;AAC5B,UAAM,QAAQ,YAAY;AAC1B,UAAMA,QAAQ,MAAkD;AAAA,MAC9D;AAAA,IACF;AAEA,cAAU,MAAM;AACd,MAAAA,MAAK,QAAQ;AAAA,IACf,CAAC;AACD,WAAOA;AAAA,EACT,CAAC;AAED,SAAO,CAAC,MAAM,KAAK,EAAE,MAAM,MAAM,KAAK,EAAE,aAAa;AACvD;",
|
|
6
6
|
"names": ["view"]
|
|
7
7
|
}
|
|
@@ -4,21 +4,27 @@
|
|
|
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
|
+
};
|
|
22
28
|
declare const perUserMutationLimit: {
|
|
23
29
|
max: {
|
|
24
30
|
type: v.Optional<number>;
|
|
@@ -126,17 +132,27 @@ export declare const zeroOptions: {
|
|
|
126
132
|
desc: string[];
|
|
127
133
|
};
|
|
128
134
|
};
|
|
129
|
-
|
|
135
|
+
app: {
|
|
130
136
|
id: {
|
|
131
137
|
type: v.Type<string>;
|
|
132
138
|
desc: string[];
|
|
133
|
-
allCaps: boolean;
|
|
134
139
|
};
|
|
135
140
|
publications: {
|
|
136
141
|
type: v.Type<string[]>;
|
|
137
142
|
desc: string[];
|
|
138
143
|
};
|
|
139
144
|
};
|
|
145
|
+
shard: {
|
|
146
|
+
id: {
|
|
147
|
+
type: v.Optional<string>;
|
|
148
|
+
hidden: boolean;
|
|
149
|
+
};
|
|
150
|
+
num: {
|
|
151
|
+
type: v.Type<number>;
|
|
152
|
+
desc: string[];
|
|
153
|
+
hidden: boolean;
|
|
154
|
+
};
|
|
155
|
+
};
|
|
140
156
|
auth: {
|
|
141
157
|
jwk: {
|
|
142
158
|
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,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiTvB,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,46 +6,74 @@ 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.`,
|
|
46
53
|
],
|
|
47
54
|
},
|
|
48
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
|
+
};
|
|
49
77
|
const perUserMutationLimit = {
|
|
50
78
|
max: {
|
|
51
79
|
type: v.number().optional(),
|
|
@@ -189,6 +217,7 @@ export const zeroOptions = {
|
|
|
189
217
|
],
|
|
190
218
|
},
|
|
191
219
|
log: logOptions,
|
|
220
|
+
app: appOptions,
|
|
192
221
|
shard: shardOptions,
|
|
193
222
|
auth: authOptions,
|
|
194
223
|
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,CAA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,8DAA8D,CAAC;QACtE,MAAM,EAAE,IAAI;KACb;CACF,CAAC;AAIF,MAAM,CAAC,MAAM,mBAAmB,GAAG,OAAO,CAAC;AAE3C,IAAI,YAAoC,CAAC;AAEzC,MAAM,UAAU,aAAa,CAC3B,MAAyB,OAAO,CAAC,GAAG,EACpC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAE5B,IAAI,CAAC,YAAY,IAAI,iBAAiB,EAAE,EAAE,CAAC;QACzC,YAAY,GAAG,YAAY,CAAC,WAAW,EAAE,IAAI,EAAE,mBAAmB,EAAE,GAAG,CAAC,CAAC;QAEzE,IAAI,YAAY,CAAC,mBAAmB,EAAE,CAAC;YACrC,iBAAiB,CAAC,eAAe,GAAG,IAAI,CAAC;QAC3C,CAAC;IACH,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC"}
|
|
@@ -75,6 +75,6 @@ export declare const versionHistory: v.ObjectType<{
|
|
|
75
75
|
}, undefined>;
|
|
76
76
|
export type VersionHistory = v.Infer<typeof versionHistory>;
|
|
77
77
|
export declare function createVersionHistoryTable(sql: postgres.Sql, schemaName: string): Promise<void>;
|
|
78
|
-
export declare function getVersionHistory(sql: postgres.Sql, schemaName: string): Promise<VersionHistory>;
|
|
78
|
+
export declare function getVersionHistory(sql: postgres.Sql, schemaName: string, create?: boolean): Promise<VersionHistory | null>;
|
|
79
79
|
export {};
|
|
80
80
|
//# sourceMappingURL=migration.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration.d.ts","sourceRoot":"","sources":["../../../../../zero-cache/src/db/migration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"migration.d.ts","sourceRoot":"","sources":["../../../../../zero-cache/src/db/migration.ts"],"names":[],"mappings":"AAAA,OAA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UAAQ,GACb,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAuBhC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { assert } from "../../../shared/src/asserts.js";
|
|
2
|
+
import { must } from "../../../shared/src/must.js";
|
|
2
3
|
import * as v from "../../../shared/src/valita.js";
|
|
3
4
|
/**
|
|
4
5
|
* Ensures that the schema is compatible with the current code, updating and
|
|
@@ -13,7 +14,7 @@ export async function runSchemaMigrations(log, debugName, schemaName, db, setupM
|
|
|
13
14
|
const codeVersion = versionMigrations[versionMigrations.length - 1][0];
|
|
14
15
|
log.info?.(`Checking schema for compatibility with ${debugName} at schema v${codeVersion}`);
|
|
15
16
|
let versions = await db.begin(async (tx) => {
|
|
16
|
-
const versions = await
|
|
17
|
+
const versions = await ensureVersionHistory(tx, schemaName);
|
|
17
18
|
if (codeVersion < versions.minSafeVersion) {
|
|
18
19
|
throw new Error(`Cannot run ${debugName} at schema v${codeVersion} because rollback limit is v${versions.minSafeVersion}`);
|
|
19
20
|
}
|
|
@@ -34,7 +35,7 @@ export async function runSchemaMigrations(log, debugName, schemaName, db, setupM
|
|
|
34
35
|
void log.flush(); // Flush logs before each migration to help debug crash-y migrations.
|
|
35
36
|
versions = await db.begin(async (tx) => {
|
|
36
37
|
// Fetch meta from within the transaction to make the migration atomic.
|
|
37
|
-
let versions = await
|
|
38
|
+
let versions = await ensureVersionHistory(tx, schemaName);
|
|
38
39
|
if (versions.dataVersion < dest) {
|
|
39
40
|
versions = await runMigration(log, schemaName, tx, versions, dest, migration);
|
|
40
41
|
assert(versions.dataVersion === dest);
|
|
@@ -102,19 +103,29 @@ export async function createVersionHistoryTable(sql, schemaName) {
|
|
|
102
103
|
CONSTRAINT CK_schema_meta_lock CHECK (lock='v')
|
|
103
104
|
);`.simple();
|
|
104
105
|
}
|
|
105
|
-
|
|
106
|
+
async function ensureVersionHistory(sql, schemaName) {
|
|
107
|
+
return must(await getVersionHistory(sql, schemaName, true));
|
|
108
|
+
}
|
|
109
|
+
export async function getVersionHistory(sql, schemaName, create = false) {
|
|
106
110
|
const exists = await sql `
|
|
107
111
|
SELECT nspname, relname FROM pg_class
|
|
108
112
|
JOIN pg_namespace ON relnamespace = pg_namespace.oid
|
|
109
113
|
WHERE nspname = ${schemaName} AND relname = ${'versionHistory'}`;
|
|
110
114
|
if (exists.length === 0) {
|
|
111
|
-
|
|
115
|
+
if (create) {
|
|
116
|
+
await createVersionHistoryTable(sql, schemaName);
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
112
121
|
}
|
|
113
122
|
const rows = await sql `
|
|
114
123
|
SELECT "dataVersion", "schemaVersion", "minSafeVersion"
|
|
115
124
|
FROM ${sql(schemaName)}."versionHistory"`;
|
|
116
125
|
if (rows.length === 0) {
|
|
117
|
-
return
|
|
126
|
+
return create
|
|
127
|
+
? { schemaVersion: 0, dataVersion: 0, minSafeVersion: 0 }
|
|
128
|
+
: null;
|
|
118
129
|
}
|
|
119
130
|
return v.parse(rows[0], versionHistory);
|
|
120
131
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration.js","sourceRoot":"","sources":["../../../../../zero-cache/src/db/migration.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,MAAM,EAAC,MAAM,gCAAgC,CAAC;AACtD,OAAO,KAAK,CAAC,MAAM,+BAA+B,CAAC;AAkDnD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,GAAe,EACf,SAAiB,EACjB,UAAkB,EAClB,EAAc,EACd,cAAyB,EACzB,uBAAgD;IAEhD,GAAG,GAAG,GAAG,CAAC,WAAW,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;IAChD,IAAI,CAAC;QACH,MAAM,iBAAiB,GAAG,MAAM,CAAC,uBAAuB,CAAC,CAAC;QAC1D,MAAM,CACJ,iBAAiB,CAAC,MAAM,EACxB,6CAA6C,CAC9C,CAAC;QACF,MAAM,CACJ,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AAc,CACzB,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAS,iBAAiB,CACxB,GAAe,EACf,OAAuB,EACvB,mBAA4B;IAE5B,IAAI,mBAAmB,KAAK,SAAS,EAAE,CAAC;QACtC,OAAO,OAAO,CAAC,cAAc,CAAC;IAChC,CAAC;IACD,IAAI,OAAO,CAAC,cAAc,IAAI,mBAAmB,EAAE,CAAC;QAClD,gDAAgD;QAChD,GAAG,CAAC,KAAK,EAAE,CACT,gCAAgC,OAAO,CAAC,cAAc,IAAI;YACxD,yBAAyB,mBAAmB,EAAE,CACjD,CAAC;QACF,OAAO,OAAO,CAAC,cAAc,CAAC;IAChC,CAAC;IACD,GAAG,CAAC,IAAI,EAAE,CACR,+BAA+B,OAAO,CAAC,cAAc,OAAO,mBAAmB,EAAE,CAClF,CAAC;IACF,OAAO,mBAAmB,CAAC;AAC7B,CAAC"}
|
|
@@ -1,36 +1,49 @@
|
|
|
1
1
|
import { consoleLogSink, LogContext } from '@rocicorp/logger';
|
|
2
2
|
import 'dotenv/config';
|
|
3
3
|
import { writeFile } from 'node:fs/promises';
|
|
4
|
-
import { literal } from 'pg-format';
|
|
4
|
+
import { ident as id, literal } from 'pg-format';
|
|
5
5
|
import { parseOptions } from "../../../shared/src/options.js";
|
|
6
|
+
import { difference } from "../../../shared/src/set-utils.js";
|
|
6
7
|
import { mapCondition } from "../../../zero-protocol/src/ast.js";
|
|
7
8
|
import {} from "../../../zero-schema/src/compiled-permissions.js";
|
|
8
9
|
import { validator } from "../../../zero-schema/src/name-mapper.js";
|
|
9
10
|
import { ZERO_ENV_VAR_PREFIX } from "../config/zero-config.js";
|
|
10
11
|
import { getPublicationInfo } from "../services/change-source/pg/schema/published.js";
|
|
11
|
-
import { ensureGlobalTables } from "../services/change-source/pg/schema/shard.js";
|
|
12
|
+
import { ensureGlobalTables, SHARD_CONFIG_TABLE, } from "../services/change-source/pg/schema/shard.js";
|
|
12
13
|
import { liteTableName } from "../types/names.js";
|
|
13
14
|
import { pgClient } from "../types/pg.js";
|
|
15
|
+
import { appSchema, getShardID, upstreamSchema } from "../types/shards.js";
|
|
14
16
|
import { deployPermissionsOptions, loadPermissions } from "./permissions.js";
|
|
15
17
|
const config = parseOptions(deployPermissionsOptions, process.argv.slice(2), ZERO_ENV_VAR_PREFIX);
|
|
18
|
+
const shard = getShardID(config);
|
|
19
|
+
const app = appSchema(shard);
|
|
16
20
|
const lc = new LogContext('debug', {}, consoleLogSink);
|
|
17
21
|
async function validatePermissions(db, permissions) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
const schema = upstreamSchema(shard);
|
|
23
|
+
// Check if the shardConfig table has been initialized.
|
|
24
|
+
const result = await db `
|
|
25
|
+
SELECT relname FROM pg_class
|
|
26
|
+
JOIN pg_namespace ON relnamespace = pg_namespace.oid
|
|
27
|
+
WHERE nspname = ${schema} AND relname = ${SHARD_CONFIG_TABLE}`;
|
|
28
|
+
if (result.length === 0) {
|
|
29
|
+
lc.warn?.(`zero-cache has not yet initialized the upstream database.\n` +
|
|
30
|
+
`Deploying ${app} permissions without validating against published tables/columns.`);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
// Get the publications for the shard
|
|
34
|
+
const [{ publications: shardPublications }] = await db `
|
|
35
|
+
SELECT publications FROM ${db(schema + '.' + SHARD_CONFIG_TABLE)}
|
|
36
|
+
`;
|
|
37
|
+
lc.info?.(`Validating permissions against tables and columns published for "${app}".`);
|
|
38
|
+
const { tables, publications } = await getPublicationInfo(db, shardPublications);
|
|
39
|
+
const pubnames = publications.map(p => p.pubname);
|
|
40
|
+
const missing = difference(new Set(shardPublications), new Set(pubnames));
|
|
41
|
+
if (missing.size) {
|
|
42
|
+
lc.warn?.(`Upstream is missing expected publications "${[...missing]}".\n` +
|
|
43
|
+
`You may need to re-initialize your replica.\n` +
|
|
44
|
+
`Deploying ${app} permissions without validating against published tables/columns.`);
|
|
30
45
|
return;
|
|
31
46
|
}
|
|
32
|
-
lc.info?.('Validating permissions against upstream table and column names.');
|
|
33
|
-
const { tables } = await getPublicationInfo(db, pubnames.map(p => p.pubname));
|
|
34
47
|
const tablesToColumns = new Map(tables.map(t => [liteTableName(t), Object.keys(t.columns)]));
|
|
35
48
|
const validate = validator(tablesToColumns);
|
|
36
49
|
try {
|
|
@@ -62,8 +75,10 @@ function failWithMessage(msg) {
|
|
|
62
75
|
}
|
|
63
76
|
async function deployPermissions(upstreamURI, permissions, force) {
|
|
64
77
|
const db = pgClient(lc, upstreamURI);
|
|
78
|
+
const { host, port } = db.options;
|
|
79
|
+
lc.debug?.(`Connecting to upstream@${host}:${port}`);
|
|
65
80
|
try {
|
|
66
|
-
await ensureGlobalTables(db,
|
|
81
|
+
await ensureGlobalTables(db, shard);
|
|
67
82
|
const { hash, changed } = await db.begin(async (tx) => {
|
|
68
83
|
if (force) {
|
|
69
84
|
lc.warn?.(`--force specified. Skipping validation.`);
|
|
@@ -73,9 +88,9 @@ async function deployPermissions(upstreamURI, permissions, force) {
|
|
|
73
88
|
}
|
|
74
89
|
lc.info?.(`Deploying permissions to upstream@${db.options.host}`);
|
|
75
90
|
const [{ hash: beforeHash }] = await tx `
|
|
76
|
-
SELECT hash from
|
|
91
|
+
SELECT hash from ${tx(app)}.permissions`;
|
|
77
92
|
const [{ hash }] = await tx `
|
|
78
|
-
UPDATE
|
|
93
|
+
UPDATE ${tx(app)}.permissions SET ${db({ permissions })} RETURNING hash`;
|
|
79
94
|
return { hash: hash.substring(0, 7), changed: beforeHash !== hash };
|
|
80
95
|
});
|
|
81
96
|
if (changed) {
|
|
@@ -91,7 +106,7 @@ async function deployPermissions(upstreamURI, permissions, force) {
|
|
|
91
106
|
}
|
|
92
107
|
async function writePermissionsFile(perms, file, format) {
|
|
93
108
|
const contents = format === 'sql'
|
|
94
|
-
? `UPDATE
|
|
109
|
+
? `UPDATE ${id(app)}.permissions SET permissions = ${literal(JSON.stringify(perms))};`
|
|
95
110
|
: JSON.stringify(perms, null, format === 'pretty' ? 2 : 0);
|
|
96
111
|
await writeFile(file, contents);
|
|
97
112
|
lc.info?.(`Wrote ${format} permissions to ${config.output.file}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy-permissions.js","sourceRoot":"","sources":["../../../../../zero-cache/src/scripts/deploy-permissions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAE,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAC5D,OAAO,eAAe,CAAC;AACvB,OAAO,EAAC,SAAS,EAAC,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"deploy-permissions.js","sourceRoot":"","sources":["../../../../../zero-cache/src/scripts/deploy-permissions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAE,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAC5D,OAAO,eAAe,CAAC;AACvB,OAAO,EAAC,SAAS,EAAC,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAC,KAAK,IAAI,EAAE,EAAE,OAAO,EAAC,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAC,YAAY,EAAC,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAC,UAAU,EAAC,MAAM,kCAAkC,CAAC;AAC5D,OAAO,EAAC,YAAY,EAAC,MAAM,mCAAmC,CAAC;AAC/D,OAAO,EAIN,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EAAC,SAAS,EAAC,MAAM,yCAAyC,CAAC;AAClE,OAAO,EAAC,mBAAmB,EAAC,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAC,kBAAkB,EAAC,MAAM,kDAAkD,CAAC;AACpF,OAAO,EACL,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,8CAA8C,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;
|
|
26
|
+
desc: string[];
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
shard: {
|
|
30
|
+
id: {
|
|
31
|
+
type: v.Optional<string>;
|
|
32
|
+
hidden: boolean;
|
|
33
|
+
};
|
|
34
|
+
num: {
|
|
35
|
+
type: v.Type<number>;
|
|
36
|
+
desc: string[];
|
|
37
|
+
hidden: boolean;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
23
40
|
output: {
|
|
24
41
|
file: {
|
|
25
42
|
type: v.Optional<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../../../../zero-cache/src/scripts/permissions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAIjD,OAAO,KAAK,CAAC,MAAM,+BAA+B,CAAC;AACnD,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,kDAAkD,CAAC;AAI1D,eAAO,MAAM,wBAAwB
|
|
1
|
+
{"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../../../../zero-cache/src/scripts/permissions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAIjD,OAAO,KAAK,CAAC,MAAM,+BAA+B,CAAC;AACnD,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,kDAAkD,CAAC;AAI1D,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyDpC,CAAC;AAEF,wBAAsB,eAAe,CACnC,EAAE,EAAE,UAAU,EACd,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,iBAAiB,CAAC,CA6C5B"}
|
|
@@ -4,7 +4,7 @@ import { tsImport } from 'tsx/esm/api';
|
|
|
4
4
|
import * as v from "../../../shared/src/valita.js";
|
|
5
5
|
import { permissionsConfigSchema, } from "../../../zero-schema/src/compiled-permissions.js";
|
|
6
6
|
import { isSchemaConfig } from "../../../zero-schema/src/schema-config.js";
|
|
7
|
-
import { zeroOptions } from "../config/zero-config.js";
|
|
7
|
+
import { appOptions, shardOptions, zeroOptions } from "../config/zero-config.js";
|
|
8
8
|
export const deployPermissionsOptions = {
|
|
9
9
|
schema: {
|
|
10
10
|
path: {
|
|
@@ -26,6 +26,8 @@ export const deployPermissionsOptions = {
|
|
|
26
26
|
},
|
|
27
27
|
type: zeroOptions.upstream.type,
|
|
28
28
|
},
|
|
29
|
+
app: { id: appOptions.id },
|
|
30
|
+
shard: shardOptions,
|
|
29
31
|
output: {
|
|
30
32
|
file: {
|
|
31
33
|
type: v.string().optional(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permissions.js","sourceRoot":"","sources":["../../../../../zero-cache/src/scripts/permissions.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAC,MAAM,WAAW,CAAC;AAC1E,OAAO,EAAC,aAAa,EAAC,MAAM,UAAU,CAAC;AACvC,OAAO,EAAC,QAAQ,EAAC,MAAM,aAAa,CAAC;AACrC,OAAO,KAAK,CAAC,MAAM,+BAA+B,CAAC;AACnD,OAAO,EACL,uBAAuB,GAExB,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EAAC,cAAc,EAAC,MAAM,2CAA2C,CAAC;AACzE,OAAO,EAAC,WAAW,EAAC,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"permissions.js","sourceRoot":"","sources":["../../../../../zero-cache/src/scripts/permissions.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAC,MAAM,WAAW,CAAC;AAC1E,OAAO,EAAC,aAAa,EAAC,MAAM,UAAU,CAAC;AACvC,OAAO,EAAC,QAAQ,EAAC,M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,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC;QAC5B,EAAE,CAAC,KAAK,EAAE,CACR,eAAe,UAAU,0CAA0C;YACjE,sBAAsB,EAAE,CAC3B,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IACD,IAAI,CAAC;QACH,MAAM,YAAY,GAAG,MAAM,CAAC;QAC5B,MAAM,KAAK,GACT,MAAO,YAAY,CAAC,WAA2C,CAAC;QAClE,OAAO,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,uBAAuB,CAAC,CAAC;IACjD,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,EAAE,CAAC,KAAK,EAAE,CAAC,oCAAoC,CAAC,CAAC;QACjD,MAAM,CAAC,CAAC;IACV,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"change-streamer.d.ts","sourceRoot":"","sources":["../../../../../zero-cache/src/server/change-streamer.ts"],"names":[],"mappings":"AAaA,OAAO,EAGL,KAAK,MAAM,EACZ,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"change-streamer.d.ts","sourceRoot":"","sources":["../../../../../zero-cache/src/server/change-streamer.ts"],"names":[],"mappings":"AAaA,OAAO,EAGL,KAAK,MAAM,EACZ,MAAM,uBAAuB,CAAC;AAI/B,wBAA8B,SAAS,CACrC,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,CAAC,UAAU,GACrB,OAAO,CAAC,IAAI,CAAC,CAuFf"}
|