agentlang 0.7.4 → 0.7.6
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 -1
- package/out/api/http.d.ts.map +1 -1
- package/out/api/http.js +39 -1
- package/out/api/http.js.map +1 -1
- package/out/runtime/interpreter.d.ts.map +1 -1
- package/out/runtime/interpreter.js +18 -10
- package/out/runtime/interpreter.js.map +1 -1
- package/out/runtime/module.d.ts +3 -0
- package/out/runtime/module.d.ts.map +1 -1
- package/out/runtime/module.js +61 -2
- package/out/runtime/module.js.map +1 -1
- package/out/runtime/modules/ai.d.ts +7 -0
- package/out/runtime/modules/ai.d.ts.map +1 -1
- package/out/runtime/modules/ai.js +84 -13
- package/out/runtime/modules/ai.js.map +1 -1
- package/out/runtime/modules/core.d.ts.map +1 -1
- package/out/runtime/modules/core.js +29 -9
- package/out/runtime/modules/core.js.map +1 -1
- package/out/runtime/monitor.d.ts +3 -0
- package/out/runtime/monitor.d.ts.map +1 -1
- package/out/runtime/monitor.js +49 -0
- package/out/runtime/monitor.js.map +1 -1
- package/out/runtime/resolvers/interface.d.ts +2 -2
- package/out/runtime/resolvers/interface.d.ts.map +1 -1
- package/out/runtime/resolvers/interface.js +3 -3
- package/out/runtime/resolvers/interface.js.map +1 -1
- package/out/runtime/resolvers/sqldb/database.d.ts +1 -1
- package/out/runtime/resolvers/sqldb/database.d.ts.map +1 -1
- package/out/runtime/resolvers/sqldb/database.js +3 -1
- package/out/runtime/resolvers/sqldb/database.js.map +1 -1
- package/out/runtime/resolvers/sqldb/impl.d.ts +2 -2
- package/out/runtime/resolvers/sqldb/impl.d.ts.map +1 -1
- package/out/runtime/resolvers/sqldb/impl.js +18 -12
- package/out/runtime/resolvers/sqldb/impl.js.map +1 -1
- package/out/runtime/state.d.ts +8 -0
- package/out/runtime/state.d.ts.map +1 -1
- package/out/runtime/state.js +34 -0
- package/out/runtime/state.js.map +1 -1
- package/out/runtime/util.d.ts +1 -0
- package/out/runtime/util.d.ts.map +1 -1
- package/out/runtime/util.js +1 -0
- package/out/runtime/util.js.map +1 -1
- package/out/setupClassic.d.ts +98 -0
- package/out/setupClassic.d.ts.map +1 -0
- package/out/setupClassic.js +38 -0
- package/out/setupClassic.js.map +1 -0
- package/out/setupCommon.d.ts +2 -0
- package/out/setupCommon.d.ts.map +1 -0
- package/out/setupCommon.js +33 -0
- package/out/setupCommon.js.map +1 -0
- package/out/setupExtended.d.ts +40 -0
- package/out/setupExtended.d.ts.map +1 -0
- package/out/setupExtended.js +67 -0
- package/out/setupExtended.js.map +1 -0
- package/package.json +186 -185
- package/src/api/http.ts +64 -0
- package/src/runtime/interpreter.ts +30 -10
- package/src/runtime/module.ts +75 -1
- package/src/runtime/modules/ai.ts +99 -12
- package/src/runtime/modules/core.ts +34 -13
- package/src/runtime/monitor.ts +54 -0
- package/src/runtime/resolvers/interface.ts +5 -4
- package/src/runtime/resolvers/sqldb/database.ts +5 -3
- package/src/runtime/resolvers/sqldb/impl.ts +39 -22
- package/src/runtime/state.ts +47 -0
- package/src/runtime/util.ts +2 -0
package/package.json
CHANGED
|
@@ -1,186 +1,187 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
2
|
+
"name": "agentlang",
|
|
3
|
+
"description": "The easiest way to build the most reliable AI agents - enterprise-grade teams of AI agents that collaborate with each other and humans",
|
|
4
|
+
"version": "0.7.6",
|
|
5
|
+
"license": "Sustainable Use License",
|
|
6
|
+
"author": "agentlang-ai",
|
|
7
|
+
"homepage": "https://github.com/agentlang-ai/agentlang#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/agentlang-ai/agentlang.git"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/agentlang-ai/agentlang/issues"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"agentlang",
|
|
17
|
+
"agents-generation",
|
|
18
|
+
"ai-agents",
|
|
19
|
+
"enterprise",
|
|
20
|
+
"multi-agent",
|
|
21
|
+
"no-code",
|
|
22
|
+
"agent-teams",
|
|
23
|
+
"production-ready"
|
|
24
|
+
],
|
|
25
|
+
"files": [
|
|
26
|
+
"bin",
|
|
27
|
+
"out",
|
|
28
|
+
"src",
|
|
29
|
+
"LICENSE"
|
|
30
|
+
],
|
|
31
|
+
"type": "module",
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public",
|
|
34
|
+
"registry": "https://registry.npmjs.org/"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "tsc -b tsconfig.src.json && tsc -b tsconfig.declarations.json && node esbuild.mjs",
|
|
38
|
+
"build:ts": "tsc -b tsconfig.src.json",
|
|
39
|
+
"watch": "concurrently -n tsc,esbuild -c blue,yellow \"tsc -b tsconfig.src.json --watch\" \"node esbuild.mjs --watch\"",
|
|
40
|
+
"lint": "eslint . --ext .ts",
|
|
41
|
+
"lint:fix": "eslint . --ext .ts --fix",
|
|
42
|
+
"format": "prettier --write \"src/**/*.{js,ts,tsx,json,md}\"",
|
|
43
|
+
"format:check": "prettier --check \"src/**/*.{js,ts,tsx,json,md}\"",
|
|
44
|
+
"langium:generate": "langium generate",
|
|
45
|
+
"langium:generate:production": "langium generate --mode=production",
|
|
46
|
+
"langium:watch": "langium generate --watch",
|
|
47
|
+
"vscode:prepublish": "npm run build && npm run lint",
|
|
48
|
+
"dev": "vite",
|
|
49
|
+
"test": "vitest run",
|
|
50
|
+
"test:verbose": "VITEST_VERBOSE=true vitest run"
|
|
51
|
+
},
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"@aws-sdk/client-cognito-identity": "^3.828.0",
|
|
54
|
+
"@aws-sdk/client-cognito-identity-provider": "^3.828.0",
|
|
55
|
+
"@aws-sdk/credential-providers": "^3.828.0",
|
|
56
|
+
"@isomorphic-git/lightning-fs": "^4.6.1",
|
|
57
|
+
"@langchain/anthropic": "^0.3.32",
|
|
58
|
+
"@langchain/core": "^0.3.78",
|
|
59
|
+
"@langchain/openai": "^0.6.16",
|
|
60
|
+
"@types/jsonwebtoken": "^9.0.10",
|
|
61
|
+
"@types/multer": "^1.4.5-lts.1",
|
|
62
|
+
"amazon-cognito-identity-js": "^6.3.15",
|
|
63
|
+
"aws-jwt-verify": "^5.1.0",
|
|
64
|
+
"bcryptjs": "^3.0.2",
|
|
65
|
+
"buffer": "^6.0.3",
|
|
66
|
+
"chalk": "~5.3.0",
|
|
67
|
+
"commander": "~11.0.0",
|
|
68
|
+
"express": "^5.1.0",
|
|
69
|
+
"handlebars": "^4.7.8",
|
|
70
|
+
"jsonwebtoken": "^9.0.2",
|
|
71
|
+
"langchain": "^0.3.36",
|
|
72
|
+
"langium": "^3.5.0",
|
|
73
|
+
"multer": "^1.4.5-lts.1",
|
|
74
|
+
"openapi-client-axios": "^7.6.0",
|
|
75
|
+
"pg": "^8.16.1",
|
|
76
|
+
"pgvector": "^0.2.1",
|
|
77
|
+
"sql.js": "^1.13.0",
|
|
78
|
+
"sqlite3": "^5.1.7",
|
|
79
|
+
"typeorm": "^0.3.25",
|
|
80
|
+
"vscode-languageserver": "^9.0.1",
|
|
81
|
+
"winston": "^3.17.0",
|
|
82
|
+
"winston-daily-rotate-file": "^5.0.0",
|
|
83
|
+
"zod": "^3.25.55"
|
|
84
|
+
},
|
|
85
|
+
"overrides": {
|
|
86
|
+
"semver": "^7.5.3",
|
|
87
|
+
"trim-newlines": ">=3.0.1"
|
|
88
|
+
},
|
|
89
|
+
"devDependencies": {
|
|
90
|
+
"@codingame/esbuild-import-meta-url-plugin": "~1.0.2",
|
|
91
|
+
"@eslint/js": "^9.26.0",
|
|
92
|
+
"@types/cookie-parser": "^1.4.9",
|
|
93
|
+
"@types/express": "^5.0.1",
|
|
94
|
+
"@types/node": "^18.19.110",
|
|
95
|
+
"@types/sql.js": "^1.4.9",
|
|
96
|
+
"@types/vscode": "^1.100.0",
|
|
97
|
+
"@typescript-eslint/eslint-plugin": "~8.32.1",
|
|
98
|
+
"@typescript-eslint/parser": "~8.32.1",
|
|
99
|
+
"brace-expansion": ">=2.0.2",
|
|
100
|
+
"concurrently": "~8.2.1",
|
|
101
|
+
"esbuild": "^0.25.4",
|
|
102
|
+
"eslint": "^9.39.1",
|
|
103
|
+
"generator-langium": "^3.0.0",
|
|
104
|
+
"http-server": "~14.1.1",
|
|
105
|
+
"langium-cli": "^3.5.0",
|
|
106
|
+
"nodemon": "^3.1.10",
|
|
107
|
+
"prettier": "^3.5.3",
|
|
108
|
+
"typescript": "^5.8.3",
|
|
109
|
+
"typescript-eslint": "^8.32.1",
|
|
110
|
+
"vite": "^6.3.5",
|
|
111
|
+
"vite-plugin-node-polyfills": "^0.24.0",
|
|
112
|
+
"vitest": "^3.1.3",
|
|
113
|
+
"vscode-languageclient": "^9.0.1",
|
|
114
|
+
"vscode-uri": "^3.1.0"
|
|
115
|
+
},
|
|
116
|
+
"volta": {
|
|
117
|
+
"node": ">=20.0.0",
|
|
118
|
+
"npm": ">=10.8.2"
|
|
119
|
+
},
|
|
120
|
+
"displayName": "agentlang",
|
|
121
|
+
"engines": {
|
|
122
|
+
"vscode": "^1.67.0",
|
|
123
|
+
"node": ">=20.0.0"
|
|
124
|
+
},
|
|
125
|
+
"categories": [
|
|
126
|
+
"Programming Languages"
|
|
127
|
+
],
|
|
128
|
+
"contributes": {
|
|
129
|
+
"languages": [
|
|
130
|
+
{
|
|
131
|
+
"id": "agentlang",
|
|
132
|
+
"aliases": [
|
|
133
|
+
"Agentlang",
|
|
134
|
+
"agentlang"
|
|
135
|
+
],
|
|
136
|
+
"extensions": [
|
|
137
|
+
".al"
|
|
138
|
+
],
|
|
139
|
+
"configuration": "./language-configuration.json"
|
|
140
|
+
}
|
|
141
|
+
],
|
|
142
|
+
"grammars": [
|
|
143
|
+
{
|
|
144
|
+
"language": "agentlang",
|
|
145
|
+
"scopeName": "source.agentlang",
|
|
146
|
+
"path": "syntaxes/agentlang.tmLanguage.json"
|
|
147
|
+
}
|
|
148
|
+
]
|
|
149
|
+
},
|
|
150
|
+
"activationEvents": [
|
|
151
|
+
"onLanguage:agentlang"
|
|
152
|
+
],
|
|
153
|
+
"main": "./out/extension/main.cjs",
|
|
154
|
+
"types": "./out/index.d.ts",
|
|
155
|
+
"exports": {
|
|
156
|
+
".": {
|
|
157
|
+
"types": "./out/index.d.ts",
|
|
158
|
+
"import": "./out/extension/main.cjs",
|
|
159
|
+
"require": "./out/extension/main.cjs"
|
|
160
|
+
},
|
|
161
|
+
"./browser": {
|
|
162
|
+
"types": "./out/browser.d.ts",
|
|
163
|
+
"import": "./out/browser.js",
|
|
164
|
+
"default": "./out/browser.js"
|
|
165
|
+
},
|
|
166
|
+
"./src/*": {
|
|
167
|
+
"types": "./out/*.d.ts",
|
|
168
|
+
"import": "./out/*.js",
|
|
169
|
+
"require": "./out/*.js",
|
|
170
|
+
"default": "./out/*.js"
|
|
171
|
+
},
|
|
172
|
+
"./out/*": "./out/*"
|
|
173
|
+
},
|
|
174
|
+
"bin": {
|
|
175
|
+
"agentlang-cli": "./bin/cli.js"
|
|
176
|
+
},
|
|
177
|
+
"lint-staged": {
|
|
178
|
+
"*.{js,ts,tsx}": [
|
|
179
|
+
"eslint --fix --cache",
|
|
180
|
+
"prettier --write"
|
|
181
|
+
],
|
|
182
|
+
"*.{json,md,yml,yaml}": [
|
|
183
|
+
"prettier --write"
|
|
184
|
+
]
|
|
185
|
+
},
|
|
186
|
+
"packageManager": "pnpm@10.22.0"
|
|
187
|
+
}
|
package/src/api/http.ts
CHANGED
|
@@ -17,6 +17,8 @@ import {
|
|
|
17
17
|
fetchRefTarget,
|
|
18
18
|
getAttributeNames,
|
|
19
19
|
Module,
|
|
20
|
+
getAllBetweenRelationshipNames,
|
|
21
|
+
linkInstancesEvent,
|
|
20
22
|
} from '../runtime/module.js';
|
|
21
23
|
import { isNodeEnv } from '../utils/runtime.js';
|
|
22
24
|
import { parseAndEvaluateStatement, Result } from '../runtime/interpreter.js';
|
|
@@ -264,6 +266,24 @@ export async function startServer(
|
|
|
264
266
|
});
|
|
265
267
|
});
|
|
266
268
|
|
|
269
|
+
const addBetweenHandlers = (moduleName: string, n: string) => {
|
|
270
|
+
app.get(`/${moduleName}/${n}`, (req: Request, res: Response) => {
|
|
271
|
+
handleEntityGet(moduleName, n, req, res);
|
|
272
|
+
});
|
|
273
|
+
app.post(`/${moduleName}/${n}`, (req: Request, res: Response) => {
|
|
274
|
+
handleBetweenRelationshipPost(moduleName, n, req, res);
|
|
275
|
+
});
|
|
276
|
+
app.delete(`/${moduleName}/${n}`, (req: Request, res: Response) => {
|
|
277
|
+
handleBetweenRelationshipDelete(moduleName, n, req, res);
|
|
278
|
+
});
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
getAllBetweenRelationshipNames().forEach((entityNames: string[], moduleName: string) => {
|
|
282
|
+
entityNames.forEach((n: string) => {
|
|
283
|
+
addBetweenHandlers(moduleName, n);
|
|
284
|
+
});
|
|
285
|
+
});
|
|
286
|
+
|
|
267
287
|
const cb = () => {
|
|
268
288
|
console.log(
|
|
269
289
|
chalk.green(
|
|
@@ -584,6 +604,50 @@ async function handleEntityDelete(
|
|
|
584
604
|
}
|
|
585
605
|
}
|
|
586
606
|
|
|
607
|
+
async function handleBetweenRelationshipLinking(
|
|
608
|
+
moduleName: string,
|
|
609
|
+
betweenRelName: string,
|
|
610
|
+
req: Request,
|
|
611
|
+
res: Response,
|
|
612
|
+
unlink: boolean
|
|
613
|
+
): Promise<void> {
|
|
614
|
+
try {
|
|
615
|
+
const sessionInfo = await verifyAuth(moduleName, betweenRelName, req.headers.authorization);
|
|
616
|
+
if (isNoSession(sessionInfo)) {
|
|
617
|
+
res.status(401).send('Authorization required');
|
|
618
|
+
return;
|
|
619
|
+
}
|
|
620
|
+
const path = await linkInstancesEvent(moduleName, betweenRelName, unlink);
|
|
621
|
+
const pattern = patternFromAttributes(
|
|
622
|
+
path.getModuleName(),
|
|
623
|
+
path.getEntryName(),
|
|
624
|
+
objectAsInstanceAttributes(req.body)
|
|
625
|
+
);
|
|
626
|
+
parseAndEvaluateStatement(pattern, sessionInfo.userId).then(ok(res)).catch(internalError(res));
|
|
627
|
+
} catch (err: any) {
|
|
628
|
+
logger.error(err);
|
|
629
|
+
res.status(500).send(err.toString());
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
async function handleBetweenRelationshipPost(
|
|
634
|
+
moduleName: string,
|
|
635
|
+
betweenRelName: string,
|
|
636
|
+
req: Request,
|
|
637
|
+
res: Response
|
|
638
|
+
): Promise<void> {
|
|
639
|
+
await handleBetweenRelationshipLinking(moduleName, betweenRelName, req, res, false);
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
async function handleBetweenRelationshipDelete(
|
|
643
|
+
moduleName: string,
|
|
644
|
+
betweenRelName: string,
|
|
645
|
+
req: Request,
|
|
646
|
+
res: Response
|
|
647
|
+
): Promise<void> {
|
|
648
|
+
await handleBetweenRelationshipLinking(moduleName, betweenRelName, req, res, true);
|
|
649
|
+
}
|
|
650
|
+
|
|
587
651
|
function fetchTreePattern(fqName: string, path?: string): string {
|
|
588
652
|
let pattern = path ? `{${fqName} {${PathAttributeNameQuery} "${path}"}` : `{${fqName}? {}`;
|
|
589
653
|
const rels = getAllChildRelationships(fqName);
|
|
@@ -1463,7 +1463,8 @@ async function evaluateCrudMap(crud: CrudMap, env: Environment): Promise<void> {
|
|
|
1463
1463
|
}
|
|
1464
1464
|
return;
|
|
1465
1465
|
}
|
|
1466
|
-
|
|
1466
|
+
const isBetRel = isBetweenRelationship(inst.name, inst.moduleName);
|
|
1467
|
+
if (isEntityInstance(inst) || isBetRel) {
|
|
1467
1468
|
if (qattrs === undefined && !isQueryAll) {
|
|
1468
1469
|
const parentPath: string | undefined = env.getParentPath();
|
|
1469
1470
|
if (parentPath) {
|
|
@@ -1479,10 +1480,22 @@ async function evaluateCrudMap(crud: CrudMap, env: Environment): Promise<void> {
|
|
|
1479
1480
|
r = await res.upsertInstance(inst);
|
|
1480
1481
|
await runPostUpdateEvents(inst, undefined, env);
|
|
1481
1482
|
} else {
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1483
|
+
if (isBetRel && env.isInDeleteMode()) {
|
|
1484
|
+
const rel: Relationship = getRelationship(inst.name, inst.moduleName);
|
|
1485
|
+
await res.handleInstancesLink(
|
|
1486
|
+
inst.lookup(rel.node1.alias),
|
|
1487
|
+
inst.lookup(rel.node2.alias),
|
|
1488
|
+
rel,
|
|
1489
|
+
false,
|
|
1490
|
+
true
|
|
1491
|
+
);
|
|
1492
|
+
r = inst;
|
|
1493
|
+
} else {
|
|
1494
|
+
await runPreCreateEvents(inst, env);
|
|
1495
|
+
if (isTimer(inst)) triggerTimer(inst);
|
|
1496
|
+
r = await res.createInstance(inst);
|
|
1497
|
+
await runPostCreateEvents(inst, env);
|
|
1498
|
+
}
|
|
1486
1499
|
}
|
|
1487
1500
|
if (r && entryName == AgentEntityName && inst.moduleName == CoreAIModuleName) {
|
|
1488
1501
|
defineAgentEvent(env.getActiveModuleName(), r.lookup('name'), r.lookup('instruction'));
|
|
@@ -1490,11 +1503,12 @@ async function evaluateCrudMap(crud: CrudMap, env: Environment): Promise<void> {
|
|
|
1490
1503
|
env.setLastResult(r);
|
|
1491
1504
|
const betRelInfo: BetweenRelInfo | undefined = env.getBetweenRelInfo();
|
|
1492
1505
|
if (betRelInfo) {
|
|
1493
|
-
await res.
|
|
1506
|
+
await res.handleInstancesLink(
|
|
1494
1507
|
betRelInfo.connectedInstance,
|
|
1495
1508
|
env.getLastResult(),
|
|
1496
1509
|
betRelInfo.relationship,
|
|
1497
|
-
env.isInUpsertMode()
|
|
1510
|
+
env.isInUpsertMode(),
|
|
1511
|
+
env.isInDeleteMode()
|
|
1498
1512
|
);
|
|
1499
1513
|
}
|
|
1500
1514
|
if (crud.relationships !== undefined) {
|
|
@@ -1514,7 +1528,13 @@ async function evaluateCrudMap(crud: CrudMap, env: Environment): Promise<void> {
|
|
|
1514
1528
|
await evaluatePattern(rel.pattern, newEnv);
|
|
1515
1529
|
const relResult: any = newEnv.getLastResult();
|
|
1516
1530
|
const res: Resolver = await getResolverForPath(rel.name, moduleName, env);
|
|
1517
|
-
await res.
|
|
1531
|
+
await res.handleInstancesLink(
|
|
1532
|
+
lastInst,
|
|
1533
|
+
relResult,
|
|
1534
|
+
relEntry,
|
|
1535
|
+
env.isInUpsertMode(),
|
|
1536
|
+
env.isInDeleteMode()
|
|
1537
|
+
);
|
|
1518
1538
|
lastInst.attachRelatedInstances(rel.name, newEnv.getLastResult());
|
|
1519
1539
|
}
|
|
1520
1540
|
}
|
|
@@ -2182,7 +2202,7 @@ export async function maybeDeleteQueriedInstances(
|
|
|
2182
2202
|
const inst: Instance[] | Instance = queryEnv.getLastResult();
|
|
2183
2203
|
let resolver: Resolver = Resolver.Default;
|
|
2184
2204
|
if (inst instanceof Array) {
|
|
2185
|
-
if (inst.length > 0) {
|
|
2205
|
+
if (inst.length > 0 && isEntityInstance(inst[0])) {
|
|
2186
2206
|
resolver = await getResolverForPath(inst[0].name, inst[0].moduleName, queryEnv);
|
|
2187
2207
|
const finalResult: Array<any> = new Array<any>();
|
|
2188
2208
|
for (let i = 0; i < inst.length; ++i) {
|
|
@@ -2195,7 +2215,7 @@ export async function maybeDeleteQueriedInstances(
|
|
|
2195
2215
|
} else {
|
|
2196
2216
|
queryEnv.setLastResult(inst);
|
|
2197
2217
|
}
|
|
2198
|
-
} else {
|
|
2218
|
+
} else if (isEntityInstance(inst)) {
|
|
2199
2219
|
resolver = await getResolverForPath(inst.name, inst.moduleName, queryEnv);
|
|
2200
2220
|
await runPreDeleteEvents(inst, env);
|
|
2201
2221
|
const r: Instance | null = await resolver.deleteInstance(inst, purge);
|