better-supabase 0.18.0 → 0.18.2

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 (74) hide show
  1. package/dist/{app-tables-XwCviyhP.d.ts → app-tables-atP-tZKZ.d.ts} +1 -1
  2. package/dist/blocks/audit/index.d.ts +1 -1
  3. package/dist/cli/{add-B1S3yK4L.js → add-CbUFLPVA.js} +9 -9
  4. package/dist/cli/{add-D7YIXslp.js → add-ee805E_R.js} +2 -2
  5. package/dist/cli/add-k8gdux-e.js +1 -0
  6. package/dist/cli/{backfill-BwkyNhlC.js → backfill-CCNXzDjt.js} +1 -1
  7. package/dist/cli/bin.js +1 -1
  8. package/dist/cli/{blocks-DDm1Zc2S.js → blocks-CKp4EfLe.js} +1 -1
  9. package/dist/cli/{blocks-CBqENu3C.js → blocks-DNgcfS8X.js} +1 -1
  10. package/dist/cli/{cache-DE2IH1-C.js → cache-CDNVq1vO.js} +1 -1
  11. package/dist/cli/{codemod-OHKhVV-v.js → codemod-B621vQYQ.js} +2 -2
  12. package/dist/cli/{content-mapper-CaygHH_k.js → content-mapper-Chm3txER.js} +2 -2
  13. package/dist/cli/{doctor-D_nrsd9E.js → doctor-EWtWH8I9.js} +15 -15
  14. package/dist/cli/{gen-D7gMEwvg.js → gen-D-g9TAmr.js} +11 -11
  15. package/dist/cli/index.d.ts +1 -1
  16. package/dist/cli/index.js +6 -6
  17. package/dist/cli/{init-ch-HWJyp.js → init-D0SxtKH5.js} +5 -5
  18. package/dist/cli/{legacy-prefix-DkTA3Rhx.js → legacy-prefix-R7UChFFl.js} +18 -5
  19. package/dist/cli/{live-B38ePuRS.js → live-PaO1MC10.js} +2 -2
  20. package/dist/cli/{mcp-P9RP2SJ3.js → mcp-CHpzdlOg.js} +2 -2
  21. package/dist/cli/{metadata-BTihErEc.js → metadata-KKCdxMLb.js} +3 -3
  22. package/dist/cli/{migration-safety-DYo1vVWC.js → migration-safety-Cgr44KLM.js} +1 -1
  23. package/dist/cli/{migrations-BoIyGczt.js → migrations-VmJloDtq.js} +1 -1
  24. package/dist/cli/{module-migration-DXvo0EqU.js → module-migration-D4lirR47.js} +2 -2
  25. package/dist/cli/powersync-Bo16K2S6.js +1 -0
  26. package/dist/cli/{powersync-D-0yV_L_.js → powersync-Cc9Ad_Mn.js} +2 -2
  27. package/dist/cli/{print-CRon4lXf.js → print-CXmXGe3Y.js} +2 -2
  28. package/dist/cli/{remove-D89s99ha.js → remove-CJi3fvpP.js} +5 -5
  29. package/dist/cli/{render-BJF9ytUi.js → render-CVTKsacY.js} +3 -3
  30. package/dist/cli/{run-x9ZY4Tm0.js → run-DvK2vagi.js} +21 -21
  31. package/dist/cli/{run-jeplMBOK.js → run-x9l841K2.js} +8 -8
  32. package/dist/cli/{shared-B38Chjgd.js → shared-FhGSrA9E.js} +1 -1
  33. package/dist/cli/{snapshot-BXmU3IXN.js → snapshot-B12QpZNf.js} +2 -2
  34. package/dist/cli/{source-irttnsEb.js → source-DP8KOgax.js} +1 -1
  35. package/dist/cli/{spec-DzD5wMVF.js → spec-CIQBAQgr.js} +1 -1
  36. package/dist/cli/{spec-CDxfokey.js → spec-D-NPgLTj.js} +2 -2
  37. package/dist/cli/{sql-layout-D8QrNvt4.js → sql-layout-DTczUfCt.js} +2 -2
  38. package/dist/cli/{sync-s1iKFIos.js → sync-DHJ6UBod.js} +3 -3
  39. package/dist/cli/{upgrade-B4FPlK-_.js → upgrade-B69K7-JE.js} +5 -5
  40. package/dist/cli/{upgrade-CluxP3JJ.js → upgrade-C7SEKT4b.js} +2 -2
  41. package/dist/cli/{version-TgFM8sOd.js → version-DmaGTP3L.js} +1 -1
  42. package/dist/config/index.d.ts +1 -1
  43. package/dist/{context-D24k1Cpc.d.ts → context-Cj-9gE6l.d.ts} +4 -2
  44. package/dist/create/index.d.ts +2 -2
  45. package/dist/create/index.js +1 -1
  46. package/dist/{field-errors-DucQdLl7.d.ts → field-errors-DkAemDoc.d.ts} +1 -1
  47. package/dist/{index-XAyzdLns.d.ts → index-DTbJAsrT.d.ts} +2 -2
  48. package/dist/{index-BAcQz5DS.d.ts → index-DVYEoVMK.d.ts} +1 -1
  49. package/dist/{index-4WT_uRRL.d.ts → index-DZylLz7h.d.ts} +1 -1
  50. package/dist/{index-BH3NYExp.d.ts → index-DmbCyl6Z.d.ts} +7 -3
  51. package/dist/mapper/bin.js +5 -5
  52. package/dist/next/index.d.ts +1 -1
  53. package/dist/otel/index.js +4 -4
  54. package/dist/preset/index.d.ts +3 -3
  55. package/dist/react/index.d.ts +3 -3
  56. package/dist/react/index.js +1 -1
  57. package/dist/react/server.d.ts +3 -3
  58. package/dist/react/server.js +1 -1
  59. package/dist/{react-CZUZYn9E.js → react-zBTxLsV6.js} +1 -1
  60. package/dist/realtime/index.d.ts +1 -1
  61. package/dist/realtime/index.js +1 -1
  62. package/dist/{relay-gKvKJ3xf.js → relay-CIKcAVjf.js} +61 -21
  63. package/dist/server/index.d.ts +3 -2
  64. package/dist/server/index.js +11 -4
  65. package/dist/solid/index.d.ts +1 -1
  66. package/dist/sql/index.d.ts +3 -3
  67. package/dist/sql/index.js +1 -1
  68. package/dist/{sql-fHTjZGqR.js → sql-D2Sc6BTr.js} +39 -10
  69. package/dist/svelte/index.d.ts +1 -1
  70. package/dist/testing/index.d.ts +1 -1
  71. package/dist/vue/index.d.ts +1 -1
  72. package/package.json +1 -1
  73. package/dist/cli/add-BQPJnapO.js +0 -1
  74. package/dist/cli/powersync-DXVsKkAu.js +0 -1
