better-supabase 0.18.0 → 0.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/cli/{add-B1S3yK4L.js → add-C5kLXuqn.js} +9 -9
  2. package/dist/cli/add-CFKvvXlK.js +1 -0
  3. package/dist/cli/{add-D7YIXslp.js → add-CTtj1dfh.js} +2 -2
  4. package/dist/cli/{backfill-BwkyNhlC.js → backfill-C-b6eH98.js} +1 -1
  5. package/dist/cli/bin.js +1 -1
  6. package/dist/cli/{blocks-DDm1Zc2S.js → blocks-CT8-TBdW.js} +1 -1
  7. package/dist/cli/{blocks-CBqENu3C.js → blocks-zpu__C1Y.js} +1 -1
  8. package/dist/cli/{cache-DE2IH1-C.js → cache-BxohmNou.js} +1 -1
  9. package/dist/cli/{codemod-OHKhVV-v.js → codemod-BVo3sdx7.js} +2 -2
  10. package/dist/cli/{content-mapper-CaygHH_k.js → content-mapper-D54wumPS.js} +2 -2
  11. package/dist/cli/{doctor-D_nrsd9E.js → doctor-DBxc5aud.js} +14 -14
  12. package/dist/cli/{gen-D7gMEwvg.js → gen--IBq-J4M.js} +11 -11
  13. package/dist/cli/index.d.ts +1 -1
  14. package/dist/cli/index.js +6 -6
  15. package/dist/cli/{init-ch-HWJyp.js → init-Dxvlzka4.js} +5 -5
  16. package/dist/cli/{legacy-prefix-DkTA3Rhx.js → legacy-prefix-R7UChFFl.js} +18 -5
  17. package/dist/cli/{live-B38ePuRS.js → live-C-0OdLKE.js} +2 -2
  18. package/dist/cli/{mcp-P9RP2SJ3.js → mcp-3q5RDvYJ.js} +2 -2
  19. package/dist/cli/{metadata-BTihErEc.js → metadata-Dvc6U3bk.js} +3 -3
  20. package/dist/cli/{migration-safety-DYo1vVWC.js → migration-safety-DYgarZxP.js} +1 -1
  21. package/dist/cli/{migrations-BoIyGczt.js → migrations-Cwh5VvUC.js} +1 -1
  22. package/dist/cli/{module-migration-DXvo0EqU.js → module-migration-CXtSwDLu.js} +2 -2
  23. package/dist/cli/powersync-BAE2dlPJ.js +1 -0
  24. package/dist/cli/{powersync-D-0yV_L_.js → powersync-BCDuGn5p.js} +2 -2
  25. package/dist/cli/{print-CRon4lXf.js → print-Dpfa_--H.js} +2 -2
  26. package/dist/cli/{remove-D89s99ha.js → remove-DpAwgO8A.js} +5 -5
  27. package/dist/cli/{render-BJF9ytUi.js → render-D9c5ynjR.js} +3 -3
  28. package/dist/cli/{run-jeplMBOK.js → run-CuzSU8Sk.js} +8 -8
  29. package/dist/cli/{run-x9ZY4Tm0.js → run-Q5V5Kle1.js} +21 -21
  30. package/dist/cli/{shared-B38Chjgd.js → shared-BNScv93m.js} +1 -1
  31. package/dist/cli/{snapshot-BXmU3IXN.js → snapshot-k4R6vT20.js} +2 -2
  32. package/dist/cli/{source-irttnsEb.js → source-MMQKgaIx.js} +1 -1
  33. package/dist/cli/{spec-CDxfokey.js → spec-CCpPVw_T.js} +2 -2
  34. package/dist/cli/{spec-DzD5wMVF.js → spec-CqANRfuu.js} +1 -1
  35. package/dist/cli/{sql-layout-D8QrNvt4.js → sql-layout-AByPAQXl.js} +2 -2
  36. package/dist/cli/{sync-s1iKFIos.js → sync-DYQVml8j.js} +3 -3
  37. package/dist/cli/{upgrade-B4FPlK-_.js → upgrade-DHcIHeRM.js} +5 -5
  38. package/dist/cli/{upgrade-CluxP3JJ.js → upgrade-f-3Nl6lO.js} +2 -2
  39. package/dist/cli/{version-TgFM8sOd.js → version-DzroJkIT.js} +1 -1
  40. package/dist/{field-errors-DucQdLl7.d.ts → field-errors-DkAemDoc.d.ts} +1 -1
  41. package/dist/{index-XAyzdLns.d.ts → index-DTbJAsrT.d.ts} +2 -2
  42. package/dist/{index-BH3NYExp.d.ts → index-DmbCyl6Z.d.ts} +7 -3
  43. package/dist/mapper/bin.js +5 -5
  44. package/dist/next/index.d.ts +1 -1
  45. package/dist/otel/index.js +4 -4
  46. package/dist/react/index.d.ts +3 -3
  47. package/dist/react/index.js +1 -1
  48. package/dist/react/server.d.ts +3 -3
  49. package/dist/react/server.js +1 -1
  50. package/dist/{react-CZUZYn9E.js → react-zBTxLsV6.js} +1 -1
  51. package/dist/realtime/index.d.ts +1 -1
  52. package/dist/realtime/index.js +1 -1
  53. package/dist/{relay-gKvKJ3xf.js → relay-CIKcAVjf.js} +61 -21
  54. package/dist/server/index.d.ts +3 -2
  55. package/dist/server/index.js +11 -4
  56. package/dist/solid/index.d.ts +1 -1
  57. package/dist/svelte/index.d.ts +1 -1
  58. package/dist/vue/index.d.ts +1 -1
  59. package/package.json +1 -1
  60. package/dist/cli/add-BQPJnapO.js +0 -1
  61. package/dist/cli/powersync-DXVsKkAu.js +0 -1
@@ -1,21 +1,21 @@
1
1
  import { a as list, p as commandMeta, r as defineCliCommand } from "./command-BWEEXmtz.js";
2
2
  import { i as plain } from "./style-Bm2X5JrN.js";
3
- import { t as VERSION } from "./version-TgFM8sOd.js";
3
+ import { t as VERSION } from "./version-DzroJkIT.js";
4
4
  import { a as parseNames, n as CliError } from "./errors-BTe6A15O.js";
5
5
  import { r as readIfExists, t as display } from "./io-DH1kcmmP.js";
6
- import { t as loadSnapshot } from "./snapshot-BXmU3IXN.js";
6
+ import { t as loadSnapshot } from "./snapshot-k4R6vT20.js";
7
7
  import { t as isRecord } from "./guards-CUlDNYZs.js";
8
- import { a as toCatalog } from "./source-irttnsEb.js";
9
- import { n as dataMigration } from "./migrations-BoIyGczt.js";
8
+ import { a as toCatalog } from "./source-MMQKgaIx.js";
9
+ import { n as dataMigration } from "./migrations-Cwh5VvUC.js";
10
10
  import { a as findConfig, f as INTEGRATIONS, s as loadConfig } from "./config-BJSqMi04.js";
11
11
  import { i as changeLines, n as PLAN_ARGS, r as applyPlan, u as planResult } from "./files-CX71yBm8.js";
12
- import { a as wiringFiles, d as libEntry, f as needsLib, i as wiringChecklist, l as importFrom, n as latestMigrationVersion, o as wiringFor, p as resolveIntegrations, s as TEMPLATES, u as isIntegration } from "./migration-safety-DYo1vVWC.js";
12
+ import { a as wiringFiles, d as libEntry, f as needsLib, i as wiringChecklist, l as importFrom, n as latestMigrationVersion, o as wiringFor, p as resolveIntegrations, s as TEMPLATES, u as isIntegration } from "./migration-safety-DYgarZxP.js";
13
13
  import { n as installCommand, t as detectProject } from "./detect-D9JaAX20.js";
14
14
  import { d as setBlockInJson, f as setPathInConfig, h as setPresetInJson, m as setPresetInConfig, n as addBlocksToJson, p as setPathInJson, r as addBlocksToWiring, t as addBlocksToConfig, u as setBlockInConfig } from "./config-edit-CrWfk8s3.js";
15
- import { t as syncModules } from "./sync-s1iKFIos.js";
16
- import { t as addModules } from "./add-D7YIXslp.js";
17
- import { n as ident } from "./live-B38ePuRS.js";
18
- import { t as blockNames } from "./blocks-DDm1Zc2S.js";
15
+ import { t as syncModules } from "./sync-DYQVml8j.js";
16
+ import { t as addModules } from "./add-CTtj1dfh.js";
17
+ import { n as ident } from "./live-C-0OdLKE.js";
18
+ import { t as blockNames } from "./blocks-CT8-TBdW.js";
19
19
  import { i as sourceArgs, n as SOURCE_ARGS } from "./source-args-DlckPVje.js";
20
20
  import { existsSync } from "node:fs";
21
21
  import { dirname, join, posix, resolve } from "node:path";
@@ -0,0 +1 @@
1
+ export { t as addCommand } from "./add-C5kLXuqn.js";
@@ -1,8 +1,8 @@
1
1
  import { n as CliError } from "./errors-BTe6A15O.js";
2
- import { c as layoutFor, g as providerLabel, l as providerOwnsMemberships, o as MEMBERSHIP_CLAIM_MODULES } from "./migrations-BoIyGczt.js";
2
+ import { c as layoutFor, g as providerLabel, l as providerOwnsMemberships, o as MEMBERSHIP_CLAIM_MODULES } from "./migrations-Cwh5VvUC.js";
3
3
  import { r as applyPlan } from "./files-CX71yBm8.js";
4
4
  import { n as addBlocksToJson, s as keyText, t as addBlocksToConfig } from "./config-edit-CrWfk8s3.js";
5
- import { a as write, i as unlistedModuleFiles, r as nextStep } from "./sync-s1iKFIos.js";
5
+ import { a as write, i as unlistedModuleFiles, r as nextStep } from "./sync-DYQVml8j.js";
6
6
  import { basename, dirname } from "node:path";
7
7
  import { readFile } from "node:fs/promises";
8
8
  import { SQL_MODULES, resolveBlocks } from "better-supabase/sql";
@@ -3,7 +3,7 @@ import { n as CliError, r as errorText } from "./errors-BTe6A15O.js";
3
3
  import { i as isLocalDatabaseUrl, r as databaseHost } from "./agent-CbuPvI2x.js";
4
4
  import { l as stdinDatabaseUrl, n as databaseUrl } from "./config-BJSqMi04.js";
5
5
  import { t as connect } from "./db-CQCLx7cx.js";
6
- import { n as ident } from "./live-B38ePuRS.js";
6
+ import { n as ident } from "./live-C-0OdLKE.js";
7
7
  import { r as STACK_ARG, t as DB_URL_STDIN_ARG } from "./source-args-DlckPVje.js";
8
8
  //#region src/cli/commands/backfill.ts
9
9
  const DEFAULT_BATCH = 1e3;
package/dist/cli/bin.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { i as run } from "./run-x9ZY4Tm0.js";
2
+ import { i as run } from "./run-Q5V5Kle1.js";
3
3
  import { t as colorEnabled } from "./style-Bm2X5JrN.js";
4
4
  import { existsSync } from "node:fs";
5
5
  import { basename } from "node:path";
@@ -1,7 +1,7 @@
1
1
  import { p as commandMeta, r as defineCliCommand } from "./command-BWEEXmtz.js";
2
2
  import { n as CliError } from "./errors-BTe6A15O.js";
3
3
  import { t as SQL_ARGS } from "./args-UEwg0l-N.js";
4
- import { n as listModules, t as printModule } from "./print-CRon4lXf.js";
4
+ import { n as listModules, t as printModule } from "./print-Dpfa_--H.js";
5
5
  import { t as decodePresetInput } from "./preset-BwmIfFnh.js";
6
6
  import { BLOCK_CATEGORIES } from "better-supabase/blocks";
7
7
  import { PRESET_CATALOG, PRESET_NAMES, glueCommand } from "better-supabase/preset";
@@ -1 +1 @@
1
- export { n as blocksListCommand, r as blocksSearchCommand, i as blocksViewCommand } from "./blocks-DDm1Zc2S.js";
1
+ export { n as blocksListCommand, r as blocksSearchCommand, i as blocksViewCommand } from "./blocks-CT8-TBdW.js";
@@ -1,4 +1,4 @@
1
- import { t as VERSION } from "./version-TgFM8sOd.js";
1
+ import { t as VERSION } from "./version-DzroJkIT.js";
2
2
  import { dirname, resolve } from "node:path";
3
3
  import { createHash } from "node:crypto";
4
4
  import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
@@ -4,9 +4,9 @@ import { n as CliError } from "./errors-BTe6A15O.js";
4
4
  import { t as migrateCliCall } from "./moved-DVwgE8lV.js";
5
5
  import { t as isRecord$1 } from "./guards-CUlDNYZs.js";
6
6
  import { a as changedFiles, i as changeLines, r as applyPlan, u as planResult } from "./files-CX71yBm8.js";
7
- import { i as schemasDirOf, n as migrationsDir, o as writtenByBlocks } from "./sql-layout-D8QrNvt4.js";
7
+ import { i as schemasDirOf, n as migrationsDir, o as writtenByBlocks } from "./sql-layout-AByPAQXl.js";
8
8
  import { a as configObject, c as mask, f as setPathInConfig, g as skipSpace, h as setPresetInJson, i as closingIndex, l as properties, m as setPresetInConfig, o as indentAt, p as setPathInJson, t as addBlocksToConfig, v as codeRanges } from "./config-edit-CrWfk8s3.js";
9
- import { i as legacyPrefixNames, n as LEGACY_PREFIXES, t as LEGACY_CLAIMS } from "./legacy-prefix-DkTA3Rhx.js";
9
+ import { i as legacyPrefixNames, n as LEGACY_PREFIXES, t as LEGACY_CLAIMS } from "./legacy-prefix-R7UChFFl.js";
10
10
  import { a as REVIEW_0_15, c as renameSubpaths, r as PLUGIN_IMPORT_RENAMES, s as SUBPATH_RENAMES_0_15, t as BLOCK_EXPORT_RENAMES } from "./codemod-block-renames-BuSaTE_G.js";
