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
@@ -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";
@@ -1,5 +1,5 @@
1
1
  import { M as BlockOptionsRegistry, j as BLOCK_OPTION_SCHEMAS, k as resolveBlock } from "../authorization-IiE__z2m.js";
2
- import { C as OwnView, Qn as auditRegistrations, S as BlockSqlUpgrade, T as notNullCheckName, Xn as sameTenantLayout, Yn as DeclaredForeignKey, Zn as AuditedTable, _ as BlockSqlDeprecation, a as BlockSqlContext, b as BlockSqlLayout, c as BlockSqlIdType, d as MODULE_ID_TYPES, f as contractSignature, g as BlockSqlAccessProvider, h as BlockSql, i as BlockSqlAudit, l as BlockSqlNames, m as moduleIdType, n as AuditCategory, o as BlockSqlContractFunction, p as isBlockSqlIdType, r as BlockSqlAction, s as BlockSqlEmit, t as AUDIT_CATEGORIES, u as BlockSqlTableSpec, v as BlockSqlEntitlementsProvider, w as blockSqlVersion, x as BlockSqlTestFile, y as BlockSqlFile } from "../context-D24k1Cpc.js";
3
- import { a as appTableEventTypes } from "../app-tables-XwCviyhP.js";
4
- import { $ as BlockSqlPermissionKey, A as tenantsQuery, B as AdoptedView, C as declaredUpdatedAtTriggers, Ct as moduleBody, D as rlsTables, E as policyGrants, F as SECRET_COLUMNS, G as APP_TABLES_MARKER, H as adoptedTables, I as dataExportPlan, J as DEFAULT_ROLES, K as APP_TABLES_MODULE, L as excludedColumns, M as sameTenantColumn, N as sameTenantTrigger, O as subjectColumns, P as DataExportPlan, Q as BlockSqlExtension, R as resolveExposeColumns, S as declaredTables, St as customContracts, T as extensionSchema, Tt as renderBlocks, U as adoptedViews, V as adoptedColumnProblems, W as moduleWritesText, X as SQL_MODULES, Y as instanceFunctions, Z as resolveBlocks, _ as templateFunctions, _t as BlockSqlUpgradePlan, a as scopePolicyName, at as isModuleDataFile, b as declaredColumnTypes, bt as upgradePlan, c as compileReadSet, ct as moduleDataDir, d as MigrationOptionUse, dt as EntityRenameStep, et as moduleEventTriggers, f as migrationOptionUses, ft as entityRenamePlan, g as scopeProblems, gt as renamedBlock, h as resolveProviderSql, ht as formerBlockName, i as TENANT_SCOPE_POLICY, it as blockFileState, j as expiredFlagsQuery, k as TenantQuery, l as compileReadSets, lt as moduleFilePaths, m as SCOPE_ID_TYPES, mt as currentBlockName, n as declaredPolicies, nt as modulePermissionKeys, o as hasColumnAccess, ot as moduleFileVersion, p as moduleLayout, pt as BLOCK_RENAMES, q as appTablesFiles, r as widenedCommands, rt as moduleSchemaExtensions, s as CompiledReadSet, st as sameBlockFile, t as appTablePolicyNotes, tt as moduleHidingColumns, u as sharedRolesProblems, ut as EntityRenamePlan, v as DeclaredView, vt as InstalledBlock, w as declaredViews, wt as moduleTopics, x as declaredTableColumns, xt as BlockSqlTopic, y as PolicyGrant, yt as moduleDeprecations, z as AdoptedTable } from "../index-4WT_uRRL.js";
2
+ import { C as OwnView, Qn as auditRegistrations, S as BlockSqlUpgrade, T as notNullCheckName, Xn as sameTenantLayout, Yn as DeclaredForeignKey, Zn as AuditedTable, _ as BlockSqlDeprecation, a as BlockSqlContext, b as BlockSqlLayout, c as BlockSqlIdType, d as MODULE_ID_TYPES, f as contractSignature, g as BlockSqlAccessProvider, h as BlockSql, i as BlockSqlAudit, l as BlockSqlNames, m as moduleIdType, n as AuditCategory, o as BlockSqlContractFunction, p as isBlockSqlIdType, r as BlockSqlAction, s as BlockSqlEmit, t as AUDIT_CATEGORIES, u as BlockSqlTableSpec, v as BlockSqlEntitlementsProvider, w as blockSqlVersion, x as BlockSqlTestFile, y as BlockSqlFile } from "../context-Cj-9gE6l.js";
3
+ import { a as appTableEventTypes } from "../app-tables-atP-tZKZ.js";
4
+ import { $ as BlockSqlPermissionKey, A as tenantsQuery, B as AdoptedView, C as declaredUpdatedAtTriggers, Ct as moduleBody, D as rlsTables, E as policyGrants, F as SECRET_COLUMNS, G as APP_TABLES_MARKER, H as adoptedTables, I as dataExportPlan, J as DEFAULT_ROLES, K as APP_TABLES_MODULE, L as excludedColumns, M as sameTenantColumn, N as sameTenantTrigger, O as subjectColumns, P as DataExportPlan, Q as BlockSqlExtension, R as resolveExposeColumns, S as declaredTables, St as customContracts, T as extensionSchema, Tt as renderBlocks, U as adoptedViews, V as adoptedColumnProblems, W as moduleWritesText, X as SQL_MODULES, Y as instanceFunctions, Z as resolveBlocks, _ as templateFunctions, _t as BlockSqlUpgradePlan, a as scopePolicyName, at as isModuleDataFile, b as declaredColumnTypes, bt as upgradePlan, c as compileReadSet, ct as moduleDataDir, d as MigrationOptionUse, dt as EntityRenameStep, et as moduleEventTriggers, f as migrationOptionUses, ft as entityRenamePlan, g as scopeProblems, gt as renamedBlock, h as resolveProviderSql, ht as formerBlockName, i as TENANT_SCOPE_POLICY, it as blockFileState, j as expiredFlagsQuery, k as TenantQuery, l as compileReadSets, lt as moduleFilePaths, m as SCOPE_ID_TYPES, mt as currentBlockName, n as declaredPolicies, nt as modulePermissionKeys, o as hasColumnAccess, ot as moduleFileVersion, p as moduleLayout, pt as BLOCK_RENAMES, q as appTablesFiles, r as widenedCommands, rt as moduleSchemaExtensions, s as CompiledReadSet, st as sameBlockFile, t as appTablePolicyNotes, tt as moduleHidingColumns, u as sharedRolesProblems, ut as EntityRenamePlan, v as DeclaredView, vt as InstalledBlock, w as declaredViews, wt as moduleTopics, x as declaredTableColumns, xt as BlockSqlTopic, y as PolicyGrant, yt as moduleDeprecations, z as AdoptedTable } from "../index-DZylLz7h.js";
5
5
  export { APP_TABLES_MARKER, APP_TABLES_MODULE, AUDIT_CATEGORIES, type AdoptedTable, type AdoptedView, type AuditCategory, type AuditedTable, BLOCK_OPTION_SCHEMAS, BLOCK_RENAMES, type BlockOptionsRegistry, type BlockSql, type BlockSqlAccessProvider, type BlockSqlAction, type BlockSqlAudit, type BlockSqlContext, type BlockSqlContractFunction, type BlockSqlDeprecation, type BlockSqlEmit, type BlockSqlEntitlementsProvider, type BlockSqlExtension, type BlockSqlFile, type BlockSqlIdType, type BlockSqlLayout, type BlockSqlNames, type BlockSqlPermissionKey, type BlockSqlTableSpec, type BlockSqlTestFile, type BlockSqlTopic, type BlockSqlUpgrade, type BlockSqlUpgradePlan, type CompiledReadSet, DEFAULT_ROLES, type DataExportPlan, type DeclaredForeignKey, type DeclaredView, type EntityRenamePlan, type EntityRenameStep, type InstalledBlock, MODULE_ID_TYPES, type MigrationOptionUse, type OwnView, type PolicyGrant, SCOPE_ID_TYPES, SECRET_COLUMNS, SQL_MODULES, TENANT_SCOPE_POLICY, type TenantQuery, adoptedColumnProblems, adoptedTables, adoptedViews, appTableEventTypes, appTablePolicyNotes, appTablesFiles, auditRegistrations, blockFileState, blockSqlVersion, compileReadSet, compileReadSets, contractSignature, currentBlockName, customContracts, dataExportPlan, declaredColumnTypes, declaredPolicies, declaredTableColumns, declaredTables, declaredUpdatedAtTriggers, declaredViews, entityRenamePlan, excludedColumns, expiredFlagsQuery, extensionSchema, formerBlockName, hasColumnAccess, instanceFunctions, isBlockSqlIdType, isModuleDataFile, migrationOptionUses, moduleBody, moduleDataDir, moduleDeprecations, moduleEventTriggers, moduleFilePaths, moduleFileVersion, moduleHidingColumns, moduleIdType, moduleLayout, modulePermissionKeys, moduleSchemaExtensions, moduleTopics, moduleWritesText, notNullCheckName, policyGrants, renamedBlock, renderBlocks, resolveBlock, resolveBlocks, resolveExposeColumns, resolveProviderSql, rlsTables, sameBlockFile, sameTenantColumn, sameTenantLayout, sameTenantTrigger, scopePolicyName, scopeProblems, sharedRolesProblems, subjectColumns, templateFunctions, tenantsQuery, upgradePlan, widenedCommands };
