adula 2.0.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 +5 -3
- 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,56 @@
|
|
|
1
|
+
import { fromRow, serialize } from '../contracts.js';
|
|
2
|
+
import { notFound } from '../errors.js';
|
|
3
|
+
import { audit, requireInlineParents } from './lifecycle.js';
|
|
4
|
+
import { authorizeAction, columns, hydrateOne, requireRecord, } from './shared.js';
|
|
5
|
+
/**
|
|
6
|
+
* One soft-deleted record within the actor's organization scope; 404 otherwise. It
|
|
7
|
+
* mirrors shared.find() for rows whose deleted_at is set, so restore never sees a live row.
|
|
8
|
+
*/
|
|
9
|
+
async function findDeleted(db, resource, actor, ability, id) {
|
|
10
|
+
const query = db(`${resource.name} as r`).whereNotNull('r.deleted_at').where('r.id', id);
|
|
11
|
+
if (resource.scoped) {
|
|
12
|
+
query
|
|
13
|
+
.join('org_units as ou', 'ou.id', 'r.org_unit_id')
|
|
14
|
+
.where((scope) => {
|
|
15
|
+
if (!actor.orgPaths.length)
|
|
16
|
+
scope.whereRaw('FALSE');
|
|
17
|
+
actor.orgPaths.forEach((path) => scope.orWhereRaw('ou.path <@ ?::ltree', [path]));
|
|
18
|
+
})
|
|
19
|
+
.select('ou.path as org_path');
|
|
20
|
+
}
|
|
21
|
+
query.select(columns(resource, ability, true)).forUpdate('r');
|
|
22
|
+
const row = await query.first();
|
|
23
|
+
if (!row)
|
|
24
|
+
throw notFound();
|
|
25
|
+
return fromRow(row, resource);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Clears deleted_at of a soft-deleted record; see ResourceService.restore. Restore is
|
|
29
|
+
* authorized by the actor's delete rule (ADR 046): the resource must offer delete, the
|
|
30
|
+
* actor must hold it, and its conditions and organization scope are evaluated on the
|
|
31
|
+
* deleted record (404 outside the scope, 403 when a condition refuses).
|
|
32
|
+
*/
|
|
33
|
+
export async function restore(ctx, name, id, actor, transaction) {
|
|
34
|
+
const resource = ctx.registry.get(name);
|
|
35
|
+
const ability = authorizeAction(ctx, resource, actor, 'delete');
|
|
36
|
+
if (!Number.isSafeInteger(id) || id <= 0)
|
|
37
|
+
throw notFound();
|
|
38
|
+
const work = async (trx) => {
|
|
39
|
+
const record = await findDeleted(trx, resource, actor, ability, id);
|
|
40
|
+
requireRecord(ability, actor, resource, 'delete', record);
|
|
41
|
+
// An inline line comes back only while its parent is a draft the actor may update.
|
|
42
|
+
await requireInlineParents(ctx, trx, resource, actor, record);
|
|
43
|
+
const values = {
|
|
44
|
+
deleted_at: null,
|
|
45
|
+
updated_by: actor.id,
|
|
46
|
+
updated_at: trx.fn.now(),
|
|
47
|
+
};
|
|
48
|
+
if (resource.version)
|
|
49
|
+
values.version = Number(record.version) + 1;
|
|
50
|
+
const [row] = await trx(name).where({ id }).update(values).returning('*');
|
|
51
|
+
const saved = fromRow(row, resource);
|
|
52
|
+
await audit(ctx, trx, resource, actor, 'restore', saved, []);
|
|
53
|
+
return serialize(resource, await hydrateOne(trx, resource, saved, ctx.attachments), ability, actor);
|
|
54
|
+
};
|
|
55
|
+
return transaction ? work(transaction) : ctx.db.transaction(work);
|
|
56
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { Knex } from 'knex';
|
|
2
|
+
import type { RecordData, SerializedRecord } from '../../resource/types.js';
|
|
3
|
+
import { type Actor } from '../../auth/ability.js';
|
|
4
|
+
import { type ResourceContext } from './shared.js';
|
|
5
|
+
import { type ParentWrite } from './lifecycle.js';
|
|
6
|
+
/** Options of ResourceService.systemSave. */
|
|
7
|
+
export type SystemSaveOptions = {
|
|
8
|
+
/**
|
|
9
|
+
* The user recorded as the author: created/updated by, activity and events. null is an
|
|
10
|
+
* unattributed update by the system itself (for example a workflow whose triggering
|
|
11
|
+
* event named no user): it runs the validator, hooks and lock, keeps updated_by, and
|
|
12
|
+
* writes no activity entry or domain event because there is no author. Creates need one.
|
|
13
|
+
*/
|
|
14
|
+
actorId: number | null;
|
|
15
|
+
/** Write inside the module's transaction. */
|
|
16
|
+
trx?: Knex.Transaction;
|
|
17
|
+
/** Why module code wrote the record; stored with the activity entry. */
|
|
18
|
+
reason?: string;
|
|
19
|
+
/** Optimistic lock: when given, it must match the stored version. */
|
|
20
|
+
version?: number;
|
|
21
|
+
/**
|
|
22
|
+
* The person who chose the values, when module code writes a choice made by a user,
|
|
23
|
+
* such as a supervisor reassigning a record. A new value of a user field must then be
|
|
24
|
+
* eligible for them as in a user save; without it, any active member qualifies on
|
|
25
|
+
* unscoped resources.
|
|
26
|
+
*/
|
|
27
|
+
chooser?: Actor;
|
|
28
|
+
/**
|
|
29
|
+
* Also write a submitted document (docStatus 1), as workflow update steps do. Drafts
|
|
30
|
+
* are always writable; cancelled documents stay locked.
|
|
31
|
+
*/
|
|
32
|
+
submitted?: boolean;
|
|
33
|
+
};
|
|
34
|
+
/** What persist() needs to know about a write decided by module code. */
|
|
35
|
+
type SystemWrite = {
|
|
36
|
+
reason?: string;
|
|
37
|
+
version?: number;
|
|
38
|
+
chooser?: Actor;
|
|
39
|
+
submitted?: boolean;
|
|
40
|
+
unattributed?: boolean;
|
|
41
|
+
};
|
|
42
|
+
/** A module-code write; see ResourceService.systemSave. */
|
|
43
|
+
export declare function systemSave(ctx: ResourceContext, name: string, values: RecordData, id: number | undefined, options: SystemSaveOptions): Promise<RecordData>;
|
|
44
|
+
/** Moves records whose scope follows a parent; see ResourceService.rehome. */
|
|
45
|
+
export declare function rehome(ctx: ResourceContext, parentName: string, parentId: number, options: Omit<SystemSaveOptions, 'version'>): Promise<number>;
|
|
46
|
+
/**
|
|
47
|
+
* Creates or updates one record, for a user (save) or for module code (system). Every
|
|
48
|
+
* user write, every inline row and every amended copy goes through here.
|
|
49
|
+
*/
|
|
50
|
+
export declare function persist(ctx: ResourceContext, name: string, actor: Actor, input: RecordData, id?: number, transaction?: Knex.Transaction, parentWrite?: ParentWrite, system?: SystemWrite): Promise<SerializedRecord>;
|
|
51
|
+
/**
|
|
52
|
+
* Amend-by-copy: a cancelled document is copied into a new draft that points to
|
|
53
|
+
* it through amended_from_id, together with its inline lines. The original stays
|
|
54
|
+
* cancelled and unchanged; sequence fields receive new numbers.
|
|
55
|
+
*/
|
|
56
|
+
export declare function amend(ctx: ResourceContext, name: string, id: number, actor: Actor, transaction?: Knex.Transaction): Promise<SerializedRecord>;
|
|
57
|
+
export {};
|