@axium/server 0.26.3 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/config.js CHANGED
@@ -30,7 +30,6 @@ export const ConfigSchema = z
30
30
  .partial(),
31
31
  auth: z
32
32
  .looseObject({
33
- origin: z.string(),
34
33
  /** In minutes */
35
34
  passkey_probation: z.number(),
36
35
  rp_id: z.string(),
@@ -62,6 +61,7 @@ export const ConfigSchema = z
62
61
  console: z.boolean(),
63
62
  })
64
63
  .partial(),
64
+ origin: z.string(),
65
65
  request_size_limit: z.number().min(0).optional(),
66
66
  show_duplicate_state: z.boolean(),
67
67
  web: z
@@ -95,7 +95,6 @@ export const defaultConfig = {
95
95
  auto_suspend: 'critical',
96
96
  },
97
97
  auth: {
98
- origin: 'https://test.localhost',
99
98
  passkey_probation: 60,
100
99
  rp_id: 'test.localhost',
101
100
  rp_name: 'Axium',
@@ -122,6 +121,7 @@ export const defaultConfig = {
122
121
  console: true,
123
122
  level: 'info',
124
123
  },
124
+ origin: 'https://test.localhost',
125
125
  show_duplicate_state: false,
126
126
  request_size_limit: 0,
127
127
  web: {
@@ -228,8 +228,11 @@ export async function loadConfig(path, options = {}) {
228
228
  io.debug('Loaded config: ' + path);
229
229
  for (const include of file.include ?? [])
230
230
  await loadConfig(resolve(dirname(path), include), { ...options, optional: true, _markIncluded: true });
231
- for (const plugin of file.plugins ?? [])
232
- await loadPlugin('server', plugin, path, options.safe);
231
+ for (const pluginPath of file.plugins ?? []) {
232
+ const plugin = await loadPlugin('server', pluginPath, path, options.safe);
233
+ if (!plugin)
234
+ continue;
235
+ }
233
236
  }
234
237
  export async function loadDefaultConfigs(safe = false) {
235
238
  for (const path of findConfigPaths()) {
@@ -277,9 +280,7 @@ export function saveConfigTo(path, changed) {
277
280
  */
278
281
  export function findConfigPaths() {
279
282
  const paths = dirs.map(dir => join(dir, 'config.json'));
280
- if (process.env.AXIUM_CONFIG)
283
+ if (process.env.AXIUM_CONFIG && !paths.includes(process.env.AXIUM_CONFIG))
281
284
  paths.push(process.env.AXIUM_CONFIG);
282
285
  return paths;
283
286
  }
284
- if (process.env.AXIUM_CONFIG)
285
- await loadConfig(process.env.AXIUM_CONFIG);
@@ -1,14 +1,19 @@
1
- import type { Permission, Preferences, Severity, UserInternal } from '@axium/core';
1
+ import type { Preferences, Severity, UserInternal } from '@axium/core';
2
2
  import type { AuthenticatorTransportFuture, CredentialDeviceType } from '@simplewebauthn/server';
3
3
  import type * as kysely from 'kysely';
4
4
  import { Kysely } from 'kysely';
5
+ import * as z from 'zod';
5
6
  import type { VerificationRole } from './auth.js';
6
7
  export interface DBAccessControl {
7
8
  itemId: string;
8
- userId: string;
9
+ userId?: string | null;
10
+ role?: string | null;
11
+ tag?: string | null;
9
12
  createdAt: kysely.GeneratedAlways<Date>;
10
- permission: Permission;
11
13
  }
14
+ export type DBBool<K extends string> = {
15
+ [key in K]?: boolean | null;
16
+ };
12
17
  export interface Schema {
13
18
  users: {
14
19
  id: string;
@@ -58,7 +63,7 @@ export interface Schema {
58
63
  source: string;
59
64
  extra: kysely.Generated<Record<string, unknown>>;
60
65
  };
61
- [key: `acl.${string}`]: DBAccessControl;
66
+ [key: `acl.${string}`]: DBAccessControl & Record<string, unknown>;
62
67
  }
63
68
  export type Database = Kysely<Schema> & AsyncDisposable;
64
69
  export declare let database: Database;
@@ -75,6 +80,10 @@ export type TablesMatching<T> = (string & keyof Schema) & keyof {
75
80
  export declare function userFromId<TB extends TablesMatching<{
76
81
  userId: string;
77
82
  }>>(builder: kysely.ExpressionBuilder<Schema, TB>): kysely.AliasedRawBuilder<UserInternal, 'user' | TB>;
83
+ /**
84
+ * Used for `update ... set ... from`
85
+ */
86
+ export declare function values<R extends Record<string, unknown>, A extends string>(records: R[], alias: A): kysely.AliasedRawBuilder<R, A>;
78
87
  export interface Stats {
79
88
  users: number;
80
89
  passkeys: number;
@@ -90,26 +99,415 @@ export interface InitOptions extends OpOptions {
90
99
  }
91
100
  export declare function shouldRecreate(opt: InitOptions): boolean;
92
101
  export declare function getHBA(opt: OpOptions): Promise<[content: string, writeBack: (newContent: string) => void]>;
102
+ /** @internal @hidden */
103
+ export declare const _pgHba = "\nlocal axium axium md5\nhost axium axium 127.0.0.1/32 md5\nhost axium axium ::1/128 md5\n";
104
+ /** @internal @hidden */
105
+ export declare const _sql: (command: string, message: string) => Promise<string>;
93
106
  /** Shortcut to output a warning if an error is thrown because relation already exists */
94
107
  export declare const warnExists: (error: string | Error) => void;
95
- export declare function createIndex(table: string, column: string, mod?: (ib: kysely.CreateIndexBuilder<string>) => kysely.CreateIndexBuilder<string>): Promise<void>;
96
108
  export declare function init(opt: InitOptions): Promise<void>;
109
+ export declare const Column: z.ZodObject<{
110
+ type: z.ZodString;
111
+ required: z.ZodDefault<z.ZodBoolean>;
112
+ unique: z.ZodDefault<z.ZodBoolean>;
113
+ primary: z.ZodDefault<z.ZodBoolean>;
114
+ references: z.ZodOptional<z.ZodString>;
115
+ onDelete: z.ZodOptional<z.ZodEnum<{
116
+ cascade: "cascade";
117
+ restrict: "restrict";
118
+ "no action": "no action";
119
+ "set null": "set null";
120
+ "set default": "set default";
121
+ }>>;
122
+ default: z.ZodOptional<z.ZodAny>;
123
+ check: z.ZodOptional<z.ZodString>;
124
+ }, z.core.$strict>;
125
+ export interface Column extends z.infer<typeof Column> {
126
+ }
127
+ export declare const Constraint: z.ZodDiscriminatedUnion<[z.ZodObject<{
128
+ type: z.ZodLiteral<"primary_key">;
129
+ on: z.ZodArray<z.ZodString>;
130
+ }, z.core.$strict>, z.ZodObject<{
131
+ type: z.ZodLiteral<"foreign_key">;
132
+ on: z.ZodArray<z.ZodString>;
133
+ target: z.ZodString;
134
+ references: z.ZodArray<z.ZodString>;
135
+ }, z.core.$strict>, z.ZodObject<{
136
+ type: z.ZodLiteral<"unique">;
137
+ on: z.ZodArray<z.ZodString>;
138
+ nulls_not_distinct: z.ZodOptional<z.ZodBoolean>;
139
+ }, z.core.$strict>, z.ZodObject<{
140
+ type: z.ZodLiteral<"check">;
141
+ check: z.ZodString;
142
+ }, z.core.$strict>], "type">;
143
+ export type Constraint = z.infer<typeof Constraint>;
144
+ export declare const Table: z.ZodObject<{
145
+ columns: z.ZodRecord<z.ZodString, z.ZodObject<{
146
+ type: z.ZodString;
147
+ required: z.ZodDefault<z.ZodBoolean>;
148
+ unique: z.ZodDefault<z.ZodBoolean>;
149
+ primary: z.ZodDefault<z.ZodBoolean>;
150
+ references: z.ZodOptional<z.ZodString>;
151
+ onDelete: z.ZodOptional<z.ZodEnum<{
152
+ cascade: "cascade";
153
+ restrict: "restrict";
154
+ "no action": "no action";
155
+ "set null": "set null";
156
+ "set default": "set default";
157
+ }>>;
158
+ default: z.ZodOptional<z.ZodAny>;
159
+ check: z.ZodOptional<z.ZodString>;
160
+ }, z.core.$strict>>;
161
+ constraints: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
162
+ type: z.ZodLiteral<"primary_key">;
163
+ on: z.ZodArray<z.ZodString>;
164
+ }, z.core.$strict>, z.ZodObject<{
165
+ type: z.ZodLiteral<"foreign_key">;
166
+ on: z.ZodArray<z.ZodString>;
167
+ target: z.ZodString;
168
+ references: z.ZodArray<z.ZodString>;
169
+ }, z.core.$strict>, z.ZodObject<{
170
+ type: z.ZodLiteral<"unique">;
171
+ on: z.ZodArray<z.ZodString>;
172
+ nulls_not_distinct: z.ZodOptional<z.ZodBoolean>;
173
+ }, z.core.$strict>, z.ZodObject<{
174
+ type: z.ZodLiteral<"check">;
175
+ check: z.ZodString;
176
+ }, z.core.$strict>], "type">>>>;
177
+ }, z.core.$strict>;
178
+ export interface Table extends z.infer<typeof Table> {
179
+ }
180
+ export declare const IndexString: z.ZodTemplateLiteral<`${string}:${string}`>;
181
+ export type IndexString = z.infer<typeof IndexString>;
182
+ export declare function parseIndex(value: IndexString): {
183
+ table: string;
184
+ column: string;
185
+ };
186
+ export declare const SchemaDecl: z.ZodObject<{
187
+ tables: z.ZodRecord<z.ZodString, z.ZodObject<{
188
+ columns: z.ZodRecord<z.ZodString, z.ZodObject<{
189
+ type: z.ZodString;
190
+ required: z.ZodDefault<z.ZodBoolean>;
191
+ unique: z.ZodDefault<z.ZodBoolean>;
192
+ primary: z.ZodDefault<z.ZodBoolean>;
193
+ references: z.ZodOptional<z.ZodString>;
194
+ onDelete: z.ZodOptional<z.ZodEnum<{
195
+ cascade: "cascade";
196
+ restrict: "restrict";
197
+ "no action": "no action";
198
+ "set null": "set null";
199
+ "set default": "set default";
200
+ }>>;
201
+ default: z.ZodOptional<z.ZodAny>;
202
+ check: z.ZodOptional<z.ZodString>;
203
+ }, z.core.$strict>>;
204
+ constraints: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
205
+ type: z.ZodLiteral<"primary_key">;
206
+ on: z.ZodArray<z.ZodString>;
207
+ }, z.core.$strict>, z.ZodObject<{
208
+ type: z.ZodLiteral<"foreign_key">;
209
+ on: z.ZodArray<z.ZodString>;
210
+ target: z.ZodString;
211
+ references: z.ZodArray<z.ZodString>;
212
+ }, z.core.$strict>, z.ZodObject<{
213
+ type: z.ZodLiteral<"unique">;
214
+ on: z.ZodArray<z.ZodString>;
215
+ nulls_not_distinct: z.ZodOptional<z.ZodBoolean>;
216
+ }, z.core.$strict>, z.ZodObject<{
217
+ type: z.ZodLiteral<"check">;
218
+ check: z.ZodString;
219
+ }, z.core.$strict>], "type">>>>;
220
+ }, z.core.$strict>>;
221
+ indexes: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodTemplateLiteral<`${string}:${string}`>>>>;
222
+ }, z.core.$strict>;
223
+ export interface SchemaDecl extends z.infer<typeof SchemaDecl> {
224
+ }
225
+ export declare const ColumnDelta: z.ZodObject<{
226
+ type: z.ZodOptional<z.ZodString>;
227
+ default: z.ZodOptional<z.ZodString>;
228
+ ops: z.ZodOptional<z.ZodArray<z.ZodLiteral<"drop_default" | "set_required" | "drop_required">>>;
229
+ }, z.core.$strict>;
230
+ export interface ColumnDelta extends z.infer<typeof ColumnDelta> {
231
+ }
232
+ export declare const TableDelta: z.ZodObject<{
233
+ add_columns: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
234
+ type: z.ZodString;
235
+ required: z.ZodDefault<z.ZodBoolean>;
236
+ unique: z.ZodDefault<z.ZodBoolean>;
237
+ primary: z.ZodDefault<z.ZodBoolean>;
238
+ references: z.ZodOptional<z.ZodString>;
239
+ onDelete: z.ZodOptional<z.ZodEnum<{
240
+ cascade: "cascade";
241
+ restrict: "restrict";
242
+ "no action": "no action";
243
+ "set null": "set null";
244
+ "set default": "set default";
245
+ }>>;
246
+ default: z.ZodOptional<z.ZodAny>;
247
+ check: z.ZodOptional<z.ZodString>;
248
+ }, z.core.$strict>>>>;
249
+ drop_columns: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
250
+ alter_columns: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
251
+ type: z.ZodOptional<z.ZodString>;
252
+ default: z.ZodOptional<z.ZodString>;
253
+ ops: z.ZodOptional<z.ZodArray<z.ZodLiteral<"drop_default" | "set_required" | "drop_required">>>;
254
+ }, z.core.$strict>>>>;
255
+ add_constraints: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
256
+ type: z.ZodLiteral<"primary_key">;
257
+ on: z.ZodArray<z.ZodString>;
258
+ }, z.core.$strict>, z.ZodObject<{
259
+ type: z.ZodLiteral<"foreign_key">;
260
+ on: z.ZodArray<z.ZodString>;
261
+ target: z.ZodString;
262
+ references: z.ZodArray<z.ZodString>;
263
+ }, z.core.$strict>, z.ZodObject<{
264
+ type: z.ZodLiteral<"unique">;
265
+ on: z.ZodArray<z.ZodString>;
266
+ nulls_not_distinct: z.ZodOptional<z.ZodBoolean>;
267
+ }, z.core.$strict>, z.ZodObject<{
268
+ type: z.ZodLiteral<"check">;
269
+ check: z.ZodString;
270
+ }, z.core.$strict>], "type">>>>;
271
+ drop_constraints: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
272
+ }, z.core.$strict>;
273
+ export interface TableDelta extends z.infer<typeof TableDelta> {
274
+ }
275
+ export declare const VersionDelta: z.ZodObject<{
276
+ delta: z.ZodLiteral<true>;
277
+ add_tables: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
278
+ columns: z.ZodRecord<z.ZodString, z.ZodObject<{
279
+ type: z.ZodString;
280
+ required: z.ZodDefault<z.ZodBoolean>;
281
+ unique: z.ZodDefault<z.ZodBoolean>;
282
+ primary: z.ZodDefault<z.ZodBoolean>;
283
+ references: z.ZodOptional<z.ZodString>;
284
+ onDelete: z.ZodOptional<z.ZodEnum<{
285
+ cascade: "cascade";
286
+ restrict: "restrict";
287
+ "no action": "no action";
288
+ "set null": "set null";
289
+ "set default": "set default";
290
+ }>>;
291
+ default: z.ZodOptional<z.ZodAny>;
292
+ check: z.ZodOptional<z.ZodString>;
293
+ }, z.core.$strict>>;
294
+ constraints: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
295
+ type: z.ZodLiteral<"primary_key">;
296
+ on: z.ZodArray<z.ZodString>;
297
+ }, z.core.$strict>, z.ZodObject<{
298
+ type: z.ZodLiteral<"foreign_key">;
299
+ on: z.ZodArray<z.ZodString>;
300
+ target: z.ZodString;
301
+ references: z.ZodArray<z.ZodString>;
302
+ }, z.core.$strict>, z.ZodObject<{
303
+ type: z.ZodLiteral<"unique">;
304
+ on: z.ZodArray<z.ZodString>;
305
+ nulls_not_distinct: z.ZodOptional<z.ZodBoolean>;
306
+ }, z.core.$strict>, z.ZodObject<{
307
+ type: z.ZodLiteral<"check">;
308
+ check: z.ZodString;
309
+ }, z.core.$strict>], "type">>>>;
310
+ }, z.core.$strict>>>>;
311
+ drop_tables: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
312
+ alter_tables: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
313
+ add_columns: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
314
+ type: z.ZodString;
315
+ required: z.ZodDefault<z.ZodBoolean>;
316
+ unique: z.ZodDefault<z.ZodBoolean>;
317
+ primary: z.ZodDefault<z.ZodBoolean>;
318
+ references: z.ZodOptional<z.ZodString>;
319
+ onDelete: z.ZodOptional<z.ZodEnum<{
320
+ cascade: "cascade";
321
+ restrict: "restrict";
322
+ "no action": "no action";
323
+ "set null": "set null";
324
+ "set default": "set default";
325
+ }>>;
326
+ default: z.ZodOptional<z.ZodAny>;
327
+ check: z.ZodOptional<z.ZodString>;
328
+ }, z.core.$strict>>>>;
329
+ drop_columns: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
330
+ alter_columns: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
331
+ type: z.ZodOptional<z.ZodString>;
332
+ default: z.ZodOptional<z.ZodString>;
333
+ ops: z.ZodOptional<z.ZodArray<z.ZodLiteral<"drop_default" | "set_required" | "drop_required">>>;
334
+ }, z.core.$strict>>>>;
335
+ add_constraints: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
336
+ type: z.ZodLiteral<"primary_key">;
337
+ on: z.ZodArray<z.ZodString>;
338
+ }, z.core.$strict>, z.ZodObject<{
339
+ type: z.ZodLiteral<"foreign_key">;
340
+ on: z.ZodArray<z.ZodString>;
341
+ target: z.ZodString;
342
+ references: z.ZodArray<z.ZodString>;
343
+ }, z.core.$strict>, z.ZodObject<{
344
+ type: z.ZodLiteral<"unique">;
345
+ on: z.ZodArray<z.ZodString>;
346
+ nulls_not_distinct: z.ZodOptional<z.ZodBoolean>;
347
+ }, z.core.$strict>, z.ZodObject<{
348
+ type: z.ZodLiteral<"check">;
349
+ check: z.ZodString;
350
+ }, z.core.$strict>], "type">>>>;
351
+ drop_constraints: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
352
+ }, z.core.$strict>>>>;
353
+ add_indexes: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodTemplateLiteral<`${string}:${string}`>>>>;
354
+ drop_indexes: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodTemplateLiteral<`${string}:${string}`>>>>;
355
+ }, z.core.$strict>;
356
+ export interface VersionDelta extends z.infer<typeof VersionDelta> {
357
+ }
358
+ export declare const SchemaFile: z.ZodObject<{
359
+ format: z.ZodLiteral<0>;
360
+ versions: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
361
+ tables: z.ZodRecord<z.ZodString, z.ZodObject<{
362
+ columns: z.ZodRecord<z.ZodString, z.ZodObject<{
363
+ type: z.ZodString;
364
+ required: z.ZodDefault<z.ZodBoolean>;
365
+ unique: z.ZodDefault<z.ZodBoolean>;
366
+ primary: z.ZodDefault<z.ZodBoolean>;
367
+ references: z.ZodOptional<z.ZodString>;
368
+ onDelete: z.ZodOptional<z.ZodEnum<{
369
+ cascade: "cascade";
370
+ restrict: "restrict";
371
+ "no action": "no action";
372
+ "set null": "set null";
373
+ "set default": "set default";
374
+ }>>;
375
+ default: z.ZodOptional<z.ZodAny>;
376
+ check: z.ZodOptional<z.ZodString>;
377
+ }, z.core.$strict>>;
378
+ constraints: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
379
+ type: z.ZodLiteral<"primary_key">;
380
+ on: z.ZodArray<z.ZodString>;
381
+ }, z.core.$strict>, z.ZodObject<{
382
+ type: z.ZodLiteral<"foreign_key">;
383
+ on: z.ZodArray<z.ZodString>;
384
+ target: z.ZodString;
385
+ references: z.ZodArray<z.ZodString>;
386
+ }, z.core.$strict>, z.ZodObject<{
387
+ type: z.ZodLiteral<"unique">;
388
+ on: z.ZodArray<z.ZodString>;
389
+ nulls_not_distinct: z.ZodOptional<z.ZodBoolean>;
390
+ }, z.core.$strict>, z.ZodObject<{
391
+ type: z.ZodLiteral<"check">;
392
+ check: z.ZodString;
393
+ }, z.core.$strict>], "type">>>>;
394
+ }, z.core.$strict>>;
395
+ indexes: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodTemplateLiteral<`${string}:${string}`>>>>;
396
+ delta: z.ZodLiteral<false>;
397
+ }, z.core.$strict>, z.ZodObject<{
398
+ delta: z.ZodLiteral<true>;
399
+ add_tables: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
400
+ columns: z.ZodRecord<z.ZodString, z.ZodObject<{
401
+ type: z.ZodString;
402
+ required: z.ZodDefault<z.ZodBoolean>;
403
+ unique: z.ZodDefault<z.ZodBoolean>;
404
+ primary: z.ZodDefault<z.ZodBoolean>;
405
+ references: z.ZodOptional<z.ZodString>;
406
+ onDelete: z.ZodOptional<z.ZodEnum<{
407
+ cascade: "cascade";
408
+ restrict: "restrict";
409
+ "no action": "no action";
410
+ "set null": "set null";
411
+ "set default": "set default";
412
+ }>>;
413
+ default: z.ZodOptional<z.ZodAny>;
414
+ check: z.ZodOptional<z.ZodString>;
415
+ }, z.core.$strict>>;
416
+ constraints: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
417
+ type: z.ZodLiteral<"primary_key">;
418
+ on: z.ZodArray<z.ZodString>;
419
+ }, z.core.$strict>, z.ZodObject<{
420
+ type: z.ZodLiteral<"foreign_key">;
421
+ on: z.ZodArray<z.ZodString>;
422
+ target: z.ZodString;
423
+ references: z.ZodArray<z.ZodString>;
424
+ }, z.core.$strict>, z.ZodObject<{
425
+ type: z.ZodLiteral<"unique">;
426
+ on: z.ZodArray<z.ZodString>;
427
+ nulls_not_distinct: z.ZodOptional<z.ZodBoolean>;
428
+ }, z.core.$strict>, z.ZodObject<{
429
+ type: z.ZodLiteral<"check">;
430
+ check: z.ZodString;
431
+ }, z.core.$strict>], "type">>>>;
432
+ }, z.core.$strict>>>>;
433
+ drop_tables: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
434
+ alter_tables: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
435
+ add_columns: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
436
+ type: z.ZodString;
437
+ required: z.ZodDefault<z.ZodBoolean>;
438
+ unique: z.ZodDefault<z.ZodBoolean>;
439
+ primary: z.ZodDefault<z.ZodBoolean>;
440
+ references: z.ZodOptional<z.ZodString>;
441
+ onDelete: z.ZodOptional<z.ZodEnum<{
442
+ cascade: "cascade";
443
+ restrict: "restrict";
444
+ "no action": "no action";
445
+ "set null": "set null";
446
+ "set default": "set default";
447
+ }>>;
448
+ default: z.ZodOptional<z.ZodAny>;
449
+ check: z.ZodOptional<z.ZodString>;
450
+ }, z.core.$strict>>>>;
451
+ drop_columns: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
452
+ alter_columns: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
453
+ type: z.ZodOptional<z.ZodString>;
454
+ default: z.ZodOptional<z.ZodString>;
455
+ ops: z.ZodOptional<z.ZodArray<z.ZodLiteral<"drop_default" | "set_required" | "drop_required">>>;
456
+ }, z.core.$strict>>>>;
457
+ add_constraints: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
458
+ type: z.ZodLiteral<"primary_key">;
459
+ on: z.ZodArray<z.ZodString>;
460
+ }, z.core.$strict>, z.ZodObject<{
461
+ type: z.ZodLiteral<"foreign_key">;
462
+ on: z.ZodArray<z.ZodString>;
463
+ target: z.ZodString;
464
+ references: z.ZodArray<z.ZodString>;
465
+ }, z.core.$strict>, z.ZodObject<{
466
+ type: z.ZodLiteral<"unique">;
467
+ on: z.ZodArray<z.ZodString>;
468
+ nulls_not_distinct: z.ZodOptional<z.ZodBoolean>;
469
+ }, z.core.$strict>, z.ZodObject<{
470
+ type: z.ZodLiteral<"check">;
471
+ check: z.ZodString;
472
+ }, z.core.$strict>], "type">>>>;
473
+ drop_constraints: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
474
+ }, z.core.$strict>>>>;
475
+ add_indexes: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodTemplateLiteral<`${string}:${string}`>>>>;
476
+ drop_indexes: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodTemplateLiteral<`${string}:${string}`>>>>;
477
+ }, z.core.$strict>], "delta">>;
478
+ wipe: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
479
+ latest: z.ZodOptional<z.ZodNumber>;
480
+ acl_tables: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>>;
481
+ }, z.core.$strip>;
482
+ export interface SchemaFile extends z.infer<typeof SchemaFile> {
483
+ }
484
+ export declare function getSchemaFiles(): Generator<[string, SchemaFile]>;
97
485
  /**
98
- * Expected column types for a table in the database.
486
+ * Get the active schema
99
487
  */