package/dist/sql/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { A as resolveBlock, l as appTableEventTypes, v as hasColumnAccess } from "../app-tables-DyswUg6J.js";
2
2
  import { c as templateFunctions, o as resolveProviderSql, s as scopeProblems, t as SCOPE_ID_TYPES } from "../access-sql-CNIgUqWf.js";
3
3
  import { Y as notNullCheckName, a as DEFAULT_ROLES } from "../workflow-sdk-DELaQEp3.js";
4
- import { $ as AUDIT_CATEGORIES, A as blockFileState, B as TENANT_SCOPE_POLICY, C as moduleDataDir, D as appTablesFiles, E as APP_TABLES_MODULE, F as moduleHidingColumns, G as subjectColumns, H as resolveExposeColumns, I as modulePermissionKeys, J as migrationOptionUses, K as sameTenantColumn, L as moduleSchemaExtensions, M as moduleFileVersion, N as sameBlockFile, O as scopePolicyName, P as moduleEventTriggers, Q as renamedBlock, R as SQL_MODULES, S as widenedCommands, T as APP_TABLES_MARKER, U as SECRET_COLUMNS, V as excludedColumns, W as dataExportPlan, X as currentBlockName, Y as BLOCK_RENAMES, Z as formerBlockName, _ as renderBlocks, a as tenantsQuery, at as declaredColumnTypes, b as appTablePolicyNotes, c as adoptedColumnProblems, ct as declaredUpdatedAtTriggers, d as moduleWritesText, dt as policyGrants, et as MODULE_ID_TYPES, f as instanceFunctions, ft as rlsTables, g as moduleTopics, h as moduleBody, i as moduleLayout, it as BLOCK_OPTION_SCHEMAS, j as isModuleDataFile, k as blockSqlVersion, l as adoptedTables, lt as declaredViews, m as customContracts, n as compileReadSets, nt as isBlockSqlIdType, o as expiredFlagsQuery, ot as declaredTableColumns, p as entityRenamePlan, pt as auditRegistrations, q as sameTenantTrigger, r as sharedRolesProblems, rt as moduleIdType, s as sameTenantLayout, st as declaredTables, t as compileReadSet, tt as contractSignature, u as adoptedViews, ut as extensionSchema, v as moduleDeprecations, w as moduleFilePaths, x as declaredPolicies, y as upgradePlan, z as resolveBlocks } from "../sql-fHTjZGqR.js";
4
+ import { $ as AUDIT_CATEGORIES, A as blockFileState, B as TENANT_SCOPE_POLICY, C as moduleDataDir, D as appTablesFiles, E as APP_TABLES_MODULE, F as moduleHidingColumns, G as subjectColumns, H as resolveExposeColumns, I as modulePermissionKeys, J as migrationOptionUses, K as sameTenantColumn, L as moduleSchemaExtensions, M as moduleFileVersion, N as sameBlockFile, O as scopePolicyName, P as moduleEventTriggers, Q as renamedBlock, R as SQL_MODULES, S as widenedCommands, T as APP_TABLES_MARKER, U as SECRET_COLUMNS, V as excludedColumns, W as dataExportPlan, X as currentBlockName, Y as BLOCK_RENAMES, Z as formerBlockName, _ as renderBlocks, a as tenantsQuery, at as declaredColumnTypes, b as appTablePolicyNotes, c as adoptedColumnProblems, ct as declaredUpdatedAtTriggers, d as moduleWritesText, dt as policyGrants, et as MODULE_ID_TYPES, f as instanceFunctions, ft as rlsTables, g as moduleTopics, h as moduleBody, i as moduleLayout, it as BLOCK_OPTION_SCHEMAS, j as isModuleDataFile, k as blockSqlVersion, l as adoptedTables, lt as declaredViews, m as customContracts, n as compileReadSets, nt as isBlockSqlIdType, o as expiredFlagsQuery, ot as declaredTableColumns, p as entityRenamePlan, pt as auditRegistrations, q as sameTenantTrigger, r as sharedRolesProblems, rt as moduleIdType, s as sameTenantLayout, st as declaredTables, t as compileReadSet, tt as contractSignature, u as adoptedViews, ut as extensionSchema, v as moduleDeprecations, w as moduleFilePaths, x as declaredPolicies, y as upgradePlan, z as resolveBlocks } from "../sql-D2Sc6BTr.js";
5
5
  export { APP_TABLES_MARKER, APP_TABLES_MODULE, AUDIT_CATEGORIES, BLOCK_OPTION_SCHEMAS, BLOCK_RENAMES, DEFAULT_ROLES, MODULE_ID_TYPES, SCOPE_ID_TYPES, SECRET_COLUMNS, SQL_MODULES, TENANT_SCOPE_POLICY, adoptedColumnProblems, adoptedTables, adoptedViews, appTableEventTypes, appTablePolicyNotes, appTablesFiles, auditRegistrations, blockFileState, blockSqlVersion, compileReadSet, compileReadSets, contractSignature, currentBlockName, customContracts, dataExportPlan, declaredColumnTypes, declaredPolicies, declaredTableColumns, declaredTables, declaredUpdatedAtTriggers, declaredViews, entityRenamePlan, excludedColumns, expiredFlagsQuery, extensionSchema, formerBlockName, hasColumnAccess, instanceFunctions, isBlockSqlIdType, isModuleDataFile, migrationOptionUses, moduleBody, moduleDataDir, moduleDeprecations, moduleEventTriggers, moduleFilePaths, moduleFileVersion, moduleHidingColumns, moduleIdType, moduleLayout, modulePermissionKeys, moduleSchemaExtensions, moduleTopics, moduleWritesText, notNullCheckName, policyGrants, renamedBlock, renderBlocks, resolveBlock, resolveBlocks, resolveExposeColumns, resolveProviderSql, rlsTables, sameBlockFile, sameTenantColumn, sameTenantLayout, sameTenantTrigger, scopePolicyName, scopeProblems, sharedRolesProblems, subjectColumns, templateFunctions, tenantsQuery, upgradePlan, widenedCommands };
