@objectstack/runtime 3.2.6 → 3.2.8
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/.turbo/turbo-build.log +8 -8
- package/CHANGELOG.md +18 -0
- package/dist/index.cjs +79 -42
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +78 -41
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/src/http-dispatcher.test.ts +100 -0
- package/src/http-dispatcher.ts +88 -42
- package/src/seed-loader.ts +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @objectstack/runtime@3.2.
|
|
2
|
+
> @objectstack/runtime@3.2.8 build /home/runner/work/spec/spec/packages/runtime
|
|
3
3
|
> tsup --config ../../tsup.config.ts
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -10,13 +10,13 @@
|
|
|
10
10
|
[34mCLI[39m Cleaning output folder
|
|
11
11
|
[34mESM[39m Build start
|
|
12
12
|
[34mCJS[39m Build start
|
|
13
|
-
[32mESM[39m [1mdist/index.js [22m[
|
|
14
|
-
[32mESM[39m [1mdist/index.js.map [22m[
|
|
15
|
-
[32mESM[39m ⚡️ Build success in
|
|
16
|
-
[32mCJS[39m [1mdist/index.cjs [22m[
|
|
17
|
-
[32mCJS[39m [1mdist/index.cjs.map [22m[
|
|
18
|
-
[32mCJS[39m ⚡️ Build success in
|
|
13
|
+
[32mESM[39m [1mdist/index.js [22m[32m87.23 KB[39m
|
|
14
|
+
[32mESM[39m [1mdist/index.js.map [22m[32m187.79 KB[39m
|
|
15
|
+
[32mESM[39m ⚡️ Build success in 88ms
|
|
16
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m89.81 KB[39m
|
|
17
|
+
[32mCJS[39m [1mdist/index.cjs.map [22m[32m187.86 KB[39m
|
|
18
|
+
[32mCJS[39m ⚡️ Build success in 90ms
|
|
19
19
|
[34mDTS[39m Build start
|
|
20
|
-
[32mDTS[39m ⚡️ Build success in
|
|
20
|
+
[32mDTS[39m ⚡️ Build success in 2689ms
|
|
21
21
|
[32mDTS[39m [1mdist/index.d.ts [22m[32m24.35 KB[39m
|
|
22
22
|
[32mDTS[39m [1mdist/index.d.cts [22m[32m24.35 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @objectstack/runtime
|
|
2
2
|
|
|
3
|
+
## 3.2.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @objectstack/spec@3.2.8
|
|
8
|
+
- @objectstack/core@3.2.8
|
|
9
|
+
- @objectstack/types@3.2.8
|
|
10
|
+
- @objectstack/rest@3.2.8
|
|
11
|
+
|
|
12
|
+
## 3.2.7
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- @objectstack/spec@3.2.7
|
|
17
|
+
- @objectstack/core@3.2.7
|
|
18
|
+
- @objectstack/types@3.2.7
|
|
19
|
+
- @objectstack/rest@3.2.7
|
|
20
|
+
|
|
3
21
|
## 3.2.6
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -123,6 +123,7 @@ var DriverPlugin = class {
|
|
|
123
123
|
};
|
|
124
124
|
|
|
125
125
|
// src/seed-loader.ts
|
|
126
|
+
var import_data = require("@objectstack/spec/data");
|
|
126
127
|
var DEFAULT_EXTERNAL_ID_FIELD = "name";
|
|
127
128
|
var SeedLoaderService = class {
|
|
128
129
|
constructor(engine, metadata, logger) {
|
|
@@ -207,8 +208,7 @@ var SeedLoaderService = class {
|
|
|
207
208
|
return { nodes, insertOrder, circularDependencies };
|
|
208
209
|
}
|
|
209
210
|
async validate(datasets, config) {
|
|
210
|
-
const
|
|
211
|
-
const parsedConfig = SeedLoaderConfigSchema.parse({ ...config, dryRun: true });
|
|
211
|
+
const parsedConfig = import_data.SeedLoaderConfigSchema.parse({ ...config, dryRun: true });
|
|
212
212
|
return this.load({ datasets, config: parsedConfig });
|
|
213
213
|
}
|
|
214
214
|
// ==========================================================================
|
|
@@ -1090,7 +1090,7 @@ var HttpDispatcher = class {
|
|
|
1090
1090
|
* Fallback for backward compat: /metadata (all objects), /metadata/:objectName (get object)
|
|
1091
1091
|
*/
|
|
1092
1092
|
async handleMetadata(path, context, method, body, query) {
|
|
1093
|
-
const broker = this.
|
|
1093
|
+
const broker = this.kernel.broker ?? null;
|
|
1094
1094
|
const parts = path.replace(/^\/+/, "").split("/").filter(Boolean);
|
|
1095
1095
|
if (parts[0] === "types") {
|
|
1096
1096
|
const protocol = await this.resolveService("protocol");
|
|
@@ -1098,12 +1098,14 @@ var HttpDispatcher = class {
|
|
|
1098
1098
|
const result = await protocol.getMetaTypes({});
|
|
1099
1099
|
return { handled: true, response: this.success(result) };
|
|
1100
1100
|
}
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1101
|
+
if (broker) {
|
|
1102
|
+
try {
|
|
1103
|
+
const data = await broker.call("metadata.types", {}, { request: context.request });
|
|
1104
|
+
return { handled: true, response: this.success(data) };
|
|
1105
|
+
} catch {
|
|
1106
|
+
}
|
|
1106
1107
|
}
|
|
1108
|
+
return { handled: true, response: this.success({ types: ["object", "app", "plugin"] }) };
|
|
1107
1109
|
}
|
|
1108
1110
|
if (parts.length === 3 && parts[2] === "published" && (!method || method === "GET")) {
|
|
1109
1111
|
const [type, name] = parts;
|
|
@@ -1113,12 +1115,15 @@ var HttpDispatcher = class {
|
|
|
1113
1115
|
if (data === void 0) return { handled: true, response: this.error("Not found", 404) };
|
|
1114
1116
|
return { handled: true, response: this.success(data) };
|
|
1115
1117
|
}
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1118
|
+
if (broker) {
|
|
1119
|
+
try {
|
|
1120
|
+
const data = await broker.call("metadata.getPublished", { type, name }, { request: context.request });
|
|
1121
|
+
return { handled: true, response: this.success(data) };
|
|
1122
|
+
} catch (e) {
|
|
1123
|
+
return { handled: true, response: this.error(e.message, 404) };
|
|
1124
|
+
}
|
|
1121
1125
|
}
|
|
1126
|
+
return { handled: true, response: this.error("Not found", 404) };
|
|
1122
1127
|
}
|
|
1123
1128
|
if (parts.length === 2) {
|
|
1124
1129
|
const [type, name] = parts;
|
|
@@ -1132,30 +1137,44 @@ var HttpDispatcher = class {
|
|
|
1132
1137
|
return { handled: true, response: this.error(e.message, 400) };
|
|
1133
1138
|
}
|
|
1134
1139
|
}
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
+
if (broker) {
|
|
1141
|
+
try {
|
|
1142
|
+
const data = await broker.call("metadata.saveItem", { type, name, item: body }, { request: context.request });
|
|
1143
|
+
return { handled: true, response: this.success(data) };
|
|
1144
|
+
} catch (e) {
|
|
1145
|
+
return { handled: true, response: this.error(e.message || "Save not supported", 501) };
|
|
1146
|
+
}
|
|
1140
1147
|
}
|
|
1148
|
+
return { handled: true, response: this.error("Save not supported", 501) };
|
|
1141
1149
|
}
|
|
1142
1150
|
try {
|
|
1143
1151
|
if (type === "objects" || type === "object") {
|
|
1144
|
-
|
|
1145
|
-
|
|
1152
|
+
if (broker) {
|
|
1153
|
+
const data = await broker.call("metadata.getObject", { objectName: name }, { request: context.request });
|
|
1154
|
+
return { handled: true, response: this.success(data) };
|
|
1155
|
+
}
|
|
1156
|
+
const qlService = await this.getObjectQLService();
|
|
1157
|
+
if (qlService?.registry) {
|
|
1158
|
+
const data = qlService.registry.getObject(name);
|
|
1159
|
+
if (data) return { handled: true, response: this.success(data) };
|
|
1160
|
+
}
|
|
1161
|
+
return { handled: true, response: this.error("Not found", 404) };
|
|
1146
1162
|
}
|
|
1147
1163
|
const singularType = type.endsWith("s") ? type.slice(0, -1) : type;
|
|
1148
1164
|
const protocol = await this.resolveService("protocol");
|
|
1149
1165
|
if (protocol && typeof protocol.getMetaItem === "function") {
|
|
1150
1166
|
try {
|
|
1151
|
-
const
|
|
1152
|
-
return { handled: true, response: this.success(
|
|
1167
|
+
const data = await protocol.getMetaItem({ type: singularType, name });
|
|
1168
|
+
return { handled: true, response: this.success(data) };
|
|
1153
1169
|
} catch (e) {
|
|
1154
1170
|
}
|
|
1155
1171
|
}
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1172
|
+
if (broker) {
|
|
1173
|
+
const method2 = `metadata.get${this.capitalize(singularType)}`;
|
|
1174
|
+
const data = await broker.call(method2, { name }, { request: context.request });
|
|
1175
|
+
return { handled: true, response: this.success(data) };
|
|
1176
|
+
}
|
|
1177
|
+
return { handled: true, response: this.error("Not found", 404) };
|
|
1159
1178
|
} catch (e) {
|
|
1160
1179
|
return { handled: true, response: this.error(e.message, 404) };
|
|
1161
1180
|
}
|
|
@@ -1173,23 +1192,39 @@ var HttpDispatcher = class {
|
|
|
1173
1192
|
} catch {
|
|
1174
1193
|
}
|
|
1175
1194
|
}
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1195
|
+
if (broker) {
|
|
1196
|
+
try {
|
|
1197
|
+
if (typeOrName === "objects") {
|
|
1198
|
+
const data2 = await broker.call("metadata.objects", { packageId }, { request: context.request });
|
|
1199
|
+
return { handled: true, response: this.success(data2) };
|
|
1200
|
+
}
|
|
1201
|
+
const data = await broker.call(`metadata.${typeOrName}`, { packageId }, { request: context.request });
|
|
1202
|
+
if (data !== null && data !== void 0) {
|
|
1203
|
+
return { handled: true, response: this.success(data) };
|
|
1204
|
+
}
|
|
1205
|
+
} catch {
|
|
1180
1206
|
}
|
|
1181
|
-
|
|
1182
|
-
|
|
1207
|
+
try {
|
|
1208
|
+
const data = await broker.call("metadata.getObject", { objectName: typeOrName }, { request: context.request });
|
|
1183
1209
|
return { handled: true, response: this.success(data) };
|
|
1210
|
+
} catch (e) {
|
|
1211
|
+
return { handled: true, response: this.error(e.message, 404) };
|
|
1184
1212
|
}
|
|
1185
|
-
} catch {
|
|
1186
1213
|
}
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1214
|
+
const qlService = await this.getObjectQLService();
|
|
1215
|
+
if (qlService?.registry) {
|
|
1216
|
+
if (typeOrName === "objects") {
|
|
1217
|
+
const objs = qlService.registry.getAllObjects(packageId);
|
|
1218
|
+
return { handled: true, response: this.success({ type: "object", items: objs }) };
|
|
1219
|
+
}
|
|
1220
|
+
const items = qlService.registry.listItems?.(typeOrName, packageId);
|
|
1221
|
+
if (items && items.length > 0) {
|
|
1222
|
+
return { handled: true, response: this.success({ type: typeOrName, items }) };
|
|
1223
|
+
}
|
|
1224
|
+
const obj = qlService.registry.getObject(typeOrName);
|
|
1225
|
+
if (obj) return { handled: true, response: this.success(obj) };
|
|
1192
1226
|
}
|
|
1227
|
+
return { handled: true, response: this.error("Not found", 404) };
|
|
1193
1228
|
}
|
|
1194
1229
|
if (parts.length === 0) {
|
|
1195
1230
|
const protocol = await this.resolveService("protocol");
|
|
@@ -1197,12 +1232,14 @@ var HttpDispatcher = class {
|
|
|
1197
1232
|
const result = await protocol.getMetaTypes({});
|
|
1198
1233
|
return { handled: true, response: this.success(result) };
|
|
1199
1234
|
}
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1235
|
+
if (broker) {
|
|
1236
|
+
try {
|
|
1237
|
+
const data = await broker.call("metadata.types", {}, { request: context.request });
|
|
1238
|
+
return { handled: true, response: this.success(data) };
|
|
1239
|
+
} catch {
|
|
1240
|
+
}
|
|
1205
1241
|
}
|
|
1242
|
+
return { handled: true, response: this.success({ types: ["object", "app", "plugin"] }) };
|
|
1206
1243
|
}
|
|
1207
1244
|
return { handled: false };
|
|
1208
1245
|
}
|