@xyo-network/schema-cache 4.0.3 → 4.1.0
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/neutral/index.d.ts +53 -0
- package/package.json +16 -16
- /package/{dist/types → build/neutral}/Debounce.d.ts +0 -0
- /package/{dist/types → build/neutral}/Debounce.d.ts.map +0 -0
- /package/{dist/types → build/neutral}/SchemaCache.d.ts +0 -0
- /package/{dist/types → build/neutral}/SchemaCache.d.ts.map +0 -0
- /package/{dist/types → build/neutral}/SchemaNameToValidatorMap.d.ts +0 -0
- /package/{dist/types → build/neutral}/SchemaNameToValidatorMap.d.ts.map +0 -0
- /package/{dist/types → build/neutral}/index.d.ts +0 -0
- /package/{dist/types → build/neutral}/index.d.ts.map +0 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { FetchedPayload } from '@xyo-network/huri';
|
|
2
|
+
import { SchemaSchema, SchemaPayload } from '@xyo-network/schema-payload-plugin';
|
|
3
|
+
import { DomainSchema, DomainPayload } from '@xyo-network/domain-payload-plugin';
|
|
4
|
+
import { Payload, PayloadSchema } from '@xyo-network/payload-model';
|
|
5
|
+
|
|
6
|
+
declare class Debounce<TKey = string> {
|
|
7
|
+
private map;
|
|
8
|
+
one<T>(key: TKey, closure: () => Promise<T>, timeout?: number): Promise<T>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Used in conjunction with schema validation to support compile time type assertion
|
|
13
|
+
* for known schema types.
|
|
14
|
+
*/
|
|
15
|
+
type NarrowPayload<T extends Payload = Payload> = ((x: Payload) => x is T) | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Used to map known schemas (byt their string name) to the validators which assert their types
|
|
18
|
+
*/
|
|
19
|
+
interface SchemaNameToValidatorMap {
|
|
20
|
+
[DomainSchema]: NarrowPayload<DomainPayload>;
|
|
21
|
+
[PayloadSchema]: NarrowPayload<Payload>;
|
|
22
|
+
[SchemaSchema]: NarrowPayload<SchemaPayload>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
type SchemaCacheEntry = FetchedPayload<SchemaPayload>;
|
|
26
|
+
declare class SchemaCache<T extends SchemaNameToValidatorMap = SchemaNameToValidatorMap> {
|
|
27
|
+
/**
|
|
28
|
+
* Object representing `null` since LRU Cache types
|
|
29
|
+
* only allow for types that derive from object
|
|
30
|
+
*/
|
|
31
|
+
protected static readonly NULL: SchemaCacheEntry;
|
|
32
|
+
private static _instance?;
|
|
33
|
+
onSchemaCached?: (name: string, entry: SchemaCacheEntry) => void;
|
|
34
|
+
proxy?: string;
|
|
35
|
+
private _cache;
|
|
36
|
+
private _validators;
|
|
37
|
+
private getDebounce;
|
|
38
|
+
private constructor();
|
|
39
|
+
static get instance(): SchemaCache<SchemaNameToValidatorMap>;
|
|
40
|
+
/**
|
|
41
|
+
* A map of cached schema (by name) to payload validators for the schema. A schema
|
|
42
|
+
* must be cached via `get('schema.name')` before it's validator can be used as
|
|
43
|
+
* they are compiled dynamically at runtime upon retrieval.
|
|
44
|
+
*/
|
|
45
|
+
get validators(): T;
|
|
46
|
+
get(schema?: string): Promise<SchemaCacheEntry | undefined | null>;
|
|
47
|
+
private cacheSchemaIfValid;
|
|
48
|
+
private cacheSchemas;
|
|
49
|
+
private fetchSchema;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { Debounce, SchemaCache };
|
|
53
|
+
export type { NarrowPayload, SchemaCacheEntry, SchemaNameToValidatorMap };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/schema-cache",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
5
5
|
"homepage": "https://xyo.network",
|
|
6
6
|
"bugs": {
|
|
@@ -21,32 +21,32 @@
|
|
|
21
21
|
"type": "module",
|
|
22
22
|
"exports": {
|
|
23
23
|
".": {
|
|
24
|
-
"types": "./dist/
|
|
24
|
+
"types": "./dist/neutral/index.d.ts",
|
|
25
25
|
"default": "./dist/neutral/index.mjs"
|
|
26
26
|
},
|
|
27
27
|
"./package.json": "./package.json"
|
|
28
28
|
},
|
|
29
29
|
"module": "dist/neutral/index.mjs",
|
|
30
|
-
"types": "dist/
|
|
30
|
+
"types": "dist/neutral/index.d.ts",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@xylabs/delay": "^4.13.
|
|
33
|
-
"@xylabs/error": "^4.13.
|
|
34
|
-
"@xylabs/typeof": "^4.13.
|
|
35
|
-
"@xyo-network/domain-payload-plugin": "^4.0
|
|
36
|
-
"@xyo-network/huri": "^4.0
|
|
37
|
-
"@xyo-network/payload-model": "^4.0
|
|
38
|
-
"@xyo-network/schema-payload-plugin": "^4.0
|
|
32
|
+
"@xylabs/delay": "^4.13.15",
|
|
33
|
+
"@xylabs/error": "^4.13.15",
|
|
34
|
+
"@xylabs/typeof": "^4.13.15",
|
|
35
|
+
"@xyo-network/domain-payload-plugin": "^4.1.0",
|
|
36
|
+
"@xyo-network/huri": "^4.1.0",
|
|
37
|
+
"@xyo-network/payload-model": "^4.1.0",
|
|
38
|
+
"@xyo-network/schema-payload-plugin": "^4.1.0",
|
|
39
39
|
"ajv": "^8.17.1",
|
|
40
40
|
"axios": "^1.10.0",
|
|
41
41
|
"lru-cache": "^11.1.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@xylabs/assert": "^4.13.
|
|
45
|
-
"@xylabs/ts-scripts-yarn3": "^
|
|
46
|
-
"@xylabs/tsconfig-dom": "^
|
|
47
|
-
"@xylabs/vitest-extended": "^4.13.
|
|
48
|
-
"@xyo-network/network": "^4.0
|
|
49
|
-
"@xyo-network/payload-builder": "^4.0
|
|
44
|
+
"@xylabs/assert": "^4.13.15",
|
|
45
|
+
"@xylabs/ts-scripts-yarn3": "^7.0.0-rc.20",
|
|
46
|
+
"@xylabs/tsconfig-dom": "^7.0.0-rc.20",
|
|
47
|
+
"@xylabs/vitest-extended": "^4.13.15",
|
|
48
|
+
"@xyo-network/network": "^4.1.0",
|
|
49
|
+
"@xyo-network/payload-builder": "^4.1.0",
|
|
50
50
|
"typescript": "^5.8.3",
|
|
51
51
|
"vitest": "^3.2.4"
|
|
52
52
|
},
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|