@@ -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-B12QpZNf.js";
2
+ import { a as toCatalog } from "./source-DP8KOgax.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-VmJloDtq.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-DTczUfCt.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-D4lirR47.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-VmJloDtq.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-DTczUfCt.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-D4lirR47.js";
6
+ import { a as write, o as topicPolicyFile, r as nextStep } from "./sync-DHJ6UBod.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-DHJ6UBod.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-B69K7-JE.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.2";
3
3
  //#endregion
4
4
  export { VERSION as t };
@@ -1,6 +1,6 @@
1
1
  import { M as Casing } from "../types-DFdg_4yN.js";
2
2
  import { A as tenantNameOf, C as EntityConfig, D as OwnTablePolicies, S as EntitiesConfig, a as AuthorizationProvider, b as DEFAULT_ACTIVE_TENANT, c as AuthorizationScope, d as AccessBlockConfig, f as ActiveTenantSource, g as BlockMode, i as AuthorizationPermission, l as AuthorizationTokenHook, m as BlockConfig, n as AuthorizationMembership, o as AuthorizationRequirement, p as AnyBlocksConfig, r as AuthorizationOperation, s as AuthorizationRoleSource, t as AuthorizationFunctions, u as providerApiProblem, v as BlockScope, x as DisabledRow, y as BlocksConfig } from "../authorization-IiE__z2m.js";
