@stonecrop/stonecrop 0.10.12 → 0.10.13
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/dist/composables/stonecrop.js +19 -144
- package/dist/index.js +9 -6
- package/dist/plugins/index.js +4 -1
- package/dist/schema-validator.js +1 -13
- package/dist/src/composables/stonecrop.d.ts +2 -74
- package/dist/src/composables/stonecrop.d.ts.map +1 -1
- package/dist/src/doctype.d.ts +1 -27
- package/dist/src/doctype.d.ts.map +1 -1
- package/dist/src/index.d.ts +6 -9
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/plugins/index.d.ts.map +1 -1
- package/dist/src/schema-validator.d.ts +1 -62
- package/dist/src/schema-validator.d.ts.map +1 -1
- package/dist/src/stonecrop.d.ts +38 -17
- package/dist/src/stonecrop.d.ts.map +1 -1
- package/dist/src/stores/operation-log.d.ts +1 -1
- package/dist/src/types/composable.d.ts +230 -0
- package/dist/src/types/composable.d.ts.map +1 -0
- package/dist/src/types/doctype.d.ts +57 -0
- package/dist/src/types/doctype.d.ts.map +1 -0
- package/dist/src/types/index.d.ts +6 -67
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/types/plugin.d.ts +37 -0
- package/dist/src/types/plugin.d.ts.map +1 -0
- package/dist/src/types/schema-validator.d.ts +64 -0
- package/dist/src/types/schema-validator.d.ts.map +1 -0
- package/dist/src/types/stonecrop.d.ts +17 -0
- package/dist/src/types/stonecrop.d.ts.map +1 -0
- package/dist/stonecrop.d.ts +192 -3
- package/dist/stonecrop.js +1509 -1517
- package/dist/stonecrop.js.map +1 -1
- package/dist/types/composable.js +0 -0
- package/dist/types/doctype.js +0 -0
- package/dist/types/index.js +7 -2
- package/dist/types/plugin.js +0 -0
- package/dist/types/schema-validator.js +13 -0
- package/dist/types/stonecrop.js +0 -0
- package/package.json +5 -5
- package/src/composables/stonecrop.ts +26 -266
- package/src/doctype.ts +2 -29
- package/src/index.ts +12 -19
- package/src/plugins/index.ts +4 -1
- package/src/schema-validator.ts +3 -66
- package/src/stonecrop.ts +147 -16
- package/src/types/composable.ts +245 -0
- package/src/types/doctype.ts +60 -0
- package/src/types/index.ts +7 -74
- package/src/types/plugin.ts +38 -0
- package/src/types/schema-validator.ts +67 -0
- package/src/types/stonecrop.ts +17 -0
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { isDoctypeMany, } from '@stonecrop/aform';
|
|
2
1
|
import { storeToRefs } from 'pinia';
|
|
3
2
|
import { inject, onMounted, ref, watch, provide, computed } from 'vue';
|
|
4
3
|
import { Stonecrop } from '../stonecrop';
|
|
@@ -22,6 +21,12 @@ export function useStonecrop(options) {
|
|
|
22
21
|
const isLoading = ref(false);
|
|
23
22
|
const error = ref(null);
|
|
24
23
|
const resolvedDoctype = ref();
|
|
24
|
+
// Initialize stonecrop instance synchronously using singleton pattern
|
|
25
|
+
// Use injected instance if available, otherwise fall back to the singleton root
|
|
26
|
+
const stonecropInstance = providedStonecrop || Stonecrop._root;
|
|
27
|
+
if (stonecropInstance) {
|
|
28
|
+
stonecrop.value = stonecropInstance;
|
|
29
|
+
}
|
|
25
30
|
// If doctype is a Doctype instance (not string), set resolved immediately
|
|
26
31
|
if (options?.doctype && typeof options.doctype !== 'string') {
|
|
27
32
|
resolvedDoctype.value = options.doctype;
|
|
@@ -82,10 +87,9 @@ export function useStonecrop(options) {
|
|
|
82
87
|
};
|
|
83
88
|
// Initialize Stonecrop instance
|
|
84
89
|
onMounted(async () => {
|
|
85
|
-
if (!registry) {
|
|
90
|
+
if (!registry || !stonecrop.value) {
|
|
86
91
|
return;
|
|
87
92
|
}
|
|
88
|
-
stonecrop.value = providedStonecrop || new Stonecrop(registry);
|
|
89
93
|
// Set up reactive refs from operation log store - only if Pinia is available
|
|
90
94
|
try {
|
|
91
95
|
const opLogStore = stonecrop.value.getOperationLogStore();
|
|
@@ -149,12 +153,12 @@ export function useStonecrop(options) {
|
|
|
149
153
|
}
|
|
150
154
|
}
|
|
151
155
|
catch {
|
|
152
|
-
formData.value =
|
|
156
|
+
formData.value = registry.initializeRecord(resolvedSchema.value);
|
|
153
157
|
}
|
|
154
158
|
}
|
|
155
159
|
}
|
|
156
160
|
else {
|
|
157
|
-
formData.value =
|
|
161
|
+
formData.value = registry.initializeRecord(resolvedSchema.value);
|
|
158
162
|
}
|
|
159
163
|
if (hstStore.value) {
|
|
160
164
|
setupDeepReactivity(doctype, recordId || 'new', formData, hstStore.value);
|
|
@@ -230,12 +234,12 @@ export function useStonecrop(options) {
|
|
|
230
234
|
}
|
|
231
235
|
}
|
|
232
236
|
catch {
|
|
233
|
-
formData.value =
|
|
237
|
+
formData.value = registry.initializeRecord(resolvedSchema.value);
|
|
234
238
|
}
|
|
235
239
|
}
|
|
236
240
|
}
|
|
237
241
|
else {
|
|
238
|
-
formData.value =
|
|
242
|
+
formData.value = registry.initializeRecord(resolvedSchema.value);
|
|
239
243
|
}
|
|
240
244
|
if (hstStore.value) {
|
|
241
245
|
setupDeepReactivity(doctype, recordId || 'new', formData, hstStore.value);
|
|
@@ -299,80 +303,30 @@ export function useStonecrop(options) {
|
|
|
299
303
|
}
|
|
300
304
|
/**
|
|
301
305
|
* Load nested doctype data from API or initialize empty structure
|
|
306
|
+
* Delegates to Stonecrop.loadNestedData method
|
|
302
307
|
* @param parentPath - The parent path (e.g., "customer.123.address")
|
|
303
308
|
* @param childDoctype - The child doctype metadata
|
|
304
309
|
* @param recordId - Optional record ID to load
|
|
305
|
-
* @returns
|
|
310
|
+
* @returns The loaded or initialized data
|
|
306
311
|
*/
|
|
307
312
|
const loadNestedData = (parentPath, childDoctype, recordId) => {
|
|
308
313
|
if (!stonecrop.value) {
|
|
309
|
-
|
|
310
|
-
}
|
|
311
|
-
// If recordId provided, try to load existing data
|
|
312
|
-
if (recordId) {
|
|
313
|
-
try {
|
|
314
|
-
// Check if data already exists in HST
|
|
315
|
-
const existingData = hstStore.value?.get(parentPath);
|
|
316
|
-
if (existingData && typeof existingData === 'object') {
|
|
317
|
-
return existingData;
|
|
318
|
-
}
|
|
319
|
-
// TODO: Add API fetch logic here if needed
|
|
320
|
-
// For now, initialize new record
|
|
321
|
-
return initializeNewRecord(childDoctype);
|
|
322
|
-
}
|
|
323
|
-
catch {
|
|
324
|
-
return initializeNewRecord(childDoctype);
|
|
325
|
-
}
|
|
314
|
+
throw new Error('Stonecrop instance not available');
|
|
326
315
|
}
|
|
327
|
-
|
|
328
|
-
return initializeNewRecord(childDoctype);
|
|
316
|
+
return stonecrop.value.loadNestedData(parentPath, childDoctype, recordId);
|
|
329
317
|
};
|
|
330
318
|
/**
|
|
331
319
|
* Collect a record payload with all nested doctype fields from HST
|
|
320
|
+
* Delegates to Stonecrop.collectRecordPayload method
|
|
332
321
|
* @param doctype - The doctype metadata
|
|
333
322
|
* @param recordId - The record ID to collect
|
|
334
323
|
* @returns The complete record payload ready for API submission
|
|
335
324
|
*/
|
|
336
325
|
const collectRecordPayload = (doctype, recordId) => {
|
|
337
|
-
if (!
|
|
338
|
-
throw new Error('
|
|
339
|
-
}
|
|
340
|
-
const recordPath = `${doctype.slug}.${recordId}`;
|
|
341
|
-
const recordData = hstStore.value.get(recordPath) || {};
|
|
342
|
-
// Build the save payload using resolved schema
|
|
343
|
-
const payload = { ...recordData };
|
|
344
|
-
// Use resolveSchema to get the full resolved tree, then walk Doctype fields
|
|
345
|
-
const schemaArray = doctype.schema
|
|
346
|
-
? Array.isArray(doctype.schema)
|
|
347
|
-
? doctype.schema
|
|
348
|
-
: Array.from(doctype.schema)
|
|
349
|
-
: [];
|
|
350
|
-
const resolved = registry ? registry.resolveSchema(schemaArray) : schemaArray;
|
|
351
|
-
// 1:1 nested Doctype fields (cardinality: 'one' or undefined)
|
|
352
|
-
const doctypeFields = resolved.filter(field => 'fieldtype' in field &&
|
|
353
|
-
field.fieldtype === 'Doctype' &&
|
|
354
|
-
!isDoctypeMany(field) &&
|
|
355
|
-
'schema' in field &&
|
|
356
|
-
Array.isArray(field.schema));
|
|
357
|
-
// Recursively collect nested data from HST using resolved schemas
|
|
358
|
-
for (const field of doctypeFields) {
|
|
359
|
-
const doctypeField = field;
|
|
360
|
-
const fieldPath = `${recordPath}.${doctypeField.fieldname}`;
|
|
361
|
-
const nestedData = collectNestedData(doctypeField.schema, fieldPath, hstStore.value);
|
|
362
|
-
payload[doctypeField.fieldname] = nestedData;
|
|
363
|
-
}
|
|
364
|
-
// 1:many child tables (cardinality: 'many')
|
|
365
|
-
const doctypeManyFields = resolved.filter(field => 'fieldtype' in field && field.fieldtype === 'Doctype' && isDoctypeMany(field));
|
|
366
|
-
// Read array data from HST for cardinality: 'many' fields
|
|
367
|
-
for (const field of doctypeManyFields) {
|
|
368
|
-
const doctypeField = field;
|
|
369
|
-
const fieldPath = `${recordPath}.${doctypeField.fieldname}`;
|
|
370
|
-
const arrayData = hstStore.value.get(fieldPath);
|
|
371
|
-
if (Array.isArray(arrayData)) {
|
|
372
|
-
payload[doctypeField.fieldname] = arrayData;
|
|
373
|
-
}
|
|
326
|
+
if (!stonecrop.value) {
|
|
327
|
+
throw new Error('Stonecrop instance not available');
|
|
374
328
|
}
|
|
375
|
-
return
|
|
329
|
+
return stonecrop.value.collectRecordPayload(doctype, recordId);
|
|
376
330
|
};
|
|
377
331
|
/**
|
|
378
332
|
* Create a nested context for child forms
|
|
@@ -461,50 +415,6 @@ export function useStonecrop(options) {
|
|
|
461
415
|
operationLog,
|
|
462
416
|
};
|
|
463
417
|
}
|
|
464
|
-
/**
|
|
465
|
-
* Initialize new record structure based on doctype schema
|
|
466
|
-
*/
|
|
467
|
-
function initializeNewRecord(doctype) {
|
|
468
|
-
const initialData = {};
|
|
469
|
-
if (!doctype.schema) {
|
|
470
|
-
return initialData;
|
|
471
|
-
}
|
|
472
|
-
doctype.schema.forEach(field => {
|
|
473
|
-
const fieldtype = 'fieldtype' in field ? field.fieldtype : 'Data';
|
|
474
|
-
switch (fieldtype) {
|
|
475
|
-
case 'Data':
|
|
476
|
-
case 'Text':
|
|
477
|
-
initialData[field.fieldname] = '';
|
|
478
|
-
break;
|
|
479
|
-
case 'Check':
|
|
480
|
-
initialData[field.fieldname] = false;
|
|
481
|
-
break;
|
|
482
|
-
case 'Int':
|
|
483
|
-
case 'Float':
|
|
484
|
-
initialData[field.fieldname] = 0;
|
|
485
|
-
break;
|
|
486
|
-
case 'JSON':
|
|
487
|
-
initialData[field.fieldname] = {};
|
|
488
|
-
break;
|
|
489
|
-
case 'Doctype': {
|
|
490
|
-
// Check cardinality to determine initial value
|
|
491
|
-
const cardinality = 'cardinality' in field ? field.cardinality : undefined;
|
|
492
|
-
if (cardinality === 'many') {
|
|
493
|
-
// 1:many child table - initialize as empty array
|
|
494
|
-
initialData[field.fieldname] = [];
|
|
495
|
-
}
|
|
496
|
-
else {
|
|
497
|
-
// 1:1 nested form - initialize as empty object
|
|
498
|
-
initialData[field.fieldname] = {};
|
|
499
|
-
}
|
|
500
|
-
break;
|
|
501
|
-
}
|
|
502
|
-
default:
|
|
503
|
-
initialData[field.fieldname] = null;
|
|
504
|
-
}
|
|
505
|
-
});
|
|
506
|
-
return initialData;
|
|
507
|
-
}
|
|
508
418
|
/**
|
|
509
419
|
* Setup deep reactivity between form data and HST store
|
|
510
420
|
*/
|
|
@@ -537,38 +447,3 @@ function updateNestedObject(obj, path, value) {
|
|
|
537
447
|
const finalKey = path[path.length - 1];
|
|
538
448
|
current[finalKey] = value;
|
|
539
449
|
}
|
|
540
|
-
/**
|
|
541
|
-
* Recursively collect nested data from HST using pre-resolved schemas
|
|
542
|
-
* @param resolvedSchema - The already-resolved schema (with nested schemas embedded)
|
|
543
|
-
* @param basePath - The base path in HST (e.g., "customer.123.address")
|
|
544
|
-
* @param hstStore - The HST store instance
|
|
545
|
-
* @returns The collected data object
|
|
546
|
-
*/
|
|
547
|
-
function collectNestedData(resolvedSchema, basePath, hstStore) {
|
|
548
|
-
const data = hstStore.get(basePath) || {};
|
|
549
|
-
const payload = { ...data };
|
|
550
|
-
// Find Doctype fields that have resolved child schemas (1:1 only, not cardinality: 'many')
|
|
551
|
-
const doctypeFields = resolvedSchema.filter(field => 'fieldtype' in field &&
|
|
552
|
-
field.fieldtype === 'Doctype' &&
|
|
553
|
-
!isDoctypeMany(field) &&
|
|
554
|
-
'schema' in field &&
|
|
555
|
-
Array.isArray(field.schema));
|
|
556
|
-
// Recursively collect nested data
|
|
557
|
-
for (const field of doctypeFields) {
|
|
558
|
-
const doctypeField = field;
|
|
559
|
-
const fieldPath = `${basePath}.${doctypeField.fieldname}`;
|
|
560
|
-
const nestedData = collectNestedData(doctypeField.schema, fieldPath, hstStore);
|
|
561
|
-
payload[doctypeField.fieldname] = nestedData;
|
|
562
|
-
}
|
|
563
|
-
// Also collect array data for cardinality: 'many' fields
|
|
564
|
-
const doctypeManyFields = resolvedSchema.filter(field => 'fieldtype' in field && field.fieldtype === 'Doctype' && isDoctypeMany(field));
|
|
565
|
-
for (const field of doctypeManyFields) {
|
|
566
|
-
const doctypeField = field;
|
|
567
|
-
const fieldPath = `${basePath}.${doctypeField.fieldname}`;
|
|
568
|
-
const arrayData = hstStore.get(fieldPath);
|
|
569
|
-
if (Array.isArray(arrayData)) {
|
|
570
|
-
payload[doctypeField.fieldname] = arrayData;
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
return payload;
|
|
574
|
-
}
|
package/dist/index.js
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
import { useStonecrop } from './composables/stonecrop';
|
|
2
2
|
import { useOperationLog, useUndoRedoShortcuts, withBatch } from './composables/operation-log';
|
|
3
3
|
import Doctype from './doctype';
|
|
4
|
-
import { getGlobalTriggerEngine, markOperationIrreversible, registerGlobalAction, registerTransitionAction, setFieldRollback, triggerTransition, } from './field-triggers';
|
|
4
|
+
import { FieldTriggerEngine, getGlobalTriggerEngine, markOperationIrreversible, registerGlobalAction, registerTransitionAction, setFieldRollback, triggerTransition, } from './field-triggers';
|
|
5
5
|
import plugin from './plugins';
|
|
6
6
|
import Registry from './registry';
|
|
7
|
-
import { Stonecrop } from './stonecrop';
|
|
7
|
+
import { Stonecrop, collectNestedData } from './stonecrop';
|
|
8
8
|
import { HST, createHST } from './stores/hst';
|
|
9
9
|
import { useOperationLogStore } from './stores/operation-log';
|
|
10
|
-
// Export schema validator
|
|
11
10
|
import { SchemaValidator, createValidator, validateSchema } from './schema-validator';
|
|
12
|
-
|
|
11
|
+
import { ValidationSeverity } from './types/schema-validator';
|
|
12
|
+
// Export enum as value (enums need runtime export, not just type)
|
|
13
|
+
export { ValidationSeverity };
|
|
13
14
|
export { Doctype, Registry, Stonecrop, useStonecrop,
|
|
14
15
|
// HST exports for advanced usage
|
|
15
16
|
HST, createHST,
|
|
16
17
|
// Field trigger system exports
|
|
17
|
-
getGlobalTriggerEngine, registerGlobalAction, registerTransitionAction, setFieldRollback, triggerTransition, markOperationIrreversible,
|
|
18
|
+
FieldTriggerEngine, getGlobalTriggerEngine, registerGlobalAction, registerTransitionAction, setFieldRollback, triggerTransition, markOperationIrreversible,
|
|
18
19
|
// Schema validator exports
|
|
19
20
|
SchemaValidator, createValidator, validateSchema,
|
|
20
21
|
// Operation log exports
|
|
21
|
-
useOperationLog, useOperationLogStore, useUndoRedoShortcuts, withBatch,
|
|
22
|
+
useOperationLog, useOperationLogStore, useUndoRedoShortcuts, withBatch,
|
|
23
|
+
// Utility functions
|
|
24
|
+
collectNestedData, };
|
|
22
25
|
// Default export is the Vue plugin
|
|
23
26
|
export default plugin;
|
package/dist/plugins/index.js
CHANGED
|
@@ -61,7 +61,10 @@ const plugin = {
|
|
|
61
61
|
app.provide('$registry', registry);
|
|
62
62
|
app.config.globalProperties.$registry = registry;
|
|
63
63
|
// Create and provide a global Stonecrop instance
|
|
64
|
-
const stonecrop = new Stonecrop(registry
|
|
64
|
+
const stonecrop = new Stonecrop(registry);
|
|
65
|
+
if (options?.client) {
|
|
66
|
+
stonecrop.setClient(options.client);
|
|
67
|
+
}
|
|
65
68
|
app.provide('$stonecrop', stonecrop);
|
|
66
69
|
app.config.globalProperties.$stonecrop = stonecrop;
|
|
67
70
|
// Initialize operation log store if Pinia is available
|
package/dist/schema-validator.js
CHANGED
|
@@ -4,19 +4,7 @@
|
|
|
4
4
|
* @packageDocumentation
|
|
5
5
|
*/
|
|
6
6
|
import { getGlobalTriggerEngine } from './field-triggers';
|
|
7
|
-
|
|
8
|
-
* Validation severity levels
|
|
9
|
-
* @public
|
|
10
|
-
*/
|
|
11
|
-
export var ValidationSeverity;
|
|
12
|
-
(function (ValidationSeverity) {
|
|
13
|
-
/** Blocking error that prevents save */
|
|
14
|
-
ValidationSeverity["ERROR"] = "error";
|
|
15
|
-
/** Advisory warning that allows save */
|
|
16
|
-
ValidationSeverity["WARNING"] = "warning";
|
|
17
|
-
/** Informational message */
|
|
18
|
-
ValidationSeverity["INFO"] = "info";
|
|
19
|
-
})(ValidationSeverity || (ValidationSeverity = {}));
|
|
7
|
+
import { ValidationSeverity } from './types/schema-validator';
|
|
20
8
|
/**
|
|
21
9
|
* Schema validator class
|
|
22
10
|
* @public
|
|
@@ -1,78 +1,6 @@
|
|
|
1
|
-
import { type SchemaTypes } from '@stonecrop/aform';
|
|
2
|
-
import { Ref, type ComputedRef } from 'vue';
|
|
3
|
-
import Registry from '../registry';
|
|
4
|
-
import { Stonecrop } from '../stonecrop';
|
|
5
1
|
import Doctype from '../doctype';
|
|
6
|
-
import
|
|
7
|
-
import type {
|
|
8
|
-
/**
|
|
9
|
-
* Operation Log API - nested object containing all operation log functionality
|
|
10
|
-
* @public
|
|
11
|
-
*/
|
|
12
|
-
export type OperationLogAPI = {
|
|
13
|
-
operations: Ref<HSTOperation[]>;
|
|
14
|
-
currentIndex: Ref<number>;
|
|
15
|
-
undoRedoState: ComputedRef<{
|
|
16
|
-
canUndo: boolean;
|
|
17
|
-
canRedo: boolean;
|
|
18
|
-
undoCount: number;
|
|
19
|
-
redoCount: number;
|
|
20
|
-
currentIndex: number;
|
|
21
|
-
}>;
|
|
22
|
-
canUndo: ComputedRef<boolean>;
|
|
23
|
-
canRedo: ComputedRef<boolean>;
|
|
24
|
-
undoCount: ComputedRef<number>;
|
|
25
|
-
redoCount: ComputedRef<number>;
|
|
26
|
-
undo: (hstStore: HSTNode) => boolean;
|
|
27
|
-
redo: (hstStore: HSTNode) => boolean;
|
|
28
|
-
startBatch: () => void;
|
|
29
|
-
commitBatch: (description?: string) => string | null;
|
|
30
|
-
cancelBatch: () => void;
|
|
31
|
-
clear: () => void;
|
|
32
|
-
getOperationsFor: (doctype: string, recordId?: string) => HSTOperation[];
|
|
33
|
-
getSnapshot: () => OperationLogSnapshot;
|
|
34
|
-
markIrreversible: (operationId: string, reason: string) => void;
|
|
35
|
-
logAction: (doctype: string, actionName: string, recordIds?: string[], result?: 'success' | 'failure' | 'pending', error?: string) => string;
|
|
36
|
-
configure: (options: Partial<OperationLogConfig>) => void;
|
|
37
|
-
};
|
|
38
|
-
/**
|
|
39
|
-
* Base Stonecrop composable return type - includes operation log functionality
|
|
40
|
-
* @public
|
|
41
|
-
*/
|
|
42
|
-
export type BaseStonecropReturn = {
|
|
43
|
-
stonecrop: Ref<Stonecrop | undefined>;
|
|
44
|
-
operationLog: OperationLogAPI;
|
|
45
|
-
};
|
|
46
|
-
/**
|
|
47
|
-
* HST-enabled Stonecrop composable return type
|
|
48
|
-
* @public
|
|
49
|
-
*/
|
|
50
|
-
export type HSTStonecropReturn = BaseStonecropReturn & {
|
|
51
|
-
provideHSTPath: (fieldname: string, recordId?: string) => string;
|
|
52
|
-
handleHSTChange: (changeData: HSTChangeData) => void;
|
|
53
|
-
hstStore: Ref<HSTNode | undefined>;
|
|
54
|
-
formData: Ref<Record<string, any>>;
|
|
55
|
-
resolvedSchema: Ref<SchemaTypes[]>;
|
|
56
|
-
loadNestedData: (parentPath: string, childDoctype: Doctype, recordId?: string) => Record<string, any>;
|
|
57
|
-
collectRecordPayload: (doctype: Doctype, recordId: string) => Record<string, any>;
|
|
58
|
-
createNestedContext: (basePath: string, childDoctype: Doctype) => {
|
|
59
|
-
provideHSTPath: (fieldname: string) => string;
|
|
60
|
-
handleHSTChange: (changeData: HSTChangeData) => void;
|
|
61
|
-
};
|
|
62
|
-
isLoading: Ref<boolean>;
|
|
63
|
-
error: Ref<Error | null>;
|
|
64
|
-
resolvedDoctype: Ref<Doctype | undefined>;
|
|
65
|
-
};
|
|
66
|
-
/**
|
|
67
|
-
* HST Change data structure
|
|
68
|
-
* @public
|
|
69
|
-
*/
|
|
70
|
-
export type HSTChangeData = {
|
|
71
|
-
path: string;
|
|
72
|
-
value: any;
|
|
73
|
-
fieldname: string;
|
|
74
|
-
recordId?: string;
|
|
75
|
-
};
|
|
2
|
+
import Registry from '../registry';
|
|
3
|
+
import type { BaseStonecropReturn, HSTStonecropReturn } from '../types/composable';
|
|
76
4
|
/**
|
|
77
5
|
* Unified Stonecrop composable - handles both general operations and HST reactive integration
|
|
78
6
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stonecrop.d.ts","sourceRoot":"","sources":["../../../src/composables/stonecrop.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"stonecrop.d.ts","sourceRoot":"","sources":["../../../src/composables/stonecrop.ts"],"names":[],"mappings":"AAIA,OAAO,OAAO,MAAM,YAAY,CAAA;AAChC,OAAO,QAAQ,MAAM,aAAa,CAAA;AAGlC,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAkC,MAAM,qBAAqB,CAAA;AAIlH;;;;;;GAMG;AACH,wBAAgB,YAAY,IAAI,mBAAmB,GAAG,kBAAkB,CAAA;AACxE;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE;IACrC,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,OAAO,EAAE,OAAO,GAAG,MAAM,CAAA;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAA;CACjB,GAAG,kBAAkB,CAAA"}
|
package/dist/src/doctype.d.ts
CHANGED
|
@@ -1,33 +1,7 @@
|
|
|
1
1
|
import type { SchemaTypes } from '@stonecrop/aform';
|
|
2
|
-
import type { WorkflowMeta } from '@stonecrop/schema';
|
|
3
2
|
import { Component } from 'vue';
|
|
4
|
-
import type { UnknownMachineConfig } from 'xstate';
|
|
5
3
|
import type { ImmutableDoctype } from './types';
|
|
6
|
-
|
|
7
|
-
* Plain object representation of doctype configuration for serialization/API responses.
|
|
8
|
-
* Compatible with the DoctypeMeta type from \@stonecrop/schema.
|
|
9
|
-
* @public
|
|
10
|
-
*/
|
|
11
|
-
export type DoctypeConfig = {
|
|
12
|
-
/** Display name of the doctype */
|
|
13
|
-
name: string;
|
|
14
|
-
/** URL-friendly slug (kebab-case) */
|
|
15
|
-
slug?: string;
|
|
16
|
-
/** Database table name */
|
|
17
|
-
tableName?: string;
|
|
18
|
-
/** Field definitions */
|
|
19
|
-
fields?: SchemaTypes[];
|
|
20
|
-
/** Workflow configuration (XState format or simple WorkflowMeta) */
|
|
21
|
-
workflow?: UnknownMachineConfig | WorkflowMeta;
|
|
22
|
-
/** Actions and their field triggers */
|
|
23
|
-
actions?: Record<string, string[]>;
|
|
24
|
-
/** Parent doctype for inheritance */
|
|
25
|
-
inherits?: string;
|
|
26
|
-
/** Doctype to use for list views */
|
|
27
|
-
listDoctype?: string;
|
|
28
|
-
/** Parent doctype for child tables */
|
|
29
|
-
parentDoctype?: string;
|
|
30
|
-
};
|
|
4
|
+
import type { DoctypeConfig } from './types/doctype';
|
|
31
5
|
/**
|
|
32
6
|
* Doctype runtime class with Immutable.js collections for HST change tracking.
|
|
33
7
|
* @public
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctype.d.ts","sourceRoot":"","sources":["../../src/doctype.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"doctype.d.ts","sourceRoot":"","sources":["../../src/doctype.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,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AW,EAAE,MAAM,CAAA;KAAE,CAAC;IAsC3F;;;;;;;;;;;;;;OAcG;IACH,aAAa,CAAC,UAAU,EAAE,MAAM,GAC7B;QACA,KAAK,EAAE,MAAM,CAAA;QACb,OAAO,EAAE,MAAM,CAAA;QACf,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;QACzB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAA;QACxB,OAAO,CAAC,EAAE,OAAO,CAAA;QACjB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAC7B,GACD,SAAS;IAQZ;;;;;;;;;;;;;;;OAeG;IACH,IAAI,IAAI,WAKP;CACD"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -2,20 +2,17 @@ export type * from '@stonecrop/aform/types';
|
|
|
2
2
|
export type * from '@stonecrop/atable/types';
|
|
3
3
|
import { useStonecrop } from './composables/stonecrop';
|
|
4
4
|
import { useOperationLog, useUndoRedoShortcuts, withBatch } from './composables/operation-log';
|
|
5
|
-
import Doctype
|
|
6
|
-
import { getGlobalTriggerEngine, markOperationIrreversible, registerGlobalAction, registerTransitionAction, setFieldRollback, triggerTransition } from './field-triggers';
|
|
5
|
+
import Doctype from './doctype';
|
|
6
|
+
import { FieldTriggerEngine, getGlobalTriggerEngine, markOperationIrreversible, registerGlobalAction, registerTransitionAction, setFieldRollback, triggerTransition } from './field-triggers';
|
|
7
7
|
import plugin from './plugins';
|
|
8
8
|
import Registry from './registry';
|
|
9
|
-
import {
|
|
9
|
+
import { Stonecrop, collectNestedData } from './stonecrop';
|
|
10
10
|
import { HST, createHST, type HSTNode } from './stores/hst';
|
|
11
11
|
import { useOperationLogStore } from './stores/operation-log';
|
|
12
12
|
import { SchemaValidator, createValidator, validateSchema } from './schema-validator';
|
|
13
|
+
import { ValidationSeverity } from './types/schema-validator';
|
|
13
14
|
export type * from './types';
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export type { FieldChangeContext, TransitionChangeContext, FieldTriggerExecutionResult, ActionExecutionResult, TransitionExecutionResult, FieldActionFunction, TransitionActionFunction, } from './types/field-triggers';
|
|
17
|
-
export type { ValidationIssue, ValidationResult, ValidatorOptions } from './schema-validator';
|
|
18
|
-
export { ValidationSeverity } from './schema-validator';
|
|
19
|
-
export { Doctype, DoctypeConfig, Registry, Stonecrop, StonecropOptions, useStonecrop, HST, createHST, HSTNode, getGlobalTriggerEngine, registerGlobalAction, registerTransitionAction, setFieldRollback, triggerTransition, markOperationIrreversible, SchemaValidator, createValidator, validateSchema, useOperationLog, useOperationLogStore, useUndoRedoShortcuts, withBatch, };
|
|
15
|
+
export { ValidationSeverity };
|
|
16
|
+
export { Doctype, Registry, Stonecrop, useStonecrop, HST, createHST, HSTNode, FieldTriggerEngine, getGlobalTriggerEngine, registerGlobalAction, registerTransitionAction, setFieldRollback, triggerTransition, markOperationIrreversible, SchemaValidator, createValidator, validateSchema, useOperationLog, useOperationLogStore, useUndoRedoShortcuts, withBatch, collectNestedData, };
|
|
20
17
|
export default plugin;
|
|
21
18
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,wBAAwB,CAAA;AAC3C,mBAAmB,yBAAyB,CAAA;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAA;AAC9F,OAAO,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,wBAAwB,CAAA;AAC3C,mBAAmB,yBAAyB,CAAA;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,oBAAo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,MAAM,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,MAAM,EAAY,MAAM,KAAK,CAAA;AA2BhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,QAAA,MAAM,MAAM,EAAE,MAqDb,CAAA;AAED,eAAe,MAAM,CAAA"}
|
|
@@ -7,68 +7,7 @@ import type { SchemaTypes } from '@stonecrop/aform';
|
|
|
7
7
|
import type { List, Map as ImmutableMap } from 'immutable';
|
|
8
8
|
import type { AnyStateNodeConfig } from 'xstate';
|
|
9
9
|
import type Registry from './registry';
|
|
10
|
-
|
|
11
|
-
* Validation severity levels
|
|
12
|
-
* @public
|
|
13
|
-
*/
|
|
14
|
-
export declare enum ValidationSeverity {
|
|
15
|
-
/** Blocking error that prevents save */
|
|
16
|
-
ERROR = "error",
|
|
17
|
-
/** Advisory warning that allows save */
|
|
18
|
-
WARNING = "warning",
|
|
19
|
-
/** Informational message */
|
|
20
|
-
INFO = "info"
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Validation issue
|
|
24
|
-
* @public
|
|
25
|
-
*/
|
|
26
|
-
export interface ValidationIssue {
|
|
27
|
-
/** Severity level */
|
|
28
|
-
severity: ValidationSeverity;
|
|
29
|
-
/** Validation rule that failed */
|
|
30
|
-
rule: string;
|
|
31
|
-
/** Human-readable message */
|
|
32
|
-
message: string;
|
|
33
|
-
/** Doctype name */
|
|
34
|
-
doctype?: string;
|
|
35
|
-
/** Field name if applicable */
|
|
36
|
-
fieldname?: string;
|
|
37
|
-
/** Additional context */
|
|
38
|
-
context?: Record<string, unknown>;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Validation result
|
|
42
|
-
* @public
|
|
43
|
-
*/
|
|
44
|
-
export interface ValidationResult {
|
|
45
|
-
/** Whether validation passed (no blocking errors) */
|
|
46
|
-
valid: boolean;
|
|
47
|
-
/** List of validation issues */
|
|
48
|
-
issues: ValidationIssue[];
|
|
49
|
-
/** Count of errors */
|
|
50
|
-
errorCount: number;
|
|
51
|
-
/** Count of warnings */
|
|
52
|
-
warningCount: number;
|
|
53
|
-
/** Count of info messages */
|
|
54
|
-
infoCount: number;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Schema validator options
|
|
58
|
-
* @public
|
|
59
|
-
*/
|
|
60
|
-
export interface ValidatorOptions {
|
|
61
|
-
/** Registry instance for doctype lookups */
|
|
62
|
-
registry?: Registry;
|
|
63
|
-
/** Whether to validate Link field targets */
|
|
64
|
-
validateLinkTargets?: boolean;
|
|
65
|
-
/** Whether to validate workflow reachability */
|
|
66
|
-
validateWorkflows?: boolean;
|
|
67
|
-
/** Whether to validate action registration */
|
|
68
|
-
validateActions?: boolean;
|
|
69
|
-
/** Whether to validate required schema properties */
|
|
70
|
-
validateRequiredProperties?: boolean;
|
|
71
|
-
}
|
|
10
|
+
import type { ValidationResult, ValidatorOptions } from './types/schema-validator';
|
|
72
11
|
/**
|
|
73
12
|
* Schema validator class
|
|
74
13
|
* @public
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-validator.d.ts","sourceRoot":"","sources":["../../src/schema-validator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,YAAY,EAAE,MAAM,WAAW,CAAA;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"schema-validator.d.ts","sourceRoot":"","sources":["../../src/schema-validator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,YAAY,EA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