@abyss-project/runtime 3.4.0 → 3.6.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.
Files changed (58) hide show
  1. package/.eslintrc.js +32 -32
  2. package/.prettierrc +5 -5
  3. package/dist/discord/discord.types.d.ts +167 -4
  4. package/dist/discord/discord.types.js +48 -1
  5. package/dist/discord/discord.types.js.map +1 -1
  6. package/dist/engine/engine-source.js +1 -1
  7. package/dist/interpreter/interpreter.js +18 -4
  8. package/dist/interpreter/interpreter.js.map +1 -1
  9. package/dist/interpreter/interpreter.types.d.ts +2 -0
  10. package/dist/interpreter/interpreter.types.js.map +1 -1
  11. package/dist/runner-protocol/execution-protocol.types.d.ts +11 -0
  12. package/dist/runner-protocol/execution-protocol.types.js +2 -1
  13. package/dist/runner-protocol/execution-protocol.types.js.map +1 -1
  14. package/jest.config.ts +11 -11
  15. package/package.json +15 -10
  16. package/scripts/build-engine.cjs +70 -70
  17. package/src/__tests__/engine-bundle.test.ts +121 -121
  18. package/src/__tests__/surface.test.ts +5 -1
  19. package/src/access/__tests__/host-match.test.ts +24 -24
  20. package/src/access/access.types.ts +25 -25
  21. package/src/access/host-match.ts +13 -13
  22. package/src/cost/__tests__/execution-cost.test.ts +196 -196
  23. package/src/cost/execution-cost.ts +186 -186
  24. package/src/definition/__tests__/validate-definition.test.ts +354 -354
  25. package/src/definition/definition.limits.ts +9 -9
  26. package/src/definition/definition.schema.ts +172 -172
  27. package/src/definition/definition.types.ts +171 -171
  28. package/src/definition/validate-definition.ts +206 -206
  29. package/src/definition/walk-steps.ts +44 -44
  30. package/src/discord/discord.types.ts +264 -5
  31. package/src/engine/__tests__/run-in-isolate.test.ts +468 -468
  32. package/src/engine/engine-entry.ts +3 -3
  33. package/src/engine/engine-global.ts +2 -2
  34. package/src/engine/run-in-isolate.ts +404 -404
  35. package/src/errors/runtime-error-code.enum.ts +37 -37
  36. package/src/index.ts +32 -32
  37. package/src/interpreter/__tests__/interpreter.test.ts +854 -854
  38. package/src/interpreter/__tests__/log-respond-resume.test.ts +270 -223
  39. package/src/interpreter/interpreter-error.ts +12 -12
  40. package/src/interpreter/interpreter.ts +482 -461
  41. package/src/interpreter/interpreter.types.ts +202 -192
  42. package/src/interpreter/sequence-path.ts +67 -67
  43. package/src/interpreter/test-host.ts +85 -85
  44. package/src/runner-protocol/evaluation.types.ts +21 -21
  45. package/src/runner-protocol/execution-protocol.types.ts +254 -231
  46. package/src/schedule/schedule.types.ts +100 -100
  47. package/src/server/__tests__/code-runner-session.test.ts +311 -311
  48. package/src/server/code-runner-error.ts +12 -12
  49. package/src/server/code-runner-session.ts +310 -310
  50. package/src/server/index.ts +11 -11
  51. package/src/steps/__tests__/global-references.test.ts +133 -133
  52. package/src/steps/execute-step.ts +186 -186
  53. package/src/steps/global-references.ts +48 -48
  54. package/src/steps/step-access.ts +56 -56
  55. package/src/steps/step-fields.ts +87 -87
  56. package/src/steps/value-source.ts +69 -69
  57. package/tsconfig.check.json +15 -15
  58. package/tsconfig.json +35 -35
