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,139 @@
|
|
|
1
|
+
import type { Knex } from 'knex';
|
|
2
|
+
import type { ResourceService, SystemSaveOptions } from '../admin/resource_service.js';
|
|
3
|
+
import type { RecordData } from '../resource/types.js';
|
|
4
|
+
import { type OutboundErrorCategory } from './outbound.js';
|
|
5
|
+
export type SyncTrigger = 'schedule' | 'manual';
|
|
6
|
+
export type SyncRunStatus = 'queued' | 'running' | 'succeeded' | 'failed';
|
|
7
|
+
/** Stored failure categories; the page translates them, the message is secondary. */
|
|
8
|
+
export type SyncErrorCategory = 'timeout' | 'validation' | 'authorization' | 'conflict' | 'handler' | OutboundErrorCategory;
|
|
9
|
+
/** Counters a handler returns, such as { created: 3, updated: 1 }. */
|
|
10
|
+
export type SyncStats = Record<string, number>;
|
|
11
|
+
export type SyncLogger = {
|
|
12
|
+
info(message: string, data?: Record<string, unknown>): void;
|
|
13
|
+
warn(message: string, data?: Record<string, unknown>): void;
|
|
14
|
+
error(message: string, data?: Record<string, unknown>): void;
|
|
15
|
+
};
|
|
16
|
+
/** ResourceService.systemSave options; `id` updates, and actorId defaults to the requester. */
|
|
17
|
+
export type SyncSaveOptions = Omit<SystemSaveOptions, 'actorId'> & {
|
|
18
|
+
id?: number;
|
|
19
|
+
actorId?: number | null;
|
|
20
|
+
};
|
|
21
|
+
export type SyncJobContext = {
|
|
22
|
+
jobName: string;
|
|
23
|
+
runId: number;
|
|
24
|
+
trigger: SyncTrigger;
|
|
25
|
+
/** The user who pressed "run now"; null for scheduled runs. */
|
|
26
|
+
requestedBy: number | null;
|
|
27
|
+
/** When this job last finished successfully, for incremental pulls. */
|
|
28
|
+
lastSuccessAt: Date | null;
|
|
29
|
+
/**
|
|
30
|
+
* Aborted when the run exceeds its timeout. Handlers must honour it: pass it to fetch
|
|
31
|
+
* and outbound calls and stop working once it aborts. After the abort systemSave and
|
|
32
|
+
* logger refuse; a handler still unsettled at timeout + stale margin is abandoned (the
|
|
33
|
+
* run fails as timeout) and the job's next run waits until it settles in this process.
|
|
34
|
+
*/
|
|
35
|
+
signal: AbortSignal;
|
|
36
|
+
logger: SyncLogger;
|
|
37
|
+
/**
|
|
38
|
+
* Writes a record through ResourceService.systemSave (validator, hooks, audit trail).
|
|
39
|
+
* Creates need an author: actorId defaults to requestedBy, so a scheduled job that
|
|
40
|
+
* creates records passes the integration user's id explicitly.
|
|
41
|
+
*/
|
|
42
|
+
systemSave(resource: string, values: RecordData, options?: SyncSaveOptions): Promise<RecordData>;
|
|
43
|
+
};
|
|
44
|
+
export type SyncJobDefinition = {
|
|
45
|
+
name: string;
|
|
46
|
+
label: {
|
|
47
|
+
ar: string;
|
|
48
|
+
en?: string;
|
|
49
|
+
};
|
|
50
|
+
/** Five fields (minute hour day month weekday), numbers, `*`, ranges, steps and lists. */
|
|
51
|
+
cron: string;
|
|
52
|
+
timeoutMs: number;
|
|
53
|
+
handler: (ctx: SyncJobContext) => Promise<SyncStats | void>;
|
|
54
|
+
};
|
|
55
|
+
export type SyncJobInput = Omit<SyncJobDefinition, 'timeoutMs'> & {
|
|
56
|
+
timeoutMs?: number;
|
|
57
|
+
};
|
|
58
|
+
export type SyncRun = {
|
|
59
|
+
id: number;
|
|
60
|
+
job: string;
|
|
61
|
+
trigger: SyncTrigger;
|
|
62
|
+
status: SyncRunStatus;
|
|
63
|
+
requestedBy: number | null;
|
|
64
|
+
queuedAt: string;
|
|
65
|
+
startedAt: string | null;
|
|
66
|
+
finishedAt: string | null;
|
|
67
|
+
durationMs: number | null;
|
|
68
|
+
errorCategory: SyncErrorCategory | null;
|
|
69
|
+
errorMessage: string | null;
|
|
70
|
+
stats: SyncStats;
|
|
71
|
+
};
|
|
72
|
+
export type SyncJobSummary = {
|
|
73
|
+
name: string;
|
|
74
|
+
label: {
|
|
75
|
+
ar: string;
|
|
76
|
+
en?: string;
|
|
77
|
+
};
|
|
78
|
+
cron: string;
|
|
79
|
+
timeoutMs: number;
|
|
80
|
+
/**
|
|
81
|
+
* A queued or running run exists ("run now" is refused until it finishes), or an
|
|
82
|
+
* abandoned handler of the job is still alive in this process.
|
|
83
|
+
*/
|
|
84
|
+
busy: boolean;
|
|
85
|
+
lastRun: SyncRun | null;
|
|
86
|
+
lastSuccessAt: string | null;
|
|
87
|
+
/** The category of the latest finished run when it failed. */
|
|
88
|
+
lastErrorCategory: SyncErrorCategory | null;
|
|
89
|
+
/** The next scheduled time in the server's time zone, as the scheduler fires it. */
|
|
90
|
+
nextRunAt: string | null;
|
|
91
|
+
};
|
|
92
|
+
export type SyncJobsOptions = {
|
|
93
|
+
logger?: SyncLogger;
|
|
94
|
+
/** How long past its timeout a running row may stay before it counts as crashed. */
|
|
95
|
+
staleMarginMs?: number;
|
|
96
|
+
};
|
|
97
|
+
/** A failure the handler classifies itself, for example `http-status:503` from a remote API. */
|
|
98
|
+
export declare class SyncJobError extends Error {
|
|
99
|
+
category: SyncErrorCategory;
|
|
100
|
+
constructor(category: SyncErrorCategory, message: string);
|
|
101
|
+
}
|
|
102
|
+
export declare const SYNC_DEFAULT_TIMEOUT_MS: number;
|
|
103
|
+
/**
|
|
104
|
+
* Declares a background synchronization job; the scheduler queues it and the worker runs it.
|
|
105
|
+
* The handler must honour ctx.signal: pass it to fetch and outbound calls and stop work
|
|
106
|
+
* when it aborts at timeoutMs. See SyncJobContext.signal for what happens otherwise.
|
|
107
|
+
*/
|
|
108
|
+
export declare function defineSyncJob(input: SyncJobInput): SyncJobDefinition;
|
|
109
|
+
/** Classifies a handler failure for storage and display. */
|
|
110
|
+
export declare function syncErrorCategory(error: unknown): SyncErrorCategory;
|
|
111
|
+
/**
|
|
112
|
+
* Background synchronization runs (sync_job_runs). The scheduler and "run now" queue a
|
|
113
|
+
* run; the worker claims one with SKIP LOCKED and runs its handler under a timeout. At
|
|
114
|
+
* most one queued or running run exists per job, enforced by a partial unique index.
|
|
115
|
+
*/
|
|
116
|
+
export declare class SyncJobs {
|
|
117
|
+
private db;
|
|
118
|
+
private resources;
|
|
119
|
+
private options;
|
|
120
|
+
private definitions;
|
|
121
|
+
private crons;
|
|
122
|
+
constructor(db: Knex, resources: ResourceService, definitions: SyncJobDefinition[], options?: SyncJobsOptions);
|
|
123
|
+
all(): SyncJobDefinition[];
|
|
124
|
+
private definition;
|
|
125
|
+
/** Queues a run; refuses (409) while a run of the same job is queued or running. */
|
|
126
|
+
queue(name: string, trigger: SyncTrigger, requestedBy?: number | null): Promise<SyncRun>;
|
|
127
|
+
/** Runs the oldest queued run of a defined job; null when nothing is queued. */
|
|
128
|
+
runNext(): Promise<SyncRun | null>;
|
|
129
|
+
/**
|
|
130
|
+
* Marks running rows older than their timeout plus a margin as failed timeouts, so a
|
|
131
|
+
* worker that crashed mid-run does not block the job forever.
|
|
132
|
+
*/
|
|
133
|
+
recoverStale(): Promise<number>;
|
|
134
|
+
/** Every defined job with its latest run, last success and next scheduled time. */
|
|
135
|
+
list(now?: Date): Promise<SyncJobSummary[]>;
|
|
136
|
+
/** Run history of one job, newest first. */
|
|
137
|
+
runs(name: string, limit?: number): Promise<SyncRun[]>;
|
|
138
|
+
private serialize;
|
|
139
|
+
}
|
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
import { AdulaError } from '../admin/errors.js';
|
|
2
|
+
import { OutboundTargetError, outboundErrorCategory, } from './outbound.js';
|
|
3
|
+
/** A failure the handler classifies itself, for example `http-status:503` from a remote API. */
|
|
4
|
+
export class SyncJobError extends Error {
|
|
5
|
+
category;
|
|
6
|
+
constructor(category, message) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.category = category;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export const SYNC_DEFAULT_TIMEOUT_MS = 5 * 60_000;
|
|
12
|
+
const MAX_TIMEOUT_MS = 6 * 60 * 60_000;
|
|
13
|
+
const STALE_MARGIN_MS = 60_000;
|
|
14
|
+
const MESSAGE_LIMIT = 500;
|
|
15
|
+
const NAME = /^sync:[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
16
|
+
/**
|
|
17
|
+
* Handlers abandoned at the stale limit that have not settled yet, per job name. Kept per
|
|
18
|
+
* process (the application builds a new SyncJobs per adula() call), so one worker never
|
|
19
|
+
* starts a job's next run while its previous handler is still alive.
|
|
20
|
+
*/
|
|
21
|
+
const abandonedHandlers = new Map();
|
|
22
|
+
/**
|
|
23
|
+
* Declares a background synchronization job; the scheduler queues it and the worker runs it.
|
|
24
|
+
* The handler must honour ctx.signal: pass it to fetch and outbound calls and stop work
|
|
25
|
+
* when it aborts at timeoutMs. See SyncJobContext.signal for what happens otherwise.
|
|
26
|
+
*/
|
|
27
|
+
export function defineSyncJob(input) {
|
|
28
|
+
if (typeof input.name !== 'string' || input.name.length > 100 || !NAME.test(input.name))
|
|
29
|
+
throw new Error(`Sync job name "${input.name}" must look like sync:kebab-case`);
|
|
30
|
+
if (!input.label?.ar?.trim())
|
|
31
|
+
throw new Error(`Sync job ${input.name} needs an Arabic label`);
|
|
32
|
+
parseCron(input.cron, input.name);
|
|
33
|
+
const timeoutMs = input.timeoutMs ?? SYNC_DEFAULT_TIMEOUT_MS;
|
|
34
|
+
if (!Number.isSafeInteger(timeoutMs) || timeoutMs < 1 || timeoutMs > MAX_TIMEOUT_MS)
|
|
35
|
+
throw new Error(`Sync job ${input.name} timeoutMs must be between 1 ms and 6 hours`);
|
|
36
|
+
if (typeof input.handler !== 'function')
|
|
37
|
+
throw new Error(`Sync job ${input.name} needs a handler`);
|
|
38
|
+
return { ...input, cron: input.cron.trim().replace(/\s+/g, ' '), timeoutMs };
|
|
39
|
+
}
|
|
40
|
+
const CRON_BOUNDS = [
|
|
41
|
+
[0, 59],
|
|
42
|
+
[0, 23],
|
|
43
|
+
[1, 31],
|
|
44
|
+
[1, 12],
|
|
45
|
+
[0, 7],
|
|
46
|
+
];
|
|
47
|
+
/**
|
|
48
|
+
* Parses the subset of node-cron syntax (used by adonisjs-scheduler) whose meaning is
|
|
49
|
+
* unambiguous. Steps follow node-cron: `a-b/n` keeps the values divisible by n.
|
|
50
|
+
*/
|
|
51
|
+
function parseCron(expression, job) {
|
|
52
|
+
const parts = typeof expression === 'string' ? expression.trim().split(/\s+/) : [];
|
|
53
|
+
if (parts.length !== 5)
|
|
54
|
+
throw new Error(`Sync job ${job} cron must have five fields (minute hour day month weekday)`);
|
|
55
|
+
return parts.map((part, index) => {
|
|
56
|
+
const [min, max] = CRON_BOUNDS[index];
|
|
57
|
+
const values = new Set();
|
|
58
|
+
for (const item of part.split(',')) {
|
|
59
|
+
const match = /^(\*|(\d+)(?:-(\d+))?)(?:\/(\d+))?$/.exec(item);
|
|
60
|
+
const from = match?.[2] === undefined ? min : Number(match[2]);
|
|
61
|
+
const to = match?.[3] !== undefined ? Number(match[3]) : match?.[1] === '*' ? max : from;
|
|
62
|
+
const step = match?.[4] === undefined ? 1 : Number(match[4]);
|
|
63
|
+
const stepped = match?.[4] !== undefined;
|
|
64
|
+
if (!match ||
|
|
65
|
+
from < min ||
|
|
66
|
+
to > max ||
|
|
67
|
+
from > to ||
|
|
68
|
+
step < 1 ||
|
|
69
|
+
(stepped && part.includes(',')))
|
|
70
|
+
throw new Error(`Sync job ${job} has an invalid cron field "${part}"`);
|
|
71
|
+
// node-cron counts Sunday as 0 or 7.
|
|
72
|
+
for (let value = from; value <= to; value++)
|
|
73
|
+
if (value % step === 0 || !stepped)
|
|
74
|
+
values.add(index === 4 && value === 7 ? 0 : value);
|
|
75
|
+
}
|
|
76
|
+
if (values.size === 0)
|
|
77
|
+
throw new Error(`Sync job ${job} has an empty cron field "${part}"`);
|
|
78
|
+
return values;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
/** The first minute after `after` matching every field (node-cron matches day AND weekday). */
|
|
82
|
+
function nextCronTime(fields, after) {
|
|
83
|
+
const [minutes, hours, days, months, weekdays] = fields;
|
|
84
|
+
const at = new Date(after);
|
|
85
|
+
at.setSeconds(0, 0);
|
|
86
|
+
at.setMinutes(at.getMinutes() + 1);
|
|
87
|
+
for (let step = 0; step < 100_000; step++) {
|
|
88
|
+
if (!months.has(at.getMonth() + 1)) {
|
|
89
|
+
at.setMonth(at.getMonth() + 1, 1);
|
|
90
|
+
at.setHours(0, 0, 0, 0);
|
|
91
|
+
}
|
|
92
|
+
else if (!days.has(at.getDate()) || !weekdays.has(at.getDay())) {
|
|
93
|
+
at.setDate(at.getDate() + 1);
|
|
94
|
+
at.setHours(0, 0, 0, 0);
|
|
95
|
+
}
|
|
96
|
+
else if (!hours.has(at.getHours()))
|
|
97
|
+
at.setHours(at.getHours() + 1, 0, 0, 0);
|
|
98
|
+
else if (!minutes.has(at.getMinutes()))
|
|
99
|
+
at.setMinutes(at.getMinutes() + 1, 0, 0);
|
|
100
|
+
else
|
|
101
|
+
return at;
|
|
102
|
+
}
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
const VALIDATION_CODES = /^(23502|23503|23505|23514|22\w{3})$/;
|
|
106
|
+
/** Classifies a handler failure for storage and display. */
|
|
107
|
+
export function syncErrorCategory(error) {
|
|
108
|
+
if (error instanceof SyncJobError)
|
|
109
|
+
return error.category;
|
|
110
|
+
const { status, code } = (error ?? {});
|
|
111
|
+
// E_ACTOR: the write has no author the job may act for (for example a scheduled create).
|
|
112
|
+
if (code === 'E_ACTOR' || status === 401 || status === 403)
|
|
113
|
+
return 'authorization';
|
|
114
|
+
if (code === 'E_VALIDATION_ERROR' || status === 422)
|
|
115
|
+
return 'validation';
|
|
116
|
+
if (status === 409)
|
|
117
|
+
return 'conflict';
|
|
118
|
+
if (typeof code === 'string' && VALIDATION_CODES.test(code))
|
|
119
|
+
return 'validation';
|
|
120
|
+
if (error instanceof AdulaError)
|
|
121
|
+
return 'handler';
|
|
122
|
+
// outboundErrorCategory falls back to 'connect'; only trust it for network failures.
|
|
123
|
+
const outbound = outboundErrorCategory(error);
|
|
124
|
+
if (outbound !== 'connect' || error instanceof OutboundTargetError)
|
|
125
|
+
return outbound;
|
|
126
|
+
for (let current = error, depth = 0; current && depth < 5; depth++) {
|
|
127
|
+
const nested = current.code;
|
|
128
|
+
if (typeof nested === 'string' && /^(ECONN|ENET|EHOST|EPIPE|UND_ERR)/.test(nested))
|
|
129
|
+
return 'connect';
|
|
130
|
+
current = current.cause;
|
|
131
|
+
}
|
|
132
|
+
return 'handler';
|
|
133
|
+
}
|
|
134
|
+
/** Keeps the message useful while dropping credentials, query strings and control characters. */
|
|
135
|
+
function sanitize(error) {
|
|
136
|
+
let raw = error instanceof Error ? error.message : String(error);
|
|
137
|
+
// VineJS keeps the refused fields in `messages`; name them, never their values.
|
|
138
|
+
const fields = error?.messages;
|
|
139
|
+
if (Array.isArray(fields))
|
|
140
|
+
raw += `: ${[...new Set(fields.map((item) => String(item?.field ?? '')).filter(Boolean))].join(', ')}`;
|
|
141
|
+
const clean = raw
|
|
142
|
+
.replace(/\p{Cc}+/gu, ' ')
|
|
143
|
+
.replace(/(\w+:\/\/)[^/\s@]+@/g, '$1')
|
|
144
|
+
.replace(/(https?:\/\/[^\s?#]+)[?#]\S*/g, '$1')
|
|
145
|
+
.replace(/\b(bearer|basic)\s+[\w.~+/=-]+/gi, '$1 [hidden]')
|
|
146
|
+
.replace(/\b(password|secret|token|api[_-]?key|authorization)(["']?\s*[:=]\s*)\S+/gi, '$1$2[hidden]')
|
|
147
|
+
.replace(/\s+/g, ' ')
|
|
148
|
+
.trim();
|
|
149
|
+
return clean.length > MESSAGE_LIMIT ? `${clean.slice(0, MESSAGE_LIMIT - 1)}…` : clean;
|
|
150
|
+
}
|
|
151
|
+
const iso = (value) => (value ? new Date(value).toISOString() : null);
|
|
152
|
+
const silent = { info: () => { }, warn: () => { }, error: () => { } };
|
|
153
|
+
/**
|
|
154
|
+
* Background synchronization runs (sync_job_runs). The scheduler and "run now" queue a
|
|
155
|
+
* run; the worker claims one with SKIP LOCKED and runs its handler under a timeout. At
|
|
156
|
+
* most one queued or running run exists per job, enforced by a partial unique index.
|
|
157
|
+
*/
|
|
158
|
+
export class SyncJobs {
|
|
159
|
+
db;
|
|
160
|
+
resources;
|
|
161
|
+
options;
|
|
162
|
+
definitions = new Map();
|
|
163
|
+
crons = new Map();
|
|
164
|
+
constructor(db, resources, definitions, options = {}) {
|
|
165
|
+
this.db = db;
|
|
166
|
+
this.resources = resources;
|
|
167
|
+
this.options = options;
|
|
168
|
+
for (const definition of definitions) {
|
|
169
|
+
if (this.definitions.has(definition.name))
|
|
170
|
+
throw new Error(`Sync job ${definition.name} is defined twice`);
|
|
171
|
+
this.definitions.set(definition.name, definition);
|
|
172
|
+
this.crons.set(definition.name, parseCron(definition.cron, definition.name));
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
all() {
|
|
176
|
+
return [...this.definitions.values()];
|
|
177
|
+
}
|
|
178
|
+
definition(name) {
|
|
179
|
+
const definition = this.definitions.get(name);
|
|
180
|
+
if (!definition)
|
|
181
|
+
throw new AdulaError(404, 'E_SYNC_JOB_NOT_FOUND', 'مهمة المزامنة غير موجودة');
|
|
182
|
+
return definition;
|
|
183
|
+
}
|
|
184
|
+
/** Queues a run; refuses (409) while a run of the same job is queued or running. */
|
|
185
|
+
async queue(name, trigger, requestedBy = null) {
|
|
186
|
+
this.definition(name);
|
|
187
|
+
await this.recoverStale();
|
|
188
|
+
try {
|
|
189
|
+
const [row] = await this.db('sync_job_runs')
|
|
190
|
+
.insert({ job: name, trigger, status: 'queued', requested_by: requestedBy })
|
|
191
|
+
.returning('*');
|
|
192
|
+
return this.serialize(row);
|
|
193
|
+
}
|
|
194
|
+
catch (error) {
|
|
195
|
+
if (error.code === '23505')
|
|
196
|
+
throw new AdulaError(409, 'E_SYNC_JOB_BUSY', 'مهمة المزامنة بانتظار التشغيل أو قيد التشغيل بالفعل');
|
|
197
|
+
throw error;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
/** Runs the oldest queued run of a defined job; null when nothing is queued. */
|
|
201
|
+
async runNext() {
|
|
202
|
+
await this.recoverStale();
|
|
203
|
+
// A job whose abandoned handler is still alive here is not claimed until it settles.
|
|
204
|
+
const names = [...this.definitions.keys()].filter((name) => !abandonedHandlers.has(name));
|
|
205
|
+
if (!names.length)
|
|
206
|
+
return null;
|
|
207
|
+
const claimed = await this.db.transaction(async (trx) => {
|
|
208
|
+
const row = await trx('sync_job_runs')
|
|
209
|
+
.where('status', 'queued')
|
|
210
|
+
.whereIn('job', names)
|
|
211
|
+
.orderBy([{ column: 'queued_at' }, { column: 'id' }])
|
|
212
|
+
.forUpdate()
|
|
213
|
+
.skipLocked()
|
|
214
|
+
.first();
|
|
215
|
+
if (!row)
|
|
216
|
+
return null;
|
|
217
|
+
const [running] = await trx('sync_job_runs')
|
|
218
|
+
.where('id', row.id)
|
|
219
|
+
.update({ status: 'running', started_at: trx.fn.now() })
|
|
220
|
+
.returning('*');
|
|
221
|
+
return running;
|
|
222
|
+
});
|
|
223
|
+
if (!claimed)
|
|
224
|
+
return null;
|
|
225
|
+
const definition = this.definition(String(claimed.job));
|
|
226
|
+
const runId = Number(claimed.id);
|
|
227
|
+
const requestedBy = claimed.requested_by === null ? null : Number(claimed.requested_by);
|
|
228
|
+
const last = await this.db('sync_job_runs')
|
|
229
|
+
.where({ job: definition.name, status: 'succeeded' })
|
|
230
|
+
.max('finished_at as at')
|
|
231
|
+
.first();
|
|
232
|
+
const base = this.options.logger ?? silent;
|
|
233
|
+
const tag = { job: definition.name, runId };
|
|
234
|
+
const controller = new AbortController();
|
|
235
|
+
// After the timeout the handler's tools refuse, so an ignored signal cannot keep writing.
|
|
236
|
+
const live = () => {
|
|
237
|
+
if (controller.signal.aborted)
|
|
238
|
+
throw controller.signal.reason;
|
|
239
|
+
};
|
|
240
|
+
const logger = {
|
|
241
|
+
info: (message, data) => (live(), base.info(message, { ...tag, ...data })),
|
|
242
|
+
warn: (message, data) => (live(), base.warn(message, { ...tag, ...data })),
|
|
243
|
+
error: (message, data) => (live(), base.error(message, { ...tag, ...data })),
|
|
244
|
+
};
|
|
245
|
+
const margin = this.options.staleMarginMs ?? STALE_MARGIN_MS;
|
|
246
|
+
const timers = [];
|
|
247
|
+
timers.push(setTimeout(() => controller.abort(new SyncJobError('timeout', `Sync job exceeded ${definition.timeoutMs} ms`)), definition.timeoutMs));
|
|
248
|
+
// The row stays running (and the job busy) until the handler settles. One that never
|
|
249
|
+
// settles is abandoned at the stale limit, as recoverStale would do for a crash.
|
|
250
|
+
const abandoned = new Promise((resolve) => {
|
|
251
|
+
timers.push(setTimeout(() => resolve({ abandoned: true }), definition.timeoutMs + margin));
|
|
252
|
+
});
|
|
253
|
+
const started = Date.now();
|
|
254
|
+
const settled = Promise.resolve()
|
|
255
|
+
.then(() => definition.handler({
|
|
256
|
+
jobName: definition.name,
|
|
257
|
+
runId,
|
|
258
|
+
trigger: claimed.trigger,
|
|
259
|
+
requestedBy,
|
|
260
|
+
lastSuccessAt: last?.at ? new Date(last.at) : null,
|
|
261
|
+
signal: controller.signal,
|
|
262
|
+
logger,
|
|
263
|
+
systemSave: async (resource, values, { id, actorId, ...options } = {}) => {
|
|
264
|
+
live();
|
|
265
|
+
return this.resources.systemSave(resource, values, id, {
|
|
266
|
+
reason: definition.name,
|
|
267
|
+
...options,
|
|
268
|
+
actorId: actorId === undefined ? requestedBy : actorId,
|
|
269
|
+
});
|
|
270
|
+
},
|
|
271
|
+
}))
|
|
272
|
+
.then((stats) => ({ ok: true, stats }), (error) => ({ ok: false, error }));
|
|
273
|
+
const outcome = await Promise.race([settled, abandoned]);
|
|
274
|
+
for (const timer of timers)
|
|
275
|
+
clearTimeout(timer);
|
|
276
|
+
if ('abandoned' in outcome) {
|
|
277
|
+
const job = definition.name;
|
|
278
|
+
abandonedHandlers.set(job, (abandonedHandlers.get(job) ?? 0) + 1);
|
|
279
|
+
base.warn('Sync job handler ignored its abort; the job is held until it settles', tag);
|
|
280
|
+
void settled.then(() => {
|
|
281
|
+
const left = (abandonedHandlers.get(job) ?? 1) - 1;
|
|
282
|
+
if (left > 0)
|
|
283
|
+
abandonedHandlers.set(job, left);
|
|
284
|
+
else
|
|
285
|
+
abandonedHandlers.delete(job);
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
let update;
|
|
289
|
+
if ('abandoned' in outcome || controller.signal.aborted) {
|
|
290
|
+
update = {
|
|
291
|
+
status: 'failed',
|
|
292
|
+
error_category: 'timeout',
|
|
293
|
+
error_message: sanitize('abandoned' in outcome
|
|
294
|
+
? 'لم تتوقف المهمة بعد انتهاء مهلتها؛ أوقفت كتاباتها واعتُبرت منتهية المهلة'
|
|
295
|
+
: controller.signal.reason),
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
else if (outcome.ok) {
|
|
299
|
+
update = { status: 'succeeded', stats: JSON.stringify(numericStats(outcome.stats)) };
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
const category = syncErrorCategory(outcome.error);
|
|
303
|
+
update = {
|
|
304
|
+
status: 'failed',
|
|
305
|
+
error_category: category,
|
|
306
|
+
error_message: sanitize(outcome.error),
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
if (update.status === 'failed')
|
|
310
|
+
base.warn('Sync job failed', { ...tag, category: update.error_category });
|
|
311
|
+
// Conditional on running: a run stale recovery already closed is never overwritten.
|
|
312
|
+
const [row] = await this.db('sync_job_runs')
|
|
313
|
+
.where({ id: runId, status: 'running' })
|
|
314
|
+
.update({ ...update, finished_at: this.db.fn.now(), duration_ms: Date.now() - started })
|
|
315
|
+
.returning('*');
|
|
316
|
+
// Stale recovery may already have closed the run; report what is stored.
|
|
317
|
+
return this.serialize(row ?? (await this.db('sync_job_runs').where('id', runId).first()));
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Marks running rows older than their timeout plus a margin as failed timeouts, so a
|
|
321
|
+
* worker that crashed mid-run does not block the job forever.
|
|
322
|
+
*/
|
|
323
|
+
async recoverStale() {
|
|
324
|
+
const margin = this.options.staleMarginMs ?? STALE_MARGIN_MS;
|
|
325
|
+
const rows = await this.db('sync_job_runs')
|
|
326
|
+
.where('status', 'running')
|
|
327
|
+
.select('id', 'job', 'started_at');
|
|
328
|
+
let recovered = 0;
|
|
329
|
+
for (const row of rows) {
|
|
330
|
+
const limit = (this.definitions.get(row.job)?.timeoutMs ?? SYNC_DEFAULT_TIMEOUT_MS) + margin;
|
|
331
|
+
if (Date.now() - new Date(row.started_at).getTime() <= limit)
|
|
332
|
+
continue;
|
|
333
|
+
recovered += await this.db('sync_job_runs').where({ id: row.id, status: 'running' }).update({
|
|
334
|
+
status: 'failed',
|
|
335
|
+
finished_at: this.db.fn.now(),
|
|
336
|
+
error_category: 'timeout',
|
|
337
|
+
error_message: 'توقف التشغيل دون نتيجة؛ اعتُبر منتهي المهلة',
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
return recovered;
|
|
341
|
+
}
|
|
342
|
+
/** Every defined job with its latest run, last success and next scheduled time. */
|
|
343
|
+
async list(now = new Date()) {
|
|
344
|
+
const names = [...this.definitions.keys()];
|
|
345
|
+
if (!names.length)
|
|
346
|
+
return [];
|
|
347
|
+
const latest = await this.db('sync_job_runs')
|
|
348
|
+
.distinctOn('job')
|
|
349
|
+
.whereIn('job', names)
|
|
350
|
+
.orderBy([{ column: 'job' }, { column: 'id', order: 'desc' }]);
|
|
351
|
+
const finished = await this.db('sync_job_runs')
|
|
352
|
+
.distinctOn('job')
|
|
353
|
+
.whereIn('job', names)
|
|
354
|
+
.whereIn('status', ['succeeded', 'failed'])
|
|
355
|
+
.orderBy([{ column: 'job' }, { column: 'id', order: 'desc' }]);
|
|
356
|
+
const successes = await this.db('sync_job_runs')
|
|
357
|
+
.whereIn('job', names)
|
|
358
|
+
.where('status', 'succeeded')
|
|
359
|
+
.groupBy('job')
|
|
360
|
+
.select('job')
|
|
361
|
+
.max('finished_at as at');
|
|
362
|
+
const busy = await this.db('sync_job_runs')
|
|
363
|
+
.whereIn('job', names)
|
|
364
|
+
.whereIn('status', ['queued', 'running'])
|
|
365
|
+
.distinct('job');
|
|
366
|
+
return this.all().map((definition) => {
|
|
367
|
+
const last = latest.find((row) => row.job === definition.name);
|
|
368
|
+
const done = finished.find((row) => row.job === definition.name);
|
|
369
|
+
const next = nextCronTime(this.crons.get(definition.name), now);
|
|
370
|
+
return {
|
|
371
|
+
name: definition.name,
|
|
372
|
+
label: definition.label,
|
|
373
|
+
cron: definition.cron,
|
|
374
|
+
timeoutMs: definition.timeoutMs,
|
|
375
|
+
busy: abandonedHandlers.has(definition.name) || busy.some((row) => row.job === definition.name),
|
|
376
|
+
lastRun: last ? this.serialize(last) : null,
|
|
377
|
+
lastSuccessAt: iso(successes.find((row) => row.job === definition.name)?.at),
|
|
378
|
+
lastErrorCategory: done?.status === 'failed' ? done.error_category : null,
|
|
379
|
+
nextRunAt: next ? next.toISOString() : null,
|
|
380
|
+
};
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
/** Run history of one job, newest first. */
|
|
384
|
+
async runs(name, limit = 20) {
|
|
385
|
+
this.definition(name);
|
|
386
|
+
const rows = await this.db('sync_job_runs')
|
|
387
|
+
.where('job', name)
|
|
388
|
+
.orderBy('id', 'desc')
|
|
389
|
+
.limit(Math.min(Math.max(Math.trunc(limit) || 20, 1), 100));
|
|
390
|
+
return rows.map((row) => this.serialize(row));
|
|
391
|
+
}
|
|
392
|
+
serialize(row) {
|
|
393
|
+
return {
|
|
394
|
+
id: Number(row.id),
|
|
395
|
+
job: String(row.job),
|
|
396
|
+
trigger: row.trigger,
|
|
397
|
+
status: row.status,
|
|
398
|
+
requestedBy: row.requested_by === null ? null : Number(row.requested_by),
|
|
399
|
+
queuedAt: iso(row.queued_at),
|
|
400
|
+
startedAt: iso(row.started_at),
|
|
401
|
+
finishedAt: iso(row.finished_at),
|
|
402
|
+
durationMs: row.duration_ms === null ? null : Number(row.duration_ms),
|
|
403
|
+
errorCategory: row.error_category ?? null,
|
|
404
|
+
errorMessage: row.error_message ?? null,
|
|
405
|
+
stats: row.stats ?? {},
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
/** Keeps finite numeric counters only, so stats stay small and safe to display. */
|
|
410
|
+
function numericStats(stats) {
|
|
411
|
+
if (!stats || typeof stats !== 'object')
|
|
412
|
+
return {};
|
|
413
|
+
return Object.fromEntries(Object.entries(stats)
|
|
414
|
+
.filter(([key, value]) => key.length <= 64 && typeof value === 'number' && Number.isFinite(value))
|
|
415
|
+
.slice(0, 50));
|
|
416
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Knex } from 'knex';
|
|
2
2
|
import type { ResourceRegistry } from '../resource/registry.js';
|
|
3
3
|
import type { Listener } from '../events/outbox.js';
|
|
4
|
+
import { type OutboundOptions, type OutboundRequest } from './outbound.js';
|
|
4
5
|
/** Seals webhook secrets at rest; hosts pass their framework encryption service. */
|
|
5
6
|
export type SecretBox = {
|
|
6
7
|
seal(value: string): string;
|
|
@@ -27,17 +28,13 @@ export type WebhookDelivery = {
|
|
|
27
28
|
deliveredAt: string | null;
|
|
28
29
|
nextAttemptAt: string | null;
|
|
29
30
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
export type HttpPoster = (url: string, init: {
|
|
37
|
-
headers: Record<string, string>;
|
|
38
|
-
body: string;
|
|
39
|
-
signal: AbortSignal;
|
|
40
|
-
}) => Promise<{
|
|
31
|
+
/** Outbound target policy; private targets need an explicit opt-in. */
|
|
32
|
+
export type WebhookOptions = OutboundOptions;
|
|
33
|
+
/**
|
|
34
|
+
* Sends one POST. `init.target` is the address validated for this delivery;
|
|
35
|
+
* a poster must connect to it (createOutboundPoster does) to defeat DNS rebinding.
|
|
36
|
+
*/
|
|
37
|
+
export type HttpPoster = (url: string, init: OutboundRequest) => Promise<{
|
|
41
38
|
status: number;
|
|
42
39
|
}>;
|
|
43
40
|
export declare const WEBHOOK_MAX_ATTEMPTS: number;
|
|
@@ -87,12 +84,15 @@ export declare class Webhooks {
|
|
|
87
84
|
* Sends due deliveries. Each row is claimed with SKIP LOCKED; a crash after the
|
|
88
85
|
* HTTP call may repeat a delivery, so receivers deduplicate on X-Adula-Delivery.
|
|
89
86
|
*/
|
|
90
|
-
deliver(post
|
|
87
|
+
deliver(post?: HttpPoster, limit?: number): Promise<{
|
|
91
88
|
delivered: number;
|
|
92
89
|
failed: number;
|
|
93
90
|
}>;
|
|
94
91
|
private validate;
|
|
95
92
|
/** Refuses non-HTTPS URLs and hosts resolving to private addresses (SSRF). */
|
|
96
93
|
private assertTarget;
|
|
94
|
+
/** Re-validates a stored URL at delivery time and returns the address to pin. */
|
|
95
|
+
private resolveTarget;
|
|
96
|
+
private parseTarget;
|
|
97
97
|
private present;
|
|
98
98
|
}
|