@stonecrop/stonecrop 0.12.1 → 0.12.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/stonecrop.d.ts +3 -2
- package/dist/src/stonecrop.d.ts.map +1 -1
- package/dist/src/stonecrop.js +12 -7
- package/dist/stonecrop.d.ts +3 -2
- package/dist/stonecrop.js +175 -171
- package/dist/stonecrop.js.map +1 -1
- package/package.json +4 -4
- package/src/stonecrop.ts +14 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stonecrop/stonecrop",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"pinia-shared-state": "^1.0.1",
|
|
35
35
|
"pinia-xstate": "^3.0.0",
|
|
36
36
|
"xstate": "^5.25.0",
|
|
37
|
-
"@stonecrop/schema": "0.12.
|
|
37
|
+
"@stonecrop/schema": "0.12.3"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"pinia": "^3.0.4",
|
|
@@ -60,8 +60,8 @@
|
|
|
60
60
|
"vue-router": "^5.0.6",
|
|
61
61
|
"vite": "^7.3.2",
|
|
62
62
|
"vitest": "^4.1.5",
|
|
63
|
-
"@stonecrop/aform": "0.12.
|
|
64
|
-
"@stonecrop/atable": "0.12.
|
|
63
|
+
"@stonecrop/aform": "0.12.3",
|
|
64
|
+
"@stonecrop/atable": "0.12.3",
|
|
65
65
|
"stonecrop-rig": "0.7.0"
|
|
66
66
|
},
|
|
67
67
|
"description": "Schema-driven framework with XState workflows and HST state management",
|
package/src/stonecrop.ts
CHANGED
|
@@ -378,11 +378,12 @@ export class Stonecrop {
|
|
|
378
378
|
|
|
379
379
|
/**
|
|
380
380
|
* Get single record from server using the configured data client.
|
|
381
|
-
* @param doctype - The doctype
|
|
381
|
+
* @param doctype - The doctype slug string or Doctype object
|
|
382
382
|
* @param recordId - The record ID
|
|
383
383
|
* @throws Error if no data client has been configured
|
|
384
|
+
* @throws Error if a slug string is given and no matching doctype is found in the registry
|
|
384
385
|
*/
|
|
385
|
-
async getRecord(doctype: Doctype, recordId: string): Promise<void> {
|
|
386
|
+
async getRecord(doctype: string | Doctype, recordId: string): Promise<void> {
|
|
386
387
|
if (!this._client) {
|
|
387
388
|
throw new Error(
|
|
388
389
|
'No data client configured. Call setClient() with a DataClient implementation ' +
|
|
@@ -390,10 +391,15 @@ export class Stonecrop {
|
|
|
390
391
|
)
|
|
391
392
|
}
|
|
392
393
|
|
|
393
|
-
const
|
|
394
|
+
const resolved = typeof doctype === 'string' ? this.registry.getDoctype(doctype) : doctype
|
|
395
|
+
if (!resolved) {
|
|
396
|
+
throw new Error(`Doctype not found: ${typeof doctype === 'string' ? doctype : doctype.slug}`)
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
const result = await this._client.getRecord(resolved, recordId)
|
|
394
400
|
|
|
395
|
-
if (record) {
|
|
396
|
-
this.addRecord(
|
|
401
|
+
if (result?.record) {
|
|
402
|
+
this.addRecord(resolved, recordId, result.record)
|
|
397
403
|
}
|
|
398
404
|
}
|
|
399
405
|
|
|
@@ -587,11 +593,11 @@ export class Stonecrop {
|
|
|
587
593
|
)
|
|
588
594
|
}
|
|
589
595
|
|
|
590
|
-
const
|
|
596
|
+
const result = await this._client.getRecord({ name: doctype.doctype }, recordId, {
|
|
591
597
|
includeNested: options?.includeNested ?? true,
|
|
592
598
|
})
|
|
593
599
|
|
|
594
|
-
if (!record) {
|
|
600
|
+
if (!result?.record) {
|
|
595
601
|
throw createCodedError(`Record not found: ${doctype.doctype} ${recordId}`, 'RECORD_NOT_FOUND')
|
|
596
602
|
}
|
|
597
603
|
|
|
@@ -605,7 +611,7 @@ export class Stonecrop {
|
|
|
605
611
|
this.hstStore.set(`${slug}.${recordId}`, {}, 'system')
|
|
606
612
|
}
|
|
607
613
|
|
|
608
|
-
for (const [key, value] of Object.entries(record)) {
|
|
614
|
+
for (const [key, value] of Object.entries(result.record)) {
|
|
609
615
|
this.hstStore.set(`${slug}.${recordId}.${key}`, value, 'system')
|
|
610
616
|
}
|
|
611
617
|
}
|