@stonecrop/stonecrop 0.31.0 → 0.33.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.
Files changed (121) hide show
  1. package/dist/stonecrop.js +3548 -2740
  2. package/dist/stonecrop.js.map +1 -1
  3. package/dist/tsdoc-metadata.json +1 -1
  4. package/package.json +33 -27
  5. package/dist/src/client-action.d.ts +0 -31
  6. package/dist/src/client-action.d.ts.map +0 -1
  7. package/dist/src/client-action.js +0 -169
  8. package/dist/src/client-handler.d.ts +0 -43
  9. package/dist/src/client-handler.d.ts.map +0 -1
  10. package/dist/src/client-handler.js +0 -42
  11. package/dist/src/composables/lazy-link.d.ts +0 -25
  12. package/dist/src/composables/lazy-link.d.ts.map +0 -1
  13. package/dist/src/composables/lazy-link.js +0 -124
  14. package/dist/src/composables/operation-log.d.ts +0 -136
  15. package/dist/src/composables/operation-log.d.ts.map +0 -1
  16. package/dist/src/composables/operation-log.js +0 -224
  17. package/dist/src/composables/stonecrop.d.ts +0 -37
  18. package/dist/src/composables/stonecrop.d.ts.map +0 -1
  19. package/dist/src/composables/stonecrop.js +0 -433
  20. package/dist/src/doctype.d.ts +0 -243
  21. package/dist/src/doctype.d.ts.map +0 -1
  22. package/dist/src/doctype.js +0 -325
  23. package/dist/src/draft.d.ts +0 -35
  24. package/dist/src/draft.d.ts.map +0 -1
  25. package/dist/src/draft.js +0 -36
  26. package/dist/src/exceptions.d.ts +0 -14
  27. package/dist/src/exceptions.d.ts.map +0 -1
  28. package/dist/src/exceptions.js +0 -16
  29. package/dist/src/field-triggers.d.ts +0 -184
  30. package/dist/src/field-triggers.d.ts.map +0 -1
  31. package/dist/src/field-triggers.js +0 -577
  32. package/dist/src/index.d.ts +0 -25
  33. package/dist/src/index.d.ts.map +0 -1
  34. package/dist/src/index.js +0 -39
  35. package/dist/src/plugins/index.d.ts +0 -35
  36. package/dist/src/plugins/index.d.ts.map +0 -1
  37. package/dist/src/plugins/index.js +0 -98
  38. package/dist/src/registry.d.ts +0 -161
  39. package/dist/src/registry.d.ts.map +0 -1
  40. package/dist/src/registry.js +0 -384
  41. package/dist/src/schema-validator.d.ts +0 -78
  42. package/dist/src/schema-validator.d.ts.map +0 -1
  43. package/dist/src/schema-validator.js +0 -398
  44. package/dist/src/stonecrop.d.ts +0 -539
  45. package/dist/src/stonecrop.d.ts.map +0 -1
  46. package/dist/src/stonecrop.js +0 -610
  47. package/dist/src/stores/hst.d.ts +0 -92
  48. package/dist/src/stores/hst.d.ts.map +0 -1
  49. package/dist/src/stores/hst.js +0 -487
  50. package/dist/src/stores/index.d.ts +0 -9
  51. package/dist/src/stores/index.d.ts.map +0 -1
  52. package/dist/src/stores/index.js +0 -13
  53. package/dist/src/stores/operation-log.d.ts +0 -262
  54. package/dist/src/stores/operation-log.d.ts.map +0 -1
  55. package/dist/src/stores/operation-log.js +0 -571
  56. package/dist/src/stores/validation.d.ts +0 -83
  57. package/dist/src/stores/validation.d.ts.map +0 -1
  58. package/dist/src/stores/validation.js +0 -104
  59. package/dist/src/types/client-action.d.ts +0 -121
  60. package/dist/src/types/client-action.d.ts.map +0 -1
  61. package/dist/src/types/client-action.js +0 -0
  62. package/dist/src/types/composable.d.ts +0 -268
  63. package/dist/src/types/composable.d.ts.map +0 -1
  64. package/dist/src/types/composable.js +0 -0
  65. package/dist/src/types/doctype.d.ts +0 -34
  66. package/dist/src/types/doctype.d.ts.map +0 -1
  67. package/dist/src/types/doctype.js +0 -0
  68. package/dist/src/types/field-triggers.d.ts +0 -186
  69. package/dist/src/types/field-triggers.d.ts.map +0 -1
  70. package/dist/src/types/field-triggers.js +0 -4
  71. package/dist/src/types/hst.d.ts +0 -70
  72. package/dist/src/types/hst.d.ts.map +0 -1
  73. package/dist/src/types/hst.js +0 -0
  74. package/dist/src/types/index.d.ts +0 -11
  75. package/dist/src/types/index.d.ts.map +0 -1
  76. package/dist/src/types/index.js +0 -11
  77. package/dist/src/types/operation-log.d.ts +0 -163
  78. package/dist/src/types/operation-log.d.ts.map +0 -1
  79. package/dist/src/types/operation-log.js +0 -0
  80. package/dist/src/types/plugin.d.ts +0 -37
  81. package/dist/src/types/plugin.d.ts.map +0 -1
  82. package/dist/src/types/plugin.js +0 -0
  83. package/dist/src/types/registry.d.ts +0 -11
  84. package/dist/src/types/registry.d.ts.map +0 -1
  85. package/dist/src/types/registry.js +0 -0
  86. package/dist/src/types/schema-validator.d.ts +0 -66
  87. package/dist/src/types/schema-validator.d.ts.map +0 -1
  88. package/dist/src/types/schema-validator.js +0 -13
  89. package/dist/src/types/stonecrop.d.ts +0 -32
  90. package/dist/src/types/stonecrop.d.ts.map +0 -1
  91. package/dist/src/types/stonecrop.js +0 -0
  92. package/dist/stonecrop.tsbuildinfo +0 -1
  93. package/src/client-action.ts +0 -207
  94. package/src/client-handler.ts +0 -55
  95. package/src/composables/lazy-link.ts +0 -145
  96. package/src/composables/operation-log.ts +0 -257
  97. package/src/composables/stonecrop.ts +0 -556
  98. package/src/doctype.ts +0 -360
  99. package/src/draft.ts +0 -38
  100. package/src/exceptions.ts +0 -16
  101. package/src/field-triggers.ts +0 -686
  102. package/src/index.ts +0 -81
  103. package/src/plugins/index.ts +0 -113
  104. package/src/registry.ts +0 -433
  105. package/src/schema-validator.ts +0 -476
  106. package/src/stonecrop.ts +0 -721
  107. package/src/stores/hst.ts +0 -626
  108. package/src/stores/index.ts +0 -21
  109. package/src/stores/operation-log.ts +0 -675
  110. package/src/stores/validation.ts +0 -138
  111. package/src/types/client-action.ts +0 -121
  112. package/src/types/composable.ts +0 -288
  113. package/src/types/doctype.ts +0 -35
  114. package/src/types/field-triggers.ts +0 -201
  115. package/src/types/hst.ts +0 -77
  116. package/src/types/index.ts +0 -11
  117. package/src/types/operation-log.ts +0 -202
  118. package/src/types/plugin.ts +0 -38
  119. package/src/types/registry.ts +0 -10
  120. package/src/types/schema-validator.ts +0 -69
  121. package/src/types/stonecrop.ts +0 -33
