@abyss-project/runtime 3.12.0 → 3.13.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 (69) hide show
  1. package/.eslintrc.js +32 -32
  2. package/.prettierrc +5 -5
  3. package/README.md +88 -88
  4. package/dist/definition/definition.schema.js +6 -0
  5. package/dist/definition/definition.schema.js.map +1 -1
  6. package/dist/definition/definition.types.d.ts +11 -0
  7. package/dist/definition/definition.types.js +6 -1
  8. package/dist/definition/definition.types.js.map +1 -1
  9. package/dist/discord/discord.types.d.ts +2 -34
  10. package/dist/discord/discord.types.js +1 -9
  11. package/dist/discord/discord.types.js.map +1 -1
  12. package/dist/engine/engine-source.js +1 -1
  13. package/dist/errors/runtime-error-code.enum.d.ts +1 -0
  14. package/dist/errors/runtime-error-code.enum.js +1 -0
  15. package/dist/errors/runtime-error-code.enum.js.map +1 -1
  16. package/dist/runner-protocol/evaluation.types.d.ts +1 -0
  17. package/dist/steps/global-references.js +7 -0
  18. package/dist/steps/global-references.js.map +1 -1
  19. package/dist/steps/step-fields.js +10 -0
  20. package/dist/steps/step-fields.js.map +1 -1
  21. package/jest.config.ts +11 -11
  22. package/package.json +1 -1
  23. package/scripts/build-engine.cjs +70 -70
  24. package/src/__tests__/engine-bundle.test.ts +121 -121
  25. package/src/__tests__/surface.test.ts +81 -88
  26. package/src/access/__tests__/host-match.test.ts +24 -24
  27. package/src/access/access.types.ts +25 -25
  28. package/src/access/host-match.ts +13 -13
  29. package/src/cost/__tests__/execution-cost.test.ts +249 -249
  30. package/src/cost/execution-cost.ts +203 -203
  31. package/src/definition/__tests__/code-step.test.ts +56 -0
  32. package/src/definition/__tests__/validate-definition.test.ts +354 -354
  33. package/src/definition/definition.limits.ts +9 -9
  34. package/src/definition/definition.schema.ts +7 -0
  35. package/src/definition/definition.types.ts +21 -1
  36. package/src/definition/validate-definition.ts +206 -206
  37. package/src/definition/walk-steps.ts +44 -44
  38. package/src/discord/__tests__/discord-event-input.test.ts +90 -108
  39. package/src/discord/discord.types.ts +696 -738
  40. package/src/engine/__tests__/run-in-isolate.test.ts +519 -519
  41. package/src/engine/engine-entry.ts +3 -3
  42. package/src/engine/engine-global.ts +2 -2
  43. package/src/engine/run-in-isolate.ts +462 -462
  44. package/src/errors/runtime-error-code.enum.ts +5 -0
  45. package/src/index.ts +32 -32
  46. package/src/interpreter/__tests__/interpreter.test.ts +854 -854
  47. package/src/interpreter/__tests__/log-respond-resume.test.ts +271 -271
  48. package/src/interpreter/interpreter-error.ts +12 -12
  49. package/src/interpreter/interpreter.ts +483 -483
  50. package/src/interpreter/interpreter.types.ts +204 -204
  51. package/src/interpreter/sequence-path.ts +67 -67
  52. package/src/interpreter/test-host.ts +85 -85
  53. package/src/runner-protocol/__tests__/file-payload.test.ts +26 -26
  54. package/src/runner-protocol/evaluation.types.ts +2 -0
  55. package/src/runner-protocol/execution-protocol.types.ts +297 -297
  56. package/src/schedule/schedule.types.ts +100 -100
  57. package/src/server/__tests__/code-runner-session.test.ts +311 -311
  58. package/src/server/code-runner-error.ts +12 -12
  59. package/src/server/code-runner-session.ts +310 -310
  60. package/src/server/index.ts +11 -11
  61. package/src/steps/__tests__/global-references.test.ts +140 -124
  62. package/src/steps/__tests__/step-fields.test.ts +58 -0
  63. package/src/steps/execute-step.ts +186 -186
  64. package/src/steps/global-references.ts +56 -48
  65. package/src/steps/step-access.ts +56 -56
  66. package/src/steps/step-fields.ts +10 -0
  67. package/src/steps/value-source.ts +69 -69
  68. package/tsconfig.check.json +15 -15
  69. 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
+ }