@dxos/functions 0.8.1 → 0.8.2-main.10c050d
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/bundler/index.mjs +0 -3
- package/dist/lib/browser/bundler/index.mjs.map +3 -3
- package/dist/lib/browser/edge/index.mjs +63 -7
- package/dist/lib/browser/edge/index.mjs.map +4 -4
- package/dist/lib/browser/index.mjs +513 -100
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/bundler/index.cjs +0 -1
- package/dist/lib/node/bundler/index.cjs.map +3 -3
- package/dist/lib/node/edge/index.cjs +65 -5
- package/dist/lib/node/edge/index.cjs.map +4 -4
- package/dist/lib/node/index.cjs +519 -92
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/bundler/index.mjs +0 -1
- package/dist/lib/node-esm/bundler/index.mjs.map +3 -3
- package/dist/lib/node-esm/edge/index.mjs +64 -6
- package/dist/lib/node-esm/edge/index.mjs.map +4 -4
- package/dist/lib/node-esm/index.mjs +513 -98
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/bundler/bundler.d.ts.map +1 -1
- package/dist/types/src/edge/functions.d.ts +3 -3
- package/dist/types/src/edge/functions.d.ts.map +1 -1
- package/dist/types/src/edge/index.d.ts.map +1 -1
- package/dist/types/src/executor/executor.d.ts +8 -0
- package/dist/types/src/executor/executor.d.ts.map +1 -0
- package/dist/types/src/executor/index.d.ts +2 -0
- package/dist/types/src/executor/index.d.ts.map +1 -0
- package/dist/types/src/handler.d.ts +23 -67
- package/dist/types/src/handler.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +5 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/schema.d.ts +57 -0
- package/dist/types/src/schema.d.ts.map +1 -0
- package/dist/types/src/services/ai.d.ts +9 -0
- package/dist/types/src/services/ai.d.ts.map +1 -0
- package/dist/types/src/services/credentials.d.ts +30 -0
- package/dist/types/src/services/credentials.d.ts.map +1 -0
- package/dist/types/src/services/database.d.ts +9 -0
- package/dist/types/src/services/database.d.ts.map +1 -0
- package/dist/types/src/services/index.d.ts +7 -0
- package/dist/types/src/services/index.d.ts.map +1 -0
- package/dist/types/src/services/queues.d.ts +10 -0
- package/dist/types/src/services/queues.d.ts.map +1 -0
- package/dist/types/src/services/service-container.d.ts +25 -0
- package/dist/types/src/services/service-container.d.ts.map +1 -0
- package/dist/types/src/services/tracing.d.ts +15 -0
- package/dist/types/src/services/tracing.d.ts.map +1 -0
- package/dist/types/src/trace.d.ts +149 -0
- package/dist/types/src/trace.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +2 -1
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +407 -0
- package/dist/types/src/types.d.ts.map +1 -0
- package/dist/types/src/{types/url.d.ts → url.d.ts} +6 -0
- package/dist/types/src/url.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +21 -36
- package/src/bundler/bundler.ts +7 -1
- package/src/edge/functions.ts +7 -4
- package/src/edge/index.ts +4 -0
- package/src/executor/executor.ts +47 -0
- package/src/executor/index.ts +5 -0
- package/src/handler.ts +29 -125
- package/src/index.ts +8 -5
- package/src/schema.ts +52 -0
- package/src/services/ai.ts +15 -0
- package/src/services/credentials.ts +55 -0
- package/src/services/database.ts +14 -0
- package/src/services/index.ts +10 -0
- package/src/services/queues.ts +16 -0
- package/src/services/service-container.ts +58 -0
- package/src/services/tracing.ts +27 -0
- package/src/{types/trace.ts → trace.ts} +37 -35
- package/src/translations.ts +1 -1
- package/src/types.ts +211 -0
- package/src/{types/url.ts → url.ts} +5 -0
- package/dist/lib/browser/chunk-HI7YZO2K.mjs +0 -482
- package/dist/lib/browser/chunk-HI7YZO2K.mjs.map +0 -7
- package/dist/lib/browser/chunk-LT4LR4VU.mjs +0 -72
- package/dist/lib/browser/chunk-LT4LR4VU.mjs.map +0 -7
- package/dist/lib/browser/chunk-RVSG6WTL.mjs +0 -358
- package/dist/lib/browser/chunk-RVSG6WTL.mjs.map +0 -7
- package/dist/lib/browser/chunk-XRCXIG74.mjs +0 -12
- package/dist/lib/browser/chunk-XRCXIG74.mjs.map +0 -7
- package/dist/lib/browser/testing/index.mjs +0 -670
- package/dist/lib/browser/testing/index.mjs.map +0 -7
- package/dist/lib/browser/types/index.mjs +0 -49
- package/dist/lib/browser/types/index.mjs.map +0 -7
- package/dist/lib/node/chunk-DSUGRAAL.cjs +0 -392
- package/dist/lib/node/chunk-DSUGRAAL.cjs.map +0 -7
- package/dist/lib/node/chunk-JEQ2X3Z6.cjs +0 -34
- package/dist/lib/node/chunk-JEQ2X3Z6.cjs.map +0 -7
- package/dist/lib/node/chunk-NXZNXVT3.cjs +0 -94
- package/dist/lib/node/chunk-NXZNXVT3.cjs.map +0 -7
- package/dist/lib/node/chunk-RXMCVAMJ.cjs +0 -496
- package/dist/lib/node/chunk-RXMCVAMJ.cjs.map +0 -7
- package/dist/lib/node/testing/index.cjs +0 -687
- package/dist/lib/node/testing/index.cjs.map +0 -7
- package/dist/lib/node/types/index.cjs +0 -70
- package/dist/lib/node/types/index.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-DHGBFXSZ.mjs +0 -12
- package/dist/lib/node-esm/chunk-DHGBFXSZ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HBD2FZXO.mjs +0 -358
- package/dist/lib/node-esm/chunk-HBD2FZXO.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-O2SXVYU5.mjs +0 -72
- package/dist/lib/node-esm/chunk-O2SXVYU5.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SQSJO5HI.mjs +0 -482
- package/dist/lib/node-esm/chunk-SQSJO5HI.mjs.map +0 -7
- package/dist/lib/node-esm/testing/index.mjs +0 -670
- package/dist/lib/node-esm/testing/index.mjs.map +0 -7
- package/dist/lib/node-esm/types/index.mjs +0 -49
- package/dist/lib/node-esm/types/index.mjs.map +0 -7
- package/dist/types/src/browser/index.d.ts +0 -2
- package/dist/types/src/browser/index.d.ts.map +0 -1
- package/dist/types/src/function/function-registry.d.ts +0 -25
- package/dist/types/src/function/function-registry.d.ts.map +0 -1
- package/dist/types/src/function/function-registry.test.d.ts +0 -2
- package/dist/types/src/function/function-registry.test.d.ts.map +0 -1
- package/dist/types/src/function/index.d.ts +0 -2
- package/dist/types/src/function/index.d.ts.map +0 -1
- package/dist/types/src/runtime/dev-server.d.ts +0 -52
- package/dist/types/src/runtime/dev-server.d.ts.map +0 -1
- package/dist/types/src/runtime/dev-server.test.d.ts +0 -2
- package/dist/types/src/runtime/dev-server.test.d.ts.map +0 -1
- package/dist/types/src/runtime/index.d.ts +0 -3
- package/dist/types/src/runtime/index.d.ts.map +0 -1
- package/dist/types/src/runtime/scheduler.d.ts +0 -34
- package/dist/types/src/runtime/scheduler.d.ts.map +0 -1
- package/dist/types/src/runtime/scheduler.test.d.ts +0 -2
- package/dist/types/src/runtime/scheduler.test.d.ts.map +0 -1
- package/dist/types/src/testing/functions-integration.test.d.ts +0 -2
- package/dist/types/src/testing/functions-integration.test.d.ts.map +0 -1
- package/dist/types/src/testing/index.d.ts +0 -5
- package/dist/types/src/testing/index.d.ts.map +0 -1
- package/dist/types/src/testing/manifest.d.ts +0 -3
- package/dist/types/src/testing/manifest.d.ts.map +0 -1
- package/dist/types/src/testing/plugin-init.d.ts +0 -6
- package/dist/types/src/testing/plugin-init.d.ts.map +0 -1
- package/dist/types/src/testing/setup.d.ts +0 -15
- package/dist/types/src/testing/setup.d.ts.map +0 -1
- package/dist/types/src/testing/test/handler.d.ts +0 -4
- package/dist/types/src/testing/test/handler.d.ts.map +0 -1
- package/dist/types/src/testing/test/index.d.ts +0 -3
- package/dist/types/src/testing/test/index.d.ts.map +0 -1
- package/dist/types/src/testing/types.d.ts +0 -10
- package/dist/types/src/testing/types.d.ts.map +0 -1
- package/dist/types/src/testing/util.d.ts +0 -5
- package/dist/types/src/testing/util.d.ts.map +0 -1
- package/dist/types/src/trigger/index.d.ts +0 -3
- package/dist/types/src/trigger/index.d.ts.map +0 -1
- package/dist/types/src/trigger/trigger-registry.d.ts +0 -38
- package/dist/types/src/trigger/trigger-registry.d.ts.map +0 -1
- package/dist/types/src/trigger/trigger-registry.test.d.ts +0 -2
- package/dist/types/src/trigger/trigger-registry.test.d.ts.map +0 -1
- package/dist/types/src/trigger/type/index.d.ts +0 -3
- package/dist/types/src/trigger/type/index.d.ts.map +0 -1
- package/dist/types/src/trigger/type/subscription-trigger.d.ts +0 -4
- package/dist/types/src/trigger/type/subscription-trigger.d.ts.map +0 -1
- package/dist/types/src/trigger/type/timer-trigger.d.ts +0 -4
- package/dist/types/src/trigger/type/timer-trigger.d.ts.map +0 -1
- package/dist/types/src/trigger/type/webhook-trigger.d.ts +0 -4
- package/dist/types/src/trigger/type/webhook-trigger.d.ts.map +0 -1
- package/dist/types/src/types/index.d.ts +0 -5
- package/dist/types/src/types/index.d.ts.map +0 -1
- package/dist/types/src/types/schema.d.ts +0 -53
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/dist/types/src/types/trace.d.ts +0 -146
- package/dist/types/src/types/trace.d.ts.map +0 -1
- package/dist/types/src/types/types.d.ts +0 -265
- package/dist/types/src/types/types.d.ts.map +0 -1
- package/dist/types/src/types/url.d.ts.map +0 -1
- package/dist/types/tools/schema.d.ts +0 -2
- package/dist/types/tools/schema.d.ts.map +0 -1
- package/schema/functions.json +0 -211
- package/src/browser/index.ts +0 -5
- package/src/function/function-registry.test.ts +0 -118
- package/src/function/function-registry.ts +0 -104
- package/src/function/index.ts +0 -5
- package/src/runtime/dev-server.test.ts +0 -79
- package/src/runtime/dev-server.ts +0 -240
- package/src/runtime/index.ts +0 -6
- package/src/runtime/scheduler.test.ts +0 -152
- package/src/runtime/scheduler.ts +0 -170
- package/src/testing/functions-integration.test.ts +0 -65
- package/src/testing/index.ts +0 -8
- package/src/testing/manifest.ts +0 -15
- package/src/testing/plugin-init.ts +0 -20
- package/src/testing/setup.ts +0 -109
- package/src/testing/test/handler.ts +0 -15
- package/src/testing/test/index.ts +0 -7
- package/src/testing/types.ts +0 -9
- package/src/testing/util.ts +0 -26
- package/src/trigger/index.ts +0 -6
- package/src/trigger/trigger-registry.test.ts +0 -278
- package/src/trigger/trigger-registry.ts +0 -218
- package/src/trigger/type/index.ts +0 -7
- package/src/trigger/type/subscription-trigger.ts +0 -84
- package/src/trigger/type/timer-trigger.ts +0 -48
- package/src/trigger/type/webhook-trigger.ts +0 -48
- package/src/types/index.ts +0 -8
- package/src/types/schema.ts +0 -46
- package/src/types/types.ts +0 -163
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
import { Schema } from 'effect';
|
|
2
|
+
import { Expando, Ref } from '@dxos/echo-schema';
|
|
3
|
+
import { FunctionType } from './schema';
|
|
4
|
+
/**
|
|
5
|
+
* Type discriminator for TriggerType.
|
|
6
|
+
* Every spec has a type field of type TriggerKind that we can use to understand which type we're working with.
|
|
7
|
+
* https://www.typescriptlang.org/docs/handbook/2/narrowing.html#discriminated-unions
|
|
8
|
+
*/
|
|
9
|
+
export declare enum TriggerKind {
|
|
10
|
+
Timer = "timer",
|
|
11
|
+
Webhook = "webhook",
|
|
12
|
+
Subscription = "subscription",
|
|
13
|
+
Email = "email",
|
|
14
|
+
Queue = "queue"
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Cron timer.
|
|
18
|
+
*/
|
|
19
|
+
declare const TimerTriggerSchema: Schema.mutable<Schema.Struct<{
|
|
20
|
+
kind: Schema.Literal<[TriggerKind.Timer]>;
|
|
21
|
+
cron: Schema.SchemaClass<string, string, never>;
|
|
22
|
+
}>>;
|
|
23
|
+
export type TimerTrigger = Schema.Schema.Type<typeof TimerTriggerSchema>;
|
|
24
|
+
declare const EmailTriggerSchema: Schema.mutable<Schema.Struct<{
|
|
25
|
+
kind: Schema.Literal<[TriggerKind.Email]>;
|
|
26
|
+
}>>;
|
|
27
|
+
export type EmailTrigger = Schema.Schema.Type<typeof EmailTriggerSchema>;
|
|
28
|
+
declare const QueueTriggerSchema: Schema.mutable<Schema.Struct<{
|
|
29
|
+
kind: Schema.Literal<[TriggerKind.Queue]>;
|
|
30
|
+
queue: Schema.refine<string, typeof Schema.NonEmptyString>;
|
|
31
|
+
}>>;
|
|
32
|
+
export type QueueTrigger = Schema.Schema.Type<typeof QueueTriggerSchema>;
|
|
33
|
+
/**
|
|
34
|
+
* Webhook.
|
|
35
|
+
*/
|
|
36
|
+
declare const WebhookTriggerSchema: Schema.mutable<Schema.Struct<{
|
|
37
|
+
kind: Schema.Literal<[TriggerKind.Webhook]>;
|
|
38
|
+
method: Schema.optional<Schema.SchemaClass<string, string, never>>;
|
|
39
|
+
port: Schema.optional<Schema.SchemaClass<number, number, never>>;
|
|
40
|
+
}>>;
|
|
41
|
+
export type WebhookTrigger = Schema.Schema.Type<typeof WebhookTriggerSchema>;
|
|
42
|
+
/**
|
|
43
|
+
* Subscription.
|
|
44
|
+
*/
|
|
45
|
+
declare const SubscriptionTriggerSchema: Schema.mutable<Schema.Struct<{
|
|
46
|
+
kind: Schema.Literal<[TriggerKind.Subscription]>;
|
|
47
|
+
filter: Schema.Struct<{
|
|
48
|
+
type: Schema.optional<Schema.SchemaClass<string, string, never>>;
|
|
49
|
+
props: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Any>>;
|
|
50
|
+
}>;
|
|
51
|
+
options: Schema.optional<Schema.Struct<{
|
|
52
|
+
deep: Schema.optional<Schema.SchemaClass<boolean, boolean, never>>;
|
|
53
|
+
delay: Schema.optional<Schema.SchemaClass<number, number, never>>;
|
|
54
|
+
}>>;
|
|
55
|
+
}>>;
|
|
56
|
+
export type SubscriptionTrigger = Schema.Schema.Type<typeof SubscriptionTriggerSchema>;
|
|
57
|
+
/**
|
|
58
|
+
* Trigger schema (discriminated union).
|
|
59
|
+
*/
|
|
60
|
+
export declare const TriggerSchema: Schema.Union<[Schema.mutable<Schema.Struct<{
|
|
61
|
+
kind: Schema.Literal<[TriggerKind.Timer]>;
|
|
62
|
+
cron: Schema.SchemaClass<string, string, never>;
|
|
63
|
+
}>>, Schema.mutable<Schema.Struct<{
|
|
64
|
+
kind: Schema.Literal<[TriggerKind.Webhook]>;
|
|
65
|
+
method: Schema.optional<Schema.SchemaClass<string, string, never>>;
|
|
66
|
+
port: Schema.optional<Schema.SchemaClass<number, number, never>>;
|
|
67
|
+
}>>, Schema.mutable<Schema.Struct<{
|
|
68
|
+
kind: Schema.Literal<[TriggerKind.Subscription]>;
|
|
69
|
+
filter: Schema.Struct<{
|
|
70
|
+
type: Schema.optional<Schema.SchemaClass<string, string, never>>;
|
|
71
|
+
props: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Any>>;
|
|
72
|
+
}>;
|
|
73
|
+
options: Schema.optional<Schema.Struct<{
|
|
74
|
+
deep: Schema.optional<Schema.SchemaClass<boolean, boolean, never>>;
|
|
75
|
+
delay: Schema.optional<Schema.SchemaClass<number, number, never>>;
|
|
76
|
+
}>>;
|
|
77
|
+
}>>, Schema.mutable<Schema.Struct<{
|
|
78
|
+
kind: Schema.Literal<[TriggerKind.Email]>;
|
|
79
|
+
}>>, Schema.mutable<Schema.Struct<{
|
|
80
|
+
kind: Schema.Literal<[TriggerKind.Queue]>;
|
|
81
|
+
queue: Schema.refine<string, typeof Schema.NonEmptyString>;
|
|
82
|
+
}>>]>;
|
|
83
|
+
export type TriggerType = Schema.Schema.Type<typeof TriggerSchema>;
|
|
84
|
+
export type EventType = EmailTriggerOutput | WebhookTriggerOutput | QueueTriggerOutput | SubscriptionTriggerOutput | TimerTriggerOutput;
|
|
85
|
+
export declare const EmailTriggerOutput: Schema.mutable<Schema.Struct<{
|
|
86
|
+
from: typeof Schema.String;
|
|
87
|
+
to: typeof Schema.String;
|
|
88
|
+
subject: typeof Schema.String;
|
|
89
|
+
created: typeof Schema.String;
|
|
90
|
+
body: typeof Schema.String;
|
|
91
|
+
}>>;
|
|
92
|
+
export type EmailTriggerOutput = Schema.Schema.Type<typeof EmailTriggerOutput>;
|
|
93
|
+
export declare const WebhookTriggerOutput: Schema.mutable<Schema.Struct<{
|
|
94
|
+
url: typeof Schema.String;
|
|
95
|
+
method: Schema.Literal<["GET", "POST"]>;
|
|
96
|
+
headers: Schema.Record$<typeof Schema.String, typeof Schema.String>;
|
|
97
|
+
bodyText: typeof Schema.String;
|
|
98
|
+
}>>;
|
|
99
|
+
export type WebhookTriggerOutput = Schema.Schema.Type<typeof WebhookTriggerOutput>;
|
|
100
|
+
export declare const QueueTriggerOutput: Schema.mutable<Schema.Struct<{
|
|
101
|
+
queue: Schema.refine<string, typeof Schema.NonEmptyString>;
|
|
102
|
+
item: typeof Schema.Any;
|
|
103
|
+
cursor: typeof Schema.String;
|
|
104
|
+
}>>;
|
|
105
|
+
export type QueueTriggerOutput = Schema.Schema.Type<typeof QueueTriggerOutput>;
|
|
106
|
+
export declare const SubscriptionTriggerOutput: Schema.mutable<Schema.Struct<{
|
|
107
|
+
type: typeof Schema.String;
|
|
108
|
+
changedObjectId: typeof Schema.String;
|
|
109
|
+
}>>;
|
|
110
|
+
export type SubscriptionTriggerOutput = Schema.Schema.Type<typeof SubscriptionTriggerOutput>;
|
|
111
|
+
export declare const TimerTriggerOutput: Schema.mutable<Schema.Struct<{
|
|
112
|
+
tick: typeof Schema.Number;
|
|
113
|
+
}>>;
|
|
114
|
+
export type TimerTriggerOutput = Schema.Schema.Type<typeof TimerTriggerOutput>;
|
|
115
|
+
/**
|
|
116
|
+
* Function trigger.
|
|
117
|
+
* Function is invoked with the `payload` passed as input data.
|
|
118
|
+
* The event that triggers the function is available in the function context.
|
|
119
|
+
*/
|
|
120
|
+
export declare const FunctionTriggerSchema: Schema.Struct<{
|
|
121
|
+
/**
|
|
122
|
+
* Function or workflow to invoke.
|
|
123
|
+
*/
|
|
124
|
+
function: Schema.optional<Schema.SchemaClass<Ref<Expando>, import("@dxos/echo-protocol").EncodedReference, never>>;
|
|
125
|
+
/**
|
|
126
|
+
* Only used for workflowSchema.
|
|
127
|
+
* Specifies the input node in the circuit.
|
|
128
|
+
* @deprecated Remove and enforce a single input node in all compute graphSchema.
|
|
129
|
+
*/
|
|
130
|
+
inputNodeId: Schema.optional<Schema.SchemaClass<string, string, never>>;
|
|
131
|
+
enabled: Schema.optional<Schema.SchemaClass<boolean, boolean, never>>;
|
|
132
|
+
spec: Schema.optional<Schema.Union<[Schema.mutable<Schema.Struct<{
|
|
133
|
+
kind: Schema.Literal<[TriggerKind.Timer]>;
|
|
134
|
+
cron: Schema.SchemaClass<string, string, never>;
|
|
135
|
+
}>>, Schema.mutable<Schema.Struct<{
|
|
136
|
+
kind: Schema.Literal<[TriggerKind.Webhook]>;
|
|
137
|
+
method: Schema.optional<Schema.SchemaClass<string, string, never>>;
|
|
138
|
+
port: Schema.optional<Schema.SchemaClass<number, number, never>>;
|
|
139
|
+
}>>, Schema.mutable<Schema.Struct<{
|
|
140
|
+
kind: Schema.Literal<[TriggerKind.Subscription]>;
|
|
141
|
+
filter: Schema.Struct<{
|
|
142
|
+
type: Schema.optional<Schema.SchemaClass<string, string, never>>;
|
|
143
|
+
props: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Any>>;
|
|
144
|
+
}>;
|
|
145
|
+
options: Schema.optional<Schema.Struct<{
|
|
146
|
+
deep: Schema.optional<Schema.SchemaClass<boolean, boolean, never>>;
|
|
147
|
+
delay: Schema.optional<Schema.SchemaClass<number, number, never>>;
|
|
148
|
+
}>>;
|
|
149
|
+
}>>, Schema.mutable<Schema.Struct<{
|
|
150
|
+
kind: Schema.Literal<[TriggerKind.Email]>;
|
|
151
|
+
}>>, Schema.mutable<Schema.Struct<{
|
|
152
|
+
kind: Schema.Literal<[TriggerKind.Queue]>;
|
|
153
|
+
queue: Schema.refine<string, typeof Schema.NonEmptyString>;
|
|
154
|
+
}>>]>>;
|
|
155
|
+
/**
|
|
156
|
+
* Passed as the input data to the function.
|
|
157
|
+
* Must match the function's input schema.
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* {
|
|
161
|
+
* item: '{{$.trigger.event}}',
|
|
162
|
+
* instructions: 'Summarize and perform entity-extraction'
|
|
163
|
+
* mailbox: { '/': 'dxn:echo:AAA:ZZZ' }
|
|
164
|
+
* }
|
|
165
|
+
*/
|
|
166
|
+
input: Schema.optional<Schema.mutable<Schema.Record$<typeof Schema.String, typeof Schema.Any>>>;
|
|
167
|
+
}>;
|
|
168
|
+
export type FunctionTriggerType = Schema.Schema.Type<typeof FunctionTriggerSchema>;
|
|
169
|
+
declare const FunctionTrigger_base: import("@dxos/echo-schema").TypedObjectPrototype<import("@dxos/echo-schema").TypedObjectFields<Readonly<{
|
|
170
|
+
/**
|
|
171
|
+
* Function or workflow to invoke.
|
|
172
|
+
*/
|
|
173
|
+
function: Schema.optional<Schema.SchemaClass<Ref<Expando>, import("@dxos/echo-protocol").EncodedReference, never>>;
|
|
174
|
+
/**
|
|
175
|
+
* Only used for workflowSchema.
|
|
176
|
+
* Specifies the input node in the circuit.
|
|
177
|
+
* @deprecated Remove and enforce a single input node in all compute graphSchema.
|
|
178
|
+
*/
|
|
179
|
+
inputNodeId: Schema.optional<Schema.SchemaClass<string, string, never>>;
|
|
180
|
+
enabled: Schema.optional<Schema.SchemaClass<boolean, boolean, never>>;
|
|
181
|
+
spec: Schema.optional<Schema.Union<[Schema.mutable<Schema.Struct<{
|
|
182
|
+
kind: Schema.Literal<[TriggerKind.Timer]>;
|
|
183
|
+
cron: Schema.SchemaClass<string, string, never>;
|
|
184
|
+
}>>, Schema.mutable<Schema.Struct<{
|
|
185
|
+
kind: Schema.Literal<[TriggerKind.Webhook]>;
|
|
186
|
+
method: Schema.optional<Schema.SchemaClass<string, string, never>>;
|
|
187
|
+
port: Schema.optional<Schema.SchemaClass<number, number, never>>;
|
|
188
|
+
}>>, Schema.mutable<Schema.Struct<{
|
|
189
|
+
kind: Schema.Literal<[TriggerKind.Subscription]>;
|
|
190
|
+
filter: Schema.Struct<{
|
|
191
|
+
type: Schema.optional<Schema.SchemaClass<string, string, never>>;
|
|
192
|
+
props: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Any>>;
|
|
193
|
+
}>;
|
|
194
|
+
options: Schema.optional<Schema.Struct<{
|
|
195
|
+
deep: Schema.optional<Schema.SchemaClass<boolean, boolean, never>>;
|
|
196
|
+
delay: Schema.optional<Schema.SchemaClass<number, number, never>>;
|
|
197
|
+
}>>;
|
|
198
|
+
}>>, Schema.mutable<Schema.Struct<{
|
|
199
|
+
kind: Schema.Literal<[TriggerKind.Email]>;
|
|
200
|
+
}>>, Schema.mutable<Schema.Struct<{
|
|
201
|
+
kind: Schema.Literal<[TriggerKind.Queue]>;
|
|
202
|
+
queue: Schema.refine<string, typeof Schema.NonEmptyString>;
|
|
203
|
+
}>>]>>;
|
|
204
|
+
/**
|
|
205
|
+
* Passed as the input data to the function.
|
|
206
|
+
* Must match the function's input schema.
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
* {
|
|
210
|
+
* item: '{{$.trigger.event}}',
|
|
211
|
+
* instructions: 'Summarize and perform entity-extraction'
|
|
212
|
+
* mailbox: { '/': 'dxn:echo:AAA:ZZZ' }
|
|
213
|
+
* }
|
|
214
|
+
*/
|
|
215
|
+
input: Schema.optional<Schema.mutable<Schema.Record$<typeof Schema.String, typeof Schema.Any>>>;
|
|
216
|
+
}>, import("@dxos/echo-schema").TypedObjectOptions>, Schema.Struct.Encoded<Readonly<{
|
|
217
|
+
/**
|
|
218
|
+
* Function or workflow to invoke.
|
|
219
|
+
*/
|
|
220
|
+
function: Schema.optional<Schema.SchemaClass<Ref<Expando>, import("@dxos/echo-protocol").EncodedReference, never>>;
|
|
221
|
+
/**
|
|
222
|
+
* Only used for workflowSchema.
|
|
223
|
+
* Specifies the input node in the circuit.
|
|
224
|
+
* @deprecated Remove and enforce a single input node in all compute graphSchema.
|
|
225
|
+
*/
|
|
226
|
+
inputNodeId: Schema.optional<Schema.SchemaClass<string, string, never>>;
|
|
227
|
+
enabled: Schema.optional<Schema.SchemaClass<boolean, boolean, never>>;
|
|
228
|
+
spec: Schema.optional<Schema.Union<[Schema.mutable<Schema.Struct<{
|
|
229
|
+
kind: Schema.Literal<[TriggerKind.Timer]>;
|
|
230
|
+
cron: Schema.SchemaClass<string, string, never>;
|
|
231
|
+
}>>, Schema.mutable<Schema.Struct<{
|
|
232
|
+
kind: Schema.Literal<[TriggerKind.Webhook]>;
|
|
233
|
+
method: Schema.optional<Schema.SchemaClass<string, string, never>>;
|
|
234
|
+
port: Schema.optional<Schema.SchemaClass<number, number, never>>;
|
|
235
|
+
}>>, Schema.mutable<Schema.Struct<{
|
|
236
|
+
kind: Schema.Literal<[TriggerKind.Subscription]>;
|
|
237
|
+
filter: Schema.Struct<{
|
|
238
|
+
type: Schema.optional<Schema.SchemaClass<string, string, never>>;
|
|
239
|
+
props: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Any>>;
|
|
240
|
+
}>;
|
|
241
|
+
options: Schema.optional<Schema.Struct<{
|
|
242
|
+
deep: Schema.optional<Schema.SchemaClass<boolean, boolean, never>>;
|
|
243
|
+
delay: Schema.optional<Schema.SchemaClass<number, number, never>>;
|
|
244
|
+
}>>;
|
|
245
|
+
}>>, Schema.mutable<Schema.Struct<{
|
|
246
|
+
kind: Schema.Literal<[TriggerKind.Email]>;
|
|
247
|
+
}>>, Schema.mutable<Schema.Struct<{
|
|
248
|
+
kind: Schema.Literal<[TriggerKind.Queue]>;
|
|
249
|
+
queue: Schema.refine<string, typeof Schema.NonEmptyString>;
|
|
250
|
+
}>>]>>;
|
|
251
|
+
/**
|
|
252
|
+
* Passed as the input data to the function.
|
|
253
|
+
* Must match the function's input schema.
|
|
254
|
+
*
|
|
255
|
+
* @example
|
|
256
|
+
* {
|
|
257
|
+
* item: '{{$.trigger.event}}',
|
|
258
|
+
* instructions: 'Summarize and perform entity-extraction'
|
|
259
|
+
* mailbox: { '/': 'dxn:echo:AAA:ZZZ' }
|
|
260
|
+
* }
|
|
261
|
+
*/
|
|
262
|
+
input: Schema.optional<Schema.mutable<Schema.Record$<typeof Schema.String, typeof Schema.Any>>>;
|
|
263
|
+
}>>>;
|
|
264
|
+
/**
|
|
265
|
+
* Function trigger.
|
|
266
|
+
*/
|
|
267
|
+
export declare class FunctionTrigger extends FunctionTrigger_base {
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Function manifest file.
|
|
271
|
+
*/
|
|
272
|
+
export declare const FunctionManifestSchema: Schema.Struct<{
|
|
273
|
+
functions: Schema.optional<Schema.mutable<Schema.Array$<Schema.Schema<import("@dxos/echo-schema").ExcludeId<import("@dxos/echo-schema").TypedObjectFields<{
|
|
274
|
+
name: typeof Schema.NonEmptyString;
|
|
275
|
+
version: typeof Schema.String;
|
|
276
|
+
description: Schema.optional<typeof Schema.String>;
|
|
277
|
+
source: Schema.optional<import("@dxos/echo-schema").Ref$<{
|
|
278
|
+
readonly id: string;
|
|
279
|
+
name?: string | undefined;
|
|
280
|
+
description?: string | undefined;
|
|
281
|
+
changed?: boolean | undefined;
|
|
282
|
+
source: Ref<{
|
|
283
|
+
readonly id: string;
|
|
284
|
+
content: string;
|
|
285
|
+
}>;
|
|
286
|
+
}>>;
|
|
287
|
+
inputSchema: Schema.optional<Schema.Schema<import("@dxos/echo-schema").JsonSchemaType, import("@dxos/echo-schema").JsonSchemaType, never>>;
|
|
288
|
+
outputSchema: Schema.optional<Schema.Schema<import("@dxos/echo-schema").JsonSchemaType, import("@dxos/echo-schema").JsonSchemaType, never>>;
|
|
289
|
+
binding: Schema.optional<typeof Schema.String>;
|
|
290
|
+
}, import("@dxos/echo-schema").TypedObjectOptions>> & import("@dxos/echo-schema").WithMeta, Schema.Struct.Encoded<{
|
|
291
|
+
name: typeof Schema.NonEmptyString;
|
|
292
|
+
version: typeof Schema.String;
|
|
293
|
+
description: Schema.optional<typeof Schema.String>;
|
|
294
|
+
source: Schema.optional<import("@dxos/echo-schema").Ref$<{
|
|
295
|
+
readonly id: string;
|
|
296
|
+
name?: string | undefined;
|
|
297
|
+
description?: string | undefined;
|
|
298
|
+
changed?: boolean | undefined;
|
|
299
|
+
source: Ref<{
|
|
300
|
+
readonly id: string;
|
|
301
|
+
content: string;
|
|
302
|
+
}>;
|
|
303
|
+
}>>;
|
|
304
|
+
inputSchema: Schema.optional<Schema.Schema<import("@dxos/echo-schema").JsonSchemaType, import("@dxos/echo-schema").JsonSchemaType, never>>;
|
|
305
|
+
outputSchema: Schema.optional<Schema.Schema<import("@dxos/echo-schema").JsonSchemaType, import("@dxos/echo-schema").JsonSchemaType, never>>;
|
|
306
|
+
binding: Schema.optional<typeof Schema.String>;
|
|
307
|
+
}>, never>>>>;
|
|
308
|
+
triggers: Schema.optional<Schema.mutable<Schema.Array$<Schema.Schema<import("@dxos/echo-schema").ExcludeId<import("@dxos/echo-schema").TypedObjectFields<Readonly<{
|
|
309
|
+
/**
|
|
310
|
+
* Function or workflow to invoke.
|
|
311
|
+
*/
|
|
312
|
+
function: Schema.optional<Schema.SchemaClass<Ref<Expando>, import("@dxos/echo-protocol").EncodedReference, never>>;
|
|
313
|
+
/**
|
|
314
|
+
* Only used for workflowSchema.
|
|
315
|
+
* Specifies the input node in the circuit.
|
|
316
|
+
* @deprecated Remove and enforce a single input node in all compute graphSchema.
|
|
317
|
+
*/
|
|
318
|
+
inputNodeId: Schema.optional<Schema.SchemaClass<string, string, never>>;
|
|
319
|
+
enabled: Schema.optional<Schema.SchemaClass<boolean, boolean, never>>;
|
|
320
|
+
spec: Schema.optional<Schema.Union<[Schema.mutable<Schema.Struct<{
|
|
321
|
+
kind: Schema.Literal<[TriggerKind.Timer]>;
|
|
322
|
+
cron: Schema.SchemaClass<string, string, never>;
|
|
323
|
+
}>>, Schema.mutable<Schema.Struct<{
|
|
324
|
+
kind: Schema.Literal<[TriggerKind.Webhook]>;
|
|
325
|
+
method: Schema.optional<Schema.SchemaClass<string, string, never>>;
|
|
326
|
+
port: Schema.optional<Schema.SchemaClass<number, number, never>>;
|
|
327
|
+
}>>, Schema.mutable<Schema.Struct<{
|
|
328
|
+
kind: Schema.Literal<[TriggerKind.Subscription]>;
|
|
329
|
+
filter: Schema.Struct<{
|
|
330
|
+
type: Schema.optional<Schema.SchemaClass<string, string, never>>;
|
|
331
|
+
props: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Any>>;
|
|
332
|
+
}>;
|
|
333
|
+
options: Schema.optional<Schema.Struct<{
|
|
334
|
+
deep: Schema.optional<Schema.SchemaClass<boolean, boolean, never>>;
|
|
335
|
+
delay: Schema.optional<Schema.SchemaClass<number, number, never>>;
|
|
336
|
+
}>>;
|
|
337
|
+
}>>, Schema.mutable<Schema.Struct<{
|
|
338
|
+
kind: Schema.Literal<[TriggerKind.Email]>;
|
|
339
|
+
}>>, Schema.mutable<Schema.Struct<{
|
|
340
|
+
kind: Schema.Literal<[TriggerKind.Queue]>;
|
|
341
|
+
queue: Schema.refine<string, typeof Schema.NonEmptyString>;
|
|
342
|
+
}>>]>>;
|
|
343
|
+
/**
|
|
344
|
+
* Passed as the input data to the function.
|
|
345
|
+
* Must match the function's input schema.
|
|
346
|
+
*
|
|
347
|
+
* @example
|
|
348
|
+
* {
|
|
349
|
+
* item: '{{$.trigger.event}}',
|
|
350
|
+
* instructions: 'Summarize and perform entity-extraction'
|
|
351
|
+
* mailbox: { '/': 'dxn:echo:AAA:ZZZ' }
|
|
352
|
+
* }
|
|
353
|
+
*/
|
|
354
|
+
input: Schema.optional<Schema.mutable<Schema.Record$<typeof Schema.String, typeof Schema.Any>>>;
|
|
355
|
+
}>, import("@dxos/echo-schema").TypedObjectOptions>> & import("@dxos/echo-schema").WithMeta, Schema.Struct.Encoded<Readonly<{
|
|
356
|
+
/**
|
|
357
|
+
* Function or workflow to invoke.
|
|
358
|
+
*/
|
|
359
|
+
function: Schema.optional<Schema.SchemaClass<Ref<Expando>, import("@dxos/echo-protocol").EncodedReference, never>>;
|
|
360
|
+
/**
|
|
361
|
+
* Only used for workflowSchema.
|
|
362
|
+
* Specifies the input node in the circuit.
|
|
363
|
+
* @deprecated Remove and enforce a single input node in all compute graphSchema.
|
|
364
|
+
*/
|
|
365
|
+
inputNodeId: Schema.optional<Schema.SchemaClass<string, string, never>>;
|
|
366
|
+
enabled: Schema.optional<Schema.SchemaClass<boolean, boolean, never>>;
|
|
367
|
+
spec: Schema.optional<Schema.Union<[Schema.mutable<Schema.Struct<{
|
|
368
|
+
kind: Schema.Literal<[TriggerKind.Timer]>;
|
|
369
|
+
cron: Schema.SchemaClass<string, string, never>;
|
|
370
|
+
}>>, Schema.mutable<Schema.Struct<{
|
|
371
|
+
kind: Schema.Literal<[TriggerKind.Webhook]>;
|
|
372
|
+
method: Schema.optional<Schema.SchemaClass<string, string, never>>;
|
|
373
|
+
port: Schema.optional<Schema.SchemaClass<number, number, never>>;
|
|
374
|
+
}>>, Schema.mutable<Schema.Struct<{
|
|
375
|
+
kind: Schema.Literal<[TriggerKind.Subscription]>;
|
|
376
|
+
filter: Schema.Struct<{
|
|
377
|
+
type: Schema.optional<Schema.SchemaClass<string, string, never>>;
|
|
378
|
+
props: Schema.optional<Schema.Record$<typeof Schema.String, typeof Schema.Any>>;
|
|
379
|
+
}>;
|
|
380
|
+
options: Schema.optional<Schema.Struct<{
|
|
381
|
+
deep: Schema.optional<Schema.SchemaClass<boolean, boolean, never>>;
|
|
382
|
+
delay: Schema.optional<Schema.SchemaClass<number, number, never>>;
|
|
383
|
+
}>>;
|
|
384
|
+
}>>, Schema.mutable<Schema.Struct<{
|
|
385
|
+
kind: Schema.Literal<[TriggerKind.Email]>;
|
|
386
|
+
}>>, Schema.mutable<Schema.Struct<{
|
|
387
|
+
kind: Schema.Literal<[TriggerKind.Queue]>;
|
|
388
|
+
queue: Schema.refine<string, typeof Schema.NonEmptyString>;
|
|
389
|
+
}>>]>>;
|
|
390
|
+
/**
|
|
391
|
+
* Passed as the input data to the function.
|
|
392
|
+
* Must match the function's input schema.
|
|
393
|
+
*
|
|
394
|
+
* @example
|
|
395
|
+
* {
|
|
396
|
+
* item: '{{$.trigger.event}}',
|
|
397
|
+
* instructions: 'Summarize and perform entity-extraction'
|
|
398
|
+
* mailbox: { '/': 'dxn:echo:AAA:ZZZ' }
|
|
399
|
+
* }
|
|
400
|
+
*/
|
|
401
|
+
input: Schema.optional<Schema.mutable<Schema.Record$<typeof Schema.String, typeof Schema.Any>>>;
|
|
402
|
+
}>>, never>>>>;
|
|
403
|
+
}>;
|
|
404
|
+
export type FunctionManifest = Schema.Schema.Type<typeof FunctionManifestSchema>;
|
|
405
|
+
export declare const FUNCTION_TYPES: (typeof FunctionType | typeof FunctionTrigger)[];
|
|
406
|
+
export {};
|
|
407
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"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"}
|
|
@@ -3,6 +3,12 @@ import { type SpaceId } from '@dxos/keys';
|
|
|
3
3
|
export declare const FUNCTIONS_PRESET_META_KEY = "dxos.org/service/function-preset";
|
|
4
4
|
export declare const getUserFunctionUrlInMetadata: (meta: ObjectMeta) => string | undefined;
|
|
5
5
|
export declare const setUserFunctionUrlInMetadata: (meta: ObjectMeta, functionUrl: string) => void;
|
|
6
|
+
/**
|
|
7
|
+
* NOTE: functionId is backend ID, not ECHO object id.
|
|
8
|
+
*/
|
|
9
|
+
export declare const makeFunctionUrl: (fn: {
|
|
10
|
+
functionId: string;
|
|
11
|
+
}) => string;
|
|
6
12
|
export declare const getInvocationUrl: (functionUrl: string, edgeUrl: string, options?: InvocationOptions) => string;
|
|
7
13
|
export type InvocationOptions = {
|
|
8
14
|
spaceId?: SpaceId;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../../src/url.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAK1C,eAAO,MAAM,yBAAyB,qCAAqC,CAAC;AAM5E,eAAO,MAAM,4BAA4B,GAAI,MAAM,UAAU,uBAE5D,CAAC;AAEF,eAAO,MAAM,4BAA4B,GAAI,MAAM,UAAU,EAAE,aAAa,MAAM,SASjF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,IAAI;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,WAAwB,CAAC;AAEnF,eAAO,MAAM,gBAAgB,GAAI,aAAa,MAAM,EAAE,SAAS,MAAM,EAAE,UAAS,iBAAsB,WAUrG,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"5.
|
|
1
|
+
{"version":"5.8.3"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/functions",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.2-main.10c050d",
|
|
4
4
|
"description": "Functions API and runtime.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -23,16 +23,6 @@
|
|
|
23
23
|
"types": "./dist/types/src/edge/index.d.ts",
|
|
24
24
|
"browser": "./dist/lib/browser/edge/index.mjs",
|
|
25
25
|
"node": "./dist/lib/node-esm/edge/index.mjs"
|
|
26
|
-
},
|
|
27
|
-
"./testing": {
|
|
28
|
-
"types": "./dist/types/src/testing/index.d.ts",
|
|
29
|
-
"browser": "./dist/lib/browser/testing/index.mjs",
|
|
30
|
-
"node": "./dist/lib/node-esm/testing/index.mjs"
|
|
31
|
-
},
|
|
32
|
-
"./types": {
|
|
33
|
-
"types": "./dist/types/src/types/index.d.ts",
|
|
34
|
-
"browser": "./dist/lib/browser/types/index.mjs",
|
|
35
|
-
"node": "./dist/lib/node-esm/types/index.mjs"
|
|
36
26
|
}
|
|
37
27
|
},
|
|
38
28
|
"types": "dist/types/src/index.d.ts",
|
|
@@ -43,12 +33,6 @@
|
|
|
43
33
|
],
|
|
44
34
|
"edge": [
|
|
45
35
|
"dist/types/src/edge/index.d.ts"
|
|
46
|
-
],
|
|
47
|
-
"testing": [
|
|
48
|
-
"dist/types/src/testing/index.d.ts"
|
|
49
|
-
],
|
|
50
|
-
"types": [
|
|
51
|
-
"dist/types/src/types/index.d.ts"
|
|
52
36
|
]
|
|
53
37
|
}
|
|
54
38
|
},
|
|
@@ -58,36 +42,37 @@
|
|
|
58
42
|
"src"
|
|
59
43
|
],
|
|
60
44
|
"dependencies": {
|
|
61
|
-
"@preact/signals-core": "^1.
|
|
45
|
+
"@preact/signals-core": "^1.9.0",
|
|
62
46
|
"cron": "^3.1.6",
|
|
63
47
|
"cron-schedule": "^5.0.4",
|
|
64
|
-
"effect": "3.
|
|
48
|
+
"effect": "3.14.21",
|
|
65
49
|
"esbuild-wasm": "^0.16.14",
|
|
66
50
|
"express": "^4.19.2",
|
|
67
51
|
"get-port-please": "^3.1.1",
|
|
68
52
|
"iso-did": "^1.6.0",
|
|
69
53
|
"ws": "^8.14.2",
|
|
70
|
-
"@dxos/
|
|
71
|
-
"@dxos/
|
|
72
|
-
"@dxos/context": "0.8.
|
|
73
|
-
"@dxos/crypto": "0.8.
|
|
74
|
-
"@dxos/
|
|
75
|
-
"@dxos/echo-
|
|
76
|
-
"@dxos/echo-
|
|
77
|
-
"@dxos/
|
|
78
|
-
"@dxos/
|
|
79
|
-
"@dxos/
|
|
80
|
-
"@dxos/keys": "0.8.
|
|
81
|
-
"@dxos/
|
|
82
|
-
"@dxos/
|
|
83
|
-
"@dxos/
|
|
84
|
-
"@dxos/
|
|
85
|
-
"@dxos/
|
|
54
|
+
"@dxos/ai": "0.8.2-main.10c050d",
|
|
55
|
+
"@dxos/async": "0.8.2-main.10c050d",
|
|
56
|
+
"@dxos/context": "0.8.2-main.10c050d",
|
|
57
|
+
"@dxos/crypto": "0.8.2-main.10c050d",
|
|
58
|
+
"@dxos/client": "0.8.2-main.10c050d",
|
|
59
|
+
"@dxos/echo-db": "0.8.2-main.10c050d",
|
|
60
|
+
"@dxos/echo-protocol": "0.8.2-main.10c050d",
|
|
61
|
+
"@dxos/echo-schema": "0.8.2-main.10c050d",
|
|
62
|
+
"@dxos/edge-client": "0.8.2-main.10c050d",
|
|
63
|
+
"@dxos/invariant": "0.8.2-main.10c050d",
|
|
64
|
+
"@dxos/keys": "0.8.2-main.10c050d",
|
|
65
|
+
"@dxos/live-object": "0.8.2-main.10c050d",
|
|
66
|
+
"@dxos/log": "0.8.2-main.10c050d",
|
|
67
|
+
"@dxos/node-std": "0.8.2-main.10c050d",
|
|
68
|
+
"@dxos/protocols": "0.8.2-main.10c050d",
|
|
69
|
+
"@dxos/schema": "0.8.2-main.10c050d",
|
|
70
|
+
"@dxos/util": "0.8.2-main.10c050d"
|
|
86
71
|
},
|
|
87
72
|
"devDependencies": {
|
|
88
73
|
"@types/express": "^4.17.17",
|
|
89
74
|
"@types/ws": "^7.4.0",
|
|
90
|
-
"@dxos/agent": "0.8.
|
|
75
|
+
"@dxos/agent": "0.8.2-main.10c050d"
|
|
91
76
|
},
|
|
92
77
|
"publishConfig": {
|
|
93
78
|
"access": "public"
|
package/src/bundler/bundler.ts
CHANGED
|
@@ -171,7 +171,13 @@ export class Bundler {
|
|
|
171
171
|
});
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
analyzeSourceFileImports(code: string) {
|
|
174
|
+
analyzeSourceFileImports(code: string): {
|
|
175
|
+
defaultImportName: string;
|
|
176
|
+
namedImports: string[];
|
|
177
|
+
wildcardImportName: string;
|
|
178
|
+
moduleIdentifier: string;
|
|
179
|
+
quotes: string;
|
|
180
|
+
}[] {
|
|
175
181
|
// TODO(dmaretskyi): Support import aliases and wildcard imports.
|
|
176
182
|
const parsedImports = allMatches(IMPORT_REGEX, code);
|
|
177
183
|
return parsedImports.map((capture) => {
|
package/src/edge/functions.ts
CHANGED
|
@@ -8,33 +8,36 @@ import { type Client } from '@dxos/client';
|
|
|
8
8
|
import { createEdgeIdentity } from '@dxos/client/edge';
|
|
9
9
|
import { EdgeHttpClient } from '@dxos/edge-client';
|
|
10
10
|
import { invariant } from '@dxos/invariant';
|
|
11
|
-
import type { PublicKey
|
|
11
|
+
import type { PublicKey } from '@dxos/keys';
|
|
12
12
|
import { log } from '@dxos/log';
|
|
13
13
|
import { type UploadFunctionResponseBody } from '@dxos/protocols';
|
|
14
14
|
|
|
15
15
|
export type UploadWorkerArgs = {
|
|
16
16
|
client: Client;
|
|
17
|
-
spaceId: SpaceId;
|
|
18
17
|
source: string;
|
|
19
18
|
version: string;
|
|
20
19
|
name?: string;
|
|
21
20
|
functionId?: string;
|
|
21
|
+
ownerPublicKey: PublicKey;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
export const uploadWorkerFunction = async ({
|
|
25
25
|
client,
|
|
26
|
-
spaceId,
|
|
27
26
|
version,
|
|
28
27
|
source,
|
|
29
28
|
name,
|
|
30
29
|
functionId,
|
|
30
|
+
ownerPublicKey,
|
|
31
31
|
}: UploadWorkerArgs): Promise<UploadFunctionResponseBody> => {
|
|
32
32
|
const edgeUrl = client.config.values.runtime?.services?.edge?.url;
|
|
33
33
|
invariant(edgeUrl, 'Edge is not configured.');
|
|
34
34
|
const edgeClient = new EdgeHttpClient(edgeUrl);
|
|
35
35
|
const edgeIdentity = createEdgeIdentity(client);
|
|
36
36
|
edgeClient.setIdentity(edgeIdentity);
|
|
37
|
-
const response = await edgeClient.uploadFunction(
|
|
37
|
+
const response = await edgeClient.uploadFunction(
|
|
38
|
+
{ functionId },
|
|
39
|
+
{ name, version, script: source, ownerPublicKey: ownerPublicKey.toHex() },
|
|
40
|
+
);
|
|
38
41
|
|
|
39
42
|
// TODO(burdon): Edge service log.
|
|
40
43
|
log.info('Uploaded', {
|
package/src/edge/index.ts
CHANGED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Effect, Schema } from 'effect';
|
|
6
|
+
|
|
7
|
+
import type { SpaceId } from '@dxos/client/echo';
|
|
8
|
+
|
|
9
|
+
import type { FunctionContext, FunctionDefinition } from '../handler';
|
|
10
|
+
import type { ServiceContainer } from '../services';
|
|
11
|
+
|
|
12
|
+
export class FunctionExecutor {
|
|
13
|
+
constructor(private readonly _services: ServiceContainer) {}
|
|
14
|
+
|
|
15
|
+
// TODO(dmaretskyi): Invocation context: queue, space, etc...
|
|
16
|
+
async invoke<F extends FunctionDefinition<any, any>>(
|
|
17
|
+
fnDef: F,
|
|
18
|
+
input: F extends FunctionDefinition<infer I, infer _O> ? I : never,
|
|
19
|
+
): Promise<F extends FunctionDefinition<infer _I, infer O> ? O : never> {
|
|
20
|
+
// Assert input matches schema
|
|
21
|
+
const assertInput = fnDef.inputSchema.pipe(Schema.asserts);
|
|
22
|
+
(assertInput as any)(input);
|
|
23
|
+
|
|
24
|
+
const context: FunctionContext = {
|
|
25
|
+
getService: this._services.getService.bind(this._services),
|
|
26
|
+
getSpace: async (_spaceId: SpaceId) => {
|
|
27
|
+
throw new Error('Not available. Use the database service instead.');
|
|
28
|
+
},
|
|
29
|
+
space: undefined,
|
|
30
|
+
get ai(): never {
|
|
31
|
+
throw new Error('Not available. Use the ai service instead.');
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const result = await fnDef.handler({ context, data: input });
|
|
36
|
+
|
|
37
|
+
// Assert output matches schema
|
|
38
|
+
const assertOutput = fnDef.outputSchema?.pipe(Schema.asserts);
|
|
39
|
+
(assertOutput as any)(result);
|
|
40
|
+
|
|
41
|
+
if (Effect.isEffect(result)) {
|
|
42
|
+
return Effect.runPromise(result as any);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return result as any;
|
|
46
|
+
}
|
|
47
|
+
}
|