@abyss-project/runtime 0.0.0-stage → 2.0.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 (132) hide show
  1. package/.eslintrc.js +32 -0
  2. package/.prettierrc +5 -0
  3. package/README.md +28 -3
  4. package/dist/access/access.types.d.ts +14 -0
  5. package/dist/access/access.types.js +9 -0
  6. package/dist/access/access.types.js.map +1 -0
  7. package/dist/access/host-match.d.ts +1 -0
  8. package/dist/access/host-match.js +14 -0
  9. package/dist/access/host-match.js.map +1 -0
  10. package/dist/cost/execution-cost.d.ts +45 -0
  11. package/dist/cost/execution-cost.js +114 -0
  12. package/dist/cost/execution-cost.js.map +1 -0
  13. package/dist/definition/definition.limits.d.ts +4 -0
  14. package/dist/definition/definition.limits.js +8 -0
  15. package/dist/definition/definition.limits.js.map +1 -0
  16. package/dist/definition/definition.schema.d.ts +8 -0
  17. package/dist/definition/definition.schema.js +123 -0
  18. package/dist/definition/definition.schema.js.map +1 -0
  19. package/dist/definition/definition.types.d.ts +117 -0
  20. package/dist/definition/definition.types.js +37 -0
  21. package/dist/definition/definition.types.js.map +1 -0
  22. package/dist/definition/validate-definition.d.ts +9 -0
  23. package/dist/definition/validate-definition.js +163 -0
  24. package/dist/definition/validate-definition.js.map +1 -0
  25. package/dist/definition/walk-steps.d.ts +5 -0
  26. package/dist/definition/walk-steps.js +31 -0
  27. package/dist/definition/walk-steps.js.map +1 -0
  28. package/dist/engine/engine-entry.d.ts +1 -0
  29. package/dist/engine/engine-entry.js +6 -0
  30. package/dist/engine/engine-entry.js.map +1 -0
  31. package/dist/engine/engine-global.d.ts +1 -0
  32. package/dist/engine/engine-global.js +5 -0
  33. package/dist/engine/engine-global.js.map +1 -0
  34. package/dist/engine/engine-source.d.ts +2 -0
  35. package/dist/engine/engine-source.js +3 -0
  36. package/dist/engine/run-in-isolate.d.ts +34 -0
  37. package/dist/engine/run-in-isolate.js +267 -0
  38. package/dist/engine/run-in-isolate.js.map +1 -0
  39. package/dist/errors/runtime-error-code.enum.d.ts +18 -0
  40. package/dist/errors/runtime-error-code.enum.js +19 -0
  41. package/dist/errors/runtime-error-code.enum.js.map +1 -0
  42. package/dist/index.d.ts +21 -0
  43. package/dist/index.js +47 -0
  44. package/dist/index.js.map +1 -0
  45. package/dist/interpreter/interpreter-error.d.ts +5 -0
  46. package/dist/interpreter/interpreter-error.js +12 -0
  47. package/dist/interpreter/interpreter-error.js.map +1 -0
  48. package/dist/interpreter/interpreter.d.ts +30 -0
  49. package/dist/interpreter/interpreter.js +313 -0
  50. package/dist/interpreter/interpreter.js.map +1 -0
  51. package/dist/interpreter/interpreter.types.d.ts +152 -0
  52. package/dist/interpreter/interpreter.types.js +31 -0
  53. package/dist/interpreter/interpreter.types.js.map +1 -0
  54. package/dist/interpreter/sequence-path.d.ts +6 -0
  55. package/dist/interpreter/sequence-path.js +53 -0
  56. package/dist/interpreter/sequence-path.js.map +1 -0
  57. package/dist/interpreter/test-host.d.ts +18 -0
  58. package/dist/interpreter/test-host.js +43 -0
  59. package/dist/interpreter/test-host.js.map +1 -0
  60. package/dist/runner-protocol/evaluation.types.d.ts +20 -0
  61. package/dist/runner-protocol/evaluation.types.js +10 -0
  62. package/dist/runner-protocol/evaluation.types.js.map +1 -0
  63. package/dist/runner-protocol/execution-protocol.types.d.ts +132 -0
  64. package/dist/runner-protocol/execution-protocol.types.js +48 -0
  65. package/dist/runner-protocol/execution-protocol.types.js.map +1 -0
  66. package/dist/server/code-runner-error.d.ts +5 -0
  67. package/dist/server/code-runner-error.js +12 -0
  68. package/dist/server/code-runner-error.js.map +1 -0
  69. package/dist/server/code-runner-session.d.ts +28 -0
  70. package/dist/server/code-runner-session.js +208 -0
  71. package/dist/server/code-runner-session.js.map +1 -0
  72. package/dist/server/index.d.ts +3 -0
  73. package/dist/server/index.js +10 -0
  74. package/dist/server/index.js.map +1 -0
  75. package/dist/steps/execute-step.d.ts +50 -0
  76. package/dist/steps/execute-step.js +136 -0
  77. package/dist/steps/execute-step.js.map +1 -0
  78. package/dist/steps/global-references.d.ts +2 -0
  79. package/dist/steps/global-references.js +28 -0
  80. package/dist/steps/global-references.js.map +1 -0
  81. package/dist/steps/step-access.d.ts +8 -0
  82. package/dist/steps/step-access.js +39 -0
  83. package/dist/steps/step-access.js.map +1 -0
  84. package/dist/steps/step-fields.d.ts +5 -0
  85. package/dist/steps/step-fields.js +68 -0
  86. package/dist/steps/step-fields.js.map +1 -0
  87. package/dist/steps/value-source.d.ts +6 -0
  88. package/dist/steps/value-source.js +58 -0
  89. package/dist/steps/value-source.js.map +1 -0
  90. package/jest.config.ts +11 -0
  91. package/package.json +68 -3
  92. package/scripts/build-engine.cjs +70 -0
  93. package/src/__tests__/engine-bundle.test.ts +121 -0
  94. package/src/__tests__/surface.test.ts +53 -0
  95. package/src/access/__tests__/host-match.test.ts +24 -0
  96. package/src/access/access.types.ts +25 -0
  97. package/src/access/host-match.ts +13 -0
  98. package/src/cost/__tests__/execution-cost.test.ts +200 -0
  99. package/src/cost/execution-cost.ts +192 -0
  100. package/src/definition/__tests__/validate-definition.test.ts +354 -0
  101. package/src/definition/definition.limits.ts +9 -0
  102. package/src/definition/definition.schema.ts +172 -0
  103. package/src/definition/definition.types.ts +171 -0
  104. package/src/definition/validate-definition.ts +206 -0
  105. package/src/definition/walk-steps.ts +44 -0
  106. package/src/engine/__tests__/run-in-isolate.test.ts +468 -0
  107. package/src/engine/engine-entry.ts +3 -0
  108. package/src/engine/engine-global.ts +2 -0
  109. package/src/engine/run-in-isolate.ts +404 -0
  110. package/src/errors/runtime-error-code.enum.ts +37 -0
  111. package/src/index.ts +30 -0
  112. package/src/interpreter/__tests__/interpreter.test.ts +854 -0
  113. package/src/interpreter/__tests__/log-respond-resume.test.ts +223 -0
  114. package/src/interpreter/interpreter-error.ts +12 -0
  115. package/src/interpreter/interpreter.ts +461 -0
  116. package/src/interpreter/interpreter.types.ts +192 -0
  117. package/src/interpreter/sequence-path.ts +67 -0
  118. package/src/interpreter/test-host.ts +85 -0
  119. package/src/runner-protocol/evaluation.types.ts +21 -0
  120. package/src/runner-protocol/execution-protocol.types.ts +221 -0
  121. package/src/server/__tests__/code-runner-session.test.ts +311 -0
  122. package/src/server/code-runner-error.ts +12 -0
  123. package/src/server/code-runner-session.ts +310 -0
  124. package/src/server/index.ts +11 -0
  125. package/src/steps/__tests__/global-references.test.ts +113 -0
  126. package/src/steps/execute-step.ts +186 -0
  127. package/src/steps/global-references.ts +48 -0
  128. package/src/steps/step-access.ts +56 -0
  129. package/src/steps/step-fields.ts +87 -0
  130. package/src/steps/value-source.ts +69 -0
  131. package/tsconfig.check.json +15 -0
  132. package/tsconfig.json +35 -0
