@dxos/functions 0.8.4-main.bc674ce → 0.8.4-main.bcb3aa67d6
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/Trace.mjs +34 -0
- package/dist/lib/neutral/Trace.mjs.map +7 -0
- package/dist/lib/neutral/chunk-BHLSCAA2.mjs +123 -0
- package/dist/lib/neutral/chunk-BHLSCAA2.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-Z2XDJJVH.mjs +49 -0
- package/dist/lib/neutral/chunk-Z2XDJJVH.mjs.map +7 -0
- package/dist/lib/neutral/fib-S6PPI4UW.mjs +23 -0
- package/dist/lib/neutral/fib-S6PPI4UW.mjs.map +7 -0
- package/dist/lib/{browser → neutral}/index.mjs +649 -633
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/reply-TOHXEG7V.mjs +19 -0
- package/dist/lib/neutral/reply-TOHXEG7V.mjs.map +7 -0
- package/dist/lib/neutral/sleep-QPSZDPEH.mjs +15 -0
- package/dist/lib/neutral/sleep-QPSZDPEH.mjs.map +7 -0
- package/dist/types/src/Trace.d.ts +135 -0
- package/dist/types/src/Trace.d.ts.map +1 -0
- 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/index.d.ts +4 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/process/Process.d.ts +247 -0
- package/dist/types/src/process/Process.d.ts.map +1 -0
- package/dist/types/src/process/ServiceResolver.d.ts +74 -0
- package/dist/types/src/process/ServiceResolver.d.ts.map +1 -0
- package/dist/types/src/process/StorageService.d.ts +58 -0
- package/dist/types/src/process/StorageService.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 +4 -104
- package/dist/types/src/sdk.d.ts.map +1 -1
- package/dist/types/src/services/event-logger.d.ts +4 -4
- package/dist/types/src/services/function-invocation-service.d.ts +6 -5
- package/dist/types/src/services/function-invocation-service.d.ts.map +1 -1
- package/dist/types/src/services/queues.d.ts +4 -2
- package/dist/types/src/services/queues.d.ts.map +1 -1
- package/dist/types/src/services/tracing.d.ts +25 -2
- package/dist/types/src/services/tracing.d.ts.map +1 -1
- package/dist/types/src/types/Script.d.ts +4 -3
- package/dist/types/src/types/Script.d.ts.map +1 -1
- package/dist/types/src/types/Trigger.d.ts +8 -9
- package/dist/types/src/types/Trigger.d.ts.map +1 -1
- package/dist/types/src/types/TriggerEvent.d.ts +3 -2
- 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 +2 -2
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +25 -20
- package/src/Trace.ts +162 -0
- package/src/errors.ts +1 -1
- 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/index.ts +4 -0
- package/src/process/Process.ts +457 -0
- package/src/process/ServiceResolver.ts +173 -0
- package/src/process/StorageService.ts +99 -0
- package/src/protocol/protocol.ts +33 -27
- package/src/sdk.ts +6 -256
- package/src/services/event-logger.ts +1 -1
- package/src/services/function-invocation-service.ts +6 -5
- package/src/services/queues.ts +10 -2
- package/src/services/tracing.ts +35 -2
- package/src/types/Script.ts +7 -3
- package/src/types/Trigger.ts +17 -6
- package/src/types/TriggerEvent.ts +2 -2
- package/src/types/index.ts +0 -1
- package/src/types/url.ts +2 -2
- 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 -1230
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/types/src/operation-compatibility.test.d.ts +0 -2
- package/dist/types/src/operation-compatibility.test.d.ts.map +0 -1
- package/dist/types/src/types/Function.d.ts +0 -52
- package/dist/types/src/types/Function.d.ts.map +0 -1
- package/src/operation-compatibility.test.ts +0 -185
- package/src/types/Function.ts +0 -82
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}, {
|
|
5
|
-
readonly result: string;
|
|
6
|
-
}, import("..").FunctionServices>;
|
|
7
|
-
const reply: import("..").FunctionDefinition<any, any, import("..").FunctionServices>;
|
|
8
|
-
const sleep: import("..").FunctionDefinition<{
|
|
9
|
-
readonly duration?: number | undefined;
|
|
10
|
-
}, void, import("..").FunctionServices>;
|
|
11
|
-
}
|
|
1
|
+
import { OperationHandlerSet } from '@dxos/operation';
|
|
2
|
+
export * from './definitions';
|
|
3
|
+
export declare const ExampleHandlers: OperationHandlerSet.OperationHandlerSet;
|
|
12
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/example/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/example/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,cAAc,eAAe,CAAC;AAE9B,eAAO,MAAM,eAAe,yCAI3B,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { Operation } from '@dxos/operation';
|
|
2
|
+
declare const _default: Operation.WithHandler<Operation.Definition<any, any, never>>;
|
|
2
3
|
export default _default;
|
|
3
4
|
//# sourceMappingURL=reply.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reply.d.ts","sourceRoot":"","sources":["../../../../src/example/reply.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"reply.d.ts","sourceRoot":"","sources":["../../../../src/example/reply.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;;AAG5C,wBAOE"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { Operation } from '@dxos/operation';
|
|
2
|
+
declare const _default: Operation.WithHandler<Operation.Definition<{
|
|
2
3
|
readonly duration?: number | undefined;
|
|
3
|
-
}, void,
|
|
4
|
+
}, void, never>>;
|
|
4
5
|
export default _default;
|
|
5
6
|
//# sourceMappingURL=sleep.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sleep.d.ts","sourceRoot":"","sources":["../../../../src/example/sleep.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sleep.d.ts","sourceRoot":"","sources":["../../../../src/example/sleep.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;;;;AAE5C,wBAME"}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
export * from './errors';
|
|
2
2
|
export * from './example';
|
|
3
|
+
export * as Process from './process/Process';
|
|
4
|
+
export * as ServiceResolver from './process/ServiceResolver';
|
|
5
|
+
export * from './process/StorageService';
|
|
3
6
|
export * from './sdk';
|
|
4
7
|
export * from './services';
|
|
5
8
|
export * from './types';
|
|
6
9
|
export * from './protocol';
|
|
10
|
+
export * as Trace from './Trace';
|
|
7
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,OAAO,KAAK,OAAO,MAAM,mBAAmB,CAAC;AAC7C,OAAO,KAAK,eAAe,MAAM,2BAA2B,CAAC;AAC7D,cAAc,0BAA0B,CAAC;AACzC,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import * as Scope from 'effect/Scope';
|
|
2
|
+
import * as Effect from 'effect/Effect';
|
|
3
|
+
import * as Schema from 'effect/Schema';
|
|
4
|
+
import type * as Exit from 'effect/Exit';
|
|
5
|
+
import * as Context from 'effect/Context';
|
|
6
|
+
import type * as Types from 'effect/Types';
|
|
7
|
+
import { Operation, OperationHandlerSet } from '@dxos/operation';
|
|
8
|
+
import type { TracingService } from '../services/tracing';
|
|
9
|
+
import * as Option from 'effect/Option';
|
|
10
|
+
import type { Atom } from '@effect-atom/atom';
|
|
11
|
+
import type { ObjectId } from '@dxos/protocols';
|
|
12
|
+
import * as Trace from '../Trace';
|
|
13
|
+
/** Opaque process id (arbitrary string). */
|
|
14
|
+
export declare const ID: Schema.brand<typeof Schema.String, "ProcessId">;
|
|
15
|
+
export type ID = Schema.Schema.Type<typeof ID>;
|
|
16
|
+
/**
|
|
17
|
+
* A running process callbacks.
|
|
18
|
+
*
|
|
19
|
+
* Process lifecycle: Initial -> Running <-> Suspended -> Terminated.
|
|
20
|
+
*
|
|
21
|
+
* - onSpawn -> called once when the process is spawned.
|
|
22
|
+
* - onInput -> called for every input submitted to the process.
|
|
23
|
+
* - onAlarm -> called for processes scheduling alarms.
|
|
24
|
+
* - onChildEvent -> called when child process produces output or exits.
|
|
25
|
+
*/
|
|
26
|
+
export interface Callbacks<I, O, R> {
|
|
27
|
+
/**
|
|
28
|
+
* Called when the process is spawned.
|
|
29
|
+
* Not called for processes that are resumed from a previously suspended state.
|
|
30
|
+
*
|
|
31
|
+
* @returns A signal indicating to the runtime whether the process is finished, or should be resumed later.
|
|
32
|
+
* @throws Throwing in the handler will terminate the process with an error.
|
|
33
|
+
*
|
|
34
|
+
* Note: This function should aim to complete in under 5 seconds to avoid exceeding limits in serverless environments.
|
|
35
|
+
*/
|
|
36
|
+
onSpawn(): Effect.Effect<void, never, R | BaseServices>;
|
|
37
|
+
/**
|
|
38
|
+
* Called when there's input available to process.
|
|
39
|
+
*
|
|
40
|
+
* The function can be called in parallel.
|
|
41
|
+
*
|
|
42
|
+
* @returns A signal indicating to the runtime whether the process is finished, or should be resumed later.
|
|
43
|
+
* @throws Throwing in the handler will terminate the process with an error.
|
|
44
|
+
*
|
|
45
|
+
* Note: This function should aim to complete in under 5 seconds to avoid exceeding limits in serverless environments.
|
|
46
|
+
*/
|
|
47
|
+
onInput(input: I): Effect.Effect<void, never, R | BaseServices>;
|
|
48
|
+
/**
|
|
49
|
+
* Called when the process's alarm is triggered.
|
|
50
|
+
*
|
|
51
|
+
* @throws Throwing in the handler will terminate the process with an error.
|
|
52
|
+
*/
|
|
53
|
+
onAlarm(): Effect.Effect<void, never, R | BaseServices>;
|
|
54
|
+
/**
|
|
55
|
+
* Called when the process's child process produces output or exits.
|
|
56
|
+
*
|
|
57
|
+
* This allows the parent process to hibernate while a long-running child process is running.
|
|
58
|
+
*/
|
|
59
|
+
onChildEvent(event: ChildEvent<unknown>): Effect.Effect<void, never, R | BaseServices>;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Services that are always available to all processes.
|
|
63
|
+
*/
|
|
64
|
+
export type BaseServices = TracingService | Trace.TraceService;
|
|
65
|
+
export type ChildEvent<T> = {
|
|
66
|
+
readonly _tag: 'output';
|
|
67
|
+
readonly pid: ID;
|
|
68
|
+
readonly data: T;
|
|
69
|
+
} | {
|
|
70
|
+
readonly _tag: 'exited';
|
|
71
|
+
readonly pid: ID;
|
|
72
|
+
readonly result: Exit.Exit<void>;
|
|
73
|
+
};
|
|
74
|
+
export interface ProcessContext<I, O> {
|
|
75
|
+
readonly id: ID;
|
|
76
|
+
/**
|
|
77
|
+
* Parameters assigned during process creation.
|
|
78
|
+
*/
|
|
79
|
+
readonly params: Params;
|
|
80
|
+
/**
|
|
81
|
+
* Complete this process with sucessful result.
|
|
82
|
+
* No additional events will be pushed to the process.
|
|
83
|
+
*/
|
|
84
|
+
succeed(): void;
|
|
85
|
+
/**
|
|
86
|
+
* Complete this process with an error.
|
|
87
|
+
* No additional events will be pushed to the process.
|
|
88
|
+
*/
|
|
89
|
+
fail(error: Error): void;
|
|
90
|
+
/**
|
|
91
|
+
* Submit output of the process.
|
|
92
|
+
*/
|
|
93
|
+
submitOutput(output: O): void;
|
|
94
|
+
/**
|
|
95
|
+
* Set an alarm for the process to be woken up later.
|
|
96
|
+
*
|
|
97
|
+
* @param timeout - Optional timeout in milliseconds. If not provided, the process is woken up as soon as possible.
|
|
98
|
+
*/
|
|
99
|
+
setAlarm(timeout?: number): void;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Generic parameters for a all processes.
|
|
103
|
+
*/
|
|
104
|
+
export interface Params {
|
|
105
|
+
/**
|
|
106
|
+
* Process name for debugging purposes.
|
|
107
|
+
*/
|
|
108
|
+
readonly name: string | null;
|
|
109
|
+
/**
|
|
110
|
+
* Target object that this process is assigned to.
|
|
111
|
+
*/
|
|
112
|
+
readonly target: ObjectId | null;
|
|
113
|
+
}
|
|
114
|
+
export declare const ProcessTypeId: "~@dxos/functions/Process";
|
|
115
|
+
export type ProcessTypeId = typeof ProcessTypeId;
|
|
116
|
+
/**
|
|
117
|
+
* A process (factory).
|
|
118
|
+
* Can be instantiated mutlitple times to produce new runtime instance with separate state and callbacks.
|
|
119
|
+
* `create` is used to instantiate a new process.
|
|
120
|
+
* Can store runtime state in scope of `create` function.
|
|
121
|
+
*/
|
|
122
|
+
export interface Process<I, O, R> extends Process.Variance<I, O, R> {
|
|
123
|
+
/**
|
|
124
|
+
* Unique identifier for the executable in the reverse DNS format.
|
|
125
|
+
*/
|
|
126
|
+
readonly key: string;
|
|
127
|
+
/**
|
|
128
|
+
* Human-readable label from {@link MakeExecutableOpts.name} when provided.
|
|
129
|
+
*/
|
|
130
|
+
readonly name?: string;
|
|
131
|
+
readonly services: readonly Context.Tag<any, any>[];
|
|
132
|
+
/**
|
|
133
|
+
* Create a new instance of the process.
|
|
134
|
+
*/
|
|
135
|
+
create(ctx: ProcessContext<I, O>): Effect.Effect<Callbacks<I, O, R>, never, R | BaseServices | Scope.Scope>;
|
|
136
|
+
}
|
|
137
|
+
export declare const isProcess: (executable: unknown) => executable is Process.Any;
|
|
138
|
+
export declare namespace Process {
|
|
139
|
+
interface Variance<I, O, R> {
|
|
140
|
+
readonly [ProcessTypeId]: {
|
|
141
|
+
readonly _Input: Types.Contravariant<I>;
|
|
142
|
+
readonly _Output: Types.Covariant<O>;
|
|
143
|
+
readonly _Requirements: Types.Covariant<R>;
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
type Any = Process<any, any, never>;
|
|
147
|
+
}
|
|
148
|
+
export interface MakeProcessOpts {
|
|
149
|
+
/**
|
|
150
|
+
* Unique identifier for the process in the reverse DNS format.
|
|
151
|
+
*/
|
|
152
|
+
readonly key: string;
|
|
153
|
+
readonly input: Schema.Schema.AnyNoContext;
|
|
154
|
+
readonly output: Schema.Schema.AnyNoContext;
|
|
155
|
+
readonly services: readonly Context.Tag<any, any>[];
|
|
156
|
+
}
|
|
157
|
+
export declare const make: <const Opts extends Types.NoExcessProperties<MakeProcessOpts, Opts>>(opts: Opts, create: (ctx: ProcessContext<Schema.Schema.Type<Opts["input"]>, Schema.Schema.Type<Opts["output"]>>) => Effect.Effect<Partial<Callbacks<Schema.Schema.Type<Opts["input"]>, Schema.Schema.Type<Opts["output"]>, Context.Tag.Identifier<NonNullable<Opts["services"]>[number]>>>, never, Context.Tag.Identifier<NonNullable<Opts["services"]>[number]> | BaseServices | Scope.Scope>) => Process<Schema.Schema.Type<Opts["input"]>, Schema.Schema.Type<Opts["output"]>, Context.Tag.Identifier<NonNullable<Opts["services"]>[number]>>;
|
|
158
|
+
export declare const fromOperation: <const Op extends Operation.Definition.Any>(op: Op, handler: OperationHandlerSet.OperationHandlerSet) => Process<Operation.Definition.Input<Op>, Operation.Definition.Output<Op>, Operation.Definition.Services<Op>>;
|
|
159
|
+
/**
|
|
160
|
+
* Runtime state of a process.
|
|
161
|
+
*/
|
|
162
|
+
export declare enum State {
|
|
163
|
+
RUNNING = "RUNNING",
|
|
164
|
+
HYBERNATING = "HYBERNATING",
|
|
165
|
+
IDLE = "IDLE",
|
|
166
|
+
TERMINATING = "TERMINATING",
|
|
167
|
+
TERMINATED = "TERMINATED",
|
|
168
|
+
SUCCEEDED = "SUCCEEDED",
|
|
169
|
+
FAILED = "FAILED"
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Read-only view of a process tree
|
|
173
|
+
*/
|
|
174
|
+
export interface Monitor {
|
|
175
|
+
/**
|
|
176
|
+
* Get the current state of the process tree.
|
|
177
|
+
*/
|
|
178
|
+
processTree: Effect.Effect<readonly Info[]>;
|
|
179
|
+
/**
|
|
180
|
+
* Atom for the process tree.
|
|
181
|
+
*/
|
|
182
|
+
processTreeAtom: Atom.Atom<readonly Info[]>;
|
|
183
|
+
}
|
|
184
|
+
declare const ProcessMonitorService_base: Context.TagClass<ProcessMonitorService, "@dxos/functions/ProcessMonitorService", Monitor>;
|
|
185
|
+
export declare class ProcessMonitorService extends ProcessMonitorService_base {
|
|
186
|
+
}
|
|
187
|
+
export interface Info {
|
|
188
|
+
readonly pid: ID;
|
|
189
|
+
readonly parentPid: ID | null;
|
|
190
|
+
/**
|
|
191
|
+
* Key of the process.
|
|
192
|
+
*
|
|
193
|
+
* NOTE: There might be multiple running processes with the same key.
|
|
194
|
+
*/
|
|
195
|
+
readonly key: string;
|
|
196
|
+
/**
|
|
197
|
+
* Parameters of the process.
|
|
198
|
+
*/
|
|
199
|
+
readonly params: Params;
|
|
200
|
+
/**
|
|
201
|
+
* State of the process.
|
|
202
|
+
*/
|
|
203
|
+
readonly state: State;
|
|
204
|
+
/**
|
|
205
|
+
* Error of the process.
|
|
206
|
+
* Only for process in FAILED state.
|
|
207
|
+
*/
|
|
208
|
+
readonly error: string | null;
|
|
209
|
+
/**
|
|
210
|
+
* UNIX timestamp in milliseconds.
|
|
211
|
+
*/
|
|
212
|
+
readonly startedAt: number;
|
|
213
|
+
/**
|
|
214
|
+
* UNIX timestamp in milliseconds.
|
|
215
|
+
*/
|
|
216
|
+
readonly completedAt: Option.Option<number>;
|
|
217
|
+
readonly metrics: {
|
|
218
|
+
/**
|
|
219
|
+
* Total wall time of all handler invocations of the process in milliseconds.
|
|
220
|
+
*/
|
|
221
|
+
readonly wallTime: number;
|
|
222
|
+
/**
|
|
223
|
+
* Total number of inputs submitted to the process.
|
|
224
|
+
*/
|
|
225
|
+
readonly inputCount: number;
|
|
226
|
+
/**
|
|
227
|
+
* Total number of outputs submitted to the process.
|
|
228
|
+
*/
|
|
229
|
+
readonly outputCount: number;
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* New process is spawned.
|
|
234
|
+
*/
|
|
235
|
+
export declare const SpawnedEvent: Trace.EventType<void>;
|
|
236
|
+
/**
|
|
237
|
+
* Process has reached a terminal state.
|
|
238
|
+
*/
|
|
239
|
+
export declare const ExitedEvent: Trace.EventType<{
|
|
240
|
+
readonly outcome: "succeeded" | "failed" | "terminated";
|
|
241
|
+
}>;
|
|
242
|
+
/**
|
|
243
|
+
* Renders spawned processes as a forest: top-level rows use "- ", nested rows use ├── / └── / │.
|
|
244
|
+
*/
|
|
245
|
+
export declare const prettyProcessTree: (tree: readonly Info[]) => string;
|
|
246
|
+
export {};
|
|
247
|
+
//# sourceMappingURL=Process.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Process.d.ts","sourceRoot":"","sources":["../../../../src/process/Process.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,IAAI,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,KAAK,KAAK,MAAM,UAAU,CAAC;AAMlC,4CAA4C;AAC5C,eAAO,MAAM,EAAE,iDAAgD,CAAC;AAChE,MAAM,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;AAE/C;;;;;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,CAAC;CAC7C;;AAED,qBAAa,qBAAsB,SAAQ,0BAGxC;CAAG;AAEN,MAAM,WAAW,IAAI;IACnB,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC;IACjB,QAAQ,CAAC,SAAS,EAAE,EAAE,GAAG,IAAI,CAAC;IAE9B;;;;OAIG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IAEtB;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAE9B;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAE5C,QAAQ,CAAC,OAAO,EAAE;QAChB;;WAEG;QACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAE1B;;WAEG;QACH,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;QAE5B;;WAEG;QACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;KAC9B,CAAC;CACH;AAED;;GAEG;AACH,eAAO,MAAM,YAAY,uBAGvB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,WAAW;;EAKtB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAAI,MAAM,SAAS,IAAI,EAAE,KAAG,MA+DzD,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import * as Context from 'effect/Context';
|
|
2
|
+
import * as Effect from 'effect/Effect';
|
|
3
|
+
import * as Layer from 'effect/Layer';
|
|
4
|
+
import type { DXN, SpaceId } from '@dxos/keys';
|
|
5
|
+
import { ServiceNotAvailableError } from '../errors';
|
|
6
|
+
import * as Process from './Process';
|
|
7
|
+
import * as Scope from 'effect/Scope';
|
|
8
|
+
declare const ServiceResolverTypeId: "~@dxos/functions/ServiceResolver";
|
|
9
|
+
type ServiceResolverTypeId = typeof ServiceResolverTypeId;
|
|
10
|
+
export interface ServiceResolver {
|
|
11
|
+
readonly [ServiceResolverTypeId]: ServiceResolverTypeId;
|
|
12
|
+
/**
|
|
13
|
+
* Resolve a set of services identified by their tags.
|
|
14
|
+
* Returns a Context containing all requested services, or fails with ServiceNotAvailableError.
|
|
15
|
+
*/
|
|
16
|
+
resolve<Tag extends Context.Tag<any, any>>(tag: Tag, context: ResolutionContext): Effect.Effect<Context.Tag.Service<Tag>, ServiceNotAvailableError, Scope.Scope>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Tag for the ServiceResolver service.
|
|
20
|
+
*/
|
|
21
|
+
export declare const ServiceResolver: Context.Tag<ServiceResolver, ServiceResolver>;
|
|
22
|
+
export declare const resolve: <Tag extends Context.Tag<any, any>>(tag: Tag, context: ResolutionContext) => Effect.Effect<Context.Tag.Service<Tag>, ServiceNotAvailableError, Scope.Scope | ServiceResolver>;
|
|
23
|
+
export declare const resolveAll: <const Tags extends readonly Context.Tag<any, any>[]>(tags: Tags, context: ResolutionContext) => Effect.Effect<Context.Context<Tags[number]>, ServiceNotAvailableError, Scope.Scope | ServiceResolver>;
|
|
24
|
+
/**
|
|
25
|
+
* Provides context for service resolution.
|
|
26
|
+
*/
|
|
27
|
+
export interface ResolutionContext {
|
|
28
|
+
/**
|
|
29
|
+
* Under which identity the process is running.
|
|
30
|
+
*/
|
|
31
|
+
readonly identity?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Under which space the process is running.
|
|
34
|
+
*/
|
|
35
|
+
readonly space?: SpaceId;
|
|
36
|
+
/**
|
|
37
|
+
* DXN of the conversation feed the process is running in.
|
|
38
|
+
*/
|
|
39
|
+
readonly conversation?: DXN.String;
|
|
40
|
+
/**
|
|
41
|
+
* Under which process the process is running.
|
|
42
|
+
*/
|
|
43
|
+
readonly process?: Process.ID;
|
|
44
|
+
}
|
|
45
|
+
export declare const succeed: <I, S>(tag: Context.Tag<I, S>, getService: (context: ResolutionContext) => Effect.Effect<S, ServiceNotAvailableError, Scope.Scope>) => ServiceResolver;
|
|
46
|
+
/**
|
|
47
|
+
* Create a ServiceResolver from a custom resolution function.
|
|
48
|
+
*/
|
|
49
|
+
export declare const make: (resolveFn: <I, S>(tag: Context.Tag<I, S>, context: ResolutionContext) => Effect.Effect<S, ServiceNotAvailableError, Scope.Scope>) => ServiceResolver;
|
|
50
|
+
/**
|
|
51
|
+
* Create a ServiceResolver backed by a static Context.
|
|
52
|
+
* Tags present in the context are resolved; missing tags fail with ServiceNotAvailableError.
|
|
53
|
+
*/
|
|
54
|
+
export declare const fromContext: (ctx: Context.Context<any>) => ServiceResolver;
|
|
55
|
+
/**
|
|
56
|
+
* Create a ServiceResolver that resolves tags from the current Effect context.
|
|
57
|
+
* Only the specified tags are available; requests for other tags fail.
|
|
58
|
+
*/
|
|
59
|
+
export declare const fromRequirements: <const Tags extends readonly Context.Tag<any, any>[]>(...tags: Tags) => Effect.Effect<ServiceResolver, never, Context.Tag.Identifier<Tags[number]>>;
|
|
60
|
+
/**
|
|
61
|
+
* Like {@link fromRequirements} but returns a Layer that provides ServiceResolver.
|
|
62
|
+
*/
|
|
63
|
+
export declare const layerRequirements: <const Tags extends readonly Context.Tag<any, any>[]>(...tags: Tags) => Layer.Layer<ServiceResolver, never, Context.Tag.Identifier<Tags[number]>>;
|
|
64
|
+
/**
|
|
65
|
+
* Compose multiple resolvers left to right. Earlier resolvers take precedence:
|
|
66
|
+
* the first resolver that can satisfy a tag wins.
|
|
67
|
+
*/
|
|
68
|
+
export declare const compose: (...resolvers: readonly ServiceResolver[]) => ServiceResolver;
|
|
69
|
+
/**
|
|
70
|
+
* An empty resolver that fails for any requested service.
|
|
71
|
+
*/
|
|
72
|
+
export declare const empty: ServiceResolver;
|
|
73
|
+
export {};
|
|
74
|
+
//# sourceMappingURL=ServiceResolver.d.ts.map
|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AAC,MAAM,CAAC,eAAe,EAAE,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAgBzE,CAAC;AAEL;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAAI,KAAK,CAAC,IAAI,SAAS,SAAS,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EACnF,GAAG,MAAM,IAAI,KACZ,KAAK,CAAC,KAAK,CAAC,eAAe,EAAE,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CACjB,CAAC;AAE3D;;;GAGG;AACH,eAAO,MAAM,OAAO,GAAI,GAAG,WAAW,SAAS,eAAe,EAAE,KAAG,eAYhE,CAAC;AAEJ;;GAEG;AACH,eAAO,MAAM,KAAK,EAAE,eAElB,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import * as Pipeable from 'effect/Pipeable';
|
|
2
|
+
import * as Context from 'effect/Context';
|
|
3
|
+
import * as Effect from 'effect/Effect';
|
|
4
|
+
import * as Option from 'effect/Option';
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
export interface Service {
|
|
7
|
+
/** Read a value by key. Returns `None` if key does not exist. */
|
|
8
|
+
get<S extends Schema.Schema<any, string, any>>(schema: S, key: string): Effect.Effect<Option.Option<Schema.Schema.Type<S>>, never, Schema.Schema.Context<S>>;
|
|
9
|
+
/** Write a value for the given key. */
|
|
10
|
+
set<S extends Schema.Schema<any, string, any>>(schema: S, key: string, value: Schema.Schema.Type<S>): Effect.Effect<void, never, Schema.Schema.Context<S>>;
|
|
11
|
+
/** Remove a key. */
|
|
12
|
+
delete(key: string): Effect.Effect<void>;
|
|
13
|
+
/** List all keys, optionally filtered by prefix. */
|
|
14
|
+
list(prefix?: string): Effect.Effect<readonly string[]>;
|
|
15
|
+
/** Remove all keys managed by this scoped store. */
|
|
16
|
+
clear(): Effect.Effect<void>;
|
|
17
|
+
}
|
|
18
|
+
declare const StorageService_base: Context.TagClass<StorageService, "@dxos/functions/StorageService", Service>;
|
|
19
|
+
/**
|
|
20
|
+
* Scoped key-value storage service for processes.
|
|
21
|
+
* Each process receives its own namespaced instance via the process manager.
|
|
22
|
+
* Construct a live implementation with `StorageService.layer` from `@dxos/functions-runtime`.
|
|
23
|
+
*/
|
|
24
|
+
export declare class StorageService extends StorageService_base {
|
|
25
|
+
}
|
|
26
|
+
export declare const get: <S extends Schema.Schema<any, string, any>>(schema: S, key: string) => Effect.Effect<Option.Option<Schema.Schema.Type<S>>, never, Schema.Schema.Context<S> | StorageService>;
|
|
27
|
+
export declare const set: <S extends Schema.Schema<any, string, any>>(schema: S, key: string, value: Schema.Schema.Type<S>) => Effect.Effect<void, never, Schema.Schema.Context<S> | StorageService>;
|
|
28
|
+
export declare const deleteKey: (key: string) => Effect.Effect<void, never, StorageService>;
|
|
29
|
+
export declare const list: (prefix?: string | undefined) => Effect.Effect<readonly string[], never, StorageService>;
|
|
30
|
+
export declare const clear: () => Effect.Effect<void, never, StorageService>;
|
|
31
|
+
/**
|
|
32
|
+
* Typed key in a storage service.
|
|
33
|
+
*/
|
|
34
|
+
export interface Key<T> extends Pipeable.Pipeable {
|
|
35
|
+
readonly key: string;
|
|
36
|
+
get: Effect.Effect<Option.Option<T>, never, StorageService>;
|
|
37
|
+
set(value: T): Effect.Effect<void, never, StorageService>;
|
|
38
|
+
delete(): Effect.Effect<void, never, StorageService>;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Create a typed key in a storage service.
|
|
42
|
+
*/
|
|
43
|
+
export declare const key: <S extends Schema.Schema<any, string, any>>(schema: S, key: string) => Key<Schema.Schema.Type<S>>;
|
|
44
|
+
/**
|
|
45
|
+
* Typed key in a storage service with a default value.
|
|
46
|
+
*/
|
|
47
|
+
export interface KeyWithDefault<T, U> extends Pipeable.Pipeable {
|
|
48
|
+
readonly key: string;
|
|
49
|
+
get: Effect.Effect<T | U, never, StorageService>;
|
|
50
|
+
set(value: U): Effect.Effect<void, never, StorageService>;
|
|
51
|
+
delete(): Effect.Effect<void, never, StorageService>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Assign a default value to a key if it is not present.
|
|
55
|
+
*/
|
|
56
|
+
export declare const withDefault: <T>(getDefault: () => NoInfer<T>) => (key: Key<T>) => KeyWithDefault<T, T>;
|
|
57
|
+
export {};
|
|
58
|
+
//# sourceMappingURL=StorageService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StorageService.d.ts","sourceRoot":"","sources":["../../../../src/process/StorageService.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,MAAM,WAAW,OAAO;IACtB,iEAAiE;IACjE,GAAG,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAC3C,MAAM,EAAE,CAAC,EACT,GAAG,EAAE,MAAM,GACV,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAExF,uCAAuC;IACvC,GAAG,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAC3C,MAAM,EAAE,CAAC,EACT,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,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KAAK,EAAE,cAAc,CAAC,CAAC;CACtD;AAED;;GAEG;AACH,eAAO,MAAM,GAAG,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,QAAQ,CAAC,EAAE,KAAK,MAAM,KAAG,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAUhH,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC,EAAE,CAAC,CAAE,SAAQ,QAAQ,CAAC,QAAQ;IAC7D,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC;IACjD,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC;IAC1D,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC;CACtD;AAED;;GAEG;AACH,eAAO,MAAM,WAAW,GACrB,CAAC,EAAE,YAAY,MAAM,OAAO,CAAC,CAAC,CAAC,MAC/B,KAAK,GAAG,CAAC,CAAC,CAAC,KAAG,cAAc,CAAC,CAAC,EAAE,CAAC,CAUjC,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type FunctionProtocol } from '@dxos/protocols';
|
|
2
|
-
import {
|
|
2
|
+
import { Operation } from '@dxos/operation';
|
|
3
3
|
/**
|
|
4
4
|
* Wraps a function handler made with `defineFunction` to a protocol that the functions-runtime expects.
|
|
5
5
|
*/
|
|
6
|
-
export declare const wrapFunctionHandler: (func:
|
|
6
|
+
export declare const wrapFunctionHandler: (func: Operation.WithHandler<Operation.Definition.Any>) => FunctionProtocol.Func;
|
|
7
7
|
//# sourceMappingURL=protocol.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../../../src/protocol/protocol.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../../../src/protocol/protocol.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAMxD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAAI,MAAM,SAAS,CAAC,WAAW,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,KAAG,gBAAgB,CAAC,IAwE5G,CAAC"}
|
package/dist/types/src/sdk.d.ts
CHANGED
|
@@ -1,114 +1,14 @@
|
|
|
1
|
-
import type * as Context from 'effect/Context';
|
|
2
|
-
import * as Effect from 'effect/Effect';
|
|
3
|
-
import * as Schema from 'effect/Schema';
|
|
4
1
|
import { type AiService } from '@dxos/ai';
|
|
5
|
-
import {
|
|
6
|
-
import { type
|
|
7
|
-
import { Operation } from '@dxos/operation';
|
|
2
|
+
import { type Database, type Feed } from '@dxos/echo';
|
|
3
|
+
import { type Trace } from '@dxos/functions';
|
|
8
4
|
import { type CredentialsService, type FunctionInvocationService, type QueueService, type TracingService } from './services';
|
|
9
|
-
import { Function } from './types';
|
|
10
5
|
/**
|
|
11
6
|
* Services that are provided at the function call site by the caller.
|
|
12
7
|
*/
|
|
13
8
|
export type InvocationServices = TracingService;
|
|
14
9
|
/**
|
|
15
10
|
* Services that are available to invoked functions.
|
|
11
|
+
* @deprecated
|
|
16
12
|
*/
|
|
17
|
-
export type FunctionServices = InvocationServices | AiService.AiService | CredentialsService | Database.Service | QueueService | FunctionInvocationService;
|
|
18
|
-
/**
|
|
19
|
-
* Function handler.
|
|
20
|
-
*/
|
|
21
|
-
export type FunctionHandler<TData = {}, TOutput = any, S extends FunctionServices = FunctionServices> = (params: {
|
|
22
|
-
/**
|
|
23
|
-
* Context available to the function.
|
|
24
|
-
*/
|
|
25
|
-
context: FunctionContext;
|
|
26
|
-
/**
|
|
27
|
-
* Data passed as the input to the function.
|
|
28
|
-
* Must match the function's input schema.
|
|
29
|
-
* This will be the payload from the trigger or other data passed into the function in a workflow.
|
|
30
|
-
*/
|
|
31
|
-
data: TData;
|
|
32
|
-
}) => TOutput | Promise<TOutput> | Effect.Effect<TOutput, any, S>;
|
|
33
|
-
/**
|
|
34
|
-
* Function context.
|
|
35
|
-
*/
|
|
36
|
-
export interface FunctionContext {
|
|
37
|
-
}
|
|
38
|
-
declare const typeId: unique symbol;
|
|
39
|
-
export type FunctionDefinition<T = any, O = any, S extends FunctionServices = FunctionServices> = {
|
|
40
|
-
[typeId]: true;
|
|
41
|
-
key: string;
|
|
42
|
-
name: string;
|
|
43
|
-
description?: string;
|
|
44
|
-
inputSchema: Schema.Schema<T, any>;
|
|
45
|
-
outputSchema?: Schema.Schema<O, any>;
|
|
46
|
-
/**
|
|
47
|
-
* List of types the function uses.
|
|
48
|
-
* This is used to ensure that the types are available when the function is executed.
|
|
49
|
-
*/
|
|
50
|
-
types: readonly Type.Entity.Any[];
|
|
51
|
-
/**
|
|
52
|
-
* Keys of the required services.
|
|
53
|
-
*/
|
|
54
|
-
services: readonly string[];
|
|
55
|
-
handler: FunctionHandler<T, O, S>;
|
|
56
|
-
meta?: {
|
|
57
|
-
/**
|
|
58
|
-
* Tools that are projected from functions have this annotation.
|
|
59
|
-
*
|
|
60
|
-
* deployedFunctionId:
|
|
61
|
-
* - Backend deployment ID assigned by the EDGE function service (typically a UUID).
|
|
62
|
-
* - Used for remote invocation via `FunctionInvocationService` → `RemoteFunctionExecutionService`.
|
|
63
|
-
* - Persisted on the corresponding ECHO `Function.Function` object's metadata under the
|
|
64
|
-
* `FUNCTIONS_META_KEY` and retrieved with `getUserFunctionIdInMetadata`.
|
|
65
|
-
*/
|
|
66
|
-
deployedFunctionId?: string;
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
export declare namespace FunctionDefinition {
|
|
70
|
-
type Any = FunctionDefinition<any, any, any>;
|
|
71
|
-
type Input<T extends Any> = T extends FunctionDefinition<infer I, infer _O, infer _S> ? I : never;
|
|
72
|
-
type Output<T extends Any> = T extends FunctionDefinition<infer _I, infer O, infer _S> ? O : never;
|
|
73
|
-
type Services<T extends Any> = T extends FunctionDefinition<infer _I, infer _O, infer S> ? S : never;
|
|
74
|
-
}
|
|
75
|
-
export type FunctionProps<T, O> = {
|
|
76
|
-
key: string;
|
|
77
|
-
name: string;
|
|
78
|
-
description?: string;
|
|
79
|
-
inputSchema: Schema.Schema<T, any>;
|
|
80
|
-
outputSchema?: Schema.Schema<O, any>;
|
|
81
|
-
/**
|
|
82
|
-
* List of types the function uses.
|
|
83
|
-
* This is used to ensure that the types are available when the function is executed.
|
|
84
|
-
*/
|
|
85
|
-
types?: readonly Type.Entity.Any[];
|
|
86
|
-
services?: readonly Context.Tag<any, any>[];
|
|
87
|
-
handler: FunctionHandler<T, O, FunctionServices>;
|
|
88
|
-
};
|
|
89
|
-
export declare const defineFunction: {
|
|
90
|
-
<I, O>(params: FunctionProps<I, O>): FunctionDefinition<I, O, FunctionServices>;
|
|
91
|
-
};
|
|
92
|
-
/**
|
|
93
|
-
* Converts a FunctionDefinition to an OperationDefinition with handler.
|
|
94
|
-
* The function handler is adapted to the OperationHandler format.
|
|
95
|
-
*
|
|
96
|
-
* Note: FunctionDefinition stores service keys as strings, not Tag types,
|
|
97
|
-
* so we can't use Operation.withHandler's type inference here.
|
|
98
|
-
*/
|
|
99
|
-
export declare const toOperation: <T, O, S extends FunctionServices = FunctionServices>(functionDef: FunctionDefinition<T, O, S>) => Operation.Definition<T, O> & {
|
|
100
|
-
handler: Operation.Handler<T, O, any, S>;
|
|
101
|
-
};
|
|
102
|
-
export declare const FunctionDefinition: {
|
|
103
|
-
make: <I, O>(params: FunctionProps<I, O>) => FunctionDefinition<I, O, FunctionServices>;
|
|
104
|
-
isFunction: (value: unknown) => value is FunctionDefinition.Any;
|
|
105
|
-
serialize: (functionDef: FunctionDefinition.Any) => Function.Function;
|
|
106
|
-
deserialize: (functionObj: Function.Function) => FunctionDefinition.Any;
|
|
107
|
-
toOperation: <T, O, S extends FunctionServices = FunctionServices>(functionDef: FunctionDefinition<T, O, S>) => Operation.Definition<T, O> & {
|
|
108
|
-
handler: Operation.Handler<T, O, any, S>;
|
|
109
|
-
};
|
|
110
|
-
};
|
|
111
|
-
export declare const serializeFunction: (functionDef: FunctionDefinition.Any) => Function.Function;
|
|
112
|
-
export declare const deserializeFunction: (functionObj: Function.Function) => FunctionDefinition<unknown, unknown>;
|
|
113
|
-
export {};
|
|
13
|
+
export type FunctionServices = InvocationServices | AiService.AiService | CredentialsService | Database.Service | QueueService | Feed.Service | Trace.TraceService | FunctionInvocationService;
|
|
114
14
|
//# sourceMappingURL=sdk.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../../src/sdk.ts"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../../src/sdk.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,yBAAyB,EAC9B,KAAK,YAAY,EACjB,KAAK,cAAc,EACpB,MAAM,YAAY,CAAC;AAOpB;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,cAAc,CAAC;AAEhD;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GACxB,kBAAkB,GAClB,SAAS,CAAC,SAAS,GACnB,kBAAkB,GAClB,QAAQ,CAAC,OAAO,GAEhB,YAAY,GACZ,IAAI,CAAC,OAAO,GACZ,KAAK,CAAC,YAAY,GAClB,yBAAyB,CAAC"}
|
|
@@ -45,15 +45,15 @@ export declare const ComputeEvent: Type.Obj<{
|
|
|
45
45
|
readonly nodeId: string;
|
|
46
46
|
readonly outputs: readonly string[];
|
|
47
47
|
} | {
|
|
48
|
-
readonly value: any;
|
|
49
48
|
readonly type: "compute-input";
|
|
50
|
-
readonly
|
|
49
|
+
readonly value: any;
|
|
51
50
|
readonly property: string;
|
|
51
|
+
readonly nodeId: string;
|
|
52
52
|
} | {
|
|
53
|
-
readonly value: any;
|
|
54
53
|
readonly type: "compute-output";
|
|
55
|
-
readonly
|
|
54
|
+
readonly value: any;
|
|
56
55
|
readonly property: string;
|
|
56
|
+
readonly nodeId: string;
|
|
57
57
|
} | {
|
|
58
58
|
readonly type: "custom";
|
|
59
59
|
readonly nodeId: string;
|