@xyo-network/react-sentinel 7.5.8 → 7.5.11
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/browser/contexts/Provider.d.ts.map +1 -1
- package/dist/browser/contexts/use.d.ts +4 -4
- package/dist/browser/index.mjs +147 -177
- package/dist/browser/index.mjs.map +1 -1
- package/package.json +152 -50
- package/src/components/Card/Card.stories.tsx +0 -139
- package/src/components/Card/Card.tsx +0 -35
- package/src/components/Card/CardActions.tsx +0 -23
- package/src/components/Card/CardContent.tsx +0 -28
- package/src/components/Card/CardHeader.tsx +0 -11
- package/src/components/Card/NftSentinel.json +0 -214
- package/src/components/Card/index.ts +0 -3
- package/src/components/Card/manifest.ts +0 -1
- package/src/components/index.ts +0 -1
- package/src/contexts/Context.ts +0 -5
- package/src/contexts/Provider.tsx +0 -131
- package/src/contexts/State.ts +0 -40
- package/src/contexts/index.ts +0 -4
- package/src/contexts/use.ts +0 -12
- package/src/hooks/index.ts +0 -1
- package/src/hooks/node/index.ts +0 -4
- package/src/hooks/node/useSentinelFromNode.tsx +0 -18
- package/src/hooks/node/useSentinelsFromNode.tsx +0 -27
- package/src/hooks/node/useWeakSentinelFromNode.tsx +0 -11
- package/src/hooks/node/useWeakSentinelsFromNode.tsx +0 -27
- package/src/index.ts +0 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../src/contexts/Provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAEjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAKjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAEjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAC9C,OAAO,
|
|
1
|
+
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../src/contexts/Provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAEjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAKjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAEjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAC9C,OAAO,KAA4B,MAAM,OAAO,CAAA;AAMhD,MAAM,WAAW,qBAAqB;IACpC,+CAA+C;IAC/C,OAAO,EAAE,eAAe,CAAA;IACxB,+EAA+E;IAC/E,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,GAAG,CAAC,EAAE,gBAAgB,EAAE,CAAA;IACxB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,SAAS,CAAC,EAAE,eAAe,EAAE,CAAA;CAC9B;AAED,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAAC,qBAAqB,CAAC,CAmG/E,CAAA"}
|
|
@@ -8,16 +8,16 @@ export declare const useSentinelContext: () => {
|
|
|
8
8
|
} & {
|
|
9
9
|
readonly __address: true;
|
|
10
10
|
})[];
|
|
11
|
-
payload_hashes: import("@xylabs/
|
|
11
|
+
payload_hashes: import("@xylabs/sdk-js").BrandedHash[];
|
|
12
12
|
payload_schemas: import("@xyo-network/payload-model").BrandedSchema<string>[];
|
|
13
|
-
previous_hashes: (import("@xylabs/
|
|
14
|
-
$signatures: (import("@xylabs/
|
|
13
|
+
previous_hashes: (import("@xylabs/sdk-js").BrandedHash | null)[];
|
|
14
|
+
$signatures: (import("@xylabs/sdk-js").BrandedHex | null)[];
|
|
15
15
|
$destination?: (Lowercase<string> & {
|
|
16
16
|
readonly __hex: true;
|
|
17
17
|
} & {
|
|
18
18
|
readonly __address: true;
|
|
19
19
|
}) | undefined;
|
|
20
|
-
$sourceQuery?: import("@xylabs/
|
|
20
|
+
$sourceQuery?: import("@xylabs/sdk-js").BrandedHash | undefined;
|
|
21
21
|
}[] | undefined;
|
|
22
22
|
progress: import("./State.ts").SentinelReportProgress | undefined;
|
|
23
23
|
reportingErrors: Error[] | undefined;
|
package/dist/browser/index.mjs
CHANGED
|
@@ -1,77 +1,69 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
1
|
// src/components/Card/Card.tsx
|
|
5
2
|
import { Card } from "@mui/material";
|
|
6
3
|
import { usePromise } from "@xylabs/react-promise";
|
|
7
|
-
import
|
|
4
|
+
import { useState } from "react";
|
|
8
5
|
|
|
9
6
|
// src/components/Card/CardActions.tsx
|
|
10
7
|
import { ButtonEx } from "@xylabs/react-button";
|
|
11
8
|
import { ModuleCardActions } from "@xyo-network/react-module";
|
|
12
|
-
import
|
|
13
|
-
var SentinelCardActions =
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
variant: "outlined"
|
|
21
|
-
}, "Report"));
|
|
22
|
-
}, "SentinelCardActions");
|
|
9
|
+
import { jsx } from "react/jsx-runtime";
|
|
10
|
+
var SentinelCardActions = ({
|
|
11
|
+
onReport,
|
|
12
|
+
mod,
|
|
13
|
+
...props
|
|
14
|
+
}) => {
|
|
15
|
+
return /* @__PURE__ */ jsx(ModuleCardActions, { mod, ...props, children: /* @__PURE__ */ jsx(ButtonEx, { onClick: () => onReport?.(mod), size: "small", variant: "outlined", children: "Report" }) });
|
|
16
|
+
};
|
|
23
17
|
|
|
24
18
|
// src/components/Card/CardContent.tsx
|
|
25
19
|
import { FlexGrowRow } from "@xylabs/react-flexbox";
|
|
26
20
|
import { ModuleCardContent } from "@xyo-network/react-module";
|
|
27
21
|
import { JsonViewerEx } from "@xyo-network/react-payload-raw-info";
|
|
28
|
-
import
|
|
29
|
-
var SentinelCardContent =
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}, "SentinelCardContent");
|
|
22
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
23
|
+
var SentinelCardContent = ({
|
|
24
|
+
children,
|
|
25
|
+
report,
|
|
26
|
+
mod,
|
|
27
|
+
...props
|
|
28
|
+
}) => {
|
|
29
|
+
return /* @__PURE__ */ jsx2(ModuleCardContent, { mod, ...props, children: /* @__PURE__ */ jsxs(FlexGrowRow, { flexWrap: "wrap", justifyContent: "start", gap: 2, children: [
|
|
30
|
+
report ? /* @__PURE__ */ jsx2(JsonViewerEx, { value: report }) : null,
|
|
31
|
+
children
|
|
32
|
+
] }) });
|
|
33
|
+
};
|
|
41
34
|
|
|
42
35
|
// src/components/Card/CardHeader.tsx
|
|
43
36
|
import { ModuleCardHeader } from "@xyo-network/react-module";
|
|
44
|
-
import
|
|
45
|
-
var SentinelCardHeader =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
});
|
|
51
|
-
}
|
|
37
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
38
|
+
var SentinelCardHeader = ({
|
|
39
|
+
title,
|
|
40
|
+
mod,
|
|
41
|
+
...props
|
|
42
|
+
}) => {
|
|
43
|
+
return /* @__PURE__ */ jsx3(ModuleCardHeader, { mod, title: title ?? mod?.config.name ?? "Sentinel", ...props });
|
|
44
|
+
};
|
|
52
45
|
|
|
53
46
|
// src/components/Card/Card.tsx
|
|
54
|
-
|
|
47
|
+
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
48
|
+
var SentinelCard = ({
|
|
49
|
+
children,
|
|
50
|
+
inPayloads,
|
|
51
|
+
mod,
|
|
52
|
+
...props
|
|
53
|
+
}) => {
|
|
55
54
|
const [retry, setRetry] = useState(-1);
|
|
56
55
|
const [report] = usePromise(async () => {
|
|
57
56
|
if (retry >= 0) {
|
|
58
57
|
return await mod?.report(inPayloads);
|
|
59
58
|
}
|
|
60
|
-
}, [
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
mod,
|
|
69
|
-
report
|
|
70
|
-
}), children, /* @__PURE__ */ React4.createElement(SentinelCardActions, {
|
|
71
|
-
mod,
|
|
72
|
-
onReport: /* @__PURE__ */ __name(() => setRetry(retry + 1), "onReport")
|
|
73
|
-
}));
|
|
74
|
-
}, "SentinelCard");
|
|
59
|
+
}, [mod, retry, inPayloads]);
|
|
60
|
+
return /* @__PURE__ */ jsxs2(Card, { ...props, children: [
|
|
61
|
+
/* @__PURE__ */ jsx4(SentinelCardHeader, { mod }),
|
|
62
|
+
/* @__PURE__ */ jsx4(SentinelCardContent, { mod, report }),
|
|
63
|
+
children,
|
|
64
|
+
/* @__PURE__ */ jsx4(SentinelCardActions, { mod, onReport: () => setRetry(retry + 1) })
|
|
65
|
+
] });
|
|
66
|
+
};
|
|
75
67
|
|
|
76
68
|
// src/contexts/Context.ts
|
|
77
69
|
import { createContextEx } from "@xylabs/react-shared";
|
|
@@ -83,7 +75,7 @@ import { useWitnessesFromNode } from "@xyo-network/react-witness";
|
|
|
83
75
|
import { MemorySentinel } from "@xyo-network/sentinel-memory";
|
|
84
76
|
import { SentinelConfigSchema } from "@xyo-network/sentinel-model";
|
|
85
77
|
import { asWitnessInstance } from "@xyo-network/witness-model";
|
|
86
|
-
import
|
|
78
|
+
import { useMemo, useState as useState2 } from "react";
|
|
87
79
|
|
|
88
80
|
// src/contexts/State.ts
|
|
89
81
|
import { Enum } from "@xylabs/sdk-js";
|
|
@@ -96,94 +88,92 @@ var SentinelReportStatus = Enum({
|
|
|
96
88
|
});
|
|
97
89
|
|
|
98
90
|
// src/contexts/Provider.tsx
|
|
99
|
-
|
|
91
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
92
|
+
var SentinelProvider = ({
|
|
93
|
+
account,
|
|
94
|
+
archivist,
|
|
95
|
+
children,
|
|
96
|
+
ids,
|
|
97
|
+
name,
|
|
98
|
+
required = false
|
|
99
|
+
}) => {
|
|
100
100
|
const [sentinel, setSentinel] = useState2();
|
|
101
101
|
const [history, setHistory] = useState2();
|
|
102
102
|
const [progress, setProgress] = useState2({});
|
|
103
103
|
const [status, setStatus] = useState2(SentinelReportStatus.Idle);
|
|
104
104
|
const [reportingErrors, setReportingErrors] = useState2();
|
|
105
105
|
const [witnesses] = useWitnessesFromNode(ids);
|
|
106
|
-
useAsyncEffect(
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
archivist
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
tasks: witnesses?.map((mod) => ({
|
|
117
|
-
mod: mod.address
|
|
118
|
-
}))
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
const offCallbacks = [
|
|
122
|
-
sentinel2.on("reportEnd", ({ mod, outPayloads }) => {
|
|
123
|
-
if (mounted()) {
|
|
124
|
-
setProgress({
|
|
125
|
-
archivists: progress.archivists,
|
|
126
|
-
witnesses: progress.witnesses
|
|
127
|
-
});
|
|
128
|
-
setStatus(outPayloads?.length ? SentinelReportStatus.Succeeded : SentinelReportStatus.Failed);
|
|
129
|
-
setReportingErrors([
|
|
130
|
-
new Error(`Witness failed [${mod?.config?.name ?? mod.address}]`)
|
|
131
|
-
]);
|
|
132
|
-
}
|
|
133
|
-
}),
|
|
134
|
-
sentinel2.on("reportStart", () => {
|
|
135
|
-
if (mounted()) {
|
|
136
|
-
setProgress({
|
|
137
|
-
archivists: {},
|
|
138
|
-
witnesses: {}
|
|
139
|
-
});
|
|
140
|
-
setStatus(SentinelReportStatus.Started);
|
|
106
|
+
useAsyncEffect(
|
|
107
|
+
async (mounted) => {
|
|
108
|
+
const sentinel2 = await MemorySentinel.create({
|
|
109
|
+
account,
|
|
110
|
+
config: {
|
|
111
|
+
archivists: archivist ? [archivist] : void 0,
|
|
112
|
+
name,
|
|
113
|
+
schema: SentinelConfigSchema,
|
|
114
|
+
synchronous: true,
|
|
115
|
+
tasks: witnesses?.map((mod) => ({ mod: mod.address }))
|
|
141
116
|
}
|
|
142
|
-
})
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
witnesses:
|
|
157
|
-
|
|
117
|
+
});
|
|
118
|
+
const offCallbacks = [
|
|
119
|
+
sentinel2.on("reportEnd", ({ mod, outPayloads }) => {
|
|
120
|
+
if (mounted()) {
|
|
121
|
+
setProgress({
|
|
122
|
+
archivists: progress.archivists,
|
|
123
|
+
witnesses: progress.witnesses
|
|
124
|
+
});
|
|
125
|
+
setStatus(outPayloads?.length ? SentinelReportStatus.Succeeded : SentinelReportStatus.Failed);
|
|
126
|
+
setReportingErrors([new Error(`Witness failed [${mod?.config?.name ?? mod.address}]`)]);
|
|
127
|
+
}
|
|
128
|
+
}),
|
|
129
|
+
sentinel2.on("reportStart", () => {
|
|
130
|
+
if (mounted()) {
|
|
131
|
+
setProgress({ archivists: {}, witnesses: {} });
|
|
132
|
+
setStatus(SentinelReportStatus.Started);
|
|
133
|
+
}
|
|
134
|
+
})
|
|
135
|
+
];
|
|
136
|
+
if (witnesses)
|
|
137
|
+
for (const witness of witnesses) {
|
|
138
|
+
offCallbacks.push(
|
|
139
|
+
witness.on("observeEnd", ({ mod, outPayloads }) => {
|
|
140
|
+
const witnesses2 = progress.witnesses ?? {};
|
|
141
|
+
witnesses2[witness.address] = {
|
|
142
|
+
status: outPayloads?.length ? SentinelReportStatus.Succeeded : SentinelReportStatus.Failed,
|
|
143
|
+
witness: asWitnessInstance(mod, () => `Module is not a witness [${mod.id}]`, { required: true })
|
|
144
|
+
};
|
|
145
|
+
if (mounted()) {
|
|
146
|
+
setProgress({
|
|
147
|
+
archivists: progress.archivists,
|
|
148
|
+
witnesses: witnesses2
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}),
|
|
152
|
+
witness.on("observeStart", ({ mod }) => {
|
|
153
|
+
const witnesses2 = progress.witnesses ?? {};
|
|
154
|
+
witnesses2[witness.address] = {
|
|
155
|
+
status: SentinelReportStatus.Started,
|
|
156
|
+
witness: asWitnessInstance(mod, () => `Module is not a witness [${mod.id}]`, { required: true })
|
|
157
|
+
};
|
|
158
|
+
if (mounted()) {
|
|
159
|
+
setProgress({
|
|
160
|
+
archivists: progress.archivists,
|
|
161
|
+
witnesses: witnesses2
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
})
|
|
165
|
+
);
|
|
158
166
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
required: true
|
|
165
|
-
})
|
|
166
|
-
};
|
|
167
|
-
if (mounted()) {
|
|
168
|
-
setProgress({
|
|
169
|
-
archivists: progress.archivists,
|
|
170
|
-
witnesses: witnesses2
|
|
171
|
-
});
|
|
167
|
+
setSentinel(sentinel2);
|
|
168
|
+
setHistory(sentinel2?.history);
|
|
169
|
+
return () => {
|
|
170
|
+
for (const callback of offCallbacks) {
|
|
171
|
+
callback();
|
|
172
172
|
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
return () => {
|
|
178
|
-
for (const callback of offCallbacks) {
|
|
179
|
-
callback();
|
|
180
|
-
}
|
|
181
|
-
};
|
|
182
|
-
}, [
|
|
183
|
-
account,
|
|
184
|
-
archivist,
|
|
185
|
-
witnesses
|
|
186
|
-
]);
|
|
173
|
+
};
|
|
174
|
+
},
|
|
175
|
+
[account, archivist, witnesses]
|
|
176
|
+
);
|
|
187
177
|
const value = useMemo(() => ({
|
|
188
178
|
history,
|
|
189
179
|
progress,
|
|
@@ -191,22 +181,20 @@ var SentinelProvider = /* @__PURE__ */ __name(({ account, archivist, children, i
|
|
|
191
181
|
reportingErrors,
|
|
192
182
|
sentinel,
|
|
193
183
|
status
|
|
194
|
-
}), [
|
|
184
|
+
}), [history, progress, reportingErrors, sentinel, status]);
|
|
185
|
+
return !required || sentinel ? /* @__PURE__ */ jsx5(SentinelContext, { value, children }) : null;
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
// src/contexts/use.ts
|
|
189
|
+
import { useContextEx } from "@xylabs/react-shared";
|
|
190
|
+
var useSentinelContext = () => {
|
|
191
|
+
const {
|
|
192
|
+
sentinel,
|
|
195
193
|
history,
|
|
196
194
|
progress,
|
|
197
195
|
reportingErrors,
|
|
198
|
-
sentinel,
|
|
199
196
|
status
|
|
200
|
-
|
|
201
|
-
return !required || sentinel ? /* @__PURE__ */ React5.createElement(SentinelContext, {
|
|
202
|
-
value
|
|
203
|
-
}, children) : null;
|
|
204
|
-
}, "SentinelProvider");
|
|
205
|
-
|
|
206
|
-
// src/contexts/use.ts
|
|
207
|
-
import { useContextEx } from "@xylabs/react-shared";
|
|
208
|
-
var useSentinelContext = /* @__PURE__ */ __name(() => {
|
|
209
|
-
const { sentinel, history, progress, reportingErrors, status } = useContextEx(SentinelContext, "Sentinel");
|
|
197
|
+
} = useContextEx(SentinelContext, "Sentinel");
|
|
210
198
|
return {
|
|
211
199
|
history,
|
|
212
200
|
progress,
|
|
@@ -214,38 +202,29 @@ var useSentinelContext = /* @__PURE__ */ __name(() => {
|
|
|
214
202
|
sentinel,
|
|
215
203
|
status
|
|
216
204
|
};
|
|
217
|
-
}
|
|
205
|
+
};
|
|
218
206
|
|
|
219
207
|
// src/hooks/node/useSentinelFromNode.tsx
|
|
220
208
|
import { useModuleFromNode } from "@xyo-network/react-node";
|
|
221
209
|
import { asSentinelInstance } from "@xyo-network/sentinel-model";
|
|
222
|
-
var useSentinelFromNode =
|
|
210
|
+
var useSentinelFromNode = (nameOrAddressOrInstance, config) => {
|
|
223
211
|
const [mod, error] = useModuleFromNode(nameOrAddressOrInstance, config);
|
|
224
212
|
const instance = asSentinelInstance(mod);
|
|
225
213
|
if (mod && !instance) {
|
|
226
214
|
const error2 = new Error(`Resolved module is not a SentinelInstance [${mod.config?.schema}:${mod.config?.name}:${mod.address}]`);
|
|
227
215
|
console.error(error2.message);
|
|
228
|
-
return [
|
|
229
|
-
void 0,
|
|
230
|
-
error2
|
|
231
|
-
];
|
|
216
|
+
return [void 0, error2];
|
|
232
217
|
}
|
|
233
|
-
return [
|
|
234
|
-
|
|
235
|
-
error
|
|
236
|
-
];
|
|
237
|
-
}, "useSentinelFromNode");
|
|
218
|
+
return [instance, error];
|
|
219
|
+
};
|
|
238
220
|
|
|
239
221
|
// src/hooks/node/useSentinelsFromNode.tsx
|
|
240
222
|
import { useModulesFromNode } from "@xyo-network/react-node";
|
|
241
223
|
import { isSentinelInstance } from "@xyo-network/sentinel-model";
|
|
242
|
-
var useSentinelsFromNode =
|
|
224
|
+
var useSentinelsFromNode = (ids, config) => {
|
|
243
225
|
const [modules, error] = useModulesFromNode(ids, config);
|
|
244
226
|
if (error) {
|
|
245
|
-
return [
|
|
246
|
-
null,
|
|
247
|
-
error
|
|
248
|
-
];
|
|
227
|
+
return [null, error];
|
|
249
228
|
}
|
|
250
229
|
return modules ? [
|
|
251
230
|
// eslint-disable-next-line unicorn/no-array-reduce
|
|
@@ -256,33 +235,24 @@ var useSentinelsFromNode = /* @__PURE__ */ __name((ids, config) => {
|
|
|
256
235
|
return prev;
|
|
257
236
|
}, []),
|
|
258
237
|
void 0
|
|
259
|
-
] : [
|
|
260
|
-
|
|
261
|
-
error
|
|
262
|
-
];
|
|
263
|
-
}, "useSentinelsFromNode");
|
|
238
|
+
] : [modules, error];
|
|
239
|
+
};
|
|
264
240
|
|
|
265
241
|
// src/hooks/node/useWeakSentinelFromNode.tsx
|
|
266
242
|
import { useWeakModuleFromNode } from "@xyo-network/react-node";
|
|
267
243
|
import { isSentinelInstance as isSentinelInstance2 } from "@xyo-network/sentinel-model";
|
|
268
|
-
var useWeakSentinelFromNode =
|
|
269
|
-
return useWeakModuleFromNode(nameOrAddressOrInstance, {
|
|
270
|
-
|
|
271
|
-
...config
|
|
272
|
-
});
|
|
273
|
-
}, "useWeakSentinelFromNode");
|
|
244
|
+
var useWeakSentinelFromNode = (nameOrAddressOrInstance, config) => {
|
|
245
|
+
return useWeakModuleFromNode(nameOrAddressOrInstance, { identity: isSentinelInstance2, ...config });
|
|
246
|
+
};
|
|
274
247
|
|
|
275
248
|
// src/hooks/node/useWeakSentinelsFromNode.tsx
|
|
276
249
|
import { exists } from "@xylabs/sdk-js";
|
|
277
250
|
import { useWeakModulesFromNode } from "@xyo-network/react-node";
|
|
278
251
|
import { asSentinelInstance as asSentinelInstance2 } from "@xyo-network/sentinel-model";
|
|
279
|
-
var useWeakSentinelsFromNode =
|
|
252
|
+
var useWeakSentinelsFromNode = (ids, config) => {
|
|
280
253
|
const [modules, error] = useWeakModulesFromNode(ids, config);
|
|
281
254
|
if (error) {
|
|
282
|
-
return [
|
|
283
|
-
null,
|
|
284
|
-
error
|
|
285
|
-
];
|
|
255
|
+
return [null, error];
|
|
286
256
|
}
|
|
287
257
|
return [
|
|
288
258
|
modules?.map((mod) => {
|
|
@@ -293,7 +263,7 @@ var useWeakSentinelsFromNode = /* @__PURE__ */ __name((ids, config) => {
|
|
|
293
263
|
}).filter(exists) ?? [],
|
|
294
264
|
void 0
|
|
295
265
|
];
|
|
296
|
-
}
|
|
266
|
+
};
|
|
297
267
|
export {
|
|
298
268
|
SentinelCard,
|
|
299
269
|
SentinelCardContent,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/Card/Card.tsx","../../src/components/Card/CardActions.tsx","../../src/components/Card/CardContent.tsx","../../src/components/Card/CardHeader.tsx","../../src/contexts/Context.ts","../../src/contexts/Provider.tsx","../../src/contexts/State.ts","../../src/contexts/use.ts","../../src/hooks/node/useSentinelFromNode.tsx","../../src/hooks/node/useSentinelsFromNode.tsx","../../src/hooks/node/useWeakSentinelFromNode.tsx","../../src/hooks/node/useWeakSentinelsFromNode.tsx"],"sourcesContent":["import type { CardProps } from '@mui/material'\nimport { Card } from '@mui/material'\nimport { usePromise } from '@xylabs/react-promise'\nimport type { Payload } from '@xyo-network/payload-model'\nimport type { ModuleRenderProps } from '@xyo-network/react-module'\nimport type { SentinelInstance } from '@xyo-network/sentinel-model'\nimport React, { useState } from 'react'\n\nimport { SentinelCardActions } from './CardActions.tsx'\nimport { SentinelCardContent } from './CardContent.tsx'\nimport { SentinelCardHeader } from './CardHeader.tsx'\n\nexport type SentinelCardProps = CardProps\n & ModuleRenderProps<SentinelInstance> & {\n inPayloads?: Payload[]\n }\n\nexport const SentinelCard: React.FC<SentinelCardProps> = ({\n children, inPayloads, mod, ...props\n}) => {\n const [retry, setRetry] = useState(-1)\n const [report] = usePromise(async () => {\n if (retry >= 0) {\n return await mod?.report(inPayloads)\n }\n }, [mod, retry, inPayloads])\n return (\n <Card {...props}>\n <SentinelCardHeader mod={mod} />\n <SentinelCardContent mod={mod} report={report} />\n {children}\n <SentinelCardActions mod={mod} onReport={() => setRetry(retry + 1)} />\n </Card>\n )\n}\n","import type { CardActionsProps } from '@mui/material'\nimport { ButtonEx } from '@xylabs/react-button'\nimport type { ModuleRenderProps } from '@xyo-network/react-module'\nimport { ModuleCardActions } from '@xyo-network/react-module'\nimport type { SentinelInstance } from '@xyo-network/sentinel-model'\nimport React from 'react'\n\nexport type SentinelCardActionsProps = ModuleRenderProps<SentinelInstance>\n & CardActionsProps & {\n onReport?: (mod?: SentinelInstance) => void\n }\n\nexport const SentinelCardActions: React.FC<SentinelCardActionsProps> = ({\n onReport, mod, ...props\n}) => {\n return (\n <ModuleCardActions mod={mod} {...props}>\n <ButtonEx onClick={() => onReport?.(mod)} size=\"small\" variant=\"outlined\">\n Report\n </ButtonEx>\n </ModuleCardActions>\n )\n}\n","import type { CardContentProps } from '@mui/material'\nimport { FlexGrowRow } from '@xylabs/react-flexbox'\nimport type { Payload } from '@xyo-network/payload-model'\nimport type { ModuleRenderProps } from '@xyo-network/react-module'\nimport { ModuleCardContent } from '@xyo-network/react-module'\nimport { JsonViewerEx } from '@xyo-network/react-payload-raw-info'\nimport type { SentinelInstance } from '@xyo-network/sentinel-model'\nimport React from 'react'\n\nexport type SentinelCardContentProps = ModuleRenderProps<SentinelInstance>\n & CardContentProps & {\n report?: Payload[]\n }\n\nexport const SentinelCardContent: React.FC<SentinelCardContentProps> = ({\n children, report, mod, ...props\n}) => {\n return (\n <ModuleCardContent mod={mod} {...props}>\n <FlexGrowRow flexWrap=\"wrap\" justifyContent=\"start\" gap={2}>\n {report\n ? <JsonViewerEx value={report} />\n : null}\n {children}\n </FlexGrowRow>\n </ModuleCardContent>\n )\n}\n","import type { CardHeaderProps } from '@mui/material'\nimport type { ModuleRenderProps } from '@xyo-network/react-module'\nimport { ModuleCardHeader } from '@xyo-network/react-module'\nimport type { SentinelInstance } from '@xyo-network/sentinel-model'\nimport React from 'react'\n\nexport const SentinelCardHeader: React.FC<ModuleRenderProps<SentinelInstance> & CardHeaderProps> = ({\n title, mod, ...props\n}) => {\n return <ModuleCardHeader mod={mod} title={title ?? mod?.config.name ?? 'Sentinel'} {...props} />\n}\n","import { createContextEx } from '@xylabs/react-shared'\n\nimport type { SentinelContextState } from './State.ts'\n\nexport const SentinelContext = createContextEx<SentinelContextState>()\n","import { useAsyncEffect } from '@xylabs/react-async-effect'\nimport type { AccountInstance } from '@xyo-network/account-model'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport type { ModuleIdentifier } from '@xyo-network/module-model'\nimport { useWitnessesFromNode } from '@xyo-network/react-witness'\nimport { MemorySentinel } from '@xyo-network/sentinel-memory'\nimport type { SentinelConfig } from '@xyo-network/sentinel-model'\nimport { SentinelConfigSchema } from '@xyo-network/sentinel-model'\nimport type { WitnessInstance } from '@xyo-network/witness-model'\nimport { asWitnessInstance } from '@xyo-network/witness-model'\nimport type { PropsWithChildren } from 'react'\nimport React, {\n useEffect, useMemo, useState,\n} from 'react'\n\nimport { SentinelContext } from './Context.ts'\nimport type { SentinelContextState, SentinelReportProgress } from './State.ts'\nimport { SentinelReportStatus } from './State.ts'\n\nexport interface SentinelProviderProps {\n /** Account used by the sentinel for signing */\n account: AccountInstance\n /** @deprecated - sentinel no longer uses archive but relies on an archivist */\n archive?: string\n archivist?: string\n ids?: ModuleIdentifier[]\n name?: string\n required?: boolean\n witnesses?: WitnessInstance[]\n}\n\nexport const SentinelProvider: React.FC<PropsWithChildren<SentinelProviderProps>> = ({\n account, archivist, children, ids, name, required = false,\n}) => {\n const [sentinel, setSentinel] = useState<MemorySentinel>()\n const [history, setHistory] = useState<BoundWitness[]>()\n const [progress, setProgress] = useState<SentinelReportProgress>({})\n const [status, setStatus] = useState<SentinelReportStatus>(SentinelReportStatus.Idle)\n const [reportingErrors, setReportingErrors] = useState<Error[]>()\n const [witnesses] = useWitnessesFromNode(ids)\n\n useAsyncEffect(\n\n async (mounted) => {\n const sentinel = await MemorySentinel.create({\n account,\n config: {\n archivists: archivist ? [archivist] : undefined,\n name,\n\n schema: SentinelConfigSchema,\n synchronous: true,\n\n tasks: witnesses?.map(mod => ({ mod: mod.address })),\n } as SentinelConfig,\n })\n const offCallbacks: (() => void)[] = [\n sentinel.on('reportEnd', ({ mod, outPayloads }) => {\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses: progress.witnesses,\n })\n setStatus(outPayloads?.length ? SentinelReportStatus.Succeeded : SentinelReportStatus.Failed)\n setReportingErrors([new Error(`Witness failed [${mod?.config?.name ?? mod.address}]`)])\n }\n }),\n sentinel.on('reportStart', () => {\n if (mounted()) {\n setProgress({ archivists: {}, witnesses: {} })\n setStatus(SentinelReportStatus.Started)\n }\n }),\n ]\n if (witnesses)\n for (const witness of witnesses) {\n offCallbacks.push(\n witness.on('observeEnd', ({ mod, outPayloads }) => {\n const witnesses = progress.witnesses ?? {}\n witnesses[witness.address] = {\n status: outPayloads?.length ? SentinelReportStatus.Succeeded : SentinelReportStatus.Failed,\n witness: asWitnessInstance(mod, () => `Module is not a witness [${mod.id}]`, { required: true }),\n }\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses,\n })\n }\n }),\n witness.on('observeStart', ({ mod }) => {\n const witnesses = progress.witnesses ?? {}\n witnesses[witness.address] = {\n status: SentinelReportStatus.Started,\n witness: asWitnessInstance(mod, () => `Module is not a witness [${mod.id}]`, { required: true }),\n }\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses,\n })\n }\n }),\n )\n }\n setSentinel(sentinel as MemorySentinel)\n setHistory(sentinel?.history as BoundWitness[])\n return () => {\n // unsubscribe from events\n for (const callback of offCallbacks) {\n callback()\n }\n }\n },\n\n [account, archivist, witnesses],\n )\n\n const value: SentinelContextState = useMemo(() => ({\n history, progress, provided: true, reportingErrors, sentinel, status,\n }), [history, progress, reportingErrors, sentinel, status])\n\n return !required || sentinel\n\n ? (\n <SentinelContext value={value}>\n {children}\n </SentinelContext>\n )\n : null\n}\n","import type { ContextExState } from '@xylabs/react-shared'\nimport type { EnumValue } from '@xylabs/sdk-js'\nimport { Enum } from '@xylabs/sdk-js'\nimport type { ArchivistModuleInstance } from '@xyo-network/archivist-model'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport type { SentinelModule } from '@xyo-network/sentinel-model'\nimport type { WitnessModule } from '@xyo-network/witness-model'\n\nexport const SentinelReportStatus = Enum({\n Idle: 'idle',\n Queued: 'queued',\n Started: 'started',\n Succeeded: 'succeeded',\n Failed: 'failed',\n})\n\nexport type SentinelReportStatus = EnumValue<typeof SentinelReportStatus>\n\nexport interface SentinelWitnessReportProgress {\n status: SentinelReportStatus\n witness: WitnessModule\n}\n\nexport interface SentinelArchivistApiReportProgress {\n archivist: ArchivistModuleInstance\n status: SentinelReportStatus\n}\n\nexport interface SentinelReportProgress {\n archivists?: Record<string, SentinelArchivistApiReportProgress>\n witnesses?: Record<string, SentinelWitnessReportProgress>\n}\n\nexport type SentinelContextState = ContextExState<{\n history?: BoundWitness[]\n progress?: SentinelReportProgress\n reportingErrors?: Error[]\n sentinel?: SentinelModule\n status?: SentinelReportStatus\n}>\n","import { useContextEx } from '@xylabs/react-shared'\n\nimport { SentinelContext } from './Context.ts'\n\nexport const useSentinelContext = () => {\n const {\n sentinel, history, progress, reportingErrors, status,\n } = useContextEx(SentinelContext, 'Sentinel')\n return {\n history, progress, reportingErrors, sentinel, status,\n }\n}\n","import type { ModuleFromNodeConfig } from '@xyo-network/react-node'\nimport { useModuleFromNode } from '@xyo-network/react-node'\nimport type { SentinelInstance } from '@xyo-network/sentinel-model'\nimport { asSentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useSentinelFromNode = (\n nameOrAddressOrInstance?: string | SentinelInstance,\n config?: ModuleFromNodeConfig,\n): [SentinelInstance | undefined, Error | undefined] => {\n const [mod, error] = useModuleFromNode(nameOrAddressOrInstance, config)\n const instance = asSentinelInstance(mod)\n if (mod && !instance) {\n const error = new Error(`Resolved module is not a SentinelInstance [${mod.config?.schema}:${mod.config?.name}:${mod.address}]`)\n console.error(error.message)\n return [undefined, error]\n }\n return [instance, error]\n}\n","import type { ModuleIdentifier } from '@xyo-network/module-model'\nimport type { ModuleFromNodeConfig } from '@xyo-network/react-node'\nimport { useModulesFromNode } from '@xyo-network/react-node'\nimport type { SentinelInstance } from '@xyo-network/sentinel-model'\nimport { isSentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useSentinelsFromNode = (\n ids?: ModuleIdentifier[],\n config?: ModuleFromNodeConfig,\n): [SentinelInstance[] | null | undefined, Error | undefined] => {\n const [modules, error] = useModulesFromNode(ids, config)\n if (error) {\n return [null, error]\n }\n return modules\n ? [\n // eslint-disable-next-line unicorn/no-array-reduce\n modules.reduce<SentinelInstance[]>((prev, mod) => {\n if (isSentinelInstance(mod)) {\n prev.push(mod)\n }\n return prev\n }, []),\n undefined,\n ]\n : [modules, error]\n}\n","import type { WeakModuleFromNodeConfig } from '@xyo-network/react-node'\nimport { useWeakModuleFromNode } from '@xyo-network/react-node'\nimport type { SentinelInstance } from '@xyo-network/sentinel-model'\nimport { isSentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useWeakSentinelFromNode = (\n nameOrAddressOrInstance?: string | SentinelInstance,\n config?: WeakModuleFromNodeConfig,\n): [WeakRef<SentinelInstance> | undefined, Error | undefined] => {\n return useWeakModuleFromNode<SentinelInstance>(nameOrAddressOrInstance, { identity: isSentinelInstance, ...config })\n}\n","import { exists } from '@xylabs/sdk-js'\nimport type { ModuleIdentifier } from '@xyo-network/module-model'\nimport type { ModuleFromNodeConfig } from '@xyo-network/react-node'\nimport { useWeakModulesFromNode } from '@xyo-network/react-node'\nimport type { SentinelInstance } from '@xyo-network/sentinel-model'\nimport { asSentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useWeakSentinelsFromNode = (\n ids?: ModuleIdentifier[],\n config?: ModuleFromNodeConfig,\n): [WeakRef<SentinelInstance>[] | null | undefined, Error | undefined] => {\n const [modules, error] = useWeakModulesFromNode(ids, config)\n if (error) {\n return [null, error]\n }\n return [\n modules\n ?.map((mod) => {\n const instance = asSentinelInstance(mod?.deref())\n if (instance) {\n return new WeakRef(instance)\n }\n })\n .filter(exists) ?? [],\n undefined,\n ]\n}\n"],"mappings":";;;;AACA,SAASA,YAAY;AACrB,SAASC,kBAAkB;AAI3B,OAAOC,UAASC,gBAAgB;;;ACLhC,SAASC,gBAAgB;AAEzB,SAASC,yBAAyB;AAElC,OAAOC,WAAW;AAOX,IAAMC,sBAA0D,wBAAC,EACtEC,UAAUC,KAAK,GAAGC,MAAAA,MACnB;AACC,SACE,sBAAA,cAACC,mBAAAA;IAAkBF;IAAW,GAAGC;KAC/B,sBAAA,cAACE,UAAAA;IAASC,SAAS,6B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,OAA2B,CAACC,MAAMC,QAAAA;AACxC,UAAIC,mBAAmBD,GAAAA,GAAM;AAC3BD,aAAKG,KAAKF,GAAAA;MACZ;AACA,aAAOD;IACT,GAAG,CAAA,CAAE;IACLI;MAEF;IAACR;IAASC;;AAChB,GApBoC;;;ACLpC,SAASQ,6BAA6B;AAEtC,SAASC,sBAAAA,2BAA0B;AAE5B,IAAMC,0BAA0B,wBACrCC,yBACAC,WAAAA;AAEA,SAAOC,sBAAwCF,yBAAyB;IAAEG,UAAUC;IAAoB,GAAGH;EAAO,CAAA;AACpH,GALuC;;;ACLvC,SAASI,cAAc;AAGvB,SAASC,8BAA8B;AAEvC,SAASC,sBAAAA,2BAA0B;AAE5B,IAAMC,2BAA2B,wBACtCC,KACAC,WAAAA;AAEA,QAAM,CAACC,SAASC,KAAAA,IAASC,uBAAuBJ,KAAKC,MAAAA;AACrD,MAAIE,OAAO;AACT,WAAO;MAAC;MAAMA;;EAChB;AACA,SAAO;IACLD,SACIG,IAAI,CAACC,QAAAA;AACL,YAAMC,WAAWC,oBAAmBF,KAAKG,MAAAA,CAAAA;AACzC,UAAIF,UAAU;AACZ,eAAO,IAAIG,QAAQH,QAAAA;MACrB;IACF,CAAA,EACCI,OAAOC,MAAAA,KAAW,CAAA;IACrBC;;AAEJ,GAnBwC;","names":["Card","usePromise","React","useState","ButtonEx","ModuleCardActions","React","SentinelCardActions","onReport","mod","props","ModuleCardActions","ButtonEx","onClick","size","variant","FlexGrowRow","ModuleCardContent","JsonViewerEx","React","SentinelCardContent","children","report","mod","props","React","ModuleCardContent","FlexGrowRow","flexWrap","justifyContent","gap","JsonViewerEx","value","ModuleCardHeader","React","SentinelCardHeader","title","mod","props","React","ModuleCardHeader","config","name","SentinelCard","children","inPayloads","mod","props","retry","setRetry","useState","report","usePromise","React","Card","SentinelCardHeader","SentinelCardContent","SentinelCardActions","onReport","createContextEx","SentinelContext","useAsyncEffect","useWitnessesFromNode","MemorySentinel","SentinelConfigSchema","asWitnessInstance","React","useMemo","useState","Enum","SentinelReportStatus","Idle","Queued","Started","Succeeded","Failed","SentinelProvider","account","archivist","children","ids","name","required","sentinel","setSentinel","useState","history","setHistory","progress","setProgress","status","setStatus","SentinelReportStatus","Idle","reportingErrors","setReportingErrors","witnesses","useWitnessesFromNode","useAsyncEffect","mounted","MemorySentinel","create","config","archivists","undefined","schema","SentinelConfigSchema","synchronous","tasks","map","mod","address","offCallbacks","on","outPayloads","length","Succeeded","Failed","Error","Started","witness","push","asWitnessInstance","id","callback","value","useMemo","provided","React","SentinelContext","useContextEx","useSentinelContext","sentinel","history","progress","reportingErrors","status","useContextEx","SentinelContext","useModuleFromNode","asSentinelInstance","useSentinelFromNode","nameOrAddressOrInstance","config","mod","error","useModuleFromNode","instance","asSentinelInstance","Error","schema","name","address","console","message","undefined","useModulesFromNode","isSentinelInstance","useSentinelsFromNode","ids","config","modules","error","useModulesFromNode","reduce","prev","mod","isSentinelInstance","push","undefined","useWeakModuleFromNode","isSentinelInstance","useWeakSentinelFromNode","nameOrAddressOrInstance","config","useWeakModuleFromNode","identity","isSentinelInstance","exists","useWeakModulesFromNode","asSentinelInstance","useWeakSentinelsFromNode","ids","config","modules","error","useWeakModulesFromNode","map","mod","instance","asSentinelInstance","deref","WeakRef","filter","exists","undefined"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/Card/Card.tsx","../../src/components/Card/CardActions.tsx","../../src/components/Card/CardContent.tsx","../../src/components/Card/CardHeader.tsx","../../src/contexts/Context.ts","../../src/contexts/Provider.tsx","../../src/contexts/State.ts","../../src/contexts/use.ts","../../src/hooks/node/useSentinelFromNode.tsx","../../src/hooks/node/useSentinelsFromNode.tsx","../../src/hooks/node/useWeakSentinelFromNode.tsx","../../src/hooks/node/useWeakSentinelsFromNode.tsx"],"sourcesContent":["import type { CardProps } from '@mui/material'\nimport { Card } from '@mui/material'\nimport { usePromise } from '@xylabs/react-promise'\nimport type { Payload } from '@xyo-network/payload-model'\nimport type { ModuleRenderProps } from '@xyo-network/react-module'\nimport type { SentinelInstance } from '@xyo-network/sentinel-model'\nimport React, { useState } from 'react'\n\nimport { SentinelCardActions } from './CardActions.tsx'\nimport { SentinelCardContent } from './CardContent.tsx'\nimport { SentinelCardHeader } from './CardHeader.tsx'\n\nexport type SentinelCardProps = CardProps\n & ModuleRenderProps<SentinelInstance> & {\n inPayloads?: Payload[]\n }\n\nexport const SentinelCard: React.FC<SentinelCardProps> = ({\n children, inPayloads, mod, ...props\n}) => {\n const [retry, setRetry] = useState(-1)\n const [report] = usePromise(async () => {\n if (retry >= 0) {\n return await mod?.report(inPayloads)\n }\n }, [mod, retry, inPayloads])\n return (\n <Card {...props}>\n <SentinelCardHeader mod={mod} />\n <SentinelCardContent mod={mod} report={report} />\n {children}\n <SentinelCardActions mod={mod} onReport={() => setRetry(retry + 1)} />\n </Card>\n )\n}\n","import type { CardActionsProps } from '@mui/material'\nimport { ButtonEx } from '@xylabs/react-button'\nimport type { ModuleRenderProps } from '@xyo-network/react-module'\nimport { ModuleCardActions } from '@xyo-network/react-module'\nimport type { SentinelInstance } from '@xyo-network/sentinel-model'\nimport React from 'react'\n\nexport type SentinelCardActionsProps = ModuleRenderProps<SentinelInstance>\n & CardActionsProps & {\n onReport?: (mod?: SentinelInstance) => void\n }\n\nexport const SentinelCardActions: React.FC<SentinelCardActionsProps> = ({\n onReport, mod, ...props\n}) => {\n return (\n <ModuleCardActions mod={mod} {...props}>\n <ButtonEx onClick={() => onReport?.(mod)} size=\"small\" variant=\"outlined\">\n Report\n </ButtonEx>\n </ModuleCardActions>\n )\n}\n","import type { CardContentProps } from '@mui/material'\nimport { FlexGrowRow } from '@xylabs/react-flexbox'\nimport type { Payload } from '@xyo-network/payload-model'\nimport type { ModuleRenderProps } from '@xyo-network/react-module'\nimport { ModuleCardContent } from '@xyo-network/react-module'\nimport { JsonViewerEx } from '@xyo-network/react-payload-raw-info'\nimport type { SentinelInstance } from '@xyo-network/sentinel-model'\nimport React from 'react'\n\nexport type SentinelCardContentProps = ModuleRenderProps<SentinelInstance>\n & CardContentProps & {\n report?: Payload[]\n }\n\nexport const SentinelCardContent: React.FC<SentinelCardContentProps> = ({\n children, report, mod, ...props\n}) => {\n return (\n <ModuleCardContent mod={mod} {...props}>\n <FlexGrowRow flexWrap=\"wrap\" justifyContent=\"start\" gap={2}>\n {report\n ? <JsonViewerEx value={report} />\n : null}\n {children}\n </FlexGrowRow>\n </ModuleCardContent>\n )\n}\n","import type { CardHeaderProps } from '@mui/material'\nimport type { ModuleRenderProps } from '@xyo-network/react-module'\nimport { ModuleCardHeader } from '@xyo-network/react-module'\nimport type { SentinelInstance } from '@xyo-network/sentinel-model'\nimport React from 'react'\n\nexport const SentinelCardHeader: React.FC<ModuleRenderProps<SentinelInstance> & CardHeaderProps> = ({\n title, mod, ...props\n}) => {\n return <ModuleCardHeader mod={mod} title={title ?? mod?.config.name ?? 'Sentinel'} {...props} />\n}\n","import { createContextEx } from '@xylabs/react-shared'\n\nimport type { SentinelContextState } from './State.ts'\n\nexport const SentinelContext = createContextEx<SentinelContextState>()\n","import { useAsyncEffect } from '@xylabs/react-async-effect'\nimport type { AccountInstance } from '@xyo-network/account-model'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport type { ModuleIdentifier } from '@xyo-network/module-model'\nimport { useWitnessesFromNode } from '@xyo-network/react-witness'\nimport { MemorySentinel } from '@xyo-network/sentinel-memory'\nimport type { SentinelConfig } from '@xyo-network/sentinel-model'\nimport { SentinelConfigSchema } from '@xyo-network/sentinel-model'\nimport type { WitnessInstance } from '@xyo-network/witness-model'\nimport { asWitnessInstance } from '@xyo-network/witness-model'\nimport type { PropsWithChildren } from 'react'\nimport React, { useMemo, useState } from 'react'\n\nimport { SentinelContext } from './Context.ts'\nimport type { SentinelContextState, SentinelReportProgress } from './State.ts'\nimport { SentinelReportStatus } from './State.ts'\n\nexport interface SentinelProviderProps {\n /** Account used by the sentinel for signing */\n account: AccountInstance\n /** @deprecated - sentinel no longer uses archive but relies on an archivist */\n archive?: string\n archivist?: string\n ids?: ModuleIdentifier[]\n name?: string\n required?: boolean\n witnesses?: WitnessInstance[]\n}\n\nexport const SentinelProvider: React.FC<PropsWithChildren<SentinelProviderProps>> = ({\n account, archivist, children, ids, name, required = false,\n}) => {\n const [sentinel, setSentinel] = useState<MemorySentinel>()\n const [history, setHistory] = useState<BoundWitness[]>()\n const [progress, setProgress] = useState<SentinelReportProgress>({})\n const [status, setStatus] = useState<SentinelReportStatus>(SentinelReportStatus.Idle)\n const [reportingErrors, setReportingErrors] = useState<Error[]>()\n const [witnesses] = useWitnessesFromNode(ids)\n\n useAsyncEffect(\n\n async (mounted) => {\n const sentinel = await MemorySentinel.create({\n account,\n config: {\n archivists: archivist ? [archivist] : undefined,\n name,\n\n schema: SentinelConfigSchema,\n synchronous: true,\n\n tasks: witnesses?.map(mod => ({ mod: mod.address })),\n } as SentinelConfig,\n })\n const offCallbacks: (() => void)[] = [\n sentinel.on('reportEnd', ({ mod, outPayloads }) => {\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses: progress.witnesses,\n })\n setStatus(outPayloads?.length ? SentinelReportStatus.Succeeded : SentinelReportStatus.Failed)\n setReportingErrors([new Error(`Witness failed [${mod?.config?.name ?? mod.address}]`)])\n }\n }),\n sentinel.on('reportStart', () => {\n if (mounted()) {\n setProgress({ archivists: {}, witnesses: {} })\n setStatus(SentinelReportStatus.Started)\n }\n }),\n ]\n if (witnesses)\n for (const witness of witnesses) {\n offCallbacks.push(\n witness.on('observeEnd', ({ mod, outPayloads }) => {\n const witnesses = progress.witnesses ?? {}\n witnesses[witness.address] = {\n status: outPayloads?.length ? SentinelReportStatus.Succeeded : SentinelReportStatus.Failed,\n witness: asWitnessInstance(mod, () => `Module is not a witness [${mod.id}]`, { required: true }),\n }\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses,\n })\n }\n }),\n witness.on('observeStart', ({ mod }) => {\n const witnesses = progress.witnesses ?? {}\n witnesses[witness.address] = {\n status: SentinelReportStatus.Started,\n witness: asWitnessInstance(mod, () => `Module is not a witness [${mod.id}]`, { required: true }),\n }\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses,\n })\n }\n }),\n )\n }\n setSentinel(sentinel as MemorySentinel)\n setHistory(sentinel?.history as BoundWitness[])\n return () => {\n // unsubscribe from events\n for (const callback of offCallbacks) {\n callback()\n }\n }\n },\n\n [account, archivist, witnesses],\n )\n\n const value: SentinelContextState = useMemo(() => ({\n history, progress, provided: true, reportingErrors, sentinel, status,\n }), [history, progress, reportingErrors, sentinel, status])\n\n return !required || sentinel\n\n ? (\n <SentinelContext value={value}>\n {children}\n </SentinelContext>\n )\n : null\n}\n","import type { ContextExState } from '@xylabs/react-shared'\nimport type { EnumValue } from '@xylabs/sdk-js'\nimport { Enum } from '@xylabs/sdk-js'\nimport type { ArchivistModuleInstance } from '@xyo-network/archivist-model'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport type { SentinelModule } from '@xyo-network/sentinel-model'\nimport type { WitnessModule } from '@xyo-network/witness-model'\n\nexport const SentinelReportStatus = Enum({\n Idle: 'idle',\n Queued: 'queued',\n Started: 'started',\n Succeeded: 'succeeded',\n Failed: 'failed',\n})\n\nexport type SentinelReportStatus = EnumValue<typeof SentinelReportStatus>\n\nexport interface SentinelWitnessReportProgress {\n status: SentinelReportStatus\n witness: WitnessModule\n}\n\nexport interface SentinelArchivistApiReportProgress {\n archivist: ArchivistModuleInstance\n status: SentinelReportStatus\n}\n\nexport interface SentinelReportProgress {\n archivists?: Record<string, SentinelArchivistApiReportProgress>\n witnesses?: Record<string, SentinelWitnessReportProgress>\n}\n\nexport type SentinelContextState = ContextExState<{\n history?: BoundWitness[]\n progress?: SentinelReportProgress\n reportingErrors?: Error[]\n sentinel?: SentinelModule\n status?: SentinelReportStatus\n}>\n","import { useContextEx } from '@xylabs/react-shared'\n\nimport { SentinelContext } from './Context.ts'\n\nexport const useSentinelContext = () => {\n const {\n sentinel, history, progress, reportingErrors, status,\n } = useContextEx(SentinelContext, 'Sentinel')\n return {\n history, progress, reportingErrors, sentinel, status,\n }\n}\n","import type { ModuleFromNodeConfig } from '@xyo-network/react-node'\nimport { useModuleFromNode } from '@xyo-network/react-node'\nimport type { SentinelInstance } from '@xyo-network/sentinel-model'\nimport { asSentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useSentinelFromNode = (\n nameOrAddressOrInstance?: string | SentinelInstance,\n config?: ModuleFromNodeConfig,\n): [SentinelInstance | undefined, Error | undefined] => {\n const [mod, error] = useModuleFromNode(nameOrAddressOrInstance, config)\n const instance = asSentinelInstance(mod)\n if (mod && !instance) {\n const error = new Error(`Resolved module is not a SentinelInstance [${mod.config?.schema}:${mod.config?.name}:${mod.address}]`)\n console.error(error.message)\n return [undefined, error]\n }\n return [instance, error]\n}\n","import type { ModuleIdentifier } from '@xyo-network/module-model'\nimport type { ModuleFromNodeConfig } from '@xyo-network/react-node'\nimport { useModulesFromNode } from '@xyo-network/react-node'\nimport type { SentinelInstance } from '@xyo-network/sentinel-model'\nimport { isSentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useSentinelsFromNode = (\n ids?: ModuleIdentifier[],\n config?: ModuleFromNodeConfig,\n): [SentinelInstance[] | null | undefined, Error | undefined] => {\n const [modules, error] = useModulesFromNode(ids, config)\n if (error) {\n return [null, error]\n }\n return modules\n ? [\n // eslint-disable-next-line unicorn/no-array-reduce\n modules.reduce<SentinelInstance[]>((prev, mod) => {\n if (isSentinelInstance(mod)) {\n prev.push(mod)\n }\n return prev\n }, []),\n undefined,\n ]\n : [modules, error]\n}\n","import type { WeakModuleFromNodeConfig } from '@xyo-network/react-node'\nimport { useWeakModuleFromNode } from '@xyo-network/react-node'\nimport type { SentinelInstance } from '@xyo-network/sentinel-model'\nimport { isSentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useWeakSentinelFromNode = (\n nameOrAddressOrInstance?: string | SentinelInstance,\n config?: WeakModuleFromNodeConfig,\n): [WeakRef<SentinelInstance> | undefined, Error | undefined] => {\n return useWeakModuleFromNode<SentinelInstance>(nameOrAddressOrInstance, { identity: isSentinelInstance, ...config })\n}\n","import { exists } from '@xylabs/sdk-js'\nimport type { ModuleIdentifier } from '@xyo-network/module-model'\nimport type { ModuleFromNodeConfig } from '@xyo-network/react-node'\nimport { useWeakModulesFromNode } from '@xyo-network/react-node'\nimport type { SentinelInstance } from '@xyo-network/sentinel-model'\nimport { asSentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useWeakSentinelsFromNode = (\n ids?: ModuleIdentifier[],\n config?: ModuleFromNodeConfig,\n): [WeakRef<SentinelInstance>[] | null | undefined, Error | undefined] => {\n const [modules, error] = useWeakModulesFromNode(ids, config)\n if (error) {\n return [null, error]\n }\n return [\n modules\n ?.map((mod) => {\n const instance = asSentinelInstance(mod?.deref())\n if (instance) {\n return new WeakRef(instance)\n }\n })\n .filter(exists) ?? [],\n undefined,\n ]\n}\n"],"mappings":";AACA,SAAS,YAAY;AACrB,SAAS,kBAAkB;AAI3B,SAAgB,gBAAgB;;;ACLhC,SAAS,gBAAgB;AAEzB,SAAS,yBAAyB;AAc5B;AALC,IAAM,sBAA0D,CAAC;AAAA,EACtE;AAAA,EAAU;AAAA,EAAK,GAAG;AACpB,MAAM;AACJ,SACE,oBAAC,qBAAkB,KAAW,GAAG,OAC/B,8BAAC,YAAS,SAAS,MAAM,WAAW,GAAG,GAAG,MAAK,SAAQ,SAAQ,YAAW,oBAE1E,GACF;AAEJ;;;ACrBA,SAAS,mBAAmB;AAG5B,SAAS,yBAAyB;AAClC,SAAS,oBAAoB;AAcvB,SAEM,OAAAA,MAFN;AALC,IAAM,sBAA0D,CAAC;AAAA,EACtE;AAAA,EAAU;AAAA,EAAQ;AAAA,EAAK,GAAG;AAC5B,MAAM;AACJ,SACE,gBAAAA,KAAC,qBAAkB,KAAW,GAAG,OAC/B,+BAAC,eAAY,UAAS,QAAO,gBAAe,SAAQ,KAAK,GACtD;AAAA,aACG,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;;ACzBA,SAAS,6BAA6B;AAEtC,SAAS,sBAAAC,2BAA0B;AAE5B,IAAM,0BAA0B,CACrC,yBACA,WAC+D;AAC/D,SAAO,sBAAwC,yBAAyB,EAAE,UAAUA,qBAAoB,GAAG,OAAO,CAAC;AACrH;;;ACVA,SAAS,cAAc;AAGvB,SAAS,8BAA8B;AAEvC,SAAS,sBAAAC,2BAA0B;AAE5B,IAAM,2BAA2B,CACtC,KACA,WACwE;AACxE,QAAM,CAAC,SAAS,KAAK,IAAI,uBAAuB,KAAK,MAAM;AAC3D,MAAI,OAAO;AACT,WAAO,CAAC,MAAM,KAAK;AAAA,EACrB;AACA,SAAO;AAAA,IACL,SACI,IAAI,CAAC,QAAQ;AACb,YAAM,WAAWA,oBAAmB,KAAK,MAAM,CAAC;AAChD,UAAI,UAAU;AACZ,eAAO,IAAI,QAAQ,QAAQ;AAAA,MAC7B;AAAA,IACF,CAAC,EACA,OAAO,MAAM,KAAK,CAAC;AAAA,IACtB;AAAA,EACF;AACF;","names":["jsx","jsx","jsx","jsxs","useState","jsx","useState","sentinel","witnesses","error","isSentinelInstance","asSentinelInstance"]}
|