@knaus94/prisma-extension-cache-manager 0.0.2
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/README.md +1 -0
- package/dist/index.d.mts +43 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.global.js +168 -0
- package/dist/index.js +94 -0
- package/dist/index.mjs +73 -0
- package/package.json +63 -0
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# prisma-extension-cache-manager
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as _prisma_client_extension from '@prisma/client/extension';
|
|
2
|
+
import { Prisma } from '@prisma/client/extension';
|
|
3
|
+
import * as _prisma_client_runtime_library from '@prisma/client/runtime/library';
|
|
4
|
+
import * as cache_manager from 'cache-manager';
|
|
5
|
+
import { Cache } from 'cache-manager';
|
|
6
|
+
|
|
7
|
+
declare const REQUIRED_ARGS_OPERATIONS: readonly ["findUnique", "findUniqueOrThrow", "groupBy"];
|
|
8
|
+
declare const OPTIONAL_ARGS_OPERATIONS: readonly ["findMany", "findFirst", "findFirstOrThrow", "count"];
|
|
9
|
+
type RequiredArgsOperation = (typeof REQUIRED_ARGS_OPERATIONS)[number];
|
|
10
|
+
type OptionalArgsOperation = (typeof OPTIONAL_ARGS_OPERATIONS)[number];
|
|
11
|
+
type RequiredArgsFunction<O extends RequiredArgsOperation> = <T, A>(this: T, args: Prisma.Exact<A, Prisma.Args<T, O> & PrismaCacheArgs>) => Promise<Prisma.Result<T, A, O>>;
|
|
12
|
+
type OptionalArgsFunction<O extends OptionalArgsOperation> = <T, A>(this: T, args?: Prisma.Exact<A, Prisma.Args<T, O> & PrismaCacheArgs>) => Promise<Prisma.Result<T, A, O>>;
|
|
13
|
+
type ModelExtension = {
|
|
14
|
+
[O1 in RequiredArgsOperation]: RequiredArgsFunction<O1>;
|
|
15
|
+
} & {
|
|
16
|
+
[O2 in OptionalArgsOperation]: OptionalArgsFunction<O2>;
|
|
17
|
+
};
|
|
18
|
+
interface CacheOptions {
|
|
19
|
+
/**
|
|
20
|
+
* Cache key
|
|
21
|
+
*/
|
|
22
|
+
key: string;
|
|
23
|
+
/**
|
|
24
|
+
* Time to live
|
|
25
|
+
*/
|
|
26
|
+
ttl?: number;
|
|
27
|
+
}
|
|
28
|
+
interface PrismaCacheArgs {
|
|
29
|
+
cache?: boolean | CacheOptions;
|
|
30
|
+
}
|
|
31
|
+
interface PrismaRedisCacheConfig {
|
|
32
|
+
cache: Cache;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
declare const _default: ({ cache }: PrismaRedisCacheConfig) => (client: any) => _prisma_client_extension.PrismaClientExtends<_prisma_client_runtime_library.InternalArgs<{}, {
|
|
36
|
+
$allModels: ModelExtension;
|
|
37
|
+
}, {}, {
|
|
38
|
+
cache: {
|
|
39
|
+
store: cache_manager.Cache;
|
|
40
|
+
};
|
|
41
|
+
}>>;
|
|
42
|
+
|
|
43
|
+
export { _default as default };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as _prisma_client_extension from '@prisma/client/extension';
|
|
2
|
+
import { Prisma } from '@prisma/client/extension';
|
|
3
|
+
import * as _prisma_client_runtime_library from '@prisma/client/runtime/library';
|
|
4
|
+
import * as cache_manager from 'cache-manager';
|
|
5
|
+
import { Cache } from 'cache-manager';
|
|
6
|
+
|
|
7
|
+
declare const REQUIRED_ARGS_OPERATIONS: readonly ["findUnique", "findUniqueOrThrow", "groupBy"];
|
|
8
|
+
declare const OPTIONAL_ARGS_OPERATIONS: readonly ["findMany", "findFirst", "findFirstOrThrow", "count"];
|
|
9
|
+
type RequiredArgsOperation = (typeof REQUIRED_ARGS_OPERATIONS)[number];
|
|
10
|
+
type OptionalArgsOperation = (typeof OPTIONAL_ARGS_OPERATIONS)[number];
|
|
11
|
+
type RequiredArgsFunction<O extends RequiredArgsOperation> = <T, A>(this: T, args: Prisma.Exact<A, Prisma.Args<T, O> & PrismaCacheArgs>) => Promise<Prisma.Result<T, A, O>>;
|
|
12
|
+
type OptionalArgsFunction<O extends OptionalArgsOperation> = <T, A>(this: T, args?: Prisma.Exact<A, Prisma.Args<T, O> & PrismaCacheArgs>) => Promise<Prisma.Result<T, A, O>>;
|
|
13
|
+
type ModelExtension = {
|
|
14
|
+
[O1 in RequiredArgsOperation]: RequiredArgsFunction<O1>;
|
|
15
|
+
} & {
|
|
16
|
+
[O2 in OptionalArgsOperation]: OptionalArgsFunction<O2>;
|
|
17
|
+
};
|
|
18
|
+
interface CacheOptions {
|
|
19
|
+
/**
|
|
20
|
+
* Cache key
|
|
21
|
+
*/
|
|
22
|
+
key: string;
|
|
23
|
+
/**
|
|
24
|
+
* Time to live
|
|
25
|
+
*/
|
|
26
|
+
ttl?: number;
|
|
27
|
+
}
|
|
28
|
+
interface PrismaCacheArgs {
|
|
29
|
+
cache?: boolean | CacheOptions;
|
|
30
|
+
}
|
|
31
|
+
interface PrismaRedisCacheConfig {
|
|
32
|
+
cache: Cache;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
declare const _default: ({ cache }: PrismaRedisCacheConfig) => (client: any) => _prisma_client_extension.PrismaClientExtends<_prisma_client_runtime_library.InternalArgs<{}, {
|
|
36
|
+
$allModels: ModelExtension;
|
|
37
|
+
}, {}, {
|
|
38
|
+
cache: {
|
|
39
|
+
store: cache_manager.Cache;
|
|
40
|
+
};
|
|
41
|
+
}>>;
|
|
42
|
+
|
|
43
|
+
export { _default as default };
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
(() => {
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
10
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
|
|
29
|
+
// node_modules/@prisma/client/scripts/default-index.js
|
|
30
|
+
var require_default_index = __commonJS({
|
|
31
|
+
"node_modules/@prisma/client/scripts/default-index.js"(exports, module) {
|
|
32
|
+
"use strict";
|
|
33
|
+
var __defProp2 = Object.defineProperty;
|
|
34
|
+
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
35
|
+
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
36
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
37
|
+
var __export = (target, all) => {
|
|
38
|
+
for (var name in all)
|
|
39
|
+
__defProp2(target, name, { get: all[name], enumerable: true });
|
|
40
|
+
};
|
|
41
|
+
var __copyProps2 = (to, from, except, desc) => {
|
|
42
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
43
|
+
for (let key of __getOwnPropNames2(from))
|
|
44
|
+
if (!__hasOwnProp2.call(to, key) && key !== except)
|
|
45
|
+
__defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
|
|
46
|
+
}
|
|
47
|
+
return to;
|
|
48
|
+
};
|
|
49
|
+
var __toCommonJS = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
|
|
50
|
+
var default_index_exports = {};
|
|
51
|
+
__export(default_index_exports, {
|
|
52
|
+
Prisma: () => Prisma2,
|
|
53
|
+
PrismaClient: () => PrismaClient,
|
|
54
|
+
default: () => default_index_default
|
|
55
|
+
});
|
|
56
|
+
module.exports = __toCommonJS(default_index_exports);
|
|
57
|
+
var prisma = {
|
|
58
|
+
enginesVersion: "0a83d8541752d7582de2ebc1ece46519ce72a848"
|
|
59
|
+
};
|
|
60
|
+
var version = "5.8.0";
|
|
61
|
+
var clientVersion = version;
|
|
62
|
+
var PrismaClient = class {
|
|
63
|
+
constructor() {
|
|
64
|
+
throw new Error(
|
|
65
|
+
`@prisma/client did not initialize yet. Please run "prisma generate" and try to import it again.
|
|
66
|
+
In case this error is unexpected for you, please report it in https://github.com/prisma/prisma/issues`
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
function defineExtension(ext) {
|
|
71
|
+
if (typeof ext === "function") {
|
|
72
|
+
return ext;
|
|
73
|
+
}
|
|
74
|
+
return (client) => client.$extends(ext);
|
|
75
|
+
}
|
|
76
|
+
function getExtensionContext(that) {
|
|
77
|
+
return that;
|
|
78
|
+
}
|
|
79
|
+
var Prisma2 = {
|
|
80
|
+
defineExtension,
|
|
81
|
+
getExtensionContext,
|
|
82
|
+
prismaVersion: { client: clientVersion, engine: prisma.enginesVersion }
|
|
83
|
+
};
|
|
84
|
+
var default_index_default = { Prisma: Prisma2 };
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// node_modules/@prisma/client/extension.js
|
|
89
|
+
var require_extension = __commonJS({
|
|
90
|
+
"node_modules/@prisma/client/extension.js"(exports, module) {
|
|
91
|
+
"use strict";
|
|
92
|
+
module.exports = {
|
|
93
|
+
...require_default_index()
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// src/index.ts
|
|
99
|
+
var import_extension = __toESM(require_extension());
|
|
100
|
+
|
|
101
|
+
// src/types.ts
|
|
102
|
+
var REQUIRED_ARGS_OPERATIONS = [
|
|
103
|
+
"findUnique",
|
|
104
|
+
"findUniqueOrThrow",
|
|
105
|
+
"groupBy"
|
|
106
|
+
];
|
|
107
|
+
var OPTIONAL_ARGS_OPERATIONS = [
|
|
108
|
+
"findMany",
|
|
109
|
+
"findFirst",
|
|
110
|
+
"findFirstOrThrow",
|
|
111
|
+
"count"
|
|
112
|
+
];
|
|
113
|
+
var CACHE_OPERATIONS = [
|
|
114
|
+
...REQUIRED_ARGS_OPERATIONS,
|
|
115
|
+
...OPTIONAL_ARGS_OPERATIONS
|
|
116
|
+
];
|
|
117
|
+
|
|
118
|
+
// src/index.ts
|
|
119
|
+
var src_default = ({ cache }) => {
|
|
120
|
+
return import_extension.Prisma.defineExtension({
|
|
121
|
+
name: "prisma-extension-cache-manager",
|
|
122
|
+
client: {
|
|
123
|
+
cache: { store: cache }
|
|
124
|
+
},
|
|
125
|
+
model: {
|
|
126
|
+
$allModels: {}
|
|
127
|
+
},
|
|
128
|
+
query: {
|
|
129
|
+
$allModels: {
|
|
130
|
+
async $allOperations({ model, operation, args, query }) {
|
|
131
|
+
let result;
|
|
132
|
+
const useCache = ["boolean", "object"].includes(typeof args["cache"]) && args["cache"] !== null && CACHE_OPERATIONS.includes(operation);
|
|
133
|
+
if (!useCache)
|
|
134
|
+
return query(args);
|
|
135
|
+
const queryArgs = {
|
|
136
|
+
...args
|
|
137
|
+
};
|
|
138
|
+
delete queryArgs["cache"];
|
|
139
|
+
if (typeof args["cache"] === "boolean") {
|
|
140
|
+
const cacheKey = `prisma-${model}-${JSON.stringify(queryArgs)}`;
|
|
141
|
+
const cached2 = await cache.get(cacheKey);
|
|
142
|
+
if (cached2) {
|
|
143
|
+
return typeof cached2 === "string" ? JSON.parse(cached2) : cached2;
|
|
144
|
+
}
|
|
145
|
+
result = await query(queryArgs);
|
|
146
|
+
await cache.set(cacheKey, JSON.stringify(result));
|
|
147
|
+
return result;
|
|
148
|
+
}
|
|
149
|
+
const { key, ttl } = args["cache"];
|
|
150
|
+
const customCacheKey = key || `prisma-custom-${model}-${JSON.stringify(queryArgs)}`;
|
|
151
|
+
const cached = await cache.get(customCacheKey);
|
|
152
|
+
if (cached) {
|
|
153
|
+
return typeof cached === "string" ? JSON.parse(cached) : cached;
|
|
154
|
+
}
|
|
155
|
+
result = await query(queryArgs);
|
|
156
|
+
const value = JSON.stringify(result);
|
|
157
|
+
if (ttl) {
|
|
158
|
+
await cache.set(customCacheKey, value, ttl);
|
|
159
|
+
} else {
|
|
160
|
+
await cache.set(customCacheKey, value);
|
|
161
|
+
}
|
|
162
|
+
return result;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
};
|
|
168
|
+
})();
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
default: () => src_default
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(src_exports);
|
|
26
|
+
var import_extension = require("@prisma/client/extension");
|
|
27
|
+
|
|
28
|
+
// src/types.ts
|
|
29
|
+
var REQUIRED_ARGS_OPERATIONS = [
|
|
30
|
+
"findUnique",
|
|
31
|
+
"findUniqueOrThrow",
|
|
32
|
+
"groupBy"
|
|
33
|
+
];
|
|
34
|
+
var OPTIONAL_ARGS_OPERATIONS = [
|
|
35
|
+
"findMany",
|
|
36
|
+
"findFirst",
|
|
37
|
+
"findFirstOrThrow",
|
|
38
|
+
"count"
|
|
39
|
+
];
|
|
40
|
+
var CACHE_OPERATIONS = [
|
|
41
|
+
...REQUIRED_ARGS_OPERATIONS,
|
|
42
|
+
...OPTIONAL_ARGS_OPERATIONS
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
// src/index.ts
|
|
46
|
+
var src_default = ({ cache }) => {
|
|
47
|
+
return import_extension.Prisma.defineExtension({
|
|
48
|
+
name: "prisma-extension-cache-manager",
|
|
49
|
+
client: {
|
|
50
|
+
cache: { store: cache }
|
|
51
|
+
},
|
|
52
|
+
model: {
|
|
53
|
+
$allModels: {}
|
|
54
|
+
},
|
|
55
|
+
query: {
|
|
56
|
+
$allModels: {
|
|
57
|
+
async $allOperations({ model, operation, args, query }) {
|
|
58
|
+
let result;
|
|
59
|
+
const useCache = ["boolean", "object"].includes(typeof args["cache"]) && args["cache"] !== null && CACHE_OPERATIONS.includes(operation);
|
|
60
|
+
if (!useCache)
|
|
61
|
+
return query(args);
|
|
62
|
+
const queryArgs = {
|
|
63
|
+
...args
|
|
64
|
+
};
|
|
65
|
+
delete queryArgs["cache"];
|
|
66
|
+
if (typeof args["cache"] === "boolean") {
|
|
67
|
+
const cacheKey = `prisma-${model}-${JSON.stringify(queryArgs)}`;
|
|
68
|
+
const cached2 = await cache.get(cacheKey);
|
|
69
|
+
if (cached2) {
|
|
70
|
+
return typeof cached2 === "string" ? JSON.parse(cached2) : cached2;
|
|
71
|
+
}
|
|
72
|
+
result = await query(queryArgs);
|
|
73
|
+
await cache.set(cacheKey, JSON.stringify(result));
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
76
|
+
const { key, ttl } = args["cache"];
|
|
77
|
+
const customCacheKey = key || `prisma-custom-${model}-${JSON.stringify(queryArgs)}`;
|
|
78
|
+
const cached = await cache.get(customCacheKey);
|
|
79
|
+
if (cached) {
|
|
80
|
+
return typeof cached === "string" ? JSON.parse(cached) : cached;
|
|
81
|
+
}
|
|
82
|
+
result = await query(queryArgs);
|
|
83
|
+
const value = JSON.stringify(result);
|
|
84
|
+
if (ttl) {
|
|
85
|
+
await cache.set(customCacheKey, value, ttl);
|
|
86
|
+
} else {
|
|
87
|
+
await cache.set(customCacheKey, value);
|
|
88
|
+
}
|
|
89
|
+
return result;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
};
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { Prisma } from "@prisma/client/extension";
|
|
3
|
+
|
|
4
|
+
// src/types.ts
|
|
5
|
+
var REQUIRED_ARGS_OPERATIONS = [
|
|
6
|
+
"findUnique",
|
|
7
|
+
"findUniqueOrThrow",
|
|
8
|
+
"groupBy"
|
|
9
|
+
];
|
|
10
|
+
var OPTIONAL_ARGS_OPERATIONS = [
|
|
11
|
+
"findMany",
|
|
12
|
+
"findFirst",
|
|
13
|
+
"findFirstOrThrow",
|
|
14
|
+
"count"
|
|
15
|
+
];
|
|
16
|
+
var CACHE_OPERATIONS = [
|
|
17
|
+
...REQUIRED_ARGS_OPERATIONS,
|
|
18
|
+
...OPTIONAL_ARGS_OPERATIONS
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
// src/index.ts
|
|
22
|
+
var src_default = ({ cache }) => {
|
|
23
|
+
return Prisma.defineExtension({
|
|
24
|
+
name: "prisma-extension-cache-manager",
|
|
25
|
+
client: {
|
|
26
|
+
cache: { store: cache }
|
|
27
|
+
},
|
|
28
|
+
model: {
|
|
29
|
+
$allModels: {}
|
|
30
|
+
},
|
|
31
|
+
query: {
|
|
32
|
+
$allModels: {
|
|
33
|
+
async $allOperations({ model, operation, args, query }) {
|
|
34
|
+
let result;
|
|
35
|
+
const useCache = ["boolean", "object"].includes(typeof args["cache"]) && args["cache"] !== null && CACHE_OPERATIONS.includes(operation);
|
|
36
|
+
if (!useCache)
|
|
37
|
+
return query(args);
|
|
38
|
+
const queryArgs = {
|
|
39
|
+
...args
|
|
40
|
+
};
|
|
41
|
+
delete queryArgs["cache"];
|
|
42
|
+
if (typeof args["cache"] === "boolean") {
|
|
43
|
+
const cacheKey = `prisma-${model}-${JSON.stringify(queryArgs)}`;
|
|
44
|
+
const cached2 = await cache.get(cacheKey);
|
|
45
|
+
if (cached2) {
|
|
46
|
+
return typeof cached2 === "string" ? JSON.parse(cached2) : cached2;
|
|
47
|
+
}
|
|
48
|
+
result = await query(queryArgs);
|
|
49
|
+
await cache.set(cacheKey, JSON.stringify(result));
|
|
50
|
+
return result;
|
|
51
|
+
}
|
|
52
|
+
const { key, ttl } = args["cache"];
|
|
53
|
+
const customCacheKey = key || `prisma-custom-${model}-${JSON.stringify(queryArgs)}`;
|
|
54
|
+
const cached = await cache.get(customCacheKey);
|
|
55
|
+
if (cached) {
|
|
56
|
+
return typeof cached === "string" ? JSON.parse(cached) : cached;
|
|
57
|
+
}
|
|
58
|
+
result = await query(queryArgs);
|
|
59
|
+
const value = JSON.stringify(result);
|
|
60
|
+
if (ttl) {
|
|
61
|
+
await cache.set(customCacheKey, value, ttl);
|
|
62
|
+
} else {
|
|
63
|
+
await cache.set(customCacheKey, value);
|
|
64
|
+
}
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
export {
|
|
72
|
+
src_default as default
|
|
73
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@knaus94/prisma-extension-cache-manager",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "https://github.com/knaus94/prisma-extension-cache-manager.git"
|
|
7
|
+
},
|
|
8
|
+
"homepage": "https://github.com/knaus94/prisma-extension-cache-manager",
|
|
9
|
+
"bugs": "https://github.com/knaus94/prisma-extension-cache-manager/issues",
|
|
10
|
+
"author": {
|
|
11
|
+
"name": "knaus94",
|
|
12
|
+
"url": "https://github.com/knaus94"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"prisma",
|
|
16
|
+
"extension",
|
|
17
|
+
"cache-manager",
|
|
18
|
+
"cache"
|
|
19
|
+
],
|
|
20
|
+
"main": "./dist/index.js",
|
|
21
|
+
"module": "./dist/index.mjs",
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"import": "./dist/index.mjs",
|
|
26
|
+
"require": "./dist/index.js",
|
|
27
|
+
"types": "./dist/index.d.ts"
|
|
28
|
+
},
|
|
29
|
+
"./package.json": "./package.json"
|
|
30
|
+
},
|
|
31
|
+
"typesVersions": {
|
|
32
|
+
"*": {}
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"dist/**/*",
|
|
36
|
+
"LICENSE",
|
|
37
|
+
"README.md"
|
|
38
|
+
],
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsup",
|
|
41
|
+
"dev": "tsup --watch",
|
|
42
|
+
"format": "prettier --write .",
|
|
43
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/node": "^20.10.6",
|
|
47
|
+
"prettier": "^3.1.1",
|
|
48
|
+
"tsup": "^8.0.1",
|
|
49
|
+
"typescript": "^5.3.3"
|
|
50
|
+
},
|
|
51
|
+
"publishConfig": {
|
|
52
|
+
"access": "public"
|
|
53
|
+
},
|
|
54
|
+
"release": {
|
|
55
|
+
"branches": [
|
|
56
|
+
"main"
|
|
57
|
+
]
|
|
58
|
+
},
|
|
59
|
+
"dependencies": {
|
|
60
|
+
"@prisma/client": "^5.7.1",
|
|
61
|
+
"cache-manager": "^5.2.1"
|
|
62
|
+
}
|
|
63
|
+
}
|