@authhero/drizzle 1.10.0 → 1.12.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.mjs
CHANGED
|
@@ -475,7 +475,7 @@ var Re = Object.defineProperty, ze = (e, t) => {
|
|
|
475
475
|
C({ columns: [e.tenant_id, e.id] }),
|
|
476
476
|
x("connections_tenant_id_index").on(e.tenant_id),
|
|
477
477
|
re("connections_id_unique").on(e.id)
|
|
478
|
-
]),
|
|
478
|
+
]), Ke = w("custom_domains", {
|
|
479
479
|
custom_domain_id: T("custom_domain_id", { length: 256 }).primaryKey(),
|
|
480
480
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
481
481
|
domain: T("domain", { length: 255 }).notNull(),
|
|
@@ -489,7 +489,7 @@ var Re = Object.defineProperty, ze = (e, t) => {
|
|
|
489
489
|
domain_metadata: T("domain_metadata", { length: 2048 }),
|
|
490
490
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
491
491
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
492
|
-
}, (e) => [re("custom_domains_domain_unique").on(e.domain)]),
|
|
492
|
+
}, (e) => [re("custom_domains_domain_unique").on(e.domain)]), qe = 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 Re = Object.defineProperty, ze = (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
|
+
}), V = 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 Re = Object.defineProperty, ze = (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)]), H = 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 Re = Object.defineProperty, ze = (e, t) => {
|
|
|
522
522
|
x("idx_user_organizations_tenant_id").on(e.tenant_id),
|
|
523
523
|
x("idx_user_organizations_user_id").on(e.user_id),
|
|
524
524
|
x("idx_user_organizations_organization_id").on(e.organization_id)
|
|
525
|
-
]),
|
|
525
|
+
]), Je = 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 Re = Object.defineProperty, ze = (e, t) => {
|
|
|
544
544
|
x("idx_invites_organization_id").on(e.organization_id),
|
|
545
545
|
x("idx_invites_expires_at").on(e.expires_at),
|
|
546
546
|
x("idx_invites_tenant_created").on(e.tenant_id, e.created_at)
|
|
547
|
-
]),
|
|
547
|
+
]), U = w("roles", {
|
|
548
548
|
id: T("id", { length: 21 }).notNull(),
|
|
549
549
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
550
550
|
name: T("name", { length: 50 }).notNull(),
|
|
@@ -556,7 +556,7 @@ var Re = Object.defineProperty, ze = (e, t) => {
|
|
|
556
556
|
}, (e) => [C({
|
|
557
557
|
columns: [e.tenant_id, e.id],
|
|
558
558
|
name: "roles_pk"
|
|
559
|
-
})]),
|
|
559
|
+
})]), W = w("role_permissions", {
|
|
560
560
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
561
561
|
role_id: T("role_id", { length: 21 }).notNull(),
|
|
562
562
|
resource_server_identifier: T("resource_server_identifier", { length: 191 }).notNull(),
|
|
@@ -807,7 +807,13 @@ var Re = Object.defineProperty, ze = (e, t) => {
|
|
|
807
807
|
e.tenant_id,
|
|
808
808
|
e.prompt,
|
|
809
809
|
e.language
|
|
810
|
-
] })]), ct = w("
|
|
810
|
+
] })]), ct = w("prompt_partials", {
|
|
811
|
+
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
812
|
+
prompt: T("prompt", { length: 64 }).notNull(),
|
|
813
|
+
body: T("body").notNull(),
|
|
814
|
+
created_at_ts: S("created_at_ts").notNull(),
|
|
815
|
+
updated_at_ts: S("updated_at_ts").notNull()
|
|
816
|
+
}, (e) => [C({ columns: [e.tenant_id, e.prompt] })]), lt = w("authentication_methods", {
|
|
811
817
|
id: T("id", { length: 26 }).primaryKey(),
|
|
812
818
|
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
813
819
|
user_id: T("user_id", { length: 255 }).notNull(),
|
|
@@ -889,7 +895,7 @@ var Re = Object.defineProperty, ze = (e, t) => {
|
|
|
889
895
|
handlers: T("handlers", { length: 16384 }).notNull().default("[]"),
|
|
890
896
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
891
897
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
892
|
-
}, (e) => [x("proxy_routes_tenant_id_idx").on(e.tenant_id), x("proxy_routes_custom_domain_id_idx").on(e.custom_domain_id)]),
|
|
898
|
+
}, (e) => [x("proxy_routes_tenant_id_idx").on(e.tenant_id), x("proxy_routes_custom_domain_id_idx").on(e.custom_domain_id)]), ut = w("scim_configurations", {
|
|
893
899
|
connection_id: T("connection_id", { length: 255 }).notNull(),
|
|
894
900
|
tenant_id: T("tenant_id", { length: 255 }).notNull(),
|
|
895
901
|
user_id_attribute: T("user_id_attribute", { length: 255 }).notNull().default("externalId"),
|
|
@@ -909,7 +915,7 @@ var Re = Object.defineProperty, ze = (e, t) => {
|
|
|
909
915
|
C({ columns: [e.tenant_id, e.token_id] }),
|
|
910
916
|
x("scim_tokens_tenant_connection_idx").on(e.tenant_id, e.connection_id),
|
|
911
917
|
re("scim_tokens_tenant_hash_idx").on(e.tenant_id, e.token_hash)
|
|
912
|
-
]),
|
|
918
|
+
]), dt = w("scim_external_ids", {
|
|
913
919
|
tenant_id: T("tenant_id", { length: 255 }).notNull(),
|
|
914
920
|
connection_id: T("connection_id", { length: 255 }).notNull(),
|
|
915
921
|
external_id: T("external_id", { length: 255 }).notNull(),
|
|
@@ -919,7 +925,7 @@ var Re = Object.defineProperty, ze = (e, t) => {
|
|
|
919
925
|
e.tenant_id,
|
|
920
926
|
e.connection_id,
|
|
921
927
|
e.user_id
|
|
922
|
-
] }), re("scim_external_ids_connection_external_idx").on(e.tenant_id, e.connection_id, e.external_id)]),
|
|
928
|
+
] }), re("scim_external_ids_connection_external_idx").on(e.tenant_id, e.connection_id, e.external_id)]), ft = w("token_exchange_profiles", {
|
|
923
929
|
id: T("id", { length: 64 }).primaryKey(),
|
|
924
930
|
tenant_id: T("tenant_id", { length: 255 }).notNull(),
|
|
925
931
|
name: T("name", { length: 255 }).notNull(),
|
|
@@ -929,21 +935,21 @@ var Re = Object.defineProperty, ze = (e, t) => {
|
|
|
929
935
|
jwt_verification: T("jwt_verification"),
|
|
930
936
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
931
937
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
932
|
-
}, (e) => [re("token_exchange_profiles_tenant_subject_token_type_idx").on(e.tenant_id, e.subject_token_type)]),
|
|
938
|
+
}, (e) => [re("token_exchange_profiles_tenant_subject_token_type_idx").on(e.tenant_id, e.subject_token_type)]), pt = /* @__PURE__ */ ze({
|
|
933
939
|
actionExecutions: () => Ve,
|
|
934
940
|
actionVersions: () => k,
|
|
935
941
|
actions: () => Be,
|
|
936
942
|
authenticationCodes: () => Ue,
|
|
937
|
-
authenticationMethods: () =>
|
|
943
|
+
authenticationMethods: () => lt,
|
|
938
944
|
branding: () => Xe,
|
|
939
945
|
clientGrants: () => R,
|
|
940
946
|
clientRegistrationTokens: () => L,
|
|
941
947
|
clients: () => I,
|
|
942
948
|
codes: () => F,
|
|
943
949
|
connections: () => B,
|
|
944
|
-
customDomains: () =>
|
|
950
|
+
customDomains: () => Ke,
|
|
945
951
|
customText: () => st,
|
|
946
|
-
domains: () =>
|
|
952
|
+
domains: () => qe,
|
|
947
953
|
emailProviders: () => nt,
|
|
948
954
|
emailTemplates: () => rt,
|
|
949
955
|
flows: () => et,
|
|
@@ -951,31 +957,32 @@ var Re = Object.defineProperty, ze = (e, t) => {
|
|
|
951
957
|
grants: () => z,
|
|
952
958
|
hookCode: () => at,
|
|
953
959
|
hooks: () => it,
|
|
954
|
-
invites: () =>
|
|
960
|
+
invites: () => Je,
|
|
955
961
|
keys: () => ot,
|
|
956
962
|
loginSessions: () => P,
|
|
957
963
|
logs: () => q,
|
|
958
|
-
organizations: () =>
|
|
964
|
+
organizations: () => V,
|
|
959
965
|
otps: () => We,
|
|
960
966
|
outboxEvents: () => J,
|
|
961
967
|
passwords: () => j,
|
|
968
|
+
promptPartials: () => ct,
|
|
962
969
|
promptSettings: () => tt,
|
|
963
970
|
proxyRoutes: () => Y,
|
|
964
971
|
refreshTokens: () => N,
|
|
965
972
|
resourceServers: () => K,
|
|
966
|
-
rolePermissions: () =>
|
|
967
|
-
roles: () =>
|
|
968
|
-
scimConfigurations: () =>
|
|
969
|
-
scimExternalIds: () =>
|
|
973
|
+
rolePermissions: () => W,
|
|
974
|
+
roles: () => U,
|
|
975
|
+
scimConfigurations: () => ut,
|
|
976
|
+
scimExternalIds: () => dt,
|
|
970
977
|
scimTokens: () => X,
|
|
971
978
|
sessions: () => M,
|
|
972
979
|
tenants: () => O,
|
|
973
980
|
themes: () => Qe,
|
|
974
981
|
tickets: () => Ge,
|
|
975
|
-
tokenExchangeProfiles: () =>
|
|
982
|
+
tokenExchangeProfiles: () => ft,
|
|
976
983
|
universalLoginTemplates: () => Ze,
|
|
977
984
|
userActivity: () => He,
|
|
978
|
-
userOrganizations: () =>
|
|
985
|
+
userOrganizations: () => H,
|
|
979
986
|
userPermissions: () => Ye,
|
|
980
987
|
userRoles: () => G,
|
|
981
988
|
users: () => A
|
|
@@ -991,14 +998,14 @@ function Z(e, t) {
|
|
|
991
998
|
}
|
|
992
999
|
return e;
|
|
993
1000
|
}
|
|
994
|
-
function
|
|
1001
|
+
function mt(e, t = "", n = {}) {
|
|
995
1002
|
for (let r in e) if (Object.prototype.hasOwnProperty.call(e, r)) {
|
|
996
1003
|
let i = t ? `${t}_${r}` : r, a = e[r];
|
|
997
|
-
typeof a == "object" && a && !Array.isArray(a) ?
|
|
1004
|
+
typeof a == "object" && a && !Array.isArray(a) ? mt(a, i, n) : typeof a == "boolean" ? n[i] = +!!a : n[i] = a;
|
|
998
1005
|
}
|
|
999
1006
|
return n;
|
|
1000
1007
|
}
|
|
1001
|
-
function
|
|
1008
|
+
function ht(e, t) {
|
|
1002
1009
|
let n = {};
|
|
1003
1010
|
for (let [r, i] of Object.entries(e)) {
|
|
1004
1011
|
let e = t.find((e) => r.startsWith(`${e}_`));
|
|
@@ -1015,13 +1022,13 @@ function mt(e, t) {
|
|
|
1015
1022
|
}
|
|
1016
1023
|
//#endregion
|
|
1017
1024
|
//#region src/helpers/filter.ts
|
|
1018
|
-
function
|
|
1025
|
+
function gt(e) {
|
|
1019
1026
|
return typeof e == "object" && !!e && "coalesce" in e && "defaultValue" in e;
|
|
1020
1027
|
}
|
|
1021
|
-
function
|
|
1028
|
+
function _t(e) {
|
|
1022
1029
|
return y`coalesce(${e.coalesce}, ${e.defaultValue})`;
|
|
1023
1030
|
}
|
|
1024
|
-
function
|
|
1031
|
+
function vt(n, r, i, l = []) {
|
|
1025
1032
|
let ee = u(n, te) ? o(n) : n, b = new Set(l), ne = (e) => {
|
|
1026
1033
|
let t = Number(e);
|
|
1027
1034
|
return Number.isFinite(t) ? t : e;
|
|
@@ -1034,7 +1041,7 @@ function _t(n, r, i, l = []) {
|
|
|
1034
1041
|
let [, r, i] = n;
|
|
1035
1042
|
if (!r || !i) return null;
|
|
1036
1043
|
let o = r.trim(), s = Ie(i.replace(/^"(.*)"$/, "$1").trim()), c = ee[o];
|
|
1037
|
-
return
|
|
1044
|
+
return gt(c) ? a(_t(c), ne(s)) : u(c, e) ? b.has(o) ? p(c, `%${s}%`) : a(c, s) : null;
|
|
1038
1045
|
}).filter((e) => e !== null);
|
|
1039
1046
|
return r.length === 0 ? null : r.length === 1 ? r[0] : t(...r) ?? null;
|
|
1040
1047
|
}).filter((e) => e !== null);
|
|
@@ -1057,12 +1064,12 @@ function _t(n, r, i, l = []) {
|
|
|
1057
1064
|
};
|
|
1058
1065
|
}), C = [];
|
|
1059
1066
|
for (let { key: t, value: n, isNegation: r, isExistsQuery: o, operator: l } of S) if (t) {
|
|
1060
|
-
let i = ee[t], v =
|
|
1067
|
+
let i = ee[t], v = gt(i), te = v ? i.coalesce : u(i, e) ? i : void 0, x = v ? ne(n) : n;
|
|
1061
1068
|
if (!te) {
|
|
1062
1069
|
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}`);
|
|
1063
1070
|
continue;
|
|
1064
1071
|
}
|
|
1065
|
-
let S = v ?
|
|
1072
|
+
let S = v ? _t(i) : y`${te}`;
|
|
1066
1073
|
if (o) C.push(r ? f(te) : d(te));
|
|
1067
1074
|
else if (b.has(t) && l === "=") C.push(r ? _(te, `%${n}%`) : p(te, `%${n}%`));
|
|
1068
1075
|
else if (r) switch (l) {
|
|
@@ -1111,11 +1118,11 @@ function _t(n, r, i, l = []) {
|
|
|
1111
1118
|
}
|
|
1112
1119
|
//#endregion
|
|
1113
1120
|
//#region src/adapters/actions.ts
|
|
1114
|
-
function
|
|
1121
|
+
function yt(e) {
|
|
1115
1122
|
let t = Z(e);
|
|
1116
1123
|
return Array.isArray(t) ? t : [];
|
|
1117
1124
|
}
|
|
1118
|
-
function
|
|
1125
|
+
function bt(e) {
|
|
1119
1126
|
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;
|
|
1120
1127
|
return {
|
|
1121
1128
|
...f,
|
|
@@ -1132,7 +1139,7 @@ function yt(e) {
|
|
|
1132
1139
|
updated_at: new Date(Number(n)).toISOString()
|
|
1133
1140
|
};
|
|
1134
1141
|
}
|
|
1135
|
-
function
|
|
1142
|
+
function xt(e) {
|
|
1136
1143
|
return {
|
|
1137
1144
|
async create(t, n) {
|
|
1138
1145
|
let r = Date.now(), i = `act_${b()}`;
|
|
@@ -1168,12 +1175,12 @@ function bt(e) {
|
|
|
1168
1175
|
},
|
|
1169
1176
|
async get(n, r) {
|
|
1170
1177
|
let i = await e.select().from(Be).where(t(a(Be.tenant_id, n), a(Be.id, r))).get();
|
|
1171
|
-
return i ?
|
|
1178
|
+
return i ? bt(i) : null;
|
|
1172
1179
|
},
|
|
1173
1180
|
async list(o, s = {}) {
|
|
1174
1181
|
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s, p = [a(Be.tenant_id, o)];
|
|
1175
1182
|
if (f) {
|
|
1176
|
-
let e =
|
|
1183
|
+
let e = vt(Be, f, ["name"]);
|
|
1177
1184
|
e && p.push(e);
|
|
1178
1185
|
}
|
|
1179
1186
|
let m = t(...p), h = e.select().from(Be).where(m).$dynamic();
|
|
@@ -1181,7 +1188,7 @@ function bt(e) {
|
|
|
1181
1188
|
let e = Be[d.sort_by];
|
|
1182
1189
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
1183
1190
|
}
|
|
1184
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
1191
|
+
let g = (await h.offset(c * l).limit(l)).map(bt);
|
|
1185
1192
|
if (!u) return {
|
|
1186
1193
|
actions: g,
|
|
1187
1194
|
start: 0,
|
|
@@ -1199,7 +1206,7 @@ function bt(e) {
|
|
|
1199
1206
|
async update(n, r, i) {
|
|
1200
1207
|
let o = { updated_at_ts: Date.now() };
|
|
1201
1208
|
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) {
|
|
1202
|
-
let s = await e.select({ secrets: Be.secrets }).from(Be).where(t(a(Be.tenant_id, n), a(Be.id, r))).get(), c = new Map(
|
|
1209
|
+
let s = await e.select({ secrets: Be.secrets }).from(Be).where(t(a(Be.tenant_id, n), a(Be.id, r))).get(), c = new Map(yt(s?.secrets).map((e) => [e.name, e])), l = i.secrets.map((e) => e.value === void 0 ? {
|
|
1203
1210
|
name: e.name,
|
|
1204
1211
|
value: c.get(e.name)?.value
|
|
1205
1212
|
} : e);
|
|
@@ -1218,8 +1225,8 @@ function bt(e) {
|
|
|
1218
1225
|
}
|
|
1219
1226
|
//#endregion
|
|
1220
1227
|
//#region src/adapters/actionExecutions.ts
|
|
1221
|
-
var
|
|
1222
|
-
function
|
|
1228
|
+
var St = 500;
|
|
1229
|
+
function Ct(e) {
|
|
1223
1230
|
return {
|
|
1224
1231
|
async create(t, n) {
|
|
1225
1232
|
let r = Date.now();
|
|
@@ -1261,8 +1268,8 @@ function St(e) {
|
|
|
1261
1268
|
if (Number.isNaN(n)) throw Error(`Invalid olderThan date: ${t}`);
|
|
1262
1269
|
let r = 0;
|
|
1263
1270
|
for (;;) {
|
|
1264
|
-
let t = await e.delete(Ve).where(y`rowid IN (SELECT rowid FROM ${Ve} WHERE ${Ve.created_at_ts} < ${n} LIMIT ${
|
|
1265
|
-
if (r += t.length, t.length <
|
|
1271
|
+
let t = await e.delete(Ve).where(y`rowid IN (SELECT rowid FROM ${Ve} WHERE ${Ve.created_at_ts} < ${n} LIMIT ${St})`).returning({ id: Ve.id });
|
|
1272
|
+
if (r += t.length, t.length < St) break;
|
|
1266
1273
|
}
|
|
1267
1274
|
return r;
|
|
1268
1275
|
}
|
|
@@ -1270,12 +1277,12 @@ function St(e) {
|
|
|
1270
1277
|
}
|
|
1271
1278
|
//#endregion
|
|
1272
1279
|
//#region src/adapters/atomic.ts
|
|
1273
|
-
function
|
|
1280
|
+
function wt(e) {
|
|
1274
1281
|
let t = e;
|
|
1275
1282
|
return typeof t == "object" && !!t && "batch" in t && typeof t.batch == "function";
|
|
1276
1283
|
}
|
|
1277
|
-
async function
|
|
1278
|
-
if (
|
|
1284
|
+
async function Tt(e, t) {
|
|
1285
|
+
if (wt(e)) return e.batch(t);
|
|
1279
1286
|
await e.run(y`BEGIN`);
|
|
1280
1287
|
try {
|
|
1281
1288
|
let n = [];
|
|
@@ -1292,7 +1299,7 @@ async function wt(e, t) {
|
|
|
1292
1299
|
}
|
|
1293
1300
|
//#endregion
|
|
1294
1301
|
//#region src/adapters/actionVersions.ts
|
|
1295
|
-
function
|
|
1302
|
+
function Et(e) {
|
|
1296
1303
|
let { created_at_ts: t, updated_at_ts: n, secrets: r, dependencies: i, supported_triggers: a, deployed: o, runtime: s, ...c } = e;
|
|
1297
1304
|
return {
|
|
1298
1305
|
...c,
|
|
@@ -1305,7 +1312,7 @@ function Tt(e) {
|
|
|
1305
1312
|
updated_at: new Date(Number(n)).toISOString()
|
|
1306
1313
|
};
|
|
1307
1314
|
}
|
|
1308
|
-
function
|
|
1315
|
+
function Dt(e) {
|
|
1309
1316
|
return {
|
|
1310
1317
|
async create(n, r) {
|
|
1311
1318
|
let o = Date.now(), s = `ver_${b()}`, c = r.deployed !== !1, l = ((await e.select({ number: k.number }).from(k).where(t(a(k.tenant_id, n), a(k.action_id, r.action_id))).orderBy(i(k.number)).limit(1).get())?.number ?? 0) + 1, u = e.insert(k).values({
|
|
@@ -1322,7 +1329,7 @@ function Et(e) {
|
|
|
1322
1329
|
created_at_ts: o,
|
|
1323
1330
|
updated_at_ts: o
|
|
1324
1331
|
});
|
|
1325
|
-
return await
|
|
1332
|
+
return await Tt(e, c ? [e.update(k).set({
|
|
1326
1333
|
deployed: 0,
|
|
1327
1334
|
updated_at_ts: o
|
|
1328
1335
|
}).where(t(a(k.tenant_id, n), a(k.action_id, r.action_id), a(k.deployed, 1))), u] : [u]), {
|
|
@@ -1342,10 +1349,10 @@ function Et(e) {
|
|
|
1342
1349
|
},
|
|
1343
1350
|
async get(n, r, i) {
|
|
1344
1351
|
let o = await e.select().from(k).where(t(a(k.tenant_id, n), a(k.action_id, r), a(k.id, i))).get();
|
|
1345
|
-
return o ?
|
|
1352
|
+
return o ? Et(o) : null;
|
|
1346
1353
|
},
|
|
1347
1354
|
async list(n, o, s = {}) {
|
|
1348
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1 } = s, d = t(a(k.tenant_id, n), a(k.action_id, o)), f = (await e.select().from(k).where(d).orderBy(i(k.number)).offset(c * l).limit(l)).map(
|
|
1355
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1 } = s, d = t(a(k.tenant_id, n), a(k.action_id, o)), f = (await e.select().from(k).where(d).orderBy(i(k.number)).offset(c * l).limit(l)).map(Et);
|
|
1349
1356
|
if (!u) return {
|
|
1350
1357
|
versions: f,
|
|
1351
1358
|
start: 0,
|
|
@@ -1367,10 +1374,10 @@ function Et(e) {
|
|
|
1367
1374
|
}
|
|
1368
1375
|
//#endregion
|
|
1369
1376
|
//#region src/adapters/branding.ts
|
|
1370
|
-
function
|
|
1377
|
+
function Ot(e) {
|
|
1371
1378
|
return e === "dark" || e === "light" || e === "auto";
|
|
1372
1379
|
}
|
|
1373
|
-
function
|
|
1380
|
+
function kt(e) {
|
|
1374
1381
|
return {
|
|
1375
1382
|
async get(t) {
|
|
1376
1383
|
let n = await e.select().from(Xe).where(a(Xe.tenant_id, t)).get();
|
|
@@ -1388,7 +1395,7 @@ function Ot(e) {
|
|
|
1388
1395
|
}
|
|
1389
1396
|
},
|
|
1390
1397
|
font: u ? { url: u } : void 0,
|
|
1391
|
-
dark_mode:
|
|
1398
|
+
dark_mode: Ot(d) ? d : void 0
|
|
1392
1399
|
});
|
|
1393
1400
|
},
|
|
1394
1401
|
async set(t, n) {
|
|
@@ -1414,18 +1421,18 @@ function Ot(e) {
|
|
|
1414
1421
|
}
|
|
1415
1422
|
//#endregion
|
|
1416
1423
|
//#region src/helpers/paginate.ts
|
|
1417
|
-
function
|
|
1424
|
+
function At(e) {
|
|
1418
1425
|
return e?.from !== void 0 || e?.take !== void 0;
|
|
1419
1426
|
}
|
|
1420
|
-
function
|
|
1427
|
+
function jt(e) {
|
|
1421
1428
|
let t = e?.take, n = typeof t == "number" && Number.isFinite(t) ? Math.floor(t) : NaN;
|
|
1422
1429
|
return n >= 1 ? n : 50;
|
|
1423
1430
|
}
|
|
1424
|
-
function
|
|
1431
|
+
function Mt(e) {
|
|
1425
1432
|
let t = e.sortOrder === "asc" ? n : i;
|
|
1426
1433
|
return [t(e.sortColumn), t(e.idColumn)];
|
|
1427
1434
|
}
|
|
1428
|
-
function
|
|
1435
|
+
function Nt(e, t) {
|
|
1429
1436
|
let n = e?.from ? ge(e.from) : null;
|
|
1430
1437
|
if (!n) return;
|
|
1431
1438
|
if (n.k !== t.sortKey) throw new Le(400, { message: "The `from` cursor was issued under a different sort and cannot be used with this request" });
|
|
@@ -1433,7 +1440,7 @@ function Mt(e, t) {
|
|
|
1433
1440
|
let r = t.sortOrder === "asc" ? y.raw(">") : y.raw("<");
|
|
1434
1441
|
return y`(${t.sortColumn}, ${t.idColumn}) ${r} (${n.s}, ${n.i})`;
|
|
1435
1442
|
}
|
|
1436
|
-
function
|
|
1443
|
+
function Pt(e, t, n, r = "id", i) {
|
|
1437
1444
|
let a = e.length > t, o = a ? e.slice(0, t) : e, s, c = o[o.length - 1];
|
|
1438
1445
|
if (a && c) {
|
|
1439
1446
|
let e = c[n];
|
|
@@ -1450,7 +1457,7 @@ function Nt(e, t, n, r = "id", i) {
|
|
|
1450
1457
|
}
|
|
1451
1458
|
//#endregion
|
|
1452
1459
|
//#region src/adapters/clients.ts
|
|
1453
|
-
var
|
|
1460
|
+
var Ft = [
|
|
1454
1461
|
"global",
|
|
1455
1462
|
"is_first_party",
|
|
1456
1463
|
"oidc_conformant",
|
|
@@ -1462,7 +1469,7 @@ var Pt = [
|
|
|
1462
1469
|
"require_pushed_authorization_requests",
|
|
1463
1470
|
"require_proof_of_possession",
|
|
1464
1471
|
"hide_sign_up_disabled_error"
|
|
1465
|
-
],
|
|
1472
|
+
], It = [
|
|
1466
1473
|
"callbacks",
|
|
1467
1474
|
"allowed_origins",
|
|
1468
1475
|
"web_origins",
|
|
@@ -1471,7 +1478,7 @@ var Pt = [
|
|
|
1471
1478
|
"allowed_logout_urls",
|
|
1472
1479
|
"grant_types",
|
|
1473
1480
|
"signing_keys"
|
|
1474
|
-
],
|
|
1481
|
+
], Lt = [
|
|
1475
1482
|
"session_transfer",
|
|
1476
1483
|
"oidc_logout",
|
|
1477
1484
|
"jwt_configuration",
|
|
@@ -1488,21 +1495,21 @@ var Pt = [
|
|
|
1488
1495
|
"registration_metadata",
|
|
1489
1496
|
"token_exchange"
|
|
1490
1497
|
];
|
|
1491
|
-
function
|
|
1498
|
+
function Rt(e) {
|
|
1492
1499
|
let { tenant_id: t, connections: n, ...r } = e, i = { ...r };
|
|
1493
|
-
for (let e of
|
|
1494
|
-
for (let e of
|
|
1495
|
-
for (let e of
|
|
1500
|
+
for (let e of Ft) i[e] = !!r[e];
|
|
1501
|
+
for (let e of It) i[e] = Z(r[e], []);
|
|
1502
|
+
for (let e of Lt) i[e] = Z(r[e], {});
|
|
1496
1503
|
return i.connections = Z(n, []), D(i);
|
|
1497
1504
|
}
|
|
1498
|
-
function
|
|
1505
|
+
function zt(e) {
|
|
1499
1506
|
let t = { ...e };
|
|
1500
|
-
ie(e,
|
|
1501
|
-
for (let n of
|
|
1502
|
-
for (let n of
|
|
1507
|
+
ie(e, Ft, t);
|
|
1508
|
+
for (let n of It) e[n] !== void 0 && (t[n] = JSON.stringify(e[n] || []));
|
|
1509
|
+
for (let n of Lt) e[n] !== void 0 && (t[n] = JSON.stringify(e[n] || {}));
|
|
1503
1510
|
return e.connections !== void 0 && (t.connections = JSON.stringify(e.connections || [])), ce(t);
|
|
1504
1511
|
}
|
|
1505
|
-
function
|
|
1512
|
+
function Bt(e) {
|
|
1506
1513
|
return {
|
|
1507
1514
|
async create(t, n) {
|
|
1508
1515
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -1526,12 +1533,12 @@ function zt(e) {
|
|
|
1526
1533
|
created_at: r,
|
|
1527
1534
|
updated_at: r
|
|
1528
1535
|
};
|
|
1529
|
-
for (let e of
|
|
1536
|
+
for (let e of Ft) i[e] = n[e] ?? !1;
|
|
1530
1537
|
i.oidc_conformant = n.oidc_conformant ?? !0, i.auth0_conformant = n.auth0_conformant ?? !0, i.sso_disabled = n.sso_disabled ?? !1;
|
|
1531
|
-
for (let e of
|
|
1532
|
-
for (let e of
|
|
1538
|
+
for (let e of It) i[e] = n[e] || [];
|
|
1539
|
+
for (let e of Lt) i[e] = n[e] || {};
|
|
1533
1540
|
i.connections = n.connections || [];
|
|
1534
|
-
let a =
|
|
1541
|
+
let a = zt(i);
|
|
1535
1542
|
try {
|
|
1536
1543
|
await e.insert(I).values({
|
|
1537
1544
|
...a,
|
|
@@ -1540,37 +1547,37 @@ function zt(e) {
|
|
|
1540
1547
|
} catch (e) {
|
|
1541
1548
|
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new Le(409, { message: "Client already exists" }) : e;
|
|
1542
1549
|
}
|
|
1543
|
-
return
|
|
1550
|
+
return Rt({
|
|
1544
1551
|
...a,
|
|
1545
1552
|
tenant_id: t
|
|
1546
1553
|
});
|
|
1547
1554
|
},
|
|
1548
1555
|
async get(n, r) {
|
|
1549
1556
|
let i = await e.select().from(I).where(t(a(I.tenant_id, n), a(I.client_id, r))).get();
|
|
1550
|
-
return i ?
|
|
1557
|
+
return i ? Rt(i) : null;
|
|
1551
1558
|
},
|
|
1552
1559
|
async getByClientId(t) {
|
|
1553
1560
|
let n = await e.select().from(I).where(a(I.client_id, t)).get();
|
|
1554
1561
|
return n ? {
|
|
1555
|
-
...
|
|
1562
|
+
...Rt(n),
|
|
1556
1563
|
tenant_id: n.tenant_id
|
|
1557
1564
|
} : null;
|
|
1558
1565
|
},
|
|
1559
1566
|
async update(n, r, i) {
|
|
1560
|
-
let o =
|
|
1567
|
+
let o = zt({
|
|
1561
1568
|
...i,
|
|
1562
1569
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
1563
1570
|
});
|
|
1564
1571
|
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;
|
|
1565
1572
|
},
|
|
1566
1573
|
async list(o, s) {
|
|
1567
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
1568
|
-
if (
|
|
1574
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? vt(I, f, ["name", "client_id"]) : void 0, m = p ? t(a(I.tenant_id, o), p) : a(I.tenant_id, o);
|
|
1575
|
+
if (At(s)) {
|
|
1569
1576
|
let n = {
|
|
1570
1577
|
sortColumn: I.created_at,
|
|
1571
1578
|
idColumn: I.client_id,
|
|
1572
1579
|
sortOrder: "desc"
|
|
1573
|
-
}, r =
|
|
1580
|
+
}, r = Nt(s, n), i = jt(s), { rows: a, next: o } = Pt(await e.select().from(I).where(r ? t(m, r) : m).orderBy(...Mt(n)).limit(i + 1), i, "created_at", "client_id"), c = a.map(Rt);
|
|
1574
1581
|
return {
|
|
1575
1582
|
clients: c,
|
|
1576
1583
|
totals: {
|
|
@@ -1586,7 +1593,7 @@ function zt(e) {
|
|
|
1586
1593
|
let e = I[d.sort_by];
|
|
1587
1594
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
1588
1595
|
}
|
|
1589
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
1596
|
+
let g = (await h.offset(c * l).limit(l)).map(Rt);
|
|
1590
1597
|
if (!u) return { clients: g };
|
|
1591
1598
|
let [_] = await e.select({ count: r() }).from(I).where(m);
|
|
1592
1599
|
return {
|
|
@@ -1606,7 +1613,7 @@ function zt(e) {
|
|
|
1606
1613
|
}
|
|
1607
1614
|
//#endregion
|
|
1608
1615
|
//#region src/adapters/clientConnections.ts
|
|
1609
|
-
function
|
|
1616
|
+
function Vt(e) {
|
|
1610
1617
|
let { tenant_id: t, is_system: n, options: r, metadata: i, ...a } = e;
|
|
1611
1618
|
return D({
|
|
1612
1619
|
...a,
|
|
@@ -1615,14 +1622,14 @@ function Bt(e) {
|
|
|
1615
1622
|
is_system: n ? !0 : void 0
|
|
1616
1623
|
});
|
|
1617
1624
|
}
|
|
1618
|
-
function
|
|
1625
|
+
function Ht(e) {
|
|
1619
1626
|
return {
|
|
1620
1627
|
async listByClient(n, r) {
|
|
1621
1628
|
let i = await e.select({ connections: I.connections }).from(I).where(t(a(I.tenant_id, n), a(I.client_id, r))).get();
|
|
1622
1629
|
if (!i) return [];
|
|
1623
1630
|
let o = Z(i.connections, []) || [];
|
|
1624
1631
|
if (o.length === 0) return [];
|
|
1625
|
-
let s = (await e.select().from(B).where(t(a(B.tenant_id, n), l(B.id, o))).all()).map(
|
|
1632
|
+
let s = (await e.select().from(B).where(t(a(B.tenant_id, n), l(B.id, o))).all()).map(Vt);
|
|
1626
1633
|
return o.map((e) => s.find((t) => t.id === e)).filter(Boolean);
|
|
1627
1634
|
},
|
|
1628
1635
|
async updateByClient(n, r, i) {
|
|
@@ -1659,7 +1666,7 @@ function Vt(e) {
|
|
|
1659
1666
|
}
|
|
1660
1667
|
//#endregion
|
|
1661
1668
|
//#region src/adapters/clientGrants.ts
|
|
1662
|
-
function
|
|
1669
|
+
function Ut(e) {
|
|
1663
1670
|
let { tenant_id: t, scope: n, authorization_details_types: r, allow_any_organization: i, is_system: a, ...o } = e;
|
|
1664
1671
|
return D({
|
|
1665
1672
|
...o,
|
|
@@ -1669,7 +1676,7 @@ function Ht(e) {
|
|
|
1669
1676
|
is_system: !!a
|
|
1670
1677
|
});
|
|
1671
1678
|
}
|
|
1672
|
-
function
|
|
1679
|
+
function Wt(e) {
|
|
1673
1680
|
return {
|
|
1674
1681
|
async create(t, n) {
|
|
1675
1682
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -1686,14 +1693,14 @@ function Ut(e) {
|
|
|
1686
1693
|
created_at: r,
|
|
1687
1694
|
updated_at: r
|
|
1688
1695
|
};
|
|
1689
|
-
return await e.insert(R).values(i),
|
|
1696
|
+
return await e.insert(R).values(i), Ut({
|
|
1690
1697
|
...i,
|
|
1691
1698
|
tenant_id: t
|
|
1692
1699
|
});
|
|
1693
1700
|
},
|
|
1694
1701
|
async get(n, r) {
|
|
1695
1702
|
let i = await e.select().from(R).where(t(a(R.tenant_id, n), a(R.id, r))).get();
|
|
1696
|
-
return i ?
|
|
1703
|
+
return i ? Ut(i) : null;
|
|
1697
1704
|
},
|
|
1698
1705
|
async update(n, r, i) {
|
|
1699
1706
|
let { scope: o, authorization_details_types: s, allow_any_organization: c, is_system: l, ...u } = i, d = {
|
|
@@ -1703,13 +1710,13 @@ function Ut(e) {
|
|
|
1703
1710
|
return o !== void 0 && (d.scope = JSON.stringify(o)), s !== void 0 && (d.authorization_details_types = JSON.stringify(s)), c !== void 0 && (d.allow_any_organization = +!!c), l !== void 0 && (d.is_system = +!!l), (await e.update(R).set(d).where(t(a(R.tenant_id, n), a(R.id, r))).returning()).length > 0;
|
|
1704
1711
|
},
|
|
1705
1712
|
async list(o, s) {
|
|
1706
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
1707
|
-
if (
|
|
1713
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? vt(R, f, ["client_id", "audience"]) : void 0, m = p ? t(a(R.tenant_id, o), p) : a(R.tenant_id, o);
|
|
1714
|
+
if (At(s)) {
|
|
1708
1715
|
let n = {
|
|
1709
1716
|
sortColumn: R.created_at,
|
|
1710
1717
|
idColumn: R.id,
|
|
1711
1718
|
sortOrder: "desc"
|
|
1712
|
-
}, r =
|
|
1719
|
+
}, r = Nt(s, n), i = jt(s), { rows: a, next: o } = Pt(await e.select().from(R).where(r ? t(m, r) : m).orderBy(...Mt(n)).limit(i + 1), i, "created_at"), c = a.map(Ut);
|
|
1713
1720
|
return {
|
|
1714
1721
|
client_grants: c,
|
|
1715
1722
|
start: 0,
|
|
@@ -1723,7 +1730,7 @@ function Ut(e) {
|
|
|
1723
1730
|
let e = R[d.sort_by];
|
|
1724
1731
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
1725
1732
|
} else h = h.orderBy(i(R.created_at), i(R.id));
|
|
1726
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
1733
|
+
let g = (await h.offset(c * l).limit(l)).map(Ut);
|
|
1727
1734
|
if (!u) return { client_grants: g };
|
|
1728
1735
|
let [_] = await e.select({ count: r() }).from(R).where(m);
|
|
1729
1736
|
return {
|
|
@@ -1740,20 +1747,20 @@ function Ut(e) {
|
|
|
1740
1747
|
}
|
|
1741
1748
|
//#endregion
|
|
1742
1749
|
//#region src/adapters/clientRegistrationTokens.ts
|
|
1743
|
-
function
|
|
1750
|
+
function Gt(e) {
|
|
1744
1751
|
if (!e) return;
|
|
1745
1752
|
let t = JSON.parse(e);
|
|
1746
1753
|
return be(t) ? t : void 0;
|
|
1747
1754
|
}
|
|
1748
|
-
function
|
|
1755
|
+
function Kt(e) {
|
|
1749
1756
|
return e == null ? void 0 : new Date(e).toISOString();
|
|
1750
1757
|
}
|
|
1751
|
-
function
|
|
1758
|
+
function qt(e) {
|
|
1752
1759
|
if (!e) return null;
|
|
1753
1760
|
let t = new Date(e);
|
|
1754
1761
|
return isNaN(t.getTime()) ? null : t.getTime();
|
|
1755
1762
|
}
|
|
1756
|
-
function
|
|
1763
|
+
function Jt(e) {
|
|
1757
1764
|
let t = he.parse(e.type);
|
|
1758
1765
|
return {
|
|
1759
1766
|
id: e.id,
|
|
@@ -1761,15 +1768,15 @@ function qt(e) {
|
|
|
1761
1768
|
type: t,
|
|
1762
1769
|
client_id: e.client_id ?? void 0,
|
|
1763
1770
|
sub: e.sub ?? void 0,
|
|
1764
|
-
constraints:
|
|
1771
|
+
constraints: Gt(e.constraints),
|
|
1765
1772
|
single_use: !!e.single_use,
|
|
1766
|
-
expires_at:
|
|
1767
|
-
used_at:
|
|
1768
|
-
revoked_at:
|
|
1773
|
+
expires_at: Kt(e.expires_at_ts),
|
|
1774
|
+
used_at: Kt(e.used_at_ts),
|
|
1775
|
+
revoked_at: Kt(e.revoked_at_ts),
|
|
1769
1776
|
created_at: new Date(e.created_at_ts).toISOString()
|
|
1770
1777
|
};
|
|
1771
1778
|
}
|
|
1772
|
-
function
|
|
1779
|
+
function Yt(e) {
|
|
1773
1780
|
return {
|
|
1774
1781
|
async create(t, n) {
|
|
1775
1782
|
let r = Date.now();
|
|
@@ -1782,7 +1789,7 @@ function Jt(e) {
|
|
|
1782
1789
|
sub: n.sub ?? null,
|
|
1783
1790
|
constraints: n.constraints ? JSON.stringify(n.constraints) : null,
|
|
1784
1791
|
single_use: +!!n.single_use,
|
|
1785
|
-
expires_at_ts:
|
|
1792
|
+
expires_at_ts: qt(n.expires_at),
|
|
1786
1793
|
created_at_ts: r
|
|
1787
1794
|
}), {
|
|
1788
1795
|
id: n.id,
|
|
@@ -1798,23 +1805,23 @@ function Jt(e) {
|
|
|
1798
1805
|
},
|
|
1799
1806
|
async get(n, r) {
|
|
1800
1807
|
let i = await e.select().from(L).where(t(a(L.tenant_id, n), a(L.id, r))).get();
|
|
1801
|
-
return i ?
|
|
1808
|
+
return i ? Jt(i) : null;
|
|
1802
1809
|
},
|
|
1803
1810
|
async getByHash(n, r) {
|
|
1804
1811
|
let i = await e.select().from(L).where(t(a(L.tenant_id, n), a(L.token_hash, r))).get();
|
|
1805
|
-
return i ?
|
|
1812
|
+
return i ? Jt(i) : null;
|
|
1806
1813
|
},
|
|
1807
1814
|
async listByClient(n, r) {
|
|
1808
|
-
return (await e.select().from(L).where(t(a(L.tenant_id, n), a(L.client_id, r))).orderBy(i(L.created_at_ts))).map(
|
|
1815
|
+
return (await e.select().from(L).where(t(a(L.tenant_id, n), a(L.client_id, r))).orderBy(i(L.created_at_ts))).map(Jt);
|
|
1809
1816
|
},
|
|
1810
1817
|
async markUsed(n, r, i) {
|
|
1811
|
-
return (await e.update(L).set({ used_at_ts:
|
|
1818
|
+
return (await e.update(L).set({ used_at_ts: qt(i) }).where(t(a(L.tenant_id, n), a(L.id, r), f(L.used_at_ts))).returning()).length > 0;
|
|
1812
1819
|
},
|
|
1813
1820
|
async revoke(n, r, i) {
|
|
1814
|
-
return (await e.update(L).set({ revoked_at_ts:
|
|
1821
|
+
return (await e.update(L).set({ revoked_at_ts: qt(i) }).where(t(a(L.tenant_id, n), a(L.id, r), f(L.revoked_at_ts))).returning()).length > 0;
|
|
1815
1822
|
},
|
|
1816
1823
|
async revokeByClient(n, r, i) {
|
|
1817
|
-
return (await e.update(L).set({ revoked_at_ts:
|
|
1824
|
+
return (await e.update(L).set({ revoked_at_ts: qt(i) }).where(t(a(L.tenant_id, n), a(L.client_id, r), f(L.revoked_at_ts))).returning()).length;
|
|
1818
1825
|
},
|
|
1819
1826
|
async remove(n, r) {
|
|
1820
1827
|
return (await e.delete(L).where(t(a(L.tenant_id, n), a(L.id, r))).returning()).length > 0;
|
|
@@ -1823,12 +1830,12 @@ function Jt(e) {
|
|
|
1823
1830
|
}
|
|
1824
1831
|
//#endregion
|
|
1825
1832
|
//#region src/adapters/codes.ts
|
|
1826
|
-
var
|
|
1827
|
-
function
|
|
1833
|
+
var Xt = ["code_id", "login_id"], Zt = 500;
|
|
1834
|
+
function Qt(e) {
|
|
1828
1835
|
let { tenant_id: t, ...n } = e;
|
|
1829
1836
|
return D(n);
|
|
1830
1837
|
}
|
|
1831
|
-
function
|
|
1838
|
+
function $t(e) {
|
|
1832
1839
|
return {
|
|
1833
1840
|
async create(t, n) {
|
|
1834
1841
|
let r = {
|
|
@@ -1837,18 +1844,18 @@ function Qt(e) {
|
|
|
1837
1844
|
created_at: n.created_at || (/* @__PURE__ */ new Date()).toISOString(),
|
|
1838
1845
|
expires_at: n.expires_at
|
|
1839
1846
|
};
|
|
1840
|
-
return await e.insert(F).values(r),
|
|
1847
|
+
return await e.insert(F).values(r), Qt(r);
|
|
1841
1848
|
},
|
|
1842
1849
|
async get(n, r, i) {
|
|
1843
1850
|
let o = n ? t(a(F.tenant_id, n), a(F.code_id, r), a(F.code_type, i)) : t(a(F.code_id, r), a(F.code_type, i)), s = await e.select().from(F).where(o).get();
|
|
1844
|
-
return s ?
|
|
1851
|
+
return s ? Qt(s) : null;
|
|
1845
1852
|
},
|
|
1846
1853
|
async list(o, s) {
|
|
1847
1854
|
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(F.tenant_id, o)];
|
|
1848
1855
|
if (f) {
|
|
1849
|
-
let e = Te(f,
|
|
1856
|
+
let e = Te(f, Xt);
|
|
1850
1857
|
if (e) {
|
|
1851
|
-
let t =
|
|
1858
|
+
let t = vt(F, e, Xt);
|
|
1852
1859
|
t && p.push(t);
|
|
1853
1860
|
}
|
|
1854
1861
|
}
|
|
@@ -1857,7 +1864,7 @@ function Qt(e) {
|
|
|
1857
1864
|
let e = F[d.sort_by];
|
|
1858
1865
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
1859
1866
|
}
|
|
1860
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
1867
|
+
let g = (await h.offset(c * l).limit(l)).map(Qt);
|
|
1861
1868
|
if (!u) return { codes: g };
|
|
1862
1869
|
let [_] = await e.select({ count: r() }).from(F).where(m);
|
|
1863
1870
|
return {
|
|
@@ -1879,8 +1886,8 @@ function Qt(e) {
|
|
|
1879
1886
|
async cleanup(t) {
|
|
1880
1887
|
let n = 0;
|
|
1881
1888
|
for (;;) {
|
|
1882
|
-
let r = await e.delete(F).where(y`rowid IN (SELECT rowid FROM ${F} WHERE ${F.expires_at} < ${t} LIMIT ${
|
|
1883
|
-
if (n += r.length, r.length <
|
|
1889
|
+
let r = await e.delete(F).where(y`rowid IN (SELECT rowid FROM ${F} WHERE ${F.expires_at} < ${t} LIMIT ${Zt})`).returning({ code_id: F.code_id });
|
|
1890
|
+
if (n += r.length, r.length < Zt) break;
|
|
1884
1891
|
}
|
|
1885
1892
|
return n;
|
|
1886
1893
|
}
|
|
@@ -1888,10 +1895,10 @@ function Qt(e) {
|
|
|
1888
1895
|
}
|
|
1889
1896
|
//#endregion
|
|
1890
1897
|
//#region src/adapters/connections.ts
|
|
1891
|
-
function
|
|
1898
|
+
function en() {
|
|
1892
1899
|
return `con_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
1893
1900
|
}
|
|
1894
|
-
function
|
|
1901
|
+
function tn(e) {
|
|
1895
1902
|
let { tenant_id: t, is_system: n, options: r, metadata: i, ...a } = e;
|
|
1896
1903
|
return D({
|
|
1897
1904
|
...a,
|
|
@@ -1900,11 +1907,11 @@ function en(e) {
|
|
|
1900
1907
|
is_system: n ? !0 : void 0
|
|
1901
1908
|
});
|
|
1902
1909
|
}
|
|
1903
|
-
function
|
|
1910
|
+
function nn(e) {
|
|
1904
1911
|
return {
|
|
1905
1912
|
async create(t, n) {
|
|
1906
1913
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
1907
|
-
id: n.id ||
|
|
1914
|
+
id: n.id || en(),
|
|
1908
1915
|
...n,
|
|
1909
1916
|
tenant_id: t,
|
|
1910
1917
|
options: JSON.stringify(n.options || {}),
|
|
@@ -1918,11 +1925,11 @@ function tn(e) {
|
|
|
1918
1925
|
} catch (e) {
|
|
1919
1926
|
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new Le(409, { message: "Connection already exists" }) : e;
|
|
1920
1927
|
}
|
|
1921
|
-
return
|
|
1928
|
+
return tn(i);
|
|
1922
1929
|
},
|
|
1923
1930
|
async get(n, r) {
|
|
1924
1931
|
let i = await e.select().from(B).where(t(a(B.tenant_id, n), a(B.id, r))).get();
|
|
1925
|
-
return i ?
|
|
1932
|
+
return i ? tn(i) : null;
|
|
1926
1933
|
},
|
|
1927
1934
|
async update(n, r, i) {
|
|
1928
1935
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -1931,15 +1938,15 @@ function tn(e) {
|
|
|
1931
1938
|
async list(o, s) {
|
|
1932
1939
|
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = a(B.tenant_id, o);
|
|
1933
1940
|
if (f) {
|
|
1934
|
-
let e =
|
|
1941
|
+
let e = vt(B, f, ["name"]);
|
|
1935
1942
|
e && (p = t(p, e));
|
|
1936
1943
|
}
|
|
1937
|
-
if (
|
|
1944
|
+
if (At(s)) {
|
|
1938
1945
|
let n = {
|
|
1939
1946
|
sortColumn: B.created_at,
|
|
1940
1947
|
idColumn: B.id,
|
|
1941
1948
|
sortOrder: "desc"
|
|
1942
|
-
}, r =
|
|
1949
|
+
}, r = Nt(s, n), i = jt(s), { rows: a, next: o } = Pt(await e.select().from(B).where(r ? t(p, r) : p).orderBy(...Mt(n)).limit(i + 1), i, "created_at", "id"), c = a.map(tn);
|
|
1943
1950
|
return {
|
|
1944
1951
|
connections: c,
|
|
1945
1952
|
start: 0,
|
|
@@ -1953,7 +1960,7 @@ function tn(e) {
|
|
|
1953
1960
|
let e = B[d.sort_by];
|
|
1954
1961
|
e && (m = m.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
1955
1962
|
}
|
|
1956
|
-
let h = (await m.offset(c * l).limit(l)).map(
|
|
1963
|
+
let h = (await m.offset(c * l).limit(l)).map(tn);
|
|
1957
1964
|
if (!u) return { connections: h };
|
|
1958
1965
|
let [g] = await e.select({ count: r() }).from(B).where(p);
|
|
1959
1966
|
return {
|
|
@@ -1970,7 +1977,7 @@ function tn(e) {
|
|
|
1970
1977
|
}
|
|
1971
1978
|
//#endregion
|
|
1972
1979
|
//#region src/adapters/customDomains.ts
|
|
1973
|
-
function
|
|
1980
|
+
function rn(e) {
|
|
1974
1981
|
let { tenant_id: t, domain_metadata: n, verification: r, ...i } = e;
|
|
1975
1982
|
return D({
|
|
1976
1983
|
...i,
|
|
@@ -1979,7 +1986,7 @@ function nn(e) {
|
|
|
1979
1986
|
verification: Z(r)
|
|
1980
1987
|
});
|
|
1981
1988
|
}
|
|
1982
|
-
function
|
|
1989
|
+
function an(e) {
|
|
1983
1990
|
return {
|
|
1984
1991
|
async create(t, n) {
|
|
1985
1992
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -1997,37 +2004,37 @@ function rn(e) {
|
|
|
1997
2004
|
created_at: r,
|
|
1998
2005
|
updated_at: r
|
|
1999
2006
|
};
|
|
2000
|
-
return await e.insert(
|
|
2007
|
+
return await e.insert(Ke).values(i), rn({
|
|
2001
2008
|
...i,
|
|
2002
2009
|
tenant_id: t
|
|
2003
2010
|
});
|
|
2004
2011
|
},
|
|
2005
2012
|
async get(n, r) {
|
|
2006
|
-
let i = await e.select().from(
|
|
2007
|
-
return i ?
|
|
2013
|
+
let i = await e.select().from(Ke).where(t(a(Ke.tenant_id, n), a(Ke.custom_domain_id, r))).get();
|
|
2014
|
+
return i ? rn(i) : null;
|
|
2008
2015
|
},
|
|
2009
2016
|
async getByDomain(t) {
|
|
2010
|
-
let n = await e.select().from(
|
|
2017
|
+
let n = await e.select().from(Ke).where(a(Ke.domain, t)).get();
|
|
2011
2018
|
return n ? {
|
|
2012
|
-
...
|
|
2019
|
+
...rn(n),
|
|
2013
2020
|
tenant_id: n.tenant_id
|
|
2014
2021
|
} : null;
|
|
2015
2022
|
},
|
|
2016
2023
|
async list(t) {
|
|
2017
|
-
return (await e.select().from(
|
|
2024
|
+
return (await e.select().from(Ke).where(a(Ke.tenant_id, t)).all()).map(rn);
|
|
2018
2025
|
},
|
|
2019
2026
|
async update(n, r, i) {
|
|
2020
2027
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2021
|
-
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(
|
|
2028
|
+
return i.domain !== void 0 && (o.domain = i.domain), i.primary !== void 0 && (o.primary = i.primary), i.status !== void 0 && (o.status = i.status), i.type !== void 0 && (o.type = i.type), i.origin_domain_name !== void 0 && (o.origin_domain_name = i.origin_domain_name), i.verification !== void 0 && (o.verification = JSON.stringify(i.verification)), i.custom_client_ip_header !== void 0 && (o.custom_client_ip_header = i.custom_client_ip_header), i.tls_policy !== void 0 && (o.tls_policy = i.tls_policy), i.domain_metadata !== void 0 && (o.domain_metadata = JSON.stringify(i.domain_metadata)), (await e.update(Ke).set(o).where(t(a(Ke.tenant_id, n), a(Ke.custom_domain_id, r))).returning()).length > 0;
|
|
2022
2029
|
},
|
|
2023
2030
|
async remove(n, r) {
|
|
2024
|
-
return (await e.delete(
|
|
2031
|
+
return (await e.delete(Ke).where(t(a(Ke.tenant_id, n), a(Ke.custom_domain_id, r))).returning()).length > 0;
|
|
2025
2032
|
}
|
|
2026
2033
|
};
|
|
2027
2034
|
}
|
|
2028
2035
|
//#endregion
|
|
2029
2036
|
//#region src/adapters/customText.ts
|
|
2030
|
-
function
|
|
2037
|
+
function on(e) {
|
|
2031
2038
|
return {
|
|
2032
2039
|
async get(n, r, i) {
|
|
2033
2040
|
let o = await e.select().from(st).where(t(a(st.tenant_id, n), a(st.prompt, r), a(st.language, i))).get();
|
|
@@ -2072,7 +2079,7 @@ function an(e) {
|
|
|
2072
2079
|
}
|
|
2073
2080
|
//#endregion
|
|
2074
2081
|
//#region src/adapters/emailProviders.ts
|
|
2075
|
-
function
|
|
2082
|
+
function sn(e) {
|
|
2076
2083
|
return {
|
|
2077
2084
|
async create(t, n) {
|
|
2078
2085
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -2109,7 +2116,7 @@ function on(e) {
|
|
|
2109
2116
|
}
|
|
2110
2117
|
//#endregion
|
|
2111
2118
|
//#region src/adapters/emailTemplates.ts
|
|
2112
|
-
function
|
|
2119
|
+
function cn(e) {
|
|
2113
2120
|
return D({
|
|
2114
2121
|
template: e.template,
|
|
2115
2122
|
body: e.body,
|
|
@@ -2122,14 +2129,14 @@ function sn(e) {
|
|
|
2122
2129
|
urlLifetimeInSeconds: e.url_lifetime_in_seconds ?? void 0
|
|
2123
2130
|
});
|
|
2124
2131
|
}
|
|
2125
|
-
function
|
|
2132
|
+
function ln(e) {
|
|
2126
2133
|
return {
|
|
2127
2134
|
async get(n, r) {
|
|
2128
2135
|
let i = await e.select().from(rt).where(t(a(rt.tenant_id, n), a(rt.template, r))).get();
|
|
2129
|
-
return i ?
|
|
2136
|
+
return i ? cn(i) : null;
|
|
2130
2137
|
},
|
|
2131
2138
|
async list(t) {
|
|
2132
|
-
return (await e.select().from(rt).where(a(rt.tenant_id, t)).all()).map(
|
|
2139
|
+
return (await e.select().from(rt).where(a(rt.tenant_id, t)).all()).map(cn);
|
|
2133
2140
|
},
|
|
2134
2141
|
async create(t, n) {
|
|
2135
2142
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -2162,8 +2169,8 @@ function cn(e) {
|
|
|
2162
2169
|
}
|
|
2163
2170
|
//#endregion
|
|
2164
2171
|
//#region src/adapters/flows.ts
|
|
2165
|
-
var
|
|
2166
|
-
function
|
|
2172
|
+
var un = ["id", "name"];
|
|
2173
|
+
function dn(e) {
|
|
2167
2174
|
return {
|
|
2168
2175
|
async create(t, n) {
|
|
2169
2176
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = `af_${b()}`;
|
|
@@ -2198,9 +2205,9 @@ function un(e) {
|
|
|
2198
2205
|
async list(o, s) {
|
|
2199
2206
|
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(et.tenant_id, o)];
|
|
2200
2207
|
if (f) {
|
|
2201
|
-
let e = Te(f,
|
|
2208
|
+
let e = Te(f, un);
|
|
2202
2209
|
if (e) {
|
|
2203
|
-
let t =
|
|
2210
|
+
let t = vt(et, e, []);
|
|
2204
2211
|
t && p.push(t);
|
|
2205
2212
|
}
|
|
2206
2213
|
}
|
|
@@ -2232,12 +2239,12 @@ function un(e) {
|
|
|
2232
2239
|
}
|
|
2233
2240
|
//#endregion
|
|
2234
2241
|
//#region src/adapters/forms.ts
|
|
2235
|
-
var
|
|
2242
|
+
var fn = [
|
|
2236
2243
|
"nodes",
|
|
2237
2244
|
"start",
|
|
2238
2245
|
"ending"
|
|
2239
|
-
],
|
|
2240
|
-
function
|
|
2246
|
+
], pn = ["name"];
|
|
2247
|
+
function mn(e) {
|
|
2241
2248
|
return {
|
|
2242
2249
|
async create(t, n) {
|
|
2243
2250
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = b(), a = {
|
|
@@ -2251,7 +2258,7 @@ function pn(e) {
|
|
|
2251
2258
|
created_at: r,
|
|
2252
2259
|
updated_at: r
|
|
2253
2260
|
};
|
|
2254
|
-
for (let e of
|
|
2261
|
+
for (let e of fn) a[e] = JSON.stringify(n[e] || (e === "nodes" ? [] : {}));
|
|
2255
2262
|
return await e.insert($e).values(a), {
|
|
2256
2263
|
id: i,
|
|
2257
2264
|
...n,
|
|
@@ -2263,20 +2270,20 @@ function pn(e) {
|
|
|
2263
2270
|
let i = await e.select().from($e).where(t(a($e.tenant_id, n), a($e.id, r))).get();
|
|
2264
2271
|
if (!i) return null;
|
|
2265
2272
|
let { tenant_id: o, ...s } = i, c = { ...s };
|
|
2266
|
-
for (let e of
|
|
2273
|
+
for (let e of fn) c[e] = Z(s[e]);
|
|
2267
2274
|
return D(c);
|
|
2268
2275
|
},
|
|
2269
2276
|
async update(n, r, i) {
|
|
2270
2277
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2271
|
-
for (let [e, t] of Object.entries(i)) t !== void 0 && (
|
|
2278
|
+
for (let [e, t] of Object.entries(i)) t !== void 0 && (fn.includes(e) ? o[e] = JSON.stringify(t) : o[e] = t);
|
|
2272
2279
|
return (await e.update($e).set(o).where(t(a($e.tenant_id, n), a($e.id, r))).returning()).length > 0;
|
|
2273
2280
|
},
|
|
2274
2281
|
async list(o, s) {
|
|
2275
2282
|
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a($e.tenant_id, o)];
|
|
2276
2283
|
if (f) {
|
|
2277
|
-
let e = Te(f,
|
|
2284
|
+
let e = Te(f, pn);
|
|
2278
2285
|
if (e) {
|
|
2279
|
-
let t =
|
|
2286
|
+
let t = vt($e, e, pn);
|
|
2280
2287
|
t && p.push(t);
|
|
2281
2288
|
}
|
|
2282
2289
|
}
|
|
@@ -2287,7 +2294,7 @@ function pn(e) {
|
|
|
2287
2294
|
}
|
|
2288
2295
|
let g = (await h.offset(c * l).limit(l)).map((e) => {
|
|
2289
2296
|
let { tenant_id: t, ...n } = e, r = { ...n };
|
|
2290
|
-
for (let e of
|
|
2297
|
+
for (let e of fn) r[e] = Z(n[e]);
|
|
2291
2298
|
return D(r);
|
|
2292
2299
|
});
|
|
2293
2300
|
if (!u) return { forms: g };
|
|
@@ -2306,7 +2313,7 @@ function pn(e) {
|
|
|
2306
2313
|
}
|
|
2307
2314
|
//#endregion
|
|
2308
2315
|
//#region src/adapters/grants.ts
|
|
2309
|
-
function
|
|
2316
|
+
function hn(e) {
|
|
2310
2317
|
return {
|
|
2311
2318
|
id: e.id,
|
|
2312
2319
|
user_id: e.user_id,
|
|
@@ -2315,17 +2322,17 @@ function mn(e) {
|
|
|
2315
2322
|
scope: Z(e.scope, []) ?? []
|
|
2316
2323
|
};
|
|
2317
2324
|
}
|
|
2318
|
-
var
|
|
2325
|
+
var gn = {
|
|
2319
2326
|
user_id: z.user_id,
|
|
2320
2327
|
client_id: z.client_id,
|
|
2321
2328
|
audience: z.audience,
|
|
2322
2329
|
created_at: z.created_at,
|
|
2323
2330
|
updated_at: z.updated_at
|
|
2324
2331
|
};
|
|
2325
|
-
function gn(e) {
|
|
2326
|
-
return Object.hasOwn(hn, e) ? hn[e] : void 0;
|
|
2327
|
-
}
|
|
2328
2332
|
function _n(e) {
|
|
2333
|
+
return Object.hasOwn(gn, e) ? gn[e] : void 0;
|
|
2334
|
+
}
|
|
2335
|
+
function vn(e) {
|
|
2329
2336
|
return {
|
|
2330
2337
|
async create(n, r) {
|
|
2331
2338
|
let i = (/* @__PURE__ */ new Date()).toISOString(), o = r.scope ?? [], s = r.audience ?? "", c = await e.select().from(z).where(t(a(z.tenant_id, n), a(z.user_id, r.user_id), a(z.client_id, r.clientID), a(z.audience, s))).get();
|
|
@@ -2334,7 +2341,7 @@ function _n(e) {
|
|
|
2334
2341
|
return await e.update(z).set({
|
|
2335
2342
|
scope: JSON.stringify(s),
|
|
2336
2343
|
updated_at: i
|
|
2337
|
-
}).where(t(a(z.tenant_id, n), a(z.id, c.id))),
|
|
2344
|
+
}).where(t(a(z.tenant_id, n), a(z.id, c.id))), hn({
|
|
2338
2345
|
...c,
|
|
2339
2346
|
scope: JSON.stringify(s)
|
|
2340
2347
|
});
|
|
@@ -2359,16 +2366,16 @@ function _n(e) {
|
|
|
2359
2366
|
},
|
|
2360
2367
|
async get(n, r, i, o) {
|
|
2361
2368
|
let s = await e.select().from(z).where(t(a(z.tenant_id, n), a(z.user_id, r), a(z.client_id, i), a(z.audience, o ?? ""))).get();
|
|
2362
|
-
return s ?
|
|
2369
|
+
return s ? hn(s) : null;
|
|
2363
2370
|
},
|
|
2364
2371
|
async list(o, s) {
|
|
2365
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
2372
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? vt(z, f, [
|
|
2366
2373
|
"user_id",
|
|
2367
2374
|
"client_id",
|
|
2368
2375
|
"audience"
|
|
2369
|
-
]) : void 0, m = p ? t(a(z.tenant_id, o), p) : a(z.tenant_id, o), h = e.select().from(z).where(m).$dynamic(), g = d?.sort_by ?
|
|
2376
|
+
]) : void 0, m = p ? t(a(z.tenant_id, o), p) : a(z.tenant_id, o), h = e.select().from(z).where(m).$dynamic(), g = d?.sort_by ? _n(d.sort_by) : void 0;
|
|
2370
2377
|
h = g ? h.orderBy(d?.sort_order === "desc" ? i(g) : n(g)) : h.orderBy(n(z.created_at));
|
|
2371
|
-
let _ = (await h.offset(c * l).limit(l)).map(
|
|
2378
|
+
let _ = (await h.offset(c * l).limit(l)).map(hn);
|
|
2372
2379
|
if (!u) return {
|
|
2373
2380
|
grants: _,
|
|
2374
2381
|
start: 0,
|
|
@@ -2393,11 +2400,11 @@ function _n(e) {
|
|
|
2393
2400
|
}
|
|
2394
2401
|
//#endregion
|
|
2395
2402
|
//#region src/adapters/hookCode.ts
|
|
2396
|
-
var
|
|
2397
|
-
function
|
|
2398
|
-
return `hc_${
|
|
2403
|
+
var yn = ee("0123456789abcdefghijklmnopqrstuvwxyz", 17);
|
|
2404
|
+
function bn() {
|
|
2405
|
+
return `hc_${yn()}`;
|
|
2399
2406
|
}
|
|
2400
|
-
function
|
|
2407
|
+
function xn(e) {
|
|
2401
2408
|
let { created_at_ts: t, updated_at_ts: n, secrets: r, ...i } = e, a = ae({
|
|
2402
2409
|
created_at_ts: t,
|
|
2403
2410
|
updated_at_ts: n
|
|
@@ -2408,25 +2415,25 @@ function bn(e) {
|
|
|
2408
2415
|
secrets: r ? JSON.parse(r) : void 0
|
|
2409
2416
|
};
|
|
2410
2417
|
}
|
|
2411
|
-
function
|
|
2418
|
+
function Sn(e) {
|
|
2412
2419
|
return {
|
|
2413
2420
|
async create(t, n) {
|
|
2414
2421
|
let r = Date.now(), i = {
|
|
2415
|
-
id:
|
|
2422
|
+
id: bn(),
|
|
2416
2423
|
tenant_id: t,
|
|
2417
2424
|
code: n.code,
|
|
2418
2425
|
secrets: n.secrets ? JSON.stringify(n.secrets) : null,
|
|
2419
2426
|
created_at_ts: r,
|
|
2420
2427
|
updated_at_ts: r
|
|
2421
2428
|
};
|
|
2422
|
-
return await e.insert(at).values(i),
|
|
2429
|
+
return await e.insert(at).values(i), xn({
|
|
2423
2430
|
...i,
|
|
2424
2431
|
tenant_id: t
|
|
2425
2432
|
});
|
|
2426
2433
|
},
|
|
2427
2434
|
async get(n, r) {
|
|
2428
2435
|
let i = await e.select().from(at).where(t(a(at.tenant_id, n), a(at.id, r))).get();
|
|
2429
|
-
return i ?
|
|
2436
|
+
return i ? xn(i) : null;
|
|
2430
2437
|
},
|
|
2431
2438
|
async update(n, r, i) {
|
|
2432
2439
|
let o = { updated_at_ts: Date.now() };
|
|
@@ -2439,10 +2446,10 @@ function xn(e) {
|
|
|
2439
2446
|
}
|
|
2440
2447
|
//#endregion
|
|
2441
2448
|
//#region src/adapters/hooks.ts
|
|
2442
|
-
function
|
|
2449
|
+
function Cn() {
|
|
2443
2450
|
return `h_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
2444
2451
|
}
|
|
2445
|
-
function
|
|
2452
|
+
function wn(e) {
|
|
2446
2453
|
if (!(typeof e != "string" || !e)) try {
|
|
2447
2454
|
let t = JSON.parse(e);
|
|
2448
2455
|
return t && typeof t == "object" && !Array.isArray(t) ? t : void 0;
|
|
@@ -2450,7 +2457,7 @@ function Cn(e) {
|
|
|
2450
2457
|
return;
|
|
2451
2458
|
}
|
|
2452
2459
|
}
|
|
2453
|
-
function
|
|
2460
|
+
function Tn(e) {
|
|
2454
2461
|
let { tenant_id: t, created_at_ts: n, updated_at_ts: r, metadata: i, ...a } = e, o = ae({
|
|
2455
2462
|
created_at_ts: n,
|
|
2456
2463
|
updated_at_ts: r
|
|
@@ -2459,15 +2466,15 @@ function wn(e) {
|
|
|
2459
2466
|
...a,
|
|
2460
2467
|
enabled: !!a.enabled,
|
|
2461
2468
|
synchronous: !!a.synchronous,
|
|
2462
|
-
metadata:
|
|
2469
|
+
metadata: wn(i),
|
|
2463
2470
|
...o
|
|
2464
2471
|
});
|
|
2465
2472
|
}
|
|
2466
|
-
function
|
|
2473
|
+
function En(e) {
|
|
2467
2474
|
return {
|
|
2468
2475
|
async create(t, n) {
|
|
2469
2476
|
let r = Date.now(), i = {
|
|
2470
|
-
hook_id: n.hook_id ||
|
|
2477
|
+
hook_id: n.hook_id || Cn(),
|
|
2471
2478
|
tenant_id: t,
|
|
2472
2479
|
trigger_id: n.trigger_id,
|
|
2473
2480
|
url: n.url,
|
|
@@ -2483,28 +2490,28 @@ function Tn(e) {
|
|
|
2483
2490
|
created_at_ts: r,
|
|
2484
2491
|
updated_at_ts: r
|
|
2485
2492
|
};
|
|
2486
|
-
return await e.insert(it).values(i),
|
|
2493
|
+
return await e.insert(it).values(i), Tn({
|
|
2487
2494
|
...i,
|
|
2488
2495
|
tenant_id: t
|
|
2489
2496
|
});
|
|
2490
2497
|
},
|
|
2491
2498
|
async get(n, r) {
|
|
2492
2499
|
let i = await e.select().from(it).where(t(a(it.tenant_id, n), a(it.hook_id, r))).get();
|
|
2493
|
-
return i ?
|
|
2500
|
+
return i ? Tn(i) : null;
|
|
2494
2501
|
},
|
|
2495
2502
|
async update(n, r, i) {
|
|
2496
2503
|
let o = { updated_at_ts: Date.now() };
|
|
2497
2504
|
return i.trigger_id !== void 0 && (o.trigger_id = i.trigger_id), i.url !== void 0 && (o.url = i.url), i.enabled !== void 0 && (o.enabled = i.enabled), i.synchronous !== void 0 && (o.synchronous = i.synchronous), i.priority !== void 0 && (o.priority = i.priority), i.form_id !== void 0 && (o.form_id = i.form_id), i.template_id !== void 0 && (o.template_id = i.template_id), i.code_id !== void 0 && (o.code_id = i.code_id), i.page_id !== void 0 && (o.page_id = i.page_id), i.permission_required !== void 0 && (o.permission_required = i.permission_required), i.metadata !== void 0 && (o.metadata = i.metadata === null ? null : JSON.stringify(i.metadata)), (await e.update(it).set(o).where(t(a(it.tenant_id, n), a(it.hook_id, r))).returning()).length > 0;
|
|
2498
2505
|
},
|
|
2499
2506
|
async list(o, s) {
|
|
2500
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
2507
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? vt(it, f, [
|
|
2501
2508
|
"url",
|
|
2502
2509
|
"form_id",
|
|
2503
2510
|
"template_id",
|
|
2504
2511
|
"code_id"
|
|
2505
2512
|
]) : void 0, m = p ? t(a(it.tenant_id, o), p) : a(it.tenant_id, o), h = e.select().from(it).where(m).$dynamic(), g = d?.sort_by ? it[d.sort_by] : void 0;
|
|
2506
2513
|
h = g ? h.orderBy(d?.sort_order === "desc" ? i(g) : n(g)) : h.orderBy(i(it.priority), n(it.created_at_ts));
|
|
2507
|
-
let _ = (await h.offset(c * l).limit(l)).map(
|
|
2514
|
+
let _ = (await h.offset(c * l).limit(l)).map(Tn);
|
|
2508
2515
|
if (!u) return { hooks: _ };
|
|
2509
2516
|
let [v] = await e.select({ count: r() }).from(it).where(m);
|
|
2510
2517
|
return {
|
|
@@ -2521,25 +2528,25 @@ function Tn(e) {
|
|
|
2521
2528
|
}
|
|
2522
2529
|
//#endregion
|
|
2523
2530
|
//#region src/adapters/invites.ts
|
|
2524
|
-
function
|
|
2531
|
+
function Dn() {
|
|
2525
2532
|
return `inv_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
2526
2533
|
}
|
|
2527
|
-
var
|
|
2534
|
+
var On = [
|
|
2528
2535
|
"inviter",
|
|
2529
2536
|
"invitee",
|
|
2530
2537
|
"app_metadata",
|
|
2531
2538
|
"user_metadata",
|
|
2532
2539
|
"roles"
|
|
2533
2540
|
];
|
|
2534
|
-
function
|
|
2541
|
+
function kn(e) {
|
|
2535
2542
|
let { tenant_id: t, send_invitation_email: n, ...r } = e, i = { ...r };
|
|
2536
|
-
for (let e of
|
|
2543
|
+
for (let e of On) i[e] = Z(r[e], e === "roles" ? [] : {});
|
|
2537
2544
|
return i.send_invitation_email = !!n, D(i);
|
|
2538
2545
|
}
|
|
2539
|
-
function
|
|
2546
|
+
function An(e) {
|
|
2540
2547
|
return {
|
|
2541
2548
|
async create(t, n) {
|
|
2542
|
-
let r = n.id ||
|
|
2549
|
+
let r = n.id || Dn(), i = n.ttl_sec || 604800, a = /* @__PURE__ */ new Date(), o = new Date(a.getTime() + i * 1e3).toISOString(), s = {
|
|
2543
2550
|
id: r,
|
|
2544
2551
|
tenant_id: t,
|
|
2545
2552
|
organization_id: n.organization_id,
|
|
@@ -2552,35 +2559,35 @@ function kn(e) {
|
|
|
2552
2559
|
created_at: a.toISOString(),
|
|
2553
2560
|
expires_at: o
|
|
2554
2561
|
};
|
|
2555
|
-
for (let e of
|
|
2562
|
+
for (let e of On) n[e] !== void 0 && (s[e] = JSON.stringify(n[e]));
|
|
2556
2563
|
try {
|
|
2557
|
-
await e.insert(
|
|
2564
|
+
await e.insert(Je).values(s);
|
|
2558
2565
|
} catch (e) {
|
|
2559
2566
|
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new Le(409, { message: "Invite already exists" }) : e;
|
|
2560
2567
|
}
|
|
2561
|
-
return
|
|
2568
|
+
return kn({
|
|
2562
2569
|
...s,
|
|
2563
2570
|
tenant_id: t
|
|
2564
2571
|
});
|
|
2565
2572
|
},
|
|
2566
2573
|
async get(n, r) {
|
|
2567
|
-
let i = await e.select().from(
|
|
2568
|
-
return i ?
|
|
2574
|
+
let i = await e.select().from(Je).where(t(a(Je.tenant_id, n), a(Je.id, r))).get();
|
|
2575
|
+
return i ? kn(i) : null;
|
|
2569
2576
|
},
|
|
2570
2577
|
async update(n, r, i) {
|
|
2571
2578
|
let o = {};
|
|
2572
|
-
for (let e of
|
|
2573
|
-
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(
|
|
2579
|
+
for (let e of On) i[e] !== void 0 && (o[e] = JSON.stringify(i[e]));
|
|
2580
|
+
return i.connection_id !== void 0 && (o.connection_id = i.connection_id), i.ttl_sec !== void 0 && (o.ttl_sec = i.ttl_sec, o.expires_at = new Date(Date.now() + i.ttl_sec * 1e3).toISOString()), (await e.update(Je).set(o).where(t(a(Je.tenant_id, n), a(Je.id, r))).returning()).length > 0;
|
|
2574
2581
|
},
|
|
2575
2582
|
async list(t, o) {
|
|
2576
|
-
let { page: s = 0, per_page: c = 50, include_totals: l = !1, sort: u } = o || {}, d = e.select().from(
|
|
2583
|
+
let { page: s = 0, per_page: c = 50, include_totals: l = !1, sort: u } = o || {}, d = e.select().from(Je).where(a(Je.tenant_id, t)).$dynamic();
|
|
2577
2584
|
if (u?.sort_by) {
|
|
2578
|
-
let e =
|
|
2585
|
+
let e = Je[u.sort_by];
|
|
2579
2586
|
e && (d = d.orderBy(u.sort_order === "desc" ? i(e) : n(e)));
|
|
2580
2587
|
}
|
|
2581
|
-
let f = (await d.offset(s * c).limit(c)).map(
|
|
2588
|
+
let f = (await d.offset(s * c).limit(c)).map(kn);
|
|
2582
2589
|
if (!l) return { invites: f };
|
|
2583
|
-
let [p] = await e.select({ count: r() }).from(
|
|
2590
|
+
let [p] = await e.select({ count: r() }).from(Je).where(a(Je.tenant_id, t));
|
|
2584
2591
|
return {
|
|
2585
2592
|
invites: f,
|
|
2586
2593
|
start: s * c,
|
|
@@ -2589,20 +2596,20 @@ function kn(e) {
|
|
|
2589
2596
|
};
|
|
2590
2597
|
},
|
|
2591
2598
|
async remove(n, r) {
|
|
2592
|
-
return (await e.delete(
|
|
2599
|
+
return (await e.delete(Je).where(t(a(Je.tenant_id, n), a(Je.id, r))).returning()).length > 0;
|
|
2593
2600
|
}
|
|
2594
2601
|
};
|
|
2595
2602
|
}
|
|
2596
2603
|
//#endregion
|
|
2597
2604
|
//#region src/adapters/keys.ts
|
|
2598
|
-
var
|
|
2605
|
+
var jn = [
|
|
2599
2606
|
"kid",
|
|
2600
2607
|
"connection",
|
|
2601
2608
|
"fingerprint",
|
|
2602
2609
|
"thumbprint",
|
|
2603
2610
|
"type"
|
|
2604
2611
|
];
|
|
2605
|
-
function
|
|
2612
|
+
function Mn(e) {
|
|
2606
2613
|
return {
|
|
2607
2614
|
async create(t) {
|
|
2608
2615
|
await e.insert(ot).values({
|
|
@@ -2613,9 +2620,9 @@ function jn(e) {
|
|
|
2613
2620
|
async list(a) {
|
|
2614
2621
|
let { page: o = 0, per_page: c = 50, include_totals: l = !1, sort: u, q: d } = a || {}, p = (/* @__PURE__ */ new Date()).toISOString(), m = [v(s(ot.revoked_at, p), f(ot.revoked_at))];
|
|
2615
2622
|
if (d) {
|
|
2616
|
-
let e = Te(d,
|
|
2623
|
+
let e = Te(d, jn);
|
|
2617
2624
|
if (e) {
|
|
2618
|
-
let t =
|
|
2625
|
+
let t = vt(ot, e, jn);
|
|
2619
2626
|
t && m.push(t);
|
|
2620
2627
|
}
|
|
2621
2628
|
}
|
|
@@ -2644,16 +2651,16 @@ function jn(e) {
|
|
|
2644
2651
|
}
|
|
2645
2652
|
//#endregion
|
|
2646
2653
|
//#region src/adapters/loginSessions.ts
|
|
2647
|
-
var
|
|
2648
|
-
function
|
|
2654
|
+
var Nn = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", Pn = 32;
|
|
2655
|
+
function Fn() {
|
|
2649
2656
|
let e = Date.now(), t = "";
|
|
2650
|
-
for (let n = 10; n > 0; n--) t =
|
|
2657
|
+
for (let n = 10; n > 0; n--) t = Nn.charAt(e % Pn) + t, e = Math.floor(e / Pn);
|
|
2651
2658
|
let n = new Uint8Array(16);
|
|
2652
2659
|
crypto.getRandomValues(n);
|
|
2653
|
-
for (let e = 0; e < 16; e++) t +=
|
|
2660
|
+
for (let e = 0; e < 16; e++) t += Nn.charAt(n[e] % Pn);
|
|
2654
2661
|
return t;
|
|
2655
2662
|
}
|
|
2656
|
-
function
|
|
2663
|
+
function In(e) {
|
|
2657
2664
|
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({
|
|
2658
2665
|
created_at_ts: n,
|
|
2659
2666
|
updated_at_ts: r,
|
|
@@ -2665,17 +2672,17 @@ function Fn(e) {
|
|
|
2665
2672
|
]), l = {};
|
|
2666
2673
|
for (let [e, t] of Object.entries(s)) t != null && (l[e] = t);
|
|
2667
2674
|
return D({
|
|
2668
|
-
...
|
|
2675
|
+
...ht(l, ["auth_strategy"]),
|
|
2669
2676
|
authParams: typeof o == "string" && o.length > 0 ? JSON.parse(o) : {},
|
|
2670
2677
|
...c,
|
|
2671
2678
|
state_data: Z(a)
|
|
2672
2679
|
});
|
|
2673
2680
|
}
|
|
2674
|
-
function
|
|
2681
|
+
function Ln(e) {
|
|
2675
2682
|
return {
|
|
2676
2683
|
async create(t, n) {
|
|
2677
2684
|
let r = Date.now(), i = {
|
|
2678
|
-
id:
|
|
2685
|
+
id: Fn(),
|
|
2679
2686
|
tenant_id: t,
|
|
2680
2687
|
session_id: n.session_id,
|
|
2681
2688
|
csrf_token: n.csrf_token,
|
|
@@ -2696,14 +2703,14 @@ function In(e) {
|
|
|
2696
2703
|
updated_at_ts: r,
|
|
2697
2704
|
expires_at_ts: n.expires_at ? E(n.expires_at) : r + 1e3 * 60 * 60 * 24
|
|
2698
2705
|
};
|
|
2699
|
-
return await e.insert(P).values(i),
|
|
2706
|
+
return await e.insert(P).values(i), In({
|
|
2700
2707
|
...i,
|
|
2701
2708
|
tenant_id: t
|
|
2702
2709
|
});
|
|
2703
2710
|
},
|
|
2704
2711
|
async get(n, r) {
|
|
2705
2712
|
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();
|
|
2706
|
-
return o ?
|
|
2713
|
+
return o ? In(o) : null;
|
|
2707
2714
|
},
|
|
2708
2715
|
async update(n, r, i) {
|
|
2709
2716
|
let o = { updated_at_ts: Date.now() };
|
|
@@ -2723,7 +2730,7 @@ function In(e) {
|
|
|
2723
2730
|
}
|
|
2724
2731
|
//#endregion
|
|
2725
2732
|
//#region src/adapters/logs.ts
|
|
2726
|
-
function
|
|
2733
|
+
function Rn(e) {
|
|
2727
2734
|
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 = {
|
|
2728
2735
|
...f,
|
|
2729
2736
|
isMobile: !!n,
|
|
@@ -2740,7 +2747,7 @@ function Ln(e) {
|
|
|
2740
2747
|
continent_code: u
|
|
2741
2748
|
})), D(p);
|
|
2742
2749
|
}
|
|
2743
|
-
function
|
|
2750
|
+
function zn(e) {
|
|
2744
2751
|
return {
|
|
2745
2752
|
async create(t, n) {
|
|
2746
2753
|
let r = {
|
|
@@ -2766,7 +2773,7 @@ function Rn(e) {
|
|
|
2766
2773
|
hostname: n.hostname,
|
|
2767
2774
|
session_connection: n.session_connection
|
|
2768
2775
|
};
|
|
2769
|
-
return n.auth0_client && (r.auth0_client = JSON.stringify(n.auth0_client)), n.details && (r.details = JSON.stringify(n.details).substring(0, 8192)), n.location_info && (r.country_code = n.location_info.country_code, r.city_name = n.location_info.city_name, r.latitude = n.location_info.latitude, r.longitude = n.location_info.longitude, r.time_zone = n.location_info.time_zone, r.continent_code = n.location_info.continent_code), await e.insert(q).values(r),
|
|
2776
|
+
return n.auth0_client && (r.auth0_client = JSON.stringify(n.auth0_client)), n.details && (r.details = JSON.stringify(n.details).substring(0, 8192)), n.location_info && (r.country_code = n.location_info.country_code, r.city_name = n.location_info.city_name, r.latitude = n.location_info.latitude, r.longitude = n.location_info.longitude, r.time_zone = n.location_info.time_zone, r.continent_code = n.location_info.continent_code), await e.insert(q).values(r), Rn({
|
|
2770
2777
|
...r,
|
|
2771
2778
|
tenant_id: t
|
|
2772
2779
|
});
|
|
@@ -2774,7 +2781,7 @@ function Rn(e) {
|
|
|
2774
2781
|
async list(o, s) {
|
|
2775
2782
|
let { page: l = 0, per_page: u = 50, include_totals: d = !1, sort: f, q: p, from_date: h, to_date: g } = s || {}, _ = [a(q.tenant_id, o)];
|
|
2776
2783
|
if (p) {
|
|
2777
|
-
let e =
|
|
2784
|
+
let e = vt(q, p, [
|
|
2778
2785
|
"user_id",
|
|
2779
2786
|
"ip",
|
|
2780
2787
|
"type",
|
|
@@ -2784,14 +2791,14 @@ function Rn(e) {
|
|
|
2784
2791
|
}
|
|
2785
2792
|
typeof h == "number" && Number.isFinite(h) && _.push(c(q.date, (/* @__PURE__ */ new Date(Math.floor(h) * 1e3)).toISOString())), typeof g == "number" && Number.isFinite(g) && _.push(m(q.date, (/* @__PURE__ */ new Date((Math.floor(g) + 1) * 1e3)).toISOString()));
|
|
2786
2793
|
let v = t(..._);
|
|
2787
|
-
if (
|
|
2794
|
+
if (At(s)) {
|
|
2788
2795
|
if (f?.sort_by && f.sort_by !== "date") throw new Le(400, { message: `Sorting by ${f.sort_by} is not supported with checkpoint pagination (from/take); only date is` });
|
|
2789
2796
|
let n = f?.sort_order === "asc" ? "asc" : "desc", r = {
|
|
2790
2797
|
sortColumn: q.date,
|
|
2791
2798
|
idColumn: q.log_id,
|
|
2792
2799
|
sortOrder: n,
|
|
2793
2800
|
sortKey: `date:${n}`
|
|
2794
|
-
}, i =
|
|
2801
|
+
}, i = Nt(s, r), a = jt(s), { rows: o, next: c } = Pt(await e.select().from(q).where(i ? t(v, i) : v).orderBy(...Mt(r)).limit(a + 1), a, "date", "log_id", r.sortKey), l = o.map(Rn);
|
|
2795
2802
|
return {
|
|
2796
2803
|
logs: l,
|
|
2797
2804
|
start: 0,
|
|
@@ -2805,7 +2812,7 @@ function Rn(e) {
|
|
|
2805
2812
|
let e = q[f.sort_by];
|
|
2806
2813
|
e && (y = y.orderBy(f.sort_order === "desc" ? i(e) : n(e)));
|
|
2807
2814
|
} else y = y.orderBy(i(q.date));
|
|
2808
|
-
let ee = (await y.offset(l * u).limit(u)).map(
|
|
2815
|
+
let ee = (await y.offset(l * u).limit(u)).map(Rn);
|
|
2809
2816
|
if (!d) return { logs: ee };
|
|
2810
2817
|
let [b] = await e.select({ count: r() }).from(q).where(v);
|
|
2811
2818
|
return {
|
|
@@ -2817,22 +2824,22 @@ function Rn(e) {
|
|
|
2817
2824
|
},
|
|
2818
2825
|
async get(n, r) {
|
|
2819
2826
|
let i = await e.select().from(q).where(t(a(q.tenant_id, n), a(q.log_id, r))).get();
|
|
2820
|
-
return i ?
|
|
2827
|
+
return i ? Rn(i) : null;
|
|
2821
2828
|
}
|
|
2822
2829
|
};
|
|
2823
2830
|
}
|
|
2824
2831
|
//#endregion
|
|
2825
2832
|
//#region src/adapters/authenticationMethods.ts
|
|
2826
|
-
var
|
|
2827
|
-
function
|
|
2833
|
+
var Bn = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", Vn = 32;
|
|
2834
|
+
function Hn() {
|
|
2828
2835
|
let e = Date.now(), t = "";
|
|
2829
|
-
for (let n = 10; n > 0; n--) t =
|
|
2836
|
+
for (let n = 10; n > 0; n--) t = Bn.charAt(e % Vn) + t, e = Math.floor(e / Vn);
|
|
2830
2837
|
let n = new Uint8Array(16);
|
|
2831
2838
|
crypto.getRandomValues(n);
|
|
2832
|
-
for (let e = 0; e < 16; e++) t +=
|
|
2839
|
+
for (let e = 0; e < 16; e++) t += Bn.charAt(n[e] % Vn);
|
|
2833
2840
|
return t;
|
|
2834
2841
|
}
|
|
2835
|
-
function
|
|
2842
|
+
function Un(e) {
|
|
2836
2843
|
let { tenant_id: t, created_at_ts: n, updated_at_ts: r, credential_backed_up: i, confirmed: a, transports: o, ...s } = e;
|
|
2837
2844
|
return D({
|
|
2838
2845
|
...s,
|
|
@@ -2843,11 +2850,11 @@ function Hn(e) {
|
|
|
2843
2850
|
updated_at: oe(r)
|
|
2844
2851
|
});
|
|
2845
2852
|
}
|
|
2846
|
-
function
|
|
2853
|
+
function Wn(e) {
|
|
2847
2854
|
return {
|
|
2848
2855
|
async create(t, n) {
|
|
2849
2856
|
let r = Date.now(), i = {
|
|
2850
|
-
id: n.id ||
|
|
2857
|
+
id: n.id || Hn(),
|
|
2851
2858
|
tenant_id: t,
|
|
2852
2859
|
user_id: n.user_id,
|
|
2853
2860
|
type: n.type,
|
|
@@ -2863,41 +2870,41 @@ function Un(e) {
|
|
|
2863
2870
|
created_at_ts: r,
|
|
2864
2871
|
updated_at_ts: r
|
|
2865
2872
|
};
|
|
2866
|
-
return await e.insert(
|
|
2873
|
+
return await e.insert(lt).values(i), Un({
|
|
2867
2874
|
...i,
|
|
2868
2875
|
tenant_id: t
|
|
2869
2876
|
});
|
|
2870
2877
|
},
|
|
2871
2878
|
async get(n, r) {
|
|
2872
|
-
let i = await e.select().from(
|
|
2873
|
-
return i ?
|
|
2879
|
+
let i = await e.select().from(lt).where(t(a(lt.tenant_id, n), a(lt.id, r))).get();
|
|
2880
|
+
return i ? Un(i) : null;
|
|
2874
2881
|
},
|
|
2875
2882
|
async getByCredentialId(n, r) {
|
|
2876
|
-
let i = await e.select().from(
|
|
2877
|
-
return i ?
|
|
2883
|
+
let i = await e.select().from(lt).where(t(a(lt.tenant_id, n), a(lt.credential_id, r))).get();
|
|
2884
|
+
return i ? Un(i) : null;
|
|
2878
2885
|
},
|
|
2879
2886
|
async list(n, r) {
|
|
2880
|
-
return (await e.select().from(
|
|
2887
|
+
return (await e.select().from(lt).where(t(a(lt.tenant_id, n), a(lt.user_id, r))).all()).map(Un);
|
|
2881
2888
|
},
|
|
2882
2889
|
async update(n, r, i) {
|
|
2883
2890
|
let o = { updated_at_ts: Date.now() };
|
|
2884
|
-
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(
|
|
2891
|
+
i.type !== void 0 && (o.type = i.type), i.phone_number !== void 0 && (o.phone_number = i.phone_number), i.totp_secret !== void 0 && (o.totp_secret = i.totp_secret), i.credential_id !== void 0 && (o.credential_id = i.credential_id), i.public_key !== void 0 && (o.public_key = i.public_key), i.sign_count !== void 0 && (o.sign_count = i.sign_count), i.credential_backed_up !== void 0 && (o.credential_backed_up = +!!i.credential_backed_up), i.transports !== void 0 && (o.transports = JSON.stringify(i.transports)), i.friendly_name !== void 0 && (o.friendly_name = i.friendly_name), i.confirmed !== void 0 && (o.confirmed = +!!i.confirmed), await e.update(lt).set(o).where(t(a(lt.tenant_id, n), a(lt.id, r)));
|
|
2885
2892
|
let s = await this.get(n, r);
|
|
2886
2893
|
if (!s) throw Error(`Authentication method ${r} not found after update`);
|
|
2887
2894
|
return s;
|
|
2888
2895
|
},
|
|
2889
2896
|
async remove(n, r) {
|
|
2890
|
-
return (await e.delete(
|
|
2897
|
+
return (await e.delete(lt).where(t(a(lt.tenant_id, n), a(lt.id, r))).returning()).length > 0;
|
|
2891
2898
|
}
|
|
2892
2899
|
};
|
|
2893
2900
|
}
|
|
2894
2901
|
//#endregion
|
|
2895
2902
|
//#region src/adapters/organizations.ts
|
|
2896
|
-
var
|
|
2897
|
-
function
|
|
2903
|
+
var Gn = ["name", "display_name"];
|
|
2904
|
+
function Kn() {
|
|
2898
2905
|
return `org_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
2899
2906
|
}
|
|
2900
|
-
function
|
|
2907
|
+
function qn(e) {
|
|
2901
2908
|
let { tenant_id: t, branding: n, metadata: r, enabled_connections: i, token_quota: a, ...o } = e;
|
|
2902
2909
|
return D({
|
|
2903
2910
|
...o,
|
|
@@ -2907,11 +2914,11 @@ function Kn(e) {
|
|
|
2907
2914
|
token_quota: Z(a, {})
|
|
2908
2915
|
});
|
|
2909
2916
|
}
|
|
2910
|
-
function
|
|
2917
|
+
function Jn(e) {
|
|
2911
2918
|
return {
|
|
2912
2919
|
async create(t, n) {
|
|
2913
2920
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
2914
|
-
id: n.id ||
|
|
2921
|
+
id: n.id || Kn(),
|
|
2915
2922
|
tenant_id: t,
|
|
2916
2923
|
name: n.name,
|
|
2917
2924
|
display_name: n.display_name,
|
|
@@ -2923,39 +2930,39 @@ function qn(e) {
|
|
|
2923
2930
|
updated_at: r
|
|
2924
2931
|
};
|
|
2925
2932
|
try {
|
|
2926
|
-
await e.insert(
|
|
2933
|
+
await e.insert(V).values(i);
|
|
2927
2934
|
} catch (e) {
|
|
2928
2935
|
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("AlreadyExists") ? new Le(409, { message: "Organization already exists" }) : e;
|
|
2929
2936
|
}
|
|
2930
|
-
return
|
|
2937
|
+
return qn({
|
|
2931
2938
|
...i,
|
|
2932
2939
|
tenant_id: t
|
|
2933
2940
|
});
|
|
2934
2941
|
},
|
|
2935
2942
|
async get(n, r) {
|
|
2936
|
-
let i = await e.select().from(
|
|
2937
|
-
return i ||= await e.select().from(
|
|
2943
|
+
let i = await e.select().from(V).where(t(a(V.tenant_id, n), a(V.id, r))).get();
|
|
2944
|
+
return i ||= await e.select().from(V).where(t(a(V.tenant_id, n), a(V.name, r))).get(), i ? qn(i) : null;
|
|
2938
2945
|
},
|
|
2939
2946
|
async update(n, r, i) {
|
|
2940
2947
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2941
|
-
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(
|
|
2948
|
+
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(V).set(o).where(t(a(V.tenant_id, n), a(V.id, r))).returning()).length > 0;
|
|
2942
2949
|
},
|
|
2943
2950
|
async list(o, s) {
|
|
2944
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(
|
|
2951
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(V.tenant_id, o)];
|
|
2945
2952
|
if (f) {
|
|
2946
|
-
let e = Te(f,
|
|
2953
|
+
let e = Te(f, Gn);
|
|
2947
2954
|
if (e) {
|
|
2948
|
-
let t =
|
|
2955
|
+
let t = vt(V, e, Gn);
|
|
2949
2956
|
t && p.push(t);
|
|
2950
2957
|
}
|
|
2951
2958
|
}
|
|
2952
2959
|
let m = t(...p);
|
|
2953
|
-
if (
|
|
2960
|
+
if (At(s)) {
|
|
2954
2961
|
let n = {
|
|
2955
|
-
sortColumn:
|
|
2956
|
-
idColumn:
|
|
2962
|
+
sortColumn: V.created_at,
|
|
2963
|
+
idColumn: V.id,
|
|
2957
2964
|
sortOrder: "desc"
|
|
2958
|
-
}, r =
|
|
2965
|
+
}, r = Nt(s, n), i = jt(s), { rows: a, next: o } = Pt(await e.select().from(V).where(r ? t(m, r) : m).orderBy(...Mt(n)).limit(i + 1), i, "created_at"), c = a.map(qn);
|
|
2959
2966
|
return {
|
|
2960
2967
|
organizations: c,
|
|
2961
2968
|
start: 0,
|
|
@@ -2965,14 +2972,14 @@ function qn(e) {
|
|
|
2965
2972
|
next: o
|
|
2966
2973
|
};
|
|
2967
2974
|
}
|
|
2968
|
-
let h = e.select().from(
|
|
2975
|
+
let h = e.select().from(V).where(m).$dynamic();
|
|
2969
2976
|
if (d?.sort_by) {
|
|
2970
|
-
let e =
|
|
2977
|
+
let e = V[d.sort_by];
|
|
2971
2978
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
2972
2979
|
}
|
|
2973
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
2980
|
+
let g = (await h.offset(c * l).limit(l)).map(qn);
|
|
2974
2981
|
if (!u) return { organizations: g };
|
|
2975
|
-
let [_] = await e.select({ count: r() }).from(
|
|
2982
|
+
let [_] = await e.select({ count: r() }).from(V).where(m);
|
|
2976
2983
|
return {
|
|
2977
2984
|
organizations: g,
|
|
2978
2985
|
start: c * l,
|
|
@@ -2981,20 +2988,20 @@ function qn(e) {
|
|
|
2981
2988
|
};
|
|
2982
2989
|
},
|
|
2983
2990
|
async remove(n, r) {
|
|
2984
|
-
return (await e.delete(
|
|
2991
|
+
return (await e.delete(V).where(t(a(V.tenant_id, n), a(V.id, r))).returning()).length > 0;
|
|
2985
2992
|
}
|
|
2986
2993
|
};
|
|
2987
2994
|
}
|
|
2988
2995
|
//#endregion
|
|
2989
2996
|
//#region src/adapters/passwords.ts
|
|
2990
|
-
function
|
|
2997
|
+
function Yn(e) {
|
|
2991
2998
|
let { tenant_id: t, is_current: n, ...r } = e;
|
|
2992
2999
|
return {
|
|
2993
3000
|
...r,
|
|
2994
3001
|
is_current: !!n
|
|
2995
3002
|
};
|
|
2996
3003
|
}
|
|
2997
|
-
function
|
|
3004
|
+
function Xn(e) {
|
|
2998
3005
|
return {
|
|
2999
3006
|
async create(n, r) {
|
|
3000
3007
|
let i = (/* @__PURE__ */ new Date()).toISOString(), o = r.id || b();
|
|
@@ -3009,18 +3016,18 @@ function Yn(e) {
|
|
|
3009
3016
|
created_at: i,
|
|
3010
3017
|
updated_at: i
|
|
3011
3018
|
};
|
|
3012
|
-
return await e.insert(j).values(s),
|
|
3019
|
+
return await e.insert(j).values(s), Yn({
|
|
3013
3020
|
...s,
|
|
3014
3021
|
tenant_id: n
|
|
3015
3022
|
});
|
|
3016
3023
|
},
|
|
3017
3024
|
async get(n, r) {
|
|
3018
3025
|
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();
|
|
3019
|
-
return i ?
|
|
3026
|
+
return i ? Yn(i) : null;
|
|
3020
3027
|
},
|
|
3021
3028
|
async list(n, r, o) {
|
|
3022
3029
|
let s = e.select().from(j).where(t(a(j.tenant_id, n), a(j.user_id, r))).orderBy(i(j.created_at)).$dynamic();
|
|
3023
|
-
return o && (s = s.limit(o)), (await s).map(
|
|
3030
|
+
return o && (s = s.limit(o)), (await s).map(Yn);
|
|
3024
3031
|
},
|
|
3025
3032
|
async update(n, r) {
|
|
3026
3033
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -3030,7 +3037,7 @@ function Yn(e) {
|
|
|
3030
3037
|
}
|
|
3031
3038
|
//#endregion
|
|
3032
3039
|
//#region src/adapters/promptSettings.ts
|
|
3033
|
-
function
|
|
3040
|
+
function Zn(e) {
|
|
3034
3041
|
return {
|
|
3035
3042
|
async get(t) {
|
|
3036
3043
|
let n = await e.select().from(tt).where(a(tt.tenant_id, t)).get();
|
|
@@ -3070,8 +3077,45 @@ function Xn(e) {
|
|
|
3070
3077
|
};
|
|
3071
3078
|
}
|
|
3072
3079
|
//#endregion
|
|
3080
|
+
//#region src/adapters/promptPartials.ts
|
|
3081
|
+
function Qn(e) {
|
|
3082
|
+
return {
|
|
3083
|
+
async get(n, r) {
|
|
3084
|
+
let i = await e.select({ body: ct.body }).from(ct).where(t(a(ct.tenant_id, n), a(ct.prompt, r))).get();
|
|
3085
|
+
if (!i) return null;
|
|
3086
|
+
try {
|
|
3087
|
+
return JSON.parse(i.body);
|
|
3088
|
+
} catch {
|
|
3089
|
+
return null;
|
|
3090
|
+
}
|
|
3091
|
+
},
|
|
3092
|
+
async set(t, n, r, i) {
|
|
3093
|
+
let a = Date.now(), o = i?.importMetadata?.created_at, s = i?.importMetadata?.updated_at, c = o ? new Date(o).getTime() : a, l = s ? new Date(s).getTime() : c, u = JSON.stringify(r);
|
|
3094
|
+
await e.insert(ct).values({
|
|
3095
|
+
tenant_id: t,
|
|
3096
|
+
prompt: n,
|
|
3097
|
+
body: u,
|
|
3098
|
+
created_at_ts: c,
|
|
3099
|
+
updated_at_ts: l
|
|
3100
|
+
}).onConflictDoUpdate({
|
|
3101
|
+
target: [ct.tenant_id, ct.prompt],
|
|
3102
|
+
set: {
|
|
3103
|
+
body: u,
|
|
3104
|
+
updated_at_ts: s ? l : a
|
|
3105
|
+
}
|
|
3106
|
+
});
|
|
3107
|
+
},
|
|
3108
|
+
async delete(n, r) {
|
|
3109
|
+
await e.delete(ct).where(t(a(ct.tenant_id, n), a(ct.prompt, r)));
|
|
3110
|
+
},
|
|
3111
|
+
async list(t) {
|
|
3112
|
+
return (await e.select({ prompt: ct.prompt }).from(ct).where(a(ct.tenant_id, t)).all()).map(({ prompt: e }) => e);
|
|
3113
|
+
}
|
|
3114
|
+
};
|
|
3115
|
+
}
|
|
3116
|
+
//#endregion
|
|
3073
3117
|
//#region src/adapters/proxyRoutes.ts
|
|
3074
|
-
function
|
|
3118
|
+
function $n(e) {
|
|
3075
3119
|
if (!e) return { path: "/*" };
|
|
3076
3120
|
try {
|
|
3077
3121
|
let t = JSON.parse(e), n = xe.safeParse(t);
|
|
@@ -3079,7 +3123,7 @@ function Zn(e) {
|
|
|
3079
3123
|
} catch {}
|
|
3080
3124
|
return { path: "/*" };
|
|
3081
3125
|
}
|
|
3082
|
-
function
|
|
3126
|
+
function er(e) {
|
|
3083
3127
|
if (!e) return [];
|
|
3084
3128
|
try {
|
|
3085
3129
|
let t = JSON.parse(e);
|
|
@@ -3094,19 +3138,19 @@ function Qn(e) {
|
|
|
3094
3138
|
return [];
|
|
3095
3139
|
}
|
|
3096
3140
|
}
|
|
3097
|
-
function
|
|
3141
|
+
function tr(e) {
|
|
3098
3142
|
return {
|
|
3099
3143
|
id: e.id,
|
|
3100
3144
|
tenant_id: e.tenant_id,
|
|
3101
3145
|
custom_domain_id: e.custom_domain_id,
|
|
3102
3146
|
priority: e.priority,
|
|
3103
|
-
match:
|
|
3104
|
-
handlers:
|
|
3147
|
+
match: $n(e.match),
|
|
3148
|
+
handlers: er(e.handlers),
|
|
3105
3149
|
created_at: e.created_at,
|
|
3106
3150
|
updated_at: e.updated_at
|
|
3107
3151
|
};
|
|
3108
3152
|
}
|
|
3109
|
-
function
|
|
3153
|
+
function nr(e) {
|
|
3110
3154
|
return {
|
|
3111
3155
|
async create(t, n) {
|
|
3112
3156
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -3132,14 +3176,14 @@ function er(e) {
|
|
|
3132
3176
|
},
|
|
3133
3177
|
async get(n, r) {
|
|
3134
3178
|
let i = await e.select().from(Y).where(t(a(Y.tenant_id, n), a(Y.id, r))).limit(1);
|
|
3135
|
-
return i[0] ?
|
|
3179
|
+
return i[0] ? tr(i[0]) : null;
|
|
3136
3180
|
},
|
|
3137
3181
|
async list(r, i = {}) {
|
|
3138
3182
|
let o = i.page ?? 0, s = i.per_page ?? 50, c = [a(Y.tenant_id, r)];
|
|
3139
3183
|
i.custom_domain_id && c.push(a(Y.custom_domain_id, i.custom_domain_id));
|
|
3140
3184
|
let l = await e.select().from(Y).where(t(...c)).orderBy(n(Y.priority), n(Y.created_at)).offset(o * s).limit(s);
|
|
3141
3185
|
return {
|
|
3142
|
-
proxy_routes: l.map(
|
|
3186
|
+
proxy_routes: l.map(tr),
|
|
3143
3187
|
start: o * s,
|
|
3144
3188
|
limit: s,
|
|
3145
3189
|
length: l.length
|
|
@@ -3158,8 +3202,8 @@ function er(e) {
|
|
|
3158
3202
|
}
|
|
3159
3203
|
//#endregion
|
|
3160
3204
|
//#region src/adapters/tokenExchangeProfiles.ts
|
|
3161
|
-
var
|
|
3162
|
-
function
|
|
3205
|
+
var rr = ee("0123456789abcdefghijklmnopqrstuvwxyz", 17);
|
|
3206
|
+
function ir(e) {
|
|
3163
3207
|
if (e) try {
|
|
3164
3208
|
let t = Fe.safeParse(JSON.parse(e));
|
|
3165
3209
|
return t.success ? t.data : void 0;
|
|
@@ -3167,7 +3211,7 @@ function nr(e) {
|
|
|
3167
3211
|
return;
|
|
3168
3212
|
}
|
|
3169
3213
|
}
|
|
3170
|
-
function
|
|
3214
|
+
function ar(e) {
|
|
3171
3215
|
let t = {
|
|
3172
3216
|
id: e.id,
|
|
3173
3217
|
name: e.name,
|
|
@@ -3177,14 +3221,14 @@ function rr(e) {
|
|
|
3177
3221
|
updated_at: e.updated_at
|
|
3178
3222
|
};
|
|
3179
3223
|
e.action_id && (t.action_id = e.action_id);
|
|
3180
|
-
let n =
|
|
3224
|
+
let n = ir(e.jwt_verification);
|
|
3181
3225
|
return n && (t.jwt_verification = n), t;
|
|
3182
3226
|
}
|
|
3183
|
-
function
|
|
3227
|
+
function or(e) {
|
|
3184
3228
|
return {
|
|
3185
3229
|
async create(t, n, r) {
|
|
3186
3230
|
let i = r?.importMetadata, a = (/* @__PURE__ */ new Date()).toISOString(), o = {
|
|
3187
|
-
id: i?.id ?? `tep_${
|
|
3231
|
+
id: i?.id ?? `tep_${rr()}`,
|
|
3188
3232
|
tenant_id: t,
|
|
3189
3233
|
name: n.name,
|
|
3190
3234
|
subject_token_type: n.subject_token_type,
|
|
@@ -3194,27 +3238,27 @@ function ir(e) {
|
|
|
3194
3238
|
created_at: i?.created_at ?? a,
|
|
3195
3239
|
updated_at: i?.updated_at ?? a
|
|
3196
3240
|
};
|
|
3197
|
-
return await e.insert(
|
|
3241
|
+
return await e.insert(ft).values(o), ar(o);
|
|
3198
3242
|
},
|
|
3199
3243
|
async get(n, r) {
|
|
3200
|
-
let i = await e.select().from(
|
|
3201
|
-
return i[0] ?
|
|
3244
|
+
let i = await e.select().from(ft).where(t(a(ft.tenant_id, n), a(ft.id, r))).limit(1);
|
|
3245
|
+
return i[0] ? ar(i[0]) : null;
|
|
3202
3246
|
},
|
|
3203
3247
|
async list(t) {
|
|
3204
|
-
return (await e.select().from(
|
|
3248
|
+
return (await e.select().from(ft).where(a(ft.tenant_id, t)).orderBy(n(ft.created_at), n(ft.id))).map(ar);
|
|
3205
3249
|
},
|
|
3206
3250
|
async update(n, r, i) {
|
|
3207
3251
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
3208
|
-
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(
|
|
3252
|
+
return i.name !== void 0 && (o.name = i.name), i.subject_token_type !== void 0 && (o.subject_token_type = i.subject_token_type), i.jwt_verification !== void 0 && (o.jwt_verification = JSON.stringify(i.jwt_verification)), (await e.update(ft).set(o).where(t(a(ft.tenant_id, n), a(ft.id, r))).returning({ id: ft.id })).length > 0;
|
|
3209
3253
|
},
|
|
3210
3254
|
async remove(n, r) {
|
|
3211
|
-
return (await e.delete(
|
|
3255
|
+
return (await e.delete(ft).where(t(a(ft.tenant_id, n), a(ft.id, r))).returning({ id: ft.id })).length > 0;
|
|
3212
3256
|
}
|
|
3213
3257
|
};
|
|
3214
3258
|
}
|
|
3215
3259
|
//#endregion
|
|
3216
3260
|
//#region src/adapters/scim.ts
|
|
3217
|
-
function
|
|
3261
|
+
function sr(e) {
|
|
3218
3262
|
if (!e) return [];
|
|
3219
3263
|
try {
|
|
3220
3264
|
let t = JSON.parse(e);
|
|
@@ -3229,7 +3273,7 @@ function ar(e) {
|
|
|
3229
3273
|
return [];
|
|
3230
3274
|
}
|
|
3231
3275
|
}
|
|
3232
|
-
function
|
|
3276
|
+
function cr(e) {
|
|
3233
3277
|
if (!e) return [];
|
|
3234
3278
|
try {
|
|
3235
3279
|
let t = JSON.parse(e);
|
|
@@ -3238,16 +3282,16 @@ function or(e) {
|
|
|
3238
3282
|
return [];
|
|
3239
3283
|
}
|
|
3240
3284
|
}
|
|
3241
|
-
function
|
|
3285
|
+
function lr(e) {
|
|
3242
3286
|
return {
|
|
3243
3287
|
connection_id: e.connection_id,
|
|
3244
3288
|
user_id_attribute: e.user_id_attribute,
|
|
3245
|
-
mapping:
|
|
3289
|
+
mapping: sr(e.mapping),
|
|
3246
3290
|
created_at: e.created_at,
|
|
3247
3291
|
updated_at: e.updated_at
|
|
3248
3292
|
};
|
|
3249
3293
|
}
|
|
3250
|
-
function
|
|
3294
|
+
function ur(e) {
|
|
3251
3295
|
return {
|
|
3252
3296
|
async create(t, n) {
|
|
3253
3297
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -3257,7 +3301,7 @@ function cr(e) {
|
|
|
3257
3301
|
created_at: r,
|
|
3258
3302
|
updated_at: r
|
|
3259
3303
|
};
|
|
3260
|
-
return await e.insert(
|
|
3304
|
+
return await e.insert(ut).values({
|
|
3261
3305
|
connection_id: i.connection_id,
|
|
3262
3306
|
tenant_id: t,
|
|
3263
3307
|
user_id_attribute: i.user_id_attribute,
|
|
@@ -3267,31 +3311,31 @@ function cr(e) {
|
|
|
3267
3311
|
}), i;
|
|
3268
3312
|
},
|
|
3269
3313
|
async get(n, r) {
|
|
3270
|
-
let i = await e.select().from(
|
|
3271
|
-
return i[0] ?
|
|
3314
|
+
let i = await e.select().from(ut).where(t(a(ut.tenant_id, n), a(ut.connection_id, r))).limit(1);
|
|
3315
|
+
return i[0] ? lr(i[0]) : null;
|
|
3272
3316
|
},
|
|
3273
3317
|
async update(n, r, i) {
|
|
3274
|
-
if ((await e.select({ connection_id:
|
|
3318
|
+
if ((await e.select({ connection_id: ut.connection_id }).from(ut).where(t(a(ut.tenant_id, n), a(ut.connection_id, r))).limit(1)).length === 0) return !1;
|
|
3275
3319
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
3276
|
-
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(
|
|
3320
|
+
return i.user_id_attribute !== void 0 && (o.user_id_attribute = i.user_id_attribute), i.mapping !== void 0 && (o.mapping = JSON.stringify(i.mapping)), await e.update(ut).set(o).where(t(a(ut.tenant_id, n), a(ut.connection_id, r))), !0;
|
|
3277
3321
|
},
|
|
3278
3322
|
async remove(n, r) {
|
|
3279
|
-
return (await e.select({ connection_id:
|
|
3323
|
+
return (await e.select({ connection_id: ut.connection_id }).from(ut).where(t(a(ut.tenant_id, n), a(ut.connection_id, r))).limit(1)).length === 0 ? !1 : (await e.delete(ut).where(t(a(ut.tenant_id, n), a(ut.connection_id, r))), !0);
|
|
3280
3324
|
}
|
|
3281
3325
|
};
|
|
3282
3326
|
}
|
|
3283
|
-
function
|
|
3327
|
+
function dr(e) {
|
|
3284
3328
|
return {
|
|
3285
3329
|
token_id: e.token_id,
|
|
3286
3330
|
connection_id: e.connection_id,
|
|
3287
3331
|
token_hash: e.token_hash,
|
|
3288
|
-
scopes:
|
|
3332
|
+
scopes: cr(e.scopes),
|
|
3289
3333
|
valid_until: e.valid_until ?? void 0,
|
|
3290
3334
|
created_at: e.created_at,
|
|
3291
3335
|
last_used_at: e.last_used_at ?? void 0
|
|
3292
3336
|
};
|
|
3293
3337
|
}
|
|
3294
|
-
function
|
|
3338
|
+
function fr(e) {
|
|
3295
3339
|
return {
|
|
3296
3340
|
async create(t, n) {
|
|
3297
3341
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -3314,14 +3358,14 @@ function ur(e) {
|
|
|
3314
3358
|
},
|
|
3315
3359
|
async get(n, r) {
|
|
3316
3360
|
let i = await e.select().from(X).where(t(a(X.tenant_id, n), a(X.token_id, r))).limit(1);
|
|
3317
|
-
return i[0] ?
|
|
3361
|
+
return i[0] ? dr(i[0]) : null;
|
|
3318
3362
|
},
|
|
3319
3363
|
async getByHash(n, r) {
|
|
3320
3364
|
let i = await e.select().from(X).where(t(a(X.tenant_id, n), a(X.token_hash, r))).limit(1);
|
|
3321
|
-
return i[0] ?
|
|
3365
|
+
return i[0] ? dr(i[0]) : null;
|
|
3322
3366
|
},
|
|
3323
3367
|
async listByConnection(n, r) {
|
|
3324
|
-
return (await e.select().from(X).where(t(a(X.tenant_id, n), a(X.connection_id, r)))).map(
|
|
3368
|
+
return (await e.select().from(X).where(t(a(X.tenant_id, n), a(X.connection_id, r)))).map(dr);
|
|
3325
3369
|
},
|
|
3326
3370
|
async markUsed(n, r, i) {
|
|
3327
3371
|
return (await e.select({ token_id: X.token_id }).from(X).where(t(a(X.tenant_id, n), a(X.token_id, r))).limit(1)).length === 0 ? !1 : (await e.update(X).set({ last_used_at: i }).where(t(a(X.tenant_id, n), a(X.token_id, r))), !0);
|
|
@@ -3331,7 +3375,7 @@ function ur(e) {
|
|
|
3331
3375
|
}
|
|
3332
3376
|
};
|
|
3333
3377
|
}
|
|
3334
|
-
function
|
|
3378
|
+
function pr(e) {
|
|
3335
3379
|
return {
|
|
3336
3380
|
connection_id: e.connection_id,
|
|
3337
3381
|
external_id: e.external_id,
|
|
@@ -3339,7 +3383,7 @@ function dr(e) {
|
|
|
3339
3383
|
created_at: e.created_at
|
|
3340
3384
|
};
|
|
3341
3385
|
}
|
|
3342
|
-
function
|
|
3386
|
+
function mr(e) {
|
|
3343
3387
|
return {
|
|
3344
3388
|
async create(t, n) {
|
|
3345
3389
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -3348,7 +3392,7 @@ function fr(e) {
|
|
|
3348
3392
|
user_id: n.user_id,
|
|
3349
3393
|
created_at: r
|
|
3350
3394
|
};
|
|
3351
|
-
return await e.insert(
|
|
3395
|
+
return await e.insert(dt).values({
|
|
3352
3396
|
tenant_id: t,
|
|
3353
3397
|
connection_id: i.connection_id,
|
|
3354
3398
|
external_id: i.external_id,
|
|
@@ -3357,21 +3401,21 @@ function fr(e) {
|
|
|
3357
3401
|
}), i;
|
|
3358
3402
|
},
|
|
3359
3403
|
async getByExternalId(n, r, i) {
|
|
3360
|
-
let o = await e.select().from(
|
|
3361
|
-
return o[0] ?
|
|
3404
|
+
let o = await e.select().from(dt).where(t(a(dt.tenant_id, n), a(dt.connection_id, r), a(dt.external_id, i))).limit(1);
|
|
3405
|
+
return o[0] ? pr(o[0]) : null;
|
|
3362
3406
|
},
|
|
3363
3407
|
async getByUserId(n, r, i) {
|
|
3364
|
-
let o = await e.select().from(
|
|
3365
|
-
return o[0] ?
|
|
3408
|
+
let o = await e.select().from(dt).where(t(a(dt.tenant_id, n), a(dt.connection_id, r), a(dt.user_id, i))).limit(1);
|
|
3409
|
+
return o[0] ? pr(o[0]) : null;
|
|
3366
3410
|
},
|
|
3367
3411
|
async remove(n, r, i) {
|
|
3368
|
-
return (await e.select({ user_id:
|
|
3412
|
+
return (await e.select({ user_id: dt.user_id }).from(dt).where(t(a(dt.tenant_id, n), a(dt.connection_id, r), a(dt.user_id, i))).limit(1)).length === 0 ? !1 : (await e.delete(dt).where(t(a(dt.tenant_id, n), a(dt.connection_id, r), a(dt.user_id, i))), !0);
|
|
3369
3413
|
}
|
|
3370
3414
|
};
|
|
3371
3415
|
}
|
|
3372
3416
|
//#endregion
|
|
3373
3417
|
//#region src/adapters/refreshTokens.ts
|
|
3374
|
-
function
|
|
3418
|
+
function hr(e) {
|
|
3375
3419
|
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({
|
|
3376
3420
|
created_at_ts: n,
|
|
3377
3421
|
expires_at_ts: r,
|
|
@@ -3398,10 +3442,10 @@ function pr(e) {
|
|
|
3398
3442
|
} } : {}
|
|
3399
3443
|
});
|
|
3400
3444
|
}
|
|
3401
|
-
function
|
|
3445
|
+
function gr(e, t) {
|
|
3402
3446
|
return Math.max(e ?? 0, t ?? 0);
|
|
3403
3447
|
}
|
|
3404
|
-
function
|
|
3448
|
+
function _r(e) {
|
|
3405
3449
|
return {
|
|
3406
3450
|
async create(n, r) {
|
|
3407
3451
|
let i = Date.now(), o = {
|
|
@@ -3427,22 +3471,22 @@ function hr(e) {
|
|
|
3427
3471
|
expires_at_ts: E(r.expires_at),
|
|
3428
3472
|
idle_expires_at_ts: E(r.idle_expires_at),
|
|
3429
3473
|
last_exchanged_at_ts: E(r.last_exchanged_at)
|
|
3430
|
-
}, s = [e.insert(N).values(o)], c =
|
|
3474
|
+
}, s = [e.insert(N).values(o)], c = gr(o.expires_at_ts, o.idle_expires_at_ts);
|
|
3431
3475
|
return c > 0 && o.login_id && s.push(e.update(P).set({
|
|
3432
3476
|
expires_at_ts: c,
|
|
3433
3477
|
updated_at_ts: i
|
|
3434
|
-
}).where(t(a(P.tenant_id, n), a(P.id, o.login_id), m(P.expires_at_ts, c)))), await
|
|
3478
|
+
}).where(t(a(P.tenant_id, n), a(P.id, o.login_id), m(P.expires_at_ts, c)))), await Tt(e, s), hr({
|
|
3435
3479
|
...o,
|
|
3436
3480
|
tenant_id: n
|
|
3437
3481
|
});
|
|
3438
3482
|
},
|
|
3439
3483
|
async get(n, r) {
|
|
3440
3484
|
let i = await e.select().from(N).where(t(a(N.tenant_id, n), a(N.id, r))).get();
|
|
3441
|
-
return i ?
|
|
3485
|
+
return i ? hr(i) : null;
|
|
3442
3486
|
},
|
|
3443
3487
|
async getByLookup(n, r) {
|
|
3444
3488
|
let i = await e.select().from(N).where(t(a(N.tenant_id, n), a(N.token_lookup, r))).get();
|
|
3445
|
-
return i ?
|
|
3489
|
+
return i ? hr(i) : null;
|
|
3446
3490
|
},
|
|
3447
3491
|
async update(n, r, i, o) {
|
|
3448
3492
|
let s = {};
|
|
@@ -3454,17 +3498,17 @@ function hr(e) {
|
|
|
3454
3498
|
}).where(t(a(P.tenant_id, n), a(P.id, c.login_id), m(P.expires_at_ts, l))).catch(() => {}), u.length > 0;
|
|
3455
3499
|
},
|
|
3456
3500
|
async list(o, s) {
|
|
3457
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
3501
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? vt(N, f, ["user_id", "login_id"]) : void 0, m = [
|
|
3458
3502
|
a(N.tenant_id, o),
|
|
3459
3503
|
...s?.user_id === void 0 ? [] : [a(N.user_id, s.user_id)],
|
|
3460
3504
|
...p ? [p] : []
|
|
3461
3505
|
], h = m.length === 1 ? m[0] : t(...m);
|
|
3462
|
-
if (
|
|
3506
|
+
if (At(s)) {
|
|
3463
3507
|
let n = {
|
|
3464
3508
|
sortColumn: N.created_at_ts,
|
|
3465
3509
|
idColumn: N.id,
|
|
3466
3510
|
sortOrder: "desc"
|
|
3467
|
-
}, r =
|
|
3511
|
+
}, r = Nt(s, n), i = jt(s), { rows: a, next: o } = Pt(await e.select().from(N).where(r ? t(h, r) : h).orderBy(...Mt(n)).limit(i + 1), i, "created_at_ts"), c = a.map(hr);
|
|
3468
3512
|
return {
|
|
3469
3513
|
refresh_tokens: c,
|
|
3470
3514
|
start: 0,
|
|
@@ -3478,7 +3522,7 @@ function hr(e) {
|
|
|
3478
3522
|
let e = N[d.sort_by];
|
|
3479
3523
|
e && (g = g.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
3480
3524
|
}
|
|
3481
|
-
let _ = (await g.offset(c * l).limit(l)).map(
|
|
3525
|
+
let _ = (await g.offset(c * l).limit(l)).map(hr);
|
|
3482
3526
|
if (!u) return { refresh_tokens: _ };
|
|
3483
3527
|
let [v] = await e.select({ count: r() }).from(N).where(h);
|
|
3484
3528
|
return {
|
|
@@ -3507,15 +3551,15 @@ function hr(e) {
|
|
|
3507
3551
|
}
|
|
3508
3552
|
//#endregion
|
|
3509
3553
|
//#region src/adapters/resourceServers.ts
|
|
3510
|
-
var
|
|
3511
|
-
function
|
|
3554
|
+
var vr = ["name", "identifier"];
|
|
3555
|
+
function yr() {
|
|
3512
3556
|
return `api_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
3513
3557
|
}
|
|
3514
|
-
var
|
|
3558
|
+
var br = [
|
|
3515
3559
|
"skip_consent_for_verifiable_first_party_clients",
|
|
3516
3560
|
"allow_offline_access",
|
|
3517
3561
|
"is_system"
|
|
3518
|
-
],
|
|
3562
|
+
], xr = new Set([
|
|
3519
3563
|
"id",
|
|
3520
3564
|
"tenant_id",
|
|
3521
3565
|
"identifier",
|
|
@@ -3534,17 +3578,17 @@ var vr = [
|
|
|
3534
3578
|
"created_at",
|
|
3535
3579
|
"updated_at"
|
|
3536
3580
|
]);
|
|
3537
|
-
function
|
|
3581
|
+
function Sr(e) {
|
|
3538
3582
|
let { tenant_id: t, verification_key: n, scopes: r, options: i, metadata: a, ...o } = e, s = { ...o };
|
|
3539
3583
|
s.scopes = Z(r, []), s.options = Z(i, {}), s.metadata = Z(a), n !== void 0 && (s.verificationKey = n);
|
|
3540
|
-
for (let e of
|
|
3584
|
+
for (let e of br) o[e] !== void 0 && o[e] !== null && (s[e] = !!o[e]);
|
|
3541
3585
|
return D(s);
|
|
3542
3586
|
}
|
|
3543
|
-
function
|
|
3587
|
+
function Cr(e) {
|
|
3544
3588
|
return {
|
|
3545
3589
|
async create(t, n) {
|
|
3546
3590
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
3547
|
-
id: n.id ||
|
|
3591
|
+
id: n.id || yr(),
|
|
3548
3592
|
tenant_id: t,
|
|
3549
3593
|
identifier: n.identifier,
|
|
3550
3594
|
name: n.name,
|
|
@@ -3559,37 +3603,37 @@ function xr(e) {
|
|
|
3559
3603
|
created_at: r,
|
|
3560
3604
|
updated_at: r
|
|
3561
3605
|
};
|
|
3562
|
-
for (let e of
|
|
3563
|
-
return i.is_system === void 0 && (i.is_system = 0), await e.insert(K).values(i),
|
|
3606
|
+
for (let e of br) n[e] !== void 0 && (i[e] = +!!n[e]);
|
|
3607
|
+
return i.is_system === void 0 && (i.is_system = 0), await e.insert(K).values(i), Sr({
|
|
3564
3608
|
...i,
|
|
3565
3609
|
tenant_id: t
|
|
3566
3610
|
});
|
|
3567
3611
|
},
|
|
3568
3612
|
async get(n, r) {
|
|
3569
3613
|
let i = await e.select().from(K).where(t(a(K.tenant_id, n), a(K.id, r))).get();
|
|
3570
|
-
return i ?
|
|
3614
|
+
return i ? Sr(i) : null;
|
|
3571
3615
|
},
|
|
3572
3616
|
async update(n, r, i) {
|
|
3573
3617
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
3574
3618
|
i.name !== void 0 && (o.name = i.name), i.identifier !== void 0 && (o.identifier = i.identifier), i.signing_alg !== void 0 && (o.signing_alg = i.signing_alg), i.signing_secret !== void 0 && (o.signing_secret = i.signing_secret), i.token_lifetime !== void 0 && (o.token_lifetime = i.token_lifetime), i.token_lifetime_for_web !== void 0 && (o.token_lifetime_for_web = i.token_lifetime_for_web), i.scopes !== void 0 && (o.scopes = JSON.stringify(i.scopes)), i.options !== void 0 && (o.options = y`json_patch(COALESCE(${K.options}, '{}'), ${JSON.stringify(i.options)})`), i.metadata !== void 0 && (o.metadata = JSON.stringify(i.metadata)), i.verificationKey !== void 0 && (o.verification_key = i.verificationKey);
|
|
3575
|
-
for (let e of
|
|
3619
|
+
for (let e of br) i[e] !== void 0 && (o[e] = +!!i[e]);
|
|
3576
3620
|
return (await e.update(K).set(o).where(t(a(K.tenant_id, n), a(K.id, r))).returning()).length > 0;
|
|
3577
3621
|
},
|
|
3578
3622
|
async list(o, s) {
|
|
3579
3623
|
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = Math.max(0, Math.floor(Number(c) || 0)), m = Math.min(Math.max(1, Math.floor(Number(l) || 50)), 500), h = [a(K.tenant_id, o)];
|
|
3580
3624
|
if (f) {
|
|
3581
|
-
let e = Te(f,
|
|
3625
|
+
let e = Te(f, vr);
|
|
3582
3626
|
if (e) {
|
|
3583
|
-
let t =
|
|
3627
|
+
let t = vt(K, e, vr, ["name", "identifier"]);
|
|
3584
3628
|
t && h.push(t);
|
|
3585
3629
|
}
|
|
3586
3630
|
}
|
|
3587
|
-
if (
|
|
3631
|
+
if (At(s)) {
|
|
3588
3632
|
let n = {
|
|
3589
3633
|
sortColumn: K.created_at,
|
|
3590
3634
|
idColumn: K.id,
|
|
3591
3635
|
sortOrder: "desc"
|
|
3592
|
-
}, r =
|
|
3636
|
+
}, r = Nt(s, n), i = jt(s), { rows: a, next: o } = Pt(await e.select().from(K).where(t(...h, r)).orderBy(...Mt(n)).limit(i + 1), i, "created_at", "id"), c = a.map(Sr);
|
|
3593
3637
|
return {
|
|
3594
3638
|
resource_servers: c,
|
|
3595
3639
|
start: 0,
|
|
@@ -3599,11 +3643,11 @@ function xr(e) {
|
|
|
3599
3643
|
};
|
|
3600
3644
|
}
|
|
3601
3645
|
let g = e.select().from(K).where(t(...h)).$dynamic();
|
|
3602
|
-
if (d?.sort_by &&
|
|
3646
|
+
if (d?.sort_by && xr.has(d.sort_by)) {
|
|
3603
3647
|
let e = K[d.sort_by];
|
|
3604
3648
|
g = g.orderBy(d.sort_order === "desc" ? i(e) : n(e));
|
|
3605
3649
|
}
|
|
3606
|
-
let _ = (await g.offset(p * m).limit(m)).map(
|
|
3650
|
+
let _ = (await g.offset(p * m).limit(m)).map(Sr);
|
|
3607
3651
|
if (!u) return { resource_servers: _ };
|
|
3608
3652
|
let [v] = await e.select({ count: r() }).from(K).where(t(...h));
|
|
3609
3653
|
return {
|
|
@@ -3620,12 +3664,12 @@ function xr(e) {
|
|
|
3620
3664
|
}
|
|
3621
3665
|
//#endregion
|
|
3622
3666
|
//#region src/adapters/rolePermissions.ts
|
|
3623
|
-
function
|
|
3667
|
+
function wr(e) {
|
|
3624
3668
|
return {
|
|
3625
3669
|
async assign(t, n, r) {
|
|
3626
3670
|
if (r.length === 0) return !0;
|
|
3627
3671
|
let i = (/* @__PURE__ */ new Date()).toISOString();
|
|
3628
|
-
return await e.insert(
|
|
3672
|
+
return await e.insert(W).values(r.map((e) => ({
|
|
3629
3673
|
tenant_id: t,
|
|
3630
3674
|
role_id: n,
|
|
3631
3675
|
resource_server_identifier: e.resource_server_identifier,
|
|
@@ -3634,33 +3678,52 @@ function Sr(e) {
|
|
|
3634
3678
|
}))).onConflictDoNothing(), !0;
|
|
3635
3679
|
},
|
|
3636
3680
|
async list(n, r, i) {
|
|
3637
|
-
|
|
3638
|
-
resource_server_identifier:
|
|
3639
|
-
permission_name:
|
|
3640
|
-
created_at:
|
|
3641
|
-
}).from(
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
}
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3681
|
+
return Tr(e, n, await e.select({
|
|
3682
|
+
resource_server_identifier: W.resource_server_identifier,
|
|
3683
|
+
permission_name: W.permission_name,
|
|
3684
|
+
created_at: W.created_at
|
|
3685
|
+
}).from(W).where(t(a(W.tenant_id, n), a(W.role_id, r))).all());
|
|
3686
|
+
},
|
|
3687
|
+
async listCheckpoint(n, r, i = {}) {
|
|
3688
|
+
let o = {
|
|
3689
|
+
sortColumn: W.resource_server_identifier,
|
|
3690
|
+
idColumn: W.permission_name,
|
|
3691
|
+
sortOrder: "asc"
|
|
3692
|
+
}, s = jt(i), { rows: c, next: l } = Pt(await e.select({
|
|
3693
|
+
role_id: W.role_id,
|
|
3694
|
+
resource_server_identifier: W.resource_server_identifier,
|
|
3695
|
+
permission_name: W.permission_name,
|
|
3696
|
+
created_at: W.created_at
|
|
3697
|
+
}).from(W).where(t(a(W.tenant_id, n), a(W.role_id, r), Nt(i, o))).orderBy(...Mt(o)).limit(s + 1).all(), s, "resource_server_identifier", "permission_name");
|
|
3698
|
+
return {
|
|
3699
|
+
permissions: await Tr(e, n, c),
|
|
3700
|
+
next: l
|
|
3701
|
+
};
|
|
3653
3702
|
},
|
|
3654
3703
|
async remove(n, r, i) {
|
|
3655
3704
|
if (i.length === 0) return !0;
|
|
3656
|
-
let o = i.map((e) => t(a(
|
|
3657
|
-
return await e.delete(
|
|
3705
|
+
let o = i.map((e) => t(a(W.resource_server_identifier, e.resource_server_identifier), a(W.permission_name, e.permission_name)));
|
|
3706
|
+
return await e.delete(W).where(t(a(W.tenant_id, n), a(W.role_id, r), v(...o))).returning(), !0;
|
|
3658
3707
|
}
|
|
3659
3708
|
};
|
|
3660
3709
|
}
|
|
3710
|
+
async function Tr(e, n, r) {
|
|
3711
|
+
let i = [...new Set(r.map((e) => e.resource_server_identifier))], o = /* @__PURE__ */ new Map();
|
|
3712
|
+
if (i.length > 0) {
|
|
3713
|
+
let r = await e.select({
|
|
3714
|
+
identifier: K.identifier,
|
|
3715
|
+
name: K.name
|
|
3716
|
+
}).from(K).where(t(a(K.tenant_id, n), l(K.identifier, i))).all();
|
|
3717
|
+
for (let e of r) o.set(e.identifier, e.name);
|
|
3718
|
+
}
|
|
3719
|
+
return r.map((e) => ({
|
|
3720
|
+
...e,
|
|
3721
|
+
resource_server_name: o.get(e.resource_server_identifier) || e.resource_server_identifier
|
|
3722
|
+
}));
|
|
3723
|
+
}
|
|
3661
3724
|
//#endregion
|
|
3662
3725
|
//#region src/adapters/userPermissions.ts
|
|
3663
|
-
function
|
|
3726
|
+
function Er(e) {
|
|
3664
3727
|
return {
|
|
3665
3728
|
async create(t, n, r, i) {
|
|
3666
3729
|
try {
|
|
@@ -3699,7 +3762,7 @@ function Cr(e) {
|
|
|
3699
3762
|
}
|
|
3700
3763
|
//#endregion
|
|
3701
3764
|
//#region src/adapters/roles.ts
|
|
3702
|
-
function
|
|
3765
|
+
function Dr(e) {
|
|
3703
3766
|
let { tenant_id: t, is_system: n, metadata: r, ...i } = e;
|
|
3704
3767
|
return D({
|
|
3705
3768
|
...i,
|
|
@@ -3707,7 +3770,7 @@ function wr(e) {
|
|
|
3707
3770
|
metadata: Z(r)
|
|
3708
3771
|
});
|
|
3709
3772
|
}
|
|
3710
|
-
function
|
|
3773
|
+
function Or(e) {
|
|
3711
3774
|
return {
|
|
3712
3775
|
async create(t, n) {
|
|
3713
3776
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -3720,43 +3783,43 @@ function Tr(e) {
|
|
|
3720
3783
|
created_at: r,
|
|
3721
3784
|
updated_at: r
|
|
3722
3785
|
};
|
|
3723
|
-
return await e.insert(
|
|
3786
|
+
return await e.insert(U).values(i), Dr({
|
|
3724
3787
|
...i,
|
|
3725
3788
|
tenant_id: t
|
|
3726
3789
|
});
|
|
3727
3790
|
},
|
|
3728
3791
|
async get(n, r) {
|
|
3729
|
-
let i = await e.select().from(
|
|
3730
|
-
return i ?
|
|
3792
|
+
let i = await e.select().from(U).where(t(a(U.tenant_id, n), a(U.id, r))).get();
|
|
3793
|
+
return i ? Dr(i) : null;
|
|
3731
3794
|
},
|
|
3732
3795
|
async update(n, r, i) {
|
|
3733
3796
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
3734
|
-
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(
|
|
3797
|
+
return i.name !== void 0 && (o.name = i.name), i.description !== void 0 && (o.description = i.description), i.is_system !== void 0 && (o.is_system = +!!i.is_system), i.metadata !== void 0 && (o.metadata = JSON.stringify(i.metadata)), (await e.update(U).set(o).where(t(a(U.tenant_id, n), a(U.id, r))).returning()).length > 0;
|
|
3735
3798
|
},
|
|
3736
3799
|
async list(o, s) {
|
|
3737
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
3738
|
-
if (
|
|
3800
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? vt(U, f, ["name"]) : void 0, m = p ? t(a(U.tenant_id, o), p) : a(U.tenant_id, o);
|
|
3801
|
+
if (At(s)) {
|
|
3739
3802
|
let n = {
|
|
3740
|
-
sortColumn:
|
|
3741
|
-
idColumn:
|
|
3803
|
+
sortColumn: U.created_at,
|
|
3804
|
+
idColumn: U.id,
|
|
3742
3805
|
sortOrder: "desc"
|
|
3743
|
-
}, r =
|
|
3806
|
+
}, r = jt(s), { rows: i, next: a } = Pt(await e.select().from(U).where(t(m, Nt(s, n))).orderBy(...Mt(n)).limit(r + 1), r, "created_at");
|
|
3744
3807
|
return {
|
|
3745
|
-
roles: i.map(
|
|
3808
|
+
roles: i.map(Dr),
|
|
3746
3809
|
start: 0,
|
|
3747
3810
|
limit: r,
|
|
3748
3811
|
length: i.length,
|
|
3749
3812
|
next: a
|
|
3750
3813
|
};
|
|
3751
3814
|
}
|
|
3752
|
-
let h = e.select().from(
|
|
3815
|
+
let h = e.select().from(U).where(m).$dynamic();
|
|
3753
3816
|
if (d?.sort_by) {
|
|
3754
|
-
let e =
|
|
3817
|
+
let e = U[d.sort_by];
|
|
3755
3818
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
3756
3819
|
}
|
|
3757
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
3820
|
+
let g = (await h.offset(c * l).limit(l)).map(Dr);
|
|
3758
3821
|
if (!u) return { roles: g };
|
|
3759
|
-
let [_] = await e.select({ count: r() }).from(
|
|
3822
|
+
let [_] = await e.select({ count: r() }).from(U).where(m);
|
|
3760
3823
|
return {
|
|
3761
3824
|
roles: g,
|
|
3762
3825
|
start: c * l,
|
|
@@ -3765,13 +3828,13 @@ function Tr(e) {
|
|
|
3765
3828
|
};
|
|
3766
3829
|
},
|
|
3767
3830
|
async remove(n, r) {
|
|
3768
|
-
return (await e.delete(
|
|
3831
|
+
return (await e.delete(U).where(t(a(U.tenant_id, n), a(U.id, r))).returning()).length > 0;
|
|
3769
3832
|
}
|
|
3770
3833
|
};
|
|
3771
3834
|
}
|
|
3772
3835
|
//#endregion
|
|
3773
3836
|
//#region src/adapters/sessions.ts
|
|
3774
|
-
var
|
|
3837
|
+
var kr = ["created_at_ts", "updated_at_ts"], Ar = [
|
|
3775
3838
|
"expires_at_ts",
|
|
3776
3839
|
"idle_expires_at_ts",
|
|
3777
3840
|
"authenticated_at_ts",
|
|
@@ -3779,7 +3842,7 @@ var Er = ["created_at_ts", "updated_at_ts"], Dr = [
|
|
|
3779
3842
|
"used_at_ts",
|
|
3780
3843
|
"revoked_at_ts"
|
|
3781
3844
|
];
|
|
3782
|
-
function
|
|
3845
|
+
function jr(e) {
|
|
3783
3846
|
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({
|
|
3784
3847
|
created_at_ts: n,
|
|
3785
3848
|
updated_at_ts: r,
|
|
@@ -3789,7 +3852,7 @@ function Or(e) {
|
|
|
3789
3852
|
last_interaction_at_ts: s,
|
|
3790
3853
|
used_at_ts: c,
|
|
3791
3854
|
revoked_at_ts: l
|
|
3792
|
-
}, [...
|
|
3855
|
+
}, [...kr], [...Ar]);
|
|
3793
3856
|
return D({
|
|
3794
3857
|
...f,
|
|
3795
3858
|
...p,
|
|
@@ -3797,10 +3860,10 @@ function Or(e) {
|
|
|
3797
3860
|
clients: Z(d, [])
|
|
3798
3861
|
});
|
|
3799
3862
|
}
|
|
3800
|
-
function
|
|
3863
|
+
function Mr(e, t) {
|
|
3801
3864
|
return Math.max(e ?? 0, t ?? 0);
|
|
3802
3865
|
}
|
|
3803
|
-
function
|
|
3866
|
+
function Nr(e) {
|
|
3804
3867
|
return {
|
|
3805
3868
|
async create(n, r) {
|
|
3806
3869
|
let i = Date.now(), o = {
|
|
@@ -3818,23 +3881,23 @@ function Ar(e) {
|
|
|
3818
3881
|
last_interaction_at_ts: r.last_interaction_at ? E(r.last_interaction_at) : i,
|
|
3819
3882
|
used_at_ts: E(r.used_at),
|
|
3820
3883
|
revoked_at_ts: E(r.revoked_at)
|
|
3821
|
-
}, s = [e.insert(M).values(o)], c =
|
|
3884
|
+
}, s = [e.insert(M).values(o)], c = Mr(o.expires_at_ts, o.idle_expires_at_ts);
|
|
3822
3885
|
return c > 0 && o.login_session_id && s.push(e.update(P).set({
|
|
3823
3886
|
expires_at_ts: c,
|
|
3824
3887
|
updated_at_ts: i
|
|
3825
|
-
}).where(t(a(P.tenant_id, n), a(P.id, o.login_session_id), m(P.expires_at_ts, c)))), await
|
|
3888
|
+
}).where(t(a(P.tenant_id, n), a(P.id, o.login_session_id), m(P.expires_at_ts, c)))), await Tt(e, s), jr({
|
|
3826
3889
|
...o,
|
|
3827
3890
|
tenant_id: n
|
|
3828
3891
|
});
|
|
3829
3892
|
},
|
|
3830
3893
|
async get(n, r) {
|
|
3831
3894
|
let i = await e.select().from(M).where(t(a(M.tenant_id, n), a(M.id, r))).get();
|
|
3832
|
-
return i ?
|
|
3895
|
+
return i ? jr(i) : null;
|
|
3833
3896
|
},
|
|
3834
3897
|
async update(n, r, i) {
|
|
3835
3898
|
let o = { updated_at_ts: Date.now() };
|
|
3836
3899
|
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));
|
|
3837
|
-
let s = await e.update(M).set(o).where(t(a(M.tenant_id, n), a(M.id, r))).returning(), c =
|
|
3900
|
+
let s = await e.update(M).set(o).where(t(a(M.tenant_id, n), a(M.id, r))).returning(), c = Mr(o.expires_at_ts, o.idle_expires_at_ts), l = s[0];
|
|
3838
3901
|
if (c > 0 && l) {
|
|
3839
3902
|
let r = i.login_session_id ?? l.login_session_id;
|
|
3840
3903
|
r && await e.update(P).set({
|
|
@@ -3845,12 +3908,12 @@ function Ar(e) {
|
|
|
3845
3908
|
return s.length > 0;
|
|
3846
3909
|
},
|
|
3847
3910
|
async list(o, s) {
|
|
3848
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
3911
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? vt(M, f, ["user_id", "id"]) : void 0, m = p ? t(a(M.tenant_id, o), p) : a(M.tenant_id, o), h = e.select().from(M).where(m).$dynamic();
|
|
3849
3912
|
if (d?.sort_by) {
|
|
3850
3913
|
let e = M[d.sort_by];
|
|
3851
3914
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
3852
3915
|
}
|
|
3853
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
3916
|
+
let g = (await h.offset(c * l).limit(l)).map(jr);
|
|
3854
3917
|
if (!u) return { sessions: g };
|
|
3855
3918
|
let [_] = await e.select({ count: r() }).from(M).where(m);
|
|
3856
3919
|
return {
|
|
@@ -3867,7 +3930,7 @@ function Ar(e) {
|
|
|
3867
3930
|
}
|
|
3868
3931
|
//#endregion
|
|
3869
3932
|
//#region src/adapters/tenants.ts
|
|
3870
|
-
var
|
|
3933
|
+
var Pr = [
|
|
3871
3934
|
"session_cookie",
|
|
3872
3935
|
"enabled_locales",
|
|
3873
3936
|
"error_page",
|
|
@@ -3883,25 +3946,25 @@ var jr = [
|
|
|
3883
3946
|
"acr_values_supported",
|
|
3884
3947
|
"mtls",
|
|
3885
3948
|
"mfa"
|
|
3886
|
-
],
|
|
3949
|
+
], Fr = [
|
|
3887
3950
|
"allow_organization_name_in_authentication_api",
|
|
3888
3951
|
"customize_mfa_in_postlogin_action",
|
|
3889
3952
|
"pushed_authorization_requests_supported",
|
|
3890
3953
|
"authorization_response_iss_parameter_supported"
|
|
3891
3954
|
];
|
|
3892
|
-
function
|
|
3955
|
+
function Ir(e) {
|
|
3893
3956
|
let t = { ...e };
|
|
3894
|
-
for (let e of
|
|
3895
|
-
for (let e of
|
|
3957
|
+
for (let e of Pr) typeof t[e] == "string" && (t[e] = Z(t[e]));
|
|
3958
|
+
for (let e of Fr) t[e] !== void 0 && t[e] !== null && (t[e] = t[e] === 1);
|
|
3896
3959
|
return D(t);
|
|
3897
3960
|
}
|
|
3898
|
-
function
|
|
3961
|
+
function Lr(e) {
|
|
3899
3962
|
let t = { ...e };
|
|
3900
|
-
le(e,
|
|
3901
|
-
for (let n of
|
|
3963
|
+
le(e, Pr, t);
|
|
3964
|
+
for (let n of Fr) e[n] !== void 0 && (t[n] = +!!e[n]);
|
|
3902
3965
|
return ce(t);
|
|
3903
3966
|
}
|
|
3904
|
-
function
|
|
3967
|
+
function Rr(e) {
|
|
3905
3968
|
return {
|
|
3906
3969
|
async create(t) {
|
|
3907
3970
|
let n = {
|
|
@@ -3909,7 +3972,7 @@ function Fr(e) {
|
|
|
3909
3972
|
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3910
3973
|
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3911
3974
|
...t
|
|
3912
|
-
}, r =
|
|
3975
|
+
}, r = Lr(n);
|
|
3913
3976
|
try {
|
|
3914
3977
|
await e.insert(O).values(r);
|
|
3915
3978
|
} catch (e) {
|
|
@@ -3920,15 +3983,15 @@ function Fr(e) {
|
|
|
3920
3983
|
},
|
|
3921
3984
|
async get(t) {
|
|
3922
3985
|
let n = await e.select().from(O).where(a(O.id, t)).get();
|
|
3923
|
-
return n ?
|
|
3986
|
+
return n ? Ir(n) : null;
|
|
3924
3987
|
},
|
|
3925
3988
|
async list(t) {
|
|
3926
|
-
let { page: a = 0, per_page: o = 50, include_totals: s = !1, sort: c, q: l } = t || {}, u = l ?
|
|
3989
|
+
let { page: a = 0, per_page: o = 50, include_totals: s = !1, sort: c, q: l } = t || {}, u = l ? vt(O, l, ["friendly_name"]) : void 0, d = e.select().from(O).$dynamic();
|
|
3927
3990
|
if (u && (d = d.where(u)), c?.sort_by) {
|
|
3928
3991
|
let e = O[c.sort_by];
|
|
3929
3992
|
e && (d = d.orderBy(c.sort_order === "desc" ? i(e) : n(e)));
|
|
3930
3993
|
}
|
|
3931
|
-
let f = (await d.offset(a * o).limit(o)).map(
|
|
3994
|
+
let f = (await d.offset(a * o).limit(o)).map(Ir);
|
|
3932
3995
|
if (!s) return { tenants: f };
|
|
3933
3996
|
let p = e.select({ count: r() }).from(O).$dynamic();
|
|
3934
3997
|
u && (p = p.where(u));
|
|
@@ -3941,7 +4004,7 @@ function Fr(e) {
|
|
|
3941
4004
|
};
|
|
3942
4005
|
},
|
|
3943
4006
|
async update(t, n) {
|
|
3944
|
-
let r =
|
|
4007
|
+
let r = Lr({
|
|
3945
4008
|
...n,
|
|
3946
4009
|
id: t,
|
|
3947
4010
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -3955,38 +4018,38 @@ function Fr(e) {
|
|
|
3955
4018
|
}
|
|
3956
4019
|
//#endregion
|
|
3957
4020
|
//#region src/adapters/themes.ts
|
|
3958
|
-
var
|
|
4021
|
+
var zr = [
|
|
3959
4022
|
"colors",
|
|
3960
4023
|
"borders",
|
|
3961
4024
|
"fonts",
|
|
3962
4025
|
"page_background",
|
|
3963
4026
|
"widget"
|
|
3964
4027
|
];
|
|
3965
|
-
function
|
|
3966
|
-
let { tenant_id: t, ...n } = e, r =
|
|
4028
|
+
function Br(e) {
|
|
4029
|
+
let { tenant_id: t, ...n } = e, r = ht(n, zr);
|
|
3967
4030
|
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);
|
|
3968
4031
|
}
|
|
3969
|
-
function
|
|
4032
|
+
function Vr(e) {
|
|
3970
4033
|
return {
|
|
3971
4034
|
async create(t, n, r, i) {
|
|
3972
4035
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = a?.id || r || b(), c = {
|
|
3973
|
-
...
|
|
4036
|
+
...mt(n),
|
|
3974
4037
|
tenant_id: t,
|
|
3975
4038
|
themeId: s,
|
|
3976
4039
|
created_at: a?.created_at ?? o,
|
|
3977
4040
|
updated_at: a?.updated_at ?? o
|
|
3978
4041
|
};
|
|
3979
|
-
return await e.insert(Qe).values(c),
|
|
4042
|
+
return await e.insert(Qe).values(c), Br({
|
|
3980
4043
|
...c,
|
|
3981
4044
|
tenant_id: t
|
|
3982
4045
|
});
|
|
3983
4046
|
},
|
|
3984
4047
|
async get(n, r) {
|
|
3985
4048
|
let i = await e.select().from(Qe).where(t(a(Qe.tenant_id, n), a(Qe.themeId, r))).get();
|
|
3986
|
-
return i ?
|
|
4049
|
+
return i ? Br(i) : null;
|
|
3987
4050
|
},
|
|
3988
4051
|
async update(n, r, i) {
|
|
3989
|
-
let o =
|
|
4052
|
+
let o = mt(i);
|
|
3990
4053
|
return o.updated_at = (/* @__PURE__ */ new Date()).toISOString(), await e.update(Qe).set(o).where(t(a(Qe.tenant_id, n), a(Qe.themeId, r))), !0;
|
|
3991
4054
|
},
|
|
3992
4055
|
async remove(n, r) {
|
|
@@ -3996,7 +4059,7 @@ function Rr(e) {
|
|
|
3996
4059
|
}
|
|
3997
4060
|
//#endregion
|
|
3998
4061
|
//#region src/adapters/universalLoginTemplates.ts
|
|
3999
|
-
function
|
|
4062
|
+
function Hr(e) {
|
|
4000
4063
|
return {
|
|
4001
4064
|
async get(t) {
|
|
4002
4065
|
let n = await e.select({ body: Ze.body }).from(Ze).where(a(Ze.tenant_id, t)).get();
|
|
@@ -4024,11 +4087,11 @@ function zr(e) {
|
|
|
4024
4087
|
}
|
|
4025
4088
|
//#endregion
|
|
4026
4089
|
//#region src/adapters/userActivity.ts
|
|
4027
|
-
function
|
|
4090
|
+
function Ur(e) {
|
|
4028
4091
|
let t = {};
|
|
4029
4092
|
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;
|
|
4030
4093
|
}
|
|
4031
|
-
function
|
|
4094
|
+
function Wr(e) {
|
|
4032
4095
|
return {
|
|
4033
4096
|
async get(n, r) {
|
|
4034
4097
|
let i = await e.select().from(He).where(t(a(He.tenant_id, n), a(He.user_id, r))).get();
|
|
@@ -4042,7 +4105,7 @@ function Vr(e) {
|
|
|
4042
4105
|
} : null;
|
|
4043
4106
|
},
|
|
4044
4107
|
async upsert(t, n, r) {
|
|
4045
|
-
let i =
|
|
4108
|
+
let i = Ur(r), a = e.insert(He).values({
|
|
4046
4109
|
tenant_id: t,
|
|
4047
4110
|
user_id: n,
|
|
4048
4111
|
login_count: 0,
|
|
@@ -4061,13 +4124,13 @@ function Vr(e) {
|
|
|
4061
4124
|
}
|
|
4062
4125
|
//#endregion
|
|
4063
4126
|
//#region src/adapters/outbox.ts
|
|
4064
|
-
function
|
|
4127
|
+
function Gr(e) {
|
|
4065
4128
|
return {
|
|
4066
4129
|
...e,
|
|
4067
4130
|
payload: Z(e.payload, {})
|
|
4068
4131
|
};
|
|
4069
4132
|
}
|
|
4070
|
-
function
|
|
4133
|
+
function Kr(e, t, n, r) {
|
|
4071
4134
|
return e.insert(J).values({
|
|
4072
4135
|
id: t,
|
|
4073
4136
|
tenant_id: n,
|
|
@@ -4088,18 +4151,18 @@ function Ur(e, t, n, r) {
|
|
|
4088
4151
|
claim_expires_at: null
|
|
4089
4152
|
});
|
|
4090
4153
|
}
|
|
4091
|
-
function
|
|
4154
|
+
function qr(e) {
|
|
4092
4155
|
return {
|
|
4093
4156
|
async create(t, n) {
|
|
4094
4157
|
let r = b();
|
|
4095
|
-
return await
|
|
4158
|
+
return await Kr(e, r, t, n), r;
|
|
4096
4159
|
},
|
|
4097
4160
|
async getByIds(t) {
|
|
4098
|
-
return t.length === 0 ? [] : (await e.select().from(J).where(l(J.id, t)).all()).map(
|
|
4161
|
+
return t.length === 0 ? [] : (await e.select().from(J).where(l(J.id, t)).all()).map(Gr);
|
|
4099
4162
|
},
|
|
4100
4163
|
async getUnprocessed(n) {
|
|
4101
4164
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
4102
|
-
return (await e.select().from(J).where(t(f(J.processed_at), v(f(J.next_retry_at), h(J.next_retry_at, r)), v(f(J.claimed_by), h(J.claim_expires_at, r)))).orderBy(J.created_at, J.id).limit(n).all()).map(
|
|
4165
|
+
return (await e.select().from(J).where(t(f(J.processed_at), v(f(J.next_retry_at), h(J.next_retry_at, r)), v(f(J.claimed_by), h(J.claim_expires_at, r)))).orderBy(J.created_at, J.id).limit(n).all()).map(Gr);
|
|
4103
4166
|
},
|
|
4104
4167
|
async claimEvents(n, r, i) {
|
|
4105
4168
|
if (n.length === 0) return [];
|
|
@@ -4174,10 +4237,10 @@ function Wr(e) {
|
|
|
4174
4237
|
}
|
|
4175
4238
|
//#endregion
|
|
4176
4239
|
//#region src/adapters/users.ts
|
|
4177
|
-
function
|
|
4178
|
-
return (n?.outboxEvents ?? []).map((n) =>
|
|
4240
|
+
function Jr(e, t, n) {
|
|
4241
|
+
return (n?.outboxEvents ?? []).map((n) => Kr(e, n.id, t, n));
|
|
4179
4242
|
}
|
|
4180
|
-
var
|
|
4243
|
+
var Yr = [
|
|
4181
4244
|
"user_id",
|
|
4182
4245
|
"email",
|
|
4183
4246
|
"email_verified",
|
|
@@ -4199,23 +4262,23 @@ var Kr = [
|
|
|
4199
4262
|
"login_count",
|
|
4200
4263
|
"created_at",
|
|
4201
4264
|
"updated_at"
|
|
4202
|
-
],
|
|
4265
|
+
], Xr = [
|
|
4203
4266
|
"email",
|
|
4204
4267
|
"name",
|
|
4205
4268
|
"phone_number",
|
|
4206
4269
|
"user_id"
|
|
4207
|
-
],
|
|
4270
|
+
], Zr = new Set([
|
|
4208
4271
|
"last_login",
|
|
4209
4272
|
"last_ip",
|
|
4210
4273
|
"login_count"
|
|
4211
|
-
]),
|
|
4274
|
+
]), Qr = o(A), $r = o(He), ei = Object.fromEntries(Yr.map((e) => [e, e === "login_count" ? {
|
|
4212
4275
|
coalesce: He.login_count,
|
|
4213
4276
|
defaultValue: 0
|
|
4214
|
-
} :
|
|
4215
|
-
function
|
|
4277
|
+
} : Zr.has(e) ? $r[e] : Qr[e]]));
|
|
4278
|
+
function ti() {
|
|
4216
4279
|
return t(a(He.tenant_id, A.tenant_id), a(He.user_id, A.user_id));
|
|
4217
4280
|
}
|
|
4218
|
-
function
|
|
4281
|
+
function ni(e, t) {
|
|
4219
4282
|
return {
|
|
4220
4283
|
...e,
|
|
4221
4284
|
last_login: t?.last_login,
|
|
@@ -4223,7 +4286,7 @@ function $r(e, t) {
|
|
|
4223
4286
|
login_count: t?.login_count ?? 0
|
|
4224
4287
|
};
|
|
4225
4288
|
}
|
|
4226
|
-
function
|
|
4289
|
+
function ri(e, t) {
|
|
4227
4290
|
let n = {
|
|
4228
4291
|
connection: e.connection,
|
|
4229
4292
|
provider: e.provider,
|
|
@@ -4236,8 +4299,8 @@ function ei(e, t) {
|
|
|
4236
4299
|
...typeof e.profileData == "string" ? Z(e.profileData, {}) : {}
|
|
4237
4300
|
}, n;
|
|
4238
4301
|
}
|
|
4239
|
-
function
|
|
4240
|
-
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 =
|
|
4302
|
+
function ii(e, t = []) {
|
|
4303
|
+
let { tenant_id: n, app_metadata: r, user_metadata: i, address: a, email_verified: o, phone_verified: s, is_social: c, blocked: l, linked_to: u, profileData: d, ...f } = e, p = ri(e, !0), m = t.map((e) => ri(e, !1));
|
|
4241
4304
|
return D({
|
|
4242
4305
|
...f,
|
|
4243
4306
|
email: e.email || "",
|
|
@@ -4251,7 +4314,7 @@ function ti(e, t = []) {
|
|
|
4251
4314
|
identities: [p, ...m]
|
|
4252
4315
|
});
|
|
4253
4316
|
}
|
|
4254
|
-
function
|
|
4317
|
+
function ai(e) {
|
|
4255
4318
|
let o = async (t, n, r) => {
|
|
4256
4319
|
let i = (/* @__PURE__ */ new Date()).toISOString(), a = {
|
|
4257
4320
|
user_id: n.user_id,
|
|
@@ -4305,12 +4368,12 @@ function ni(e) {
|
|
|
4305
4368
|
created_at: i,
|
|
4306
4369
|
updated_at: i
|
|
4307
4370
|
}));
|
|
4308
|
-
for (let n of
|
|
4309
|
-
c.length > 1 ? await
|
|
4371
|
+
for (let n of Jr(e, t, r)) c.push(n);
|
|
4372
|
+
c.length > 1 ? await Tt(e, c) : await e.insert(A).values(a);
|
|
4310
4373
|
} catch (e) {
|
|
4311
4374
|
throw e?.message?.includes("UNIQUE constraint") || e?.message?.includes("AlreadyExists") ? new Le(409, { message: "User already exists" }) : (console.error("User upsert failed:", e?.code, e?.message), new Le(500, { message: "Internal server error" }));
|
|
4312
4375
|
}
|
|
4313
|
-
return
|
|
4376
|
+
return ii({
|
|
4314
4377
|
...a,
|
|
4315
4378
|
last_login: n.last_login,
|
|
4316
4379
|
last_ip: n.last_ip,
|
|
@@ -4321,10 +4384,10 @@ function ni(e) {
|
|
|
4321
4384
|
create: o,
|
|
4322
4385
|
rawCreate: o,
|
|
4323
4386
|
async get(n, r) {
|
|
4324
|
-
let i = await e.select().from(A).leftJoin(He,
|
|
4387
|
+
let i = await e.select().from(A).leftJoin(He, ti()).where(t(a(A.tenant_id, n), a(A.user_id, r))).get();
|
|
4325
4388
|
if (!i) return null;
|
|
4326
4389
|
let o = await e.select().from(A).where(t(a(A.tenant_id, n), a(A.linked_to, r))).all();
|
|
4327
|
-
return
|
|
4390
|
+
return ii(ni(i.users, i.user_activity), o);
|
|
4328
4391
|
},
|
|
4329
4392
|
async update(n, r, i, o) {
|
|
4330
4393
|
let s = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -4351,8 +4414,8 @@ function ni(e) {
|
|
|
4351
4414
|
"zoneinfo"
|
|
4352
4415
|
]) i[e] !== void 0 && (s[e] = i[e]);
|
|
4353
4416
|
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));
|
|
4354
|
-
let c = e.update(A).set(s).where(t(a(A.tenant_id, n), a(A.user_id, r))).returning(), l =
|
|
4355
|
-
return u = l.length > 0 ? (await
|
|
4417
|
+
let c = e.update(A).set(s).where(t(a(A.tenant_id, n), a(A.user_id, r))).returning(), l = Jr(e, n, o), u;
|
|
4418
|
+
return u = l.length > 0 ? (await Tt(e, [c, ...l]))[0] : await c, !Array.isArray(u) || u.length === 0 ? !1 : ((i.last_login !== void 0 || i.last_ip !== void 0 || i.login_count !== void 0) && await Wr(e).upsert(n, r, {
|
|
4356
4419
|
last_login: i.last_login,
|
|
4357
4420
|
last_ip: i.last_ip,
|
|
4358
4421
|
login_count: i.login_count
|
|
@@ -4361,24 +4424,24 @@ function ni(e) {
|
|
|
4361
4424
|
async list(o, s) {
|
|
4362
4425
|
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)];
|
|
4363
4426
|
if (m) {
|
|
4364
|
-
let e = Te(m,
|
|
4427
|
+
let e = Te(m, Yr);
|
|
4365
4428
|
if (e) {
|
|
4366
|
-
let t =
|
|
4429
|
+
let t = vt(ei, e, Xr);
|
|
4367
4430
|
t && h.push(t);
|
|
4368
4431
|
}
|
|
4369
4432
|
}
|
|
4370
4433
|
let g = t(...h), _ = async (n) => {
|
|
4371
4434
|
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))) : [];
|
|
4372
|
-
return n.map((e) =>
|
|
4435
|
+
return n.map((e) => ii(e, i.filter((t) => t.linked_to === e.user_id)));
|
|
4373
4436
|
};
|
|
4374
|
-
if (
|
|
4437
|
+
if (At(s)) {
|
|
4375
4438
|
if (p?.sort_by && p.sort_by !== "created_at") throw new Le(400, { message: `Sorting by ${p.sort_by} is not supported with checkpoint pagination (from/take); only created_at is` });
|
|
4376
4439
|
let n = p?.sort_order === "asc" ? "asc" : "desc", r = {
|
|
4377
4440
|
sortColumn: A.created_at,
|
|
4378
4441
|
idColumn: A.user_id,
|
|
4379
4442
|
sortOrder: n,
|
|
4380
4443
|
sortKey: `created_at:${n}`
|
|
4381
|
-
}, i =
|
|
4444
|
+
}, i = jt(s), a = Nt(s, r), { rows: o, next: c } = Pt((await e.select().from(A).leftJoin(He, ti()).where(a ? t(g, a) : g).orderBy(...Mt(r)).limit(i + 1)).map((e) => ni(e.users, e.user_activity)), i, "created_at", "user_id", r.sortKey), l = await _(o);
|
|
4382
4445
|
return {
|
|
4383
4446
|
users: l,
|
|
4384
4447
|
start: 0,
|
|
@@ -4387,15 +4450,15 @@ function ni(e) {
|
|
|
4387
4450
|
next: c
|
|
4388
4451
|
};
|
|
4389
4452
|
}
|
|
4390
|
-
let v = e.select().from(A).leftJoin(He,
|
|
4453
|
+
let v = e.select().from(A).leftJoin(He, ti()).where(g).$dynamic();
|
|
4391
4454
|
if (p?.sort_by) {
|
|
4392
|
-
let e =
|
|
4455
|
+
let e = ei[p.sort_by];
|
|
4393
4456
|
if (e) {
|
|
4394
|
-
let t =
|
|
4457
|
+
let t = gt(e) ? _t(e) : e;
|
|
4395
4458
|
v = v.orderBy(p.sort_order === "desc" ? i(t) : n(t));
|
|
4396
4459
|
}
|
|
4397
4460
|
}
|
|
4398
|
-
let [y, ee] = await Promise.all([v.offset(c * u).limit(u), d ? e.select({ count: r() }).from(A).leftJoin(He,
|
|
4461
|
+
let [y, ee] = await Promise.all([v.offset(c * u).limit(u), d ? e.select({ count: r() }).from(A).leftJoin(He, ti()).where(g) : void 0]), b = await _(y.map((e) => ni(e.users, e.user_activity)));
|
|
4399
4462
|
if (!ee) return { users: b };
|
|
4400
4463
|
let [te] = ee;
|
|
4401
4464
|
return {
|
|
@@ -4407,14 +4470,14 @@ function ni(e) {
|
|
|
4407
4470
|
},
|
|
4408
4471
|
async remove(n, r, i) {
|
|
4409
4472
|
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 = [
|
|
4410
|
-
e.delete(
|
|
4473
|
+
e.delete(lt).where(t(a(lt.tenant_id, n), l(lt.user_id, u))),
|
|
4411
4474
|
e.delete(j).where(t(a(j.tenant_id, n), l(j.user_id, u))),
|
|
4412
4475
|
e.delete(He).where(t(a(He.tenant_id, n), l(He.user_id, u))),
|
|
4413
4476
|
e.delete(A).where(t(a(A.tenant_id, n), l(A.user_id, c))),
|
|
4414
4477
|
e.delete(A).where(t(a(A.tenant_id, n), a(A.user_id, r))).returning()
|
|
4415
4478
|
], f = d.length - 1;
|
|
4416
|
-
if (s) for (let t of
|
|
4417
|
-
let p = (await
|
|
4479
|
+
if (s) for (let t of Jr(e, n, i)) d.push(t);
|
|
4480
|
+
let p = (await Tt(e, d))[f];
|
|
4418
4481
|
return Array.isArray(p) && p.length > 0;
|
|
4419
4482
|
},
|
|
4420
4483
|
async unlink(n, r, i, o) {
|
|
@@ -4425,7 +4488,7 @@ function ni(e) {
|
|
|
4425
4488
|
}
|
|
4426
4489
|
//#endregion
|
|
4427
4490
|
//#region src/adapters/userRoles.ts
|
|
4428
|
-
function
|
|
4491
|
+
function oi(e) {
|
|
4429
4492
|
return {
|
|
4430
4493
|
async create(t, n, r, i) {
|
|
4431
4494
|
try {
|
|
@@ -4447,7 +4510,7 @@ function ri(e) {
|
|
|
4447
4510
|
o !== void 0 && s.push(a(G.organization_id, o));
|
|
4448
4511
|
let c = await e.select({ role_id: G.role_id }).from(G).where(t(...s)).all();
|
|
4449
4512
|
return c.length === 0 ? [] : (await Promise.all(c.map(async (r) => {
|
|
4450
|
-
let i = await e.select().from(
|
|
4513
|
+
let i = await e.select().from(U).where(t(a(U.tenant_id, n), a(U.id, r.role_id))).get();
|
|
4451
4514
|
if (!i) return null;
|
|
4452
4515
|
let { tenant_id: o, is_system: s, metadata: c, ...l } = i;
|
|
4453
4516
|
return D({
|
|
@@ -4459,12 +4522,12 @@ function ri(e) {
|
|
|
4459
4522
|
},
|
|
4460
4523
|
async listUsers(r, i, o) {
|
|
4461
4524
|
let s = t(a(G.tenant_id, r), a(G.role_id, i));
|
|
4462
|
-
if (
|
|
4525
|
+
if (At(o)) {
|
|
4463
4526
|
let n = {
|
|
4464
4527
|
sortColumn: G.user_id,
|
|
4465
4528
|
idColumn: G.user_id,
|
|
4466
4529
|
sortOrder: "asc"
|
|
4467
|
-
}, r =
|
|
4530
|
+
}, r = Nt(o, n), i = jt(o), { rows: a, next: c } = Pt(await e.selectDistinct({ user_id: G.user_id }).from(G).where(r ? t(s, r) : s).orderBy(...Mt(n)).limit(i + 1).all(), i, "user_id", "user_id");
|
|
4468
4531
|
return {
|
|
4469
4532
|
userIds: a.map((e) => e.user_id),
|
|
4470
4533
|
start: 0,
|
|
@@ -4488,7 +4551,7 @@ function ri(e) {
|
|
|
4488
4551
|
}
|
|
4489
4552
|
//#endregion
|
|
4490
4553
|
//#region src/adapters/userOrganizations.ts
|
|
4491
|
-
function
|
|
4554
|
+
function si(e) {
|
|
4492
4555
|
return {
|
|
4493
4556
|
async create(t, n) {
|
|
4494
4557
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -4500,7 +4563,7 @@ function ii(e) {
|
|
|
4500
4563
|
updated_at: r
|
|
4501
4564
|
};
|
|
4502
4565
|
try {
|
|
4503
|
-
await e.insert(
|
|
4566
|
+
await e.insert(H).values(i);
|
|
4504
4567
|
} catch (e) {
|
|
4505
4568
|
throw e?.message?.includes("UNIQUE constraint") || e?.message?.includes("duplicate key") ? new Le(409, { message: "User organization already exists" }) : e;
|
|
4506
4569
|
}
|
|
@@ -4508,31 +4571,31 @@ function ii(e) {
|
|
|
4508
4571
|
return o;
|
|
4509
4572
|
},
|
|
4510
4573
|
async get(n, r) {
|
|
4511
|
-
let i = await e.select().from(
|
|
4574
|
+
let i = await e.select().from(H).where(t(a(H.tenant_id, n), a(H.id, r))).get();
|
|
4512
4575
|
if (!i) return null;
|
|
4513
4576
|
let { tenant_id: o, ...s } = i;
|
|
4514
4577
|
return s;
|
|
4515
4578
|
},
|
|
4516
4579
|
async update(n, r, i) {
|
|
4517
4580
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
4518
|
-
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(
|
|
4581
|
+
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(H).set(o).where(t(a(H.tenant_id, n), a(H.id, r))).returning()).length > 0;
|
|
4519
4582
|
},
|
|
4520
4583
|
async list(n, o) {
|
|
4521
|
-
let { include_totals: s = !1, q: c } = o || {}, l = a(
|
|
4584
|
+
let { include_totals: s = !1, q: c } = o || {}, l = a(H.tenant_id, n), u = l;
|
|
4522
4585
|
if (c) {
|
|
4523
|
-
let e =
|
|
4586
|
+
let e = vt(H, c, ["user_id", "organization_id"]);
|
|
4524
4587
|
e && (u = t(l, e));
|
|
4525
4588
|
}
|
|
4526
4589
|
let d = (e) => {
|
|
4527
4590
|
let { tenant_id: t, ...n } = e;
|
|
4528
4591
|
return n;
|
|
4529
4592
|
};
|
|
4530
|
-
if (
|
|
4593
|
+
if (At(o)) {
|
|
4531
4594
|
let n = {
|
|
4532
|
-
sortColumn:
|
|
4533
|
-
idColumn:
|
|
4595
|
+
sortColumn: H.created_at,
|
|
4596
|
+
idColumn: H.id,
|
|
4534
4597
|
sortOrder: "desc"
|
|
4535
|
-
}, r =
|
|
4598
|
+
}, r = Nt(o, n), i = jt(o), { rows: a, next: s } = Pt((await e.select().from(H).where(r ? t(u, r) : u).orderBy(...Mt(n)).limit(i + 1)).map(d), i, "created_at");
|
|
4536
4599
|
return {
|
|
4537
4600
|
userOrganizations: a,
|
|
4538
4601
|
start: 0,
|
|
@@ -4541,9 +4604,9 @@ function ii(e) {
|
|
|
4541
4604
|
next: s
|
|
4542
4605
|
};
|
|
4543
4606
|
}
|
|
4544
|
-
let f = o?.page ?? 0, p = o?.per_page ?? 50, m = f * p, h = (await e.select().from(
|
|
4607
|
+
let f = o?.page ?? 0, p = o?.per_page ?? 50, m = f * p, h = (await e.select().from(H).where(u).orderBy(i(H.created_at), i(H.id)).offset(m).limit(p)).map(d);
|
|
4545
4608
|
if (!s) return { userOrganizations: h };
|
|
4546
|
-
let [g] = await e.select({ count: r() }).from(
|
|
4609
|
+
let [g] = await e.select({ count: r() }).from(H).where(u);
|
|
4547
4610
|
return {
|
|
4548
4611
|
userOrganizations: h,
|
|
4549
4612
|
start: m,
|
|
@@ -4552,8 +4615,8 @@ function ii(e) {
|
|
|
4552
4615
|
};
|
|
4553
4616
|
},
|
|
4554
4617
|
async listUserOrganizations(n, i, o) {
|
|
4555
|
-
let { page: s = 0, per_page: c = 50, include_totals: l = !1 } = o || {}, u = await e.select().from(
|
|
4556
|
-
let i = await e.select().from(
|
|
4618
|
+
let { page: s = 0, per_page: c = 50, include_totals: l = !1 } = o || {}, u = await e.select().from(H).where(t(a(H.tenant_id, n), a(H.user_id, i))).offset(s * c).limit(c).all(), d = (await Promise.all(u.map(async (r) => {
|
|
4619
|
+
let i = await e.select().from(V).where(t(a(V.tenant_id, n), a(V.id, r.organization_id))).get();
|
|
4557
4620
|
if (!i) return null;
|
|
4558
4621
|
let { tenant_id: o, branding: s, metadata: c, enabled_connections: l, token_quota: u, ...d } = i;
|
|
4559
4622
|
return D({
|
|
@@ -4565,7 +4628,7 @@ function ii(e) {
|
|
|
4565
4628
|
});
|
|
4566
4629
|
}))).filter(Boolean);
|
|
4567
4630
|
if (!l) return { organizations: d };
|
|
4568
|
-
let [f] = await e.select({ count: r() }).from(
|
|
4631
|
+
let [f] = await e.select({ count: r() }).from(H).where(t(a(H.tenant_id, n), a(H.user_id, i)));
|
|
4569
4632
|
return {
|
|
4570
4633
|
organizations: d,
|
|
4571
4634
|
start: s * c,
|
|
@@ -4574,25 +4637,25 @@ function ii(e) {
|
|
|
4574
4637
|
};
|
|
4575
4638
|
},
|
|
4576
4639
|
async remove(n, r) {
|
|
4577
|
-
return (await e.delete(
|
|
4640
|
+
return (await e.delete(H).where(t(a(H.tenant_id, n), a(H.id, r))).returning()).length > 0;
|
|
4578
4641
|
}
|
|
4579
4642
|
};
|
|
4580
4643
|
}
|
|
4581
4644
|
//#endregion
|
|
4582
4645
|
//#region src/adapters/stats.ts
|
|
4583
|
-
var
|
|
4584
|
-
function
|
|
4646
|
+
var ci = ["s"], li = ["pwd_leak"];
|
|
4647
|
+
function ui(e) {
|
|
4585
4648
|
return /^\d{8}$/.test(e) ? `${e.slice(0, 4)}-${e.slice(4, 6)}-${e.slice(6, 8)}` : e;
|
|
4586
4649
|
}
|
|
4587
|
-
function
|
|
4650
|
+
function di(e) {
|
|
4588
4651
|
return {
|
|
4589
4652
|
async getDaily(n, r) {
|
|
4590
|
-
let i = /* @__PURE__ */ new Date(), o = r?.from ?
|
|
4653
|
+
let i = /* @__PURE__ */ new Date(), o = r?.from ? ui(r.from) : (/* @__PURE__ */ new Date(i.getTime() - 720 * 60 * 60 * 1e3)).toISOString().split("T")[0], s = r?.to ? ui(r.to) : i.toISOString().split("T")[0];
|
|
4591
4654
|
return (await e.select({
|
|
4592
4655
|
date: y`substr(${q.date}, 1, 10)`.as("date"),
|
|
4593
|
-
logins: y`SUM(CASE WHEN ${q.type} IN (${y.join(
|
|
4656
|
+
logins: y`SUM(CASE WHEN ${q.type} IN (${y.join(ci.map((e) => y`${e}`), y`, `)}) THEN 1 ELSE 0 END)`.as("logins"),
|
|
4594
4657
|
signups: y`SUM(CASE WHEN ${q.type} = 'ss' THEN 1 ELSE 0 END)`.as("signups"),
|
|
4595
|
-
leaked_passwords: y`SUM(CASE WHEN ${q.type} IN (${y.join(
|
|
4658
|
+
leaked_passwords: y`SUM(CASE WHEN ${q.type} IN (${y.join(li.map((e) => y`${e}`), y`, `)}) THEN 1 ELSE 0 END)`.as("leaked_passwords")
|
|
4596
4659
|
}).from(q).where(t(a(q.tenant_id, n), c(q.date, o), h(q.date, `${s}T23:59:59.999Z`))).groupBy(y`substr(${q.date}, 1, 10)`).orderBy(y`substr(${q.date}, 1, 10)`).all()).map((e) => ({
|
|
4597
4660
|
date: e.date,
|
|
4598
4661
|
logins: Number(e.logins) || 0,
|
|
@@ -4603,14 +4666,14 @@ function ci(e) {
|
|
|
4603
4666
|
}));
|
|
4604
4667
|
},
|
|
4605
4668
|
async getActiveUsers(n) {
|
|
4606
|
-
let r = (/* @__PURE__ */ new Date(Date.now() - 720 * 60 * 60 * 1e3)).toISOString(), [i] = await e.select({ count: y`COUNT(DISTINCT ${q.user_id})`.as("count") }).from(q).where(t(a(q.tenant_id, n), c(q.date, r), y`${q.type} IN (${y.join(
|
|
4669
|
+
let r = (/* @__PURE__ */ new Date(Date.now() - 720 * 60 * 60 * 1e3)).toISOString(), [i] = await e.select({ count: y`COUNT(DISTINCT ${q.user_id})`.as("count") }).from(q).where(t(a(q.tenant_id, n), c(q.date, r), y`${q.type} IN (${y.join(ci.map((e) => y`${e}`), y`, `)})`));
|
|
4607
4670
|
return Number(i?.count) || 0;
|
|
4608
4671
|
}
|
|
4609
4672
|
};
|
|
4610
4673
|
}
|
|
4611
4674
|
//#endregion
|
|
4612
4675
|
//#region src/adapters/analytics.ts
|
|
4613
|
-
var
|
|
4676
|
+
var fi = {
|
|
4614
4677
|
"active-users": ["s", "seacft"],
|
|
4615
4678
|
logins: [
|
|
4616
4679
|
"s",
|
|
@@ -4640,7 +4703,7 @@ var li = {
|
|
|
4640
4703
|
"fvr"
|
|
4641
4704
|
],
|
|
4642
4705
|
"codes-sent": ["cls", "cs"]
|
|
4643
|
-
},
|
|
4706
|
+
}, pi = {
|
|
4644
4707
|
"active-users": {
|
|
4645
4708
|
alias: "active_users",
|
|
4646
4709
|
type: "UInt64",
|
|
@@ -4697,7 +4760,7 @@ var li = {
|
|
|
4697
4760
|
agg: "count"
|
|
4698
4761
|
}
|
|
4699
4762
|
};
|
|
4700
|
-
function
|
|
4763
|
+
function mi(e) {
|
|
4701
4764
|
switch (e) {
|
|
4702
4765
|
case "hour": return y`substr(${q.date}, 1, 13)`;
|
|
4703
4766
|
case "month": return y`substr(${q.date}, 1, 7)`;
|
|
@@ -4706,10 +4769,10 @@ function di(e) {
|
|
|
4706
4769
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4707
4770
|
}
|
|
4708
4771
|
}
|
|
4709
|
-
function
|
|
4772
|
+
function hi(e) {
|
|
4710
4773
|
return `"${e.replace(/"/g, "\"\"")}"`;
|
|
4711
4774
|
}
|
|
4712
|
-
function
|
|
4775
|
+
function gi(e) {
|
|
4713
4776
|
switch (e) {
|
|
4714
4777
|
case "connection": return q.connection;
|
|
4715
4778
|
case "client_id": return q.client_id;
|
|
@@ -4718,10 +4781,10 @@ function pi(e) {
|
|
|
4718
4781
|
case "time": throw Error("time dimension handled separately");
|
|
4719
4782
|
}
|
|
4720
4783
|
}
|
|
4721
|
-
function
|
|
4784
|
+
function _i(e) {
|
|
4722
4785
|
return {
|
|
4723
4786
|
async query(n, r, i) {
|
|
4724
|
-
let o = Date.now(), s =
|
|
4787
|
+
let o = Date.now(), s = fi[r], u = pi[r], d = [
|
|
4725
4788
|
a(q.tenant_id, n),
|
|
4726
4789
|
c(q.date, i.from),
|
|
4727
4790
|
m(q.date, i.to),
|
|
@@ -4730,13 +4793,13 @@ function mi(e) {
|
|
|
4730
4793
|
i.filters.connection?.length && d.push(l(q.connection, i.filters.connection)), i.filters.client_id?.length && d.push(l(q.client_id, i.filters.client_id)), i.filters.user_type?.length && d.push(l(q.strategy_type, i.filters.user_type)), i.filters.user_id?.length && d.push(l(q.user_id, i.filters.user_id));
|
|
4731
4794
|
let f = {}, p = [], h = [];
|
|
4732
4795
|
for (let e of i.group_by) if (e === "time") {
|
|
4733
|
-
let e =
|
|
4796
|
+
let e = mi(i.interval);
|
|
4734
4797
|
f.time = e, p.push(e), h.push({
|
|
4735
4798
|
name: "time",
|
|
4736
4799
|
type: i.interval === "hour" ? "DateTime" : "Date"
|
|
4737
4800
|
});
|
|
4738
4801
|
} else {
|
|
4739
|
-
let t =
|
|
4802
|
+
let t = gi(e);
|
|
4740
4803
|
f[e] = t, p.push(t), h.push({
|
|
4741
4804
|
name: e,
|
|
4742
4805
|
type: "String"
|
|
@@ -4752,9 +4815,9 @@ function mi(e) {
|
|
|
4752
4815
|
if (i.order_by) {
|
|
4753
4816
|
let e = i.order_by.startsWith("-"), t = e ? i.order_by.slice(1) : i.order_by;
|
|
4754
4817
|
if (!_.has(t)) throw Error(`Invalid order_by column '${t}' for analytics query`);
|
|
4755
|
-
let n =
|
|
4818
|
+
let n = hi(t);
|
|
4756
4819
|
g = g.orderBy(y.raw(`${n} ${e ? "DESC" : "ASC"}`));
|
|
4757
|
-
} else g = i.group_by[0] === "time" ? g.orderBy(y.raw(`${
|
|
4820
|
+
} else g = i.group_by[0] === "time" ? g.orderBy(y.raw(`${hi("time")} ASC`)) : g.orderBy(y.raw(`${hi(u.alias)} DESC`));
|
|
4758
4821
|
g = g.limit(i.limit).offset(i.offset);
|
|
4759
4822
|
let v = (await g.all()).map((e) => {
|
|
4760
4823
|
let t = {};
|
|
@@ -4803,10 +4866,10 @@ function mi(e) {
|
|
|
4803
4866
|
}
|
|
4804
4867
|
//#endregion
|
|
4805
4868
|
//#region src/adapters/cleanup.ts
|
|
4806
|
-
var
|
|
4807
|
-
function
|
|
4869
|
+
var vi = 10080 * 60 * 1e3;
|
|
4870
|
+
function yi(e) {
|
|
4808
4871
|
return async (n) => {
|
|
4809
|
-
let r = Date.now() -
|
|
4872
|
+
let r = Date.now() - vi;
|
|
4810
4873
|
try {
|
|
4811
4874
|
let i = [v(m(N.expires_at_ts, r), m(N.idle_expires_at_ts, r))];
|
|
4812
4875
|
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));
|
|
@@ -4841,7 +4904,7 @@ var Q = w("tenant_operations", {
|
|
|
4841
4904
|
x("tenant_operations_tenant_id_created_at_idx").on(e.tenant_id, e.created_at),
|
|
4842
4905
|
x("tenant_operations_rollout_id_idx").on(e.rollout_id),
|
|
4843
4906
|
x("tenant_operations_status_idx").on(e.status)
|
|
4844
|
-
]),
|
|
4907
|
+
]), bi = w("tenant_operation_events", {
|
|
4845
4908
|
id: T("id", { length: 255 }).primaryKey(),
|
|
4846
4909
|
operation_id: T("operation_id", { length: 255 }).notNull(),
|
|
4847
4910
|
step: T("step", { length: 255 }).notNull(),
|
|
@@ -4872,7 +4935,7 @@ var Q = w("tenant_operations", {
|
|
|
4872
4935
|
name: "tenant_operation_rows_operation_id_constraint"
|
|
4873
4936
|
}).onDelete("cascade"),
|
|
4874
4937
|
x("tenant_operation_rows_operation_id_status_idx").on(e.operation_id, e.status)
|
|
4875
|
-
]),
|
|
4938
|
+
]), xi = w("rollouts", {
|
|
4876
4939
|
id: T("id", { length: 255 }).primaryKey(),
|
|
4877
4940
|
kind: T("kind", { length: 32 }).notNull(),
|
|
4878
4941
|
status: T("status", { length: 32 }).notNull(),
|
|
@@ -4888,7 +4951,7 @@ var Q = w("tenant_operations", {
|
|
|
4888
4951
|
});
|
|
4889
4952
|
//#endregion
|
|
4890
4953
|
//#region src/adapters/tenantOperations.ts
|
|
4891
|
-
function
|
|
4954
|
+
function Si(e) {
|
|
4892
4955
|
if (!e) return null;
|
|
4893
4956
|
try {
|
|
4894
4957
|
return JSON.parse(e);
|
|
@@ -4896,7 +4959,7 @@ function yi(e) {
|
|
|
4896
4959
|
return null;
|
|
4897
4960
|
}
|
|
4898
4961
|
}
|
|
4899
|
-
function
|
|
4962
|
+
function Ci(e) {
|
|
4900
4963
|
return Pe.parse({
|
|
4901
4964
|
id: e.id,
|
|
4902
4965
|
tenant_id: e.tenant_id,
|
|
@@ -4910,8 +4973,8 @@ function bi(e) {
|
|
|
4910
4973
|
target_database_version: e.target_database_version,
|
|
4911
4974
|
error: e.error,
|
|
4912
4975
|
initiated_by: e.initiated_by,
|
|
4913
|
-
input:
|
|
4914
|
-
result:
|
|
4976
|
+
input: Si(e.input),
|
|
4977
|
+
result: Si(e.result),
|
|
4915
4978
|
claimed_by: e.claimed_by,
|
|
4916
4979
|
claim_expires_at: e.claim_expires_at,
|
|
4917
4980
|
created_at: e.created_at,
|
|
@@ -4919,7 +4982,7 @@ function bi(e) {
|
|
|
4919
4982
|
finished_at: e.finished_at
|
|
4920
4983
|
});
|
|
4921
4984
|
}
|
|
4922
|
-
function
|
|
4985
|
+
function wi(e) {
|
|
4923
4986
|
return {
|
|
4924
4987
|
async create(t) {
|
|
4925
4988
|
let n = je.parse(t), r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -4950,7 +5013,7 @@ function xi(e) {
|
|
|
4950
5013
|
},
|
|
4951
5014
|
async get(t) {
|
|
4952
5015
|
let n = await e.select().from(Q).where(a(Q.id, t)).limit(1);
|
|
4953
|
-
return n[0] ?
|
|
5016
|
+
return n[0] ? Ci(n[0]) : null;
|
|
4954
5017
|
},
|
|
4955
5018
|
async list(n = {}) {
|
|
4956
5019
|
let r = n.page ?? 0, o = n.per_page ?? 50, s = [];
|
|
@@ -4961,7 +5024,7 @@ function xi(e) {
|
|
|
4961
5024
|
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));
|
|
4962
5025
|
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);
|
|
4963
5026
|
return {
|
|
4964
|
-
operations: c.map(
|
|
5027
|
+
operations: c.map(Ci),
|
|
4965
5028
|
start: r * o,
|
|
4966
5029
|
limit: o,
|
|
4967
5030
|
length: c.length
|
|
@@ -4987,7 +5050,7 @@ function xi(e) {
|
|
|
4987
5050
|
},
|
|
4988
5051
|
async listResumable(r) {
|
|
4989
5052
|
let i = (/* @__PURE__ */ new Date()).toISOString();
|
|
4990
|
-
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(
|
|
5053
|
+
return (await e.select().from(Q).where(t(l(Q.status, ["pending", "running"]), a(Q.kind, r.kind), v(f(Q.claimed_by), h(Q.claim_expires_at, i)))).orderBy(n(Q.created_at), n(Q.id)).limit(r.limit)).map(Ci);
|
|
4991
5054
|
},
|
|
4992
5055
|
async remove(t) {
|
|
4993
5056
|
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);
|
|
@@ -4996,19 +5059,19 @@ function xi(e) {
|
|
|
4996
5059
|
}
|
|
4997
5060
|
//#endregion
|
|
4998
5061
|
//#region src/adapters/tenantOperationRows.ts
|
|
4999
|
-
var
|
|
5000
|
-
function
|
|
5062
|
+
var Ti = 50, Ei = 50;
|
|
5063
|
+
function Di(e) {
|
|
5001
5064
|
try {
|
|
5002
5065
|
return JSON.parse(e);
|
|
5003
5066
|
} catch {
|
|
5004
5067
|
return {};
|
|
5005
5068
|
}
|
|
5006
5069
|
}
|
|
5007
|
-
function
|
|
5070
|
+
function Oi(e) {
|
|
5008
5071
|
return Ne.parse({
|
|
5009
5072
|
operation_id: e.operation_id,
|
|
5010
5073
|
seq: e.seq,
|
|
5011
|
-
payload:
|
|
5074
|
+
payload: Di(e.payload),
|
|
5012
5075
|
status: e.status,
|
|
5013
5076
|
error_code: e.error_code,
|
|
5014
5077
|
error_message: e.error_message,
|
|
@@ -5018,12 +5081,12 @@ function Ti(e) {
|
|
|
5018
5081
|
updated_at: e.updated_at
|
|
5019
5082
|
});
|
|
5020
5083
|
}
|
|
5021
|
-
function
|
|
5084
|
+
function ki(e, t) {
|
|
5022
5085
|
let n = [];
|
|
5023
5086
|
for (let r = 0; r < e.length; r += t) n.push(e.slice(r, r + t));
|
|
5024
5087
|
return n;
|
|
5025
5088
|
}
|
|
5026
|
-
function
|
|
5089
|
+
function Ai(e, n, r, i) {
|
|
5027
5090
|
return e.update($).set({
|
|
5028
5091
|
status: r.status,
|
|
5029
5092
|
error_code: r.error_code ?? null,
|
|
@@ -5033,7 +5096,7 @@ function Di(e, n, r, i) {
|
|
|
5033
5096
|
updated_at: i
|
|
5034
5097
|
}).where(t(a($.operation_id, n), a($.seq, r.seq), a($.status, "pending")));
|
|
5035
5098
|
}
|
|
5036
|
-
function
|
|
5099
|
+
function ji(e) {
|
|
5037
5100
|
return {
|
|
5038
5101
|
async createMany(t) {
|
|
5039
5102
|
if (t.length === 0) return 0;
|
|
@@ -5052,24 +5115,24 @@ function Oi(e) {
|
|
|
5052
5115
|
updated_at: n
|
|
5053
5116
|
};
|
|
5054
5117
|
});
|
|
5055
|
-
for (let t of
|
|
5118
|
+
for (let t of ki(r, Ti)) await e.insert($).values(t);
|
|
5056
5119
|
return r.length;
|
|
5057
5120
|
},
|
|
5058
5121
|
async claimPending(r, i) {
|
|
5059
|
-
return (await e.select().from($).where(t(a($.operation_id, r), a($.status, "pending"))).orderBy(n($.seq)).limit(i)).map(
|
|
5122
|
+
return (await e.select().from($).where(t(a($.operation_id, r), a($.status, "pending"))).orderBy(n($.seq)).limit(i)).map(Oi);
|
|
5060
5123
|
},
|
|
5061
5124
|
async recordOutcomes(n, r) {
|
|
5062
5125
|
if (r.length === 0) return 0;
|
|
5063
5126
|
let i = (/* @__PURE__ */ new Date()).toISOString(), o = r.map((e) => e.seq), s = /* @__PURE__ */ new Set();
|
|
5064
|
-
for (let r of
|
|
5127
|
+
for (let r of ki(o, Ei)) {
|
|
5065
5128
|
let i = await e.select({ seq: $.seq }).from($).where(t(a($.operation_id, n), a($.status, "pending"), l($.seq, r)));
|
|
5066
5129
|
for (let e of i) s.add(e.seq);
|
|
5067
5130
|
}
|
|
5068
5131
|
let c = r.filter((e) => s.has(e.seq));
|
|
5069
5132
|
if (c.length === 0) return 0;
|
|
5070
|
-
for (let t of
|
|
5071
|
-
let [r, ...a] = t.map((t) =>
|
|
5072
|
-
r && await
|
|
5133
|
+
for (let t of ki(c, Ei)) {
|
|
5134
|
+
let [r, ...a] = t.map((t) => Ai(e, n, t, i));
|
|
5135
|
+
r && await Tt(e, [r, ...a]);
|
|
5073
5136
|
}
|
|
5074
5137
|
return c.length;
|
|
5075
5138
|
},
|
|
@@ -5104,7 +5167,7 @@ function Oi(e) {
|
|
|
5104
5167
|
}
|
|
5105
5168
|
let u = await e.select().from($).where(t(...c)).orderBy(n($.seq)).offset(o * s).limit(s);
|
|
5106
5169
|
return {
|
|
5107
|
-
rows: u.map(
|
|
5170
|
+
rows: u.map(Oi),
|
|
5108
5171
|
start: o * s,
|
|
5109
5172
|
limit: s,
|
|
5110
5173
|
length: u.length
|
|
@@ -5118,27 +5181,27 @@ function Oi(e) {
|
|
|
5118
5181
|
}
|
|
5119
5182
|
//#endregion
|
|
5120
5183
|
//#region src/helpers/monotonic-id.ts
|
|
5121
|
-
var
|
|
5122
|
-
function
|
|
5184
|
+
var Mi = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", Ni = 32, Pi = 10, Fi = 4, Ii = 10;
|
|
5185
|
+
function Li(e, t) {
|
|
5123
5186
|
let n = "";
|
|
5124
|
-
for (let r = t; r > 0; r--) n =
|
|
5187
|
+
for (let r = t; r > 0; r--) n = Mi.charAt(e % Ni) + n, e = Math.floor(e / Ni);
|
|
5125
5188
|
return n;
|
|
5126
5189
|
}
|
|
5127
|
-
function
|
|
5128
|
-
let e = new Uint8Array(
|
|
5190
|
+
function Ri() {
|
|
5191
|
+
let e = new Uint8Array(Ii);
|
|
5129
5192
|
crypto.getRandomValues(e);
|
|
5130
5193
|
let t = "";
|
|
5131
|
-
for (let n = 0; n <
|
|
5194
|
+
for (let n = 0; n < Ii; n++) t += Mi.charAt(e[n] % Ni);
|
|
5132
5195
|
return t;
|
|
5133
5196
|
}
|
|
5134
|
-
var
|
|
5135
|
-
function
|
|
5197
|
+
var zi = 0, Bi = 0;
|
|
5198
|
+
function Vi() {
|
|
5136
5199
|
let e = Date.now();
|
|
5137
|
-
return e ===
|
|
5200
|
+
return e === zi ? Bi++ : (zi = e, Bi = 0), Li(e, Pi) + Li(Bi, Fi) + Ri();
|
|
5138
5201
|
}
|
|
5139
5202
|
//#endregion
|
|
5140
5203
|
//#region src/adapters/tenantOperationEvents.ts
|
|
5141
|
-
function
|
|
5204
|
+
function Hi(e) {
|
|
5142
5205
|
if (!e) return null;
|
|
5143
5206
|
try {
|
|
5144
5207
|
let t = JSON.parse(e);
|
|
@@ -5146,22 +5209,22 @@ function zi(e) {
|
|
|
5146
5209
|
} catch {}
|
|
5147
5210
|
return null;
|
|
5148
5211
|
}
|
|
5149
|
-
function
|
|
5212
|
+
function Ui(e) {
|
|
5150
5213
|
return Ae.parse({
|
|
5151
5214
|
id: e.id,
|
|
5152
5215
|
operation_id: e.operation_id,
|
|
5153
5216
|
step: e.step,
|
|
5154
5217
|
outcome: e.outcome,
|
|
5155
|
-
detail:
|
|
5218
|
+
detail: Hi(e.detail),
|
|
5156
5219
|
attempt: e.attempt,
|
|
5157
5220
|
created_at: e.created_at
|
|
5158
5221
|
});
|
|
5159
5222
|
}
|
|
5160
|
-
function
|
|
5223
|
+
function Wi(e) {
|
|
5161
5224
|
return {
|
|
5162
5225
|
async create(t) {
|
|
5163
5226
|
let n = ke.parse(t), r = {
|
|
5164
|
-
id: `evt_${
|
|
5227
|
+
id: `evt_${Vi()}`,
|
|
5165
5228
|
operation_id: n.operation_id,
|
|
5166
5229
|
step: n.step,
|
|
5167
5230
|
outcome: n.outcome,
|
|
@@ -5169,7 +5232,7 @@ function Vi(e) {
|
|
|
5169
5232
|
attempt: n.attempt,
|
|
5170
5233
|
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
5171
5234
|
};
|
|
5172
|
-
return await e.insert(
|
|
5235
|
+
return await e.insert(bi).values(r), Ae.parse({
|
|
5173
5236
|
id: r.id,
|
|
5174
5237
|
operation_id: r.operation_id,
|
|
5175
5238
|
step: r.step,
|
|
@@ -5180,9 +5243,9 @@ function Vi(e) {
|
|
|
5180
5243
|
});
|
|
5181
5244
|
},
|
|
5182
5245
|
async listByOperation(t, r = {}) {
|
|
5183
|
-
let i = r.page ?? 0, o = r.per_page ?? 100, s = await e.select().from(
|
|
5246
|
+
let i = r.page ?? 0, o = r.per_page ?? 100, s = await e.select().from(bi).where(a(bi.operation_id, t)).orderBy(n(bi.created_at), n(bi.id)).offset(i * o).limit(o);
|
|
5184
5247
|
return {
|
|
5185
|
-
events: s.map(
|
|
5248
|
+
events: s.map(Ui),
|
|
5186
5249
|
start: i * o,
|
|
5187
5250
|
limit: o,
|
|
5188
5251
|
length: s.length
|
|
@@ -5192,7 +5255,7 @@ function Vi(e) {
|
|
|
5192
5255
|
}
|
|
5193
5256
|
//#endregion
|
|
5194
5257
|
//#region src/adapters/rollouts.ts
|
|
5195
|
-
function
|
|
5258
|
+
function Gi(e) {
|
|
5196
5259
|
if (!e) return null;
|
|
5197
5260
|
try {
|
|
5198
5261
|
return JSON.parse(e);
|
|
@@ -5200,7 +5263,7 @@ function Hi(e) {
|
|
|
5200
5263
|
return null;
|
|
5201
5264
|
}
|
|
5202
5265
|
}
|
|
5203
|
-
function
|
|
5266
|
+
function Ki(e) {
|
|
5204
5267
|
return we.parse({
|
|
5205
5268
|
id: e.id,
|
|
5206
5269
|
kind: e.kind,
|
|
@@ -5208,15 +5271,15 @@ function Ui(e) {
|
|
|
5208
5271
|
target_worker_version: e.target_worker_version,
|
|
5209
5272
|
target_database_version: e.target_database_version,
|
|
5210
5273
|
wave_size: e.wave_size,
|
|
5211
|
-
canary_tenant_ids:
|
|
5212
|
-
filter:
|
|
5274
|
+
canary_tenant_ids: Gi(e.canary_tenant_ids),
|
|
5275
|
+
filter: Gi(e.filter),
|
|
5213
5276
|
initiated_by: e.initiated_by,
|
|
5214
5277
|
created_at: e.created_at,
|
|
5215
5278
|
updated_at: e.updated_at,
|
|
5216
5279
|
finished_at: e.finished_at
|
|
5217
5280
|
});
|
|
5218
5281
|
}
|
|
5219
|
-
function
|
|
5282
|
+
function qi(e) {
|
|
5220
5283
|
return {
|
|
5221
5284
|
async create(t) {
|
|
5222
5285
|
let n = Ce.parse(t), r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -5233,95 +5296,96 @@ function Wi(e) {
|
|
|
5233
5296
|
updated_at: r,
|
|
5234
5297
|
finished_at: null
|
|
5235
5298
|
};
|
|
5236
|
-
await e.insert(
|
|
5299
|
+
await e.insert(xi).values(i);
|
|
5237
5300
|
let a = await this.get(i.id);
|
|
5238
5301
|
if (!a) throw Error(`Failed to create rollout ${i.id}`);
|
|
5239
5302
|
return a;
|
|
5240
5303
|
},
|
|
5241
5304
|
async get(t) {
|
|
5242
|
-
let n = await e.select().from(
|
|
5243
|
-
return n[0] ?
|
|
5305
|
+
let n = await e.select().from(xi).where(a(xi.id, t)).limit(1);
|
|
5306
|
+
return n[0] ? Ki(n[0]) : null;
|
|
5244
5307
|
},
|
|
5245
5308
|
async list(t = {}) {
|
|
5246
|
-
let n = t.page ?? 0, r = t.per_page ?? 50, a = await e.select().from(
|
|
5309
|
+
let n = t.page ?? 0, r = t.per_page ?? 50, a = await e.select().from(xi).orderBy(i(xi.created_at), i(xi.id)).offset(n * r).limit(r);
|
|
5247
5310
|
return {
|
|
5248
|
-
rollouts: a.map(
|
|
5311
|
+
rollouts: a.map(Ki),
|
|
5249
5312
|
start: n * r,
|
|
5250
5313
|
limit: r,
|
|
5251
5314
|
length: a.length
|
|
5252
5315
|
};
|
|
5253
5316
|
},
|
|
5254
5317
|
async update(t, n) {
|
|
5255
|
-
if ((await e.select({ id:
|
|
5318
|
+
if ((await e.select({ id: xi.id }).from(xi).where(a(xi.id, t)).limit(1)).length === 0) return !1;
|
|
5256
5319
|
let r = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
5257
|
-
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(
|
|
5320
|
+
return n.status !== void 0 && (r.status = n.status), n.wave_size !== void 0 && (r.wave_size = n.wave_size), n.canary_tenant_ids !== void 0 && (r.canary_tenant_ids = n.canary_tenant_ids ? JSON.stringify(n.canary_tenant_ids) : null), n.filter !== void 0 && (r.filter = n.filter ? JSON.stringify(n.filter) : null), n.finished_at !== void 0 && (r.finished_at = n.finished_at), await e.update(xi).set(r).where(a(xi.id, t)), !0;
|
|
5258
5321
|
},
|
|
5259
5322
|
async remove(t) {
|
|
5260
|
-
return (await e.select({ id:
|
|
5323
|
+
return (await e.select({ id: xi.id }).from(xi).where(a(xi.id, t)).limit(1)).length === 0 ? !1 : (await e.delete(xi).where(a(xi.id, t)), !0);
|
|
5261
5324
|
}
|
|
5262
5325
|
};
|
|
5263
5326
|
}
|
|
5264
5327
|
//#endregion
|
|
5265
5328
|
//#region src/adapters/index.ts
|
|
5266
|
-
function
|
|
5329
|
+
function Ji(e, t = { useTransactions: !0 }) {
|
|
5267
5330
|
let n = {
|
|
5268
|
-
actions:
|
|
5269
|
-
actionExecutions:
|
|
5270
|
-
actionVersions:
|
|
5271
|
-
branding:
|
|
5272
|
-
clients:
|
|
5273
|
-
clientConnections:
|
|
5274
|
-
clientGrants:
|
|
5275
|
-
clientRegistrationTokens:
|
|
5276
|
-
codes:
|
|
5277
|
-
connections:
|
|
5278
|
-
customDomains:
|
|
5279
|
-
customText:
|
|
5280
|
-
emailProviders:
|
|
5281
|
-
emailTemplates:
|
|
5282
|
-
flows:
|
|
5283
|
-
forms:
|
|
5284
|
-
grants:
|
|
5285
|
-
hookCode:
|
|
5286
|
-
hooks:
|
|
5287
|
-
invites:
|
|
5288
|
-
keys:
|
|
5289
|
-
loginSessions:
|
|
5290
|
-
logs:
|
|
5291
|
-
authenticationMethods:
|
|
5292
|
-
organizations:
|
|
5293
|
-
passwords:
|
|
5294
|
-
promptSettings:
|
|
5295
|
-
|
|
5296
|
-
|
|
5297
|
-
|
|
5298
|
-
|
|
5299
|
-
|
|
5300
|
-
|
|
5301
|
-
|
|
5302
|
-
|
|
5303
|
-
|
|
5304
|
-
|
|
5305
|
-
|
|
5306
|
-
|
|
5307
|
-
|
|
5331
|
+
actions: xt(e),
|
|
5332
|
+
actionExecutions: Ct(e),
|
|
5333
|
+
actionVersions: Dt(e),
|
|
5334
|
+
branding: kt(e),
|
|
5335
|
+
clients: Bt(e),
|
|
5336
|
+
clientConnections: Ht(e),
|
|
5337
|
+
clientGrants: Wt(e),
|
|
5338
|
+
clientRegistrationTokens: Yt(e),
|
|
5339
|
+
codes: $t(e),
|
|
5340
|
+
connections: nn(e),
|
|
5341
|
+
customDomains: an(e),
|
|
5342
|
+
customText: on(e),
|
|
5343
|
+
emailProviders: sn(e),
|
|
5344
|
+
emailTemplates: ln(e),
|
|
5345
|
+
flows: dn(e),
|
|
5346
|
+
forms: mn(e),
|
|
5347
|
+
grants: vn(e),
|
|
5348
|
+
hookCode: Sn(e),
|
|
5349
|
+
hooks: En(e),
|
|
5350
|
+
invites: An(e),
|
|
5351
|
+
keys: Mn(e),
|
|
5352
|
+
loginSessions: Ln(e),
|
|
5353
|
+
logs: zn(e),
|
|
5354
|
+
authenticationMethods: Wn(e),
|
|
5355
|
+
organizations: Jn(e),
|
|
5356
|
+
passwords: Xn(e),
|
|
5357
|
+
promptSettings: Zn(e),
|
|
5358
|
+
promptPartials: Qn(e),
|
|
5359
|
+
proxyRoutes: nr(e),
|
|
5360
|
+
scimConfigurations: ur(e),
|
|
5361
|
+
scimTokens: fr(e),
|
|
5362
|
+
scimExternalIds: mr(e),
|
|
5363
|
+
refreshTokens: _r(e),
|
|
5364
|
+
resourceServers: Cr(e),
|
|
5365
|
+
rolePermissions: wr(e),
|
|
5366
|
+
userPermissions: Er(e),
|
|
5367
|
+
roles: Or(e),
|
|
5368
|
+
sessions: Nr(e),
|
|
5369
|
+
sessionCleanup: yi(e),
|
|
5370
|
+
tenants: Rr(e),
|
|
5371
|
+
tokenExchangeProfiles: or(e),
|
|
5308
5372
|
...t.controlPlane ? {
|
|
5309
|
-
tenantOperations:
|
|
5310
|
-
tenantOperationEvents:
|
|
5311
|
-
tenantOperationRows:
|
|
5312
|
-
rollouts:
|
|
5373
|
+
tenantOperations: wi(e),
|
|
5374
|
+
tenantOperationEvents: Wi(e),
|
|
5375
|
+
tenantOperationRows: ji(e),
|
|
5376
|
+
rollouts: qi(e)
|
|
5313
5377
|
} : {},
|
|
5314
|
-
themes:
|
|
5315
|
-
universalLoginTemplates:
|
|
5316
|
-
users:
|
|
5317
|
-
userActivity:
|
|
5318
|
-
userRoles:
|
|
5319
|
-
userOrganizations:
|
|
5320
|
-
stats:
|
|
5321
|
-
analytics:
|
|
5322
|
-
outbox:
|
|
5378
|
+
themes: Vr(e),
|
|
5379
|
+
universalLoginTemplates: Hr(e),
|
|
5380
|
+
users: ai(e),
|
|
5381
|
+
userActivity: Wr(e),
|
|
5382
|
+
userRoles: oi(e),
|
|
5383
|
+
userOrganizations: si(e),
|
|
5384
|
+
stats: di(e),
|
|
5385
|
+
analytics: _i(e),
|
|
5386
|
+
outbox: qr(e),
|
|
5323
5387
|
async transaction(r) {
|
|
5324
|
-
if (t.useTransactions === !1 ||
|
|
5388
|
+
if (t.useTransactions === !1 || wt(e)) return r(n);
|
|
5325
5389
|
await e.run(y`BEGIN`);
|
|
5326
5390
|
try {
|
|
5327
5391
|
let t = await r(n);
|
|
@@ -5335,7 +5399,7 @@ function Gi(e, t = { useTransactions: !0 }) {
|
|
|
5335
5399
|
}
|
|
5336
5400
|
//#endregion
|
|
5337
5401
|
//#region src/adapters/resolveHost.ts
|
|
5338
|
-
function
|
|
5402
|
+
function Yi(e) {
|
|
5339
5403
|
if (!e) return { path: "/*" };
|
|
5340
5404
|
try {
|
|
5341
5405
|
let t = JSON.parse(e), n = xe.safeParse(t);
|
|
@@ -5343,7 +5407,7 @@ function Ki(e) {
|
|
|
5343
5407
|
} catch {}
|
|
5344
5408
|
return { path: "/*" };
|
|
5345
5409
|
}
|
|
5346
|
-
function
|
|
5410
|
+
function Xi(e) {
|
|
5347
5411
|
if (!e) return [];
|
|
5348
5412
|
try {
|
|
5349
5413
|
let t = JSON.parse(e);
|
|
@@ -5358,20 +5422,20 @@ function qi(e) {
|
|
|
5358
5422
|
return [];
|
|
5359
5423
|
}
|
|
5360
5424
|
}
|
|
5361
|
-
async function
|
|
5425
|
+
async function Zi(e, r) {
|
|
5362
5426
|
let i = r.toLowerCase(), o = (await e.select({
|
|
5363
|
-
custom_domain_id:
|
|
5364
|
-
tenant_id:
|
|
5365
|
-
domain:
|
|
5366
|
-
}).from(
|
|
5427
|
+
custom_domain_id: Ke.custom_domain_id,
|
|
5428
|
+
tenant_id: Ke.tenant_id,
|
|
5429
|
+
domain: Ke.domain
|
|
5430
|
+
}).from(Ke).where(a(Ke.domain, i)).limit(1))[0];
|
|
5367
5431
|
if (!o) return null;
|
|
5368
5432
|
let s = (await e.select().from(Y).where(t(a(Y.tenant_id, o.tenant_id), a(Y.custom_domain_id, o.custom_domain_id))).orderBy(n(Y.priority), n(Y.created_at))).map((e) => ({
|
|
5369
5433
|
id: e.id,
|
|
5370
5434
|
tenant_id: e.tenant_id,
|
|
5371
5435
|
custom_domain_id: e.custom_domain_id,
|
|
5372
5436
|
priority: e.priority,
|
|
5373
|
-
match:
|
|
5374
|
-
handlers:
|
|
5437
|
+
match: Yi(e.match),
|
|
5438
|
+
handlers: Xi(e.handlers),
|
|
5375
5439
|
created_at: e.created_at,
|
|
5376
5440
|
updated_at: e.updated_at
|
|
5377
5441
|
}));
|
|
@@ -5384,11 +5448,11 @@ async function Ji(e, r) {
|
|
|
5384
5448
|
}
|
|
5385
5449
|
//#endregion
|
|
5386
5450
|
//#region src/adapters/proxyData.ts
|
|
5387
|
-
function
|
|
5451
|
+
function Qi(e) {
|
|
5388
5452
|
return {
|
|
5389
|
-
proxyRoutes:
|
|
5390
|
-
resolveHost: (t) =>
|
|
5453
|
+
proxyRoutes: nr(e),
|
|
5454
|
+
resolveHost: (t) => Zi(e, t)
|
|
5391
5455
|
};
|
|
5392
5456
|
}
|
|
5393
5457
|
//#endregion
|
|
5394
|
-
export {
|
|
5458
|
+
export { Qi as createProxyDataAdapter, nr as createProxyRoutesAdapter, Ji as default, pt as sqlite };
|