@dxos/functions 0.8.4-main.72ec0f3 → 0.8.4-main.7996785055
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/README.md +4 -6
- package/dist/lib/neutral/chunk-GEM2K7BA.mjs +56 -0
- package/dist/lib/neutral/chunk-GEM2K7BA.mjs.map +7 -0
- package/dist/lib/neutral/fib-XBUKWUUS.mjs +22 -0
- package/dist/lib/neutral/fib-XBUKWUUS.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +960 -0
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/reply-XBQTXDLZ.mjs +18 -0
- package/dist/lib/neutral/reply-XBQTXDLZ.mjs.map +7 -0
- package/dist/lib/neutral/sleep-TLQKHAK2.mjs +14 -0
- package/dist/lib/neutral/sleep-TLQKHAK2.mjs.map +7 -0
- package/dist/types/src/errors.d.ts +24 -32
- package/dist/types/src/errors.d.ts.map +1 -1
- package/dist/types/src/example/definitions.d.ts +11 -0
- package/dist/types/src/example/definitions.d.ts.map +1 -0
- package/dist/types/src/example/fib.d.ts +3 -2
- package/dist/types/src/example/fib.d.ts.map +1 -1
- package/dist/types/src/example/index.d.ts +3 -11
- package/dist/types/src/example/index.d.ts.map +1 -1
- package/dist/types/src/example/reply.d.ts +2 -1
- package/dist/types/src/example/reply.d.ts.map +1 -1
- package/dist/types/src/example/sleep.d.ts +3 -2
- package/dist/types/src/example/sleep.d.ts.map +1 -1
- package/dist/types/src/protocol/functions-ai-http-client.d.ts +12 -0
- package/dist/types/src/protocol/functions-ai-http-client.d.ts.map +1 -0
- package/dist/types/src/protocol/protocol.d.ts +2 -2
- package/dist/types/src/protocol/protocol.d.ts.map +1 -1
- package/dist/types/src/sdk.d.ts +2 -79
- package/dist/types/src/sdk.d.ts.map +1 -1
- package/dist/types/src/services/credentials.d.ts +6 -4
- package/dist/types/src/services/credentials.d.ts.map +1 -1
- package/dist/types/src/services/event-logger.d.ts +25 -31
- package/dist/types/src/services/event-logger.d.ts.map +1 -1
- package/dist/types/src/services/function-invocation-service.d.ts +9 -3
- package/dist/types/src/services/function-invocation-service.d.ts.map +1 -1
- package/dist/types/src/services/index.d.ts +0 -1
- package/dist/types/src/services/index.d.ts.map +1 -1
- package/dist/types/src/services/queues.d.ts +4 -4
- package/dist/types/src/services/queues.d.ts.map +1 -1
- package/dist/types/src/services/tracing.d.ts +38 -3
- package/dist/types/src/services/tracing.d.ts.map +1 -1
- package/dist/types/src/types/Script.d.ts +9 -16
- package/dist/types/src/types/Script.d.ts.map +1 -1
- package/dist/types/src/types/Trigger.d.ts +57 -76
- package/dist/types/src/types/Trigger.d.ts.map +1 -1
- package/dist/types/src/types/TriggerEvent.d.ts +44 -13
- package/dist/types/src/types/TriggerEvent.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +0 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/url.d.ts +6 -5
- package/dist/types/src/types/url.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +23 -17
- package/src/errors.ts +4 -4
- package/src/example/definitions.ts +48 -0
- package/src/example/fib.ts +14 -24
- package/src/example/forex-effect.ts +1 -1
- package/src/example/index.ts +7 -8
- package/src/example/reply.ts +10 -13
- package/src/example/sleep.ts +8 -17
- package/src/protocol/functions-ai-http-client.ts +67 -0
- package/src/protocol/protocol.ts +196 -84
- package/src/sdk.ts +4 -194
- package/src/services/credentials.ts +31 -15
- package/src/services/event-logger.ts +2 -2
- package/src/services/function-invocation-service.ts +18 -3
- package/src/services/index.ts +0 -2
- package/src/services/queues.ts +5 -7
- package/src/services/tracing.ts +64 -4
- package/src/types/Script.ts +13 -8
- package/src/types/Trigger.ts +31 -17
- package/src/types/TriggerEvent.ts +29 -29
- package/src/types/index.ts +0 -1
- package/src/types/url.ts +6 -5
- package/dist/lib/browser/index.mjs +0 -927
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/node-esm/index.mjs +0 -928
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/types/src/types/Function.d.ts +0 -58
- package/dist/types/src/types/Function.d.ts.map +0 -1
- package/src/types/Function.ts +0 -62
package/README.md
CHANGED
|
@@ -27,11 +27,9 @@ import { FunctionContext } from '@dxos/functions';
|
|
|
27
27
|
|
|
28
28
|
export default (event: any, context: FunctionContext) => {
|
|
29
29
|
const identity = context.client.halo.identity.get();
|
|
30
|
-
return context
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
message: `Hello ${identity?.profile?.displayName}`
|
|
34
|
-
});
|
|
30
|
+
return context.status(200).succeed({
|
|
31
|
+
message: `Hello ${identity?.profile?.displayName}`,
|
|
32
|
+
});
|
|
35
33
|
};
|
|
36
34
|
```
|
|
37
35
|
|
|
@@ -69,7 +67,7 @@ nodemon -w ./src -e ts --exec $(git rev-parse --show-toplevel)/packages/devtools
|
|
|
69
67
|
> NOTE: The port (7001) must match the one in config.
|
|
70
68
|
|
|
71
69
|
```bash
|
|
72
|
-
curl http://localhost:7001/dev/hello -X POST -H 'Content-Type: application/json' -w '\n' --data '{ "message": "Hello World!" }'
|
|
70
|
+
curl http://localhost:7001/dev/hello -X POST -H 'Content-Type: application/json' -w '\n' --data '{ "message": "Hello World!" }'
|
|
73
71
|
```
|
|
74
72
|
|
|
75
73
|
## DXOS Resources
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __export = (target, all) => {
|
|
3
|
+
for (var name in all)
|
|
4
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
// src/example/definitions.ts
|
|
8
|
+
import { Operation } from "@dxos/operation";
|
|
9
|
+
import * as Schema from "effect/Schema";
|
|
10
|
+
var Fibonacci = Operation.make({
|
|
11
|
+
meta: {
|
|
12
|
+
key: "example.org/function/fib",
|
|
13
|
+
name: "Fibonacci",
|
|
14
|
+
description: "Function that calculates a Fibonacci number"
|
|
15
|
+
},
|
|
16
|
+
input: Schema.Struct({
|
|
17
|
+
iterations: Schema.optional(Schema.Number).annotations({
|
|
18
|
+
description: "Number of iterations",
|
|
19
|
+
default: 1e5
|
|
20
|
+
})
|
|
21
|
+
}),
|
|
22
|
+
output: Schema.Struct({
|
|
23
|
+
result: Schema.String
|
|
24
|
+
})
|
|
25
|
+
});
|
|
26
|
+
var Reply = Operation.make({
|
|
27
|
+
meta: {
|
|
28
|
+
key: "example.org/function/reply",
|
|
29
|
+
name: "Reply",
|
|
30
|
+
description: "Function that echoes the input"
|
|
31
|
+
},
|
|
32
|
+
input: Schema.Any,
|
|
33
|
+
output: Schema.Any
|
|
34
|
+
});
|
|
35
|
+
var Sleep = Operation.make({
|
|
36
|
+
meta: {
|
|
37
|
+
key: "example.org/function/sleep",
|
|
38
|
+
name: "Sleep",
|
|
39
|
+
description: "Function that sleeps for a given amount of time"
|
|
40
|
+
},
|
|
41
|
+
input: Schema.Struct({
|
|
42
|
+
duration: Schema.optional(Schema.Number).annotations({
|
|
43
|
+
description: "Milliseconds to sleep",
|
|
44
|
+
default: 1e5
|
|
45
|
+
})
|
|
46
|
+
}),
|
|
47
|
+
output: Schema.Void
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
export {
|
|
51
|
+
__export,
|
|
52
|
+
Fibonacci,
|
|
53
|
+
Reply,
|
|
54
|
+
Sleep
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=chunk-GEM2K7BA.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/example/definitions.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2026 DXOS.org\n//\n\nimport { Operation } from '@dxos/operation';\nimport * as Schema from 'effect/Schema';\n\nexport const Fibonacci = Operation.make({\n meta: {\n key: 'example.org/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: 'example.org/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: 'example.org/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,SAASA,iBAAiB;AAC1B,YAAYC,YAAY;AAEjB,IAAMC,YAAYC,UAAUC,KAAK;EACtCC,MAAM;IACJC,KAAK;IACLC,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,QAAQhB,UAAUC,KAAK;EAClCC,MAAM;IACJC,KAAK;IACLC,MAAM;IACNC,aAAa;EACf;EACAC,OAAcW;EACdJ,QAAeI;AACjB,CAAA;AAEO,IAAMC,QAAQlB,UAAUC,KAAK;EAClCC,MAAM;IACJC,KAAK;IACLC,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": ["Operation", "Schema", "Fibonacci", "Operation", "make", "meta", "key", "name", "description", "input", "Struct", "iterations", "optional", "Number", "annotations", "default", "output", "result", "String", "Reply", "Any", "Sleep", "duration", "Void"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Fibonacci
|
|
3
|
+
} from "./chunk-GEM2K7BA.mjs";
|
|
4
|
+
|
|
5
|
+
// src/example/fib.ts
|
|
6
|
+
import * as Effect from "effect/Effect";
|
|
7
|
+
import { Operation } from "@dxos/operation";
|
|
8
|
+
var fib_default = Fibonacci.pipe(Operation.withHandler(Effect.fn(function* ({ iterations = 1e5 }) {
|
|
9
|
+
let a = 0n;
|
|
10
|
+
let b = 1n;
|
|
11
|
+
for (let i = 0; i < iterations; i++) {
|
|
12
|
+
a += b;
|
|
13
|
+
b = a - b;
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
result: a.toString()
|
|
17
|
+
};
|
|
18
|
+
})));
|
|
19
|
+
export {
|
|
20
|
+
fib_default as default
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=fib-XBUKWUUS.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/example/fib.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { Operation } from '@dxos/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;AAExB,SAASC,iBAAiB;AAG1B,IAAA,cAAeC,UAAUC,KACvBC,UAAUC,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", "Operation", "Fibonacci", "pipe", "Operation", "withHandler", "fn", "iterations", "a", "b", "i", "result", "toString"]
|
|
7
|
+
}
|