@objectstack/runtime 3.0.10 → 3.1.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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @objectstack/runtime@3.0.10 build /home/runner/work/spec/spec/packages/runtime
2
+ > @objectstack/runtime@3.1.0 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
- ESM dist/index.js 52.28 KB
14
- ESM dist/index.js.map 117.25 KB
15
- ESM ⚡️ Build success in 178ms
16
- CJS dist/index.cjs 54.16 KB
17
- CJS dist/index.cjs.map 117.31 KB
13
+ ESM dist/index.js 55.51 KB
14
+ ESM dist/index.js.map 123.66 KB
15
+ ESM ⚡️ Build success in 166ms
16
+ CJS dist/index.cjs 57.43 KB
17
+ CJS dist/index.cjs.map 123.73 KB
18
18
  CJS ⚡️ Build success in 166ms
19
19
  DTS Build start
20
- DTS ⚡️ Build success in 6341ms
21
- DTS dist/index.d.ts 20.49 KB
22
- DTS dist/index.d.cts 20.49 KB
20
+ DTS ⚡️ Build success in 6928ms
21
+ DTS dist/index.d.ts 20.64 KB
22
+ DTS dist/index.d.cts 20.64 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @objectstack/runtime
2
2
 
3
+ ## 3.1.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [0088830]
8
+ - @objectstack/spec@3.1.0
9
+ - @objectstack/core@3.1.0
10
+ - @objectstack/rest@3.1.0
11
+ - @objectstack/types@3.1.0
12
+
13
+ ## 3.0.11
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies [92d9d99]
18
+ - @objectstack/spec@3.0.11
19
+ - @objectstack/core@3.0.11
20
+ - @objectstack/rest@3.0.11
21
+ - @objectstack/types@3.0.11
22
+
3
23
  ## 3.0.10
4
24
 