@@ -505,19 +505,44 @@ $$;
505
505
  revoke execute on function better_supabase.as_column_type(text, anyelement) from public;
506
506
  grant execute on function better_supabase.as_column_type(text, anyelement) to anon, authenticated, service_role;`;
507
507
  }
508
+ function tryColumnTypeFunction() {
509
+ return `${SCHEMA$5}
510
+ create or replace function better_supabase.try_column_type(value text, target anyelement)
511
+ returns anyelement
512
+ language plpgsql
513
+ stable
514
+ security invoker
515
+ set search_path = ''
516
+ as $$
517
+ declare
518
+ result alias for $0;
519
+ begin
520
+ result := value;
521
+ return result;
522
+ exception when data_exception or check_violation then
523
+ return null;
524
+ end;
525
+ $$;
526
+ revoke execute on function better_supabase.try_column_type(text, anyelement) from public;
527
+ grant execute on function better_supabase.try_column_type(text, anyelement) to anon, authenticated, service_role;`;
528
+ }
508
529
  /** `value` (text) cast to the type of `column` on the quoted `table`. */
509
530
  function asColumnType(table, column, value) {
510
531
  return `better_supabase.as_column_type(${value}, (null::${table}).${sqlIdent(column)})`;
511
532
  }
533
+ function tryColumnType(table, column, value) {
534
+ return `better_supabase.try_column_type(${value}, (null::${table}).${sqlIdent(column)})`;
535
+ }
536
+ const FUNCTIONS$1 = [["as_column_type", columnTypeFunction], ["try_column_type", tryColumnTypeFunction]];
512
537
  /**
513
- * `sql` with `better_supabase.as_column_type` defined ahead of it when it calls
514
- * the function and does not define it. PL/pgSQL returns `value` through the
515
- * type's input function, so a text value becomes an enum label or any other
516
- * type `target` has.
538
+ * `sql` with `better_supabase.as_column_type` and `try_column_type` defined
539
+ * ahead of it when it calls them and does not define them. PL/pgSQL returns
540
+ * `value` through the type's input function, so a text value becomes an enum
541
+ * label or any other type `target` has.
517
542
  */
518
543
  function withColumnTypeFunction(sql) {
519
- if (!sql.includes("better_supabase.as_column_type(") || sql.includes("function better_supabase.as_column_type(")) return sql;
520
- return `${columnTypeFunction()}\n${sql}`;
544
+ const missing = FUNCTIONS$1.filter(([name]) => sql.includes(`better_supabase.${name}(`) && !sql.includes(`function better_supabase.${name}(`));
545
+ return missing.length === 0 ? sql : `${missing.map(([, define]) => define()).join("\n")}\n${sql}`;
521
546
  }
522
547
  //#endregion
523
548
  //#region src/sql/audit-registrations.ts
@@ -1312,11 +1337,11 @@ function tableOwnership(input, column, requiredColumn) {
1312
1337
  name: `${UNMAPPED_TABLE}${logical}`
1313
1338
  } : input.tableName(logical),
1314
1339
  col: (table, logical) => sqlIdent(column(table, logical) === null && appOwned.includes(table) ? `${UNMAPPED_COLUMN}${table}.${logical}` : requiredColumn(table, logical)),
1315
- cast: (table, logical, value) => {
1340
+ cast: (table, logical, value, invalid = "raise") => {
1316
1341
  if (input.tables[table]?.typed?.includes(logical) !== true) throw new TypeError(`Module "${input.module}" casts ${table}.${logical}, which its names.tables.${table}.typed doesn't list`);
1317
1342
  if (!appOwned.includes(table)) return value;
1318
1343
  const parts = input.tableName(table);
1319
- return asColumnType(`${sqlIdent(parts.schema)}.${sqlIdent(parts.name)}`, requiredColumn(table, logical), value);
1344
+ return (invalid === "null" ? tryColumnType : asColumnType)(`${sqlIdent(parts.schema)}.${sqlIdent(parts.name)}`, requiredColumn(table, logical), value);
1320
1345
  }
1321
1346
  };
