@authhero/drizzle 1.12.0 → 1.13.0

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.
@@ -2,16 +2,16 @@ import { Column as e, and as t, asc as n, count as r, desc as i, eq as a, getTab
2
2
  import { customAlphabet as ee, nanoid as b } from "nanoid";
3
3
  import { SQLiteTable as te, foreignKey as ne, index as x, integer as S, primaryKey as C, sqliteTable as w, text as T, uniqueIndex as re } from "drizzle-orm/sqlite-core";
4
4
  import { booleanToInt as ie, convertDatesToAdapter as ae, dbDateToIsoRequired as oe, getCountAsInt as se, isoToDbDate as E, removeNullProperties as D, removeUndefinedAndNull as ce, stringifyProperties as le } from "@authhero/adapter-interfaces/sql";
5
- import { MONDAY_EPOCH_SHIFT_MS as ue, TOKEN_EXCHANGE_PROFILE_TYPE as de, WEEK_MS as fe, buildRefreshTokenRetention as pe, buildSessionRetention as me, clientRegistrationTokenTypeSchema as he, decodeCursor as ge, encodeCursor as _e, handlerConfigSchema as ve, isEmailSearchTerm as ye, isPlainObject as be, matchSchema as xe, parseUserId as Se, rolloutInsertSchema as Ce, rolloutSchema as we, sanitizeLuceneQuery as Te, scimMappingEntrySchema as Ee, sessionRetentionWindow as De, splitLuceneOrGroups as Oe, tenantOperationEventInsertSchema as ke, tenantOperationEventSchema as Ae, tenantOperationInsertSchema as je, tenantOperationRowInsertSchema as Me, tenantOperationRowSchema as Ne, tenantOperationSchema as Pe, tokenExchangeJwtVerificationSchema as Fe, unescapeLuceneValue as Ie } from "@authhero/adapter-interfaces";
6
- import { HTTPException as Le } from "hono/http-exception";
5
+ import { MONDAY_EPOCH_SHIFT_MS as ue, TOKEN_EXCHANGE_PROFILE_TYPE as de, WEEK_MS as fe, buildRefreshTokenRetention as pe, buildSessionRetention as me, clientRegistrationTokenTypeSchema as he, decodeCursor as ge, encodeCursor as _e, handlerConfigSchema as ve, isEmailSearchTerm as ye, isPlainObject as be, matchSchema as xe, migrationProviderTypeSchema as Se, parseUserId as Ce, rolloutInsertSchema as we, rolloutSchema as Te, sanitizeLuceneQuery as Ee, scimMappingEntrySchema as De, sessionRetentionWindow as Oe, splitLuceneOrGroups as ke, tenantOperationEventInsertSchema as Ae, tenantOperationEventSchema as je, tenantOperationInsertSchema as Me, tenantOperationRowInsertSchema as Ne, tenantOperationRowSchema as Pe, tenantOperationSchema as Fe, tokenExchangeJwtVerificationSchema as Ie, unescapeLuceneValue as Le } from "@authhero/adapter-interfaces";
6
+ import { HTTPException as Re } from "hono/http-exception";
7
7
  //#region \0rolldown/runtime.js
8
- var Re = Object.defineProperty, ze = (e, t) => {
8
+ var ze = Object.defineProperty, Be = (e, t) => {
9
9
  let n = {};
10
- for (var r in e) Re(n, r, {
10
+ for (var r in e) ze(n, r, {
11
11
  get: e[r],
12
12
  enumerable: !0
13
13
  });
14
- return t || Re(n, Symbol.toStringTag, { value: "Module" }), n;
14
+ return t || ze(n, Symbol.toStringTag, { value: "Module" }), n;
15
15
  }, O = w("tenants", {
16
16
  id: T("id", { length: 191 }).primaryKey(),
17
17
  name: T("name", { length: 255 }),
@@ -67,7 +67,7 @@ var Re = Object.defineProperty, ze = (e, t) => {
67
67
  worker_script_name: T("worker_script_name", { length: 255 }),
68
68
  storage_kind: T("storage_kind", { length: 32 }),
69
69
  d1_database_id: T("d1_database_id", { length: 64 })
70
- }), Be = w("actions", {
70
+ }), Ve = w("actions", {
71
71
  id: T("id", { length: 255 }).notNull(),
72
72
  tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
73
73
  name: T("name", { length: 255 }).notNull(),
@@ -109,7 +109,7 @@ var Re = Object.defineProperty, ze = (e, t) => {
109
109
  }),
110
110
  re("uq_action_versions_number").on(e.tenant_id, e.action_id, e.number),
111
111
  x("idx_action_versions_action_id").on(e.tenant_id, e.action_id)
112
- ]), Ve = w("action_executions", {
112
+ ]), He = w("action_executions", {
113
113
  id: T("id", { length: 255 }).notNull(),
114
114
  tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
115
115
  trigger_id: T("trigger_id", { length: 255 }).notNull(),
@@ -175,7 +175,7 @@ var Re = Object.defineProperty, ze = (e, t) => {
175
175
  password: T("password", { length: 255 }).notNull(),
176
176
  algorithm: T("algorithm", { length: 16 }).notNull().default("bcrypt"),
177
177
  is_current: S("is_current").notNull().default(1)
178
- }), He = w("user_activity", {
178
+ }), Ue = w("user_activity", {
179
179
  tenant_id: T("tenant_id", { length: 255 }).notNull(),
180
180
  user_id: T("user_id", { length: 255 }).notNull(),
181
181
  last_login: T("last_login", { length: 35 }),
@@ -298,7 +298,7 @@ var Re = Object.defineProperty, ze = (e, t) => {
298
298
  }, (e) => [C({
299
299
  columns: [e.code_id, e.code_type],
300
300
  name: "PK_codes_code_id_code_type"
301
- }), x("codes_expires_at_index").on(e.expires_at)]), Ue = w("authentication_codes", {
301
+ }), x("codes_expires_at_index").on(e.expires_at)]), We = w("authentication_codes", {
302
302
  tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
303
303
  code: T("code", { length: 255 }).primaryKey(),
304
304
  client_id: T("client_id", { length: 255 }).notNull(),
@@ -312,7 +312,7 @@ var Re = Object.defineProperty, ze = (e, t) => {
312
312
  created_at: T("created_at", { length: 35 }).notNull(),
313
313
  expires_at: T("expires_at", { length: 35 }).notNull(),
314
314
  used_at: T("used_at", { length: 35 })
315
- }), We = w("otps", {
315
+ }), Ge = w("otps", {
316
316
  tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
317
317
  id: T("id", { length: 255 }).primaryKey(),
318
318
  client_id: T("client_id", { length: 255 }).notNull(),
@@ -331,7 +331,7 @@ var Re = Object.defineProperty, ze = (e, t) => {
331
331
  used_at: T("used_at", { length: 35 }),
332
332
  audience: T("audience", { length: 255 }),
333
333
  ip: T("ip", { length: 64 })
334
- }, (e) => [x("otps_email_index").on(e.email), x("otps_expires_at_index").on(e.expires_at)]), Ge = w("tickets", {
334
+ }, (e) => [x("otps_email_index").on(e.email), x("otps_expires_at_index").on(e.expires_at)]), Ke = w("tickets", {
335
335
  tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
336
336
  id: T("id", { length: 255 }).primaryKey(),
337
337
  client_id: T("client_id", { length: 255 }).notNull(),
@@ -475,7 +475,7 @@ var Re = Object.defineProperty, ze = (e, t) => {
475
475
  C({ columns: [e.tenant_id, e.id] }),
476
476
  x("connections_tenant_id_index").on(e.tenant_id),
477
477
  re("connections_id_unique").on(e.id)
478
- ]), Ke = w("custom_domains", {
478
+ ]), qe = w("custom_domains", {
479
479
  custom_domain_id: T("custom_domain_id", { length: 256 }).primaryKey(),
480
480
  tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
481
481
  domain: T("domain", { length: 255 }).notNull(),
@@ -489,7 +489,7 @@ var Re = Object.defineProperty, ze = (e, t) => {
489
489
  domain_metadata: T("domain_metadata", { length: 2048 }),
490
490
  created_at: T("created_at", { length: 35 }).notNull(),
491
491
  updated_at: T("updated_at", { length: 35 }).notNull()
492
- }, (e) => [re("custom_domains_domain_unique").on(e.domain)]), qe = w("domains", {
492
+ }, (e) => [re("custom_domains_domain_unique").on(e.domain)]), Je = w("domains", {
493
493
  id: T("id", { length: 255 }).primaryKey(),
494
494
  tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
495
495
  domain: T("domain", { length: 255 }).notNull(),
@@ -522,7 +522,7 @@ var Re = Object.defineProperty, ze = (e, t) => {
522
522
  x("idx_user_organizations_tenant_id").on(e.tenant_id),
523
523
  x("idx_user_organizations_user_id").on(e.user_id),
524
524
  x("idx_user_organizations_organization_id").on(e.organization_id)
525
- ]), Je = w("invites", {
525
+ ]), Ye = w("invites", {
526
526
  id: T("id", { length: 21 }).primaryKey(),
527
527
  tenant_id: T("tenant_id", { length: 191 }).notNull(),
528
528
  organization_id: T("organization_id", { length: 21 }).notNull(),
@@ -544,7 +544,20 @@ var Re = Object.defineProperty, ze = (e, t) => {
544
544
  x("idx_invites_organization_id").on(e.organization_id),
545
545
  x("idx_invites_expires_at").on(e.expires_at),
546
546
  x("idx_invites_tenant_created").on(e.tenant_id, e.created_at)
547
- ]), U = w("roles", {
547
+ ]), Xe = w("organization_connections", {
548
+ tenant_id: T("tenant_id", { length: 191 }).notNull(),
549
+ organization_id: T("organization_id", { length: 21 }).notNull(),
550
+ connection_id: T("connection_id", { length: 191 }).notNull(),
551
+ assign_membership_on_login: S("assign_membership_on_login").notNull().default(0),
552
+ show_as_button: S("show_as_button").notNull().default(1),
553
+ is_signup_enabled: S("is_signup_enabled").notNull().default(1),
554
+ created_at: T("created_at", { length: 35 }).notNull(),
555
+ updated_at: T("updated_at", { length: 35 }).notNull()
556
+ }, (e) => [C({ columns: [
557
+ e.tenant_id,
558
+ e.organization_id,
559
+ e.connection_id
560
+ ] })]), U = w("roles", {
548
561
  id: T("id", { length: 21 }).notNull(),
549
562
  tenant_id: T("tenant_id", { length: 191 }).notNull(),
550
563
  name: T("name", { length: 50 }).notNull(),
@@ -574,7 +587,7 @@ var Re = Object.defineProperty, ze = (e, t) => {
574
587
  }),
575
588
  x("role_permissions_role_fk").on(e.tenant_id, e.role_id),
576
589
  x("role_permissions_permission_fk").on(e.tenant_id, e.resource_server_identifier, e.permission_name)
577
- ]), Ye = w("user_permissions", {
590
+ ]), Ze = w("user_permissions", {
578
591
  tenant_id: T("tenant_id", { length: 191 }).notNull(),
579
592
  user_id: T("user_id", { length: 191 }).notNull(),
580
593
  resource_server_identifier: T("resource_server_identifier", { length: 191 }).notNull(),
@@ -635,7 +648,7 @@ var Re = Object.defineProperty, ze = (e, t) => {
635
648
  }, (e) => [C({
636
649
  columns: [e.tenant_id, e.id],
637
650
  name: "resource_servers_pk"
638
- })]), Xe = w("branding", {
651
+ })]), Qe = w("branding", {
639
652
  tenant_id: T("tenant_id", { length: 191 }).primaryKey().references(() => O.id, { onDelete: "cascade" }),
640
653
  logo_url: T("logo_url", { length: 512 }),
641
654
  favicon_url: T("favicon_url", { length: 512 }),
@@ -646,12 +659,12 @@ var Re = Object.defineProperty, ze = (e, t) => {
646
659
  colors_page_background_end: T("colors_page_background_end", { length: 8 }),
647
660
  colors_page_background_angle_dev: S("colors_page_background_angle_dev"),
648
661
  dark_mode: T("dark_mode", { length: 8 })
649
- }), Ze = w("universal_login_templates", {
662
+ }), $e = w("universal_login_templates", {
650
663
  tenant_id: T("tenant_id", { length: 191 }).primaryKey().references(() => O.id, { onDelete: "cascade" }),
651
664
  body: T("body").notNull(),
652
665
  created_at_ts: S("created_at_ts").notNull(),
653
666
  updated_at_ts: S("updated_at_ts").notNull()
654
- }), Qe = w("themes", {
667
+ }), et = w("themes", {
655
668
  tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
656
669
  themeId: T("themeId", { length: 255 }).notNull(),
657
670
  displayName: T("displayName", { length: 255 }).notNull(),
@@ -711,7 +724,7 @@ var Re = Object.defineProperty, ze = (e, t) => {
711
724
  }, (e) => [C({
712
725
  columns: [e.tenant_id, e.themeId],
713
726
  name: "themes_pkey"
714
- }), x("themes_tenant_id_idx").on(e.tenant_id)]), $e = w("forms", {
727
+ }), x("themes_tenant_id_idx").on(e.tenant_id)]), tt = w("forms", {
715
728
  id: T("id", { length: 255 }).primaryKey(),
716
729
  name: T("name", { length: 255 }).notNull(),
717
730
  tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
@@ -724,21 +737,21 @@ var Re = Object.defineProperty, ze = (e, t) => {
724
737
  style: T("style", { length: 1042 }),
725
738
  created_at: T("created_at", { length: 35 }).notNull(),
726
739
  updated_at: T("updated_at", { length: 35 }).notNull()
727
- }, (e) => [x("forms_tenant_id_idx").on(e.tenant_id)]), et = w("flows", {
740
+ }, (e) => [x("forms_tenant_id_idx").on(e.tenant_id)]), nt = w("flows", {
728
741
  id: T("id", { length: 24 }).primaryKey(),
729
742
  tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
730
743
  name: T("name", { length: 150 }).notNull(),
731
744
  actions: T("actions"),
732
745
  created_at: T("created_at", { length: 35 }).notNull(),
733
746
  updated_at: T("updated_at", { length: 35 }).notNull()
734
- }, (e) => [x("flows_tenant_id_idx").on(e.tenant_id)]), tt = w("prompt_settings", {
747
+ }, (e) => [x("flows_tenant_id_idx").on(e.tenant_id)]), rt = w("prompt_settings", {
735
748
  tenant_id: T("tenant_id", { length: 191 }).primaryKey(),
736
749
  universal_login_experience: T("universal_login_experience", { length: 16 }).notNull().default("new"),
737
750
  identifier_first: S("identifier_first", { mode: "boolean" }).notNull().default(!0),
738
751
  password_first: S("password_first", { mode: "boolean" }).notNull().default(!1),
739
752
  webauthn_platform_first_factor: S("webauthn_platform_first_factor", { mode: "boolean" }).notNull().default(!1),
740
753
  show_last_used_connection: S("show_last_used_connection", { mode: "boolean" }).notNull().default(!1)
741
- }), nt = w("email_providers", {
754
+ }), it = w("email_providers", {
742
755
  tenant_id: T("tenant_id", { length: 191 }).primaryKey(),
743
756
  name: T("name", { length: 255 }).notNull(),
744
757
  enabled: S("enabled", { mode: "boolean" }).notNull(),
@@ -747,7 +760,7 @@ var Re = Object.defineProperty, ze = (e, t) => {
747
760
  settings: T("settings", { length: 2048 }).notNull().default("{}"),
748
761
  created_at: T("created_at", { length: 35 }).notNull(),
749
762
  updated_at: T("updated_at", { length: 35 }).notNull()
750
- }), rt = w("email_templates", {
763
+ }), at = w("email_templates", {
751
764
  tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
752
765
  template: T("template", { length: 64 }).notNull(),
753
766
  body: T("body").notNull(),
@@ -760,7 +773,7 @@ var Re = Object.defineProperty, ze = (e, t) => {
760
773
  enabled: S("enabled", { mode: "boolean" }).notNull().default(!0),
761
774
  created_at: T("created_at", { length: 35 }).notNull(),
762
775
  updated_at: T("updated_at", { length: 35 }).notNull()
763
- }, (e) => [C({ columns: [e.tenant_id, e.template] })]), it = w("hooks", {
776
+ }, (e) => [C({ columns: [e.tenant_id, e.template] })]), ot = w("hooks", {
764
777
  hook_id: T("hook_id", { length: 21 }).primaryKey(),
765
778
  tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
766
779
  url: T("url", { length: 512 }),
@@ -776,14 +789,14 @@ var Re = Object.defineProperty, ze = (e, t) => {
776
789
  page_id: T("page_id", { length: 64 }),
777
790
  permission_required: T("permission_required", { length: 255 }),
778
791
  metadata: T("metadata")
779
- }, (e) => [x("hooks_tenant_id_idx").on(e.tenant_id)]), at = w("hook_code", {
792
+ }, (e) => [x("hooks_tenant_id_idx").on(e.tenant_id)]), st = w("hook_code", {
780
793
  id: T("id", { length: 21 }).primaryKey(),
781
794
  tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
782
795
  code: T("code").notNull(),
783
796
  secrets: T("secrets"),
784
797
  created_at_ts: S("created_at_ts").notNull(),
785
798
  updated_at_ts: S("updated_at_ts").notNull()
786
- }, (e) => [x("hook_code_tenant_id_idx").on(e.tenant_id)]), ot = w("keys", {
799
+ }, (e) => [x("hook_code_tenant_id_idx").on(e.tenant_id)]), ct = w("keys", {
787
800
  kid: T("kid", { length: 255 }).primaryKey(),
788
801
  tenant_id: T("tenant_id", { length: 191 }).references(() => O.id, { onDelete: "cascade" }),
789
802
  created_at: T("created_at", { length: 35 }).notNull(),
@@ -796,7 +809,7 @@ var Re = Object.defineProperty, ze = (e, t) => {
796
809
  current_until: T("current_until", { length: 35 }),
797
810
  type: T("type", { length: 50 }).notNull().default("jwt_signing"),
798
811
  connection: T("connection", { length: 255 }).references(() => B.id, { onDelete: "cascade" })
799
- }), st = w("custom_text", {
812
+ }), lt = w("custom_text", {
800
813
  tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
801
814
  prompt: T("prompt", { length: 64 }).notNull(),
802
815
  language: T("language", { length: 16 }).notNull(),
@@ -807,13 +820,13 @@ var Re = Object.defineProperty, ze = (e, t) => {
807
820
  e.tenant_id,
808
821
  e.prompt,
809
822
  e.language
810
- ] })]), ct = w("prompt_partials", {
823
+ ] })]), ut = w("prompt_partials", {
811
824
  tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
812
825
  prompt: T("prompt", { length: 64 }).notNull(),
813
826
  body: T("body").notNull(),
814
827
  created_at_ts: S("created_at_ts").notNull(),
815
828
  updated_at_ts: S("updated_at_ts").notNull()
816
- }, (e) => [C({ columns: [e.tenant_id, e.prompt] })]), lt = w("authentication_methods", {
829
+ }, (e) => [C({ columns: [e.tenant_id, e.prompt] })]), dt = w("authentication_methods", {
817
830
  id: T("id", { length: 26 }).primaryKey(),
818
831
  tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
819
832
  user_id: T("user_id", { length: 255 }).notNull(),
@@ -895,7 +908,7 @@ var Re = Object.defineProperty, ze = (e, t) => {
895
908
  handlers: T("handlers", { length: 16384 }).notNull().default("[]"),
896
909
  created_at: T("created_at", { length: 35 }).notNull(),
897
910
  updated_at: T("updated_at", { length: 35 }).notNull()
898
- }, (e) => [x("proxy_routes_tenant_id_idx").on(e.tenant_id), x("proxy_routes_custom_domain_id_idx").on(e.custom_domain_id)]), ut = w("scim_configurations", {
911
+ }, (e) => [x("proxy_routes_tenant_id_idx").on(e.tenant_id), x("proxy_routes_custom_domain_id_idx").on(e.custom_domain_id)]), ft = w("scim_configurations", {
899
912
  connection_id: T("connection_id", { length: 255 }).notNull(),
900
913
  tenant_id: T("tenant_id", { length: 255 }).notNull(),
901
914
  user_id_attribute: T("user_id_attribute", { length: 255 }).notNull().default("externalId"),
@@ -915,7 +928,7 @@ var Re = Object.defineProperty, ze = (e, t) => {
915
928
  C({ columns: [e.tenant_id, e.token_id] }),
916
929
  x("scim_tokens_tenant_connection_idx").on(e.tenant_id, e.connection_id),
917
930
  re("scim_tokens_tenant_hash_idx").on(e.tenant_id, e.token_hash)
918
- ]), dt = w("scim_external_ids", {
931
+ ]), pt = w("scim_external_ids", {
919
932
  tenant_id: T("tenant_id", { length: 255 }).notNull(),
920
933
  connection_id: T("connection_id", { length: 255 }).notNull(),
921
934
  external_id: T("external_id", { length: 255 }).notNull(),
@@ -925,7 +938,7 @@ var Re = Object.defineProperty, ze = (e, t) => {
925
938
  e.tenant_id,
926
939
  e.connection_id,
927
940
  e.user_id
928
- ] }), re("scim_external_ids_connection_external_idx").on(e.tenant_id, e.connection_id, e.external_id)]), ft = w("token_exchange_profiles", {
941
+ ] }), re("scim_external_ids_connection_external_idx").on(e.tenant_id, e.connection_id, e.external_id)]), mt = w("token_exchange_profiles", {
929
942
  id: T("id", { length: 64 }).primaryKey(),
930
943
  tenant_id: T("tenant_id", { length: 255 }).notNull(),
931
944
  name: T("name", { length: 255 }).notNull(),
@@ -935,55 +948,79 @@ var Re = Object.defineProperty, ze = (e, t) => {
935
948
  jwt_verification: T("jwt_verification"),
936
949
  created_at: T("created_at", { length: 35 }).notNull(),
937
950
  updated_at: T("updated_at", { length: 35 }).notNull()
938
- }, (e) => [re("token_exchange_profiles_tenant_subject_token_type_idx").on(e.tenant_id, e.subject_token_type)]), pt = /* @__PURE__ */ ze({
939
- actionExecutions: () => Ve,
951
+ }, (e) => [re("token_exchange_profiles_tenant_subject_token_type_idx").on(e.tenant_id, e.subject_token_type)]), ht = w("log_streams", {
952
+ id: T("id", { length: 64 }).primaryKey(),
953
+ tenant_id: T("tenant_id", { length: 191 }).notNull(),
954
+ name: T("name", { length: 255 }).notNull(),
955
+ type: T("type", { length: 64 }).notNull(),
956
+ status: T("status", { length: 32 }).notNull(),
957
+ sink: T("sink").notNull(),
958
+ filters: T("filters"),
959
+ is_priority: S("is_priority"),
960
+ created_at: T("created_at", { length: 35 }).notNull(),
961
+ updated_at: T("updated_at", { length: 35 }).notNull()
962
+ }, (e) => [x("idx_log_streams_tenant_id").on(e.tenant_id)]), gt = w("migration_sources", {
963
+ id: T("id", { length: 64 }).primaryKey(),
964
+ tenant_id: T("tenant_id", { length: 191 }).notNull(),
965
+ name: T("name", { length: 255 }).notNull(),
966
+ provider: T("provider", { length: 32 }).notNull(),
967
+ connection: T("connection", { length: 255 }).notNull(),
968
+ enabled: S("enabled").notNull(),
969
+ credentials: T("credentials").notNull(),
970
+ created_at: T("created_at", { length: 35 }).notNull(),
971
+ updated_at: T("updated_at", { length: 35 }).notNull()
972
+ }, (e) => [x("idx_migration_sources_tenant_id").on(e.tenant_id)]), _t = /* @__PURE__ */ Be({
973
+ actionExecutions: () => He,
940
974
  actionVersions: () => k,
941
- actions: () => Be,
942
- authenticationCodes: () => Ue,
943
- authenticationMethods: () => lt,
944
- branding: () => Xe,
975
+ actions: () => Ve,
976
+ authenticationCodes: () => We,
977
+ authenticationMethods: () => dt,
978
+ branding: () => Qe,
945
979
  clientGrants: () => R,
946
980
  clientRegistrationTokens: () => L,
947
981
  clients: () => I,
948
982
  codes: () => F,
949
983
  connections: () => B,
950
- customDomains: () => Ke,
951
- customText: () => st,
952
- domains: () => qe,
953
- emailProviders: () => nt,
954
- emailTemplates: () => rt,
955
- flows: () => et,
956
- forms: () => $e,
984
+ customDomains: () => qe,
985
+ customText: () => lt,
986
+ domains: () => Je,
987
+ emailProviders: () => it,
988
+ emailTemplates: () => at,
989
+ flows: () => nt,
990
+ forms: () => tt,
957
991
  grants: () => z,
958
- hookCode: () => at,
959
- hooks: () => it,
960
- invites: () => Je,
961
- keys: () => ot,
992
+ hookCode: () => st,
993
+ hooks: () => ot,
994
+ invites: () => Ye,
995
+ keys: () => ct,
996
+ logStreams: () => ht,
962
997
  loginSessions: () => P,
963
998
  logs: () => q,
999
+ migrationSources: () => gt,
1000
+ organizationConnections: () => Xe,
964
1001
  organizations: () => V,
965
- otps: () => We,
1002
+ otps: () => Ge,
966
1003
  outboxEvents: () => J,
967
1004
  passwords: () => j,
968
- promptPartials: () => ct,
969
- promptSettings: () => tt,
1005
+ promptPartials: () => ut,
1006
+ promptSettings: () => rt,
970
1007
  proxyRoutes: () => Y,
971
1008
  refreshTokens: () => N,
972
1009
  resourceServers: () => K,
973
1010
  rolePermissions: () => W,
974
1011
  roles: () => U,
975
- scimConfigurations: () => ut,
976
- scimExternalIds: () => dt,
1012
+ scimConfigurations: () => ft,
1013
+ scimExternalIds: () => pt,
977
1014
  scimTokens: () => X,
978
1015
  sessions: () => M,
979
1016
  tenants: () => O,
980
- themes: () => Qe,
981
- tickets: () => Ge,
982
- tokenExchangeProfiles: () => ft,
983
- universalLoginTemplates: () => Ze,
984
- userActivity: () => He,
1017
+ themes: () => et,
1018
+ tickets: () => Ke,
1019
+ tokenExchangeProfiles: () => mt,
1020
+ universalLoginTemplates: () => $e,
1021
+ userActivity: () => Ue,
985
1022
  userOrganizations: () => H,
986
- userPermissions: () => Ye,
1023
+ userPermissions: () => Ze,
987
1024
  userRoles: () => G,
988
1025
  users: () => A
989
1026
  });
@@ -998,14 +1035,14 @@ function Z(e, t) {
998
1035
  }
999
1036
  return e;
1000
1037
  }
1001
- function mt(e, t = "", n = {}) {
1038
+ function vt(e, t = "", n = {}) {
1002
1039
  for (let r in e) if (Object.prototype.hasOwnProperty.call(e, r)) {
1003
1040
  let i = t ? `${t}_${r}` : r, a = e[r];
1004
- typeof a == "object" && a && !Array.isArray(a) ? mt(a, i, n) : typeof a == "boolean" ? n[i] = +!!a : n[i] = a;
1041
+ typeof a == "object" && a && !Array.isArray(a) ? vt(a, i, n) : typeof a == "boolean" ? n[i] = +!!a : n[i] = a;
1005
1042
  }
1006
1043
  return n;
1007
1044
  }
1008
- function ht(e, t) {
1045
+ function yt(e, t) {
1009
1046
  let n = {};
1010
1047
  for (let [r, i] of Object.entries(e)) {
1011
1048
  let e = t.find((e) => r.startsWith(`${e}_`));
@@ -1022,17 +1059,17 @@ function ht(e, t) {
1022
1059
  }
1023
1060
  //#endregion
1024
1061
  //#region src/helpers/filter.ts
1025
- function gt(e) {
1062
+ function bt(e) {
1026
1063
  return typeof e == "object" && !!e && "coalesce" in e && "defaultValue" in e;
1027
1064
  }
1028
- function _t(e) {
1065
+ function xt(e) {
1029
1066
  return y`coalesce(${e.coalesce}, ${e.defaultValue})`;
1030
1067
  }
1031
- function vt(n, r, i, l = []) {
1068
+ function St(n, r, i, l = []) {
1032
1069
  let ee = u(n, te) ? o(n) : n, b = new Set(l), ne = (e) => {
1033
1070
  let t = Number(e);
1034
1071
  return Number.isFinite(t) ? t : e;
1035
- }, x = Oe(r);
1072
+ }, x = ke(r);
1036
1073
  if (x.length > 1) {
1037
1074
  let n = x.map((n) => {
1038
1075
  let r = n.map((t) => {
@@ -1040,8 +1077,8 @@ function vt(n, r, i, l = []) {
1040
1077
  if (!n) return null;
1041
1078
  let [, r, i] = n;
1042
1079
  if (!r || !i) return null;
1043
- let o = r.trim(), s = Ie(i.replace(/^"(.*)"$/, "$1").trim()), c = ee[o];
1044
- return gt(c) ? a(_t(c), ne(s)) : u(c, e) ? b.has(o) ? p(c, `%${s}%`) : a(c, s) : null;
1080
+ let o = r.trim(), s = Le(i.replace(/^"(.*)"$/, "$1").trim()), c = ee[o];
1081
+ return bt(c) ? a(xt(c), ne(s)) : u(c, e) ? b.has(o) ? p(c, `%${s}%`) : a(c, s) : null;
1045
1082
  }).filter((e) => e !== null);
1046
1083
  return r.length === 0 ? null : r.length === 1 ? r[0] : t(...r) ?? null;
1047
1084
  }).filter((e) => e !== null);
@@ -1053,8 +1090,8 @@ function vt(n, r, i, l = []) {
1053
1090
  else if (e.startsWith("_exists_:")) n = e.substring(9), i = !0, t = !1;
1054
1091
  else if (e.includes(":")) {
1055
1092
  let o = t ? e.substring(1) : e, s = o.indexOf(":");
1056
- n = o.substring(0, s), r = o.substring(s + 1), i = !1, r.startsWith(">=") ? (a = ">=", r = r.substring(2)) : r.startsWith(">") ? (a = ">", r = r.substring(1)) : r.startsWith("<=") ? (a = "<=", r = r.substring(2)) : r.startsWith("<") ? (a = "<", r = r.substring(1)) : a = "=", r.startsWith("\"") && r.endsWith("\"") && r.length > 1 && (r = r.slice(1, -1)), r = Ie(r);
1057
- } else n = null, r = Ie(e), i = !1;
1093
+ n = o.substring(0, s), r = o.substring(s + 1), i = !1, r.startsWith(">=") ? (a = ">=", r = r.substring(2)) : r.startsWith(">") ? (a = ">", r = r.substring(1)) : r.startsWith("<=") ? (a = "<=", r = r.substring(2)) : r.startsWith("<") ? (a = "<", r = r.substring(1)) : a = "=", r.startsWith("\"") && r.endsWith("\"") && r.length > 1 && (r = r.slice(1, -1)), r = Le(r);
1094
+ } else n = null, r = Le(e), i = !1;
1058
1095
  return {
1059
1096
  key: n,
1060
1097
  value: r,
@@ -1064,12 +1101,12 @@ function vt(n, r, i, l = []) {
1064
1101
  };
1065
1102
  }), C = [];
1066
1103
  for (let { key: t, value: n, isNegation: r, isExistsQuery: o, operator: l } of S) if (t) {
1067
- let i = ee[t], v = gt(i), te = v ? i.coalesce : u(i, e) ? i : void 0, x = v ? ne(n) : n;
1104
+ let i = ee[t], v = bt(i), te = v ? i.coalesce : u(i, e) ? i : void 0, x = v ? ne(n) : n;
1068
1105
  if (!te) {
1069
1106
  o ? C.push(r ? y`${y.identifier(t)} IS NULL` : y`${y.identifier(t)} IS NOT NULL`) : C.push(y`${y.identifier(t)} ${y.raw(r ? "!=" : l ?? "=")} ${n}`);
1070
1107
  continue;
1071
1108
  }
1072
- let S = v ? _t(i) : y`${te}`;
1109
+ let S = v ? xt(i) : y`${te}`;
1073
1110
  if (o) C.push(r ? f(te) : d(te));
1074
1111
  else if (b.has(t) && l === "=") C.push(r ? _(te, `%${n}%`) : p(te, `%${n}%`));
1075
1112
  else if (r) switch (l) {
@@ -1118,11 +1155,11 @@ function vt(n, r, i, l = []) {
1118
1155
  }
1119
1156
  //#endregion
1120
1157
  //#region src/adapters/actions.ts
1121
- function yt(e) {
1158
+ function Ct(e) {
1122
1159
  let t = Z(e);
1123
1160
  return Array.isArray(t) ? t : [];
1124
1161
  }
1125
- function bt(e) {
1162
+ function wt(e) {
1126
1163
  let { created_at_ts: t, updated_at_ts: n, deployed_at_ts: r, secrets: i, dependencies: a, supported_triggers: o, is_system: s, inherit: c, tenant_id: l, runtime: u, status: d, ...f } = e;
1127
1164
  return {
1128
1165
  ...f,
@@ -1139,11 +1176,11 @@ function bt(e) {
1139
1176
  updated_at: new Date(Number(n)).toISOString()
1140
1177
  };
1141
1178
  }
1142
- function xt(e) {
1179
+ function Tt(e) {
1143
1180
  return {
1144
1181
  async create(t, n) {
1145
1182
  let r = Date.now(), i = `act_${b()}`;
1146
- return await e.insert(Be).values({
1183
+ return await e.insert(Ve).values({
1147
1184
  id: i,
1148
1185
  tenant_id: t,
1149
1186
  name: n.name,
@@ -1174,28 +1211,28 @@ function xt(e) {
1174
1211
  };
1175
1212
  },
1176
1213
  async get(n, r) {
1177
- let i = await e.select().from(Be).where(t(a(Be.tenant_id, n), a(Be.id, r))).get();
1178
- return i ? bt(i) : null;
1214
+ let i = await e.select().from(Ve).where(t(a(Ve.tenant_id, n), a(Ve.id, r))).get();
1215
+ return i ? wt(i) : null;
1179
1216
  },
1180
1217
  async list(o, s = {}) {
1181
- let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s, p = [a(Be.tenant_id, o)];
1218
+ let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s, p = [a(Ve.tenant_id, o)];
1182
1219
  if (f) {
1183
- let e = vt(Be, f, ["name"]);
1220
+ let e = St(Ve, f, ["name"]);
1184
1221
  e && p.push(e);
1185
1222
  }
1186
- let m = t(...p), h = e.select().from(Be).where(m).$dynamic();
1223
+ let m = t(...p), h = e.select().from(Ve).where(m).$dynamic();
1187
1224
  if (d?.sort_by) {
1188
- let e = Be[d.sort_by];
1225
+ let e = Ve[d.sort_by];
1189
1226
  e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
1190
1227
  }
1191
- let g = (await h.offset(c * l).limit(l)).map(bt);
1228
+ let g = (await h.offset(c * l).limit(l)).map(wt);
1192
1229
  if (!u) return {
1193
1230
  actions: g,
1194
1231
  start: 0,
1195
1232
  limit: 0,
1196
1233
  length: 0
1197
1234
  };
1198
- let [_] = await e.select({ count: r() }).from(Be).where(m);
1235
+ let [_] = await e.select({ count: r() }).from(Ve).where(m);
1199
1236
  return {
1200
1237
  actions: g,
1201
1238
  start: c * l,
@@ -1206,7 +1243,7 @@ function xt(e) {
1206
1243
  async update(n, r, i) {
1207
1244
  let o = { updated_at_ts: Date.now() };
1208
1245
  if (i.name !== void 0 && (o.name = i.name), i.code !== void 0 && (o.code = i.code), i.runtime !== void 0 && (o.runtime = i.runtime), i.secrets !== void 0) {
1209
- let s = await e.select({ secrets: Be.secrets }).from(Be).where(t(a(Be.tenant_id, n), a(Be.id, r))).get(), c = new Map(yt(s?.secrets).map((e) => [e.name, e])), l = i.secrets.map((e) => e.value === void 0 ? {
1246
+ let s = await e.select({ secrets: Ve.secrets }).from(Ve).where(t(a(Ve.tenant_id, n), a(Ve.id, r))).get(), c = new Map(Ct(s?.secrets).map((e) => [e.name, e])), l = i.secrets.map((e) => e.value === void 0 ? {
1210
1247
  name: e.name,
1211
1248
  value: c.get(e.name)?.value
1212
1249
  } : e);
@@ -1216,21 +1253,21 @@ function xt(e) {
1216
1253
  let e = new Date(i.deployed_at).getTime();
1217
1254
  Number.isFinite(e) && (o.deployed_at_ts = e);
1218
1255
  }
1219
- return i.is_system !== void 0 && (o.is_system = +!!i.is_system), i.inherit !== void 0 && (o.inherit = +!!i.inherit), (await e.update(Be).set(o).where(t(a(Be.tenant_id, n), a(Be.id, r))).returning()).length > 0;
1256
+ return i.is_system !== void 0 && (o.is_system = +!!i.is_system), i.inherit !== void 0 && (o.inherit = +!!i.inherit), (await e.update(Ve).set(o).where(t(a(Ve.tenant_id, n), a(Ve.id, r))).returning()).length > 0;
1220
1257
  },
1221
1258
  async remove(n, r) {
1222
- return (await e.delete(Be).where(t(a(Be.tenant_id, n), a(Be.id, r))).returning()).length > 0;
1259
+ return (await e.delete(Ve).where(t(a(Ve.tenant_id, n), a(Ve.id, r))).returning()).length > 0;
1223
1260
  }
1224
1261
  };
1225
1262
  }
1226
1263
  //#endregion
1227
1264
  //#region src/adapters/actionExecutions.ts
1228
- var St = 500;
1229
- function Ct(e) {
1265
+ var Et = 500;
1266
+ function Dt(e) {
1230
1267
  return {
1231
1268
  async create(t, n) {
1232
1269
  let r = Date.now();
1233
- return await e.insert(Ve).values({
1270
+ return await e.insert(He).values({
1234
1271
  id: n.id,
1235
1272
  tenant_id: t,
1236
1273
  trigger_id: n.trigger_id,
@@ -1251,7 +1288,7 @@ function Ct(e) {
1251
1288
  };
1252
1289
  },
1253
1290
  async get(n, r) {
1254
- let i = await e.select().from(Ve).where(t(a(Ve.tenant_id, n), a(Ve.id, r))).get();
1291
+ let i = await e.select().from(He).where(t(a(He.tenant_id, n), a(He.id, r))).get();
1255
1292
  return i ? {
1256
1293
  id: i.id,
1257
1294
  tenant_id: i.tenant_id,
@@ -1268,8 +1305,8 @@ function Ct(e) {
1268
1305
  if (Number.isNaN(n)) throw Error(`Invalid olderThan date: ${t}`);
1269
1306
  let r = 0;
1270
1307
  for (;;) {
1271
- let t = await e.delete(Ve).where(y`rowid IN (SELECT rowid FROM ${Ve} WHERE ${Ve.created_at_ts} < ${n} LIMIT ${St})`).returning({ id: Ve.id });
1272
- if (r += t.length, t.length < St) break;
1308
+ let t = await e.delete(He).where(y`rowid IN (SELECT rowid FROM ${He} WHERE ${He.created_at_ts} < ${n} LIMIT ${Et})`).returning({ id: He.id });
1309
+ if (r += t.length, t.length < Et) break;
1273
1310
  }
1274
1311
  return r;
1275
1312
  }
@@ -1277,12 +1314,12 @@ function Ct(e) {
1277
1314
  }
1278
1315
  //#endregion
1279
1316
  //#region src/adapters/atomic.ts
1280
- function wt(e) {
1317
+ function Ot(e) {
1281
1318
  let t = e;
1282
1319
  return typeof t == "object" && !!t && "batch" in t && typeof t.batch == "function";
1283
1320
  }
1284
- async function Tt(e, t) {
1285
- if (wt(e)) return e.batch(t);
1321
+ async function kt(e, t) {
1322
+ if (Ot(e)) return e.batch(t);
1286
1323
  await e.run(y`BEGIN`);
1287
1324
  try {
1288
1325
  let n = [];
@@ -1299,7 +1336,7 @@ async function Tt(e, t) {
1299
1336
  }
1300
1337
  //#endregion
1301
1338
  //#region src/adapters/actionVersions.ts
1302
- function Et(e) {
1339
+ function At(e) {
1303
1340
  let { created_at_ts: t, updated_at_ts: n, secrets: r, dependencies: i, supported_triggers: a, deployed: o, runtime: s, ...c } = e;
1304
1341
  return {
1305
1342
  ...c,
@@ -1312,7 +1349,7 @@ function Et(e) {
1312
1349
  updated_at: new Date(Number(n)).toISOString()
1313
1350
  };
1314
1351
  }
1315
- function Dt(e) {
1352
+ function jt(e) {
1316
1353
  return {
1317
1354
  async create(n, r) {
1318
1355
  let o = Date.now(), s = `ver_${b()}`, c = r.deployed !== !1, l = ((await e.select({ number: k.number }).from(k).where(t(a(k.tenant_id, n), a(k.action_id, r.action_id))).orderBy(i(k.number)).limit(1).get())?.number ?? 0) + 1, u = e.insert(k).values({
@@ -1329,7 +1366,7 @@ function Dt(e) {
1329
1366
  created_at_ts: o,
1330
1367
  updated_at_ts: o
1331
1368
  });
1332
- return await Tt(e, c ? [e.update(k).set({
1369
+ return await kt(e, c ? [e.update(k).set({
1333
1370
  deployed: 0,
1334
1371
  updated_at_ts: o
1335
1372
  }).where(t(a(k.tenant_id, n), a(k.action_id, r.action_id), a(k.deployed, 1))), u] : [u]), {
@@ -1349,10 +1386,10 @@ function Dt(e) {
1349
1386
  },
1350
1387
  async get(n, r, i) {
1351
1388
  let o = await e.select().from(k).where(t(a(k.tenant_id, n), a(k.action_id, r), a(k.id, i))).get();
1352
- return o ? Et(o) : null;
1389
+ return o ? At(o) : null;
1353
1390
  },
1354
1391
  async list(n, o, s = {}) {
1355
- let { page: c = 0, per_page: l = 50, include_totals: u = !1 } = s, d = t(a(k.tenant_id, n), a(k.action_id, o)), f = (await e.select().from(k).where(d).orderBy(i(k.number)).offset(c * l).limit(l)).map(Et);
1392
+ let { page: c = 0, per_page: l = 50, include_totals: u = !1 } = s, d = t(a(k.tenant_id, n), a(k.action_id, o)), f = (await e.select().from(k).where(d).orderBy(i(k.number)).offset(c * l).limit(l)).map(At);
1356
1393
  if (!u) return {
1357
1394
  versions: f,
1358
1395
  start: 0,
@@ -1374,13 +1411,13 @@ function Dt(e) {
1374
1411
  }
1375
1412
  //#endregion
1376
1413
  //#region src/adapters/branding.ts
1377
- function Ot(e) {
1414
+ function Mt(e) {
1378
1415
  return e === "dark" || e === "light" || e === "auto";
1379
1416
  }
1380
- function kt(e) {
1417
+ function Nt(e) {
1381
1418
  return {
1382
1419
  async get(t) {
1383
- let n = await e.select().from(Xe).where(a(Xe.tenant_id, t)).get();
1420
+ let n = await e.select().from(Qe).where(a(Qe.tenant_id, t)).get();
1384
1421
  if (!n) return null;
1385
1422
  let { tenant_id: r, colors_primary: i, colors_page_background_type: o, colors_page_background_start: s, colors_page_background_end: c, colors_page_background_angle_dev: l, font_url: u, dark_mode: d, ...f } = n;
1386
1423
  return D({
@@ -1395,7 +1432,7 @@ function kt(e) {
1395
1432
  }
1396
1433
  },
1397
1434
  font: u ? { url: u } : void 0,
1398
- dark_mode: Ot(d) ? d : void 0
1435
+ dark_mode: Mt(d) ? d : void 0
1399
1436
  });
1400
1437
  },
1401
1438
  async set(t, n) {
@@ -1409,11 +1446,11 @@ function kt(e) {
1409
1446
  font_url: i?.url,
1410
1447
  dark_mode: a
1411
1448
  };
1412
- await e.insert(Xe).values({
1449
+ await e.insert(Qe).values({
1413
1450
  tenant_id: t,
1414
1451
  ...l
1415
1452
  }).onConflictDoUpdate({
1416
- target: Xe.tenant_id,
1453
+ target: Qe.tenant_id,
1417
1454
  set: l
1418
1455
  });
1419
1456
  }
@@ -1421,26 +1458,26 @@ function kt(e) {
1421
1458
  }
1422
1459
  //#endregion
1423
1460
  //#region src/helpers/paginate.ts
1424
- function At(e) {
1461
+ function Pt(e) {
1425
1462
  return e?.from !== void 0 || e?.take !== void 0;
1426
1463
  }
1427
- function jt(e) {
1464
+ function Ft(e) {
1428
1465
  let t = e?.take, n = typeof t == "number" && Number.isFinite(t) ? Math.floor(t) : NaN;
1429
1466
  return n >= 1 ? n : 50;
1430
1467
  }
1431
- function Mt(e) {
1468
+ function It(e) {
1432
1469
  let t = e.sortOrder === "asc" ? n : i;
1433
1470
  return [t(e.sortColumn), t(e.idColumn)];
1434
1471
  }
1435
- function Nt(e, t) {
1472
+ function Lt(e, t) {
1436
1473
  let n = e?.from ? ge(e.from) : null;
1437
1474
  if (!n) return;
1438
- if (n.k !== t.sortKey) throw new Le(400, { message: "The `from` cursor was issued under a different sort and cannot be used with this request" });
1475
+ if (n.k !== t.sortKey) throw new Re(400, { message: "The `from` cursor was issued under a different sort and cannot be used with this request" });
1439
1476
  if (n.s === void 0 || n.s === null) return t.sortOrder === "asc" ? s(t.idColumn, n.i) : m(t.idColumn, n.i);
1440
1477
  let r = t.sortOrder === "asc" ? y.raw(">") : y.raw("<");
1441
1478
  return y`(${t.sortColumn}, ${t.idColumn}) ${r} (${n.s}, ${n.i})`;
1442
1479
  }
1443
- function Pt(e, t, n, r = "id", i) {
1480
+ function Rt(e, t, n, r = "id", i) {
1444
1481
  let a = e.length > t, o = a ? e.slice(0, t) : e, s, c = o[o.length - 1];
1445
1482
  if (a && c) {
1446
1483
  let e = c[n];
@@ -1457,7 +1494,7 @@ function Pt(e, t, n, r = "id", i) {
1457
1494
  }
1458
1495
  //#endregion
1459
1496
  //#region src/adapters/clients.ts
1460
- var Ft = [
1497
+ var zt = [
1461
1498
  "global",
1462
1499
  "is_first_party",
1463
1500
  "oidc_conformant",
@@ -1469,7 +1506,7 @@ var Ft = [
1469
1506
  "require_pushed_authorization_requests",
1470
1507
  "require_proof_of_possession",
1471
1508
  "hide_sign_up_disabled_error"
1472
- ], It = [
1509
+ ], Bt = [
1473
1510
  "callbacks",
1474
1511
  "allowed_origins",
1475
1512
  "web_origins",
@@ -1478,7 +1515,7 @@ var Ft = [
1478
1515
  "allowed_logout_urls",
1479
1516
  "grant_types",
1480
1517
  "signing_keys"
1481
- ], Lt = [
1518
+ ], Vt = [
1482
1519
  "session_transfer",
1483
1520
  "oidc_logout",
1484
1521
  "jwt_configuration",
@@ -1495,21 +1532,21 @@ var Ft = [
1495
1532
  "registration_metadata",
1496
1533
  "token_exchange"
1497
1534
  ];
1498
- function Rt(e) {
1535
+ function Ht(e) {
1499
1536
  let { tenant_id: t, connections: n, ...r } = e, i = { ...r };
1500
- for (let e of Ft) i[e] = !!r[e];
1501
- for (let e of It) i[e] = Z(r[e], []);
1502
- for (let e of Lt) i[e] = Z(r[e], {});
1537
+ for (let e of zt) i[e] = !!r[e];
1538
+ for (let e of Bt) i[e] = Z(r[e], []);
1539
+ for (let e of Vt) i[e] = Z(r[e], {});
1503
1540
  return i.connections = Z(n, []), D(i);
1504
1541
  }
1505
- function zt(e) {
1542
+ function Ut(e) {
1506
1543
  let t = { ...e };
1507
- ie(e, Ft, t);
1508
- for (let n of It) e[n] !== void 0 && (t[n] = JSON.stringify(e[n] || []));
1509
- for (let n of Lt) e[n] !== void 0 && (t[n] = JSON.stringify(e[n] || {}));
1544
+ ie(e, zt, t);
1545
+ for (let n of Bt) e[n] !== void 0 && (t[n] = JSON.stringify(e[n] || []));
1546
+ for (let n of Vt) e[n] !== void 0 && (t[n] = JSON.stringify(e[n] || {}));
1510
1547
  return e.connections !== void 0 && (t.connections = JSON.stringify(e.connections || [])), ce(t);
1511
1548
  }
1512
- function Bt(e) {
1549
+ function Wt(e) {
1513
1550
  return {
1514
1551
  async create(t, n) {
1515
1552
  let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
@@ -1533,51 +1570,51 @@ function Bt(e) {
1533
1570
  created_at: r,
1534
1571
  updated_at: r
1535
1572
  };
1536
- for (let e of Ft) i[e] = n[e] ?? !1;
1573
+ for (let e of zt) i[e] = n[e] ?? !1;
1537
1574
  i.oidc_conformant = n.oidc_conformant ?? !0, i.auth0_conformant = n.auth0_conformant ?? !0, i.sso_disabled = n.sso_disabled ?? !1;
1538
- for (let e of It) i[e] = n[e] || [];
1539
- for (let e of Lt) i[e] = n[e] || {};
1575
+ for (let e of Bt) i[e] = n[e] || [];
1576
+ for (let e of Vt) i[e] = n[e] || {};
1540
1577
  i.connections = n.connections || [];
1541
- let a = zt(i);
1578
+ let a = Ut(i);
1542
1579
  try {
1543
1580
  await e.insert(I).values({
1544
1581
  ...a,
1545
1582
  tenant_id: t
1546
1583
  });
1547
1584
  } catch (e) {
1548
- throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new Le(409, { message: "Client already exists" }) : e;
1585
+ throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new Re(409, { message: "Client already exists" }) : e;
1549
1586
  }
1550
- return Rt({
1587
+ return Ht({
1551
1588
  ...a,
1552
1589
  tenant_id: t
1553
1590
  });
1554
1591
  },
1555
1592
  async get(n, r) {
1556
1593
  let i = await e.select().from(I).where(t(a(I.tenant_id, n), a(I.client_id, r))).get();
1557
- return i ? Rt(i) : null;
1594
+ return i ? Ht(i) : null;
1558
1595
  },
1559
1596
  async getByClientId(t) {
1560
1597
  let n = await e.select().from(I).where(a(I.client_id, t)).get();
1561
1598
  return n ? {
1562
- ...Rt(n),
1599
+ ...Ht(n),
1563
1600
  tenant_id: n.tenant_id
1564
1601
  } : null;
1565
1602
  },
1566
1603
  async update(n, r, i) {
1567
- let o = zt({
1604
+ let o = Ut({
1568
1605
  ...i,
1569
1606
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
1570
1607
  });
1571
1608
  return delete o.client_id, delete o.tenant_id, await e.update(I).set(o).where(t(a(I.tenant_id, n), a(I.client_id, r))), !0;
1572
1609
  },
1573
1610
  async list(o, s) {
1574
- let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? vt(I, f, ["name", "client_id"]) : void 0, m = p ? t(a(I.tenant_id, o), p) : a(I.tenant_id, o);
1575
- if (At(s)) {
1611
+ let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? St(I, f, ["name", "client_id"]) : void 0, m = p ? t(a(I.tenant_id, o), p) : a(I.tenant_id, o);
1612
+ if (Pt(s)) {
1576
1613
  let n = {
1577
1614
  sortColumn: I.created_at,
1578
1615
  idColumn: I.client_id,
1579
1616
  sortOrder: "desc"
1580
- }, r = Nt(s, n), i = jt(s), { rows: a, next: o } = Pt(await e.select().from(I).where(r ? t(m, r) : m).orderBy(...Mt(n)).limit(i + 1), i, "created_at", "client_id"), c = a.map(Rt);
1617
+ }, r = Lt(s, n), i = Ft(s), { rows: a, next: o } = Rt(await e.select().from(I).where(r ? t(m, r) : m).orderBy(...It(n)).limit(i + 1), i, "created_at", "client_id"), c = a.map(Ht);
1581
1618
  return {
1582
1619
  clients: c,
1583
1620
  totals: {
@@ -1593,7 +1630,7 @@ function Bt(e) {
1593
1630
  let e = I[d.sort_by];
1594
1631
  e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
1595
1632
  }
1596
- let g = (await h.offset(c * l).limit(l)).map(Rt);
1633
+ let g = (await h.offset(c * l).limit(l)).map(Ht);
1597
1634
  if (!u) return { clients: g };
1598
1635
  let [_] = await e.select({ count: r() }).from(I).where(m);
1599
1636
  return {
@@ -1613,7 +1650,7 @@ function Bt(e) {
1613
1650
  }
1614
1651
  //#endregion
1615
1652
  //#region src/adapters/clientConnections.ts
1616
- function Vt(e) {
1653
+ function Gt(e) {
1617
1654
  let { tenant_id: t, is_system: n, options: r, metadata: i, ...a } = e;
1618
1655
  return D({
1619
1656
  ...a,
@@ -1622,14 +1659,14 @@ function Vt(e) {
1622
1659
  is_system: n ? !0 : void 0
1623
1660
  });
1624
1661
  }
1625
- function Ht(e) {
1662
+ function Kt(e) {
1626
1663
  return {
1627
1664
  async listByClient(n, r) {
1628
1665
  let i = await e.select({ connections: I.connections }).from(I).where(t(a(I.tenant_id, n), a(I.client_id, r))).get();
1629
1666
  if (!i) return [];
1630
1667
  let o = Z(i.connections, []) || [];
1631
1668
  if (o.length === 0) return [];
1632
- let s = (await e.select().from(B).where(t(a(B.tenant_id, n), l(B.id, o))).all()).map(Vt);
1669
+ let s = (await e.select().from(B).where(t(a(B.tenant_id, n), l(B.id, o))).all()).map(Gt);
1633
1670
  return o.map((e) => s.find((t) => t.id === e)).filter(Boolean);
1634
1671
  },
1635
1672
  async updateByClient(n, r, i) {
@@ -1666,7 +1703,7 @@ function Ht(e) {
1666
1703
  }
1667
1704
  //#endregion
1668
1705
  //#region src/adapters/clientGrants.ts
1669
- function Ut(e) {
1706
+ function qt(e) {
1670
1707
  let { tenant_id: t, scope: n, authorization_details_types: r, allow_any_organization: i, is_system: a, ...o } = e;
1671
1708
  return D({
1672
1709
  ...o,
@@ -1676,7 +1713,7 @@ function Ut(e) {
1676
1713
  is_system: !!a
1677
1714
  });
1678
1715
  }
1679
- function Wt(e) {
1716
+ function Jt(e) {
1680
1717
  return {
1681
1718
  async create(t, n) {
1682
1719
  let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
@@ -1693,14 +1730,14 @@ function Wt(e) {
1693
1730
  created_at: r,
1694
1731
  updated_at: r
1695
1732
  };
1696
- return await e.insert(R).values(i), Ut({
1733
+ return await e.insert(R).values(i), qt({
1697
1734
  ...i,
1698
1735
  tenant_id: t
1699
1736
  });
1700
1737
  },
1701
1738
  async get(n, r) {
1702
1739
  let i = await e.select().from(R).where(t(a(R.tenant_id, n), a(R.id, r))).get();
1703
- return i ? Ut(i) : null;
1740
+ return i ? qt(i) : null;
1704
1741
  },
1705
1742
  async update(n, r, i) {
1706
1743
  let { scope: o, authorization_details_types: s, allow_any_organization: c, is_system: l, ...u } = i, d = {
@@ -1710,13 +1747,13 @@ function Wt(e) {
1710
1747
  return o !== void 0 && (d.scope = JSON.stringify(o)), s !== void 0 && (d.authorization_details_types = JSON.stringify(s)), c !== void 0 && (d.allow_any_organization = +!!c), l !== void 0 && (d.is_system = +!!l), (await e.update(R).set(d).where(t(a(R.tenant_id, n), a(R.id, r))).returning()).length > 0;
1711
1748
  },
1712
1749
  async list(o, s) {
1713
- let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? vt(R, f, ["client_id", "audience"]) : void 0, m = p ? t(a(R.tenant_id, o), p) : a(R.tenant_id, o);
1714
- if (At(s)) {
1750
+ let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? St(R, f, ["client_id", "audience"]) : void 0, m = p ? t(a(R.tenant_id, o), p) : a(R.tenant_id, o);
1751
+ if (Pt(s)) {
1715
1752
  let n = {
1716
1753
  sortColumn: R.created_at,
1717
1754
  idColumn: R.id,
1718
1755
  sortOrder: "desc"
1719
- }, r = Nt(s, n), i = jt(s), { rows: a, next: o } = Pt(await e.select().from(R).where(r ? t(m, r) : m).orderBy(...Mt(n)).limit(i + 1), i, "created_at"), c = a.map(Ut);
1756
+ }, r = Lt(s, n), i = Ft(s), { rows: a, next: o } = Rt(await e.select().from(R).where(r ? t(m, r) : m).orderBy(...It(n)).limit(i + 1), i, "created_at"), c = a.map(qt);
1720
1757
  return {
1721
1758
  client_grants: c,
1722
1759
  start: 0,
@@ -1730,7 +1767,7 @@ function Wt(e) {
1730
1767
  let e = R[d.sort_by];
1731
1768
  e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
1732
1769
  } else h = h.orderBy(i(R.created_at), i(R.id));
1733
- let g = (await h.offset(c * l).limit(l)).map(Ut);
1770
+ let g = (await h.offset(c * l).limit(l)).map(qt);
1734
1771
  if (!u) return { client_grants: g };
1735
1772
  let [_] = await e.select({ count: r() }).from(R).where(m);
1736
1773
  return {
@@ -1747,20 +1784,20 @@ function Wt(e) {
1747
1784
  }
1748
1785
  //#endregion
1749
1786
  //#region src/adapters/clientRegistrationTokens.ts
1750
- function Gt(e) {
1787
+ function Yt(e) {
1751
1788
  if (!e) return;
1752
1789
  let t = JSON.parse(e);
1753
1790
  return be(t) ? t : void 0;
1754
1791
  }
1755
- function Kt(e) {
1792
+ function Xt(e) {
1756
1793
  return e == null ? void 0 : new Date(e).toISOString();
1757
1794
  }
1758
- function qt(e) {
1795
+ function Zt(e) {
1759
1796
  if (!e) return null;
1760
1797
  let t = new Date(e);
1761
1798
  return isNaN(t.getTime()) ? null : t.getTime();
1762
1799
  }
1763
- function Jt(e) {
1800
+ function Qt(e) {
1764
1801
  let t = he.parse(e.type);
1765
1802
  return {
1766
1803
  id: e.id,
@@ -1768,15 +1805,15 @@ function Jt(e) {
1768
1805
  type: t,
1769
1806
  client_id: e.client_id ?? void 0,
1770
1807
  sub: e.sub ?? void 0,
1771
- constraints: Gt(e.constraints),
1808
+ constraints: Yt(e.constraints),
1772
1809
  single_use: !!e.single_use,
1773
- expires_at: Kt(e.expires_at_ts),
1774
- used_at: Kt(e.used_at_ts),
1775
- revoked_at: Kt(e.revoked_at_ts),
1810
+ expires_at: Xt(e.expires_at_ts),
1811
+ used_at: Xt(e.used_at_ts),
1812
+ revoked_at: Xt(e.revoked_at_ts),
1776
1813
  created_at: new Date(e.created_at_ts).toISOString()
1777
1814
  };
1778
1815
  }
1779
- function Yt(e) {
1816
+ function $t(e) {
1780
1817
  return {
1781
1818
  async create(t, n) {
1782
1819
  let r = Date.now();
@@ -1789,7 +1826,7 @@ function Yt(e) {
1789
1826
  sub: n.sub ?? null,
1790
1827
  constraints: n.constraints ? JSON.stringify(n.constraints) : null,
1791
1828
  single_use: +!!n.single_use,
1792
- expires_at_ts: qt(n.expires_at),
1829
+ expires_at_ts: Zt(n.expires_at),
1793
1830
  created_at_ts: r
1794
1831
  }), {
1795
1832
  id: n.id,
@@ -1805,23 +1842,23 @@ function Yt(e) {
1805
1842
  },
1806
1843
  async get(n, r) {
1807
1844
  let i = await e.select().from(L).where(t(a(L.tenant_id, n), a(L.id, r))).get();
1808
- return i ? Jt(i) : null;
1845
+ return i ? Qt(i) : null;
1809
1846
  },
1810
1847
  async getByHash(n, r) {
1811
1848
  let i = await e.select().from(L).where(t(a(L.tenant_id, n), a(L.token_hash, r))).get();
1812
- return i ? Jt(i) : null;
1849
+ return i ? Qt(i) : null;
1813
1850
  },
1814
1851
  async listByClient(n, r) {
1815
- return (await e.select().from(L).where(t(a(L.tenant_id, n), a(L.client_id, r))).orderBy(i(L.created_at_ts))).map(Jt);
1852
+ return (await e.select().from(L).where(t(a(L.tenant_id, n), a(L.client_id, r))).orderBy(i(L.created_at_ts))).map(Qt);
1816
1853
  },
1817
1854
  async markUsed(n, r, i) {
1818
- return (await e.update(L).set({ used_at_ts: qt(i) }).where(t(a(L.tenant_id, n), a(L.id, r), f(L.used_at_ts))).returning()).length > 0;
1855
+ return (await e.update(L).set({ used_at_ts: Zt(i) }).where(t(a(L.tenant_id, n), a(L.id, r), f(L.used_at_ts))).returning()).length > 0;
1819
1856
  },
1820
1857
  async revoke(n, r, i) {
1821
- return (await e.update(L).set({ revoked_at_ts: qt(i) }).where(t(a(L.tenant_id, n), a(L.id, r), f(L.revoked_at_ts))).returning()).length > 0;
1858
+ return (await e.update(L).set({ revoked_at_ts: Zt(i) }).where(t(a(L.tenant_id, n), a(L.id, r), f(L.revoked_at_ts))).returning()).length > 0;
1822
1859
  },
1823
1860
  async revokeByClient(n, r, i) {
1824
- return (await e.update(L).set({ revoked_at_ts: qt(i) }).where(t(a(L.tenant_id, n), a(L.client_id, r), f(L.revoked_at_ts))).returning()).length;
1861
+ return (await e.update(L).set({ revoked_at_ts: Zt(i) }).where(t(a(L.tenant_id, n), a(L.client_id, r), f(L.revoked_at_ts))).returning()).length;
1825
1862
  },
1826
1863
  async remove(n, r) {
1827
1864
  return (await e.delete(L).where(t(a(L.tenant_id, n), a(L.id, r))).returning()).length > 0;
@@ -1830,12 +1867,12 @@ function Yt(e) {
1830
1867
  }
1831
1868
  //#endregion
1832
1869
  //#region src/adapters/codes.ts
1833
- var Xt = ["code_id", "login_id"], Zt = 500;
1834
- function Qt(e) {
1870
+ var en = ["code_id", "login_id"], tn = 500;
1871
+ function nn(e) {
1835
1872
  let { tenant_id: t, ...n } = e;
1836
1873
  return D(n);
1837
1874
  }
1838
- function $t(e) {
1875
+ function rn(e) {
1839
1876
  return {
1840
1877
  async create(t, n) {
1841
1878
  let r = {
@@ -1844,18 +1881,18 @@ function $t(e) {
1844
1881
  created_at: n.created_at || (/* @__PURE__ */ new Date()).toISOString(),
1845
1882
  expires_at: n.expires_at
1846
1883
  };
1847
- return await e.insert(F).values(r), Qt(r);
1884
+ return await e.insert(F).values(r), nn(r);
1848
1885
  },
1849
1886
  async get(n, r, i) {
1850
1887
  let o = n ? t(a(F.tenant_id, n), a(F.code_id, r), a(F.code_type, i)) : t(a(F.code_id, r), a(F.code_type, i)), s = await e.select().from(F).where(o).get();
1851
- return s ? Qt(s) : null;
1888
+ return s ? nn(s) : null;
1852
1889
  },
1853
1890
  async list(o, s) {
1854
1891
  let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(F.tenant_id, o)];
1855
1892
  if (f) {
1856
- let e = Te(f, Xt);
1893
+ let e = Ee(f, en);
1857
1894
  if (e) {
1858
- let t = vt(F, e, Xt);
1895
+ let t = St(F, e, en);
1859
1896
  t && p.push(t);
1860
1897
  }
1861
1898
  }
@@ -1864,7 +1901,7 @@ function $t(e) {
1864
1901
  let e = F[d.sort_by];
1865
1902
  e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
1866
1903
  }
1867
- let g = (await h.offset(c * l).limit(l)).map(Qt);
1904
+ let g = (await h.offset(c * l).limit(l)).map(nn);
1868
1905
  if (!u) return { codes: g };
1869
1906
  let [_] = await e.select({ count: r() }).from(F).where(m);
1870
1907
  return {
@@ -1886,8 +1923,8 @@ function $t(e) {
1886
1923
  async cleanup(t) {
1887
1924
  let n = 0;
1888
1925
  for (;;) {
1889
- let r = await e.delete(F).where(y`rowid IN (SELECT rowid FROM ${F} WHERE ${F.expires_at} < ${t} LIMIT ${Zt})`).returning({ code_id: F.code_id });
1890
- if (n += r.length, r.length < Zt) break;
1926
+ let r = await e.delete(F).where(y`rowid IN (SELECT rowid FROM ${F} WHERE ${F.expires_at} < ${t} LIMIT ${tn})`).returning({ code_id: F.code_id });
1927
+ if (n += r.length, r.length < tn) break;
1891
1928
  }
1892
1929
  return n;
1893
1930
  }
@@ -1895,10 +1932,10 @@ function $t(e) {
1895
1932
  }
1896
1933
  //#endregion
1897
1934
  //#region src/adapters/connections.ts
1898
- function en() {
1935
+ function an() {
1899
1936
  return `con_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
1900
1937
  }
1901
- function tn(e) {
1938
+ function on(e) {
1902
1939
  let { tenant_id: t, is_system: n, options: r, metadata: i, ...a } = e;
1903
1940
  return D({
1904
1941
  ...a,
@@ -1907,11 +1944,11 @@ function tn(e) {
1907
1944
  is_system: n ? !0 : void 0
1908
1945
  });
1909
1946
  }
1910
- function nn(e) {
1947
+ function sn(e) {
1911
1948
  return {
1912
1949
  async create(t, n) {
1913
1950
  let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
1914
- id: n.id || en(),
1951
+ id: n.id || an(),
1915
1952
  ...n,
1916
1953
  tenant_id: t,
1917
1954
  options: JSON.stringify(n.options || {}),
@@ -1923,13 +1960,13 @@ function nn(e) {
1923
1960
  try {
1924
1961
  await e.insert(B).values(i);
1925
1962
  } catch (e) {
1926
- throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new Le(409, { message: "Connection already exists" }) : e;
1963
+ throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new Re(409, { message: "Connection already exists" }) : e;
1927
1964
  }
1928
- return tn(i);
1965
+ return on(i);
1929
1966
  },
1930
1967
  async get(n, r) {
1931
1968
  let i = await e.select().from(B).where(t(a(B.tenant_id, n), a(B.id, r))).get();
1932
- return i ? tn(i) : null;
1969
+ return i ? on(i) : null;
1933
1970
  },
1934
1971
  async update(n, r, i) {
1935
1972
  let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
@@ -1938,15 +1975,15 @@ function nn(e) {
1938
1975
  async list(o, s) {
1939
1976
  let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = a(B.tenant_id, o);
1940
1977
  if (f) {
1941
- let e = vt(B, f, ["name"]);
1978
+ let e = St(B, f, ["name"]);
1942
1979
  e && (p = t(p, e));
1943
1980
  }
1944
- if (At(s)) {
1981
+ if (Pt(s)) {
1945
1982
  let n = {
1946
1983
  sortColumn: B.created_at,
1947
1984
  idColumn: B.id,
1948
1985
  sortOrder: "desc"
1949
- }, r = Nt(s, n), i = jt(s), { rows: a, next: o } = Pt(await e.select().from(B).where(r ? t(p, r) : p).orderBy(...Mt(n)).limit(i + 1), i, "created_at", "id"), c = a.map(tn);
1986
+ }, r = Lt(s, n), i = Ft(s), { rows: a, next: o } = Rt(await e.select().from(B).where(r ? t(p, r) : p).orderBy(...It(n)).limit(i + 1), i, "created_at", "id"), c = a.map(on);
1950
1987
  return {
1951
1988
  connections: c,
1952
1989
  start: 0,
@@ -1960,7 +1997,7 @@ function nn(e) {
1960
1997
  let e = B[d.sort_by];
1961
1998
  e && (m = m.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
1962
1999
  }
1963
- let h = (await m.offset(c * l).limit(l)).map(tn);
2000
+ let h = (await m.offset(c * l).limit(l)).map(on);
1964
2001
  if (!u) return { connections: h };
1965
2002
  let [g] = await e.select({ count: r() }).from(B).where(p);
1966
2003
  return {
@@ -1977,7 +2014,7 @@ function nn(e) {
1977
2014
  }
1978
2015
  //#endregion
1979
2016
  //#region src/adapters/customDomains.ts
1980
- function rn(e) {
2017
+ function cn(e) {
1981
2018
  let { tenant_id: t, domain_metadata: n, verification: r, ...i } = e;
1982
2019
  return D({
1983
2020
  ...i,
@@ -1986,7 +2023,7 @@ function rn(e) {
1986
2023
  verification: Z(r)
1987
2024
  });
1988
2025
  }
1989
- function an(e) {
2026
+ function ln(e) {
1990
2027
  return {
1991
2028
  async create(t, n) {
1992
2029
  let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
@@ -2004,40 +2041,40 @@ function an(e) {
2004
2041
  created_at: r,
2005
2042
  updated_at: r
2006
2043
  };
2007
- return await e.insert(Ke).values(i), rn({
2044
+ return await e.insert(qe).values(i), cn({
2008
2045
  ...i,
2009
2046
  tenant_id: t
2010
2047
  });
2011
2048
  },
2012
2049
  async get(n, r) {
2013
- let i = await e.select().from(Ke).where(t(a(Ke.tenant_id, n), a(Ke.custom_domain_id, r))).get();
2014
- return i ? rn(i) : null;
2050
+ let i = await e.select().from(qe).where(t(a(qe.tenant_id, n), a(qe.custom_domain_id, r))).get();
2051
+ return i ? cn(i) : null;
2015
2052
  },
2016
2053
  async getByDomain(t) {
2017
- let n = await e.select().from(Ke).where(a(Ke.domain, t)).get();
2054
+ let n = await e.select().from(qe).where(a(qe.domain, t)).get();
2018
2055
  return n ? {
2019
- ...rn(n),
2056
+ ...cn(n),
2020
2057
  tenant_id: n.tenant_id
2021
2058
  } : null;
2022
2059
  },
2023
2060
  async list(t) {
2024
- return (await e.select().from(Ke).where(a(Ke.tenant_id, t)).all()).map(rn);
2061
+ return (await e.select().from(qe).where(a(qe.tenant_id, t)).all()).map(cn);
2025
2062
  },
2026
2063
  async update(n, r, i) {
2027
2064
  let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
2028
- return i.domain !== void 0 && (o.domain = i.domain), i.primary !== void 0 && (o.primary = i.primary), i.status !== void 0 && (o.status = i.status), i.type !== void 0 && (o.type = i.type), i.origin_domain_name !== void 0 && (o.origin_domain_name = i.origin_domain_name), i.verification !== void 0 && (o.verification = JSON.stringify(i.verification)), i.custom_client_ip_header !== void 0 && (o.custom_client_ip_header = i.custom_client_ip_header), i.tls_policy !== void 0 && (o.tls_policy = i.tls_policy), i.domain_metadata !== void 0 && (o.domain_metadata = JSON.stringify(i.domain_metadata)), (await e.update(Ke).set(o).where(t(a(Ke.tenant_id, n), a(Ke.custom_domain_id, r))).returning()).length > 0;
2065
+ return i.domain !== void 0 && (o.domain = i.domain), i.primary !== void 0 && (o.primary = i.primary), i.status !== void 0 && (o.status = i.status), i.type !== void 0 && (o.type = i.type), i.origin_domain_name !== void 0 && (o.origin_domain_name = i.origin_domain_name), i.verification !== void 0 && (o.verification = JSON.stringify(i.verification)), i.custom_client_ip_header !== void 0 && (o.custom_client_ip_header = i.custom_client_ip_header), i.tls_policy !== void 0 && (o.tls_policy = i.tls_policy), i.domain_metadata !== void 0 && (o.domain_metadata = JSON.stringify(i.domain_metadata)), (await e.update(qe).set(o).where(t(a(qe.tenant_id, n), a(qe.custom_domain_id, r))).returning()).length > 0;
2029
2066
  },
2030
2067
  async remove(n, r) {
2031
- return (await e.delete(Ke).where(t(a(Ke.tenant_id, n), a(Ke.custom_domain_id, r))).returning()).length > 0;
2068
+ return (await e.delete(qe).where(t(a(qe.tenant_id, n), a(qe.custom_domain_id, r))).returning()).length > 0;
2032
2069
  }
2033
2070
  };
2034
2071
  }
2035
2072
  //#endregion
2036
2073
  //#region src/adapters/customText.ts
2037
- function on(e) {
2074
+ function un(e) {
2038
2075
  return {
2039
2076
  async get(n, r, i) {
2040
- let o = await e.select().from(st).where(t(a(st.tenant_id, n), a(st.prompt, r), a(st.language, i))).get();
2077
+ let o = await e.select().from(lt).where(t(a(lt.tenant_id, n), a(lt.prompt, r), a(lt.language, i))).get();
2041
2078
  if (!o) return null;
2042
2079
  try {
2043
2080
  return JSON.parse(o.custom_text);
@@ -2047,7 +2084,7 @@ function on(e) {
2047
2084
  },
2048
2085
  async set(t, n, r, i) {
2049
2086
  let a = Date.now(), o = JSON.stringify(i);
2050
- await e.insert(st).values({
2087
+ await e.insert(lt).values({
2051
2088
  tenant_id: t,
2052
2089
  prompt: n,
2053
2090
  language: r,
@@ -2056,9 +2093,9 @@ function on(e) {
2056
2093
  updated_at_ts: a
2057
2094
  }).onConflictDoUpdate({
2058
2095
  target: [
2059
- st.tenant_id,
2060
- st.prompt,
2061
- st.language
2096
+ lt.tenant_id,
2097
+ lt.prompt,
2098
+ lt.language
2062
2099
  ],
2063
2100
  set: {
2064
2101
  custom_text: o,
@@ -2067,23 +2104,23 @@ function on(e) {
2067
2104
  });
2068
2105
  },
2069
2106
  async delete(n, r, i) {
2070
- await e.delete(st).where(t(a(st.tenant_id, n), a(st.prompt, r), a(st.language, i)));
2107
+ await e.delete(lt).where(t(a(lt.tenant_id, n), a(lt.prompt, r), a(lt.language, i)));
2071
2108
  },
2072
2109
  async list(t) {
2073
2110
  return await e.select({
2074
- prompt: st.prompt,
2075
- language: st.language
2076
- }).from(st).where(a(st.tenant_id, t)).all();
2111
+ prompt: lt.prompt,
2112
+ language: lt.language
2113
+ }).from(lt).where(a(lt.tenant_id, t)).all();
2077
2114
  }
2078
2115
  };
2079
2116
  }
2080
2117
  //#endregion
2081
2118
  //#region src/adapters/emailProviders.ts
2082
- function sn(e) {
2119
+ function dn(e) {
2083
2120
  return {
2084
2121
  async create(t, n) {
2085
2122
  let r = (/* @__PURE__ */ new Date()).toISOString();
2086
- await e.insert(nt).values({
2123
+ await e.insert(it).values({
2087
2124
  tenant_id: t,
2088
2125
  name: n.name,
2089
2126
  enabled: n.enabled,
@@ -2095,7 +2132,7 @@ function sn(e) {
2095
2132
  });
2096
2133
  },
2097
2134
  async get(t) {
2098
- let n = await e.select().from(nt).where(a(nt.tenant_id, t)).get();
2135
+ let n = await e.select().from(it).where(a(it.tenant_id, t)).get();
2099
2136
  if (!n) return null;
2100
2137
  let { tenant_id: r, ...i } = n;
2101
2138
  return D({
@@ -2107,16 +2144,16 @@ function sn(e) {
2107
2144
  },
2108
2145
  async update(t, n) {
2109
2146
  let r = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
2110
- n.name !== void 0 && (r.name = n.name), n.enabled !== void 0 && (r.enabled = n.enabled), n.default_from_address !== void 0 && (r.default_from_address = n.default_from_address), n.credentials !== void 0 && (r.credentials = JSON.stringify(n.credentials)), n.settings !== void 0 && (r.settings = JSON.stringify(n.settings)), await e.update(nt).set(r).where(a(nt.tenant_id, t));
2147
+ n.name !== void 0 && (r.name = n.name), n.enabled !== void 0 && (r.enabled = n.enabled), n.default_from_address !== void 0 && (r.default_from_address = n.default_from_address), n.credentials !== void 0 && (r.credentials = JSON.stringify(n.credentials)), n.settings !== void 0 && (r.settings = JSON.stringify(n.settings)), await e.update(it).set(r).where(a(it.tenant_id, t));
2111
2148
  },
2112
2149
  async remove(t) {
2113
- await e.delete(nt).where(a(nt.tenant_id, t));
2150
+ await e.delete(it).where(a(it.tenant_id, t));
2114
2151
  }
2115
2152
  };
2116
2153
  }
2117
2154
  //#endregion
2118
2155
  //#region src/adapters/emailTemplates.ts
2119
- function cn(e) {
2156
+ function fn(e) {
2120
2157
  return D({
2121
2158
  template: e.template,
2122
2159
  body: e.body,
@@ -2129,18 +2166,18 @@ function cn(e) {
2129
2166
  urlLifetimeInSeconds: e.url_lifetime_in_seconds ?? void 0
2130
2167
  });
2131
2168
  }
2132
- function ln(e) {
2169
+ function pn(e) {
2133
2170
  return {
2134
2171
  async get(n, r) {
2135
- let i = await e.select().from(rt).where(t(a(rt.tenant_id, n), a(rt.template, r))).get();
2136
- return i ? cn(i) : null;
2172
+ let i = await e.select().from(at).where(t(a(at.tenant_id, n), a(at.template, r))).get();
2173
+ return i ? fn(i) : null;
2137
2174
  },
2138
2175
  async list(t) {
2139
- return (await e.select().from(rt).where(a(rt.tenant_id, t)).all()).map(cn);
2176
+ return (await e.select().from(at).where(a(at.tenant_id, t)).all()).map(fn);
2140
2177
  },
2141
2178
  async create(t, n) {
2142
2179
  let r = (/* @__PURE__ */ new Date()).toISOString();
2143
- return await e.insert(rt).values({
2180
+ return await e.insert(at).values({
2144
2181
  tenant_id: t,
2145
2182
  template: n.template,
2146
2183
  body: n.body,
@@ -2158,23 +2195,23 @@ function ln(e) {
2158
2195
  async update(n, r, i) {
2159
2196
  let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
2160
2197
  i.body !== void 0 && (o.body = i.body), i.from !== void 0 && (o.from = i.from), i.subject !== void 0 && (o.subject = i.subject), i.syntax !== void 0 && (o.syntax = i.syntax), i.resultUrl !== void 0 && (o.result_url = i.resultUrl), i.urlLifetimeInSeconds !== void 0 && (o.url_lifetime_in_seconds = i.urlLifetimeInSeconds), i.includeEmailInRedirect !== void 0 && (o.include_email_in_redirect = i.includeEmailInRedirect), i.enabled !== void 0 && (o.enabled = i.enabled);
2161
- let s = await e.update(rt).set(o).where(t(a(rt.tenant_id, n), a(rt.template, r))).run();
2198
+ let s = await e.update(at).set(o).where(t(a(at.tenant_id, n), a(at.template, r))).run();
2162
2199
  return Number(s.changes ?? 0) > 0;
2163
2200
  },
2164
2201
  async remove(n, r) {
2165
- let i = await e.delete(rt).where(t(a(rt.tenant_id, n), a(rt.template, r))).run();
2202
+ let i = await e.delete(at).where(t(a(at.tenant_id, n), a(at.template, r))).run();
2166
2203
  return Number(i.changes ?? 0) > 0;
2167
2204
  }
2168
2205
  };
2169
2206
  }
2170
2207
  //#endregion
2171
2208
  //#region src/adapters/flows.ts
2172
- var un = ["id", "name"];
2173
- function dn(e) {
2209
+ var mn = ["id", "name"];
2210
+ function hn(e) {
2174
2211
  return {
2175
2212
  async create(t, n) {
2176
2213
  let r = (/* @__PURE__ */ new Date()).toISOString(), i = `af_${b()}`;
2177
- return await e.insert(et).values({
2214
+ return await e.insert(nt).values({
2178
2215
  id: i,
2179
2216
  tenant_id: t,
2180
2217
  name: n.name,
@@ -2190,7 +2227,7 @@ function dn(e) {
2190
2227
  };
2191
2228
  },
2192
2229
  async get(n, r) {
2193
- let i = await e.select().from(et).where(t(a(et.tenant_id, n), a(et.id, r))).get();
2230
+ let i = await e.select().from(nt).where(t(a(nt.tenant_id, n), a(nt.id, r))).get();
2194
2231
  if (!i) return null;
2195
2232
  let { tenant_id: o, actions: s, ...c } = i;
2196
2233
  return D({
@@ -2200,20 +2237,20 @@ function dn(e) {
2200
2237
  },
2201
2238
  async update(n, r, i) {
2202
2239
  let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
2203
- return i.name !== void 0 && (o.name = i.name), i.actions !== void 0 && (o.actions = JSON.stringify(i.actions)), (await e.update(et).set(o).where(t(a(et.tenant_id, n), a(et.id, r))).returning()).length === 0 ? null : this.get(n, r);
2240
+ return i.name !== void 0 && (o.name = i.name), i.actions !== void 0 && (o.actions = JSON.stringify(i.actions)), (await e.update(nt).set(o).where(t(a(nt.tenant_id, n), a(nt.id, r))).returning()).length === 0 ? null : this.get(n, r);
2204
2241
  },
2205
2242
  async list(o, s) {
2206
- let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(et.tenant_id, o)];
2243
+ let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(nt.tenant_id, o)];
2207
2244
  if (f) {
2208
- let e = Te(f, un);
2245
+ let e = Ee(f, mn);
2209
2246
  if (e) {
2210
- let t = vt(et, e, []);
2247
+ let t = St(nt, e, []);
2211
2248
  t && p.push(t);
2212
2249
  }
2213
2250
  }
2214
- let m = t(...p), h = e.select().from(et).where(m).$dynamic();
2251
+ let m = t(...p), h = e.select().from(nt).where(m).$dynamic();
2215
2252
  if (d?.sort_by) {
2216
- let e = et[d.sort_by];
2253
+ let e = nt[d.sort_by];
2217
2254
  e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
2218
2255
  }
2219
2256
  let g = (await h.offset(c * l).limit(l)).map((e) => {
@@ -2224,7 +2261,7 @@ function dn(e) {
2224
2261
  });
2225
2262
  });
2226
2263
  if (!u) return { flows: g };
2227
- let [_] = await e.select({ count: r() }).from(et).where(m);
2264
+ let [_] = await e.select({ count: r() }).from(nt).where(m);
2228
2265
  return {
2229
2266
  flows: g,
2230
2267
  start: c * l,
@@ -2233,18 +2270,18 @@ function dn(e) {
2233
2270
  };
2234
2271
  },
2235
2272
  async remove(n, r) {
2236
- return (await e.delete(et).where(t(a(et.tenant_id, n), a(et.id, r))).returning()).length > 0;
2273
+ return (await e.delete(nt).where(t(a(nt.tenant_id, n), a(nt.id, r))).returning()).length > 0;
2237
2274
  }
2238
2275
  };
2239
2276
  }
2240
2277
  //#endregion
2241
2278
  //#region src/adapters/forms.ts
2242
- var fn = [
2279
+ var gn = [
2243
2280
  "nodes",
2244
2281
  "start",
2245
2282
  "ending"
2246
- ], pn = ["name"];
2247
- function mn(e) {
2283
+ ], _n = ["name"];
2284
+ function vn(e) {
2248
2285
  return {
2249
2286
  async create(t, n) {
2250
2287
  let r = (/* @__PURE__ */ new Date()).toISOString(), i = b(), a = {
@@ -2258,8 +2295,8 @@ function mn(e) {
2258
2295
  created_at: r,
2259
2296
  updated_at: r
2260
2297
  };
2261
- for (let e of fn) a[e] = JSON.stringify(n[e] || (e === "nodes" ? [] : {}));
2262
- return await e.insert($e).values(a), {
2298
+ for (let e of gn) a[e] = JSON.stringify(n[e] || (e === "nodes" ? [] : {}));
2299
+ return await e.insert(tt).values(a), {
2263
2300
  id: i,
2264
2301
  ...n,
2265
2302
  created_at: r,
@@ -2267,38 +2304,38 @@ function mn(e) {
2267
2304
  };
2268
2305
  },
2269
2306
  async get(n, r) {
2270
- let i = await e.select().from($e).where(t(a($e.tenant_id, n), a($e.id, r))).get();
2307
+ let i = await e.select().from(tt).where(t(a(tt.tenant_id, n), a(tt.id, r))).get();
2271
2308
  if (!i) return null;
2272
2309
  let { tenant_id: o, ...s } = i, c = { ...s };
2273
- for (let e of fn) c[e] = Z(s[e]);
2310
+ for (let e of gn) c[e] = Z(s[e]);
2274
2311
  return D(c);
2275
2312
  },
2276
2313
  async update(n, r, i) {
2277
2314
  let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
2278
- for (let [e, t] of Object.entries(i)) t !== void 0 && (fn.includes(e) ? o[e] = JSON.stringify(t) : o[e] = t);
2279
- return (await e.update($e).set(o).where(t(a($e.tenant_id, n), a($e.id, r))).returning()).length > 0;
2315
+ for (let [e, t] of Object.entries(i)) t !== void 0 && (gn.includes(e) ? o[e] = JSON.stringify(t) : o[e] = t);
2316
+ return (await e.update(tt).set(o).where(t(a(tt.tenant_id, n), a(tt.id, r))).returning()).length > 0;
2280
2317
  },
2281
2318
  async list(o, s) {
2282
- let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a($e.tenant_id, o)];
2319
+ let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(tt.tenant_id, o)];
2283
2320
  if (f) {
2284
- let e = Te(f, pn);
2321
+ let e = Ee(f, _n);
2285
2322
  if (e) {
2286
- let t = vt($e, e, pn);
2323
+ let t = St(tt, e, _n);
2287
2324
  t && p.push(t);
2288
2325
  }
2289
2326
  }
2290
- let m = t(...p), h = e.select().from($e).where(m).$dynamic();
2327
+ let m = t(...p), h = e.select().from(tt).where(m).$dynamic();
2291
2328
  if (d?.sort_by) {
2292
- let e = $e[d.sort_by];
2329
+ let e = tt[d.sort_by];
2293
2330
  e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
2294
2331
  }
2295
2332
  let g = (await h.offset(c * l).limit(l)).map((e) => {
2296
2333
  let { tenant_id: t, ...n } = e, r = { ...n };
2297
- for (let e of fn) r[e] = Z(n[e]);
2334
+ for (let e of gn) r[e] = Z(n[e]);
2298
2335
  return D(r);
2299
2336
  });
2300
2337
  if (!u) return { forms: g };
2301
- let [_] = await e.select({ count: r() }).from($e).where(m);
2338
+ let [_] = await e.select({ count: r() }).from(tt).where(m);
2302
2339
  return {
2303
2340
  forms: g,
2304
2341
  start: c * l,
@@ -2307,13 +2344,13 @@ function mn(e) {
2307
2344
  };
2308
2345
  },
2309
2346
  async remove(n, r) {
2310
- return (await e.delete($e).where(t(a($e.tenant_id, n), a($e.id, r))).returning()).length > 0;
2347
+ return (await e.delete(tt).where(t(a(tt.tenant_id, n), a(tt.id, r))).returning()).length > 0;
2311
2348
  }
2312
2349
  };
2313
2350
  }
2314
2351
  //#endregion
2315
2352
  //#region src/adapters/grants.ts
2316
- function hn(e) {
2353
+ function yn(e) {
2317
2354
  return {
2318
2355
  id: e.id,
2319
2356
  user_id: e.user_id,
@@ -2322,17 +2359,17 @@ function hn(e) {
2322
2359
  scope: Z(e.scope, []) ?? []
2323
2360
  };
2324
2361
  }
2325
- var gn = {
2362
+ var bn = {
2326
2363
  user_id: z.user_id,
2327
2364
  client_id: z.client_id,
2328
2365
  audience: z.audience,
2329
2366
  created_at: z.created_at,
2330
2367
  updated_at: z.updated_at
2331
2368
  };
2332
- function _n(e) {
2333
- return Object.hasOwn(gn, e) ? gn[e] : void 0;
2369
+ function xn(e) {
2370
+ return Object.hasOwn(bn, e) ? bn[e] : void 0;
2334
2371
  }
2335
- function vn(e) {
2372
+ function Sn(e) {
2336
2373
  return {
2337
2374
  async create(n, r) {
2338
2375
  let i = (/* @__PURE__ */ new Date()).toISOString(), o = r.scope ?? [], s = r.audience ?? "", c = await e.select().from(z).where(t(a(z.tenant_id, n), a(z.user_id, r.user_id), a(z.client_id, r.clientID), a(z.audience, s))).get();
@@ -2341,7 +2378,7 @@ function vn(e) {
2341
2378
  return await e.update(z).set({
2342
2379
  scope: JSON.stringify(s),
2343
2380
  updated_at: i
2344
- }).where(t(a(z.tenant_id, n), a(z.id, c.id))), hn({
2381
+ }).where(t(a(z.tenant_id, n), a(z.id, c.id))), yn({
2345
2382
  ...c,
2346
2383
  scope: JSON.stringify(s)
2347
2384
  });
@@ -2366,16 +2403,16 @@ function vn(e) {
2366
2403
  },
2367
2404
  async get(n, r, i, o) {
2368
2405
  let s = await e.select().from(z).where(t(a(z.tenant_id, n), a(z.user_id, r), a(z.client_id, i), a(z.audience, o ?? ""))).get();
2369
- return s ? hn(s) : null;
2406
+ return s ? yn(s) : null;
2370
2407
  },
2371
2408
  async list(o, s) {
2372
- let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? vt(z, f, [
2409
+ let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? St(z, f, [
2373
2410
  "user_id",
2374
2411
  "client_id",
2375
2412
  "audience"
2376
- ]) : void 0, m = p ? t(a(z.tenant_id, o), p) : a(z.tenant_id, o), h = e.select().from(z).where(m).$dynamic(), g = d?.sort_by ? _n(d.sort_by) : void 0;
2413
+ ]) : void 0, m = p ? t(a(z.tenant_id, o), p) : a(z.tenant_id, o), h = e.select().from(z).where(m).$dynamic(), g = d?.sort_by ? xn(d.sort_by) : void 0;
2377
2414
  h = g ? h.orderBy(d?.sort_order === "desc" ? i(g) : n(g)) : h.orderBy(n(z.created_at));
2378
- let _ = (await h.offset(c * l).limit(l)).map(hn);
2415
+ let _ = (await h.offset(c * l).limit(l)).map(yn);
2379
2416
  if (!u) return {
2380
2417
  grants: _,
2381
2418
  start: 0,
@@ -2400,11 +2437,11 @@ function vn(e) {
2400
2437
  }
2401
2438
  //#endregion
2402
2439
  //#region src/adapters/hookCode.ts
2403
- var yn = ee("0123456789abcdefghijklmnopqrstuvwxyz", 17);
2404
- function bn() {
2405
- return `hc_${yn()}`;
2440
+ var Cn = ee("0123456789abcdefghijklmnopqrstuvwxyz", 17);
2441
+ function wn() {
2442
+ return `hc_${Cn()}`;
2406
2443
  }
2407
- function xn(e) {
2444
+ function Tn(e) {
2408
2445
  let { created_at_ts: t, updated_at_ts: n, secrets: r, ...i } = e, a = ae({
2409
2446
  created_at_ts: t,
2410
2447
  updated_at_ts: n
@@ -2415,41 +2452,41 @@ function xn(e) {
2415
2452
  secrets: r ? JSON.parse(r) : void 0
2416
2453
  };
2417
2454
  }
2418
- function Sn(e) {
2455
+ function En(e) {
2419
2456
  return {
2420
2457
  async create(t, n) {
2421
2458
  let r = Date.now(), i = {
2422
- id: bn(),
2459
+ id: wn(),
2423
2460
  tenant_id: t,
2424
2461
  code: n.code,
2425
2462
  secrets: n.secrets ? JSON.stringify(n.secrets) : null,
2426
2463
  created_at_ts: r,
2427
2464
  updated_at_ts: r
2428
2465
  };
2429
- return await e.insert(at).values(i), xn({
2466
+ return await e.insert(st).values(i), Tn({
2430
2467
  ...i,
2431
2468
  tenant_id: t
2432
2469
  });
2433
2470
  },
2434
2471
  async get(n, r) {
2435
- let i = await e.select().from(at).where(t(a(at.tenant_id, n), a(at.id, r))).get();
2436
- return i ? xn(i) : null;
2472
+ let i = await e.select().from(st).where(t(a(st.tenant_id, n), a(st.id, r))).get();
2473
+ return i ? Tn(i) : null;
2437
2474
  },
2438
2475
  async update(n, r, i) {
2439
2476
  let o = { updated_at_ts: Date.now() };
2440
- return i.code !== void 0 && (o.code = i.code), i.secrets !== void 0 && (o.secrets = JSON.stringify(i.secrets)), (await e.update(at).set(o).where(t(a(at.tenant_id, n), a(at.id, r))).returning()).length > 0;
2477
+ return i.code !== void 0 && (o.code = i.code), i.secrets !== void 0 && (o.secrets = JSON.stringify(i.secrets)), (await e.update(st).set(o).where(t(a(st.tenant_id, n), a(st.id, r))).returning()).length > 0;
2441
2478
  },
2442
2479
  async remove(n, r) {
2443
- return (await e.delete(at).where(t(a(at.tenant_id, n), a(at.id, r))).returning()).length > 0;
2480
+ return (await e.delete(st).where(t(a(st.tenant_id, n), a(st.id, r))).returning()).length > 0;
2444
2481
  }
2445
2482
  };
2446
2483
  }
2447
2484
  //#endregion
2448
2485
  //#region src/adapters/hooks.ts
2449
- function Cn() {
2486
+ function Dn() {
2450
2487
  return `h_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
2451
2488
  }
2452
- function wn(e) {
2489
+ function On(e) {
2453
2490
  if (!(typeof e != "string" || !e)) try {
2454
2491
  let t = JSON.parse(e);
2455
2492
  return t && typeof t == "object" && !Array.isArray(t) ? t : void 0;
@@ -2457,7 +2494,7 @@ function wn(e) {
2457
2494
  return;
2458
2495
  }
2459
2496
  }
2460
- function Tn(e) {
2497
+ function kn(e) {
2461
2498
  let { tenant_id: t, created_at_ts: n, updated_at_ts: r, metadata: i, ...a } = e, o = ae({
2462
2499
  created_at_ts: n,
2463
2500
  updated_at_ts: r
@@ -2466,15 +2503,15 @@ function Tn(e) {
2466
2503
  ...a,
2467
2504
  enabled: !!a.enabled,
2468
2505
  synchronous: !!a.synchronous,
2469
- metadata: wn(i),
2506
+ metadata: On(i),
2470
2507
  ...o
2471
2508
  });
2472
2509
  }
2473
- function En(e) {
2510
+ function An(e) {
2474
2511
  return {
2475
2512
  async create(t, n) {
2476
2513
  let r = Date.now(), i = {
2477
- hook_id: n.hook_id || Cn(),
2514
+ hook_id: n.hook_id || Dn(),
2478
2515
  tenant_id: t,
2479
2516
  trigger_id: n.trigger_id,
2480
2517
  url: n.url,
@@ -2490,30 +2527,30 @@ function En(e) {
2490
2527
  created_at_ts: r,
2491
2528
  updated_at_ts: r
2492
2529
  };
2493
- return await e.insert(it).values(i), Tn({
2530
+ return await e.insert(ot).values(i), kn({
2494
2531
  ...i,
2495
2532
  tenant_id: t
2496
2533
  });
2497
2534
  },
2498
2535
  async get(n, r) {
2499
- let i = await e.select().from(it).where(t(a(it.tenant_id, n), a(it.hook_id, r))).get();
2500
- return i ? Tn(i) : null;
2536
+ let i = await e.select().from(ot).where(t(a(ot.tenant_id, n), a(ot.hook_id, r))).get();
2537
+ return i ? kn(i) : null;
2501
2538
  },
2502
2539
  async update(n, r, i) {
2503
2540
  let o = { updated_at_ts: Date.now() };
2504
- return i.trigger_id !== void 0 && (o.trigger_id = i.trigger_id), i.url !== void 0 && (o.url = i.url), i.enabled !== void 0 && (o.enabled = i.enabled), i.synchronous !== void 0 && (o.synchronous = i.synchronous), i.priority !== void 0 && (o.priority = i.priority), i.form_id !== void 0 && (o.form_id = i.form_id), i.template_id !== void 0 && (o.template_id = i.template_id), i.code_id !== void 0 && (o.code_id = i.code_id), i.page_id !== void 0 && (o.page_id = i.page_id), i.permission_required !== void 0 && (o.permission_required = i.permission_required), i.metadata !== void 0 && (o.metadata = i.metadata === null ? null : JSON.stringify(i.metadata)), (await e.update(it).set(o).where(t(a(it.tenant_id, n), a(it.hook_id, r))).returning()).length > 0;
2541
+ return i.trigger_id !== void 0 && (o.trigger_id = i.trigger_id), i.url !== void 0 && (o.url = i.url), i.enabled !== void 0 && (o.enabled = i.enabled), i.synchronous !== void 0 && (o.synchronous = i.synchronous), i.priority !== void 0 && (o.priority = i.priority), i.form_id !== void 0 && (o.form_id = i.form_id), i.template_id !== void 0 && (o.template_id = i.template_id), i.code_id !== void 0 && (o.code_id = i.code_id), i.page_id !== void 0 && (o.page_id = i.page_id), i.permission_required !== void 0 && (o.permission_required = i.permission_required), i.metadata !== void 0 && (o.metadata = i.metadata === null ? null : JSON.stringify(i.metadata)), (await e.update(ot).set(o).where(t(a(ot.tenant_id, n), a(ot.hook_id, r))).returning()).length > 0;
2505
2542
  },
2506
2543
  async list(o, s) {
2507
- let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? vt(it, f, [
2544
+ let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? St(ot, f, [
2508
2545
  "url",
2509
2546
  "form_id",
2510
2547
  "template_id",
2511
2548
  "code_id"
2512
- ]) : void 0, m = p ? t(a(it.tenant_id, o), p) : a(it.tenant_id, o), h = e.select().from(it).where(m).$dynamic(), g = d?.sort_by ? it[d.sort_by] : void 0;
2513
- h = g ? h.orderBy(d?.sort_order === "desc" ? i(g) : n(g)) : h.orderBy(i(it.priority), n(it.created_at_ts));
2514
- let _ = (await h.offset(c * l).limit(l)).map(Tn);
2549
+ ]) : void 0, m = p ? t(a(ot.tenant_id, o), p) : a(ot.tenant_id, o), h = e.select().from(ot).where(m).$dynamic(), g = d?.sort_by ? ot[d.sort_by] : void 0;
2550
+ h = g ? h.orderBy(d?.sort_order === "desc" ? i(g) : n(g)) : h.orderBy(i(ot.priority), n(ot.created_at_ts));
2551
+ let _ = (await h.offset(c * l).limit(l)).map(kn);
2515
2552
  if (!u) return { hooks: _ };
2516
- let [v] = await e.select({ count: r() }).from(it).where(m);
2553
+ let [v] = await e.select({ count: r() }).from(ot).where(m);
2517
2554
  return {
2518
2555
  hooks: _,
2519
2556
  start: c * l,
@@ -2522,31 +2559,31 @@ function En(e) {
2522
2559
  };
2523
2560
  },
2524
2561
  async remove(n, r) {
2525
- return (await e.delete(it).where(t(a(it.tenant_id, n), a(it.hook_id, r))).returning()).length > 0;
2562
+ return (await e.delete(ot).where(t(a(ot.tenant_id, n), a(ot.hook_id, r))).returning()).length > 0;
2526
2563
  }
2527
2564
  };
2528
2565
  }
2529
2566
  //#endregion
2530
2567
  //#region src/adapters/invites.ts
2531
- function Dn() {
2568
+ function jn() {
2532
2569
  return `inv_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
2533
2570
  }
2534
- var On = [
2571
+ var Mn = [
2535
2572
  "inviter",
2536
2573
  "invitee",
2537
2574
  "app_metadata",
2538
2575
  "user_metadata",
2539
2576
  "roles"
2540
2577
  ];
2541
- function kn(e) {
2578
+ function Nn(e) {
2542
2579
  let { tenant_id: t, send_invitation_email: n, ...r } = e, i = { ...r };
2543
- for (let e of On) i[e] = Z(r[e], e === "roles" ? [] : {});
2580
+ for (let e of Mn) i[e] = Z(r[e], e === "roles" ? [] : {});
2544
2581
  return i.send_invitation_email = !!n, D(i);
2545
2582
  }
2546
- function An(e) {
2583
+ function Pn(e) {
2547
2584
  return {
2548
2585
  async create(t, n) {
2549
- let r = n.id || Dn(), i = n.ttl_sec || 604800, a = /* @__PURE__ */ new Date(), o = new Date(a.getTime() + i * 1e3).toISOString(), s = {
2586
+ let r = n.id || jn(), i = n.ttl_sec || 604800, a = /* @__PURE__ */ new Date(), o = new Date(a.getTime() + i * 1e3).toISOString(), s = {
2550
2587
  id: r,
2551
2588
  tenant_id: t,
2552
2589
  organization_id: n.organization_id,
@@ -2559,35 +2596,35 @@ function An(e) {
2559
2596
  created_at: a.toISOString(),
2560
2597
  expires_at: o
2561
2598
  };
2562
- for (let e of On) n[e] !== void 0 && (s[e] = JSON.stringify(n[e]));
2599
+ for (let e of Mn) n[e] !== void 0 && (s[e] = JSON.stringify(n[e]));
2563
2600
  try {
2564
- await e.insert(Je).values(s);
2601
+ await e.insert(Ye).values(s);
2565
2602
  } catch (e) {
2566
- throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new Le(409, { message: "Invite already exists" }) : e;
2603
+ throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new Re(409, { message: "Invite already exists" }) : e;
2567
2604
  }
2568
- return kn({
2605
+ return Nn({
2569
2606
  ...s,
2570
2607
  tenant_id: t
2571
2608
  });
2572
2609
  },
2573
2610
  async get(n, r) {
2574
- let i = await e.select().from(Je).where(t(a(Je.tenant_id, n), a(Je.id, r))).get();
2575
- return i ? kn(i) : null;
2611
+ let i = await e.select().from(Ye).where(t(a(Ye.tenant_id, n), a(Ye.id, r))).get();
2612
+ return i ? Nn(i) : null;
2576
2613
  },
2577
2614
  async update(n, r, i) {
2578
2615
  let o = {};
2579
- for (let e of On) i[e] !== void 0 && (o[e] = JSON.stringify(i[e]));
2580
- return i.connection_id !== void 0 && (o.connection_id = i.connection_id), i.ttl_sec !== void 0 && (o.ttl_sec = i.ttl_sec, o.expires_at = new Date(Date.now() + i.ttl_sec * 1e3).toISOString()), (await e.update(Je).set(o).where(t(a(Je.tenant_id, n), a(Je.id, r))).returning()).length > 0;
2616
+ for (let e of Mn) i[e] !== void 0 && (o[e] = JSON.stringify(i[e]));
2617
+ return i.connection_id !== void 0 && (o.connection_id = i.connection_id), i.ttl_sec !== void 0 && (o.ttl_sec = i.ttl_sec, o.expires_at = new Date(Date.now() + i.ttl_sec * 1e3).toISOString()), (await e.update(Ye).set(o).where(t(a(Ye.tenant_id, n), a(Ye.id, r))).returning()).length > 0;
2581
2618
  },
2582
2619
  async list(t, o) {
2583
- let { page: s = 0, per_page: c = 50, include_totals: l = !1, sort: u } = o || {}, d = e.select().from(Je).where(a(Je.tenant_id, t)).$dynamic();
2620
+ let { page: s = 0, per_page: c = 50, include_totals: l = !1, sort: u } = o || {}, d = e.select().from(Ye).where(a(Ye.tenant_id, t)).$dynamic();
2584
2621
  if (u?.sort_by) {
2585
- let e = Je[u.sort_by];
2622
+ let e = Ye[u.sort_by];
2586
2623
  e && (d = d.orderBy(u.sort_order === "desc" ? i(e) : n(e)));
2587
2624
  }
2588
- let f = (await d.offset(s * c).limit(c)).map(kn);
2625
+ let f = (await d.offset(s * c).limit(c)).map(Nn);
2589
2626
  if (!l) return { invites: f };
2590
- let [p] = await e.select({ count: r() }).from(Je).where(a(Je.tenant_id, t));
2627
+ let [p] = await e.select({ count: r() }).from(Ye).where(a(Ye.tenant_id, t));
2591
2628
  return {
2592
2629
  invites: f,
2593
2630
  start: s * c,
@@ -2596,39 +2633,39 @@ function An(e) {
2596
2633
  };
2597
2634
  },
2598
2635
  async remove(n, r) {
2599
- return (await e.delete(Je).where(t(a(Je.tenant_id, n), a(Je.id, r))).returning()).length > 0;
2636
+ return (await e.delete(Ye).where(t(a(Ye.tenant_id, n), a(Ye.id, r))).returning()).length > 0;
2600
2637
  }
2601
2638
  };
2602
2639
  }
2603
2640
  //#endregion
2604
2641
  //#region src/adapters/keys.ts
2605
- var jn = [
2642
+ var Fn = [
2606
2643
  "kid",
2607
2644
  "connection",
2608
2645
  "fingerprint",
2609
2646
  "thumbprint",
2610
2647
  "type"
2611
2648
  ];
2612
- function Mn(e) {
2649
+ function In(e) {
2613
2650
  return {
2614
2651
  async create(t) {
2615
- await e.insert(ot).values({
2652
+ await e.insert(ct).values({
2616
2653
  ...t,
2617
2654
  created_at: (/* @__PURE__ */ new Date()).toDateString()
2618
2655
  });
2619
2656
  },
2620
2657
  async list(a) {
2621
- let { page: o = 0, per_page: c = 50, include_totals: l = !1, sort: u, q: d } = a || {}, p = (/* @__PURE__ */ new Date()).toISOString(), m = [v(s(ot.revoked_at, p), f(ot.revoked_at))];
2658
+ let { page: o = 0, per_page: c = 50, include_totals: l = !1, sort: u, q: d } = a || {}, p = (/* @__PURE__ */ new Date()).toISOString(), m = [v(s(ct.revoked_at, p), f(ct.revoked_at))];
2622
2659
  if (d) {
2623
- let e = Te(d, jn);
2660
+ let e = Ee(d, Fn);
2624
2661
  if (e) {
2625
- let t = vt(ot, e, jn);
2662
+ let t = St(ct, e, Fn);
2626
2663
  t && m.push(t);
2627
2664
  }
2628
2665
  }
2629
- let h = t(...m), g = e.select().from(ot).where(h).$dynamic();
2666
+ let h = t(...m), g = e.select().from(ct).where(h).$dynamic();
2630
2667
  if (u?.sort_by) {
2631
- let e = ot[u.sort_by];
2668
+ let e = ct[u.sort_by];
2632
2669
  e && (g = g.orderBy(u.sort_order === "desc" ? i(e) : n(e)));
2633
2670
  }
2634
2671
  let _ = (await g.offset(o * c).limit(c)).map((e) => {
@@ -2636,7 +2673,7 @@ function Mn(e) {
2636
2673
  return D(n);
2637
2674
  });
2638
2675
  if (!l) return { signingKeys: _ };
2639
- let [y] = await e.select({ count: r() }).from(ot).where(h);
2676
+ let [y] = await e.select({ count: r() }).from(ct).where(h);
2640
2677
  return {
2641
2678
  signingKeys: _,
2642
2679
  start: o * c,
@@ -2645,22 +2682,22 @@ function Mn(e) {
2645
2682
  };
2646
2683
  },
2647
2684
  async update(t, n) {
2648
- return (await e.update(ot).set(n).where(a(ot.kid, t)).returning()).length > 0;
2685
+ return (await e.update(ct).set(n).where(a(ct.kid, t)).returning()).length > 0;
2649
2686
  }
2650
2687
  };
2651
2688
  }
2652
2689
  //#endregion
2653
2690
  //#region src/adapters/loginSessions.ts
2654
- var Nn = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", Pn = 32;
2655
- function Fn() {
2691
+ var Ln = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", Rn = 32;
2692
+ function zn() {
2656
2693
  let e = Date.now(), t = "";
2657
- for (let n = 10; n > 0; n--) t = Nn.charAt(e % Pn) + t, e = Math.floor(e / Pn);
2694
+ for (let n = 10; n > 0; n--) t = Ln.charAt(e % Rn) + t, e = Math.floor(e / Rn);
2658
2695
  let n = new Uint8Array(16);
2659
2696
  crypto.getRandomValues(n);
2660
- for (let e = 0; e < 16; e++) t += Nn.charAt(n[e] % Pn);
2697
+ for (let e = 0; e < 16; e++) t += Ln.charAt(n[e] % Rn);
2661
2698
  return t;
2662
2699
  }
2663
- function In(e) {
2700
+ function Bn(e) {
2664
2701
  let { tenant_id: t, created_at_ts: n, updated_at_ts: r, expires_at_ts: i, state_data: a, auth_params: o, ...s } = e, c = ae({
2665
2702
  created_at_ts: n,
2666
2703
  updated_at_ts: r,
@@ -2672,17 +2709,17 @@ function In(e) {
2672
2709
  ]), l = {};
2673
2710
  for (let [e, t] of Object.entries(s)) t != null && (l[e] = t);
2674
2711
  return D({
2675
- ...ht(l, ["auth_strategy"]),
2712
+ ...yt(l, ["auth_strategy"]),
2676
2713
  authParams: typeof o == "string" && o.length > 0 ? JSON.parse(o) : {},
2677
2714
  ...c,
2678
2715
  state_data: Z(a)
2679
2716
  });
2680
2717
  }
2681
- function Ln(e) {
2718
+ function Vn(e) {
2682
2719
  return {
2683
2720
  async create(t, n) {
2684
2721
  let r = Date.now(), i = {
2685
- id: Fn(),
2722
+ id: zn(),
2686
2723
  tenant_id: t,
2687
2724
  session_id: n.session_id,
2688
2725
  csrf_token: n.csrf_token,
@@ -2703,14 +2740,14 @@ function Ln(e) {
2703
2740
  updated_at_ts: r,
2704
2741
  expires_at_ts: n.expires_at ? E(n.expires_at) : r + 1e3 * 60 * 60 * 24
2705
2742
  };
2706
- return await e.insert(P).values(i), In({
2743
+ return await e.insert(P).values(i), Bn({
2707
2744
  ...i,
2708
2745
  tenant_id: t
2709
2746
  });
2710
2747
  },
2711
2748
  async get(n, r) {
2712
2749
  let i = n ? t(a(P.tenant_id, n), a(P.id, r)) : a(P.id, r), o = await e.select().from(P).where(i).get();
2713
- return o ? In(o) : null;
2750
+ return o ? Bn(o) : null;
2714
2751
  },
2715
2752
  async update(n, r, i) {
2716
2753
  let o = { updated_at_ts: Date.now() };
@@ -2730,7 +2767,7 @@ function Ln(e) {
2730
2767
  }
2731
2768
  //#endregion
2732
2769
  //#region src/adapters/logs.ts
2733
- function Rn(e) {
2770
+ function Hn(e) {
2734
2771
  let { tenant_id: t, isMobile: n, auth0_client: r, details: i, country_code: a, city_name: o, latitude: s, longitude: c, time_zone: l, continent_code: u, scope: d, ...f } = e, p = {
2735
2772
  ...f,
2736
2773
  isMobile: !!n,
@@ -2747,7 +2784,7 @@ function Rn(e) {
2747
2784
  continent_code: u
2748
2785
  })), D(p);
2749
2786
  }
2750
- function zn(e) {
2787
+ function Un(e) {
2751
2788
  return {
2752
2789
  async create(t, n) {
2753
2790
  let r = {
@@ -2773,7 +2810,7 @@ function zn(e) {
2773
2810
  hostname: n.hostname,
2774
2811
  session_connection: n.session_connection
2775
2812
  };
2776
- return n.auth0_client && (r.auth0_client = JSON.stringify(n.auth0_client)), n.details && (r.details = JSON.stringify(n.details).substring(0, 8192)), n.location_info && (r.country_code = n.location_info.country_code, r.city_name = n.location_info.city_name, r.latitude = n.location_info.latitude, r.longitude = n.location_info.longitude, r.time_zone = n.location_info.time_zone, r.continent_code = n.location_info.continent_code), await e.insert(q).values(r), Rn({
2813
+ return n.auth0_client && (r.auth0_client = JSON.stringify(n.auth0_client)), n.details && (r.details = JSON.stringify(n.details).substring(0, 8192)), n.location_info && (r.country_code = n.location_info.country_code, r.city_name = n.location_info.city_name, r.latitude = n.location_info.latitude, r.longitude = n.location_info.longitude, r.time_zone = n.location_info.time_zone, r.continent_code = n.location_info.continent_code), await e.insert(q).values(r), Hn({
2777
2814
  ...r,
2778
2815
  tenant_id: t
2779
2816
  });
@@ -2781,7 +2818,7 @@ function zn(e) {
2781
2818
  async list(o, s) {
2782
2819
  let { page: l = 0, per_page: u = 50, include_totals: d = !1, sort: f, q: p, from_date: h, to_date: g } = s || {}, _ = [a(q.tenant_id, o)];
2783
2820
  if (p) {
2784
- let e = vt(q, p, [
2821
+ let e = St(q, p, [
2785
2822
  "user_id",
2786
2823
  "ip",
2787
2824
  "type",
@@ -2791,14 +2828,14 @@ function zn(e) {
2791
2828
  }
2792
2829
  typeof h == "number" && Number.isFinite(h) && _.push(c(q.date, (/* @__PURE__ */ new Date(Math.floor(h) * 1e3)).toISOString())), typeof g == "number" && Number.isFinite(g) && _.push(m(q.date, (/* @__PURE__ */ new Date((Math.floor(g) + 1) * 1e3)).toISOString()));
2793
2830
  let v = t(..._);
2794
- if (At(s)) {
2795
- if (f?.sort_by && f.sort_by !== "date") throw new Le(400, { message: `Sorting by ${f.sort_by} is not supported with checkpoint pagination (from/take); only date is` });
2831
+ if (Pt(s)) {
2832
+ if (f?.sort_by && f.sort_by !== "date") throw new Re(400, { message: `Sorting by ${f.sort_by} is not supported with checkpoint pagination (from/take); only date is` });
2796
2833
  let n = f?.sort_order === "asc" ? "asc" : "desc", r = {
2797
2834
  sortColumn: q.date,
2798
2835
  idColumn: q.log_id,
2799
2836
  sortOrder: n,
2800
2837
  sortKey: `date:${n}`
2801
- }, i = Nt(s, r), a = jt(s), { rows: o, next: c } = Pt(await e.select().from(q).where(i ? t(v, i) : v).orderBy(...Mt(r)).limit(a + 1), a, "date", "log_id", r.sortKey), l = o.map(Rn);
2838
+ }, i = Lt(s, r), a = Ft(s), { rows: o, next: c } = Rt(await e.select().from(q).where(i ? t(v, i) : v).orderBy(...It(r)).limit(a + 1), a, "date", "log_id", r.sortKey), l = o.map(Hn);
2802
2839
  return {
2803
2840
  logs: l,
2804
2841
  start: 0,
@@ -2812,7 +2849,7 @@ function zn(e) {
2812
2849
  let e = q[f.sort_by];
2813
2850
  e && (y = y.orderBy(f.sort_order === "desc" ? i(e) : n(e)));
2814
2851
  } else y = y.orderBy(i(q.date));
2815
- let ee = (await y.offset(l * u).limit(u)).map(Rn);
2852
+ let ee = (await y.offset(l * u).limit(u)).map(Hn);
2816
2853
  if (!d) return { logs: ee };
2817
2854
  let [b] = await e.select({ count: r() }).from(q).where(v);
2818
2855
  return {
@@ -2824,22 +2861,22 @@ function zn(e) {
2824
2861
  },
2825
2862
  async get(n, r) {
2826
2863
  let i = await e.select().from(q).where(t(a(q.tenant_id, n), a(q.log_id, r))).get();
2827
- return i ? Rn(i) : null;
2864
+ return i ? Hn(i) : null;
2828
2865
  }
2829
2866
  };
2830
2867
  }
2831
2868
  //#endregion
2832
2869
  //#region src/adapters/authenticationMethods.ts
2833
- var Bn = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", Vn = 32;
2834
- function Hn() {
2870
+ var Wn = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", Gn = 32;
2871
+ function Kn() {
2835
2872
  let e = Date.now(), t = "";
2836
- for (let n = 10; n > 0; n--) t = Bn.charAt(e % Vn) + t, e = Math.floor(e / Vn);
2873
+ for (let n = 10; n > 0; n--) t = Wn.charAt(e % Gn) + t, e = Math.floor(e / Gn);
2837
2874
  let n = new Uint8Array(16);
2838
2875
  crypto.getRandomValues(n);
2839
- for (let e = 0; e < 16; e++) t += Bn.charAt(n[e] % Vn);
2876
+ for (let e = 0; e < 16; e++) t += Wn.charAt(n[e] % Gn);
2840
2877
  return t;
2841
2878
  }
2842
- function Un(e) {
2879
+ function qn(e) {
2843
2880
  let { tenant_id: t, created_at_ts: n, updated_at_ts: r, credential_backed_up: i, confirmed: a, transports: o, ...s } = e;
2844
2881
  return D({
2845
2882
  ...s,
@@ -2850,11 +2887,11 @@ function Un(e) {
2850
2887
  updated_at: oe(r)
2851
2888
  });
2852
2889
  }
2853
- function Wn(e) {
2890
+ function Jn(e) {
2854
2891
  return {
2855
2892
  async create(t, n) {
2856
2893
  let r = Date.now(), i = {
2857
- id: n.id || Hn(),
2894
+ id: n.id || Kn(),
2858
2895
  tenant_id: t,
2859
2896
  user_id: n.user_id,
2860
2897
  type: n.type,
@@ -2870,41 +2907,41 @@ function Wn(e) {
2870
2907
  created_at_ts: r,
2871
2908
  updated_at_ts: r
2872
2909
  };
2873
- return await e.insert(lt).values(i), Un({
2910
+ return await e.insert(dt).values(i), qn({
2874
2911
  ...i,
2875
2912
  tenant_id: t
2876
2913
  });
2877
2914
  },
2878
2915
  async get(n, r) {
2879
- let i = await e.select().from(lt).where(t(a(lt.tenant_id, n), a(lt.id, r))).get();
2880
- return i ? Un(i) : null;
2916
+ let i = await e.select().from(dt).where(t(a(dt.tenant_id, n), a(dt.id, r))).get();
2917
+ return i ? qn(i) : null;
2881
2918
  },
2882
2919
  async getByCredentialId(n, r) {
2883
- let i = await e.select().from(lt).where(t(a(lt.tenant_id, n), a(lt.credential_id, r))).get();
2884
- return i ? Un(i) : null;
2920
+ let i = await e.select().from(dt).where(t(a(dt.tenant_id, n), a(dt.credential_id, r))).get();
2921
+ return i ? qn(i) : null;
2885
2922
  },
2886
2923
  async list(n, r) {
2887
- return (await e.select().from(lt).where(t(a(lt.tenant_id, n), a(lt.user_id, r))).all()).map(Un);
2924
+ return (await e.select().from(dt).where(t(a(dt.tenant_id, n), a(dt.user_id, r))).all()).map(qn);
2888
2925
  },
2889
2926
  async update(n, r, i) {
2890
2927
  let o = { updated_at_ts: Date.now() };
2891
- i.type !== void 0 && (o.type = i.type), i.phone_number !== void 0 && (o.phone_number = i.phone_number), i.totp_secret !== void 0 && (o.totp_secret = i.totp_secret), i.credential_id !== void 0 && (o.credential_id = i.credential_id), i.public_key !== void 0 && (o.public_key = i.public_key), i.sign_count !== void 0 && (o.sign_count = i.sign_count), i.credential_backed_up !== void 0 && (o.credential_backed_up = +!!i.credential_backed_up), i.transports !== void 0 && (o.transports = JSON.stringify(i.transports)), i.friendly_name !== void 0 && (o.friendly_name = i.friendly_name), i.confirmed !== void 0 && (o.confirmed = +!!i.confirmed), await e.update(lt).set(o).where(t(a(lt.tenant_id, n), a(lt.id, r)));
2928
+ i.type !== void 0 && (o.type = i.type), i.phone_number !== void 0 && (o.phone_number = i.phone_number), i.totp_secret !== void 0 && (o.totp_secret = i.totp_secret), i.credential_id !== void 0 && (o.credential_id = i.credential_id), i.public_key !== void 0 && (o.public_key = i.public_key), i.sign_count !== void 0 && (o.sign_count = i.sign_count), i.credential_backed_up !== void 0 && (o.credential_backed_up = +!!i.credential_backed_up), i.transports !== void 0 && (o.transports = JSON.stringify(i.transports)), i.friendly_name !== void 0 && (o.friendly_name = i.friendly_name), i.confirmed !== void 0 && (o.confirmed = +!!i.confirmed), await e.update(dt).set(o).where(t(a(dt.tenant_id, n), a(dt.id, r)));
2892
2929
  let s = await this.get(n, r);
2893
2930
  if (!s) throw Error(`Authentication method ${r} not found after update`);
2894
2931
  return s;
2895
2932
  },
2896
2933
  async remove(n, r) {
2897
- return (await e.delete(lt).where(t(a(lt.tenant_id, n), a(lt.id, r))).returning()).length > 0;
2934
+ return (await e.delete(dt).where(t(a(dt.tenant_id, n), a(dt.id, r))).returning()).length > 0;
2898
2935
  }
2899
2936
  };
2900
2937
  }
2901
2938
  //#endregion
2902
2939
  //#region src/adapters/organizations.ts
2903
- var Gn = ["name", "display_name"];
2904
- function Kn() {
2940
+ var Yn = ["name", "display_name"];
2941
+ function Xn() {
2905
2942
  return `org_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
2906
2943
  }
2907
- function qn(e) {
2944
+ function Zn(e) {
2908
2945
  let { tenant_id: t, branding: n, metadata: r, enabled_connections: i, token_quota: a, ...o } = e;
2909
2946
  return D({
2910
2947
  ...o,
@@ -2914,11 +2951,11 @@ function qn(e) {
2914
2951
  token_quota: Z(a, {})
2915
2952
  });
2916
2953
  }
2917
- function Jn(e) {
2954
+ function Qn(e) {
2918
2955
  return {
2919
2956
  async create(t, n) {
2920
2957
  let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
2921
- id: n.id || Kn(),
2958
+ id: n.id || Xn(),
2922
2959
  tenant_id: t,
2923
2960
  name: n.name,
2924
2961
  display_name: n.display_name,
@@ -2932,16 +2969,16 @@ function Jn(e) {
2932
2969
  try {
2933
2970
  await e.insert(V).values(i);
2934
2971
  } catch (e) {
2935
- throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("AlreadyExists") ? new Le(409, { message: "Organization already exists" }) : e;
2972
+ throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("AlreadyExists") ? new Re(409, { message: "Organization already exists" }) : e;
2936
2973
  }
2937
- return qn({
2974
+ return Zn({
2938
2975
  ...i,
2939
2976
  tenant_id: t
2940
2977
  });
2941
2978
  },
2942
2979
  async get(n, r) {
2943
2980
  let i = await e.select().from(V).where(t(a(V.tenant_id, n), a(V.id, r))).get();
2944
- return i ||= await e.select().from(V).where(t(a(V.tenant_id, n), a(V.name, r))).get(), i ? qn(i) : null;
2981
+ return i ||= await e.select().from(V).where(t(a(V.tenant_id, n), a(V.name, r))).get(), i ? Zn(i) : null;
2945
2982
  },
2946
2983
  async update(n, r, i) {
2947
2984
  let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
@@ -2950,19 +2987,19 @@ function Jn(e) {
2950
2987
  async list(o, s) {
2951
2988
  let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(V.tenant_id, o)];
2952
2989
  if (f) {
2953
- let e = Te(f, Gn);
2990
+ let e = Ee(f, Yn);
2954
2991
  if (e) {
2955
- let t = vt(V, e, Gn);
2992
+ let t = St(V, e, Yn);
2956
2993
  t && p.push(t);
2957
2994
  }
2958
2995
  }
2959
2996
  let m = t(...p);
2960
- if (At(s)) {
2997
+ if (Pt(s)) {
2961
2998
  let n = {
2962
2999
  sortColumn: V.created_at,
2963
3000
  idColumn: V.id,
2964
3001
  sortOrder: "desc"
2965
- }, r = Nt(s, n), i = jt(s), { rows: a, next: o } = Pt(await e.select().from(V).where(r ? t(m, r) : m).orderBy(...Mt(n)).limit(i + 1), i, "created_at"), c = a.map(qn);
3002
+ }, r = Lt(s, n), i = Ft(s), { rows: a, next: o } = Rt(await e.select().from(V).where(r ? t(m, r) : m).orderBy(...It(n)).limit(i + 1), i, "created_at"), c = a.map(Zn);
2966
3003
  return {
2967
3004
  organizations: c,
2968
3005
  start: 0,
@@ -2977,7 +3014,7 @@ function Jn(e) {
2977
3014
  let e = V[d.sort_by];
2978
3015
  e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
2979
3016
  }
2980
- let g = (await h.offset(c * l).limit(l)).map(qn);
3017
+ let g = (await h.offset(c * l).limit(l)).map(Zn);
2981
3018
  if (!u) return { organizations: g };
2982
3019
  let [_] = await e.select({ count: r() }).from(V).where(m);
2983
3020
  return {
@@ -2993,15 +3030,172 @@ function Jn(e) {
2993
3030
  };
2994
3031
  }
2995
3032
  //#endregion
3033
+ //#region src/adapters/organizationConnections.ts
3034
+ function $n(e, t) {
3035
+ return {
3036
+ connection_id: e.connection_id,
3037
+ assign_membership_on_login: !!e.assign_membership_on_login,
3038
+ show_as_button: !!e.show_as_button,
3039
+ is_signup_enabled: !!e.is_signup_enabled,
3040
+ connection: t ? {
3041
+ name: t.name,
3042
+ strategy: t.strategy
3043
+ } : void 0,
3044
+ created_at: e.created_at,
3045
+ updated_at: e.updated_at
3046
+ };
3047
+ }
3048
+ function er(e) {
3049
+ async function n(n, r) {
3050
+ let i = await e.select({
3051
+ name: B.name,
3052
+ strategy: B.strategy
3053
+ }).from(B).where(t(a(B.tenant_id, n), a(B.id, r))).get();
3054
+ if (i) return {
3055
+ name: i.name,
3056
+ strategy: typeof i.strategy == "string" ? i.strategy : void 0
3057
+ };
3058
+ }
3059
+ let r = (e, n, r) => t(a(Xe.tenant_id, e), a(Xe.organization_id, n), a(Xe.connection_id, r));
3060
+ return {
3061
+ async create(t, r, i, a) {
3062
+ let o = a?.importMetadata, s = (/* @__PURE__ */ new Date()).toISOString(), c = {
3063
+ tenant_id: t,
3064
+ organization_id: r,
3065
+ connection_id: i.connection_id,
3066
+ assign_membership_on_login: +!!i.assign_membership_on_login,
3067
+ show_as_button: i.show_as_button === !1 ? 0 : 1,
3068
+ is_signup_enabled: i.is_signup_enabled === !1 ? 0 : 1,
3069
+ created_at: o?.created_at ?? s,
3070
+ updated_at: o?.updated_at ?? s
3071
+ };
3072
+ return await e.insert(Xe).values(c), $n(c, await n(t, i.connection_id));
3073
+ },
3074
+ async list(r, i) {
3075
+ let o = await e.select().from(Xe).where(t(a(Xe.tenant_id, r), a(Xe.organization_id, i))).all(), s = [];
3076
+ for (let e of o) s.push($n(e, await n(r, e.connection_id)));
3077
+ return s;
3078
+ },
3079
+ async get(t, i, a) {
3080
+ let o = await e.select().from(Xe).where(r(t, i, a)).get();
3081
+ return o ? $n(o, await n(t, a)) : null;
3082
+ },
3083
+ async update(t, i, a, o) {
3084
+ let s = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
3085
+ o.assign_membership_on_login !== void 0 && (s.assign_membership_on_login = +!!o.assign_membership_on_login), o.show_as_button !== void 0 && (s.show_as_button = +!!o.show_as_button), o.is_signup_enabled !== void 0 && (s.is_signup_enabled = +!!o.is_signup_enabled);
3086
+ let c = await e.update(Xe).set(s).where(r(t, i, a)).returning();
3087
+ return c.length === 0 ? null : $n(c[0], await n(t, a));
3088
+ },
3089
+ async remove(t, n, i) {
3090
+ return (await e.delete(Xe).where(r(t, n, i)).returning({ id: Xe.connection_id })).length > 0;
3091
+ }
3092
+ };
3093
+ }
3094
+ //#endregion
3095
+ //#region src/adapters/logStreams.ts
3096
+ function tr(e) {
3097
+ return {
3098
+ id: e.id,
3099
+ name: e.name,
3100
+ type: e.type,
3101
+ status: e.status,
3102
+ sink: JSON.parse(e.sink),
3103
+ filters: e.filters ? JSON.parse(e.filters) : void 0,
3104
+ isPriority: e.is_priority == null ? void 0 : e.is_priority === 1,
3105
+ created_at: e.created_at,
3106
+ updated_at: e.updated_at
3107
+ };
3108
+ }
3109
+ function nr(e) {
3110
+ return {
3111
+ async create(t, n, r) {
3112
+ let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = {
3113
+ id: i?.id ?? `lst_${b()}`,
3114
+ tenant_id: t,
3115
+ name: n.name,
3116
+ type: n.type,
3117
+ status: n.status ?? "active",
3118
+ sink: JSON.stringify(n.sink),
3119
+ filters: n.filters ? JSON.stringify(n.filters) : null,
3120
+ is_priority: n.isPriority === void 0 ? null : +!!n.isPriority,
3121
+ created_at: i?.created_at ?? a,
3122
+ updated_at: i?.updated_at ?? a
3123
+ };
3124
+ return await e.insert(ht).values(o), tr(o);
3125
+ },
3126
+ async get(n, r) {
3127
+ let i = await e.select().from(ht).where(t(a(ht.tenant_id, n), a(ht.id, r))).get();
3128
+ return i ? tr(i) : null;
3129
+ },
3130
+ async list(t) {
3131
+ return (await e.select().from(ht).where(a(ht.tenant_id, t)).all()).map(tr);
3132
+ },
3133
+ async update(n, r, i) {
3134
+ let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
3135
+ return i.name !== void 0 && (o.name = i.name), i.type !== void 0 && (o.type = i.type), i.status !== void 0 && (o.status = i.status), i.sink !== void 0 && (o.sink = JSON.stringify(i.sink)), i.filters !== void 0 && (o.filters = i.filters ? JSON.stringify(i.filters) : null), i.isPriority !== void 0 && (o.is_priority = +!!i.isPriority), (await e.update(ht).set(o).where(t(a(ht.tenant_id, n), a(ht.id, r))).returning({ id: ht.id })).length > 0;
3136
+ },
3137
+ async remove(n, r) {
3138
+ return (await e.delete(ht).where(t(a(ht.tenant_id, n), a(ht.id, r))).returning({ id: ht.id })).length > 0;
3139
+ }
3140
+ };
3141
+ }
3142
+ //#endregion
3143
+ //#region src/adapters/migrationSources.ts
3144
+ function rr(e) {
3145
+ return {
3146
+ id: e.id,
3147
+ name: e.name,
3148
+ provider: Se.parse(e.provider),
3149
+ connection: e.connection,
3150
+ enabled: e.enabled === 1,
3151
+ credentials: JSON.parse(e.credentials),
3152
+ created_at: e.created_at,
3153
+ updated_at: e.updated_at
3154
+ };
3155
+ }
3156
+ function ir(e) {
3157
+ let n = (e, n) => t(a(gt.tenant_id, e), a(gt.id, n));
3158
+ return {
3159
+ async create(t, n, r) {
3160
+ let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = {
3161
+ id: i?.id ?? n.id ?? `mig_${b()}`,
3162
+ tenant_id: t,
3163
+ name: n.name,
3164
+ provider: n.provider,
3165
+ connection: n.connection,
3166
+ enabled: n.enabled ?? !0 ? 1 : 0,
3167
+ credentials: JSON.stringify(n.credentials),
3168
+ created_at: i?.created_at ?? a,
3169
+ updated_at: i?.updated_at ?? a
3170
+ };
3171
+ return await e.insert(gt).values(o), rr(o);
3172
+ },
3173
+ async get(t, r) {
3174
+ let i = await e.select().from(gt).where(n(t, r)).get();
3175
+ return i ? rr(i) : null;
3176
+ },
3177
+ async list(t) {
3178
+ return (await e.select().from(gt).where(a(gt.tenant_id, t)).all()).map(rr);
3179
+ },
3180
+ async update(t, r, i) {
3181
+ let a = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
3182
+ return i.name !== void 0 && (a.name = i.name), i.provider !== void 0 && (a.provider = i.provider), i.connection !== void 0 && (a.connection = i.connection), i.enabled !== void 0 && (a.enabled = +!!i.enabled), i.credentials !== void 0 && (a.credentials = JSON.stringify(i.credentials)), (await e.update(gt).set(a).where(n(t, r)).returning({ id: gt.id })).length > 0;
3183
+ },
3184
+ async remove(t, r) {
3185
+ return (await e.delete(gt).where(n(t, r)).returning({ id: gt.id })).length > 0;
3186
+ }
3187
+ };
3188
+ }
3189
+ //#endregion
2996
3190
  //#region src/adapters/passwords.ts
2997
- function Yn(e) {
3191
+ function ar(e) {
2998
3192
  let { tenant_id: t, is_current: n, ...r } = e;
2999
3193
  return {
3000
3194
  ...r,
3001
3195
  is_current: !!n
3002
3196
  };
3003
3197
  }
3004
- function Xn(e) {
3198
+ function or(e) {
3005
3199
  return {
3006
3200
  async create(n, r) {
3007
3201
  let i = (/* @__PURE__ */ new Date()).toISOString(), o = r.id || b();
@@ -3016,18 +3210,18 @@ function Xn(e) {
3016
3210
  created_at: i,
3017
3211
  updated_at: i
3018
3212
  };
3019
- return await e.insert(j).values(s), Yn({
3213
+ return await e.insert(j).values(s), ar({
3020
3214
  ...s,
3021
3215
  tenant_id: n
3022
3216
  });
3023
3217
  },
3024
3218
  async get(n, r) {
3025
3219
  let i = await e.select().from(j).where(t(a(j.tenant_id, n), a(j.user_id, r), a(j.is_current, 1))).get();
3026
- return i ? Yn(i) : null;
3220
+ return i ? ar(i) : null;
3027
3221
  },
3028
3222
  async list(n, r, o) {
3029
3223
  let s = e.select().from(j).where(t(a(j.tenant_id, n), a(j.user_id, r))).orderBy(i(j.created_at)).$dynamic();
3030
- return o && (s = s.limit(o)), (await s).map(Yn);
3224
+ return o && (s = s.limit(o)), (await s).map(ar);
3031
3225
  },
3032
3226
  async update(n, r) {
3033
3227
  let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
@@ -3037,10 +3231,10 @@ function Xn(e) {
3037
3231
  }
3038
3232
  //#endregion
3039
3233
  //#region src/adapters/promptSettings.ts
3040
- function Zn(e) {
3234
+ function sr(e) {
3041
3235
  return {
3042
3236
  async get(t) {
3043
- let n = await e.select().from(tt).where(a(tt.tenant_id, t)).get();
3237
+ let n = await e.select().from(rt).where(a(rt.tenant_id, t)).get();
3044
3238
  return n ? {
3045
3239
  universal_login_experience: n.universal_login_experience,
3046
3240
  identifier_first: !!n.identifier_first,
@@ -3056,7 +3250,7 @@ function Zn(e) {
3056
3250
  };
3057
3251
  },
3058
3252
  async set(t, n) {
3059
- await e.insert(tt).values({
3253
+ await e.insert(rt).values({
3060
3254
  tenant_id: t,
3061
3255
  universal_login_experience: n.universal_login_experience,
3062
3256
  identifier_first: n.identifier_first,
@@ -3064,7 +3258,7 @@ function Zn(e) {
3064
3258
  webauthn_platform_first_factor: n.webauthn_platform_first_factor,
3065
3259
  show_last_used_connection: n.show_last_used_connection
3066
3260
  }).onConflictDoUpdate({
3067
- target: tt.tenant_id,
3261
+ target: rt.tenant_id,
3068
3262
  set: {
3069
3263
  universal_login_experience: n.universal_login_experience,
3070
3264
  identifier_first: n.identifier_first,
@@ -3078,10 +3272,10 @@ function Zn(e) {
3078
3272
  }
3079
3273
  //#endregion
3080
3274
  //#region src/adapters/promptPartials.ts
3081
- function Qn(e) {
3275
+ function cr(e) {
3082
3276
  return {
3083
3277
  async get(n, r) {
3084
- let i = await e.select({ body: ct.body }).from(ct).where(t(a(ct.tenant_id, n), a(ct.prompt, r))).get();
3278
+ let i = await e.select({ body: ut.body }).from(ut).where(t(a(ut.tenant_id, n), a(ut.prompt, r))).get();
3085
3279
  if (!i) return null;
3086
3280
  try {
3087
3281
  return JSON.parse(i.body);
@@ -3091,14 +3285,14 @@ function Qn(e) {
3091
3285
  },
3092
3286
  async set(t, n, r, i) {
3093
3287
  let a = Date.now(), o = i?.importMetadata?.created_at, s = i?.importMetadata?.updated_at, c = o ? new Date(o).getTime() : a, l = s ? new Date(s).getTime() : c, u = JSON.stringify(r);
3094
- await e.insert(ct).values({
3288
+ await e.insert(ut).values({
3095
3289
  tenant_id: t,
3096
3290
  prompt: n,
3097
3291
  body: u,
3098
3292
  created_at_ts: c,
3099
3293
  updated_at_ts: l
3100
3294
  }).onConflictDoUpdate({
3101
- target: [ct.tenant_id, ct.prompt],
3295
+ target: [ut.tenant_id, ut.prompt],
3102
3296
  set: {
3103
3297
  body: u,
3104
3298
  updated_at_ts: s ? l : a
@@ -3106,16 +3300,16 @@ function Qn(e) {
3106
3300
  });
3107
3301
  },
3108
3302
  async delete(n, r) {
3109
- await e.delete(ct).where(t(a(ct.tenant_id, n), a(ct.prompt, r)));
3303
+ await e.delete(ut).where(t(a(ut.tenant_id, n), a(ut.prompt, r)));
3110
3304
  },
3111
3305
  async list(t) {
3112
- return (await e.select({ prompt: ct.prompt }).from(ct).where(a(ct.tenant_id, t)).all()).map(({ prompt: e }) => e);
3306
+ return (await e.select({ prompt: ut.prompt }).from(ut).where(a(ut.tenant_id, t)).all()).map(({ prompt: e }) => e);
3113
3307
  }
3114
3308
  };
3115
3309
  }
3116
3310
  //#endregion
3117
3311
  //#region src/adapters/proxyRoutes.ts
3118
- function $n(e) {
3312
+ function lr(e) {
3119
3313
  if (!e) return { path: "/*" };
3120
3314
  try {
3121
3315
  let t = JSON.parse(e), n = xe.safeParse(t);
@@ -3123,7 +3317,7 @@ function $n(e) {
3123
3317
  } catch {}
3124
3318
  return { path: "/*" };
3125
3319
  }
3126
- function er(e) {
3320
+ function ur(e) {
3127
3321
  if (!e) return [];
3128
3322
  try {
3129
3323
  let t = JSON.parse(e);
@@ -3138,19 +3332,19 @@ function er(e) {
3138
3332
  return [];
3139
3333
  }
3140
3334
  }
3141
- function tr(e) {
3335
+ function dr(e) {
3142
3336
  return {
3143
3337
  id: e.id,
3144
3338
  tenant_id: e.tenant_id,
3145
3339
  custom_domain_id: e.custom_domain_id,
3146
3340
  priority: e.priority,
3147
- match: $n(e.match),
3148
- handlers: er(e.handlers),
3341
+ match: lr(e.match),
3342
+ handlers: ur(e.handlers),
3149
3343
  created_at: e.created_at,
3150
3344
  updated_at: e.updated_at
3151
3345
  };
3152
3346
  }
3153
- function nr(e) {
3347
+ function fr(e) {
3154
3348
  return {
3155
3349
  async create(t, n) {
3156
3350
  let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
@@ -3176,14 +3370,14 @@ function nr(e) {
3176
3370
  },
3177
3371
  async get(n, r) {
3178
3372
  let i = await e.select().from(Y).where(t(a(Y.tenant_id, n), a(Y.id, r))).limit(1);
3179
- return i[0] ? tr(i[0]) : null;
3373
+ return i[0] ? dr(i[0]) : null;
3180
3374
  },
3181
3375
  async list(r, i = {}) {
3182
3376
  let o = i.page ?? 0, s = i.per_page ?? 50, c = [a(Y.tenant_id, r)];
3183
3377
  i.custom_domain_id && c.push(a(Y.custom_domain_id, i.custom_domain_id));
3184
3378
  let l = await e.select().from(Y).where(t(...c)).orderBy(n(Y.priority), n(Y.created_at)).offset(o * s).limit(s);
3185
3379
  return {
3186
- proxy_routes: l.map(tr),
3380
+ proxy_routes: l.map(dr),
3187
3381
  start: o * s,
3188
3382
  limit: s,
3189
3383
  length: l.length
@@ -3202,16 +3396,16 @@ function nr(e) {
3202
3396
  }
3203
3397
  //#endregion
3204
3398
  //#region src/adapters/tokenExchangeProfiles.ts
3205
- var rr = ee("0123456789abcdefghijklmnopqrstuvwxyz", 17);
3206
- function ir(e) {
3399
+ var pr = ee("0123456789abcdefghijklmnopqrstuvwxyz", 17);
3400
+ function mr(e) {
3207
3401
  if (e) try {
3208
- let t = Fe.safeParse(JSON.parse(e));
3402
+ let t = Ie.safeParse(JSON.parse(e));
3209
3403
  return t.success ? t.data : void 0;
3210
3404
  } catch {
3211
3405
  return;
3212
3406
  }
3213
3407
  }
3214
- function ar(e) {
3408
+ function hr(e) {
3215
3409
  let t = {
3216
3410
  id: e.id,
3217
3411
  name: e.name,
@@ -3221,14 +3415,14 @@ function ar(e) {
3221
3415
  updated_at: e.updated_at
3222
3416
  };
3223
3417
  e.action_id && (t.action_id = e.action_id);
3224
- let n = ir(e.jwt_verification);
3418
+ let n = mr(e.jwt_verification);
3225
3419
  return n && (t.jwt_verification = n), t;
3226
3420
  }
3227
- function or(e) {
3421
+ function gr(e) {
3228
3422
  return {
3229
3423
  async create(t, n, r) {
3230
3424
  let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = {
3231
- id: i?.id ?? `tep_${rr()}`,
3425
+ id: i?.id ?? `tep_${pr()}`,
3232
3426
  tenant_id: t,
3233
3427
  name: n.name,
3234
3428
  subject_token_type: n.subject_token_type,
@@ -3238,34 +3432,34 @@ function or(e) {
3238
3432
  created_at: i?.created_at ?? a,
3239
3433
  updated_at: i?.updated_at ?? a
3240
3434
  };
3241
- return await e.insert(ft).values(o), ar(o);
3435
+ return await e.insert(mt).values(o), hr(o);
3242
3436
  },
3243
3437
  async get(n, r) {
3244
- let i = await e.select().from(ft).where(t(a(ft.tenant_id, n), a(ft.id, r))).limit(1);
3245
- return i[0] ? ar(i[0]) : null;
3438
+ let i = await e.select().from(mt).where(t(a(mt.tenant_id, n), a(mt.id, r))).limit(1);
3439
+ return i[0] ? hr(i[0]) : null;
3246
3440
  },
3247
3441
  async list(t) {
3248
- return (await e.select().from(ft).where(a(ft.tenant_id, t)).orderBy(n(ft.created_at), n(ft.id))).map(ar);
3442
+ return (await e.select().from(mt).where(a(mt.tenant_id, t)).orderBy(n(mt.created_at), n(mt.id))).map(hr);
3249
3443
  },
3250
3444
  async update(n, r, i) {
3251
3445
  let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
3252
- return i.name !== void 0 && (o.name = i.name), i.subject_token_type !== void 0 && (o.subject_token_type = i.subject_token_type), i.jwt_verification !== void 0 && (o.jwt_verification = JSON.stringify(i.jwt_verification)), (await e.update(ft).set(o).where(t(a(ft.tenant_id, n), a(ft.id, r))).returning({ id: ft.id })).length > 0;
3446
+ return i.name !== void 0 && (o.name = i.name), i.subject_token_type !== void 0 && (o.subject_token_type = i.subject_token_type), i.jwt_verification !== void 0 && (o.jwt_verification = JSON.stringify(i.jwt_verification)), (await e.update(mt).set(o).where(t(a(mt.tenant_id, n), a(mt.id, r))).returning({ id: mt.id })).length > 0;
3253
3447
  },
3254
3448
  async remove(n, r) {
3255
- return (await e.delete(ft).where(t(a(ft.tenant_id, n), a(ft.id, r))).returning({ id: ft.id })).length > 0;
3449
+ return (await e.delete(mt).where(t(a(mt.tenant_id, n), a(mt.id, r))).returning({ id: mt.id })).length > 0;
3256
3450
  }
3257
3451
  };
3258
3452
  }
3259
3453
  //#endregion
3260
3454
  //#region src/adapters/scim.ts
3261
- function sr(e) {
3455
+ function _r(e) {
3262
3456
  if (!e) return [];
3263
3457
  try {
3264
3458
  let t = JSON.parse(e);
3265
3459
  if (!Array.isArray(t)) return [];
3266
3460
  let n = [];
3267
3461
  for (let e of t) {
3268
- let t = Ee.safeParse(e);
3462
+ let t = De.safeParse(e);
3269
3463
  t.success && n.push(t.data);
3270
3464
  }
3271
3465
  return n;
@@ -3273,7 +3467,7 @@ function sr(e) {
3273
3467
  return [];
3274
3468
  }
3275
3469
  }
3276
- function cr(e) {
3470
+ function vr(e) {
3277
3471
  if (!e) return [];
3278
3472
  try {
3279
3473
  let t = JSON.parse(e);
@@ -3282,16 +3476,16 @@ function cr(e) {
3282
3476
  return [];
3283
3477
  }
3284
3478
  }
3285
- function lr(e) {
3479
+ function yr(e) {
3286
3480
  return {
3287
3481
  connection_id: e.connection_id,
3288
3482
  user_id_attribute: e.user_id_attribute,
3289
- mapping: sr(e.mapping),
3483
+ mapping: _r(e.mapping),
3290
3484
  created_at: e.created_at,
3291
3485
  updated_at: e.updated_at
3292
3486
  };
3293
3487
  }
3294
- function ur(e) {
3488
+ function br(e) {
3295
3489
  return {
3296
3490
  async create(t, n) {
3297
3491
  let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
@@ -3301,7 +3495,7 @@ function ur(e) {
3301
3495
  created_at: r,
3302
3496
  updated_at: r
3303
3497
  };
3304
- return await e.insert(ut).values({
3498
+ return await e.insert(ft).values({
3305
3499
  connection_id: i.connection_id,
3306
3500
  tenant_id: t,
3307
3501
  user_id_attribute: i.user_id_attribute,
@@ -3311,31 +3505,31 @@ function ur(e) {
3311
3505
  }), i;
3312
3506
  },
3313
3507
  async get(n, r) {
3314
- let i = await e.select().from(ut).where(t(a(ut.tenant_id, n), a(ut.connection_id, r))).limit(1);
3315
- return i[0] ? lr(i[0]) : null;
3508
+ let i = await e.select().from(ft).where(t(a(ft.tenant_id, n), a(ft.connection_id, r))).limit(1);
3509
+ return i[0] ? yr(i[0]) : null;
3316
3510
  },
3317
3511
  async update(n, r, i) {
3318
- if ((await e.select({ connection_id: ut.connection_id }).from(ut).where(t(a(ut.tenant_id, n), a(ut.connection_id, r))).limit(1)).length === 0) return !1;
3512
+ if ((await e.select({ connection_id: ft.connection_id }).from(ft).where(t(a(ft.tenant_id, n), a(ft.connection_id, r))).limit(1)).length === 0) return !1;
3319
3513
  let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
3320
- return i.user_id_attribute !== void 0 && (o.user_id_attribute = i.user_id_attribute), i.mapping !== void 0 && (o.mapping = JSON.stringify(i.mapping)), await e.update(ut).set(o).where(t(a(ut.tenant_id, n), a(ut.connection_id, r))), !0;
3514
+ return i.user_id_attribute !== void 0 && (o.user_id_attribute = i.user_id_attribute), i.mapping !== void 0 && (o.mapping = JSON.stringify(i.mapping)), await e.update(ft).set(o).where(t(a(ft.tenant_id, n), a(ft.connection_id, r))), !0;
3321
3515
  },
3322
3516
  async remove(n, r) {
3323
- return (await e.select({ connection_id: ut.connection_id }).from(ut).where(t(a(ut.tenant_id, n), a(ut.connection_id, r))).limit(1)).length === 0 ? !1 : (await e.delete(ut).where(t(a(ut.tenant_id, n), a(ut.connection_id, r))), !0);
3517
+ return (await e.select({ connection_id: ft.connection_id }).from(ft).where(t(a(ft.tenant_id, n), a(ft.connection_id, r))).limit(1)).length === 0 ? !1 : (await e.delete(ft).where(t(a(ft.tenant_id, n), a(ft.connection_id, r))), !0);
3324
3518
  }
3325
3519
  };
3326
3520
  }
3327
- function dr(e) {
3521
+ function xr(e) {
3328
3522
  return {
3329
3523
  token_id: e.token_id,
3330
3524
  connection_id: e.connection_id,
3331
3525
  token_hash: e.token_hash,
3332
- scopes: cr(e.scopes),
3526
+ scopes: vr(e.scopes),
3333
3527
  valid_until: e.valid_until ?? void 0,
3334
3528
  created_at: e.created_at,
3335
3529
  last_used_at: e.last_used_at ?? void 0
3336
3530
  };
3337
3531
  }
3338
- function fr(e) {
3532
+ function Sr(e) {
3339
3533
  return {
3340
3534
  async create(t, n) {
3341
3535
  let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
@@ -3358,14 +3552,14 @@ function fr(e) {
3358
3552
  },
3359
3553
  async get(n, r) {
3360
3554
  let i = await e.select().from(X).where(t(a(X.tenant_id, n), a(X.token_id, r))).limit(1);
3361
- return i[0] ? dr(i[0]) : null;
3555
+ return i[0] ? xr(i[0]) : null;
3362
3556
  },
3363
3557
  async getByHash(n, r) {
3364
3558
  let i = await e.select().from(X).where(t(a(X.tenant_id, n), a(X.token_hash, r))).limit(1);
3365
- return i[0] ? dr(i[0]) : null;
3559
+ return i[0] ? xr(i[0]) : null;
3366
3560
  },
3367
3561
  async listByConnection(n, r) {
3368
- return (await e.select().from(X).where(t(a(X.tenant_id, n), a(X.connection_id, r)))).map(dr);
3562
+ return (await e.select().from(X).where(t(a(X.tenant_id, n), a(X.connection_id, r)))).map(xr);
3369
3563
  },
3370
3564
  async markUsed(n, r, i) {
3371
3565
  return (await e.select({ token_id: X.token_id }).from(X).where(t(a(X.tenant_id, n), a(X.token_id, r))).limit(1)).length === 0 ? !1 : (await e.update(X).set({ last_used_at: i }).where(t(a(X.tenant_id, n), a(X.token_id, r))), !0);
@@ -3375,7 +3569,7 @@ function fr(e) {
3375
3569
  }
3376
3570
  };
3377
3571
  }
3378
- function pr(e) {
3572
+ function Cr(e) {
3379
3573
  return {
3380
3574
  connection_id: e.connection_id,
3381
3575
  external_id: e.external_id,
@@ -3383,7 +3577,7 @@ function pr(e) {
3383
3577
  created_at: e.created_at
3384
3578
  };
3385
3579
  }
3386
- function mr(e) {
3580
+ function wr(e) {
3387
3581
  return {
3388
3582
  async create(t, n) {
3389
3583
  let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
@@ -3392,7 +3586,7 @@ function mr(e) {
3392
3586
  user_id: n.user_id,
3393
3587
  created_at: r
3394
3588
  };
3395
- return await e.insert(dt).values({
3589
+ return await e.insert(pt).values({
3396
3590
  tenant_id: t,
3397
3591
  connection_id: i.connection_id,
3398
3592
  external_id: i.external_id,
@@ -3401,21 +3595,21 @@ function mr(e) {
3401
3595
  }), i;
3402
3596
  },
3403
3597
  async getByExternalId(n, r, i) {
3404
- let o = await e.select().from(dt).where(t(a(dt.tenant_id, n), a(dt.connection_id, r), a(dt.external_id, i))).limit(1);
3405
- return o[0] ? pr(o[0]) : null;
3598
+ let o = await e.select().from(pt).where(t(a(pt.tenant_id, n), a(pt.connection_id, r), a(pt.external_id, i))).limit(1);
3599
+ return o[0] ? Cr(o[0]) : null;
3406
3600
  },
3407
3601
  async getByUserId(n, r, i) {
3408
- let o = await e.select().from(dt).where(t(a(dt.tenant_id, n), a(dt.connection_id, r), a(dt.user_id, i))).limit(1);
3409
- return o[0] ? pr(o[0]) : null;
3602
+ let o = await e.select().from(pt).where(t(a(pt.tenant_id, n), a(pt.connection_id, r), a(pt.user_id, i))).limit(1);
3603
+ return o[0] ? Cr(o[0]) : null;
3410
3604
  },
3411
3605
  async remove(n, r, i) {
3412
- return (await e.select({ user_id: dt.user_id }).from(dt).where(t(a(dt.tenant_id, n), a(dt.connection_id, r), a(dt.user_id, i))).limit(1)).length === 0 ? !1 : (await e.delete(dt).where(t(a(dt.tenant_id, n), a(dt.connection_id, r), a(dt.user_id, i))), !0);
3606
+ return (await e.select({ user_id: pt.user_id }).from(pt).where(t(a(pt.tenant_id, n), a(pt.connection_id, r), a(pt.user_id, i))).limit(1)).length === 0 ? !1 : (await e.delete(pt).where(t(a(pt.tenant_id, n), a(pt.connection_id, r), a(pt.user_id, i))), !0);
3413
3607
  }
3414
3608
  };
3415
3609
  }
3416
3610
  //#endregion
3417
3611
  //#region src/adapters/refreshTokens.ts
3418
- function hr(e) {
3612
+ function Tr(e) {
3419
3613
  let { tenant_id: t, created_at_ts: n, expires_at_ts: r, idle_expires_at_ts: i, last_exchanged_at_ts: a, revoked_at_ts: o, rotated_at_ts: s, device: c, resource_servers: l, rotating: u, auth_strategy_strategy: d, auth_strategy_strategy_type: f, ...p } = e, m = ae({
3420
3614
  created_at_ts: n,
3421
3615
  expires_at_ts: r,
@@ -3442,10 +3636,10 @@ function hr(e) {
3442
3636
  } } : {}
3443
3637
  });
3444
3638
  }
3445
- function gr(e, t) {
3639
+ function Er(e, t) {
3446
3640
  return Math.max(e ?? 0, t ?? 0);
3447
3641
  }
3448
- function _r(e) {
3642
+ function Dr(e) {
3449
3643
  return {
3450
3644
  async create(n, r) {
3451
3645
  let i = Date.now(), o = {
@@ -3471,22 +3665,22 @@ function _r(e) {
3471
3665
  expires_at_ts: E(r.expires_at),
3472
3666
  idle_expires_at_ts: E(r.idle_expires_at),
3473
3667
  last_exchanged_at_ts: E(r.last_exchanged_at)
3474
- }, s = [e.insert(N).values(o)], c = gr(o.expires_at_ts, o.idle_expires_at_ts);
3668
+ }, s = [e.insert(N).values(o)], c = Er(o.expires_at_ts, o.idle_expires_at_ts);
3475
3669
  return c > 0 && o.login_id && s.push(e.update(P).set({
3476
3670
  expires_at_ts: c,
3477
3671
  updated_at_ts: i
3478
- }).where(t(a(P.tenant_id, n), a(P.id, o.login_id), m(P.expires_at_ts, c)))), await Tt(e, s), hr({
3672
+ }).where(t(a(P.tenant_id, n), a(P.id, o.login_id), m(P.expires_at_ts, c)))), await kt(e, s), Tr({
3479
3673
  ...o,
3480
3674
  tenant_id: n
3481
3675
  });
3482
3676
  },
3483
3677
  async get(n, r) {
3484
3678
  let i = await e.select().from(N).where(t(a(N.tenant_id, n), a(N.id, r))).get();
3485
- return i ? hr(i) : null;
3679
+ return i ? Tr(i) : null;
3486
3680
  },
3487
3681
  async getByLookup(n, r) {
3488
3682
  let i = await e.select().from(N).where(t(a(N.tenant_id, n), a(N.token_lookup, r))).get();
3489
- return i ? hr(i) : null;
3683
+ return i ? Tr(i) : null;
3490
3684
  },
3491
3685
  async update(n, r, i, o) {
3492
3686
  let s = {};
@@ -3498,17 +3692,17 @@ function _r(e) {
3498
3692
  }).where(t(a(P.tenant_id, n), a(P.id, c.login_id), m(P.expires_at_ts, l))).catch(() => {}), u.length > 0;
3499
3693
  },
3500
3694
  async list(o, s) {
3501
- let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? vt(N, f, ["user_id", "login_id"]) : void 0, m = [
3695
+ let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? St(N, f, ["user_id", "login_id"]) : void 0, m = [
3502
3696
  a(N.tenant_id, o),
3503
3697
  ...s?.user_id === void 0 ? [] : [a(N.user_id, s.user_id)],
3504
3698
  ...p ? [p] : []
3505
3699
  ], h = m.length === 1 ? m[0] : t(...m);
3506
- if (At(s)) {
3700
+ if (Pt(s)) {
3507
3701
  let n = {
3508
3702
  sortColumn: N.created_at_ts,
3509
3703
  idColumn: N.id,
3510
3704
  sortOrder: "desc"
3511
- }, r = Nt(s, n), i = jt(s), { rows: a, next: o } = Pt(await e.select().from(N).where(r ? t(h, r) : h).orderBy(...Mt(n)).limit(i + 1), i, "created_at_ts"), c = a.map(hr);
3705
+ }, r = Lt(s, n), i = Ft(s), { rows: a, next: o } = Rt(await e.select().from(N).where(r ? t(h, r) : h).orderBy(...It(n)).limit(i + 1), i, "created_at_ts"), c = a.map(Tr);
3512
3706
  return {
3513
3707
  refresh_tokens: c,
3514
3708
  start: 0,
@@ -3522,7 +3716,7 @@ function _r(e) {
3522
3716
  let e = N[d.sort_by];
3523
3717
  e && (g = g.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
3524
3718
  }
3525
- let _ = (await g.offset(c * l).limit(l)).map(hr);
3719
+ let _ = (await g.offset(c * l).limit(l)).map(Tr);
3526
3720
  if (!u) return { refresh_tokens: _ };
3527
3721
  let [v] = await e.select({ count: r() }).from(N).where(h);
3528
3722
  return {
@@ -3551,15 +3745,15 @@ function _r(e) {
3551
3745
  }
3552
3746
  //#endregion
3553
3747
  //#region src/adapters/resourceServers.ts
3554
- var vr = ["name", "identifier"];
3555
- function yr() {
3748
+ var Or = ["name", "identifier"];
3749
+ function kr() {
3556
3750
  return `api_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
3557
3751
  }
3558
- var br = [
3752
+ var Ar = [
3559
3753
  "skip_consent_for_verifiable_first_party_clients",
3560
3754
  "allow_offline_access",
3561
3755
  "is_system"
3562
- ], xr = new Set([
3756
+ ], jr = new Set([
3563
3757
  "id",
3564
3758
  "tenant_id",
3565
3759
  "identifier",
@@ -3578,17 +3772,17 @@ var br = [
3578
3772
  "created_at",
3579
3773
  "updated_at"
3580
3774
  ]);
3581
- function Sr(e) {
3775
+ function Mr(e) {
3582
3776
  let { tenant_id: t, verification_key: n, scopes: r, options: i, metadata: a, ...o } = e, s = { ...o };
3583
3777
  s.scopes = Z(r, []), s.options = Z(i, {}), s.metadata = Z(a), n !== void 0 && (s.verificationKey = n);
3584
- for (let e of br) o[e] !== void 0 && o[e] !== null && (s[e] = !!o[e]);
3778
+ for (let e of Ar) o[e] !== void 0 && o[e] !== null && (s[e] = !!o[e]);
3585
3779
  return D(s);
3586
3780
  }
3587
- function Cr(e) {
3781
+ function Nr(e) {
3588
3782
  return {
3589
3783
  async create(t, n) {
3590
3784
  let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
3591
- id: n.id || yr(),
3785
+ id: n.id || kr(),
3592
3786
  tenant_id: t,
3593
3787
  identifier: n.identifier,
3594
3788
  name: n.name,
@@ -3603,37 +3797,37 @@ function Cr(e) {
3603
3797
  created_at: r,
3604
3798
  updated_at: r
3605
3799
  };
3606
- for (let e of br) n[e] !== void 0 && (i[e] = +!!n[e]);
3607
- return i.is_system === void 0 && (i.is_system = 0), await e.insert(K).values(i), Sr({
3800
+ for (let e of Ar) n[e] !== void 0 && (i[e] = +!!n[e]);
3801
+ return i.is_system === void 0 && (i.is_system = 0), await e.insert(K).values(i), Mr({
3608
3802
  ...i,
3609
3803
  tenant_id: t
3610
3804
  });
3611
3805
  },
3612
3806
  async get(n, r) {
3613
3807
  let i = await e.select().from(K).where(t(a(K.tenant_id, n), a(K.id, r))).get();
3614
- return i ? Sr(i) : null;
3808
+ return i ? Mr(i) : null;
3615
3809
  },
3616
3810
  async update(n, r, i) {
3617
3811
  let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
3618
3812
  i.name !== void 0 && (o.name = i.name), i.identifier !== void 0 && (o.identifier = i.identifier), i.signing_alg !== void 0 && (o.signing_alg = i.signing_alg), i.signing_secret !== void 0 && (o.signing_secret = i.signing_secret), i.token_lifetime !== void 0 && (o.token_lifetime = i.token_lifetime), i.token_lifetime_for_web !== void 0 && (o.token_lifetime_for_web = i.token_lifetime_for_web), i.scopes !== void 0 && (o.scopes = JSON.stringify(i.scopes)), i.options !== void 0 && (o.options = y`json_patch(COALESCE(${K.options}, '{}'), ${JSON.stringify(i.options)})`), i.metadata !== void 0 && (o.metadata = JSON.stringify(i.metadata)), i.verificationKey !== void 0 && (o.verification_key = i.verificationKey);
3619
- for (let e of br) i[e] !== void 0 && (o[e] = +!!i[e]);
3813
+ for (let e of Ar) i[e] !== void 0 && (o[e] = +!!i[e]);
3620
3814
  return (await e.update(K).set(o).where(t(a(K.tenant_id, n), a(K.id, r))).returning()).length > 0;
3621
3815
  },
3622
3816
  async list(o, s) {
3623
3817
  let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = Math.max(0, Math.floor(Number(c) || 0)), m = Math.min(Math.max(1, Math.floor(Number(l) || 50)), 500), h = [a(K.tenant_id, o)];
3624
3818
  if (f) {
3625
- let e = Te(f, vr);
3819
+ let e = Ee(f, Or);
3626
3820
  if (e) {
3627
- let t = vt(K, e, vr, ["name", "identifier"]);
3821
+ let t = St(K, e, Or, ["name", "identifier"]);
3628
3822
  t && h.push(t);
3629
3823
  }
3630
3824
  }
3631
- if (At(s)) {
3825
+ if (Pt(s)) {
3632
3826
  let n = {
3633
3827
  sortColumn: K.created_at,
3634
3828
  idColumn: K.id,
3635
3829
  sortOrder: "desc"
3636
- }, r = Nt(s, n), i = jt(s), { rows: a, next: o } = Pt(await e.select().from(K).where(t(...h, r)).orderBy(...Mt(n)).limit(i + 1), i, "created_at", "id"), c = a.map(Sr);
3830
+ }, r = Lt(s, n), i = Ft(s), { rows: a, next: o } = Rt(await e.select().from(K).where(t(...h, r)).orderBy(...It(n)).limit(i + 1), i, "created_at", "id"), c = a.map(Mr);
3637
3831
  return {
3638
3832
  resource_servers: c,
3639
3833
  start: 0,
@@ -3643,11 +3837,11 @@ function Cr(e) {
3643
3837
  };
3644
3838
  }
3645
3839
  let g = e.select().from(K).where(t(...h)).$dynamic();
3646
- if (d?.sort_by && xr.has(d.sort_by)) {
3840
+ if (d?.sort_by && jr.has(d.sort_by)) {
3647
3841
  let e = K[d.sort_by];
3648
3842
  g = g.orderBy(d.sort_order === "desc" ? i(e) : n(e));
3649
3843
  }
3650
- let _ = (await g.offset(p * m).limit(m)).map(Sr);
3844
+ let _ = (await g.offset(p * m).limit(m)).map(Mr);
3651
3845
  if (!u) return { resource_servers: _ };
3652
3846
  let [v] = await e.select({ count: r() }).from(K).where(t(...h));
3653
3847
  return {
@@ -3664,7 +3858,7 @@ function Cr(e) {
3664
3858
  }
3665
3859
  //#endregion
3666
3860
  //#region src/adapters/rolePermissions.ts
3667
- function wr(e) {
3861
+ function Pr(e) {
3668
3862
  return {
3669
3863
  async assign(t, n, r) {
3670
3864
  if (r.length === 0) return !0;
@@ -3678,7 +3872,7 @@ function wr(e) {
3678
3872
  }))).onConflictDoNothing(), !0;
3679
3873
  },
3680
3874
  async list(n, r, i) {
3681
- return Tr(e, n, await e.select({
3875
+ return Fr(e, n, await e.select({
3682
3876
  resource_server_identifier: W.resource_server_identifier,
3683
3877
  permission_name: W.permission_name,
3684
3878
  created_at: W.created_at
@@ -3689,14 +3883,14 @@ function wr(e) {
3689
3883
  sortColumn: W.resource_server_identifier,
3690
3884
  idColumn: W.permission_name,
3691
3885
  sortOrder: "asc"
3692
- }, s = jt(i), { rows: c, next: l } = Pt(await e.select({
3886
+ }, s = Ft(i), { rows: c, next: l } = Rt(await e.select({
3693
3887
  role_id: W.role_id,
3694
3888
  resource_server_identifier: W.resource_server_identifier,
3695
3889
  permission_name: W.permission_name,
3696
3890
  created_at: W.created_at
3697
- }).from(W).where(t(a(W.tenant_id, n), a(W.role_id, r), Nt(i, o))).orderBy(...Mt(o)).limit(s + 1).all(), s, "resource_server_identifier", "permission_name");
3891
+ }).from(W).where(t(a(W.tenant_id, n), a(W.role_id, r), Lt(i, o))).orderBy(...It(o)).limit(s + 1).all(), s, "resource_server_identifier", "permission_name");
3698
3892
  return {
3699
- permissions: await Tr(e, n, c),
3893
+ permissions: await Fr(e, n, c),
3700
3894
  next: l
3701
3895
  };
3702
3896
  },
@@ -3707,7 +3901,7 @@ function wr(e) {
3707
3901
  }
3708
3902
  };
3709
3903
  }
3710
- async function Tr(e, n, r) {
3904
+ async function Fr(e, n, r) {
3711
3905
  let i = [...new Set(r.map((e) => e.resource_server_identifier))], o = /* @__PURE__ */ new Map();
3712
3906
  if (i.length > 0) {
3713
3907
  let r = await e.select({
@@ -3723,11 +3917,11 @@ async function Tr(e, n, r) {
3723
3917
  }
3724
3918
  //#endregion
3725
3919
  //#region src/adapters/userPermissions.ts
3726
- function Er(e) {
3920
+ function Ir(e) {
3727
3921
  return {
3728
3922
  async create(t, n, r, i) {
3729
3923
  try {
3730
- await e.insert(Ye).values({
3924
+ await e.insert(Ze).values({
3731
3925
  tenant_id: t,
3732
3926
  user_id: n,
3733
3927
  resource_server_identifier: r.resource_server_identifier,
@@ -3742,9 +3936,9 @@ function Er(e) {
3742
3936
  return !0;
3743
3937
  },
3744
3938
  async list(n, r, i, o) {
3745
- let s = [a(Ye.tenant_id, n), a(Ye.user_id, r)];
3746
- o && s.push(a(Ye.organization_id, o));
3747
- let c = await e.select().from(Ye).where(t(...s)).all();
3939
+ let s = [a(Ze.tenant_id, n), a(Ze.user_id, r)];
3940
+ o && s.push(a(Ze.organization_id, o));
3941
+ let c = await e.select().from(Ze).where(t(...s)).all();
3748
3942
  return await Promise.all(c.map(async (r) => {
3749
3943
  let i = await e.select({ name: K.name }).from(K).where(t(a(K.tenant_id, n), a(K.identifier, r.resource_server_identifier))).get();
3750
3944
  return {
@@ -3756,13 +3950,13 @@ function Er(e) {
3756
3950
  }));
3757
3951
  },
3758
3952
  async remove(n, r, i, o) {
3759
- return (await e.delete(Ye).where(t(a(Ye.tenant_id, n), a(Ye.user_id, r), a(Ye.resource_server_identifier, i.resource_server_identifier), a(Ye.permission_name, i.permission_name), a(Ye.organization_id, o || ""))).returning()).length > 0;
3953
+ return (await e.delete(Ze).where(t(a(Ze.tenant_id, n), a(Ze.user_id, r), a(Ze.resource_server_identifier, i.resource_server_identifier), a(Ze.permission_name, i.permission_name), a(Ze.organization_id, o || ""))).returning()).length > 0;
3760
3954
  }
3761
3955
  };
3762
3956
  }
3763
3957
  //#endregion
3764
3958
  //#region src/adapters/roles.ts
3765
- function Dr(e) {
3959
+ function Lr(e) {
3766
3960
  let { tenant_id: t, is_system: n, metadata: r, ...i } = e;
3767
3961
  return D({
3768
3962
  ...i,
@@ -3770,7 +3964,7 @@ function Dr(e) {
3770
3964
  metadata: Z(r)
3771
3965
  });
3772
3966
  }
3773
- function Or(e) {
3967
+ function Rr(e) {
3774
3968
  return {
3775
3969
  async create(t, n) {
3776
3970
  let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
@@ -3783,29 +3977,29 @@ function Or(e) {
3783
3977
  created_at: r,
3784
3978
  updated_at: r
3785
3979
  };
3786
- return await e.insert(U).values(i), Dr({
3980
+ return await e.insert(U).values(i), Lr({
3787
3981
  ...i,
3788
3982
  tenant_id: t
3789
3983
  });
3790
3984
  },
3791
3985
  async get(n, r) {
3792
3986
  let i = await e.select().from(U).where(t(a(U.tenant_id, n), a(U.id, r))).get();
3793
- return i ? Dr(i) : null;
3987
+ return i ? Lr(i) : null;
3794
3988
  },
3795
3989
  async update(n, r, i) {
3796
3990
  let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
3797
3991
  return i.name !== void 0 && (o.name = i.name), i.description !== void 0 && (o.description = i.description), i.is_system !== void 0 && (o.is_system = +!!i.is_system), i.metadata !== void 0 && (o.metadata = JSON.stringify(i.metadata)), (await e.update(U).set(o).where(t(a(U.tenant_id, n), a(U.id, r))).returning()).length > 0;
3798
3992
  },
3799
3993
  async list(o, s) {
3800
- let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? vt(U, f, ["name"]) : void 0, m = p ? t(a(U.tenant_id, o), p) : a(U.tenant_id, o);
3801
- if (At(s)) {
3994
+ let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? St(U, f, ["name"]) : void 0, m = p ? t(a(U.tenant_id, o), p) : a(U.tenant_id, o);
3995
+ if (Pt(s)) {
3802
3996
  let n = {
3803
3997
  sortColumn: U.created_at,
3804
3998
  idColumn: U.id,
3805
3999
  sortOrder: "desc"
3806
- }, r = jt(s), { rows: i, next: a } = Pt(await e.select().from(U).where(t(m, Nt(s, n))).orderBy(...Mt(n)).limit(r + 1), r, "created_at");
4000
+ }, r = Ft(s), { rows: i, next: a } = Rt(await e.select().from(U).where(t(m, Lt(s, n))).orderBy(...It(n)).limit(r + 1), r, "created_at");
3807
4001
  return {
3808
- roles: i.map(Dr),
4002
+ roles: i.map(Lr),
3809
4003
  start: 0,
3810
4004
  limit: r,
3811
4005
  length: i.length,
@@ -3817,7 +4011,7 @@ function Or(e) {
3817
4011
  let e = U[d.sort_by];
3818
4012
  e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
3819
4013
  }
3820
- let g = (await h.offset(c * l).limit(l)).map(Dr);
4014
+ let g = (await h.offset(c * l).limit(l)).map(Lr);
3821
4015
  if (!u) return { roles: g };
3822
4016
  let [_] = await e.select({ count: r() }).from(U).where(m);
3823
4017
  return {
@@ -3834,7 +4028,7 @@ function Or(e) {
3834
4028
  }
3835
4029
  //#endregion
3836
4030
  //#region src/adapters/sessions.ts
3837
- var kr = ["created_at_ts", "updated_at_ts"], Ar = [
4031
+ var zr = ["created_at_ts", "updated_at_ts"], Br = [
3838
4032
  "expires_at_ts",
3839
4033
  "idle_expires_at_ts",
3840
4034
  "authenticated_at_ts",
@@ -3842,7 +4036,7 @@ var kr = ["created_at_ts", "updated_at_ts"], Ar = [
3842
4036
  "used_at_ts",
3843
4037
  "revoked_at_ts"
3844
4038
  ];
3845
- function jr(e) {
4039
+ function Vr(e) {
3846
4040
  let { tenant_id: t, created_at_ts: n, updated_at_ts: r, expires_at_ts: i, idle_expires_at_ts: a, authenticated_at_ts: o, last_interaction_at_ts: s, used_at_ts: c, revoked_at_ts: l, device: u, clients: d, ...f } = e, p = ae({
3847
4041
  created_at_ts: n,
3848
4042
  updated_at_ts: r,
@@ -3852,7 +4046,7 @@ function jr(e) {
3852
4046
  last_interaction_at_ts: s,
3853
4047
  used_at_ts: c,
3854
4048
  revoked_at_ts: l
3855
- }, [...kr], [...Ar]);
4049
+ }, [...zr], [...Br]);
3856
4050
  return D({
3857
4051
  ...f,
3858
4052
  ...p,
@@ -3860,10 +4054,10 @@ function jr(e) {
3860
4054
  clients: Z(d, [])
3861
4055
  });
3862
4056
  }
3863
- function Mr(e, t) {
4057
+ function Hr(e, t) {
3864
4058
  return Math.max(e ?? 0, t ?? 0);
3865
4059
  }
3866
- function Nr(e) {
4060
+ function Ur(e) {
3867
4061
  return {
3868
4062
  async create(n, r) {
3869
4063
  let i = Date.now(), o = {
@@ -3881,23 +4075,23 @@ function Nr(e) {
3881
4075
  last_interaction_at_ts: r.last_interaction_at ? E(r.last_interaction_at) : i,
3882
4076
  used_at_ts: E(r.used_at),
3883
4077
  revoked_at_ts: E(r.revoked_at)
3884
- }, s = [e.insert(M).values(o)], c = Mr(o.expires_at_ts, o.idle_expires_at_ts);
4078
+ }, s = [e.insert(M).values(o)], c = Hr(o.expires_at_ts, o.idle_expires_at_ts);
3885
4079
  return c > 0 && o.login_session_id && s.push(e.update(P).set({
3886
4080
  expires_at_ts: c,
3887
4081
  updated_at_ts: i
3888
- }).where(t(a(P.tenant_id, n), a(P.id, o.login_session_id), m(P.expires_at_ts, c)))), await Tt(e, s), jr({
4082
+ }).where(t(a(P.tenant_id, n), a(P.id, o.login_session_id), m(P.expires_at_ts, c)))), await kt(e, s), Vr({
3889
4083
  ...o,
3890
4084
  tenant_id: n
3891
4085
  });
3892
4086
  },
3893
4087
  async get(n, r) {
3894
4088
  let i = await e.select().from(M).where(t(a(M.tenant_id, n), a(M.id, r))).get();
3895
- return i ? jr(i) : null;
4089
+ return i ? Vr(i) : null;
3896
4090
  },
3897
4091
  async update(n, r, i) {
3898
4092
  let o = { updated_at_ts: Date.now() };
3899
4093
  i.user_id !== void 0 && (o.user_id = i.user_id), i.login_session_id !== void 0 && (o.login_session_id = i.login_session_id), i.device !== void 0 && (o.device = JSON.stringify(i.device)), i.clients !== void 0 && (o.clients = JSON.stringify(i.clients)), i.expires_at !== void 0 && (o.expires_at_ts = E(i.expires_at)), i.idle_expires_at !== void 0 && (o.idle_expires_at_ts = E(i.idle_expires_at)), i.authenticated_at !== void 0 && (o.authenticated_at_ts = E(i.authenticated_at)), i.last_interaction_at !== void 0 && (o.last_interaction_at_ts = E(i.last_interaction_at)), i.used_at !== void 0 && (o.used_at_ts = E(i.used_at)), i.revoked_at !== void 0 && (o.revoked_at_ts = E(i.revoked_at));
3900
- let s = await e.update(M).set(o).where(t(a(M.tenant_id, n), a(M.id, r))).returning(), c = Mr(o.expires_at_ts, o.idle_expires_at_ts), l = s[0];
4094
+ let s = await e.update(M).set(o).where(t(a(M.tenant_id, n), a(M.id, r))).returning(), c = Hr(o.expires_at_ts, o.idle_expires_at_ts), l = s[0];
3901
4095
  if (c > 0 && l) {
3902
4096
  let r = i.login_session_id ?? l.login_session_id;
3903
4097
  r && await e.update(P).set({
@@ -3908,12 +4102,12 @@ function Nr(e) {
3908
4102
  return s.length > 0;
3909
4103
  },
3910
4104
  async list(o, s) {
3911
- let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? vt(M, f, ["user_id", "id"]) : void 0, m = p ? t(a(M.tenant_id, o), p) : a(M.tenant_id, o), h = e.select().from(M).where(m).$dynamic();
4105
+ let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? St(M, f, ["user_id", "id"]) : void 0, m = p ? t(a(M.tenant_id, o), p) : a(M.tenant_id, o), h = e.select().from(M).where(m).$dynamic();
3912
4106
  if (d?.sort_by) {
3913
4107
  let e = M[d.sort_by];
3914
4108
  e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
3915
4109
  }
3916
- let g = (await h.offset(c * l).limit(l)).map(jr);
4110
+ let g = (await h.offset(c * l).limit(l)).map(Vr);
3917
4111
  if (!u) return { sessions: g };
3918
4112
  let [_] = await e.select({ count: r() }).from(M).where(m);
3919
4113
  return {
@@ -3930,7 +4124,7 @@ function Nr(e) {
3930
4124
  }
3931
4125
  //#endregion
3932
4126
  //#region src/adapters/tenants.ts
3933
- var Pr = [
4127
+ var Wr = [
3934
4128
  "session_cookie",
3935
4129
  "enabled_locales",
3936
4130
  "error_page",
@@ -3946,25 +4140,25 @@ var Pr = [
3946
4140
  "acr_values_supported",
3947
4141
  "mtls",
3948
4142
  "mfa"
3949
- ], Fr = [
4143
+ ], Gr = [
3950
4144
  "allow_organization_name_in_authentication_api",
3951
4145
  "customize_mfa_in_postlogin_action",
3952
4146
  "pushed_authorization_requests_supported",
3953
4147
  "authorization_response_iss_parameter_supported"
3954
4148
  ];
3955
- function Ir(e) {
4149
+ function Kr(e) {
3956
4150
  let t = { ...e };
3957
- for (let e of Pr) typeof t[e] == "string" && (t[e] = Z(t[e]));
3958
- for (let e of Fr) t[e] !== void 0 && t[e] !== null && (t[e] = t[e] === 1);
4151
+ for (let e of Wr) typeof t[e] == "string" && (t[e] = Z(t[e]));
4152
+ for (let e of Gr) t[e] !== void 0 && t[e] !== null && (t[e] = t[e] === 1);
3959
4153
  return D(t);
3960
4154
  }
3961
- function Lr(e) {
4155
+ function qr(e) {
3962
4156
  let t = { ...e };
3963
- le(e, Pr, t);
3964
- for (let n of Fr) e[n] !== void 0 && (t[n] = +!!e[n]);
4157
+ le(e, Wr, t);
4158
+ for (let n of Gr) e[n] !== void 0 && (t[n] = +!!e[n]);
3965
4159
  return ce(t);
3966
4160
  }
3967
- function Rr(e) {
4161
+ function Jr(e) {
3968
4162
  return {
3969
4163
  async create(t) {
3970
4164
  let n = {
@@ -3972,26 +4166,26 @@ function Rr(e) {
3972
4166
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
3973
4167
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
3974
4168
  ...t
3975
- }, r = Lr(n);
4169
+ }, r = qr(n);
3976
4170
  try {
3977
4171
  await e.insert(O).values(r);
3978
4172
  } catch (e) {
3979
4173
  let t = e?.message ?? "";
3980
- throw t.includes("UNIQUE constraint failed") || t.includes("Duplicate entry") || t.includes("duplicate key") || t.includes("AlreadyExists") || e?.code === "SQLITE_CONSTRAINT" || e?.code === "SQLITE_CONSTRAINT_UNIQUE" || e?.code === "SQLITE_CONSTRAINT_PRIMARYKEY" || e?.code === "ER_DUP_ENTRY" || e?.code === "23505" ? new Le(409, { message: `Tenant with ID '${n.id}' already exists` }) : e;
4174
+ throw t.includes("UNIQUE constraint failed") || t.includes("Duplicate entry") || t.includes("duplicate key") || t.includes("AlreadyExists") || e?.code === "SQLITE_CONSTRAINT" || e?.code === "SQLITE_CONSTRAINT_UNIQUE" || e?.code === "SQLITE_CONSTRAINT_PRIMARYKEY" || e?.code === "ER_DUP_ENTRY" || e?.code === "23505" ? new Re(409, { message: `Tenant with ID '${n.id}' already exists` }) : e;
3981
4175
  }
3982
4176
  return n;
3983
4177
  },
3984
4178
  async get(t) {
3985
4179
  let n = await e.select().from(O).where(a(O.id, t)).get();
3986
- return n ? Ir(n) : null;
4180
+ return n ? Kr(n) : null;
3987
4181
  },
3988
4182
  async list(t) {
3989
- let { page: a = 0, per_page: o = 50, include_totals: s = !1, sort: c, q: l } = t || {}, u = l ? vt(O, l, ["friendly_name"]) : void 0, d = e.select().from(O).$dynamic();
4183
+ let { page: a = 0, per_page: o = 50, include_totals: s = !1, sort: c, q: l } = t || {}, u = l ? St(O, l, ["friendly_name"]) : void 0, d = e.select().from(O).$dynamic();
3990
4184
  if (u && (d = d.where(u)), c?.sort_by) {
3991
4185
  let e = O[c.sort_by];
3992
4186
  e && (d = d.orderBy(c.sort_order === "desc" ? i(e) : n(e)));
3993
4187
  }
3994
- let f = (await d.offset(a * o).limit(o)).map(Ir);
4188
+ let f = (await d.offset(a * o).limit(o)).map(Kr);
3995
4189
  if (!s) return { tenants: f };
3996
4190
  let p = e.select({ count: r() }).from(O).$dynamic();
3997
4191
  u && (p = p.where(u));
@@ -4004,7 +4198,7 @@ function Rr(e) {
4004
4198
  };
4005
4199
  },
4006
4200
  async update(t, n) {
4007
- let r = Lr({
4201
+ let r = qr({
4008
4202
  ...n,
4009
4203
  id: t,
4010
4204
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
@@ -4018,62 +4212,62 @@ function Rr(e) {
4018
4212
  }
4019
4213
  //#endregion
4020
4214
  //#region src/adapters/themes.ts
4021
- var zr = [
4215
+ var Yr = [
4022
4216
  "colors",
4023
4217
  "borders",
4024
4218
  "fonts",
4025
4219
  "page_background",
4026
4220
  "widget"
4027
4221
  ];
4028
- function Br(e) {
4029
- let { tenant_id: t, ...n } = e, r = ht(n, zr);
4222
+ function Xr(e) {
4223
+ let { tenant_id: t, ...n } = e, r = yt(n, Yr);
4030
4224
  return r.borders && (r.borders.show_widget_shadow = !!r.borders.show_widget_shadow), r.fonts && (r.fonts.body_text_bold = !!r.fonts.body_text_bold, r.fonts.buttons_text_bold = !!r.fonts.buttons_text_bold, r.fonts.input_labels_bold = !!r.fonts.input_labels_bold, r.fonts.links_bold = !!r.fonts.links_bold, r.fonts.subtitle_bold = !!r.fonts.subtitle_bold, r.fonts.title_bold = !!r.fonts.title_bold), D(r);
4031
4225
  }
4032
- function Vr(e) {
4226
+ function Zr(e) {
4033
4227
  return {
4034
4228
  async create(t, n, r, i) {
4035
4229
  let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = a?.id || r || b(), c = {
4036
- ...mt(n),
4230
+ ...vt(n),
4037
4231
  tenant_id: t,
4038
4232
  themeId: s,
4039
4233
  created_at: a?.created_at ?? o,
4040
4234
  updated_at: a?.updated_at ?? o
4041
4235
  };
4042
- return await e.insert(Qe).values(c), Br({
4236
+ return await e.insert(et).values(c), Xr({
4043
4237
  ...c,
4044
4238
  tenant_id: t
4045
4239
  });
4046
4240
  },
4047
4241
  async get(n, r) {
4048
- let i = await e.select().from(Qe).where(t(a(Qe.tenant_id, n), a(Qe.themeId, r))).get();
4049
- return i ? Br(i) : null;
4242
+ let i = await e.select().from(et).where(t(a(et.tenant_id, n), a(et.themeId, r))).get();
4243
+ return i ? Xr(i) : null;
4050
4244
  },
4051
4245
  async update(n, r, i) {
4052
- let o = mt(i);
4053
- return o.updated_at = (/* @__PURE__ */ new Date()).toISOString(), await e.update(Qe).set(o).where(t(a(Qe.tenant_id, n), a(Qe.themeId, r))), !0;
4246
+ let o = vt(i);
4247
+ return o.updated_at = (/* @__PURE__ */ new Date()).toISOString(), await e.update(et).set(o).where(t(a(et.tenant_id, n), a(et.themeId, r))), !0;
4054
4248
  },
4055
4249
  async remove(n, r) {
4056
- return (await e.delete(Qe).where(t(a(Qe.tenant_id, n), a(Qe.themeId, r))).returning()).length > 0;
4250
+ return (await e.delete(et).where(t(a(et.tenant_id, n), a(et.themeId, r))).returning()).length > 0;
4057
4251
  }
4058
4252
  };
4059
4253
  }
4060
4254
  //#endregion
4061
4255
  //#region src/adapters/universalLoginTemplates.ts
4062
- function Hr(e) {
4256
+ function Qr(e) {
4063
4257
  return {
4064
4258
  async get(t) {
4065
- let n = await e.select({ body: Ze.body }).from(Ze).where(a(Ze.tenant_id, t)).get();
4259
+ let n = await e.select({ body: $e.body }).from($e).where(a($e.tenant_id, t)).get();
4066
4260
  return n ? { body: n.body } : null;
4067
4261
  },
4068
4262
  async set(t, n) {
4069
4263
  let r = Date.now();
4070
- await e.insert(Ze).values({
4264
+ await e.insert($e).values({
4071
4265
  tenant_id: t,
4072
4266
  body: n.body,
4073
4267
  created_at_ts: r,
4074
4268
  updated_at_ts: r
4075
4269
  }).onConflictDoUpdate({
4076
- target: Ze.tenant_id,
4270
+ target: $e.tenant_id,
4077
4271
  set: {
4078
4272
  body: n.body,
4079
4273
  updated_at_ts: r
@@ -4081,20 +4275,20 @@ function Hr(e) {
4081
4275
  });
4082
4276
  },
4083
4277
  async delete(t) {
4084
- await e.delete(Ze).where(a(Ze.tenant_id, t));
4278
+ await e.delete($e).where(a($e.tenant_id, t));
4085
4279
  }
4086
4280
  };
4087
4281
  }
4088
4282
  //#endregion
4089
4283
  //#region src/adapters/userActivity.ts
4090
- function Ur(e) {
4284
+ function $r(e) {
4091
4285
  let t = {};
4092
4286
  return e.last_login !== void 0 && (t.last_login = e.last_login), e.last_ip !== void 0 && (t.last_ip = e.last_ip), e.login_count !== void 0 && (t.login_count = e.login_count), e.failed_logins !== void 0 && (t.failed_logins = JSON.stringify(e.failed_logins)), e.last_password_reset !== void 0 && (t.last_password_reset = e.last_password_reset), t;
4093
4287
  }
4094
- function Wr(e) {
4288
+ function ei(e) {
4095
4289
  return {
4096
4290
  async get(n, r) {
4097
- let i = await e.select().from(He).where(t(a(He.tenant_id, n), a(He.user_id, r))).get();
4291
+ let i = await e.select().from(Ue).where(t(a(Ue.tenant_id, n), a(Ue.user_id, r))).get();
4098
4292
  return i ? {
4099
4293
  user_id: i.user_id,
4100
4294
  last_login: i.last_login ?? void 0,
@@ -4105,7 +4299,7 @@ function Wr(e) {
4105
4299
  } : null;
4106
4300
  },
4107
4301
  async upsert(t, n, r) {
4108
- let i = Ur(r), a = e.insert(He).values({
4302
+ let i = $r(r), a = e.insert(Ue).values({
4109
4303
  tenant_id: t,
4110
4304
  user_id: n,
4111
4305
  login_count: 0,
@@ -4116,7 +4310,7 @@ function Wr(e) {
4116
4310
  return;
4117
4311
  }
4118
4312
  await a.onConflictDoUpdate({
4119
- target: [He.tenant_id, He.user_id],
4313
+ target: [Ue.tenant_id, Ue.user_id],
4120
4314
  set: i
4121
4315
  });
4122
4316
  }
@@ -4124,13 +4318,13 @@ function Wr(e) {
4124
4318
  }
4125
4319
  //#endregion
4126
4320
  //#region src/adapters/outbox.ts
4127
- function Gr(e) {
4321
+ function ti(e) {
4128
4322
  return {
4129
4323
  ...e,
4130
4324
  payload: Z(e.payload, {})
4131
4325
  };
4132
4326
  }
4133
- function Kr(e, t, n, r) {
4327
+ function ni(e, t, n, r) {
4134
4328
  return e.insert(J).values({
4135
4329
  id: t,
4136
4330
  tenant_id: n,
@@ -4151,18 +4345,18 @@ function Kr(e, t, n, r) {
4151
4345
  claim_expires_at: null
4152
4346
  });
4153
4347
  }
4154
- function qr(e) {
4348
+ function ri(e) {
4155
4349
  return {
4156
4350
  async create(t, n) {
4157
4351
  let r = b();
4158
- return await Kr(e, r, t, n), r;
4352
+ return await ni(e, r, t, n), r;
4159
4353
  },
4160
4354
  async getByIds(t) {
4161
- return t.length === 0 ? [] : (await e.select().from(J).where(l(J.id, t)).all()).map(Gr);
4355
+ return t.length === 0 ? [] : (await e.select().from(J).where(l(J.id, t)).all()).map(ti);
4162
4356
  },
4163
4357
  async getUnprocessed(n) {
4164
4358
  let r = (/* @__PURE__ */ new Date()).toISOString();
4165
- return (await e.select().from(J).where(t(f(J.processed_at), v(f(J.next_retry_at), h(J.next_retry_at, r)), v(f(J.claimed_by), h(J.claim_expires_at, r)))).orderBy(J.created_at, J.id).limit(n).all()).map(Gr);
4359
+ return (await e.select().from(J).where(t(f(J.processed_at), v(f(J.next_retry_at), h(J.next_retry_at, r)), v(f(J.claimed_by), h(J.claim_expires_at, r)))).orderBy(J.created_at, J.id).limit(n).all()).map(ti);
4166
4360
  },
4167
4361
  async claimEvents(n, r, i) {
4168
4362
  if (n.length === 0) return [];
@@ -4237,10 +4431,10 @@ function qr(e) {
4237
4431
  }
4238
4432
  //#endregion
4239
4433
  //#region src/adapters/users.ts
4240
- function Jr(e, t, n) {
4241
- return (n?.outboxEvents ?? []).map((n) => Kr(e, n.id, t, n));
4434
+ function ii(e, t, n) {
4435
+ return (n?.outboxEvents ?? []).map((n) => ni(e, n.id, t, n));
4242
4436
  }
4243
- var Yr = [
4437
+ var ai = [
4244
4438
  "user_id",
4245
4439
  "email",
4246
4440
  "email_verified",
@@ -4262,23 +4456,23 @@ var Yr = [
4262
4456
  "login_count",
4263
4457
  "created_at",
4264
4458
  "updated_at"
4265
- ], Xr = [
4459
+ ], oi = [
4266
4460
  "email",
4267
4461
  "name",
4268
4462
  "phone_number",
4269
4463
  "user_id"
4270
- ], Zr = new Set([
4464
+ ], si = new Set([
4271
4465
  "last_login",
4272
4466
  "last_ip",
4273
4467
  "login_count"
4274
- ]), Qr = o(A), $r = o(He), ei = Object.fromEntries(Yr.map((e) => [e, e === "login_count" ? {
4275
- coalesce: He.login_count,
4468
+ ]), ci = o(A), li = o(Ue), ui = Object.fromEntries(ai.map((e) => [e, e === "login_count" ? {
4469
+ coalesce: Ue.login_count,
4276
4470
  defaultValue: 0
4277
- } : Zr.has(e) ? $r[e] : Qr[e]]));
4278
- function ti() {
4279
- return t(a(He.tenant_id, A.tenant_id), a(He.user_id, A.user_id));
4471
+ } : si.has(e) ? li[e] : ci[e]]));
4472
+ function di() {
4473
+ return t(a(Ue.tenant_id, A.tenant_id), a(Ue.user_id, A.user_id));
4280
4474
  }
4281
- function ni(e, t) {
4475
+ function fi(e, t) {
4282
4476
  return {
4283
4477
  ...e,
4284
4478
  last_login: t?.last_login,
@@ -4286,11 +4480,11 @@ function ni(e, t) {
4286
4480
  login_count: t?.login_count ?? 0
4287
4481
  };
4288
4482
  }
4289
- function ri(e, t) {
4483
+ function pi(e, t) {
4290
4484
  let n = {
4291
4485
  connection: e.connection,
4292
4486
  provider: e.provider,
4293
- user_id: Se(e.user_id).id,
4487
+ user_id: Ce(e.user_id).id,
4294
4488
  isSocial: !!e.is_social
4295
4489
  };
4296
4490
  return t ? n.isPrimary = !0 : n.profileData = {
@@ -4299,8 +4493,8 @@ function ri(e, t) {
4299
4493
  ...typeof e.profileData == "string" ? Z(e.profileData, {}) : {}
4300
4494
  }, n;
4301
4495
  }
4302
- function ii(e, t = []) {
4303
- let { tenant_id: n, app_metadata: r, user_metadata: i, address: a, email_verified: o, phone_verified: s, is_social: c, blocked: l, linked_to: u, profileData: d, ...f } = e, p = ri(e, !0), m = t.map((e) => ri(e, !1));
4496
+ function mi(e, t = []) {
4497
+ let { tenant_id: n, app_metadata: r, user_metadata: i, address: a, email_verified: o, phone_verified: s, is_social: c, blocked: l, linked_to: u, profileData: d, ...f } = e, p = pi(e, !0), m = t.map((e) => pi(e, !1));
4304
4498
  return D({
4305
4499
  ...f,
4306
4500
  email: e.email || "",
@@ -4314,7 +4508,7 @@ function ii(e, t = []) {
4314
4508
  identities: [p, ...m]
4315
4509
  });
4316
4510
  }
4317
- function ai(e) {
4511
+ function hi(e) {
4318
4512
  let o = async (t, n, r) => {
4319
4513
  let i = (/* @__PURE__ */ new Date()).toISOString(), a = {
4320
4514
  user_id: n.user_id,
@@ -4352,7 +4546,7 @@ function ai(e) {
4352
4546
  }, o = n.password ? b() : void 0, s = n.last_login !== void 0 || n.last_ip !== void 0 || n.login_count !== void 0;
4353
4547
  try {
4354
4548
  let c = [e.insert(A).values(a)];
4355
- s && c.push(e.insert(He).values({
4549
+ s && c.push(e.insert(Ue).values({
4356
4550
  tenant_id: t,
4357
4551
  user_id: n.user_id,
4358
4552
  last_login: n.last_login,
@@ -4368,12 +4562,12 @@ function ai(e) {
4368
4562
  created_at: i,
4369
4563
  updated_at: i
4370
4564
  }));
4371
- for (let n of Jr(e, t, r)) c.push(n);
4372
- c.length > 1 ? await Tt(e, c) : await e.insert(A).values(a);
4565
+ for (let n of ii(e, t, r)) c.push(n);
4566
+ c.length > 1 ? await kt(e, c) : await e.insert(A).values(a);
4373
4567
  } catch (e) {
4374
- throw e?.message?.includes("UNIQUE constraint") || e?.message?.includes("AlreadyExists") ? new Le(409, { message: "User already exists" }) : (console.error("User upsert failed:", e?.code, e?.message), new Le(500, { message: "Internal server error" }));
4568
+ throw e?.message?.includes("UNIQUE constraint") || e?.message?.includes("AlreadyExists") ? new Re(409, { message: "User already exists" }) : (console.error("User upsert failed:", e?.code, e?.message), new Re(500, { message: "Internal server error" }));
4375
4569
  }
4376
- return ii({
4570
+ return mi({
4377
4571
  ...a,
4378
4572
  last_login: n.last_login,
4379
4573
  last_ip: n.last_ip,
@@ -4384,10 +4578,10 @@ function ai(e) {
4384
4578
  create: o,
4385
4579
  rawCreate: o,
4386
4580
  async get(n, r) {
4387
- let i = await e.select().from(A).leftJoin(He, ti()).where(t(a(A.tenant_id, n), a(A.user_id, r))).get();
4581
+ let i = await e.select().from(A).leftJoin(Ue, di()).where(t(a(A.tenant_id, n), a(A.user_id, r))).get();
4388
4582
  if (!i) return null;
4389
4583
  let o = await e.select().from(A).where(t(a(A.tenant_id, n), a(A.linked_to, r))).all();
4390
- return ii(ni(i.users, i.user_activity), o);
4584
+ return mi(fi(i.users, i.user_activity), o);
4391
4585
  },
4392
4586
  async update(n, r, i, o) {
4393
4587
  let s = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
@@ -4414,8 +4608,8 @@ function ai(e) {
4414
4608
  "zoneinfo"
4415
4609
  ]) i[e] !== void 0 && (s[e] = i[e]);
4416
4610
  i.email_verified !== void 0 && (s.email_verified = i.email_verified), i.phone_verified !== void 0 && (s.phone_verified = i.phone_verified), i.is_social !== void 0 && (s.is_social = i.is_social), i.blocked !== void 0 && (s.blocked = i.blocked), i.app_metadata !== void 0 && (s.app_metadata = JSON.stringify(i.app_metadata)), i.user_metadata !== void 0 && (s.user_metadata = JSON.stringify(i.user_metadata)), i.address !== void 0 && (s.address = JSON.stringify(i.address)), i.profileData !== void 0 && (s.profileData = JSON.stringify(i.profileData));
4417
- let c = e.update(A).set(s).where(t(a(A.tenant_id, n), a(A.user_id, r))).returning(), l = Jr(e, n, o), u;
4418
- return u = l.length > 0 ? (await Tt(e, [c, ...l]))[0] : await c, !Array.isArray(u) || u.length === 0 ? !1 : ((i.last_login !== void 0 || i.last_ip !== void 0 || i.login_count !== void 0) && await Wr(e).upsert(n, r, {
4611
+ let c = e.update(A).set(s).where(t(a(A.tenant_id, n), a(A.user_id, r))).returning(), l = ii(e, n, o), u;
4612
+ return u = l.length > 0 ? (await kt(e, [c, ...l]))[0] : await c, !Array.isArray(u) || u.length === 0 ? !1 : ((i.last_login !== void 0 || i.last_ip !== void 0 || i.login_count !== void 0) && await ei(e).upsert(n, r, {
4419
4613
  last_login: i.last_login,
4420
4614
  last_ip: i.last_ip,
4421
4615
  login_count: i.login_count
@@ -4424,24 +4618,24 @@ function ai(e) {
4424
4618
  async list(o, s) {
4425
4619
  let { page: c = 0, per_page: u = 50, include_totals: d = !1, sort: p, q: m } = s || {}, h = [a(A.tenant_id, o), f(A.linked_to)];
4426
4620
  if (m) {
4427
- let e = Te(m, Yr);
4621
+ let e = Ee(m, ai);
4428
4622
  if (e) {
4429
- let t = vt(ei, e, Xr);
4623
+ let t = St(ui, e, oi);
4430
4624
  t && h.push(t);
4431
4625
  }
4432
4626
  }
4433
4627
  let g = t(...h), _ = async (n) => {
4434
4628
  let r = n.map((e) => e.user_id), i = r.length > 0 ? await e.select().from(A).where(t(a(A.tenant_id, o), l(A.linked_to, r))) : [];
4435
- return n.map((e) => ii(e, i.filter((t) => t.linked_to === e.user_id)));
4629
+ return n.map((e) => mi(e, i.filter((t) => t.linked_to === e.user_id)));
4436
4630
  };
4437
- if (At(s)) {
4438
- if (p?.sort_by && p.sort_by !== "created_at") throw new Le(400, { message: `Sorting by ${p.sort_by} is not supported with checkpoint pagination (from/take); only created_at is` });
4631
+ if (Pt(s)) {
4632
+ if (p?.sort_by && p.sort_by !== "created_at") throw new Re(400, { message: `Sorting by ${p.sort_by} is not supported with checkpoint pagination (from/take); only created_at is` });
4439
4633
  let n = p?.sort_order === "asc" ? "asc" : "desc", r = {
4440
4634
  sortColumn: A.created_at,
4441
4635
  idColumn: A.user_id,
4442
4636
  sortOrder: n,
4443
4637
  sortKey: `created_at:${n}`
4444
- }, i = jt(s), a = Nt(s, r), { rows: o, next: c } = Pt((await e.select().from(A).leftJoin(He, ti()).where(a ? t(g, a) : g).orderBy(...Mt(r)).limit(i + 1)).map((e) => ni(e.users, e.user_activity)), i, "created_at", "user_id", r.sortKey), l = await _(o);
4638
+ }, i = Ft(s), a = Lt(s, r), { rows: o, next: c } = Rt((await e.select().from(A).leftJoin(Ue, di()).where(a ? t(g, a) : g).orderBy(...It(r)).limit(i + 1)).map((e) => fi(e.users, e.user_activity)), i, "created_at", "user_id", r.sortKey), l = await _(o);
4445
4639
  return {
4446
4640
  users: l,
4447
4641
  start: 0,
@@ -4450,15 +4644,15 @@ function ai(e) {
4450
4644
  next: c
4451
4645
  };
4452
4646
  }
4453
- let v = e.select().from(A).leftJoin(He, ti()).where(g).$dynamic();
4647
+ let v = e.select().from(A).leftJoin(Ue, di()).where(g).$dynamic();
4454
4648
  if (p?.sort_by) {
4455
- let e = ei[p.sort_by];
4649
+ let e = ui[p.sort_by];
4456
4650
  if (e) {
4457
- let t = gt(e) ? _t(e) : e;
4651
+ let t = bt(e) ? xt(e) : e;
4458
4652
  v = v.orderBy(p.sort_order === "desc" ? i(t) : n(t));
4459
4653
  }
4460
4654
  }
4461
- let [y, ee] = await Promise.all([v.offset(c * u).limit(u), d ? e.select({ count: r() }).from(A).leftJoin(He, ti()).where(g) : void 0]), b = await _(y.map((e) => ni(e.users, e.user_activity)));
4655
+ let [y, ee] = await Promise.all([v.offset(c * u).limit(u), d ? e.select({ count: r() }).from(A).leftJoin(Ue, di()).where(g) : void 0]), b = await _(y.map((e) => fi(e.users, e.user_activity)));
4462
4656
  if (!ee) return { users: b };
4463
4657
  let [te] = ee;
4464
4658
  return {
@@ -4470,14 +4664,14 @@ function ai(e) {
4470
4664
  },
4471
4665
  async remove(n, r, i) {
4472
4666
  let o = await e.select({ user_id: A.user_id }).from(A).where(t(a(A.tenant_id, n), v(a(A.user_id, r), a(A.linked_to, r)))), s = o.some((e) => e.user_id === r), c = o.map((e) => e.user_id).filter((e) => e !== r), u = [r, ...c], d = [
4473
- e.delete(lt).where(t(a(lt.tenant_id, n), l(lt.user_id, u))),
4667
+ e.delete(dt).where(t(a(dt.tenant_id, n), l(dt.user_id, u))),
4474
4668
  e.delete(j).where(t(a(j.tenant_id, n), l(j.user_id, u))),
4475
- e.delete(He).where(t(a(He.tenant_id, n), l(He.user_id, u))),
4669
+ e.delete(Ue).where(t(a(Ue.tenant_id, n), l(Ue.user_id, u))),
4476
4670
  e.delete(A).where(t(a(A.tenant_id, n), l(A.user_id, c))),
4477
4671
  e.delete(A).where(t(a(A.tenant_id, n), a(A.user_id, r))).returning()
4478
4672
  ], f = d.length - 1;
4479
- if (s) for (let t of Jr(e, n, i)) d.push(t);
4480
- let p = (await Tt(e, d))[f];
4673
+ if (s) for (let t of ii(e, n, i)) d.push(t);
4674
+ let p = (await kt(e, d))[f];
4481
4675
  return Array.isArray(p) && p.length > 0;
4482
4676
  },
4483
4677
  async unlink(n, r, i, o) {
@@ -4488,7 +4682,7 @@ function ai(e) {
4488
4682
  }
4489
4683
  //#endregion
4490
4684
  //#region src/adapters/userRoles.ts
4491
- function oi(e) {
4685
+ function gi(e) {
4492
4686
  return {
4493
4687
  async create(t, n, r, i) {
4494
4688
  try {
@@ -4522,12 +4716,12 @@ function oi(e) {
4522
4716
  },
4523
4717
  async listUsers(r, i, o) {
4524
4718
  let s = t(a(G.tenant_id, r), a(G.role_id, i));
4525
- if (At(o)) {
4719
+ if (Pt(o)) {
4526
4720
  let n = {
4527
4721
  sortColumn: G.user_id,
4528
4722
  idColumn: G.user_id,
4529
4723
  sortOrder: "asc"
4530
- }, r = Nt(o, n), i = jt(o), { rows: a, next: c } = Pt(await e.selectDistinct({ user_id: G.user_id }).from(G).where(r ? t(s, r) : s).orderBy(...Mt(n)).limit(i + 1).all(), i, "user_id", "user_id");
4724
+ }, r = Lt(o, n), i = Ft(o), { rows: a, next: c } = Rt(await e.selectDistinct({ user_id: G.user_id }).from(G).where(r ? t(s, r) : s).orderBy(...It(n)).limit(i + 1).all(), i, "user_id", "user_id");
4531
4725
  return {
4532
4726
  userIds: a.map((e) => e.user_id),
4533
4727
  start: 0,
@@ -4551,7 +4745,7 @@ function oi(e) {
4551
4745
  }
4552
4746
  //#endregion
4553
4747
  //#region src/adapters/userOrganizations.ts
4554
- function si(e) {
4748
+ function _i(e) {
4555
4749
  return {
4556
4750
  async create(t, n) {
4557
4751
  let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
@@ -4565,7 +4759,7 @@ function si(e) {
4565
4759
  try {
4566
4760
  await e.insert(H).values(i);
4567
4761
  } catch (e) {
4568
- throw e?.message?.includes("UNIQUE constraint") || e?.message?.includes("duplicate key") ? new Le(409, { message: "User organization already exists" }) : e;
4762
+ throw e?.message?.includes("UNIQUE constraint") || e?.message?.includes("duplicate key") ? new Re(409, { message: "User organization already exists" }) : e;
4569
4763
  }
4570
4764
  let { tenant_id: a, ...o } = i;
4571
4765
  return o;
@@ -4583,19 +4777,19 @@ function si(e) {
4583
4777
  async list(n, o) {
4584
4778
  let { include_totals: s = !1, q: c } = o || {}, l = a(H.tenant_id, n), u = l;
4585
4779
  if (c) {
4586
- let e = vt(H, c, ["user_id", "organization_id"]);
4780
+ let e = St(H, c, ["user_id", "organization_id"]);
4587
4781
  e && (u = t(l, e));
4588
4782
  }
4589
4783
  let d = (e) => {
4590
4784
  let { tenant_id: t, ...n } = e;
4591
4785
  return n;
4592
4786
  };
4593
- if (At(o)) {
4787
+ if (Pt(o)) {
4594
4788
  let n = {
4595
4789
  sortColumn: H.created_at,
4596
4790
  idColumn: H.id,
4597
4791
  sortOrder: "desc"
4598
- }, r = Nt(o, n), i = jt(o), { rows: a, next: s } = Pt((await e.select().from(H).where(r ? t(u, r) : u).orderBy(...Mt(n)).limit(i + 1)).map(d), i, "created_at");
4792
+ }, r = Lt(o, n), i = Ft(o), { rows: a, next: s } = Rt((await e.select().from(H).where(r ? t(u, r) : u).orderBy(...It(n)).limit(i + 1)).map(d), i, "created_at");
4599
4793
  return {
4600
4794
  userOrganizations: a,
4601
4795
  start: 0,
@@ -4643,19 +4837,19 @@ function si(e) {
4643
4837
  }
4644
4838
  //#endregion
4645
4839
  //#region src/adapters/stats.ts
4646
- var ci = ["s"], li = ["pwd_leak"];
4647
- function ui(e) {
4840
+ var vi = ["s"], yi = ["pwd_leak"];
4841
+ function bi(e) {
4648
4842
  return /^\d{8}$/.test(e) ? `${e.slice(0, 4)}-${e.slice(4, 6)}-${e.slice(6, 8)}` : e;
4649
4843
  }
4650
- function di(e) {
4844
+ function xi(e) {
4651
4845
  return {
4652
4846
  async getDaily(n, r) {
4653
- let i = /* @__PURE__ */ new Date(), o = r?.from ? ui(r.from) : (/* @__PURE__ */ new Date(i.getTime() - 720 * 60 * 60 * 1e3)).toISOString().split("T")[0], s = r?.to ? ui(r.to) : i.toISOString().split("T")[0];
4847
+ let i = /* @__PURE__ */ new Date(), o = r?.from ? bi(r.from) : (/* @__PURE__ */ new Date(i.getTime() - 720 * 60 * 60 * 1e3)).toISOString().split("T")[0], s = r?.to ? bi(r.to) : i.toISOString().split("T")[0];
4654
4848
  return (await e.select({
4655
4849
  date: y`substr(${q.date}, 1, 10)`.as("date"),
4656
- logins: y`SUM(CASE WHEN ${q.type} IN (${y.join(ci.map((e) => y`${e}`), y`, `)}) THEN 1 ELSE 0 END)`.as("logins"),
4850
+ logins: y`SUM(CASE WHEN ${q.type} IN (${y.join(vi.map((e) => y`${e}`), y`, `)}) THEN 1 ELSE 0 END)`.as("logins"),
4657
4851
  signups: y`SUM(CASE WHEN ${q.type} = 'ss' THEN 1 ELSE 0 END)`.as("signups"),
4658
- leaked_passwords: y`SUM(CASE WHEN ${q.type} IN (${y.join(li.map((e) => y`${e}`), y`, `)}) THEN 1 ELSE 0 END)`.as("leaked_passwords")
4852
+ leaked_passwords: y`SUM(CASE WHEN ${q.type} IN (${y.join(yi.map((e) => y`${e}`), y`, `)}) THEN 1 ELSE 0 END)`.as("leaked_passwords")
4659
4853
  }).from(q).where(t(a(q.tenant_id, n), c(q.date, o), h(q.date, `${s}T23:59:59.999Z`))).groupBy(y`substr(${q.date}, 1, 10)`).orderBy(y`substr(${q.date}, 1, 10)`).all()).map((e) => ({
4660
4854
  date: e.date,
4661
4855
  logins: Number(e.logins) || 0,
@@ -4666,14 +4860,14 @@ function di(e) {
4666
4860
  }));
4667
4861
  },
4668
4862
  async getActiveUsers(n) {
4669
- let r = (/* @__PURE__ */ new Date(Date.now() - 720 * 60 * 60 * 1e3)).toISOString(), [i] = await e.select({ count: y`COUNT(DISTINCT ${q.user_id})`.as("count") }).from(q).where(t(a(q.tenant_id, n), c(q.date, r), y`${q.type} IN (${y.join(ci.map((e) => y`${e}`), y`, `)})`));
4863
+ let r = (/* @__PURE__ */ new Date(Date.now() - 720 * 60 * 60 * 1e3)).toISOString(), [i] = await e.select({ count: y`COUNT(DISTINCT ${q.user_id})`.as("count") }).from(q).where(t(a(q.tenant_id, n), c(q.date, r), y`${q.type} IN (${y.join(vi.map((e) => y`${e}`), y`, `)})`));
4670
4864
  return Number(i?.count) || 0;
4671
4865
  }
4672
4866
  };
4673
4867
  }
4674
4868
  //#endregion
4675
4869
  //#region src/adapters/analytics.ts
4676
- var fi = {
4870
+ var Si = {
4677
4871
  "active-users": ["s", "seacft"],
4678
4872
  logins: [
4679
4873
  "s",
@@ -4703,7 +4897,7 @@ var fi = {
4703
4897
  "fvr"
4704
4898
  ],
4705
4899
  "codes-sent": ["cls", "cs"]
4706
- }, pi = {
4900
+ }, Ci = {
4707
4901
  "active-users": {
4708
4902
  alias: "active_users",
4709
4903
  type: "UInt64",
@@ -4760,7 +4954,7 @@ var fi = {
4760
4954
  agg: "count"
4761
4955
  }
4762
4956
  };
4763
- function mi(e) {
4957
+ function wi(e) {
4764
4958
  switch (e) {
4765
4959
  case "hour": return y`substr(${q.date}, 1, 13)`;
4766
4960
  case "month": return y`substr(${q.date}, 1, 7)`;
@@ -4769,10 +4963,10 @@ function mi(e) {
4769
4963
  default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
4770
4964
  }
4771
4965
  }
4772
- function hi(e) {
4966
+ function Ti(e) {
4773
4967
  return `"${e.replace(/"/g, "\"\"")}"`;
4774
4968
  }
4775
- function gi(e) {
4969
+ function Ei(e) {
4776
4970
  switch (e) {
4777
4971
  case "connection": return q.connection;
4778
4972
  case "client_id": return q.client_id;
@@ -4781,10 +4975,10 @@ function gi(e) {
4781
4975
  case "time": throw Error("time dimension handled separately");
4782
4976
  }
4783
4977
  }
4784
- function _i(e) {
4978
+ function Di(e) {
4785
4979
  return {
4786
4980
  async query(n, r, i) {
4787
- let o = Date.now(), s = fi[r], u = pi[r], d = [
4981
+ let o = Date.now(), s = Si[r], u = Ci[r], d = [
4788
4982
  a(q.tenant_id, n),
4789
4983
  c(q.date, i.from),
4790
4984
  m(q.date, i.to),
@@ -4793,13 +4987,13 @@ function _i(e) {
4793
4987
  i.filters.connection?.length && d.push(l(q.connection, i.filters.connection)), i.filters.client_id?.length && d.push(l(q.client_id, i.filters.client_id)), i.filters.user_type?.length && d.push(l(q.strategy_type, i.filters.user_type)), i.filters.user_id?.length && d.push(l(q.user_id, i.filters.user_id));
4794
4988
  let f = {}, p = [], h = [];
4795
4989
  for (let e of i.group_by) if (e === "time") {
4796
- let e = mi(i.interval);
4990
+ let e = wi(i.interval);
4797
4991
  f.time = e, p.push(e), h.push({
4798
4992
  name: "time",
4799
4993
  type: i.interval === "hour" ? "DateTime" : "Date"
4800
4994
  });
4801
4995
  } else {
4802
- let t = gi(e);
4996
+ let t = Ei(e);
4803
4997
  f[e] = t, p.push(t), h.push({
4804
4998
  name: e,
4805
4999
  type: "String"
@@ -4815,9 +5009,9 @@ function _i(e) {
4815
5009
  if (i.order_by) {
4816
5010
  let e = i.order_by.startsWith("-"), t = e ? i.order_by.slice(1) : i.order_by;
4817
5011
  if (!_.has(t)) throw Error(`Invalid order_by column '${t}' for analytics query`);
4818
- let n = hi(t);
5012
+ let n = Ti(t);
4819
5013
  g = g.orderBy(y.raw(`${n} ${e ? "DESC" : "ASC"}`));
4820
- } else g = i.group_by[0] === "time" ? g.orderBy(y.raw(`${hi("time")} ASC`)) : g.orderBy(y.raw(`${hi(u.alias)} DESC`));
5014
+ } else g = i.group_by[0] === "time" ? g.orderBy(y.raw(`${Ti("time")} ASC`)) : g.orderBy(y.raw(`${Ti(u.alias)} DESC`));
4821
5015
  g = g.limit(i.limit).offset(i.offset);
4822
5016
  let v = (await g.all()).map((e) => {
4823
5017
  let t = {};
@@ -4836,7 +5030,7 @@ function _i(e) {
4836
5030
  };
4837
5031
  },
4838
5032
  async sessionRetention(n, r) {
4839
- let i = Date.now(), { sinceMs: o } = De(r.weeks, i), s = y`(${M.created_at_ts} + ${ue}) / ${fe}`, l = y`(COALESCE(${M.used_at_ts}, ${M.created_at_ts}) + ${ue}) / ${fe}`;
5033
+ let i = Date.now(), { sinceMs: o } = Oe(r.weeks, i), s = y`(${M.created_at_ts} + ${ue}) / ${fe}`, l = y`(COALESCE(${M.used_at_ts}, ${M.created_at_ts}) + ${ue}) / ${fe}`;
4840
5034
  return me((await e.select({
4841
5035
  created_week: s,
4842
5036
  used_week: l,
@@ -4848,7 +5042,7 @@ function _i(e) {
4848
5042
  })), r.weeks, i);
4849
5043
  },
4850
5044
  async refreshTokenRetention(n, r) {
4851
- let i = Date.now(), { sinceMs: o } = De(r.weeks, i), s = r.client_id && r.client_id.length > 0 ? l(N.client_id, r.client_id) : void 0, u = e.select({
5045
+ let i = Date.now(), { sinceMs: o } = Oe(r.weeks, i), s = r.client_id && r.client_id.length > 0 ? l(N.client_id, r.client_id) : void 0, u = e.select({
4852
5046
  min_created: y`MIN(${N.created_at_ts})`.as("min_created"),
4853
5047
  max_used: y`MAX(COALESCE(${N.last_exchanged_at_ts}, ${N.created_at_ts}))`.as("max_used")
4854
5048
  }).from(N).where(t(a(N.tenant_id, n), s)).groupBy(y`COALESCE(${N.family_id}, ${N.id})`).as("families"), d = y`(${u.min_created} + ${ue}) / ${fe}`, f = y`(${u.max_used} + ${ue}) / ${fe}`;
@@ -4866,10 +5060,10 @@ function _i(e) {
4866
5060
  }
4867
5061
  //#endregion
4868
5062
  //#region src/adapters/cleanup.ts
4869
- var vi = 10080 * 60 * 1e3;
4870
- function yi(e) {
5063
+ var Oi = 10080 * 60 * 1e3;
5064
+ function ki(e) {
4871
5065
  return async (n) => {
4872
- let r = Date.now() - vi;
5066
+ let r = Date.now() - Oi;
4873
5067
  try {
4874
5068
  let i = [v(m(N.expires_at_ts, r), m(N.idle_expires_at_ts, r))];
4875
5069
  n?.tenant_id && i.push(a(N.tenant_id, n.tenant_id)), await e.delete(N).where(t(...i)), i = [v(m(M.expires_at_ts, r), m(M.idle_expires_at_ts, r))], n?.tenant_id && i.push(a(M.tenant_id, n.tenant_id)), n?.user_id && i.push(a(M.user_id, n.user_id)), await e.delete(M).where(t(...i)), i = [m(P.expires_at_ts, r)], n?.tenant_id && i.push(a(P.tenant_id, n.tenant_id)), await e.delete(P).where(t(...i));
@@ -4904,7 +5098,7 @@ var Q = w("tenant_operations", {
4904
5098
  x("tenant_operations_tenant_id_created_at_idx").on(e.tenant_id, e.created_at),
4905
5099
  x("tenant_operations_rollout_id_idx").on(e.rollout_id),
4906
5100
  x("tenant_operations_status_idx").on(e.status)
4907
- ]), bi = w("tenant_operation_events", {
5101
+ ]), Ai = w("tenant_operation_events", {
4908
5102
  id: T("id", { length: 255 }).primaryKey(),
4909
5103
  operation_id: T("operation_id", { length: 255 }).notNull(),
4910
5104
  step: T("step", { length: 255 }).notNull(),
@@ -4935,7 +5129,7 @@ var Q = w("tenant_operations", {
4935
5129
  name: "tenant_operation_rows_operation_id_constraint"
4936
5130
  }).onDelete("cascade"),
4937
5131
  x("tenant_operation_rows_operation_id_status_idx").on(e.operation_id, e.status)
4938
- ]), xi = w("rollouts", {
5132
+ ]), ji = w("rollouts", {
4939
5133
  id: T("id", { length: 255 }).primaryKey(),
4940
5134
  kind: T("kind", { length: 32 }).notNull(),
4941
5135
  status: T("status", { length: 32 }).notNull(),
@@ -4951,7 +5145,7 @@ var Q = w("tenant_operations", {
4951
5145
  });
4952
5146
  //#endregion
4953
5147
  //#region src/adapters/tenantOperations.ts
4954
- function Si(e) {
5148
+ function Mi(e) {
4955
5149
  if (!e) return null;
4956
5150
  try {
4957
5151
  return JSON.parse(e);
@@ -4959,8 +5153,8 @@ function Si(e) {
4959
5153
  return null;
4960
5154
  }
4961
5155
  }
4962
- function Ci(e) {
4963
- return Pe.parse({
5156
+ function Ni(e) {
5157
+ return Fe.parse({
4964
5158
  id: e.id,
4965
5159
  tenant_id: e.tenant_id,
4966
5160
  rollout_id: e.rollout_id,
@@ -4973,8 +5167,8 @@ function Ci(e) {
4973
5167
  target_database_version: e.target_database_version,
4974
5168
  error: e.error,
4975
5169
  initiated_by: e.initiated_by,
4976
- input: Si(e.input),
4977
- result: Si(e.result),
5170
+ input: Mi(e.input),
5171
+ result: Mi(e.result),
4978
5172
  claimed_by: e.claimed_by,
4979
5173
  claim_expires_at: e.claim_expires_at,
4980
5174
  created_at: e.created_at,
@@ -4982,10 +5176,10 @@ function Ci(e) {
4982
5176
  finished_at: e.finished_at
4983
5177
  });
4984
5178
  }
4985
- function wi(e) {
5179
+ function Pi(e) {
4986
5180
  return {
4987
5181
  async create(t) {
4988
- let n = je.parse(t), r = (/* @__PURE__ */ new Date()).toISOString(), i = {
5182
+ let n = Me.parse(t), r = (/* @__PURE__ */ new Date()).toISOString(), i = {
4989
5183
  id: `op_${b()}`,
4990
5184
  tenant_id: n.tenant_id,
4991
5185
  rollout_id: n.rollout_id ?? null,
@@ -5013,7 +5207,7 @@ function wi(e) {
5013
5207
  },
5014
5208
  async get(t) {
5015
5209
  let n = await e.select().from(Q).where(a(Q.id, t)).limit(1);
5016
- return n[0] ? Ci(n[0]) : null;
5210
+ return n[0] ? Ni(n[0]) : null;
5017
5211
  },
5018
5212
  async list(n = {}) {
5019
5213
  let r = n.page ?? 0, o = n.per_page ?? 50, s = [];
@@ -5024,7 +5218,7 @@ function wi(e) {
5024
5218
  n.engine !== void 0 && s.push(a(Q.engine, n.engine)), n.updated_before !== void 0 && s.push(m(Q.updated_at, n.updated_before));
5025
5219
  let c = await e.select().from(Q).where(s.length ? t(...s) : void 0).orderBy(i(Q.created_at), i(Q.id)).offset(r * o).limit(o);
5026
5220
  return {
5027
- operations: c.map(Ci),
5221
+ operations: c.map(Ni),
5028
5222
  start: r * o,
5029
5223
  limit: o,
5030
5224
  length: c.length
@@ -5050,7 +5244,7 @@ function wi(e) {
5050
5244
  },
5051
5245
  async listResumable(r) {
5052
5246
  let i = (/* @__PURE__ */ new Date()).toISOString();
5053
- return (await e.select().from(Q).where(t(l(Q.status, ["pending", "running"]), a(Q.kind, r.kind), v(f(Q.claimed_by), h(Q.claim_expires_at, i)))).orderBy(n(Q.created_at), n(Q.id)).limit(r.limit)).map(Ci);
5247
+ return (await e.select().from(Q).where(t(l(Q.status, ["pending", "running"]), a(Q.kind, r.kind), v(f(Q.claimed_by), h(Q.claim_expires_at, i)))).orderBy(n(Q.created_at), n(Q.id)).limit(r.limit)).map(Ni);
5054
5248
  },
5055
5249
  async remove(t) {
5056
5250
  return (await e.select({ id: Q.id }).from(Q).where(a(Q.id, t)).limit(1)).length === 0 ? !1 : (await e.delete(Q).where(a(Q.id, t)), !0);
@@ -5059,19 +5253,19 @@ function wi(e) {
5059
5253
  }
5060
5254
  //#endregion
5061
5255
  //#region src/adapters/tenantOperationRows.ts
5062
- var Ti = 50, Ei = 50;
5063
- function Di(e) {
5256
+ var Fi = 50, Ii = 50;
5257
+ function Li(e) {
5064
5258
  try {
5065
5259
  return JSON.parse(e);
5066
5260
  } catch {
5067
5261
  return {};
5068
5262
  }
5069
5263
  }
5070
- function Oi(e) {
5071
- return Ne.parse({
5264
+ function Ri(e) {
5265
+ return Pe.parse({
5072
5266
  operation_id: e.operation_id,
5073
5267
  seq: e.seq,
5074
- payload: Di(e.payload),
5268
+ payload: Li(e.payload),
5075
5269
  status: e.status,
5076
5270
  error_code: e.error_code,
5077
5271
  error_message: e.error_message,
@@ -5081,12 +5275,12 @@ function Oi(e) {
5081
5275
  updated_at: e.updated_at
5082
5276
  });
5083
5277
  }
5084
- function ki(e, t) {
5278
+ function zi(e, t) {
5085
5279
  let n = [];
5086
5280
  for (let r = 0; r < e.length; r += t) n.push(e.slice(r, r + t));
5087
5281
  return n;
5088
5282
  }
5089
- function Ai(e, n, r, i) {
5283
+ function Bi(e, n, r, i) {
5090
5284
  return e.update($).set({
5091
5285
  status: r.status,
5092
5286
  error_code: r.error_code ?? null,
@@ -5096,12 +5290,12 @@ function Ai(e, n, r, i) {
5096
5290
  updated_at: i
5097
5291
  }).where(t(a($.operation_id, n), a($.seq, r.seq), a($.status, "pending")));
5098
5292
  }
5099
- function ji(e) {
5293
+ function Vi(e) {
5100
5294
  return {
5101
5295
  async createMany(t) {
5102
5296
  if (t.length === 0) return 0;
5103
5297
  let n = (/* @__PURE__ */ new Date()).toISOString(), r = t.map((e) => {
5104
- let t = Me.parse(e);
5298
+ let t = Ne.parse(e);
5105
5299
  return {
5106
5300
  operation_id: t.operation_id,
5107
5301
  seq: t.seq,
@@ -5115,24 +5309,24 @@ function ji(e) {
5115
5309
  updated_at: n
5116
5310
  };
5117
5311
  });
5118
- for (let t of ki(r, Ti)) await e.insert($).values(t);
5312
+ for (let t of zi(r, Fi)) await e.insert($).values(t);
5119
5313
  return r.length;
5120
5314
  },
5121
5315
  async claimPending(r, i) {
5122
- return (await e.select().from($).where(t(a($.operation_id, r), a($.status, "pending"))).orderBy(n($.seq)).limit(i)).map(Oi);
5316
+ return (await e.select().from($).where(t(a($.operation_id, r), a($.status, "pending"))).orderBy(n($.seq)).limit(i)).map(Ri);
5123
5317
  },
5124
5318
  async recordOutcomes(n, r) {
5125
5319
  if (r.length === 0) return 0;
5126
5320
  let i = (/* @__PURE__ */ new Date()).toISOString(), o = r.map((e) => e.seq), s = /* @__PURE__ */ new Set();
5127
- for (let r of ki(o, Ei)) {
5321
+ for (let r of zi(o, Ii)) {
5128
5322
  let i = await e.select({ seq: $.seq }).from($).where(t(a($.operation_id, n), a($.status, "pending"), l($.seq, r)));
5129
5323
  for (let e of i) s.add(e.seq);
5130
5324
  }
5131
5325
  let c = r.filter((e) => s.has(e.seq));
5132
5326
  if (c.length === 0) return 0;
5133
- for (let t of ki(c, Ei)) {
5134
- let [r, ...a] = t.map((t) => Ai(e, n, t, i));
5135
- r && await Tt(e, [r, ...a]);
5327
+ for (let t of zi(c, Ii)) {
5328
+ let [r, ...a] = t.map((t) => Bi(e, n, t, i));
5329
+ r && await kt(e, [r, ...a]);
5136
5330
  }
5137
5331
  return c.length;
5138
5332
  },
@@ -5167,7 +5361,7 @@ function ji(e) {
5167
5361
  }
5168
5362
  let u = await e.select().from($).where(t(...c)).orderBy(n($.seq)).offset(o * s).limit(s);
5169
5363
  return {
5170
- rows: u.map(Oi),
5364
+ rows: u.map(Ri),
5171
5365
  start: o * s,
5172
5366
  limit: s,
5173
5367
  length: u.length
@@ -5181,27 +5375,27 @@ function ji(e) {
5181
5375
  }
5182
5376
  //#endregion
5183
5377
  //#region src/helpers/monotonic-id.ts
5184
- var Mi = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", Ni = 32, Pi = 10, Fi = 4, Ii = 10;
5185
- function Li(e, t) {
5378
+ var Hi = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", Ui = 32, Wi = 10, Gi = 4, Ki = 10;
5379
+ function qi(e, t) {
5186
5380
  let n = "";
5187
- for (let r = t; r > 0; r--) n = Mi.charAt(e % Ni) + n, e = Math.floor(e / Ni);
5381
+ for (let r = t; r > 0; r--) n = Hi.charAt(e % Ui) + n, e = Math.floor(e / Ui);
5188
5382
  return n;
5189
5383
  }
5190
- function Ri() {
5191
- let e = new Uint8Array(Ii);
5384
+ function Ji() {
5385
+ let e = new Uint8Array(Ki);
5192
5386
  crypto.getRandomValues(e);
5193
5387
  let t = "";
5194
- for (let n = 0; n < Ii; n++) t += Mi.charAt(e[n] % Ni);
5388
+ for (let n = 0; n < Ki; n++) t += Hi.charAt(e[n] % Ui);
5195
5389
  return t;
5196
5390
  }
5197
- var zi = 0, Bi = 0;
5198
- function Vi() {
5391
+ var Yi = 0, Xi = 0;
5392
+ function Zi() {
5199
5393
  let e = Date.now();
5200
- return e === zi ? Bi++ : (zi = e, Bi = 0), Li(e, Pi) + Li(Bi, Fi) + Ri();
5394
+ return e === Yi ? Xi++ : (Yi = e, Xi = 0), qi(e, Wi) + qi(Xi, Gi) + Ji();
5201
5395
  }
5202
5396
  //#endregion
5203
5397
  //#region src/adapters/tenantOperationEvents.ts
5204
- function Hi(e) {
5398
+ function Qi(e) {
5205
5399
  if (!e) return null;
5206
5400
  try {
5207
5401
  let t = JSON.parse(e);
@@ -5209,22 +5403,22 @@ function Hi(e) {
5209
5403
  } catch {}
5210
5404
  return null;
5211
5405
  }
5212
- function Ui(e) {
5213
- return Ae.parse({
5406
+ function $i(e) {
5407
+ return je.parse({
5214
5408
  id: e.id,
5215
5409
  operation_id: e.operation_id,
5216
5410
  step: e.step,
5217
5411
  outcome: e.outcome,
5218
- detail: Hi(e.detail),
5412
+ detail: Qi(e.detail),
5219
5413
  attempt: e.attempt,
5220
5414
  created_at: e.created_at
5221
5415
  });
5222
5416
  }
5223
- function Wi(e) {
5417
+ function ea(e) {
5224
5418
  return {
5225
5419
  async create(t) {
5226
- let n = ke.parse(t), r = {
5227
- id: `evt_${Vi()}`,
5420
+ let n = Ae.parse(t), r = {
5421
+ id: `evt_${Zi()}`,
5228
5422
  operation_id: n.operation_id,
5229
5423
  step: n.step,
5230
5424
  outcome: n.outcome,
@@ -5232,7 +5426,7 @@ function Wi(e) {
5232
5426
  attempt: n.attempt,
5233
5427
  created_at: (/* @__PURE__ */ new Date()).toISOString()
5234
5428
  };
5235
- return await e.insert(bi).values(r), Ae.parse({
5429
+ return await e.insert(Ai).values(r), je.parse({
5236
5430
  id: r.id,
5237
5431
  operation_id: r.operation_id,
5238
5432
  step: r.step,
@@ -5243,9 +5437,9 @@ function Wi(e) {
5243
5437
  });
5244
5438
  },
5245
5439
  async listByOperation(t, r = {}) {
5246
- let i = r.page ?? 0, o = r.per_page ?? 100, s = await e.select().from(bi).where(a(bi.operation_id, t)).orderBy(n(bi.created_at), n(bi.id)).offset(i * o).limit(o);
5440
+ let i = r.page ?? 0, o = r.per_page ?? 100, s = await e.select().from(Ai).where(a(Ai.operation_id, t)).orderBy(n(Ai.created_at), n(Ai.id)).offset(i * o).limit(o);
5247
5441
  return {
5248
- events: s.map(Ui),
5442
+ events: s.map($i),
5249
5443
  start: i * o,
5250
5444
  limit: o,
5251
5445
  length: s.length
@@ -5255,7 +5449,7 @@ function Wi(e) {
5255
5449
  }
5256
5450
  //#endregion
5257
5451
  //#region src/adapters/rollouts.ts
5258
- function Gi(e) {
5452
+ function ta(e) {
5259
5453
  if (!e) return null;
5260
5454
  try {
5261
5455
  return JSON.parse(e);
@@ -5263,26 +5457,26 @@ function Gi(e) {
5263
5457
  return null;
5264
5458
  }
5265
5459
  }
5266
- function Ki(e) {
5267
- return we.parse({
5460
+ function na(e) {
5461
+ return Te.parse({
5268
5462
  id: e.id,
5269
5463
  kind: e.kind,
5270
5464
  status: e.status,
5271
5465
  target_worker_version: e.target_worker_version,
5272
5466
  target_database_version: e.target_database_version,
5273
5467
  wave_size: e.wave_size,
5274
- canary_tenant_ids: Gi(e.canary_tenant_ids),
5275
- filter: Gi(e.filter),
5468
+ canary_tenant_ids: ta(e.canary_tenant_ids),
5469
+ filter: ta(e.filter),
5276
5470
  initiated_by: e.initiated_by,
5277
5471
  created_at: e.created_at,
5278
5472
  updated_at: e.updated_at,
5279
5473
  finished_at: e.finished_at
5280
5474
  });
5281
5475
  }
5282
- function qi(e) {
5476
+ function ra(e) {
5283
5477
  return {
5284
5478
  async create(t) {
5285
- let n = Ce.parse(t), r = (/* @__PURE__ */ new Date()).toISOString(), i = {
5479
+ let n = we.parse(t), r = (/* @__PURE__ */ new Date()).toISOString(), i = {
5286
5480
  id: `rol_${b()}`,
5287
5481
  kind: n.kind,
5288
5482
  status: "pending",
@@ -5296,96 +5490,99 @@ function qi(e) {
5296
5490
  updated_at: r,
5297
5491
  finished_at: null
5298
5492
  };
5299
- await e.insert(xi).values(i);
5493
+ await e.insert(ji).values(i);
5300
5494
  let a = await this.get(i.id);
5301
5495
  if (!a) throw Error(`Failed to create rollout ${i.id}`);
5302
5496
  return a;
5303
5497
  },
5304
5498
  async get(t) {
5305
- let n = await e.select().from(xi).where(a(xi.id, t)).limit(1);
5306
- return n[0] ? Ki(n[0]) : null;
5499
+ let n = await e.select().from(ji).where(a(ji.id, t)).limit(1);
5500
+ return n[0] ? na(n[0]) : null;
5307
5501
  },
5308
5502
  async list(t = {}) {
5309
- let n = t.page ?? 0, r = t.per_page ?? 50, a = await e.select().from(xi).orderBy(i(xi.created_at), i(xi.id)).offset(n * r).limit(r);
5503
+ let n = t.page ?? 0, r = t.per_page ?? 50, a = await e.select().from(ji).orderBy(i(ji.created_at), i(ji.id)).offset(n * r).limit(r);
5310
5504
  return {
5311
- rollouts: a.map(Ki),
5505
+ rollouts: a.map(na),
5312
5506
  start: n * r,
5313
5507
  limit: r,
5314
5508
  length: a.length
5315
5509
  };
5316
5510
  },
5317
5511
  async update(t, n) {
5318
- if ((await e.select({ id: xi.id }).from(xi).where(a(xi.id, t)).limit(1)).length === 0) return !1;
5512
+ if ((await e.select({ id: ji.id }).from(ji).where(a(ji.id, t)).limit(1)).length === 0) return !1;
5319
5513
  let r = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
5320
- return n.status !== void 0 && (r.status = n.status), n.wave_size !== void 0 && (r.wave_size = n.wave_size), n.canary_tenant_ids !== void 0 && (r.canary_tenant_ids = n.canary_tenant_ids ? JSON.stringify(n.canary_tenant_ids) : null), n.filter !== void 0 && (r.filter = n.filter ? JSON.stringify(n.filter) : null), n.finished_at !== void 0 && (r.finished_at = n.finished_at), await e.update(xi).set(r).where(a(xi.id, t)), !0;
5514
+ return n.status !== void 0 && (r.status = n.status), n.wave_size !== void 0 && (r.wave_size = n.wave_size), n.canary_tenant_ids !== void 0 && (r.canary_tenant_ids = n.canary_tenant_ids ? JSON.stringify(n.canary_tenant_ids) : null), n.filter !== void 0 && (r.filter = n.filter ? JSON.stringify(n.filter) : null), n.finished_at !== void 0 && (r.finished_at = n.finished_at), await e.update(ji).set(r).where(a(ji.id, t)), !0;
5321
5515
  },
5322
5516
  async remove(t) {
5323
- return (await e.select({ id: xi.id }).from(xi).where(a(xi.id, t)).limit(1)).length === 0 ? !1 : (await e.delete(xi).where(a(xi.id, t)), !0);
5517
+ return (await e.select({ id: ji.id }).from(ji).where(a(ji.id, t)).limit(1)).length === 0 ? !1 : (await e.delete(ji).where(a(ji.id, t)), !0);
5324
5518
  }
5325
5519
  };
5326
5520
  }
5327
5521
  //#endregion
5328
5522
  //#region src/adapters/index.ts
5329
- function Ji(e, t = { useTransactions: !0 }) {
5523
+ function ia(e, t = { useTransactions: !0 }) {
5330
5524
  let n = {
5331
- actions: xt(e),
5332
- actionExecutions: Ct(e),
5333
- actionVersions: Dt(e),
5334
- branding: kt(e),
5335
- clients: Bt(e),
5336
- clientConnections: Ht(e),
5337
- clientGrants: Wt(e),
5338
- clientRegistrationTokens: Yt(e),
5339
- codes: $t(e),
5340
- connections: nn(e),
5341
- customDomains: an(e),
5342
- customText: on(e),
5343
- emailProviders: sn(e),
5344
- emailTemplates: ln(e),
5345
- flows: dn(e),
5346
- forms: mn(e),
5347
- grants: vn(e),
5348
- hookCode: Sn(e),
5349
- hooks: En(e),
5350
- invites: An(e),
5351
- keys: Mn(e),
5352
- loginSessions: Ln(e),
5353
- logs: zn(e),
5354
- authenticationMethods: Wn(e),
5355
- organizations: Jn(e),
5356
- passwords: Xn(e),
5357
- promptSettings: Zn(e),
5358
- promptPartials: Qn(e),
5359
- proxyRoutes: nr(e),
5360
- scimConfigurations: ur(e),
5361
- scimTokens: fr(e),
5362
- scimExternalIds: mr(e),
5363
- refreshTokens: _r(e),
5364
- resourceServers: Cr(e),
5365
- rolePermissions: wr(e),
5366
- userPermissions: Er(e),
5367
- roles: Or(e),
5368
- sessions: Nr(e),
5369
- sessionCleanup: yi(e),
5370
- tenants: Rr(e),
5371
- tokenExchangeProfiles: or(e),
5525
+ actions: Tt(e),
5526
+ actionExecutions: Dt(e),
5527
+ actionVersions: jt(e),
5528
+ branding: Nt(e),
5529
+ clients: Wt(e),
5530
+ clientConnections: Kt(e),
5531
+ clientGrants: Jt(e),
5532
+ clientRegistrationTokens: $t(e),
5533
+ codes: rn(e),
5534
+ connections: sn(e),
5535
+ customDomains: ln(e),
5536
+ customText: un(e),
5537
+ emailProviders: dn(e),
5538
+ emailTemplates: pn(e),
5539
+ flows: hn(e),
5540
+ forms: vn(e),
5541
+ grants: Sn(e),
5542
+ hookCode: En(e),
5543
+ hooks: An(e),
5544
+ invites: Pn(e),
5545
+ keys: In(e),
5546
+ loginSessions: Vn(e),
5547
+ logs: Un(e),
5548
+ logStreams: nr(e),
5549
+ migrationSources: ir(e),
5550
+ authenticationMethods: Jn(e),
5551
+ organizations: Qn(e),
5552
+ organizationConnections: er(e),
5553
+ passwords: or(e),
5554
+ promptSettings: sr(e),
5555
+ promptPartials: cr(e),
5556
+ proxyRoutes: fr(e),
5557
+ scimConfigurations: br(e),
5558
+ scimTokens: Sr(e),
5559
+ scimExternalIds: wr(e),
5560
+ refreshTokens: Dr(e),
5561
+ resourceServers: Nr(e),
5562
+ rolePermissions: Pr(e),
5563
+ userPermissions: Ir(e),
5564
+ roles: Rr(e),
5565
+ sessions: Ur(e),
5566
+ sessionCleanup: ki(e),
5567
+ tenants: Jr(e),
5568
+ tokenExchangeProfiles: gr(e),
5372
5569
  ...t.controlPlane ? {
5373
- tenantOperations: wi(e),
5374
- tenantOperationEvents: Wi(e),
5375
- tenantOperationRows: ji(e),
5376
- rollouts: qi(e)
5570
+ tenantOperations: Pi(e),
5571
+ tenantOperationEvents: ea(e),
5572
+ tenantOperationRows: Vi(e),
5573
+ rollouts: ra(e)
5377
5574
  } : {},
5378
- themes: Vr(e),
5379
- universalLoginTemplates: Hr(e),
5380
- users: ai(e),
5381
- userActivity: Wr(e),
5382
- userRoles: oi(e),
5383
- userOrganizations: si(e),
5384
- stats: di(e),
5385
- analytics: _i(e),
5386
- outbox: qr(e),
5575
+ themes: Zr(e),
5576
+ universalLoginTemplates: Qr(e),
5577
+ users: hi(e),
5578
+ userActivity: ei(e),
5579
+ userRoles: gi(e),
5580
+ userOrganizations: _i(e),
5581
+ stats: xi(e),
5582
+ analytics: Di(e),
5583
+ outbox: ri(e),
5387
5584
  async transaction(r) {
5388
- if (t.useTransactions === !1 || wt(e)) return r(n);
5585
+ if (t.useTransactions === !1 || Ot(e)) return r(n);
5389
5586
  await e.run(y`BEGIN`);
5390
5587
  try {
5391
5588
  let t = await r(n);
@@ -5399,7 +5596,7 @@ function Ji(e, t = { useTransactions: !0 }) {
5399
5596
  }
5400
5597
  //#endregion
5401
5598
  //#region src/adapters/resolveHost.ts
5402
- function Yi(e) {
5599
+ function aa(e) {
5403
5600
  if (!e) return { path: "/*" };
5404
5601
  try {
5405
5602
  let t = JSON.parse(e), n = xe.safeParse(t);
@@ -5407,7 +5604,7 @@ function Yi(e) {
5407
5604
  } catch {}
5408
5605
  return { path: "/*" };
5409
5606
  }
5410
- function Xi(e) {
5607
+ function oa(e) {
5411
5608
  if (!e) return [];
5412
5609
  try {
5413
5610
  let t = JSON.parse(e);
@@ -5422,20 +5619,20 @@ function Xi(e) {
5422
5619
  return [];
5423
5620
  }
5424
5621
  }
5425
- async function Zi(e, r) {
5622
+ async function sa(e, r) {
5426
5623
  let i = r.toLowerCase(), o = (await e.select({
5427
- custom_domain_id: Ke.custom_domain_id,
5428
- tenant_id: Ke.tenant_id,
5429
- domain: Ke.domain
5430
- }).from(Ke).where(a(Ke.domain, i)).limit(1))[0];
5624
+ custom_domain_id: qe.custom_domain_id,
5625
+ tenant_id: qe.tenant_id,
5626
+ domain: qe.domain
5627
+ }).from(qe).where(a(qe.domain, i)).limit(1))[0];
5431
5628
  if (!o) return null;
5432
5629
  let s = (await e.select().from(Y).where(t(a(Y.tenant_id, o.tenant_id), a(Y.custom_domain_id, o.custom_domain_id))).orderBy(n(Y.priority), n(Y.created_at))).map((e) => ({
5433
5630
  id: e.id,
5434
5631
  tenant_id: e.tenant_id,
5435
5632
  custom_domain_id: e.custom_domain_id,
5436
5633
  priority: e.priority,
5437
- match: Yi(e.match),
5438
- handlers: Xi(e.handlers),
5634
+ match: aa(e.match),
5635
+ handlers: oa(e.handlers),
5439
5636
  created_at: e.created_at,
5440
5637
  updated_at: e.updated_at
5441
5638
  }));
@@ -5448,11 +5645,11 @@ async function Zi(e, r) {
5448
5645
  }
5449
5646
  //#endregion
5450
5647
  //#region src/adapters/proxyData.ts
5451
- function Qi(e) {
5648
+ function ca(e) {
5452
5649
  return {
5453
- proxyRoutes: nr(e),
5454
- resolveHost: (t) => Zi(e, t)
5650
+ proxyRoutes: fr(e),
5651
+ resolveHost: (t) => sa(e, t)
5455
5652
  };
5456
5653
  }
5457
5654
  //#endregion
5458
- export { Qi as createProxyDataAdapter, nr as createProxyRoutesAdapter, Ji as default, pt as sqlite };
5655
+ export { ca as createProxyDataAdapter, fr as createProxyRoutesAdapter, ia as default, _t as sqlite };