@@ -1,100 +1,100 @@
1
- import type { JSONValue } from '../runner-protocol/execution-protocol.types';
2
-
3
- /**
4
- * Host capabilities of the delayed runs of a Service. The host declares them in the execution's
5
- * capabilities; client code reaches them through `abyss.schedule.<name>(...)`; every helper
6
- * exists, and one whose capability is not granted rejects with an error naming the action to
7
- * declare. The argument shapes below are the `args` of the `call`.
8
- */
9
- export enum ScheduleCapability {
10
- /** Schedules a run of a task after a delay. Arguments: `ScheduleAfterArgs`; result: `ScheduleResult`. */
11
- SCHEDULE_AFTER = 'schedule.after',
12
- /** Schedules a run of a task at a date. Arguments: `ScheduleAtArgs`; result: `ScheduleResult`. */
13
- SCHEDULE_AT = 'schedule.at',
14
- /** Cancels a pending delayed run. Arguments: `ScheduleCancelArgs`; result: `ScheduleCancelResult`. */
15
- SCHEDULE_CANCEL = 'schedule.cancel',
16
- }
17
-
18
- /**
19
- * Codes of the errors `abyss.schedule.*` throws. The host fails the call with the message
20
- * `<code>: <detail>` (or the bare code); the helper rethrows an `Error` named `ScheduleError`
21
- * whose `code` is the code and whose `message` is the detail.
22
- */
23
- export enum ScheduleErrorCode {
24
- /** No task of that name in the version in service. */
25
- SCHEDULE_TASK_UNKNOWN = 'SCHEDULE_TASK_UNKNOWN',
26
- /** The due date is less than the minimal delay away, or beyond the horizon. */
27
- SCHEDULE_HORIZON_EXCEEDED = 'SCHEDULE_HORIZON_EXCEEDED',
28
- /** The Service already has as many pending delayed runs in this environment as its plan allows. */
29
- SCHEDULE_LIMIT_REACHED = 'SCHEDULE_LIMIT_REACHED',
30
- /** The attached payload is longer than allowed once serialized to JSON. */
31
- SCHEDULE_PAYLOAD_TOO_LARGE = 'SCHEDULE_PAYLOAD_TOO_LARGE',
32
- /** The arguments are malformed (delay not a number, date not ISO 8601, empty key...). */
33
- SCHEDULE_INVALID = 'SCHEDULE_INVALID',
34
- }
35
-
36
- /** Options shared by `abyss.schedule.after` and `abyss.schedule.at`. */
37
- export interface ScheduleOptions {
38
- /**
39
- * Deduplication key: while a delayed run of the same task with the same key is pending in the
40
- * environment, scheduling again returns that run's id with `deduplicated: true`.
41
- * `abyss.schedule.cancel(key)` cancels the pending runs with that key across every task of the
42
- * Service in the environment.
43
- */
44
- key?: string;
45
- }
46
-
47
- export interface ScheduleAfterArgs extends ScheduleOptions {
48
- /** Delay before the run, in seconds. */
49
- seconds: number;
50
- /** Name of the task of the Service to run. */
51
- taskName: string;
52
- /** Data handed to the run as `input.payload`. */
53
- payload?: JSONValue;
54
- }
55
-
56
- export interface ScheduleAtArgs extends ScheduleOptions {
57
- /** Due date, ISO 8601. */
58
- at: string;
59
- /** Name of the task of the Service to run. */
60
- taskName: string;
61
- /** Data handed to the run as `input.payload`. */
62
- payload?: JSONValue;
63
- }
64
-
65
- export interface ScheduleCancelArgs {
66
- /** The id `schedule.after` or `schedule.at` returned, or the deduplication key of the run. */
67
- idOrKey: string;
68
- }
69
-
70
- export interface ScheduleResult {
71
- /** Id of the delayed run. */
72
- id: string;
73
- /** True when a pending run with the same key already existed: its id is returned, nothing is added. */
74
- deduplicated: boolean;
75
- }
76
-
77
- export interface ScheduleCancelResult {
78
- /** False when no pending run matched (unknown, already run or already cancelled). */
79
- cancelled: boolean;
80
- }
81
-
82
- /** What started a scheduled run: a tick of the task's cron, or a delayed run. */
83
- export enum ScheduledRunKind {
84
- SCHEDULE = 'SCHEDULE',
85
- DELAYED = 'DELAYED',
86
- }
87
-
88
- /** The `input` of a function started by a task: a cron tick or a delayed run. */
89
- export interface ScheduledRunInput {
90
- kind: ScheduledRunKind;
91
- task: { id: string; name: string };
92
- /** When the run was due, ISO 8601. */
93
- scheduledFor: string;
94
- /** When this attempt started, ISO 8601. */
95
- firedAt: string;
96
- /** Attempt number, from 1. */
97
- attempt: number;
98
- /** The payload of a delayed run, when it has one. */
99
- payload?: JSONValue;
100
- }
1
+ import type { JSONValue } from '../runner-protocol/execution-protocol.types';
2
+
3
+ /**
4
+ * Host capabilities of the delayed runs of a Service. The host declares them in the execution's
5
+ * capabilities; client code reaches them through `abyss.schedule.<name>(...)`; every helper
6
+ * exists, and one whose capability is not granted rejects with an error naming the action to
7
+ * declare. The argument shapes below are the `args` of the `call`.
8
+ */
9
+ export enum ScheduleCapability {
10
+ /** Schedules a run of a task after a delay. Arguments: `ScheduleAfterArgs`; result: `ScheduleResult`. */
11
+ SCHEDULE_AFTER = 'schedule.after',
12
+ /** Schedules a run of a task at a date. Arguments: `ScheduleAtArgs`; result: `ScheduleResult`. */
13
+ SCHEDULE_AT = 'schedule.at',
14
+ /** Cancels a pending delayed run. Arguments: `ScheduleCancelArgs`; result: `ScheduleCancelResult`. */
15
+ SCHEDULE_CANCEL = 'schedule.cancel',
16
+ }
17
+
18
+ /**
19
+ * Codes of the errors `abyss.schedule.*` throws. The host fails the call with the message
20
+ * `<code>: <detail>` (or the bare code); the helper rethrows an `Error` named `ScheduleError`
21
+ * whose `code` is the code and whose `message` is the detail.
22
+ */
23
+ export enum ScheduleErrorCode {
24
+ /** No task of that name in the version in service. */
25
+ SCHEDULE_TASK_UNKNOWN = 'SCHEDULE_TASK_UNKNOWN',
26
+ /** The due date is less than the minimal delay away, or beyond the horizon. */
27
+ SCHEDULE_HORIZON_EXCEEDED = 'SCHEDULE_HORIZON_EXCEEDED',
28
+ /** The Service already has as many pending delayed runs in this environment as its plan allows. */
29
+ SCHEDULE_LIMIT_REACHED = 'SCHEDULE_LIMIT_REACHED',
30
+ /** The attached payload is longer than allowed once serialized to JSON. */
31
+ SCHEDULE_PAYLOAD_TOO_LARGE = 'SCHEDULE_PAYLOAD_TOO_LARGE',
32
+ /** The arguments are malformed (delay not a number, date not ISO 8601, empty key...). */
33
+ SCHEDULE_INVALID = 'SCHEDULE_INVALID',
34
+ }
35
+
36
+ /** Options shared by `abyss.schedule.after` and `abyss.schedule.at`. */
37
+ export interface ScheduleOptions {
38
+ /**
39
+ * Deduplication key: while a delayed run of the same task with the same key is pending in the
40
+ * environment, scheduling again returns that run's id with `deduplicated: true`.
41
+ * `abyss.schedule.cancel(key)` cancels the pending runs with that key across every task of the
42
+ * Service in the environment.
43
+ */
44
+ key?: string;
45
+ }
46
+
47
+ export interface ScheduleAfterArgs extends ScheduleOptions {
48
+ /** Delay before the run, in seconds. */
49
+ seconds: number;
50
+ /** Name of the task of the Service to run. */
51
+ taskName: string;
52
+ /** Data handed to the run as `input.payload`. */
53
+ payload?: JSONValue;
54
+ }
55
+
56
+ export interface ScheduleAtArgs extends ScheduleOptions {
57
+ /** Due date, ISO 8601. */
58
+ at: string;
59
+ /** Name of the task of the Service to run. */
60
+ taskName: string;
61
+ /** Data handed to the run as `input.payload`. */
62
+ payload?: JSONValue;
63
+ }
64
+
65
+ export interface ScheduleCancelArgs {
66
+ /** The id `schedule.after` or `schedule.at` returned, or the deduplication key of the run. */
67
+ idOrKey: string;
68
+ }
69
+
70
+ export interface ScheduleResult {
71
+ /** Id of the delayed run. */
72
+ id: string;
73
+ /** True when a pending run with the same key already existed: its id is returned, nothing is added. */
74
+ deduplicated: boolean;
75
+ }
76
+
77
+ export interface ScheduleCancelResult {
78
+ /** False when no pending run matched (unknown, already run or already cancelled). */
79
+ cancelled: boolean;
80
+ }
81
+
82
+ /** What started a scheduled run: a tick of the task's cron, or a delayed run. */
83
+ export enum ScheduledRunKind {
84
+ SCHEDULE = 'SCHEDULE',
85
+ DELAYED = 'DELAYED',
86
+ }
87
+
88
+ /** The `input` of a function started by a task: a cron tick or a delayed run. */
89
+ export interface ScheduledRunInput {
90
+ kind: ScheduledRunKind;
91
+ task: { id: string; name: string };
92
+ /** When the run was due, ISO 8601. */
93
+ scheduledFor: string;
94
+ /** When this attempt started, ISO 8601. */
95
+ firedAt: string;
96
+ /** Attempt number, from 1. */
97
+ attempt: number;
98
+ /** The payload of a delayed run, when it has one. */
99
+ payload?: JSONValue;
100
+ }