@stonecrop/stonecrop 0.16.4 → 0.16.5
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/doctype.d.ts +13 -0
- package/dist/src/doctype.d.ts.map +1 -1
- package/dist/src/doctype.js +16 -1
- package/dist/src/stonecrop.d.ts.map +1 -1
- package/dist/src/stonecrop.js +7 -6
- package/dist/stonecrop.d.ts +13 -0
- package/dist/stonecrop.js +149 -133
- package/dist/stonecrop.js.map +1 -1
- package/package.json +4 -4
- package/src/doctype.ts +17 -1
- package/src/stonecrop.ts +7 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stonecrop/stonecrop",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.5",
|
|
4
4
|
"description": "Schema-driven framework with XState workflows and HST state management",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/agritheory/stonecrop/issues"
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"immutable": "^5.1.4",
|
|
35
35
|
"pinia-shared-state": "^1.0.1",
|
|
36
36
|
"xstate": "^5.25.0",
|
|
37
|
-
"@stonecrop/aform": "0.16.
|
|
38
|
-
"@stonecrop/
|
|
39
|
-
"@stonecrop/
|
|
37
|
+
"@stonecrop/aform": "0.16.5",
|
|
38
|
+
"@stonecrop/atable": "0.16.5",
|
|
39
|
+
"@stonecrop/schema": "0.16.5"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@microsoft/api-documenter": "^7.30.5",
|
package/src/doctype.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DoctypeField, LinkDeclaration, TriggerDefinition, WorkflowMeta } from '@stonecrop/schema'
|
|
2
|
-
import { isActionAllowedInState, normalizeFieldKind } from '@stonecrop/schema'
|
|
2
|
+
import { getRecordIdentity, isActionAllowedInState, normalizeFieldKind } from '@stonecrop/schema'
|
|
3
3
|
import { List, Map } from 'immutable'
|
|
4
4
|
import { Component } from 'vue'
|
|
5
5
|
|
|
@@ -157,6 +157,22 @@ export default class Doctype {
|
|
|
157
157
|
return this.schema.toArray()
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
+
/**
|
|
161
|
+
* Resolve a record's identity using this doctype's declared `primaryKey`, falling back to `id`.
|
|
162
|
+
*
|
|
163
|
+
* Lives here rather than at the call site because the doctype owns its schema — and because the
|
|
164
|
+
* rule must match the server's, which builds its SQL identity predicate from the same declared
|
|
165
|
+
* field via `@stonecrop/schema`'s `getPrimaryKeyField`.
|
|
166
|
+
*
|
|
167
|
+
* @param record - the record to read the identity from
|
|
168
|
+
* @returns the identity as a string, or `undefined` when neither the declared key nor `id` yields one
|
|
169
|
+
*
|
|
170
|
+
* @public
|
|
171
|
+
*/
|
|
172
|
+
getRecordId(record: Record<string, unknown>): string | undefined {
|
|
173
|
+
return getRecordIdentity(this.getSchemaArray(), record)
|
|
174
|
+
}
|
|
175
|
+
|
|
160
176
|
/**
|
|
161
177
|
* Returns the actions as a plain object for use with components that expect
|
|
162
178
|
* plain JavaScript objects.
|
package/src/stonecrop.ts
CHANGED
|
@@ -368,12 +368,14 @@ export class Stonecrop {
|
|
|
368
368
|
|
|
369
369
|
const records = await this._client.getRecords(doctype)
|
|
370
370
|
|
|
371
|
-
//
|
|
371
|
+
// Key each record by its declared primary key, falling back to `id`. This used to read
|
|
372
|
+
// `record.id` only, which silently dropped every row of a natural-keyed doctype (no `id`
|
|
373
|
+
// column at all) — the records never entered HST, so the list rendered empty and no
|
|
374
|
+
// downstream id-resolution could recover them.
|
|
372
375
|
records.forEach(record => {
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
this.addRecord(doctype, String(record.id), record)
|
|
376
|
+
const recordId = doctype.getRecordId(record)
|
|
377
|
+
if (recordId !== undefined) {
|
|
378
|
+
this.addRecord(doctype, recordId, record)
|
|
377
379
|
}
|
|
378
380
|
})
|
|
379
381
|
}
|