@xyo-network/react-schema 2.38.11 → 2.38.12

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.
Files changed (57) hide show
  1. package/dist/cjs/hooks/index.d.ts +2 -0
  2. package/dist/cjs/hooks/index.d.ts.map +1 -0
  3. package/dist/cjs/{diviners → hooks}/index.js +1 -1
  4. package/dist/cjs/hooks/index.js.map +1 -0
  5. package/dist/cjs/hooks/useGetSchema.d.ts +25 -0
  6. package/dist/cjs/hooks/useGetSchema.d.ts.map +1 -0
  7. package/dist/cjs/hooks/useGetSchema.js +53 -0
  8. package/dist/cjs/hooks/useGetSchema.js.map +1 -0
  9. package/dist/cjs/index.d.ts +1 -1
  10. package/dist/cjs/index.d.ts.map +1 -1
  11. package/dist/cjs/index.js +1 -1
  12. package/dist/cjs/index.js.map +1 -1
  13. package/dist/docs.json +321 -566
  14. package/dist/esm/hooks/index.d.ts +2 -0
  15. package/dist/esm/hooks/index.d.ts.map +1 -0
  16. package/dist/esm/hooks/index.js +2 -0
  17. package/dist/esm/hooks/index.js.map +1 -0
  18. package/dist/esm/hooks/useGetSchema.d.ts +25 -0
  19. package/dist/esm/hooks/useGetSchema.d.ts.map +1 -0
  20. package/dist/esm/hooks/useGetSchema.js +49 -0
  21. package/dist/esm/hooks/useGetSchema.js.map +1 -0
  22. package/dist/esm/index.d.ts +1 -1
  23. package/dist/esm/index.d.ts.map +1 -1
  24. package/dist/esm/index.js +1 -1
  25. package/dist/esm/index.js.map +1 -1
  26. package/package.json +5 -6
  27. package/src/hooks/index.ts +1 -0
  28. package/src/hooks/useGetSchema.stories.tsx +76 -0
  29. package/src/hooks/useGetSchema.tsx +55 -0
  30. package/src/index.ts +1 -1
  31. package/dist/cjs/diviners/SchemaListApiDiviner.d.ts +0 -20
  32. package/dist/cjs/diviners/SchemaListApiDiviner.d.ts.map +0 -1
  33. package/dist/cjs/diviners/SchemaListApiDiviner.js +0 -54
  34. package/dist/cjs/diviners/SchemaListApiDiviner.js.map +0 -1
  35. package/dist/cjs/diviners/SchemaListApiDivinerConfig.d.ts +0 -9
  36. package/dist/cjs/diviners/SchemaListApiDivinerConfig.d.ts.map +0 -1
  37. package/dist/cjs/diviners/SchemaListApiDivinerConfig.js +0 -5
  38. package/dist/cjs/diviners/SchemaListApiDivinerConfig.js.map +0 -1
  39. package/dist/cjs/diviners/index.d.ts +0 -2
  40. package/dist/cjs/diviners/index.d.ts.map +0 -1
  41. package/dist/cjs/diviners/index.js.map +0 -1
  42. package/dist/esm/diviners/SchemaListApiDiviner.d.ts +0 -20
  43. package/dist/esm/diviners/SchemaListApiDiviner.d.ts.map +0 -1
  44. package/dist/esm/diviners/SchemaListApiDiviner.js +0 -36
  45. package/dist/esm/diviners/SchemaListApiDiviner.js.map +0 -1
  46. package/dist/esm/diviners/SchemaListApiDivinerConfig.d.ts +0 -9
  47. package/dist/esm/diviners/SchemaListApiDivinerConfig.d.ts.map +0 -1
  48. package/dist/esm/diviners/SchemaListApiDivinerConfig.js +0 -2
  49. package/dist/esm/diviners/SchemaListApiDivinerConfig.js.map +0 -1
  50. package/dist/esm/diviners/index.d.ts +0 -2
  51. package/dist/esm/diviners/index.d.ts.map +0 -1
  52. package/dist/esm/diviners/index.js +0 -2
  53. package/dist/esm/diviners/index.js.map +0 -1
  54. package/src/diviners/SchemaListApiDiviner.spec.ts +0 -23
  55. package/src/diviners/SchemaListApiDiviner.ts +0 -51
  56. package/src/diviners/SchemaListApiDivinerConfig.ts +0 -13
  57. package/src/diviners/index.ts +0 -1
