@graphql-mesh/store 1.0.0-alpha-3fc47d119.0 → 1.0.0-alpha-20230420181317-a95037648
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/{index.js → cjs/index.js} +34 -31
- package/cjs/package.json +1 -0
- package/{index.mjs → esm/index.js} +27 -24
- package/package.json +26 -19
- package/typings/index.d.cts +60 -0
- package/{index.d.ts → typings/index.d.ts} +4 -4
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const graphql = require('graphql');
|
|
10
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MeshStore = exports.PredefinedProxyOptions = exports.PredefinedProxyOptionsName = exports.FsStoreStorageAdapter = exports.InMemoryStoreStorageAdapter = exports.ValidationError = exports.ReadonlyStoreError = void 0;
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
|
+
const core_1 = require("@graphql-inspector/core");
|
|
6
|
+
const cross_helpers_1 = require("@graphql-mesh/cross-helpers");
|
|
7
|
+
const utils_1 = require("@graphql-mesh/utils");
|
|
8
|
+
const utils_2 = require("@graphql-tools/utils");
|
|
11
9
|
class ReadonlyStoreError extends Error {
|
|
12
10
|
}
|
|
11
|
+
exports.ReadonlyStoreError = ReadonlyStoreError;
|
|
13
12
|
class ValidationError extends Error {
|
|
14
13
|
}
|
|
14
|
+
exports.ValidationError = ValidationError;
|
|
15
15
|
class InMemoryStoreStorageAdapter {
|
|
16
16
|
constructor() {
|
|
17
17
|
this.data = new Map();
|
|
@@ -29,12 +29,15 @@ class InMemoryStoreStorageAdapter {
|
|
|
29
29
|
this.data.clear();
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
+
exports.InMemoryStoreStorageAdapter = InMemoryStoreStorageAdapter;
|
|
32
33
|
class FsStoreStorageAdapter {
|
|
33
34
|
constructor(options) {
|
|
34
35
|
this.options = options;
|
|
35
36
|
}
|
|
36
37
|
getAbsolutePath(jsFileName) {
|
|
37
|
-
return
|
|
38
|
+
return cross_helpers_1.path.isAbsolute(jsFileName)
|
|
39
|
+
? jsFileName
|
|
40
|
+
: cross_helpers_1.path.join(this.options.cwd, jsFileName);
|
|
38
41
|
}
|
|
39
42
|
async read(key, options) {
|
|
40
43
|
let absoluteModulePath = this.getAbsolutePath(key);
|
|
@@ -42,7 +45,9 @@ class FsStoreStorageAdapter {
|
|
|
42
45
|
absoluteModulePath += '.' + this.options.fileType;
|
|
43
46
|
}
|
|
44
47
|
try {
|
|
45
|
-
const importedData = await this.options
|
|
48
|
+
const importedData = await this.options
|
|
49
|
+
.importFn(absoluteModulePath)
|
|
50
|
+
.then(m => m.default || m);
|
|
46
51
|
if (this.options.fileType === 'json') {
|
|
47
52
|
return await options.fromJSON(importedData, key);
|
|
48
53
|
}
|
|
@@ -61,20 +66,22 @@ class FsStoreStorageAdapter {
|
|
|
61
66
|
: `// @ts-nocheck\n` + (await options.codify(data, key));
|
|
62
67
|
const modulePath = this.getAbsolutePath(key);
|
|
63
68
|
const filePath = modulePath + '.' + this.options.fileType;
|
|
64
|
-
await
|
|
69
|
+
await (0, utils_1.writeFile)(filePath, asString);
|
|
65
70
|
await this.options.importFn(this.options.fileType !== 'ts' ? filePath : modulePath);
|
|
66
71
|
}
|
|
67
72
|
async delete(key) {
|
|
68
73
|
const filePath = this.getAbsolutePath(key) + '.' + this.options.fileType;
|
|
69
|
-
return
|
|
74
|
+
return cross_helpers_1.fs.promises.unlink(filePath);
|
|
70
75
|
}
|
|
71
76
|
}
|
|
77
|
+
exports.FsStoreStorageAdapter = FsStoreStorageAdapter;
|
|
78
|
+
var PredefinedProxyOptionsName;
|
|
72
79
|
(function (PredefinedProxyOptionsName) {
|
|
73
80
|
PredefinedProxyOptionsName["JsonWithoutValidation"] = "JsonWithoutValidation";
|
|
74
81
|
PredefinedProxyOptionsName["StringWithoutValidation"] = "StringWithoutValidation";
|
|
75
82
|
PredefinedProxyOptionsName["GraphQLSchemaWithDiffing"] = "GraphQLSchemaWithDiffing";
|
|
76
|
-
})(exports.PredefinedProxyOptionsName || (exports.PredefinedProxyOptionsName = {}));
|
|
77
|
-
|
|
83
|
+
})(PredefinedProxyOptionsName = exports.PredefinedProxyOptionsName || (exports.PredefinedProxyOptionsName = {}));
|
|
84
|
+
exports.PredefinedProxyOptions = {
|
|
78
85
|
JsonWithoutValidation: {
|
|
79
86
|
codify: v => `export default ${JSON.stringify(v, null, 2)}`,
|
|
80
87
|
fromJSON: v => v,
|
|
@@ -91,21 +98,23 @@ const PredefinedProxyOptions = {
|
|
|
91
98
|
codify: schema => `
|
|
92
99
|
import { buildASTSchema } from 'graphql';
|
|
93
100
|
|
|
94
|
-
const schemaAST = ${JSON.stringify(
|
|
101
|
+
const schemaAST = ${JSON.stringify((0, utils_2.getDocumentNodeFromSchema)(schema), null, 2)};
|
|
95
102
|
|
|
96
103
|
export default buildASTSchema(schemaAST, {
|
|
97
104
|
assumeValid: true,
|
|
98
105
|
assumeValidSDL: true
|
|
99
106
|
});
|
|
100
107
|
`.trim(),
|
|
101
|
-
fromJSON: schemaAST =>
|
|
102
|
-
toJSON: schema =>
|
|
108
|
+
fromJSON: schemaAST => (0, graphql_1.buildASTSchema)(schemaAST, { assumeValid: true, assumeValidSDL: true }),
|
|
109
|
+
toJSON: schema => (0, utils_2.getDocumentNodeFromSchema)(schema),
|
|
103
110
|
validate: async (oldSchema, newSchema) => {
|
|
104
|
-
const changes = await
|
|
111
|
+
const changes = await (0, core_1.diff)(oldSchema, newSchema);
|
|
105
112
|
const errors = [];
|
|
106
113
|
for (const change of changes) {
|
|
107
|
-
if (change.criticality.level ===
|
|
108
|
-
change.criticality.level ===
|
|
114
|
+
if ((change.criticality.level === core_1.CriticalityLevel.Breaking ||
|
|
115
|
+
change.criticality.level === core_1.CriticalityLevel.Dangerous) &&
|
|
116
|
+
!change.message.includes('@specifiedBy') &&
|
|
117
|
+
!change.message.includes('@deprecated')) {
|
|
109
118
|
errors.push(change.message);
|
|
110
119
|
}
|
|
111
120
|
}
|
|
@@ -114,7 +123,7 @@ export default buildASTSchema(schemaAST, {
|
|
|
114
123
|
throw errors[0];
|
|
115
124
|
}
|
|
116
125
|
else {
|
|
117
|
-
throw new
|
|
126
|
+
throw new Error(`Breaking changes found; \n${errors.map(error => `- ${error}`).join('\n')}`);
|
|
118
127
|
}
|
|
119
128
|
}
|
|
120
129
|
},
|
|
@@ -127,13 +136,13 @@ class MeshStore {
|
|
|
127
136
|
this.flags = flags;
|
|
128
137
|
}
|
|
129
138
|
child(childIdentifier, flags) {
|
|
130
|
-
return new MeshStore(
|
|
139
|
+
return new MeshStore(cross_helpers_1.path.join(this.identifier, childIdentifier), this.storage, {
|
|
131
140
|
...this.flags,
|
|
132
141
|
...flags,
|
|
133
142
|
});
|
|
134
143
|
}
|
|
135
144
|
proxy(id, options) {
|
|
136
|
-
const path =
|
|
145
|
+
const path = cross_helpers_1.path.join(this.identifier, id);
|
|
137
146
|
let value;
|
|
138
147
|
let isValueCached = false;
|
|
139
148
|
const ensureValueCached = async () => {
|
|
@@ -187,10 +196,4 @@ class MeshStore {
|
|
|
187
196
|
return proxy;
|
|
188
197
|
}
|
|
189
198
|
}
|
|
190
|
-
|
|
191
|
-
exports.FsStoreStorageAdapter = FsStoreStorageAdapter;
|
|
192
|
-
exports.InMemoryStoreStorageAdapter = InMemoryStoreStorageAdapter;
|
|
193
199
|
exports.MeshStore = MeshStore;
|
|
194
|
-
exports.PredefinedProxyOptions = PredefinedProxyOptions;
|
|
195
|
-
exports.ReadonlyStoreError = ReadonlyStoreError;
|
|
196
|
-
exports.ValidationError = ValidationError;
|
package/cjs/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { path, fs } from '@graphql-mesh/cross-helpers';
|
|
2
|
-
import { writeFile } from '@graphql-mesh/utils';
|
|
3
|
-
import { diff, CriticalityLevel } from '@graphql-inspector/core';
|
|
4
|
-
import { getDocumentNodeFromSchema, AggregateError } from '@graphql-tools/utils';
|
|
5
1
|
import { buildASTSchema } from 'graphql';
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import { CriticalityLevel, diff } from '@graphql-inspector/core';
|
|
3
|
+
import { fs, path as pathModule } from '@graphql-mesh/cross-helpers';
|
|
4
|
+
import { writeFile } from '@graphql-mesh/utils';
|
|
5
|
+
import { getDocumentNodeFromSchema } from '@graphql-tools/utils';
|
|
6
|
+
export class ReadonlyStoreError extends Error {
|
|
8
7
|
}
|
|
9
|
-
class ValidationError extends Error {
|
|
8
|
+
export class ValidationError extends Error {
|
|
10
9
|
}
|
|
11
|
-
class InMemoryStoreStorageAdapter {
|
|
10
|
+
export class InMemoryStoreStorageAdapter {
|
|
12
11
|
constructor() {
|
|
13
12
|
this.data = new Map();
|
|
14
13
|
}
|
|
@@ -25,12 +24,14 @@ class InMemoryStoreStorageAdapter {
|
|
|
25
24
|
this.data.clear();
|
|
26
25
|
}
|
|
27
26
|
}
|
|
28
|
-
class FsStoreStorageAdapter {
|
|
27
|
+
export class FsStoreStorageAdapter {
|
|
29
28
|
constructor(options) {
|
|
30
29
|
this.options = options;
|
|
31
30
|
}
|
|
32
31
|
getAbsolutePath(jsFileName) {
|
|
33
|
-
return
|
|
32
|
+
return pathModule.isAbsolute(jsFileName)
|
|
33
|
+
? jsFileName
|
|
34
|
+
: pathModule.join(this.options.cwd, jsFileName);
|
|
34
35
|
}
|
|
35
36
|
async read(key, options) {
|
|
36
37
|
let absoluteModulePath = this.getAbsolutePath(key);
|
|
@@ -38,7 +39,9 @@ class FsStoreStorageAdapter {
|
|
|
38
39
|
absoluteModulePath += '.' + this.options.fileType;
|
|
39
40
|
}
|
|
40
41
|
try {
|
|
41
|
-
const importedData = await this.options
|
|
42
|
+
const importedData = await this.options
|
|
43
|
+
.importFn(absoluteModulePath)
|
|
44
|
+
.then(m => m.default || m);
|
|
42
45
|
if (this.options.fileType === 'json') {
|
|
43
46
|
return await options.fromJSON(importedData, key);
|
|
44
47
|
}
|
|
@@ -65,13 +68,13 @@ class FsStoreStorageAdapter {
|
|
|
65
68
|
return fs.promises.unlink(filePath);
|
|
66
69
|
}
|
|
67
70
|
}
|
|
68
|
-
var PredefinedProxyOptionsName;
|
|
71
|
+
export var PredefinedProxyOptionsName;
|
|
69
72
|
(function (PredefinedProxyOptionsName) {
|
|
70
73
|
PredefinedProxyOptionsName["JsonWithoutValidation"] = "JsonWithoutValidation";
|
|
71
74
|
PredefinedProxyOptionsName["StringWithoutValidation"] = "StringWithoutValidation";
|
|
72
75
|
PredefinedProxyOptionsName["GraphQLSchemaWithDiffing"] = "GraphQLSchemaWithDiffing";
|
|
73
76
|
})(PredefinedProxyOptionsName || (PredefinedProxyOptionsName = {}));
|
|
74
|
-
const PredefinedProxyOptions = {
|
|
77
|
+
export const PredefinedProxyOptions = {
|
|
75
78
|
JsonWithoutValidation: {
|
|
76
79
|
codify: v => `export default ${JSON.stringify(v, null, 2)}`,
|
|
77
80
|
fromJSON: v => v,
|
|
@@ -101,8 +104,10 @@ export default buildASTSchema(schemaAST, {
|
|
|
101
104
|
const changes = await diff(oldSchema, newSchema);
|
|
102
105
|
const errors = [];
|
|
103
106
|
for (const change of changes) {
|
|
104
|
-
if (change.criticality.level === CriticalityLevel.Breaking ||
|
|
105
|
-
change.criticality.level === CriticalityLevel.Dangerous)
|
|
107
|
+
if ((change.criticality.level === CriticalityLevel.Breaking ||
|
|
108
|
+
change.criticality.level === CriticalityLevel.Dangerous) &&
|
|
109
|
+
!change.message.includes('@specifiedBy') &&
|
|
110
|
+
!change.message.includes('@deprecated')) {
|
|
106
111
|
errors.push(change.message);
|
|
107
112
|
}
|
|
108
113
|
}
|
|
@@ -111,31 +116,31 @@ export default buildASTSchema(schemaAST, {
|
|
|
111
116
|
throw errors[0];
|
|
112
117
|
}
|
|
113
118
|
else {
|
|
114
|
-
throw new
|
|
119
|
+
throw new Error(`Breaking changes found; \n${errors.map(error => `- ${error}`).join('\n')}`);
|
|
115
120
|
}
|
|
116
121
|
}
|
|
117
122
|
},
|
|
118
123
|
},
|
|
119
124
|
};
|
|
120
|
-
class MeshStore {
|
|
125
|
+
export class MeshStore {
|
|
121
126
|
constructor(identifier, storage, flags) {
|
|
122
127
|
this.identifier = identifier;
|
|
123
128
|
this.storage = storage;
|
|
124
129
|
this.flags = flags;
|
|
125
130
|
}
|
|
126
131
|
child(childIdentifier, flags) {
|
|
127
|
-
return new MeshStore(
|
|
132
|
+
return new MeshStore(pathModule.join(this.identifier, childIdentifier), this.storage, {
|
|
128
133
|
...this.flags,
|
|
129
134
|
...flags,
|
|
130
135
|
});
|
|
131
136
|
}
|
|
132
137
|
proxy(id, options) {
|
|
133
|
-
const path
|
|
138
|
+
const path = pathModule.join(this.identifier, id);
|
|
134
139
|
let value;
|
|
135
140
|
let isValueCached = false;
|
|
136
141
|
const ensureValueCached = async () => {
|
|
137
142
|
if (!isValueCached) {
|
|
138
|
-
value = await this.storage.read(path
|
|
143
|
+
value = await this.storage.read(path, options);
|
|
139
144
|
isValueCached = true;
|
|
140
145
|
}
|
|
141
146
|
};
|
|
@@ -177,12 +182,10 @@ class MeshStore {
|
|
|
177
182
|
}
|
|
178
183
|
value = newValue;
|
|
179
184
|
isValueCached = true;
|
|
180
|
-
await this.storage.write(path
|
|
185
|
+
await this.storage.write(path, value, options);
|
|
181
186
|
},
|
|
182
|
-
delete: () => this.storage.delete(path
|
|
187
|
+
delete: () => this.storage.delete(path),
|
|
183
188
|
};
|
|
184
189
|
return proxy;
|
|
185
190
|
}
|
|
186
191
|
}
|
|
187
|
-
|
|
188
|
-
export { FsStoreStorageAdapter, InMemoryStoreStorageAdapter, MeshStore, PredefinedProxyOptions, PredefinedProxyOptionsName, ReadonlyStoreError, ValidationError };
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-mesh/store",
|
|
3
|
-
"version": "1.0.0-alpha-
|
|
3
|
+
"version": "1.0.0-alpha-20230420181317-a95037648",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependencies": {
|
|
6
|
-
"@graphql-mesh/
|
|
7
|
-
"@graphql-mesh/
|
|
8
|
-
"graphql": "
|
|
6
|
+
"@graphql-mesh/cross-helpers": "^0.3.4",
|
|
7
|
+
"@graphql-mesh/types": "1.0.0-alpha-20230420181317-a95037648",
|
|
8
|
+
"@graphql-mesh/utils": "1.0.0-alpha-20230420181317-a95037648",
|
|
9
|
+
"@graphql-tools/utils": "^9.2.1",
|
|
10
|
+
"graphql": "*",
|
|
11
|
+
"tslib": "^2.4.0"
|
|
9
12
|
},
|
|
10
13
|
"dependencies": {
|
|
11
|
-
"@graphql-inspector/core": "3.3.0"
|
|
12
|
-
"@graphql-mesh/cross-helpers": "0.2.0",
|
|
13
|
-
"@graphql-tools/utils": "8.8.0",
|
|
14
|
-
"tslib": "^2.4.0"
|
|
14
|
+
"@graphql-inspector/core": "3.3.0"
|
|
15
15
|
},
|
|
16
16
|
"repository": {
|
|
17
17
|
"type": "git",
|
|
@@ -19,21 +19,28 @@
|
|
|
19
19
|
"directory": "packages/store"
|
|
20
20
|
},
|
|
21
21
|
"license": "MIT",
|
|
22
|
-
"main": "index.js",
|
|
23
|
-
"module": "index.
|
|
24
|
-
"typings": "index.d.ts",
|
|
22
|
+
"main": "cjs/index.js",
|
|
23
|
+
"module": "esm/index.js",
|
|
24
|
+
"typings": "typings/index.d.ts",
|
|
25
25
|
"typescript": {
|
|
26
|
-
"definition": "index.d.ts"
|
|
26
|
+
"definition": "typings/index.d.ts"
|
|
27
27
|
},
|
|
28
|
+
"type": "module",
|
|
28
29
|
"exports": {
|
|
29
30
|
".": {
|
|
30
|
-
"require":
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"
|
|
35
|
-
|
|
31
|
+
"require": {
|
|
32
|
+
"types": "./typings/index.d.cts",
|
|
33
|
+
"default": "./cjs/index.js"
|
|
34
|
+
},
|
|
35
|
+
"import": {
|
|
36
|
+
"types": "./typings/index.d.ts",
|
|
37
|
+
"default": "./esm/index.js"
|
|
38
|
+
},
|
|
39
|
+
"default": {
|
|
40
|
+
"types": "./typings/index.d.ts",
|
|
41
|
+
"default": "./esm/index.js"
|
|
42
|
+
}
|
|
36
43
|
},
|
|
37
44
|
"./package.json": "./package.json"
|
|
38
45
|
}
|
|
39
|
-
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { ImportFn } from '@graphql-mesh/types';
|
|
2
|
+
export declare class ReadonlyStoreError extends Error {
|
|
3
|
+
}
|
|
4
|
+
export declare class ValidationError extends Error {
|
|
5
|
+
}
|
|
6
|
+
export type StoreStorageAdapter<TData = any, TKey = string> = {
|
|
7
|
+
read: (key: TKey, options: ProxyOptions<TData>) => Promise<TData>;
|
|
8
|
+
write: (key: TKey, data: TData, options: ProxyOptions<TData>) => Promise<TData>;
|
|
9
|
+
delete: (key: TKey) => Promise<void>;
|
|
10
|
+
};
|
|
11
|
+
export declare class InMemoryStoreStorageAdapter implements StoreStorageAdapter {
|
|
12
|
+
private data;
|
|
13
|
+
read<TData>(key: string, options: ProxyOptions<any>): Promise<TData>;
|
|
14
|
+
write<TData>(key: string, data: TData, options: ProxyOptions<any>): Promise<void>;
|
|
15
|
+
delete(key: string): Promise<void>;
|
|
16
|
+
clear(): void;
|
|
17
|
+
}
|
|
18
|
+
export interface FsStoreStorageAdapterOptions {
|
|
19
|
+
cwd: string;
|
|
20
|
+
importFn: ImportFn;
|
|
21
|
+
fileType: 'ts' | 'json' | 'js';
|
|
22
|
+
}
|
|
23
|
+
export declare class FsStoreStorageAdapter implements StoreStorageAdapter {
|
|
24
|
+
private options;
|
|
25
|
+
constructor(options: FsStoreStorageAdapterOptions);
|
|
26
|
+
private getAbsolutePath;
|
|
27
|
+
read<TData, TJSONData = any>(key: string, options: ProxyOptions<TData, TJSONData>): Promise<TData>;
|
|
28
|
+
write<TData, TJSONData = any>(key: string, data: TData, options: ProxyOptions<TData, TJSONData>): Promise<void>;
|
|
29
|
+
delete(key: string): Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
export type StoreProxy<TData> = {
|
|
32
|
+
set(value: TData): Promise<void>;
|
|
33
|
+
get(): Promise<TData>;
|
|
34
|
+
getWithSet(setterFn: () => TData | Promise<TData>): Promise<TData>;
|
|
35
|
+
delete(): Promise<void>;
|
|
36
|
+
};
|
|
37
|
+
export type ProxyOptions<TData, TJSONData = any> = {
|
|
38
|
+
codify: (value: TData, identifier: string) => string | Promise<string>;
|
|
39
|
+
fromJSON: (jsonData: TJSONData, identifier: string) => TData | Promise<TData>;
|
|
40
|
+
toJSON: (value: TData, identifier: string) => TJSONData | Promise<TJSONData>;
|
|
41
|
+
validate: (oldValue: TData, newValue: TData, identifier: string) => void | Promise<void>;
|
|
42
|
+
};
|
|
43
|
+
export type StoreFlags = {
|
|
44
|
+
readonly: boolean;
|
|
45
|
+
validate: boolean;
|
|
46
|
+
};
|
|
47
|
+
export declare enum PredefinedProxyOptionsName {
|
|
48
|
+
JsonWithoutValidation = "JsonWithoutValidation",
|
|
49
|
+
StringWithoutValidation = "StringWithoutValidation",
|
|
50
|
+
GraphQLSchemaWithDiffing = "GraphQLSchemaWithDiffing"
|
|
51
|
+
}
|
|
52
|
+
export declare const PredefinedProxyOptions: Record<PredefinedProxyOptionsName, ProxyOptions<any>>;
|
|
53
|
+
export declare class MeshStore {
|
|
54
|
+
identifier: string;
|
|
55
|
+
protected storage: StoreStorageAdapter;
|
|
56
|
+
flags: StoreFlags;
|
|
57
|
+
constructor(identifier: string, storage: StoreStorageAdapter, flags: StoreFlags);
|
|
58
|
+
child(childIdentifier: string, flags?: Partial<StoreFlags>): MeshStore;
|
|
59
|
+
proxy<TData>(id: string, options: ProxyOptions<TData>): StoreProxy<TData>;
|
|
60
|
+
}
|
|
@@ -3,7 +3,7 @@ export declare class ReadonlyStoreError extends Error {
|
|
|
3
3
|
}
|
|
4
4
|
export declare class ValidationError extends Error {
|
|
5
5
|
}
|
|
6
|
-
export
|
|
6
|
+
export type StoreStorageAdapter<TData = any, TKey = string> = {
|
|
7
7
|
read: (key: TKey, options: ProxyOptions<TData>) => Promise<TData>;
|
|
8
8
|
write: (key: TKey, data: TData, options: ProxyOptions<TData>) => Promise<TData>;
|
|
9
9
|
delete: (key: TKey) => Promise<void>;
|
|
@@ -28,19 +28,19 @@ export declare class FsStoreStorageAdapter implements StoreStorageAdapter {
|
|
|
28
28
|
write<TData, TJSONData = any>(key: string, data: TData, options: ProxyOptions<TData, TJSONData>): Promise<void>;
|
|
29
29
|
delete(key: string): Promise<void>;
|
|
30
30
|
}
|
|
31
|
-
export
|
|
31
|
+
export type StoreProxy<TData> = {
|
|
32
32
|
set(value: TData): Promise<void>;
|
|
33
33
|
get(): Promise<TData>;
|
|
34
34
|
getWithSet(setterFn: () => TData | Promise<TData>): Promise<TData>;
|
|
35
35
|
delete(): Promise<void>;
|
|
36
36
|
};
|
|
37
|
-
export
|
|
37
|
+
export type ProxyOptions<TData, TJSONData = any> = {
|
|
38
38
|
codify: (value: TData, identifier: string) => string | Promise<string>;
|
|
39
39
|
fromJSON: (jsonData: TJSONData, identifier: string) => TData | Promise<TData>;
|
|
40
40
|
toJSON: (value: TData, identifier: string) => TJSONData | Promise<TJSONData>;
|
|
41
41
|
validate: (oldValue: TData, newValue: TData, identifier: string) => void | Promise<void>;
|
|
42
42
|
};
|
|
43
|
-
export
|
|
43
|
+
export type StoreFlags = {
|
|
44
44
|
readonly: boolean;
|
|
45
45
|
validate: boolean;
|
|
46
46
|
};
|