@stonecrop/stonecrop 0.10.5 → 0.10.7
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 +32 -3
- package/dist/composables/stonecrop.js +69 -12
- 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 +9 -6
- 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 +125 -32
- package/dist/stonecrop.js +4647 -1391
- package/dist/stonecrop.js.map +1 -1
- package/package.json +4 -4
- package/src/composables/stonecrop.ts +92 -28
- 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/src/stonecrop.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DataClient } from '@stonecrop/schema';
|
|
2
|
-
import
|
|
2
|
+
import Doctype from './doctype';
|
|
3
3
|
import Registry from './registry';
|
|
4
4
|
import { type HSTNode } from './stores/hst';
|
|
5
5
|
import type { OperationLogConfig } from './types/operation-log';
|
|
@@ -332,43 +332,43 @@ export declare class Stonecrop {
|
|
|
332
332
|
* @param doctype - The doctype to get records for
|
|
333
333
|
* @returns HST node containing records hash
|
|
334
334
|
*/
|
|
335
|
-
records(doctype: string |
|
|
335
|
+
records(doctype: string | Doctype): HSTNode;
|
|
336
336
|
/**
|
|
337
337
|
* Add a record to the store
|
|
338
338
|
* @param doctype - The doctype
|
|
339
339
|
* @param recordId - The record ID
|
|
340
340
|
* @param recordData - The record data
|
|
341
341
|
*/
|
|
342
|
-
addRecord(doctype: string |
|
|
342
|
+
addRecord(doctype: string | Doctype, recordId: string, recordData: any): void;
|
|
343
343
|
/**
|
|
344
344
|
* Get a specific record
|
|
345
345
|
* @param doctype - The doctype
|
|
346
346
|
* @param recordId - The record ID
|
|
347
347
|
* @returns HST node for the record or undefined
|
|
348
348
|
*/
|
|
349
|
-
getRecordById(doctype: string |
|
|
349
|
+
getRecordById(doctype: string | Doctype, recordId: string): HSTNode | undefined;
|
|
350
350
|
/**
|
|
351
351
|
* Remove a record from the store
|
|
352
352
|
* @param doctype - The doctype
|
|
353
353
|
* @param recordId - The record ID
|
|
354
354
|
*/
|
|
355
|
-
removeRecord(doctype: string |
|
|
355
|
+
removeRecord(doctype: string | Doctype, recordId: string): void;
|
|
356
356
|
/**
|
|
357
357
|
* Get all record IDs for a doctype
|
|
358
358
|
* @param doctype - The doctype
|
|
359
359
|
* @returns Array of record IDs
|
|
360
360
|
*/
|
|
361
|
-
getRecordIds(doctype: string |
|
|
361
|
+
getRecordIds(doctype: string | Doctype): string[];
|
|
362
362
|
/**
|
|
363
363
|
* Clear all records for a doctype
|
|
364
364
|
* @param doctype - The doctype
|
|
365
365
|
*/
|
|
366
|
-
clearRecords(doctype: string |
|
|
366
|
+
clearRecords(doctype: string | Doctype): void;
|
|
367
367
|
/**
|
|
368
368
|
* Setup method for doctype initialization
|
|
369
369
|
* @param doctype - The doctype to setup
|
|
370
370
|
*/
|
|
371
|
-
setup(doctype:
|
|
371
|
+
setup(doctype: Doctype): void;
|
|
372
372
|
/**
|
|
373
373
|
* Run action on doctype
|
|
374
374
|
* Executes the action and logs it to the operation log for audit tracking
|
|
@@ -376,20 +376,20 @@ export declare class Stonecrop {
|
|
|
376
376
|
* @param action - The action to run
|
|
377
377
|
* @param args - Action arguments (typically record IDs)
|
|
378
378
|
*/
|
|
379
|
-
runAction(doctype:
|
|
379
|
+
runAction(doctype: Doctype, action: string, args?: any[]): void;
|
|
380
380
|
/**
|
|
381
381
|
* Get records from server using the configured data client.
|
|
382
382
|
* @param doctype - The doctype
|
|
383
383
|
* @throws Error if no data client has been configured
|
|
384
384
|
*/
|
|
385
|
-
getRecords(doctype:
|
|
385
|
+
getRecords(doctype: Doctype): Promise<void>;
|
|
386
386
|
/**
|
|
387
387
|
* Get single record from server using the configured data client.
|
|
388
388
|
* @param doctype - The doctype
|
|
389
389
|
* @param recordId - The record ID
|
|
390
390
|
* @throws Error if no data client has been configured
|
|
391
391
|
*/
|
|
392
|
-
getRecord(doctype:
|
|
392
|
+
getRecord(doctype: Doctype, recordId: string): Promise<void>;
|
|
393
393
|
/**
|
|
394
394
|
* Dispatch an action to the server via the configured data client.
|
|
395
395
|
* All state changes flow through this single mutation endpoint.
|
|
@@ -400,7 +400,7 @@ export declare class Stonecrop {
|
|
|
400
400
|
* @returns Action result with success status, response data, and any error
|
|
401
401
|
* @throws Error if no data client has been configured
|
|
402
402
|
*/
|
|
403
|
-
dispatchAction(doctype:
|
|
403
|
+
dispatchAction(doctype: Doctype, action: string, args?: unknown[]): Promise<{
|
|
404
404
|
success: boolean;
|
|
405
405
|
data: unknown;
|
|
406
406
|
error: string | null;
|
|
@@ -428,12 +428,12 @@ export declare class Stonecrop {
|
|
|
428
428
|
* empty the doctype's declared `workflow.initial` state is used as the fallback,
|
|
429
429
|
* giving callers a reliable state name without having to duplicate that logic.
|
|
430
430
|
*
|
|
431
|
-
* @param doctype - The doctype slug or
|
|
431
|
+
* @param doctype - The doctype slug or Doctype instance
|
|
432
432
|
* @param recordId - The record identifier
|
|
433
433
|
* @returns The current state name, or an empty string if the doctype has no workflow
|
|
434
434
|
*
|
|
435
435
|
* @public
|
|
436
436
|
*/
|
|
437
|
-
getRecordState(doctype: string |
|
|
437
|
+
getRecordState(doctype: string | Doctype, recordId: string): string;
|
|
438
438
|
}
|
|
439
439
|
//# sourceMappingURL=stonecrop.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stonecrop.d.ts","sourceRoot":"","sources":["../../src/stonecrop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAGnD,OAAO,
|
|
1
|
+
{"version":3,"file":"stonecrop.d.ts","sourceRoot":"","sources":["../../src/stonecrop.ts"],"names":[],"mappings":"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"}
|
|
@@ -4,7 +4,7 @@ import { List, Map } from 'immutable';
|
|
|
4
4
|
import type { Component } from 'vue';
|
|
5
5
|
import type { Router } from 'vue-router';
|
|
6
6
|
import type { AnyStateNodeConfig, UnknownMachineConfig } from 'xstate';
|
|
7
|
-
import type
|
|
7
|
+
import type Doctype from '../doctype';
|
|
8
8
|
import Registry from '../registry';
|
|
9
9
|
import { Stonecrop } from '../stonecrop';
|
|
10
10
|
import type { RouteContext } from './registry';
|
|
@@ -42,7 +42,7 @@ export type Schema = {
|
|
|
42
42
|
export type InstallOptions = {
|
|
43
43
|
router?: Router;
|
|
44
44
|
components?: Record<string, Component>;
|
|
45
|
-
getMeta?: (routeContext: RouteContext) =>
|
|
45
|
+
getMeta?: (routeContext: RouteContext) => Doctype | Promise<Doctype>;
|
|
46
46
|
/**
|
|
47
47
|
* Data client for fetching doctype metadata and records.
|
|
48
48
|
* Use \@stonecrop/graphql-client's StonecropClient for GraphQL backends,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AACpC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAA;AAEtE,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AACpC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAA;AAEtE,OAAO,KAAK,OAAO,MAAM,YAAY,CAAA;AACrC,OAAO,QAAQ,MAAM,aAAa,CAAA;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE9C;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC9B,QAAQ,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,CAAA;IACnC,QAAQ,CAAC,QAAQ,CAAC,EAAE,oBAAoB,GAAG,kBAAkB,CAAA;IAC7D,QAAQ,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;CACxC,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,WAAW,EAAE,CAAA;IACtB,QAAQ,CAAC,EAAE,oBAAoB,GAAG,kBAAkB,CAAA;IACpD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;CAClC,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,MAAM,GAAG;IACpB,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,CAAA;CACzB,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IACtC,OAAO,CAAC,EAAE,CAAC,YAAY,EAAE,YAAY,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IACpE;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,oFAAoF;IACpF,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,iEAAiE;IACjE,mBAAmB,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACxF,CAAA;AAGD,cAAc,kBAAkB,CAAA;AAChC,cAAc,YAAY,CAAA;AAC1B,cAAc,iBAAiB,CAAA"}
|
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,12 +716,15 @@ 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
|
};
|
|
725
|
+
isLoading: Ref<boolean>;
|
|
726
|
+
error: Ref<Error | null>;
|
|
727
|
+
resolvedDoctype: Ref<Doctype | undefined>;
|
|
635
728
|
};
|
|
636
729
|
|
|
637
730
|
/**
|
|
@@ -651,7 +744,7 @@ export declare type ImmutableDoctype = {
|
|
|
651
744
|
export declare type InstallOptions = {
|
|
652
745
|
router?: Router;
|
|
653
746
|
components?: Record<string, Component>;
|
|
654
|
-
getMeta?: (routeContext: RouteContext) =>
|
|
747
|
+
getMeta?: (routeContext: RouteContext) => Doctype | Promise<Doctype>;
|
|
655
748
|
/**
|
|
656
749
|
* Data client for fetching doctype metadata and records.
|
|
657
750
|
* Use \@stonecrop/graphql-client's StonecropClient for GraphQL backends,
|
|
@@ -851,9 +944,9 @@ export declare class Registry {
|
|
|
851
944
|
readonly name: string;
|
|
852
945
|
/**
|
|
853
946
|
* The registry property contains a collection of doctypes
|
|
854
|
-
* @see {@link
|
|
947
|
+
* @see {@link Doctype}
|
|
855
948
|
*/
|
|
856
|
-
readonly registry: Record<string,
|
|
949
|
+
readonly registry: Record<string, Doctype>;
|
|
857
950
|
/**
|
|
858
951
|
* The Vue router instance
|
|
859
952
|
* @see {@link https://router.vuejs.org/}
|
|
@@ -864,19 +957,19 @@ export declare class Registry {
|
|
|
864
957
|
* @param router - Optional Vue router instance for route management
|
|
865
958
|
* @param getMeta - Optional function to fetch doctype metadata from an API
|
|
866
959
|
*/
|
|
867
|
-
constructor(router?: Router, getMeta?: (routeContext: RouteContext) =>
|
|
960
|
+
constructor(router?: Router, getMeta?: (routeContext: RouteContext) => Doctype | Promise<Doctype>);
|
|
868
961
|
/**
|
|
869
962
|
* The getMeta function fetches doctype metadata from an API based on route context
|
|
870
|
-
* @see {@link
|
|
963
|
+
* @see {@link Doctype}
|
|
871
964
|
*/
|
|
872
|
-
getMeta?: (routeContext: RouteContext) =>
|
|
965
|
+
getMeta?: (routeContext: RouteContext) => Doctype | Promise<Doctype>;
|
|
873
966
|
/**
|
|
874
967
|
* Get doctype metadata
|
|
875
968
|
* @param doctype - The doctype to fetch metadata for
|
|
876
969
|
* @returns The doctype metadata
|
|
877
|
-
* @see {@link
|
|
970
|
+
* @see {@link Doctype}
|
|
878
971
|
*/
|
|
879
|
-
addDoctype(doctype:
|
|
972
|
+
addDoctype(doctype: Doctype): void;
|
|
880
973
|
/**
|
|
881
974
|
* Resolve nested Doctype and Table fields in a schema by embedding child schemas inline.
|
|
882
975
|
*
|
|
@@ -938,10 +1031,10 @@ export declare class Registry {
|
|
|
938
1031
|
/**
|
|
939
1032
|
* Get a registered doctype by slug
|
|
940
1033
|
* @param slug - The doctype slug to look up
|
|
941
|
-
* @returns The
|
|
1034
|
+
* @returns The Doctype instance if found, or undefined
|
|
942
1035
|
* @public
|
|
943
1036
|
*/
|
|
944
|
-
getDoctype(slug: string):
|
|
1037
|
+
getDoctype(slug: string): Doctype | undefined;
|
|
945
1038
|
}
|
|
946
1039
|
|
|
947
1040
|
/**
|
|
@@ -1328,43 +1421,43 @@ export declare class Stonecrop {
|
|
|
1328
1421
|
* @param doctype - The doctype to get records for
|
|
1329
1422
|
* @returns HST node containing records hash
|
|
1330
1423
|
*/
|
|
1331
|
-
records(doctype: string |
|
|
1424
|
+
records(doctype: string | Doctype): HSTNode;
|
|
1332
1425
|
/**
|
|
1333
1426
|
* Add a record to the store
|
|
1334
1427
|
* @param doctype - The doctype
|
|
1335
1428
|
* @param recordId - The record ID
|
|
1336
1429
|
* @param recordData - The record data
|
|
1337
1430
|
*/
|
|
1338
|
-
addRecord(doctype: string |
|
|
1431
|
+
addRecord(doctype: string | Doctype, recordId: string, recordData: any): void;
|
|
1339
1432
|
/**
|
|
1340
1433
|
* Get a specific record
|
|
1341
1434
|
* @param doctype - The doctype
|
|
1342
1435
|
* @param recordId - The record ID
|
|
1343
1436
|
* @returns HST node for the record or undefined
|
|
1344
1437
|
*/
|
|
1345
|
-
getRecordById(doctype: string |
|
|
1438
|
+
getRecordById(doctype: string | Doctype, recordId: string): HSTNode | undefined;
|
|
1346
1439
|
/**
|
|
1347
1440
|
* Remove a record from the store
|
|
1348
1441
|
* @param doctype - The doctype
|
|
1349
1442
|
* @param recordId - The record ID
|
|
1350
1443
|
*/
|
|
1351
|
-
removeRecord(doctype: string |
|
|
1444
|
+
removeRecord(doctype: string | Doctype, recordId: string): void;
|
|
1352
1445
|
/**
|
|
1353
1446
|
* Get all record IDs for a doctype
|
|
1354
1447
|
* @param doctype - The doctype
|
|
1355
1448
|
* @returns Array of record IDs
|
|
1356
1449
|
*/
|
|
1357
|
-
getRecordIds(doctype: string |
|
|
1450
|
+
getRecordIds(doctype: string | Doctype): string[];
|
|
1358
1451
|
/**
|
|
1359
1452
|
* Clear all records for a doctype
|
|
1360
1453
|
* @param doctype - The doctype
|
|
1361
1454
|
*/
|
|
1362
|
-
clearRecords(doctype: string |
|
|
1455
|
+
clearRecords(doctype: string | Doctype): void;
|
|
1363
1456
|
/**
|
|
1364
1457
|
* Setup method for doctype initialization
|
|
1365
1458
|
* @param doctype - The doctype to setup
|
|
1366
1459
|
*/
|
|
1367
|
-
setup(doctype:
|
|
1460
|
+
setup(doctype: Doctype): void;
|
|
1368
1461
|
/**
|
|
1369
1462
|
* Run action on doctype
|
|
1370
1463
|
* Executes the action and logs it to the operation log for audit tracking
|
|
@@ -1372,20 +1465,20 @@ export declare class Stonecrop {
|
|
|
1372
1465
|
* @param action - The action to run
|
|
1373
1466
|
* @param args - Action arguments (typically record IDs)
|
|
1374
1467
|
*/
|
|
1375
|
-
runAction(doctype:
|
|
1468
|
+
runAction(doctype: Doctype, action: string, args?: any[]): void;
|
|
1376
1469
|
/**
|
|
1377
1470
|
* Get records from server using the configured data client.
|
|
1378
1471
|
* @param doctype - The doctype
|
|
1379
1472
|
* @throws Error if no data client has been configured
|
|
1380
1473
|
*/
|
|
1381
|
-
getRecords(doctype:
|
|
1474
|
+
getRecords(doctype: Doctype): Promise<void>;
|
|
1382
1475
|
/**
|
|
1383
1476
|
* Get single record from server using the configured data client.
|
|
1384
1477
|
* @param doctype - The doctype
|
|
1385
1478
|
* @param recordId - The record ID
|
|
1386
1479
|
* @throws Error if no data client has been configured
|
|
1387
1480
|
*/
|
|
1388
|
-
getRecord(doctype:
|
|
1481
|
+
getRecord(doctype: Doctype, recordId: string): Promise<void>;
|
|
1389
1482
|
/**
|
|
1390
1483
|
* Dispatch an action to the server via the configured data client.
|
|
1391
1484
|
* All state changes flow through this single mutation endpoint.
|
|
@@ -1396,7 +1489,7 @@ export declare class Stonecrop {
|
|
|
1396
1489
|
* @returns Action result with success status, response data, and any error
|
|
1397
1490
|
* @throws Error if no data client has been configured
|
|
1398
1491
|
*/
|
|
1399
|
-
dispatchAction(doctype:
|
|
1492
|
+
dispatchAction(doctype: Doctype, action: string, args?: unknown[]): Promise<{
|
|
1400
1493
|
success: boolean;
|
|
1401
1494
|
data: unknown;
|
|
1402
1495
|
error: string | null;
|
|
@@ -1424,13 +1517,13 @@ export declare class Stonecrop {
|
|
|
1424
1517
|
* empty the doctype's declared `workflow.initial` state is used as the fallback,
|
|
1425
1518
|
* giving callers a reliable state name without having to duplicate that logic.
|
|
1426
1519
|
*
|
|
1427
|
-
* @param doctype - The doctype slug or
|
|
1520
|
+
* @param doctype - The doctype slug or Doctype instance
|
|
1428
1521
|
* @param recordId - The record identifier
|
|
1429
1522
|
* @returns The current state name, or an empty string if the doctype has no workflow
|
|
1430
1523
|
*
|
|
1431
1524
|
* @public
|
|
1432
1525
|
*/
|
|
1433
|
-
getRecordState(doctype: string |
|
|
1526
|
+
getRecordState(doctype: string | Doctype, recordId: string): string;
|
|
1434
1527
|
}
|
|
1435
1528
|
|
|
1436
1529
|
/**
|
|
@@ -1901,13 +1994,13 @@ export declare function useStonecrop(): BaseStonecropReturn | HSTStonecropReturn
|
|
|
1901
1994
|
/**
|
|
1902
1995
|
* Unified Stonecrop composable with HST integration for a specific doctype and record
|
|
1903
1996
|
*
|
|
1904
|
-
* @param options - Configuration with doctype and optional recordId
|
|
1997
|
+
* @param options - Configuration with doctype (string slug or Doctype instance) and optional recordId
|
|
1905
1998
|
* @returns Stonecrop instance with full HST integration utilities
|
|
1906
1999
|
* @public
|
|
1907
2000
|
*/
|
|
1908
2001
|
export declare function useStonecrop(options: {
|
|
1909
2002
|
registry?: Registry;
|
|
1910
|
-
doctype:
|
|
2003
|
+
doctype: Doctype | string;
|
|
1911
2004
|
recordId?: string;
|
|
1912
2005
|
}): HSTStonecropReturn;
|
|
1913
2006
|
|