@@ -1,539 +0,0 @@
1
- import type { DataClient, GetRecordOptions, GetRecordsOptions, GetRecordsResult } from '@stonecrop/schema';
2
- import Doctype from './doctype';
3
- import Registry from './registry';
4
- import { type HSTNode } from './stores/hst';
5
- import type { OperationLogConfig } from './types/operation-log';
6
- import type { RouteContext } from './types/registry';
7
- import type { PageInfo, StonecropOptions } from './types/stonecrop';
8
- /**
9
- * Main Stonecrop class with HST integration and built-in Operation Log
10
- * @public
11
- */
12
- export declare class Stonecrop {
13
- /**
14
- * Singleton instance of Stonecrop. Only one Stonecrop instance can exist
15
- * per application, ensuring consistent HST state and registry access.
16
- * Subsequent constructor calls return this instance instead of creating new ones.
17
- * @internal
18
- */
19
- static _root: Stonecrop;
20
- /** The HST store instance for reactive state management */
21
- private hstStore;
22
- private _operationLogStore?;
23
- private _operationLogConfig?;
24
- private _client?;
25
- /**
26
- * Per-doctype page info from the last list read, keyed by slug. Reactive so views tracking
27
- * it update on fetch. Deliberately not in HST — see {@link Stonecrop.getRecords}.
28
- */
29
- private pageInfo;
30
- /** The registry instance containing all doctype definitions */
31
- readonly registry: Registry;
32
- /**
33
- * Creates a new Stonecrop instance with HST integration (singleton pattern)
34
- * @param registry - The Registry instance containing doctype definitions
35
- * @param operationLogConfig - Optional configuration for the operation log
36
- * @param options - Options including the data client (can be set later via setClient)
37
- */
38
- constructor(registry: Registry, operationLogConfig?: Partial<OperationLogConfig>, options?: StonecropOptions);
39
- /**
40
- * Set the data client for fetching doctype metadata and records.
41
- * Use this for deferred configuration in Nuxt/Vue plugin setups.
42
- *
43
- * @param client - DataClient implementation (e.g., StonecropClient from \@stonecrop/graphql-client)
44
- *
45
- * @example
46
- * ```ts
47
- * const { setClient } = useStonecropRegistry()
48
- * const client = new StonecropClient({ endpoint: '/graphql' })
49
- * setClient(client)
50
- * ```
51
- */
52
- setClient(client: DataClient): void;
53
- /**
54
- * Get the current data client
55
- * @returns The DataClient instance or undefined if not set
56
- */
57
- getClient(): DataClient | undefined;
58
- /**
59
- * Get the operation log store (lazy initialization)
60
- * @internal
61
- */
62
- getOperationLogStore(): import("pinia").Store<"hst-operation-log", Pick<{
63
- operations: import("vue").Ref<{
64
- id: string;
65
- type: import("./types").HSTOperationType;
66
- path: string;
67
- fieldname: string;
68
- beforeValue: any;
69
- afterValue: any;
70
- doctype: string;
71
- recordId?: string | undefined;
72
- timestamp: Date;
73
- source?: import("./types").OperationSource | undefined;
74
- reversible: boolean;
75
- irreversibleReason?: string | undefined;
76
- transition?: string | undefined;
77
- currentState?: string | undefined;
78
- targetState?: string | undefined;
79
- actionName?: string | undefined;
80
- actionRecordIds?: string[] | undefined;
81
- actionResult?: "success" | "failure" | "pending" | undefined;
82
- actionError?: string | undefined;
83
- userId?: string | undefined;
84
- metadata?: Record<string, any> | undefined;
85
- ancestorOperationId?: string | undefined;
86
- descendantOperationIds?: string[] | undefined;
87
- }[], import("./types").HSTOperation[] | {
88
- id: string;
89
- type: import("./types").HSTOperationType;
90
- path: string;
91
- fieldname: string;
92
- beforeValue: any;
93
- afterValue: any;
94
- doctype: string;
95
- recordId?: string | undefined;
96
- timestamp: Date;
97
- source?: import("./types").OperationSource | undefined;
98
- reversible: boolean;
99
- irreversibleReason?: string | undefined;
100
- transition?: string | undefined;
101
- currentState?: string | undefined;
102
- targetState?: string | undefined;
103
- actionName?: string | undefined;
104
- actionRecordIds?: string[] | undefined;
105
- actionResult?: "success" | "failure" | "pending" | undefined;
106
- actionError?: string | undefined;
107
- userId?: string | undefined;
108
- metadata?: Record<string, any> | undefined;
109
- ancestorOperationId?: string | undefined;
110
- descendantOperationIds?: string[] | undefined;
111
- }[]>;
112
- currentIndex: import("vue").Ref<number, number>;
113
- config: import("vue").Ref<{
114
- maxOperations?: number | undefined;
115
- enableCrossTabSync?: boolean | undefined;
116
- enablePersistence?: boolean | undefined;
117
- persistenceKeyPrefix?: string | undefined;
118
- userId?: string | undefined;
119
- operationFilter?: ((operation: import("./types").HSTOperation) => boolean) | undefined;
120
- }, OperationLogConfig | {
121
- maxOperations?: number | undefined;
122
- enableCrossTabSync?: boolean | undefined;
123
- enablePersistence?: boolean | undefined;
124
- persistenceKeyPrefix?: string | undefined;
125
- userId?: string | undefined;
126
- operationFilter?: ((operation: import("./types").HSTOperation) => boolean) | undefined;
127
- }>;
128
- clientId: import("vue").Ref<string, string>;
129
- undoRedoState: import("vue").ComputedRef<import("./types").UndoRedoState>;
130
- canUndo: import("vue").ComputedRef<boolean>;
131
- canRedo: import("vue").ComputedRef<boolean>;
132
- undoCount: import("vue").ComputedRef<number>;
133
- redoCount: import("vue").ComputedRef<number>;
134
- configure: (options: Partial<OperationLogConfig>) => void;
135
- addOperation: (operation: import("./types").HSTOperationInput, source?: import("./types").OperationSource) => string;
136
- startBatch: () => void;
137
- commitBatch: (description?: string) => string | null;
138
- cancelBatch: () => void;
139
- undo: (store: HSTNode) => boolean;
140
- redo: (store: HSTNode) => boolean;
141
- clear: () => void;
142
- getOperationsFor: (doctype: string, recordId?: string) => import("./types").HSTOperation[];
143
- getSnapshot: () => import("./types").OperationLogSnapshot;
144
- markIrreversible: (operationId: string, reason: string) => void;
145
- logAction: (doctype: string, actionName: string, recordIds?: string[], result?: "success" | "failure" | "pending", error?: string) => string;
146
- }, "config" | "operations" | "clientId" | "currentIndex">, Pick<{
147
- operations: import("vue").Ref<{
148
- id: string;
149
- type: import("./types").HSTOperationType;
150
- path: string;
151
- fieldname: string;
152
- beforeValue: any;
153
- afterValue: any;
154
- doctype: string;
155
- recordId?: string | undefined;
156
- timestamp: Date;
157
- source?: import("./types").OperationSource | undefined;
158
- reversible: boolean;
159
- irreversibleReason?: string | undefined;
160
- transition?: string | undefined;
161
- currentState?: string | undefined;
162
- targetState?: string | undefined;
163
- actionName?: string | undefined;
164
- actionRecordIds?: string[] | undefined;
165
- actionResult?: "success" | "failure" | "pending" | undefined;
166
- actionError?: string | undefined;
167
- userId?: string | undefined;
168
- metadata?: Record<string, any> | undefined;
169
- ancestorOperationId?: string | undefined;
170
- descendantOperationIds?: string[] | undefined;
171
- }[], import("./types").HSTOperation[] | {
172
- id: string;
173
- type: import("./types").HSTOperationType;
174
- path: string;
175
- fieldname: string;
176
- beforeValue: any;
177
- afterValue: any;
178
- doctype: string;
179
- recordId?: string | undefined;
180
- timestamp: Date;
181
- source?: import("./types").OperationSource | undefined;
182
- reversible: boolean;
183
- irreversibleReason?: string | undefined;
184
- transition?: string | undefined;
185
- currentState?: string | undefined;
186
- targetState?: string | undefined;
187
- actionName?: string | undefined;
188
- actionRecordIds?: string[] | undefined;
189
- actionResult?: "success" | "failure" | "pending" | undefined;
190
- actionError?: string | undefined;
191
- userId?: string | undefined;
192
- metadata?: Record<string, any> | undefined;
193
- ancestorOperationId?: string | undefined;
194
- descendantOperationIds?: string[] | undefined;
195
- }[]>;
196
- currentIndex: import("vue").Ref<number, number>;
197
- config: import("vue").Ref<{
198
- maxOperations?: number | undefined;
199
- enableCrossTabSync?: boolean | undefined;
200
- enablePersistence?: boolean | undefined;
201
- persistenceKeyPrefix?: string | undefined;
202
- userId?: string | undefined;
203
- operationFilter?: ((operation: import("./types").HSTOperation) => boolean) | undefined;
204
- }, OperationLogConfig | {
205
- maxOperations?: number | undefined;
206
- enableCrossTabSync?: boolean | undefined;
207
- enablePersistence?: boolean | undefined;
208
- persistenceKeyPrefix?: string | undefined;
209
- userId?: string | undefined;
210
- operationFilter?: ((operation: import("./types").HSTOperation) => boolean) | undefined;
211
- }>;
212
- clientId: import("vue").Ref<string, string>;
213
- undoRedoState: import("vue").ComputedRef<import("./types").UndoRedoState>;
214
- canUndo: import("vue").ComputedRef<boolean>;
215
- canRedo: import("vue").ComputedRef<boolean>;
216
- undoCount: import("vue").ComputedRef<number>;
217
- redoCount: import("vue").ComputedRef<number>;
218
- configure: (options: Partial<OperationLogConfig>) => void;
219
- addOperation: (operation: import("./types").HSTOperationInput, source?: import("./types").OperationSource) => string;
220
- startBatch: () => void;
221
- commitBatch: (description?: string) => string | null;
222
- cancelBatch: () => void;
223
- undo: (store: HSTNode) => boolean;
224
- redo: (store: HSTNode) => boolean;
225
- clear: () => void;
226
- getOperationsFor: (doctype: string, recordId?: string) => import("./types").HSTOperation[];
227
- getSnapshot: () => import("./types").OperationLogSnapshot;
228
- markIrreversible: (operationId: string, reason: string) => void;
229
- logAction: (doctype: string, actionName: string, recordIds?: string[], result?: "success" | "failure" | "pending", error?: string) => string;
230
- }, "undoRedoState" | "canUndo" | "canRedo" | "undoCount" | "redoCount">, Pick<{
231
- operations: import("vue").Ref<{
232
- id: string;
233
- type: import("./types").HSTOperationType;
234
- path: string;
235
- fieldname: string;
236
- beforeValue: any;
237
- afterValue: any;
238
- doctype: string;
239
- recordId?: string | undefined;
240
- timestamp: Date;
241
- source?: import("./types").OperationSource | undefined;
242
- reversible: boolean;
243
- irreversibleReason?: string | undefined;
244
- transition?: string | undefined;
245
- currentState?: string | undefined;
246
- targetState?: string | undefined;
247
- actionName?: string | undefined;
248
- actionRecordIds?: string[] | undefined;
249
- actionResult?: "success" | "failure" | "pending" | undefined;
250
- actionError?: string | undefined;
251
- userId?: string | undefined;
252
- metadata?: Record<string, any> | undefined;
253
- ancestorOperationId?: string | undefined;
254
- descendantOperationIds?: string[] | undefined;
255
- }[], import("./types").HSTOperation[] | {
256
- id: string;
257
- type: import("./types").HSTOperationType;
258
- path: string;
259
- fieldname: string;
260
- beforeValue: any;
261
- afterValue: any;
262
- doctype: string;
263
- recordId?: string | undefined;
264
- timestamp: Date;
265
- source?: import("./types").OperationSource | undefined;
266
- reversible: boolean;
267
- irreversibleReason?: string | undefined;
268
- transition?: string | undefined;
269
- currentState?: string | undefined;
270
- targetState?: string | undefined;
271
- actionName?: string | undefined;
272
- actionRecordIds?: string[] | undefined;
273
- actionResult?: "success" | "failure" | "pending" | undefined;
274
- actionError?: string | undefined;
275
- userId?: string | undefined;
276
- metadata?: Record<string, any> | undefined;
277
- ancestorOperationId?: string | undefined;
278
- descendantOperationIds?: string[] | undefined;
279
- }[]>;
280
- currentIndex: import("vue").Ref<number, number>;
281
- config: import("vue").Ref<{
282
- maxOperations?: number | undefined;
283
- enableCrossTabSync?: boolean | undefined;
284
- enablePersistence?: boolean | undefined;
285
- persistenceKeyPrefix?: string | undefined;
286
- userId?: string | undefined;
287
- operationFilter?: ((operation: import("./types").HSTOperation) => boolean) | undefined;
288
- }, OperationLogConfig | {
289
- maxOperations?: number | undefined;
290
- enableCrossTabSync?: boolean | undefined;
291
- enablePersistence?: boolean | undefined;
292
- persistenceKeyPrefix?: string | undefined;
293
- userId?: string | undefined;
294
- operationFilter?: ((operation: import("./types").HSTOperation) => boolean) | undefined;
295
- }>;
296
- clientId: import("vue").Ref<string, string>;
297
- undoRedoState: import("vue").ComputedRef<import("./types").UndoRedoState>;
298
- canUndo: import("vue").ComputedRef<boolean>;
299
- canRedo: import("vue").ComputedRef<boolean>;
300
- undoCount: import("vue").ComputedRef<number>;
301
- redoCount: import("vue").ComputedRef<number>;
302
- configure: (options: Partial<OperationLogConfig>) => void;
303
- addOperation: (operation: import("./types").HSTOperationInput, source?: import("./types").OperationSource) => string;
304
- startBatch: () => void;
305
- commitBatch: (description?: string) => string | null;
306
- cancelBatch: () => void;
307
- undo: (store: HSTNode) => boolean;
308
- redo: (store: HSTNode) => boolean;
309
- clear: () => void;
310
- getOperationsFor: (doctype: string, recordId?: string) => import("./types").HSTOperation[];
311
- getSnapshot: () => import("./types").OperationLogSnapshot;
312
- markIrreversible: (operationId: string, reason: string) => void;
313
- logAction: (doctype: string, actionName: string, recordIds?: string[], result?: "success" | "failure" | "pending", error?: string) => string;
314
- }, "clear" | "undo" | "redo" | "configure" | "addOperation" | "startBatch" | "commitBatch" | "cancelBatch" | "getOperationsFor" | "getSnapshot" | "markIrreversible" | "logAction">>;
315
- /**
316
- * Initialize the HST store structure
317
- */
318
- private initializeHSTStore;
319
- /**
320
- * Setup automatic sync with Registry when doctypes are added
321
- */
322
- private setupRegistrySync;
323
- /**
324
- * Get records hash for a doctype
325
- * @param doctype - The doctype to get records for
326
- * @returns HST node containing records hash
327
- */
328
- records(doctype: string | Doctype): HSTNode;
329
- /**
330
- * Add a record to the store
331
- * @param doctype - The doctype
332
- * @param recordId - The record ID
333
- * @param recordData - The record data
334
- */
335
- addRecord(doctype: string | Doctype, recordId: string, recordData: any): void;
336
- /**
337
- * Get a specific record
338
- * @param doctype - The doctype
339
- * @param recordId - The record ID
340
- * @returns HST node for the record or undefined
341
- */
342
- getRecordById(doctype: string | Doctype, recordId: string): HSTNode | undefined;
343
- /**
344
- * Remove a record from the store
345
- * @param doctype - The doctype
346
- * @param recordId - The record ID
347
- */
348
- removeRecord(doctype: string | Doctype, recordId: string): void;
349
- /**
350
- * Get all record IDs for a doctype
351
- * @param doctype - The doctype
352
- * @returns Array of record IDs
353
- */
354
- getRecordIds(doctype: string | Doctype): string[];
355
- /**
356
- * Clear all records for a doctype
357
- * @param doctype - The doctype
358
- */
359
- clearRecords(doctype: string | Doctype): void;
360
- /**
361
- * Setup method for doctype initialization
362
- * @param doctype - The doctype to setup
363
- */
364
- setup(doctype: Doctype): void;
365
- /**
366
- * Get the effective blockWorkflows value for a link.
367
- * Returns true if blockWorkflows is explicitly true, or if it's absent and fetch method is 'sync'.
368
- * @param link - The link declaration
369
- * @returns Whether workflows should be blocked until this link is loaded
370
- */
371
- private getEffectiveBlockWorkflows;
372
- /**
373
- * Check if workflow actions are ready to run (all required link data is loaded).
374
- * A link's data is considered loaded if it exists in HST at `slug.recordId.linkname`.
375
- * @param doctype - The doctype to check
376
- * @param recordId - The record ID
377
- * @returns Object with `ready: true` if all blocked links are loaded, or `ready: false` with `blockedLinks` array
378
- */
379
- isWorkflowReady(doctype: Doctype, recordId: string): {
380
- ready: boolean;
381
- blockedLinks?: string[];
382
- };
383
- /**
384
- * Fetch a doctype's records from the server and store them in HST.
385
- *
386
- * This is the one read path for a list. Every caller shares its keying rule, so a row is
387
- * always stored under the identity its Edit link will later ask for.
388
- *
389
- * Deliberately unguarded, unlike {@link Stonecrop.getRecord}: a list is a view of data that
390
- * changes, so revisiting one must re-read it rather than serve whatever HST happens to hold.
391
- *
392
- * `options` is forwarded to the client untouched — no row limit is invented here, because
393
- * nothing on this side of the wire knows what is safe for an arbitrary backend. A caller that
394
- * passes none gets whatever the server considers a reasonable page.
395
- *
396
- * `options.offset === 0` (or omitted) replaces the doctype's HST records; `offset > 0` appends.
397
- *
398
- * @param doctype - The doctype
399
- * @param options - Query options (filters, orderBy, limit, offset), forwarded to the client
400
- * @throws Error if no data client has been configured
401
- * @public
402
- */
403
- getRecords(doctype: Doctype, options?: GetRecordsOptions): Promise<GetRecordsResult>;
404
- /**
405
- * What the last {@link Stonecrop.getRecords} for this doctype returned about the wider set.
406
- *
407
- * Answers the question HST cannot: HST holds what was fetched, so counting its keys reports
408
- * how much has been seen, never how much exists. Reactive, so a view reading it re-renders
409
- * when a fetch lands.
410
- *
411
- * @param doctype - The doctype slug string or Doctype object
412
- * @returns Page info, or undefined if this doctype's records have not been fetched
413
- * @public
414
- */
415
- getPageInfo(doctype: string | Doctype): PageInfo | undefined;
416
- /**
417
- * Fetch a single record from the server and store it in HST.
418
- *
419
- * This is the one read path for a record, and it owns the whole job: deciding whether a fetch
420
- * is warranted, performing it, and writing the result back under the doctype's declared
421
- * identity. Callers ask for a record and get one; they do not re-derive when to ask.
422
- *
423
- * Two cases return without touching the network, because in both the answer is already known:
424
- * a draft does not exist on the server yet, and a record already in HST has been read.
425
- * Refetching the latter would also discard unsaved edits sitting in the store.
426
- *
427
- * @param doctype - The doctype slug string or Doctype object
428
- * @param recordId - The record ID
429
- * @param options - Query options (includeNested, maxDepth), forwarded to the client
430
- * @throws Error if no data client has been configured
431
- * @throws Error if a slug string is given and no matching doctype is found in the registry
432
- * @public
433
- */
434
- getRecord(doctype: string | Doctype, recordId: string, options?: GetRecordOptions): Promise<void>;
435
- /**
436
- * Dispatch an action to the server via the configured data client, and file the record it
437
- * returns into HST under the identity the *server* settled on.
438
- *
439
- * The write is the point. For a created record the settled identity is never the one that was
440
- * dispatched, so a caller that stores the result under the id it sent files the record under a
441
- * key nothing can fetch and leaves the next save creating a second one. Every host that
442
- * hand-rolled this got it wrong the same way, so it stops being the caller's job — this is the
443
- * write-side twin of {@link Stonecrop.getRecords}, which keys reads by the same rule.
444
- *
445
- * Two things are deliberately NOT done here, because both need the id that was dispatched and
446
- * that lives inside `args` — an opaque array whose shape is a convention between a host's
447
- * client and its server handlers, not something this layer may parse. Dropping the stale key
448
- * and moving the route therefore stay with `useClientAction`, which knows both ids.
449
- *
450
- * A result that states no identity of its own — a `{ state: 'APPROVED' }` outcome — is left
451
- * alone rather than guessed at, for the same reason `settledRecordId` is strict: a partial
452
- * record must not be able to look like a rename.
453
- *
454
- * @param doctype - The doctype
455
- * @param action - Action name to execute (e.g., 'SUBMIT', 'APPROVE', 'save')
456
- * @param args - Action arguments (typically record ID and/or form data)
457
- * @returns Action result with success status, response data, and any error
458
- * @throws Error if no data client has been configured
459
- */
460
- dispatchAction(doctype: Doctype, action: string, args?: unknown[]): Promise<{
461
- success: boolean;
462
- data: unknown;
463
- error: string | null;
464
- }>;
465
- /**
466
- * Ensure doctype section exists in HST store
467
- * @param slug - The doctype slug
468
- */
469
- private ensureDoctypeExists;
470
- /**
471
- * Get doctype metadata from the registry
472
- * @param context - The route context
473
- * @returns The doctype metadata
474
- */
475
- getMeta(context: RouteContext): Promise<any>;
476
- /**
477
- * Get the root HST store node for advanced usage
478
- * @returns Root HST node
479
- */
480
- getStore(): HSTNode;
481
- /**
482
- * Determine the current workflow state for a record.
483
- *
484
- * Reads the record's `status` field from the HST store. If the field is absent or
485
- * empty the doctype's declared `workflow.initial` state is used as the fallback,
486
- * giving callers a reliable state name without having to duplicate that logic.
487
- *
488
- * @param doctype - The doctype slug or Doctype instance
489
- * @param recordId - The record identifier
490
- * @returns The current state name, or an empty string if the doctype has no workflow
491
- *
492
- * @public
493
- */
494
- getRecordState(doctype: string | Doctype, recordId: string): string;
495
- /**
496
- * Collect a record payload with all nested doctype fields from HST
497
- * @param doctype - The doctype metadata
498
- * @param recordId - The record ID to collect
499
- * @returns The complete record payload ready for API submission
500
- * @public
501
- */
502
- collectRecordPayload(doctype: Doctype, recordId: string): Record<string, any>;
503
- /**
504
- * Scaffold empty descendant records from defaults for all descendant links.
505
- *
506
- * Initializes all scalar and link fields at their HST paths with default values.
507
- * For new records, call this after setting up the doctype to ensure all paths exist.
508
- *
509
- * @param path - HST path (e.g., "customer.new")
510
- * @param doctype - The doctype to initialize
511
- * @public
512
- */
513
- initializeNestedData(path: string, doctype: Doctype): void;
514
- /**
515
- * Fetch a record and its nested data from the server.
516
- *
517
- * Calls `_client.getRecord()` with nested sub-selections and stores each scalar field at its own HST path
518
- * (`slug.recordId.fieldname`), descendants at the link-level path (`slug.recordId.linkname`).
519
- *
520
- * @param path - HST path (e.g., "recipe.r1")
521
- * @param doctype - The doctype to fetch
522
- * @param recordId - Record ID to fetch
523
- * @param options - Query options (includeNested to control which links are fetched)
524
- * @throws Error with code `"CLIENT_REQUIRED"` if no data client is configured
525
- * @throws Error with code `"RECORD_NOT_FOUND"` if the server returns null
526
- * @public
527
- */
528
- fetchNestedData(path: string, doctype: Doctype, recordId: string, options?: {
529
- includeNested?: boolean | string[];
530
- }): Promise<void>;
531
- /**
532
- * Recursively collect nested data from HST
533
- * @param basePath - The base path in HST (e.g., "customer.123.address")
534
- * @param doctype - The doctype whose links drive the recursive traversal
535
- * @returns The collected data object
536
- */
537
- private collectNestedData;
538
- }
539
- //# sourceMappingURL=stonecrop.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stonecrop.d.ts","sourceRoot":"","sources":["../../src/stonecrop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAG1G,OAAO,OAAO,MAAM,WAAW,CAAA;AAE/B,OAAO,QAAQ,MAAM,YAAY,CAAA;AACjC,OAAO,EAAa,KAAK,OAAO,EAAE,MAAM,cAAc,CAAA;AAEtD,OAAO,KAAK,EA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