@rocicorp/zero 0.25.0-canary.21 → 0.25.0-canary.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/out/analyze-query/src/run-ast.d.ts +1 -1
  2. package/out/analyze-query/src/run-ast.d.ts.map +1 -1
  3. package/out/analyze-query/src/run-ast.js +7 -1
  4. package/out/analyze-query/src/run-ast.js.map +1 -1
  5. package/out/otel/src/log-options.d.ts +1 -1
  6. package/out/otel/src/log-options.d.ts.map +1 -1
  7. package/out/otel/src/log-options.js +0 -1
  8. package/out/otel/src/log-options.js.map +1 -1
  9. package/out/shared/src/options-types.d.ts +113 -0
  10. package/out/shared/src/options-types.d.ts.map +1 -0
  11. package/out/shared/src/options.d.ts +2 -111
  12. package/out/shared/src/options.d.ts.map +1 -1
  13. package/out/shared/src/options.js.map +1 -1
  14. package/out/zero/package.json.js +1 -1
  15. package/out/zero/src/pg.js +1 -2
  16. package/out/zero/src/server.js +1 -2
  17. package/out/zero/src/zero-cache-dev.js +11 -5
  18. package/out/zero/src/zero-cache-dev.js.map +1 -1
  19. package/out/zero/src/zero.js +0 -2
  20. package/out/zero/src/zero.js.map +1 -1
  21. package/out/zero-cache/src/auth/read-authorizer.js +1 -1
  22. package/out/zero-cache/src/auth/read-authorizer.js.map +1 -1
  23. package/out/zero-cache/src/auth/write-authorizer.js +1 -1
  24. package/out/zero-cache/src/auth/write-authorizer.js.map +1 -1
  25. package/out/zero-cache/src/config/zero-config.d.ts.map +1 -1
  26. package/out/zero-cache/src/config/zero-config.js +5 -3
  27. package/out/zero-cache/src/config/zero-config.js.map +1 -1
  28. package/out/zero-cache/src/scripts/deploy-permissions.js +6 -3
  29. package/out/zero-cache/src/scripts/deploy-permissions.js.map +1 -1
  30. package/out/zero-cache/src/scripts/permissions.d.ts.map +1 -1
  31. package/out/zero-cache/src/scripts/permissions.js +11 -13
  32. package/out/zero-cache/src/scripts/permissions.js.map +1 -1
  33. package/out/zero-cache/src/services/change-source/pg/schema/published.d.ts.map +1 -1
  34. package/out/zero-cache/src/services/change-source/pg/schema/published.js +3 -2
  35. package/out/zero-cache/src/services/change-source/pg/schema/published.js.map +1 -1
  36. package/out/zero-client/src/client/crud.d.ts +3 -2
  37. package/out/zero-client/src/client/crud.d.ts.map +1 -1
  38. package/out/zero-client/src/client/crud.js +7 -3
  39. package/out/zero-client/src/client/crud.js.map +1 -1
  40. package/out/zero-client/src/client/custom.d.ts +3 -2
  41. package/out/zero-client/src/client/custom.d.ts.map +1 -1
  42. package/out/zero-client/src/client/custom.js +2 -2
  43. package/out/zero-client/src/client/custom.js.map +1 -1
  44. package/out/zero-client/src/client/make-mutate-property.d.ts +1 -1
  45. package/out/zero-client/src/client/make-mutate-property.d.ts.map +1 -1
  46. package/out/zero-client/src/client/make-mutate-property.js +2 -2
  47. package/out/zero-client/src/client/make-mutate-property.js.map +1 -1
  48. package/out/zero-client/src/client/mutator-proxy.js +6 -7
  49. package/out/zero-client/src/client/mutator-proxy.js.map +1 -1
  50. package/out/zero-client/src/client/version.js +1 -1
  51. package/out/zero-client/src/client/zero.d.ts +14 -3
  52. package/out/zero-client/src/client/zero.d.ts.map +1 -1
  53. package/out/zero-client/src/client/zero.js +19 -6
  54. package/out/zero-client/src/client/zero.js.map +1 -1
  55. package/out/zero-client/src/mod.d.ts +3 -4
  56. package/out/zero-client/src/mod.d.ts.map +1 -1
  57. package/out/zero-schema/src/compiled-permissions.d.ts +22 -2
  58. package/out/zero-schema/src/compiled-permissions.d.ts.map +1 -1
  59. package/out/zero-schema/src/compiled-permissions.js +7 -6
  60. package/out/zero-schema/src/compiled-permissions.js.map +1 -1
  61. package/out/zero-schema/src/permissions.d.ts.map +1 -1
  62. package/out/zero-schema/src/permissions.js.map +1 -1
  63. package/out/zero-schema/src/schema-config.d.ts +0 -5
  64. package/out/zero-schema/src/schema-config.d.ts.map +1 -1
  65. package/out/zero-schema/src/schema-config.js +1 -1
  66. package/out/zero-schema/src/schema-config.js.map +1 -1
  67. package/out/zero-server/src/custom.d.ts +5 -14
  68. package/out/zero-server/src/custom.d.ts.map +1 -1
  69. package/out/zero-server/src/custom.js +8 -18
  70. package/out/zero-server/src/custom.js.map +1 -1
  71. package/out/zql/src/mutate/crud.d.ts +3 -26
  72. package/out/zql/src/mutate/crud.d.ts.map +1 -1
  73. package/out/zql/src/mutate/crud.js +14 -26
  74. package/out/zql/src/mutate/crud.js.map +1 -1
  75. package/out/zql/src/mutate/custom.d.ts +7 -8
  76. package/out/zql/src/mutate/custom.d.ts.map +1 -1
  77. package/out/zql/src/mutate/custom.js.map +1 -1
  78. package/out/zql/src/planner/planner-join.d.ts.map +1 -1
  79. package/out/zql/src/planner/planner-join.js +3 -1
  80. package/out/zql/src/planner/planner-join.js.map +1 -1
  81. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"file":"permissions.js","sources":["../../../../../zero-cache/src/scripts/permissions.ts"],"sourcesContent":["import {existsSync} from 'node:fs';\nimport {basename, dirname, join, relative, resolve, sep} from 'node:path';\nimport {fileURLToPath} from 'node:url';\nimport {tsImport} from 'tsx/esm/api';\nimport {logOptions} from '../../../otel/src/log-options.ts';\nimport {colorConsole} from '../../../shared/src/logging.ts';\nimport * as v from '../../../shared/src/valita.ts';\nimport {\n permissionsConfigSchema,\n type PermissionsConfig,\n} from '../../../zero-schema/src/compiled-permissions.ts';\nimport {isSchemaConfig} from '../../../zero-schema/src/schema-config.ts';\nimport type {Schema} from '../../../zero-types/src/schema.ts';\nimport {appOptions, shardOptions, zeroOptions} from '../config/zero-config.ts';\n\nexport const deployPermissionsOptions = {\n schema: {\n path: {\n type: v.string().default('schema.ts'),\n desc: [\n 'Relative path to the file containing the schema definition.',\n 'The file must have a default export of type SchemaConfig.',\n ],\n alias: 'p',\n },\n },\n\n upstream: {\n db: {\n type: v.string().optional(),\n desc: [\n `The upstream Postgres database to deploy permissions to.`,\n `This is ignored if an {bold output-file} is specified.`,\n ],\n },\n\n type: zeroOptions.upstream.type,\n },\n\n app: {id: appOptions.id},\n\n shard: shardOptions,\n\n log: logOptions,\n\n output: {\n file: {\n type: v.string().optional(),\n desc: [\n `Outputs the permissions to a file with the requested {bold output-format}.`,\n ],\n },\n\n format: {\n type: v.literalUnion('sql', 'json', 'pretty').default('sql'),\n desc: [\n `The desired format of the output file.`,\n ``,\n `A {bold sql} file can be executed via \"psql -f <file.sql>\", or \"\\\\\\\\i <file.sql>\"`,\n `from within the psql console, or copied and pasted into a migration script.`,\n ``,\n `The {bold json} and {bold pretty} formats are available for non-pg backends`,\n `and general debugging.`,\n ],\n },\n },\n\n force: {\n type: v.boolean().default(false),\n desc: [`Deploy to upstream without validation. Use at your own risk.`],\n alias: 'f',\n },\n};\n\nexport async function loadSchemaAndPermissions(\n schemaPath: string,\n allowMissing: true,\n): Promise<{schema: Schema; permissions: PermissionsConfig} | undefined>;\nexport async function loadSchemaAndPermissions(\n schemaPath: string,\n allowMissing?: false,\n): Promise<{schema: Schema; permissions: PermissionsConfig}>;\nexport async function loadSchemaAndPermissions(\n schemaPath: string,\n allowMissing: boolean | undefined,\n): Promise<{schema: Schema; permissions: PermissionsConfig} | undefined> {\n const typeModuleErrorMessage = () =>\n `\\n\\nYou may need to add \\` \"type\": \"module\" \\` to the package.json file for ${schemaPath}.\\n`;\n\n colorConsole.info(`Loading permissions from ${schemaPath}`);\n const dir = dirname(fileURLToPath(import.meta.url));\n const absoluteSchemaPath = resolve(schemaPath);\n const relativeDir = relative(dir, dirname(absoluteSchemaPath));\n let relativePath = join(\n // tsImport expects the relativePath to be a path and not just a filename.\n relativeDir.length ? relativeDir : `.${sep}`,\n basename(absoluteSchemaPath),\n );\n\n // tsImport doesn't expect to receive slashes in the Windows format when running\n // on Windows. They need to be converted to *nix format.\n relativePath = relativePath.replace(/\\\\/g, '/');\n\n if (!existsSync(absoluteSchemaPath)) {\n if (allowMissing) {\n return undefined;\n }\n colorConsole.error(`Schema file ${schemaPath} does not exist.`);\n process.exit(1);\n }\n\n let module;\n try {\n module = await tsImport(relativePath, import.meta.url);\n } catch (e) {\n colorConsole.error(\n `Failed to load zero schema from ${absoluteSchemaPath}` +\n typeModuleErrorMessage(),\n );\n throw e;\n }\n\n if (!isSchemaConfig(module)) {\n colorConsole.error(\n `Schema file ${schemaPath} must export [schema] and [permissions].` +\n typeModuleErrorMessage(),\n );\n process.exit(1);\n }\n try {\n const schemaConfig = module;\n const perms =\n await (schemaConfig.permissions as unknown as Promise<unknown>);\n const {schema} = schemaConfig;\n return {\n schema,\n permissions: v.parse(perms, permissionsConfigSchema),\n };\n } catch (e) {\n colorConsole.error(`Failed to parse Permissions object`);\n throw e;\n }\n}\n"],"names":["v.string","v.literalUnion","v.boolean","v.parse"],"mappings":";;;;;;;;;;;AAeO,MAAM,2BAA2B;AAAA,EACtC,QAAQ;AAAA,IACN,MAAM;AAAA,MACJ,MAAMA,OAAE,EAAS,QAAQ,WAAW;AAAA,MACpC,MAAM;AAAA,QACJ;AAAA,QACA;AAAA,MAAA;AAAA,MAEF,OAAO;AAAA,IAAA;AAAA,EACT;AAAA,EAGF,UAAU;AAAA,IACR,IAAI;AAAA,MACF,MAAMA,OAAE,EAAS,SAAA;AAAA,MACjB,MAAM;AAAA,QACJ;AAAA,QACA;AAAA,MAAA;AAAA,IACF;AAAA,IAGF,MAAM,YAAY,SAAS;AAAA,EAAA;AAAA,EAG7B,KAAK,EAAC,IAAI,WAAW,GAAA;AAAA,EAErB,OAAO;AAAA,EAEP,KAAK;AAAA,EAEL,QAAQ;AAAA,IACN,MAAM;AAAA,MACJ,MAAMA,OAAE,EAAS,SAAA;AAAA,MACjB,MAAM;AAAA,QACJ;AAAA,MAAA;AAAA,IACF;AAAA,IAGF,QAAQ;AAAA,MACN,MAAMC,aAAe,OAAO,QAAQ,QAAQ,EAAE,QAAQ,KAAK;AAAA,MAC3D,MAAM;AAAA,QACJ;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAA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AG;AACV,iBAAa,MAAM,oCAAoC;AACvD,UAAM;AAAA,EACR;AACF;"}