1322
1347
  }
@@ -81029,7 +81054,8 @@ const NAMES$45 = {
81029
81054
  "createdAt",
81030
81055
  "updatedAt"
81031
81056
  ],
81032
- yieldsToExtra: ["locale"]
81057
+ yieldsToExtra: ["locale"],
81058
+ typed: ["locale"]
81033
81059
  } },
81034
81060
  hooks: [
81035
81061
  "after_profile_sync",
@@ -81130,6 +81156,8 @@ function syncValues(ctx) {
81130
81156
  if (has("lastName")) values.set(col("lastName"), `coalesce(${values.get(col("lastName")) ?? "null"}, nullif(btrim(substr(${full}, length(split_part(${full}, ' ', 1)) + 1)), ''))`);
81131
81157
  }
81132
81158
  }
81159
+ const fromLocale = hasLocale(ctx) ? values.get(col("locale")) : void 0;
81160
+ if (fromLocale !== void 0) values.set(col("locale"), ctx.cast("profiles", "locale", fromLocale, "null"));
81133
81161
  if (has("email")) values.set(col("email"), "lower(u.email)");
81134
81162
  if (has("username") && ctx.flag("username", true)) values.set(col("username"), `${ctx.fn("allocate_username")}(coalesce(${usernameSource(ctx, values)}, split_part(u.email, '@', 1)), user_id)`);
