@stonecrop/stonecrop 0.38.1 → 0.39.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.
@@ -1,3 +1,4 @@
1
+ import { ActionDispatchResult } from '@stonecrop/schema';
1
2
  import type { AnyStateNodeConfig } from 'xstate';
2
3
  import { Component } from 'vue';
3
4
  import { ComputedRef } from 'vue';
@@ -38,17 +39,7 @@ export declare interface ActionArgsContext {
38
39
  extra?: Record<string, unknown>;
39
40
  }
40
41
 
41
- /**
42
- * Result of dispatching an action to its server handler.
43
- * @public
44
- */
45
- export declare type ActionDispatchResult = {
46
- success: boolean;
47
- data: unknown;
48
- error: string | null;
49
- /** The record as a read returns it after the action; null when it failed or targets no record. */
50
- record: Record<string, unknown> | null;
51
- };
42
+ export { ActionDispatchResult }
52
43
 
53
44
  /**
54
45
  * Payload emitted with the 'action' event when the user triggers a declared action —
@@ -1467,7 +1458,7 @@ export declare class Registry {
1467
1458
  * Narrows by `kind` discriminator for precise branch selection.
1468
1459
  *
1469
1460
  * - `kind: 'table'` or `kind: 'link'` → `[]` or `{}`
1470
- * - `kind: 'fieldset'` → recursively initializes children as `{}`
1461
+ * - `kind: 'fieldset'` → its children, at the top level of the record: a fieldset is layout
1471
1462
  * - `kind: 'field'` → derives the default from the component's category; falls back to `null`
1472
1463
  *
1473
1464
  * @param schema - The resolved schema array to derive defaults from
@@ -2041,7 +2032,7 @@ export declare class Stonecrop {
2041
2032
  * @param doctype - The doctype
2042
2033
  * @param action - Action name to execute (e.g., 'SUBMIT', 'APPROVE', 'save')
2043
2034
  * @param args - Action arguments (typically record ID and/or form data)
2044
- * @returns Action result with success status, the handler's data, any error, and the record
2035
+ * @returns Action result with success status, the handler's data, any error, the record, and the keys the write discarded
2045
2036
  * @throws Error if no data client has been configured
2046
2037
  */
2047
2038
  dispatchAction(doctype: Doctype, action: string, args?: unknown[]): Promise<ActionDispatchResult>;
package/dist/stonecrop.js CHANGED
@@ -1580,7 +1580,7 @@ var Stonecrop = class Stonecrop {
1580
1580
  * @param doctype - The doctype
1581
1581
  * @param action - Action name to execute (e.g., 'SUBMIT', 'APPROVE', 'save')
1582
1582
  * @param args - Action arguments (typically record ID and/or form data)
1583
- * @returns Action result with success status, the handler's data, any error, and the record
1583
+ * @returns Action result with success status, the handler's data, any error, the record, and the keys the write discarded
1584
1584
  * @throws Error if no data client has been configured
1585
1585
  */
1586
1586
  async dispatchAction(doctype, action, args) {
@@ -2983,7 +2983,7 @@ var Registry = class Registry {
2983
2983
  * Narrows by `kind` discriminator for precise branch selection.
2984
2984
  *
2985
2985
  * - `kind: 'table'` or `kind: 'link'` → `[]` or `{}`
2986
- * - `kind: 'fieldset'` → recursively initializes children as `{}`
2986
+ * - `kind: 'fieldset'` → its children, at the top level of the record: a fieldset is layout
2987
2987
  * - `kind: 'field'` → derives the default from the component's category; falls back to `null`
2988
2988
  *
2989
2989
  * @param schema - The resolved schema array to derive defaults from
@@ -2994,7 +2994,7 @@ var Registry = class Registry {
2994
2994
  const record = {};
2995
2995
  for (const field of schema) if (field.kind === "table") record[field.fieldname] = [];
2996
2996
  else if (field.kind === "link") record[field.fieldname] = this.initializeRecord(field.schema);
2997
- else if (field.kind === "fieldset") record[field.fieldname] = this.initializeRecord(field.schema);
2997
+ else if (field.kind === "fieldset") Object.assign(record, this.initializeRecord(field.schema));
2998
2998
  else {
2999
2999
  const fieldDefault = field.default;
3000
3000
  if (fieldDefault !== void 0) record[field.fieldname] = fieldDefault;