adula 2.1.0 → 2.2.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/README.md +149 -18
- package/build/agent/AGENTS.template.md +4 -4
- package/build/agent/capabilities.md +22 -11
- package/build/agent/skills/adula-frontend-design/SKILL.md +1 -1
- package/build/agent/skills/idea-review/SKILL.md +2 -2
- package/build/commands/adula_outbox.d.ts +10 -0
- package/build/commands/adula_outbox.js +11 -0
- package/build/commands/adula_restore_reconcile.d.ts +10 -0
- package/build/commands/adula_restore_reconcile.js +34 -0
- package/build/commands/adula_runtime_health.d.ts +10 -0
- package/build/commands/adula_runtime_health.js +27 -0
- package/build/commands/adula_uploads_prune.d.ts +10 -0
- package/build/commands/adula_uploads_prune.js +16 -0
- package/build/commands/app.d.ts +10 -0
- package/build/commands/app.js +64 -0
- package/build/commands/backup_create.d.ts +11 -0
- package/build/commands/backup_create.js +99 -0
- package/build/commands/backup_restore_files.d.ts +11 -0
- package/build/commands/backup_restore_files.js +44 -0
- package/build/commands/backup_restore_test.d.ts +12 -0
- package/build/commands/backup_restore_test.js +185 -0
- package/build/commands/backup_services.d.ts +31 -0
- package/build/commands/backup_services.js +6 -0
- package/build/commands/backup_verify.d.ts +9 -0
- package/build/commands/backup_verify.js +59 -0
- package/build/commands/backup_verify_snapshot.d.ts +10 -0
- package/build/commands/backup_verify_snapshot.js +37 -0
- package/build/commands/client.d.ts +16 -0
- package/build/commands/client.js +71 -0
- package/build/commands/doctor.js +4 -1
- package/build/commands/install.d.ts +8 -0
- package/build/commands/install.js +63 -45
- package/build/commands/main.d.ts +3 -2
- package/build/commands/main.js +26 -0
- package/build/commands/module_add.js +4 -20
- package/build/commands/resource.d.ts +2 -0
- package/build/commands/resource.js +12 -3
- package/build/commands/resource_migration.d.ts +15 -0
- package/build/commands/resource_migration.js +72 -0
- package/build/commands/resource_snapshot.d.ts +2 -0
- package/build/commands/resource_snapshot.js +3 -0
- package/build/commands/sla_evaluate.d.ts +14 -0
- package/build/commands/sla_evaluate.js +16 -0
- package/build/commands/ui.js +4 -2
- package/build/commands/ui_css.d.ts +9 -0
- package/build/commands/ui_css.js +19 -0
- package/build/commands/upgrade.d.ts +1 -1
- package/build/commands/upgrade.js +1 -1
- package/build/configure.js +1 -1
- package/build/database/migrations/1770000000020_two_factor.d.ts +5 -0
- package/build/database/migrations/1770000000020_two_factor.js +10 -0
- package/build/database/migrations/1770000000041_import_modes.d.ts +5 -0
- package/build/database/migrations/1770000000041_import_modes.js +10 -0
- package/build/database/migrations/1770000000042_sync_jobs.d.ts +5 -0
- package/build/database/migrations/1770000000042_sync_jobs.js +10 -0
- package/build/database/migrations/1770000000043_notification_channels.d.ts +5 -0
- package/build/database/migrations/1770000000043_notification_channels.js +10 -0
- package/build/database/migrations/1770000000044_channel_confirmations.d.ts +5 -0
- package/build/database/migrations/1770000000044_channel_confirmations.js +10 -0
- package/build/database/migrations/1770000000045_import_leases.d.ts +5 -0
- package/build/database/migrations/1770000000045_import_leases.js +10 -0
- package/build/database/migrations/1770000000046_workflow_delegation_sla.d.ts +5 -0
- package/build/database/migrations/1770000000046_workflow_delegation_sla.js +10 -0
- package/build/database/migrations/1770000000049_print_templates.d.ts +5 -0
- package/build/database/migrations/1770000000049_print_templates.js +10 -0
- package/build/index.d.ts +56 -10
- package/build/index.js +34 -6
- package/build/providers/adula_provider.d.ts +2 -0
- package/build/providers/adula_provider.js +7 -0
- package/build/src/admin/contracts.js +1 -1
- package/build/src/admin/controller.d.ts +14 -1
- package/build/src/admin/controller.js +77 -13
- package/build/src/admin/errors.d.ts +32 -0
- package/build/src/admin/errors.js +63 -1
- package/build/src/admin/presentation.d.ts +21 -2
- package/build/src/admin/resource/editor.d.ts +59 -0
- package/build/src/admin/resource/editor.js +323 -0
- package/build/src/admin/resource/export.d.ts +37 -0
- package/build/src/admin/resource/export.js +181 -0
- package/build/src/admin/resource/lifecycle.d.ts +21 -0
- package/build/src/admin/resource/lifecycle.js +91 -0
- package/build/src/admin/resource/query.d.ts +100 -0
- package/build/src/admin/resource/query.js +508 -0
- package/build/src/admin/resource/read.d.ts +106 -0
- package/build/src/admin/resource/read.js +327 -0
- package/build/src/admin/resource/shared.d.ts +77 -0
- package/build/src/admin/resource/shared.js +222 -0
- package/build/src/admin/resource/trash.d.ts +10 -0
- package/build/src/admin/resource/trash.js +56 -0
- package/build/src/admin/resource/write.d.ts +57 -0
- package/build/src/admin/resource/write.js +574 -0
- package/build/src/admin/resource_service.d.ts +66 -193
- package/build/src/admin/resource_service.js +69 -1345
- package/build/src/attachments/attachment_service.d.ts +46 -2
- package/build/src/attachments/attachment_service.js +96 -4
- package/build/src/auth/conditions.d.ts +5 -0
- package/build/src/auth/conditions.js +26 -3
- package/build/src/auth/sql.js +17 -5
- package/build/src/auth/two_factor.d.ts +96 -0
- package/build/src/auth/two_factor.js +259 -0
- package/build/src/collaboration/assignments.d.ts +36 -1
- package/build/src/collaboration/assignments.js +132 -66
- package/build/src/collaboration/record_collaboration.d.ts +2 -3
- package/build/src/collaboration/record_collaboration.js +19 -16
- package/build/src/collaboration/shared.d.ts +16 -0
- package/build/src/collaboration/shared.js +21 -0
- package/build/src/commands/app_scaffold.d.ts +72 -0
- package/build/src/commands/app_scaffold.js +285 -0
- package/build/src/commands/capabilities.js +34 -8
- package/build/src/commands/doctor.d.ts +14 -2
- package/build/src/commands/doctor.js +50 -5
- package/build/src/commands/gap_report.d.ts +1 -1
- package/build/src/commands/gap_report.js +2 -2
- package/build/src/commands/generator.d.ts +37 -1
- package/build/src/commands/generator.js +61 -18
- package/build/src/commands/snapshot.d.ts +10 -13
- package/build/src/commands/snapshot.js +31 -14
- package/build/src/commands/source_markers.d.ts +10 -0
- package/build/src/commands/source_markers.js +29 -0
- package/build/src/core/activity.d.ts +2 -0
- package/build/src/core/activity.js +7 -1
- package/build/src/core/administrators.d.ts +38 -0
- package/build/src/core/administrators.js +129 -0
- package/build/src/core/html_sanitizer.d.ts +20 -0
- package/build/src/core/html_sanitizer.js +261 -0
- package/build/src/core/like.d.ts +5 -0
- package/build/src/core/like.js +5 -0
- package/build/src/core/lookups.d.ts +80 -0
- package/build/src/core/lookups.js +319 -0
- package/build/src/core/message_templates.d.ts +7 -2
- package/build/src/core/message_templates.js +72 -11
- package/build/src/core/module_seed.js +2 -1
- package/build/src/core/notification_channels.d.ts +235 -0
- package/build/src/core/notification_channels.js +660 -0
- package/build/src/core/roles.js +2 -2
- package/build/src/core/saved_views.d.ts +8 -1
- package/build/src/core/saved_views.js +36 -2
- package/build/src/core/sequences.d.ts +32 -0
- package/build/src/core/sequences.js +97 -0
- package/build/src/core/settings.d.ts +5 -0
- package/build/src/core/settings.js +19 -2
- package/build/src/core/template_language.d.ts +61 -0
- package/build/src/core/template_language.js +141 -0
- package/build/src/core/ui_preferences.d.ts +4 -0
- package/build/src/core/ui_preferences.js +4 -1
- package/build/src/core/user_invitations.d.ts +5 -1
- package/build/src/core/user_invitations.js +7 -1
- package/build/src/core/users.js +1 -1
- package/build/src/database/calendar_days.d.ts +19 -0
- package/build/src/database/calendar_days.js +36 -0
- package/build/src/database/schema.d.ts +155 -2
- package/build/src/database/schema.js +531 -59
- package/build/src/database/schema_diff.d.ts +56 -0
- package/build/src/database/schema_diff.js +157 -0
- package/build/src/events/record_mutation.d.ts +2 -1
- package/build/src/events/record_mutation.js +1 -0
- package/build/src/integrations/api_client.d.ts +37 -0
- package/build/src/integrations/api_client.js +552 -0
- package/build/src/integrations/import_adapters.d.ts +37 -0
- package/build/src/integrations/import_adapters.js +35 -0
- package/build/src/integrations/imports.d.ts +118 -16
- package/build/src/integrations/imports.js +406 -73
- package/build/src/integrations/openapi.d.ts +3 -1
- package/build/src/integrations/openapi.js +454 -31
- package/build/src/integrations/outbound.d.ts +51 -0
- package/build/src/integrations/outbound.js +195 -0
- package/build/src/integrations/print.d.ts +21 -1
- package/build/src/integrations/print.js +63 -21
- package/build/src/integrations/print_templates.d.ts +216 -0
- package/build/src/integrations/print_templates.js +1015 -0
- package/build/src/integrations/sync_jobs.d.ts +139 -0
- package/build/src/integrations/sync_jobs.js +416 -0
- package/build/src/integrations/webhooks.d.ts +12 -12
- package/build/src/integrations/webhooks.js +34 -43
- package/build/src/languages/ar.d.ts +11 -0
- package/build/src/languages/ar.js +336 -0
- package/build/src/languages/ar_ui.d.ts +332 -0
- package/build/src/languages/ar_ui.js +333 -0
- package/build/src/languages/catalog.d.ts +66 -0
- package/build/src/languages/catalog.js +152 -0
- package/build/src/languages/en.d.ts +7 -0
- package/build/src/languages/en.js +330 -0
- package/build/src/languages/en_ui.d.ts +3 -0
- package/build/src/languages/en_ui.js +328 -0
- package/build/src/languages/validation.d.ts +26 -0
- package/build/src/languages/validation.js +60 -0
- package/build/src/lists/bulk_actions.d.ts +89 -0
- package/build/src/lists/bulk_actions.js +268 -0
- package/build/src/lists/dashboards.d.ts +96 -0
- package/build/src/lists/dashboards.js +241 -0
- package/build/src/mcp/tools.js +1 -1
- package/build/src/resource/define_resource.d.ts +18 -1
- package/build/src/resource/define_resource.js +205 -18
- package/build/src/resource/definition.d.ts +44 -0
- package/build/src/resource/definition.js +171 -0
- package/build/src/resource/registry.js +15 -4
- package/build/src/resource/types.d.ts +304 -16
- package/build/src/resource/values.d.ts +56 -1
- package/build/src/resource/values.js +237 -5
- package/build/src/services/settings.d.ts +2 -0
- package/build/src/services/settings.js +5 -1
- package/build/src/upgrade/legacy.js +2 -2
- package/build/src/workflows/calendar.d.ts +9 -0
- package/build/src/workflows/calendar.js +44 -0
- package/build/src/workflows/define_workflow.d.ts +48 -3
- package/build/src/workflows/define_workflow.js +57 -13
- package/build/src/workflows/delegations.d.ts +93 -0
- package/build/src/workflows/delegations.js +287 -0
- package/build/src/workflows/engine.d.ts +69 -4
- package/build/src/workflows/engine.js +441 -83
- package/build/src/workflows/sla.d.ts +15 -0
- package/build/src/workflows/sla.js +8 -0
- package/build/stubs/resource_contract.txt +12 -1
- package/package.json +5 -2
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { BaseCommand, flags } from '@adonisjs/core/ace';
|
|
8
|
+
import { resolve, join, basename } from 'node:path';
|
|
9
|
+
import { createReadStream } from 'node:fs';
|
|
10
|
+
import { stat, writeFile } from 'node:fs/promises';
|
|
11
|
+
import { applicationEnv, backupSnapshotService } from './backup_services.js';
|
|
12
|
+
export default class BackupCreate extends BaseCommand {
|
|
13
|
+
static commandName = 'backup:create';
|
|
14
|
+
static description = 'Create a consistent database and all-disk attachment snapshot; publish COMPLETE last';
|
|
15
|
+
static options = { startApp: true };
|
|
16
|
+
async run() {
|
|
17
|
+
const env = await applicationEnv(this.app);
|
|
18
|
+
const { default: db } = await import('@adonisjs/lucid/services/db');
|
|
19
|
+
const { Settings } = await import('../src/services/settings.js');
|
|
20
|
+
const { createSnapshot } = await backupSnapshotService(this.app);
|
|
21
|
+
const { publishSnapshot } = (await this.app.import('#services/backup_publish'));
|
|
22
|
+
const directory = resolve(this.snapshot);
|
|
23
|
+
const bucket = env.get('BACKUP_S3_BUCKET');
|
|
24
|
+
const prefix = this.prefix ?? `${env.get('BACKUP_S3_PREFIX') ?? 'adula'}/${basename(directory)}/`;
|
|
25
|
+
if (!/^adula\/[a-zA-Z0-9/_-]+\/$/.test(prefix) || prefix.includes('//'))
|
|
26
|
+
throw new Error('Invalid offsite prefix');
|
|
27
|
+
const { S3Client, PutObjectCommand, GetObjectCommand, HeadObjectCommand } = bucket
|
|
28
|
+
? (await this.app.import('@aws-sdk/client-s3'))
|
|
29
|
+
: {};
|
|
30
|
+
const client = bucket
|
|
31
|
+
? new S3Client({
|
|
32
|
+
region: env.get('BACKUP_S3_REGION'),
|
|
33
|
+
endpoint: env.get('BACKUP_S3_ENDPOINT'),
|
|
34
|
+
credentials: {
|
|
35
|
+
accessKeyId: env.get('BACKUP_S3_ACCESS_KEY_ID'),
|
|
36
|
+
secretAccessKey: env.get('BACKUP_S3_SECRET_ACCESS_KEY'),
|
|
37
|
+
},
|
|
38
|
+
})
|
|
39
|
+
: null;
|
|
40
|
+
try {
|
|
41
|
+
if (client) {
|
|
42
|
+
try {
|
|
43
|
+
await client.send(new HeadObjectCommand({ Bucket: bucket, Key: prefix + 'COMPLETE' }));
|
|
44
|
+
throw new Error('Refusing to overwrite a complete offsite snapshot');
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
if (error.$metadata?.httpStatusCode !== 404)
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
await createSnapshot(directory);
|
|
52
|
+
if (client) {
|
|
53
|
+
await publishSnapshot(directory, {
|
|
54
|
+
exists: async () => {
|
|
55
|
+
try {
|
|
56
|
+
await client.send(new HeadObjectCommand({ Bucket: bucket, Key: prefix + 'COMPLETE' }));
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
if (error.$metadata?.httpStatusCode ===
|
|
61
|
+
404)
|
|
62
|
+
return false;
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
put: async (name, path) => {
|
|
67
|
+
const info = path ? await stat(path) : null;
|
|
68
|
+
await client.send(new PutObjectCommand({
|
|
69
|
+
Bucket: bucket,
|
|
70
|
+
Key: prefix + name,
|
|
71
|
+
Body: path ? createReadStream(path) : '',
|
|
72
|
+
ContentLength: info?.size ?? 0,
|
|
73
|
+
}));
|
|
74
|
+
},
|
|
75
|
+
read: async (name) => {
|
|
76
|
+
const response = await client.send(new GetObjectCommand({ Bucket: bucket, Key: prefix + name }));
|
|
77
|
+
if (!response.Body)
|
|
78
|
+
throw new Error('Missing offsite body: ' + name);
|
|
79
|
+
return response.Body;
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
await new Settings(db.connection().getWriteClient()).set('backup.lastOffsite', new Date().toISOString());
|
|
83
|
+
}
|
|
84
|
+
await writeFile(join(directory, 'COMPLETE'), '');
|
|
85
|
+
this.logger.success(`Backup complete: ${directory}`);
|
|
86
|
+
}
|
|
87
|
+
finally {
|
|
88
|
+
client?.destroy();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
__decorate([
|
|
93
|
+
flags.string({ required: true, description: 'New snapshot directory (must not exist)' })
|
|
94
|
+
], BackupCreate.prototype, "snapshot", void 0);
|
|
95
|
+
__decorate([
|
|
96
|
+
flags.string({
|
|
97
|
+
description: 'Offsite key prefix (defaults to adula/<snapshot directory name>/)',
|
|
98
|
+
})
|
|
99
|
+
], BackupCreate.prototype, "prefix", void 0);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BaseCommand } from '@adonisjs/core/ace';
|
|
2
|
+
export default class BackupRestoreFiles extends BaseCommand {
|
|
3
|
+
static commandName: string;
|
|
4
|
+
static description: string;
|
|
5
|
+
static options: {
|
|
6
|
+
startApp: boolean;
|
|
7
|
+
};
|
|
8
|
+
snapshot: string;
|
|
9
|
+
apply: boolean;
|
|
10
|
+
run(): Promise<void>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { BaseCommand, flags } from '@adonisjs/core/ace';
|
|
8
|
+
import { mkdtemp, rm } from 'node:fs/promises';
|
|
9
|
+
import { tmpdir } from 'node:os';
|
|
10
|
+
import { join, resolve } from 'node:path';
|
|
11
|
+
import { backupSnapshotService } from './backup_services.js';
|
|
12
|
+
export default class BackupRestoreFiles extends BaseCommand {
|
|
13
|
+
static commandName = 'backup:restore-files';
|
|
14
|
+
static description = 'Restore verified attachment bytes to their original disks after database recovery';
|
|
15
|
+
static options = { startApp: true };
|
|
16
|
+
async run() {
|
|
17
|
+
if (!this.apply)
|
|
18
|
+
throw new Error('Use --apply after restoring the database with application traffic stopped');
|
|
19
|
+
const { default: db } = await import('@adonisjs/lucid/services/db');
|
|
20
|
+
const { verifySnapshot, extractSnapshot, verifyAttachments, restoreAttachments } = await backupSnapshotService(this.app);
|
|
21
|
+
const snapshot = resolve(this.snapshot);
|
|
22
|
+
const files = await verifySnapshot(snapshot);
|
|
23
|
+
if (!files)
|
|
24
|
+
throw new Error('Legacy snapshots must use the local-files restore script');
|
|
25
|
+
const extracted = await mkdtemp(join(tmpdir(), 'adula-recovery-'));
|
|
26
|
+
try {
|
|
27
|
+
await extractSnapshot(snapshot, extracted);
|
|
28
|
+
await verifyAttachments(files, extracted, await db.connection().getWriteClient()('attachments').select('*'));
|
|
29
|
+
await restoreAttachments(files, extracted, false);
|
|
30
|
+
this.logger.success(`Restored and verified ${files.length} attachments on their original disks`);
|
|
31
|
+
}
|
|
32
|
+
finally {
|
|
33
|
+
await rm(extracted, { recursive: true, force: true });
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
__decorate([
|
|
38
|
+
flags.string({ required: true })
|
|
39
|
+
], BackupRestoreFiles.prototype, "snapshot", void 0);
|
|
40
|
+
__decorate([
|
|
41
|
+
flags.boolean({
|
|
42
|
+
description: 'Write original attachment keys; stop application traffic before recovery',
|
|
43
|
+
})
|
|
44
|
+
], BackupRestoreFiles.prototype, "apply", void 0);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BaseCommand } from '@adonisjs/core/ace';
|
|
2
|
+
export default class BackupRestoreTest extends BaseCommand {
|
|
3
|
+
static commandName: string;
|
|
4
|
+
static description: string;
|
|
5
|
+
static options: {
|
|
6
|
+
startApp: boolean;
|
|
7
|
+
};
|
|
8
|
+
dir: string;
|
|
9
|
+
snapshot: string;
|
|
10
|
+
allowEmpty: boolean;
|
|
11
|
+
run(): Promise<void>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { BaseCommand, flags } from '@adonisjs/core/ace';
|
|
8
|
+
import { execFile } from 'node:child_process';
|
|
9
|
+
import { randomUUID } from 'node:crypto';
|
|
10
|
+
import { mkdtemp, readdir, rm, stat } from 'node:fs/promises';
|
|
11
|
+
import { tmpdir } from 'node:os';
|
|
12
|
+
import { join, resolve } from 'node:path';
|
|
13
|
+
import { promisify } from 'node:util';
|
|
14
|
+
import { applicationEnv, backupSnapshotService } from './backup_services.js';
|
|
15
|
+
const run = promisify(execFile);
|
|
16
|
+
const SNAPSHOT = /^\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}Z$/;
|
|
17
|
+
async function latestSnapshot(directory) {
|
|
18
|
+
const entries = await readdir(directory, { withFileTypes: true });
|
|
19
|
+
const candidates = [];
|
|
20
|
+
for (const entry of entries) {
|
|
21
|
+
if (!entry.isDirectory() || !SNAPSHOT.test(entry.name))
|
|
22
|
+
continue;
|
|
23
|
+
try {
|
|
24
|
+
await stat(join(directory, entry.name, 'COMPLETE'));
|
|
25
|
+
candidates.push(entry.name);
|
|
26
|
+
}
|
|
27
|
+
catch { }
|
|
28
|
+
}
|
|
29
|
+
if (!candidates.length)
|
|
30
|
+
throw new Error(`No complete snapshot found under ${directory}`);
|
|
31
|
+
return join(directory, candidates.sort().at(-1));
|
|
32
|
+
}
|
|
33
|
+
export default class BackupRestoreTest extends BaseCommand {
|
|
34
|
+
static commandName = 'backup:restore-test';
|
|
35
|
+
static description = 'Restore the latest snapshot into a temporary database and verify a record together with its attachment file';
|
|
36
|
+
static options = { startApp: true };
|
|
37
|
+
async run() {
|
|
38
|
+
const { default: db } = await import('@adonisjs/lucid/services/db');
|
|
39
|
+
const env = await applicationEnv(this.app);
|
|
40
|
+
const { Settings } = await import('../src/services/settings.js');
|
|
41
|
+
const { isRelativeDiskPath } = await import('../src/attachments/attachment_service.js');
|
|
42
|
+
const { registry } = (await this.app.import('#start/modules'));
|
|
43
|
+
const { verifySnapshot, extractSnapshot, verifyAttachments, restoreAttachments } = await backupSnapshotService(this.app);
|
|
44
|
+
const live = db.connection().getWriteClient();
|
|
45
|
+
const settings = new Settings(live);
|
|
46
|
+
const startedAt = new Date();
|
|
47
|
+
const report = { startedAt: startedAt.toISOString(), status: 'failed' };
|
|
48
|
+
const stamp = startedAt
|
|
49
|
+
.toISOString()
|
|
50
|
+
.replace(/[-:]/g, '')
|
|
51
|
+
.replace(/\.\d+Z$/, '')
|
|
52
|
+
.toLowerCase();
|
|
53
|
+
const database = `${env.get('DB_DATABASE').slice(0, 20)}_restore_${stamp}_${randomUUID().slice(0, 8)}_test`;
|
|
54
|
+
const pgEnv = {
|
|
55
|
+
...process.env,
|
|
56
|
+
PGHOST: env.get('DB_HOST'),
|
|
57
|
+
PGPORT: String(env.get('DB_PORT')),
|
|
58
|
+
PGUSER: env.get('DB_USER'),
|
|
59
|
+
PGPASSWORD: env.get('DB_PASSWORD'),
|
|
60
|
+
};
|
|
61
|
+
let extracted;
|
|
62
|
+
let connected = false;
|
|
63
|
+
let created = false;
|
|
64
|
+
try {
|
|
65
|
+
const snapshot = this.snapshot
|
|
66
|
+
? resolve(this.snapshot)
|
|
67
|
+
: await latestSnapshot(resolve(this.dir ?? '/backups'));
|
|
68
|
+
report.snapshot = snapshot;
|
|
69
|
+
const files = await verifySnapshot(snapshot);
|
|
70
|
+
await live.raw('CREATE DATABASE ??', [database]);
|
|
71
|
+
created = true;
|
|
72
|
+
report.database = database;
|
|
73
|
+
await run('pg_restore', [
|
|
74
|
+
'--no-owner',
|
|
75
|
+
'--no-privileges',
|
|
76
|
+
'--exit-on-error',
|
|
77
|
+
`--dbname=${database}`,
|
|
78
|
+
join(snapshot, 'database.dump'),
|
|
79
|
+
], { env: pgEnv, windowsHide: true, timeout: 600000, maxBuffer: 16 * 1024 * 1024 });
|
|
80
|
+
extracted = await mkdtemp(join(tmpdir(), 'adula-restore-'));
|
|
81
|
+
await extractSnapshot(snapshot, extracted);
|
|
82
|
+
db.manager.add(database, {
|
|
83
|
+
client: 'pg',
|
|
84
|
+
connection: {
|
|
85
|
+
host: env.get('DB_HOST'),
|
|
86
|
+
port: env.get('DB_PORT'),
|
|
87
|
+
user: env.get('DB_USER'),
|
|
88
|
+
password: env.get('DB_PASSWORD'),
|
|
89
|
+
database,
|
|
90
|
+
},
|
|
91
|
+
pool: { min: 0, max: 2 },
|
|
92
|
+
});
|
|
93
|
+
connected = true;
|
|
94
|
+
const restored = db.connection(database).getWriteClient();
|
|
95
|
+
const tables = {};
|
|
96
|
+
for (const resource of registry.all()) {
|
|
97
|
+
const count = await restored(resource.name)
|
|
98
|
+
.whereNull('deleted_at')
|
|
99
|
+
.count('* as count')
|
|
100
|
+
.first();
|
|
101
|
+
tables[resource.name] = Number(count?.count ?? 0);
|
|
102
|
+
}
|
|
103
|
+
const attachments = await restored('attachments')
|
|
104
|
+
.whereNull('deleted_at')
|
|
105
|
+
.count('* as count')
|
|
106
|
+
.first();
|
|
107
|
+
tables.attachments = Number(attachments?.count ?? 0);
|
|
108
|
+
report.tables = tables;
|
|
109
|
+
if (files) {
|
|
110
|
+
await verifyAttachments(files, extracted, await restored('attachments').select('*'));
|
|
111
|
+
await restoreAttachments(files, extracted, true);
|
|
112
|
+
report.verifiedFiles = files.length;
|
|
113
|
+
}
|
|
114
|
+
else if (await restored('attachments').whereNot('disk', 'local').first()) {
|
|
115
|
+
throw new Error('Legacy snapshot does not contain non-local attachments');
|
|
116
|
+
}
|
|
117
|
+
const candidate = await restored('attachments')
|
|
118
|
+
.whereNull('deleted_at')
|
|
119
|
+
.whereNotNull('record_id')
|
|
120
|
+
.orderBy('id', 'desc')
|
|
121
|
+
.first();
|
|
122
|
+
if (!candidate) {
|
|
123
|
+
if (!this.allowEmpty)
|
|
124
|
+
throw new Error('No record with an attachment exists in the snapshot; the drill cannot verify a file');
|
|
125
|
+
report.attachment = null;
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
const resource = registry.all().find((entry) => entry.name === candidate.resource);
|
|
129
|
+
if (!resource)
|
|
130
|
+
throw new Error(`Attachment ${candidate.id} belongs to unknown resource ${candidate.resource}`);
|
|
131
|
+
const record = await restored(resource.name)
|
|
132
|
+
.where('id', candidate.record_id)
|
|
133
|
+
.whereNull('deleted_at')
|
|
134
|
+
.first('id');
|
|
135
|
+
if (!record)
|
|
136
|
+
throw new Error(`Record ${candidate.resource}#${candidate.record_id} for attachment ${candidate.id} is missing from the restored database`);
|
|
137
|
+
if (!isRelativeDiskPath(candidate.path))
|
|
138
|
+
throw new Error(`Unsafe attachment path: ${candidate.path}`);
|
|
139
|
+
const file = await stat(join(extracted, files ? `${candidate.id}.bin` : candidate.path)).catch(() => undefined);
|
|
140
|
+
if (!file || !file.isFile())
|
|
141
|
+
throw new Error(`Attachment ${candidate.id} file ${candidate.path} is missing from uploads.tar.gz`);
|
|
142
|
+
if (file.size !== Number(candidate.size))
|
|
143
|
+
throw new Error(`Attachment ${candidate.id} file ${candidate.path} has ${file.size} bytes, expected ${candidate.size}`);
|
|
144
|
+
report.attachment = {
|
|
145
|
+
id: Number(candidate.id),
|
|
146
|
+
resource: String(candidate.resource),
|
|
147
|
+
recordId: Number(candidate.record_id),
|
|
148
|
+
field: String(candidate.field),
|
|
149
|
+
path: String(candidate.path),
|
|
150
|
+
size: Number(candidate.size),
|
|
151
|
+
fileVerified: true,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
report.status = 'passed';
|
|
155
|
+
report.finishedAt = new Date().toISOString();
|
|
156
|
+
await settings.set('backup.lastRestoreTest', report.finishedAt);
|
|
157
|
+
await settings.set('backup.lastRestoreTestReport', report);
|
|
158
|
+
this.logger.success(`Restore drill passed: ${JSON.stringify(report)}`);
|
|
159
|
+
}
|
|
160
|
+
catch (error) {
|
|
161
|
+
report.error = error instanceof Error ? error.message : String(error);
|
|
162
|
+
report.finishedAt = new Date().toISOString();
|
|
163
|
+
await settings.set('backup.lastRestoreTestReport', report);
|
|
164
|
+
this.logger.error(`Restore drill failed: ${JSON.stringify(report)}`);
|
|
165
|
+
this.exitCode = 1;
|
|
166
|
+
}
|
|
167
|
+
finally {
|
|
168
|
+
if (connected)
|
|
169
|
+
await db.manager.close(database, true);
|
|
170
|
+
if (created)
|
|
171
|
+
await live.raw('DROP DATABASE IF EXISTS ?? WITH (FORCE)', [database]);
|
|
172
|
+
if (extracted)
|
|
173
|
+
await rm(extracted, { recursive: true, force: true });
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
__decorate([
|
|
178
|
+
flags.string({ description: 'Directory that holds dated snapshots (default: /backups)' })
|
|
179
|
+
], BackupRestoreTest.prototype, "dir", void 0);
|
|
180
|
+
__decorate([
|
|
181
|
+
flags.string({ description: 'Explicit snapshot directory instead of the latest one' })
|
|
182
|
+
], BackupRestoreTest.prototype, "snapshot", void 0);
|
|
183
|
+
__decorate([
|
|
184
|
+
flags.boolean({ description: 'Pass even when no record carries an attachment' })
|
|
185
|
+
], BackupRestoreTest.prototype, "allowEmpty", void 0);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ApplicationService } from '@adonisjs/core/types';
|
|
2
|
+
/**
|
|
3
|
+
* The backup commands ship with the package, while the snapshot format, the Drive disks and
|
|
4
|
+
* the validated environment belong to the application. They are resolved through the
|
|
5
|
+
* application's importer, so `#start/env` and `#services/backup_*` are the application's own.
|
|
6
|
+
*/
|
|
7
|
+
export type ArchivedAttachment = {
|
|
8
|
+
id: number;
|
|
9
|
+
disk: string;
|
|
10
|
+
path: string;
|
|
11
|
+
size: number;
|
|
12
|
+
sha256: string;
|
|
13
|
+
};
|
|
14
|
+
export type BackupSnapshotService = {
|
|
15
|
+
createSnapshot(directory: string): Promise<void>;
|
|
16
|
+
verifySnapshot(directory: string): Promise<ArchivedAttachment[] | null>;
|
|
17
|
+
extractSnapshot(directory: string, target: string): Promise<void>;
|
|
18
|
+
verifyAttachments(files: ArchivedAttachment[], extracted: string, rows: Record<string, any>[]): Promise<void>;
|
|
19
|
+
restoreAttachments(files: ArchivedAttachment[], extracted: string, drill: boolean): Promise<void>;
|
|
20
|
+
};
|
|
21
|
+
export type SnapshotTransport = {
|
|
22
|
+
exists(): Promise<boolean>;
|
|
23
|
+
put(name: string, file?: string): Promise<void>;
|
|
24
|
+
read(name: string): Promise<AsyncIterable<Uint8Array>>;
|
|
25
|
+
};
|
|
26
|
+
/** The application's validated environment (`#start/env`). */
|
|
27
|
+
export type ApplicationEnv = {
|
|
28
|
+
get(key: string): any;
|
|
29
|
+
};
|
|
30
|
+
export declare function applicationEnv(app: ApplicationService): Promise<ApplicationEnv>;
|
|
31
|
+
export declare function backupSnapshotService(app: ApplicationService): Promise<BackupSnapshotService>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { BaseCommand } from '@adonisjs/core/ace';
|
|
2
|
+
import { execFile } from 'node:child_process';
|
|
3
|
+
import { promisify } from 'node:util';
|
|
4
|
+
import { applicationEnv } from './backup_services.js';
|
|
5
|
+
export default class BackupVerify extends BaseCommand {
|
|
6
|
+
static commandName = 'backup:verify';
|
|
7
|
+
static description = 'Verify recent database, uploads and checksum objects in offsite storage';
|
|
8
|
+
static options = { startApp: true };
|
|
9
|
+
async run() {
|
|
10
|
+
const { verifyBackup } = await import('../src/services/backup.js');
|
|
11
|
+
const { default: db } = await import('@adonisjs/lucid/services/db');
|
|
12
|
+
const env = await applicationEnv(this.app);
|
|
13
|
+
const prefix = env.get('BACKUP_S3_PREFIX') ?? 'adula';
|
|
14
|
+
const status = await verifyBackup(db.connection().getWriteClient(), async () => {
|
|
15
|
+
const endpoint = env.get('BACKUP_S3_ENDPOINT');
|
|
16
|
+
const bucket = env.get('BACKUP_S3_BUCKET');
|
|
17
|
+
if (!endpoint || !bucket)
|
|
18
|
+
throw new Error('Offsite storage is not configured');
|
|
19
|
+
const { stdout } = await promisify(execFile)('aws', [
|
|
20
|
+
'--endpoint-url',
|
|
21
|
+
endpoint,
|
|
22
|
+
's3api',
|
|
23
|
+
'list-objects-v2',
|
|
24
|
+
'--bucket',
|
|
25
|
+
bucket,
|
|
26
|
+
'--prefix',
|
|
27
|
+
prefix + '/',
|
|
28
|
+
'--output',
|
|
29
|
+
'json',
|
|
30
|
+
], {
|
|
31
|
+
timeout: 60000,
|
|
32
|
+
maxBuffer: 16 * 1024 * 1024,
|
|
33
|
+
windowsHide: true,
|
|
34
|
+
env: {
|
|
35
|
+
...process.env,
|
|
36
|
+
AWS_ACCESS_KEY_ID: env.get('BACKUP_S3_ACCESS_KEY_ID'),
|
|
37
|
+
AWS_SECRET_ACCESS_KEY: env.get('BACKUP_S3_SECRET_ACCESS_KEY'),
|
|
38
|
+
AWS_DEFAULT_REGION: env.get('BACKUP_S3_REGION'),
|
|
39
|
+
AWS_PAGER: '',
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
const result = JSON.parse(stdout);
|
|
43
|
+
return (result.Contents ?? []).map((item) => ({
|
|
44
|
+
key: item.Key,
|
|
45
|
+
size: item.Size,
|
|
46
|
+
modifiedAt: item.LastModified,
|
|
47
|
+
}));
|
|
48
|
+
}, Date.now(), prefix);
|
|
49
|
+
const { Settings } = await import('../src/services/settings.js');
|
|
50
|
+
const { backupFingerprint } = (await this.app.import('#services/initial_setup'));
|
|
51
|
+
await new Settings(db.connection().getWriteClient()).set('setup.backup_check', {
|
|
52
|
+
fingerprint: backupFingerprint(),
|
|
53
|
+
at: status.checkedAt,
|
|
54
|
+
});
|
|
55
|
+
this.logger.log(JSON.stringify(status));
|
|
56
|
+
if (!status.healthy)
|
|
57
|
+
this.exitCode = 1;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BaseCommand } from '@adonisjs/core/ace';
|
|
2
|
+
export default class BackupVerifySnapshot extends BaseCommand {
|
|
3
|
+
static commandName: string;
|
|
4
|
+
static description: string;
|
|
5
|
+
static options: {
|
|
6
|
+
startApp: boolean;
|
|
7
|
+
};
|
|
8
|
+
snapshot: string;
|
|
9
|
+
run(): Promise<void>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { BaseCommand, flags } from '@adonisjs/core/ace';
|
|
8
|
+
import { mkdtemp, rm } from 'node:fs/promises';
|
|
9
|
+
import { tmpdir } from 'node:os';
|
|
10
|
+
import { join, resolve } from 'node:path';
|
|
11
|
+
import { applicationEnv, backupSnapshotService } from './backup_services.js';
|
|
12
|
+
export default class BackupVerifySnapshot extends BaseCommand {
|
|
13
|
+
static commandName = 'backup:verify-snapshot';
|
|
14
|
+
static description = 'Validate snapshot checksums, manifest and archive before database recovery';
|
|
15
|
+
static options = { startApp: true };
|
|
16
|
+
async run() {
|
|
17
|
+
const { verifySnapshot, extractSnapshot, verifyAttachments } = await backupSnapshotService(this.app);
|
|
18
|
+
const env = await applicationEnv(this.app);
|
|
19
|
+
const directory = resolve(this.snapshot);
|
|
20
|
+
const files = await verifySnapshot(directory);
|
|
21
|
+
if (!files && env.get('DRIVE_DISK') !== 'local')
|
|
22
|
+
throw new Error('Legacy snapshot does not contain S3 attachments');
|
|
23
|
+
const extracted = await mkdtemp(join(tmpdir(), 'adula-verify-'));
|
|
24
|
+
try {
|
|
25
|
+
await extractSnapshot(directory, extracted);
|
|
26
|
+
if (files)
|
|
27
|
+
await verifyAttachments(files, extracted, files);
|
|
28
|
+
this.logger.success('Snapshot integrity verified');
|
|
29
|
+
}
|
|
30
|
+
finally {
|
|
31
|
+
await rm(extracted, { recursive: true, force: true });
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
__decorate([
|
|
36
|
+
flags.string({ required: true })
|
|
37
|
+
], BackupVerifySnapshot.prototype, "snapshot", void 0);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BaseCommand } from '@adonisjs/core/ace';
|
|
2
|
+
/**
|
|
3
|
+
* Writes clients/<system>/index.ts, a typed API client of every registered resource
|
|
4
|
+
* (or of what one user may use), and its README with token usage.
|
|
5
|
+
*/
|
|
6
|
+
export default class Client extends BaseCommand {
|
|
7
|
+
static commandName: string;
|
|
8
|
+
static description: string;
|
|
9
|
+
static options: {
|
|
10
|
+
startApp: boolean;
|
|
11
|
+
};
|
|
12
|
+
asUser: number | undefined;
|
|
13
|
+
url: string | undefined;
|
|
14
|
+
output: string | undefined;
|
|
15
|
+
run(): Promise<void>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { BaseCommand, flags } from '@adonisjs/core/ace';
|
|
8
|
+
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
9
|
+
import { isAbsolute } from 'node:path';
|
|
10
|
+
import { ActorStore } from '../src/auth/actor_store.js';
|
|
11
|
+
import { openApiDocument } from '../src/integrations/openapi.js';
|
|
12
|
+
import { apiClientName, apiClientReadme, apiClientSource } from '../src/integrations/api_client.js';
|
|
13
|
+
import { ADULA_VERSION } from '../src/version.js';
|
|
14
|
+
/**
|
|
15
|
+
* Writes clients/<system>/index.ts, a typed API client of every registered resource
|
|
16
|
+
* (or of what one user may use), and its README with token usage.
|
|
17
|
+
*/
|
|
18
|
+
export default class Client extends BaseCommand {
|
|
19
|
+
static commandName = 'adula:client';
|
|
20
|
+
static description = 'Generate a typed TypeScript client of the bearer-token resource API in clients/<system>/';
|
|
21
|
+
static options = { startApp: true };
|
|
22
|
+
async run() {
|
|
23
|
+
const { registry } = (await this.app.import('#start/modules'));
|
|
24
|
+
let actor;
|
|
25
|
+
if (this.asUser !== undefined) {
|
|
26
|
+
if (!Number.isSafeInteger(this.asUser) || this.asUser <= 0) {
|
|
27
|
+
this.logger.error('--as-user must be a user id');
|
|
28
|
+
this.exitCode = 1;
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const { default: db } = await import('@adonisjs/lucid/services/db');
|
|
32
|
+
const knex = db.connection().getWriteClient();
|
|
33
|
+
if (!(await knex('users').where('id', this.asUser).first('id'))) {
|
|
34
|
+
this.logger.error(`No user with id ${this.asUser}`);
|
|
35
|
+
this.exitCode = 1;
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
actor = await new ActorStore(knex, registry).load(this.asUser);
|
|
39
|
+
}
|
|
40
|
+
let name = 'app';
|
|
41
|
+
try {
|
|
42
|
+
name = apiClientName(JSON.parse(await readFile(this.app.makePath('package.json'), 'utf8')).name);
|
|
43
|
+
}
|
|
44
|
+
catch { }
|
|
45
|
+
const document = openApiDocument(registry, {
|
|
46
|
+
title: name,
|
|
47
|
+
version: ADULA_VERSION,
|
|
48
|
+
serverUrl: this.url ?? process.env.APP_URL ?? 'http://localhost:3333',
|
|
49
|
+
actor,
|
|
50
|
+
});
|
|
51
|
+
const output = this.output ?? `clients/${name}`;
|
|
52
|
+
const directory = isAbsolute(output) ? output : this.app.makePath(output);
|
|
53
|
+
await mkdir(directory, { recursive: true });
|
|
54
|
+
await writeFile(`${directory}/index.ts`, apiClientSource(document));
|
|
55
|
+
await writeFile(`${directory}/README.md`, apiClientReadme(name, document));
|
|
56
|
+
this.logger.success(`${directory}/index.ts`);
|
|
57
|
+
this.logger.success(`${directory}/README.md`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
__decorate([
|
|
61
|
+
flags.number({
|
|
62
|
+
flagName: 'as-user',
|
|
63
|
+
description: 'Describe only what this user id may use (default: the full registry)',
|
|
64
|
+
})
|
|
65
|
+
], Client.prototype, "asUser", void 0);
|
|
66
|
+
__decorate([
|
|
67
|
+
flags.string({ description: 'Default server URL in the client (default: APP_URL)' })
|
|
68
|
+
], Client.prototype, "url", void 0);
|
|
69
|
+
__decorate([
|
|
70
|
+
flags.string({ description: 'Output directory (default: clients/<system name>)' })
|
|
71
|
+
], Client.prototype, "output", void 0);
|
package/build/commands/doctor.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseCommand } from '@adonisjs/core/ace';
|
|
2
2
|
import { fileURLToPath } from 'node:url';
|
|
3
|
-
import { diagnose, diagnoseResourceSnapshots, diagnoseOutbox, diagnoseWorkflowRoles, } from '../src/commands/doctor.js';
|
|
3
|
+
import { diagnose, diagnoseResourceSnapshots, diagnoseResourceSchemas, diagnoseOutbox, diagnoseWorkflowRoles, } from '../src/commands/doctor.js';
|
|
4
4
|
import { runtimeHealth } from '../src/core/health.js';
|
|
5
5
|
import { diagnoseAttachments } from '../src/attachments/doctor.js';
|
|
6
6
|
import { Settings } from '../src/services/settings.js';
|
|
@@ -64,6 +64,9 @@ export default class Doctor extends BaseCommand {
|
|
|
64
64
|
return undefined;
|
|
65
65
|
}
|
|
66
66
|
}));
|
|
67
|
+
// Tables of resources whose create-migration is still pending are reported missing.
|
|
68
|
+
if (registry)
|
|
69
|
+
findings.push(await diagnoseResourceSchemas(db.connection().getWriteClient(), registry.all()));
|
|
67
70
|
for (const finding of findings)
|
|
68
71
|
this.logger.log(`${finding.status.toUpperCase()} ${finding.check}: ${finding.message}`);
|
|
69
72
|
if (findings.some((finding) => finding.status === 'fail'))
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import { BaseCommand } from '@adonisjs/core/ace';
|
|
2
|
+
/**
|
|
3
|
+
* Installs the core organization, administrator role and managed agent instructions.
|
|
4
|
+
* Creating or re-securing the first administrator requires the application's `#models/user`
|
|
5
|
+
* Lucid model (with `email`, `fullName` and a hashed `password`); it is loaded only then.
|
|
6
|
+
*/
|
|
2
7
|
export default class Install extends BaseCommand {
|
|
3
8
|
static commandName: string;
|
|
4
9
|
static description: string;
|
|
5
10
|
static options: {
|
|
6
11
|
startApp: boolean;
|
|
7
12
|
};
|
|
13
|
+
adminEmail?: string;
|
|
14
|
+
adminName?: string;
|
|
15
|
+
keepPassword?: boolean;
|
|
8
16
|
run(): Promise<void>;
|
|
9
17
|
}
|