@modern-admin/system-prisma 0.2.0 → 0.3.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/LICENSE +21 -0
- package/dist/stores/ai-task-store.d.ts +1 -25
- package/dist/stores/ai-task-store.d.ts.map +1 -1
- package/dist/stores/ai-task-store.js +1 -26
- package/dist/stores/ai-task-store.js.map +1 -1
- package/dist/stores/cache-store.d.ts +1 -10
- package/dist/stores/cache-store.d.ts.map +1 -1
- package/dist/stores/cache-store.js +25 -13
- package/dist/stores/cache-store.js.map +1 -1
- package/dist/stores/config-store.d.ts.map +1 -1
- package/dist/stores/config-store.js +4 -8
- package/dist/stores/config-store.js.map +1 -1
- package/dist/stores/history-store.d.ts +1 -13
- package/dist/stores/history-store.d.ts.map +1 -1
- package/dist/stores/history-store.js +1 -13
- package/dist/stores/history-store.js.map +1 -1
- package/dist/stores/log-store.d.ts +1 -13
- package/dist/stores/log-store.d.ts.map +1 -1
- package/dist/stores/log-store.js +2 -17
- package/dist/stores/log-store.js.map +1 -1
- package/dist/stores/webhook-store.d.ts +1 -29
- package/dist/stores/webhook-store.d.ts.map +1 -1
- package/dist/stores/webhook-store.js +1 -28
- package/dist/stores/webhook-store.js.map +1 -1
- package/package.json +3 -3
- package/src/stores/ai-task-store.ts +4 -52
- package/src/stores/cache-store.ts +24 -26
- package/src/stores/config-store.ts +5 -8
- package/src/stores/history-store.ts +8 -26
- package/src/stores/log-store.ts +9 -31
- package/src/stores/webhook-store.ts +4 -59
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Modern Admin contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,28 +1,5 @@
|
|
|
1
|
-
import { type AiTask, type AiTaskEvent, type AiTaskInput, type AiTaskStatus, type IAiTaskStore } from '@modern-admin/core';
|
|
1
|
+
import { type AiTask, type AiTaskEvent, type AiTaskInput, type AiTaskStatus, type IAiTaskStore, type EventRow, type TaskRow } from '@modern-admin/core';
|
|
2
2
|
import type { PrismaDelegate } from '../types.js';
|
|
3
|
-
interface TaskRow {
|
|
4
|
-
id: string;
|
|
5
|
-
kind: string;
|
|
6
|
-
resourceId: string | null;
|
|
7
|
-
recordId: string | null;
|
|
8
|
-
userId: string | null;
|
|
9
|
-
status: string;
|
|
10
|
-
input: unknown;
|
|
11
|
-
output: unknown;
|
|
12
|
-
error: string | null;
|
|
13
|
-
progress: number | null;
|
|
14
|
-
createdAt: Date;
|
|
15
|
-
updatedAt: Date;
|
|
16
|
-
startedAt: Date | null;
|
|
17
|
-
finishedAt: Date | null;
|
|
18
|
-
}
|
|
19
|
-
interface EventRow {
|
|
20
|
-
id: string;
|
|
21
|
-
taskId: string;
|
|
22
|
-
type: string;
|
|
23
|
-
data: unknown;
|
|
24
|
-
createdAt: Date;
|
|
25
|
-
}
|
|
26
3
|
export declare class PrismaAiTaskStore implements IAiTaskStore {
|
|
27
4
|
private readonly taskDelegate;
|
|
28
5
|
private readonly eventDelegate;
|
|
@@ -39,5 +16,4 @@ export declare class PrismaAiTaskStore implements IAiTaskStore {
|
|
|
39
16
|
appendEvent(taskId: string, type: string, data: Record<string, unknown>): Promise<AiTaskEvent>;
|
|
40
17
|
events(taskId: string, sinceId?: string): Promise<AiTaskEvent[]>;
|
|
41
18
|
}
|
|
42
|
-
export {};
|
|
43
19
|
//# sourceMappingURL=ai-task-store.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-task-store.d.ts","sourceRoot":"","sources":["../../src/stores/ai-task-store.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ai-task-store.d.ts","sourceRoot":"","sources":["../../src/stores/ai-task-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,MAAM,EACX,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,QAAQ,EACb,KAAK,OAAO,EACb,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAIjD,qBAAa,iBAAkB,YAAW,YAAY;IAElD,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,aAAa;gBADb,YAAY,EAAE,cAAc,CAAC,OAAO,CAAC,EACrC,aAAa,EAAE,cAAc,CAAC,QAAQ,CAAC;IAGpD,OAAO,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC;IAgB5C,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAKvC,IAAI,CAAC,MAAM,GAAE,UAAU,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAiBzE,YAAY,CAChB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE;QACL,MAAM,EAAE,YAAY,CAAA;QACpB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;QACxB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;QAChC,KAAK,CAAC,EAAE,MAAM,CAAA;KACf,GACA,OAAO,CAAC,MAAM,CAAC;IAiBZ,WAAW,CACf,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,OAAO,CAAC,WAAW,CAAC;IAOjB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;CASvE"}
|
|
@@ -1,29 +1,4 @@
|
|
|
1
|
-
import { uuidv7, } from '@modern-admin/core';
|
|
2
|
-
const rowToTask = (row) => ({
|
|
3
|
-
id: row.id,
|
|
4
|
-
kind: row.kind,
|
|
5
|
-
...(row.resourceId !== null ? { resourceId: row.resourceId } : {}),
|
|
6
|
-
...(row.recordId !== null ? { recordId: row.recordId } : {}),
|
|
7
|
-
...(row.userId !== null ? { userId: row.userId } : {}),
|
|
8
|
-
status: row.status,
|
|
9
|
-
input: row.input ?? {},
|
|
10
|
-
...(row.output !== null && row.output !== undefined
|
|
11
|
-
? { output: row.output }
|
|
12
|
-
: {}),
|
|
13
|
-
...(row.error !== null ? { error: row.error } : {}),
|
|
14
|
-
progress: row.progress,
|
|
15
|
-
createdAt: row.createdAt.toISOString(),
|
|
16
|
-
updatedAt: row.updatedAt.toISOString(),
|
|
17
|
-
...(row.startedAt !== null ? { startedAt: row.startedAt.toISOString() } : {}),
|
|
18
|
-
...(row.finishedAt !== null ? { finishedAt: row.finishedAt.toISOString() } : {}),
|
|
19
|
-
});
|
|
20
|
-
const rowToEvent = (row) => ({
|
|
21
|
-
id: row.id,
|
|
22
|
-
taskId: row.taskId,
|
|
23
|
-
type: row.type,
|
|
24
|
-
data: row.data ?? {},
|
|
25
|
-
createdAt: row.createdAt.toISOString(),
|
|
26
|
-
});
|
|
1
|
+
import { rowToEvent, rowToTask, uuidv7, } from '@modern-admin/core';
|
|
27
2
|
const TERMINAL = ['succeeded', 'failed', 'cancelled'];
|
|
28
3
|
export class PrismaAiTaskStore {
|
|
29
4
|
constructor(taskDelegate, eventDelegate) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-task-store.js","sourceRoot":"","sources":["../../src/stores/ai-task-store.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"ai-task-store.js","sourceRoot":"","sources":["../../src/stores/ai-task-store.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EACT,MAAM,GAQP,MAAM,oBAAoB,CAAA;AAG3B,MAAM,QAAQ,GAAmB,CAAC,WAAW,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAA;AAErE,MAAM,OAAO,iBAAiB;IAC5B,YACmB,YAAqC,EACrC,aAAuC;QADvC,iBAAY,GAAZ,YAAY,CAAyB;QACrC,kBAAa,GAAb,aAAa,CAA0B;IACvD,CAAC;IAEJ,KAAK,CAAC,OAAO,CAAC,KAAkB;QAC9B,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC;YACzC,IAAI,EAAE;gBACJ,EAAE,EAAE,MAAM,EAAE;gBACZ,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,UAAU,EAAE,KAAK,CAAC,UAAU,IAAI,IAAI;gBACpC,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,IAAI;gBAChC,MAAM,EAAE,KA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AE,CAAC,CAAA;QACnE,OAAO,SAAS,CAAC,GAAG,CAAC,CAAA;IACvB,CAAC;IAED,KAAK,CAAC,WAAW,CACf,MAAc,EACd,IAAY,EACZ,IAA6B;QAE7B,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC;YAC1C,IAAI,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE;SAC3C,CAAC,CAAA;QACF,OAAO,UAAU,CAAC,GAAG,CAAC,CAAA;IACxB,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,MAAc,EAAE,OAAgB;QAC3C,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC;YAC5C,KAAK,EAAE,EAAE,MAAM,EAAE;YACjB,OAAO,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE;SAC9B,CAAC,CAAA;QACF,IAAI,CAAC,OAAO;YAAE,OAAO,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;QACxC,MAAM,GAAG,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,OAAO,CAAC,CAAA;QAClD,OAAO,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;IAC7D,CAAC;CACF"}
|
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type CacheEntry, type CacheRow, type ICacheStore } from '@modern-admin/core';
|
|
2
2
|
import type { PrismaDelegate } from '../types.js';
|
|
3
|
-
interface CacheRow {
|
|
4
|
-
key: string;
|
|
5
|
-
value: unknown;
|
|
6
|
-
tags: unknown;
|
|
7
|
-
expiresAt: Date | null;
|
|
8
|
-
createdAt: Date;
|
|
9
|
-
updatedAt: Date;
|
|
10
|
-
}
|
|
11
3
|
export declare class PrismaCacheStore implements ICacheStore {
|
|
12
4
|
private readonly delegate;
|
|
13
5
|
constructor(delegate: PrismaDelegate<CacheRow>);
|
|
@@ -26,5 +18,4 @@ export declare class PrismaCacheStore implements ICacheStore {
|
|
|
26
18
|
invalidateTags(tags: string[]): Promise<number>;
|
|
27
19
|
prune(): Promise<number>;
|
|
28
20
|
}
|
|
29
|
-
export {};
|
|
30
21
|
//# sourceMappingURL=cache-store.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache-store.d.ts","sourceRoot":"","sources":["../../src/stores/cache-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"cache-store.d.ts","sourceRoot":"","sources":["../../src/stores/cache-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,UAAU,EAAE,KAAK,QAAQ,EAAE,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACtG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEjD,qBAAa,gBAAiB,YAAW,WAAW;IACtC,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAAR,QAAQ,EAAE,cAAc,CAAC,QAAQ,CAAC;IAEzD,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IAU5C,GAAG,CACP,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,OAAO,EACd,OAAO,GAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;KAAO,GAChD,OAAO,CAAC,IAAI,CAAC;IAUV,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIxC;;;;;OAKG;IACG,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IA8B/C,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC;CAM/B"}
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
key: row.key,
|
|
3
|
-
value: row.value,
|
|
4
|
-
tags: Array.isArray(row.tags) ? row.tags : [],
|
|
5
|
-
expiresAt: row.expiresAt ? row.expiresAt.toISOString() : null,
|
|
6
|
-
createdAt: row.createdAt.toISOString(),
|
|
7
|
-
updatedAt: row.updatedAt.toISOString(),
|
|
8
|
-
});
|
|
1
|
+
import { rowToCacheEntry } from '@modern-admin/core';
|
|
9
2
|
export class PrismaCacheStore {
|
|
10
3
|
constructor(delegate) {
|
|
11
4
|
this.delegate = delegate;
|
|
@@ -18,7 +11,7 @@ export class PrismaCacheStore {
|
|
|
18
11
|
await this.delegate.delete({ where: { key } }).catch(() => undefined);
|
|
19
12
|
return null;
|
|
20
13
|
}
|
|
21
|
-
return
|
|
14
|
+
return rowToCacheEntry(row);
|
|
22
15
|
}
|
|
23
16
|
async set(key, value, options = {}) {
|
|
24
17
|
const expiresAt = options.ttlMs ? new Date(Date.now() + options.ttlMs) : null;
|
|
@@ -42,12 +35,31 @@ export class PrismaCacheStore {
|
|
|
42
35
|
if (!tags.length)
|
|
43
36
|
return 0;
|
|
44
37
|
const set = new Set(tags);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
38
|
+
// Page through the table (key ordered, key+tags projection only) so a
|
|
39
|
+
// large cache never loads whole in memory at once.
|
|
40
|
+
const BATCH = 1000;
|
|
41
|
+
const targetKeys = [];
|
|
42
|
+
let skip = 0;
|
|
43
|
+
for (;;) {
|
|
44
|
+
const rows = await this.delegate.findMany({
|
|
45
|
+
select: { key: true, tags: true },
|
|
46
|
+
orderBy: { key: 'asc' },
|
|
47
|
+
take: BATCH,
|
|
48
|
+
skip,
|
|
49
|
+
});
|
|
50
|
+
for (const r of rows) {
|
|
51
|
+
if (Array.isArray(r.tags) && r.tags.some((t) => set.has(t))) {
|
|
52
|
+
targetKeys.push(r.key);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (rows.length < BATCH)
|
|
56
|
+
break;
|
|
57
|
+
skip += BATCH;
|
|
58
|
+
}
|
|
59
|
+
if (!targetKeys.length)
|
|
48
60
|
return 0;
|
|
49
61
|
const result = await this.delegate.deleteMany({
|
|
50
|
-
where: { key: { in:
|
|
62
|
+
where: { key: { in: targetKeys } },
|
|
51
63
|
});
|
|
52
64
|
return result.count;
|
|
53
65
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache-store.js","sourceRoot":"","sources":["../../src/stores/cache-store.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cache-store.js","sourceRoot":"","sources":["../../src/stores/cache-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAoD,MAAM,oBAAoB,CAAA;AAGtG,MAAM,OAAO,gBAAgB;IAC3B,YAA6B,QAAkC;QAAlC,aAAQ,GAAR,QAAQ,CAA0B;IAAG,CAAC;IAEnE,KAAK,CAAC,GAAG,CAAC,GAAW;QACnB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,CAAA;QAC9D,IAAI,CAAC,GAAG;YAAE,OAAO,IAAI,CAAA;QACrB,IAAI,GAAG,CAAC,SAAS,IAAI,GAAG,CAAC,SAAS,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;YAC1D,MAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAA;YACrE,OAAO,IAAI,CAAA;QACb,CAAC;QACD,OAAO,eAAe,CAAC,GAAG,CAAC,CAAA;IAC7B,CAAC;IAED,KAAK,CAAC,GAA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BACjC,OAAO,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE;gBACvB,IAAI,EAAE,KAAK;gBACX,IAAI;aACL,CAAC,CAAA;YACF,KAAK,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;gBACrB,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,IAAK,CAAC,CAAC,IAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;oBAC1E,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;gBACxB,CAAC;YACH,CAAC;YACD,IAAI,IAAI,CAAC,MAAM,GAAG,KAAK;gBAAE,MAAK;YAC9B,IAAI,IAAI,KAAK,CAAA;QACf,CAAC;QACD,IAAI,CAAC,UAAU,CAAC,MAAM;YAAE,OAAO,CAAC,CAAA;QAChC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC;YAC5C,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE;SACnC,CAAC,CAAA;QACF,OAAO,MAAM,CAAC,KAAK,CAAA;IACrB,CAAC;IAED,KAAK,CAAC,KAAK;QACT,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC;YAC5C,KAAK,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,IAAI,IAAI,EAAE,EAAE,EAAE;SACzC,CAAC,CAAA;QACF,OAAO,MAAM,CAAC,KAAK,CAAA;IACrB,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-store.d.ts","sourceRoot":"","sources":["../../src/stores/config-store.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"config-store.d.ts","sourceRoot":"","sources":["../../src/stores/config-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,WAAW,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY,EAAU,MAAM,oBAAoB,CAAA;AACpH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEjD,UAAU,SAAS;IACjB,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,OAAO,CAAA;IACd,SAAS,EAAE,IAAI,CAAA;CAChB;AAWD,qBAAa,iBAAkB,YAAW,YAAY;IACxC,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAAR,QAAQ,EAAE,cAAc,CAAC,SAAS,CAAC;IAG1D,GAAG,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAU9E,GAAG,CACP,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,MAAM,GAAG,IAAI,EACtB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,IAAI,CAAC;IAsBV,MAAM,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAO9E,IAAI,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;CAO/E"}
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import { uuidv7 } from '@modern-admin/core';
|
|
1
|
+
import { rowToConfigEntry, uuidv7 } from '@modern-admin/core';
|
|
2
2
|
const GLOBAL_SCOPE_ID = '';
|
|
3
3
|
const encodeScopeId = (scopeId) => scopeId ?? GLOBAL_SCOPE_ID;
|
|
4
4
|
const decodeScopeId = (scopeId) => scopeId === GLOBAL_SCOPE_ID ? null : scopeId;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
key: row.key,
|
|
9
|
-
value: row.value,
|
|
10
|
-
updatedAt: row.updatedAt.toISOString(),
|
|
11
|
-
});
|
|
5
|
+
// Prisma stores the global scope as a non-null sentinel (`''`); decode it back
|
|
6
|
+
// to `null` before handing the row to the shared mapper.
|
|
7
|
+
const rowToEntry = (row) => rowToConfigEntry({ ...row, scopeId: decodeScopeId(row.scopeId) });
|
|
12
8
|
export class PrismaConfigStore {
|
|
13
9
|
constructor(delegate) {
|
|
14
10
|
this.delegate = delegate;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-store.js","sourceRoot":"","sources":["../../src/stores/config-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyD,MAAM,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"config-store.js","sourceRoot":"","sources":["../../src/stores/config-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAyD,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAYpH,MAAM,eAAe,GAAG,EAAE,CAAA;AAC1B,MAAM,aAAa,GAAG,CAAC,OAAsB,EAAU,EAAE,CAAC,OAAO,IAAI,eAAe,CAAA;AACpF,MAAM,aAAa,GAAG,CAAC,OAAe,EAAiB,EAAE,CAAC,OAAO,KAAK,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAA;AAEtG,+EAA+E;AAC/E,yDAAyD;AACzD,MAAM,UAAU,GAAG,CAAC,GAAc,EAAE,EAAE,CACpC,gBAAgB,CAAC,EAAE,GAAG,GAAG,EAAE,OAAO,EAAE,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;AAEnE,MAAM,OAAO,iBAAiB;IAC5B,YAA6B,QAAmC;QAAnC,aAAQ,GAAR,QAAQ,CAA2B;IAChE,CAAC;IAED,KAAK,CA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AsB,EAAE,GAAW;QAClE,0EAA0E;QAC1E,MAAM,IAAI,CAAC,QAAQ;aAChB,UAAU,CAAC,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC;aACtE,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAA;IAC3B,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,KAAkB,EAAE,OAAsB;QACnD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;YACxC,KAAK,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,EAAE;YACjD,OAAO,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE;SACxB,CAAC,CAAA;QACF,OAAO,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;IAC7B,CAAC;CACF"}
|
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
import { type HistoryEntry, type HistoryOp, type IHistoryStore } from '@modern-admin/core';
|
|
1
|
+
import { type HistoryEntry, type HistoryOp, type HistoryRow, type IHistoryStore } from '@modern-admin/core';
|
|
2
2
|
import type { PrismaDelegate } from '../types.js';
|
|
3
|
-
interface HistoryRow {
|
|
4
|
-
id: string;
|
|
5
|
-
resourceId: string;
|
|
6
|
-
recordId: string;
|
|
7
|
-
op: string;
|
|
8
|
-
userId: string | null;
|
|
9
|
-
snapshot: unknown;
|
|
10
|
-
snapshotBefore: unknown;
|
|
11
|
-
diff: unknown;
|
|
12
|
-
createdAt: Date;
|
|
13
|
-
}
|
|
14
3
|
export declare class PrismaHistoryStore implements IHistoryStore {
|
|
15
4
|
private readonly delegate;
|
|
16
5
|
constructor(delegate: PrismaDelegate<HistoryRow>);
|
|
@@ -29,5 +18,4 @@ export declare class PrismaHistoryStore implements IHistoryStore {
|
|
|
29
18
|
get(resourceId: string, recordId: string, revisionId: string): Promise<HistoryEntry | null>;
|
|
30
19
|
latest(resourceId: string, recordId: string): Promise<HistoryEntry | null>;
|
|
31
20
|
}
|
|
32
|
-
export {};
|
|
33
21
|
//# sourceMappingURL=history-store.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"history-store.d.ts","sourceRoot":"","sources":["../../src/stores/history-store.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"history-store.d.ts","sourceRoot":"","sources":["../../src/stores/history-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,aAAa,EACnB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEjD,qBAAa,kBAAmB,YAAW,aAAa;IAC1C,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAAR,QAAQ,EAAE,cAAc,CAAC,UAAU,CAAC;IAE3D,MAAM,CAAC,KAAK,EAAE;QAClB,UAAU,EAAE,MAAM,CAAA;QAClB,QAAQ,EAAE,MAAM,CAAA;QAChB,EAAE,EAAE,SAAS,CAAA;QACb,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;QACjC,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KACzC,GAAG,OAAO,CAAC,YAAY,CAAC;IAenB,IAAI,CACR,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAO,GAChD,OAAO,CAAC,YAAY,EAAE,CAAC;IAYpB,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAO3F,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;CAOjF"}
|
|
@@ -1,16 +1,4 @@
|
|
|
1
|
-
import { uuidv7 } from '@modern-admin/core';
|
|
2
|
-
const rowToEntry = (row) => ({
|
|
3
|
-
id: row.id,
|
|
4
|
-
resourceId: row.resourceId,
|
|
5
|
-
recordId: row.recordId,
|
|
6
|
-
op: row.op,
|
|
7
|
-
...(row.userId !== null ? { userId: row.userId } : {}),
|
|
8
|
-
snapshot: row.snapshot ?? {},
|
|
9
|
-
...(row.snapshotBefore !== null && row.snapshotBefore !== undefined
|
|
10
|
-
? { snapshotBefore: row.snapshotBefore }
|
|
11
|
-
: {}),
|
|
12
|
-
createdAt: row.createdAt.toISOString(),
|
|
13
|
-
});
|
|
1
|
+
import { rowToHistoryEntry as rowToEntry, uuidv7, } from '@modern-admin/core';
|
|
14
2
|
export class PrismaHistoryStore {
|
|
15
3
|
constructor(delegate) {
|
|
16
4
|
this.delegate = delegate;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"history-store.js","sourceRoot":"","sources":["../../src/stores/history-store.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"history-store.js","sourceRoot":"","sources":["../../src/stores/history-store.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,IAAI,UAAU,EAC/B,MAAM,GAKP,MAAM,oBAAoB,CAAA;AAG3B,MAAM,OAAO,kBAAkB;IAC7B,YAA6B,QAAoC;QAApC,aAAQ,GAAR,QAAQ,CAA4B;IAAG,CAAC;IAErE,KAAK,CAAC,MAAM,CAAC,KAOZ;QACC,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;YACrC,IAAI,EAAE;gBACJ,EAAE,EAAE,MAAM,EAAE;gBACZ,UAAU,EAAE,KAAK,CAAC,UA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kB,EAAE,QAAgB;QAC/C,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC;YACxC,KAAK,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE;YAC/B,OAAO,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE;SAC/B,CAAC,CAAA;QACF,OAAO,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;IACrC,CAAC;CACF"}
|
|
@@ -1,17 +1,5 @@
|
|
|
1
|
-
import { type ActionLogEntry, type ILogStore, type IQueryableLogStore } from '@modern-admin/core';
|
|
1
|
+
import { type ActionLogEntry, type ILogStore, type IQueryableLogStore, type LogRow } from '@modern-admin/core';
|
|
2
2
|
import type { PrismaDelegate } from '../types.js';
|
|
3
|
-
interface LogRow {
|
|
4
|
-
id: string;
|
|
5
|
-
resourceId: string;
|
|
6
|
-
action: string;
|
|
7
|
-
recordId: string | null;
|
|
8
|
-
recordIds: unknown;
|
|
9
|
-
userId: string | null;
|
|
10
|
-
payload: unknown;
|
|
11
|
-
result: unknown;
|
|
12
|
-
at: bigint;
|
|
13
|
-
createdAt: Date;
|
|
14
|
-
}
|
|
15
3
|
export declare class PrismaLogStore implements IQueryableLogStore {
|
|
16
4
|
private readonly delegate;
|
|
17
5
|
constructor(delegate: PrismaDelegate<LogRow>);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log-store.d.ts","sourceRoot":"","sources":["../../src/stores/log-store.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"log-store.d.ts","sourceRoot":"","sources":["../../src/stores/log-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,kBAAkB,EACvB,KAAK,MAAM,EACZ,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEjD,qBAAa,cAAe,YAAW,kBAAkB;IAC3C,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAAR,QAAQ,EAAE,cAAc,CAAC,MAAM,CAAC;IAEvD,MAAM,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAkB5C,IAAI,CAAC,MAAM,GAAE,UAAU,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;CAoB9F;AAED,kFAAkF;AAClF,YAAY,EAAE,SAAS,EAAE,CAAA"}
|
package/dist/stores/log-store.js
CHANGED
|
@@ -1,19 +1,4 @@
|
|
|
1
|
-
import { uuidv7 } from '@modern-admin/core';
|
|
2
|
-
const rowToEntry = (row) => ({
|
|
3
|
-
id: row.id,
|
|
4
|
-
resourceId: row.resourceId,
|
|
5
|
-
action: row.action,
|
|
6
|
-
...(row.recordId !== null ? { recordId: row.recordId } : {}),
|
|
7
|
-
...(Array.isArray(row.recordIds) ? { recordIds: row.recordIds } : {}),
|
|
8
|
-
...(row.userId !== null ? { userId: row.userId } : {}),
|
|
9
|
-
...(row.payload !== null && row.payload !== undefined
|
|
10
|
-
? { payload: row.payload }
|
|
11
|
-
: {}),
|
|
12
|
-
...(row.result !== null && row.result !== undefined
|
|
13
|
-
? { result: row.result }
|
|
14
|
-
: {}),
|
|
15
|
-
at: Number(row.at),
|
|
16
|
-
});
|
|
1
|
+
import { rowToLogEntry, uuidv7, } from '@modern-admin/core';
|
|
17
2
|
export class PrismaLogStore {
|
|
18
3
|
constructor(delegate) {
|
|
19
4
|
this.delegate = delegate;
|
|
@@ -59,7 +44,7 @@ export class PrismaLogStore {
|
|
|
59
44
|
...(filter.limit !== undefined ? { take: filter.limit } : {}),
|
|
60
45
|
...(filter.offset !== undefined ? { skip: filter.offset } : {}),
|
|
61
46
|
});
|
|
62
|
-
return rows.map(
|
|
47
|
+
return rows.map(rowToLogEntry);
|
|
63
48
|
}
|
|
64
49
|
}
|
|
65
50
|
//# sourceMappingURL=log-store.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log-store.js","sourceRoot":"","sources":["../../src/stores/log-store.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"log-store.js","sourceRoot":"","sources":["../../src/stores/log-store.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,MAAM,GAKP,MAAM,oBAAoB,CAAA;AAG3B,MAAM,OAAO,cAAc;IACzB,YAA6B,QAAgC;QAAhC,aAAQ,GAAR,QAAQ,CAAwB;IAAG,CAAC;IAEjE,KAAK,CAAC,MAAM,CAAC,KAAqB;QAChC,MAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;YACzB,IAAI,EAAE;gBACJ,qEAAqE;gBACrE,qEAAqE;gBACrE,EAAE,EAAE,KAAK,CAAC,EAAE,IAAI,MAAM,EAAE;gBACxB,UAAU,EAAE,KAAK,CAAC,UAAU;gBAC5B,MAAM,EAAE,KAAK,CAAC,MAAM;gBACpB,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,IAAI;gBAChC,SAAS,EAAE,KAAK,CAAC,SAAS,IAAI,IAAI;gBAClC,MAAM,EAAE,KAAK,CAAC,MAAM,IAAI,IAAI;gBAC5B,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,IAAI;gBAC9B,MAAM,EAAE,KAAK,CAAC,MAAM,IAAI,IAAI;gBAC5B,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;aACrB;SACF,CAAC,CAAA;IACJ,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,SAAoD,EAAE;QAC/D,MAAM,KAAK,GAA4B,EAAE,CAAA;QACzC,IAAI,MAAM,CAAC,UAAU;YAAE,KAAK,CAAC,YAAY,CAAC,GAAG,MAAM,CAAC,UAAU,CAAA;QAC9D,IAAI,MAAM,CAAC,QAAQ;YAAE,KAAK,CAAC,UAAU,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WebhookDelivery, type WebhookInput } from '@modern-admin/core';
|
|
1
|
+
import { type DeliveryRow, type IWebhookStore, type Webhook, type WebhookDelivery, type WebhookInput, type WebhookRow } from '@modern-admin/core';
|
|
2
2
|
import type { PrismaDelegate } from '../types.js';
|
|
3
|
-
interface WebhookRow {
|
|
4
|
-
id: string;
|
|
5
|
-
name: string;
|
|
6
|
-
url: string;
|
|
7
|
-
events: unknown;
|
|
8
|
-
resourceId: string | null;
|
|
9
|
-
enabled: boolean;
|
|
10
|
-
secret: string | null;
|
|
11
|
-
headers: unknown;
|
|
12
|
-
filters: unknown;
|
|
13
|
-
payloadFields: unknown;
|
|
14
|
-
createdAt: Date;
|
|
15
|
-
updatedAt: Date;
|
|
16
|
-
}
|
|
17
|
-
interface DeliveryRow {
|
|
18
|
-
id: string;
|
|
19
|
-
webhookId: string;
|
|
20
|
-
event: string;
|
|
21
|
-
payload: unknown;
|
|
22
|
-
status: string;
|
|
23
|
-
responseStatus: number | null;
|
|
24
|
-
responseBody: string | null;
|
|
25
|
-
error: string | null;
|
|
26
|
-
attempt: number;
|
|
27
|
-
createdAt: Date;
|
|
28
|
-
deliveredAt: Date | null;
|
|
29
|
-
}
|
|
30
3
|
export declare class PrismaWebhookStore implements IWebhookStore {
|
|
31
4
|
private readonly webhookDelegate;
|
|
32
5
|
private readonly deliveryDelegate;
|
|
@@ -39,5 +12,4 @@ export declare class PrismaWebhookStore implements IWebhookStore {
|
|
|
39
12
|
recordDelivery(delivery: Omit<WebhookDelivery, 'id' | 'createdAt'>): Promise<WebhookDelivery>;
|
|
40
13
|
listDeliveries(webhookId: string, limit?: number): Promise<WebhookDelivery[]>;
|
|
41
14
|
}
|
|
42
|
-
export {};
|
|
43
15
|
//# sourceMappingURL=webhook-store.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook-store.d.ts","sourceRoot":"","sources":["../../src/stores/webhook-store.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"webhook-store.d.ts","sourceRoot":"","sources":["../../src/stores/webhook-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,OAAO,EACZ,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,UAAU,EAChB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEjD,qBAAa,kBAAmB,YAAW,aAAa;IAEpD,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,gBAAgB;gBADhB,eAAe,EAAE,cAAc,CAAC,UAAU,CAAC,EAC3C,gBAAgB,EAAE,cAAc,CAAC,WAAW,CAAC;IAG1D,IAAI,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAK1B,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IAKxC,MAAM,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC;IAkB7C,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IAelE,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIjC,cAAc,CAClB,QAAQ,EAAE,IAAI,CAAC,eAAe,EAAE,IAAI,GAAG,WAAW,CAAC,GAClD,OAAO,CAAC,eAAe,CAAC;IAkBrB,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,SAAK,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;CAQhF"}
|
|
@@ -1,31 +1,4 @@
|
|
|
1
|
-
import { uuidv7, } from '@modern-admin/core';
|
|
2
|
-
const rowToWebhook = (row) => ({
|
|
3
|
-
id: row.id,
|
|
4
|
-
name: row.name,
|
|
5
|
-
url: row.url,
|
|
6
|
-
events: Array.isArray(row.events) ? row.events : [],
|
|
7
|
-
resourceId: row.resourceId,
|
|
8
|
-
enabled: row.enabled,
|
|
9
|
-
...(row.secret !== null ? { secret: row.secret } : {}),
|
|
10
|
-
headers: row.headers ?? {},
|
|
11
|
-
filters: row.filters ?? {},
|
|
12
|
-
payloadFields: Array.isArray(row.payloadFields) ? row.payloadFields : [],
|
|
13
|
-
createdAt: row.createdAt.toISOString(),
|
|
14
|
-
updatedAt: row.updatedAt.toISOString(),
|
|
15
|
-
});
|
|
16
|
-
const rowToDelivery = (row) => ({
|
|
17
|
-
id: row.id,
|
|
18
|
-
webhookId: row.webhookId,
|
|
19
|
-
event: row.event,
|
|
20
|
-
payload: row.payload ?? {},
|
|
21
|
-
status: row.status,
|
|
22
|
-
...(row.responseStatus !== null ? { responseStatus: row.responseStatus } : {}),
|
|
23
|
-
...(row.responseBody !== null ? { responseBody: row.responseBody } : {}),
|
|
24
|
-
...(row.error !== null ? { error: row.error } : {}),
|
|
25
|
-
attempt: row.attempt,
|
|
26
|
-
createdAt: row.createdAt.toISOString(),
|
|
27
|
-
...(row.deliveredAt !== null ? { deliveredAt: row.deliveredAt.toISOString() } : {}),
|
|
28
|
-
});
|
|
1
|
+
import { rowToDelivery, rowToWebhook, uuidv7, } from '@modern-admin/core';
|
|
29
2
|
export class PrismaWebhookStore {
|
|
30
3
|
constructor(webhookDelegate, deliveryDelegate) {
|
|
31
4
|
this.webhookDelegate = webhookDelegate;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook-store.js","sourceRoot":"","sources":["../../src/stores/webhook-store.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"webhook-store.js","sourceRoot":"","sources":["../../src/stores/webhook-store.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,YAAY,EACZ,MAAM,GAOP,MAAM,oBAAoB,CAAA;AAG3B,MAAM,OAAO,kBAAkB;IAC7B,YACmB,eAA2C,EAC3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in/system-prisma",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Prisma-backed implementation of Modern Admin system stores (logs, history, webhooks, AI tasks).",
|
|
5
5
|
"homepage": "https://github.com/modern-admin/modern-admin/tree/main/packages/system-prisma#readme",
|
|
6
6
|
"keywords": [
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@modern-admin/core": "0.
|
|
47
|
+
"@modern-admin/core": "^0.3.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@modern-admin/tsconfig": "0.
|
|
50
|
+
"@modern-admin/tsconfig": "0.3.0",
|
|
51
51
|
"@types/bun": "^1.3.13",
|
|
52
52
|
"typescript": "^6.0.3"
|
|
53
53
|
},
|
|
@@ -1,65 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
|
+
rowToEvent,
|
|
3
|
+
rowToTask,
|
|
2
4
|
uuidv7,
|
|
3
5
|
type AiTask,
|
|
4
6
|
type AiTaskEvent,
|
|
5
7
|
type AiTaskInput,
|
|
6
8
|
type AiTaskStatus,
|
|
7
9
|
type IAiTaskStore,
|
|
10
|
+
type EventRow,
|
|
11
|
+
type TaskRow,
|
|
8
12
|
} from '@modern-admin/core'
|
|
9
13
|
import type { PrismaDelegate } from '../types.js'
|
|
10
14
|
|
|
11
|
-
interface TaskRow {
|
|
12
|
-
id: string
|
|
13
|
-
kind: string
|
|
14
|
-
resourceId: string | null
|
|
15
|
-
recordId: string | null
|
|
16
|
-
userId: string | null
|
|
17
|
-
status: string
|
|
18
|
-
input: unknown
|
|
19
|
-
output: unknown
|
|
20
|
-
error: string | null
|
|
21
|
-
progress: number | null
|
|
22
|
-
createdAt: Date
|
|
23
|
-
updatedAt: Date
|
|
24
|
-
startedAt: Date | null
|
|
25
|
-
finishedAt: Date | null
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
interface EventRow {
|
|
29
|
-
id: string
|
|
30
|
-
taskId: string
|
|
31
|
-
type: string
|
|
32
|
-
data: unknown
|
|
33
|
-
createdAt: Date
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const rowToTask = (row: TaskRow): AiTask => ({
|
|
37
|
-
id: row.id,
|
|
38
|
-
kind: row.kind,
|
|
39
|
-
...(row.resourceId !== null ? { resourceId: row.resourceId } : {}),
|
|
40
|
-
...(row.recordId !== null ? { recordId: row.recordId } : {}),
|
|
41
|
-
...(row.userId !== null ? { userId: row.userId } : {}),
|
|
42
|
-
status: row.status as AiTaskStatus,
|
|
43
|
-
input: (row.input as Record<string, unknown>) ?? {},
|
|
44
|
-
...(row.output !== null && row.output !== undefined
|
|
45
|
-
? { output: row.output as Record<string, unknown> }
|
|
46
|
-
: {}),
|
|
47
|
-
...(row.error !== null ? { error: row.error } : {}),
|
|
48
|
-
progress: row.progress,
|
|
49
|
-
createdAt: row.createdAt.toISOString(),
|
|
50
|
-
updatedAt: row.updatedAt.toISOString(),
|
|
51
|
-
...(row.startedAt !== null ? { startedAt: row.startedAt.toISOString() } : {}),
|
|
52
|
-
...(row.finishedAt !== null ? { finishedAt: row.finishedAt.toISOString() } : {}),
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
const rowToEvent = (row: EventRow): AiTaskEvent => ({
|
|
56
|
-
id: row.id,
|
|
57
|
-
taskId: row.taskId,
|
|
58
|
-
type: row.type,
|
|
59
|
-
data: (row.data as Record<string, unknown>) ?? {},
|
|
60
|
-
createdAt: row.createdAt.toISOString(),
|
|
61
|
-
})
|
|
62
|
-
|
|
63
15
|
const TERMINAL: AiTaskStatus[] = ['succeeded', 'failed', 'cancelled']
|
|
64
16
|
|
|
65
17
|
export class PrismaAiTaskStore implements IAiTaskStore {
|
|
@@ -1,24 +1,6 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { rowToCacheEntry, type CacheEntry, type CacheRow, type ICacheStore } from '@modern-admin/core'
|
|
2
2
|
import type { PrismaDelegate } from '../types.js'
|
|
3
3
|
|
|
4
|
-
interface CacheRow {
|
|
5
|
-
key: string
|
|
6
|
-
value: unknown
|
|
7
|
-
tags: unknown
|
|
8
|
-
expiresAt: Date | null
|
|
9
|
-
createdAt: Date
|
|
10
|
-
updatedAt: Date
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const rowToEntry = (row: CacheRow): CacheEntry => ({
|
|
14
|
-
key: row.key,
|
|
15
|
-
value: row.value,
|
|
16
|
-
tags: Array.isArray(row.tags) ? (row.tags as string[]) : [],
|
|
17
|
-
expiresAt: row.expiresAt ? row.expiresAt.toISOString() : null,
|
|
18
|
-
createdAt: row.createdAt.toISOString(),
|
|
19
|
-
updatedAt: row.updatedAt.toISOString(),
|
|
20
|
-
})
|
|
21
|
-
|
|
22
4
|
export class PrismaCacheStore implements ICacheStore {
|
|
23
5
|
constructor(private readonly delegate: PrismaDelegate<CacheRow>) {}
|
|
24
6
|
|
|
@@ -29,7 +11,7 @@ export class PrismaCacheStore implements ICacheStore {
|
|
|
29
11
|
await this.delegate.delete({ where: { key } }).catch(() => undefined)
|
|
30
12
|
return null
|
|
31
13
|
}
|
|
32
|
-
return
|
|
14
|
+
return rowToCacheEntry(row)
|
|
33
15
|
}
|
|
34
16
|
|
|
35
17
|
async set(
|
|
@@ -59,13 +41,29 @@ export class PrismaCacheStore implements ICacheStore {
|
|
|
59
41
|
async invalidateTags(tags: string[]): Promise<number> {
|
|
60
42
|
if (!tags.length) return 0
|
|
61
43
|
const set = new Set(tags)
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
44
|
+
// Page through the table (key ordered, key+tags projection only) so a
|
|
45
|
+
// large cache never loads whole in memory at once.
|
|
46
|
+
const BATCH = 1000
|
|
47
|
+
const targetKeys: string[] = []
|
|
48
|
+
let skip = 0
|
|
49
|
+
for (;;) {
|
|
50
|
+
const rows = await this.delegate.findMany({
|
|
51
|
+
select: { key: true, tags: true },
|
|
52
|
+
orderBy: { key: 'asc' },
|
|
53
|
+
take: BATCH,
|
|
54
|
+
skip,
|
|
55
|
+
})
|
|
56
|
+
for (const r of rows) {
|
|
57
|
+
if (Array.isArray(r.tags) && (r.tags as string[]).some((t) => set.has(t))) {
|
|
58
|
+
targetKeys.push(r.key)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (rows.length < BATCH) break
|
|
62
|
+
skip += BATCH
|
|
63
|
+
}
|
|
64
|
+
if (!targetKeys.length) return 0
|
|
67
65
|
const result = await this.delegate.deleteMany({
|
|
68
|
-
where: { key: { in:
|
|
66
|
+
where: { key: { in: targetKeys } },
|
|
69
67
|
})
|
|
70
68
|
return result.count
|
|
71
69
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ConfigEntry, type ConfigScope, type IConfigStore, uuidv7 } from '@modern-admin/core'
|
|
1
|
+
import { rowToConfigEntry, type ConfigEntry, type ConfigScope, type IConfigStore, uuidv7 } from '@modern-admin/core'
|
|
2
2
|
import type { PrismaDelegate } from '../types.js'
|
|
3
3
|
|
|
4
4
|
interface ConfigRow {
|
|
@@ -14,13 +14,10 @@ const GLOBAL_SCOPE_ID = ''
|
|
|
14
14
|
const encodeScopeId = (scopeId: string | null): string => scopeId ?? GLOBAL_SCOPE_ID
|
|
15
15
|
const decodeScopeId = (scopeId: string): string | null => scopeId === GLOBAL_SCOPE_ID ? null : scopeId
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
value: row.value,
|
|
22
|
-
updatedAt: row.updatedAt.toISOString(),
|
|
23
|
-
})
|
|
17
|
+
// Prisma stores the global scope as a non-null sentinel (`''`); decode it back
|
|
18
|
+
// to `null` before handing the row to the shared mapper.
|
|
19
|
+
const rowToEntry = (row: ConfigRow) =>
|
|
20
|
+
rowToConfigEntry({ ...row, scopeId: decodeScopeId(row.scopeId) })
|
|
24
21
|
|
|
25
22
|
export class PrismaConfigStore implements IConfigStore {
|
|
26
23
|
constructor(private readonly delegate: PrismaDelegate<ConfigRow>) {
|
|
@@ -1,31 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
rowToHistoryEntry as rowToEntry,
|
|
3
|
+
uuidv7,
|
|
4
|
+
type HistoryEntry,
|
|
5
|
+
type HistoryOp,
|
|
6
|
+
type HistoryRow,
|
|
7
|
+
type IHistoryStore,
|
|
8
|
+
} from '@modern-admin/core'
|
|
2
9
|
import type { PrismaDelegate } from '../types.js'
|
|
3
10
|
|
|
4
|
-
interface HistoryRow {
|
|
5
|
-
id: string
|
|
6
|
-
resourceId: string
|
|
7
|
-
recordId: string
|
|
8
|
-
op: string
|
|
9
|
-
userId: string | null
|
|
10
|
-
snapshot: unknown
|
|
11
|
-
snapshotBefore: unknown
|
|
12
|
-
diff: unknown
|
|
13
|
-
createdAt: Date
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const rowToEntry = (row: HistoryRow): HistoryEntry => ({
|
|
17
|
-
id: row.id,
|
|
18
|
-
resourceId: row.resourceId,
|
|
19
|
-
recordId: row.recordId,
|
|
20
|
-
op: row.op as HistoryOp,
|
|
21
|
-
...(row.userId !== null ? { userId: row.userId } : {}),
|
|
22
|
-
snapshot: (row.snapshot as Record<string, unknown>) ?? {},
|
|
23
|
-
...(row.snapshotBefore !== null && row.snapshotBefore !== undefined
|
|
24
|
-
? { snapshotBefore: row.snapshotBefore as Record<string, unknown> }
|
|
25
|
-
: {}),
|
|
26
|
-
createdAt: row.createdAt.toISOString(),
|
|
27
|
-
})
|
|
28
|
-
|
|
29
11
|
export class PrismaHistoryStore implements IHistoryStore {
|
|
30
12
|
constructor(private readonly delegate: PrismaDelegate<HistoryRow>) {}
|
|
31
13
|
|
package/src/stores/log-store.ts
CHANGED
|
@@ -1,35 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
rowToLogEntry,
|
|
3
|
+
uuidv7,
|
|
4
|
+
type ActionLogEntry,
|
|
5
|
+
type ILogStore,
|
|
6
|
+
type IQueryableLogStore,
|
|
7
|
+
type LogRow,
|
|
8
|
+
} from '@modern-admin/core'
|
|
2
9
|
import type { PrismaDelegate } from '../types.js'
|
|
3
10
|
|
|
4
|
-
interface LogRow {
|
|
5
|
-
id: string
|
|
6
|
-
resourceId: string
|
|
7
|
-
action: string
|
|
8
|
-
recordId: string | null
|
|
9
|
-
recordIds: unknown
|
|
10
|
-
userId: string | null
|
|
11
|
-
payload: unknown
|
|
12
|
-
result: unknown
|
|
13
|
-
at: bigint
|
|
14
|
-
createdAt: Date
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const rowToEntry = (row: LogRow): ActionLogEntry => ({
|
|
18
|
-
id: row.id,
|
|
19
|
-
resourceId: row.resourceId,
|
|
20
|
-
action: row.action,
|
|
21
|
-
...(row.recordId !== null ? { recordId: row.recordId } : {}),
|
|
22
|
-
...(Array.isArray(row.recordIds) ? { recordIds: row.recordIds as string[] } : {}),
|
|
23
|
-
...(row.userId !== null ? { userId: row.userId } : {}),
|
|
24
|
-
...(row.payload !== null && row.payload !== undefined
|
|
25
|
-
? { payload: row.payload as Record<string, unknown> }
|
|
26
|
-
: {}),
|
|
27
|
-
...(row.result !== null && row.result !== undefined
|
|
28
|
-
? { result: row.result as Record<string, unknown> }
|
|
29
|
-
: {}),
|
|
30
|
-
at: Number(row.at),
|
|
31
|
-
})
|
|
32
|
-
|
|
33
11
|
export class PrismaLogStore implements IQueryableLogStore {
|
|
34
12
|
constructor(private readonly delegate: PrismaDelegate<LogRow>) {}
|
|
35
13
|
|
|
@@ -69,7 +47,7 @@ export class PrismaLogStore implements IQueryableLogStore {
|
|
|
69
47
|
...(filter.limit !== undefined ? { take: filter.limit } : {}),
|
|
70
48
|
...(filter.offset !== undefined ? { skip: filter.offset } : {}),
|
|
71
49
|
})
|
|
72
|
-
return rows.map(
|
|
50
|
+
return rows.map(rowToLogEntry)
|
|
73
51
|
}
|
|
74
52
|
}
|
|
75
53
|
|
|
@@ -1,71 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
|
+
rowToDelivery,
|
|
3
|
+
rowToWebhook,
|
|
2
4
|
uuidv7,
|
|
5
|
+
type DeliveryRow,
|
|
3
6
|
type IWebhookStore,
|
|
4
7
|
type Webhook,
|
|
5
8
|
type WebhookDelivery,
|
|
6
|
-
type WebhookDeliveryStatus,
|
|
7
9
|
type WebhookInput,
|
|
10
|
+
type WebhookRow,
|
|
8
11
|
} from '@modern-admin/core'
|
|
9
12
|
import type { PrismaDelegate } from '../types.js'
|
|
10
13
|
|
|
11
|
-
interface WebhookRow {
|
|
12
|
-
id: string
|
|
13
|
-
name: string
|
|
14
|
-
url: string
|
|
15
|
-
events: unknown
|
|
16
|
-
resourceId: string | null
|
|
17
|
-
enabled: boolean
|
|
18
|
-
secret: string | null
|
|
19
|
-
headers: unknown
|
|
20
|
-
filters: unknown
|
|
21
|
-
payloadFields: unknown
|
|
22
|
-
createdAt: Date
|
|
23
|
-
updatedAt: Date
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
interface DeliveryRow {
|
|
27
|
-
id: string
|
|
28
|
-
webhookId: string
|
|
29
|
-
event: string
|
|
30
|
-
payload: unknown
|
|
31
|
-
status: string
|
|
32
|
-
responseStatus: number | null
|
|
33
|
-
responseBody: string | null
|
|
34
|
-
error: string | null
|
|
35
|
-
attempt: number
|
|
36
|
-
createdAt: Date
|
|
37
|
-
deliveredAt: Date | null
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const rowToWebhook = (row: WebhookRow): Webhook => ({
|
|
41
|
-
id: row.id,
|
|
42
|
-
name: row.name,
|
|
43
|
-
url: row.url,
|
|
44
|
-
events: Array.isArray(row.events) ? (row.events as string[]) : [],
|
|
45
|
-
resourceId: row.resourceId,
|
|
46
|
-
enabled: row.enabled,
|
|
47
|
-
...(row.secret !== null ? { secret: row.secret } : {}),
|
|
48
|
-
headers: (row.headers as Record<string, string>) ?? {},
|
|
49
|
-
filters: (row.filters as Record<string, string>) ?? {},
|
|
50
|
-
payloadFields: Array.isArray(row.payloadFields) ? (row.payloadFields as string[]) : [],
|
|
51
|
-
createdAt: row.createdAt.toISOString(),
|
|
52
|
-
updatedAt: row.updatedAt.toISOString(),
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
const rowToDelivery = (row: DeliveryRow): WebhookDelivery => ({
|
|
56
|
-
id: row.id,
|
|
57
|
-
webhookId: row.webhookId,
|
|
58
|
-
event: row.event,
|
|
59
|
-
payload: (row.payload as Record<string, unknown>) ?? {},
|
|
60
|
-
status: row.status as WebhookDeliveryStatus,
|
|
61
|
-
...(row.responseStatus !== null ? { responseStatus: row.responseStatus } : {}),
|
|
62
|
-
...(row.responseBody !== null ? { responseBody: row.responseBody } : {}),
|
|
63
|
-
...(row.error !== null ? { error: row.error } : {}),
|
|
64
|
-
attempt: row.attempt,
|
|
65
|
-
createdAt: row.createdAt.toISOString(),
|
|
66
|
-
...(row.deliveredAt !== null ? { deliveredAt: row.deliveredAt.toISOString() } : {}),
|
|
67
|
-
})
|
|
68
|
-
|
|
69
14
|
export class PrismaWebhookStore implements IWebhookStore {
|
|
70
15
|
constructor(
|
|
71
16
|
private readonly webhookDelegate: PrismaDelegate<WebhookRow>,
|