@ainetwork/adk-provider-memory-mongodb 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-GPOFS7ZT.js → chunk-2XJ6S2W5.js} +12 -7
- package/dist/chunk-2XJ6S2W5.js.map +1 -0
- package/dist/{chunk-5CCEN7NK.js → chunk-QULDFKGZ.js} +5 -1
- package/dist/chunk-QULDFKGZ.js.map +1 -0
- package/dist/chunk-RC275GLE.js +70 -0
- package/dist/chunk-RC275GLE.js.map +1 -0
- package/dist/{chunk-NGLXQZLX.js → chunk-SJ2FHHN6.js} +13 -10
- package/dist/chunk-SJ2FHHN6.js.map +1 -0
- package/dist/index.cjs +322 -75
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -3
- package/dist/index.d.ts +11 -3
- package/dist/index.js +232 -59
- package/dist/index.js.map +1 -1
- package/dist/models/messages.model.cjs +4 -0
- package/dist/models/messages.model.cjs.map +1 -1
- package/dist/models/messages.model.d.cts +14 -1
- package/dist/models/messages.model.d.ts +14 -1
- package/dist/models/messages.model.js +1 -1
- package/dist/models/threads.model.cjs +11 -6
- package/dist/models/threads.model.cjs.map +1 -1
- package/dist/models/threads.model.d.cts +22 -9
- package/dist/models/threads.model.d.ts +22 -9
- package/dist/models/threads.model.js +1 -1
- package/dist/models/user-workflow.model.cjs +105 -0
- package/dist/models/user-workflow.model.cjs.map +1 -0
- package/dist/models/user-workflow.model.d.cts +92 -0
- package/dist/models/user-workflow.model.d.ts +92 -0
- package/dist/models/user-workflow.model.js +9 -0
- package/dist/models/{workflow.model.cjs → workflow-template.model.cjs} +18 -15
- package/dist/models/workflow-template.model.cjs.map +1 -0
- package/dist/models/workflow-template.model.d.cts +60 -0
- package/dist/models/workflow-template.model.d.ts +60 -0
- package/dist/models/workflow-template.model.js +9 -0
- package/dist/models/workflow-template.model.js.map +1 -0
- package/implements/base.memory.ts +130 -12
- package/implements/thread.memory.ts +48 -22
- package/implements/user-workflow.memory.ts +87 -0
- package/implements/workflow-template.memory.ts +69 -0
- package/models/messages.model.ts +7 -0
- package/models/threads.model.ts +16 -9
- package/models/user-workflow.model.ts +91 -0
- package/models/workflow-template.model.ts +58 -0
- package/package.json +3 -3
- package/dist/chunk-5CCEN7NK.js.map +0 -1
- package/dist/chunk-GPOFS7ZT.js.map +0 -1
- package/dist/chunk-NGLXQZLX.js.map +0 -1
- package/dist/models/workflow.model.cjs.map +0 -1
- package/dist/models/workflow.model.d.cts +0 -54
- package/dist/models/workflow.model.d.ts +0 -54
- package/dist/models/workflow.model.js +0 -9
- package/implements/workflow.memory.ts +0 -78
- package/models/workflow.model.ts +0 -46
- /package/dist/models/{workflow.model.js.map → user-workflow.model.js.map} +0 -0
package/models/threads.model.ts
CHANGED
|
@@ -23,14 +23,19 @@ export const ThreadObjectSchema = new Schema(
|
|
|
23
23
|
type: String,
|
|
24
24
|
required: false,
|
|
25
25
|
},
|
|
26
|
-
|
|
27
|
-
type:
|
|
28
|
-
required:
|
|
26
|
+
isPinned: {
|
|
27
|
+
type: Boolean,
|
|
28
|
+
required: false,
|
|
29
|
+
default: false,
|
|
29
30
|
},
|
|
30
|
-
|
|
31
|
-
type:
|
|
32
|
-
required:
|
|
33
|
-
|
|
31
|
+
workflowId: {
|
|
32
|
+
type: String,
|
|
33
|
+
required: false,
|
|
34
|
+
index: true,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
timestamps: true,
|
|
34
39
|
},
|
|
35
40
|
);
|
|
36
41
|
|
|
@@ -39,8 +44,10 @@ export interface ThreadDocument extends Document {
|
|
|
39
44
|
threadId: string;
|
|
40
45
|
userId: string;
|
|
41
46
|
title: string;
|
|
42
|
-
|
|
43
|
-
|
|
47
|
+
isPinned: boolean;
|
|
48
|
+
workflowId?: string;
|
|
49
|
+
createdAt: Date;
|
|
50
|
+
updatedAt: Date;
|
|
44
51
|
}
|
|
45
52
|
|
|
46
53
|
export const ThreadModel = mongoose.model<ThreadDocument>("Thread", ThreadObjectSchema);
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { type Document, Schema } from "mongoose";
|
|
2
|
+
import mongoose from "mongoose";
|
|
3
|
+
|
|
4
|
+
export const UserWorkflowObjectSchema = new Schema(
|
|
5
|
+
{
|
|
6
|
+
workflowId: {
|
|
7
|
+
type: String,
|
|
8
|
+
required: true,
|
|
9
|
+
unique: true,
|
|
10
|
+
},
|
|
11
|
+
userId: {
|
|
12
|
+
type: String,
|
|
13
|
+
required: true,
|
|
14
|
+
index: true,
|
|
15
|
+
},
|
|
16
|
+
title: {
|
|
17
|
+
type: String,
|
|
18
|
+
required: true,
|
|
19
|
+
},
|
|
20
|
+
description: {
|
|
21
|
+
type: String,
|
|
22
|
+
},
|
|
23
|
+
active: {
|
|
24
|
+
type: Boolean,
|
|
25
|
+
required: true,
|
|
26
|
+
default: false,
|
|
27
|
+
},
|
|
28
|
+
templateId: {
|
|
29
|
+
type: String,
|
|
30
|
+
},
|
|
31
|
+
content: {
|
|
32
|
+
type: String,
|
|
33
|
+
required: true,
|
|
34
|
+
},
|
|
35
|
+
variables: {
|
|
36
|
+
type: Schema.Types.Mixed,
|
|
37
|
+
},
|
|
38
|
+
variableValues: {
|
|
39
|
+
type: Schema.Types.Mixed,
|
|
40
|
+
},
|
|
41
|
+
schedule: {
|
|
42
|
+
type: String,
|
|
43
|
+
},
|
|
44
|
+
timezone: {
|
|
45
|
+
type: String,
|
|
46
|
+
},
|
|
47
|
+
lastRunAt: {
|
|
48
|
+
type: Number,
|
|
49
|
+
},
|
|
50
|
+
nextRunAt: {
|
|
51
|
+
type: Number,
|
|
52
|
+
},
|
|
53
|
+
lastThreadId: {
|
|
54
|
+
type: String,
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
timestamps: true,
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
export interface UserWorkflowDocument extends Document {
|
|
63
|
+
workflowId: string;
|
|
64
|
+
userId: string;
|
|
65
|
+
title: string;
|
|
66
|
+
description?: string;
|
|
67
|
+
active: boolean;
|
|
68
|
+
templateId?: string;
|
|
69
|
+
content: string;
|
|
70
|
+
variables?: Record<
|
|
71
|
+
string,
|
|
72
|
+
{
|
|
73
|
+
id: string;
|
|
74
|
+
label: string;
|
|
75
|
+
type: "select" | "date_range" | "date_parts" | "text" | "number";
|
|
76
|
+
options?: Array<string>;
|
|
77
|
+
resolveAt?: "creation" | "execution";
|
|
78
|
+
}
|
|
79
|
+
>;
|
|
80
|
+
variableValues?: Record<string, string>;
|
|
81
|
+
schedule?: string;
|
|
82
|
+
timezone?: string;
|
|
83
|
+
lastRunAt?: number;
|
|
84
|
+
nextRunAt?: number;
|
|
85
|
+
lastThreadId?: string;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export const UserWorkflowModel = mongoose.model<UserWorkflowDocument>(
|
|
89
|
+
"UserWorkflow",
|
|
90
|
+
UserWorkflowObjectSchema
|
|
91
|
+
);
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { type Document, Schema } from "mongoose";
|
|
2
|
+
import mongoose from "mongoose";
|
|
3
|
+
|
|
4
|
+
export const WorkflowTemplateObjectSchema = new Schema(
|
|
5
|
+
{
|
|
6
|
+
templateId: {
|
|
7
|
+
type: String,
|
|
8
|
+
required: true,
|
|
9
|
+
unique: true,
|
|
10
|
+
},
|
|
11
|
+
title: {
|
|
12
|
+
type: String,
|
|
13
|
+
required: true,
|
|
14
|
+
},
|
|
15
|
+
description: {
|
|
16
|
+
type: String,
|
|
17
|
+
required: true,
|
|
18
|
+
},
|
|
19
|
+
active: {
|
|
20
|
+
type: Boolean,
|
|
21
|
+
required: true,
|
|
22
|
+
default: false,
|
|
23
|
+
},
|
|
24
|
+
content: {
|
|
25
|
+
type: String,
|
|
26
|
+
required: true,
|
|
27
|
+
},
|
|
28
|
+
variables: {
|
|
29
|
+
type: Schema.Types.Mixed,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
timestamps: true,
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
export interface WorkflowTemplateDocument extends Document {
|
|
38
|
+
templateId: string;
|
|
39
|
+
title: string;
|
|
40
|
+
description: string;
|
|
41
|
+
active: boolean;
|
|
42
|
+
content: string;
|
|
43
|
+
variables?: Record<
|
|
44
|
+
string,
|
|
45
|
+
{
|
|
46
|
+
id: string;
|
|
47
|
+
label: string;
|
|
48
|
+
type: "select" | "date_range" | "date_parts" | "text" | "number";
|
|
49
|
+
options?: Array<string>;
|
|
50
|
+
resolveAt?: "creation" | "execution";
|
|
51
|
+
}
|
|
52
|
+
>;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export const WorkflowTemplateModel = mongoose.model<WorkflowTemplateDocument>(
|
|
56
|
+
"WorkflowTemplate",
|
|
57
|
+
WorkflowTemplateObjectSchema
|
|
58
|
+
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ainetwork/adk-provider-memory-mongodb",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"author": "AI Network (https://ainetwork.ai)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"clean": "rm -rf dist"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@ainetwork/adk": "^0.
|
|
31
|
+
"@ainetwork/adk": "^0.5.0",
|
|
32
32
|
"mongoose": "^8.16.5"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"publishConfig": {
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "8c14fa8de70f23589cd273772db665f354f3e713"
|
|
42
42
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../models/messages.model.ts"],"sourcesContent":["import { MessageRole } from \"@ainetwork/adk/types/memory\";\nimport { type Document, Schema } from \"mongoose\";\nimport mongoose from \"mongoose\";\n\n// MessageContentObject schema\nexport const MessageContentObjectSchema = new Schema(\n\t{\n\t\ttype: { type: String, required: true },\n\t\tparts: { type: [Schema.Types.Mixed], required: true },\n\t},\n\t{ _id: false },\n);\n\n// MessageObject schema - 개별 문서로 저장\nexport const MessageObjectSchema = new Schema(\n\t{\n\t\tmessageId: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t\tindex: true,\n\t\t},\n\t\tthreadId: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t\tindex: true,\n\t\t},\n\t\tuserId: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t\tindex: true,\n\t\t},\n\t\trole: {\n\t\t\ttype: String,\n\t\t\tenum: Object.values(MessageRole),\n\t\t\trequired: true,\n\t\t},\n\t\tcontent: {\n\t\t\ttype: MessageContentObjectSchema,\n\t\t\trequired: true,\n\t\t},\n\t\ttimestamp: {\n\t\t\ttype: Number,\n\t\t\trequired: true,\n\t\t},\n\t\tmetadata: {\n\t\t\ttype: Schema.Types.Mixed,\n\t\t\tdefault: {},\n\t\t},\n\t},\n);\n\n// Message Document interface\nexport interface MessageDocument extends Document {\n\tmessageId: string;\n\tthreadId: string;\n\tuserId: string;\n\trole: MessageRole;\n\tcontent: {\n\t\ttype: string;\n\t\tparts: any[];\n\t};\n\ttimestamp: number;\n\tmetadata?: { [key: string]: unknown };\n}\n\nexport const MessageModel = mongoose.model<MessageDocument>(\"Message\", MessageObjectSchema);"],"mappings":";AAAA,SAAS,mBAAmB;AAC5B,SAAwB,cAAc;AACtC,OAAO,cAAc;AAGd,IAAM,6BAA6B,IAAI;AAAA,EAC7C;AAAA,IACC,MAAM,EAAE,MAAM,QAAQ,UAAU,KAAK;AAAA,IACrC,OAAO,EAAE,MAAM,CAAC,OAAO,MAAM,KAAK,GAAG,UAAU,KAAK;AAAA,EACrD;AAAA,EACA,EAAE,KAAK,MAAM;AACd;AAGO,IAAM,sBAAsB,IAAI;AAAA,EACtC;AAAA,IACC,WAAW;AAAA,MACV,MAAM;AAAA,MACN,UAAU;AAAA,MACV,OAAO;AAAA,IACR;AAAA,IACA,UAAU;AAAA,MACT,MAAM;AAAA,MACN,UAAU;AAAA,MACV,OAAO;AAAA,IACR;AAAA,IACA,QAAQ;AAAA,MACP,MAAM;AAAA,MACN,UAAU;AAAA,MACV,OAAO;AAAA,IACR;AAAA,IACA,MAAM;AAAA,MACL,MAAM;AAAA,MACN,MAAM,OAAO,OAAO,WAAW;AAAA,MAC/B,UAAU;AAAA,IACX;AAAA,IACA,SAAS;AAAA,MACR,MAAM;AAAA,MACN,UAAU;AAAA,IACX;AAAA,IACA,WAAW;AAAA,MACV,MAAM;AAAA,MACN,UAAU;AAAA,IACX;AAAA,IACA,UAAU;AAAA,MACT,MAAM,OAAO,MAAM;AAAA,MACnB,SAAS,CAAC;AAAA,IACX;AAAA,EACD;AACD;AAgBO,IAAM,eAAe,SAAS,MAAuB,WAAW,mBAAmB;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../models/threads.model.ts"],"sourcesContent":["import { ThreadType } from \"@ainetwork/adk/types/memory\";\nimport { type Document, Schema } from \"mongoose\";\nimport mongoose from \"mongoose\";\n\nexport const ThreadObjectSchema = new Schema(\n\t{\n\t\ttype: {\n\t\t\ttype: String,\n\t\t\tenum: Object.values(ThreadType),\n\t\t\trequired: true,\n\t\t},\n\t\tthreadId: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t\tindex: true,\n\t\t},\n\t\tuserId: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t\tindex: true,\n\t\t},\n\t\ttitle: {\n\t\t\ttype: String,\n\t\t\trequired: false,\n\t\t},\n\t\tcreated_at: {\n\t\t\ttype: Number,\n\t\t\trequired: true,\n\t\t},\n\t\tupdated_at: {\n\t\t\ttype: Number,\n\t\t\trequired: true,\n\t\t}\n\t},\n);\n\nexport interface ThreadDocument extends Document {\n\ttype: ThreadType;\n\tthreadId: string;\n\tuserId: string;\n\ttitle: string;\n\tcreated_at: number;\n\tupdated_at: number;\n}\n\nexport const ThreadModel = mongoose.model<ThreadDocument>(\"Thread\", ThreadObjectSchema);\n"],"mappings":";AAAA,SAAS,kBAAkB;AAC3B,SAAwB,cAAc;AACtC,OAAO,cAAc;AAEd,IAAM,qBAAqB,IAAI;AAAA,EACrC;AAAA,IACC,MAAM;AAAA,MACL,MAAM;AAAA,MACN,MAAM,OAAO,OAAO,UAAU;AAAA,MAC9B,UAAU;AAAA,IACX;AAAA,IACA,UAAU;AAAA,MACT,MAAM;AAAA,MACN,UAAU;AAAA,MACV,OAAO;AAAA,IACR;AAAA,IACA,QAAQ;AAAA,MACP,MAAM;AAAA,MACN,UAAU;AAAA,MACV,OAAO;AAAA,IACR;AAAA,IACA,OAAO;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,IACX;AAAA,IACA,YAAY;AAAA,MACX,MAAM;AAAA,MACN,UAAU;AAAA,IACX;AAAA,IACA,YAAY;AAAA,MACX,MAAM;AAAA,MACN,UAAU;AAAA,IACX;AAAA,EACD;AACD;AAWO,IAAM,cAAc,SAAS,MAAsB,UAAU,kBAAkB;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../models/workflow.model.ts"],"sourcesContent":["import { type Document, Schema } from \"mongoose\";\nimport mongoose from \"mongoose\";\n\nexport const WorkflowObjectSchema = new Schema(\n\t{\n\t\tworkflowId: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t\tunique: true,\n\t\t},\n\t\tuserId: {\n\t\t\ttype: String,\n\t\t},\n\t\ttitle: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t\tdescription: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t\tactive: {\n\t\t\ttype: Boolean,\n\t\t\trequired: true,\n\t\t\tdefault: false,\n\t\t},\n\t\tcontent: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t},\n\t{\n\t\ttimestamps: true,\n\t}\n);\n\nexport interface WorkflowDocument extends Document {\n\tworkflowId: string;\n\tuserId?: string;\n\ttitle: string;\n\tdescription: string;\n\tactive: boolean;\n\tcontent: string;\n}\n\nexport const WorkflowModel = mongoose.model<WorkflowDocument>(\"Workflow\", WorkflowObjectSchema);\n"],"mappings":";AAAA,SAAwB,cAAc;AACtC,OAAO,cAAc;AAEd,IAAM,uBAAuB,IAAI;AAAA,EACvC;AAAA,IACC,YAAY;AAAA,MACX,MAAM;AAAA,MACN,UAAU;AAAA,MACV,QAAQ;AAAA,IACT;AAAA,IACA,QAAQ;AAAA,MACP,MAAM;AAAA,IACP;AAAA,IACA,OAAO;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,IACX;AAAA,IACA,aAAa;AAAA,MACZ,MAAM;AAAA,MACN,UAAU;AAAA,IACX;AAAA,IACA,QAAQ;AAAA,MACP,MAAM;AAAA,MACN,UAAU;AAAA,MACV,SAAS;AAAA,IACV;AAAA,IACA,SAAS;AAAA,MACR,MAAM;AAAA,MACN,UAAU;AAAA,IACX;AAAA,EACD;AAAA,EACA;AAAA,IACC,YAAY;AAAA,EACb;AACD;AAWO,IAAM,gBAAgB,SAAS,MAAwB,YAAY,oBAAoB;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../models/workflow.model.ts"],"sourcesContent":["import { type Document, Schema } from \"mongoose\";\nimport mongoose from \"mongoose\";\n\nexport const WorkflowObjectSchema = new Schema(\n\t{\n\t\tworkflowId: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t\tunique: true,\n\t\t},\n\t\tuserId: {\n\t\t\ttype: String,\n\t\t},\n\t\ttitle: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t\tdescription: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t\tactive: {\n\t\t\ttype: Boolean,\n\t\t\trequired: true,\n\t\t\tdefault: false,\n\t\t},\n\t\tcontent: {\n\t\t\ttype: String,\n\t\t\trequired: true,\n\t\t},\n\t},\n\t{\n\t\ttimestamps: true,\n\t}\n);\n\nexport interface WorkflowDocument extends Document {\n\tworkflowId: string;\n\tuserId?: string;\n\ttitle: string;\n\tdescription: string;\n\tactive: boolean;\n\tcontent: string;\n}\n\nexport const WorkflowModel = mongoose.model<WorkflowDocument>(\"Workflow\", WorkflowObjectSchema);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAsC;AACtC,IAAAA,mBAAqB;AAEd,IAAM,uBAAuB,IAAI;AAAA,EACvC;AAAA,IACC,YAAY;AAAA,MACX,MAAM;AAAA,MACN,UAAU;AAAA,MACV,QAAQ;AAAA,IACT;AAAA,IACA,QAAQ;AAAA,MACP,MAAM;AAAA,IACP;AAAA,IACA,OAAO;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,IACX;AAAA,IACA,aAAa;AAAA,MACZ,MAAM;AAAA,MACN,UAAU;AAAA,IACX;AAAA,IACA,QAAQ;AAAA,MACP,MAAM;AAAA,MACN,UAAU;AAAA,MACV,SAAS;AAAA,IACV;AAAA,IACA,SAAS;AAAA,MACR,MAAM;AAAA,MACN,UAAU;AAAA,IACX;AAAA,EACD;AAAA,EACA;AAAA,IACC,YAAY;AAAA,EACb;AACD;AAWO,IAAM,gBAAgB,iBAAAC,QAAS,MAAwB,YAAY,oBAAoB;","names":["import_mongoose","mongoose"]}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import mongoose, { Schema, Document } from 'mongoose';
|
|
2
|
-
|
|
3
|
-
declare const WorkflowObjectSchema: Schema<any, mongoose.Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
4
|
-
timestamps: true;
|
|
5
|
-
}, {
|
|
6
|
-
createdAt: NativeDate;
|
|
7
|
-
updatedAt: NativeDate;
|
|
8
|
-
} & {
|
|
9
|
-
description: string;
|
|
10
|
-
title: string;
|
|
11
|
-
content: string;
|
|
12
|
-
workflowId: string;
|
|
13
|
-
active: boolean;
|
|
14
|
-
userId?: string | null | undefined;
|
|
15
|
-
}, Document<unknown, {}, mongoose.FlatRecord<{
|
|
16
|
-
createdAt: NativeDate;
|
|
17
|
-
updatedAt: NativeDate;
|
|
18
|
-
} & {
|
|
19
|
-
description: string;
|
|
20
|
-
title: string;
|
|
21
|
-
content: string;
|
|
22
|
-
workflowId: string;
|
|
23
|
-
active: boolean;
|
|
24
|
-
userId?: string | null | undefined;
|
|
25
|
-
}>, {}> & mongoose.FlatRecord<{
|
|
26
|
-
createdAt: NativeDate;
|
|
27
|
-
updatedAt: NativeDate;
|
|
28
|
-
} & {
|
|
29
|
-
description: string;
|
|
30
|
-
title: string;
|
|
31
|
-
content: string;
|
|
32
|
-
workflowId: string;
|
|
33
|
-
active: boolean;
|
|
34
|
-
userId?: string | null | undefined;
|
|
35
|
-
}> & {
|
|
36
|
-
_id: mongoose.Types.ObjectId;
|
|
37
|
-
} & {
|
|
38
|
-
__v: number;
|
|
39
|
-
}>;
|
|
40
|
-
interface WorkflowDocument extends Document {
|
|
41
|
-
workflowId: string;
|
|
42
|
-
userId?: string;
|
|
43
|
-
title: string;
|
|
44
|
-
description: string;
|
|
45
|
-
active: boolean;
|
|
46
|
-
content: string;
|
|
47
|
-
}
|
|
48
|
-
declare const WorkflowModel: mongoose.Model<WorkflowDocument, {}, {}, {}, Document<unknown, {}, WorkflowDocument, {}> & WorkflowDocument & Required<{
|
|
49
|
-
_id: unknown;
|
|
50
|
-
}> & {
|
|
51
|
-
__v: number;
|
|
52
|
-
}, any>;
|
|
53
|
-
|
|
54
|
-
export { type WorkflowDocument, WorkflowModel, WorkflowObjectSchema };
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import mongoose, { Schema, Document } from 'mongoose';
|
|
2
|
-
|
|
3
|
-
declare const WorkflowObjectSchema: Schema<any, mongoose.Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
4
|
-
timestamps: true;
|
|
5
|
-
}, {
|
|
6
|
-
createdAt: NativeDate;
|
|
7
|
-
updatedAt: NativeDate;
|
|
8
|
-
} & {
|
|
9
|
-
description: string;
|
|
10
|
-
title: string;
|
|
11
|
-
content: string;
|
|
12
|
-
workflowId: string;
|
|
13
|
-
active: boolean;
|
|
14
|
-
userId?: string | null | undefined;
|
|
15
|
-
}, Document<unknown, {}, mongoose.FlatRecord<{
|
|
16
|
-
createdAt: NativeDate;
|
|
17
|
-
updatedAt: NativeDate;
|
|
18
|
-
} & {
|
|
19
|
-
description: string;
|
|
20
|
-
title: string;
|
|
21
|
-
content: string;
|
|
22
|
-
workflowId: string;
|
|
23
|
-
active: boolean;
|
|
24
|
-
userId?: string | null | undefined;
|
|
25
|
-
}>, {}> & mongoose.FlatRecord<{
|
|
26
|
-
createdAt: NativeDate;
|
|
27
|
-
updatedAt: NativeDate;
|
|
28
|
-
} & {
|
|
29
|
-
description: string;
|
|
30
|
-
title: string;
|
|
31
|
-
content: string;
|
|
32
|
-
workflowId: string;
|
|
33
|
-
active: boolean;
|
|
34
|
-
userId?: string | null | undefined;
|
|
35
|
-
}> & {
|
|
36
|
-
_id: mongoose.Types.ObjectId;
|
|
37
|
-
} & {
|
|
38
|
-
__v: number;
|
|
39
|
-
}>;
|
|
40
|
-
interface WorkflowDocument extends Document {
|
|
41
|
-
workflowId: string;
|
|
42
|
-
userId?: string;
|
|
43
|
-
title: string;
|
|
44
|
-
description: string;
|
|
45
|
-
active: boolean;
|
|
46
|
-
content: string;
|
|
47
|
-
}
|
|
48
|
-
declare const WorkflowModel: mongoose.Model<WorkflowDocument, {}, {}, {}, Document<unknown, {}, WorkflowDocument, {}> & WorkflowDocument & Required<{
|
|
49
|
-
_id: unknown;
|
|
50
|
-
}> & {
|
|
51
|
-
__v: number;
|
|
52
|
-
}, any>;
|
|
53
|
-
|
|
54
|
-
export { type WorkflowDocument, WorkflowModel, WorkflowObjectSchema };
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import type { IWorkflowMemory } from "@ainetwork/adk/modules";
|
|
2
|
-
import type { Workflow } from "@ainetwork/adk/types/memory";
|
|
3
|
-
import { WorkflowModel } from "../models/workflow.model";
|
|
4
|
-
|
|
5
|
-
export type ExecuteWithRetryFn = <T>(
|
|
6
|
-
operation: () => Promise<T>,
|
|
7
|
-
operationName?: string
|
|
8
|
-
) => Promise<T>;
|
|
9
|
-
|
|
10
|
-
export type GetOperationTimeoutFn = () => number;
|
|
11
|
-
|
|
12
|
-
export class MongoDBWorkflow implements IWorkflowMemory {
|
|
13
|
-
private executeWithRetry: ExecuteWithRetryFn;
|
|
14
|
-
private getOperationTimeout: GetOperationTimeoutFn;
|
|
15
|
-
|
|
16
|
-
constructor(
|
|
17
|
-
executeWithRetry: ExecuteWithRetryFn,
|
|
18
|
-
getOperationTimeout: GetOperationTimeoutFn
|
|
19
|
-
) {
|
|
20
|
-
this.executeWithRetry = executeWithRetry;
|
|
21
|
-
this.getOperationTimeout = getOperationTimeout;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
public async createWorkflow(workflow: Workflow): Promise<Workflow> {
|
|
25
|
-
return this.executeWithRetry(async () => {
|
|
26
|
-
const timeout = this.getOperationTimeout();
|
|
27
|
-
const created = await WorkflowModel.create(workflow);
|
|
28
|
-
return created.toObject() as Workflow;
|
|
29
|
-
}, "createWorkflow()");
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
public async getWorkflow(workflowId: string): Promise<Workflow | undefined> {
|
|
33
|
-
return this.executeWithRetry(async () => {
|
|
34
|
-
const timeout = this.getOperationTimeout();
|
|
35
|
-
const workflow = await WorkflowModel.findOne({
|
|
36
|
-
workflowId
|
|
37
|
-
}).maxTimeMS(timeout).lean<Workflow>();
|
|
38
|
-
return workflow || undefined;
|
|
39
|
-
}, "getWorkflow()");
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
public async updateWorkflow(workflowId: string, updates: Partial<Workflow>): Promise<void> {
|
|
43
|
-
if (!updates.userId) {
|
|
44
|
-
throw new Error("userId is required for updateWorkflow");
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return this.executeWithRetry(async () => {
|
|
48
|
-
const timeout = this.getOperationTimeout();
|
|
49
|
-
// userId를 조건에 포함하여 소유자만 수정 가능하도록 함
|
|
50
|
-
await WorkflowModel.updateOne(
|
|
51
|
-
{ workflowId, userId: updates.userId },
|
|
52
|
-
{ $set: updates }
|
|
53
|
-
).maxTimeMS(timeout);
|
|
54
|
-
}, "updateWorkflow()");
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
public async deleteWorkflow(workflowId: string, userId: string): Promise<void> {
|
|
58
|
-
return this.executeWithRetry(async () => {
|
|
59
|
-
const timeout = this.getOperationTimeout();
|
|
60
|
-
await WorkflowModel.deleteOne({ workflowId, userId }).maxTimeMS(timeout);
|
|
61
|
-
}, "deleteWorkflow()");
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
public async listWorkflows(userId?: string): Promise<Workflow[]> {
|
|
65
|
-
return this.executeWithRetry(async () => {
|
|
66
|
-
const timeout = this.getOperationTimeout();
|
|
67
|
-
// userId가 있으면: 해당 유저 소유 + 템플릿(userId 없음)
|
|
68
|
-
// userId가 없으면: 템플릿만 반환
|
|
69
|
-
const query = userId
|
|
70
|
-
? { $or: [{ userId }, { userId: { $exists: false } }, { userId: null }] }
|
|
71
|
-
: { $or: [{ userId: { $exists: false } }, { userId: null }] };
|
|
72
|
-
const workflows = await WorkflowModel.find(query)
|
|
73
|
-
.maxTimeMS(timeout)
|
|
74
|
-
.lean<Workflow[]>();
|
|
75
|
-
return workflows;
|
|
76
|
-
}, "listWorkflows()");
|
|
77
|
-
}
|
|
78
|
-
}
|
package/models/workflow.model.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { type Document, Schema } from "mongoose";
|
|
2
|
-
import mongoose from "mongoose";
|
|
3
|
-
|
|
4
|
-
export const WorkflowObjectSchema = new Schema(
|
|
5
|
-
{
|
|
6
|
-
workflowId: {
|
|
7
|
-
type: String,
|
|
8
|
-
required: true,
|
|
9
|
-
unique: true,
|
|
10
|
-
},
|
|
11
|
-
userId: {
|
|
12
|
-
type: String,
|
|
13
|
-
},
|
|
14
|
-
title: {
|
|
15
|
-
type: String,
|
|
16
|
-
required: true,
|
|
17
|
-
},
|
|
18
|
-
description: {
|
|
19
|
-
type: String,
|
|
20
|
-
required: true,
|
|
21
|
-
},
|
|
22
|
-
active: {
|
|
23
|
-
type: Boolean,
|
|
24
|
-
required: true,
|
|
25
|
-
default: false,
|
|
26
|
-
},
|
|
27
|
-
content: {
|
|
28
|
-
type: String,
|
|
29
|
-
required: true,
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
timestamps: true,
|
|
34
|
-
}
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
export interface WorkflowDocument extends Document {
|
|
38
|
-
workflowId: string;
|
|
39
|
-
userId?: string;
|
|
40
|
-
title: string;
|
|
41
|
-
description: string;
|
|
42
|
-
active: boolean;
|
|
43
|
-
content: string;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export const WorkflowModel = mongoose.model<WorkflowDocument>("Workflow", WorkflowObjectSchema);
|
|
File without changes
|