@xyo-network/schema-cache 5.1.22 → 5.1.23

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/schema-cache",
3
- "version": "5.1.22",
3
+ "version": "5.1.23",
4
4
  "description": "Primary SDK for using XYO Protocol 2.0",
5
5
  "homepage": "https://xyo.network",
6
6
  "bugs": {
@@ -30,29 +30,32 @@
30
30
  "types": "dist/neutral/index.d.ts",
31
31
  "files": [
32
32
  "dist",
33
- "src"
33
+ "src",
34
+ "!**/*.bench.*",
35
+ "!**/*.spec.*",
36
+ "!**/*.test.*"
34
37
  ],
35
38
  "dependencies": {
36
- "@xylabs/delay": "~5.0.24",
37
- "@xylabs/error": "~5.0.24",
38
- "@xylabs/typeof": "~5.0.24",
39
- "@xyo-network/domain-payload-plugin": "~5.1.22",
40
- "@xyo-network/huri": "~5.1.22",
41
- "@xyo-network/payload-model": "~5.1.22",
42
- "@xyo-network/schema-payload-plugin": "~5.1.22",
39
+ "@xylabs/delay": "~5.0.33",
40
+ "@xylabs/error": "~5.0.33",
41
+ "@xylabs/typeof": "~5.0.33",
42
+ "@xyo-network/domain-payload-plugin": "~5.1.23",
43
+ "@xyo-network/huri": "~5.1.23",
44
+ "@xyo-network/payload-model": "~5.1.23",
45
+ "@xyo-network/schema-payload-plugin": "~5.1.23",
43
46
  "ajv": "~8.17.1",
44
47
  "axios": "~1.13.2",
45
48
  "lru-cache": "~11.2.2"
46
49
  },
47
50
  "devDependencies": {
48
- "@xylabs/assert": "~5.0.24",
51
+ "@xylabs/assert": "~5.0.33",
49
52
  "@xylabs/ts-scripts-yarn3": "~7.2.8",
50
53
  "@xylabs/tsconfig-dom": "~7.2.8",
51
- "@xylabs/vitest-extended": "~5.0.24",
52
- "@xyo-network/network": "~5.1.22",
53
- "@xyo-network/payload-builder": "~5.1.22",
54
+ "@xylabs/vitest-extended": "~5.0.33",
55
+ "@xyo-network/network": "~5.1.23",
56
+ "@xyo-network/payload-builder": "~5.1.23",
54
57
  "typescript": "~5.9.3",
55
- "vitest": "~4.0.8"
58
+ "vitest": "~4.0.9"
56
59
  },
57
60
  "publishConfig": {
58
61
  "access": "public"
@@ -1,2 +0,0 @@
1
- import '@xylabs/vitest-extended';
2
- //# sourceMappingURL=SchemaCache.Proxy.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SchemaCache.Proxy.spec.d.ts","sourceRoot":"","sources":["../../../src/spec/SchemaCache.Proxy.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
@@ -1,2 +0,0 @@
1
- import '@xylabs/vitest-extended';
2
- //# sourceMappingURL=SchemaCache.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SchemaCache.spec.d.ts","sourceRoot":"","sources":["../../../src/spec/SchemaCache.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
@@ -1,96 +0,0 @@
1
- import '@xylabs/vitest-extended'
2
-
3
- import { assertEx } from '@xylabs/assert'
4
- import type { DomainPayload } from '@xyo-network/domain-payload-plugin'
5
- import { DomainSchema } from '@xyo-network/domain-payload-plugin'
6
- import { NetworkNodeSchema, NetworkSchema } from '@xyo-network/network'
7
- import { PayloadBuilder } from '@xyo-network/payload-builder'
8
- import type { Payload } from '@xyo-network/payload-model'
9
- import { PayloadSchema } from '@xyo-network/payload-model'
10
- import { SchemaSchema } from '@xyo-network/schema-payload-plugin'
11
- import {
12
- beforeEach,
13
- describe, expect, test,
14
- } from 'vitest'
15
-
16
- import { SchemaCache } from '../SchemaCache.ts'
17
-
18
- const proxy = 'https://beta.api.archivist.xyo.network/domain'
19
-
20
- const exampleDomainConfig: DomainPayload = {
21
- aliases: { [SchemaSchema]: { huri: '548476cc8388e97c7a724c77ffc89b8b858b66ee009750797405d264c570b260' } },
22
- networks: [
23
- {
24
- name: 'Main',
25
- nodes: [
26
- {
27
- name: 'XYO Archivist',
28
- schema: NetworkNodeSchema,
29
- slug: 'xyo',
30
- type: 'archivist',
31
- uri: 'https://api.archivist.xyo.network',
32
- web: 'https://archivist.xyo.network',
33
- },
34
- ],
35
- schema: NetworkSchema,
36
- slug: 'main',
37
- },
38
- ],
39
- schema: DomainSchema,
40
- }
41
-
42
- describe('SchemaCache', () => {
43
- beforeEach(() => {
44
- SchemaCache.instance.proxy = proxy
45
- })
46
-
47
- test('Valid', async () => {
48
- const cache = SchemaCache.instance
49
- const fetchedPayload = await cache.get(SchemaSchema)
50
- expect(fetchedPayload?.payload.schema).toBe(SchemaSchema)
51
- })
52
-
53
- describe('validator', () => {
54
- describe('provides strongly typed validator for known schema type', () => {
55
- test('Payload', async () => {
56
- const schema = PayloadSchema
57
- const cache = SchemaCache.instance
58
- const fetchedPayload = await cache.get(schema)
59
- expect(fetchedPayload).toBeTruthy()
60
- const payloads: Payload[] = [
61
- new PayloadBuilder({ schema }).fields({ a: 'a' }).build(),
62
- new PayloadBuilder({ schema }).fields({ b: 'b' }).build(),
63
- new PayloadBuilder({ schema }).fields({ c: 'c' }).build(),
64
- ]
65
- const validator = assertEx(cache.validators[schema])
66
- // Strongly typing variable to ensure TypeScript inferred type from validator matches
67
- const valid: Payload[] = payloads.filter(validator)
68
- expect(valid.length).toBe(payloads.length)
69
- })
70
- test('DomainConfig', async () => {
71
- const schema = DomainSchema
72
- const cache = SchemaCache.instance
73
- const fetchedPayload = await cache.get(schema)
74
- expect(fetchedPayload).toBeTruthy()
75
- const payloads = [new PayloadBuilder<DomainPayload>({ schema }).fields(exampleDomainConfig).build()]
76
- const validator = assertEx(cache.validators[schema])
77
- // Strongly typing variable to ensure TypeScript inferred type from validator matches
78
- const valid: DomainPayload[] = payloads.filter(validator)
79
- expect(valid.length).toBe(payloads.length)
80
- })
81
- })
82
- })
83
-
84
- test('Not In Cache', async () => {
85
- const cache = SchemaCache.instance
86
- const fetchedPayload = await cache.get('foo.domain.com')
87
- expect(fetchedPayload).toBeNull()
88
- })
89
-
90
- test('Set Proxy', () => {
91
- const cache = SchemaCache.instance
92
- const testProxy = 'https://foo.com'
93
- cache.proxy = testProxy
94
- expect(cache?.proxy).toBe(testProxy)
95
- })
96
- })
@@ -1,82 +0,0 @@
1
- import '@xylabs/vitest-extended'
2
-
3
- import { assertEx } from '@xylabs/assert'
4
- import type { DomainPayload } from '@xyo-network/domain-payload-plugin'
5
- import { DomainSchema } from '@xyo-network/domain-payload-plugin'
6
- import { NetworkNodeSchema, NetworkSchema } from '@xyo-network/network'
7
- import { PayloadBuilder } from '@xyo-network/payload-builder'
8
- import type { Payload } from '@xyo-network/payload-model'
9
- import { PayloadSchema } from '@xyo-network/payload-model'
10
- import { SchemaSchema } from '@xyo-network/schema-payload-plugin'
11
- import {
12
- describe, expect, test,
13
- } from 'vitest'
14
-
15
- import { SchemaCache } from '../SchemaCache.ts'
16
-
17
- const exampleDomainConfig: DomainPayload = {
18
- aliases: { [SchemaSchema]: { huri: '548476cc8388e97c7a724c77ffc89b8b858b66ee009750797405d264c570b260' } },
19
- networks: [
20
- {
21
- name: 'Main',
22
- nodes: [
23
- {
24
- name: 'XYO Archivist',
25
- schema: NetworkNodeSchema,
26
- slug: 'xyo',
27
- type: 'archivist',
28
- uri: 'https://api.archivist.xyo.network',
29
- web: 'https://archivist.xyo.network',
30
- },
31
- ],
32
- schema: NetworkSchema,
33
- slug: 'main',
34
- },
35
- ],
36
- schema: DomainSchema,
37
- }
38
-
39
- describe('SchemaCache', () => {
40
- test('Valid', async () => {
41
- const cache = SchemaCache.instance
42
- const fetchedPayload = await cache.get(SchemaSchema)
43
- expect(fetchedPayload?.payload.schema).toBe(SchemaSchema)
44
- })
45
-
46
- describe('validator', () => {
47
- describe('provides strongly typed validator for known schema type', () => {
48
- test('Payload', async () => {
49
- const schema = PayloadSchema
50
- const cache = SchemaCache.instance
51
- const fetchedPayload = await cache.get(schema)
52
- expect(fetchedPayload).toBeTruthy()
53
- const payloads: Payload[] = [
54
- new PayloadBuilder({ schema }).fields({ a: 'a' }).build(),
55
- new PayloadBuilder({ schema }).fields({ b: 'b' }).build(),
56
- new PayloadBuilder({ schema }).fields({ c: 'c' }).build(),
57
- ]
58
- const validator = assertEx(cache.validators[schema])
59
- // Strongly typing variable to ensure TypeScript inferred type from validator matches
60
- const valid: Payload[] = payloads.filter(validator)
61
- expect(valid.length).toBe(payloads.length)
62
- })
63
- test('DomainConfig', async () => {
64
- const schema = DomainSchema
65
- const cache = SchemaCache.instance
66
- const fetchedPayload = await cache.get(schema)
67
- expect(fetchedPayload).toBeTruthy()
68
- const payloads = [new PayloadBuilder<DomainPayload>({ schema }).fields(exampleDomainConfig).build()]
69
- const validator = assertEx(cache.validators[schema])
70
- // Strongly typing variable to ensure TypeScript inferred type from validator matches
71
- const valid: DomainPayload[] = payloads.filter(validator)
72
- expect(valid.length).toBe(payloads.length)
73
- })
74
- })
75
- })
76
-
77
- test('Not In Cache', async () => {
78
- const cache = SchemaCache.instance
79
- const fetchedPayload = await cache.get('foo.domain.com')
80
- expect(fetchedPayload).toBeNull()
81
- })
82
- })