3
- import { $ as blockEntrySource, $n as APP_COLUMN_ACCESS, $r as RpcTypeReference, $t as ResolvedExtensions, A as ValibotGeneratorOptions, Ai as SkillsAgent, An as ExposePrivilege, Ar as CatalogIndex, At as GeneratedFile, B as jsonSchema, Br as ForeignKeyAction, Bt as GeneratorInputSchema, Ci as GenConfig, Cn as TopicTriggerPayloadValueConfig, Cr as CatalogColumn, D as ZodFlavor, Di as MigrationSafetyConfig, Dn as VectorSearchConfig, Dr as CatalogFunction, Dt as resolveJsonSchema, Ei as KeysConfig, En as VectorDistance, Er as CatalogForeignKey, F as nuqs, Fi as IntegrationInfo, Fr as ExtrasDomain, Ft as GeneratorEntitySchemas, G as tenantClaimPaths, Gr as PostgresColumn, Gt as JsonSchemaSource, H as ClaimPaths, Hr as SnapshotBucket, Ht as GeneratorModel, I as FactoriesGeneratorOptions, Ii as SKILLS_AGENTS, Ir as ExtrasFunction, It as GeneratorField, J as blockEntityRenames, Jn as CONFIG_DEFAULTS, Jr as RpcFunction, Jt as SourceConfig, K as BlockEntity, Kr as PostgresFunction, Kt as JsonTypeConfig, L as factories, Lr as ExtrasHook, Lt as GeneratorFunction, M as StandardSchemaGeneratorOptions, Mi as GEN_TASKS, Mn as Privilege, Mr as CatalogTable, Mt as GeneratorBlock, N as standardSchema, Ni as INTEGRATION_INFO, Nn as ResolvedExpose, Nr as CatalogTrigger, Nt as GeneratorBlockEntity, O as ZodGeneratorOptions, Oi as OpenApiConfig, On as ColumnPrivilege, Or as CatalogFunctionArg, Ot as ClaimsConfig, P as NuqsGeneratorOptions, Pi as INTEGRATION_NAMES, Pr as CatalogUnique, Pt as GeneratorColumn, Q as RENAMED_CONFIG_KEYS, Qr as RpcReturnColumn, Qt as ResolvedConfig, R as JsonSchemaGeneratorOptions, Rr as ExtrasHookFunction, Rt as GeneratorFunctionArg, Si as EnvFileConfig, Sn as TopicTriggerLookupConfig, Sr as CatalogCheck, Ti as IntegrationName, Tn as TopicTriggerValueConfig, Tr as CatalogEnum, U as DEFAULT_CLAIMS, Ur as SnapshotExtras, Ut as GeneratorNoun, V as JsonSchemaTarget, Vr as Snapshot, Vt as GeneratorJsonSchema, W as claimPaths, Wr as GeneratorMetadata, Wt as GeneratorTable, X as CONFIG_GROUPS, Xr as RpcFunctionOverload, Xt as DataHooksFramework, Y as blockSubjectTypes, Yr as RpcFunctionArg, Yt as TableConfig, Z as RENAMED_BLOCK_KEYS, Zr as RpcFunctionReturns, Zt as FlatConfig, _n as ResolvedSqlConfig, _r as AppTableEvents, an as BlockInput, ar as AppColumnAccess, at as defineConfig, bn as SqlWorkflow, br as AppTablesConfig, cn as EnvironmentConfig, cr as AppColumnType, ct as BlockTableReference, dn as SqlInput, dr as AppReference, dt as RoleNames, en as ApiConfig, er as APP_COLUMN_FORMATS, et as flattenConfig, fn as ToolingConfig, fr as AppReferenceTarget, ft as TypedReference, gn as RealtimeConfig, gr as AppTableEventKind, hn as BucketConfig, hr as AppTableConfig, in as BetterSupabaseConfig, ir as APP_TABLE_EVENT_KINDS, it as CONFIG_SCHEMA_URL, j as valibot, ji as SkillsConfig, jn as ExposeRole, jr as CatalogPolicy, jt as Generator, k as zod, ki as PowerSyncGenConfig, kn as ExposeConfig, kr as CatalogGrant, kt as CodecsConfig, ln as GenGroupConfig, lr as AppLookupConfig, lt as BucketName, mn as EntitlementsConfig, mr as AppRollupConfig, mt as ExpandedConfig, nn as AppTablesInput, nr as APP_ON_DELETE_ACTIONS, nt as groupEntries, on as BlocksInput, or as AppColumnConfig, ot as resolveConfig, pn as EntitlementPlansSource, pr as AppRollupAggregate, q as blockEntities, qr as PostgresFunctionArg, qt as RelationsConfig, rn as AuthConfig, rr as APP_ROLLUP_AGGREGATES, rt as hasFlatTables, sn as DatabaseConfig, sr as AppColumnFormat, st as AppTableNames, tn as AppTableInput, tr as APP_COLUMN_TYPES, tt as groupConfig, un as OrganizationConfig, ur as AppOnDeleteAction, ut as ConfigReferences, vn as SeedConfig, vr as AppTableSubject, wi as GenTask, wn as TopicTriggerTopicConfig, wr as CatalogColumnGrant, xi as DoctorConfig, xn as TopicTriggerConfig, xr as Catalog, yn as SqlConfig, yr as AppTableVersions, z as buildJsonSchema, zr as ExtrasTable, zt as GeneratorInput } from "../context-D24k1Cpc.js";
3
+ import { $ as blockEntrySource, $n as APP_COLUMN_ACCESS, $r as RpcTypeReference, $t as ResolvedExtensions, A as ValibotGeneratorOptions, Ai as SkillsAgent, An as ExposePrivilege, Ar as CatalogIndex, At as GeneratedFile, B as jsonSchema, Br as ForeignKeyAction, Bt as GeneratorInputSchema, Ci as GenConfig, Cn as TopicTriggerPayloadValueConfig, Cr as CatalogColumn, D as ZodFlavor, Di as MigrationSafetyConfig, Dn as VectorSearchConfig, Dr as CatalogFunction, Dt as resolveJsonSchema, Ei as KeysConfig, En as VectorDistance, Er as CatalogForeignKey, F as nuqs, Fi as IntegrationInfo, Fr as ExtrasDomain, Ft as GeneratorEntitySchemas, G as tenantClaimPaths, Gr as PostgresColumn, Gt as JsonSchemaSource, H as ClaimPaths, Hr as SnapshotBucket, Ht as GeneratorModel, I as FactoriesGeneratorOptions, Ii as SKILLS_AGENTS, Ir as ExtrasFunction, It as GeneratorField, J as blockEntityRenames, Jn as CONFIG_DEFAULTS, Jr as RpcFunction, Jt as SourceConfig, K as BlockEntity, Kr as PostgresFunction, Kt as JsonTypeConfig, L as factories, Lr as ExtrasHook, Lt as GeneratorFunction, M as StandardSchemaGeneratorOptions, Mi as GEN_TASKS, Mn as Privilege, Mr as CatalogTable, Mt as GeneratorBlock, N as standardSchema, Ni as INTEGRATION_INFO, Nn as ResolvedExpose, Nr as CatalogTrigger, Nt as GeneratorBlockEntity, O as ZodGeneratorOptions, Oi as OpenApiConfig, On as ColumnPrivilege, Or as CatalogFunctionArg, Ot as ClaimsConfig, P as NuqsGeneratorOptions, Pi as INTEGRATION_NAMES, Pr as CatalogUnique, Pt as GeneratorColumn, Q as RENAMED_CONFIG_KEYS, Qr as RpcReturnColumn, Qt as ResolvedConfig, R as JsonSchemaGeneratorOptions, Rr as ExtrasHookFunction, Rt as GeneratorFunctionArg, Si as EnvFileConfig, Sn as TopicTriggerLookupConfig, Sr as CatalogCheck, Ti as IntegrationName, Tn as TopicTriggerValueConfig, Tr as CatalogEnum, U as DEFAULT_CLAIMS, Ur as SnapshotExtras, Ut as GeneratorNoun, V as JsonSchemaTarget, Vr as Snapshot, Vt as GeneratorJsonSchema, W as claimPaths, Wr as GeneratorMetadata, Wt as GeneratorTable, X as CONFIG_GROUPS, Xr as RpcFunctionOverload, Xt as DataHooksFramework, Y as blockSubjectTypes, Yr as RpcFunctionArg, Yt as TableConfig, Z as RENAMED_BLOCK_KEYS, Zr as RpcFunctionReturns, Zt as FlatConfig, _n as ResolvedSqlConfig, _r as AppTableEvents, an as BlockInput, ar as AppColumnAccess, at as defineConfig, bn as SqlWorkflow, br as AppTablesConfig, cn as EnvironmentConfig, cr as AppColumnType, ct as BlockTableReference, dn as SqlInput, dr as AppReference, dt as RoleNames, en as ApiConfig, er as APP_COLUMN_FORMATS, et as flattenConfig, fn as ToolingConfig, fr as AppReferenceTarget, ft as TypedReference, gn as RealtimeConfig, gr as AppTableEventKind, hn as BucketConfig, hr as AppTableConfig, in as BetterSupabaseConfig, ir as APP_TABLE_EVENT_KINDS, it as CONFIG_SCHEMA_URL, j as valibot, ji as SkillsConfig, jn as ExposeRole, jr as CatalogPolicy, jt as Generator, k as zod, ki as PowerSyncGenConfig, kn as ExposeConfig, kr as CatalogGrant, kt as CodecsConfig, ln as GenGroupConfig, lr as AppLookupConfig, lt as BucketName, mn as EntitlementsConfig, mr as AppRollupConfig, mt as ExpandedConfig, nn as AppTablesInput, nr as APP_ON_DELETE_ACTIONS, nt as groupEntries, on as BlocksInput, or as AppColumnConfig, ot as resolveConfig, pn as EntitlementPlansSource, pr as AppRollupAggregate, q as blockEntities, qr as PostgresFunctionArg, qt as RelationsConfig, rn as AuthConfig, rr as APP_ROLLUP_AGGREGATES, rt as hasFlatTables, sn as DatabaseConfig, sr as AppColumnFormat, st as AppTableNames, tn as AppTableInput, tr as APP_COLUMN_TYPES, tt as groupConfig, un as OrganizationConfig, ur as AppOnDeleteAction, ut as ConfigReferences, vn as SeedConfig, vr as AppTableSubject, wi as GenTask, wn as TopicTriggerTopicConfig, wr as CatalogColumnGrant, xi as DoctorConfig, xn as TopicTriggerConfig, xr as Catalog, yn as SqlConfig, yr as AppTableVersions, z as buildJsonSchema, zr as ExtrasTable, zt as GeneratorInput } from "../context-Cj-9gE6l.js";
4
4
  import { n as SubjectsConfig, t as SubjectConfig } from "../subjects-DvmQeF_F.js";