11
11
  import { a as RECORD_BINDING_RENAMES, n as groupConfigJson, r as groupConfigSource, t as cutRange } from "./config-group-C8tjut39.js";
12
12
  import { existsSync } from "node:fs";
@@ -1,6 +1,6 @@
1
1
  import { r as readIfExists } from "./io-DH1kcmmP.js";
2
- import { t as CACHE_DIR } from "./cache-DE2IH1-C.js";
3
- import { x as installedVersion } from "./snapshot-BXmU3IXN.js";
2
+ import { t as CACHE_DIR } from "./cache-BxohmNou.js";
3
+ import { x as installedVersion } from "./snapshot-k4R6vT20.js";
4
4
  import { t as i } from "./jsonc-D5Fu67jw.js";
5
5
  import { resolve } from "node:path";
6
6
  import { createHash } from "node:crypto";
@@ -1,36 +1,36 @@
1
1
  import { a as list, p as commandMeta, r as defineCliCommand } from "./command-BWEEXmtz.js";
2
2
  import { i as plain } from "./style-Bm2X5JrN.js";
3
- import { t as VERSION } from "./version-TgFM8sOd.js";
3
+ import { t as VERSION } from "./version-DzroJkIT.js";
4
4
  import { n as CliError, r as errorText } from "./errors-BTe6A15O.js";
5
5
  import { i as isLocalDatabaseUrl, r as databaseHost } from "./agent-CbuPvI2x.js";
6
6
  import { a as sameText, t as display } from "./io-DH1kcmmP.js";
7
- import { t as CACHE_DIR } from "./cache-DE2IH1-C.js";
7
+ import { t as CACHE_DIR } from "./cache-BxohmNou.js";
8
8
  import { t as byCodePoint } from "./compare-BmIWVEui.js";
9
- import { C as satisfies, S as peerVersions, c as isSqliteLiteDriver, n as managementTarget, o as snapshotFile, r as openSource, s as liteDriverOf, t as loadSnapshot, u as MetadataRejectedError } from "./snapshot-BXmU3IXN.js";
10
- import { d as configFor, r as renderFiles, u as notNullTag } from "./render-BJF9ytUi.js";
9
+ import { C as satisfies, S as peerVersions, c as isSqliteLiteDriver, n as managementTarget, o as snapshotFile, r as openSource, s as liteDriverOf, t as loadSnapshot, u as MetadataRejectedError } from "./snapshot-k4R6vT20.js";
10
+ import { d as configFor, r as renderFiles, u as notNullTag } from "./render-D9c5ynjR.js";
11
11
  import { t as isRecord } from "./guards-CUlDNYZs.js";
12
- import { i as request } from "./source-irttnsEb.js";
13
- import { g as providerLabel, u as compiledReadSets } from "./migrations-BoIyGczt.js";
12
+ import { i as request } from "./source-MMQKgaIx.js";
13
+ import { g as providerLabel, u as compiledReadSets } from "./migrations-Cwh5VvUC.js";
14
14
  import { l as stdinDatabaseUrl, n as databaseUrl } from "./config-BJSqMi04.js";
15
15
  import { a as findRepoRoot, c as httpHooks, d as readSupabaseToml, f as schemaPaths, h as tomlGet, i as diffEngine, l as migrationCommand, n as declarativeSchemasDir, p as sqlWorkflow, u as pgFunctionHooks } from "./supabase-toml-CncmQbO0.js";
16
16
  import { t as PROCESS_ENV } from "./env-DMgjB_4y.js";
17
17
  import { n as readStackStatus } from "./stack-status-B_Ipd_-z.js";
18
18
  import { t as connect } from "./db-CQCLx7cx.js";
19
- import { a as hasContentMapper, c as supportsContentMappers, i as contentMapperSetup$1, n as TSCONFIG_SNIPPET, o as needsRunExternalCode, t as RUN_EXTERNAL_CODE } from "./content-mapper-CaygHH_k.js";
19
+ import { a as hasContentMapper, c as supportsContentMappers, i as contentMapperSetup$1, n as TSCONFIG_SNIPPET, o as needsRunExternalCode, t as RUN_EXTERNAL_CODE } from "./content-mapper-D54wumPS.js";
20
20
  import { c as insideRoot, i as changeLines, r as applyPlan } from "./files-CX71yBm8.js";
21
- import { C as splinterTables, S as advisorRule, _ as withoutStrings, a as METADATA_GAPS_TEXT, b as appTablesOf, c as accessModule, d as RLS_RULES, f as appliesTo, g as policyHelpers, h as functionObject, l as entitlementsModule, m as functionBody, p as escape$2, s as AUTHORIZATION_RULES, u as COMMANDS$2, v as BLOCK_PREFIX, x as appViewsOf, y as blockTargets } from "./run-jeplMBOK.js";
22
- import { n as migrationsDir, r as moduleLayoutFor, t as blockDeclaredTables } from "./sql-layout-D8QrNvt4.js";
23
- import { a as permissionCatalogKeys, i as lineOf, l as tableObject, n as exposed, o as policyObject, r as exposedSchemas, s as qualified, t as catalogOf, u as workflowOf } from "./shared-B38Chjgd.js";
24
- import { i as migrationHolds, o as migrationModules, r as latestMigration, t as MODULES_SUFFIX } from "./module-migration-DXvo0EqU.js";
25
- import { o as wiringFor, r as configInstances, t as MIGRATION_SAFETY_RULES } from "./migration-safety-DYo1vVWC.js";
21
+ import { C as splinterTables, S as advisorRule, _ as withoutStrings, a as METADATA_GAPS_TEXT, b as appTablesOf, c as accessModule, d as RLS_RULES, f as appliesTo, g as policyHelpers, h as functionObject, l as entitlementsModule, m as functionBody, p as escape$2, s as AUTHORIZATION_RULES, u as COMMANDS$2, v as BLOCK_PREFIX, x as appViewsOf, y as blockTargets } from "./run-CuzSU8Sk.js";
22
+ import { n as migrationsDir, r as moduleLayoutFor, t as blockDeclaredTables } from "./sql-layout-AByPAQXl.js";
23
+ import { a as permissionCatalogKeys, i as lineOf, l as tableObject, n as exposed, o as policyObject, r as exposedSchemas, s as qualified, t as catalogOf, u as workflowOf } from "./shared-BNScv93m.js";
24
+ import { i as migrationHolds, o as migrationModules, r as latestMigration, t as MODULES_SUFFIX } from "./module-migration-CXtSwDLu.js";
25
+ import { o as wiringFor, r as configInstances, t as MIGRATION_SAFETY_RULES } from "./migration-safety-DYgarZxP.js";
26
26
  import { t as orphanedBlockFiles } from "./orphans-BAboqyVM.js";
27
- import { i as reservedRoles, n as ident$1, r as literal$1, t as LIVE_RULES } from "./live-B38ePuRS.js";
27
+ import { i as reservedRoles, n as ident$1, r as literal$1, t as LIVE_RULES } from "./live-C-0OdLKE.js";
28
28
  import { a as sourceFlags, n as SOURCE_ARGS } from "./source-args-DlckPVje.js";
29
29
  import { i as PLUGIN_SUBPATH_RENAMES, n as BLOCK_SUBPATH_RENAMES, o as SPEC_SUBPATH_RENAMES, t as BLOCK_EXPORT_RENAMES } from "./codemod-block-renames-BuSaTE_G.js";
30
30
  import { n as PLATFORM_SCHEMAS } from "./in-stack-diff-DQTW53Vf.js";
31
31
  import { i as staleVariables, r as stackEnvValues, t as PREFIX_NAMES } from "./stack-env-6hS-WEmh.js";
32
32
  import { a as readSharedMemory, n as listStacks, t as branchName } from "./stacks-BYlQ96WS.js";
33
- import { i as refuseWithMetadata, r as readMetadataSnapshot } from "./metadata-BTihErEc.js";
33
+ import { i as refuseWithMetadata, r as readMetadataSnapshot } from "./metadata-Dvc6U3bk.js";
34
34
  import { existsSync } from "node:fs";
35
35
  import { dirname, resolve } from "node:path";
36
36
  import { createHash } from "node:crypto";
@@ -1,22 +1,22 @@
1
1
  import { a as list, p as commandMeta, r as defineCliCommand } from "./command-BWEEXmtz.js";
2
2
  import { i as plain } from "./style-Bm2X5JrN.js";
3
3
  import { a as parseNames, i as failedResult, n as CliError } from "./errors-BTe6A15O.js";
4
- import { u as catalogFingerprint } from "./cache-DE2IH1-C.js";
5
- import { a as serializeSnapshot, g as serializeGenerator, h as restrictSchemas, o as snapshotFile, r as openSource, t as loadSnapshot } from "./snapshot-BXmU3IXN.js";
6
- import { n as dataMigration } from "./migrations-BoIyGczt.js";
4
+ import { u as catalogFingerprint } from "./cache-BxohmNou.js";
5
+ import { a as serializeSnapshot, g as serializeGenerator, h as restrictSchemas, o as snapshotFile, r as openSource, t as loadSnapshot } from "./snapshot-k4R6vT20.js";
6
+ import { n as dataMigration } from "./migrations-Cwh5VvUC.js";
7
7
  import { d as GEN_TASKS, p as isGenTask } from "./config-BJSqMi04.js";
8
8
  import { c as insideRoot, r as applyPlan, u as planResult } from "./files-CX71yBm8.js";
9
- import { n as runGen } from "./run-jeplMBOK.js";
10
- import { t as syncModules } from "./sync-s1iKFIos.js";
11
- import { t as addModules } from "./add-D7YIXslp.js";
12
- import { n as listModules, t as printModule } from "./print-CRon4lXf.js";
9
+ import { n as runGen } from "./run-CuzSU8Sk.js";
10
+ import { t as syncModules } from "./sync-DYQVml8j.js";
11
+ import { t as addModules } from "./add-CTtj1dfh.js";
12
+ import { n as listModules, t as printModule } from "./print-Dpfa_--H.js";
13
13
  import { a as sourceFlags, i as sourceArgs, n as SOURCE_ARGS } from "./source-args-DlckPVje.js";
14
- import { a as runMetadataGen, n as checkMetadataFlags, t as EMITS } from "./metadata-BTihErEc.js";
14
+ import { a as runMetadataGen, n as checkMetadataFlags, t as EMITS } from "./metadata-Dvc6U3bk.js";
15
15
  import { a as runEnv } from "./env-BCgVZkcb.js";
16
- import { c as watchLoop, o as parseInterval, r as specOptionsFromConfig, s as stampFiles, t as runSpec } from "./spec-CDxfokey.js";
17
- import { n as runPowerSync } from "./powersync-D-0yV_L_.js";
16
+ import { c as watchLoop, o as parseInterval, r as specOptionsFromConfig, s as stampFiles, t as runSpec } from "./spec-CCpPVw_T.js";
17
+ import { n as runPowerSync } from "./powersync-BCDuGn5p.js";
18
18
  import { t as runSeed } from "./seed-D9mt8bnW.js";
19
- import { t as upgrade } from "./upgrade-B4FPlK-_.js";
19
+ import { t as upgrade } from "./upgrade-DHcIHeRM.js";
20
20
  import { existsSync } from "node:fs";
21
21
  import { resolve } from "node:path";
22
22
  //#region src/cli/commands/sql.ts
@@ -798,6 +798,6 @@ export declare function emitModule(model: Model, options: EmitOptions): string;
798
798
  export declare function loadConfig(cwd: string, explicit?: string, environment?: string, path?: string | undefined): Promise<ResolvedConfig>;
799
799
  //#endregion
800
800
  //#region src/cli/version.d.ts
801
- export declare const VERSION = "0.18.0";
801
+ export declare const VERSION = "0.18.1";
802
802
  //#endregion
803
803
  export type { Catalog, CatalogCheck, CatalogColumn, CatalogColumnGrant, CatalogEnum, CatalogForeignKey, CatalogFunction, CatalogFunctionArg, CatalogGrant, CatalogIndex, CatalogPolicy, CatalogTable, CatalogTrigger, CatalogUnique, Choice, Cli, CliArgs, CliCommand, CliCommandDef, CliContext, CliEnv, CliErrorCode, CliErrorOptions, CliIo, CliLog, CliProblem, CliProblemExtensions, CommandResult, CreateCliOptions, ExitCode, ExtrasFunction, ExtrasHook, ExtrasHookFunction, ExtrasTable, ForeignKeyAction, Format, GeneratorMetadata, IntrospectionSource, ManagementSourceOptions, NextStep, Paint, Prompter, Queryable, RunOptions, RunResult, Snapshot, SnapshotBucket, SnapshotExtras };
package/dist/cli/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import { a as list, r as defineCliCommand } from "./command-BWEEXmtz.js";
2
- import { i as run, n as createCli, r as help, t as commandNames } from "./run-x9ZY4Tm0.js";
3
- import { t as VERSION } from "./version-TgFM8sOd.js";
2
+ import { i as run, n as createCli, r as help, t as commandNames } from "./run-Q5V5Kle1.js";
3
+ import { t as VERSION } from "./version-DzroJkIT.js";
4
4
  import { n as CliError, t as CLI_ERRORS_URL } from "./errors-BTe6A15O.js";
