@stonecrop/stonecrop 0.10.4 → 0.10.6
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 +2 -2
- package/dist/doctype.js +81 -4
- package/dist/index.js +2 -2
- package/dist/registry.js +4 -4
- package/dist/src/composables/stonecrop.d.ts +5 -5
- package/dist/src/composables/stonecrop.d.ts.map +1 -1
- package/dist/src/doctype.d.ts +95 -4
- package/dist/src/doctype.d.ts.map +1 -1
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/registry.d.ts +10 -10
- package/dist/src/registry.d.ts.map +1 -1
- package/dist/src/stonecrop.d.ts +14 -14
- package/dist/src/stonecrop.d.ts.map +1 -1
- package/dist/src/types/index.d.ts +2 -2
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/stonecrop.d.ts +121 -31
- package/dist/stonecrop.js +4606 -1376
- package/dist/stonecrop.js.map +1 -1
- package/package.json +5 -5
- package/src/composables/stonecrop.ts +12 -16
- package/src/doctype.ts +112 -4
- package/src/index.ts +3 -2
- package/src/registry.ts +11 -11
- package/src/stonecrop.ts +15 -15
- package/src/types/index.ts +2 -2
package/dist/stonecrop.d.ts
CHANGED
|
@@ -116,10 +116,10 @@ export declare interface CrossTabMessage {
|
|
|
116
116
|
export declare type CrossTabMessageType = 'operation' | 'undo' | 'redo' | 'sync-request' | 'sync-response';
|
|
117
117
|
|
|
118
118
|
/**
|
|
119
|
-
* Doctype
|
|
119
|
+
* Doctype runtime class with Immutable.js collections for HST change tracking.
|
|
120
120
|
* @public
|
|
121
121
|
*/
|
|
122
|
-
export declare class
|
|
122
|
+
export declare class Doctype {
|
|
123
123
|
/**
|
|
124
124
|
* The doctype name
|
|
125
125
|
* @public
|
|
@@ -157,7 +157,7 @@ export declare class DoctypeMeta {
|
|
|
157
157
|
*/
|
|
158
158
|
readonly component?: Component;
|
|
159
159
|
/**
|
|
160
|
-
* Creates a new
|
|
160
|
+
* Creates a new Doctype instance
|
|
161
161
|
* @param doctype - The doctype name
|
|
162
162
|
* @param schema - The doctype schema definition
|
|
163
163
|
* @param workflow - The doctype workflow configuration (XState machine)
|
|
@@ -165,6 +165,70 @@ export declare class DoctypeMeta {
|
|
|
165
165
|
* @param component - Optional Vue component for rendering the doctype
|
|
166
166
|
*/
|
|
167
167
|
constructor(doctype: string, schema: ImmutableDoctype['schema'], workflow: ImmutableDoctype['workflow'], actions: ImmutableDoctype['actions'], component?: Component);
|
|
168
|
+
/**
|
|
169
|
+
* Creates a Doctype instance from a plain configuration object.
|
|
170
|
+
* Handles conversion of arrays to Immutable.js collections internally.
|
|
171
|
+
*
|
|
172
|
+
* This is the recommended way to create a Doctype from API responses
|
|
173
|
+
* or configuration files, as it encapsulates the Immutable.js construction
|
|
174
|
+
* that the framework uses internally.
|
|
175
|
+
*
|
|
176
|
+
* @param config - Plain object with doctype configuration (typically from API response)
|
|
177
|
+
* @returns A new Doctype instance with Immutable.js collections
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* ```ts
|
|
181
|
+
* // From an API response
|
|
182
|
+
* const response = await client.getMeta({ doctype: 'plan' })
|
|
183
|
+
* const doctype = Doctype.fromObject(response)
|
|
184
|
+
* registry.addDoctype(doctype)
|
|
185
|
+
* ```
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* ```ts
|
|
189
|
+
* // From a configuration object
|
|
190
|
+
* const planDoctype = Doctype.fromObject({
|
|
191
|
+
* name: 'Plan',
|
|
192
|
+
* fields: [
|
|
193
|
+
* { fieldname: 'title', label: 'Title', fieldtype: 'Data' },
|
|
194
|
+
* { fieldname: 'status', label: 'Status', fieldtype: 'Data' },
|
|
195
|
+
* ],
|
|
196
|
+
* workflow: {
|
|
197
|
+
* id: 'plan',
|
|
198
|
+
* initial: 'draft',
|
|
199
|
+
* states: { draft: {}, submitted: {} }
|
|
200
|
+
* }
|
|
201
|
+
* })
|
|
202
|
+
* ```
|
|
203
|
+
*
|
|
204
|
+
* @public
|
|
205
|
+
*/
|
|
206
|
+
static fromObject(config: DoctypeConfig): Doctype;
|
|
207
|
+
/**
|
|
208
|
+
* Returns the schema as a plain array for use with components that expect
|
|
209
|
+
* plain JavaScript arrays (e.g., AForm, ATable).
|
|
210
|
+
*
|
|
211
|
+
* @returns Array of schema fields
|
|
212
|
+
*
|
|
213
|
+
* @example
|
|
214
|
+
* ```ts
|
|
215
|
+
* const schemaArray = doctype.getSchemaArray()
|
|
216
|
+
* // Use with AForm
|
|
217
|
+
* <AForm :schema="schemaArray" v-model:data="formData" />
|
|
218
|
+
* ```
|
|
219
|
+
*
|
|
220
|
+
* @public
|
|
221
|
+
*/
|
|
222
|
+
getSchemaArray(): SchemaTypes[];
|
|
223
|
+
/**
|
|
224
|
+
* Returns the actions as a plain object for use with components that expect
|
|
225
|
+
* plain JavaScript objects.
|
|
226
|
+
*
|
|
227
|
+
* @returns Object mapping action names to field trigger arrays
|
|
228
|
+
*
|
|
229
|
+
* @public
|
|
230
|
+
*/
|
|
231
|
+
getActionsObject(): Record<string, string[]>;
|
|
168
232
|
/**
|
|
169
233
|
* Returns the transitions available from a given workflow state, derived from the
|
|
170
234
|
* doctype's XState workflow configuration.
|
|
@@ -194,7 +258,7 @@ export declare class DoctypeMeta {
|
|
|
194
258
|
*
|
|
195
259
|
* @example
|
|
196
260
|
* ```ts
|
|
197
|
-
* const doctype = new
|
|
261
|
+
* const doctype = new Doctype('TaskItem', schema, workflow, actions)
|
|
198
262
|
* console.log(doctype.slug) // 'task-item'
|
|
199
263
|
* ```
|
|
200
264
|
*
|
|
@@ -203,6 +267,32 @@ export declare class DoctypeMeta {
|
|
|
203
267
|
get slug(): string;
|
|
204
268
|
}
|
|
205
269
|
|
|
270
|
+
/**
|
|
271
|
+
* Plain object representation of doctype configuration for serialization/API responses.
|
|
272
|
+
* Compatible with the DoctypeMeta type from \@stonecrop/schema.
|
|
273
|
+
* @public
|
|
274
|
+
*/
|
|
275
|
+
export declare type DoctypeConfig = {
|
|
276
|
+
/** Display name of the doctype */
|
|
277
|
+
name: string;
|
|
278
|
+
/** URL-friendly slug (kebab-case) */
|
|
279
|
+
slug?: string;
|
|
280
|
+
/** Database table name */
|
|
281
|
+
tableName?: string;
|
|
282
|
+
/** Field definitions */
|
|
283
|
+
fields?: SchemaTypes[];
|
|
284
|
+
/** Workflow configuration */
|
|
285
|
+
workflow?: UnknownMachineConfig;
|
|
286
|
+
/** Actions and their field triggers */
|
|
287
|
+
actions?: Record<string, string[]>;
|
|
288
|
+
/** Parent doctype for inheritance */
|
|
289
|
+
inherits?: string;
|
|
290
|
+
/** Doctype to use for list views */
|
|
291
|
+
listDoctype?: string;
|
|
292
|
+
/** Parent doctype for child tables */
|
|
293
|
+
parentDoctype?: string;
|
|
294
|
+
};
|
|
295
|
+
|
|
206
296
|
/**
|
|
207
297
|
* Supported action types for field triggers
|
|
208
298
|
* @public
|
|
@@ -626,9 +716,9 @@ export declare type HSTStonecropReturn = BaseStonecropReturn & {
|
|
|
626
716
|
hstStore: Ref<HSTNode | undefined>;
|
|
627
717
|
formData: Ref<Record<string, any>>;
|
|
628
718
|
resolvedSchema: Ref<SchemaTypes[]>;
|
|
629
|
-
loadNestedData: (parentPath: string, childDoctype:
|
|
630
|
-
saveRecursive: (doctype:
|
|
631
|
-
createNestedContext: (basePath: string, childDoctype:
|
|
719
|
+
loadNestedData: (parentPath: string, childDoctype: Doctype, recordId?: string) => Record<string, any>;
|
|
720
|
+
saveRecursive: (doctype: Doctype, recordId: string) => Promise<Record<string, any>>;
|
|
721
|
+
createNestedContext: (basePath: string, childDoctype: Doctype) => {
|
|
632
722
|
provideHSTPath: (fieldname: string) => string;
|
|
633
723
|
handleHSTChange: (changeData: HSTChangeData) => void;
|
|
634
724
|
};
|
|
@@ -651,7 +741,7 @@ export declare type ImmutableDoctype = {
|
|
|
651
741
|
export declare type InstallOptions = {
|
|
652
742
|
router?: Router;
|
|
653
743
|
components?: Record<string, Component>;
|
|
654
|
-
getMeta?: (routeContext: RouteContext) =>
|
|
744
|
+
getMeta?: (routeContext: RouteContext) => Doctype | Promise<Doctype>;
|
|
655
745
|
/**
|
|
656
746
|
* Data client for fetching doctype metadata and records.
|
|
657
747
|
* Use \@stonecrop/graphql-client's StonecropClient for GraphQL backends,
|
|
@@ -851,9 +941,9 @@ export declare class Registry {
|
|
|
851
941
|
readonly name: string;
|
|
852
942
|
/**
|
|
853
943
|
* The registry property contains a collection of doctypes
|
|
854
|
-
* @see {@link
|
|
944
|
+
* @see {@link Doctype}
|
|
855
945
|
*/
|
|
856
|
-
readonly registry: Record<string,
|
|
946
|
+
readonly registry: Record<string, Doctype>;
|
|
857
947
|
/**
|
|
858
948
|
* The Vue router instance
|
|
859
949
|
* @see {@link https://router.vuejs.org/}
|
|
@@ -864,19 +954,19 @@ export declare class Registry {
|
|
|
864
954
|
* @param router - Optional Vue router instance for route management
|
|
865
955
|
* @param getMeta - Optional function to fetch doctype metadata from an API
|
|
866
956
|
*/
|
|
867
|
-
constructor(router?: Router, getMeta?: (routeContext: RouteContext) =>
|
|
957
|
+
constructor(router?: Router, getMeta?: (routeContext: RouteContext) => Doctype | Promise<Doctype>);
|
|
868
958
|
/**
|
|
869
959
|
* The getMeta function fetches doctype metadata from an API based on route context
|
|
870
|
-
* @see {@link
|
|
960
|
+
* @see {@link Doctype}
|
|
871
961
|
*/
|
|
872
|
-
getMeta?: (routeContext: RouteContext) =>
|
|
962
|
+
getMeta?: (routeContext: RouteContext) => Doctype | Promise<Doctype>;
|
|
873
963
|
/**
|
|
874
964
|
* Get doctype metadata
|
|
875
965
|
* @param doctype - The doctype to fetch metadata for
|
|
876
966
|
* @returns The doctype metadata
|
|
877
|
-
* @see {@link
|
|
967
|
+
* @see {@link Doctype}
|
|
878
968
|
*/
|
|
879
|
-
addDoctype(doctype:
|
|
969
|
+
addDoctype(doctype: Doctype): void;
|
|
880
970
|
/**
|
|
881
971
|
* Resolve nested Doctype and Table fields in a schema by embedding child schemas inline.
|
|
882
972
|
*
|
|
@@ -938,10 +1028,10 @@ export declare class Registry {
|
|
|
938
1028
|
/**
|
|
939
1029
|
* Get a registered doctype by slug
|
|
940
1030
|
* @param slug - The doctype slug to look up
|
|
941
|
-
* @returns The
|
|
1031
|
+
* @returns The Doctype instance if found, or undefined
|
|
942
1032
|
* @public
|
|
943
1033
|
*/
|
|
944
|
-
getDoctype(slug: string):
|
|
1034
|
+
getDoctype(slug: string): Doctype | undefined;
|
|
945
1035
|
}
|
|
946
1036
|
|
|
947
1037
|
/**
|
|
@@ -1328,43 +1418,43 @@ export declare class Stonecrop {
|
|
|
1328
1418
|
* @param doctype - The doctype to get records for
|
|
1329
1419
|
* @returns HST node containing records hash
|
|
1330
1420
|
*/
|
|
1331
|
-
records(doctype: string |
|
|
1421
|
+
records(doctype: string | Doctype): HSTNode;
|
|
1332
1422
|
/**
|
|
1333
1423
|
* Add a record to the store
|
|
1334
1424
|
* @param doctype - The doctype
|
|
1335
1425
|
* @param recordId - The record ID
|
|
1336
1426
|
* @param recordData - The record data
|
|
1337
1427
|
*/
|
|
1338
|
-
addRecord(doctype: string |
|
|
1428
|
+
addRecord(doctype: string | Doctype, recordId: string, recordData: any): void;
|
|
1339
1429
|
/**
|
|
1340
1430
|
* Get a specific record
|
|
1341
1431
|
* @param doctype - The doctype
|
|
1342
1432
|
* @param recordId - The record ID
|
|
1343
1433
|
* @returns HST node for the record or undefined
|
|
1344
1434
|
*/
|
|
1345
|
-
getRecordById(doctype: string |
|
|
1435
|
+
getRecordById(doctype: string | Doctype, recordId: string): HSTNode | undefined;
|
|
1346
1436
|
/**
|
|
1347
1437
|
* Remove a record from the store
|
|
1348
1438
|
* @param doctype - The doctype
|
|
1349
1439
|
* @param recordId - The record ID
|
|
1350
1440
|
*/
|
|
1351
|
-
removeRecord(doctype: string |
|
|
1441
|
+
removeRecord(doctype: string | Doctype, recordId: string): void;
|
|
1352
1442
|
/**
|
|
1353
1443
|
* Get all record IDs for a doctype
|
|
1354
1444
|
* @param doctype - The doctype
|
|
1355
1445
|
* @returns Array of record IDs
|
|
1356
1446
|
*/
|
|
1357
|
-
getRecordIds(doctype: string |
|
|
1447
|
+
getRecordIds(doctype: string | Doctype): string[];
|
|
1358
1448
|
/**
|
|
1359
1449
|
* Clear all records for a doctype
|
|
1360
1450
|
* @param doctype - The doctype
|
|
1361
1451
|
*/
|
|
1362
|
-
clearRecords(doctype: string |
|
|
1452
|
+
clearRecords(doctype: string | Doctype): void;
|
|
1363
1453
|
/**
|
|
1364
1454
|
* Setup method for doctype initialization
|
|
1365
1455
|
* @param doctype - The doctype to setup
|
|
1366
1456
|
*/
|
|
1367
|
-
setup(doctype:
|
|
1457
|
+
setup(doctype: Doctype): void;
|
|
1368
1458
|
/**
|
|
1369
1459
|
* Run action on doctype
|
|
1370
1460
|
* Executes the action and logs it to the operation log for audit tracking
|
|
@@ -1372,20 +1462,20 @@ export declare class Stonecrop {
|
|
|
1372
1462
|
* @param action - The action to run
|
|
1373
1463
|
* @param args - Action arguments (typically record IDs)
|
|
1374
1464
|
*/
|
|
1375
|
-
runAction(doctype:
|
|
1465
|
+
runAction(doctype: Doctype, action: string, args?: any[]): void;
|
|
1376
1466
|
/**
|
|
1377
1467
|
* Get records from server using the configured data client.
|
|
1378
1468
|
* @param doctype - The doctype
|
|
1379
1469
|
* @throws Error if no data client has been configured
|
|
1380
1470
|
*/
|
|
1381
|
-
getRecords(doctype:
|
|
1471
|
+
getRecords(doctype: Doctype): Promise<void>;
|
|
1382
1472
|
/**
|
|
1383
1473
|
* Get single record from server using the configured data client.
|
|
1384
1474
|
* @param doctype - The doctype
|
|
1385
1475
|
* @param recordId - The record ID
|
|
1386
1476
|
* @throws Error if no data client has been configured
|
|
1387
1477
|
*/
|
|
1388
|
-
getRecord(doctype:
|
|
1478
|
+
getRecord(doctype: Doctype, recordId: string): Promise<void>;
|
|
1389
1479
|
/**
|
|
1390
1480
|
* Dispatch an action to the server via the configured data client.
|
|
1391
1481
|
* All state changes flow through this single mutation endpoint.
|
|
@@ -1396,7 +1486,7 @@ export declare class Stonecrop {
|
|
|
1396
1486
|
* @returns Action result with success status, response data, and any error
|
|
1397
1487
|
* @throws Error if no data client has been configured
|
|
1398
1488
|
*/
|
|
1399
|
-
dispatchAction(doctype:
|
|
1489
|
+
dispatchAction(doctype: Doctype, action: string, args?: unknown[]): Promise<{
|
|
1400
1490
|
success: boolean;
|
|
1401
1491
|
data: unknown;
|
|
1402
1492
|
error: string | null;
|
|
@@ -1424,13 +1514,13 @@ export declare class Stonecrop {
|
|
|
1424
1514
|
* empty the doctype's declared `workflow.initial` state is used as the fallback,
|
|
1425
1515
|
* giving callers a reliable state name without having to duplicate that logic.
|
|
1426
1516
|
*
|
|
1427
|
-
* @param doctype - The doctype slug or
|
|
1517
|
+
* @param doctype - The doctype slug or Doctype instance
|
|
1428
1518
|
* @param recordId - The record identifier
|
|
1429
1519
|
* @returns The current state name, or an empty string if the doctype has no workflow
|
|
1430
1520
|
*
|
|
1431
1521
|
* @public
|
|
1432
1522
|
*/
|
|
1433
|
-
getRecordState(doctype: string |
|
|
1523
|
+
getRecordState(doctype: string | Doctype, recordId: string): string;
|
|
1434
1524
|
}
|
|
1435
1525
|
|
|
1436
1526
|
/**
|
|
@@ -1907,7 +1997,7 @@ export declare function useStonecrop(): BaseStonecropReturn | HSTStonecropReturn
|
|
|
1907
1997
|
*/
|
|
1908
1998
|
export declare function useStonecrop(options: {
|
|
1909
1999
|
registry?: Registry;
|
|
1910
|
-
doctype:
|
|
2000
|
+
doctype: Doctype;
|
|
1911
2001
|
recordId?: string;
|
|
1912
2002
|
}): HSTStonecropReturn;
|
|
1913
2003
|
|