@dxos/compute 0.8.4-main.fcfe5033a5 → 0.8.4-staging.60fe92afc8
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 +102 -5
- package/README.md +36 -1
- package/dist/lib/neutral/StorageService.mjs +22 -0
- package/dist/lib/neutral/StorageService.mjs.map +7 -0
- package/dist/lib/neutral/chunk-2B2KSJT6.mjs +17 -0
- package/dist/lib/neutral/chunk-2B2KSJT6.mjs.map +7 -0
- package/dist/lib/neutral/chunk-AFBNVFAY.mjs +25 -0
- package/dist/lib/neutral/chunk-AFBNVFAY.mjs.map +7 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/neutral/chunk-JAU4E4EK.mjs +53 -0
- package/dist/lib/neutral/chunk-JAU4E4EK.mjs.map +7 -0
- package/dist/lib/neutral/chunk-MEPE4HHX.mjs +21 -0
- package/dist/lib/neutral/chunk-MEPE4HHX.mjs.map +7 -0
- package/dist/lib/neutral/chunk-QZS4G6PE.mjs +240 -0
- package/dist/lib/neutral/chunk-QZS4G6PE.mjs.map +7 -0
- package/dist/lib/neutral/chunk-XEVFBI6S.mjs +62 -0
- package/dist/lib/neutral/chunk-XEVFBI6S.mjs.map +7 -0
- package/dist/lib/neutral/chunk-Z3Y7FQGN.mjs +174 -0
- package/dist/lib/neutral/chunk-Z3Y7FQGN.mjs.map +7 -0
- package/dist/lib/neutral/fib-HBDUGQW7.mjs +10 -0
- package/dist/lib/neutral/fib-HBDUGQW7.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +1179 -51
- package/dist/lib/neutral/index.mjs.map +4 -4
- package/dist/lib/neutral/meta.json +1 -1
- package/dist/lib/neutral/reply-RJIAJ6FV.mjs +10 -0
- package/dist/lib/neutral/reply-RJIAJ6FV.mjs.map +7 -0
- package/dist/lib/neutral/sleep-3T2CZ7RE.mjs +10 -0
- package/dist/lib/neutral/sleep-3T2CZ7RE.mjs.map +7 -0
- package/dist/lib/neutral/testing/index.mjs +27 -214
- package/dist/lib/neutral/testing/index.mjs.map +4 -4
- package/dist/types/src/Blueprint.d.ts +182 -0
- package/dist/types/src/Blueprint.d.ts.map +1 -0
- package/dist/types/src/Credential.d.ts +27 -0
- package/dist/types/src/Credential.d.ts.map +1 -0
- package/dist/types/src/Header.d.ts +9 -0
- package/dist/types/src/Header.d.ts.map +1 -0
- package/dist/types/src/Header.test.d.ts +2 -0
- package/dist/types/src/Header.test.d.ts.map +1 -0
- package/dist/types/src/LayerSpec.d.ts +56 -0
- package/dist/types/src/LayerSpec.d.ts.map +1 -0
- package/dist/types/src/McpServer.d.ts +26 -0
- package/dist/types/src/McpServer.d.ts.map +1 -0
- package/dist/types/src/Operation.d.ts +385 -0
- package/dist/types/src/Operation.d.ts.map +1 -0
- package/dist/types/src/OperationHandlerSet.d.ts +69 -0
- package/dist/types/src/OperationHandlerSet.d.ts.map +1 -0
- package/dist/types/src/OperationHandlerSet.test.d.ts +2 -0
- package/dist/types/src/OperationHandlerSet.test.d.ts.map +1 -0
- package/dist/types/src/OperationRegistry.d.ts +23 -0
- package/dist/types/src/OperationRegistry.d.ts.map +1 -0
- package/dist/types/src/Process.d.ts +255 -0
- package/dist/types/src/Process.d.ts.map +1 -0
- package/dist/types/src/Routine.d.ts +54 -0
- package/dist/types/src/Routine.d.ts.map +1 -0
- package/dist/types/src/Script.d.ts +21 -0
- package/dist/types/src/Script.d.ts.map +1 -0
- package/dist/types/src/ServiceResolver.d.ts +92 -0
- package/dist/types/src/ServiceResolver.d.ts.map +1 -0
- package/dist/types/src/StorageService.d.ts +58 -0
- package/dist/types/src/StorageService.d.ts.map +1 -0
- package/dist/types/src/Template.d.ts +61 -0
- package/dist/types/src/Template.d.ts.map +1 -0
- package/dist/types/src/Template.test.d.ts +2 -0
- package/dist/types/src/Template.test.d.ts.map +1 -0
- package/dist/types/src/Trace.d.ts +266 -0
- package/dist/types/src/Trace.d.ts.map +1 -0
- package/dist/types/src/Trigger.d.ts +192 -0
- package/dist/types/src/Trigger.d.ts.map +1 -0
- package/dist/types/src/TriggerEvent.d.ts +83 -0
- package/dist/types/src/TriggerEvent.d.ts.map +1 -0
- package/dist/types/src/errors.d.ts +308 -0
- package/dist/types/src/errors.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +18 -5
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/testing/definitions.d.ts +11 -0
- package/dist/types/src/testing/definitions.d.ts.map +1 -0
- package/dist/types/src/testing/fib.d.ts +8 -0
- package/dist/types/src/testing/fib.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +6 -4
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/reply.d.ts +4 -0
- package/dist/types/src/testing/reply.d.ts.map +1 -0
- package/dist/types/src/testing/sleep.d.ts +6 -0
- package/dist/types/src/testing/sleep.d.ts.map +1 -0
- package/dist/types/src/umbrella.test.d.ts +2 -0
- package/dist/types/src/umbrella.test.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +25 -36
- package/src/Blueprint.ts +224 -0
- package/src/Credential.ts +53 -0
- package/src/Header.test.ts +132 -0
- package/src/Header.ts +38 -0
- package/src/LayerSpec.ts +91 -0
- package/src/McpServer.ts +44 -0
- package/src/Operation.ts +646 -0
- package/src/OperationHandlerSet.test.ts +97 -0
- package/src/OperationHandlerSet.ts +181 -0
- package/src/OperationRegistry.ts +50 -0
- package/src/Process.ts +541 -0
- package/src/Routine.ts +68 -0
- package/src/Script.ts +33 -0
- package/src/ServiceResolver.ts +200 -0
- package/src/StorageService.ts +101 -0
- package/src/Template.test.ts +164 -0
- package/src/Template.ts +125 -0
- package/src/Trace.ts +363 -0
- package/src/Trigger.ts +196 -0
- package/src/TriggerEvent.ts +64 -0
- package/src/errors.ts +71 -0
- package/src/index.ts +20 -6
- package/src/testing/definitions.ts +51 -0
- package/src/testing/fib.ts +22 -0
- package/src/testing/index.ts +13 -5
- package/src/testing/reply.ts +18 -0
- package/src/testing/sleep.ts +16 -0
- package/src/umbrella.test.ts +51 -0
- package/dist/lib/neutral/chunk-JRV42MW3.mjs +0 -3101
- package/dist/lib/neutral/chunk-JRV42MW3.mjs.map +0 -7
- package/dist/types/src/compute-graph-registry.d.ts +0 -37
- package/dist/types/src/compute-graph-registry.d.ts.map +0 -1
- package/dist/types/src/compute-graph-registry.test.d.ts +0 -2
- package/dist/types/src/compute-graph-registry.test.d.ts.map +0 -1
- package/dist/types/src/compute-graph.d.ts +0 -67
- package/dist/types/src/compute-graph.d.ts.map +0 -1
- package/dist/types/src/compute-graph.test.d.ts +0 -2
- package/dist/types/src/compute-graph.test.d.ts.map +0 -1
- package/dist/types/src/compute-node.d.ts +0 -24
- package/dist/types/src/compute-node.d.ts.map +0 -1
- package/dist/types/src/functions/async-function.d.ts +0 -68
- package/dist/types/src/functions/async-function.d.ts.map +0 -1
- package/dist/types/src/functions/edge-function.d.ts +0 -20
- package/dist/types/src/functions/edge-function.d.ts.map +0 -1
- package/dist/types/src/functions/function-defs.d.ts +0 -11
- package/dist/types/src/functions/function-defs.d.ts.map +0 -1
- package/dist/types/src/functions/index.d.ts +0 -4
- package/dist/types/src/functions/index.d.ts.map +0 -1
- package/dist/types/src/hyperformula.test.d.ts +0 -2
- package/dist/types/src/hyperformula.test.d.ts.map +0 -1
- package/dist/types/src/testing/test-builder.d.ts +0 -15
- package/dist/types/src/testing/test-builder.d.ts.map +0 -1
- package/dist/types/src/testing/test-plugin.d.ts +0 -35
- package/dist/types/src/testing/test-plugin.d.ts.map +0 -1
- package/dist/types/src/testing/test-runtime.d.ts +0 -10
- package/dist/types/src/testing/test-runtime.d.ts.map +0 -1
- package/dist/types/src/testing/util.d.ts +0 -2
- package/dist/types/src/testing/util.d.ts.map +0 -1
- package/dist/types/src/types/hyperformula.d.ts +0 -8
- package/dist/types/src/types/hyperformula.d.ts.map +0 -1
- package/dist/types/src/types/index.d.ts +0 -3
- package/dist/types/src/types/index.d.ts.map +0 -1
- package/dist/types/src/types/types.d.ts +0 -20
- package/dist/types/src/types/types.d.ts.map +0 -1
- package/dist/types/src/types/types.test.d.ts +0 -2
- package/dist/types/src/types/types.test.d.ts.map +0 -1
- package/dist/types/src/util.d.ts +0 -2
- package/dist/types/src/util.d.ts.map +0 -1
- package/src/compute-graph-registry.test.ts +0 -167
- package/src/compute-graph-registry.ts +0 -97
- package/src/compute-graph.test.ts +0 -139
- package/src/compute-graph.ts +0 -265
- package/src/compute-node.ts +0 -59
- package/src/functions/async-function.ts +0 -184
- package/src/functions/edge-function.ts +0 -108
- package/src/functions/function-defs.ts +0 -2427
- package/src/functions/index.ts +0 -7
- package/src/hyperformula.test.ts +0 -14
- package/src/testing/test-builder.ts +0 -59
- package/src/testing/test-plugin.ts +0 -98
- package/src/testing/test-runtime.ts +0 -53
- package/src/testing/util.ts +0 -9
- package/src/types/hyperformula.ts +0 -19
- package/src/types/index.ts +0 -6
- package/src/types/types.test.ts +0 -91
- package/src/types/types.ts +0 -80
- package/src/util.ts +0 -8
package/LICENSE
CHANGED
|
@@ -1,8 +1,105 @@
|
|
|
1
|
-
|
|
2
|
-
Copyright (c) 2022 DXOS
|
|
1
|
+
# Functional Source License, Version 1.1, ALv2 Future License
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
## Abbreviation
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
FSL-1.1-Apache-2.0
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
## Notice
|
|
8
|
+
|
|
9
|
+
Copyright 2026 DXOS
|
|
10
|
+
|
|
11
|
+
## Terms and Conditions
|
|
12
|
+
|
|
13
|
+
### Licensor ("We")
|
|
14
|
+
|
|
15
|
+
The party offering the Software under these Terms and Conditions.
|
|
16
|
+
|
|
17
|
+
### The Software
|
|
18
|
+
|
|
19
|
+
The "Software" is each version of the software that we make available under
|
|
20
|
+
these Terms and Conditions, as indicated by our inclusion of these Terms and
|
|
21
|
+
Conditions with the Software.
|
|
22
|
+
|
|
23
|
+
### License Grant
|
|
24
|
+
|
|
25
|
+
Subject to your compliance with this License Grant and the Patents,
|
|
26
|
+
Redistribution and Trademark clauses below, we hereby grant you the right to
|
|
27
|
+
use, copy, modify, create derivative works, publicly perform, publicly display
|
|
28
|
+
and redistribute the Software for any Permitted Purpose identified below.
|
|
29
|
+
|
|
30
|
+
### Permitted Purpose
|
|
31
|
+
|
|
32
|
+
A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
|
|
33
|
+
means making the Software available to others in a commercial product or
|
|
34
|
+
service that:
|
|
35
|
+
|
|
36
|
+
1. substitutes for the Software;
|
|
37
|
+
|
|
38
|
+
2. substitutes for any other product or service we offer using the Software
|
|
39
|
+
that exists as of the date we make the Software available; or
|
|
40
|
+
|
|
41
|
+
3. offers the same or substantially similar functionality as the Software.
|
|
42
|
+
|
|
43
|
+
Permitted Purposes specifically include using the Software:
|
|
44
|
+
|
|
45
|
+
1. for your internal use and access;
|
|
46
|
+
|
|
47
|
+
2. for non-commercial education;
|
|
48
|
+
|
|
49
|
+
3. for non-commercial research; and
|
|
50
|
+
|
|
51
|
+
4. in connection with professional services that you provide to a licensee
|
|
52
|
+
using the Software in accordance with these Terms and Conditions.
|
|
53
|
+
|
|
54
|
+
### Patents
|
|
55
|
+
|
|
56
|
+
To the extent your use for a Permitted Purpose would necessarily infringe our
|
|
57
|
+
patents, the license grant above includes a license under our patents. If you
|
|
58
|
+
make a claim against any party that the Software infringes or contributes to
|
|
59
|
+
the infringement of any patent, then your patent license to the Software ends
|
|
60
|
+
immediately.
|
|
61
|
+
|
|
62
|
+
### Redistribution
|
|
63
|
+
|
|
64
|
+
The Terms and Conditions apply to all copies, modifications and derivatives of
|
|
65
|
+
the Software.
|
|
66
|
+
|
|
67
|
+
If you redistribute any copies, modifications or derivatives of the Software,
|
|
68
|
+
you must include a copy of or a link to these Terms and Conditions and not
|
|
69
|
+
remove any copyright notices provided in or with the Software.
|
|
70
|
+
|
|
71
|
+
### Disclaimer
|
|
72
|
+
|
|
73
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
|
|
74
|
+
IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
|
|
75
|
+
PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
|
|
76
|
+
|
|
77
|
+
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
|
|
78
|
+
SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
|
|
79
|
+
EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
|
|
80
|
+
|
|
81
|
+
### Trademarks
|
|
82
|
+
|
|
83
|
+
Except for displaying the License Details and identifying us as the origin of
|
|
84
|
+
the Software, you have no right under these Terms and Conditions to use our
|
|
85
|
+
trademarks, trade names, service marks or product names.
|
|
86
|
+
|
|
87
|
+
## Grant of Future License
|
|
88
|
+
|
|
89
|
+
We hereby irrevocably grant you an additional license to use the Software under
|
|
90
|
+
the Apache License, Version 2.0 that is effective on the second anniversary of
|
|
91
|
+
the date we make the Software available. On or after that date, you may use the
|
|
92
|
+
Software under the Apache License, Version 2.0, in which case the following
|
|
93
|
+
will apply:
|
|
94
|
+
|
|
95
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
96
|
+
this file except in compliance with the License.
|
|
97
|
+
|
|
98
|
+
You may obtain a copy of the License at
|
|
99
|
+
|
|
100
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
101
|
+
|
|
102
|
+
Unless required by applicable law or agreed to in writing, software distributed
|
|
103
|
+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
104
|
+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
105
|
+
specific language governing permissions and limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,38 @@
|
|
|
1
1
|
# @dxos/compute
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Umbrella package for AI-aware DXOS compute primitives.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
Importing from `@dxos/compute` is equivalent to importing from the underlying
|
|
8
|
+
source packages. Namespaces preserve their nesting — there is no extra wrapping
|
|
9
|
+
or unwrapping:
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { Blueprint, Operation, Routine, Process, Script, Trace, Trigger } from '@dxos/compute';
|
|
13
|
+
|
|
14
|
+
Blueprint.make({ /* ... */ });
|
|
15
|
+
Operation.lazy(() => /* ... */);
|
|
16
|
+
Trace.write(Trace.OperationStart, { /* ... */ });
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
This single surface subsumes:
|
|
20
|
+
|
|
21
|
+
| Re-exported from | Includes |
|
|
22
|
+
| ------------------ | --------------------------------------------------------------- |
|
|
23
|
+
| `@dxos/operation` | `Operation`, `OperationInvoker`, `OperationHandlerSet`, `OperationRegistry`, errors |
|
|
24
|
+
| `@dxos/blueprints` | `Blueprint`, `Routine`, `Template` |
|
|
25
|
+
| `@dxos/functions` | `Process`, `Trigger`, `TriggerEvent`, `Script`, `Trace`, `ServiceResolver`, `StorageService`, `CredentialsService`, `ExampleHandlers`, services, errors, sdk |
|
|
26
|
+
|
|
27
|
+
The HyperFormula-based compute graph that previously lived here moved to
|
|
28
|
+
[`@dxos/compute-hyperformula`](../compute-hyperformula).
|
|
29
|
+
|
|
30
|
+
## Roadmap
|
|
31
|
+
|
|
32
|
+
- Stage 1 (current): re-exports — consumers depend only on `@dxos/compute`
|
|
33
|
+
while the source packages stay in place.
|
|
34
|
+
- Stage 2: migrate source into `@dxos/compute` and remove
|
|
35
|
+
`@dxos/operation`, `@dxos/blueprints`, and `@dxos/functions`.
|
|
36
|
+
- A companion `@dxos/compute-runtime-local` package will host the local
|
|
37
|
+
implementations of the services defined here (currently in
|
|
38
|
+
`@dxos/functions-runtime`).
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
StorageService,
|
|
3
|
+
clear,
|
|
4
|
+
deleteKey,
|
|
5
|
+
get,
|
|
6
|
+
key,
|
|
7
|
+
list,
|
|
8
|
+
set,
|
|
9
|
+
withDefault
|
|
10
|
+
} from "./chunk-XEVFBI6S.mjs";
|
|
11
|
+
import "./chunk-J5LGTIGS.mjs";
|
|
12
|
+
export {
|
|
13
|
+
StorageService,
|
|
14
|
+
clear,
|
|
15
|
+
deleteKey,
|
|
16
|
+
get,
|
|
17
|
+
key,
|
|
18
|
+
list,
|
|
19
|
+
set,
|
|
20
|
+
withDefault
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=StorageService.mjs.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Sleep
|
|
3
|
+
} from "./chunk-JAU4E4EK.mjs";
|
|
4
|
+
import {
|
|
5
|
+
withHandler
|
|
6
|
+
} from "./chunk-QZS4G6PE.mjs";
|
|
7
|
+
|
|
8
|
+
// src/testing/sleep.ts
|
|
9
|
+
import * as Effect from "effect/Effect";
|
|
10
|
+
var sleep_default = Sleep.pipe(withHandler(Effect.fn(function* ({ duration = 1e5 }) {
|
|
11
|
+
yield* Effect.sleep(duration);
|
|
12
|
+
})));
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
sleep_default
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=chunk-2B2KSJT6.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/testing/sleep.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport * as Operation from '../Operation';\nimport { Sleep } from './definitions';\n\nexport default Sleep.pipe(\n Operation.withHandler(\n Effect.fn(function* ({ duration = 100_000 }) {\n yield* Effect.sleep(duration);\n }),\n ),\n);\n"],
|
|
5
|
+
"mappings": ";;;;;;;;AAIA,YAAYA,YAAY;AAKxB,IAAA,gBAAeC,MAAMC,KACTC,YACDC,UAAG,WAAW,EAAEC,WAAW,IAAO,GAAE;AACzC,SAAcC,aAAMD,QAAAA;AACtB,CAAA,CAAA,CAAA;",
|
|
6
|
+
"names": ["Effect", "Sleep", "pipe", "withHandler", "fn", "duration", "sleep"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Fibonacci
|
|
3
|
+
} from "./chunk-JAU4E4EK.mjs";
|
|
4
|
+
import {
|
|
5
|
+
withHandler
|
|
6
|
+
} from "./chunk-QZS4G6PE.mjs";
|
|
7
|
+
|
|
8
|
+
// src/testing/fib.ts
|
|
9
|
+
import * as Effect from "effect/Effect";
|
|
10
|
+
var fib_default = Fibonacci.pipe(withHandler(Effect.fn(function* ({ iterations = 1e5 }) {
|
|
11
|
+
let a = 0n;
|
|
12
|
+
let b = 1n;
|
|
13
|
+
for (let i = 0; i < iterations; i++) {
|
|
14
|
+
a += b;
|
|
15
|
+
b = a - b;
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
result: a.toString()
|
|
19
|
+
};
|
|
20
|
+
})));
|
|
21
|
+
|
|
22
|
+
export {
|
|
23
|
+
fib_default
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=chunk-AFBNVFAY.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/testing/fib.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport * as Operation from '../Operation';\nimport { Fibonacci } from './definitions';\n\nexport default Fibonacci.pipe(\n Operation.withHandler(\n Effect.fn(function* ({ iterations = 100_000 }) {\n let a = 0n;\n let b = 1n;\n for (let i = 0; i < iterations; i++) {\n a += b;\n b = a - b;\n }\n return { result: a.toString() };\n }),\n ),\n);\n"],
|
|
5
|
+
"mappings": ";;;;;;;;AAIA,YAAYA,YAAY;AAKxB,IAAA,cAAeC,UAAUC,KACbC,YACDC,UAAG,WAAW,EAAEC,aAAa,IAAO,GAAE;AAC3C,MAAIC,IAAI;AACR,MAAIC,IAAI;AACR,WAASC,IAAI,GAAGA,IAAIH,YAAYG,KAAK;AACnCF,SAAKC;AACLA,QAAID,IAAIC;EACV;AACA,SAAO;IAAEE,QAAQH,EAAEI,SAAQ;EAAG;AAChC,CAAA,CAAA,CAAA;",
|
|
6
|
+
"names": ["Effect", "Fibonacci", "pipe", "withHandler", "fn", "iterations", "a", "b", "i", "result", "toString"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import {
|
|
2
|
+
make
|
|
3
|
+
} from "./chunk-QZS4G6PE.mjs";
|
|
4
|
+
|
|
5
|
+
// src/testing/definitions.ts
|
|
6
|
+
import * as Schema from "effect/Schema";
|
|
7
|
+
import { DXN } from "@dxos/keys";
|
|
8
|
+
var Fibonacci = make({
|
|
9
|
+
meta: {
|
|
10
|
+
key: DXN.make("org.example.function.fib"),
|
|
11
|
+
name: "Fibonacci",
|
|
12
|
+
description: "Function that calculates a Fibonacci number"
|
|
13
|
+
},
|
|
14
|
+
input: Schema.Struct({
|
|
15
|
+
iterations: Schema.optional(Schema.Number).annotations({
|
|
16
|
+
description: "Number of iterations",
|
|
17
|
+
default: 1e5
|
|
18
|
+
})
|
|
19
|
+
}),
|
|
20
|
+
output: Schema.Struct({
|
|
21
|
+
result: Schema.String
|
|
22
|
+
})
|
|
23
|
+
});
|
|
24
|
+
var Reply = make({
|
|
25
|
+
meta: {
|
|
26
|
+
key: DXN.make("org.example.function.reply"),
|
|
27
|
+
name: "Reply",
|
|
28
|
+
description: "Function that echoes the input"
|
|
29
|
+
},
|
|
30
|
+
input: Schema.Any,
|
|
31
|
+
output: Schema.Any
|
|
32
|
+
});
|
|
33
|
+
var Sleep = make({
|
|
34
|
+
meta: {
|
|
35
|
+
key: DXN.make("org.example.function.sleep"),
|
|
36
|
+
name: "Sleep",
|
|
37
|
+
description: "Function that sleeps for a given amount of time"
|
|
38
|
+
},
|
|
39
|
+
input: Schema.Struct({
|
|
40
|
+
duration: Schema.optional(Schema.Number).annotations({
|
|
41
|
+
description: "Milliseconds to sleep",
|
|
42
|
+
default: 1e5
|
|
43
|
+
})
|
|
44
|
+
}),
|
|
45
|
+
output: Schema.Void
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
export {
|
|
49
|
+
Fibonacci,
|
|
50
|
+
Reply,
|
|
51
|
+
Sleep
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=chunk-JAU4E4EK.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/testing/definitions.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { DXN } from '@dxos/keys';\n\nimport * as Operation from '../Operation';\n\nexport const Fibonacci = Operation.make({\n meta: {\n key: DXN.make('org.example.function.fib'),\n name: 'Fibonacci',\n description: 'Function that calculates a Fibonacci number',\n },\n input: Schema.Struct({\n iterations: Schema.optional(Schema.Number).annotations({\n description: 'Number of iterations',\n default: 100_000,\n }),\n }),\n output: Schema.Struct({\n result: Schema.String,\n }),\n});\n\nexport const Reply = Operation.make({\n meta: {\n key: DXN.make('org.example.function.reply'),\n name: 'Reply',\n description: 'Function that echoes the input',\n },\n input: Schema.Any,\n output: Schema.Any,\n});\n\nexport const Sleep = Operation.make({\n meta: {\n key: DXN.make('org.example.function.sleep'),\n name: 'Sleep',\n description: 'Function that sleeps for a given amount of time',\n },\n input: Schema.Struct({\n duration: Schema.optional(Schema.Number).annotations({\n description: 'Milliseconds to sleep',\n default: 100_000,\n }),\n }),\n output: Schema.Void,\n});\n"],
|
|
5
|
+
"mappings": ";;;;;AAIA,YAAYA,YAAY;AAExB,SAASC,WAAW;AAIb,IAAMC,YAAsBC,KAAK;EACtCC,MAAM;IACJC,KAAKC,IAAIH,KAAK,0BAAA;IACdI,MAAM;IACNC,aAAa;EACf;EACAC,OAAcC,cAAO;IACnBC,YAAmBC,gBAAgBC,aAAM,EAAEC,YAAY;MACrDN,aAAa;MACbO,SAAS;IACX,CAAA;EACF,CAAA;EACAC,QAAeN,cAAO;IACpBO,QAAeC;EACjB,CAAA;AACF,CAAA;AAEO,IAAMC,QAAkBhB,KAAK;EAClCC,MAAM;IACJC,KAAKC,IAAIH,KAAK,4BAAA;IACdI,MAAM;IACNC,aAAa;EACf;EACAC,OAAcW;EACdJ,QAAeI;AACjB,CAAA;AAEO,IAAMC,QAAkBlB,KAAK;EAClCC,MAAM;IACJC,KAAKC,IAAIH,KAAK,4BAAA;IACdI,MAAM;IACNC,aAAa;EACf;EACAC,OAAcC,cAAO;IACnBY,UAAiBV,gBAAgBC,aAAM,EAAEC,YAAY;MACnDN,aAAa;MACbO,SAAS;IACX,CAAA;EACF,CAAA;EACAC,QAAeO;AACjB,CAAA;",
|
|
6
|
+
"names": ["Schema", "DXN", "Fibonacci", "make", "meta", "key", "DXN", "name", "description", "input", "Struct", "iterations", "optional", "Number", "annotations", "default", "output", "result", "String", "Reply", "Any", "Sleep", "duration", "Void"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Reply
|
|
3
|
+
} from "./chunk-JAU4E4EK.mjs";
|
|
4
|
+
import {
|
|
5
|
+
withHandler
|
|
6
|
+
} from "./chunk-QZS4G6PE.mjs";
|
|
7
|
+
|
|
8
|
+
// src/testing/reply.ts
|
|
9
|
+
import * as Console from "effect/Console";
|
|
10
|
+
import * as Effect from "effect/Effect";
|
|
11
|
+
var reply_default = Reply.pipe(withHandler(Effect.fn(function* (input) {
|
|
12
|
+
yield* Console.log("reply", {
|
|
13
|
+
input
|
|
14
|
+
});
|
|
15
|
+
return input;
|
|
16
|
+
})));
|
|
17
|
+
|
|
18
|
+
export {
|
|
19
|
+
reply_default
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=chunk-MEPE4HHX.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/testing/reply.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Console from 'effect/Console';\nimport * as Effect from 'effect/Effect';\n\nimport * as Operation from '../Operation';\nimport { Reply } from './definitions';\n\nexport default Reply.pipe(\n Operation.withHandler(\n Effect.fn(function* (input) {\n yield* Console.log('reply', { input });\n return input;\n }),\n ),\n);\n"],
|
|
5
|
+
"mappings": ";;;;;;;;AAIA,YAAYA,aAAa;AACzB,YAAYC,YAAY;AAKxB,IAAA,gBAAeC,MAAMC,KACTC,YACDC,UAAG,WAAWC,OAAK;AACxB,SAAeC,YAAI,SAAS;IAAED;EAAM,CAAA;AACpC,SAAOA;AACT,CAAA,CAAA,CAAA;",
|
|
6
|
+
"names": ["Console", "Effect", "Reply", "pipe", "withHandler", "fn", "input", "log"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__export
|
|
3
|
+
} from "./chunk-J5LGTIGS.mjs";
|
|
4
|
+
|
|
5
|
+
// src/Operation.ts
|
|
6
|
+
var Operation_exports = {};
|
|
7
|
+
__export(Operation_exports, {
|
|
8
|
+
DefinitionTypeId: () => DefinitionTypeId,
|
|
9
|
+
IdempotentAnnotation: () => IdempotentAnnotation,
|
|
10
|
+
PersistentOperation: () => PersistentOperation,
|
|
11
|
+
PersistentOperation_v0_1_0: () => PersistentOperation_v0_1_0,
|
|
12
|
+
Service: () => Service,
|
|
13
|
+
deserialize: () => deserialize,
|
|
14
|
+
getKey: () => getKey,
|
|
15
|
+
getVersion: () => getVersion,
|
|
16
|
+
invoke: () => invoke,
|
|
17
|
+
isIdempotent: () => isIdempotent,
|
|
18
|
+
isOperationDefinition: () => isOperationDefinition,
|
|
19
|
+
isOperationWithHandler: () => isOperationWithHandler,
|
|
20
|
+
make: () => make,
|
|
21
|
+
migrations: () => migrations,
|
|
22
|
+
opaqueHandler: () => opaqueHandler,
|
|
23
|
+
schedule: () => schedule,
|
|
24
|
+
serialize: () => serialize,
|
|
25
|
+
setFrom: () => setFrom,
|
|
26
|
+
withHandler: () => withHandler,
|
|
27
|
+
withInvocationOptions: () => withInvocationOptions
|
|
28
|
+
});
|
|
29
|
+
import * as Context from "effect/Context";
|
|
30
|
+
import * as Effect from "effect/Effect";
|
|
31
|
+
import * as Layer from "effect/Layer";
|
|
32
|
+
import * as Option from "effect/Option";
|
|
33
|
+
import * as Pipeable from "effect/Pipeable";
|
|
34
|
+
import * as Schema$ from "effect/Schema";
|
|
35
|
+
import { DXN, Annotation, JsonSchema, Migration, Obj, Ref, Type } from "@dxos/echo";
|
|
36
|
+
var DefinitionTypeId = "~@dxos/operation/OperationDefinition";
|
|
37
|
+
var isOperationDefinition = (value) => {
|
|
38
|
+
return typeof value === "object" && value !== null && DefinitionTypeId in value;
|
|
39
|
+
};
|
|
40
|
+
var isOperationWithHandler = (value) => {
|
|
41
|
+
return isOperationDefinition(value) && "handler" in value;
|
|
42
|
+
};
|
|
43
|
+
var make = (props) => {
|
|
44
|
+
return {
|
|
45
|
+
[DefinitionTypeId]: {},
|
|
46
|
+
...props,
|
|
47
|
+
executionMode: props.executionMode ?? "async",
|
|
48
|
+
types: props.types ?? [],
|
|
49
|
+
services: props.services ?? [],
|
|
50
|
+
pipe() {
|
|
51
|
+
return Pipeable.pipeArguments(this, arguments);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
var withHandler = (opOrHandler, handler) => {
|
|
56
|
+
if (handler === void 0) {
|
|
57
|
+
const handlerFn = opOrHandler;
|
|
58
|
+
return (op2) => ({
|
|
59
|
+
...op2,
|
|
60
|
+
handler: handlerFn
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
const op = opOrHandler;
|
|
64
|
+
return {
|
|
65
|
+
...op,
|
|
66
|
+
handler
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
var opaqueHandler = (handler) => handler;
|
|
70
|
+
var PersistentOperation = Schema$.Struct({
|
|
71
|
+
name: Schema$.NonEmptyString,
|
|
72
|
+
description: Schema$.optional(Schema$.String),
|
|
73
|
+
/**
|
|
74
|
+
* ISO date string of the last deployment.
|
|
75
|
+
*/
|
|
76
|
+
updated: Schema$.optional(Schema$.String),
|
|
77
|
+
// Reference to a source script if it exists within ECHO.
|
|
78
|
+
// TODO(burdon): Don't ref ScriptType directly (core).
|
|
79
|
+
source: Schema$.optional(Ref.Ref(Obj.Unknown)),
|
|
80
|
+
inputSchema: Schema$.optional(JsonSchema.JsonSchema),
|
|
81
|
+
outputSchema: Schema$.optional(JsonSchema.JsonSchema),
|
|
82
|
+
/**
|
|
83
|
+
* List of required services.
|
|
84
|
+
* Match the Context.Tag keys of the FunctionServices variants.
|
|
85
|
+
*/
|
|
86
|
+
services: Schema$.optional(Schema$.Array(Schema$.String)),
|
|
87
|
+
// Local binding to a function name.
|
|
88
|
+
// TODO(dmaretskyi): Add this field to Operation.Definition.
|
|
89
|
+
binding: Schema$.optional(Schema$.String),
|
|
90
|
+
/**
|
|
91
|
+
* Phosphor icon identifier in `ph--<name>--<variant>` format (e.g. `ph--file-text--regular`).
|
|
92
|
+
*/
|
|
93
|
+
icon: Schema$.optional(Schema$.String)
|
|
94
|
+
}).pipe(
|
|
95
|
+
Annotation.LabelAnnotation.set([
|
|
96
|
+
"name"
|
|
97
|
+
]),
|
|
98
|
+
Annotation.IconAnnotation.set({
|
|
99
|
+
icon: "ph--function--regular",
|
|
100
|
+
hue: "blue"
|
|
101
|
+
}),
|
|
102
|
+
Annotation.HiddenAnnotation.set(true),
|
|
103
|
+
// TODO(dmaretskyi): Keep typename as 'org.dxos.type.function' (not 'operation') to maintain
|
|
104
|
+
// backward compatibility with existing data and avoid requiring data migration.
|
|
105
|
+
Type.makeObject(DXN.make("org.dxos.type.function", "0.2.0"))
|
|
106
|
+
);
|
|
107
|
+
var FUNCTION_META_KEY = "org.dxos.service.function";
|
|
108
|
+
var getKey = (record) => Obj.getMeta(record).key;
|
|
109
|
+
var getVersion = (record) => Obj.getMeta(record).version;
|
|
110
|
+
var serialize = (operation) => {
|
|
111
|
+
return Obj.make(PersistentOperation, {
|
|
112
|
+
[Obj.Meta]: {
|
|
113
|
+
key: operation.meta.key,
|
|
114
|
+
version: operation.meta.version ?? "0.0.0",
|
|
115
|
+
keys: operation.meta.deployedId ? [
|
|
116
|
+
{
|
|
117
|
+
source: FUNCTION_META_KEY,
|
|
118
|
+
id: operation.meta.deployedId
|
|
119
|
+
}
|
|
120
|
+
] : [],
|
|
121
|
+
annotations: operation.meta.annotations
|
|
122
|
+
},
|
|
123
|
+
name: operation.meta.name ?? "",
|
|
124
|
+
description: operation.meta.description,
|
|
125
|
+
icon: operation.meta.icon,
|
|
126
|
+
updated: void 0,
|
|
127
|
+
source: void 0,
|
|
128
|
+
inputSchema: JsonSchema.toJsonSchema(operation.input),
|
|
129
|
+
outputSchema: JsonSchema.toJsonSchema(operation.output),
|
|
130
|
+
services: operation.services.map((service) => service.key)
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
var deserialize = (record) => {
|
|
134
|
+
const meta = Obj.getMeta(record);
|
|
135
|
+
const deployedId = meta.keys.find((key) => key.source === FUNCTION_META_KEY)?.id;
|
|
136
|
+
return make({
|
|
137
|
+
input: record.inputSchema ? JsonSchema.toEffectSchema(record.inputSchema) : Schema$.Unknown,
|
|
138
|
+
output: record.outputSchema ? JsonSchema.toEffectSchema(record.outputSchema) : Schema$.Unknown,
|
|
139
|
+
services: record.services?.map((service) => Context.GenericTag(service)) ?? [],
|
|
140
|
+
executionMode: "async",
|
|
141
|
+
types: [],
|
|
142
|
+
meta: {
|
|
143
|
+
key: DXN.tryMake(meta.key ?? record.name) ?? DXN.make(meta.key ?? record.name),
|
|
144
|
+
name: record.name,
|
|
145
|
+
version: meta.version ?? "0.0.0",
|
|
146
|
+
description: record.description,
|
|
147
|
+
icon: record.icon,
|
|
148
|
+
deployedId,
|
|
149
|
+
annotations: meta.annotations ?? {}
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
var setFrom = (target, source) => {
|
|
154
|
+
Obj.update(target, (target2) => {
|
|
155
|
+
target2.name = source.name ?? target2.name;
|
|
156
|
+
target2.description = source.description;
|
|
157
|
+
target2.icon = source.icon;
|
|
158
|
+
target2.updated = source.updated;
|
|
159
|
+
target2.inputSchema = source.inputSchema ? JSON.parse(JSON.stringify(source.inputSchema)) : void 0;
|
|
160
|
+
target2.outputSchema = source.outputSchema ? JSON.parse(JSON.stringify(source.outputSchema)) : void 0;
|
|
161
|
+
const sourceMeta = Obj.getMeta(source);
|
|
162
|
+
const targetMeta = Obj.getMeta(target2);
|
|
163
|
+
targetMeta.key = sourceMeta.key ?? targetMeta.key;
|
|
164
|
+
targetMeta.version = sourceMeta.version;
|
|
165
|
+
if (sourceMeta.keys.length > 0) {
|
|
166
|
+
targetMeta.keys = JSON.parse(JSON.stringify(sourceMeta.keys));
|
|
167
|
+
}
|
|
168
|
+
targetMeta.annotations = sourceMeta.annotations ?? targetMeta.annotations;
|
|
169
|
+
});
|
|
170
|
+
};
|
|
171
|
+
var IdempotentAnnotation = Annotation.make({
|
|
172
|
+
id: "org.dxos.operation.idempotent",
|
|
173
|
+
schema: Schema$.Boolean
|
|
174
|
+
});
|
|
175
|
+
var isIdempotent = (op) => op.meta.annotations ? Option.getOrElse(Annotation.getDictionary(op.meta.annotations, IdempotentAnnotation), () => false) : false;
|
|
176
|
+
var Service = class extends Context.Tag("@dxos/operation/Service")() {
|
|
177
|
+
};
|
|
178
|
+
var invoke = (op, ...args) => Effect.flatMap(Service, (ops) => ops.invoke(op, ...args)).pipe(Effect.withSpan("Operation.invoke"));
|
|
179
|
+
var schedule = (op, ...args) => Effect.flatMap(Service, (ops) => ops.schedule(op, ...args)).pipe(Effect.withSpan("Operation.schedule"));
|
|
180
|
+
var withInvocationOptions = (options) => Layer.effect(Service, Effect.gen(function* () {
|
|
181
|
+
const service = yield* Service;
|
|
182
|
+
return Service.of({
|
|
183
|
+
invoke: (op, input, invocationOptions) => service.invoke(op, input, {
|
|
184
|
+
...options,
|
|
185
|
+
...invocationOptions
|
|
186
|
+
}),
|
|
187
|
+
invokePromise: (op, input, invocationOptions) => service.invokePromise(op, input, {
|
|
188
|
+
...options,
|
|
189
|
+
...invocationOptions
|
|
190
|
+
}),
|
|
191
|
+
schedule: (op, input, invocationOptions) => service.schedule(op, input, {
|
|
192
|
+
...options,
|
|
193
|
+
...invocationOptions
|
|
194
|
+
})
|
|
195
|
+
});
|
|
196
|
+
}));
|
|
197
|
+
var PersistentOperation_v0_1_0 = Schema$.Struct({
|
|
198
|
+
key: Schema$.optional(Schema$.String),
|
|
199
|
+
name: Schema$.NonEmptyString,
|
|
200
|
+
version: Schema$.String,
|
|
201
|
+
description: Schema$.optional(Schema$.String),
|
|
202
|
+
updated: Schema$.optional(Schema$.String),
|
|
203
|
+
source: Schema$.optional(Ref.Ref(Obj.Unknown)),
|
|
204
|
+
inputSchema: Schema$.optional(JsonSchema.JsonSchema),
|
|
205
|
+
outputSchema: Schema$.optional(JsonSchema.JsonSchema),
|
|
206
|
+
services: Schema$.optional(Schema$.Array(Schema$.String)),
|
|
207
|
+
binding: Schema$.optional(Schema$.String)
|
|
208
|
+
}).pipe(Type.makeObject(DXN.make("org.dxos.type.function", "0.1.0")));
|
|
209
|
+
var _migration = Migration.define({
|
|
210
|
+
from: PersistentOperation_v0_1_0,
|
|
211
|
+
to: PersistentOperation,
|
|
212
|
+
transform: async (from) => ({
|
|
213
|
+
[Obj.Meta]: {
|
|
214
|
+
key: from.key,
|
|
215
|
+
version: from.version
|
|
216
|
+
},
|
|
217
|
+
name: from.name,
|
|
218
|
+
description: from.description,
|
|
219
|
+
updated: from.updated,
|
|
220
|
+
source: from.source,
|
|
221
|
+
inputSchema: from.inputSchema,
|
|
222
|
+
outputSchema: from.outputSchema,
|
|
223
|
+
services: from.services,
|
|
224
|
+
binding: from.binding
|
|
225
|
+
})
|
|
226
|
+
});
|
|
227
|
+
var migrations = [
|
|
228
|
+
_migration
|
|
229
|
+
];
|
|
230
|
+
|
|
231
|
+
export {
|
|
232
|
+
make,
|
|
233
|
+
withHandler,
|
|
234
|
+
PersistentOperation,
|
|
235
|
+
deserialize,
|
|
236
|
+
isIdempotent,
|
|
237
|
+
invoke,
|
|
238
|
+
Operation_exports
|
|
239
|
+
};
|
|
240
|
+
//# sourceMappingURL=chunk-QZS4G6PE.mjs.map
|