@atscript/moost-wf 0.1.149 → 0.1.151

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/store.d.mts CHANGED
@@ -100,6 +100,13 @@ declare class AsWfStore implements WfStateStore {
100
100
  now(): number;
101
101
  };
102
102
  constructor(opts: AsWfStoreOptions);
103
+ /**
104
+ * Persist `state` under `handle`. A new handle (the common case: a fresh
105
+ * handle, or one just consumed by `getAndDelete`) is written with a single
106
+ * conflict-ignoring insert; only when the handle already exists is the row
107
+ * read back (to keep `createdAt` / `createdBy`) and replaced. Adapters
108
+ * without `onConflict: "ignore"` take the read-then-write path every time.
109
+ */
103
110
  set(handle: string, state: WfState, expiresAt?: number): Promise<void>;
104
111
  get(handle: string): Promise<{
105
112
  state: WfState;
package/dist/store.mjs CHANGED
@@ -21,14 +21,39 @@ var AsWfStore = class {
21
21
  #actor;
22
22
  #shadowFieldsCache = null;
23
23
  #warnedFields = /* @__PURE__ */ new Set();
24
+ /** Whether the table's adapter supports `insertOne(…, { onConflict: "ignore" })`; `undefined` until first tried. */
25
+ #insertIgnore;
24
26
  constructor(opts) {
25
27
  this.table = opts.table;
26
28
  this.clock = opts.clock ?? defaultClock;
27
29
  this.#actor = opts.actor;
28
30
  }
31
+ /**
32
+ * Persist `state` under `handle`. A new handle (the common case: a fresh
33
+ * handle, or one just consumed by `getAndDelete`) is written with a single
34
+ * conflict-ignoring insert; only when the handle already exists is the row
35
+ * read back (to keep `createdAt` / `createdBy`) and replaced. Adapters
36
+ * without `onConflict: "ignore"` take the read-then-write path every time.
37
+ */
29
38
  async set(handle, state, expiresAt) {
30
39
  const now = this.clock.now();
31
40
  const actor = this.getActor();
41
+ if (this.#insertIgnore !== false) {
42
+ const fresh = this.buildSetPayload(handle, state, {
43
+ expiresAt,
44
+ existing: null,
45
+ now,
46
+ actor
47
+ });
48
+ try {
49
+ const result = await this.table.insertOne(fresh, { onConflict: "ignore" });
50
+ this.#insertIgnore = true;
51
+ if (!result.conflict) return;
52
+ } catch (error) {
53
+ if (error?.code !== "ON_CONFLICT_NOT_SUPPORTED") throw error;
54
+ this.#insertIgnore = false;
55
+ }
56
+ }
32
57
  const existing = await this.findRow(handle);
33
58
  const payload = this.buildSetPayload(handle, state, {
34
59
  expiresAt,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atscript/moost-wf",
3
- "version": "0.1.149",
3
+ "version": "0.1.151",
4
4
  "description": "Workflow form integration for moost — decorators, interceptors, and serialization driven by atscript type metadata",
5
5
  "keywords": [
6
6
  "atscript",
@@ -56,30 +56,30 @@
56
56
  "access": "public"
57
57
  },
58
58
  "devDependencies": {
59
- "@atscript/core": "^0.1.100",
60
- "@atscript/db": "^0.1.149",
61
- "@atscript/db-sql-tools": "^0.1.149",
62
- "@atscript/db-sqlite": "^0.1.149",
63
- "@atscript/typescript": "^0.1.100",
64
- "@moostjs/event-wf": "^0.6.45",
59
+ "@atscript/core": "^0.1.102",
60
+ "@atscript/db": "^0.1.151",
61
+ "@atscript/db-sql-tools": "^0.1.151",
62
+ "@atscript/db-sqlite": "^0.1.151",
63
+ "@atscript/typescript": "^0.1.102",
64
+ "@moostjs/event-wf": "^0.6.48",
65
65
  "@prostojs/wf": "^0.1.1",
66
- "@uniqu/core": "^0.1.13",
67
- "@wooksjs/event-core": "^0.7.26",
68
- "@wooksjs/event-http": "^0.7.26",
69
- "@wooksjs/event-wf": "^0.7.26",
70
- "@wooksjs/http-body": "^0.7.26",
71
- "moost": "^0.6.45",
72
- "unplugin-atscript": "^0.1.100",
66
+ "@uniqu/core": "^0.1.14",
67
+ "@wooksjs/event-core": "^0.7.27",
68
+ "@wooksjs/event-http": "^0.7.27",
69
+ "@wooksjs/event-wf": "^0.7.27",
70
+ "@wooksjs/http-body": "^0.7.27",
71
+ "moost": "^0.6.48",
72
+ "unplugin-atscript": "^0.1.102",
73
73
  "vitest": "npm:@voidzero-dev/vite-plus-test@0.1.14",
74
- "@atscript/ui": "^0.1.149"
74
+ "@atscript/ui": "^0.1.151"
75
75
  },
76
76
  "peerDependencies": {
77
- "@atscript/core": "^0.1.100",
78
- "@atscript/typescript": "^0.1.100",
79
- "@moostjs/event-wf": "^0.6.45",
80
- "@wooksjs/event-core": "^0.7.26",
81
- "@wooksjs/event-wf": "^0.7.26",
82
- "moost": "^0.6.45"
77
+ "@atscript/core": "^0.1.102",
78
+ "@atscript/typescript": "^0.1.102",
79
+ "@moostjs/event-wf": "^0.6.48",
80
+ "@wooksjs/event-core": "^0.7.27",
81
+ "@wooksjs/event-wf": "^0.7.27",
82
+ "moost": "^0.6.48"
83
83
  },
84
84
  "scripts": {
85
85
  "build": "vp pack",