@astrale-os/shell-react 0.2.8 → 0.2.10-beta.2
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/application/apps/app-host.d.ts +7 -15
- package/dist/application/apps/app-host.d.ts.map +1 -1
- package/dist/application/apps/app-host.js +3 -2
- package/dist/application/apps/apps.hook.d.ts +7 -4
- package/dist/application/apps/apps.hook.d.ts.map +1 -1
- package/dist/application/apps/apps.hook.js +10 -2
- package/dist/application/apps/domains.hook.d.ts +1 -1
- package/dist/application/apps/domains.hook.d.ts.map +1 -1
- package/dist/application/apps/domains.hook.js +1 -1
- package/dist/application/apps/open-app.hook.d.ts +2 -3
- package/dist/application/apps/open-app.hook.d.ts.map +1 -1
- package/dist/application/index.d.ts +2 -4
- package/dist/application/index.d.ts.map +1 -1
- package/dist/application/index.js +2 -3
- package/dist/application/spaces/space.hook.d.ts +2 -2
- package/dist/application/spaces/space.hook.d.ts.map +1 -1
- package/dist/application/spaces/space.hook.js +2 -2
- package/dist/application/spaces/spaces.hook.d.ts +2 -3
- package/dist/application/spaces/spaces.hook.d.ts.map +1 -1
- package/dist/application/spaces/spaces.hook.js +10 -3
- package/dist/auth/act-as.context.d.ts +15 -32
- package/dist/auth/act-as.context.d.ts.map +1 -1
- package/dist/auth/act-as.context.js +22 -66
- package/dist/auth/auth.hook.d.ts +1 -0
- package/dist/auth/auth.hook.d.ts.map +1 -1
- package/dist/auth/auth.hook.js +2 -22
- package/dist/auth/can.hook.d.ts +10 -38
- package/dist/auth/can.hook.d.ts.map +1 -1
- package/dist/auth/can.hook.js +35 -110
- package/dist/auth/index.d.ts +1 -0
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/self.hook.d.ts +2 -2
- package/dist/auth/self.hook.d.ts.map +1 -1
- package/dist/auth/self.hook.js +0 -7
- package/dist/auth/session-kernel.d.ts +2 -3
- package/dist/auth/session-kernel.d.ts.map +1 -1
- package/dist/auth/session-kernel.js +4 -13
- package/dist/components/boundaries.d.ts +47 -0
- package/dist/components/boundaries.d.ts.map +1 -0
- package/dist/components/boundaries.js +55 -0
- package/dist/components/can.d.ts +11 -0
- package/dist/components/can.d.ts.map +1 -0
- package/dist/components/can.js +5 -0
- package/dist/components/index.d.ts +7 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +4 -0
- package/dist/components/mount-domain-frontend.d.ts +22 -0
- package/dist/components/mount-domain-frontend.d.ts.map +1 -0
- package/dist/components/mount-domain-frontend.js +85 -0
- package/dist/components/view-app.d.ts +16 -0
- package/dist/components/view-app.d.ts.map +1 -0
- package/dist/components/view-app.js +16 -0
- package/dist/graph/call/call.hook.d.ts +8 -18
- package/dist/graph/call/call.hook.d.ts.map +1 -1
- package/dist/graph/call/call.hook.js +7 -13
- package/dist/graph/call/stream.hook.d.ts +12 -20
- package/dist/graph/call/stream.hook.d.ts.map +1 -1
- package/dist/graph/call/stream.hook.js +55 -111
- package/dist/graph/graph.context.d.ts +4 -3
- package/dist/graph/graph.context.d.ts.map +1 -1
- package/dist/graph/graph.context.js +2 -8
- package/dist/graph/guards.error.d.ts +7 -8
- package/dist/graph/guards.error.d.ts.map +1 -1
- package/dist/graph/guards.error.js +11 -7
- package/dist/graph/index.d.ts +8 -16
- package/dist/graph/index.d.ts.map +1 -1
- package/dist/graph/index.js +3 -7
- package/dist/graph/memory/read/envelope.d.ts +22 -54
- package/dist/graph/memory/read/envelope.d.ts.map +1 -1
- package/dist/graph/memory/read/envelope.js +26 -20
- package/dist/graph/memory/read/idle.d.ts +1 -15
- package/dist/graph/memory/read/idle.d.ts.map +1 -1
- package/dist/graph/memory/read/idle.js +4 -13
- package/dist/graph/query-definition.hook.d.ts +11 -0
- package/dist/graph/query-definition.hook.d.ts.map +1 -0
- package/dist/graph/query-definition.hook.js +205 -0
- package/dist/graph/resource.d.ts +34 -0
- package/dist/graph/resource.d.ts.map +1 -0
- package/dist/graph/resource.js +244 -0
- package/dist/graph/store.d.ts +25 -0
- package/dist/graph/store.d.ts.map +1 -0
- package/dist/graph/store.js +69 -0
- package/dist/host/actions.hook.d.ts +34 -0
- package/dist/host/actions.hook.d.ts.map +1 -0
- package/dist/host/actions.hook.js +125 -0
- package/dist/host/components.d.ts +15 -0
- package/dist/host/components.d.ts.map +1 -0
- package/dist/host/components.js +14 -0
- package/dist/host/index.d.ts +5 -0
- package/dist/host/index.d.ts.map +1 -0
- package/dist/host/index.js +3 -0
- package/dist/index.d.ts +26 -37
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -31
- package/dist/intents/envelope.d.ts +7 -19
- package/dist/intents/envelope.d.ts.map +1 -1
- package/dist/intents/envelope.js +2 -3
- package/dist/intents/send-intent.hook.d.ts +5 -7
- package/dist/intents/send-intent.hook.d.ts.map +1 -1
- package/dist/intents/send-intent.hook.js +17 -75
- package/dist/navigation/adapters/adapter.d.ts +5 -0
- package/dist/navigation/adapters/adapter.d.ts.map +1 -1
- package/dist/navigation/adapters/memory.adapter.d.ts.map +1 -1
- package/dist/navigation/adapters/memory.adapter.js +4 -0
- package/dist/navigation/adapters/url.adapter.d.ts.map +1 -1
- package/dist/navigation/adapters/url.adapter.js +57 -10
- package/dist/navigation/codec.d.ts +60 -0
- package/dist/navigation/codec.d.ts.map +1 -0
- package/dist/navigation/codec.js +121 -0
- package/dist/navigation/history.d.ts +11 -9
- package/dist/navigation/history.d.ts.map +1 -1
- package/dist/navigation/history.js +6 -8
- package/dist/navigation/hooks/ancestors.hook.d.ts +5 -7
- package/dist/navigation/hooks/ancestors.hook.d.ts.map +1 -1
- package/dist/navigation/hooks/ancestors.hook.js +7 -51
- package/dist/navigation/hooks/location.hook.d.ts.map +1 -1
- package/dist/navigation/hooks/location.hook.js +4 -6
- package/dist/navigation/hooks/scope.hook.d.ts.map +1 -1
- package/dist/navigation/hooks/scope.hook.js +4 -6
- package/dist/navigation/index.d.ts +4 -2
- package/dist/navigation/index.d.ts.map +1 -1
- package/dist/navigation/index.js +2 -1
- package/dist/navigation/link.d.ts +12 -0
- package/dist/navigation/link.d.ts.map +1 -1
- package/dist/navigation/link.js +13 -2
- package/dist/navigation/location.d.ts +13 -40
- package/dist/navigation/location.d.ts.map +1 -1
- package/dist/navigation/location.js +14 -76
- package/dist/navigation/scope.context.d.ts +17 -26
- package/dist/navigation/scope.context.d.ts.map +1 -1
- package/dist/navigation/scope.context.js +140 -108
- package/dist/navigation/snapshot.d.ts +14 -19
- package/dist/navigation/snapshot.d.ts.map +1 -1
- package/dist/navigation/snapshot.js +48 -44
- package/dist/schema/action.hook.d.ts +44 -0
- package/dist/schema/action.hook.d.ts.map +1 -0
- package/dist/schema/action.hook.js +72 -0
- package/dist/schema/domain.hook.d.ts +12 -7
- package/dist/schema/domain.hook.d.ts.map +1 -1
- package/dist/schema/domain.hook.js +101 -4
- package/dist/schema/index.d.ts +9 -8
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/index.js +5 -7
- package/dist/schema/kernel.hook.d.ts +4 -9
- package/dist/schema/kernel.hook.d.ts.map +1 -1
- package/dist/schema/kernel.hook.js +4 -6
- package/dist/schema/mutation.hook.d.ts +9 -0
- package/dist/schema/mutation.hook.d.ts.map +1 -0
- package/dist/schema/mutation.hook.js +41 -0
- package/dist/schema/object.hook.d.ts +16 -0
- package/dist/schema/object.hook.d.ts.map +1 -0
- package/dist/schema/object.hook.js +46 -0
- package/dist/schema/relation.hook.d.ts +46 -0
- package/dist/schema/relation.hook.d.ts.map +1 -0
- package/dist/schema/relation.hook.js +136 -0
- package/dist/selection/live.d.ts +9 -17
- package/dist/selection/live.d.ts.map +1 -1
- package/dist/selection/live.js +65 -112
- package/dist/selection/scope.context.js +5 -4
- package/dist/session/boot/boot.d.ts +1 -13
- package/dist/session/boot/boot.d.ts.map +1 -1
- package/dist/session/boot/boot.js +9 -27
- package/dist/session/index.d.ts +1 -0
- package/dist/session/index.d.ts.map +1 -1
- package/dist/session/kernel-instance.hook.d.ts +1 -4
- package/dist/session/kernel-instance.hook.d.ts.map +1 -1
- package/dist/session/kernel-instance.hook.js +1 -5
- package/dist/session/provider.d.ts +9 -23
- package/dist/session/provider.d.ts.map +1 -1
- package/dist/session/provider.js +29 -75
- package/dist/session/session.context.d.ts +5 -0
- package/dist/session/session.context.d.ts.map +1 -1
- package/dist/window/adopt.d.ts +0 -1
- package/dist/window/adopt.d.ts.map +1 -1
- package/dist/window/hooks/target-node.hook.d.ts +10 -6
- package/dist/window/hooks/target-node.hook.d.ts.map +1 -1
- package/dist/window/hooks/target-node.hook.js +14 -72
- package/dist/window/hooks/views-for.hook.d.ts +4 -3
- package/dist/window/hooks/views-for.hook.d.ts.map +1 -1
- package/dist/window/hooks/views-for.hook.js +6 -22
- package/dist/window/hooks/windows.hook.d.ts.map +1 -1
- package/dist/window/hooks/windows.hook.js +3 -4
- package/dist/window/host.d.ts +11 -11
- package/dist/window/host.d.ts.map +1 -1
- package/dist/window/host.js +38 -54
- package/dist/window/hub.d.ts +2 -0
- package/dist/window/hub.d.ts.map +1 -1
- package/dist/window/hub.js +33 -0
- package/dist/window/index.d.ts +3 -3
- package/dist/window/index.d.ts.map +1 -1
- package/dist/window/index.js +2 -2
- package/dist/window/lifecycle/mount.d.ts +5 -44
- package/dist/window/lifecycle/mount.d.ts.map +1 -1
- package/dist/window/lifecycle/mount.js +14 -120
- package/dist/window/lifecycle/states.d.ts +0 -5
- package/dist/window/lifecycle/states.d.ts.map +1 -1
- package/dist/window/stage.d.ts.map +1 -1
- package/dist/window/stage.js +1 -0
- package/package.json +9 -8
- package/src/application/apps/app-host.tsx +17 -18
- package/src/application/apps/apps.hook.ts +13 -6
- package/src/application/apps/domains.hook.ts +1 -1
- package/src/application/apps/open-app.hook.ts +3 -4
- package/src/application/index.ts +4 -6
- package/src/application/spaces/space.hook.ts +5 -6
- package/src/application/spaces/spaces.hook.ts +14 -9
- package/src/auth/act-as.context.tsx +37 -91
- package/src/auth/auth.hook.ts +2 -30
- package/src/auth/can.hook.ts +44 -135
- package/src/auth/index.ts +1 -0
- package/src/auth/self.hook.ts +2 -9
- package/src/auth/session-kernel.ts +6 -16
- package/src/components/boundaries.tsx +113 -0
- package/src/components/can.tsx +16 -0
- package/src/components/index.ts +14 -0
- package/src/components/mount-domain-frontend.tsx +158 -0
- package/src/components/view-app.tsx +49 -0
- package/src/graph/call/call.hook.ts +22 -27
- package/src/graph/call/stream.hook.ts +66 -143
- package/src/graph/graph.context.ts +6 -11
- package/src/graph/guards.error.ts +17 -55
- package/src/graph/index.ts +23 -17
- package/src/graph/memory/read/envelope.ts +40 -65
- package/src/graph/memory/read/idle.ts +5 -18
- package/src/graph/query-definition.hook.ts +270 -0
- package/src/graph/resource.ts +358 -0
- package/src/graph/store.ts +97 -0
- package/src/host/actions.hook.ts +165 -0
- package/src/host/components.tsx +29 -0
- package/src/host/index.ts +17 -0
- package/src/index.ts +137 -123
- package/src/intents/envelope.ts +7 -23
- package/src/intents/send-intent.hook.ts +24 -79
- package/src/navigation/adapters/adapter.ts +3 -0
- package/src/navigation/adapters/memory.adapter.ts +4 -0
- package/src/navigation/adapters/url.adapter.ts +48 -8
- package/src/navigation/codec.ts +190 -0
- package/src/navigation/history.ts +20 -11
- package/src/navigation/hooks/ancestors.hook.ts +10 -60
- package/src/navigation/hooks/location.hook.ts +4 -6
- package/src/navigation/hooks/scope.hook.ts +4 -6
- package/src/navigation/index.ts +18 -2
- package/src/navigation/link.tsx +27 -2
- package/src/navigation/location.ts +26 -93
- package/src/navigation/scope.context.tsx +151 -136
- package/src/navigation/snapshot.ts +69 -50
- package/src/schema/action.hook.ts +146 -0
- package/src/schema/domain.hook.ts +127 -11
- package/src/schema/index.ts +9 -30
- package/src/schema/kernel.hook.ts +6 -13
- package/src/schema/mutation.hook.ts +63 -0
- package/src/schema/object.hook.ts +85 -0
- package/src/schema/relation.hook.ts +253 -0
- package/src/selection/live.ts +75 -125
- package/src/selection/scope.context.tsx +4 -4
- package/src/session/boot/boot.ts +8 -33
- package/src/session/index.ts +1 -0
- package/src/session/kernel-instance.hook.ts +2 -11
- package/src/session/provider.tsx +34 -103
- package/src/session/session.context.ts +6 -0
- package/src/window/adopt.ts +0 -1
- package/src/window/hooks/target-node.hook.ts +20 -85
- package/src/window/hooks/views-for.hook.ts +12 -25
- package/src/window/hooks/windows.hook.ts +3 -4
- package/src/window/host.tsx +51 -68
- package/src/window/hub.ts +33 -0
- package/src/window/index.ts +4 -4
- package/src/window/lifecycle/mount.ts +15 -160
- package/src/window/lifecycle/states.ts +1 -5
- package/src/window/stage.tsx +1 -0
- package/dist/application/roles.hook.d.ts +0 -7
- package/dist/application/roles.hook.d.ts.map +0 -1
- package/dist/application/roles.hook.js +0 -23
- package/dist/graph/memory/base.d.ts +0 -21
- package/dist/graph/memory/base.d.ts.map +0 -1
- package/dist/graph/memory/base.js +0 -33
- package/dist/graph/memory/read/read.d.ts +0 -9
- package/dist/graph/memory/read/read.d.ts.map +0 -1
- package/dist/graph/memory/read/read.js +0 -87
- package/dist/graph/memory/scope.d.ts +0 -7
- package/dist/graph/memory/scope.d.ts.map +0 -1
- package/dist/graph/memory/scope.js +0 -25
- package/dist/graph/mutate/move.hook.d.ts +0 -7
- package/dist/graph/mutate/move.hook.d.ts.map +0 -1
- package/dist/graph/mutate/move.hook.js +0 -49
- package/dist/graph/mutate/mutate.hook.d.ts +0 -17
- package/dist/graph/mutate/mutate.hook.d.ts.map +0 -1
- package/dist/graph/mutate/mutate.hook.js +0 -45
- package/dist/graph/query/children.hook.d.ts +0 -29
- package/dist/graph/query/children.hook.d.ts.map +0 -1
- package/dist/graph/query/children.hook.js +0 -64
- package/dist/graph/query/graph.hook.d.ts +0 -9
- package/dist/graph/query/graph.hook.d.ts.map +0 -1
- package/dist/graph/query/graph.hook.js +0 -5
- package/dist/graph/query/neighbors.hook.d.ts +0 -7
- package/dist/graph/query/neighbors.hook.d.ts.map +0 -1
- package/dist/graph/query/neighbors.hook.js +0 -104
- package/dist/graph/query/node.hook.d.ts +0 -14
- package/dist/graph/query/node.hook.d.ts.map +0 -1
- package/dist/graph/query/node.hook.js +0 -43
- package/dist/graph/query/query.hook.d.ts +0 -14
- package/dist/graph/query/query.hook.d.ts.map +0 -1
- package/dist/graph/query/query.hook.js +0 -23
- package/dist/schema/bind-read.d.ts +0 -37
- package/dist/schema/bind-read.d.ts.map +0 -1
- package/dist/schema/bind-read.js +0 -205
- package/dist/schema/binding.d.ts +0 -21
- package/dist/schema/binding.d.ts.map +0 -1
- package/dist/schema/binding.js +0 -99
- package/dist/schema/function.hook.d.ts +0 -9
- package/dist/schema/function.hook.d.ts.map +0 -1
- package/dist/schema/function.hook.js +0 -40
- package/dist/schema/method.hook.d.ts +0 -14
- package/dist/schema/method.hook.d.ts.map +0 -1
- package/dist/schema/method.hook.js +0 -49
- package/dist/schema/tag.d.ts +0 -11
- package/dist/schema/tag.d.ts.map +0 -1
- package/dist/schema/tag.js +0 -11
- package/dist/schema/types.d.ts +0 -73
- package/dist/schema/types.d.ts.map +0 -1
- package/dist/schema/types.js +0 -1
- package/dist/schema/write.d.ts +0 -16
- package/dist/schema/write.d.ts.map +0 -1
- package/dist/schema/write.js +0 -56
- package/src/application/roles.hook.ts +0 -41
- package/src/graph/memory/base.ts +0 -50
- package/src/graph/memory/read/read.ts +0 -103
- package/src/graph/memory/scope.ts +0 -29
- package/src/graph/mutate/move.hook.ts +0 -70
- package/src/graph/mutate/mutate.hook.ts +0 -69
- package/src/graph/query/children.hook.ts +0 -136
- package/src/graph/query/graph.hook.ts +0 -13
- package/src/graph/query/neighbors.hook.ts +0 -159
- package/src/graph/query/node.hook.ts +0 -83
- package/src/graph/query/query.hook.ts +0 -42
- package/src/schema/bind-read.ts +0 -319
- package/src/schema/binding.ts +0 -146
- package/src/schema/function.hook.ts +0 -68
- package/src/schema/method.hook.ts +0 -103
- package/src/schema/tag.ts +0 -19
- package/src/schema/types.ts +0 -150
- package/src/schema/write.ts +0 -96
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../../src/navigation/snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../../src/navigation/snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAA;AACjE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAA;AACtD,OAAO,KAAK,EAAY,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AACpE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAA;AACjD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAM9C,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAElE,uFAAuF;AACvF,MAAM,MAAM,SAAS,GACjB,QAAQ,GACR,IAAI,GACJ;IACE,QAAQ,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAA;IAC9B,QAAQ,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,IAAI,CAAA;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACzC,CAAA;AAgBL,qEAAqE;AACrE,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,GAAG,kBAAkB,CAOrE;AAQD,6FAA6F;AAC7F,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,UAAU,EACnB,KAAK,EAAE,UAAU,EACjB,KAAK,EAAE,KAAK,GACX,OAAO,CAAC,OAAO,CAAC,CAkBlB"}
|
|
@@ -1,63 +1,67 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { normalizeRef } from '@astrale-os/kernel-client';
|
|
7
|
-
function isRecord(x) {
|
|
8
|
-
return typeof x === 'object' && x !== null;
|
|
1
|
+
import { Path } from '@astrale-os/sdk/graph/path';
|
|
2
|
+
import { Query } from '@astrale-os/sdk/query';
|
|
3
|
+
import { Key as admitKey } from '@astrale-os/sdk/schema';
|
|
4
|
+
function isNode(value) {
|
|
5
|
+
return typeof value === 'object' && value !== null && 'id' in value && 'class' in value;
|
|
9
6
|
}
|
|
10
|
-
|
|
7
|
+
function nodePath(value) {
|
|
8
|
+
return isNode(value) ? Path.id(value.id).raw : Path.from(value).raw;
|
|
9
|
+
}
|
|
10
|
+
function isComposite(value) {
|
|
11
|
+
return typeof value === 'object' && value !== null && 'node' in value;
|
|
12
|
+
}
|
|
13
|
+
/** Normalize every target to canonical astrale-node-path-v1 text. */
|
|
11
14
|
export function serializeTarget(target) {
|
|
12
|
-
if (
|
|
13
|
-
return { node:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return { node: normalizeRef(target.id) };
|
|
26
|
-
}
|
|
27
|
-
return { node: normalizeRef(target) };
|
|
15
|
+
if (!isComposite(target))
|
|
16
|
+
return { node: nodePath(target) };
|
|
17
|
+
return {
|
|
18
|
+
node: nodePath(target.node),
|
|
19
|
+
...(target.view === undefined ? {} : { view: viewKey(target.view) }),
|
|
20
|
+
...(target.params === undefined ? {} : { params: { ...target.params } }),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function viewKey(input) {
|
|
24
|
+
const key = admitKey(input);
|
|
25
|
+
if (!admitKey.ref(key).startsWith('view.'))
|
|
26
|
+
throw new TypeError(`Invalid View key '${input}'.`);
|
|
27
|
+
return key;
|
|
28
28
|
}
|
|
29
|
-
/**
|
|
30
|
-
|
|
31
|
-
* Each entry is point-read one-shot; a null/failed read is a dead anchor. The
|
|
32
|
-
* cursor re-lands on the surviving current entry, else the nearest survivor
|
|
33
|
-
* before it.
|
|
34
|
-
*/
|
|
35
|
-
export async function revalidateAndPrune(history, memory) {
|
|
29
|
+
/** Drop restored entries that no longer resolve under the authenticated Graph capability. */
|
|
30
|
+
export async function revalidateAndPrune(history, store, shell) {
|
|
36
31
|
const { entries, cursor } = history.snapshot();
|
|
37
|
-
const alive = await Promise.all(entries.map((
|
|
32
|
+
const alive = await Promise.all(entries.map((entry) => resolves(store, shell, entry)));
|
|
38
33
|
if (alive.every(Boolean))
|
|
39
|
-
return;
|
|
34
|
+
return false;
|
|
40
35
|
const survivors = [];
|
|
41
36
|
let newCursor = -1;
|
|
42
37
|
let fallback = -1;
|
|
43
|
-
entries.forEach((entry,
|
|
44
|
-
if (!alive[
|
|
38
|
+
entries.forEach((entry, index) => {
|
|
39
|
+
if (!alive[index])
|
|
45
40
|
return;
|
|
46
41
|
survivors.push(entry);
|
|
47
|
-
const
|
|
48
|
-
if (
|
|
49
|
-
newCursor =
|
|
50
|
-
else if (
|
|
51
|
-
fallback =
|
|
42
|
+
const next = survivors.length - 1;
|
|
43
|
+
if (index === cursor)
|
|
44
|
+
newCursor = next;
|
|
45
|
+
else if (index < cursor)
|
|
46
|
+
fallback = next;
|
|
52
47
|
});
|
|
53
48
|
if (newCursor === -1)
|
|
54
49
|
newCursor = fallback !== -1 ? fallback : survivors.length > 0 ? 0 : -1;
|
|
55
50
|
history.reset(survivors, newCursor);
|
|
51
|
+
return true;
|
|
56
52
|
}
|
|
57
|
-
async function resolves(
|
|
53
|
+
async function resolves(store, shell, entry) {
|
|
58
54
|
try {
|
|
59
|
-
const
|
|
60
|
-
|
|
55
|
+
const query = Query.from({ kind: 'node', paths: [entry.node] }).select({ kind: 'graph' });
|
|
56
|
+
const response = await store.read(query, { page: { size: 1 } });
|
|
57
|
+
if (response.result.kind !== 'graph' ||
|
|
58
|
+
response.result.selection.kind !== 'node' ||
|
|
59
|
+
response.result.selection.ids.length === 0)
|
|
60
|
+
return false;
|
|
61
|
+
if (entry.view === undefined)
|
|
62
|
+
return true;
|
|
63
|
+
const routes = await shell.views.resolve(entry.node);
|
|
64
|
+
return routes.some((candidate) => candidate.route.key === entry.view);
|
|
61
65
|
}
|
|
62
66
|
catch {
|
|
63
67
|
return false;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { InputOf, InstanceMethod, OutputOf, ReceiverOf, RemoteCallableOf } from '@astrale-os/sdk/domain';
|
|
2
|
+
import type { QueryAST } from '@astrale-os/sdk/query';
|
|
3
|
+
import type { schema } from '@astrale-os/sdk/schema';
|
|
4
|
+
import type { DomainInvokeOptions } from '@astrale-os/shell';
|
|
5
|
+
type Callable = RemoteCallableOf<schema.DomainSchema> | InstanceMethod;
|
|
6
|
+
declare const QUERY_REFRESH: unique symbol;
|
|
7
|
+
export interface QueryRefresh {
|
|
8
|
+
readonly id: string;
|
|
9
|
+
readonly [QUERY_REFRESH]: () => {
|
|
10
|
+
readonly ast: QueryAST;
|
|
11
|
+
readonly page: Readonly<{
|
|
12
|
+
readonly size: number;
|
|
13
|
+
}>;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
type RefreshableQuery<Input, Query extends QueryAST> = {
|
|
17
|
+
readonly id: string;
|
|
18
|
+
readonly page: Readonly<{
|
|
19
|
+
readonly size: number;
|
|
20
|
+
}>;
|
|
21
|
+
prepare?(input: Input): Input;
|
|
22
|
+
build(input: Input): Query;
|
|
23
|
+
};
|
|
24
|
+
/** Pair one exact named Query definition with its admitted input for targeted invalidation. */
|
|
25
|
+
export declare function queryRefresh<Input, Query extends QueryAST>(definition: RefreshableQuery<Input, Query>, input: Input): QueryRefresh;
|
|
26
|
+
export type ActionRefresh = 'all' | 'none' | {
|
|
27
|
+
readonly queries: readonly QueryRefresh[];
|
|
28
|
+
};
|
|
29
|
+
export interface ActionOptions extends DomainInvokeOptions {
|
|
30
|
+
readonly refresh?: ActionRefresh;
|
|
31
|
+
readonly onError?: (error: unknown) => void;
|
|
32
|
+
}
|
|
33
|
+
type ActionArgs<C extends Callable> = C extends InstanceMethod ? [receiver: ReceiverOf<C>, input: InputOf<C>] : [input: InputOf<C>];
|
|
34
|
+
export interface DomainAction<Args extends unknown[], Result> {
|
|
35
|
+
run(...args: Args): Promise<Result>;
|
|
36
|
+
readonly pending: boolean;
|
|
37
|
+
readonly error: unknown;
|
|
38
|
+
readonly result: Result | undefined;
|
|
39
|
+
reset(): void;
|
|
40
|
+
}
|
|
41
|
+
/** Invoke one schema-declared Function or Method and invalidate Store by explicit policy. */
|
|
42
|
+
export declare function useAction<C extends Callable>(callable: C, options?: ActionOptions): DomainAction<ActionArgs<C>, OutputOf<C>>;
|
|
43
|
+
export {};
|
|
44
|
+
//# sourceMappingURL=action.hook.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action.hook.d.ts","sourceRoot":"","sources":["../../src/schema/action.hook.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,cAAc,EACd,QAAQ,EACR,UAAU,EACV,gBAAgB,EACjB,MAAM,wBAAwB,CAAA;AAE/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AACpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAW5D,KAAK,QAAQ,GAAG,gBAAgB,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,cAAc,CAAA;AAEtE,QAAA,MAAM,aAAa,eAAsC,CAAA;AAEzD,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,CAAC,aAAa,CAAC,EAAE,MAAM;QAC9B,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAA;QACtB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;YAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KACnD,CAAA;CACF;AAED,KAAK,gBAAgB,CAAC,KAAK,EAAE,KAAK,SAAS,QAAQ,IAAI;IACrD,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IAClD,OAAO,CAAC,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAAA;IAC7B,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAAA;CAC3B,CAAA;AAED,+FAA+F;AAC/F,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,SAAS,QAAQ,EACxD,UAAU,EAAE,gBAAgB,CAAC,KAAK,EAAE,KAAK,CAAC,EAC1C,KAAK,EAAE,KAAK,GACX,YAAY,CAQd;AAED,MAAM,MAAM,aAAa,GACrB,KAAK,GACL,MAAM,GACN;IACE,QAAQ,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,CAAA;CAC1C,CAAA;AAEL,MAAM,WAAW,aAAc,SAAQ,mBAAmB;IACxD,QAAQ,CAAC,OAAO,CAAC,EAAE,aAAa,CAAA;IAChC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;CAC5C;AAED,KAAK,UAAU,CAAC,CAAC,SAAS,QAAQ,IAAI,CAAC,SAAS,cAAc,GAC1D,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,GAC5C,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAA;AAEvB,MAAM,WAAW,YAAY,CAAC,IAAI,SAAS,OAAO,EAAE,EAAE,MAAM;IAC1D,GAAG,CAAC,GAAG,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IACnC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;IACnC,KAAK,IAAI,IAAI,CAAA;CACd;AAED,6FAA6F;AAC7F,wBAAgB,SAAS,CAAC,CAAC,SAAS,QAAQ,EAC1C,QAAQ,EAAE,CAAC,EACX,OAAO,GAAE,aAAkB,GAC1B,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAyC1C"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Path } from '@astrale-os/sdk/graph/path';
|
|
2
|
+
import { useCallback, useMemo, useRef } from 'react';
|
|
3
|
+
import { useAction as useAsyncAction } from '../graph/action.js';
|
|
4
|
+
import { useGraphStore } from '../graph/store.js';
|
|
5
|
+
import { bindingFor } from './domain.hook.js';
|
|
6
|
+
const QUERY_REFRESH = Symbol('shell-react.query-refresh');
|
|
7
|
+
/** Pair one exact named Query definition with its admitted input for targeted invalidation. */
|
|
8
|
+
export function queryRefresh(definition, input) {
|
|
9
|
+
return Object.freeze({
|
|
10
|
+
id: definition.id,
|
|
11
|
+
[QUERY_REFRESH]: () => {
|
|
12
|
+
const prepared = definition.prepare?.(input) ?? input;
|
|
13
|
+
return Object.freeze({ ast: definition.build(prepared), page: definition.page });
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
/** Invoke one schema-declared Function or Method and invalidate Store by explicit policy. */
|
|
18
|
+
export function useAction(callable, options = {}) {
|
|
19
|
+
const binding = bindingFor(callable);
|
|
20
|
+
const store = useGraphStore();
|
|
21
|
+
const callableRef = useRef(callable);
|
|
22
|
+
callableRef.current = callable;
|
|
23
|
+
const bindingRef = useRef(binding);
|
|
24
|
+
bindingRef.current = binding;
|
|
25
|
+
const optionsRef = useRef(options);
|
|
26
|
+
optionsRef.current = options;
|
|
27
|
+
const invoke = useCallback(async (...args) => {
|
|
28
|
+
const current = callableRef.current;
|
|
29
|
+
const policy = optionsRef.current;
|
|
30
|
+
const { refresh: _refresh, onError: _onError, ...request } = policy;
|
|
31
|
+
try {
|
|
32
|
+
const invokeExact = bindingRef.current.$.invoke;
|
|
33
|
+
const result = 'on' in current
|
|
34
|
+
? await invokeExact(current, receiverPath(args[0]), args[1], request)
|
|
35
|
+
: await invokeExact(current, args[0], request);
|
|
36
|
+
const refresh = policy.refresh ?? 'all';
|
|
37
|
+
if (refresh === 'all')
|
|
38
|
+
store.invalidate();
|
|
39
|
+
else if (refresh !== 'none') {
|
|
40
|
+
refresh.queries.forEach((query) => {
|
|
41
|
+
const target = query[QUERY_REFRESH]();
|
|
42
|
+
store.invalidate(target.ast, { page: target.page });
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
policy.onError?.(error);
|
|
49
|
+
throw error;
|
|
50
|
+
}
|
|
51
|
+
}, [store]);
|
|
52
|
+
const action = useAsyncAction(invoke);
|
|
53
|
+
return useMemo(() => projectAction(action), [action]);
|
|
54
|
+
}
|
|
55
|
+
function projectAction(action) {
|
|
56
|
+
return {
|
|
57
|
+
run: (...args) => action(...args),
|
|
58
|
+
get pending() {
|
|
59
|
+
return action.pending;
|
|
60
|
+
},
|
|
61
|
+
get error() {
|
|
62
|
+
return action.error;
|
|
63
|
+
},
|
|
64
|
+
get result() {
|
|
65
|
+
return action.result;
|
|
66
|
+
},
|
|
67
|
+
reset: action.reset,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function receiverPath(receiver) {
|
|
71
|
+
return Path.id(receiver.id).raw;
|
|
72
|
+
}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
+
import type { DomainBinding } from '@astrale-os/shell';
|
|
2
|
+
import { schema } from '@astrale-os/sdk/schema';
|
|
1
3
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* shared scoped memory, so typed writes are optimistic and revalidate (§6).
|
|
4
|
+
* Resolve an exact verified DomainBinding. The first render suspends while Session snapshot and schema
|
|
5
|
+
* revision checks complete; later renders return the retained binding synchronously.
|
|
5
6
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
export declare function useDomain<const S extends schema.DomainSchema>(schema: S): DomainBinding<S>;
|
|
8
|
+
/** Dynamic verified root binding used by tools that intentionally do not carry a schema witness. */
|
|
9
|
+
export declare function useDynamicDomain(): DomainBinding;
|
|
10
|
+
/** Bind several exact installed schemas behind one Suspense boundary and stable named result. */
|
|
11
|
+
export declare function useDomains<const Schemas extends Readonly<Record<string, schema.DomainSchema>>>(schemas: Schemas): {
|
|
12
|
+
readonly [Name in keyof Schemas]: DomainBinding<Schemas[Name]>;
|
|
13
|
+
};
|
|
14
|
+
export declare function bindingFor(value: object): DomainBinding;
|
|
10
15
|
//# sourceMappingURL=domain.hook.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domain.hook.d.ts","sourceRoot":"","sources":["../../src/schema/domain.hook.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"domain.hook.d.ts","sourceRoot":"","sources":["../../src/schema/domain.hook.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAgB,MAAM,mBAAmB,CAAA;AAEpE,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAiB/C;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,YAAY,EAAE,MAAM,EAAE,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAe1F;AAED,oGAAoG;AACpG,wBAAgB,gBAAgB,IAAI,aAAa,CAUhD;AAED,iGAAiG;AACjG,wBAAgB,UAAU,CAAC,KAAK,CAAC,OAAO,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,YAAY,CAAC,CAAC,EAC5F,OAAO,EAAE,OAAO,GACf;IAAE,QAAQ,EAAE,IAAI,IAAI,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;CAAE,CAwBpE;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,CAMvD"}
|
|
@@ -1,7 +1,104 @@
|
|
|
1
|
+
import { schema } from '@astrale-os/sdk/schema';
|
|
1
2
|
import { useSessionKernel } from '../auth/session-kernel.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
const typed = new WeakMap();
|
|
4
|
+
const dynamic = new WeakMap();
|
|
5
|
+
const aggregates = new WeakMap();
|
|
6
|
+
const bindingByValue = new WeakMap();
|
|
7
|
+
/**
|
|
8
|
+
* Resolve an exact verified DomainBinding. The first render suspends while Session snapshot and schema
|
|
9
|
+
* revision checks complete; later renders return the retained binding synchronously.
|
|
10
|
+
*/
|
|
5
11
|
export function useDomain(schema) {
|
|
6
|
-
|
|
12
|
+
const kernel = useSessionKernel();
|
|
13
|
+
let bySchema = typed.get(kernel);
|
|
14
|
+
if (bySchema === undefined) {
|
|
15
|
+
bySchema = new WeakMap();
|
|
16
|
+
typed.set(kernel, bySchema);
|
|
17
|
+
}
|
|
18
|
+
let resource = bySchema.get(schema);
|
|
19
|
+
if (resource === undefined) {
|
|
20
|
+
resource = createResource(kernel.domain(schema));
|
|
21
|
+
bySchema.set(schema, resource);
|
|
22
|
+
}
|
|
23
|
+
const binding = read(resource);
|
|
24
|
+
registerBinding(binding);
|
|
25
|
+
return binding;
|
|
26
|
+
}
|
|
27
|
+
/** Dynamic verified root binding used by tools that intentionally do not carry a schema witness. */
|
|
28
|
+
export function useDynamicDomain() {
|
|
29
|
+
const kernel = useSessionKernel();
|
|
30
|
+
let resource = dynamic.get(kernel);
|
|
31
|
+
if (resource === undefined) {
|
|
32
|
+
resource = createResource(kernel.domain());
|
|
33
|
+
dynamic.set(kernel, resource);
|
|
34
|
+
}
|
|
35
|
+
const binding = read(resource);
|
|
36
|
+
registerBinding(binding);
|
|
37
|
+
return binding;
|
|
38
|
+
}
|
|
39
|
+
/** Bind several exact installed schemas behind one Suspense boundary and stable named result. */
|
|
40
|
+
export function useDomains(schemas) {
|
|
41
|
+
const kernel = useSessionKernel();
|
|
42
|
+
const names = Object.keys(schemas).sort();
|
|
43
|
+
if (names.length === 0)
|
|
44
|
+
return Object.freeze({});
|
|
45
|
+
const key = names
|
|
46
|
+
.map((name) => `${name}\u0000${schemas[name].origin}\u0000${schema.revision(schemas[name])}`)
|
|
47
|
+
.join('\u0001');
|
|
48
|
+
let bySet = aggregates.get(kernel);
|
|
49
|
+
if (bySet === undefined) {
|
|
50
|
+
bySet = new Map();
|
|
51
|
+
aggregates.set(kernel, bySet);
|
|
52
|
+
}
|
|
53
|
+
let resource = bySet.get(key);
|
|
54
|
+
if (resource === undefined) {
|
|
55
|
+
resource = createResource(Promise.all(names.map(async (name) => [name, await kernel.domain(schemas[name])])).then((entries) => Object.freeze(Object.fromEntries(entries))));
|
|
56
|
+
bySet.set(key, resource);
|
|
57
|
+
}
|
|
58
|
+
const values = read(resource);
|
|
59
|
+
Object.values(values).forEach(registerBinding);
|
|
60
|
+
return values;
|
|
61
|
+
}
|
|
62
|
+
export function bindingFor(value) {
|
|
63
|
+
const binding = bindingByValue.get(value);
|
|
64
|
+
if (binding === undefined) {
|
|
65
|
+
throw new Error('The definition is not owned by a Domain bound in this React runtime.');
|
|
66
|
+
}
|
|
67
|
+
return binding;
|
|
68
|
+
}
|
|
69
|
+
function registerBinding(binding) {
|
|
70
|
+
const seen = new WeakSet();
|
|
71
|
+
const visit = (value, depth) => {
|
|
72
|
+
if (depth > 4 || value === null || typeof value !== 'object' || seen.has(value))
|
|
73
|
+
return;
|
|
74
|
+
seen.add(value);
|
|
75
|
+
bindingByValue.set(value, binding);
|
|
76
|
+
for (const [key, child] of Object.entries(value)) {
|
|
77
|
+
if (key === 'schema' || key === 'publication' || key === 'session')
|
|
78
|
+
continue;
|
|
79
|
+
visit(child, depth + 1);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
visit(binding, 0);
|
|
83
|
+
}
|
|
84
|
+
function createResource(promise) {
|
|
85
|
+
const cell = {
|
|
86
|
+
status: 'pending',
|
|
87
|
+
promise: Promise.resolve(),
|
|
88
|
+
};
|
|
89
|
+
cell.promise = promise.then((value) => {
|
|
90
|
+
cell.status = 'ready';
|
|
91
|
+
cell.value = value;
|
|
92
|
+
}, (error) => {
|
|
93
|
+
cell.status = 'failed';
|
|
94
|
+
cell.error = error;
|
|
95
|
+
});
|
|
96
|
+
return cell;
|
|
97
|
+
}
|
|
98
|
+
function read(resource) {
|
|
99
|
+
if (resource.status === 'pending')
|
|
100
|
+
throw resource.promise;
|
|
101
|
+
if (resource.status === 'failed')
|
|
102
|
+
throw resource.error;
|
|
103
|
+
return resource.value;
|
|
7
104
|
}
|
package/dist/schema/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export { useKernel } from './kernel.hook.js';
|
|
2
|
-
export { useDomain } from './domain.hook.js';
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export type {
|
|
7
|
-
export {
|
|
8
|
-
export type {
|
|
9
|
-
export
|
|
2
|
+
export { useDomain, useDomains, useDynamicDomain } from './domain.hook.js';
|
|
3
|
+
export { queryRefresh, useAction } from './action.hook.js';
|
|
4
|
+
export type { ActionOptions, ActionRefresh, DomainAction, QueryRefresh } from './action.hook.js';
|
|
5
|
+
export { useMutation } from './mutation.hook.js';
|
|
6
|
+
export type { MutationOptions } from './mutation.hook.js';
|
|
7
|
+
export { useDynamicObject, useObject } from './object.hook.js';
|
|
8
|
+
export type { RichReadOptions } from './object.hook.js';
|
|
9
|
+
export { RelationUnavailableError, useRelation } from './relation.hook.js';
|
|
10
|
+
export type { RelationOptions, RelationResource, RelationUnavailable } from './relation.hook.js';
|
|
10
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schema/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schema/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAC1E,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC1D,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAChG,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAChD,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACzD,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC9D,YAAY,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AACvD,OAAO,EAAE,wBAAwB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAC1E,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA"}
|
package/dist/schema/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
// schema — the typing substrate (API §6). Typed kernel/domain bindings, typed
|
|
2
|
-
// reads, method/function dispatch. See SHELL_REACT_API.md.
|
|
3
1
|
export { useKernel } from './kernel.hook.js';
|
|
4
|
-
export { useDomain } from './domain.hook.js';
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
2
|
+
export { useDomain, useDomains, useDynamicDomain } from './domain.hook.js';
|
|
3
|
+
export { queryRefresh, useAction } from './action.hook.js';
|
|
4
|
+
export { useMutation } from './mutation.hook.js';
|
|
5
|
+
export { useDynamicObject, useObject } from './object.hook.js';
|
|
6
|
+
export { RelationUnavailableError, useRelation } from './relation.hook.js';
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*/
|
|
6
|
-
import type { FnMap, SchemaBoundView } from '@astrale-os/kernel-client';
|
|
7
|
-
import { KernelSchema } from '@astrale-os/kernel-core';
|
|
8
|
-
/** The typed kernel — `kernel.withSchema(KernelSchema)`, memoized (§4-scoped). */
|
|
9
|
-
export declare function useKernel(): SchemaBoundView<typeof KernelSchema, FnMap>;
|
|
1
|
+
import type { DomainBinding } from '@astrale-os/shell';
|
|
2
|
+
import { KernelSchema } from '@astrale-os/sdk/schema/kernel';
|
|
3
|
+
/** The verified, exactly typed Kernel Domain binding. */
|
|
4
|
+
export declare function useKernel(): DomainBinding<typeof KernelSchema>;
|
|
10
5
|
//# sourceMappingURL=kernel.hook.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kernel.hook.d.ts","sourceRoot":"","sources":["../../src/schema/kernel.hook.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"kernel.hook.d.ts","sourceRoot":"","sources":["../../src/schema/kernel.hook.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAI5D,yDAAyD;AACzD,wBAAgB,SAAS,IAAI,aAAa,CAAC,OAAO,YAAY,CAAC,CAE9D"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { KernelSchema } from '@astrale-os/kernel
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { bindingFor } from './binding.js';
|
|
5
|
-
/** The typed kernel — `kernel.withSchema(KernelSchema)`, memoized (§4-scoped). */
|
|
1
|
+
import { KernelSchema } from '@astrale-os/sdk/schema/kernel';
|
|
2
|
+
import { useDomain } from './domain.hook.js';
|
|
3
|
+
/** The verified, exactly typed Kernel Domain binding. */
|
|
6
4
|
export function useKernel() {
|
|
7
|
-
return
|
|
5
|
+
return useDomain(KernelSchema);
|
|
8
6
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { MutationDefinition } from '@astrale-os/sdk/mutation';
|
|
2
|
+
import type { DomainAction } from './action.hook.js';
|
|
3
|
+
export interface MutationOptions {
|
|
4
|
+
readonly optimistic?: boolean;
|
|
5
|
+
readonly onError?: (error: unknown) => void;
|
|
6
|
+
}
|
|
7
|
+
/** Execute one named SDK Mutation definition through GraphStore optimism/invalidation. */
|
|
8
|
+
export declare function useMutation<Input, Output>(definition: MutationDefinition<Input, Output>, options?: MutationOptions): DomainAction<[Input], Output>;
|
|
9
|
+
//# sourceMappingURL=mutation.hook.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutation.hook.d.ts","sourceRoot":"","sources":["../../src/schema/mutation.hook.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAMlE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAKpD,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAA;IAC7B,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;CAC5C;AAED,0FAA0F;AAC1F,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EACvC,UAAU,EAAE,kBAAkB,CAAC,KAAK,EAAE,MAAM,CAAC,EAC7C,OAAO,GAAE,eAAoB,GAC5B,YAAY,CAAC,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,CAwB/B"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { bindMutations } from '@astrale-os/sdk/mutation';
|
|
2
|
+
import { useCallback, useMemo, useRef } from 'react';
|
|
3
|
+
import { useAction as useAsyncAction } from '../graph/action.js';
|
|
4
|
+
import { useGraphStore } from '../graph/store.js';
|
|
5
|
+
/** Execute one named SDK Mutation definition through GraphStore optimism/invalidation. */
|
|
6
|
+
export function useMutation(definition, options = {}) {
|
|
7
|
+
const store = useGraphStore();
|
|
8
|
+
const definitionRef = useRef(definition);
|
|
9
|
+
definitionRef.current = definition;
|
|
10
|
+
const optionsRef = useRef(options);
|
|
11
|
+
optionsRef.current = options;
|
|
12
|
+
const run = useCallback(async (input) => {
|
|
13
|
+
const execute = bindMutations((ast) => store.mutate(ast, {
|
|
14
|
+
optimistic: optionsRef.current.optimistic ?? true,
|
|
15
|
+
}));
|
|
16
|
+
try {
|
|
17
|
+
return await execute(definitionRef.current, input);
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
optionsRef.current.onError?.(error);
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
23
|
+
}, [store]);
|
|
24
|
+
const action = useAsyncAction(run);
|
|
25
|
+
return useMemo(() => project(action), [action]);
|
|
26
|
+
}
|
|
27
|
+
function project(action) {
|
|
28
|
+
return {
|
|
29
|
+
run: (input) => action(input),
|
|
30
|
+
get pending() {
|
|
31
|
+
return action.pending;
|
|
32
|
+
},
|
|
33
|
+
get error() {
|
|
34
|
+
return action.error;
|
|
35
|
+
},
|
|
36
|
+
get result() {
|
|
37
|
+
return action.result;
|
|
38
|
+
},
|
|
39
|
+
reset: action.reset,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { BoundInstanceOf, Definition } from '@astrale-os/sdk/domain';
|
|
2
|
+
import type { Node } from '@astrale-os/sdk/graph/node';
|
|
3
|
+
import type { PathLike } from '@astrale-os/sdk/graph/path';
|
|
4
|
+
import type { GraphResource } from '../graph/resource.js';
|
|
5
|
+
export interface RichReadOptions {
|
|
6
|
+
readonly pageSize?: number;
|
|
7
|
+
}
|
|
8
|
+
type ObjectDefinition = Pick<Definition<'class' | 'interface'>, 'kind' | 'origin' | 'name' | 'key' | 'schemaRef' | 'definition'> & {
|
|
9
|
+
readonly family: 'node';
|
|
10
|
+
};
|
|
11
|
+
/** Read and bind one exact rich object definition exclusively through GraphStore. */
|
|
12
|
+
export declare function useObject<RichDefinition extends ObjectDefinition>(definition: RichDefinition, target: PathLike | null | undefined, options?: RichReadOptions): GraphResource<BoundInstanceOf<RichDefinition> | null>;
|
|
13
|
+
/** Explicitly untyped point read for inspectors; it never impersonates `useObject`. */
|
|
14
|
+
export declare function useDynamicObject(target: PathLike | null | undefined, options?: RichReadOptions): GraphResource<Node | null>;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=object.hook.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object.hook.d.ts","sourceRoot":"","sources":["../../src/schema/object.hook.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACzE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAA;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AAM1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAKzD,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAC3B;AAED,KAAK,gBAAgB,GAAG,IAAI,CAC1B,UAAU,CAAC,OAAO,GAAG,WAAW,CAAC,EACjC,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,KAAK,GAAG,WAAW,GAAG,YAAY,CAChE,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAA;AAE/B,qFAAqF;AACrF,wBAAgB,SAAS,CAAC,cAAc,SAAS,gBAAgB,EAC/D,UAAU,EAAE,cAAc,EAC1B,MAAM,EAAE,QAAQ,GAAG,IAAI,GAAG,SAAS,EACnC,OAAO,GAAE,eAAoB,GAC5B,aAAa,CAAC,eAAe,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,CA8BvD;AAED,uFAAuF;AACvF,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,QAAQ,GAAG,IAAI,GAAG,SAAS,EACnC,OAAO,GAAE,eAAoB,GAC5B,aAAa,CAAC,IAAI,GAAG,IAAI,CAAC,CAoB5B"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Path } from '@astrale-os/sdk/graph/path';
|
|
2
|
+
import { Query } from '@astrale-os/sdk/query';
|
|
3
|
+
import { useCallback, useMemo } from 'react';
|
|
4
|
+
import { useStoreResource } from '../graph/resource.js';
|
|
5
|
+
import { bindingFor } from './domain.hook.js';
|
|
6
|
+
/** Read and bind one exact rich object definition exclusively through GraphStore. */
|
|
7
|
+
export function useObject(definition, target, options = {}) {
|
|
8
|
+
const binding = bindingFor(definition);
|
|
9
|
+
const path = target === null || target === undefined ? null : Path.from(target);
|
|
10
|
+
const query = useMemo(() => path === null
|
|
11
|
+
? null
|
|
12
|
+
: Query.from({ kind: 'node', paths: [path], binding: 'object' })
|
|
13
|
+
.filter({ satisfies: definition.schemaRef })
|
|
14
|
+
.select({ kind: 'graph' }), [definition, path?.raw]);
|
|
15
|
+
const project = useCallback((response) => {
|
|
16
|
+
const result = response.result;
|
|
17
|
+
if (result.kind !== 'graph' || result.selection.kind !== 'node')
|
|
18
|
+
return null;
|
|
19
|
+
const id = result.selection.ids[0];
|
|
20
|
+
const node = id === undefined
|
|
21
|
+
? undefined
|
|
22
|
+
: result.graph.nodes.find((candidate) => candidate.id === id);
|
|
23
|
+
const bind = binding.$.bind;
|
|
24
|
+
return node === undefined ? null : bind(definition, node);
|
|
25
|
+
}, [binding, definition]);
|
|
26
|
+
return useStoreResource(query, options.pageSize ?? 1, project);
|
|
27
|
+
}
|
|
28
|
+
/** Explicitly untyped point read for inspectors; it never impersonates `useObject`. */
|
|
29
|
+
export function useDynamicObject(target, options = {}) {
|
|
30
|
+
const path = target === null || target === undefined ? null : Path.from(target);
|
|
31
|
+
const query = useMemo(() => path === null
|
|
32
|
+
? null
|
|
33
|
+
: Query.from({ kind: 'node', paths: [path], binding: 'dynamic_object' }).select({
|
|
34
|
+
kind: 'graph',
|
|
35
|
+
}), [path?.raw]);
|
|
36
|
+
const project = useCallback((response) => {
|
|
37
|
+
const result = response.result;
|
|
38
|
+
if (result.kind !== 'graph' || result.selection.kind !== 'node')
|
|
39
|
+
return null;
|
|
40
|
+
const id = result.selection.ids[0];
|
|
41
|
+
return id === undefined
|
|
42
|
+
? null
|
|
43
|
+
: (result.graph.nodes.find((candidate) => candidate.id === id) ?? null);
|
|
44
|
+
}, []);
|
|
45
|
+
return useStoreResource(query, options.pageSize ?? 1, project);
|
|
46
|
+
}
|