@comake/skl-js-engine 1.4.3 → 1.5.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/SklEngine.d.ts +11 -0
- package/dist/SklEngine.d.ts.map +1 -1
- package/dist/SklEngine.js +138 -12
- package/dist/SklEngine.js.map +1 -1
- package/dist/SklEngineOptions.d.ts +32 -0
- package/dist/SklEngineOptions.d.ts.map +1 -1
- package/dist/SklEngineOptions.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/storage/FindOptionsTypes.d.ts +4 -1
- package/dist/storage/FindOptionsTypes.d.ts.map +1 -1
- package/dist/storage/FindOptionsTypes.js.map +1 -1
- package/dist/util/ReadCacheHelper.d.ts +14 -0
- package/dist/util/ReadCacheHelper.d.ts.map +1 -0
- package/dist/util/ReadCacheHelper.js +61 -0
- package/dist/util/ReadCacheHelper.js.map +1 -0
- package/package.json +1 -1
- package/src/SklEngine.ts +172 -13
- package/src/SklEngineOptions.ts +40 -0
- package/src/index.ts +1 -0
- package/src/storage/FindOptionsTypes.ts +4 -1
- package/src/util/ReadCacheHelper.ts +64 -0
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
import type { SparqlQueryAdapterOptions } from './storage/query-adapter/sparql/SparqlQueryAdapterOptions';
|
|
2
2
|
import type { Callbacks } from './util/Types';
|
|
3
|
+
export declare type ReadCacheOperation = 'find' | 'findBy' | 'findAll' | 'count';
|
|
4
|
+
export interface ReadCacheStore {
|
|
5
|
+
get: (key: string) => Promise<unknown | undefined>;
|
|
6
|
+
set: (key: string, value: unknown, ttlMs: number) => Promise<void>;
|
|
7
|
+
delete?: (key: string) => Promise<void>;
|
|
8
|
+
clear?: () => Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
export interface ReadCachePolicyInput {
|
|
11
|
+
operation: ReadCacheOperation;
|
|
12
|
+
args: readonly unknown[];
|
|
13
|
+
endpointUrl?: string;
|
|
14
|
+
namespace?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface ReadCachePolicyDecision {
|
|
17
|
+
cache: boolean;
|
|
18
|
+
ttlMs?: number;
|
|
19
|
+
keyHint?: string;
|
|
20
|
+
}
|
|
21
|
+
export declare type ReadCachePolicy = (input: ReadCachePolicyInput) => ReadCachePolicyDecision;
|
|
3
22
|
export declare type SklEngineOptions = SparqlQueryAdapterOptions & {
|
|
4
23
|
/**
|
|
5
24
|
* Callbacks to execute upon events.
|
|
@@ -22,5 +41,18 @@ export declare type SklEngineOptions = SparqlQueryAdapterOptions & {
|
|
|
22
41
|
* The path to the executor script.
|
|
23
42
|
*/
|
|
24
43
|
readonly scriptPath?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Optional read cache store used for select read operations.
|
|
46
|
+
* Cache decisions are made by readCachePolicy.
|
|
47
|
+
*/
|
|
48
|
+
readonly readCache?: ReadCacheStore;
|
|
49
|
+
/**
|
|
50
|
+
* Optional policy that decides whether a given read operation should be cached.
|
|
51
|
+
*/
|
|
52
|
+
readonly readCachePolicy?: ReadCachePolicy;
|
|
53
|
+
/**
|
|
54
|
+
* Optional namespace to scope cache keys (for example tenant/account isolation).
|
|
55
|
+
*/
|
|
56
|
+
readonly readCacheNamespace?: string;
|
|
25
57
|
};
|
|
26
58
|
//# sourceMappingURL=SklEngineOptions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SklEngineOptions.d.ts","sourceRoot":"","sources":["../src/SklEngineOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,0DAA0D,CAAC;AAC1G,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,oBAAY,gBAAgB,GAAG,yBAAyB,GAAG;IACzD;;OAEG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC;IAC/B;;OAEG;IACH,QAAQ,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;CACpB;AAED,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,oBAAY,eAAe,GAAG,CAAC,KAAK,EAAE,oBAAoB,KAAK,uBAAuB,CAAC;AAEvF,oBAAY,gBAAgB,GAAG,yBAAyB,GAAG;IACzD;;OAEG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC;IAC/B;;OAEG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,GAAG,GAAG,GAAG,EAAE,KAAK,GAAG,CAAC,CAAC;IAChE;;OAEG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IACrC;;OAEG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE7C,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAE7B;;OAEG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAE7B;;;OAGG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,cAAc,CAAC;IAEpC;;OAEG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,eAAe,CAAC;IAE3C;;OAEG;IACH,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;CACtC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SklEngineOptions.js","sourceRoot":"","sources":["../src/SklEngineOptions.ts"],"names":[],"mappings":"","sourcesContent":["import type { SparqlQueryAdapterOptions } from './storage/query-adapter/sparql/SparqlQueryAdapterOptions';\nimport type { Callbacks } from './util/Types';\n\nexport type SklEngineOptions = SparqlQueryAdapterOptions & {\n /**\n * Callbacks to execute upon events.\n */\n readonly callbacks?: Callbacks;\n /**\n * Manually defined functions which can be used in mappings.\n */\n readonly functions?: Record<string, (args: any | any[]) => any>;\n /**\n * When true, disables validation of verb parameters and return values according to schemas\n */\n readonly disableValidation?: boolean;\n /**\n * An object containing files keyed on their title that can be used in mappings.\n */\n readonly inputFiles?: Record<string, string>;\n\n readonly debugMode?: boolean;\n\n /**\n * The path to the executor script.\n */\n readonly scriptPath?: string;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"SklEngineOptions.js","sourceRoot":"","sources":["../src/SklEngineOptions.ts"],"names":[],"mappings":"","sourcesContent":["import type { SparqlQueryAdapterOptions } from './storage/query-adapter/sparql/SparqlQueryAdapterOptions';\nimport type { Callbacks } from './util/Types';\n\nexport type ReadCacheOperation = 'find' | 'findBy' | 'findAll' | 'count';\n\nexport interface ReadCacheStore {\n get: (key: string) => Promise<unknown | undefined>;\n set: (key: string, value: unknown, ttlMs: number) => Promise<void>;\n delete?: (key: string) => Promise<void>;\n clear?: () => Promise<void>;\n}\n\nexport interface ReadCachePolicyInput {\n operation: ReadCacheOperation;\n args: readonly unknown[];\n endpointUrl?: string;\n namespace?: string;\n}\n\nexport interface ReadCachePolicyDecision {\n cache: boolean;\n ttlMs?: number;\n keyHint?: string;\n}\n\nexport type ReadCachePolicy = (input: ReadCachePolicyInput) => ReadCachePolicyDecision;\n\nexport type SklEngineOptions = SparqlQueryAdapterOptions & {\n /**\n * Callbacks to execute upon events.\n */\n readonly callbacks?: Callbacks;\n /**\n * Manually defined functions which can be used in mappings.\n */\n readonly functions?: Record<string, (args: any | any[]) => any>;\n /**\n * When true, disables validation of verb parameters and return values according to schemas\n */\n readonly disableValidation?: boolean;\n /**\n * An object containing files keyed on their title that can be used in mappings.\n */\n readonly inputFiles?: Record<string, string>;\n\n readonly debugMode?: boolean;\n\n /**\n * The path to the executor script.\n */\n readonly scriptPath?: string;\n\n /**\n * Optional read cache store used for select read operations.\n * Cache decisions are made by readCachePolicy.\n */\n readonly readCache?: ReadCacheStore;\n\n /**\n * Optional policy that decides whether a given read operation should be cached.\n */\n readonly readCachePolicy?: ReadCachePolicy;\n\n /**\n * Optional namespace to scope cache keys (for example tenant/account isolation).\n */\n readonly readCacheNamespace?: string;\n};\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * from './hooks/types';
|
|
|
5
5
|
export * from './JsExecutor';
|
|
6
6
|
export * from './mapping/Mapper';
|
|
7
7
|
export * from './SklEngine';
|
|
8
|
+
export * from './SklEngineOptions';
|
|
8
9
|
export * from './storage/FindOperator';
|
|
9
10
|
export * from './storage/FindOptionsTypes';
|
|
10
11
|
export * from './storage/operator/And';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,kBAAkB,EAAE,KAAK,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AACxF,OAAO,EAAE,WAAW,IAAI,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrF,cAAc,eAAe,CAAC;AAE9B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,kBAAkB,EAAE,KAAK,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AACxF,OAAO,EAAE,WAAW,IAAI,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrF,cAAc,eAAe,CAAC;AAE9B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AAEnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC;AAE5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uCAAuC,CAAC;AACtD,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oCAAoC,CAAC;AACnD,cAAc,yCAAyC,CAAC;AACxD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oCAAoC,CAAC;AACnD,cAAc,wBAAwB,CAAC;AACvC,cAAc,kCAAkC,CAAC;AACjD,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC;AAChD,cAAc,mCAAmC,CAAC;AAClD,cAAc,sCAAsC,CAAC;AACrD,cAAc,2EAA2E,CAAC;AAC1F,cAAc,2EAA2E,CAAC;AAE1F,cAAc,mDAAmD,CAAC;AAClE,cAAc,mDAAmD,CAAC;AAClE,cAAc,oDAAoD,CAAC;AACnE,cAAc,kDAAkD,CAAC;AAEjE,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,4BAA4B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -28,6 +28,7 @@ __exportStar(require("./hooks/types"), exports);
|
|
|
28
28
|
__exportStar(require("./JsExecutor"), exports);
|
|
29
29
|
__exportStar(require("./mapping/Mapper"), exports);
|
|
30
30
|
__exportStar(require("./SklEngine"), exports);
|
|
31
|
+
__exportStar(require("./SklEngineOptions"), exports);
|
|
31
32
|
// Storage
|
|
32
33
|
__exportStar(require("./storage/FindOperator"), exports);
|
|
33
34
|
__exportStar(require("./storage/FindOptionsTypes"), exports);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,UAAU;AACV,8CAA4B;AAC5B,2DAAwF;AAA/E,wHAAA,kBAAkB,OAAA;AAC3B,mDAAqF;AAA5E,uGAAA,WAAW,OAAY;AAAE,yGAAA,UAAU,OAAA;AAAE,wGAAA,SAAS,OAAA;AACvD,gDAA8B;AAC9B,gBAAgB;AAChB,+CAA6B;AAC7B,mDAAiC;AACjC,8CAA4B;AAC5B,UAAU;AACV,yDAAuC;AACvC,6DAA2C;AAC3C,yDAAuC;AACvC,8DAA4C;AAC5C,mBAAmB;AACnB,2DAAyC;AACzC,4DAA0C;AAC1C,iEAA+C;AAC/C,wEAAsD;AACtD,wDAAsC;AACtC,6DAA2C;AAC3C,iEAA+C;AAC/C,qEAAmD;AACnD,0EAAwD;AACxD,8DAA4C;AAC5C,qEAAmD;AACnD,yDAAuC;AACvC,mEAAiD;AACjD,wDAAsC;AACtC,8DAA4C;AAC5C,kEAAgD;AAChD,oEAAkD;AAClD,uEAAqD;AACrD,4GAA0F;AAC1F,4GAA0F;AAC1F,iBAAiB;AACjB,oFAAkE;AAClE,oFAAkE;AAClE,qFAAmE;AACnE,mFAAiE;AACjE,OAAO;AACP,oDAAkC;AAClC,+CAA6B;AAC7B,8CAA4B;AAC5B,6DAA2C","sourcesContent":["// Mapping\nexport * from './constants';\nexport { customCapabilities, type CustomCapabilityHandler } from './customCapabilities';\nexport { globalHooks as SklHooks, HookStages, HookTypes } from './hooks/globalHooks';\nexport * from './hooks/types';\n// Code Executor\nexport * from './JsExecutor';\nexport * from './mapping/Mapper';\nexport * from './SklEngine';\n// Storage\nexport * from './storage/FindOperator';\nexport * from './storage/FindOptionsTypes';\nexport * from './storage/operator/And';\nexport * from './storage/operator/Contains';\n// Storage/Operator\nexport * from './storage/operator/Equal';\nexport * from './storage/operator/Exists';\nexport * from './storage/operator/GreaterThan';\nexport * from './storage/operator/GreaterThanOrEqual';\nexport * from './storage/operator/In';\nexport * from './storage/operator/Inverse';\nexport * from './storage/operator/InversePath';\nexport * from './storage/operator/InverseRelation';\nexport * from './storage/operator/InverseRelationOrder';\nexport * from './storage/operator/LessThan';\nexport * from './storage/operator/LessThanOrEqual';\nexport * from './storage/operator/Not';\nexport * from './storage/operator/OneOrMorePath';\nexport * from './storage/operator/Or';\nexport * from './storage/operator/Sequence';\nexport * from './storage/operator/SequencePath';\nexport * from './storage/operator/ZeroOrMorePath';\nexport * from './storage/query-adapter/QueryAdapter';\nexport * from './storage/query-adapter/sparql/query-executor/InMemorySparqlQueryExecutor';\nexport * from './storage/query-adapter/sparql/query-executor/SparqlEndpointQueryExecutor';\n// Storage/Sparql\nexport * from './storage/query-adapter/sparql/SparqlQueryAdapter';\nexport * from './storage/query-adapter/sparql/SparqlQueryBuilder';\nexport * from './storage/query-adapter/sparql/SparqlUpdateBuilder';\nexport * from './storage/query-adapter/sparql/VariableGenerator';\n// Util\nexport * from './util/TripleUtil';\nexport * from './util/Types';\nexport * from './util/Util';\nexport * from './util/Vocabularies/helper';\n\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,UAAU;AACV,8CAA4B;AAC5B,2DAAwF;AAA/E,wHAAA,kBAAkB,OAAA;AAC3B,mDAAqF;AAA5E,uGAAA,WAAW,OAAY;AAAE,yGAAA,UAAU,OAAA;AAAE,wGAAA,SAAS,OAAA;AACvD,gDAA8B;AAC9B,gBAAgB;AAChB,+CAA6B;AAC7B,mDAAiC;AACjC,8CAA4B;AAC5B,qDAAmC;AACnC,UAAU;AACV,yDAAuC;AACvC,6DAA2C;AAC3C,yDAAuC;AACvC,8DAA4C;AAC5C,mBAAmB;AACnB,2DAAyC;AACzC,4DAA0C;AAC1C,iEAA+C;AAC/C,wEAAsD;AACtD,wDAAsC;AACtC,6DAA2C;AAC3C,iEAA+C;AAC/C,qEAAmD;AACnD,0EAAwD;AACxD,8DAA4C;AAC5C,qEAAmD;AACnD,yDAAuC;AACvC,mEAAiD;AACjD,wDAAsC;AACtC,8DAA4C;AAC5C,kEAAgD;AAChD,oEAAkD;AAClD,uEAAqD;AACrD,4GAA0F;AAC1F,4GAA0F;AAC1F,iBAAiB;AACjB,oFAAkE;AAClE,oFAAkE;AAClE,qFAAmE;AACnE,mFAAiE;AACjE,OAAO;AACP,oDAAkC;AAClC,+CAA6B;AAC7B,8CAA4B;AAC5B,6DAA2C","sourcesContent":["// Mapping\nexport * from './constants';\nexport { customCapabilities, type CustomCapabilityHandler } from './customCapabilities';\nexport { globalHooks as SklHooks, HookStages, HookTypes } from './hooks/globalHooks';\nexport * from './hooks/types';\n// Code Executor\nexport * from './JsExecutor';\nexport * from './mapping/Mapper';\nexport * from './SklEngine';\nexport * from './SklEngineOptions';\n// Storage\nexport * from './storage/FindOperator';\nexport * from './storage/FindOptionsTypes';\nexport * from './storage/operator/And';\nexport * from './storage/operator/Contains';\n// Storage/Operator\nexport * from './storage/operator/Equal';\nexport * from './storage/operator/Exists';\nexport * from './storage/operator/GreaterThan';\nexport * from './storage/operator/GreaterThanOrEqual';\nexport * from './storage/operator/In';\nexport * from './storage/operator/Inverse';\nexport * from './storage/operator/InversePath';\nexport * from './storage/operator/InverseRelation';\nexport * from './storage/operator/InverseRelationOrder';\nexport * from './storage/operator/LessThan';\nexport * from './storage/operator/LessThanOrEqual';\nexport * from './storage/operator/Not';\nexport * from './storage/operator/OneOrMorePath';\nexport * from './storage/operator/Or';\nexport * from './storage/operator/Sequence';\nexport * from './storage/operator/SequencePath';\nexport * from './storage/operator/ZeroOrMorePath';\nexport * from './storage/query-adapter/QueryAdapter';\nexport * from './storage/query-adapter/sparql/query-executor/InMemorySparqlQueryExecutor';\nexport * from './storage/query-adapter/sparql/query-executor/SparqlEndpointQueryExecutor';\n// Storage/Sparql\nexport * from './storage/query-adapter/sparql/SparqlQueryAdapter';\nexport * from './storage/query-adapter/sparql/SparqlQueryBuilder';\nexport * from './storage/query-adapter/sparql/SparqlUpdateBuilder';\nexport * from './storage/query-adapter/sparql/VariableGenerator';\n// Util\nexport * from './util/TripleUtil';\nexport * from './util/Types';\nexport * from './util/Util';\nexport * from './util/Vocabularies/helper';\n\n"]}
|
|
@@ -14,6 +14,7 @@ export interface FindOneOptions {
|
|
|
14
14
|
skipFraming?: boolean;
|
|
15
15
|
group?: Variable;
|
|
16
16
|
entitySelectVariable?: Variable;
|
|
17
|
+
bypassCache?: boolean;
|
|
17
18
|
}
|
|
18
19
|
export declare type FindOptionsRelationsValue = boolean | FindOptionsRelations | FindOperator<InverseRelationOperatorValue, 'inverseRelation'>;
|
|
19
20
|
export declare type FindOptionsRelations = {
|
|
@@ -49,7 +50,8 @@ export interface FindOptionsWhere {
|
|
|
49
50
|
binds?: BindPattern[];
|
|
50
51
|
and?: FindOptionsWhere[];
|
|
51
52
|
or?: FindOptionsWhere[];
|
|
52
|
-
|
|
53
|
+
bypassCache?: boolean;
|
|
54
|
+
[k: string]: FindOptionsWhereField | BindPattern[] | FindOptionsWhere[] | boolean | undefined;
|
|
53
55
|
}
|
|
54
56
|
export interface SubQuery {
|
|
55
57
|
select: Variable[];
|
|
@@ -72,5 +74,6 @@ export interface FindCountOptions {
|
|
|
72
74
|
relations?: FindOptionsRelations;
|
|
73
75
|
order?: FindOptionsOrder;
|
|
74
76
|
offset?: number;
|
|
77
|
+
bypassCache?: boolean;
|
|
75
78
|
}
|
|
76
79
|
//# sourceMappingURL=FindOptionsTypes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FindOptionsTypes.d.ts","sourceRoot":"","sources":["../../src/storage/FindOptionsTypes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,4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AAC;IACzB,SAAS,CAAC,EAAE,oBAAoB,CAAC;CAClC;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,gBAAgB,CAAC;IACzB,SAAS,CAAC,EAAE,oBAAoB,CAAC;IACjC,KAAK,CAAC,EAAE,gBAAgB,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FindOptionsTypes.js","sourceRoot":"","sources":["../../src/storage/FindOptionsTypes.ts"],"names":[],"mappings":"","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\nimport type { Expression, Variable } from 'sparqljs';\nimport type { OrArray, JSONArray, JSONObject } from '../util/Types';\nimport type { FindOperator } from './FindOperator';\nimport type { InverseRelationOperatorValue } from './operator/InverseRelation';\nimport type { InverseRelationOrderValue } from './operator/InverseRelationOrder';\n\nexport type FindOptionsSelect = string[] | {[key: string]: boolean | FindOptionsSelect };\n\nexport interface FindOneOptions {\n select?: FindOptionsSelect;\n where?: FindOptionsWhere;\n relations?: FindOptionsRelations;\n order?: FindOptionsOrder;\n skipFraming?: boolean;\n group?: Variable;\n entitySelectVariable?: Variable;\n}\n\nexport type FindOptionsRelationsValue =\n | boolean\n | FindOptionsRelations\n | FindOperator<InverseRelationOperatorValue, 'inverseRelation'>;\n\n// eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style\nexport type FindOptionsRelations = {\n [k: string]: FindOptionsRelationsValue;\n};\n\nexport type FindOptionsOrderValue = 'ASC' | 'DESC' | 'asc' | 'desc' | 1 | -1;\n\nexport type FindOptionsOrder = Record<\nstring,\nFindOptionsOrderValue | FindOperator<InverseRelationOrderValue, 'inverseRelationOrder'>\n>;\n\nexport type FieldPrimitiveValue = boolean | number | string | Date;\n\nexport type JsonValueObject = {\n '@value': FieldPrimitiveValue | JSONObject | JSONArray;\n '@type': '@json';\n};\n\nexport type LanguageValueObject = {\n '@value': string;\n '@language': string;\n '@direction': string;\n};\n\nexport type NonJsonValueObject = {\n '@value': FieldPrimitiveValue;\n '@type': string;\n};\n\nexport type ValueWhereFieldObject = JsonValueObject | LanguageValueObject | NonJsonValueObject;\n\nexport type FindOptionsWhereField =\n | OrArray<FieldPrimitiveValue>\n | ValueWhereFieldObject\n | FindOptionsWhere\n | OrArray<FindOperator<any, any>>\n | BindPattern[];\n\nexport type IdFindOptionsWhereField = string | FindOperator<any, 'in' | 'not' | 'equal' | 'inversePath' | 'contains'>;\n\nexport type TypeFindOptionsWhereField =\n | string\n | FindOperator<string | string[] | FindOptionsWhere, 'in' | 'not' | 'equal' | 'inverse' | 'contains'>;\n\nexport interface BindPattern {\n expression: Expression;\n variable: Variable;\n}\n\nexport interface FindOptionsWhere {\n type?: TypeFindOptionsWhereField;\n id?: IdFindOptionsWhereField;\n binds?: BindPattern[];\n and?: FindOptionsWhere[];\n or?: FindOptionsWhere[];\n [k: string]: FindOptionsWhereField | BindPattern[] | FindOptionsWhere[] | undefined;\n}\n\n// Add these new types\nexport interface SubQuery {\n select: Variable[];\n where: FindOptionsWhere;\n groupBy?: string[];\n having?: FindOptionsWhere;\n}\n\nexport interface FindAllOptions extends FindOneOptions {\n offset?: number;\n limit?: number;\n skipHook?: boolean;\n subQueries?: SubQuery[];\n}\n\nexport interface FindExistsOptions {\n where?: FindOptionsWhere;\n relations?: FindOptionsRelations;\n}\n\nexport interface FindCountOptions {\n where?: FindOptionsWhere;\n relations?: FindOptionsRelations;\n order?: FindOptionsOrder;\n offset?: number;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"FindOptionsTypes.js","sourceRoot":"","sources":["../../src/storage/FindOptionsTypes.ts"],"names":[],"mappings":"","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\nimport type { Expression, Variable } from 'sparqljs';\nimport type { OrArray, JSONArray, JSONObject } from '../util/Types';\nimport type { FindOperator } from './FindOperator';\nimport type { InverseRelationOperatorValue } from './operator/InverseRelation';\nimport type { InverseRelationOrderValue } from './operator/InverseRelationOrder';\n\nexport type FindOptionsSelect = string[] | {[key: string]: boolean | FindOptionsSelect };\n\nexport interface FindOneOptions {\n select?: FindOptionsSelect;\n where?: FindOptionsWhere;\n relations?: FindOptionsRelations;\n order?: FindOptionsOrder;\n skipFraming?: boolean;\n group?: Variable;\n entitySelectVariable?: Variable;\n bypassCache?: boolean;\n}\n\nexport type FindOptionsRelationsValue =\n | boolean\n | FindOptionsRelations\n | FindOperator<InverseRelationOperatorValue, 'inverseRelation'>;\n\n// eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style\nexport type FindOptionsRelations = {\n [k: string]: FindOptionsRelationsValue;\n};\n\nexport type FindOptionsOrderValue = 'ASC' | 'DESC' | 'asc' | 'desc' | 1 | -1;\n\nexport type FindOptionsOrder = Record<\nstring,\nFindOptionsOrderValue | FindOperator<InverseRelationOrderValue, 'inverseRelationOrder'>\n>;\n\nexport type FieldPrimitiveValue = boolean | number | string | Date;\n\nexport type JsonValueObject = {\n '@value': FieldPrimitiveValue | JSONObject | JSONArray;\n '@type': '@json';\n};\n\nexport type LanguageValueObject = {\n '@value': string;\n '@language': string;\n '@direction': string;\n};\n\nexport type NonJsonValueObject = {\n '@value': FieldPrimitiveValue;\n '@type': string;\n};\n\nexport type ValueWhereFieldObject = JsonValueObject | LanguageValueObject | NonJsonValueObject;\n\nexport type FindOptionsWhereField =\n | OrArray<FieldPrimitiveValue>\n | ValueWhereFieldObject\n | FindOptionsWhere\n | OrArray<FindOperator<any, any>>\n | BindPattern[];\n\nexport type IdFindOptionsWhereField = string | FindOperator<any, 'in' | 'not' | 'equal' | 'inversePath' | 'contains'>;\n\nexport type TypeFindOptionsWhereField =\n | string\n | FindOperator<string | string[] | FindOptionsWhere, 'in' | 'not' | 'equal' | 'inverse' | 'contains'>;\n\nexport interface BindPattern {\n expression: Expression;\n variable: Variable;\n}\n\nexport interface FindOptionsWhere {\n type?: TypeFindOptionsWhereField;\n id?: IdFindOptionsWhereField;\n binds?: BindPattern[];\n and?: FindOptionsWhere[];\n or?: FindOptionsWhere[];\n bypassCache?: boolean;\n [k: string]: FindOptionsWhereField | BindPattern[] | FindOptionsWhere[] | boolean | undefined;\n}\n\n// Add these new types\nexport interface SubQuery {\n select: Variable[];\n where: FindOptionsWhere;\n groupBy?: string[];\n having?: FindOptionsWhere;\n}\n\nexport interface FindAllOptions extends FindOneOptions {\n offset?: number;\n limit?: number;\n skipHook?: boolean;\n subQueries?: SubQuery[];\n}\n\nexport interface FindExistsOptions {\n where?: FindOptionsWhere;\n relations?: FindOptionsRelations;\n}\n\nexport interface FindCountOptions {\n where?: FindOptionsWhere;\n relations?: FindOptionsRelations;\n order?: FindOptionsOrder;\n offset?: number;\n bypassCache?: boolean;\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ReadCacheOperation } from '../SklEngineOptions';
|
|
2
|
+
export interface BuildReadCacheKeyInput {
|
|
3
|
+
operation: ReadCacheOperation;
|
|
4
|
+
args: readonly unknown[];
|
|
5
|
+
endpointUrl?: string;
|
|
6
|
+
namespace?: string;
|
|
7
|
+
keyHint?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function buildReadCacheKey(input: BuildReadCacheKeyInput): string;
|
|
10
|
+
export declare class ReadCacheSingleflight {
|
|
11
|
+
private readonly inflight;
|
|
12
|
+
do<T>(key: string, fn: () => Promise<T>): Promise<T>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=ReadCacheHelper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReadCacheHelper.d.ts","sourceRoot":"","sources":["../../src/util/ReadCacheHelper.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,MAAM,WAAW,sBAAsB;IACrC,SAAS,EAAE,kBAAkB,CAAC;IAC9B,IAAI,EAAE,SAAS,OAAO,EAAE,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAuBD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,GAAG,MAAM,CASvE;AAED,qBAAa,qBAAqB;IAChC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAuC;IAEnD,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;CAiBlE"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ReadCacheSingleflight = exports.buildReadCacheKey = void 0;
|
|
7
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
8
|
+
function stableStringify(value) {
|
|
9
|
+
if (value === null)
|
|
10
|
+
return 'null';
|
|
11
|
+
const valueType = typeof value;
|
|
12
|
+
if (valueType === 'number' || valueType === 'boolean')
|
|
13
|
+
return String(value);
|
|
14
|
+
if (valueType === 'string')
|
|
15
|
+
return JSON.stringify(value);
|
|
16
|
+
if (valueType !== 'object') {
|
|
17
|
+
const serializedPrimitive = JSON.stringify(value);
|
|
18
|
+
return serializedPrimitive ?? String(value);
|
|
19
|
+
}
|
|
20
|
+
if (Array.isArray(value)) {
|
|
21
|
+
return `[${value.map(stableStringify).join(',')}]`;
|
|
22
|
+
}
|
|
23
|
+
const objectValue = value;
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/require-array-sort-compare
|
|
25
|
+
const keys = Object.keys(objectValue).sort();
|
|
26
|
+
return `{${keys.map((key) => `${JSON.stringify(key)}:${stableStringify(objectValue[key])}`).join(',')}}`;
|
|
27
|
+
}
|
|
28
|
+
function buildReadCacheKey(input) {
|
|
29
|
+
const keyParts = {
|
|
30
|
+
namespace: input.namespace ?? '',
|
|
31
|
+
endpointUrl: input.endpointUrl ?? '',
|
|
32
|
+
operation: input.operation,
|
|
33
|
+
keyHint: input.keyHint ?? '',
|
|
34
|
+
args: input.args
|
|
35
|
+
};
|
|
36
|
+
return crypto_1.default.createHash('sha256').update(stableStringify(keyParts)).digest('hex');
|
|
37
|
+
}
|
|
38
|
+
exports.buildReadCacheKey = buildReadCacheKey;
|
|
39
|
+
class ReadCacheSingleflight {
|
|
40
|
+
constructor() {
|
|
41
|
+
this.inflight = new Map();
|
|
42
|
+
}
|
|
43
|
+
async do(key, fn) {
|
|
44
|
+
const existing = this.inflight.get(key);
|
|
45
|
+
if (existing) {
|
|
46
|
+
return existing;
|
|
47
|
+
}
|
|
48
|
+
const promise = (async () => {
|
|
49
|
+
try {
|
|
50
|
+
return await fn();
|
|
51
|
+
}
|
|
52
|
+
finally {
|
|
53
|
+
this.inflight.delete(key);
|
|
54
|
+
}
|
|
55
|
+
})();
|
|
56
|
+
this.inflight.set(key, promise);
|
|
57
|
+
return promise;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.ReadCacheSingleflight = ReadCacheSingleflight;
|
|
61
|
+
//# sourceMappingURL=ReadCacheHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReadCacheHelper.js","sourceRoot":"","sources":["../../src/util/ReadCacheHelper.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAW5B,SAAS,eAAe,CAAC,KAAc;IACrC,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,MAAM,CAAC;IAElC,MAAM,SAAS,GAAG,OAAO,KAAK,CAAC;IAC/B,IAAI,SAAS,KAAK,QAAQ,IAAI,SAAS,KAAK,SAAS;QAAE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IAC5E,IAAI,SAAS,KAAK,Q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aAAQ,GAAG,IAAI,GAAG,EAA4B,CAAC;IAmBlE,CAAC;IAjBQ,KAAK,CAAC,EAAE,CAAI,GAAW,EAAE,EAAoB;QAClD,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAA2B,CAAC;QAClE,IAAI,QAAQ,EAAE;YACZ,OAAO,QAAQ,CAAC;SACjB;QAED,MAAM,OAAO,GAAG,CAAC,KAAK,IAAe,EAAE;YACrC,IAAI;gBACF,OAAO,MAAM,EAAE,EAAE,CAAC;aACnB;oBAAS;gBACR,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;aAC3B;QACH,CAAC,CAAC,EAAE,CAAC;QAEL,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,OAA2B,CAAC,CAAC;QACpD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AApBD,sDAoBC","sourcesContent":["import crypto from 'crypto';\nimport type { ReadCacheOperation } from '../SklEngineOptions';\n\nexport interface BuildReadCacheKeyInput {\n operation: ReadCacheOperation;\n args: readonly unknown[];\n endpointUrl?: string;\n namespace?: string;\n keyHint?: string;\n}\n\nfunction stableStringify(value: unknown): string {\n if (value === null) return 'null';\n\n const valueType = typeof value;\n if (valueType === 'number' || valueType === 'boolean') return String(value);\n if (valueType === 'string') return JSON.stringify(value);\n if (valueType !== 'object') {\n const serializedPrimitive = JSON.stringify(value);\n return serializedPrimitive ?? String(value);\n }\n\n if (Array.isArray(value)) {\n return `[${value.map(stableStringify).join(',')}]`;\n }\n\n const objectValue = value as Record<string, unknown>;\n // eslint-disable-next-line @typescript-eslint/require-array-sort-compare\n const keys = Object.keys(objectValue).sort();\n return `{${keys.map((key) => `${JSON.stringify(key)}:${stableStringify(objectValue[key])}`).join(',')}}`;\n}\n\nexport function buildReadCacheKey(input: BuildReadCacheKeyInput): string {\n const keyParts = {\n namespace: input.namespace ?? '',\n endpointUrl: input.endpointUrl ?? '',\n operation: input.operation,\n keyHint: input.keyHint ?? '',\n args: input.args\n };\n return crypto.createHash('sha256').update(stableStringify(keyParts)).digest('hex');\n}\n\nexport class ReadCacheSingleflight {\n private readonly inflight = new Map<string, Promise<unknown>>();\n\n public async do<T>(key: string, fn: () => Promise<T>): Promise<T> {\n const existing = this.inflight.get(key) as Promise<T> | undefined;\n if (existing) {\n return existing;\n }\n\n const promise = (async(): Promise<T> => {\n try {\n return await fn();\n } finally {\n this.inflight.delete(key);\n }\n })();\n\n this.inflight.set(key, promise as Promise<unknown>);\n return promise;\n }\n}\n"]}
|
package/package.json
CHANGED
package/src/SklEngine.ts
CHANGED
|
@@ -34,7 +34,7 @@ import type { ExecutionOptions } from './JsExecutor';
|
|
|
34
34
|
import type { ICodeExecutor } from './JsExecutor/types';
|
|
35
35
|
import { Logger } from './logger';
|
|
36
36
|
import { Mapper } from './mapping/Mapper';
|
|
37
|
-
import type { SklEngineOptions } from './SklEngineOptions';
|
|
37
|
+
import type { ReadCacheOperation, ReadCachePolicy, ReadCacheStore, SklEngineOptions } from './SklEngineOptions';
|
|
38
38
|
import type { FindOperator } from './storage/FindOperator';
|
|
39
39
|
import type { FindAllOptions, FindOneOptions, FindOptionsWhere } from './storage/FindOptionsTypes';
|
|
40
40
|
import type { GroupByOptions, GroupByResponse } from './storage/GroupOptionTypes';
|
|
@@ -48,6 +48,7 @@ import { ZeroOrMorePath } from './storage/operator/ZeroOrMorePath';
|
|
|
48
48
|
import type { QueryAdapter, RawQueryResult } from './storage/query-adapter/QueryAdapter';
|
|
49
49
|
import { SparqlQueryAdapter } from './storage/query-adapter/sparql/SparqlQueryAdapter';
|
|
50
50
|
import { PerformanceLogger } from './util/PerformanceLogger';
|
|
51
|
+
import { buildReadCacheKey, ReadCacheSingleflight } from './util/ReadCacheHelper';
|
|
51
52
|
// Import './util/safeJsonStringify';
|
|
52
53
|
import type {
|
|
53
54
|
Callbacks,
|
|
@@ -82,6 +83,12 @@ export type CapabilityInterface = Record<string, CapabilityHandler>;
|
|
|
82
83
|
export type MappingResponseOption<T extends boolean> = T extends true ? JSONObject : NodeObject;
|
|
83
84
|
|
|
84
85
|
export type WriteOptions = { bypassHooks?: boolean };
|
|
86
|
+
const DEFAULT_READ_CACHE_TTL_MS = 60_000;
|
|
87
|
+
const READ_CACHE_ENVELOPE_MARKER = '__sklReadCacheEnvelopeV1';
|
|
88
|
+
type ReadCacheEnvelope<T> = {
|
|
89
|
+
[READ_CACHE_ENVELOPE_MARKER]: true;
|
|
90
|
+
value: T;
|
|
91
|
+
};
|
|
85
92
|
|
|
86
93
|
export class SKLEngine implements SKLEngineInterface {
|
|
87
94
|
private readonly queryAdapter: QueryAdapter;
|
|
@@ -94,6 +101,10 @@ export class SKLEngine implements SKLEngineInterface {
|
|
|
94
101
|
private readonly skdsEndpointUrl: string;
|
|
95
102
|
private readonly scriptPath: string;
|
|
96
103
|
private readonly logger: Logger;
|
|
104
|
+
private readonly readCache?: ReadCacheStore;
|
|
105
|
+
private readonly readCachePolicy?: ReadCachePolicy;
|
|
106
|
+
private readonly readCacheNamespace?: string;
|
|
107
|
+
private readonly readCacheSingleflight = new ReadCacheSingleflight();
|
|
97
108
|
public constructor(options: SklEngineOptions) {
|
|
98
109
|
this.queryAdapter = new SparqlQueryAdapter(options);
|
|
99
110
|
this.disableValidation = options.disableValidation;
|
|
@@ -101,6 +112,9 @@ export class SKLEngine implements SKLEngineInterface {
|
|
|
101
112
|
this.inputFiles = options.inputFiles;
|
|
102
113
|
this.skdsEndpointUrl = (options as any).endpointUrl;
|
|
103
114
|
this.scriptPath = (options as any).scriptPath;
|
|
115
|
+
this.readCache = options.readCache;
|
|
116
|
+
this.readCachePolicy = options.readCachePolicy;
|
|
117
|
+
this.readCacheNamespace = options.readCacheNamespace;
|
|
104
118
|
if (options.functions) {
|
|
105
119
|
this.functions = Object.fromEntries(
|
|
106
120
|
Object.entries(options.functions).map(([key, func]) => [
|
|
@@ -145,21 +159,137 @@ export class SKLEngine implements SKLEngineInterface {
|
|
|
145
159
|
return await this.queryAdapter.executeRawConstructQuery(query, frame);
|
|
146
160
|
}
|
|
147
161
|
|
|
162
|
+
private cloneForReadCache<T>(value: T): T {
|
|
163
|
+
try {
|
|
164
|
+
return structuredClone(value);
|
|
165
|
+
} catch {
|
|
166
|
+
return value;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
private wrapReadCacheValue<T>(value: T): ReadCacheEnvelope<T> {
|
|
171
|
+
return {
|
|
172
|
+
[READ_CACHE_ENVELOPE_MARKER]: true,
|
|
173
|
+
value
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
private isReadCacheEnvelope<T>(value: unknown): value is ReadCacheEnvelope<T> {
|
|
178
|
+
if (!value || typeof value !== 'object') {
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
181
|
+
return (value as Record<string, unknown>)[READ_CACHE_ENVELOPE_MARKER] === true;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
private stripBypassCacheFromFindOneOptions(options?: FindOneOptions): FindOneOptions | undefined {
|
|
185
|
+
if (!options) {
|
|
186
|
+
return options;
|
|
187
|
+
}
|
|
188
|
+
const { bypassCache, ...rest } = options;
|
|
189
|
+
return rest;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
private stripBypassCacheFromFindAllOptions(options?: FindAllOptions): FindAllOptions | undefined {
|
|
193
|
+
if (!options) {
|
|
194
|
+
return options;
|
|
195
|
+
}
|
|
196
|
+
const { bypassCache, ...rest } = options;
|
|
197
|
+
return rest;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
private stripBypassCacheFromWhere(where?: FindOptionsWhere): FindOptionsWhere | undefined {
|
|
201
|
+
if (!where) {
|
|
202
|
+
return where;
|
|
203
|
+
}
|
|
204
|
+
const { bypassCache, ...rest } = where;
|
|
205
|
+
return rest;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
private async runReadWithCache<T>(params: {
|
|
209
|
+
operation: ReadCacheOperation;
|
|
210
|
+
args: readonly unknown[];
|
|
211
|
+
bypassCache?: boolean;
|
|
212
|
+
execute: () => Promise<T>;
|
|
213
|
+
}): Promise<T> {
|
|
214
|
+
if (params.bypassCache) {
|
|
215
|
+
return await params.execute();
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (!this.readCache || !this.readCachePolicy) {
|
|
219
|
+
return await params.execute();
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const policyDecision = this.readCachePolicy({
|
|
223
|
+
operation: params.operation,
|
|
224
|
+
args: params.args,
|
|
225
|
+
endpointUrl: this.skdsEndpointUrl,
|
|
226
|
+
namespace: this.readCacheNamespace
|
|
227
|
+
});
|
|
228
|
+
if (!policyDecision.cache) {
|
|
229
|
+
return await params.execute();
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const ttlMs = policyDecision.ttlMs ?? DEFAULT_READ_CACHE_TTL_MS;
|
|
233
|
+
if (ttlMs <= 0) {
|
|
234
|
+
return await params.execute();
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
const cacheKey = buildReadCacheKey({
|
|
238
|
+
operation: params.operation,
|
|
239
|
+
args: params.args,
|
|
240
|
+
endpointUrl: this.skdsEndpointUrl,
|
|
241
|
+
namespace: this.readCacheNamespace,
|
|
242
|
+
keyHint: policyDecision.keyHint
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
return await this.readCacheSingleflight.do(cacheKey, async() => {
|
|
246
|
+
try {
|
|
247
|
+
const cached = await this.readCache?.get(cacheKey);
|
|
248
|
+
if (cached !== undefined) {
|
|
249
|
+
if (this.isReadCacheEnvelope<T>(cached)) {
|
|
250
|
+
return this.cloneForReadCache(cached.value);
|
|
251
|
+
}
|
|
252
|
+
return this.cloneForReadCache(cached as T);
|
|
253
|
+
}
|
|
254
|
+
} catch (error) {
|
|
255
|
+
this.logger.debug('Read cache lookup failed; continuing without cache', error as any);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
const result = await params.execute();
|
|
259
|
+
|
|
260
|
+
try {
|
|
261
|
+
await this.readCache?.set(cacheKey, this.wrapReadCacheValue(this.cloneForReadCache(result)), ttlMs);
|
|
262
|
+
} catch (error) {
|
|
263
|
+
this.logger.debug('Read cache write failed; continuing without cache', error as any);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
return result;
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
|
|
148
270
|
public async find(options?: FindOneOptions): Promise<Entity> {
|
|
271
|
+
const bypassCache = options?.bypassCache;
|
|
272
|
+
const optionsWithoutBypass = this.stripBypassCacheFromFindOneOptions(options);
|
|
273
|
+
|
|
149
274
|
return PerformanceLogger.withSpanRoot('SklEngine.find', async() => {
|
|
150
275
|
const context = {
|
|
151
276
|
entities: [],
|
|
152
277
|
operation: 'find',
|
|
153
|
-
operationParameters: { options },
|
|
278
|
+
operationParameters: { options: optionsWithoutBypass },
|
|
154
279
|
sklEngine: this
|
|
155
280
|
};
|
|
156
281
|
|
|
157
282
|
await globalHooks.execute(HookTypes.READ, HookStages.BEFORE, context);
|
|
158
283
|
|
|
159
284
|
try {
|
|
160
|
-
const entity = await this.
|
|
285
|
+
const entity = await this.runReadWithCache({
|
|
286
|
+
operation: 'find',
|
|
287
|
+
args: [optionsWithoutBypass],
|
|
288
|
+
bypassCache,
|
|
289
|
+
execute: async() => await this.queryAdapter.find(optionsWithoutBypass)
|
|
290
|
+
});
|
|
161
291
|
if (!entity) {
|
|
162
|
-
throw new Error(`No schema found with fields matching ${JSON.stringify(
|
|
292
|
+
throw new Error(`No schema found with fields matching ${JSON.stringify(optionsWithoutBypass)}`);
|
|
163
293
|
}
|
|
164
294
|
|
|
165
295
|
const updatedContext = { ...context, entities: [entity]};
|
|
@@ -170,31 +300,39 @@ export class SKLEngine implements SKLEngineInterface {
|
|
|
170
300
|
await globalHooks.execute(HookTypes.READ, HookStages.ERROR, context, error);
|
|
171
301
|
throw error;
|
|
172
302
|
}
|
|
173
|
-
}, { options });
|
|
303
|
+
}, { options: optionsWithoutBypass });
|
|
174
304
|
}
|
|
175
305
|
|
|
176
306
|
public async findBy(where: FindOptionsWhere, notFoundErrorMessage?: string): Promise<Entity> {
|
|
307
|
+
const bypassCache = where?.bypassCache;
|
|
308
|
+
const whereWithoutBypass = this.stripBypassCacheFromWhere(where)!;
|
|
309
|
+
|
|
177
310
|
return PerformanceLogger.withSpanRoot('SklEngine.findBy', async() => {
|
|
178
311
|
const context = {
|
|
179
312
|
entities: [],
|
|
180
313
|
operation: 'findBy',
|
|
181
|
-
operationParameters: { where },
|
|
314
|
+
operationParameters: { where: whereWithoutBypass },
|
|
182
315
|
sklEngine: this
|
|
183
316
|
};
|
|
184
317
|
await globalHooks.execute(HookTypes.READ, HookStages.BEFORE, context);
|
|
185
318
|
try {
|
|
186
|
-
const entity = await this.
|
|
319
|
+
const entity = await this.runReadWithCache({
|
|
320
|
+
operation: 'findBy',
|
|
321
|
+
args: [whereWithoutBypass, notFoundErrorMessage],
|
|
322
|
+
bypassCache,
|
|
323
|
+
execute: async() => await this.queryAdapter.findBy(whereWithoutBypass)
|
|
324
|
+
});
|
|
187
325
|
if (entity) {
|
|
188
326
|
const updatedContext = { ...context, entities: [entity]};
|
|
189
327
|
await globalHooks.execute(HookTypes.READ, HookStages.AFTER, updatedContext, entity);
|
|
190
328
|
return entity;
|
|
191
329
|
}
|
|
192
|
-
throw new Error(notFoundErrorMessage ?? `No schema found with fields matching ${JSON.stringify(
|
|
330
|
+
throw new Error(notFoundErrorMessage ?? `No schema found with fields matching ${JSON.stringify(whereWithoutBypass)}`);
|
|
193
331
|
} catch (error: unknown) {
|
|
194
332
|
await globalHooks.execute(HookTypes.READ, HookStages.ERROR, context, error);
|
|
195
333
|
throw error;
|
|
196
334
|
}
|
|
197
|
-
}, { where });
|
|
335
|
+
}, { where: whereWithoutBypass });
|
|
198
336
|
}
|
|
199
337
|
|
|
200
338
|
public async findByIfExists(options: FindOptionsWhere): Promise<Entity | undefined> {
|
|
@@ -207,16 +345,24 @@ export class SKLEngine implements SKLEngineInterface {
|
|
|
207
345
|
}
|
|
208
346
|
|
|
209
347
|
public async findAll(options?: FindAllOptions): Promise<Entity[]> {
|
|
348
|
+
const bypassCache = options?.bypassCache;
|
|
349
|
+
const optionsWithoutBypass = this.stripBypassCacheFromFindAllOptions(options);
|
|
350
|
+
|
|
210
351
|
return PerformanceLogger.withSpanRoot('SklEngine.findAll', async() => {
|
|
211
352
|
const context = {
|
|
212
353
|
entities: [],
|
|
213
354
|
operation: 'findAll',
|
|
214
|
-
operationParameters: { options },
|
|
355
|
+
operationParameters: { options: optionsWithoutBypass },
|
|
215
356
|
sklEngine: this
|
|
216
357
|
};
|
|
217
358
|
await globalHooks.execute(HookTypes.READ, HookStages.BEFORE, context);
|
|
218
359
|
try {
|
|
219
|
-
const entities = await this.
|
|
360
|
+
const entities = await this.runReadWithCache({
|
|
361
|
+
operation: 'findAll',
|
|
362
|
+
args: [optionsWithoutBypass],
|
|
363
|
+
bypassCache,
|
|
364
|
+
execute: async() => await this.queryAdapter.findAll(optionsWithoutBypass)
|
|
365
|
+
});
|
|
220
366
|
const updatedContext = { ...context, entities };
|
|
221
367
|
await globalHooks.execute(HookTypes.READ, HookStages.AFTER, updatedContext, entities);
|
|
222
368
|
return entities;
|
|
@@ -224,7 +370,7 @@ export class SKLEngine implements SKLEngineInterface {
|
|
|
224
370
|
await globalHooks.execute(HookTypes.READ, HookStages.ERROR, context, error);
|
|
225
371
|
throw error;
|
|
226
372
|
}
|
|
227
|
-
}, { options });
|
|
373
|
+
}, { options: optionsWithoutBypass });
|
|
228
374
|
}
|
|
229
375
|
|
|
230
376
|
public async groupBy(options: GroupByOptions): Promise<GroupByResponse> {
|
|
@@ -274,7 +420,20 @@ export class SKLEngine implements SKLEngineInterface {
|
|
|
274
420
|
}
|
|
275
421
|
|
|
276
422
|
public async count(options?: FindAllOptions): Promise<number> {
|
|
277
|
-
|
|
423
|
+
const bypassCache = options?.bypassCache;
|
|
424
|
+
const optionsWithoutBypass = this.stripBypassCacheFromFindAllOptions(options);
|
|
425
|
+
|
|
426
|
+
return PerformanceLogger.withSpanRoot(
|
|
427
|
+
'SklEngine.count',
|
|
428
|
+
async() =>
|
|
429
|
+
await this.runReadWithCache({
|
|
430
|
+
operation: 'count',
|
|
431
|
+
args: [optionsWithoutBypass],
|
|
432
|
+
bypassCache,
|
|
433
|
+
execute: async() => await this.queryAdapter.count(optionsWithoutBypass)
|
|
434
|
+
}),
|
|
435
|
+
{ options: optionsWithoutBypass }
|
|
436
|
+
);
|
|
278
437
|
}
|
|
279
438
|
|
|
280
439
|
public async save(entity: Entity, options?: WriteOptions): Promise<Entity>;
|
package/src/SklEngineOptions.ts
CHANGED
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
import type { SparqlQueryAdapterOptions } from './storage/query-adapter/sparql/SparqlQueryAdapterOptions';
|
|
2
2
|
import type { Callbacks } from './util/Types';
|
|
3
3
|
|
|
4
|
+
export type ReadCacheOperation = 'find' | 'findBy' | 'findAll' | 'count';
|
|
5
|
+
|
|
6
|
+
export interface ReadCacheStore {
|
|
7
|
+
get: (key: string) => Promise<unknown | undefined>;
|
|
8
|
+
set: (key: string, value: unknown, ttlMs: number) => Promise<void>;
|
|
9
|
+
delete?: (key: string) => Promise<void>;
|
|
10
|
+
clear?: () => Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface ReadCachePolicyInput {
|
|
14
|
+
operation: ReadCacheOperation;
|
|
15
|
+
args: readonly unknown[];
|
|
16
|
+
endpointUrl?: string;
|
|
17
|
+
namespace?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface ReadCachePolicyDecision {
|
|
21
|
+
cache: boolean;
|
|
22
|
+
ttlMs?: number;
|
|
23
|
+
keyHint?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type ReadCachePolicy = (input: ReadCachePolicyInput) => ReadCachePolicyDecision;
|
|
27
|
+
|
|
4
28
|
export type SklEngineOptions = SparqlQueryAdapterOptions & {
|
|
5
29
|
/**
|
|
6
30
|
* Callbacks to execute upon events.
|
|
@@ -25,4 +49,20 @@ export type SklEngineOptions = SparqlQueryAdapterOptions & {
|
|
|
25
49
|
* The path to the executor script.
|
|
26
50
|
*/
|
|
27
51
|
readonly scriptPath?: string;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Optional read cache store used for select read operations.
|
|
55
|
+
* Cache decisions are made by readCachePolicy.
|
|
56
|
+
*/
|
|
57
|
+
readonly readCache?: ReadCacheStore;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Optional policy that decides whether a given read operation should be cached.
|
|
61
|
+
*/
|
|
62
|
+
readonly readCachePolicy?: ReadCachePolicy;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Optional namespace to scope cache keys (for example tenant/account isolation).
|
|
66
|
+
*/
|
|
67
|
+
readonly readCacheNamespace?: string;
|
|
28
68
|
};
|
package/src/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ export * from './hooks/types';
|
|
|
7
7
|
export * from './JsExecutor';
|
|
8
8
|
export * from './mapping/Mapper';
|
|
9
9
|
export * from './SklEngine';
|
|
10
|
+
export * from './SklEngineOptions';
|
|
10
11
|
// Storage
|
|
11
12
|
export * from './storage/FindOperator';
|
|
12
13
|
export * from './storage/FindOptionsTypes';
|
|
@@ -15,6 +15,7 @@ export interface FindOneOptions {
|
|
|
15
15
|
skipFraming?: boolean;
|
|
16
16
|
group?: Variable;
|
|
17
17
|
entitySelectVariable?: Variable;
|
|
18
|
+
bypassCache?: boolean;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
export type FindOptionsRelationsValue =
|
|
@@ -78,7 +79,8 @@ export interface FindOptionsWhere {
|
|
|
78
79
|
binds?: BindPattern[];
|
|
79
80
|
and?: FindOptionsWhere[];
|
|
80
81
|
or?: FindOptionsWhere[];
|
|
81
|
-
|
|
82
|
+
bypassCache?: boolean;
|
|
83
|
+
[k: string]: FindOptionsWhereField | BindPattern[] | FindOptionsWhere[] | boolean | undefined;
|
|
82
84
|
}
|
|
83
85
|
|
|
84
86
|
// Add these new types
|
|
@@ -106,4 +108,5 @@ export interface FindCountOptions {
|
|
|
106
108
|
relations?: FindOptionsRelations;
|
|
107
109
|
order?: FindOptionsOrder;
|
|
108
110
|
offset?: number;
|
|
111
|
+
bypassCache?: boolean;
|
|
109
112
|
}
|