@stonecrop/stonecrop 0.13.14 → 0.15.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 +6 -3
- package/dist/src/doctype.d.ts +42 -7
- package/dist/src/doctype.d.ts.map +1 -1
- package/dist/src/doctype.js +77 -18
- package/dist/src/index.d.ts +5 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +6 -0
- package/dist/src/registry.d.ts +1 -1
- package/dist/src/registry.d.ts.map +1 -1
- package/dist/src/registry.js +46 -38
- package/dist/src/schema-validator.d.ts.map +1 -1
- package/dist/src/schema-validator.js +44 -47
- package/dist/src/stonecrop.d.ts +0 -6
- package/dist/src/stonecrop.d.ts.map +1 -1
- package/dist/src/stores/index.d.ts +2 -0
- package/dist/src/stores/index.d.ts.map +1 -1
- package/dist/src/stores/index.js +1 -0
- package/dist/src/stores/operation-log.d.ts +0 -6
- package/dist/src/stores/operation-log.d.ts.map +1 -1
- package/dist/src/stores/operation-log.js +0 -1
- package/dist/src/stores/validation.d.ts +83 -0
- package/dist/src/stores/validation.d.ts.map +1 -0
- package/dist/src/stores/validation.js +104 -0
- package/dist/src/types/doctype.d.ts +1 -1
- package/dist/src/types/doctype.d.ts.map +1 -1
- package/dist/src/types/operation-log.d.ts +0 -2
- package/dist/src/types/operation-log.d.ts.map +1 -1
- package/dist/stonecrop.d.ts +166 -22
- package/dist/stonecrop.js +5235 -1950
- package/dist/stonecrop.js.map +1 -1
- package/package.json +23 -23
- package/src/client-handler.ts +55 -0
- package/src/doctype.ts +83 -22
- package/src/index.ts +12 -0
- package/src/registry.ts +45 -40
- package/src/schema-validator.ts +52 -48
- package/src/stores/index.ts +2 -0
- package/src/stores/operation-log.ts +0 -1
- package/src/stores/validation.ts +138 -0
- package/src/types/doctype.ts +1 -1
- package/src/types/operation-log.ts +0 -3
- package/dist/composable.js +0 -1
- package/dist/composables/lazy-link.js +0 -125
- package/dist/composables/operation-log.js +0 -224
- package/dist/composables/stonecrop.js +0 -504
- package/dist/composables/use-lazy-link-state.js +0 -125
- package/dist/composables/use-stonecrop.js +0 -476
- package/dist/doctype.js +0 -242
- package/dist/exceptions.js +0 -16
- package/dist/field-triggers.js +0 -575
- package/dist/index.js +0 -27
- package/dist/operation-log-DB-dGNT9.js +0 -593
- package/dist/operation-log-DB-dGNT9.js.map +0 -1
- package/dist/plugins/index.js +0 -99
- package/dist/registry.js +0 -423
- package/dist/schema-validator.js +0 -407
- package/dist/src/composable.d.ts +0 -11
- package/dist/src/composable.d.ts.map +0 -1
- package/dist/src/composable.js +0 -477
- package/dist/src/composables/use-lazy-link-state.d.ts +0 -25
- package/dist/src/composables/use-lazy-link-state.d.ts.map +0 -1
- package/dist/src/composables/use-stonecrop.d.ts +0 -93
- package/dist/src/composables/use-stonecrop.d.ts.map +0 -1
- package/dist/src/composables/useNestedSchema.d.ts +0 -110
- package/dist/src/composables/useNestedSchema.d.ts.map +0 -1
- package/dist/src/composables/useNestedSchema.js +0 -155
- package/dist/src/stores/data.d.ts +0 -11
- package/dist/src/stores/data.d.ts.map +0 -1
- package/dist/src/stores/xstate.d.ts +0 -31
- package/dist/src/stores/xstate.d.ts.map +0 -1
- package/dist/src/tsdoc-metadata.json +0 -11
- package/dist/src/utils.d.ts +0 -24
- package/dist/src/utils.d.ts.map +0 -1
- package/dist/stonecrop.css +0 -1
- package/dist/stonecrop.umd.cjs +0 -6
- package/dist/stonecrop.umd.cjs.map +0 -1
- package/dist/stores/data.js +0 -7
- package/dist/stores/hst.js +0 -496
- package/dist/stores/index.js +0 -12
- package/dist/stores/operation-log.js +0 -580
- package/dist/stores/xstate.js +0 -29
- package/dist/tests/setup.d.ts +0 -5
- package/dist/tests/setup.d.ts.map +0 -1
- package/dist/tests/setup.js +0 -15
- package/dist/types/composable.js +0 -0
- package/dist/types/doctype.js +0 -0
- package/dist/types/field-triggers.js +0 -4
- package/dist/types/hst.js +0 -0
- package/dist/types/index.js +0 -10
- package/dist/types/operation-log.js +0 -0
- package/dist/types/plugin.js +0 -0
- package/dist/types/registry.js +0 -0
- package/dist/types/schema-validator.js +0 -13
- package/dist/types/stonecrop.js +0 -0
- package/dist/utils.js +0 -46
package/dist/stonecrop.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ import type { ResolvedField } from '@stonecrop/aform';
|
|
|
12
12
|
import { Router } from 'vue-router';
|
|
13
13
|
import { Store } from 'pinia';
|
|
14
14
|
import { StoreDefinition } from 'pinia';
|
|
15
|
+
import type { TriggerDefinition } from '@stonecrop/schema';
|
|
15
16
|
import type { UnknownMachineConfig } from 'xstate';
|
|
16
17
|
import type { WorkflowMeta } from '@stonecrop/schema';
|
|
17
18
|
|
|
@@ -82,6 +83,15 @@ export declare interface BatchOperation {
|
|
|
82
83
|
reversible: boolean;
|
|
83
84
|
}
|
|
84
85
|
|
|
86
|
+
/**
|
|
87
|
+
* Named capabilities injected into a clientHandler body as function parameters.
|
|
88
|
+
* The caller (the assembly composable) owns what each name resolves to — typically
|
|
89
|
+
* `router`, `record`, `runAction`, and a read-only `graphql`.
|
|
90
|
+
*
|
|
91
|
+
* @public
|
|
92
|
+
*/
|
|
93
|
+
export declare type ClientHandlerApi = Record<string, unknown>;
|
|
94
|
+
|
|
85
95
|
/**
|
|
86
96
|
* Factory function for HST creation
|
|
87
97
|
* Creates a new HSTNode proxy for hierarchical state tree navigation.
|
|
@@ -208,8 +218,8 @@ export declare class Doctype {
|
|
|
208
218
|
* const planDoctype = Doctype.fromObject({
|
|
209
219
|
* name: 'Plan',
|
|
210
220
|
* fields: [
|
|
211
|
-
* { fieldname: 'title', label: 'Title',
|
|
212
|
-
* { fieldname: 'status', label: 'Status',
|
|
221
|
+
* { fieldname: 'title', label: 'Title', component: 'ATextInput' },
|
|
222
|
+
* { fieldname: 'status', label: 'Status', component: 'ATextInput' },
|
|
213
223
|
* ],
|
|
214
224
|
* workflow: {
|
|
215
225
|
* id: 'plan',
|
|
@@ -266,6 +276,44 @@ export declare class Doctype {
|
|
|
266
276
|
name: string;
|
|
267
277
|
targetState: string;
|
|
268
278
|
}>;
|
|
279
|
+
/**
|
|
280
|
+
* Returns the stateless **Commands** available in a given workflow state — side-effect
|
|
281
|
+
* actions (save/print/email…) that do not change workflow state. Unlike transitions,
|
|
282
|
+
* Commands may exist on a workflow that declares no `states` (a commands-only doctype),
|
|
283
|
+
* and a Command with no `allowedStates` is available in every state.
|
|
284
|
+
*
|
|
285
|
+
* Only meaningful for WorkflowMeta format; XState workflows have no Commands.
|
|
286
|
+
*
|
|
287
|
+
* @param currentState - The record's current state, used to honor a Command's `allowedStates`
|
|
288
|
+
* @returns Array of command descriptors with `name`
|
|
289
|
+
*
|
|
290
|
+
* @example
|
|
291
|
+
* ```ts
|
|
292
|
+
* const commands = doctype.getAvailableCommands('Draft')
|
|
293
|
+
* // [{ name: 'Print' }]
|
|
294
|
+
* ```
|
|
295
|
+
*
|
|
296
|
+
* @public
|
|
297
|
+
*/
|
|
298
|
+
getAvailableCommands(currentState?: string): Array<{
|
|
299
|
+
name: string;
|
|
300
|
+
}>;
|
|
301
|
+
/**
|
|
302
|
+
* Returns the field-validation **triggers** declared on this doctype's workflow (advisory,
|
|
303
|
+
* client-side). Keyed by trigger name. Returns undefined when the workflow is absent, is an
|
|
304
|
+
* XState machine (no triggers), or simply declares none.
|
|
305
|
+
*
|
|
306
|
+
* @returns The `workflow.triggers` map, or undefined
|
|
307
|
+
*
|
|
308
|
+
* @example
|
|
309
|
+
* ```ts
|
|
310
|
+
* const triggers = doctype.getTriggers()
|
|
311
|
+
* // { dateOrder: { on: ['start_date', 'end_date'], clientHandler: '…' } }
|
|
312
|
+
* ```
|
|
313
|
+
*
|
|
314
|
+
* @public
|
|
315
|
+
*/
|
|
316
|
+
getTriggers(): Record<string, TriggerDefinition> | undefined;
|
|
269
317
|
/**
|
|
270
318
|
* Returns metadata for a specific action, if available.
|
|
271
319
|
* Only works with WorkflowMeta format; returns undefined for XState format.
|
|
@@ -276,18 +324,15 @@ export declare class Doctype {
|
|
|
276
324
|
* @example
|
|
277
325
|
* ```ts
|
|
278
326
|
* const actionMeta = doctype.getActionMeta('submit')
|
|
279
|
-
* // { label: 'Submit',
|
|
327
|
+
* // { label: 'Submit', allowedStates: ['draft'] }
|
|
280
328
|
* ```
|
|
281
329
|
*
|
|
282
330
|
* @public
|
|
283
331
|
*/
|
|
284
332
|
getActionMeta(actionName: string): {
|
|
285
333
|
label: string;
|
|
286
|
-
handler: string;
|
|
287
334
|
requiredFields?: string[];
|
|
288
335
|
allowedStates?: string[];
|
|
289
|
-
confirm?: boolean;
|
|
290
|
-
args?: Record<string, unknown>;
|
|
291
336
|
} | undefined;
|
|
292
337
|
/**
|
|
293
338
|
* Converts the registered doctype string to a slug (kebab-case). The following conversions are made:
|
|
@@ -318,7 +363,7 @@ export declare type DoctypeConfig = {
|
|
|
318
363
|
name: string;
|
|
319
364
|
/** URL-friendly slug (kebab-case) */
|
|
320
365
|
slug?: string;
|
|
321
|
-
/** Field definitions (
|
|
366
|
+
/** Field definitions (a link field is one carrying `doctype`) */
|
|
322
367
|
fields?: DoctypeField[];
|
|
323
368
|
/** Relationship links to other doctypes */
|
|
324
369
|
links?: Record<string, LinkDeclaration>;
|
|
@@ -330,6 +375,36 @@ export declare type DoctypeConfig = {
|
|
|
330
375
|
inherits?: string;
|
|
331
376
|
};
|
|
332
377
|
|
|
378
|
+
/**
|
|
379
|
+
* Execute a docbuilder-authored `clientHandler` body against an injected API map.
|
|
380
|
+
*
|
|
381
|
+
* `code` is a function *body* (statements), not a full function — authored in the
|
|
382
|
+
* docbuilder code editor and stored on `ActionDefinition.clientHandler`. It is compiled
|
|
383
|
+
* with the AsyncFunction constructor, so `await` works directly. Each key of `api`
|
|
384
|
+
* becomes a parameter name bound to its value, so a handler can reference `router`,
|
|
385
|
+
* `record`, `runAction`, etc. by name.
|
|
386
|
+
*
|
|
387
|
+
* This executor is deliberately concern-free: it performs no routing, dispatch, or HST
|
|
388
|
+
* writes itself — the caller assembles `api`. The injected set is an *intent* contract,
|
|
389
|
+
* not a sandbox (an AsyncFunction body can still reach `fetch`/`window`); enforcement of
|
|
390
|
+
* what a handler may actually do lives server-side, not here.
|
|
391
|
+
*
|
|
392
|
+
* Errors are propagated to the caller as a rejected promise — syntax errors at compile
|
|
393
|
+
* time and thrown errors / rejections at run time — so callers handle both uniformly.
|
|
394
|
+
*
|
|
395
|
+
* @param code - the clientHandler body, e.g. `"router.push('/users')"`
|
|
396
|
+
* @param api - named capabilities injected as parameters (default: none)
|
|
397
|
+
* @returns whatever the body returns (typically `void`)
|
|
398
|
+
*
|
|
399
|
+
* @example
|
|
400
|
+
* ```ts
|
|
401
|
+
* await executeClientHandler("await runAction('Assign', [record.id])", { runAction, record })
|
|
402
|
+
* ```
|
|
403
|
+
*
|
|
404
|
+
* @public
|
|
405
|
+
*/
|
|
406
|
+
export declare function executeClientHandler(code: string, api?: ClientHandlerApi): Promise<unknown>;
|
|
407
|
+
|
|
333
408
|
/**
|
|
334
409
|
* Supported action types for field triggers
|
|
335
410
|
* @public
|
|
@@ -1057,8 +1132,6 @@ export declare interface OperationLogConfig {
|
|
|
1057
1132
|
maxOperations?: number;
|
|
1058
1133
|
/** Enable cross-tab synchronization (default: true) */
|
|
1059
1134
|
enableCrossTabSync?: boolean;
|
|
1060
|
-
/** Auto-sync interval in milliseconds (default: 30000) */
|
|
1061
|
-
autoSyncInterval?: number;
|
|
1062
1135
|
/** Enable operation persistence to localStorage (default: false) */
|
|
1063
1136
|
enablePersistence?: boolean;
|
|
1064
1137
|
/** Persistence key prefix */
|
|
@@ -1256,7 +1329,7 @@ export declare class Registry {
|
|
|
1256
1329
|
*
|
|
1257
1330
|
* - `kind: 'table'` or `kind: 'link'` → `[]` or `{}`
|
|
1258
1331
|
* - `kind: 'fieldset'` → recursively initializes children as `{}`
|
|
1259
|
-
* - `kind: 'field'` → derives default from
|
|
1332
|
+
* - `kind: 'field'` → derives the default from the component's category; falls back to `null`
|
|
1260
1333
|
*
|
|
1261
1334
|
* @param schema - The resolved schema array to derive defaults from
|
|
1262
1335
|
* @returns A plain object with default values for each field
|
|
@@ -1483,7 +1556,6 @@ export declare class Stonecrop {
|
|
|
1483
1556
|
config: Ref< {
|
|
1484
1557
|
maxOperations?: number | undefined;
|
|
1485
1558
|
enableCrossTabSync?: boolean | undefined;
|
|
1486
|
-
autoSyncInterval?: number | undefined;
|
|
1487
1559
|
enablePersistence?: boolean | undefined;
|
|
1488
1560
|
persistenceKeyPrefix?: string | undefined;
|
|
1489
1561
|
userId?: string | undefined;
|
|
@@ -1491,7 +1563,6 @@ export declare class Stonecrop {
|
|
|
1491
1563
|
}, OperationLogConfig | {
|
|
1492
1564
|
maxOperations?: number | undefined;
|
|
1493
1565
|
enableCrossTabSync?: boolean | undefined;
|
|
1494
|
-
autoSyncInterval?: number | undefined;
|
|
1495
1566
|
enablePersistence?: boolean | undefined;
|
|
1496
1567
|
persistenceKeyPrefix?: string | undefined;
|
|
1497
1568
|
userId?: string | undefined;
|
|
@@ -1569,7 +1640,6 @@ export declare class Stonecrop {
|
|
|
1569
1640
|
config: Ref< {
|
|
1570
1641
|
maxOperations?: number | undefined;
|
|
1571
1642
|
enableCrossTabSync?: boolean | undefined;
|
|
1572
|
-
autoSyncInterval?: number | undefined;
|
|
1573
1643
|
enablePersistence?: boolean | undefined;
|
|
1574
1644
|
persistenceKeyPrefix?: string | undefined;
|
|
1575
1645
|
userId?: string | undefined;
|
|
@@ -1577,7 +1647,6 @@ export declare class Stonecrop {
|
|
|
1577
1647
|
}, OperationLogConfig | {
|
|
1578
1648
|
maxOperations?: number | undefined;
|
|
1579
1649
|
enableCrossTabSync?: boolean | undefined;
|
|
1580
|
-
autoSyncInterval?: number | undefined;
|
|
1581
1650
|
enablePersistence?: boolean | undefined;
|
|
1582
1651
|
persistenceKeyPrefix?: string | undefined;
|
|
1583
1652
|
userId?: string | undefined;
|
|
@@ -1655,7 +1724,6 @@ export declare class Stonecrop {
|
|
|
1655
1724
|
config: Ref< {
|
|
1656
1725
|
maxOperations?: number | undefined;
|
|
1657
1726
|
enableCrossTabSync?: boolean | undefined;
|
|
1658
|
-
autoSyncInterval?: number | undefined;
|
|
1659
1727
|
enablePersistence?: boolean | undefined;
|
|
1660
1728
|
persistenceKeyPrefix?: string | undefined;
|
|
1661
1729
|
userId?: string | undefined;
|
|
@@ -1663,7 +1731,6 @@ export declare class Stonecrop {
|
|
|
1663
1731
|
}, OperationLogConfig | {
|
|
1664
1732
|
maxOperations?: number | undefined;
|
|
1665
1733
|
enableCrossTabSync?: boolean | undefined;
|
|
1666
|
-
autoSyncInterval?: number | undefined;
|
|
1667
1734
|
enablePersistence?: boolean | undefined;
|
|
1668
1735
|
persistenceKeyPrefix?: string | undefined;
|
|
1669
1736
|
userId?: string | undefined;
|
|
@@ -2141,7 +2208,6 @@ currentIndex: Ref<number, number>;
|
|
|
2141
2208
|
config: Ref< {
|
|
2142
2209
|
maxOperations?: number | undefined;
|
|
2143
2210
|
enableCrossTabSync?: boolean | undefined;
|
|
2144
|
-
autoSyncInterval?: number | undefined;
|
|
2145
2211
|
enablePersistence?: boolean | undefined;
|
|
2146
2212
|
persistenceKeyPrefix?: string | undefined;
|
|
2147
2213
|
userId?: string | undefined;
|
|
@@ -2149,7 +2215,6 @@ operationFilter?: ((operation: HSTOperation) => boolean) | undefined;
|
|
|
2149
2215
|
}, OperationLogConfig | {
|
|
2150
2216
|
maxOperations?: number | undefined;
|
|
2151
2217
|
enableCrossTabSync?: boolean | undefined;
|
|
2152
|
-
autoSyncInterval?: number | undefined;
|
|
2153
2218
|
enablePersistence?: boolean | undefined;
|
|
2154
2219
|
persistenceKeyPrefix?: string | undefined;
|
|
2155
2220
|
userId?: string | undefined;
|
|
@@ -2227,7 +2292,6 @@ currentIndex: Ref<number, number>;
|
|
|
2227
2292
|
config: Ref< {
|
|
2228
2293
|
maxOperations?: number | undefined;
|
|
2229
2294
|
enableCrossTabSync?: boolean | undefined;
|
|
2230
|
-
autoSyncInterval?: number | undefined;
|
|
2231
2295
|
enablePersistence?: boolean | undefined;
|
|
2232
2296
|
persistenceKeyPrefix?: string | undefined;
|
|
2233
2297
|
userId?: string | undefined;
|
|
@@ -2235,7 +2299,6 @@ operationFilter?: ((operation: HSTOperation) => boolean) | undefined;
|
|
|
2235
2299
|
}, OperationLogConfig | {
|
|
2236
2300
|
maxOperations?: number | undefined;
|
|
2237
2301
|
enableCrossTabSync?: boolean | undefined;
|
|
2238
|
-
autoSyncInterval?: number | undefined;
|
|
2239
2302
|
enablePersistence?: boolean | undefined;
|
|
2240
2303
|
persistenceKeyPrefix?: string | undefined;
|
|
2241
2304
|
userId?: string | undefined;
|
|
@@ -2313,7 +2376,6 @@ currentIndex: Ref<number, number>;
|
|
|
2313
2376
|
config: Ref< {
|
|
2314
2377
|
maxOperations?: number | undefined;
|
|
2315
2378
|
enableCrossTabSync?: boolean | undefined;
|
|
2316
|
-
autoSyncInterval?: number | undefined;
|
|
2317
2379
|
enablePersistence?: boolean | undefined;
|
|
2318
2380
|
persistenceKeyPrefix?: string | undefined;
|
|
2319
2381
|
userId?: string | undefined;
|
|
@@ -2321,7 +2383,6 @@ operationFilter?: ((operation: HSTOperation) => boolean) | undefined;
|
|
|
2321
2383
|
}, OperationLogConfig | {
|
|
2322
2384
|
maxOperations?: number | undefined;
|
|
2323
2385
|
enableCrossTabSync?: boolean | undefined;
|
|
2324
|
-
autoSyncInterval?: number | undefined;
|
|
2325
2386
|
enablePersistence?: boolean | undefined;
|
|
2326
2387
|
persistenceKeyPrefix?: string | undefined;
|
|
2327
2388
|
userId?: string | undefined;
|
|
@@ -2398,6 +2459,76 @@ export declare function useStonecrop(options: {
|
|
|
2398
2459
|
*/
|
|
2399
2460
|
export declare function useUndoRedoShortcuts(hstStore: HSTNode, enabled?: boolean): void;
|
|
2400
2461
|
|
|
2462
|
+
/**
|
|
2463
|
+
* Reactive per-field validation error store + the advisory field-validation trigger engine.
|
|
2464
|
+
*
|
|
2465
|
+
* Holds the errors produced by field-validation triggers (see `TriggerDefinition` in
|
|
2466
|
+
* `@stonecrop/schema`) and runs a trigger's `clientHandler` on demand. Errors are **namespaced
|
|
2467
|
+
* by trigger**: re-running a trigger clears its own prior contributions before repopulating, so a
|
|
2468
|
+
* corrected value clears its stale error without disturbing other triggers.
|
|
2469
|
+
*
|
|
2470
|
+
* The engine is **advisory** and does **no rollback** — an invalid value stays in the record so the
|
|
2471
|
+
* user can fix it; validity is reported separately via `isValid` (read by the save gate) and
|
|
2472
|
+
* the per-field messages are surfaced via `errorsByField` / `errorsFor` for display.
|
|
2473
|
+
*
|
|
2474
|
+
* @public
|
|
2475
|
+
*/
|
|
2476
|
+
export declare const useValidationStore: StoreDefinition<"stonecrop-validation", Pick<{
|
|
2477
|
+
errors: Ref< {
|
|
2478
|
+
trigger: string;
|
|
2479
|
+
field: string;
|
|
2480
|
+
message: string;
|
|
2481
|
+
}[], ValidationError[] | {
|
|
2482
|
+
trigger: string;
|
|
2483
|
+
field: string;
|
|
2484
|
+
message: string;
|
|
2485
|
+
}[]>;
|
|
2486
|
+
isValid: ComputedRef<boolean>;
|
|
2487
|
+
errorsByField: ComputedRef<Record<string, string[]>>;
|
|
2488
|
+
errorsFor: (field: string) => string[];
|
|
2489
|
+
setError: (trigger: string, field: string, message: string) => void;
|
|
2490
|
+
clearTrigger: (trigger: string) => void;
|
|
2491
|
+
clearAll: () => void;
|
|
2492
|
+
validateField: (triggers: Record<string, TriggerDefinition>, changedField: string, record: Record<string, unknown>) => Promise<void>;
|
|
2493
|
+
validateRecord: (triggers: Record<string, TriggerDefinition>, record: Record<string, unknown>) => Promise<void>;
|
|
2494
|
+
}, "errors">, Pick<{
|
|
2495
|
+
errors: Ref< {
|
|
2496
|
+
trigger: string;
|
|
2497
|
+
field: string;
|
|
2498
|
+
message: string;
|
|
2499
|
+
}[], ValidationError[] | {
|
|
2500
|
+
trigger: string;
|
|
2501
|
+
field: string;
|
|
2502
|
+
message: string;
|
|
2503
|
+
}[]>;
|
|
2504
|
+
isValid: ComputedRef<boolean>;
|
|
2505
|
+
errorsByField: ComputedRef<Record<string, string[]>>;
|
|
2506
|
+
errorsFor: (field: string) => string[];
|
|
2507
|
+
setError: (trigger: string, field: string, message: string) => void;
|
|
2508
|
+
clearTrigger: (trigger: string) => void;
|
|
2509
|
+
clearAll: () => void;
|
|
2510
|
+
validateField: (triggers: Record<string, TriggerDefinition>, changedField: string, record: Record<string, unknown>) => Promise<void>;
|
|
2511
|
+
validateRecord: (triggers: Record<string, TriggerDefinition>, record: Record<string, unknown>) => Promise<void>;
|
|
2512
|
+
}, "isValid" | "errorsByField">, Pick<{
|
|
2513
|
+
errors: Ref< {
|
|
2514
|
+
trigger: string;
|
|
2515
|
+
field: string;
|
|
2516
|
+
message: string;
|
|
2517
|
+
}[], ValidationError[] | {
|
|
2518
|
+
trigger: string;
|
|
2519
|
+
field: string;
|
|
2520
|
+
message: string;
|
|
2521
|
+
}[]>;
|
|
2522
|
+
isValid: ComputedRef<boolean>;
|
|
2523
|
+
errorsByField: ComputedRef<Record<string, string[]>>;
|
|
2524
|
+
errorsFor: (field: string) => string[];
|
|
2525
|
+
setError: (trigger: string, field: string, message: string) => void;
|
|
2526
|
+
clearTrigger: (trigger: string) => void;
|
|
2527
|
+
clearAll: () => void;
|
|
2528
|
+
validateField: (triggers: Record<string, TriggerDefinition>, changedField: string, record: Record<string, unknown>) => Promise<void>;
|
|
2529
|
+
validateRecord: (triggers: Record<string, TriggerDefinition>, record: Record<string, unknown>) => Promise<void>;
|
|
2530
|
+
}, "errorsFor" | "setError" | "clearTrigger" | "clearAll" | "validateField" | "validateRecord">>;
|
|
2531
|
+
|
|
2401
2532
|
/**
|
|
2402
2533
|
* Quick validation helper
|
|
2403
2534
|
* @param doctype - Doctype name
|
|
@@ -2410,6 +2541,19 @@ export declare function useUndoRedoShortcuts(hstStore: HSTNode, enabled?: boolea
|
|
|
2410
2541
|
*/
|
|
2411
2542
|
export declare function validateSchema(doctype: string, schema: List<DoctypeField> | DoctypeField[] | undefined, registry: Registry, workflow?: AnyStateNodeConfig, actions?: Map_2<string, string[]> | Map<string, string[]>): ValidationResult;
|
|
2412
2543
|
|
|
2544
|
+
/**
|
|
2545
|
+
* A single validation error contributed by a trigger, displayed on a field.
|
|
2546
|
+
* @public
|
|
2547
|
+
*/
|
|
2548
|
+
export declare interface ValidationError {
|
|
2549
|
+
/** The trigger that produced this error — the namespace a re-run clears before repopulating */
|
|
2550
|
+
trigger: string;
|
|
2551
|
+
/** The fieldname the error displays on (the `setError` target, not necessarily a fired field) */
|
|
2552
|
+
field: string;
|
|
2553
|
+
/** The message to display */
|
|
2554
|
+
message: string;
|
|
2555
|
+
}
|
|
2556
|
+
|
|
2413
2557
|
/**
|
|
2414
2558
|
* Validation issue
|
|
2415
2559
|
* @public
|