5
- import { a as serializeSnapshot, i as parseSnapshot, l as introspect, t as loadSnapshot } from "./snapshot-BXmU3IXN.js";
6
- import { a as emitBlockConfig, l as buildModel, o as GENERATED_HEADER, r as renderFiles, s as emitModule } from "./render-BJF9ytUi.js";
7
- import { a as toCatalog, n as managementSource, r as pgSource } from "./source-irttnsEb.js";
5
+ import { a as serializeSnapshot, i as parseSnapshot, l as introspect, t as loadSnapshot } from "./snapshot-k4R6vT20.js";
6
+ import { a as emitBlockConfig, l as buildModel, o as GENERATED_HEADER, r as renderFiles, s as emitModule } from "./render-D9c5ynjR.js";
7
+ import { a as toCatalog, n as managementSource, r as pgSource } from "./source-MMQKgaIx.js";
8
8
  import { s as loadConfig } from "./config-BJSqMi04.js";
9
- import { n as runGen } from "./run-jeplMBOK.js";
9
+ import { n as runGen } from "./run-CuzSU8Sk.js";
10
10
  //#region src/cli/introspect/from-catalog.ts
11
11
  /**
12
12
  * Builds a snapshot from catalog records: the inverse of `toCatalog`. Tests and
@@ -2,14 +2,14 @@ import { a as list, p as commandMeta, r as defineCliCommand } from "./command-BW
2
2
  import { i as plain } from "./style-Bm2X5JrN.js";
3
3
  import { n as CliError } from "./errors-BTe6A15O.js";
4
4
  import { r as readIfExists } from "./io-DH1kcmmP.js";
5
- import { l as TYPEGEN_VERSION } from "./cache-DE2IH1-C.js";
5
+ import { l as TYPEGEN_VERSION } from "./cache-BxohmNou.js";
6
6
  import { a as findConfig, s as loadConfig } from "./config-BJSqMi04.js";
7
- import { r as contentMapperFiles } from "./content-mapper-CaygHH_k.js";
7
+ import { r as contentMapperFiles } from "./content-mapper-D54wumPS.js";
8
8
  import { i as changeLines, n as PLAN_ARGS, r as applyPlan, u as planResult } from "./files-CX71yBm8.js";
9
- import { C as promptConventions, S as hasConventionFlags, _ as templatePlan, b as conventionFlags, c as AUTHZ_NOTE, d as chooseIntegrations, f as integrationFiles, g as templateContextFor, h as parseIntegrations, i as blocksWiringPath, l as createUrlParam, m as packagesFor, o as writeDesign, p as overwrite, r as blockConfigImport, s as readPresetInput, u as CANCELLED, v as CONVENTION_ARGS, w as withConventions, x as defaultConventions, y as CONVENTION_COMPLETIONS } from "./add-B1S3yK4L.js";
10
- import { a as wiringFiles, c as baseFiles, f as needsLib, i as wiringChecklist, m as suggestedIntegrations, n as latestMigrationVersion, o as wiringFor, p as resolveIntegrations, r as configInstances, s as TEMPLATES } from "./migration-safety-DYo1vVWC.js";
9
+ import { C as promptConventions, S as hasConventionFlags, _ as templatePlan, b as conventionFlags, c as AUTHZ_NOTE, d as chooseIntegrations, f as integrationFiles, g as templateContextFor, h as parseIntegrations, i as blocksWiringPath, l as createUrlParam, m as packagesFor, o as writeDesign, p as overwrite, r as blockConfigImport, s as readPresetInput, u as CANCELLED, v as CONVENTION_ARGS, w as withConventions, x as defaultConventions, y as CONVENTION_COMPLETIONS } from "./add-C5kLXuqn.js";
10
+ import { a as wiringFiles, c as baseFiles, f as needsLib, i as wiringChecklist, m as suggestedIntegrations, n as latestMigrationVersion, o as wiringFor, p as resolveIntegrations, r as configInstances, s as TEMPLATES } from "./migration-safety-DYgarZxP.js";
11
11
  import { n as installCommand, t as detectProject } from "./detect-D9JaAX20.js";
12
- import { s as enablePgDelta, t as syncModules } from "./sync-s1iKFIos.js";
12
+ import { s as enablePgDelta, t as syncModules } from "./sync-DYQVml8j.js";
13
13
  import { existsSync } from "node:fs";
14
14
  import { join, posix, resolve } from "node:path";
15
15
  import { glob, readFile } from "node:fs/promises";
@@ -21,11 +21,11 @@ function legacyPrefixNames(text) {
21
21
  }
22
22
  const array = (values) => `array[${values.map((value) => `'${value.replaceAll("'", "''")}'`).join(", ")}]::text[]`;
23
23
  /**
24
- * Renames the installed `bs_` triggers, policies, constraints, indexes and
25
- * functions to `bsb_`, so the module files' `drop ... if exists bsb_x` replace
26
- * them instead of adding a second copy. Only the names in `names` and the
27
- * runtime prefixes are renamed, and only while the new name is free, so the
28
- * step can run again.
24
+ * Renames the installed `bs_` triggers, event triggers, policies, constraints,
25
+ * indexes and functions to `bsb_`, so the module files' `drop ... if exists
26
+ * bsb_x` replace them instead of adding a second copy. Only the names in
27
+ * `names` and the runtime prefixes are renamed, and only while the new name is
28
+ * free, so the step can run again.
29
29
  */
