@executioncontrolprotocol/jsonata 0.13.2 → 0.60.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/LICENSE +198 -13
- package/README.md +6 -46
- package/dist/capabilities/transform.d.ts +9 -0
- package/dist/capabilities/transform.d.ts.map +1 -0
- package/dist/capabilities/transform.js +80 -0
- package/dist/capabilities/transform.js.map +1 -0
- package/dist/index.d.ts +14 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +30 -50
- package/dist/index.js.map +1 -1
- package/ecp.manifest.json +35 -0
- package/ecp.schema.json +5 -0
- package/package.json +26 -13
- package/dist/schemas.d.ts +0 -32
- package/dist/schemas.d.ts.map +0 -1
- package/dist/schemas.js +0 -16
- package/dist/schemas.js.map +0 -1
- package/dist/transform.d.ts +0 -7
- package/dist/transform.d.ts.map +0 -1
- package/dist/transform.js +0 -29
- package/dist/transform.js.map +0 -1
package/LICENSE
CHANGED
|
@@ -1,17 +1,202 @@
|
|
|
1
|
-
Apache License
|
|
2
|
-
Version 2.0, January 2004
|
|
3
|
-
http://www.apache.org/licenses/
|
|
4
1
|
|
|
5
|
-
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
you may not use this file except in compliance with the License.
|
|
9
|
-
You may obtain a copy of the License at
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
10
7
|
|
|
11
|
-
|
|
8
|
+
1. Definitions.
|
|
12
9
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 Rockbound Digital Inc.
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,49 +1,9 @@
|
|
|
1
1
|
# @executioncontrolprotocol/jsonata
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Optional first-party plugin. Supplies `@executioncontrolprotocol/jsonata.transform` for step-level
|
|
4
|
+
`expression` transforms using [JSONata](https://jsonata.org/). Not bundled with the host; install
|
|
5
|
+
with `ecp plugins install jsonata`.
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
```ts
|
|
10
|
-
import "@executioncontrolprotocol/jsonata"
|
|
11
|
-
import { environment, extension } from "@executioncontrolprotocol/node"
|
|
12
|
-
|
|
13
|
-
export default environment("jsonata-demo").withExtensions([
|
|
14
|
-
extension("@executioncontrolprotocol/jsonata").with({}),
|
|
15
|
-
])
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
## Capability: `@executioncontrolprotocol/jsonata.transform`
|
|
19
|
-
|
|
20
|
-
**Input:** `{ expression, payload, bindings? }`
|
|
21
|
-
|
|
22
|
-
- `expression` — JSONata expression string (agent-authored)
|
|
23
|
-
- `payload` — document to evaluate against (literal or `ref(...)`)
|
|
24
|
-
- `bindings` — optional named variables assigned before evaluation
|
|
25
|
-
|
|
26
|
-
**Output:** `{ result }` — evaluation result (any JSON-compatible value).
|
|
27
|
-
|
|
28
|
-
## Chaining
|
|
29
|
-
|
|
30
|
-
```ts
|
|
31
|
-
step("@executioncontrolprotocol/jsonata.transform", "Project fields")
|
|
32
|
-
.with({
|
|
33
|
-
expression: '{ "name": name, "total": price * qty }',
|
|
34
|
-
payload: ref("echo.echo"),
|
|
35
|
-
})
|
|
36
|
-
.as("projected")
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
With bindings (reference assigned names as `$factor`):
|
|
40
|
-
|
|
41
|
-
```ts
|
|
42
|
-
step("@executioncontrolprotocol/jsonata.transform", "Scale total")
|
|
43
|
-
.with({
|
|
44
|
-
expression: "total * $factor",
|
|
45
|
-
payload: ref("projected.result"),
|
|
46
|
-
bindings: { factor: 2 },
|
|
47
|
-
})
|
|
48
|
-
.as("scaled")
|
|
49
|
-
```
|
|
7
|
+
Each evaluation runs in a short-lived child Node.js process with a 64 MiB heap. The child is killed
|
|
8
|
+
when the step times out (capability `timeoutMs`, 1000 ms) or is cancelled, so a runaway or
|
|
9
|
+
memory-hungry expression fails the step without affecting the host.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { HandlerContext } from "@executioncontrolprotocol/plugin-sdk";
|
|
2
|
+
/**
|
|
3
|
+
* Evaluates the step JSONata expression on resolved input in a child process. The step signal
|
|
4
|
+
* (capability `timeoutMs`, or cancellation) kills the child, so evaluation never outlives the step.
|
|
5
|
+
* A result of `undefined` (nothing matched) becomes `null`; the host `returns` check decides if that is valid.
|
|
6
|
+
* @category Plugins
|
|
7
|
+
*/
|
|
8
|
+
export default function handler(input: unknown, ctx: HandlerContext): Promise<unknown>;
|
|
9
|
+
//# sourceMappingURL=transform.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../src/capabilities/transform.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAA;AAoC1E;;;;;GAKG;AACH,wBAA8B,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAsC3F"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
/** Heap cap for one evaluation process. */
|
|
4
|
+
const CHILD_HEAP_MB = 64;
|
|
5
|
+
const jsonataPath = createRequire(import.meta.url).resolve("jsonata");
|
|
6
|
+
/**
|
|
7
|
+
* Child body (CommonJS, run with `node -e`). JSONata runs in its own process, not on the host's event
|
|
8
|
+
* loop or heap: terminating it stops a runaway expression, and running out of memory kills only the child.
|
|
9
|
+
* (A worker thread is not enough: V8 can abort the whole process when a worker exhausts its heap.)
|
|
10
|
+
*/
|
|
11
|
+
const CHILD_SOURCE = `
|
|
12
|
+
process.once("message", ({ jsonataPath, expression, input }) => {
|
|
13
|
+
Promise.resolve()
|
|
14
|
+
.then(() => require(jsonataPath)(expression).evaluate(input))
|
|
15
|
+
.then(
|
|
16
|
+
(value) => process.send({ ok: true, json: value === undefined ? undefined : JSON.stringify(value) }),
|
|
17
|
+
(error) => process.send({
|
|
18
|
+
ok: false,
|
|
19
|
+
message: error && typeof error.message === "string" ? error.message : String(error),
|
|
20
|
+
position: error && typeof error.position === "number" ? error.position : undefined,
|
|
21
|
+
}),
|
|
22
|
+
)
|
|
23
|
+
.finally(() => process.disconnect())
|
|
24
|
+
})
|
|
25
|
+
`;
|
|
26
|
+
function stepError(code, message) {
|
|
27
|
+
return Object.assign(new Error(message), { code });
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Evaluates the step JSONata expression on resolved input in a child process. The step signal
|
|
31
|
+
* (capability `timeoutMs`, or cancellation) kills the child, so evaluation never outlives the step.
|
|
32
|
+
* A result of `undefined` (nothing matched) becomes `null`; the host `returns` check decides if that is valid.
|
|
33
|
+
* @category Plugins
|
|
34
|
+
*/
|
|
35
|
+
export default async function handler(input, ctx) {
|
|
36
|
+
const expression = ctx.expression;
|
|
37
|
+
if (typeof expression !== "string" || expression.trim().length === 0) {
|
|
38
|
+
throw stepError("ECP_STEP_FAILED", "Step expression is required for JSONata transform.");
|
|
39
|
+
}
|
|
40
|
+
if (ctx.signal.aborted)
|
|
41
|
+
throw stepError("ECP_STEP_TIMEOUT", "Step timed out.");
|
|
42
|
+
const child = spawn(process.execPath, [`--max-old-space-size=${CHILD_HEAP_MB}`, "-e", CHILD_SOURCE], {
|
|
43
|
+
stdio: ["ignore", "ignore", "pipe", "ipc"],
|
|
44
|
+
windowsHide: true,
|
|
45
|
+
});
|
|
46
|
+
let stderr = "";
|
|
47
|
+
child.stderr?.on("data", (chunk) => {
|
|
48
|
+
if (stderr.length < 4096)
|
|
49
|
+
stderr += chunk.toString("utf8");
|
|
50
|
+
});
|
|
51
|
+
const onAbort = () => child.kill();
|
|
52
|
+
ctx.signal.addEventListener("abort", onAbort, { once: true });
|
|
53
|
+
try {
|
|
54
|
+
const reply = await new Promise((resolve, reject) => {
|
|
55
|
+
child.once("message", (message) => resolve(message));
|
|
56
|
+
child.once("error", (error) => reject(stepError("ECP_STEP_FAILED", `JSONata process failed: ${error.message}`)));
|
|
57
|
+
child.once("exit", () => {
|
|
58
|
+
if (ctx.signal.aborted)
|
|
59
|
+
reject(stepError("ECP_STEP_TIMEOUT", "Step timed out."));
|
|
60
|
+
else if (/heap out of memory|heap limit/i.test(stderr)) {
|
|
61
|
+
reject(stepError("ECP_STEP_FAILED", "JSONata evaluation exceeded the memory limit."));
|
|
62
|
+
}
|
|
63
|
+
else
|
|
64
|
+
reject(stepError("ECP_STEP_FAILED", "JSONata process exited without a result."));
|
|
65
|
+
});
|
|
66
|
+
child.send({ jsonataPath, expression, input });
|
|
67
|
+
});
|
|
68
|
+
if (!reply.ok) {
|
|
69
|
+
const at = reply.position !== undefined && Number.isFinite(reply.position) ? ` (at position ${reply.position})` : "";
|
|
70
|
+
throw stepError("ECP_STEP_FAILED", `${reply.message}${at}`);
|
|
71
|
+
}
|
|
72
|
+
return reply.json === undefined ? null : JSON.parse(reply.json);
|
|
73
|
+
}
|
|
74
|
+
finally {
|
|
75
|
+
ctx.signal.removeEventListener("abort", onAbort);
|
|
76
|
+
if (child.exitCode === null && child.signalCode === null)
|
|
77
|
+
child.kill();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=transform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../../src/capabilities/transform.ts"],"names":[],"mappings":"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"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* JSONata transform capability. Step `accepts`, `returns`, and `expression` live on the execution step.
|
|
4
|
+
* @category Plugins
|
|
5
|
+
*/
|
|
6
|
+
export declare const transform: import("@executioncontrolprotocol/plugin-sdk").CapabilityDefinition<z.ZodUnknown, z.ZodUnknown, Record<string, unknown> | undefined>;
|
|
7
|
+
/**
|
|
8
|
+
* JSONata transform plugin.
|
|
9
|
+
* @category Plugins
|
|
10
|
+
*/
|
|
11
|
+
declare const _default: import("@executioncontrolprotocol/plugin-sdk").PluginDefinition<undefined, {
|
|
12
|
+
transform: import("@executioncontrolprotocol/plugin-sdk").CapabilityDefinition<z.ZodUnknown, z.ZodUnknown, Record<string, unknown> | undefined>;
|
|
13
|
+
}>;
|
|
14
|
+
export default _default;
|
|
9
15
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;GAGG;AACH,eAAO,MAAM,SAAS,sIAYpB,CAAA;AAEF;;;GAGG;;;;AACH,wBAQE"}
|
package/dist/index.js
CHANGED
|
@@ -1,51 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"Run this JSONata expression on the payload",
|
|
32
|
-
"Map order lines to `{ sku, qty }` objects with JSONata",
|
|
33
|
-
],
|
|
34
|
-
})
|
|
35
|
-
.withHandler(async (input) => {
|
|
36
|
-
const parsed = input;
|
|
37
|
-
return runJsonataTransform(parsed);
|
|
38
|
-
}),
|
|
39
|
-
])
|
|
40
|
-
.build();
|
|
41
|
-
catalogExtension(jsonataExtension);
|
|
42
|
-
/** Register @executioncontrolprotocol/jsonata. */
|
|
43
|
-
export async function registerJsonataExtension(registry = globalRegistry) {
|
|
44
|
-
if (!registry.getExtension("@executioncontrolprotocol/jsonata")) {
|
|
45
|
-
await registry.registerExtension(jsonataExtension);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
export { jsonataTransformInputSchema, jsonataTransformOutputSchema, } from "./schemas.js";
|
|
49
|
-
export { runJsonataTransform } from "./transform.js";
|
|
50
|
-
export default jsonataExtension;
|
|
1
|
+
import { capability, definePlugin } from "@executioncontrolprotocol/plugin-sdk";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
/**
|
|
4
|
+
* JSONata transform capability. Step `accepts`, `returns`, and `expression` live on the execution step.
|
|
5
|
+
* @category Plugins
|
|
6
|
+
*/
|
|
7
|
+
export const transform = capability({
|
|
8
|
+
contract: "step",
|
|
9
|
+
code: "expression",
|
|
10
|
+
timeoutMs: 1000,
|
|
11
|
+
summary: "Evaluate a JSONata expression against resolved step input.",
|
|
12
|
+
description: "Compiles the step expression with JSONata, evaluates it on the resolved input object, and returns JSON for the host returns check.",
|
|
13
|
+
useCases: ["Project or filter fields with JSONata instead of a sandbox script"],
|
|
14
|
+
projections: ["Take the JSON value JSONata returns; match it to the step returns schema"],
|
|
15
|
+
accepts: z.unknown(),
|
|
16
|
+
returns: z.unknown(),
|
|
17
|
+
handler: () => import("./capabilities/transform.js"),
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* JSONata transform plugin.
|
|
21
|
+
* @category Plugins
|
|
22
|
+
*/
|
|
23
|
+
export default definePlugin({
|
|
24
|
+
id: "@executioncontrolprotocol/jsonata",
|
|
25
|
+
summary: "JSONata transforms for execution steps.",
|
|
26
|
+
description: "Registers the optional transform capability for step-level JSONata expressions. Install separately from the host.",
|
|
27
|
+
capabilities: {
|
|
28
|
+
transform,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
51
31
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAA;AAC/E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,UAAU,CAAC;IAClC,QAAQ,EAAE,MAAM;IAChB,IAAI,EAAE,YAAY;IAClB,SAAS,EAAE,IAAI;IACf,OAAO,EAAE,4DAA4D;IACrE,WAAW,EACT,oIAAoI;IACtI,QAAQ,EAAE,CAAC,mEAAmE,CAAC;IAC/E,WAAW,EAAE,CAAC,0EAA0E,CAAC;IACzF,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE;IACpB,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE;IACpB,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,6BAA6B,CAAC;CACrD,CAAC,CAAA;AAEF;;;GAGG;AACH,eAAe,YAAY,CAAC;IAC1B,EAAE,EAAE,mCAAmC;IACvC,OAAO,EAAE,yCAAyC;IAClD,WAAW,EACT,mHAAmH;IACrH,YAAY,EAAE;QACZ,SAAS;KACV;CACF,CAAC,CAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"capabilities": [
|
|
3
|
+
{
|
|
4
|
+
"code": "expression",
|
|
5
|
+
"contract": "step",
|
|
6
|
+
"description": "Compiles the step expression with JSONata, evaluates it on the resolved input object, and returns JSON for the host returns check.",
|
|
7
|
+
"id": "@executioncontrolprotocol/jsonata.transform",
|
|
8
|
+
"name": "transform",
|
|
9
|
+
"projections": [
|
|
10
|
+
"Take the JSON value JSONata returns; match it to the step returns schema"
|
|
11
|
+
],
|
|
12
|
+
"summary": "Evaluate a JSONata expression against resolved step input.",
|
|
13
|
+
"timeoutMs": 1000,
|
|
14
|
+
"useCases": [
|
|
15
|
+
"Project or filter fields with JSONata instead of a sandbox script"
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"entry": "./dist/index.js",
|
|
20
|
+
"hash": "a04460f3eb2b66498c0d06ff7e54019578f520f983bc229bc278b64a1cdda36f",
|
|
21
|
+
"plugin": {
|
|
22
|
+
"description": "Registers the optional transform capability for step-level JSONata expressions. Install separately from the host.",
|
|
23
|
+
"id": "@executioncontrolprotocol/jsonata",
|
|
24
|
+
"package": "@executioncontrolprotocol/jsonata",
|
|
25
|
+
"summary": "JSONata transforms for execution steps.",
|
|
26
|
+
"version": "0.60.0"
|
|
27
|
+
},
|
|
28
|
+
"pluginSchema": {
|
|
29
|
+
"hash": "8e317e831a89e6ca6f08dea4221f31c4a92e79e71b8f999969bbe63d98a58461",
|
|
30
|
+
"path": "./ecp.schema.json"
|
|
31
|
+
},
|
|
32
|
+
"schema": "@executioncontrolprotocol.plugin-manifest",
|
|
33
|
+
"sdkVersion": "0.60.0",
|
|
34
|
+
"version": "2.0"
|
|
35
|
+
}
|
package/ecp.schema.json
ADDED
package/package.json
CHANGED
|
@@ -1,34 +1,47 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@executioncontrolprotocol/jsonata",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "JSONata
|
|
5
|
-
"license": "Apache-2.0",
|
|
3
|
+
"version": "0.60.0",
|
|
4
|
+
"description": "Optional JSONata transform capability for step-level data reshaping.",
|
|
6
5
|
"type": "module",
|
|
7
|
-
"
|
|
8
|
-
|
|
6
|
+
"engines": {
|
|
7
|
+
"node": ">=22.12"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [
|
|
10
|
+
"ecosystem:ecp-plugin",
|
|
11
|
+
"oclif-plugin"
|
|
12
|
+
],
|
|
13
|
+
"oclif": {},
|
|
14
|
+
"ecp": {
|
|
15
|
+
"manifest": "./ecp.manifest.json",
|
|
16
|
+
"schema": "./ecp.schema.json"
|
|
17
|
+
},
|
|
9
18
|
"exports": {
|
|
10
19
|
".": {
|
|
11
20
|
"types": "./dist/index.d.ts",
|
|
12
21
|
"import": "./dist/index.js"
|
|
13
|
-
}
|
|
22
|
+
},
|
|
23
|
+
"./ecp.manifest.json": "./ecp.manifest.json",
|
|
24
|
+
"./ecp.schema.json": "./ecp.schema.json"
|
|
14
25
|
},
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
15
27
|
"files": [
|
|
16
28
|
"dist",
|
|
17
|
-
"
|
|
29
|
+
"ecp.manifest.json",
|
|
30
|
+
"ecp.schema.json"
|
|
18
31
|
],
|
|
19
32
|
"dependencies": {
|
|
20
33
|
"jsonata": "^2.2.2"
|
|
21
34
|
},
|
|
22
35
|
"peerDependencies": {
|
|
23
|
-
"
|
|
24
|
-
"@executioncontrolprotocol/
|
|
25
|
-
"zod": "^3.24.0"
|
|
36
|
+
"zod": "^4.0.0",
|
|
37
|
+
"@executioncontrolprotocol/plugin-sdk": "0.60.0"
|
|
26
38
|
},
|
|
27
39
|
"devDependencies": {
|
|
28
|
-
"
|
|
29
|
-
"
|
|
40
|
+
"zod": "^4.0.0",
|
|
41
|
+
"@executioncontrolprotocol/plugin-sdk": "0.60.0"
|
|
30
42
|
},
|
|
31
43
|
"scripts": {
|
|
32
|
-
"build": "tsc -b"
|
|
44
|
+
"build": "tsc -b && node ../../packages/plugin-sdk/dist/bin/ecp-plugin-manifest.js",
|
|
45
|
+
"check:manifest": "node ../../packages/plugin-sdk/dist/bin/ecp-plugin-manifest.js --check"
|
|
33
46
|
}
|
|
34
47
|
}
|
package/dist/schemas.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
/** Input for {@link "@executioncontrolprotocol/jsonata.transform"}. @category Extensions */
|
|
3
|
-
export declare const jsonataTransformInputSchema: z.ZodObject<{
|
|
4
|
-
/** JSONata expression (agent-authored). */
|
|
5
|
-
expression: z.ZodString;
|
|
6
|
-
/** Document to evaluate against (literal or ref-resolved). */
|
|
7
|
-
payload: z.ZodUnknown;
|
|
8
|
-
/** Optional named bindings assigned before evaluation (reference as `$name` in the expression). */
|
|
9
|
-
bindings: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
10
|
-
}, "strip", z.ZodTypeAny, {
|
|
11
|
-
expression: string;
|
|
12
|
-
payload?: unknown;
|
|
13
|
-
bindings?: Record<string, unknown> | undefined;
|
|
14
|
-
}, {
|
|
15
|
-
expression: string;
|
|
16
|
-
payload?: unknown;
|
|
17
|
-
bindings?: Record<string, unknown> | undefined;
|
|
18
|
-
}>;
|
|
19
|
-
/** Output for {@link "@executioncontrolprotocol/jsonata.transform"}. @category Extensions */
|
|
20
|
-
export declare const jsonataTransformOutputSchema: z.ZodObject<{
|
|
21
|
-
/** Evaluation result (any JSON-compatible value). */
|
|
22
|
-
result: z.ZodUnknown;
|
|
23
|
-
}, "strip", z.ZodTypeAny, {
|
|
24
|
-
result?: unknown;
|
|
25
|
-
}, {
|
|
26
|
-
result?: unknown;
|
|
27
|
-
}>;
|
|
28
|
-
/** Inferred input type for jsonata.transform. @category Extensions */
|
|
29
|
-
export type JsonataTransformInput = z.infer<typeof jsonataTransformInputSchema>;
|
|
30
|
-
/** Inferred output type for jsonata.transform. @category Extensions */
|
|
31
|
-
export type JsonataTransformOutput = z.infer<typeof jsonataTransformOutputSchema>;
|
|
32
|
-
//# sourceMappingURL=schemas.d.ts.map
|
package/dist/schemas.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,4FAA4F;AAC5F,eAAO,MAAM,2BAA2B;IACtC,2CAA2C;;IAE3C,8DAA8D;;IAE9D,mGAAmG;;;;;;;;;;EAEnG,CAAA;AAEF,6FAA6F;AAC7F,eAAO,MAAM,4BAA4B;IACvC,qDAAqD;;;;;;EAErD,CAAA;AAEF,sEAAsE;AACtE,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAA;AAE/E,uEAAuE;AACvE,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAA"}
|
package/dist/schemas.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
/** Input for {@link "@executioncontrolprotocol/jsonata.transform"}. @category Extensions */
|
|
3
|
-
export const jsonataTransformInputSchema = z.object({
|
|
4
|
-
/** JSONata expression (agent-authored). */
|
|
5
|
-
expression: z.string().min(1),
|
|
6
|
-
/** Document to evaluate against (literal or ref-resolved). */
|
|
7
|
-
payload: z.unknown(),
|
|
8
|
-
/** Optional named bindings assigned before evaluation (reference as `$name` in the expression). */
|
|
9
|
-
bindings: z.record(z.string(), z.unknown()).optional(),
|
|
10
|
-
});
|
|
11
|
-
/** Output for {@link "@executioncontrolprotocol/jsonata.transform"}. @category Extensions */
|
|
12
|
-
export const jsonataTransformOutputSchema = z.object({
|
|
13
|
-
/** Evaluation result (any JSON-compatible value). */
|
|
14
|
-
result: z.unknown(),
|
|
15
|
-
});
|
|
16
|
-
//# sourceMappingURL=schemas.js.map
|
package/dist/schemas.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,4FAA4F;AAC5F,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,MAAM,CAAC;IAClD,2CAA2C;IAC3C,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7B,8DAA8D;IAC9D,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE;IACpB,mGAAmG;IACnG,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE;CACvD,CAAC,CAAA;AAEF,6FAA6F;AAC7F,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAC,MAAM,CAAC;IACnD,qDAAqD;IACrD,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE;CACpB,CAAC,CAAA"}
|
package/dist/transform.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { JsonataTransformInput, JsonataTransformOutput } from "./schemas.js";
|
|
2
|
-
/**
|
|
3
|
-
* Compile and evaluate a JSONata expression against a payload.
|
|
4
|
-
* @category Extensions
|
|
5
|
-
*/
|
|
6
|
-
export declare function runJsonataTransform(input: JsonataTransformInput): Promise<JsonataTransformOutput>;
|
|
7
|
-
//# sourceMappingURL=transform.d.ts.map
|
package/dist/transform.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../src/transform.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAA;AAEjF;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,KAAK,EAAE,qBAAqB,GAC3B,OAAO,CAAC,sBAAsB,CAAC,CAsBjC"}
|
package/dist/transform.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import jsonata from "jsonata";
|
|
2
|
-
/**
|
|
3
|
-
* Compile and evaluate a JSONata expression against a payload.
|
|
4
|
-
* @category Extensions
|
|
5
|
-
*/
|
|
6
|
-
export async function runJsonataTransform(input) {
|
|
7
|
-
let expr;
|
|
8
|
-
try {
|
|
9
|
-
expr = jsonata(input.expression);
|
|
10
|
-
}
|
|
11
|
-
catch (err) {
|
|
12
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
13
|
-
throw new Error(`Invalid JSONata expression: ${message}`);
|
|
14
|
-
}
|
|
15
|
-
if (input.bindings) {
|
|
16
|
-
for (const [name, value] of Object.entries(input.bindings)) {
|
|
17
|
-
expr.assign(name, value);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
try {
|
|
21
|
-
const result = await expr.evaluate(input.payload);
|
|
22
|
-
return { result };
|
|
23
|
-
}
|
|
24
|
-
catch (err) {
|
|
25
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
26
|
-
throw new Error(`JSONata evaluation failed: ${message}`);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=transform.js.map
|
package/dist/transform.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../src/transform.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAA;AAG7B;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,KAA4B;IAE5B,IAAI,IAAI,CAAA;IACR,IAAI,CAAC;QACH,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;IAClC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QAChE,MAAM,IAAI,KAAK,CAAC,+BAA+B,OAAO,EAAE,CAAC,CAAA;IAC3D,CAAC;IAED,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;QACnB,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC3D,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;QAC1B,CAAC;IACH,CAAC;IAED,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QACjD,OAAO,EAAE,MAAM,EAAE,CAAA;IACnB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QAChE,MAAM,IAAI,KAAK,CAAC,8BAA8B,OAAO,EAAE,CAAC,CAAA;IAC1D,CAAC;AACH,CAAC"}
|