1
+ {"version":3,"file":"permissions.js","sources":["../../../../../zero-cache/src/scripts/permissions.ts"],"sourcesContent":["import {existsSync} from 'node:fs';\nimport {basename, dirname, join, relative, resolve, sep} from 'node:path';\nimport {fileURLToPath} from 'node:url';\nimport {tsImport} from 'tsx/esm/api';\nimport {logOptions} from '../../../otel/src/log-options.ts';\nimport {colorConsole} from '../../../shared/src/logging.ts';\nimport * as v from '../../../shared/src/valita.ts';\nimport {\n permissionsConfigSchema,\n type PermissionsConfig,\n} from '../../../zero-schema/src/compiled-permissions.ts';\nimport {isSchemaConfig} from '../../../zero-schema/src/schema-config.ts';\nimport type {Schema} from '../../../zero-types/src/schema.ts';\nimport {appOptions, shardOptions, zeroOptions} from '../config/zero-config.ts';\n\nexport const deployPermissionsOptions = {\n schema: {\n path: {\n type: v.string().default('schema.ts'),\n desc: ['Relative path to the file containing the schema definition.'],\n alias: 'p',\n },\n },\n\n upstream: {\n db: {\n type: v.string().optional(),\n desc: [\n `The upstream Postgres database to deploy permissions to.`,\n `This is ignored if an {bold output-file} is specified.`,\n ],\n },\n\n type: zeroOptions.upstream.type,\n },\n\n app: {id: appOptions.id},\n\n shard: shardOptions,\n\n log: logOptions,\n\n output: {\n file: {\n type: v.string().optional(),\n desc: [\n `Outputs the permissions to a file with the requested {bold output-format}.`,\n ],\n },\n\n format: {\n type: v.literalUnion('sql', 'json', 'pretty').default('sql'),\n desc: [\n `The desired format of the output file.`,\n ``,\n `A {bold sql} file can be executed via \"psql -f <file.sql>\", or \"\\\\\\\\i <file.sql>\"`,\n `from within the psql console, or copied and pasted into a migration script.`,\n ``,\n `The {bold json} and {bold pretty} formats are available for non-pg backends`,\n `and general debugging.`,\n ],\n },\n },\n\n force: {\n type: v.boolean().default(false),\n desc: [`Deploy to upstream without validation. Use at your own risk.`],\n alias: 'f',\n },\n};\n\nexport async function loadSchemaAndPermissions(\n schemaPath: string,\n allowMissing: true,\n): Promise<{schema: Schema; permissions: PermissionsConfig} | undefined>;\nexport async function loadSchemaAndPermissions(\n schemaPath: string,\n allowMissing?: false,\n): Promise<{schema: Schema; permissions: PermissionsConfig}>;\nexport async function loadSchemaAndPermissions(\n schemaPath: string,\n allowMissing: boolean | undefined,\n): Promise<{schema: Schema; permissions: PermissionsConfig} | undefined> {\n const typeModuleErrorMessage = () =>\n `\\n\\nYou may need to add \\` \"type\": \"module\" \\` to the package.json file for ${schemaPath}.\\n`;\n\n colorConsole.info(`Loading schema from ${schemaPath}`);\n\n const dir = dirname(fileURLToPath(import.meta.url));\n const absoluteSchemaPath = resolve(schemaPath);\n const relativeDir = relative(dir, dirname(absoluteSchemaPath));\n let relativePath =\n relativeDir.length && relativeDir !== '.'\n ? join(relativeDir, basename(absoluteSchemaPath))\n : `.${sep}${basename(absoluteSchemaPath)}`;\n\n // tsImport doesn't expect to receive slashes in the Windows format when running\n // on Windows. They need to be converted to *nix format.\n relativePath = relativePath.replace(/\\\\/g, '/');\n\n if (!existsSync(absoluteSchemaPath)) {\n if (allowMissing) {\n return undefined;\n }\n colorConsole.error(`Schema file ${schemaPath} does not exist.`);\n process.exit(1);\n }\n\n let module;\n try {\n module = await tsImport(relativePath, import.meta.url);\n } catch (e) {\n colorConsole.error(\n `Failed to load zero schema from ${absoluteSchemaPath}` +\n typeModuleErrorMessage(),\n );\n throw e;\n }\n\n if (!isSchemaConfig(module)) {\n colorConsole.error(\n `Schema file ${schemaPath} must export [schema].` +\n typeModuleErrorMessage(),\n );\n process.exit(1);\n }\n try {\n const schemaConfig = module;\n const perms =\n await (schemaConfig.permissions as unknown as Promise<unknown>);\n const {schema} = schemaConfig;\n\n if (perms) {\n colorConsole.warn?.(\n 'Permissions are deprecated and will be removed in an upcoming release. See: https://zero.rocicorp.dev/docs/auth.',\n );\n }\n\n return {\n schema,\n permissions: v.parse(perms ?? {}, permissionsConfigSchema),\n };\n } catch (e) {\n colorConsole.error(`Failed to parse Permissions object`);\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,CAAC;AAC7D,MAAI,eACF,YAAY,UAAU,gBAAgB,MAClC,KAAK,aAAa,SAAS,kBAAkB,CAAC,IAC9C,IAAI,GAAG,GAAG,SAAS,kBAAkB,CAAC;AAI5C,iBAAe,aAAa,QAAQ,OAAO,GAAG;AAE9C,MAAI,CAAC,WAAW,kBAAkB,GAAG;AACnC,QAAI,cAAc;AAChB,aAAO;AAAA,IACT;AACA,iBAAa,MAAM,eAAe,UAAU,kBAAkB;AAC9D,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,MAAI;AACJ,MAAI;AACF,aAAS,MAAM,SAAS,cAAc,YAAY,GAAG;AAAA,EACvD,SAAS,GAAG;AACV,iBAAa;AAAA,MACX,mCAAmC,kBAAkB,KACnD,uBAAA;AAAA,IAAuB;AAE3B,UAAM;AAAA,EACR;AAEA,MAAI,CAAC,eAAe,MAAM,GAAG;AAC3B,iBAAa;AAAA,MACX,eAAe,UAAU,2BACvB,uBAAA;AAAA,IAAuB;AAE3B,YAAQ,KAAK,CAAC;AAAA,EAChB;AACA,MAAI;AACF,UAAM,eAAe;AACrB,UAAM,QACJ,MAAO,aAAa;AACtB,UAAM,EAAC,WAAU;AAEjB,QAAI,OAAO;AACT,mBAAa;AAAA,QACX;AAAA,MAAA;AAAA,IAEJ;AAEA,WAAO;AAAA,MACL;AAAA,MACA,aAAaC,MAAQ,SAAS,CAAA,GAAI,uBAAuB;AAAA,IAAA;AAAA,EAE7D,SAAS,GAAG;AACV,iBAAa,MAAM,oCAAoC;AACvD,UAAM;AAAA,EACR;AACF;"}
@@ -1 +1 @@
1
- {"version":3,"file":"published.d.ts","sourceRoot":"","sources":["../../../../../../../../zero-cache/src/services/change-source/pg/schema/published.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AAErC,OAAO,KAAK,CAAC,MAAM,wCAAwC,CAAC;AAG5D,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,UAgFlE;AAED,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,UA0EpE;AAKD,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAE3B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAY9D,QAAA,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAEzB,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,QAAQ,CAAC,GAAG,EACjB,YAAY,EAAE,MAAM,EAAE,GACrB,OAAO,CAAC,eAAe,CAAC,CAiD1B"}
1
+ {"version":3,"file":"published.d.ts","sourceRoot":"","sources":["../../../../../../../../zero-cache/src/services/change-source/pg/schema/published.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AAErC,OAAO,KAAK,CAAC,MAAM,wCAAwC,CAAC;AAG5D,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,UAiFlE;AAED,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,UA0EpE;AAKD,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAE3B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAY9D,QAAA,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAEzB,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,QAAQ,CAAC,GAAG,EACjB,YAAY,EAAE,MAAM,EAAE,GACrB,OAAO,CAAC,eAAe,CAAC,CAiD1B"}
@@ -36,7 +36,8 @@ JOIN pg_publication_tables as pb ON
36
36
  attname = ANY(pb.attnames)
37
37
  LEFT JOIN pg_constraint pk ON pk.contype = 'p' AND pk.connamespace = relnamespace AND pk.conrelid = attrelid
38
38
  LEFT JOIN pg_attrdef pd ON pd.adrelid = attrelid AND pd.adnum = attnum
39
- WHERE pb.pubname IN (${literal(publications)}) AND attgenerated = ''
39
+ WHERE pb.pubname IN (${literal(publications)}) AND
40
+ (current_setting('server_version_num')::int >= 160000 OR attgenerated = '')
40
41
  ORDER BY nspname, pc.relname),
41
42
 
42
43
  tables AS (SELECT json_build_object(
@@ -120,7 +121,7 @@ function indexDefinitionsQuery(publications) {
120
121
  AND pg_index.indpred IS NULL
121
122
  AND (pg_constraint.contype IS NULL OR pg_constraint.contype IN ('p', 'u'))
122
123
  AND indexed.attnames <@ pb.attnames
123
- AND false = ALL(indexed.generated)
124
+ AND (current_setting('server_version_num')::int >= 160000 OR false = ALL(indexed.generated))
124
125
  ORDER BY
125
126
  pg_indexes.schemaname,
126
127
  pg_indexes.tablename,
@@ -1 +1 @@
1
- {"version":3,"file":"published.js","sources":["../../../../../../../../zero-cache/src/services/change-source/pg/schema/published.ts"],"sourcesContent":["import {literal} from 'pg-format';\nimport type postgres from 'postgres';\nimport {equals} from '../../../../../../shared/src/set-utils.ts';\nimport * as v from '../../../../../../shared/src/valita.ts';\nimport {publishedIndexSpec, publishedTableSpec} from '../../../../db/specs.ts';\n\nexport function publishedTableQuery(publications: readonly string[]) {\n // Notes:\n // * There's a bug in PG15 in which generated columns are incorrectly\n // included in pg_publication_tables.attnames, (even though the generated\n // column values are not be included in the replication stream).\n // The WHERE condition `attgenerated = ''` fixes this by explicitly excluding\n // generated columns from the list.\n return /*sql*/ `\nWITH published_columns AS (SELECT \n pc.oid::int8 AS \"oid\",\n nspname AS \"schema\", \n pc.relname AS \"name\", \n pc.relreplident AS \"replicaIdentity\",\n attnum AS \"pos\", \n attname AS \"col\", \n pt.typname AS \"type\", \n atttypid::int8 AS \"typeOID\", \n pt.typtype,\n elem_pt.typtype AS \"elemTyptype\",\n NULLIF(atttypmod, -1) AS \"maxLen\", \n attndims \"arrayDims\", \n attnotnull AS \"notNull\",\n pg_get_expr(pd.adbin, pd.adrelid) as \"dflt\",\n NULLIF(ARRAY_POSITION(conkey, attnum), -1) AS \"keyPos\", \n pb.rowfilter as \"rowFilter\",\n pb.pubname as \"publication\"\nFROM pg_attribute\nJOIN pg_class pc ON pc.oid = attrelid\nJOIN pg_namespace pns ON pns.oid = relnamespace\nJOIN pg_type pt ON atttypid = pt.oid\nLEFT JOIN pg_type elem_pt ON elem_pt.oid = pt.typelem\nJOIN pg_publication_tables as pb ON \n pb.schemaname = nspname AND \n pb.tablename = pc.relname AND\n attname = ANY(pb.attnames)\nLEFT JOIN pg_constraint pk ON pk.contype = 'p' AND pk.connamespace = relnamespace AND pk.conrelid = attrelid\nLEFT JOIN pg_attrdef pd ON pd.adrelid = attrelid AND pd.adnum = attnum\nWHERE pb.pubname IN (${literal(publications)}) AND attgenerated = ''\nORDER BY nspname, pc.relname),\n\ntables AS (SELECT json_build_object(\n 'oid', \"oid\",\n 'schema', \"schema\", \n 'name', \"name\", \n 'replicaIdentity', \"replicaIdentity\",\n 'columns', json_object_agg(\n DISTINCT\n col,\n jsonb_build_object(\n 'pos', \"pos\",\n 'dataType', CASE WHEN \"arrayDims\" = 0 \n THEN \"type\" \n ELSE substring(\"type\" from 2) || repeat('[]', \"arrayDims\") END,\n 'pgTypeClass', \"typtype\",\n 'elemPgTypeClass', \"elemTyptype\",\n 'typeOID', \"typeOID\",\n -- https://stackoverflow.com/a/52376230\n 'characterMaximumLength', CASE WHEN \"typeOID\" = 1043 OR \"typeOID\" = 1042 \n THEN \"maxLen\" - 4 \n ELSE \"maxLen\" END,\n 'notNull', \"notNull\",\n 'dflt', \"dflt\"\n )\n ),\n 'primaryKey', ARRAY( SELECT json_object_keys(\n json_strip_nulls(\n json_object_agg(\n DISTINCT \"col\", \"keyPos\" ORDER BY \"keyPos\"\n )\n )\n )),\n 'publications', json_object_agg(\n DISTINCT \n \"publication\", \n jsonb_build_object('rowFilter', \"rowFilter\")\n )\n) AS \"table\" FROM published_columns GROUP BY \"schema\", \"name\", \"oid\", \"replicaIdentity\")\n\nSELECT COALESCE(json_agg(\"table\"), '[]'::json) as \"tables\" FROM tables\n `;\n}\n\nexport function indexDefinitionsQuery(publications: readonly string[]) {\n // Note: pg_attribute contains column names for tables and for indexes.\n // However, the latter does not get updated when a column in a table is\n // renamed.\n //\n // https://www.postgresql.org/message-id/5860814f-c91d-4ab0-b771-ded90d7b9c55%40www.fastmail.com\n //\n // To address this, the pg_attribute rows are looked up for the index's\n // table rather than the index itself, using the pg_index.indkey array\n // to determine the set and order of columns to include.\n //\n // Notes:\n // * The first bit of indoption is 1 for DESC and 0 for ASC:\n // https://github.com/postgres/postgres/blob/4e1fad37872e49a711adad5d9870516e5c71a375/src/include/catalog/pg_index.h#L89\n // * pg_index.indkey is an int2vector which is 0-based instead of 1-based.\n // * The additional check fo attgenerated is required for the aforementioned\n // (in publishedTableQuery) bug in PG15 in which generated columns are\n // incorrectly included in pg_publication_tables.attnames\n return /*sql*/ `\n WITH indexed_columns AS (SELECT\n pg_indexes.schemaname as \"schema\",\n pg_indexes.tablename as \"tableName\",\n pg_indexes.indexname as \"name\",\n index_column.name as \"col\",\n CASE WHEN pg_index.indoption[index_column.pos-1] & 1 = 1 THEN 'DESC' ELSE 'ASC' END as \"dir\",\n pg_index.indisunique as \"unique\",\n pg_index.indisreplident as \"isReplicaIdentity\",\n pg_index.indimmediate as \"isImmediate\"\n FROM pg_indexes\n JOIN pg_namespace ON pg_indexes.schemaname = pg_namespace.nspname\n JOIN pg_class pc ON\n pc.relname = pg_indexes.indexname\n AND pc.relnamespace = pg_namespace.oid\n JOIN pg_publication_tables as pb ON \n pb.schemaname = pg_indexes.schemaname AND \n pb.tablename = pg_indexes.tablename\n JOIN pg_index ON pg_index.indexrelid = pc.oid\n JOIN LATERAL (\n SELECT array_agg(attname) as attnames, array_agg(attgenerated != '') as generated FROM pg_attribute\n WHERE attrelid = pg_index.indrelid\n AND attnum = ANY( (pg_index.indkey::smallint[] )[:pg_index.indnkeyatts - 1] )\n ) as indexed ON true\n JOIN LATERAL (\n SELECT pg_attribute.attname as name, col.index_pos as pos\n FROM UNNEST( (pg_index.indkey::smallint[])[:pg_index.indnkeyatts - 1] ) \n WITH ORDINALITY as col(table_pos, index_pos)\n JOIN pg_attribute ON attrelid = pg_index.indrelid AND attnum = col.table_pos\n ) AS index_column ON true\n LEFT JOIN pg_constraint ON pg_constraint.conindid = pc.oid\n WHERE pb.pubname IN (${literal(publications)})\n AND pg_index.indexprs IS NULL\n AND pg_index.indpred IS NULL\n AND (pg_constraint.contype IS NULL OR pg_constraint.contype IN ('p', 'u'))\n AND indexed.attnames <@ pb.attnames\n AND false = ALL(indexed.generated)\n ORDER BY\n pg_indexes.schemaname,\n pg_indexes.tablename,\n pg_indexes.indexname,\n index_column.pos ASC),\n \n indexes AS (SELECT json_build_object(\n 'schema', \"schema\",\n 'tableName', \"tableName\",\n 'name', \"name\",\n 'unique', \"unique\",\n 'isReplicaIdentity', \"isReplicaIdentity\",\n 'isImmediate', \"isImmediate\",\n 'columns', json_object_agg(\"col\", \"dir\")\n ) AS index FROM indexed_columns \n GROUP BY \"schema\", \"tableName\", \"name\", \"unique\", \"isReplicaIdentity\", \"isImmediate\")\n\n SELECT COALESCE(json_agg(\"index\"), '[]'::json) as \"indexes\" FROM indexes\n `;\n}\n\nconst publishedTablesSchema = v.object({tables: v.array(publishedTableSpec)});\nconst publishedIndexesSchema = v.object({indexes: v.array(publishedIndexSpec)});\n\nexport const publishedSchema = publishedTablesSchema.extend(\n publishedIndexesSchema.shape,\n);\n\nexport type PublishedSchema = v.Infer<typeof publishedSchema>;\n\nconst publicationSchema = v.object({\n pubname: v.string(),\n pubinsert: v.boolean(),\n pubupdate: v.boolean(),\n pubdelete: v.boolean(),\n pubtruncate: v.boolean(),\n});\n\nconst publicationsResultSchema = v.array(publicationSchema);\n\nconst publicationInfoSchema = publishedSchema.extend({\n publications: publicationsResultSchema,\n});\n\nexport type PublicationInfo = v.Infer<typeof publicationInfoSchema>;\n\n/**\n * Retrieves published tables and columns.\n */\nexport async function getPublicationInfo(\n sql: postgres.Sql,\n publications: string[],\n): Promise<PublicationInfo> {\n const result = await sql.unsafe(/*sql*/ `\n SELECT \n schemaname AS \"schema\",\n tablename AS \"table\", \n json_object_agg(pubname, attnames) AS \"publications\"\n FROM pg_publication_tables pb\n WHERE pb.pubname IN (${literal(publications)})\n GROUP BY schemaname, tablename;\n\n SELECT ${Object.keys(publicationSchema.shape).join(\n ',',\n )} FROM pg_publication pb\n WHERE pb.pubname IN (${literal(publications)})\n ORDER BY pubname;\n\n ${publishedTableQuery(publications)};\n\n ${indexDefinitionsQuery(publications)};\n`);\n\n // The first query is used to check that tables in multiple publications\n // always publish the same set of columns.\n const publishedColumns = result[0] as {\n schema: string;\n table: string;\n publications: Record<string, string[]>;\n }[];\n for (const {table, publications} of publishedColumns) {\n let expected: Set<string>;\n Object.entries(publications).forEach(([_, columns], i) => {\n const cols = new Set(columns);\n if (i === 0) {\n expected = cols;\n } else if (!equals(expected, cols)) {\n throw new Error(\n `Table ${table} is exported with different columns: [${[\n ...expected,\n ]}] vs [${[...cols]}]`,\n );\n }\n });\n }\n\n return {\n publications: v.parse(result[1], publicationsResultSchema),\n ...v.parse(result[2][0], publishedTablesSchema),\n ...v.parse(result[3][0], publishedIndexesSchema),\n };\n}\n"],"names":["v.object","v.array","v.string","v.boolean","publications","v.parse"],"mappings":";;;;;AAMO,SAAS,oBAAoB,cAAiC;AAOnE;AAAA;AAAA,IAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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AA2BF,MAAQ,iBAAiB;AAE5B,gBAAgB,OAAO;AAAA,EACnD,cAAc;AAChB,CAAC;AAOD,eAAsB,mBACpB,KACA,cAC0B;AAC1B,QAAM,SAAS,MAAM,IAAI;AAAA;AAAA,IAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAMf,QAAQ,YAAY,CAAC;AAAA;AAAA;AAAA,WAGrC,OAAO,KAAK,kBAAkB,KAAK,EAAE;AAAA,MAC5C;AAAA,IAAA,CACD;AAAA,2BACwB,QAAQ,YAAY,CAAC;AAAA;AAAA;AAAA,IAG5C,oBAAoB,YAAY,CAAC;AAAA;AAAA,IAEjC,sBAAsB,YAAY,CAAC;AAAA;AAAA,EAAA;AAKrC,QAAM,mBAAmB,OAAO,CAAC;AAKjC,aAAW,EAAC,OAAO,cAAAG,cAAAA,KAAiB,kBAAkB;AACpD,QAAI;AACJ,WAAO,QAAQA,aAAY,EAAE,QAAQ,CAAC,CAAC,GAAG,OAAO,GAAG,MAAM;AACxD,YAAM,OAAO,IAAI,IAAI,OAAO;AAC5B,UAAI,MAAM,GAAG;AACX,mBAAW;AAAA,MACb,WAAW,CAAC,OAAO,UAAU,IAAI,GAAG;AAClC,cAAM,IAAI;AAAA,UACR,SAAS,KAAK,yCAAyC;AAAA,YACrD,GAAG;AAAA,UAAA,CACJ,SAAS,CAAC,GAAG,IAAI,CAAC;AAAA,QAAA;AAAA,MAEvB;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SAAO;AAAA,IACL,cAAcC,MAAQ,OAAO,CAAC,GAAG,wBAAwB;AAAA,IACzD,GAAGA,MAAQ,OAAO,CAAC,EAAE,CAAC,GAAG,qBAAqB;AAAA,IAC9C,GAAGA,MAAQ,OAAO,CAAC,EAAE,CAAC,GAAG,sBAAsB;AAAA,EAAA;AAEnD;"}
1
+ {"version":3,"file":"published.js","sources":["../../../../../../../../zero-cache/src/services/change-source/pg/schema/published.ts"],"sourcesContent":["import {literal} from 'pg-format';\nimport type postgres from 'postgres';\nimport {equals} from '../../../../../../shared/src/set-utils.ts';\nimport * as v from '../../../../../../shared/src/valita.ts';\nimport {publishedIndexSpec, publishedTableSpec} from '../../../../db/specs.ts';\n\nexport function publishedTableQuery(publications: readonly string[]) {\n // Notes:\n // * There's a bug in PG15 in which generated columns are incorrectly\n // included in pg_publication_tables.attnames, (even though the generated\n // column values are not be included in the replication stream).\n // The WHERE condition `attgenerated = ''` fixes this by explicitly excluding\n // generated columns from the list.\n return /*sql*/ `\nWITH published_columns AS (SELECT \n pc.oid::int8 AS \"oid\",\n nspname AS \"schema\", \n pc.relname AS \"name\", \n pc.relreplident AS \"replicaIdentity\",\n attnum AS \"pos\", \n attname AS \"col\", \n pt.typname AS \"type\", \n atttypid::int8 AS \"typeOID\", \n pt.typtype,\n elem_pt.typtype AS \"elemTyptype\",\n NULLIF(atttypmod, -1) AS \"maxLen\", \n attndims \"arrayDims\", \n attnotnull AS \"notNull\",\n pg_get_expr(pd.adbin, pd.adrelid) as \"dflt\",\n NULLIF(ARRAY_POSITION(conkey, attnum), -1) AS \"keyPos\", \n pb.rowfilter as \"rowFilter\",\n pb.pubname as \"publication\"\nFROM pg_attribute\nJOIN pg_class pc ON pc.oid = attrelid\nJOIN pg_namespace pns ON pns.oid = relnamespace\nJOIN pg_type pt ON atttypid = pt.oid\nLEFT JOIN pg_type elem_pt ON elem_pt.oid = pt.typelem\nJOIN pg_publication_tables as pb ON \n pb.schemaname = nspname AND \n pb.tablename = pc.relname AND\n attname = ANY(pb.attnames)\nLEFT JOIN pg_constraint pk ON pk.contype = 'p' AND pk.connamespace = relnamespace AND pk.conrelid = attrelid\nLEFT JOIN pg_attrdef pd ON pd.adrelid = attrelid AND pd.adnum = attnum\nWHERE pb.pubname IN (${literal(publications)}) AND \n (current_setting('server_version_num')::int >= 160000 OR attgenerated = '')\nORDER BY nspname, pc.relname),\n\ntables AS (SELECT json_build_object(\n 'oid', \"oid\",\n 'schema', \"schema\", \n 'name', \"name\", \n 'replicaIdentity', \"replicaIdentity\",\n 'columns', json_object_agg(\n DISTINCT\n col,\n jsonb_build_object(\n 'pos', \"pos\",\n 'dataType', CASE WHEN \"arrayDims\" = 0 \n THEN \"type\" \n ELSE substring(\"type\" from 2) || repeat('[]', \"arrayDims\") END,\n 'pgTypeClass', \"typtype\",\n 'elemPgTypeClass', \"elemTyptype\",\n 'typeOID', \"typeOID\",\n -- https://stackoverflow.com/a/52376230\n 'characterMaximumLength', CASE WHEN \"typeOID\" = 1043 OR \"typeOID\" = 1042 \n THEN \"maxLen\" - 4 \n ELSE \"maxLen\" END,\n 'notNull', \"notNull\",\n 'dflt', \"dflt\"\n )\n ),\n 'primaryKey', ARRAY( SELECT json_object_keys(\n json_strip_nulls(\n json_object_agg(\n DISTINCT \"col\", \"keyPos\" ORDER BY \"keyPos\"\n )\n )\n )),\n 'publications', json_object_agg(\n DISTINCT \n \"publication\", \n jsonb_build_object('rowFilter', \"rowFilter\")\n )\n) AS \"table\" FROM published_columns GROUP BY \"schema\", \"name\", \"oid\", \"replicaIdentity\")\n\nSELECT COALESCE(json_agg(\"table\"), '[]'::json) as \"tables\" FROM tables\n `;\n}\n\nexport function indexDefinitionsQuery(publications: readonly string[]) {\n // Note: pg_attribute contains column names for tables and for indexes.\n // However, the latter does not get updated when a column in a table is\n // renamed.\n //\n // https://www.postgresql.org/message-id/5860814f-c91d-4ab0-b771-ded90d7b9c55%40www.fastmail.com\n //\n // To address this, the pg_attribute rows are looked up for the index's\n // table rather than the index itself, using the pg_index.indkey array\n // to determine the set and order of columns to include.\n //\n // Notes:\n // * The first bit of indoption is 1 for DESC and 0 for ASC:\n // https://github.com/postgres/postgres/blob/4e1fad37872e49a711adad5d9870516e5c71a375/src/include/catalog/pg_index.h#L89\n // * pg_index.indkey is an int2vector which is 0-based instead of 1-based.\n // * The additional check for attgenerated is required for the aforementioned\n // (in publishedTableQuery) bug in PG15 in which generated columns are\n // incorrectly included in pg_publication_tables.attnames\n return /*sql*/ `\n WITH indexed_columns AS (SELECT\n pg_indexes.schemaname as \"schema\",\n pg_indexes.tablename as \"tableName\",\n pg_indexes.indexname as \"name\",\n index_column.name as \"col\",\n CASE WHEN pg_index.indoption[index_column.pos-1] & 1 = 1 THEN 'DESC' ELSE 'ASC' END as \"dir\",\n pg_index.indisunique as \"unique\",\n pg_index.indisreplident as \"isReplicaIdentity\",\n pg_index.indimmediate as \"isImmediate\"\n FROM pg_indexes\n JOIN pg_namespace ON pg_indexes.schemaname = pg_namespace.nspname\n JOIN pg_class pc ON\n pc.relname = pg_indexes.indexname\n AND pc.relnamespace = pg_namespace.oid\n JOIN pg_publication_tables as pb ON \n pb.schemaname = pg_indexes.schemaname AND \n pb.tablename = pg_indexes.tablename\n JOIN pg_index ON pg_index.indexrelid = pc.oid\n JOIN LATERAL (\n SELECT array_agg(attname) as attnames, array_agg(attgenerated != '') as generated FROM pg_attribute\n WHERE attrelid = pg_index.indrelid\n AND attnum = ANY( (pg_index.indkey::smallint[] )[:pg_index.indnkeyatts - 1] )\n ) as indexed ON true\n JOIN LATERAL (\n SELECT pg_attribute.attname as name, col.index_pos as pos\n FROM UNNEST( (pg_index.indkey::smallint[])[:pg_index.indnkeyatts - 1] ) \n WITH ORDINALITY as col(table_pos, index_pos)\n JOIN pg_attribute ON attrelid = pg_index.indrelid AND attnum = col.table_pos\n ) AS index_column ON true\n LEFT JOIN pg_constraint ON pg_constraint.conindid = pc.oid\n WHERE pb.pubname IN (${literal(publications)})\n AND pg_index.indexprs IS NULL\n AND pg_index.indpred IS NULL\n AND (pg_constraint.contype IS NULL OR pg_constraint.contype IN ('p', 'u'))\n AND indexed.attnames <@ pb.attnames\n AND (current_setting('server_version_num')::int >= 160000 OR false = ALL(indexed.generated))\n ORDER BY\n pg_indexes.schemaname,\n pg_indexes.tablename,\n pg_indexes.indexname,\n index_column.pos ASC),\n \n indexes AS (SELECT json_build_object(\n 'schema', \"schema\",\n 'tableName', \"tableName\",\n 'name', \"name\",\n 'unique', \"unique\",\n 'isReplicaIdentity', \"isReplicaIdentity\",\n 'isImmediate', \"isImmediate\",\n 'columns', json_object_agg(\"col\", \"dir\")\n ) AS index FROM indexed_columns \n GROUP BY \"schema\", \"tableName\", \"name\", \"unique\", \"isReplicaIdentity\", \"isImmediate\")\n\n SELECT COALESCE(json_agg(\"index\"), '[]'::json) as \"indexes\" FROM indexes\n `;\n}\n\nconst publishedTablesSchema = v.object({tables: v.array(publishedTableSpec)});\nconst publishedIndexesSchema = v.object({indexes: v.array(publishedIndexSpec)});\n\nexport const publishedSchema = publishedTablesSchema.extend(\n publishedIndexesSchema.shape,\n);\n\nexport type PublishedSchema = v.Infer<typeof publishedSchema>;\n\nconst publicationSchema = v.object({\n pubname: v.string(),\n pubinsert: v.boolean(),\n pubupdate: v.boolean(),\n pubdelete: v.boolean(),\n pubtruncate: v.boolean(),\n});\n\nconst publicationsResultSchema = v.array(publicationSchema);\n\nconst publicationInfoSchema = publishedSchema.extend({\n publications: publicationsResultSchema,\n});\n\nexport type PublicationInfo = v.Infer<typeof publicationInfoSchema>;\n\n/**\n * Retrieves published tables and columns.\n */\nexport async function getPublicationInfo(\n sql: postgres.Sql,\n publications: string[],\n): Promise<PublicationInfo> {\n const result = await sql.unsafe(/*sql*/ `\n SELECT \n schemaname AS \"schema\",\n tablename AS \"table\", \n json_object_agg(pubname, attnames) AS \"publications\"\n FROM pg_publication_tables pb\n WHERE pb.pubname IN (${literal(publications)})\n GROUP BY schemaname, tablename;\n\n SELECT ${Object.keys(publicationSchema.shape).join(\n ',',\n )} FROM pg_publication pb\n WHERE pb.pubname IN (${literal(publications)})\n ORDER BY pubname;\n\n ${publishedTableQuery(publications)};\n\n ${indexDefinitionsQuery(publications)};\n`);\n\n // The first query is used to check that tables in multiple publications\n // always publish the same set of columns.\n const publishedColumns = result[0] as {\n schema: string;\n table: string;\n publications: Record<string, string[]>;\n }[];\n for (const {table, publications} of publishedColumns) {\n let expected: Set<string>;\n Object.entries(publications).forEach(([_, columns], i) => {\n const cols = new Set(columns);\n if (i === 0) {\n expected = cols;\n } else if (!equals(expected, cols)) {\n throw new Error(\n `Table ${table} is exported with different columns: [${[\n ...expected,\n ]}] vs [${[...cols]}]`,\n );\n }\n });\n }\n\n return {\n publications: v.parse(result[1], publicationsResultSchema),\n ...v.parse(result[2][0], publishedTablesSchema),\n ...v.parse(result[3][0], publishedIndexesSchema),\n };\n}\n"],"names":["v.object","v.array","v.string","v.boolean","publications","v.parse"],"mappings":";;;;;AAMO,SAAS,oBAAoB,cAAiC;AAOnE;AAAA;AAAA,IAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBA8BM,QAAQ,YAAY,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA4C5C;AAEO,SAAS,sBAAsB,cAAiC;AAkBrE;AAAA;AAAA,IAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BA+BU,QAAQ,YAAY,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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AAAA,QAAA;AAAA,MAEvB;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SAAO;AAAA,IACL,cAAcC,MAAQ,OAAO,CAAC,GAAG,wBAAwB;AAAA,IACzD,GAAGA,MAAQ,OAAO,CAAC,EAAE,CAAC,GAAG,qBAAqB;AAAA,IAC9C,GAAGA,MAAQ,OAAO,CAAC,EAAE,CAAC,GAAG,sBAAsB;AAAA,EAAA;AAEnD;"}
@@ -13,7 +13,7 @@ type ZeroCRUDMutate = {
13
13
  [CRUD_MUTATION_NAME]: CRUDMutate;
14
14
  };
15
15
  /**
16
- * This is the zero.mutate object part representing the CRUD operations. If the
16
+ * This is the zero.mutateBatch function part representing the CRUD operations. If the
17
17
  * tables are `issue` and `label`, then this object will have `issue` and
18
18
  * `label` properties.
19
19
  *
@@ -22,7 +22,8 @@ type ZeroCRUDMutate = {
22
22
  * @param mutate - The object to use as the mutate object. Properties for each
23
23
  * table will be assigned to this object.
24
24
  */
25
- export declare function makeCRUDMutate<const S extends Schema>(schema: S, repMutate: ZeroCRUDMutate, mutate: object): BatchMutator<S>;
25
+ export declare function makeCRUDMutateBatch<const S extends Schema>(schema: S, repMutate: ZeroCRUDMutate): BatchMutator<S>;
26
+ export declare function addTableCRUDProperties<TSchema extends Schema>(schema: TSchema, mutate: object, repMutate: ZeroCRUDMutate): void;
26
27
  /**
27
28
  * Creates the `{insert, upsert, update, delete}` object for use inside a
28
29
  * batch.
@@ -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,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,0CAA0C,CAAC;AAC1E,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,mCAA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,YAAY,CAWd;AAMD,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,CAU3D"}
@@ -1,7 +1,7 @@
1
1
  import { promiseVoid } from "../../../shared/src/resolved-promises.js";
2
2
  import { CRUD_MUTATION_NAME } from "../../../zero-protocol/src/push.js";
3
3
  import * as crudImpl from "./crud-impl.js";
4
- function makeCRUDMutate(schema, repMutate, mutate) {
4
+ function makeCRUDMutateBatch(schema, repMutate) {
5
5
  if (schema.enableLegacyMutators !== true) {
6
6
  return void 0;
7
7
  }
@@ -16,6 +16,10 @@ function makeCRUDMutate(schema, repMutate, mutate) {
16
16
  await zeroCRUD({ ops });
17
17
  return rv;
18
18
  };
19
+ return mutateBatch;
20
+ }
21
+ function addTableCRUDProperties(schema, mutate, repMutate) {
22
+ const { [CRUD_MUTATION_NAME]: zeroCRUD } = repMutate;
19
23
  for (const [name, tableSchema] of Object.entries(schema.tables)) {
20
24
  mutate[name] = makeEntityCRUDMutate(
21
25
  name,
@@ -23,7 +27,6 @@ function makeCRUDMutate(schema, repMutate, mutate) {
23
27
  zeroCRUD
24
28
  );
25
29
  }
26
- return mutateBatch;
27
30
  }
28
31
  function makeEntityCRUDMutate(tableName, primaryKey, zeroCRUD) {
29
32
  return {
@@ -131,9 +134,10 @@ function makeCRUDMutator(schema) {
131
134
  };
132
135
  }
133
136
  export {
137
+ addTableCRUDProperties,
134
138
  makeBatchCRUDMutate,
135
139
  makeCRUDExecutor,
136
- makeCRUDMutate,
140
+ makeCRUDMutateBatch,
137
141
  makeCRUDMutator
138
142
  };
139
143
  //# sourceMappingURL=crud.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"crud.js","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/push.ts';\nimport type {TableSchema} from '../../../zero-schema/src/table-schema.ts';\nimport type {Schema} from '../../../zero-types/src/schema.ts';\nimport type {CRUDExecutor, TableMutator} from '../../../zql/src/mutate/crud.ts';\nimport type {\n DeleteID,\n InsertValue,\n UpdateValue,\n UpsertValue,\n} from '../../../zql/src/mutate/custom.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.mutate object 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 makeCRUDMutate<const S extends Schema>(\n schema: S,\n repMutate: ZeroCRUDMutate,\n mutate: object,\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 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 return mutateBatch as BatchMutator<S>;\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"],"names":[],"mappings":";;;AAiDO,SAAS,eACd,QACA,WACA,QACiB;AACjB,MAAI,OAAO,yBAAyB,MAAM;AACxC,WAAO;AAAA,EACT;AAEA,QAAM,EAAC,CAAC,kBAAkB,GAAG,aAAY;AAEzC,QAAM,cAAc,OAAU,SAA6C;AACzE,UAAM,MAAgB,CAAA;AACtB,UAAM,IAAI,CAAA;AACV,eAAW,QAAQ,OAAO,KAAK,OAAO,MAAM,GAAG;AAC7C,QAAE,IAAI,IAAI,oBAAoB,MAAM,QAAQ,GAAG;AAAA,IACjD;AAEA,UAAM,KAAK,MAAM,KAAK,CAAiB;AACvC,UAAM,SAAS,EAAC,KAAI;AACpB,WAAO;AAAA,EACT;AAEA,aAAW,CAAC,MAAM,WAAW,KAAK,OAAO,QAAQ,OAAO,MAAM,G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,QACA;AAAA,MAAA;AAEF,UAAI,KAAK,EAAE;AACX,aAAO;AAAA,IACT;AAAA,IACA,QAAQ,CAAC,UAA0B;AACjC,YAAM,KAAe;AAAA,QACnB,IAAI;AAAA,QACJ;AAAA,QACA;AAAA,QACA;AAAA,MAAA;AAEF,UAAI,KAAK,EAAE;AACX,aAAO;AAAA,IACT;AAAA,IACA,QAAQ,CAAC,OAAoB;AAC3B,YAAM,KAAe;AAAA,QACnB,IAAI;AAAA,QACJ;AAAA,QACA;AAAA,QACA,OAAO;AAAA,MAAA;AAET,UAAI,KAAK,EAAE;AACX,aAAO;AAAA,IACT;AAAA,EAAA;AAEJ;AAaO,SAAS,iBACd,IACA,QACA,WACc;AACd,SAAO,CAAC,WAAW,MAAM,UAAU;AACjC,UAAM,EAAC,WAAA,IAAc,OAAO,OAAO,SAAS;AAC5C,WAAO,SAAS,IAAI;AAAA,MAClB;AAAA;AAAA,MAEA,EAAC,IAAI,MAAM,WAAW,YAAY,MAAA;AAAA,MAClC;AAAA,MACA;AAAA,IAAA;AAAA,EAEJ;AACF;AAMO,SAAS,gBAAgB,QAA6B;AAC3D,SAAO,OACL,IACA,YACkB;AAClB,UAAM,WAAW,iBAAiB,IAAI,QAAQ,MAAS;AACvD,eAAW,MAAM,QAAQ,KAAK;AAC5B,YAAM,SAAS,GAAG,WAAW,GAAG,IAAI,GAAG,KAAK;AAAA,IAC9C;AAAA,EACF;AACF;"}
1
+ {"version":3,"file":"crud.js","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/push.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"],"names":[],"mappings":";;;AAkDO,SAAS,oBACd,QACA,WACiB;AACjB,MAAI,OAAO,yBAAyB,MAAM;AACxC,WAAO;AAAA,EACT;AAEA,QAAM,EAAC,CAAC,kBAAkB,GAAG,aAAY;AAEzC,QAAM,cAAc,OAAU,SAA6C;AACzE,UAAM,MAAgB,CAAA;AACtB,UAAM,IAAI,CAAA;AACV,eAAW,QAAQ,OAAO,KAAK,OAAO,MAAM,GAAG;AAC7C,QAAE,IAAI,IAAI,oBAAoB,MAAM,QAAQ,GAAG;AAAA,IACjD;AAEA,UAAM,KAAK,MAAM,KAAK,CAAiB;AACvC,UAAM,SAAS,EAAC,KAAI;AACpB,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAEO,SAAS,uBACd,QACA,QACA,WACM;AACN,QAAM,EAAC,CAAC,kBAAkB,GAAG,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YAAM,KAAe;AAAA,QACnB,IAAI;AAAA,QACJ;AAAA,QACA;AAAA,QACA;AAAA,MAAA;AAEF,UAAI,KAAK,EAAE;AACX,aAAO;AAAA,IACT;AAAA,IACA,QAAQ,CAAC,UAA0B;AACjC,YAAM,KAAe;AAAA,QACnB,IAAI;AAAA,QACJ;AAAA,QACA;AAAA,QACA;AAAA,MAAA;AAEF,UAAI,KAAK,EAAE;AACX,aAAO;AAAA,IACT;AAAA,IACA,QAAQ,CAAC,OAAoB;AAC3B,YAAM,KAAe;AAAA,QACnB,IAAI;AAAA,QACJ;AAAA,QACA;AAAA,QACA,OAAO;AAAA,MAAA;AAET,UAAI,KAAK,EAAE;AACX,aAAO;AAAA,IACT;AAAA,EAAA;AAEJ;AAaO,SAAS,iBACd,IACA,QACA,WACc;AACd,SAAO,CAAC,WAAW,MAAM,UAAU;AACjC,UAAM,EAAC,WAAA,IAAc,OAAO,OAAO,SAAS;AAC5C,WAAO,SAAS,IAAI;AAAA,MAClB;AAAA;AAAA,MAEA,EAAC,IAAI,MAAM,WAAW,YAAY,MAAA;AAAA,MAClC;AAAA,MACA;AAAA,IAAA;AAAA,EAEJ;AACF;AAMO,SAAS,gBAAgB,QAA6B;AAC3D,SAAO,OACL,IACA,YACkB;AAClB,UAAM,WAAW,iBAAiB,IAAI,QAAQ,MAAS;AACvD,eAAW,MAAM,QAAQ,KAAK;AAC5B,YAAM,SAAS,GAAG,WAAW,GAAG,IAAI,GAAG,KAAK;AAAA,IAC9C;AAAA,EACF;AACF;"}
@@ -3,7 +3,8 @@ import type { ZeroTxData } from '../../../replicache/src/replicache-options.ts';
3
3
  import type { ReadonlyJSONValue } from '../../../shared/src/json.ts';
4
4
  import type { DefaultSchema } from '../../../zero-types/src/default-types.ts';
5
5
  import type { Schema } from '../../../zero-types/src/schema.ts';
6
- import type { ClientTransaction, MutateCRUD, Transaction } from '../../../zql/src/mutate/custom.ts';
6
+ import { type TransactionMutate } from '../../../zql/src/mutate/crud.ts';
7
+ import type { ClientTransaction, Transaction } from '../../../zql/src/mutate/custom.ts';
7
8
  import { type HumanReadable, type Query, type RunOptions } from '../../../zql/src/query/query.ts';
8
9
  import type { SchemaQuery } from '../../../zql/src/query/schema-query.ts';
9
10
  import type { ClientID } from '../types/client-state.ts';
@@ -54,7 +55,7 @@ export type MakeCustomMutatorInterface<TSchema extends Schema, F> = F extends (t
54
55
  export declare class TransactionImpl<TSchema extends Schema = DefaultSchema> implements ClientTransaction<TSchema> {
55
56
  #private;
56
57
  readonly location = "client";
57
- readonly mutate: MutateCRUD<TSchema>;
58
+ readonly mutate: TransactionMutate<TSchema>;
58
59
  /**
59
60
  * @deprecated Use {@linkcode createBuilder} with `tx.run(zql.table.where(...))` instead.
60
61
  */
@@ -1 +1 @@
1
- {"version":3,"file":"custom.d.ts","sourceRoot":"","sources":["../../../../../zero-client/src/client/custom.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,+CAA+C,CAAC;AAI9E,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,6BAA6B,CAAC;AAGnE,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,0CAA0C,CAAC;AAC5E,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,mCAAmC,CAAC;AAE9D,OAAO,KAAK,EACV,iBAAiB,EACjB,UAAU,EACV,WAAW,EACZ,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,KAAK,EACV,KAAK,UAAU,EAChB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,wCAAwC,CAAC;AACxE,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,0BAA0B,CAAC;AAIvD,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,uBAAuB,CAAC;AAE5D;;;GAGG;AACH,MAAM,MAAM,iBAAiB,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O;IAoBpE,IAAI,QAAQ,IAAI,QAAQ,CAEvB;IAED,IAAI,UAAU,IAAI,MAAM,CAEvB;IAED,IAAI,MAAM,IAAI,YAAY,GAAG,QAAQ,CAEpC;IAED,IAAI,KAAK,IAAI,MAAM,GAAG,SAAS,CAE9B;IAED,GAAG,CAAC,MAAM,SAAS,MAAM,OAAO,CAAC,QAAQ,CAAC,GAAG,MAAM,EAAE,OAAO,EAC1D,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,EACtC,OAAO,CAAC,EAAE,UAAU,GACnB,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;CAGnC;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,gBAAgB,GAAG,UAAU,CAMjE;AAED,wBAAgB,qBAAqB,CACnC,CAAC,SAAS,MAAM,EAChB,mBAAmB,EACnB,OAAO,EAEP,EAAE,EAAE,UAAU,EACd,OAAO,EAAE,iBAAiB,CAAC,CAAC,EAAE,mBAAmB,CAAC,EAClD,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,OAAO,GACf,CAAC,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,iBAAiB,KAAK,OAAO,CAAC,IAAI,CAAC,CAQrE"}
@@ -2,7 +2,7 @@ import { zeroData } from "../../../replicache/src/transactions.js";
2
2
  import { assert } from "../../../shared/src/asserts.js";
3
3
  import { must } from "../../../shared/src/must.js";
4
4
  import { emptyFunction } from "../../../shared/src/sentinels.js";
5
- import { makeMutateCRUDFunction } from "../../../zql/src/mutate/crud.js";
5
+ import { makeTransactionMutate } from "../../../zql/src/mutate/crud.js";
6
6
  import { createRunnableBuilder } from "../../../zql/src/query/create-builder.js";
7
7
  import "../../../zero-protocol/src/ast.js";
8
8
  import { ZeroContext } from "./context.js";
@@ -22,7 +22,7 @@ class TransactionImpl {
22
22
  const ivmBranch = txData.ivmSources;
23
23
  this.#repTx = repTx;
24
24
  const executor = makeCRUDExecutor(repTx, schema, ivmBranch);
25
- this.mutate = makeMutateCRUDFunction(schema, executor);
25
+ this.mutate = makeTransactionMutate(schema, executor);
26
26
  const zeroContext = newZeroContext(
27
27
  lc,
28
28
  txData.ivmSources
@@ -1 +1 @@
1
- {"version":3,"file":"custom.js","sources":["../../../../../zero-client/src/client/custom.ts"],"sourcesContent":["import type {LogContext} from '@rocicorp/logger';\nimport type {ZeroTxData} from '../../../replicache/src/replicache-options.ts';\nimport type {WriteTransactionImpl} from '../../../replicache/src/transactions.ts';\nimport {zeroData} from '../../../replicache/src/transactions.ts';\nimport {assert} from '../../../shared/src/asserts.ts';\nimport type {ReadonlyJSONValue} from '../../../shared/src/json.ts';\nimport {must} from '../../../shared/src/must.ts';\nimport {emptyFunction} from '../../../shared/src/sentinels.ts';\nimport type {DefaultSchema} from '../../../zero-types/src/default-types.ts';\nimport type {Schema} from '../../../zero-types/src/schema.ts';\nimport {makeMutateCRUDFunction} from '../../../zql/src/mutate/crud.ts';\nimport type {\n ClientTransaction,\n MutateCRUD,\n Transaction,\n} from '../../../zql/src/mutate/custom.ts';\nimport {createRunnableBuilder} from '../../../zql/src/query/create-builder.ts';\nimport {\n type HumanReadable,\n type Query,\n type RunOptions,\n} from '../../../zql/src/query/query.ts';\nimport type {SchemaQuery} from '../../../zql/src/query/schema-query.ts';\nimport type {ClientID} from '../types/client-state.ts';\nimport {ZeroContext} from './context.ts';\nimport {makeCRUDExecutor} from './crud.ts';\nimport type {IVMSourceBranch} from './ivm-branch.ts';\nimport type {WriteTransaction} from './replicache-types.ts';\n\n/**\n * The shape which a user's custom mutator definitions must conform to.\n * Supports arbitrary depth nesting of namespaces.\n */\nexport type CustomMutatorDefs = {\n // oxlint-disable-next-line no-explicit-any\n [namespaceOrKey: string]: CustomMutatorImpl<any> | CustomMutatorDefs;\n};\n\nexport type MutatorResultDetails =\n | {\n readonly type: 'success';\n }\n | {\n readonly type: 'error';\n readonly error:\n | {\n readonly type: 'app';\n readonly message: string;\n readonly details: ReadonlyJSONValue | undefined;\n }\n | {\n readonly type: 'zero';\n readonly message: string;\n };\n };\n\nexport type MutatorResultSuccessDetails = Extract<\n MutatorResultDetails,\n {type: 'success'}\n>;\nexport type MutatorResultErrorDetails = Extract<\n MutatorResultDetails,\n {type: 'error'}\n>;\n\nexport type MutatorResult = {\n client: Promise<MutatorResultDetails & {}>;\n server: Promise<MutatorResultDetails & {}>;\n} & {};\n\nexport type CustomMutatorImpl<\n S extends Schema,\n TWrappedTransaction = unknown,\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n TArgs = any,\n Context = unknown,\n> = (\n tx: Transaction<S, TWrappedTransaction>,\n // TODO: many args. See commit: 52657c2f934b4a458d628ea77e56ce92b61eb3c6 which did have many args.\n // The issue being that it will be a protocol change to support varargs.\n args: TArgs,\n ctx: Context,\n) => Promise<void>;\n\n/**\n * The shape exposed on the `Zero.mutate` instance.\n * The signature of a custom mutator takes a `transaction` as its first arg\n * but the user does not provide this arg when calling the mutator.\n *\n * This utility strips the `tx` arg from the user's custom mutator signatures.\n * Supports arbitrary depth nesting of namespaces.\n */\nexport type MakeCustomMutatorInterfaces<\n S extends Schema,\n MD extends CustomMutatorDefs,\n TContext,\n> = {\n readonly [NamespaceOrName in keyof MD]: MD[NamespaceOrName] extends (\n tx: Transaction<S>,\n ...args: infer Args\n ) => Promise<void>\n ? (...args: Args) => MutatorResult\n : MD[NamespaceOrName] extends CustomMutatorDefs\n ? MakeCustomMutatorInterfaces<S, MD[NamespaceOrName], TContext>\n : never;\n};\n\nexport type MakeCustomMutatorInterface<TSchema extends Schema, F> = F extends (\n tx: ClientTransaction<TSchema>,\n ...args: infer Args\n) => Promise<void>\n ? (...args: Args) => MutatorResult\n : never;\n\nexport class TransactionImpl<TSchema extends Schema = DefaultSchema>\n implements ClientTransaction<TSchema>\n{\n readonly location = 'client';\n readonly mutate: MutateCRUD<TSchema>;\n /**\n * @deprecated Use {@linkcode createBuilder} with `tx.run(zql.table.where(...))` instead.\n */\n readonly query: SchemaQuery<TSchema>;\n\n readonly #repTx: WriteTransaction;\n readonly #zeroContext: ZeroContext;\n\n constructor(lc: LogContext, repTx: WriteTransaction, schema: TSchema) {\n must(repTx.reason === 'initial' || repTx.reason === 'rebase');\n const txData = getZeroTxData(repTx);\n const ivmBranch = txData.ivmSources as IVMSourceBranch;\n\n this.#repTx = repTx;\n\n const executor = makeCRUDExecutor(repTx, schema, ivmBranch);\n this.mutate = makeMutateCRUDFunction(schema, executor);\n\n const zeroContext = newZeroContext(\n lc,\n txData.ivmSources as IVMSourceBranch,\n );\n\n this.query = createRunnableBuilder(zeroContext, schema);\n\n this.#zeroContext = zeroContext;\n }\n\n get clientID(): ClientID {\n return this.#repTx.clientID;\n }\n\n get mutationID(): number {\n return this.#repTx.mutationID;\n }\n\n get reason(): 'optimistic' | 'rebase' {\n return this.#repTx.reason === 'initial' ? 'optimistic' : 'rebase';\n }\n\n get token(): string | undefined {\n return (this.#repTx as WriteTransactionImpl)[zeroData]?.token;\n }\n\n run<TTable extends keyof TSchema['tables'] & string, TReturn>(\n query: Query<TTable, TSchema, TReturn>,\n options?: RunOptions,\n ): Promise<HumanReadable<TReturn>> {\n return this.#zeroContext.run(query, options);\n }\n}\n\nexport function getZeroTxData(repTx: WriteTransaction): ZeroTxData {\n const txData = must(\n (repTx as WriteTransactionImpl)[zeroData],\n 'zero was not set on replicache internal options!',\n );\n return txData as ZeroTxData;\n}\n\nexport function makeReplicacheMutator<\n S extends Schema,\n TWrappedTransaction,\n Context,\n>(\n lc: LogContext,\n mutator: CustomMutatorImpl<S, TWrappedTransaction>,\n schema: S,\n context: Context,\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 await mutator(tx, args, context);\n };\n}\n\nfunction assertValidRunOptions(options: RunOptions | undefined): void {\n // TODO(arv): We should enforce this with the type system too.\n assert(\n options?.type !== 'complete',\n 'Cannot wait for complete results in custom mutations',\n );\n}\n\nfunction newZeroContext(lc: LogContext, ivmBranch: IVMSourceBranch) {\n return new ZeroContext(\n lc,\n ivmBranch,\n () => emptyFunction,\n () => emptyFunction,\n emptyFunction,\n emptyFunction,\n emptyFunction,\n applyViewUpdates => applyViewUpdates(),\n emptyFunction,\n assertValidRunOptions,\n );\n}\n"],"names":[],"mappings":";;;;;;;;;AAkHO,MAAM,gBAEb;AAAA,EACW,WAAW;AAAA,EACX;AAAA;AAAA;AAAA;AAAA,EAIA;AAAA,EAEA;AAAA,EACA;AAAA,EAET,YAAY,IAAgB,OAAyB,QAAiB;AACpE,SAAK,MAAM,WAAW,aAAa,MAAM,WAAW,QAAQ;AAC5D,UAAM,SAAS,cAAc,KAAK;AAClC,UAAM,YAAY,OAAO;AAEzB,SAAK,SAAS;AAEd,UAAM,WAAW,iBAAiB,OAAO,QAAQ,SAAS;AAC1D,SAAK,SAAS,uBAAuB,QAAQ,QAAQ;AAErD,UAAM,cAAc;AAAA,MAClB;AAAA,MACA,OAAO;AAAA,IAAA;AAGT,SAAK,QAAQ,sBAAsB,aAAa,MAAM;AAEtD,SAAK,eAAe;AAAA,EACtB;AAAA,EAEA,IAAI,WAAqB;AACvB,WAAO,KAAK,OAAO;AAAA,EACrB;AAAA,EAEA,IAAI,aAAqB;AACvB,WAAO,KAAK,OAAO;AAAA,EACrB;AAAA,EAEA,IAAI,SAAkC;AACpC,WAAO,KAAK,OAAO,WAAW,YAAY,eAAe;AAAA,EAC3D;AAAA,EAEA,IAAI,QAA4B;AAC9B,WAAQ,KAAK,OAAgC,QAAQ,GAAG;AAAA,EAC1D;AAAA,EAEA,IACE,OACA,SACiC;AACjC,WAAO,KAAK,aAAa,IAAI,OAAO,OAAO;AAAA,EAC7C;AACF;AAEO,SAAS,cAAc,OAAqC;AACjE,QAAM,SAAS;AAAA,IACZ,MAA+B,QAAQ;AAAA,IACxC;AAAA,EAAA;AAEF,SAAO;AACT;AAEO,SAAS,sBAKd,IACA,SACA,QACA,SACqE;AACrE,SAAO,OACL,OACA,SACkB;AAClB,UAAM,KAAK,IAAI,gBAAgB,IAAI,OAAO,MAAM;AAChD,UAAM,QAAQ,IAAI,MAAM,OAAO;AAAA,EACjC;AACF;AAEA,SAAS,sBAAsB,SAAuC;AAEpE;AAAA,IACE,SAAS,SAAS;AAAA,IAClB;AAAA,EAAA;AAEJ;AAEA,SAAS,eAAe,IAAgB,WAA4B;AAClE,SAAO,IAAI;AAAA,IACT;AAAA,IACA;AAAA,IACA,MAAM;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA,sBAAoB,iBAAA;AAAA,IACpB;AAAA,IACA;AAAA,EAAA;AAEJ;"}
1
+ {"version":3,"file":"custom.js","sources":["../../../../../zero-client/src/client/custom.ts"],"sourcesContent":["import type {LogContext} from '@rocicorp/logger';\nimport type {ZeroTxData} from '../../../replicache/src/replicache-options.ts';\nimport type {WriteTransactionImpl} from '../../../replicache/src/transactions.ts';\nimport {zeroData} from '../../../replicache/src/transactions.ts';\nimport {assert} from '../../../shared/src/asserts.ts';\nimport type {ReadonlyJSONValue} from '../../../shared/src/json.ts';\nimport {must} from '../../../shared/src/must.ts';\nimport {emptyFunction} from '../../../shared/src/sentinels.ts';\nimport type {DefaultSchema} from '../../../zero-types/src/default-types.ts';\nimport type {Schema} from '../../../zero-types/src/schema.ts';\nimport {\n makeTransactionMutate,\n type TransactionMutate,\n} from '../../../zql/src/mutate/crud.ts';\nimport type {\n ClientTransaction,\n Transaction,\n} from '../../../zql/src/mutate/custom.ts';\nimport {createRunnableBuilder} from '../../../zql/src/query/create-builder.ts';\nimport {\n type HumanReadable,\n type Query,\n type RunOptions,\n} from '../../../zql/src/query/query.ts';\nimport type {SchemaQuery} from '../../../zql/src/query/schema-query.ts';\nimport type {ClientID} from '../types/client-state.ts';\nimport {ZeroContext} from './context.ts';\nimport {makeCRUDExecutor} from './crud.ts';\nimport type {IVMSourceBranch} from './ivm-branch.ts';\nimport type {WriteTransaction} from './replicache-types.ts';\n\n/**\n * The shape which a user's custom mutator definitions must conform to.\n * Supports arbitrary depth nesting of namespaces.\n */\nexport type CustomMutatorDefs = {\n // oxlint-disable-next-line no-explicit-any\n [namespaceOrKey: string]: CustomMutatorImpl<any> | CustomMutatorDefs;\n};\n\nexport type MutatorResultDetails =\n | {\n readonly type: 'success';\n }\n | {\n readonly type: 'error';\n readonly error:\n | {\n readonly type: 'app';\n readonly message: string;\n readonly details: ReadonlyJSONValue | undefined;\n }\n | {\n readonly type: 'zero';\n readonly message: string;\n };\n };\n\nexport type MutatorResultSuccessDetails = Extract<\n MutatorResultDetails,\n {type: 'success'}\n>;\nexport type MutatorResultErrorDetails = Extract<\n MutatorResultDetails,\n {type: 'error'}\n>;\n\nexport type MutatorResult = {\n client: Promise<MutatorResultDetails & {}>;\n server: Promise<MutatorResultDetails & {}>;\n} & {};\n\nexport type CustomMutatorImpl<\n S extends Schema,\n TWrappedTransaction = unknown,\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n TArgs = any,\n Context = unknown,\n> = (\n tx: Transaction<S, TWrappedTransaction>,\n // TODO: many args. See commit: 52657c2f934b4a458d628ea77e56ce92b61eb3c6 which did have many args.\n // The issue being that it will be a protocol change to support varargs.\n args: TArgs,\n ctx: Context,\n) => Promise<void>;\n\n/**\n * The shape exposed on the `Zero.mutate` instance.\n * The signature of a custom mutator takes a `transaction` as its first arg\n * but the user does not provide this arg when calling the mutator.\n *\n * This utility strips the `tx` arg from the user's custom mutator signatures.\n * Supports arbitrary depth nesting of namespaces.\n */\nexport type MakeCustomMutatorInterfaces<\n S extends Schema,\n MD extends CustomMutatorDefs,\n TContext,\n> = {\n readonly [NamespaceOrName in keyof MD]: MD[NamespaceOrName] extends (\n tx: Transaction<S>,\n ...args: infer Args\n ) => Promise<void>\n ? (...args: Args) => MutatorResult\n : MD[NamespaceOrName] extends CustomMutatorDefs\n ? MakeCustomMutatorInterfaces<S, MD[NamespaceOrName], TContext>\n : never;\n};\n\nexport type MakeCustomMutatorInterface<TSchema extends Schema, F> = F extends (\n tx: ClientTransaction<TSchema>,\n ...args: infer Args\n) => Promise<void>\n ? (...args: Args) => MutatorResult\n : never;\n\nexport class TransactionImpl<TSchema extends Schema = DefaultSchema>\n implements ClientTransaction<TSchema>\n{\n readonly location = 'client';\n readonly mutate: TransactionMutate<TSchema>;\n /**\n * @deprecated Use {@linkcode createBuilder} with `tx.run(zql.table.where(...))` instead.\n */\n readonly query: SchemaQuery<TSchema>;\n\n readonly #repTx: WriteTransaction;\n readonly #zeroContext: ZeroContext;\n\n constructor(lc: LogContext, repTx: WriteTransaction, schema: TSchema) {\n must(repTx.reason === 'initial' || repTx.reason === 'rebase');\n const txData = getZeroTxData(repTx);\n const ivmBranch = txData.ivmSources as IVMSourceBranch;\n\n this.#repTx = repTx;\n\n const executor = makeCRUDExecutor(repTx, schema, ivmBranch);\n this.mutate = makeTransactionMutate(schema, executor);\n\n const zeroContext = newZeroContext(\n lc,\n txData.ivmSources as IVMSourceBranch,\n );\n\n this.query = createRunnableBuilder(zeroContext, schema);\n\n this.#zeroContext = zeroContext;\n }\n\n get clientID(): ClientID {\n return this.#repTx.clientID;\n }\n\n get mutationID(): number {\n return this.#repTx.mutationID;\n }\n\n get reason(): 'optimistic' | 'rebase' {\n return this.#repTx.reason === 'initial' ? 'optimistic' : 'rebase';\n }\n\n get token(): string | undefined {\n return (this.#repTx as WriteTransactionImpl)[zeroData]?.token;\n }\n\n run<TTable extends keyof TSchema['tables'] & string, TReturn>(\n query: Query<TTable, TSchema, TReturn>,\n options?: RunOptions,\n ): Promise<HumanReadable<TReturn>> {\n return this.#zeroContext.run(query, options);\n }\n}\n\nexport function getZeroTxData(repTx: WriteTransaction): ZeroTxData {\n const txData = must(\n (repTx as WriteTransactionImpl)[zeroData],\n 'zero was not set on replicache internal options!',\n );\n return txData as ZeroTxData;\n}\n\nexport function makeReplicacheMutator<\n S extends Schema,\n TWrappedTransaction,\n Context,\n>(\n lc: LogContext,\n mutator: CustomMutatorImpl<S, TWrappedTransaction>,\n schema: S,\n context: Context,\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 await mutator(tx, args, context);\n };\n}\n\nfunction assertValidRunOptions(options: RunOptions | undefined): void {\n // TODO(arv): We should enforce this with the type system too.\n assert(\n options?.type !== 'complete',\n 'Cannot wait for complete results in custom mutations',\n );\n}\n\nfunction newZeroContext(lc: LogContext, ivmBranch: IVMSourceBranch) {\n return new ZeroContext(\n lc,\n ivmBranch,\n () => emptyFunction,\n () => emptyFunction,\n emptyFunction,\n emptyFunction,\n emptyFunction,\n applyViewUpdates => applyViewUpdates(),\n emptyFunction,\n assertValidRunOptions,\n );\n}\n"],"names":[],"mappings":";;;;;;;;;AAoHO,MAAM,gBAEb;AAAA,EACW,WAAW;AAAA,EACX;AAAA;AAAA;AAAA;AAAA,EAIA;AAAA,EAEA;AAAA,EACA;AAAA,EAET,YAAY,IAAgB,OAAyB,QAAiB;AACpE,SAAK,MAAM,WAAW,aAAa,MAAM,WAAW,QAAQ;AAC5D,UAAM,SAAS,cAAc,KAAK;AAClC,UAAM,YAAY,OAAO;AAEzB,SAAK,SAAS;AAEd,UAAM,WAAW,iBAAiB,OAAO,QAAQ,SAAS;AAC1D,SAAK,SAAS,sBAAsB,QAAQ,QAAQ;AAEpD,UAAM,cAAc;AAAA,MAClB;AAAA,MACA,OAAO;AAAA,IAAA;AAGT,SAAK,QAAQ,sBAAsB,aAAa,MAAM;AAEtD,SAAK,eAAe;AAAA,EACtB;AAAA,EAEA,IAAI,WAAqB;AACvB,WAAO,KAAK,OAAO;AAAA,EACrB;AAAA,EAEA,IAAI,aAAqB;AACvB,WAAO,KAAK,OAAO;AAAA,EACrB;AAAA,EAEA,IAAI,SAAkC;AACpC,WAAO,KAAK,OAAO,WAAW,YAAY,eAAe;AAAA,EAC3D;AAAA,EAEA,IAAI,QAA4B;AAC9B,WAAQ,KAAK,OAAgC,QAAQ,GAAG;AAAA,EAC1D;AAAA,EAEA,IACE,OACA,SACiC;AACjC,WAAO,KAAK,aAAa,IAAI,OAAO,OAAO;AAAA,EAC7C;AACF;AAEO,SAAS,cAAc,OAAqC;AACjE,QAAM,SAAS;AAAA,IACZ,MAA+B,QAAQ;AAAA,IACxC;AAAA,EAAA;AAEF,SAAO;AACT;AAEO,SAAS,sBAKd,IACA,SACA,QACA,SACqE;AACrE,SAAO,OACL,OACA,SACkB;AAClB,UAAM,KAAK,IAAI,gBAAgB,IAAI,OAAO,MAAM;AAChD,UAAM,QAAQ,IAAI,MAAM,OAAO;AAAA,EACjC;AACF;AAEA,SAAS,sBAAsB,SAAuC;AAEpE;AAAA,IACE,SAAS,SAAS;AAAA,IAClB;AAAA,EAAA;AAEJ;AAEA,SAAS,eAAe,IAAgB,WAA4B;AAClE,SAAO,IAAI;AAAA,IACT;AAAA,IACA;AAAA,IACA,MAAM;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA,sBAAoB,iBAAA;AAAA,IACpB;AAAA,IACA;AAAA,EAAA;AAEJ;"}
@@ -27,7 +27,7 @@ import type { MutatorProxy } from './mutator-proxy.ts';
27
27
  * using different separators ('.' for mutator definitions, '|' for custom functions) and wraps them
28
28
  * using the mutator proxy.
29
29
  */
30
- export declare function makeMutateProperty(mutators: CustomMutatorDefs, mutatorProxy: MutatorProxy, mutateObject: Record<string, unknown>, replicacheMutate: Record<string, unknown>): void;
30
+ export declare function addCustomMutatorsProperties(mutators: CustomMutatorDefs, mutatorProxy: MutatorProxy, mutateObject: Record<string, unknown>, replicacheMutate: Record<string, unknown>): void;
31
31
  /**
32
32
  * Builds the mutate type from legacy CustomMutatorDefs, handling arbitrary nesting.
33
33
  * Each node can be either a CustomMutatorImpl function or a namespace containing more mutators.
@@ -1 +1 @@
1
- {"version":3,"file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GAAG,SAAS,EACxC,CAAC,IACC,EAAE,SAAS,iBAAiB,GAC5B,CAAC,CAAC,sBAAsB,CAAC,SAAS,IAAI,GACpC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,0BAA0B,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,GAC7D,0BAA0B,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,GACtC,SAAS,CAAC,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"make-mutate-property.d.ts","sourceRoot":"","sources":["../../../../../zero-client/src/client/make-mutate-property.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,mCAAmC,CAAC;AAEjE,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,mCAAmC,CAAC;AAC9D,OAAO,EAEL,KAAK,WAAW,EACjB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAC,iBAAiB,EAAE,aAAa,EAAC,MAAM,aAAa,CAAC;AAClE,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,iBAAiB,EAC3B,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrC,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACxC,IAAI,CAkCN;AAED;;;GAGG;AACH,KAAK,0BAA0B,CAC7B,CAAC,SAAS,MAAM,EAChB,EAAE,SAAS,iBAAiB,EAC5B,CAAC,IACC;IACF,QAAQ,EAAE,CAAC,IAAI,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,SAAS,CACtC,EAAE,EAAE,WAAW,CAAC,CAAC,CAAC,EAClB,GAAG,IAAI,EAAE,MAAM,IAAI,KAChB,OAAO,CAAC,IAAI,CAAC,GACd,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,aAAa,GAChC,EAAE,CAAC,CAAC,CAAC,SAAS,iBAAiB,GAC7B,0BAA0B,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GACvC,KAAK;CACZ,CAAC;AAEF,MAAM,MAAM,sBAAsB,CAChC,CAAC,SAAS,MAAM,EAChB,EAAE,SAAS,iBAAiB,GAAG,SAAS,EACxC,CAAC,IACC,EAAE,SAAS,iBAAiB,GAC5B,CAAC,CAAC,sBAAsB,CAAC,SAAS,IAAI,GACpC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,0BAA0B,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,GAC7D,0BAA0B,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,GACtC,SAAS,CAAC,CAAC,CAAC,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { must } from "../../../shared/src/must.js";
2
2
  import { customMutatorKey } from "../../../zql/src/mutate/custom.js";
3
- function makeMutateProperty(mutators, mutatorProxy, mutateObject, replicacheMutate) {
3
+ function addCustomMutatorsProperties(mutators, mutatorProxy, mutateObject, replicacheMutate) {
4
4
  const processMutators = (mutators2, path, mutateObject2) => {
5
5
  for (const [key, mutator] of Object.entries(mutators2)) {
6
6
  path.push(key);
@@ -28,6 +28,6 @@ function makeMutateProperty(mutators, mutatorProxy, mutateObject, replicacheMuta
28
28
  processMutators(mutators, [], mutateObject);
29
29
  }
30
30
  export {
31
- makeMutateProperty
31
+ addCustomMutatorsProperties
32
32
  };
33
33
  //# sourceMappingURL=make-mutate-property.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"make-mutate-property.js","sources":["../../../../../zero-client/src/client/make-mutate-property.ts"],"sourcesContent":["import type {DeepMerge} from '../../../shared/src/deep-merge.ts';\nimport {must} from '../../../shared/src/must.ts';\nimport type {Schema} from '../../../zero-types/src/schema.ts';\nimport {\n customMutatorKey,\n type Transaction,\n} from '../../../zql/src/mutate/custom.ts';\nimport type {DBMutator} from './crud.ts';\nimport type {CustomMutatorDefs, MutatorResult} from './custom.ts';\nimport type {MutatorProxy} from './mutator-proxy.ts';\n\n/**\n * Creates and populates a mutate property object by processing mutator definitions recursively.\n *\n * This function traverses through mutator definitions (either schema-based or custom) and builds\n * a corresponding object structure where each mutator is wrapped by the mutator proxy. It handles\n * both flat mutator functions and nested mutator definition objects.\n *\n * @template S - The schema type that defines the structure of the data\n * @template C - The context type used by mutators, defaults to unknown\n *\n * @param mutators - The mutator definitions to process, can be schema-based or custom mutator definitions\n * @param mutatorProxy - The proxy object responsible for wrapping mutators with additional functionality\n * @param mutateObject - The target object to populate with wrapped mutators\n * @param replicacheMutate - The source object containing the actual mutator implementations to wrap\n *\n * @returns void - This function mutates the mutateObject parameter directly\n *\n * @remarks\n * The function recursively processes nested mutator structures, creating corresponding nested objects\n * in the mutateObject. For leaf mutators (functions or mutator definitions), it generates a full key\n * using different separators ('.' for mutator definitions, '|' for custom functions) and wraps them\n * using the mutator proxy.\n */\nexport function makeMutateProperty(\n mutators: CustomMutatorDefs,\n mutatorProxy: MutatorProxy,\n mutateObject: Record<string, unknown>,\n replicacheMutate: Record<string, unknown>,\n): void {\n const processMutators = (\n mutators: CustomMutatorDefs,\n path: string[],\n mutateObject: Record<string, unknown>,\n ) => {\n for (const [key, mutator] of Object.entries(mutators)) {\n path.push(key);\n if (typeof mutator === 'function') {\n const fullKey = customMutatorKey('|', path);\n mutateObject[key] = mutatorProxy.wrapCustomMutator(\n fullKey,\n must(replicacheMutate[fullKey]) as unknown as (\n ...args: unknown[]\n ) => MutatorResult,\n );\n } else {\n // Nested namespace - recursive build and process.\n let existing = mutateObject[key];\n if (existing === undefined) {\n existing = {};\n mutateObject[key] = existing;\n }\n processMutators(\n mutator as CustomMutatorDefs,\n path,\n existing as Record<string, unknown>,\n );\n }\n path.pop();\n }\n };\n\n processMutators(mutators, [], mutateObject);\n}\n\n/**\n * Builds the mutate type from legacy CustomMutatorDefs, handling arbitrary nesting.\n * Each node can be either a CustomMutatorImpl function or a namespace containing more mutators.\n */\ntype MakeFromMutatorDefinitions<\n S extends Schema,\n MD extends CustomMutatorDefs,\n C,\n> = {\n readonly [K in keyof MD]: MD[K] extends (\n tx: Transaction<S>,\n ...args: infer Args\n ) => Promise<void>\n ? (...args: Args) => MutatorResult\n : MD[K] extends CustomMutatorDefs\n ? MakeFromMutatorDefinitions<S, MD[K], C>\n : never;\n};\n\nexport type MakeMutatePropertyType<\n S extends Schema,\n MD extends CustomMutatorDefs | undefined,\n C,\n> = MD extends CustomMutatorDefs\n ? S['enableLegacyMutators'] extends true\n ? DeepMerge<DBMutator<S>, MakeFromMutatorDefinitions<S, MD, C>>\n : MakeFromMutatorDefinitions<S, MD, C>\n : DBMutator<S>;\n"],"names":["mutators","mutateObject"],"mappings":";;AAkCO,SAAS,mBACd,UACA,cACA,cACA,kBACM;AACN,QAAM,kBAAkB,CACtBA,WACA,MACAC,kBACG;AACH,eAAW,CAAC,KAAK,OAAO,KAAK,OAAO,QAAQD,SAAQ,GAAG;AACrD,WAAK,KAAK,GAAG;AACb,UAAI,OAAO,YAAY,YAAY;AACjC,cAAM,UAAU,iBAAiB,KAAK,IAAI;AAC1CC,sBAAa,GAAG,IAAI,aAAa;AAAA,UAC/B;AAAA,UACA,KAAK,iBAAiB,OAAO,CAAC;AAAA,QAAA;AAAA,MAIlC,OAAO;AAEL,YAAI,WAAWA,cAAa,GAAG;AAC/B,YAAI,aAAa,QAAW;AAC1B,qBAAW,CAAA;AACXA,wBAAa,GAAG,IAAI;AAAA,QACtB;AACA;AAAA,UACE;AAAA,UACA;AAAA,UACA;AAAA,QAAA;AAAA,MAEJ;AACA,WAAK,IAAA;AAAA,IACP;AAAA,EACF;AAEA,kBAAgB,UAAU,CAAA,GAAI,YAAY;AAC5C;"}
1
+ {"version":3,"file":"make-mutate-property.js","sources":["../../../../../zero-client/src/client/make-mutate-property.ts"],"sourcesContent":["import type {DeepMerge} from '../../../shared/src/deep-merge.ts';\nimport {must} from '../../../shared/src/must.ts';\nimport type {Schema} from '../../../zero-types/src/schema.ts';\nimport {\n customMutatorKey,\n type Transaction,\n} from '../../../zql/src/mutate/custom.ts';\nimport type {DBMutator} from './crud.ts';\nimport type {CustomMutatorDefs, MutatorResult} from './custom.ts';\nimport type {MutatorProxy} from './mutator-proxy.ts';\n\n/**\n * Creates and populates a mutate property object by processing mutator definitions recursively.\n *\n * This function traverses through mutator definitions (either schema-based or custom) and builds\n * a corresponding object structure where each mutator is wrapped by the mutator proxy. It handles\n * both flat mutator functions and nested mutator definition objects.\n *\n * @template S - The schema type that defines the structure of the data\n * @template C - The context type used by mutators, defaults to unknown\n *\n * @param mutators - The mutator definitions to process, can be schema-based or custom mutator definitions\n * @param mutatorProxy - The proxy object responsible for wrapping mutators with additional functionality\n * @param mutateObject - The target object to populate with wrapped mutators\n * @param replicacheMutate - The source object containing the actual mutator implementations to wrap\n *\n * @returns void - This function mutates the mutateObject parameter directly\n *\n * @remarks\n * The function recursively processes nested mutator structures, creating corresponding nested objects\n * in the mutateObject. For leaf mutators (functions or mutator definitions), it generates a full key\n * using different separators ('.' for mutator definitions, '|' for custom functions) and wraps them\n * using the mutator proxy.\n */\nexport function addCustomMutatorsProperties(\n mutators: CustomMutatorDefs,\n mutatorProxy: MutatorProxy,\n mutateObject: Record<string, unknown>,\n replicacheMutate: Record<string, unknown>,\n): void {\n const processMutators = (\n mutators: CustomMutatorDefs,\n path: string[],\n mutateObject: Record<string, unknown>,\n ) => {\n for (const [key, mutator] of Object.entries(mutators)) {\n path.push(key);\n if (typeof mutator === 'function') {\n const fullKey = customMutatorKey('|', path);\n mutateObject[key] = mutatorProxy.wrapCustomMutator(\n fullKey,\n must(replicacheMutate[fullKey]) as unknown as (\n ...args: unknown[]\n ) => MutatorResult,\n );\n } else {\n // Nested namespace - recursive build and process.\n let existing = mutateObject[key];\n if (existing === undefined) {\n existing = {};\n mutateObject[key] = existing;\n }\n processMutators(\n mutator as CustomMutatorDefs,\n path,\n existing as Record<string, unknown>,\n );\n }\n path.pop();\n }\n };\n\n processMutators(mutators, [], mutateObject);\n}\n\n/**\n * Builds the mutate type from legacy CustomMutatorDefs, handling arbitrary nesting.\n * Each node can be either a CustomMutatorImpl function or a namespace containing more mutators.\n */\ntype MakeFromMutatorDefinitions<\n S extends Schema,\n MD extends CustomMutatorDefs,\n C,\n> = {\n readonly [K in keyof MD]: MD[K] extends (\n tx: Transaction<S>,\n ...args: infer Args\n ) => Promise<void>\n ? (...args: Args) => MutatorResult\n : MD[K] extends CustomMutatorDefs\n ? MakeFromMutatorDefinitions<S, MD[K], C>\n : never;\n};\n\nexport type MakeMutatePropertyType<\n S extends Schema,\n MD extends CustomMutatorDefs | undefined,\n C,\n> = MD extends CustomMutatorDefs\n ? S['enableLegacyMutators'] extends true\n ? DeepMerge<DBMutator<S>, MakeFromMutatorDefinitions<S, MD, C>>\n : MakeFromMutatorDefinitions<S, MD, C>\n : DBMutator<S>;\n"],"names":["mutators","mutateObject"],"mappings":";;AAkCO,SAAS,4BACd,UACA,cACA,cACA,kBACM;AACN,QAAM,kBAAkB,CACtBA,WACA,MACAC,kBACG;AACH,eAAW,CAAC,KAAK,OAAO,KAAK,OAAO,QAAQD,SAAQ,GAAG;AACrD,WAAK,KAAK,GAAG;AACb,UAAI,OAAO,YAAY,YAAY;AACjC,cAAM,UAAU,iBAAiB,KAAK,IAAI;AAC1CC,sBAAa,GAAG,IAAI,aAAa;AAAA,UAC/B;AAAA,UACA,KAAK,iBAAiB,OAAO,CAAC;AAAA,QAAA;AAAA,MAIlC,OAAO;AAEL,YAAI,WAAWA,cAAa,GAAG;AAC/B,YAAI,aAAa,QAAW;AAC1B,qBAAW,CAAA;AACXA,wBAAa,GAAG,IAAI;AAAA,QACtB;AACA;AAAA,UACE;AAAA,UACA;AAAA,UACA;AAAA,QAAA;AAAA,MAEJ;AACA,WAAK,IAAA;AAAA,IACP;AAAA,EACF;AAEA,kBAAgB,UAAU,CAAA,GAAI,YAAY;AAC5C;"}
@@ -72,19 +72,18 @@ class MutatorProxy {
72
72
  if (cachedPromise) {
73
73
  return cachedPromise;
74
74
  }
75
- this.#lc.error?.(
76
- `Mutator "${name}" error on ${origin}`,
77
- args[0],
78
- error
79
- );
80
75
  if (isZeroError(error)) {
76
+ this.#lc.error?.(`Mutator "${name}" error on ${origin}`, error);
81
77
  const zeroErrorPromise = this.#makeZeroErrorResultDetails(error);
82
78
  cachedMutationPromises[origin] = zeroErrorPromise;
83
79
  return zeroErrorPromise;
84
80
  }
85
- const applicationErrorPromise = this.#makeApplicationErrorResultDetails(
86
- wrapWithApplicationError(error)
81
+ const applicationError = wrapWithApplicationError(error);
82
+ this.#lc.error?.(
83
+ `Mutator "${name}" app error on ${origin}`,
84
+ applicationError
87
85
  );
86
+ const applicationErrorPromise = this.#makeApplicationErrorResultDetails(applicationError);
88
87
  cachedMutationPromises[origin] = applicationErrorPromise;
89
88
  return applicationErrorPromise;
90
89
  };
@@ -1 +1 @@
1
- {"version":3,"file":"mutator-proxy.js","sources":["../../../../../zero-client/src/client/mutator-proxy.ts"],"sourcesContent":["import type {LogContext} from '@rocicorp/logger';\nimport {unreachable} from '../../../shared/src/asserts.ts';\nimport type {ReadonlyJSONValue} from '../../../shared/src/json.ts';\nimport type {ApplicationError} from '../../../zero-protocol/src/application-error.ts';\nimport {wrapWithApplicationError} from '../../../zero-protocol/src/application-error.ts';\nimport {ClientErrorKind} from './client-error-kind.ts';\nimport type {\n ConnectionManager,\n ConnectionManagerState,\n} from './connection-manager.ts';\nimport {ConnectionStatus} from './connection-status.ts';\nimport type {\n MutatorResult,\n MutatorResultErrorDetails,\n MutatorResultSuccessDetails,\n} from './custom.ts';\nimport {isZeroError, type ZeroError} from './error.ts';\nimport type {MutationTracker} from './mutation-tracker.ts';\n\nconst successResultDetails = {\n type: 'success',\n} as const satisfies MutatorResultSuccessDetails;\nconst successResult = () => successResultDetails;\n\ntype CachedMutationRejection = {\n readonly error: ZeroError;\n readonly promise: Promise<MutatorResultErrorDetails>;\n};\n\nexport class MutatorProxy {\n readonly #lc: LogContext;\n readonly #connectionManager: ConnectionManager;\n readonly #mutationTracker: MutationTracker;\n #mutationRejection: CachedMutationRejection | undefined;\n\n constructor(\n lc: LogContext,\n connectionManager: ConnectionManager,\n mutationTracker: MutationTracker,\n ) {\n this.#lc = lc;\n this.#connectionManager = connectionManager;\n this.#mutationTracker = mutationTracker;\n\n this.#connectionManager.subscribe(state =>\n this.#onConnectionStateChange(state),\n );\n this.#onConnectionStateChange(connectionManager.state);\n }\n\n get mutationRejectionError(): ZeroError | undefined {\n return this.#mutationRejection?.error;\n }\n\n /**\n * Called when the connection state changes.\n *\n * If the connection state is disconnected, error, or closed, the\n * mutation rejection error is set and all outstanding `.server` promises in\n * the mutation tracker are rejected with the error.\n */\n #onConnectionStateChange(state: ConnectionManagerState) {\n // we short circuit the rejection if the error is due to a missing cacheURL\n // this allows local writes to continue\n if (\n state.name === ConnectionStatus.Disconnected &&\n state.reason.kind === ClientErrorKind.NoSocketOrigin\n ) {\n this.#mutationRejection = undefined;\n return;\n }\n\n switch (state.name) {\n case ConnectionStatus.Disconnected:\n case ConnectionStatus.Error:\n case ConnectionStatus.Closed:\n this.#mutationRejection = {\n error: state.reason,\n promise: Promise.resolve(\n this.#makeZeroErrorResultDetails(state.reason),\n ),\n };\n this.#mutationTracker.rejectAllOutstandingMutations(state.reason);\n break;\n case ConnectionStatus.Connected:\n case ConnectionStatus.Connecting:\n case ConnectionStatus.NeedsAuth:\n this.#mutationRejection = undefined;\n return;\n default:\n unreachable(state);\n }\n }\n\n wrapCustomMutator<\n F extends (...args: [] | [ReadonlyJSONValue]) => {\n client: Promise<unknown>;\n server: Promise<unknown>;\n },\n >(name: string, f: F): (...args: Parameters<F>) => MutatorResult {\n return (...args) => {\n if (this.#mutationRejection) {\n return {\n client: this.#mutationRejection.promise,\n server: this.#mutationRejection.promise,\n } as const satisfies MutatorResult;\n }\n\n let result: {\n client: Promise<unknown>;\n server: Promise<unknown>;\n };\n\n const cachedMutationPromises: Partial<\n Record<'client' | 'server', Promise<MutatorResultErrorDetails>>\n > = {};\n\n const wrapErrorFor =\n (origin: 'client' | 'server') =>\n (error: unknown): Promise<MutatorResultErrorDetails> => {\n const cachedPromise = cachedMutationPromises[origin];\n if (cachedPromise) {\n return cachedPromise;\n }\n\n this.#lc.error?.(\n `Mutator \"${name}\" error on ${origin}`,\n args[0],\n error,\n );\n\n if (isZeroError(error)) {\n const zeroErrorPromise = this.#makeZeroErrorResultDetails(error);\n cachedMutationPromises[origin] = zeroErrorPromise;\n return zeroErrorPromise;\n }\n\n const applicationErrorPromise =\n this.#makeApplicationErrorResultDetails(\n wrapWithApplicationError(error),\n );\n cachedMutationPromises[origin] = applicationErrorPromise;\n return applicationErrorPromise;\n };\n\n try {\n result = f(...args);\n } catch (error) {\n const clientPromise = wrapErrorFor('client')(error);\n const serverPromise = wrapErrorFor('server')(error);\n\n return {\n client: clientPromise,\n server: serverPromise,\n } as const satisfies MutatorResult;\n }\n\n const client = this.#normalizeResultPromise(\n result.client,\n wrapErrorFor('client'),\n );\n const server = this.#normalizeResultPromise(\n result.server,\n wrapErrorFor('server'),\n );\n\n return {\n client,\n server,\n };\n };\n }\n\n #normalizeResultPromise(\n promise: Promise<unknown>,\n wrapError: (error: unknown) => Promise<MutatorResultErrorDetails>,\n ) {\n return promise.then<MutatorResultSuccessDetails, MutatorResultErrorDetails>(\n successResult,\n wrapError,\n );\n }\n\n #makeZeroErrorResultDetails(zeroError: ZeroError) {\n return Promise.resolve({\n type: 'error',\n error: {\n type: 'zero',\n message: zeroError.message,\n },\n } as const satisfies MutatorResultErrorDetails);\n }\n\n #makeApplicationErrorResultDetails(applicationError: ApplicationError) {\n return Promise.resolve({\n type: 'error',\n error: {\n type: 'app',\n message: applicationError.message,\n details: applicationError.details,\n },\n } as const satisfies MutatorResultErrorDetails);\n }\n}\n"],"names":["ConnectionStatus.Disconnected","ClientErrorKind.NoSocketOrigin","ConnectionStatus.Error","ConnectionStatus.Closed","ConnectionStatus.Connected","ConnectionStatus.Connecting","ConnectionStatus.NeedsAuth"],"mappings":";;;;;AAmBA,MAAM,uBAAuB;AAAA,EAC3B,MAAM;AACR;AACA,MAAM,gBAAgB,MAAM;AAOrB,MAAM,aAAa;AAAA,EACf;AAAA,EACA;AAAA,EACA;AAAA,EACT;AAAA,EAEA,YACE,IACA,mBACA,iBACA;AACA,SAAK,MAAM;AACX,SAAK,qBAAqB;AAC1B,SAAK,mBAAmB;AAExB,SAAK,mBAAmB;AAAA,MAAU,CAAA,UAChC,KAAK,yBAAyB,KAAK;AAAA,IAAA;AAErC,SAAK,yBAAyB,kBAAkB,KAAK;AAAA,EACvD;AAAA,EAEA,IAAI,yBAAgD;AAClD,WAAO,KAAK,oBAAoB;AAAA,EAClC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,yBAAyB,OAA+B;AAGtD,QACE,MAAM,SAASA,gBACf,MAAM,OAAO,SAASC,gBACtB;AACA,WAAK,qBAAqB;AAC1B;AAAA,IACF;AAEA,YAAQ,MAAM,MAAA;AAAA,MACZ,KAAKD;AAAAA,MACL,KAAKE;AAAAA,MACL,KAAKC;AACH,aAAK,qBAAqB;AAAA,UACxB,OAAO,MAAM;AAAA,UACb,SAAS,QAAQ;AAAA,YACf,KAAK,4BAA4B,MAAM,MAAM;AAAA,UAAA;AAAA,QAC/C;AAEF,aAAK,iBAAiB,8BAA8B,MAAM,MAAM;AAChE;AAAA,MACF,KAAKC;AAAAA,MACL,KAAKC;AAAAA,MACL,KAAKC;AACH,aAAK,qBAAqB;AAC1B;AAAA,MACF;AACE,oBAAiB;AAAA,IAAA;AAAA,EAEvB;AAAA,EAEA,kBAKE,MAAc,GAAiD;AAC/D,WAAO,IAAI,SAAS;AAClB,UAAI,KAAK,oBAAoB;AAC3B,eAAO;AAAA,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AAM;AAAA,QACN,SAAS,UAAU;AAAA,MAAA;AAAA,IACrB,CAC4C;AAAA,EAChD;AAAA,EAEA,mCAAmC,kBAAoC;AACrE,WAAO,QAAQ,QAAQ;AAAA,MACrB,MAAM;AAAA,MACN,OAAO;AAAA,QACL,MAAM;AAAA,QACN,SAAS,iBAAiB;AAAA,QAC1B,SAAS,iBAAiB;AAAA,MAAA;AAAA,IAC5B,CAC4C;AAAA,EAChD;AACF;"}
1
+ {"version":3,"file":"mutator-proxy.js","sources":["../../../../../zero-client/src/client/mutator-proxy.ts"],"sourcesContent":["import type {LogContext} from '@rocicorp/logger';\nimport {unreachable} from '../../../shared/src/asserts.ts';\nimport type {ReadonlyJSONValue} from '../../../shared/src/json.ts';\nimport type {ApplicationError} from '../../../zero-protocol/src/application-error.ts';\nimport {wrapWithApplicationError} from '../../../zero-protocol/src/application-error.ts';\nimport {ClientErrorKind} from './client-error-kind.ts';\nimport type {\n ConnectionManager,\n ConnectionManagerState,\n} from './connection-manager.ts';\nimport {ConnectionStatus} from './connection-status.ts';\nimport type {\n MutatorResult,\n MutatorResultErrorDetails,\n MutatorResultSuccessDetails,\n} from './custom.ts';\nimport {isZeroError, type ZeroError} from './error.ts';\nimport type {MutationTracker} from './mutation-tracker.ts';\n\nconst successResultDetails = {\n type: 'success',\n} as const satisfies MutatorResultSuccessDetails;\nconst successResult = () => successResultDetails;\n\ntype CachedMutationRejection = {\n readonly error: ZeroError;\n readonly promise: Promise<MutatorResultErrorDetails>;\n};\n\nexport class MutatorProxy {\n readonly #lc: LogContext;\n readonly #connectionManager: ConnectionManager;\n readonly #mutationTracker: MutationTracker;\n #mutationRejection: CachedMutationRejection | undefined;\n\n constructor(\n lc: LogContext,\n connectionManager: ConnectionManager,\n mutationTracker: MutationTracker,\n ) {\n this.#lc = lc;\n this.#connectionManager = connectionManager;\n this.#mutationTracker = mutationTracker;\n\n this.#connectionManager.subscribe(state =>\n this.#onConnectionStateChange(state),\n );\n this.#onConnectionStateChange(connectionManager.state);\n }\n\n get mutationRejectionError(): ZeroError | undefined {\n return this.#mutationRejection?.error;\n }\n\n /**\n * Called when the connection state changes.\n *\n * If the connection state is disconnected, error, or closed, the\n * mutation rejection error is set and all outstanding `.server` promises in\n * the mutation tracker are rejected with the error.\n */\n #onConnectionStateChange(state: ConnectionManagerState) {\n // we short circuit the rejection if the error is due to a missing cacheURL\n // this allows local writes to continue\n if (\n state.name === ConnectionStatus.Disconnected &&\n state.reason.kind === ClientErrorKind.NoSocketOrigin\n ) {\n this.#mutationRejection = undefined;\n return;\n }\n\n switch (state.name) {\n case ConnectionStatus.Disconnected:\n case ConnectionStatus.Error:\n case ConnectionStatus.Closed:\n this.#mutationRejection = {\n error: state.reason,\n promise: Promise.resolve(\n this.#makeZeroErrorResultDetails(state.reason),\n ),\n };\n this.#mutationTracker.rejectAllOutstandingMutations(state.reason);\n break;\n case ConnectionStatus.Connected:\n case ConnectionStatus.Connecting:\n case ConnectionStatus.NeedsAuth:\n this.#mutationRejection = undefined;\n return;\n default:\n unreachable(state);\n }\n }\n\n wrapCustomMutator<\n F extends (...args: [] | [ReadonlyJSONValue]) => {\n client: Promise<unknown>;\n server: Promise<unknown>;\n },\n >(name: string, f: F): (...args: Parameters<F>) => MutatorResult {\n return (...args) => {\n if (this.#mutationRejection) {\n return {\n client: this.#mutationRejection.promise,\n server: this.#mutationRejection.promise,\n } as const satisfies MutatorResult;\n }\n\n let result: {\n client: Promise<unknown>;\n server: Promise<unknown>;\n };\n\n const cachedMutationPromises: Partial<\n Record<'client' | 'server', Promise<MutatorResultErrorDetails>>\n > = {};\n\n const wrapErrorFor =\n (origin: 'client' | 'server') =>\n (error: unknown): Promise<MutatorResultErrorDetails> => {\n const cachedPromise = cachedMutationPromises[origin];\n if (cachedPromise) {\n return cachedPromise;\n }\n\n if (isZeroError(error)) {\n this.#lc.error?.(`Mutator \"${name}\" error on ${origin}`, error);\n\n const zeroErrorPromise = this.#makeZeroErrorResultDetails(error);\n cachedMutationPromises[origin] = zeroErrorPromise;\n return zeroErrorPromise;\n }\n\n const applicationError = wrapWithApplicationError(error);\n this.#lc.error?.(\n `Mutator \"${name}\" app error on ${origin}`,\n applicationError,\n );\n\n const applicationErrorPromise =\n this.#makeApplicationErrorResultDetails(applicationError);\n cachedMutationPromises[origin] = applicationErrorPromise;\n return applicationErrorPromise;\n };\n\n try {\n result = f(...args);\n } catch (error) {\n const clientPromise = wrapErrorFor('client')(error);\n const serverPromise = wrapErrorFor('server')(error);\n\n return {\n client: clientPromise,\n server: serverPromise,\n } as const satisfies MutatorResult;\n }\n\n const client = this.#normalizeResultPromise(\n result.client,\n wrapErrorFor('client'),\n );\n const server = this.#normalizeResultPromise(\n result.server,\n wrapErrorFor('server'),\n );\n\n return {\n client,\n server,\n };\n };\n }\n\n #normalizeResultPromise(\n promise: Promise<unknown>,\n wrapError: (error: unknown) => Promise<MutatorResultErrorDetails>,\n ) {\n return promise.then<MutatorResultSuccessDetails, MutatorResultErrorDetails>(\n successResult,\n wrapError,\n );\n }\n\n #makeZeroErrorResultDetails(zeroError: ZeroError) {\n return Promise.resolve({\n type: 'error',\n error: {\n type: 'zero',\n message: zeroError.message,\n },\n } as const satisfies MutatorResultErrorDetails);\n }\n\n #makeApplicationErrorResultDetails(applicationError: ApplicationError) {\n return Promise.resolve({\n type: 'error',\n error: {\n type: 'app',\n message: applicationError.message,\n details: applicationError.details,\n },\n } as const satisfies MutatorResultErrorDetails);\n }\n}\n"],"names":["ConnectionStatus.Disconnected","ClientErrorKind.NoSocketOrigin","ConnectionStatus.Error","ConnectionStatus.Closed","ConnectionStatus.Connected","ConnectionStatus.Connecting","ConnectionStatus.NeedsAuth"],"mappings":";;;;;AAmBA,MAAM,uBAAuB;AAAA,EAC3B,MAAM;AACR;AACA,MAAM,gBAAgB,MAAM;AAOrB,MAAM,aAAa;AAAA,EACf;AAAA,EACA;AAAA,EACA;AAAA,EACT;AAAA,EAEA,YACE,IACA,mBACA,iBACA;AACA,SAAK,MAAM;AACX,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 +1,4 @@
1
- const version = "0.25.0-canary.21";
1
+ const version = "0.25.0-canary.24";
2
2
  export {
3
3
  version
4
4
  };
@@ -74,6 +74,7 @@ export interface ReplicacheInternalAPI {
74
74
  lastMutationID(): number;
75
75
  }
76
76
  export declare function getInternalReplicacheImplForTesting(z: object): ReplicacheImpl<MutatorDefs>;
77
+ export type ZeroMutate<S extends Schema, MD extends CustomMutatorDefs | undefined, C> = MakeMutatePropertyType<S, MD, C> & ((mr: MutateRequest<any, S, C, any>) => MutatorResult);
77
78
  export declare class Zero<const S extends Schema = DefaultSchema, MD extends CustomMutatorDefs | undefined = undefined, C = DefaultContext> {
78
79
  #private;
79
80
  readonly version: string;
@@ -208,13 +209,23 @@ export declare class Zero<const S extends Schema = DefaultSchema, MD extends Cus
208
209
  get clientID(): ClientID;
209
210
  get clientGroupID(): Promise<ClientGroupID>;
210
211
  /**
211
- * Provides simple "CRUD" mutations for the tables in the schema.
212
+ * Use to execute mutations. The primary flow is to call
213
+ * `zero.mutate(mutationRequest)` with your registered custom mutators:
212
214
  *
213
- * Each table has `create`, `set`, `update`, and `delete` methods.
215
+ * ```ts
216
+ * await zero.mutate(
217
+ * mutators.myMutator({id: '1', title: 'First issue'}),
218
+ * );
219
+ * ```
220
+ *
221
+ * When `schema.enableLegacyMutators` is true, legacy conveniences are added:
222
+ * - Table-scoped CRUD helpers, e.g. `zero.mutate.issue.create` / `set` / `update` / `delete`
223
+ * - Your custom mutators exposed directly on `zero.mutate`
214
224
  *
215
225
  * ```ts
216
226
  * await zero.mutate.issue.create({id: '1', title: 'First issue', priority: 'high'});
217
227
  * await zero.mutate.comment.create({id: '1', text: 'First comment', issueID: '1'});
228
+ * await zero.mutate.myMutator({id: '1', title: 'First issue'});
218
229
  * ```
219
230
  *
220
231
  * The `update` methods support partials. Unspecified or `undefined` fields
@@ -225,7 +236,7 @@ export declare class Zero<const S extends Schema = DefaultSchema, MD extends Cus
225
236
  * await zero.mutate.issue.update({id: '1', title: 'Updated title'});
226
237
  * ```
227
238
  */
228
- readonly mutate: MakeMutatePropertyType<S, MD, C> & ((mr: MutateRequest<any, S, C, any>) => MutatorResult);
239
+ readonly mutate: ZeroMutate<S, MD, C>;
229
240
  /**
230
241
  * Provides a way to batch multiple CRUD mutations together:
231
242
  *
@@ -1 +1 @@
1
- {"version":3,"file":"zero.d.ts","sourceRoot":"","sources":["../../../../../zero-client/src/client/zero.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAgB,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAC,KAAK,QAAQ,EAAW,MAAM,oBAAoB,CAAC;AAE3D,OAAO,EACL,cAAc,EAEf,MAAM,iCAAiC,CAAC;AAEzC,OAAO,KAAK,EAAC,MAAM,EAAe,MAAM,mCAAmC,CAAC;AAC5E,OAAO,KAAK,EAAC,MAAM,EAAe,MAAM,mCAAmC,CAAC;AAE5E,OAAO,KAAK,EACV,aAAa,EACb,QAAQ,EACT,MAAM,qCAAqC,CAAC;AAG7C,OAAO,KAAK,EACV,WAAW,EAEZ,MAAM,kCAAkC,CAAC;AAS1C,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,6BAA6B,CAAC;AAMnE,OAAO,EAAC,YAAY,EAAC,MAAM,qCAAqC,CAAC;AAGjE,OAAO,EAAC,KAAK,YAAY,EAAC,MAAM,6CAA6C,CAAC;AAG9E,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,8CAA8C,CAAC;AA6BpF,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,6CAA6C,CAAC;AAElF,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,uCAAuC,CAAC;AAO3E,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACd,MAAM,0CAA0C,CAAC;AAClD,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,mCAAmC,CAAC;AAC9D,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAK9D,OAAO,KAAK,EAEV,aAAa,EAC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