@stonecrop/stonecrop 0.10.15 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +72 -29
- package/dist/composable.js +1 -0
- package/dist/composables/lazy-link.js +125 -0
- package/dist/composables/stonecrop.js +123 -68
- package/dist/composables/use-lazy-link-state.js +125 -0
- package/dist/composables/use-stonecrop.js +476 -0
- package/dist/doctype.js +10 -2
- package/dist/field-triggers.js +15 -3
- package/dist/index.js +4 -3
- package/dist/operation-log-DB-dGNT9.js +593 -0
- package/dist/operation-log-DB-dGNT9.js.map +1 -0
- package/dist/registry.js +261 -101
- package/dist/schema-validator.js +105 -1
- package/dist/src/composable.d.ts +11 -0
- package/dist/src/composable.d.ts.map +1 -0
- package/dist/src/composable.js +477 -0
- package/dist/src/composables/lazy-link.d.ts +25 -0
- package/dist/src/composables/lazy-link.d.ts.map +1 -0
- package/dist/src/composables/operation-log.d.ts +5 -5
- package/dist/src/composables/operation-log.d.ts.map +1 -1
- package/dist/src/composables/operation-log.js +224 -0
- package/dist/src/composables/stonecrop.d.ts +11 -1
- package/dist/src/composables/stonecrop.d.ts.map +1 -1
- package/dist/src/composables/stonecrop.js +574 -0
- package/dist/src/composables/use-lazy-link-state.d.ts +25 -0
- package/dist/src/composables/use-lazy-link-state.d.ts.map +1 -0
- package/dist/src/composables/use-stonecrop.d.ts +93 -0
- package/dist/src/composables/use-stonecrop.d.ts.map +1 -0
- package/dist/src/composables/useNestedSchema.d.ts +110 -0
- package/dist/src/composables/useNestedSchema.d.ts.map +1 -0
- package/dist/src/composables/useNestedSchema.js +155 -0
- package/dist/src/doctype.d.ts +9 -1
- package/dist/src/doctype.d.ts.map +1 -1
- package/dist/src/doctype.js +234 -0
- package/dist/src/exceptions.js +16 -0
- package/dist/src/field-triggers.d.ts +6 -0
- package/dist/src/field-triggers.d.ts.map +1 -1
- package/dist/src/field-triggers.js +567 -0
- package/dist/src/index.d.ts +3 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +23 -0
- package/dist/src/plugins/index.js +96 -0
- package/dist/src/registry.d.ts +102 -23
- package/dist/src/registry.d.ts.map +1 -1
- package/dist/src/registry.js +246 -0
- package/dist/src/schema-validator.d.ts +8 -1
- package/dist/src/schema-validator.d.ts.map +1 -1
- package/dist/src/schema-validator.js +315 -0
- package/dist/src/stonecrop.d.ts +73 -28
- package/dist/src/stonecrop.d.ts.map +1 -1
- package/dist/src/stonecrop.js +339 -0
- package/dist/src/stores/data.d.ts +11 -0
- package/dist/src/stores/data.d.ts.map +1 -0
- package/dist/src/stores/hst.d.ts +5 -75
- package/dist/src/stores/hst.d.ts.map +1 -1
- package/dist/src/stores/hst.js +495 -0
- package/dist/src/stores/index.js +12 -0
- package/dist/src/stores/operation-log.d.ts +14 -14
- package/dist/src/stores/operation-log.d.ts.map +1 -1
- package/dist/src/stores/operation-log.js +568 -0
- package/dist/src/stores/xstate.d.ts +31 -0
- package/dist/src/stores/xstate.d.ts.map +1 -0
- package/dist/src/tsdoc-metadata.json +11 -0
- package/dist/src/types/composable.d.ts +50 -12
- package/dist/src/types/composable.d.ts.map +1 -1
- package/dist/src/types/doctype.d.ts +6 -7
- package/dist/src/types/doctype.d.ts.map +1 -1
- package/dist/src/types/field-triggers.d.ts +1 -1
- package/dist/src/types/field-triggers.d.ts.map +1 -1
- package/dist/src/types/field-triggers.js +4 -0
- package/dist/src/types/hst.d.ts +70 -0
- package/dist/src/types/hst.d.ts.map +1 -0
- package/dist/src/types/index.d.ts +1 -0
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/types/index.js +4 -0
- package/dist/src/types/operation-log.d.ts +4 -4
- package/dist/src/types/operation-log.d.ts.map +1 -1
- package/dist/src/types/operation-log.js +0 -0
- package/dist/src/types/registry.js +0 -0
- package/dist/src/types/schema-validator.d.ts +2 -0
- package/dist/src/types/schema-validator.d.ts.map +1 -1
- package/dist/src/utils.d.ts +24 -0
- package/dist/src/utils.d.ts.map +1 -0
- package/dist/stonecrop.d.ts +317 -99
- package/dist/stonecrop.js +2191 -1897
- package/dist/stonecrop.js.map +1 -1
- package/dist/stonecrop.umd.cjs +6 -0
- package/dist/stonecrop.umd.cjs.map +1 -0
- package/dist/stores/data.js +7 -0
- package/dist/stores/hst.js +27 -25
- package/dist/stores/operation-log.js +59 -47
- package/dist/stores/xstate.js +29 -0
- package/dist/tests/setup.d.ts +5 -0
- package/dist/tests/setup.d.ts.map +1 -0
- package/dist/tests/setup.js +15 -0
- package/dist/types/hst.js +0 -0
- package/dist/types/index.js +1 -0
- package/dist/utils.js +46 -0
- package/package.json +4 -4
- package/src/composables/lazy-link.ts +146 -0
- package/src/composables/operation-log.ts +1 -1
- package/src/composables/stonecrop.ts +142 -73
- package/src/doctype.ts +13 -4
- package/src/field-triggers.ts +18 -4
- package/src/index.ts +4 -2
- package/src/registry.ts +289 -111
- package/src/schema-validator.ts +120 -1
- package/src/stonecrop.ts +230 -106
- package/src/stores/hst.ts +29 -104
- package/src/stores/operation-log.ts +64 -50
- package/src/types/composable.ts +55 -12
- package/src/types/doctype.ts +6 -7
- package/src/types/field-triggers.ts +1 -1
- package/src/types/hst.ts +77 -0
- package/src/types/index.ts +1 -0
- package/src/types/operation-log.ts +4 -4
- package/src/types/schema-validator.ts +2 -0
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
import { reactive } from 'vue';
|
|
2
|
+
import { createHST } from './stores/hst';
|
|
3
|
+
import { useOperationLogStore } from './stores/operation-log';
|
|
4
|
+
/**
|
|
5
|
+
* Main Stonecrop class with HST integration and built-in Operation Log
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export class Stonecrop {
|
|
9
|
+
_hstStore;
|
|
10
|
+
_operationLogStore;
|
|
11
|
+
_operationLogConfig;
|
|
12
|
+
_client;
|
|
13
|
+
/** The registry instance containing all doctype definitions */
|
|
14
|
+
registry;
|
|
15
|
+
get hstStore() {
|
|
16
|
+
if (!this._hstStore) {
|
|
17
|
+
const initialStoreStructure = {};
|
|
18
|
+
Object.keys(this.registry.registry).forEach(doctypeSlug => {
|
|
19
|
+
initialStoreStructure[doctypeSlug] = {};
|
|
20
|
+
});
|
|
21
|
+
this._hstStore = createHST(reactive(initialStoreStructure), 'StonecropStore');
|
|
22
|
+
}
|
|
23
|
+
return this._hstStore;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Creates a new Stonecrop instance with HST integration
|
|
27
|
+
* @param registry - The Registry instance containing doctype definitions
|
|
28
|
+
* @param operationLogConfig - Optional configuration for the operation log
|
|
29
|
+
* @param options - Options including the data client (can be set later via setClient)
|
|
30
|
+
*/
|
|
31
|
+
constructor(registry, operationLogConfig, options) {
|
|
32
|
+
this.registry = registry;
|
|
33
|
+
// Store config for lazy initialization
|
|
34
|
+
this._operationLogConfig = operationLogConfig;
|
|
35
|
+
// Store data client (can be set later via setClient)
|
|
36
|
+
this._client = options?.client;
|
|
37
|
+
// Setup automatic sync with Registry when doctypes are added
|
|
38
|
+
this.setupRegistrySync();
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Set the data client for fetching doctype metadata and records.
|
|
42
|
+
* Use this for deferred configuration in Nuxt/Vue plugin setups.
|
|
43
|
+
*
|
|
44
|
+
* @param client - DataClient implementation (e.g., StonecropClient from \@stonecrop/graphql-client)
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* const { setClient } = useStonecropRegistry()
|
|
49
|
+
* const client = new StonecropClient({ endpoint: '/graphql' })
|
|
50
|
+
* setClient(client)
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
setClient(client) {
|
|
54
|
+
this._client = client;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Get the current data client
|
|
58
|
+
* @returns The DataClient instance or undefined if not set
|
|
59
|
+
*/
|
|
60
|
+
getClient() {
|
|
61
|
+
return this._client;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Get the operation log store (lazy initialization)
|
|
65
|
+
* @internal
|
|
66
|
+
*/
|
|
67
|
+
getOperationLogStore() {
|
|
68
|
+
if (!this._operationLogStore) {
|
|
69
|
+
this._operationLogStore = useOperationLogStore();
|
|
70
|
+
if (this._operationLogConfig) {
|
|
71
|
+
this._operationLogStore.configure(this._operationLogConfig);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return this._operationLogStore;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Setup automatic sync with Registry when doctypes are added
|
|
78
|
+
*/
|
|
79
|
+
setupRegistrySync() {
|
|
80
|
+
// Extend Registry.addDoctype to auto-create HST store sections
|
|
81
|
+
const originalAddDoctype = this.registry.addDoctype.bind(this.registry);
|
|
82
|
+
this.registry.addDoctype = (doctype) => {
|
|
83
|
+
// Call original method
|
|
84
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
85
|
+
originalAddDoctype(doctype);
|
|
86
|
+
// Auto-create HST store section for new doctype
|
|
87
|
+
if (!this.hstStore.has(doctype.slug)) {
|
|
88
|
+
this.hstStore.set(doctype.slug, {});
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Get records hash for a doctype
|
|
94
|
+
* @param doctype - The doctype to get records for
|
|
95
|
+
* @returns HST node containing records hash
|
|
96
|
+
*/
|
|
97
|
+
records(doctype) {
|
|
98
|
+
const slug = typeof doctype === 'string' ? doctype : doctype.slug;
|
|
99
|
+
this.ensureDoctypeExists(slug);
|
|
100
|
+
return this.hstStore.getNode(slug);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Add a record to the store
|
|
104
|
+
* @param doctype - The doctype
|
|
105
|
+
* @param recordId - The record ID
|
|
106
|
+
* @param recordData - The record data
|
|
107
|
+
*/
|
|
108
|
+
addRecord(doctype, recordId, recordData) {
|
|
109
|
+
const slug = typeof doctype === 'string' ? doctype : doctype.slug;
|
|
110
|
+
this.ensureDoctypeExists(slug);
|
|
111
|
+
// Store raw record data - let HST handle wrapping with proper hierarchy
|
|
112
|
+
this.hstStore.set(`${slug}.${recordId}`, recordData);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Get a specific record
|
|
116
|
+
* @param doctype - The doctype
|
|
117
|
+
* @param recordId - The record ID
|
|
118
|
+
* @returns HST node for the record or undefined
|
|
119
|
+
*/
|
|
120
|
+
getRecordById(doctype, recordId) {
|
|
121
|
+
const slug = typeof doctype === 'string' ? doctype : doctype.slug;
|
|
122
|
+
this.ensureDoctypeExists(slug);
|
|
123
|
+
// First check if the record exists
|
|
124
|
+
const recordExists = this.hstStore.has(`${slug}.${recordId}`);
|
|
125
|
+
if (!recordExists) {
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
// Check if the actual value is undefined (i.e., record was removed)
|
|
129
|
+
const recordValue = this.hstStore.get(`${slug}.${recordId}`);
|
|
130
|
+
if (recordValue === undefined) {
|
|
131
|
+
return undefined;
|
|
132
|
+
}
|
|
133
|
+
// Use getNode to get the properly wrapped HST node with correct parent relationships
|
|
134
|
+
return this.hstStore.getNode(`${slug}.${recordId}`);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Remove a record from the store
|
|
138
|
+
* @param doctype - The doctype
|
|
139
|
+
* @param recordId - The record ID
|
|
140
|
+
*/
|
|
141
|
+
removeRecord(doctype, recordId) {
|
|
142
|
+
const slug = typeof doctype === 'string' ? doctype : doctype.slug;
|
|
143
|
+
this.ensureDoctypeExists(slug);
|
|
144
|
+
// Remove the specific record directly by setting to undefined
|
|
145
|
+
if (this.hstStore.has(`${slug}.${recordId}`)) {
|
|
146
|
+
this.hstStore.set(`${slug}.${recordId}`, undefined);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Get all record IDs for a doctype
|
|
151
|
+
* @param doctype - The doctype
|
|
152
|
+
* @returns Array of record IDs
|
|
153
|
+
*/
|
|
154
|
+
getRecordIds(doctype) {
|
|
155
|
+
const slug = typeof doctype === 'string' ? doctype : doctype.slug;
|
|
156
|
+
this.ensureDoctypeExists(slug);
|
|
157
|
+
const doctypeNode = this.hstStore.get(slug);
|
|
158
|
+
if (!doctypeNode || typeof doctypeNode !== 'object') {
|
|
159
|
+
return [];
|
|
160
|
+
}
|
|
161
|
+
return Object.keys(doctypeNode).filter(key => doctypeNode[key] !== undefined);
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Clear all records for a doctype
|
|
165
|
+
* @param doctype - The doctype
|
|
166
|
+
*/
|
|
167
|
+
clearRecords(doctype) {
|
|
168
|
+
const slug = typeof doctype === 'string' ? doctype : doctype.slug;
|
|
169
|
+
this.ensureDoctypeExists(slug);
|
|
170
|
+
// Get all record IDs and remove them
|
|
171
|
+
const recordIds = this.getRecordIds(slug);
|
|
172
|
+
recordIds.forEach(recordId => {
|
|
173
|
+
this.hstStore.set(`${slug}.${recordId}`, undefined);
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Setup method for doctype initialization
|
|
178
|
+
* @param doctype - The doctype to setup
|
|
179
|
+
*/
|
|
180
|
+
setup(doctype) {
|
|
181
|
+
// Ensure doctype exists in store
|
|
182
|
+
this.ensureDoctypeExists(doctype.slug);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Run action on doctype
|
|
186
|
+
* Executes the action and logs it to the operation log for audit tracking
|
|
187
|
+
* @param doctype - The doctype
|
|
188
|
+
* @param action - The action to run
|
|
189
|
+
* @param args - Action arguments (typically record IDs)
|
|
190
|
+
*/
|
|
191
|
+
runAction(doctype, action, args) {
|
|
192
|
+
const registry = this.registry.registry[doctype.slug];
|
|
193
|
+
const actions = registry?.actions?.get(action);
|
|
194
|
+
const recordIds = Array.isArray(args) ? args.filter((arg) => typeof arg === 'string') : undefined;
|
|
195
|
+
// Log action execution start
|
|
196
|
+
const opLogStore = this.getOperationLogStore();
|
|
197
|
+
let actionResult = 'success';
|
|
198
|
+
let actionError;
|
|
199
|
+
try {
|
|
200
|
+
// Execute action functions
|
|
201
|
+
if (actions && actions.length > 0) {
|
|
202
|
+
actions.forEach(actionStr => {
|
|
203
|
+
try {
|
|
204
|
+
// eslint-disable-next-line @typescript-eslint/no-implied-eval
|
|
205
|
+
const actionFn = new Function('args', actionStr);
|
|
206
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
207
|
+
actionFn(args);
|
|
208
|
+
}
|
|
209
|
+
catch (error) {
|
|
210
|
+
actionResult = 'failure';
|
|
211
|
+
actionError = error instanceof Error ? error.message : 'Unknown error';
|
|
212
|
+
throw error;
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
catch {
|
|
218
|
+
// Error already set in inner catch
|
|
219
|
+
}
|
|
220
|
+
finally {
|
|
221
|
+
// Log the action execution to operation log
|
|
222
|
+
opLogStore.logAction(doctype.doctype, action, recordIds, actionResult, actionError);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Get records from server using the configured data client.
|
|
227
|
+
* @param doctype - The doctype
|
|
228
|
+
* @throws Error if no data client has been configured
|
|
229
|
+
*/
|
|
230
|
+
async getRecords(doctype) {
|
|
231
|
+
if (!this._client) {
|
|
232
|
+
throw new Error('No data client configured. Call setClient() with a DataClient implementation ' +
|
|
233
|
+
'(e.g., StonecropClient from @stonecrop/graphql-client) before fetching records.');
|
|
234
|
+
}
|
|
235
|
+
const records = await this._client.getRecords(doctype);
|
|
236
|
+
// Store each record in HST
|
|
237
|
+
records.forEach(record => {
|
|
238
|
+
if (record.id) {
|
|
239
|
+
this.addRecord(doctype, record.id, record);
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Get single record from server using the configured data client.
|
|
245
|
+
* @param doctype - The doctype
|
|
246
|
+
* @param recordId - The record ID
|
|
247
|
+
* @throws Error if no data client has been configured
|
|
248
|
+
*/
|
|
249
|
+
async getRecord(doctype, recordId) {
|
|
250
|
+
if (!this._client) {
|
|
251
|
+
throw new Error('No data client configured. Call setClient() with a DataClient implementation ' +
|
|
252
|
+
'(e.g., StonecropClient from @stonecrop/graphql-client) before fetching records.');
|
|
253
|
+
}
|
|
254
|
+
const record = await this._client.getRecord(doctype, recordId);
|
|
255
|
+
if (record) {
|
|
256
|
+
this.addRecord(doctype, recordId, record);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Dispatch an action to the server via the configured data client.
|
|
261
|
+
* All state changes flow through this single mutation endpoint.
|
|
262
|
+
*
|
|
263
|
+
* @param doctype - The doctype
|
|
264
|
+
* @param action - Action name to execute (e.g., 'SUBMIT', 'APPROVE', 'save')
|
|
265
|
+
* @param args - Action arguments (typically record ID and/or form data)
|
|
266
|
+
* @returns Action result with success status, response data, and any error
|
|
267
|
+
* @throws Error if no data client has been configured
|
|
268
|
+
*/
|
|
269
|
+
async dispatchAction(doctype, action, args) {
|
|
270
|
+
if (!this._client) {
|
|
271
|
+
throw new Error('No data client configured. Call setClient() with a DataClient implementation ' +
|
|
272
|
+
'(e.g., StonecropClient from @stonecrop/graphql-client) before dispatching actions.');
|
|
273
|
+
}
|
|
274
|
+
return this._client.runAction(doctype, action, args);
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Ensure doctype section exists in HST store
|
|
278
|
+
* @param slug - The doctype slug
|
|
279
|
+
*/
|
|
280
|
+
ensureDoctypeExists(slug) {
|
|
281
|
+
if (!this.hstStore.has(slug)) {
|
|
282
|
+
this.hstStore.set(slug, {});
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Get doctype metadata from the registry
|
|
287
|
+
* @param context - The route context
|
|
288
|
+
* @returns The doctype metadata
|
|
289
|
+
*/
|
|
290
|
+
async getMeta(context) {
|
|
291
|
+
if (!this.registry.getMeta) {
|
|
292
|
+
throw new Error('No getMeta function provided to Registry');
|
|
293
|
+
}
|
|
294
|
+
return await this.registry.getMeta(context);
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Get the root HST store node for advanced usage
|
|
298
|
+
* @returns Root HST node
|
|
299
|
+
*/
|
|
300
|
+
getStore() {
|
|
301
|
+
return this.hstStore;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Determine the current workflow state for a record.
|
|
305
|
+
*
|
|
306
|
+
* Reads the record's `status` field from the HST store. If the field is absent or
|
|
307
|
+
* empty the doctype's declared `workflow.initial` state is used as the fallback,
|
|
308
|
+
* giving callers a reliable state name without having to duplicate that logic.
|
|
309
|
+
*
|
|
310
|
+
* @param doctype - The doctype slug or Doctype instance
|
|
311
|
+
* @param recordId - The record identifier
|
|
312
|
+
* @returns The current state name, or an empty string if the doctype has no workflow
|
|
313
|
+
*
|
|
314
|
+
* @public
|
|
315
|
+
*/
|
|
316
|
+
getRecordState(doctype, recordId) {
|
|
317
|
+
const slug = typeof doctype === 'string' ? doctype : doctype.slug;
|
|
318
|
+
const meta = this.registry.getDoctype(slug);
|
|
319
|
+
if (!meta?.workflow)
|
|
320
|
+
return '';
|
|
321
|
+
const record = this.getRecordById(slug, recordId);
|
|
322
|
+
const status = record?.get('status');
|
|
323
|
+
// Handle both XState format and WorkflowMeta format
|
|
324
|
+
const workflow = meta.workflow;
|
|
325
|
+
let initialState;
|
|
326
|
+
if (Array.isArray(workflow.states)) {
|
|
327
|
+
// WorkflowMeta format: states is a string array
|
|
328
|
+
initialState = workflow.states[0] ?? '';
|
|
329
|
+
}
|
|
330
|
+
else {
|
|
331
|
+
// XState format: states is an object, use initial or first key
|
|
332
|
+
initialState =
|
|
333
|
+
typeof workflow.initial === 'string'
|
|
334
|
+
? workflow.initial
|
|
335
|
+
: Object.keys(workflow.states ?? {})[0] ?? '';
|
|
336
|
+
}
|
|
337
|
+
return status || initialState;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const useDataStore: import("pinia").StoreDefinition<"data", Pick<{
|
|
2
|
+
records: import("vue").Ref<Record<string, any>[], Record<string, any>[]>;
|
|
3
|
+
record: import("vue").Ref<Record<string, any>, Record<string, any>>;
|
|
4
|
+
}, "records" | "record">, Pick<{
|
|
5
|
+
records: import("vue").Ref<Record<string, any>[], Record<string, any>[]>;
|
|
6
|
+
record: import("vue").Ref<Record<string, any>, Record<string, any>>;
|
|
7
|
+
}, never>, Pick<{
|
|
8
|
+
records: import("vue").Ref<Record<string, any>[], Record<string, any>[]>;
|
|
9
|
+
record: import("vue").Ref<Record<string, any>, Record<string, any>>;
|
|
10
|
+
}, never>>;
|
|
11
|
+
//# sourceMappingURL=data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../src/stores/data.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,YAAY;;;;;;;;;UAIvB,CAAA"}
|
package/dist/src/stores/hst.d.ts
CHANGED
|
@@ -1,72 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Core HST Interface - enhanced with tree navigation
|
|
3
|
-
* Provides a hierarchical state tree interface for navigating and manipulating nested data structures.
|
|
4
|
-
*
|
|
5
|
-
* @public
|
|
6
|
-
*/
|
|
7
|
-
interface HSTNode {
|
|
8
|
-
/**
|
|
9
|
-
* Gets a value at the specified path
|
|
10
|
-
* @param path - The dot-separated path to the value
|
|
11
|
-
* @returns The value at the specified path
|
|
12
|
-
*/
|
|
13
|
-
get(path: string): any;
|
|
14
|
-
/**
|
|
15
|
-
* Sets a value at the specified path
|
|
16
|
-
* @param path - The dot-separated path where to set the value
|
|
17
|
-
* @param value - The value to set
|
|
18
|
-
* @param source - Optional source of the operation (user, system, sync, undo, redo)
|
|
19
|
-
*/
|
|
20
|
-
set(path: string, value: any, source?: 'user' | 'system' | 'sync' | 'undo' | 'redo'): void;
|
|
21
|
-
/**
|
|
22
|
-
* Checks if a value exists at the specified path
|
|
23
|
-
* @param path - The dot-separated path to check
|
|
24
|
-
* @returns True if the path exists, false otherwise
|
|
25
|
-
*/
|
|
26
|
-
has(path: string): boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Gets the parent node in the tree hierarchy
|
|
29
|
-
* @returns The parent HSTNode or null if this is the root
|
|
30
|
-
*/
|
|
31
|
-
getParent(): HSTNode | null;
|
|
32
|
-
/**
|
|
33
|
-
* Gets the root node of the tree
|
|
34
|
-
* @returns The root HSTNode
|
|
35
|
-
*/
|
|
36
|
-
getRoot(): HSTNode;
|
|
37
|
-
/**
|
|
38
|
-
* Gets the full path from root to this node
|
|
39
|
-
* @returns The dot-separated path string
|
|
40
|
-
*/
|
|
41
|
-
getPath(): string;
|
|
42
|
-
/**
|
|
43
|
-
* Gets the depth level of this node in the tree
|
|
44
|
-
* @returns The depth as a number (0 for root)
|
|
45
|
-
*/
|
|
46
|
-
getDepth(): number;
|
|
47
|
-
/**
|
|
48
|
-
* Gets an array of path segments from root to this node
|
|
49
|
-
* @returns Array of path segments representing breadcrumbs
|
|
50
|
-
*/
|
|
51
|
-
getBreadcrumbs(): string[];
|
|
52
|
-
/**
|
|
53
|
-
* Gets a child node at the specified relative path
|
|
54
|
-
* @param path - The relative path to the child node
|
|
55
|
-
* @returns The child HSTNode
|
|
56
|
-
*/
|
|
57
|
-
getNode(path: string): HSTNode;
|
|
58
|
-
/**
|
|
59
|
-
* Trigger an XState transition with optional context data
|
|
60
|
-
* @param transition - The transition name (should be uppercase per convention)
|
|
61
|
-
* @param context - Optional additional FSM context data
|
|
62
|
-
* @returns Promise resolving to the transition execution results
|
|
63
|
-
*/
|
|
64
|
-
triggerTransition(transition: string, context?: {
|
|
65
|
-
currentState?: string;
|
|
66
|
-
targetState?: string;
|
|
67
|
-
fsmContext?: Record<string, any>;
|
|
68
|
-
}): Promise<any>;
|
|
69
|
-
}
|
|
1
|
+
import type { HSTNode } from '../types/hst';
|
|
70
2
|
interface RegistryGlobal {
|
|
71
3
|
Registry?: {
|
|
72
4
|
_root?: {
|
|
@@ -106,17 +38,16 @@ declare class HST {
|
|
|
106
38
|
}
|
|
107
39
|
declare class HSTProxy implements HSTNode {
|
|
108
40
|
private target;
|
|
109
|
-
private
|
|
41
|
+
private ancestorPath;
|
|
110
42
|
private rootNode;
|
|
111
43
|
private doctype;
|
|
112
|
-
private parentDoctype?;
|
|
113
44
|
private hst;
|
|
114
|
-
constructor(target: any, doctype: string,
|
|
45
|
+
constructor(target: any, doctype: string, ancestorPath?: string, rootNode?: HSTNode | null);
|
|
115
46
|
get(path: string): any;
|
|
116
47
|
getNode(path: string): HSTNode;
|
|
117
48
|
set(path: string, value: any, source?: 'user' | 'system' | 'sync' | 'undo' | 'redo'): void;
|
|
118
49
|
has(path: string): boolean;
|
|
119
|
-
|
|
50
|
+
getAncestor(): HSTNode | null;
|
|
120
51
|
getRoot(): HSTNode;
|
|
121
52
|
getPath(): string;
|
|
122
53
|
getDepth(): number;
|
|
@@ -152,11 +83,10 @@ declare class HSTProxy implements HSTNode {
|
|
|
152
83
|
*
|
|
153
84
|
* @param target - The target object to wrap with HST functionality
|
|
154
85
|
* @param doctype - The document type identifier
|
|
155
|
-
* @param parentDoctype - Optional parent document type identifier
|
|
156
86
|
* @returns A new HSTNode proxy instance
|
|
157
87
|
*
|
|
158
88
|
* @public
|
|
159
89
|
*/
|
|
160
|
-
declare function createHST(target: any, doctype: string
|
|
90
|
+
declare function createHST(target: any, doctype: string): HSTNode;
|
|
161
91
|
export { HSTProxy, HST, createHST, type HSTNode };
|
|
162
92
|
//# sourceMappingURL=hst.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hst.d.ts","sourceRoot":"","sources":["../../../src/stores/hst.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hst.d.ts","sourceRoot":"","sources":["../../../src/stores/hst.ts"],"names":[],"mappings":"AAGA,OAAO,K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