@@ -0,0 +1,2 @@
1
+ export * from './useGetSchema';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './useGetSchema';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA"}
@@ -0,0 +1,25 @@
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/payload").Huri<import("@xyo-network/payload").SchemaFields & import("@xyo-network/payload").PayloadFields & {
7
+ schema: string;
8
+ }> | undefined;
9
+ schemaPayload: (import("@xyo-network/payload").SchemaFields & import("@xyo-network/payload").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").SchemaFields & import("@xyo-network/payload").PayloadFields & {
19
+ message?: string | undefined;
20
+ schema: "network.xyo.error";
21
+ sources: string[];
22
+ }) | undefined;
23
+ };
24
+ export { useGetSchemaPayload };
25
+ //# 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"}
@@ -0,0 +1,49 @@
1
+ import { useAsyncEffect } from '@xylabs/react-shared';
2
+ import { XyoErrorSchema } from '@xyo-network/module';
3
+ import { XyoPayloadBuilder } from '@xyo-network/payload';
4
+ import { XyoSchemaCache } from '@xyo-network/utils';
5
+ import { useState } from 'react';
6
+ /**
7
+ * Gets a Huri and schema payload from a schema string
8
+ */
9
+ const useGetSchemaPayload = (schema) => {
10
+ const [notFound, setNotFound] = useState(false);
11
+ const [xyoError, setXyoError] = useState();
12
+ const [schemaCacheEntry, setSchemaCacheEntry] = useState();
13
+ const [schemaLocal, setSchemaLocal] = useState();
14
+ useAsyncEffect(
15
+ // eslint-disable-next-line react-hooks/exhaustive-deps
16
+ async (mounted) => {
17
+ const firstRequest = !notFound && !schemaCacheEntry && !xyoError;
18
+ const schemaChanged = schema !== schemaLocal;
19
+ if ((schema && firstRequest) || (schema && schemaChanged)) {
20
+ try {
21
+ const schemaCacheEntry = await XyoSchemaCache.instance.get(schema);
22
+ if (mounted()) {
23
+ setSchemaCacheEntry(schemaCacheEntry);
24
+ setNotFound(schemaCacheEntry === null || schemaCacheEntry === undefined);
25
+ }
26
+ }
27
+ catch (e) {
28
+ const error = e;
29
+ console.error(e);
30
+ if (mounted()) {
31
+ setXyoError({ message: error.message, schema: XyoErrorSchema, sources: [] });
32
+ }
33
+ }
34
+ }
35
+ if (schemaChanged) {
36
+ setSchemaLocal(schema);
37
+ }
38
+ }, [xyoError, notFound, schema, schemaLocal, schemaCacheEntry]);
39
+ return {
40
+ notFound,
41
+ schemaHuri: schemaCacheEntry?.huri,
42
+ schemaPayload: schemaCacheEntry
43
+ ? new XyoPayloadBuilder(schemaCacheEntry?.payload).fields(schemaCacheEntry.payload).build()
44
+ : schemaCacheEntry,
45
+ xyoError,
46
+ };
47
+ };
48
+ export { useGetSchemaPayload };
49
+ //# sourceMappingURL=useGetSchema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useGetSchema.js","sourceRoot":"","sources":["../../../src/hooks/useGetSchema.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAY,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAExD,OAAO,EAAE,cAAc,EAAuB,MAAM,oBAAoB,CAAA;AACxE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEhC;;GAEG;AACH,MAAM,mBAAmB,GAAG,CAAC,MAAe,EAAE,EAAE;IAC9C,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;IAC/C,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,EAAY,CAAA;IACpD,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,QAAQ,EAA0C,CAAA;IAClG,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,EAAU,CAAA;IAExD,cAAc;IACZ,uDAAuD;IACvD,KAAK,EAAE,OAAO,EAAE,EAAE;QAChB,MAAM,YAAY,GAAG,CAAC,QAAQ,IAAI,CAAC,gBAAgB,IAAI,CAAC,QAAQ,CAAA;QAChE,MAAM,aAAa,GAAG,MAAM,KAAK,WAAW,CAAA;QAE5C,IAAI,CAAC,MAAM,IAAI,YAAY,CAAC,IAAI,CAAC,MAAM,IAAI,aAAa,CAAC,EAAE;YACzD,IAAI;gBACF,MAAM,gBAAgB,GAAG,MAAM,cAAc,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;gBAClE,IAAI,OAAO,EAAE,EAAE;oBACb,mBAAmB,CAAC,gBAAgB,CAAC,CAAA;oBACrC,WAAW,CAAC,gBAAgB,KAAK,IAAI,IAAI,gBAAgB,KAAK,SAAS,CAAC,CAAA;iBACzE;aACF;YAAC,OAAO,CAAC,EAAE;gBACV,MAAM,KAAK,GAAG,CAAU,CAAA;gBACxB,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;gBAChB,IAAI,OAAO,EAAE,EAAE;oBACb,WAAW,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAA;iBAC7E;aACF;SACF;QACD,IAAI,aAAa,EAAE;YACjB,cAAc,CAAC,MAAM,CAAC,CAAA;SACvB;IACH,CAAC,EACD,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,gBAAgB,CAAC,CAC5D,CAAA;IAED,OAAO;QACL,QAAQ;QACR,UAAU,EAAE,gBAAgB,EAAE,IAAI;QAClC,aAAa,EAAE,gBAAgB;YAC7B,CAAC,CAAC,IAAI,iBAAiB,CAAmB,gBAAgB,EAAE,OAAO,CAAC,CAAC,MAAM,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE;YAC7G,CAAC,CAAC,gBAAgB;QACpB,QAAQ;KACT,CAAA;AACH,CAAC,CAAA;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAA"}
@@ -1,4 +1,4 @@
1
1
  export * from './components';
