@nivaro/extension-kit 0.1.1
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 +78 -0
- package/dist/column-probe.d.ts +9 -0
- package/dist/column-probe.d.ts.map +1 -0
- package/dist/column-probe.js +58 -0
- package/dist/column-probe.js.map +1 -0
- package/dist/context.d.ts +361 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +2 -0
- package/dist/context.js.map +1 -0
- package/dist/flows.d.ts +58 -0
- package/dist/flows.d.ts.map +1 -0
- package/dist/flows.js +2 -0
- package/dist/flows.js.map +1 -0
- package/dist/hooks.d.ts +26 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +2 -0
- package/dist/hooks.js.map +1 -0
- package/dist/imports.d.ts +155 -0
- package/dist/imports.d.ts.map +1 -0
- package/dist/imports.js +2 -0
- package/dist/imports.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/notifications.d.ts +183 -0
- package/dist/notifications.d.ts.map +1 -0
- package/dist/notifications.js +2 -0
- package/dist/notifications.js.map +1 -0
- package/dist/obligations.d.ts +66 -0
- package/dist/obligations.d.ts.map +1 -0
- package/dist/obligations.js +2 -0
- package/dist/obligations.js.map +1 -0
- package/dist/registrations.d.ts +470 -0
- package/dist/registrations.d.ts.map +1 -0
- package/dist/registrations.js +2 -0
- package/dist/registrations.js.map +1 -0
- package/dist/requester-columns.d.ts +26 -0
- package/dist/requester-columns.d.ts.map +1 -0
- package/dist/requester-columns.js +17 -0
- package/dist/requester-columns.js.map +1 -0
- package/dist/signals.d.ts +77 -0
- package/dist/signals.d.ts.map +1 -0
- package/dist/signals.js +2 -0
- package/dist/signals.js.map +1 -0
- package/dist/testing.d.ts +193 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +615 -0
- package/dist/testing.js.map +1 -0
- package/dist/user.d.ts +27 -0
- package/dist/user.d.ts.map +1 -0
- package/dist/user.js +2 -0
- package/dist/user.js.map +1 -0
- package/package.json +59 -0
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
import type { FastifyRequest } from 'fastify';
|
|
2
|
+
import type { Knex } from 'knex';
|
|
3
|
+
import type { ExtensionUser } from './user.js';
|
|
4
|
+
export type BulkActionAccess = {
|
|
5
|
+
mode: 'everyone' | 'admin' | 'roles';
|
|
6
|
+
role_ids?: string[];
|
|
7
|
+
};
|
|
8
|
+
export interface BulkActionContext {
|
|
9
|
+
collection: string;
|
|
10
|
+
ids: (string | number)[];
|
|
11
|
+
payload?: Record<string, unknown>;
|
|
12
|
+
reason?: string | null;
|
|
13
|
+
userId?: string;
|
|
14
|
+
}
|
|
15
|
+
/** A bulk action shown in the collection browser / queue selection bar. */
|
|
16
|
+
export interface BulkActionDef {
|
|
17
|
+
id: string;
|
|
18
|
+
label: string;
|
|
19
|
+
/** Optional icon name from lucide (informational — the admin renders it). */
|
|
20
|
+
icon?: string;
|
|
21
|
+
/** If provided, only shown for these collections. Omit for all. */
|
|
22
|
+
collections?: string[];
|
|
23
|
+
/** 'danger' renders red (destructive). */
|
|
24
|
+
variant?: 'default' | 'danger';
|
|
25
|
+
/** Defaults to everyone (with update permission on the collection). */
|
|
26
|
+
access?: BulkActionAccess;
|
|
27
|
+
/** The bar prompts for a reason and passes it as ctx.reason. */
|
|
28
|
+
require_reason?: boolean;
|
|
29
|
+
/** Confirm text shown before running. */
|
|
30
|
+
confirm?: string;
|
|
31
|
+
/** Called by the API route. Return a message shown in the admin toast. */
|
|
32
|
+
execute(ctx: BulkActionContext): Promise<{
|
|
33
|
+
message: string;
|
|
34
|
+
}>;
|
|
35
|
+
}
|
|
36
|
+
export interface ItemActionContext {
|
|
37
|
+
collection: string;
|
|
38
|
+
itemId: string | number;
|
|
39
|
+
payload?: Record<string, unknown>;
|
|
40
|
+
userId?: string;
|
|
41
|
+
}
|
|
42
|
+
/** A contextual button in the record form's toolbar. */
|
|
43
|
+
export interface ItemActionDef {
|
|
44
|
+
id: string;
|
|
45
|
+
label: string;
|
|
46
|
+
icon?: string;
|
|
47
|
+
/** Only shown for these collections. Omit for all. */
|
|
48
|
+
collections?: string[];
|
|
49
|
+
/** Hint for the admin: 'default' | 'destructive' | 'outline' */
|
|
50
|
+
variant?: 'default' | 'destructive' | 'outline';
|
|
51
|
+
/** When present, clients show a confirmation dialog before executing. */
|
|
52
|
+
confirm?: {
|
|
53
|
+
title?: string;
|
|
54
|
+
body?: string;
|
|
55
|
+
confirm_label?: string;
|
|
56
|
+
input?: {
|
|
57
|
+
label: string;
|
|
58
|
+
placeholder?: string;
|
|
59
|
+
required?: boolean;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
execute(ctx: ItemActionContext): Promise<{
|
|
63
|
+
message: string;
|
|
64
|
+
data?: unknown;
|
|
65
|
+
}>;
|
|
66
|
+
/** The action CREATES AN ADDENDUM: core enforces the addendum-create gates
|
|
67
|
+
* (collection toggle, role allow-list, pipeline-state allow-list) — the
|
|
68
|
+
* button hides when the caller could not create one, and execute 403s with
|
|
69
|
+
* the gate's reason. Declared, not implemented. */
|
|
70
|
+
requires_addendum_create?: boolean;
|
|
71
|
+
/** Per-record applicability; the client hides inapplicable buttons. Errors
|
|
72
|
+
* count as applicable — a broken check must not hide a working action. */
|
|
73
|
+
applicable?(ctx: {
|
|
74
|
+
collection: string;
|
|
75
|
+
itemId: string | number;
|
|
76
|
+
}): Promise<boolean>;
|
|
77
|
+
}
|
|
78
|
+
export interface DashboardWidgetDef {
|
|
79
|
+
type: string;
|
|
80
|
+
label: string;
|
|
81
|
+
icon?: string;
|
|
82
|
+
/** JSON schema for the widget's configuration options. */
|
|
83
|
+
configSchema?: Record<string, unknown>;
|
|
84
|
+
description?: string;
|
|
85
|
+
}
|
|
86
|
+
export interface CollectionViewDef {
|
|
87
|
+
id: string;
|
|
88
|
+
label: string;
|
|
89
|
+
icon?: string;
|
|
90
|
+
/** URL of the extension's UI bundle that renders this view. */
|
|
91
|
+
bundleUrl?: string;
|
|
92
|
+
/** Optional field mappings to configure the view (e.g. titleField, dateField). */
|
|
93
|
+
fieldMappings?: Array<{
|
|
94
|
+
key: string;
|
|
95
|
+
label: string;
|
|
96
|
+
required?: boolean;
|
|
97
|
+
}>;
|
|
98
|
+
/** Which collections this view supports. Omit for all. */
|
|
99
|
+
collections?: string[];
|
|
100
|
+
}
|
|
101
|
+
export interface FieldTypeDef {
|
|
102
|
+
type: string;
|
|
103
|
+
label: string;
|
|
104
|
+
/** Which built-in interface the admin field editor falls back to. */
|
|
105
|
+
interface?: 'text' | 'textarea' | 'number' | 'boolean' | 'date' | 'json';
|
|
106
|
+
/** JSON schema for validation. Applied server-side on create/update. */
|
|
107
|
+
validationSchema?: Record<string, unknown>;
|
|
108
|
+
/** Transform the raw value before storing. */
|
|
109
|
+
serialize?(value: unknown): unknown;
|
|
110
|
+
/** Transform the stored value before returning to clients. */
|
|
111
|
+
deserialize?(value: unknown): unknown;
|
|
112
|
+
}
|
|
113
|
+
export interface ValidatorDef {
|
|
114
|
+
/** Operator name used in validation_rules JSON, e.g. 'phone', 'iban', 'luhn'. */
|
|
115
|
+
operator: string;
|
|
116
|
+
label: string;
|
|
117
|
+
/** Returns null on pass, or an error message string on fail. */
|
|
118
|
+
validate(value: unknown, options?: unknown): string | null;
|
|
119
|
+
}
|
|
120
|
+
export interface StorageFileMeta {
|
|
121
|
+
filename: string;
|
|
122
|
+
mimetype: string;
|
|
123
|
+
size: number;
|
|
124
|
+
}
|
|
125
|
+
export interface StorageAdapter {
|
|
126
|
+
/** Store a file. `stream` is a readable stream of the file contents. */
|
|
127
|
+
put(key: string, stream: NodeJS.ReadableStream, meta: StorageFileMeta): Promise<void>;
|
|
128
|
+
/** Return a readable stream for the file. */
|
|
129
|
+
get(key: string): Promise<NodeJS.ReadableStream>;
|
|
130
|
+
/** Delete a file. Must not throw if the key does not exist. */
|
|
131
|
+
delete(key: string): Promise<void>;
|
|
132
|
+
/** Return a public or pre-signed URL, or null if serving via proxy. */
|
|
133
|
+
url(key: string): Promise<string | null>;
|
|
134
|
+
}
|
|
135
|
+
export interface ParsedRow {
|
|
136
|
+
[column: string]: string;
|
|
137
|
+
}
|
|
138
|
+
export interface ImportParserDef {
|
|
139
|
+
/** MIME type(s) this parser handles. */
|
|
140
|
+
mimeTypes: string[];
|
|
141
|
+
/** File extension(s), e.g. ['xlsx', 'xls']. */
|
|
142
|
+
extensions: string[];
|
|
143
|
+
label: string;
|
|
144
|
+
/** Parse raw file content (Buffer or string) into column-named rows. */
|
|
145
|
+
parse(content: Buffer | string): Promise<ParsedRow[]> | ParsedRow[];
|
|
146
|
+
}
|
|
147
|
+
export interface RelatedNoteEntry {
|
|
148
|
+
/** Stable id within the provider, e.g. the source row id. */
|
|
149
|
+
id: string | number;
|
|
150
|
+
/** Badge text, e.g. the integration's name. */
|
|
151
|
+
label: string;
|
|
152
|
+
text: string;
|
|
153
|
+
/** A user id when a person wrote it; null for machine events. */
|
|
154
|
+
user?: string | null;
|
|
155
|
+
created_at: string | Date;
|
|
156
|
+
/** Secondary context line ("Order 12345"). */
|
|
157
|
+
context?: string | null;
|
|
158
|
+
/** Optional record the entry belongs to (renders a jump link). */
|
|
159
|
+
link?: {
|
|
160
|
+
collection: string;
|
|
161
|
+
item_id: string;
|
|
162
|
+
};
|
|
163
|
+
/** The provider can re-apply this event — the thread shows a Replay action. */
|
|
164
|
+
replayable?: boolean;
|
|
165
|
+
/** Machine status of the event, for the feed's filter. */
|
|
166
|
+
status?: 'ok' | 'error' | 'info' | null;
|
|
167
|
+
}
|
|
168
|
+
export interface RelatedNoteFeedEntry extends RelatedNoteEntry {
|
|
169
|
+
collection: string;
|
|
170
|
+
item_id: string;
|
|
171
|
+
/** Friendly record label when the provider knows one. */
|
|
172
|
+
item_label?: string | null;
|
|
173
|
+
}
|
|
174
|
+
/** Read-only entries for a record's Notes thread and the Events feed. */
|
|
175
|
+
export interface RelatedNoteProvider {
|
|
176
|
+
/** Unique provider id — conventionally `<extension>:<what>`. */
|
|
177
|
+
id: string;
|
|
178
|
+
/** The business collection whose threads this provider feeds. */
|
|
179
|
+
collection: string;
|
|
180
|
+
/** Human name for the feed's integration filter. */
|
|
181
|
+
label?: string;
|
|
182
|
+
load(item: string): Promise<RelatedNoteEntry[]>;
|
|
183
|
+
/** Newest entries ACROSS records (a feed page, not a thread). */
|
|
184
|
+
list?(opts: {
|
|
185
|
+
limit: number;
|
|
186
|
+
status?: 'ok' | 'error' | 'info' | null;
|
|
187
|
+
/** Older-than cursor (ISO) — a provider MAY honour it. */
|
|
188
|
+
before?: string | null;
|
|
189
|
+
}): Promise<RelatedNoteFeedEntry[]>;
|
|
190
|
+
/** One entry by id, however old. Null when it does not exist. */
|
|
191
|
+
get?(entryId: string): Promise<RelatedNoteFeedEntry | null>;
|
|
192
|
+
/** Re-fetch / re-apply one event from its stored form. */
|
|
193
|
+
replay?(entryId: string, opts: {
|
|
194
|
+
userId: string | null;
|
|
195
|
+
}): Promise<{
|
|
196
|
+
detail: string;
|
|
197
|
+
}>;
|
|
198
|
+
}
|
|
199
|
+
/** Comment strings an extension's machinery writes, so the Notes thread
|
|
200
|
+
* drops them and row history renders them as provenance. */
|
|
201
|
+
export interface MachineMarkerSet {
|
|
202
|
+
/** Whole-comment matches, case-insensitive ("legacy-import"). */
|
|
203
|
+
exact?: string[];
|
|
204
|
+
/** Prefix matches, case-insensitive ("forecast-import:"). */
|
|
205
|
+
prefixes?: string[];
|
|
206
|
+
}
|
|
207
|
+
export type ReadinessStatus = 'pass' | 'warn' | 'fail' | 'skip';
|
|
208
|
+
export interface ReadinessResult {
|
|
209
|
+
status: ReadinessStatus;
|
|
210
|
+
/** One-sentence current state, shown under the check. */
|
|
211
|
+
detail?: string;
|
|
212
|
+
/** Concrete blockers to resolve, listed as bullet lines. */
|
|
213
|
+
blockers?: string[];
|
|
214
|
+
}
|
|
215
|
+
/** A scored check on the go-live readiness scorecard. */
|
|
216
|
+
export interface ReadinessCheck {
|
|
217
|
+
id: string;
|
|
218
|
+
label: string;
|
|
219
|
+
description?: string;
|
|
220
|
+
/** Grouping header on the scorecard (e.g. 'Data', 'Integrations'). */
|
|
221
|
+
group?: string;
|
|
222
|
+
run: () => Promise<ReadinessResult>;
|
|
223
|
+
/** Optional automatic fix. Runs as a BACKGROUND job with server-held
|
|
224
|
+
* progress, so the admin can navigate away and come back. */
|
|
225
|
+
remediation?: {
|
|
226
|
+
label: string;
|
|
227
|
+
run: () => Promise<{
|
|
228
|
+
detail: string;
|
|
229
|
+
}>;
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
export interface IntegrityFinding {
|
|
233
|
+
item_id: string;
|
|
234
|
+
message: string;
|
|
235
|
+
}
|
|
236
|
+
export interface IntegrityFixArgs {
|
|
237
|
+
id: string;
|
|
238
|
+
message: string | null;
|
|
239
|
+
user: ExtensionUser;
|
|
240
|
+
req?: FastifyRequest;
|
|
241
|
+
}
|
|
242
|
+
/** A Data Integrity check the conformance sweep, the record banner and the
|
|
243
|
+
* Fix button run alongside the built-in rules. */
|
|
244
|
+
export interface IntegrityCheck {
|
|
245
|
+
/** Rule key on the findings ('forecast-missing'); kebab-case, unique. */
|
|
246
|
+
id: string;
|
|
247
|
+
collection: string;
|
|
248
|
+
/** Human rule label for the Data Integrity facets. */
|
|
249
|
+
label: string;
|
|
250
|
+
/** The field the finding anchors to on the form (a grid alias or column). */
|
|
251
|
+
field: string;
|
|
252
|
+
run(ids: string[]): Promise<IntegrityFinding[]>;
|
|
253
|
+
/** Optional one-click fix; `fix_label` is the proposal's button text. */
|
|
254
|
+
fix_label?: string;
|
|
255
|
+
fix?(args: IntegrityFixArgs): Promise<{
|
|
256
|
+
fixed: boolean;
|
|
257
|
+
detail?: string;
|
|
258
|
+
}>;
|
|
259
|
+
}
|
|
260
|
+
export interface BriefLine {
|
|
261
|
+
label: string;
|
|
262
|
+
text: string;
|
|
263
|
+
tone?: 'ok' | 'warn' | 'danger' | 'neutral';
|
|
264
|
+
}
|
|
265
|
+
/** One short line on the transition confirm's approval brief. */
|
|
266
|
+
export type BriefLineProvider = (args: {
|
|
267
|
+
collection: string;
|
|
268
|
+
item: string;
|
|
269
|
+
}) => Promise<BriefLine | null>;
|
|
270
|
+
export type LinkKind = 'record' | 'queue' | 'report' | 'alerts' | 'chat' | 'tasks' | 'approvals' | 'access_requests' | 'notifications' | 'my_work' | 'home' | 'profile' | 'issues' | 'imports' | 'dashboard' | 'integrations';
|
|
271
|
+
/** The headless frontend's base URL + route map, so email links land there. */
|
|
272
|
+
export interface LinkRegistration {
|
|
273
|
+
/** Portal origin, no trailing slash. */
|
|
274
|
+
base: string;
|
|
275
|
+
/** Route templates per kind: '/records/{collection}/{id}'. Missing kinds
|
|
276
|
+
* fall back to the admin route. */
|
|
277
|
+
routes: Partial<Record<LinkKind, string>>;
|
|
278
|
+
}
|
|
279
|
+
export interface CallOptions {
|
|
280
|
+
method?: string;
|
|
281
|
+
path?: string;
|
|
282
|
+
body?: unknown;
|
|
283
|
+
headers?: Record<string, string>;
|
|
284
|
+
query?: Record<string, string>;
|
|
285
|
+
timeoutMs?: number;
|
|
286
|
+
/** Pre-defined endpoint name or id. Sets method/path/body/query/headers
|
|
287
|
+
* defaults; caller options override. */
|
|
288
|
+
endpoint?: string | number;
|
|
289
|
+
/** Logging context — omit to skip logging. */
|
|
290
|
+
_log?: {
|
|
291
|
+
triggeredBy?: string;
|
|
292
|
+
userId?: string;
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
export interface CallResult {
|
|
296
|
+
status: number;
|
|
297
|
+
headers: Record<string, string>;
|
|
298
|
+
body: unknown;
|
|
299
|
+
/** Answered by this instance's mock rules, no network call was made. */
|
|
300
|
+
mock?: boolean;
|
|
301
|
+
}
|
|
302
|
+
/** Core tables whose rows carry an integration event chain. */
|
|
303
|
+
export type ChainTable = 'nivaro_activity' | 'nivaro_api_logs' | 'nivaro_erp_submissions' | 'nivaro_erp_submission_attempts' | 'nivaro_external_api_logs' | 'nivaro_workflow_history' | 'nivaro_flow_runs';
|
|
304
|
+
export type EventDirection = 'in' | 'out' | 'poll';
|
|
305
|
+
export interface EventEntry {
|
|
306
|
+
id: string;
|
|
307
|
+
source: string;
|
|
308
|
+
direction: EventDirection;
|
|
309
|
+
label: string;
|
|
310
|
+
text: string;
|
|
311
|
+
context?: string | null;
|
|
312
|
+
created_at: string;
|
|
313
|
+
status?: 'ok' | 'error' | 'info' | null;
|
|
314
|
+
user?: string | null;
|
|
315
|
+
collection: string | null;
|
|
316
|
+
item_id: string | null;
|
|
317
|
+
item_label?: string | null;
|
|
318
|
+
record_count?: number;
|
|
319
|
+
partner?: string | null;
|
|
320
|
+
caller?: string | null;
|
|
321
|
+
chain_id?: string | null;
|
|
322
|
+
replayable?: boolean;
|
|
323
|
+
}
|
|
324
|
+
export interface EventListOpts {
|
|
325
|
+
limit: number;
|
|
326
|
+
status?: 'ok' | 'error' | 'info' | null;
|
|
327
|
+
before?: string | null;
|
|
328
|
+
partner?: string | null;
|
|
329
|
+
caller?: string | null;
|
|
330
|
+
includePeople?: boolean;
|
|
331
|
+
/** Record search: restrict to these chains. */
|
|
332
|
+
chainIds?: string[] | null;
|
|
333
|
+
record?: {
|
|
334
|
+
collection: string;
|
|
335
|
+
item: string;
|
|
336
|
+
} | null;
|
|
337
|
+
}
|
|
338
|
+
/** An event source on the Integrations console's Events feed. */
|
|
339
|
+
export interface EventSourceDef {
|
|
340
|
+
id: string;
|
|
341
|
+
label: string;
|
|
342
|
+
direction: EventDirection;
|
|
343
|
+
list(opts: EventListOpts): Promise<EventEntry[]>;
|
|
344
|
+
get?(id: string): Promise<EventEntry | null>;
|
|
345
|
+
}
|
|
346
|
+
/** A tool the AI chat bot may call. Handlers run with the ASKING user — the
|
|
347
|
+
* extension owns its permission posture. */
|
|
348
|
+
export interface BotToolDef {
|
|
349
|
+
name: string;
|
|
350
|
+
description: string;
|
|
351
|
+
input_schema: Record<string, unknown>;
|
|
352
|
+
handler: (asker: ExtensionUser, input: Record<string, unknown>) => Promise<unknown>;
|
|
353
|
+
}
|
|
354
|
+
export interface OpsTaskRunContext {
|
|
355
|
+
/** A line of output the console shows as the task runs. */
|
|
356
|
+
log(line: string): void;
|
|
357
|
+
/** Rows done so far, for a progress bar. */
|
|
358
|
+
progress(done: number, total?: number): void;
|
|
359
|
+
/** True once an admin asked the run to stop; check it between chunks. */
|
|
360
|
+
cancelled(): boolean;
|
|
361
|
+
/** Who started the run (null for a cron). */
|
|
362
|
+
userId: string | null;
|
|
363
|
+
/** True on a dry run — the task must write nothing. */
|
|
364
|
+
dryRun: boolean;
|
|
365
|
+
}
|
|
366
|
+
export interface OpsTaskOutcome {
|
|
367
|
+
/** One line the run list shows ('312 rows would move', '0 duplicates'). */
|
|
368
|
+
summary: string;
|
|
369
|
+
/** Counts the console renders as tiles. */
|
|
370
|
+
counts?: Record<string, number>;
|
|
371
|
+
/** Tables the run created and left behind (backups), by name. */
|
|
372
|
+
backup_tables?: string[];
|
|
373
|
+
/** What still needs a person after this run. */
|
|
374
|
+
follow_up?: string | null;
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* A repair, backfill or migration an extension owns, run from the admin
|
|
378
|
+
* console: dry run by default, one run at a time per task, every run a
|
|
379
|
+
* job-runs row with its output kept. Registered with `ctx.tasks.register`.
|
|
380
|
+
*/
|
|
381
|
+
export interface OpsTaskDef {
|
|
382
|
+
/** `<extension>:<name>` — unique, kebab-case name. */
|
|
383
|
+
key: string;
|
|
384
|
+
label: string;
|
|
385
|
+
/** What it fixes or produces, in a sentence or two. */
|
|
386
|
+
description: string;
|
|
387
|
+
/** Console grouping ('Data repairs', 'Backfills'). */
|
|
388
|
+
group?: string;
|
|
389
|
+
/** What a real run leaves behind (a backup table, rows to review). */
|
|
390
|
+
leaves_behind?: string | null;
|
|
391
|
+
/** What to do after a real run ('re-run the rollup backfill'). */
|
|
392
|
+
follow_up?: string | null;
|
|
393
|
+
/** A shell command that does the same thing, for a host where the task
|
|
394
|
+
* cannot run (a built image without its script sources). */
|
|
395
|
+
cli?: string | null;
|
|
396
|
+
/** Whether the task can run on THIS host, and why not. Default: yes. */
|
|
397
|
+
available?(): {
|
|
398
|
+
ok: boolean;
|
|
399
|
+
reason?: string;
|
|
400
|
+
} | Promise<{
|
|
401
|
+
ok: boolean;
|
|
402
|
+
reason?: string;
|
|
403
|
+
}>;
|
|
404
|
+
/** The dry run: report what a real run would do, write nothing. Absent =
|
|
405
|
+
* the console offers only the real run. */
|
|
406
|
+
dryRun?(ctx: OpsTaskRunContext): Promise<OpsTaskOutcome>;
|
|
407
|
+
/** The real run. */
|
|
408
|
+
execute(ctx: OpsTaskRunContext): Promise<OpsTaskOutcome>;
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Rows of a configuration collection an extension owns the definition of,
|
|
412
|
+
* checked in beside its code. A seed is never applied at boot: it is
|
|
413
|
+
* registered as an operational task (`seed:<key>`) whose dry run is the
|
|
414
|
+
* drift report — every row where the database differs from the file, and
|
|
415
|
+
* who changed it — and whose real run applies the file.
|
|
416
|
+
*/
|
|
417
|
+
export interface ConfigSeedDef {
|
|
418
|
+
/** `<extension>:<name>`. */
|
|
419
|
+
key: string;
|
|
420
|
+
label?: string;
|
|
421
|
+
description?: string;
|
|
422
|
+
/** The collection the rows belong to (never a `nivaro_*` system table). */
|
|
423
|
+
collection: string;
|
|
424
|
+
/** Columns that identify a row across databases — never `id`. */
|
|
425
|
+
match_by: string[];
|
|
426
|
+
/** The rows, inline… */
|
|
427
|
+
rows?: Array<Record<string, unknown>>;
|
|
428
|
+
/** …or a JSON file holding an array of rows (absolute path). */
|
|
429
|
+
file?: string;
|
|
430
|
+
/**
|
|
431
|
+
* `fill-only`: create rows the database lacks and fill columns that are
|
|
432
|
+
* empty there; a value someone set stays. `authoritative`: the file wins —
|
|
433
|
+
* differing columns are written back to the seed's values.
|
|
434
|
+
*/
|
|
435
|
+
mode: 'fill-only' | 'authoritative';
|
|
436
|
+
/** Columns the file carries that must never be written (ids, audit stamps). */
|
|
437
|
+
ignore?: string[];
|
|
438
|
+
}
|
|
439
|
+
export interface SchemaCheckResult {
|
|
440
|
+
ok: boolean;
|
|
441
|
+
/** What is missing or different, when not ok. */
|
|
442
|
+
detail?: string;
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* A versioned schema or registry change an extension owns — a table it
|
|
446
|
+
* keeps, a column it adds to a business table, a registry row — declared
|
|
447
|
+
* with `ctx.schema.step(id, {...})` inside `register()` and run at load,
|
|
448
|
+
* under the migration lock, in declaration order. A step that ran once is
|
|
449
|
+
* recorded in `nivaro_extension_schema_steps` with the schema diff it
|
|
450
|
+
* produced and never runs again on that database; `check` reports drift.
|
|
451
|
+
*/
|
|
452
|
+
export interface SchemaStepDef {
|
|
453
|
+
/** Unique within the extension; kebab-case. */
|
|
454
|
+
id: string;
|
|
455
|
+
/** What the step builds, in a sentence. */
|
|
456
|
+
description: string;
|
|
457
|
+
/**
|
|
458
|
+
* The change. It runs inside a transaction that holds the migration
|
|
459
|
+
* lock; `db` is that transaction. Guard it (hasTable / hasColumn) anyway —
|
|
460
|
+
* a database built by hand may already carry the object.
|
|
461
|
+
*/
|
|
462
|
+
up(db: Knex): Promise<void>;
|
|
463
|
+
/**
|
|
464
|
+
* Does the database still carry what the step built? Run after the step
|
|
465
|
+
* (or on every readiness read) — cheap reads only. `false` or `{ok: false}`
|
|
466
|
+
* reports drift; absent = never checked.
|
|
467
|
+
*/
|
|
468
|
+
check?(db: Knex): Promise<SchemaCheckResult | boolean>;
|
|
469
|
+
}
|
|
470
|
+
//# sourceMappingURL=registrations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registrations.d.ts","sourceRoot":"","sources":["../src/registrations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM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
|
+
import type { Knex } from 'knex';
|
|
2
|
+
/**
|
|
3
|
+
* `requested_by` / `requested_via` on the ERP submission tables ("who started
|
|
4
|
+
* each push", migration 350). A missing column does not just drop the two
|
|
5
|
+
* fields: an INSERT or SELECT naming an unknown column fails WHOLESALE, so a
|
|
6
|
+
* writer that names one anyway loses the whole submission row it was trying
|
|
7
|
+
* to record. Every insert or select that might name them goes through here.
|
|
8
|
+
*/
|
|
9
|
+
export type RequesterTable = 'nivaro_erp_submissions' | 'nivaro_erp_submission_attempts';
|
|
10
|
+
export declare const REQUESTER_COLUMNS: readonly ["requested_by", "requested_via"];
|
|
11
|
+
/** `{requested_by, requested_via}` for an INSERT into `table` on this
|
|
12
|
+
* database, or `{}` before migration 350 has reached it — spread this into
|
|
13
|
+
* the insert payload, never write the two column names directly. */
|
|
14
|
+
export declare function requesterInsertFields(db: Knex, table: RequesterTable | (string & {}), requestedBy: string | null | undefined, requestedVia: string | null | undefined, opts?: {
|
|
15
|
+
scope?: string;
|
|
16
|
+
}): Promise<{
|
|
17
|
+
requested_by?: string | null;
|
|
18
|
+
requested_via?: string | null;
|
|
19
|
+
}>;
|
|
20
|
+
/** The extra column names a SELECT against `table` may safely name —
|
|
21
|
+
* `['requested_by', 'requested_via']` once migration 350 has reached it,
|
|
22
|
+
* else `[]`. */
|
|
23
|
+
export declare function requesterSelectColumns(db: Knex, table: RequesterTable | (string & {}), opts?: {
|
|
24
|
+
scope?: string;
|
|
25
|
+
}): Promise<string[]>;
|
|
26
|
+
//# sourceMappingURL=requester-columns.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requester-columns.d.ts","sourceRoot":"","sources":["../src/requester-columns.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAGhC;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GAAG,wBAAwB,GAAG,gCAAgC,CAAA;AAExF,eAAO,MAAM,iBAAiB,4CAA6C,CAAA;AAE3E;;qEAEqE;AACrE,wBAAsB,qBAAqB,CACzC,EAAE,EAAE,IAAI,EACR,KAAK,EAAE,cAAc,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,EACrC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACtC,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACvC,IAAI,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAO,GAC5B,OAAO,CAAC;IAAE,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC,CAG1E;AAED;;iBAEiB;AACjB,wBAAsB,sBAAsB,CAC1C,EAAE,EAAE,IAAI,EACR,KAAK,EAAE,cAAc,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,EACrC,IAAI,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAO,GAC5B,OAAO,CAAC,MAAM,EAAE,CAAC,CAEnB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { hasColumn } from './column-probe.js';
|
|
2
|
+
export const REQUESTER_COLUMNS = ['requested_by', 'requested_via'];
|
|
3
|
+
/** `{requested_by, requested_via}` for an INSERT into `table` on this
|
|
4
|
+
* database, or `{}` before migration 350 has reached it — spread this into
|
|
5
|
+
* the insert payload, never write the two column names directly. */
|
|
6
|
+
export async function requesterInsertFields(db, table, requestedBy, requestedVia, opts = {}) {
|
|
7
|
+
if (!(await hasColumn(db, table, 'requested_by', opts)))
|
|
8
|
+
return {};
|
|
9
|
+
return { requested_by: requestedBy ?? null, requested_via: requestedVia ?? null };
|
|
10
|
+
}
|
|
11
|
+
/** The extra column names a SELECT against `table` may safely name —
|
|
12
|
+
* `['requested_by', 'requested_via']` once migration 350 has reached it,
|
|
13
|
+
* else `[]`. */
|
|
14
|
+
export async function requesterSelectColumns(db, table, opts = {}) {
|
|
15
|
+
return (await hasColumn(db, table, 'requested_by', opts)) ? [...REQUESTER_COLUMNS] : [];
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=requester-columns.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requester-columns.js","sourceRoot":"","sources":["../src/requester-columns.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAW7C,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,cAAc,EAAE,eAAe,CAAU,CAAA;AAE3E;;qEAEqE;AACrE,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,EAAQ,EACR,KAAqC,EACrC,WAAsC,EACtC,YAAuC,EACvC,OAA2B,EAAE;IAE7B,IAAI,CAAC,CAAC,MAAM,SAAS,CAAC,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE,IAAI,CAAC,CAAC;QAAE,OAAO,EAAE,CAAA;IAClE,OAAO,EAAE,YAAY,EAAE,WAAW,IAAI,IAAI,EAAE,aAAa,EAAE,YAAY,IAAI,IAAI,EAAE,CAAA;AACnF,CAAC;AAED;;iBAEiB;AACjB,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,EAAQ,EACR,KAAqC,EACrC,OAA2B,EAAE;IAE7B,OAAO,CAAC,MAAM,SAAS,CAAC,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;AACzF,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
export interface SignalThreshold {
|
|
2
|
+
key: string;
|
|
3
|
+
label: string;
|
|
4
|
+
default: number;
|
|
5
|
+
unit: string;
|
|
6
|
+
min?: number;
|
|
7
|
+
max?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface SignalAction {
|
|
10
|
+
kind: 'retry_submission' | 'resend' | 'open' | 'explain' | 'extension';
|
|
11
|
+
label: string;
|
|
12
|
+
/** Extension action id (kind 'extension'), submission id (retry), etc. */
|
|
13
|
+
id?: string;
|
|
14
|
+
payload?: Record<string, unknown>;
|
|
15
|
+
}
|
|
16
|
+
/** A typed "Details" reference on a signal row — see `SignalRow.drill`. */
|
|
17
|
+
export interface SignalDrill {
|
|
18
|
+
kind: 'submission' | 'import_run';
|
|
19
|
+
id: string;
|
|
20
|
+
}
|
|
21
|
+
export interface SignalRow {
|
|
22
|
+
/** Stable identity of the problem instance — NEVER a message or timestamp. */
|
|
23
|
+
key: string;
|
|
24
|
+
group?: string;
|
|
25
|
+
group_label?: string;
|
|
26
|
+
title: string;
|
|
27
|
+
detail?: string;
|
|
28
|
+
since?: string;
|
|
29
|
+
/** Identity of THIS occurrence of the problem (a run id, a submission
|
|
30
|
+
* attempt, an obligation id). `key` names the PROBLEM and stays the same
|
|
31
|
+
* across every failure; a Dismiss hides the row until `occurrence` next
|
|
32
|
+
* changes. Unset falls back to `since`, then a masked hash of the row. */
|
|
33
|
+
occurrence?: string;
|
|
34
|
+
api?: string;
|
|
35
|
+
record?: {
|
|
36
|
+
collection: string;
|
|
37
|
+
id: string;
|
|
38
|
+
label?: string;
|
|
39
|
+
};
|
|
40
|
+
actions: SignalAction[];
|
|
41
|
+
/** What the console can open in place under this row. */
|
|
42
|
+
drill?: SignalDrill;
|
|
43
|
+
}
|
|
44
|
+
export interface SignalEvalContext {
|
|
45
|
+
thresholds: Record<string, number>;
|
|
46
|
+
/** A Date `n` business days before now (core SLA schedule: days + holidays). */
|
|
47
|
+
businessDaysAgo(n: number): Promise<Date>;
|
|
48
|
+
}
|
|
49
|
+
/** One kind of problem on the Integrations console's Firefight list,
|
|
50
|
+
* evaluated every five minutes. */
|
|
51
|
+
export interface IntegrationSignal {
|
|
52
|
+
id: string;
|
|
53
|
+
label: string;
|
|
54
|
+
description: string;
|
|
55
|
+
tab: string;
|
|
56
|
+
severity: 'critical' | 'warn';
|
|
57
|
+
thresholds: SignalThreshold[];
|
|
58
|
+
evaluate(ctx: SignalEvalContext): Promise<{
|
|
59
|
+
count: number;
|
|
60
|
+
rows: SignalRow[];
|
|
61
|
+
}>;
|
|
62
|
+
}
|
|
63
|
+
/** An action a signal row may offer (kind 'extension', id = def.id). */
|
|
64
|
+
export interface SignalActionHandler {
|
|
65
|
+
id: string;
|
|
66
|
+
label: string;
|
|
67
|
+
run(args: {
|
|
68
|
+
rows: SignalRow[];
|
|
69
|
+
userId: string | null;
|
|
70
|
+
authHeaders: Record<string, string>;
|
|
71
|
+
}): Promise<Array<{
|
|
72
|
+
key: string;
|
|
73
|
+
ok: boolean;
|
|
74
|
+
message: string;
|
|
75
|
+
}>>;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=signals.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signals.d.ts","sourceRoot":"","sources":["../src/signals.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,kBAAkB,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,WAAW,CAAA;IACtE,KAAK,EAAE,MAAM,CAAA;IACb,0EAA0E;IAC1E,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAClC;AAED,2EAA2E;AAC3E,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,YAAY,GAAG,YAAY,CAAA;IACjC,EAAE,EAAE,MAAM,CAAA;CACX;AAED,MAAM,WAAW,SAAS;IACxB,8EAA8E;IAC9E,GAAG,EAAE,MAAM,CAAA;I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