@xyo-network/react-schema 2.64.0-rc.7 → 2.64.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/components/Property/SchemaProperty.cjs +76 -0
- package/dist/{node/components/Property/SchemaProperty.mjs.map → browser/components/Property/SchemaProperty.cjs.map} +1 -1
- package/dist/browser/components/Property/SchemaProperty.d.cts +40 -0
- package/dist/browser/components/Property/SchemaProperty.d.cts.map +1 -0
- package/dist/browser/components/Property/SchemaProperty.js +4 -3
- package/dist/browser/components/Property/SchemaProperty.js.map +1 -1
- package/dist/browser/components/Property/index.cjs +78 -0
- package/dist/browser/components/Property/index.cjs.map +1 -0
- package/dist/browser/components/Property/index.d.cts +2 -0
- package/dist/browser/components/Property/index.d.cts.map +1 -0
- package/dist/browser/components/Property/index.js +54 -1
- package/dist/browser/components/Property/index.js.map +1 -1
- package/dist/browser/components/SelectEx/SchemaSelectEx.cjs +68 -0
- package/dist/browser/components/SelectEx/SchemaSelectEx.cjs.map +1 -0
- package/dist/browser/components/SelectEx/SchemaSelectEx.d.cts +5 -0
- package/dist/browser/components/SelectEx/SchemaSelectEx.d.cts.map +1 -0
- package/dist/browser/components/SelectEx/SchemaSelectEx.js +15 -3
- package/dist/browser/components/SelectEx/SchemaSelectEx.js.map +1 -1
- package/dist/browser/components/SelectEx/index.cjs +70 -0
- package/dist/browser/components/SelectEx/index.cjs.map +1 -0
- package/dist/browser/components/SelectEx/index.d.cts +2 -0
- package/dist/browser/components/SelectEx/index.d.cts.map +1 -0
- package/dist/browser/components/SelectEx/index.js +46 -1
- package/dist/browser/components/SelectEx/index.js.map +1 -1
- package/dist/browser/components/index.cjs +123 -0
- package/dist/browser/components/index.cjs.map +1 -0
- package/dist/browser/components/index.d.cts +3 -0
- package/dist/browser/components/index.d.cts.map +1 -0
- package/dist/browser/components/index.js +99 -2
- package/dist/browser/components/index.js.map +1 -1
- package/dist/browser/contexts/Schema/Context.cjs +28 -0
- package/dist/{node/contexts/Schema/Context.mjs.map → browser/contexts/Schema/Context.cjs.map} +1 -1
- package/dist/browser/contexts/Schema/Context.d.cts +4 -0
- package/dist/browser/contexts/Schema/Context.d.cts.map +1 -0
- package/dist/browser/contexts/Schema/Context.js +2 -1
- package/dist/browser/contexts/Schema/Context.js.map +1 -1
- package/dist/browser/contexts/Schema/Provider/Memory.cjs +94 -0
- package/dist/browser/contexts/Schema/Provider/Memory.cjs.map +1 -0
- package/dist/browser/contexts/Schema/Provider/Memory.d.cts +5 -0
- package/dist/browser/contexts/Schema/Provider/Memory.d.cts.map +1 -0
- package/dist/browser/contexts/Schema/Provider/Memory.js +59 -7
- package/dist/browser/contexts/Schema/Provider/Memory.js.map +1 -1
- package/dist/browser/contexts/Schema/Provider/Props.cjs +19 -0
- package/dist/browser/contexts/Schema/Provider/Props.cjs.map +1 -0
- package/dist/browser/contexts/Schema/Provider/Props.d.cts +5 -0
- package/dist/browser/contexts/Schema/Provider/Props.d.cts.map +1 -0
- package/dist/browser/contexts/Schema/Provider/Route.cjs +144 -0
- package/dist/browser/contexts/Schema/Provider/Route.cjs.map +1 -0
- package/dist/browser/contexts/Schema/Provider/Route.d.cts +5 -0
- package/dist/browser/contexts/Schema/Provider/Route.d.cts.map +1 -0
- package/dist/browser/contexts/Schema/Provider/Route.js +86 -10
- package/dist/browser/contexts/Schema/Provider/Route.js.map +1 -1
- package/dist/browser/contexts/Schema/Provider/index.cjs +147 -0
- package/dist/browser/contexts/Schema/Provider/index.cjs.map +1 -0
- package/dist/browser/contexts/Schema/Provider/index.d.cts +4 -0
- package/dist/browser/contexts/Schema/Provider/index.d.cts.map +1 -0
- package/dist/browser/contexts/Schema/Provider/index.js +123 -3
- package/dist/browser/contexts/Schema/Provider/index.js.map +1 -1
- package/dist/browser/contexts/Schema/State.cjs +19 -0
- package/dist/browser/contexts/Schema/State.cjs.map +1 -0
- package/dist/browser/contexts/Schema/State.d.cts +13 -0
- package/dist/browser/contexts/Schema/State.d.cts.map +1 -0
- package/dist/browser/contexts/Schema/index.cjs +149 -0
- package/dist/browser/contexts/Schema/index.cjs.map +1 -0
- package/dist/browser/contexts/Schema/index.d.cts +5 -0
- package/dist/browser/contexts/Schema/index.d.cts.map +1 -0
- package/dist/browser/contexts/Schema/index.js +125 -4
- package/dist/browser/contexts/Schema/index.js.map +1 -1
- package/dist/browser/contexts/Schema/use.cjs +36 -0
- package/dist/browser/contexts/Schema/use.cjs.map +1 -0
- package/dist/browser/contexts/Schema/use.d.cts +3 -0
- package/dist/browser/contexts/Schema/use.d.cts.map +1 -0
- package/dist/browser/contexts/Schema/use.js +8 -2
- package/dist/browser/contexts/Schema/use.js.map +1 -1
- package/dist/browser/contexts/index.cjs +149 -0
- package/dist/browser/contexts/index.cjs.map +1 -0
- package/dist/browser/contexts/index.d.cts +2 -0
- package/dist/browser/contexts/index.d.cts.map +1 -0
- package/dist/browser/contexts/index.js +125 -1
- package/dist/browser/contexts/index.js.map +1 -1
- package/dist/browser/hooks/index.cjs +189 -0
- package/dist/browser/hooks/index.cjs.map +1 -0
- package/dist/browser/hooks/index.d.cts +5 -0
- package/dist/browser/hooks/index.d.cts.map +1 -0
- package/dist/browser/hooks/index.js +165 -4
- package/dist/browser/hooks/index.js.map +1 -1
- package/dist/browser/hooks/useGetSchema.cjs +69 -0
- package/dist/{node/hooks/useGetSchema.mjs.map → browser/hooks/useGetSchema.cjs.map} +1 -1
- package/dist/browser/hooks/useGetSchema.d.cts +27 -0
- package/dist/browser/hooks/useGetSchema.d.cts.map +1 -0
- package/dist/browser/hooks/useGetSchema.js +2 -1
- package/dist/browser/hooks/useGetSchema.js.map +1 -1
- package/dist/browser/hooks/useSchemaDefinitions.cjs +47 -0
- package/dist/{node/hooks/useSchemaDefinitions.mjs.map → browser/hooks/useSchemaDefinitions.cjs.map} +1 -1
- package/dist/browser/hooks/useSchemaDefinitions.d.cts +6 -0
- package/dist/browser/hooks/useSchemaDefinitions.d.cts.map +1 -0
- package/dist/browser/hooks/useSchemaDefinitions.js +2 -1
- package/dist/browser/hooks/useSchemaDefinitions.js.map +1 -1
- package/dist/browser/hooks/useSchemaList.cjs +69 -0
- package/dist/browser/hooks/useSchemaList.cjs.map +1 -0
- package/dist/browser/hooks/useSchemaList.d.cts +3 -0
- package/dist/browser/hooks/useSchemaList.d.cts.map +1 -0
- package/dist/browser/hooks/useSchemaList.js +2 -1
- package/dist/browser/hooks/useSchemaList.js.map +1 -1
- package/dist/browser/hooks/useSchemaStats.cjs +71 -0
- package/dist/{node/hooks/useSchemaStats.mjs.map → browser/hooks/useSchemaStats.cjs.map} +1 -1
- package/dist/browser/hooks/useSchemaStats.d.cts +4 -0
- package/dist/browser/hooks/useSchemaStats.d.cts.map +1 -0
- package/dist/browser/hooks/useSchemaStats.js +2 -1
- package/dist/browser/hooks/useSchemaStats.js.map +1 -1
- package/dist/browser/index.cjs +354 -0
- package/dist/browser/index.cjs.map +1 -0
- package/dist/browser/index.d.cts +4 -0
- package/dist/browser/index.d.cts.map +1 -0
- package/dist/browser/index.js +330 -3
- package/dist/browser/index.js.map +1 -1
- package/dist/docs.json +2071 -0
- package/dist/node/components/Property/SchemaProperty.cjs +81 -0
- package/dist/node/components/Property/SchemaProperty.cjs.map +1 -0
- package/dist/node/components/Property/SchemaProperty.d.cts +40 -0
- package/dist/node/components/Property/SchemaProperty.d.cts.map +1 -0
- package/dist/node/components/Property/SchemaProperty.js +26 -48
- package/dist/node/components/Property/SchemaProperty.js.map +1 -1
- package/dist/node/components/Property/index.cjs +83 -0
- package/dist/node/components/Property/index.cjs.map +1 -0
- package/dist/node/components/Property/index.d.cts +2 -0
- package/dist/node/components/Property/index.d.cts.map +1 -0
- package/dist/node/components/Property/index.js +53 -20
- package/dist/node/components/Property/index.js.map +1 -1
- package/dist/node/components/SelectEx/SchemaSelectEx.cjs +72 -0
- package/dist/node/components/SelectEx/SchemaSelectEx.cjs.map +1 -0
- package/dist/node/components/SelectEx/SchemaSelectEx.d.cts +5 -0
- package/dist/node/components/SelectEx/SchemaSelectEx.d.cts.map +1 -0
- package/dist/node/components/SelectEx/SchemaSelectEx.js +27 -39
- package/dist/node/components/SelectEx/SchemaSelectEx.js.map +1 -1
- package/dist/node/components/SelectEx/index.cjs +74 -0
- package/dist/node/components/SelectEx/index.cjs.map +1 -0
- package/dist/node/components/SelectEx/index.d.cts +2 -0
- package/dist/node/components/SelectEx/index.d.cts.map +1 -0
- package/dist/node/components/SelectEx/index.js +45 -21
- package/dist/node/components/SelectEx/index.js.map +1 -1
- package/dist/node/components/index.cjs +129 -0
- package/dist/node/components/index.cjs.map +1 -0
- package/dist/node/components/index.d.cts +3 -0
- package/dist/node/components/index.d.cts.map +1 -0
- package/dist/node/components/index.js +98 -22
- package/dist/node/components/index.js.map +1 -1
- package/dist/node/contexts/Schema/Context.cjs +32 -0
- package/dist/node/contexts/Schema/Context.cjs.map +1 -0
- package/dist/node/contexts/Schema/Context.d.cts +4 -0
- package/dist/node/contexts/Schema/Context.d.cts.map +1 -0
- package/dist/node/contexts/Schema/Context.js +5 -28
- package/dist/node/contexts/Schema/Context.js.map +1 -1
- package/dist/node/contexts/Schema/Provider/Memory.cjs +98 -0
- package/dist/node/contexts/Schema/Provider/Memory.cjs.map +1 -0
- package/dist/node/contexts/Schema/Provider/Memory.d.cts +5 -0
- package/dist/node/contexts/Schema/Provider/Memory.d.cts.map +1 -0
- package/dist/node/contexts/Schema/Provider/Memory.js +65 -37
- package/dist/node/contexts/Schema/Provider/Memory.js.map +1 -1
- package/dist/node/contexts/Schema/Provider/Props.cjs +19 -0
- package/dist/node/contexts/Schema/Provider/Props.cjs.map +1 -0
- package/dist/node/contexts/Schema/Provider/Props.d.cts +5 -0
- package/dist/node/contexts/Schema/Provider/Props.d.cts.map +1 -0
- package/dist/node/contexts/Schema/Provider/Props.js +0 -16
- package/dist/node/contexts/Schema/Provider/Props.js.map +1 -1
- package/dist/node/contexts/Schema/Provider/Route.cjs +148 -0
- package/dist/node/contexts/Schema/Provider/Route.cjs.map +1 -0
- package/dist/node/contexts/Schema/Provider/Route.d.cts +5 -0
- package/dist/node/contexts/Schema/Provider/Route.d.cts.map +1 -0
- package/dist/node/contexts/Schema/Provider/Route.js +94 -42
- package/dist/node/contexts/Schema/Provider/Route.js.map +1 -1
- package/dist/node/contexts/Schema/Provider/index.cjs +152 -0
- package/dist/node/contexts/Schema/Provider/index.cjs.map +1 -0
- package/dist/node/contexts/Schema/Provider/index.d.cts +4 -0
- package/dist/node/contexts/Schema/Provider/index.d.cts.map +1 -0
- package/dist/node/contexts/Schema/Provider/index.js +122 -25
- package/dist/node/contexts/Schema/Provider/index.js.map +1 -1
- package/dist/node/contexts/Schema/State.cjs +19 -0
- package/dist/node/contexts/Schema/State.cjs.map +1 -0
- package/dist/node/contexts/Schema/State.d.cts +13 -0
- package/dist/node/contexts/Schema/State.d.cts.map +1 -0
- package/dist/node/contexts/Schema/State.js +0 -16
- package/dist/node/contexts/Schema/State.js.map +1 -1
- package/dist/node/contexts/Schema/index.cjs +156 -0
- package/dist/node/contexts/Schema/index.cjs.map +1 -0
- package/dist/node/contexts/Schema/index.d.cts +5 -0
- package/dist/node/contexts/Schema/index.d.cts.map +1 -0
- package/dist/node/contexts/Schema/index.js +124 -27
- package/dist/node/contexts/Schema/index.js.map +1 -1
- package/dist/node/contexts/Schema/use.cjs +40 -0
- package/dist/node/contexts/Schema/use.cjs.map +1 -0
- package/dist/node/contexts/Schema/use.d.cts +3 -0
- package/dist/node/contexts/Schema/use.d.cts.map +1 -0
- package/dist/node/contexts/Schema/use.js +12 -30
- package/dist/node/contexts/Schema/use.js.map +1 -1
- package/dist/node/contexts/index.cjs +156 -0
- package/dist/node/contexts/index.cjs.map +1 -0
- package/dist/node/contexts/index.d.cts +2 -0
- package/dist/node/contexts/index.d.cts.map +1 -0
- package/dist/node/contexts/index.js +124 -21
- package/dist/node/contexts/index.js.map +1 -1
- package/dist/node/hooks/index.cjs +199 -0
- package/dist/node/hooks/index.cjs.map +1 -0
- package/dist/node/hooks/index.d.cts +5 -0
- package/dist/node/hooks/index.d.cts.map +1 -0
- package/dist/node/hooks/index.js +167 -27
- package/dist/node/hooks/index.js.map +1 -1
- package/dist/node/hooks/useGetSchema.cjs +73 -0
- package/dist/node/hooks/useGetSchema.cjs.map +1 -0
- package/dist/node/hooks/useGetSchema.d.cts +27 -0
- package/dist/node/hooks/useGetSchema.d.cts.map +1 -0
- package/dist/node/hooks/useGetSchema.js +18 -41
- package/dist/node/hooks/useGetSchema.js.map +1 -1
- package/dist/node/hooks/useSchemaDefinitions.cjs +54 -0
- package/dist/node/hooks/useSchemaDefinitions.cjs.map +1 -0
- package/dist/node/hooks/useSchemaDefinitions.d.cts +6 -0
- package/dist/node/hooks/useSchemaDefinitions.d.cts.map +1 -0
- package/dist/node/hooks/useSchemaDefinitions.js +14 -34
- package/dist/node/hooks/useSchemaDefinitions.js.map +1 -1
- package/dist/node/hooks/useSchemaList.cjs +73 -0
- package/dist/node/hooks/{useSchemaList.mjs.map → useSchemaList.cjs.map} +1 -1
- package/dist/node/hooks/useSchemaList.d.cts +3 -0
- package/dist/node/hooks/useSchemaList.d.cts.map +1 -0
- package/dist/node/hooks/useSchemaList.js +16 -39
- package/dist/node/hooks/useSchemaList.js.map +1 -1
- package/dist/node/hooks/useSchemaStats.cjs +75 -0
- package/dist/node/hooks/useSchemaStats.cjs.map +1 -0
- package/dist/node/hooks/useSchemaStats.d.cts +4 -0
- package/dist/node/hooks/useSchemaStats.d.cts.map +1 -0
- package/dist/node/hooks/useSchemaStats.js +17 -40
- package/dist/node/hooks/useSchemaStats.js.map +1 -1
- package/dist/node/index.cjs +371 -0
- package/dist/node/index.cjs.map +1 -0
- package/dist/node/index.d.cts +4 -0
- package/dist/node/index.d.cts.map +1 -0
- package/dist/node/index.js +333 -25
- package/dist/node/index.js.map +1 -1
- package/package.json +36 -36
- package/dist/browser/components/Property/SchemaProperty.stories.js +0 -37
- package/dist/browser/components/Property/SchemaProperty.stories.js.map +0 -1
- package/dist/browser/hooks/stories/TestSchemaHooks.stories.js +0 -65
- package/dist/browser/hooks/stories/TestSchemaHooks.stories.js.map +0 -1
- package/dist/browser/hooks/useGetSchema.stories.js +0 -63
- package/dist/browser/hooks/useGetSchema.stories.js.map +0 -1
- package/dist/node/components/Property/SchemaProperty.mjs +0 -54
- package/dist/node/components/Property/SchemaProperty.stories.js +0 -64
- package/dist/node/components/Property/SchemaProperty.stories.js.map +0 -1
- package/dist/node/components/Property/SchemaProperty.stories.mjs +0 -37
- package/dist/node/components/Property/SchemaProperty.stories.mjs.map +0 -1
- package/dist/node/components/Property/index.mjs +0 -2
- package/dist/node/components/Property/index.mjs.map +0 -1
- package/dist/node/components/SelectEx/SchemaSelectEx.mjs +0 -35
- package/dist/node/components/SelectEx/SchemaSelectEx.mjs.map +0 -1
- package/dist/node/components/SelectEx/index.mjs +0 -2
- package/dist/node/components/SelectEx/index.mjs.map +0 -1
- package/dist/node/components/index.mjs +0 -3
- package/dist/node/components/index.mjs.map +0 -1
- package/dist/node/contexts/Schema/Context.mjs +0 -6
- package/dist/node/contexts/Schema/Provider/Memory.mjs +0 -21
- package/dist/node/contexts/Schema/Provider/Memory.mjs.map +0 -1
- package/dist/node/contexts/Schema/Provider/Props.mjs +0 -1
- package/dist/node/contexts/Schema/Provider/Props.mjs.map +0 -1
- package/dist/node/contexts/Schema/Provider/Route.mjs +0 -47
- package/dist/node/contexts/Schema/Provider/Route.mjs.map +0 -1
- package/dist/node/contexts/Schema/Provider/index.mjs +0 -4
- package/dist/node/contexts/Schema/Provider/index.mjs.map +0 -1
- package/dist/node/contexts/Schema/State.mjs +0 -1
- package/dist/node/contexts/Schema/State.mjs.map +0 -1
- package/dist/node/contexts/Schema/index.mjs +0 -5
- package/dist/node/contexts/Schema/index.mjs.map +0 -1
- package/dist/node/contexts/Schema/use.mjs +0 -9
- package/dist/node/contexts/Schema/use.mjs.map +0 -1
- package/dist/node/contexts/index.mjs +0 -2
- package/dist/node/contexts/index.mjs.map +0 -1
- package/dist/node/hooks/index.mjs +0 -5
- package/dist/node/hooks/index.mjs.map +0 -1
- package/dist/node/hooks/stories/TestSchemaHooks.stories.js +0 -89
- package/dist/node/hooks/stories/TestSchemaHooks.stories.js.map +0 -1
- package/dist/node/hooks/stories/TestSchemaHooks.stories.mjs +0 -65
- package/dist/node/hooks/stories/TestSchemaHooks.stories.mjs.map +0 -1
- package/dist/node/hooks/useGetSchema.mjs +0 -47
- package/dist/node/hooks/useGetSchema.stories.js +0 -98
- package/dist/node/hooks/useGetSchema.stories.js.map +0 -1
- package/dist/node/hooks/useGetSchema.stories.mjs +0 -63
- package/dist/node/hooks/useGetSchema.stories.mjs.map +0 -1
- package/dist/node/hooks/useSchemaDefinitions.mjs +0 -25
- package/dist/node/hooks/useSchemaList.mjs +0 -47
- package/dist/node/hooks/useSchemaStats.mjs +0 -49
- package/dist/node/index.mjs +0 -4
- package/dist/node/index.mjs.map +0 -1
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/hooks/useGetSchema.tsx
|
|
21
|
+
var useGetSchema_exports = {};
|
|
22
|
+
__export(useGetSchema_exports, {
|
|
23
|
+
useGetSchemaPayload: () => useGetSchemaPayload
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(useGetSchema_exports);
|
|
26
|
+
var import_react_async_effect = require("@xylabs/react-async-effect");
|
|
27
|
+
var import_payload_builder = require("@xyo-network/payload-builder");
|
|
28
|
+
var import_payload_model = require("@xyo-network/payload-model");
|
|
29
|
+
var import_schema_cache = require("@xyo-network/schema-cache");
|
|
30
|
+
var import_react = require("react");
|
|
31
|
+
var useGetSchemaPayload = (schema) => {
|
|
32
|
+
const [notFound, setNotFound] = (0, import_react.useState)(false);
|
|
33
|
+
const [xyoError, setError] = (0, import_react.useState)();
|
|
34
|
+
const [schemaCacheEntry, setSchemaCacheEntry] = (0, import_react.useState)();
|
|
35
|
+
const [schemaLocal, setSchemaLocal] = (0, import_react.useState)();
|
|
36
|
+
(0, import_react_async_effect.useAsyncEffect)(
|
|
37
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
38
|
+
async (mounted) => {
|
|
39
|
+
const firstRequest = !notFound && !schemaCacheEntry && !xyoError;
|
|
40
|
+
const schemaChanged = schema !== schemaLocal;
|
|
41
|
+
if (schema && firstRequest || schema && schemaChanged) {
|
|
42
|
+
try {
|
|
43
|
+
const schemaCacheEntry2 = await import_schema_cache.SchemaCache.instance.get(schema);
|
|
44
|
+
if (mounted()) {
|
|
45
|
+
setSchemaCacheEntry(schemaCacheEntry2);
|
|
46
|
+
setNotFound(schemaCacheEntry2 === null || schemaCacheEntry2 === void 0);
|
|
47
|
+
}
|
|
48
|
+
} catch (e) {
|
|
49
|
+
const error = e;
|
|
50
|
+
console.error(e);
|
|
51
|
+
if (mounted()) {
|
|
52
|
+
setError({ message: error.message, schema: import_payload_model.ModuleErrorSchema, sources: [] });
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (schemaChanged) {
|
|
57
|
+
setSchemaLocal(schema);
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
[xyoError, notFound, schema, schemaLocal, schemaCacheEntry]
|
|
61
|
+
);
|
|
62
|
+
return {
|
|
63
|
+
notFound,
|
|
64
|
+
schemaHuri: schemaCacheEntry?.huri,
|
|
65
|
+
schemaPayload: schemaCacheEntry ? new import_payload_builder.PayloadBuilder(schemaCacheEntry?.payload).fields(schemaCacheEntry.payload).build() : schemaCacheEntry,
|
|
66
|
+
xyoError
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=useGetSchema.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/useGetSchema.tsx"],"sourcesContent":["import { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport { ModuleError, ModuleErrorSchema } from '@xyo-network/payload-model'\nimport { SchemaCache, SchemaCacheEntry } from '@xyo-network/schema-cache'\nimport { 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 // eslint-disable-next-line react-hooks/exhaustive-deps\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: schemaCacheEntry\n ? new PayloadBuilder<SchemaPayload>(schemaCacheEntry?.payload).fields(schemaCacheEntry.payload).build()\n : schemaCacheEntry,\n xyoError,\n }\n}\n\nexport { useGetSchemaPayload }\n"],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/useGetSchema.tsx"],"sourcesContent":["import { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport { ModuleError, ModuleErrorSchema } from '@xyo-network/payload-model'\nimport { SchemaCache, SchemaCacheEntry } from '@xyo-network/schema-cache'\nimport { 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 // eslint-disable-next-line react-hooks/exhaustive-deps\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: schemaCacheEntry\n ? new PayloadBuilder<SchemaPayload>(schemaCacheEntry?.payload).fields(schemaCacheEntry.payload).build()\n : schemaCacheEntry,\n xyoError,\n }\n}\n\nexport { useGetSchemaPayload }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCAA+B;AAC/B,6BAA+B;AAC/B,2BAA+C;AAC/C,0BAA8C;AAE9C,mBAAyB;AAKzB,IAAM,sBAAsB,CAAC,WAAoB;AAC/C,QAAM,CAAC,UAAU,WAAW,QAAI,uBAAS,KAAK;AAC9C,QAAM,CAAC,UAAU,QAAQ,QAAI,uBAAsB;AACnD,QAAM,CAAC,kBAAkB,mBAAmB,QAAI,uBAA8C;AAC9F,QAAM,CAAC,aAAa,cAAc,QAAI,uBAAiB;AAEvD;AAAA;AAAA,IAEE,OAAO,YAAY;AACjB,YAAM,eAAe,CAAC,YAAY,CAAC,oBAAoB,CAAC;AACxD,YAAM,gBAAgB,WAAW;AAEjC,UAAK,UAAU,gBAAkB,UAAU,eAAgB;AACzD,YAAI;AACF,gBAAMA,oBAAmB,MAAM,gCAAY,SAAS,IAAI,MAAM;AAC9D,cAAI,QAAQ,GAAG;AACb,gCAAoBA,iBAAgB;AACpC,wBAAYA,sBAAqB,QAAQA,sBAAqB,MAAS;AAAA,UACzE;AAAA,QACF,SAAS,GAAG;AACV,gBAAM,QAAQ;AACd,kBAAQ,MAAM,CAAC;AACf,cAAI,QAAQ,GAAG;AACb,qBAAS,EAAE,SAAS,MAAM,SAAS,QAAQ,wCAAmB,SAAS,CAAC,EAAE,CAAC;AAAA,UAC7E;AAAA,QACF;AAAA,MACF;AACA,UAAI,eAAe;AACjB,uBAAe,MAAM;AAAA,MACvB;AAAA,IACF;AAAA,IACA,CAAC,UAAU,UAAU,QAAQ,aAAa,gBAAgB;AAAA,EAC5D;AAEA,SAAO;AAAA,IACL;AAAA,IACA,YAAY,kBAAkB;AAAA,IAC9B,eAAe,mBACX,IAAI,sCAA8B,kBAAkB,OAAO,EAAE,OAAO,iBAAiB,OAAO,EAAE,MAAM,IACpG;AAAA,IACJ;AAAA,EACF;AACF;","names":["schemaCacheEntry"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gets a Huri and schema payload from a schema string
|
|
3
|
+
*/
|
|
4
|
+
declare const useGetSchemaPayload: (schema?: string) => {
|
|
5
|
+
notFound: boolean;
|
|
6
|
+
schemaHuri: import("@xyo-network/huri").Huri<{
|
|
7
|
+
schema: string;
|
|
8
|
+
} & import("@xyo-network/payload-model").PayloadFields> | undefined;
|
|
9
|
+
schemaPayload: (import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & {
|
|
10
|
+
definition: {
|
|
11
|
+
[key: string]: unknown;
|
|
12
|
+
$id?: string | undefined;
|
|
13
|
+
};
|
|
14
|
+
extends?: string | undefined;
|
|
15
|
+
name?: string | undefined;
|
|
16
|
+
schema: "network.xyo.schema";
|
|
17
|
+
}) | null | undefined;
|
|
18
|
+
xyoError: (import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & {
|
|
19
|
+
message?: string | undefined;
|
|
20
|
+
name?: string | undefined;
|
|
21
|
+
query?: string | undefined;
|
|
22
|
+
schema: "network.xyo.error.module";
|
|
23
|
+
sources?: string[] | undefined;
|
|
24
|
+
}) | undefined;
|
|
25
|
+
};
|
|
26
|
+
export { useGetSchemaPayload };
|
|
27
|
+
//# sourceMappingURL=useGetSchema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGetSchema.d.ts","sourceRoot":"","sources":["../../../src/hooks/useGetSchema.tsx"],"names":[],"mappings":"AAOA;;GAEG;AACH,QAAA,MAAM,mBAAmB,YAAa,MAAM;;;;;;;;;;;;;;;;;;;;;CA0C3C,CAAA;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAA"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
// src/hooks/useGetSchema.tsx
|
|
1
2
|
import { useAsyncEffect } from "@xylabs/react-async-effect";
|
|
2
3
|
import { PayloadBuilder } from "@xyo-network/payload-builder";
|
|
3
4
|
import { ModuleErrorSchema } from "@xyo-network/payload-model";
|
|
4
5
|
import { SchemaCache } from "@xyo-network/schema-cache";
|
|
5
6
|
import { useState } from "react";
|
|
6
|
-
|
|
7
|
+
var useGetSchemaPayload = (schema) => {
|
|
7
8
|
const [notFound, setNotFound] = useState(false);
|
|
8
9
|
const [xyoError, setError] = useState();
|
|
9
10
|
const [schemaCacheEntry, setSchemaCacheEntry] = useState();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/useGetSchema.tsx"],"sourcesContent":["import { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport { ModuleError, ModuleErrorSchema } from '@xyo-network/payload-model'\nimport { SchemaCache, SchemaCacheEntry } from '@xyo-network/schema-cache'\nimport { 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 // eslint-disable-next-line react-hooks/exhaustive-deps\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: schemaCacheEntry\n ? new PayloadBuilder<SchemaPayload>(schemaCacheEntry?.payload).fields(schemaCacheEntry.payload).build()\n : schemaCacheEntry,\n xyoError,\n }\n}\n\nexport { useGetSchemaPayload }\n"],"mappings":"AAAA,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AAC/B,SAAsB,yBAAyB;AAC/C,SAAS,mBAAqC;AAE9C,SAAS,gBAAgB;AAKzB,
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/useGetSchema.tsx"],"sourcesContent":["import { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport { ModuleError, ModuleErrorSchema } from '@xyo-network/payload-model'\nimport { SchemaCache, SchemaCacheEntry } from '@xyo-network/schema-cache'\nimport { 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 // eslint-disable-next-line react-hooks/exhaustive-deps\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: schemaCacheEntry\n ? new PayloadBuilder<SchemaPayload>(schemaCacheEntry?.payload).fields(schemaCacheEntry.payload).build()\n : schemaCacheEntry,\n xyoError,\n }\n}\n\nexport { useGetSchemaPayload }\n"],"mappings":";AAAA,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AAC/B,SAAsB,yBAAyB;AAC/C,SAAS,mBAAqC;AAE9C,SAAS,gBAAgB;AAKzB,IAAM,sBAAsB,CAAC,WAAoB;AAC/C,QAAM,CAAC,UAAU,WAAW,IAAI,SAAS,KAAK;AAC9C,QAAM,CAAC,UAAU,QAAQ,IAAI,SAAsB;AACnD,QAAM,CAAC,kBAAkB,mBAAmB,IAAI,SAA8C;AAC9F,QAAM,CAAC,aAAa,cAAc,IAAI,SAAiB;AAEvD;AAAA;AAAA,IAEE,OAAO,YAAY;AACjB,YAAM,eAAe,CAAC,YAAY,CAAC,oBAAoB,CAAC;AACxD,YAAM,gBAAgB,WAAW;AAEjC,UAAK,UAAU,gBAAkB,UAAU,eAAgB;AACzD,YAAI;AACF,gBAAMA,oBAAmB,MAAM,YAAY,SAAS,IAAI,MAAM;AAC9D,cAAI,QAAQ,GAAG;AACb,gCAAoBA,iBAAgB;AACpC,wBAAYA,sBAAqB,QAAQA,sBAAqB,MAAS;AAAA,UACzE;AAAA,QACF,SAAS,GAAG;AACV,gBAAM,QAAQ;AACd,kBAAQ,MAAM,CAAC;AACf,cAAI,QAAQ,GAAG;AACb,qBAAS,EAAE,SAAS,MAAM,SAAS,QAAQ,mBAAmB,SAAS,CAAC,EAAE,CAAC;AAAA,UAC7E;AAAA,QACF;AAAA,MACF;AACA,UAAI,eAAe;AACjB,uBAAe,MAAM;AAAA,MACvB;AAAA,IACF;AAAA,IACA,CAAC,UAAU,UAAU,QAAQ,aAAa,gBAAgB;AAAA,EAC5D;AAEA,SAAO;AAAA,IACL;AAAA,IACA,YAAY,kBAAkB;AAAA,IAC9B,eAAe,mBACX,IAAI,eAA8B,kBAAkB,OAAO,EAAE,OAAO,iBAAiB,OAAO,EAAE,MAAM,IACpG;AAAA,IACJ;AAAA,EACF;AACF;","names":["schemaCacheEntry"]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/hooks/useSchemaDefinitions.tsx
|
|
21
|
+
var useSchemaDefinitions_exports = {};
|
|
22
|
+
__export(useSchemaDefinitions_exports, {
|
|
23
|
+
useSchemaDefinitions: () => useSchemaDefinitions
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(useSchemaDefinitions_exports);
|
|
26
|
+
var import_react_async_effect = require("@xylabs/react-async-effect");
|
|
27
|
+
var import_schema_cache = require("@xyo-network/schema-cache");
|
|
28
|
+
var import_react = require("react");
|
|
29
|
+
var useSchemaDefinitions = (schemaList) => {
|
|
30
|
+
const [schemaPayloads, setSchemaPayloads] = (0, import_react.useState)();
|
|
31
|
+
(0, import_react_async_effect.useAsyncEffect)(
|
|
32
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
33
|
+
async (mounted) => {
|
|
34
|
+
if (schemaList) {
|
|
35
|
+
const promiseResults = await Promise.allSettled(schemaList?.map(({ name }) => import_schema_cache.SchemaCache.instance.get(name)));
|
|
36
|
+
if (mounted()) {
|
|
37
|
+
setSchemaPayloads(
|
|
38
|
+
promiseResults.map((result) => result.status === "fulfilled" ? result.value?.payload : void 0).filter((item) => item !== void 0 && item !== null)
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
[schemaList]
|
|
44
|
+
);
|
|
45
|
+
return schemaPayloads;
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=useSchemaDefinitions.cjs.map
|
package/dist/{node/hooks/useSchemaDefinitions.mjs.map → browser/hooks/useSchemaDefinitions.cjs.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/useSchemaDefinitions.tsx"],"sourcesContent":["import { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { SchemaCache } from '@xyo-network/schema-cache'\nimport { 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 // eslint-disable-next-line react-hooks/exhaustive-deps\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"],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/useSchemaDefinitions.tsx"],"sourcesContent":["import { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { SchemaCache } from '@xyo-network/schema-cache'\nimport { 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 // eslint-disable-next-line react-hooks/exhaustive-deps\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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCAA+B;AAC/B,0BAA4B;AAE5B,mBAAyB;AAIlB,IAAM,uBAAuB,CAAC,eAA2D;AAC9F,QAAM,CAAC,gBAAgB,iBAAiB,QAAI,uBAA0B;AACtE;AAAA;AAAA,IAEE,OAAO,YAAY;AACjB,UAAI,YAAY;AACd,cAAM,iBAAiB,MAAM,QAAQ,WAAW,YAAY,IAAI,CAAC,EAAE,KAAK,MAAM,gCAAY,SAAS,IAAI,IAAI,CAAC,CAAC;AAC7G,YAAI,QAAQ,GAAG;AACb;AAAA,YACE,eACG,IAAI,CAAC,WAAY,OAAO,WAAW,cAAc,OAAO,OAAO,UAAU,MAAU,EACnF,OAAO,CAAC,SAAS,SAAS,UAAa,SAAS,IAAI;AAAA,UACzD;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IACA,CAAC,UAAU;AAAA,EACb;AACA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { 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,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAA;AAGlE,MAAM,MAAM,UAAU,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAA;AAEzC,eAAO,MAAM,oBAAoB,gBAAiB,UAAU,EAAE,KAAG,aAAa,EAAE,GAAG,SAmBlF,CAAA"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
// src/hooks/useSchemaDefinitions.tsx
|
|
1
2
|
import { useAsyncEffect } from "@xylabs/react-async-effect";
|
|
2
3
|
import { SchemaCache } from "@xyo-network/schema-cache";
|
|
3
4
|
import { useState } from "react";
|
|
4
|
-
|
|
5
|
+
var useSchemaDefinitions = (schemaList) => {
|
|
5
6
|
const [schemaPayloads, setSchemaPayloads] = useState();
|
|
6
7
|
useAsyncEffect(
|
|
7
8
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/useSchemaDefinitions.tsx"],"sourcesContent":["import { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { SchemaCache } from '@xyo-network/schema-cache'\nimport { 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 // eslint-disable-next-line react-hooks/exhaustive-deps\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"],"mappings":"AAAA,SAAS,sBAAsB;AAC/B,SAAS,mBAAmB;AAE5B,SAAS,gBAAgB;AAIlB,
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/useSchemaDefinitions.tsx"],"sourcesContent":["import { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { SchemaCache } from '@xyo-network/schema-cache'\nimport { 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 // eslint-disable-next-line react-hooks/exhaustive-deps\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"],"mappings":";AAAA,SAAS,sBAAsB;AAC/B,SAAS,mBAAmB;AAE5B,SAAS,gBAAgB;AAIlB,IAAM,uBAAuB,CAAC,eAA2D;AAC9F,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,SAA0B;AACtE;AAAA;AAAA,IAEE,OAAO,YAAY;AACjB,UAAI,YAAY;AACd,cAAM,iBAAiB,MAAM,QAAQ,WAAW,YAAY,IAAI,CAAC,EAAE,KAAK,MAAM,YAAY,SAAS,IAAI,IAAI,CAAC,CAAC;AAC7G,YAAI,QAAQ,GAAG;AACb;AAAA,YACE,eACG,IAAI,CAAC,WAAY,OAAO,WAAW,cAAc,OAAO,OAAO,UAAU,MAAU,EACnF,OAAO,CAAC,SAAS,SAAS,UAAa,SAAS,IAAI;AAAA,UACzD;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IACA,CAAC,UAAU;AAAA,EACb;AACA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/hooks/useSchemaList.tsx
|
|
21
|
+
var useSchemaList_exports = {};
|
|
22
|
+
__export(useSchemaList_exports, {
|
|
23
|
+
useSchemaList: () => useSchemaList
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(useSchemaList_exports);
|
|
26
|
+
var import_react_async_effect = require("@xylabs/react-async-effect");
|
|
27
|
+
var import_diviner_schema_list_model = require("@xyo-network/diviner-schema-list-model");
|
|
28
|
+
var import_react_diviner = require("@xyo-network/react-diviner");
|
|
29
|
+
var import_react = require("react");
|
|
30
|
+
var useSchemaList = (address, nameOrAddress = "SchemaListDiviner") => {
|
|
31
|
+
const [schemaList, setSchemaList] = (0, import_react.useState)();
|
|
32
|
+
const [error, setError] = (0, import_react.useState)();
|
|
33
|
+
const [diviner, divinerError] = (0, import_react_diviner.useDivinerFromNode)(nameOrAddress);
|
|
34
|
+
const query = (0, import_react.useMemo)(
|
|
35
|
+
() => address ? [
|
|
36
|
+
{
|
|
37
|
+
address,
|
|
38
|
+
schema: import_diviner_schema_list_model.SchemaListQuerySchema
|
|
39
|
+
}
|
|
40
|
+
] : void 0,
|
|
41
|
+
[address]
|
|
42
|
+
);
|
|
43
|
+
(0, import_react.useEffect)(() => {
|
|
44
|
+
if (diviner === null) {
|
|
45
|
+
setSchemaList(null);
|
|
46
|
+
setError(void 0);
|
|
47
|
+
}
|
|
48
|
+
}, [diviner]);
|
|
49
|
+
(0, import_react_async_effect.useAsyncEffect)(
|
|
50
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps, require-await
|
|
51
|
+
async (mounted) => {
|
|
52
|
+
if (diviner) {
|
|
53
|
+
try {
|
|
54
|
+
const response = await diviner.divine(query);
|
|
55
|
+
if (mounted()) {
|
|
56
|
+
setSchemaList(response?.[0]);
|
|
57
|
+
setError(void 0);
|
|
58
|
+
}
|
|
59
|
+
} catch (e) {
|
|
60
|
+
setError(e);
|
|
61
|
+
setSchemaList(void 0);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
[diviner, divinerError, query]
|
|
66
|
+
);
|
|
67
|
+
return [schemaList, error];
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=useSchemaList.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/useSchemaList.tsx"],"sourcesContent":["import { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { SchemaListPayload, SchemaListQueryPayload, SchemaListQuerySchema } from '@xyo-network/diviner-schema-list-model'\nimport { useDivinerFromNode } from '@xyo-network/react-diviner'\nimport { useEffect, useMemo, useState } from 'react'\n\nexport const useSchemaList = (address?: string, nameOrAddress = 'SchemaListDiviner'): [SchemaListPayload | null | undefined, Error | undefined] => {\n const [schemaList, setSchemaList] = useState<SchemaListPayload | null>()\n const [error, setError] = useState<Error>()\n const [diviner, divinerError] = useDivinerFromNode(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 // eslint-disable-next-line react-hooks/exhaustive-deps, require-await\n async (mounted) => {\n if (diviner) {\n try {\n const response = (await diviner.divine(query)) as 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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCAA+B;AAC/B,uCAAiF;AACjF,2BAAmC;AACnC,mBAA6C;AAEtC,IAAM,gBAAgB,CAAC,SAAkB,gBAAgB,wBAAmF;AACjJ,QAAM,CAAC,YAAY,aAAa,QAAI,uBAAmC;AACvE,QAAM,CAAC,OAAO,QAAQ,QAAI,uBAAgB;AAC1C,QAAM,CAAC,SAAS,YAAY,QAAI,yCAAmB,aAAa;AAEhE,QAAM,YAA8C;AAAA,IAClD,MACE,UACI;AAAA,MACE;AAAA,QACE;AAAA,QACA,QAAQ;AAAA,MACV;AAAA,IACF,IACA;AAAA,IACN,CAAC,OAAO;AAAA,EACV;AAEA,8BAAU,MAAM;AACd,QAAI,YAAY,MAAM;AACpB,oBAAc,IAAI;AAClB,eAAS,MAAS;AAAA,IACpB;AAAA,EACF,GAAG,CAAC,OAAO,CAAC;AAEZ;AAAA;AAAA,IAEE,OAAO,YAAY;AACjB,UAAI,SAAS;AACX,YAAI;AACF,gBAAM,WAAY,MAAM,QAAQ,OAAO,KAAK;AAC5C,cAAI,QAAQ,GAAG;AACb,0BAAc,WAAW,CAAC,CAAC;AAC3B,qBAAS,MAAS;AAAA,UACpB;AAAA,QACF,SAAS,GAAG;AACV,mBAAS,CAAU;AACnB,wBAAc,MAAS;AAAA,QACzB;AAAA,MACF;AAAA,IACF;AAAA,IACA,CAAC,SAAS,cAAc,KAAK;AAAA,EAC/B;AACA,SAAO,CAAC,YAAY,KAAK;AAC3B;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSchemaList.d.ts","sourceRoot":"","sources":["../../../src/hooks/useSchemaList.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAiD,MAAM,wCAAwC,CAAA;AAIzH,eAAO,MAAM,aAAa,aAAc,MAAM,6BAAwC,CAAC,iBAAiB,GAAG,IAAI,GAAG,SAAS,EAAE,KAAK,GAAG,SAAS,CA4C7I,CAAA"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
// src/hooks/useSchemaList.tsx
|
|
1
2
|
import { useAsyncEffect } from "@xylabs/react-async-effect";
|
|
2
3
|
import { SchemaListQuerySchema } from "@xyo-network/diviner-schema-list-model";
|
|
3
4
|
import { useDivinerFromNode } from "@xyo-network/react-diviner";
|
|
4
5
|
import { useEffect, useMemo, useState } from "react";
|
|
5
|
-
|
|
6
|
+
var useSchemaList = (address, nameOrAddress = "SchemaListDiviner") => {
|
|
6
7
|
const [schemaList, setSchemaList] = useState();
|
|
7
8
|
const [error, setError] = useState();
|
|
8
9
|
const [diviner, divinerError] = useDivinerFromNode(nameOrAddress);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/useSchemaList.tsx"],"sourcesContent":["import { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { SchemaListPayload, SchemaListQueryPayload, SchemaListQuerySchema } from '@xyo-network/diviner-schema-list-model'\nimport { useDivinerFromNode } from '@xyo-network/react-diviner'\nimport { useEffect, useMemo, useState } from 'react'\n\nexport const useSchemaList = (address?: string, nameOrAddress = 'SchemaListDiviner'): [SchemaListPayload | null | undefined, Error | undefined] => {\n const [schemaList, setSchemaList] = useState<SchemaListPayload | null>()\n const [error, setError] = useState<Error>()\n const [diviner, divinerError] = useDivinerFromNode(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 // eslint-disable-next-line react-hooks/exhaustive-deps, require-await\n async (mounted) => {\n if (diviner) {\n try {\n const response = (await diviner.divine(query)) as 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"],"mappings":"AAAA,SAAS,sBAAsB;AAC/B,SAAoD,6BAA6B;AACjF,SAAS,0BAA0B;AACnC,SAAS,WAAW,SAAS,gBAAgB;AAEtC,
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/useSchemaList.tsx"],"sourcesContent":["import { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { SchemaListPayload, SchemaListQueryPayload, SchemaListQuerySchema } from '@xyo-network/diviner-schema-list-model'\nimport { useDivinerFromNode } from '@xyo-network/react-diviner'\nimport { useEffect, useMemo, useState } from 'react'\n\nexport const useSchemaList = (address?: string, nameOrAddress = 'SchemaListDiviner'): [SchemaListPayload | null | undefined, Error | undefined] => {\n const [schemaList, setSchemaList] = useState<SchemaListPayload | null>()\n const [error, setError] = useState<Error>()\n const [diviner, divinerError] = useDivinerFromNode(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 // eslint-disable-next-line react-hooks/exhaustive-deps, require-await\n async (mounted) => {\n if (diviner) {\n try {\n const response = (await diviner.divine(query)) as 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"],"mappings":";AAAA,SAAS,sBAAsB;AAC/B,SAAoD,6BAA6B;AACjF,SAAS,0BAA0B;AACnC,SAAS,WAAW,SAAS,gBAAgB;AAEtC,IAAM,gBAAgB,CAAC,SAAkB,gBAAgB,wBAAmF;AACjJ,QAAM,CAAC,YAAY,aAAa,IAAI,SAAmC;AACvE,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAgB;AAC1C,QAAM,CAAC,SAAS,YAAY,IAAI,mBAAmB,aAAa;AAEhE,QAAM,QAA8C;AAAA,IAClD,MACE,UACI;AAAA,MACE;AAAA,QACE;AAAA,QACA,QAAQ;AAAA,MACV;AAAA,IACF,IACA;AAAA,IACN,CAAC,OAAO;AAAA,EACV;AAEA,YAAU,MAAM;AACd,QAAI,YAAY,MAAM;AACpB,oBAAc,IAAI;AAClB,eAAS,MAAS;AAAA,IACpB;AAAA,EACF,GAAG,CAAC,OAAO,CAAC;AAEZ;AAAA;AAAA,IAEE,OAAO,YAAY;AACjB,UAAI,SAAS;AACX,YAAI;AACF,gBAAM,WAAY,MAAM,QAAQ,OAAO,KAAK;AAC5C,cAAI,QAAQ,GAAG;AACb,0BAAc,WAAW,CAAC,CAAC;AAC3B,qBAAS,MAAS;AAAA,UACpB;AAAA,QACF,SAAS,GAAG;AACV,mBAAS,CAAU;AACnB,wBAAc,MAAS;AAAA,QACzB;AAAA,MACF;AAAA,IACF;AAAA,IACA,CAAC,SAAS,cAAc,KAAK;AAAA,EAC/B;AACA,SAAO,CAAC,YAAY,KAAK;AAC3B;","names":[]}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/hooks/useSchemaStats.tsx
|
|
21
|
+
var useSchemaStats_exports = {};
|
|
22
|
+
__export(useSchemaStats_exports, {
|
|
23
|
+
useSchemaStats: () => useSchemaStats
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(useSchemaStats_exports);
|
|
26
|
+
var import_react_async_effect = require("@xylabs/react-async-effect");
|
|
27
|
+
var import_diviner_schema_stats_model = require("@xyo-network/diviner-schema-stats-model");
|
|
28
|
+
var import_node_core_types = require("@xyo-network/node-core-types");
|
|
29
|
+
var import_react_diviner = require("@xyo-network/react-diviner");
|
|
30
|
+
var import_react = require("react");
|
|
31
|
+
var useSchemaStats = (statsAddress, nameOrAddress = import_node_core_types.TYPES.SchemaStatsDiviner.description) => {
|
|
32
|
+
const [refresh, setRefresh] = (0, import_react.useState)(1);
|
|
33
|
+
const [diviner, divinerError] = (0, import_react_diviner.useDivinerFromNode)(nameOrAddress);
|
|
34
|
+
const [error, setError] = (0, import_react.useState)();
|
|
35
|
+
const refreshHistory = () => setRefresh((previous) => previous + 1);
|
|
36
|
+
const [schemaList, setSchemaList] = (0, import_react.useState)();
|
|
37
|
+
const query = (0, import_react.useMemo)(
|
|
38
|
+
() => ({
|
|
39
|
+
address: statsAddress,
|
|
40
|
+
schema: import_diviner_schema_stats_model.SchemaStatsQuerySchema
|
|
41
|
+
}),
|
|
42
|
+
[statsAddress]
|
|
43
|
+
);
|
|
44
|
+
(0, import_react_async_effect.useAsyncEffect)(
|
|
45
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
46
|
+
async (mounted) => {
|
|
47
|
+
if (diviner) {
|
|
48
|
+
if (divinerError) {
|
|
49
|
+
if (mounted()) {
|
|
50
|
+
setError(divinerError);
|
|
51
|
+
setSchemaList(void 0);
|
|
52
|
+
}
|
|
53
|
+
} else {
|
|
54
|
+
try {
|
|
55
|
+
const schemas = (await diviner.divine([query])).filter(import_diviner_schema_stats_model.isSchemaStatsPayload);
|
|
56
|
+
if (mounted()) {
|
|
57
|
+
setSchemaList(schemas);
|
|
58
|
+
setError(void 0);
|
|
59
|
+
}
|
|
60
|
+
} catch (ex) {
|
|
61
|
+
setError(ex);
|
|
62
|
+
setSchemaList(void 0);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
[diviner, refresh, divinerError, query]
|
|
68
|
+
);
|
|
69
|
+
return [schemaList, error, refreshHistory];
|
|
70
|
+
};
|
|
71
|
+
//# sourceMappingURL=useSchemaStats.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/useSchemaStats.tsx"],"sourcesContent":["import { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { isSchemaStatsPayload, SchemaStatsPayload, SchemaStatsQueryPayload, SchemaStatsQuerySchema } from '@xyo-network/diviner-schema-stats-model'\nimport { TYPES } from '@xyo-network/node-core-types'\nimport { useDivinerFromNode } from '@xyo-network/react-diviner'\nimport { Dispatch, SetStateAction, useMemo, useState } from 'react'\n\nexport const useSchemaStats = (\n statsAddress?: string,\n nameOrAddress = TYPES.SchemaStatsDiviner.description,\n): [SchemaStatsPayload[] | undefined, Error | undefined, Dispatch<SetStateAction<number>>] => {\n const [refresh, setRefresh] = useState(1)\n const [diviner, divinerError] = useDivinerFromNode(nameOrAddress)\n const [error, setError] = useState<Error>()\n const refreshHistory = () => setRefresh((previous) => previous + 1)\n\n const [schemaList, setSchemaList] = useState<SchemaStatsPayload[]>()\n\n const query: SchemaStatsQueryPayload = useMemo(\n () => ({\n address: statsAddress,\n schema: SchemaStatsQuerySchema,\n }),\n [statsAddress],\n )\n\n useAsyncEffect(\n // eslint-disable-next-line react-hooks/exhaustive-deps\n async (mounted) => {\n if (diviner) {\n if (divinerError) {\n if (mounted()) {\n setError(divinerError)\n setSchemaList(undefined)\n }\n } else {\n try {\n const schemas = (await diviner.divine([query])).filter(isSchemaStatsPayload)\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"],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/useSchemaStats.tsx"],"sourcesContent":["import { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { isSchemaStatsPayload, SchemaStatsPayload, SchemaStatsQueryPayload, SchemaStatsQuerySchema } from '@xyo-network/diviner-schema-stats-model'\nimport { TYPES } from '@xyo-network/node-core-types'\nimport { useDivinerFromNode } from '@xyo-network/react-diviner'\nimport { Dispatch, SetStateAction, useMemo, useState } from 'react'\n\nexport const useSchemaStats = (\n statsAddress?: string,\n nameOrAddress = TYPES.SchemaStatsDiviner.description,\n): [SchemaStatsPayload[] | undefined, Error | undefined, Dispatch<SetStateAction<number>>] => {\n const [refresh, setRefresh] = useState(1)\n const [diviner, divinerError] = useDivinerFromNode(nameOrAddress)\n const [error, setError] = useState<Error>()\n const refreshHistory = () => setRefresh((previous) => previous + 1)\n\n const [schemaList, setSchemaList] = useState<SchemaStatsPayload[]>()\n\n const query: SchemaStatsQueryPayload = useMemo(\n () => ({\n address: statsAddress,\n schema: SchemaStatsQuerySchema,\n }),\n [statsAddress],\n )\n\n useAsyncEffect(\n // eslint-disable-next-line react-hooks/exhaustive-deps\n async (mounted) => {\n if (diviner) {\n if (divinerError) {\n if (mounted()) {\n setError(divinerError)\n setSchemaList(undefined)\n }\n } else {\n try {\n const schemas = (await diviner.divine([query])).filter(isSchemaStatsPayload)\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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCAA+B;AAC/B,wCAA0G;AAC1G,6BAAsB;AACtB,2BAAmC;AACnC,mBAA4D;AAErD,IAAM,iBAAiB,CAC5B,cACA,gBAAgB,6BAAM,mBAAmB,gBACmD;AAC5F,QAAM,CAAC,SAAS,UAAU,QAAI,uBAAS,CAAC;AACxC,QAAM,CAAC,SAAS,YAAY,QAAI,yCAAmB,aAAa;AAChE,QAAM,CAAC,OAAO,QAAQ,QAAI,uBAAgB;AAC1C,QAAM,iBAAiB,MAAM,WAAW,CAAC,aAAa,WAAW,CAAC;AAElE,QAAM,CAAC,YAAY,aAAa,QAAI,uBAA+B;AAEnE,QAAM,YAAiC;AAAA,IACrC,OAAO;AAAA,MACL,SAAS;AAAA,MACT,QAAQ;AAAA,IACV;AAAA,IACA,CAAC,YAAY;AAAA,EACf;AAEA;AAAA;AAAA,IAEE,OAAO,YAAY;AACjB,UAAI,SAAS;AACX,YAAI,cAAc;AAChB,cAAI,QAAQ,GAAG;AACb,qBAAS,YAAY;AACrB,0BAAc,MAAS;AAAA,UACzB;AAAA,QACF,OAAO;AACL,cAAI;AACF,kBAAM,WAAW,MAAM,QAAQ,OAAO,CAAC,KAAK,CAAC,GAAG,OAAO,sDAAoB;AAC3E,gBAAI,QAAQ,GAAG;AACb,4BAAc,OAAO;AACrB,uBAAS,MAAS;AAAA,YACpB;AAAA,UACF,SAAS,IAAI;AACX,qBAAS,EAAW;AACpB,0BAAc,MAAS;AAAA,UACzB;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IACA,CAAC,SAAS,SAAS,cAAc,KAAK;AAAA,EACxC;AAEA,SAAO,CAAC,YAAY,OAAO,cAAc;AAC3C;","names":[]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { SchemaStatsPayload } from '@xyo-network/diviner-schema-stats-model';
|
|
2
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
3
|
+
export declare const useSchemaStats: (statsAddress?: string, nameOrAddress?: string | undefined) => [SchemaStatsPayload[] | undefined, Error | undefined, Dispatch<SetStateAction<number>>];
|
|
4
|
+
//# sourceMappingURL=useSchemaStats.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSchemaStats.d.ts","sourceRoot":"","sources":["../../../src/hooks/useSchemaStats.tsx"],"names":[],"mappings":"AACA,OAAO,EAAwB,kBAAkB,EAAmD,MAAM,yCAAyC,CAAA;AAGnJ,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAqB,MAAM,OAAO,CAAA;AAEnE,eAAO,MAAM,cAAc,kBACV,MAAM,yCAEpB,CAAC,kBAAkB,EAAE,GAAG,SAAS,EAAE,KAAK,GAAG,SAAS,EAAE,SAAS,eAAe,MAAM,CAAC,CAAC,CA2CxF,CAAA"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
// src/hooks/useSchemaStats.tsx
|
|
1
2
|
import { useAsyncEffect } from "@xylabs/react-async-effect";
|
|
2
3
|
import { isSchemaStatsPayload, SchemaStatsQuerySchema } from "@xyo-network/diviner-schema-stats-model";
|
|
3
4
|
import { TYPES } from "@xyo-network/node-core-types";
|
|
4
5
|
import { useDivinerFromNode } from "@xyo-network/react-diviner";
|
|
5
6
|
import { useMemo, useState } from "react";
|
|
6
|
-
|
|
7
|
+
var useSchemaStats = (statsAddress, nameOrAddress = TYPES.SchemaStatsDiviner.description) => {
|
|
7
8
|
const [refresh, setRefresh] = useState(1);
|
|
8
9
|
const [diviner, divinerError] = useDivinerFromNode(nameOrAddress);
|
|
9
10
|
const [error, setError] = useState();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/useSchemaStats.tsx"],"sourcesContent":["import { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { isSchemaStatsPayload, SchemaStatsPayload, SchemaStatsQueryPayload, SchemaStatsQuerySchema } from '@xyo-network/diviner-schema-stats-model'\nimport { TYPES } from '@xyo-network/node-core-types'\nimport { useDivinerFromNode } from '@xyo-network/react-diviner'\nimport { Dispatch, SetStateAction, useMemo, useState } from 'react'\n\nexport const useSchemaStats = (\n statsAddress?: string,\n nameOrAddress = TYPES.SchemaStatsDiviner.description,\n): [SchemaStatsPayload[] | undefined, Error | undefined, Dispatch<SetStateAction<number>>] => {\n const [refresh, setRefresh] = useState(1)\n const [diviner, divinerError] = useDivinerFromNode(nameOrAddress)\n const [error, setError] = useState<Error>()\n const refreshHistory = () => setRefresh((previous) => previous + 1)\n\n const [schemaList, setSchemaList] = useState<SchemaStatsPayload[]>()\n\n const query: SchemaStatsQueryPayload = useMemo(\n () => ({\n address: statsAddress,\n schema: SchemaStatsQuerySchema,\n }),\n [statsAddress],\n )\n\n useAsyncEffect(\n // eslint-disable-next-line react-hooks/exhaustive-deps\n async (mounted) => {\n if (diviner) {\n if (divinerError) {\n if (mounted()) {\n setError(divinerError)\n setSchemaList(undefined)\n }\n } else {\n try {\n const schemas = (await diviner.divine([query])).filter(isSchemaStatsPayload)\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"],"mappings":"AAAA,SAAS,sBAAsB;AAC/B,SAAS,sBAAmE,8BAA8B;AAC1G,SAAS,aAAa;AACtB,SAAS,0BAA0B;AACnC,SAAmC,SAAS,gBAAgB;AAErD,
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/useSchemaStats.tsx"],"sourcesContent":["import { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { isSchemaStatsPayload, SchemaStatsPayload, SchemaStatsQueryPayload, SchemaStatsQuerySchema } from '@xyo-network/diviner-schema-stats-model'\nimport { TYPES } from '@xyo-network/node-core-types'\nimport { useDivinerFromNode } from '@xyo-network/react-diviner'\nimport { Dispatch, SetStateAction, useMemo, useState } from 'react'\n\nexport const useSchemaStats = (\n statsAddress?: string,\n nameOrAddress = TYPES.SchemaStatsDiviner.description,\n): [SchemaStatsPayload[] | undefined, Error | undefined, Dispatch<SetStateAction<number>>] => {\n const [refresh, setRefresh] = useState(1)\n const [diviner, divinerError] = useDivinerFromNode(nameOrAddress)\n const [error, setError] = useState<Error>()\n const refreshHistory = () => setRefresh((previous) => previous + 1)\n\n const [schemaList, setSchemaList] = useState<SchemaStatsPayload[]>()\n\n const query: SchemaStatsQueryPayload = useMemo(\n () => ({\n address: statsAddress,\n schema: SchemaStatsQuerySchema,\n }),\n [statsAddress],\n )\n\n useAsyncEffect(\n // eslint-disable-next-line react-hooks/exhaustive-deps\n async (mounted) => {\n if (diviner) {\n if (divinerError) {\n if (mounted()) {\n setError(divinerError)\n setSchemaList(undefined)\n }\n } else {\n try {\n const schemas = (await diviner.divine([query])).filter(isSchemaStatsPayload)\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"],"mappings":";AAAA,SAAS,sBAAsB;AAC/B,SAAS,sBAAmE,8BAA8B;AAC1G,SAAS,aAAa;AACtB,SAAS,0BAA0B;AACnC,SAAmC,SAAS,gBAAgB;AAErD,IAAM,iBAAiB,CAC5B,cACA,gBAAgB,MAAM,mBAAmB,gBACmD;AAC5F,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,CAAC;AACxC,QAAM,CAAC,SAAS,YAAY,IAAI,mBAAmB,aAAa;AAChE,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAgB;AAC1C,QAAM,iBAAiB,MAAM,WAAW,CAAC,aAAa,WAAW,CAAC;AAElE,QAAM,CAAC,YAAY,aAAa,IAAI,SAA+B;AAEnE,QAAM,QAAiC;AAAA,IACrC,OAAO;AAAA,MACL,SAAS;AAAA,MACT,QAAQ;AAAA,IACV;AAAA,IACA,CAAC,YAAY;AAAA,EACf;AAEA;AAAA;AAAA,IAEE,OAAO,YAAY;AACjB,UAAI,SAAS;AACX,YAAI,cAAc;AAChB,cAAI,QAAQ,GAAG;AACb,qBAAS,YAAY;AACrB,0BAAc,MAAS;AAAA,UACzB;AAAA,QACF,OAAO;AACL,cAAI;AACF,kBAAM,WAAW,MAAM,QAAQ,OAAO,CAAC,KAAK,CAAC,GAAG,OAAO,oBAAoB;AAC3E,gBAAI,QAAQ,GAAG;AACb,4BAAc,OAAO;AACrB,uBAAS,MAAS;AAAA,YACpB;AAAA,UACF,SAAS,IAAI;AACX,qBAAS,EAAW;AACpB,0BAAc,MAAS;AAAA,UACzB;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IACA,CAAC,SAAS,SAAS,cAAc,KAAK;AAAA,EACxC;AAEA,SAAO,CAAC,YAAY,OAAO,cAAc;AAC3C;","names":[]}
|