@authhero/drizzle 1.5.0 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/drizzle-adapter.cjs +2 -2
- package/dist/drizzle-adapter.mjs +899 -901
- package/package.json +3 -3
package/dist/drizzle-adapter.mjs
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { Column as e, and as t, asc as n, count as r, desc as i, eq as a, getTableColumns as o, gt as s, gte as c, inArray as l, is as u, isNotNull as d, isNull as f, like as p, lt as m, lte as h, ne as g, notLike as _, or as v, sql as y } from "drizzle-orm";
|
|
2
2
|
import { customAlphabet as ee, nanoid as b } from "nanoid";
|
|
3
|
-
import { SQLiteTable as te, foreignKey as ne, index as x, integer as S, primaryKey as C, sqliteTable as w, text as T, uniqueIndex as
|
|
4
|
-
import { booleanToInt as
|
|
5
|
-
import { MONDAY_EPOCH_SHIFT_MS as
|
|
6
|
-
import { HTTPException as
|
|
3
|
+
import { SQLiteTable as te, foreignKey as ne, index as x, integer as S, primaryKey as C, sqliteTable as w, text as T, uniqueIndex as re } from "drizzle-orm/sqlite-core";
|
|
4
|
+
import { booleanToInt as ie, convertDatesToAdapter as ae, dbDateToIsoRequired as oe, getCountAsInt as se, isoToDbDate as E, removeNullProperties as D, removeUndefinedAndNull as ce, stringifyProperties as le } from "@authhero/adapter-interfaces/sql";
|
|
5
|
+
import { MONDAY_EPOCH_SHIFT_MS as ue, WEEK_MS as de, buildRefreshTokenRetention as fe, buildSessionRetention as pe, clientRegistrationTokenTypeSchema as me, decodeCursor as he, encodeCursor as ge, handlerConfigSchema as _e, isEmailSearchTerm as ve, isPlainObject as ye, matchSchema as be, parseUserId as xe, rolloutInsertSchema as Se, rolloutSchema as Ce, sanitizeLuceneQuery as we, scimMappingEntrySchema as Te, sessionRetentionWindow as Ee, splitLuceneOrGroups as De, tenantOperationEventInsertSchema as Oe, tenantOperationEventSchema as ke, tenantOperationInsertSchema as Ae, tenantOperationSchema as je, unescapeLuceneValue as Me } from "@authhero/adapter-interfaces";
|
|
6
|
+
import { HTTPException as Ne } from "hono/http-exception";
|
|
7
7
|
//#region \0rolldown/runtime.js
|
|
8
|
-
var
|
|
8
|
+
var Pe = Object.defineProperty, Fe = (e, t) => {
|
|
9
9
|
let n = {};
|
|
10
|
-
for (var r in e)
|
|
10
|
+
for (var r in e) Pe(n, r, {
|
|
11
11
|
get: e[r],
|
|
12
12
|
enumerable: !0
|
|
13
13
|
});
|
|
14
|
-
return t ||
|
|
15
|
-
},
|
|
14
|
+
return t || Pe(n, Symbol.toStringTag, { value: "Module" }), n;
|
|
15
|
+
}, O = w("tenants", {
|
|
16
16
|
id: T("id", { length: 191 }).primaryKey(),
|
|
17
17
|
name: T("name", { length: 255 }),
|
|
18
18
|
audience: T("audience", { length: 255 }),
|
|
@@ -67,9 +67,9 @@ var je = Object.defineProperty, Me = (e, t) => {
|
|
|
67
67
|
worker_script_name: T("worker_script_name", { length: 255 }),
|
|
68
68
|
storage_kind: T("storage_kind", { length: 32 }),
|
|
69
69
|
d1_database_id: T("d1_database_id", { length: 64 })
|
|
70
|
-
}),
|
|
70
|
+
}), k = w("actions", {
|
|
71
71
|
id: T("id", { length: 255 }).notNull(),
|
|
72
|
-
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() =>
|
|
72
|
+
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
73
73
|
name: T("name", { length: 255 }).notNull(),
|
|
74
74
|
code: T("code").notNull(),
|
|
75
75
|
runtime: T("runtime", { length: 50 }),
|
|
@@ -91,7 +91,7 @@ var je = Object.defineProperty, Me = (e, t) => {
|
|
|
91
91
|
x("idx_actions_name").on(e.tenant_id, e.name)
|
|
92
92
|
]), A = w("action_versions", {
|
|
93
93
|
id: T("id", { length: 255 }).notNull(),
|
|
94
|
-
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() =>
|
|
94
|
+
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
95
95
|
action_id: T("action_id", { length: 255 }).notNull(),
|
|
96
96
|
number: S("number").notNull(),
|
|
97
97
|
code: T("code").notNull(),
|
|
@@ -107,11 +107,11 @@ var je = Object.defineProperty, Me = (e, t) => {
|
|
|
107
107
|
columns: [e.tenant_id, e.id],
|
|
108
108
|
name: "action_versions_pk"
|
|
109
109
|
}),
|
|
110
|
-
|
|
110
|
+
re("uq_action_versions_number").on(e.tenant_id, e.action_id, e.number),
|
|
111
111
|
x("idx_action_versions_action_id").on(e.tenant_id, e.action_id)
|
|
112
|
-
]),
|
|
112
|
+
]), Ie = w("action_executions", {
|
|
113
113
|
id: T("id", { length: 255 }).notNull(),
|
|
114
|
-
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() =>
|
|
114
|
+
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
115
115
|
trigger_id: T("trigger_id", { length: 255 }).notNull(),
|
|
116
116
|
status: T("status", { length: 32 }).notNull(),
|
|
117
117
|
results: T("results").notNull(),
|
|
@@ -123,7 +123,7 @@ var je = Object.defineProperty, Me = (e, t) => {
|
|
|
123
123
|
name: "action_executions_pk"
|
|
124
124
|
}), x("action_executions_created_at_ts_index").on(e.created_at_ts)]), j = w("users", {
|
|
125
125
|
user_id: T("user_id", { length: 255 }).notNull(),
|
|
126
|
-
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() =>
|
|
126
|
+
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
127
127
|
email: T("email", { length: 255 }),
|
|
128
128
|
given_name: T("given_name", { length: 255 }),
|
|
129
129
|
family_name: T("family_name", { length: 255 }),
|
|
@@ -160,22 +160,22 @@ var je = Object.defineProperty, Me = (e, t) => {
|
|
|
160
160
|
columns: [e.user_id, e.tenant_id],
|
|
161
161
|
name: "users_tenants"
|
|
162
162
|
}),
|
|
163
|
-
|
|
164
|
-
|
|
163
|
+
re("unique_email_provider").on(e.email, e.provider, e.tenant_id),
|
|
164
|
+
re("unique_username_provider").on(e.username, e.provider, e.tenant_id),
|
|
165
165
|
x("users_email_index").on(e.email),
|
|
166
166
|
x("users_linked_to_index").on(e.linked_to),
|
|
167
167
|
x("users_name_index").on(e.name),
|
|
168
168
|
x("users_phone_tenant_provider_index").on(e.tenant_id, e.phone_number, e.provider)
|
|
169
169
|
]), M = w("passwords", {
|
|
170
170
|
id: T("id", { length: 21 }).primaryKey(),
|
|
171
|
-
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() =>
|
|
171
|
+
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
172
172
|
user_id: T("user_id", { length: 255 }).notNull(),
|
|
173
173
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
174
174
|
updated_at: T("updated_at", { length: 35 }).notNull(),
|
|
175
175
|
password: T("password", { length: 255 }).notNull(),
|
|
176
176
|
algorithm: T("algorithm", { length: 16 }).notNull().default("bcrypt"),
|
|
177
177
|
is_current: S("is_current").notNull().default(1)
|
|
178
|
-
}),
|
|
178
|
+
}), Le = w("user_activity", {
|
|
179
179
|
tenant_id: T("tenant_id", { length: 255 }).notNull(),
|
|
180
180
|
user_id: T("user_id", { length: 255 }).notNull(),
|
|
181
181
|
last_login: T("last_login", { length: 35 }),
|
|
@@ -192,7 +192,7 @@ var je = Object.defineProperty, Me = (e, t) => {
|
|
|
192
192
|
name: "user_activity_user_id_constraint"
|
|
193
193
|
}).onDelete("cascade")]), N = w("sessions", {
|
|
194
194
|
id: T("id", { length: 21 }).notNull(),
|
|
195
|
-
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() =>
|
|
195
|
+
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
196
196
|
user_id: T("user_id", { length: 255 }),
|
|
197
197
|
created_at_ts: S("created_at_ts").notNull(),
|
|
198
198
|
updated_at_ts: S("updated_at_ts").notNull(),
|
|
@@ -215,7 +215,7 @@ var je = Object.defineProperty, Me = (e, t) => {
|
|
|
215
215
|
x("idx_sessions_expires_at_ts").on(e.expires_at_ts)
|
|
216
216
|
]), P = w("refresh_tokens", {
|
|
217
217
|
id: T("id", { length: 26 }).notNull(),
|
|
218
|
-
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() =>
|
|
218
|
+
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
219
219
|
client_id: T("client_id", { length: 191 }).notNull(),
|
|
220
220
|
login_id: T("login_id", { length: 26 }).notNull(),
|
|
221
221
|
session_id: T("session_id", { length: 26 }),
|
|
@@ -250,7 +250,7 @@ var je = Object.defineProperty, Me = (e, t) => {
|
|
|
250
250
|
x("idx_refresh_tokens_session_id").on(e.tenant_id, e.session_id)
|
|
251
251
|
]), F = w("login_sessions", {
|
|
252
252
|
id: T("id", { length: 21 }).notNull(),
|
|
253
|
-
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() =>
|
|
253
|
+
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
254
254
|
session_id: T("session_id", { length: 21 }),
|
|
255
255
|
csrf_token: T("csrf_token", { length: 21 }).notNull(),
|
|
256
256
|
auth_params: T("auth_params"),
|
|
@@ -281,7 +281,7 @@ var je = Object.defineProperty, Me = (e, t) => {
|
|
|
281
281
|
x("idx_login_sessions_expires_at_ts").on(e.expires_at_ts)
|
|
282
282
|
]), I = w("codes", {
|
|
283
283
|
code_id: T("code_id", { length: 191 }).notNull(),
|
|
284
|
-
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() =>
|
|
284
|
+
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
285
285
|
user_id: T("user_id", { length: 255 }),
|
|
286
286
|
login_id: T("login_id", { length: 255 }),
|
|
287
287
|
connection_id: T("connection_id", { length: 255 }),
|
|
@@ -298,8 +298,8 @@ var je = Object.defineProperty, Me = (e, t) => {
|
|
|
298
298
|
}, (e) => [C({
|
|
299
299
|
columns: [e.code_id, e.code_type],
|
|
300
300
|
name: "PK_codes_code_id_code_type"
|
|
301
|
-
}), x("codes_expires_at_index").on(e.expires_at)]),
|
|
302
|
-
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() =>
|
|
301
|
+
}), x("codes_expires_at_index").on(e.expires_at)]), Re = w("authentication_codes", {
|
|
302
|
+
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
303
303
|
code: T("code", { length: 255 }).primaryKey(),
|
|
304
304
|
client_id: T("client_id", { length: 255 }).notNull(),
|
|
305
305
|
user_id: T("user_id", { length: 255 }).notNull(),
|
|
@@ -312,8 +312,8 @@ var je = Object.defineProperty, Me = (e, t) => {
|
|
|
312
312
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
313
313
|
expires_at: T("expires_at", { length: 35 }).notNull(),
|
|
314
314
|
used_at: T("used_at", { length: 35 })
|
|
315
|
-
}),
|
|
316
|
-
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() =>
|
|
315
|
+
}), ze = w("otps", {
|
|
316
|
+
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
317
317
|
id: T("id", { length: 255 }).primaryKey(),
|
|
318
318
|
client_id: T("client_id", { length: 255 }).notNull(),
|
|
319
319
|
code: T("code", { length: 255 }).notNull(),
|
|
@@ -331,8 +331,8 @@ var je = Object.defineProperty, Me = (e, t) => {
|
|
|
331
331
|
used_at: T("used_at", { length: 35 }),
|
|
332
332
|
audience: T("audience", { length: 255 }),
|
|
333
333
|
ip: T("ip", { length: 64 })
|
|
334
|
-
}, (e) => [x("otps_email_index").on(e.email), x("otps_expires_at_index").on(e.expires_at)]),
|
|
335
|
-
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() =>
|
|
334
|
+
}, (e) => [x("otps_email_index").on(e.email), x("otps_expires_at_index").on(e.expires_at)]), Be = w("tickets", {
|
|
335
|
+
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
336
336
|
id: T("id", { length: 255 }).primaryKey(),
|
|
337
337
|
client_id: T("client_id", { length: 255 }).notNull(),
|
|
338
338
|
email: T("email", { length: 255 }).notNull(),
|
|
@@ -347,7 +347,7 @@ var je = Object.defineProperty, Me = (e, t) => {
|
|
|
347
347
|
used_at: T("used_at", { length: 35 })
|
|
348
348
|
}), L = w("clients", {
|
|
349
349
|
client_id: T("client_id", { length: 191 }).notNull(),
|
|
350
|
-
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() =>
|
|
350
|
+
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
351
351
|
name: T("name", { length: 255 }).notNull(),
|
|
352
352
|
description: T("description", { length: 140 }),
|
|
353
353
|
global: S("global").notNull().default(0),
|
|
@@ -407,7 +407,7 @@ var je = Object.defineProperty, Me = (e, t) => {
|
|
|
407
407
|
name: "clients_tenant_id_client_id"
|
|
408
408
|
}), x("idx_clients_owner_user_id").on(e.tenant_id, e.owner_user_id)]), R = w("client_registration_tokens", {
|
|
409
409
|
id: T("id", { length: 255 }).primaryKey(),
|
|
410
|
-
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() =>
|
|
410
|
+
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
411
411
|
token_hash: T("token_hash", { length: 64 }).notNull(),
|
|
412
412
|
type: T("type", { length: 8 }).notNull(),
|
|
413
413
|
client_id: T("client_id", { length: 191 }),
|
|
@@ -418,9 +418,9 @@ var je = Object.defineProperty, Me = (e, t) => {
|
|
|
418
418
|
expires_at_ts: S("expires_at_ts"),
|
|
419
419
|
created_at_ts: S("created_at_ts").notNull(),
|
|
420
420
|
revoked_at_ts: S("revoked_at_ts")
|
|
421
|
-
}, (e) => [
|
|
421
|
+
}, (e) => [re("idx_client_registration_tokens_hash").on(e.tenant_id, e.token_hash), x("idx_client_registration_tokens_client").on(e.tenant_id, e.client_id)]), z = w("client_grants", {
|
|
422
422
|
id: T("id", { length: 21 }).notNull(),
|
|
423
|
-
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() =>
|
|
423
|
+
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
424
424
|
client_id: T("client_id", { length: 191 }).notNull(),
|
|
425
425
|
audience: T("audience", { length: 191 }).notNull(),
|
|
426
426
|
scope: T("scope").default("[]"),
|
|
@@ -436,7 +436,7 @@ var je = Object.defineProperty, Me = (e, t) => {
|
|
|
436
436
|
name: "pk_client_grants"
|
|
437
437
|
}), x("idx_client_grants_audience").on(e.audience)]), B = w("grants", {
|
|
438
438
|
id: T("id", { length: 21 }).primaryKey(),
|
|
439
|
-
tenant_id: T("tenant_id", { length: 255 }).notNull().references(() =>
|
|
439
|
+
tenant_id: T("tenant_id", { length: 255 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
440
440
|
user_id: T("user_id", { length: 255 }).notNull(),
|
|
441
441
|
client_id: T("client_id", { length: 100 }).notNull(),
|
|
442
442
|
audience: T("audience", { length: 100 }).notNull().default(""),
|
|
@@ -449,11 +449,11 @@ var je = Object.defineProperty, Me = (e, t) => {
|
|
|
449
449
|
foreignColumns: [j.user_id, j.tenant_id],
|
|
450
450
|
name: "grants_user_id_constraint"
|
|
451
451
|
}).onDelete("cascade"),
|
|
452
|
-
|
|
452
|
+
re("grants_natural_key_idx").on(e.tenant_id, e.user_id, e.client_id, e.audience),
|
|
453
453
|
x("grants_tenant_user_idx").on(e.tenant_id, e.user_id)
|
|
454
|
-
]),
|
|
454
|
+
]), Ve = w("connections", {
|
|
455
455
|
id: T("id", { length: 255 }).notNull(),
|
|
456
|
-
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() =>
|
|
456
|
+
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
457
457
|
name: T("name", { length: 255 }).notNull(),
|
|
458
458
|
response_type: T("response_type", { length: 255 }),
|
|
459
459
|
response_mode: T("response_mode", { length: 255 }),
|
|
@@ -469,10 +469,10 @@ var je = Object.defineProperty, Me = (e, t) => {
|
|
|
469
469
|
}, (e) => [
|
|
470
470
|
C({ columns: [e.tenant_id, e.id] }),
|
|
471
471
|
x("connections_tenant_id_index").on(e.tenant_id),
|
|
472
|
-
|
|
473
|
-
]),
|
|
472
|
+
re("connections_id_unique").on(e.id)
|
|
473
|
+
]), V = w("custom_domains", {
|
|
474
474
|
custom_domain_id: T("custom_domain_id", { length: 256 }).primaryKey(),
|
|
475
|
-
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() =>
|
|
475
|
+
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
476
476
|
domain: T("domain", { length: 255 }).notNull(),
|
|
477
477
|
primary: S("primary", { mode: "boolean" }).notNull(),
|
|
478
478
|
status: T("status", { length: 50 }).notNull(),
|
|
@@ -484,9 +484,9 @@ var je = Object.defineProperty, Me = (e, t) => {
|
|
|
484
484
|
domain_metadata: T("domain_metadata", { length: 2048 }),
|
|
485
485
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
486
486
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
487
|
-
}, (e) => [
|
|
487
|
+
}, (e) => [re("custom_domains_domain_unique").on(e.domain)]), He = w("domains", {
|
|
488
488
|
id: T("id", { length: 255 }).primaryKey(),
|
|
489
|
-
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() =>
|
|
489
|
+
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
490
490
|
domain: T("domain", { length: 255 }).notNull(),
|
|
491
491
|
email_service: T("email_service", { length: 255 }),
|
|
492
492
|
email_api_key: T("email_api_key", { length: 255 }),
|
|
@@ -494,7 +494,7 @@ var je = Object.defineProperty, Me = (e, t) => {
|
|
|
494
494
|
dkim_public_key: T("dkim_public_key", { length: 2048 }),
|
|
495
495
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
496
496
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
497
|
-
}),
|
|
497
|
+
}), H = w("organizations", {
|
|
498
498
|
id: T("id", { length: 21 }).primaryKey(),
|
|
499
499
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
500
500
|
name: T("name", { length: 256 }).notNull(),
|
|
@@ -505,7 +505,7 @@ var je = Object.defineProperty, Me = (e, t) => {
|
|
|
505
505
|
token_quota: T("token_quota"),
|
|
506
506
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
507
507
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
508
|
-
}, (e) => [x("idx_organizations_tenant_id").on(e.tenant_id)]),
|
|
508
|
+
}, (e) => [x("idx_organizations_tenant_id").on(e.tenant_id)]), U = w("user_organizations", {
|
|
509
509
|
id: T("id", { length: 21 }).primaryKey(),
|
|
510
510
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
511
511
|
user_id: T("user_id", { length: 191 }).notNull(),
|
|
@@ -513,11 +513,11 @@ var je = Object.defineProperty, Me = (e, t) => {
|
|
|
513
513
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
514
514
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
515
515
|
}, (e) => [
|
|
516
|
-
|
|
516
|
+
re("user_organizations_unique").on(e.tenant_id, e.user_id, e.organization_id),
|
|
517
517
|
x("idx_user_organizations_tenant_id").on(e.tenant_id),
|
|
518
518
|
x("idx_user_organizations_user_id").on(e.user_id),
|
|
519
519
|
x("idx_user_organizations_organization_id").on(e.organization_id)
|
|
520
|
-
]),
|
|
520
|
+
]), Ue = w("invites", {
|
|
521
521
|
id: T("id", { length: 21 }).primaryKey(),
|
|
522
522
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
523
523
|
organization_id: T("organization_id", { length: 21 }).notNull(),
|
|
@@ -539,7 +539,7 @@ var je = Object.defineProperty, Me = (e, t) => {
|
|
|
539
539
|
x("idx_invites_organization_id").on(e.organization_id),
|
|
540
540
|
x("idx_invites_expires_at").on(e.expires_at),
|
|
541
541
|
x("idx_invites_tenant_created").on(e.tenant_id, e.created_at)
|
|
542
|
-
]),
|
|
542
|
+
]), W = w("roles", {
|
|
543
543
|
id: T("id", { length: 21 }).notNull(),
|
|
544
544
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
545
545
|
name: T("name", { length: 50 }).notNull(),
|
|
@@ -551,7 +551,7 @@ var je = Object.defineProperty, Me = (e, t) => {
|
|
|
551
551
|
}, (e) => [C({
|
|
552
552
|
columns: [e.tenant_id, e.id],
|
|
553
553
|
name: "roles_pk"
|
|
554
|
-
})]),
|
|
554
|
+
})]), We = w("role_permissions", {
|
|
555
555
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
556
556
|
role_id: T("role_id", { length: 21 }).notNull(),
|
|
557
557
|
resource_server_identifier: T("resource_server_identifier", { length: 191 }).notNull(),
|
|
@@ -569,7 +569,7 @@ var je = Object.defineProperty, Me = (e, t) => {
|
|
|
569
569
|
}),
|
|
570
570
|
x("role_permissions_role_fk").on(e.tenant_id, e.role_id),
|
|
571
571
|
x("role_permissions_permission_fk").on(e.tenant_id, e.resource_server_identifier, e.permission_name)
|
|
572
|
-
]),
|
|
572
|
+
]), Ge = w("user_permissions", {
|
|
573
573
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
574
574
|
user_id: T("user_id", { length: 191 }).notNull(),
|
|
575
575
|
resource_server_identifier: T("resource_server_identifier", { length: 191 }).notNull(),
|
|
@@ -590,7 +590,7 @@ var je = Object.defineProperty, Me = (e, t) => {
|
|
|
590
590
|
x("user_permissions_user_fk").on(e.tenant_id, e.user_id),
|
|
591
591
|
x("user_permissions_permission_fk").on(e.tenant_id, e.resource_server_identifier, e.permission_name),
|
|
592
592
|
x("user_permissions_organization_fk").on(e.organization_id)
|
|
593
|
-
]),
|
|
593
|
+
]), G = w("user_roles", {
|
|
594
594
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
595
595
|
user_id: T("user_id", { length: 191 }).notNull(),
|
|
596
596
|
role_id: T("role_id", { length: 21 }).notNull(),
|
|
@@ -609,7 +609,7 @@ var je = Object.defineProperty, Me = (e, t) => {
|
|
|
609
609
|
x("user_roles_user_fk").on(e.tenant_id, e.user_id),
|
|
610
610
|
x("user_roles_role_fk").on(e.tenant_id, e.role_id),
|
|
611
611
|
x("user_roles_organization_fk").on(e.organization_id)
|
|
612
|
-
]),
|
|
612
|
+
]), K = w("resource_servers", {
|
|
613
613
|
id: T("id", { length: 21 }).notNull(),
|
|
614
614
|
tenant_id: T("tenant_id", { length: 191 }).notNull(),
|
|
615
615
|
identifier: T("identifier", { length: 191 }).notNull(),
|
|
@@ -630,8 +630,8 @@ var je = Object.defineProperty, Me = (e, t) => {
|
|
|
630
630
|
}, (e) => [C({
|
|
631
631
|
columns: [e.tenant_id, e.id],
|
|
632
632
|
name: "resource_servers_pk"
|
|
633
|
-
})]),
|
|
634
|
-
tenant_id: T("tenant_id", { length: 191 }).primaryKey().references(() =>
|
|
633
|
+
})]), Ke = w("branding", {
|
|
634
|
+
tenant_id: T("tenant_id", { length: 191 }).primaryKey().references(() => O.id, { onDelete: "cascade" }),
|
|
635
635
|
logo_url: T("logo_url", { length: 512 }),
|
|
636
636
|
favicon_url: T("favicon_url", { length: 512 }),
|
|
637
637
|
font_url: T("font_url", { length: 512 }),
|
|
@@ -641,13 +641,13 @@ var je = Object.defineProperty, Me = (e, t) => {
|
|
|
641
641
|
colors_page_background_end: T("colors_page_background_end", { length: 8 }),
|
|
642
642
|
colors_page_background_angle_dev: S("colors_page_background_angle_dev"),
|
|
643
643
|
dark_mode: T("dark_mode", { length: 8 })
|
|
644
|
-
}),
|
|
645
|
-
tenant_id: T("tenant_id", { length: 191 }).primaryKey().references(() =>
|
|
644
|
+
}), qe = w("universal_login_templates", {
|
|
645
|
+
tenant_id: T("tenant_id", { length: 191 }).primaryKey().references(() => O.id, { onDelete: "cascade" }),
|
|
646
646
|
body: T("body").notNull(),
|
|
647
647
|
created_at_ts: S("created_at_ts").notNull(),
|
|
648
648
|
updated_at_ts: S("updated_at_ts").notNull()
|
|
649
|
-
}),
|
|
650
|
-
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() =>
|
|
649
|
+
}), Je = w("themes", {
|
|
650
|
+
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
651
651
|
themeId: T("themeId", { length: 255 }).notNull(),
|
|
652
652
|
displayName: T("displayName", { length: 255 }).notNull(),
|
|
653
653
|
colors_primary_button_label: T("colors_primary_button_label", { length: 24 }).notNull(),
|
|
@@ -706,10 +706,10 @@ var je = Object.defineProperty, Me = (e, t) => {
|
|
|
706
706
|
}, (e) => [C({
|
|
707
707
|
columns: [e.tenant_id, e.themeId],
|
|
708
708
|
name: "themes_pkey"
|
|
709
|
-
}), x("themes_tenant_id_idx").on(e.tenant_id)]),
|
|
709
|
+
}), x("themes_tenant_id_idx").on(e.tenant_id)]), Ye = w("forms", {
|
|
710
710
|
id: T("id", { length: 255 }).primaryKey(),
|
|
711
711
|
name: T("name", { length: 255 }).notNull(),
|
|
712
|
-
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() =>
|
|
712
|
+
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
713
713
|
messages: T("messages", { length: 255 }),
|
|
714
714
|
languages: T("languages", { length: 255 }),
|
|
715
715
|
translations: T("translations", { length: 4096 }),
|
|
@@ -719,21 +719,21 @@ var je = Object.defineProperty, Me = (e, t) => {
|
|
|
719
719
|
style: T("style", { length: 1042 }),
|
|
720
720
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
721
721
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
722
|
-
}, (e) => [x("forms_tenant_id_idx").on(e.tenant_id)]),
|
|
722
|
+
}, (e) => [x("forms_tenant_id_idx").on(e.tenant_id)]), Xe = w("flows", {
|
|
723
723
|
id: T("id", { length: 24 }).primaryKey(),
|
|
724
|
-
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() =>
|
|
724
|
+
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
725
725
|
name: T("name", { length: 150 }).notNull(),
|
|
726
726
|
actions: T("actions"),
|
|
727
727
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
728
728
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
729
|
-
}, (e) => [x("flows_tenant_id_idx").on(e.tenant_id)]),
|
|
729
|
+
}, (e) => [x("flows_tenant_id_idx").on(e.tenant_id)]), Ze = w("prompt_settings", {
|
|
730
730
|
tenant_id: T("tenant_id", { length: 191 }).primaryKey(),
|
|
731
731
|
universal_login_experience: T("universal_login_experience", { length: 16 }).notNull().default("new"),
|
|
732
732
|
identifier_first: S("identifier_first", { mode: "boolean" }).notNull().default(!0),
|
|
733
733
|
password_first: S("password_first", { mode: "boolean" }).notNull().default(!1),
|
|
734
734
|
webauthn_platform_first_factor: S("webauthn_platform_first_factor", { mode: "boolean" }).notNull().default(!1),
|
|
735
735
|
show_last_used_connection: S("show_last_used_connection", { mode: "boolean" }).notNull().default(!1)
|
|
736
|
-
}),
|
|
736
|
+
}), Qe = w("email_providers", {
|
|
737
737
|
tenant_id: T("tenant_id", { length: 191 }).primaryKey(),
|
|
738
738
|
name: T("name", { length: 255 }).notNull(),
|
|
739
739
|
enabled: S("enabled", { mode: "boolean" }).notNull(),
|
|
@@ -742,8 +742,8 @@ var je = Object.defineProperty, Me = (e, t) => {
|
|
|
742
742
|
settings: T("settings", { length: 2048 }).notNull().default("{}"),
|
|
743
743
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
744
744
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
745
|
-
}),
|
|
746
|
-
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() =>
|
|
745
|
+
}), $e = w("email_templates", {
|
|
746
|
+
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
747
747
|
template: T("template", { length: 64 }).notNull(),
|
|
748
748
|
body: T("body").notNull(),
|
|
749
749
|
from: T("from", { length: 255 }).notNull(),
|
|
@@ -755,9 +755,9 @@ var je = Object.defineProperty, Me = (e, t) => {
|
|
|
755
755
|
enabled: S("enabled", { mode: "boolean" }).notNull().default(!0),
|
|
756
756
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
757
757
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
758
|
-
}, (e) => [C({ columns: [e.tenant_id, e.template] })]),
|
|
758
|
+
}, (e) => [C({ columns: [e.tenant_id, e.template] })]), et = w("hooks", {
|
|
759
759
|
hook_id: T("hook_id", { length: 21 }).primaryKey(),
|
|
760
|
-
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() =>
|
|
760
|
+
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
761
761
|
url: T("url", { length: 512 }),
|
|
762
762
|
trigger_id: T("trigger_id", { length: 255 }).notNull(),
|
|
763
763
|
enabled: S("enabled", { mode: "boolean" }).notNull(),
|
|
@@ -771,16 +771,16 @@ var je = Object.defineProperty, Me = (e, t) => {
|
|
|
771
771
|
page_id: T("page_id", { length: 64 }),
|
|
772
772
|
permission_required: T("permission_required", { length: 255 }),
|
|
773
773
|
metadata: T("metadata")
|
|
774
|
-
}, (e) => [x("hooks_tenant_id_idx").on(e.tenant_id)]),
|
|
774
|
+
}, (e) => [x("hooks_tenant_id_idx").on(e.tenant_id)]), tt = w("hook_code", {
|
|
775
775
|
id: T("id", { length: 21 }).primaryKey(),
|
|
776
|
-
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() =>
|
|
776
|
+
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
777
777
|
code: T("code").notNull(),
|
|
778
778
|
secrets: T("secrets"),
|
|
779
779
|
created_at_ts: S("created_at_ts").notNull(),
|
|
780
780
|
updated_at_ts: S("updated_at_ts").notNull()
|
|
781
|
-
}, (e) => [x("hook_code_tenant_id_idx").on(e.tenant_id)]),
|
|
781
|
+
}, (e) => [x("hook_code_tenant_id_idx").on(e.tenant_id)]), nt = w("keys", {
|
|
782
782
|
kid: T("kid", { length: 255 }).primaryKey(),
|
|
783
|
-
tenant_id: T("tenant_id", { length: 191 }).references(() =>
|
|
783
|
+
tenant_id: T("tenant_id", { length: 191 }).references(() => O.id, { onDelete: "cascade" }),
|
|
784
784
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
785
785
|
revoked_at: T("revoked_at", { length: 35 }),
|
|
786
786
|
cert: T("cert", { length: 4096 }),
|
|
@@ -790,9 +790,9 @@ var je = Object.defineProperty, Me = (e, t) => {
|
|
|
790
790
|
current_since: T("current_since", { length: 35 }),
|
|
791
791
|
current_until: T("current_until", { length: 35 }),
|
|
792
792
|
type: T("type", { length: 50 }).notNull().default("jwt_signing"),
|
|
793
|
-
connection: T("connection", { length: 255 }).references(() =>
|
|
794
|
-
}),
|
|
795
|
-
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() =>
|
|
793
|
+
connection: T("connection", { length: 255 }).references(() => Ve.id, { onDelete: "cascade" })
|
|
794
|
+
}), rt = w("custom_text", {
|
|
795
|
+
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
796
796
|
prompt: T("prompt", { length: 64 }).notNull(),
|
|
797
797
|
language: T("language", { length: 16 }).notNull(),
|
|
798
798
|
custom_text: T("custom_text").notNull(),
|
|
@@ -802,9 +802,9 @@ var je = Object.defineProperty, Me = (e, t) => {
|
|
|
802
802
|
e.tenant_id,
|
|
803
803
|
e.prompt,
|
|
804
804
|
e.language
|
|
805
|
-
] })]),
|
|
805
|
+
] })]), q = w("authentication_methods", {
|
|
806
806
|
id: T("id", { length: 26 }).primaryKey(),
|
|
807
|
-
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() =>
|
|
807
|
+
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
808
808
|
user_id: T("user_id", { length: 255 }).notNull(),
|
|
809
809
|
type: T("type", { length: 32 }).notNull(),
|
|
810
810
|
phone_number: T("phone_number", { length: 32 }),
|
|
@@ -855,7 +855,7 @@ var je = Object.defineProperty, Me = (e, t) => {
|
|
|
855
855
|
x("IDX_logs_tenant_date_type_user").on(e.tenant_id, e.date, e.type, e.user_id)
|
|
856
856
|
]), Y = w("outbox_events", {
|
|
857
857
|
id: T("id", { length: 26 }).primaryKey(),
|
|
858
|
-
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() =>
|
|
858
|
+
tenant_id: T("tenant_id", { length: 191 }).notNull().references(() => O.id, { onDelete: "cascade" }),
|
|
859
859
|
event_type: T("event_type", { length: 64 }).notNull(),
|
|
860
860
|
log_type: T("log_type", { length: 64 }).notNull(),
|
|
861
861
|
aggregate_type: T("aggregate_type", { length: 64 }).notNull(),
|
|
@@ -884,7 +884,7 @@ var je = Object.defineProperty, Me = (e, t) => {
|
|
|
884
884
|
handlers: T("handlers", { length: 16384 }).notNull().default("[]"),
|
|
885
885
|
created_at: T("created_at", { length: 35 }).notNull(),
|
|
886
886
|
updated_at: T("updated_at", { length: 35 }).notNull()
|
|
887
|
-
}, (e) => [x("proxy_routes_tenant_id_idx").on(e.tenant_id), x("proxy_routes_custom_domain_id_idx").on(e.custom_domain_id)]),
|
|
887
|
+
}, (e) => [x("proxy_routes_tenant_id_idx").on(e.tenant_id), x("proxy_routes_custom_domain_id_idx").on(e.custom_domain_id)]), it = w("scim_configurations", {
|
|
888
888
|
connection_id: T("connection_id", { length: 255 }).notNull(),
|
|
889
889
|
tenant_id: T("tenant_id", { length: 255 }).notNull(),
|
|
890
890
|
user_id_attribute: T("user_id_attribute", { length: 255 }).notNull().default("externalId"),
|
|
@@ -903,8 +903,8 @@ var je = Object.defineProperty, Me = (e, t) => {
|
|
|
903
903
|
}, (e) => [
|
|
904
904
|
C({ columns: [e.tenant_id, e.token_id] }),
|
|
905
905
|
x("scim_tokens_tenant_connection_idx").on(e.tenant_id, e.connection_id),
|
|
906
|
-
|
|
907
|
-
]),
|
|
906
|
+
re("scim_tokens_tenant_hash_idx").on(e.tenant_id, e.token_hash)
|
|
907
|
+
]), at = w("scim_external_ids", {
|
|
908
908
|
tenant_id: T("tenant_id", { length: 255 }).notNull(),
|
|
909
909
|
connection_id: T("connection_id", { length: 255 }).notNull(),
|
|
910
910
|
external_id: T("external_id", { length: 255 }).notNull(),
|
|
@@ -914,54 +914,54 @@ var je = Object.defineProperty, Me = (e, t) => {
|
|
|
914
914
|
e.tenant_id,
|
|
915
915
|
e.connection_id,
|
|
916
916
|
e.user_id
|
|
917
|
-
] }),
|
|
918
|
-
actionExecutions: () =>
|
|
917
|
+
] }), re("scim_external_ids_connection_external_idx").on(e.tenant_id, e.connection_id, e.external_id)]), ot = /* @__PURE__ */ Fe({
|
|
918
|
+
actionExecutions: () => Ie,
|
|
919
919
|
actionVersions: () => A,
|
|
920
|
-
actions: () =>
|
|
921
|
-
authenticationCodes: () =>
|
|
922
|
-
authenticationMethods: () =>
|
|
923
|
-
branding: () =>
|
|
920
|
+
actions: () => k,
|
|
921
|
+
authenticationCodes: () => Re,
|
|
922
|
+
authenticationMethods: () => q,
|
|
923
|
+
branding: () => Ke,
|
|
924
924
|
clientGrants: () => z,
|
|
925
925
|
clientRegistrationTokens: () => R,
|
|
926
926
|
clients: () => L,
|
|
927
927
|
codes: () => I,
|
|
928
|
-
connections: () =>
|
|
929
|
-
customDomains: () =>
|
|
930
|
-
customText: () =>
|
|
931
|
-
domains: () =>
|
|
932
|
-
emailProviders: () =>
|
|
933
|
-
emailTemplates: () =>
|
|
934
|
-
flows: () =>
|
|
935
|
-
forms: () =>
|
|
928
|
+
connections: () => Ve,
|
|
929
|
+
customDomains: () => V,
|
|
930
|
+
customText: () => rt,
|
|
931
|
+
domains: () => He,
|
|
932
|
+
emailProviders: () => Qe,
|
|
933
|
+
emailTemplates: () => $e,
|
|
934
|
+
flows: () => Xe,
|
|
935
|
+
forms: () => Ye,
|
|
936
936
|
grants: () => B,
|
|
937
|
-
hookCode: () =>
|
|
938
|
-
hooks: () =>
|
|
939
|
-
invites: () =>
|
|
940
|
-
keys: () =>
|
|
937
|
+
hookCode: () => tt,
|
|
938
|
+
hooks: () => et,
|
|
939
|
+
invites: () => Ue,
|
|
940
|
+
keys: () => nt,
|
|
941
941
|
loginSessions: () => F,
|
|
942
942
|
logs: () => J,
|
|
943
|
-
organizations: () =>
|
|
944
|
-
otps: () =>
|
|
943
|
+
organizations: () => H,
|
|
944
|
+
otps: () => ze,
|
|
945
945
|
outboxEvents: () => Y,
|
|
946
946
|
passwords: () => M,
|
|
947
|
-
promptSettings: () =>
|
|
947
|
+
promptSettings: () => Ze,
|
|
948
948
|
proxyRoutes: () => X,
|
|
949
949
|
refreshTokens: () => P,
|
|
950
|
-
resourceServers: () =>
|
|
951
|
-
rolePermissions: () =>
|
|
952
|
-
roles: () =>
|
|
953
|
-
scimConfigurations: () =>
|
|
954
|
-
scimExternalIds: () =>
|
|
950
|
+
resourceServers: () => K,
|
|
951
|
+
rolePermissions: () => We,
|
|
952
|
+
roles: () => W,
|
|
953
|
+
scimConfigurations: () => it,
|
|
954
|
+
scimExternalIds: () => at,
|
|
955
955
|
scimTokens: () => Z,
|
|
956
956
|
sessions: () => N,
|
|
957
|
-
tenants: () =>
|
|
958
|
-
themes: () =>
|
|
959
|
-
tickets: () =>
|
|
960
|
-
universalLoginTemplates: () =>
|
|
961
|
-
userActivity: () =>
|
|
962
|
-
userOrganizations: () =>
|
|
963
|
-
userPermissions: () =>
|
|
964
|
-
userRoles: () =>
|
|
957
|
+
tenants: () => O,
|
|
958
|
+
themes: () => Je,
|
|
959
|
+
tickets: () => Be,
|
|
960
|
+
universalLoginTemplates: () => qe,
|
|
961
|
+
userActivity: () => Le,
|
|
962
|
+
userOrganizations: () => U,
|
|
963
|
+
userPermissions: () => Ge,
|
|
964
|
+
userRoles: () => G,
|
|
965
965
|
users: () => j
|
|
966
966
|
});
|
|
967
967
|
//#endregion
|
|
@@ -975,14 +975,14 @@ function Q(e, t) {
|
|
|
975
975
|
}
|
|
976
976
|
return e;
|
|
977
977
|
}
|
|
978
|
-
function
|
|
978
|
+
function st(e, t = "", n = {}) {
|
|
979
979
|
for (let r in e) if (Object.prototype.hasOwnProperty.call(e, r)) {
|
|
980
980
|
let i = t ? `${t}_${r}` : r, a = e[r];
|
|
981
|
-
typeof a == "object" && a && !Array.isArray(a) ?
|
|
981
|
+
typeof a == "object" && a && !Array.isArray(a) ? st(a, i, n) : typeof a == "boolean" ? n[i] = +!!a : n[i] = a;
|
|
982
982
|
}
|
|
983
983
|
return n;
|
|
984
984
|
}
|
|
985
|
-
function
|
|
985
|
+
function ct(e, t) {
|
|
986
986
|
let n = {};
|
|
987
987
|
for (let [r, i] of Object.entries(e)) {
|
|
988
988
|
let e = t.find((e) => r.startsWith(`${e}_`));
|
|
@@ -999,44 +999,39 @@ function ot(e, t) {
|
|
|
999
999
|
}
|
|
1000
1000
|
//#endregion
|
|
1001
1001
|
//#region src/helpers/filter.ts
|
|
1002
|
-
function
|
|
1002
|
+
function lt(e) {
|
|
1003
1003
|
return typeof e == "object" && !!e && "coalesce" in e && "defaultValue" in e;
|
|
1004
1004
|
}
|
|
1005
|
-
function
|
|
1005
|
+
function ut(e) {
|
|
1006
1006
|
return y`coalesce(${e.coalesce}, ${e.defaultValue})`;
|
|
1007
1007
|
}
|
|
1008
|
-
function
|
|
1008
|
+
function dt(n, r, i, l = []) {
|
|
1009
1009
|
let ee = u(n, te) ? o(n) : n, b = new Set(l), ne = (e) => {
|
|
1010
1010
|
let t = Number(e);
|
|
1011
1011
|
return Number.isFinite(t) ? t : e;
|
|
1012
|
-
}, x = r
|
|
1012
|
+
}, x = De(r);
|
|
1013
1013
|
if (x.length > 1) {
|
|
1014
|
-
let
|
|
1015
|
-
let
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1014
|
+
let n = x.map((n) => {
|
|
1015
|
+
let r = n.map((t) => {
|
|
1016
|
+
let n = t.match(/^([^:]+):(.+)$/);
|
|
1017
|
+
if (!n) return null;
|
|
1018
|
+
let [, r, i] = n;
|
|
1019
|
+
if (!r || !i) return null;
|
|
1020
|
+
let o = r.trim(), s = Me(i.replace(/^"(.*)"$/, "$1").trim()), c = ee[o];
|
|
1021
|
+
return lt(c) ? a(ut(c), ne(s)) : u(c, e) ? b.has(o) ? p(c, `%${s}%`) : a(c, s) : null;
|
|
1022
|
+
}).filter((e) => e !== null);
|
|
1023
|
+
return r.length === 0 ? null : r.length === 1 ? r[0] : t(...r) ?? null;
|
|
1023
1024
|
}).filter((e) => e !== null);
|
|
1024
|
-
return
|
|
1025
|
-
}
|
|
1026
|
-
let S = [], C = "", w = !1;
|
|
1027
|
-
for (let e = 0; e < r.length; e++) {
|
|
1028
|
-
let t = r[e];
|
|
1029
|
-
t === "\"" ? (w = !w, C += t) : t === " " && !w ? C.trim() && (S.push(C.trim()), C = "") : C += t;
|
|
1025
|
+
return n.length === 0 ? void 0 : v(...n);
|
|
1030
1026
|
}
|
|
1031
|
-
|
|
1032
|
-
let T = S.filter((e) => e !== "AND").map((e) => e.replace(/^([^:]+)=/g, "$1:")).map((e) => {
|
|
1027
|
+
let S = (x[0] ?? []).filter((e) => e !== "AND").map((e) => e.replace(/^([^:]+)=/g, "$1:")).map((e) => {
|
|
1033
1028
|
let t = e.startsWith("-"), n = null, r = "", i = !1, a;
|
|
1034
1029
|
if (e.startsWith("-_exists_:")) n = e.substring(10), i = !0, t = !0;
|
|
1035
1030
|
else if (e.startsWith("_exists_:")) n = e.substring(9), i = !0, t = !1;
|
|
1036
1031
|
else if (e.includes(":")) {
|
|
1037
1032
|
let o = t ? e.substring(1) : e, s = o.indexOf(":");
|
|
1038
|
-
n = o.substring(0, s), r = o.substring(s + 1), i = !1, r.startsWith(">=") ? (a = ">=", r = r.substring(2)) : r.startsWith(">") ? (a = ">", r = r.substring(1)) : r.startsWith("<=") ? (a = "<=", r = r.substring(2)) : r.startsWith("<") ? (a = "<", r = r.substring(1)) : a = "=", r.startsWith("\"") && r.endsWith("\"") && r.length > 1 && (r = r.slice(1, -1));
|
|
1039
|
-
} else n = null, r = e, i = !1;
|
|
1033
|
+
n = o.substring(0, s), r = o.substring(s + 1), i = !1, r.startsWith(">=") ? (a = ">=", r = r.substring(2)) : r.startsWith(">") ? (a = ">", r = r.substring(1)) : r.startsWith("<=") ? (a = "<=", r = r.substring(2)) : r.startsWith("<") ? (a = "<", r = r.substring(1)) : a = "=", r.startsWith("\"") && r.endsWith("\"") && r.length > 1 && (r = r.slice(1, -1)), r = Me(r);
|
|
1034
|
+
} else n = null, r = Me(e), i = !1;
|
|
1040
1035
|
return {
|
|
1041
1036
|
key: n,
|
|
1042
1037
|
value: r,
|
|
@@ -1044,67 +1039,67 @@ function lt(n, r, i, l = []) {
|
|
|
1044
1039
|
isExistsQuery: i,
|
|
1045
1040
|
operator: a
|
|
1046
1041
|
};
|
|
1047
|
-
}),
|
|
1048
|
-
for (let { key: t, value: n, isNegation: r, isExistsQuery: o, operator: l } of
|
|
1049
|
-
let i = ee[t], v =
|
|
1042
|
+
}), C = [];
|
|
1043
|
+
for (let { key: t, value: n, isNegation: r, isExistsQuery: o, operator: l } of S) if (t) {
|
|
1044
|
+
let i = ee[t], v = lt(i), te = v ? i.coalesce : u(i, e) ? i : void 0, x = v ? ne(n) : n;
|
|
1050
1045
|
if (!te) {
|
|
1051
|
-
o ?
|
|
1046
|
+
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}`);
|
|
1052
1047
|
continue;
|
|
1053
1048
|
}
|
|
1054
|
-
let S = v ?
|
|
1055
|
-
if (o)
|
|
1056
|
-
else if (b.has(t) && l === "=")
|
|
1049
|
+
let S = v ? ut(i) : y`${te}`;
|
|
1050
|
+
if (o) C.push(r ? f(te) : d(te));
|
|
1051
|
+
else if (b.has(t) && l === "=") C.push(r ? _(te, `%${n}%`) : p(te, `%${n}%`));
|
|
1057
1052
|
else if (r) switch (l) {
|
|
1058
1053
|
case ">":
|
|
1059
|
-
|
|
1054
|
+
C.push(h(S, x));
|
|
1060
1055
|
break;
|
|
1061
1056
|
case ">=":
|
|
1062
|
-
|
|
1057
|
+
C.push(m(S, x));
|
|
1063
1058
|
break;
|
|
1064
1059
|
case "<":
|
|
1065
|
-
|
|
1060
|
+
C.push(c(S, x));
|
|
1066
1061
|
break;
|
|
1067
1062
|
case "<=":
|
|
1068
|
-
|
|
1063
|
+
C.push(s(S, x));
|
|
1069
1064
|
break;
|
|
1070
|
-
default:
|
|
1065
|
+
default: C.push(g(S, x));
|
|
1071
1066
|
}
|
|
1072
1067
|
else switch (l) {
|
|
1073
1068
|
case ">":
|
|
1074
|
-
|
|
1069
|
+
C.push(s(S, x));
|
|
1075
1070
|
break;
|
|
1076
1071
|
case ">=":
|
|
1077
|
-
|
|
1072
|
+
C.push(c(S, x));
|
|
1078
1073
|
break;
|
|
1079
1074
|
case "<":
|
|
1080
|
-
|
|
1075
|
+
C.push(m(S, x));
|
|
1081
1076
|
break;
|
|
1082
1077
|
case "<=":
|
|
1083
|
-
|
|
1078
|
+
C.push(h(S, x));
|
|
1084
1079
|
break;
|
|
1085
|
-
default:
|
|
1080
|
+
default: C.push(a(S, x));
|
|
1086
1081
|
}
|
|
1087
1082
|
} else if (n) {
|
|
1088
1083
|
let t = i.includes("email") ? ee.email : void 0;
|
|
1089
|
-
if (
|
|
1090
|
-
|
|
1084
|
+
if (ve(n) && u(t, e)) {
|
|
1085
|
+
C.push(a(t, n.toLowerCase()));
|
|
1091
1086
|
continue;
|
|
1092
1087
|
}
|
|
1093
1088
|
let r = (n.includes("|") ? [...i, "user_id"] : i).map((t) => {
|
|
1094
1089
|
let r = ee[t];
|
|
1095
1090
|
return u(r, e) ? t === "user_id" ? a(r, n) : p(r, `%${n}%`) : null;
|
|
1096
1091
|
}).filter((e) => e !== null);
|
|
1097
|
-
r.length > 0 &&
|
|
1092
|
+
r.length > 0 && C.push(v(...r));
|
|
1098
1093
|
}
|
|
1099
|
-
if (
|
|
1094
|
+
if (C.length !== 0) return C.length === 1 ? C[0] : t(...C);
|
|
1100
1095
|
}
|
|
1101
1096
|
//#endregion
|
|
1102
1097
|
//#region src/adapters/actions.ts
|
|
1103
|
-
function
|
|
1098
|
+
function ft(e) {
|
|
1104
1099
|
let t = Q(e);
|
|
1105
1100
|
return Array.isArray(t) ? t : [];
|
|
1106
1101
|
}
|
|
1107
|
-
function
|
|
1102
|
+
function pt(e) {
|
|
1108
1103
|
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;
|
|
1109
1104
|
return {
|
|
1110
1105
|
...f,
|
|
@@ -1121,11 +1116,11 @@ function dt(e) {
|
|
|
1121
1116
|
updated_at: new Date(Number(n)).toISOString()
|
|
1122
1117
|
};
|
|
1123
1118
|
}
|
|
1124
|
-
function
|
|
1119
|
+
function mt(e) {
|
|
1125
1120
|
return {
|
|
1126
1121
|
async create(t, n) {
|
|
1127
1122
|
let r = Date.now(), i = `act_${b()}`;
|
|
1128
|
-
return await e.insert(
|
|
1123
|
+
return await e.insert(k).values({
|
|
1129
1124
|
id: i,
|
|
1130
1125
|
tenant_id: t,
|
|
1131
1126
|
name: n.name,
|
|
@@ -1156,28 +1151,28 @@ function ft(e) {
|
|
|
1156
1151
|
};
|
|
1157
1152
|
},
|
|
1158
1153
|
async get(n, r) {
|
|
1159
|
-
let i = await e.select().from(
|
|
1160
|
-
return i ?
|
|
1154
|
+
let i = await e.select().from(k).where(t(a(k.tenant_id, n), a(k.id, r))).get();
|
|
1155
|
+
return i ? pt(i) : null;
|
|
1161
1156
|
},
|
|
1162
1157
|
async list(o, s = {}) {
|
|
1163
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s, p = [a(
|
|
1158
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s, p = [a(k.tenant_id, o)];
|
|
1164
1159
|
if (f) {
|
|
1165
|
-
let e =
|
|
1160
|
+
let e = dt(k, f, ["name"]);
|
|
1166
1161
|
e && p.push(e);
|
|
1167
1162
|
}
|
|
1168
|
-
let m = t(...p), h = e.select().from(
|
|
1163
|
+
let m = t(...p), h = e.select().from(k).where(m).$dynamic();
|
|
1169
1164
|
if (d?.sort_by) {
|
|
1170
|
-
let e =
|
|
1165
|
+
let e = k[d.sort_by];
|
|
1171
1166
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
1172
1167
|
}
|
|
1173
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
1168
|
+
let g = (await h.offset(c * l).limit(l)).map(pt);
|
|
1174
1169
|
if (!u) return {
|
|
1175
1170
|
actions: g,
|
|
1176
1171
|
start: 0,
|
|
1177
1172
|
limit: 0,
|
|
1178
1173
|
length: 0
|
|
1179
1174
|
};
|
|
1180
|
-
let [_] = await e.select({ count: r() }).from(
|
|
1175
|
+
let [_] = await e.select({ count: r() }).from(k).where(m);
|
|
1181
1176
|
return {
|
|
1182
1177
|
actions: g,
|
|
1183
1178
|
start: c * l,
|
|
@@ -1188,7 +1183,7 @@ function ft(e) {
|
|
|
1188
1183
|
async update(n, r, i) {
|
|
1189
1184
|
let o = { updated_at_ts: Date.now() };
|
|
1190
1185
|
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) {
|
|
1191
|
-
let s = await e.select({ secrets:
|
|
1186
|
+
let s = await e.select({ secrets: k.secrets }).from(k).where(t(a(k.tenant_id, n), a(k.id, r))).get(), c = new Map(ft(s?.secrets).map((e) => [e.name, e])), l = i.secrets.map((e) => e.value === void 0 ? {
|
|
1192
1187
|
name: e.name,
|
|
1193
1188
|
value: c.get(e.name)?.value
|
|
1194
1189
|
} : e);
|
|
@@ -1198,21 +1193,21 @@ function ft(e) {
|
|
|
1198
1193
|
let e = new Date(i.deployed_at).getTime();
|
|
1199
1194
|
Number.isFinite(e) && (o.deployed_at_ts = e);
|
|
1200
1195
|
}
|
|
1201
|
-
return i.is_system !== void 0 && (o.is_system = +!!i.is_system), i.inherit !== void 0 && (o.inherit = +!!i.inherit), (await e.update(
|
|
1196
|
+
return i.is_system !== void 0 && (o.is_system = +!!i.is_system), i.inherit !== void 0 && (o.inherit = +!!i.inherit), (await e.update(k).set(o).where(t(a(k.tenant_id, n), a(k.id, r))).returning()).length > 0;
|
|
1202
1197
|
},
|
|
1203
1198
|
async remove(n, r) {
|
|
1204
|
-
return (await e.delete(
|
|
1199
|
+
return (await e.delete(k).where(t(a(k.tenant_id, n), a(k.id, r))).returning()).length > 0;
|
|
1205
1200
|
}
|
|
1206
1201
|
};
|
|
1207
1202
|
}
|
|
1208
1203
|
//#endregion
|
|
1209
1204
|
//#region src/adapters/actionExecutions.ts
|
|
1210
|
-
var
|
|
1211
|
-
function
|
|
1205
|
+
var ht = 500;
|
|
1206
|
+
function gt(e) {
|
|
1212
1207
|
return {
|
|
1213
1208
|
async create(t, n) {
|
|
1214
1209
|
let r = Date.now();
|
|
1215
|
-
return await e.insert(
|
|
1210
|
+
return await e.insert(Ie).values({
|
|
1216
1211
|
id: n.id,
|
|
1217
1212
|
tenant_id: t,
|
|
1218
1213
|
trigger_id: n.trigger_id,
|
|
@@ -1233,7 +1228,7 @@ function mt(e) {
|
|
|
1233
1228
|
};
|
|
1234
1229
|
},
|
|
1235
1230
|
async get(n, r) {
|
|
1236
|
-
let i = await e.select().from(
|
|
1231
|
+
let i = await e.select().from(Ie).where(t(a(Ie.tenant_id, n), a(Ie.id, r))).get();
|
|
1237
1232
|
return i ? {
|
|
1238
1233
|
id: i.id,
|
|
1239
1234
|
tenant_id: i.tenant_id,
|
|
@@ -1250,8 +1245,8 @@ function mt(e) {
|
|
|
1250
1245
|
if (Number.isNaN(n)) throw Error(`Invalid olderThan date: ${t}`);
|
|
1251
1246
|
let r = 0;
|
|
1252
1247
|
for (;;) {
|
|
1253
|
-
let t = await e.delete(
|
|
1254
|
-
if (r += t.length, t.length <
|
|
1248
|
+
let t = await e.delete(Ie).where(y`rowid IN (SELECT rowid FROM ${Ie} WHERE ${Ie.created_at_ts} < ${n} LIMIT ${ht})`).returning({ id: Ie.id });
|
|
1249
|
+
if (r += t.length, t.length < ht) break;
|
|
1255
1250
|
}
|
|
1256
1251
|
return r;
|
|
1257
1252
|
}
|
|
@@ -1259,12 +1254,12 @@ function mt(e) {
|
|
|
1259
1254
|
}
|
|
1260
1255
|
//#endregion
|
|
1261
1256
|
//#region src/adapters/atomic.ts
|
|
1262
|
-
function
|
|
1257
|
+
function _t(e) {
|
|
1263
1258
|
let t = e;
|
|
1264
1259
|
return typeof t == "object" && !!t && "batch" in t && typeof t.batch == "function";
|
|
1265
1260
|
}
|
|
1266
|
-
async function
|
|
1267
|
-
if (
|
|
1261
|
+
async function vt(e, t) {
|
|
1262
|
+
if (_t(e)) return e.batch(t);
|
|
1268
1263
|
await e.run(y`BEGIN`);
|
|
1269
1264
|
try {
|
|
1270
1265
|
let n = [];
|
|
@@ -1281,7 +1276,7 @@ async function gt(e, t) {
|
|
|
1281
1276
|
}
|
|
1282
1277
|
//#endregion
|
|
1283
1278
|
//#region src/adapters/actionVersions.ts
|
|
1284
|
-
function
|
|
1279
|
+
function yt(e) {
|
|
1285
1280
|
let { created_at_ts: t, updated_at_ts: n, secrets: r, dependencies: i, supported_triggers: a, deployed: o, runtime: s, ...c } = e;
|
|
1286
1281
|
return {
|
|
1287
1282
|
...c,
|
|
@@ -1294,7 +1289,7 @@ function _t(e) {
|
|
|
1294
1289
|
updated_at: new Date(Number(n)).toISOString()
|
|
1295
1290
|
};
|
|
1296
1291
|
}
|
|
1297
|
-
function
|
|
1292
|
+
function bt(e) {
|
|
1298
1293
|
return {
|
|
1299
1294
|
async create(n, r) {
|
|
1300
1295
|
let o = Date.now(), s = `ver_${b()}`, c = r.deployed !== !1, l = ((await e.select({ number: A.number }).from(A).where(t(a(A.tenant_id, n), a(A.action_id, r.action_id))).orderBy(i(A.number)).limit(1).get())?.number ?? 0) + 1, u = e.insert(A).values({
|
|
@@ -1311,7 +1306,7 @@ function vt(e) {
|
|
|
1311
1306
|
created_at_ts: o,
|
|
1312
1307
|
updated_at_ts: o
|
|
1313
1308
|
});
|
|
1314
|
-
return await
|
|
1309
|
+
return await vt(e, c ? [e.update(A).set({
|
|
1315
1310
|
deployed: 0,
|
|
1316
1311
|
updated_at_ts: o
|
|
1317
1312
|
}).where(t(a(A.tenant_id, n), a(A.action_id, r.action_id), a(A.deployed, 1))), u] : [u]), {
|
|
@@ -1331,10 +1326,10 @@ function vt(e) {
|
|
|
1331
1326
|
},
|
|
1332
1327
|
async get(n, r, i) {
|
|
1333
1328
|
let o = await e.select().from(A).where(t(a(A.tenant_id, n), a(A.action_id, r), a(A.id, i))).get();
|
|
1334
|
-
return o ?
|
|
1329
|
+
return o ? yt(o) : null;
|
|
1335
1330
|
},
|
|
1336
1331
|
async list(n, o, s = {}) {
|
|
1337
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1 } = s, d = t(a(A.tenant_id, n), a(A.action_id, o)), f = (await e.select().from(A).where(d).orderBy(i(A.number)).offset(c * l).limit(l)).map(
|
|
1332
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1 } = s, d = t(a(A.tenant_id, n), a(A.action_id, o)), f = (await e.select().from(A).where(d).orderBy(i(A.number)).offset(c * l).limit(l)).map(yt);
|
|
1338
1333
|
if (!u) return {
|
|
1339
1334
|
versions: f,
|
|
1340
1335
|
start: 0,
|
|
@@ -1356,16 +1351,16 @@ function vt(e) {
|
|
|
1356
1351
|
}
|
|
1357
1352
|
//#endregion
|
|
1358
1353
|
//#region src/adapters/branding.ts
|
|
1359
|
-
function
|
|
1354
|
+
function xt(e) {
|
|
1360
1355
|
return e === "dark" || e === "light" || e === "auto";
|
|
1361
1356
|
}
|
|
1362
|
-
function
|
|
1357
|
+
function St(e) {
|
|
1363
1358
|
return {
|
|
1364
1359
|
async get(t) {
|
|
1365
|
-
let n = await e.select().from(
|
|
1360
|
+
let n = await e.select().from(Ke).where(a(Ke.tenant_id, t)).get();
|
|
1366
1361
|
if (!n) return null;
|
|
1367
1362
|
let { tenant_id: r, colors_primary: i, colors_page_background_type: o, colors_page_background_start: s, colors_page_background_end: c, colors_page_background_angle_dev: l, font_url: u, dark_mode: d, ...f } = n;
|
|
1368
|
-
return
|
|
1363
|
+
return D({
|
|
1369
1364
|
...f,
|
|
1370
1365
|
colors: {
|
|
1371
1366
|
primary: i,
|
|
@@ -1377,7 +1372,7 @@ function bt(e) {
|
|
|
1377
1372
|
}
|
|
1378
1373
|
},
|
|
1379
1374
|
font: u ? { url: u } : void 0,
|
|
1380
|
-
dark_mode:
|
|
1375
|
+
dark_mode: xt(d) ? d : void 0
|
|
1381
1376
|
});
|
|
1382
1377
|
},
|
|
1383
1378
|
async set(t, n) {
|
|
@@ -1391,11 +1386,11 @@ function bt(e) {
|
|
|
1391
1386
|
font_url: i?.url,
|
|
1392
1387
|
dark_mode: a
|
|
1393
1388
|
};
|
|
1394
|
-
await e.insert(
|
|
1389
|
+
await e.insert(Ke).values({
|
|
1395
1390
|
tenant_id: t,
|
|
1396
1391
|
...l
|
|
1397
1392
|
}).onConflictDoUpdate({
|
|
1398
|
-
target:
|
|
1393
|
+
target: Ke.tenant_id,
|
|
1399
1394
|
set: l
|
|
1400
1395
|
});
|
|
1401
1396
|
}
|
|
@@ -1403,30 +1398,30 @@ function bt(e) {
|
|
|
1403
1398
|
}
|
|
1404
1399
|
//#endregion
|
|
1405
1400
|
//#region src/helpers/paginate.ts
|
|
1406
|
-
function
|
|
1401
|
+
function Ct(e) {
|
|
1407
1402
|
return e?.from !== void 0 || e?.take !== void 0;
|
|
1408
1403
|
}
|
|
1409
|
-
function
|
|
1404
|
+
function wt(e) {
|
|
1410
1405
|
let t = e?.take, n = typeof t == "number" && Number.isFinite(t) ? Math.floor(t) : NaN;
|
|
1411
1406
|
return n >= 1 ? n : 50;
|
|
1412
1407
|
}
|
|
1413
|
-
function
|
|
1408
|
+
function Tt(e) {
|
|
1414
1409
|
let t = e.sortOrder === "asc" ? n : i;
|
|
1415
1410
|
return [t(e.sortColumn), t(e.idColumn)];
|
|
1416
1411
|
}
|
|
1417
|
-
function
|
|
1418
|
-
let n = e?.from ?
|
|
1412
|
+
function Et(e, t) {
|
|
1413
|
+
let n = e?.from ? he(e.from) : null;
|
|
1419
1414
|
if (!n) return;
|
|
1420
|
-
if (n.k !== t.sortKey) throw new
|
|
1415
|
+
if (n.k !== t.sortKey) throw new Ne(400, { message: "The `from` cursor was issued under a different sort and cannot be used with this request" });
|
|
1421
1416
|
if (n.s === void 0 || n.s === null) return t.sortOrder === "asc" ? s(t.idColumn, n.i) : m(t.idColumn, n.i);
|
|
1422
1417
|
let r = t.sortOrder === "asc" ? y.raw(">") : y.raw("<");
|
|
1423
1418
|
return y`(${t.sortColumn}, ${t.idColumn}) ${r} (${n.s}, ${n.i})`;
|
|
1424
1419
|
}
|
|
1425
|
-
function
|
|
1420
|
+
function Dt(e, t, n, r = "id", i) {
|
|
1426
1421
|
let a = e.length > t, o = a ? e.slice(0, t) : e, s, c = o[o.length - 1];
|
|
1427
1422
|
if (a && c) {
|
|
1428
1423
|
let e = c[n];
|
|
1429
|
-
s =
|
|
1424
|
+
s = ge({
|
|
1430
1425
|
s: typeof e == "string" || typeof e == "number" || e === null ? e : String(e),
|
|
1431
1426
|
i: String(c[r]),
|
|
1432
1427
|
...i !== void 0 && { k: i }
|
|
@@ -1439,7 +1434,7 @@ function Tt(e, t, n, r = "id", i) {
|
|
|
1439
1434
|
}
|
|
1440
1435
|
//#endregion
|
|
1441
1436
|
//#region src/adapters/clients.ts
|
|
1442
|
-
var
|
|
1437
|
+
var Ot = [
|
|
1443
1438
|
"global",
|
|
1444
1439
|
"is_first_party",
|
|
1445
1440
|
"oidc_conformant",
|
|
@@ -1451,7 +1446,7 @@ var Et = [
|
|
|
1451
1446
|
"require_pushed_authorization_requests",
|
|
1452
1447
|
"require_proof_of_possession",
|
|
1453
1448
|
"hide_sign_up_disabled_error"
|
|
1454
|
-
],
|
|
1449
|
+
], kt = [
|
|
1455
1450
|
"callbacks",
|
|
1456
1451
|
"allowed_origins",
|
|
1457
1452
|
"web_origins",
|
|
@@ -1460,7 +1455,7 @@ var Et = [
|
|
|
1460
1455
|
"allowed_logout_urls",
|
|
1461
1456
|
"grant_types",
|
|
1462
1457
|
"signing_keys"
|
|
1463
|
-
],
|
|
1458
|
+
], At = [
|
|
1464
1459
|
"session_transfer",
|
|
1465
1460
|
"oidc_logout",
|
|
1466
1461
|
"jwt_configuration",
|
|
@@ -1476,21 +1471,21 @@ var Et = [
|
|
|
1476
1471
|
"token_quota",
|
|
1477
1472
|
"registration_metadata"
|
|
1478
1473
|
];
|
|
1479
|
-
function
|
|
1474
|
+
function jt(e) {
|
|
1480
1475
|
let { tenant_id: t, connections: n, ...r } = e, i = { ...r };
|
|
1481
|
-
for (let e of
|
|
1482
|
-
for (let e of
|
|
1483
|
-
for (let e of
|
|
1484
|
-
return i.connections = Q(n, []),
|
|
1476
|
+
for (let e of Ot) i[e] = !!r[e];
|
|
1477
|
+
for (let e of kt) i[e] = Q(r[e], []);
|
|
1478
|
+
for (let e of At) i[e] = Q(r[e], {});
|
|
1479
|
+
return i.connections = Q(n, []), D(i);
|
|
1485
1480
|
}
|
|
1486
|
-
function
|
|
1481
|
+
function Mt(e) {
|
|
1487
1482
|
let t = { ...e };
|
|
1488
|
-
|
|
1489
|
-
for (let n of
|
|
1490
|
-
for (let n of
|
|
1491
|
-
return e.connections !== void 0 && (t.connections = JSON.stringify(e.connections || [])),
|
|
1483
|
+
ie(e, Ot, t);
|
|
1484
|
+
for (let n of kt) e[n] !== void 0 && (t[n] = JSON.stringify(e[n] || []));
|
|
1485
|
+
for (let n of At) e[n] !== void 0 && (t[n] = JSON.stringify(e[n] || {}));
|
|
1486
|
+
return e.connections !== void 0 && (t.connections = JSON.stringify(e.connections || [])), ce(t);
|
|
1492
1487
|
}
|
|
1493
|
-
function
|
|
1488
|
+
function Nt(e) {
|
|
1494
1489
|
return {
|
|
1495
1490
|
async create(t, n) {
|
|
1496
1491
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -1514,51 +1509,51 @@ function jt(e) {
|
|
|
1514
1509
|
created_at: r,
|
|
1515
1510
|
updated_at: r
|
|
1516
1511
|
};
|
|
1517
|
-
for (let e of
|
|
1512
|
+
for (let e of Ot) i[e] = n[e] ?? !1;
|
|
1518
1513
|
i.oidc_conformant = n.oidc_conformant ?? !0, i.auth0_conformant = n.auth0_conformant ?? !0, i.sso_disabled = n.sso_disabled ?? !1;
|
|
1519
|
-
for (let e of
|
|
1520
|
-
for (let e of
|
|
1514
|
+
for (let e of kt) i[e] = n[e] || [];
|
|
1515
|
+
for (let e of At) i[e] = n[e] || {};
|
|
1521
1516
|
i.connections = n.connections || [];
|
|
1522
|
-
let a =
|
|
1517
|
+
let a = Mt(i);
|
|
1523
1518
|
try {
|
|
1524
1519
|
await e.insert(L).values({
|
|
1525
1520
|
...a,
|
|
1526
1521
|
tenant_id: t
|
|
1527
1522
|
});
|
|
1528
1523
|
} catch (e) {
|
|
1529
|
-
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new
|
|
1524
|
+
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new Ne(409, { message: "Client already exists" }) : e;
|
|
1530
1525
|
}
|
|
1531
|
-
return
|
|
1526
|
+
return jt({
|
|
1532
1527
|
...a,
|
|
1533
1528
|
tenant_id: t
|
|
1534
1529
|
});
|
|
1535
1530
|
},
|
|
1536
1531
|
async get(n, r) {
|
|
1537
1532
|
let i = await e.select().from(L).where(t(a(L.tenant_id, n), a(L.client_id, r))).get();
|
|
1538
|
-
return i ?
|
|
1533
|
+
return i ? jt(i) : null;
|
|
1539
1534
|
},
|
|
1540
1535
|
async getByClientId(t) {
|
|
1541
1536
|
let n = await e.select().from(L).where(a(L.client_id, t)).get();
|
|
1542
1537
|
return n ? {
|
|
1543
|
-
...
|
|
1538
|
+
...jt(n),
|
|
1544
1539
|
tenant_id: n.tenant_id
|
|
1545
1540
|
} : null;
|
|
1546
1541
|
},
|
|
1547
1542
|
async update(n, r, i) {
|
|
1548
|
-
let o =
|
|
1543
|
+
let o = Mt({
|
|
1549
1544
|
...i,
|
|
1550
1545
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
1551
1546
|
});
|
|
1552
1547
|
return delete o.client_id, delete o.tenant_id, await e.update(L).set(o).where(t(a(L.tenant_id, n), a(L.client_id, r))), !0;
|
|
1553
1548
|
},
|
|
1554
1549
|
async list(o, s) {
|
|
1555
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
1556
|
-
if (
|
|
1550
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? dt(L, f, ["name", "client_id"]) : void 0, m = p ? t(a(L.tenant_id, o), p) : a(L.tenant_id, o);
|
|
1551
|
+
if (Ct(s)) {
|
|
1557
1552
|
let n = {
|
|
1558
1553
|
sortColumn: L.created_at,
|
|
1559
1554
|
idColumn: L.client_id,
|
|
1560
1555
|
sortOrder: "desc"
|
|
1561
|
-
}, r =
|
|
1556
|
+
}, r = Et(s, n), i = wt(s), { rows: a, next: o } = Dt(await e.select().from(L).where(r ? t(m, r) : m).orderBy(...Tt(n)).limit(i + 1), i, "created_at", "client_id"), c = a.map(jt);
|
|
1562
1557
|
return {
|
|
1563
1558
|
clients: c,
|
|
1564
1559
|
totals: {
|
|
@@ -1574,7 +1569,7 @@ function jt(e) {
|
|
|
1574
1569
|
let e = L[d.sort_by];
|
|
1575
1570
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
1576
1571
|
}
|
|
1577
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
1572
|
+
let g = (await h.offset(c * l).limit(l)).map(jt);
|
|
1578
1573
|
if (!u) return { clients: g };
|
|
1579
1574
|
let [_] = await e.select({ count: r() }).from(L).where(m);
|
|
1580
1575
|
return {
|
|
@@ -1594,23 +1589,23 @@ function jt(e) {
|
|
|
1594
1589
|
}
|
|
1595
1590
|
//#endregion
|
|
1596
1591
|
//#region src/adapters/clientConnections.ts
|
|
1597
|
-
function
|
|
1592
|
+
function Pt(e) {
|
|
1598
1593
|
let { tenant_id: t, is_system: n, options: r, metadata: i, ...a } = e;
|
|
1599
|
-
return
|
|
1594
|
+
return D({
|
|
1600
1595
|
...a,
|
|
1601
1596
|
options: Q(r, {}),
|
|
1602
1597
|
metadata: Q(i),
|
|
1603
1598
|
is_system: n ? !0 : void 0
|
|
1604
1599
|
});
|
|
1605
1600
|
}
|
|
1606
|
-
function
|
|
1601
|
+
function Ft(e) {
|
|
1607
1602
|
return {
|
|
1608
1603
|
async listByClient(n, r) {
|
|
1609
1604
|
let i = await e.select({ connections: L.connections }).from(L).where(t(a(L.tenant_id, n), a(L.client_id, r))).get();
|
|
1610
1605
|
if (!i) return [];
|
|
1611
1606
|
let o = Q(i.connections, []) || [];
|
|
1612
1607
|
if (o.length === 0) return [];
|
|
1613
|
-
let s = (await e.select().from(
|
|
1608
|
+
let s = (await e.select().from(Ve).where(t(a(Ve.tenant_id, n), l(Ve.id, o))).all()).map(Pt);
|
|
1614
1609
|
return o.map((e) => s.find((t) => t.id === e)).filter(Boolean);
|
|
1615
1610
|
},
|
|
1616
1611
|
async updateByClient(n, r, i) {
|
|
@@ -1647,9 +1642,9 @@ function Nt(e) {
|
|
|
1647
1642
|
}
|
|
1648
1643
|
//#endregion
|
|
1649
1644
|
//#region src/adapters/clientGrants.ts
|
|
1650
|
-
function
|
|
1645
|
+
function It(e) {
|
|
1651
1646
|
let { tenant_id: t, scope: n, authorization_details_types: r, allow_any_organization: i, is_system: a, ...o } = e;
|
|
1652
|
-
return
|
|
1647
|
+
return D({
|
|
1653
1648
|
...o,
|
|
1654
1649
|
scope: Q(n, []),
|
|
1655
1650
|
authorization_details_types: Q(r, []),
|
|
@@ -1657,7 +1652,7 @@ function Pt(e) {
|
|
|
1657
1652
|
is_system: !!a
|
|
1658
1653
|
});
|
|
1659
1654
|
}
|
|
1660
|
-
function
|
|
1655
|
+
function Lt(e) {
|
|
1661
1656
|
return {
|
|
1662
1657
|
async create(t, n) {
|
|
1663
1658
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -1674,14 +1669,14 @@ function Ft(e) {
|
|
|
1674
1669
|
created_at: r,
|
|
1675
1670
|
updated_at: r
|
|
1676
1671
|
};
|
|
1677
|
-
return await e.insert(z).values(i),
|
|
1672
|
+
return await e.insert(z).values(i), It({
|
|
1678
1673
|
...i,
|
|
1679
1674
|
tenant_id: t
|
|
1680
1675
|
});
|
|
1681
1676
|
},
|
|
1682
1677
|
async get(n, r) {
|
|
1683
1678
|
let i = await e.select().from(z).where(t(a(z.tenant_id, n), a(z.id, r))).get();
|
|
1684
|
-
return i ?
|
|
1679
|
+
return i ? It(i) : null;
|
|
1685
1680
|
},
|
|
1686
1681
|
async update(n, r, i) {
|
|
1687
1682
|
let { scope: o, authorization_details_types: s, allow_any_organization: c, is_system: l, ...u } = i, d = {
|
|
@@ -1691,13 +1686,13 @@ function Ft(e) {
|
|
|
1691
1686
|
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(z).set(d).where(t(a(z.tenant_id, n), a(z.id, r))).returning()).length > 0;
|
|
1692
1687
|
},
|
|
1693
1688
|
async list(o, s) {
|
|
1694
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
1695
|
-
if (
|
|
1689
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? dt(z, f, ["client_id", "audience"]) : void 0, m = p ? t(a(z.tenant_id, o), p) : a(z.tenant_id, o);
|
|
1690
|
+
if (Ct(s)) {
|
|
1696
1691
|
let n = {
|
|
1697
1692
|
sortColumn: z.created_at,
|
|
1698
1693
|
idColumn: z.id,
|
|
1699
1694
|
sortOrder: "desc"
|
|
1700
|
-
}, r =
|
|
1695
|
+
}, r = Et(s, n), i = wt(s), { rows: a, next: o } = Dt(await e.select().from(z).where(r ? t(m, r) : m).orderBy(...Tt(n)).limit(i + 1), i, "created_at"), c = a.map(It);
|
|
1701
1696
|
return {
|
|
1702
1697
|
client_grants: c,
|
|
1703
1698
|
start: 0,
|
|
@@ -1711,7 +1706,7 @@ function Ft(e) {
|
|
|
1711
1706
|
let e = z[d.sort_by];
|
|
1712
1707
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
1713
1708
|
} else h = h.orderBy(n(z.created_at));
|
|
1714
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
1709
|
+
let g = (await h.offset(c * l).limit(l)).map(It);
|
|
1715
1710
|
if (!u) return { client_grants: g };
|
|
1716
1711
|
let [_] = await e.select({ count: r() }).from(z).where(m);
|
|
1717
1712
|
return {
|
|
@@ -1728,36 +1723,36 @@ function Ft(e) {
|
|
|
1728
1723
|
}
|
|
1729
1724
|
//#endregion
|
|
1730
1725
|
//#region src/adapters/clientRegistrationTokens.ts
|
|
1731
|
-
function
|
|
1726
|
+
function Rt(e) {
|
|
1732
1727
|
if (!e) return;
|
|
1733
1728
|
let t = JSON.parse(e);
|
|
1734
|
-
return
|
|
1729
|
+
return ye(t) ? t : void 0;
|
|
1735
1730
|
}
|
|
1736
|
-
function
|
|
1731
|
+
function zt(e) {
|
|
1737
1732
|
return e == null ? void 0 : new Date(e).toISOString();
|
|
1738
1733
|
}
|
|
1739
|
-
function
|
|
1734
|
+
function Bt(e) {
|
|
1740
1735
|
if (!e) return null;
|
|
1741
1736
|
let t = new Date(e);
|
|
1742
1737
|
return isNaN(t.getTime()) ? null : t.getTime();
|
|
1743
1738
|
}
|
|
1744
|
-
function
|
|
1745
|
-
let t =
|
|
1739
|
+
function Vt(e) {
|
|
1740
|
+
let t = me.parse(e.type);
|
|
1746
1741
|
return {
|
|
1747
1742
|
id: e.id,
|
|
1748
1743
|
token_hash: e.token_hash,
|
|
1749
1744
|
type: t,
|
|
1750
1745
|
client_id: e.client_id ?? void 0,
|
|
1751
1746
|
sub: e.sub ?? void 0,
|
|
1752
|
-
constraints:
|
|
1747
|
+
constraints: Rt(e.constraints),
|
|
1753
1748
|
single_use: !!e.single_use,
|
|
1754
|
-
expires_at:
|
|
1755
|
-
used_at:
|
|
1756
|
-
revoked_at:
|
|
1749
|
+
expires_at: zt(e.expires_at_ts),
|
|
1750
|
+
used_at: zt(e.used_at_ts),
|
|
1751
|
+
revoked_at: zt(e.revoked_at_ts),
|
|
1757
1752
|
created_at: new Date(e.created_at_ts).toISOString()
|
|
1758
1753
|
};
|
|
1759
1754
|
}
|
|
1760
|
-
function
|
|
1755
|
+
function Ht(e) {
|
|
1761
1756
|
return {
|
|
1762
1757
|
async create(t, n) {
|
|
1763
1758
|
let r = Date.now();
|
|
@@ -1770,7 +1765,7 @@ function Bt(e) {
|
|
|
1770
1765
|
sub: n.sub ?? null,
|
|
1771
1766
|
constraints: n.constraints ? JSON.stringify(n.constraints) : null,
|
|
1772
1767
|
single_use: +!!n.single_use,
|
|
1773
|
-
expires_at_ts:
|
|
1768
|
+
expires_at_ts: Bt(n.expires_at),
|
|
1774
1769
|
created_at_ts: r
|
|
1775
1770
|
}), {
|
|
1776
1771
|
id: n.id,
|
|
@@ -1786,23 +1781,23 @@ function Bt(e) {
|
|
|
1786
1781
|
},
|
|
1787
1782
|
async get(n, r) {
|
|
1788
1783
|
let i = await e.select().from(R).where(t(a(R.tenant_id, n), a(R.id, r))).get();
|
|
1789
|
-
return i ?
|
|
1784
|
+
return i ? Vt(i) : null;
|
|
1790
1785
|
},
|
|
1791
1786
|
async getByHash(n, r) {
|
|
1792
1787
|
let i = await e.select().from(R).where(t(a(R.tenant_id, n), a(R.token_hash, r))).get();
|
|
1793
|
-
return i ?
|
|
1788
|
+
return i ? Vt(i) : null;
|
|
1794
1789
|
},
|
|
1795
1790
|
async listByClient(n, r) {
|
|
1796
|
-
return (await e.select().from(R).where(t(a(R.tenant_id, n), a(R.client_id, r))).orderBy(i(R.created_at_ts))).map(
|
|
1791
|
+
return (await e.select().from(R).where(t(a(R.tenant_id, n), a(R.client_id, r))).orderBy(i(R.created_at_ts))).map(Vt);
|
|
1797
1792
|
},
|
|
1798
1793
|
async markUsed(n, r, i) {
|
|
1799
|
-
return (await e.update(R).set({ used_at_ts:
|
|
1794
|
+
return (await e.update(R).set({ used_at_ts: Bt(i) }).where(t(a(R.tenant_id, n), a(R.id, r), f(R.used_at_ts))).returning()).length > 0;
|
|
1800
1795
|
},
|
|
1801
1796
|
async revoke(n, r, i) {
|
|
1802
|
-
return (await e.update(R).set({ revoked_at_ts:
|
|
1797
|
+
return (await e.update(R).set({ revoked_at_ts: Bt(i) }).where(t(a(R.tenant_id, n), a(R.id, r), f(R.revoked_at_ts))).returning()).length > 0;
|
|
1803
1798
|
},
|
|
1804
1799
|
async revokeByClient(n, r, i) {
|
|
1805
|
-
return (await e.update(R).set({ revoked_at_ts:
|
|
1800
|
+
return (await e.update(R).set({ revoked_at_ts: Bt(i) }).where(t(a(R.tenant_id, n), a(R.client_id, r), f(R.revoked_at_ts))).returning()).length;
|
|
1806
1801
|
},
|
|
1807
1802
|
async remove(n, r) {
|
|
1808
1803
|
return (await e.delete(R).where(t(a(R.tenant_id, n), a(R.id, r))).returning()).length > 0;
|
|
@@ -1811,12 +1806,12 @@ function Bt(e) {
|
|
|
1811
1806
|
}
|
|
1812
1807
|
//#endregion
|
|
1813
1808
|
//#region src/adapters/codes.ts
|
|
1814
|
-
var
|
|
1815
|
-
function
|
|
1809
|
+
var Ut = ["code_id", "login_id"], Wt = 500;
|
|
1810
|
+
function Gt(e) {
|
|
1816
1811
|
let { tenant_id: t, ...n } = e;
|
|
1817
|
-
return
|
|
1812
|
+
return D(n);
|
|
1818
1813
|
}
|
|
1819
|
-
function
|
|
1814
|
+
function Kt(e) {
|
|
1820
1815
|
return {
|
|
1821
1816
|
async create(t, n) {
|
|
1822
1817
|
let r = {
|
|
@@ -1825,18 +1820,18 @@ function Wt(e) {
|
|
|
1825
1820
|
created_at: n.created_at || (/* @__PURE__ */ new Date()).toISOString(),
|
|
1826
1821
|
expires_at: n.expires_at
|
|
1827
1822
|
};
|
|
1828
|
-
return await e.insert(I).values(r),
|
|
1823
|
+
return await e.insert(I).values(r), Gt(r);
|
|
1829
1824
|
},
|
|
1830
1825
|
async get(n, r, i) {
|
|
1831
1826
|
let o = n ? t(a(I.tenant_id, n), a(I.code_id, r), a(I.code_type, i)) : t(a(I.code_id, r), a(I.code_type, i)), s = await e.select().from(I).where(o).get();
|
|
1832
|
-
return s ?
|
|
1827
|
+
return s ? Gt(s) : null;
|
|
1833
1828
|
},
|
|
1834
1829
|
async list(o, s) {
|
|
1835
1830
|
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(I.tenant_id, o)];
|
|
1836
1831
|
if (f) {
|
|
1837
|
-
let e =
|
|
1832
|
+
let e = we(f, Ut);
|
|
1838
1833
|
if (e) {
|
|
1839
|
-
let t =
|
|
1834
|
+
let t = dt(I, e, Ut);
|
|
1840
1835
|
t && p.push(t);
|
|
1841
1836
|
}
|
|
1842
1837
|
}
|
|
@@ -1845,7 +1840,7 @@ function Wt(e) {
|
|
|
1845
1840
|
let e = I[d.sort_by];
|
|
1846
1841
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
1847
1842
|
}
|
|
1848
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
1843
|
+
let g = (await h.offset(c * l).limit(l)).map(Gt);
|
|
1849
1844
|
if (!u) return { codes: g };
|
|
1850
1845
|
let [_] = await e.select({ count: r() }).from(I).where(m);
|
|
1851
1846
|
return {
|
|
@@ -1867,8 +1862,8 @@ function Wt(e) {
|
|
|
1867
1862
|
async cleanup(t) {
|
|
1868
1863
|
let n = 0;
|
|
1869
1864
|
for (;;) {
|
|
1870
|
-
let r = await e.delete(I).where(y`rowid IN (SELECT rowid FROM ${I} WHERE ${I.expires_at} < ${t} LIMIT ${
|
|
1871
|
-
if (n += r.length, r.length <
|
|
1865
|
+
let r = await e.delete(I).where(y`rowid IN (SELECT rowid FROM ${I} WHERE ${I.expires_at} < ${t} LIMIT ${Wt})`).returning({ code_id: I.code_id });
|
|
1866
|
+
if (n += r.length, r.length < Wt) break;
|
|
1872
1867
|
}
|
|
1873
1868
|
return n;
|
|
1874
1869
|
}
|
|
@@ -1876,23 +1871,23 @@ function Wt(e) {
|
|
|
1876
1871
|
}
|
|
1877
1872
|
//#endregion
|
|
1878
1873
|
//#region src/adapters/connections.ts
|
|
1879
|
-
function
|
|
1874
|
+
function qt() {
|
|
1880
1875
|
return `con_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
1881
1876
|
}
|
|
1882
|
-
function
|
|
1877
|
+
function Jt(e) {
|
|
1883
1878
|
let { tenant_id: t, is_system: n, options: r, metadata: i, ...a } = e;
|
|
1884
|
-
return
|
|
1879
|
+
return D({
|
|
1885
1880
|
...a,
|
|
1886
1881
|
options: Q(r, {}),
|
|
1887
1882
|
metadata: Q(i),
|
|
1888
1883
|
is_system: n ? !0 : void 0
|
|
1889
1884
|
});
|
|
1890
1885
|
}
|
|
1891
|
-
function
|
|
1886
|
+
function Yt(e) {
|
|
1892
1887
|
return {
|
|
1893
1888
|
async create(t, n) {
|
|
1894
1889
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
1895
|
-
id: n.id ||
|
|
1890
|
+
id: n.id || qt(),
|
|
1896
1891
|
...n,
|
|
1897
1892
|
tenant_id: t,
|
|
1898
1893
|
options: JSON.stringify(n.options || {}),
|
|
@@ -1902,34 +1897,34 @@ function qt(e) {
|
|
|
1902
1897
|
updated_at: r
|
|
1903
1898
|
};
|
|
1904
1899
|
try {
|
|
1905
|
-
await e.insert(
|
|
1900
|
+
await e.insert(Ve).values(i);
|
|
1906
1901
|
} catch (e) {
|
|
1907
|
-
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new
|
|
1902
|
+
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new Ne(409, { message: "Connection already exists" }) : e;
|
|
1908
1903
|
}
|
|
1909
|
-
return
|
|
1904
|
+
return Jt(i);
|
|
1910
1905
|
},
|
|
1911
1906
|
async get(n, r) {
|
|
1912
|
-
let i = await e.select().from(
|
|
1913
|
-
return i ?
|
|
1907
|
+
let i = await e.select().from(Ve).where(t(a(Ve.tenant_id, n), a(Ve.id, r))).get();
|
|
1908
|
+
return i ? Jt(i) : null;
|
|
1914
1909
|
},
|
|
1915
1910
|
async update(n, r, i) {
|
|
1916
1911
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
1917
|
-
return i.name !== void 0 && (o.name = i.name), i.strategy !== void 0 && (o.strategy = i.strategy), i.options !== void 0 && (o.options = JSON.stringify(i.options)), i.metadata !== void 0 && (o.metadata = JSON.stringify(i.metadata)), i.display_name !== void 0 && (o.display_name = i.display_name), i.response_type !== void 0 && (o.response_type = i.response_type), i.response_mode !== void 0 && (o.response_mode = i.response_mode), await e.update(
|
|
1912
|
+
return i.name !== void 0 && (o.name = i.name), i.strategy !== void 0 && (o.strategy = i.strategy), i.options !== void 0 && (o.options = JSON.stringify(i.options)), i.metadata !== void 0 && (o.metadata = JSON.stringify(i.metadata)), i.display_name !== void 0 && (o.display_name = i.display_name), i.response_type !== void 0 && (o.response_type = i.response_type), i.response_mode !== void 0 && (o.response_mode = i.response_mode), await e.update(Ve).set(o).where(t(a(Ve.tenant_id, n), a(Ve.id, r))), !0;
|
|
1918
1913
|
},
|
|
1919
1914
|
async list(o, s) {
|
|
1920
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = a(
|
|
1915
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = a(Ve.tenant_id, o);
|
|
1921
1916
|
if (f) {
|
|
1922
|
-
let e =
|
|
1917
|
+
let e = dt(Ve, f, ["name"]);
|
|
1923
1918
|
e && (p = t(p, e));
|
|
1924
1919
|
}
|
|
1925
|
-
let m = e.select().from(
|
|
1920
|
+
let m = e.select().from(Ve).where(p).$dynamic();
|
|
1926
1921
|
if (d?.sort_by) {
|
|
1927
|
-
let e =
|
|
1922
|
+
let e = Ve[d.sort_by];
|
|
1928
1923
|
e && (m = m.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
1929
1924
|
}
|
|
1930
|
-
let h = (await m.offset(c * l).limit(l)).map(
|
|
1925
|
+
let h = (await m.offset(c * l).limit(l)).map(Jt);
|
|
1931
1926
|
if (!u) return { connections: h };
|
|
1932
|
-
let [g] = await e.select({ count: r() }).from(
|
|
1927
|
+
let [g] = await e.select({ count: r() }).from(Ve).where(p);
|
|
1933
1928
|
return {
|
|
1934
1929
|
connections: h,
|
|
1935
1930
|
start: c * l,
|
|
@@ -1938,21 +1933,21 @@ function qt(e) {
|
|
|
1938
1933
|
};
|
|
1939
1934
|
},
|
|
1940
1935
|
async remove(n, r) {
|
|
1941
|
-
return (await e.delete(
|
|
1936
|
+
return (await e.delete(Ve).where(t(a(Ve.tenant_id, n), a(Ve.id, r))).returning()).length > 0;
|
|
1942
1937
|
}
|
|
1943
1938
|
};
|
|
1944
1939
|
}
|
|
1945
1940
|
//#endregion
|
|
1946
1941
|
//#region src/adapters/customDomains.ts
|
|
1947
|
-
function
|
|
1942
|
+
function Xt(e) {
|
|
1948
1943
|
let { tenant_id: t, domain_metadata: n, ...r } = e;
|
|
1949
|
-
return
|
|
1944
|
+
return D({
|
|
1950
1945
|
...r,
|
|
1951
1946
|
primary: !!r.primary,
|
|
1952
1947
|
domain_metadata: Q(n)
|
|
1953
1948
|
});
|
|
1954
1949
|
}
|
|
1955
|
-
function
|
|
1950
|
+
function Zt(e) {
|
|
1956
1951
|
return {
|
|
1957
1952
|
async create(t, n) {
|
|
1958
1953
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -1970,40 +1965,40 @@ function Yt(e) {
|
|
|
1970
1965
|
created_at: r,
|
|
1971
1966
|
updated_at: r
|
|
1972
1967
|
};
|
|
1973
|
-
return await e.insert(
|
|
1968
|
+
return await e.insert(V).values(i), Xt({
|
|
1974
1969
|
...i,
|
|
1975
1970
|
tenant_id: t
|
|
1976
1971
|
});
|
|
1977
1972
|
},
|
|
1978
1973
|
async get(n, r) {
|
|
1979
|
-
let i = await e.select().from(
|
|
1980
|
-
return i ?
|
|
1974
|
+
let i = await e.select().from(V).where(t(a(V.tenant_id, n), a(V.custom_domain_id, r))).get();
|
|
1975
|
+
return i ? Xt(i) : null;
|
|
1981
1976
|
},
|
|
1982
1977
|
async getByDomain(t) {
|
|
1983
|
-
let n = await e.select().from(
|
|
1978
|
+
let n = await e.select().from(V).where(a(V.domain, t)).get();
|
|
1984
1979
|
return n ? {
|
|
1985
|
-
...
|
|
1980
|
+
...Xt(n),
|
|
1986
1981
|
tenant_id: n.tenant_id
|
|
1987
1982
|
} : null;
|
|
1988
1983
|
},
|
|
1989
1984
|
async list(t) {
|
|
1990
|
-
return (await e.select().from(
|
|
1985
|
+
return (await e.select().from(V).where(a(V.tenant_id, t)).all()).map(Xt);
|
|
1991
1986
|
},
|
|
1992
1987
|
async update(n, r, i) {
|
|
1993
1988
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
1994
|
-
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 = 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(
|
|
1989
|
+
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 = 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(V).set(o).where(t(a(V.tenant_id, n), a(V.custom_domain_id, r))).returning()).length > 0;
|
|
1995
1990
|
},
|
|
1996
1991
|
async remove(n, r) {
|
|
1997
|
-
return (await e.delete(
|
|
1992
|
+
return (await e.delete(V).where(t(a(V.tenant_id, n), a(V.custom_domain_id, r))).returning()).length > 0;
|
|
1998
1993
|
}
|
|
1999
1994
|
};
|
|
2000
1995
|
}
|
|
2001
1996
|
//#endregion
|
|
2002
1997
|
//#region src/adapters/customText.ts
|
|
2003
|
-
function
|
|
1998
|
+
function Qt(e) {
|
|
2004
1999
|
return {
|
|
2005
2000
|
async get(n, r, i) {
|
|
2006
|
-
let o = await e.select().from(
|
|
2001
|
+
let o = await e.select().from(rt).where(t(a(rt.tenant_id, n), a(rt.prompt, r), a(rt.language, i))).get();
|
|
2007
2002
|
if (!o) return null;
|
|
2008
2003
|
try {
|
|
2009
2004
|
return JSON.parse(o.custom_text);
|
|
@@ -2013,7 +2008,7 @@ function Xt(e) {
|
|
|
2013
2008
|
},
|
|
2014
2009
|
async set(t, n, r, i) {
|
|
2015
2010
|
let a = Date.now(), o = JSON.stringify(i);
|
|
2016
|
-
await e.insert(
|
|
2011
|
+
await e.insert(rt).values({
|
|
2017
2012
|
tenant_id: t,
|
|
2018
2013
|
prompt: n,
|
|
2019
2014
|
language: r,
|
|
@@ -2022,9 +2017,9 @@ function Xt(e) {
|
|
|
2022
2017
|
updated_at_ts: a
|
|
2023
2018
|
}).onConflictDoUpdate({
|
|
2024
2019
|
target: [
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2020
|
+
rt.tenant_id,
|
|
2021
|
+
rt.prompt,
|
|
2022
|
+
rt.language
|
|
2028
2023
|
],
|
|
2029
2024
|
set: {
|
|
2030
2025
|
custom_text: o,
|
|
@@ -2033,23 +2028,23 @@ function Xt(e) {
|
|
|
2033
2028
|
});
|
|
2034
2029
|
},
|
|
2035
2030
|
async delete(n, r, i) {
|
|
2036
|
-
await e.delete(
|
|
2031
|
+
await e.delete(rt).where(t(a(rt.tenant_id, n), a(rt.prompt, r), a(rt.language, i)));
|
|
2037
2032
|
},
|
|
2038
2033
|
async list(t) {
|
|
2039
2034
|
return await e.select({
|
|
2040
|
-
prompt:
|
|
2041
|
-
language:
|
|
2042
|
-
}).from(
|
|
2035
|
+
prompt: rt.prompt,
|
|
2036
|
+
language: rt.language
|
|
2037
|
+
}).from(rt).where(a(rt.tenant_id, t)).all();
|
|
2043
2038
|
}
|
|
2044
2039
|
};
|
|
2045
2040
|
}
|
|
2046
2041
|
//#endregion
|
|
2047
2042
|
//#region src/adapters/emailProviders.ts
|
|
2048
|
-
function
|
|
2043
|
+
function $t(e) {
|
|
2049
2044
|
return {
|
|
2050
2045
|
async create(t, n) {
|
|
2051
2046
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
2052
|
-
await e.insert(
|
|
2047
|
+
await e.insert(Qe).values({
|
|
2053
2048
|
tenant_id: t,
|
|
2054
2049
|
name: n.name,
|
|
2055
2050
|
enabled: n.enabled,
|
|
@@ -2061,10 +2056,10 @@ function Zt(e) {
|
|
|
2061
2056
|
});
|
|
2062
2057
|
},
|
|
2063
2058
|
async get(t) {
|
|
2064
|
-
let n = await e.select().from(
|
|
2059
|
+
let n = await e.select().from(Qe).where(a(Qe.tenant_id, t)).get();
|
|
2065
2060
|
if (!n) return null;
|
|
2066
2061
|
let { tenant_id: r, ...i } = n;
|
|
2067
|
-
return
|
|
2062
|
+
return D({
|
|
2068
2063
|
...i,
|
|
2069
2064
|
enabled: !!i.enabled,
|
|
2070
2065
|
credentials: Q(i.credentials, {}),
|
|
@@ -2073,17 +2068,17 @@ function Zt(e) {
|
|
|
2073
2068
|
},
|
|
2074
2069
|
async update(t, n) {
|
|
2075
2070
|
let r = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2076
|
-
n.name !== void 0 && (r.name = n.name), n.enabled !== void 0 && (r.enabled = n.enabled), n.default_from_address !== void 0 && (r.default_from_address = n.default_from_address), n.credentials !== void 0 && (r.credentials = JSON.stringify(n.credentials)), n.settings !== void 0 && (r.settings = JSON.stringify(n.settings)), await e.update(
|
|
2071
|
+
n.name !== void 0 && (r.name = n.name), n.enabled !== void 0 && (r.enabled = n.enabled), n.default_from_address !== void 0 && (r.default_from_address = n.default_from_address), n.credentials !== void 0 && (r.credentials = JSON.stringify(n.credentials)), n.settings !== void 0 && (r.settings = JSON.stringify(n.settings)), await e.update(Qe).set(r).where(a(Qe.tenant_id, t));
|
|
2077
2072
|
},
|
|
2078
2073
|
async remove(t) {
|
|
2079
|
-
await e.delete(
|
|
2074
|
+
await e.delete(Qe).where(a(Qe.tenant_id, t));
|
|
2080
2075
|
}
|
|
2081
2076
|
};
|
|
2082
2077
|
}
|
|
2083
2078
|
//#endregion
|
|
2084
2079
|
//#region src/adapters/emailTemplates.ts
|
|
2085
|
-
function
|
|
2086
|
-
return
|
|
2080
|
+
function en(e) {
|
|
2081
|
+
return D({
|
|
2087
2082
|
template: e.template,
|
|
2088
2083
|
body: e.body,
|
|
2089
2084
|
from: e.from,
|
|
@@ -2095,18 +2090,18 @@ function Qt(e) {
|
|
|
2095
2090
|
urlLifetimeInSeconds: e.url_lifetime_in_seconds ?? void 0
|
|
2096
2091
|
});
|
|
2097
2092
|
}
|
|
2098
|
-
function
|
|
2093
|
+
function tn(e) {
|
|
2099
2094
|
return {
|
|
2100
2095
|
async get(n, r) {
|
|
2101
|
-
let i = await e.select().from(
|
|
2102
|
-
return i ?
|
|
2096
|
+
let i = await e.select().from($e).where(t(a($e.tenant_id, n), a($e.template, r))).get();
|
|
2097
|
+
return i ? en(i) : null;
|
|
2103
2098
|
},
|
|
2104
2099
|
async list(t) {
|
|
2105
|
-
return (await e.select().from(
|
|
2100
|
+
return (await e.select().from($e).where(a($e.tenant_id, t)).all()).map(en);
|
|
2106
2101
|
},
|
|
2107
2102
|
async create(t, n) {
|
|
2108
2103
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
2109
|
-
return await e.insert(
|
|
2104
|
+
return await e.insert($e).values({
|
|
2110
2105
|
tenant_id: t,
|
|
2111
2106
|
template: n.template,
|
|
2112
2107
|
body: n.body,
|
|
@@ -2124,23 +2119,23 @@ function $t(e) {
|
|
|
2124
2119
|
async update(n, r, i) {
|
|
2125
2120
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2126
2121
|
i.body !== void 0 && (o.body = i.body), i.from !== void 0 && (o.from = i.from), i.subject !== void 0 && (o.subject = i.subject), i.syntax !== void 0 && (o.syntax = i.syntax), i.resultUrl !== void 0 && (o.result_url = i.resultUrl), i.urlLifetimeInSeconds !== void 0 && (o.url_lifetime_in_seconds = i.urlLifetimeInSeconds), i.includeEmailInRedirect !== void 0 && (o.include_email_in_redirect = i.includeEmailInRedirect), i.enabled !== void 0 && (o.enabled = i.enabled);
|
|
2127
|
-
let s = await e.update(
|
|
2122
|
+
let s = await e.update($e).set(o).where(t(a($e.tenant_id, n), a($e.template, r))).run();
|
|
2128
2123
|
return Number(s.changes ?? 0) > 0;
|
|
2129
2124
|
},
|
|
2130
2125
|
async remove(n, r) {
|
|
2131
|
-
let i = await e.delete(
|
|
2126
|
+
let i = await e.delete($e).where(t(a($e.tenant_id, n), a($e.template, r))).run();
|
|
2132
2127
|
return Number(i.changes ?? 0) > 0;
|
|
2133
2128
|
}
|
|
2134
2129
|
};
|
|
2135
2130
|
}
|
|
2136
2131
|
//#endregion
|
|
2137
2132
|
//#region src/adapters/flows.ts
|
|
2138
|
-
var
|
|
2139
|
-
function
|
|
2133
|
+
var nn = ["id", "name"];
|
|
2134
|
+
function rn(e) {
|
|
2140
2135
|
return {
|
|
2141
2136
|
async create(t, n) {
|
|
2142
2137
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = `af_${b()}`;
|
|
2143
|
-
return await e.insert(
|
|
2138
|
+
return await e.insert(Xe).values({
|
|
2144
2139
|
id: i,
|
|
2145
2140
|
tenant_id: t,
|
|
2146
2141
|
name: n.name,
|
|
@@ -2156,41 +2151,41 @@ function tn(e) {
|
|
|
2156
2151
|
};
|
|
2157
2152
|
},
|
|
2158
2153
|
async get(n, r) {
|
|
2159
|
-
let i = await e.select().from(
|
|
2154
|
+
let i = await e.select().from(Xe).where(t(a(Xe.tenant_id, n), a(Xe.id, r))).get();
|
|
2160
2155
|
if (!i) return null;
|
|
2161
2156
|
let { tenant_id: o, actions: s, ...c } = i;
|
|
2162
|
-
return
|
|
2157
|
+
return D({
|
|
2163
2158
|
...c,
|
|
2164
2159
|
actions: Q(s, [])
|
|
2165
2160
|
});
|
|
2166
2161
|
},
|
|
2167
2162
|
async update(n, r, i) {
|
|
2168
2163
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2169
|
-
return i.name !== void 0 && (o.name = i.name), i.actions !== void 0 && (o.actions = JSON.stringify(i.actions)), (await e.update(
|
|
2164
|
+
return i.name !== void 0 && (o.name = i.name), i.actions !== void 0 && (o.actions = JSON.stringify(i.actions)), (await e.update(Xe).set(o).where(t(a(Xe.tenant_id, n), a(Xe.id, r))).returning()).length === 0 ? null : this.get(n, r);
|
|
2170
2165
|
},
|
|
2171
2166
|
async list(o, s) {
|
|
2172
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(
|
|
2167
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(Xe.tenant_id, o)];
|
|
2173
2168
|
if (f) {
|
|
2174
|
-
let e =
|
|
2169
|
+
let e = we(f, nn);
|
|
2175
2170
|
if (e) {
|
|
2176
|
-
let t =
|
|
2171
|
+
let t = dt(Xe, e, []);
|
|
2177
2172
|
t && p.push(t);
|
|
2178
2173
|
}
|
|
2179
2174
|
}
|
|
2180
|
-
let m = t(...p), h = e.select().from(
|
|
2175
|
+
let m = t(...p), h = e.select().from(Xe).where(m).$dynamic();
|
|
2181
2176
|
if (d?.sort_by) {
|
|
2182
|
-
let e =
|
|
2177
|
+
let e = Xe[d.sort_by];
|
|
2183
2178
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
2184
2179
|
}
|
|
2185
2180
|
let g = (await h.offset(c * l).limit(l)).map((e) => {
|
|
2186
2181
|
let { tenant_id: t, actions: n, ...r } = e;
|
|
2187
|
-
return
|
|
2182
|
+
return D({
|
|
2188
2183
|
...r,
|
|
2189
2184
|
actions: Q(n, [])
|
|
2190
2185
|
});
|
|
2191
2186
|
});
|
|
2192
2187
|
if (!u) return { flows: g };
|
|
2193
|
-
let [_] = await e.select({ count: r() }).from(
|
|
2188
|
+
let [_] = await e.select({ count: r() }).from(Xe).where(m);
|
|
2194
2189
|
return {
|
|
2195
2190
|
flows: g,
|
|
2196
2191
|
start: c * l,
|
|
@@ -2199,18 +2194,18 @@ function tn(e) {
|
|
|
2199
2194
|
};
|
|
2200
2195
|
},
|
|
2201
2196
|
async remove(n, r) {
|
|
2202
|
-
return (await e.delete(
|
|
2197
|
+
return (await e.delete(Xe).where(t(a(Xe.tenant_id, n), a(Xe.id, r))).returning()).length > 0;
|
|
2203
2198
|
}
|
|
2204
2199
|
};
|
|
2205
2200
|
}
|
|
2206
2201
|
//#endregion
|
|
2207
2202
|
//#region src/adapters/forms.ts
|
|
2208
|
-
var
|
|
2203
|
+
var an = [
|
|
2209
2204
|
"nodes",
|
|
2210
2205
|
"start",
|
|
2211
2206
|
"ending"
|
|
2212
|
-
],
|
|
2213
|
-
function
|
|
2207
|
+
], on = ["name"];
|
|
2208
|
+
function sn(e) {
|
|
2214
2209
|
return {
|
|
2215
2210
|
async create(t, n) {
|
|
2216
2211
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = b(), a = {
|
|
@@ -2224,8 +2219,8 @@ function an(e) {
|
|
|
2224
2219
|
created_at: r,
|
|
2225
2220
|
updated_at: r
|
|
2226
2221
|
};
|
|
2227
|
-
for (let e of
|
|
2228
|
-
return await e.insert(
|
|
2222
|
+
for (let e of an) a[e] = JSON.stringify(n[e] || (e === "nodes" ? [] : {}));
|
|
2223
|
+
return await e.insert(Ye).values(a), {
|
|
2229
2224
|
id: i,
|
|
2230
2225
|
...n,
|
|
2231
2226
|
created_at: r,
|
|
@@ -2233,38 +2228,38 @@ function an(e) {
|
|
|
2233
2228
|
};
|
|
2234
2229
|
},
|
|
2235
2230
|
async get(n, r) {
|
|
2236
|
-
let i = await e.select().from(
|
|
2231
|
+
let i = await e.select().from(Ye).where(t(a(Ye.tenant_id, n), a(Ye.id, r))).get();
|
|
2237
2232
|
if (!i) return null;
|
|
2238
2233
|
let { tenant_id: o, ...s } = i, c = { ...s };
|
|
2239
|
-
for (let e of
|
|
2240
|
-
return
|
|
2234
|
+
for (let e of an) c[e] = Q(s[e]);
|
|
2235
|
+
return D(c);
|
|
2241
2236
|
},
|
|
2242
2237
|
async update(n, r, i) {
|
|
2243
2238
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2244
|
-
for (let [e, t] of Object.entries(i)) t !== void 0 && (
|
|
2245
|
-
return (await e.update(
|
|
2239
|
+
for (let [e, t] of Object.entries(i)) t !== void 0 && (an.includes(e) ? o[e] = JSON.stringify(t) : o[e] = t);
|
|
2240
|
+
return (await e.update(Ye).set(o).where(t(a(Ye.tenant_id, n), a(Ye.id, r))).returning()).length > 0;
|
|
2246
2241
|
},
|
|
2247
2242
|
async list(o, s) {
|
|
2248
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(
|
|
2243
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(Ye.tenant_id, o)];
|
|
2249
2244
|
if (f) {
|
|
2250
|
-
let e =
|
|
2245
|
+
let e = we(f, on);
|
|
2251
2246
|
if (e) {
|
|
2252
|
-
let t =
|
|
2247
|
+
let t = dt(Ye, e, on);
|
|
2253
2248
|
t && p.push(t);
|
|
2254
2249
|
}
|
|
2255
2250
|
}
|
|
2256
|
-
let m = t(...p), h = e.select().from(
|
|
2251
|
+
let m = t(...p), h = e.select().from(Ye).where(m).$dynamic();
|
|
2257
2252
|
if (d?.sort_by) {
|
|
2258
|
-
let e =
|
|
2253
|
+
let e = Ye[d.sort_by];
|
|
2259
2254
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
2260
2255
|
}
|
|
2261
2256
|
let g = (await h.offset(c * l).limit(l)).map((e) => {
|
|
2262
2257
|
let { tenant_id: t, ...n } = e, r = { ...n };
|
|
2263
|
-
for (let e of
|
|
2264
|
-
return
|
|
2258
|
+
for (let e of an) r[e] = Q(n[e]);
|
|
2259
|
+
return D(r);
|
|
2265
2260
|
});
|
|
2266
2261
|
if (!u) return { forms: g };
|
|
2267
|
-
let [_] = await e.select({ count: r() }).from(
|
|
2262
|
+
let [_] = await e.select({ count: r() }).from(Ye).where(m);
|
|
2268
2263
|
return {
|
|
2269
2264
|
forms: g,
|
|
2270
2265
|
start: c * l,
|
|
@@ -2273,13 +2268,13 @@ function an(e) {
|
|
|
2273
2268
|
};
|
|
2274
2269
|
},
|
|
2275
2270
|
async remove(n, r) {
|
|
2276
|
-
return (await e.delete(
|
|
2271
|
+
return (await e.delete(Ye).where(t(a(Ye.tenant_id, n), a(Ye.id, r))).returning()).length > 0;
|
|
2277
2272
|
}
|
|
2278
2273
|
};
|
|
2279
2274
|
}
|
|
2280
2275
|
//#endregion
|
|
2281
2276
|
//#region src/adapters/grants.ts
|
|
2282
|
-
function
|
|
2277
|
+
function cn(e) {
|
|
2283
2278
|
return {
|
|
2284
2279
|
id: e.id,
|
|
2285
2280
|
user_id: e.user_id,
|
|
@@ -2288,17 +2283,17 @@ function on(e) {
|
|
|
2288
2283
|
scope: Q(e.scope, []) ?? []
|
|
2289
2284
|
};
|
|
2290
2285
|
}
|
|
2291
|
-
var
|
|
2286
|
+
var ln = {
|
|
2292
2287
|
user_id: B.user_id,
|
|
2293
2288
|
client_id: B.client_id,
|
|
2294
2289
|
audience: B.audience,
|
|
2295
2290
|
created_at: B.created_at,
|
|
2296
2291
|
updated_at: B.updated_at
|
|
2297
2292
|
};
|
|
2298
|
-
function
|
|
2299
|
-
return Object.hasOwn(
|
|
2293
|
+
function un(e) {
|
|
2294
|
+
return Object.hasOwn(ln, e) ? ln[e] : void 0;
|
|
2300
2295
|
}
|
|
2301
|
-
function
|
|
2296
|
+
function dn(e) {
|
|
2302
2297
|
return {
|
|
2303
2298
|
async create(n, r) {
|
|
2304
2299
|
let i = (/* @__PURE__ */ new Date()).toISOString(), o = r.scope ?? [], s = r.audience ?? "", c = await e.select().from(B).where(t(a(B.tenant_id, n), a(B.user_id, r.user_id), a(B.client_id, r.clientID), a(B.audience, s))).get();
|
|
@@ -2307,7 +2302,7 @@ function ln(e) {
|
|
|
2307
2302
|
return await e.update(B).set({
|
|
2308
2303
|
scope: JSON.stringify(s),
|
|
2309
2304
|
updated_at: i
|
|
2310
|
-
}).where(t(a(B.tenant_id, n), a(B.id, c.id))),
|
|
2305
|
+
}).where(t(a(B.tenant_id, n), a(B.id, c.id))), cn({
|
|
2311
2306
|
...c,
|
|
2312
2307
|
scope: JSON.stringify(s)
|
|
2313
2308
|
});
|
|
@@ -2332,16 +2327,16 @@ function ln(e) {
|
|
|
2332
2327
|
},
|
|
2333
2328
|
async get(n, r, i, o) {
|
|
2334
2329
|
let s = await e.select().from(B).where(t(a(B.tenant_id, n), a(B.user_id, r), a(B.client_id, i), a(B.audience, o ?? ""))).get();
|
|
2335
|
-
return s ?
|
|
2330
|
+
return s ? cn(s) : null;
|
|
2336
2331
|
},
|
|
2337
2332
|
async list(o, s) {
|
|
2338
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
2333
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? dt(B, f, [
|
|
2339
2334
|
"user_id",
|
|
2340
2335
|
"client_id",
|
|
2341
2336
|
"audience"
|
|
2342
|
-
]) : void 0, m = p ? t(a(B.tenant_id, o), p) : a(B.tenant_id, o), h = e.select().from(B).where(m).$dynamic(), g = d?.sort_by ?
|
|
2337
|
+
]) : void 0, m = p ? t(a(B.tenant_id, o), p) : a(B.tenant_id, o), h = e.select().from(B).where(m).$dynamic(), g = d?.sort_by ? un(d.sort_by) : void 0;
|
|
2343
2338
|
h = g ? h.orderBy(d?.sort_order === "desc" ? i(g) : n(g)) : h.orderBy(n(B.created_at));
|
|
2344
|
-
let _ = (await h.offset(c * l).limit(l)).map(
|
|
2339
|
+
let _ = (await h.offset(c * l).limit(l)).map(cn);
|
|
2345
2340
|
if (!u) return {
|
|
2346
2341
|
grants: _,
|
|
2347
2342
|
start: 0,
|
|
@@ -2366,12 +2361,12 @@ function ln(e) {
|
|
|
2366
2361
|
}
|
|
2367
2362
|
//#endregion
|
|
2368
2363
|
//#region src/adapters/hookCode.ts
|
|
2369
|
-
var
|
|
2370
|
-
function
|
|
2371
|
-
return `hc_${
|
|
2364
|
+
var fn = ee("0123456789abcdefghijklmnopqrstuvwxyz", 17);
|
|
2365
|
+
function pn() {
|
|
2366
|
+
return `hc_${fn()}`;
|
|
2372
2367
|
}
|
|
2373
|
-
function
|
|
2374
|
-
let { created_at_ts: t, updated_at_ts: n, secrets: r, ...i } = e, a =
|
|
2368
|
+
function mn(e) {
|
|
2369
|
+
let { created_at_ts: t, updated_at_ts: n, secrets: r, ...i } = e, a = ae({
|
|
2375
2370
|
created_at_ts: t,
|
|
2376
2371
|
updated_at_ts: n
|
|
2377
2372
|
}, ["created_at_ts", "updated_at_ts"]);
|
|
@@ -2381,41 +2376,41 @@ function fn(e) {
|
|
|
2381
2376
|
secrets: r ? JSON.parse(r) : void 0
|
|
2382
2377
|
};
|
|
2383
2378
|
}
|
|
2384
|
-
function
|
|
2379
|
+
function hn(e) {
|
|
2385
2380
|
return {
|
|
2386
2381
|
async create(t, n) {
|
|
2387
2382
|
let r = Date.now(), i = {
|
|
2388
|
-
id:
|
|
2383
|
+
id: pn(),
|
|
2389
2384
|
tenant_id: t,
|
|
2390
2385
|
code: n.code,
|
|
2391
2386
|
secrets: n.secrets ? JSON.stringify(n.secrets) : null,
|
|
2392
2387
|
created_at_ts: r,
|
|
2393
2388
|
updated_at_ts: r
|
|
2394
2389
|
};
|
|
2395
|
-
return await e.insert(
|
|
2390
|
+
return await e.insert(tt).values(i), mn({
|
|
2396
2391
|
...i,
|
|
2397
2392
|
tenant_id: t
|
|
2398
2393
|
});
|
|
2399
2394
|
},
|
|
2400
2395
|
async get(n, r) {
|
|
2401
|
-
let i = await e.select().from(
|
|
2402
|
-
return i ?
|
|
2396
|
+
let i = await e.select().from(tt).where(t(a(tt.tenant_id, n), a(tt.id, r))).get();
|
|
2397
|
+
return i ? mn(i) : null;
|
|
2403
2398
|
},
|
|
2404
2399
|
async update(n, r, i) {
|
|
2405
2400
|
let o = { updated_at_ts: Date.now() };
|
|
2406
|
-
return i.code !== void 0 && (o.code = i.code), i.secrets !== void 0 && (o.secrets = JSON.stringify(i.secrets)), (await e.update(
|
|
2401
|
+
return i.code !== void 0 && (o.code = i.code), i.secrets !== void 0 && (o.secrets = JSON.stringify(i.secrets)), (await e.update(tt).set(o).where(t(a(tt.tenant_id, n), a(tt.id, r))).returning()).length > 0;
|
|
2407
2402
|
},
|
|
2408
2403
|
async remove(n, r) {
|
|
2409
|
-
return (await e.delete(
|
|
2404
|
+
return (await e.delete(tt).where(t(a(tt.tenant_id, n), a(tt.id, r))).returning()).length > 0;
|
|
2410
2405
|
}
|
|
2411
2406
|
};
|
|
2412
2407
|
}
|
|
2413
2408
|
//#endregion
|
|
2414
2409
|
//#region src/adapters/hooks.ts
|
|
2415
|
-
function
|
|
2410
|
+
function gn() {
|
|
2416
2411
|
return `h_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
2417
2412
|
}
|
|
2418
|
-
function
|
|
2413
|
+
function _n(e) {
|
|
2419
2414
|
if (!(typeof e != "string" || !e)) try {
|
|
2420
2415
|
let t = JSON.parse(e);
|
|
2421
2416
|
return t && typeof t == "object" && !Array.isArray(t) ? t : void 0;
|
|
@@ -2423,24 +2418,24 @@ function hn(e) {
|
|
|
2423
2418
|
return;
|
|
2424
2419
|
}
|
|
2425
2420
|
}
|
|
2426
|
-
function
|
|
2427
|
-
let { tenant_id: t, created_at_ts: n, updated_at_ts: r, metadata: i, ...a } = e, o =
|
|
2421
|
+
function vn(e) {
|
|
2422
|
+
let { tenant_id: t, created_at_ts: n, updated_at_ts: r, metadata: i, ...a } = e, o = ae({
|
|
2428
2423
|
created_at_ts: n,
|
|
2429
2424
|
updated_at_ts: r
|
|
2430
2425
|
}, ["created_at_ts", "updated_at_ts"]);
|
|
2431
|
-
return
|
|
2426
|
+
return D({
|
|
2432
2427
|
...a,
|
|
2433
2428
|
enabled: !!a.enabled,
|
|
2434
2429
|
synchronous: !!a.synchronous,
|
|
2435
|
-
metadata:
|
|
2430
|
+
metadata: _n(i),
|
|
2436
2431
|
...o
|
|
2437
2432
|
});
|
|
2438
2433
|
}
|
|
2439
|
-
function
|
|
2434
|
+
function yn(e) {
|
|
2440
2435
|
return {
|
|
2441
2436
|
async create(t, n) {
|
|
2442
2437
|
let r = Date.now(), i = {
|
|
2443
|
-
hook_id: n.hook_id ||
|
|
2438
|
+
hook_id: n.hook_id || gn(),
|
|
2444
2439
|
tenant_id: t,
|
|
2445
2440
|
trigger_id: n.trigger_id,
|
|
2446
2441
|
url: n.url,
|
|
@@ -2456,30 +2451,30 @@ function _n(e) {
|
|
|
2456
2451
|
created_at_ts: r,
|
|
2457
2452
|
updated_at_ts: r
|
|
2458
2453
|
};
|
|
2459
|
-
return await e.insert(
|
|
2454
|
+
return await e.insert(et).values(i), vn({
|
|
2460
2455
|
...i,
|
|
2461
2456
|
tenant_id: t
|
|
2462
2457
|
});
|
|
2463
2458
|
},
|
|
2464
2459
|
async get(n, r) {
|
|
2465
|
-
let i = await e.select().from(
|
|
2466
|
-
return i ?
|
|
2460
|
+
let i = await e.select().from(et).where(t(a(et.tenant_id, n), a(et.hook_id, r))).get();
|
|
2461
|
+
return i ? vn(i) : null;
|
|
2467
2462
|
},
|
|
2468
2463
|
async update(n, r, i) {
|
|
2469
2464
|
let o = { updated_at_ts: Date.now() };
|
|
2470
|
-
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(
|
|
2465
|
+
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(et).set(o).where(t(a(et.tenant_id, n), a(et.hook_id, r))).returning()).length > 0;
|
|
2471
2466
|
},
|
|
2472
2467
|
async list(o, s) {
|
|
2473
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
2468
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? dt(et, f, [
|
|
2474
2469
|
"url",
|
|
2475
2470
|
"form_id",
|
|
2476
2471
|
"template_id",
|
|
2477
2472
|
"code_id"
|
|
2478
|
-
]) : void 0, m = p ? t(a(
|
|
2479
|
-
h = g ? h.orderBy(d?.sort_order === "desc" ? i(g) : n(g)) : h.orderBy(i(
|
|
2480
|
-
let _ = (await h.offset(c * l).limit(l)).map(
|
|
2473
|
+
]) : void 0, m = p ? t(a(et.tenant_id, o), p) : a(et.tenant_id, o), h = e.select().from(et).where(m).$dynamic(), g = d?.sort_by ? et[d.sort_by] : void 0;
|
|
2474
|
+
h = g ? h.orderBy(d?.sort_order === "desc" ? i(g) : n(g)) : h.orderBy(i(et.priority), n(et.created_at_ts));
|
|
2475
|
+
let _ = (await h.offset(c * l).limit(l)).map(vn);
|
|
2481
2476
|
if (!u) return { hooks: _ };
|
|
2482
|
-
let [v] = await e.select({ count: r() }).from(
|
|
2477
|
+
let [v] = await e.select({ count: r() }).from(et).where(m);
|
|
2483
2478
|
return {
|
|
2484
2479
|
hooks: _,
|
|
2485
2480
|
start: c * l,
|
|
@@ -2488,31 +2483,31 @@ function _n(e) {
|
|
|
2488
2483
|
};
|
|
2489
2484
|
},
|
|
2490
2485
|
async remove(n, r) {
|
|
2491
|
-
return (await e.delete(
|
|
2486
|
+
return (await e.delete(et).where(t(a(et.tenant_id, n), a(et.hook_id, r))).returning()).length > 0;
|
|
2492
2487
|
}
|
|
2493
2488
|
};
|
|
2494
2489
|
}
|
|
2495
2490
|
//#endregion
|
|
2496
2491
|
//#region src/adapters/invites.ts
|
|
2497
|
-
function
|
|
2492
|
+
function bn() {
|
|
2498
2493
|
return `inv_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
2499
2494
|
}
|
|
2500
|
-
var
|
|
2495
|
+
var xn = [
|
|
2501
2496
|
"inviter",
|
|
2502
2497
|
"invitee",
|
|
2503
2498
|
"app_metadata",
|
|
2504
2499
|
"user_metadata",
|
|
2505
2500
|
"roles"
|
|
2506
2501
|
];
|
|
2507
|
-
function
|
|
2502
|
+
function Sn(e) {
|
|
2508
2503
|
let { tenant_id: t, send_invitation_email: n, ...r } = e, i = { ...r };
|
|
2509
|
-
for (let e of
|
|
2510
|
-
return i.send_invitation_email = !!n,
|
|
2504
|
+
for (let e of xn) i[e] = Q(r[e], e === "roles" ? [] : {});
|
|
2505
|
+
return i.send_invitation_email = !!n, D(i);
|
|
2511
2506
|
}
|
|
2512
|
-
function
|
|
2507
|
+
function Cn(e) {
|
|
2513
2508
|
return {
|
|
2514
2509
|
async create(t, n) {
|
|
2515
|
-
let r = n.id ||
|
|
2510
|
+
let r = n.id || bn(), i = n.ttl_sec || 604800, a = /* @__PURE__ */ new Date(), o = new Date(a.getTime() + i * 1e3).toISOString(), s = {
|
|
2516
2511
|
id: r,
|
|
2517
2512
|
tenant_id: t,
|
|
2518
2513
|
organization_id: n.organization_id,
|
|
@@ -2525,35 +2520,35 @@ function xn(e) {
|
|
|
2525
2520
|
created_at: a.toISOString(),
|
|
2526
2521
|
expires_at: o
|
|
2527
2522
|
};
|
|
2528
|
-
for (let e of
|
|
2523
|
+
for (let e of xn) n[e] !== void 0 && (s[e] = JSON.stringify(n[e]));
|
|
2529
2524
|
try {
|
|
2530
|
-
await e.insert(
|
|
2525
|
+
await e.insert(Ue).values(s);
|
|
2531
2526
|
} catch (e) {
|
|
2532
|
-
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new
|
|
2527
|
+
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("duplicate key") ? new Ne(409, { message: "Invite already exists" }) : e;
|
|
2533
2528
|
}
|
|
2534
|
-
return
|
|
2529
|
+
return Sn({
|
|
2535
2530
|
...s,
|
|
2536
2531
|
tenant_id: t
|
|
2537
2532
|
});
|
|
2538
2533
|
},
|
|
2539
2534
|
async get(n, r) {
|
|
2540
|
-
let i = await e.select().from(
|
|
2541
|
-
return i ?
|
|
2535
|
+
let i = await e.select().from(Ue).where(t(a(Ue.tenant_id, n), a(Ue.id, r))).get();
|
|
2536
|
+
return i ? Sn(i) : null;
|
|
2542
2537
|
},
|
|
2543
2538
|
async update(n, r, i) {
|
|
2544
2539
|
let o = {};
|
|
2545
|
-
for (let e of
|
|
2546
|
-
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(
|
|
2540
|
+
for (let e of xn) i[e] !== void 0 && (o[e] = JSON.stringify(i[e]));
|
|
2541
|
+
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(Ue).set(o).where(t(a(Ue.tenant_id, n), a(Ue.id, r))).returning()).length > 0;
|
|
2547
2542
|
},
|
|
2548
2543
|
async list(t, o) {
|
|
2549
|
-
let { page: s = 0, per_page: c = 50, include_totals: l = !1, sort: u } = o || {}, d = e.select().from(
|
|
2544
|
+
let { page: s = 0, per_page: c = 50, include_totals: l = !1, sort: u } = o || {}, d = e.select().from(Ue).where(a(Ue.tenant_id, t)).$dynamic();
|
|
2550
2545
|
if (u?.sort_by) {
|
|
2551
|
-
let e =
|
|
2546
|
+
let e = Ue[u.sort_by];
|
|
2552
2547
|
e && (d = d.orderBy(u.sort_order === "desc" ? i(e) : n(e)));
|
|
2553
2548
|
}
|
|
2554
|
-
let f = (await d.offset(s * c).limit(c)).map(
|
|
2549
|
+
let f = (await d.offset(s * c).limit(c)).map(Sn);
|
|
2555
2550
|
if (!l) return { invites: f };
|
|
2556
|
-
let [p] = await e.select({ count: r() }).from(
|
|
2551
|
+
let [p] = await e.select({ count: r() }).from(Ue).where(a(Ue.tenant_id, t));
|
|
2557
2552
|
return {
|
|
2558
2553
|
invites: f,
|
|
2559
2554
|
start: s * c,
|
|
@@ -2562,72 +2557,72 @@ function xn(e) {
|
|
|
2562
2557
|
};
|
|
2563
2558
|
},
|
|
2564
2559
|
async remove(n, r) {
|
|
2565
|
-
return (await e.delete(
|
|
2560
|
+
return (await e.delete(Ue).where(t(a(Ue.tenant_id, n), a(Ue.id, r))).returning()).length > 0;
|
|
2566
2561
|
}
|
|
2567
2562
|
};
|
|
2568
2563
|
}
|
|
2569
2564
|
//#endregion
|
|
2570
2565
|
//#region src/adapters/keys.ts
|
|
2571
|
-
var
|
|
2566
|
+
var wn = [
|
|
2572
2567
|
"kid",
|
|
2573
2568
|
"connection",
|
|
2574
2569
|
"fingerprint",
|
|
2575
2570
|
"thumbprint",
|
|
2576
2571
|
"type"
|
|
2577
2572
|
];
|
|
2578
|
-
function
|
|
2573
|
+
function Tn(e) {
|
|
2579
2574
|
return {
|
|
2580
2575
|
async create(t) {
|
|
2581
|
-
await e.insert(
|
|
2576
|
+
await e.insert(nt).values({
|
|
2582
2577
|
...t,
|
|
2583
2578
|
created_at: (/* @__PURE__ */ new Date()).toDateString()
|
|
2584
2579
|
});
|
|
2585
2580
|
},
|
|
2586
2581
|
async list(a) {
|
|
2587
|
-
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(
|
|
2582
|
+
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(nt.revoked_at, p), f(nt.revoked_at))];
|
|
2588
2583
|
if (d) {
|
|
2589
|
-
let e =
|
|
2584
|
+
let e = we(d, wn);
|
|
2590
2585
|
if (e) {
|
|
2591
|
-
let t =
|
|
2586
|
+
let t = dt(nt, e, wn);
|
|
2592
2587
|
t && m.push(t);
|
|
2593
2588
|
}
|
|
2594
2589
|
}
|
|
2595
|
-
let h = t(...m), g = e.select().from(
|
|
2590
|
+
let h = t(...m), g = e.select().from(nt).where(h).$dynamic();
|
|
2596
2591
|
if (u?.sort_by) {
|
|
2597
|
-
let e =
|
|
2592
|
+
let e = nt[u.sort_by];
|
|
2598
2593
|
e && (g = g.orderBy(u.sort_order === "desc" ? i(e) : n(e)));
|
|
2599
2594
|
}
|
|
2600
2595
|
let _ = (await g.offset(o * c).limit(c)).map((e) => {
|
|
2601
2596
|
let { created_at: t, ...n } = e;
|
|
2602
|
-
return
|
|
2597
|
+
return D(n);
|
|
2603
2598
|
});
|
|
2604
2599
|
if (!l) return { signingKeys: _ };
|
|
2605
|
-
let [y] = await e.select({ count: r() }).from(
|
|
2600
|
+
let [y] = await e.select({ count: r() }).from(nt).where(h);
|
|
2606
2601
|
return {
|
|
2607
2602
|
signingKeys: _,
|
|
2608
2603
|
start: o * c,
|
|
2609
2604
|
limit: c,
|
|
2610
|
-
length:
|
|
2605
|
+
length: se(y?.count ?? 0)
|
|
2611
2606
|
};
|
|
2612
2607
|
},
|
|
2613
2608
|
async update(t, n) {
|
|
2614
|
-
return (await e.update(
|
|
2609
|
+
return (await e.update(nt).set(n).where(a(nt.kid, t)).returning()).length > 0;
|
|
2615
2610
|
}
|
|
2616
2611
|
};
|
|
2617
2612
|
}
|
|
2618
2613
|
//#endregion
|
|
2619
2614
|
//#region src/adapters/loginSessions.ts
|
|
2620
|
-
var
|
|
2621
|
-
function
|
|
2615
|
+
var En = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", Dn = 32;
|
|
2616
|
+
function On() {
|
|
2622
2617
|
let e = Date.now(), t = "";
|
|
2623
|
-
for (let n = 10; n > 0; n--) t =
|
|
2618
|
+
for (let n = 10; n > 0; n--) t = En.charAt(e % Dn) + t, e = Math.floor(e / Dn);
|
|
2624
2619
|
let n = new Uint8Array(16);
|
|
2625
2620
|
crypto.getRandomValues(n);
|
|
2626
|
-
for (let e = 0; e < 16; e++) t +=
|
|
2621
|
+
for (let e = 0; e < 16; e++) t += En.charAt(n[e] % Dn);
|
|
2627
2622
|
return t;
|
|
2628
2623
|
}
|
|
2629
|
-
function
|
|
2630
|
-
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 =
|
|
2624
|
+
function kn(e) {
|
|
2625
|
+
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({
|
|
2631
2626
|
created_at_ts: n,
|
|
2632
2627
|
updated_at_ts: r,
|
|
2633
2628
|
expires_at_ts: i
|
|
@@ -2637,18 +2632,18 @@ function Dn(e) {
|
|
|
2637
2632
|
"expires_at_ts"
|
|
2638
2633
|
]), l = {};
|
|
2639
2634
|
for (let [e, t] of Object.entries(s)) t != null && (l[e] = t);
|
|
2640
|
-
return
|
|
2641
|
-
...
|
|
2635
|
+
return D({
|
|
2636
|
+
...ct(l, ["auth_strategy"]),
|
|
2642
2637
|
authParams: typeof o == "string" && o.length > 0 ? JSON.parse(o) : {},
|
|
2643
2638
|
...c,
|
|
2644
2639
|
state_data: Q(a)
|
|
2645
2640
|
});
|
|
2646
2641
|
}
|
|
2647
|
-
function
|
|
2642
|
+
function An(e) {
|
|
2648
2643
|
return {
|
|
2649
2644
|
async create(t, n) {
|
|
2650
2645
|
let r = Date.now(), i = {
|
|
2651
|
-
id:
|
|
2646
|
+
id: On(),
|
|
2652
2647
|
tenant_id: t,
|
|
2653
2648
|
session_id: n.session_id,
|
|
2654
2649
|
csrf_token: n.csrf_token,
|
|
@@ -2667,20 +2662,20 @@ function On(e) {
|
|
|
2667
2662
|
authenticated_at: n.authenticated_at,
|
|
2668
2663
|
created_at_ts: r,
|
|
2669
2664
|
updated_at_ts: r,
|
|
2670
|
-
expires_at_ts: n.expires_at ?
|
|
2665
|
+
expires_at_ts: n.expires_at ? E(n.expires_at) : r + 1e3 * 60 * 60 * 24
|
|
2671
2666
|
};
|
|
2672
|
-
return await e.insert(F).values(i),
|
|
2667
|
+
return await e.insert(F).values(i), kn({
|
|
2673
2668
|
...i,
|
|
2674
2669
|
tenant_id: t
|
|
2675
2670
|
});
|
|
2676
2671
|
},
|
|
2677
2672
|
async get(n, r) {
|
|
2678
2673
|
let i = n ? t(a(F.tenant_id, n), a(F.id, r)) : a(F.id, r), o = await e.select().from(F).where(i).get();
|
|
2679
|
-
return o ?
|
|
2674
|
+
return o ? kn(o) : null;
|
|
2680
2675
|
},
|
|
2681
2676
|
async update(n, r, i) {
|
|
2682
2677
|
let o = { updated_at_ts: Date.now() };
|
|
2683
|
-
if (i.session_id !== void 0 && (o.session_id = i.session_id), i.state !== void 0 && (o.state = i.state), i.state_data !== void 0 && (o.state_data = JSON.stringify(i.state_data)), i.failure_reason !== void 0 && (o.failure_reason = i.failure_reason), i.user_id !== void 0 && (o.user_id = i.user_id), i.auth_connection !== void 0 && (o.auth_connection = i.auth_connection), i.auth_strategy !== void 0 && (o.auth_strategy_strategy = i.auth_strategy?.strategy, o.auth_strategy_strategy_type = i.auth_strategy?.strategy_type), i.authenticated_at !== void 0 && (o.authenticated_at = i.authenticated_at), i.authorization_url !== void 0 && (o.authorization_url = i.authorization_url?.substring(0, 1024)), i.expires_at !== void 0 && (o.expires_at_ts =
|
|
2678
|
+
if (i.session_id !== void 0 && (o.session_id = i.session_id), i.state !== void 0 && (o.state = i.state), i.state_data !== void 0 && (o.state_data = JSON.stringify(i.state_data)), i.failure_reason !== void 0 && (o.failure_reason = i.failure_reason), i.user_id !== void 0 && (o.user_id = i.user_id), i.auth_connection !== void 0 && (o.auth_connection = i.auth_connection), i.auth_strategy !== void 0 && (o.auth_strategy_strategy = i.auth_strategy?.strategy, o.auth_strategy_strategy_type = i.auth_strategy?.strategy_type), i.authenticated_at !== void 0 && (o.authenticated_at = i.authenticated_at), i.authorization_url !== void 0 && (o.authorization_url = i.authorization_url?.substring(0, 1024)), i.expires_at !== void 0 && (o.expires_at_ts = E(i.expires_at)), i.authParams !== void 0) {
|
|
2684
2679
|
let s = await e.select({ auth_params: F.auth_params }).from(F).where(t(a(F.tenant_id, n), a(F.id, r))).get(), c = s?.auth_params && typeof s.auth_params == "string" && s.auth_params.length > 0 ? JSON.parse(s.auth_params) : {};
|
|
2685
2680
|
o.auth_params = JSON.stringify({
|
|
2686
2681
|
...c,
|
|
@@ -2696,7 +2691,7 @@ function On(e) {
|
|
|
2696
2691
|
}
|
|
2697
2692
|
//#endregion
|
|
2698
2693
|
//#region src/adapters/logs.ts
|
|
2699
|
-
function
|
|
2694
|
+
function jn(e) {
|
|
2700
2695
|
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 = {
|
|
2701
2696
|
...f,
|
|
2702
2697
|
isMobile: !!n,
|
|
@@ -2704,16 +2699,16 @@ function kn(e) {
|
|
|
2704
2699
|
details: Q(i),
|
|
2705
2700
|
scope: d ? d.split(",") : void 0
|
|
2706
2701
|
};
|
|
2707
|
-
return a && (p.location_info =
|
|
2702
|
+
return a && (p.location_info = D({
|
|
2708
2703
|
country_code: a,
|
|
2709
2704
|
city_name: o,
|
|
2710
2705
|
latitude: s,
|
|
2711
2706
|
longitude: c,
|
|
2712
2707
|
time_zone: l,
|
|
2713
2708
|
continent_code: u
|
|
2714
|
-
})),
|
|
2709
|
+
})), D(p);
|
|
2715
2710
|
}
|
|
2716
|
-
function
|
|
2711
|
+
function Mn(e) {
|
|
2717
2712
|
return {
|
|
2718
2713
|
async create(t, n) {
|
|
2719
2714
|
let r = {
|
|
@@ -2739,7 +2734,7 @@ function An(e) {
|
|
|
2739
2734
|
hostname: n.hostname,
|
|
2740
2735
|
session_connection: n.session_connection
|
|
2741
2736
|
};
|
|
2742
|
-
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(J).values(r),
|
|
2737
|
+
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(J).values(r), jn({
|
|
2743
2738
|
...r,
|
|
2744
2739
|
tenant_id: t
|
|
2745
2740
|
});
|
|
@@ -2747,7 +2742,7 @@ function An(e) {
|
|
|
2747
2742
|
async list(o, s) {
|
|
2748
2743
|
let { page: l = 0, per_page: u = 50, include_totals: d = !1, sort: f, q: p, from_date: h, to_date: g } = s || {}, _ = [a(J.tenant_id, o)];
|
|
2749
2744
|
if (p) {
|
|
2750
|
-
let e =
|
|
2745
|
+
let e = dt(J, p, [
|
|
2751
2746
|
"user_id",
|
|
2752
2747
|
"ip",
|
|
2753
2748
|
"type",
|
|
@@ -2757,14 +2752,14 @@ function An(e) {
|
|
|
2757
2752
|
}
|
|
2758
2753
|
typeof h == "number" && Number.isFinite(h) && _.push(c(J.date, (/* @__PURE__ */ new Date(Math.floor(h) * 1e3)).toISOString())), typeof g == "number" && Number.isFinite(g) && _.push(m(J.date, (/* @__PURE__ */ new Date((Math.floor(g) + 1) * 1e3)).toISOString()));
|
|
2759
2754
|
let v = t(..._);
|
|
2760
|
-
if (
|
|
2761
|
-
if (f?.sort_by && f.sort_by !== "date") throw new
|
|
2755
|
+
if (Ct(s)) {
|
|
2756
|
+
if (f?.sort_by && f.sort_by !== "date") throw new Ne(400, { message: `Sorting by ${f.sort_by} is not supported with checkpoint pagination (from/take); only date is` });
|
|
2762
2757
|
let n = f?.sort_order === "asc" ? "asc" : "desc", r = {
|
|
2763
2758
|
sortColumn: J.date,
|
|
2764
2759
|
idColumn: J.log_id,
|
|
2765
2760
|
sortOrder: n,
|
|
2766
2761
|
sortKey: `date:${n}`
|
|
2767
|
-
}, i =
|
|
2762
|
+
}, i = Et(s, r), a = wt(s), { rows: o, next: c } = Dt(await e.select().from(J).where(i ? t(v, i) : v).orderBy(...Tt(r)).limit(a + 1), a, "date", "log_id", r.sortKey), l = o.map(jn);
|
|
2768
2763
|
return {
|
|
2769
2764
|
logs: l,
|
|
2770
2765
|
start: 0,
|
|
@@ -2778,7 +2773,7 @@ function An(e) {
|
|
|
2778
2773
|
let e = J[f.sort_by];
|
|
2779
2774
|
e && (y = y.orderBy(f.sort_order === "desc" ? i(e) : n(e)));
|
|
2780
2775
|
} else y = y.orderBy(i(J.date));
|
|
2781
|
-
let ee = (await y.offset(l * u).limit(u)).map(
|
|
2776
|
+
let ee = (await y.offset(l * u).limit(u)).map(jn);
|
|
2782
2777
|
if (!d) return { logs: ee };
|
|
2783
2778
|
let [b] = await e.select({ count: r() }).from(J).where(v);
|
|
2784
2779
|
return {
|
|
@@ -2790,37 +2785,37 @@ function An(e) {
|
|
|
2790
2785
|
},
|
|
2791
2786
|
async get(n, r) {
|
|
2792
2787
|
let i = await e.select().from(J).where(t(a(J.tenant_id, n), a(J.log_id, r))).get();
|
|
2793
|
-
return i ?
|
|
2788
|
+
return i ? jn(i) : null;
|
|
2794
2789
|
}
|
|
2795
2790
|
};
|
|
2796
2791
|
}
|
|
2797
2792
|
//#endregion
|
|
2798
2793
|
//#region src/adapters/authenticationMethods.ts
|
|
2799
|
-
var
|
|
2800
|
-
function
|
|
2794
|
+
var Nn = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", Pn = 32;
|
|
2795
|
+
function Fn() {
|
|
2801
2796
|
let e = Date.now(), t = "";
|
|
2802
|
-
for (let n = 10; n > 0; n--) t =
|
|
2797
|
+
for (let n = 10; n > 0; n--) t = Nn.charAt(e % Pn) + t, e = Math.floor(e / Pn);
|
|
2803
2798
|
let n = new Uint8Array(16);
|
|
2804
2799
|
crypto.getRandomValues(n);
|
|
2805
|
-
for (let e = 0; e < 16; e++) t +=
|
|
2800
|
+
for (let e = 0; e < 16; e++) t += Nn.charAt(n[e] % Pn);
|
|
2806
2801
|
return t;
|
|
2807
2802
|
}
|
|
2808
|
-
function
|
|
2803
|
+
function In(e) {
|
|
2809
2804
|
let { tenant_id: t, created_at_ts: n, updated_at_ts: r, credential_backed_up: i, confirmed: a, transports: o, ...s } = e;
|
|
2810
|
-
return
|
|
2805
|
+
return D({
|
|
2811
2806
|
...s,
|
|
2812
2807
|
confirmed: !!a,
|
|
2813
2808
|
credential_backed_up: i == null ? void 0 : !!i,
|
|
2814
2809
|
transports: Q(o),
|
|
2815
|
-
created_at:
|
|
2816
|
-
updated_at:
|
|
2810
|
+
created_at: oe(n),
|
|
2811
|
+
updated_at: oe(r)
|
|
2817
2812
|
});
|
|
2818
2813
|
}
|
|
2819
|
-
function
|
|
2814
|
+
function Ln(e) {
|
|
2820
2815
|
return {
|
|
2821
2816
|
async create(t, n) {
|
|
2822
2817
|
let r = Date.now(), i = {
|
|
2823
|
-
id: n.id ||
|
|
2818
|
+
id: n.id || Fn(),
|
|
2824
2819
|
tenant_id: t,
|
|
2825
2820
|
user_id: n.user_id,
|
|
2826
2821
|
type: n.type,
|
|
@@ -2836,43 +2831,43 @@ function Fn(e) {
|
|
|
2836
2831
|
created_at_ts: r,
|
|
2837
2832
|
updated_at_ts: r
|
|
2838
2833
|
};
|
|
2839
|
-
return await e.insert(
|
|
2834
|
+
return await e.insert(q).values(i), In({
|
|
2840
2835
|
...i,
|
|
2841
2836
|
tenant_id: t
|
|
2842
2837
|
});
|
|
2843
2838
|
},
|
|
2844
2839
|
async get(n, r) {
|
|
2845
|
-
let i = await e.select().from(
|
|
2846
|
-
return i ?
|
|
2840
|
+
let i = await e.select().from(q).where(t(a(q.tenant_id, n), a(q.id, r))).get();
|
|
2841
|
+
return i ? In(i) : null;
|
|
2847
2842
|
},
|
|
2848
2843
|
async getByCredentialId(n, r) {
|
|
2849
|
-
let i = await e.select().from(
|
|
2850
|
-
return i ?
|
|
2844
|
+
let i = await e.select().from(q).where(t(a(q.tenant_id, n), a(q.credential_id, r))).get();
|
|
2845
|
+
return i ? In(i) : null;
|
|
2851
2846
|
},
|
|
2852
2847
|
async list(n, r) {
|
|
2853
|
-
return (await e.select().from(
|
|
2848
|
+
return (await e.select().from(q).where(t(a(q.tenant_id, n), a(q.user_id, r))).all()).map(In);
|
|
2854
2849
|
},
|
|
2855
2850
|
async update(n, r, i) {
|
|
2856
2851
|
let o = { updated_at_ts: Date.now() };
|
|
2857
|
-
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(
|
|
2852
|
+
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(q).set(o).where(t(a(q.tenant_id, n), a(q.id, r)));
|
|
2858
2853
|
let s = await this.get(n, r);
|
|
2859
2854
|
if (!s) throw Error(`Authentication method ${r} not found after update`);
|
|
2860
2855
|
return s;
|
|
2861
2856
|
},
|
|
2862
2857
|
async remove(n, r) {
|
|
2863
|
-
return (await e.delete(
|
|
2858
|
+
return (await e.delete(q).where(t(a(q.tenant_id, n), a(q.id, r))).returning()).length > 0;
|
|
2864
2859
|
}
|
|
2865
2860
|
};
|
|
2866
2861
|
}
|
|
2867
2862
|
//#endregion
|
|
2868
2863
|
//#region src/adapters/organizations.ts
|
|
2869
|
-
var
|
|
2870
|
-
function
|
|
2864
|
+
var Rn = ["name", "display_name"];
|
|
2865
|
+
function zn() {
|
|
2871
2866
|
return `org_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
2872
2867
|
}
|
|
2873
|
-
function
|
|
2868
|
+
function Bn(e) {
|
|
2874
2869
|
let { tenant_id: t, branding: n, metadata: r, enabled_connections: i, token_quota: a, ...o } = e;
|
|
2875
|
-
return
|
|
2870
|
+
return D({
|
|
2876
2871
|
...o,
|
|
2877
2872
|
branding: Q(n, {}),
|
|
2878
2873
|
metadata: Q(r, {}),
|
|
@@ -2880,11 +2875,11 @@ function Rn(e) {
|
|
|
2880
2875
|
token_quota: Q(a, {})
|
|
2881
2876
|
});
|
|
2882
2877
|
}
|
|
2883
|
-
function
|
|
2878
|
+
function Vn(e) {
|
|
2884
2879
|
return {
|
|
2885
2880
|
async create(t, n) {
|
|
2886
2881
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
2887
|
-
id: n.id ||
|
|
2882
|
+
id: n.id || zn(),
|
|
2888
2883
|
tenant_id: t,
|
|
2889
2884
|
name: n.name,
|
|
2890
2885
|
display_name: n.display_name,
|
|
@@ -2896,39 +2891,39 @@ function zn(e) {
|
|
|
2896
2891
|
updated_at: r
|
|
2897
2892
|
};
|
|
2898
2893
|
try {
|
|
2899
|
-
await e.insert(
|
|
2894
|
+
await e.insert(H).values(i);
|
|
2900
2895
|
} catch (e) {
|
|
2901
|
-
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("AlreadyExists") ? new
|
|
2896
|
+
throw e?.message?.includes("UNIQUE constraint failed") || e?.message?.includes("AlreadyExists") ? new Ne(409, { message: "Organization already exists" }) : e;
|
|
2902
2897
|
}
|
|
2903
|
-
return
|
|
2898
|
+
return Bn({
|
|
2904
2899
|
...i,
|
|
2905
2900
|
tenant_id: t
|
|
2906
2901
|
});
|
|
2907
2902
|
},
|
|
2908
2903
|
async get(n, r) {
|
|
2909
|
-
let i = await e.select().from(
|
|
2910
|
-
return i ||= await e.select().from(
|
|
2904
|
+
let i = await e.select().from(H).where(t(a(H.tenant_id, n), a(H.id, r))).get();
|
|
2905
|
+
return i ||= await e.select().from(H).where(t(a(H.tenant_id, n), a(H.name, r))).get(), i ? Bn(i) : null;
|
|
2911
2906
|
},
|
|
2912
2907
|
async update(n, r, i) {
|
|
2913
2908
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
2914
|
-
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(
|
|
2909
|
+
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(H).set(o).where(t(a(H.tenant_id, n), a(H.id, r))).returning()).length > 0;
|
|
2915
2910
|
},
|
|
2916
2911
|
async list(o, s) {
|
|
2917
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(
|
|
2912
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = [a(H.tenant_id, o)];
|
|
2918
2913
|
if (f) {
|
|
2919
|
-
let e =
|
|
2914
|
+
let e = we(f, Rn);
|
|
2920
2915
|
if (e) {
|
|
2921
|
-
let t =
|
|
2916
|
+
let t = dt(H, e, Rn);
|
|
2922
2917
|
t && p.push(t);
|
|
2923
2918
|
}
|
|
2924
2919
|
}
|
|
2925
2920
|
let m = t(...p);
|
|
2926
|
-
if (
|
|
2921
|
+
if (Ct(s)) {
|
|
2927
2922
|
let n = {
|
|
2928
|
-
sortColumn:
|
|
2929
|
-
idColumn:
|
|
2923
|
+
sortColumn: H.created_at,
|
|
2924
|
+
idColumn: H.id,
|
|
2930
2925
|
sortOrder: "desc"
|
|
2931
|
-
}, r =
|
|
2926
|
+
}, r = Et(s, n), i = wt(s), { rows: a, next: o } = Dt(await e.select().from(H).where(r ? t(m, r) : m).orderBy(...Tt(n)).limit(i + 1), i, "created_at"), c = a.map(Bn);
|
|
2932
2927
|
return {
|
|
2933
2928
|
organizations: c,
|
|
2934
2929
|
start: 0,
|
|
@@ -2938,14 +2933,14 @@ function zn(e) {
|
|
|
2938
2933
|
next: o
|
|
2939
2934
|
};
|
|
2940
2935
|
}
|
|
2941
|
-
let h = e.select().from(
|
|
2936
|
+
let h = e.select().from(H).where(m).$dynamic();
|
|
2942
2937
|
if (d?.sort_by) {
|
|
2943
|
-
let e =
|
|
2938
|
+
let e = H[d.sort_by];
|
|
2944
2939
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
2945
2940
|
}
|
|
2946
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
2941
|
+
let g = (await h.offset(c * l).limit(l)).map(Bn);
|
|
2947
2942
|
if (!u) return { organizations: g };
|
|
2948
|
-
let [_] = await e.select({ count: r() }).from(
|
|
2943
|
+
let [_] = await e.select({ count: r() }).from(H).where(m);
|
|
2949
2944
|
return {
|
|
2950
2945
|
organizations: g,
|
|
2951
2946
|
start: c * l,
|
|
@@ -2954,20 +2949,20 @@ function zn(e) {
|
|
|
2954
2949
|
};
|
|
2955
2950
|
},
|
|
2956
2951
|
async remove(n, r) {
|
|
2957
|
-
return (await e.delete(
|
|
2952
|
+
return (await e.delete(H).where(t(a(H.tenant_id, n), a(H.id, r))).returning()).length > 0;
|
|
2958
2953
|
}
|
|
2959
2954
|
};
|
|
2960
2955
|
}
|
|
2961
2956
|
//#endregion
|
|
2962
2957
|
//#region src/adapters/passwords.ts
|
|
2963
|
-
function
|
|
2958
|
+
function Hn(e) {
|
|
2964
2959
|
let { tenant_id: t, is_current: n, ...r } = e;
|
|
2965
2960
|
return {
|
|
2966
2961
|
...r,
|
|
2967
2962
|
is_current: !!n
|
|
2968
2963
|
};
|
|
2969
2964
|
}
|
|
2970
|
-
function
|
|
2965
|
+
function Un(e) {
|
|
2971
2966
|
return {
|
|
2972
2967
|
async create(n, r) {
|
|
2973
2968
|
let i = (/* @__PURE__ */ new Date()).toISOString(), o = r.id || b();
|
|
@@ -2982,18 +2977,18 @@ function Vn(e) {
|
|
|
2982
2977
|
created_at: i,
|
|
2983
2978
|
updated_at: i
|
|
2984
2979
|
};
|
|
2985
|
-
return await e.insert(M).values(s),
|
|
2980
|
+
return await e.insert(M).values(s), Hn({
|
|
2986
2981
|
...s,
|
|
2987
2982
|
tenant_id: n
|
|
2988
2983
|
});
|
|
2989
2984
|
},
|
|
2990
2985
|
async get(n, r) {
|
|
2991
2986
|
let i = await e.select().from(M).where(t(a(M.tenant_id, n), a(M.user_id, r), a(M.is_current, 1))).get();
|
|
2992
|
-
return i ?
|
|
2987
|
+
return i ? Hn(i) : null;
|
|
2993
2988
|
},
|
|
2994
2989
|
async list(n, r, o) {
|
|
2995
2990
|
let s = e.select().from(M).where(t(a(M.tenant_id, n), a(M.user_id, r))).orderBy(i(M.created_at)).$dynamic();
|
|
2996
|
-
return o && (s = s.limit(o)), (await s).map(
|
|
2991
|
+
return o && (s = s.limit(o)), (await s).map(Hn);
|
|
2997
2992
|
},
|
|
2998
2993
|
async update(n, r) {
|
|
2999
2994
|
let i = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -3003,10 +2998,10 @@ function Vn(e) {
|
|
|
3003
2998
|
}
|
|
3004
2999
|
//#endregion
|
|
3005
3000
|
//#region src/adapters/promptSettings.ts
|
|
3006
|
-
function
|
|
3001
|
+
function Wn(e) {
|
|
3007
3002
|
return {
|
|
3008
3003
|
async get(t) {
|
|
3009
|
-
let n = await e.select().from(
|
|
3004
|
+
let n = await e.select().from(Ze).where(a(Ze.tenant_id, t)).get();
|
|
3010
3005
|
return n ? {
|
|
3011
3006
|
universal_login_experience: n.universal_login_experience,
|
|
3012
3007
|
identifier_first: !!n.identifier_first,
|
|
@@ -3022,7 +3017,7 @@ function Hn(e) {
|
|
|
3022
3017
|
};
|
|
3023
3018
|
},
|
|
3024
3019
|
async set(t, n) {
|
|
3025
|
-
await e.insert(
|
|
3020
|
+
await e.insert(Ze).values({
|
|
3026
3021
|
tenant_id: t,
|
|
3027
3022
|
universal_login_experience: n.universal_login_experience,
|
|
3028
3023
|
identifier_first: n.identifier_first,
|
|
@@ -3030,7 +3025,7 @@ function Hn(e) {
|
|
|
3030
3025
|
webauthn_platform_first_factor: n.webauthn_platform_first_factor,
|
|
3031
3026
|
show_last_used_connection: n.show_last_used_connection
|
|
3032
3027
|
}).onConflictDoUpdate({
|
|
3033
|
-
target:
|
|
3028
|
+
target: Ze.tenant_id,
|
|
3034
3029
|
set: {
|
|
3035
3030
|
universal_login_experience: n.universal_login_experience,
|
|
3036
3031
|
identifier_first: n.identifier_first,
|
|
@@ -3044,22 +3039,22 @@ function Hn(e) {
|
|
|
3044
3039
|
}
|
|
3045
3040
|
//#endregion
|
|
3046
3041
|
//#region src/adapters/proxyRoutes.ts
|
|
3047
|
-
function
|
|
3042
|
+
function Gn(e) {
|
|
3048
3043
|
if (!e) return { path: "/*" };
|
|
3049
3044
|
try {
|
|
3050
|
-
let t = JSON.parse(e), n =
|
|
3045
|
+
let t = JSON.parse(e), n = be.safeParse(t);
|
|
3051
3046
|
if (n.success) return n.data;
|
|
3052
3047
|
} catch {}
|
|
3053
3048
|
return { path: "/*" };
|
|
3054
3049
|
}
|
|
3055
|
-
function
|
|
3050
|
+
function Kn(e) {
|
|
3056
3051
|
if (!e) return [];
|
|
3057
3052
|
try {
|
|
3058
3053
|
let t = JSON.parse(e);
|
|
3059
3054
|
if (!Array.isArray(t)) return [];
|
|
3060
3055
|
let n = [];
|
|
3061
3056
|
for (let e of t) {
|
|
3062
|
-
let t =
|
|
3057
|
+
let t = _e.safeParse(e);
|
|
3063
3058
|
t.success && n.push(t.data);
|
|
3064
3059
|
}
|
|
3065
3060
|
return n;
|
|
@@ -3067,19 +3062,19 @@ function Wn(e) {
|
|
|
3067
3062
|
return [];
|
|
3068
3063
|
}
|
|
3069
3064
|
}
|
|
3070
|
-
function
|
|
3065
|
+
function qn(e) {
|
|
3071
3066
|
return {
|
|
3072
3067
|
id: e.id,
|
|
3073
3068
|
tenant_id: e.tenant_id,
|
|
3074
3069
|
custom_domain_id: e.custom_domain_id,
|
|
3075
3070
|
priority: e.priority,
|
|
3076
|
-
match:
|
|
3077
|
-
handlers:
|
|
3071
|
+
match: Gn(e.match),
|
|
3072
|
+
handlers: Kn(e.handlers),
|
|
3078
3073
|
created_at: e.created_at,
|
|
3079
3074
|
updated_at: e.updated_at
|
|
3080
3075
|
};
|
|
3081
3076
|
}
|
|
3082
|
-
function
|
|
3077
|
+
function Jn(e) {
|
|
3083
3078
|
return {
|
|
3084
3079
|
async create(t, n) {
|
|
3085
3080
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -3105,14 +3100,14 @@ function Kn(e) {
|
|
|
3105
3100
|
},
|
|
3106
3101
|
async get(n, r) {
|
|
3107
3102
|
let i = await e.select().from(X).where(t(a(X.tenant_id, n), a(X.id, r))).limit(1);
|
|
3108
|
-
return i[0] ?
|
|
3103
|
+
return i[0] ? qn(i[0]) : null;
|
|
3109
3104
|
},
|
|
3110
3105
|
async list(r, i = {}) {
|
|
3111
3106
|
let o = i.page ?? 0, s = i.per_page ?? 50, c = [a(X.tenant_id, r)];
|
|
3112
3107
|
i.custom_domain_id && c.push(a(X.custom_domain_id, i.custom_domain_id));
|
|
3113
3108
|
let l = await e.select().from(X).where(t(...c)).orderBy(n(X.priority), n(X.created_at)).offset(o * s).limit(s);
|
|
3114
3109
|
return {
|
|
3115
|
-
proxy_routes: l.map(
|
|
3110
|
+
proxy_routes: l.map(qn),
|
|
3116
3111
|
start: o * s,
|
|
3117
3112
|
limit: s,
|
|
3118
3113
|
length: l.length
|
|
@@ -3131,14 +3126,14 @@ function Kn(e) {
|
|
|
3131
3126
|
}
|
|
3132
3127
|
//#endregion
|
|
3133
3128
|
//#region src/adapters/scim.ts
|
|
3134
|
-
function
|
|
3129
|
+
function Yn(e) {
|
|
3135
3130
|
if (!e) return [];
|
|
3136
3131
|
try {
|
|
3137
3132
|
let t = JSON.parse(e);
|
|
3138
3133
|
if (!Array.isArray(t)) return [];
|
|
3139
3134
|
let n = [];
|
|
3140
3135
|
for (let e of t) {
|
|
3141
|
-
let t =
|
|
3136
|
+
let t = Te.safeParse(e);
|
|
3142
3137
|
t.success && n.push(t.data);
|
|
3143
3138
|
}
|
|
3144
3139
|
return n;
|
|
@@ -3146,7 +3141,7 @@ function qn(e) {
|
|
|
3146
3141
|
return [];
|
|
3147
3142
|
}
|
|
3148
3143
|
}
|
|
3149
|
-
function
|
|
3144
|
+
function Xn(e) {
|
|
3150
3145
|
if (!e) return [];
|
|
3151
3146
|
try {
|
|
3152
3147
|
let t = JSON.parse(e);
|
|
@@ -3155,16 +3150,16 @@ function Jn(e) {
|
|
|
3155
3150
|
return [];
|
|
3156
3151
|
}
|
|
3157
3152
|
}
|
|
3158
|
-
function
|
|
3153
|
+
function Zn(e) {
|
|
3159
3154
|
return {
|
|
3160
3155
|
connection_id: e.connection_id,
|
|
3161
3156
|
user_id_attribute: e.user_id_attribute,
|
|
3162
|
-
mapping:
|
|
3157
|
+
mapping: Yn(e.mapping),
|
|
3163
3158
|
created_at: e.created_at,
|
|
3164
3159
|
updated_at: e.updated_at
|
|
3165
3160
|
};
|
|
3166
3161
|
}
|
|
3167
|
-
function
|
|
3162
|
+
function Qn(e) {
|
|
3168
3163
|
return {
|
|
3169
3164
|
async create(t, n) {
|
|
3170
3165
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -3174,7 +3169,7 @@ function Xn(e) {
|
|
|
3174
3169
|
created_at: r,
|
|
3175
3170
|
updated_at: r
|
|
3176
3171
|
};
|
|
3177
|
-
return await e.insert(
|
|
3172
|
+
return await e.insert(it).values({
|
|
3178
3173
|
connection_id: i.connection_id,
|
|
3179
3174
|
tenant_id: t,
|
|
3180
3175
|
user_id_attribute: i.user_id_attribute,
|
|
@@ -3184,31 +3179,31 @@ function Xn(e) {
|
|
|
3184
3179
|
}), i;
|
|
3185
3180
|
},
|
|
3186
3181
|
async get(n, r) {
|
|
3187
|
-
let i = await e.select().from(
|
|
3188
|
-
return i[0] ?
|
|
3182
|
+
let i = await e.select().from(it).where(t(a(it.tenant_id, n), a(it.connection_id, r))).limit(1);
|
|
3183
|
+
return i[0] ? Zn(i[0]) : null;
|
|
3189
3184
|
},
|
|
3190
3185
|
async update(n, r, i) {
|
|
3191
|
-
if ((await e.select({ connection_id:
|
|
3186
|
+
if ((await e.select({ connection_id: it.connection_id }).from(it).where(t(a(it.tenant_id, n), a(it.connection_id, r))).limit(1)).length === 0) return !1;
|
|
3192
3187
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
3193
|
-
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(
|
|
3188
|
+
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(it).set(o).where(t(a(it.tenant_id, n), a(it.connection_id, r))), !0;
|
|
3194
3189
|
},
|
|
3195
3190
|
async remove(n, r) {
|
|
3196
|
-
return (await e.select({ connection_id:
|
|
3191
|
+
return (await e.select({ connection_id: it.connection_id }).from(it).where(t(a(it.tenant_id, n), a(it.connection_id, r))).limit(1)).length === 0 ? !1 : (await e.delete(it).where(t(a(it.tenant_id, n), a(it.connection_id, r))), !0);
|
|
3197
3192
|
}
|
|
3198
3193
|
};
|
|
3199
3194
|
}
|
|
3200
|
-
function
|
|
3195
|
+
function $n(e) {
|
|
3201
3196
|
return {
|
|
3202
3197
|
token_id: e.token_id,
|
|
3203
3198
|
connection_id: e.connection_id,
|
|
3204
3199
|
token_hash: e.token_hash,
|
|
3205
|
-
scopes:
|
|
3200
|
+
scopes: Xn(e.scopes),
|
|
3206
3201
|
valid_until: e.valid_until ?? void 0,
|
|
3207
3202
|
created_at: e.created_at,
|
|
3208
3203
|
last_used_at: e.last_used_at ?? void 0
|
|
3209
3204
|
};
|
|
3210
3205
|
}
|
|
3211
|
-
function
|
|
3206
|
+
function er(e) {
|
|
3212
3207
|
return {
|
|
3213
3208
|
async create(t, n) {
|
|
3214
3209
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -3231,14 +3226,14 @@ function Qn(e) {
|
|
|
3231
3226
|
},
|
|
3232
3227
|
async get(n, r) {
|
|
3233
3228
|
let i = await e.select().from(Z).where(t(a(Z.tenant_id, n), a(Z.token_id, r))).limit(1);
|
|
3234
|
-
return i[0] ?
|
|
3229
|
+
return i[0] ? $n(i[0]) : null;
|
|
3235
3230
|
},
|
|
3236
3231
|
async getByHash(n, r) {
|
|
3237
3232
|
let i = await e.select().from(Z).where(t(a(Z.tenant_id, n), a(Z.token_hash, r))).limit(1);
|
|
3238
|
-
return i[0] ?
|
|
3233
|
+
return i[0] ? $n(i[0]) : null;
|
|
3239
3234
|
},
|
|
3240
3235
|
async listByConnection(n, r) {
|
|
3241
|
-
return (await e.select().from(Z).where(t(a(Z.tenant_id, n), a(Z.connection_id, r)))).map(
|
|
3236
|
+
return (await e.select().from(Z).where(t(a(Z.tenant_id, n), a(Z.connection_id, r)))).map($n);
|
|
3242
3237
|
},
|
|
3243
3238
|
async markUsed(n, r, i) {
|
|
3244
3239
|
return (await e.select({ token_id: Z.token_id }).from(Z).where(t(a(Z.tenant_id, n), a(Z.token_id, r))).limit(1)).length === 0 ? !1 : (await e.update(Z).set({ last_used_at: i }).where(t(a(Z.tenant_id, n), a(Z.token_id, r))), !0);
|
|
@@ -3248,7 +3243,7 @@ function Qn(e) {
|
|
|
3248
3243
|
}
|
|
3249
3244
|
};
|
|
3250
3245
|
}
|
|
3251
|
-
function
|
|
3246
|
+
function tr(e) {
|
|
3252
3247
|
return {
|
|
3253
3248
|
connection_id: e.connection_id,
|
|
3254
3249
|
external_id: e.external_id,
|
|
@@ -3256,7 +3251,7 @@ function $n(e) {
|
|
|
3256
3251
|
created_at: e.created_at
|
|
3257
3252
|
};
|
|
3258
3253
|
}
|
|
3259
|
-
function
|
|
3254
|
+
function nr(e) {
|
|
3260
3255
|
return {
|
|
3261
3256
|
async create(t, n) {
|
|
3262
3257
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -3265,7 +3260,7 @@ function er(e) {
|
|
|
3265
3260
|
user_id: n.user_id,
|
|
3266
3261
|
created_at: r
|
|
3267
3262
|
};
|
|
3268
|
-
return await e.insert(
|
|
3263
|
+
return await e.insert(at).values({
|
|
3269
3264
|
tenant_id: t,
|
|
3270
3265
|
connection_id: i.connection_id,
|
|
3271
3266
|
external_id: i.external_id,
|
|
@@ -3274,22 +3269,22 @@ function er(e) {
|
|
|
3274
3269
|
}), i;
|
|
3275
3270
|
},
|
|
3276
3271
|
async getByExternalId(n, r, i) {
|
|
3277
|
-
let o = await e.select().from(
|
|
3278
|
-
return o[0] ?
|
|
3272
|
+
let o = await e.select().from(at).where(t(a(at.tenant_id, n), a(at.connection_id, r), a(at.external_id, i))).limit(1);
|
|
3273
|
+
return o[0] ? tr(o[0]) : null;
|
|
3279
3274
|
},
|
|
3280
3275
|
async getByUserId(n, r, i) {
|
|
3281
|
-
let o = await e.select().from(
|
|
3282
|
-
return o[0] ?
|
|
3276
|
+
let o = await e.select().from(at).where(t(a(at.tenant_id, n), a(at.connection_id, r), a(at.user_id, i))).limit(1);
|
|
3277
|
+
return o[0] ? tr(o[0]) : null;
|
|
3283
3278
|
},
|
|
3284
3279
|
async remove(n, r, i) {
|
|
3285
|
-
return (await e.select({ user_id:
|
|
3280
|
+
return (await e.select({ user_id: at.user_id }).from(at).where(t(a(at.tenant_id, n), a(at.connection_id, r), a(at.user_id, i))).limit(1)).length === 0 ? !1 : (await e.delete(at).where(t(a(at.tenant_id, n), a(at.connection_id, r), a(at.user_id, i))), !0);
|
|
3286
3281
|
}
|
|
3287
3282
|
};
|
|
3288
3283
|
}
|
|
3289
3284
|
//#endregion
|
|
3290
3285
|
//#region src/adapters/refreshTokens.ts
|
|
3291
|
-
function
|
|
3292
|
-
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 =
|
|
3286
|
+
function rr(e) {
|
|
3287
|
+
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({
|
|
3293
3288
|
created_at_ts: n,
|
|
3294
3289
|
expires_at_ts: r,
|
|
3295
3290
|
idle_expires_at_ts: i,
|
|
@@ -3303,7 +3298,7 @@ function tr(e) {
|
|
|
3303
3298
|
"revoked_at_ts",
|
|
3304
3299
|
"rotated_at_ts"
|
|
3305
3300
|
]);
|
|
3306
|
-
return
|
|
3301
|
+
return D({
|
|
3307
3302
|
...p,
|
|
3308
3303
|
...m,
|
|
3309
3304
|
rotating: !!u,
|
|
@@ -3315,10 +3310,10 @@ function tr(e) {
|
|
|
3315
3310
|
} } : {}
|
|
3316
3311
|
});
|
|
3317
3312
|
}
|
|
3318
|
-
function
|
|
3313
|
+
function ir(e, t) {
|
|
3319
3314
|
return Math.max(e ?? 0, t ?? 0);
|
|
3320
3315
|
}
|
|
3321
|
-
function
|
|
3316
|
+
function ar(e) {
|
|
3322
3317
|
return {
|
|
3323
3318
|
async create(n, r) {
|
|
3324
3319
|
let i = Date.now(), o = {
|
|
@@ -3339,49 +3334,49 @@ function rr(e) {
|
|
|
3339
3334
|
token_hash: r.token_hash ?? null,
|
|
3340
3335
|
family_id: r.family_id ?? null,
|
|
3341
3336
|
rotated_to: r.rotated_to ?? null,
|
|
3342
|
-
rotated_at_ts:
|
|
3337
|
+
rotated_at_ts: E(r.rotated_at),
|
|
3343
3338
|
created_at_ts: i,
|
|
3344
|
-
expires_at_ts:
|
|
3345
|
-
idle_expires_at_ts:
|
|
3346
|
-
last_exchanged_at_ts:
|
|
3347
|
-
}, s = [e.insert(P).values(o)], c =
|
|
3339
|
+
expires_at_ts: E(r.expires_at),
|
|
3340
|
+
idle_expires_at_ts: E(r.idle_expires_at),
|
|
3341
|
+
last_exchanged_at_ts: E(r.last_exchanged_at)
|
|
3342
|
+
}, s = [e.insert(P).values(o)], c = ir(o.expires_at_ts, o.idle_expires_at_ts);
|
|
3348
3343
|
return c > 0 && o.login_id && s.push(e.update(F).set({
|
|
3349
3344
|
expires_at_ts: c,
|
|
3350
3345
|
updated_at_ts: i
|
|
3351
|
-
}).where(t(a(F.tenant_id, n), a(F.id, o.login_id), m(F.expires_at_ts, c)))), await
|
|
3346
|
+
}).where(t(a(F.tenant_id, n), a(F.id, o.login_id), m(F.expires_at_ts, c)))), await vt(e, s), rr({
|
|
3352
3347
|
...o,
|
|
3353
3348
|
tenant_id: n
|
|
3354
3349
|
});
|
|
3355
3350
|
},
|
|
3356
3351
|
async get(n, r) {
|
|
3357
3352
|
let i = await e.select().from(P).where(t(a(P.tenant_id, n), a(P.id, r))).get();
|
|
3358
|
-
return i ?
|
|
3353
|
+
return i ? rr(i) : null;
|
|
3359
3354
|
},
|
|
3360
3355
|
async getByLookup(n, r) {
|
|
3361
3356
|
let i = await e.select().from(P).where(t(a(P.tenant_id, n), a(P.token_lookup, r))).get();
|
|
3362
|
-
return i ?
|
|
3357
|
+
return i ? rr(i) : null;
|
|
3363
3358
|
},
|
|
3364
3359
|
async update(n, r, i, o) {
|
|
3365
3360
|
let s = {};
|
|
3366
|
-
i.device !== void 0 && (s.device = JSON.stringify(i.device)), i.resource_servers !== void 0 && (s.resource_servers = JSON.stringify(i.resource_servers)), i.rotating !== void 0 && (s.rotating = i.rotating), i.token_lookup !== void 0 && (s.token_lookup = i.token_lookup), i.token_hash !== void 0 && (s.token_hash = i.token_hash), i.family_id !== void 0 && (s.family_id = i.family_id), i.rotated_to !== void 0 && (s.rotated_to = i.rotated_to), i.rotated_at !== void 0 && (s.rotated_at_ts =
|
|
3367
|
-
let c = o?.loginSessionBump, l = c ?
|
|
3361
|
+
i.device !== void 0 && (s.device = JSON.stringify(i.device)), i.resource_servers !== void 0 && (s.resource_servers = JSON.stringify(i.resource_servers)), i.rotating !== void 0 && (s.rotating = i.rotating), i.token_lookup !== void 0 && (s.token_lookup = i.token_lookup), i.token_hash !== void 0 && (s.token_hash = i.token_hash), i.family_id !== void 0 && (s.family_id = i.family_id), i.rotated_to !== void 0 && (s.rotated_to = i.rotated_to), i.rotated_at !== void 0 && (s.rotated_at_ts = E(i.rotated_at)), i.expires_at !== void 0 && (s.expires_at_ts = E(i.expires_at)), i.idle_expires_at !== void 0 && (s.idle_expires_at_ts = E(i.idle_expires_at)), i.last_exchanged_at !== void 0 && (s.last_exchanged_at_ts = E(i.last_exchanged_at)), i.revoked_at !== void 0 && (s.revoked_at_ts = E(i.revoked_at));
|
|
3362
|
+
let c = o?.loginSessionBump, l = c ? E(c.expires_at) : null, u = await e.update(P).set(s).where(t(a(P.tenant_id, n), a(P.id, r))).returning();
|
|
3368
3363
|
return c?.login_id && l && l > 0 && await e.update(F).set({
|
|
3369
3364
|
expires_at_ts: l,
|
|
3370
3365
|
updated_at_ts: Date.now()
|
|
3371
3366
|
}).where(t(a(F.tenant_id, n), a(F.id, c.login_id), m(F.expires_at_ts, l))).catch(() => {}), u.length > 0;
|
|
3372
3367
|
},
|
|
3373
3368
|
async list(o, s) {
|
|
3374
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
3369
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? dt(P, f, ["user_id", "login_id"]) : void 0, m = [
|
|
3375
3370
|
a(P.tenant_id, o),
|
|
3376
3371
|
...s?.user_id === void 0 ? [] : [a(P.user_id, s.user_id)],
|
|
3377
3372
|
...p ? [p] : []
|
|
3378
3373
|
], h = m.length === 1 ? m[0] : t(...m);
|
|
3379
|
-
if (
|
|
3374
|
+
if (Ct(s)) {
|
|
3380
3375
|
let n = {
|
|
3381
3376
|
sortColumn: P.created_at_ts,
|
|
3382
3377
|
idColumn: P.id,
|
|
3383
3378
|
sortOrder: "desc"
|
|
3384
|
-
}, r =
|
|
3379
|
+
}, r = Et(s, n), i = wt(s), { rows: a, next: o } = Dt(await e.select().from(P).where(r ? t(h, r) : h).orderBy(...Tt(n)).limit(i + 1), i, "created_at_ts"), c = a.map(rr);
|
|
3385
3380
|
return {
|
|
3386
3381
|
refresh_tokens: c,
|
|
3387
3382
|
start: 0,
|
|
@@ -3395,7 +3390,7 @@ function rr(e) {
|
|
|
3395
3390
|
let e = P[d.sort_by];
|
|
3396
3391
|
e && (g = g.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
3397
3392
|
}
|
|
3398
|
-
let _ = (await g.offset(c * l).limit(l)).map(
|
|
3393
|
+
let _ = (await g.offset(c * l).limit(l)).map(rr);
|
|
3399
3394
|
if (!u) return { refresh_tokens: _ };
|
|
3400
3395
|
let [v] = await e.select({ count: r() }).from(P).where(h);
|
|
3401
3396
|
return {
|
|
@@ -3409,27 +3404,30 @@ function rr(e) {
|
|
|
3409
3404
|
return (await e.delete(P).where(t(a(P.tenant_id, n), a(P.id, r))).returning()).length > 0;
|
|
3410
3405
|
},
|
|
3411
3406
|
async revokeByUser(n, r, i) {
|
|
3412
|
-
return (await e.update(P).set({ revoked_at_ts:
|
|
3407
|
+
return (await e.update(P).set({ revoked_at_ts: E(i) }).where(t(a(P.tenant_id, n), a(P.user_id, r), f(P.revoked_at_ts))).returning()).length;
|
|
3413
3408
|
},
|
|
3414
3409
|
async revokeByLoginSession(n, r, i) {
|
|
3415
|
-
return (await e.update(P).set({ revoked_at_ts:
|
|
3410
|
+
return (await e.update(P).set({ revoked_at_ts: E(i) }).where(t(a(P.tenant_id, n), a(P.login_id, r), f(P.revoked_at_ts))).returning()).length;
|
|
3411
|
+
},
|
|
3412
|
+
async revokeBySession(n, r, i) {
|
|
3413
|
+
return (await e.update(P).set({ revoked_at_ts: E(i) }).where(t(a(P.tenant_id, n), a(P.session_id, r), f(P.revoked_at_ts))).returning()).length;
|
|
3416
3414
|
},
|
|
3417
3415
|
async revokeFamily(n, r, i) {
|
|
3418
|
-
return (await e.update(P).set({ revoked_at_ts:
|
|
3416
|
+
return (await e.update(P).set({ revoked_at_ts: E(i) }).where(t(a(P.tenant_id, n), a(P.family_id, r), f(P.revoked_at_ts))).returning()).length;
|
|
3419
3417
|
}
|
|
3420
3418
|
};
|
|
3421
3419
|
}
|
|
3422
3420
|
//#endregion
|
|
3423
3421
|
//#region src/adapters/resourceServers.ts
|
|
3424
|
-
var
|
|
3425
|
-
function
|
|
3422
|
+
var or = ["name", "identifier"];
|
|
3423
|
+
function sr() {
|
|
3426
3424
|
return `api_${ee("0123456789abcdefghijklmnopqrstuvwxyz", 17)()}`;
|
|
3427
3425
|
}
|
|
3428
|
-
var
|
|
3426
|
+
var cr = [
|
|
3429
3427
|
"skip_consent_for_verifiable_first_party_clients",
|
|
3430
3428
|
"allow_offline_access",
|
|
3431
3429
|
"is_system"
|
|
3432
|
-
],
|
|
3430
|
+
], lr = new Set([
|
|
3433
3431
|
"id",
|
|
3434
3432
|
"tenant_id",
|
|
3435
3433
|
"identifier",
|
|
@@ -3448,17 +3446,17 @@ var or = [
|
|
|
3448
3446
|
"created_at",
|
|
3449
3447
|
"updated_at"
|
|
3450
3448
|
]);
|
|
3451
|
-
function
|
|
3449
|
+
function ur(e) {
|
|
3452
3450
|
let { tenant_id: t, verification_key: n, scopes: r, options: i, metadata: a, ...o } = e, s = { ...o };
|
|
3453
3451
|
s.scopes = Q(r, []), s.options = Q(i, {}), s.metadata = Q(a), n !== void 0 && (s.verificationKey = n);
|
|
3454
|
-
for (let e of
|
|
3455
|
-
return
|
|
3452
|
+
for (let e of cr) o[e] !== void 0 && o[e] !== null && (s[e] = !!o[e]);
|
|
3453
|
+
return D(s);
|
|
3456
3454
|
}
|
|
3457
|
-
function
|
|
3455
|
+
function dr(e) {
|
|
3458
3456
|
return {
|
|
3459
3457
|
async create(t, n) {
|
|
3460
3458
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
3461
|
-
id: n.id ||
|
|
3459
|
+
id: n.id || sr(),
|
|
3462
3460
|
tenant_id: t,
|
|
3463
3461
|
identifier: n.identifier,
|
|
3464
3462
|
name: n.name,
|
|
@@ -3473,39 +3471,39 @@ function lr(e) {
|
|
|
3473
3471
|
created_at: r,
|
|
3474
3472
|
updated_at: r
|
|
3475
3473
|
};
|
|
3476
|
-
for (let e of
|
|
3477
|
-
return i.is_system === void 0 && (i.is_system = 0), await e.insert(
|
|
3474
|
+
for (let e of cr) n[e] !== void 0 && (i[e] = +!!n[e]);
|
|
3475
|
+
return i.is_system === void 0 && (i.is_system = 0), await e.insert(K).values(i), ur({
|
|
3478
3476
|
...i,
|
|
3479
3477
|
tenant_id: t
|
|
3480
3478
|
});
|
|
3481
3479
|
},
|
|
3482
3480
|
async get(n, r) {
|
|
3483
|
-
let i = await e.select().from(
|
|
3484
|
-
return i ?
|
|
3481
|
+
let i = await e.select().from(K).where(t(a(K.tenant_id, n), a(K.id, r))).get();
|
|
3482
|
+
return i ? ur(i) : null;
|
|
3485
3483
|
},
|
|
3486
3484
|
async update(n, r, i) {
|
|
3487
3485
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
3488
|
-
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(${
|
|
3489
|
-
for (let e of
|
|
3490
|
-
return (await e.update(
|
|
3486
|
+
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);
|
|
3487
|
+
for (let e of cr) i[e] !== void 0 && (o[e] = +!!i[e]);
|
|
3488
|
+
return (await e.update(K).set(o).where(t(a(K.tenant_id, n), a(K.id, r))).returning()).length > 0;
|
|
3491
3489
|
},
|
|
3492
3490
|
async list(o, s) {
|
|
3493
|
-
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(
|
|
3491
|
+
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)];
|
|
3494
3492
|
if (f) {
|
|
3495
|
-
let e =
|
|
3493
|
+
let e = we(f, or);
|
|
3496
3494
|
if (e) {
|
|
3497
|
-
let t =
|
|
3495
|
+
let t = dt(K, e, or, ["name", "identifier"]);
|
|
3498
3496
|
t && h.push(t);
|
|
3499
3497
|
}
|
|
3500
3498
|
}
|
|
3501
|
-
let g = e.select().from(
|
|
3502
|
-
if (d?.sort_by &&
|
|
3503
|
-
let e =
|
|
3499
|
+
let g = e.select().from(K).where(t(...h)).$dynamic();
|
|
3500
|
+
if (d?.sort_by && lr.has(d.sort_by)) {
|
|
3501
|
+
let e = K[d.sort_by];
|
|
3504
3502
|
g = g.orderBy(d.sort_order === "desc" ? i(e) : n(e));
|
|
3505
3503
|
}
|
|
3506
|
-
let _ = (await g.offset(p * m).limit(m)).map(
|
|
3504
|
+
let _ = (await g.offset(p * m).limit(m)).map(ur);
|
|
3507
3505
|
if (!u) return { resource_servers: _ };
|
|
3508
|
-
let [v] = await e.select({ count: r() }).from(
|
|
3506
|
+
let [v] = await e.select({ count: r() }).from(K).where(t(...h));
|
|
3509
3507
|
return {
|
|
3510
3508
|
resource_servers: _,
|
|
3511
3509
|
start: p * m,
|
|
@@ -3514,18 +3512,18 @@ function lr(e) {
|
|
|
3514
3512
|
};
|
|
3515
3513
|
},
|
|
3516
3514
|
async remove(n, r) {
|
|
3517
|
-
return (await e.delete(
|
|
3515
|
+
return (await e.delete(K).where(t(a(K.tenant_id, n), a(K.id, r))).returning()).length > 0;
|
|
3518
3516
|
}
|
|
3519
3517
|
};
|
|
3520
3518
|
}
|
|
3521
3519
|
//#endregion
|
|
3522
3520
|
//#region src/adapters/rolePermissions.ts
|
|
3523
|
-
function
|
|
3521
|
+
function fr(e) {
|
|
3524
3522
|
return {
|
|
3525
3523
|
async assign(t, n, r) {
|
|
3526
3524
|
if (r.length === 0) return !0;
|
|
3527
3525
|
let i = (/* @__PURE__ */ new Date()).toISOString();
|
|
3528
|
-
return await e.insert(
|
|
3526
|
+
return await e.insert(We).values(r.map((e) => ({
|
|
3529
3527
|
tenant_id: t,
|
|
3530
3528
|
role_id: n,
|
|
3531
3529
|
resource_server_identifier: e.resource_server_identifier,
|
|
@@ -3535,15 +3533,15 @@ function ur(e) {
|
|
|
3535
3533
|
},
|
|
3536
3534
|
async list(n, r, i) {
|
|
3537
3535
|
let o = await e.select({
|
|
3538
|
-
resource_server_identifier:
|
|
3539
|
-
permission_name:
|
|
3540
|
-
created_at:
|
|
3541
|
-
}).from(
|
|
3536
|
+
resource_server_identifier: We.resource_server_identifier,
|
|
3537
|
+
permission_name: We.permission_name,
|
|
3538
|
+
created_at: We.created_at
|
|
3539
|
+
}).from(We).where(t(a(We.tenant_id, n), a(We.role_id, r))).all(), s = [...new Set(o.map((e) => e.resource_server_identifier))], c = /* @__PURE__ */ new Map();
|
|
3542
3540
|
if (s.length > 0) {
|
|
3543
3541
|
let r = await e.select({
|
|
3544
|
-
identifier:
|
|
3545
|
-
name:
|
|
3546
|
-
}).from(
|
|
3542
|
+
identifier: K.identifier,
|
|
3543
|
+
name: K.name
|
|
3544
|
+
}).from(K).where(t(a(K.tenant_id, n), l(K.identifier, s))).all();
|
|
3547
3545
|
for (let e of r) c.set(e.identifier, e.name);
|
|
3548
3546
|
}
|
|
3549
3547
|
return o.map((e) => ({
|
|
@@ -3553,18 +3551,18 @@ function ur(e) {
|
|
|
3553
3551
|
},
|
|
3554
3552
|
async remove(n, r, i) {
|
|
3555
3553
|
if (i.length === 0) return !0;
|
|
3556
|
-
let o = i.map((e) => t(a(
|
|
3557
|
-
return await e.delete(
|
|
3554
|
+
let o = i.map((e) => t(a(We.resource_server_identifier, e.resource_server_identifier), a(We.permission_name, e.permission_name)));
|
|
3555
|
+
return await e.delete(We).where(t(a(We.tenant_id, n), a(We.role_id, r), v(...o))).returning(), !0;
|
|
3558
3556
|
}
|
|
3559
3557
|
};
|
|
3560
3558
|
}
|
|
3561
3559
|
//#endregion
|
|
3562
3560
|
//#region src/adapters/userPermissions.ts
|
|
3563
|
-
function
|
|
3561
|
+
function pr(e) {
|
|
3564
3562
|
return {
|
|
3565
3563
|
async create(t, n, r, i) {
|
|
3566
3564
|
try {
|
|
3567
|
-
await e.insert(
|
|
3565
|
+
await e.insert(Ge).values({
|
|
3568
3566
|
tenant_id: t,
|
|
3569
3567
|
user_id: n,
|
|
3570
3568
|
resource_server_identifier: r.resource_server_identifier,
|
|
@@ -3579,11 +3577,11 @@ function dr(e) {
|
|
|
3579
3577
|
return !0;
|
|
3580
3578
|
},
|
|
3581
3579
|
async list(n, r, i, o) {
|
|
3582
|
-
let s = [a(
|
|
3583
|
-
o && s.push(a(
|
|
3584
|
-
let c = await e.select().from(
|
|
3580
|
+
let s = [a(Ge.tenant_id, n), a(Ge.user_id, r)];
|
|
3581
|
+
o && s.push(a(Ge.organization_id, o));
|
|
3582
|
+
let c = await e.select().from(Ge).where(t(...s)).all();
|
|
3585
3583
|
return await Promise.all(c.map(async (r) => {
|
|
3586
|
-
let i = await e.select({ name:
|
|
3584
|
+
let i = await e.select({ name: K.name }).from(K).where(t(a(K.tenant_id, n), a(K.identifier, r.resource_server_identifier))).get();
|
|
3587
3585
|
return {
|
|
3588
3586
|
resource_server_identifier: r.resource_server_identifier,
|
|
3589
3587
|
permission_name: r.permission_name,
|
|
@@ -3593,21 +3591,21 @@ function dr(e) {
|
|
|
3593
3591
|
}));
|
|
3594
3592
|
},
|
|
3595
3593
|
async remove(n, r, i, o) {
|
|
3596
|
-
return (await e.delete(
|
|
3594
|
+
return (await e.delete(Ge).where(t(a(Ge.tenant_id, n), a(Ge.user_id, r), a(Ge.resource_server_identifier, i.resource_server_identifier), a(Ge.permission_name, i.permission_name), a(Ge.organization_id, o || ""))).returning()).length > 0;
|
|
3597
3595
|
}
|
|
3598
3596
|
};
|
|
3599
3597
|
}
|
|
3600
3598
|
//#endregion
|
|
3601
3599
|
//#region src/adapters/roles.ts
|
|
3602
|
-
function
|
|
3600
|
+
function mr(e) {
|
|
3603
3601
|
let { tenant_id: t, is_system: n, metadata: r, ...i } = e;
|
|
3604
|
-
return
|
|
3602
|
+
return D({
|
|
3605
3603
|
...i,
|
|
3606
3604
|
is_system: n ? !0 : void 0,
|
|
3607
3605
|
metadata: Q(r)
|
|
3608
3606
|
});
|
|
3609
3607
|
}
|
|
3610
|
-
function
|
|
3608
|
+
function hr(e) {
|
|
3611
3609
|
return {
|
|
3612
3610
|
async create(t, n) {
|
|
3613
3611
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -3620,28 +3618,28 @@ function pr(e) {
|
|
|
3620
3618
|
created_at: r,
|
|
3621
3619
|
updated_at: r
|
|
3622
3620
|
};
|
|
3623
|
-
return await e.insert(
|
|
3621
|
+
return await e.insert(W).values(i), mr({
|
|
3624
3622
|
...i,
|
|
3625
3623
|
tenant_id: t
|
|
3626
3624
|
});
|
|
3627
3625
|
},
|
|
3628
3626
|
async get(n, r) {
|
|
3629
|
-
let i = await e.select().from(
|
|
3630
|
-
return i ?
|
|
3627
|
+
let i = await e.select().from(W).where(t(a(W.tenant_id, n), a(W.id, r))).get();
|
|
3628
|
+
return i ? mr(i) : null;
|
|
3631
3629
|
},
|
|
3632
3630
|
async update(n, r, i) {
|
|
3633
3631
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
3634
|
-
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(
|
|
3632
|
+
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(W).set(o).where(t(a(W.tenant_id, n), a(W.id, r))).returning()).length > 0;
|
|
3635
3633
|
},
|
|
3636
3634
|
async list(o, s) {
|
|
3637
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
3635
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? dt(W, f, ["name"]) : void 0, m = p ? t(a(W.tenant_id, o), p) : a(W.tenant_id, o), h = e.select().from(W).where(m).$dynamic();
|
|
3638
3636
|
if (d?.sort_by) {
|
|
3639
|
-
let e =
|
|
3637
|
+
let e = W[d.sort_by];
|
|
3640
3638
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
3641
3639
|
}
|
|
3642
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
3640
|
+
let g = (await h.offset(c * l).limit(l)).map(mr);
|
|
3643
3641
|
if (!u) return { roles: g };
|
|
3644
|
-
let [_] = await e.select({ count: r() }).from(
|
|
3642
|
+
let [_] = await e.select({ count: r() }).from(W).where(m);
|
|
3645
3643
|
return {
|
|
3646
3644
|
roles: g,
|
|
3647
3645
|
start: c * l,
|
|
@@ -3650,13 +3648,13 @@ function pr(e) {
|
|
|
3650
3648
|
};
|
|
3651
3649
|
},
|
|
3652
3650
|
async remove(n, r) {
|
|
3653
|
-
return (await e.delete(
|
|
3651
|
+
return (await e.delete(W).where(t(a(W.tenant_id, n), a(W.id, r))).returning()).length > 0;
|
|
3654
3652
|
}
|
|
3655
3653
|
};
|
|
3656
3654
|
}
|
|
3657
3655
|
//#endregion
|
|
3658
3656
|
//#region src/adapters/sessions.ts
|
|
3659
|
-
var
|
|
3657
|
+
var gr = ["created_at_ts", "updated_at_ts"], _r = [
|
|
3660
3658
|
"expires_at_ts",
|
|
3661
3659
|
"idle_expires_at_ts",
|
|
3662
3660
|
"authenticated_at_ts",
|
|
@@ -3664,8 +3662,8 @@ var mr = ["created_at_ts", "updated_at_ts"], hr = [
|
|
|
3664
3662
|
"used_at_ts",
|
|
3665
3663
|
"revoked_at_ts"
|
|
3666
3664
|
];
|
|
3667
|
-
function
|
|
3668
|
-
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 =
|
|
3665
|
+
function vr(e) {
|
|
3666
|
+
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({
|
|
3669
3667
|
created_at_ts: n,
|
|
3670
3668
|
updated_at_ts: r,
|
|
3671
3669
|
expires_at_ts: i,
|
|
@@ -3674,18 +3672,18 @@ function gr(e) {
|
|
|
3674
3672
|
last_interaction_at_ts: s,
|
|
3675
3673
|
used_at_ts: c,
|
|
3676
3674
|
revoked_at_ts: l
|
|
3677
|
-
}, [...
|
|
3678
|
-
return
|
|
3675
|
+
}, [...gr], [..._r]);
|
|
3676
|
+
return D({
|
|
3679
3677
|
...f,
|
|
3680
3678
|
...p,
|
|
3681
3679
|
device: Q(u, {}),
|
|
3682
3680
|
clients: Q(d, [])
|
|
3683
3681
|
});
|
|
3684
3682
|
}
|
|
3685
|
-
function
|
|
3683
|
+
function yr(e, t) {
|
|
3686
3684
|
return Math.max(e ?? 0, t ?? 0);
|
|
3687
3685
|
}
|
|
3688
|
-
function
|
|
3686
|
+
function br(e) {
|
|
3689
3687
|
return {
|
|
3690
3688
|
async create(n, r) {
|
|
3691
3689
|
let i = Date.now(), o = {
|
|
@@ -3697,29 +3695,29 @@ function vr(e) {
|
|
|
3697
3695
|
clients: JSON.stringify(r.clients || []),
|
|
3698
3696
|
created_at_ts: i,
|
|
3699
3697
|
updated_at_ts: i,
|
|
3700
|
-
expires_at_ts:
|
|
3701
|
-
idle_expires_at_ts:
|
|
3702
|
-
authenticated_at_ts: r.authenticated_at ?
|
|
3703
|
-
last_interaction_at_ts: r.last_interaction_at ?
|
|
3704
|
-
used_at_ts:
|
|
3705
|
-
revoked_at_ts:
|
|
3706
|
-
}, s = [e.insert(N).values(o)], c =
|
|
3698
|
+
expires_at_ts: E(r.expires_at),
|
|
3699
|
+
idle_expires_at_ts: E(r.idle_expires_at),
|
|
3700
|
+
authenticated_at_ts: r.authenticated_at ? E(r.authenticated_at) : i,
|
|
3701
|
+
last_interaction_at_ts: r.last_interaction_at ? E(r.last_interaction_at) : i,
|
|
3702
|
+
used_at_ts: E(r.used_at),
|
|
3703
|
+
revoked_at_ts: E(r.revoked_at)
|
|
3704
|
+
}, s = [e.insert(N).values(o)], c = yr(o.expires_at_ts, o.idle_expires_at_ts);
|
|
3707
3705
|
return c > 0 && o.login_session_id && s.push(e.update(F).set({
|
|
3708
3706
|
expires_at_ts: c,
|
|
3709
3707
|
updated_at_ts: i
|
|
3710
|
-
}).where(t(a(F.tenant_id, n), a(F.id, o.login_session_id), m(F.expires_at_ts, c)))), await
|
|
3708
|
+
}).where(t(a(F.tenant_id, n), a(F.id, o.login_session_id), m(F.expires_at_ts, c)))), await vt(e, s), vr({
|
|
3711
3709
|
...o,
|
|
3712
3710
|
tenant_id: n
|
|
3713
3711
|
});
|
|
3714
3712
|
},
|
|
3715
3713
|
async get(n, r) {
|
|
3716
3714
|
let i = await e.select().from(N).where(t(a(N.tenant_id, n), a(N.id, r))).get();
|
|
3717
|
-
return i ?
|
|
3715
|
+
return i ? vr(i) : null;
|
|
3718
3716
|
},
|
|
3719
3717
|
async update(n, r, i) {
|
|
3720
3718
|
let o = { updated_at_ts: Date.now() };
|
|
3721
|
-
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 =
|
|
3722
|
-
let s = await e.update(N).set(o).where(t(a(N.tenant_id, n), a(N.id, r))).returning(), c =
|
|
3719
|
+
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));
|
|
3720
|
+
let s = await e.update(N).set(o).where(t(a(N.tenant_id, n), a(N.id, r))).returning(), c = yr(o.expires_at_ts, o.idle_expires_at_ts), l = s[0];
|
|
3723
3721
|
if (c > 0 && l) {
|
|
3724
3722
|
let r = i.login_session_id ?? l.login_session_id;
|
|
3725
3723
|
r && await e.update(F).set({
|
|
@@ -3730,12 +3728,12 @@ function vr(e) {
|
|
|
3730
3728
|
return s.length > 0;
|
|
3731
3729
|
},
|
|
3732
3730
|
async list(o, s) {
|
|
3733
|
-
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ?
|
|
3731
|
+
let { page: c = 0, per_page: l = 50, include_totals: u = !1, sort: d, q: f } = s || {}, p = f ? dt(N, f, ["user_id", "id"]) : void 0, m = p ? t(a(N.tenant_id, o), p) : a(N.tenant_id, o), h = e.select().from(N).where(m).$dynamic();
|
|
3734
3732
|
if (d?.sort_by) {
|
|
3735
3733
|
let e = N[d.sort_by];
|
|
3736
3734
|
e && (h = h.orderBy(d.sort_order === "desc" ? i(e) : n(e)));
|
|
3737
3735
|
}
|
|
3738
|
-
let g = (await h.offset(c * l).limit(l)).map(
|
|
3736
|
+
let g = (await h.offset(c * l).limit(l)).map(vr);
|
|
3739
3737
|
if (!u) return { sessions: g };
|
|
3740
3738
|
let [_] = await e.select({ count: r() }).from(N).where(m);
|
|
3741
3739
|
return {
|
|
@@ -3752,7 +3750,7 @@ function vr(e) {
|
|
|
3752
3750
|
}
|
|
3753
3751
|
//#endregion
|
|
3754
3752
|
//#region src/adapters/tenants.ts
|
|
3755
|
-
var
|
|
3753
|
+
var xr = [
|
|
3756
3754
|
"session_cookie",
|
|
3757
3755
|
"enabled_locales",
|
|
3758
3756
|
"error_page",
|
|
@@ -3768,25 +3766,25 @@ var yr = [
|
|
|
3768
3766
|
"acr_values_supported",
|
|
3769
3767
|
"mtls",
|
|
3770
3768
|
"mfa"
|
|
3771
|
-
],
|
|
3769
|
+
], Sr = [
|
|
3772
3770
|
"allow_organization_name_in_authentication_api",
|
|
3773
3771
|
"customize_mfa_in_postlogin_action",
|
|
3774
3772
|
"pushed_authorization_requests_supported",
|
|
3775
3773
|
"authorization_response_iss_parameter_supported"
|
|
3776
3774
|
];
|
|
3777
|
-
function
|
|
3775
|
+
function Cr(e) {
|
|
3778
3776
|
let t = { ...e };
|
|
3779
|
-
for (let e of
|
|
3780
|
-
for (let e of
|
|
3781
|
-
return
|
|
3777
|
+
for (let e of xr) typeof t[e] == "string" && (t[e] = Q(t[e]));
|
|
3778
|
+
for (let e of Sr) t[e] !== void 0 && t[e] !== null && (t[e] = t[e] === 1);
|
|
3779
|
+
return D(t);
|
|
3782
3780
|
}
|
|
3783
|
-
function
|
|
3781
|
+
function wr(e) {
|
|
3784
3782
|
let t = { ...e };
|
|
3785
|
-
|
|
3786
|
-
for (let n of
|
|
3787
|
-
return
|
|
3783
|
+
le(e, xr, t);
|
|
3784
|
+
for (let n of Sr) e[n] !== void 0 && (t[n] = +!!e[n]);
|
|
3785
|
+
return ce(t);
|
|
3788
3786
|
}
|
|
3789
|
-
function
|
|
3787
|
+
function Tr(e) {
|
|
3790
3788
|
return {
|
|
3791
3789
|
async create(t) {
|
|
3792
3790
|
let n = {
|
|
@@ -3794,28 +3792,28 @@ function Cr(e) {
|
|
|
3794
3792
|
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3795
3793
|
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3796
3794
|
...t
|
|
3797
|
-
}, r =
|
|
3795
|
+
}, r = wr(n);
|
|
3798
3796
|
try {
|
|
3799
|
-
await e.insert(
|
|
3797
|
+
await e.insert(O).values(r);
|
|
3800
3798
|
} catch (e) {
|
|
3801
3799
|
let t = e?.message ?? "";
|
|
3802
|
-
throw t.includes("UNIQUE constraint failed") || t.includes("Duplicate entry") || t.includes("duplicate key") || t.includes("AlreadyExists") || e?.code === "SQLITE_CONSTRAINT" || e?.code === "SQLITE_CONSTRAINT_UNIQUE" || e?.code === "SQLITE_CONSTRAINT_PRIMARYKEY" || e?.code === "ER_DUP_ENTRY" || e?.code === "23505" ? new
|
|
3800
|
+
throw t.includes("UNIQUE constraint failed") || t.includes("Duplicate entry") || t.includes("duplicate key") || t.includes("AlreadyExists") || e?.code === "SQLITE_CONSTRAINT" || e?.code === "SQLITE_CONSTRAINT_UNIQUE" || e?.code === "SQLITE_CONSTRAINT_PRIMARYKEY" || e?.code === "ER_DUP_ENTRY" || e?.code === "23505" ? new Ne(409, { message: `Tenant with ID '${n.id}' already exists` }) : e;
|
|
3803
3801
|
}
|
|
3804
3802
|
return n;
|
|
3805
3803
|
},
|
|
3806
3804
|
async get(t) {
|
|
3807
|
-
let n = await e.select().from(
|
|
3808
|
-
return n ?
|
|
3805
|
+
let n = await e.select().from(O).where(a(O.id, t)).get();
|
|
3806
|
+
return n ? Cr(n) : null;
|
|
3809
3807
|
},
|
|
3810
3808
|
async list(t) {
|
|
3811
|
-
let { page: a = 0, per_page: o = 50, include_totals: s = !1, sort: c, q: l } = t || {}, u = l ?
|
|
3809
|
+
let { page: a = 0, per_page: o = 50, include_totals: s = !1, sort: c, q: l } = t || {}, u = l ? dt(O, l, ["friendly_name"]) : void 0, d = e.select().from(O).$dynamic();
|
|
3812
3810
|
if (u && (d = d.where(u)), c?.sort_by) {
|
|
3813
|
-
let e =
|
|
3811
|
+
let e = O[c.sort_by];
|
|
3814
3812
|
e && (d = d.orderBy(c.sort_order === "desc" ? i(e) : n(e)));
|
|
3815
3813
|
}
|
|
3816
|
-
let f = (await d.offset(a * o).limit(o)).map(
|
|
3814
|
+
let f = (await d.offset(a * o).limit(o)).map(Cr);
|
|
3817
3815
|
if (!s) return { tenants: f };
|
|
3818
|
-
let p = e.select({ count: r() }).from(
|
|
3816
|
+
let p = e.select({ count: r() }).from(O).$dynamic();
|
|
3819
3817
|
u && (p = p.where(u));
|
|
3820
3818
|
let [m] = await p;
|
|
3821
3819
|
return {
|
|
@@ -3826,76 +3824,76 @@ function Cr(e) {
|
|
|
3826
3824
|
};
|
|
3827
3825
|
},
|
|
3828
3826
|
async update(t, n) {
|
|
3829
|
-
let r =
|
|
3827
|
+
let r = wr({
|
|
3830
3828
|
...n,
|
|
3831
3829
|
id: t,
|
|
3832
3830
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
3833
3831
|
});
|
|
3834
|
-
await e.update(
|
|
3832
|
+
await e.update(O).set(r).where(a(O.id, t));
|
|
3835
3833
|
},
|
|
3836
3834
|
async remove(t) {
|
|
3837
|
-
return (await e.delete(
|
|
3835
|
+
return (await e.delete(O).where(a(O.id, t)).returning()).length > 0;
|
|
3838
3836
|
}
|
|
3839
3837
|
};
|
|
3840
3838
|
}
|
|
3841
3839
|
//#endregion
|
|
3842
3840
|
//#region src/adapters/themes.ts
|
|
3843
|
-
var
|
|
3841
|
+
var Er = [
|
|
3844
3842
|
"colors",
|
|
3845
3843
|
"borders",
|
|
3846
3844
|
"fonts",
|
|
3847
3845
|
"page_background",
|
|
3848
3846
|
"widget"
|
|
3849
3847
|
];
|
|
3850
|
-
function
|
|
3851
|
-
let { tenant_id: t, ...n } = e, r =
|
|
3852
|
-
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),
|
|
3848
|
+
function Dr(e) {
|
|
3849
|
+
let { tenant_id: t, ...n } = e, r = ct(n, Er);
|
|
3850
|
+
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);
|
|
3853
3851
|
}
|
|
3854
|
-
function
|
|
3852
|
+
function Or(e) {
|
|
3855
3853
|
return {
|
|
3856
3854
|
async create(t, n, r, i) {
|
|
3857
3855
|
let a = i?.importMetadata, o = (/* @__PURE__ */ new Date()).toISOString(), s = a?.id || r || b(), c = {
|
|
3858
|
-
...
|
|
3856
|
+
...st(n),
|
|
3859
3857
|
tenant_id: t,
|
|
3860
3858
|
themeId: s,
|
|
3861
3859
|
created_at: a?.created_at ?? o,
|
|
3862
3860
|
updated_at: a?.updated_at ?? o
|
|
3863
3861
|
};
|
|
3864
|
-
return await e.insert(
|
|
3862
|
+
return await e.insert(Je).values(c), Dr({
|
|
3865
3863
|
...c,
|
|
3866
3864
|
tenant_id: t
|
|
3867
3865
|
});
|
|
3868
3866
|
},
|
|
3869
3867
|
async get(n, r) {
|
|
3870
|
-
let i = await e.select().from(
|
|
3871
|
-
return i ?
|
|
3868
|
+
let i = await e.select().from(Je).where(t(a(Je.tenant_id, n), a(Je.themeId, r))).get();
|
|
3869
|
+
return i ? Dr(i) : null;
|
|
3872
3870
|
},
|
|
3873
3871
|
async update(n, r, i) {
|
|
3874
|
-
let o =
|
|
3875
|
-
return o.updated_at = (/* @__PURE__ */ new Date()).toISOString(), await e.update(
|
|
3872
|
+
let o = st(i);
|
|
3873
|
+
return o.updated_at = (/* @__PURE__ */ new Date()).toISOString(), await e.update(Je).set(o).where(t(a(Je.tenant_id, n), a(Je.themeId, r))), !0;
|
|
3876
3874
|
},
|
|
3877
3875
|
async remove(n, r) {
|
|
3878
|
-
return (await e.delete(
|
|
3876
|
+
return (await e.delete(Je).where(t(a(Je.tenant_id, n), a(Je.themeId, r))).returning()).length > 0;
|
|
3879
3877
|
}
|
|
3880
3878
|
};
|
|
3881
3879
|
}
|
|
3882
3880
|
//#endregion
|
|
3883
3881
|
//#region src/adapters/universalLoginTemplates.ts
|
|
3884
|
-
function
|
|
3882
|
+
function kr(e) {
|
|
3885
3883
|
return {
|
|
3886
3884
|
async get(t) {
|
|
3887
|
-
let n = await e.select({ body:
|
|
3885
|
+
let n = await e.select({ body: qe.body }).from(qe).where(a(qe.tenant_id, t)).get();
|
|
3888
3886
|
return n ? { body: n.body } : null;
|
|
3889
3887
|
},
|
|
3890
3888
|
async set(t, n) {
|
|
3891
3889
|
let r = Date.now();
|
|
3892
|
-
await e.insert(
|
|
3890
|
+
await e.insert(qe).values({
|
|
3893
3891
|
tenant_id: t,
|
|
3894
3892
|
body: n.body,
|
|
3895
3893
|
created_at_ts: r,
|
|
3896
3894
|
updated_at_ts: r
|
|
3897
3895
|
}).onConflictDoUpdate({
|
|
3898
|
-
target:
|
|
3896
|
+
target: qe.tenant_id,
|
|
3899
3897
|
set: {
|
|
3900
3898
|
body: n.body,
|
|
3901
3899
|
updated_at_ts: r
|
|
@@ -3903,20 +3901,20 @@ function Dr(e) {
|
|
|
3903
3901
|
});
|
|
3904
3902
|
},
|
|
3905
3903
|
async delete(t) {
|
|
3906
|
-
await e.delete(
|
|
3904
|
+
await e.delete(qe).where(a(qe.tenant_id, t));
|
|
3907
3905
|
}
|
|
3908
3906
|
};
|
|
3909
3907
|
}
|
|
3910
3908
|
//#endregion
|
|
3911
3909
|
//#region src/adapters/userActivity.ts
|
|
3912
|
-
function
|
|
3910
|
+
function Ar(e) {
|
|
3913
3911
|
let t = {};
|
|
3914
3912
|
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;
|
|
3915
3913
|
}
|
|
3916
|
-
function
|
|
3914
|
+
function jr(e) {
|
|
3917
3915
|
return {
|
|
3918
3916
|
async get(n, r) {
|
|
3919
|
-
let i = await e.select().from(
|
|
3917
|
+
let i = await e.select().from(Le).where(t(a(Le.tenant_id, n), a(Le.user_id, r))).get();
|
|
3920
3918
|
return i ? {
|
|
3921
3919
|
user_id: i.user_id,
|
|
3922
3920
|
last_login: i.last_login ?? void 0,
|
|
@@ -3927,7 +3925,7 @@ function kr(e) {
|
|
|
3927
3925
|
} : null;
|
|
3928
3926
|
},
|
|
3929
3927
|
async upsert(t, n, r) {
|
|
3930
|
-
let i =
|
|
3928
|
+
let i = Ar(r), a = e.insert(Le).values({
|
|
3931
3929
|
tenant_id: t,
|
|
3932
3930
|
user_id: n,
|
|
3933
3931
|
login_count: 0,
|
|
@@ -3938,7 +3936,7 @@ function kr(e) {
|
|
|
3938
3936
|
return;
|
|
3939
3937
|
}
|
|
3940
3938
|
await a.onConflictDoUpdate({
|
|
3941
|
-
target: [
|
|
3939
|
+
target: [Le.tenant_id, Le.user_id],
|
|
3942
3940
|
set: i
|
|
3943
3941
|
});
|
|
3944
3942
|
}
|
|
@@ -3946,13 +3944,13 @@ function kr(e) {
|
|
|
3946
3944
|
}
|
|
3947
3945
|
//#endregion
|
|
3948
3946
|
//#region src/adapters/outbox.ts
|
|
3949
|
-
function
|
|
3947
|
+
function Mr(e) {
|
|
3950
3948
|
return {
|
|
3951
3949
|
...e,
|
|
3952
3950
|
payload: Q(e.payload, {})
|
|
3953
3951
|
};
|
|
3954
3952
|
}
|
|
3955
|
-
function
|
|
3953
|
+
function Nr(e, t, n, r) {
|
|
3956
3954
|
return e.insert(Y).values({
|
|
3957
3955
|
id: t,
|
|
3958
3956
|
tenant_id: n,
|
|
@@ -3973,18 +3971,18 @@ function jr(e, t, n, r) {
|
|
|
3973
3971
|
claim_expires_at: null
|
|
3974
3972
|
});
|
|
3975
3973
|
}
|
|
3976
|
-
function
|
|
3974
|
+
function Pr(e) {
|
|
3977
3975
|
return {
|
|
3978
3976
|
async create(t, n) {
|
|
3979
3977
|
let r = b();
|
|
3980
|
-
return await
|
|
3978
|
+
return await Nr(e, r, t, n), r;
|
|
3981
3979
|
},
|
|
3982
3980
|
async getByIds(t) {
|
|
3983
|
-
return t.length === 0 ? [] : (await e.select().from(Y).where(l(Y.id, t)).all()).map(
|
|
3981
|
+
return t.length === 0 ? [] : (await e.select().from(Y).where(l(Y.id, t)).all()).map(Mr);
|
|
3984
3982
|
},
|
|
3985
3983
|
async getUnprocessed(n) {
|
|
3986
3984
|
let r = (/* @__PURE__ */ new Date()).toISOString();
|
|
3987
|
-
return (await e.select().from(Y).where(t(f(Y.processed_at), v(f(Y.next_retry_at), h(Y.next_retry_at, r)), v(f(Y.claimed_by), h(Y.claim_expires_at, r)))).orderBy(Y.created_at, Y.id).limit(n).all()).map(
|
|
3985
|
+
return (await e.select().from(Y).where(t(f(Y.processed_at), v(f(Y.next_retry_at), h(Y.next_retry_at, r)), v(f(Y.claimed_by), h(Y.claim_expires_at, r)))).orderBy(Y.created_at, Y.id).limit(n).all()).map(Mr);
|
|
3988
3986
|
},
|
|
3989
3987
|
async claimEvents(n, r, i) {
|
|
3990
3988
|
if (n.length === 0) return [];
|
|
@@ -4054,10 +4052,10 @@ function Mr(e) {
|
|
|
4054
4052
|
}
|
|
4055
4053
|
//#endregion
|
|
4056
4054
|
//#region src/adapters/users.ts
|
|
4057
|
-
function
|
|
4058
|
-
return (n?.outboxEvents ?? []).map((n) =>
|
|
4055
|
+
function Fr(e, t, n) {
|
|
4056
|
+
return (n?.outboxEvents ?? []).map((n) => Nr(e, n.id, t, n));
|
|
4059
4057
|
}
|
|
4060
|
-
var
|
|
4058
|
+
var Ir = [
|
|
4061
4059
|
"user_id",
|
|
4062
4060
|
"email",
|
|
4063
4061
|
"email_verified",
|
|
@@ -4079,23 +4077,23 @@ var Pr = [
|
|
|
4079
4077
|
"login_count",
|
|
4080
4078
|
"created_at",
|
|
4081
4079
|
"updated_at"
|
|
4082
|
-
],
|
|
4080
|
+
], Lr = [
|
|
4083
4081
|
"email",
|
|
4084
4082
|
"name",
|
|
4085
4083
|
"phone_number",
|
|
4086
4084
|
"user_id"
|
|
4087
|
-
],
|
|
4085
|
+
], Rr = new Set([
|
|
4088
4086
|
"last_login",
|
|
4089
4087
|
"last_ip",
|
|
4090
4088
|
"login_count"
|
|
4091
|
-
]),
|
|
4092
|
-
coalesce:
|
|
4089
|
+
]), zr = o(j), Br = o(Le), Vr = Object.fromEntries(Ir.map((e) => [e, e === "login_count" ? {
|
|
4090
|
+
coalesce: Le.login_count,
|
|
4093
4091
|
defaultValue: 0
|
|
4094
|
-
} :
|
|
4095
|
-
function
|
|
4096
|
-
return t(a(
|
|
4092
|
+
} : Rr.has(e) ? Br[e] : zr[e]]));
|
|
4093
|
+
function Hr() {
|
|
4094
|
+
return t(a(Le.tenant_id, j.tenant_id), a(Le.user_id, j.user_id));
|
|
4097
4095
|
}
|
|
4098
|
-
function
|
|
4096
|
+
function Ur(e, t) {
|
|
4099
4097
|
return {
|
|
4100
4098
|
...e,
|
|
4101
4099
|
last_login: t?.last_login,
|
|
@@ -4103,11 +4101,11 @@ function Vr(e, t) {
|
|
|
4103
4101
|
login_count: t?.login_count ?? 0
|
|
4104
4102
|
};
|
|
4105
4103
|
}
|
|
4106
|
-
function
|
|
4104
|
+
function Wr(e, t) {
|
|
4107
4105
|
let n = {
|
|
4108
4106
|
connection: e.connection,
|
|
4109
4107
|
provider: e.provider,
|
|
4110
|
-
user_id:
|
|
4108
|
+
user_id: xe(e.user_id).id,
|
|
4111
4109
|
isSocial: !!e.is_social
|
|
4112
4110
|
};
|
|
4113
4111
|
return t ? n.isPrimary = !0 : n.profileData = {
|
|
@@ -4116,9 +4114,9 @@ function Hr(e, t) {
|
|
|
4116
4114
|
...typeof e.profileData == "string" ? Q(e.profileData, {}) : {}
|
|
4117
4115
|
}, n;
|
|
4118
4116
|
}
|
|
4119
|
-
function
|
|
4120
|
-
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 =
|
|
4121
|
-
return
|
|
4117
|
+
function Gr(e, t = []) {
|
|
4118
|
+
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 = Wr(e, !0), m = t.map((e) => Wr(e, !1));
|
|
4119
|
+
return D({
|
|
4122
4120
|
...f,
|
|
4123
4121
|
email: e.email || "",
|
|
4124
4122
|
email_verified: !!o,
|
|
@@ -4131,7 +4129,7 @@ function Ur(e, t = []) {
|
|
|
4131
4129
|
identities: [p, ...m]
|
|
4132
4130
|
});
|
|
4133
4131
|
}
|
|
4134
|
-
function
|
|
4132
|
+
function Kr(e) {
|
|
4135
4133
|
let o = async (t, n, r) => {
|
|
4136
4134
|
let i = (/* @__PURE__ */ new Date()).toISOString(), a = {
|
|
4137
4135
|
user_id: n.user_id,
|
|
@@ -4169,7 +4167,7 @@ function Wr(e) {
|
|
|
4169
4167
|
}, o = n.password ? b() : void 0, s = n.last_login !== void 0 || n.last_ip !== void 0 || n.login_count !== void 0;
|
|
4170
4168
|
try {
|
|
4171
4169
|
let c = [e.insert(j).values(a)];
|
|
4172
|
-
s && c.push(e.insert(
|
|
4170
|
+
s && c.push(e.insert(Le).values({
|
|
4173
4171
|
tenant_id: t,
|
|
4174
4172
|
user_id: n.user_id,
|
|
4175
4173
|
last_login: n.last_login,
|
|
@@ -4185,12 +4183,12 @@ function Wr(e) {
|
|
|
4185
4183
|
created_at: i,
|
|
4186
4184
|
updated_at: i
|
|
4187
4185
|
}));
|
|
4188
|
-
for (let n of
|
|
4189
|
-
c.length > 1 ? await
|
|
4186
|
+
for (let n of Fr(e, t, r)) c.push(n);
|
|
4187
|
+
c.length > 1 ? await vt(e, c) : await e.insert(j).values(a);
|
|
4190
4188
|
} catch (e) {
|
|
4191
|
-
throw e?.message?.includes("UNIQUE constraint") || e?.message?.includes("AlreadyExists") ? new
|
|
4189
|
+
throw e?.message?.includes("UNIQUE constraint") || e?.message?.includes("AlreadyExists") ? new Ne(409, { message: "User already exists" }) : (console.error("User upsert failed:", e?.code, e?.message), new Ne(500, { message: "Internal server error" }));
|
|
4192
4190
|
}
|
|
4193
|
-
return
|
|
4191
|
+
return Gr({
|
|
4194
4192
|
...a,
|
|
4195
4193
|
last_login: n.last_login,
|
|
4196
4194
|
last_ip: n.last_ip,
|
|
@@ -4201,10 +4199,10 @@ function Wr(e) {
|
|
|
4201
4199
|
create: o,
|
|
4202
4200
|
rawCreate: o,
|
|
4203
4201
|
async get(n, r) {
|
|
4204
|
-
let i = await e.select().from(j).leftJoin(
|
|
4202
|
+
let i = await e.select().from(j).leftJoin(Le, Hr()).where(t(a(j.tenant_id, n), a(j.user_id, r))).get();
|
|
4205
4203
|
if (!i) return null;
|
|
4206
4204
|
let o = await e.select().from(j).where(t(a(j.tenant_id, n), a(j.linked_to, r))).all();
|
|
4207
|
-
return Ur(
|
|
4205
|
+
return Gr(Ur(i.users, i.user_activity), o);
|
|
4208
4206
|
},
|
|
4209
4207
|
async update(n, r, i, o) {
|
|
4210
4208
|
let s = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -4231,8 +4229,8 @@ function Wr(e) {
|
|
|
4231
4229
|
"zoneinfo"
|
|
4232
4230
|
]) i[e] !== void 0 && (s[e] = i[e]);
|
|
4233
4231
|
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));
|
|
4234
|
-
let c = e.update(j).set(s).where(t(a(j.tenant_id, n), a(j.user_id, r))).returning(), l =
|
|
4235
|
-
return u = l.length > 0 ? (await
|
|
4232
|
+
let c = e.update(j).set(s).where(t(a(j.tenant_id, n), a(j.user_id, r))).returning(), l = Fr(e, n, o), u;
|
|
4233
|
+
return u = l.length > 0 ? (await vt(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 jr(e).upsert(n, r, {
|
|
4236
4234
|
last_login: i.last_login,
|
|
4237
4235
|
last_ip: i.last_ip,
|
|
4238
4236
|
login_count: i.login_count
|
|
@@ -4241,24 +4239,24 @@ function Wr(e) {
|
|
|
4241
4239
|
async list(o, s) {
|
|
4242
4240
|
let { page: c = 0, per_page: u = 50, include_totals: d = !1, sort: p, q: m } = s || {}, h = [a(j.tenant_id, o), f(j.linked_to)];
|
|
4243
4241
|
if (m) {
|
|
4244
|
-
let e =
|
|
4242
|
+
let e = we(m, Ir);
|
|
4245
4243
|
if (e) {
|
|
4246
|
-
let t =
|
|
4244
|
+
let t = dt(Vr, e, Lr);
|
|
4247
4245
|
t && h.push(t);
|
|
4248
4246
|
}
|
|
4249
4247
|
}
|
|
4250
4248
|
let g = t(...h), _ = async (n) => {
|
|
4251
4249
|
let r = n.map((e) => e.user_id), i = r.length > 0 ? await e.select().from(j).where(t(a(j.tenant_id, o), l(j.linked_to, r))) : [];
|
|
4252
|
-
return n.map((e) =>
|
|
4250
|
+
return n.map((e) => Gr(e, i.filter((t) => t.linked_to === e.user_id)));
|
|
4253
4251
|
};
|
|
4254
|
-
if (
|
|
4255
|
-
if (p?.sort_by && p.sort_by !== "created_at") throw new
|
|
4252
|
+
if (Ct(s)) {
|
|
4253
|
+
if (p?.sort_by && p.sort_by !== "created_at") throw new Ne(400, { message: `Sorting by ${p.sort_by} is not supported with checkpoint pagination (from/take); only created_at is` });
|
|
4256
4254
|
let n = p?.sort_order === "asc" ? "asc" : "desc", r = {
|
|
4257
4255
|
sortColumn: j.created_at,
|
|
4258
4256
|
idColumn: j.user_id,
|
|
4259
4257
|
sortOrder: n,
|
|
4260
4258
|
sortKey: `created_at:${n}`
|
|
4261
|
-
}, i =
|
|
4259
|
+
}, i = wt(s), a = Et(s, r), { rows: o, next: c } = Dt((await e.select().from(j).leftJoin(Le, Hr()).where(a ? t(g, a) : g).orderBy(...Tt(r)).limit(i + 1)).map((e) => Ur(e.users, e.user_activity)), i, "created_at", "user_id", r.sortKey), l = await _(o);
|
|
4262
4260
|
return {
|
|
4263
4261
|
users: l,
|
|
4264
4262
|
start: 0,
|
|
@@ -4267,15 +4265,15 @@ function Wr(e) {
|
|
|
4267
4265
|
next: c
|
|
4268
4266
|
};
|
|
4269
4267
|
}
|
|
4270
|
-
let v = e.select().from(j).leftJoin(
|
|
4268
|
+
let v = e.select().from(j).leftJoin(Le, Hr()).where(g).$dynamic();
|
|
4271
4269
|
if (p?.sort_by) {
|
|
4272
|
-
let e =
|
|
4270
|
+
let e = Vr[p.sort_by];
|
|
4273
4271
|
if (e) {
|
|
4274
|
-
let t =
|
|
4272
|
+
let t = lt(e) ? ut(e) : e;
|
|
4275
4273
|
v = v.orderBy(p.sort_order === "desc" ? i(t) : n(t));
|
|
4276
4274
|
}
|
|
4277
4275
|
}
|
|
4278
|
-
let [y, ee] = await Promise.all([v.offset(c * u).limit(u), d ? e.select({ count: r() }).from(j).leftJoin(
|
|
4276
|
+
let [y, ee] = await Promise.all([v.offset(c * u).limit(u), d ? e.select({ count: r() }).from(j).leftJoin(Le, Hr()).where(g) : void 0]), b = await _(y.map((e) => Ur(e.users, e.user_activity)));
|
|
4279
4277
|
if (!ee) return { users: b };
|
|
4280
4278
|
let [te] = ee;
|
|
4281
4279
|
return {
|
|
@@ -4287,14 +4285,14 @@ function Wr(e) {
|
|
|
4287
4285
|
},
|
|
4288
4286
|
async remove(n, r, i) {
|
|
4289
4287
|
let o = await e.select({ user_id: j.user_id }).from(j).where(t(a(j.tenant_id, n), v(a(j.user_id, r), a(j.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 = [
|
|
4290
|
-
e.delete(
|
|
4288
|
+
e.delete(q).where(t(a(q.tenant_id, n), l(q.user_id, u))),
|
|
4291
4289
|
e.delete(M).where(t(a(M.tenant_id, n), l(M.user_id, u))),
|
|
4292
|
-
e.delete(
|
|
4290
|
+
e.delete(Le).where(t(a(Le.tenant_id, n), l(Le.user_id, u))),
|
|
4293
4291
|
e.delete(j).where(t(a(j.tenant_id, n), l(j.user_id, c))),
|
|
4294
4292
|
e.delete(j).where(t(a(j.tenant_id, n), a(j.user_id, r))).returning()
|
|
4295
4293
|
], f = d.length - 1;
|
|
4296
|
-
if (s) for (let t of
|
|
4297
|
-
let p = (await
|
|
4294
|
+
if (s) for (let t of Fr(e, n, i)) d.push(t);
|
|
4295
|
+
let p = (await vt(e, d))[f];
|
|
4298
4296
|
return Array.isArray(p) && p.length > 0;
|
|
4299
4297
|
},
|
|
4300
4298
|
async unlink(n, r, i, o) {
|
|
@@ -4305,11 +4303,11 @@ function Wr(e) {
|
|
|
4305
4303
|
}
|
|
4306
4304
|
//#endregion
|
|
4307
4305
|
//#region src/adapters/userRoles.ts
|
|
4308
|
-
function
|
|
4306
|
+
function qr(e) {
|
|
4309
4307
|
return {
|
|
4310
4308
|
async create(t, n, r, i) {
|
|
4311
4309
|
try {
|
|
4312
|
-
await e.insert(
|
|
4310
|
+
await e.insert(G).values({
|
|
4313
4311
|
tenant_id: t,
|
|
4314
4312
|
user_id: n,
|
|
4315
4313
|
role_id: r,
|
|
@@ -4323,14 +4321,14 @@ function Gr(e) {
|
|
|
4323
4321
|
return !0;
|
|
4324
4322
|
},
|
|
4325
4323
|
async list(n, r, i, o) {
|
|
4326
|
-
let s = [a(
|
|
4327
|
-
o !== void 0 && s.push(a(
|
|
4328
|
-
let c = await e.select({ role_id:
|
|
4324
|
+
let s = [a(G.tenant_id, n), a(G.user_id, r)];
|
|
4325
|
+
o !== void 0 && s.push(a(G.organization_id, o));
|
|
4326
|
+
let c = await e.select({ role_id: G.role_id }).from(G).where(t(...s)).all();
|
|
4329
4327
|
return c.length === 0 ? [] : (await Promise.all(c.map(async (r) => {
|
|
4330
|
-
let i = await e.select().from(
|
|
4328
|
+
let i = await e.select().from(W).where(t(a(W.tenant_id, n), a(W.id, r.role_id))).get();
|
|
4331
4329
|
if (!i) return null;
|
|
4332
4330
|
let { tenant_id: o, is_system: s, metadata: c, ...l } = i;
|
|
4333
|
-
return
|
|
4331
|
+
return D({
|
|
4334
4332
|
...l,
|
|
4335
4333
|
is_system: s ? !0 : void 0,
|
|
4336
4334
|
metadata: Q(c)
|
|
@@ -4338,13 +4336,13 @@ function Gr(e) {
|
|
|
4338
4336
|
}))).filter(Boolean);
|
|
4339
4337
|
},
|
|
4340
4338
|
async listUsers(r, i, o) {
|
|
4341
|
-
let s = t(a(
|
|
4342
|
-
if (
|
|
4339
|
+
let s = t(a(G.tenant_id, r), a(G.role_id, i));
|
|
4340
|
+
if (Ct(o)) {
|
|
4343
4341
|
let n = {
|
|
4344
|
-
sortColumn:
|
|
4345
|
-
idColumn:
|
|
4342
|
+
sortColumn: G.user_id,
|
|
4343
|
+
idColumn: G.user_id,
|
|
4346
4344
|
sortOrder: "asc"
|
|
4347
|
-
}, r =
|
|
4345
|
+
}, r = Et(o, n), i = wt(o), { rows: a, next: c } = Dt(await e.selectDistinct({ user_id: G.user_id }).from(G).where(r ? t(s, r) : s).orderBy(...Tt(n)).limit(i + 1).all(), i, "user_id", "user_id");
|
|
4348
4346
|
return {
|
|
4349
4347
|
userIds: a.map((e) => e.user_id),
|
|
4350
4348
|
start: 0,
|
|
@@ -4353,7 +4351,7 @@ function Gr(e) {
|
|
|
4353
4351
|
next: c
|
|
4354
4352
|
};
|
|
4355
4353
|
}
|
|
4356
|
-
let c = o?.page || 0, l = o?.per_page || 50, u = c * l, d = await e.selectDistinct({ user_id:
|
|
4354
|
+
let c = o?.page || 0, l = o?.per_page || 50, u = c * l, d = await e.selectDistinct({ user_id: G.user_id }).from(G).where(s).orderBy(n(G.user_id)).limit(l).offset(u).all(), f = await e.select({ count: y`count(distinct ${G.user_id})` }).from(G).where(s).get();
|
|
4357
4355
|
return {
|
|
4358
4356
|
userIds: d.map((e) => e.user_id),
|
|
4359
4357
|
start: u,
|
|
@@ -4362,13 +4360,13 @@ function Gr(e) {
|
|
|
4362
4360
|
};
|
|
4363
4361
|
},
|
|
4364
4362
|
async remove(n, r, i, o) {
|
|
4365
|
-
return (await e.delete(
|
|
4363
|
+
return (await e.delete(G).where(t(a(G.tenant_id, n), a(G.user_id, r), a(G.role_id, i), a(G.organization_id, o || ""))).returning()).length > 0;
|
|
4366
4364
|
}
|
|
4367
4365
|
};
|
|
4368
4366
|
}
|
|
4369
4367
|
//#endregion
|
|
4370
4368
|
//#region src/adapters/userOrganizations.ts
|
|
4371
|
-
function
|
|
4369
|
+
function Jr(e) {
|
|
4372
4370
|
return {
|
|
4373
4371
|
async create(t, n) {
|
|
4374
4372
|
let r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
@@ -4380,39 +4378,39 @@ function Kr(e) {
|
|
|
4380
4378
|
updated_at: r
|
|
4381
4379
|
};
|
|
4382
4380
|
try {
|
|
4383
|
-
await e.insert(
|
|
4381
|
+
await e.insert(U).values(i);
|
|
4384
4382
|
} catch (e) {
|
|
4385
|
-
throw e?.message?.includes("UNIQUE constraint") || e?.message?.includes("duplicate key") ? new
|
|
4383
|
+
throw e?.message?.includes("UNIQUE constraint") || e?.message?.includes("duplicate key") ? new Ne(409, { message: "User organization already exists" }) : e;
|
|
4386
4384
|
}
|
|
4387
4385
|
let { tenant_id: a, ...o } = i;
|
|
4388
4386
|
return o;
|
|
4389
4387
|
},
|
|
4390
4388
|
async get(n, r) {
|
|
4391
|
-
let i = await e.select().from(
|
|
4389
|
+
let i = await e.select().from(U).where(t(a(U.tenant_id, n), a(U.id, r))).get();
|
|
4392
4390
|
if (!i) return null;
|
|
4393
4391
|
let { tenant_id: o, ...s } = i;
|
|
4394
4392
|
return s;
|
|
4395
4393
|
},
|
|
4396
4394
|
async update(n, r, i) {
|
|
4397
4395
|
let o = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
4398
|
-
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(
|
|
4396
|
+
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(U).set(o).where(t(a(U.tenant_id, n), a(U.id, r))).returning()).length > 0;
|
|
4399
4397
|
},
|
|
4400
4398
|
async list(n, o) {
|
|
4401
|
-
let { include_totals: s = !1, q: c } = o || {}, l = a(
|
|
4399
|
+
let { include_totals: s = !1, q: c } = o || {}, l = a(U.tenant_id, n), u = l;
|
|
4402
4400
|
if (c) {
|
|
4403
|
-
let e =
|
|
4401
|
+
let e = dt(U, c, ["user_id", "organization_id"]);
|
|
4404
4402
|
e && (u = t(l, e));
|
|
4405
4403
|
}
|
|
4406
4404
|
let d = (e) => {
|
|
4407
4405
|
let { tenant_id: t, ...n } = e;
|
|
4408
4406
|
return n;
|
|
4409
4407
|
};
|
|
4410
|
-
if (
|
|
4408
|
+
if (Ct(o)) {
|
|
4411
4409
|
let n = {
|
|
4412
|
-
sortColumn:
|
|
4413
|
-
idColumn:
|
|
4410
|
+
sortColumn: U.created_at,
|
|
4411
|
+
idColumn: U.id,
|
|
4414
4412
|
sortOrder: "desc"
|
|
4415
|
-
}, r =
|
|
4413
|
+
}, r = Et(o, n), i = wt(o), { rows: a, next: s } = Dt((await e.select().from(U).where(r ? t(u, r) : u).orderBy(...Tt(n)).limit(i + 1)).map(d), i, "created_at");
|
|
4416
4414
|
return {
|
|
4417
4415
|
userOrganizations: a,
|
|
4418
4416
|
start: 0,
|
|
@@ -4421,9 +4419,9 @@ function Kr(e) {
|
|
|
4421
4419
|
next: s
|
|
4422
4420
|
};
|
|
4423
4421
|
}
|
|
4424
|
-
let f = o?.page ?? 0, p = o?.per_page ?? 50, m = f * p, h = (await e.select().from(
|
|
4422
|
+
let f = o?.page ?? 0, p = o?.per_page ?? 50, m = f * p, h = (await e.select().from(U).where(u).orderBy(i(U.created_at), i(U.id)).offset(m).limit(p)).map(d);
|
|
4425
4423
|
if (!s) return { userOrganizations: h };
|
|
4426
|
-
let [g] = await e.select({ count: r() }).from(
|
|
4424
|
+
let [g] = await e.select({ count: r() }).from(U).where(u);
|
|
4427
4425
|
return {
|
|
4428
4426
|
userOrganizations: h,
|
|
4429
4427
|
start: m,
|
|
@@ -4432,11 +4430,11 @@ function Kr(e) {
|
|
|
4432
4430
|
};
|
|
4433
4431
|
},
|
|
4434
4432
|
async listUserOrganizations(n, i, o) {
|
|
4435
|
-
let { page: s = 0, per_page: c = 50, include_totals: l = !1 } = o || {}, u = await e.select().from(
|
|
4436
|
-
let i = await e.select().from(
|
|
4433
|
+
let { page: s = 0, per_page: c = 50, include_totals: l = !1 } = o || {}, u = await e.select().from(U).where(t(a(U.tenant_id, n), a(U.user_id, i))).offset(s * c).limit(c).all(), d = (await Promise.all(u.map(async (r) => {
|
|
4434
|
+
let i = await e.select().from(H).where(t(a(H.tenant_id, n), a(H.id, r.organization_id))).get();
|
|
4437
4435
|
if (!i) return null;
|
|
4438
4436
|
let { tenant_id: o, branding: s, metadata: c, enabled_connections: l, token_quota: u, ...d } = i;
|
|
4439
|
-
return
|
|
4437
|
+
return D({
|
|
4440
4438
|
...d,
|
|
4441
4439
|
branding: Q(s, {}),
|
|
4442
4440
|
metadata: Q(c, {}),
|
|
@@ -4445,7 +4443,7 @@ function Kr(e) {
|
|
|
4445
4443
|
});
|
|
4446
4444
|
}))).filter(Boolean);
|
|
4447
4445
|
if (!l) return { organizations: d };
|
|
4448
|
-
let [f] = await e.select({ count: r() }).from(
|
|
4446
|
+
let [f] = await e.select({ count: r() }).from(U).where(t(a(U.tenant_id, n), a(U.user_id, i)));
|
|
4449
4447
|
return {
|
|
4450
4448
|
organizations: d,
|
|
4451
4449
|
start: s * c,
|
|
@@ -4454,25 +4452,25 @@ function Kr(e) {
|
|
|
4454
4452
|
};
|
|
4455
4453
|
},
|
|
4456
4454
|
async remove(n, r) {
|
|
4457
|
-
return (await e.delete(
|
|
4455
|
+
return (await e.delete(U).where(t(a(U.tenant_id, n), a(U.id, r))).returning()).length > 0;
|
|
4458
4456
|
}
|
|
4459
4457
|
};
|
|
4460
4458
|
}
|
|
4461
4459
|
//#endregion
|
|
4462
4460
|
//#region src/adapters/stats.ts
|
|
4463
|
-
var
|
|
4464
|
-
function
|
|
4461
|
+
var Yr = ["s"], Xr = ["pwd_leak"];
|
|
4462
|
+
function Zr(e) {
|
|
4465
4463
|
return /^\d{8}$/.test(e) ? `${e.slice(0, 4)}-${e.slice(4, 6)}-${e.slice(6, 8)}` : e;
|
|
4466
4464
|
}
|
|
4467
|
-
function
|
|
4465
|
+
function Qr(e) {
|
|
4468
4466
|
return {
|
|
4469
4467
|
async getDaily(n, r) {
|
|
4470
|
-
let i = /* @__PURE__ */ new Date(), o = r?.from ?
|
|
4468
|
+
let i = /* @__PURE__ */ new Date(), o = r?.from ? Zr(r.from) : (/* @__PURE__ */ new Date(i.getTime() - 720 * 60 * 60 * 1e3)).toISOString().split("T")[0], s = r?.to ? Zr(r.to) : i.toISOString().split("T")[0];
|
|
4471
4469
|
return (await e.select({
|
|
4472
4470
|
date: y`substr(${J.date}, 1, 10)`.as("date"),
|
|
4473
|
-
logins: y`SUM(CASE WHEN ${J.type} IN (${y.join(
|
|
4471
|
+
logins: y`SUM(CASE WHEN ${J.type} IN (${y.join(Yr.map((e) => y`${e}`), y`, `)}) THEN 1 ELSE 0 END)`.as("logins"),
|
|
4474
4472
|
signups: y`SUM(CASE WHEN ${J.type} = 'ss' THEN 1 ELSE 0 END)`.as("signups"),
|
|
4475
|
-
leaked_passwords: y`SUM(CASE WHEN ${J.type} IN (${y.join(
|
|
4473
|
+
leaked_passwords: y`SUM(CASE WHEN ${J.type} IN (${y.join(Xr.map((e) => y`${e}`), y`, `)}) THEN 1 ELSE 0 END)`.as("leaked_passwords")
|
|
4476
4474
|
}).from(J).where(t(a(J.tenant_id, n), c(J.date, o), h(J.date, `${s}T23:59:59.999Z`))).groupBy(y`substr(${J.date}, 1, 10)`).orderBy(y`substr(${J.date}, 1, 10)`).all()).map((e) => ({
|
|
4477
4475
|
date: e.date,
|
|
4478
4476
|
logins: Number(e.logins) || 0,
|
|
@@ -4483,14 +4481,14 @@ function Xr(e) {
|
|
|
4483
4481
|
}));
|
|
4484
4482
|
},
|
|
4485
4483
|
async getActiveUsers(n) {
|
|
4486
|
-
let r = (/* @__PURE__ */ new Date(Date.now() - 720 * 60 * 60 * 1e3)).toISOString(), [i] = await e.select({ count: y`COUNT(DISTINCT ${J.user_id})`.as("count") }).from(J).where(t(a(J.tenant_id, n), c(J.date, r), y`${J.type} IN (${y.join(
|
|
4484
|
+
let r = (/* @__PURE__ */ new Date(Date.now() - 720 * 60 * 60 * 1e3)).toISOString(), [i] = await e.select({ count: y`COUNT(DISTINCT ${J.user_id})`.as("count") }).from(J).where(t(a(J.tenant_id, n), c(J.date, r), y`${J.type} IN (${y.join(Yr.map((e) => y`${e}`), y`, `)})`));
|
|
4487
4485
|
return Number(i?.count) || 0;
|
|
4488
4486
|
}
|
|
4489
4487
|
};
|
|
4490
4488
|
}
|
|
4491
4489
|
//#endregion
|
|
4492
4490
|
//#region src/adapters/analytics.ts
|
|
4493
|
-
var
|
|
4491
|
+
var $r = {
|
|
4494
4492
|
"active-users": ["s", "seacft"],
|
|
4495
4493
|
logins: [
|
|
4496
4494
|
"s",
|
|
@@ -4520,7 +4518,7 @@ var Zr = {
|
|
|
4520
4518
|
"fvr"
|
|
4521
4519
|
],
|
|
4522
4520
|
"codes-sent": ["cls", "cs"]
|
|
4523
|
-
},
|
|
4521
|
+
}, ei = {
|
|
4524
4522
|
"active-users": {
|
|
4525
4523
|
alias: "active_users",
|
|
4526
4524
|
type: "UInt64",
|
|
@@ -4577,7 +4575,7 @@ var Zr = {
|
|
|
4577
4575
|
agg: "count"
|
|
4578
4576
|
}
|
|
4579
4577
|
};
|
|
4580
|
-
function
|
|
4578
|
+
function ti(e) {
|
|
4581
4579
|
switch (e) {
|
|
4582
4580
|
case "hour": return y`substr(${J.date}, 1, 13)`;
|
|
4583
4581
|
case "month": return y`substr(${J.date}, 1, 7)`;
|
|
@@ -4586,10 +4584,10 @@ function $r(e) {
|
|
|
4586
4584
|
default: throw Error(`Unsupported interval '${e}' for SQL analytics adapter`);
|
|
4587
4585
|
}
|
|
4588
4586
|
}
|
|
4589
|
-
function
|
|
4587
|
+
function ni(e) {
|
|
4590
4588
|
return `"${e.replace(/"/g, "\"\"")}"`;
|
|
4591
4589
|
}
|
|
4592
|
-
function
|
|
4590
|
+
function ri(e) {
|
|
4593
4591
|
switch (e) {
|
|
4594
4592
|
case "connection": return J.connection;
|
|
4595
4593
|
case "client_id": return J.client_id;
|
|
@@ -4598,10 +4596,10 @@ function ti(e) {
|
|
|
4598
4596
|
case "time": throw Error("time dimension handled separately");
|
|
4599
4597
|
}
|
|
4600
4598
|
}
|
|
4601
|
-
function
|
|
4599
|
+
function ii(e) {
|
|
4602
4600
|
return {
|
|
4603
4601
|
async query(n, r, i) {
|
|
4604
|
-
let o = Date.now(), s =
|
|
4602
|
+
let o = Date.now(), s = $r[r], u = ei[r], d = [
|
|
4605
4603
|
a(J.tenant_id, n),
|
|
4606
4604
|
c(J.date, i.from),
|
|
4607
4605
|
m(J.date, i.to),
|
|
@@ -4610,13 +4608,13 @@ function ni(e) {
|
|
|
4610
4608
|
i.filters.connection?.length && d.push(l(J.connection, i.filters.connection)), i.filters.client_id?.length && d.push(l(J.client_id, i.filters.client_id)), i.filters.user_type?.length && d.push(l(J.strategy_type, i.filters.user_type)), i.filters.user_id?.length && d.push(l(J.user_id, i.filters.user_id));
|
|
4611
4609
|
let f = {}, p = [], h = [];
|
|
4612
4610
|
for (let e of i.group_by) if (e === "time") {
|
|
4613
|
-
let e =
|
|
4611
|
+
let e = ti(i.interval);
|
|
4614
4612
|
f.time = e, p.push(e), h.push({
|
|
4615
4613
|
name: "time",
|
|
4616
4614
|
type: i.interval === "hour" ? "DateTime" : "Date"
|
|
4617
4615
|
});
|
|
4618
4616
|
} else {
|
|
4619
|
-
let t =
|
|
4617
|
+
let t = ri(e);
|
|
4620
4618
|
f[e] = t, p.push(t), h.push({
|
|
4621
4619
|
name: e,
|
|
4622
4620
|
type: "String"
|
|
@@ -4632,9 +4630,9 @@ function ni(e) {
|
|
|
4632
4630
|
if (i.order_by) {
|
|
4633
4631
|
let e = i.order_by.startsWith("-"), t = e ? i.order_by.slice(1) : i.order_by;
|
|
4634
4632
|
if (!_.has(t)) throw Error(`Invalid order_by column '${t}' for analytics query`);
|
|
4635
|
-
let n =
|
|
4633
|
+
let n = ni(t);
|
|
4636
4634
|
g = g.orderBy(y.raw(`${n} ${e ? "DESC" : "ASC"}`));
|
|
4637
|
-
} else g = i.group_by[0] === "time" ? g.orderBy(y.raw(`${
|
|
4635
|
+
} else g = i.group_by[0] === "time" ? g.orderBy(y.raw(`${ni("time")} ASC`)) : g.orderBy(y.raw(`${ni(u.alias)} DESC`));
|
|
4638
4636
|
g = g.limit(i.limit).offset(i.offset);
|
|
4639
4637
|
let v = (await g.all()).map((e) => {
|
|
4640
4638
|
let t = {};
|
|
@@ -4653,8 +4651,8 @@ function ni(e) {
|
|
|
4653
4651
|
};
|
|
4654
4652
|
},
|
|
4655
4653
|
async sessionRetention(n, r) {
|
|
4656
|
-
let i = Date.now(), { sinceMs: o } =
|
|
4657
|
-
return
|
|
4654
|
+
let i = Date.now(), { sinceMs: o } = Ee(r.weeks, i), s = y`(${N.created_at_ts} + ${ue}) / ${de}`, l = y`(COALESCE(${N.used_at_ts}, ${N.created_at_ts}) + ${ue}) / ${de}`;
|
|
4655
|
+
return pe((await e.select({
|
|
4658
4656
|
created_week: s,
|
|
4659
4657
|
used_week: l,
|
|
4660
4658
|
count: y`COUNT(*)`
|
|
@@ -4665,11 +4663,11 @@ function ni(e) {
|
|
|
4665
4663
|
})), r.weeks, i);
|
|
4666
4664
|
},
|
|
4667
4665
|
async refreshTokenRetention(n, r) {
|
|
4668
|
-
let i = Date.now(), { sinceMs: o } =
|
|
4666
|
+
let i = Date.now(), { sinceMs: o } = Ee(r.weeks, i), s = r.client_id && r.client_id.length > 0 ? l(P.client_id, r.client_id) : void 0, u = e.select({
|
|
4669
4667
|
min_created: y`MIN(${P.created_at_ts})`.as("min_created"),
|
|
4670
4668
|
max_used: y`MAX(COALESCE(${P.last_exchanged_at_ts}, ${P.created_at_ts}))`.as("max_used")
|
|
4671
|
-
}).from(P).where(t(a(P.tenant_id, n), s)).groupBy(y`COALESCE(${P.family_id}, ${P.id})`).as("families"), d = y`(${u.min_created} + ${
|
|
4672
|
-
return
|
|
4669
|
+
}).from(P).where(t(a(P.tenant_id, n), s)).groupBy(y`COALESCE(${P.family_id}, ${P.id})`).as("families"), d = y`(${u.min_created} + ${ue}) / ${de}`, f = y`(${u.max_used} + ${ue}) / ${de}`;
|
|
4670
|
+
return fe((await e.select({
|
|
4673
4671
|
created_week: d,
|
|
4674
4672
|
used_week: f,
|
|
4675
4673
|
count: y`COUNT(*)`
|
|
@@ -4683,10 +4681,10 @@ function ni(e) {
|
|
|
4683
4681
|
}
|
|
4684
4682
|
//#endregion
|
|
4685
4683
|
//#region src/adapters/cleanup.ts
|
|
4686
|
-
var
|
|
4687
|
-
function
|
|
4684
|
+
var ai = 10080 * 60 * 1e3;
|
|
4685
|
+
function oi(e) {
|
|
4688
4686
|
return async (n) => {
|
|
4689
|
-
let r = Date.now() -
|
|
4687
|
+
let r = Date.now() - ai;
|
|
4690
4688
|
try {
|
|
4691
4689
|
let i = [v(m(P.expires_at_ts, r), m(P.idle_expires_at_ts, r))];
|
|
4692
4690
|
n?.tenant_id && i.push(a(P.tenant_id, n.tenant_id)), await e.delete(P).where(t(...i)), i = [v(m(N.expires_at_ts, r), m(N.idle_expires_at_ts, r))], n?.tenant_id && i.push(a(N.tenant_id, n.tenant_id)), n?.user_id && i.push(a(N.user_id, n.user_id)), await e.delete(N).where(t(...i)), i = [m(F.expires_at_ts, r)], n?.tenant_id && i.push(a(F.tenant_id, n.tenant_id)), await e.delete(F).where(t(...i));
|
|
@@ -4717,7 +4715,7 @@ var $ = w("tenant_operations", {
|
|
|
4717
4715
|
x("tenant_operations_tenant_id_created_at_idx").on(e.tenant_id, e.created_at),
|
|
4718
4716
|
x("tenant_operations_rollout_id_idx").on(e.rollout_id),
|
|
4719
4717
|
x("tenant_operations_status_idx").on(e.status)
|
|
4720
|
-
]),
|
|
4718
|
+
]), si = w("tenant_operation_events", {
|
|
4721
4719
|
id: T("id", { length: 255 }).primaryKey(),
|
|
4722
4720
|
operation_id: T("operation_id", { length: 255 }).notNull(),
|
|
4723
4721
|
step: T("step", { length: 255 }).notNull(),
|
|
@@ -4729,7 +4727,7 @@ var $ = w("tenant_operations", {
|
|
|
4729
4727
|
columns: [e.operation_id],
|
|
4730
4728
|
foreignColumns: [$.id],
|
|
4731
4729
|
name: "tenant_operation_events_operation_id_constraint"
|
|
4732
|
-
}).onDelete("cascade"), x("tenant_operation_events_operation_id_created_at_idx").on(e.operation_id, e.created_at)]),
|
|
4730
|
+
}).onDelete("cascade"), x("tenant_operation_events_operation_id_created_at_idx").on(e.operation_id, e.created_at)]), ci = w("rollouts", {
|
|
4733
4731
|
id: T("id", { length: 255 }).primaryKey(),
|
|
4734
4732
|
kind: T("kind", { length: 32 }).notNull(),
|
|
4735
4733
|
status: T("status", { length: 32 }).notNull(),
|
|
@@ -4745,8 +4743,8 @@ var $ = w("tenant_operations", {
|
|
|
4745
4743
|
});
|
|
4746
4744
|
//#endregion
|
|
4747
4745
|
//#region src/adapters/tenantOperations.ts
|
|
4748
|
-
function
|
|
4749
|
-
return
|
|
4746
|
+
function li(e) {
|
|
4747
|
+
return je.parse({
|
|
4750
4748
|
id: e.id,
|
|
4751
4749
|
tenant_id: e.tenant_id,
|
|
4752
4750
|
rollout_id: e.rollout_id,
|
|
@@ -4764,10 +4762,10 @@ function si(e) {
|
|
|
4764
4762
|
finished_at: e.finished_at
|
|
4765
4763
|
});
|
|
4766
4764
|
}
|
|
4767
|
-
function
|
|
4765
|
+
function ui(e) {
|
|
4768
4766
|
return {
|
|
4769
4767
|
async create(t) {
|
|
4770
|
-
let n =
|
|
4768
|
+
let n = Ae.parse(t), r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
4771
4769
|
id: `op_${b()}`,
|
|
4772
4770
|
tenant_id: n.tenant_id,
|
|
4773
4771
|
rollout_id: n.rollout_id ?? null,
|
|
@@ -4791,7 +4789,7 @@ function ci(e) {
|
|
|
4791
4789
|
},
|
|
4792
4790
|
async get(t) {
|
|
4793
4791
|
let n = await e.select().from($).where(a($.id, t)).limit(1);
|
|
4794
|
-
return n[0] ?
|
|
4792
|
+
return n[0] ? li(n[0]) : null;
|
|
4795
4793
|
},
|
|
4796
4794
|
async list(n = {}) {
|
|
4797
4795
|
let r = n.page ?? 0, o = n.per_page ?? 50, s = [];
|
|
@@ -4802,7 +4800,7 @@ function ci(e) {
|
|
|
4802
4800
|
n.engine !== void 0 && s.push(a($.engine, n.engine)), n.updated_before !== void 0 && s.push(m($.updated_at, n.updated_before));
|
|
4803
4801
|
let c = await e.select().from($).where(s.length ? t(...s) : void 0).orderBy(i($.created_at), i($.id)).offset(r * o).limit(o);
|
|
4804
4802
|
return {
|
|
4805
|
-
operations: c.map(
|
|
4803
|
+
operations: c.map(li),
|
|
4806
4804
|
start: r * o,
|
|
4807
4805
|
limit: o,
|
|
4808
4806
|
length: c.length
|
|
@@ -4820,27 +4818,27 @@ function ci(e) {
|
|
|
4820
4818
|
}
|
|
4821
4819
|
//#endregion
|
|
4822
4820
|
//#region src/helpers/monotonic-id.ts
|
|
4823
|
-
var
|
|
4824
|
-
function
|
|
4821
|
+
var di = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", fi = 32, pi = 10, mi = 4, hi = 10;
|
|
4822
|
+
function gi(e, t) {
|
|
4825
4823
|
let n = "";
|
|
4826
|
-
for (let r = t; r > 0; r--) n =
|
|
4824
|
+
for (let r = t; r > 0; r--) n = di.charAt(e % fi) + n, e = Math.floor(e / fi);
|
|
4827
4825
|
return n;
|
|
4828
4826
|
}
|
|
4829
|
-
function
|
|
4830
|
-
let e = new Uint8Array(
|
|
4827
|
+
function _i() {
|
|
4828
|
+
let e = new Uint8Array(hi);
|
|
4831
4829
|
crypto.getRandomValues(e);
|
|
4832
4830
|
let t = "";
|
|
4833
|
-
for (let n = 0; n <
|
|
4831
|
+
for (let n = 0; n < hi; n++) t += di.charAt(e[n] % fi);
|
|
4834
4832
|
return t;
|
|
4835
4833
|
}
|
|
4836
|
-
var
|
|
4837
|
-
function
|
|
4834
|
+
var vi = 0, yi = 0;
|
|
4835
|
+
function bi() {
|
|
4838
4836
|
let e = Date.now();
|
|
4839
|
-
return e ===
|
|
4837
|
+
return e === vi ? yi++ : (vi = e, yi = 0), gi(e, pi) + gi(yi, mi) + _i();
|
|
4840
4838
|
}
|
|
4841
4839
|
//#endregion
|
|
4842
4840
|
//#region src/adapters/tenantOperationEvents.ts
|
|
4843
|
-
function
|
|
4841
|
+
function xi(e) {
|
|
4844
4842
|
if (!e) return null;
|
|
4845
4843
|
try {
|
|
4846
4844
|
let t = JSON.parse(e);
|
|
@@ -4848,22 +4846,22 @@ function yi(e) {
|
|
|
4848
4846
|
} catch {}
|
|
4849
4847
|
return null;
|
|
4850
4848
|
}
|
|
4851
|
-
function
|
|
4852
|
-
return
|
|
4849
|
+
function Si(e) {
|
|
4850
|
+
return ke.parse({
|
|
4853
4851
|
id: e.id,
|
|
4854
4852
|
operation_id: e.operation_id,
|
|
4855
4853
|
step: e.step,
|
|
4856
4854
|
outcome: e.outcome,
|
|
4857
|
-
detail:
|
|
4855
|
+
detail: xi(e.detail),
|
|
4858
4856
|
attempt: e.attempt,
|
|
4859
4857
|
created_at: e.created_at
|
|
4860
4858
|
});
|
|
4861
4859
|
}
|
|
4862
|
-
function
|
|
4860
|
+
function Ci(e) {
|
|
4863
4861
|
return {
|
|
4864
4862
|
async create(t) {
|
|
4865
|
-
let n =
|
|
4866
|
-
id: `evt_${
|
|
4863
|
+
let n = Oe.parse(t), r = {
|
|
4864
|
+
id: `evt_${bi()}`,
|
|
4867
4865
|
operation_id: n.operation_id,
|
|
4868
4866
|
step: n.step,
|
|
4869
4867
|
outcome: n.outcome,
|
|
@@ -4871,7 +4869,7 @@ function xi(e) {
|
|
|
4871
4869
|
attempt: n.attempt,
|
|
4872
4870
|
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
4873
4871
|
};
|
|
4874
|
-
return await e.insert(
|
|
4872
|
+
return await e.insert(si).values(r), ke.parse({
|
|
4875
4873
|
id: r.id,
|
|
4876
4874
|
operation_id: r.operation_id,
|
|
4877
4875
|
step: r.step,
|
|
@@ -4882,9 +4880,9 @@ function xi(e) {
|
|
|
4882
4880
|
});
|
|
4883
4881
|
},
|
|
4884
4882
|
async listByOperation(t, r = {}) {
|
|
4885
|
-
let i = r.page ?? 0, o = r.per_page ?? 100, s = await e.select().from(
|
|
4883
|
+
let i = r.page ?? 0, o = r.per_page ?? 100, s = await e.select().from(si).where(a(si.operation_id, t)).orderBy(n(si.created_at), n(si.id)).offset(i * o).limit(o);
|
|
4886
4884
|
return {
|
|
4887
|
-
events: s.map(
|
|
4885
|
+
events: s.map(Si),
|
|
4888
4886
|
start: i * o,
|
|
4889
4887
|
limit: o,
|
|
4890
4888
|
length: s.length
|
|
@@ -4894,7 +4892,7 @@ function xi(e) {
|
|
|
4894
4892
|
}
|
|
4895
4893
|
//#endregion
|
|
4896
4894
|
//#region src/adapters/rollouts.ts
|
|
4897
|
-
function
|
|
4895
|
+
function wi(e) {
|
|
4898
4896
|
if (!e) return null;
|
|
4899
4897
|
try {
|
|
4900
4898
|
return JSON.parse(e);
|
|
@@ -4902,26 +4900,26 @@ function Si(e) {
|
|
|
4902
4900
|
return null;
|
|
4903
4901
|
}
|
|
4904
4902
|
}
|
|
4905
|
-
function
|
|
4906
|
-
return
|
|
4903
|
+
function Ti(e) {
|
|
4904
|
+
return Ce.parse({
|
|
4907
4905
|
id: e.id,
|
|
4908
4906
|
kind: e.kind,
|
|
4909
4907
|
status: e.status,
|
|
4910
4908
|
target_worker_version: e.target_worker_version,
|
|
4911
4909
|
target_database_version: e.target_database_version,
|
|
4912
4910
|
wave_size: e.wave_size,
|
|
4913
|
-
canary_tenant_ids:
|
|
4914
|
-
filter:
|
|
4911
|
+
canary_tenant_ids: wi(e.canary_tenant_ids),
|
|
4912
|
+
filter: wi(e.filter),
|
|
4915
4913
|
initiated_by: e.initiated_by,
|
|
4916
4914
|
created_at: e.created_at,
|
|
4917
4915
|
updated_at: e.updated_at,
|
|
4918
4916
|
finished_at: e.finished_at
|
|
4919
4917
|
});
|
|
4920
4918
|
}
|
|
4921
|
-
function
|
|
4919
|
+
function Ei(e) {
|
|
4922
4920
|
return {
|
|
4923
4921
|
async create(t) {
|
|
4924
|
-
let n =
|
|
4922
|
+
let n = Se.parse(t), r = (/* @__PURE__ */ new Date()).toISOString(), i = {
|
|
4925
4923
|
id: `rol_${b()}`,
|
|
4926
4924
|
kind: n.kind,
|
|
4927
4925
|
status: "pending",
|
|
@@ -4935,93 +4933,93 @@ function wi(e) {
|
|
|
4935
4933
|
updated_at: r,
|
|
4936
4934
|
finished_at: null
|
|
4937
4935
|
};
|
|
4938
|
-
await e.insert(
|
|
4936
|
+
await e.insert(ci).values(i);
|
|
4939
4937
|
let a = await this.get(i.id);
|
|
4940
4938
|
if (!a) throw Error(`Failed to create rollout ${i.id}`);
|
|
4941
4939
|
return a;
|
|
4942
4940
|
},
|
|
4943
4941
|
async get(t) {
|
|
4944
|
-
let n = await e.select().from(
|
|
4945
|
-
return n[0] ?
|
|
4942
|
+
let n = await e.select().from(ci).where(a(ci.id, t)).limit(1);
|
|
4943
|
+
return n[0] ? Ti(n[0]) : null;
|
|
4946
4944
|
},
|
|
4947
4945
|
async list(t = {}) {
|
|
4948
|
-
let n = t.page ?? 0, r = t.per_page ?? 50, a = await e.select().from(
|
|
4946
|
+
let n = t.page ?? 0, r = t.per_page ?? 50, a = await e.select().from(ci).orderBy(i(ci.created_at), i(ci.id)).offset(n * r).limit(r);
|
|
4949
4947
|
return {
|
|
4950
|
-
rollouts: a.map(
|
|
4948
|
+
rollouts: a.map(Ti),
|
|
4951
4949
|
start: n * r,
|
|
4952
4950
|
limit: r,
|
|
4953
4951
|
length: a.length
|
|
4954
4952
|
};
|
|
4955
4953
|
},
|
|
4956
4954
|
async update(t, n) {
|
|
4957
|
-
if ((await e.select({ id:
|
|
4955
|
+
if ((await e.select({ id: ci.id }).from(ci).where(a(ci.id, t)).limit(1)).length === 0) return !1;
|
|
4958
4956
|
let r = { updated_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
4959
|
-
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(
|
|
4957
|
+
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(ci).set(r).where(a(ci.id, t)), !0;
|
|
4960
4958
|
},
|
|
4961
4959
|
async remove(t) {
|
|
4962
|
-
return (await e.select({ id:
|
|
4960
|
+
return (await e.select({ id: ci.id }).from(ci).where(a(ci.id, t)).limit(1)).length === 0 ? !1 : (await e.delete(ci).where(a(ci.id, t)), !0);
|
|
4963
4961
|
}
|
|
4964
4962
|
};
|
|
4965
4963
|
}
|
|
4966
4964
|
//#endregion
|
|
4967
4965
|
//#region src/adapters/index.ts
|
|
4968
|
-
function
|
|
4966
|
+
function Di(e, t = { useTransactions: !0 }) {
|
|
4969
4967
|
let n = {
|
|
4970
|
-
actions:
|
|
4971
|
-
actionExecutions:
|
|
4972
|
-
actionVersions:
|
|
4973
|
-
branding:
|
|
4974
|
-
clients:
|
|
4975
|
-
clientConnections:
|
|
4976
|
-
clientGrants:
|
|
4977
|
-
clientRegistrationTokens:
|
|
4978
|
-
codes:
|
|
4979
|
-
connections:
|
|
4980
|
-
customDomains:
|
|
4981
|
-
customText:
|
|
4982
|
-
emailProviders:
|
|
4983
|
-
emailTemplates:
|
|
4984
|
-
flows:
|
|
4985
|
-
forms:
|
|
4986
|
-
grants:
|
|
4987
|
-
hookCode:
|
|
4988
|
-
hooks:
|
|
4989
|
-
invites:
|
|
4990
|
-
keys:
|
|
4991
|
-
loginSessions:
|
|
4992
|
-
logs:
|
|
4993
|
-
authenticationMethods:
|
|
4994
|
-
organizations:
|
|
4995
|
-
passwords:
|
|
4996
|
-
promptSettings:
|
|
4997
|
-
proxyRoutes:
|
|
4998
|
-
scimConfigurations:
|
|
4999
|
-
scimTokens:
|
|
5000
|
-
scimExternalIds:
|
|
5001
|
-
refreshTokens:
|
|
5002
|
-
resourceServers:
|
|
5003
|
-
rolePermissions:
|
|
5004
|
-
userPermissions:
|
|
5005
|
-
roles:
|
|
5006
|
-
sessions:
|
|
5007
|
-
sessionCleanup:
|
|
5008
|
-
tenants:
|
|
4968
|
+
actions: mt(e),
|
|
4969
|
+
actionExecutions: gt(e),
|
|
4970
|
+
actionVersions: bt(e),
|
|
4971
|
+
branding: St(e),
|
|
4972
|
+
clients: Nt(e),
|
|
4973
|
+
clientConnections: Ft(e),
|
|
4974
|
+
clientGrants: Lt(e),
|
|
4975
|
+
clientRegistrationTokens: Ht(e),
|
|
4976
|
+
codes: Kt(e),
|
|
4977
|
+
connections: Yt(e),
|
|
4978
|
+
customDomains: Zt(e),
|
|
4979
|
+
customText: Qt(e),
|
|
4980
|
+
emailProviders: $t(e),
|
|
4981
|
+
emailTemplates: tn(e),
|
|
4982
|
+
flows: rn(e),
|
|
4983
|
+
forms: sn(e),
|
|
4984
|
+
grants: dn(e),
|
|
4985
|
+
hookCode: hn(e),
|
|
4986
|
+
hooks: yn(e),
|
|
4987
|
+
invites: Cn(e),
|
|
4988
|
+
keys: Tn(e),
|
|
4989
|
+
loginSessions: An(e),
|
|
4990
|
+
logs: Mn(e),
|
|
4991
|
+
authenticationMethods: Ln(e),
|
|
4992
|
+
organizations: Vn(e),
|
|
4993
|
+
passwords: Un(e),
|
|
4994
|
+
promptSettings: Wn(e),
|
|
4995
|
+
proxyRoutes: Jn(e),
|
|
4996
|
+
scimConfigurations: Qn(e),
|
|
4997
|
+
scimTokens: er(e),
|
|
4998
|
+
scimExternalIds: nr(e),
|
|
4999
|
+
refreshTokens: ar(e),
|
|
5000
|
+
resourceServers: dr(e),
|
|
5001
|
+
rolePermissions: fr(e),
|
|
5002
|
+
userPermissions: pr(e),
|
|
5003
|
+
roles: hr(e),
|
|
5004
|
+
sessions: br(e),
|
|
5005
|
+
sessionCleanup: oi(e),
|
|
5006
|
+
tenants: Tr(e),
|
|
5009
5007
|
...t.controlPlane ? {
|
|
5010
|
-
tenantOperations:
|
|
5011
|
-
tenantOperationEvents:
|
|
5012
|
-
rollouts:
|
|
5008
|
+
tenantOperations: ui(e),
|
|
5009
|
+
tenantOperationEvents: Ci(e),
|
|
5010
|
+
rollouts: Ei(e)
|
|
5013
5011
|
} : {},
|
|
5014
|
-
themes:
|
|
5015
|
-
universalLoginTemplates:
|
|
5016
|
-
users:
|
|
5017
|
-
userActivity:
|
|
5018
|
-
userRoles:
|
|
5019
|
-
userOrganizations:
|
|
5020
|
-
stats:
|
|
5021
|
-
analytics:
|
|
5022
|
-
outbox:
|
|
5012
|
+
themes: Or(e),
|
|
5013
|
+
universalLoginTemplates: kr(e),
|
|
5014
|
+
users: Kr(e),
|
|
5015
|
+
userActivity: jr(e),
|
|
5016
|
+
userRoles: qr(e),
|
|
5017
|
+
userOrganizations: Jr(e),
|
|
5018
|
+
stats: Qr(e),
|
|
5019
|
+
analytics: ii(e),
|
|
5020
|
+
outbox: Pr(e),
|
|
5023
5021
|
async transaction(r) {
|
|
5024
|
-
if (t.useTransactions === !1 ||
|
|
5022
|
+
if (t.useTransactions === !1 || _t(e)) return r(n);
|
|
5025
5023
|
await e.run(y`BEGIN`);
|
|
5026
5024
|
try {
|
|
5027
5025
|
let t = await r(n);
|
|
@@ -5035,22 +5033,22 @@ function Ti(e, t = { useTransactions: !0 }) {
|
|
|
5035
5033
|
}
|
|
5036
5034
|
//#endregion
|
|
5037
5035
|
//#region src/adapters/resolveHost.ts
|
|
5038
|
-
function
|
|
5036
|
+
function Oi(e) {
|
|
5039
5037
|
if (!e) return { path: "/*" };
|
|
5040
5038
|
try {
|
|
5041
|
-
let t = JSON.parse(e), n =
|
|
5039
|
+
let t = JSON.parse(e), n = be.safeParse(t);
|
|
5042
5040
|
if (n.success) return n.data;
|
|
5043
5041
|
} catch {}
|
|
5044
5042
|
return { path: "/*" };
|
|
5045
5043
|
}
|
|
5046
|
-
function
|
|
5044
|
+
function ki(e) {
|
|
5047
5045
|
if (!e) return [];
|
|
5048
5046
|
try {
|
|
5049
5047
|
let t = JSON.parse(e);
|
|
5050
5048
|
if (!Array.isArray(t)) return [];
|
|
5051
5049
|
let n = [];
|
|
5052
5050
|
for (let e of t) {
|
|
5053
|
-
let t =
|
|
5051
|
+
let t = _e.safeParse(e);
|
|
5054
5052
|
t.success && n.push(t.data);
|
|
5055
5053
|
}
|
|
5056
5054
|
return n;
|
|
@@ -5058,20 +5056,20 @@ function Di(e) {
|
|
|
5058
5056
|
return [];
|
|
5059
5057
|
}
|
|
5060
5058
|
}
|
|
5061
|
-
async function
|
|
5059
|
+
async function Ai(e, r) {
|
|
5062
5060
|
let i = r.toLowerCase(), o = (await e.select({
|
|
5063
|
-
custom_domain_id:
|
|
5064
|
-
tenant_id:
|
|
5065
|
-
domain:
|
|
5066
|
-
}).from(
|
|
5061
|
+
custom_domain_id: V.custom_domain_id,
|
|
5062
|
+
tenant_id: V.tenant_id,
|
|
5063
|
+
domain: V.domain
|
|
5064
|
+
}).from(V).where(a(V.domain, i)).limit(1))[0];
|
|
5067
5065
|
if (!o) return null;
|
|
5068
5066
|
let s = (await e.select().from(X).where(t(a(X.tenant_id, o.tenant_id), a(X.custom_domain_id, o.custom_domain_id))).orderBy(n(X.priority), n(X.created_at))).map((e) => ({
|
|
5069
5067
|
id: e.id,
|
|
5070
5068
|
tenant_id: e.tenant_id,
|
|
5071
5069
|
custom_domain_id: e.custom_domain_id,
|
|
5072
5070
|
priority: e.priority,
|
|
5073
|
-
match:
|
|
5074
|
-
handlers:
|
|
5071
|
+
match: Oi(e.match),
|
|
5072
|
+
handlers: ki(e.handlers),
|
|
5075
5073
|
created_at: e.created_at,
|
|
5076
5074
|
updated_at: e.updated_at
|
|
5077
5075
|
}));
|
|
@@ -5084,11 +5082,11 @@ async function Oi(e, r) {
|
|
|
5084
5082
|
}
|
|
5085
5083
|
//#endregion
|
|
5086
5084
|
//#region src/adapters/proxyData.ts
|
|
5087
|
-
function
|
|
5085
|
+
function ji(e) {
|
|
5088
5086
|
return {
|
|
5089
|
-
proxyRoutes:
|
|
5090
|
-
resolveHost: (t) =>
|
|
5087
|
+
proxyRoutes: Jn(e),
|
|
5088
|
+
resolveHost: (t) => Ai(e, t)
|
|
5091
5089
|
};
|
|
5092
5090
|
}
|
|
5093
5091
|
//#endregion
|
|
5094
|
-
export {
|
|
5092
|
+
export { ji as createProxyDataAdapter, Jn as createProxyRoutesAdapter, Di as default, ot as sqlite };
|