100
- export type ColumnTypes<TableSchema extends object> = {
101
- [K in keyof TableSchema & string]: {
102
- type: string;
103
- required?: boolean;
104
- hasDefault?: boolean;
105
- };
106
- };
107
- type _Expected = {
108
- [K in keyof Schema & string]: ColumnTypes<Schema[K]>;
109
- };
110
- export interface ExpectedSchema extends _Expected {
488
+ export declare function getFullSchema(opt?: {
489
+ exclude?: string[];
490
+ }): SchemaDecl;
491
+ export declare const UpgradesInfo: z.ZodObject<{
492
+ current: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodInt>>;
493
+ upgrades: z.ZodDefault<z.ZodArray<z.ZodObject<{
494
+ timestamp: z.ZodCoercedDate<unknown>;
495
+ from: z.ZodRecord<z.ZodString, z.ZodInt>;
496
+ to: z.ZodRecord<z.ZodString, z.ZodInt>;
497
+ }, z.core.$strip>>>;
498
+ }, z.core.$strip>;
499
+ export interface UpgradesInfo extends z.infer<typeof UpgradesInfo> {
111
500
  }
112
- export declare const expectedTypes: ExpectedSchema;
501
+ export declare function getUpgradeInfo(): UpgradesInfo;
502
+ export declare function setUpgradeInfo(info: UpgradesInfo): void;
503
+ export declare function applyTableDeltaToSchema(table: Table, delta: TableDelta): void;
504
+ export declare function applyDeltaToSchema(schema: SchemaDecl, delta: VersionDelta): void;
505
+ export declare function validateDelta(delta: VersionDelta): void;
506
+ export declare function computeDelta(from: SchemaDecl, to: SchemaDecl): VersionDelta;
507
+ export declare function collapseDeltas(deltas: VersionDelta[]): VersionDelta;
508
+ export declare function deltaIsEmpty(delta: VersionDelta): boolean;
509
+ export declare function displayDelta(delta: VersionDelta): Generator<string>;
510
+ export declare function applyDelta(delta: VersionDelta, forceAbort?: boolean): Promise<void>;
113
511
  export interface CheckOptions extends OpOptions {
114
512
  /** Whether to throw an error instead of emitting a warning on most column issues */
115
513
  strict?: boolean;
@@ -126,16 +524,6 @@ export interface CheckOptions extends OpOptions {
126
524
  /**
127
525
  * Checks that a table has the expected column types, nullability, and default values.
128
526
  */
129
- export declare function checkTableTypes<TB extends keyof Schema & string>(tableName: TB, types: ColumnTypes<Schema[TB]>, opt: CheckOptions): Promise<void>;
130
- export declare function check(opt: CheckOptions): Promise<void>;
527
+ export declare function checkTableTypes<TB extends keyof Schema & string>(tableName: TB, types: Table, opt: CheckOptions): Promise<void>;
131
528
  export declare function clean(opt: Partial<OpOptions>): Promise<void>;
132
- /**
133
- * Completely remove Axium from the database.
134
- */
135
- export declare function uninstall(opt: OpOptions): Promise<void>;
136
- /**
137
- * Removes all data from tables.
138
- */
139
- export declare function wipe(opt: OpOptions): Promise<void>;
140
529
  export declare function rotatePassword(): Promise<void>;
141
- export {};