81135
81163
  return values;
@@ -81615,7 +81643,8 @@ function selfUpdates(ctx) {
81615
81643
  return [...columns.map((logical) => {
81616
81644
  const quoted = ctx.col("profiles", logical);
81617
81645
  const key = sqlString(profilePhysical(ctx, logical));
81618
- return `${quoted} = case when update_my_profile.attrs ? ${key} then update_my_profile.attrs ${logical === "onboarding" ? "->" : "->>"} ${key} else p.${quoted} end`;
81646
+ const value = `update_my_profile.attrs ${logical === "onboarding" ? "->" : "->>"} ${key}`;
81647
+ return `${quoted} = case when update_my_profile.attrs ? ${key} then ${logical === "locale" ? ctx.cast("profiles", logical, value) : value} else p.${quoted} end`;
81619
81648
  }), ...extras].join(",\n ");
81620
81649
  }
81621
81650
  /**
@@ -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";
@@ -26,7 +26,7 @@ import { r as GuardOptions } from "../respond-oZeJ342J.js";
26
26
  import { l as Transcriber, s as NoteTaker, u as TranscriberInput } from "../recordings-BBSJt_YV.js";
27
27
  import { n as Controller } from "../controller-BR7CZ1R9.js";
28
28
  import { c as AiTaskRunner, o as AiTaskRun, r as AiTask } from "../ai-schedules-DzLh6BYI.js";
29
- import { Ht as GeneratorModel, Qt as ResolvedConfig, jt as Generator, zt as GeneratorInput } from "../context-D24k1Cpc.js";
29
+ import { Ht as GeneratorModel, Qt as ResolvedConfig, jt as Generator, zt as GeneratorInput } from "../context-Cj-9gE6l.js";
30
30
  import { r as WebhookInput } from "../signatures-Dkx9OE8j.js";
31
31
  import { n as Payment, o as PaymentProvider } from "../payments-BYcN34Fp.js";
32
32
  import { t as NotificationChannel } from "../channel-JcMd5lNP.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.2",
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";