@objectstack/runtime 3.2.7 → 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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @objectstack/runtime@3.2.7 build /home/runner/work/spec/spec/packages/runtime
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
  CLI Building entry: src/index.ts
@@ -10,13 +10,13 @@
10
10
  CLI Cleaning output folder
11
11
  ESM Build start
12
12
  CJS Build start
13
- CJS dist/index.cjs 88.26 KB
14
- CJS dist/index.cjs.map 184.29 KB
15
- CJS ⚡️ Build success in 192ms
16
- ESM dist/index.js 85.68 KB
17
- ESM dist/index.js.map 184.22 KB
18
- ESM ⚡️ Build success in 226ms
13
+ ESM dist/index.js 87.23 KB
14
+ ESM dist/index.js.map 187.79 KB
15
+ ESM ⚡️ Build success in 88ms
16
+ CJS dist/index.cjs 89.81 KB
17
+ CJS dist/index.cjs.map 187.86 KB
18
+ CJS ⚡️ Build success in 90ms
19
19
  DTS Build start
20
- DTS ⚡️ Build success in 7678ms
20
+ DTS ⚡️ Build success in 2689ms
21
21
  DTS dist/index.d.ts 24.35 KB
22
22
  DTS dist/index.d.cts 24.35 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
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
+
3
12
  ## 3.2.7
4
13
 
5
14
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -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.ensureBroker();
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
- try {
1102
- const data = await broker.call("metadata.types", {}, { request: context.request });
1103
- return { handled: true, response: this.success(data) };
1104
- } catch {
1105
- return { handled: true, response: this.success({ types: ["object", "app", "plugin"] }) };
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
- try {
1117
- const data = await broker.call("metadata.getPublished", { type, name }, { request: context.request });
1118
- return { handled: true, response: this.success(data) };
1119
- } catch (e) {
1120
- return { handled: true, response: this.error(e.message, 404) };
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
- try {
1136
- const data = await broker.call("metadata.saveItem", { type, name, item: body }, { request: context.request });
1137
- return { handled: true, response: this.success(data) };
1138
- } catch (e) {
1139
- return { handled: true, response: this.error(e.message || "Save not supported", 501) };
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
- const data2 = await broker.call("metadata.getObject", { objectName: name }, { request: context.request });
1145
- return { handled: true, response: this.success(data2) };
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 data2 = await protocol.getMetaItem({ type: singularType, name });
1152
- return { handled: true, response: this.success(data2) };
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
- const method2 = `metadata.get${this.capitalize(singularType)}`;
1157
- const data = await broker.call(method2, { name }, { request: context.request });
1158
- return { handled: true, response: this.success(data) };
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
- try {
1177
- if (typeOrName === "objects") {
1178
- const data2 = await broker.call("metadata.objects", { packageId }, { request: context.request });
1179
- return { handled: true, response: this.success(data2) };
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
- const data = await broker.call(`metadata.${typeOrName}`, { packageId }, { request: context.request });
1182
- if (data !== null && data !== void 0) {
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
- try {
1188
- const data = await broker.call("metadata.getObject", { objectName: typeOrName }, { request: context.request });
1189
- return { handled: true, response: this.success(data) };
1190
- } catch (e) {
1191
- return { handled: true, response: this.error(e.message, 404) };
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
- try {
1201
- const data = await broker.call("metadata.types", {}, { request: context.request });
1202
- return { handled: true, response: this.success(data) };
1203
- } catch {
1204
- return { handled: true, response: this.success({ types: ["object", "app", "plugin"] }) };
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
  }