30
30
  function legacyPrefixSql(names) {
31
31
  return `do $bsb_rename$
@@ -48,6 +48,19 @@ begin
48
48
  end;
49
49
  end loop;
50
50
 
51
+ for r in
52
+ select e.evtname as name
53
+ from pg_event_trigger e
54
+ where (e.evtname = any (v_names) or exists (select 1 from unnest(v_prefixes) x where starts_with(e.evtname, x)))
55
+ and not exists (select 1 from pg_event_trigger f where f.evtname = 'bsb_' || substr(e.evtname, 4))
56
+ loop
57
+ begin
58
+ execute format('alter event trigger %I rename to %I', r.name, 'bsb_' || substr(r.name, 4));
59
+ exception when insufficient_privilege then
60
+ raise warning 'better-supabase: rename % to bsb_% by hand; the migration role does not own it', r.name, substr(r.name, 4);
61
+ end;
62
+ end loop;
63
+
51
64
  for r in
52
65
  select p.polname as name, p.polrelid::regclass::text as rel
53
66
  from pg_policy p
@@ -1,6 +1,6 @@
1
1
  import { r as errorText } from "./errors-BTe6A15O.js";
2
- import "./source-irttnsEb.js";
3
- import { l as tableObject, n as exposed, s as qualified, t as catalogOf } from "./shared-B38Chjgd.js";
2
+ import "./source-MMQKgaIx.js";
3
+ import { l as tableObject, n as exposed, s as qualified, t as catalogOf } from "./shared-BNScv93m.js";
4
4
  //#region src/cli/doctor/reserved-roles.ts
5
5
  /**
6
6
  * Supautils' `reserved_roles` on Supabase. Nobody but a superuser may alter,
@@ -1,6 +1,6 @@
1
1
  import { p as commandMeta, r as defineCliCommand } from "./command-BWEEXmtz.js";
2
- import { a as envelope, i as run } from "./run-x9ZY4Tm0.js";
3
- import { t as VERSION } from "./version-TgFM8sOd.js";
2
+ import { a as envelope, i as run } from "./run-Q5V5Kle1.js";
3
+ import { t as VERSION } from "./version-DzroJkIT.js";
4
4
  import { n as CliError } from "./errors-BTe6A15O.js";
5
5
  import { n as consentToken } from "./agent-CbuPvI2x.js";
6
6
  import { C as optional, D as record, N as unknown, a as array, d as is, j as string$1, k as safeParse, o as boolean, t as PROCESS_ENV, x as object } from "./env-DMgjB_4y.js";
@@ -1,8 +1,8 @@
1
1
  import { n as CliError, r as errorText } from "./errors-BTe6A15O.js";
2
2
  import { i as readStdin } from "./io-DH1kcmmP.js";
3
- import { m as parseMetadataDocument, u as MetadataRejectedError } from "./snapshot-BXmU3IXN.js";
4
- import { c as metaPaths, n as render } from "./render-BJF9ytUi.js";
5
- import { i as generationNotices, n as runGen, o as fromMetadata, r as UNFORMATTED, t as refuseRowConditionedBuckets } from "./run-jeplMBOK.js";
3
+ import { m as parseMetadataDocument, u as MetadataRejectedError } from "./snapshot-k4R6vT20.js";
4
+ import { c as metaPaths, n as render } from "./render-D9c5ynjR.js";
5
+ import { i as generationNotices, n as runGen, o as fromMetadata, r as UNFORMATTED, t as refuseRowConditionedBuckets } from "./run-CuzSU8Sk.js";
6
6
  import { basename, join, relative, resolve, sep } from "node:path";
7
7
  import { readFile } from "node:fs/promises";
8
8
  import { jsonSchema, standardSchema, valibot, zod } from "better-supabase/config";
@@ -1,5 +1,5 @@
1
1
  import { f as INTEGRATIONS } from "./config-BJSqMi04.js";
2
- import { c as splitStatements } from "./shared-B38Chjgd.js";
2
+ import { c as splitStatements } from "./shared-BNScv93m.js";
3
3
  import { dirname, join, posix } from "node:path";
4
4
  import { readdir } from "node:fs/promises";
5
5
  import { INTEGRATION_INFO, groupEntries } from "better-supabase/config";
@@ -2,7 +2,7 @@ import { n as CliError } from "./errors-BTe6A15O.js";
2
2
  import { d as readSupabaseToml, p as sqlWorkflow } from "./supabase-toml-CncmQbO0.js";
3
3
  import { t as importFresh } from "./fresh-import-DzgsGHkX.js";
4
4
  import { i as changeLines, r as applyPlan } from "./files-CX71yBm8.js";
5
- import { a as sqlPlan, i as schemasDirOf, n as migrationsDir, r as moduleLayoutFor } from "./sql-layout-D8QrNvt4.js";
5
+ import { a as sqlPlan, i as schemasDirOf, n as migrationsDir, r as moduleLayoutFor } from "./sql-layout-AByPAQXl.js";
6
6
  import { resolve } from "node:path";
7
7
  import { readFile, readdir } from "node:fs/promises";
8
8
  import { MODULE_ID_TYPES, compileReadSets, moduleIdType, moduleLayout, modulePermissionKeys, moduleSchemaExtensions, renderBlocks, resolveBlocks, scopeProblems, templateFunctions } from "better-supabase/sql";
@@ -1,7 +1,7 @@
1
- import { i as stampAfter } from "./migrations-BoIyGczt.js";
1
+ import { i as stampAfter } from "./migrations-Cwh5VvUC.js";
2
2
  import { d as readSupabaseToml, p as sqlWorkflow } from "./supabase-toml-CncmQbO0.js";
3
3
  import { i as changeLines, r as applyPlan } from "./files-CX71yBm8.js";
4
- import { a as sqlPlan, n as migrationsDir } from "./sql-layout-D8QrNvt4.js";
4
+ import { a as sqlPlan, n as migrationsDir } from "./sql-layout-AByPAQXl.js";
5
5
  import { resolve } from "node:path";
6
6
  import { readFile, readdir } from "node:fs/promises";
7
7
  import { moduleSchemaExtensions } from "better-supabase/sql";
@@ -0,0 +1 @@
1
+ export { t as powersyncStreamsCommand } from "./powersync-BCDuGn5p.js";
@@ -1,7 +1,7 @@
1
1
  import { p as commandMeta, r as defineCliCommand } from "./command-BWEEXmtz.js";
2
- import { c as layoutFor, i as stampAfter } from "./migrations-BoIyGczt.js";
2
+ import { c as layoutFor, i as stampAfter } from "./migrations-Cwh5VvUC.js";
3
3
  import { n as PLAN_ARGS, r as applyPlan, u as planResult } from "./files-CX71yBm8.js";
4
- import { n as migrationsDir } from "./sql-layout-D8QrNvt4.js";
4
+ import { n as migrationsDir } from "./sql-layout-AByPAQXl.js";
5
5
  import { existsSync } from "node:fs";
6
6
  import { join, resolve } from "node:path";
7
7
  import { readFile, readdir } from "node:fs/promises";
@@ -1,6 +1,6 @@
1
1
  import { n as CliError } from "./errors-BTe6A15O.js";
2
- import { s as layout } from "./migrations-BoIyGczt.js";
3
- import { o as migrationModules, r as latestMigration, u as writesMigrations } from "./module-migration-DXvo0EqU.js";
2
+ import { s as layout } from "./migrations-Cwh5VvUC.js";
3
+ import { o as migrationModules, r as latestMigration, u as writesMigrations } from "./module-migration-CXtSwDLu.js";
4
4
  import { existsSync } from "node:fs";
5
5
  import { resolve } from "node:path";
6
6
  import { SQL_MODULES, contractSignature, customContracts, moduleBody, moduleFilePaths } from "better-supabase/sql";
@@ -2,15 +2,15 @@ import { p as commandMeta, r as defineCliCommand } from "./command-BWEEXmtz.js";
2
2
  import { i as plain } from "./style-Bm2X5JrN.js";
3
3
  import { n as CliError } from "./errors-BTe6A15O.js";
4
4
  import { r as readIfExists, t as display } from "./io-DH1kcmmP.js";
5
- import { c as layoutFor } from "./migrations-BoIyGczt.js";
5
+ import { c as layoutFor } from "./migrations-Cwh5VvUC.js";
6
6
  import { i as changeLines, n as PLAN_ARGS, r as applyPlan, t as HAND_EDITED, u as planResult } from "./files-CX71yBm8.js";
7
- import { a as sqlPlan } from "./sql-layout-D8QrNvt4.js";
8
- import { g as templateContextFor, i as blocksWiringPath, n as blockClients } from "./add-B1S3yK4L.js";
7
+ import { a as sqlPlan } from "./sql-layout-AByPAQXl.js";
8
+ import { g as templateContextFor, i as blocksWiringPath, n as blockClients } from "./add-C5kLXuqn.js";
9
9
  import { t as detectProject } from "./detect-D9JaAX20.js";
10
10
  import { _ as wiringBlocks, a as configObject, c as mask, i as closingIndex, l as properties } from "./config-edit-CrWfk8s3.js";
11
- import { n as guardedRemoval } from "./sync-s1iKFIos.js";
11
+ import { n as guardedRemoval } from "./sync-DYQVml8j.js";
12
12
  import { t as SQL_ARGS } from "./args-UEwg0l-N.js";
13
- import { t as blockNames } from "./blocks-DDm1Zc2S.js";
13
+ import { t as blockNames } from "./blocks-CT8-TBdW.js";
14
14
  import { i as tidyInline, t as cutRange } from "./config-group-C8tjut39.js";
15
15
  import { existsSync } from "node:fs";
16
16
  import { resolve } from "node:path";
@@ -1,10 +1,10 @@
1
1
  import { n as CliError, r as errorText } from "./errors-BTe6A15O.js";
2
2
  import { n as importPath } from "./io-DH1kcmmP.js";
3
- import { i as cachedTypesModule, n as cachedDatabaseTypes, s as typesModuleKey } from "./cache-DE2IH1-C.js";
3
+ import { i as cachedTypesModule, n as cachedDatabaseTypes, s as typesModuleKey } from "./cache-BxohmNou.js";
4
4
  import { t as byCodePoint } from "./compare-BmIWVEui.js";
5
- import { f as generateDatabaseTypes, h as restrictSchemas, p as oxfmtInstalled, v as tsTypeOf } from "./snapshot-BXmU3IXN.js";
5
+ import { f as generateDatabaseTypes, h as restrictSchemas, p as oxfmtInstalled, v as tsTypeOf } from "./snapshot-k4R6vT20.js";
6
6
  import { t as isRecord$1 } from "./guards-CUlDNYZs.js";
7
- import { a as toCatalog } from "./source-irttnsEb.js";
7
+ import { a as toCatalog } from "./source-MMQKgaIx.js";
8
8
  import { basename, dirname, isAbsolute, join, posix, relative, resolve } from "node:path";
9
9
  import { entityNames } from "better-supabase/blocks";
10
10
  import { DEFAULT_CLAIMS, blockEntities, blockEntityRenames, blockSubjectTypes, tenantClaimPaths, tenantNameOf } from "better-supabase/config";
@@ -1,15 +1,15 @@
1
1
  import { r as errorText } from "./errors-BTe6A15O.js";
2
2
  import { a as sameText, t as display } from "./io-DH1kcmmP.js";
3
- import { c as writeAtomic, o as storeTypesModule, s as typesModuleKey, t as CACHE_DIR } from "./cache-DE2IH1-C.js";
3
+ import { c as writeAtomic, o as storeTypesModule, s as typesModuleKey, t as CACHE_DIR } from "./cache-BxohmNou.js";
4
4
  import { t as byCodePoint } from "./compare-BmIWVEui.js";
5
- import { _ as stabilizeMetadata, b as typegenVersionNotice, p as oxfmtInstalled, t as loadSnapshot, y as typegenVersion } from "./snapshot-BXmU3IXN.js";
6
- import { n as render } from "./render-BJF9ytUi.js";
7
- import { _ as unsafeKey, d as accessProviderMode, f as accessRequirements, g as providerLabel, h as moduleKeyProblems, m as entitlementsMode, p as entitlementRequirements, u as compiledReadSets } from "./migrations-BoIyGczt.js";
8
- import { s as schemaStampPath } from "./content-mapper-CaygHH_k.js";
5
+ import { _ as stabilizeMetadata, b as typegenVersionNotice, p as oxfmtInstalled, t as loadSnapshot, y as typegenVersion } from "./snapshot-k4R6vT20.js";
6
+ import { n as render } from "./render-D9c5ynjR.js";
7
+ import { _ as unsafeKey, d as accessProviderMode, f as accessRequirements, g as providerLabel, h as moduleKeyProblems, m as entitlementsMode, p as entitlementRequirements, u as compiledReadSets } from "./migrations-Cwh5VvUC.js";
8
+ import { s as schemaStampPath } from "./content-mapper-D54wumPS.js";
9
9
  import { a as changedFiles, d as fileDiff, i as changeLines, r as applyPlan, s as hasConflicts } from "./files-CX71yBm8.js";
10
- import { n as migrationsDir, o as writtenByBlocks } from "./sql-layout-D8QrNvt4.js";
11
- import { l as tableObject, n as exposed, o as policyObject, s as qualified, t as catalogOf } from "./shared-B38Chjgd.js";
12
- import { c as sameModuleMigration, l as writeLatestMigration, n as READ_SETS_SUFFIX, r as latestMigration, u as writesMigrations } from "./module-migration-DXvo0EqU.js";
10
+ import { n as migrationsDir, o as writtenByBlocks } from "./sql-layout-AByPAQXl.js";
11
+ import { l as tableObject, n as exposed, o as policyObject, s as qualified, t as catalogOf } from "./shared-BNScv93m.js";
12
+ import { c as sameModuleMigration, l as writeLatestMigration, n as READ_SETS_SUFFIX, r as latestMigration, u as writesMigrations } from "./module-migration-CXtSwDLu.js";
13
13
  import { existsSync } from "node:fs";
14
14
  import { dirname, isAbsolute, relative, resolve, sep } from "node:path";
15
15
  import { readFile } from "node:fs/promises";
@@ -1,6 +1,6 @@
1
1
  import { c as COMMANDS, d as GROUPS, f as RESERVED_NAMES, h as runCommand, i as joinRepeated, m as parseArgs$2, o as listArgs, s as runsWithInvalidConfig, t as GLOBAL_ARGS, u as DOCS_ORIGIN } from "./command-BWEEXmtz.js";
2
2
  import { n as highlight, r as painter } from "./style-Bm2X5JrN.js";
3
- import { t as VERSION } from "./version-TgFM8sOd.js";
3
+ import { t as VERSION } from "./version-DzroJkIT.js";
4
4
  import { n as CliError, o as toCliError } from "./errors-BTe6A15O.js";
5
5
  import { a as missingInputNext, o as resolveAgent, t as checkConsent } from "./agent-CbuPvI2x.js";
6
6
  import { a as globalFlags, c as resolveCommand, i as commandTree, n as closestName, o as isVariadic, r as commandArgs, t as checkArgs } from "./parse-B079x40m.js";
@@ -16,36 +16,36 @@ import { resolve } from "node:path";
16
16
  * loads on demand, so `--version` and `--help` import no command.
17
17
  */
18
18
  const LOADERS = [
19
- ["init", () => import("./init-ch-HWJyp.js").then((m) => m.initCommand)],
20
- ["add", () => import("./add-BQPJnapO.js").then((m) => m.addCommand)],
21
- ["remove", () => import("./remove-D89s99ha.js").then((m) => m.removeCommand)],
22
- ["upgrade", () => import("./upgrade-CluxP3JJ.js").then((m) => m.upgradeCommand)],
23
- ["gen", () => import("./gen-D7gMEwvg.js").then((m) => m.genCommand)],
24
- ["doctor", () => import("./doctor-D_nrsd9E.js").then((m) => m.doctorCommand)],
19
+ ["init", () => import("./init-Dxvlzka4.js").then((m) => m.initCommand)],
20
+ ["add", () => import("./add-CFKvvXlK.js").then((m) => m.addCommand)],
21
+ ["remove", () => import("./remove-DpAwgO8A.js").then((m) => m.removeCommand)],
22
+ ["upgrade", () => import("./upgrade-f-3Nl6lO.js").then((m) => m.upgradeCommand)],
23
+ ["gen", () => import("./gen--IBq-J4M.js").then((m) => m.genCommand)],
24
+ ["doctor", () => import("./doctor-DBxc5aud.js").then((m) => m.doctorCommand)],
25
25
  ["db query", () => import("./db-DYU5hUcd.js").then((m) => m.dbQueryCommand)],
26
26
  ["db diff", () => import("./db-DYU5hUcd.js").then((m) => m.dbDiffCommand)],
27
27
  ["db seed", () => import("./seed-EPO6AvLG.js").then((m) => m.seedCommand)],
28
- ["db backfill", () => import("./backfill-BwkyNhlC.js").then((m) => m.dbBackfillCommand)],
28
+ ["db backfill", () => import("./backfill-C-b6eH98.js").then((m) => m.dbBackfillCommand)],
29
29
  ["dev env", () => import("./env-xhwXk5Ri.js").then((m) => m.envCommand)],
30
30
  ["dev run", () => import("./run-DmOTMa44.js").then((m) => m.runCommand)],
31
31
  ["dev keys", () => import("./keys-CbaL0lnw.js").then((m) => m.keysCommand)],
32
32
  ["dev stack ls", () => import("./stack-DgASZP0K.js").then((m) => m.stackLsCommand)],
33
33
  ["dev stack prune", () => import("./stack-DgASZP0K.js").then((m) => m.stackPruneCommand)],
34
- ["blocks list", () => import("./blocks-CBqENu3C.js").then((m) => m.blocksListCommand)],
35
- ["blocks view", () => import("./blocks-CBqENu3C.js").then((m) => m.blocksViewCommand)],
36
- ["blocks search", () => import("./blocks-CBqENu3C.js").then((m) => m.blocksSearchCommand)],
37
- ["powersync streams", () => import("./powersync-DXVsKkAu.js").then((m) => m.powersyncStreamsCommand)],
38
- ["spec emit", () => import("./spec-DzD5wMVF.js").then((m) => m.specEmitCommand)],
39
- ["spec validate", () => import("./spec-DzD5wMVF.js").then((m) => m.specValidateCommand)],
40
- ["mcp", () => import("./mcp-P9RP2SJ3.js").then((m) => m.mcpCommand)],
34
+ ["blocks list", () => import("./blocks-zpu__C1Y.js").then((m) => m.blocksListCommand)],
35
+ ["blocks view", () => import("./blocks-zpu__C1Y.js").then((m) => m.blocksViewCommand)],
36
+ ["blocks search", () => import("./blocks-zpu__C1Y.js").then((m) => m.blocksSearchCommand)],
37
+ ["powersync streams", () => import("./powersync-BAE2dlPJ.js").then((m) => m.powersyncStreamsCommand)],
38
+ ["spec emit", () => import("./spec-CqANRfuu.js").then((m) => m.specEmitCommand)],
39
+ ["spec validate", () => import("./spec-CqANRfuu.js").then((m) => m.specValidateCommand)],
40
+ ["mcp", () => import("./mcp-3q5RDvYJ.js").then((m) => m.mcpCommand)],
41
41
  ["skills list", () => import("./skills-FXAVPLzp.js").then((m) => m.skillsListCommand)],
42
42
  ["skills install", () => import("./skills-FXAVPLzp.js").then((m) => m.skillsInstallCommand)],
43
- ["codemod 0.4", () => import("./codemod-OHKhVV-v.js").then((m) => m.codemodCommand("0.4"))],
44
- ["codemod 0.5", () => import("./codemod-OHKhVV-v.js").then((m) => m.codemodCommand("0.5"))],
45
- ["codemod 0.6", () => import("./codemod-OHKhVV-v.js").then((m) => m.codemodCommand("0.6"))],
46
- ["codemod 0.9", () => import("./codemod-OHKhVV-v.js").then((m) => m.codemodCommand("0.9"))],
47
- ["codemod 0.11", () => import("./codemod-OHKhVV-v.js").then((m) => m.codemodCommand("0.11"))],
48
- ["codemod 0.15", () => import("./codemod-OHKhVV-v.js").then((m) => m.codemodCommand("0.15"))],
43
+ ["codemod 0.4", () => import("./codemod-BVo3sdx7.js").then((m) => m.codemodCommand("0.4"))],
44
+ ["codemod 0.5", () => import("./codemod-BVo3sdx7.js").then((m) => m.codemodCommand("0.5"))],
45
+ ["codemod 0.6", () => import("./codemod-BVo3sdx7.js").then((m) => m.codemodCommand("0.6"))],
46
+ ["codemod 0.9", () => import("./codemod-BVo3sdx7.js").then((m) => m.codemodCommand("0.9"))],
47
+ ["codemod 0.11", () => import("./codemod-BVo3sdx7.js").then((m) => m.codemodCommand("0.11"))],
48
+ ["codemod 0.15", () => import("./codemod-BVo3sdx7.js").then((m) => m.codemodCommand("0.15"))],
49
49
  ["completion", () => import("./completion-BfnKI4QZ.js").then((m) => m.completionCommand)],
50
50
  ["config", () => import("./config-WKDixoGK.js").then((m) => m.configCommand)]
51
51
  ];
@@ -1,4 +1,4 @@
1
- import { a as toCatalog } from "./source-irttnsEb.js";
1
+ import { a as toCatalog } from "./source-MMQKgaIx.js";
2
2
  import { h as tomlGet, p as sqlWorkflow, r as detectWorkflow } from "./supabase-toml-CncmQbO0.js";
3
3
  //#region src/cli/doctor/shared.ts
4
4
  const catalogs = /* @__PURE__ */ new WeakMap();
@@ -1,7 +1,7 @@
1
1
  import { n as CliError, r as errorText } from "./errors-BTe6A15O.js";
2
- import { d as readExtras, l as TYPEGEN_VERSION, r as cachedIntrospect } from "./cache-DE2IH1-C.js";
2
+ import { d as readExtras, l as TYPEGEN_VERSION, r as cachedIntrospect } from "./cache-BxohmNou.js";
3
3
  import { t as byCodePoint } from "./compare-BmIWVEui.js";
4
- import { n as managementSource, r as pgSource } from "./source-irttnsEb.js";
4
+ import { n as managementSource, r as pgSource } from "./source-MMQKgaIx.js";
5
5
  import { n as databaseUrl, u as accessToken } from "./config-BJSqMi04.js";
6
6
  import { d as readSupabaseToml, f as schemaPaths, h as tomlGet, u as pgFunctionHooks } from "./supabase-toml-CncmQbO0.js";
7
7
  import { t as connect } from "./db-CQCLx7cx.js";
@@ -1,4 +1,4 @@
1
- import { t as VERSION } from "./version-TgFM8sOd.js";
1
+ import { t as VERSION } from "./version-DzroJkIT.js";
2
2
  import { n as CliError } from "./errors-BTe6A15O.js";
3
3
  import { r as redactUrl } from "./redact-KGAk2Ul9.js";
4
4
  import { n as HTTP_CHANNEL } from "./trace-VbdO6bcN.js";
@@ -1,9 +1,9 @@
1
1
  import { n as __require, t as __commonJSMin } from "./rolldown-runtime-kJ_i4yPo.js";
2
2
  import { p as commandMeta, r as defineCliCommand } from "./command-BWEEXmtz.js";
3
- import { t as VERSION } from "./version-TgFM8sOd.js";
3
+ import { t as VERSION } from "./version-DzroJkIT.js";
4
4
  import { i as failedResult, n as CliError, r as errorText } from "./errors-BTe6A15O.js";
5
5
  import { t as display } from "./io-DH1kcmmP.js";
6
- import { c as writeAtomic, t as CACHE_DIR } from "./cache-DE2IH1-C.js";
6
+ import { c as writeAtomic, t as CACHE_DIR } from "./cache-BxohmNou.js";
7
7
  import { t as isRecord } from "./guards-CUlDNYZs.js";
8
8
  import { t as importFresh } from "./fresh-import-DzgsGHkX.js";
9
9
  import { a as changedFiles, i as changeLines, r as applyPlan } from "./files-CX71yBm8.js";
@@ -1 +1 @@
1
- export { n as specEmitCommand, i as specValidateCommand } from "./spec-CDxfokey.js";
1
+ export { n as specEmitCommand, i as specValidateCommand } from "./spec-CCpPVw_T.js";
@@ -1,5 +1,5 @@
1
- import { d as TypegenMissingError, i as parseSnapshot } from "./snapshot-BXmU3IXN.js";
2
- import { a as toCatalog } from "./source-irttnsEb.js";
1
+ import { d as TypegenMissingError, i as parseSnapshot } from "./snapshot-k4R6vT20.js";
2
+ import { a as toCatalog } from "./source-MMQKgaIx.js";
3
3
  import { d as readSupabaseToml, f as schemaPaths, n as declarativeSchemasDir, p as sqlWorkflow } from "./supabase-toml-CncmQbO0.js";
4
4
  import { existsSync } from "node:fs";
5
5
  import { dirname, join, relative, resolve, sep } from "node:path";
@@ -1,10 +1,10 @@
1
1
  import { n as CliError } from "./errors-BTe6A15O.js";
2
2
  import { t as display } from "./io-DH1kcmmP.js";
3
- import { a as writeExtensionsMigration, c as layoutFor, t as DATA_NEXT } from "./migrations-BoIyGczt.js";
3
+ import { a as writeExtensionsMigration, c as layoutFor, t as DATA_NEXT } from "./migrations-Cwh5VvUC.js";
4
4
  import { d as readSupabaseToml, f as schemaPaths, h as tomlGet, i as diffEngine, l as migrationCommand, o as findSupabaseRoot, p as sqlWorkflow, t as PGDELTA_TABLE } from "./supabase-toml-CncmQbO0.js";
5
5
  import { d as fileDiff, i as changeLines, l as keepHandEdit, o as handEditedError, r as applyPlan, t as HAND_EDITED, u as planResult } from "./files-CX71yBm8.js";
6
- import { a as sqlPlan, n as migrationsDir } from "./sql-layout-D8QrNvt4.js";
7
- import { c as sameModuleMigration, l as writeLatestMigration, r as latestMigration, s as renderModuleMigration, t as MODULES_SUFFIX, u as writesMigrations } from "./module-migration-DXvo0EqU.js";
6
+ import { a as sqlPlan, n as migrationsDir } from "./sql-layout-AByPAQXl.js";
7
+ import { c as sameModuleMigration, l as writeLatestMigration, r as latestMigration, s as renderModuleMigration, t as MODULES_SUFFIX, u as writesMigrations } from "./module-migration-CXtSwDLu.js";
8
8
  import { t as loadTopics } from "./topics-BpdnYmWb.js";
9
9
  import { t as orphanedBlockFiles } from "./orphans-BAboqyVM.js";
10
10
  import { dirname, join, resolve } from "node:path";
@@ -1,10 +1,10 @@
1
1
  import { t as display } from "./io-DH1kcmmP.js";
2
- import { c as layoutFor, r as migrationStamp } from "./migrations-BoIyGczt.js";
2
+ import { c as layoutFor, r as migrationStamp } from "./migrations-Cwh5VvUC.js";
3
3
  import { d as fileDiff, i as changeLines, r as applyPlan } from "./files-CX71yBm8.js";
4
- import { a as sqlPlan, n as migrationsDir } from "./sql-layout-D8QrNvt4.js";
5
- import { a as migrationInstances, c as sameModuleMigration, o as migrationModules, r as latestMigration, s as renderModuleMigration, t as MODULES_SUFFIX, u as writesMigrations } from "./module-migration-DXvo0EqU.js";
6
- import { a as write, o as topicPolicyFile, r as nextStep } from "./sync-s1iKFIos.js";
7
- import { a as legacyPrefixSql, i as legacyPrefixNames, r as legacyBlocksTableSql } from "./legacy-prefix-DkTA3Rhx.js";
4
+ import { a as sqlPlan, n as migrationsDir } from "./sql-layout-AByPAQXl.js";
5
+ import { a as migrationInstances, c as sameModuleMigration, o as migrationModules, r as latestMigration, s as renderModuleMigration, t as MODULES_SUFFIX, u as writesMigrations } from "./module-migration-CXtSwDLu.js";
6
+ import { a as write, o as topicPolicyFile, r as nextStep } from "./sync-DYQVml8j.js";
7
+ import { a as legacyPrefixSql, i as legacyPrefixNames, r as legacyBlocksTableSql } from "./legacy-prefix-R7UChFFl.js";
8
8
  import { resolve } from "node:path";
9
9
  import { readFile } from "node:fs/promises";
10
10
  import { BLOCK_RENAMES, SQL_MODULES, currentBlockName, entityRenamePlan, formerBlockName, moduleFileVersion, moduleTopics, renderBlocks, sameBlockFile, upgradePlan } from "better-supabase/sql";
@@ -1,8 +1,8 @@
1
1
  import { p as commandMeta, r as defineCliCommand } from "./command-BWEEXmtz.js";
2
2
  import { i as plain } from "./style-Bm2X5JrN.js";
3
- import { t as syncModules } from "./sync-s1iKFIos.js";
3
+ import { t as syncModules } from "./sync-DYQVml8j.js";
4
4
  import { t as SQL_ARGS } from "./args-UEwg0l-N.js";
5
- import { t as upgrade } from "./upgrade-B4FPlK-_.js";
5
+ import { t as upgrade } from "./upgrade-DHcIHeRM.js";
6
6
  //#region src/cli/commands/upgrade.ts
7
7
  const UPGRADE_ARGS = {
8
8
  check: {
@@ -1,4 +1,4 @@
1
1
  //#region src/cli/version.ts
2
- const VERSION = "0.18.0";
2
+ const VERSION = "0.18.1";
3
3
  //#endregion
4
4
  export { VERSION as t };
@@ -8,7 +8,7 @@ import { Dn as GeneratedBlocks } from "./define-block-CJWiDWa5.js";
8
8
  import { _ as TopicMessage, c as RealtimeClient, d as SubscribeOptions, i as PresenceOptions, s as PresenceSubscription } from "./topic-nQYxoTaU.js";
9
9
  import { t as ClientPorts } from "./ports-g0H1Kzwr.js";
10
10
  import { a as ClientAuth } from "./bind-pu5TLrla.js";
11
- import { a as LiveSource, r as LiveCountSeed } from "./index-BH3NYExp.js";
11
+ import { a as LiveSource, r as LiveCountSeed } from "./index-DmbCyl6Z.js";
12
12
  import { SupabaseClient } from "@supabase/supabase-js";
13
13
  import { QueryClient } from "@tanstack/query-core";
14
14
  import { StandardSchemaV1 } from "@standard-schema/spec";
@@ -8,9 +8,9 @@ import { M as BindingName, S as RecordWriteInput, _ as RecordTypeBlocks, b as Re
8
8
  import { c as RealtimeClient, d as SubscribeOptions, g as TopicHandlers, i as PresenceOptions, m as Topic, p as SubscriptionStatus, r as PresenceMember, s as PresenceSubscription, t as EventSchemas } from "./topic-nQYxoTaU.js";
9
9
  import { t as AuthSnapshot } from "./bind-pu5TLrla.js";
10
10
  import { t as AuthSession } from "./view-DyFdMCqg.js";
11
- import { r as LiveCountSeed, v as RelayClientOptions } from "./index-BH3NYExp.js";
11
+ import { r as LiveCountSeed, v as RelayClientOptions } from "./index-DmbCyl6Z.js";
12
12
  import { n as Controller } from "./controller-BR7CZ1R9.js";
13
- import { D as ProfileOf, O as UseActionOptions, S as LiveCountHookOptions, _ as ActionResultOf, a as DataRows, b as ClaimsOf, c as DataWrites, d as BlockMutationState, f as BlockQueryActions, g as ActionInputOf, i as DataRow, l as BlockEventSource, m as BlockQueryState, n as DataId, o as DataSource, p as BlockQueryOptions, r as DataListArgs, s as DataState, u as BlockMutationActions, w as LiveQueryHookOptions, x as ClientLike, y as BroadcastOptions } from "./field-errors-DucQdLl7.js";
13
+ import { D as ProfileOf, O as UseActionOptions, S as LiveCountHookOptions, _ as ActionResultOf, a as DataRows, b as ClaimsOf, c as DataWrites, d as BlockMutationState, f as BlockQueryActions, g as ActionInputOf, i as DataRow, l as BlockEventSource, m as BlockQueryState, n as DataId, o as DataSource, p as BlockQueryOptions, r as DataListArgs, s as DataState, u as BlockMutationActions, w as LiveQueryHookOptions, x as ClientLike, y as BroadcastOptions } from "./field-errors-DkAemDoc.js";
14
14
  import { t as BlockEnv } from "./block-env-CA65ulTD.js";
15
15
  import { n as BlockDataOf, r as BlockMethodName, t as BlockArgsOf } from "./block-method-CiVa2G-J.js";
16
16
  import { s as RecordFormValues, t as RecordForm } from "./record-form-zMwz0Ayt.js";
@@ -23,11 +23,15 @@ interface RelayClientOptions {
23
23
  /** `fetch` for broadcasts; defaults to the global one. */
24
24
  readonly fetch?: typeof fetch;
25
25
  /**
26
- * Milliseconds to wait for the first join before reporting `TIMED_OUT`.
27
- * Defaults to 15000.
26
+ * Milliseconds from `subscribe()` to the first join. Until then, a failed
27
+ * attempt is retried with backoff; when the time is up, the channel reports
28
+ * `TIMED_OUT` and stops. Defaults to 15000.
28
29
  */
29
30
  readonly timeoutMs?: number;
30
- /** The longest wait between reconnects after the relay refused. Defaults to 30000. */
31
+ /**
32
+ * The longest wait between reconnects after a stream closed or a join failed
33
+ * for a reason that may pass. Defaults to 30000.
34
+ */
31
35
  readonly maxBackoffMs?: number;
32
36
  }
33
37
  /**
@@ -1,10 +1,10 @@
1
- import { t as VERSION } from "../cli/version-TgFM8sOd.js";
2
- import { a as lastTypesModule, c as writeAtomic, s as typesModuleKey } from "../cli/cache-DE2IH1-C.js";
3
- import { t as loadSnapshot } from "../cli/snapshot-BXmU3IXN.js";
4
- import { i as renderTypesModule, t as mapperFilePath } from "../cli/render-BJF9ytUi.js";
1
+ import { t as VERSION } from "../cli/version-DzroJkIT.js";
2
+ import { a as lastTypesModule, c as writeAtomic, s as typesModuleKey } from "../cli/cache-BxohmNou.js";
3
+ import { t as loadSnapshot } from "../cli/snapshot-k4R6vT20.js";
4
+ import { i as renderTypesModule, t as mapperFilePath } from "../cli/render-D9c5ynjR.js";
5
5
  import { i as discoverConfig, s as loadConfig } from "../cli/config-BJSqMi04.js";
6
6
  import { i as parseEnv, n as configEnvironment } from "../cli/env-DMgjB_4y.js";
7
- import { s as schemaStampPath } from "../cli/content-mapper-CaygHH_k.js";
7
+ import { s as schemaStampPath } from "../cli/content-mapper-D54wumPS.js";
8
8
  import { existsSync, realpathSync } from "node:fs";
9
9
  import { basename, dirname, join, resolve } from "node:path";
10
10
  import { createHash } from "node:crypto";
@@ -15,7 +15,7 @@ import { t as AuthOutageHook } from "../session-Fcft5A39.js";
15
15
  import { n as AuthKind, r as GuardOptions } from "../respond-oZeJ342J.js";
16
16
  import { a as AuthorizedContext, c as ResourceLoaderContext, i as AuthorizeOptions, l as Unwrapped, n as ActionParsed, r as ActionResult, t as ActionInput } from "../kit-CVgQCIBO.js";
17
17
  import { c as ListParseOptions, m as ListSearchParams } from "../list-query-DxjuIHEL.js";
18
- import { r as LiveCountSeed, t as CountRunner } from "../index-BH3NYExp.js";
18
+ import { r as LiveCountSeed, t as CountRunner } from "../index-DmbCyl6Z.js";
19
19
  import { r as MembershipClaim } from "../entitlements-DHcNt1aF.js";
20
20
  import { i as ResourceContext, l as ResourceRouteOptions, o as ResourceHooks, r as ResourceAction, t as ActionArgs } from "../resource-types-8Q5Klkpa.js";
21
21
  import { t as ResourceMap } from "../resources-DxpqenZA.js";
@@ -40,9 +40,9 @@ function systemOf(executor) {
40
40
  * ```
41
41
  */
42
42
  function otel(options = {}) {
43
- const tracer = options.tracer ?? trace.getTracer("better-supabase", "0.18.0");
43
+ const tracer = options.tracer ?? trace.getTracer("better-supabase", "0.18.1");
44
44
  let histogram;
45
- if (options.metrics !== false) histogram = (options.meter ?? metrics.getMeter("better-supabase", "0.18.0")).createHistogram("db.client.operation.duration", {
45
+ if (options.metrics !== false) histogram = (options.meter ?? metrics.getMeter("better-supabase", "0.18.1")).createHistogram("db.client.operation.duration", {
46
46
  unit: "s",
47
47
  description: "Duration of database client operations.",
48
48
  advice: { explicitBucketBoundaries: [
@@ -219,7 +219,7 @@ function otel(options = {}) {
219
219
  * `betterSupabase.events`. Returns a function that stops listening.
220
220
  */
221
221
  function traceAuth(betterSupabase, options = {}) {
222
- const tracer = options.tracer ?? trace.getTracer("better-supabase", "0.18.0");
222
+ const tracer = options.tracer ?? trace.getTracer("better-supabase", "0.18.1");
223
223
  const offAuth = betterSupabase.events.on("auth", (event) => {
224
224
  const span = tracer.startSpan("auth.resolve", {
225
225
  kind: SpanKind.INTERNAL,
@@ -257,7 +257,7 @@ function traceAuth(betterSupabase, options = {}) {
257
257
  * an error status. Returns a function that stops listening.
258
258
  */
259
259
  function traceBlockEvents(betterSupabase, options = {}) {
260
- const tracer = options.tracer ?? trace.getTracer("better-supabase", "0.18.0");
260
+ const tracer = options.tracer ?? trace.getTracer("better-supabase", "0.18.1");
261
261
  return betterSupabase.events.on("block", (event) => {
262
262
  const attributes = {
263
263
  ...options.attributes,
@@ -3,11 +3,11 @@ import { n as Impersonator } from "../impersonation-YTa9dZUv.js";
3
3
  import { i as DataEntry, m as RejectedChange, n as DataEngine, o as DataSyncState } from "../data-engine-BWoz9lED.js";
4
4
  import { t as tenantOf } from "../tenant-DyoVYFfC.js";
5
5
  import { t as AuthSession } from "../view-DyFdMCqg.js";
6
- import { r as LiveCountSeed } from "../index-BH3NYExp.js";
6
+ import { r as LiveCountSeed } from "../index-DmbCyl6Z.js";
7
7
  import { r as MembershipClaim } from "../entitlements-DHcNt1aF.js";
8
- import { D as ProfileOf, O as UseActionOptions, S as LiveCountHookOptions, _ as ActionResultOf, b as ClaimsOf, c as DataWrites, d as BlockMutationState, f as BlockQueryActions, g as ActionInputOf, h as BlockRefetchOn, l as BlockEventSource, m as BlockQueryState, o as DataSource, p as BlockQueryOptions, s as DataState, t as fieldErrorsOf, u as BlockMutationActions, w as LiveQueryHookOptions, x as ClientLike, y as BroadcastOptions } from "../field-errors-DucQdLl7.js";
8
+ import { D as ProfileOf, O as UseActionOptions, S as LiveCountHookOptions, _ as ActionResultOf, b as ClaimsOf, c as DataWrites, d as BlockMutationState, f as BlockQueryActions, g as ActionInputOf, h as BlockRefetchOn, l as BlockEventSource, m as BlockQueryState, o as DataSource, p as BlockQueryOptions, s as DataState, t as fieldErrorsOf, u as BlockMutationActions, w as LiveQueryHookOptions, x as ClientLike, y as BroadcastOptions } from "../field-errors-DkAemDoc.js";
9
9
  import { n as supportOf, t as SupportView } from "../support-view-BYOgwXsJ.js";
10
- import { $ as UseActionFormOptions, A as useController, B as RecordListUrl, C as useConflicts, D as defineDataHooks, E as DataView, F as RecordFormState, G as RecordInitial, H as useRecordListState, I as UseRecordFormOptions, J as RecordState, K as RecordProviderKit, L as useRecordForm, M as useBlockEvent, N as useBlockMutation, O as useBlockEnv, P as useBlockQuery, Q as ActionHandle, R as RecordListQueryStates, S as Conflicts, T as DataHooks, U as RecordActionsOf, V as RecordListUrlState, W as RecordContextValue, X as createRecordProvider, Y as RecordWriteHandlers, Z as ActionForm, _ as useRealtimeRelay, a as Upload, at as LiveCount, b as PresenceTopic, c as UseImageOptions, ct as useBroadcast, d as useSignedUrl, dt as useSupabase, et as useAction, f as useUpload, g as UseRealtimeRelayOptions, h as useDebouncedSearch, i as StorageImage, it as BetterSupabaseProviderProps, j as useLatest, k as useBlockTenant, l as UseUploadOptions, lt as useLiveCount, m as DebouncedSearchOptions, n as SignedUrl, nt as BetterHooks, o as UploadStatus, ot as createHooks, p as DebouncedSearch, q as RecordProviderProps, r as SignedUrlSource, rt as BetterSupabaseProvider, s as UploadTarget, st as useAuth, t as ImageSource, tt as useActionForm, u as useImage, ut as useLiveQuery, v as Presence, w as useSyncStatus, x as usePresence, y as PresenceHookOptions, z as RecordListState } from "../index-XAyzdLns.js";
10
+ import { $ as UseActionFormOptions, A as useController, B as RecordListUrl, C as useConflicts, D as defineDataHooks, E as DataView, F as RecordFormState, G as RecordInitial, H as useRecordListState, I as UseRecordFormOptions, J as RecordState, K as RecordProviderKit, L as useRecordForm, M as useBlockEvent, N as useBlockMutation, O as useBlockEnv, P as useBlockQuery, Q as ActionHandle, R as RecordListQueryStates, S as Conflicts, T as DataHooks, U as RecordActionsOf, V as RecordListUrlState, W as RecordContextValue, X as createRecordProvider, Y as RecordWriteHandlers, Z as ActionForm, _ as useRealtimeRelay, a as Upload, at as LiveCount, b as PresenceTopic, c as UseImageOptions, ct as useBroadcast, d as useSignedUrl, dt as useSupabase, et as useAction, f as useUpload, g as UseRealtimeRelayOptions, h as useDebouncedSearch, i as StorageImage, it as BetterSupabaseProviderProps, j as useLatest, k as useBlockTenant, l as UseUploadOptions, lt as useLiveCount, m as DebouncedSearchOptions, n as SignedUrl, nt as BetterHooks, o as UploadStatus, ot as createHooks, p as DebouncedSearch, q as RecordProviderProps, r as SignedUrlSource, rt as BetterSupabaseProvider, s as UploadTarget, st as useAuth, t as ImageSource, tt as useActionForm, u as useImage, ut as useLiveQuery, v as Presence, w as useSyncStatus, x as usePresence, y as PresenceHookOptions, z as RecordListState } from "../index-DTbJAsrT.js";
11
11
  import { SessionProvider, SessionProviderProps, useSession, useSupportSession } from "./session.js";
12
12
  import { a as useSignIn, i as SignOut, n as PendingState, o as useSignOut, r as SignIn, t as AuthHookOptions } from "../sign-in-D54FLMQy.js";
13
13
  export { type ActionForm, type ActionHandle, type ActionInputOf, type ActionResultOf, type AuthHookOptions, type AuthSession, type BetterHooks, BetterSupabaseProvider, type BetterSupabaseProviderProps, type BlockEventSource, type BlockMutationActions, type BlockMutationState, type BlockQueryActions, type BlockQueryOptions, type BlockQueryState, type BlockRefetchOn, type BroadcastOptions, type ClaimsOf, type ClientLike, type Conflicts, type DataEngine, type DataEntry, type DataHooks, type DataSource, type DataState, type DataSyncState, type DataView, type DataWrites, type DebouncedSearch, type DebouncedSearchOptions, type ImageSource, type Impersonator, type LiveCount, type LiveCountHookOptions, type LiveCountSeed, type LiveQueryHookOptions, type MembershipClaim, type PendingState, type Presence, type PresenceHookOptions, type PresenceTopic, type ProfileOf, type RecordActionsOf, type RecordContextValue, type RecordFormState, type RecordInitial, type RecordListQueryStates, type RecordListState, type RecordListUrl, type RecordListUrlState, type RecordProviderKit, type RecordProviderProps, type RecordState, type RecordWriteHandlers, type RejectedChange, SessionProvider, type SessionProviderProps, type SignIn, type SignOut, type SignedUrl, type SignedUrlSource, type StorageImage, type SupportView, type Upload, type UploadStatus, type UploadTarget, type UseActionFormOptions, type UseActionOptions, type UseImageOptions, type UseRealtimeRelayOptions, type UseRecordFormOptions, type UseUploadOptions, createHooks, createRecordProvider, defineDataHooks, escapeLike, fieldErrorsOf, supportOf, tenantOf, useAction, useActionForm, useAuth, useBlockEnv, useBlockEvent, useBlockMutation, useBlockQuery, useBlockTenant, useBroadcast, useConflicts, useController, useDebouncedSearch, useImage, useLatest, useLiveCount, useLiveQuery, usePresence, useRealtimeRelay, useRecordForm, useRecordListState, useSession, useSignIn, useSignOut, useSignedUrl, useSupabase, useSupportSession, useSyncStatus, useUpload };
@@ -4,6 +4,6 @@ import { a as createHooks, d as useSupabase, i as BetterSupabaseProvider, l as u
4
4
  import { t as supportOf } from "../support-view-g4YLBeqX.js";
5
5
  import { SessionProvider, useSession, useSupportSession } from "./session.js";
6
6
  import { d as fieldErrorsOf } from "../data-hooks-tgF1Ct0F.js";
7
- import { _ as useBlockTenant, a as useRealtimeRelay, b as useAction, c as useSyncStatus, d as useBlockMutation, f as useBlockQuery, g as useBlockEnv, h as createRecordProvider, i as useDebouncedSearch, l as defineDataHooks, m as useRecordListState, n as useSignedUrl, o as usePresence, p as useRecordForm, r as useUpload, s as useConflicts, t as useImage, u as useBlockEvent, v as useController, x as useActionForm, y as useLatest } from "../react-CZUZYn9E.js";
7
+ import { _ as useBlockTenant, a as useRealtimeRelay, b as useAction, c as useSyncStatus, d as useBlockMutation, f as useBlockQuery, g as useBlockEnv, h as createRecordProvider, i as useDebouncedSearch, l as defineDataHooks, m as useRecordListState, n as useSignedUrl, o as usePresence, p as useRecordForm, r as useUpload, s as useConflicts, t as useImage, u as useBlockEvent, v as useController, x as useActionForm, y as useLatest } from "../react-zBTxLsV6.js";
8
8
  import { t as tenantOf } from "../tenant-BgIiMQpo.js";
9
9
  export { BetterSupabaseProvider, SessionProvider, createHooks, createRecordProvider, defineDataHooks, escapeLike, fieldErrorsOf, supportOf, tenantOf, useAction, useActionForm, useAuth, useBlockEnv, useBlockEvent, useBlockMutation, useBlockQuery, useBlockTenant, useBroadcast, useConflicts, useController, useDebouncedSearch, useImage, useLatest, useLiveCount, useLiveQuery, usePresence, useRealtimeRelay, useRecordForm, useRecordListState, useSession, useSignIn, useSignOut, useSignedUrl, useSupabase, useSupportSession, useSyncStatus, useUpload };
@@ -3,11 +3,11 @@ import { pt as QuerySpec } from "../define-Cgru0_kF.js";
3
3
  import { n as Impersonator } from "../impersonation-YTa9dZUv.js";
4
4
  import { t as tenantOf } from "../tenant-DyoVYFfC.js";
5
5
  import { t as AuthSession } from "../view-DyFdMCqg.js";
6
- import { r as LiveCountSeed } from "../index-BH3NYExp.js";
6
+ import { r as LiveCountSeed } from "../index-DmbCyl6Z.js";
7
7
  import { r as MembershipClaim } from "../entitlements-DHcNt1aF.js";
8
- import { D as ProfileOf, O as UseActionOptions, S as LiveCountHookOptions, _ as ActionResultOf, b as ClaimsOf, g as ActionInputOf, t as fieldErrorsOf, w as LiveQueryHookOptions, x as ClientLike, y as BroadcastOptions } from "../field-errors-DucQdLl7.js";
8
+ import { D as ProfileOf, O as UseActionOptions, S as LiveCountHookOptions, _ as ActionResultOf, b as ClaimsOf, g as ActionInputOf, t as fieldErrorsOf, w as LiveQueryHookOptions, x as ClientLike, y as BroadcastOptions } from "../field-errors-DkAemDoc.js";
9
9
  import { n as supportOf, t as SupportView } from "../support-view-BYOgwXsJ.js";
10
- import { $ as UseActionFormOptions, A as useController$1, B as RecordListUrl, C as useConflicts$1, D as defineDataHooks$1, F as RecordFormState, G as RecordInitial, H as useRecordListState$1, I as UseRecordFormOptions, J as RecordState, K as RecordProviderKit, L as useRecordForm$1, M as useBlockEvent$1, N as useBlockMutation$1, O as useBlockEnv$1, P as useBlockQuery$1, Q as ActionHandle, R as RecordListQueryStates, U as RecordActionsOf, V as RecordListUrlState, W as RecordContextValue, X as createRecordProvider$1, Y as RecordWriteHandlers, Z as ActionForm, _ as useRealtimeRelay$1, a as Upload, at as LiveCount, b as PresenceTopic, c as UseImageOptions, ct as useBroadcast, d as useSignedUrl$1, dt as useSupabase, f as useUpload$1, g as UseRealtimeRelayOptions, h as useDebouncedSearch$1, i as StorageImage, it as BetterSupabaseProviderProps, j as useLatest$1, k as useBlockTenant$1, l as UseUploadOptions, m as DebouncedSearchOptions, n as SignedUrl, nt as BetterHooks, o as UploadStatus, p as DebouncedSearch, q as RecordProviderProps, r as SignedUrlSource, rt as BetterSupabaseProvider, s as UploadTarget, st as useAuth, t as ImageSource, u as useImage$1, ut as useLiveQuery, v as Presence, w as useSyncStatus$1, x as usePresence$1, y as PresenceHookOptions, z as RecordListState } from "../index-XAyzdLns.js";
10
+ import { $ as UseActionFormOptions, A as useController$1, B as RecordListUrl, C as useConflicts$1, D as defineDataHooks$1, F as RecordFormState, G as RecordInitial, H as useRecordListState$1, I as UseRecordFormOptions, J as RecordState, K as RecordProviderKit, L as useRecordForm$1, M as useBlockEvent$1, N as useBlockMutation$1, O as useBlockEnv$1, P as useBlockQuery$1, Q as ActionHandle, R as RecordListQueryStates, U as RecordActionsOf, V as RecordListUrlState, W as RecordContextValue, X as createRecordProvider$1, Y as RecordWriteHandlers, Z as ActionForm, _ as useRealtimeRelay$1, a as Upload, at as LiveCount, b as PresenceTopic, c as UseImageOptions, ct as useBroadcast, d as useSignedUrl$1, dt as useSupabase, f as useUpload$1, g as UseRealtimeRelayOptions, h as useDebouncedSearch$1, i as StorageImage, it as BetterSupabaseProviderProps, j as useLatest$1, k as useBlockTenant$1, l as UseUploadOptions, m as DebouncedSearchOptions, n as SignedUrl, nt as BetterHooks, o as UploadStatus, p as DebouncedSearch, q as RecordProviderProps, r as SignedUrlSource, rt as BetterSupabaseProvider, s as UploadTarget, st as useAuth, t as ImageSource, u as useImage$1, ut as useLiveQuery, v as Presence, w as useSyncStatus$1, x as usePresence$1, y as PresenceHookOptions, z as RecordListState } from "../index-DTbJAsrT.js";
11
11
  import { SessionProvider, SessionProviderProps } from "./session.js";
12
12
  import { a as useSignIn$1, i as SignOut, n as PendingState, o as useSignOut$1, r as SignIn, t as AuthHookOptions } from "../sign-in-D54FLMQy.js";
13
13
  //#region src/react/server.d.ts
@@ -2,7 +2,7 @@ import { t as escapeLike } from "../escape-like-DHfx6jRr.js";
2
2
  import { d as useSupabase, i as BetterSupabaseProvider, o as useAuth, s as useBroadcast, u as useLiveQuery } from "../sign-in-CmPK1AgM.js";
3
3
  import { t as supportOf } from "../support-view-g4YLBeqX.js";
4
4
  import { d as fieldErrorsOf } from "../data-hooks-tgF1Ct0F.js";
5
- import "../react-CZUZYn9E.js";
5
+ import "../react-zBTxLsV6.js";
6
6
  import { t as tenantOf } from "../tenant-BgIiMQpo.js";
7
7
  import { SessionProvider } from "./session.js";
8
8
  //#region src/react/server.ts
@@ -8,7 +8,7 @@ import { H as rpcTransport } from "./block-helpers-CtBdjgO4.js";
8
8
  import { r as createBlocks } from "./create-blocks-Bu4H5TXw.js";
9
9
  import { a as recordCan, i as plainData, l as runBindingWrite, s as recordSubject } from "./record-type-DRbnlj5q.js";
10
10
  import { t as createRecordController } from "./controller-BNZKd6bJ.js";
11
- import { t as relayRealtimeClient } from "./relay-gKvKJ3xf.js";
11
+ import { t as relayRealtimeClient } from "./relay-CIKcAVjf.js";
12
12
  import { a as ttlSeconds, n as scaleTransform, r as transformFor } from "./variants-Cy--Ub-a.js";
13
13
  import { createContext, createElement, use, useCallback, useContext, useEffect, useMemo, useRef, useState, useSyncExternalStore, useTransition } from "react";
14
14
  //#region src/react/actions.ts
@@ -3,6 +3,6 @@ import { et as TemplateParams, tt as TemplateValues } from "../bucket-vc-QRrva.j
3
3
  import { t as RealtimeStatus } from "../realtime-status-BhNkb-Ow.js";
4
4
  import { A as TriggerTopic, C as TopicSubscription, D as TriggerLookup, E as TopicTriggerValue, F as FanOutResult, I as TopicFanOutOptions, M as defineTopic, N as rowChange, O as TriggerOptions, P as rowKeys, S as TopicSubscribeOptions, T as TopicTriggerOptions, _ as TopicMessage, a as PresenceOutput, b as TopicPermission, c as RealtimeClient, d as SubscribeOptions, f as Subscription, g as TopicHandlers, h as TopicEvent, i as PresenceOptions, j as TriggerValue, k as TriggerPayloadMode, l as RowChange, m as Topic, n as PresenceInput, o as PresenceSchema, p as SubscriptionStatus, r as PresenceMember, s as PresenceSubscription, t as EventSchemas, u as RowKeys, v as TopicOptions, w as TopicTriggerLookup, x as TopicSqlOptions, y as TopicPayload } from "../topic-nQYxoTaU.js";
5
5
  import { a as watchTopic, i as topicPort, n as TopicPort, r as TopicWatch, t as TopicHandle } from "../watch-topic-UGSEWAqR.js";
6
- import { S as relayTopicPort, _ as subjectPresenceValues, a as LiveSource, b as RelayEventSourceConstructor, c as liveCount, d as realtimeChanges, f as SUBJECT_PRESENCE_TEMPLATE, g as subjectPresenceTopic, h as subjectPresence, i as LiveQueryOptions, l as liveQuery, m as SubjectPresenceValues, n as LiveCountOptions, o as LiveSubscription, p as SubjectPresenceTopic, r as LiveCountSeed, s as RealtimeChangesOptions, t as CountRunner, u as liveTopic, v as RelayClientOptions, x as relayRealtimeClient, y as RelayEventSource } from "../index-BH3NYExp.js";
6
+ import { S as relayTopicPort, _ as subjectPresenceValues, a as LiveSource, b as RelayEventSourceConstructor, c as liveCount, d as realtimeChanges, f as SUBJECT_PRESENCE_TEMPLATE, g as subjectPresenceTopic, h as subjectPresence, i as LiveQueryOptions, l as liveQuery, m as SubjectPresenceValues, n as LiveCountOptions, o as LiveSubscription, p as SubjectPresenceTopic, r as LiveCountSeed, s as RealtimeChangesOptions, t as CountRunner, u as liveTopic, v as RelayClientOptions, x as relayRealtimeClient, y as RelayEventSource } from "../index-DmbCyl6Z.js";
7
7
  import { n as subjectReaders, t as SubjectReadersOptions } from "../subject-readers-8GySC9Z8.js";
8
8
  export { type AccessPolicySql, type AccessTopicPolicy, type CountRunner, type EventSchemas, type FanOutResult, type LiveCountOptions, type LiveCountSeed, type LiveQueryOptions, type LiveSource, type LiveSubscription, type PresenceInput, type PresenceMember, type PresenceOptions, type PresenceOutput, type PresenceSchema, type PresenceSubscription, type RealtimeChangesOptions, type RealtimeClient, type RealtimeStatus, type RelayClientOptions, type RelayEventSource, type RelayEventSourceConstructor, type RowChange, type RowKeys, SUBJECT_PRESENCE_TEMPLATE, type SubjectPresenceTopic, type SubjectPresenceValues, type SubjectReadersOptions, type SubscribeOptions, type Subscription, type SubscriptionStatus, type TemplateParams, type TemplateValues, type Topic, type TopicEvent, type TopicFanOutOptions, type TopicHandle, type TopicHandlers, type TopicMessage, type TopicOptions, type TopicPayload, type TopicPermission, type TopicPort, type TopicSqlOptions, type TopicSubscribeOptions, type TopicSubscription, type TopicTriggerLookup, type TopicTriggerOptions, type TopicTriggerValue, type TopicWatch, type TriggerLookup, type TriggerOptions, type TriggerPayloadMode, type TriggerTopic, type TriggerValue, defineTopic, liveCount, liveQuery, liveTopic, realtimeChanges, relayRealtimeClient, relayTopicPort, rowChange, rowKeys, subjectPresence, subjectPresenceTopic, subjectPresenceValues, subjectReaders, topicPort, watchTopic };
@@ -1,6 +1,6 @@
1
1
  import { i as realtimeChanges, n as liveQuery, r as liveTopic, t as liveCount } from "../live-C21DgbsD.js";
2
2
  import { n as watchTopic, t as topicPort } from "../watch-topic-CuaWfCuv.js";
3
- import { n as relayTopicPort, t as relayRealtimeClient } from "../relay-gKvKJ3xf.js";
3
+ import { n as relayTopicPort, t as relayRealtimeClient } from "../relay-CIKcAVjf.js";
4
4
  import { t as subjectReaders } from "../subject-readers-B-pQ9Mmo.js";
5
5
  import { n as rowChange, r as rowKeys, t as defineTopic } from "../topic-J9I3yu6f.js";
6
6
  //#region src/realtime/subject-presence.ts
@@ -15,6 +15,10 @@ function globalEventSource() {
15
15
  return typeof value === "function" ? value : void 0;
16
16
  }
17
17
  const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
18
+ async function problemDetail(response) {
19
+ const problem = await response.json().catch(() => void 0);
20
+ return isRecord(problem) && typeof problem["detail"] === "string" ? problem["detail"] : isRecord(problem) && typeof problem["title"] === "string" ? problem["title"] : response.statusText;
21
+ }
18
22
  /**
19
23
  * A Realtime client that joins topics through `realtimeRelay` on the server
20
24
  * instead of a browser connection with the user's token: for support sessions
@@ -52,12 +56,10 @@ function relayRealtimeClient(url, options = {}) {
52
56
  await response.body?.cancel();
53
57
  return { success: true };
54
58
  }
55
- const problem = await response.json().catch(() => void 0);
56
- const detail = isRecord(problem) && typeof problem["detail"] === "string" ? problem["detail"] : isRecord(problem) && typeof problem["title"] === "string" ? problem["title"] : response.statusText;
57
59
  return {
58
60
  success: false,
59
61
  status: response.status,
60
- error: detail
62
+ error: await problemDetail(response)
61
63
  };
62
64
  } catch (cause) {
63
65
  return {
@@ -67,8 +69,24 @@ function relayRealtimeClient(url, options = {}) {
67
69
  };
68
70
  }
69
71
  };
72
+ const failureOf = async (streamUrl) => {
73
+ const controller = new AbortController();
74
+ try {
75
+ const response = await (options.fetch ?? globalThis.fetch.bind(globalThis))(streamUrl, {
76
+ credentials: "include",
77
+ headers: { accept: "text/event-stream" },
78
+ signal: controller.signal
79
+ });
80
+ return response.ok ? void 0 : `${String(response.status)} ${await problemDetail(response)}`.trim();
81
+ } catch {
82
+ return;
83
+ } finally {
84
+ controller.abort();
85
+ }
86
+ };
70
87
  const create = (name) => {
71
88
  const topic = `realtime:${name}`;
89
+ const streamUrl = `${url}${url.includes("?") ? "&" : "?"}topic=${encodeURIComponent(name)}`;
72
90
  const listeners = [];
73
91
  let presence = {};
74
92
  let source;
@@ -76,31 +94,54 @@ function relayRealtimeClient(url, options = {}) {
76
94
  let subscribed = false;
77
95
  let ending = false;
78
96
  let removed = false;
97
+ let stopped = false;
98
+ let failed = false;
79
99
  let backoff = 1e3;
80
100
  let joinTimer;
81
101
  let retryTimer;
82
102
  const dispatch = (type, event, message) => {
83
103
  for (const listener of listeners) if (listener.event === `${type}:*` || listener.event === `${type}:${event}`) listener.callback(message);
84
104
  };
105
+ const timedOut = () => {
106
+ if (subscribed || removed) return;
107
+ stopped = true;
108
+ clearTimeout(retryTimer);
109
+ source?.close();
110
+ source = void 0;
111
+ if (!failed) {
112
+ status?.("TIMED_OUT");
113
+ return;
114
+ }
115
+ failureOf(streamUrl).then((failure) => {
116
+ if (!removed) status?.("TIMED_OUT", /* @__PURE__ */ new Error(failure === void 0 ? `The relay could not join ${name}` : `The relay could not join ${name}: ${failure}`));
117
+ });
118
+ };
85
119
  const open = () => {
86
- if (removed) return;
120
+ if (removed || stopped) return;
87
121
  const Source = options.EventSource ?? globalEventSource();
88
122
  if (Source === void 0) {
123
+ clearTimeout(joinTimer);
89
124
  status?.("CHANNEL_ERROR", /* @__PURE__ */ new Error("relayRealtimeClient needs EventSource"));
90
125
  return;
91
126
  }
92
- const next = new Source(`${url}${url.includes("?") ? "&" : "?"}topic=${encodeURIComponent(name)}`, { withCredentials: true });
127
+ const next = new Source(streamUrl, { withCredentials: true });
128
+ let joined = false;
129
+ const retry = (message) => {
130
+ next.close();
131
+ source = void 0;
132
+ failed = true;
133
+ status?.("CHANNEL_ERROR", new Error(message));
134
+ retryTimer = setTimeout(open, backoff);
135
+ backoff = Math.min(backoff * 2, maxBackoffMs);
136
+ };
93
137
  source = next;
94
- clearTimeout(joinTimer);
95
- joinTimer = setTimeout(() => {
96
- if (!subscribed && source === next) status?.("TIMED_OUT");
97
- }, timeoutMs);
98
138
  next.addEventListener("status", (event) => {
99
139
  const data = parse(event);
100
140
  if (!isRecord(data) || source !== next) return;
101
141
  if (data["status"] === "subscribed") {
102
142
  clearTimeout(joinTimer);
103
143
  subscribed = true;
144
+ joined = true;
104
145
  ending = false;
105
146
  backoff = 1e3;
106
147
  status?.("SUBSCRIBED");
@@ -121,8 +162,15 @@ function relayRealtimeClient(url, options = {}) {
121
162
  presence = Object.fromEntries(Object.entries(data).filter((entry) => Array.isArray(entry[1])));
122
163
  dispatch("presence", "sync", {});
123
164
  });
124
- next.addEventListener("end", () => {
125
- ending = true;
165
+ next.addEventListener("end", (event) => {
166
+ if (removed || source !== next) return;
167
+ if (joined) {
168
+ ending = true;
169
+ return;
170
+ }
171
+ const data = parse(event);
172
+ const reason = isRecord(data) && typeof data["reason"] === "string" ? data["reason"] : "closed";
173
+ retry(`The relay could not join ${name} (${reason}); retrying`);
126
174
  });
127
175
  next.addEventListener("error", () => {
128
176
  if (removed || source !== next) return;
@@ -130,16 +178,7 @@ function relayRealtimeClient(url, options = {}) {
130
178
  if (subscribed && !ending) status?.("CHANNEL_ERROR", /* @__PURE__ */ new Error(`The relay connection for ${name} dropped`));
131
179
  return;
132
180
  }
133
- next.close();
134
- source = void 0;
135
- if (!subscribed) {
136
- clearTimeout(joinTimer);
137
- status?.("CHANNEL_ERROR", /* @__PURE__ */ new Error(`The relay refused ${name}`));
138
- return;
139
- }
140
- status?.("CHANNEL_ERROR", /* @__PURE__ */ new Error(`The relay closed ${name}; reconnecting`));
141
- retryTimer = setTimeout(open, backoff);
142
- backoff = Math.min(backoff * 2, maxBackoffMs);
181
+ retry(subscribed ? `The relay closed ${name}; reconnecting` : `The relay could not join ${name}; retrying`);
143
182
  });
144
183
  };
145
184
  const close = () => {
@@ -161,6 +200,7 @@ function relayRealtimeClient(url, options = {}) {
161
200
  subscribe(callback) {
162
201
  if (status !== void 0 || removed) throw new Error(`tried to subscribe multiple times to ${name} on the relay`);
163
202
  status = callback ?? (() => void 0);
203
+ joinTimer = setTimeout(timedOut, timeoutMs);
164
204
  open();
165
205
  return channel;
166
206
  },
@@ -228,7 +228,8 @@ interface RelayAccessInput {
228
228
  }
229
229
  /**
230
230
  * Decides whether the caller may receive or send on a topic. A throw or
231
- * rejection denies.
231
+ * rejection is a failure that may pass: a join ends with `unavailable` and the
232
+ * client retries, a send answers 503.
232
233
  */
233
234
  type RelayAuthorize = (input: RelayAccessInput) => boolean | PromiseLike<boolean>;
234
235
  /**
@@ -296,7 +297,7 @@ interface RealtimeRelayOptions {
296
297
  readonly problem?: ProblemFormat;
297
298
  }
298
299
  /** Why the relay ended a stream, in its `end` event. */
299
- type RelayEndReason = "expired" | "max_duration" | "overflow" | "closed" | "upstream_error";
300
+ type RelayEndReason = "expired" | "max_duration" | "overflow" | "closed" | "upstream_error" | "unavailable";
300
301
  /**
301
302
  * Whether `claims` may receive or send on `topic`, by the `realtime.messages`
302
303
  * policies, checked the way Realtime checks a join: a probe message is
@@ -214,6 +214,7 @@ async function realtimeTopicAccess(postgres, input) {
214
214
  const encoder = new TextEncoder();
215
215
  const frame = (event, data) => encoder.encode(`event: ${event}\ndata: ${JSON.stringify(data)}\n\n`);
216
216
  const PING = encoder.encode(": ping\n\n");
217
+ const TRANSIENT_AUTH = /* @__PURE__ */ new Set(["network", "unexpected"]);
217
218
  const STREAM_HEADERS = {
218
219
  "content-type": "text/event-stream; charset=utf-8",
219
220
  "cache-control": "no-store, no-transform",
@@ -262,6 +263,10 @@ function realtimeRelay(server, options) {
262
263
  return upstream;
263
264
  };
264
265
  const problem = (error) => problemResponse(error, { format: options.problem });
266
+ const unavailableStream = () => new Response(`retry: ${String(retryMs)}\n\nevent: end\ndata: ${JSON.stringify({ reason: "unavailable" })}\n\n`, {
267
+ status: 200,
268
+ headers: STREAM_HEADERS
269
+ });
265
270
  const topicOf = (name) => options.topics.find((each) => each.match(name) !== null);
266
271
  const allowed = async (input) => {
267
272
  try {
@@ -273,7 +278,7 @@ function realtimeRelay(server, options) {
273
278
  action: input.action
274
279
  }) : false;
275
280
  } catch {
276
- return false;
281
+ return "unavailable";
277
282
  }
278
283
  };
279
284
  const claimsOf = (auth, support) => {
@@ -293,16 +298,18 @@ function realtimeRelay(server, options) {
293
298
  if (!topic) return { refusal: problem(dbError("not_found", `No relayed topic "${name}"`)) };
294
299
  const ctx = await server.context(request, { refresh });
295
300
  const { auth, support } = ctx;
296
- if (auth.kind === "invalid") return { refusal: ctx.apply(problem(auth.error)) };
301
+ if (auth.kind === "invalid") return { refusal: ctx.apply(action === "receive" && TRANSIENT_AUTH.has(auth.error.kind) ? unavailableStream() : problem(auth.error)) };
297
302
  if (!(auth.kind !== "anon") && (topic.private || action === "send")) return { refusal: ctx.apply(problem(dbError("unauthorized", "Sign in to join this topic"))) };
298
303
  if (action === "send" && support?.session.readOnly === true) return { refusal: ctx.apply(problem(readOnlyError())) };
299
- if (!(!topic.private && action === "receive" ? true : await allowed({
304
+ const ok = !topic.private && action === "receive" ? true : await allowed({
300
305
  topic: name,
301
306
  action,
302
307
  auth,
303
308
  support,
304
309
  claims: claimsOf(auth, support)
305
- }))) return { refusal: ctx.apply(problem(dbError("forbidden", `Not allowed to ${action} on "${name}"`))) };
310
+ });
311
+ if (ok === "unavailable") return { refusal: ctx.apply(action === "receive" ? unavailableStream() : problem(dbError("network", `Could not check access to "${name}"`))) };
312
+ if (!ok) return { refusal: ctx.apply(problem(dbError("forbidden", `Not allowed to ${action} on "${name}"`))) };
306
313
  return {
307
314
  topic,
308
315
  ctx
@@ -6,7 +6,7 @@ import { g as TopicHandlers, m as Topic, p as SubscriptionStatus, r as PresenceM
6
6
  import { t as AuthSnapshot } from "../bind-pu5TLrla.js";
7
7
  import { t as AuthSession } from "../view-DyFdMCqg.js";
8
8
  import { n as Controller } from "../controller-BR7CZ1R9.js";
9
- import { C as LiveCountSource, D as ProfileOf, E as PresenceTopic, O as UseActionOptions, S as LiveCountHookOptions, T as PresenceHookOptions, _ as ActionResultOf, a as DataRows, b as ClaimsOf, c as DataWrites, d as BlockMutationState, f as BlockQueryActions, g as ActionInputOf, h as BlockRefetchOn, i as DataRow, l as BlockEventSource, m as BlockQueryState, n as DataId, o as DataSource, p as BlockQueryOptions, r as DataListArgs, s as DataState, t as fieldErrorsOf, u as BlockMutationActions, v as ActionState, w as LiveQueryHookOptions, x as ClientLike, y as BroadcastOptions } from "../field-errors-DucQdLl7.js";
9
+ import { C as LiveCountSource, D as ProfileOf, E as PresenceTopic, O as UseActionOptions, S as LiveCountHookOptions, T as PresenceHookOptions, _ as ActionResultOf, a as DataRows, b as ClaimsOf, c as DataWrites, d as BlockMutationState, f as BlockQueryActions, g as ActionInputOf, h as BlockRefetchOn, i as DataRow, l as BlockEventSource, m as BlockQueryState, n as DataId, o as DataSource, p as BlockQueryOptions, r as DataListArgs, s as DataState, t as fieldErrorsOf, u as BlockMutationActions, v as ActionState, w as LiveQueryHookOptions, x as ClientLike, y as BroadcastOptions } from "../field-errors-DkAemDoc.js";
10
10
  import { n as BlockOptions } from "../block-env-CA65ulTD.js";
11
11
  import { n as BlockDataOf, r as BlockMethodName, t as BlockArgsOf } from "../block-method-CiVa2G-J.js";
12
12
  import { t as SupportView } from "../support-view-BYOgwXsJ.js";
@@ -6,7 +6,7 @@ import { g as TopicHandlers, m as Topic, p as SubscriptionStatus, r as PresenceM
6
6
  import { t as AuthSnapshot } from "../bind-pu5TLrla.js";
7
7
  import { t as AuthSession } from "../view-DyFdMCqg.js";
8
8
  import { n as Controller } from "../controller-BR7CZ1R9.js";
9
- import { C as LiveCountSource, D as ProfileOf, E as PresenceTopic, O as UseActionOptions, S as LiveCountHookOptions, T as PresenceHookOptions, _ as ActionResultOf, a as DataRows, b as ClaimsOf, c as DataWrites, d as BlockMutationState, f as BlockQueryActions, g as ActionInputOf, h as BlockRefetchOn, i as DataRow, l as BlockEventSource, m as BlockQueryState, n as DataId, o as DataSource, p as BlockQueryOptions, r as DataListArgs, s as DataState, t as fieldErrorsOf, u as BlockMutationActions, v as ActionState, w as LiveQueryHookOptions, x as ClientLike, y as BroadcastOptions } from "../field-errors-DucQdLl7.js";
9
+ import { C as LiveCountSource, D as ProfileOf, E as PresenceTopic, O as UseActionOptions, S as LiveCountHookOptions, T as PresenceHookOptions, _ as ActionResultOf, a as DataRows, b as ClaimsOf, c as DataWrites, d as BlockMutationState, f as BlockQueryActions, g as ActionInputOf, h as BlockRefetchOn, i as DataRow, l as BlockEventSource, m as BlockQueryState, n as DataId, o as DataSource, p as BlockQueryOptions, r as DataListArgs, s as DataState, t as fieldErrorsOf, u as BlockMutationActions, v as ActionState, w as LiveQueryHookOptions, x as ClientLike, y as BroadcastOptions } from "../field-errors-DkAemDoc.js";
10
10
  import { n as BlockOptions } from "../block-env-CA65ulTD.js";
11
11
  import { n as BlockDataOf, r as BlockMethodName, t as BlockArgsOf } from "../block-method-CiVa2G-J.js";
12
12
  import { SupabaseClient } from "@supabase/supabase-js";
@@ -6,7 +6,7 @@ import { g as TopicHandlers, m as Topic, p as SubscriptionStatus, r as PresenceM
6
6
  import { t as AuthSnapshot } from "../bind-pu5TLrla.js";
7
7
  import { t as AuthSession } from "../view-DyFdMCqg.js";
8
8
  import { n as Controller } from "../controller-BR7CZ1R9.js";
9
- import { C as LiveCountSource, D as ProfileOf, E as PresenceTopic, O as UseActionOptions, S as LiveCountHookOptions, T as PresenceHookOptions, _ as ActionResultOf, a as DataRows, b as ClaimsOf, c as DataWrites, d as BlockMutationState, f as BlockQueryActions, g as ActionInputOf, h as BlockRefetchOn, i as DataRow, l as BlockEventSource, m as BlockQueryState, n as DataId, o as DataSource, p as BlockQueryOptions, r as DataListArgs, s as DataState, t as fieldErrorsOf, u as BlockMutationActions, v as ActionState, w as LiveQueryHookOptions, x as ClientLike, y as BroadcastOptions } from "../field-errors-DucQdLl7.js";
9
+ import { C as LiveCountSource, D as ProfileOf, E as PresenceTopic, O as UseActionOptions, S as LiveCountHookOptions, T as PresenceHookOptions, _ as ActionResultOf, a as DataRows, b as ClaimsOf, c as DataWrites, d as BlockMutationState, f as BlockQueryActions, g as ActionInputOf, h as BlockRefetchOn, i as DataRow, l as BlockEventSource, m as BlockQueryState, n as DataId, o as DataSource, p as BlockQueryOptions, r as DataListArgs, s as DataState, t as fieldErrorsOf, u as BlockMutationActions, v as ActionState, w as LiveQueryHookOptions, x as ClientLike, y as BroadcastOptions } from "../field-errors-DkAemDoc.js";
10
10
  import { n as BlockOptions } from "../block-env-CA65ulTD.js";
11
11
  import { n as BlockDataOf, r as BlockMethodName, t as BlockArgsOf } from "../block-method-CiVa2G-J.js";
12
12
  import { t as SupportView } from "../support-view-BYOgwXsJ.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "better-supabase",
3
- "version": "0.18.0",
3
+ "version": "0.18.1",
4
4
  "description": "Strongly typed Supabase: generated schema, typed repositories, plugins, auth glue, framework integrations and the better-supabase CLI.",
5
5
  "keywords": [
6
6
  "cli",
@@ -1 +0,0 @@
1
- export { t as addCommand } from "./add-B1S3yK4L.js";
@@ -1 +0,0 @@
1
- export { t as powersyncStreamsCommand } from "./powersync-D-0yV_L_.js";