5
5
  import { a as FieldFormat, o as FieldFormatInput, r as FIELD_FORMATS } from "../field-formats-CAFNkKSN.js";
6
6
  export { APP_COLUMN_ACCESS, APP_COLUMN_FORMATS, APP_COLUMN_TYPES, APP_ON_DELETE_ACTIONS, APP_ROLLUP_AGGREGATES, APP_TABLE_EVENT_KINDS, type AccessBlockConfig, type ActiveTenantSource, type AnyBlocksConfig, type ApiConfig, type AppColumnAccess, type AppColumnConfig, type AppColumnFormat, type AppColumnType, type AppLookupConfig, type AppOnDeleteAction, type AppReference, type AppReferenceTarget, type AppRollupAggregate, type AppRollupConfig, type AppTableConfig, type AppTableEventKind, type AppTableEvents, type AppTableInput, type AppTableNames, type AppTableSubject, type AppTableVersions, type AppTablesConfig, type AppTablesInput, type AuthConfig, type AuthorizationFunctions, type AuthorizationMembership, type AuthorizationOperation, type AuthorizationPermission, type AuthorizationProvider, type AuthorizationRequirement, type AuthorizationRoleSource, type AuthorizationScope, type AuthorizationTokenHook, type BetterSupabaseConfig, type BlockConfig, type BlockEntity, type BlockInput, type BlockMode, type BlockScope, type BlockTableReference, type BlocksConfig, type BlocksInput, type BucketConfig, type BucketName, CONFIG_DEFAULTS, CONFIG_GROUPS, CONFIG_SCHEMA_URL, type Casing, type Catalog, type CatalogCheck, type CatalogColumn, type CatalogColumnGrant, type CatalogEnum, type CatalogForeignKey, type CatalogFunction, type CatalogFunctionArg, type CatalogGrant, type CatalogIndex, type CatalogPolicy, type CatalogTable, type CatalogTrigger, type CatalogUnique, type ClaimPaths, type ClaimsConfig, type CodecsConfig, type ColumnPrivilege, type ConfigReferences, DEFAULT_ACTIVE_TENANT, DEFAULT_CLAIMS, type DataHooksFramework, type DatabaseConfig, type DisabledRow, type DoctorConfig, type EntitiesConfig, type EntitlementPlansSource, type EntitlementsConfig, type EntityConfig, type EnvFileConfig, type EnvironmentConfig, type ExpandedConfig, type ExposeConfig, type ExposePrivilege, type ExposeRole, type ExtrasDomain, type ExtrasFunction, type ExtrasHook, type ExtrasHookFunction, type ExtrasTable, FIELD_FORMATS, type FactoriesGeneratorOptions, type FieldFormat, type FieldFormatInput, type FlatConfig, type ForeignKeyAction, GEN_TASKS, type GenConfig, type GenGroupConfig, type GenTask, type GeneratedFile, type Generator, type GeneratorBlock, type GeneratorBlockEntity, type GeneratorColumn, type GeneratorEntitySchemas, type GeneratorField, type GeneratorFunction, type GeneratorFunctionArg, type GeneratorInput, type GeneratorInputSchema, type GeneratorJsonSchema, type GeneratorMetadata, type GeneratorModel, type GeneratorNoun, type GeneratorTable, INTEGRATION_INFO, INTEGRATION_NAMES, type IntegrationInfo, type IntegrationName, type JsonSchemaGeneratorOptions, type JsonSchemaSource, type JsonSchemaTarget, type JsonTypeConfig, type KeysConfig, type MigrationSafetyConfig, type NuqsGeneratorOptions, type OpenApiConfig, type OrganizationConfig, type OwnTablePolicies, type PostgresColumn, type PostgresFunction, type PostgresFunctionArg, type PowerSyncGenConfig, type Privilege, RENAMED_BLOCK_KEYS, RENAMED_CONFIG_KEYS, type RealtimeConfig, type RelationsConfig, type ResolvedConfig, type ResolvedExpose, type ResolvedExtensions, type ResolvedSqlConfig, type RoleNames, type RpcFunction, type RpcFunctionArg, type RpcFunctionOverload, type RpcFunctionReturns, type RpcReturnColumn, type RpcTypeReference, SKILLS_AGENTS, type SeedConfig, type SkillsAgent, type SkillsConfig, type Snapshot, type SnapshotBucket, type SnapshotExtras, type SourceConfig, type SqlConfig, type SqlInput, type SqlWorkflow, type StandardSchemaGeneratorOptions, type SubjectConfig, type SubjectsConfig, type TableConfig, type ToolingConfig, type TopicTriggerConfig, type TopicTriggerLookupConfig, type TopicTriggerPayloadValueConfig, type TopicTriggerTopicConfig, type TopicTriggerValueConfig, type TypedReference, type ValibotGeneratorOptions, type VectorDistance, type VectorSearchConfig, type ZodFlavor, type ZodGeneratorOptions, blockEntities, blockEntityRenames, blockEntrySource, blockSubjectTypes, buildJsonSchema, claimPaths, defineConfig, factories, flattenConfig, groupConfig, groupEntries, hasFlatTables, jsonSchema, nuqs, providerApiProblem, resolveConfig, resolveJsonSchema, standardSchema, tenantClaimPaths, tenantNameOf, valibot, zod };
