@authhero/drizzle 1.13.0 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/drizzle-adapter.cjs +2 -2
- package/dist/drizzle-adapter.mjs +1162 -946
- 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
|
+
};
|
|
2711
|
+
}
|
|
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)));
|
|
2624
2716
|
}
|
|
2625
|
-
let
|
|
2626
|
-
if (!
|
|
2627
|
-
let [
|
|
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,15 +4331,15 @@ 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, ["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));
|
|
@@ -4198,7 +4352,7 @@ function Jr(e) {
|
|
|
4198
4352
|
};
|
|
4199
4353
|
},
|
|
4200
4354
|
async update(t, n) {
|
|
4201
|
-
let r =
|
|
4355
|
+
let r = Xr({
|
|
4202
4356
|
...n,
|
|
4203
4357
|
id: t,
|
|
4204
4358
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -4212,62 +4366,62 @@ function Jr(e) {
|
|
|
4212
4366
|
}
|
|
4213
4367
|
//#endregion
|
|
4214
4368
|
//#region src/adapters/themes.ts
|
|
4215
|
-
var
|
|
4369
|
+
var Qr = [
|
|
4216
4370
|
"colors",
|
|
4217
4371
|
"borders",
|
|
4218
4372
|
"fonts",
|
|
4219
4373
|
"page_background",
|
|
4220
4374
|
"widget"
|
|
4221
4375
|
];
|
|
4222
|
-
function
|
|
4223
|
-
let { tenant_id: t, ...n } = e, r =
|
|
4376
|
+
function $r(e) {
|
|
4377
|
+
let { tenant_id: t, ...n } = e, r = bt(n, Qr);
|
|
4224
4378
|
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
4379
|
}
|
|
4226
|
-
function
|
|
4380
|
+
function ei(e) {
|
|
4227
4381
|
return {
|
|
4228
4382
|
async create(t, n, r, i) {
|
|
4229
4383
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = a?.id || r || b(), c = {
|
|
4230
|
-
...
|
|
4384
|
+
...yt(n),
|
|
4231
4385
|
tenant_id: t,
|
|
4232
4386
|
themeId: s,
|
|
4233
4387
|
created_at: a?.created_at ?? o,
|
|
4234
4388
|
updated_at: a?.updated_at ?? o
|
|
4235
4389
|
};
|
|
4236
|
-
return await e.insert(
|
|
4390
|
+
return await e.insert(tt).values(c), $r({
|
|
4237
4391
|
...c,
|
|
4238
4392
|
tenant_id: t
|
|
4239
4393
|
});
|
|
4240
4394
|
},
|
|
4241
4395
|
async get(n, r) {
|
|
4242
|
-
let i = await e.select().from(
|
|
4243
|
-
return i ?
|
|
4396
|
+
let i = await e.select().from(tt).where(t(a(tt.tenant_id, n), a(tt.themeId, r))).get();
|
|
4397
|
+
return i ? $r(i) : null;
|
|
4244
4398
|
},
|
|
4245
4399
|
async update(n, r, i) {
|
|
4246
|
-
let o =
|
|
4247
|
-
return o.updated_at = (/* @__PURE__ */ new Date()).toISOString(), await e.update(
|
|
4400
|
+
let o = yt(i);
|
|
4401
|
+
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
4402
|
},
|
|
4249
4403
|
async remove(n, r) {
|
|
4250
|
-
return (await e.delete(
|
|
4404
|
+
return (await e.delete(tt).where(t(a(tt.tenant_id, n), a(tt.themeId, r))).returning()).length > 0;
|
|
4251
4405
|
}
|
|
4252
4406
|
};
|
|
4253
4407
|
}
|
|
4254
4408
|
//#endregion
|
|
4255
4409
|
//#region src/adapters/universalLoginTemplates.ts
|
|
4256
|
-
function
|
|
4410
|
+
function ti(e) {
|
|
4257
4411
|
return {
|
|
4258
4412
|
async get(t) {
|
|
4259
|
-
let n = await e.select({ body:
|
|
4413
|
+
let n = await e.select({ body: et.body }).from(et).where(a(et.tenant_id, t)).get();
|
|
4260
4414
|
return n ? { body: n.body } : null;
|
|
4261
4415
|
},
|
|
4262
4416
|
async set(t, n) {
|
|
4263
4417
|
let r = Date.now();
|
|
4264
|
-
await e.insert(
|
|
4418
|
+
await e.insert(et).values({
|
|
4265
4419
|
tenant_id: t,
|
|
4266
4420
|
body: n.body,
|
|
4267
4421
|
created_at_ts: r,
|
|
4268
4422
|
updated_at_ts: r
|
|
4269
4423
|
}).onConflictDoUpdate({
|
|
4270
|
-
target:
|
|
4424
|
+
target: et.tenant_id,
|
|
4271
4425
|
set: {
|
|
4272
4426
|
body: n.body,
|
|
4273
4427
|
updated_at_ts: r
|
|
@@ -4275,17 +4429,17 @@ function Qr(e) {
|
|
|
4275
4429
|
});
|
|
4276
4430
|
},
|
|
4277
4431
|
async delete(t) {
|
|
4278
|
-
await e.delete(
|
|
4432
|
+
await e.delete(et).where(a(et.tenant_id, t));
|
|
4279
4433
|
}
|
|
4280
4434
|
};
|
|
4281
4435
|
}
|
|
4282
4436
|
//#endregion
|
|
4283
4437
|
//#region src/adapters/userActivity.ts
|
|
4284
|
-
function
|
|
4438
|
+
function ni(e) {
|
|
4285
4439
|
let t = {};
|
|
4286
4440
|
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
4441
|
}
|
|
4288
|
-
function
|
|
4442
|
+
function ri(e) {
|
|
4289
4443
|
return {
|
|
4290
4444
|
async get(n, r) {
|
|
4291
4445
|
let i = await e.select().from(Ue).where(t(a(Ue.tenant_id, n), a(Ue.user_id, r))).get();
|
|
@@ -4299,7 +4453,7 @@ function ei(e) {
|
|
|
4299
4453
|
} : null;
|
|
4300
4454
|
},
|
|
4301
4455
|
async upsert(t, n, r) {
|
|
4302
|
-
let i =
|
|
4456
|
+
let i = ni(r), a = e.insert(Ue).values({
|
|
4303
4457
|
tenant_id: t,
|
|
4304
4458
|
user_id: n,
|
|
4305
4459
|
login_count: 0,
|
|
@@ -4318,14 +4472,14 @@ function ei(e) {
|
|
|
4318
4472
|
}
|
|
4319
4473
|
//#endregion
|
|
4320
4474
|
//#region src/adapters/outbox.ts
|
|
4321
|
-
function
|
|
4475
|
+
function ii(e) {
|
|
4322
4476
|
return {
|
|
4323
4477
|
...e,
|
|
4324
|
-
payload:
|
|
4478
|
+
payload: X(e.payload, {})
|
|
4325
4479
|
};
|
|
4326
4480
|
}
|
|
4327
|
-
function
|
|
4328
|
-
return e.insert(
|
|
4481
|
+
function ai(e, t, n, r) {
|
|
4482
|
+
return e.insert(q).values({
|
|
4329
4483
|
id: t,
|
|
4330
4484
|
tenant_id: n,
|
|
4331
4485
|
event_type: r.event_type,
|
|
@@ -4345,64 +4499,82 @@ function ni(e, t, n, r) {
|
|
|
4345
4499
|
claim_expires_at: null
|
|
4346
4500
|
});
|
|
4347
4501
|
}
|
|
4348
|
-
function
|
|
4502
|
+
function oi(e) {
|
|
4503
|
+
return {
|
|
4504
|
+
...X(e.payload, {}),
|
|
4505
|
+
id: e.id,
|
|
4506
|
+
created_at: e.created_at,
|
|
4507
|
+
processed_at: e.processed_at,
|
|
4508
|
+
retry_count: e.retry_count,
|
|
4509
|
+
next_retry_at: e.next_retry_at,
|
|
4510
|
+
error: e.error,
|
|
4511
|
+
dead_lettered_at: e.dead_lettered_at,
|
|
4512
|
+
final_error: e.final_error
|
|
4513
|
+
};
|
|
4514
|
+
}
|
|
4515
|
+
function si(e) {
|
|
4349
4516
|
return {
|
|
4350
4517
|
async create(t, n) {
|
|
4351
4518
|
let r = b();
|
|
4352
|
-
return await
|
|
4519
|
+
return await ai(e, r, t, n), r;
|
|
4353
4520
|
},
|
|
4354
4521
|
async getByIds(t) {
|
|
4355
|
-
return t.length === 0 ? [] : (await e.select().from(
|
|
4522
|
+
return t.length === 0 ? [] : (await e.select().from(q).where(l(q.id, t)).all()).map(ii);
|
|
4356
4523
|
},
|
|
4357
4524
|
async getUnprocessed(n) {
|
|
4358
4525
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
4359
|
-
return (await e.select().from(
|
|
4526
|
+
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
4527
|
},
|
|
4361
4528
|
async claimEvents(n, r, i) {
|
|
4362
4529
|
if (n.length === 0) return [];
|
|
4363
4530
|
let o = (/* @__PURE__ */ new Date()).toISOString(), s = new Date(Date.now() + i).toISOString();
|
|
4364
|
-
return await e.update(
|
|
4531
|
+
return await e.update(q).set({
|
|
4365
4532
|
claimed_by: r,
|
|
4366
4533
|
claim_expires_at: s
|
|
4367
|
-
}).where(t(l(
|
|
4534
|
+
}).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
4535
|
},
|
|
4369
4536
|
async markProcessed(t) {
|
|
4370
|
-
t.length !== 0 && await e.update(
|
|
4537
|
+
t.length !== 0 && await e.update(q).set({ processed_at: (/* @__PURE__ */ new Date()).toISOString() }).where(l(q.id, t));
|
|
4371
4538
|
},
|
|
4372
4539
|
async markRetry(t, n, r) {
|
|
4373
|
-
await e.update(
|
|
4540
|
+
await e.update(q).set({
|
|
4374
4541
|
error: n,
|
|
4375
4542
|
next_retry_at: r,
|
|
4376
|
-
retry_count: y`${
|
|
4543
|
+
retry_count: y`${q.retry_count} + 1`,
|
|
4377
4544
|
claimed_by: null,
|
|
4378
4545
|
claim_expires_at: null
|
|
4379
|
-
}).where(a(
|
|
4546
|
+
}).where(a(q.id, t));
|
|
4380
4547
|
},
|
|
4381
4548
|
async cleanup(n) {
|
|
4382
|
-
return (await e.delete(
|
|
4549
|
+
return (await e.delete(q).where(t(y`${q.processed_at} IS NOT NULL`, h(q.processed_at, n))).returning()).length;
|
|
4383
4550
|
},
|
|
4384
4551
|
async deadLetter(t, n) {
|
|
4385
4552
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
4386
|
-
await e.update(
|
|
4553
|
+
await e.update(q).set({
|
|
4387
4554
|
processed_at: r,
|
|
4388
4555
|
dead_lettered_at: r,
|
|
4389
4556
|
final_error: n
|
|
4390
|
-
}).where(a(
|
|
4557
|
+
}).where(a(q.id, t));
|
|
4391
4558
|
},
|
|
4392
4559
|
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
|
-
|
|
4560
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1 } = s;
|
|
4561
|
+
if (wt(s)) {
|
|
4562
|
+
let n = {
|
|
4563
|
+
sortColumn: q.dead_lettered_at,
|
|
4564
|
+
idColumn: q.id,
|
|
4565
|
+
sortOrder: "desc"
|
|
4566
|
+
}, 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);
|
|
4567
|
+
return {
|
|
4568
|
+
events: l,
|
|
4569
|
+
start: 0,
|
|
4570
|
+
limit: r,
|
|
4571
|
+
length: l.length,
|
|
4572
|
+
next: c
|
|
4573
|
+
};
|
|
4574
|
+
}
|
|
4575
|
+
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
4576
|
if (u) {
|
|
4405
|
-
let [n] = await e.select({ total: r() }).from(
|
|
4577
|
+
let [n] = await e.select({ total: r() }).from(q).where(t(a(q.tenant_id, o), d(q.dead_lettered_at)));
|
|
4406
4578
|
p = Number(n?.total ?? f.length);
|
|
4407
4579
|
}
|
|
4408
4580
|
return {
|
|
@@ -4413,7 +4585,7 @@ function ri(e) {
|
|
|
4413
4585
|
};
|
|
4414
4586
|
},
|
|
4415
4587
|
async replay(n, r) {
|
|
4416
|
-
return (await e.update(
|
|
4588
|
+
return (await e.update(q).set({
|
|
4417
4589
|
processed_at: null,
|
|
4418
4590
|
dead_lettered_at: null,
|
|
4419
4591
|
final_error: null,
|
|
@@ -4422,19 +4594,19 @@ function ri(e) {
|
|
|
4422
4594
|
error: null,
|
|
4423
4595
|
claimed_by: null,
|
|
4424
4596
|
claim_expires_at: null
|
|
4425
|
-
}).where(t(a(
|
|
4597
|
+
}).where(t(a(q.id, n), a(q.tenant_id, r), d(q.dead_lettered_at))).returning()).length > 0;
|
|
4426
4598
|
},
|
|
4427
4599
|
async discard(n, r) {
|
|
4428
|
-
return (await e.delete(
|
|
4600
|
+
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
4601
|
}
|
|
4430
4602
|
};
|
|
4431
4603
|
}
|
|
4432
4604
|
//#endregion
|
|
4433
4605
|
//#region src/adapters/users.ts
|
|
4434
|
-
function
|
|
4435
|
-
return (n?.outboxEvents ?? []).map((n) =>
|
|
4606
|
+
function ci(e, t, n) {
|
|
4607
|
+
return (n?.outboxEvents ?? []).map((n) => ai(e, n.id, t, n));
|
|
4436
4608
|
}
|
|
4437
|
-
var
|
|
4609
|
+
var li = [
|
|
4438
4610
|
"user_id",
|
|
4439
4611
|
"email",
|
|
4440
4612
|
"email_verified",
|
|
@@ -4456,23 +4628,23 @@ var ai = [
|
|
|
4456
4628
|
"login_count",
|
|
4457
4629
|
"created_at",
|
|
4458
4630
|
"updated_at"
|
|
4459
|
-
],
|
|
4631
|
+
], ui = [
|
|
4460
4632
|
"email",
|
|
4461
4633
|
"name",
|
|
4462
4634
|
"phone_number",
|
|
4463
4635
|
"user_id"
|
|
4464
|
-
],
|
|
4636
|
+
], di = new Set([
|
|
4465
4637
|
"last_login",
|
|
4466
4638
|
"last_ip",
|
|
4467
4639
|
"login_count"
|
|
4468
|
-
]),
|
|
4640
|
+
]), fi = o(A), pi = o(Ue), mi = Object.fromEntries(li.map((e) => [e, e === "login_count" ? {
|
|
4469
4641
|
coalesce: Ue.login_count,
|
|
4470
4642
|
defaultValue: 0
|
|
4471
|
-
} :
|
|
4472
|
-
function
|
|
4643
|
+
} : di.has(e) ? pi[e] : fi[e]]));
|
|
4644
|
+
function hi() {
|
|
4473
4645
|
return t(a(Ue.tenant_id, A.tenant_id), a(Ue.user_id, A.user_id));
|
|
4474
4646
|
}
|
|
4475
|
-
function
|
|
4647
|
+
function gi(e, t) {
|
|
4476
4648
|
return {
|
|
4477
4649
|
...e,
|
|
4478
4650
|
last_login: t?.last_login,
|
|
@@ -4480,7 +4652,7 @@ function fi(e, t) {
|
|
|
4480
4652
|
login_count: t?.login_count ?? 0
|
|
4481
4653
|
};
|
|
4482
4654
|
}
|
|
4483
|
-
function
|
|
4655
|
+
function _i(e, t) {
|
|
4484
4656
|
let n = {
|
|
4485
4657
|
connection: e.connection,
|
|
4486
4658
|
provider: e.provider,
|
|
@@ -4490,11 +4662,11 @@ function pi(e, t) {
|
|
|
4490
4662
|
return t ? n.isPrimary = !0 : n.profileData = {
|
|
4491
4663
|
email: e.email,
|
|
4492
4664
|
email_verified: !!e.email_verified,
|
|
4493
|
-
...typeof e.profileData == "string" ?
|
|
4665
|
+
...typeof e.profileData == "string" ? X(e.profileData, {}) : {}
|
|
4494
4666
|
}, n;
|
|
4495
4667
|
}
|
|
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 =
|
|
4668
|
+
function vi(e, t = []) {
|
|
4669
|
+
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
4670
|
return D({
|
|
4499
4671
|
...f,
|
|
4500
4672
|
email: e.email || "",
|
|
@@ -4502,13 +4674,13 @@ function mi(e, t = []) {
|
|
|
4502
4674
|
phone_verified: s == null ? void 0 : !!s,
|
|
4503
4675
|
is_social: !!c,
|
|
4504
4676
|
blocked: l == null ? void 0 : !!l,
|
|
4505
|
-
app_metadata:
|
|
4506
|
-
user_metadata:
|
|
4507
|
-
address:
|
|
4677
|
+
app_metadata: X(r, {}),
|
|
4678
|
+
user_metadata: X(i, {}),
|
|
4679
|
+
address: X(a),
|
|
4508
4680
|
identities: [p, ...m]
|
|
4509
4681
|
});
|
|
4510
4682
|
}
|
|
4511
|
-
function
|
|
4683
|
+
function yi(e) {
|
|
4512
4684
|
let o = async (t, n, r) => {
|
|
4513
4685
|
let i = (/* @__PURE__ */ new Date()).toISOString(), a = {
|
|
4514
4686
|
user_id: n.user_id,
|
|
@@ -4562,12 +4734,12 @@ function hi(e) {
|
|
|
4562
4734
|
created_at: i,
|
|
4563
4735
|
updated_at: i
|
|
4564
4736
|
}));
|
|
4565
|
-
for (let n of
|
|
4566
|
-
c.length > 1 ? await
|
|
4737
|
+
for (let n of ci(e, t, r)) c.push(n);
|
|
4738
|
+
c.length > 1 ? await Pt(e, c) : await e.insert(A).values(a);
|
|
4567
4739
|
} catch (e) {
|
|
4568
4740
|
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
4741
|
}
|
|
4570
|
-
return
|
|
4742
|
+
return vi({
|
|
4571
4743
|
...a,
|
|
4572
4744
|
last_login: n.last_login,
|
|
4573
4745
|
last_ip: n.last_ip,
|
|
@@ -4578,10 +4750,10 @@ function hi(e) {
|
|
|
4578
4750
|
create: o,
|
|
4579
4751
|
rawCreate: o,
|
|
4580
4752
|
async get(n, r) {
|
|
4581
|
-
let i = await e.select().from(A).leftJoin(Ue,
|
|
4753
|
+
let i = await e.select().from(A).leftJoin(Ue, hi()).where(t(a(A.tenant_id, n), a(A.user_id, r))).get();
|
|
4582
4754
|
if (!i) return null;
|
|
4583
4755
|
let o = await e.select().from(A).where(t(a(A.tenant_id, n), a(A.linked_to, r))).all();
|
|
4584
|
-
return
|
|
4756
|
+
return vi(gi(i.users, i.user_activity), o);
|
|
4585
4757
|
},
|
|
4586
4758
|
async update(n, r, i, o) {
|
|
4587
4759
|
let s = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -4608,8 +4780,8 @@ function hi(e) {
|
|
|
4608
4780
|
"zoneinfo"
|
|
4609
4781
|
]) i[e] !== void 0 && (s[e] = i[e]);
|
|
4610
4782
|
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
|
|
4783
|
+
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;
|
|
4784
|
+
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
4785
|
last_login: i.last_login,
|
|
4614
4786
|
last_ip: i.last_ip,
|
|
4615
4787
|
login_count: i.login_count
|
|
@@ -4618,24 +4790,24 @@ function hi(e) {
|
|
|
4618
4790
|
async list(o, s) {
|
|
4619
4791
|
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
4792
|
if (m) {
|
|
4621
|
-
let e = Ee(m,
|
|
4793
|
+
let e = Ee(m, li);
|
|
4622
4794
|
if (e) {
|
|
4623
|
-
let t =
|
|
4795
|
+
let t = Ct(mi, e, ui);
|
|
4624
4796
|
t && h.push(t);
|
|
4625
4797
|
}
|
|
4626
4798
|
}
|
|
4627
4799
|
let g = t(...h), _ = async (n) => {
|
|
4628
4800
|
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) =>
|
|
4801
|
+
return n.map((e) => vi(e, i.filter((t) => t.linked_to === e.user_id)));
|
|
4630
4802
|
};
|
|
4631
|
-
if (
|
|
4803
|
+
if (wt(s)) {
|
|
4632
4804
|
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
4805
|
let n = p?.sort_order === "asc" ? "asc" : "desc", r = {
|
|
4634
4806
|
sortColumn: A.created_at,
|
|
4635
4807
|
idColumn: A.user_id,
|
|
4636
4808
|
sortOrder: n,
|
|
4637
4809
|
sortKey: `created_at:${n}`
|
|
4638
|
-
}, i =
|
|
4810
|
+
}, 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
4811
|
return {
|
|
4640
4812
|
users: l,
|
|
4641
4813
|
start: 0,
|
|
@@ -4644,15 +4816,15 @@ function hi(e) {
|
|
|
4644
4816
|
next: c
|
|
4645
4817
|
};
|
|
4646
4818
|
}
|
|
4647
|
-
let v = e.select().from(A).leftJoin(Ue,
|
|
4819
|
+
let v = e.select().from(A).leftJoin(Ue, hi()).where(g).$dynamic();
|
|
4648
4820
|
if (p?.sort_by) {
|
|
4649
|
-
let e =
|
|
4821
|
+
let e = mi[p.sort_by];
|
|
4650
4822
|
if (e) {
|
|
4651
|
-
let t =
|
|
4823
|
+
let t = xt(e) ? St(e) : e;
|
|
4652
4824
|
v = v.orderBy(p.sort_order === "desc" ? i(t) : n(t));
|
|
4653
4825
|
}
|
|
4654
4826
|
}
|
|
4655
|
-
let [y, ee] = await Promise.all([v.offset(c * u).limit(u), d ? e.select({ count: r() }).from(A).leftJoin(Ue,
|
|
4827
|
+
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
4828
|
if (!ee) return { users: b };
|
|
4657
4829
|
let [te] = ee;
|
|
4658
4830
|
return {
|
|
@@ -4664,14 +4836,14 @@ function hi(e) {
|
|
|
4664
4836
|
},
|
|
4665
4837
|
async remove(n, r, i) {
|
|
4666
4838
|
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(
|
|
4839
|
+
e.delete(ft).where(t(a(ft.tenant_id, n), l(ft.user_id, u))),
|
|
4668
4840
|
e.delete(j).where(t(a(j.tenant_id, n), l(j.user_id, u))),
|
|
4669
4841
|
e.delete(Ue).where(t(a(Ue.tenant_id, n), l(Ue.user_id, u))),
|
|
4670
4842
|
e.delete(A).where(t(a(A.tenant_id, n), l(A.user_id, c))),
|
|
4671
4843
|
e.delete(A).where(t(a(A.tenant_id, n), a(A.user_id, r))).returning()
|
|
4672
4844
|
], f = d.length - 1;
|
|
4673
|
-
if (s) for (let t of
|
|
4674
|
-
let p = (await
|
|
4845
|
+
if (s) for (let t of ci(e, n, i)) d.push(t);
|
|
4846
|
+
let p = (await Pt(e, d))[f];
|
|
4675
4847
|
return Array.isArray(p) && p.length > 0;
|
|
4676
4848
|
},
|
|
4677
4849
|
async unlink(n, r, i, o) {
|
|
@@ -4682,11 +4854,11 @@ function hi(e) {
|
|
|
4682
4854
|
}
|
|
4683
4855
|
//#endregion
|
|
4684
4856
|
//#region src/adapters/userRoles.ts
|
|
4685
|
-
function
|
|
4857
|
+
function bi(e) {
|
|
4686
4858
|
return {
|
|
4687
4859
|
async create(t, n, r, i) {
|
|
4688
4860
|
try {
|
|
4689
|
-
await e.insert(
|
|
4861
|
+
await e.insert(W).values({
|
|
4690
4862
|
tenant_id: t,
|
|
4691
4863
|
user_id: n,
|
|
4692
4864
|
role_id: r,
|
|
@@ -4700,28 +4872,48 @@ function gi(e) {
|
|
|
4700
4872
|
return !0;
|
|
4701
4873
|
},
|
|
4702
4874
|
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:
|
|
4875
|
+
let s = [a(W.tenant_id, n), a(W.user_id, r)];
|
|
4876
|
+
o !== void 0 && s.push(a(W.organization_id, o));
|
|
4877
|
+
let c = await e.select({ role_id: W.role_id }).from(W).where(t(...s)).all();
|
|
4706
4878
|
return c.length === 0 ? [] : (await Promise.all(c.map(async (r) => {
|
|
4707
|
-
let i = await e.select().from(
|
|
4879
|
+
let i = await e.select().from(H).where(t(a(H.tenant_id, n), a(H.id, r.role_id))).get();
|
|
4708
4880
|
if (!i) return null;
|
|
4709
4881
|
let { tenant_id: o, is_system: s, metadata: c, ...l } = i;
|
|
4710
4882
|
return D({
|
|
4711
4883
|
...l,
|
|
4712
4884
|
is_system: s ? !0 : void 0,
|
|
4713
|
-
metadata:
|
|
4885
|
+
metadata: X(c)
|
|
4714
4886
|
});
|
|
4715
4887
|
}))).filter(Boolean);
|
|
4716
4888
|
},
|
|
4889
|
+
async listCheckpoint(n, r, i = {}, o) {
|
|
4890
|
+
let s = [a(W.tenant_id, n), a(W.user_id, r)];
|
|
4891
|
+
o !== void 0 && s.push(a(W.organization_id, o));
|
|
4892
|
+
let c = {
|
|
4893
|
+
sortColumn: H.id,
|
|
4894
|
+
idColumn: H.id,
|
|
4895
|
+
sortOrder: "asc"
|
|
4896
|
+
}, 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");
|
|
4897
|
+
return {
|
|
4898
|
+
roles: d.map((e) => {
|
|
4899
|
+
let { tenant_id: t, is_system: n, metadata: r, ...i } = e;
|
|
4900
|
+
return D({
|
|
4901
|
+
...i,
|
|
4902
|
+
is_system: n ? !0 : void 0,
|
|
4903
|
+
metadata: X(r)
|
|
4904
|
+
});
|
|
4905
|
+
}),
|
|
4906
|
+
next: f
|
|
4907
|
+
};
|
|
4908
|
+
},
|
|
4717
4909
|
async listUsers(r, i, o) {
|
|
4718
|
-
let s = t(a(
|
|
4719
|
-
if (
|
|
4910
|
+
let s = t(a(W.tenant_id, r), a(W.role_id, i));
|
|
4911
|
+
if (wt(o)) {
|
|
4720
4912
|
let n = {
|
|
4721
|
-
sortColumn:
|
|
4722
|
-
idColumn:
|
|
4913
|
+
sortColumn: W.user_id,
|
|
4914
|
+
idColumn: W.user_id,
|
|
4723
4915
|
sortOrder: "asc"
|
|
4724
|
-
}, r =
|
|
4916
|
+
}, 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
4917
|
return {
|
|
4726
4918
|
userIds: a.map((e) => e.user_id),
|
|
4727
4919
|
start: 0,
|
|
@@ -4730,7 +4922,7 @@ function gi(e) {
|
|
|
4730
4922
|
next: c
|
|
4731
4923
|
};
|
|
4732
4924
|
}
|
|
4733
|
-
let c = o?.page || 0, l = o?.per_page || 50, u = c * l, d = await e.selectDistinct({ user_id:
|
|
4925
|
+
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
4926
|
return {
|
|
4735
4927
|
userIds: d.map((e) => e.user_id),
|
|
4736
4928
|
start: u,
|
|
@@ -4739,13 +4931,13 @@ function gi(e) {
|
|
|
4739
4931
|
};
|
|
4740
4932
|
},
|
|
4741
4933
|
async remove(n, r, i, o) {
|
|
4742
|
-
return (await e.delete(
|
|
4934
|
+
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
4935
|
}
|
|
4744
4936
|
};
|
|
4745
4937
|
}
|
|
4746
4938
|
//#endregion
|
|
4747
4939
|
//#region src/adapters/userOrganizations.ts
|
|
4748
|
-
function
|
|
4940
|
+
function xi(e) {
|
|
4749
4941
|
return {
|
|
4750
4942
|
async create(t, n) {
|
|
4751
4943
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -4757,7 +4949,7 @@ function _i(e) {
|
|
|
4757
4949
|
updated_at: r
|
|
4758
4950
|
};
|
|
4759
4951
|
try {
|
|
4760
|
-
await e.insert(
|
|
4952
|
+
await e.insert(V).values(i);
|
|
4761
4953
|
} catch (e) {
|
|
4762
4954
|
throw e?.message?.includes("UNIQUE constraint") || e?.message?.includes("duplicate key") ? new Re(409, { message: "User organization already exists" }) : e;
|
|
4763
4955
|
}
|
|
@@ -4765,31 +4957,31 @@ function _i(e) {
|
|
|
4765
4957
|
return o;
|
|
4766
4958
|
},
|
|
4767
4959
|
async get(n, r) {
|
|
4768
|
-
let i = await e.select().from(
|
|
4960
|
+
let i = await e.select().from(V).where(t(a(V.tenant_id, n), a(V.id, r))).get();
|
|
4769
4961
|
if (!i) return null;
|
|
4770
4962
|
let { tenant_id: o, ...s } = i;
|
|
4771
4963
|
return s;
|
|
4772
4964
|
},
|
|
4773
4965
|
async update(n, r, i) {
|
|
4774
4966
|
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(
|
|
4967
|
+
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
4968
|
},
|
|
4777
4969
|
async list(n, o) {
|
|
4778
|
-
let { include_totals: s = !1, q: c } = o || {}, l = a(
|
|
4970
|
+
let { include_totals: s = !1, q: c } = o || {}, l = a(V.tenant_id, n), u = l;
|
|
4779
4971
|
if (c) {
|
|
4780
|
-
let e =
|
|
4972
|
+
let e = Ct(V, c, ["user_id", "organization_id"]);
|
|
4781
4973
|
e && (u = t(l, e));
|
|
4782
4974
|
}
|
|
4783
4975
|
let d = (e) => {
|
|
4784
4976
|
let { tenant_id: t, ...n } = e;
|
|
4785
4977
|
return n;
|
|
4786
4978
|
};
|
|
4787
|
-
if (
|
|
4979
|
+
if (wt(o)) {
|
|
4788
4980
|
let n = {
|
|
4789
|
-
sortColumn:
|
|
4790
|
-
idColumn:
|
|
4981
|
+
sortColumn: V.created_at,
|
|
4982
|
+
idColumn: V.id,
|
|
4791
4983
|
sortOrder: "desc"
|
|
4792
|
-
}, r =
|
|
4984
|
+
}, 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
4985
|
return {
|
|
4794
4986
|
userOrganizations: a,
|
|
4795
4987
|
start: 0,
|
|
@@ -4798,9 +4990,9 @@ function _i(e) {
|
|
|
4798
4990
|
next: s
|
|
4799
4991
|
};
|
|
4800
4992
|
}
|
|
4801
|
-
let f = o?.page ?? 0, p = o?.per_page ?? 50, m = f * p, h = (await e.select().from(
|
|
4993
|
+
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
4994
|
if (!s) return { userOrganizations: h };
|
|
4803
|
-
let [g] = await e.select({ count: r() }).from(
|
|
4995
|
+
let [g] = await e.select({ count: r() }).from(V).where(u);
|
|
4804
4996
|
return {
|
|
4805
4997
|
userOrganizations: h,
|
|
4806
4998
|
start: m,
|
|
@@ -4809,20 +5001,44 @@ function _i(e) {
|
|
|
4809
5001
|
};
|
|
4810
5002
|
},
|
|
4811
5003
|
async listUserOrganizations(n, i, o) {
|
|
4812
|
-
let { page: s = 0, per_page: c = 50, include_totals: l = !1 } = o || {}
|
|
4813
|
-
|
|
5004
|
+
let { page: s = 0, per_page: c = 50, include_totals: l = !1 } = o || {};
|
|
5005
|
+
if (wt(o)) {
|
|
5006
|
+
let r = {
|
|
5007
|
+
sortColumn: V.created_at,
|
|
5008
|
+
idColumn: V.id,
|
|
5009
|
+
sortOrder: "desc"
|
|
5010
|
+
}, 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) => {
|
|
5011
|
+
let { tenant_id: t, branding: n, metadata: r, enabled_connections: i, token_quota: a, ...o } = e;
|
|
5012
|
+
return D({
|
|
5013
|
+
...o,
|
|
5014
|
+
branding: X(n, {}),
|
|
5015
|
+
metadata: X(r, {}),
|
|
5016
|
+
enabled_connections: X(i, []),
|
|
5017
|
+
token_quota: X(a, {})
|
|
5018
|
+
});
|
|
5019
|
+
});
|
|
5020
|
+
return {
|
|
5021
|
+
organizations: d,
|
|
5022
|
+
start: 0,
|
|
5023
|
+
limit: s,
|
|
5024
|
+
length: d.length,
|
|
5025
|
+
next: u
|
|
5026
|
+
};
|
|
5027
|
+
}
|
|
5028
|
+
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) => {
|
|
5029
|
+
let i = await e.select().from(B).where(t(a(B.tenant_id, n), a(B.id, r.organization_id))).get();
|
|
4814
5030
|
if (!i) return null;
|
|
4815
5031
|
let { tenant_id: o, branding: s, metadata: c, enabled_connections: l, token_quota: u, ...d } = i;
|
|
4816
5032
|
return D({
|
|
4817
5033
|
...d,
|
|
4818
|
-
branding:
|
|
4819
|
-
metadata:
|
|
4820
|
-
enabled_connections:
|
|
4821
|
-
token_quota:
|
|
5034
|
+
branding: X(s, {}),
|
|
5035
|
+
metadata: X(c, {}),
|
|
5036
|
+
enabled_connections: X(l, []),
|
|
5037
|
+
token_quota: X(u, {})
|
|
4822
5038
|
});
|
|
4823
5039
|
}))).filter(Boolean);
|
|
4824
5040
|
if (!l) return { organizations: d };
|
|
4825
|
-
let [f] = await e.select({ count: r() }).from(
|
|
5041
|
+
let [f] = await e.select({ count: r() }).from(V).where(t(a(V.tenant_id, n), a(V.user_id, i)));
|
|
4826
5042
|
return {
|
|
4827
5043
|
organizations: d,
|
|
4828
5044
|
start: s * c,
|
|
@@ -4831,26 +5047,26 @@ function _i(e) {
|
|
|
4831
5047
|
};
|
|
4832
5048
|
},
|
|
4833
5049
|
async remove(n, r) {
|
|
4834
|
-
return (await e.delete(
|
|
5050
|
+
return (await e.delete(V).where(t(a(V.tenant_id, n), a(V.id, r))).returning()).length > 0;
|
|
4835
5051
|
}
|
|
4836
5052
|
};
|
|
4837
5053
|
}
|
|
4838
5054
|
//#endregion
|
|
4839
5055
|
//#region src/adapters/stats.ts
|
|
4840
|
-
var
|
|
4841
|
-
function
|
|
5056
|
+
var Si = ["s"], Ci = ["pwd_leak"];
|
|
5057
|
+
function wi(e) {
|
|
4842
5058
|
return /^\d{8}$/.test(e) ? `${e.slice(0, 4)}-${e.slice(4, 6)}-${e.slice(6, 8)}` : e;
|
|
4843
5059
|
}
|
|
4844
|
-
function
|
|
5060
|
+
function Ti(e) {
|
|
4845
5061
|
return {
|
|
4846
5062
|
async getDaily(n, r) {
|
|
4847
|
-
let i = /* @__PURE__ */ new Date(), o = r?.from ?
|
|
5063
|
+
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
5064
|
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(
|
|
5065
|
+
date: y`substr(${K.date}, 1, 10)`.as("date"),
|
|
5066
|
+
logins: y`SUM(CASE WHEN ${K.type} IN (${y.join(Si.map((e) => y`${e}`), y`, `)}) THEN 1 ELSE 0 END)`.as("logins"),
|
|
5067
|
+
signups: y`SUM(CASE WHEN ${K.type} = 'ss' THEN 1 ELSE 0 END)`.as("signups"),
|
|
5068
|
+
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")
|
|
5069
|
+
}).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
5070
|
date: e.date,
|
|
4855
5071
|
logins: Number(e.logins) || 0,
|
|
4856
5072
|
signups: Number(e.signups) || 0,
|
|
@@ -4860,14 +5076,14 @@ function xi(e) {
|
|
|
4860
5076
|
}));
|
|
4861
5077
|
},
|
|
4862
5078
|
async getActiveUsers(n) {
|
|
4863
|
-
let r = (/* @__PURE__ */ new Date(Date.now() - 720 * 60 * 60 * 1e3)).toISOString(), [i] = await e.select({ count: y`COUNT(DISTINCT ${
|
|
5079
|
+
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
5080
|
return Number(i?.count) || 0;
|
|
4865
5081
|
}
|
|
4866
5082
|
};
|
|
4867
5083
|
}
|
|
4868
5084
|
//#endregion
|
|
4869
5085
|
//#region src/adapters/analytics.ts
|
|
4870
|
-
var
|
|
5086
|
+
var Ei = {
|
|
4871
5087
|
"active-users": ["s", "seacft"],
|
|
4872
5088
|
logins: [
|
|
4873
5089
|
"s",
|
|
@@ -4897,7 +5113,7 @@ var Si = {
|
|
|
4897
5113
|
"fvr"
|
|
4898
5114
|
],
|
|
4899
5115
|
"codes-sent": ["cls", "cs"]
|
|
4900
|
-
},
|
|
5116
|
+
}, Di = {
|
|
4901
5117
|
"active-users": {
|
|
4902
5118
|
alias: "active_users",
|
|
4903
5119
|
type: "UInt64",
|
|
@@ -4954,64 +5170,64 @@ var Si = {
|
|
|
4954
5170
|
agg: "count"
|
|
4955
5171
|
}
|
|
4956
5172
|
};
|
|
4957
|
-
function
|
|
5173
|
+
function Oi(e) {
|
|
4958
5174
|
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(${
|
|
5175
|
+
case "hour": return y`substr(${K.date}, 1, 13)`;
|
|
5176
|
+
case "month": return y`substr(${K.date}, 1, 7)`;
|
|
5177
|
+
case "day": return y`substr(${K.date}, 1, 10)`;
|
|
5178
|
+
case "week": return y`date(substr(${K.date}, 1, 10), '-' || ((cast(strftime('%w', substr(${K.date}, 1, 10)) as integer) + 6) % 7) || ' days')`;
|
|
4963
5179
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4964
5180
|
}
|
|
4965
5181
|
}
|
|
4966
|
-
function
|
|
5182
|
+
function ki(e) {
|
|
4967
5183
|
return `"${e.replace(/"/g, "\"\"")}"`;
|
|
4968
5184
|
}
|
|
4969
|
-
function
|
|
5185
|
+
function Ai(e) {
|
|
4970
5186
|
switch (e) {
|
|
4971
|
-
case "connection": return
|
|
4972
|
-
case "client_id": return
|
|
4973
|
-
case "user_type": return
|
|
4974
|
-
case "event": return
|
|
5187
|
+
case "connection": return K.connection;
|
|
5188
|
+
case "client_id": return K.client_id;
|
|
5189
|
+
case "user_type": return K.strategy_type;
|
|
5190
|
+
case "event": return K.type;
|
|
4975
5191
|
case "time": throw Error("time dimension handled separately");
|
|
4976
5192
|
}
|
|
4977
5193
|
}
|
|
4978
|
-
function
|
|
5194
|
+
function ji(e) {
|
|
4979
5195
|
return {
|
|
4980
5196
|
async query(n, r, i) {
|
|
4981
|
-
let o = Date.now(), s =
|
|
4982
|
-
a(
|
|
4983
|
-
c(
|
|
4984
|
-
m(
|
|
4985
|
-
l(
|
|
5197
|
+
let o = Date.now(), s = Ei[r], u = Di[r], d = [
|
|
5198
|
+
a(K.tenant_id, n),
|
|
5199
|
+
c(K.date, i.from),
|
|
5200
|
+
m(K.date, i.to),
|
|
5201
|
+
l(K.type, s)
|
|
4986
5202
|
];
|
|
4987
|
-
i.filters.connection?.length && d.push(l(
|
|
5203
|
+
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
5204
|
let f = {}, p = [], h = [];
|
|
4989
5205
|
for (let e of i.group_by) if (e === "time") {
|
|
4990
|
-
let e =
|
|
5206
|
+
let e = Oi(i.interval);
|
|
4991
5207
|
f.time = e, p.push(e), h.push({
|
|
4992
5208
|
name: "time",
|
|
4993
5209
|
type: i.interval === "hour" ? "DateTime" : "Date"
|
|
4994
5210
|
});
|
|
4995
5211
|
} else {
|
|
4996
|
-
let t =
|
|
5212
|
+
let t = Ai(e);
|
|
4997
5213
|
f[e] = t, p.push(t), h.push({
|
|
4998
5214
|
name: e,
|
|
4999
5215
|
type: "String"
|
|
5000
5216
|
});
|
|
5001
5217
|
}
|
|
5002
|
-
f[u.alias] = u.agg === "uniq" ? y`COUNT(DISTINCT ${
|
|
5218
|
+
f[u.alias] = u.agg === "uniq" ? y`COUNT(DISTINCT ${K.user_id})` : y`COUNT(*)`, h.push({
|
|
5003
5219
|
name: u.alias,
|
|
5004
5220
|
type: u.type
|
|
5005
5221
|
});
|
|
5006
|
-
let g = e.select(f).from(
|
|
5222
|
+
let g = e.select(f).from(K).where(t(...d));
|
|
5007
5223
|
p.length > 0 && (g = g.groupBy(...p));
|
|
5008
5224
|
let _ = new Set([...Object.keys(f)]);
|
|
5009
5225
|
if (i.order_by) {
|
|
5010
5226
|
let e = i.order_by.startsWith("-"), t = e ? i.order_by.slice(1) : i.order_by;
|
|
5011
5227
|
if (!_.has(t)) throw Error(`Invalid order_by column '${t}' for analytics query`);
|
|
5012
|
-
let n =
|
|
5228
|
+
let n = ki(t);
|
|
5013
5229
|
g = g.orderBy(y.raw(`${n} ${e ? "DESC" : "ASC"}`));
|
|
5014
|
-
} else g = i.group_by[0] === "time" ? g.orderBy(y.raw(`${
|
|
5230
|
+
} else g = i.group_by[0] === "time" ? g.orderBy(y.raw(`${ki("time")} ASC`)) : g.orderBy(y.raw(`${ki(u.alias)} DESC`));
|
|
5015
5231
|
g = g.limit(i.limit).offset(i.offset);
|
|
5016
5232
|
let v = (await g.all()).map((e) => {
|
|
5017
5233
|
let t = {};
|
|
@@ -5060,10 +5276,10 @@ function Di(e) {
|
|
|
5060
5276
|
}
|
|
5061
5277
|
//#endregion
|
|
5062
5278
|
//#region src/adapters/cleanup.ts
|
|
5063
|
-
var
|
|
5064
|
-
function
|
|
5279
|
+
var Mi = 10080 * 60 * 1e3;
|
|
5280
|
+
function Ni(e) {
|
|
5065
5281
|
return async (n) => {
|
|
5066
|
-
let r = Date.now() -
|
|
5282
|
+
let r = Date.now() - Mi;
|
|
5067
5283
|
try {
|
|
5068
5284
|
let i = [v(m(N.expires_at_ts, r), m(N.idle_expires_at_ts, r))];
|
|
5069
5285
|
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 +5314,7 @@ var Q = w("tenant_operations", {
|
|
|
5098
5314
|
x("tenant_operations_tenant_id_created_at_idx").on(e.tenant_id, e.created_at),
|
|
5099
5315
|
x("tenant_operations_rollout_id_idx").on(e.rollout_id),
|
|
5100
5316
|
x("tenant_operations_status_idx").on(e.status)
|
|
5101
|
-
]),
|
|
5317
|
+
]), Pi = w("tenant_operation_events", {
|
|
5102
5318
|
id: T("id", { length: 255 }).primaryKey(),
|
|
5103
5319
|
operation_id: T("operation_id", { length: 255 }).notNull(),
|
|
5104
5320
|
step: T("step", { length: 255 }).notNull(),
|
|
@@ -5129,7 +5345,7 @@ var Q = w("tenant_operations", {
|
|
|
5129
5345
|
name: "tenant_operation_rows_operation_id_constraint"
|
|
5130
5346
|
}).onDelete("cascade"),
|
|
5131
5347
|
x("tenant_operation_rows_operation_id_status_idx").on(e.operation_id, e.status)
|
|
5132
|
-
]),
|
|
5348
|
+
]), Fi = w("rollouts", {
|
|
5133
5349
|
id: T("id", { length: 255 }).primaryKey(),
|
|
5134
5350
|
kind: T("kind", { length: 32 }).notNull(),
|
|
5135
5351
|
status: T("status", { length: 32 }).notNull(),
|
|
@@ -5145,7 +5361,7 @@ var Q = w("tenant_operations", {
|
|
|
5145
5361
|
});
|
|
5146
5362
|
//#endregion
|
|
5147
5363
|
//#region src/adapters/tenantOperations.ts
|
|
5148
|
-
function
|
|
5364
|
+
function Ii(e) {
|
|
5149
5365
|
if (!e) return null;
|
|
5150
5366
|
try {
|
|
5151
5367
|
return JSON.parse(e);
|
|
@@ -5153,7 +5369,7 @@ function Mi(e) {
|
|
|
5153
5369
|
return null;
|
|
5154
5370
|
}
|
|
5155
5371
|
}
|
|
5156
|
-
function
|
|
5372
|
+
function Li(e) {
|
|
5157
5373
|
return Fe.parse({
|
|
5158
5374
|
id: e.id,
|
|
5159
5375
|
tenant_id: e.tenant_id,
|
|
@@ -5167,8 +5383,8 @@ function Ni(e) {
|
|
|
5167
5383
|
target_database_version: e.target_database_version,
|
|
5168
5384
|
error: e.error,
|
|
5169
5385
|
initiated_by: e.initiated_by,
|
|
5170
|
-
input:
|
|
5171
|
-
result:
|
|
5386
|
+
input: Ii(e.input),
|
|
5387
|
+
result: Ii(e.result),
|
|
5172
5388
|
claimed_by: e.claimed_by,
|
|
5173
5389
|
claim_expires_at: e.claim_expires_at,
|
|
5174
5390
|
created_at: e.created_at,
|
|
@@ -5176,7 +5392,7 @@ function Ni(e) {
|
|
|
5176
5392
|
finished_at: e.finished_at
|
|
5177
5393
|
});
|
|
5178
5394
|
}
|
|
5179
|
-
function
|
|
5395
|
+
function Ri(e) {
|
|
5180
5396
|
return {
|
|
5181
5397
|
async create(t) {
|
|
5182
5398
|
let n = Me.parse(t), r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -5207,7 +5423,7 @@ function Pi(e) {
|
|
|
5207
5423
|
},
|
|
5208
5424
|
async get(t) {
|
|
5209
5425
|
let n = await e.select().from(Q).where(a(Q.id, t)).limit(1);
|
|
5210
|
-
return n[0] ?
|
|
5426
|
+
return n[0] ? Li(n[0]) : null;
|
|
5211
5427
|
},
|
|
5212
5428
|
async list(n = {}) {
|
|
5213
5429
|
let r = n.page ?? 0, o = n.per_page ?? 50, s = [];
|
|
@@ -5218,7 +5434,7 @@ function Pi(e) {
|
|
|
5218
5434
|
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
5435
|
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
5436
|
return {
|
|
5221
|
-
operations: c.map(
|
|
5437
|
+
operations: c.map(Li),
|
|
5222
5438
|
start: r * o,
|
|
5223
5439
|
limit: o,
|
|
5224
5440
|
length: c.length
|
|
@@ -5244,7 +5460,7 @@ function Pi(e) {
|
|
|
5244
5460
|
},
|
|
5245
5461
|
async listResumable(r) {
|
|
5246
5462
|
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(
|
|
5463
|
+
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
5464
|
},
|
|
5249
5465
|
async remove(t) {
|
|
5250
5466
|
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 +5469,19 @@ function Pi(e) {
|
|
|
5253
5469
|
}
|
|
5254
5470
|
//#endregion
|
|
5255
5471
|
//#region src/adapters/tenantOperationRows.ts
|
|
5256
|
-
var
|
|
5257
|
-
function
|
|
5472
|
+
var zi = 50, Bi = 50;
|
|
5473
|
+
function Vi(e) {
|
|
5258
5474
|
try {
|
|
5259
5475
|
return JSON.parse(e);
|
|
5260
5476
|
} catch {
|
|
5261
5477
|
return {};
|
|
5262
5478
|
}
|
|
5263
5479
|
}
|
|
5264
|
-
function
|
|
5480
|
+
function Hi(e) {
|
|
5265
5481
|
return Pe.parse({
|
|
5266
5482
|
operation_id: e.operation_id,
|
|
5267
5483
|
seq: e.seq,
|
|
5268
|
-
payload:
|
|
5484
|
+
payload: Vi(e.payload),
|
|
5269
5485
|
status: e.status,
|
|
5270
5486
|
error_code: e.error_code,
|
|
5271
5487
|
error_message: e.error_message,
|
|
@@ -5275,12 +5491,12 @@ function Ri(e) {
|
|
|
5275
5491
|
updated_at: e.updated_at
|
|
5276
5492
|
});
|
|
5277
5493
|
}
|
|
5278
|
-
function
|
|
5494
|
+
function Ui(e, t) {
|
|
5279
5495
|
let n = [];
|
|
5280
5496
|
for (let r = 0; r < e.length; r += t) n.push(e.slice(r, r + t));
|
|
5281
5497
|
return n;
|
|
5282
5498
|
}
|
|
5283
|
-
function
|
|
5499
|
+
function Wi(e, n, r, i) {
|
|
5284
5500
|
return e.update($).set({
|
|
5285
5501
|
status: r.status,
|
|
5286
5502
|
error_code: r.error_code ?? null,
|
|
@@ -5290,7 +5506,7 @@ function Bi(e, n, r, i) {
|
|
|
5290
5506
|
updated_at: i
|
|
5291
5507
|
}).where(t(a($.operation_id, n), a($.seq, r.seq), a($.status, "pending")));
|
|
5292
5508
|
}
|
|
5293
|
-
function
|
|
5509
|
+
function Gi(e) {
|
|
5294
5510
|
return {
|
|
5295
5511
|
async createMany(t) {
|
|
5296
5512
|
if (t.length === 0) return 0;
|
|
@@ -5309,24 +5525,24 @@ function Vi(e) {
|
|
|
5309
5525
|
updated_at: n
|
|
5310
5526
|
};
|
|
5311
5527
|
});
|
|
5312
|
-
for (let t of
|
|
5528
|
+
for (let t of Ui(r, zi)) await e.insert($).values(t);
|
|
5313
5529
|
return r.length;
|
|
5314
5530
|
},
|
|
5315
5531
|
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(
|
|
5532
|
+
return (await e.select().from($).where(t(a($.operation_id, r), a($.status, "pending"))).orderBy(n($.seq)).limit(i)).map(Hi);
|
|
5317
5533
|
},
|
|
5318
5534
|
async recordOutcomes(n, r) {
|
|
5319
5535
|
if (r.length === 0) return 0;
|
|
5320
5536
|
let i = (/* @__PURE__ */ new Date()).toISOString(), o = r.map((e) => e.seq), s = /* @__PURE__ */ new Set();
|
|
5321
|
-
for (let r of
|
|
5537
|
+
for (let r of Ui(o, Bi)) {
|
|
5322
5538
|
let i = await e.select({ seq: $.seq }).from($).where(t(a($.operation_id, n), a($.status, "pending"), l($.seq, r)));
|
|
5323
5539
|
for (let e of i) s.add(e.seq);
|
|
5324
5540
|
}
|
|
5325
5541
|
let c = r.filter((e) => s.has(e.seq));
|
|
5326
5542
|
if (c.length === 0) return 0;
|
|
5327
|
-
for (let t of
|
|
5328
|
-
let [r, ...a] = t.map((t) =>
|
|
5329
|
-
r && await
|
|
5543
|
+
for (let t of Ui(c, Bi)) {
|
|
5544
|
+
let [r, ...a] = t.map((t) => Wi(e, n, t, i));
|
|
5545
|
+
r && await Pt(e, [r, ...a]);
|
|
5330
5546
|
}
|
|
5331
5547
|
return c.length;
|
|
5332
5548
|
},
|
|
@@ -5361,7 +5577,7 @@ function Vi(e) {
|
|
|
5361
5577
|
}
|
|
5362
5578
|
let u = await e.select().from($).where(t(...c)).orderBy(n($.seq)).offset(o * s).limit(s);
|
|
5363
5579
|
return {
|
|
5364
|
-
rows: u.map(
|
|
5580
|
+
rows: u.map(Hi),
|
|
5365
5581
|
start: o * s,
|
|
5366
5582
|
limit: s,
|
|
5367
5583
|
length: u.length
|
|
@@ -5375,27 +5591,27 @@ function Vi(e) {
|
|
|
5375
5591
|
}
|
|
5376
5592
|
//#endregion
|
|
5377
5593
|
//#region src/helpers/monotonic-id.ts
|
|
5378
|
-
var
|
|
5379
|
-
function
|
|
5594
|
+
var Ki = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", qi = 32, Ji = 10, Yi = 4, Xi = 10;
|
|
5595
|
+
function Zi(e, t) {
|
|
5380
5596
|
let n = "";
|
|
5381
|
-
for (let r = t; r > 0; r--) n =
|
|
5597
|
+
for (let r = t; r > 0; r--) n = Ki.charAt(e % qi) + n, e = Math.floor(e / qi);
|
|
5382
5598
|
return n;
|
|
5383
5599
|
}
|
|
5384
|
-
function
|
|
5385
|
-
let e = new Uint8Array(
|
|
5600
|
+
function Qi() {
|
|
5601
|
+
let e = new Uint8Array(Xi);
|
|
5386
5602
|
crypto.getRandomValues(e);
|
|
5387
5603
|
let t = "";
|
|
5388
|
-
for (let n = 0; n <
|
|
5604
|
+
for (let n = 0; n < Xi; n++) t += Ki.charAt(e[n] % qi);
|
|
5389
5605
|
return t;
|
|
5390
5606
|
}
|
|
5391
|
-
var
|
|
5392
|
-
function
|
|
5607
|
+
var $i = 0, ea = 0;
|
|
5608
|
+
function ta() {
|
|
5393
5609
|
let e = Date.now();
|
|
5394
|
-
return e ===
|
|
5610
|
+
return e === $i ? ea++ : ($i = e, ea = 0), Zi(e, Ji) + Zi(ea, Yi) + Qi();
|
|
5395
5611
|
}
|
|
5396
5612
|
//#endregion
|
|
5397
5613
|
//#region src/adapters/tenantOperationEvents.ts
|
|
5398
|
-
function
|
|
5614
|
+
function na(e) {
|
|
5399
5615
|
if (!e) return null;
|
|
5400
5616
|
try {
|
|
5401
5617
|
let t = JSON.parse(e);
|
|
@@ -5403,22 +5619,22 @@ function Qi(e) {
|
|
|
5403
5619
|
} catch {}
|
|
5404
5620
|
return null;
|
|
5405
5621
|
}
|
|
5406
|
-
function
|
|
5622
|
+
function ra(e) {
|
|
5407
5623
|
return je.parse({
|
|
5408
5624
|
id: e.id,
|
|
5409
5625
|
operation_id: e.operation_id,
|
|
5410
5626
|
step: e.step,
|
|
5411
5627
|
outcome: e.outcome,
|
|
5412
|
-
detail:
|
|
5628
|
+
detail: na(e.detail),
|
|
5413
5629
|
attempt: e.attempt,
|
|
5414
5630
|
created_at: e.created_at
|
|
5415
5631
|
});
|
|
5416
5632
|
}
|
|
5417
|
-
function
|
|
5633
|
+
function ia(e) {
|
|
5418
5634
|
return {
|
|
5419
5635
|
async create(t) {
|
|
5420
5636
|
let n = Ae.parse(t), r = {
|
|
5421
|
-
id: `evt_${
|
|
5637
|
+
id: `evt_${ta()}`,
|
|
5422
5638
|
operation_id: n.operation_id,
|
|
5423
5639
|
step: n.step,
|
|
5424
5640
|
outcome: n.outcome,
|
|
@@ -5426,7 +5642,7 @@ function ea(e) {
|
|
|
5426
5642
|
attempt: n.attempt,
|
|
5427
5643
|
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
5428
5644
|
};
|
|
5429
|
-
return await e.insert(
|
|
5645
|
+
return await e.insert(Pi).values(r), je.parse({
|
|
5430
5646
|
id: r.id,
|
|
5431
5647
|
operation_id: r.operation_id,
|
|
5432
5648
|
step: r.step,
|
|
@@ -5437,9 +5653,9 @@ function ea(e) {
|
|
|
5437
5653
|
});
|
|
5438
5654
|
},
|
|
5439
5655
|
async listByOperation(t, r = {}) {
|
|
5440
|
-
let i = r.page ?? 0, o = r.per_page ?? 100, s = await e.select().from(
|
|
5656
|
+
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
5657
|
return {
|
|
5442
|
-
events: s.map(
|
|
5658
|
+
events: s.map(ra),
|
|
5443
5659
|
start: i * o,
|
|
5444
5660
|
limit: o,
|
|
5445
5661
|
length: s.length
|
|
@@ -5449,7 +5665,7 @@ function ea(e) {
|
|
|
5449
5665
|
}
|
|
5450
5666
|
//#endregion
|
|
5451
5667
|
//#region src/adapters/rollouts.ts
|
|
5452
|
-
function
|
|
5668
|
+
function aa(e) {
|
|
5453
5669
|
if (!e) return null;
|
|
5454
5670
|
try {
|
|
5455
5671
|
return JSON.parse(e);
|
|
@@ -5457,7 +5673,7 @@ function ta(e) {
|
|
|
5457
5673
|
return null;
|
|
5458
5674
|
}
|
|
5459
5675
|
}
|
|
5460
|
-
function
|
|
5676
|
+
function oa(e) {
|
|
5461
5677
|
return Te.parse({
|
|
5462
5678
|
id: e.id,
|
|
5463
5679
|
kind: e.kind,
|
|
@@ -5465,15 +5681,15 @@ function na(e) {
|
|
|
5465
5681
|
target_worker_version: e.target_worker_version,
|
|
5466
5682
|
target_database_version: e.target_database_version,
|
|
5467
5683
|
wave_size: e.wave_size,
|
|
5468
|
-
canary_tenant_ids:
|
|
5469
|
-
filter:
|
|
5684
|
+
canary_tenant_ids: aa(e.canary_tenant_ids),
|
|
5685
|
+
filter: aa(e.filter),
|
|
5470
5686
|
initiated_by: e.initiated_by,
|
|
5471
5687
|
created_at: e.created_at,
|
|
5472
5688
|
updated_at: e.updated_at,
|
|
5473
5689
|
finished_at: e.finished_at
|
|
5474
5690
|
});
|
|
5475
5691
|
}
|
|
5476
|
-
function
|
|
5692
|
+
function sa(e) {
|
|
5477
5693
|
return {
|
|
5478
5694
|
async create(t) {
|
|
5479
5695
|
let n = we.parse(t), r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -5490,42 +5706,42 @@ function ra(e) {
|
|
|
5490
5706
|
updated_at: r,
|
|
5491
5707
|
finished_at: null
|
|
5492
5708
|
};
|
|
5493
|
-
await e.insert(
|
|
5709
|
+
await e.insert(Fi).values(i);
|
|
5494
5710
|
let a = await this.get(i.id);
|
|
5495
5711
|
if (!a) throw Error(`Failed to create rollout ${i.id}`);
|
|
5496
5712
|
return a;
|
|
5497
5713
|
},
|
|
5498
5714
|
async get(t) {
|
|
5499
|
-
let n = await e.select().from(
|
|
5500
|
-
return n[0] ?
|
|
5715
|
+
let n = await e.select().from(Fi).where(a(Fi.id, t)).limit(1);
|
|
5716
|
+
return n[0] ? oa(n[0]) : null;
|
|
5501
5717
|
},
|
|
5502
5718
|
async list(t = {}) {
|
|
5503
|
-
let n = t.page ?? 0, r = t.per_page ?? 50, a = await e.select().from(
|
|
5719
|
+
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
5720
|
return {
|
|
5505
|
-
rollouts: a.map(
|
|
5721
|
+
rollouts: a.map(oa),
|
|
5506
5722
|
start: n * r,
|
|
5507
5723
|
limit: r,
|
|
5508
5724
|
length: a.length
|
|
5509
5725
|
};
|
|
5510
5726
|
},
|
|
5511
5727
|
async update(t, n) {
|
|
5512
|
-
if ((await e.select({ id:
|
|
5728
|
+
if ((await e.select({ id: Fi.id }).from(Fi).where(a(Fi.id, t)).limit(1)).length === 0) return !1;
|
|
5513
5729
|
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(
|
|
5730
|
+
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
5731
|
},
|
|
5516
5732
|
async remove(t) {
|
|
5517
|
-
return (await e.select({ id:
|
|
5733
|
+
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
5734
|
}
|
|
5519
5735
|
};
|
|
5520
5736
|
}
|
|
5521
5737
|
//#endregion
|
|
5522
5738
|
//#region src/adapters/index.ts
|
|
5523
|
-
function
|
|
5739
|
+
function ca(e, t = { useTransactions: !0 }) {
|
|
5524
5740
|
let n = {
|
|
5525
|
-
actions:
|
|
5526
|
-
actionExecutions:
|
|
5527
|
-
actionVersions:
|
|
5528
|
-
branding:
|
|
5741
|
+
actions: At(e),
|
|
5742
|
+
actionExecutions: Mt(e),
|
|
5743
|
+
actionVersions: It(e),
|
|
5744
|
+
branding: Rt(e),
|
|
5529
5745
|
clients: Wt(e),
|
|
5530
5746
|
clientConnections: Kt(e),
|
|
5531
5747
|
clientGrants: Jt(e),
|
|
@@ -5536,53 +5752,53 @@ function ia(e, t = { useTransactions: !0 }) {
|
|
|
5536
5752
|
customText: un(e),
|
|
5537
5753
|
emailProviders: dn(e),
|
|
5538
5754
|
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:
|
|
5755
|
+
flows: gn(e),
|
|
5756
|
+
forms: bn(e),
|
|
5757
|
+
grants: wn(e),
|
|
5758
|
+
hookCode: On(e),
|
|
5759
|
+
hooks: Mn(e),
|
|
5760
|
+
invites: In(e),
|
|
5761
|
+
keys: Rn(e),
|
|
5762
|
+
loginSessions: Un(e),
|
|
5763
|
+
logs: Gn(e),
|
|
5764
|
+
logStreams: ir(e),
|
|
5765
|
+
migrationSources: or(e),
|
|
5766
|
+
authenticationMethods: Xn(e),
|
|
5767
|
+
organizations: er(e),
|
|
5768
|
+
organizationConnections: nr(e),
|
|
5769
|
+
passwords: cr(e),
|
|
5770
|
+
promptSettings: lr(e),
|
|
5771
|
+
promptPartials: ur(e),
|
|
5772
|
+
proxyRoutes: mr(e),
|
|
5773
|
+
scimConfigurations: Sr(e),
|
|
5774
|
+
scimTokens: wr(e),
|
|
5775
|
+
scimExternalIds: Er(e),
|
|
5776
|
+
refreshTokens: kr(e),
|
|
5777
|
+
resourceServers: Fr(e),
|
|
5778
|
+
rolePermissions: Ir(e),
|
|
5779
|
+
userPermissions: zr(e),
|
|
5780
|
+
roles: Vr(e),
|
|
5781
|
+
sessions: Kr(e),
|
|
5782
|
+
sessionCleanup: Ni(e),
|
|
5783
|
+
tenants: Zr(e),
|
|
5784
|
+
tokenExchangeProfiles: vr(e),
|
|
5569
5785
|
...t.controlPlane ? {
|
|
5570
|
-
tenantOperations:
|
|
5571
|
-
tenantOperationEvents:
|
|
5572
|
-
tenantOperationRows:
|
|
5573
|
-
rollouts:
|
|
5786
|
+
tenantOperations: Ri(e),
|
|
5787
|
+
tenantOperationEvents: ia(e),
|
|
5788
|
+
tenantOperationRows: Gi(e),
|
|
5789
|
+
rollouts: sa(e)
|
|
5574
5790
|
} : {},
|
|
5575
|
-
themes:
|
|
5576
|
-
universalLoginTemplates:
|
|
5577
|
-
users:
|
|
5578
|
-
userActivity:
|
|
5579
|
-
userRoles:
|
|
5580
|
-
userOrganizations:
|
|
5581
|
-
stats:
|
|
5582
|
-
analytics:
|
|
5583
|
-
outbox:
|
|
5791
|
+
themes: ei(e),
|
|
5792
|
+
universalLoginTemplates: ti(e),
|
|
5793
|
+
users: yi(e),
|
|
5794
|
+
userActivity: ri(e),
|
|
5795
|
+
userRoles: bi(e),
|
|
5796
|
+
userOrganizations: xi(e),
|
|
5797
|
+
stats: Ti(e),
|
|
5798
|
+
analytics: ji(e),
|
|
5799
|
+
outbox: si(e),
|
|
5584
5800
|
async transaction(r) {
|
|
5585
|
-
if (t.useTransactions === !1 ||
|
|
5801
|
+
if (t.useTransactions === !1 || Nt(e)) return r(n);
|
|
5586
5802
|
await e.run(y`BEGIN`);
|
|
5587
5803
|
try {
|
|
5588
5804
|
let t = await r(n);
|
|
@@ -5596,7 +5812,7 @@ function ia(e, t = { useTransactions: !0 }) {
|
|
|
5596
5812
|
}
|
|
5597
5813
|
//#endregion
|
|
5598
5814
|
//#region src/adapters/resolveHost.ts
|
|
5599
|
-
function
|
|
5815
|
+
function la(e) {
|
|
5600
5816
|
if (!e) return { path: "/*" };
|
|
5601
5817
|
try {
|
|
5602
5818
|
let t = JSON.parse(e), n = xe.safeParse(t);
|
|
@@ -5604,7 +5820,7 @@ function aa(e) {
|
|
|
5604
5820
|
} catch {}
|
|
5605
5821
|
return { path: "/*" };
|
|
5606
5822
|
}
|
|
5607
|
-
function
|
|
5823
|
+
function ua(e) {
|
|
5608
5824
|
if (!e) return [];
|
|
5609
5825
|
try {
|
|
5610
5826
|
let t = JSON.parse(e);
|
|
@@ -5619,20 +5835,20 @@ function oa(e) {
|
|
|
5619
5835
|
return [];
|
|
5620
5836
|
}
|
|
5621
5837
|
}
|
|
5622
|
-
async function
|
|
5838
|
+
async function da(e, r) {
|
|
5623
5839
|
let i = r.toLowerCase(), o = (await e.select({
|
|
5624
|
-
custom_domain_id:
|
|
5625
|
-
tenant_id:
|
|
5626
|
-
domain:
|
|
5627
|
-
}).from(
|
|
5840
|
+
custom_domain_id: Je.custom_domain_id,
|
|
5841
|
+
tenant_id: Je.tenant_id,
|
|
5842
|
+
domain: Je.domain
|
|
5843
|
+
}).from(Je).where(a(Je.domain, i)).limit(1))[0];
|
|
5628
5844
|
if (!o) return null;
|
|
5629
|
-
let s = (await e.select().from(
|
|
5845
|
+
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
5846
|
id: e.id,
|
|
5631
5847
|
tenant_id: e.tenant_id,
|
|
5632
5848
|
custom_domain_id: e.custom_domain_id,
|
|
5633
5849
|
priority: e.priority,
|
|
5634
|
-
match:
|
|
5635
|
-
handlers:
|
|
5850
|
+
match: la(e.match),
|
|
5851
|
+
handlers: ua(e.handlers),
|
|
5636
5852
|
created_at: e.created_at,
|
|
5637
5853
|
updated_at: e.updated_at
|
|
5638
5854
|
}));
|
|
@@ -5645,11 +5861,11 @@ async function sa(e, r) {
|
|
|
5645
5861
|
}
|
|
5646
5862
|
//#endregion
|
|
5647
5863
|
//#region src/adapters/proxyData.ts
|
|
5648
|
-
function
|
|
5864
|
+
function fa(e) {
|
|
5649
5865
|
return {
|
|
5650
|
-
proxyRoutes:
|
|
5651
|
-
resolveHost: (t) =>
|
|
5866
|
+
proxyRoutes: mr(e),
|
|
5867
|
+
resolveHost: (t) => da(e, t)
|
|
5652
5868
|
};
|
|
5653
5869
|
}
|
|
5654
5870
|
//#endregion
|
|
5655
|
-
export {
|
|
5871
|
+
export { fa as createProxyDataAdapter, mr as createProxyRoutesAdapter, ca as default, vt as sqlite };
|