@xyo-network/react-sentinel 2.77.0-rc.1 → 2.77.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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 { Card, CardProps } from '@mui/material'\nimport { usePromise } from '@xylabs/react-promise'\nimport { Payload } from '@xyo-network/payload-model'\nimport { ModuleRenderProps } from '@xyo-network/react-module'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\nimport { useState } from 'react'\n\nimport { SentinelCardActions } from './CardActions'\nimport { SentinelCardContent } from './CardContent'\nimport { SentinelCardHeader } from './CardHeader'\n\nexport type SentinelCardProps = CardProps &\n ModuleRenderProps<SentinelInstance> & {\n inPayloads?: Payload[]\n }\n\nexport const SentinelCard: React.FC<SentinelCardProps> = ({ children, inPayloads, mod, ...props }) => {\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 { CardActionsProps } from '@mui/material'\nimport { ButtonEx } from '@xylabs/react-button'\nimport { ModuleCardActions, ModuleRenderProps } from '@xyo-network/react-module'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport type SentinelCardActionsProps = ModuleRenderProps<SentinelInstance> &\n CardActionsProps & {\n onReport?: (mod?: SentinelInstance) => void\n }\n\nexport const SentinelCardActions: React.FC<SentinelCardActionsProps> = ({ onReport, mod, ...props }) => {\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 { CardContentProps } from '@mui/material'\nimport { FlexGrowRow } from '@xylabs/react-flexbox'\nimport { Payload } from '@xyo-network/payload-model'\nimport { ModuleCardContent, ModuleRenderProps } from '@xyo-network/react-module'\nimport { JsonViewerEx } from '@xyo-network/react-payload-raw-info'\nimport { 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> = ({ children, report, mod, ...props }) => {\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 { CardHeaderProps } from '@mui/material'\nimport { ModuleCardHeader, ModuleRenderProps } from '@xyo-network/react-module'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const SentinelCardHeader: React.FC<ModuleRenderProps<SentinelInstance> & CardHeaderProps> = ({ title, mod, ...props }) => {\n return <ModuleCardHeader mod={mod} title={title ?? mod?.config.name ?? 'Sentinel'} {...props} />\n}\n","import { createContextEx } from '@xyo-network/react-shared'\n\nimport { SentinelContextState } from './State'\n\nexport const SentinelContext = createContextEx<SentinelContextState>()\n","/* eslint-disable unicorn/no-array-push-push */\nimport { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { WithChildren } from '@xylabs/react-shared'\nimport { AccountInstance } from '@xyo-network/account-model'\nimport { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { ModuleFilter } from '@xyo-network/module-model'\nimport { useWitnessesFromNode } from '@xyo-network/react-witness'\nimport { MemorySentinel } from '@xyo-network/sentinel-memory'\nimport { SentinelConfig, SentinelConfigSchema } from '@xyo-network/sentinel-model'\nimport { asWitnessInstance, WitnessInstance } from '@xyo-network/witness-model'\nimport { useEffect, useState } from 'react'\n\nimport { SentinelContext } from './Context'\nimport { SentinelReportProgress, SentinelReportStatus } from './State'\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 filter?: ModuleFilter\n name?: string\n required?: boolean\n witnesses?: WitnessInstance[]\n}\n\nexport const SentinelProvider: React.FC<WithChildren<SentinelProviderProps>> = ({ account, archivist, children, filter, name, required = false }) => {\n const [sentinel, setSentinel] = useState<MemorySentinel>()\n const [history, setHistory] = useState<BoundWitness[]>()\n const [progress, setProgress] = useState<SentinelReportProgress>({})\n const [status, setStatus] = useState(SentinelReportStatus.Idle)\n const [reportingErrors, setReportingErrors] = useState<Error[]>()\n const [witnesses] = useWitnessesFromNode(filter)\n\n useAsyncEffect(\n // eslint-disable-next-line react-hooks/exhaustive-deps\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 // eslint-disable-next-line id-denylist\n tasks: witnesses?.map((mod) => ({ module: mod.address })),\n } as SentinelConfig,\n })\n const offCallbacks: (() => void)[] = []\n offCallbacks.push(\n sentinel.on('reportEnd', ({ module: 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 )\n offCallbacks.push(\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', ({ module: 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}]`),\n }\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses,\n })\n }\n }),\n )\n offCallbacks.push(\n witness.on('observeStart', ({ module: 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}]`),\n }\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses,\n })\n }\n }),\n )\n }\n setSentinel(sentinel as MemorySentinel)\n return () => {\n //unsubscribe from events\n for (const callback of offCallbacks) {\n callback()\n }\n }\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [account, archivist, witnesses],\n )\n\n useEffect(() => {\n setHistory(sentinel?.history as BoundWitness[])\n }, [sentinel])\n\n return !required || sentinel ?\n <SentinelContext.Provider value={{ history, progress, provided: true, reportingErrors, sentinel, status }}>{children}</SentinelContext.Provider>\n : null\n}\n","import { ArchivistModule } from '@xyo-network/archivist-model'\nimport { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { SentinelModule } from '@xyo-network/sentinel-model'\nimport { WitnessModule } from '@xyo-network/witness-model'\n\nexport enum SentinelReportStatus {\n Idle = 'idle',\n Queued = 'queued',\n Started = 'started',\n Succeeded = 'succeeded',\n Failed = 'failed',\n}\n\nexport interface SentinelWitnessReportProgress {\n status: SentinelReportStatus\n witness: WitnessModule\n}\n\nexport interface SentinelArchivistApiReportProgress {\n archivist: ArchivistModule\n status: SentinelReportStatus\n}\n\nexport interface SentinelReportProgress {\n archivists?: Record<string, SentinelArchivistApiReportProgress>\n witnesses?: Record<string, SentinelWitnessReportProgress>\n}\n\nexport interface SentinelContextState {\n history?: BoundWitness[]\n progress?: SentinelReportProgress\n reportingErrors?: Error[]\n sentinel?: SentinelModule\n status?: SentinelReportStatus\n}\n","import { useContextEx } from '@xyo-network/react-shared'\n\nimport { SentinelContext } from './Context'\n\nexport const useSentinelContext = () => {\n const { sentinel, history, progress, reportingErrors, status } = useContextEx(SentinelContext, 'Sentinel')\n return { history, progress, reportingErrors, sentinel, status }\n}\n","// eslint-disable-next-line import/no-deprecated\nimport { ModuleFromNodeConfig, useModuleFromNode } from '@xyo-network/react-node'\nimport { asSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useSentinelFromNode = (\n nameOrAddressOrInstance?: string | SentinelInstance,\n config?: ModuleFromNodeConfig,\n): [SentinelInstance | undefined, Error | undefined] => {\n // eslint-disable-next-line deprecation/deprecation, import/no-deprecated\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 { ModuleFilter } from '@xyo-network/module-model'\n// eslint-disable-next-line import/no-deprecated\nimport { ModuleFromNodeConfig, useModulesFromNode } from '@xyo-network/react-node'\nimport { isSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useSentinelsFromNode = (\n filter?: ModuleFilter,\n config?: ModuleFromNodeConfig,\n): [SentinelInstance[] | null | undefined, Error | undefined] => {\n // eslint-disable-next-line deprecation/deprecation, import/no-deprecated\n const [modules, error] = useModulesFromNode(filter, 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 { useWeakModuleFromNode, WeakModuleFromNodeConfig } from '@xyo-network/react-node'\nimport { isSentinelInstance, SentinelInstance } 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/exists'\nimport { ModuleFilter } from '@xyo-network/module-model'\nimport { ModuleFromNodeConfig, useWeakModulesFromNode } from '@xyo-network/react-node'\nimport { asSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useWeakSentinelsFromNode = (\n filter?: ModuleFilter,\n config?: ModuleFromNodeConfig,\n): [WeakRef<SentinelInstance>[] | null | undefined, Error | undefined] => {\n const [modules, error] = useWeakModulesFromNode(filter, 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":";AAAA,SAAS,YAAuB;AAChC,SAAS,kBAAkB;AAI3B,SAAS,gBAAgB;;;ACJzB,SAAS,gBAAgB;AACzB,SAAS,yBAA4C;AAW/C;AAHC,IAAM,sBAA0D,CAAC,EAAE,UAAU,KAAK,GAAG,MAAM,MAAM;AACtG,SACE,oBAAC,qBAAkB,KAAW,GAAG,OAC/B,8BAAC,YAAS,SAAS,MAAM,WAAW,GAAG,GAAG,MAAM,SAAS,SAAS,YAAY,oBAE9E,GACF;AAEJ;;;ACjBA,SAAS,mBAAmB;AAE5B,SAAS,yBAA4C;AACrD,SAAS,oBAAoB;AAYvB,SAEI,OAAAA,MAFJ;AAHC,IAAM,sBAA0D,CAAC,EAAE,UAAU,QAAQ,KAAK,GAAG,MAAM,MAAM;AAC9G,SACE,gBAA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BACA,WAC+D;AAC/D,SAAO,sBAAwC,yBAAyB,EAAE,UAAUA,qBAAoB,GAAG,OAAO,CAAC;AACrH;;;ACRA,SAAS,cAAc;AAEvB,SAA+B,8BAA8B;AAC7D,SAAS,sBAAAC,2BAA4C;AAE9C,IAAM,2BAA2B,CACtC,QACA,WACwE;AACxE,QAAM,CAAC,SAAS,KAAK,IAAI,uBAAuB,QAAQ,MAAM;AAC9D,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","SentinelReportStatus","jsx","useState","sentinel","witnesses","error","isSentinelInstance","asSentinelInstance"]}
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 { Card, CardProps } from '@mui/material'\nimport { usePromise } from '@xylabs/react-promise'\nimport { Payload } from '@xyo-network/payload-model'\nimport { ModuleRenderProps } from '@xyo-network/react-module'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\nimport { useState } from 'react'\n\nimport { SentinelCardActions } from './CardActions'\nimport { SentinelCardContent } from './CardContent'\nimport { SentinelCardHeader } from './CardHeader'\n\nexport type SentinelCardProps = CardProps &\n ModuleRenderProps<SentinelInstance> & {\n inPayloads?: Payload[]\n }\n\nexport const SentinelCard: React.FC<SentinelCardProps> = ({ children, inPayloads, mod, ...props }) => {\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 { CardActionsProps } from '@mui/material'\nimport { ButtonEx } from '@xylabs/react-button'\nimport { ModuleCardActions, ModuleRenderProps } from '@xyo-network/react-module'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport type SentinelCardActionsProps = ModuleRenderProps<SentinelInstance> &\n CardActionsProps & {\n onReport?: (mod?: SentinelInstance) => void\n }\n\nexport const SentinelCardActions: React.FC<SentinelCardActionsProps> = ({ onReport, mod, ...props }) => {\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 { CardContentProps } from '@mui/material'\nimport { FlexGrowRow } from '@xylabs/react-flexbox'\nimport { Payload } from '@xyo-network/payload-model'\nimport { ModuleCardContent, ModuleRenderProps } from '@xyo-network/react-module'\nimport { JsonViewerEx } from '@xyo-network/react-payload-raw-info'\nimport { 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> = ({ children, report, mod, ...props }) => {\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 { CardHeaderProps } from '@mui/material'\nimport { ModuleCardHeader, ModuleRenderProps } from '@xyo-network/react-module'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const SentinelCardHeader: React.FC<ModuleRenderProps<SentinelInstance> & CardHeaderProps> = ({ title, mod, ...props }) => {\n return <ModuleCardHeader mod={mod} title={title ?? mod?.config.name ?? 'Sentinel'} {...props} />\n}\n","import { createContextEx } from '@xyo-network/react-shared'\n\nimport { SentinelContextState } from './State'\n\nexport const SentinelContext = createContextEx<SentinelContextState>()\n","/* eslint-disable unicorn/no-array-push-push */\nimport { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { WithChildren } from '@xylabs/react-shared'\nimport { AccountInstance } from '@xyo-network/account-model'\nimport { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { ModuleFilter } from '@xyo-network/module-model'\nimport { useWitnessesFromNode } from '@xyo-network/react-witness'\nimport { MemorySentinel } from '@xyo-network/sentinel-memory'\nimport { SentinelConfig, SentinelConfigSchema } from '@xyo-network/sentinel-model'\nimport { asWitnessInstance, WitnessInstance } from '@xyo-network/witness-model'\nimport { useEffect, useState } from 'react'\n\nimport { SentinelContext } from './Context'\nimport { SentinelReportProgress, SentinelReportStatus } from './State'\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 filter?: ModuleFilter\n name?: string\n required?: boolean\n witnesses?: WitnessInstance[]\n}\n\nexport const SentinelProvider: React.FC<WithChildren<SentinelProviderProps>> = ({ account, archivist, children, filter, name, required = false }) => {\n const [sentinel, setSentinel] = useState<MemorySentinel>()\n const [history, setHistory] = useState<BoundWitness[]>()\n const [progress, setProgress] = useState<SentinelReportProgress>({})\n const [status, setStatus] = useState(SentinelReportStatus.Idle)\n const [reportingErrors, setReportingErrors] = useState<Error[]>()\n const [witnesses] = useWitnessesFromNode(filter)\n\n useAsyncEffect(\n // eslint-disable-next-line react-hooks/exhaustive-deps\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 // eslint-disable-next-line id-denylist\n tasks: witnesses?.map((mod) => ({ module: mod.address })),\n } as SentinelConfig,\n })\n const offCallbacks: (() => void)[] = []\n offCallbacks.push(\n sentinel.on('reportEnd', ({ module: 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 )\n offCallbacks.push(\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', ({ module: 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}]`),\n }\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses,\n })\n }\n }),\n )\n offCallbacks.push(\n witness.on('observeStart', ({ module: 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}]`),\n }\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses,\n })\n }\n }),\n )\n }\n setSentinel(sentinel as MemorySentinel)\n return () => {\n //unsubscribe from events\n for (const callback of offCallbacks) {\n callback()\n }\n }\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [account, archivist, witnesses],\n )\n\n useEffect(() => {\n setHistory(sentinel?.history as BoundWitness[])\n }, [sentinel])\n\n return !required || sentinel ?\n <SentinelContext.Provider value={{ history, progress, provided: true, reportingErrors, sentinel, status }}>{children}</SentinelContext.Provider>\n : null\n}\n","import { ArchivistModule } from '@xyo-network/archivist-model'\nimport { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { SentinelModule } from '@xyo-network/sentinel-model'\nimport { WitnessModule } from '@xyo-network/witness-model'\n\nexport enum SentinelReportStatus {\n Idle = 'idle',\n Queued = 'queued',\n Started = 'started',\n Succeeded = 'succeeded',\n Failed = 'failed',\n}\n\nexport interface SentinelWitnessReportProgress {\n status: SentinelReportStatus\n witness: WitnessModule\n}\n\nexport interface SentinelArchivistApiReportProgress {\n archivist: ArchivistModule\n status: SentinelReportStatus\n}\n\nexport interface SentinelReportProgress {\n archivists?: Record<string, SentinelArchivistApiReportProgress>\n witnesses?: Record<string, SentinelWitnessReportProgress>\n}\n\nexport interface SentinelContextState {\n history?: BoundWitness[]\n progress?: SentinelReportProgress\n reportingErrors?: Error[]\n sentinel?: SentinelModule\n status?: SentinelReportStatus\n}\n","import { useContextEx } from '@xyo-network/react-shared'\n\nimport { SentinelContext } from './Context'\n\nexport const useSentinelContext = () => {\n const { sentinel, history, progress, reportingErrors, status } = useContextEx(SentinelContext, 'Sentinel')\n return { history, progress, reportingErrors, sentinel, status }\n}\n","// eslint-disable-next-line import/no-deprecated\nimport { ModuleFromNodeConfig, useModuleFromNode } from '@xyo-network/react-node'\nimport { asSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useSentinelFromNode = (\n nameOrAddressOrInstance?: string | SentinelInstance,\n config?: ModuleFromNodeConfig,\n): [SentinelInstance | undefined, Error | undefined] => {\n // eslint-disable-next-line deprecation/deprecation, import/no-deprecated\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 { ModuleFilter } from '@xyo-network/module-model'\n// eslint-disable-next-line import/no-deprecated\nimport { ModuleFromNodeConfig, useModulesFromNode } from '@xyo-network/react-node'\nimport { isSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useSentinelsFromNode = (\n filter?: ModuleFilter,\n config?: ModuleFromNodeConfig,\n): [SentinelInstance[] | null | undefined, Error | undefined] => {\n // eslint-disable-next-line deprecation/deprecation, import/no-deprecated\n const [modules, error] = useModulesFromNode(filter, 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 { useWeakModuleFromNode, WeakModuleFromNodeConfig } from '@xyo-network/react-node'\nimport { isSentinelInstance, SentinelInstance } 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/exists'\nimport { ModuleFilter } from '@xyo-network/module-model'\nimport { ModuleFromNodeConfig, useWeakModulesFromNode } from '@xyo-network/react-node'\nimport { asSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useWeakSentinelsFromNode = (\n filter?: ModuleFilter,\n config?: ModuleFromNodeConfig,\n): [WeakRef<SentinelInstance>[] | null | undefined, Error | undefined] => {\n const [modules, error] = useWeakModulesFromNode(filter, 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"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,EACAC,IAC+D,CAE/D,GAAM,CAACC,EAASC,CAAK,EAAIN,GAAmBG,EAAQC,CAAM,EAC1D,OAAIE,EACK,CAAC,KAAMA,CAAK,EAEdD,EACH,CAEEA,EAAQ,OAA2B,CAACE,EAAMC,KACpCP,GAAmBO,CAAG,GACxBD,EAAK,KAAKC,CAAG,EAERD,GACN,CAAC,CAAC,EACL,MACF,EACA,CAACF,EAASC,CAAK,CACrB,EC1BA,OAAS,yBAAAG,OAAuD,0BAChE,OAAS,sBAAAC,OAA4C,8BAE9C,IAAMC,GAA0B,CACrCC,EACAC,IAEOJ,GAAwCG,EAAyB,CAAE,SAAUF,GAAoB,GAAGG,CAAO,CAAC,ECPrH,OAAS,UAAAC,OAAc,iBAEvB,OAA+B,0BAAAC,OAA8B,0BAC7D,OAAS,sBAAAC,OAA4C,8BAE9C,IAAMC,GAA2B,CACtCC,EACAC,IACwE,CACxE,GAAM,CAACC,EAASC,CAAK,EAAIN,GAAuBG,EAAQC,CAAM,EAC9D,OAAIE,EACK,CAAC,KAAMA,CAAK,EAEd,CACLD,GACI,IAAKE,GAAQ,CACb,IAAMC,EAAWP,GAAmBM,GAAK,MAAM,CAAC,EAChD,GAAIC,EACF,OAAO,IAAI,QAAQA,CAAQ,CAE/B,CAAC,EACA,OAAOT,EAAM,GAAK,CAAC,EACtB,MACF,CACF","names":["Card","usePromise","useState","ButtonEx","ModuleCardActions","jsx","SentinelCardActions","onReport","mod","props","FlexGrowRow","ModuleCardContent","JsonViewerEx","jsx","jsxs","SentinelCardContent","children","report","mod","props","ModuleCardHeader","jsx","SentinelCardHeader","title","mod","props","jsx","jsxs","SentinelCard","children","inPayloads","mod","props","retry","setRetry","useState","report","usePromise","Card","SentinelCardHeader","SentinelCardContent","SentinelCardActions","createContextEx","SentinelContext","useAsyncEffect","useWitnessesFromNode","MemorySentinel","SentinelConfigSchema","asWitnessInstance","useEffect","useState","SentinelReportStatus","jsx","SentinelProvider","account","archivist","children","filter","name","required","sentinel","setSentinel","useState","history","setHistory","progress","setProgress","status","setStatus","reportingErrors","setReportingErrors","witnesses","useWitnessesFromNode","useAsyncEffect","mounted","MemorySentinel","SentinelConfigSchema","mod","offCallbacks","outPayloads","witness","asWitnessInstance","callback","useEffect","SentinelContext","useContextEx","useSentinelContext","sentinel","history","progress","reportingErrors","status","useContextEx","SentinelContext","useModuleFromNode","asSentinelInstance","useSentinelFromNode","nameOrAddressOrInstance","config","mod","error","instance","useModulesFromNode","isSentinelInstance","useSentinelsFromNode","filter","config","modules","error","prev","mod","useWeakModuleFromNode","isSentinelInstance","useWeakSentinelFromNode","nameOrAddressOrInstance","config","exists","useWeakModulesFromNode","asSentinelInstance","useWeakSentinelsFromNode","filter","config","modules","error","mod","instance"]}
@@ -4,9 +4,7 @@ import { AccountInstance } from '@xyo-network/account-model';
4
4
  import { ModuleFilter } from '@xyo-network/module-model';
5
5
  import { WitnessInstance } from '@xyo-network/witness-model';
6
6
  export interface SentinelProviderProps {
7
- /** Account used by the sentinel for signing */
8
7
  account: AccountInstance;
9
- /** @deprecated - sentinel no longer uses archive but relies on an archivist */
10
8
  archive?: string;
11
9
  archivist?: string;
12
10
  filter?: ModuleFilter;
@@ -1 +1 @@
1
- {"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../src/contexts/Provider.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAIxD,OAAO,EAAqB,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAM/E,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,MAAM,CAAC,EAAE,YAAY,CAAA;IACrB,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,YAAY,CAAC,qBAAqB,CAAC,CAgG1E,CAAA"}
1
+ {"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../src/contexts/Provider.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAIxD,OAAO,EAAqB,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAM/E,MAAM,WAAW,qBAAqB;IAEpC,OAAO,EAAE,eAAe,CAAA;IAExB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,YAAY,CAAA;IACrB,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,YAAY,CAAC,qBAAqB,CAAC,CAgG1E,CAAA"}
@@ -4,9 +4,7 @@ import { AccountInstance } from '@xyo-network/account-model';
4
4
  import { ModuleFilter } from '@xyo-network/module-model';
5
5
  import { WitnessInstance } from '@xyo-network/witness-model';
6
6
  export interface SentinelProviderProps {
7
- /** Account used by the sentinel for signing */
8
7
  account: AccountInstance;
9
- /** @deprecated - sentinel no longer uses archive but relies on an archivist */
10
8
  archive?: string;
11
9
  archivist?: string;
12
10
  filter?: ModuleFilter;
@@ -1 +1 @@
1
- {"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../src/contexts/Provider.tsx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AgB,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,qBAAqB,CAAC,CAgG1E,CAAA"}
@@ -4,9 +4,7 @@ import { AccountInstance } from '@xyo-network/account-model';
4
4
  import { ModuleFilter } from '@xyo-network/module-model';
5
5
  import { WitnessInstance } from '@xyo-network/witness-model';
6
6
  export interface SentinelProviderProps {
7
- /** Account used by the sentinel for signing */
8
7
  account: AccountInstance;
9
- /** @deprecated - sentinel no longer uses archive but relies on an archivist */
10
8
  archive?: string;
11
9
  archivist?: string;
12
10
  filter?: ModuleFilter;
@@ -1 +1 @@
1
- {"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../src/contexts/Provider.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAIxD,OAAO,EAAqB,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAM/E,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,MAAM,CAAC,EAAE,YAAY,CAAA;IACrB,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,YAAY,CAAC,qBAAqB,CAAC,CAgG1E,CAAA"}
1
+ {"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../src/contexts/Provider.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAE5D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAIxD,OAAO,EAAqB,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAM/E,MAAM,WAAW,qBAAqB;IAEpC,OAAO,EAAE,eAAe,CAAA;IAExB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,YAAY,CAAA;IACrB,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,YAAY,CAAC,qBAAqB,CAAC,CAgG1E,CAAA"}
@@ -1,284 +1,2 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var src_exports = {};
22
- __export(src_exports, {
23
- SentinelCard: () => SentinelCard,
24
- SentinelCardContent: () => SentinelCardContent,
25
- SentinelCardHeader: () => SentinelCardHeader,
26
- SentinelContext: () => SentinelContext,
27
- SentinelProvider: () => SentinelProvider,
28
- SentinelReportStatus: () => SentinelReportStatus,
29
- useSentinelContext: () => useSentinelContext,
30
- useSentinelFromNode: () => useSentinelFromNode,
31
- useSentinelsFromNode: () => useSentinelsFromNode,
32
- useWeakSentinelFromNode: () => useWeakSentinelFromNode,
33
- useWeakSentinelsFromNode: () => useWeakSentinelsFromNode
34
- });
35
- module.exports = __toCommonJS(src_exports);
36
-
37
- // src/components/Card/Card.tsx
38
- var import_material = require("@mui/material");
39
- var import_react_promise = require("@xylabs/react-promise");
40
- var import_react = require("react");
41
-
42
- // src/components/Card/CardActions.tsx
43
- var import_react_button = require("@xylabs/react-button");
44
- var import_react_module = require("@xyo-network/react-module");
45
- var import_jsx_runtime = require("react/jsx-runtime");
46
- var SentinelCardActions = ({ onReport, mod, ...props }) => {
47
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_module.ModuleCardActions, { mod, ...props, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_button.ButtonEx, { onClick: () => onReport == null ? void 0 : onReport(mod), size: "small", variant: "outlined", children: "Report" }) });
48
- };
49
-
50
- // src/components/Card/CardContent.tsx
51
- var import_react_flexbox = require("@xylabs/react-flexbox");
52
- var import_react_module2 = require("@xyo-network/react-module");
53
- var import_react_payload_raw_info = require("@xyo-network/react-payload-raw-info");
54
- var import_jsx_runtime2 = require("react/jsx-runtime");
55
- var SentinelCardContent = ({ children, report, mod, ...props }) => {
56
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_module2.ModuleCardContent, { mod, ...props, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_flexbox.FlexGrowRow, { flexWrap: "wrap", justifyContent: "start", gap: 2, children: [
57
- report ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_payload_raw_info.JsonViewerEx, { value: report }) : null,
58
- children
59
- ] }) });
60
- };
61
-
62
- // src/components/Card/CardHeader.tsx
63
- var import_react_module3 = require("@xyo-network/react-module");
64
- var import_jsx_runtime3 = require("react/jsx-runtime");
65
- var SentinelCardHeader = ({ title, mod, ...props }) => {
66
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_module3.ModuleCardHeader, { mod, title: title ?? (mod == null ? void 0 : mod.config.name) ?? "Sentinel", ...props });
67
- };
68
-
69
- // src/components/Card/Card.tsx
70
- var import_jsx_runtime4 = require("react/jsx-runtime");
71
- var SentinelCard = ({ children, inPayloads, mod, ...props }) => {
72
- const [retry, setRetry] = (0, import_react.useState)(-1);
73
- const [report] = (0, import_react_promise.usePromise)(async () => {
74
- if (retry >= 0) {
75
- return await (mod == null ? void 0 : mod.report(inPayloads));
76
- }
77
- }, [mod, retry, inPayloads]);
78
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_material.Card, { ...props, children: [
79
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(SentinelCardHeader, { mod }),
80
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(SentinelCardContent, { mod, report }),
81
- children,
82
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(SentinelCardActions, { mod, onReport: () => setRetry(retry + 1) })
83
- ] });
84
- };
85
-
86
- // src/contexts/Context.ts
87
- var import_react_shared = require("@xyo-network/react-shared");
88
- var SentinelContext = (0, import_react_shared.createContextEx)();
89
-
90
- // src/contexts/Provider.tsx
91
- var import_react_async_effect = require("@xylabs/react-async-effect");
92
- var import_react_witness = require("@xyo-network/react-witness");
93
- var import_sentinel_memory = require("@xyo-network/sentinel-memory");
94
- var import_sentinel_model = require("@xyo-network/sentinel-model");
95
- var import_witness_model = require("@xyo-network/witness-model");
96
- var import_react2 = require("react");
97
-
98
- // src/contexts/State.ts
99
- var SentinelReportStatus = /* @__PURE__ */ ((SentinelReportStatus2) => {
100
- SentinelReportStatus2["Idle"] = "idle";
101
- SentinelReportStatus2["Queued"] = "queued";
102
- SentinelReportStatus2["Started"] = "started";
103
- SentinelReportStatus2["Succeeded"] = "succeeded";
104
- SentinelReportStatus2["Failed"] = "failed";
105
- return SentinelReportStatus2;
106
- })(SentinelReportStatus || {});
107
-
108
- // src/contexts/Provider.tsx
109
- var import_jsx_runtime5 = require("react/jsx-runtime");
110
- var SentinelProvider = ({ account, archivist, children, filter, name, required = false }) => {
111
- const [sentinel, setSentinel] = (0, import_react2.useState)();
112
- const [history, setHistory] = (0, import_react2.useState)();
113
- const [progress, setProgress] = (0, import_react2.useState)({});
114
- const [status, setStatus] = (0, import_react2.useState)("idle" /* Idle */);
115
- const [reportingErrors, setReportingErrors] = (0, import_react2.useState)();
116
- const [witnesses] = (0, import_react_witness.useWitnessesFromNode)(filter);
117
- (0, import_react_async_effect.useAsyncEffect)(
118
- // eslint-disable-next-line react-hooks/exhaustive-deps
119
- async (mounted) => {
120
- const sentinel2 = await import_sentinel_memory.MemorySentinel.create({
121
- account,
122
- config: {
123
- archivists: archivist ? [archivist] : void 0,
124
- name,
125
- schema: import_sentinel_model.SentinelConfigSchema,
126
- synchronous: true,
127
- // eslint-disable-next-line id-denylist
128
- tasks: witnesses == null ? void 0 : witnesses.map((mod) => ({ module: mod.address }))
129
- }
130
- });
131
- const offCallbacks = [];
132
- offCallbacks.push(
133
- sentinel2.on("reportEnd", ({ module: mod, outPayloads }) => {
134
- var _a;
135
- if (mounted()) {
136
- setProgress({
137
- archivists: progress.archivists,
138
- witnesses: progress.witnesses
139
- });
140
- setStatus((outPayloads == null ? void 0 : outPayloads.length) ? "succeeded" /* Succeeded */ : "failed" /* Failed */);
141
- setReportingErrors([new Error(`Witness failed [${((_a = mod == null ? void 0 : mod.config) == null ? void 0 : _a.name) ?? mod.address}]`)]);
142
- }
143
- })
144
- );
145
- offCallbacks.push(
146
- sentinel2.on("reportStart", () => {
147
- if (mounted()) {
148
- setProgress({ archivists: {}, witnesses: {} });
149
- setStatus("started" /* Started */);
150
- }
151
- })
152
- );
153
- if (witnesses)
154
- for (const witness of witnesses) {
155
- offCallbacks.push(
156
- witness.on("observeEnd", ({ module: mod, outPayloads }) => {
157
- const witnesses2 = progress.witnesses ?? {};
158
- witnesses2[witness.address] = {
159
- status: (outPayloads == null ? void 0 : outPayloads.length) ? "succeeded" /* Succeeded */ : "failed" /* Failed */,
160
- witness: (0, import_witness_model.asWitnessInstance)(mod, () => `Module is not a witness [${mod.id}]`)
161
- };
162
- if (mounted()) {
163
- setProgress({
164
- archivists: progress.archivists,
165
- witnesses: witnesses2
166
- });
167
- }
168
- })
169
- );
170
- offCallbacks.push(
171
- witness.on("observeStart", ({ module: mod }) => {
172
- const witnesses2 = progress.witnesses ?? {};
173
- witnesses2[witness.address] = {
174
- status: "started" /* Started */,
175
- witness: (0, import_witness_model.asWitnessInstance)(mod, () => `Module is not a witness [${mod.id}]`)
176
- };
177
- if (mounted()) {
178
- setProgress({
179
- archivists: progress.archivists,
180
- witnesses: witnesses2
181
- });
182
- }
183
- })
184
- );
185
- }
186
- setSentinel(sentinel2);
187
- return () => {
188
- for (const callback of offCallbacks) {
189
- callback();
190
- }
191
- };
192
- },
193
- // eslint-disable-next-line react-hooks/exhaustive-deps
194
- [account, archivist, witnesses]
195
- );
196
- (0, import_react2.useEffect)(() => {
197
- setHistory(sentinel == null ? void 0 : sentinel.history);
198
- }, [sentinel]);
199
- return !required || sentinel ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SentinelContext.Provider, { value: { history, progress, provided: true, reportingErrors, sentinel, status }, children }) : null;
200
- };
201
-
202
- // src/contexts/use.ts
203
- var import_react_shared2 = require("@xyo-network/react-shared");
204
- var useSentinelContext = () => {
205
- const { sentinel, history, progress, reportingErrors, status } = (0, import_react_shared2.useContextEx)(SentinelContext, "Sentinel");
206
- return { history, progress, reportingErrors, sentinel, status };
207
- };
208
-
209
- // src/hooks/node/useSentinelFromNode.tsx
210
- var import_react_node = require("@xyo-network/react-node");
211
- var import_sentinel_model2 = require("@xyo-network/sentinel-model");
212
- var useSentinelFromNode = (nameOrAddressOrInstance, config) => {
213
- var _a, _b;
214
- const [mod, error] = (0, import_react_node.useModuleFromNode)(nameOrAddressOrInstance, config);
215
- const instance = (0, import_sentinel_model2.asSentinelInstance)(mod);
216
- if (mod && !instance) {
217
- const error2 = new Error(`Resolved module is not a SentinelInstance [${(_a = mod.config) == null ? void 0 : _a.schema}:${(_b = mod.config) == null ? void 0 : _b.name}:${mod.address}]`);
218
- console.error(error2.message);
219
- return [void 0, error2];
220
- }
221
- return [instance, error];
222
- };
223
-
224
- // src/hooks/node/useSentinelsFromNode.tsx
225
- var import_react_node2 = require("@xyo-network/react-node");
226
- var import_sentinel_model3 = require("@xyo-network/sentinel-model");
227
- var useSentinelsFromNode = (filter, config) => {
228
- const [modules, error] = (0, import_react_node2.useModulesFromNode)(filter, config);
229
- if (error) {
230
- return [null, error];
231
- }
232
- return modules ? [
233
- // eslint-disable-next-line unicorn/no-array-reduce
234
- modules.reduce((prev, mod) => {
235
- if ((0, import_sentinel_model3.isSentinelInstance)(mod)) {
236
- prev.push(mod);
237
- }
238
- return prev;
239
- }, []),
240
- void 0
241
- ] : [modules, error];
242
- };
243
-
244
- // src/hooks/node/useWeakSentinelFromNode.tsx
245
- var import_react_node3 = require("@xyo-network/react-node");
246
- var import_sentinel_model4 = require("@xyo-network/sentinel-model");
247
- var useWeakSentinelFromNode = (nameOrAddressOrInstance, config) => {
248
- return (0, import_react_node3.useWeakModuleFromNode)(nameOrAddressOrInstance, { identity: import_sentinel_model4.isSentinelInstance, ...config });
249
- };
250
-
251
- // src/hooks/node/useWeakSentinelsFromNode.tsx
252
- var import_exists = require("@xylabs/exists");
253
- var import_react_node4 = require("@xyo-network/react-node");
254
- var import_sentinel_model5 = require("@xyo-network/sentinel-model");
255
- var useWeakSentinelsFromNode = (filter, config) => {
256
- const [modules, error] = (0, import_react_node4.useWeakModulesFromNode)(filter, config);
257
- if (error) {
258
- return [null, error];
259
- }
260
- return [
261
- (modules == null ? void 0 : modules.map((mod) => {
262
- const instance = (0, import_sentinel_model5.asSentinelInstance)(mod == null ? void 0 : mod.deref());
263
- if (instance) {
264
- return new WeakRef(instance);
265
- }
266
- }).filter(import_exists.exists)) ?? [],
267
- void 0
268
- ];
269
- };
270
- // Annotate the CommonJS export names for ESM import in node:
271
- 0 && (module.exports = {
272
- SentinelCard,
273
- SentinelCardContent,
274
- SentinelCardHeader,
275
- SentinelContext,
276
- SentinelProvider,
277
- SentinelReportStatus,
278
- useSentinelContext,
279
- useSentinelFromNode,
280
- useSentinelsFromNode,
281
- useWeakSentinelFromNode,
282
- useWeakSentinelsFromNode
283
- });
1
+ "use strict";var h=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var de=Object.getOwnPropertyNames;var ae=Object.prototype.hasOwnProperty;var pe=(r,e)=>{for(var n in e)h(r,n,{get:e[n],enumerable:!0})},ce=(r,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of de(e))!ae.call(r,t)&&t!==n&&h(r,t,{get:()=>e[t],enumerable:!(o=le(e,t))||o.enumerable});return r};var me=r=>ce(h({},"__esModule",{value:!0}),r);var Pe={};pe(Pe,{SentinelCard:()=>fe,SentinelCardContent:()=>I,SentinelCardHeader:()=>R,SentinelContext:()=>C,SentinelProvider:()=>ue,SentinelReportStatus:()=>J,useSentinelContext:()=>Se,useSentinelFromNode:()=>Ce,useSentinelsFromNode:()=>ge,useWeakSentinelFromNode:()=>Me,useWeakSentinelsFromNode:()=>xe});module.exports=me(Pe);var b=require("@mui/material"),q=require("@xylabs/react-promise"),G=require("react");var E=require("@xylabs/react-button"),A=require("@xyo-network/react-module"),F=require("react/jsx-runtime"),N=({onReport:r,mod:e,...n})=>(0,F.jsx)(A.ModuleCardActions,{mod:e,...n,children:(0,F.jsx)(E.ButtonEx,{onClick:()=>r==null?void 0:r(e),size:"small",variant:"outlined",children:"Report"})});var y=require("@xylabs/react-flexbox"),k=require("@xyo-network/react-module"),B=require("@xyo-network/react-payload-raw-info"),S=require("react/jsx-runtime"),I=({children:r,report:e,mod:n,...o})=>(0,S.jsx)(k.ModuleCardContent,{mod:n,...o,children:(0,S.jsxs)(y.FlexGrowRow,{flexWrap:"wrap",justifyContent:"start",gap:2,children:[e?(0,S.jsx)(B.JsonViewerEx,{value:e}):null,r]})});var H=require("@xyo-network/react-module"),$=require("react/jsx-runtime"),R=({title:r,mod:e,...n})=>(0,$.jsx)(H.ModuleCardHeader,{mod:e,title:r??(e==null?void 0:e.config.name)??"Sentinel",...n});var f=require("react/jsx-runtime"),fe=({children:r,inPayloads:e,mod:n,...o})=>{let[t,s]=(0,G.useState)(-1),[l]=(0,q.usePromise)(async()=>{if(t>=0)return await(n==null?void 0:n.report(e))},[n,t,e]);return(0,f.jsxs)(b.Card,{...o,children:[(0,f.jsx)(R,{mod:n}),(0,f.jsx)(I,{mod:n,report:l}),r,(0,f.jsx)(N,{mod:n,onReport:()=>s(t+1)})]})};var z=require("@xyo-network/react-shared"),C=(0,z.createContextEx)();var Q=require("@xylabs/react-async-effect"),V=require("@xyo-network/react-witness"),D=require("@xyo-network/sentinel-memory"),K=require("@xyo-network/sentinel-model"),v=require("@xyo-network/witness-model"),p=require("react");var J=(s=>(s.Idle="idle",s.Queued="queued",s.Started="started",s.Succeeded="succeeded",s.Failed="failed",s))(J||{});var L=require("react/jsx-runtime"),ue=({account:r,archivist:e,children:n,filter:o,name:t,required:s=!1})=>{let[l,g]=(0,p.useState)(),[re,te]=(0,p.useState)(),[c,M]=(0,p.useState)({}),[oe,W]=(0,p.useState)("idle"),[se,ie]=(0,p.useState)(),[m]=(0,V.useWitnessesFromNode)(o);return(0,Q.useAsyncEffect)(async x=>{let P=await D.MemorySentinel.create({account:r,config:{archivists:e?[e]:void 0,name:t,schema:K.SentinelConfigSchema,synchronous:!0,tasks:m==null?void 0:m.map(i=>({module:i.address}))}}),u=[];if(u.push(P.on("reportEnd",({module:i,outPayloads:d})=>{var a;x()&&(M({archivists:c.archivists,witnesses:c.witnesses}),W(d!=null&&d.length?"succeeded":"failed"),ie([new Error(`Witness failed [${((a=i==null?void 0:i.config)==null?void 0:a.name)??i.address}]`)]))})),u.push(P.on("reportStart",()=>{x()&&(M({archivists:{},witnesses:{}}),W("started"))})),m)for(let i of m)u.push(i.on("observeEnd",({module:d,outPayloads:a})=>{let w=c.witnesses??{};w[i.address]={status:a!=null&&a.length?"succeeded":"failed",witness:(0,v.asWitnessInstance)(d,()=>`Module is not a witness [${d.id}]`)},x()&&M({archivists:c.archivists,witnesses:w})})),u.push(i.on("observeStart",({module:d})=>{let a=c.witnesses??{};a[i.address]={status:"started",witness:(0,v.asWitnessInstance)(d,()=>`Module is not a witness [${d.id}]`)},x()&&M({archivists:c.archivists,witnesses:a})}));return g(P),()=>{for(let i of u)i()}},[r,e,m]),(0,p.useEffect)(()=>{te(l==null?void 0:l.history)},[l]),!s||l?(0,L.jsx)(C.Provider,{value:{history:re,progress:c,provided:!0,reportingErrors:se,sentinel:l,status:oe},children:n}):null};var O=require("@xyo-network/react-shared");var Se=()=>{let{sentinel:r,history:e,progress:n,reportingErrors:o,status:t}=(0,O.useContextEx)(C,"Sentinel");return{history:e,progress:n,reportingErrors:o,sentinel:r,status:t}};var T=require("@xyo-network/react-node"),U=require("@xyo-network/sentinel-model"),Ce=(r,e)=>{var s,l;let[n,o]=(0,T.useModuleFromNode)(r,e),t=(0,U.asSentinelInstance)(n);if(n&&!t){let g=new Error(`Resolved module is not a SentinelInstance [${(s=n.config)==null?void 0:s.schema}:${(l=n.config)==null?void 0:l.name}:${n.address}]`);return console.error(g.message),[void 0,g]}return[t,o]};var X=require("@xyo-network/react-node"),Y=require("@xyo-network/sentinel-model"),ge=(r,e)=>{let[n,o]=(0,X.useModulesFromNode)(r,e);return o?[null,o]:n?[n.reduce((t,s)=>((0,Y.isSentinelInstance)(s)&&t.push(s),t),[]),void 0]:[n,o]};var Z=require("@xyo-network/react-node"),_=require("@xyo-network/sentinel-model"),Me=(r,e)=>(0,Z.useWeakModuleFromNode)(r,{identity:_.isSentinelInstance,...e});var j=require("@xylabs/exists"),ee=require("@xyo-network/react-node"),ne=require("@xyo-network/sentinel-model"),xe=(r,e)=>{let[n,o]=(0,ee.useWeakModulesFromNode)(r,e);return o?[null,o]:[(n==null?void 0:n.map(t=>{let s=(0,ne.asSentinelInstance)(t==null?void 0:t.deref());if(s)return new WeakRef(s)}).filter(j.exists))??[],void 0]};0&&(module.exports={SentinelCard,SentinelCardContent,SentinelCardHeader,SentinelContext,SentinelProvider,SentinelReportStatus,useSentinelContext,useSentinelFromNode,useSentinelsFromNode,useWeakSentinelFromNode,useWeakSentinelsFromNode});
284
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts","../../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":["export * from './components'\nexport * from './contexts'\nexport * from './hooks'\n","import { Card, CardProps } from '@mui/material'\nimport { usePromise } from '@xylabs/react-promise'\nimport { Payload } from '@xyo-network/payload-model'\nimport { ModuleRenderProps } from '@xyo-network/react-module'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\nimport { useState } from 'react'\n\nimport { SentinelCardActions } from './CardActions'\nimport { SentinelCardContent } from './CardContent'\nimport { SentinelCardHeader } from './CardHeader'\n\nexport type SentinelCardProps = CardProps &\n ModuleRenderProps<SentinelInstance> & {\n inPayloads?: Payload[]\n }\n\nexport const SentinelCard: React.FC<SentinelCardProps> = ({ children, inPayloads, mod, ...props }) => {\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 { CardActionsProps } from '@mui/material'\nimport { ButtonEx } from '@xylabs/react-button'\nimport { ModuleCardActions, ModuleRenderProps } from '@xyo-network/react-module'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport type SentinelCardActionsProps = ModuleRenderProps<SentinelInstance> &\n CardActionsProps & {\n onReport?: (mod?: SentinelInstance) => void\n }\n\nexport const SentinelCardActions: React.FC<SentinelCardActionsProps> = ({ onReport, mod, ...props }) => {\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 { CardContentProps } from '@mui/material'\nimport { FlexGrowRow } from '@xylabs/react-flexbox'\nimport { Payload } from '@xyo-network/payload-model'\nimport { ModuleCardContent, ModuleRenderProps } from '@xyo-network/react-module'\nimport { JsonViewerEx } from '@xyo-network/react-payload-raw-info'\nimport { 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> = ({ children, report, mod, ...props }) => {\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 { CardHeaderProps } from '@mui/material'\nimport { ModuleCardHeader, ModuleRenderProps } from '@xyo-network/react-module'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const SentinelCardHeader: React.FC<ModuleRenderProps<SentinelInstance> & CardHeaderProps> = ({ title, mod, ...props }) => {\n return <ModuleCardHeader mod={mod} title={title ?? mod?.config.name ?? 'Sentinel'} {...props} />\n}\n","import { createContextEx } from '@xyo-network/react-shared'\n\nimport { SentinelContextState } from './State'\n\nexport const SentinelContext = createContextEx<SentinelContextState>()\n","/* eslint-disable unicorn/no-array-push-push */\nimport { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { WithChildren } from '@xylabs/react-shared'\nimport { AccountInstance } from '@xyo-network/account-model'\nimport { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { ModuleFilter } from '@xyo-network/module-model'\nimport { useWitnessesFromNode } from '@xyo-network/react-witness'\nimport { MemorySentinel } from '@xyo-network/sentinel-memory'\nimport { SentinelConfig, SentinelConfigSchema } from '@xyo-network/sentinel-model'\nimport { asWitnessInstance, WitnessInstance } from '@xyo-network/witness-model'\nimport { useEffect, useState } from 'react'\n\nimport { SentinelContext } from './Context'\nimport { SentinelReportProgress, SentinelReportStatus } from './State'\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 filter?: ModuleFilter\n name?: string\n required?: boolean\n witnesses?: WitnessInstance[]\n}\n\nexport const SentinelProvider: React.FC<WithChildren<SentinelProviderProps>> = ({ account, archivist, children, filter, name, required = false }) => {\n const [sentinel, setSentinel] = useState<MemorySentinel>()\n const [history, setHistory] = useState<BoundWitness[]>()\n const [progress, setProgress] = useState<SentinelReportProgress>({})\n const [status, setStatus] = useState(SentinelReportStatus.Idle)\n const [reportingErrors, setReportingErrors] = useState<Error[]>()\n const [witnesses] = useWitnessesFromNode(filter)\n\n useAsyncEffect(\n // eslint-disable-next-line react-hooks/exhaustive-deps\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 // eslint-disable-next-line id-denylist\n tasks: witnesses?.map((mod) => ({ module: mod.address })),\n } as SentinelConfig,\n })\n const offCallbacks: (() => void)[] = []\n offCallbacks.push(\n sentinel.on('reportEnd', ({ module: 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 )\n offCallbacks.push(\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', ({ module: 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}]`),\n }\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses,\n })\n }\n }),\n )\n offCallbacks.push(\n witness.on('observeStart', ({ module: 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}]`),\n }\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses,\n })\n }\n }),\n )\n }\n setSentinel(sentinel as MemorySentinel)\n return () => {\n //unsubscribe from events\n for (const callback of offCallbacks) {\n callback()\n }\n }\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [account, archivist, witnesses],\n )\n\n useEffect(() => {\n setHistory(sentinel?.history as BoundWitness[])\n }, [sentinel])\n\n return !required || sentinel ?\n <SentinelContext.Provider value={{ history, progress, provided: true, reportingErrors, sentinel, status }}>{children}</SentinelContext.Provider>\n : null\n}\n","import { ArchivistModule } from '@xyo-network/archivist-model'\nimport { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { SentinelModule } from '@xyo-network/sentinel-model'\nimport { WitnessModule } from '@xyo-network/witness-model'\n\nexport enum SentinelReportStatus {\n Idle = 'idle',\n Queued = 'queued',\n Started = 'started',\n Succeeded = 'succeeded',\n Failed = 'failed',\n}\n\nexport interface SentinelWitnessReportProgress {\n status: SentinelReportStatus\n witness: WitnessModule\n}\n\nexport interface SentinelArchivistApiReportProgress {\n archivist: ArchivistModule\n status: SentinelReportStatus\n}\n\nexport interface SentinelReportProgress {\n archivists?: Record<string, SentinelArchivistApiReportProgress>\n witnesses?: Record<string, SentinelWitnessReportProgress>\n}\n\nexport interface SentinelContextState {\n history?: BoundWitness[]\n progress?: SentinelReportProgress\n reportingErrors?: Error[]\n sentinel?: SentinelModule\n status?: SentinelReportStatus\n}\n","import { useContextEx } from '@xyo-network/react-shared'\n\nimport { SentinelContext } from './Context'\n\nexport const useSentinelContext = () => {\n const { sentinel, history, progress, reportingErrors, status } = useContextEx(SentinelContext, 'Sentinel')\n return { history, progress, reportingErrors, sentinel, status }\n}\n","// eslint-disable-next-line import/no-deprecated\nimport { ModuleFromNodeConfig, useModuleFromNode } from '@xyo-network/react-node'\nimport { asSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useSentinelFromNode = (\n nameOrAddressOrInstance?: string | SentinelInstance,\n config?: ModuleFromNodeConfig,\n): [SentinelInstance | undefined, Error | undefined] => {\n // eslint-disable-next-line deprecation/deprecation, import/no-deprecated\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 { ModuleFilter } from '@xyo-network/module-model'\n// eslint-disable-next-line import/no-deprecated\nimport { ModuleFromNodeConfig, useModulesFromNode } from '@xyo-network/react-node'\nimport { isSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useSentinelsFromNode = (\n filter?: ModuleFilter,\n config?: ModuleFromNodeConfig,\n): [SentinelInstance[] | null | undefined, Error | undefined] => {\n // eslint-disable-next-line deprecation/deprecation, import/no-deprecated\n const [modules, error] = useModulesFromNode(filter, 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 { useWeakModuleFromNode, WeakModuleFromNodeConfig } from '@xyo-network/react-node'\nimport { isSentinelInstance, SentinelInstance } 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/exists'\nimport { ModuleFilter } from '@xyo-network/module-model'\nimport { ModuleFromNodeConfig, useWeakModulesFromNode } from '@xyo-network/react-node'\nimport { asSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useWeakSentinelsFromNode = (\n filter?: ModuleFilter,\n config?: ModuleFromNodeConfig,\n): [WeakRef<SentinelInstance>[] | null | undefined, Error | undefined] => {\n const [modules, error] = useWeakModulesFromNode(filter, 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":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,sBAAgC;AAChC,2BAA2B;AAI3B,mBAAyB;;;ACJzB,0BAAyB;AACzB,0BAAqD;AAW/C;AAHC,IAAM,sBAA0D,CAAC,EAAE,UAAU,KAAK,GAAG,MAAM,MAAM;AACtG,SACE,4CAAC,yCAAkB,KAAW,G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AACA,aAAO;AAAA,IACT,GAAG,CAAC,CAAC;AAAA,IACL;AAAA,EACF,IACA,CAAC,SAAS,KAAK;AACrB;;;AC1BA,IAAAC,qBAAgE;AAChE,IAAAC,yBAAqD;AAE9C,IAAM,0BAA0B,CACrC,yBACA,WAC+D;AAC/D,aAAO,0CAAwC,yBAAyB,EAAE,UAAU,2CAAoB,GAAG,OAAO,CAAC;AACrH;;;ACRA,oBAAuB;AAEvB,IAAAC,qBAA6D;AAC7D,IAAAC,yBAAqD;AAE9C,IAAM,2BAA2B,CACtC,QACA,WACwE;AACxE,QAAM,CAAC,SAAS,KAAK,QAAI,2CAAuB,QAAQ,MAAM;AAC9D,MAAI,OAAO;AACT,WAAO,CAAC,MAAM,KAAK;AAAA,EACrB;AACA,SAAO;AAAA,KACL,mCACI,IAAI,CAAC,QAAQ;AACb,YAAM,eAAW,2CAAmB,2BAAK,OAAO;AAChD,UAAI,UAAU;AACZ,eAAO,IAAI,QAAQ,QAAQ;AAAA,MAC7B;AAAA,IACF,GACC,OAAO,0BAAW,CAAC;AAAA,IACtB;AAAA,EACF;AACF;","names":["import_react_module","import_jsx_runtime","import_react_module","import_jsx_runtime","import_jsx_runtime","import_react","SentinelReportStatus","import_jsx_runtime","sentinel","witnesses","import_react_shared","import_sentinel_model","error","import_react_node","import_sentinel_model","import_react_node","import_sentinel_model","import_react_node","import_sentinel_model"]}
1
+ {"version":3,"sources":["../../src/index.ts","../../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":["export * from './components'\nexport * from './contexts'\nexport * from './hooks'\n","import { Card, CardProps } from '@mui/material'\nimport { usePromise } from '@xylabs/react-promise'\nimport { Payload } from '@xyo-network/payload-model'\nimport { ModuleRenderProps } from '@xyo-network/react-module'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\nimport { useState } from 'react'\n\nimport { SentinelCardActions } from './CardActions'\nimport { SentinelCardContent } from './CardContent'\nimport { SentinelCardHeader } from './CardHeader'\n\nexport type SentinelCardProps = CardProps &\n ModuleRenderProps<SentinelInstance> & {\n inPayloads?: Payload[]\n }\n\nexport const SentinelCard: React.FC<SentinelCardProps> = ({ children, inPayloads, mod, ...props }) => {\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 { CardActionsProps } from '@mui/material'\nimport { ButtonEx } from '@xylabs/react-button'\nimport { ModuleCardActions, ModuleRenderProps } from '@xyo-network/react-module'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport type SentinelCardActionsProps = ModuleRenderProps<SentinelInstance> &\n CardActionsProps & {\n onReport?: (mod?: SentinelInstance) => void\n }\n\nexport const SentinelCardActions: React.FC<SentinelCardActionsProps> = ({ onReport, mod, ...props }) => {\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 { CardContentProps } from '@mui/material'\nimport { FlexGrowRow } from '@xylabs/react-flexbox'\nimport { Payload } from '@xyo-network/payload-model'\nimport { ModuleCardContent, ModuleRenderProps } from '@xyo-network/react-module'\nimport { JsonViewerEx } from '@xyo-network/react-payload-raw-info'\nimport { 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> = ({ children, report, mod, ...props }) => {\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 { CardHeaderProps } from '@mui/material'\nimport { ModuleCardHeader, ModuleRenderProps } from '@xyo-network/react-module'\nimport { SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const SentinelCardHeader: React.FC<ModuleRenderProps<SentinelInstance> & CardHeaderProps> = ({ title, mod, ...props }) => {\n return <ModuleCardHeader mod={mod} title={title ?? mod?.config.name ?? 'Sentinel'} {...props} />\n}\n","import { createContextEx } from '@xyo-network/react-shared'\n\nimport { SentinelContextState } from './State'\n\nexport const SentinelContext = createContextEx<SentinelContextState>()\n","/* eslint-disable unicorn/no-array-push-push */\nimport { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { WithChildren } from '@xylabs/react-shared'\nimport { AccountInstance } from '@xyo-network/account-model'\nimport { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { ModuleFilter } from '@xyo-network/module-model'\nimport { useWitnessesFromNode } from '@xyo-network/react-witness'\nimport { MemorySentinel } from '@xyo-network/sentinel-memory'\nimport { SentinelConfig, SentinelConfigSchema } from '@xyo-network/sentinel-model'\nimport { asWitnessInstance, WitnessInstance } from '@xyo-network/witness-model'\nimport { useEffect, useState } from 'react'\n\nimport { SentinelContext } from './Context'\nimport { SentinelReportProgress, SentinelReportStatus } from './State'\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 filter?: ModuleFilter\n name?: string\n required?: boolean\n witnesses?: WitnessInstance[]\n}\n\nexport const SentinelProvider: React.FC<WithChildren<SentinelProviderProps>> = ({ account, archivist, children, filter, name, required = false }) => {\n const [sentinel, setSentinel] = useState<MemorySentinel>()\n const [history, setHistory] = useState<BoundWitness[]>()\n const [progress, setProgress] = useState<SentinelReportProgress>({})\n const [status, setStatus] = useState(SentinelReportStatus.Idle)\n const [reportingErrors, setReportingErrors] = useState<Error[]>()\n const [witnesses] = useWitnessesFromNode(filter)\n\n useAsyncEffect(\n // eslint-disable-next-line react-hooks/exhaustive-deps\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 // eslint-disable-next-line id-denylist\n tasks: witnesses?.map((mod) => ({ module: mod.address })),\n } as SentinelConfig,\n })\n const offCallbacks: (() => void)[] = []\n offCallbacks.push(\n sentinel.on('reportEnd', ({ module: 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 )\n offCallbacks.push(\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', ({ module: 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}]`),\n }\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses,\n })\n }\n }),\n )\n offCallbacks.push(\n witness.on('observeStart', ({ module: 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}]`),\n }\n if (mounted()) {\n setProgress({\n archivists: progress.archivists,\n witnesses,\n })\n }\n }),\n )\n }\n setSentinel(sentinel as MemorySentinel)\n return () => {\n //unsubscribe from events\n for (const callback of offCallbacks) {\n callback()\n }\n }\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [account, archivist, witnesses],\n )\n\n useEffect(() => {\n setHistory(sentinel?.history as BoundWitness[])\n }, [sentinel])\n\n return !required || sentinel ?\n <SentinelContext.Provider value={{ history, progress, provided: true, reportingErrors, sentinel, status }}>{children}</SentinelContext.Provider>\n : null\n}\n","import { ArchivistModule } from '@xyo-network/archivist-model'\nimport { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { SentinelModule } from '@xyo-network/sentinel-model'\nimport { WitnessModule } from '@xyo-network/witness-model'\n\nexport enum SentinelReportStatus {\n Idle = 'idle',\n Queued = 'queued',\n Started = 'started',\n Succeeded = 'succeeded',\n Failed = 'failed',\n}\n\nexport interface SentinelWitnessReportProgress {\n status: SentinelReportStatus\n witness: WitnessModule\n}\n\nexport interface SentinelArchivistApiReportProgress {\n archivist: ArchivistModule\n status: SentinelReportStatus\n}\n\nexport interface SentinelReportProgress {\n archivists?: Record<string, SentinelArchivistApiReportProgress>\n witnesses?: Record<string, SentinelWitnessReportProgress>\n}\n\nexport interface SentinelContextState {\n history?: BoundWitness[]\n progress?: SentinelReportProgress\n reportingErrors?: Error[]\n sentinel?: SentinelModule\n status?: SentinelReportStatus\n}\n","import { useContextEx } from '@xyo-network/react-shared'\n\nimport { SentinelContext } from './Context'\n\nexport const useSentinelContext = () => {\n const { sentinel, history, progress, reportingErrors, status } = useContextEx(SentinelContext, 'Sentinel')\n return { history, progress, reportingErrors, sentinel, status }\n}\n","// eslint-disable-next-line import/no-deprecated\nimport { ModuleFromNodeConfig, useModuleFromNode } from '@xyo-network/react-node'\nimport { asSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useSentinelFromNode = (\n nameOrAddressOrInstance?: string | SentinelInstance,\n config?: ModuleFromNodeConfig,\n): [SentinelInstance | undefined, Error | undefined] => {\n // eslint-disable-next-line deprecation/deprecation, import/no-deprecated\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 { ModuleFilter } from '@xyo-network/module-model'\n// eslint-disable-next-line import/no-deprecated\nimport { ModuleFromNodeConfig, useModulesFromNode } from '@xyo-network/react-node'\nimport { isSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useSentinelsFromNode = (\n filter?: ModuleFilter,\n config?: ModuleFromNodeConfig,\n): [SentinelInstance[] | null | undefined, Error | undefined] => {\n // eslint-disable-next-line deprecation/deprecation, import/no-deprecated\n const [modules, error] = useModulesFromNode(filter, 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 { useWeakModuleFromNode, WeakModuleFromNodeConfig } from '@xyo-network/react-node'\nimport { isSentinelInstance, SentinelInstance } 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/exists'\nimport { ModuleFilter } from '@xyo-network/module-model'\nimport { ModuleFromNodeConfig, useWeakModulesFromNode } from '@xyo-network/react-node'\nimport { asSentinelInstance, SentinelInstance } from '@xyo-network/sentinel-model'\n\nexport const useWeakSentinelsFromNode = (\n filter?: ModuleFilter,\n config?: ModuleFromNodeConfig,\n): [WeakRef<SentinelInstance>[] | null | undefined, Error | undefined] => {\n const [modules, error] = useWeakModulesFromNode(filter, 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":"mbAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,kBAAAE,GAAA,wBAAAC,EAAA,uBAAAC,EAAA,oBAAAC,EAAA,qBAAAC,GAAA,yBAAAC,EAAA,uBAAAC,GAAA,wBAAAC,GAAA,yBAAAC,GAAA,4BAAAC,GAAA,6BAAAC,KAAA,eAAAC,GAAAb,ICAA,IAAAc,EAAgC,yBAChCC,EAA2B,iCAI3BC,EAAyB,iBCJzB,IAAAC,EAAyB,gCACzBC,EAAqD,qCAW/CC,EAAA,6BAHOC,EAA0D,CAAC,CAAE,SAAAC,EAAU,IAAAC,EAAK,GAAGC,CAAM,OAE9F,OAAC,qBAAkB,IAAKD,EAAM,GAAGC,EAC/B,mBAAC,YAAS,QAAS,IAAMF,GAAA,YAAAA,EAAWC,GAAM,KAAM,QAAS,QAAS,WAAY,kBAE9E,EACF,ECfJ,IAAAE,EAA4B,iCAE5BC,EAAqD,qCACrDC,EAA6B,+CAYvBC,EAAA,6BAHOC,EAA0D,CAAC,CAAE,SAAAC,EAAU,OAAAC,EAAQ,IAAAC,EAAK,GAAGC,CAAM,OAEtG,OAAC,qBAAkB,IAAKD,EAAM,GAAGC,EAC/B,oBAAC,eAAY,SAAS,OAAO,eAAe,QAAQ,IAAK,EACtD,UAAAF,KACC,OAAC,gBAAa,MAAOA,EAAQ,EAC7B,KACDD,GACH,EACF,ECrBJ,IAAAI,EAAoD,qCAI3CC,EAAA,6BADIC,EAAsF,CAAC,CAAE,MAAAC,EAAO,IAAAC,EAAK,GAAGC,CAAM,OACl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MAAM,KAAIC,EAAAC,EAAI,SAAJ,YAAAD,EAAY,IAAI,IAAIC,EAAI,OAAO,GAAG,EAC9H,eAAQ,MAAMC,EAAM,OAAO,EACpB,CAAC,OAAWA,CAAK,CAC1B,CACA,MAAO,CAACC,EAAUD,CAAK,CACzB,ECfA,IAAAE,EAAyD,mCACzDC,EAAqD,uCAExCC,GAAuB,CAClCC,EACAC,IAC+D,CAE/D,GAAM,CAACC,EAASC,CAAK,KAAI,sBAAmBH,EAAQC,CAAM,EAC1D,OAAIE,EACK,CAAC,KAAMA,CAAK,EAEdD,EACH,CAEEA,EAAQ,OAA2B,CAACE,EAAMC,QACpC,sBAAmBA,CAAG,GACxBD,EAAK,KAAKC,CAAG,EAERD,GACN,CAAC,CAAC,EACL,MACF,EACA,CAACF,EAASC,CAAK,CACrB,EC1BA,IAAAG,EAAgE,mCAChEC,EAAqD,uCAExCC,GAA0B,CACrCC,EACAC,OAEO,yBAAwCD,EAAyB,CAAE,SAAU,qBAAoB,GAAGC,CAAO,CAAC,ECPrH,IAAAC,EAAuB,0BAEvBC,GAA6D,mCAC7DC,GAAqD,uCAExCC,GAA2B,CACtCC,EACAC,IACwE,CACxE,GAAM,CAACC,EAASC,CAAK,KAAI,2BAAuBH,EAAQC,CAAM,EAC9D,OAAIE,EACK,CAAC,KAAMA,CAAK,EAEd,EACLD,GAAA,YAAAA,EACI,IAAKE,GAAQ,CACb,IAAMC,KAAW,uBAAmBD,GAAA,YAAAA,EAAK,OAAO,EAChD,GAAIC,EACF,OAAO,IAAI,QAAQA,CAAQ,CAE/B,GACC,OAAO,YAAW,CAAC,EACtB,MACF,CACF","names":["src_exports","__export","SentinelCard","SentinelCardContent","SentinelCardHeader","SentinelContext","SentinelProvider","SentinelReportStatus","useSentinelContext","useSentinelFromNode","useSentinelsFromNode","useWeakSentinelFromNode","useWeakSentinelsFromNode","__toCommonJS","import_material","import_react_promise","import_react","import_react_button","import_react_module","import_jsx_runtime","SentinelCardActions","onReport","mod","props","import_react_flexbox","import_react_module","import_react_payload_raw_info","import_jsx_runtime","SentinelCardContent","children","report","mod","props","import_react_module","import_jsx_runtime","SentinelCardHeader","title","mod","props","import_jsx_runtime","SentinelCard","children","inPayloads","mod","props","retry","setRetry","report","SentinelCardHeader","SentinelCardContent","SentinelCardActions","import_react_shared","SentinelContext","import_react_async_effect","import_react_witness","import_sentinel_memory","import_sentinel_model","import_witness_model","import_react","SentinelReportStatus","import_jsx_runtime","SentinelProvider","account","archivist","children","filter","name","required","sentinel","setSentinel","history","setHistory","progress","setProgress","status","setStatus","reportingErrors","setReportingErrors","witnesses","mounted","mod","offCallbacks","outPayloads","_a","witness","callback","SentinelContext","import_react_shared","useSentinelContext","sentinel","history","progress","reportingErrors","status","SentinelContext","import_react_node","import_sentinel_model","useSentinelFromNode","nameOrAddressOrInstance","config","_a","_b","mod","error","instance","import_react_node","import_sentinel_model","useSentinelsFromNode","filter","config","modules","error","prev","mod","import_react_node","import_sentinel_model","useWeakSentinelFromNode","nameOrAddressOrInstance","config","import_exists","import_react_node","import_sentinel_model","useWeakSentinelsFromNode","filter","config","modules","error","mod","instance"]}