@diphyx/harlemify 4.0.0 → 4.0.1

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/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.0.0 || >=4.0.0"
6
6
  },
7
- "version": "4.0.0",
7
+ "version": "4.0.1",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "0.8.4",
10
10
  "unbuild": "unknown"
@@ -9,6 +9,7 @@ export interface RuntimeActionConfig {
9
9
  concurrent?: ActionConcurrent;
10
10
  }
11
11
  export declare const DEFINITION: unique symbol;
12
+ export declare const AUTO: unique symbol;
12
13
  export declare enum ActionOneMode {
13
14
  SET = "set",
14
15
  RESET = "reset",
@@ -103,8 +104,8 @@ export interface ActionDefinition<M extends Model, V, R = void> {
103
104
  }
104
105
  export type ActionDefinitions<M extends Model, V> = Record<string, ActionDefinition<M, V, unknown>>;
105
106
  export interface ActionCommitMethod<M extends Model, V, R> {
106
- <K extends keyof M, Mode extends ActionOneMode>(model: K, mode: Mode, ...args: Mode extends ActionOneMode.RESET ? [] : [value?: ActionCommitValue<M, K, Mode>, options?: MutationsOneOptions]): ActionCommitChain<M, V, R>;
107
- <K extends keyof M, Mode extends ActionManyMode>(model: K, mode: Mode, ...args: Mode extends ActionManyMode.RESET ? [] : [value?: ActionCommitValue<M, K, Mode>, options?: MutationsManyOptions]): ActionCommitChain<M, V, R>;
107
+ <K extends keyof M, Mode extends ActionOneMode>(model: K, mode: Mode, ...args: Mode extends ActionOneMode.RESET ? [] : [value?: ActionCommitValue<M, K, Mode> | typeof AUTO, options?: MutationsOneOptions]): ActionCommitChain<M, V, R>;
108
+ <K extends keyof M, Mode extends ActionManyMode>(model: K, mode: Mode, ...args: Mode extends ActionManyMode.RESET ? [] : [value?: ActionCommitValue<M, K, Mode> | typeof AUTO, options?: MutationsManyOptions]): ActionCommitChain<M, V, R>;
108
109
  }
109
110
  export interface ActionApiChain<M extends Model, V, ApiResponse> {
110
111
  handle<R>(callback: ActionHandleCallback<M, V, R, ApiResponse>): ActionHandleChain<M, V, R>;
@@ -1,4 +1,5 @@
1
1
  export const DEFINITION = Symbol("definition");
2
+ export const AUTO = Symbol("auto");
2
3
  export var ActionOneMode = /* @__PURE__ */ ((ActionOneMode2) => {
3
4
  ActionOneMode2["SET"] = "set";
4
5
  ActionOneMode2["RESET"] = "reset";
@@ -3,7 +3,7 @@ import { resolveShape } from "./shape.js";
3
3
  import {
4
4
  ModelKind
5
5
  } from "../types/model.js";
6
- import { ActionOneMode, ActionManyMode } from "../types/action.js";
6
+ import { ActionOneMode, ActionManyMode, AUTO } from "../types/action.js";
7
7
  export function initializeState(model) {
8
8
  const state = {};
9
9
  for (const [key, definition] of Object.entries(model)) {
@@ -212,7 +212,10 @@ export function executeCommit(definition, mutations, result) {
212
212
  break;
213
213
  }
214
214
  default: {
215
- handler(definition.value ?? result, definition.options);
215
+ handler(
216
+ definition.value === AUTO || definition.value === void 0 ? result : definition.value,
217
+ definition.options
218
+ );
216
219
  }
217
220
  }
218
221
  }
@@ -3,7 +3,7 @@ export type { Store, StoreConfig } from "./core/store.js";
3
3
  export { shape } from "./core/layers/shape.js";
4
4
  export type { ShapeInfer } from "./core/types/shape.js";
5
5
  export { ModelKind } from "./core/types/model.js";
6
- export { ActionOneMode, ActionManyMode, ActionStatus, ActionConcurrent, ActionApiMethod } from "./core/types/action.js";
6
+ export { AUTO, ActionOneMode, ActionManyMode, ActionStatus, ActionConcurrent, ActionApiMethod, } from "./core/types/action.js";
7
7
  export type { Action, ActionCallPayload, ActionApiShortcutDefinition, ActionError, ActionApiError, ActionHandleError, ActionCommitError, ActionConcurrentError, } from "./core/types/action.js";
8
8
  export { useIsolatedActionStatus, useIsolatedActionError } from "./composables/action.js";
9
9
  export type { RuntimeConfig } from "./config.js";
@@ -1,5 +1,12 @@
1
1
  export { createStore } from "./core/store.js";
2
2
  export { shape } from "./core/layers/shape.js";
3
3
  export { ModelKind } from "./core/types/model.js";
4
- export { ActionOneMode, ActionManyMode, ActionStatus, ActionConcurrent, ActionApiMethod } from "./core/types/action.js";
4
+ export {
5
+ AUTO,
6
+ ActionOneMode,
7
+ ActionManyMode,
8
+ ActionStatus,
9
+ ActionConcurrent,
10
+ ActionApiMethod
11
+ } from "./core/types/action.js";
5
12
  export { useIsolatedActionStatus, useIsolatedActionError } from "./composables/action.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diphyx/harlemify",
3
- "version": "4.0.0",
3
+ "version": "4.0.1",
4
4
  "description": "API state management for Nuxt powered by Harlem",
5
5
  "keywords": [
6
6
  "nuxt",