@xyo-network/react-schema 3.0.2 → 3.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/components/Property/SchemaProperty.d.ts +40 -0
- package/dist/browser/components/Property/SchemaProperty.d.ts.map +1 -0
- package/dist/browser/components/Property/index.d.ts +2 -0
- package/dist/browser/components/Property/index.d.ts.map +1 -0
- package/dist/browser/components/SelectEx/SchemaSelectEx.d.ts +5 -0
- package/dist/browser/components/SelectEx/SchemaSelectEx.d.ts.map +1 -0
- package/dist/browser/components/SelectEx/index.d.ts +2 -0
- package/dist/browser/components/SelectEx/index.d.ts.map +1 -0
- package/dist/browser/components/index.d.ts +3 -0
- package/dist/browser/components/index.d.ts.map +1 -0
- package/dist/browser/contexts/Schema/Context.d.ts +3 -0
- package/dist/browser/contexts/Schema/Context.d.ts.map +1 -0
- package/dist/browser/contexts/Schema/Provider/Memory.d.ts +5 -0
- package/dist/browser/contexts/Schema/Provider/Memory.d.ts.map +1 -0
- package/dist/browser/contexts/Schema/Provider/Props.d.ts +5 -0
- package/dist/browser/contexts/Schema/Provider/Props.d.ts.map +1 -0
- package/dist/browser/contexts/Schema/Provider/Route.d.ts +5 -0
- package/dist/browser/contexts/Schema/Provider/Route.d.ts.map +1 -0
- package/dist/browser/contexts/Schema/Provider/index.d.ts +4 -0
- package/dist/browser/contexts/Schema/Provider/index.d.ts.map +1 -0
- package/dist/browser/contexts/Schema/State.d.ts +9 -0
- package/dist/browser/contexts/Schema/State.d.ts.map +1 -0
- package/dist/browser/contexts/Schema/index.d.ts +5 -0
- package/dist/browser/contexts/Schema/index.d.ts.map +1 -0
- package/dist/browser/contexts/Schema/use.d.ts +3 -0
- package/dist/browser/contexts/Schema/use.d.ts.map +1 -0
- package/dist/browser/contexts/index.d.ts +2 -0
- package/dist/browser/contexts/index.d.ts.map +1 -0
- package/dist/browser/hooks/index.d.ts +5 -0
- package/dist/browser/hooks/index.d.ts.map +1 -0
- package/dist/browser/hooks/useGetSchema.d.ts +26 -0
- package/dist/browser/hooks/useGetSchema.d.ts.map +1 -0
- package/dist/browser/hooks/useSchemaDefinitions.d.ts +6 -0
- package/dist/browser/hooks/useSchemaDefinitions.d.ts.map +1 -0
- package/dist/browser/hooks/useSchemaList.d.ts +4 -0
- package/dist/browser/hooks/useSchemaList.d.ts.map +1 -0
- package/dist/browser/hooks/useSchemaStats.d.ts +5 -0
- package/dist/browser/hooks/useSchemaStats.d.ts.map +1 -0
- package/dist/browser/index.d.ts +4 -117
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.mjs.map +1 -1
- package/package.json +68 -60
- package/src/components/Property/SchemaProperty.stories.tsx +4 -6
- package/src/components/Property/SchemaProperty.tsx +6 -2
- package/src/components/SelectEx/SchemaSelectEx.tsx +6 -2
- package/src/contexts/Schema/Provider/Memory.tsx +9 -3
- package/src/contexts/Schema/Provider/Route.tsx +12 -4
- package/src/hooks/stories/TestSchemaHooks.stories.tsx +15 -4
- package/src/hooks/useGetSchema.stories.tsx +4 -6
- package/src/hooks/useGetSchema.tsx +3 -1
- package/src/hooks/useSchemaList.tsx +3 -1
- package/src/hooks/useSchemaStats.tsx +2 -1
- package/xy.config.ts +1 -3
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { PropertyProps } from '@xyo-network/react-property';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export type SchemaPropertyProps = PropertyProps & {
|
|
4
|
+
showLinkNames?: boolean;
|
|
5
|
+
showOpenNewWindowLink?: boolean;
|
|
6
|
+
showStatusIcon?: boolean;
|
|
7
|
+
value?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const SchemaProperty: React.ForwardRefExoticComponent<((import("@xyo-network/react-property").PropertyBaseProps & {
|
|
10
|
+
actions?: import("@xyo-network/react-property").PropertyAction[];
|
|
11
|
+
badge?: boolean;
|
|
12
|
+
required?: boolean;
|
|
13
|
+
size?: import("@xyo-network/react-shared").SizeProp;
|
|
14
|
+
value?: string | number | boolean | null;
|
|
15
|
+
} & import("@xylabs/react-flexbox").BusyBoxProps & {
|
|
16
|
+
paper?: false;
|
|
17
|
+
} & {
|
|
18
|
+
showLinkNames?: boolean;
|
|
19
|
+
showOpenNewWindowLink?: boolean;
|
|
20
|
+
showStatusIcon?: boolean;
|
|
21
|
+
value?: string;
|
|
22
|
+
}) | Omit<import("@xyo-network/react-property").PropertyBaseProps & {
|
|
23
|
+
actions?: import("@xyo-network/react-property").PropertyAction[];
|
|
24
|
+
badge?: boolean;
|
|
25
|
+
required?: boolean;
|
|
26
|
+
size?: import("@xyo-network/react-shared").SizeProp;
|
|
27
|
+
value?: string | number | boolean | null;
|
|
28
|
+
} & import("@mui/material").PaperOwnProps & import("@mui/material/OverridableComponent.js").CommonProps & Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
29
|
+
ref?: ((instance: HTMLDivElement | null) => void | React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | React.RefObject<HTMLDivElement> | null | undefined;
|
|
30
|
+
}, "className" | "style" | "classes" | "children" | "elevation" | "square" | "sx" | "variant"> & {
|
|
31
|
+
component?: React.ElementType;
|
|
32
|
+
} & {
|
|
33
|
+
paper: true;
|
|
34
|
+
} & {
|
|
35
|
+
showLinkNames?: boolean;
|
|
36
|
+
showOpenNewWindowLink?: boolean;
|
|
37
|
+
showStatusIcon?: boolean;
|
|
38
|
+
value?: string;
|
|
39
|
+
}, "ref">) & React.RefAttributes<HTMLDivElement>>;
|
|
40
|
+
//# sourceMappingURL=SchemaProperty.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SchemaProperty.d.ts","sourceRoot":"","sources":["../../../../src/components/Property/SchemaProperty.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAIhE,OAAO,KAA+B,MAAM,OAAO,CAAA;AAEnD,MAAM,MAAM,mBAAmB,GAAG,aAAa,GAAG;IAChD,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAC/B,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAkBD,eAAO,MAAM,cAAc;;;;;;;;;oBAtBT,OAAO;4BACC,OAAO;qBACd,OAAO;YAChB,MAAM;;;;;;;;;;;;;;oBAHE,OAAO;4BACC,OAAO;qBACd,OAAO;YAChB,MAAM;iDAmFf,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/Property/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SchemaSelectEx.d.ts","sourceRoot":"","sources":["../../../../src/components/SelectEx/SchemaSelectEx.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAEzD,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,MAAM,MAAM,mBAAmB,GAAG,aAAa,CAAC,MAAM,CAAC,CAAA;AAEvD,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAmCxD,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/SelectEx/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../../../src/contexts/Schema/Context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAEpD,eAAO,MAAM,aAAa,kGAAwC,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { WithChildren } from '@xylabs/react-shared';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import type { SchemaProviderProps } from './Props.ts';
|
|
4
|
+
export declare const SchemaMemoryProvider: React.FC<WithChildren<SchemaProviderProps>>;
|
|
5
|
+
//# sourceMappingURL=Memory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Memory.d.ts","sourceRoot":"","sources":["../../../../../src/contexts/Schema/Provider/Memory.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,KAEN,MAAM,OAAO,CAAA;AAId,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAErD,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAmB5E,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Props.d.ts","sourceRoot":"","sources":["../../../../../src/contexts/Schema/Provider/Props.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,mBAAmB;IAClC,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAA;CAC3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Route.d.ts","sourceRoot":"","sources":["../../../../../src/contexts/Schema/Provider/Route.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,KAEN,MAAM,OAAO,CAAA;AAMd,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAsDrD,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAQ3E,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/contexts/Schema/Provider/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ContextExState } from '@xyo-network/react-shared';
|
|
2
|
+
import type { Dispatch } from 'react';
|
|
3
|
+
export interface SchemaContextState extends ContextExState {
|
|
4
|
+
schema?: string;
|
|
5
|
+
schemaList?: string[];
|
|
6
|
+
setSchema?: Dispatch<string>;
|
|
7
|
+
setSchemaList?: Dispatch<string[]>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=State.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"State.d.ts","sourceRoot":"","sources":["../../../../src/contexts/Schema/State.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAC/D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAErC,MAAM,WAAW,kBAAmB,SAAQ,cAAc;IAExD,MAAM,CAAC,EAAE,MAAM,CAAA;IAEf,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;IAErB,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;IAE5B,aAAa,CAAC,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAA;CACnC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/contexts/Schema/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,qBAAqB,CAAA;AACnC,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use.d.ts","sourceRoot":"","sources":["../../../../src/contexts/Schema/use.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAEpD,eAAO,MAAM,SAAS,8DAErB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/contexts/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,qBAAqB,CAAA;AACnC,cAAc,sBAAsB,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ModuleErrorSchema } from '@xyo-network/payload-model';
|
|
2
|
+
declare const useGetSchemaPayload: (schema?: string) => {
|
|
3
|
+
notFound: boolean;
|
|
4
|
+
schemaHuri: import("@xyo-network/huri").Huri<{
|
|
5
|
+
schema: string;
|
|
6
|
+
} & import("@xyo-network/payload-model").PayloadFields> | undefined;
|
|
7
|
+
schemaPayload: Promise<import("@xyo-network/payload-model").WithMeta<import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & {
|
|
8
|
+
definition: {
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
$id?: string;
|
|
11
|
+
};
|
|
12
|
+
extends?: string;
|
|
13
|
+
name?: string;
|
|
14
|
+
schema: import("@xyo-network/schema-payload-plugin").SchemaSchema;
|
|
15
|
+
}>> | null | undefined;
|
|
16
|
+
xyoError: (import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & {
|
|
17
|
+
details?: import("@xylabs/object").JsonValue;
|
|
18
|
+
message?: string;
|
|
19
|
+
name?: string;
|
|
20
|
+
query?: import("@xylabs/hex").Hash;
|
|
21
|
+
schema: ModuleErrorSchema;
|
|
22
|
+
sources?: import("@xylabs/hex").Hash[];
|
|
23
|
+
}) | undefined;
|
|
24
|
+
};
|
|
25
|
+
export { useGetSchemaPayload };
|
|
26
|
+
//# sourceMappingURL=useGetSchema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGetSchema.d.ts","sourceRoot":"","sources":["../../../src/hooks/useGetSchema.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAS9D,QAAA,MAAM,mBAAmB,YAAa,MAAM;;;;;;;;eATrB,CAAC;;;;;;;;;;;;;;CAmDvB,CAAA;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SchemaPayload } from '@xyo-network/schema-payload-plugin';
|
|
2
|
+
export type SchemaList = {
|
|
3
|
+
name: string;
|
|
4
|
+
};
|
|
5
|
+
export declare const useSchemaDefinitions: (schemaList?: SchemaList[]) => SchemaPayload[] | undefined;
|
|
6
|
+
//# sourceMappingURL=useSchemaDefinitions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSchemaDefinitions.d.ts","sourceRoot":"","sources":["../../../src/hooks/useSchemaDefinitions.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAA;AAGvE,MAAM,MAAM,UAAU,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAA;AAEzC,eAAO,MAAM,oBAAoB,gBAAiB,UAAU,EAAE,KAAG,aAAa,EAAE,GAAG,SAkBlF,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Address } from '@xylabs/hex';
|
|
2
|
+
import type { SchemaListPayload } from '@xyo-network/diviner-schema-list-model';
|
|
3
|
+
export declare const useSchemaList: (address?: Address, nameOrAddress?: string) => [SchemaListPayload | null | undefined, Error | undefined];
|
|
4
|
+
//# sourceMappingURL=useSchemaList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSchemaList.d.ts","sourceRoot":"","sources":["../../../src/hooks/useSchemaList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAE1C,OAAO,KAAK,EAAE,iBAAiB,EAA0B,MAAM,wCAAwC,CAAA;AAQvG,eAAO,MAAM,aAAa,aAAc,OAAO,6BAAwC,CAAC,iBAAiB,GAAG,IAAI,GAAG,SAAS,EAAE,KAAK,GAAG,SAAS,CA4C9I,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Address } from '@xylabs/hex';
|
|
2
|
+
import type { SchemaStatsPayload } from '@xyo-network/diviner-schema-stats-model';
|
|
3
|
+
import type { Dispatch, SetStateAction } from 'react';
|
|
4
|
+
export declare const useSchemaStats: (statsAddress?: Address, nameOrAddress?: string) => [SchemaStatsPayload[] | undefined, Error | undefined, Dispatch<SetStateAction<number>>];
|
|
5
|
+
//# sourceMappingURL=useSchemaStats.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSchemaStats.d.ts","sourceRoot":"","sources":["../../../src/hooks/useSchemaStats.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAE1C,OAAO,KAAK,EACV,kBAAkB,EAEnB,MAAM,yCAAyC,CAAA;AAShD,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAGrD,eAAO,MAAM,cAAc,kBACV,OAAO,6BAErB,CAAC,kBAAkB,EAAE,GAAG,SAAS,EAAE,KAAK,GAAG,SAAS,EAAE,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CA6CxF,CAAA"}
|
package/dist/browser/index.d.ts
CHANGED
|
@@ -1,117 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { ContextExState } from '@xyo-network/react-shared';
|
|
6
|
-
import * as _xyo_network_react_property from '@xyo-network/react-property';
|
|
7
|
-
import { PropertyProps } from '@xyo-network/react-property';
|
|
8
|
-
import * as React from 'react';
|
|
9
|
-
import React__default, { Dispatch, SetStateAction } from 'react';
|
|
10
|
-
import { SelectExProps } from '@xylabs/react-select';
|
|
11
|
-
import { WithChildren } from '@xylabs/react-shared';
|
|
12
|
-
import * as _xylabs_hex from '@xylabs/hex';
|
|
13
|
-
import { Address } from '@xylabs/hex';
|
|
14
|
-
import * as _xylabs_object from '@xylabs/object';
|
|
15
|
-
import * as _xyo_network_schema_payload_plugin from '@xyo-network/schema-payload-plugin';
|
|
16
|
-
import { SchemaPayload } from '@xyo-network/schema-payload-plugin';
|
|
17
|
-
import * as _xyo_network_huri from '@xyo-network/huri';
|
|
18
|
-
import * as _xyo_network_payload_model from '@xyo-network/payload-model';
|
|
19
|
-
import { ModuleErrorSchema } from '@xyo-network/payload-model';
|
|
20
|
-
import { SchemaListPayload } from '@xyo-network/diviner-schema-list-model';
|
|
21
|
-
import { SchemaStatsPayload } from '@xyo-network/diviner-schema-stats-model';
|
|
22
|
-
|
|
23
|
-
type SchemaPropertyProps = PropertyProps & {
|
|
24
|
-
showLinkNames?: boolean;
|
|
25
|
-
showOpenNewWindowLink?: boolean;
|
|
26
|
-
showStatusIcon?: boolean;
|
|
27
|
-
value?: string;
|
|
28
|
-
};
|
|
29
|
-
declare const SchemaProperty: React__default.ForwardRefExoticComponent<((_xyo_network_react_property.PropertyBaseProps & {
|
|
30
|
-
actions?: _xyo_network_react_property.PropertyAction[];
|
|
31
|
-
badge?: boolean;
|
|
32
|
-
required?: boolean;
|
|
33
|
-
size?: _xyo_network_react_shared.SizeProp;
|
|
34
|
-
value?: string | number | boolean | null;
|
|
35
|
-
} & _xylabs_react_flexbox.BusyBoxProps & {
|
|
36
|
-
paper?: false;
|
|
37
|
-
} & {
|
|
38
|
-
showLinkNames?: boolean;
|
|
39
|
-
showOpenNewWindowLink?: boolean;
|
|
40
|
-
showStatusIcon?: boolean;
|
|
41
|
-
value?: string;
|
|
42
|
-
}) | Omit<_xyo_network_react_property.PropertyBaseProps & {
|
|
43
|
-
actions?: _xyo_network_react_property.PropertyAction[];
|
|
44
|
-
badge?: boolean;
|
|
45
|
-
required?: boolean;
|
|
46
|
-
size?: _xyo_network_react_shared.SizeProp;
|
|
47
|
-
value?: string | number | boolean | null;
|
|
48
|
-
} & _mui_material.PaperOwnProps & _mui_material_OverridableComponent_js.CommonProps & Omit<Omit<React__default.DetailedHTMLProps<React__default.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
49
|
-
ref?: ((instance: HTMLDivElement | null) => void | React__default.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof React__default.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | React__default.RefObject<HTMLDivElement> | null | undefined;
|
|
50
|
-
}, "className" | "style" | "classes" | "children" | "elevation" | "square" | "sx" | "variant"> & {
|
|
51
|
-
component?: React__default.ElementType;
|
|
52
|
-
} & {
|
|
53
|
-
paper: true;
|
|
54
|
-
} & {
|
|
55
|
-
showLinkNames?: boolean;
|
|
56
|
-
showOpenNewWindowLink?: boolean;
|
|
57
|
-
showStatusIcon?: boolean;
|
|
58
|
-
value?: string;
|
|
59
|
-
}, "ref">) & React__default.RefAttributes<HTMLDivElement>>;
|
|
60
|
-
|
|
61
|
-
type SchemaSelectExProps = SelectExProps<string>;
|
|
62
|
-
declare const SchemaSelectEx: React__default.FC<SchemaSelectExProps>;
|
|
63
|
-
|
|
64
|
-
interface SchemaContextState extends ContextExState {
|
|
65
|
-
schema?: string;
|
|
66
|
-
schemaList?: string[];
|
|
67
|
-
setSchema?: Dispatch<string>;
|
|
68
|
-
setSchemaList?: Dispatch<string[]>;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
declare const SchemaContext: React.Context<SchemaContextState & _xyo_network_react_shared.ContextExState>;
|
|
72
|
-
|
|
73
|
-
interface SchemaProviderProps {
|
|
74
|
-
defaultSchema?: string;
|
|
75
|
-
knownSchemaList?: string[];
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
declare const SchemaMemoryProvider: React__default.FC<WithChildren<SchemaProviderProps>>;
|
|
79
|
-
|
|
80
|
-
declare const SchemaRouteProvider: React__default.FC<WithChildren<SchemaProviderProps>>;
|
|
81
|
-
|
|
82
|
-
declare const useSchema: (required?: boolean) => Omit<SchemaContextState, "provided">;
|
|
83
|
-
|
|
84
|
-
declare const useGetSchemaPayload: (schema?: string) => {
|
|
85
|
-
notFound: boolean;
|
|
86
|
-
schemaHuri: _xyo_network_huri.Huri<{
|
|
87
|
-
schema: string;
|
|
88
|
-
} & _xyo_network_payload_model.PayloadFields> | undefined;
|
|
89
|
-
schemaPayload: Promise<_xyo_network_payload_model.WithMeta<_xyo_network_payload_model.SchemaFields & _xyo_network_payload_model.PayloadFields & {
|
|
90
|
-
definition: {
|
|
91
|
-
[key: string]: unknown;
|
|
92
|
-
$id?: string;
|
|
93
|
-
};
|
|
94
|
-
extends?: string;
|
|
95
|
-
name?: string;
|
|
96
|
-
schema: _xyo_network_schema_payload_plugin.SchemaSchema;
|
|
97
|
-
}>> | null | undefined;
|
|
98
|
-
xyoError: (_xyo_network_payload_model.SchemaFields & _xyo_network_payload_model.PayloadFields & {
|
|
99
|
-
details?: _xylabs_object.JsonValue;
|
|
100
|
-
message?: string;
|
|
101
|
-
name?: string;
|
|
102
|
-
query?: _xylabs_hex.Hash;
|
|
103
|
-
schema: ModuleErrorSchema;
|
|
104
|
-
sources?: _xylabs_hex.Hash[];
|
|
105
|
-
}) | undefined;
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
type SchemaList = {
|
|
109
|
-
name: string;
|
|
110
|
-
};
|
|
111
|
-
declare const useSchemaDefinitions: (schemaList?: SchemaList[]) => SchemaPayload[] | undefined;
|
|
112
|
-
|
|
113
|
-
declare const useSchemaList: (address?: Address, nameOrAddress?: string) => [SchemaListPayload | null | undefined, Error | undefined];
|
|
114
|
-
|
|
115
|
-
declare const useSchemaStats: (statsAddress?: Address, nameOrAddress?: string) => [SchemaStatsPayload[] | undefined, Error | undefined, Dispatch<SetStateAction<number>>];
|
|
116
|
-
|
|
117
|
-
export { SchemaContext, type SchemaContextState, type SchemaList, SchemaMemoryProvider, SchemaProperty, type SchemaPropertyProps, type SchemaProviderProps, SchemaRouteProvider, SchemaSelectEx, type SchemaSelectExProps, useGetSchemaPayload, useSchema, useSchemaDefinitions, useSchemaList, useSchemaStats };
|
|
1
|
+
export * from './components/index.ts';
|
|
2
|
+
export * from './contexts/index.ts';
|
|
3
|
+
export * from './hooks/index.ts';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,qBAAqB,CAAA;AACnC,cAAc,kBAAkB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/Property/SchemaProperty.tsx","../../src/components/SelectEx/SchemaSelectEx.tsx","../../src/contexts/Schema/Context.ts","../../src/contexts/Schema/Provider/Memory.tsx","../../src/hooks/useGetSchema.tsx","../../src/hooks/useSchemaDefinitions.tsx","../../src/hooks/useSchemaList.tsx","../../src/hooks/useSchemaStats.tsx","../../src/contexts/Schema/Provider/Route.tsx","../../src/contexts/Schema/use.ts"],"sourcesContent":["import { NewReleases as NewReleasesIcon, OpenInNew as OpenInNewIcon, Verified as VerifiedIcon } from '@mui/icons-material'\nimport { IconButton } from '@mui/material'\nimport { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { LinkEx } from '@xylabs/react-link'\nimport type { EventDispatch, EventNoun } from '@xyo-network/react-event'\nimport { useEvent } from '@xyo-network/react-event'\nimport type { PropertyProps } from '@xyo-network/react-property'\nimport { Property, PropertyValue } from '@xyo-network/react-property'\nimport type { SchemaCacheEntry } from '@xyo-network/schema-cache'\nimport { SchemaCache } from '@xyo-network/schema-cache'\nimport React, { forwardRef, useState } from 'react'\n\nexport type SchemaPropertyProps = PropertyProps & {\n showLinkNames?: boolean\n showOpenNewWindowLink?: boolean\n showStatusIcon?: boolean\n value?: string\n}\n\nconst useResolveSchema = (schema?: string) => {\n const [entry, setEntry] = useState<SchemaCacheEntry | null>()\n useAsyncEffect(\n async (mounted) => {\n if (schema) {\n const entry = await SchemaCache.instance.get(schema)\n if (mounted()) {\n setEntry(entry)\n }\n }\n },\n [schema],\n )\n return entry\n}\n\nexport const SchemaProperty = forwardRef<HTMLDivElement, SchemaPropertyProps>(\n ({ showLinkNames = true, showOpenNewWindowLink = true, showStatusIcon = true, titleProps, value, ...props }, forwardedRef) => {\n const resolvedSchema = useResolveSchema(value)\n const [buttonRef, buttonDispatch] = useEvent<HTMLButtonElement>()\n const [divRef, divDispatch] = useEvent<HTMLDivElement>()\n\n const onClick = (dispatch?: EventDispatch<EventNoun, 'click', string>, openNewWindow = false) => {\n dispatch?.(\n 'schema',\n 'click',\n JSON.stringify({\n openNewWindow,\n schema: value,\n }),\n )\n }\n\n return (\n <Property ref={forwardedRef} title=\"Schema\" value={value} tip=\"Schema sent with the payload\" titleProps={titleProps} {...props}>\n {value && showStatusIcon\n ? resolvedSchema === null\n ? (\n <IconButton ref={buttonRef} size=\"small\" onClick={() => onClick(buttonDispatch)}>\n <NewReleasesIcon color=\"warning\" fontSize=\"inherit\" />\n </IconButton>\n )\n : resolvedSchema === undefined\n ? (\n <IconButton ref={buttonRef} size=\"small\" onClick={() => onClick(buttonDispatch)}>\n <NewReleasesIcon color=\"disabled\" fontSize=\"inherit\" />\n </IconButton>\n )\n : (\n <IconButton rel=\"noopener noreferrer\" size=\"small\" target=\"_blank\" href={resolvedSchema?.huri?.href ?? ''}>\n <VerifiedIcon color=\"success\" fontSize=\"inherit\" />\n </IconButton>\n )\n\n : null}\n {value\n ? (\n <>\n {showLinkNames\n ? (\n <LinkEx display=\"block\" width=\"100%\" sx={{ cursor: 'pointer' }}>\n <PropertyValue ref={divRef} value={value} title=\"view schema\" onClick={() => onClick(divDispatch)} />\n </LinkEx>\n )\n : <PropertyValue ref={divRef} value={value} title=\"view schema\" onClick={() => onClick(divDispatch)} />}\n {showOpenNewWindowLink\n ? (\n <IconButton ref={buttonRef} size=\"small\" onClick={() => onClick(buttonDispatch, true)}>\n <OpenInNewIcon fontSize=\"inherit\" />\n </IconButton>\n )\n : null}\n </>\n )\n : null}\n </Property>\n )\n },\n)\n\nSchemaProperty.displayName = 'SchemaProperty'\n","import { MenuItem, Typography } from '@mui/material'\nimport type { SelectExProps } from '@xylabs/react-select'\nimport { SelectEx } from '@xylabs/react-select'\nimport React from 'react'\n\nimport { useSchema } from '../../contexts/index.ts'\n\nexport type SchemaSelectExProps = SelectExProps<string>\n\nexport const SchemaSelectEx: React.FC<SchemaSelectExProps> = ({ onChange, variant = 'outlined', ...props }) => {\n const { schema, setSchema, schemaList } = useSchema(false)\n\n return (\n <SelectEx\n variant={variant}\n size=\"small\"\n value={schema ?? 'none'}\n onChange={(event, child) => {\n if (event.target.value !== schema) {\n onChange?.(event, child)\n setSchema?.(event.target.value)\n }\n }}\n renderValue={(value) => {\n return <Typography>{value === 'none' ? '- None -' : value}</Typography>\n }}\n {...props}\n >\n {schemaList?.map((schema, index) => {\n return (\n <MenuItem key={index} value={schema}>\n {schema}\n </MenuItem>\n )\n })}\n <MenuItem key=\"none\" value=\"none\">\n - None -\n </MenuItem>\n </SelectEx>\n )\n}\n","import { createContextEx } from '@xyo-network/react-shared'\n\nimport type { SchemaContextState } from './State.ts'\n\nexport const SchemaContext = createContextEx<SchemaContextState>()\n","import { exists } from '@xylabs/exists'\nimport type { WithChildren } from '@xylabs/react-shared'\nimport React, { useEffect, useMemo, useState } from 'react'\n\nimport { useSchemaStats } from '../../../hooks/index.ts'\nimport { SchemaContext } from '../Context.ts'\nimport type { SchemaProviderProps } from './Props.ts'\n\nexport const SchemaMemoryProvider: React.FC<WithChildren<SchemaProviderProps>> = ({ defaultSchema, knownSchemaList, ...props }) => {\n const [schema, setSchema] = useState(defaultSchema)\n const [schemaList, setSchemaList] = useState<string[] | undefined>(knownSchemaList)\n const [fetchedSchemaStats] = useSchemaStats()\n\n useEffect(() => {\n if (fetchedSchemaStats) {\n const schemaList = (fetchedSchemaStats.map(({ name }) => name)).filter(exists)\n setSchemaList(schemaList)\n }\n }, [fetchedSchemaStats])\n\n const value = useMemo(() => ({ provided: true, schema, schemaList: knownSchemaList ?? schemaList, setSchema, setSchemaList }), [schema, schemaList, knownSchemaList])\n\n return <SchemaContext.Provider value={value} {...props} />\n}\n","import { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { ModuleError } from '@xyo-network/payload-model'\nimport { ModuleErrorSchema } from '@xyo-network/payload-model'\nimport type { SchemaCacheEntry } from '@xyo-network/schema-cache'\nimport { SchemaCache } from '@xyo-network/schema-cache'\nimport type { SchemaPayload } from '@xyo-network/schema-payload-plugin'\nimport { useState } from 'react'\n\n/**\n * Gets a Huri and schema payload from a schema string\n */\nconst useGetSchemaPayload = (schema?: string) => {\n const [notFound, setNotFound] = useState(false)\n const [xyoError, setError] = useState<ModuleError>()\n const [schemaCacheEntry, setSchemaCacheEntry] = useState<SchemaCacheEntry | null | undefined>()\n const [schemaLocal, setSchemaLocal] = useState<string>()\n\n useAsyncEffect(\n async (mounted) => {\n const firstRequest = !notFound && !schemaCacheEntry && !xyoError\n const schemaChanged = schema !== schemaLocal\n\n if ((schema && firstRequest) || (schema && schemaChanged)) {\n try {\n const schemaCacheEntry = await SchemaCache.instance.get(schema)\n if (mounted()) {\n setSchemaCacheEntry(schemaCacheEntry)\n setNotFound(schemaCacheEntry === null || schemaCacheEntry === undefined)\n }\n } catch (e) {\n const error = e as Error\n console.error(e)\n if (mounted()) {\n setError({ message: error.message, schema: ModuleErrorSchema, sources: [] })\n }\n }\n }\n if (schemaChanged) {\n setSchemaLocal(schema)\n }\n },\n [xyoError, notFound, schema, schemaLocal, schemaCacheEntry],\n )\n\n return {\n notFound,\n schemaHuri: schemaCacheEntry?.huri,\n schemaPayload:\n schemaCacheEntry ? new PayloadBuilder<SchemaPayload>(schemaCacheEntry?.payload).fields(schemaCacheEntry.payload).build() : schemaCacheEntry,\n xyoError,\n }\n}\n\nexport { useGetSchemaPayload }\n","import { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { SchemaCache } from '@xyo-network/schema-cache'\nimport type { SchemaPayload } from '@xyo-network/schema-payload-plugin'\nimport { useState } from 'react'\n\nexport type SchemaList = { name: string }\n\nexport const useSchemaDefinitions = (schemaList?: SchemaList[]): SchemaPayload[] | undefined => {\n const [schemaPayloads, setSchemaPayloads] = useState<SchemaPayload[]>()\n useAsyncEffect(\n async (mounted) => {\n if (schemaList) {\n const promiseResults = await Promise.allSettled(schemaList?.map(({ name }) => SchemaCache.instance.get(name)))\n if (mounted()) {\n setSchemaPayloads(\n promiseResults\n .map(result => (result.status === 'fulfilled' ? result.value?.payload : undefined))\n .filter(item => item !== undefined && item !== null) as SchemaPayload[],\n )\n }\n }\n },\n [schemaList],\n )\n return schemaPayloads\n}\n","import type { Address } from '@xylabs/hex'\nimport { useAsyncEffect } from '@xylabs/react-async-effect'\nimport type { SchemaListPayload, SchemaListQueryPayload } from '@xyo-network/diviner-schema-list-model'\nimport { SchemaListQuerySchema } from '@xyo-network/diviner-schema-list-model'\nimport type { WithMeta } from '@xyo-network/payload-model'\nimport { useWeakDivinerFromNode } from '@xyo-network/react-diviner'\nimport { useEffect, useMemo, useState } from 'react'\n\nexport const useSchemaList = (address?: Address, nameOrAddress = 'SchemaListDiviner'): [SchemaListPayload | null | undefined, Error | undefined] => {\n const [schemaList, setSchemaList] = useState<SchemaListPayload | null>()\n const [error, setError] = useState<Error>()\n const [diviner, divinerError] = useWeakDivinerFromNode(nameOrAddress)\n\n const query: SchemaListQueryPayload[] | undefined = useMemo(\n () =>\n address\n ? [\n {\n address,\n schema: SchemaListQuerySchema,\n },\n ]\n : undefined,\n [address],\n )\n\n useEffect(() => {\n if (diviner === null) {\n setSchemaList(null)\n setError(undefined)\n }\n }, [diviner])\n\n useAsyncEffect(\n async (mounted) => {\n const divinerInstance = diviner?.deref()\n if (divinerInstance) {\n try {\n const response = (await divinerInstance.divine(query)) as WithMeta<SchemaListPayload>[]\n if (mounted()) {\n setSchemaList(response?.[0])\n setError(undefined)\n }\n } catch (e) {\n setError(e as Error)\n setSchemaList(undefined)\n }\n }\n },\n [diviner, divinerError, query],\n )\n return [schemaList, error]\n}\n","import type { Address } from '@xylabs/hex'\nimport { useAsyncEffect } from '@xylabs/react-async-effect'\nimport type {\n SchemaStatsPayload,\n SchemaStatsQueryPayload } from '@xyo-network/diviner-schema-stats-model'\nimport {\n SchemaStatsDivinerSchema,\n SchemaStatsQuerySchema,\n} from '@xyo-network/diviner-schema-stats-model'\nimport { TYPES } from '@xyo-network/node-core-types'\nimport type { WithMeta, WithSources } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaTypeWithMeta } from '@xyo-network/payload-model'\nimport { useWeakDivinerFromNode } from '@xyo-network/react-diviner'\nimport type { Dispatch, SetStateAction } from 'react'\nimport { useMemo, useState } from 'react'\n\nexport const useSchemaStats = (\n statsAddress?: Address,\n nameOrAddress = TYPES.SchemaStatsDiviner,\n): [SchemaStatsPayload[] | undefined, Error | undefined, Dispatch<SetStateAction<number>>] => {\n const [refresh, setRefresh] = useState(1)\n const [diviner, divinerError] = useWeakDivinerFromNode(nameOrAddress)\n const [error, setError] = useState<Error>()\n const refreshHistory = () => setRefresh(previous => previous + 1)\n\n const [schemaList, setSchemaList] = useState<WithSources<WithMeta<SchemaStatsPayload>>[]>()\n\n const query: SchemaStatsQueryPayload = useMemo(\n () => ({\n address: statsAddress,\n schema: SchemaStatsQuerySchema,\n }),\n [statsAddress],\n )\n\n useAsyncEffect(\n async (mounted) => {\n const instance = diviner?.deref()\n if (instance) {\n if (divinerError) {\n if (mounted()) {\n setError(divinerError)\n setSchemaList(undefined)\n }\n } else {\n try {\n const schemas = (await instance.divine([query])).filter(isPayloadOfSchemaTypeWithMeta(SchemaStatsDivinerSchema)) as WithSources<\n WithMeta<SchemaStatsPayload>\n >[]\n if (mounted()) {\n setSchemaList(schemas)\n setError(undefined)\n }\n } catch (ex) {\n setError(ex as Error)\n setSchemaList(undefined)\n }\n }\n }\n },\n [diviner, refresh, divinerError, query],\n )\n\n return [schemaList, error, refreshHistory]\n}\n","import type { WithChildren } from '@xylabs/react-shared'\nimport React, { useCallback, useEffect, useMemo } from 'react'\nimport { useSearchParams } from 'react-router-dom'\n\nimport { SchemaContext } from '../Context.ts'\nimport { useSchema } from '../use.ts'\nimport { SchemaMemoryProvider } from './Memory.tsx'\nimport type { SchemaProviderProps } from './Props.ts'\n\nconst SchemaRouteProviderInner: React.FC<WithChildren> = ({ children }) => {\n const { schema, setSchema, schemaList } = useSchema()\n\n const [params, setParams] = useSearchParams()\n\n const routeSchema = params.get('schema')\n\n // update the network stored in the route\n const setSchemaParam = useCallback(\n (schema?: string) => {\n if (schema) {\n params.set('schema', schema)\n setParams(params, { replace: true })\n setSchema?.(schema)\n } else {\n params.delete('network')\n }\n },\n [params, setParams, setSchema],\n )\n\n // if the network is actively changed, update both memory and route\n const setSchemaLocal = useCallback(\n (schema: string) => {\n setSchemaParam(schema)\n setSchema?.(schema)\n },\n [setSchemaParam, setSchema],\n )\n\n // sync memory and route storage of network\n useEffect(() => {\n if (routeSchema !== schema) {\n if (routeSchema === undefined && schema !== undefined) {\n // if the route does not have a network selected, use what is in the memory context\n setSchemaLocal(schema)\n } else if (routeSchema) {\n // if the route has a selection and it is different from memory, update memory\n setSchema?.(routeSchema)\n }\n }\n }, [routeSchema, schema, setSchemaParam, setSchema, setSchemaLocal])\n\n const value = useMemo(() => ({ provided: true, schema, schemaList, setSchema: setSchemaLocal }), [schema, schemaList, setSchemaLocal])\n\n return <SchemaContext.Provider value={value}>{children}</SchemaContext.Provider>\n}\n\nexport const SchemaRouteProvider: React.FC<WithChildren<SchemaProviderProps>> = ({ knownSchemaList, defaultSchema, ...props }) => {\n return (\n <SchemaMemoryProvider knownSchemaList={knownSchemaList} defaultSchema={defaultSchema}>\n <SchemaRouteProviderInner {...props} />\n </SchemaMemoryProvider>\n )\n}\n","import { useContextEx } from '@xyo-network/react-shared'\n\nimport { SchemaContext } from './Context.ts'\nimport type { SchemaContextState } from './State.ts'\n\nexport const useSchema = (required = false) => {\n return useContextEx<SchemaContextState>(SchemaContext, 'Schema', required)\n}\n"],"mappings":";;;;AAAA,SAASA,eAAeC,iBAAiBC,aAAaC,eAAeC,YAAYC,oBAAoB;AACrG,SAASC,kBAAkB;AAC3B,SAASC,sBAAsB;AAC/B,SAASC,cAAc;AAEvB,SAASC,gBAAgB;AAEzB,SAASC,UAAUC,qBAAqB;AAExC,SAASC,mBAAmB;AAC5B,OAAOC,SAASC,YAAYC,gBAAgB;AAS5C,IAAMC,mBAAmB,wBAACC,WAAAA;AACxB,QAAM,CAACC,OAAOC,QAAAA,IAAYC,SAAAA;AAC1BC,iBACE,OAAOC,YAAAA;AACL,QAAIL,QAAQ;AACV,YAAMC,SAAQ,MAAMK,YAAYC,SAASC,IAAIR,MAAAA;AAC7C,UAAIK,QAAAA,GAAW;AACbH,iBAASD,MAAAA;MACX;IACF;EACF,GACA;IAACD;GAAO;AAEV,SAAOC;AACT,GAdyB;AAgBlB,IAAMQ,iBAAiBC,2BAC5B,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;GAAe;AAErI,SAAO,gBAAAM,OAAA,cAACC,cAAcC,UAAQ;IAACL;KAAelB,QAAAA;AAChD,GA9CyD;AAgDlD,IAAMwB,sBAAmE,wBAAC,EAAEC,iBAAiBC,eAAe,GAAGC,MAAAA,MAAO;AAC3H,SACE,gBAAAN,OAAA,cAACO,sBAAAA;IAAqBH;IAAkCC;KACtD,gBAAAL,OAAA,cAACtB,0BAA6B4B,KAAAA,CAAAA;AAGpC,GANgF;;;APhDzE,IAAME,iBAAgD,wBAAC,EAAEC,UAAUC,UAAU,YAAY,GAAGC,MAAAA,MAAO;AACxG,QAAM,EAAEC,QAAQC,WAAWC,WAAU,IAAKC,UAAU,KAAA;AAEpD,SACE,gBAAAC,OAAA,cAACC,UAAAA;IACCP;IACAQ,MAAK;IACLC,OAAOP,UAAU;IACjBH,UAAU,wBAACW,OAAOC,UAAAA;AAChB,UAAID,MAAME,OAAOH,UAAUP,QAAQ;AACjCH,mBAAWW,OAAOC,KAAAA;AAClBR,oBAAYO,MAAME,OAAOH,KAAK;MAChC;IACF,GALU;IAMVI,aAAa,wBAACJ,UAAAA;AACZ,aAAO,gBAAAH,OAAA,cAACQ,YAAAA,MAAYL,UAAU,SAAS,aAAaA,KAAAA;IACtD,GAFa;IAGZ,GAAGR;KAEHG,YAAYW,IAAI,CAACb,SAAQc,UAAAA;AACxB,WACE,gBAAAV,OAAA,cAACW,UAAAA;MAASC,KAAKF;MAAOP,OAAOP;OAC1BA,OAAAA;EAGP,CAAA,GACA,gBAAAI,OAAA,cAACW,UAAAA;IAASC,KAAI;IAAOT,OAAM;KAAO,UAAA,CAAA;AAKxC,GA/B6D;","names":["NewReleases","NewReleasesIcon","OpenInNew","OpenInNewIcon","Verified","VerifiedIcon","IconButton","useAsyncEffect","LinkEx","useEvent","Property","PropertyValue","SchemaCache","React","forwardRef","useState","useResolveSchema","schema","entry","setEntry","useState","useAsyncEffect","mounted","SchemaCache","instance","get","SchemaProperty","forwardRef","showLinkNames","showOpenNewWindowLink","showStatusIcon","titleProps","value","props","forwardedRef","resolvedSchema","buttonRef","buttonDispatch","useEvent","divRef","divDispatch","onClick","dispatch","openNewWindow","JSON","stringify","Property","ref","title","tip","IconButton","size","NewReleasesIcon","color","fontSize","undefined","rel","target","href","huri","VerifiedIcon","LinkEx","display","width","sx","cursor","PropertyValue","OpenInNewIcon","displayName","MenuItem","Typography","SelectEx","React","createContextEx","SchemaContext","exists","React","useEffect","useMemo","useState","useAsyncEffect","PayloadBuilder","ModuleErrorSchema","SchemaCache","useState","useGetSchemaPayload","schema","notFound","setNotFound","useState","xyoError","setError","schemaCacheEntry","setSchemaCacheEntry","schemaLocal","setSchemaLocal","useAsyncEffect","mounted","firstRequest","schemaChanged","SchemaCache","instance","get","undefined","e","error","console","message","ModuleErrorSchema","sources","schemaHuri","huri","schemaPayload","PayloadBuilder","payload","fields","build","useAsyncEffect","SchemaCache","useState","useSchemaDefinitions","schemaList","schemaPayloads","setSchemaPayloads","useState","useAsyncEffect","mounted","promiseResults","Promise","allSettled","map","name","SchemaCache","instance","get","result","status","value","payload","undefined","filter","item","useAsyncEffect","SchemaListQuerySchema","useWeakDivinerFromNode","useEffect","useMemo","useState","useSchemaList","address","nameOrAddress","schemaList","setSchemaList","useState","error","setError","diviner","divinerError","useWeakDivinerFromNode","query","useMemo","schema","SchemaListQuerySchema","undefined","useEffect","useAsyncEffect","mounted","divinerInstance","deref","response","divine","e","useAsyncEffect","SchemaStatsDivinerSchema","SchemaStatsQuerySchema","TYPES","isPayloadOfSchemaTypeWithMeta","useWeakDivinerFromNode","useMemo","useState","useSchemaStats","statsAddress","nameOrAddress","TYPES","SchemaStatsDiviner","refresh","setRefresh","useState","diviner","divinerError","useWeakDivinerFromNode","error","setError","refreshHistory","previous","schemaList","setSchemaList","query","useMemo","address","schema","SchemaStatsQuerySchema","useAsyncEffect","mounted","instance","deref","undefined","schemas","divine","filter","isPayloadOfSchemaTypeWithMeta","SchemaStatsDivinerSchema","ex","SchemaMemoryProvider","defaultSchema","knownSchemaList","props","schema","setSchema","useState","schemaList","setSchemaList","fetchedSchemaStats","useSchemaStats","useEffect","map","name","filter","exists","value","useMemo","provided","React","SchemaContext","Provider","React","useCallback","useEffect","useMemo","useSearchParams","useContextEx","useSchema","required","useContextEx","SchemaContext","SchemaRouteProviderInner","children","schema","setSchema","schemaList","useSchema","params","setParams","useSearchParams","routeSchema","get","setSchemaParam","useCallback","set","replace","delete","setSchemaLocal","useEffect","undefined","value","useMemo","provided","React","SchemaContext","Provider","SchemaRouteProvider","knownSchemaList","defaultSchema","props","SchemaMemoryProvider","SchemaSelectEx","onChange","variant","props","schema","setSchema","schemaList","useSchema","React","SelectEx","size","value","event","child","target","renderValue","Typography","map","index","MenuItem","key"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/Property/SchemaProperty.tsx","../../src/components/SelectEx/SchemaSelectEx.tsx","../../src/contexts/Schema/Context.ts","../../src/contexts/Schema/Provider/Memory.tsx","../../src/hooks/useGetSchema.tsx","../../src/hooks/useSchemaDefinitions.tsx","../../src/hooks/useSchemaList.tsx","../../src/hooks/useSchemaStats.tsx","../../src/contexts/Schema/Provider/Route.tsx","../../src/contexts/Schema/use.ts"],"sourcesContent":["import {\n NewReleases as NewReleasesIcon, OpenInNew as OpenInNewIcon, Verified as VerifiedIcon,\n} from '@mui/icons-material'\nimport { IconButton } from '@mui/material'\nimport { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { LinkEx } from '@xylabs/react-link'\nimport type { EventDispatch, EventNoun } from '@xyo-network/react-event'\nimport { useEvent } from '@xyo-network/react-event'\nimport type { PropertyProps } from '@xyo-network/react-property'\nimport { Property, PropertyValue } from '@xyo-network/react-property'\nimport type { SchemaCacheEntry } from '@xyo-network/schema-cache'\nimport { SchemaCache } from '@xyo-network/schema-cache'\nimport React, { forwardRef, useState } from 'react'\n\nexport type SchemaPropertyProps = PropertyProps & {\n showLinkNames?: boolean\n showOpenNewWindowLink?: boolean\n showStatusIcon?: boolean\n value?: string\n}\n\nconst useResolveSchema = (schema?: string) => {\n const [entry, setEntry] = useState<SchemaCacheEntry | null>()\n useAsyncEffect(\n async (mounted) => {\n if (schema) {\n const entry = await SchemaCache.instance.get(schema)\n if (mounted()) {\n setEntry(entry)\n }\n }\n },\n [schema],\n )\n return entry\n}\n\nexport const SchemaProperty = forwardRef<HTMLDivElement, SchemaPropertyProps>(\n ({\n showLinkNames = true, showOpenNewWindowLink = true, showStatusIcon = true, titleProps, value, ...props\n }, forwardedRef) => {\n const resolvedSchema = useResolveSchema(value)\n const [buttonRef, buttonDispatch] = useEvent<HTMLButtonElement>()\n const [divRef, divDispatch] = useEvent<HTMLDivElement>()\n\n const onClick = (dispatch?: EventDispatch<EventNoun, 'click', string>, openNewWindow = false) => {\n dispatch?.(\n 'schema',\n 'click',\n JSON.stringify({\n openNewWindow,\n schema: value,\n }),\n )\n }\n\n return (\n <Property ref={forwardedRef} title=\"Schema\" value={value} tip=\"Schema sent with the payload\" titleProps={titleProps} {...props}>\n {value && showStatusIcon\n ? resolvedSchema === null\n ? (\n <IconButton ref={buttonRef} size=\"small\" onClick={() => onClick(buttonDispatch)}>\n <NewReleasesIcon color=\"warning\" fontSize=\"inherit\" />\n </IconButton>\n )\n : resolvedSchema === undefined\n ? (\n <IconButton ref={buttonRef} size=\"small\" onClick={() => onClick(buttonDispatch)}>\n <NewReleasesIcon color=\"disabled\" fontSize=\"inherit\" />\n </IconButton>\n )\n : (\n <IconButton rel=\"noopener noreferrer\" size=\"small\" target=\"_blank\" href={resolvedSchema?.huri?.href ?? ''}>\n <VerifiedIcon color=\"success\" fontSize=\"inherit\" />\n </IconButton>\n )\n\n : null}\n {value\n ? (\n <>\n {showLinkNames\n ? (\n <LinkEx display=\"block\" width=\"100%\" sx={{ cursor: 'pointer' }}>\n <PropertyValue ref={divRef} value={value} title=\"view schema\" onClick={() => onClick(divDispatch)} />\n </LinkEx>\n )\n : <PropertyValue ref={divRef} value={value} title=\"view schema\" onClick={() => onClick(divDispatch)} />}\n {showOpenNewWindowLink\n ? (\n <IconButton ref={buttonRef} size=\"small\" onClick={() => onClick(buttonDispatch, true)}>\n <OpenInNewIcon fontSize=\"inherit\" />\n </IconButton>\n )\n : null}\n </>\n )\n : null}\n </Property>\n )\n },\n)\n\nSchemaProperty.displayName = 'SchemaProperty'\n","import { MenuItem, Typography } from '@mui/material'\nimport type { SelectExProps } from '@xylabs/react-select'\nimport { SelectEx } from '@xylabs/react-select'\nimport React from 'react'\n\nimport { useSchema } from '../../contexts/index.ts'\n\nexport type SchemaSelectExProps = SelectExProps<string>\n\nexport const SchemaSelectEx: React.FC<SchemaSelectExProps> = ({\n onChange, variant = 'outlined', ...props\n}) => {\n const {\n schema, setSchema, schemaList,\n } = useSchema(false)\n\n return (\n <SelectEx\n variant={variant}\n size=\"small\"\n value={schema ?? 'none'}\n onChange={(event, child) => {\n if (event.target.value !== schema) {\n onChange?.(event, child)\n setSchema?.(event.target.value)\n }\n }}\n renderValue={(value) => {\n return <Typography>{value === 'none' ? '- None -' : value}</Typography>\n }}\n {...props}\n >\n {schemaList?.map((schema, index) => {\n return (\n <MenuItem key={index} value={schema}>\n {schema}\n </MenuItem>\n )\n })}\n <MenuItem key=\"none\" value=\"none\">\n - None -\n </MenuItem>\n </SelectEx>\n )\n}\n","import { createContextEx } from '@xyo-network/react-shared'\n\nimport type { SchemaContextState } from './State.ts'\n\nexport const SchemaContext = createContextEx<SchemaContextState>()\n","import { exists } from '@xylabs/exists'\nimport type { WithChildren } from '@xylabs/react-shared'\nimport React, {\n useEffect, useMemo, useState,\n} from 'react'\n\nimport { useSchemaStats } from '../../../hooks/index.ts'\nimport { SchemaContext } from '../Context.ts'\nimport type { SchemaProviderProps } from './Props.ts'\n\nexport const SchemaMemoryProvider: React.FC<WithChildren<SchemaProviderProps>> = ({\n defaultSchema, knownSchemaList, ...props\n}) => {\n const [schema, setSchema] = useState(defaultSchema)\n const [schemaList, setSchemaList] = useState<string[] | undefined>(knownSchemaList)\n const [fetchedSchemaStats] = useSchemaStats()\n\n useEffect(() => {\n if (fetchedSchemaStats) {\n const schemaList = (fetchedSchemaStats.map(({ name }) => name)).filter(exists)\n setSchemaList(schemaList)\n }\n }, [fetchedSchemaStats])\n\n const value = useMemo(() => ({\n provided: true, schema, schemaList: knownSchemaList ?? schemaList, setSchema, setSchemaList,\n }), [schema, schemaList, knownSchemaList])\n\n return <SchemaContext.Provider value={value} {...props} />\n}\n","import { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { ModuleError } from '@xyo-network/payload-model'\nimport { ModuleErrorSchema } from '@xyo-network/payload-model'\nimport type { SchemaCacheEntry } from '@xyo-network/schema-cache'\nimport { SchemaCache } from '@xyo-network/schema-cache'\nimport type { SchemaPayload } from '@xyo-network/schema-payload-plugin'\nimport { useState } from 'react'\n\n/**\n * Gets a Huri and schema payload from a schema string\n */\nconst useGetSchemaPayload = (schema?: string) => {\n const [notFound, setNotFound] = useState(false)\n const [xyoError, setError] = useState<ModuleError>()\n const [schemaCacheEntry, setSchemaCacheEntry] = useState<SchemaCacheEntry | null | undefined>()\n const [schemaLocal, setSchemaLocal] = useState<string>()\n\n useAsyncEffect(\n async (mounted) => {\n const firstRequest = !notFound && !schemaCacheEntry && !xyoError\n const schemaChanged = schema !== schemaLocal\n\n if ((schema && firstRequest) || (schema && schemaChanged)) {\n try {\n const schemaCacheEntry = await SchemaCache.instance.get(schema)\n if (mounted()) {\n setSchemaCacheEntry(schemaCacheEntry)\n setNotFound(schemaCacheEntry === null || schemaCacheEntry === undefined)\n }\n } catch (e) {\n const error = e as Error\n console.error(e)\n if (mounted()) {\n setError({\n message: error.message, schema: ModuleErrorSchema, sources: [],\n })\n }\n }\n }\n if (schemaChanged) {\n setSchemaLocal(schema)\n }\n },\n [xyoError, notFound, schema, schemaLocal, schemaCacheEntry],\n )\n\n return {\n notFound,\n schemaHuri: schemaCacheEntry?.huri,\n schemaPayload:\n schemaCacheEntry ? new PayloadBuilder<SchemaPayload>(schemaCacheEntry?.payload).fields(schemaCacheEntry.payload).build() : schemaCacheEntry,\n xyoError,\n }\n}\n\nexport { useGetSchemaPayload }\n","import { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { SchemaCache } from '@xyo-network/schema-cache'\nimport type { SchemaPayload } from '@xyo-network/schema-payload-plugin'\nimport { useState } from 'react'\n\nexport type SchemaList = { name: string }\n\nexport const useSchemaDefinitions = (schemaList?: SchemaList[]): SchemaPayload[] | undefined => {\n const [schemaPayloads, setSchemaPayloads] = useState<SchemaPayload[]>()\n useAsyncEffect(\n async (mounted) => {\n if (schemaList) {\n const promiseResults = await Promise.allSettled(schemaList?.map(({ name }) => SchemaCache.instance.get(name)))\n if (mounted()) {\n setSchemaPayloads(\n promiseResults\n .map(result => (result.status === 'fulfilled' ? result.value?.payload : undefined))\n .filter(item => item !== undefined && item !== null) as SchemaPayload[],\n )\n }\n }\n },\n [schemaList],\n )\n return schemaPayloads\n}\n","import type { Address } from '@xylabs/hex'\nimport { useAsyncEffect } from '@xylabs/react-async-effect'\nimport type { SchemaListPayload, SchemaListQueryPayload } from '@xyo-network/diviner-schema-list-model'\nimport { SchemaListQuerySchema } from '@xyo-network/diviner-schema-list-model'\nimport type { WithMeta } from '@xyo-network/payload-model'\nimport { useWeakDivinerFromNode } from '@xyo-network/react-diviner'\nimport {\n useEffect, useMemo, useState,\n} from 'react'\n\nexport const useSchemaList = (address?: Address, nameOrAddress = 'SchemaListDiviner'): [SchemaListPayload | null | undefined, Error | undefined] => {\n const [schemaList, setSchemaList] = useState<SchemaListPayload | null>()\n const [error, setError] = useState<Error>()\n const [diviner, divinerError] = useWeakDivinerFromNode(nameOrAddress)\n\n const query: SchemaListQueryPayload[] | undefined = useMemo(\n () =>\n address\n ? [\n {\n address,\n schema: SchemaListQuerySchema,\n },\n ]\n : undefined,\n [address],\n )\n\n useEffect(() => {\n if (diviner === null) {\n setSchemaList(null)\n setError(undefined)\n }\n }, [diviner])\n\n useAsyncEffect(\n async (mounted) => {\n const divinerInstance = diviner?.deref()\n if (divinerInstance) {\n try {\n const response = (await divinerInstance.divine(query)) as WithMeta<SchemaListPayload>[]\n if (mounted()) {\n setSchemaList(response?.[0])\n setError(undefined)\n }\n } catch (e) {\n setError(e as Error)\n setSchemaList(undefined)\n }\n }\n },\n [diviner, divinerError, query],\n )\n return [schemaList, error]\n}\n","import type { Address } from '@xylabs/hex'\nimport { useAsyncEffect } from '@xylabs/react-async-effect'\nimport type {\n SchemaStatsPayload,\n SchemaStatsQueryPayload,\n} from '@xyo-network/diviner-schema-stats-model'\nimport {\n SchemaStatsDivinerSchema,\n SchemaStatsQuerySchema,\n} from '@xyo-network/diviner-schema-stats-model'\nimport { TYPES } from '@xyo-network/node-core-types'\nimport type { WithMeta, WithSources } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaTypeWithMeta } from '@xyo-network/payload-model'\nimport { useWeakDivinerFromNode } from '@xyo-network/react-diviner'\nimport type { Dispatch, SetStateAction } from 'react'\nimport { useMemo, useState } from 'react'\n\nexport const useSchemaStats = (\n statsAddress?: Address,\n nameOrAddress = TYPES.SchemaStatsDiviner,\n): [SchemaStatsPayload[] | undefined, Error | undefined, Dispatch<SetStateAction<number>>] => {\n const [refresh, setRefresh] = useState(1)\n const [diviner, divinerError] = useWeakDivinerFromNode(nameOrAddress)\n const [error, setError] = useState<Error>()\n const refreshHistory = () => setRefresh(previous => previous + 1)\n\n const [schemaList, setSchemaList] = useState<WithSources<WithMeta<SchemaStatsPayload>>[]>()\n\n const query: SchemaStatsQueryPayload = useMemo(\n () => ({\n address: statsAddress,\n schema: SchemaStatsQuerySchema,\n }),\n [statsAddress],\n )\n\n useAsyncEffect(\n async (mounted) => {\n const instance = diviner?.deref()\n if (instance) {\n if (divinerError) {\n if (mounted()) {\n setError(divinerError)\n setSchemaList(undefined)\n }\n } else {\n try {\n const schemas = (await instance.divine([query])).filter(isPayloadOfSchemaTypeWithMeta(SchemaStatsDivinerSchema)) as WithSources<\n WithMeta<SchemaStatsPayload>\n >[]\n if (mounted()) {\n setSchemaList(schemas)\n setError(undefined)\n }\n } catch (ex) {\n setError(ex as Error)\n setSchemaList(undefined)\n }\n }\n }\n },\n [diviner, refresh, divinerError, query],\n )\n\n return [schemaList, error, refreshHistory]\n}\n","import type { WithChildren } from '@xylabs/react-shared'\nimport React, {\n useCallback, useEffect, useMemo,\n} from 'react'\nimport { useSearchParams } from 'react-router-dom'\n\nimport { SchemaContext } from '../Context.ts'\nimport { useSchema } from '../use.ts'\nimport { SchemaMemoryProvider } from './Memory.tsx'\nimport type { SchemaProviderProps } from './Props.ts'\n\nconst SchemaRouteProviderInner: React.FC<WithChildren> = ({ children }) => {\n const {\n schema, setSchema, schemaList,\n } = useSchema()\n\n const [params, setParams] = useSearchParams()\n\n const routeSchema = params.get('schema')\n\n // update the network stored in the route\n const setSchemaParam = useCallback(\n (schema?: string) => {\n if (schema) {\n params.set('schema', schema)\n setParams(params, { replace: true })\n setSchema?.(schema)\n } else {\n params.delete('network')\n }\n },\n [params, setParams, setSchema],\n )\n\n // if the network is actively changed, update both memory and route\n const setSchemaLocal = useCallback(\n (schema: string) => {\n setSchemaParam(schema)\n setSchema?.(schema)\n },\n [setSchemaParam, setSchema],\n )\n\n // sync memory and route storage of network\n useEffect(() => {\n if (routeSchema !== schema) {\n if (routeSchema === undefined && schema !== undefined) {\n // if the route does not have a network selected, use what is in the memory context\n setSchemaLocal(schema)\n } else if (routeSchema) {\n // if the route has a selection and it is different from memory, update memory\n setSchema?.(routeSchema)\n }\n }\n }, [routeSchema, schema, setSchemaParam, setSchema, setSchemaLocal])\n\n const value = useMemo(() => ({\n provided: true, schema, schemaList, setSchema: setSchemaLocal,\n }), [schema, schemaList, setSchemaLocal])\n\n return <SchemaContext.Provider value={value}>{children}</SchemaContext.Provider>\n}\n\nexport const SchemaRouteProvider: React.FC<WithChildren<SchemaProviderProps>> = ({\n knownSchemaList, defaultSchema, ...props\n}) => {\n return (\n <SchemaMemoryProvider knownSchemaList={knownSchemaList} defaultSchema={defaultSchema}>\n <SchemaRouteProviderInner {...props} />\n </SchemaMemoryProvider>\n )\n}\n","import { useContextEx } from '@xyo-network/react-shared'\n\nimport { SchemaContext } from './Context.ts'\nimport type { SchemaContextState } from './State.ts'\n\nexport const useSchema = (required = false) => {\n return useContextEx<SchemaContextState>(SchemaContext, 'Schema', required)\n}\n"],"mappings":";;;;AAAA,SACEA,eAAeC,iBAAiBC,aAAaC,eAAeC,YAAYC,oBACnE;AACP,SAASC,kBAAkB;AAC3B,SAASC,sBAAsB;AAC/B,SAASC,cAAc;AAEvB,SAASC,gBAAgB;AAEzB,SAASC,UAAUC,qBAAqB;AAExC,SAASC,mBAAmB;AAC5B,OAAOC,SAASC,YAAYC,gBAAgB;AAS5C,IAAMC,mBAAmB,wBAACC,WAAAA;AACxB,QAAM,CAACC,OAAOC,QAAAA,IAAYC,SAAAA;AAC1BC,iBACE,OAAOC,YAAAA;AACL,QAAIL,QAAQ;AACV,YAAMC,SAAQ,MAAMK,YAAYC,SAASC,IAAIR,MAAAA;AAC7C,UAAIK,QAAAA,GAAW;AACbH,iBAASD,MAAAA;MACX;IACF;EACF,GACA;IAACD;GAAO;AAEV,SAAOC;AACT,GAdyB;AAgBlB,IAAMQ,iBAAiBC,2BAC5B,CAAC,EACCC,gBAAgB,MAAMC,wBAAwB,MAAMC,iBAAiB,MAAMC,YAAYC,OAAO,GAAGC,MAAAA,GAChGC,iBAAAA;AACD,QAAMC,iBAAiBnB,iBAAiBgB,KAAAA;AACxC,QAAM,CAACI,WAAWC,cAAAA,IAAkBC,SAAAA;AACpC,QAAM,CAACC,QAAQC,WAAAA,IAAeF,SAAAA;AAE9B,QAAMG,UAAU,wBAACC,UAAsDC,gBAAgB,UAAK;AAC1FD,eACE,UACA,SACAE,KAAKC,UAAU;MACbF;MACA1B,QAAQe;IACV,CAAA,CAAA;EAEJ,GATgB;AAWhB,SACE,sBAAA,cAACc,UAAAA;IAASC,KAAKb;IAAcc,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C,OAAA,cAACC,UAAAA;IACCP;IACAQ,MAAK;IACLC,OAAOP,UAAU;IACjBH,UAAU,wBAACW,OAAOC,UAAAA;AAChB,UAAID,MAAME,OAAOH,UAAUP,QAAQ;AACjCH,mBAAWW,OAAOC,KAAAA;AAClBR,oBAAYO,MAAME,OAAOH,KAAK;MAChC;IACF,GALU;IAMVI,aAAa,wBAACJ,UAAAA;AACZ,aAAO,gBAAAH,OAAA,cAACQ,YAAAA,MAAYL,UAAU,SAAS,aAAaA,KAAAA;IACtD,GAFa;IAGZ,GAAGR;KAEHG,YAAYW,IAAI,CAACb,SAAQc,UAAAA;AACxB,WACE,gBAAAV,OAAA,cAACW,UAAAA;MAASC,KAAKF;MAAOP,OAAOP;OAC1BA,OAAAA;EAGP,CAAA,GACA,gBAAAI,OAAA,cAACW,UAAAA;IAASC,KAAI;IAAOT,OAAM;KAAO,UAAA,CAAA;AAKxC,GAnC6D;","names":["NewReleases","NewReleasesIcon","OpenInNew","OpenInNewIcon","Verified","VerifiedIcon","IconButton","useAsyncEffect","LinkEx","useEvent","Property","PropertyValue","SchemaCache","React","forwardRef","useState","useResolveSchema","schema","entry","setEntry","useState","useAsyncEffect","mounted","SchemaCache","instance","get","SchemaProperty","forwardRef","showLinkNames","showOpenNewWindowLink","showStatusIcon","titleProps","value","props","forwardedRef","resolvedSchema","buttonRef","buttonDispatch","useEvent","divRef","divDispatch","onClick","dispatch","openNewWindow","JSON","stringify","Property","ref","title","tip","IconButton","size","NewReleasesIcon","color","fontSize","undefined","rel","target","href","huri","VerifiedIcon","LinkEx","display","width","sx","cursor","PropertyValue","OpenInNewIcon","displayName","MenuItem","Typography","SelectEx","React","createContextEx","SchemaContext","exists","React","useEffect","useMemo","useState","useAsyncEffect","PayloadBuilder","ModuleErrorSchema","SchemaCache","useState","useGetSchemaPayload","schema","notFound","setNotFound","useState","xyoError","setError","schemaCacheEntry","setSchemaCacheEntry","schemaLocal","setSchemaLocal","useAsyncEffect","mounted","firstRequest","schemaChanged","SchemaCache","instance","get","undefined","e","error","console","message","ModuleErrorSchema","sources","schemaHuri","huri","schemaPayload","PayloadBuilder","payload","fields","build","useAsyncEffect","SchemaCache","useState","useSchemaDefinitions","schemaList","schemaPayloads","setSchemaPayloads","useState","useAsyncEffect","mounted","promiseResults","Promise","allSettled","map","name","SchemaCache","instance","get","result","status","value","payload","undefined","filter","item","useAsyncEffect","SchemaListQuerySchema","useWeakDivinerFromNode","useEffect","useMemo","useState","useSchemaList","address","nameOrAddress","schemaList","setSchemaList","useState","error","setError","diviner","divinerError","useWeakDivinerFromNode","query","useMemo","schema","SchemaListQuerySchema","undefined","useEffect","useAsyncEffect","mounted","divinerInstance","deref","response","divine","e","useAsyncEffect","SchemaStatsDivinerSchema","SchemaStatsQuerySchema","TYPES","isPayloadOfSchemaTypeWithMeta","useWeakDivinerFromNode","useMemo","useState","useSchemaStats","statsAddress","nameOrAddress","TYPES","SchemaStatsDiviner","refresh","setRefresh","useState","diviner","divinerError","useWeakDivinerFromNode","error","setError","refreshHistory","previous","schemaList","setSchemaList","query","useMemo","address","schema","SchemaStatsQuerySchema","useAsyncEffect","mounted","instance","deref","undefined","schemas","divine","filter","isPayloadOfSchemaTypeWithMeta","SchemaStatsDivinerSchema","ex","SchemaMemoryProvider","defaultSchema","knownSchemaList","props","schema","setSchema","useState","schemaList","setSchemaList","fetchedSchemaStats","useSchemaStats","useEffect","map","name","filter","exists","value","useMemo","provided","React","SchemaContext","Provider","React","useCallback","useEffect","useMemo","useSearchParams","useContextEx","useSchema","required","useContextEx","SchemaContext","SchemaRouteProviderInner","children","schema","setSchema","schemaList","useSchema","params","setParams","useSearchParams","routeSchema","get","setSchemaParam","useCallback","set","replace","delete","setSchemaLocal","useEffect","undefined","value","useMemo","provided","React","SchemaContext","Provider","SchemaRouteProvider","knownSchemaList","defaultSchema","props","SchemaMemoryProvider","SchemaSelectEx","onChange","variant","props","schema","setSchema","schemaList","useSchema","React","SelectEx","size","value","event","child","target","renderValue","Typography","map","index","MenuItem","key"]}
|
package/package.json
CHANGED
|
@@ -1,46 +1,87 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/react-schema",
|
|
3
|
+
"version": "3.0.4",
|
|
4
|
+
"description": "Common React library for all XYO projects that use React",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"xyo",
|
|
7
|
+
"utility",
|
|
8
|
+
"typescript",
|
|
9
|
+
"react"
|
|
10
|
+
],
|
|
11
|
+
"homepage": "https://xyo.network",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "git+https://github.com/XYOracleNetwork/sdk-xyo-react-js/issues",
|
|
14
|
+
"email": "support@xyo.network"
|
|
15
|
+
},
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/XYOracleNetwork/sdk-xyo-react-js.git"
|
|
19
|
+
},
|
|
20
|
+
"license": "LGPL-3.0-only",
|
|
3
21
|
"author": {
|
|
4
|
-
"email": "support@xyo.network",
|
|
5
22
|
"name": "XYO Development Team",
|
|
23
|
+
"email": "support@xyo.network",
|
|
6
24
|
"url": "https://xyo.network"
|
|
7
25
|
},
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
26
|
+
"sideEffects": false,
|
|
27
|
+
"type": "module",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"import": {
|
|
31
|
+
"types": "./dist/browser/index.d.ts",
|
|
32
|
+
"default": "./dist/browser/index.mjs"
|
|
33
|
+
},
|
|
34
|
+
"types": "./dist/browser/index.d.ts",
|
|
35
|
+
"default": "./dist/browser/index.mjs"
|
|
36
|
+
},
|
|
37
|
+
"./package.json": "./package.json"
|
|
38
|
+
},
|
|
39
|
+
"module": "dist/browser/index.mjs",
|
|
40
|
+
"types": "dist/browser/index.d.ts",
|
|
41
|
+
"scripts": {
|
|
42
|
+
"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\"",
|
|
43
|
+
"lint-pkg": "npmPkgJsonLint ."
|
|
11
44
|
},
|
|
12
45
|
"dependencies": {
|
|
13
|
-
"@xylabs/exists": "^4.0.
|
|
14
|
-
"@xylabs/hex": "^4.0.
|
|
46
|
+
"@xylabs/exists": "^4.0.5",
|
|
47
|
+
"@xylabs/hex": "^4.0.5",
|
|
15
48
|
"@xylabs/react-async-effect": "^4.0.3",
|
|
16
49
|
"@xylabs/react-link": "^4.0.3",
|
|
17
50
|
"@xylabs/react-select": "^4.0.3",
|
|
18
51
|
"@xylabs/react-shared": "^4.0.3",
|
|
19
|
-
"@xyo-network/diviner-schema-list-model": "^3.0.
|
|
20
|
-
"@xyo-network/diviner-schema-stats-model": "^3.0.
|
|
21
|
-
"@xyo-network/node-core-types": "^
|
|
22
|
-
"@xyo-network/payload-builder": "^3.0.
|
|
23
|
-
"@xyo-network/payload-model": "^3.0.
|
|
24
|
-
"@xyo-network/react-diviner": "^3.0.
|
|
25
|
-
"@xyo-network/react-event": "^3.0.
|
|
26
|
-
"@xyo-network/react-property": "^3.0.
|
|
27
|
-
"@xyo-network/react-shared": "^3.0.
|
|
28
|
-
"@xyo-network/schema-cache": "^3.0.
|
|
29
|
-
"@xyo-network/schema-payload-plugin": "^3.0.
|
|
52
|
+
"@xyo-network/diviner-schema-list-model": "^3.0.15",
|
|
53
|
+
"@xyo-network/diviner-schema-stats-model": "^3.0.15",
|
|
54
|
+
"@xyo-network/node-core-types": "^3.0.1",
|
|
55
|
+
"@xyo-network/payload-builder": "^3.0.15",
|
|
56
|
+
"@xyo-network/payload-model": "^3.0.15",
|
|
57
|
+
"@xyo-network/react-diviner": "^3.0.4",
|
|
58
|
+
"@xyo-network/react-event": "^3.0.4",
|
|
59
|
+
"@xyo-network/react-property": "^3.0.4",
|
|
60
|
+
"@xyo-network/react-shared": "^3.0.4",
|
|
61
|
+
"@xyo-network/schema-cache": "^3.0.15",
|
|
62
|
+
"@xyo-network/schema-payload-plugin": "^3.0.15",
|
|
30
63
|
"react-router-dom": "^6.26.1"
|
|
31
64
|
},
|
|
32
65
|
"devDependencies": {
|
|
66
|
+
"@emotion/react": "^11.13.3",
|
|
67
|
+
"@emotion/styled": "^11.13.0",
|
|
68
|
+
"@mui/icons-material": "^5.16.7",
|
|
69
|
+
"@mui/material": "^5.16.7",
|
|
70
|
+
"@mui/styles": "^5.16.7",
|
|
33
71
|
"@storybook/react": "^8.2.9",
|
|
34
72
|
"@xylabs/react-flexbox": "^4.0.3",
|
|
35
|
-
"@xylabs/ts-scripts-yarn3": "^4.0.
|
|
36
|
-
"@xylabs/tsconfig-react": "^4.0.
|
|
37
|
-
"@xyo-network/bridge-http": "^3.0.
|
|
38
|
-
"@xyo-network/node-memory": "^3.0.
|
|
39
|
-
"@xyo-network/node-model": "^3.0.
|
|
40
|
-
"@xyo-network/react-node": "^3.0.
|
|
41
|
-
"@xyo-network/react-payload-raw-info": "^3.0.
|
|
42
|
-
"@xyo-network/react-storybook": "^3.0.
|
|
43
|
-
"@xyo-network/react-wallet": "^3.0.
|
|
73
|
+
"@xylabs/ts-scripts-yarn3": "^4.0.7",
|
|
74
|
+
"@xylabs/tsconfig-react": "^4.0.7",
|
|
75
|
+
"@xyo-network/bridge-http": "^3.0.15",
|
|
76
|
+
"@xyo-network/node-memory": "^3.0.15",
|
|
77
|
+
"@xyo-network/node-model": "^3.0.15",
|
|
78
|
+
"@xyo-network/react-node": "^3.0.4",
|
|
79
|
+
"@xyo-network/react-payload-raw-info": "^3.0.4",
|
|
80
|
+
"@xyo-network/react-storybook": "^3.0.4",
|
|
81
|
+
"@xyo-network/react-wallet": "^3.0.4",
|
|
82
|
+
"react": "^18.3.1",
|
|
83
|
+
"react-dom": "^18.3.1",
|
|
84
|
+
"storybook": "^8.2.9",
|
|
44
85
|
"typescript": "^5.5.4"
|
|
45
86
|
},
|
|
46
87
|
"peerDependencies": {
|
|
@@ -52,41 +93,8 @@
|
|
|
52
93
|
"react": "^18",
|
|
53
94
|
"react-dom": "^18"
|
|
54
95
|
},
|
|
55
|
-
"description": "Common React library for all XYO projects that use React",
|
|
56
|
-
"docs": "dist/docs.json",
|
|
57
|
-
"exports": {
|
|
58
|
-
".": {
|
|
59
|
-
"import": {
|
|
60
|
-
"types": "./dist/browser/index.d.ts",
|
|
61
|
-
"default": "./dist/browser/index.mjs"
|
|
62
|
-
},
|
|
63
|
-
"types": "./dist/browser/index.d.ts",
|
|
64
|
-
"default": "./dist/browser/index.mjs"
|
|
65
|
-
},
|
|
66
|
-
"./package.json": "./package.json"
|
|
67
|
-
},
|
|
68
|
-
"module": "dist/browser/index.mjs",
|
|
69
|
-
"homepage": "https://xyo.network",
|
|
70
|
-
"keywords": [
|
|
71
|
-
"xyo",
|
|
72
|
-
"utility",
|
|
73
|
-
"typescript",
|
|
74
|
-
"react"
|
|
75
|
-
],
|
|
76
|
-
"license": "LGPL-3.0-only",
|
|
77
96
|
"publishConfig": {
|
|
78
97
|
"access": "public"
|
|
79
98
|
},
|
|
80
|
-
"
|
|
81
|
-
"type": "git",
|
|
82
|
-
"url": "git+https://github.com/XYOracleNetwork/sdk-xyo-react-js.git"
|
|
83
|
-
},
|
|
84
|
-
"scripts": {
|
|
85
|
-
"lint-pkg": "npmPkgJsonLint .",
|
|
86
|
-
"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\""
|
|
87
|
-
},
|
|
88
|
-
"sideEffects": false,
|
|
89
|
-
"types": "dist/browser/index.d.ts",
|
|
90
|
-
"version": "3.0.2",
|
|
91
|
-
"type": "module"
|
|
99
|
+
"docs": "dist/docs.json"
|
|
92
100
|
}
|
|
@@ -7,11 +7,7 @@ import { SchemaProperty } from './SchemaProperty.tsx'
|
|
|
7
7
|
|
|
8
8
|
const StorybookEntry: Meta = {
|
|
9
9
|
component: SchemaProperty,
|
|
10
|
-
parameters: {
|
|
11
|
-
docs: {
|
|
12
|
-
page: null,
|
|
13
|
-
},
|
|
14
|
-
},
|
|
10
|
+
parameters: { docs: { page: null } },
|
|
15
11
|
title: 'Schema/SchemaProperty',
|
|
16
12
|
}
|
|
17
13
|
|
|
@@ -38,6 +34,8 @@ WithVerifiedValuePaper.args = { paper: true, value: 'network.xyo.schema' }
|
|
|
38
34
|
const WithUnverifiedValue = Template.bind({})
|
|
39
35
|
WithUnverifiedValue.args = { value: 'network.xyo.blahblah' }
|
|
40
36
|
|
|
41
|
-
export {
|
|
37
|
+
export {
|
|
38
|
+
Default, WithUnverifiedValue, WithVerifiedValue, WithVerifiedValuePaper,
|
|
39
|
+
}
|
|
42
40
|
|
|
43
41
|
export default StorybookEntry
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
NewReleases as NewReleasesIcon, OpenInNew as OpenInNewIcon, Verified as VerifiedIcon,
|
|
3
|
+
} from '@mui/icons-material'
|
|
2
4
|
import { IconButton } from '@mui/material'
|
|
3
5
|
import { useAsyncEffect } from '@xylabs/react-async-effect'
|
|
4
6
|
import { LinkEx } from '@xylabs/react-link'
|
|
@@ -34,7 +36,9 @@ const useResolveSchema = (schema?: string) => {
|
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
export const SchemaProperty = forwardRef<HTMLDivElement, SchemaPropertyProps>(
|
|
37
|
-
({
|
|
39
|
+
({
|
|
40
|
+
showLinkNames = true, showOpenNewWindowLink = true, showStatusIcon = true, titleProps, value, ...props
|
|
41
|
+
}, forwardedRef) => {
|
|
38
42
|
const resolvedSchema = useResolveSchema(value)
|
|
39
43
|
const [buttonRef, buttonDispatch] = useEvent<HTMLButtonElement>()
|
|
40
44
|
const [divRef, divDispatch] = useEvent<HTMLDivElement>()
|
|
@@ -7,8 +7,12 @@ import { useSchema } from '../../contexts/index.ts'
|
|
|
7
7
|
|
|
8
8
|
export type SchemaSelectExProps = SelectExProps<string>
|
|
9
9
|
|
|
10
|
-
export const SchemaSelectEx: React.FC<SchemaSelectExProps> = ({
|
|
11
|
-
|
|
10
|
+
export const SchemaSelectEx: React.FC<SchemaSelectExProps> = ({
|
|
11
|
+
onChange, variant = 'outlined', ...props
|
|
12
|
+
}) => {
|
|
13
|
+
const {
|
|
14
|
+
schema, setSchema, schemaList,
|
|
15
|
+
} = useSchema(false)
|
|
12
16
|
|
|
13
17
|
return (
|
|
14
18
|
<SelectEx
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { exists } from '@xylabs/exists'
|
|
2
2
|
import type { WithChildren } from '@xylabs/react-shared'
|
|
3
|
-
import React, {
|
|
3
|
+
import React, {
|
|
4
|
+
useEffect, useMemo, useState,
|
|
5
|
+
} from 'react'
|
|
4
6
|
|
|
5
7
|
import { useSchemaStats } from '../../../hooks/index.ts'
|
|
6
8
|
import { SchemaContext } from '../Context.ts'
|
|
7
9
|
import type { SchemaProviderProps } from './Props.ts'
|
|
8
10
|
|
|
9
|
-
export const SchemaMemoryProvider: React.FC<WithChildren<SchemaProviderProps>> = ({
|
|
11
|
+
export const SchemaMemoryProvider: React.FC<WithChildren<SchemaProviderProps>> = ({
|
|
12
|
+
defaultSchema, knownSchemaList, ...props
|
|
13
|
+
}) => {
|
|
10
14
|
const [schema, setSchema] = useState(defaultSchema)
|
|
11
15
|
const [schemaList, setSchemaList] = useState<string[] | undefined>(knownSchemaList)
|
|
12
16
|
const [fetchedSchemaStats] = useSchemaStats()
|
|
@@ -18,7 +22,9 @@ export const SchemaMemoryProvider: React.FC<WithChildren<SchemaProviderProps>> =
|
|
|
18
22
|
}
|
|
19
23
|
}, [fetchedSchemaStats])
|
|
20
24
|
|
|
21
|
-
const value = useMemo(() => ({
|
|
25
|
+
const value = useMemo(() => ({
|
|
26
|
+
provided: true, schema, schemaList: knownSchemaList ?? schemaList, setSchema, setSchemaList,
|
|
27
|
+
}), [schema, schemaList, knownSchemaList])
|
|
22
28
|
|
|
23
29
|
return <SchemaContext.Provider value={value} {...props} />
|
|
24
30
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { WithChildren } from '@xylabs/react-shared'
|
|
2
|
-
import React, {
|
|
2
|
+
import React, {
|
|
3
|
+
useCallback, useEffect, useMemo,
|
|
4
|
+
} from 'react'
|
|
3
5
|
import { useSearchParams } from 'react-router-dom'
|
|
4
6
|
|
|
5
7
|
import { SchemaContext } from '../Context.ts'
|
|
@@ -8,7 +10,9 @@ import { SchemaMemoryProvider } from './Memory.tsx'
|
|
|
8
10
|
import type { SchemaProviderProps } from './Props.ts'
|
|
9
11
|
|
|
10
12
|
const SchemaRouteProviderInner: React.FC<WithChildren> = ({ children }) => {
|
|
11
|
-
const {
|
|
13
|
+
const {
|
|
14
|
+
schema, setSchema, schemaList,
|
|
15
|
+
} = useSchema()
|
|
12
16
|
|
|
13
17
|
const [params, setParams] = useSearchParams()
|
|
14
18
|
|
|
@@ -50,12 +54,16 @@ const SchemaRouteProviderInner: React.FC<WithChildren> = ({ children }) => {
|
|
|
50
54
|
}
|
|
51
55
|
}, [routeSchema, schema, setSchemaParam, setSchema, setSchemaLocal])
|
|
52
56
|
|
|
53
|
-
const value = useMemo(() => ({
|
|
57
|
+
const value = useMemo(() => ({
|
|
58
|
+
provided: true, schema, schemaList, setSchema: setSchemaLocal,
|
|
59
|
+
}), [schema, schemaList, setSchemaLocal])
|
|
54
60
|
|
|
55
61
|
return <SchemaContext.Provider value={value}>{children}</SchemaContext.Provider>
|
|
56
62
|
}
|
|
57
63
|
|
|
58
|
-
export const SchemaRouteProvider: React.FC<WithChildren<SchemaProviderProps>> = ({
|
|
64
|
+
export const SchemaRouteProvider: React.FC<WithChildren<SchemaProviderProps>> = ({
|
|
65
|
+
knownSchemaList, defaultSchema, ...props
|
|
66
|
+
}) => {
|
|
59
67
|
return (
|
|
60
68
|
<SchemaMemoryProvider knownSchemaList={knownSchemaList} defaultSchema={defaultSchema}>
|
|
61
69
|
<SchemaRouteProviderInner {...props} />
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
Alert, Button, TextField, Typography,
|
|
3
|
+
} from '@mui/material'
|
|
4
|
+
import type {
|
|
5
|
+
Decorator, Meta, StoryFn,
|
|
6
|
+
} from '@storybook/react'
|
|
3
7
|
import type { Address } from '@xylabs/hex'
|
|
4
8
|
import { useAsyncEffect } from '@xylabs/react-async-effect'
|
|
5
9
|
import { FlexGrowRow } from '@xylabs/react-flexbox'
|
|
@@ -25,7 +29,11 @@ const MemoryNodeDecorator: Decorator = (Story, args) => {
|
|
|
25
29
|
useAsyncEffect(
|
|
26
30
|
async () => {
|
|
27
31
|
const node = await MemoryNode.create({ config: { schema: NodeConfigSchema } })
|
|
28
|
-
const bridge = await HttpBridge.create({
|
|
32
|
+
const bridge = await HttpBridge.create({
|
|
33
|
+
config: {
|
|
34
|
+
nodeUrl, schema: HttpBridgeConfigSchema, security: { allowAnonymous: true },
|
|
35
|
+
},
|
|
36
|
+
})
|
|
29
37
|
await node.register(bridge)
|
|
30
38
|
await node.attach(bridge.address, true)
|
|
31
39
|
setNode(node)
|
|
@@ -59,7 +67,10 @@ const Template: StoryFn<React.FC> = () => {
|
|
|
59
67
|
const schemaDefinitions = useSchemaDefinitions(mappedSchemaList)
|
|
60
68
|
|
|
61
69
|
return (
|
|
62
|
-
<div style={{
|
|
70
|
+
<div style={{
|
|
71
|
+
display: 'flex', flexDirection: 'column', rowGap: '16px',
|
|
72
|
+
}}
|
|
73
|
+
>
|
|
63
74
|
{schemaStatsError
|
|
64
75
|
? <Alert severity="error">{schemaStatsError.message ?? schemaListError?.message}</Alert>
|
|
65
76
|
: null}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
FormControl, TextField, Typography,
|
|
3
|
+
} from '@mui/material'
|
|
2
4
|
import type { Meta, StoryFn } from '@storybook/react'
|
|
3
5
|
import { FlexRow } from '@xylabs/react-flexbox'
|
|
4
6
|
import { JsonViewerEx } from '@xyo-network/react-payload-raw-info'
|
|
@@ -49,11 +51,7 @@ const UseGetSchemaComponent: React.FC<{ schema: string }> = ({ schema }) => {
|
|
|
49
51
|
const StorybookEntry: Meta = {
|
|
50
52
|
argTypes: {},
|
|
51
53
|
component: UseGetSchemaComponent,
|
|
52
|
-
parameters: {
|
|
53
|
-
docs: {
|
|
54
|
-
page: null,
|
|
55
|
-
},
|
|
56
|
-
},
|
|
54
|
+
parameters: { docs: { page: null } },
|
|
57
55
|
title: 'payload/useGetSchema',
|
|
58
56
|
}
|
|
59
57
|
|
|
@@ -32,7 +32,9 @@ const useGetSchemaPayload = (schema?: string) => {
|
|
|
32
32
|
const error = e as Error
|
|
33
33
|
console.error(e)
|
|
34
34
|
if (mounted()) {
|
|
35
|
-
setError({
|
|
35
|
+
setError({
|
|
36
|
+
message: error.message, schema: ModuleErrorSchema, sources: [],
|
|
37
|
+
})
|
|
36
38
|
}
|
|
37
39
|
}
|
|
38
40
|
}
|
|
@@ -4,7 +4,9 @@ import type { SchemaListPayload, SchemaListQueryPayload } from '@xyo-network/div
|
|
|
4
4
|
import { SchemaListQuerySchema } from '@xyo-network/diviner-schema-list-model'
|
|
5
5
|
import type { WithMeta } from '@xyo-network/payload-model'
|
|
6
6
|
import { useWeakDivinerFromNode } from '@xyo-network/react-diviner'
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
useEffect, useMemo, useState,
|
|
9
|
+
} from 'react'
|
|
8
10
|
|
|
9
11
|
export const useSchemaList = (address?: Address, nameOrAddress = 'SchemaListDiviner'): [SchemaListPayload | null | undefined, Error | undefined] => {
|
|
10
12
|
const [schemaList, setSchemaList] = useState<SchemaListPayload | null>()
|
|
@@ -2,7 +2,8 @@ import type { Address } from '@xylabs/hex'
|
|
|
2
2
|
import { useAsyncEffect } from '@xylabs/react-async-effect'
|
|
3
3
|
import type {
|
|
4
4
|
SchemaStatsPayload,
|
|
5
|
-
SchemaStatsQueryPayload
|
|
5
|
+
SchemaStatsQueryPayload,
|
|
6
|
+
} from '@xyo-network/diviner-schema-stats-model'
|
|
6
7
|
import {
|
|
7
8
|
SchemaStatsDivinerSchema,
|
|
8
9
|
SchemaStatsQuerySchema,
|