2
2
  export * from './contexts';
3
- export * from './diviners';
3
+ export * from './hooks';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA"}
package/dist/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  export * from './components';
2
2
  export * from './contexts';
3
- export * from './diviners';
3
+ export * from './hooks';
4
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA"}
package/package.json CHANGED
@@ -13,10 +13,10 @@
13
13
  "@xylabs/react-common": "^2.15.1",
14
14
  "@xylabs/react-link": "^2.15.1",
15
15
  "@xylabs/react-shared": "^2.15.1",
16
- "@xyo-network/react-archive": "^2.38.11",
17
- "@xyo-network/react-archivist-api": "^2.38.11",
18
- "@xyo-network/react-property": "^2.38.11",
19
- "@xyo-network/react-shared": "^2.38.11",
16
+ "@xyo-network/react-archive": "^2.38.12",
17
+ "@xyo-network/react-archivist-api": "^2.38.12",
18
+ "@xyo-network/react-property": "^2.38.12",
19
+ "@xyo-network/react-shared": "^2.38.12",
20
20
  "tslib": "^2.4.0"
21
21
  },
22
22
  "peerDependencies": {
@@ -24,7 +24,6 @@
24
24
  "@mui/material": "^5.10.3",
25
25
  "@mui/styles": "^5.10.3",
26
26
  "@xylabs/sdk-js": "^2.6.9",
27
- "@xyo-network/api": "*",
28
27
  "@xyo-network/diviner": "*",
29
28
  "@xyo-network/module": "*",
30
29
  "@xyo-network/payload": "*",
@@ -80,5 +79,5 @@
80
79
  },
81
80
  "sideEffects": false,
82
81
  "types": "dist/esm/index.d.ts",
83
- "version": "2.38.11"
82
+ "version": "2.38.12"
84
83
  }
