@authhero/drizzle 1.13.0 → 1.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/drizzle-adapter.cjs +2 -2
- package/dist/drizzle-adapter.mjs +1167 -949
- package/package.json +3 -3
package/dist/drizzle-adapter.mjs
CHANGED
|
@@ -67,7 +67,7 @@ var ze = Object.defineProperty, Be = (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
|
-
}),
|
|
70
|
+
}), k = 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(),
|
|
@@ -89,7 +89,7 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
89
89
|
}),
|
|
90
90
|
x("idx_actions_tenant_id").on(e.tenant_id),
|
|
91
91
|
x("idx_actions_name").on(e.tenant_id, e.name)
|
|
92
|
-
]),
|
|
92
|
+
]), Ve = w("action_versions", {
|
|
93
93
|
id: T("id", { length: 255 }).notNull(),
|
|
94
94
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
95
95
|
action_id: T("action_id", { length: 255 }).notNull(),
|
|
@@ -419,7 +419,7 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
419
419
|
expires_at_ts: S("expires_at_ts"),
|
|
420
420
|
created_at_ts: S("created_at_ts").notNull(),
|
|
421
421
|
revoked_at_ts: S("revoked_at_ts")
|
|
422
|
-
}, (e) => [re("idx_client_registration_tokens_hash").on(e.tenant_id, e.token_hash), x("idx_client_registration_tokens_client").on(e.tenant_id, e.client_id)]),
|
|
422
|
+
}, (e) => [re("idx_client_registration_tokens_hash").on(e.tenant_id, e.token_hash), x("idx_client_registration_tokens_client").on(e.tenant_id, e.client_id)]), qe = w("client_grants", {
|
|
423
423
|
id: T("id", { length: 21 }).notNull(),
|
|
424
424
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
425
425
|
client_id: T("client_id", { length: 191 }).notNull(),
|
|
@@ -439,7 +439,7 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
439
439
|
}),
|
|
440
440
|
x("idx_client_grants_audience").on(e.audience),
|
|
441
441
|
re("uq_client_grants_tenant_client_audience").on(e.tenant_id, e.client_id, e.audience)
|
|
442
|
-
]),
|
|
442
|
+
]), R = w("grants", {
|
|
443
443
|
id: T("id", { length: 21 }).primaryKey(),
|
|
444
444
|
tenant_id: T("tenant_id", { length: 255 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
445
445
|
user_id: T("user_id", { length: 255 }).notNull(),
|
|
@@ -456,7 +456,7 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
456
456
|
}).onDelete("cascade"),
|
|
457
457
|
re("grants_natural_key_idx").on(e.tenant_id, e.user_id, e.client_id, e.audience),
|
|
458
458
|
x("grants_tenant_user_idx").on(e.tenant_id, e.user_id)
|
|
459
|
-
]),
|
|
459
|
+
]), z = w("connections", {
|
|
460
460
|
id: T("id", { length: 255 }).notNull(),
|
|
461
461
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
462
462
|
name: T("name", { length: 255 }).notNull(),
|
|
@@ -475,7 +475,7 @@ var ze = Object.defineProperty, Be = (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
|
-
]),
|
|
478
|
+
]), Je = 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 ze = Object.defineProperty, Be = (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)]),
|
|
492
|
+
}, (e) => [re("custom_domains_domain_unique").on(e.domain)]), Ye = 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(),
|
|
@@ -499,7 +499,7 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
499
499
|
dkim_public_key: T("dkim_public_key", { length: 2048 }),
|
|
500
500
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
501
501
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
502
|
-
}),
|
|
502
|
+
}), B = w("organizations", {
|
|
503
503
|
id: T("id", { length: 21 }).primaryKey(),
|
|
504
504
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
505
505
|
name: T("name", { length: 256 }).notNull(),
|
|
@@ -510,7 +510,7 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
510
510
|
token_quota: T("token_quota"),
|
|
511
511
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
512
512
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
513
|
-
}, (e) => [x("idx_organizations_tenant_id").on(e.tenant_id)]),
|
|
513
|
+
}, (e) => [x("idx_organizations_tenant_id").on(e.tenant_id)]), V = w("user_organizations", {
|
|
514
514
|
id: T("id", { length: 21 }).primaryKey(),
|
|
515
515
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
516
516
|
user_id: T("user_id", { length: 191 }).notNull(),
|
|
@@ -522,7 +522,7 @@ var ze = Object.defineProperty, Be = (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
|
-
]),
|
|
525
|
+
]), Xe = 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,7 @@ var ze = Object.defineProperty, Be = (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
|
-
]),
|
|
547
|
+
]), Ze = w("organization_connections", {
|
|
548
548
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
549
549
|
organization_id: T("organization_id", { length: 21 }).notNull(),
|
|
550
550
|
connection_id: T("connection_id", { length: 191 }).notNull(),
|
|
@@ -557,7 +557,7 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
557
557
|
e.tenant_id,
|
|
558
558
|
e.organization_id,
|
|
559
559
|
e.connection_id
|
|
560
|
-
] })]),
|
|
560
|
+
] })]), H = w("roles", {
|
|
561
561
|
id: T("id", { length: 21 }).notNull(),
|
|
562
562
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
563
563
|
name: T("name", { length: 50 }).notNull(),
|
|
@@ -569,7 +569,7 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
569
569
|
}, (e) => [C({
|
|
570
570
|
columns: [e.tenant_id, e.id],
|
|
571
571
|
name: "roles_pk"
|
|
572
|
-
})]),
|
|
572
|
+
})]), U = w("role_permissions", {
|
|
573
573
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
574
574
|
role_id: T("role_id", { length: 21 }).notNull(),
|
|
575
575
|
resource_server_identifier: T("resource_server_identifier", { length: 191 }).notNull(),
|
|
@@ -587,7 +587,7 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
587
587
|
}),
|
|
588
588
|
x("role_permissions_role_fk").on(e.tenant_id, e.role_id),
|
|
589
589
|
x("role_permissions_permission_fk").on(e.tenant_id, e.resource_server_identifier, e.permission_name)
|
|
590
|
-
]),
|
|
590
|
+
]), Qe = w("user_permissions", {
|
|
591
591
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
592
592
|
user_id: T("user_id", { length: 191 }).notNull(),
|
|
593
593
|
resource_server_identifier: T("resource_server_identifier", { length: 191 }).notNull(),
|
|
@@ -608,7 +608,7 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
608
608
|
x("user_permissions_user_fk").on(e.tenant_id, e.user_id),
|
|
609
609
|
x("user_permissions_permission_fk").on(e.tenant_id, e.resource_server_identifier, e.permission_name),
|
|
610
610
|
x("user_permissions_organization_fk").on(e.organization_id)
|
|
611
|
-
]),
|
|
611
|
+
]), W = w("user_roles", {
|
|
612
612
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
613
613
|
user_id: T("user_id", { length: 191 }).notNull(),
|
|
614
614
|
role_id: T("role_id", { length: 21 }).notNull(),
|
|
@@ -627,7 +627,7 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
627
627
|
x("user_roles_user_fk").on(e.tenant_id, e.user_id),
|
|
628
628
|
x("user_roles_role_fk").on(e.tenant_id, e.role_id),
|
|
629
629
|
x("user_roles_organization_fk").on(e.organization_id)
|
|
630
|
-
]),
|
|
630
|
+
]), G = w("resource_servers", {
|
|
631
631
|
id: T("id", { length: 21 }).notNull(),
|
|
632
632
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
633
633
|
identifier: T("identifier", { length: 191 }).notNull(),
|
|
@@ -648,7 +648,7 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
648
648
|
}, (e) => [C({
|
|
649
649
|
columns: [e.tenant_id, e.id],
|
|
650
650
|
name: "resource_servers_pk"
|
|
651
|
-
})]),
|
|
651
|
+
})]), $e = w("branding", {
|
|
652
652
|
tenant_id: T("tenant_id", { length: 191 }).primaryKey().references(() => O.id, { onDelete: "cascade" }),
|
|
653
653
|
logo_url: T("logo_url", { length: 512 }),
|
|
654
654
|
favicon_url: T("favicon_url", { length: 512 }),
|
|
@@ -659,12 +659,12 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
659
659
|
colors_page_background_end: T("colors_page_background_end", { length: 8 }),
|
|
660
660
|
colors_page_background_angle_dev: S("colors_page_background_angle_dev"),
|
|
661
661
|
dark_mode: T("dark_mode", { length: 8 })
|
|
662
|
-
}),
|
|
662
|
+
}), et = w("universal_login_templates", {
|
|
663
663
|
tenant_id: T("tenant_id", { length: 191 }).primaryKey().references(() => O.id, { onDelete: "cascade" }),
|
|
664
664
|
body: T("body").notNull(),
|
|
665
665
|
created_at_ts: S("created_at_ts").notNull(),
|
|
666
666
|
updated_at_ts: S("updated_at_ts").notNull()
|
|
667
|
-
}),
|
|
667
|
+
}), tt = w("themes", {
|
|
668
668
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
669
669
|
themeId: T("themeId", { length: 255 }).notNull(),
|
|
670
670
|
displayName: T("displayName", { length: 255 }).notNull(),
|
|
@@ -724,7 +724,7 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
724
724
|
}, (e) => [C({
|
|
725
725
|
columns: [e.tenant_id, e.themeId],
|
|
726
726
|
name: "themes_pkey"
|
|
727
|
-
}), x("themes_tenant_id_idx").on(e.tenant_id)]),
|
|
727
|
+
}), x("themes_tenant_id_idx").on(e.tenant_id)]), nt = w("forms", {
|
|
728
728
|
id: T("id", { length: 255 }).primaryKey(),
|
|
729
729
|
name: T("name", { length: 255 }).notNull(),
|
|
730
730
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
@@ -737,21 +737,21 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
737
737
|
style: T("style", { length: 1042 }),
|
|
738
738
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
739
739
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
740
|
-
}, (e) => [x("forms_tenant_id_idx").on(e.tenant_id)]),
|
|
740
|
+
}, (e) => [x("forms_tenant_id_idx").on(e.tenant_id)]), rt = w("flows", {
|
|
741
741
|
id: T("id", { length: 24 }).primaryKey(),
|
|
742
742
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
743
743
|
name: T("name", { length: 150 }).notNull(),
|
|
744
744
|
actions: T("actions"),
|
|
745
745
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
746
746
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
747
|
-
}, (e) => [x("flows_tenant_id_idx").on(e.tenant_id)]),
|
|
747
|
+
}, (e) => [x("flows_tenant_id_idx").on(e.tenant_id)]), it = w("prompt_settings", {
|
|
748
748
|
tenant_id: T("tenant_id", { length: 191 }).primaryKey(),
|
|
749
749
|
universal_login_experience: T("universal_login_experience", { length: 16 }).notNull().default("new"),
|
|
750
750
|
identifier_first: S("identifier_first", { mode: "boolean" }).notNull().default(!0),
|
|
751
751
|
password_first: S("password_first", { mode: "boolean" }).notNull().default(!1),
|
|
752
752
|
webauthn_platform_first_factor: S("webauthn_platform_first_factor", { mode: "boolean" }).notNull().default(!1),
|
|
753
753
|
show_last_used_connection: S("show_last_used_connection", { mode: "boolean" }).notNull().default(!1)
|
|
754
|
-
}),
|
|
754
|
+
}), at = w("email_providers", {
|
|
755
755
|
tenant_id: T("tenant_id", { length: 191 }).primaryKey(),
|
|
756
756
|
name: T("name", { length: 255 }).notNull(),
|
|
757
757
|
enabled: S("enabled", { mode: "boolean" }).notNull(),
|
|
@@ -760,7 +760,7 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
760
760
|
settings: T("settings", { length: 2048 }).notNull().default("{}"),
|
|
761
761
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
762
762
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
763
|
-
}),
|
|
763
|
+
}), ot = w("email_templates", {
|
|
764
764
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
765
765
|
template: T("template", { length: 64 }).notNull(),
|
|
766
766
|
body: T("body").notNull(),
|
|
@@ -773,7 +773,7 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
773
773
|
enabled: S("enabled", { mode: "boolean" }).notNull().default(!0),
|
|
774
774
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
775
775
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
776
|
-
}, (e) => [C({ columns: [e.tenant_id, e.template] })]),
|
|
776
|
+
}, (e) => [C({ columns: [e.tenant_id, e.template] })]), st = w("hooks", {
|
|
777
777
|
hook_id: T("hook_id", { length: 21 }).primaryKey(),
|
|
778
778
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
779
779
|
url: T("url", { length: 512 }),
|
|
@@ -789,14 +789,14 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
789
789
|
page_id: T("page_id", { length: 64 }),
|
|
790
790
|
permission_required: T("permission_required", { length: 255 }),
|
|
791
791
|
metadata: T("metadata")
|
|
792
|
-
}, (e) => [x("hooks_tenant_id_idx").on(e.tenant_id)]),
|
|
792
|
+
}, (e) => [x("hooks_tenant_id_idx").on(e.tenant_id)]), ct = w("hook_code", {
|
|
793
793
|
id: T("id", { length: 21 }).primaryKey(),
|
|
794
794
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
795
795
|
code: T("code").notNull(),
|
|
796
796
|
secrets: T("secrets"),
|
|
797
797
|
created_at_ts: S("created_at_ts").notNull(),
|
|
798
798
|
updated_at_ts: S("updated_at_ts").notNull()
|
|
799
|
-
}, (e) => [x("hook_code_tenant_id_idx").on(e.tenant_id)]),
|
|
799
|
+
}, (e) => [x("hook_code_tenant_id_idx").on(e.tenant_id)]), lt = w("keys", {
|
|
800
800
|
kid: T("kid", { length: 255 }).primaryKey(),
|
|
801
801
|
tenant_id: T("tenant_id", { length: 191 }).references(() => O.id, { onDelete: "cascade" }),
|
|
802
802
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
@@ -808,8 +808,8 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
808
808
|
current_since: T("current_since", { length: 35 }),
|
|
809
809
|
current_until: T("current_until", { length: 35 }),
|
|
810
810
|
type: T("type", { length: 50 }).notNull().default("jwt_signing"),
|
|
811
|
-
connection: T("connection", { length: 255 }).references(() =>
|
|
812
|
-
}),
|
|
811
|
+
connection: T("connection", { length: 255 }).references(() => z.id, { onDelete: "cascade" })
|
|
812
|
+
}), ut = w("custom_text", {
|
|
813
813
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
814
814
|
prompt: T("prompt", { length: 64 }).notNull(),
|
|
815
815
|
language: T("language", { length: 16 }).notNull(),
|
|
@@ -820,13 +820,13 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
820
820
|
e.tenant_id,
|
|
821
821
|
e.prompt,
|
|
822
822
|
e.language
|
|
823
|
-
] })]),
|
|
823
|
+
] })]), dt = w("prompt_partials", {
|
|
824
824
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
825
825
|
prompt: T("prompt", { length: 64 }).notNull(),
|
|
826
826
|
body: T("body").notNull(),
|
|
827
827
|
created_at_ts: S("created_at_ts").notNull(),
|
|
828
828
|
updated_at_ts: S("updated_at_ts").notNull()
|
|
829
|
-
}, (e) => [C({ columns: [e.tenant_id, e.prompt] })]),
|
|
829
|
+
}, (e) => [C({ columns: [e.tenant_id, e.prompt] })]), ft = w("authentication_methods", {
|
|
830
830
|
id: T("id", { length: 26 }).primaryKey(),
|
|
831
831
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
832
832
|
user_id: T("user_id", { length: 255 }).notNull(),
|
|
@@ -842,7 +842,7 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
842
842
|
confirmed: S("confirmed").notNull().default(0),
|
|
843
843
|
created_at_ts: S("created_at_ts").notNull(),
|
|
844
844
|
updated_at_ts: S("updated_at_ts").notNull()
|
|
845
|
-
}, (e) => [x("authentication_methods_tenant_user_idx").on(e.tenant_id, e.user_id), x("authentication_methods_credential_id_idx").on(e.credential_id)]),
|
|
845
|
+
}, (e) => [x("authentication_methods_tenant_user_idx").on(e.tenant_id, e.user_id), x("authentication_methods_credential_id_idx").on(e.credential_id)]), K = w("logs", {
|
|
846
846
|
log_id: T("log_id", { length: 21 }).primaryKey(),
|
|
847
847
|
category: T("category", { length: 255 }),
|
|
848
848
|
tenant_id: T("tenant_id", { length: 64 }),
|
|
@@ -877,7 +877,7 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
877
877
|
x("logs_tenant_id").on(e.tenant_id),
|
|
878
878
|
x("logs_date").on(e.date),
|
|
879
879
|
x("IDX_logs_tenant_date_type_user").on(e.tenant_id, e.date, e.type, e.user_id)
|
|
880
|
-
]),
|
|
880
|
+
]), q = w("outbox_events", {
|
|
881
881
|
id: T("id", { length: 26 }).primaryKey(),
|
|
882
882
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
883
883
|
event_type: T("event_type", { length: 64 }).notNull(),
|
|
@@ -899,7 +899,7 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
899
899
|
x("idx_outbox_events_processed_at").on(e.processed_at),
|
|
900
900
|
x("idx_outbox_events_claimed_by").on(e.claimed_by),
|
|
901
901
|
x("idx_outbox_events_tenant_dead_lettered").on(e.tenant_id, e.dead_lettered_at)
|
|
902
|
-
]),
|
|
902
|
+
]), J = w("proxy_routes", {
|
|
903
903
|
id: T("id", { length: 64 }).primaryKey(),
|
|
904
904
|
tenant_id: T("tenant_id", { length: 255 }).notNull(),
|
|
905
905
|
custom_domain_id: T("custom_domain_id", { length: 256 }).notNull(),
|
|
@@ -908,14 +908,14 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
908
908
|
handlers: T("handlers", { length: 16384 }).notNull().default("[]"),
|
|
909
909
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
910
910
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
911
|
-
}, (e) => [x("proxy_routes_tenant_id_idx").on(e.tenant_id), x("proxy_routes_custom_domain_id_idx").on(e.custom_domain_id)]),
|
|
911
|
+
}, (e) => [x("proxy_routes_tenant_id_idx").on(e.tenant_id), x("proxy_routes_custom_domain_id_idx").on(e.custom_domain_id)]), pt = w("scim_configurations", {
|
|
912
912
|
connection_id: T("connection_id", { length: 255 }).notNull(),
|
|
913
913
|
tenant_id: T("tenant_id", { length: 255 }).notNull(),
|
|
914
914
|
user_id_attribute: T("user_id_attribute", { length: 255 }).notNull().default("externalId"),
|
|
915
915
|
mapping: T("mapping", { length: 16384 }).notNull().default("[]"),
|
|
916
916
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
917
917
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
918
|
-
}, (e) => [C({ columns: [e.tenant_id, e.connection_id] })]),
|
|
918
|
+
}, (e) => [C({ columns: [e.tenant_id, e.connection_id] })]), Y = w("scim_tokens", {
|
|
919
919
|
token_id: T("token_id", { length: 64 }).notNull(),
|
|
920
920
|
tenant_id: T("tenant_id", { length: 255 }).notNull(),
|
|
921
921
|
connection_id: T("connection_id", { length: 255 }).notNull(),
|
|
@@ -928,7 +928,7 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
928
928
|
C({ columns: [e.tenant_id, e.token_id] }),
|
|
929
929
|
x("scim_tokens_tenant_connection_idx").on(e.tenant_id, e.connection_id),
|
|
930
930
|
re("scim_tokens_tenant_hash_idx").on(e.tenant_id, e.token_hash)
|
|
931
|
-
]),
|
|
931
|
+
]), mt = w("scim_external_ids", {
|
|
932
932
|
tenant_id: T("tenant_id", { length: 255 }).notNull(),
|
|
933
933
|
connection_id: T("connection_id", { length: 255 }).notNull(),
|
|
934
934
|
external_id: T("external_id", { length: 255 }).notNull(),
|
|
@@ -938,7 +938,7 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
938
938
|
e.tenant_id,
|
|
939
939
|
e.connection_id,
|
|
940
940
|
e.user_id
|
|
941
|
-
] }), re("scim_external_ids_connection_external_idx").on(e.tenant_id, e.connection_id, e.external_id)]),
|
|
941
|
+
] }), re("scim_external_ids_connection_external_idx").on(e.tenant_id, e.connection_id, e.external_id)]), ht = w("token_exchange_profiles", {
|
|
942
942
|
id: T("id", { length: 64 }).primaryKey(),
|
|
943
943
|
tenant_id: T("tenant_id", { length: 255 }).notNull(),
|
|
944
944
|
name: T("name", { length: 255 }).notNull(),
|
|
@@ -948,7 +948,7 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
948
948
|
jwt_verification: T("jwt_verification"),
|
|
949
949
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
950
950
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
951
|
-
}, (e) => [re("token_exchange_profiles_tenant_subject_token_type_idx").on(e.tenant_id, e.subject_token_type)]),
|
|
951
|
+
}, (e) => [re("token_exchange_profiles_tenant_subject_token_type_idx").on(e.tenant_id, e.subject_token_type)]), gt = w("log_streams", {
|
|
952
952
|
id: T("id", { length: 64 }).primaryKey(),
|
|
953
953
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
954
954
|
name: T("name", { length: 255 }).notNull(),
|
|
@@ -959,7 +959,7 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
959
959
|
is_priority: S("is_priority"),
|
|
960
960
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
961
961
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
962
|
-
}, (e) => [x("idx_log_streams_tenant_id").on(e.tenant_id)]),
|
|
962
|
+
}, (e) => [x("idx_log_streams_tenant_id").on(e.tenant_id)]), _t = w("migration_sources", {
|
|
963
963
|
id: T("id", { length: 64 }).primaryKey(),
|
|
964
964
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
965
965
|
name: T("name", { length: 255 }).notNull(),
|
|
@@ -969,64 +969,64 @@ var ze = Object.defineProperty, Be = (e, t) => {
|
|
|
969
969
|
credentials: T("credentials").notNull(),
|
|
970
970
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
971
971
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
972
|
-
}, (e) => [x("idx_migration_sources_tenant_id").on(e.tenant_id)]),
|
|
972
|
+
}, (e) => [x("idx_migration_sources_tenant_id").on(e.tenant_id)]), vt = /* @__PURE__ */ Be({
|
|
973
973
|
actionExecutions: () => He,
|
|
974
|
-
actionVersions: () =>
|
|
975
|
-
actions: () =>
|
|
974
|
+
actionVersions: () => Ve,
|
|
975
|
+
actions: () => k,
|
|
976
976
|
authenticationCodes: () => We,
|
|
977
|
-
authenticationMethods: () =>
|
|
978
|
-
branding: () =>
|
|
979
|
-
clientGrants: () =>
|
|
977
|
+
authenticationMethods: () => ft,
|
|
978
|
+
branding: () => $e,
|
|
979
|
+
clientGrants: () => qe,
|
|
980
980
|
clientRegistrationTokens: () => L,
|
|
981
981
|
clients: () => I,
|
|
982
982
|
codes: () => F,
|
|
983
|
-
connections: () =>
|
|
984
|
-
customDomains: () =>
|
|
985
|
-
customText: () =>
|
|
986
|
-
domains: () =>
|
|
987
|
-
emailProviders: () =>
|
|
988
|
-
emailTemplates: () =>
|
|
989
|
-
flows: () =>
|
|
990
|
-
forms: () =>
|
|
991
|
-
grants: () =>
|
|
992
|
-
hookCode: () =>
|
|
993
|
-
hooks: () =>
|
|
994
|
-
invites: () =>
|
|
995
|
-
keys: () =>
|
|
996
|
-
logStreams: () =>
|
|
983
|
+
connections: () => z,
|
|
984
|
+
customDomains: () => Je,
|
|
985
|
+
customText: () => ut,
|
|
986
|
+
domains: () => Ye,
|
|
987
|
+
emailProviders: () => at,
|
|
988
|
+
emailTemplates: () => ot,
|
|
989
|
+
flows: () => rt,
|
|
990
|
+
forms: () => nt,
|
|
991
|
+
grants: () => R,
|
|
992
|
+
hookCode: () => ct,
|
|
993
|
+
hooks: () => st,
|
|
994
|
+
invites: () => Xe,
|
|
995
|
+
keys: () => lt,
|
|
996
|
+
logStreams: () => gt,
|
|
997
997
|
loginSessions: () => P,
|
|
998
|
-
logs: () =>
|
|
999
|
-
migrationSources: () =>
|
|
1000
|
-
organizationConnections: () =>
|
|
1001
|
-
organizations: () =>
|
|
998
|
+
logs: () => K,
|
|
999
|
+
migrationSources: () => _t,
|
|
1000
|
+
organizationConnections: () => Ze,
|
|
1001
|
+
organizations: () => B,
|
|
1002
1002
|
otps: () => Ge,
|
|
1003
|
-
outboxEvents: () =>
|
|
1003
|
+
outboxEvents: () => q,
|
|
1004
1004
|
passwords: () => j,
|
|
1005
|
-
promptPartials: () =>
|
|
1006
|
-
promptSettings: () =>
|
|
1007
|
-
proxyRoutes: () =>
|
|
1005
|
+
promptPartials: () => dt,
|
|
1006
|
+
promptSettings: () => it,
|
|
1007
|
+
proxyRoutes: () => J,
|
|
1008
1008
|
refreshTokens: () => N,
|
|
1009
|
-
resourceServers: () =>
|
|
1010
|
-
rolePermissions: () =>
|
|
1011
|
-
roles: () =>
|
|
1012
|
-
scimConfigurations: () =>
|
|
1013
|
-
scimExternalIds: () =>
|
|
1014
|
-
scimTokens: () =>
|
|
1009
|
+
resourceServers: () => G,
|
|
1010
|
+
rolePermissions: () => U,
|
|
1011
|
+
roles: () => H,
|
|
1012
|
+
scimConfigurations: () => pt,
|
|
1013
|
+
scimExternalIds: () => mt,
|
|
1014
|
+
scimTokens: () => Y,
|
|
1015
1015
|
sessions: () => M,
|
|
1016
1016
|
tenants: () => O,
|
|
1017
|
-
themes: () =>
|
|
1017
|
+
themes: () => tt,
|
|
1018
1018
|
tickets: () => Ke,
|
|
1019
|
-
tokenExchangeProfiles: () =>
|
|
1020
|
-
universalLoginTemplates: () =>
|
|
1019
|
+
tokenExchangeProfiles: () => ht,
|
|
1020
|
+
universalLoginTemplates: () => et,
|
|
1021
1021
|
userActivity: () => Ue,
|
|
1022
|
-
userOrganizations: () =>
|
|
1023
|
-
userPermissions: () =>
|
|
1024
|
-
userRoles: () =>
|
|
1022
|
+
userOrganizations: () => V,
|
|
1023
|
+
userPermissions: () => Qe,
|
|
1024
|
+
userRoles: () => W,
|
|
1025
1025
|
users: () => A
|
|
1026
1026
|
});
|
|
1027
1027
|
//#endregion
|
|
1028
1028
|
//#region src/helpers/transform.ts
|
|
1029
|
-
function
|
|
1029
|
+
function X(e, t) {
|
|
1030
1030
|
if (e == null) return t;
|
|
1031
1031
|
if (typeof e == "string") try {
|
|
1032
1032
|
return JSON.parse(e);
|
|
@@ -1035,14 +1035,14 @@ function Z(e, t) {
|
|
|
1035
1035
|
}
|
|
1036
1036
|
return e;
|
|
1037
1037
|
}
|
|
1038
|
-
function
|
|
1038
|
+
function yt(e, t = "", n = {}) {
|
|
1039
1039
|
for (let r in e) if (Object.prototype.hasOwnProperty.call(e, r)) {
|
|
1040
1040
|
let i = t ? `${t}_${r}` : r, a = e[r];
|
|
1041
|
-
typeof a == "object" && a && !Array.isArray(a) ?
|
|
1041
|
+
typeof a == "object" && a && !Array.isArray(a) ? yt(a, i, n) : typeof a == "boolean" ? n[i] = +!!a : n[i] = a;
|
|
1042
1042
|
}
|
|
1043
1043
|
return n;
|
|
1044
1044
|
}
|
|
1045
|
-
function
|
|
1045
|
+
function bt(e, t) {
|
|
1046
1046
|
let n = {};
|
|
1047
1047
|
for (let [r, i] of Object.entries(e)) {
|
|
1048
1048
|
let e = t.find((e) => r.startsWith(`${e}_`));
|
|
@@ -1059,13 +1059,13 @@ function yt(e, t) {
|
|
|
1059
1059
|
}
|
|
1060
1060
|
//#endregion
|
|
1061
1061
|
//#region src/helpers/filter.ts
|
|
1062
|
-
function
|
|
1062
|
+
function xt(e) {
|
|
1063
1063
|
return typeof e == "object" && !!e && "coalesce" in e && "defaultValue" in e;
|
|
1064
1064
|
}
|
|
1065
|
-
function
|
|
1065
|
+
function St(e) {
|
|
1066
1066
|
return y`coalesce(${e.coalesce}, ${e.defaultValue})`;
|
|
1067
1067
|
}
|
|
1068
|
-
function
|
|
1068
|
+
function Ct(n, r, i, l = []) {
|
|
1069
1069
|
let ee = u(n, te) ? o(n) : n, b = new Set(l), ne = (e) => {
|
|
1070
1070
|
let t = Number(e);
|
|
1071
1071
|
return Number.isFinite(t) ? t : e;
|
|
@@ -1078,7 +1078,7 @@ function St(n, r, i, l = []) {
|
|
|
1078
1078
|
let [, r, i] = n;
|
|
1079
1079
|
if (!r || !i) return null;
|
|
1080
1080
|
let o = r.trim(), s = Le(i.replace(/^"(.*)"$/, "$1").trim()), c = ee[o];
|
|
1081
|
-
return
|
|
1081
|
+
return xt(c) ? a(St(c), ne(s)) : u(c, e) ? b.has(o) ? p(c, `%${s}%`) : a(c, s) : null;
|
|
1082
1082
|
}).filter((e) => e !== null);
|
|
1083
1083
|
return r.length === 0 ? null : r.length === 1 ? r[0] : t(...r) ?? null;
|
|
1084
1084
|
}).filter((e) => e !== null);
|
|
@@ -1101,12 +1101,12 @@ function St(n, r, i, l = []) {
|
|
|
1101
1101
|
};
|
|
1102
1102
|
}), C = [];
|
|
1103
1103
|
for (let { key: t, value: n, isNegation: r, isExistsQuery: o, operator: l } of S) if (t) {
|
|
1104
|
-
let i = ee[t], v =
|
|
1104
|
+
let i = ee[t], v = xt(i), te = v ? i.coalesce : u(i, e) ? i : void 0, x = v ? ne(n) : n;
|
|
1105
1105
|
if (!te) {
|
|
1106
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}`);
|
|
1107
1107
|
continue;
|
|
1108
1108
|
}
|
|
1109
|
-
let S = v ?
|
|
1109
|
+
let S = v ? St(i) : y`${te}`;
|
|
1110
1110
|
if (o) C.push(r ? f(te) : d(te));
|
|
1111
1111
|
else if (b.has(t) && l === "=") C.push(r ? _(te, `%${n}%`) : p(te, `%${n}%`));
|
|
1112
1112
|
else if (r) switch (l) {
|
|
@@ -1154,12 +1154,48 @@ function St(n, r, i, l = []) {
|
|
|
1154
1154
|
if (C.length !== 0) return C.length === 1 ? C[0] : t(...C);
|
|
1155
1155
|
}
|
|
1156
1156
|
//#endregion
|
|
1157
|
+
//#region src/helpers/paginate.ts
|
|
1158
|
+
function wt(e) {
|
|
1159
|
+
return e?.from !== void 0 || e?.take !== void 0;
|
|
1160
|
+
}
|
|
1161
|
+
function Z(e) {
|
|
1162
|
+
let t = e?.take, n = typeof t == "number" && Number.isFinite(t) ? Math.floor(t) : NaN;
|
|
1163
|
+
return n >= 1 ? n : 50;
|
|
1164
|
+
}
|
|
1165
|
+
function Tt(e) {
|
|
1166
|
+
let t = e.sortOrder === "asc" ? n : i;
|
|
1167
|
+
return [t(e.sortColumn), t(e.idColumn)];
|
|
1168
|
+
}
|
|
1169
|
+
function Et(e, t) {
|
|
1170
|
+
let n = e?.from ? ge(e.from) : null;
|
|
1171
|
+
if (!n) return;
|
|
1172
|
+
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" });
|
|
1173
|
+
if (n.s === void 0 || n.s === null) return t.sortOrder === "asc" ? s(t.idColumn, n.i) : m(t.idColumn, n.i);
|
|
1174
|
+
let r = t.sortOrder === "asc" ? y.raw(">") : y.raw("<");
|
|
1175
|
+
return y`(${t.sortColumn}, ${t.idColumn}) ${r} (${n.s}, ${n.i})`;
|
|
1176
|
+
}
|
|
1177
|
+
function Dt(e, t, n, r = "id", i) {
|
|
1178
|
+
let a = e.length > t, o = a ? e.slice(0, t) : e, s, c = o[o.length - 1];
|
|
1179
|
+
if (a && c) {
|
|
1180
|
+
let e = c[n];
|
|
1181
|
+
s = _e({
|
|
1182
|
+
s: typeof e == "string" || typeof e == "number" || e === null ? e : String(e),
|
|
1183
|
+
i: String(c[r]),
|
|
1184
|
+
...i !== void 0 && { k: i }
|
|
1185
|
+
});
|
|
1186
|
+
}
|
|
1187
|
+
return {
|
|
1188
|
+
rows: o,
|
|
1189
|
+
next: s
|
|
1190
|
+
};
|
|
1191
|
+
}
|
|
1192
|
+
//#endregion
|
|
1157
1193
|
//#region src/adapters/actions.ts
|
|
1158
|
-
function
|
|
1159
|
-
let t =
|
|
1194
|
+
function Ot(e) {
|
|
1195
|
+
let t = X(e);
|
|
1160
1196
|
return Array.isArray(t) ? t : [];
|
|
1161
1197
|
}
|
|
1162
|
-
function
|
|
1198
|
+
function kt(e) {
|
|
1163
1199
|
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;
|
|
1164
1200
|
return {
|
|
1165
1201
|
...f,
|
|
@@ -1167,20 +1203,20 @@ function wt(e) {
|
|
|
1167
1203
|
runtime: u ?? void 0,
|
|
1168
1204
|
status: d || "built",
|
|
1169
1205
|
deployed_at: r ? new Date(Number(r)).toISOString() : void 0,
|
|
1170
|
-
secrets:
|
|
1171
|
-
dependencies:
|
|
1172
|
-
supported_triggers:
|
|
1206
|
+
secrets: X(i),
|
|
1207
|
+
dependencies: X(a),
|
|
1208
|
+
supported_triggers: X(o),
|
|
1173
1209
|
is_system: !!s,
|
|
1174
1210
|
inherit: !!c,
|
|
1175
1211
|
created_at: new Date(Number(t)).toISOString(),
|
|
1176
1212
|
updated_at: new Date(Number(n)).toISOString()
|
|
1177
1213
|
};
|
|
1178
1214
|
}
|
|
1179
|
-
function
|
|
1215
|
+
function At(e) {
|
|
1180
1216
|
return {
|
|
1181
1217
|
async create(t, n) {
|
|
1182
1218
|
let r = Date.now(), i = `act_${b()}`;
|
|
1183
|
-
return await e.insert(
|
|
1219
|
+
return await e.insert(k).values({
|
|
1184
1220
|
id: i,
|
|
1185
1221
|
tenant_id: t,
|
|
1186
1222
|
name: n.name,
|
|
@@ -1211,28 +1247,43 @@ function Tt(e) {
|
|
|
1211
1247
|
};
|
|
1212
1248
|
},
|
|
1213
1249
|
async get(n, r) {
|
|
1214
|
-
let i = await e.select().from(
|
|
1215
|
-
return i ?
|
|
1250
|
+
let i = await e.select().from(k).where(t(a(k.tenant_id, n), a(k.id, r))).get();
|
|
1251
|
+
return i ? kt(i) : null;
|
|
1216
1252
|
},
|
|
1217
1253
|
async list(o, s = {}) {
|
|
1218
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s, p = [a(
|
|
1254
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s, p = [a(k.tenant_id, o)];
|
|
1219
1255
|
if (f) {
|
|
1220
|
-
let e =
|
|
1256
|
+
let e = Ct(k, f, ["name"]);
|
|
1221
1257
|
e && p.push(e);
|
|
1222
1258
|
}
|
|
1223
|
-
let m = t(...p)
|
|
1259
|
+
let m = t(...p);
|
|
1260
|
+
if (wt(s)) {
|
|
1261
|
+
let n = {
|
|
1262
|
+
sortColumn: k.created_at_ts,
|
|
1263
|
+
idColumn: k.id,
|
|
1264
|
+
sortOrder: "desc"
|
|
1265
|
+
}, r = Z(s), i = Et(s, n), { rows: a, next: o } = Dt(await e.select().from(k).where(i ? t(m, i) : m).orderBy(...Tt(n)).limit(r + 1), r, "created_at_ts", "id"), c = a.map(kt);
|
|
1266
|
+
return {
|
|
1267
|
+
actions: c,
|
|
1268
|
+
start: 0,
|
|
1269
|
+
limit: r,
|
|
1270
|
+
length: c.length,
|
|
1271
|
+
next: o
|
|
1272
|
+
};
|
|
1273
|
+
}
|
|
1274
|
+
let h = e.select().from(k).where(m).$dynamic();
|
|
1224
1275
|
if (d?.sort_by) {
|
|
1225
|
-
let e =
|
|
1276
|
+
let e = k[d.sort_by];
|
|
1226
1277
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
1227
1278
|
}
|
|
1228
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
1279
|
+
let g = (await h.offset(c * l).limit(l)).map(kt);
|
|
1229
1280
|
if (!u) return {
|
|
1230
1281
|
actions: g,
|
|
1231
1282
|
start: 0,
|
|
1232
1283
|
limit: 0,
|
|
1233
1284
|
length: 0
|
|
1234
1285
|
};
|
|
1235
|
-
let [_] = await e.select({ count: r() }).from(
|
|
1286
|
+
let [_] = await e.select({ count: r() }).from(k).where(m);
|
|
1236
1287
|
return {
|
|
1237
1288
|
actions: g,
|
|
1238
1289
|
start: c * l,
|
|
@@ -1243,7 +1294,7 @@ function Tt(e) {
|
|
|
1243
1294
|
async update(n, r, i) {
|
|
1244
1295
|
let o = { updated_at_ts: Date.now() };
|
|
1245
1296
|
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) {
|
|
1246
|
-
let s = await e.select({ secrets:
|
|
1297
|
+
let s = await e.select({ secrets: k.secrets }).from(k).where(t(a(k.tenant_id, n), a(k.id, r))).get(), c = new Map(Ot(s?.secrets).map((e) => [e.name, e])), l = i.secrets.map((e) => e.value === void 0 ? {
|
|
1247
1298
|
name: e.name,
|
|
1248
1299
|
value: c.get(e.name)?.value
|
|
1249
1300
|
} : e);
|
|
@@ -1253,17 +1304,17 @@ function Tt(e) {
|
|
|
1253
1304
|
let e = new Date(i.deployed_at).getTime();
|
|
1254
1305
|
Number.isFinite(e) && (o.deployed_at_ts = e);
|
|
1255
1306
|
}
|
|
1256
|
-
return i.is_system !== void 0 && (o.is_system = +!!i.is_system), i.inherit !== void 0 && (o.inherit = +!!i.inherit), (await e.update(
|
|
1307
|
+
return i.is_system !== void 0 && (o.is_system = +!!i.is_system), i.inherit !== void 0 && (o.inherit = +!!i.inherit), (await e.update(k).set(o).where(t(a(k.tenant_id, n), a(k.id, r))).returning()).length > 0;
|
|
1257
1308
|
},
|
|
1258
1309
|
async remove(n, r) {
|
|
1259
|
-
return (await e.delete(
|
|
1310
|
+
return (await e.delete(k).where(t(a(k.tenant_id, n), a(k.id, r))).returning()).length > 0;
|
|
1260
1311
|
}
|
|
1261
1312
|
};
|
|
1262
1313
|
}
|
|
1263
1314
|
//#endregion
|
|
1264
1315
|
//#region src/adapters/actionExecutions.ts
|
|
1265
|
-
var
|
|
1266
|
-
function
|
|
1316
|
+
var jt = 500;
|
|
1317
|
+
function Mt(e) {
|
|
1267
1318
|
return {
|
|
1268
1319
|
async create(t, n) {
|
|
1269
1320
|
let r = Date.now();
|
|
@@ -1294,8 +1345,8 @@ function Dt(e) {
|
|
|
1294
1345
|
tenant_id: i.tenant_id,
|
|
1295
1346
|
trigger_id: i.trigger_id,
|
|
1296
1347
|
status: i.status,
|
|
1297
|
-
results:
|
|
1298
|
-
logs:
|
|
1348
|
+
results: X(i.results) ?? [],
|
|
1349
|
+
logs: X(i.logs),
|
|
1299
1350
|
created_at: new Date(Number(i.created_at_ts)).toISOString(),
|
|
1300
1351
|
updated_at: new Date(Number(i.updated_at_ts)).toISOString()
|
|
1301
1352
|
} : null;
|
|
@@ -1305,8 +1356,8 @@ function Dt(e) {
|
|
|
1305
1356
|
if (Number.isNaN(n)) throw Error(`Invalid olderThan date: ${t}`);
|
|
1306
1357
|
let r = 0;
|
|
1307
1358
|
for (;;) {
|
|
1308
|
-
let t = await e.delete(He).where(y`rowid IN (SELECT rowid FROM ${He} WHERE ${He.created_at_ts} < ${n} LIMIT ${
|
|
1309
|
-
if (r += t.length, t.length <
|
|
1359
|
+
let t = await e.delete(He).where(y`rowid IN (SELECT rowid FROM ${He} WHERE ${He.created_at_ts} < ${n} LIMIT ${jt})`).returning({ id: He.id });
|
|
1360
|
+
if (r += t.length, t.length < jt) break;
|
|
1310
1361
|
}
|
|
1311
1362
|
return r;
|
|
1312
1363
|
}
|
|
@@ -1314,12 +1365,12 @@ function Dt(e) {
|
|
|
1314
1365
|
}
|
|
1315
1366
|
//#endregion
|
|
1316
1367
|
//#region src/adapters/atomic.ts
|
|
1317
|
-
function
|
|
1368
|
+
function Nt(e) {
|
|
1318
1369
|
let t = e;
|
|
1319
1370
|
return typeof t == "object" && !!t && "batch" in t && typeof t.batch == "function";
|
|
1320
1371
|
}
|
|
1321
|
-
async function
|
|
1322
|
-
if (
|
|
1372
|
+
async function Pt(e, t) {
|
|
1373
|
+
if (Nt(e)) return e.batch(t);
|
|
1323
1374
|
await e.run(y`BEGIN`);
|
|
1324
1375
|
try {
|
|
1325
1376
|
let n = [];
|
|
@@ -1336,23 +1387,23 @@ async function kt(e, t) {
|
|
|
1336
1387
|
}
|
|
1337
1388
|
//#endregion
|
|
1338
1389
|
//#region src/adapters/actionVersions.ts
|
|
1339
|
-
function
|
|
1390
|
+
function Ft(e) {
|
|
1340
1391
|
let { created_at_ts: t, updated_at_ts: n, secrets: r, dependencies: i, supported_triggers: a, deployed: o, runtime: s, ...c } = e;
|
|
1341
1392
|
return {
|
|
1342
1393
|
...c,
|
|
1343
1394
|
runtime: s ?? void 0,
|
|
1344
1395
|
deployed: !!o,
|
|
1345
|
-
secrets:
|
|
1346
|
-
dependencies:
|
|
1347
|
-
supported_triggers:
|
|
1396
|
+
secrets: X(r),
|
|
1397
|
+
dependencies: X(i),
|
|
1398
|
+
supported_triggers: X(a),
|
|
1348
1399
|
created_at: new Date(Number(t)).toISOString(),
|
|
1349
1400
|
updated_at: new Date(Number(n)).toISOString()
|
|
1350
1401
|
};
|
|
1351
1402
|
}
|
|
1352
|
-
function
|
|
1403
|
+
function It(e) {
|
|
1353
1404
|
return {
|
|
1354
1405
|
async create(n, r) {
|
|
1355
|
-
let o = Date.now(), s = `ver_${b()}`, c = r.deployed !== !1, l = ((await e.select({ number:
|
|
1406
|
+
let o = Date.now(), s = `ver_${b()}`, c = r.deployed !== !1, l = ((await e.select({ number: Ve.number }).from(Ve).where(t(a(Ve.tenant_id, n), a(Ve.action_id, r.action_id))).orderBy(i(Ve.number)).limit(1).get())?.number ?? 0) + 1, u = e.insert(Ve).values({
|
|
1356
1407
|
id: s,
|
|
1357
1408
|
tenant_id: n,
|
|
1358
1409
|
action_id: r.action_id,
|
|
@@ -1366,10 +1417,10 @@ function jt(e) {
|
|
|
1366
1417
|
created_at_ts: o,
|
|
1367
1418
|
updated_at_ts: o
|
|
1368
1419
|
});
|
|
1369
|
-
return await
|
|
1420
|
+
return await Pt(e, c ? [e.update(Ve).set({
|
|
1370
1421
|
deployed: 0,
|
|
1371
1422
|
updated_at_ts: o
|
|
1372
|
-
}).where(t(a(
|
|
1423
|
+
}).where(t(a(Ve.tenant_id, n), a(Ve.action_id, r.action_id), a(Ve.deployed, 1))), u] : [u]), {
|
|
1373
1424
|
id: s,
|
|
1374
1425
|
tenant_id: n,
|
|
1375
1426
|
action_id: r.action_id,
|
|
@@ -1385,18 +1436,18 @@ function jt(e) {
|
|
|
1385
1436
|
};
|
|
1386
1437
|
},
|
|
1387
1438
|
async get(n, r, i) {
|
|
1388
|
-
let o = await e.select().from(
|
|
1389
|
-
return o ?
|
|
1439
|
+
let o = await e.select().from(Ve).where(t(a(Ve.tenant_id, n), a(Ve.action_id, r), a(Ve.id, i))).get();
|
|
1440
|
+
return o ? Ft(o) : null;
|
|
1390
1441
|
},
|
|
1391
1442
|
async list(n, o, s = {}) {
|
|
1392
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1 } = s, d = t(a(
|
|
1443
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1 } = s, d = t(a(Ve.tenant_id, n), a(Ve.action_id, o)), f = (await e.select().from(Ve).where(d).orderBy(i(Ve.number)).offset(c * l).limit(l)).map(Ft);
|
|
1393
1444
|
if (!u) return {
|
|
1394
1445
|
versions: f,
|
|
1395
1446
|
start: 0,
|
|
1396
1447
|
limit: 0,
|
|
1397
1448
|
length: 0
|
|
1398
1449
|
};
|
|
1399
|
-
let [p] = await e.select({ count: r() }).from(
|
|
1450
|
+
let [p] = await e.select({ count: r() }).from(Ve).where(d);
|
|
1400
1451
|
return {
|
|
1401
1452
|
versions: f,
|
|
1402
1453
|
start: c * l,
|
|
@@ -1405,19 +1456,19 @@ function jt(e) {
|
|
|
1405
1456
|
};
|
|
1406
1457
|
},
|
|
1407
1458
|
async removeForAction(n, r) {
|
|
1408
|
-
return (await e.delete(
|
|
1459
|
+
return (await e.delete(Ve).where(t(a(Ve.tenant_id, n), a(Ve.action_id, r))).returning()).length;
|
|
1409
1460
|
}
|
|
1410
1461
|
};
|
|
1411
1462
|
}
|
|
1412
1463
|
//#endregion
|
|
1413
1464
|
//#region src/adapters/branding.ts
|
|
1414
|
-
function
|
|
1465
|
+
function Lt(e) {
|
|
1415
1466
|
return e === "dark" || e === "light" || e === "auto";
|
|
1416
1467
|
}
|
|
1417
|
-
function
|
|
1468
|
+
function Rt(e) {
|
|
1418
1469
|
return {
|
|
1419
1470
|
async get(t) {
|
|
1420
|
-
let n = await e.select().from(
|
|
1471
|
+
let n = await e.select().from($e).where(a($e.tenant_id, t)).get();
|
|
1421
1472
|
if (!n) return null;
|
|
1422
1473
|
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;
|
|
1423
1474
|
return D({
|
|
@@ -1432,7 +1483,7 @@ function Nt(e) {
|
|
|
1432
1483
|
}
|
|
1433
1484
|
},
|
|
1434
1485
|
font: u ? { url: u } : void 0,
|
|
1435
|
-
dark_mode:
|
|
1486
|
+
dark_mode: Lt(d) ? d : void 0
|
|
1436
1487
|
});
|
|
1437
1488
|
},
|
|
1438
1489
|
async set(t, n) {
|
|
@@ -1446,53 +1497,17 @@ function Nt(e) {
|
|
|
1446
1497
|
font_url: i?.url,
|
|
1447
1498
|
dark_mode: a
|
|
1448
1499
|
};
|
|
1449
|
-
await e.insert(
|
|
1500
|
+
await e.insert($e).values({
|
|
1450
1501
|
tenant_id: t,
|
|
1451
1502
|
...l
|
|
1452
1503
|
}).onConflictDoUpdate({
|
|
1453
|
-
target:
|
|
1504
|
+
target: $e.tenant_id,
|
|
1454
1505
|
set: l
|
|
1455
1506
|
});
|
|
1456
1507
|
}
|
|
1457
1508
|
};
|
|
1458
1509
|
}
|
|
1459
1510
|
//#endregion
|
|
1460
|
-
//#region src/helpers/paginate.ts
|
|
1461
|
-
function Pt(e) {
|
|
1462
|
-
return e?.from !== void 0 || e?.take !== void 0;
|
|
1463
|
-
}
|
|
1464
|
-
function Ft(e) {
|
|
1465
|
-
let t = e?.take, n = typeof t == "number" && Number.isFinite(t) ? Math.floor(t) : NaN;
|
|
1466
|
-
return n >= 1 ? n : 50;
|
|
1467
|
-
}
|
|
1468
|
-
function It(e) {
|
|
1469
|
-
let t = e.sortOrder === "asc" ? n : i;
|
|
1470
|
-
return [t(e.sortColumn), t(e.idColumn)];
|
|
1471
|
-
}
|
|
1472
|
-
function Lt(e, t) {
|
|
1473
|
-
let n = e?.from ? ge(e.from) : null;
|
|
1474
|
-
if (!n) return;
|
|
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" });
|
|
1476
|
-
if (n.s === void 0 || n.s === null) return t.sortOrder === "asc" ? s(t.idColumn, n.i) : m(t.idColumn, n.i);
|
|
1477
|
-
let r = t.sortOrder === "asc" ? y.raw(">") : y.raw("<");
|
|
1478
|
-
return y`(${t.sortColumn}, ${t.idColumn}) ${r} (${n.s}, ${n.i})`;
|
|
1479
|
-
}
|
|
1480
|
-
function Rt(e, t, n, r = "id", i) {
|
|
1481
|
-
let a = e.length > t, o = a ? e.slice(0, t) : e, s, c = o[o.length - 1];
|
|
1482
|
-
if (a && c) {
|
|
1483
|
-
let e = c[n];
|
|
1484
|
-
s = _e({
|
|
1485
|
-
s: typeof e == "string" || typeof e == "number" || e === null ? e : String(e),
|
|
1486
|
-
i: String(c[r]),
|
|
1487
|
-
...i !== void 0 && { k: i }
|
|
1488
|
-
});
|
|
1489
|
-
}
|
|
1490
|
-
return {
|
|
1491
|
-
rows: o,
|
|
1492
|
-
next: s
|
|
1493
|
-
};
|
|
1494
|
-
}
|
|
1495
|
-
//#endregion
|
|
1496
1511
|
//#region src/adapters/clients.ts
|
|
1497
1512
|
var zt = [
|
|
1498
1513
|
"global",
|
|
@@ -1535,9 +1550,9 @@ var zt = [
|
|
|
1535
1550
|
function Ht(e) {
|
|
1536
1551
|
let { tenant_id: t, connections: n, ...r } = e, i = { ...r };
|
|
1537
1552
|
for (let e of zt) i[e] = !!r[e];
|
|
1538
|
-
for (let e of Bt) i[e] =
|
|
1539
|
-
for (let e of Vt) i[e] =
|
|
1540
|
-
return i.connections =
|
|
1553
|
+
for (let e of Bt) i[e] = X(r[e], []);
|
|
1554
|
+
for (let e of Vt) i[e] = X(r[e], {});
|
|
1555
|
+
return i.connections = X(n, []), D(i);
|
|
1541
1556
|
}
|
|
1542
1557
|
function Ut(e) {
|
|
1543
1558
|
let t = { ...e };
|
|
@@ -1608,13 +1623,13 @@ function Wt(e) {
|
|
|
1608
1623
|
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;
|
|
1609
1624
|
},
|
|
1610
1625
|
async list(o, s) {
|
|
1611
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
1612
|
-
if (
|
|
1626
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? Ct(I, f, ["name", "client_id"]) : void 0, m = p ? t(a(I.tenant_id, o), p) : a(I.tenant_id, o);
|
|
1627
|
+
if (wt(s)) {
|
|
1613
1628
|
let n = {
|
|
1614
1629
|
sortColumn: I.created_at,
|
|
1615
1630
|
idColumn: I.client_id,
|
|
1616
1631
|
sortOrder: "desc"
|
|
1617
|
-
}, r =
|
|
1632
|
+
}, r = Et(s, n), i = Z(s), { rows: a, next: o } = Dt(await e.select().from(I).where(r ? t(m, r) : m).orderBy(...Tt(n)).limit(i + 1), i, "created_at", "client_id"), c = a.map(Ht);
|
|
1618
1633
|
return {
|
|
1619
1634
|
clients: c,
|
|
1620
1635
|
totals: {
|
|
@@ -1654,8 +1669,8 @@ function Gt(e) {
|
|
|
1654
1669
|
let { tenant_id: t, is_system: n, options: r, metadata: i, ...a } = e;
|
|
1655
1670
|
return D({
|
|
1656
1671
|
...a,
|
|
1657
|
-
options:
|
|
1658
|
-
metadata:
|
|
1672
|
+
options: X(r, {}),
|
|
1673
|
+
metadata: X(i),
|
|
1659
1674
|
is_system: n ? !0 : void 0
|
|
1660
1675
|
});
|
|
1661
1676
|
}
|
|
@@ -1664,9 +1679,9 @@ function Kt(e) {
|
|
|
1664
1679
|
async listByClient(n, r) {
|
|
1665
1680
|
let i = await e.select({ connections: I.connections }).from(I).where(t(a(I.tenant_id, n), a(I.client_id, r))).get();
|
|
1666
1681
|
if (!i) return [];
|
|
1667
|
-
let o =
|
|
1682
|
+
let o = X(i.connections, []) || [];
|
|
1668
1683
|
if (o.length === 0) return [];
|
|
1669
|
-
let s = (await e.select().from(
|
|
1684
|
+
let s = (await e.select().from(z).where(t(a(z.tenant_id, n), l(z.id, o))).all()).map(Gt);
|
|
1670
1685
|
return o.map((e) => s.find((t) => t.id === e)).filter(Boolean);
|
|
1671
1686
|
},
|
|
1672
1687
|
async updateByClient(n, r, i) {
|
|
@@ -1676,7 +1691,7 @@ function Kt(e) {
|
|
|
1676
1691
|
return (await e.select({
|
|
1677
1692
|
client_id: I.client_id,
|
|
1678
1693
|
connections: I.connections
|
|
1679
|
-
}).from(I).where(a(I.tenant_id, t)).all()).filter((e) => (
|
|
1694
|
+
}).from(I).where(a(I.tenant_id, t)).all()).filter((e) => (X(e.connections, []) || []).includes(n)).map((e) => e.client_id);
|
|
1680
1695
|
},
|
|
1681
1696
|
async addClientToConnection(n, r, i) {
|
|
1682
1697
|
if (!await e.select({ client_id: I.client_id }).from(I).where(t(a(I.tenant_id, n), a(I.client_id, i))).get()) return !1;
|
|
@@ -1707,8 +1722,8 @@ function qt(e) {
|
|
|
1707
1722
|
let { tenant_id: t, scope: n, authorization_details_types: r, allow_any_organization: i, is_system: a, ...o } = e;
|
|
1708
1723
|
return D({
|
|
1709
1724
|
...o,
|
|
1710
|
-
scope:
|
|
1711
|
-
authorization_details_types:
|
|
1725
|
+
scope: X(n, []),
|
|
1726
|
+
authorization_details_types: X(r, []),
|
|
1712
1727
|
allow_any_organization: !!i,
|
|
1713
1728
|
is_system: !!a
|
|
1714
1729
|
});
|
|
@@ -1730,13 +1745,13 @@ function Jt(e) {
|
|
|
1730
1745
|
created_at: r,
|
|
1731
1746
|
updated_at: r
|
|
1732
1747
|
};
|
|
1733
|
-
return await e.insert(
|
|
1748
|
+
return await e.insert(qe).values(i), qt({
|
|
1734
1749
|
...i,
|
|
1735
1750
|
tenant_id: t
|
|
1736
1751
|
});
|
|
1737
1752
|
},
|
|
1738
1753
|
async get(n, r) {
|
|
1739
|
-
let i = await e.select().from(
|
|
1754
|
+
let i = await e.select().from(qe).where(t(a(qe.tenant_id, n), a(qe.id, r))).get();
|
|
1740
1755
|
return i ? qt(i) : null;
|
|
1741
1756
|
},
|
|
1742
1757
|
async update(n, r, i) {
|
|
@@ -1744,16 +1759,16 @@ function Jt(e) {
|
|
|
1744
1759
|
...u,
|
|
1745
1760
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
1746
1761
|
};
|
|
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(
|
|
1762
|
+
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(qe).set(d).where(t(a(qe.tenant_id, n), a(qe.id, r))).returning()).length > 0;
|
|
1748
1763
|
},
|
|
1749
1764
|
async list(o, s) {
|
|
1750
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
1751
|
-
if (
|
|
1765
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? Ct(qe, f, ["client_id", "audience"]) : void 0, m = p ? t(a(qe.tenant_id, o), p) : a(qe.tenant_id, o);
|
|
1766
|
+
if (wt(s)) {
|
|
1752
1767
|
let n = {
|
|
1753
|
-
sortColumn:
|
|
1754
|
-
idColumn:
|
|
1768
|
+
sortColumn: qe.created_at,
|
|
1769
|
+
idColumn: qe.id,
|
|
1755
1770
|
sortOrder: "desc"
|
|
1756
|
-
}, r =
|
|
1771
|
+
}, r = Et(s, n), i = Z(s), { rows: a, next: o } = Dt(await e.select().from(qe).where(r ? t(m, r) : m).orderBy(...Tt(n)).limit(i + 1), i, "created_at"), c = a.map(qt);
|
|
1757
1772
|
return {
|
|
1758
1773
|
client_grants: c,
|
|
1759
1774
|
start: 0,
|
|
@@ -1762,14 +1777,14 @@ function Jt(e) {
|
|
|
1762
1777
|
next: o
|
|
1763
1778
|
};
|
|
1764
1779
|
}
|
|
1765
|
-
let h = e.select().from(
|
|
1780
|
+
let h = e.select().from(qe).where(m).$dynamic();
|
|
1766
1781
|
if (d?.sort_by) {
|
|
1767
|
-
let e =
|
|
1782
|
+
let e = qe[d.sort_by];
|
|
1768
1783
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
1769
|
-
} else h = h.orderBy(i(
|
|
1784
|
+
} else h = h.orderBy(i(qe.created_at), i(qe.id));
|
|
1770
1785
|
let g = (await h.offset(c * l).limit(l)).map(qt);
|
|
1771
1786
|
if (!u) return { client_grants: g };
|
|
1772
|
-
let [_] = await e.select({ count: r() }).from(
|
|
1787
|
+
let [_] = await e.select({ count: r() }).from(qe).where(m);
|
|
1773
1788
|
return {
|
|
1774
1789
|
client_grants: g,
|
|
1775
1790
|
start: c * l,
|
|
@@ -1778,7 +1793,7 @@ function Jt(e) {
|
|
|
1778
1793
|
};
|
|
1779
1794
|
},
|
|
1780
1795
|
async remove(n, r) {
|
|
1781
|
-
return (await e.delete(
|
|
1796
|
+
return (await e.delete(qe).where(t(a(qe.tenant_id, n), a(qe.id, r))).returning()).length > 0;
|
|
1782
1797
|
}
|
|
1783
1798
|
};
|
|
1784
1799
|
}
|
|
@@ -1892,7 +1907,7 @@ function rn(e) {
|
|
|
1892
1907
|
if (f) {
|
|
1893
1908
|
let e = Ee(f, en);
|
|
1894
1909
|
if (e) {
|
|
1895
|
-
let t =
|
|
1910
|
+
let t = Ct(F, e, en);
|
|
1896
1911
|
t && p.push(t);
|
|
1897
1912
|
}
|
|
1898
1913
|
}
|
|
@@ -1939,8 +1954,8 @@ function on(e) {
|
|
|
1939
1954
|
let { tenant_id: t, is_system: n, options: r, metadata: i, ...a } = e;
|
|
1940
1955
|
return D({
|
|
1941
1956
|
...a,
|
|
1942
|
-
options:
|
|
1943
|
-
metadata:
|
|
1957
|
+
options: X(r, {}),
|
|
1958
|
+
metadata: X(i),
|
|
1944
1959
|
is_system: n ? !0 : void 0
|
|
1945
1960
|
});
|
|
1946
1961
|
}
|
|
@@ -1958,32 +1973,32 @@ function sn(e) {
|
|
|
1958
1973
|
updated_at: r
|
|
1959
1974
|
};
|
|
1960
1975
|
try {
|
|
1961
|
-
await e.insert(
|
|
1976
|
+
await e.insert(z).values(i);
|
|
1962
1977
|
} catch (e) {
|
|
1963
1978
|
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new Re(409, { message: "Connection already exists" }) : e;
|
|
1964
1979
|
}
|
|
1965
1980
|
return on(i);
|
|
1966
1981
|
},
|
|
1967
1982
|
async get(n, r) {
|
|
1968
|
-
let i = await e.select().from(
|
|
1983
|
+
let i = await e.select().from(z).where(t(a(z.tenant_id, n), a(z.id, r))).get();
|
|
1969
1984
|
return i ? on(i) : null;
|
|
1970
1985
|
},
|
|
1971
1986
|
async update(n, r, i) {
|
|
1972
1987
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
1973
|
-
return i.name !== void 0 && (o.name = i.name), i.strategy !== void 0 && (o.strategy = i.strategy), i.options !== void 0 && (o.options = JSON.stringify(i.options)), i.metadata !== void 0 && (o.metadata = JSON.stringify(i.metadata)), i.display_name !== void 0 && (o.display_name = i.display_name), i.response_type !== void 0 && (o.response_type = i.response_type), i.response_mode !== void 0 && (o.response_mode = i.response_mode), await e.update(
|
|
1988
|
+
return i.name !== void 0 && (o.name = i.name), i.strategy !== void 0 && (o.strategy = i.strategy), i.options !== void 0 && (o.options = JSON.stringify(i.options)), i.metadata !== void 0 && (o.metadata = JSON.stringify(i.metadata)), i.display_name !== void 0 && (o.display_name = i.display_name), i.response_type !== void 0 && (o.response_type = i.response_type), i.response_mode !== void 0 && (o.response_mode = i.response_mode), await e.update(z).set(o).where(t(a(z.tenant_id, n), a(z.id, r))), !0;
|
|
1974
1989
|
},
|
|
1975
1990
|
async list(o, s) {
|
|
1976
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = a(
|
|
1991
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = a(z.tenant_id, o);
|
|
1977
1992
|
if (f) {
|
|
1978
|
-
let e =
|
|
1993
|
+
let e = Ct(z, f, ["name"]);
|
|
1979
1994
|
e && (p = t(p, e));
|
|
1980
1995
|
}
|
|
1981
|
-
if (
|
|
1996
|
+
if (wt(s)) {
|
|
1982
1997
|
let n = {
|
|
1983
|
-
sortColumn:
|
|
1984
|
-
idColumn:
|
|
1998
|
+
sortColumn: z.created_at,
|
|
1999
|
+
idColumn: z.id,
|
|
1985
2000
|
sortOrder: "desc"
|
|
1986
|
-
}, r =
|
|
2001
|
+
}, r = Et(s, n), i = Z(s), { rows: a, next: o } = Dt(await e.select().from(z).where(r ? t(p, r) : p).orderBy(...Tt(n)).limit(i + 1), i, "created_at", "id"), c = a.map(on);
|
|
1987
2002
|
return {
|
|
1988
2003
|
connections: c,
|
|
1989
2004
|
start: 0,
|
|
@@ -1992,14 +2007,14 @@ function sn(e) {
|
|
|
1992
2007
|
next: o
|
|
1993
2008
|
};
|
|
1994
2009
|
}
|
|
1995
|
-
let m = e.select().from(
|
|
2010
|
+
let m = e.select().from(z).where(p).$dynamic();
|
|
1996
2011
|
if (d?.sort_by) {
|
|
1997
|
-
let e =
|
|
2012
|
+
let e = z[d.sort_by];
|
|
1998
2013
|
e && (m = m.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
1999
2014
|
}
|
|
2000
2015
|
let h = (await m.offset(c * l).limit(l)).map(on);
|
|
2001
2016
|
if (!u) return { connections: h };
|
|
2002
|
-
let [g] = await e.select({ count: r() }).from(
|
|
2017
|
+
let [g] = await e.select({ count: r() }).from(z).where(p);
|
|
2003
2018
|
return {
|
|
2004
2019
|
connections: h,
|
|
2005
2020
|
start: c * l,
|
|
@@ -2008,7 +2023,7 @@ function sn(e) {
|
|
|
2008
2023
|
};
|
|
2009
2024
|
},
|
|
2010
2025
|
async remove(n, r) {
|
|
2011
|
-
return (await e.delete(
|
|
2026
|
+
return (await e.delete(z).where(t(a(z.tenant_id, n), a(z.id, r))).returning()).length > 0;
|
|
2012
2027
|
}
|
|
2013
2028
|
};
|
|
2014
2029
|
}
|
|
@@ -2019,8 +2034,8 @@ function cn(e) {
|
|
|
2019
2034
|
return D({
|
|
2020
2035
|
...i,
|
|
2021
2036
|
primary: !!i.primary,
|
|
2022
|
-
domain_metadata:
|
|
2023
|
-
verification:
|
|
2037
|
+
domain_metadata: X(n),
|
|
2038
|
+
verification: X(r)
|
|
2024
2039
|
});
|
|
2025
2040
|
}
|
|
2026
2041
|
function ln(e) {
|
|
@@ -2041,31 +2056,31 @@ function ln(e) {
|
|
|
2041
2056
|
created_at: r,
|
|
2042
2057
|
updated_at: r
|
|
2043
2058
|
};
|
|
2044
|
-
return await e.insert(
|
|
2059
|
+
return await e.insert(Je).values(i), cn({
|
|
2045
2060
|
...i,
|
|
2046
2061
|
tenant_id: t
|
|
2047
2062
|
});
|
|
2048
2063
|
},
|
|
2049
2064
|
async get(n, r) {
|
|
2050
|
-
let i = await e.select().from(
|
|
2065
|
+
let i = await e.select().from(Je).where(t(a(Je.tenant_id, n), a(Je.custom_domain_id, r))).get();
|
|
2051
2066
|
return i ? cn(i) : null;
|
|
2052
2067
|
},
|
|
2053
2068
|
async getByDomain(t) {
|
|
2054
|
-
let n = await e.select().from(
|
|
2069
|
+
let n = await e.select().from(Je).where(a(Je.domain, t)).get();
|
|
2055
2070
|
return n ? {
|
|
2056
2071
|
...cn(n),
|
|
2057
2072
|
tenant_id: n.tenant_id
|
|
2058
2073
|
} : null;
|
|
2059
2074
|
},
|
|
2060
2075
|
async list(t) {
|
|
2061
|
-
return (await e.select().from(
|
|
2076
|
+
return (await e.select().from(Je).where(a(Je.tenant_id, t)).all()).map(cn);
|
|
2062
2077
|
},
|
|
2063
2078
|
async update(n, r, i) {
|
|
2064
2079
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
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(
|
|
2080
|
+
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(Je).set(o).where(t(a(Je.tenant_id, n), a(Je.custom_domain_id, r))).returning()).length > 0;
|
|
2066
2081
|
},
|
|
2067
2082
|
async remove(n, r) {
|
|
2068
|
-
return (await e.delete(
|
|
2083
|
+
return (await e.delete(Je).where(t(a(Je.tenant_id, n), a(Je.custom_domain_id, r))).returning()).length > 0;
|
|
2069
2084
|
}
|
|
2070
2085
|
};
|
|
2071
2086
|
}
|
|
@@ -2074,7 +2089,7 @@ function ln(e) {
|
|
|
2074
2089
|
function un(e) {
|
|
2075
2090
|
return {
|
|
2076
2091
|
async get(n, r, i) {
|
|
2077
|
-
let o = await e.select().from(
|
|
2092
|
+
let o = await e.select().from(ut).where(t(a(ut.tenant_id, n), a(ut.prompt, r), a(ut.language, i))).get();
|
|
2078
2093
|
if (!o) return null;
|
|
2079
2094
|
try {
|
|
2080
2095
|
return JSON.parse(o.custom_text);
|
|
@@ -2084,7 +2099,7 @@ function un(e) {
|
|
|
2084
2099
|
},
|
|
2085
2100
|
async set(t, n, r, i) {
|
|
2086
2101
|
let a = Date.now(), o = JSON.stringify(i);
|
|
2087
|
-
await e.insert(
|
|
2102
|
+
await e.insert(ut).values({
|
|
2088
2103
|
tenant_id: t,
|
|
2089
2104
|
prompt: n,
|
|
2090
2105
|
language: r,
|
|
@@ -2093,9 +2108,9 @@ function un(e) {
|
|
|
2093
2108
|
updated_at_ts: a
|
|
2094
2109
|
}).onConflictDoUpdate({
|
|
2095
2110
|
target: [
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2111
|
+
ut.tenant_id,
|
|
2112
|
+
ut.prompt,
|
|
2113
|
+
ut.language
|
|
2099
2114
|
],
|
|
2100
2115
|
set: {
|
|
2101
2116
|
custom_text: o,
|
|
@@ -2104,13 +2119,13 @@ function un(e) {
|
|
|
2104
2119
|
});
|
|
2105
2120
|
},
|
|
2106
2121
|
async delete(n, r, i) {
|
|
2107
|
-
await e.delete(
|
|
2122
|
+
await e.delete(ut).where(t(a(ut.tenant_id, n), a(ut.prompt, r), a(ut.language, i)));
|
|
2108
2123
|
},
|
|
2109
2124
|
async list(t) {
|
|
2110
2125
|
return await e.select({
|
|
2111
|
-
prompt:
|
|
2112
|
-
language:
|
|
2113
|
-
}).from(
|
|
2126
|
+
prompt: ut.prompt,
|
|
2127
|
+
language: ut.language
|
|
2128
|
+
}).from(ut).where(a(ut.tenant_id, t)).all();
|
|
2114
2129
|
}
|
|
2115
2130
|
};
|
|
2116
2131
|
}
|
|
@@ -2120,7 +2135,7 @@ function dn(e) {
|
|
|
2120
2135
|
return {
|
|
2121
2136
|
async create(t, n) {
|
|
2122
2137
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
2123
|
-
await e.insert(
|
|
2138
|
+
await e.insert(at).values({
|
|
2124
2139
|
tenant_id: t,
|
|
2125
2140
|
name: n.name,
|
|
2126
2141
|
enabled: n.enabled,
|
|
@@ -2132,22 +2147,22 @@ function dn(e) {
|
|
|
2132
2147
|
});
|
|
2133
2148
|
},
|
|
2134
2149
|
async get(t) {
|
|
2135
|
-
let n = await e.select().from(
|
|
2150
|
+
let n = await e.select().from(at).where(a(at.tenant_id, t)).get();
|
|
2136
2151
|
if (!n) return null;
|
|
2137
2152
|
let { tenant_id: r, ...i } = n;
|
|
2138
2153
|
return D({
|
|
2139
2154
|
...i,
|
|
2140
2155
|
enabled: !!i.enabled,
|
|
2141
|
-
credentials:
|
|
2142
|
-
settings:
|
|
2156
|
+
credentials: X(i.credentials, {}),
|
|
2157
|
+
settings: X(i.settings, {})
|
|
2143
2158
|
});
|
|
2144
2159
|
},
|
|
2145
2160
|
async update(t, n) {
|
|
2146
2161
|
let r = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
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(
|
|
2162
|
+
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(at).set(r).where(a(at.tenant_id, t));
|
|
2148
2163
|
},
|
|
2149
2164
|
async remove(t) {
|
|
2150
|
-
await e.delete(
|
|
2165
|
+
await e.delete(at).where(a(at.tenant_id, t));
|
|
2151
2166
|
}
|
|
2152
2167
|
};
|
|
2153
2168
|
}
|
|
@@ -2169,15 +2184,15 @@ function fn(e) {
|
|
|
2169
2184
|
function pn(e) {
|
|
2170
2185
|
return {
|
|
2171
2186
|
async get(n, r) {
|
|
2172
|
-
let i = await e.select().from(
|
|
2187
|
+
let i = await e.select().from(ot).where(t(a(ot.tenant_id, n), a(ot.template, r))).get();
|
|
2173
2188
|
return i ? fn(i) : null;
|
|
2174
2189
|
},
|
|
2175
2190
|
async list(t) {
|
|
2176
|
-
return (await e.select().from(
|
|
2191
|
+
return (await e.select().from(ot).where(a(ot.tenant_id, t)).all()).map(fn);
|
|
2177
2192
|
},
|
|
2178
2193
|
async create(t, n) {
|
|
2179
2194
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
2180
|
-
return await e.insert(
|
|
2195
|
+
return await e.insert(ot).values({
|
|
2181
2196
|
tenant_id: t,
|
|
2182
2197
|
template: n.template,
|
|
2183
2198
|
body: n.body,
|
|
@@ -2195,11 +2210,11 @@ function pn(e) {
|
|
|
2195
2210
|
async update(n, r, i) {
|
|
2196
2211
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2197
2212
|
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);
|
|
2198
|
-
let s = await e.update(
|
|
2213
|
+
let s = await e.update(ot).set(o).where(t(a(ot.tenant_id, n), a(ot.template, r))).run();
|
|
2199
2214
|
return Number(s.changes ?? 0) > 0;
|
|
2200
2215
|
},
|
|
2201
2216
|
async remove(n, r) {
|
|
2202
|
-
let i = await e.delete(
|
|
2217
|
+
let i = await e.delete(ot).where(t(a(ot.tenant_id, n), a(ot.template, r))).run();
|
|
2203
2218
|
return Number(i.changes ?? 0) > 0;
|
|
2204
2219
|
}
|
|
2205
2220
|
};
|
|
@@ -2208,10 +2223,17 @@ function pn(e) {
|
|
|
2208
2223
|
//#region src/adapters/flows.ts
|
|
2209
2224
|
var mn = ["id", "name"];
|
|
2210
2225
|
function hn(e) {
|
|
2226
|
+
let { tenant_id: t, actions: n, ...r } = e;
|
|
2227
|
+
return D({
|
|
2228
|
+
...r,
|
|
2229
|
+
actions: X(n, [])
|
|
2230
|
+
});
|
|
2231
|
+
}
|
|
2232
|
+
function gn(e) {
|
|
2211
2233
|
return {
|
|
2212
2234
|
async create(t, n) {
|
|
2213
2235
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = `af_${b()}`;
|
|
2214
|
-
return await e.insert(
|
|
2236
|
+
return await e.insert(rt).values({
|
|
2215
2237
|
id: i,
|
|
2216
2238
|
tenant_id: t,
|
|
2217
2239
|
name: n.name,
|
|
@@ -2227,41 +2249,50 @@ function hn(e) {
|
|
|
2227
2249
|
};
|
|
2228
2250
|
},
|
|
2229
2251
|
async get(n, r) {
|
|
2230
|
-
let i = await e.select().from(
|
|
2252
|
+
let i = await e.select().from(rt).where(t(a(rt.tenant_id, n), a(rt.id, r))).get();
|
|
2231
2253
|
if (!i) return null;
|
|
2232
2254
|
let { tenant_id: o, actions: s, ...c } = i;
|
|
2233
2255
|
return D({
|
|
2234
2256
|
...c,
|
|
2235
|
-
actions:
|
|
2257
|
+
actions: X(s, [])
|
|
2236
2258
|
});
|
|
2237
2259
|
},
|
|
2238
2260
|
async update(n, r, i) {
|
|
2239
2261
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2240
|
-
return i.name !== void 0 && (o.name = i.name), i.actions !== void 0 && (o.actions = JSON.stringify(i.actions)), (await e.update(
|
|
2262
|
+
return i.name !== void 0 && (o.name = i.name), i.actions !== void 0 && (o.actions = JSON.stringify(i.actions)), (await e.update(rt).set(o).where(t(a(rt.tenant_id, n), a(rt.id, r))).returning()).length === 0 ? null : this.get(n, r);
|
|
2241
2263
|
},
|
|
2242
2264
|
async list(o, s) {
|
|
2243
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(
|
|
2265
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(rt.tenant_id, o)];
|
|
2244
2266
|
if (f) {
|
|
2245
2267
|
let e = Ee(f, mn);
|
|
2246
2268
|
if (e) {
|
|
2247
|
-
let t =
|
|
2269
|
+
let t = Ct(rt, e, []);
|
|
2248
2270
|
t && p.push(t);
|
|
2249
2271
|
}
|
|
2250
2272
|
}
|
|
2251
|
-
let m = t(...p)
|
|
2273
|
+
let m = t(...p);
|
|
2274
|
+
if (wt(s)) {
|
|
2275
|
+
let n = {
|
|
2276
|
+
sortColumn: rt.created_at,
|
|
2277
|
+
idColumn: rt.id,
|
|
2278
|
+
sortOrder: "desc"
|
|
2279
|
+
}, r = Z(s), i = Et(s, n), { rows: a, next: o } = Dt(await e.select().from(rt).where(i ? t(m, i) : m).orderBy(...Tt(n)).limit(r + 1), r, "created_at", "id"), c = a.map(hn);
|
|
2280
|
+
return {
|
|
2281
|
+
flows: c,
|
|
2282
|
+
start: 0,
|
|
2283
|
+
limit: r,
|
|
2284
|
+
length: c.length,
|
|
2285
|
+
next: o
|
|
2286
|
+
};
|
|
2287
|
+
}
|
|
2288
|
+
let h = e.select().from(rt).where(m).$dynamic();
|
|
2252
2289
|
if (d?.sort_by) {
|
|
2253
|
-
let e =
|
|
2290
|
+
let e = rt[d.sort_by];
|
|
2254
2291
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
2255
2292
|
}
|
|
2256
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
2257
|
-
let { tenant_id: t, actions: n, ...r } = e;
|
|
2258
|
-
return D({
|
|
2259
|
-
...r,
|
|
2260
|
-
actions: Z(n, [])
|
|
2261
|
-
});
|
|
2262
|
-
});
|
|
2293
|
+
let g = (await h.offset(c * l).limit(l)).map(hn);
|
|
2263
2294
|
if (!u) return { flows: g };
|
|
2264
|
-
let [_] = await e.select({ count: r() }).from(
|
|
2295
|
+
let [_] = await e.select({ count: r() }).from(rt).where(m);
|
|
2265
2296
|
return {
|
|
2266
2297
|
flows: g,
|
|
2267
2298
|
start: c * l,
|
|
@@ -2270,18 +2301,23 @@ function hn(e) {
|
|
|
2270
2301
|
};
|
|
2271
2302
|
},
|
|
2272
2303
|
async remove(n, r) {
|
|
2273
|
-
return (await e.delete(
|
|
2304
|
+
return (await e.delete(rt).where(t(a(rt.tenant_id, n), a(rt.id, r))).returning()).length > 0;
|
|
2274
2305
|
}
|
|
2275
2306
|
};
|
|
2276
2307
|
}
|
|
2277
2308
|
//#endregion
|
|
2278
2309
|
//#region src/adapters/forms.ts
|
|
2279
|
-
var
|
|
2310
|
+
var _n = [
|
|
2280
2311
|
"nodes",
|
|
2281
2312
|
"start",
|
|
2282
2313
|
"ending"
|
|
2283
|
-
],
|
|
2284
|
-
function
|
|
2314
|
+
], vn = ["name"];
|
|
2315
|
+
function yn(e) {
|
|
2316
|
+
let { tenant_id: t, ...n } = e, r = { ...n };
|
|
2317
|
+
for (let e of _n) r[e] = X(n[e]);
|
|
2318
|
+
return D(r);
|
|
2319
|
+
}
|
|
2320
|
+
function bn(e) {
|
|
2285
2321
|
return {
|
|
2286
2322
|
async create(t, n) {
|
|
2287
2323
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = b(), a = {
|
|
@@ -2295,8 +2331,8 @@ function vn(e) {
|
|
|
2295
2331
|
created_at: r,
|
|
2296
2332
|
updated_at: r
|
|
2297
2333
|
};
|
|
2298
|
-
for (let e of
|
|
2299
|
-
return await e.insert(
|
|
2334
|
+
for (let e of _n) a[e] = JSON.stringify(n[e] || (e === "nodes" ? [] : {}));
|
|
2335
|
+
return await e.insert(nt).values(a), {
|
|
2300
2336
|
id: i,
|
|
2301
2337
|
...n,
|
|
2302
2338
|
created_at: r,
|
|
@@ -2304,38 +2340,49 @@ function vn(e) {
|
|
|
2304
2340
|
};
|
|
2305
2341
|
},
|
|
2306
2342
|
async get(n, r) {
|
|
2307
|
-
let i = await e.select().from(
|
|
2343
|
+
let i = await e.select().from(nt).where(t(a(nt.tenant_id, n), a(nt.id, r))).get();
|
|
2308
2344
|
if (!i) return null;
|
|
2309
2345
|
let { tenant_id: o, ...s } = i, c = { ...s };
|
|
2310
|
-
for (let e of
|
|
2346
|
+
for (let e of _n) c[e] = X(s[e]);
|
|
2311
2347
|
return D(c);
|
|
2312
2348
|
},
|
|
2313
2349
|
async update(n, r, i) {
|
|
2314
2350
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2315
|
-
for (let [e, t] of Object.entries(i)) t !== void 0 && (
|
|
2316
|
-
return (await e.update(
|
|
2351
|
+
for (let [e, t] of Object.entries(i)) t !== void 0 && (_n.includes(e) ? o[e] = JSON.stringify(t) : o[e] = t);
|
|
2352
|
+
return (await e.update(nt).set(o).where(t(a(nt.tenant_id, n), a(nt.id, r))).returning()).length > 0;
|
|
2317
2353
|
},
|
|
2318
2354
|
async list(o, s) {
|
|
2319
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(
|
|
2355
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(nt.tenant_id, o)];
|
|
2320
2356
|
if (f) {
|
|
2321
|
-
let e = Ee(f,
|
|
2357
|
+
let e = Ee(f, vn);
|
|
2322
2358
|
if (e) {
|
|
2323
|
-
let t =
|
|
2359
|
+
let t = Ct(nt, e, vn);
|
|
2324
2360
|
t && p.push(t);
|
|
2325
2361
|
}
|
|
2326
2362
|
}
|
|
2327
|
-
let m = t(...p)
|
|
2363
|
+
let m = t(...p);
|
|
2364
|
+
if (wt(s)) {
|
|
2365
|
+
let n = {
|
|
2366
|
+
sortColumn: nt.created_at,
|
|
2367
|
+
idColumn: nt.id,
|
|
2368
|
+
sortOrder: "desc"
|
|
2369
|
+
}, r = Z(s), i = Et(s, n), { rows: a, next: o } = Dt(await e.select().from(nt).where(i ? t(m, i) : m).orderBy(...Tt(n)).limit(r + 1), r, "created_at", "id"), c = a.map(yn);
|
|
2370
|
+
return {
|
|
2371
|
+
forms: c,
|
|
2372
|
+
start: 0,
|
|
2373
|
+
limit: r,
|
|
2374
|
+
length: c.length,
|
|
2375
|
+
next: o
|
|
2376
|
+
};
|
|
2377
|
+
}
|
|
2378
|
+
let h = e.select().from(nt).where(m).$dynamic();
|
|
2328
2379
|
if (d?.sort_by) {
|
|
2329
|
-
let e =
|
|
2380
|
+
let e = nt[d.sort_by];
|
|
2330
2381
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
2331
2382
|
}
|
|
2332
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
2333
|
-
let { tenant_id: t, ...n } = e, r = { ...n };
|
|
2334
|
-
for (let e of gn) r[e] = Z(n[e]);
|
|
2335
|
-
return D(r);
|
|
2336
|
-
});
|
|
2383
|
+
let g = (await h.offset(c * l).limit(l)).map(yn);
|
|
2337
2384
|
if (!u) return { forms: g };
|
|
2338
|
-
let [_] = await e.select({ count: r() }).from(
|
|
2385
|
+
let [_] = await e.select({ count: r() }).from(nt).where(m);
|
|
2339
2386
|
return {
|
|
2340
2387
|
forms: g,
|
|
2341
2388
|
start: c * l,
|
|
@@ -2344,47 +2391,47 @@ function vn(e) {
|
|
|
2344
2391
|
};
|
|
2345
2392
|
},
|
|
2346
2393
|
async remove(n, r) {
|
|
2347
|
-
return (await e.delete(
|
|
2394
|
+
return (await e.delete(nt).where(t(a(nt.tenant_id, n), a(nt.id, r))).returning()).length > 0;
|
|
2348
2395
|
}
|
|
2349
2396
|
};
|
|
2350
2397
|
}
|
|
2351
2398
|
//#endregion
|
|
2352
2399
|
//#region src/adapters/grants.ts
|
|
2353
|
-
function
|
|
2400
|
+
function xn(e) {
|
|
2354
2401
|
return {
|
|
2355
2402
|
id: e.id,
|
|
2356
2403
|
user_id: e.user_id,
|
|
2357
2404
|
clientID: e.client_id,
|
|
2358
2405
|
audience: e.audience || void 0,
|
|
2359
|
-
scope:
|
|
2406
|
+
scope: X(e.scope, []) ?? []
|
|
2360
2407
|
};
|
|
2361
2408
|
}
|
|
2362
|
-
var
|
|
2363
|
-
user_id:
|
|
2364
|
-
client_id:
|
|
2365
|
-
audience:
|
|
2366
|
-
created_at:
|
|
2367
|
-
updated_at:
|
|
2409
|
+
var Sn = {
|
|
2410
|
+
user_id: R.user_id,
|
|
2411
|
+
client_id: R.client_id,
|
|
2412
|
+
audience: R.audience,
|
|
2413
|
+
created_at: R.created_at,
|
|
2414
|
+
updated_at: R.updated_at
|
|
2368
2415
|
};
|
|
2369
|
-
function
|
|
2370
|
-
return Object.hasOwn(
|
|
2416
|
+
function Cn(e) {
|
|
2417
|
+
return Object.hasOwn(Sn, e) ? Sn[e] : void 0;
|
|
2371
2418
|
}
|
|
2372
|
-
function
|
|
2419
|
+
function wn(e) {
|
|
2373
2420
|
return {
|
|
2374
2421
|
async create(n, r) {
|
|
2375
|
-
let i = (/* @__PURE__ */ new Date()).toISOString(), o = r.scope ?? [], s = r.audience ?? "", c = await e.select().from(
|
|
2422
|
+
let i = (/* @__PURE__ */ new Date()).toISOString(), o = r.scope ?? [], s = r.audience ?? "", c = await e.select().from(R).where(t(a(R.tenant_id, n), a(R.user_id, r.user_id), a(R.client_id, r.clientID), a(R.audience, s))).get();
|
|
2376
2423
|
if (c) {
|
|
2377
|
-
let r =
|
|
2378
|
-
return await e.update(
|
|
2424
|
+
let r = X(c.scope, []) ?? [], s = Array.from(new Set([...r, ...o]));
|
|
2425
|
+
return await e.update(R).set({
|
|
2379
2426
|
scope: JSON.stringify(s),
|
|
2380
2427
|
updated_at: i
|
|
2381
|
-
}).where(t(a(
|
|
2428
|
+
}).where(t(a(R.tenant_id, n), a(R.id, c.id))), xn({
|
|
2382
2429
|
...c,
|
|
2383
2430
|
scope: JSON.stringify(s)
|
|
2384
2431
|
});
|
|
2385
2432
|
}
|
|
2386
2433
|
let l = b();
|
|
2387
|
-
return await e.insert(
|
|
2434
|
+
return await e.insert(R).values({
|
|
2388
2435
|
id: l,
|
|
2389
2436
|
tenant_id: n,
|
|
2390
2437
|
user_id: r.user_id,
|
|
@@ -2402,24 +2449,39 @@ function Sn(e) {
|
|
|
2402
2449
|
};
|
|
2403
2450
|
},
|
|
2404
2451
|
async get(n, r, i, o) {
|
|
2405
|
-
let s = await e.select().from(
|
|
2406
|
-
return s ?
|
|
2452
|
+
let s = await e.select().from(R).where(t(a(R.tenant_id, n), a(R.user_id, r), a(R.client_id, i), a(R.audience, o ?? ""))).get();
|
|
2453
|
+
return s ? xn(s) : null;
|
|
2407
2454
|
},
|
|
2408
2455
|
async list(o, s) {
|
|
2409
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
2456
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? Ct(R, f, [
|
|
2410
2457
|
"user_id",
|
|
2411
2458
|
"client_id",
|
|
2412
2459
|
"audience"
|
|
2413
|
-
]) : void 0, m = p ? t(a(
|
|
2414
|
-
|
|
2415
|
-
|
|
2460
|
+
]) : void 0, m = p ? t(a(R.tenant_id, o), p) : a(R.tenant_id, o);
|
|
2461
|
+
if (wt(s)) {
|
|
2462
|
+
let n = {
|
|
2463
|
+
sortColumn: R.created_at,
|
|
2464
|
+
idColumn: R.id,
|
|
2465
|
+
sortOrder: "desc"
|
|
2466
|
+
}, r = Z(s), i = Et(s, n), { rows: a, next: o } = Dt(await e.select().from(R).where(i ? t(m, i) : m).orderBy(...Tt(n)).limit(r + 1), r, "created_at", "id"), c = a.map(xn);
|
|
2467
|
+
return {
|
|
2468
|
+
grants: c,
|
|
2469
|
+
start: 0,
|
|
2470
|
+
limit: r,
|
|
2471
|
+
length: c.length,
|
|
2472
|
+
next: o
|
|
2473
|
+
};
|
|
2474
|
+
}
|
|
2475
|
+
let h = e.select().from(R).where(m).$dynamic(), g = d?.sort_by ? Cn(d.sort_by) : void 0;
|
|
2476
|
+
h = g ? h.orderBy(d?.sort_order === "desc" ? i(g) : n(g)) : h.orderBy(n(R.created_at));
|
|
2477
|
+
let _ = (await h.offset(c * l).limit(l)).map(xn);
|
|
2416
2478
|
if (!u) return {
|
|
2417
2479
|
grants: _,
|
|
2418
2480
|
start: 0,
|
|
2419
2481
|
limit: 0,
|
|
2420
2482
|
length: 0
|
|
2421
2483
|
};
|
|
2422
|
-
let [v] = await e.select({ count: r() }).from(
|
|
2484
|
+
let [v] = await e.select({ count: r() }).from(R).where(m);
|
|
2423
2485
|
return {
|
|
2424
2486
|
grants: _,
|
|
2425
2487
|
start: c * l,
|
|
@@ -2428,20 +2490,20 @@ function Sn(e) {
|
|
|
2428
2490
|
};
|
|
2429
2491
|
},
|
|
2430
2492
|
async remove(n, r) {
|
|
2431
|
-
return (await e.delete(
|
|
2493
|
+
return (await e.delete(R).where(t(a(R.tenant_id, n), a(R.id, r))).returning()).length > 0;
|
|
2432
2494
|
},
|
|
2433
2495
|
async removeByUser(n, r) {
|
|
2434
|
-
return (await e.delete(
|
|
2496
|
+
return (await e.delete(R).where(t(a(R.tenant_id, n), a(R.user_id, r))).returning()).length > 0;
|
|
2435
2497
|
}
|
|
2436
2498
|
};
|
|
2437
2499
|
}
|
|
2438
2500
|
//#endregion
|
|
2439
2501
|
//#region src/adapters/hookCode.ts
|
|
2440
|
-
var
|
|
2441
|
-
function
|
|
2442
|
-
return `hc_${
|
|
2502
|
+
var Tn = ee("0123456789abcdefghijklmnopqrstuvwxyz", 17);
|
|
2503
|
+
function En() {
|
|
2504
|
+
return `hc_${Tn()}`;
|
|
2443
2505
|
}
|
|
2444
|
-
function
|
|
2506
|
+
function Dn(e) {
|
|
2445
2507
|
let { created_at_ts: t, updated_at_ts: n, secrets: r, ...i } = e, a = ae({
|
|
2446
2508
|
created_at_ts: t,
|
|
2447
2509
|
updated_at_ts: n
|
|
@@ -2452,41 +2514,41 @@ function Tn(e) {
|
|
|
2452
2514
|
secrets: r ? JSON.parse(r) : void 0
|
|
2453
2515
|
};
|
|
2454
2516
|
}
|
|
2455
|
-
function
|
|
2517
|
+
function On(e) {
|
|
2456
2518
|
return {
|
|
2457
2519
|
async create(t, n) {
|
|
2458
2520
|
let r = Date.now(), i = {
|
|
2459
|
-
id:
|
|
2521
|
+
id: En(),
|
|
2460
2522
|
tenant_id: t,
|
|
2461
2523
|
code: n.code,
|
|
2462
2524
|
secrets: n.secrets ? JSON.stringify(n.secrets) : null,
|
|
2463
2525
|
created_at_ts: r,
|
|
2464
2526
|
updated_at_ts: r
|
|
2465
2527
|
};
|
|
2466
|
-
return await e.insert(
|
|
2528
|
+
return await e.insert(ct).values(i), Dn({
|
|
2467
2529
|
...i,
|
|
2468
2530
|
tenant_id: t
|
|
2469
2531
|
});
|
|
2470
2532
|
},
|
|
2471
2533
|
async get(n, r) {
|
|
2472
|
-
let i = await e.select().from(
|
|
2473
|
-
return i ?
|
|
2534
|
+
let i = await e.select().from(ct).where(t(a(ct.tenant_id, n), a(ct.id, r))).get();
|
|
2535
|
+
return i ? Dn(i) : null;
|
|
2474
2536
|
},
|
|
2475
2537
|
async update(n, r, i) {
|
|
2476
2538
|
let o = { updated_at_ts: Date.now() };
|
|
2477
|
-
return i.code !== void 0 && (o.code = i.code), i.secrets !== void 0 && (o.secrets = JSON.stringify(i.secrets)), (await e.update(
|
|
2539
|
+
return i.code !== void 0 && (o.code = i.code), i.secrets !== void 0 && (o.secrets = JSON.stringify(i.secrets)), (await e.update(ct).set(o).where(t(a(ct.tenant_id, n), a(ct.id, r))).returning()).length > 0;
|
|
2478
2540
|
},
|
|
2479
2541
|
async remove(n, r) {
|
|
2480
|
-
return (await e.delete(
|
|
2542
|
+
return (await e.delete(ct).where(t(a(ct.tenant_id, n), a(ct.id, r))).returning()).length > 0;
|
|
2481
2543
|
}
|
|
2482
2544
|
};
|
|
2483
2545
|
}
|
|
2484
2546
|
//#endregion
|
|
2485
2547
|
//#region src/adapters/hooks.ts
|
|
2486
|
-
function
|
|
2548
|
+
function kn() {
|
|
2487
2549
|
return `h_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
2488
2550
|
}
|
|
2489
|
-
function
|
|
2551
|
+
function An(e) {
|
|
2490
2552
|
if (!(typeof e != "string" || !e)) try {
|
|
2491
2553
|
let t = JSON.parse(e);
|
|
2492
2554
|
return t && typeof t == "object" && !Array.isArray(t) ? t : void 0;
|
|
@@ -2494,7 +2556,7 @@ function On(e) {
|
|
|
2494
2556
|
return;
|
|
2495
2557
|
}
|
|
2496
2558
|
}
|
|
2497
|
-
function
|
|
2559
|
+
function jn(e) {
|
|
2498
2560
|
let { tenant_id: t, created_at_ts: n, updated_at_ts: r, metadata: i, ...a } = e, o = ae({
|
|
2499
2561
|
created_at_ts: n,
|
|
2500
2562
|
updated_at_ts: r
|
|
@@ -2503,15 +2565,15 @@ function kn(e) {
|
|
|
2503
2565
|
...a,
|
|
2504
2566
|
enabled: !!a.enabled,
|
|
2505
2567
|
synchronous: !!a.synchronous,
|
|
2506
|
-
metadata:
|
|
2568
|
+
metadata: An(i),
|
|
2507
2569
|
...o
|
|
2508
2570
|
});
|
|
2509
2571
|
}
|
|
2510
|
-
function
|
|
2572
|
+
function Mn(e) {
|
|
2511
2573
|
return {
|
|
2512
2574
|
async create(t, n) {
|
|
2513
2575
|
let r = Date.now(), i = {
|
|
2514
|
-
hook_id: n.hook_id ||
|
|
2576
|
+
hook_id: n.hook_id || kn(),
|
|
2515
2577
|
tenant_id: t,
|
|
2516
2578
|
trigger_id: n.trigger_id,
|
|
2517
2579
|
url: n.url,
|
|
@@ -2527,30 +2589,45 @@ function An(e) {
|
|
|
2527
2589
|
created_at_ts: r,
|
|
2528
2590
|
updated_at_ts: r
|
|
2529
2591
|
};
|
|
2530
|
-
return await e.insert(
|
|
2592
|
+
return await e.insert(st).values(i), jn({
|
|
2531
2593
|
...i,
|
|
2532
2594
|
tenant_id: t
|
|
2533
2595
|
});
|
|
2534
2596
|
},
|
|
2535
2597
|
async get(n, r) {
|
|
2536
|
-
let i = await e.select().from(
|
|
2537
|
-
return i ?
|
|
2598
|
+
let i = await e.select().from(st).where(t(a(st.tenant_id, n), a(st.hook_id, r))).get();
|
|
2599
|
+
return i ? jn(i) : null;
|
|
2538
2600
|
},
|
|
2539
2601
|
async update(n, r, i) {
|
|
2540
2602
|
let o = { updated_at_ts: Date.now() };
|
|
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(
|
|
2603
|
+
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(st).set(o).where(t(a(st.tenant_id, n), a(st.hook_id, r))).returning()).length > 0;
|
|
2542
2604
|
},
|
|
2543
2605
|
async list(o, s) {
|
|
2544
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
2606
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? Ct(st, f, [
|
|
2545
2607
|
"url",
|
|
2546
2608
|
"form_id",
|
|
2547
2609
|
"template_id",
|
|
2548
2610
|
"code_id"
|
|
2549
|
-
]) : void 0, m = p ? t(a(
|
|
2550
|
-
|
|
2551
|
-
|
|
2611
|
+
]) : void 0, m = p ? t(a(st.tenant_id, o), p) : a(st.tenant_id, o);
|
|
2612
|
+
if (wt(s)) {
|
|
2613
|
+
let n = {
|
|
2614
|
+
sortColumn: st.created_at_ts,
|
|
2615
|
+
idColumn: st.hook_id,
|
|
2616
|
+
sortOrder: "desc"
|
|
2617
|
+
}, r = Z(s), i = Et(s, n), { rows: a, next: o } = Dt(await e.select().from(st).where(i ? t(m, i) : m).orderBy(...Tt(n)).limit(r + 1), r, "created_at_ts", "hook_id"), c = a.map(jn);
|
|
2618
|
+
return {
|
|
2619
|
+
hooks: c,
|
|
2620
|
+
start: 0,
|
|
2621
|
+
limit: r,
|
|
2622
|
+
length: c.length,
|
|
2623
|
+
next: o
|
|
2624
|
+
};
|
|
2625
|
+
}
|
|
2626
|
+
let h = e.select().from(st).where(m).$dynamic(), g = d?.sort_by ? st[d.sort_by] : void 0;
|
|
2627
|
+
h = g ? h.orderBy(d?.sort_order === "desc" ? i(g) : n(g)) : h.orderBy(i(st.priority), n(st.created_at_ts));
|
|
2628
|
+
let _ = (await h.offset(c * l).limit(l)).map(jn);
|
|
2552
2629
|
if (!u) return { hooks: _ };
|
|
2553
|
-
let [v] = await e.select({ count: r() }).from(
|
|
2630
|
+
let [v] = await e.select({ count: r() }).from(st).where(m);
|
|
2554
2631
|
return {
|
|
2555
2632
|
hooks: _,
|
|
2556
2633
|
start: c * l,
|
|
@@ -2559,31 +2636,31 @@ function An(e) {
|
|
|
2559
2636
|
};
|
|
2560
2637
|
},
|
|
2561
2638
|
async remove(n, r) {
|
|
2562
|
-
return (await e.delete(
|
|
2639
|
+
return (await e.delete(st).where(t(a(st.tenant_id, n), a(st.hook_id, r))).returning()).length > 0;
|
|
2563
2640
|
}
|
|
2564
2641
|
};
|
|
2565
2642
|
}
|
|
2566
2643
|
//#endregion
|
|
2567
2644
|
//#region src/adapters/invites.ts
|
|
2568
|
-
function
|
|
2645
|
+
function Nn() {
|
|
2569
2646
|
return `inv_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
2570
2647
|
}
|
|
2571
|
-
var
|
|
2648
|
+
var Pn = [
|
|
2572
2649
|
"inviter",
|
|
2573
2650
|
"invitee",
|
|
2574
2651
|
"app_metadata",
|
|
2575
2652
|
"user_metadata",
|
|
2576
2653
|
"roles"
|
|
2577
2654
|
];
|
|
2578
|
-
function
|
|
2655
|
+
function Fn(e) {
|
|
2579
2656
|
let { tenant_id: t, send_invitation_email: n, ...r } = e, i = { ...r };
|
|
2580
|
-
for (let e of
|
|
2657
|
+
for (let e of Pn) i[e] = X(r[e], e === "roles" ? [] : {});
|
|
2581
2658
|
return i.send_invitation_email = !!n, D(i);
|
|
2582
2659
|
}
|
|
2583
|
-
function
|
|
2660
|
+
function In(e) {
|
|
2584
2661
|
return {
|
|
2585
2662
|
async create(t, n) {
|
|
2586
|
-
let r = n.id ||
|
|
2663
|
+
let r = n.id || Nn(), i = n.ttl_sec || 604800, a = /* @__PURE__ */ new Date(), o = new Date(a.getTime() + i * 1e3).toISOString(), s = {
|
|
2587
2664
|
id: r,
|
|
2588
2665
|
tenant_id: t,
|
|
2589
2666
|
organization_id: n.organization_id,
|
|
@@ -2596,76 +2673,91 @@ function Pn(e) {
|
|
|
2596
2673
|
created_at: a.toISOString(),
|
|
2597
2674
|
expires_at: o
|
|
2598
2675
|
};
|
|
2599
|
-
for (let e of
|
|
2676
|
+
for (let e of Pn) n[e] !== void 0 && (s[e] = JSON.stringify(n[e]));
|
|
2600
2677
|
try {
|
|
2601
|
-
await e.insert(
|
|
2678
|
+
await e.insert(Xe).values(s);
|
|
2602
2679
|
} catch (e) {
|
|
2603
2680
|
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new Re(409, { message: "Invite already exists" }) : e;
|
|
2604
2681
|
}
|
|
2605
|
-
return
|
|
2682
|
+
return Fn({
|
|
2606
2683
|
...s,
|
|
2607
2684
|
tenant_id: t
|
|
2608
2685
|
});
|
|
2609
2686
|
},
|
|
2610
2687
|
async get(n, r) {
|
|
2611
|
-
let i = await e.select().from(
|
|
2612
|
-
return i ?
|
|
2688
|
+
let i = await e.select().from(Xe).where(t(a(Xe.tenant_id, n), a(Xe.id, r))).get();
|
|
2689
|
+
return i ? Fn(i) : null;
|
|
2613
2690
|
},
|
|
2614
2691
|
async update(n, r, i) {
|
|
2615
2692
|
let o = {};
|
|
2616
|
-
for (let e of
|
|
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(
|
|
2693
|
+
for (let e of Pn) i[e] !== void 0 && (o[e] = JSON.stringify(i[e]));
|
|
2694
|
+
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(Xe).set(o).where(t(a(Xe.tenant_id, n), a(Xe.id, r))).returning()).length > 0;
|
|
2618
2695
|
},
|
|
2619
|
-
async list(
|
|
2620
|
-
let { page:
|
|
2621
|
-
if (
|
|
2622
|
-
let
|
|
2623
|
-
|
|
2696
|
+
async list(o, s) {
|
|
2697
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d } = s || {};
|
|
2698
|
+
if (wt(s)) {
|
|
2699
|
+
let n = {
|
|
2700
|
+
sortColumn: Xe.created_at,
|
|
2701
|
+
idColumn: Xe.id,
|
|
2702
|
+
sortOrder: "desc"
|
|
2703
|
+
}, r = Z(s), i = s?.q ? Ct(Xe, s.q, ["invitee", "inviter"]) : void 0, { rows: c, next: l } = Dt(await e.select().from(Xe).where(t(a(Xe.tenant_id, o), i, Et(s, n))).orderBy(...Tt(n)).limit(r + 1), r, "created_at"), u = c.map(Fn);
|
|
2704
|
+
return {
|
|
2705
|
+
invites: u,
|
|
2706
|
+
start: 0,
|
|
2707
|
+
limit: r,
|
|
2708
|
+
length: u.length,
|
|
2709
|
+
next: l
|
|
2710
|
+
};
|
|
2624
2711
|
}
|
|
2625
|
-
let f = (
|
|
2626
|
-
if (
|
|
2627
|
-
|
|
2712
|
+
let f = e.select().from(Xe).where(a(Xe.tenant_id, o)).$dynamic();
|
|
2713
|
+
if (d?.sort_by) {
|
|
2714
|
+
let e = Xe[d.sort_by];
|
|
2715
|
+
e && (f = f.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
2716
|
+
}
|
|
2717
|
+
let p = (await f.offset(c * l).limit(l)).map(Fn);
|
|
2718
|
+
if (!u) return { invites: p };
|
|
2719
|
+
let [m] = await e.select({ count: r() }).from(Xe).where(a(Xe.tenant_id, o));
|
|
2628
2720
|
return {
|
|
2629
|
-
invites:
|
|
2630
|
-
start:
|
|
2631
|
-
limit:
|
|
2632
|
-
length: Number(
|
|
2721
|
+
invites: p,
|
|
2722
|
+
start: c * l,
|
|
2723
|
+
limit: l,
|
|
2724
|
+
length: Number(m?.count ?? 0)
|
|
2633
2725
|
};
|
|
2634
2726
|
},
|
|
2635
2727
|
async remove(n, r) {
|
|
2636
|
-
return (await e.delete(
|
|
2728
|
+
return (await e.delete(Xe).where(t(a(Xe.tenant_id, n), a(Xe.id, r))).returning()).length > 0;
|
|
2637
2729
|
}
|
|
2638
2730
|
};
|
|
2639
2731
|
}
|
|
2640
2732
|
//#endregion
|
|
2641
2733
|
//#region src/adapters/keys.ts
|
|
2642
|
-
var
|
|
2734
|
+
var Ln = [
|
|
2643
2735
|
"kid",
|
|
2644
2736
|
"connection",
|
|
2645
2737
|
"fingerprint",
|
|
2646
2738
|
"thumbprint",
|
|
2647
2739
|
"type"
|
|
2648
2740
|
];
|
|
2649
|
-
function
|
|
2741
|
+
function Rn(e) {
|
|
2650
2742
|
return {
|
|
2651
2743
|
async create(t) {
|
|
2652
|
-
await e.insert(
|
|
2744
|
+
await e.insert(lt).values({
|
|
2653
2745
|
...t,
|
|
2654
2746
|
created_at: (/* @__PURE__ */ new Date()).toDateString()
|
|
2655
2747
|
});
|
|
2656
2748
|
},
|
|
2657
2749
|
async list(a) {
|
|
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(
|
|
2750
|
+
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(lt.revoked_at, p), f(lt.revoked_at))];
|
|
2659
2751
|
if (d) {
|
|
2660
|
-
let e = Ee(d,
|
|
2752
|
+
let e = Ee(d, Ln);
|
|
2661
2753
|
if (e) {
|
|
2662
|
-
let t =
|
|
2754
|
+
let t = Ct(lt, e, Ln);
|
|
2663
2755
|
t && m.push(t);
|
|
2664
2756
|
}
|
|
2665
2757
|
}
|
|
2666
|
-
let h = t(...m), g = e.select().from(
|
|
2758
|
+
let h = t(...m), g = e.select().from(lt).where(h).$dynamic();
|
|
2667
2759
|
if (u?.sort_by) {
|
|
2668
|
-
let e =
|
|
2760
|
+
let e = lt[u.sort_by];
|
|
2669
2761
|
e && (g = g.orderBy(u.sort_order === "desc" ? i(e) : n(e)));
|
|
2670
2762
|
}
|
|
2671
2763
|
let _ = (await g.offset(o * c).limit(c)).map((e) => {
|
|
@@ -2673,7 +2765,7 @@ function In(e) {
|
|
|
2673
2765
|
return D(n);
|
|
2674
2766
|
});
|
|
2675
2767
|
if (!l) return { signingKeys: _ };
|
|
2676
|
-
let [y] = await e.select({ count: r() }).from(
|
|
2768
|
+
let [y] = await e.select({ count: r() }).from(lt).where(h);
|
|
2677
2769
|
return {
|
|
2678
2770
|
signingKeys: _,
|
|
2679
2771
|
start: o * c,
|
|
@@ -2682,22 +2774,22 @@ function In(e) {
|
|
|
2682
2774
|
};
|
|
2683
2775
|
},
|
|
2684
2776
|
async update(t, n) {
|
|
2685
|
-
return (await e.update(
|
|
2777
|
+
return (await e.update(lt).set(n).where(a(lt.kid, t)).returning()).length > 0;
|
|
2686
2778
|
}
|
|
2687
2779
|
};
|
|
2688
2780
|
}
|
|
2689
2781
|
//#endregion
|
|
2690
2782
|
//#region src/adapters/loginSessions.ts
|
|
2691
|
-
var
|
|
2692
|
-
function
|
|
2783
|
+
var zn = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", Bn = 32;
|
|
2784
|
+
function Vn() {
|
|
2693
2785
|
let e = Date.now(), t = "";
|
|
2694
|
-
for (let n = 10; n > 0; n--) t =
|
|
2786
|
+
for (let n = 10; n > 0; n--) t = zn.charAt(e % Bn) + t, e = Math.floor(e / Bn);
|
|
2695
2787
|
let n = new Uint8Array(16);
|
|
2696
2788
|
crypto.getRandomValues(n);
|
|
2697
|
-
for (let e = 0; e < 16; e++) t +=
|
|
2789
|
+
for (let e = 0; e < 16; e++) t += zn.charAt(n[e] % Bn);
|
|
2698
2790
|
return t;
|
|
2699
2791
|
}
|
|
2700
|
-
function
|
|
2792
|
+
function Hn(e) {
|
|
2701
2793
|
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({
|
|
2702
2794
|
created_at_ts: n,
|
|
2703
2795
|
updated_at_ts: r,
|
|
@@ -2709,17 +2801,17 @@ function Bn(e) {
|
|
|
2709
2801
|
]), l = {};
|
|
2710
2802
|
for (let [e, t] of Object.entries(s)) t != null && (l[e] = t);
|
|
2711
2803
|
return D({
|
|
2712
|
-
...
|
|
2804
|
+
...bt(l, ["auth_strategy"]),
|
|
2713
2805
|
authParams: typeof o == "string" && o.length > 0 ? JSON.parse(o) : {},
|
|
2714
2806
|
...c,
|
|
2715
|
-
state_data:
|
|
2807
|
+
state_data: X(a)
|
|
2716
2808
|
});
|
|
2717
2809
|
}
|
|
2718
|
-
function
|
|
2810
|
+
function Un(e) {
|
|
2719
2811
|
return {
|
|
2720
2812
|
async create(t, n) {
|
|
2721
2813
|
let r = Date.now(), i = {
|
|
2722
|
-
id:
|
|
2814
|
+
id: Vn(),
|
|
2723
2815
|
tenant_id: t,
|
|
2724
2816
|
session_id: n.session_id,
|
|
2725
2817
|
csrf_token: n.csrf_token,
|
|
@@ -2740,14 +2832,14 @@ function Vn(e) {
|
|
|
2740
2832
|
updated_at_ts: r,
|
|
2741
2833
|
expires_at_ts: n.expires_at ? E(n.expires_at) : r + 1e3 * 60 * 60 * 24
|
|
2742
2834
|
};
|
|
2743
|
-
return await e.insert(P).values(i),
|
|
2835
|
+
return await e.insert(P).values(i), Hn({
|
|
2744
2836
|
...i,
|
|
2745
2837
|
tenant_id: t
|
|
2746
2838
|
});
|
|
2747
2839
|
},
|
|
2748
2840
|
async get(n, r) {
|
|
2749
2841
|
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();
|
|
2750
|
-
return o ?
|
|
2842
|
+
return o ? Hn(o) : null;
|
|
2751
2843
|
},
|
|
2752
2844
|
async update(n, r, i) {
|
|
2753
2845
|
let o = { updated_at_ts: Date.now() };
|
|
@@ -2767,12 +2859,12 @@ function Vn(e) {
|
|
|
2767
2859
|
}
|
|
2768
2860
|
//#endregion
|
|
2769
2861
|
//#region src/adapters/logs.ts
|
|
2770
|
-
function
|
|
2862
|
+
function Wn(e) {
|
|
2771
2863
|
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 = {
|
|
2772
2864
|
...f,
|
|
2773
2865
|
isMobile: !!n,
|
|
2774
|
-
auth0_client:
|
|
2775
|
-
details:
|
|
2866
|
+
auth0_client: X(r),
|
|
2867
|
+
details: X(i),
|
|
2776
2868
|
scope: d ? d.split(",") : void 0
|
|
2777
2869
|
};
|
|
2778
2870
|
return a && (p.location_info = D({
|
|
@@ -2784,7 +2876,7 @@ function Hn(e) {
|
|
|
2784
2876
|
continent_code: u
|
|
2785
2877
|
})), D(p);
|
|
2786
2878
|
}
|
|
2787
|
-
function
|
|
2879
|
+
function Gn(e) {
|
|
2788
2880
|
return {
|
|
2789
2881
|
async create(t, n) {
|
|
2790
2882
|
let r = {
|
|
@@ -2810,15 +2902,15 @@ function Un(e) {
|
|
|
2810
2902
|
hostname: n.hostname,
|
|
2811
2903
|
session_connection: n.session_connection
|
|
2812
2904
|
};
|
|
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(
|
|
2905
|
+
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(K).values(r), Wn({
|
|
2814
2906
|
...r,
|
|
2815
2907
|
tenant_id: t
|
|
2816
2908
|
});
|
|
2817
2909
|
},
|
|
2818
2910
|
async list(o, s) {
|
|
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(
|
|
2911
|
+
let { page: l = 0, per_page: u = 50, include_totals: d = !1, sort: f, q: p, from_date: h, to_date: g } = s || {}, _ = [a(K.tenant_id, o)];
|
|
2820
2912
|
if (p) {
|
|
2821
|
-
let e =
|
|
2913
|
+
let e = Ct(K, p, [
|
|
2822
2914
|
"user_id",
|
|
2823
2915
|
"ip",
|
|
2824
2916
|
"type",
|
|
@@ -2826,16 +2918,16 @@ function Un(e) {
|
|
|
2826
2918
|
], ["description"]);
|
|
2827
2919
|
e && _.push(e);
|
|
2828
2920
|
}
|
|
2829
|
-
typeof h == "number" && Number.isFinite(h) && _.push(c(
|
|
2921
|
+
typeof h == "number" && Number.isFinite(h) && _.push(c(K.date, (/* @__PURE__ */ new Date(Math.floor(h) * 1e3)).toISOString())), typeof g == "number" && Number.isFinite(g) && _.push(m(K.date, (/* @__PURE__ */ new Date((Math.floor(g) + 1) * 1e3)).toISOString()));
|
|
2830
2922
|
let v = t(..._);
|
|
2831
|
-
if (
|
|
2923
|
+
if (wt(s)) {
|
|
2832
2924
|
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` });
|
|
2833
2925
|
let n = f?.sort_order === "asc" ? "asc" : "desc", r = {
|
|
2834
|
-
sortColumn:
|
|
2835
|
-
idColumn:
|
|
2926
|
+
sortColumn: K.date,
|
|
2927
|
+
idColumn: K.log_id,
|
|
2836
2928
|
sortOrder: n,
|
|
2837
2929
|
sortKey: `date:${n}`
|
|
2838
|
-
}, i =
|
|
2930
|
+
}, i = Et(s, r), a = Z(s), { rows: o, next: c } = Dt(await e.select().from(K).where(i ? t(v, i) : v).orderBy(...Tt(r)).limit(a + 1), a, "date", "log_id", r.sortKey), l = o.map(Wn);
|
|
2839
2931
|
return {
|
|
2840
2932
|
logs: l,
|
|
2841
2933
|
start: 0,
|
|
@@ -2844,14 +2936,14 @@ function Un(e) {
|
|
|
2844
2936
|
next: c
|
|
2845
2937
|
};
|
|
2846
2938
|
}
|
|
2847
|
-
let y = e.select().from(
|
|
2939
|
+
let y = e.select().from(K).where(v).$dynamic();
|
|
2848
2940
|
if (f?.sort_by) {
|
|
2849
|
-
let e =
|
|
2941
|
+
let e = K[f.sort_by];
|
|
2850
2942
|
e && (y = y.orderBy(f.sort_order === "desc" ? i(e) : n(e)));
|
|
2851
|
-
} else y = y.orderBy(i(
|
|
2852
|
-
let ee = (await y.offset(l * u).limit(u)).map(
|
|
2943
|
+
} else y = y.orderBy(i(K.date));
|
|
2944
|
+
let ee = (await y.offset(l * u).limit(u)).map(Wn);
|
|
2853
2945
|
if (!d) return { logs: ee };
|
|
2854
|
-
let [b] = await e.select({ count: r() }).from(
|
|
2946
|
+
let [b] = await e.select({ count: r() }).from(K).where(v);
|
|
2855
2947
|
return {
|
|
2856
2948
|
logs: ee,
|
|
2857
2949
|
start: l * u,
|
|
@@ -2860,38 +2952,38 @@ function Un(e) {
|
|
|
2860
2952
|
};
|
|
2861
2953
|
},
|
|
2862
2954
|
async get(n, r) {
|
|
2863
|
-
let i = await e.select().from(
|
|
2864
|
-
return i ?
|
|
2955
|
+
let i = await e.select().from(K).where(t(a(K.tenant_id, n), a(K.log_id, r))).get();
|
|
2956
|
+
return i ? Wn(i) : null;
|
|
2865
2957
|
}
|
|
2866
2958
|
};
|
|
2867
2959
|
}
|
|
2868
2960
|
//#endregion
|
|
2869
2961
|
//#region src/adapters/authenticationMethods.ts
|
|
2870
|
-
var
|
|
2871
|
-
function
|
|
2962
|
+
var Kn = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", qn = 32;
|
|
2963
|
+
function Jn() {
|
|
2872
2964
|
let e = Date.now(), t = "";
|
|
2873
|
-
for (let n = 10; n > 0; n--) t =
|
|
2965
|
+
for (let n = 10; n > 0; n--) t = Kn.charAt(e % qn) + t, e = Math.floor(e / qn);
|
|
2874
2966
|
let n = new Uint8Array(16);
|
|
2875
2967
|
crypto.getRandomValues(n);
|
|
2876
|
-
for (let e = 0; e < 16; e++) t +=
|
|
2968
|
+
for (let e = 0; e < 16; e++) t += Kn.charAt(n[e] % qn);
|
|
2877
2969
|
return t;
|
|
2878
2970
|
}
|
|
2879
|
-
function
|
|
2971
|
+
function Yn(e) {
|
|
2880
2972
|
let { tenant_id: t, created_at_ts: n, updated_at_ts: r, credential_backed_up: i, confirmed: a, transports: o, ...s } = e;
|
|
2881
2973
|
return D({
|
|
2882
2974
|
...s,
|
|
2883
2975
|
confirmed: !!a,
|
|
2884
2976
|
credential_backed_up: i == null ? void 0 : !!i,
|
|
2885
|
-
transports:
|
|
2977
|
+
transports: X(o),
|
|
2886
2978
|
created_at: oe(n),
|
|
2887
2979
|
updated_at: oe(r)
|
|
2888
2980
|
});
|
|
2889
2981
|
}
|
|
2890
|
-
function
|
|
2982
|
+
function Xn(e) {
|
|
2891
2983
|
return {
|
|
2892
2984
|
async create(t, n) {
|
|
2893
2985
|
let r = Date.now(), i = {
|
|
2894
|
-
id: n.id ||
|
|
2986
|
+
id: n.id || Jn(),
|
|
2895
2987
|
tenant_id: t,
|
|
2896
2988
|
user_id: n.user_id,
|
|
2897
2989
|
type: n.type,
|
|
@@ -2907,55 +2999,55 @@ function Jn(e) {
|
|
|
2907
2999
|
created_at_ts: r,
|
|
2908
3000
|
updated_at_ts: r
|
|
2909
3001
|
};
|
|
2910
|
-
return await e.insert(
|
|
3002
|
+
return await e.insert(ft).values(i), Yn({
|
|
2911
3003
|
...i,
|
|
2912
3004
|
tenant_id: t
|
|
2913
3005
|
});
|
|
2914
3006
|
},
|
|
2915
3007
|
async get(n, r) {
|
|
2916
|
-
let i = await e.select().from(
|
|
2917
|
-
return i ?
|
|
3008
|
+
let i = await e.select().from(ft).where(t(a(ft.tenant_id, n), a(ft.id, r))).get();
|
|
3009
|
+
return i ? Yn(i) : null;
|
|
2918
3010
|
},
|
|
2919
3011
|
async getByCredentialId(n, r) {
|
|
2920
|
-
let i = await e.select().from(
|
|
2921
|
-
return i ?
|
|
3012
|
+
let i = await e.select().from(ft).where(t(a(ft.tenant_id, n), a(ft.credential_id, r))).get();
|
|
3013
|
+
return i ? Yn(i) : null;
|
|
2922
3014
|
},
|
|
2923
3015
|
async list(n, r) {
|
|
2924
|
-
return (await e.select().from(
|
|
3016
|
+
return (await e.select().from(ft).where(t(a(ft.tenant_id, n), a(ft.user_id, r))).all()).map(Yn);
|
|
2925
3017
|
},
|
|
2926
3018
|
async update(n, r, i) {
|
|
2927
3019
|
let o = { updated_at_ts: Date.now() };
|
|
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(
|
|
3020
|
+
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(ft).set(o).where(t(a(ft.tenant_id, n), a(ft.id, r)));
|
|
2929
3021
|
let s = await this.get(n, r);
|
|
2930
3022
|
if (!s) throw Error(`Authentication method ${r} not found after update`);
|
|
2931
3023
|
return s;
|
|
2932
3024
|
},
|
|
2933
3025
|
async remove(n, r) {
|
|
2934
|
-
return (await e.delete(
|
|
3026
|
+
return (await e.delete(ft).where(t(a(ft.tenant_id, n), a(ft.id, r))).returning()).length > 0;
|
|
2935
3027
|
}
|
|
2936
3028
|
};
|
|
2937
3029
|
}
|
|
2938
3030
|
//#endregion
|
|
2939
3031
|
//#region src/adapters/organizations.ts
|
|
2940
|
-
var
|
|
2941
|
-
function
|
|
3032
|
+
var Zn = ["name", "display_name"];
|
|
3033
|
+
function Qn() {
|
|
2942
3034
|
return `org_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
2943
3035
|
}
|
|
2944
|
-
function
|
|
3036
|
+
function $n(e) {
|
|
2945
3037
|
let { tenant_id: t, branding: n, metadata: r, enabled_connections: i, token_quota: a, ...o } = e;
|
|
2946
3038
|
return D({
|
|
2947
3039
|
...o,
|
|
2948
|
-
branding:
|
|
2949
|
-
metadata:
|
|
2950
|
-
enabled_connections:
|
|
2951
|
-
token_quota:
|
|
3040
|
+
branding: X(n, {}),
|
|
3041
|
+
metadata: X(r, {}),
|
|
3042
|
+
enabled_connections: X(i, []),
|
|
3043
|
+
token_quota: X(a, {})
|
|
2952
3044
|
});
|
|
2953
3045
|
}
|
|
2954
|
-
function
|
|
3046
|
+
function er(e) {
|
|
2955
3047
|
return {
|
|
2956
3048
|
async create(t, n) {
|
|
2957
3049
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
2958
|
-
id: n.id ||
|
|
3050
|
+
id: n.id || Qn(),
|
|
2959
3051
|
tenant_id: t,
|
|
2960
3052
|
name: n.name,
|
|
2961
3053
|
display_name: n.display_name,
|
|
@@ -2967,39 +3059,39 @@ function Qn(e) {
|
|
|
2967
3059
|
updated_at: r
|
|
2968
3060
|
};
|
|
2969
3061
|
try {
|
|
2970
|
-
await e.insert(
|
|
3062
|
+
await e.insert(B).values(i);
|
|
2971
3063
|
} catch (e) {
|
|
2972
3064
|
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("AlreadyExists") ? new Re(409, { message: "Organization already exists" }) : e;
|
|
2973
3065
|
}
|
|
2974
|
-
return
|
|
3066
|
+
return $n({
|
|
2975
3067
|
...i,
|
|
2976
3068
|
tenant_id: t
|
|
2977
3069
|
});
|
|
2978
3070
|
},
|
|
2979
3071
|
async get(n, r) {
|
|
2980
|
-
let i = await e.select().from(
|
|
2981
|
-
return i ||= await e.select().from(
|
|
3072
|
+
let i = await e.select().from(B).where(t(a(B.tenant_id, n), a(B.id, r))).get();
|
|
3073
|
+
return i ||= await e.select().from(B).where(t(a(B.tenant_id, n), a(B.name, r))).get(), i ? $n(i) : null;
|
|
2982
3074
|
},
|
|
2983
3075
|
async update(n, r, i) {
|
|
2984
3076
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2985
|
-
return i.name !== void 0 && (o.name = i.name), i.display_name !== void 0 && (o.display_name = i.display_name), i.branding !== void 0 && (o.branding = JSON.stringify(i.branding)), i.metadata !== void 0 && (o.metadata = JSON.stringify(i.metadata)), i.enabled_connections !== void 0 && (o.enabled_connections = JSON.stringify(i.enabled_connections)), i.token_quota !== void 0 && (o.token_quota = JSON.stringify(i.token_quota)), (await e.update(
|
|
3077
|
+
return i.name !== void 0 && (o.name = i.name), i.display_name !== void 0 && (o.display_name = i.display_name), i.branding !== void 0 && (o.branding = JSON.stringify(i.branding)), i.metadata !== void 0 && (o.metadata = JSON.stringify(i.metadata)), i.enabled_connections !== void 0 && (o.enabled_connections = JSON.stringify(i.enabled_connections)), i.token_quota !== void 0 && (o.token_quota = JSON.stringify(i.token_quota)), (await e.update(B).set(o).where(t(a(B.tenant_id, n), a(B.id, r))).returning()).length > 0;
|
|
2986
3078
|
},
|
|
2987
3079
|
async list(o, s) {
|
|
2988
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(
|
|
3080
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(B.tenant_id, o)];
|
|
2989
3081
|
if (f) {
|
|
2990
|
-
let e = Ee(f,
|
|
3082
|
+
let e = Ee(f, Zn);
|
|
2991
3083
|
if (e) {
|
|
2992
|
-
let t =
|
|
3084
|
+
let t = Ct(B, e, Zn);
|
|
2993
3085
|
t && p.push(t);
|
|
2994
3086
|
}
|
|
2995
3087
|
}
|
|
2996
3088
|
let m = t(...p);
|
|
2997
|
-
if (
|
|
3089
|
+
if (wt(s)) {
|
|
2998
3090
|
let n = {
|
|
2999
|
-
sortColumn:
|
|
3000
|
-
idColumn:
|
|
3091
|
+
sortColumn: B.created_at,
|
|
3092
|
+
idColumn: B.id,
|
|
3001
3093
|
sortOrder: "desc"
|
|
3002
|
-
}, r =
|
|
3094
|
+
}, r = Et(s, n), i = Z(s), { rows: a, next: o } = Dt(await e.select().from(B).where(r ? t(m, r) : m).orderBy(...Tt(n)).limit(i + 1), i, "created_at"), c = a.map($n);
|
|
3003
3095
|
return {
|
|
3004
3096
|
organizations: c,
|
|
3005
3097
|
start: 0,
|
|
@@ -3009,14 +3101,14 @@ function Qn(e) {
|
|
|
3009
3101
|
next: o
|
|
3010
3102
|
};
|
|
3011
3103
|
}
|
|
3012
|
-
let h = e.select().from(
|
|
3104
|
+
let h = e.select().from(B).where(m).$dynamic();
|
|
3013
3105
|
if (d?.sort_by) {
|
|
3014
|
-
let e =
|
|
3106
|
+
let e = B[d.sort_by];
|
|
3015
3107
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
3016
3108
|
}
|
|
3017
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
3109
|
+
let g = (await h.offset(c * l).limit(l)).map($n);
|
|
3018
3110
|
if (!u) return { organizations: g };
|
|
3019
|
-
let [_] = await e.select({ count: r() }).from(
|
|
3111
|
+
let [_] = await e.select({ count: r() }).from(B).where(m);
|
|
3020
3112
|
return {
|
|
3021
3113
|
organizations: g,
|
|
3022
3114
|
start: c * l,
|
|
@@ -3025,13 +3117,13 @@ function Qn(e) {
|
|
|
3025
3117
|
};
|
|
3026
3118
|
},
|
|
3027
3119
|
async remove(n, r) {
|
|
3028
|
-
return (await e.delete(
|
|
3120
|
+
return (await e.delete(B).where(t(a(B.tenant_id, n), a(B.id, r))).returning()).length > 0;
|
|
3029
3121
|
}
|
|
3030
3122
|
};
|
|
3031
3123
|
}
|
|
3032
3124
|
//#endregion
|
|
3033
3125
|
//#region src/adapters/organizationConnections.ts
|
|
3034
|
-
function
|
|
3126
|
+
function tr(e, t) {
|
|
3035
3127
|
return {
|
|
3036
3128
|
connection_id: e.connection_id,
|
|
3037
3129
|
assign_membership_on_login: !!e.assign_membership_on_login,
|
|
@@ -3045,18 +3137,18 @@ function $n(e, t) {
|
|
|
3045
3137
|
updated_at: e.updated_at
|
|
3046
3138
|
};
|
|
3047
3139
|
}
|
|
3048
|
-
function
|
|
3140
|
+
function nr(e) {
|
|
3049
3141
|
async function n(n, r) {
|
|
3050
3142
|
let i = await e.select({
|
|
3051
|
-
name:
|
|
3052
|
-
strategy:
|
|
3053
|
-
}).from(
|
|
3143
|
+
name: z.name,
|
|
3144
|
+
strategy: z.strategy
|
|
3145
|
+
}).from(z).where(t(a(z.tenant_id, n), a(z.id, r))).get();
|
|
3054
3146
|
if (i) return {
|
|
3055
3147
|
name: i.name,
|
|
3056
3148
|
strategy: typeof i.strategy == "string" ? i.strategy : void 0
|
|
3057
3149
|
};
|
|
3058
3150
|
}
|
|
3059
|
-
let r = (e, n, r) => t(a(
|
|
3151
|
+
let r = (e, n, r) => t(a(Ze.tenant_id, e), a(Ze.organization_id, n), a(Ze.connection_id, r));
|
|
3060
3152
|
return {
|
|
3061
3153
|
async create(t, r, i, a) {
|
|
3062
3154
|
let o = a?.importMetadata, s = (/* @__PURE__ */ new Date()).toISOString(), c = {
|
|
@@ -3069,31 +3161,43 @@ function er(e) {
|
|
|
3069
3161
|
created_at: o?.created_at ?? s,
|
|
3070
3162
|
updated_at: o?.updated_at ?? s
|
|
3071
3163
|
};
|
|
3072
|
-
return await e.insert(
|
|
3164
|
+
return await e.insert(Ze).values(c), tr(c, await n(t, i.connection_id));
|
|
3073
3165
|
},
|
|
3074
3166
|
async list(r, i) {
|
|
3075
|
-
let o = await e.select().from(
|
|
3076
|
-
for (let e of o) s.push(
|
|
3167
|
+
let o = await e.select().from(Ze).where(t(a(Ze.tenant_id, r), a(Ze.organization_id, i))).all(), s = [];
|
|
3168
|
+
for (let e of o) s.push(tr(e, await n(r, e.connection_id)));
|
|
3077
3169
|
return s;
|
|
3078
3170
|
},
|
|
3171
|
+
async listCheckpoint(r, i, o = {}) {
|
|
3172
|
+
let s = {
|
|
3173
|
+
sortColumn: Ze.connection_id,
|
|
3174
|
+
idColumn: Ze.connection_id,
|
|
3175
|
+
sortOrder: "asc"
|
|
3176
|
+
}, c = Z(o), { rows: l, next: u } = Dt(await e.select().from(Ze).where(t(a(Ze.tenant_id, r), a(Ze.organization_id, i), Et(o, s))).orderBy(...Tt(s)).limit(c + 1).all(), c, "connection_id", "connection_id"), d = [];
|
|
3177
|
+
for (let e of l) d.push(tr(e, await n(r, e.connection_id)));
|
|
3178
|
+
return {
|
|
3179
|
+
connections: d,
|
|
3180
|
+
next: u
|
|
3181
|
+
};
|
|
3182
|
+
},
|
|
3079
3183
|
async get(t, i, a) {
|
|
3080
|
-
let o = await e.select().from(
|
|
3081
|
-
return o ?
|
|
3184
|
+
let o = await e.select().from(Ze).where(r(t, i, a)).get();
|
|
3185
|
+
return o ? tr(o, await n(t, a)) : null;
|
|
3082
3186
|
},
|
|
3083
3187
|
async update(t, i, a, o) {
|
|
3084
3188
|
let s = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
3085
3189
|
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(
|
|
3087
|
-
return c.length === 0 ? null :
|
|
3190
|
+
let c = await e.update(Ze).set(s).where(r(t, i, a)).returning();
|
|
3191
|
+
return c.length === 0 ? null : tr(c[0], await n(t, a));
|
|
3088
3192
|
},
|
|
3089
3193
|
async remove(t, n, i) {
|
|
3090
|
-
return (await e.delete(
|
|
3194
|
+
return (await e.delete(Ze).where(r(t, n, i)).returning({ id: Ze.connection_id })).length > 0;
|
|
3091
3195
|
}
|
|
3092
3196
|
};
|
|
3093
3197
|
}
|
|
3094
3198
|
//#endregion
|
|
3095
3199
|
//#region src/adapters/logStreams.ts
|
|
3096
|
-
function
|
|
3200
|
+
function rr(e) {
|
|
3097
3201
|
return {
|
|
3098
3202
|
id: e.id,
|
|
3099
3203
|
name: e.name,
|
|
@@ -3106,7 +3210,7 @@ function tr(e) {
|
|
|
3106
3210
|
updated_at: e.updated_at
|
|
3107
3211
|
};
|
|
3108
3212
|
}
|
|
3109
|
-
function
|
|
3213
|
+
function ir(e) {
|
|
3110
3214
|
return {
|
|
3111
3215
|
async create(t, n, r) {
|
|
3112
3216
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
@@ -3121,27 +3225,27 @@ function nr(e) {
|
|
|
3121
3225
|
created_at: i?.created_at ?? a,
|
|
3122
3226
|
updated_at: i?.updated_at ?? a
|
|
3123
3227
|
};
|
|
3124
|
-
return await e.insert(
|
|
3228
|
+
return await e.insert(gt).values(o), rr(o);
|
|
3125
3229
|
},
|
|
3126
3230
|
async get(n, r) {
|
|
3127
|
-
let i = await e.select().from(
|
|
3128
|
-
return i ?
|
|
3231
|
+
let i = await e.select().from(gt).where(t(a(gt.tenant_id, n), a(gt.id, r))).get();
|
|
3232
|
+
return i ? rr(i) : null;
|
|
3129
3233
|
},
|
|
3130
3234
|
async list(t) {
|
|
3131
|
-
return (await e.select().from(
|
|
3235
|
+
return (await e.select().from(gt).where(a(gt.tenant_id, t)).all()).map(rr);
|
|
3132
3236
|
},
|
|
3133
3237
|
async update(n, r, i) {
|
|
3134
3238
|
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(
|
|
3239
|
+
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(gt).set(o).where(t(a(gt.tenant_id, n), a(gt.id, r))).returning({ id: gt.id })).length > 0;
|
|
3136
3240
|
},
|
|
3137
3241
|
async remove(n, r) {
|
|
3138
|
-
return (await e.delete(
|
|
3242
|
+
return (await e.delete(gt).where(t(a(gt.tenant_id, n), a(gt.id, r))).returning({ id: gt.id })).length > 0;
|
|
3139
3243
|
}
|
|
3140
3244
|
};
|
|
3141
3245
|
}
|
|
3142
3246
|
//#endregion
|
|
3143
3247
|
//#region src/adapters/migrationSources.ts
|
|
3144
|
-
function
|
|
3248
|
+
function ar(e) {
|
|
3145
3249
|
return {
|
|
3146
3250
|
id: e.id,
|
|
3147
3251
|
name: e.name,
|
|
@@ -3153,8 +3257,8 @@ function rr(e) {
|
|
|
3153
3257
|
updated_at: e.updated_at
|
|
3154
3258
|
};
|
|
3155
3259
|
}
|
|
3156
|
-
function
|
|
3157
|
-
let n = (e, n) => t(a(
|
|
3260
|
+
function or(e) {
|
|
3261
|
+
let n = (e, n) => t(a(_t.tenant_id, e), a(_t.id, n));
|
|
3158
3262
|
return {
|
|
3159
3263
|
async create(t, n, r) {
|
|
3160
3264
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
@@ -3168,34 +3272,34 @@ function ir(e) {
|
|
|
3168
3272
|
created_at: i?.created_at ?? a,
|
|
3169
3273
|
updated_at: i?.updated_at ?? a
|
|
3170
3274
|
};
|
|
3171
|
-
return await e.insert(
|
|
3275
|
+
return await e.insert(_t).values(o), ar(o);
|
|
3172
3276
|
},
|
|
3173
3277
|
async get(t, r) {
|
|
3174
|
-
let i = await e.select().from(
|
|
3175
|
-
return i ?
|
|
3278
|
+
let i = await e.select().from(_t).where(n(t, r)).get();
|
|
3279
|
+
return i ? ar(i) : null;
|
|
3176
3280
|
},
|
|
3177
3281
|
async list(t) {
|
|
3178
|
-
return (await e.select().from(
|
|
3282
|
+
return (await e.select().from(_t).where(a(_t.tenant_id, t)).all()).map(ar);
|
|
3179
3283
|
},
|
|
3180
3284
|
async update(t, r, i) {
|
|
3181
3285
|
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(
|
|
3286
|
+
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(_t).set(a).where(n(t, r)).returning({ id: _t.id })).length > 0;
|
|
3183
3287
|
},
|
|
3184
3288
|
async remove(t, r) {
|
|
3185
|
-
return (await e.delete(
|
|
3289
|
+
return (await e.delete(_t).where(n(t, r)).returning({ id: _t.id })).length > 0;
|
|
3186
3290
|
}
|
|
3187
3291
|
};
|
|
3188
3292
|
}
|
|
3189
3293
|
//#endregion
|
|
3190
3294
|
//#region src/adapters/passwords.ts
|
|
3191
|
-
function
|
|
3295
|
+
function sr(e) {
|
|
3192
3296
|
let { tenant_id: t, is_current: n, ...r } = e;
|
|
3193
3297
|
return {
|
|
3194
3298
|
...r,
|
|
3195
3299
|
is_current: !!n
|
|
3196
3300
|
};
|
|
3197
3301
|
}
|
|
3198
|
-
function
|
|
3302
|
+
function cr(e) {
|
|
3199
3303
|
return {
|
|
3200
3304
|
async create(n, r) {
|
|
3201
3305
|
let i = (/* @__PURE__ */ new Date()).toISOString(), o = r.id || b();
|
|
@@ -3210,18 +3314,18 @@ function or(e) {
|
|
|
3210
3314
|
created_at: i,
|
|
3211
3315
|
updated_at: i
|
|
3212
3316
|
};
|
|
3213
|
-
return await e.insert(j).values(s),
|
|
3317
|
+
return await e.insert(j).values(s), sr({
|
|
3214
3318
|
...s,
|
|
3215
3319
|
tenant_id: n
|
|
3216
3320
|
});
|
|
3217
3321
|
},
|
|
3218
3322
|
async get(n, r) {
|
|
3219
3323
|
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();
|
|
3220
|
-
return i ?
|
|
3324
|
+
return i ? sr(i) : null;
|
|
3221
3325
|
},
|
|
3222
3326
|
async list(n, r, o) {
|
|
3223
3327
|
let s = e.select().from(j).where(t(a(j.tenant_id, n), a(j.user_id, r))).orderBy(i(j.created_at)).$dynamic();
|
|
3224
|
-
return o && (s = s.limit(o)), (await s).map(
|
|
3328
|
+
return o && (s = s.limit(o)), (await s).map(sr);
|
|
3225
3329
|
},
|
|
3226
3330
|
async update(n, r) {
|
|
3227
3331
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -3231,10 +3335,10 @@ function or(e) {
|
|
|
3231
3335
|
}
|
|
3232
3336
|
//#endregion
|
|
3233
3337
|
//#region src/adapters/promptSettings.ts
|
|
3234
|
-
function
|
|
3338
|
+
function lr(e) {
|
|
3235
3339
|
return {
|
|
3236
3340
|
async get(t) {
|
|
3237
|
-
let n = await e.select().from(
|
|
3341
|
+
let n = await e.select().from(it).where(a(it.tenant_id, t)).get();
|
|
3238
3342
|
return n ? {
|
|
3239
3343
|
universal_login_experience: n.universal_login_experience,
|
|
3240
3344
|
identifier_first: !!n.identifier_first,
|
|
@@ -3250,7 +3354,7 @@ function sr(e) {
|
|
|
3250
3354
|
};
|
|
3251
3355
|
},
|
|
3252
3356
|
async set(t, n) {
|
|
3253
|
-
await e.insert(
|
|
3357
|
+
await e.insert(it).values({
|
|
3254
3358
|
tenant_id: t,
|
|
3255
3359
|
universal_login_experience: n.universal_login_experience,
|
|
3256
3360
|
identifier_first: n.identifier_first,
|
|
@@ -3258,7 +3362,7 @@ function sr(e) {
|
|
|
3258
3362
|
webauthn_platform_first_factor: n.webauthn_platform_first_factor,
|
|
3259
3363
|
show_last_used_connection: n.show_last_used_connection
|
|
3260
3364
|
}).onConflictDoUpdate({
|
|
3261
|
-
target:
|
|
3365
|
+
target: it.tenant_id,
|
|
3262
3366
|
set: {
|
|
3263
3367
|
universal_login_experience: n.universal_login_experience,
|
|
3264
3368
|
identifier_first: n.identifier_first,
|
|
@@ -3272,10 +3376,10 @@ function sr(e) {
|
|
|
3272
3376
|
}
|
|
3273
3377
|
//#endregion
|
|
3274
3378
|
//#region src/adapters/promptPartials.ts
|
|
3275
|
-
function
|
|
3379
|
+
function ur(e) {
|
|
3276
3380
|
return {
|
|
3277
3381
|
async get(n, r) {
|
|
3278
|
-
let i = await e.select({ body:
|
|
3382
|
+
let i = await e.select({ body: dt.body }).from(dt).where(t(a(dt.tenant_id, n), a(dt.prompt, r))).get();
|
|
3279
3383
|
if (!i) return null;
|
|
3280
3384
|
try {
|
|
3281
3385
|
return JSON.parse(i.body);
|
|
@@ -3285,14 +3389,14 @@ function cr(e) {
|
|
|
3285
3389
|
},
|
|
3286
3390
|
async set(t, n, r, i) {
|
|
3287
3391
|
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);
|
|
3288
|
-
await e.insert(
|
|
3392
|
+
await e.insert(dt).values({
|
|
3289
3393
|
tenant_id: t,
|
|
3290
3394
|
prompt: n,
|
|
3291
3395
|
body: u,
|
|
3292
3396
|
created_at_ts: c,
|
|
3293
3397
|
updated_at_ts: l
|
|
3294
3398
|
}).onConflictDoUpdate({
|
|
3295
|
-
target: [
|
|
3399
|
+
target: [dt.tenant_id, dt.prompt],
|
|
3296
3400
|
set: {
|
|
3297
3401
|
body: u,
|
|
3298
3402
|
updated_at_ts: s ? l : a
|
|
@@ -3300,16 +3404,16 @@ function cr(e) {
|
|
|
3300
3404
|
});
|
|
3301
3405
|
},
|
|
3302
3406
|
async delete(n, r) {
|
|
3303
|
-
await e.delete(
|
|
3407
|
+
await e.delete(dt).where(t(a(dt.tenant_id, n), a(dt.prompt, r)));
|
|
3304
3408
|
},
|
|
3305
3409
|
async list(t) {
|
|
3306
|
-
return (await e.select({ prompt:
|
|
3410
|
+
return (await e.select({ prompt: dt.prompt }).from(dt).where(a(dt.tenant_id, t)).all()).map(({ prompt: e }) => e);
|
|
3307
3411
|
}
|
|
3308
3412
|
};
|
|
3309
3413
|
}
|
|
3310
3414
|
//#endregion
|
|
3311
3415
|
//#region src/adapters/proxyRoutes.ts
|
|
3312
|
-
function
|
|
3416
|
+
function dr(e) {
|
|
3313
3417
|
if (!e) return { path: "/*" };
|
|
3314
3418
|
try {
|
|
3315
3419
|
let t = JSON.parse(e), n = xe.safeParse(t);
|
|
@@ -3317,7 +3421,7 @@ function lr(e) {
|
|
|
3317
3421
|
} catch {}
|
|
3318
3422
|
return { path: "/*" };
|
|
3319
3423
|
}
|
|
3320
|
-
function
|
|
3424
|
+
function fr(e) {
|
|
3321
3425
|
if (!e) return [];
|
|
3322
3426
|
try {
|
|
3323
3427
|
let t = JSON.parse(e);
|
|
@@ -3332,19 +3436,19 @@ function ur(e) {
|
|
|
3332
3436
|
return [];
|
|
3333
3437
|
}
|
|
3334
3438
|
}
|
|
3335
|
-
function
|
|
3439
|
+
function pr(e) {
|
|
3336
3440
|
return {
|
|
3337
3441
|
id: e.id,
|
|
3338
3442
|
tenant_id: e.tenant_id,
|
|
3339
3443
|
custom_domain_id: e.custom_domain_id,
|
|
3340
3444
|
priority: e.priority,
|
|
3341
|
-
match:
|
|
3342
|
-
handlers:
|
|
3445
|
+
match: dr(e.match),
|
|
3446
|
+
handlers: fr(e.handlers),
|
|
3343
3447
|
created_at: e.created_at,
|
|
3344
3448
|
updated_at: e.updated_at
|
|
3345
3449
|
};
|
|
3346
3450
|
}
|
|
3347
|
-
function
|
|
3451
|
+
function mr(e) {
|
|
3348
3452
|
return {
|
|
3349
3453
|
async create(t, n) {
|
|
3350
3454
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -3357,7 +3461,7 @@ function fr(e) {
|
|
|
3357
3461
|
created_at: r,
|
|
3358
3462
|
updated_at: r
|
|
3359
3463
|
};
|
|
3360
|
-
return await e.insert(
|
|
3464
|
+
return await e.insert(J).values({
|
|
3361
3465
|
id: i.id,
|
|
3362
3466
|
tenant_id: i.tenant_id,
|
|
3363
3467
|
custom_domain_id: i.custom_domain_id,
|
|
@@ -3369,15 +3473,15 @@ function fr(e) {
|
|
|
3369
3473
|
}), i;
|
|
3370
3474
|
},
|
|
3371
3475
|
async get(n, r) {
|
|
3372
|
-
let i = await e.select().from(
|
|
3373
|
-
return i[0] ?
|
|
3476
|
+
let i = await e.select().from(J).where(t(a(J.tenant_id, n), a(J.id, r))).limit(1);
|
|
3477
|
+
return i[0] ? pr(i[0]) : null;
|
|
3374
3478
|
},
|
|
3375
3479
|
async list(r, i = {}) {
|
|
3376
|
-
let o = i.page ?? 0, s = i.per_page ?? 50, c = [a(
|
|
3377
|
-
i.custom_domain_id && c.push(a(
|
|
3378
|
-
let l = await e.select().from(
|
|
3480
|
+
let o = i.page ?? 0, s = i.per_page ?? 50, c = [a(J.tenant_id, r)];
|
|
3481
|
+
i.custom_domain_id && c.push(a(J.custom_domain_id, i.custom_domain_id));
|
|
3482
|
+
let l = await e.select().from(J).where(t(...c)).orderBy(n(J.priority), n(J.created_at)).offset(o * s).limit(s);
|
|
3379
3483
|
return {
|
|
3380
|
-
proxy_routes: l.map(
|
|
3484
|
+
proxy_routes: l.map(pr),
|
|
3381
3485
|
start: o * s,
|
|
3382
3486
|
limit: s,
|
|
3383
3487
|
length: l.length
|
|
@@ -3386,18 +3490,18 @@ function fr(e) {
|
|
|
3386
3490
|
async update(n, r, i) {
|
|
3387
3491
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
3388
3492
|
i.priority !== void 0 && (o.priority = i.priority), i.match !== void 0 && (o.match = JSON.stringify(i.match)), i.handlers !== void 0 && (o.handlers = JSON.stringify(i.handlers));
|
|
3389
|
-
let s = (await e.update(
|
|
3390
|
-
return typeof s == "number" ? s > 0 : (await e.select({ id:
|
|
3493
|
+
let s = (await e.update(J).set(o).where(t(a(J.tenant_id, n), a(J.id, r))))?.changes;
|
|
3494
|
+
return typeof s == "number" ? s > 0 : (await e.select({ id: J.id }).from(J).where(t(a(J.tenant_id, n), a(J.id, r))).limit(1)).length > 0;
|
|
3391
3495
|
},
|
|
3392
3496
|
async remove(n, r) {
|
|
3393
|
-
return (await e.select({ id:
|
|
3497
|
+
return (await e.select({ id: J.id }).from(J).where(t(a(J.tenant_id, n), a(J.id, r))).limit(1)).length === 0 ? !1 : (await e.delete(J).where(t(a(J.tenant_id, n), a(J.id, r))), !0);
|
|
3394
3498
|
}
|
|
3395
3499
|
};
|
|
3396
3500
|
}
|
|
3397
3501
|
//#endregion
|
|
3398
3502
|
//#region src/adapters/tokenExchangeProfiles.ts
|
|
3399
|
-
var
|
|
3400
|
-
function
|
|
3503
|
+
var hr = ee("0123456789abcdefghijklmnopqrstuvwxyz", 17);
|
|
3504
|
+
function gr(e) {
|
|
3401
3505
|
if (e) try {
|
|
3402
3506
|
let t = Ie.safeParse(JSON.parse(e));
|
|
3403
3507
|
return t.success ? t.data : void 0;
|
|
@@ -3405,7 +3509,7 @@ function mr(e) {
|
|
|
3405
3509
|
return;
|
|
3406
3510
|
}
|
|
3407
3511
|
}
|
|
3408
|
-
function
|
|
3512
|
+
function _r(e) {
|
|
3409
3513
|
let t = {
|
|
3410
3514
|
id: e.id,
|
|
3411
3515
|
name: e.name,
|
|
@@ -3415,14 +3519,14 @@ function hr(e) {
|
|
|
3415
3519
|
updated_at: e.updated_at
|
|
3416
3520
|
};
|
|
3417
3521
|
e.action_id && (t.action_id = e.action_id);
|
|
3418
|
-
let n =
|
|
3522
|
+
let n = gr(e.jwt_verification);
|
|
3419
3523
|
return n && (t.jwt_verification = n), t;
|
|
3420
3524
|
}
|
|
3421
|
-
function
|
|
3525
|
+
function vr(e) {
|
|
3422
3526
|
return {
|
|
3423
3527
|
async create(t, n, r) {
|
|
3424
3528
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
3425
|
-
id: i?.id ?? `tep_${
|
|
3529
|
+
id: i?.id ?? `tep_${hr()}`,
|
|
3426
3530
|
tenant_id: t,
|
|
3427
3531
|
name: n.name,
|
|
3428
3532
|
subject_token_type: n.subject_token_type,
|
|
@@ -3432,27 +3536,27 @@ function gr(e) {
|
|
|
3432
3536
|
created_at: i?.created_at ?? a,
|
|
3433
3537
|
updated_at: i?.updated_at ?? a
|
|
3434
3538
|
};
|
|
3435
|
-
return await e.insert(
|
|
3539
|
+
return await e.insert(ht).values(o), _r(o);
|
|
3436
3540
|
},
|
|
3437
3541
|
async get(n, r) {
|
|
3438
|
-
let i = await e.select().from(
|
|
3439
|
-
return i[0] ?
|
|
3542
|
+
let i = await e.select().from(ht).where(t(a(ht.tenant_id, n), a(ht.id, r))).limit(1);
|
|
3543
|
+
return i[0] ? _r(i[0]) : null;
|
|
3440
3544
|
},
|
|
3441
3545
|
async list(t) {
|
|
3442
|
-
return (await e.select().from(
|
|
3546
|
+
return (await e.select().from(ht).where(a(ht.tenant_id, t)).orderBy(n(ht.created_at), n(ht.id))).map(_r);
|
|
3443
3547
|
},
|
|
3444
3548
|
async update(n, r, i) {
|
|
3445
3549
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
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(
|
|
3550
|
+
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(ht).set(o).where(t(a(ht.tenant_id, n), a(ht.id, r))).returning({ id: ht.id })).length > 0;
|
|
3447
3551
|
},
|
|
3448
3552
|
async remove(n, r) {
|
|
3449
|
-
return (await e.delete(
|
|
3553
|
+
return (await e.delete(ht).where(t(a(ht.tenant_id, n), a(ht.id, r))).returning({ id: ht.id })).length > 0;
|
|
3450
3554
|
}
|
|
3451
3555
|
};
|
|
3452
3556
|
}
|
|
3453
3557
|
//#endregion
|
|
3454
3558
|
//#region src/adapters/scim.ts
|
|
3455
|
-
function
|
|
3559
|
+
function yr(e) {
|
|
3456
3560
|
if (!e) return [];
|
|
3457
3561
|
try {
|
|
3458
3562
|
let t = JSON.parse(e);
|
|
@@ -3467,7 +3571,7 @@ function _r(e) {
|
|
|
3467
3571
|
return [];
|
|
3468
3572
|
}
|
|
3469
3573
|
}
|
|
3470
|
-
function
|
|
3574
|
+
function br(e) {
|
|
3471
3575
|
if (!e) return [];
|
|
3472
3576
|
try {
|
|
3473
3577
|
let t = JSON.parse(e);
|
|
@@ -3476,16 +3580,16 @@ function vr(e) {
|
|
|
3476
3580
|
return [];
|
|
3477
3581
|
}
|
|
3478
3582
|
}
|
|
3479
|
-
function
|
|
3583
|
+
function xr(e) {
|
|
3480
3584
|
return {
|
|
3481
3585
|
connection_id: e.connection_id,
|
|
3482
3586
|
user_id_attribute: e.user_id_attribute,
|
|
3483
|
-
mapping:
|
|
3587
|
+
mapping: yr(e.mapping),
|
|
3484
3588
|
created_at: e.created_at,
|
|
3485
3589
|
updated_at: e.updated_at
|
|
3486
3590
|
};
|
|
3487
3591
|
}
|
|
3488
|
-
function
|
|
3592
|
+
function Sr(e) {
|
|
3489
3593
|
return {
|
|
3490
3594
|
async create(t, n) {
|
|
3491
3595
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -3495,7 +3599,7 @@ function br(e) {
|
|
|
3495
3599
|
created_at: r,
|
|
3496
3600
|
updated_at: r
|
|
3497
3601
|
};
|
|
3498
|
-
return await e.insert(
|
|
3602
|
+
return await e.insert(pt).values({
|
|
3499
3603
|
connection_id: i.connection_id,
|
|
3500
3604
|
tenant_id: t,
|
|
3501
3605
|
user_id_attribute: i.user_id_attribute,
|
|
@@ -3505,31 +3609,31 @@ function br(e) {
|
|
|
3505
3609
|
}), i;
|
|
3506
3610
|
},
|
|
3507
3611
|
async get(n, r) {
|
|
3508
|
-
let i = await e.select().from(
|
|
3509
|
-
return i[0] ?
|
|
3612
|
+
let i = await e.select().from(pt).where(t(a(pt.tenant_id, n), a(pt.connection_id, r))).limit(1);
|
|
3613
|
+
return i[0] ? xr(i[0]) : null;
|
|
3510
3614
|
},
|
|
3511
3615
|
async update(n, r, i) {
|
|
3512
|
-
if ((await e.select({ connection_id:
|
|
3616
|
+
if ((await e.select({ connection_id: pt.connection_id }).from(pt).where(t(a(pt.tenant_id, n), a(pt.connection_id, r))).limit(1)).length === 0) return !1;
|
|
3513
3617
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
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(
|
|
3618
|
+
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(pt).set(o).where(t(a(pt.tenant_id, n), a(pt.connection_id, r))), !0;
|
|
3515
3619
|
},
|
|
3516
3620
|
async remove(n, r) {
|
|
3517
|
-
return (await e.select({ connection_id:
|
|
3621
|
+
return (await e.select({ connection_id: pt.connection_id }).from(pt).where(t(a(pt.tenant_id, n), a(pt.connection_id, r))).limit(1)).length === 0 ? !1 : (await e.delete(pt).where(t(a(pt.tenant_id, n), a(pt.connection_id, r))), !0);
|
|
3518
3622
|
}
|
|
3519
3623
|
};
|
|
3520
3624
|
}
|
|
3521
|
-
function
|
|
3625
|
+
function Cr(e) {
|
|
3522
3626
|
return {
|
|
3523
3627
|
token_id: e.token_id,
|
|
3524
3628
|
connection_id: e.connection_id,
|
|
3525
3629
|
token_hash: e.token_hash,
|
|
3526
|
-
scopes:
|
|
3630
|
+
scopes: br(e.scopes),
|
|
3527
3631
|
valid_until: e.valid_until ?? void 0,
|
|
3528
3632
|
created_at: e.created_at,
|
|
3529
3633
|
last_used_at: e.last_used_at ?? void 0
|
|
3530
3634
|
};
|
|
3531
3635
|
}
|
|
3532
|
-
function
|
|
3636
|
+
function wr(e) {
|
|
3533
3637
|
return {
|
|
3534
3638
|
async create(t, n) {
|
|
3535
3639
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -3540,7 +3644,7 @@ function Sr(e) {
|
|
|
3540
3644
|
valid_until: n.valid_until,
|
|
3541
3645
|
created_at: r
|
|
3542
3646
|
};
|
|
3543
|
-
return await e.insert(
|
|
3647
|
+
return await e.insert(Y).values({
|
|
3544
3648
|
token_id: i.token_id,
|
|
3545
3649
|
tenant_id: t,
|
|
3546
3650
|
connection_id: i.connection_id,
|
|
@@ -3551,25 +3655,25 @@ function Sr(e) {
|
|
|
3551
3655
|
}), i;
|
|
3552
3656
|
},
|
|
3553
3657
|
async get(n, r) {
|
|
3554
|
-
let i = await e.select().from(
|
|
3555
|
-
return i[0] ?
|
|
3658
|
+
let i = await e.select().from(Y).where(t(a(Y.tenant_id, n), a(Y.token_id, r))).limit(1);
|
|
3659
|
+
return i[0] ? Cr(i[0]) : null;
|
|
3556
3660
|
},
|
|
3557
3661
|
async getByHash(n, r) {
|
|
3558
|
-
let i = await e.select().from(
|
|
3559
|
-
return i[0] ?
|
|
3662
|
+
let i = await e.select().from(Y).where(t(a(Y.tenant_id, n), a(Y.token_hash, r))).limit(1);
|
|
3663
|
+
return i[0] ? Cr(i[0]) : null;
|
|
3560
3664
|
},
|
|
3561
3665
|
async listByConnection(n, r) {
|
|
3562
|
-
return (await e.select().from(
|
|
3666
|
+
return (await e.select().from(Y).where(t(a(Y.tenant_id, n), a(Y.connection_id, r)))).map(Cr);
|
|
3563
3667
|
},
|
|
3564
3668
|
async markUsed(n, r, i) {
|
|
3565
|
-
return (await e.select({ token_id:
|
|
3669
|
+
return (await e.select({ token_id: Y.token_id }).from(Y).where(t(a(Y.tenant_id, n), a(Y.token_id, r))).limit(1)).length === 0 ? !1 : (await e.update(Y).set({ last_used_at: i }).where(t(a(Y.tenant_id, n), a(Y.token_id, r))), !0);
|
|
3566
3670
|
},
|
|
3567
3671
|
async remove(n, r) {
|
|
3568
|
-
return (await e.select({ token_id:
|
|
3672
|
+
return (await e.select({ token_id: Y.token_id }).from(Y).where(t(a(Y.tenant_id, n), a(Y.token_id, r))).limit(1)).length === 0 ? !1 : (await e.delete(Y).where(t(a(Y.tenant_id, n), a(Y.token_id, r))), !0);
|
|
3569
3673
|
}
|
|
3570
3674
|
};
|
|
3571
3675
|
}
|
|
3572
|
-
function
|
|
3676
|
+
function Tr(e) {
|
|
3573
3677
|
return {
|
|
3574
3678
|
connection_id: e.connection_id,
|
|
3575
3679
|
external_id: e.external_id,
|
|
@@ -3577,7 +3681,7 @@ function Cr(e) {
|
|
|
3577
3681
|
created_at: e.created_at
|
|
3578
3682
|
};
|
|
3579
3683
|
}
|
|
3580
|
-
function
|
|
3684
|
+
function Er(e) {
|
|
3581
3685
|
return {
|
|
3582
3686
|
async create(t, n) {
|
|
3583
3687
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -3586,7 +3690,7 @@ function wr(e) {
|
|
|
3586
3690
|
user_id: n.user_id,
|
|
3587
3691
|
created_at: r
|
|
3588
3692
|
};
|
|
3589
|
-
return await e.insert(
|
|
3693
|
+
return await e.insert(mt).values({
|
|
3590
3694
|
tenant_id: t,
|
|
3591
3695
|
connection_id: i.connection_id,
|
|
3592
3696
|
external_id: i.external_id,
|
|
@@ -3595,21 +3699,21 @@ function wr(e) {
|
|
|
3595
3699
|
}), i;
|
|
3596
3700
|
},
|
|
3597
3701
|
async getByExternalId(n, r, i) {
|
|
3598
|
-
let o = await e.select().from(
|
|
3599
|
-
return o[0] ?
|
|
3702
|
+
let o = await e.select().from(mt).where(t(a(mt.tenant_id, n), a(mt.connection_id, r), a(mt.external_id, i))).limit(1);
|
|
3703
|
+
return o[0] ? Tr(o[0]) : null;
|
|
3600
3704
|
},
|
|
3601
3705
|
async getByUserId(n, r, i) {
|
|
3602
|
-
let o = await e.select().from(
|
|
3603
|
-
return o[0] ?
|
|
3706
|
+
let o = await e.select().from(mt).where(t(a(mt.tenant_id, n), a(mt.connection_id, r), a(mt.user_id, i))).limit(1);
|
|
3707
|
+
return o[0] ? Tr(o[0]) : null;
|
|
3604
3708
|
},
|
|
3605
3709
|
async remove(n, r, i) {
|
|
3606
|
-
return (await e.select({ user_id:
|
|
3710
|
+
return (await e.select({ user_id: mt.user_id }).from(mt).where(t(a(mt.tenant_id, n), a(mt.connection_id, r), a(mt.user_id, i))).limit(1)).length === 0 ? !1 : (await e.delete(mt).where(t(a(mt.tenant_id, n), a(mt.connection_id, r), a(mt.user_id, i))), !0);
|
|
3607
3711
|
}
|
|
3608
3712
|
};
|
|
3609
3713
|
}
|
|
3610
3714
|
//#endregion
|
|
3611
3715
|
//#region src/adapters/refreshTokens.ts
|
|
3612
|
-
function
|
|
3716
|
+
function Dr(e) {
|
|
3613
3717
|
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({
|
|
3614
3718
|
created_at_ts: n,
|
|
3615
3719
|
expires_at_ts: r,
|
|
@@ -3628,18 +3732,18 @@ function Tr(e) {
|
|
|
3628
3732
|
...p,
|
|
3629
3733
|
...m,
|
|
3630
3734
|
rotating: !!u,
|
|
3631
|
-
device:
|
|
3632
|
-
resource_servers:
|
|
3735
|
+
device: X(c, {}),
|
|
3736
|
+
resource_servers: X(l, []),
|
|
3633
3737
|
...d && f ? { auth_strategy: {
|
|
3634
3738
|
strategy: d,
|
|
3635
3739
|
strategy_type: f
|
|
3636
3740
|
} } : {}
|
|
3637
3741
|
});
|
|
3638
3742
|
}
|
|
3639
|
-
function
|
|
3743
|
+
function Or(e, t) {
|
|
3640
3744
|
return Math.max(e ?? 0, t ?? 0);
|
|
3641
3745
|
}
|
|
3642
|
-
function
|
|
3746
|
+
function kr(e) {
|
|
3643
3747
|
return {
|
|
3644
3748
|
async create(n, r) {
|
|
3645
3749
|
let i = Date.now(), o = {
|
|
@@ -3665,44 +3769,39 @@ function Dr(e) {
|
|
|
3665
3769
|
expires_at_ts: E(r.expires_at),
|
|
3666
3770
|
idle_expires_at_ts: E(r.idle_expires_at),
|
|
3667
3771
|
last_exchanged_at_ts: E(r.last_exchanged_at)
|
|
3668
|
-
}, s = [e.insert(N).values(o)], c =
|
|
3772
|
+
}, s = [e.insert(N).values(o)], c = Or(o.expires_at_ts, o.idle_expires_at_ts);
|
|
3669
3773
|
return c > 0 && o.login_id && s.push(e.update(P).set({
|
|
3670
3774
|
expires_at_ts: c,
|
|
3671
3775
|
updated_at_ts: i
|
|
3672
|
-
}).where(t(a(P.tenant_id, n), a(P.id, o.login_id), m(P.expires_at_ts, c)))), await
|
|
3776
|
+
}).where(t(a(P.tenant_id, n), a(P.id, o.login_id), m(P.expires_at_ts, c)))), await Pt(e, s), Dr({
|
|
3673
3777
|
...o,
|
|
3674
3778
|
tenant_id: n
|
|
3675
3779
|
});
|
|
3676
3780
|
},
|
|
3677
3781
|
async get(n, r) {
|
|
3678
3782
|
let i = await e.select().from(N).where(t(a(N.tenant_id, n), a(N.id, r))).get();
|
|
3679
|
-
return i ?
|
|
3783
|
+
return i ? Dr(i) : null;
|
|
3680
3784
|
},
|
|
3681
3785
|
async getByLookup(n, r) {
|
|
3682
3786
|
let i = await e.select().from(N).where(t(a(N.tenant_id, n), a(N.token_lookup, r))).get();
|
|
3683
|
-
return i ?
|
|
3787
|
+
return i ? Dr(i) : null;
|
|
3684
3788
|
},
|
|
3685
|
-
async update(n, r, i
|
|
3686
|
-
let
|
|
3687
|
-
i.device !== void 0 && (
|
|
3688
|
-
let c = o?.loginSessionBump, l = c ? E(c.expires_at) : null, u = await e.update(N).set(s).where(t(a(N.tenant_id, n), a(N.id, r))).returning();
|
|
3689
|
-
return c?.login_id && l && l > 0 && await e.update(P).set({
|
|
3690
|
-
expires_at_ts: l,
|
|
3691
|
-
updated_at_ts: Date.now()
|
|
3692
|
-
}).where(t(a(P.tenant_id, n), a(P.id, c.login_id), m(P.expires_at_ts, l))).catch(() => {}), u.length > 0;
|
|
3789
|
+
async update(n, r, i) {
|
|
3790
|
+
let o = {};
|
|
3791
|
+
return i.device !== void 0 && (o.device = JSON.stringify(i.device)), i.resource_servers !== void 0 && (o.resource_servers = JSON.stringify(i.resource_servers)), i.rotating !== void 0 && (o.rotating = i.rotating), i.token_lookup !== void 0 && (o.token_lookup = i.token_lookup), i.token_hash !== void 0 && (o.token_hash = i.token_hash), i.family_id !== void 0 && (o.family_id = i.family_id), i.rotated_to !== void 0 && (o.rotated_to = i.rotated_to), i.rotated_at !== void 0 && (o.rotated_at_ts = E(i.rotated_at)), 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.last_exchanged_at !== void 0 && (o.last_exchanged_at_ts = E(i.last_exchanged_at)), i.revoked_at !== void 0 && (o.revoked_at_ts = E(i.revoked_at)), (await e.update(N).set(o).where(t(a(N.tenant_id, n), a(N.id, r))).returning()).length > 0;
|
|
3693
3792
|
},
|
|
3694
3793
|
async list(o, s) {
|
|
3695
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
3794
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? Ct(N, f, ["user_id", "login_id"]) : void 0, m = [
|
|
3696
3795
|
a(N.tenant_id, o),
|
|
3697
3796
|
...s?.user_id === void 0 ? [] : [a(N.user_id, s.user_id)],
|
|
3698
3797
|
...p ? [p] : []
|
|
3699
3798
|
], h = m.length === 1 ? m[0] : t(...m);
|
|
3700
|
-
if (
|
|
3799
|
+
if (wt(s)) {
|
|
3701
3800
|
let n = {
|
|
3702
3801
|
sortColumn: N.created_at_ts,
|
|
3703
3802
|
idColumn: N.id,
|
|
3704
3803
|
sortOrder: "desc"
|
|
3705
|
-
}, r =
|
|
3804
|
+
}, r = Et(s, n), i = Z(s), { rows: a, next: o } = Dt(await e.select().from(N).where(r ? t(h, r) : h).orderBy(...Tt(n)).limit(i + 1), i, "created_at_ts"), c = a.map(Dr);
|
|
3706
3805
|
return {
|
|
3707
3806
|
refresh_tokens: c,
|
|
3708
3807
|
start: 0,
|
|
@@ -3716,7 +3815,7 @@ function Dr(e) {
|
|
|
3716
3815
|
let e = N[d.sort_by];
|
|
3717
3816
|
e && (g = g.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
3718
3817
|
}
|
|
3719
|
-
let _ = (await g.offset(c * l).limit(l)).map(
|
|
3818
|
+
let _ = (await g.offset(c * l).limit(l)).map(Dr);
|
|
3720
3819
|
if (!u) return { refresh_tokens: _ };
|
|
3721
3820
|
let [v] = await e.select({ count: r() }).from(N).where(h);
|
|
3722
3821
|
return {
|
|
@@ -3745,15 +3844,15 @@ function Dr(e) {
|
|
|
3745
3844
|
}
|
|
3746
3845
|
//#endregion
|
|
3747
3846
|
//#region src/adapters/resourceServers.ts
|
|
3748
|
-
var
|
|
3749
|
-
function
|
|
3847
|
+
var Ar = ["name", "identifier"];
|
|
3848
|
+
function jr() {
|
|
3750
3849
|
return `api_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
3751
3850
|
}
|
|
3752
|
-
var
|
|
3851
|
+
var Mr = [
|
|
3753
3852
|
"skip_consent_for_verifiable_first_party_clients",
|
|
3754
3853
|
"allow_offline_access",
|
|
3755
3854
|
"is_system"
|
|
3756
|
-
],
|
|
3855
|
+
], Nr = new Set([
|
|
3757
3856
|
"id",
|
|
3758
3857
|
"tenant_id",
|
|
3759
3858
|
"identifier",
|
|
@@ -3772,17 +3871,17 @@ var Ar = [
|
|
|
3772
3871
|
"created_at",
|
|
3773
3872
|
"updated_at"
|
|
3774
3873
|
]);
|
|
3775
|
-
function
|
|
3874
|
+
function Pr(e) {
|
|
3776
3875
|
let { tenant_id: t, verification_key: n, scopes: r, options: i, metadata: a, ...o } = e, s = { ...o };
|
|
3777
|
-
s.scopes =
|
|
3778
|
-
for (let e of
|
|
3876
|
+
s.scopes = X(r, []), s.options = X(i, {}), s.metadata = X(a), n !== void 0 && (s.verificationKey = n);
|
|
3877
|
+
for (let e of Mr) o[e] !== void 0 && o[e] !== null && (s[e] = !!o[e]);
|
|
3779
3878
|
return D(s);
|
|
3780
3879
|
}
|
|
3781
|
-
function
|
|
3880
|
+
function Fr(e) {
|
|
3782
3881
|
return {
|
|
3783
3882
|
async create(t, n) {
|
|
3784
3883
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
3785
|
-
id: n.id ||
|
|
3884
|
+
id: n.id || jr(),
|
|
3786
3885
|
tenant_id: t,
|
|
3787
3886
|
identifier: n.identifier,
|
|
3788
3887
|
name: n.name,
|
|
@@ -3797,37 +3896,37 @@ function Nr(e) {
|
|
|
3797
3896
|
created_at: r,
|
|
3798
3897
|
updated_at: r
|
|
3799
3898
|
};
|
|
3800
|
-
for (let e of
|
|
3801
|
-
return i.is_system === void 0 && (i.is_system = 0), await e.insert(
|
|
3899
|
+
for (let e of Mr) n[e] !== void 0 && (i[e] = +!!n[e]);
|
|
3900
|
+
return i.is_system === void 0 && (i.is_system = 0), await e.insert(G).values(i), Pr({
|
|
3802
3901
|
...i,
|
|
3803
3902
|
tenant_id: t
|
|
3804
3903
|
});
|
|
3805
3904
|
},
|
|
3806
3905
|
async get(n, r) {
|
|
3807
|
-
let i = await e.select().from(
|
|
3808
|
-
return i ?
|
|
3906
|
+
let i = await e.select().from(G).where(t(a(G.tenant_id, n), a(G.id, r))).get();
|
|
3907
|
+
return i ? Pr(i) : null;
|
|
3809
3908
|
},
|
|
3810
3909
|
async update(n, r, i) {
|
|
3811
3910
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
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(${
|
|
3813
|
-
for (let e of
|
|
3814
|
-
return (await e.update(
|
|
3911
|
+
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(${G.options}, '{}'), ${JSON.stringify(i.options)})`), i.metadata !== void 0 && (o.metadata = JSON.stringify(i.metadata)), i.verificationKey !== void 0 && (o.verification_key = i.verificationKey);
|
|
3912
|
+
for (let e of Mr) i[e] !== void 0 && (o[e] = +!!i[e]);
|
|
3913
|
+
return (await e.update(G).set(o).where(t(a(G.tenant_id, n), a(G.id, r))).returning()).length > 0;
|
|
3815
3914
|
},
|
|
3816
3915
|
async list(o, s) {
|
|
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(
|
|
3916
|
+
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(G.tenant_id, o)];
|
|
3818
3917
|
if (f) {
|
|
3819
|
-
let e = Ee(f,
|
|
3918
|
+
let e = Ee(f, Ar);
|
|
3820
3919
|
if (e) {
|
|
3821
|
-
let t =
|
|
3920
|
+
let t = Ct(G, e, Ar, ["name", "identifier"]);
|
|
3822
3921
|
t && h.push(t);
|
|
3823
3922
|
}
|
|
3824
3923
|
}
|
|
3825
|
-
if (
|
|
3924
|
+
if (wt(s)) {
|
|
3826
3925
|
let n = {
|
|
3827
|
-
sortColumn:
|
|
3828
|
-
idColumn:
|
|
3926
|
+
sortColumn: G.created_at,
|
|
3927
|
+
idColumn: G.id,
|
|
3829
3928
|
sortOrder: "desc"
|
|
3830
|
-
}, r =
|
|
3929
|
+
}, r = Et(s, n), i = Z(s), { rows: a, next: o } = Dt(await e.select().from(G).where(t(...h, r)).orderBy(...Tt(n)).limit(i + 1), i, "created_at", "id"), c = a.map(Pr);
|
|
3831
3930
|
return {
|
|
3832
3931
|
resource_servers: c,
|
|
3833
3932
|
start: 0,
|
|
@@ -3836,14 +3935,14 @@ function Nr(e) {
|
|
|
3836
3935
|
next: o
|
|
3837
3936
|
};
|
|
3838
3937
|
}
|
|
3839
|
-
let g = e.select().from(
|
|
3840
|
-
if (d?.sort_by &&
|
|
3841
|
-
let e =
|
|
3938
|
+
let g = e.select().from(G).where(t(...h)).$dynamic();
|
|
3939
|
+
if (d?.sort_by && Nr.has(d.sort_by)) {
|
|
3940
|
+
let e = G[d.sort_by];
|
|
3842
3941
|
g = g.orderBy(d.sort_order === "desc" ? i(e) : n(e));
|
|
3843
3942
|
}
|
|
3844
|
-
let _ = (await g.offset(p * m).limit(m)).map(
|
|
3943
|
+
let _ = (await g.offset(p * m).limit(m)).map(Pr);
|
|
3845
3944
|
if (!u) return { resource_servers: _ };
|
|
3846
|
-
let [v] = await e.select({ count: r() }).from(
|
|
3945
|
+
let [v] = await e.select({ count: r() }).from(G).where(t(...h));
|
|
3847
3946
|
return {
|
|
3848
3947
|
resource_servers: _,
|
|
3849
3948
|
start: p * m,
|
|
@@ -3852,18 +3951,18 @@ function Nr(e) {
|
|
|
3852
3951
|
};
|
|
3853
3952
|
},
|
|
3854
3953
|
async remove(n, r) {
|
|
3855
|
-
return (await e.delete(
|
|
3954
|
+
return (await e.delete(G).where(t(a(G.tenant_id, n), a(G.id, r))).returning()).length > 0;
|
|
3856
3955
|
}
|
|
3857
3956
|
};
|
|
3858
3957
|
}
|
|
3859
3958
|
//#endregion
|
|
3860
3959
|
//#region src/adapters/rolePermissions.ts
|
|
3861
|
-
function
|
|
3960
|
+
function Ir(e) {
|
|
3862
3961
|
return {
|
|
3863
3962
|
async assign(t, n, r) {
|
|
3864
3963
|
if (r.length === 0) return !0;
|
|
3865
3964
|
let i = (/* @__PURE__ */ new Date()).toISOString();
|
|
3866
|
-
return await e.insert(
|
|
3965
|
+
return await e.insert(U).values(r.map((e) => ({
|
|
3867
3966
|
tenant_id: t,
|
|
3868
3967
|
role_id: n,
|
|
3869
3968
|
resource_server_identifier: e.resource_server_identifier,
|
|
@@ -3872,42 +3971,43 @@ function Pr(e) {
|
|
|
3872
3971
|
}))).onConflictDoNothing(), !0;
|
|
3873
3972
|
},
|
|
3874
3973
|
async list(n, r, i) {
|
|
3875
|
-
|
|
3876
|
-
resource_server_identifier:
|
|
3877
|
-
permission_name:
|
|
3878
|
-
created_at:
|
|
3879
|
-
}).from(
|
|
3974
|
+
let o = i?.per_page, s = e.select({
|
|
3975
|
+
resource_server_identifier: U.resource_server_identifier,
|
|
3976
|
+
permission_name: U.permission_name,
|
|
3977
|
+
created_at: U.created_at
|
|
3978
|
+
}).from(U).where(t(a(U.tenant_id, n), a(U.role_id, r))).orderBy(U.resource_server_identifier, U.permission_name).$dynamic();
|
|
3979
|
+
return Lr(e, n, await (o === void 0 ? s : s.limit(o).offset((i?.page ?? 0) * o)).all());
|
|
3880
3980
|
},
|
|
3881
3981
|
async listCheckpoint(n, r, i = {}) {
|
|
3882
3982
|
let o = {
|
|
3883
|
-
sortColumn:
|
|
3884
|
-
idColumn:
|
|
3983
|
+
sortColumn: U.resource_server_identifier,
|
|
3984
|
+
idColumn: U.permission_name,
|
|
3885
3985
|
sortOrder: "asc"
|
|
3886
|
-
}, s =
|
|
3887
|
-
role_id:
|
|
3888
|
-
resource_server_identifier:
|
|
3889
|
-
permission_name:
|
|
3890
|
-
created_at:
|
|
3891
|
-
}).from(
|
|
3986
|
+
}, s = Z(i), { rows: c, next: l } = Dt(await e.select({
|
|
3987
|
+
role_id: U.role_id,
|
|
3988
|
+
resource_server_identifier: U.resource_server_identifier,
|
|
3989
|
+
permission_name: U.permission_name,
|
|
3990
|
+
created_at: U.created_at
|
|
3991
|
+
}).from(U).where(t(a(U.tenant_id, n), a(U.role_id, r), Et(i, o))).orderBy(...Tt(o)).limit(s + 1).all(), s, "resource_server_identifier", "permission_name");
|
|
3892
3992
|
return {
|
|
3893
|
-
permissions: await
|
|
3993
|
+
permissions: await Lr(e, n, c),
|
|
3894
3994
|
next: l
|
|
3895
3995
|
};
|
|
3896
3996
|
},
|
|
3897
3997
|
async remove(n, r, i) {
|
|
3898
3998
|
if (i.length === 0) return !0;
|
|
3899
|
-
let o = i.map((e) => t(a(
|
|
3900
|
-
return await e.delete(
|
|
3999
|
+
let o = i.map((e) => t(a(U.resource_server_identifier, e.resource_server_identifier), a(U.permission_name, e.permission_name)));
|
|
4000
|
+
return await e.delete(U).where(t(a(U.tenant_id, n), a(U.role_id, r), v(...o))).returning(), !0;
|
|
3901
4001
|
}
|
|
3902
4002
|
};
|
|
3903
4003
|
}
|
|
3904
|
-
async function
|
|
4004
|
+
async function Lr(e, n, r) {
|
|
3905
4005
|
let i = [...new Set(r.map((e) => e.resource_server_identifier))], o = /* @__PURE__ */ new Map();
|
|
3906
4006
|
if (i.length > 0) {
|
|
3907
4007
|
let r = await e.select({
|
|
3908
|
-
identifier:
|
|
3909
|
-
name:
|
|
3910
|
-
}).from(
|
|
4008
|
+
identifier: G.identifier,
|
|
4009
|
+
name: G.name
|
|
4010
|
+
}).from(G).where(t(a(G.tenant_id, n), l(G.identifier, i))).all();
|
|
3911
4011
|
for (let e of r) o.set(e.identifier, e.name);
|
|
3912
4012
|
}
|
|
3913
4013
|
return r.map((e) => ({
|
|
@@ -3917,11 +4017,18 @@ async function Fr(e, n, r) {
|
|
|
3917
4017
|
}
|
|
3918
4018
|
//#endregion
|
|
3919
4019
|
//#region src/adapters/userPermissions.ts
|
|
3920
|
-
function
|
|
4020
|
+
function Rr(e) {
|
|
4021
|
+
try {
|
|
4022
|
+
let t = JSON.parse(e);
|
|
4023
|
+
if (Array.isArray(t) && t.length === 2 && t.every((e) => typeof e == "string")) return t;
|
|
4024
|
+
} catch {}
|
|
4025
|
+
throw new Re(400, { message: "The `from` cursor is not valid" });
|
|
4026
|
+
}
|
|
4027
|
+
function zr(e) {
|
|
3921
4028
|
return {
|
|
3922
4029
|
async create(t, n, r, i) {
|
|
3923
4030
|
try {
|
|
3924
|
-
await e.insert(
|
|
4031
|
+
await e.insert(Qe).values({
|
|
3925
4032
|
tenant_id: t,
|
|
3926
4033
|
user_id: n,
|
|
3927
4034
|
resource_server_identifier: r.resource_server_identifier,
|
|
@@ -3936,11 +4043,11 @@ function Ir(e) {
|
|
|
3936
4043
|
return !0;
|
|
3937
4044
|
},
|
|
3938
4045
|
async list(n, r, i, o) {
|
|
3939
|
-
let s = [a(
|
|
3940
|
-
o && s.push(a(
|
|
3941
|
-
let c = await e.select().from(
|
|
4046
|
+
let s = [a(Qe.tenant_id, n), a(Qe.user_id, r)];
|
|
4047
|
+
o && s.push(a(Qe.organization_id, o));
|
|
4048
|
+
let c = await e.select().from(Qe).where(t(...s)).all();
|
|
3942
4049
|
return await Promise.all(c.map(async (r) => {
|
|
3943
|
-
let i = await e.select({ name:
|
|
4050
|
+
let i = await e.select({ name: G.name }).from(G).where(t(a(G.tenant_id, n), a(G.identifier, r.resource_server_identifier))).get();
|
|
3944
4051
|
return {
|
|
3945
4052
|
resource_server_identifier: r.resource_server_identifier,
|
|
3946
4053
|
permission_name: r.permission_name,
|
|
@@ -3949,22 +4056,54 @@ function Ir(e) {
|
|
|
3949
4056
|
};
|
|
3950
4057
|
}));
|
|
3951
4058
|
},
|
|
4059
|
+
async listCheckpoint(r, i, o = {}, s) {
|
|
4060
|
+
let c = Z(o), u = [a(Qe.tenant_id, r), a(Qe.user_id, i)];
|
|
4061
|
+
s !== void 0 && u.push(a(Qe.organization_id, s));
|
|
4062
|
+
let d = o.from ? ge(o.from) : null;
|
|
4063
|
+
if (d) {
|
|
4064
|
+
if (d.k !== void 0) throw new Re(400, { message: "The `from` cursor was issued under a different sort and cannot be used with this request" });
|
|
4065
|
+
let [e, t] = Rr(d.i);
|
|
4066
|
+
u.push(y`(${Qe.resource_server_identifier}, ${Qe.permission_name}, ${Qe.organization_id}) > (${d.s}, ${e}, ${t})`);
|
|
4067
|
+
}
|
|
4068
|
+
let f = await e.select().from(Qe).where(t(...u)).orderBy(n(Qe.resource_server_identifier), n(Qe.permission_name), n(Qe.organization_id)).limit(c + 1).all(), p = f.length > c, m = p ? f.slice(0, c) : f, h = m[m.length - 1], g = p && h ? _e({
|
|
4069
|
+
s: h.resource_server_identifier,
|
|
4070
|
+
i: JSON.stringify([h.permission_name, h.organization_id])
|
|
4071
|
+
}) : void 0, _ = [...new Set(m.map((e) => e.resource_server_identifier))], v = /* @__PURE__ */ new Map();
|
|
4072
|
+
if (_.length > 0) {
|
|
4073
|
+
let n = await e.select({
|
|
4074
|
+
identifier: G.identifier,
|
|
4075
|
+
name: G.name
|
|
4076
|
+
}).from(G).where(t(a(G.tenant_id, r), l(G.identifier, _))).all();
|
|
4077
|
+
for (let e of n) v.set(e.identifier, e.name);
|
|
4078
|
+
}
|
|
4079
|
+
return {
|
|
4080
|
+
permissions: m.map((e) => ({
|
|
4081
|
+
user_id: e.user_id,
|
|
4082
|
+
resource_server_identifier: e.resource_server_identifier,
|
|
4083
|
+
permission_name: e.permission_name,
|
|
4084
|
+
resource_server_name: v.get(e.resource_server_identifier) || e.resource_server_identifier,
|
|
4085
|
+
created_at: e.created_at,
|
|
4086
|
+
organization_id: e.organization_id === "" ? void 0 : e.organization_id
|
|
4087
|
+
})),
|
|
4088
|
+
next: g
|
|
4089
|
+
};
|
|
4090
|
+
},
|
|
3952
4091
|
async remove(n, r, i, o) {
|
|
3953
|
-
return (await e.delete(
|
|
4092
|
+
return (await e.delete(Qe).where(t(a(Qe.tenant_id, n), a(Qe.user_id, r), a(Qe.resource_server_identifier, i.resource_server_identifier), a(Qe.permission_name, i.permission_name), a(Qe.organization_id, o || ""))).returning()).length > 0;
|
|
3954
4093
|
}
|
|
3955
4094
|
};
|
|
3956
4095
|
}
|
|
3957
4096
|
//#endregion
|
|
3958
4097
|
//#region src/adapters/roles.ts
|
|
3959
|
-
function
|
|
4098
|
+
function Br(e) {
|
|
3960
4099
|
let { tenant_id: t, is_system: n, metadata: r, ...i } = e;
|
|
3961
4100
|
return D({
|
|
3962
4101
|
...i,
|
|
3963
4102
|
is_system: n ? !0 : void 0,
|
|
3964
|
-
metadata:
|
|
4103
|
+
metadata: X(r)
|
|
3965
4104
|
});
|
|
3966
4105
|
}
|
|
3967
|
-
function
|
|
4106
|
+
function Vr(e) {
|
|
3968
4107
|
return {
|
|
3969
4108
|
async create(t, n) {
|
|
3970
4109
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -3977,43 +4116,43 @@ function Rr(e) {
|
|
|
3977
4116
|
created_at: r,
|
|
3978
4117
|
updated_at: r
|
|
3979
4118
|
};
|
|
3980
|
-
return await e.insert(
|
|
4119
|
+
return await e.insert(H).values(i), Br({
|
|
3981
4120
|
...i,
|
|
3982
4121
|
tenant_id: t
|
|
3983
4122
|
});
|
|
3984
4123
|
},
|
|
3985
4124
|
async get(n, r) {
|
|
3986
|
-
let i = await e.select().from(
|
|
3987
|
-
return i ?
|
|
4125
|
+
let i = await e.select().from(H).where(t(a(H.tenant_id, n), a(H.id, r))).get();
|
|
4126
|
+
return i ? Br(i) : null;
|
|
3988
4127
|
},
|
|
3989
4128
|
async update(n, r, i) {
|
|
3990
4129
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
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(
|
|
4130
|
+
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(H).set(o).where(t(a(H.tenant_id, n), a(H.id, r))).returning()).length > 0;
|
|
3992
4131
|
},
|
|
3993
4132
|
async list(o, s) {
|
|
3994
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
3995
|
-
if (
|
|
4133
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? Ct(H, f, ["name"]) : void 0, m = p ? t(a(H.tenant_id, o), p) : a(H.tenant_id, o);
|
|
4134
|
+
if (wt(s)) {
|
|
3996
4135
|
let n = {
|
|
3997
|
-
sortColumn:
|
|
3998
|
-
idColumn:
|
|
4136
|
+
sortColumn: H.created_at,
|
|
4137
|
+
idColumn: H.id,
|
|
3999
4138
|
sortOrder: "desc"
|
|
4000
|
-
}, r =
|
|
4139
|
+
}, r = Z(s), { rows: i, next: a } = Dt(await e.select().from(H).where(t(m, Et(s, n))).orderBy(...Tt(n)).limit(r + 1), r, "created_at");
|
|
4001
4140
|
return {
|
|
4002
|
-
roles: i.map(
|
|
4141
|
+
roles: i.map(Br),
|
|
4003
4142
|
start: 0,
|
|
4004
4143
|
limit: r,
|
|
4005
4144
|
length: i.length,
|
|
4006
4145
|
next: a
|
|
4007
4146
|
};
|
|
4008
4147
|
}
|
|
4009
|
-
let h = e.select().from(
|
|
4148
|
+
let h = e.select().from(H).where(m).$dynamic();
|
|
4010
4149
|
if (d?.sort_by) {
|
|
4011
|
-
let e =
|
|
4150
|
+
let e = H[d.sort_by];
|
|
4012
4151
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
4013
4152
|
}
|
|
4014
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
4153
|
+
let g = (await h.offset(c * l).limit(l)).map(Br);
|
|
4015
4154
|
if (!u) return { roles: g };
|
|
4016
|
-
let [_] = await e.select({ count: r() }).from(
|
|
4155
|
+
let [_] = await e.select({ count: r() }).from(H).where(m);
|
|
4017
4156
|
return {
|
|
4018
4157
|
roles: g,
|
|
4019
4158
|
start: c * l,
|
|
@@ -4022,13 +4161,13 @@ function Rr(e) {
|
|
|
4022
4161
|
};
|
|
4023
4162
|
},
|
|
4024
4163
|
async remove(n, r) {
|
|
4025
|
-
return (await e.delete(
|
|
4164
|
+
return (await e.delete(H).where(t(a(H.tenant_id, n), a(H.id, r))).returning()).length > 0;
|
|
4026
4165
|
}
|
|
4027
4166
|
};
|
|
4028
4167
|
}
|
|
4029
4168
|
//#endregion
|
|
4030
4169
|
//#region src/adapters/sessions.ts
|
|
4031
|
-
var
|
|
4170
|
+
var Hr = ["created_at_ts", "updated_at_ts"], Ur = [
|
|
4032
4171
|
"expires_at_ts",
|
|
4033
4172
|
"idle_expires_at_ts",
|
|
4034
4173
|
"authenticated_at_ts",
|
|
@@ -4036,7 +4175,7 @@ var zr = ["created_at_ts", "updated_at_ts"], Br = [
|
|
|
4036
4175
|
"used_at_ts",
|
|
4037
4176
|
"revoked_at_ts"
|
|
4038
4177
|
];
|
|
4039
|
-
function
|
|
4178
|
+
function Wr(e) {
|
|
4040
4179
|
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({
|
|
4041
4180
|
created_at_ts: n,
|
|
4042
4181
|
updated_at_ts: r,
|
|
@@ -4046,18 +4185,18 @@ function Vr(e) {
|
|
|
4046
4185
|
last_interaction_at_ts: s,
|
|
4047
4186
|
used_at_ts: c,
|
|
4048
4187
|
revoked_at_ts: l
|
|
4049
|
-
}, [...
|
|
4188
|
+
}, [...Hr], [...Ur]);
|
|
4050
4189
|
return D({
|
|
4051
4190
|
...f,
|
|
4052
4191
|
...p,
|
|
4053
|
-
device:
|
|
4054
|
-
clients:
|
|
4192
|
+
device: X(u, {}),
|
|
4193
|
+
clients: X(d, [])
|
|
4055
4194
|
});
|
|
4056
4195
|
}
|
|
4057
|
-
function
|
|
4196
|
+
function Gr(e, t) {
|
|
4058
4197
|
return Math.max(e ?? 0, t ?? 0);
|
|
4059
4198
|
}
|
|
4060
|
-
function
|
|
4199
|
+
function Kr(e) {
|
|
4061
4200
|
return {
|
|
4062
4201
|
async create(n, r) {
|
|
4063
4202
|
let i = Date.now(), o = {
|
|
@@ -4075,23 +4214,23 @@ function Ur(e) {
|
|
|
4075
4214
|
last_interaction_at_ts: r.last_interaction_at ? E(r.last_interaction_at) : i,
|
|
4076
4215
|
used_at_ts: E(r.used_at),
|
|
4077
4216
|
revoked_at_ts: E(r.revoked_at)
|
|
4078
|
-
}, s = [e.insert(M).values(o)], c =
|
|
4217
|
+
}, s = [e.insert(M).values(o)], c = Gr(o.expires_at_ts, o.idle_expires_at_ts);
|
|
4079
4218
|
return c > 0 && o.login_session_id && s.push(e.update(P).set({
|
|
4080
4219
|
expires_at_ts: c,
|
|
4081
4220
|
updated_at_ts: i
|
|
4082
|
-
}).where(t(a(P.tenant_id, n), a(P.id, o.login_session_id), m(P.expires_at_ts, c)))), await
|
|
4221
|
+
}).where(t(a(P.tenant_id, n), a(P.id, o.login_session_id), m(P.expires_at_ts, c)))), await Pt(e, s), Wr({
|
|
4083
4222
|
...o,
|
|
4084
4223
|
tenant_id: n
|
|
4085
4224
|
});
|
|
4086
4225
|
},
|
|
4087
4226
|
async get(n, r) {
|
|
4088
4227
|
let i = await e.select().from(M).where(t(a(M.tenant_id, n), a(M.id, r))).get();
|
|
4089
|
-
return i ?
|
|
4228
|
+
return i ? Wr(i) : null;
|
|
4090
4229
|
},
|
|
4091
4230
|
async update(n, r, i) {
|
|
4092
4231
|
let o = { updated_at_ts: Date.now() };
|
|
4093
4232
|
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));
|
|
4094
|
-
let s = await e.update(M).set(o).where(t(a(M.tenant_id, n), a(M.id, r))).returning(), c =
|
|
4233
|
+
let s = await e.update(M).set(o).where(t(a(M.tenant_id, n), a(M.id, r))).returning(), c = Gr(o.expires_at_ts, o.idle_expires_at_ts), l = s[0];
|
|
4095
4234
|
if (c > 0 && l) {
|
|
4096
4235
|
let r = i.login_session_id ?? l.login_session_id;
|
|
4097
4236
|
r && await e.update(P).set({
|
|
@@ -4102,12 +4241,27 @@ function Ur(e) {
|
|
|
4102
4241
|
return s.length > 0;
|
|
4103
4242
|
},
|
|
4104
4243
|
async list(o, s) {
|
|
4105
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
4244
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? Ct(M, f, ["user_id", "id"]) : void 0, m = p ? t(a(M.tenant_id, o), p) : a(M.tenant_id, o);
|
|
4245
|
+
if (wt(s)) {
|
|
4246
|
+
let n = {
|
|
4247
|
+
sortColumn: M.created_at_ts,
|
|
4248
|
+
idColumn: M.id,
|
|
4249
|
+
sortOrder: "desc"
|
|
4250
|
+
}, r = Z(s), i = Et(s, n), { rows: a, next: o } = Dt(await e.select().from(M).where(i ? t(m, i) : m).orderBy(...Tt(n)).limit(r + 1), r, "created_at_ts"), c = a.map(Wr);
|
|
4251
|
+
return {
|
|
4252
|
+
sessions: c,
|
|
4253
|
+
start: 0,
|
|
4254
|
+
limit: r,
|
|
4255
|
+
length: c.length,
|
|
4256
|
+
next: o
|
|
4257
|
+
};
|
|
4258
|
+
}
|
|
4259
|
+
let h = e.select().from(M).where(m).$dynamic();
|
|
4106
4260
|
if (d?.sort_by) {
|
|
4107
4261
|
let e = M[d.sort_by];
|
|
4108
4262
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
4109
4263
|
}
|
|
4110
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
4264
|
+
let g = (await h.offset(c * l).limit(l)).map(Wr);
|
|
4111
4265
|
if (!u) return { sessions: g };
|
|
4112
4266
|
let [_] = await e.select({ count: r() }).from(M).where(m);
|
|
4113
4267
|
return {
|
|
@@ -4124,7 +4278,7 @@ function Ur(e) {
|
|
|
4124
4278
|
}
|
|
4125
4279
|
//#endregion
|
|
4126
4280
|
//#region src/adapters/tenants.ts
|
|
4127
|
-
var
|
|
4281
|
+
var qr = [
|
|
4128
4282
|
"session_cookie",
|
|
4129
4283
|
"enabled_locales",
|
|
4130
4284
|
"error_page",
|
|
@@ -4140,25 +4294,25 @@ var Wr = [
|
|
|
4140
4294
|
"acr_values_supported",
|
|
4141
4295
|
"mtls",
|
|
4142
4296
|
"mfa"
|
|
4143
|
-
],
|
|
4297
|
+
], Jr = [
|
|
4144
4298
|
"allow_organization_name_in_authentication_api",
|
|
4145
4299
|
"customize_mfa_in_postlogin_action",
|
|
4146
4300
|
"pushed_authorization_requests_supported",
|
|
4147
4301
|
"authorization_response_iss_parameter_supported"
|
|
4148
4302
|
];
|
|
4149
|
-
function
|
|
4303
|
+
function Yr(e) {
|
|
4150
4304
|
let t = { ...e };
|
|
4151
|
-
for (let e of
|
|
4152
|
-
for (let e of
|
|
4305
|
+
for (let e of qr) typeof t[e] == "string" && (t[e] = X(t[e]));
|
|
4306
|
+
for (let e of Jr) t[e] !== void 0 && t[e] !== null && (t[e] = t[e] === 1);
|
|
4153
4307
|
return D(t);
|
|
4154
4308
|
}
|
|
4155
|
-
function
|
|
4309
|
+
function Xr(e) {
|
|
4156
4310
|
let t = { ...e };
|
|
4157
|
-
le(e,
|
|
4158
|
-
for (let n of
|
|
4311
|
+
le(e, qr, t);
|
|
4312
|
+
for (let n of Jr) e[n] !== void 0 && (t[n] = +!!e[n]);
|
|
4159
4313
|
return ce(t);
|
|
4160
4314
|
}
|
|
4161
|
-
function
|
|
4315
|
+
function Zr(e) {
|
|
4162
4316
|
return {
|
|
4163
4317
|
async create(t) {
|
|
4164
4318
|
let n = {
|
|
@@ -4166,7 +4320,7 @@ function Jr(e) {
|
|
|
4166
4320
|
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4167
4321
|
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4168
4322
|
...t
|
|
4169
|
-
}, r =
|
|
4323
|
+
}, r = Xr(n);
|
|
4170
4324
|
try {
|
|
4171
4325
|
await e.insert(O).values(r);
|
|
4172
4326
|
} catch (e) {
|
|
@@ -4177,28 +4331,30 @@ function Jr(e) {
|
|
|
4177
4331
|
},
|
|
4178
4332
|
async get(t) {
|
|
4179
4333
|
let n = await e.select().from(O).where(a(O.id, t)).get();
|
|
4180
|
-
return n ?
|
|
4334
|
+
return n ? Yr(n) : null;
|
|
4181
4335
|
},
|
|
4182
4336
|
async list(t) {
|
|
4183
|
-
let { page: a = 0, per_page: o = 50, include_totals: s = !1, sort: c, q: l } = t || {}, u = l ?
|
|
4337
|
+
let { page: a = 0, per_page: o = 50, include_totals: s = !1, sort: c, q: l } = t || {}, u = l ? Ct(O, l, ["id", "friendly_name"]) : void 0, d = e.select().from(O).$dynamic();
|
|
4184
4338
|
if (u && (d = d.where(u)), c?.sort_by) {
|
|
4185
4339
|
let e = O[c.sort_by];
|
|
4186
4340
|
e && (d = d.orderBy(c.sort_order === "desc" ? i(e) : n(e)));
|
|
4187
4341
|
}
|
|
4188
|
-
let f = (await d.offset(a * o).limit(o)).map(
|
|
4342
|
+
let f = (await d.offset(a * o).limit(o)).map(Yr);
|
|
4189
4343
|
if (!s) return { tenants: f };
|
|
4190
4344
|
let p = e.select({ count: r() }).from(O).$dynamic();
|
|
4191
4345
|
u && (p = p.where(u));
|
|
4192
4346
|
let [m] = await p;
|
|
4193
4347
|
return {
|
|
4194
4348
|
tenants: f,
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4349
|
+
totals: {
|
|
4350
|
+
start: a * o,
|
|
4351
|
+
limit: o,
|
|
4352
|
+
length: Number(m?.count ?? 0)
|
|
4353
|
+
}
|
|
4198
4354
|
};
|
|
4199
4355
|
},
|
|
4200
4356
|
async update(t, n) {
|
|
4201
|
-
let r =
|
|
4357
|
+
let r = Xr({
|
|
4202
4358
|
...n,
|
|
4203
4359
|
id: t,
|
|
4204
4360
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -4212,62 +4368,62 @@ function Jr(e) {
|
|
|
4212
4368
|
}
|
|
4213
4369
|
//#endregion
|
|
4214
4370
|
//#region src/adapters/themes.ts
|
|
4215
|
-
var
|
|
4371
|
+
var Qr = [
|
|
4216
4372
|
"colors",
|
|
4217
4373
|
"borders",
|
|
4218
4374
|
"fonts",
|
|
4219
4375
|
"page_background",
|
|
4220
4376
|
"widget"
|
|
4221
4377
|
];
|
|
4222
|
-
function
|
|
4223
|
-
let { tenant_id: t, ...n } = e, r =
|
|
4378
|
+
function $r(e) {
|
|
4379
|
+
let { tenant_id: t, ...n } = e, r = bt(n, Qr);
|
|
4224
4380
|
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);
|
|
4225
4381
|
}
|
|
4226
|
-
function
|
|
4382
|
+
function ei(e) {
|
|
4227
4383
|
return {
|
|
4228
4384
|
async create(t, n, r, i) {
|
|
4229
4385
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = a?.id || r || b(), c = {
|
|
4230
|
-
...
|
|
4386
|
+
...yt(n),
|
|
4231
4387
|
tenant_id: t,
|
|
4232
4388
|
themeId: s,
|
|
4233
4389
|
created_at: a?.created_at ?? o,
|
|
4234
4390
|
updated_at: a?.updated_at ?? o
|
|
4235
4391
|
};
|
|
4236
|
-
return await e.insert(
|
|
4392
|
+
return await e.insert(tt).values(c), $r({
|
|
4237
4393
|
...c,
|
|
4238
4394
|
tenant_id: t
|
|
4239
4395
|
});
|
|
4240
4396
|
},
|
|
4241
4397
|
async get(n, r) {
|
|
4242
|
-
let i = await e.select().from(
|
|
4243
|
-
return i ?
|
|
4398
|
+
let i = await e.select().from(tt).where(t(a(tt.tenant_id, n), a(tt.themeId, r))).get();
|
|
4399
|
+
return i ? $r(i) : null;
|
|
4244
4400
|
},
|
|
4245
4401
|
async update(n, r, i) {
|
|
4246
|
-
let o =
|
|
4247
|
-
return o.updated_at = (/* @__PURE__ */ new Date()).toISOString(), await e.update(
|
|
4402
|
+
let o = yt(i);
|
|
4403
|
+
return o.updated_at = (/* @__PURE__ */ new Date()).toISOString(), await e.update(tt).set(o).where(t(a(tt.tenant_id, n), a(tt.themeId, r))), !0;
|
|
4248
4404
|
},
|
|
4249
4405
|
async remove(n, r) {
|
|
4250
|
-
return (await e.delete(
|
|
4406
|
+
return (await e.delete(tt).where(t(a(tt.tenant_id, n), a(tt.themeId, r))).returning()).length > 0;
|
|
4251
4407
|
}
|
|
4252
4408
|
};
|
|
4253
4409
|
}
|
|
4254
4410
|
//#endregion
|
|
4255
4411
|
//#region src/adapters/universalLoginTemplates.ts
|
|
4256
|
-
function
|
|
4412
|
+
function ti(e) {
|
|
4257
4413
|
return {
|
|
4258
4414
|
async get(t) {
|
|
4259
|
-
let n = await e.select({ body:
|
|
4415
|
+
let n = await e.select({ body: et.body }).from(et).where(a(et.tenant_id, t)).get();
|
|
4260
4416
|
return n ? { body: n.body } : null;
|
|
4261
4417
|
},
|
|
4262
4418
|
async set(t, n) {
|
|
4263
4419
|
let r = Date.now();
|
|
4264
|
-
await e.insert(
|
|
4420
|
+
await e.insert(et).values({
|
|
4265
4421
|
tenant_id: t,
|
|
4266
4422
|
body: n.body,
|
|
4267
4423
|
created_at_ts: r,
|
|
4268
4424
|
updated_at_ts: r
|
|
4269
4425
|
}).onConflictDoUpdate({
|
|
4270
|
-
target:
|
|
4426
|
+
target: et.tenant_id,
|
|
4271
4427
|
set: {
|
|
4272
4428
|
body: n.body,
|
|
4273
4429
|
updated_at_ts: r
|
|
@@ -4275,17 +4431,17 @@ function Qr(e) {
|
|
|
4275
4431
|
});
|
|
4276
4432
|
},
|
|
4277
4433
|
async delete(t) {
|
|
4278
|
-
await e.delete(
|
|
4434
|
+
await e.delete(et).where(a(et.tenant_id, t));
|
|
4279
4435
|
}
|
|
4280
4436
|
};
|
|
4281
4437
|
}
|
|
4282
4438
|
//#endregion
|
|
4283
4439
|
//#region src/adapters/userActivity.ts
|
|
4284
|
-
function
|
|
4440
|
+
function ni(e) {
|
|
4285
4441
|
let t = {};
|
|
4286
4442
|
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;
|
|
4287
4443
|
}
|
|
4288
|
-
function
|
|
4444
|
+
function ri(e) {
|
|
4289
4445
|
return {
|
|
4290
4446
|
async get(n, r) {
|
|
4291
4447
|
let i = await e.select().from(Ue).where(t(a(Ue.tenant_id, n), a(Ue.user_id, r))).get();
|
|
@@ -4299,7 +4455,7 @@ function ei(e) {
|
|
|
4299
4455
|
} : null;
|
|
4300
4456
|
},
|
|
4301
4457
|
async upsert(t, n, r) {
|
|
4302
|
-
let i =
|
|
4458
|
+
let i = ni(r), a = e.insert(Ue).values({
|
|
4303
4459
|
tenant_id: t,
|
|
4304
4460
|
user_id: n,
|
|
4305
4461
|
login_count: 0,
|
|
@@ -4318,14 +4474,14 @@ function ei(e) {
|
|
|
4318
4474
|
}
|
|
4319
4475
|
//#endregion
|
|
4320
4476
|
//#region src/adapters/outbox.ts
|
|
4321
|
-
function
|
|
4477
|
+
function ii(e) {
|
|
4322
4478
|
return {
|
|
4323
4479
|
...e,
|
|
4324
|
-
payload:
|
|
4480
|
+
payload: X(e.payload, {})
|
|
4325
4481
|
};
|
|
4326
4482
|
}
|
|
4327
|
-
function
|
|
4328
|
-
return e.insert(
|
|
4483
|
+
function ai(e, t, n, r) {
|
|
4484
|
+
return e.insert(q).values({
|
|
4329
4485
|
id: t,
|
|
4330
4486
|
tenant_id: n,
|
|
4331
4487
|
event_type: r.event_type,
|
|
@@ -4345,64 +4501,82 @@ function ni(e, t, n, r) {
|
|
|
4345
4501
|
claim_expires_at: null
|
|
4346
4502
|
});
|
|
4347
4503
|
}
|
|
4348
|
-
function
|
|
4504
|
+
function oi(e) {
|
|
4505
|
+
return {
|
|
4506
|
+
...X(e.payload, {}),
|
|
4507
|
+
id: e.id,
|
|
4508
|
+
created_at: e.created_at,
|
|
4509
|
+
processed_at: e.processed_at,
|
|
4510
|
+
retry_count: e.retry_count,
|
|
4511
|
+
next_retry_at: e.next_retry_at,
|
|
4512
|
+
error: e.error,
|
|
4513
|
+
dead_lettered_at: e.dead_lettered_at,
|
|
4514
|
+
final_error: e.final_error
|
|
4515
|
+
};
|
|
4516
|
+
}
|
|
4517
|
+
function si(e) {
|
|
4349
4518
|
return {
|
|
4350
4519
|
async create(t, n) {
|
|
4351
4520
|
let r = b();
|
|
4352
|
-
return await
|
|
4521
|
+
return await ai(e, r, t, n), r;
|
|
4353
4522
|
},
|
|
4354
4523
|
async getByIds(t) {
|
|
4355
|
-
return t.length === 0 ? [] : (await e.select().from(
|
|
4524
|
+
return t.length === 0 ? [] : (await e.select().from(q).where(l(q.id, t)).all()).map(ii);
|
|
4356
4525
|
},
|
|
4357
4526
|
async getUnprocessed(n) {
|
|
4358
4527
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
4359
|
-
return (await e.select().from(
|
|
4528
|
+
return (await e.select().from(q).where(t(f(q.processed_at), v(f(q.next_retry_at), h(q.next_retry_at, r)), v(f(q.claimed_by), h(q.claim_expires_at, r)))).orderBy(q.created_at, q.id).limit(n).all()).map(ii);
|
|
4360
4529
|
},
|
|
4361
4530
|
async claimEvents(n, r, i) {
|
|
4362
4531
|
if (n.length === 0) return [];
|
|
4363
4532
|
let o = (/* @__PURE__ */ new Date()).toISOString(), s = new Date(Date.now() + i).toISOString();
|
|
4364
|
-
return await e.update(
|
|
4533
|
+
return await e.update(q).set({
|
|
4365
4534
|
claimed_by: r,
|
|
4366
4535
|
claim_expires_at: s
|
|
4367
|
-
}).where(t(l(
|
|
4536
|
+
}).where(t(l(q.id, n), f(q.processed_at), v(f(q.claimed_by), h(q.claim_expires_at, o)))), (await e.select({ id: q.id }).from(q).where(t(l(q.id, n), a(q.claimed_by, r))).all()).map((e) => e.id);
|
|
4368
4537
|
},
|
|
4369
4538
|
async markProcessed(t) {
|
|
4370
|
-
t.length !== 0 && await e.update(
|
|
4539
|
+
t.length !== 0 && await e.update(q).set({ processed_at: (/* @__PURE__ */ new Date()).toISOString() }).where(l(q.id, t));
|
|
4371
4540
|
},
|
|
4372
4541
|
async markRetry(t, n, r) {
|
|
4373
|
-
await e.update(
|
|
4542
|
+
await e.update(q).set({
|
|
4374
4543
|
error: n,
|
|
4375
4544
|
next_retry_at: r,
|
|
4376
|
-
retry_count: y`${
|
|
4545
|
+
retry_count: y`${q.retry_count} + 1`,
|
|
4377
4546
|
claimed_by: null,
|
|
4378
4547
|
claim_expires_at: null
|
|
4379
|
-
}).where(a(
|
|
4548
|
+
}).where(a(q.id, t));
|
|
4380
4549
|
},
|
|
4381
4550
|
async cleanup(n) {
|
|
4382
|
-
return (await e.delete(
|
|
4551
|
+
return (await e.delete(q).where(t(y`${q.processed_at} IS NOT NULL`, h(q.processed_at, n))).returning()).length;
|
|
4383
4552
|
},
|
|
4384
4553
|
async deadLetter(t, n) {
|
|
4385
4554
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
4386
|
-
await e.update(
|
|
4555
|
+
await e.update(q).set({
|
|
4387
4556
|
processed_at: r,
|
|
4388
4557
|
dead_lettered_at: r,
|
|
4389
4558
|
final_error: n
|
|
4390
|
-
}).where(a(
|
|
4559
|
+
}).where(a(q.id, t));
|
|
4391
4560
|
},
|
|
4392
4561
|
async listFailed(o, s = {}) {
|
|
4393
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1 } = s
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4562
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1 } = s;
|
|
4563
|
+
if (wt(s)) {
|
|
4564
|
+
let n = {
|
|
4565
|
+
sortColumn: q.dead_lettered_at,
|
|
4566
|
+
idColumn: q.id,
|
|
4567
|
+
sortOrder: "desc"
|
|
4568
|
+
}, r = Z(s), { rows: i, next: c } = Dt(await e.select().from(q).where(t(a(q.tenant_id, o), d(q.dead_lettered_at), Et(s, n))).orderBy(...Tt(n)).limit(r + 1).all(), r, "dead_lettered_at"), l = i.map(oi);
|
|
4569
|
+
return {
|
|
4570
|
+
events: l,
|
|
4571
|
+
start: 0,
|
|
4572
|
+
limit: r,
|
|
4573
|
+
length: l.length,
|
|
4574
|
+
next: c
|
|
4575
|
+
};
|
|
4576
|
+
}
|
|
4577
|
+
let f = (await e.select().from(q).where(t(a(q.tenant_id, o), d(q.dead_lettered_at))).orderBy(i(q.dead_lettered_at), n(q.id)).offset(c * l).limit(l).all()).map(oi), p = f.length;
|
|
4404
4578
|
if (u) {
|
|
4405
|
-
let [n] = await e.select({ total: r() }).from(
|
|
4579
|
+
let [n] = await e.select({ total: r() }).from(q).where(t(a(q.tenant_id, o), d(q.dead_lettered_at)));
|
|
4406
4580
|
p = Number(n?.total ?? f.length);
|
|
4407
4581
|
}
|
|
4408
4582
|
return {
|
|
@@ -4413,7 +4587,7 @@ function ri(e) {
|
|
|
4413
4587
|
};
|
|
4414
4588
|
},
|
|
4415
4589
|
async replay(n, r) {
|
|
4416
|
-
return (await e.update(
|
|
4590
|
+
return (await e.update(q).set({
|
|
4417
4591
|
processed_at: null,
|
|
4418
4592
|
dead_lettered_at: null,
|
|
4419
4593
|
final_error: null,
|
|
@@ -4422,19 +4596,19 @@ function ri(e) {
|
|
|
4422
4596
|
error: null,
|
|
4423
4597
|
claimed_by: null,
|
|
4424
4598
|
claim_expires_at: null
|
|
4425
|
-
}).where(t(a(
|
|
4599
|
+
}).where(t(a(q.id, n), a(q.tenant_id, r), d(q.dead_lettered_at))).returning()).length > 0;
|
|
4426
4600
|
},
|
|
4427
4601
|
async discard(n, r) {
|
|
4428
|
-
return (await e.delete(
|
|
4602
|
+
return (await e.delete(q).where(t(a(q.id, n), a(q.tenant_id, r), d(q.dead_lettered_at))).returning({ id: q.id })).length > 0;
|
|
4429
4603
|
}
|
|
4430
4604
|
};
|
|
4431
4605
|
}
|
|
4432
4606
|
//#endregion
|
|
4433
4607
|
//#region src/adapters/users.ts
|
|
4434
|
-
function
|
|
4435
|
-
return (n?.outboxEvents ?? []).map((n) =>
|
|
4608
|
+
function ci(e, t, n) {
|
|
4609
|
+
return (n?.outboxEvents ?? []).map((n) => ai(e, n.id, t, n));
|
|
4436
4610
|
}
|
|
4437
|
-
var
|
|
4611
|
+
var li = [
|
|
4438
4612
|
"user_id",
|
|
4439
4613
|
"email",
|
|
4440
4614
|
"email_verified",
|
|
@@ -4456,23 +4630,23 @@ var ai = [
|
|
|
4456
4630
|
"login_count",
|
|
4457
4631
|
"created_at",
|
|
4458
4632
|
"updated_at"
|
|
4459
|
-
],
|
|
4633
|
+
], ui = [
|
|
4460
4634
|
"email",
|
|
4461
4635
|
"name",
|
|
4462
4636
|
"phone_number",
|
|
4463
4637
|
"user_id"
|
|
4464
|
-
],
|
|
4638
|
+
], di = new Set([
|
|
4465
4639
|
"last_login",
|
|
4466
4640
|
"last_ip",
|
|
4467
4641
|
"login_count"
|
|
4468
|
-
]),
|
|
4642
|
+
]), fi = o(A), pi = o(Ue), mi = Object.fromEntries(li.map((e) => [e, e === "login_count" ? {
|
|
4469
4643
|
coalesce: Ue.login_count,
|
|
4470
4644
|
defaultValue: 0
|
|
4471
|
-
} :
|
|
4472
|
-
function
|
|
4645
|
+
} : di.has(e) ? pi[e] : fi[e]]));
|
|
4646
|
+
function hi() {
|
|
4473
4647
|
return t(a(Ue.tenant_id, A.tenant_id), a(Ue.user_id, A.user_id));
|
|
4474
4648
|
}
|
|
4475
|
-
function
|
|
4649
|
+
function gi(e, t) {
|
|
4476
4650
|
return {
|
|
4477
4651
|
...e,
|
|
4478
4652
|
last_login: t?.last_login,
|
|
@@ -4480,7 +4654,7 @@ function fi(e, t) {
|
|
|
4480
4654
|
login_count: t?.login_count ?? 0
|
|
4481
4655
|
};
|
|
4482
4656
|
}
|
|
4483
|
-
function
|
|
4657
|
+
function _i(e, t) {
|
|
4484
4658
|
let n = {
|
|
4485
4659
|
connection: e.connection,
|
|
4486
4660
|
provider: e.provider,
|
|
@@ -4490,11 +4664,11 @@ function pi(e, t) {
|
|
|
4490
4664
|
return t ? n.isPrimary = !0 : n.profileData = {
|
|
4491
4665
|
email: e.email,
|
|
4492
4666
|
email_verified: !!e.email_verified,
|
|
4493
|
-
...typeof e.profileData == "string" ?
|
|
4667
|
+
...typeof e.profileData == "string" ? X(e.profileData, {}) : {}
|
|
4494
4668
|
}, n;
|
|
4495
4669
|
}
|
|
4496
|
-
function
|
|
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 =
|
|
4670
|
+
function vi(e, t = []) {
|
|
4671
|
+
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 = _i(e, !0), m = t.map((e) => _i(e, !1));
|
|
4498
4672
|
return D({
|
|
4499
4673
|
...f,
|
|
4500
4674
|
email: e.email || "",
|
|
@@ -4502,13 +4676,13 @@ function mi(e, t = []) {
|
|
|
4502
4676
|
phone_verified: s == null ? void 0 : !!s,
|
|
4503
4677
|
is_social: !!c,
|
|
4504
4678
|
blocked: l == null ? void 0 : !!l,
|
|
4505
|
-
app_metadata:
|
|
4506
|
-
user_metadata:
|
|
4507
|
-
address:
|
|
4679
|
+
app_metadata: X(r, {}),
|
|
4680
|
+
user_metadata: X(i, {}),
|
|
4681
|
+
address: X(a),
|
|
4508
4682
|
identities: [p, ...m]
|
|
4509
4683
|
});
|
|
4510
4684
|
}
|
|
4511
|
-
function
|
|
4685
|
+
function yi(e) {
|
|
4512
4686
|
let o = async (t, n, r) => {
|
|
4513
4687
|
let i = (/* @__PURE__ */ new Date()).toISOString(), a = {
|
|
4514
4688
|
user_id: n.user_id,
|
|
@@ -4562,12 +4736,12 @@ function hi(e) {
|
|
|
4562
4736
|
created_at: i,
|
|
4563
4737
|
updated_at: i
|
|
4564
4738
|
}));
|
|
4565
|
-
for (let n of
|
|
4566
|
-
c.length > 1 ? await
|
|
4739
|
+
for (let n of ci(e, t, r)) c.push(n);
|
|
4740
|
+
c.length > 1 ? await Pt(e, c) : await e.insert(A).values(a);
|
|
4567
4741
|
} catch (e) {
|
|
4568
4742
|
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" }));
|
|
4569
4743
|
}
|
|
4570
|
-
return
|
|
4744
|
+
return vi({
|
|
4571
4745
|
...a,
|
|
4572
4746
|
last_login: n.last_login,
|
|
4573
4747
|
last_ip: n.last_ip,
|
|
@@ -4578,10 +4752,10 @@ function hi(e) {
|
|
|
4578
4752
|
create: o,
|
|
4579
4753
|
rawCreate: o,
|
|
4580
4754
|
async get(n, r) {
|
|
4581
|
-
let i = await e.select().from(A).leftJoin(Ue,
|
|
4755
|
+
let i = await e.select().from(A).leftJoin(Ue, hi()).where(t(a(A.tenant_id, n), a(A.user_id, r))).get();
|
|
4582
4756
|
if (!i) return null;
|
|
4583
4757
|
let o = await e.select().from(A).where(t(a(A.tenant_id, n), a(A.linked_to, r))).all();
|
|
4584
|
-
return
|
|
4758
|
+
return vi(gi(i.users, i.user_activity), o);
|
|
4585
4759
|
},
|
|
4586
4760
|
async update(n, r, i, o) {
|
|
4587
4761
|
let s = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -4608,8 +4782,8 @@ function hi(e) {
|
|
|
4608
4782
|
"zoneinfo"
|
|
4609
4783
|
]) i[e] !== void 0 && (s[e] = i[e]);
|
|
4610
4784
|
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));
|
|
4611
|
-
let c = e.update(A).set(s).where(t(a(A.tenant_id, n), a(A.user_id, r))).returning(), l =
|
|
4612
|
-
return u = l.length > 0 ? (await
|
|
4785
|
+
let c = e.update(A).set(s).where(t(a(A.tenant_id, n), a(A.user_id, r))).returning(), l = ci(e, n, o), u;
|
|
4786
|
+
return u = l.length > 0 ? (await Pt(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 ri(e).upsert(n, r, {
|
|
4613
4787
|
last_login: i.last_login,
|
|
4614
4788
|
last_ip: i.last_ip,
|
|
4615
4789
|
login_count: i.login_count
|
|
@@ -4618,24 +4792,24 @@ function hi(e) {
|
|
|
4618
4792
|
async list(o, s) {
|
|
4619
4793
|
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)];
|
|
4620
4794
|
if (m) {
|
|
4621
|
-
let e = Ee(m,
|
|
4795
|
+
let e = Ee(m, li);
|
|
4622
4796
|
if (e) {
|
|
4623
|
-
let t =
|
|
4797
|
+
let t = Ct(mi, e, ui);
|
|
4624
4798
|
t && h.push(t);
|
|
4625
4799
|
}
|
|
4626
4800
|
}
|
|
4627
4801
|
let g = t(...h), _ = async (n) => {
|
|
4628
4802
|
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))) : [];
|
|
4629
|
-
return n.map((e) =>
|
|
4803
|
+
return n.map((e) => vi(e, i.filter((t) => t.linked_to === e.user_id)));
|
|
4630
4804
|
};
|
|
4631
|
-
if (
|
|
4805
|
+
if (wt(s)) {
|
|
4632
4806
|
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` });
|
|
4633
4807
|
let n = p?.sort_order === "asc" ? "asc" : "desc", r = {
|
|
4634
4808
|
sortColumn: A.created_at,
|
|
4635
4809
|
idColumn: A.user_id,
|
|
4636
4810
|
sortOrder: n,
|
|
4637
4811
|
sortKey: `created_at:${n}`
|
|
4638
|
-
}, i =
|
|
4812
|
+
}, i = Z(s), a = Et(s, r), { rows: o, next: c } = Dt((await e.select().from(A).leftJoin(Ue, hi()).where(a ? t(g, a) : g).orderBy(...Tt(r)).limit(i + 1)).map((e) => gi(e.users, e.user_activity)), i, "created_at", "user_id", r.sortKey), l = await _(o);
|
|
4639
4813
|
return {
|
|
4640
4814
|
users: l,
|
|
4641
4815
|
start: 0,
|
|
@@ -4644,15 +4818,15 @@ function hi(e) {
|
|
|
4644
4818
|
next: c
|
|
4645
4819
|
};
|
|
4646
4820
|
}
|
|
4647
|
-
let v = e.select().from(A).leftJoin(Ue,
|
|
4821
|
+
let v = e.select().from(A).leftJoin(Ue, hi()).where(g).$dynamic();
|
|
4648
4822
|
if (p?.sort_by) {
|
|
4649
|
-
let e =
|
|
4823
|
+
let e = mi[p.sort_by];
|
|
4650
4824
|
if (e) {
|
|
4651
|
-
let t =
|
|
4825
|
+
let t = xt(e) ? St(e) : e;
|
|
4652
4826
|
v = v.orderBy(p.sort_order === "desc" ? i(t) : n(t));
|
|
4653
4827
|
}
|
|
4654
4828
|
}
|
|
4655
|
-
let [y, ee] = await Promise.all([v.offset(c * u).limit(u), d ? e.select({ count: r() }).from(A).leftJoin(Ue,
|
|
4829
|
+
let [y, ee] = await Promise.all([v.offset(c * u).limit(u), d ? e.select({ count: r() }).from(A).leftJoin(Ue, hi()).where(g) : void 0]), b = await _(y.map((e) => gi(e.users, e.user_activity)));
|
|
4656
4830
|
if (!ee) return { users: b };
|
|
4657
4831
|
let [te] = ee;
|
|
4658
4832
|
return {
|
|
@@ -4664,14 +4838,14 @@ function hi(e) {
|
|
|
4664
4838
|
},
|
|
4665
4839
|
async remove(n, r, i) {
|
|
4666
4840
|
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 = [
|
|
4667
|
-
e.delete(
|
|
4841
|
+
e.delete(ft).where(t(a(ft.tenant_id, n), l(ft.user_id, u))),
|
|
4668
4842
|
e.delete(j).where(t(a(j.tenant_id, n), l(j.user_id, u))),
|
|
4669
4843
|
e.delete(Ue).where(t(a(Ue.tenant_id, n), l(Ue.user_id, u))),
|
|
4670
4844
|
e.delete(A).where(t(a(A.tenant_id, n), l(A.user_id, c))),
|
|
4671
4845
|
e.delete(A).where(t(a(A.tenant_id, n), a(A.user_id, r))).returning()
|
|
4672
4846
|
], f = d.length - 1;
|
|
4673
|
-
if (s) for (let t of
|
|
4674
|
-
let p = (await
|
|
4847
|
+
if (s) for (let t of ci(e, n, i)) d.push(t);
|
|
4848
|
+
let p = (await Pt(e, d))[f];
|
|
4675
4849
|
return Array.isArray(p) && p.length > 0;
|
|
4676
4850
|
},
|
|
4677
4851
|
async unlink(n, r, i, o) {
|
|
@@ -4682,11 +4856,11 @@ function hi(e) {
|
|
|
4682
4856
|
}
|
|
4683
4857
|
//#endregion
|
|
4684
4858
|
//#region src/adapters/userRoles.ts
|
|
4685
|
-
function
|
|
4859
|
+
function bi(e) {
|
|
4686
4860
|
return {
|
|
4687
4861
|
async create(t, n, r, i) {
|
|
4688
4862
|
try {
|
|
4689
|
-
await e.insert(
|
|
4863
|
+
await e.insert(W).values({
|
|
4690
4864
|
tenant_id: t,
|
|
4691
4865
|
user_id: n,
|
|
4692
4866
|
role_id: r,
|
|
@@ -4700,28 +4874,48 @@ function gi(e) {
|
|
|
4700
4874
|
return !0;
|
|
4701
4875
|
},
|
|
4702
4876
|
async list(n, r, i, o) {
|
|
4703
|
-
let s = [a(
|
|
4704
|
-
o !== void 0 && s.push(a(
|
|
4705
|
-
let c = await e.select({ role_id:
|
|
4877
|
+
let s = [a(W.tenant_id, n), a(W.user_id, r)];
|
|
4878
|
+
o !== void 0 && s.push(a(W.organization_id, o));
|
|
4879
|
+
let c = await e.select({ role_id: W.role_id }).from(W).where(t(...s)).all();
|
|
4706
4880
|
return c.length === 0 ? [] : (await Promise.all(c.map(async (r) => {
|
|
4707
|
-
let i = await e.select().from(
|
|
4881
|
+
let i = await e.select().from(H).where(t(a(H.tenant_id, n), a(H.id, r.role_id))).get();
|
|
4708
4882
|
if (!i) return null;
|
|
4709
4883
|
let { tenant_id: o, is_system: s, metadata: c, ...l } = i;
|
|
4710
4884
|
return D({
|
|
4711
4885
|
...l,
|
|
4712
4886
|
is_system: s ? !0 : void 0,
|
|
4713
|
-
metadata:
|
|
4887
|
+
metadata: X(c)
|
|
4714
4888
|
});
|
|
4715
4889
|
}))).filter(Boolean);
|
|
4716
4890
|
},
|
|
4891
|
+
async listCheckpoint(n, r, i = {}, o) {
|
|
4892
|
+
let s = [a(W.tenant_id, n), a(W.user_id, r)];
|
|
4893
|
+
o !== void 0 && s.push(a(W.organization_id, o));
|
|
4894
|
+
let c = {
|
|
4895
|
+
sortColumn: H.id,
|
|
4896
|
+
idColumn: H.id,
|
|
4897
|
+
sortOrder: "asc"
|
|
4898
|
+
}, l = Et(i, c), u = Z(i), { rows: d, next: f } = Dt((await e.selectDistinct({ role: H }).from(W).innerJoin(H, t(a(H.tenant_id, W.tenant_id), a(H.id, W.role_id))).where(t(...s, l)).orderBy(...Tt(c)).limit(u + 1).all()).map((e) => e.role), u, "id", "id");
|
|
4899
|
+
return {
|
|
4900
|
+
roles: d.map((e) => {
|
|
4901
|
+
let { tenant_id: t, is_system: n, metadata: r, ...i } = e;
|
|
4902
|
+
return D({
|
|
4903
|
+
...i,
|
|
4904
|
+
is_system: n ? !0 : void 0,
|
|
4905
|
+
metadata: X(r)
|
|
4906
|
+
});
|
|
4907
|
+
}),
|
|
4908
|
+
next: f
|
|
4909
|
+
};
|
|
4910
|
+
},
|
|
4717
4911
|
async listUsers(r, i, o) {
|
|
4718
|
-
let s = t(a(
|
|
4719
|
-
if (
|
|
4912
|
+
let s = t(a(W.tenant_id, r), a(W.role_id, i));
|
|
4913
|
+
if (wt(o)) {
|
|
4720
4914
|
let n = {
|
|
4721
|
-
sortColumn:
|
|
4722
|
-
idColumn:
|
|
4915
|
+
sortColumn: W.user_id,
|
|
4916
|
+
idColumn: W.user_id,
|
|
4723
4917
|
sortOrder: "asc"
|
|
4724
|
-
}, r =
|
|
4918
|
+
}, r = Et(o, n), i = Z(o), { rows: a, next: c } = Dt(await e.selectDistinct({ user_id: W.user_id }).from(W).where(r ? t(s, r) : s).orderBy(...Tt(n)).limit(i + 1).all(), i, "user_id", "user_id");
|
|
4725
4919
|
return {
|
|
4726
4920
|
userIds: a.map((e) => e.user_id),
|
|
4727
4921
|
start: 0,
|
|
@@ -4730,7 +4924,7 @@ function gi(e) {
|
|
|
4730
4924
|
next: c
|
|
4731
4925
|
};
|
|
4732
4926
|
}
|
|
4733
|
-
let c = o?.page || 0, l = o?.per_page || 50, u = c * l, d = await e.selectDistinct({ user_id:
|
|
4927
|
+
let c = o?.page || 0, l = o?.per_page || 50, u = c * l, d = await e.selectDistinct({ user_id: W.user_id }).from(W).where(s).orderBy(n(W.user_id)).limit(l).offset(u).all(), f = await e.select({ count: y`count(distinct ${W.user_id})` }).from(W).where(s).get();
|
|
4734
4928
|
return {
|
|
4735
4929
|
userIds: d.map((e) => e.user_id),
|
|
4736
4930
|
start: u,
|
|
@@ -4739,13 +4933,13 @@ function gi(e) {
|
|
|
4739
4933
|
};
|
|
4740
4934
|
},
|
|
4741
4935
|
async remove(n, r, i, o) {
|
|
4742
|
-
return (await e.delete(
|
|
4936
|
+
return (await e.delete(W).where(t(a(W.tenant_id, n), a(W.user_id, r), a(W.role_id, i), a(W.organization_id, o || ""))).returning()).length > 0;
|
|
4743
4937
|
}
|
|
4744
4938
|
};
|
|
4745
4939
|
}
|
|
4746
4940
|
//#endregion
|
|
4747
4941
|
//#region src/adapters/userOrganizations.ts
|
|
4748
|
-
function
|
|
4942
|
+
function xi(e) {
|
|
4749
4943
|
return {
|
|
4750
4944
|
async create(t, n) {
|
|
4751
4945
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -4757,7 +4951,7 @@ function _i(e) {
|
|
|
4757
4951
|
updated_at: r
|
|
4758
4952
|
};
|
|
4759
4953
|
try {
|
|
4760
|
-
await e.insert(
|
|
4954
|
+
await e.insert(V).values(i);
|
|
4761
4955
|
} catch (e) {
|
|
4762
4956
|
throw e?.message?.includes("UNIQUE constraint") || e?.message?.includes("duplicate key") ? new Re(409, { message: "User organization already exists" }) : e;
|
|
4763
4957
|
}
|
|
@@ -4765,31 +4959,31 @@ function _i(e) {
|
|
|
4765
4959
|
return o;
|
|
4766
4960
|
},
|
|
4767
4961
|
async get(n, r) {
|
|
4768
|
-
let i = await e.select().from(
|
|
4962
|
+
let i = await e.select().from(V).where(t(a(V.tenant_id, n), a(V.id, r))).get();
|
|
4769
4963
|
if (!i) return null;
|
|
4770
4964
|
let { tenant_id: o, ...s } = i;
|
|
4771
4965
|
return s;
|
|
4772
4966
|
},
|
|
4773
4967
|
async update(n, r, i) {
|
|
4774
4968
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
4775
|
-
return i.user_id !== void 0 && (o.user_id = i.user_id), i.organization_id !== void 0 && (o.organization_id = i.organization_id), (await e.update(
|
|
4969
|
+
return i.user_id !== void 0 && (o.user_id = i.user_id), i.organization_id !== void 0 && (o.organization_id = i.organization_id), (await e.update(V).set(o).where(t(a(V.tenant_id, n), a(V.id, r))).returning()).length > 0;
|
|
4776
4970
|
},
|
|
4777
4971
|
async list(n, o) {
|
|
4778
|
-
let { include_totals: s = !1, q: c } = o || {}, l = a(
|
|
4972
|
+
let { include_totals: s = !1, q: c } = o || {}, l = a(V.tenant_id, n), u = l;
|
|
4779
4973
|
if (c) {
|
|
4780
|
-
let e =
|
|
4974
|
+
let e = Ct(V, c, ["user_id", "organization_id"]);
|
|
4781
4975
|
e && (u = t(l, e));
|
|
4782
4976
|
}
|
|
4783
4977
|
let d = (e) => {
|
|
4784
4978
|
let { tenant_id: t, ...n } = e;
|
|
4785
4979
|
return n;
|
|
4786
4980
|
};
|
|
4787
|
-
if (
|
|
4981
|
+
if (wt(o)) {
|
|
4788
4982
|
let n = {
|
|
4789
|
-
sortColumn:
|
|
4790
|
-
idColumn:
|
|
4983
|
+
sortColumn: V.created_at,
|
|
4984
|
+
idColumn: V.id,
|
|
4791
4985
|
sortOrder: "desc"
|
|
4792
|
-
}, r =
|
|
4986
|
+
}, r = Et(o, n), i = Z(o), { rows: a, next: s } = Dt((await e.select().from(V).where(r ? t(u, r) : u).orderBy(...Tt(n)).limit(i + 1)).map(d), i, "created_at");
|
|
4793
4987
|
return {
|
|
4794
4988
|
userOrganizations: a,
|
|
4795
4989
|
start: 0,
|
|
@@ -4798,9 +4992,9 @@ function _i(e) {
|
|
|
4798
4992
|
next: s
|
|
4799
4993
|
};
|
|
4800
4994
|
}
|
|
4801
|
-
let f = o?.page ?? 0, p = o?.per_page ?? 50, m = f * p, h = (await e.select().from(
|
|
4995
|
+
let f = o?.page ?? 0, p = o?.per_page ?? 50, m = f * p, h = (await e.select().from(V).where(u).orderBy(i(V.created_at), i(V.id)).offset(m).limit(p)).map(d);
|
|
4802
4996
|
if (!s) return { userOrganizations: h };
|
|
4803
|
-
let [g] = await e.select({ count: r() }).from(
|
|
4997
|
+
let [g] = await e.select({ count: r() }).from(V).where(u);
|
|
4804
4998
|
return {
|
|
4805
4999
|
userOrganizations: h,
|
|
4806
5000
|
start: m,
|
|
@@ -4809,20 +5003,44 @@ function _i(e) {
|
|
|
4809
5003
|
};
|
|
4810
5004
|
},
|
|
4811
5005
|
async listUserOrganizations(n, i, o) {
|
|
4812
|
-
let { page: s = 0, per_page: c = 50, include_totals: l = !1 } = o || {}
|
|
4813
|
-
|
|
5006
|
+
let { page: s = 0, per_page: c = 50, include_totals: l = !1 } = o || {};
|
|
5007
|
+
if (wt(o)) {
|
|
5008
|
+
let r = {
|
|
5009
|
+
sortColumn: V.created_at,
|
|
5010
|
+
idColumn: V.id,
|
|
5011
|
+
sortOrder: "desc"
|
|
5012
|
+
}, s = Z(o), c = Et(o, r), { rows: l, next: u } = Dt(await e.select().from(V).where(t(a(V.tenant_id, n), a(V.user_id, i), c)).orderBy(...Tt(r)).limit(s + 1).all(), s, "created_at"), d = (await Promise.all(l.map((r) => e.select().from(B).where(t(a(B.tenant_id, n), a(B.id, r.organization_id))).get()))).filter(Boolean).map((e) => {
|
|
5013
|
+
let { tenant_id: t, branding: n, metadata: r, enabled_connections: i, token_quota: a, ...o } = e;
|
|
5014
|
+
return D({
|
|
5015
|
+
...o,
|
|
5016
|
+
branding: X(n, {}),
|
|
5017
|
+
metadata: X(r, {}),
|
|
5018
|
+
enabled_connections: X(i, []),
|
|
5019
|
+
token_quota: X(a, {})
|
|
5020
|
+
});
|
|
5021
|
+
});
|
|
5022
|
+
return {
|
|
5023
|
+
organizations: d,
|
|
5024
|
+
start: 0,
|
|
5025
|
+
limit: s,
|
|
5026
|
+
length: d.length,
|
|
5027
|
+
next: u
|
|
5028
|
+
};
|
|
5029
|
+
}
|
|
5030
|
+
let u = await e.select().from(V).where(t(a(V.tenant_id, n), a(V.user_id, i))).offset(s * c).limit(c).all(), d = (await Promise.all(u.map(async (r) => {
|
|
5031
|
+
let i = await e.select().from(B).where(t(a(B.tenant_id, n), a(B.id, r.organization_id))).get();
|
|
4814
5032
|
if (!i) return null;
|
|
4815
5033
|
let { tenant_id: o, branding: s, metadata: c, enabled_connections: l, token_quota: u, ...d } = i;
|
|
4816
5034
|
return D({
|
|
4817
5035
|
...d,
|
|
4818
|
-
branding:
|
|
4819
|
-
metadata:
|
|
4820
|
-
enabled_connections:
|
|
4821
|
-
token_quota:
|
|
5036
|
+
branding: X(s, {}),
|
|
5037
|
+
metadata: X(c, {}),
|
|
5038
|
+
enabled_connections: X(l, []),
|
|
5039
|
+
token_quota: X(u, {})
|
|
4822
5040
|
});
|
|
4823
5041
|
}))).filter(Boolean);
|
|
4824
5042
|
if (!l) return { organizations: d };
|
|
4825
|
-
let [f] = await e.select({ count: r() }).from(
|
|
5043
|
+
let [f] = await e.select({ count: r() }).from(V).where(t(a(V.tenant_id, n), a(V.user_id, i)));
|
|
4826
5044
|
return {
|
|
4827
5045
|
organizations: d,
|
|
4828
5046
|
start: s * c,
|
|
@@ -4831,26 +5049,26 @@ function _i(e) {
|
|
|
4831
5049
|
};
|
|
4832
5050
|
},
|
|
4833
5051
|
async remove(n, r) {
|
|
4834
|
-
return (await e.delete(
|
|
5052
|
+
return (await e.delete(V).where(t(a(V.tenant_id, n), a(V.id, r))).returning()).length > 0;
|
|
4835
5053
|
}
|
|
4836
5054
|
};
|
|
4837
5055
|
}
|
|
4838
5056
|
//#endregion
|
|
4839
5057
|
//#region src/adapters/stats.ts
|
|
4840
|
-
var
|
|
4841
|
-
function
|
|
5058
|
+
var Si = ["s"], Ci = ["pwd_leak"];
|
|
5059
|
+
function wi(e) {
|
|
4842
5060
|
return /^\d{8}$/.test(e) ? `${e.slice(0, 4)}-${e.slice(4, 6)}-${e.slice(6, 8)}` : e;
|
|
4843
5061
|
}
|
|
4844
|
-
function
|
|
5062
|
+
function Ti(e) {
|
|
4845
5063
|
return {
|
|
4846
5064
|
async getDaily(n, r) {
|
|
4847
|
-
let i = /* @__PURE__ */ new Date(), o = r?.from ?
|
|
5065
|
+
let i = /* @__PURE__ */ new Date(), o = r?.from ? wi(r.from) : (/* @__PURE__ */ new Date(i.getTime() - 720 * 60 * 60 * 1e3)).toISOString().split("T")[0], s = r?.to ? wi(r.to) : i.toISOString().split("T")[0];
|
|
4848
5066
|
return (await e.select({
|
|
4849
|
-
date: y`substr(${
|
|
4850
|
-
logins: y`SUM(CASE WHEN ${
|
|
4851
|
-
signups: y`SUM(CASE WHEN ${
|
|
4852
|
-
leaked_passwords: y`SUM(CASE WHEN ${
|
|
4853
|
-
}).from(
|
|
5067
|
+
date: y`substr(${K.date}, 1, 10)`.as("date"),
|
|
5068
|
+
logins: y`SUM(CASE WHEN ${K.type} IN (${y.join(Si.map((e) => y`${e}`), y`, `)}) THEN 1 ELSE 0 END)`.as("logins"),
|
|
5069
|
+
signups: y`SUM(CASE WHEN ${K.type} = 'ss' THEN 1 ELSE 0 END)`.as("signups"),
|
|
5070
|
+
leaked_passwords: y`SUM(CASE WHEN ${K.type} IN (${y.join(Ci.map((e) => y`${e}`), y`, `)}) THEN 1 ELSE 0 END)`.as("leaked_passwords")
|
|
5071
|
+
}).from(K).where(t(a(K.tenant_id, n), c(K.date, o), h(K.date, `${s}T23:59:59.999Z`))).groupBy(y`substr(${K.date}, 1, 10)`).orderBy(y`substr(${K.date}, 1, 10)`).all()).map((e) => ({
|
|
4854
5072
|
date: e.date,
|
|
4855
5073
|
logins: Number(e.logins) || 0,
|
|
4856
5074
|
signups: Number(e.signups) || 0,
|
|
@@ -4860,14 +5078,14 @@ function xi(e) {
|
|
|
4860
5078
|
}));
|
|
4861
5079
|
},
|
|
4862
5080
|
async getActiveUsers(n) {
|
|
4863
|
-
let r = (/* @__PURE__ */ new Date(Date.now() - 720 * 60 * 60 * 1e3)).toISOString(), [i] = await e.select({ count: y`COUNT(DISTINCT ${
|
|
5081
|
+
let r = (/* @__PURE__ */ new Date(Date.now() - 720 * 60 * 60 * 1e3)).toISOString(), [i] = await e.select({ count: y`COUNT(DISTINCT ${K.user_id})`.as("count") }).from(K).where(t(a(K.tenant_id, n), c(K.date, r), y`${K.type} IN (${y.join(Si.map((e) => y`${e}`), y`, `)})`));
|
|
4864
5082
|
return Number(i?.count) || 0;
|
|
4865
5083
|
}
|
|
4866
5084
|
};
|
|
4867
5085
|
}
|
|
4868
5086
|
//#endregion
|
|
4869
5087
|
//#region src/adapters/analytics.ts
|
|
4870
|
-
var
|
|
5088
|
+
var Ei = {
|
|
4871
5089
|
"active-users": ["s", "seacft"],
|
|
4872
5090
|
logins: [
|
|
4873
5091
|
"s",
|
|
@@ -4897,7 +5115,7 @@ var Si = {
|
|
|
4897
5115
|
"fvr"
|
|
4898
5116
|
],
|
|
4899
5117
|
"codes-sent": ["cls", "cs"]
|
|
4900
|
-
},
|
|
5118
|
+
}, Di = {
|
|
4901
5119
|
"active-users": {
|
|
4902
5120
|
alias: "active_users",
|
|
4903
5121
|
type: "UInt64",
|
|
@@ -4954,64 +5172,64 @@ var Si = {
|
|
|
4954
5172
|
agg: "count"
|
|
4955
5173
|
}
|
|
4956
5174
|
};
|
|
4957
|
-
function
|
|
5175
|
+
function Oi(e) {
|
|
4958
5176
|
switch (e) {
|
|
4959
|
-
case "hour": return y`substr(${
|
|
4960
|
-
case "month": return y`substr(${
|
|
4961
|
-
case "day": return y`substr(${
|
|
4962
|
-
case "week": return y`date(substr(${
|
|
5177
|
+
case "hour": return y`substr(${K.date}, 1, 13)`;
|
|
5178
|
+
case "month": return y`substr(${K.date}, 1, 7)`;
|
|
5179
|
+
case "day": return y`substr(${K.date}, 1, 10)`;
|
|
5180
|
+
case "week": return y`date(substr(${K.date}, 1, 10), '-' || ((cast(strftime('%w', substr(${K.date}, 1, 10)) as integer) + 6) % 7) || ' days')`;
|
|
4963
5181
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4964
5182
|
}
|
|
4965
5183
|
}
|
|
4966
|
-
function
|
|
5184
|
+
function ki(e) {
|
|
4967
5185
|
return `"${e.replace(/"/g, "\"\"")}"`;
|
|
4968
5186
|
}
|
|
4969
|
-
function
|
|
5187
|
+
function Ai(e) {
|
|
4970
5188
|
switch (e) {
|
|
4971
|
-
case "connection": return
|
|
4972
|
-
case "client_id": return
|
|
4973
|
-
case "user_type": return
|
|
4974
|
-
case "event": return
|
|
5189
|
+
case "connection": return K.connection;
|
|
5190
|
+
case "client_id": return K.client_id;
|
|
5191
|
+
case "user_type": return K.strategy_type;
|
|
5192
|
+
case "event": return K.type;
|
|
4975
5193
|
case "time": throw Error("time dimension handled separately");
|
|
4976
5194
|
}
|
|
4977
5195
|
}
|
|
4978
|
-
function
|
|
5196
|
+
function ji(e) {
|
|
4979
5197
|
return {
|
|
4980
5198
|
async query(n, r, i) {
|
|
4981
|
-
let o = Date.now(), s =
|
|
4982
|
-
a(
|
|
4983
|
-
c(
|
|
4984
|
-
m(
|
|
4985
|
-
l(
|
|
5199
|
+
let o = Date.now(), s = Ei[r], u = Di[r], d = [
|
|
5200
|
+
a(K.tenant_id, n),
|
|
5201
|
+
c(K.date, i.from),
|
|
5202
|
+
m(K.date, i.to),
|
|
5203
|
+
l(K.type, s)
|
|
4986
5204
|
];
|
|
4987
|
-
i.filters.connection?.length && d.push(l(
|
|
5205
|
+
i.filters.connection?.length && d.push(l(K.connection, i.filters.connection)), i.filters.client_id?.length && d.push(l(K.client_id, i.filters.client_id)), i.filters.user_type?.length && d.push(l(K.strategy_type, i.filters.user_type)), i.filters.user_id?.length && d.push(l(K.user_id, i.filters.user_id));
|
|
4988
5206
|
let f = {}, p = [], h = [];
|
|
4989
5207
|
for (let e of i.group_by) if (e === "time") {
|
|
4990
|
-
let e =
|
|
5208
|
+
let e = Oi(i.interval);
|
|
4991
5209
|
f.time = e, p.push(e), h.push({
|
|
4992
5210
|
name: "time",
|
|
4993
5211
|
type: i.interval === "hour" ? "DateTime" : "Date"
|
|
4994
5212
|
});
|
|
4995
5213
|
} else {
|
|
4996
|
-
let t =
|
|
5214
|
+
let t = Ai(e);
|
|
4997
5215
|
f[e] = t, p.push(t), h.push({
|
|
4998
5216
|
name: e,
|
|
4999
5217
|
type: "String"
|
|
5000
5218
|
});
|
|
5001
5219
|
}
|
|
5002
|
-
f[u.alias] = u.agg === "uniq" ? y`COUNT(DISTINCT ${
|
|
5220
|
+
f[u.alias] = u.agg === "uniq" ? y`COUNT(DISTINCT ${K.user_id})` : y`COUNT(*)`, h.push({
|
|
5003
5221
|
name: u.alias,
|
|
5004
5222
|
type: u.type
|
|
5005
5223
|
});
|
|
5006
|
-
let g = e.select(f).from(
|
|
5224
|
+
let g = e.select(f).from(K).where(t(...d));
|
|
5007
5225
|
p.length > 0 && (g = g.groupBy(...p));
|
|
5008
5226
|
let _ = new Set([...Object.keys(f)]);
|
|
5009
5227
|
if (i.order_by) {
|
|
5010
5228
|
let e = i.order_by.startsWith("-"), t = e ? i.order_by.slice(1) : i.order_by;
|
|
5011
5229
|
if (!_.has(t)) throw Error(`Invalid order_by column '${t}' for analytics query`);
|
|
5012
|
-
let n =
|
|
5230
|
+
let n = ki(t);
|
|
5013
5231
|
g = g.orderBy(y.raw(`${n} ${e ? "DESC" : "ASC"}`));
|
|
5014
|
-
} else g = i.group_by[0] === "time" ? g.orderBy(y.raw(`${
|
|
5232
|
+
} else g = i.group_by[0] === "time" ? g.orderBy(y.raw(`${ki("time")} ASC`)) : g.orderBy(y.raw(`${ki(u.alias)} DESC`));
|
|
5015
5233
|
g = g.limit(i.limit).offset(i.offset);
|
|
5016
5234
|
let v = (await g.all()).map((e) => {
|
|
5017
5235
|
let t = {};
|
|
@@ -5060,10 +5278,10 @@ function Di(e) {
|
|
|
5060
5278
|
}
|
|
5061
5279
|
//#endregion
|
|
5062
5280
|
//#region src/adapters/cleanup.ts
|
|
5063
|
-
var
|
|
5064
|
-
function
|
|
5281
|
+
var Mi = 10080 * 60 * 1e3;
|
|
5282
|
+
function Ni(e) {
|
|
5065
5283
|
return async (n) => {
|
|
5066
|
-
let r = Date.now() -
|
|
5284
|
+
let r = Date.now() - Mi;
|
|
5067
5285
|
try {
|
|
5068
5286
|
let i = [v(m(N.expires_at_ts, r), m(N.idle_expires_at_ts, r))];
|
|
5069
5287
|
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));
|
|
@@ -5098,7 +5316,7 @@ var Q = w("tenant_operations", {
|
|
|
5098
5316
|
x("tenant_operations_tenant_id_created_at_idx").on(e.tenant_id, e.created_at),
|
|
5099
5317
|
x("tenant_operations_rollout_id_idx").on(e.rollout_id),
|
|
5100
5318
|
x("tenant_operations_status_idx").on(e.status)
|
|
5101
|
-
]),
|
|
5319
|
+
]), Pi = w("tenant_operation_events", {
|
|
5102
5320
|
id: T("id", { length: 255 }).primaryKey(),
|
|
5103
5321
|
operation_id: T("operation_id", { length: 255 }).notNull(),
|
|
5104
5322
|
step: T("step", { length: 255 }).notNull(),
|
|
@@ -5129,7 +5347,7 @@ var Q = w("tenant_operations", {
|
|
|
5129
5347
|
name: "tenant_operation_rows_operation_id_constraint"
|
|
5130
5348
|
}).onDelete("cascade"),
|
|
5131
5349
|
x("tenant_operation_rows_operation_id_status_idx").on(e.operation_id, e.status)
|
|
5132
|
-
]),
|
|
5350
|
+
]), Fi = w("rollouts", {
|
|
5133
5351
|
id: T("id", { length: 255 }).primaryKey(),
|
|
5134
5352
|
kind: T("kind", { length: 32 }).notNull(),
|
|
5135
5353
|
status: T("status", { length: 32 }).notNull(),
|
|
@@ -5145,7 +5363,7 @@ var Q = w("tenant_operations", {
|
|
|
5145
5363
|
});
|
|
5146
5364
|
//#endregion
|
|
5147
5365
|
//#region src/adapters/tenantOperations.ts
|
|
5148
|
-
function
|
|
5366
|
+
function Ii(e) {
|
|
5149
5367
|
if (!e) return null;
|
|
5150
5368
|
try {
|
|
5151
5369
|
return JSON.parse(e);
|
|
@@ -5153,7 +5371,7 @@ function Mi(e) {
|
|
|
5153
5371
|
return null;
|
|
5154
5372
|
}
|
|
5155
5373
|
}
|
|
5156
|
-
function
|
|
5374
|
+
function Li(e) {
|
|
5157
5375
|
return Fe.parse({
|
|
5158
5376
|
id: e.id,
|
|
5159
5377
|
tenant_id: e.tenant_id,
|
|
@@ -5167,8 +5385,8 @@ function Ni(e) {
|
|
|
5167
5385
|
target_database_version: e.target_database_version,
|
|
5168
5386
|
error: e.error,
|
|
5169
5387
|
initiated_by: e.initiated_by,
|
|
5170
|
-
input:
|
|
5171
|
-
result:
|
|
5388
|
+
input: Ii(e.input),
|
|
5389
|
+
result: Ii(e.result),
|
|
5172
5390
|
claimed_by: e.claimed_by,
|
|
5173
5391
|
claim_expires_at: e.claim_expires_at,
|
|
5174
5392
|
created_at: e.created_at,
|
|
@@ -5176,7 +5394,7 @@ function Ni(e) {
|
|
|
5176
5394
|
finished_at: e.finished_at
|
|
5177
5395
|
});
|
|
5178
5396
|
}
|
|
5179
|
-
function
|
|
5397
|
+
function Ri(e) {
|
|
5180
5398
|
return {
|
|
5181
5399
|
async create(t) {
|
|
5182
5400
|
let n = Me.parse(t), r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -5207,7 +5425,7 @@ function Pi(e) {
|
|
|
5207
5425
|
},
|
|
5208
5426
|
async get(t) {
|
|
5209
5427
|
let n = await e.select().from(Q).where(a(Q.id, t)).limit(1);
|
|
5210
|
-
return n[0] ?
|
|
5428
|
+
return n[0] ? Li(n[0]) : null;
|
|
5211
5429
|
},
|
|
5212
5430
|
async list(n = {}) {
|
|
5213
5431
|
let r = n.page ?? 0, o = n.per_page ?? 50, s = [];
|
|
@@ -5218,7 +5436,7 @@ function Pi(e) {
|
|
|
5218
5436
|
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));
|
|
5219
5437
|
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);
|
|
5220
5438
|
return {
|
|
5221
|
-
operations: c.map(
|
|
5439
|
+
operations: c.map(Li),
|
|
5222
5440
|
start: r * o,
|
|
5223
5441
|
limit: o,
|
|
5224
5442
|
length: c.length
|
|
@@ -5244,7 +5462,7 @@ function Pi(e) {
|
|
|
5244
5462
|
},
|
|
5245
5463
|
async listResumable(r) {
|
|
5246
5464
|
let i = (/* @__PURE__ */ new Date()).toISOString();
|
|
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(
|
|
5465
|
+
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(Li);
|
|
5248
5466
|
},
|
|
5249
5467
|
async remove(t) {
|
|
5250
5468
|
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);
|
|
@@ -5253,19 +5471,19 @@ function Pi(e) {
|
|
|
5253
5471
|
}
|
|
5254
5472
|
//#endregion
|
|
5255
5473
|
//#region src/adapters/tenantOperationRows.ts
|
|
5256
|
-
var
|
|
5257
|
-
function
|
|
5474
|
+
var zi = 50, Bi = 50;
|
|
5475
|
+
function Vi(e) {
|
|
5258
5476
|
try {
|
|
5259
5477
|
return JSON.parse(e);
|
|
5260
5478
|
} catch {
|
|
5261
5479
|
return {};
|
|
5262
5480
|
}
|
|
5263
5481
|
}
|
|
5264
|
-
function
|
|
5482
|
+
function Hi(e) {
|
|
5265
5483
|
return Pe.parse({
|
|
5266
5484
|
operation_id: e.operation_id,
|
|
5267
5485
|
seq: e.seq,
|
|
5268
|
-
payload:
|
|
5486
|
+
payload: Vi(e.payload),
|
|
5269
5487
|
status: e.status,
|
|
5270
5488
|
error_code: e.error_code,
|
|
5271
5489
|
error_message: e.error_message,
|
|
@@ -5275,12 +5493,12 @@ function Ri(e) {
|
|
|
5275
5493
|
updated_at: e.updated_at
|
|
5276
5494
|
});
|
|
5277
5495
|
}
|
|
5278
|
-
function
|
|
5496
|
+
function Ui(e, t) {
|
|
5279
5497
|
let n = [];
|
|
5280
5498
|
for (let r = 0; r < e.length; r += t) n.push(e.slice(r, r + t));
|
|
5281
5499
|
return n;
|
|
5282
5500
|
}
|
|
5283
|
-
function
|
|
5501
|
+
function Wi(e, n, r, i) {
|
|
5284
5502
|
return e.update($).set({
|
|
5285
5503
|
status: r.status,
|
|
5286
5504
|
error_code: r.error_code ?? null,
|
|
@@ -5290,7 +5508,7 @@ function Bi(e, n, r, i) {
|
|
|
5290
5508
|
updated_at: i
|
|
5291
5509
|
}).where(t(a($.operation_id, n), a($.seq, r.seq), a($.status, "pending")));
|
|
5292
5510
|
}
|
|
5293
|
-
function
|
|
5511
|
+
function Gi(e) {
|
|
5294
5512
|
return {
|
|
5295
5513
|
async createMany(t) {
|
|
5296
5514
|
if (t.length === 0) return 0;
|
|
@@ -5309,24 +5527,24 @@ function Vi(e) {
|
|
|
5309
5527
|
updated_at: n
|
|
5310
5528
|
};
|
|
5311
5529
|
});
|
|
5312
|
-
for (let t of
|
|
5530
|
+
for (let t of Ui(r, zi)) await e.insert($).values(t);
|
|
5313
5531
|
return r.length;
|
|
5314
5532
|
},
|
|
5315
5533
|
async claimPending(r, i) {
|
|
5316
|
-
return (await e.select().from($).where(t(a($.operation_id, r), a($.status, "pending"))).orderBy(n($.seq)).limit(i)).map(
|
|
5534
|
+
return (await e.select().from($).where(t(a($.operation_id, r), a($.status, "pending"))).orderBy(n($.seq)).limit(i)).map(Hi);
|
|
5317
5535
|
},
|
|
5318
5536
|
async recordOutcomes(n, r) {
|
|
5319
5537
|
if (r.length === 0) return 0;
|
|
5320
5538
|
let i = (/* @__PURE__ */ new Date()).toISOString(), o = r.map((e) => e.seq), s = /* @__PURE__ */ new Set();
|
|
5321
|
-
for (let r of
|
|
5539
|
+
for (let r of Ui(o, Bi)) {
|
|
5322
5540
|
let i = await e.select({ seq: $.seq }).from($).where(t(a($.operation_id, n), a($.status, "pending"), l($.seq, r)));
|
|
5323
5541
|
for (let e of i) s.add(e.seq);
|
|
5324
5542
|
}
|
|
5325
5543
|
let c = r.filter((e) => s.has(e.seq));
|
|
5326
5544
|
if (c.length === 0) return 0;
|
|
5327
|
-
for (let t of
|
|
5328
|
-
let [r, ...a] = t.map((t) =>
|
|
5329
|
-
r && await
|
|
5545
|
+
for (let t of Ui(c, Bi)) {
|
|
5546
|
+
let [r, ...a] = t.map((t) => Wi(e, n, t, i));
|
|
5547
|
+
r && await Pt(e, [r, ...a]);
|
|
5330
5548
|
}
|
|
5331
5549
|
return c.length;
|
|
5332
5550
|
},
|
|
@@ -5361,7 +5579,7 @@ function Vi(e) {
|
|
|
5361
5579
|
}
|
|
5362
5580
|
let u = await e.select().from($).where(t(...c)).orderBy(n($.seq)).offset(o * s).limit(s);
|
|
5363
5581
|
return {
|
|
5364
|
-
rows: u.map(
|
|
5582
|
+
rows: u.map(Hi),
|
|
5365
5583
|
start: o * s,
|
|
5366
5584
|
limit: s,
|
|
5367
5585
|
length: u.length
|
|
@@ -5375,27 +5593,27 @@ function Vi(e) {
|
|
|
5375
5593
|
}
|
|
5376
5594
|
//#endregion
|
|
5377
5595
|
//#region src/helpers/monotonic-id.ts
|
|
5378
|
-
var
|
|
5379
|
-
function
|
|
5596
|
+
var Ki = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", qi = 32, Ji = 10, Yi = 4, Xi = 10;
|
|
5597
|
+
function Zi(e, t) {
|
|
5380
5598
|
let n = "";
|
|
5381
|
-
for (let r = t; r > 0; r--) n =
|
|
5599
|
+
for (let r = t; r > 0; r--) n = Ki.charAt(e % qi) + n, e = Math.floor(e / qi);
|
|
5382
5600
|
return n;
|
|
5383
5601
|
}
|
|
5384
|
-
function
|
|
5385
|
-
let e = new Uint8Array(
|
|
5602
|
+
function Qi() {
|
|
5603
|
+
let e = new Uint8Array(Xi);
|
|
5386
5604
|
crypto.getRandomValues(e);
|
|
5387
5605
|
let t = "";
|
|
5388
|
-
for (let n = 0; n <
|
|
5606
|
+
for (let n = 0; n < Xi; n++) t += Ki.charAt(e[n] % qi);
|
|
5389
5607
|
return t;
|
|
5390
5608
|
}
|
|
5391
|
-
var
|
|
5392
|
-
function
|
|
5609
|
+
var $i = 0, ea = 0;
|
|
5610
|
+
function ta() {
|
|
5393
5611
|
let e = Date.now();
|
|
5394
|
-
return e ===
|
|
5612
|
+
return e === $i ? ea++ : ($i = e, ea = 0), Zi(e, Ji) + Zi(ea, Yi) + Qi();
|
|
5395
5613
|
}
|
|
5396
5614
|
//#endregion
|
|
5397
5615
|
//#region src/adapters/tenantOperationEvents.ts
|
|
5398
|
-
function
|
|
5616
|
+
function na(e) {
|
|
5399
5617
|
if (!e) return null;
|
|
5400
5618
|
try {
|
|
5401
5619
|
let t = JSON.parse(e);
|
|
@@ -5403,22 +5621,22 @@ function Qi(e) {
|
|
|
5403
5621
|
} catch {}
|
|
5404
5622
|
return null;
|
|
5405
5623
|
}
|
|
5406
|
-
function
|
|
5624
|
+
function ra(e) {
|
|
5407
5625
|
return je.parse({
|
|
5408
5626
|
id: e.id,
|
|
5409
5627
|
operation_id: e.operation_id,
|
|
5410
5628
|
step: e.step,
|
|
5411
5629
|
outcome: e.outcome,
|
|
5412
|
-
detail:
|
|
5630
|
+
detail: na(e.detail),
|
|
5413
5631
|
attempt: e.attempt,
|
|
5414
5632
|
created_at: e.created_at
|
|
5415
5633
|
});
|
|
5416
5634
|
}
|
|
5417
|
-
function
|
|
5635
|
+
function ia(e) {
|
|
5418
5636
|
return {
|
|
5419
5637
|
async create(t) {
|
|
5420
5638
|
let n = Ae.parse(t), r = {
|
|
5421
|
-
id: `evt_${
|
|
5639
|
+
id: `evt_${ta()}`,
|
|
5422
5640
|
operation_id: n.operation_id,
|
|
5423
5641
|
step: n.step,
|
|
5424
5642
|
outcome: n.outcome,
|
|
@@ -5426,7 +5644,7 @@ function ea(e) {
|
|
|
5426
5644
|
attempt: n.attempt,
|
|
5427
5645
|
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
5428
5646
|
};
|
|
5429
|
-
return await e.insert(
|
|
5647
|
+
return await e.insert(Pi).values(r), je.parse({
|
|
5430
5648
|
id: r.id,
|
|
5431
5649
|
operation_id: r.operation_id,
|
|
5432
5650
|
step: r.step,
|
|
@@ -5437,9 +5655,9 @@ function ea(e) {
|
|
|
5437
5655
|
});
|
|
5438
5656
|
},
|
|
5439
5657
|
async listByOperation(t, r = {}) {
|
|
5440
|
-
let i = r.page ?? 0, o = r.per_page ?? 100, s = await e.select().from(
|
|
5658
|
+
let i = r.page ?? 0, o = r.per_page ?? 100, s = await e.select().from(Pi).where(a(Pi.operation_id, t)).orderBy(n(Pi.created_at), n(Pi.id)).offset(i * o).limit(o);
|
|
5441
5659
|
return {
|
|
5442
|
-
events: s.map(
|
|
5660
|
+
events: s.map(ra),
|
|
5443
5661
|
start: i * o,
|
|
5444
5662
|
limit: o,
|
|
5445
5663
|
length: s.length
|
|
@@ -5449,7 +5667,7 @@ function ea(e) {
|
|
|
5449
5667
|
}
|
|
5450
5668
|
//#endregion
|
|
5451
5669
|
//#region src/adapters/rollouts.ts
|
|
5452
|
-
function
|
|
5670
|
+
function aa(e) {
|
|
5453
5671
|
if (!e) return null;
|
|
5454
5672
|
try {
|
|
5455
5673
|
return JSON.parse(e);
|
|
@@ -5457,7 +5675,7 @@ function ta(e) {
|
|
|
5457
5675
|
return null;
|
|
5458
5676
|
}
|
|
5459
5677
|
}
|
|
5460
|
-
function
|
|
5678
|
+
function oa(e) {
|
|
5461
5679
|
return Te.parse({
|
|
5462
5680
|
id: e.id,
|
|
5463
5681
|
kind: e.kind,
|
|
@@ -5465,15 +5683,15 @@ function na(e) {
|
|
|
5465
5683
|
target_worker_version: e.target_worker_version,
|
|
5466
5684
|
target_database_version: e.target_database_version,
|
|
5467
5685
|
wave_size: e.wave_size,
|
|
5468
|
-
canary_tenant_ids:
|
|
5469
|
-
filter:
|
|
5686
|
+
canary_tenant_ids: aa(e.canary_tenant_ids),
|
|
5687
|
+
filter: aa(e.filter),
|
|
5470
5688
|
initiated_by: e.initiated_by,
|
|
5471
5689
|
created_at: e.created_at,
|
|
5472
5690
|
updated_at: e.updated_at,
|
|
5473
5691
|
finished_at: e.finished_at
|
|
5474
5692
|
});
|
|
5475
5693
|
}
|
|
5476
|
-
function
|
|
5694
|
+
function sa(e) {
|
|
5477
5695
|
return {
|
|
5478
5696
|
async create(t) {
|
|
5479
5697
|
let n = we.parse(t), r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -5490,42 +5708,42 @@ function ra(e) {
|
|
|
5490
5708
|
updated_at: r,
|
|
5491
5709
|
finished_at: null
|
|
5492
5710
|
};
|
|
5493
|
-
await e.insert(
|
|
5711
|
+
await e.insert(Fi).values(i);
|
|
5494
5712
|
let a = await this.get(i.id);
|
|
5495
5713
|
if (!a) throw Error(`Failed to create rollout ${i.id}`);
|
|
5496
5714
|
return a;
|
|
5497
5715
|
},
|
|
5498
5716
|
async get(t) {
|
|
5499
|
-
let n = await e.select().from(
|
|
5500
|
-
return n[0] ?
|
|
5717
|
+
let n = await e.select().from(Fi).where(a(Fi.id, t)).limit(1);
|
|
5718
|
+
return n[0] ? oa(n[0]) : null;
|
|
5501
5719
|
},
|
|
5502
5720
|
async list(t = {}) {
|
|
5503
|
-
let n = t.page ?? 0, r = t.per_page ?? 50, a = await e.select().from(
|
|
5721
|
+
let n = t.page ?? 0, r = t.per_page ?? 50, a = await e.select().from(Fi).orderBy(i(Fi.created_at), i(Fi.id)).offset(n * r).limit(r);
|
|
5504
5722
|
return {
|
|
5505
|
-
rollouts: a.map(
|
|
5723
|
+
rollouts: a.map(oa),
|
|
5506
5724
|
start: n * r,
|
|
5507
5725
|
limit: r,
|
|
5508
5726
|
length: a.length
|
|
5509
5727
|
};
|
|
5510
5728
|
},
|
|
5511
5729
|
async update(t, n) {
|
|
5512
|
-
if ((await e.select({ id:
|
|
5730
|
+
if ((await e.select({ id: Fi.id }).from(Fi).where(a(Fi.id, t)).limit(1)).length === 0) return !1;
|
|
5513
5731
|
let r = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
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(
|
|
5732
|
+
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(Fi).set(r).where(a(Fi.id, t)), !0;
|
|
5515
5733
|
},
|
|
5516
5734
|
async remove(t) {
|
|
5517
|
-
return (await e.select({ id:
|
|
5735
|
+
return (await e.select({ id: Fi.id }).from(Fi).where(a(Fi.id, t)).limit(1)).length === 0 ? !1 : (await e.delete(Fi).where(a(Fi.id, t)), !0);
|
|
5518
5736
|
}
|
|
5519
5737
|
};
|
|
5520
5738
|
}
|
|
5521
5739
|
//#endregion
|
|
5522
5740
|
//#region src/adapters/index.ts
|
|
5523
|
-
function
|
|
5741
|
+
function ca(e, t = { useTransactions: !0 }) {
|
|
5524
5742
|
let n = {
|
|
5525
|
-
actions:
|
|
5526
|
-
actionExecutions:
|
|
5527
|
-
actionVersions:
|
|
5528
|
-
branding:
|
|
5743
|
+
actions: At(e),
|
|
5744
|
+
actionExecutions: Mt(e),
|
|
5745
|
+
actionVersions: It(e),
|
|
5746
|
+
branding: Rt(e),
|
|
5529
5747
|
clients: Wt(e),
|
|
5530
5748
|
clientConnections: Kt(e),
|
|
5531
5749
|
clientGrants: Jt(e),
|
|
@@ -5536,53 +5754,53 @@ function ia(e, t = { useTransactions: !0 }) {
|
|
|
5536
5754
|
customText: un(e),
|
|
5537
5755
|
emailProviders: dn(e),
|
|
5538
5756
|
emailTemplates: pn(e),
|
|
5539
|
-
flows:
|
|
5540
|
-
forms:
|
|
5541
|
-
grants:
|
|
5542
|
-
hookCode:
|
|
5543
|
-
hooks:
|
|
5544
|
-
invites:
|
|
5545
|
-
keys:
|
|
5546
|
-
loginSessions:
|
|
5547
|
-
logs:
|
|
5548
|
-
logStreams:
|
|
5549
|
-
migrationSources:
|
|
5550
|
-
authenticationMethods:
|
|
5551
|
-
organizations:
|
|
5552
|
-
organizationConnections:
|
|
5553
|
-
passwords:
|
|
5554
|
-
promptSettings:
|
|
5555
|
-
promptPartials:
|
|
5556
|
-
proxyRoutes:
|
|
5557
|
-
scimConfigurations:
|
|
5558
|
-
scimTokens:
|
|
5559
|
-
scimExternalIds:
|
|
5560
|
-
refreshTokens:
|
|
5561
|
-
resourceServers:
|
|
5562
|
-
rolePermissions:
|
|
5563
|
-
userPermissions:
|
|
5564
|
-
roles:
|
|
5565
|
-
sessions:
|
|
5566
|
-
sessionCleanup:
|
|
5567
|
-
tenants:
|
|
5568
|
-
tokenExchangeProfiles:
|
|
5757
|
+
flows: gn(e),
|
|
5758
|
+
forms: bn(e),
|
|
5759
|
+
grants: wn(e),
|
|
5760
|
+
hookCode: On(e),
|
|
5761
|
+
hooks: Mn(e),
|
|
5762
|
+
invites: In(e),
|
|
5763
|
+
keys: Rn(e),
|
|
5764
|
+
loginSessions: Un(e),
|
|
5765
|
+
logs: Gn(e),
|
|
5766
|
+
logStreams: ir(e),
|
|
5767
|
+
migrationSources: or(e),
|
|
5768
|
+
authenticationMethods: Xn(e),
|
|
5769
|
+
organizations: er(e),
|
|
5770
|
+
organizationConnections: nr(e),
|
|
5771
|
+
passwords: cr(e),
|
|
5772
|
+
promptSettings: lr(e),
|
|
5773
|
+
promptPartials: ur(e),
|
|
5774
|
+
proxyRoutes: mr(e),
|
|
5775
|
+
scimConfigurations: Sr(e),
|
|
5776
|
+
scimTokens: wr(e),
|
|
5777
|
+
scimExternalIds: Er(e),
|
|
5778
|
+
refreshTokens: kr(e),
|
|
5779
|
+
resourceServers: Fr(e),
|
|
5780
|
+
rolePermissions: Ir(e),
|
|
5781
|
+
userPermissions: zr(e),
|
|
5782
|
+
roles: Vr(e),
|
|
5783
|
+
sessions: Kr(e),
|
|
5784
|
+
sessionCleanup: Ni(e),
|
|
5785
|
+
tenants: Zr(e),
|
|
5786
|
+
tokenExchangeProfiles: vr(e),
|
|
5569
5787
|
...t.controlPlane ? {
|
|
5570
|
-
tenantOperations:
|
|
5571
|
-
tenantOperationEvents:
|
|
5572
|
-
tenantOperationRows:
|
|
5573
|
-
rollouts:
|
|
5788
|
+
tenantOperations: Ri(e),
|
|
5789
|
+
tenantOperationEvents: ia(e),
|
|
5790
|
+
tenantOperationRows: Gi(e),
|
|
5791
|
+
rollouts: sa(e)
|
|
5574
5792
|
} : {},
|
|
5575
|
-
themes:
|
|
5576
|
-
universalLoginTemplates:
|
|
5577
|
-
users:
|
|
5578
|
-
userActivity:
|
|
5579
|
-
userRoles:
|
|
5580
|
-
userOrganizations:
|
|
5581
|
-
stats:
|
|
5582
|
-
analytics:
|
|
5583
|
-
outbox:
|
|
5793
|
+
themes: ei(e),
|
|
5794
|
+
universalLoginTemplates: ti(e),
|
|
5795
|
+
users: yi(e),
|
|
5796
|
+
userActivity: ri(e),
|
|
5797
|
+
userRoles: bi(e),
|
|
5798
|
+
userOrganizations: xi(e),
|
|
5799
|
+
stats: Ti(e),
|
|
5800
|
+
analytics: ji(e),
|
|
5801
|
+
outbox: si(e),
|
|
5584
5802
|
async transaction(r) {
|
|
5585
|
-
if (t.useTransactions === !1 ||
|
|
5803
|
+
if (t.useTransactions === !1 || Nt(e)) return r(n);
|
|
5586
5804
|
await e.run(y`BEGIN`);
|
|
5587
5805
|
try {
|
|
5588
5806
|
let t = await r(n);
|
|
@@ -5596,7 +5814,7 @@ function ia(e, t = { useTransactions: !0 }) {
|
|
|
5596
5814
|
}
|
|
5597
5815
|
//#endregion
|
|
5598
5816
|
//#region src/adapters/resolveHost.ts
|
|
5599
|
-
function
|
|
5817
|
+
function la(e) {
|
|
5600
5818
|
if (!e) return { path: "/*" };
|
|
5601
5819
|
try {
|
|
5602
5820
|
let t = JSON.parse(e), n = xe.safeParse(t);
|
|
@@ -5604,7 +5822,7 @@ function aa(e) {
|
|
|
5604
5822
|
} catch {}
|
|
5605
5823
|
return { path: "/*" };
|
|
5606
5824
|
}
|
|
5607
|
-
function
|
|
5825
|
+
function ua(e) {
|
|
5608
5826
|
if (!e) return [];
|
|
5609
5827
|
try {
|
|
5610
5828
|
let t = JSON.parse(e);
|
|
@@ -5619,20 +5837,20 @@ function oa(e) {
|
|
|
5619
5837
|
return [];
|
|
5620
5838
|
}
|
|
5621
5839
|
}
|
|
5622
|
-
async function
|
|
5840
|
+
async function da(e, r) {
|
|
5623
5841
|
let i = r.toLowerCase(), o = (await e.select({
|
|
5624
|
-
custom_domain_id:
|
|
5625
|
-
tenant_id:
|
|
5626
|
-
domain:
|
|
5627
|
-
}).from(
|
|
5842
|
+
custom_domain_id: Je.custom_domain_id,
|
|
5843
|
+
tenant_id: Je.tenant_id,
|
|
5844
|
+
domain: Je.domain
|
|
5845
|
+
}).from(Je).where(a(Je.domain, i)).limit(1))[0];
|
|
5628
5846
|
if (!o) return null;
|
|
5629
|
-
let s = (await e.select().from(
|
|
5847
|
+
let s = (await e.select().from(J).where(t(a(J.tenant_id, o.tenant_id), a(J.custom_domain_id, o.custom_domain_id))).orderBy(n(J.priority), n(J.created_at))).map((e) => ({
|
|
5630
5848
|
id: e.id,
|
|
5631
5849
|
tenant_id: e.tenant_id,
|
|
5632
5850
|
custom_domain_id: e.custom_domain_id,
|
|
5633
5851
|
priority: e.priority,
|
|
5634
|
-
match:
|
|
5635
|
-
handlers:
|
|
5852
|
+
match: la(e.match),
|
|
5853
|
+
handlers: ua(e.handlers),
|
|
5636
5854
|
created_at: e.created_at,
|
|
5637
5855
|
updated_at: e.updated_at
|
|
5638
5856
|
}));
|
|
@@ -5645,11 +5863,11 @@ async function sa(e, r) {
|
|
|
5645
5863
|
}
|
|
5646
5864
|
//#endregion
|
|
5647
5865
|
//#region src/adapters/proxyData.ts
|
|
5648
|
-
function
|
|
5866
|
+
function fa(e) {
|
|
5649
5867
|
return {
|
|
5650
|
-
proxyRoutes:
|
|
5651
|
-
resolveHost: (t) =>
|
|
5868
|
+
proxyRoutes: mr(e),
|
|
5869
|
+
resolveHost: (t) => da(e, t)
|
|
5652
5870
|
};
|
|
5653
5871
|
}
|
|
5654
5872
|
//#endregion
|
|
5655
|
-
export {
|
|
5873
|
+
export { fa as createProxyDataAdapter, mr as createProxyRoutesAdapter, ca as default, vt as sqlite };
|