5
25
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -342,7 +342,7 @@ var HttpDispatcher = class {
342
342
  * path: sub-path after /auth/
343
343
  */
344
344
  async handleAuth(path, method, body, context) {
345
- const authService = this.getService(import_system.CoreServiceName.enum.auth);
345
+ const authService = await this.getService(import_system.CoreServiceName.enum.auth);
346
346
  if (authService && typeof authService.handler === "function") {
347
347
  const response = await authService.handler(context.request, context.response);
348
348
  return { handled: true, result: response };
@@ -364,7 +364,7 @@ var HttpDispatcher = class {
364
364
  const broker = this.ensureBroker();
365
365
  const parts = path.replace(/^\/+/, "").split("/").filter(Boolean);
366
366
  if (parts[0] === "types") {
367
- const protocol = this.kernel?.context?.getService ? this.kernel.context.getService("protocol") : null;
367
+ const protocol = this.kernel?.context?.getService ? await this.kernel.context.getService("protocol") : null;
368
368
  if (protocol && typeof protocol.getMetaTypes === "function") {
369
369
  const result = await protocol.getMetaTypes({});
370
370
  return { handled: true, response: this.success(result) };
@@ -376,10 +376,25 @@ var HttpDispatcher = class {
376
376
  return { handled: true, response: this.success({ types: ["object", "app", "plugin"] }) };
377
377
  }
378
378
  }
379
+ if (parts.length === 3 && parts[2] === "published" && (!method || method === "GET")) {
380
+ const [type, name] = parts;
381
+ const metadataService = await this.getService(import_system.CoreServiceName.enum.metadata);
382
+ if (metadataService && typeof metadataService.getPublished === "function") {
383
+ const data = await metadataService.getPublished(type, name);
384
+ if (data === void 0) return { handled: true, response: this.error("Not found", 404) };
385
+ return { handled: true, response: this.success(data) };
386
+ }
387
+ try {
388
+ const data = await broker.call("metadata.getPublished", { type, name }, { request: context.request });
389
+ return { handled: true, response: this.success(data) };
390
+ } catch (e) {
391
+ return { handled: true, response: this.error(e.message, 404) };
392
+ }
393
+ }
379
394
  if (parts.length === 2) {
380
395
  const [type, name] = parts;
381
396
  if (method === "PUT" && body) {
382
- const protocol = this.kernel?.context?.getService ? this.kernel.context.getService("protocol") : null;
397
+ const protocol = this.kernel?.context?.getService ? await this.kernel.context.getService("protocol") : null;
383
398
  if (protocol && typeof protocol.saveMetaItem === "function") {
384
399
  try {
385
400
  const result = await protocol.saveMetaItem({ type, name, item: body });
@@ -401,7 +416,7 @@ var HttpDispatcher = class {
401
416
  return { handled: true, response: this.success(data2) };
402
417
  }
403
418
  const singularType = type.endsWith("s") ? type.slice(0, -1) : type;
404
- const protocol = this.kernel?.context?.getService ? this.kernel.context.getService("protocol") : null;
419
+ const protocol = this.kernel?.context?.getService ? await this.kernel.context.getService("protocol") : null;
405
420
  if (protocol && typeof protocol.getMetaItem === "function") {
406
421
  try {
407
422
  const data2 = await protocol.getMetaItem({ type: singularType, name });
@@ -419,7 +434,7 @@ var HttpDispatcher = class {
419
434
  if (parts.length === 1) {
420
435
  const typeOrName = parts[0];
421
436
  const packageId = query?.package || void 0;
422
- const protocol = this.kernel?.context?.getService ? this.kernel.context.getService("protocol") : null;
437
+ const protocol = this.kernel?.context?.getService ? await this.kernel.context.getService("protocol") : null;
423
438
  if (protocol && typeof protocol.getMetaItems === "function") {
424
439
  try {
425
440
  const data = await protocol.getMetaItems({ type: typeOrName, packageId });
@@ -448,7 +463,7 @@ var HttpDispatcher = class {
448
463
  }
449
464
  }
450
465
  if (parts.length === 0) {
451
- const protocol = this.kernel?.context?.getService ? this.kernel.context.getService("protocol") : null;
466
+ const protocol = this.kernel?.context?.getService ? await this.kernel.context.getService("protocol") : null;
452
467
  if (protocol && typeof protocol.getMetaTypes === "function") {
453
468
  const result = await protocol.getMetaTypes({});
454
469
  return { handled: true, response: this.success(result) };
@@ -522,7 +537,7 @@ var HttpDispatcher = class {
522
537
  * path: sub-path after /analytics/
523
538
  */
524
539
  async handleAnalytics(path, method, body, context) {
525
- const analyticsService = this.getService(import_system.CoreServiceName.enum.analytics);
540
+ const analyticsService = await this.getService(import_system.CoreServiceName.enum.analytics);
526
541
  if (!analyticsService) return { handled: false };
527
542
  const m = method.toUpperCase();
528
543
  const subPath = path.replace(/^\/+/, "");
@@ -550,6 +565,8 @@ var HttpDispatcher = class {
550
565
  * - DELETE /packages/:id → uninstall a package
551
566
  * - PATCH /packages/:id/enable → enable a package
552
567
  * - PATCH /packages/:id/disable → disable a package
568
+ * - POST /packages/:id/publish → publish a package (metadata snapshot)
569
+ * - POST /packages/:id/revert → revert a package to last published state
553
570
  *
554
571
  * Uses ObjectQL SchemaRegistry directly (via the 'objectql' service)
555
572
  * with broker fallback for backward compatibility.
@@ -557,7 +574,7 @@ var HttpDispatcher = class {
557
574
  async handlePackages(path, method, body, query, context) {
558
575
  const m = method.toUpperCase();
559
576
  const parts = path.replace(/^\/+/, "").split("/").filter(Boolean);
560
- const qlService = this.getObjectQLService();
577
+ const qlService = await this.getObjectQLService();
561
578
  const registry = qlService?.registry;
562
579
  if (!registry) {
563
580
  if (this.kernel.broker) {
@@ -594,6 +611,32 @@ var HttpDispatcher = class {
594
611
  if (!pkg) return { handled: true, response: this.error(`Package '${id}' not found`, 404) };
595
612
  return { handled: true, response: this.success(pkg) };
596
613
  }
614
+ if (parts.length === 2 && parts[1] === "publish" && m === "POST") {
615
+ const id = decodeURIComponent(parts[0]);
616
+ const metadataService = await this.getService(import_system.CoreServiceName.enum.metadata);
617
+ if (metadataService && typeof metadataService.publishPackage === "function") {
618
+ const result = await metadataService.publishPackage(id, body || {});
619
+ return { handled: true, response: this.success(result) };
620
+ }
621
+ if (this.kernel.broker) {
622
+ const result = await this.kernel.broker.call("metadata.publishPackage", { packageId: id, ...body }, { request: context.request });
623
+ return { handled: true, response: this.success(result) };
624
+ }
625
+ return { handled: true, response: this.error("Metadata service not available", 503) };
626
+ }
627
+ if (parts.length === 2 && parts[1] === "revert" && m === "POST") {
628
+ const id = decodeURIComponent(parts[0]);
629
+ const metadataService = await this.getService(import_system.CoreServiceName.enum.metadata);
630
+ if (metadataService && typeof metadataService.revertPackage === "function") {
631
+ await metadataService.revertPackage(id);
632
+ return { handled: true, response: this.success({ success: true }) };
633
+ }
634
+ if (this.kernel.broker) {
635
+ await this.kernel.broker.call("metadata.revertPackage", { packageId: id }, { request: context.request });
636
+ return { handled: true, response: this.success({ success: true }) };
637
+ }
638
+ return { handled: true, response: this.error("Metadata service not available", 503) };
639
+ }
597
640
  if (parts.length === 1 && m === "GET") {
598
641
  const id = decodeURIComponent(parts[0]);
599
642
  const pkg = registry.getPackage(id);
@@ -657,7 +700,7 @@ var HttpDispatcher = class {
657
700
  * path: sub-path after /storage/
658
701
  */
659
702
  async handleStorage(path, method, file, context) {
660
- const storageService = this.getService(import_system.CoreServiceName.enum["file-storage"]) || this.kernel.services?.["file-storage"];
703
+ const storageService = await this.getService(import_system.CoreServiceName.enum["file-storage"]) || this.kernel.services?.["file-storage"];
661
704
  if (!storageService) {
662
705
  return { handled: true, response: this.error("File storage not configured", 501) };
663
706
  }
@@ -702,7 +745,7 @@ var HttpDispatcher = class {
702
745
  if (parts[0] === "view" && parts[1]) {
703
746
  const objectName = parts[1];
704
747
  const type = parts[2] || query?.type || "list";
705
- const protocol = this.kernel?.context?.getService ? this.kernel.context.getService("protocol") : null;
748
+ const protocol = this.kernel?.context?.getService ? await this.kernel.context.getService("protocol") : null;
706
749
  if (protocol && typeof protocol.getUiView === "function") {
707
750
  try {
708
751
  const result = await protocol.getUiView({ object: objectName, type });
@@ -732,7 +775,7 @@ var HttpDispatcher = class {
732
775
  * GET /:name/runs/:runId → getRun
733
776
  */
734
777
  async handleAutomation(path, method, body, context, query) {
735
- const automationService = this.getService(import_system.CoreServiceName.enum.automation);
778
+ const automationService = await this.getService(import_system.CoreServiceName.enum.automation);
736
779
  if (!automationService) return { handled: false };
737
780
  const m = method.toUpperCase();
738
781
  const parts = path.replace(/^\/+/, "").split("/").filter(Boolean);
@@ -815,9 +858,9 @@ var HttpDispatcher = class {
815
858
  }
816
859
  return this.kernel.services || {};
817
860
  }
818
- getService(name) {
861
+ async getService(name) {
819
862
  if (typeof this.kernel.getService === "function") {
820
- return this.kernel.getService(name);
863
+ return await this.kernel.getService(name);
821
864
  }
822
865
  const services = this.getServicesMap();
823
866
  return services[name];
@@ -826,17 +869,17 @@ var HttpDispatcher = class {
826
869
  * Get the ObjectQL service which provides access to SchemaRegistry.
827
870
  * Tries multiple access patterns since kernel structure varies.
828
871
  */
829
- getObjectQLService() {
872
+ async getObjectQLService() {
830
873
  if (typeof this.kernel.getService === "function") {
831
874
  try {
832
- const svc = this.kernel.getService("objectql");
875
+ const svc = await this.kernel.getService("objectql");
833
876
  if (svc?.registry) return svc;
834
877
  } catch {
835
878
  }
836
879
  }
837
880
  if (this.kernel?.context?.getService) {
838
881
  try {
839
- const svc = this.kernel.context.getService("objectql");
882
+ const svc = await this.kernel.context.getService("objectql");
840
883
  if (svc?.registry) return svc;
841
884
  } catch {
842
885
  }
@@ -1093,6 +1136,22 @@ function createDispatcherPlugin(config = {}) {
1093
1136
  errorResponse(err, res);
1094
1137
  }
1095
1138
  });
1139
+ server.post(`${prefix}/packages/:id/publish`, async (req, res) => {
1140
+ try {
1141
+ const result = await dispatcher.handlePackages(`/${req.params.id}/publish`, "POST", req.body, {}, { request: req });
1142
+ sendResult(result, res);
1143
+ } catch (err) {
1144
+ errorResponse(err, res);
1145
+ }
1146
+ });
1147
+ server.post(`${prefix}/packages/:id/revert`, async (req, res) => {
1148
+ try {
1149
+ const result = await dispatcher.handlePackages(`/${req.params.id}/revert`, "POST", req.body, {}, { request: req });
1150
+ sendResult(result, res);
1151
+ } catch (err) {
1152
+ errorResponse(err, res);
1153
+ }
1154
+ });
1096
1155
  server.post(`${prefix}/storage/upload`, async (req, res) => {
1097
1156
  try {
1098
1157
  const result = await dispatcher.handleStorage("upload", "POST", req.body, { request: req });