@objectstack/runtime 3.0.9 → 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/.turbo/turbo-build.log +8 -8
- package/CHANGELOG.md +20 -0
- package/dist/index.cjs +24 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +24 -20
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/http-dispatcher.test.ts +265 -0
- package/src/http-dispatcher.ts +27 -20
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @objectstack/runtime@3.0.
|
|
2
|
+
> @objectstack/runtime@3.0.11 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
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
16
|
-
[
|
|
17
|
-
[
|
|
18
|
-
[
|
|
13
|
+
[32mESM[39m [1mdist/index.js [22m[32m52.37 KB[39m
|
|
14
|
+
[32mESM[39m [1mdist/index.js.map [22m[32m117.43 KB[39m
|
|
15
|
+
[32mESM[39m ⚡️ Build success in 118ms
|
|
16
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m54.25 KB[39m
|
|
17
|
+
[32mCJS[39m [1mdist/index.cjs.map [22m[32m117.49 KB[39m
|
|
18
|
+
[32mCJS[39m ⚡️ Build success in 127ms
|
|
19
19
|
[34mDTS[39m Build start
|
|
20
|
-
[32mDTS[39m ⚡️ Build success in
|
|
20
|
+
[32mDTS[39m ⚡️ Build success in 6917ms
|
|
21
21
|
[32mDTS[39m [1mdist/index.d.ts [22m[32m20.49 KB[39m
|
|
22
22
|
[32mDTS[39m [1mdist/index.d.cts [22m[32m20.49 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @objectstack/runtime
|
|
2
2
|
|
|
3
|
+
## 3.0.11
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [92d9d99]
|
|
8
|
+
- @objectstack/spec@3.0.11
|
|
9
|
+
- @objectstack/core@3.0.11
|
|
10
|
+
- @objectstack/rest@3.0.11
|
|
11
|
+
- @objectstack/types@3.0.11
|
|
12
|
+
|
|
13
|
+
## 3.0.10
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [d1e5d31]
|
|
18
|
+
- @objectstack/spec@3.0.10
|
|
19
|
+
- @objectstack/core@3.0.10
|
|
20
|
+
- @objectstack/rest@3.0.10
|
|
21
|
+
- @objectstack/types@3.0.10
|
|
22
|
+
|
|
3
23
|
## 3.0.9
|
|
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) };
|
|
@@ -379,7 +379,7 @@ var HttpDispatcher = class {
|
|
|
379
379
|
if (parts.length === 2) {
|
|
380
380
|
const [type, name] = parts;
|
|
381
381
|
if (method === "PUT" && body) {
|
|
382
|
-
const protocol = this.kernel?.context?.getService ? this.kernel.context.getService("protocol") : null;
|
|
382
|
+
const protocol = this.kernel?.context?.getService ? await this.kernel.context.getService("protocol") : null;
|
|
383
383
|
if (protocol && typeof protocol.saveMetaItem === "function") {
|
|
384
384
|
try {
|
|
385
385
|
const result = await protocol.saveMetaItem({ type, name, item: body });
|
|
@@ -401,7 +401,7 @@ var HttpDispatcher = class {
|
|
|
401
401
|
return { handled: true, response: this.success(data2) };
|
|
402
402
|
}
|
|
403
403
|
const singularType = type.endsWith("s") ? type.slice(0, -1) : type;
|
|
404
|
-
const protocol = this.kernel?.context?.getService ? this.kernel.context.getService("protocol") : null;
|
|
404
|
+
const protocol = this.kernel?.context?.getService ? await this.kernel.context.getService("protocol") : null;
|
|
405
405
|
if (protocol && typeof protocol.getMetaItem === "function") {
|
|
406
406
|
try {
|
|
407
407
|
const data2 = await protocol.getMetaItem({ type: singularType, name });
|
|
@@ -419,7 +419,7 @@ var HttpDispatcher = class {
|
|
|
419
419
|
if (parts.length === 1) {
|
|
420
420
|
const typeOrName = parts[0];
|
|
421
421
|
const packageId = query?.package || void 0;
|
|
422
|
-
const protocol = this.kernel?.context?.getService ? this.kernel.context.getService("protocol") : null;
|
|
422
|
+
const protocol = this.kernel?.context?.getService ? await this.kernel.context.getService("protocol") : null;
|
|
423
423
|
if (protocol && typeof protocol.getMetaItems === "function") {
|
|
424
424
|
try {
|
|
425
425
|
const data = await protocol.getMetaItems({ type: typeOrName, packageId });
|
|
@@ -448,7 +448,7 @@ var HttpDispatcher = class {
|
|
|
448
448
|
}
|
|
449
449
|
}
|
|
450
450
|
if (parts.length === 0) {
|
|
451
|
-
const protocol = this.kernel?.context?.getService ? this.kernel.context.getService("protocol") : null;
|
|
451
|
+
const protocol = this.kernel?.context?.getService ? await this.kernel.context.getService("protocol") : null;
|
|
452
452
|
if (protocol && typeof protocol.getMetaTypes === "function") {
|
|
453
453
|
const result = await protocol.getMetaTypes({});
|
|
454
454
|
return { handled: true, response: this.success(result) };
|
|
@@ -486,7 +486,11 @@ var HttpDispatcher = class {
|
|
|
486
486
|
}
|
|
487
487
|
if (parts.length === 2 && m === "GET") {
|
|
488
488
|
const id = parts[1];
|
|
489
|
-
const
|
|
489
|
+
const { select, expand } = query || {};
|
|
490
|
+
const allowedParams = {};
|
|
491
|
+
if (select != null) allowedParams.select = select;
|
|
492
|
+
if (expand != null) allowedParams.expand = expand;
|
|
493
|
+
const result = await broker.call("data.get", { object: objectName, id, ...allowedParams }, { request: context.request });
|
|
490
494
|
return { handled: true, response: this.success(result) };
|
|
491
495
|
}
|
|
492
496
|
if (parts.length === 2 && m === "PATCH") {
|
|
@@ -501,7 +505,7 @@ var HttpDispatcher = class {
|
|
|
501
505
|
}
|
|
502
506
|
} else {
|
|
503
507
|
if (m === "GET") {
|
|
504
|
-
const result = await broker.call("data.query", { object: objectName,
|
|
508
|
+
const result = await broker.call("data.query", { object: objectName, query }, { request: context.request });
|
|
505
509
|
return { handled: true, response: this.success(result) };
|
|
506
510
|
}
|
|
507
511
|
if (m === "POST") {
|
|
@@ -518,7 +522,7 @@ var HttpDispatcher = class {
|
|
|
518
522
|
* path: sub-path after /analytics/
|
|
519
523
|
*/
|
|
520
524
|
async handleAnalytics(path, method, body, context) {
|
|
521
|
-
const analyticsService = this.getService(import_system.CoreServiceName.enum.analytics);
|
|
525
|
+
const analyticsService = await this.getService(import_system.CoreServiceName.enum.analytics);
|
|
522
526
|
if (!analyticsService) return { handled: false };
|
|
523
527
|
const m = method.toUpperCase();
|
|
524
528
|
const subPath = path.replace(/^\/+/, "");
|
|
@@ -553,7 +557,7 @@ var HttpDispatcher = class {
|
|
|
553
557
|
async handlePackages(path, method, body, query, context) {
|
|
554
558
|
const m = method.toUpperCase();
|
|
555
559
|
const parts = path.replace(/^\/+/, "").split("/").filter(Boolean);
|
|
556
|
-
const qlService = this.getObjectQLService();
|
|
560
|
+
const qlService = await this.getObjectQLService();
|
|
557
561
|
const registry = qlService?.registry;
|
|
558
562
|
if (!registry) {
|
|
559
563
|
if (this.kernel.broker) {
|
|
@@ -653,7 +657,7 @@ var HttpDispatcher = class {
|
|
|
653
657
|
* path: sub-path after /storage/
|
|
654
658
|
*/
|
|
655
659
|
async handleStorage(path, method, file, context) {
|
|
656
|
-
const storageService = this.getService(import_system.CoreServiceName.enum["file-storage"]) || this.kernel.services?.["file-storage"];
|
|
660
|
+
const storageService = await this.getService(import_system.CoreServiceName.enum["file-storage"]) || this.kernel.services?.["file-storage"];
|
|
657
661
|
if (!storageService) {
|
|
658
662
|
return { handled: true, response: this.error("File storage not configured", 501) };
|
|
659
663
|
}
|
|
@@ -698,7 +702,7 @@ var HttpDispatcher = class {
|
|
|
698
702
|
if (parts[0] === "view" && parts[1]) {
|
|
699
703
|
const objectName = parts[1];
|
|
700
704
|
const type = parts[2] || query?.type || "list";
|
|
701
|
-
const protocol = this.kernel?.context?.getService ? this.kernel.context.getService("protocol") : null;
|
|
705
|
+
const protocol = this.kernel?.context?.getService ? await this.kernel.context.getService("protocol") : null;
|
|
702
706
|
if (protocol && typeof protocol.getUiView === "function") {
|
|
703
707
|
try {
|
|
704
708
|
const result = await protocol.getUiView({ object: objectName, type });
|
|
@@ -728,7 +732,7 @@ var HttpDispatcher = class {
|
|
|
728
732
|
* GET /:name/runs/:runId → getRun
|
|
729
733
|
*/
|
|
730
734
|
async handleAutomation(path, method, body, context, query) {
|
|
731
|
-
const automationService = this.getService(import_system.CoreServiceName.enum.automation);
|
|
735
|
+
const automationService = await this.getService(import_system.CoreServiceName.enum.automation);
|
|
732
736
|
if (!automationService) return { handled: false };
|
|
733
737
|
const m = method.toUpperCase();
|
|
734
738
|
const parts = path.replace(/^\/+/, "").split("/").filter(Boolean);
|
|
@@ -811,9 +815,9 @@ var HttpDispatcher = class {
|
|
|
811
815
|
}
|
|
812
816
|
return this.kernel.services || {};
|
|
813
817
|
}
|
|
814
|
-
getService(name) {
|
|
818
|
+
async getService(name) {
|
|
815
819
|
if (typeof this.kernel.getService === "function") {
|
|
816
|
-
return this.kernel.getService(name);
|
|
820
|
+
return await this.kernel.getService(name);
|
|
817
821
|
}
|
|
818
822
|
const services = this.getServicesMap();
|
|
819
823
|
return services[name];
|
|
@@ -822,17 +826,17 @@ var HttpDispatcher = class {
|
|
|
822
826
|
* Get the ObjectQL service which provides access to SchemaRegistry.
|
|
823
827
|
* Tries multiple access patterns since kernel structure varies.
|
|
824
828
|
*/
|
|
825
|
-
getObjectQLService() {
|
|
829
|
+
async getObjectQLService() {
|
|
826
830
|
if (typeof this.kernel.getService === "function") {
|
|
827
831
|
try {
|
|
828
|
-
const svc = this.kernel.getService("objectql");
|
|
832
|
+
const svc = await this.kernel.getService("objectql");
|
|
829
833
|
if (svc?.registry) return svc;
|
|
830
834
|
} catch {
|
|
831
835
|
}
|
|
832
836
|
}
|
|
833
837
|
if (this.kernel?.context?.getService) {
|
|
834
838
|
try {
|
|
835
|
-
const svc = this.kernel.context.getService("objectql");
|
|
839
|
+
const svc = await this.kernel.context.getService("objectql");
|
|
836
840
|
if (svc?.registry) return svc;
|
|
837
841
|
} catch {
|
|
838
842
|
}
|
|
@@ -922,8 +926,8 @@ var HttpDispatcher = class {
|
|
|
922
926
|
if (endpoint.objectParams) {
|
|
923
927
|
const { object, operation } = endpoint.objectParams;
|
|
924
928
|
if (operation === "find") {
|
|
925
|
-
const result = await broker.call("data.query", { object,
|
|
926
|
-
return { handled: true, response: this.success(result.
|
|
929
|
+
const result = await broker.call("data.query", { object, query }, { request: context.request });
|
|
930
|
+
return { handled: true, response: this.success(result.records, { total: result.total }) };
|
|
927
931
|
}
|
|
928
932
|
if (operation === "get" && query.id) {
|
|
929
933
|
const result = await broker.call("data.get", { object, id: query.id }, { request: context.request });
|