@objectstack/runtime 3.3.1 → 4.0.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/index.js CHANGED
@@ -295,8 +295,8 @@ var SeedLoaderService = class {
295
295
  async resolveFromDatabase(targetObject, targetField, value) {
296
296
  try {
297
297
  const records = await this.engine.find(targetObject, {
298
- filter: { [targetField]: value },
299
- select: ["id"],
298
+ where: { [targetField]: value },
299
+ fields: ["id"],
300
300
  limit: 1
301
301
  });
302
302
  if (records && records.length > 0) {
@@ -516,7 +516,7 @@ var SeedLoaderService = class {
516
516
  const map = /* @__PURE__ */ new Map();
517
517
  try {
518
518
  const records = await this.engine.find(objectName, {
519
- select: ["id", externalId]
519
+ fields: ["id", externalId]
520
520
  });
521
521
  for (const record of records || []) {
522
522
  const key = String(record[externalId] ?? "");
@@ -1239,7 +1239,29 @@ var HttpDispatcher = class {
1239
1239
  }
1240
1240
  } else {
1241
1241
  if (m === "GET") {
1242
- const result = await broker.call("data.query", { object: objectName, query }, { request: context.request });
1242
+ const normalized = { ...query };
1243
+ if (normalized.filter != null || normalized.filters != null) {
1244
+ normalized.where = normalized.where ?? normalized.filter ?? normalized.filters;
1245
+ delete normalized.filter;
1246
+ delete normalized.filters;
1247
+ }
1248
+ if (normalized.select != null && normalized.fields == null) {
1249
+ normalized.fields = normalized.select;
1250
+ delete normalized.select;
1251
+ }
1252
+ if (normalized.sort != null && normalized.orderBy == null) {
1253
+ normalized.orderBy = normalized.sort;
1254
+ delete normalized.sort;
1255
+ }
1256
+ if (normalized.top != null && normalized.limit == null) {
1257
+ normalized.limit = normalized.top;
1258
+ delete normalized.top;
1259
+ }
1260
+ if (normalized.skip != null && normalized.offset == null) {
1261
+ normalized.offset = normalized.skip;
1262
+ delete normalized.skip;
1263
+ }
1264
+ const result = await broker.call("data.query", { object: objectName, query: normalized }, { request: context.request });
1243
1265
  return { handled: true, response: this.success(result) };
1244
1266
  }
1245
1267
  if (m === "POST") {
@@ -1689,7 +1711,7 @@ var HttpDispatcher = class {
1689
1711
  */
1690
1712
  async dispatch(method, path, body, query, context) {
1691
1713
  const cleanPath = path.replace(/\/$/, "");
1692
- if (cleanPath === "" && method === "GET") {
1714
+ if ((cleanPath === "/discovery" || cleanPath === "") && method === "GET") {
1693
1715
  const info = await this.getDiscoveryInfo("");
1694
1716
  return {
1695
1717
  handled: true,