adula 2.1.0 → 2.3.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 -12
- package/build/agent/skills/adula-frontend-design/SKILL.md +6 -4
- package/build/agent/skills/idea-review/SKILL.md +2 -2
- package/build/commands/adula_assistant_prune.d.ts +10 -0
- package/build/commands/adula_assistant_prune.js +12 -0
- 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_open.d.ts +16 -0
- package/build/commands/backup_open.js +48 -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 +188 -0
- package/build/commands/backup_seal.d.ts +12 -0
- package/build/commands/backup_seal.js +36 -0
- package/build/commands/backup_services.d.ts +33 -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 +21 -1
- package/build/commands/install.d.ts +8 -0
- package/build/commands/install.js +69 -45
- package/build/commands/main.d.ts +3 -2
- package/build/commands/main.js +32 -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 +81 -0
- package/build/commands/resource_snapshot.d.ts +2 -0
- package/build/commands/resource_snapshot.js +21 -4
- 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/database/migrations/1770000000051_comment_notifications.d.ts +5 -0
- package/build/database/migrations/1770000000051_comment_notifications.js +10 -0
- package/build/database/migrations/1770000000054_cloud_backups.d.ts +5 -0
- package/build/database/migrations/1770000000054_cloud_backups.js +10 -0
- package/build/database/migrations/1770000000055_ai_assistant.d.ts +5 -0
- package/build/database/migrations/1770000000055_ai_assistant.js +10 -0
- package/build/database/migrations/1770000000056_appearance.d.ts +5 -0
- package/build/database/migrations/1770000000056_appearance.js +10 -0
- package/build/index.d.ts +87 -11
- package/build/index.js +50 -7
- 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 +91 -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 +60 -0
- package/build/src/admin/resource/editor.js +345 -0
- package/build/src/admin/resource/export.d.ts +54 -0
- package/build/src/admin/resource/export.js +262 -0
- package/build/src/admin/resource/lifecycle.d.ts +23 -0
- package/build/src/admin/resource/lifecycle.js +91 -0
- package/build/src/admin/resource/query.d.ts +111 -0
- package/build/src/admin/resource/query.js +595 -0
- package/build/src/admin/resource/read.d.ts +109 -0
- package/build/src/admin/resource/read.js +388 -0
- package/build/src/admin/resource/shared.d.ts +93 -0
- package/build/src/admin/resource/shared.js +265 -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 +603 -0
- package/build/src/admin/resource_service.d.ts +80 -193
- package/build/src/admin/resource_service.js +81 -1343
- package/build/src/admin/resource_tools.d.ts +111 -0
- package/build/src/admin/resource_tools.js +139 -0
- package/build/src/ai/assistant.d.ts +100 -0
- package/build/src/ai/assistant.js +487 -0
- package/build/src/ai/client.d.ts +49 -0
- package/build/src/ai/client.js +85 -0
- package/build/src/ai/prompt.d.ts +23 -0
- package/build/src/ai/prompt.js +83 -0
- package/build/src/ai/settings.d.ts +56 -0
- package/build/src/ai/settings.js +214 -0
- package/build/src/ai/usage.d.ts +16 -0
- package/build/src/ai/usage.js +33 -0
- package/build/src/appearance/appearance.d.ts +134 -0
- package/build/src/appearance/appearance.js +461 -0
- package/build/src/appearance/colors.d.ts +43 -0
- package/build/src/appearance/colors.js +99 -0
- package/build/src/appearance/logo.d.ts +32 -0
- package/build/src/appearance/logo.js +112 -0
- package/build/src/attachments/attachment_service.d.ts +46 -2
- package/build/src/attachments/attachment_service.js +96 -4
- package/build/src/auth/actor_store.d.ts +5 -1
- package/build/src/auth/actor_store.js +8 -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/backups/archive.d.ts +52 -0
- package/build/src/backups/archive.js +362 -0
- package/build/src/backups/cloud_backups.d.ts +133 -0
- package/build/src/backups/cloud_backups.js +650 -0
- package/build/src/backups/doctor.d.ts +7 -0
- package/build/src/backups/doctor.js +55 -0
- package/build/src/backups/providers.d.ts +81 -0
- package/build/src/backups/providers.js +470 -0
- package/build/src/collaboration/assignments.d.ts +59 -2
- package/build/src/collaboration/assignments.js +196 -74
- package/build/src/collaboration/record_collaboration.d.ts +21 -4
- package/build/src/collaboration/record_collaboration.js +126 -51
- package/build/src/collaboration/shared.d.ts +24 -0
- package/build/src/collaboration/shared.js +34 -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 +35 -9
- package/build/src/commands/doctor.d.ts +24 -2
- package/build/src/commands/doctor.js +81 -6
- 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 +24 -13
- package/build/src/commands/snapshot.js +54 -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 +145 -0
- package/build/src/core/avatar_image.d.ts +33 -0
- package/build/src/core/avatar_image.js +278 -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/mail_settings.d.ts +83 -0
- package/build/src/core/mail_settings.js +274 -0
- package/build/src/core/mail_test.d.ts +16 -0
- package/build/src/core/mail_test.js +81 -6
- package/build/src/core/message_templates.d.ts +15 -2
- package/build/src/core/message_templates.js +81 -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 +26 -9
- package/build/src/core/saved_views.d.ts +8 -1
- package/build/src/core/saved_views.js +91 -26
- 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 +31 -3
- 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 +10 -0
- package/build/src/core/ui_preferences.js +15 -1
- package/build/src/core/user_avatars.d.ts +79 -0
- package/build/src/core/user_avatars.js +186 -0
- package/build/src/core/user_invitations.d.ts +5 -1
- package/build/src/core/user_invitations.js +7 -1
- package/build/src/core/user_preferences.d.ts +36 -0
- package/build/src/core/user_preferences.js +125 -0
- package/build/src/core/users.d.ts +2 -0
- package/build/src/core/users.js +5 -3
- 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 +201 -2
- package/build/src/database/schema.js +713 -59
- package/build/src/database/schema_diff.d.ts +70 -0
- package/build/src/database/schema_diff.js +190 -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 +567 -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 +130 -16
- package/build/src/integrations/imports.js +434 -73
- package/build/src/integrations/openapi.d.ts +3 -1
- package/build/src/integrations/openapi.js +465 -31
- package/build/src/integrations/outbound.d.ts +94 -0
- package/build/src/integrations/outbound.js +276 -0
- package/build/src/integrations/print.d.ts +22 -1
- package/build/src/integrations/print.js +68 -22
- package/build/src/integrations/print_templates.d.ts +216 -0
- package/build/src/integrations/print_templates.js +1017 -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/integrations/xlsx.d.ts +41 -0
- package/build/src/integrations/xlsx.js +519 -0
- package/build/src/languages/ar.d.ts +11 -0
- package/build/src/languages/ar.js +358 -0
- package/build/src/languages/ar_ui.d.ts +461 -0
- package/build/src/languages/ar_ui.js +464 -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 +352 -0
- package/build/src/languages/en_ui.d.ts +3 -0
- package/build/src/languages/en_ui.js +458 -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 +138 -0
- package/build/src/lists/dashboards.js +290 -0
- package/build/src/mcp/tools.js +9 -104
- package/build/src/resource/define_resource.d.ts +18 -1
- package/build/src/resource/define_resource.js +212 -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 +313 -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 +107 -0
- package/build/src/workflows/delegations.js +326 -0
- package/build/src/workflows/engine.d.ts +80 -4
- package/build/src/workflows/engine.js +466 -86
- 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 +9 -2
|
@@ -14,6 +14,8 @@ export type UserOrgUnit = {
|
|
|
14
14
|
export type UserSummary = {
|
|
15
15
|
id: number;
|
|
16
16
|
fullName: string | null;
|
|
17
|
+
/** The user's versioned picture URL, or null without one (ADR 050). */
|
|
18
|
+
avatarUrl?: string | null;
|
|
17
19
|
email: string;
|
|
18
20
|
disabledAt: string | null;
|
|
19
21
|
roles: UserRoleAssignment[];
|
package/build/src/core/users.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { AdulaError } from '../admin/errors.js';
|
|
2
2
|
import { logActivity, pageLimit } from './activity.js';
|
|
3
3
|
import { administrationGuard } from './administration_guard.js';
|
|
4
|
+
import { escapeLike } from './like.js';
|
|
5
|
+
import { avatarUrlFor, avatarVersionColumn } from './user_avatars.js';
|
|
4
6
|
const RESOURCE = 'core.users';
|
|
5
|
-
const escapeLike = (value) => value.replace(/[\\%_]/g, '\\$&');
|
|
6
7
|
/** Host applications own the users table; AdulaJS expects id, email, full_name and disabled_at. */
|
|
7
8
|
export class UsersAdmin {
|
|
8
9
|
db;
|
|
@@ -12,7 +13,7 @@ export class UsersAdmin {
|
|
|
12
13
|
async list(options = {}) {
|
|
13
14
|
const limit = pageLimit(options.limit);
|
|
14
15
|
const query = this.db('users')
|
|
15
|
-
.select('id', 'email', 'full_name', 'disabled_at')
|
|
16
|
+
.select('id', 'email', 'full_name', 'disabled_at', avatarVersionColumn(this.db, 'users.id'))
|
|
16
17
|
.orderBy('id')
|
|
17
18
|
.limit(limit + 1);
|
|
18
19
|
const search = options.search?.trim();
|
|
@@ -138,7 +139,7 @@ export class UsersAdmin {
|
|
|
138
139
|
}
|
|
139
140
|
async find(db, id) {
|
|
140
141
|
const user = await db('users')
|
|
141
|
-
.select('id', 'email', 'full_name', 'disabled_at')
|
|
142
|
+
.select('id', 'email', 'full_name', 'disabled_at', avatarVersionColumn(db, 'users.id'))
|
|
142
143
|
.where('id', id)
|
|
143
144
|
.first();
|
|
144
145
|
if (!user)
|
|
@@ -163,6 +164,7 @@ export class UsersAdmin {
|
|
|
163
164
|
return rows.map((row) => ({
|
|
164
165
|
id: row.id,
|
|
165
166
|
fullName: row.full_name ?? null,
|
|
167
|
+
avatarUrl: avatarUrlFor(row.id, row.avatar_version),
|
|
166
168
|
email: row.email,
|
|
167
169
|
disabledAt: row.disabled_at ? new Date(row.disabled_at).toISOString() : null,
|
|
168
170
|
roles: roles
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Database } from '@adonisjs/lucid/database';
|
|
2
|
+
/** PostgreSQL's type OID for DATE (a calendar day without a time or zone). */
|
|
3
|
+
export declare const POSTGRES_DATE_OID = 1082;
|
|
4
|
+
/** PostgreSQL's type OID for DATE[] (for example `array_agg(day)`). */
|
|
5
|
+
export declare const POSTGRES_DATE_ARRAY_OID = 1182;
|
|
6
|
+
/**
|
|
7
|
+
* node-postgres turns a DATE into a JavaScript Date at local midnight, so in any time zone
|
|
8
|
+
* east of UTC `toISOString()` reports the previous day. A calendar day never passes
|
|
9
|
+
* through local time in AdulaJS: every PostgreSQL connection returns DATE as the
|
|
10
|
+
* 'YYYY-MM-DD' text the server sent, and DATE[] as an array of those strings (null
|
|
11
|
+
* elements stay null). node-postgres keeps one parser registry per driver, so this
|
|
12
|
+
* covers every query: resources, module code and raw Lucid queries alike.
|
|
13
|
+
*
|
|
14
|
+
* `manager.connect(name)` only builds the connection's Knex client (the pool opens no
|
|
15
|
+
* socket until the first query); it is needed because the driver whose registry must be
|
|
16
|
+
* changed is reachable only through that client, and the change has to be in place
|
|
17
|
+
* before any query parses a DATE. Connecting an already connected name is a no-op.
|
|
18
|
+
*/
|
|
19
|
+
export declare function keepCalendarDays(db: Pick<Database, 'config' | 'manager' | 'getRawConnection'>): void;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** PostgreSQL's type OID for DATE (a calendar day without a time or zone). */
|
|
2
|
+
export const POSTGRES_DATE_OID = 1082;
|
|
3
|
+
/** PostgreSQL's type OID for DATE[] (for example `array_agg(day)`). */
|
|
4
|
+
export const POSTGRES_DATE_ARRAY_OID = 1182;
|
|
5
|
+
/** PostgreSQL's type OID for TEXT[]; its parser returns the elements as strings. */
|
|
6
|
+
const POSTGRES_TEXT_ARRAY_OID = 1009;
|
|
7
|
+
/**
|
|
8
|
+
* node-postgres turns a DATE into a JavaScript Date at local midnight, so in any time zone
|
|
9
|
+
* east of UTC `toISOString()` reports the previous day. A calendar day never passes
|
|
10
|
+
* through local time in AdulaJS: every PostgreSQL connection returns DATE as the
|
|
11
|
+
* 'YYYY-MM-DD' text the server sent, and DATE[] as an array of those strings (null
|
|
12
|
+
* elements stay null). node-postgres keeps one parser registry per driver, so this
|
|
13
|
+
* covers every query: resources, module code and raw Lucid queries alike.
|
|
14
|
+
*
|
|
15
|
+
* `manager.connect(name)` only builds the connection's Knex client (the pool opens no
|
|
16
|
+
* socket until the first query); it is needed because the driver whose registry must be
|
|
17
|
+
* changed is reachable only through that client, and the change has to be in place
|
|
18
|
+
* before any query parses a DATE. Connecting an already connected name is a no-op.
|
|
19
|
+
*/
|
|
20
|
+
export function keepCalendarDays(db) {
|
|
21
|
+
for (const [name, config] of Object.entries(db.config.connections)) {
|
|
22
|
+
if (!['pg', 'postgres', 'postgresql'].includes(config.client))
|
|
23
|
+
continue;
|
|
24
|
+
db.manager.connect(name);
|
|
25
|
+
const connection = db.getRawConnection(name)?.connection;
|
|
26
|
+
for (const client of [connection?.client, connection?.readClient]) {
|
|
27
|
+
const types = client?.client?.driver?.types;
|
|
28
|
+
if (!types)
|
|
29
|
+
continue;
|
|
30
|
+
types.setTypeParser(POSTGRES_DATE_OID, (value) => value);
|
|
31
|
+
const textArray = types.getTypeParser?.(POSTGRES_TEXT_ARRAY_OID, 'text');
|
|
32
|
+
if (textArray)
|
|
33
|
+
types.setTypeParser(POSTGRES_DATE_ARRAY_OID, textArray);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -1,10 +1,111 @@
|
|
|
1
1
|
import type { Knex } from 'knex';
|
|
2
|
-
import type { Resource } from '../resource/types.js';
|
|
2
|
+
import type { Field, Resource, Scalar } from '../resource/types.js';
|
|
3
3
|
export declare function createCoreSchema(db: Knex): Promise<void>;
|
|
4
4
|
/** Attachment metadata lives in one table so ownership, restore drills and disk moves see every file. */
|
|
5
5
|
export declare function createAttachmentsSchema(db: Knex): Promise<void>;
|
|
6
6
|
export declare function createSavedViewsSchema(db: Knex): Promise<void>;
|
|
7
|
-
|
|
7
|
+
/** The definition parts that decide a resource table (what create-migrations embed). */
|
|
8
|
+
export type ResourceTableDefinition = Pick<Resource, 'name' | 'scoped' | 'version' | 'submittable' | 'fields'> & {
|
|
9
|
+
unique?: readonly (readonly string[])[];
|
|
10
|
+
};
|
|
11
|
+
/** One column of a resource table; `type` is PostgreSQL's format_type() spelling. */
|
|
12
|
+
export type ResourceColumn = {
|
|
13
|
+
name: string;
|
|
14
|
+
type: string;
|
|
15
|
+
nullable: boolean;
|
|
16
|
+
/** The column default of a field `default` (scalar types only). */
|
|
17
|
+
default?: Scalar;
|
|
18
|
+
/** The referenced table of a foreign key. */
|
|
19
|
+
references?: string;
|
|
20
|
+
/** The field key, or null for a standard column. */
|
|
21
|
+
field: string | null;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* A partial unique index over these columns: over live rows (`WHERE deleted_at IS NULL`)
|
|
25
|
+
* and, on a submittable resource, also excluding cancelled documents
|
|
26
|
+
* (`AND doc_status <> 2`) so an amended copy may keep the values of its original.
|
|
27
|
+
*/
|
|
28
|
+
export type ResourceUniqueIndex = {
|
|
29
|
+
name: string;
|
|
30
|
+
columns: string[];
|
|
31
|
+
fields: string[];
|
|
32
|
+
/** The predicate also excludes cancelled documents (submittable resources). */
|
|
33
|
+
excludeCancelled: boolean;
|
|
34
|
+
};
|
|
35
|
+
/** The join table of one manyToMany field. */
|
|
36
|
+
export type ResourceJoinTable = {
|
|
37
|
+
table: string;
|
|
38
|
+
field: string;
|
|
39
|
+
/** Column referencing the owner table. */
|
|
40
|
+
owner: string;
|
|
41
|
+
/** Column referencing the target table. */
|
|
42
|
+
target: string;
|
|
43
|
+
resource: string;
|
|
44
|
+
};
|
|
45
|
+
/** The table shape a definition expects; see resourceSchema(). */
|
|
46
|
+
export type ResourceSchema = {
|
|
47
|
+
table: string;
|
|
48
|
+
columns: ResourceColumn[];
|
|
49
|
+
unique: ResourceUniqueIndex[];
|
|
50
|
+
joinTables: ResourceJoinTable[];
|
|
51
|
+
/** Columns of the generated search_vector, in order. */
|
|
52
|
+
searchable: string[];
|
|
53
|
+
};
|
|
54
|
+
/** The column type of one stored field (format_type() spelling), or null when it has none. */
|
|
55
|
+
export declare function fieldColumnType(field: Field): string | null;
|
|
56
|
+
/**
|
|
57
|
+
* The table a definition expects: standard and field columns with their types,
|
|
58
|
+
* nullability and defaults, the partial unique indexes (single fields and the
|
|
59
|
+
* resource's composite `unique`) and the join tables of manyToMany fields.
|
|
60
|
+
* createResourceTable builds it and the `resources.schema` doctor check compares it
|
|
61
|
+
* with the live database.
|
|
62
|
+
*/
|
|
63
|
+
export declare function resourceSchema(resource: ResourceTableDefinition): ResourceSchema;
|
|
64
|
+
export declare function createResourceTable(db: Knex, resource: ResourceTableDefinition & {
|
|
65
|
+
/**
|
|
66
|
+
* @deprecated The `customFields` resource flag was removed. Kept only so create-migrations
|
|
67
|
+
* generated before the removal still compile and replay unchanged on a new database
|
|
68
|
+
* (migrations are immutable); new definitions cannot set it (`defineResource` refuses it).
|
|
69
|
+
*/
|
|
70
|
+
customFields?: boolean;
|
|
71
|
+
}): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* What an additive resource migration changes on an existing table: new field columns
|
|
74
|
+
* (and the join tables of new manyToMany fields), embedded as definition snapshots,
|
|
75
|
+
* partial unique indexes by column name, and two relaxing changes: NOT NULL dropped from
|
|
76
|
+
* columns the definition now lets be empty, and unique indexes recreated so cancelled
|
|
77
|
+
* documents no longer count. Generated by `node ace adula:resource:migration`.
|
|
78
|
+
*/
|
|
79
|
+
export type ResourceAddition = {
|
|
80
|
+
fields?: Record<string, Field>;
|
|
81
|
+
/** Unique indexes over live rows, each a list of column names. */
|
|
82
|
+
unique?: readonly (readonly string[])[];
|
|
83
|
+
/**
|
|
84
|
+
* Columns whose NOT NULL constraint is dropped, for example after `visibleWhen` was
|
|
85
|
+
* added to a required field (a hidden field stores null). Only relaxes: NOT NULL is
|
|
86
|
+
* never added automatically.
|
|
87
|
+
*/
|
|
88
|
+
dropNotNull?: readonly string[];
|
|
89
|
+
/**
|
|
90
|
+
* Unique indexes of a submittable table that still count cancelled documents: each is
|
|
91
|
+
* dropped by name and created again over live rows that are not cancelled, so an
|
|
92
|
+
* amended copy can keep the values of its cancelled original. Only relaxes.
|
|
93
|
+
*/
|
|
94
|
+
recreateUnique?: readonly {
|
|
95
|
+
index: string;
|
|
96
|
+
columns: readonly string[];
|
|
97
|
+
}[];
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Applies a ResourceAddition: drops NOT NULL from the named columns, adds the columns
|
|
101
|
+
* (NOT NULL only with a default, since the table may hold rows), creates join tables,
|
|
102
|
+
* recreates the named unique indexes with the cancelled-document predicate and creates
|
|
103
|
+
* the new unique indexes (excluding cancelled documents on a submittable table). It never
|
|
104
|
+
* tightens a constraint or drops data, so released migrations replay unchanged. The
|
|
105
|
+
* generated search_vector is not changed: making a field searchable needs a hand-written
|
|
106
|
+
* migration.
|
|
107
|
+
*/
|
|
108
|
+
export declare function alterResourceTable(db: Knex, name: string, addition: ResourceAddition): Promise<void>;
|
|
8
109
|
/** Record collaboration (phase 3): comments with mentions, followers, tags and field history. */
|
|
9
110
|
export declare function createCollaborationSchema(db: Knex): Promise<void>;
|
|
10
111
|
/** Work assigned to a user on a record; approval steps of workflows reuse it (phase 4). */
|
|
@@ -50,3 +151,101 @@ export declare function createUploadGrantsSchema(db: Knex): Promise<void>;
|
|
|
50
151
|
* dispatched as domain events through the outbox.
|
|
51
152
|
*/
|
|
52
153
|
export declare function createInboundWebhooksSchema(db: Knex): Promise<void>;
|
|
154
|
+
/**
|
|
155
|
+
* TOTP two-factor authentication (2.2): one row per user with the sealed secret and
|
|
156
|
+
* the last accepted time step (replay guard), and one row per recovery code so a
|
|
157
|
+
* code is consumed atomically. Codes are stored as SHA-256 over a per-code salt.
|
|
158
|
+
*/
|
|
159
|
+
export declare function createTwoFactorSchema(db: Knex): Promise<void>;
|
|
160
|
+
/**
|
|
161
|
+
* Import modes: upsert by a unique field, dry-run validation and its per-row report.
|
|
162
|
+
* `updated` counts rows an upsert changed; `report` holds the dry run's row outcomes.
|
|
163
|
+
*/
|
|
164
|
+
export declare function createImportModesSchema(db: Knex): Promise<void>;
|
|
165
|
+
/**
|
|
166
|
+
* Background synchronization runs (sync_jobs.ts): one row per queued, running or
|
|
167
|
+
* finished run. The partial unique index allows one open (queued or running) run per job.
|
|
168
|
+
*/
|
|
169
|
+
export declare function createSyncJobsSchema(db: Knex): Promise<void>;
|
|
170
|
+
/**
|
|
171
|
+
* Notification channels (2.x): per-user channel preferences (e-mail opt-out, the
|
|
172
|
+
* address of an HTTP provider channel such as SMS or WhatsApp) and the delivery state
|
|
173
|
+
* of channels other than in-app and e-mail, which keeps its notifications.mail_state.
|
|
174
|
+
* Only error categories are stored, never provider response bodies.
|
|
175
|
+
*/
|
|
176
|
+
export declare function createNotificationChannelsSchema(db: Knex): Promise<void>;
|
|
177
|
+
/**
|
|
178
|
+
* Confirmation of a notification channel address (2.x): a one-time code sent to the
|
|
179
|
+
* number before the channel can be enabled with it. One row per user and channel, the
|
|
180
|
+
* code stored as SHA-256 over a per-code salt and void after five wrong attempts; the
|
|
181
|
+
* row also counts codes sent in a 24-hour window. Preferences record when their number
|
|
182
|
+
* was confirmed; a number without confirmed_at never receives messages.
|
|
183
|
+
*/
|
|
184
|
+
export declare function createChannelConfirmationsSchema(db: Knex): Promise<void>;
|
|
185
|
+
/**
|
|
186
|
+
* Import worker leases: a claimed batch belongs to one worker until lease_expires_at;
|
|
187
|
+
* every progress write names lease_id, so a worker whose lease was taken over writes nothing.
|
|
188
|
+
*/
|
|
189
|
+
export declare function createImportLeasesSchema(db: Knex): Promise<void>;
|
|
190
|
+
/**
|
|
191
|
+
* Approval delegation and SLA deadlines (ADR 044). A delegation routes a user's new
|
|
192
|
+
* approvals to a delegate for a date range and lets the delegate act on the user's
|
|
193
|
+
* pending ones; overlap is refused by WorkflowDelegations under a row lock. Approval
|
|
194
|
+
* assignments gain a deadline, the delegation they were routed through and the SLA
|
|
195
|
+
* markers; workflow_escalations records each reminder and escalation once.
|
|
196
|
+
*/
|
|
197
|
+
export declare function createWorkflowDelegationSlaSchema(db: Knex): Promise<void>;
|
|
198
|
+
/**
|
|
199
|
+
* Administrator print templates (ADR 048). A template row points to its current
|
|
200
|
+
* version; versions are immutable (a trigger refuses UPDATE and DELETE, except clearing
|
|
201
|
+
* created_by when the author is deleted), so a printed
|
|
202
|
+
* document's recorded version always resolves to the markup that produced it.
|
|
203
|
+
* Templates are deployment-wide, like message_templates.
|
|
204
|
+
*/
|
|
205
|
+
export declare function createPrintTemplatesSchema(db: Knex): Promise<void>;
|
|
206
|
+
/** Template keys of the notifications that quote a comment's text. */
|
|
207
|
+
export declare const COMMENT_NOTIFICATION_KEYS: readonly ["comment.mentioned", "comment.created"];
|
|
208
|
+
export declare const DELETED_COMMENT_TITLE = "\u062A\u0639\u0644\u064A\u0642 \u0645\u062D\u0630\u0648\u0641";
|
|
209
|
+
export declare const DELETED_COMMENT_BODY = "\u062D\u064F\u0630\u0641 \u0647\u0630\u0627 \u0627\u0644\u062A\u0639\u0644\u064A\u0642.";
|
|
210
|
+
/**
|
|
211
|
+
* Ids and template keys of the notifications that quote a comment: those naming it
|
|
212
|
+
* (comment_id, 2.3.0) and those written before notifications named their comment. A
|
|
213
|
+
* comment's notifications were inserted in its own transaction, so their created_at equals
|
|
214
|
+
* the comment's (both now()), and they quote its text from the start: the first 100
|
|
215
|
+
* characters are matched, which the 200-unit excerpt always contains. Read before a
|
|
216
|
+
* comment's body changes. `comment` is one comment id, or 'deleted' for every deleted one.
|
|
217
|
+
*/
|
|
218
|
+
export declare function commentNotifications(db: Knex, comment: number | 'deleted'): Promise<{
|
|
219
|
+
id: number;
|
|
220
|
+
key: string;
|
|
221
|
+
}[]>;
|
|
222
|
+
/**
|
|
223
|
+
* Stops what has not been sent yet of the given notifications: pending e-mail is skipped
|
|
224
|
+
* and pending channel deliveries are withdrawn (a channel worker re-checks the pending
|
|
225
|
+
* state before it sends, so a claimed delivery is not sent either).
|
|
226
|
+
*/
|
|
227
|
+
export declare function withdrawNotificationDelivery(db: Knex, ids: number[]): Promise<void>;
|
|
228
|
+
/**
|
|
229
|
+
* Comment notifications name their comment (2.3.0), so deleting or editing the comment
|
|
230
|
+
* withdraws the quoted text. Notifications of comments deleted before this migration are
|
|
231
|
+
* found by their transaction time and quoted text, and withdrawn here.
|
|
232
|
+
*/
|
|
233
|
+
export declare function createCommentNotificationsSchema(db: Knex): Promise<void>;
|
|
234
|
+
/** Replaces the quoted text of every deleted comment's notifications with a neutral note. */
|
|
235
|
+
export declare function withdrawDeletedCommentNotifications(db: Knex): Promise<void>;
|
|
236
|
+
/**
|
|
237
|
+
* The built-in assistant (ADR 052): conversation metadata (never message text), pending
|
|
238
|
+
* write proposals awaiting the user's confirmation, and per-user daily token usage.
|
|
239
|
+
*/
|
|
240
|
+
export declare function createAssistantSchema(db: Knex): Promise<void>;
|
|
241
|
+
/**
|
|
242
|
+
* Cloud and downloadable backups (ADR 051): one connection per destination with its refresh
|
|
243
|
+
* token sealed by the host's SecretBox, and one row per backup run.
|
|
244
|
+
*/
|
|
245
|
+
export declare function createCloudBackupsSchema(db: Knex): Promise<void>;
|
|
246
|
+
/**
|
|
247
|
+
* Appearance occasions (ADR 053): dated overrides of the base identity, which is the system
|
|
248
|
+
* setting `appearance.identity`. Logos are `attachments` rows, so only the id is kept here.
|
|
249
|
+
* Overlapping ranges are refused by the service under a table lock.
|
|
250
|
+
*/
|
|
251
|
+
export declare function createAppearanceSchema(db: Knex): Promise<void>;
|