@dxos/functions 0.8.4-main.5ad4a44 → 0.8.4-main.66e292d
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/dist/lib/browser/index.mjs +830 -1195
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +830 -1195
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/errors.d.ts +28 -36
- package/dist/types/src/errors.d.ts.map +1 -1
- package/dist/types/src/{examples → example}/fib.d.ts +1 -1
- package/dist/types/src/example/fib.d.ts.map +1 -0
- package/dist/types/src/example/forex-effect.d.ts +3 -0
- package/dist/types/src/example/forex-effect.d.ts.map +1 -0
- package/dist/types/src/example/index.d.ts +12 -0
- package/dist/types/src/example/index.d.ts.map +1 -0
- package/dist/types/src/{examples → example}/reply.d.ts +1 -1
- package/dist/types/src/example/reply.d.ts.map +1 -0
- package/dist/types/src/{examples → example}/sleep.d.ts +1 -1
- package/dist/types/src/example/sleep.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +4 -8
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/protocol/index.d.ts +2 -0
- package/dist/types/src/protocol/index.d.ts.map +1 -0
- package/dist/types/src/protocol/protocol.d.ts +7 -0
- package/dist/types/src/protocol/protocol.d.ts.map +1 -0
- package/dist/types/src/protocol/protocol.test.d.ts +2 -0
- package/dist/types/src/protocol/protocol.test.d.ts.map +1 -0
- package/dist/types/src/sdk.d.ts +100 -0
- package/dist/types/src/sdk.d.ts.map +1 -0
- package/dist/types/src/services/credentials.d.ts +1 -1
- package/dist/types/src/services/credentials.d.ts.map +1 -1
- package/dist/types/src/services/event-logger.d.ts +16 -4
- package/dist/types/src/services/event-logger.d.ts.map +1 -1
- package/dist/types/src/services/function-invocation-service.d.ts +3 -20
- package/dist/types/src/services/function-invocation-service.d.ts.map +1 -1
- package/dist/types/src/services/index.d.ts +3 -4
- 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 +5 -10
- package/dist/types/src/services/tracing.d.ts.map +1 -1
- package/dist/types/src/types/Function.d.ts +63 -0
- package/dist/types/src/types/Function.d.ts.map +1 -0
- package/dist/types/src/types/Script.d.ts +28 -0
- package/dist/types/src/types/Script.d.ts.map +1 -0
- package/dist/types/src/types/Trigger.d.ts +141 -0
- package/dist/types/src/types/Trigger.d.ts.map +1 -0
- package/dist/types/src/types/TriggerEvent.d.ts +43 -0
- package/dist/types/src/types/TriggerEvent.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +6 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/src/{url.d.ts → types/url.d.ts} +0 -9
- package/dist/types/src/types/url.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +15 -59
- package/src/{examples → example}/fib.ts +1 -1
- package/src/example/forex-effect.ts +40 -0
- package/src/example/index.ts +13 -0
- package/src/{examples → example}/reply.ts +1 -1
- package/src/{examples → example}/sleep.ts +1 -1
- package/src/index.ts +4 -8
- package/src/{executor → protocol}/index.ts +1 -1
- package/src/protocol/protocol.test.ts +59 -0
- package/src/protocol/protocol.ts +156 -0
- package/src/{handler.ts → sdk.ts} +96 -81
- package/src/services/credentials.ts +3 -4
- package/src/services/event-logger.ts +8 -2
- package/src/services/function-invocation-service.ts +10 -71
- package/src/services/index.ts +4 -4
- package/src/services/queues.ts +5 -7
- package/src/services/tracing.ts +8 -43
- package/src/types/Function.ts +80 -0
- package/src/types/Script.ts +33 -0
- package/src/types/Trigger.ts +140 -0
- package/src/types/TriggerEvent.ts +62 -0
- package/src/types/index.ts +9 -0
- package/src/{url.ts → types/url.ts} +0 -24
- package/dist/lib/browser/bundler/index.mjs +0 -269
- package/dist/lib/browser/bundler/index.mjs.map +0 -7
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +0 -10
- package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +0 -7
- package/dist/lib/browser/chunk-LKYT2SAL.mjs +0 -665
- package/dist/lib/browser/chunk-LKYT2SAL.mjs.map +0 -7
- package/dist/lib/browser/edge/index.mjs +0 -83
- package/dist/lib/browser/edge/index.mjs.map +0 -7
- package/dist/lib/browser/testing/index.mjs +0 -131
- package/dist/lib/browser/testing/index.mjs.map +0 -7
- package/dist/lib/node-esm/bundler/index.mjs +0 -270
- package/dist/lib/node-esm/bundler/index.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +0 -11
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-NAQIKLZB.mjs +0 -667
- package/dist/lib/node-esm/chunk-NAQIKLZB.mjs.map +0 -7
- package/dist/lib/node-esm/edge/index.mjs +0 -84
- package/dist/lib/node-esm/edge/index.mjs.map +0 -7
- package/dist/lib/node-esm/testing/index.mjs +0 -132
- package/dist/lib/node-esm/testing/index.mjs.map +0 -7
- package/dist/types/src/bundler/bundler.d.ts +0 -49
- package/dist/types/src/bundler/bundler.d.ts.map +0 -1
- package/dist/types/src/bundler/bundler.test.d.ts +0 -2
- package/dist/types/src/bundler/bundler.test.d.ts.map +0 -1
- package/dist/types/src/bundler/index.d.ts +0 -2
- package/dist/types/src/bundler/index.d.ts.map +0 -1
- package/dist/types/src/edge/functions.d.ts +0 -17
- package/dist/types/src/edge/functions.d.ts.map +0 -1
- package/dist/types/src/edge/index.d.ts +0 -2
- package/dist/types/src/edge/index.d.ts.map +0 -1
- package/dist/types/src/examples/fib.d.ts.map +0 -1
- package/dist/types/src/examples/index.d.ts +0 -4
- package/dist/types/src/examples/index.d.ts.map +0 -1
- package/dist/types/src/examples/reply.d.ts.map +0 -1
- package/dist/types/src/examples/sleep.d.ts.map +0 -1
- package/dist/types/src/executor/executor.d.ts +0 -14
- package/dist/types/src/executor/executor.d.ts.map +0 -1
- package/dist/types/src/executor/index.d.ts +0 -2
- package/dist/types/src/executor/index.d.ts.map +0 -1
- package/dist/types/src/handler.d.ts +0 -109
- package/dist/types/src/handler.d.ts.map +0 -1
- package/dist/types/src/schema.d.ts +0 -43
- package/dist/types/src/schema.d.ts.map +0 -1
- package/dist/types/src/services/database.d.ts +0 -67
- package/dist/types/src/services/database.d.ts.map +0 -1
- package/dist/types/src/services/function-invocation-service.test.d.ts +0 -2
- package/dist/types/src/services/function-invocation-service.test.d.ts.map +0 -1
- package/dist/types/src/services/local-function-execution.d.ts +0 -34
- package/dist/types/src/services/local-function-execution.d.ts.map +0 -1
- package/dist/types/src/services/remote-function-execution-service.d.ts +0 -22
- package/dist/types/src/services/remote-function-execution-service.d.ts.map +0 -1
- package/dist/types/src/services/service-container.d.ts +0 -57
- package/dist/types/src/services/service-container.d.ts.map +0 -1
- package/dist/types/src/services/service-registry.d.ts +0 -31
- package/dist/types/src/services/service-registry.d.ts.map +0 -1
- package/dist/types/src/services/service-registry.test.d.ts +0 -2
- package/dist/types/src/services/service-registry.test.d.ts.map +0 -1
- package/dist/types/src/testing/index.d.ts +0 -3
- package/dist/types/src/testing/index.d.ts.map +0 -1
- package/dist/types/src/testing/layer.d.ts +0 -18
- package/dist/types/src/testing/layer.d.ts.map +0 -1
- package/dist/types/src/testing/logger.d.ts +0 -5
- package/dist/types/src/testing/logger.d.ts.map +0 -1
- package/dist/types/src/testing/persist-database.test.d.ts +0 -2
- package/dist/types/src/testing/persist-database.test.d.ts.map +0 -1
- package/dist/types/src/testing/services.d.ts +0 -59
- package/dist/types/src/testing/services.d.ts.map +0 -1
- package/dist/types/src/trace.d.ts +0 -122
- package/dist/types/src/trace.d.ts.map +0 -1
- package/dist/types/src/translations.d.ts +0 -12
- package/dist/types/src/translations.d.ts.map +0 -1
- package/dist/types/src/triggers/index.d.ts +0 -4
- package/dist/types/src/triggers/index.d.ts.map +0 -1
- package/dist/types/src/triggers/input-builder.d.ts +0 -3
- package/dist/types/src/triggers/input-builder.d.ts.map +0 -1
- package/dist/types/src/triggers/invocation-tracer.d.ts +0 -37
- package/dist/types/src/triggers/invocation-tracer.d.ts.map +0 -1
- package/dist/types/src/triggers/trigger-dispatcher.d.ts +0 -78
- package/dist/types/src/triggers/trigger-dispatcher.d.ts.map +0 -1
- package/dist/types/src/triggers/trigger-dispatcher.test.d.ts +0 -2
- package/dist/types/src/triggers/trigger-dispatcher.test.d.ts.map +0 -1
- package/dist/types/src/triggers/trigger-state-store.d.ts +0 -28
- package/dist/types/src/triggers/trigger-state-store.d.ts.map +0 -1
- package/dist/types/src/types.d.ts +0 -230
- package/dist/types/src/types.d.ts.map +0 -1
- package/dist/types/src/url.d.ts.map +0 -1
- package/src/bundler/bundler.test.ts +0 -58
- package/src/bundler/bundler.ts +0 -295
- package/src/bundler/index.ts +0 -5
- package/src/edge/functions.ts +0 -67
- package/src/edge/index.ts +0 -9
- package/src/examples/index.ts +0 -7
- package/src/executor/executor.ts +0 -58
- package/src/schema.ts +0 -71
- package/src/services/database.ts +0 -175
- package/src/services/function-invocation-service.test.ts +0 -81
- package/src/services/local-function-execution.ts +0 -153
- package/src/services/remote-function-execution-service.ts +0 -63
- package/src/services/service-container.ts +0 -115
- package/src/services/service-registry.test.ts +0 -45
- package/src/services/service-registry.ts +0 -63
- package/src/testing/index.ts +0 -6
- package/src/testing/layer.ts +0 -114
- package/src/testing/logger.ts +0 -17
- package/src/testing/persist-database.test.ts +0 -87
- package/src/testing/services.ts +0 -115
- package/src/trace.ts +0 -178
- package/src/translations.ts +0 -20
- package/src/triggers/index.ts +0 -7
- package/src/triggers/input-builder.ts +0 -35
- package/src/triggers/invocation-tracer.ts +0 -101
- package/src/triggers/trigger-dispatcher.test.ts +0 -665
- package/src/triggers/trigger-dispatcher.ts +0 -533
- package/src/triggers/trigger-state-store.ts +0 -61
- package/src/types.ts +0 -218
|
@@ -5,30 +5,48 @@
|
|
|
5
5
|
import type * as Context from 'effect/Context';
|
|
6
6
|
import * as Effect from 'effect/Effect';
|
|
7
7
|
import * as Schema from 'effect/Schema';
|
|
8
|
-
import type * as Types from 'effect/Types';
|
|
9
8
|
|
|
9
|
+
import { type AiService } from '@dxos/ai';
|
|
10
10
|
import { Obj, Type } from '@dxos/echo';
|
|
11
|
-
import { type
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
import { type DatabaseService } from '@dxos/echo-db';
|
|
12
|
+
import { assertArgument, failedInvariant } from '@dxos/invariant';
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
type CredentialsService,
|
|
16
|
+
type FunctionInvocationService,
|
|
17
|
+
type QueueService,
|
|
18
|
+
type TracingService,
|
|
19
|
+
} from './services';
|
|
20
|
+
import { Function } from './types';
|
|
21
|
+
import { getUserFunctionIdInMetadata, setUserFunctionIdInMetadata } from './types';
|
|
20
22
|
|
|
21
23
|
// TODO(burdon): Model after http request. Ref Lambda/OpenFaaS.
|
|
22
24
|
// https://docs.aws.amazon.com/lambda/latest/dg/typescript-handler.html
|
|
23
25
|
// https://www.serverless.com/framework/docs/providers/aws/guide/serverless.yml/#functions
|
|
24
26
|
// https://www.npmjs.com/package/aws-lambda
|
|
25
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Services that are provided at the function call site by the caller.
|
|
30
|
+
*/
|
|
31
|
+
export type InvocationServices = TracingService;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Services that are available to invoked functions.
|
|
35
|
+
*/
|
|
36
|
+
export type FunctionServices =
|
|
37
|
+
| InvocationServices
|
|
38
|
+
| AiService.AiService
|
|
39
|
+
| CredentialsService
|
|
40
|
+
| DatabaseService
|
|
41
|
+
| QueueService
|
|
42
|
+
| FunctionInvocationService;
|
|
43
|
+
|
|
26
44
|
/**
|
|
27
45
|
* Function handler.
|
|
28
46
|
*/
|
|
29
|
-
export type FunctionHandler<TData = {}, TOutput = any> = (params: {
|
|
47
|
+
export type FunctionHandler<TData = {}, TOutput = any, S extends FunctionServices = FunctionServices> = (params: {
|
|
30
48
|
/**
|
|
31
|
-
*
|
|
49
|
+
* Context available to the function.
|
|
32
50
|
*/
|
|
33
51
|
context: FunctionContext;
|
|
34
52
|
|
|
@@ -38,68 +56,37 @@ export type FunctionHandler<TData = {}, TOutput = any> = (params: {
|
|
|
38
56
|
* This will be the payload from the trigger or other data passed into the function in a workflow.
|
|
39
57
|
*/
|
|
40
58
|
data: TData;
|
|
41
|
-
}) => TOutput | Promise<TOutput> | Effect.Effect<TOutput, any,
|
|
59
|
+
}) => TOutput | Promise<TOutput> | Effect.Effect<TOutput, any, S>;
|
|
42
60
|
|
|
43
61
|
/**
|
|
44
62
|
* Function context.
|
|
45
63
|
*/
|
|
46
64
|
export interface FunctionContext {
|
|
47
|
-
|
|
48
|
-
* Space from which the function was invoked.
|
|
49
|
-
*/
|
|
50
|
-
space: SpaceAPI | undefined;
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Resolves a service available to the function.
|
|
54
|
-
* @throws if the service is not available.
|
|
55
|
-
*/
|
|
56
|
-
getService: <T extends Context.Tag<any, any>>(tag: T) => Context.Tag.Service<T>;
|
|
57
|
-
|
|
58
|
-
getSpace: (spaceId: SpaceId) => Promise<SpaceAPI>;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export interface FunctionContextAi {
|
|
62
|
-
// TODO(dmaretskyi): Refer to cloudflare AI docs for more comprehensive typedefs.
|
|
63
|
-
run(model: string, inputs: any, options?: any): Promise<any>;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
//
|
|
67
|
-
// API.
|
|
68
|
-
//
|
|
69
|
-
|
|
70
|
-
// TODO(dmaretskyi): Temporary API to get the queues working.
|
|
71
|
-
// TODO(dmaretskyi): To be replaced with integrating queues into echo.
|
|
72
|
-
export interface QueuesAPI {
|
|
73
|
-
queryQueue(queue: DXN, options?: {}): Promise<QueryResult>;
|
|
74
|
-
insertIntoQueue(queue: DXN, objects: HasId[]): Promise<void>;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Space interface available to functions.
|
|
79
|
-
*/
|
|
80
|
-
export interface SpaceAPI {
|
|
81
|
-
get id(): SpaceId;
|
|
82
|
-
get db(): EchoDatabase;
|
|
83
|
-
|
|
84
|
-
// TODO(dmaretskyi): Align with echo api: queues.get(id).append(items);
|
|
85
|
-
get queues(): QueuesAPI;
|
|
65
|
+
// TODO(dmaretskyi): Consider what we should put into context.
|
|
86
66
|
}
|
|
87
67
|
|
|
88
|
-
// TODO(wittjosiah): Queues are incompatible.
|
|
89
|
-
const __assertFunctionSpaceIsCompatibleWithTheClientSpace = () => {
|
|
90
|
-
// const _: SpaceAPI = {} as Space;
|
|
91
|
-
};
|
|
92
|
-
|
|
93
68
|
const typeId = Symbol.for('@dxos/functions/FunctionDefinition');
|
|
94
69
|
|
|
95
|
-
export type FunctionDefinition<T = any, O = any> = {
|
|
70
|
+
export type FunctionDefinition<T = any, O = any, S extends FunctionServices = FunctionServices> = {
|
|
96
71
|
[typeId]: true;
|
|
97
72
|
key: string;
|
|
98
73
|
name: string;
|
|
99
74
|
description?: string;
|
|
100
75
|
inputSchema: Schema.Schema<T, any>;
|
|
101
76
|
outputSchema?: Schema.Schema<O, any>;
|
|
102
|
-
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* List of types the function uses.
|
|
80
|
+
* This is used to ensure that the types are available when the function is executed.
|
|
81
|
+
*/
|
|
82
|
+
types: readonly Type.Obj.Any[];
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Keys of the required services.
|
|
86
|
+
*/
|
|
87
|
+
services: readonly string[];
|
|
88
|
+
|
|
89
|
+
handler: FunctionHandler<T, O, S>;
|
|
103
90
|
meta?: {
|
|
104
91
|
/**
|
|
105
92
|
* Tools that are projected from functions have this annotation.
|
|
@@ -107,24 +94,42 @@ export type FunctionDefinition<T = any, O = any> = {
|
|
|
107
94
|
* deployedFunctionId:
|
|
108
95
|
* - Backend deployment ID assigned by the EDGE function service (typically a UUID).
|
|
109
96
|
* - Used for remote invocation via `FunctionInvocationService` → `RemoteFunctionExecutionService`.
|
|
110
|
-
* - Persisted on the corresponding ECHO `
|
|
97
|
+
* - Persisted on the corresponding ECHO `Function.Function` object's metadata under the
|
|
111
98
|
* `FUNCTIONS_META_KEY` and retrieved with `getUserFunctionIdInMetadata`.
|
|
112
99
|
*/
|
|
113
100
|
deployedFunctionId?: string;
|
|
114
101
|
};
|
|
115
102
|
};
|
|
116
103
|
|
|
104
|
+
export declare namespace FunctionDefinition {
|
|
105
|
+
export type Any = FunctionDefinition<any, any, any>;
|
|
106
|
+
export type Input<T extends Any> = T extends FunctionDefinition<infer I, infer _O, infer _S> ? I : never;
|
|
107
|
+
export type Output<T extends Any> = T extends FunctionDefinition<infer _I, infer O, infer _S> ? O : never;
|
|
108
|
+
export type Services<T extends Any> = T extends FunctionDefinition<infer _I, infer _O, infer S> ? S : never;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export type FunctionProps<T, O> = {
|
|
112
|
+
key: string;
|
|
113
|
+
name: string;
|
|
114
|
+
description?: string;
|
|
115
|
+
inputSchema: Schema.Schema<T, any>;
|
|
116
|
+
outputSchema?: Schema.Schema<O, any>;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* List of types the function uses.
|
|
120
|
+
* This is used to ensure that the types are available when the function is executed.
|
|
121
|
+
*/
|
|
122
|
+
types?: readonly Type.Obj.Any[];
|
|
123
|
+
// TODO(dmaretskyi): This currently doesn't cause a compile-time error if the handler requests a service that is not specified
|
|
124
|
+
services?: readonly Context.Tag<any, any>[];
|
|
125
|
+
|
|
126
|
+
handler: FunctionHandler<T, O, FunctionServices>;
|
|
127
|
+
};
|
|
128
|
+
|
|
117
129
|
// TODO(dmaretskyi): Output type doesn't get typechecked.
|
|
118
130
|
export const defineFunction: {
|
|
119
|
-
<I, O>(params:
|
|
120
|
-
|
|
121
|
-
name: string;
|
|
122
|
-
description?: string;
|
|
123
|
-
inputSchema: Schema.Schema<I, any>;
|
|
124
|
-
outputSchema?: Schema.Schema<O, any>;
|
|
125
|
-
handler: Types.NoInfer<FunctionHandler<I, O>>;
|
|
126
|
-
}): FunctionDefinition<I, O>;
|
|
127
|
-
} = ({ key, name, description, inputSchema, outputSchema = Schema.Any, handler }) => {
|
|
131
|
+
<I, O>(params: FunctionProps<I, O>): FunctionDefinition<I, O, FunctionServices>;
|
|
132
|
+
} = ({ key, name, description, inputSchema, outputSchema = Schema.Any, handler, types, services }) => {
|
|
128
133
|
if (!Schema.isSchema(inputSchema)) {
|
|
129
134
|
throw new Error('Input schema must be a valid schema');
|
|
130
135
|
}
|
|
@@ -169,7 +174,19 @@ export const defineFunction: {
|
|
|
169
174
|
inputSchema,
|
|
170
175
|
outputSchema,
|
|
171
176
|
handler: handlerWithSpan,
|
|
172
|
-
|
|
177
|
+
types: types ?? [],
|
|
178
|
+
services: !services ? [] : getServiceKeys(services),
|
|
179
|
+
} satisfies FunctionDefinition.Any;
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
const getServiceKeys = (services: readonly Context.Tag<any, any>[]) => {
|
|
183
|
+
return services.map((tag: any) => {
|
|
184
|
+
if (typeof tag.key === 'string') {
|
|
185
|
+
return tag.key;
|
|
186
|
+
}
|
|
187
|
+
console.log(tag);
|
|
188
|
+
failedInvariant();
|
|
189
|
+
});
|
|
173
190
|
};
|
|
174
191
|
|
|
175
192
|
export const FunctionDefinition = {
|
|
@@ -177,29 +194,25 @@ export const FunctionDefinition = {
|
|
|
177
194
|
isFunction: (value: unknown): value is FunctionDefinition.Any => {
|
|
178
195
|
return typeof value === 'object' && value !== null && Symbol.for('@dxos/functions/FunctionDefinition') in value;
|
|
179
196
|
},
|
|
180
|
-
serialize: (functionDef: FunctionDefinition.Any):
|
|
197
|
+
serialize: (functionDef: FunctionDefinition.Any): Function.Function => {
|
|
181
198
|
assertArgument(FunctionDefinition.isFunction(functionDef), 'functionDef');
|
|
182
199
|
return serializeFunction(functionDef);
|
|
183
200
|
},
|
|
184
|
-
deserialize: (functionObj:
|
|
185
|
-
assertArgument(Obj.instanceOf(
|
|
201
|
+
deserialize: (functionObj: Function.Function): FunctionDefinition.Any => {
|
|
202
|
+
assertArgument(Obj.instanceOf(Function.Function, functionObj), 'functionObj');
|
|
186
203
|
return deserializeFunction(functionObj);
|
|
187
204
|
},
|
|
188
205
|
};
|
|
189
|
-
export declare namespace FunctionDefinition {
|
|
190
|
-
export type Any = FunctionDefinition<any, any>;
|
|
191
|
-
export type Input<T extends FunctionDefinition> = T extends FunctionDefinition<infer I, any> ? I : never;
|
|
192
|
-
export type Output<T extends FunctionDefinition> = T extends FunctionDefinition<any, infer O> ? O : never;
|
|
193
|
-
}
|
|
194
206
|
|
|
195
|
-
export const serializeFunction = (functionDef: FunctionDefinition
|
|
196
|
-
const fn =
|
|
207
|
+
export const serializeFunction = (functionDef: FunctionDefinition.Any): Function.Function => {
|
|
208
|
+
const fn = Function.make({
|
|
197
209
|
key: functionDef.key,
|
|
198
210
|
name: functionDef.name,
|
|
199
211
|
version: '0.1.0',
|
|
200
212
|
description: functionDef.description,
|
|
201
213
|
inputSchema: Type.toJsonSchema(functionDef.inputSchema),
|
|
202
214
|
outputSchema: !functionDef.outputSchema ? undefined : Type.toJsonSchema(functionDef.outputSchema),
|
|
215
|
+
services: functionDef.services,
|
|
203
216
|
});
|
|
204
217
|
if (functionDef.meta?.deployedFunctionId) {
|
|
205
218
|
setUserFunctionIdInMetadata(Obj.getMeta(fn), functionDef.meta.deployedFunctionId);
|
|
@@ -207,7 +220,7 @@ export const serializeFunction = (functionDef: FunctionDefinition<any, any>): Fu
|
|
|
207
220
|
return fn;
|
|
208
221
|
};
|
|
209
222
|
|
|
210
|
-
export const deserializeFunction = (functionObj:
|
|
223
|
+
export const deserializeFunction = (functionObj: Function.Function): FunctionDefinition<unknown, unknown> => {
|
|
211
224
|
return {
|
|
212
225
|
[typeId]: true,
|
|
213
226
|
// TODO(dmaretskyi): Fix key.
|
|
@@ -218,6 +231,8 @@ export const deserializeFunction = (functionObj: FunctionType): FunctionDefiniti
|
|
|
218
231
|
outputSchema: !functionObj.outputSchema ? undefined : Type.toEffectSchema(functionObj.outputSchema),
|
|
219
232
|
// TODO(dmaretskyi): This should throw error.
|
|
220
233
|
handler: () => {},
|
|
234
|
+
services: functionObj.services ?? [],
|
|
235
|
+
types: [],
|
|
221
236
|
meta: {
|
|
222
237
|
deployedFunctionId: getUserFunctionIdInMetadata(Obj.getMeta(functionObj)),
|
|
223
238
|
},
|
|
@@ -11,9 +11,8 @@ import * as Layer from 'effect/Layer';
|
|
|
11
11
|
import * as Redacted from 'effect/Redacted';
|
|
12
12
|
|
|
13
13
|
import { Query } from '@dxos/echo';
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
import { DatabaseService } from './database';
|
|
14
|
+
import { DatabaseService } from '@dxos/echo-db';
|
|
15
|
+
import { AccessToken } from '@dxos/types';
|
|
17
16
|
|
|
18
17
|
export type CredentialQuery = {
|
|
19
18
|
service?: string;
|
|
@@ -84,7 +83,7 @@ export class CredentialsService extends Context.Tag('@dxos/functions/Credentials
|
|
|
84
83
|
Effect.gen(function* () {
|
|
85
84
|
const dbService = yield* DatabaseService;
|
|
86
85
|
const queryCredentials = async (query: CredentialQuery): Promise<ServiceCredential[]> => {
|
|
87
|
-
const { objects: accessTokens } = await dbService.db.query(Query.type(
|
|
86
|
+
const { objects: accessTokens } = await dbService.db.query(Query.type(AccessToken.AccessToken)).run();
|
|
88
87
|
return accessTokens
|
|
89
88
|
.filter((accessToken) => accessToken.source === query.service)
|
|
90
89
|
.map((accessToken) => ({
|
|
@@ -17,12 +17,18 @@ export const ComputeEventPayload = Schema.Union(
|
|
|
17
17
|
Schema.Struct({
|
|
18
18
|
type: Schema.Literal('begin-compute'),
|
|
19
19
|
nodeId: Schema.String,
|
|
20
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Names of the inputs begin computed.
|
|
22
|
+
*/
|
|
23
|
+
inputs: Schema.Array(Schema.String),
|
|
21
24
|
}),
|
|
22
25
|
Schema.Struct({
|
|
23
26
|
type: Schema.Literal('end-compute'),
|
|
24
27
|
nodeId: Schema.String,
|
|
25
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Names of the outputs computed.
|
|
30
|
+
*/
|
|
31
|
+
outputs: Schema.Array(Schema.String),
|
|
26
32
|
}),
|
|
27
33
|
Schema.Struct({
|
|
28
34
|
type: Schema.Literal('compute-input'),
|
|
@@ -3,82 +3,21 @@
|
|
|
3
3
|
//
|
|
4
4
|
import * as Context from 'effect/Context';
|
|
5
5
|
import * as Effect from 'effect/Effect';
|
|
6
|
-
import * as Layer from 'effect/Layer';
|
|
7
6
|
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
import { type FunctionDefinition } from '../handler';
|
|
11
|
-
|
|
12
|
-
import { CredentialsService } from './credentials';
|
|
13
|
-
import { DatabaseService } from './database';
|
|
14
|
-
import {
|
|
15
|
-
FunctionImplementationResolver,
|
|
16
|
-
type InvocationServices,
|
|
17
|
-
LocalFunctionExecutionService,
|
|
18
|
-
} from './local-function-execution';
|
|
19
|
-
import { QueueService } from './queues';
|
|
20
|
-
import { RemoteFunctionExecutionService } from './remote-function-execution-service';
|
|
7
|
+
import { type FunctionDefinition, type InvocationServices } from '../sdk';
|
|
21
8
|
|
|
22
9
|
export class FunctionInvocationService extends Context.Tag('@dxos/functions/FunctionInvocationService')<
|
|
23
10
|
FunctionInvocationService,
|
|
24
11
|
{
|
|
25
|
-
invokeFunction<I, O>(
|
|
12
|
+
invokeFunction<I, O>(
|
|
13
|
+
functionDef: FunctionDefinition<I, O, any>,
|
|
14
|
+
input: I,
|
|
15
|
+
): Effect.Effect<O, never, InvocationServices>;
|
|
26
16
|
}
|
|
27
17
|
>() {
|
|
28
|
-
static invokeFunction =
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
Effect.
|
|
33
|
-
const localExecutioner = yield* LocalFunctionExecutionService;
|
|
34
|
-
const remoteExecutioner = yield* RemoteFunctionExecutionService;
|
|
35
|
-
|
|
36
|
-
return {
|
|
37
|
-
invokeFunction: <I, O>(
|
|
38
|
-
functionDef: FunctionDefinition<I, O>,
|
|
39
|
-
input: I,
|
|
40
|
-
): Effect.Effect<O, never, InvocationServices> =>
|
|
41
|
-
Effect.gen(function* () {
|
|
42
|
-
if (functionDef.meta?.deployedFunctionId) {
|
|
43
|
-
return yield* remoteExecutioner.callFunction<I, O>(functionDef.meta.deployedFunctionId, input);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return yield* localExecutioner.invokeFunction(functionDef, input);
|
|
47
|
-
}),
|
|
48
|
-
} satisfies Context.Tag.Service<FunctionInvocationService>;
|
|
49
|
-
}),
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
// TODO(dmaretskyi): Don't provide `FunctionImplementationResolver`.
|
|
53
|
-
static layerTest = ({
|
|
54
|
-
functions = [],
|
|
55
|
-
}: {
|
|
56
|
-
functions?: FunctionDefinition<any, any>[];
|
|
57
|
-
} = {}): Layer.Layer<
|
|
58
|
-
FunctionInvocationService,
|
|
59
|
-
never,
|
|
60
|
-
AiService.AiService | CredentialsService | DatabaseService | QueueService
|
|
61
|
-
> =>
|
|
62
|
-
FunctionInvocationService.layer.pipe(
|
|
63
|
-
Layer.provide(LocalFunctionExecutionService.layerLive),
|
|
64
|
-
Layer.provide(FunctionImplementationResolver.layerTest({ functions })),
|
|
65
|
-
Layer.provide(RemoteFunctionExecutionService.layerMock),
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
// TODO(dmaretskyi): This shouldn't default to all services being not available.
|
|
69
|
-
// TODO(dmaretskyi): Don't provide `FunctionImplementationResolver`.
|
|
70
|
-
/**
|
|
71
|
-
* @deprecated Use {@link layerTest} instead.
|
|
72
|
-
*/
|
|
73
|
-
static layerTestMocked = ({
|
|
74
|
-
functions,
|
|
75
|
-
}: {
|
|
76
|
-
functions: FunctionDefinition<any, any>[];
|
|
77
|
-
}): Layer.Layer<FunctionInvocationService> =>
|
|
78
|
-
FunctionInvocationService.layerTest({ functions }).pipe(
|
|
79
|
-
Layer.provide(AiService.notAvailable),
|
|
80
|
-
Layer.provide(CredentialsService.configuredLayer([])),
|
|
81
|
-
Layer.provide(DatabaseService.notAvailable),
|
|
82
|
-
Layer.provide(QueueService.notAvailable),
|
|
83
|
-
);
|
|
18
|
+
static invokeFunction = <I, O>(
|
|
19
|
+
functionDef: FunctionDefinition<I, O, any>,
|
|
20
|
+
input: I,
|
|
21
|
+
): Effect.Effect<O, never, FunctionInvocationService | InvocationServices> =>
|
|
22
|
+
Effect.serviceFunctionEffect(FunctionInvocationService, (service) => service.invokeFunction)(functionDef, input);
|
|
84
23
|
}
|
package/src/services/index.ts
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
export { DatabaseService } from '@dxos/echo-db';
|
|
6
|
+
|
|
5
7
|
export * from './credentials';
|
|
6
|
-
export
|
|
8
|
+
export { ConfiguredCredentialsService, type ServiceCredential } from './credentials';
|
|
7
9
|
export * from './event-logger';
|
|
10
|
+
export { createEventLogger, createDefectLogger } from './event-logger';
|
|
8
11
|
export * from './function-invocation-service';
|
|
9
|
-
export * from './local-function-execution';
|
|
10
12
|
export * from './queues';
|
|
11
|
-
export * from './service-container';
|
|
12
13
|
export * from './tracing';
|
|
13
|
-
export * from './remote-function-execution-service';
|
package/src/services/queues.ts
CHANGED
|
@@ -6,7 +6,7 @@ import * as Context from 'effect/Context';
|
|
|
6
6
|
import * as Effect from 'effect/Effect';
|
|
7
7
|
import * as Layer from 'effect/Layer';
|
|
8
8
|
|
|
9
|
-
import type {
|
|
9
|
+
import type { Entity } from '@dxos/echo';
|
|
10
10
|
import type { Queue, QueueAPI, QueueFactory } from '@dxos/echo-db';
|
|
11
11
|
import type { DXN, QueueSubspaceTag } from '@dxos/keys';
|
|
12
12
|
|
|
@@ -53,22 +53,20 @@ export class QueueService extends Context.Tag('@dxos/functions/QueueService')<
|
|
|
53
53
|
/**
|
|
54
54
|
* Gets a queue by its DXN.
|
|
55
55
|
*/
|
|
56
|
-
static getQueue = <T extends
|
|
56
|
+
static getQueue = <T extends Entity.Unknown = Entity.Unknown>(
|
|
57
57
|
dxn: DXN,
|
|
58
58
|
): Effect.Effect<Queue<T>, never, QueueService> => QueueService.pipe(Effect.map(({ queues }) => queues.get<T>(dxn)));
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
61
|
* Creates a new queue.
|
|
62
62
|
*/
|
|
63
|
-
static createQueue = <T extends
|
|
63
|
+
static createQueue = <T extends Entity.Unknown = Entity.Unknown>(options?: {
|
|
64
64
|
subspaceTag?: QueueSubspaceTag;
|
|
65
65
|
}): Effect.Effect<Queue<T>, never, QueueService> =>
|
|
66
66
|
QueueService.pipe(Effect.map(({ queues }) => queues.create<T>(options)));
|
|
67
67
|
|
|
68
|
-
static append = <T extends
|
|
69
|
-
queue
|
|
70
|
-
objects: T[],
|
|
71
|
-
): Effect.Effect<void> => Effect.promise(() => queue.append(objects));
|
|
68
|
+
static append = <T extends Entity.Unknown = Entity.Unknown>(queue: Queue<T>, objects: T[]): Effect.Effect<void> =>
|
|
69
|
+
Effect.promise(() => queue.append(objects));
|
|
72
70
|
}
|
|
73
71
|
|
|
74
72
|
/**
|
package/src/services/tracing.ts
CHANGED
|
@@ -8,10 +8,8 @@ import * as Layer from 'effect/Layer';
|
|
|
8
8
|
|
|
9
9
|
import { AgentStatus } from '@dxos/ai';
|
|
10
10
|
import { Obj } from '@dxos/echo';
|
|
11
|
-
import type
|
|
12
|
-
import
|
|
13
|
-
import { log } from '@dxos/log';
|
|
14
|
-
import { DataType } from '@dxos/schema';
|
|
11
|
+
import { type ObjectId } from '@dxos/keys';
|
|
12
|
+
import { Message } from '@dxos/types';
|
|
15
13
|
|
|
16
14
|
/**
|
|
17
15
|
* Provides a way for compute primitives (functions, workflows, tools)
|
|
@@ -32,29 +30,12 @@ export class TracingService extends Context.Tag('@dxos/functions/TracingService'
|
|
|
32
30
|
write: (event: Obj.Any) => void;
|
|
33
31
|
}
|
|
34
32
|
>() {
|
|
35
|
-
static noop: Context.Tag.Service<TracingService> = {
|
|
36
|
-
|
|
37
|
-
static layerNoop = Layer.succeed(TracingService, TracingService.noop);
|
|
38
|
-
|
|
39
|
-
static console: Context.Tag.Service<TracingService> = {
|
|
40
|
-
write: (event) => {
|
|
41
|
-
console.log(event);
|
|
42
|
-
},
|
|
33
|
+
static noop: Context.Tag.Service<TracingService> = {
|
|
43
34
|
getTraceContext: () => ({}),
|
|
35
|
+
write: () => {},
|
|
44
36
|
};
|
|
45
37
|
|
|
46
|
-
static
|
|
47
|
-
|
|
48
|
-
static layerLogInfo = () =>
|
|
49
|
-
Layer.succeed(TracingService, {
|
|
50
|
-
write: (event) => {
|
|
51
|
-
if (Obj.instanceOf(AgentStatus, event)) {
|
|
52
|
-
log.info('status', { message: event.message });
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
getTraceContext: () => ({}),
|
|
56
|
-
});
|
|
57
|
-
|
|
38
|
+
static layerNoop: Layer.Layer<TracingService> = Layer.succeed(TracingService, TracingService.noop);
|
|
58
39
|
/**
|
|
59
40
|
* Creates a TracingService layer that emits events to the parent tracing service.
|
|
60
41
|
*/
|
|
@@ -71,22 +52,6 @@ export class TracingService extends Context.Tag('@dxos/functions/TracingService'
|
|
|
71
52
|
}),
|
|
72
53
|
);
|
|
73
54
|
|
|
74
|
-
static layerQueue = (queue: Queue) =>
|
|
75
|
-
Layer.effect(
|
|
76
|
-
TracingService,
|
|
77
|
-
Effect.gen(function* () {
|
|
78
|
-
// TODO(dmaretskyi): Batching.
|
|
79
|
-
return {
|
|
80
|
-
write: (event) => queue.append([event]),
|
|
81
|
-
getTraceContext: () => ({
|
|
82
|
-
debugInfo: {
|
|
83
|
-
queue: queue.dxn.toString(),
|
|
84
|
-
},
|
|
85
|
-
}),
|
|
86
|
-
};
|
|
87
|
-
}),
|
|
88
|
-
);
|
|
89
|
-
|
|
90
55
|
/**
|
|
91
56
|
* Emit the current human-readable execution status.
|
|
92
57
|
*/
|
|
@@ -105,11 +70,11 @@ export class TracingService extends Context.Tag('@dxos/functions/TracingService'
|
|
|
105
70
|
});
|
|
106
71
|
|
|
107
72
|
static emitConverationMessage: (
|
|
108
|
-
data: Obj.MakeProps<typeof
|
|
73
|
+
data: Obj.MakeProps<typeof Message.Message>,
|
|
109
74
|
) => Effect.Effect<void, never, TracingService> = Effect.fnUntraced(function* (data) {
|
|
110
75
|
const tracing = yield* TracingService;
|
|
111
76
|
tracing.write(
|
|
112
|
-
Obj.make(
|
|
77
|
+
Obj.make(Message.Message, {
|
|
113
78
|
parentMessage: tracing.getTraceContext().parentMessage,
|
|
114
79
|
...data,
|
|
115
80
|
properties: {
|
|
@@ -138,6 +103,6 @@ export namespace TracingService {
|
|
|
138
103
|
}
|
|
139
104
|
|
|
140
105
|
/**
|
|
141
|
-
* Goes into {@link
|
|
106
|
+
* Goes into {@link Message['properties']}
|
|
142
107
|
*/
|
|
143
108
|
export const MESSAGE_PROPERTY_TOOL_CALL_ID = 'toolCallId' as const;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
7
|
+
import { Annotation, JsonSchema, Obj, Type } from '@dxos/echo';
|
|
8
|
+
import { SystemTypeAnnotation } from '@dxos/echo/internal';
|
|
9
|
+
|
|
10
|
+
import { Script } from './Script';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Function deployment.
|
|
14
|
+
*/
|
|
15
|
+
export const Function = Schema.Struct({
|
|
16
|
+
/**
|
|
17
|
+
* Global registry ID.
|
|
18
|
+
* NOTE: The `key` property refers to the original registry entry.
|
|
19
|
+
*/
|
|
20
|
+
// TODO(burdon): Create Format type for DXN-like ids, such as this and schema type.
|
|
21
|
+
// TODO(dmaretskyi): Consider making it part of ECHO meta.
|
|
22
|
+
// TODO(dmaretskyi): Make required.
|
|
23
|
+
key: Schema.optional(Schema.String).annotations({
|
|
24
|
+
description: 'Unique registration key for the blueprint',
|
|
25
|
+
}),
|
|
26
|
+
|
|
27
|
+
name: Schema.NonEmptyString,
|
|
28
|
+
version: Schema.String,
|
|
29
|
+
|
|
30
|
+
description: Schema.optional(Schema.String),
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* ISO date string of the last deployment.
|
|
34
|
+
*/
|
|
35
|
+
updated: Schema.optional(Schema.String),
|
|
36
|
+
|
|
37
|
+
// Reference to a source script if it exists within ECHO.
|
|
38
|
+
// TODO(burdon): Don't ref ScriptType directly (core).
|
|
39
|
+
source: Schema.optional(Type.Ref(Script)),
|
|
40
|
+
|
|
41
|
+
inputSchema: Schema.optional(JsonSchema.JsonSchema),
|
|
42
|
+
outputSchema: Schema.optional(JsonSchema.JsonSchema),
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* List of required services.
|
|
46
|
+
* Match the Context.Tag keys of the FunctionServices variants.
|
|
47
|
+
*/
|
|
48
|
+
services: Schema.optional(Schema.Array(Schema.String)),
|
|
49
|
+
|
|
50
|
+
// Local binding to a function name.
|
|
51
|
+
binding: Schema.optional(Schema.String),
|
|
52
|
+
}).pipe(
|
|
53
|
+
Type.Obj({
|
|
54
|
+
typename: 'dxos.org/type/Function',
|
|
55
|
+
version: '0.1.0',
|
|
56
|
+
}),
|
|
57
|
+
Annotation.LabelAnnotation.set(['name']),
|
|
58
|
+
SystemTypeAnnotation.set(true),
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
export interface Function extends Schema.Schema.Type<typeof Function> {}
|
|
62
|
+
|
|
63
|
+
export const make = (props: Obj.MakeProps<typeof Function>) => Obj.make(Function, props);
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Copies properties from source to target.
|
|
67
|
+
* @param target - Target object to copy properties to.
|
|
68
|
+
* @param source - Source object to copy properties from.
|
|
69
|
+
*/
|
|
70
|
+
export const setFrom = (target: Function, source: Function) => {
|
|
71
|
+
target.key = source.key ?? target.key;
|
|
72
|
+
target.name = source.name ?? target.name;
|
|
73
|
+
target.version = source.version;
|
|
74
|
+
target.description = source.description;
|
|
75
|
+
target.updated = source.updated;
|
|
76
|
+
// TODO(dmaretskyi): A workaround for an ECHO bug.
|
|
77
|
+
target.inputSchema = source.inputSchema ? JSON.parse(JSON.stringify(source.inputSchema)) : undefined;
|
|
78
|
+
target.outputSchema = source.outputSchema ? JSON.parse(JSON.stringify(source.outputSchema)) : undefined;
|
|
79
|
+
Obj.getMeta(target).keys = JSON.parse(JSON.stringify(Obj.getMeta(source).keys));
|
|
80
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
7
|
+
import { Annotation, Obj, Ref, Type } from '@dxos/echo';
|
|
8
|
+
import { FormInputAnnotation } from '@dxos/echo/internal';
|
|
9
|
+
import { Text } from '@dxos/schema';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Source script.
|
|
13
|
+
*/
|
|
14
|
+
export const Script = Schema.Struct({
|
|
15
|
+
name: Schema.String.pipe(Schema.optional),
|
|
16
|
+
description: Schema.String.pipe(Schema.optional),
|
|
17
|
+
// TODO(burdon): Change to hash of deployed content.
|
|
18
|
+
// Whether source has changed since last deploy.
|
|
19
|
+
changed: Schema.Boolean.pipe(FormInputAnnotation.set(false), Schema.optional),
|
|
20
|
+
source: Type.Ref(Text.Text).pipe(FormInputAnnotation.set(false)),
|
|
21
|
+
}).pipe(
|
|
22
|
+
Type.Obj({
|
|
23
|
+
typename: 'dxos.org/type/Script',
|
|
24
|
+
version: '0.1.0',
|
|
25
|
+
}),
|
|
26
|
+
Annotation.LabelAnnotation.set(['name']),
|
|
27
|
+
);
|
|
28
|
+
export interface Script extends Schema.Schema.Type<typeof Script> {}
|
|
29
|
+
|
|
30
|
+
type Props = Omit<Obj.MakeProps<typeof Script>, 'source'> & { source?: string };
|
|
31
|
+
|
|
32
|
+
export const make = ({ source = '', ...props }: Props = {}) =>
|
|
33
|
+
Obj.make(Script, { ...props, source: Ref.make(Text.make(source)) });
|