@@ -4022,9 +4022,11 @@ interface BlockSqlContext {
4022
4022
  * lists in `typed`. On a table the app has, the column may be an enum or
4023
4023
  * another type with a text input, so the value goes through
4024
4024
  * `better_supabase.as_column_type`; on the module's own table it stays as it
4025
- * is.
4025
+ * is. With `invalid: "null"`, a value the type rejects, such as a label the
4026
+ * enum lacks, becomes null through `better_supabase.try_column_type` instead
4027
+ * of raising.
4026
4028
  */
4027
- cast(table: string, column: string, value: string): string;
4029
+ cast(table: string, column: string, value: string, invalid?: "raise" | "null"): string;
4028
4030
  /** Whether an optional logical table exists (it can be mapped to `null`). */
4029
4031
  hasTable(table: string): boolean;
4030
4032
  /** Whether the module renders its managed SQL (not adopt or custom mode). */
@@ -1,6 +1,6 @@
1
1
  /// <reference lib="esnext.temporal" />
2
- import { Pn as PresetSpec, Wn as PresetName, ar as AppColumnAccess, ci as Preset, cr as AppColumnType, g as BlockSqlAccessProvider, ht as PresetInput, nr as APP_ON_DELETE_ACTIONS, sr as AppColumnFormat, ur as AppOnDeleteAction, yr as AppTableVersions } from "../context-D24k1Cpc.js";
3
- import { a as DesignChange, p as DesignErrorCode, u as CreateDesign } from "../index-BAcQz5DS.js";
2
+ import { Pn as PresetSpec, Wn as PresetName, ar as AppColumnAccess, ci as Preset, cr as AppColumnType, g as BlockSqlAccessProvider, ht as PresetInput, nr as APP_ON_DELETE_ACTIONS, sr as AppColumnFormat, ur as AppOnDeleteAction, yr as AppTableVersions } from "../context-Cj-9gE6l.js";
3
+ import { a as DesignChange, p as DesignErrorCode, u as CreateDesign } from "../index-DVYEoVMK.js";
4
4
  import { a as SupabaseLint, o as SupabaseOrganization, s as SupabaseProject } from "../management-wtecfrNf.js";
5
5
  import { t as PresetMigrationFile } from "../types-DGHfTW8_.js";
6
6
  //#region src/create/design-computed.d.ts
@@ -2,7 +2,7 @@ import { a as presetOf, d as resolvePreset } from "../config-CD2OGfCG.js";
2
2
  import { C as APP_ON_DELETE_ACTIONS, E as PRESET_CATALOG, a as appIdentifierError, m as isAppDefault, o as appNameLengthError, p as appDefaultError, s as appReservedColumns } from "../app-tables-DyswUg6J.js";
3
3
  import { c as resolveConfig } from "../config-mbVyJwSc.js";
4
4
  import { _ as jsonPointer, a as DesignParseError, h as encodeDesign, n as diffDesigns, o as DesignTooLongError, p as designOf, u as designConfig, v as parseDesign } from "../preset-B3CukUhu.js";
5
- import { R as SQL_MODULES, _ as renderBlocks, i as moduleLayout } from "../sql-fHTjZGqR.js";
5
+ import { R as SQL_MODULES, _ as renderBlocks, i as moduleLayout } from "../sql-D2Sc6BTr.js";
6
6
  //#region src/create/column-keys.ts
7
7
  /** The most options a select takes, and the longest option. */
8
8
  const MAX_OPTIONS = 100;
@@ -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";
@@ -1,4 +1,4 @@
1
- import { Pn as PresetSpec, St as ResolvedPreset, Wn as PresetName, br as AppTablesConfig, ci as Preset, cr as AppColumnType, ei as PresetCatalog, hr as AppTableConfig, or as AppColumnConfig, ri as PresetGlueItem, vt as presetConfig } from "./context-D24k1Cpc.js";
1
+ import { Pn as PresetSpec, St as ResolvedPreset, Wn as PresetName, br as AppTablesConfig, ci as Preset, cr as AppColumnType, ei as PresetCatalog, hr as AppTableConfig, or as AppColumnConfig, ri as PresetGlueItem, vt as presetConfig } from "./context-Cj-9gE6l.js";
2
2
  import { StandardSchemaV1 } from "@standard-schema/spec";
3
3
  //#region src/preset/catalog.generated.d.ts
4
4
  declare const PRESET_CATALOG: PresetCatalog;
@@ -1,7 +1,7 @@
1
1
  import { E as AccessPolicySql } from "./types-DFdg_4yN.js";
2
2
  import { p as AnyBlocksConfig, t as AuthorizationFunctions } from "./authorization-IiE__z2m.js";
3
3
  import { tt as ReadSet } from "./define-Cgru0_kF.js";
4
- import { E as TableGrant, Qt as ResolvedConfig, _ as BlockSqlDeprecation, b as BlockSqlLayout, c as BlockSqlIdType, g as BlockSqlAccessProvider, h as BlockSql, hr as AppTableConfig, jr as CatalogPolicy, o as BlockSqlContractFunction, v as BlockSqlEntitlementsProvider, y as BlockSqlFile } from "./context-D24k1Cpc.js";
4
+ import { E as TableGrant, Qt as ResolvedConfig, _ as BlockSqlDeprecation, b as BlockSqlLayout, c as BlockSqlIdType, g as BlockSqlAccessProvider, h as BlockSql, hr as AppTableConfig, jr as CatalogPolicy, o as BlockSqlContractFunction, v as BlockSqlEntitlementsProvider, y as BlockSqlFile } from "./context-Cj-9gE6l.js";
5
5
  import { t as SubjectConfig } from "./subjects-DvmQeF_F.js";
6
6
  //#region src/sql/render.d.ts
7
7
  /** A module's SQL for `layout`, without header; `undefined` in custom mode. */
@@ -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-DmaGTP3L.js";
2
+ import { a as lastTypesModule, c as writeAtomic, s as typesModuleKey } from "../cli/cache-CDNVq1vO.js";
3
+ import { t as loadSnapshot } from "../cli/snapshot-B12QpZNf.js";
4
+ import { i as renderTypesModule, t as mapperFilePath } from "../cli/render-CVTKsacY.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-Chm3txER.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.2");
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.2")).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.2");
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.2");
261
261
  return betterSupabase.events.on("block", (event) => {
262
262
  const attributes = {
263
263
  ...options.attributes,
@@ -1,4 +1,4 @@
1
- import { Bn as PRESETS, Ct as ResolvedPresetBlock, Et as resolvePreset, Fn as presetFromSpec, Gn as defaultPreset, Hn as PRESET_NAMES, In as presetOfSpec, Kn as isPresetName, Ln as presetSpec, Pn as PresetSpec, Rn as DEFAULT_PRESET_NAME, St as ResolvedPreset, Tt as presetBlockConflict, Un as PresetGroup, Vn as PRESET_GROUPS, Wn as PresetName, _i as PresetValueInfo, _t as expandPreset, ai as DEFAULT_CONVENTIONS, bi as presetValueLabel, bt as PresetConflict, ci as Preset, di as PresetField, ei as PresetCatalog, er as APP_COLUMN_FORMATS, fi as PresetFieldKey, gi as PresetScope, gt as conventionConfig, hi as PresetPlatforms, ht as PresetInput, ii as CONVENTION_FIELDS, li as PresetAccess, mi as PresetFramework, mt as ExpandedConfig, ni as PresetCatalogManifest, oi as PRESET_FRAMEWORKS, pi as PresetFieldValue, pt as ConfigConventions, qn as namedPreset, ri as PresetGlueItem, si as PRESET_TENANT_NAMES, sr as AppColumnFormat, ti as PresetCatalogBlock, ui as PresetConventions, vi as integrationsForFramework, vt as presetConfig, wt as listNames, xt as PresetIntegration, yi as presetField, yt as presetOf, zn as NamedPreset } from "../context-D24k1Cpc.js";
2
- import { A as presetAndDesignOf, C as designFileSource, D as encodeDesign, E as designSchema, F as safeDesignFileSource, I as safeParseDesign, L as appDefaultError, M as presetConfigSource, N as presetInstallCommand, O as isDesignCode, P as readDesignFile, R as isAppDefault, S as designConfig, T as designOf, _ as DesignParseResult, a as DesignChange, b as createUrl, c as diffAppTables, d as DESIGN_FILE, f as DESIGN_FORMAT, g as DesignParseIssue, h as DesignParseError, i as presetGlue, j as presetApplyCommand, k as parseDesign, l as diffDesigns, m as DesignFile, n as glueCommand, o as DesignChangeKind, p as DesignErrorCode, r as presetBlocksSource, s as DiffOptions, t as PROVIDER_COMMENT, u as CreateDesign, v as DesignTooLongError, w as designFormat, x as decodeDesign, y as MAX_DESIGN_CODE_LENGTH, z as PRESET_CATALOG } from "../index-BAcQz5DS.js";
3
- import { i as appReservedColumns, n as appIdentifierError, r as appNameLengthError, t as APP_NAME_MAX } from "../app-tables-XwCviyhP.js";
1
+ import { Bn as PRESETS, Ct as ResolvedPresetBlock, Et as resolvePreset, Fn as presetFromSpec, Gn as defaultPreset, Hn as PRESET_NAMES, In as presetOfSpec, Kn as isPresetName, Ln as presetSpec, Pn as PresetSpec, Rn as DEFAULT_PRESET_NAME, St as ResolvedPreset, Tt as presetBlockConflict, Un as PresetGroup, Vn as PRESET_GROUPS, Wn as PresetName, _i as PresetValueInfo, _t as expandPreset, ai as DEFAULT_CONVENTIONS, bi as presetValueLabel, bt as PresetConflict, ci as Preset, di as PresetField, ei as PresetCatalog, er as APP_COLUMN_FORMATS, fi as PresetFieldKey, gi as PresetScope, gt as conventionConfig, hi as PresetPlatforms, ht as PresetInput, ii as CONVENTION_FIELDS, li as PresetAccess, mi as PresetFramework, mt as ExpandedConfig, ni as PresetCatalogManifest, oi as PRESET_FRAMEWORKS, pi as PresetFieldValue, pt as ConfigConventions, qn as namedPreset, ri as PresetGlueItem, si as PRESET_TENANT_NAMES, sr as AppColumnFormat, ti as PresetCatalogBlock, ui as PresetConventions, vi as integrationsForFramework, vt as presetConfig, wt as listNames, xt as PresetIntegration, yi as presetField, yt as presetOf, zn as NamedPreset } from "../context-Cj-9gE6l.js";
2
+ import { A as presetAndDesignOf, C as designFileSource, D as encodeDesign, E as designSchema, F as safeDesignFileSource, I as safeParseDesign, L as appDefaultError, M as presetConfigSource, N as presetInstallCommand, O as isDesignCode, P as readDesignFile, R as isAppDefault, S as designConfig, T as designOf, _ as DesignParseResult, a as DesignChange, b as createUrl, c as diffAppTables, d as DESIGN_FILE, f as DESIGN_FORMAT, g as DesignParseIssue, h as DesignParseError, i as presetGlue, j as presetApplyCommand, k as parseDesign, l as diffDesigns, m as DesignFile, n as glueCommand, o as DesignChangeKind, p as DesignErrorCode, r as presetBlocksSource, s as DiffOptions, t as PROVIDER_COMMENT, u as CreateDesign, v as DesignTooLongError, w as designFormat, x as decodeDesign, y as MAX_DESIGN_CODE_LENGTH, z as PRESET_CATALOG } from "../index-DVYEoVMK.js";
3
+ import { i as appReservedColumns, n as appIdentifierError, r as appNameLengthError, t as APP_NAME_MAX } from "../app-tables-atP-tZKZ.js";
4
4
  export { APP_COLUMN_FORMATS, APP_NAME_MAX, type AppColumnFormat, CONVENTION_FIELDS, type ConfigConventions, type CreateDesign, DEFAULT_CONVENTIONS, DEFAULT_PRESET_NAME, DESIGN_FILE, DESIGN_FORMAT, type DesignChange, type DesignChangeKind, type DesignErrorCode, type DesignFile, DesignParseError, type DesignParseIssue, type DesignParseResult, DesignTooLongError, type DiffOptions, type ExpandedConfig, MAX_DESIGN_CODE_LENGTH, type NamedPreset, PRESETS, PRESET_CATALOG, PRESET_FRAMEWORKS, PRESET_GROUPS, PRESET_NAMES, PRESET_TENANT_NAMES, PROVIDER_COMMENT, type Preset, type PresetAccess, type PresetCatalog, type PresetCatalogBlock, type PresetCatalogManifest, type PresetConflict, type PresetConventions, type PresetField, type PresetFieldKey, type PresetFieldValue, type PresetFramework, type PresetGlueItem, type PresetGroup, type PresetInput, type PresetIntegration, type PresetName, type PresetPlatforms, type PresetScope, type PresetSpec, type PresetValueInfo, type ResolvedPreset, type ResolvedPresetBlock, appDefaultError, appIdentifierError, appNameLengthError, appReservedColumns, conventionConfig, createUrl, decodeDesign, defaultPreset, designConfig, designFileSource, designFormat, designOf, designSchema, diffAppTables, diffDesigns, encodeDesign, expandPreset, glueCommand, integrationsForFramework, isAppDefault, isDesignCode, isPresetName, listNames, namedPreset, parseDesign, presetAndDesignOf, presetApplyCommand, presetBlockConflict, presetBlocksSource, presetConfig, presetConfigSource, presetField, presetFromSpec, presetGlue, presetInstallCommand, presetOf, presetOfSpec, presetSpec, presetValueLabel, readDesignFile, resolvePreset, safeDesignFileSource, safeParseDesign };
@@ -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