@@ -0,0 +1 @@
1
+ export * from './useGetSchema'
@@ -0,0 +1,76 @@
1
+ import { FormControl, TextField, Typography } from '@mui/material'
2
+ import { ComponentStory, Meta } from '@storybook/react'
3
+ import { FlexCol, FlexRow } from '@xylabs/react-flexbox'
4
+ import { XyoSchemaCache } from '@xyo-network/utils'
5
+ import { lazy, Suspense, useEffect, useState } from 'react'
6
+
7
+ import { useGetSchemaPayload } from './useGetSchema'
8
+
9
+ const JsonView = lazy(() => import(/* webpackChunkName: "jsonView" */ 'react-json-view'))
10
+
11
+ XyoSchemaCache.instance.proxy = 'https://beta.api.archivist.xyo.network/domain'
12
+
13
+ const UseGetSchemaComponent: React.FC<{ schema: string }> = ({ schema }) => {
14
+ const exampleSchemas = ['network.xyo.domain', 'network.xyo.payload', 'network.xyo.schema']
15
+ const [schemaFieldValue, setSchemaFieldValue] = useState('')
16
+ const { schemaPayload } = useGetSchemaPayload(schemaFieldValue)
17
+
18
+ useEffect(() => {
19
+ if (schema) {
20
+ setSchemaFieldValue(schema)
21
+ }
22
+ }, [schema])
23
+
24
+ return (
25
+ <>
26
+ <Typography variant="body1" fontWeight="bold" mb={2}>
27
+ Example schemas to test:
28
+ {exampleSchemas.map((schema, index) => (
29
+ <Typography
30
+ component="span"
31
+ mx={1}
32
+ key={index}
33
+ onClick={() => setSchemaFieldValue(schema)}
34
+ sx={{ cursor: 'pointer', textDecoration: 'underline' }}
35
+ >
36
+ {schema}
37
+ </Typography>
38
+ ))}
39
+ </Typography>
40
+ <FormControl>
41
+ <TextField value={schemaFieldValue} label="Schema Name" onChange={(e) => setSchemaFieldValue(e.target.value)} />
42
+ </FormControl>
43
+ <FlexRow my={3} justifyContent="start">
44
+ <Suspense fallback={<FlexCol busy />}>
45
+ <JsonView src={schemaPayload || {}} />
46
+ </Suspense>
47
+ </FlexRow>
48
+ </>
49
+ )
50
+ }
51
+
52
+ const StorybookEntry: Meta = {
53
+ argTypes: {},
54
+ component: UseGetSchemaComponent,
55
+ parameters: {
56
+ docs: {
57
+ page: null,
58
+ },
59
+ },
60
+ title: 'payload/useGetSchema',
61
+ }
62
+
63
+ const Template: ComponentStory<typeof UseGetSchemaComponent> = ({ schema }) => {
64
+ return <UseGetSchemaComponent schema={schema} />
65
+ }
66
+
67
+ const Default = Template.bind({})
68
+ Default.args = { schema: 'network.xyo.schema' }
69
+
70
+ const Domain = Template.bind({})
71
+ Domain.args = { schema: 'network.xyo.domain' }
72
+
73
+ export { Default, Domain }
74
+
75
+ // eslint-disable-next-line import/no-default-export
76
+ export default StorybookEntry
@@ -0,0 +1,55 @@
1
+ import { useAsyncEffect } from '@xylabs/react-shared'
2
+ import { XyoError, XyoErrorSchema } from '@xyo-network/module'
3
+ import { XyoPayloadBuilder } from '@xyo-network/payload'
4
+ import { XyoSchemaPayload } from '@xyo-network/schema-payload-plugin'
5
+ import { XyoSchemaCache, XyoSchemaCacheEntry } from '@xyo-network/utils'
6
+ import { useState } from 'react'
7
+
8
+ /**
9
+ * Gets a Huri and schema payload from a schema string
10
+ */
11
+ const useGetSchemaPayload = (schema?: string) => {
12
+ const [notFound, setNotFound] = useState(false)
13
+ const [xyoError, setXyoError] = useState<XyoError>()
14
+ const [schemaCacheEntry, setSchemaCacheEntry] = useState<XyoSchemaCacheEntry | null | undefined>()
15
+ const [schemaLocal, setSchemaLocal] = useState<string>()
16
+
17
+ useAsyncEffect(
18
+ // eslint-disable-next-line react-hooks/exhaustive-deps
19
+ async (mounted) => {
20
+ const firstRequest = !notFound && !schemaCacheEntry && !xyoError
21
+ const schemaChanged = schema !== schemaLocal
22
+
23
+ if ((schema && firstRequest) || (schema && schemaChanged)) {
24
+ try {
25
+ const schemaCacheEntry = await XyoSchemaCache.instance.get(schema)
26
+ if (mounted()) {
27
+ setSchemaCacheEntry(schemaCacheEntry)
28
+ setNotFound(schemaCacheEntry === null || schemaCacheEntry === undefined)
29
+ }
30
+ } catch (e) {
31
+ const error = e as Error
32
+ console.error(e)
33
+ if (mounted()) {
34
+ setXyoError({ message: error.message, schema: XyoErrorSchema, sources: [] })
35
+ }
36
+ }
37
+ }
38
+ if (schemaChanged) {
39
+ setSchemaLocal(schema)
40
+ }
41
+ },
42
+ [xyoError, notFound, schema, schemaLocal, schemaCacheEntry],
43
+ )
44
+
45
+ return {
46
+ notFound,
47
+ schemaHuri: schemaCacheEntry?.huri,
48
+ schemaPayload: schemaCacheEntry
49
+ ? new XyoPayloadBuilder<XyoSchemaPayload>(schemaCacheEntry?.payload).fields(schemaCacheEntry.payload).build()
50
+ : schemaCacheEntry,
51
+ xyoError,
52
+ }
53
+ }
54
+
55
+ export { useGetSchemaPayload }
package/src/index.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export * from './components'
2
2
  export * from './contexts'
