@objectstack/runtime 3.0.10 → 3.0.11

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
@@ -306,7 +306,7 @@ var HttpDispatcher = class {
306
306
  * path: sub-path after /auth/
307
307
  */
308
308
  async handleAuth(path, method, body, context) {
309
- const authService = this.getService(CoreServiceName.enum.auth);
309
+ const authService = await this.getService(CoreServiceName.enum.auth);
310
310
  if (authService && typeof authService.handler === "function") {
311
311
  const response = await authService.handler(context.request, context.response);
312
312
  return { handled: true, result: response };
@@ -328,7 +328,7 @@ var HttpDispatcher = class {
328
328
  const broker = this.ensureBroker();
329
329
  const parts = path.replace(/^\/+/, "").split("/").filter(Boolean);
330
330
  if (parts[0] === "types") {
331
- const protocol = this.kernel?.context?.getService ? this.kernel.context.getService("protocol") : null;
331
+ const protocol = this.kernel?.context?.getService ? await this.kernel.context.getService("protocol") : null;
332
332
  if (protocol && typeof protocol.getMetaTypes === "function") {
333
333
  const result = await protocol.getMetaTypes({});
334
334
  return { handled: true, response: this.success(result) };
@@ -343,7 +343,7 @@ var HttpDispatcher = class {
343
343
  if (parts.length === 2) {
344
344
  const [type, name] = parts;
345
345
  if (method === "PUT" && body) {
346
- const protocol = this.kernel?.context?.getService ? this.kernel.context.getService("protocol") : null;
346
+ const protocol = this.kernel?.context?.getService ? await this.kernel.context.getService("protocol") : null;
347
347
  if (protocol && typeof protocol.saveMetaItem === "function") {
348
348
  try {
349
349
  const result = await protocol.saveMetaItem({ type, name, item: body });
@@ -365,7 +365,7 @@ var HttpDispatcher = class {
365
365
  return { handled: true, response: this.success(data2) };
366
366
  }
367
367
  const singularType = type.endsWith("s") ? type.slice(0, -1) : type;
368
- const protocol = this.kernel?.context?.getService ? this.kernel.context.getService("protocol") : null;
368
+ const protocol = this.kernel?.context?.getService ? await this.kernel.context.getService("protocol") : null;
369
369
  if (protocol && typeof protocol.getMetaItem === "function") {
370
370
  try {
371
371
  const data2 = await protocol.getMetaItem({ type: singularType, name });
@@ -383,7 +383,7 @@ var HttpDispatcher = class {
383
383
  if (parts.length === 1) {
384
384
  const typeOrName = parts[0];
385
385
  const packageId = query?.package || void 0;
386
- const protocol = this.kernel?.context?.getService ? this.kernel.context.getService("protocol") : null;
386
+ const protocol = this.kernel?.context?.getService ? await this.kernel.context.getService("protocol") : null;
387
387
  if (protocol && typeof protocol.getMetaItems === "function") {
388
388
  try {
389
389
  const data = await protocol.getMetaItems({ type: typeOrName, packageId });
@@ -412,7 +412,7 @@ var HttpDispatcher = class {
412
412
  }
413
413
  }
414
414
  if (parts.length === 0) {
415
- const protocol = this.kernel?.context?.getService ? this.kernel.context.getService("protocol") : null;
415
+ const protocol = this.kernel?.context?.getService ? await this.kernel.context.getService("protocol") : null;
416
416
  if (protocol && typeof protocol.getMetaTypes === "function") {
417
417
  const result = await protocol.getMetaTypes({});
418
418
  return { handled: true, response: this.success(result) };
@@ -486,7 +486,7 @@ var HttpDispatcher = class {
486
486
  * path: sub-path after /analytics/
487
487
  */
488
488
  async handleAnalytics(path, method, body, context) {
489
- const analyticsService = this.getService(CoreServiceName.enum.analytics);
489
+ const analyticsService = await this.getService(CoreServiceName.enum.analytics);
490
490
  if (!analyticsService) return { handled: false };
491
491
  const m = method.toUpperCase();
492
492
  const subPath = path.replace(/^\/+/, "");
@@ -521,7 +521,7 @@ var HttpDispatcher = class {
521
521
  async handlePackages(path, method, body, query, context) {
522
522
  const m = method.toUpperCase();
523
523
  const parts = path.replace(/^\/+/, "").split("/").filter(Boolean);
524
- const qlService = this.getObjectQLService();
524
+ const qlService = await this.getObjectQLService();
525
525
  const registry = qlService?.registry;
526
526
  if (!registry) {
527
527
  if (this.kernel.broker) {
@@ -621,7 +621,7 @@ var HttpDispatcher = class {
621
621
  * path: sub-path after /storage/
622
622
  */
623
623
  async handleStorage(path, method, file, context) {
624
- const storageService = this.getService(CoreServiceName.enum["file-storage"]) || this.kernel.services?.["file-storage"];
624
+ const storageService = await this.getService(CoreServiceName.enum["file-storage"]) || this.kernel.services?.["file-storage"];
625
625
  if (!storageService) {
626
626
  return { handled: true, response: this.error("File storage not configured", 501) };
627
627
  }
@@ -666,7 +666,7 @@ var HttpDispatcher = class {
666
666
  if (parts[0] === "view" && parts[1]) {
667
667
  const objectName = parts[1];
668
668
  const type = parts[2] || query?.type || "list";
669
- const protocol = this.kernel?.context?.getService ? this.kernel.context.getService("protocol") : null;
669
+ const protocol = this.kernel?.context?.getService ? await this.kernel.context.getService("protocol") : null;
670
670
  if (protocol && typeof protocol.getUiView === "function") {
671
671
  try {
672
672
  const result = await protocol.getUiView({ object: objectName, type });
@@ -696,7 +696,7 @@ var HttpDispatcher = class {
696
696
  * GET /:name/runs/:runId → getRun
697
697
  */
698
698
  async handleAutomation(path, method, body, context, query) {
699
- const automationService = this.getService(CoreServiceName.enum.automation);
699
+ const automationService = await this.getService(CoreServiceName.enum.automation);
700
700
  if (!automationService) return { handled: false };
701
701
  const m = method.toUpperCase();
702
702
  const parts = path.replace(/^\/+/, "").split("/").filter(Boolean);
@@ -779,9 +779,9 @@ var HttpDispatcher = class {
779
779
  }
780
780
  return this.kernel.services || {};
781
781
  }
782
- getService(name) {
782
+ async getService(name) {
783
783
  if (typeof this.kernel.getService === "function") {
784
- return this.kernel.getService(name);
784
+ return await this.kernel.getService(name);
785
785
  }
786
786
  const services = this.getServicesMap();
787
787
  return services[name];
@@ -790,17 +790,17 @@ var HttpDispatcher = class {
790
790
  * Get the ObjectQL service which provides access to SchemaRegistry.
791
791
  * Tries multiple access patterns since kernel structure varies.
792
792
  */
793
- getObjectQLService() {
793
+ async getObjectQLService() {
794
794
  if (typeof this.kernel.getService === "function") {
795
795
  try {
796
- const svc = this.kernel.getService("objectql");
796
+ const svc = await this.kernel.getService("objectql");
797
797
  if (svc?.registry) return svc;
798
798
  } catch {
799
799
  }
800
800
  }
801
801
  if (this.kernel?.context?.getService) {
802
802
  try {
803
- const svc = this.kernel.context.getService("objectql");
803
+ const svc = await this.kernel.context.getService("objectql");
804
804
  if (svc?.registry) return svc;
805
805
  } catch {
806
806
  }