@pactor-app/runtime 1.20.0 → 1.22.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.cjs +28 -0
- package/dist/index.js +28 -0
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -611,6 +611,34 @@ function registerBuiltinActions(registry) {
|
|
|
611
611
|
};
|
|
612
612
|
}
|
|
613
613
|
});
|
|
614
|
+
register("service.call", async (action, ctx) => {
|
|
615
|
+
const name = action.params?.["service"];
|
|
616
|
+
if (typeof name !== "string" || name === "") {
|
|
617
|
+
return {
|
|
618
|
+
ok: false,
|
|
619
|
+
error: new Error("[@pactor-app/runtime] service.call \u7F3A\u5C11 params.service")
|
|
620
|
+
};
|
|
621
|
+
}
|
|
622
|
+
const handler = ctx.context.services.get(name);
|
|
623
|
+
if (!handler) {
|
|
624
|
+
return {
|
|
625
|
+
ok: false,
|
|
626
|
+
error: new Error(`[@pactor-app/runtime] service \u672A\u6CE8\u518C: ${name}`)
|
|
627
|
+
};
|
|
628
|
+
}
|
|
629
|
+
try {
|
|
630
|
+
const callParams = action.params?.["params"];
|
|
631
|
+
const data = await handler(
|
|
632
|
+
isRecord(callParams) ? callParams : {}
|
|
633
|
+
);
|
|
634
|
+
return { ok: true, data };
|
|
635
|
+
} catch (cause) {
|
|
636
|
+
return {
|
|
637
|
+
ok: false,
|
|
638
|
+
error: cause instanceof Error ? cause : new Error(String(cause))
|
|
639
|
+
};
|
|
640
|
+
}
|
|
641
|
+
});
|
|
614
642
|
register("sequence", async (action, ctx) => {
|
|
615
643
|
for (const child of asActions(action.params?.["actions"])) {
|
|
616
644
|
const result = await ctx.execute(child);
|
package/dist/index.js
CHANGED
|
@@ -566,6 +566,34 @@ function registerBuiltinActions(registry) {
|
|
|
566
566
|
};
|
|
567
567
|
}
|
|
568
568
|
});
|
|
569
|
+
register("service.call", async (action, ctx) => {
|
|
570
|
+
const name = action.params?.["service"];
|
|
571
|
+
if (typeof name !== "string" || name === "") {
|
|
572
|
+
return {
|
|
573
|
+
ok: false,
|
|
574
|
+
error: new Error("[@pactor-app/runtime] service.call \u7F3A\u5C11 params.service")
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
const handler = ctx.context.services.get(name);
|
|
578
|
+
if (!handler) {
|
|
579
|
+
return {
|
|
580
|
+
ok: false,
|
|
581
|
+
error: new Error(`[@pactor-app/runtime] service \u672A\u6CE8\u518C: ${name}`)
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
try {
|
|
585
|
+
const callParams = action.params?.["params"];
|
|
586
|
+
const data = await handler(
|
|
587
|
+
isRecord(callParams) ? callParams : {}
|
|
588
|
+
);
|
|
589
|
+
return { ok: true, data };
|
|
590
|
+
} catch (cause) {
|
|
591
|
+
return {
|
|
592
|
+
ok: false,
|
|
593
|
+
error: cause instanceof Error ? cause : new Error(String(cause))
|
|
594
|
+
};
|
|
595
|
+
}
|
|
596
|
+
});
|
|
569
597
|
register("sequence", async (action, ctx) => {
|
|
570
598
|
for (const child of asActions(action.params?.["actions"])) {
|
|
571
599
|
const result = await ctx.execute(child);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pactor-app/runtime",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.22.0",
|
|
4
4
|
"description": "Pactor runtime: RuntimeContext, StateStore, DataSource runtime, action engine, React renderer and page runtime",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pactor",
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
"access": "public"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@pactor-app/core": "1.
|
|
49
|
-
"@pactor-app/schema": "1.
|
|
50
|
-
"@pactor-app/expression": "1.
|
|
48
|
+
"@pactor-app/core": "1.22.0",
|
|
49
|
+
"@pactor-app/schema": "1.22.0",
|
|
50
|
+
"@pactor-app/expression": "1.22.0"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"react": ">=18"
|