@rocicorp/zero 1.4.0 → 1.5.0-canary.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/analyze-query/src/analyze-cli.js +2 -2
- package/out/analyze-query/src/analyze-cli.js.map +1 -1
- package/out/zero/package.js +1 -1
- package/out/zero/package.js.map +1 -1
- package/out/zero-cache/src/auth/auth.d.ts +1 -1
- package/out/zero-cache/src/auth/auth.d.ts.map +1 -1
- package/out/zero-cache/src/auth/auth.js +1 -1
- package/out/zero-cache/src/auth/auth.js.map +1 -1
- package/out/zero-cache/src/auth/write-authorizer.d.ts +1 -1
- package/out/zero-cache/src/auth/write-authorizer.d.ts.map +1 -1
- package/out/zero-cache/src/auth/write-authorizer.js.map +1 -1
- package/out/zero-cache/src/config/normalize.d.ts.map +1 -1
- package/out/zero-cache/src/config/normalize.js +8 -0
- package/out/zero-cache/src/config/normalize.js.map +1 -1
- package/out/zero-cache/src/config/zero-config.d.ts +8 -4
- package/out/zero-cache/src/config/zero-config.d.ts.map +1 -1
- package/out/zero-cache/src/config/zero-config.js +28 -6
- package/out/zero-cache/src/config/zero-config.js.map +1 -1
- package/out/zero-cache/src/custom/fetch.d.ts +1 -1
- package/out/zero-cache/src/custom/fetch.d.ts.map +1 -1
- package/out/zero-cache/src/custom/fetch.js +2 -2
- package/out/zero-cache/src/custom/fetch.js.map +1 -1
- package/out/zero-cache/src/custom-queries/transform-query.d.ts +21 -7
- package/out/zero-cache/src/custom-queries/transform-query.d.ts.map +1 -1
- package/out/zero-cache/src/custom-queries/transform-query.js +26 -9
- package/out/zero-cache/src/custom-queries/transform-query.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 +2 -1
- package/out/zero-cache/src/server/change-streamer.js.map +1 -1
- package/out/zero-cache/src/server/runner/run-worker.d.ts.map +1 -1
- package/out/zero-cache/src/server/runner/run-worker.js +5 -2
- package/out/zero-cache/src/server/runner/run-worker.js.map +1 -1
- package/out/zero-cache/src/server/syncer.js +3 -3
- package/out/zero-cache/src/server/syncer.js.map +1 -1
- package/out/zero-cache/src/services/change-source/custom/change-source.js +2 -2
- package/out/zero-cache/src/services/change-source/custom/change-source.js.map +1 -1
- 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 +24 -20
- package/out/zero-cache/src/services/change-source/pg/change-source.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/ddl.d.ts +258 -45
- 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 +119 -83
- 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.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/init.js +1 -1
- 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/shard.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/shard.js +2 -1
- package/out/zero-cache/src/services/change-source/pg/schema/shard.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/change-streamer-http.d.ts +1 -0
- package/out/zero-cache/src/services/change-streamer/change-streamer-http.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/change-streamer-http.js +3 -3
- package/out/zero-cache/src/services/change-streamer/change-streamer-http.js.map +1 -1
- package/out/zero-cache/src/services/http-service.d.ts +1 -0
- package/out/zero-cache/src/services/http-service.d.ts.map +1 -1
- package/out/zero-cache/src/services/http-service.js +5 -4
- package/out/zero-cache/src/services/http-service.js.map +1 -1
- package/out/zero-cache/src/services/life-cycle.d.ts +1 -1
- package/out/zero-cache/src/services/life-cycle.d.ts.map +1 -1
- package/out/zero-cache/src/services/life-cycle.js +1 -2
- package/out/zero-cache/src/services/life-cycle.js.map +1 -1
- package/out/zero-cache/src/services/mutagen/mutagen.d.ts +1 -1
- package/out/zero-cache/src/services/mutagen/mutagen.d.ts.map +1 -1
- package/out/zero-cache/src/services/mutagen/mutagen.js +1 -1
- package/out/zero-cache/src/services/mutagen/mutagen.js.map +1 -1
- package/out/zero-cache/src/services/mutagen/pusher.d.ts +4 -3
- package/out/zero-cache/src/services/mutagen/pusher.d.ts.map +1 -1
- package/out/zero-cache/src/services/mutagen/pusher.js +57 -38
- package/out/zero-cache/src/services/mutagen/pusher.js.map +1 -1
- package/out/zero-cache/src/services/shadow-sync/shadow-sync-service.js +2 -1
- package/out/zero-cache/src/services/shadow-sync/shadow-sync-service.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/client-handler.js +1 -1
- package/out/zero-cache/src/services/view-syncer/client-handler.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/connection-context-manager.d.ts +41 -27
- package/out/zero-cache/src/services/view-syncer/connection-context-manager.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/connection-context-manager.js +147 -104
- package/out/zero-cache/src/services/view-syncer/connection-context-manager.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/cvr.d.ts +6 -0
- package/out/zero-cache/src/services/view-syncer/cvr.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/cvr.js +8 -0
- package/out/zero-cache/src/services/view-syncer/cvr.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts +3 -3
- 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 +119 -86
- package/out/zero-cache/src/services/view-syncer/view-syncer.js.map +1 -1
- package/out/zero-cache/src/workers/connection.js +2 -2
- package/out/zero-cache/src/workers/connection.js.map +1 -1
- package/out/zero-cache/src/workers/syncer-ws-message-handler.d.ts +1 -1
- 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 +7 -7
- package/out/zero-cache/src/workers/syncer-ws-message-handler.js.map +1 -1
- package/out/zero-cache/src/workers/syncer.d.ts +1 -1
- package/out/zero-cache/src/workers/syncer.d.ts.map +1 -1
- package/out/zero-cache/src/workers/syncer.js +11 -10
- package/out/zero-cache/src/workers/syncer.js.map +1 -1
- package/out/zero-client/src/client/connection.d.ts +15 -7
- package/out/zero-client/src/client/connection.d.ts.map +1 -1
- package/out/zero-client/src/client/connection.js.map +1 -1
- package/out/zero-client/src/client/crud-impl.d.ts +1 -1
- package/out/zero-client/src/client/crud-impl.d.ts.map +1 -1
- package/out/zero-client/src/client/crud-impl.js +1 -1
- package/out/zero-client/src/client/crud-impl.js.map +1 -1
- package/out/zero-client/src/client/crud.d.ts +1 -1
- package/out/zero-client/src/client/crud.d.ts.map +1 -1
- package/out/zero-client/src/client/crud.js +1 -1
- package/out/zero-client/src/client/crud.js.map +1 -1
- package/out/zero-client/src/client/keys.d.ts +1 -1
- package/out/zero-client/src/client/keys.d.ts.map +1 -1
- package/out/zero-client/src/client/keys.js.map +1 -1
- package/out/zero-client/src/client/make-replicache-mutators.js +1 -1
- package/out/zero-client/src/client/make-replicache-mutators.js.map +1 -1
- package/out/zero-client/src/client/mutation-tracker.d.ts +2 -1
- package/out/zero-client/src/client/mutation-tracker.d.ts.map +1 -1
- package/out/zero-client/src/client/mutation-tracker.js +3 -3
- package/out/zero-client/src/client/mutation-tracker.js.map +1 -1
- package/out/zero-client/src/client/version.js +1 -1
- package/out/zero-client/src/client/zero.d.ts.map +1 -1
- package/out/zero-client/src/client/zero.js +2 -2
- package/out/zero-client/src/client/zero.js.map +1 -1
- package/out/zero-client/src/types/client-state.d.ts +1 -1
- package/out/zero-client/src/types/client-state.d.ts.map +1 -1
- package/out/zero-protocol/src/custom-queries.js +1 -1
- package/out/zero-protocol/src/down.js +1 -1
- package/out/zero-protocol/src/error-kind-enum.d.ts +1 -2
- package/out/zero-protocol/src/error-kind-enum.d.ts.map +1 -1
- package/out/zero-protocol/src/error-kind-enum.js.map +1 -1
- package/out/zero-protocol/src/mutate-server.d.ts +165 -0
- package/out/zero-protocol/src/mutate-server.d.ts.map +1 -0
- package/out/zero-protocol/src/mutate-server.js +24 -0
- package/out/zero-protocol/src/mutate-server.js.map +1 -0
- package/out/zero-protocol/src/mutation.d.ts +229 -0
- package/out/zero-protocol/src/mutation.d.ts.map +1 -0
- package/out/zero-protocol/src/mutation.js +112 -0
- package/out/zero-protocol/src/mutation.js.map +1 -0
- package/out/zero-protocol/src/mutations-patch.js +1 -1
- package/out/zero-protocol/src/mutations-patch.js.map +1 -1
- package/out/zero-protocol/src/push.d.ts +3 -234
- package/out/zero-protocol/src/push.d.ts.map +1 -1
- package/out/zero-protocol/src/push.js +3 -114
- package/out/zero-protocol/src/push.js.map +1 -1
- package/out/zero-protocol/src/query-server.d.ts +150 -0
- package/out/zero-protocol/src/query-server.d.ts.map +1 -0
- package/out/zero-protocol/src/query-server.js +16 -0
- package/out/zero-protocol/src/query-server.js.map +1 -0
- package/out/zero-protocol/src/up.js +1 -1
- package/out/zero-server/src/mod.d.ts +4 -2
- package/out/zero-server/src/mod.d.ts.map +1 -1
- package/out/zero-server/src/process-mutations.d.ts +50 -4
- package/out/zero-server/src/process-mutations.d.ts.map +1 -1
- package/out/zero-server/src/process-mutations.js +73 -36
- package/out/zero-server/src/process-mutations.js.map +1 -1
- package/out/zero-server/src/push-processor.d.ts +3 -3
- package/out/zero-server/src/push-processor.d.ts.map +1 -1
- package/out/zero-server/src/push-processor.js.map +1 -1
- package/out/zero-server/src/queries/process-queries.d.ts +45 -53
- package/out/zero-server/src/queries/process-queries.d.ts.map +1 -1
- package/out/zero-server/src/queries/process-queries.js +72 -53
- package/out/zero-server/src/queries/process-queries.js.map +1 -1
- package/out/zero-server/src/zql-database.js.map +1 -1
- package/out/zero-types/src/default-types.d.ts +1 -0
- package/out/zero-types/src/default-types.d.ts.map +1 -1
- package/out/zql/src/builder/builder.d.ts.map +1 -1
- package/out/zql/src/builder/builder.js +17 -7
- package/out/zql/src/builder/builder.js.map +1 -1
- package/out/zql/src/ivm/cap.d.ts +32 -0
- package/out/zql/src/ivm/cap.d.ts.map +1 -0
- package/out/zql/src/ivm/cap.js +205 -0
- package/out/zql/src/ivm/cap.js.map +1 -0
- package/out/zql/src/ivm/constraint.js +1 -1
- package/out/zql/src/ivm/flipped-join.d.ts.map +1 -1
- package/out/zql/src/ivm/flipped-join.js +61 -15
- package/out/zql/src/ivm/flipped-join.js.map +1 -1
- package/out/zql/src/ivm/memory-source.d.ts.map +1 -1
- package/out/zql/src/ivm/memory-source.js +3 -4
- package/out/zql/src/ivm/memory-source.js.map +1 -1
- package/out/zql/src/ivm/schema.d.ts +8 -0
- package/out/zql/src/ivm/schema.d.ts.map +1 -1
- package/out/zql/src/ivm/take.js +2 -2
- package/out/zql/src/mutate/mutator-registry.js.map +1 -1
- package/out/zql/src/mutate/mutator.d.ts +11 -2
- package/out/zql/src/mutate/mutator.d.ts.map +1 -1
- package/out/zql/src/mutate/mutator.js.map +1 -1
- package/out/zql/src/query/query-registry.d.ts +9 -2
- package/out/zql/src/query/query-registry.d.ts.map +1 -1
- package/out/zql/src/query/query-registry.js.map +1 -1
- package/out/zqlite/src/table-source.d.ts.map +1 -1
- package/out/zqlite/src/table-source.js +4 -1
- package/out/zqlite/src/table-source.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crud.d.ts","sourceRoot":"","sources":["../../../../../zero-client/src/client/crud.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EACL,kBAAkB,EAClB,KAAK,eAAe,EACpB,KAAK,MAAM,EAKZ,MAAM,
|
|
1
|
+
{"version":3,"file":"crud.d.ts","sourceRoot":"","sources":["../../../../../zero-client/src/client/crud.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EACL,k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Ac,GACxB,IAAI,CASN;AAmDD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,WAAW,EACvD,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EAAE,GACZ,YAAY,CAAC,CAAC,CAAC,CA4CjB;AAED,MAAM,MAAM,QAAQ,CAAC,EAAE,SAAS,WAAW,IAAI,EAAE,GAAG;IAClD,CAAC,kBAAkB,CAAC,EAAE,WAAW,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAErE,MAAM,MAAM,WAAW,GAAG,CACxB,EAAE,EAAE,gBAAgB,EACpB,OAAO,EAAE,eAAe,KACrB,OAAO,CAAC,IAAI,CAAC,CAAC;AAEnB,wBAAgB,gBAAgB,CAC9B,EAAE,EAAE,gBAAgB,EACpB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,eAAe,GAAG,SAAS,GACrC,YAAY,CAWd;AAMD,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,CAU3D"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { promiseVoid } from "../../../shared/src/resolved-promises.js";
|
|
2
|
-
import { CRUD_MUTATION_NAME } from "../../../zero-protocol/src/
|
|
2
|
+
import { CRUD_MUTATION_NAME } from "../../../zero-protocol/src/mutation.js";
|
|
3
3
|
import { crud_impl_exports } from "./crud-impl.js";
|
|
4
4
|
//#region ../zero-client/src/client/crud.ts
|
|
5
5
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crud.js","names":[],"sources":["../../../../../zero-client/src/client/crud.ts"],"sourcesContent":["import {promiseVoid} from '../../../shared/src/resolved-promises.ts';\nimport type {MaybePromise} from '../../../shared/src/types.ts';\nimport {\n CRUD_MUTATION_NAME,\n type CRUDMutationArg,\n type CRUDOp,\n type DeleteOp,\n type InsertOp,\n type UpdateOp,\n type UpsertOp,\n} from '../../../zero-protocol/src/
|
|
1
|
+
{"version":3,"file":"crud.js","names":[],"sources":["../../../../../zero-client/src/client/crud.ts"],"sourcesContent":["import {promiseVoid} from '../../../shared/src/resolved-promises.ts';\nimport type {MaybePromise} from '../../../shared/src/types.ts';\nimport {\n CRUD_MUTATION_NAME,\n type CRUDMutationArg,\n type CRUDOp,\n type DeleteOp,\n type InsertOp,\n type UpdateOp,\n type UpsertOp,\n} from '../../../zero-protocol/src/mutation.ts';\nimport type {TableSchema} from '../../../zero-schema/src/table-schema.ts';\nimport type {Schema} from '../../../zero-types/src/schema.ts';\nimport type {\n CRUDExecutor,\n DeleteID,\n InsertValue,\n TableMutator,\n UpdateValue,\n UpsertValue,\n} from '../../../zql/src/mutate/crud.ts';\nimport * as crudImpl from './crud-impl.ts';\nimport type {IVMSourceBranch} from './ivm-branch.ts';\nimport type {MutatorDefs, WriteTransaction} from './replicache-types.ts';\n\nexport type DBMutator<S extends Schema> = S['enableLegacyMutators'] extends true\n ? {\n [K in keyof S['tables']]: TableMutator<S['tables'][K]>;\n }\n : {}; // {} is needed here for intersection type identity\n\nexport type BatchMutator<S extends Schema> =\n S['enableLegacyMutators'] extends true\n ? <R>(body: (m: DBMutator<S>) => MaybePromise<R>) => Promise<R>\n : undefined;\n\ntype ZeroCRUDMutate = {\n [CRUD_MUTATION_NAME]: CRUDMutate;\n};\n\n/**\n * This is the zero.mutateBatch function part representing the CRUD operations. If the\n * tables are `issue` and `label`, then this object will have `issue` and\n * `label` properties.\n *\n * @param schema - The schema defining the tables\n * @param repMutate - The replicache mutate object with the CRUD mutation\n * @param mutate - The object to use as the mutate object. Properties for each\n * table will be assigned to this object.\n */\nexport function makeCRUDMutateBatch<const S extends Schema>(\n schema: S,\n repMutate: ZeroCRUDMutate,\n): BatchMutator<S> {\n if (schema.enableLegacyMutators !== true) {\n return undefined as BatchMutator<S>;\n }\n\n const {[CRUD_MUTATION_NAME]: zeroCRUD} = repMutate;\n\n const mutateBatch = async <R>(body: (m: DBMutator<S>) => R): Promise<R> => {\n const ops: CRUDOp[] = [];\n const m = {} as Record<string, unknown>;\n for (const name of Object.keys(schema.tables)) {\n m[name] = makeBatchCRUDMutate(name, schema, ops);\n }\n\n const rv = await body(m as DBMutator<S>);\n await zeroCRUD({ops});\n return rv;\n };\n\n return mutateBatch as BatchMutator<S>;\n}\n\nexport function addTableCRUDProperties<TSchema extends Schema>(\n schema: TSchema,\n mutate: object,\n repMutate: ZeroCRUDMutate,\n): void {\n const {[CRUD_MUTATION_NAME]: zeroCRUD} = repMutate;\n for (const [name, tableSchema] of Object.entries(schema.tables)) {\n (mutate as Record<string, unknown>)[name] = makeEntityCRUDMutate(\n name,\n tableSchema.primaryKey,\n zeroCRUD,\n );\n }\n}\n\n/**\n * Creates the `{insert, upsert, update, delete}` object for use outside a\n * batch.\n */\nfunction makeEntityCRUDMutate<S extends TableSchema>(\n tableName: string,\n primaryKey: S['primaryKey'],\n zeroCRUD: CRUDMutate,\n): TableMutator<S> {\n return {\n insert: (value: InsertValue<S>) => {\n const op: InsertOp = {\n op: 'insert',\n tableName,\n primaryKey,\n value,\n };\n return zeroCRUD({ops: [op]});\n },\n upsert: (value: UpsertValue<S>) => {\n const op: UpsertOp = {\n op: 'upsert',\n tableName,\n primaryKey,\n value,\n };\n return zeroCRUD({ops: [op]});\n },\n update: (value: UpdateValue<S>) => {\n const op: UpdateOp = {\n op: 'update',\n tableName,\n primaryKey,\n value,\n };\n return zeroCRUD({ops: [op]});\n },\n delete: (id: DeleteID<S>) => {\n const op: DeleteOp = {\n op: 'delete',\n tableName,\n primaryKey,\n value: id,\n };\n return zeroCRUD({ops: [op]});\n },\n };\n}\n\n/**\n * Creates the `{insert, upsert, update, delete}` object for use inside a\n * batch.\n */\nexport function makeBatchCRUDMutate<S extends TableSchema>(\n tableName: string,\n schema: Schema,\n ops: CRUDOp[],\n): TableMutator<S> {\n const {primaryKey} = schema.tables[tableName];\n return {\n insert: (value: InsertValue<S>) => {\n const op: InsertOp = {\n op: 'insert',\n tableName,\n primaryKey,\n value,\n };\n ops.push(op);\n return promiseVoid;\n },\n upsert: (value: UpsertValue<S>) => {\n const op: UpsertOp = {\n op: 'upsert',\n tableName,\n primaryKey,\n value,\n };\n ops.push(op);\n return promiseVoid;\n },\n update: (value: UpdateValue<S>) => {\n const op: UpdateOp = {\n op: 'update',\n tableName,\n primaryKey,\n value,\n };\n ops.push(op);\n return promiseVoid;\n },\n delete: (id: DeleteID<S>) => {\n const op: DeleteOp = {\n op: 'delete',\n tableName,\n primaryKey,\n value: id,\n };\n ops.push(op);\n return promiseVoid;\n },\n };\n}\n\nexport type WithCRUD<MD extends MutatorDefs> = MD & {\n [CRUD_MUTATION_NAME]: CRUDMutator;\n};\n\nexport type CRUDMutate = (crudArg: CRUDMutationArg) => Promise<void>;\n\nexport type CRUDMutator = (\n tx: WriteTransaction,\n crudArg: CRUDMutationArg,\n) => Promise<void>;\n\nexport function makeCRUDExecutor(\n tx: WriteTransaction,\n schema: Schema,\n ivmBranch: IVMSourceBranch | undefined,\n): CRUDExecutor {\n return (tableName, kind, value) => {\n const {primaryKey} = schema.tables[tableName];\n return crudImpl[kind](\n tx,\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n {op: kind, tableName, primaryKey, value} as any,\n schema,\n ivmBranch,\n );\n };\n}\n\n// Zero crud mutators cannot function at the same\n// time as custom mutators as the rebase of crud mutators will not\n// update the IVM branch. That's ok, we're removing crud mutators\n// in favor of custom mutators.\nexport function makeCRUDMutator(schema: Schema): CRUDMutator {\n return async (\n tx: WriteTransaction,\n crudArg: CRUDMutationArg,\n ): Promise<void> => {\n const executor = makeCRUDExecutor(tx, schema, undefined);\n for (const op of crudArg.ops) {\n await executor(op.tableName, op.op, op.value);\n }\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AAkDA,SAAgB,oBACd,QACA,WACiB;AACjB,KAAI,OAAO,yBAAyB,KAClC;CAGF,MAAM,GAAE,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;AACD,OAAI,KAAK,GAAG;AACZ,UAAO;;EAET,SAAS,UAA0B;GACjC,MAAM,KAAe;IACnB,IAAI;IACJ;IACA;IACA;IACD;AACD,OAAI,KAAK,GAAG;AACZ,UAAO;;EAET,SAAS,OAAoB;GAC3B,MAAM,KAAe;IACnB,IAAI;IACJ;IACA;IACA,OAAO;IACR;AACD,OAAI,KAAK,GAAG;AACZ,UAAO;;EAEV;;AAcH,SAAgB,iBACd,IACA,QACA,WACc;AACd,SAAQ,WAAW,MAAM,UAAU;EACjC,MAAM,EAAC,eAAc,OAAO,OAAO;AACnC,SAAO,kBAAS,MACd,IAEA;GAAC,IAAI;GAAM;GAAW;GAAY;GAAM,EACxC,QACA,UACD;;;AAQL,SAAgB,gBAAgB,QAA6B;AAC3D,QAAO,OACL,IACA,YACkB;EAClB,MAAM,WAAW,iBAAiB,IAAI,QAAQ,KAAA,EAAU;AACxD,OAAK,MAAM,MAAM,QAAQ,IACvB,OAAM,SAAS,GAAG,WAAW,GAAG,IAAI,GAAG,MAAM"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CompoundKey } from '../../../zero-protocol/src/ast.ts';
|
|
2
2
|
import type { Row } from '../../../zero-protocol/src/data.ts';
|
|
3
|
-
import type { MutationID } from '../../../zero-protocol/src/
|
|
3
|
+
import type { MutationID } from '../../../zero-protocol/src/mutation-id.ts';
|
|
4
4
|
export declare const DESIRED_QUERIES_KEY_PREFIX = "d/";
|
|
5
5
|
export declare const GOT_QUERIES_KEY_PREFIX = "g/";
|
|
6
6
|
export declare const ENTITIES_KEY_PREFIX = "e/";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../../../../zero-client/src/client/keys.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,mCAAmC,CAAC;AACnE,OAAO,KAAK,EAAC,GAAG,EAAC,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../../../../zero-client/src/client/keys.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,mCAAmC,CAAC;AACnE,OAAO,KAAK,EAAC,GAAG,EAAC,MAAM,oCAAoC,CAAC;AAC5D,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,2CAA2C,CAAC;AAG1E,eAAO,MAAM,0BAA0B,OAAO,CAAC;AAC/C,eAAO,MAAM,sBAAsB,OAAO,CAAC;AAC3C,eAAO,MAAM,mBAAmB,OAAO,CAAC;AACxC,eAAO,MAAM,oBAAoB,OAAO,CAAC;AAEzC,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAE1E;AAED,wBAAgB,6BAA6B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEtE;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,UAAU,GAAG,MAAM,CAE7D;AAED,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,WAAW,EACvB,KAAK,EAAE,GAAG,GACT,MAAM,CAeR;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAGrD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keys.js","names":[],"sources":["../../../../../zero-client/src/client/keys.ts"],"sourcesContent":["import {h128} from '../../../shared/src/hash.ts';\nimport * as v from '../../../shared/src/valita.ts';\nimport type {CompoundKey} from '../../../zero-protocol/src/ast.ts';\nimport type {Row} from '../../../zero-protocol/src/data.ts';\nimport {
|
|
1
|
+
{"version":3,"file":"keys.js","names":[],"sources":["../../../../../zero-client/src/client/keys.ts"],"sourcesContent":["import {h128} from '../../../shared/src/hash.ts';\nimport * as v from '../../../shared/src/valita.ts';\nimport type {CompoundKey} from '../../../zero-protocol/src/ast.ts';\nimport type {Row} from '../../../zero-protocol/src/data.ts';\nimport type {MutationID} from '../../../zero-protocol/src/mutation-id.ts';\nimport {primaryKeyValueSchema} from '../../../zero-protocol/src/primary-key.ts';\n\nexport const DESIRED_QUERIES_KEY_PREFIX = 'd/';\nexport const GOT_QUERIES_KEY_PREFIX = 'g/';\nexport const ENTITIES_KEY_PREFIX = 'e/';\nexport const MUTATIONS_KEY_PREFIX = 'm/';\n\nexport function toDesiredQueriesKey(clientID: string, hash: string): string {\n return DESIRED_QUERIES_KEY_PREFIX + clientID + '/' + hash;\n}\n\nexport function desiredQueriesPrefixForClient(clientID: string): string {\n return DESIRED_QUERIES_KEY_PREFIX + clientID + '/';\n}\n\nexport function toGotQueriesKey(hash: string): string {\n return GOT_QUERIES_KEY_PREFIX + hash;\n}\n\nexport function toMutationResponseKey(mid: MutationID): string {\n return MUTATIONS_KEY_PREFIX + mid.clientID + '/' + mid.id;\n}\n\nexport function toPrimaryKeyString(\n tableName: string,\n primaryKey: CompoundKey,\n value: Row,\n): string {\n if (primaryKey.length === 1) {\n return (\n ENTITIES_KEY_PREFIX +\n tableName +\n '/' +\n v.parse(value[primaryKey[0]], primaryKeyValueSchema)\n );\n }\n\n const values = primaryKey.map(k => v.parse(value[k], primaryKeyValueSchema));\n const str = JSON.stringify(values);\n\n const idSegment = h128(str);\n return ENTITIES_KEY_PREFIX + tableName + '/' + idSegment;\n}\n\nexport function sourceNameFromKey(key: string): string {\n const slash = key.indexOf('/', ENTITIES_KEY_PREFIX.length);\n return key.slice(ENTITIES_KEY_PREFIX.length, slash);\n}\n"],"mappings":";;;AAYA,SAAgB,oBAAoB,UAAkB,MAAsB;AAC1E,QAAA,OAAoC,WAAW,MAAM;;AAGvD,SAAgB,8BAA8B,UAA0B;AACtE,QAAA,OAAoC,WAAW;;AAGjD,SAAgB,gBAAgB,MAAsB;AACpD,QAAA,OAAgC;;AAGlC,SAAgB,sBAAsB,KAAyB;AAC7D,QAAA,OAA8B,IAAI,WAAW,MAAM,IAAI;;AAGzD,SAAgB,mBACd,WACA,YACA,OACQ;AACR,KAAI,WAAW,WAAW,EACxB,QAAA,OAEE,YACA,MACA,MAAQ,MAAM,WAAW,KAAK,sBAAsB;CAIxD,MAAM,SAAS,WAAW,KAAI,MAAK,MAAQ,MAAM,IAAI,sBAAsB,CAAC;CAG5E,MAAM,YAAY,KAFN,KAAK,UAAU,OAAO,CAEP;AAC3B,QAAA,OAA6B,YAAY,MAAM;;AAGjD,SAAgB,kBAAkB,KAAqB;CACrD,MAAM,QAAQ,IAAI,QAAQ,KAAK,EAA2B;AAC1D,QAAO,IAAI,MAAM,GAA4B,MAAM"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isMutator } from "../../../zql/src/mutate/mutator.js";
|
|
2
2
|
import { isMutatorRegistry } from "../../../zql/src/mutate/mutator-registry.js";
|
|
3
|
-
import { CRUD_MUTATION_NAME } from "../../../zero-protocol/src/
|
|
3
|
+
import { CRUD_MUTATION_NAME } from "../../../zero-protocol/src/mutation.js";
|
|
4
4
|
import { Internal } from "./client-error-kind-enum.js";
|
|
5
5
|
import { ClientError } from "./error.js";
|
|
6
6
|
import { makeCRUDMutator } from "./crud.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"make-replicache-mutators.js","names":[],"sources":["../../../../../zero-client/src/client/make-replicache-mutators.ts"],"sourcesContent":["import type {LogContext} from '@rocicorp/logger';\nimport type {MutatorDefs} from '../../../replicache/src/types.ts';\nimport type {ReadonlyJSONValue} from '../../../shared/src/json.ts';\nimport {CRUD_MUTATION_NAME} from '../../../zero-protocol/src/
|
|
1
|
+
{"version":3,"file":"make-replicache-mutators.js","names":[],"sources":["../../../../../zero-client/src/client/make-replicache-mutators.ts"],"sourcesContent":["import type {LogContext} from '@rocicorp/logger';\nimport type {MutatorDefs} from '../../../replicache/src/types.ts';\nimport type {ReadonlyJSONValue} from '../../../shared/src/json.ts';\nimport {CRUD_MUTATION_NAME} from '../../../zero-protocol/src/mutation.ts';\nimport type {Schema} from '../../../zero-types/src/schema.ts';\nimport {customMutatorKey} from '../../../zql/src/mutate/custom.ts';\nimport {\n isMutatorRegistry,\n type AnyMutatorRegistry,\n} from '../../../zql/src/mutate/mutator-registry.ts';\nimport {isMutator, type Mutator} from '../../../zql/src/mutate/mutator.ts';\nimport {ClientErrorKind} from './client-error-kind.ts';\nimport {makeCRUDMutator, type CRUDMutator} from './crud.ts';\nimport type {CustomMutatorDefs, CustomMutatorImpl} from './custom.ts';\nimport {\n makeReplicacheMutator as makeReplicacheMutatorLegacy,\n TransactionImpl,\n} from './custom.ts';\nimport {ClientError} from './error.ts';\nimport type {WriteTransaction} from './replicache-types.ts';\n\nexport function extendReplicacheMutators<S extends Schema, C>(\n lc: LogContext,\n context: C,\n mutators: AnyMutatorRegistry | CustomMutatorDefs,\n schema: S,\n mutateObject: Record<string, unknown>,\n): void {\n // Recursively process mutator definitions at arbitrary depth\n const processMutators = (mutators: object, path: string[]) => {\n for (const [key, mutator] of Object.entries(mutators)) {\n if (key === '~') {\n // Skip phantom type\n continue;\n }\n\n path.push(key);\n if (isMutator(mutator)) {\n const fullKey = customMutatorKey('.', path);\n mutateObject[fullKey] = makeReplicacheMutator(\n lc,\n mutator,\n schema,\n context,\n );\n } else if (typeof mutator === 'function') {\n const fullKey = customMutatorKey('|', path);\n mutateObject[fullKey] = makeReplicacheMutatorLegacy(\n lc,\n // oxlint-disable-next-line no-explicit-any\n mutator as CustomMutatorImpl<any>,\n schema,\n context,\n );\n } else if (mutator !== null && typeof mutator === 'object') {\n processMutators(mutator, path);\n }\n path.pop();\n }\n };\n\n processMutators(mutators, []);\n}\n\nfunction makeReplicacheMutator<\n TArgs extends ReadonlyJSONValue | undefined,\n TSchema extends Schema,\n TContext,\n TWrappedTransaction,\n>(\n lc: LogContext,\n mutator: Mutator<TArgs, TSchema, TContext, TWrappedTransaction>,\n schema: TSchema,\n context: TContext,\n): (repTx: WriteTransaction, args: ReadonlyJSONValue) => Promise<void> {\n return async (\n repTx: WriteTransaction,\n args: ReadonlyJSONValue,\n ): Promise<void> => {\n const tx = new TransactionImpl(lc, repTx, schema);\n // fn does input validation internally\n await mutator.fn({\n args: args as TArgs,\n ctx: context,\n tx: tx,\n });\n };\n}\n\n/**\n * Creates Replicache mutators from mutator definitions.\n *\n * This function processes mutator definitions at arbitrary depth, supporting both\n * new-style mutator definitions and legacy custom mutator implementations. It creates\n * a mutator object with the CRUD mutator and any provided custom mutators, with keys\n * generated based on their path in the mutator definition hierarchy.\n *\n * @template S - The schema type that defines the structure of the data\n * @template C - The type of the context object passed to mutators\n *\n * @param schema - The schema instance used for validation and type checking\n * @param mutators - The mutator definitions to process, can be nested objects or custom mutator definitions\n * @param context - The context to be passed to mutators\n * @param lc - The log context used for logging operations\n *\n * @returns A mutator definitions object containing the CRUD mutator and any custom mutators\n *\n * @remarks\n * - New-style mutator definitions use '.' as a separator in their keys\n * - Legacy custom mutator implementations use '|' as a separator in their keys\n * - The CRUD mutator can be disabled by setting `enableLegacyMutators: false` in the schema\n */\nexport function makeReplicacheMutators<const S extends Schema, C>(\n schema: S,\n mutators: AnyMutatorRegistry | CustomMutatorDefs | undefined,\n context: C,\n lc: LogContext,\n): MutatorDefs & {_zero_crud: CRUDMutator} {\n const {enableLegacyMutators = false} = schema;\n\n const replicacheMutators = {\n [CRUD_MUTATION_NAME]: enableLegacyMutators\n ? makeCRUDMutator(schema)\n : // TODO(arv): This code is unreachable since the public API prevents\n // calling CRUD mutators when enableLegacyMutators is false. Remove this.\n () =>\n Promise.reject(\n new ClientError({\n kind: ClientErrorKind.Internal,\n message: 'Zero CRUD mutators are not enabled.',\n }),\n ),\n };\n\n if (mutators) {\n if (isMutatorRegistry(mutators)) {\n extendFromMutatorRegistry(\n lc,\n context,\n mutators,\n schema,\n replicacheMutators,\n );\n } else {\n extendReplicacheMutators(\n lc,\n context,\n mutators as CustomMutatorDefs,\n schema,\n replicacheMutators,\n );\n }\n }\n\n return replicacheMutators;\n}\n\n/**\n * Extends replicache mutators from a MutatorRegistry.\n * Walks the registry tree and wraps each Mutator.fn for Replicache.\n */\nfunction extendFromMutatorRegistry<S extends Schema, C>(\n lc: LogContext,\n context: C,\n registry: AnyMutatorRegistry,\n schema: S,\n mutateObject: Record<string, unknown>,\n): void {\n const walk = (node: unknown) => {\n if (typeof node !== 'object' || node === null) {\n return;\n }\n for (const value of Object.values(node)) {\n if (isMutator<S>(value)) {\n // Mutator.fn already handles validation internally\n mutateObject[value.mutatorName] = (\n repTx: WriteTransaction,\n args: ReadonlyJSONValue,\n ): Promise<void> => {\n const tx = new TransactionImpl(lc, repTx, schema);\n return value.fn({args, ctx: context, tx});\n };\n } else if (typeof value === 'object' && value !== null) {\n // Nested namespace\n walk(value);\n }\n }\n };\n walk(registry);\n}\n"],"mappings":";;;;;;;;;AAqBA,SAAgB,yBACd,IACA,SACA,UACA,QACA,cACM;CAEN,MAAM,mBAAmB,UAAkB,SAAmB;AAC5D,OAAK,MAAM,CAAC,KAAK,YAAY,OAAO,QAAQ,SAAS,EAAE;AACrD,OAAI,QAAQ,IAEV;AAGF,QAAK,KAAK,IAAI;AACd,OAAI,UAAU,QAAQ,EAAE;IACtB,MAAM,UAAU,iBAAiB,KAAK,KAAK;AAC3C,iBAAa,WAAW,sBACtB,IACA,SACA,QACA,QACD;cACQ,OAAO,YAAY,YAAY;IACxC,MAAM,UAAU,iBAAiB,KAAK,KAAK;AAC3C,iBAAa,WAAW,wBACtB,IAEA,SACA,QACA,QACD;cACQ,YAAY,QAAQ,OAAO,YAAY,SAChD,iBAAgB,SAAS,KAAK;AAEhC,QAAK,KAAK;;;AAId,iBAAgB,UAAU,EAAE,CAAC;;AAG/B,SAAS,sBAMP,IACA,SACA,QACA,SACqE;AACrE,QAAO,OACL,OACA,SACkB;EAClB,MAAM,KAAK,IAAI,gBAAgB,IAAI,OAAO,OAAO;AAEjD,QAAM,QAAQ,GAAG;GACT;GACN,KAAK;GACD;GACL,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BN,SAAgB,uBACd,QACA,UACA,SACA,IACyC;CACzC,MAAM,EAAC,uBAAuB,UAAS;CAEvC,MAAM,qBAAqB,GACxB,qBAAqB,uBAClB,gBAAgB,OAAO,SAIrB,QAAQ,OACN,IAAI,YAAY;EACd,MAAM;EACN,SAAS;EACV,CAAC,CACH,EACR;AAED,KAAI,SACF,KAAI,kBAAkB,SAAS,CAC7B,2BACE,IACA,SACA,UACA,QACA,mBACD;KAED,0BACE,IACA,SACA,UACA,QACA,mBACD;AAIL,QAAO;;;;;;AAOT,SAAS,0BACP,IACA,SACA,UACA,QACA,cACM;CACN,MAAM,QAAQ,SAAkB;AAC9B,MAAI,OAAO,SAAS,YAAY,SAAS,KACvC;AAEF,OAAK,MAAM,SAAS,OAAO,OAAO,KAAK,CACrC,KAAI,UAAa,MAAM,CAErB,cAAa,MAAM,gBACjB,OACA,SACkB;GAClB,MAAM,KAAK,IAAI,gBAAgB,IAAI,OAAO,OAAO;AACjD,UAAO,MAAM,GAAG;IAAC;IAAM,KAAK;IAAS;IAAG,CAAC;;WAElC,OAAO,UAAU,YAAY,UAAU,KAEhD,MAAK,MAAM;;AAIjB,MAAK,SAAS"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { LogContext } from '@rocicorp/logger';
|
|
2
2
|
import type { ReplicacheImpl } from '../../../replicache/src/impl.ts';
|
|
3
3
|
import type { EphemeralID, MutationTrackingData } from '../../../replicache/src/replicache-options.ts';
|
|
4
|
-
import {
|
|
4
|
+
import type { MutationID } from '../../../zero-protocol/src/mutation-id.ts';
|
|
5
|
+
import type { PushResponseBody } from '../../../zero-protocol/src/push.ts';
|
|
5
6
|
import type { MutatorResultSuccessDetails } from './custom.ts';
|
|
6
7
|
import { type ZeroError } from './error.ts';
|
|
7
8
|
type MutationSuccessType = MutatorResultSuccessDetails;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mutation-tracker.d.ts","sourceRoot":"","sources":["../../../../../zero-client/src/client/mutation-tracker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAGjD,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,iCAAiC,CAAC;AACpE,OAAO,KAAK,EACV,WAAW,EACX,oBAAoB,EACrB,MAAM,+CAA+C,CAAC;AAevD,OAAO,
|
|
1
|
+
{"version":3,"file":"mutation-tracker.d.ts","sourceRoot":"","sources":["../../../../../zero-client/src/client/mutation-tracker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAGjD,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,iCAAiC,CAAC;AACpE,OAAO,KAAK,EACV,WAAW,EACX,oBAAoB,EACrB,MAAM,+CAA+C,CAAC;AAevD,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,2CAA2C,CAAC;AAM1E,OAAO,KAAK,EAGV,gBAAgB,EACjB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAAC,2BAA2B,EAAC,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAc,KAAK,SAAS,EAAC,MAAM,YAAY,CAAC;AAGvD,KAAK,mBAAmB,GAAG,2BAA2B,CAAC;AAUvD;;GAEG;AACH,qBAAa,eAAe;;gBAoBxB,EAAE,EAAE,UAAU,EACd,YAAY,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,EACxC,YAAY,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI;IAY1C,mBAAmB,CACjB,QAAQ,EAAE,MAAM,EAChB,iBAAiB,EAAE,cAAc,CAAC,mBAAmB,CAAC;IAexD,aAAa,IAAI,oBAAoB,CAAC,mBAAmB,CAAC;IAU1D,kBAAkB,CAAC,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI;IAY7D;;;OAGG;IACH,cAAc,CAAC,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE,OAAO,GAAG,IAAI;IAOjD;;;OAGG;IACH,6BAA6B,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI;IAmDrD,mBAAmB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI;IAuDrD;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,WAAW,CAAC,cAAc,EAAE,MAAM;IAIlC;;;;;;OAMG;IACH,YAAY,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI;IAoB1C,IAAI,IAAI,WAEP;IAwJD;;;;;;;;;OASG;IACH,qBAAqB,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI;CASlD"}
|
|
@@ -8,7 +8,7 @@ import { Server, ZeroCache } from "../../../zero-protocol/src/error-origin-enum.
|
|
|
8
8
|
import { HTTP, Internal } from "../../../zero-protocol/src/error-reason-enum.js";
|
|
9
9
|
import { ProtocolError } from "../../../zero-protocol/src/error.js";
|
|
10
10
|
import { emptyObject } from "../../../shared/src/sentinels.js";
|
|
11
|
-
import { mutationResultSchema } from "../../../zero-protocol/src/
|
|
11
|
+
import { mutationResultSchema } from "../../../zero-protocol/src/mutation.js";
|
|
12
12
|
import { isZeroError } from "./error.js";
|
|
13
13
|
import "./keys.js";
|
|
14
14
|
import { resolver } from "@rocicorp/resolver";
|
|
@@ -201,8 +201,8 @@ var MutationTracker = class {
|
|
|
201
201
|
for (const [id, entry] of this.#outstandingMutations) if (entry.mutationID && entry.mutationID <= upTo) this.#settleMutation(id, entry, emptyObject);
|
|
202
202
|
else break;
|
|
203
203
|
}
|
|
204
|
-
#processPushOk(
|
|
205
|
-
for (const mutation of
|
|
204
|
+
#processPushOk(success) {
|
|
205
|
+
for (const mutation of success.mutations) if ("error" in mutation.result) this.#processMutationError(mutation.id.clientID, mutation.id.id, mutation.result);
|
|
206
206
|
else this.#processMutationOk(mutation.id.clientID, mutation.id.id, mutation.result);
|
|
207
207
|
}
|
|
208
208
|
#processMutationError(clientID, mid, error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mutation-tracker.js","names":["#outstandingMutations","#ephemeralIDsByMutationID","#allMutationsAppliedListeners","#lc","#ackMutations","#onFatalError","#largestOutstandingMutationID","#currentMutationID","#clientID","#processMutationResponses","#settleMutation","#notifyAllMutationsAppliedListeners","#processMutationError","#processMutationOk","#fatalErrorFromPushError","#processPushOk","#resolveMutations"],"sources":["../../../../../zero-client/src/client/mutation-tracker.ts"],"sourcesContent":["import type {LogContext} from '@rocicorp/logger';\nimport {resolver, type Resolver} from '@rocicorp/resolver';\nimport type {NoIndexDiff} from '../../../replicache/src/btree/node.ts';\nimport type {ReplicacheImpl} from '../../../replicache/src/impl.ts';\nimport type {\n EphemeralID,\n MutationTrackingData,\n} from '../../../replicache/src/replicache-options.ts';\nimport {assert, unreachable} from '../../../shared/src/asserts.ts';\nimport {getErrorDetails} from '../../../shared/src/error.ts';\nimport {must} from '../../../shared/src/must.ts';\nimport {emptyObject} from '../../../shared/src/sentinels.ts';\nimport * as v from '../../../shared/src/valita.ts';\nimport {\n ApplicationError,\n isApplicationError,\n wrapWithApplicationError,\n} from '../../../zero-protocol/src/application-error.ts';\nimport {ErrorKind} from '../../../zero-protocol/src/error-kind.ts';\nimport {ErrorOrigin} from '../../../zero-protocol/src/error-origin.ts';\nimport {ErrorReason} from '../../../zero-protocol/src/error-reason.ts';\nimport {ProtocolError} from '../../../zero-protocol/src/error.ts';\nimport {\n mutationResultSchema,\n type MutationError,\n type MutationID,\n type MutationOk,\n type PushError,\n type PushOk,\n type PushResponseBody,\n} from '../../../zero-protocol/src/push.ts';\nimport type {MutatorResultSuccessDetails} from './custom.ts';\nimport {isZeroError, type ZeroError} from './error.ts';\nimport {MUTATIONS_KEY_PREFIX} from './keys.ts';\n\ntype MutationSuccessType = MutatorResultSuccessDetails;\ntype MutationErrorType = ApplicationError | ZeroError;\n\nlet currentEphemeralID = 0;\nfunction nextEphemeralID(): EphemeralID {\n return ++currentEphemeralID as EphemeralID;\n}\n\nconst successResultDetails: MutationSuccessType = {type: 'success'};\n\n/**\n * Tracks what pushes are in-flight and resolves promises when they're acked.\n */\nexport class MutationTracker {\n readonly #outstandingMutations: Map<\n EphemeralID,\n {\n mutationID?: number | undefined;\n resolver: Resolver<MutationSuccessType, MutationErrorType>;\n }\n >;\n readonly #ephemeralIDsByMutationID: Map<number, EphemeralID>;\n readonly #allMutationsAppliedListeners: Set<() => void>;\n readonly #lc: LogContext;\n\n readonly #ackMutations: (upTo: MutationID) => void;\n readonly #onFatalError: (error: ZeroError) => void;\n\n #clientID: string | undefined;\n #largestOutstandingMutationID: number;\n #currentMutationID: number;\n\n constructor(\n lc: LogContext,\n ackMutations: (upTo: MutationID) => void,\n onFatalError: (error: ZeroError) => void,\n ) {\n this.#lc = lc.withContext('MutationTracker');\n this.#outstandingMutations = new Map();\n this.#ephemeralIDsByMutationID = new Map();\n this.#allMutationsAppliedListeners = new Set();\n this.#largestOutstandingMutationID = 0;\n this.#currentMutationID = 0;\n this.#ackMutations = ackMutations;\n this.#onFatalError = onFatalError;\n }\n\n setClientIDAndWatch(\n clientID: string,\n experimentalWatch: ReplicacheImpl['experimentalWatch'],\n ) {\n assert(this.#clientID === undefined, 'clientID already set');\n this.#clientID = clientID;\n experimentalWatch(\n diffs => {\n this.#processMutationResponses(diffs);\n },\n {\n prefix: MUTATIONS_KEY_PREFIX + clientID + '/',\n initialValuesInFirstDiff: true,\n },\n );\n }\n\n trackMutation(): MutationTrackingData<MutationSuccessType> {\n const id = nextEphemeralID();\n const mutationResolver = resolver<MutationSuccessType, MutationErrorType>();\n\n this.#outstandingMutations.set(id, {\n resolver: mutationResolver,\n });\n return {ephemeralID: id, serverPromise: mutationResolver.promise};\n }\n\n mutationIDAssigned(id: EphemeralID, mutationID: number): void {\n const entry = this.#outstandingMutations.get(id);\n if (entry) {\n entry.mutationID = mutationID;\n this.#ephemeralIDsByMutationID.set(mutationID, id);\n this.#largestOutstandingMutationID = Math.max(\n this.#largestOutstandingMutationID,\n mutationID,\n );\n }\n }\n\n /**\n * Reject the mutation due to an unhandled exception on the client.\n * The mutation must not have been persisted to the client store.\n */\n rejectMutation(id: EphemeralID, e: unknown): void {\n const entry = this.#outstandingMutations.get(id);\n if (entry) {\n this.#settleMutation(id, entry, wrapWithApplicationError(e));\n }\n }\n\n /**\n * Reject all outstanding mutations. Called when the client is in a state\n * that prevents mutations from being applied, such as offline or closed.\n */\n rejectAllOutstandingMutations(error: ZeroError): void {\n if (this.#outstandingMutations.size === 0) {\n return;\n }\n for (const [id, entry] of this.#outstandingMutations) {\n this.#settleMutation(id, entry, error);\n }\n this.#largestOutstandingMutationID = this.#currentMutationID;\n this.#notifyAllMutationsAppliedListeners();\n }\n\n /**\n * Used when zero-cache pokes down mutation results.\n */\n #processMutationResponses(diffs: NoIndexDiff): void {\n const clientID = must(this.#clientID);\n let largestLmid = 0;\n for (const diff of diffs) {\n const mutationID = Number(\n diff.key.slice(MUTATIONS_KEY_PREFIX.length + clientID.length + 1),\n );\n assert(\n !isNaN(mutationID),\n `MutationTracker received a diff with an invalid mutation ID: ${diff.key}`,\n );\n largestLmid = Math.max(largestLmid, mutationID);\n switch (diff.op) {\n case 'add': {\n const result = v.parse(diff.newValue, mutationResultSchema);\n if ('error' in result) {\n this.#processMutationError(clientID, mutationID, result);\n } else {\n this.#processMutationOk(clientID, mutationID, result);\n }\n break;\n }\n case 'del':\n break;\n case 'change':\n throw new Error('MutationTracker does not expect change operations');\n }\n }\n\n if (largestLmid > 0) {\n this.#ackMutations({\n clientID: must(this.#clientID),\n id: largestLmid,\n });\n }\n }\n\n processPushResponse(response: PushResponseBody): void {\n if ('error' in response) {\n this.#lc.error?.(\n 'Received an error response when pushing mutations',\n response,\n );\n const fatalError = this.#fatalErrorFromPushError(response);\n if (fatalError) {\n this.#onFatalError(fatalError);\n }\n } else {\n this.#processPushOk(response);\n }\n }\n\n #fatalErrorFromPushError(error: PushError): ZeroError | undefined {\n switch (error.error) {\n case 'unsupportedPushVersion':\n return new ProtocolError({\n kind: ErrorKind.PushFailed,\n origin: ErrorOrigin.ZeroCache,\n reason: ErrorReason.Internal,\n message: `Unsupported push version`,\n mutationIDs: [],\n });\n case 'unsupportedSchemaVersion':\n return new ProtocolError({\n kind: ErrorKind.PushFailed,\n origin: ErrorOrigin.ZeroCache,\n reason: ErrorReason.Internal,\n message: `Unsupported schema version`,\n mutationIDs: [],\n });\n case 'http':\n return new ProtocolError({\n kind: ErrorKind.PushFailed,\n origin: ErrorOrigin.ZeroCache,\n reason: ErrorReason.HTTP,\n status: error.status,\n message: `Fetch from API server returned non-OK status ${error.status}: ${error.details ?? 'unknown'}`,\n mutationIDs: [],\n });\n case 'zeroPusher':\n return new ProtocolError({\n kind: ErrorKind.PushFailed,\n origin: ErrorOrigin.ZeroCache,\n reason: ErrorReason.Internal,\n message: `ZeroPusher error: ${error.details ?? 'unknown'}`,\n mutationIDs: [],\n });\n default:\n unreachable(error);\n }\n }\n\n /**\n * DEPRECATED: to be removed when we switch to fully driving\n * mutation resolution via poke.\n *\n * When we reconnect to zero-cache, we resolve all outstanding mutations\n * whose ID is less than or equal to the lastMutationID.\n *\n * The reason is that any responses the API server sent\n * to those mutations have been lost.\n *\n * An example case: the API server responds while the connection\n * is down. Those responses are lost.\n *\n * Mutations whose LMID is > the lastMutationID are not resolved\n * since they will be retried by the client, giving us another chance\n * at getting a response.\n *\n * The only way to ensure that all API server responses are\n * received would be to have the API server write them\n * to the DB while writing the LMID.\n */\n onConnected(lastMutationID: number) {\n this.lmidAdvanced(lastMutationID);\n }\n\n /**\n * lmid advance will:\n * 1. notify \"allMutationsApplied\" listeners if the lastMutationID\n * is greater than or equal to the largest outstanding mutation ID.\n * 2. resolve all mutations whose mutation ID is less than or equal to\n * the lastMutationID.\n */\n lmidAdvanced(lastMutationID: number): void {\n assert(\n lastMutationID >= this.#currentMutationID,\n 'lmid must be greater than or equal to current lmid',\n );\n if (lastMutationID === this.#currentMutationID) {\n return;\n }\n\n try {\n this.#currentMutationID = lastMutationID;\n this.#resolveMutations(lastMutationID);\n } finally {\n if (lastMutationID >= this.#largestOutstandingMutationID) {\n // this is very important otherwise we hang query de-registration\n this.#notifyAllMutationsAppliedListeners();\n }\n }\n }\n\n get size() {\n return this.#outstandingMutations.size;\n }\n\n #resolveMutations(upTo: number): void {\n // We resolve all mutations whose mutation ID is less than or equal to\n // the upTo mutation ID.\n for (const [id, entry] of this.#outstandingMutations) {\n if (entry.mutationID && entry.mutationID <= upTo) {\n this.#settleMutation(id, entry, emptyObject);\n } else {\n break; // the map is in insertion order which is in mutation ID order\n }\n }\n }\n\n #processPushOk(ok: PushOk): void {\n for (const mutation of ok.mutations) {\n if ('error' in mutation.result) {\n this.#processMutationError(\n mutation.id.clientID,\n mutation.id.id,\n mutation.result,\n );\n } else {\n this.#processMutationOk(\n mutation.id.clientID,\n mutation.id.id,\n mutation.result,\n );\n }\n }\n }\n\n #processMutationError(\n clientID: string,\n mid: number,\n error: MutationError | Omit<PushError, 'mutationIDs'>,\n ): void {\n assert(\n clientID === this.#clientID,\n 'received mutation for the wrong client',\n );\n\n // Each tab sends all mutations for the client group\n // and the server responds back to the individual client that actually\n // ran the mutation. This means that N clients can send the same\n // mutation concurrently. If that happens, the promise for the mutation tracked\n // by this class will try to be resolved N times.\n // Every time after the first, the ephemeral ID will not be found.\n //\n // We also reject all outstanding mutations when the client is in a state\n // that prevents mutations from being applied, such as offline or closed.\n // In this case, the ephemeral ID will also not be found.\n const ephemeralID = this.#ephemeralIDsByMutationID.get(mid);\n if (!ephemeralID) {\n this.#lc.debug?.(\n 'Mutation already resolved or rejected (e.g. due to disconnect); ignore late reject.',\n );\n return;\n }\n\n const entry = this.#outstandingMutations.get(ephemeralID);\n assert(\n entry && entry.mutationID === mid,\n `outstanding mutation not found for mutation ID ${mid} and ephemeral ID ${ephemeralID}`,\n );\n\n if (error.error === 'alreadyProcessed') {\n this.#settleMutation(ephemeralID, entry, emptyObject);\n return;\n }\n\n this.#settleMutation(\n ephemeralID,\n entry,\n error.error === 'app'\n ? new ApplicationError(\n error.message ?? `Unknown application error: ${error.error}`,\n error.details ? {details: error.details} : undefined,\n )\n : new ProtocolError({\n kind: ErrorKind.InvalidPush,\n origin: ErrorOrigin.Server,\n reason: ErrorReason.Internal,\n message:\n error.error === 'oooMutation'\n ? 'Server reported an out-of-order mutation'\n : `Unknown fallback error with mutation ID ${mid}: ${error.error}`,\n details: getErrorDetails(error),\n }),\n );\n\n // this is included for backwards compatibility with the per-mutation fatal error responses\n if (error.error === 'oooMutation') {\n this.#onFatalError(\n new ProtocolError({\n kind: ErrorKind.InvalidPush,\n origin: ErrorOrigin.Server,\n reason: ErrorReason.Internal,\n message: 'Server reported an out-of-order mutation',\n details: error.details,\n }),\n );\n }\n }\n\n #processMutationOk(clientID: string, mid: number, result: MutationOk): void {\n assert(\n clientID === this.#clientID,\n 'received mutation for the wrong client',\n );\n\n // We reject all outstanding mutations when the client is in a state\n // that prevents mutations from being applied, such as offline or closed.\n // In this case, the ephemeral ID will not be found.\n const ephemeralID = this.#ephemeralIDsByMutationID.get(mid);\n if (!ephemeralID) {\n this.#lc.debug?.(\n 'Mutation already resolved or rejected (e.g. due to disconnect); ignore late resolve.',\n );\n return;\n }\n\n const entry = this.#outstandingMutations.get(ephemeralID);\n assert(\n entry && entry.mutationID === mid,\n `outstanding mutation not found for mutation ID ${mid} and ephemeral ID ${ephemeralID}`,\n );\n this.#settleMutation(ephemeralID, entry, result);\n }\n\n #settleMutation<Result extends MutationOk | ApplicationError | ZeroError>(\n ephemeralID: EphemeralID,\n entry: {\n mutationID?: number | undefined;\n resolver: Resolver<MutationSuccessType, MutationErrorType>;\n },\n result: Result,\n ): void {\n if (isApplicationError(result) || isZeroError(result)) {\n // we reject here and catch in the mutator proxy\n // the mutator proxy catches both client and server errors\n entry.resolver.reject(result);\n } else {\n entry.resolver.resolve(successResultDetails);\n }\n\n this.#outstandingMutations.delete(ephemeralID);\n if (entry.mutationID) {\n this.#ephemeralIDsByMutationID.delete(entry.mutationID);\n }\n }\n\n /**\n * Be notified when all mutations have been included in the server snapshot.\n *\n * The query manager will not de-register queries from the server until there\n * are no pending mutations.\n *\n * The reason is that a mutation may need to be rebased. We do not want\n * data that was available the first time it was run to not be available\n * on a rebase.\n */\n onAllMutationsApplied(listener: () => void): void {\n this.#allMutationsAppliedListeners.add(listener);\n }\n\n #notifyAllMutationsAppliedListeners() {\n for (const listener of this.#allMutationsAppliedListeners) {\n listener();\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAsCA,IAAI,qBAAqB;AACzB,SAAS,kBAA+B;AACtC,QAAO,EAAE;;AAGX,IAAM,uBAA4C,EAAC,MAAM,WAAU;;;;AAKnE,IAAa,kBAAb,MAA6B;CAC3B;CAOA;CACA;CACA;CAEA;CACA;CAEA;CACA;CACA;CAEA,YACE,IACA,cACA,cACA;AACA,QAAA,KAAW,GAAG,YAAY,kBAAkB;AAC5C,QAAA,uCAA6B,IAAI,KAAK;AACtC,QAAA,2CAAiC,IAAI,KAAK;AAC1C,QAAA,+CAAqC,IAAI,KAAK;AAC9C,QAAA,+BAAqC;AACrC,QAAA,oBAA0B;AAC1B,QAAA,eAAqB;AACrB,QAAA,eAAqB;;CAGvB,oBACE,UACA,mBACA;AACA,SAAO,MAAA,aAAmB,KAAA,GAAW,uBAAuB;AAC5D,QAAA,WAAiB;AACjB,qBACE,UAAS;AACP,SAAA,yBAA+B,MAAM;KAEvC;GACE,QAAA,OAA+B,WAAW;GAC1C,0BAA0B;GAC3B,CACF;;CAGH,gBAA2D;EACzD,MAAM,KAAK,iBAAiB;EAC5B,MAAM,mBAAmB,UAAkD;AAE3E,QAAA,qBAA2B,IAAI,IAAI,EACjC,UAAU,kBACX,CAAC;AACF,SAAO;GAAC,aAAa;GAAI,eAAe,iBAAiB;GAAQ;;CAGnE,mBAAmB,IAAiB,YAA0B;EAC5D,MAAM,QAAQ,MAAA,qBAA2B,IAAI,GAAG;AAChD,MAAI,O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mBAAmB,OAAO,IAAI,YAAY,OAAO,CAGnD,OAAM,SAAS,OAAO,OAAO;MAE7B,OAAM,SAAS,QAAQ,qBAAqB;AAG9C,QAAA,qBAA2B,OAAO,YAAY;AAC9C,MAAI,MAAM,WACR,OAAA,yBAA+B,OAAO,MAAM,WAAW;;;;;;;;;;;;CAc3D,sBAAsB,UAA4B;AAChD,QAAA,6BAAmC,IAAI,SAAS;;CAGlD,sCAAsC;AACpC,OAAK,MAAM,YAAY,MAAA,6BACrB,WAAU"}
|
|
1
|
+
{"version":3,"file":"mutation-tracker.js","names":["#outstandingMutations","#ephemeralIDsByMutationID","#allMutationsAppliedListeners","#lc","#ackMutations","#onFatalError","#largestOutstandingMutationID","#currentMutationID","#clientID","#processMutationResponses","#settleMutation","#notifyAllMutationsAppliedListeners","#processMutationError","#processMutationOk","#fatalErrorFromPushError","#processPushOk","#resolveMutations"],"sources":["../../../../../zero-client/src/client/mutation-tracker.ts"],"sourcesContent":["import type {LogContext} from '@rocicorp/logger';\nimport {resolver, type Resolver} from '@rocicorp/resolver';\nimport type {NoIndexDiff} from '../../../replicache/src/btree/node.ts';\nimport type {ReplicacheImpl} from '../../../replicache/src/impl.ts';\nimport type {\n EphemeralID,\n MutationTrackingData,\n} from '../../../replicache/src/replicache-options.ts';\nimport {assert, unreachable} from '../../../shared/src/asserts.ts';\nimport {getErrorDetails} from '../../../shared/src/error.ts';\nimport {must} from '../../../shared/src/must.ts';\nimport {emptyObject} from '../../../shared/src/sentinels.ts';\nimport * as v from '../../../shared/src/valita.ts';\nimport {\n ApplicationError,\n isApplicationError,\n wrapWithApplicationError,\n} from '../../../zero-protocol/src/application-error.ts';\nimport {ErrorKind} from '../../../zero-protocol/src/error-kind.ts';\nimport {ErrorOrigin} from '../../../zero-protocol/src/error-origin.ts';\nimport {ErrorReason} from '../../../zero-protocol/src/error-reason.ts';\nimport {ProtocolError} from '../../../zero-protocol/src/error.ts';\nimport type {MutationID} from '../../../zero-protocol/src/mutation-id.ts';\nimport {\n mutationResultSchema,\n type MutationError,\n type MutationOk,\n} from '../../../zero-protocol/src/mutation.ts';\nimport type {\n PushError,\n PushOk,\n PushResponseBody,\n} from '../../../zero-protocol/src/push.ts';\nimport type {MutatorResultSuccessDetails} from './custom.ts';\nimport {isZeroError, type ZeroError} from './error.ts';\nimport {MUTATIONS_KEY_PREFIX} from './keys.ts';\n\ntype MutationSuccessType = MutatorResultSuccessDetails;\ntype MutationErrorType = ApplicationError | ZeroError;\n\nlet currentEphemeralID = 0;\nfunction nextEphemeralID(): EphemeralID {\n return ++currentEphemeralID as EphemeralID;\n}\n\nconst successResultDetails: MutationSuccessType = {type: 'success'};\n\n/**\n * Tracks what pushes are in-flight and resolves promises when they're acked.\n */\nexport class MutationTracker {\n readonly #outstandingMutations: Map<\n EphemeralID,\n {\n mutationID?: number | undefined;\n resolver: Resolver<MutationSuccessType, MutationErrorType>;\n }\n >;\n readonly #ephemeralIDsByMutationID: Map<number, EphemeralID>;\n readonly #allMutationsAppliedListeners: Set<() => void>;\n readonly #lc: LogContext;\n\n readonly #ackMutations: (upTo: MutationID) => void;\n readonly #onFatalError: (error: ZeroError) => void;\n\n #clientID: string | undefined;\n #largestOutstandingMutationID: number;\n #currentMutationID: number;\n\n constructor(\n lc: LogContext,\n ackMutations: (upTo: MutationID) => void,\n onFatalError: (error: ZeroError) => void,\n ) {\n this.#lc = lc.withContext('MutationTracker');\n this.#outstandingMutations = new Map();\n this.#ephemeralIDsByMutationID = new Map();\n this.#allMutationsAppliedListeners = new Set();\n this.#largestOutstandingMutationID = 0;\n this.#currentMutationID = 0;\n this.#ackMutations = ackMutations;\n this.#onFatalError = onFatalError;\n }\n\n setClientIDAndWatch(\n clientID: string,\n experimentalWatch: ReplicacheImpl['experimentalWatch'],\n ) {\n assert(this.#clientID === undefined, 'clientID already set');\n this.#clientID = clientID;\n experimentalWatch(\n diffs => {\n this.#processMutationResponses(diffs);\n },\n {\n prefix: MUTATIONS_KEY_PREFIX + clientID + '/',\n initialValuesInFirstDiff: true,\n },\n );\n }\n\n trackMutation(): MutationTrackingData<MutationSuccessType> {\n const id = nextEphemeralID();\n const mutationResolver = resolver<MutationSuccessType, MutationErrorType>();\n\n this.#outstandingMutations.set(id, {\n resolver: mutationResolver,\n });\n return {ephemeralID: id, serverPromise: mutationResolver.promise};\n }\n\n mutationIDAssigned(id: EphemeralID, mutationID: number): void {\n const entry = this.#outstandingMutations.get(id);\n if (entry) {\n entry.mutationID = mutationID;\n this.#ephemeralIDsByMutationID.set(mutationID, id);\n this.#largestOutstandingMutationID = Math.max(\n this.#largestOutstandingMutationID,\n mutationID,\n );\n }\n }\n\n /**\n * Reject the mutation due to an unhandled exception on the client.\n * The mutation must not have been persisted to the client store.\n */\n rejectMutation(id: EphemeralID, e: unknown): void {\n const entry = this.#outstandingMutations.get(id);\n if (entry) {\n this.#settleMutation(id, entry, wrapWithApplicationError(e));\n }\n }\n\n /**\n * Reject all outstanding mutations. Called when the client is in a state\n * that prevents mutations from being applied, such as offline or closed.\n */\n rejectAllOutstandingMutations(error: ZeroError): void {\n if (this.#outstandingMutations.size === 0) {\n return;\n }\n for (const [id, entry] of this.#outstandingMutations) {\n this.#settleMutation(id, entry, error);\n }\n this.#largestOutstandingMutationID = this.#currentMutationID;\n this.#notifyAllMutationsAppliedListeners();\n }\n\n /**\n * Used when zero-cache pokes down mutation results.\n */\n #processMutationResponses(diffs: NoIndexDiff): void {\n const clientID = must(this.#clientID);\n let largestLmid = 0;\n for (const diff of diffs) {\n const mutationID = Number(\n diff.key.slice(MUTATIONS_KEY_PREFIX.length + clientID.length + 1),\n );\n assert(\n !isNaN(mutationID),\n `MutationTracker received a diff with an invalid mutation ID: ${diff.key}`,\n );\n largestLmid = Math.max(largestLmid, mutationID);\n switch (diff.op) {\n case 'add': {\n const result = v.parse(diff.newValue, mutationResultSchema);\n if ('error' in result) {\n this.#processMutationError(clientID, mutationID, result);\n } else {\n this.#processMutationOk(clientID, mutationID, result);\n }\n break;\n }\n case 'del':\n break;\n case 'change':\n throw new Error('MutationTracker does not expect change operations');\n }\n }\n\n if (largestLmid > 0) {\n this.#ackMutations({\n clientID: must(this.#clientID),\n id: largestLmid,\n });\n }\n }\n\n processPushResponse(response: PushResponseBody): void {\n if ('error' in response) {\n this.#lc.error?.(\n 'Received an error response when pushing mutations',\n response,\n );\n const fatalError = this.#fatalErrorFromPushError(response);\n if (fatalError) {\n this.#onFatalError(fatalError);\n }\n } else {\n this.#processPushOk(response);\n }\n }\n\n #fatalErrorFromPushError(error: PushError): ZeroError | undefined {\n switch (error.error) {\n case 'unsupportedPushVersion':\n return new ProtocolError({\n kind: ErrorKind.PushFailed,\n origin: ErrorOrigin.ZeroCache,\n reason: ErrorReason.Internal,\n message: `Unsupported push version`,\n mutationIDs: [],\n });\n case 'unsupportedSchemaVersion':\n return new ProtocolError({\n kind: ErrorKind.PushFailed,\n origin: ErrorOrigin.ZeroCache,\n reason: ErrorReason.Internal,\n message: `Unsupported schema version`,\n mutationIDs: [],\n });\n case 'http':\n return new ProtocolError({\n kind: ErrorKind.PushFailed,\n origin: ErrorOrigin.ZeroCache,\n reason: ErrorReason.HTTP,\n status: error.status,\n message: `Fetch from API server returned non-OK status ${error.status}: ${error.details ?? 'unknown'}`,\n mutationIDs: [],\n });\n case 'zeroPusher':\n return new ProtocolError({\n kind: ErrorKind.PushFailed,\n origin: ErrorOrigin.ZeroCache,\n reason: ErrorReason.Internal,\n message: `ZeroPusher error: ${error.details ?? 'unknown'}`,\n mutationIDs: [],\n });\n default:\n unreachable(error);\n }\n }\n\n /**\n * DEPRECATED: to be removed when we switch to fully driving\n * mutation resolution via poke.\n *\n * When we reconnect to zero-cache, we resolve all outstanding mutations\n * whose ID is less than or equal to the lastMutationID.\n *\n * The reason is that any responses the API server sent\n * to those mutations have been lost.\n *\n * An example case: the API server responds while the connection\n * is down. Those responses are lost.\n *\n * Mutations whose LMID is > the lastMutationID are not resolved\n * since they will be retried by the client, giving us another chance\n * at getting a response.\n *\n * The only way to ensure that all API server responses are\n * received would be to have the API server write them\n * to the DB while writing the LMID.\n */\n onConnected(lastMutationID: number) {\n this.lmidAdvanced(lastMutationID);\n }\n\n /**\n * lmid advance will:\n * 1. notify \"allMutationsApplied\" listeners if the lastMutationID\n * is greater than or equal to the largest outstanding mutation ID.\n * 2. resolve all mutations whose mutation ID is less than or equal to\n * the lastMutationID.\n */\n lmidAdvanced(lastMutationID: number): void {\n assert(\n lastMutationID >= this.#currentMutationID,\n 'lmid must be greater than or equal to current lmid',\n );\n if (lastMutationID === this.#currentMutationID) {\n return;\n }\n\n try {\n this.#currentMutationID = lastMutationID;\n this.#resolveMutations(lastMutationID);\n } finally {\n if (lastMutationID >= this.#largestOutstandingMutationID) {\n // this is very important otherwise we hang query de-registration\n this.#notifyAllMutationsAppliedListeners();\n }\n }\n }\n\n get size() {\n return this.#outstandingMutations.size;\n }\n\n #resolveMutations(upTo: number): void {\n // We resolve all mutations whose mutation ID is less than or equal to\n // the upTo mutation ID.\n for (const [id, entry] of this.#outstandingMutations) {\n if (entry.mutationID && entry.mutationID <= upTo) {\n this.#settleMutation(id, entry, emptyObject);\n } else {\n break; // the map is in insertion order which is in mutation ID order\n }\n }\n }\n\n #processPushOk(success: PushOk): void {\n for (const mutation of success.mutations) {\n if ('error' in mutation.result) {\n this.#processMutationError(\n mutation.id.clientID,\n mutation.id.id,\n mutation.result,\n );\n } else {\n this.#processMutationOk(\n mutation.id.clientID,\n mutation.id.id,\n mutation.result,\n );\n }\n }\n }\n\n #processMutationError(\n clientID: string,\n mid: number,\n error: MutationError | Omit<PushError, 'mutationIDs'>,\n ): void {\n assert(\n clientID === this.#clientID,\n 'received mutation for the wrong client',\n );\n\n // Each tab sends all mutations for the client group\n // and the server responds back to the individual client that actually\n // ran the mutation. This means that N clients can send the same\n // mutation concurrently. If that happens, the promise for the mutation tracked\n // by this class will try to be resolved N times.\n // Every time after the first, the ephemeral ID will not be found.\n //\n // We also reject all outstanding mutations when the client is in a state\n // that prevents mutations from being applied, such as offline or closed.\n // In this case, the ephemeral ID will also not be found.\n const ephemeralID = this.#ephemeralIDsByMutationID.get(mid);\n if (!ephemeralID) {\n this.#lc.debug?.(\n 'Mutation already resolved or rejected (e.g. due to disconnect); ignore late reject.',\n );\n return;\n }\n\n const entry = this.#outstandingMutations.get(ephemeralID);\n assert(\n entry && entry.mutationID === mid,\n `outstanding mutation not found for mutation ID ${mid} and ephemeral ID ${ephemeralID}`,\n );\n\n if (error.error === 'alreadyProcessed') {\n this.#settleMutation(ephemeralID, entry, emptyObject);\n return;\n }\n\n this.#settleMutation(\n ephemeralID,\n entry,\n error.error === 'app'\n ? new ApplicationError(\n error.message ?? `Unknown application error: ${error.error}`,\n error.details ? {details: error.details} : undefined,\n )\n : new ProtocolError({\n kind: ErrorKind.InvalidPush,\n origin: ErrorOrigin.Server,\n reason: ErrorReason.Internal,\n message:\n error.error === 'oooMutation'\n ? 'Server reported an out-of-order mutation'\n : `Unknown fallback error with mutation ID ${mid}: ${error.error}`,\n details: getErrorDetails(error),\n }),\n );\n\n // this is included for backwards compatibility with the per-mutation fatal error responses\n if (error.error === 'oooMutation') {\n this.#onFatalError(\n new ProtocolError({\n kind: ErrorKind.InvalidPush,\n origin: ErrorOrigin.Server,\n reason: ErrorReason.Internal,\n message: 'Server reported an out-of-order mutation',\n details: error.details,\n }),\n );\n }\n }\n\n #processMutationOk(clientID: string, mid: number, result: MutationOk): void {\n assert(\n clientID === this.#clientID,\n 'received mutation for the wrong client',\n );\n\n // We reject all outstanding mutations when the client is in a state\n // that prevents mutations from being applied, such as offline or closed.\n // In this case, the ephemeral ID will not be found.\n const ephemeralID = this.#ephemeralIDsByMutationID.get(mid);\n if (!ephemeralID) {\n this.#lc.debug?.(\n 'Mutation already resolved or rejected (e.g. due to disconnect); ignore late resolve.',\n );\n return;\n }\n\n const entry = this.#outstandingMutations.get(ephemeralID);\n assert(\n entry && entry.mutationID === mid,\n `outstanding mutation not found for mutation ID ${mid} and ephemeral ID ${ephemeralID}`,\n );\n this.#settleMutation(ephemeralID, entry, result);\n }\n\n #settleMutation<Result extends MutationOk | ApplicationError | ZeroError>(\n ephemeralID: EphemeralID,\n entry: {\n mutationID?: number | undefined;\n resolver: Resolver<MutationSuccessType, MutationErrorType>;\n },\n result: Result,\n ): void {\n if (isApplicationError(result) || isZeroError(result)) {\n // we reject here and catch in the mutator proxy\n // the mutator proxy catches both client and server errors\n entry.resolver.reject(result);\n } else {\n entry.resolver.resolve(successResultDetails);\n }\n\n this.#outstandingMutations.delete(ephemeralID);\n if (entry.mutationID) {\n this.#ephemeralIDsByMutationID.delete(entry.mutationID);\n }\n }\n\n /**\n * Be notified when all mutations have been included in the server snapshot.\n *\n * The query manager will not de-register queries from the server until there\n * are no pending mutations.\n *\n * The reason is that a mutation may need to be rebased. We do not want\n * data that was available the first time it was run to not be available\n * on a rebase.\n */\n onAllMutationsApplied(listener: () => void): void {\n this.#allMutationsAppliedListeners.add(listener);\n }\n\n #notifyAllMutationsAppliedListeners() {\n for (const listener of this.#allMutationsAppliedListeners) {\n listener();\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAwCA,IAAI,qBAAqB;AACzB,SAAS,kBAA+B;AACtC,QAAO,EAAE;;AAGX,IAAM,uBAA4C,EAAC,MAAM,WAAU;;;;AAKnE,IAAa,kBAAb,MAA6B;CAC3B;CAOA;CACA;CACA;CAEA;CACA;CAEA;CACA;CACA;CAEA,YACE,IACA,cACA,cACA;AACA,QAAA,KAAW,GAAG,YAAY,kBAAkB;AAC5C,QAAA,uCAA6B,IAAI,KAAK;AACtC,QAAA,2CAAiC,IAAI,KAAK;AAC1C,QAAA,+CAAqC,IAAI,KAAK;AAC9C,QAAA,+BAAqC;AACrC,QAAA,oBAA0B;AAC1B,QAAA,eAAqB;AACrB,QAAA,eAAqB;;CAGvB,oBACE,UACA,mBACA;AACA,SAAO,MAAA,aAAmB,KAAA,GAAW,uBAAuB;AAC5D,QAAA,WAAiB;AACjB,qBACE,UAAS;AACP,SAA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e,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,EACnD,YAAY,EAAE,MAAM,GAAG,SAAS,EAChC,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,EACpD,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,EAC3D,oBAAoB,EAAE,IAAI,CAAC,oBAAoB,EAAE,eAAe,CAAC,EACjE,eAAe,SAAW,GACzB,OAAO,CACR;IACE,SAAS;IACT,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,GAAG,SAAS;IACzC,iBAAiB,GAAG,SAAS;CAC9B,CACF,CAqEA;AAED,wBAAsB,mBAAmB,CACvC,YAAY,EAAE,UAAU,GAAG,QAAQ,EACnC,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,UAAU,EAAE,MAAM,GAAG,IAAI,EACzB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC,EAAE,WAAW,CAAC,EAC1C,SAAS,EAAE,OAAO,EAClB,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,EAC3D,EAAE,EAAE,UAAU,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,CAAC,gBA+B3D"}
|
|
@@ -29,7 +29,7 @@ import { emptyFunction } from "../../../shared/src/sentinels.js";
|
|
|
29
29
|
import { Subscribable } from "../../../shared/src/subscribable.js";
|
|
30
30
|
import { encodeSecProtocols } from "../../../zero-protocol/src/connect.js";
|
|
31
31
|
import { CRUD, Custom } from "../../../zero-protocol/src/mutation-type-enum.js";
|
|
32
|
-
import { mapCRUD } from "../../../zero-protocol/src/
|
|
32
|
+
import { mapCRUD } from "../../../zero-protocol/src/mutation.js";
|
|
33
33
|
import { nullableVersionSchema } from "../../../zero-protocol/src/version.js";
|
|
34
34
|
import { downstreamSchema } from "../../../zero-protocol/src/down.js";
|
|
35
35
|
import "../../../zero-protocol/src/protocol-version.js";
|
|
@@ -295,7 +295,7 @@ var Zero = class Zero {
|
|
|
295
295
|
this.#server = server;
|
|
296
296
|
this.userID = userID ?? void 0;
|
|
297
297
|
this.#lc = lc.withContext("clientID", rep.clientID);
|
|
298
|
-
if (userID === "anon") this.#lc.warn?.("ZeroOptions.userID \"anon\" is deprecated for logged-out clients. Omit it entirely for logged-out clients.");
|
|
298
|
+
if (userID === "anon" && !options.auth) this.#lc.warn?.("ZeroOptions.userID \"anon\" is deprecated for logged-out clients. Omit it entirely for logged-out clients.");
|
|
299
299
|
this.#connection = new ConnectionImpl(this.#connectionManager, this.#lc, (auth) => this.#setAuth(auth));
|
|
300
300
|
this.#mutationTracker.setClientIDAndWatch(rep.clientID, rep.experimentalWatch.bind(rep));
|
|
301
301
|
this.#activeClientsManager = makeActiveClientsManager(rep.clientGroupID, this.clientID, this.#closeAbortController.signal, (clientID, clientGroupID) => this.#deleteClientsManager.onClientsDeleted([{
|