package/.eslintrc.js ADDED
@@ -0,0 +1,32 @@
1
+ module.exports = {
2
+ parser: '@typescript-eslint/parser',
3
+ parserOptions: {
4
+ project: 'tsconfig.check.json',
5
+ tsconfigRootDir: __dirname,
6
+ sourceType: 'module',
7
+ },
8
+ plugins: ['@typescript-eslint/eslint-plugin', 'filenames-simple'],
9
+ extends: [
10
+ 'plugin:@typescript-eslint/recommended',
11
+ 'plugin:prettier/recommended',
12
+ ],
13
+ root: true,
14
+ env: {
15
+ node: true,
16
+ jest: true,
17
+ },
18
+ ignorePatterns: ['.eslintrc.js', 'jest.config.ts'],
19
+ rules: {
20
+ '@typescript-eslint/explicit-function-return-type': 'off',
21
+ '@typescript-eslint/explicit-module-boundary-types': 'off',
22
+ '@typescript-eslint/no-explicit-any': 'off',
23
+ "@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
24
+ 'filenames-simple/naming-convention': [
25
+ 'error',
26
+ {
27
+ rule: '^([a-z0-9]*)(-[a-z0-9]+)*$',
28
+ },
29
+ ],
30
+ },
31
+ overrides: [],
32
+ };
package/.prettierrc ADDED
@@ -0,0 +1,5 @@
1
+ {
2
+ "singleQuote": true,
3
+ "trailingComma": "all",
4
+ "printWidth": 100
5
+ }
package/README.md CHANGED
@@ -1,3 +1,28 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
1
+ # @abyss-project/runtime
2
+
3
+ Abyss automation core: definitions, interpreter, execution protocol `abyss-runtime.v2` and
4
+ execution cost.
5
+
6
+ The package root (`@abyss-project/runtime`) is browser-compatible. Node-only code (the
7
+ `CodeRunnerSession` WebSocket client) lives under `@abyss-project/runtime/server`.
8
+ `@abyss-project/runtime/engine` exports `ENGINE_SOURCE`, the interpreter bundled into one
9
+ self-contained script for the code runner's isolate.
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ npm install @abyss-project/runtime
15
+ # or
16
+ pnpm add @abyss-project/runtime
17
+ ```
18
+
19
+ ## Liens
20
+
21
+ - **Documentation** : [https://docs.abyss-project.fr](https://docs.abyss-project.fr)
22
+ - **NPM** : [@abyss-project/runtime](https://www.npmjs.com/package/@abyss-project/runtime)
23
+ - **Application Abyss** : [app.abyss-project.fr](https://app.abyss-project.fr)
24
+ - **Statut des services** : [status.abyss-project.fr](https://status.abyss-project.fr)
25
+
26
+ ## Support
27
+
28
+ Pour toute demande, ouvrir un ticket depuis [l'application Abyss](https://app.abyss-project.fr/dashboard/account/tickets/create).
@@ -0,0 +1,14 @@
1
+ export declare enum AccessKind {
2
+ HTTP = "HTTP",
3
+ HOST_ACTION = "HOST_ACTION"
4
+ }
5
+ export interface HttpAccess {
6
+ kind: AccessKind.HTTP;
7
+ hosts: string[];
8
+ }
9
+ export interface HostActionAccess {
10
+ kind: AccessKind.HOST_ACTION;
11
+ action: string;
12
+ }
13
+ export type AccessDeclaration = HttpAccess | HostActionAccess;
14
+ export type AccessGrant = AccessDeclaration;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AccessKind = void 0;
4
+ var AccessKind;
5
+ (function (AccessKind) {
6
+ AccessKind["HTTP"] = "HTTP";
7
+ AccessKind["HOST_ACTION"] = "HOST_ACTION";
8
+ })(AccessKind || (exports.AccessKind = AccessKind = {}));
9
+ //# sourceMappingURL=access.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"access.types.js","sourceRoot":"","sources":["../../src/access/access.types.ts"],"names":[],"mappings":";;;AAAA,IAAY,UAKX;AALD,WAAY,UAAU;IAEpB,2BAAa,CAAA;IAEb,yCAA2B,CAAA;AAC7B,CAAC,EALW,UAAU,0BAAV,UAAU,QAKrB"}
@@ -0,0 +1 @@
1
+ export declare const hostMatches: (host: string, pattern: string) => boolean;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.hostMatches = void 0;
4
+ const hostMatches = (host, pattern) => {
5
+ const candidate = host.toLowerCase();
6
+ const expected = pattern.toLowerCase();
7
+ if (!expected.startsWith('*.')) {
8
+ return candidate === expected;
9
+ }
10
+ const suffix = expected.slice(1);
11
+ return candidate.length > suffix.length && candidate.endsWith(suffix);
12
+ };
13
+ exports.hostMatches = hostMatches;
14
+ //# sourceMappingURL=host-match.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host-match.js","sourceRoot":"","sources":["../../src/access/host-match.ts"],"names":[],"mappings":";;;AAIO,MAAM,WAAW,GAAG,CAAC,IAAY,EAAE,OAAe,EAAW,EAAE;IACpE,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IACrC,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IACvC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAC/B,OAAO,SAAS,KAAK,QAAQ,CAAC;IAChC,CAAC;IACD,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACjC,OAAO,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AACxE,CAAC,CAAC;AARW,QAAA,WAAW,eAQtB"}
@@ -0,0 +1,45 @@
1
+ export declare enum ResourceProfile {
2
+ S = "S",
3
+ M = "M",
4
+ L = "L",
5
+ XL = "XL",
6
+ XXL = "XXL"
7
+ }
8
+ export interface ResourceProfileSpec {
9
+ memoryMb: number;
10
+ cpuCoefficient: number;
11
+ }
12
+ export declare const RESOURCE_PROFILES: Readonly<Record<ResourceProfile, ResourceProfileSpec>>;
13
+ export declare const COST_RATES: {
14
+ readonly executionMillicredits: 10;
15
+ readonly cpuMillicreditsPerSecond: 500;
16
+ readonly guaranteedCpuCoefficient: 1.5;
17
+ readonly memoryMillicreditsPerGbSecond: 100;
18
+ readonly networkOutMillicreditsPerMb: 1000;
19
+ readonly httpCallMillicredits: 10;
20
+ readonly storeWriteMillicredits: 10;
21
+ };
22
+ export declare enum CostedExecutionStatus {
23
+ RAN = "RAN",
24
+ INTERRUPTED = "INTERRUPTED",
25
+ REFUSED = "REFUSED"
26
+ }
27
+ export interface StepUsage {
28
+ cpuMs: number;
29
+ wallMs: number;
30
+ netOutBytes: number;
31
+ httpCalls: number;
32
+ storeWrites: number;
33
+ }
34
+ export interface ExecutionCostInput extends StepUsage {
35
+ status: CostedExecutionStatus;
36
+ profile: ResourceProfile;
37
+ guaranteedCpu: boolean;
38
+ resumedSegment?: boolean;
39
+ }
40
+ export interface StepCostInput {
41
+ execution: ExecutionCostInput;
42
+ steps: StepUsage[];
43
+ }
44
+ export declare const computeExecutionCost: (input: ExecutionCostInput) => number;
45
+ export declare const computeStepCost: (input: StepCostInput) => number[];
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.computeStepCost = exports.computeExecutionCost = exports.CostedExecutionStatus = exports.COST_RATES = exports.RESOURCE_PROFILES = exports.ResourceProfile = void 0;
4
+ var ResourceProfile;
5
+ (function (ResourceProfile) {
6
+ ResourceProfile["S"] = "S";
7
+ ResourceProfile["M"] = "M";
8
+ ResourceProfile["L"] = "L";
9
+ ResourceProfile["XL"] = "XL";
10
+ ResourceProfile["XXL"] = "XXL";
11
+ })(ResourceProfile || (exports.ResourceProfile = ResourceProfile = {}));
12
+ exports.RESOURCE_PROFILES = {
13
+ [ResourceProfile.S]: { memoryMb: 128, cpuCoefficient: 1 },
14
+ [ResourceProfile.M]: { memoryMb: 256, cpuCoefficient: 1.05 },
15
+ [ResourceProfile.L]: { memoryMb: 512, cpuCoefficient: 1.1 },
16
+ [ResourceProfile.XL]: { memoryMb: 1024, cpuCoefficient: 1.2 },
17
+ [ResourceProfile.XXL]: { memoryMb: 2048, cpuCoefficient: 1.35 },
18
+ };
19
+ exports.COST_RATES = {
20
+ executionMillicredits: 10,
21
+ cpuMillicreditsPerSecond: 500,
22
+ guaranteedCpuCoefficient: 1.5,
23
+ memoryMillicreditsPerGbSecond: 100,
24
+ networkOutMillicreditsPerMb: 1000,
25
+ httpCallMillicredits: 10,
26
+ storeWriteMillicredits: 10,
27
+ };
28
+ var CostedExecutionStatus;
29
+ (function (CostedExecutionStatus) {
30
+ CostedExecutionStatus["RAN"] = "RAN";
31
+ CostedExecutionStatus["INTERRUPTED"] = "INTERRUPTED";
32
+ CostedExecutionStatus["REFUSED"] = "REFUSED";
33
+ })(CostedExecutionStatus || (exports.CostedExecutionStatus = CostedExecutionStatus = {}));
34
+ const MICROS_PER_SECOND = BigInt(1_000_000);
35
+ const CPU_DENOMINATOR = MICROS_PER_SECOND * BigInt(100) * BigInt(1000);
36
+ const MEMORY_DENOMINATOR = BigInt(1024) * MICROS_PER_SECOND;
37
+ const NETWORK_DENOMINATOR = BigInt(1024 * 1024);
38
+ const UNITS_PER_MILLICREDIT = BigInt(1_048_576) * BigInt(48_828_125);
39
+ const ZERO = BigInt(0);
40
+ const ONE = BigInt(1);
41
+ const TWO = BigInt(2);
42
+ const assertUsage = (usage, subject) => {
43
+ ['cpuMs', 'wallMs', 'netOutBytes', 'httpCalls', 'storeWrites'].forEach((key) => {
44
+ const value = usage[key];
45
+ if (!Number.isFinite(value) || value < 0) {
46
+ throw new RangeError(`${subject}.${key} must be a finite number >= 0, got ${value}`);
47
+ }
48
+ });
49
+ };
50
+ const micros = (ms) => BigInt(Math.round(ms * 1000));
51
+ const whole = (count) => BigInt(Math.round(count));
52
+ const hundredths = (coefficient) => BigInt(Math.round(coefficient * 100));
53
+ const thousandths = (coefficient) => BigInt(Math.round(coefficient * 1000));
54
+ const variableUnits = (usage, execution) => {
55
+ const profile = exports.RESOURCE_PROFILES[execution.profile];
56
+ const guaranteed = execution.guaranteedCpu ? exports.COST_RATES.guaranteedCpuCoefficient : 1;
57
+ const cpu = (micros(usage.cpuMs) *
58
+ BigInt(exports.COST_RATES.cpuMillicreditsPerSecond) *
59
+ hundredths(profile.cpuCoefficient) *
60
+ thousandths(guaranteed) *
61
+ UNITS_PER_MILLICREDIT) /
62
+ CPU_DENOMINATOR;
63
+ const memory = (BigInt(profile.memoryMb) *
64
+ micros(usage.wallMs) *
65
+ BigInt(exports.COST_RATES.memoryMillicreditsPerGbSecond) *
66
+ UNITS_PER_MILLICREDIT) /
67
+ MEMORY_DENOMINATOR;
68
+ const network = (whole(usage.netOutBytes) *
69
+ BigInt(exports.COST_RATES.networkOutMillicreditsPerMb) *
70
+ UNITS_PER_MILLICREDIT) /
71
+ NETWORK_DENOMINATOR;
72
+ const effects = (whole(usage.httpCalls) * BigInt(exports.COST_RATES.httpCallMillicredits) +
73
+ whole(usage.storeWrites) * BigInt(exports.COST_RATES.storeWriteMillicredits)) *
74
+ UNITS_PER_MILLICREDIT;
75
+ return cpu + memory + network + effects;
76
+ };
77
+ const floorDiv = (numerator, denominator) => {
78
+ const quotient = numerator / denominator;
79
+ return numerator % denominator !== ZERO && numerator < ZERO ? quotient - ONE : quotient;
80
+ };
81
+ const roundHalfUp = (units) => Number(floorDiv(units * TWO + UNITS_PER_MILLICREDIT, UNITS_PER_MILLICREDIT * TWO));
82
+ const isFree = (execution) => execution.status !== CostedExecutionStatus.RAN;
83
+ const executionPrice = (execution) => isFree(execution) || execution.resumedSegment ? 0 : exports.COST_RATES.executionMillicredits;
84
+ const computeExecutionCost = (input) => {
85
+ assertUsage(input, 'execution');
86
+ if (isFree(input)) {
87
+ return 0;
88
+ }
89
+ return executionPrice(input) + roundHalfUp(variableUnits(input, input));
90
+ };
91
+ exports.computeExecutionCost = computeExecutionCost;
92
+ const computeStepCost = (input) => {
93
+ const { execution, steps } = input;
94
+ assertUsage(execution, 'execution');
95
+ steps.forEach((step, index) => assertUsage(step, `steps[${index}]`));
96
+ if (steps.length === 0) {
97
+ return [];
98
+ }
99
+ if (isFree(execution)) {
100
+ return steps.map(() => 0);
101
+ }
102
+ const total = variableUnits(execution, execution);
103
+ let cumulative = ZERO;
104
+ let assigned = 0;
105
+ return steps.map((step, index) => {
106
+ cumulative = index === steps.length - 1 ? total : cumulative + variableUnits(step, execution);
107
+ const rounded = roundHalfUp(cumulative);
108
+ const cost = rounded - assigned;
109
+ assigned = rounded;
110
+ return cost;
111
+ });
112
+ };
113
+ exports.computeStepCost = computeStepCost;
114
+ //# sourceMappingURL=execution-cost.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-cost.js","sourceRoot":"","sources":["../../src/cost/execution-cost.ts"],"names":[],"mappings":";;;AAIA,IAAY,eAMX;AAND,WAAY,eAAe;IACzB,0BAAO,CAAA;IACP,0BAAO,CAAA;IACP,0BAAO,CAAA;IACP,4BAAS,CAAA;IACT,8BAAW,CAAA;AACb,CAAC,EANW,eAAe,+BAAf,eAAe,QAM1B;AASY,QAAA,iBAAiB,GAA2D;IACvF,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,cAAc,EAAE,CAAC,EAAE;IACzD,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE;IAC5D,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,cAAc,EAA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O,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QAC/B,UAAU,GAAG,KAAK,KAAK,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,GAAG,aAAa,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QAC9F,MAAM,OAAO,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC;QACxC,MAAM,IAAI,GAAG,OAAO,GAAG,QAAQ,CAAC;QAChC,QAAQ,GAAG,OAAO,CAAC;QACnB,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AApBW,QAAA,eAAe,mBAoB1B"}
@@ -0,0 +1,4 @@
1
+ export declare const MAX_HTTP_TIMEOUT_MS = 30000;
2
+ export declare const MAX_WAIT_DURATION_MS: number;
3
+ export declare const MIN_RESPONSE_STATUS = 100;
4
+ export declare const MAX_RESPONSE_STATUS = 599;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MAX_RESPONSE_STATUS = exports.MIN_RESPONSE_STATUS = exports.MAX_WAIT_DURATION_MS = exports.MAX_HTTP_TIMEOUT_MS = void 0;
4
+ exports.MAX_HTTP_TIMEOUT_MS = 30_000;
5
+ exports.MAX_WAIT_DURATION_MS = 30 * 24 * 60 * 60 * 1000;
6
+ exports.MIN_RESPONSE_STATUS = 100;
7
+ exports.MAX_RESPONSE_STATUS = 599;
8
+ //# sourceMappingURL=definition.limits.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definition.limits.js","sourceRoot":"","sources":["../../src/definition/definition.limits.ts"],"names":[],"mappings":";;;AAGa,QAAA,mBAAmB,GAAG,MAAM,CAAC;AAC7B,QAAA,oBAAoB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAGhD,QAAA,mBAAmB,GAAG,GAAG,CAAC;AAC1B,QAAA,mBAAmB,GAAG,GAAG,CAAC"}
@@ -0,0 +1,8 @@
1
+ import Joi from 'joi';
2
+ import { AccessKind } from '../access/access.types';
3
+ import { MAX_HTTP_TIMEOUT_MS, MAX_WAIT_DURATION_MS } from './definition.limits';
4
+ import { StepType } from './definition.types';
5
+ export { MAX_HTTP_TIMEOUT_MS, MAX_WAIT_DURATION_MS };
6
+ export declare const STEP_SCHEMAS: Record<StepType, Joi.ObjectSchema>;
7
+ export declare const DEFINITION_SCHEMA: Joi.ObjectSchema<any>;
8
+ export declare const ACCESS_SCHEMAS: Record<AccessKind, Joi.ObjectSchema>;
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ACCESS_SCHEMAS = exports.DEFINITION_SCHEMA = exports.STEP_SCHEMAS = exports.MAX_WAIT_DURATION_MS = exports.MAX_HTTP_TIMEOUT_MS = void 0;
7
+ const joi_1 = __importDefault(require("joi"));
8
+ const access_types_1 = require("../access/access.types");
9
+ const definition_limits_1 = require("./definition.limits");
10
+ Object.defineProperty(exports, "MAX_HTTP_TIMEOUT_MS", { enumerable: true, get: function () { return definition_limits_1.MAX_HTTP_TIMEOUT_MS; } });
11
+ Object.defineProperty(exports, "MAX_WAIT_DURATION_MS", { enumerable: true, get: function () { return definition_limits_1.MAX_WAIT_DURATION_MS; } });
12
+ const definition_types_1 = require("./definition.types");
13
+ const RESERVED_NAMES = ['__proto__', 'constructor', 'prototype'];
14
+ const IDENTIFIER = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
15
+ const HOST_PATTERN = /^(\*\.)?[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i;
16
+ let valueSourceCount = 0;
17
+ const valueSource = () => {
18
+ const id = `valueSource${valueSourceCount++}`;
19
+ return joi_1.default.alternatives()
20
+ .try(joi_1.default.string().allow(''), joi_1.default.number(), joi_1.default.boolean(), joi_1.default.valid(null), joi_1.default.array().items(joi_1.default.link(`#${id}`)), joi_1.default.object({ $expression: joi_1.default.string().required() }), joi_1.default.object().pattern(joi_1.default.string().invalid('$expression'), joi_1.default.link(`#${id}`)))
21
+ .id(id);
22
+ };
23
+ const valueMap = () => joi_1.default.object().pattern(joi_1.default.string(), valueSource());
24
+ const durationSource = () => joi_1.default.alternatives().try(joi_1.default.number().integer().min(0).max(definition_limits_1.MAX_WAIT_DURATION_MS), joi_1.default.string().allow(''), joi_1.default.object({ $expression: joi_1.default.string().required() }));
25
+ const untilSource = () => joi_1.default.alternatives().try(joi_1.default.string().pattern(/\{\{[\s\S]*?\}\}/), joi_1.default.string().isoDate(), joi_1.default.object({ $expression: joi_1.default.string().required() }));
26
+ const statusSource = () => joi_1.default.alternatives().try(joi_1.default.number().integer().min(definition_limits_1.MIN_RESPONSE_STATUS).max(definition_limits_1.MAX_RESPONSE_STATUS), joi_1.default.string().pattern(/\{\{[\s\S]*?\}\}/), joi_1.default.object({ $expression: joi_1.default.string().required() }));
27
+ const stepBase = {
28
+ id: joi_1.default.string()
29
+ .min(1)
30
+ .invalid(...RESERVED_NAMES)
31
+ .required(),
32
+ name: joi_1.default.string().allow(''),
33
+ };
34
+ exports.STEP_SCHEMAS = {
35
+ [definition_types_1.StepType.CONDITION]: joi_1.default.object({
36
+ ...stepBase,
37
+ type: joi_1.default.valid(definition_types_1.StepType.CONDITION).required(),
38
+ if: valueSource().required(),
39
+ then: joi_1.default.array().required(),
40
+ else: joi_1.default.array(),
41
+ }),
42
+ [definition_types_1.StepType.SWITCH]: joi_1.default.object({
43
+ ...stepBase,
44
+ type: joi_1.default.valid(definition_types_1.StepType.SWITCH).required(),
45
+ value: valueSource().required(),
46
+ cases: joi_1.default.array()
47
+ .min(1)
48
+ .items(joi_1.default.object({ match: valueSource().required(), steps: joi_1.default.array().required() }))
49
+ .required(),
50
+ default: joi_1.default.array(),
51
+ }),
52
+ [definition_types_1.StepType.WAIT]: joi_1.default.object({
53
+ ...stepBase,
54
+ type: joi_1.default.valid(definition_types_1.StepType.WAIT).required(),
55
+ durationMs: durationSource(),
56
+ until: untilSource(),
57
+ }).xor('durationMs', 'until'),
58
+ [definition_types_1.StepType.SET]: joi_1.default.object({
59
+ ...stepBase,
60
+ type: joi_1.default.valid(definition_types_1.StepType.SET).required(),
61
+ variable: joi_1.default.string()
62
+ .pattern(IDENTIFIER)
63
+ .invalid(...RESERVED_NAMES)
64
+ .required(),
65
+ value: valueSource().required(),
66
+ }),
67
+ [definition_types_1.StepType.CODE]: joi_1.default.object({
68
+ ...stepBase,
69
+ type: joi_1.default.valid(definition_types_1.StepType.CODE).required(),
70
+ source: joi_1.default.string().min(1).required(),
71
+ }),
72
+ [definition_types_1.StepType.HTTP]: joi_1.default.object({
73
+ ...stepBase,
74
+ type: joi_1.default.valid(definition_types_1.StepType.HTTP).required(),
75
+ method: joi_1.default.valid(...Object.values(definition_types_1.HttpMethod)).required(),
76
+ url: valueSource().required(),
77
+ headers: valueMap(),
78
+ body: valueSource(),
79
+ timeoutMs: joi_1.default.number().integer().min(1).max(definition_limits_1.MAX_HTTP_TIMEOUT_MS),
80
+ }),
81
+ [definition_types_1.StepType.HOST]: joi_1.default.object({
82
+ ...stepBase,
83
+ type: joi_1.default.valid(definition_types_1.StepType.HOST).required(),
84
+ action: joi_1.default.string().min(1).required(),
85
+ input: valueMap().required(),
86
+ }),
87
+ [definition_types_1.StepType.LOG]: joi_1.default.object({
88
+ ...stepBase,
89
+ type: joi_1.default.valid(definition_types_1.StepType.LOG).required(),
90
+ level: joi_1.default.valid(...Object.values(definition_types_1.LogLevel)).required(),
91
+ message: valueSource().required(),
92
+ data: valueSource(),
93
+ }),
94
+ [definition_types_1.StepType.RESPOND]: joi_1.default.object({
95
+ ...stepBase,
96
+ type: joi_1.default.valid(definition_types_1.StepType.RESPOND).required(),
97
+ status: statusSource().required(),
98
+ headers: valueMap(),
99
+ body: valueSource(),
100
+ }),
101
+ [definition_types_1.StepType.STOP]: joi_1.default.object({
102
+ ...stepBase,
103
+ type: joi_1.default.valid(definition_types_1.StepType.STOP).required(),
104
+ status: joi_1.default.valid(...Object.values(definition_types_1.StopStatus)).required(),
105
+ output: valueSource(),
106
+ }),
107
+ };
108
+ exports.DEFINITION_SCHEMA = joi_1.default.object({
109
+ formatVersion: joi_1.default.valid(definition_types_1.CURRENT_FORMAT_VERSION).required(),
110
+ accesses: joi_1.default.array().required(),
111
+ steps: joi_1.default.array().required(),
112
+ });
113
+ exports.ACCESS_SCHEMAS = {
114
+ [access_types_1.AccessKind.HTTP]: joi_1.default.object({
115
+ kind: joi_1.default.valid(access_types_1.AccessKind.HTTP).required(),
116
+ hosts: joi_1.default.array().items(joi_1.default.string().pattern(HOST_PATTERN)).min(1).required(),
117
+ }),
118
+ [access_types_1.AccessKind.HOST_ACTION]: joi_1.default.object({
119
+ kind: joi_1.default.valid(access_types_1.AccessKind.HOST_ACTION).required(),
120
+ action: joi_1.default.string().min(1).required(),
121
+ }),
122
+ };
123
+ //# sourceMappingURL=definition.schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definition.schema.js","sourceRoot":"","sources":["../../src/definition/definition.schema.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAsB;AACtB,yDAAoD;AACpD,2DAK6B;AASpB,oGAbP,uCAAmB,OAaO;AAAE,qGAX5B,wCAAoB,OAW4B;AARlD,yDAM4B;AAK5B,MAAM,cAAc,GAAG,CAAC,WAAW,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC;AAEjE,MAAM,UAAU,GAAG,4BAA4B,CAAC;AAChD,MAAM,YAAY,GAAG,2EAA2E,CAAC;AAEjG,IAAI,gBAAgB,GAAG,CAAC,CAAC;AAMzB,MAAM,WAAW,GAAG,GAA2B,EAAE;IAC/C,MAAM,EAAE,GAAG,cAAc,gBAAgB,EAAE,EAAE,CAAC;IAC9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AG,CAAC,KAAK,CAAC,yBAAU,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE;QAC3C,KAAK,EAAE,aAAG,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,aAAG,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;KAC/E,CAAC;IACF,CAAC,yBAAU,CAAC,WAAW,CAAC,EAAE,aAAG,CAAC,MAAM,CAAC;QACnC,IAAI,EAAE,aAAG,CAAC,KAAK,CAAC,yBAAU,CAAC,WAAW,CAAC,CAAC,QAAQ,EAAE;QAClD,MAAM,EAAE,aAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;KACvC,CAAC;CACH,CAAC"}
@@ -0,0 +1,117 @@
1
+ import type { ObjectSchema } from 'joi';
2
+ import type { AccessDeclaration } from '../access/access.types';
3
+ export declare const CURRENT_FORMAT_VERSION = 1;
4
+ export interface ExpressionValue {
5
+ $expression: string;
6
+ }
7
+ export type ValueSource = string | number | boolean | null | ExpressionValue | ValueSource[] | {
8
+ [key: string]: ValueSource;
9
+ };
10
+ export declare enum StepType {
11
+ CONDITION = "CONDITION",
12
+ SWITCH = "SWITCH",
13
+ WAIT = "WAIT",
14
+ SET = "SET",
15
+ CODE = "CODE",
16
+ HTTP = "HTTP",
17
+ HOST = "HOST",
18
+ LOG = "LOG",
19
+ RESPOND = "RESPOND",
20
+ STOP = "STOP"
21
+ }
22
+ export declare enum LogLevel {
23
+ INFO = "info",
24
+ WARN = "warn",
25
+ ERROR = "error"
26
+ }
27
+ export declare enum HttpMethod {
28
+ GET = "GET",
29
+ POST = "POST",
30
+ PUT = "PUT",
31
+ PATCH = "PATCH",
32
+ DELETE = "DELETE"
33
+ }
34
+ export declare enum StopStatus {
35
+ SUCCEEDED = "SUCCEEDED",
36
+ FAILED = "FAILED"
37
+ }
38
+ interface StepBase {
39
+ id: string;
40
+ name?: string;
41
+ }
42
+ export interface ConditionStep extends StepBase {
43
+ type: StepType.CONDITION;
44
+ if: ValueSource;
45
+ then: Step[];
46
+ else?: Step[];
47
+ }
48
+ export interface SwitchCase {
49
+ match: ValueSource;
50
+ steps: Step[];
51
+ }
52
+ export interface SwitchStep extends StepBase {
53
+ type: StepType.SWITCH;
54
+ value: ValueSource;
55
+ cases: SwitchCase[];
56
+ default?: Step[];
57
+ }
58
+ export interface WaitStep extends StepBase {
59
+ type: StepType.WAIT;
60
+ durationMs?: ValueSource;
61
+ until?: ValueSource;
62
+ }
63
+ export interface SetStep extends StepBase {
64
+ type: StepType.SET;
65
+ variable: string;
66
+ value: ValueSource;
67
+ }
68
+ export interface CodeStep extends StepBase {
69
+ type: StepType.CODE;
70
+ source: string;
71
+ }
72
+ export interface HttpStep extends StepBase {
73
+ type: StepType.HTTP;
74
+ method: HttpMethod;
75
+ url: ValueSource;
76
+ headers?: Record<string, ValueSource>;
77
+ body?: ValueSource;
78
+ timeoutMs?: number;
79
+ }
80
+ export interface HostStep extends StepBase {
81
+ type: StepType.HOST;
82
+ action: string;
83
+ input: Record<string, ValueSource>;
84
+ }
85
+ export interface LogStep extends StepBase {
86
+ type: StepType.LOG;
87
+ level: LogLevel;
88
+ message: ValueSource;
89
+ data?: ValueSource;
90
+ }
91
+ export interface RespondStep extends StepBase {
92
+ type: StepType.RESPOND;
93
+ status: ValueSource;
94
+ headers?: Record<string, ValueSource>;
95
+ body?: ValueSource;
96
+ }
97
+ export interface StopStep extends StepBase {
98
+ type: StepType.STOP;
99
+ status: StopStatus;
100
+ output?: ValueSource;
101
+ }
102
+ export type Step = ConditionStep | SwitchStep | WaitStep | SetStep | CodeStep | HttpStep | HostStep | LogStep | RespondStep | StopStep;
103
+ export interface RuntimeDefinition {
104
+ formatVersion: typeof CURRENT_FORMAT_VERSION;
105
+ accesses: AccessDeclaration[];
106
+ steps: Step[];
107
+ }
108
+ export interface HostActionDefinition {
109
+ name: string;
110
+ inputSchema: ObjectSchema;
111
+ }
112
+ export type HostActionCatalog = ReadonlyMap<string, HostActionDefinition>;
113
+ export interface DefinitionError {
114
+ path: string;
115
+ message: string;
116
+ }
117
+ export {};
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StopStatus = exports.HttpMethod = exports.LogLevel = exports.StepType = exports.CURRENT_FORMAT_VERSION = void 0;
4
+ exports.CURRENT_FORMAT_VERSION = 1;
5
+ var StepType;
6
+ (function (StepType) {
7
+ StepType["CONDITION"] = "CONDITION";
8
+ StepType["SWITCH"] = "SWITCH";
9
+ StepType["WAIT"] = "WAIT";
10
+ StepType["SET"] = "SET";
11
+ StepType["CODE"] = "CODE";
12
+ StepType["HTTP"] = "HTTP";
13
+ StepType["HOST"] = "HOST";
14
+ StepType["LOG"] = "LOG";
15
+ StepType["RESPOND"] = "RESPOND";
16
+ StepType["STOP"] = "STOP";
17
+ })(StepType || (exports.StepType = StepType = {}));
18
+ var LogLevel;
19
+ (function (LogLevel) {
20
+ LogLevel["INFO"] = "info";
21
+ LogLevel["WARN"] = "warn";
22
+ LogLevel["ERROR"] = "error";
23
+ })(LogLevel || (exports.LogLevel = LogLevel = {}));
24
+ var HttpMethod;
25
+ (function (HttpMethod) {
26
+ HttpMethod["GET"] = "GET";
27
+ HttpMethod["POST"] = "POST";
28
+ HttpMethod["PUT"] = "PUT";
29
+ HttpMethod["PATCH"] = "PATCH";
30
+ HttpMethod["DELETE"] = "DELETE";
31
+ })(HttpMethod || (exports.HttpMethod = HttpMethod = {}));
32
+ var StopStatus;
33
+ (function (StopStatus) {
34
+ StopStatus["SUCCEEDED"] = "SUCCEEDED";
35
+ StopStatus["FAILED"] = "FAILED";
36
+ })(StopStatus || (exports.StopStatus = StopStatus = {}));
37
+ //# sourceMappingURL=definition.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definition.types.js","sourceRoot":"","sources":["../../src/definition/definition.types.ts"],"names":[],"mappings":";;;AAGa,QAAA,sBAAsB,GAAG,CAAC,CAAC;AAmBxC,IAAY,QAaX;AAbD,WAAY,QAAQ;IAClB,mCAAuB,CAAA;IACvB,6BAAiB,CAAA;IACjB,yBAAa,CAAA;IACb,uBAAW,CAAA;IACX,yBAAa,CAAA;IACb,yBAAa,CAAA;IACb,yBAAa,CAAA;IAEb,uBAAW,CAAA;IAEX,+BAAmB,CAAA;IACnB,yBAAa,CAAA;AACf,CAAC,EAbW,QAAQ,wBAAR,QAAQ,QAanB;AAED,IAAY,QAIX;AAJD,WAAY,QAAQ;IAClB,yBAAa,CAAA;IACb,yBAAa,CAAA;IACb,2BAAe,CAAA;AACjB,CAAC,EAJW,QAAQ,wBAAR,QAAQ,QAInB;AAED,IAAY,UAMX;AAND,WAAY,UAAU;IACpB,yBAAW,CAAA;IACX,2BAAa,CAAA;IACb,yBAAW,CAAA;IACX,6BAAe,CAAA;IACf,+BAAiB,CAAA;AACnB,CAAC,EANW,UAAU,0BAAV,UAAU,QAMrB;AAED,IAAY,UAGX;AAHD,WAAY,UAAU;IACpB,qCAAuB,CAAA;IACvB,+BAAiB,CAAA;AACnB,CAAC,EAHW,UAAU,0BAAV,UAAU,QAGrB"}
@@ -0,0 +1,9 @@
1
+ import type { DefinitionError, HostActionCatalog, RuntimeDefinition } from './definition.types';
2
+ export type ValidationResult = {
3
+ ok: true;
4
+ definition: RuntimeDefinition;
5
+ } | {
6
+ ok: false;
7
+ errors: DefinitionError[];
8
+ };
9
+ export declare const validateDefinition: (raw: unknown, catalog: HostActionCatalog) => ValidationResult;