@xyo-network/react-payload 2.23.7
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/LICENSE +165 -0
- package/README.md +69 -0
- package/babel.config.json +5 -0
- package/dist/cjs/components/Details/DataDetails.d.ts +10 -0
- package/dist/cjs/components/Details/DataDetails.js +39 -0
- package/dist/cjs/components/Details/DataDetails.js.map +1 -0
- package/dist/cjs/components/Details/Details.d.ts +15 -0
- package/dist/cjs/components/Details/Details.js +16 -0
- package/dist/cjs/components/Details/Details.js.map +1 -0
- package/dist/cjs/components/Details/HashSourceDetails.d.ts +8 -0
- package/dist/cjs/components/Details/HashSourceDetails.js +18 -0
- package/dist/cjs/components/Details/HashSourceDetails.js.map +1 -0
- package/dist/cjs/components/Details/JsonDetails.d.ts +9 -0
- package/dist/cjs/components/Details/JsonDetails.js +17 -0
- package/dist/cjs/components/Details/JsonDetails.js.map +1 -0
- package/dist/cjs/components/Details/MetaDetails.d.ts +8 -0
- package/dist/cjs/components/Details/MetaDetails.js +16 -0
- package/dist/cjs/components/Details/MetaDetails.js.map +1 -0
- package/dist/cjs/components/Details/ValidationDetails/SchemaProperty.d.ts +4 -0
- package/dist/cjs/components/Details/ValidationDetails/SchemaProperty.js +15 -0
- package/dist/cjs/components/Details/ValidationDetails/SchemaProperty.js.map +1 -0
- package/dist/cjs/components/Details/ValidationDetails/ValidationDetails.d.ts +3 -0
- package/dist/cjs/components/Details/ValidationDetails/ValidationDetails.js +23 -0
- package/dist/cjs/components/Details/ValidationDetails/ValidationDetails.js.map +1 -0
- package/dist/cjs/components/Details/ValidationDetails/ValidationDetailsProps.d.ts +8 -0
- package/dist/cjs/components/Details/ValidationDetails/ValidationDetailsProps.js +3 -0
- package/dist/cjs/components/Details/ValidationDetails/ValidationDetailsProps.js.map +1 -0
- package/dist/cjs/components/Details/ValidationDetails/index.d.ts +2 -0
- package/dist/cjs/components/Details/ValidationDetails/index.js +6 -0
- package/dist/cjs/components/Details/ValidationDetails/index.js.map +1 -0
- package/dist/cjs/components/Details/index.d.ts +5 -0
- package/dist/cjs/components/Details/index.js +9 -0
- package/dist/cjs/components/Details/index.js.map +1 -0
- package/dist/cjs/components/Table/PayloadTableColumnConfig.d.ts +10 -0
- package/dist/cjs/components/Table/PayloadTableColumnConfig.js +22 -0
- package/dist/cjs/components/Table/PayloadTableColumnConfig.js.map +1 -0
- package/dist/cjs/components/Table/Table.d.ts +11 -0
- package/dist/cjs/components/Table/Table.js +25 -0
- package/dist/cjs/components/Table/Table.js.map +1 -0
- package/dist/cjs/components/Table/TableRow.d.ts +11 -0
- package/dist/cjs/components/Table/TableRow.js +43 -0
- package/dist/cjs/components/Table/TableRow.js.map +1 -0
- package/dist/cjs/components/Table/index.d.ts +3 -0
- package/dist/cjs/components/Table/index.js +7 -0
- package/dist/cjs/components/Table/index.js.map +1 -0
- package/dist/cjs/components/index.d.ts +2 -0
- package/dist/cjs/components/index.js +6 -0
- package/dist/cjs/components/index.js.map +1 -0
- package/dist/cjs/hooks/index.d.ts +5 -0
- package/dist/cjs/hooks/index.js +9 -0
- package/dist/cjs/hooks/index.js.map +1 -0
- package/dist/cjs/hooks/lib/FetchHuriHashOptions.d.ts +3 -0
- package/dist/cjs/hooks/lib/FetchHuriHashOptions.js +3 -0
- package/dist/cjs/hooks/lib/FetchHuriHashOptions.js.map +1 -0
- package/dist/cjs/hooks/lib/findHuriNetwork.d.ts +3 -0
- package/dist/cjs/hooks/lib/findHuriNetwork.js +14 -0
- package/dist/cjs/hooks/lib/findHuriNetwork.js.map +1 -0
- package/dist/cjs/hooks/lib/index.d.ts +2 -0
- package/dist/cjs/hooks/lib/index.js +6 -0
- package/dist/cjs/hooks/lib/index.js.map +1 -0
- package/dist/cjs/hooks/useGetSchema.d.ts +11 -0
- package/dist/cjs/hooks/useGetSchema.js +49 -0
- package/dist/cjs/hooks/useGetSchema.js.map +1 -0
- package/dist/cjs/hooks/useHuriHash.d.ts +5 -0
- package/dist/cjs/hooks/useHuriHash.js +24 -0
- package/dist/cjs/hooks/useHuriHash.js.map +1 -0
- package/dist/cjs/hooks/usePayload.d.ts +3 -0
- package/dist/cjs/hooks/usePayload.js +42 -0
- package/dist/cjs/hooks/usePayload.js.map +1 -0
- package/dist/cjs/hooks/useResolveHuri.d.ts +5 -0
- package/dist/cjs/hooks/useResolveHuri.js +53 -0
- package/dist/cjs/hooks/useResolveHuri.js.map +1 -0
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.js +6 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/docs.json +144528 -0
- package/dist/esm/components/Details/DataDetails.d.ts +10 -0
- package/dist/esm/components/Details/DataDetails.js +32 -0
- package/dist/esm/components/Details/DataDetails.js.map +1 -0
- package/dist/esm/components/Details/Details.d.ts +15 -0
- package/dist/esm/components/Details/Details.js +10 -0
- package/dist/esm/components/Details/Details.js.map +1 -0
- package/dist/esm/components/Details/HashSourceDetails.d.ts +8 -0
- package/dist/esm/components/Details/HashSourceDetails.js +11 -0
- package/dist/esm/components/Details/HashSourceDetails.js.map +1 -0
- package/dist/esm/components/Details/JsonDetails.d.ts +9 -0
- package/dist/esm/components/Details/JsonDetails.js +11 -0
- package/dist/esm/components/Details/JsonDetails.js.map +1 -0
- package/dist/esm/components/Details/MetaDetails.d.ts +8 -0
- package/dist/esm/components/Details/MetaDetails.js +9 -0
- package/dist/esm/components/Details/MetaDetails.js.map +1 -0
- package/dist/esm/components/Details/ValidationDetails/SchemaProperty.d.ts +4 -0
- package/dist/esm/components/Details/ValidationDetails/SchemaProperty.js +11 -0
- package/dist/esm/components/Details/ValidationDetails/SchemaProperty.js.map +1 -0
- package/dist/esm/components/Details/ValidationDetails/ValidationDetails.d.ts +3 -0
- package/dist/esm/components/Details/ValidationDetails/ValidationDetails.js +16 -0
- package/dist/esm/components/Details/ValidationDetails/ValidationDetails.js.map +1 -0
- package/dist/esm/components/Details/ValidationDetails/ValidationDetailsProps.d.ts +8 -0
- package/dist/esm/components/Details/ValidationDetails/ValidationDetailsProps.js +2 -0
- package/dist/esm/components/Details/ValidationDetails/ValidationDetailsProps.js.map +1 -0
- package/dist/esm/components/Details/ValidationDetails/index.d.ts +2 -0
- package/dist/esm/components/Details/ValidationDetails/index.js +3 -0
- package/dist/esm/components/Details/ValidationDetails/index.js.map +1 -0
- package/dist/esm/components/Details/index.d.ts +5 -0
- package/dist/esm/components/Details/index.js +6 -0
- package/dist/esm/components/Details/index.js.map +1 -0
- package/dist/esm/components/Table/PayloadTableColumnConfig.d.ts +10 -0
- package/dist/esm/components/Table/PayloadTableColumnConfig.js +18 -0
- package/dist/esm/components/Table/PayloadTableColumnConfig.js.map +1 -0
- package/dist/esm/components/Table/Table.d.ts +11 -0
- package/dist/esm/components/Table/Table.js +18 -0
- package/dist/esm/components/Table/Table.js.map +1 -0
- package/dist/esm/components/Table/TableRow.d.ts +11 -0
- package/dist/esm/components/Table/TableRow.js +36 -0
- package/dist/esm/components/Table/TableRow.js.map +1 -0
- package/dist/esm/components/Table/index.d.ts +3 -0
- package/dist/esm/components/Table/index.js +4 -0
- package/dist/esm/components/Table/index.js.map +1 -0
- package/dist/esm/components/index.d.ts +2 -0
- package/dist/esm/components/index.js +3 -0
- package/dist/esm/components/index.js.map +1 -0
- package/dist/esm/hooks/index.d.ts +5 -0
- package/dist/esm/hooks/index.js +6 -0
- package/dist/esm/hooks/index.js.map +1 -0
- package/dist/esm/hooks/lib/FetchHuriHashOptions.d.ts +3 -0
- package/dist/esm/hooks/lib/FetchHuriHashOptions.js +2 -0
- package/dist/esm/hooks/lib/FetchHuriHashOptions.js.map +1 -0
- package/dist/esm/hooks/lib/findHuriNetwork.d.ts +3 -0
- package/dist/esm/hooks/lib/findHuriNetwork.js +9 -0
- package/dist/esm/hooks/lib/findHuriNetwork.js.map +1 -0
- package/dist/esm/hooks/lib/index.d.ts +2 -0
- package/dist/esm/hooks/lib/index.js +3 -0
- package/dist/esm/hooks/lib/index.js.map +1 -0
- package/dist/esm/hooks/useGetSchema.d.ts +11 -0
- package/dist/esm/hooks/useGetSchema.js +45 -0
- package/dist/esm/hooks/useGetSchema.js.map +1 -0
- package/dist/esm/hooks/useHuriHash.d.ts +5 -0
- package/dist/esm/hooks/useHuriHash.js +21 -0
- package/dist/esm/hooks/useHuriHash.js.map +1 -0
- package/dist/esm/hooks/usePayload.d.ts +3 -0
- package/dist/esm/hooks/usePayload.js +37 -0
- package/dist/esm/hooks/usePayload.js.map +1 -0
- package/dist/esm/hooks/useResolveHuri.d.ts +5 -0
- package/dist/esm/hooks/useResolveHuri.js +49 -0
- package/dist/esm/hooks/useResolveHuri.js.map +1 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -0
- package/package.json +139 -0
- package/src/components/Details/DataDetails.tsx +60 -0
- package/src/components/Details/Details.stories.tsx +46 -0
- package/src/components/Details/Details.tsx +33 -0
- package/src/components/Details/HashSourceDetails.tsx +40 -0
- package/src/components/Details/JsonDetails.tsx +31 -0
- package/src/components/Details/MetaDetails.tsx +30 -0
- package/src/components/Details/ValidationDetails/SchemaProperty.tsx +22 -0
- package/src/components/Details/ValidationDetails/ValidationDetails.stories.tsx +55 -0
- package/src/components/Details/ValidationDetails/ValidationDetails.tsx +43 -0
- package/src/components/Details/ValidationDetails/ValidationDetailsProps.ts +9 -0
- package/src/components/Details/ValidationDetails/index.ts +2 -0
- package/src/components/Details/index.ts +5 -0
- package/src/components/Table/PayloadTableColumnConfig.ts +28 -0
- package/src/components/Table/Table.stories.tsx +43 -0
- package/src/components/Table/Table.tsx +63 -0
- package/src/components/Table/TableRow.tsx +96 -0
- package/src/components/Table/index.ts +3 -0
- package/src/components/index.ts +2 -0
- package/src/hooks/index.ts +5 -0
- package/src/hooks/lib/FetchHuriHashOptions.ts +3 -0
- package/src/hooks/lib/findHuriNetwork.ts +13 -0
- package/src/hooks/lib/index.ts +2 -0
- package/src/hooks/useGetSchema.stories.tsx +70 -0
- package/src/hooks/useGetSchema.tsx +51 -0
- package/src/hooks/useHuriHash.stories.tsx +68 -0
- package/src/hooks/useHuriHash.tsx +27 -0
- package/src/hooks/usePayload.tsx +39 -0
- package/src/hooks/useResolveHuri.tsx +59 -0
- package/src/index.ts +2 -0
- package/src/types/images.d.ts +5 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Huri } from '@xyo-network/core';
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import { usePayload } from './usePayload';
|
|
4
|
+
import { useResolveHuri } from './useResolveHuri';
|
|
5
|
+
const useHuriHash = (huriOrHash, huriUri, options) => {
|
|
6
|
+
const hash = useCallback((huriOrHash) => {
|
|
7
|
+
if (huriOrHash) {
|
|
8
|
+
if (typeof huriOrHash === 'string') {
|
|
9
|
+
return huriOrHash;
|
|
10
|
+
}
|
|
11
|
+
if (huriOrHash instanceof Huri) {
|
|
12
|
+
return huriOrHash.hash;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}, []);
|
|
16
|
+
const [payload, notFound, apiError] = usePayload(hash(huriOrHash));
|
|
17
|
+
const [huriPayload, huriPayloadNotFound, huriApiError] = useResolveHuri(huriUri, notFound, options);
|
|
18
|
+
return [payload ?? huriPayload, huriPayloadNotFound, apiError ?? huriApiError];
|
|
19
|
+
};
|
|
20
|
+
export { useHuriHash };
|
|
21
|
+
//# sourceMappingURL=useHuriHash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHuriHash.js","sourceRoot":"","sources":["../../../src/hooks/useHuriHash.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAc,MAAM,mBAAmB,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AAGnC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEjD,MAAM,WAAW,GAAG,CAAC,UAA0B,EAAE,OAAgB,EAAE,OAA8B,EAA8D,EAAE;IAC/J,MAAM,IAAI,GAAG,WAAW,CAAC,CAAC,UAA0B,EAAE,EAAE;QACtD,IAAI,UAAU,EAAE;YACd,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE;gBAClC,OAAO,UAAU,CAAA;aAClB;YACD,IAAI,UAAU,YAAY,IAAI,EAAE;gBAC9B,OAAO,UAAU,CAAC,IAAI,CAAA;aACvB;SACF;IACH,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAA;IAClE,MAAM,CAAC,WAAW,EAAE,mBAAmB,EAAE,YAAY,CAAC,GAAG,cAAc,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAA;IAEnG,OAAO,CAAC,OAAO,IAAI,WAAW,EAAE,mBAAmB,EAAE,QAAQ,IAAI,YAAY,CAAC,CAAA;AAChF,CAAC,CAAA;AAED,OAAO,EAAE,WAAW,EAAE,CAAA"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { useAsyncEffect } from '@xylabs/sdk-react';
|
|
2
|
+
import { useArchive } from '@xyo-network/react-archive';
|
|
3
|
+
import { useArchivistApi } from '@xyo-network/react-archivist-api';
|
|
4
|
+
import { useState } from 'react';
|
|
5
|
+
export const usePayload = (hash) => {
|
|
6
|
+
const { api } = useArchivistApi();
|
|
7
|
+
const { archive } = useArchive();
|
|
8
|
+
const [notFound, setNotFound] = useState(false);
|
|
9
|
+
const [apiError, setApiError] = useState();
|
|
10
|
+
const [payload, setPayload] = useState();
|
|
11
|
+
useAsyncEffect(
|
|
12
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
13
|
+
async (mounted) => {
|
|
14
|
+
if (hash && hash.length > 0) {
|
|
15
|
+
try {
|
|
16
|
+
const result = await api?.archive(archive).payload.hash(hash).get();
|
|
17
|
+
if (mounted()) {
|
|
18
|
+
setApiError(undefined);
|
|
19
|
+
if (result?.length) {
|
|
20
|
+
setPayload(result[0]);
|
|
21
|
+
}
|
|
22
|
+
else if (result) {
|
|
23
|
+
setNotFound(true);
|
|
24
|
+
setPayload(undefined);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
catch (e) {
|
|
29
|
+
setApiError(e);
|
|
30
|
+
setPayload(undefined);
|
|
31
|
+
console.error(e);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}, [hash, api, archive]);
|
|
35
|
+
return [payload, notFound, apiError];
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=usePayload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePayload.js","sourceRoot":"","sources":["../../../src/hooks/usePayload.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAGlD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAA;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEhC,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAa,EAA8D,EAAE;IACtG,MAAM,EAAE,GAAG,EAAE,GAAG,eAAe,EAAE,CAAA;IACjC,MAAM,EAAE,OAAO,EAAE,GAAG,UAAU,EAAE,CAAA;IAChC,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;IAC/C,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,EAAe,CAAA;IACvD,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,EAAc,CAAA;IACpD,cAAc;IACZ,uDAAuD;IACvD,KAAK,EAAE,OAAO,EAAE,EAAE;QAChB,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;YAC3B,IAAI;gBACF,MAAM,MAAM,GAAG,MAAM,GAAG,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,CAAA;gBACnE,IAAI,OAAO,EAAE,EAAE;oBACb,WAAW,CAAC,SAAS,CAAC,CAAA;oBACtB,IAAI,MAAM,EAAE,MAAM,EAAE;wBAClB,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;qBACtB;yBAAM,IAAI,MAAM,EAAE;wBACjB,WAAW,CAAC,IAAI,CAAC,CAAA;wBACjB,UAAU,CAAC,SAAS,CAAC,CAAA;qBACtB;iBACF;aACF;YAAC,OAAO,CAAC,EAAE;gBACV,WAAW,CAAC,CAAgB,CAAC,CAAA;gBAC7B,UAAU,CAAC,SAAS,CAAC,CAAA;gBACrB,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;aACjB;SACF;IACH,CAAC,EACD,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,CACrB,CAAA;IACD,OAAO,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAA;AACtC,CAAC,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { XyoApiError } from '@xyo-network/api';
|
|
2
|
+
import { XyoPayload } from '@xyo-network/core';
|
|
3
|
+
import { FetchHuriHashOptions } from './lib';
|
|
4
|
+
declare const useResolveHuri: (huriUri?: string | undefined, dependentNotFound?: boolean | undefined, options?: FetchHuriHashOptions | undefined) => [XyoPayload | undefined, boolean, XyoApiError | undefined];
|
|
5
|
+
export { useResolveHuri };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { useAsyncEffect } from '@xylabs/sdk-react';
|
|
2
|
+
import { Huri } from '@xyo-network/core';
|
|
3
|
+
import { useNetwork } from '@xyo-network/react-network';
|
|
4
|
+
import { useState } from 'react';
|
|
5
|
+
import { findHuriNetwork } from './lib';
|
|
6
|
+
const useResolveHuri = (huriUri, dependentNotFound, options) => {
|
|
7
|
+
const { network, networks, setNetwork } = useNetwork();
|
|
8
|
+
const [huriNetwork, setHuriNetwork] = useState();
|
|
9
|
+
const [huriPayload, setHuriPayload] = useState();
|
|
10
|
+
const [huriPayloadNotFound, setHuriPayloadNotFound] = useState(false);
|
|
11
|
+
const [huriApiError, setHuriApiError] = useState();
|
|
12
|
+
const { changeActiveNetwork } = options ?? {};
|
|
13
|
+
useAsyncEffect(
|
|
14
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
15
|
+
async (mounted) => {
|
|
16
|
+
if ((dependentNotFound === undefined || dependentNotFound) && huriUri && network !== huriNetwork) {
|
|
17
|
+
const huriInstance = new Huri(huriUri);
|
|
18
|
+
const foundHuriNetwork = findHuriNetwork(huriInstance, networks);
|
|
19
|
+
// Update when we found a huri network and it doesn't match the current one
|
|
20
|
+
if (foundHuriNetwork && mounted()) {
|
|
21
|
+
setHuriNetwork(huriNetwork);
|
|
22
|
+
if (network !== foundHuriNetwork && changeActiveNetwork) {
|
|
23
|
+
setNetwork?.(foundHuriNetwork);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
// If no matching network try to resolve the huri itself
|
|
27
|
+
try {
|
|
28
|
+
const huriPayload = await huriInstance.fetch();
|
|
29
|
+
if (mounted()) {
|
|
30
|
+
if (huriPayload) {
|
|
31
|
+
setHuriPayload(huriPayload);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
setHuriPayloadNotFound(true);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
if (mounted()) {
|
|
40
|
+
setHuriApiError(e);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}, [huriNetwork, huriUri, network, networks, dependentNotFound, setNetwork, changeActiveNetwork]);
|
|
46
|
+
return [huriPayload, huriPayloadNotFound, huriApiError];
|
|
47
|
+
};
|
|
48
|
+
export { useResolveHuri };
|
|
49
|
+
//# sourceMappingURL=useResolveHuri.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useResolveHuri.js","sourceRoot":"","sources":["../../../src/hooks/useResolveHuri.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAElD,OAAO,EAAE,IAAI,EAAc,MAAM,mBAAmB,CAAA;AAEpD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEhC,OAAO,EAAwB,eAAe,EAAE,MAAM,OAAO,CAAA;AAE7D,MAAM,cAAc,GAAG,CAAC,OAAgB,EAAE,iBAA2B,EAAE,OAA8B,EAA8D,EAAE;IACnK,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,UAAU,EAAE,CAAA;IACtD,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,EAAqB,CAAA;IACnE,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,EAAc,CAAA;IAC5D,MAAM,CAAC,mBAAmB,EAAE,sBAAsB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;IACrE,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,EAAe,CAAA;IAE/D,MAAM,EAAE,mBAAmB,EAAE,GAAG,OAAO,IAAI,EAAE,CAAA;IAE7C,cAAc;IACZ,uDAAuD;IACvD,KAAK,EAAE,OAAO,EAAE,EAAE;QAChB,IAAI,CAAC,iBAAiB,KAAK,SAAS,IAAI,iBAAiB,CAAC,IAAI,OAAO,IAAI,OAAO,KAAK,WAAW,EAAE;YAChG,MAAM,YAAY,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,CAAA;YAEtC,MAAM,gBAAgB,GAAG,eAAe,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAA;YAEhE,2EAA2E;YAC3E,IAAI,gBAAgB,IAAI,OAAO,EAAE,EAAE;gBACjC,cAAc,CAAC,WAAW,CAAC,CAAA;gBAC3B,IAAI,OAAO,KAAK,gBAAgB,IAAI,mBAAmB,EAAE;oBACvD,UAAU,EAAE,CAAC,gBAAgB,CAAC,CAAA;oBAC9B,OAAM;iBACP;gBAED,wDAAwD;gBACxD,IAAI;oBACF,MAAM,WAAW,GAAG,MAAM,YAAY,CAAC,KAAK,EAAE,CAAA;oBAC9C,IAAI,OAAO,EAAE,EAAE;wBACb,IAAI,WAAW,EAAE;4BACf,cAAc,CAAC,WAAW,CAAC,CAAA;yBAC5B;6BAAM;4BACL,sBAAsB,CAAC,IAAI,CAAC,CAAA;yBAC7B;qBACF;iBACF;gBAAC,OAAO,CAAC,EAAE;oBACV,IAAI,OAAO,EAAE,EAAE;wBACb,eAAe,CAAC,CAAgB,CAAC,CAAA;qBAClC;iBACF;aACF;SACF;IACH,CAAC,EACD,CAAC,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,UAAU,EAAE,mBAAmB,CAAC,CAC9F,CAAA;IAED,OAAO,CAAC,WAAW,EAAE,mBAAmB,EAAE,YAAY,CAAC,CAAA;AACzD,CAAC,CAAA;AAED,OAAO,EAAE,cAAc,EAAE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xyo-network/react-payload",
|
|
3
|
+
"author": {
|
|
4
|
+
"email": "support@xyo.network",
|
|
5
|
+
"name": "XYO Development Team",
|
|
6
|
+
"url": "https://xyo.network"
|
|
7
|
+
},
|
|
8
|
+
"bugs": {
|
|
9
|
+
"email": "support@xyo.network",
|
|
10
|
+
"url": "https://github.com/XYOracleNetwork/sdk-xyo-react-js/issues"
|
|
11
|
+
},
|
|
12
|
+
"workspaces": [
|
|
13
|
+
"packages/*"
|
|
14
|
+
],
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@emotion/react": "^11.9.0",
|
|
17
|
+
"@emotion/styled": "^11.8.1",
|
|
18
|
+
"@mui/icons-material": "^5.8.0",
|
|
19
|
+
"@mui/lab": "^5.0.0-alpha.83",
|
|
20
|
+
"@mui/material": "^5.8.1",
|
|
21
|
+
"@xylabs/pixel": "^1.3.7",
|
|
22
|
+
"@xylabs/sdk-js": "^2.5.5",
|
|
23
|
+
"@xylabs/sdk-react": "^2.12.7",
|
|
24
|
+
"@xyo-network/api": "^2.20.33",
|
|
25
|
+
"@xyo-network/core": "^2.20.33",
|
|
26
|
+
"@xyo-network/network": "^2.20.33",
|
|
27
|
+
"@xyo-network/panel": "^2.20.33",
|
|
28
|
+
"@xyo-network/react-auth-service": "^2.23.7",
|
|
29
|
+
"@xyo-network/react-network": "^2.23.7",
|
|
30
|
+
"@xyo-network/react-property": "^2.23.7",
|
|
31
|
+
"@xyo-network/react-shared": "^2.23.7",
|
|
32
|
+
"@xyo-network/systeminfo-witness": "^2.20.33",
|
|
33
|
+
"@xyo-network/utils": "^2.20.33",
|
|
34
|
+
"lodash": "^4.17.21",
|
|
35
|
+
"luxon": "^2.4.0",
|
|
36
|
+
"react": "^18.1.0",
|
|
37
|
+
"react-dom": "^18.1.0",
|
|
38
|
+
"react-icons": "^4.3.1",
|
|
39
|
+
"react-json-view": "^1.21.3",
|
|
40
|
+
"react-router-dom": "^6.3.0",
|
|
41
|
+
"rollbar": "^2.25.0",
|
|
42
|
+
"typedoc": "^0.22.15"
|
|
43
|
+
},
|
|
44
|
+
"description": "Common React library for all XYO projects that use React",
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@babel/core": "^7.18.0",
|
|
47
|
+
"@babel/preset-env": "^7.18.0",
|
|
48
|
+
"@storybook/addon-actions": "^6.5.4",
|
|
49
|
+
"@storybook/addon-docs": "^6.5.4",
|
|
50
|
+
"@storybook/addon-essentials": "^6.5.4",
|
|
51
|
+
"@storybook/addon-interactions": "^6.5.4",
|
|
52
|
+
"@storybook/addon-links": "^6.5.4",
|
|
53
|
+
"@storybook/addons": "^6.5.4",
|
|
54
|
+
"@storybook/api": "^6.5.4",
|
|
55
|
+
"@storybook/builder-webpack5": "^6.5.4",
|
|
56
|
+
"@storybook/components": "^6.5.4",
|
|
57
|
+
"@storybook/core-events": "^6.5.4",
|
|
58
|
+
"@storybook/manager-webpack5": "^6.5.4",
|
|
59
|
+
"@storybook/react": "^6.5.4",
|
|
60
|
+
"@storybook/testing-library": "^0.0.11",
|
|
61
|
+
"@storybook/theming": "^6.5.4",
|
|
62
|
+
"@types/lodash": "^4.14.182",
|
|
63
|
+
"@types/luxon": "^2.3.2",
|
|
64
|
+
"@xylabs/eslint-config-react": "^2.1.5",
|
|
65
|
+
"@xylabs/pixel": "^1.3.7",
|
|
66
|
+
"@xylabs/rollup-config": "^1.1.17",
|
|
67
|
+
"@xylabs/sdk-js": "^2.5.5",
|
|
68
|
+
"@xylabs/sdk-react": "^2.12.7",
|
|
69
|
+
"@xylabs/ts-scripts": "^1.0.66",
|
|
70
|
+
"@xylabs/tsconfig": "^1.0.13",
|
|
71
|
+
"assert": "^2.0.0",
|
|
72
|
+
"axios": "^0.27.2",
|
|
73
|
+
"storybook-dark-mode": "^1.1.0",
|
|
74
|
+
"typescript": "^4.6.4"
|
|
75
|
+
},
|
|
76
|
+
"browser": "dist/esm/index.js",
|
|
77
|
+
"docs": "dist/docs.json",
|
|
78
|
+
"exports": {
|
|
79
|
+
".": {
|
|
80
|
+
"node": {
|
|
81
|
+
"import": "./dist/esm/index.js",
|
|
82
|
+
"require": "./dist/cjs/index.js"
|
|
83
|
+
},
|
|
84
|
+
"browser": {
|
|
85
|
+
"import": "./dist/esm/index.js",
|
|
86
|
+
"require": "./dist/cjs/index.js"
|
|
87
|
+
},
|
|
88
|
+
"default": "./dist/esm/index.js"
|
|
89
|
+
},
|
|
90
|
+
"./dist/docs.json": {
|
|
91
|
+
"default": "./dist/docs.json"
|
|
92
|
+
},
|
|
93
|
+
"./package.json": "./package.json"
|
|
94
|
+
},
|
|
95
|
+
"main": "dist/cjs/index.js",
|
|
96
|
+
"module": "dist/esm/index.js",
|
|
97
|
+
"homepage": "https://xyo.network",
|
|
98
|
+
"keywords": [
|
|
99
|
+
"xyo",
|
|
100
|
+
"utility",
|
|
101
|
+
"typescript",
|
|
102
|
+
"react"
|
|
103
|
+
],
|
|
104
|
+
"license": "LGPL-3.0",
|
|
105
|
+
"peerDependencies": {
|
|
106
|
+
"axios": ">0.26",
|
|
107
|
+
"typedoc": "^0.22.13"
|
|
108
|
+
},
|
|
109
|
+
"peerDependenciesMeta": {
|
|
110
|
+
"typedoc": {
|
|
111
|
+
"optional": true
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
"resolutions": {
|
|
115
|
+
"@storybook/react/webpack": "^5",
|
|
116
|
+
"bn.js": "^5.2.0",
|
|
117
|
+
"react": "^18.1.0",
|
|
118
|
+
"react-dom": "^18.1.0",
|
|
119
|
+
"webpack": "^5"
|
|
120
|
+
},
|
|
121
|
+
"publishConfig": {
|
|
122
|
+
"access": "public"
|
|
123
|
+
},
|
|
124
|
+
"repository": {
|
|
125
|
+
"type": "git",
|
|
126
|
+
"url": "https://github.com/XYOracleNetwork/sdk-xyo-react-js.git"
|
|
127
|
+
},
|
|
128
|
+
"scripts": {
|
|
129
|
+
"deploy": "yarn deploy3",
|
|
130
|
+
"lint-pkg": "npmPkgJsonLint .",
|
|
131
|
+
"build": "yarn clean && tsc -p tsconfig.build.cjs.json && tsc -p tsconfig.build.esm.json && yarn gen:docs",
|
|
132
|
+
"gen:docs": "typedoc ./src/index.ts --json ./dist/docs.json --tsconfig ./tsconfig.json",
|
|
133
|
+
"license": "yarn license-checker --exclude \"MIT, ISC, Apache-2.0, BSD, BSD-2-Clause, CC-BY-4.0, Unlicense, CC-BY-3.0, CC0-1.0\""
|
|
134
|
+
},
|
|
135
|
+
"sideEffects": false,
|
|
136
|
+
"types": "dist/esm/index.d.ts",
|
|
137
|
+
"version": "2.23.7",
|
|
138
|
+
"packageManager": "yarn@3.1.1"
|
|
139
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import ContentCopyIcon from '@mui/icons-material/ContentCopy'
|
|
2
|
+
import VisibilityIcon from '@mui/icons-material/Visibility'
|
|
3
|
+
import { Dialog, DialogActions, DialogContent, DialogTitle } from '@mui/material'
|
|
4
|
+
import { ButtonEx, FlexBoxProps, FlexCol } from '@xylabs/sdk-react'
|
|
5
|
+
import { XyoPayload, XyoPayloadWrapper } from '@xyo-network/core'
|
|
6
|
+
import { Property, PropertyAction, SizeProp, usePropertyHeroProps } from '@xyo-network/react-property'
|
|
7
|
+
import { useState } from 'react'
|
|
8
|
+
|
|
9
|
+
import { PayloadHashSourceDetails } from './HashSourceDetails'
|
|
10
|
+
|
|
11
|
+
export interface PayloadDataDetailsProps extends FlexBoxProps {
|
|
12
|
+
value?: XyoPayload
|
|
13
|
+
size?: SizeProp
|
|
14
|
+
badge?: boolean
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const PayloadDataDetails: React.FC<PayloadDataDetailsProps> = ({ size, badge, value, ...props }) => {
|
|
18
|
+
const wrapper = value ? new XyoPayloadWrapper(value) : undefined
|
|
19
|
+
|
|
20
|
+
const propertyHeroProps = usePropertyHeroProps(props)
|
|
21
|
+
const [viewSourceOpen, setViewSourceOpen] = useState(false)
|
|
22
|
+
const hash = wrapper?.hash
|
|
23
|
+
|
|
24
|
+
const actions: PropertyAction[] = [
|
|
25
|
+
{
|
|
26
|
+
icon: <VisibilityIcon />,
|
|
27
|
+
name: 'View',
|
|
28
|
+
onClick: () => setViewSourceOpen(true),
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
icon: <ContentCopyIcon />,
|
|
32
|
+
name: 'Copy',
|
|
33
|
+
onClick: async () => await navigator.clipboard.writeText(wrapper?.hash ?? ''),
|
|
34
|
+
},
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
const onCopy = async () => {
|
|
38
|
+
await navigator.clipboard.writeText(wrapper?.stringified ?? '')
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<FlexCol alignItems="stretch" {...props}>
|
|
43
|
+
<Property badge={badge} size={size} actions={actions} title="Payload Hash" value={hash ?? '<Unknown>'} tip="This is the payload hash" {...propertyHeroProps} />
|
|
44
|
+
<Dialog open={viewSourceOpen} onClose={() => setViewSourceOpen(false)}>
|
|
45
|
+
<DialogTitle>Hash Source</DialogTitle>
|
|
46
|
+
<DialogContent>
|
|
47
|
+
<PayloadHashSourceDetails noTitle payload={value} />
|
|
48
|
+
</DialogContent>
|
|
49
|
+
<DialogActions>
|
|
50
|
+
<ButtonEx color="secondary" onClick={onCopy}>
|
|
51
|
+
Copy
|
|
52
|
+
</ButtonEx>
|
|
53
|
+
<ButtonEx color="secondary" onClick={() => setViewSourceOpen(false)}>
|
|
54
|
+
Close
|
|
55
|
+
</ButtonEx>
|
|
56
|
+
</DialogActions>
|
|
57
|
+
</Dialog>
|
|
58
|
+
</FlexCol>
|
|
59
|
+
)
|
|
60
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ComponentMeta, ComponentStory } from '@storybook/react'
|
|
2
|
+
import { BrowserRouter, Route, Routes } from 'react-router-dom'
|
|
3
|
+
|
|
4
|
+
import { appThemeDecorator, samplePayload, samplePayloadFromBuilder } from '../../.storybook'
|
|
5
|
+
import { PayloadDetails } from './Details'
|
|
6
|
+
|
|
7
|
+
const StorybookEntry = {
|
|
8
|
+
argTypes: {},
|
|
9
|
+
component: PayloadDetails,
|
|
10
|
+
parameters: {
|
|
11
|
+
docs: {
|
|
12
|
+
page: null,
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
title: 'Payload/Details',
|
|
16
|
+
} as ComponentMeta<typeof PayloadDetails>
|
|
17
|
+
|
|
18
|
+
const Template: ComponentStory<typeof PayloadDetails> = (args) => (
|
|
19
|
+
<BrowserRouter>
|
|
20
|
+
<Routes>
|
|
21
|
+
<Route path="temp" element={<h1>Successfully navigated to archivePath</h1>} />
|
|
22
|
+
<Route path="*" element={<PayloadDetails {...args}></PayloadDetails>}></Route>
|
|
23
|
+
</Routes>
|
|
24
|
+
</BrowserRouter>
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
const Default = Template.bind({})
|
|
28
|
+
Default.args = {}
|
|
29
|
+
Default.decorators = [appThemeDecorator]
|
|
30
|
+
|
|
31
|
+
const WithSample = Template.bind({})
|
|
32
|
+
WithSample.args = { payload: samplePayload }
|
|
33
|
+
WithSample.decorators = [appThemeDecorator]
|
|
34
|
+
|
|
35
|
+
const WithBuilderSample = Template.bind({})
|
|
36
|
+
WithBuilderSample.args = { payload: samplePayloadFromBuilder }
|
|
37
|
+
WithBuilderSample.decorators = [appThemeDecorator]
|
|
38
|
+
|
|
39
|
+
const WithArchiveLink = Template.bind({})
|
|
40
|
+
WithArchiveLink.args = { payload: samplePayloadFromBuilder, payloadMetaDetailsProps: { archivePath: 'temp' } }
|
|
41
|
+
WithArchiveLink.decorators = [appThemeDecorator]
|
|
42
|
+
|
|
43
|
+
export { Default, WithArchiveLink, WithBuilderSample, WithSample }
|
|
44
|
+
|
|
45
|
+
// eslint-disable-next-line import/no-default-export
|
|
46
|
+
export default StorybookEntry
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { FlexBoxProps, FlexCol } from '@xylabs/sdk-react'
|
|
2
|
+
import { XyoPayload } from '@xyo-network/core'
|
|
3
|
+
|
|
4
|
+
import { PayloadDataDetails, PayloadDataDetailsProps } from './DataDetails'
|
|
5
|
+
import { PayloadJsonDetails, PayloadJsonDetailsProps } from './JsonDetails'
|
|
6
|
+
import { PayloadMetaDetails, PayloadMetaDetailsProps } from './MetaDetails'
|
|
7
|
+
import { PayloadValidationDetails, PayloadValidationDetailsProps } from './ValidationDetails'
|
|
8
|
+
|
|
9
|
+
export interface PayloadDetailsProps extends FlexBoxProps {
|
|
10
|
+
payload?: XyoPayload
|
|
11
|
+
payloadDataDetailsProps?: PayloadDataDetailsProps
|
|
12
|
+
payloadMetaDetailsProps?: PayloadMetaDetailsProps
|
|
13
|
+
payloadValidationDetailsProps?: PayloadValidationDetailsProps
|
|
14
|
+
payloadJsonDetailsProps?: PayloadJsonDetailsProps
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const PayloadDetails: React.FC<PayloadDetailsProps> = ({
|
|
18
|
+
payload,
|
|
19
|
+
payloadDataDetailsProps,
|
|
20
|
+
payloadMetaDetailsProps,
|
|
21
|
+
payloadValidationDetailsProps,
|
|
22
|
+
payloadJsonDetailsProps,
|
|
23
|
+
...props
|
|
24
|
+
}) => {
|
|
25
|
+
return (
|
|
26
|
+
<FlexCol justifyContent="flex-start" alignItems="stretch" marginTop={2} marginBottom={8} {...props}>
|
|
27
|
+
<PayloadDataDetails size="large" badge value={payload} {...payloadDataDetailsProps} />
|
|
28
|
+
<PayloadMetaDetails value={payload} {...payloadMetaDetailsProps} />
|
|
29
|
+
<PayloadValidationDetails value={payload} {...payloadValidationDetailsProps} />
|
|
30
|
+
<PayloadJsonDetails payload={payload} {...payloadJsonDetailsProps} />
|
|
31
|
+
</FlexCol>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import ContentCopyIcon from '@mui/icons-material/ContentCopy'
|
|
2
|
+
import { IconButton, Typography, useTheme } from '@mui/material'
|
|
3
|
+
import { FlexBoxProps, FlexCol, FlexGrowRow, FlexRow, QuickTipButton } from '@xylabs/sdk-react'
|
|
4
|
+
import { XyoPayload, XyoPayloadWrapper } from '@xyo-network/core'
|
|
5
|
+
|
|
6
|
+
export interface PayloadHashSourceDetailsProps extends FlexBoxProps {
|
|
7
|
+
noTitle?: boolean
|
|
8
|
+
payload?: XyoPayload
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const PayloadHashSourceDetails: React.FC<PayloadHashSourceDetailsProps> = ({ noTitle = false, payload, ...props }) => {
|
|
12
|
+
const theme = useTheme()
|
|
13
|
+
const payloadWrapper = payload ? new XyoPayloadWrapper(payload) : null
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<FlexCol alignItems="stretch" {...props}>
|
|
17
|
+
{noTitle ? null : (
|
|
18
|
+
<FlexRow margin={1} justifyContent="flex-start">
|
|
19
|
+
<Typography>Hash Source</Typography>
|
|
20
|
+
<QuickTipButton title="Hash Source">The actual string used to generate the hash (SHA256)</QuickTipButton>
|
|
21
|
+
</FlexRow>
|
|
22
|
+
)}
|
|
23
|
+
<FlexRow>
|
|
24
|
+
<FlexGrowRow paper border={1} borderColor={theme.palette.divider} justifyContent="start">
|
|
25
|
+
<Typography padding={2} fontFamily="monospace" variant="body1" sx={{ overflowWrap: 'break-word', wordBreak: 'break-all' }}>
|
|
26
|
+
{payloadWrapper?.stringified ?? ''}
|
|
27
|
+
</Typography>
|
|
28
|
+
</FlexGrowRow>
|
|
29
|
+
<IconButton>
|
|
30
|
+
<ContentCopyIcon />
|
|
31
|
+
</IconButton>
|
|
32
|
+
</FlexRow>
|
|
33
|
+
{noTitle ? (
|
|
34
|
+
<FlexRow margin={1} justifyContent="flex-start">
|
|
35
|
+
<Typography variant="body2">The actual string used to generate the hash (SHA256). This can be used to validate the hash manually.</Typography>
|
|
36
|
+
</FlexRow>
|
|
37
|
+
) : null}
|
|
38
|
+
</FlexCol>
|
|
39
|
+
)
|
|
40
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Paper, Typography, useMediaQuery, useTheme } from '@mui/material'
|
|
2
|
+
import { FlexBoxProps, FlexCol, FlexGrowRow, FlexRow, QuickTipButton } from '@xylabs/sdk-react'
|
|
3
|
+
import { XyoPayload } from '@xyo-network/core'
|
|
4
|
+
import { lazy, Suspense } from 'react'
|
|
5
|
+
import { ReactJsonViewProps } from 'react-json-view'
|
|
6
|
+
|
|
7
|
+
const JsonView = lazy(() => import(/* webpackChunkName: "jsonView" */ 'react-json-view'))
|
|
8
|
+
|
|
9
|
+
export interface PayloadJsonDetailsProps extends FlexBoxProps {
|
|
10
|
+
payload?: XyoPayload
|
|
11
|
+
jsonViewProps?: ReactJsonViewProps
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const PayloadJsonDetails: React.FC<PayloadJsonDetailsProps> = ({ jsonViewProps, payload = {}, ...props }) => {
|
|
15
|
+
const { breakpoints } = useTheme()
|
|
16
|
+
const belowSm = useMediaQuery(breakpoints.down('sm'))
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<FlexCol alignItems="stretch" {...props}>
|
|
20
|
+
<FlexRow margin={1} justifyContent="flex-start">
|
|
21
|
+
<Typography>JSON</Typography>
|
|
22
|
+
<QuickTipButton title="Payload JSON">The raw JSON of the payload</QuickTipButton>
|
|
23
|
+
</FlexRow>
|
|
24
|
+
<Paper variant="outlined">
|
|
25
|
+
<Suspense fallback={<FlexGrowRow />}>
|
|
26
|
+
<JsonView src={payload} enableClipboard collapseStringsAfterLength={belowSm ? 24 : 32} {...jsonViewProps} />
|
|
27
|
+
</Suspense>
|
|
28
|
+
</Paper>
|
|
29
|
+
</FlexCol>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Typography } from '@mui/material'
|
|
2
|
+
import { FlexBoxProps, FlexCol, FlexRow, QuickTipButton } from '@xylabs/sdk-react'
|
|
3
|
+
import { XyoPayload } from '@xyo-network/core'
|
|
4
|
+
import { Property } from '@xyo-network/react-property'
|
|
5
|
+
import { ArchiveProperty } from '@xyo-network/react-shared'
|
|
6
|
+
|
|
7
|
+
export interface PayloadMetaDetailsProps extends FlexBoxProps {
|
|
8
|
+
value?: XyoPayload
|
|
9
|
+
archivePath?: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const PayloadMetaDetails: React.FC<PayloadMetaDetailsProps> = ({ archivePath, value, ...props }) => {
|
|
13
|
+
return (
|
|
14
|
+
<FlexCol alignItems="start" {...props}>
|
|
15
|
+
<FlexRow margin={1} justifyContent="start">
|
|
16
|
+
<Typography>Meta</Typography>
|
|
17
|
+
<QuickTipButton title="Payload Meta">The meta fields added to the record by the archivist</QuickTipButton>
|
|
18
|
+
</FlexRow>
|
|
19
|
+
<FlexRow flexWrap="wrap">
|
|
20
|
+
{value?._client ? <Property flexGrow={1} title="Client" value={value?._client ?? '<Unknown>'} tip="This client used to create this payload" /> : null}
|
|
21
|
+
{value?._archive ? <ArchiveProperty payload={value} path={archivePath} /> : null}
|
|
22
|
+
{value?._reportedHash ? <Property flexGrow={1} title="Reported Hash" value={value?._reportedHash ?? '<Unknown>'} tip="The has reported by the payload" /> : null}
|
|
23
|
+
{value?._timestamp ? <Property flexGrow={1} title="Timestamp" value={value?._timestamp ?? '<Unknown>'} tip="This timestamp of the payload" /> : null}
|
|
24
|
+
{value?._observeDuration ? (
|
|
25
|
+
<Property flexGrow={1} title="Observation Duration" value={value?._observeDuration ?? '<Unknown>'} tip="This duration of time observed by the witness" />
|
|
26
|
+
) : null}
|
|
27
|
+
</FlexRow>
|
|
28
|
+
</FlexCol>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import FilterNoneIcon from '@mui/icons-material/FilterNone'
|
|
2
|
+
import { useTheme } from '@mui/material'
|
|
3
|
+
import { LinkEx } from '@xylabs/sdk-react'
|
|
4
|
+
import { Property, PropertyValue } from '@xyo-network/react-property'
|
|
5
|
+
|
|
6
|
+
import { PayloadValidationDetailsProps } from './ValidationDetailsProps'
|
|
7
|
+
|
|
8
|
+
const SchemaProperty: React.FC<PayloadValidationDetailsProps> = ({ value, viewSchemaUrl }) => {
|
|
9
|
+
const theme = useTheme()
|
|
10
|
+
return (
|
|
11
|
+
<Property flexGrow={1} title="Schema" value={value?.schema} tip="Schema sent with the payload">
|
|
12
|
+
{viewSchemaUrl ? (
|
|
13
|
+
<LinkEx href={viewSchemaUrl} target="_blank" rel="noopener noreferrer" display="flex" color={theme.palette.secondary.main}>
|
|
14
|
+
<PropertyValue value={value?.schema} title="view schema in new window" />
|
|
15
|
+
<FilterNoneIcon sx={{ left: '-6px', position: 'relative', top: '9px', width: '12px' }} />
|
|
16
|
+
</LinkEx>
|
|
17
|
+
) : null}
|
|
18
|
+
</Property>
|
|
19
|
+
)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { SchemaProperty }
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ComponentStory, Meta } from '@storybook/react'
|
|
2
|
+
import { BrowserRouter } from 'react-router-dom'
|
|
3
|
+
|
|
4
|
+
import { appThemeDecorator, samplePayload } from '../../../.storybook'
|
|
5
|
+
import { PayloadDetails } from '../Details'
|
|
6
|
+
import { PayloadValidationDetails } from './ValidationDetails'
|
|
7
|
+
|
|
8
|
+
const StorybookEntry: Meta = {
|
|
9
|
+
argTypes: {},
|
|
10
|
+
args: {
|
|
11
|
+
value: {
|
|
12
|
+
schema: 'network.xyo.schema',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
component: PayloadDetails,
|
|
16
|
+
decorators: [appThemeDecorator],
|
|
17
|
+
parameters: {
|
|
18
|
+
docs: {
|
|
19
|
+
page: null,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
title: 'Payload/ValidationDetails',
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const Template: ComponentStory<typeof PayloadValidationDetails> = (args) => (
|
|
26
|
+
<BrowserRouter>
|
|
27
|
+
<PayloadValidationDetails {...args} />
|
|
28
|
+
</BrowserRouter>
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
const Default = Template.bind({})
|
|
32
|
+
Default.args = { skipBody: true, skipMeta: true }
|
|
33
|
+
|
|
34
|
+
const WithViewSchemaLink = Template.bind({})
|
|
35
|
+
WithViewSchemaLink.args = { viewSchemaUrl: 'http://beta.explore.xyo.network/6fe3f745b1179fefa74cc3c7eab58321bee1c9ca9e34d9585467364cc5d3bbe2/?huri=huri' }
|
|
36
|
+
|
|
37
|
+
const WithErrorsInToolTip = Template.bind({})
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
39
|
+
// @ts-ignore
|
|
40
|
+
WithErrorsInToolTip.args = { value: { ...samplePayload, ...{ _hash: '6fe3f745b1179fefa74cc3c7eab58321bee1c9ca9e34d9585467364cc5d3bbe2' } } }
|
|
41
|
+
|
|
42
|
+
const SkipBody = Template.bind({})
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
44
|
+
// @ts-ignore
|
|
45
|
+
SkipBody.args = { skipBody: true, value: { _hash: '44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a', _timestamp: new Date().getTime() } }
|
|
46
|
+
|
|
47
|
+
const SkipMeta = Template.bind({})
|
|
48
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
49
|
+
// @ts-ignore
|
|
50
|
+
SkipMeta.args = { skipMeta: true, value: { _hash: null, schema: 'network.xyo.schema' } }
|
|
51
|
+
|
|
52
|
+
export { Default, SkipBody, SkipMeta, WithErrorsInToolTip, WithViewSchemaLink }
|
|
53
|
+
|
|
54
|
+
// eslint-disable-next-line import/no-default-export
|
|
55
|
+
export default StorybookEntry
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Typography } from '@mui/material'
|
|
2
|
+
import { FlexCol, FlexRow, QuickTipButton } from '@xylabs/sdk-react'
|
|
3
|
+
import { XyoPayloadValidator } from '@xyo-network/core'
|
|
4
|
+
import { Property } from '@xyo-network/react-property'
|
|
5
|
+
|
|
6
|
+
import { SchemaProperty } from './SchemaProperty'
|
|
7
|
+
import { PayloadValidationDetailsProps } from './ValidationDetailsProps'
|
|
8
|
+
|
|
9
|
+
export const PayloadValidationDetails: React.FC<PayloadValidationDetailsProps> = ({ viewSchemaUrl, skipMeta = false, skipBody = false, value, ...props }) => {
|
|
10
|
+
const validator = value ? new XyoPayloadValidator(value) : undefined
|
|
11
|
+
|
|
12
|
+
const bodyErrors = skipBody ? [] : validator?.body.all() ?? []
|
|
13
|
+
const metaErrors = skipMeta ? [] : validator?.meta.all() ?? []
|
|
14
|
+
const errors: Error[] = [...bodyErrors, ...metaErrors]
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<FlexCol alignItems="start" {...props}>
|
|
18
|
+
<FlexRow margin={1} justifyContent="flex-start">
|
|
19
|
+
<Typography>Validation</Typography>
|
|
20
|
+
<QuickTipButton title="Block Validation">The results from validating the payload</QuickTipButton>
|
|
21
|
+
</FlexRow>
|
|
22
|
+
<FlexRow flexWrap="wrap">
|
|
23
|
+
<Property
|
|
24
|
+
flexGrow={1}
|
|
25
|
+
title="Valid"
|
|
26
|
+
value={errors.length === 0 ? 'True' : 'False'}
|
|
27
|
+
tip={
|
|
28
|
+
errors.length > 0 ? (
|
|
29
|
+
<FlexCol>
|
|
30
|
+
{errors.map((error, index) => {
|
|
31
|
+
return <Typography key={index}>{error.toString()}</Typography>
|
|
32
|
+
})}
|
|
33
|
+
</FlexCol>
|
|
34
|
+
) : (
|
|
35
|
+
<Typography>No Errors</Typography>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
/>
|
|
39
|
+
{value?.schema && <SchemaProperty value={value} viewSchemaUrl={viewSchemaUrl} />}
|
|
40
|
+
</FlexRow>
|
|
41
|
+
</FlexCol>
|
|
42
|
+
)
|
|
43
|
+
}
|