@owlmeans/client-planning 0.1.18-rc.20 → 0.1.18-rc.21
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/README.md +2 -2
- package/agent-meta/manifest.json +2 -2
- package/agent-meta/skills/client-planning/SKILL.md +1 -1
- package/build/commits.d.ts +1 -1
- package/build/commits.d.ts.map +1 -1
- package/build/commits.js +9 -7
- package/build/commits.js.map +1 -1
- package/build/consts.d.ts +0 -12
- package/build/consts.d.ts.map +1 -1
- package/build/consts.js +0 -14
- package/build/consts.js.map +1 -1
- package/build/events.d.ts +1 -1
- package/build/events.d.ts.map +1 -1
- package/build/events.js +9 -9
- package/build/events.js.map +1 -1
- package/build/feed.d.ts.map +1 -1
- package/build/feed.js +5 -3
- package/build/feed.js.map +1 -1
- package/build/index.d.ts +1 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -0
- package/build/index.js.map +1 -1
- package/build/stores.d.ts +1 -1
- package/build/stores.d.ts.map +1 -1
- package/build/stores.js +7 -7
- package/build/stores.js.map +1 -1
- package/build/types.local.d.ts +6 -0
- package/build/types.local.d.ts.map +1 -0
- package/build/types.local.js +2 -0
- package/build/types.local.js.map +1 -0
- package/build/utils/record.d.ts +26 -7
- package/build/utils/record.d.ts.map +1 -1
- package/build/utils/record.js +9 -7
- package/build/utils/record.js.map +1 -1
- package/build/utils/types.d.ts +3 -0
- package/build/utils/types.d.ts.map +1 -0
- package/build/utils/types.js +2 -0
- package/build/utils/types.js.map +1 -0
- package/build/utils.d.ts +13 -0
- package/build/utils.d.ts.map +1 -0
- package/build/utils.js +15 -0
- package/build/utils.js.map +1 -0
- package/package.json +17 -16
- package/src/commits.ts +10 -17
- package/src/consts.ts +0 -21
- package/src/events.ts +10 -11
- package/src/feed.ts +7 -5
- package/src/index.ts +1 -0
- package/src/stores.ts +8 -9
- package/src/types.local.ts +6 -0
- package/src/utils/record.ts +11 -7
- package/src/utils/types.ts +3 -0
- package/src/utils.ts +20 -0
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ planning service runs in-process.
|
|
|
9
9
|
## Installation
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
|
-
bun add @owlmeans/client-planning@^0.1.18-rc.
|
|
12
|
+
bun add @owlmeans/client-planning@^0.1.18-rc.21
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
## Concepts
|
|
@@ -119,7 +119,7 @@ This package ships embedded agent skills under `agent-meta/`. After installing y
|
|
|
119
119
|
your project's skill store (`.agents/skills/`):
|
|
120
120
|
|
|
121
121
|
```sh
|
|
122
|
-
npx @owlmeans/agent-skills@^0.1.18-rc.
|
|
122
|
+
npx @owlmeans/agent-skills@^0.1.18-rc.48
|
|
123
123
|
```
|
|
124
124
|
|
|
125
125
|
The embedded files are version-matched to this package release. Do not edit them
|
package/agent-meta/manifest.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 2,
|
|
3
3
|
"package": "@owlmeans/client-planning",
|
|
4
|
-
"version": "0.1.18-rc.
|
|
5
|
-
"generatedAt": "2026-10-
|
|
4
|
+
"version": "0.1.18-rc.21",
|
|
5
|
+
"generatedAt": "2026-10-05T08:32:19.119Z",
|
|
6
6
|
"canonicalRepo": "https://github.com/owlmeans/common",
|
|
7
7
|
"entries": [
|
|
8
8
|
{
|
|
@@ -8,7 +8,7 @@ user-invocable: false
|
|
|
8
8
|
# @owlmeans/client-planning
|
|
9
9
|
|
|
10
10
|
**Layer:** Client
|
|
11
|
-
**Install:** `"@owlmeans/client-planning": "^0.1.18-rc.
|
|
11
|
+
**Install:** `"@owlmeans/client-planning": "^0.1.18-rc.21"` in `dependencies`
|
|
12
12
|
|
|
13
13
|
The client half of OwlMeans planning. It answers the `PlanningFacade` interface of
|
|
14
14
|
`@owlmeans/planning` over the protocol tree a server mounted with `@owlmeans/server-planning`, keeps
|
package/build/commits.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BasicConfig, BasicContext } from '@owlmeans/context';
|
|
2
|
-
import type
|
|
2
|
+
import { type PlanningProtocols } from '@owlmeans/planning';
|
|
3
3
|
import type { RemoteCommitSource, RemoteCommitSourceOptions } from './types.js';
|
|
4
4
|
/**
|
|
5
5
|
* The commit source of a remote facade: the `commit.get` long poll and, when the host injects a
|
package/build/commits.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commits.d.ts","sourceRoot":"","sources":["../src/commits.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"commits.d.ts","sourceRoot":"","sources":["../src/commits.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAElE,OAAO,EAAsN,KAAK,iBAAiB,EAAmC,MAAM,oBAAoB,CAAA;AAGhT,OAAO,KAAK,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAA;AAqB/E;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,sBAAsB,GAAI,CAAC,SAAS,WAAW,EAAE,CAAC,SAAS,YAAY,CAAC,CAAC,CAAC,WAC5E,CAAC,aAAa,iBAAiB,SAAS,yBAAyB,KACzE,kBAuMF,CAAA"}
|
package/build/commits.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { logger } from '@owlmeans/log';
|
|
2
|
+
import { CommitFailed, CommitState, CommitTimeout, DEFAULT_COMMIT_POLL, DEFAULT_COMMIT_TIMEOUT, MAX_COMMIT_POLL, PLANNING_COMMIT_EVENT, PlanningError, WorkcardKind } from '@owlmeans/planning';
|
|
2
3
|
import { EARLY_POLL_LADDER, EARLY_POLL_MS, LONG_POLL_GRACE } from './consts.js';
|
|
3
|
-
import {
|
|
4
|
+
import { recordHelper } from './utils/record.js';
|
|
5
|
+
const log = logger('client-planning');
|
|
4
6
|
const matches = (filter, event) => filter == null || ((filter.entityId == null || filter.entityId === event.entityId)
|
|
5
7
|
&& (filter.project == null || filter.project === event.project)
|
|
6
8
|
&& (filter.card == null || filter.card === event.card)
|
|
@@ -37,7 +39,7 @@ export const makeRemoteCommitSource = (context, protocols, opts) => {
|
|
|
37
39
|
await subscription.listener(event);
|
|
38
40
|
}
|
|
39
41
|
catch (e) {
|
|
40
|
-
|
|
42
|
+
log.error('Planning commit listener failed', e);
|
|
41
43
|
}
|
|
42
44
|
}
|
|
43
45
|
};
|
|
@@ -62,7 +64,7 @@ export const makeRemoteCommitSource = (context, protocols, opts) => {
|
|
|
62
64
|
}
|
|
63
65
|
catch (e) {
|
|
64
66
|
opening = null;
|
|
65
|
-
|
|
67
|
+
log.warn('Planning commit socket failed to open', e);
|
|
66
68
|
return null;
|
|
67
69
|
}
|
|
68
70
|
})();
|
|
@@ -94,17 +96,17 @@ export const makeRemoteCommitSource = (context, protocols, opts) => {
|
|
|
94
96
|
return;
|
|
95
97
|
}
|
|
96
98
|
const known = await stores.commits.load(transition);
|
|
97
|
-
await putCommit(stores.commits, {
|
|
99
|
+
await recordHelper.putCommit(stores.commits, {
|
|
98
100
|
id: transition, state: settled.state, at: settled.at, error: settled.error,
|
|
99
101
|
});
|
|
100
102
|
if (settled.state !== CommitState.Committed) {
|
|
101
103
|
return;
|
|
102
104
|
}
|
|
103
105
|
if (settled.card != null) {
|
|
104
|
-
await putCard(stores.cards, settled.card);
|
|
106
|
+
await recordHelper.putCard(stores.cards, settled.card);
|
|
105
107
|
}
|
|
106
108
|
else if (settled.card === null && known?.card != null) {
|
|
107
|
-
await dropCard(stores, known.card, known.kind === WorkcardKind.Project);
|
|
109
|
+
await recordHelper.dropCard(stores, known.card, known.kind === WorkcardKind.Project);
|
|
108
110
|
}
|
|
109
111
|
};
|
|
110
112
|
const answer = async (transition, settled) => {
|
package/build/commits.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commits.js","sourceRoot":"","sources":["../src/commits.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"commits.js","sourceRoot":"","sources":["../src/commits.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AACtC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,eAAe,EAAE,qBAAqB,EAAE,aAAa,EAAE,YAAY,EAAmH,MAAM,oBAAoB,CAAA;AAEhT,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAG/E,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEhD,MAAM,GAAG,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAA;AAErC,MAAM,OAAO,GAAG,CAAC,MAAgC,EAAE,KAAkB,EAAW,EAAE,CAChF,MAAM,IAAI,IAAI,IAAI,CAChB,CAAC,MAAM,CAAC,QAAQ,IAAI,IAAI,IAAI,MAAM,CAAC,QAAQ,KAAK,KAAK,CAAC,QAAQ,CAAC;OAC5D,CAAC,MAAM,CAAC,OAAO,IAAI,IAAI,IAAI,MAAM,CAAC,OAAO,KAAK,KAAK,CAAC,OAAO,CAAC;OAC5D,CAAC,MAAM,CAAC,IAAI,IAAI,IAAI,IAAI,MAAM,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,CAAC;OACnD,CAAC,MAAM,CAAC,IAAI,IAAI,IAAI,IAAI,MAAM,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,CAAC,CACvD,CAAA;AAEH,MAAM,KAAK,GAAG,CAAC,EAAU,EAAkD,EAAE;IAC3E,IAAI,MAAiD,CAAA;IACrD,MAAM,OAAO,GAAG,IAAI,OAAO,CAAO,OAAO,CAAC,EAAE,GAAG,MAAM,GAAG,UAAU,CAAC,OAAO,EAAE,IAAI,CAA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AAC,CAAA;wBACF,KAAK,IAAI,CAAC,CAAA;wBACV,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,OAAO,CAAO,OAAO,CAAC,EAAE,GAAG,IAAI,GAAG,OAAO,CAAA,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;wBACrF,KAAK,CAAC,MAAM,EAAE,CAAA;wBACd,IAAI,GAAG,GAAG,EAAE,GAAG,CAAC,CAAA;oBAClB,CAAC;yBAAM,CAAC;wBACN,KAAK,GAAG,CAAC,CAAA;oBACX,CAAC;gBACH,CAAC;gBAED,OAAO,MAAM,MAAM,CAAC,UAAU,EAAE,OAAO,CAAC,CAAA;YAC1C,CAAC;oBAAS,CAAC;gBACT,WAAW,EAAE,CAAA;YACf,CAAC;QACH,CAAC;QAED,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,IAAI;QAE7B,KAAK,EAAE,KAAK,IAAI,EAAE;YAChB,MAAM,EAAE,EAAE,CAAA;YACV,MAAM,GAAG,IAAI,CAAA;YACb,MAAM,UAAU,GAAG,IAAI,CAAA;YACvB,IAAI,GAAG,IAAI,CAAA;YACX,OAAO,GAAG,IAAI,CAAA;YACd,MAAM,UAAU,EAAE,KAAK,EAAE,CAAA;QAC3B,CAAC;KACF,CAAA;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA"}
|
package/build/consts.d.ts
CHANGED
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
import type { Relationship, Workcard } from '@owlmeans/planning';
|
|
2
|
-
import type { StateAlias } from '@owlmeans/state';
|
|
3
|
-
import type { PlanningCommitRecord, PlanningStoreAliases } from './types.js';
|
|
4
|
-
/**
|
|
5
|
-
* The ONE card store. Projects, cards and specifications share an id space on the server, so they
|
|
6
|
-
* share it here too — a store per kind would let a list reload of one kind drop another's rows.
|
|
7
|
-
*/
|
|
8
|
-
export declare const CARDS: StateAlias<Workcard>;
|
|
9
|
-
export declare const LINKS: StateAlias<Relationship>;
|
|
10
|
-
/** What the client has learned about each transition it wrote or saw, keyed by transition id. */
|
|
11
|
-
export declare const COMMITS: StateAlias<PlanningCommitRecord>;
|
|
12
|
-
export declare const DEFAULT_STORE_ALIASES: Readonly<PlanningStoreAliases>;
|
|
13
1
|
/**
|
|
14
2
|
* How much longer than its own `wait` a long poll's HTTP deadline is, in milliseconds — a held
|
|
15
3
|
* response must outlast the hold, or every quiet poll reads as a broken connection.
|
package/build/consts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AACA;;;GAGG;AACH,eAAO,MAAM,eAAe,QAAS,CAAA;AAErC;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,EAAE,SAAS,MAAM,EAAuC,CAAA;AAEtF,0DAA0D;AAC1D,eAAO,MAAM,aAAa,MAAM,CAAA"}
|
package/build/consts.js
CHANGED
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
import { stateAlias } from '@owlmeans/state';
|
|
2
|
-
/**
|
|
3
|
-
* The ONE card store. Projects, cards and specifications share an id space on the server, so they
|
|
4
|
-
* share it here too — a store per kind would let a list reload of one kind drop another's rows.
|
|
5
|
-
*/
|
|
6
|
-
export const CARDS = stateAlias('planning-card-state');
|
|
7
|
-
export const LINKS = stateAlias('planning-link-state');
|
|
8
|
-
/** What the client has learned about each transition it wrote or saw, keyed by transition id. */
|
|
9
|
-
export const COMMITS = stateAlias('planning-commit-state');
|
|
10
|
-
export const DEFAULT_STORE_ALIASES = Object.freeze({
|
|
11
|
-
cards: CARDS,
|
|
12
|
-
links: LINKS,
|
|
13
|
-
commits: COMMITS,
|
|
14
|
-
});
|
|
15
1
|
/**
|
|
16
2
|
* How much longer than its own `wait` a long poll's HTTP deadline is, in milliseconds — a held
|
|
17
3
|
* response must outlast the hold, or every quiet poll reads as a broken connection.
|
package/build/consts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consts.js","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AACA
|
|
1
|
+
{"version":3,"file":"consts.js","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AACA;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAA;AAErC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAsB,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAA;AAEtF,0DAA0D;AAC1D,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,CAAA"}
|
package/build/events.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type CommitEvent, type PlanningFacade, type TransitionReceiptView, type Workcard } from '@owlmeans/planning';
|
|
2
2
|
import type { PlanningStores } from './types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Fold one commit frame into the mirror.
|
package/build/events.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+C,KAAK,WAAW,EAAE,KAAK,cAAc,EAAE,KAAK,qBAAqB,EAAE,KAAK,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAElK,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAGhD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,gBAAgB,WACnB,cAAc,SAAS,WAAW,WAAW,cAAc,KAClE,OAAO,CAAC,IAAI,CAkDd,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,WAAkB,cAAc,WAAW,qBAAqB,KAAG,OAAO,CAAC,IAAI,CAiCvG,CAAA;AAED,+FAA+F;AAC/F,eAAO,MAAM,UAAU,WAAkB,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC,SAAS,QAAQ,EAAE,KAAG,OAAO,CAAC,IAAI,CAIvG,CAAA"}
|
package/build/events.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CommitState, TransitionAction, WorkcardKind } from '@owlmeans/planning';
|
|
2
2
|
import { syncLinks } from './stores.js';
|
|
3
|
-
import {
|
|
3
|
+
import { recordHelper } from './utils/record.js';
|
|
4
4
|
/**
|
|
5
5
|
* Fold one commit frame into the mirror.
|
|
6
6
|
*
|
|
@@ -16,7 +16,7 @@ import { dropCard, putCard, putCommit } from './utils/record.js';
|
|
|
16
16
|
*/
|
|
17
17
|
export const applyCommitEvent = async (stores, event, facade) => {
|
|
18
18
|
const known = await stores.cards.load(event.card);
|
|
19
|
-
await putCommit(stores.commits, {
|
|
19
|
+
await recordHelper.putCommit(stores.commits, {
|
|
20
20
|
id: event.transition,
|
|
21
21
|
card: event.card,
|
|
22
22
|
entityId: event.entityId,
|
|
@@ -42,7 +42,7 @@ export const applyCommitEvent = async (stores, event, facade) => {
|
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
44
|
if (event.action === TransitionAction.Delete) {
|
|
45
|
-
await dropCard(stores, event.card, event.kind === WorkcardKind.Project);
|
|
45
|
+
await recordHelper.dropCard(stores, event.card, event.kind === WorkcardKind.Project);
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
48
48
|
const record = event.record !== undefined
|
|
@@ -50,10 +50,10 @@ export const applyCommitEvent = async (stores, event, facade) => {
|
|
|
50
50
|
: facade != null ? await facade.cards.load(event.card) : undefined;
|
|
51
51
|
if (record === null) {
|
|
52
52
|
// Committed, and gone by the time it was read: a later delete won the race.
|
|
53
|
-
await dropCard(stores, event.card, event.kind === WorkcardKind.Project);
|
|
53
|
+
await recordHelper.dropCard(stores, event.card, event.kind === WorkcardKind.Project);
|
|
54
54
|
}
|
|
55
55
|
else if (record !== undefined) {
|
|
56
|
-
await putCard(stores.cards, record);
|
|
56
|
+
await recordHelper.putCard(stores.cards, record);
|
|
57
57
|
}
|
|
58
58
|
if (facade != null && (event.action === TransitionAction.Link || event.action === TransitionAction.Unlink)) {
|
|
59
59
|
const links = await facade.relationships.list({ from: event.card, size: 0 });
|
|
@@ -70,7 +70,7 @@ export const applyCommitEvent = async (stores, event, facade) => {
|
|
|
70
70
|
export const applyReceipt = async (stores, receipt) => {
|
|
71
71
|
const { transition } = receipt;
|
|
72
72
|
if (transition.id != null) {
|
|
73
|
-
await putCommit(stores.commits, {
|
|
73
|
+
await recordHelper.putCommit(stores.commits, {
|
|
74
74
|
id: transition.id,
|
|
75
75
|
card: transition.card,
|
|
76
76
|
entityId: transition.entityId,
|
|
@@ -88,11 +88,11 @@ export const applyReceipt = async (stores, receipt) => {
|
|
|
88
88
|
return;
|
|
89
89
|
}
|
|
90
90
|
if (transition.commit.state === CommitState.Committed && transition.action === TransitionAction.Delete) {
|
|
91
|
-
await dropCard(stores, transition.card, transition.kind === WorkcardKind.Project);
|
|
91
|
+
await recordHelper.dropCard(stores, transition.card, transition.kind === WorkcardKind.Project);
|
|
92
92
|
return;
|
|
93
93
|
}
|
|
94
94
|
if (receipt.card != null) {
|
|
95
|
-
await putCard(stores.cards, receipt.card);
|
|
95
|
+
await recordHelper.putCard(stores.cards, receipt.card);
|
|
96
96
|
return;
|
|
97
97
|
}
|
|
98
98
|
const known = await stores.cards.load(transition.card);
|
|
@@ -103,7 +103,7 @@ export const applyReceipt = async (stores, receipt) => {
|
|
|
103
103
|
/** Write cards the caller read on its own, under the same newer-fold-wins rule as a commit. */
|
|
104
104
|
export const applyCards = async (stores, cards) => {
|
|
105
105
|
for (const card of cards) {
|
|
106
|
-
await putCard(stores.cards, card);
|
|
106
|
+
await recordHelper.putCard(stores.cards, card);
|
|
107
107
|
}
|
|
108
108
|
};
|
|
109
109
|
//# sourceMappingURL=events.js.map
|
package/build/events.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,YAAY,EAAoF,MAAM,oBAAoB,CAAA;AAClK,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEvC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEhD;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,EACnC,MAAsB,EAAE,KAAkB,EAAE,MAAuB,EACpD,EAAE;IACjB,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAEjD,MAAM,YAAY,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,EAAE;QAC3C,EAAE,EAAE,KAAK,CAAC,UAAU;QACpB,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,GAAG,EAAE,KAAK,CAAC,GAAG;QACd,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,EAAE,EAAE,KAAK,CAAC,EAAE;QACZ,KAAK,EAAE,KAAK,CAAC,KAAK;KACnB,CAAC,CAAA;IAEF,IAAI,KAAK,CAAC,KAAK,KAAK,WAAW,CAAC,MAAM,EAAE,CAAC;QACvC,OAAM;IACR,CAAC;IACD,IAAI,KA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/feed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAMlE,OAAO,KAAK,EAAyB,YAAY,EAAE,mBAAmB,EAAqB,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"feed.d.ts","sourceRoot":"","sources":["../src/feed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAMlE,OAAO,KAAK,EAAyB,YAAY,EAAE,mBAAmB,EAAqB,MAAM,YAAY,CAAA;AAQ7G;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,WAAW,EAAE,CAAC,SAAS,YAAY,CAAC,CAAC,CAAC,WACtE,CAAC,SAAQ,mBAAmB,KACpC,YAsGF,CAAA"}
|
package/build/feed.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { logger } from '@owlmeans/log';
|
|
1
2
|
import { criteriaOf, PLANNING_SERVICE } from '@owlmeans/planning';
|
|
2
3
|
import { applyCards, applyCommitEvent } from './events.js';
|
|
3
4
|
import { planningStoresOf, syncCards, syncLinks } from './stores.js';
|
|
4
|
-
import {
|
|
5
|
-
const
|
|
5
|
+
import { recordHelper } from './utils/record.js';
|
|
6
|
+
const log = logger('client-planning');
|
|
7
|
+
const linkCriteriaOf = (query) => recordHelper.clean({ from: query.from, to: query.to, type: query.type });
|
|
6
8
|
/**
|
|
7
9
|
* Keep the state mirror current: subscribe to commits FIRST, then seed from the list, then fold
|
|
8
10
|
* every frame — and, with `refresh`, re-seed on an interval as the authoritative backstop to a
|
|
@@ -86,7 +88,7 @@ export const makePlanningFeed = (context, opts = {}) => {
|
|
|
86
88
|
await applyCommitEvent(stores, event, facade);
|
|
87
89
|
}
|
|
88
90
|
catch (e) {
|
|
89
|
-
|
|
91
|
+
log.warn('Planning feed apply failed', { card: event.card, error: e });
|
|
90
92
|
}
|
|
91
93
|
}, opts.filter);
|
|
92
94
|
if (stopped) {
|
package/build/feed.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feed.js","sourceRoot":"","sources":["../src/feed.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"feed.js","sourceRoot":"","sources":["../src/feed.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AACtC,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAA+D,MAAM,oBAAoB,CAAA;AAE9H,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC1D,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEpE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEhD,MAAM,GAAG,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAA;AAErC,MAAM,cAAc,GAAG,CAAC,KAAwB,EAA0B,EAAE,CAC1E,YAAY,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAA2B,CAAA;AAEpG;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,OAAU,EAAE,IAAI,GAAwB,EAAE,EAC5B,EAAE;IAChB,MAAM,MAAM,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAA;IACxC,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;QACnB,MAAM,IAAI,WAAW,CAAC,mDAAmD,CAAC,CAAA;IAC5E,CAAC;IACD,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAwB,gBAAgB,CAAC,CAAA;IACxE,MAAM,MAAM,GAAG,OAAO,CAAC,GAA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AAI,SAAS,KAAK,OAAO,KAAK,CAAC,SAAS,CAAA,CAAC,CAAC;QAC1C,IAAI,MAAM,KAAK,OAAO,KAAK,CAAC,MAAM,CAAA,CAAC,CAAC;QACpC,IAAI,KAAK,KAAK,OAAO,KAAK,CAAC,KAAK,CAAA,CAAC,CAAC;QAClC,KAAK;QACL,OAAO,EAAE,IAAI;QACb,IAAI,EAAE,KAAK,IAAI,EAAE;YACf,OAAO,GAAG,IAAI,CAAA;YACd,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;gBAClB,aAAa,CAAC,KAAK,CAAC,CAAA;YACtB,CAAC;YACD,WAAW,EAAE,EAAE,CAAA;YACf,WAAW,GAAG,IAAI,CAAA;QACpB,CAAC;KACF,CAAA;AACH,CAAC,CAAA"}
|
package/build/index.d.ts
CHANGED
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,YAAY,CAAA;AAE/B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA;AAChC,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,YAAY,CAAA;AAE/B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA;AAChC,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA"}
|
package/build/index.js
CHANGED
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA;AAChC,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA;AAChC,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA"}
|
package/build/stores.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { BasicConfig, BasicContext } from '@owlmeans/context';
|
|
2
2
|
import type { Relationship, Workcard } from '@owlmeans/planning';
|
|
3
3
|
import type { Criteria } from '@owlmeans/resource';
|
|
4
|
-
import type
|
|
4
|
+
import { type StateResourceAppend } from '@owlmeans/state';
|
|
5
5
|
import type { PlanningStoreAliases, PlanningStores, SyncOptions, WithPlanningStores } from './types.js';
|
|
6
6
|
/**
|
|
7
7
|
* Register the planning state mirror: ONE card store for every kind, a link store and a commit
|
package/build/stores.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stores.d.ts","sourceRoot":"","sources":["../src/stores.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO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|
|
|
1
1
|
import { appendStateResource } from '@owlmeans/state';
|
|
2
|
-
import { DEFAULT_STORE_ALIASES } from './
|
|
3
|
-
import {
|
|
2
|
+
import { DEFAULT_STORE_ALIASES } from './utils.js';
|
|
3
|
+
import { recordHelper } from './utils/record.js';
|
|
4
4
|
/**
|
|
5
5
|
* Register the planning state mirror: ONE card store for every kind, a link store and a commit
|
|
6
6
|
* store, and `context.planningStores()`.
|
|
@@ -38,22 +38,22 @@ export const planningStoresOf = (context) => {
|
|
|
38
38
|
* Unchanged cards are not rewritten, so a periodic re-seed wakes no subscriber.
|
|
39
39
|
*/
|
|
40
40
|
export const syncCards = async (store, items, where, opts) => {
|
|
41
|
-
await dropUnnamed(store, idsOf(items), where, opts);
|
|
41
|
+
await dropUnnamed(store, recordHelper.idsOf(items), where, opts);
|
|
42
42
|
for (const item of items) {
|
|
43
|
-
await putCard(store, item);
|
|
43
|
+
await recordHelper.putCard(store, item);
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
46
|
/** {@link syncCards} for the link store. */
|
|
47
47
|
export const syncLinks = async (store, items, where, opts) => {
|
|
48
|
-
await dropUnnamed(store, idsOf(items), where, opts);
|
|
48
|
+
await dropUnnamed(store, recordHelper.idsOf(items), where, opts);
|
|
49
49
|
for (const item of items) {
|
|
50
|
-
await putLink(store, item);
|
|
50
|
+
await recordHelper.putLink(store, item);
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
53
|
const dropUnnamed = async (store, named, where, opts) => {
|
|
54
54
|
const keep = new Set([...named, ...(opts?.keep ?? [])]);
|
|
55
55
|
const scoped = await store.list(where);
|
|
56
|
-
const stale = idsOf(scoped.items).filter(id => !keep.has(id));
|
|
56
|
+
const stale = recordHelper.idsOf(scoped.items).filter(id => !keep.has(id));
|
|
57
57
|
if (stale.length > 0) {
|
|
58
58
|
await store.purge({ id: { $in: stale } });
|
|
59
59
|
}
|
package/build/stores.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stores.js","sourceRoot":"","sources":["../src/stores.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,
|
|
1
|
+
{"version":3,"file":"stores.js","sourceRoot":"","sources":["../src/stores.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAA4B,MAAM,iBAAiB,CAAA;AAC/E,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAElD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEhD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,OAAU,EAAE,OAAuC,EACL,EAAE;IAChD,MAAM,KAAK,GAAyB,EAAE,GAAG,qBAAqB,EAAE,GAAG,OAAO,EAAE,CAAA;IAC5E,IAAI,GAAG,GAAG,mBAAmB,CAAiB,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,CAAA;IACnE,GAAG,GAAG,mBAAmB,CAA8B,GAAG,EAAE,KAAK,CAAC,KAAK,CAAC,CAAA;IACxE,GAAG,GAAG,mBAAmB,CAAgB,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC,CAAA;IAE5D,MAAM,MAAM,GAAG,GAAmD,CAAA;IAClE,IAAI,MAAM,CAAC,cAAc,IAAI,IAAI,EAAE,CAAC;QAClC,MAAM,CAAC,cAAc,GAAG,GAAG,EAAE,CAAC,CAAC;YAC7B,KAAK,EAAE,MAAM,CAAC,gBAAgB,CAAC,KAAK,CAAC,KAAK,CAAC;YAC3C,KAAK,EAAE,MAAM,CAAC,gBAAgB,CAAC,KAAK,CAAC,KAAK,CAAC;YAC3C,OAAO,EAAE,MAAM,CAAC,gBAAgB,CAAC,KAAK,CAAC,OAAO,CAAC;SAChD,CAAC,CAAA;IACJ,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AAED,0FAA0F;AAC1F,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAA0B,EAAyB,EAAE;IACpF,MAAM,GAAG,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G,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAA;IAC1E,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrB,MAAM,KAAK,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,CAAA;IAC3C,CAAC;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.local.d.ts","sourceRoot":"","sources":["../src/types.local.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEnE,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACtD,MAAM,CAAC,EAAE,YAAY,CAAA;CACtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.local.js","sourceRoot":"","sources":["../src/types.local.ts"],"names":[],"mappings":""}
|
package/build/utils/record.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { CommitState, Relationship, Workcard } from '@owlmeans/planning';
|
|
|
3
3
|
import type { ResourceRecord } from '@owlmeans/resource';
|
|
4
4
|
import type { StateResource } from '@owlmeans/state';
|
|
5
5
|
/** Same content, whatever order the keys arrived in. */
|
|
6
|
-
|
|
6
|
+
declare const sameRecord: (left: unknown, right: unknown) => boolean;
|
|
7
7
|
/**
|
|
8
8
|
* Write one card unless the store already holds a NEWER fold of it.
|
|
9
9
|
*
|
|
@@ -11,15 +11,34 @@ export declare const sameRecord: (left: unknown, right: unknown) => boolean;
|
|
|
11
11
|
* commit landed must not undo that commit. The head only ever grows: a head this client allocated
|
|
12
12
|
* (`applyReceipt`) stays until a fold catches up with it.
|
|
13
13
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
declare const putCard: (store: StateResource<Workcard>, card: Workcard) => Promise<Workcard>;
|
|
15
|
+
declare const putLink: (store: StateResource<Relationship>, link: Relationship) => Promise<void>;
|
|
16
16
|
/** Drop a card, whatever lives under it when it is a project, and every link touching any of them. */
|
|
17
|
-
|
|
17
|
+
declare const dropCard: (stores: PlanningStores, id: string, project: boolean) => Promise<void>;
|
|
18
18
|
/** Record what is known about a transition, merged over what was known before. */
|
|
19
|
-
|
|
19
|
+
declare const putCommit: (store: StateResource<PlanningCommitRecord>, record: Partial<PlanningCommitRecord> & {
|
|
20
20
|
id: string;
|
|
21
21
|
state: CommitState;
|
|
22
22
|
}) => Promise<PlanningCommitRecord>;
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
declare const clean: <T extends object>(record: T) => T;
|
|
24
|
+
declare const idsOf: <T extends ResourceRecord>(records: T[]) => string[];
|
|
25
|
+
export declare const createRecordHelper: () => {
|
|
26
|
+
sameRecord: typeof sameRecord;
|
|
27
|
+
putCard: typeof putCard;
|
|
28
|
+
putLink: typeof putLink;
|
|
29
|
+
dropCard: typeof dropCard;
|
|
30
|
+
putCommit: typeof putCommit;
|
|
31
|
+
clean: typeof clean;
|
|
32
|
+
idsOf: typeof idsOf;
|
|
33
|
+
};
|
|
34
|
+
export declare const recordHelper: {
|
|
35
|
+
sameRecord: typeof sameRecord;
|
|
36
|
+
putCard: typeof putCard;
|
|
37
|
+
putLink: typeof putLink;
|
|
38
|
+
dropCard: typeof dropCard;
|
|
39
|
+
putCommit: typeof putCommit;
|
|
40
|
+
clean: typeof clean;
|
|
41
|
+
idsOf: typeof idsOf;
|
|
42
|
+
};
|
|
43
|
+
export {};
|
|
25
44
|
//# sourceMappingURL=record.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record.d.ts","sourceRoot":"","sources":["../../src/utils/record.ts"],"names":[],"mappings":"AAAA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,OAAO,CAAC,oBAAoB,CAS9B,CAAA;AAED,QAAA,MAAM,KAAK,GAAI,CAAC,SAAS,MAAM,UAAU,CAAC,KAAG,CAC+C,CAAA;AAE5F,QAAA,MAAM,KAAK,GAAI,CAAC,SAAS,cAAc,WAAW,CAAC,EAAE,KAAG,MAAM,EACa,CAAA;AAE3E,eAAO,MAAM,kBAAkB;;;;;;;;CAA8E,CAAA;AAE7G,eAAO,MAAM,YAAY;;;;;;;;CAAuB,CAAA"}
|
package/build/utils/record.js
CHANGED
|
@@ -11,7 +11,7 @@ const stable = (value) => {
|
|
|
11
11
|
return value;
|
|
12
12
|
};
|
|
13
13
|
/** Same content, whatever order the keys arrived in. */
|
|
14
|
-
|
|
14
|
+
const sameRecord = (left, right) => JSON.stringify(stable(left)) === JSON.stringify(stable(right));
|
|
15
15
|
/**
|
|
16
16
|
* Write one card unless the store already holds a NEWER fold of it.
|
|
17
17
|
*
|
|
@@ -19,7 +19,7 @@ export const sameRecord = (left, right) => JSON.stringify(stable(left)) === JSON
|
|
|
19
19
|
* commit landed must not undo that commit. The head only ever grows: a head this client allocated
|
|
20
20
|
* (`applyReceipt`) stays until a fold catches up with it.
|
|
21
21
|
*/
|
|
22
|
-
|
|
22
|
+
const putCard = async (store, card) => {
|
|
23
23
|
if (card.id == null) {
|
|
24
24
|
return card;
|
|
25
25
|
}
|
|
@@ -35,7 +35,7 @@ export const putCard = async (store, card) => {
|
|
|
35
35
|
await store.save(next);
|
|
36
36
|
return next;
|
|
37
37
|
};
|
|
38
|
-
|
|
38
|
+
const putLink = async (store, link) => {
|
|
39
39
|
if (link.id == null) {
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
@@ -46,7 +46,7 @@ export const putLink = async (store, link) => {
|
|
|
46
46
|
await store.save(link);
|
|
47
47
|
};
|
|
48
48
|
/** Drop a card, whatever lives under it when it is a project, and every link touching any of them. */
|
|
49
|
-
|
|
49
|
+
const dropCard = async (stores, id, project) => {
|
|
50
50
|
const ids = [id];
|
|
51
51
|
if (project) {
|
|
52
52
|
const children = await stores.cards.list({ parents: { $contains: [id] } });
|
|
@@ -58,7 +58,7 @@ export const dropCard = async (stores, id, project) => {
|
|
|
58
58
|
}
|
|
59
59
|
};
|
|
60
60
|
/** Record what is known about a transition, merged over what was known before. */
|
|
61
|
-
|
|
61
|
+
const putCommit = async (store, record) => {
|
|
62
62
|
const known = await store.load(record.id);
|
|
63
63
|
const next = { ...known, ...clean(record) };
|
|
64
64
|
if (known != null && sameRecord(known, next)) {
|
|
@@ -67,6 +67,8 @@ export const putCommit = async (store, record) => {
|
|
|
67
67
|
await store.save(next);
|
|
68
68
|
return next;
|
|
69
69
|
};
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
const clean = (record) => Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined));
|
|
71
|
+
const idsOf = (records) => records.map(record => record.id).filter((id) => id != null);
|
|
72
|
+
export const createRecordHelper = () => ({ sameRecord, putCard, putLink, dropCard, putCommit, clean, idsOf });
|
|
73
|
+
export const recordHelper = createRecordHelper();
|
|
72
74
|
//# sourceMappingURL=record.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record.js","sourceRoot":"","sources":["../../src/utils/record.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,GAAG,CAAC,KAAc,EAAW,EAAE;IACzC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;IAC1B,CAAC;IACD,IAAI,KAAK,IAAI,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC/C,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,KAAgC,CAAC;aACvE,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC;aAC1C,IAAI,CAAC,CAAC,CAAC,IAAI,CA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E3E,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAA;AAE7G,MAAM,CAAC,MAAM,YAAY,GAAG,kBAAkB,EAAE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAErD,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":""}
|
package/build/utils.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type StateAlias } from '@owlmeans/state';
|
|
2
|
+
import type { Relationship, Workcard } from '@owlmeans/planning';
|
|
3
|
+
import type { PlanningCommitRecord, PlanningStoreAliases } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* The ONE card store. Projects, cards and specifications share an id space on the server, so they
|
|
6
|
+
* share it here too — a store per kind would let a list reload of one kind drop another's rows.
|
|
7
|
+
*/
|
|
8
|
+
export declare const CARDS: StateAlias<Workcard>;
|
|
9
|
+
export declare const LINKS: StateAlias<Relationship>;
|
|
10
|
+
/** What the client has learned about each transition it wrote or saw, keyed by transition id. */
|
|
11
|
+
export declare const COMMITS: StateAlias<PlanningCommitRecord>;
|
|
12
|
+
export declare const DEFAULT_STORE_ALIASES: Readonly<PlanningStoreAliases>;
|
|
13
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAc,MAAM,iBAAiB,CAAA;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAChE,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAE5E;;;GAGG;AACH,eAAO,MAAM,KAAK,EAAE,UAAU,CAAC,QAAQ,CAA+C,CAAA;AAEtF,eAAO,MAAM,KAAK,EAAE,UAAU,CAAC,YAAY,CAAmD,CAAA;AAE9F,iGAAiG;AACjG,eAAO,MAAM,OAAO,EAAE,UAAU,CAAC,oBAAoB,CAA6D,CAAA;AAElH,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,oBAAoB,CAI/D,CAAA"}
|
package/build/utils.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { stateAlias } from '@owlmeans/state';
|
|
2
|
+
/**
|
|
3
|
+
* The ONE card store. Projects, cards and specifications share an id space on the server, so they
|
|
4
|
+
* share it here too — a store per kind would let a list reload of one kind drop another's rows.
|
|
5
|
+
*/
|
|
6
|
+
export const CARDS = stateAlias('planning-card-state');
|
|
7
|
+
export const LINKS = stateAlias('planning-link-state');
|
|
8
|
+
/** What the client has learned about each transition it wrote or saw, keyed by transition id. */
|
|
9
|
+
export const COMMITS = stateAlias('planning-commit-state');
|
|
10
|
+
export const DEFAULT_STORE_ALIASES = Object.freeze({
|
|
11
|
+
cards: CARDS,
|
|
12
|
+
links: LINKS,
|
|
13
|
+
commits: COMMITS,
|
|
14
|
+
});
|
|
15
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAI7D;;;GAGG;AACH,MAAM,CAAC,MAAM,KAAK,GAAyB,UAAU,CAAW,qBAAqB,CAAC,CAAA;AAEtF,MAAM,CAAC,MAAM,KAAK,GAA6B,UAAU,CAAe,qBAAqB,CAAC,CAAA;AAE9F,iGAAiG;AACjG,MAAM,CAAC,MAAM,OAAO,GAAqC,UAAU,CAAuB,uBAAuB,CAAC,CAAA;AAElH,MAAM,CAAC,MAAM,qBAAqB,GAAmC,MAAM,CAAC,MAAM,CAAC;IACjF,KAAK,EAAE,KAAK;IACZ,KAAK,EAAE,KAAK;IACZ,OAAO,EAAE,OAAO;CACjB,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@owlmeans/client-planning",
|
|
3
|
-
"version": "0.1.18-rc.
|
|
3
|
+
"version": "0.1.18-rc.21",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "The client half of OwlMeans planning — the remote planning facade, the state mirror and its commit fold, and the subscribe-then-poll commit wait. React-free: it runs in a browser and in a Node client alike.",
|
|
6
6
|
"type": "module",
|
|
@@ -23,17 +23,18 @@
|
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@owlmeans/auth": "^0.1.18-rc.
|
|
27
|
-
"@owlmeans/client-context": "^0.1.18-rc.
|
|
28
|
-
"@owlmeans/client-entrypoint": "^0.1.18-rc.
|
|
29
|
-
"@owlmeans/context": "^0.1.18-rc.
|
|
30
|
-
"@owlmeans/entrypoint": "^0.1.18-rc.
|
|
31
|
-
"@owlmeans/error": "^0.1.18-rc.
|
|
32
|
-
"@owlmeans/planning": "^0.1.18-rc.
|
|
33
|
-
"@owlmeans/resource": "^0.1.18-rc.
|
|
34
|
-
"@owlmeans/
|
|
35
|
-
"@owlmeans/
|
|
36
|
-
"@owlmeans/
|
|
26
|
+
"@owlmeans/auth": "^0.1.18-rc.39",
|
|
27
|
+
"@owlmeans/client-context": "^0.1.18-rc.47",
|
|
28
|
+
"@owlmeans/client-entrypoint": "^0.1.18-rc.46",
|
|
29
|
+
"@owlmeans/context": "^0.1.18-rc.33",
|
|
30
|
+
"@owlmeans/entrypoint": "^0.1.18-rc.40",
|
|
31
|
+
"@owlmeans/error": "^0.1.18-rc.37",
|
|
32
|
+
"@owlmeans/planning": "^0.1.18-rc.18",
|
|
33
|
+
"@owlmeans/resource": "^0.1.18-rc.39",
|
|
34
|
+
"@owlmeans/log": "^0.1.18-rc.1",
|
|
35
|
+
"@owlmeans/route": "^0.1.18-rc.34",
|
|
36
|
+
"@owlmeans/socket": "^0.1.18-rc.39",
|
|
37
|
+
"@owlmeans/state": "^0.1.18-rc.38"
|
|
37
38
|
},
|
|
38
39
|
"peerDependencies": {
|
|
39
40
|
"ajv": "*",
|
|
@@ -41,10 +42,10 @@
|
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
43
44
|
"@owlmeans/dep-config": "workspace:*",
|
|
44
|
-
"@owlmeans/server-planning": "^0.1.18-rc.
|
|
45
|
-
"@owlmeans/test": "^0.1.18-rc.
|
|
46
|
-
"@types/bun": "^1.4.
|
|
47
|
-
"ajv": "^8.
|
|
45
|
+
"@owlmeans/server-planning": "^0.1.18-rc.21",
|
|
46
|
+
"@owlmeans/test": "^0.1.18-rc.34",
|
|
47
|
+
"@types/bun": "^1.4.2",
|
|
48
|
+
"ajv": "^8.20.0",
|
|
48
49
|
"ajv-formats": "^3.0.1",
|
|
49
50
|
"nodemon": "^3.1.14",
|
|
50
51
|
"typescript": "^7.0.2"
|
package/src/commits.ts
CHANGED
|
@@ -1,20 +1,13 @@
|
|
|
1
1
|
import type { BasicConfig, BasicContext } from '@owlmeans/context'
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
PLANNING_COMMIT_EVENT, PlanningError, WorkcardKind,
|
|
5
|
-
} from '@owlmeans/planning'
|
|
6
|
-
import type {
|
|
7
|
-
CommitEvent, CommitFilter, CommitStatus, PlanningProtocols, Unsubscribe, Workcard,
|
|
8
|
-
} from '@owlmeans/planning'
|
|
2
|
+
import { logger } from '@owlmeans/log'
|
|
3
|
+
import { CommitFailed, CommitState, CommitTimeout, DEFAULT_COMMIT_POLL, DEFAULT_COMMIT_TIMEOUT, MAX_COMMIT_POLL, PLANNING_COMMIT_EVENT, PlanningError, WorkcardKind, type CommitEvent, type CommitFilter, type CommitStatus, type PlanningProtocols, type Unsubscribe, type Workcard } from '@owlmeans/planning'
|
|
9
4
|
import type { Connection } from '@owlmeans/socket'
|
|
10
5
|
import { EARLY_POLL_LADDER, EARLY_POLL_MS, LONG_POLL_GRACE } from './consts.js'
|
|
11
6
|
import type { RemoteCommitSource, RemoteCommitSourceOptions } from './types.js'
|
|
12
|
-
import {
|
|
7
|
+
import type { Subscription } from './types.local.js'
|
|
8
|
+
import { recordHelper } from './utils/record.js'
|
|
13
9
|
|
|
14
|
-
|
|
15
|
-
listener: (event: CommitEvent) => void | Promise<void>
|
|
16
|
-
filter?: CommitFilter
|
|
17
|
-
}
|
|
10
|
+
const log = logger('client-planning')
|
|
18
11
|
|
|
19
12
|
const matches = (filter: CommitFilter | undefined, event: CommitEvent): boolean =>
|
|
20
13
|
filter == null || (
|
|
@@ -61,7 +54,7 @@ export const makeRemoteCommitSource = <C extends BasicConfig, T extends BasicCon
|
|
|
61
54
|
try {
|
|
62
55
|
await subscription.listener(event)
|
|
63
56
|
} catch (e) {
|
|
64
|
-
|
|
57
|
+
log.error('Planning commit listener failed', e)
|
|
65
58
|
}
|
|
66
59
|
}
|
|
67
60
|
}
|
|
@@ -86,7 +79,7 @@ export const makeRemoteCommitSource = <C extends BasicConfig, T extends BasicCon
|
|
|
86
79
|
return connection
|
|
87
80
|
} catch (e) {
|
|
88
81
|
opening = null
|
|
89
|
-
|
|
82
|
+
log.warn('Planning commit socket failed to open', e)
|
|
90
83
|
return null
|
|
91
84
|
}
|
|
92
85
|
})()
|
|
@@ -122,16 +115,16 @@ export const makeRemoteCommitSource = <C extends BasicConfig, T extends BasicCon
|
|
|
122
115
|
return
|
|
123
116
|
}
|
|
124
117
|
const known = await stores.commits.load(transition)
|
|
125
|
-
await putCommit(stores.commits, {
|
|
118
|
+
await recordHelper.putCommit(stores.commits, {
|
|
126
119
|
id: transition, state: settled.state, at: settled.at, error: settled.error,
|
|
127
120
|
})
|
|
128
121
|
if (settled.state !== CommitState.Committed) {
|
|
129
122
|
return
|
|
130
123
|
}
|
|
131
124
|
if (settled.card != null) {
|
|
132
|
-
await putCard(stores.cards, settled.card)
|
|
125
|
+
await recordHelper.putCard(stores.cards, settled.card)
|
|
133
126
|
} else if (settled.card === null && known?.card != null) {
|
|
134
|
-
await dropCard(stores, known.card, known.kind === WorkcardKind.Project)
|
|
127
|
+
await recordHelper.dropCard(stores, known.card, known.kind === WorkcardKind.Project)
|
|
135
128
|
}
|
|
136
129
|
}
|
|
137
130
|
|
package/src/consts.ts
CHANGED
|
@@ -1,24 +1,3 @@
|
|
|
1
|
-
import type { Relationship, Workcard } from '@owlmeans/planning'
|
|
2
|
-
import { stateAlias } from '@owlmeans/state'
|
|
3
|
-
import type { StateAlias } from '@owlmeans/state'
|
|
4
|
-
import type { PlanningCommitRecord, PlanningStoreAliases } from './types.js'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* The ONE card store. Projects, cards and specifications share an id space on the server, so they
|
|
8
|
-
* share it here too — a store per kind would let a list reload of one kind drop another's rows.
|
|
9
|
-
*/
|
|
10
|
-
export const CARDS: StateAlias<Workcard> = stateAlias<Workcard>('planning-card-state')
|
|
11
|
-
|
|
12
|
-
export const LINKS: StateAlias<Relationship> = stateAlias<Relationship>('planning-link-state')
|
|
13
|
-
|
|
14
|
-
/** What the client has learned about each transition it wrote or saw, keyed by transition id. */
|
|
15
|
-
export const COMMITS: StateAlias<PlanningCommitRecord> = stateAlias<PlanningCommitRecord>('planning-commit-state')
|
|
16
|
-
|
|
17
|
-
export const DEFAULT_STORE_ALIASES: Readonly<PlanningStoreAliases> = Object.freeze({
|
|
18
|
-
cards: CARDS,
|
|
19
|
-
links: LINKS,
|
|
20
|
-
commits: COMMITS,
|
|
21
|
-
})
|
|
22
1
|
|
|
23
2
|
/**
|
|
24
3
|
* How much longer than its own `wait` a long poll's HTTP deadline is, in milliseconds — a held
|
package/src/events.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { CommitState, TransitionAction, WorkcardKind } from '@owlmeans/planning'
|
|
2
|
-
import type { CommitEvent, PlanningFacade, TransitionReceiptView, Workcard } from '@owlmeans/planning'
|
|
1
|
+
import { CommitState, TransitionAction, WorkcardKind, type CommitEvent, type PlanningFacade, type TransitionReceiptView, type Workcard } from '@owlmeans/planning'
|
|
3
2
|
import { syncLinks } from './stores.js'
|
|
4
3
|
import type { PlanningStores } from './types.js'
|
|
5
|
-
import {
|
|
4
|
+
import { recordHelper } from './utils/record.js'
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* Fold one commit frame into the mirror.
|
|
@@ -22,7 +21,7 @@ export const applyCommitEvent = async (
|
|
|
22
21
|
): Promise<void> => {
|
|
23
22
|
const known = await stores.cards.load(event.card)
|
|
24
23
|
|
|
25
|
-
await putCommit(stores.commits, {
|
|
24
|
+
await recordHelper.putCommit(stores.commits, {
|
|
26
25
|
id: event.transition,
|
|
27
26
|
card: event.card,
|
|
28
27
|
entityId: event.entityId,
|
|
@@ -50,7 +49,7 @@ export const applyCommitEvent = async (
|
|
|
50
49
|
}
|
|
51
50
|
|
|
52
51
|
if (event.action === TransitionAction.Delete) {
|
|
53
|
-
await dropCard(stores, event.card, event.kind === WorkcardKind.Project)
|
|
52
|
+
await recordHelper.dropCard(stores, event.card, event.kind === WorkcardKind.Project)
|
|
54
53
|
return
|
|
55
54
|
}
|
|
56
55
|
|
|
@@ -60,9 +59,9 @@ export const applyCommitEvent = async (
|
|
|
60
59
|
|
|
61
60
|
if (record === null) {
|
|
62
61
|
// Committed, and gone by the time it was read: a later delete won the race.
|
|
63
|
-
await dropCard(stores, event.card, event.kind === WorkcardKind.Project)
|
|
62
|
+
await recordHelper.dropCard(stores, event.card, event.kind === WorkcardKind.Project)
|
|
64
63
|
} else if (record !== undefined) {
|
|
65
|
-
await putCard(stores.cards, record)
|
|
64
|
+
await recordHelper.putCard(stores.cards, record)
|
|
66
65
|
}
|
|
67
66
|
|
|
68
67
|
if (facade != null && (event.action === TransitionAction.Link || event.action === TransitionAction.Unlink)) {
|
|
@@ -81,7 +80,7 @@ export const applyCommitEvent = async (
|
|
|
81
80
|
export const applyReceipt = async (stores: PlanningStores, receipt: TransitionReceiptView): Promise<void> => {
|
|
82
81
|
const { transition } = receipt
|
|
83
82
|
if (transition.id != null) {
|
|
84
|
-
await putCommit(stores.commits, {
|
|
83
|
+
await recordHelper.putCommit(stores.commits, {
|
|
85
84
|
id: transition.id,
|
|
86
85
|
card: transition.card,
|
|
87
86
|
entityId: transition.entityId,
|
|
@@ -99,11 +98,11 @@ export const applyReceipt = async (stores: PlanningStores, receipt: TransitionRe
|
|
|
99
98
|
return
|
|
100
99
|
}
|
|
101
100
|
if (transition.commit.state === CommitState.Committed && transition.action === TransitionAction.Delete) {
|
|
102
|
-
await dropCard(stores, transition.card, transition.kind === WorkcardKind.Project)
|
|
101
|
+
await recordHelper.dropCard(stores, transition.card, transition.kind === WorkcardKind.Project)
|
|
103
102
|
return
|
|
104
103
|
}
|
|
105
104
|
if (receipt.card != null) {
|
|
106
|
-
await putCard(stores.cards, receipt.card)
|
|
105
|
+
await recordHelper.putCard(stores.cards, receipt.card)
|
|
107
106
|
return
|
|
108
107
|
}
|
|
109
108
|
|
|
@@ -116,6 +115,6 @@ export const applyReceipt = async (stores: PlanningStores, receipt: TransitionRe
|
|
|
116
115
|
/** Write cards the caller read on its own, under the same newer-fold-wins rule as a commit. */
|
|
117
116
|
export const applyCards = async (stores: Pick<PlanningStores, 'cards'>, cards: Workcard[]): Promise<void> => {
|
|
118
117
|
for (const card of cards) {
|
|
119
|
-
await putCard(stores.cards, card)
|
|
118
|
+
await recordHelper.putCard(stores.cards, card)
|
|
120
119
|
}
|
|
121
120
|
}
|
package/src/feed.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import type { BasicConfig, BasicContext } from '@owlmeans/context'
|
|
2
|
-
import {
|
|
3
|
-
import type
|
|
2
|
+
import { logger } from '@owlmeans/log'
|
|
3
|
+
import { criteriaOf, PLANNING_SERVICE, type Relationship, type RelationshipQuery, type Unsubscribe } from '@owlmeans/planning'
|
|
4
4
|
import type { Criteria } from '@owlmeans/resource'
|
|
5
5
|
import { applyCards, applyCommitEvent } from './events.js'
|
|
6
6
|
import { planningStoresOf, syncCards, syncLinks } from './stores.js'
|
|
7
7
|
import type { PlanningClientService, PlanningFeed, PlanningFeedOptions, PlanningFeedState } from './types.js'
|
|
8
|
-
import {
|
|
8
|
+
import { recordHelper } from './utils/record.js'
|
|
9
|
+
|
|
10
|
+
const log = logger('client-planning')
|
|
9
11
|
|
|
10
12
|
const linkCriteriaOf = (query: RelationshipQuery): Criteria<Relationship> =>
|
|
11
|
-
clean({ from: query.from, to: query.to, type: query.type }) as Criteria<Relationship>
|
|
13
|
+
recordHelper.clean({ from: query.from, to: query.to, type: query.type }) as Criteria<Relationship>
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
* Keep the state mirror current: subscribe to commits FIRST, then seed from the list, then fold
|
|
@@ -95,7 +97,7 @@ export const makePlanningFeed = <C extends BasicConfig, T extends BasicContext<C
|
|
|
95
97
|
try {
|
|
96
98
|
await applyCommitEvent(stores, event, facade)
|
|
97
99
|
} catch (e) {
|
|
98
|
-
|
|
100
|
+
log.warn('Planning feed apply failed', { card: event.card, error: e })
|
|
99
101
|
}
|
|
100
102
|
}, opts.filter)
|
|
101
103
|
if (stopped) {
|
package/src/index.ts
CHANGED
package/src/stores.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import type { BasicConfig, BasicContext } from '@owlmeans/context'
|
|
2
2
|
import type { Relationship, Workcard } from '@owlmeans/planning'
|
|
3
3
|
import type { Criteria } from '@owlmeans/resource'
|
|
4
|
-
import { appendStateResource } from '@owlmeans/state'
|
|
5
|
-
import
|
|
6
|
-
import { DEFAULT_STORE_ALIASES } from './consts.js'
|
|
4
|
+
import { appendStateResource, type StateResourceAppend } from '@owlmeans/state'
|
|
5
|
+
import { DEFAULT_STORE_ALIASES } from './utils.js'
|
|
7
6
|
import type { PlanningStoreAliases, PlanningStores, SyncOptions, WithPlanningStores } from './types.js'
|
|
8
|
-
import {
|
|
7
|
+
import { recordHelper } from './utils/record.js'
|
|
9
8
|
|
|
10
9
|
/**
|
|
11
10
|
* Register the planning state mirror: ONE card store for every kind, a link store and a commit
|
|
@@ -53,9 +52,9 @@ export const planningStoresOf = (context: BasicContext<any>): PlanningStores | n
|
|
|
53
52
|
export const syncCards = async (
|
|
54
53
|
store: PlanningStores['cards'], items: Workcard[], where?: Criteria<Workcard>, opts?: SyncOptions
|
|
55
54
|
): Promise<void> => {
|
|
56
|
-
await dropUnnamed(store, idsOf(items), where, opts)
|
|
55
|
+
await dropUnnamed(store, recordHelper.idsOf(items), where, opts)
|
|
57
56
|
for (const item of items) {
|
|
58
|
-
await putCard(store, item)
|
|
57
|
+
await recordHelper.putCard(store, item)
|
|
59
58
|
}
|
|
60
59
|
}
|
|
61
60
|
|
|
@@ -63,9 +62,9 @@ export const syncCards = async (
|
|
|
63
62
|
export const syncLinks = async (
|
|
64
63
|
store: PlanningStores['links'], items: Relationship[], where?: Criteria<Relationship>, opts?: SyncOptions
|
|
65
64
|
): Promise<void> => {
|
|
66
|
-
await dropUnnamed(store, idsOf(items), where, opts)
|
|
65
|
+
await dropUnnamed(store, recordHelper.idsOf(items), where, opts)
|
|
67
66
|
for (const item of items) {
|
|
68
|
-
await putLink(store, item)
|
|
67
|
+
await recordHelper.putLink(store, item)
|
|
69
68
|
}
|
|
70
69
|
}
|
|
71
70
|
|
|
@@ -74,7 +73,7 @@ const dropUnnamed = async <T extends Workcard | Relationship>(
|
|
|
74
73
|
): Promise<void> => {
|
|
75
74
|
const keep = new Set([...named, ...(opts?.keep ?? [])])
|
|
76
75
|
const scoped = await (store as PlanningStores['cards']).list(where as Criteria<Workcard>)
|
|
77
|
-
const stale = idsOf(scoped.items).filter(id => !keep.has(id))
|
|
76
|
+
const stale = recordHelper.idsOf(scoped.items).filter(id => !keep.has(id))
|
|
78
77
|
if (stale.length > 0) {
|
|
79
78
|
await store.purge({ id: { $in: stale } })
|
|
80
79
|
}
|
package/src/utils/record.ts
CHANGED
|
@@ -18,7 +18,7 @@ const stable = (value: unknown): unknown => {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
/** Same content, whatever order the keys arrived in. */
|
|
21
|
-
|
|
21
|
+
const sameRecord = (left: unknown, right: unknown): boolean =>
|
|
22
22
|
JSON.stringify(stable(left)) === JSON.stringify(stable(right))
|
|
23
23
|
|
|
24
24
|
/**
|
|
@@ -28,7 +28,7 @@ export const sameRecord = (left: unknown, right: unknown): boolean =>
|
|
|
28
28
|
* commit landed must not undo that commit. The head only ever grows: a head this client allocated
|
|
29
29
|
* (`applyReceipt`) stays until a fold catches up with it.
|
|
30
30
|
*/
|
|
31
|
-
|
|
31
|
+
const putCard = async (store: StateResource<Workcard>, card: Workcard): Promise<Workcard> => {
|
|
32
32
|
if (card.id == null) {
|
|
33
33
|
return card
|
|
34
34
|
}
|
|
@@ -46,7 +46,7 @@ export const putCard = async (store: StateResource<Workcard>, card: Workcard): P
|
|
|
46
46
|
return next
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
const putLink = async (store: StateResource<Relationship>, link: Relationship): Promise<void> => {
|
|
50
50
|
if (link.id == null) {
|
|
51
51
|
return
|
|
52
52
|
}
|
|
@@ -58,7 +58,7 @@ export const putLink = async (store: StateResource<Relationship>, link: Relation
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
/** Drop a card, whatever lives under it when it is a project, and every link touching any of them. */
|
|
61
|
-
|
|
61
|
+
const dropCard = async (stores: PlanningStores, id: string, project: boolean): Promise<void> => {
|
|
62
62
|
const ids = [id]
|
|
63
63
|
if (project) {
|
|
64
64
|
const children = await stores.cards.list({ parents: { $contains: [id] } })
|
|
@@ -71,7 +71,7 @@ export const dropCard = async (stores: PlanningStores, id: string, project: bool
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
/** Record what is known about a transition, merged over what was known before. */
|
|
74
|
-
|
|
74
|
+
const putCommit = async (
|
|
75
75
|
store: StateResource<PlanningCommitRecord>, record: Partial<PlanningCommitRecord> & { id: string, state: CommitState }
|
|
76
76
|
): Promise<PlanningCommitRecord> => {
|
|
77
77
|
const known = await store.load(record.id)
|
|
@@ -84,8 +84,12 @@ export const putCommit = async (
|
|
|
84
84
|
return next
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
|
|
87
|
+
const clean = <T extends object>(record: T): T =>
|
|
88
88
|
Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined)) as T
|
|
89
89
|
|
|
90
|
-
|
|
90
|
+
const idsOf = <T extends ResourceRecord>(records: T[]): string[] =>
|
|
91
91
|
records.map(record => record.id).filter((id): id is string => id != null)
|
|
92
|
+
|
|
93
|
+
export const createRecordHelper = () => ({ sameRecord, putCard, putLink, dropCard, putCommit, clean, idsOf })
|
|
94
|
+
|
|
95
|
+
export const recordHelper = createRecordHelper()
|
package/src/utils.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type StateAlias, stateAlias } from '@owlmeans/state'
|
|
2
|
+
import type { Relationship, Workcard } from '@owlmeans/planning'
|
|
3
|
+
import type { PlanningCommitRecord, PlanningStoreAliases } from './types.js'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The ONE card store. Projects, cards and specifications share an id space on the server, so they
|
|
7
|
+
* share it here too — a store per kind would let a list reload of one kind drop another's rows.
|
|
8
|
+
*/
|
|
9
|
+
export const CARDS: StateAlias<Workcard> = stateAlias<Workcard>('planning-card-state')
|
|
10
|
+
|
|
11
|
+
export const LINKS: StateAlias<Relationship> = stateAlias<Relationship>('planning-link-state')
|
|
12
|
+
|
|
13
|
+
/** What the client has learned about each transition it wrote or saw, keyed by transition id. */
|
|
14
|
+
export const COMMITS: StateAlias<PlanningCommitRecord> = stateAlias<PlanningCommitRecord>('planning-commit-state')
|
|
15
|
+
|
|
16
|
+
export const DEFAULT_STORE_ALIASES: Readonly<PlanningStoreAliases> = Object.freeze({
|
|
17
|
+
cards: CARDS,
|
|
18
|
+
links: LINKS,
|
|
19
|
+
commits: COMMITS,
|
|
20
|
+
})
|