3
- export * from './diviners'
3
+ export * from './hooks'
@@ -1,20 +0,0 @@
1
- import { XyoArchivistApi } from '@xyo-network/api';
2
- import { XyoDiviner } from '@xyo-network/diviner';
3
- import { XyoModuleParams } from '@xyo-network/module';
4
- import { XyoPayload } from '@xyo-network/payload';
5
- import { XyoSchemaListApiDivinerConfig } from './SchemaListApiDivinerConfig';
6
- export declare type XyoSchemaListApiDivinerParams = XyoModuleParams<XyoSchemaListApiDivinerConfig> & {
7
- api: XyoArchivistApi;
8
- };
9
- export declare class SchemaListApiDiviner extends XyoDiviner<XyoSchemaListApiDivinerConfig> {
10
- protected readonly api: XyoArchivistApi;
11
- get archive(): string;
12
- static create(params: XyoSchemaListApiDivinerParams): Promise<SchemaListApiDiviner>;
13
- protected constructor(params: XyoSchemaListApiDivinerParams);
14
- queries(): string[];
15
- protected start(): Promise<this>;
16
- divine(): Promise<XyoPayload[]>;
17
- static configSchema: "network.xyo.diviner.schema.list.api.config";
18
- static targetSchema: "network.xyo.schema";
19
- }
20
- //# sourceMappingURL=SchemaListApiDiviner.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SchemaListApiDiviner.d.ts","sourceRoot":"","sources":["../../../src/diviners/SchemaListApiDiviner.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,UAAU,EAA+B,MAAM,sBAAsB,CAAA;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAGjD,OAAO,EAAE,6BAA6B,EAAuC,MAAM,8BAA8B,CAAA;AAEjH,oBAAY,6BAA6B,GAAG,eAAe,CAAC,6BAA6B,CAAC,GAAG;IAAE,GAAG,EAAE,eAAe,CAAA;CAAE,CAAA;AAErH,qBAAa,oBAAqB,SAAQ,UAAU,CAAC,6BAA6B,CAAC;IACjF,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,eAAe,CAAA;IAEvC,IAAI,OAAO,WAEV;WAEqB,MAAM,CAAC,MAAM,EAAE,6BAA6B,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAIlG,SAAS,aAAa,MAAM,EAAE,6BAA6B;IAKlD,OAAO;cAIS,KAAK;IAKjB,MAAM,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;IAY5C,OAAgB,YAAY,+CAAsC;IAClE,OAAgB,YAAY,uBAAkB;CAC/C"}
@@ -1,54 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SchemaListApiDiviner = void 0;
4
- const tslib_1 = require("tslib");
5
- const sdk_js_1 = require("@xylabs/sdk-js");
6
- const diviner_1 = require("@xyo-network/diviner");
7
- const schema_payload_plugin_1 = require("@xyo-network/schema-payload-plugin");
8
- const SchemaListApiDivinerConfig_1 = require("./SchemaListApiDivinerConfig");
9
- class SchemaListApiDiviner extends diviner_1.XyoDiviner {
10
- constructor(params) {
11
- super(params);
12
- this.api = params.api;
13
- }
14
- get archive() {
15
- var _a;
16
- return (0, sdk_js_1.assertEx)((_a = this.config) === null || _a === void 0 ? void 0 : _a.archive, `config required [${this.config}]`);
17
- }
18
- static create(params) {
19
- const _super = Object.create(null, {
20
- create: { get: () => super.create }
21
- });
22
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
23
- return (yield _super.create.call(this, params));
24
- });
25
- }
26
- queries() {
27
- return [diviner_1.XyoDivinerDivineQuerySchema, ...super.queries()];
28
- }
29
- start() {
30
- const _super = Object.create(null, {
31
- start: { get: () => super.start }
32
- });
33
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
34
- yield _super.start.call(this);
35
- return this;
36
- });
37
- }
38
- divine() {
39
- var _a, _b, _c;
40
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
41
- const apiResult = (_b = (yield ((_a = this.api.archive(this.archive)) === null || _a === void 0 ? void 0 : _a.payload.schema.get()))) !== null && _b !== void 0 ? _b : [];
42
- return ((_c = apiResult.map((schema) => {
43
- return {
44
- name: schema,
45
- schema: schema_payload_plugin_1.XyoSchemaSchema,
46
- };
47
- })) !== null && _c !== void 0 ? _c : []);
48
- });
49
- }
50
- }
51
- exports.SchemaListApiDiviner = SchemaListApiDiviner;
52
- SchemaListApiDiviner.configSchema = SchemaListApiDivinerConfig_1.XyoSchemaListApiDivinerConfigSchema;
53
- SchemaListApiDiviner.targetSchema = schema_payload_plugin_1.XyoSchemaSchema;
54
- //# sourceMappingURL=SchemaListApiDiviner.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SchemaListApiDiviner.js","sourceRoot":"","sources":["../../../src/diviners/SchemaListApiDiviner.ts"],"names":[],"mappings":";;;;AAAA,2CAAyC;AAEzC,kDAA8E;AAG9E,8EAAoE;AAEpE,6EAAiH;AAIjH,MAAa,oBAAqB,SAAQ,oBAAyC;IAWjF,YAAsB,MAAqC;QACzD,KAAK,CAAC,MAAM,CAAC,CAAA;QACb,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,CAAA;IACvB,CAAC;IAXD,IAAI,OAAO;;QACT,OAAO,IAAA,iBAAQ,EAAC,MAAA,IAAI,CAAC,MAAM,0CAAE,OAAO,EAAE,oBAAoB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAA;IAC3E,CAAC;IAED,MAAM,CAAgB,MAAM,CAAC,MAAqC;;;;;YAChE,OAAO,CAAC,MAAM,OAAM,MAAM,YAAC,MAAM,CAAC,CAAyB,CAAA;QAC7D,CAAC;KAAA;IAOQ,OAAO;QACd,OAAO,CAAC,qCAA2B,EAAE,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;IAC1D,CAAC;IAEwB,KAAK;;;;;YAC5B,MAAM,OAAM,KAAK,WAAE,CAAA;YACnB,OAAO,IAAI,CAAA;QACb,CAAC;KAAA;IAEY,MAAM;;;YACjB,MAAM,SAAS,GAAG,MAAA,CAAC,MAAM,CAAA,MAAA,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,0CAAE,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,CAAA,CAAC,mCAAI,EAAE,CAAA;YACpF,OAAO,CACL,MAAA,SAAS,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;gBACvB,OAAO;oBACL,IAAI,EAAE,MAAM;oBACZ,MAAM,EAAE,uCAAe;iBACxB,CAAA;YACH,CAAC,CAAC,mCAAI,EAAE,CACT,CAAA;;KACF;;AAnCH,oDAuCC;AAFiB,iCAAY,GAAG,gEAAmC,CAAA;AAClD,iCAAY,GAAG,uCAAe,CAAA"}
@@ -1,9 +0,0 @@
1
- import { XyoDivinerConfig } from '@xyo-network/diviner';
2
- import { XyoPayload } from '@xyo-network/payload';
3
- export declare type XyoSchemaListApiDivinerConfigSchema = 'network.xyo.diviner.schema.list.api.config';
4
- export declare const XyoSchemaListApiDivinerConfigSchema: XyoSchemaListApiDivinerConfigSchema;
5
- export declare type XyoSchemaListApiDivinerConfig<T extends XyoPayload = XyoPayload> = XyoDivinerConfig<XyoPayload, T & {
6
- schema: XyoSchemaListApiDivinerConfigSchema;
7
- archive: string;
8
- }>;
9
- //# sourceMappingURL=SchemaListApiDivinerConfig.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SchemaListApiDivinerConfig.d.ts","sourceRoot":"","sources":["../../../src/diviners/SchemaListApiDivinerConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAEjD,oBAAY,mCAAmC,GAAG,4CAA4C,CAAA;AAC9F,eAAO,MAAM,mCAAmC,EAAE,mCAAkF,CAAA;AAEpI,oBAAY,6BAA6B,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU,IAAI,gBAAgB,CAC7F,UAAU,EACV,CAAC,GAAG;IACF,MAAM,EAAE,mCAAmC,CAAA;IAC3C,OAAO,EAAE,MAAM,CAAA;CAChB,CACF,CAAA"}
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.XyoSchemaListApiDivinerConfigSchema = void 0;
4
- exports.XyoSchemaListApiDivinerConfigSchema = 'network.xyo.diviner.schema.list.api.config';
5
- //# sourceMappingURL=SchemaListApiDivinerConfig.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SchemaListApiDivinerConfig.js","sourceRoot":"","sources":["../../../src/diviners/SchemaListApiDivinerConfig.ts"],"names":[],"mappings":";;;AAIa,QAAA,mCAAmC,GAAwC,4CAA4C,CAAA"}
@@ -1,2 +0,0 @@
1
- export * from './SchemaListApiDiviner';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/diviners/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/diviners/index.ts"],"names":[],"mappings":";;;AAAA,iEAAsC"}
@@ -1,20 +0,0 @@
1
- import { XyoArchivistApi } from '@xyo-network/api';
2
- import { XyoDiviner } from '@xyo-network/diviner';
3
- import { XyoModuleParams } from '@xyo-network/module';
4
- import { XyoPayload } from '@xyo-network/payload';
5
- import { XyoSchemaListApiDivinerConfig } from './SchemaListApiDivinerConfig';
6
- export declare type XyoSchemaListApiDivinerParams = XyoModuleParams<XyoSchemaListApiDivinerConfig> & {
7
- api: XyoArchivistApi;
8
- };
9
- export declare class SchemaListApiDiviner extends XyoDiviner<XyoSchemaListApiDivinerConfig> {
10
- protected readonly api: XyoArchivistApi;
11
- get archive(): string;
12
- static create(params: XyoSchemaListApiDivinerParams): Promise<SchemaListApiDiviner>;
13
- protected constructor(params: XyoSchemaListApiDivinerParams);
14
- queries(): string[];
15
- protected start(): Promise<this>;
16
- divine(): Promise<XyoPayload[]>;
17
- static configSchema: "network.xyo.diviner.schema.list.api.config";
18
- static targetSchema: "network.xyo.schema";
19
- }
20
- //# sourceMappingURL=SchemaListApiDiviner.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SchemaListApiDiviner.d.ts","sourceRoot":"","sources":["../../../src/diviners/SchemaListApiDiviner.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,UAAU,EAA+B,MAAM,sBAAsB,CAAA;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAGjD,OAAO,EAAE,6BAA6B,EAAuC,MAAM,8BAA8B,CAAA;AAEjH,oBAAY,6BAA6B,GAAG,eAAe,CAAC,6BAA6B,CAAC,GAAG;IAAE,GAAG,EAAE,eAAe,CAAA;CAAE,CAAA;AAErH,qBAAa,oBAAqB,SAAQ,UAAU,CAAC,6BAA6B,CAAC;IACjF,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,eAAe,CAAA;IAEvC,IAAI,OAAO,WAEV;WAEqB,MAAM,CAAC,MAAM,EAAE,6BAA6B,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAIlG,SAAS,aAAa,MAAM,EAAE,6BAA6B;IAKlD,OAAO;cAIS,KAAK;IAKjB,MAAM,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;IAY5C,OAAgB,YAAY,+CAAsC;IAClE,OAAgB,YAAY,uBAAkB;CAC/C"}
@@ -1,36 +0,0 @@
1
- import { assertEx } from '@xylabs/sdk-js';
2
- import { XyoDiviner, XyoDivinerDivineQuerySchema } from '@xyo-network/diviner';
3
- import { XyoSchemaSchema } from '@xyo-network/schema-payload-plugin';
4
- import { XyoSchemaListApiDivinerConfigSchema } from './SchemaListApiDivinerConfig';
5
- export class SchemaListApiDiviner extends XyoDiviner {
6
- api;
7
- get archive() {
8
- return assertEx(this.config?.archive, `config required [${this.config}]`);
9
- }
10
- static async create(params) {
11
- return (await super.create(params));
12
- }
13
- constructor(params) {
14
- super(params);
15
- this.api = params.api;
16
- }
17
- queries() {
18
- return [XyoDivinerDivineQuerySchema, ...super.queries()];
19
- }
20
- async start() {
21
- await super.start();
22
- return this;
23
- }
24
- async divine() {
25
- const apiResult = (await this.api.archive(this.archive)?.payload.schema.get()) ?? [];
26
- return (apiResult.map((schema) => {
27
- return {
28
- name: schema,
29
- schema: XyoSchemaSchema,
30
- };
31
- }) ?? []);
32
- }
33
- static configSchema = XyoSchemaListApiDivinerConfigSchema;
34
- static targetSchema = XyoSchemaSchema;
35
- }
36
- //# sourceMappingURL=SchemaListApiDiviner.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SchemaListApiDiviner.js","sourceRoot":"","sources":["../../../src/diviners/SchemaListApiDiviner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEzC,OAAO,EAAE,UAAU,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAA;AAG9E,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAA;AAEpE,OAAO,EAAiC,mCAAmC,EAAE,MAAM,8BAA8B,CAAA;AAIjH,MAAM,OAAO,oBAAqB,SAAQ,UAAyC;IAC9D,GAAG,CAAiB;IAEvC,IAAI,OAAO;QACT,OAAO,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,oBAAoB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAA;IAC3E,CAAC;IAED,MAAM,CAAU,KAAK,CAAC,MAAM,CAAC,MAAqC;QAChE,OAAO,CAAC,MAAM,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAyB,CAAA;IAC7D,CAAC;IAED,YAAsB,MAAqC;QACzD,KAAK,CAAC,MAAM,CAAC,CAAA;QACb,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,CAAA;IACvB,CAAC;IAEQ,OAAO;QACd,OAAO,CAAC,2BAA2B,EAAE,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;IAC1D,CAAC;IAEkB,KAAK,CAAC,KAAK;QAC5B,MAAM,KAAK,CAAC,KAAK,EAAE,CAAA;QACnB,OAAO,IAAI,CAAA;IACb,CAAC;IAEM,KAAK,CAAC,MAAM;QACjB,MAAM,SAAS,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,CAAA;QACpF,OAAO,CACL,SAAS,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;YACvB,OAAO;gBACL,IAAI,EAAE,MAAM;gBACZ,MAAM,EAAE,eAAe;aACxB,CAAA;QACH,CAAC,CAAC,IAAI,EAAE,CACT,CAAA;IACH,CAAC;IAED,MAAM,CAAU,YAAY,GAAG,mCAAmC,CAAA;IAClE,MAAM,CAAU,YAAY,GAAG,eAAe,CAAA"}
@@ -1,9 +0,0 @@
1
- import { XyoDivinerConfig } from '@xyo-network/diviner';
2
- import { XyoPayload } from '@xyo-network/payload';
3
- export declare type XyoSchemaListApiDivinerConfigSchema = 'network.xyo.diviner.schema.list.api.config';
4
- export declare const XyoSchemaListApiDivinerConfigSchema: XyoSchemaListApiDivinerConfigSchema;
5
- export declare type XyoSchemaListApiDivinerConfig<T extends XyoPayload = XyoPayload> = XyoDivinerConfig<XyoPayload, T & {
6
- schema: XyoSchemaListApiDivinerConfigSchema;
7
- archive: string;
8
- }>;
9
- //# sourceMappingURL=SchemaListApiDivinerConfig.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SchemaListApiDivinerConfig.d.ts","sourceRoot":"","sources":["../../../src/diviners/SchemaListApiDivinerConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAEjD,oBAAY,mCAAmC,GAAG,4CAA4C,CAAA;AAC9F,eAAO,MAAM,mCAAmC,EAAE,mCAAkF,CAAA;AAEpI,oBAAY,6BAA6B,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU,IAAI,gBAAgB,CAC7F,UAAU,EACV,CAAC,GAAG;IACF,MAAM,EAAE,mCAAmC,CAAA;IAC3C,OAAO,EAAE,MAAM,CAAA;CAChB,CACF,CAAA"}
@@ -1,2 +0,0 @@
1
- export const XyoSchemaListApiDivinerConfigSchema = 'network.xyo.diviner.schema.list.api.config';
2
- //# sourceMappingURL=SchemaListApiDivinerConfig.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SchemaListApiDivinerConfig.js","sourceRoot":"","sources":["../../../src/diviners/SchemaListApiDivinerConfig.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,mCAAmC,GAAwC,4CAA4C,CAAA"}
@@ -1,2 +0,0 @@
1
- export * from './SchemaListApiDiviner';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/diviners/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAA"}
@@ -1,2 +0,0 @@
1
- export * from './SchemaListApiDiviner';
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/diviners/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAA"}
@@ -1,23 +0,0 @@
1
- import { XyoApiConfig, XyoArchivistApi } from '@xyo-network/api'
2
-
3
- import { SchemaListApiDiviner } from './SchemaListApiDiviner'
4
- import { XyoSchemaListApiDivinerConfigSchema } from './SchemaListApiDivinerConfig'
5
-
6
- const configData: XyoApiConfig = {
7
- apiDomain: process.env.API_DOMAIN || 'https://beta.api.archivist.xyo.network',
8
- }
9
-
10
- test('SchemaListApiDiviner', async () => {
11
- const api = new XyoArchivistApi(configData)
12
- const diviner = await SchemaListApiDiviner.create({
13
- api,
14
- config: { archive: 'temp', schema: XyoSchemaListApiDivinerConfigSchema },
15
- logger: console,
16
- })
17
-
18
- expect(diviner).toBeDefined()
19
-
20
- const result = await diviner.divine()
21
-
22
- expect(result.length).toBeGreaterThan(0)
23
- })
@@ -1,51 +0,0 @@
1
- import { assertEx } from '@xylabs/sdk-js'
2
- import { XyoArchivistApi } from '@xyo-network/api'
3
- import { XyoDiviner, XyoDivinerDivineQuerySchema } from '@xyo-network/diviner'
4
- import { XyoModuleParams } from '@xyo-network/module'
5
- import { XyoPayload } from '@xyo-network/payload'
6
- import { XyoSchemaSchema } from '@xyo-network/schema-payload-plugin'
7
-
8
- import { XyoSchemaListApiDivinerConfig, XyoSchemaListApiDivinerConfigSchema } from './SchemaListApiDivinerConfig'
9
-
10
- export type XyoSchemaListApiDivinerParams = XyoModuleParams<XyoSchemaListApiDivinerConfig> & { api: XyoArchivistApi }
11
-
12
- export class SchemaListApiDiviner extends XyoDiviner<XyoSchemaListApiDivinerConfig> {
13
- protected readonly api: XyoArchivistApi
14
-
15
- get archive() {
16
- return assertEx(this.config?.archive, `config required [${this.config}]`)
17
- }
18
-
19
- static override async create(params: XyoSchemaListApiDivinerParams): Promise<SchemaListApiDiviner> {
20
- return (await super.create(params)) as SchemaListApiDiviner
21
- }
22
-
23
- protected constructor(params: XyoSchemaListApiDivinerParams) {
24
- super(params)
25
- this.api = params.api
26
- }
27
-
28
- override queries() {
29
- return [XyoDivinerDivineQuerySchema, ...super.queries()]
30
- }
31
-
32
- protected override async start() {
33
- await super.start()
34
- return this
35
- }
36
-
37
- public async divine(): Promise<XyoPayload[]> {
38
- const apiResult = (await this.api.archive(this.archive)?.payload.schema.get()) ?? []
39
- return (
40
- apiResult.map((schema) => {
41
- return {
42
- name: schema,
43
- schema: XyoSchemaSchema,
44
- }
45
- }) ?? []
46
- )
47
- }
48
-
49
- static override configSchema = XyoSchemaListApiDivinerConfigSchema
50
- static override targetSchema = XyoSchemaSchema
51
- }
@@ -1,13 +0,0 @@
1
- import { XyoDivinerConfig } from '@xyo-network/diviner'
2
- import { XyoPayload } from '@xyo-network/payload'
3
-
4
- export type XyoSchemaListApiDivinerConfigSchema = 'network.xyo.diviner.schema.list.api.config'
5
- export const XyoSchemaListApiDivinerConfigSchema: XyoSchemaListApiDivinerConfigSchema = 'network.xyo.diviner.schema.list.api.config'
6
-
7
- export type XyoSchemaListApiDivinerConfig<T extends XyoPayload = XyoPayload> = XyoDivinerConfig<
8
- XyoPayload,
9
- T & {
10
- schema: XyoSchemaListApiDivinerConfigSchema
11
- archive: string
12
- }
13
- >
@@ -1 +0,0 @@
1
- export * from './SchemaListApiDiviner'