@sqrzro/server 4.0.0-alpha.5 → 4.0.0-alpha.51
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/chunk-2ZLU4AUD.js +2 -0
- package/dist/chunk-2ZLU4AUD.js.map +1 -0
- package/dist/chunk-6GDOIHTS.js +2 -0
- package/dist/chunk-6GDOIHTS.js.map +1 -0
- package/dist/chunk-BA3BC4CD.js +2 -0
- package/dist/chunk-BA3BC4CD.js.map +1 -0
- package/dist/chunk-UCMLSO7F.js +3 -0
- package/dist/chunk-UCMLSO7F.js.map +1 -0
- package/dist/csv/index.d.ts +7 -0
- package/dist/csv/index.js +2 -0
- package/dist/csv/index.js.map +1 -0
- package/dist/database/index.d.ts +86 -37
- package/dist/database/index.js +1 -1
- package/dist/database/index.js.map +1 -1
- package/dist/forms/index.d.ts +41 -10
- package/dist/forms/index.js +1 -1
- package/dist/forms/index.js.map +1 -1
- package/dist/{interfaces-BheedaEI.d.ts → interfaces-DTUqy5Oj.d.ts} +4 -3
- package/dist/interfaces-cnzok1wV.d.ts +13 -0
- package/dist/json/index.d.ts +3 -1
- package/dist/json/index.js +1 -1
- package/dist/json/index.js.map +1 -1
- package/dist/mail/index.d.ts +25 -0
- package/dist/mail/index.js +3 -0
- package/dist/mail/index.js.map +1 -0
- package/dist/proxy/index.d.ts +10 -0
- package/dist/proxy/index.js +2 -0
- package/dist/proxy/index.js.map +1 -0
- package/dist/storage/index.d.ts +32 -0
- package/dist/storage/index.js +2 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/utility/index.d.ts +8 -5
- package/dist/utility/index.js +1 -1
- package/package.json +27 -34
- package/dist/auth/index.d.ts +0 -49
- package/dist/auth/index.js +0 -2
- package/dist/auth/index.js.map +0 -1
- package/dist/auth/utility/schema.d.ts +0 -348
- package/dist/auth/utility/schema.js +0 -2
- package/dist/auth/utility/schema.js.map +0 -1
- package/dist/chunk-37TYQL5Y.js +0 -2
- package/dist/chunk-37TYQL5Y.js.map +0 -1
- package/dist/chunk-AGS5PPG2.js +0 -2
- package/dist/chunk-AGS5PPG2.js.map +0 -1
- package/dist/chunk-JI2U2EMD.js +0 -2
- package/dist/chunk-JI2U2EMD.js.map +0 -1
- package/dist/chunk-QE347FVL.js +0 -2
- package/dist/chunk-QE347FVL.js.map +0 -1
- package/dist/chunk-XSJ4OEIH.js +0 -2
- package/dist/chunk-XSJ4OEIH.js.map +0 -1
- package/dist/cli/index.d.ts +0 -1
- package/dist/cli/index.js +0 -4
- package/dist/cli/index.js.map +0 -1
- package/dist/cli/static/drizzle.config.js +0 -19
|
@@ -1,348 +0,0 @@
|
|
|
1
|
-
import * as drizzle_orm_pg_core from 'drizzle-orm/pg-core';
|
|
2
|
-
|
|
3
|
-
declare const DEFAULT_ROLE = 10;
|
|
4
|
-
declare const mfaType: drizzle_orm_pg_core.PgEnum<["TOTP", "HARDWARE"]>;
|
|
5
|
-
declare const resetType: drizzle_orm_pg_core.PgEnum<["INVITE", "MFA", "PASSWORD"]>;
|
|
6
|
-
type MFAType = (typeof mfaType.enumValues)[number];
|
|
7
|
-
type ResetType = (typeof resetType.enumValues)[number];
|
|
8
|
-
declare const authSchema: drizzle_orm_pg_core.PgSchema<"auth">;
|
|
9
|
-
declare const authUserTable: drizzle_orm_pg_core.PgTableWithColumns<{
|
|
10
|
-
name: "user_credentials";
|
|
11
|
-
schema: "auth";
|
|
12
|
-
columns: {
|
|
13
|
-
id: drizzle_orm_pg_core.PgColumn<{
|
|
14
|
-
name: "id";
|
|
15
|
-
tableName: "user_credentials";
|
|
16
|
-
dataType: "string";
|
|
17
|
-
columnType: "PgText";
|
|
18
|
-
data: string;
|
|
19
|
-
driverParam: string;
|
|
20
|
-
notNull: true;
|
|
21
|
-
hasDefault: false;
|
|
22
|
-
isPrimaryKey: true;
|
|
23
|
-
isAutoincrement: false;
|
|
24
|
-
hasRuntimeDefault: false;
|
|
25
|
-
enumValues: [string, ...string[]];
|
|
26
|
-
baseColumn: never;
|
|
27
|
-
identity: undefined;
|
|
28
|
-
generated: undefined;
|
|
29
|
-
}, {}, {}>;
|
|
30
|
-
email: drizzle_orm_pg_core.PgColumn<{
|
|
31
|
-
name: "email";
|
|
32
|
-
tableName: "user_credentials";
|
|
33
|
-
dataType: "string";
|
|
34
|
-
columnType: "PgText";
|
|
35
|
-
data: string;
|
|
36
|
-
driverParam: string;
|
|
37
|
-
notNull: true;
|
|
38
|
-
hasDefault: false;
|
|
39
|
-
isPrimaryKey: false;
|
|
40
|
-
isAutoincrement: false;
|
|
41
|
-
hasRuntimeDefault: false;
|
|
42
|
-
enumValues: [string, ...string[]];
|
|
43
|
-
baseColumn: never;
|
|
44
|
-
identity: undefined;
|
|
45
|
-
generated: undefined;
|
|
46
|
-
}, {}, {}>;
|
|
47
|
-
password: drizzle_orm_pg_core.PgColumn<{
|
|
48
|
-
name: "password";
|
|
49
|
-
tableName: "user_credentials";
|
|
50
|
-
dataType: "string";
|
|
51
|
-
columnType: "PgText";
|
|
52
|
-
data: string;
|
|
53
|
-
driverParam: string;
|
|
54
|
-
notNull: false;
|
|
55
|
-
hasDefault: false;
|
|
56
|
-
isPrimaryKey: false;
|
|
57
|
-
isAutoincrement: false;
|
|
58
|
-
hasRuntimeDefault: false;
|
|
59
|
-
enumValues: [string, ...string[]];
|
|
60
|
-
baseColumn: never;
|
|
61
|
-
identity: undefined;
|
|
62
|
-
generated: undefined;
|
|
63
|
-
}, {}, {}>;
|
|
64
|
-
role: drizzle_orm_pg_core.PgColumn<{
|
|
65
|
-
name: "role";
|
|
66
|
-
tableName: "user_credentials";
|
|
67
|
-
dataType: "number";
|
|
68
|
-
columnType: "PgInteger";
|
|
69
|
-
data: number;
|
|
70
|
-
driverParam: string | number;
|
|
71
|
-
notNull: true;
|
|
72
|
-
hasDefault: true;
|
|
73
|
-
isPrimaryKey: false;
|
|
74
|
-
isAutoincrement: false;
|
|
75
|
-
hasRuntimeDefault: false;
|
|
76
|
-
enumValues: undefined;
|
|
77
|
-
baseColumn: never;
|
|
78
|
-
identity: undefined;
|
|
79
|
-
generated: undefined;
|
|
80
|
-
}, {}, {}>;
|
|
81
|
-
deletedAt: drizzle_orm_pg_core.PgColumn<{
|
|
82
|
-
name: "deletedAt";
|
|
83
|
-
tableName: "user_credentials";
|
|
84
|
-
dataType: "date";
|
|
85
|
-
columnType: "PgTimestamp";
|
|
86
|
-
data: Date;
|
|
87
|
-
driverParam: string;
|
|
88
|
-
notNull: false;
|
|
89
|
-
hasDefault: false;
|
|
90
|
-
isPrimaryKey: false;
|
|
91
|
-
isAutoincrement: false;
|
|
92
|
-
hasRuntimeDefault: false;
|
|
93
|
-
enumValues: undefined;
|
|
94
|
-
baseColumn: never;
|
|
95
|
-
identity: undefined;
|
|
96
|
-
generated: undefined;
|
|
97
|
-
}, {}, {}>;
|
|
98
|
-
};
|
|
99
|
-
dialect: "pg";
|
|
100
|
-
}>;
|
|
101
|
-
type AuthUserTable = typeof authUserTable.$inferSelect;
|
|
102
|
-
declare const authResetTable: drizzle_orm_pg_core.PgTableWithColumns<{
|
|
103
|
-
name: "resets";
|
|
104
|
-
schema: "auth";
|
|
105
|
-
columns: {
|
|
106
|
-
id: drizzle_orm_pg_core.PgColumn<{
|
|
107
|
-
name: "id";
|
|
108
|
-
tableName: "resets";
|
|
109
|
-
dataType: "string";
|
|
110
|
-
columnType: "PgText";
|
|
111
|
-
data: string;
|
|
112
|
-
driverParam: string;
|
|
113
|
-
notNull: true;
|
|
114
|
-
hasDefault: false;
|
|
115
|
-
isPrimaryKey: true;
|
|
116
|
-
isAutoincrement: false;
|
|
117
|
-
hasRuntimeDefault: false;
|
|
118
|
-
enumValues: [string, ...string[]];
|
|
119
|
-
baseColumn: never;
|
|
120
|
-
identity: undefined;
|
|
121
|
-
generated: undefined;
|
|
122
|
-
}, {}, {}>;
|
|
123
|
-
userID: drizzle_orm_pg_core.PgColumn<{
|
|
124
|
-
name: "userID";
|
|
125
|
-
tableName: "resets";
|
|
126
|
-
dataType: "string";
|
|
127
|
-
columnType: "PgText";
|
|
128
|
-
data: string;
|
|
129
|
-
driverParam: string;
|
|
130
|
-
notNull: true;
|
|
131
|
-
hasDefault: false;
|
|
132
|
-
isPrimaryKey: false;
|
|
133
|
-
isAutoincrement: false;
|
|
134
|
-
hasRuntimeDefault: false;
|
|
135
|
-
enumValues: [string, ...string[]];
|
|
136
|
-
baseColumn: never;
|
|
137
|
-
identity: undefined;
|
|
138
|
-
generated: undefined;
|
|
139
|
-
}, {}, {}>;
|
|
140
|
-
type: drizzle_orm_pg_core.PgColumn<{
|
|
141
|
-
name: "type";
|
|
142
|
-
tableName: "resets";
|
|
143
|
-
dataType: "string";
|
|
144
|
-
columnType: "PgEnumColumn";
|
|
145
|
-
data: "INVITE" | "MFA" | "PASSWORD";
|
|
146
|
-
driverParam: string;
|
|
147
|
-
notNull: true;
|
|
148
|
-
hasDefault: false;
|
|
149
|
-
isPrimaryKey: false;
|
|
150
|
-
isAutoincrement: false;
|
|
151
|
-
hasRuntimeDefault: false;
|
|
152
|
-
enumValues: ["INVITE", "MFA", "PASSWORD"];
|
|
153
|
-
baseColumn: never;
|
|
154
|
-
identity: undefined;
|
|
155
|
-
generated: undefined;
|
|
156
|
-
}, {}, {}>;
|
|
157
|
-
createdAt: drizzle_orm_pg_core.PgColumn<{
|
|
158
|
-
name: "createdAt";
|
|
159
|
-
tableName: "resets";
|
|
160
|
-
dataType: "date";
|
|
161
|
-
columnType: "PgTimestamp";
|
|
162
|
-
data: Date;
|
|
163
|
-
driverParam: string;
|
|
164
|
-
notNull: true;
|
|
165
|
-
hasDefault: true;
|
|
166
|
-
isPrimaryKey: false;
|
|
167
|
-
isAutoincrement: false;
|
|
168
|
-
hasRuntimeDefault: false;
|
|
169
|
-
enumValues: undefined;
|
|
170
|
-
baseColumn: never;
|
|
171
|
-
identity: undefined;
|
|
172
|
-
generated: undefined;
|
|
173
|
-
}, {}, {}>;
|
|
174
|
-
};
|
|
175
|
-
dialect: "pg";
|
|
176
|
-
}>;
|
|
177
|
-
type AuthResetTable = typeof authResetTable.$inferSelect;
|
|
178
|
-
declare const authMFATable: drizzle_orm_pg_core.PgTableWithColumns<{
|
|
179
|
-
name: "mfas";
|
|
180
|
-
schema: "auth";
|
|
181
|
-
columns: {
|
|
182
|
-
id: drizzle_orm_pg_core.PgColumn<{
|
|
183
|
-
name: "id";
|
|
184
|
-
tableName: "mfas";
|
|
185
|
-
dataType: "string";
|
|
186
|
-
columnType: "PgText";
|
|
187
|
-
data: string;
|
|
188
|
-
driverParam: string;
|
|
189
|
-
notNull: true;
|
|
190
|
-
hasDefault: false;
|
|
191
|
-
isPrimaryKey: true;
|
|
192
|
-
isAutoincrement: false;
|
|
193
|
-
hasRuntimeDefault: false;
|
|
194
|
-
enumValues: [string, ...string[]];
|
|
195
|
-
baseColumn: never;
|
|
196
|
-
identity: undefined;
|
|
197
|
-
generated: undefined;
|
|
198
|
-
}, {}, {}>;
|
|
199
|
-
name: drizzle_orm_pg_core.PgColumn<{
|
|
200
|
-
name: "name";
|
|
201
|
-
tableName: "mfas";
|
|
202
|
-
dataType: "string";
|
|
203
|
-
columnType: "PgText";
|
|
204
|
-
data: string;
|
|
205
|
-
driverParam: string;
|
|
206
|
-
notNull: true;
|
|
207
|
-
hasDefault: false;
|
|
208
|
-
isPrimaryKey: false;
|
|
209
|
-
isAutoincrement: false;
|
|
210
|
-
hasRuntimeDefault: false;
|
|
211
|
-
enumValues: [string, ...string[]];
|
|
212
|
-
baseColumn: never;
|
|
213
|
-
identity: undefined;
|
|
214
|
-
generated: undefined;
|
|
215
|
-
}, {}, {}>;
|
|
216
|
-
userID: drizzle_orm_pg_core.PgColumn<{
|
|
217
|
-
name: "userID";
|
|
218
|
-
tableName: "mfas";
|
|
219
|
-
dataType: "string";
|
|
220
|
-
columnType: "PgText";
|
|
221
|
-
data: string;
|
|
222
|
-
driverParam: string;
|
|
223
|
-
notNull: true;
|
|
224
|
-
hasDefault: false;
|
|
225
|
-
isPrimaryKey: false;
|
|
226
|
-
isAutoincrement: false;
|
|
227
|
-
hasRuntimeDefault: false;
|
|
228
|
-
enumValues: [string, ...string[]];
|
|
229
|
-
baseColumn: never;
|
|
230
|
-
identity: undefined;
|
|
231
|
-
generated: undefined;
|
|
232
|
-
}, {}, {}>;
|
|
233
|
-
type: drizzle_orm_pg_core.PgColumn<{
|
|
234
|
-
name: "type";
|
|
235
|
-
tableName: "mfas";
|
|
236
|
-
dataType: "string";
|
|
237
|
-
columnType: "PgEnumColumn";
|
|
238
|
-
data: "TOTP" | "HARDWARE";
|
|
239
|
-
driverParam: string;
|
|
240
|
-
notNull: true;
|
|
241
|
-
hasDefault: true;
|
|
242
|
-
isPrimaryKey: false;
|
|
243
|
-
isAutoincrement: false;
|
|
244
|
-
hasRuntimeDefault: false;
|
|
245
|
-
enumValues: ["TOTP", "HARDWARE"];
|
|
246
|
-
baseColumn: never;
|
|
247
|
-
identity: undefined;
|
|
248
|
-
generated: undefined;
|
|
249
|
-
}, {}, {}>;
|
|
250
|
-
secret: drizzle_orm_pg_core.PgColumn<{
|
|
251
|
-
name: "secret";
|
|
252
|
-
tableName: "mfas";
|
|
253
|
-
dataType: "string";
|
|
254
|
-
columnType: "PgText";
|
|
255
|
-
data: string;
|
|
256
|
-
driverParam: string;
|
|
257
|
-
notNull: true;
|
|
258
|
-
hasDefault: false;
|
|
259
|
-
isPrimaryKey: false;
|
|
260
|
-
isAutoincrement: false;
|
|
261
|
-
hasRuntimeDefault: false;
|
|
262
|
-
enumValues: [string, ...string[]];
|
|
263
|
-
baseColumn: never;
|
|
264
|
-
identity: undefined;
|
|
265
|
-
generated: undefined;
|
|
266
|
-
}, {}, {}>;
|
|
267
|
-
verifiedAt: drizzle_orm_pg_core.PgColumn<{
|
|
268
|
-
name: "verifiedAt";
|
|
269
|
-
tableName: "mfas";
|
|
270
|
-
dataType: "date";
|
|
271
|
-
columnType: "PgTimestamp";
|
|
272
|
-
data: Date;
|
|
273
|
-
driverParam: string;
|
|
274
|
-
notNull: false;
|
|
275
|
-
hasDefault: false;
|
|
276
|
-
isPrimaryKey: false;
|
|
277
|
-
isAutoincrement: false;
|
|
278
|
-
hasRuntimeDefault: false;
|
|
279
|
-
enumValues: undefined;
|
|
280
|
-
baseColumn: never;
|
|
281
|
-
identity: undefined;
|
|
282
|
-
generated: undefined;
|
|
283
|
-
}, {}, {}>;
|
|
284
|
-
};
|
|
285
|
-
dialect: "pg";
|
|
286
|
-
}>;
|
|
287
|
-
type AuthMFATable = typeof authMFATable.$inferSelect;
|
|
288
|
-
declare const authClientTable: drizzle_orm_pg_core.PgTableWithColumns<{
|
|
289
|
-
name: "client_credentials";
|
|
290
|
-
schema: "auth";
|
|
291
|
-
columns: {
|
|
292
|
-
id: drizzle_orm_pg_core.PgColumn<{
|
|
293
|
-
name: "id";
|
|
294
|
-
tableName: "client_credentials";
|
|
295
|
-
dataType: "string";
|
|
296
|
-
columnType: "PgText";
|
|
297
|
-
data: string;
|
|
298
|
-
driverParam: string;
|
|
299
|
-
notNull: true;
|
|
300
|
-
hasDefault: false;
|
|
301
|
-
isPrimaryKey: true;
|
|
302
|
-
isAutoincrement: false;
|
|
303
|
-
hasRuntimeDefault: false;
|
|
304
|
-
enumValues: [string, ...string[]];
|
|
305
|
-
baseColumn: never;
|
|
306
|
-
identity: undefined;
|
|
307
|
-
generated: undefined;
|
|
308
|
-
}, {}, {}>;
|
|
309
|
-
alias: drizzle_orm_pg_core.PgColumn<{
|
|
310
|
-
name: "alias";
|
|
311
|
-
tableName: "client_credentials";
|
|
312
|
-
dataType: "string";
|
|
313
|
-
columnType: "PgText";
|
|
314
|
-
data: string;
|
|
315
|
-
driverParam: string;
|
|
316
|
-
notNull: true;
|
|
317
|
-
hasDefault: false;
|
|
318
|
-
isPrimaryKey: false;
|
|
319
|
-
isAutoincrement: false;
|
|
320
|
-
hasRuntimeDefault: false;
|
|
321
|
-
enumValues: [string, ...string[]];
|
|
322
|
-
baseColumn: never;
|
|
323
|
-
identity: undefined;
|
|
324
|
-
generated: undefined;
|
|
325
|
-
}, {}, {}>;
|
|
326
|
-
secret: drizzle_orm_pg_core.PgColumn<{
|
|
327
|
-
name: "secret";
|
|
328
|
-
tableName: "client_credentials";
|
|
329
|
-
dataType: "string";
|
|
330
|
-
columnType: "PgText";
|
|
331
|
-
data: string;
|
|
332
|
-
driverParam: string;
|
|
333
|
-
notNull: true;
|
|
334
|
-
hasDefault: false;
|
|
335
|
-
isPrimaryKey: false;
|
|
336
|
-
isAutoincrement: false;
|
|
337
|
-
hasRuntimeDefault: false;
|
|
338
|
-
enumValues: [string, ...string[]];
|
|
339
|
-
baseColumn: never;
|
|
340
|
-
identity: undefined;
|
|
341
|
-
generated: undefined;
|
|
342
|
-
}, {}, {}>;
|
|
343
|
-
};
|
|
344
|
-
dialect: "pg";
|
|
345
|
-
}>;
|
|
346
|
-
type AuthClientTable = typeof authClientTable.$inferSelect;
|
|
347
|
-
|
|
348
|
-
export { type AuthClientTable, type AuthMFATable, type AuthResetTable, type AuthUserTable, DEFAULT_ROLE, type MFAType, type ResetType, authClientTable, authMFATable, authResetTable, authSchema, authUserTable, mfaType, resetType };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"schema.js"}
|
package/dist/chunk-37TYQL5Y.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-37TYQL5Y.js"}
|
package/dist/chunk-AGS5PPG2.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/forms/utility/ValidationError.ts"],"names":["ValidationError","messages","ValidationError_default"],"mappings":"AAMA,IAAMA,CAAAA,CAAN,cAA8B,KAAM,CACzB,SAEA,WAAA,CAAYC,CAAAA,CAAkC,CACjD,KAAA,CAAM,IAAA,CAAK,SAAA,CAAUA,CAAQ,CAAC,CAAA,CAE9B,KAAK,QAAA,CAAWA,CAAAA,CAChB,KAAK,IAAA,CAAO,kBAChB,CACJ,CAAA,CAEOC,CAAAA,CAAQF","file":"chunk-AGS5PPG2.js","sourcesContent":["/**\n * Custom error class to represent validation errors in form processing.\n * \n * It extends the built-in Error class and includes a messages property\n * that holds a record of validation error messages.\n */\nclass ValidationError extends Error {\n public messages: Record<string, string>;\n\n public constructor(messages: Record<string, string>) {\n super(JSON.stringify(messages));\n\n this.messages = messages;\n this.name = 'ValidationError';\n }\n}\n\nexport default ValidationError;\n"]}
|
package/dist/chunk-JI2U2EMD.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import {sql}from'drizzle-orm';import {pgEnum,pgSchema,timestamp,integer,text}from'drizzle-orm/pg-core';var u=10,n=pgEnum("mfaType",["TOTP","HARDWARE"]),i=pgEnum("resetType",["INVITE","MFA","PASSWORD"]),t=pgSchema("auth"),a=t.table("user_credentials",{id:text("id").primaryKey(),email:text("email").notNull(),password:text("password"),role:integer("role").notNull().default(u),deletedAt:timestamp("deletedAt")}),T=t.table("resets",{id:text("id").primaryKey(),userID:text("userID").notNull().references(()=>a.id,{onDelete:"cascade"}),type:i("type").notNull(),createdAt:timestamp("createdAt").notNull().default(sql`CURRENT_TIMESTAMP`)}),d=t.table("mfas",{id:text("id").primaryKey(),name:text("name").notNull(),userID:text("userID").notNull().references(()=>a.id,{onDelete:"cascade"}),type:n("type").notNull().default("TOTP"),secret:text("secret").notNull(),verifiedAt:timestamp("verifiedAt")}),m=t.table("client_credentials",{id:text("id").primaryKey(),alias:text("alias").notNull().unique(),secret:text("secret").notNull().unique()});export{u as a,n as b,i as c,t as d,a as e,T as f,d as g,m as h};//# sourceMappingURL=chunk-JI2U2EMD.js.map
|
|
2
|
-
//# sourceMappingURL=chunk-JI2U2EMD.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/auth/utility/schema.ts"],"names":["DEFAULT_ROLE","mfaType","pgEnum","resetType","authSchema","pgSchema","authUserTable","text","integer","timestamp","authResetTable","sql","authMFATable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,EAAA,CAAI,CAAE,QAAA,CAAU,SAAU,CAAC,EAC/D,IAAA,CAAML,CAAAA,CAAQ,MAAM,CAAA,CAAE,OAAA,GAAU,OAAA,CAAQ,MAAM,EAC9C,MAAA,CAAQM,IAAAA,CAAK,QAAQ,CAAA,CAAE,OAAA,GACvB,UAAA,CAAYE,SAAAA,CAAU,YAAY,CACtC,CAAC,CAAA,CAIYI,CAAAA,CAAkBT,CAAAA,CAAW,KAAA,CAAM,qBAAsB,CAClE,EAAA,CAAIG,KAAK,IAAI,CAAA,CAAE,YAAW,CAC1B,KAAA,CAAOA,IAAAA,CAAK,OAAO,CAAA,CAAE,OAAA,GAAU,MAAA,EAAO,CACtC,OAAQA,IAAAA,CAAK,QAAQ,EAAE,OAAA,EAAQ,CAAE,MAAA,EACrC,CAAC","file":"chunk-JI2U2EMD.js","sourcesContent":["/* istanbul ignore file */\n\nimport { sql } from 'drizzle-orm';\nimport { integer, pgEnum, pgSchema, text, timestamp } from 'drizzle-orm/pg-core';\n\nexport const DEFAULT_ROLE = 10;\n\nexport const mfaType = pgEnum('mfaType', ['TOTP', 'HARDWARE']);\nexport const resetType = pgEnum('resetType', ['INVITE', 'MFA', 'PASSWORD']);\n\nexport type MFAType = (typeof mfaType.enumValues)[number];\nexport type ResetType = (typeof resetType.enumValues)[number];\n\nexport const authSchema = pgSchema('auth');\n\nexport const authUserTable = authSchema.table('user_credentials', {\n id: text('id').primaryKey(),\n email: text('email').notNull(),\n password: text('password'),\n role: integer('role').notNull().default(DEFAULT_ROLE),\n deletedAt: timestamp('deletedAt'),\n});\n\nexport type AuthUserTable = typeof authUserTable.$inferSelect;\n\nexport const authResetTable = authSchema.table('resets', {\n id: text('id').primaryKey(),\n userID: text('userID')\n .notNull()\n .references(() => authUserTable.id, { onDelete: 'cascade' }),\n type: resetType('type').notNull(),\n createdAt: timestamp('createdAt')\n .notNull()\n .default(sql`CURRENT_TIMESTAMP`),\n});\n\nexport type AuthResetTable = typeof authResetTable.$inferSelect;\n\nexport const authMFATable = authSchema.table('mfas', {\n id: text('id').primaryKey(),\n name: text('name').notNull(),\n userID: text('userID')\n .notNull()\n .references(() => authUserTable.id, { onDelete: 'cascade' }),\n type: mfaType('type').notNull().default('TOTP'),\n secret: text('secret').notNull(),\n verifiedAt: timestamp('verifiedAt'),\n});\n\nexport type AuthMFATable = typeof authMFATable.$inferSelect;\n\nexport const authClientTable = authSchema.table('client_credentials', {\n id: text('id').primaryKey(),\n alias: text('alias').notNull().unique(),\n secret: text('secret').notNull().unique(),\n});\n\nexport type AuthClientTable = typeof authClientTable.$inferSelect;\n"]}
|
package/dist/chunk-QE347FVL.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import {e}from'./chunk-JI2U2EMD.js';import I from'bcryptjs';import {cache}from'react';import {createClient}from'redis';import {cookies}from'next/headers';import {and,eq,isNull}from'drizzle-orm';import {drizzle}from'drizzle-orm/node-postgres';var i=null;async function S(){if(!process.env.REDIS_URL)throw new Error("REDIS_URL is not defined. Access to the cache is not possible.");return i||(i=createClient({url:process.env.REDIS_URL}),await i.connect(),i)}var o=S;var w={async getItem(e,r){let t=await(await o()).get(`[${e}]:${r}`);if(!t)return null;try{return JSON.parse(t)}catch{return null}},async getArray(e,r){return await(await o()).sMembers(`[${e}]:${r}`)},async addToArray(e,r,t){await(await o()).sAdd(`[${e}]:${r}`,t);},async removeFromArray(e,r,t){await(await o()).sRem(`[${e}]:${r}`,t);},async setItem(e,r,t){await(await o()).set(`[${e}]:${r}`,JSON.stringify(t));},async removeItem(e,r){await(await o()).del(`[${e}]:${r}`);}},l=w;function _(){let e=process.env.AUTH_ROLE;if(!e)throw new Error("AUTH_ROLE environment variable is not set.");let r=parseInt(e,10);if(isNaN(r))throw new Error("AUTH_ROLE environment variable is not a valid number.");return r}var u=_;var c=process.env.AUTH_COOKIE_NAME??"session",K=process.env.AUTH_INVITE_EXPIRY_HOURS?Number(process.env.AUTH_INVITE_EXPIRY_HOURS):24,V=process.env.AUTH_RESET_EXPIRY_HOURS?Number(process.env.AUTH_RESET_EXPIRY_HOURS):2;async function h(e){let r=(e??await cookies()).get(c)?.value;if(!r)return null;let t=r.split(".");if(t.length!==2)return null;let[s,a]=t;return {id:s,secret:a}}var m=h;function v(e){let{expires:r,secret:t,userID:s}=e;if(typeof r!="string"||typeof t!="string"||typeof s!="string")return null;let a=new Date(r);return isNaN(a.getTime())?null:{expires:a,secret:t,userID:s}}var f=v;async function x(e){let r=await m(e);if(!r)return null;let t=u(),s=await l.getItem("session",r.id);return s?.role!==t||typeof s?.secret!="string"||!await I.compare(r.secret,s.secret)?null:f(s)}var N=cache(x),p=N;var y=drizzle(process.env.DATABASE_URL??"");async function b(e$1,r){let t=u();return (await y.select().from(e).where(and(eq(e[e$1],r),eq(e.role,t),isNull(e.deletedAt))).limit(1))[0]??null}var d=b;async function k(e){return d("id",e)}var U=k;async function $(){let e=await p();if(!e)return null;let r=await U(e.userID);return r?{email:r.email,id:r.id}:null}async function D(){return cache($)()}var R=D;async function L(){let e=await R();if(!e)throw new Error("Could not ensure session user. No session user found.");return e}var Re=L;export{y as a,c as b,K as c,V as d,u as e,d as f,l as g,m as h,p as i,R as j,Re as k};//# sourceMappingURL=chunk-QE347FVL.js.map
|
|
2
|
-
//# sourceMappingURL=chunk-QE347FVL.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/storage/utility/get-client.ts","../src/storage/index.ts","../src/auth/utility/ensure-role.ts","../src/auth/utility/config.ts","../src/auth/sessions/utility/get-session-cookie.ts","../src/auth/sessions/utility/parse-session.ts","../src/auth/sessions/validate-session.ts","../src/utility/db.ts","../src/auth/users/utility/get-user-by.ts","../src/auth/users/utility/get-user-by-id.ts","../src/auth/users/get-session-user.ts","../src/auth/users/ensure-session-user.ts"],"names":["client","getClient","createClient","get_client_default","serverStorage","prefix","key","value","storage_default","ensureRole","role","roleNumber","ensure_role_default","AUTH_COOKIE_NAME","AUTH_INVITE_EXPIRY_HOURS","AUTH_RESET_EXPIRY_HOURS","getSessionCookie","cookies","cookie","cookieFn","parts","id","secret","get_session_cookie_default","parseSession","session","expires","userID","expiresDate","parse_session_default","uncached_validateSession","bcrypt","validateSession","cache","validate_session_default","db_default","drizzle","getUserBy","authUserTable","and","eq","isNull","get_user_by_default","getUserByID","get_user_by_id_default","uncached_getSessionUser","authUser","getSessionUser","get_session_user_default","ensureSessionUser","user","ensure_session_user_default"],"mappings":"kPAIA,IAAIA,CAAAA,CAAiD,KAQrD,eAAeC,CAAAA,EAAsD,CACjE,GAAI,CAAC,OAAA,CAAQ,GAAA,CAAI,SAAA,CACb,MAAM,IAAI,KAAA,CAAM,gEAAgE,CAAA,CAGpF,OAAID,CAAAA,GAIJA,CAAAA,CAASE,aAAa,CAClB,GAAA,CAAK,OAAA,CAAQ,GAAA,CAAI,SACrB,CAAC,CAAA,CAED,MAAMF,CAAAA,CAAO,OAAA,EAAQ,CACdA,CAAAA,CACX,CAEA,IAAOG,CAAAA,CAAQF,CAAAA,KCxBTG,CAAAA,CAAgB,CAOlB,MAAM,OAAA,CAAQC,CAAAA,CAAgBC,CAAAA,CAAsD,CAChF,IAAMC,EAAQ,KAAA,CAAO,MAAMJ,CAAAA,EAAU,EAAG,GAAA,CAAI,CAAA,CAAA,EAAIE,CAAM,CAAA,EAAA,EAAKC,CAAG,CAAA,CAAE,CAAA,CAEhE,GAAI,CAACC,CAAAA,CACD,OAAO,IAAA,CAGX,GAAI,CACA,OAAO,IAAA,CAAK,KAAA,CAAMA,CAAK,CAC3B,CAAA,KAAQ,CACJ,OAAO,IACX,CACJ,CAAA,CAEA,MAAM,QAAA,CAASF,CAAAA,CAAgBC,CAAAA,CAAgC,CAE3D,OADe,KAAA,CAAO,MAAMH,CAAAA,EAAU,EAAG,QAAA,CAAS,CAAA,CAAA,EAAIE,CAAM,CAAA,EAAA,EAAKC,CAAG,CAAA,CAAE,CAE1E,CAAA,CAEA,MAAM,UAAA,CAAWD,CAAAA,CAAgBC,CAAAA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AAA,CAAQD,CAAAA,CCAf,eAAeE,CAAAA,EAAgD,CAC3D,IAAMpB,CAAAA,CAAU,MAAMS,CAAAA,EAAgB,CAEtC,GAAI,CAACT,EACD,OAAO,IAAA,CAGX,IAAMqB,CAAAA,CAAW,MAAMF,CAAAA,CAAYnB,CAAAA,CAAQ,MAAM,EAEjD,OAAKqB,CAAAA,CAIE,CACH,KAAA,CAAOA,CAAAA,CAAS,KAAA,CAChB,EAAA,CAAIA,CAAAA,CAAS,EACjB,CAAA,CANW,IAOf,CAEA,eAAeC,CAAAA,EAA6D,CACxE,OAAOd,KAAAA,CAAMY,CAAuB,CAAA,EACxC,CAEA,IAAOG,CAAAA,CAAQD,EC3Bf,eAAeE,GAAmC,CAC9C,IAAMC,CAAAA,CAAO,MAAMF,CAAAA,EAAe,CAElC,GAAI,CAACE,EACD,MAAM,IAAI,KAAA,CAAM,uDAAuD,CAAA,CAG3E,OAAOA,CACX,KAEOC,EAAAA,CAAQF","file":"chunk-QE347FVL.js","sourcesContent":["import { createClient } from 'redis';\n\nimport isLocalhost from './is-localhost.js';\n\nlet client: ReturnType<typeof createClient> | null = null;\n\n/**\n * Get a Redis client instance. If the client does not exist, it creates a new one and connects to the Redis server.\n * If the client already exists, it returns the existing instance.\n *\n * @returns A promise that resolves to a Redis client instance.\n */\nasync function getClient(): Promise<ReturnType<typeof createClient>> {\n if (!process.env.REDIS_URL) {\n throw new Error('REDIS_URL is not defined. Access to the cache is not possible.');\n }\n\n if (client) {\n return client;\n }\n\n client = createClient({\n url: process.env.REDIS_URL,\n });\n\n await client.connect();\n return client;\n}\n\nexport default getClient;\n","import getClient from './utility/get-client';\n\n/**\n * Server-side storage utility for caching data using Redis. It is designed to match the interface of localStorage, but operates on the server side.\n */\nconst serverStorage = {\n /**\n * Get an item from the cache.\n * @param prefix The prefix to use for the cache key.\n * @param key The key of the item to retrieve.\n * @returns The cached item, or null if not found.\n */\n async getItem(prefix: string, key: string): Promise<Record<string, unknown> | null> {\n const value = await (await getClient()).get(`[${prefix}]:${key}`);\n\n if (!value) {\n return null;\n }\n\n try {\n return JSON.parse(value);\n } catch {\n return null;\n }\n },\n\n async getArray(prefix: string, key: string): Promise<string[]> {\n const values = await (await getClient()).sMembers(`[${prefix}]:${key}`);\n return values;\n },\n\n async addToArray(prefix: string, key: string, value: string): Promise<void> {\n await (await getClient()).sAdd(`[${prefix}]:${key}`, value);\n },\n\n async removeFromArray(prefix: string, key: string, value: string): Promise<void> {\n await (await getClient()).sRem(`[${prefix}]:${key}`, value);\n },\n\n /**\n * Set an item in the cache.\n * @param prefix The prefix to use for the cache key.\n * @param key The key of the item to set.\n * @param value The value of the item to set.\n */\n async setItem(prefix: string, key: string, value: Record<string, unknown>): Promise<void> {\n await (await getClient()).set(`[${prefix}]:${key}`, JSON.stringify(value));\n },\n\n /**\n * Remove an item from the cache.\n * @param prefix The prefix to use for the cache key.\n * @param key The key of the item to remove.\n */\n async removeItem(prefix: string, key: string): Promise<void> {\n await (await getClient()).del(`[${prefix}]:${key}`);\n },\n};\n\nexport default serverStorage;\n","function ensureRole(): number {\n const role = process.env.AUTH_ROLE;\n\n if (!role) {\n throw new Error('AUTH_ROLE environment variable is not set.');\n }\n\n const roleNumber = parseInt(role, 10);\n\n if (isNaN(roleNumber)) {\n throw new Error('AUTH_ROLE environment variable is not a valid number.');\n }\n\n return roleNumber;\n}\n\nexport default ensureRole;\n","export const AUTH_COOKIE_NAME = process.env.AUTH_COOKIE_NAME ?? 'session';\n\nexport const AUTH_INVITE_EXPIRY_HOURS = process.env.AUTH_INVITE_EXPIRY_HOURS\n ? Number(process.env.AUTH_INVITE_EXPIRY_HOURS)\n : 24;\n\nexport const AUTH_RESET_EXPIRY_HOURS = process.env.AUTH_RESET_EXPIRY_HOURS\n ? Number(process.env.AUTH_RESET_EXPIRY_HOURS)\n : 2;\n","import { cookies as cookieFn } from 'next/headers';\nimport { NextRequest } from 'next/server';\n\nimport { AUTH_COOKIE_NAME } from '../../utility/config';\n\nimport type { AuthSessionCookie } from './interfaces';\n\nasync function getSessionCookie(\n cookies?: NextRequest['cookies']\n): Promise<AuthSessionCookie | null> {\n const cookie = (cookies ?? (await cookieFn())).get(AUTH_COOKIE_NAME)?.value;\n\n if (!cookie) {\n return null;\n }\n\n const parts = cookie.split('.');\n\n if (parts.length !== 2) {\n return null;\n }\n\n const [id, secret] = parts;\n return { id, secret };\n}\n\nexport default getSessionCookie;\n","import type { AuthSession } from './interfaces';\n\nfunction parseSession(session: Record<string, unknown>): AuthSession | null {\n const { expires, secret, userID } = session;\n\n if (typeof expires !== 'string' || typeof secret !== 'string' || typeof userID !== 'string') {\n return null;\n }\n\n const expiresDate = new Date(expires);\n\n if (isNaN(expiresDate.getTime())) {\n return null;\n }\n\n return {\n expires: expiresDate,\n secret,\n userID,\n };\n}\n\nexport default parseSession;\n","import bcrypt from 'bcryptjs';\nimport { NextRequest } from 'next/server';\nimport { cache } from 'react';\n\nimport serverStorage from '../../storage';\n\nimport ensureRole from '../utility/ensure-role';\nimport getSessionCookie from './utility/get-session-cookie';\nimport type { AuthSession } from './utility/interfaces';\nimport parseSession from './utility/parse-session';\n\nasync function uncached_validateSession(\n cookies?: NextRequest['cookies']\n): Promise<AuthSession | null> {\n const cookie = await getSessionCookie(cookies);\n\n if (!cookie) {\n return null;\n }\n\n const role = ensureRole();\n const session = await serverStorage.getItem('session', cookie.id);\n\n if(session?.role !== role) {\n return null;\n }\n\n if (typeof session?.secret !== 'string') {\n return null;\n }\n\n if (!(await bcrypt.compare(cookie.secret, session.secret))) {\n return null;\n }\n\n return parseSession(session);\n}\n\nconst validateSession = cache(uncached_validateSession);\n\nexport default validateSession;\n","import { drizzle } from 'drizzle-orm/node-postgres';\n\nexport default drizzle(process.env.DATABASE_URL ?? '');\n","import { and, eq, isNull } from 'drizzle-orm';\n\nimport db from '../../../utility/db';\n\nimport ensureRole from '../../utility/ensure-role';\nimport { authUserTable } from '../../utility/schema';\nimport type { AuthUserTable } from '../../utility/schema';\n\nimport type { AuthUser } from './interfaces';\n\nasync function getUserBy(key: keyof AuthUserTable, value: string): Promise<AuthUser | null> {\n const role = ensureRole();\n\n const results = await db\n .select()\n .from(authUserTable)\n .where(\n and(\n eq(authUserTable[key], value),\n eq(authUserTable.role, role),\n isNull(authUserTable.deletedAt)\n )\n )\n .limit(1);\n\n return results[0] ?? null;\n}\n\nexport default getUserBy;\n","import getUserBy from './get-user-by';\nimport type { AuthUser } from './interfaces';\n\nasync function getUserByID(id: string): Promise<AuthUser | null> {\n return getUserBy('id', id);\n}\n\nexport default getUserByID;\n","import { cache } from 'react';\n\nimport validateSession from '../sessions/validate-session';\n\nimport getUserByID from './utility/get-user-by-id';\nimport type { User } from './utility/interfaces';\n\nasync function uncached_getSessionUser(): Promise<User | null> {\n const session = await validateSession();\n\n if (!session) {\n return null;\n }\n\n const authUser = await getUserByID(session.userID);\n\n if (!authUser) {\n return null;\n }\n\n return {\n email: authUser.email,\n id: authUser.id,\n };\n}\n\nasync function getSessionUser(): ReturnType<typeof uncached_getSessionUser> {\n return cache(uncached_getSessionUser)();\n}\n\nexport default getSessionUser;\n","import getSessionUser from './get-session-user';\nimport type { User } from './utility/interfaces';\n\nasync function ensureSessionUser(): Promise<User> {\n const user = await getSessionUser();\n\n if (!user) {\n throw new Error('Could not ensure session user. No session user found.');\n }\n\n return user;\n}\n\nexport default ensureSessionUser;\n"]}
|
package/dist/chunk-XSJ4OEIH.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import {randomBytes}from'crypto';function u(r,n){let t=Array.isArray(r)?r[0]:r;return t?.startsWith(n)?t:null}var s=u;function a(r,n){let t=s(r,n);if(!t)throw new Error(`Could not ensure ID. '${r}' is not a valid ID with prefix '${n}'.`);return t}var m=a;var l=16;function d(r,n=l){let t="abcdefghijklmnopqrstuvwxyz0123456789",i=randomBytes(n),e="";for(let o=0;o<n;o++)e+=t[i[o]%t.length];return `${r?r+"_":""}${e}`}var I=d;async function f(r,n,t){if(!t)throw new Error("");let i=await t,e=s(i[r],n);if(!e)throw new Error("");return e}var p=f;export{s as a,m as b,I as c,p as d};//# sourceMappingURL=chunk-XSJ4OEIH.js.map
|
|
2
|
-
//# sourceMappingURL=chunk-XSJ4OEIH.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utility/guard-id.ts","../src/utility/ensure-id.ts","../src/utility/generate-id.ts","../src/utility/get-id-from-params.ts"],"names":["guardID","id","prefix","value","guard_id_default","ensureID","guardedID","ensure_id_default","ID_LENGTH","generateID","length","chars","bytes","randomBytes","result","i","generate_id_default","getIDFromParams","key","params","awaitedParams","get_id_from_params_default"],"mappings":"iCAAA,SAASA,CAAAA,CACLC,CAAAA,CACAC,CAAAA,CACQ,CACR,IAAMC,CAAAA,CAAQ,KAAA,CAAM,OAAA,CAAQF,CAAE,CAAA,CAAIA,CAAAA,CAAG,CAAC,CAAA,CAAIA,EAE1C,OAAKE,CAAAA,EAAO,UAAA,CAAWD,CAAM,CAAA,CAItBC,CAAAA,CAHI,IAIf,KAEOC,CAAAA,CAAQJ,ECXf,SAASK,CAAAA,CAA2BJ,CAAAA,CAA0CC,CAAAA,CAAmB,CAC7F,IAAMI,EAAYF,CAAAA,CAAWH,CAAAA,CAAIC,CAAM,CAAA,CAEvC,GAAI,CAACI,CAAAA,CACD,MAAM,IAAI,KAAA,CAAM,CAAA,sBAAA,EAAyBL,CAAE,CAAA,iCAAA,EAAoCC,CAAM,CAAA,EAAA,CAAI,CAAA,CAG7F,OAAOI,CACX,CAEA,IAAOC,CAAAA,CAAQF,ECVf,IAAMG,CAAAA,CAAY,EAAA,CAElB,SAASC,CAAAA,CAAsCP,CAAAA,CAAwBQ,CAAAA,CAASF,CAAAA,CAAc,CAC1F,IAAMG,CAAAA,CAAQ,sCAAA,CACRC,CAAAA,CAAQC,WAAAA,CAAYH,CAAM,CAAA,CAE5BI,CAAAA,CAAS,EAAA,CAEb,QAASC,CAAAA,CAAI,CAAA,CAAGA,CAAAA,CAAIL,CAAAA,CAAQK,CAAAA,EAAAA,CACxBD,CAAAA,EAAUH,CAAAA,CAAMC,CAAAA,CAAMG,CAAC,CAAA,CAAIJ,CAAAA,CAAM,MAAM,CAAA,CAG3C,OAAO,CAAA,EAAGT,CAAAA,CAASA,CAAAA,CAAS,IAAM,EAAE,CAAA,EAAGY,CAAM,CAAA,CACjD,CAEA,IAAOE,CAAAA,CAAQP,ECff,eAAeQ,CAAAA,CACXC,CAAAA,CACAhB,CAAAA,CACAiB,CAAAA,CACU,CACV,GAAI,CAACA,CAAAA,CACD,MAAM,IAAI,KAAA,CAAM,EAAE,CAAA,CAGtB,IAAMC,CAAAA,CAAgB,MAAMD,CAAAA,CACtBlB,EAAKG,CAAAA,CAAWgB,CAAAA,CAAcF,CAAG,CAAA,CAAGhB,CAAM,CAAA,CAEhD,GAAI,CAACD,EACD,MAAM,IAAI,KAAA,CAAM,EAAE,CAAA,CAGtB,OAAOA,CACX,KAEOoB,CAAAA,CAAQJ","file":"chunk-XSJ4OEIH.js","sourcesContent":["function guardID<T extends string>(\n id: string[] | string | null | undefined,\n prefix: string\n): T | null {\n const value = Array.isArray(id) ? id[0] : id;\n\n if (!value?.startsWith(prefix)) {\n return null;\n }\n\n return value as T;\n}\n\nexport default guardID;\n","import guardID from './guard-id';\n\nfunction ensureID<T extends string>(id: string[] | string | null | undefined, prefix: string): T {\n const guardedID = guardID<T>(id, prefix);\n\n if (!guardedID) {\n throw new Error(`Could not ensure ID. '${id}' is not a valid ID with prefix '${prefix}'.`);\n }\n\n return guardedID;\n}\n\nexport default ensureID;\n","import { randomBytes } from 'crypto';\n\nconst ID_LENGTH = 16;\n\nfunction generateID<T extends string = string>(prefix?: string | null, length = ID_LENGTH): T {\n const chars = 'abcdefghijklmnopqrstuvwxyz0123456789';\n const bytes = randomBytes(length);\n\n let result = '';\n\n for (let i = 0; i < length; i++) {\n result += chars[bytes[i] % chars.length];\n }\n\n return `${prefix ? prefix + '_' : ''}${result}` as T;\n}\n\nexport default generateID;\n","import guardID from './guard-id';\n\nasync function getIDFromParams<T extends string>(\n key: string,\n prefix: string,\n params?: Promise<Record<string, string>> | null\n): Promise<T> {\n if (!params) {\n throw new Error('');\n }\n\n const awaitedParams = await params;\n const id = guardID<T>(awaitedParams[key], prefix);\n\n if (!id) {\n throw new Error('');\n }\n\n return id;\n}\n\nexport default getIDFromParams;\n"]}
|
package/dist/cli/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
package/dist/cli/index.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {program}from'commander';import {spawn}from'child_process';import {dirname,resolve,extname}from'path';import {fileURLToPath}from'url';import {readdir,readFile}from'fs/promises';import {Client}from'pg';import T from'dotenv';var c=dirname(fileURLToPath(import.meta.url)),S=resolve(c,"../../node_modules/.bin/drizzle-kit"),h=resolve(c,"static/drizzle.config.js");async function E(){let t=spawn(S,["generate",`--config=${h}`],{stdio:"inherit"});return new Promise((e,o)=>{t.on("close",A=>{A===0?e():o();});})}var m=E;T.config({path:resolve(process.cwd(),".env"),quiet:true});var d=resolve(process.cwd(),"./database/migrations");async function C(){let t=(await readdir(d)).filter(o=>extname(o)===".sql").map(o=>resolve(d,o)),e=[];for(let o of t)e.push(await readFile(o,"utf-8"));return e.join(`
|
|
3
|
-
`)}async function x(){if(!process.env.DATABASE_URL)throw new Error("DATABASE_URL is not defined");let t=process.env.APP_ENV;if(!t||!["development","test"].includes(t))throw new Error("APP_ENV is not defined, or does not support migration.");let e=new Client(process.env.DATABASE_URL);await e.connect(),await e.query("SET client_min_messages TO WARNING; DROP SCHEMA IF EXISTS auth CASCADE; DROP SCHEMA IF EXISTS public CASCADE; CREATE SCHEMA public;");let o=await C();await e.query(o),await e.end();}var f=x;T.config({path:resolve(process.cwd(),".env"),quiet:true});var p=resolve(process.cwd(),"./database/seeds");async function I(t){let e=await import(t);typeof e.default=="function"&&await e.default();}async function L(){let t=(await readdir(p)).map(e=>resolve(p,e));for(let e of t)await I(e);}var u=L;var w=dirname(fileURLToPath(import.meta.url));resolve(w,"../../node_modules/.bin/tsx");resolve(w,"./scripts");async function z(t){t().then(()=>{process.exit(0);}).catch(e=>{console.error(e),process.exit(1);});}var r=z;program.command("db:generate").action(async()=>await r(m));program.command("db:reset").action(async()=>await r(f));program.command("db:seed").action(async()=>await r(u));program.parse();//# sourceMappingURL=index.js.map
|
|
4
|
-
//# sourceMappingURL=index.js.map
|
package/dist/cli/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cli/scripts/db-generate.ts","../../src/cli/scripts/db-reset.ts","../../src/cli/scripts/db-seed.ts","../../src/cli/utility/run-script.ts","../../src/cli/index.ts"],"names":["__dirname","dirname","fileURLToPath","binPath","resolve","configPath","dbGenerate","ls","spawn","reject","code","db_generate_default","dotenv","migrationPath","getMigrationQuery","files","readdir","file","extname","query","readFile","dbReset","environment","client","Client","db_reset_default","seedPath","runSeedFile","seedModule","dbSeed","db_seed_default","runScript","script","err","run_script_default","program"],"mappings":";sOAIA,IAAMA,CAAAA,CAAYC,OAAAA,CAAQC,cAAc,MAAA,CAAA,IAAA,CAAY,GAAG,CAAC,CAAA,CAElDC,EAAUC,OAAAA,CAAQJ,CAAAA,CAAW,qCAAqC,CAAA,CAClEK,EAAaD,OAAAA,CAAQJ,CAAAA,CAAW,0BAA0B,CAAA,CAEhE,eAAeM,CAAAA,EAA4B,CACvC,IAAMC,CAAAA,CAAKC,MAAML,CAAAA,CAAS,CAAC,UAAA,CAAY,CAAA,SAAA,EAAYE,CAAU,CAAA,CAAE,CAAA,CAAG,CAAE,KAAA,CAAO,SAAU,CAAC,CAAA,CAEtF,OAAO,IAAI,QAAc,CAACD,CAAAA,CAASK,CAAAA,GAAW,CAC1CF,EAAG,EAAA,CAAG,OAAA,CAAUG,CAAAA,EAAS,CACjBA,IAAS,CAAA,CACTN,CAAAA,EAAQ,CAERK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AAQ,KAAA,CAAMA,CAAG,CAAA,CACjB,OAAA,CAAQ,IAAA,CAAK,CAAC,EAClB,CAAC,EACT,CAEA,IAAOC,CAAAA,CAAQH,CAAAA,CCxBfI,OAAAA,CAAQ,OAAA,CAAQ,aAAa,CAAA,CAAE,MAAA,CAAO,SAAY,MAAMD,CAAAA,CAAUvB,CAAU,CAAC,CAAA,CAC7EwB,OAAAA,CAAQ,OAAA,CAAQ,UAAU,CAAA,CAAE,MAAA,CAAO,SAAY,MAAMD,CAAAA,CAAUT,CAAO,CAAC,CAAA,CACvEU,OAAAA,CAAQ,OAAA,CAAQ,SAAS,CAAA,CAAE,MAAA,CAAO,SAAY,MAAMD,CAAAA,CAAUJ,CAAM,CAAC,CAAA,CAErEK,OAAAA,CAAQ,KAAA,EAAM","file":"index.js","sourcesContent":["import { spawn } from 'node:child_process';\nimport { dirname, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\n\nconst binPath = resolve(__dirname, '../../node_modules/.bin/drizzle-kit');\nconst configPath = resolve(__dirname, 'static/drizzle.config.js');\n\nasync function dbGenerate(): Promise<void> {\n const ls = spawn(binPath, ['generate', `--config=${configPath}`], { stdio: 'inherit' });\n\n return new Promise<void>((resolve, reject) => {\n ls.on('close', (code) => {\n if (code === 0) {\n resolve();\n } else {\n reject();\n }\n });\n });\n}\n\nexport default dbGenerate;\n","import { readdir, readFile } from 'node:fs/promises';\nimport { extname, resolve } from 'node:path';\n\nimport { Client } from 'pg';\n\nimport dotenv from 'dotenv';\ndotenv.config({ path: resolve(process.cwd(), '.env'), quiet: true });\n\nconst migrationPath = resolve(process.cwd(), './database/migrations');\n\nasync function getMigrationQuery(): Promise<string> {\n const files = (await readdir(migrationPath))\n .filter((file) => extname(file) === '.sql')\n .map((file) => resolve(migrationPath, file));\n\n let query = [];\n\n for (const file of files) {\n query.push(await readFile(file, 'utf-8'));\n }\n\n return query.join('\\n');\n}\n\nasync function dbReset() {\n if (!process.env.DATABASE_URL) {\n throw new Error('DATABASE_URL is not defined');\n }\n\n const environment = process.env.APP_ENV;\n\n if (!environment || !['development', 'test'].includes(environment)) {\n throw new Error('APP_ENV is not defined, or does not support migration.');\n }\n\n const client = new Client(process.env.DATABASE_URL);\n await client.connect();\n\n await client.query(\n 'SET client_min_messages TO WARNING; DROP SCHEMA IF EXISTS auth CASCADE; DROP SCHEMA IF EXISTS public CASCADE; CREATE SCHEMA public;'\n );\n\n const query = await getMigrationQuery();\n await client.query(query);\n\n await client.end();\n}\n\nexport default dbReset;\n","import { readdir } from 'node:fs/promises';\nimport { resolve } from 'node:path';\n\nimport dotenv from 'dotenv';\ndotenv.config({ path: resolve(process.cwd(), '.env'), quiet: true });\n\nconst seedPath = resolve(process.cwd(), './database/seeds');\n\nasync function runSeedFile(file: string) {\n const seedModule = await import(file);\n\n if (typeof seedModule.default === 'function') {\n await seedModule.default();\n }\n}\n\nasync function dbSeed() {\n const files = (await readdir(seedPath)).map((file) => resolve(seedPath, file));\n\n for (const file of files) {\n await runSeedFile(file);\n }\n}\n\nexport default dbSeed;\n","import { spawn } from 'node:child_process';\nimport { dirname, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\n\nconst binPath = resolve(__dirname, '../../node_modules/.bin/tsx');\nconst scriptPath = resolve(__dirname, './scripts');\n\n// async function runScript(file: string) {\n// const ls = spawn(binPath, [`${resolve(scriptPath, file)}.js`], { stdio: 'inherit' });\n\n// return new Promise<void>((resolve, reject) => {\n// ls.on('close', (code) => {\n// if (code === 0) {\n// resolve();\n// } else {\n// reject(new Error(`Script ${file} exited with code ${code}`));\n// }\n// });\n// });\n// }\n\nasync function runScript(script: () => Promise<void>): Promise<void> {\n script()\n .then(() => {\n process.exit(0);\n })\n .catch((err) => {\n console.error(err);\n process.exit(1);\n });\n}\n\nexport default runScript;\n","#!/usr/bin/env node\n\nimport { program } from 'commander';\n\nimport dbGenerate from './scripts/db-generate';\nimport dbReset from './scripts/db-reset';\nimport dbSeed from './scripts/db-seed';\n\nimport runScript from './utility/run-script';\n\nprogram.command('db:generate').action(async () => await runScript(dbGenerate));\nprogram.command('db:reset').action(async () => await runScript(dbReset));\nprogram.command('db:seed').action(async () => await runScript(dbSeed));\n\nprogram.parse();\n"]}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import 'dotenv/config';
|
|
2
|
-
import { defineConfig } from 'drizzle-kit';
|
|
3
|
-
|
|
4
|
-
if (!process.env.DATABASE_URL) {
|
|
5
|
-
throw new Error('DATABASE_URL is not defined. Database migration cannot be generated.');
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export default defineConfig({
|
|
9
|
-
dbCredentials: {
|
|
10
|
-
url: process.env.DATABASE_URL,
|
|
11
|
-
},
|
|
12
|
-
dialect: 'postgresql',
|
|
13
|
-
out: './database/migrations',
|
|
14
|
-
schema: [
|
|
15
|
-
require.resolve('@sqrzro/server/auth/schema'),
|
|
16
|
-
'./src/schema/**/*.ts',
|
|
17
|
-
'./src/**/schema.ts',
|
|
18
|
-
],
|
|
19
|
-
});
|