@dxos/functions 0.5.3-main.495a683 → 0.5.3-main.4e877aa
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 +301 -282
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +303 -286
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/{function → registry}/function-registry.d.ts +4 -4
- package/dist/types/src/registry/function-registry.d.ts.map +1 -0
- package/dist/types/src/registry/function-registry.test.d.ts.map +1 -0
- package/dist/types/src/registry/index.d.ts.map +1 -0
- package/dist/types/src/runtime/dev-server.d.ts +1 -1
- package/dist/types/src/runtime/dev-server.d.ts.map +1 -1
- package/dist/types/src/runtime/scheduler.d.ts +1 -2
- package/dist/types/src/runtime/scheduler.d.ts.map +1 -1
- package/dist/types/src/trigger/trigger-registry.d.ts.map +1 -1
- package/dist/types/src/trigger/type/subscription-trigger.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +19 -33
- package/dist/types/src/types.d.ts.map +1 -1
- package/package.json +18 -31
- package/schema/functions.json +9 -18
- package/src/index.ts +1 -1
- package/src/{function → registry}/function-registry.test.ts +10 -10
- package/src/registry/function-registry.ts +84 -0
- package/src/runtime/dev-server.test.ts +2 -2
- package/src/runtime/dev-server.ts +6 -5
- package/src/runtime/scheduler.test.ts +1 -1
- package/src/runtime/scheduler.ts +8 -16
- package/src/testing/functions-integration.test.ts +1 -1
- package/src/testing/setup.ts +1 -1
- package/src/trigger/trigger-registry.test.ts +34 -60
- package/src/trigger/trigger-registry.ts +6 -19
- package/src/trigger/type/subscription-trigger.ts +10 -17
- package/src/types.ts +10 -12
- package/dist/lib/browser/chunk-366QG6IX.mjs +0 -81
- package/dist/lib/browser/chunk-366QG6IX.mjs.map +0 -7
- package/dist/lib/browser/types.mjs +0 -12
- package/dist/lib/browser/types.mjs.map +0 -7
- package/dist/lib/node/chunk-3VSJ57ZZ.cjs +0 -97
- package/dist/lib/node/chunk-3VSJ57ZZ.cjs.map +0 -7
- package/dist/lib/node/types.cjs +0 -33
- package/dist/lib/node/types.cjs.map +0 -7
- package/dist/types/src/function/function-registry.d.ts.map +0 -1
- package/dist/types/src/function/function-registry.test.d.ts.map +0 -1
- package/dist/types/src/function/index.d.ts.map +0 -1
- package/dist/types/src/util.d.ts +0 -15
- package/dist/types/src/util.d.ts.map +0 -1
- package/dist/types/src/util.test.d.ts +0 -2
- package/dist/types/src/util.test.d.ts.map +0 -1
- package/src/function/function-registry.ts +0 -90
- package/src/util.test.ts +0 -43
- package/src/util.ts +0 -48
- /package/dist/types/src/{function → registry}/function-registry.test.d.ts +0 -0
- /package/dist/types/src/{function → registry}/index.d.ts +0 -0
- /package/src/{function → registry}/index.ts +0 -0
|
@@ -11,7 +11,7 @@ import { type Space } from '@dxos/client/echo';
|
|
|
11
11
|
import { TestBuilder } from '@dxos/client/testing';
|
|
12
12
|
import { Context } from '@dxos/context';
|
|
13
13
|
import { Filter } from '@dxos/echo-db';
|
|
14
|
-
import { create
|
|
14
|
+
import { create } from '@dxos/echo-schema';
|
|
15
15
|
import { describe, test } from '@dxos/test';
|
|
16
16
|
import { range } from '@dxos/util';
|
|
17
17
|
|
|
@@ -19,17 +19,9 @@ import { TriggerRegistry } from './trigger-registry';
|
|
|
19
19
|
import { createInitializedClients, TestType, triggerWebhook } from '../testing';
|
|
20
20
|
import { type FunctionManifest, FunctionTrigger } from '../types';
|
|
21
21
|
|
|
22
|
-
const
|
|
22
|
+
const testManifest: FunctionManifest = {
|
|
23
23
|
triggers: [
|
|
24
24
|
{
|
|
25
|
-
'@meta': {
|
|
26
|
-
keys: [
|
|
27
|
-
{
|
|
28
|
-
source: 'example.com',
|
|
29
|
-
id: 'trigger-1',
|
|
30
|
-
},
|
|
31
|
-
],
|
|
32
|
-
},
|
|
33
25
|
function: 'example.com/function/webhook-test',
|
|
34
26
|
spec: {
|
|
35
27
|
type: 'webhook',
|
|
@@ -37,22 +29,10 @@ const manifest: FunctionManifest = {
|
|
|
37
29
|
},
|
|
38
30
|
},
|
|
39
31
|
{
|
|
40
|
-
'@meta': {
|
|
41
|
-
keys: [
|
|
42
|
-
{
|
|
43
|
-
source: 'example.com',
|
|
44
|
-
id: 'trigger-2',
|
|
45
|
-
},
|
|
46
|
-
],
|
|
47
|
-
},
|
|
48
32
|
function: 'example.com/function/subscription-test',
|
|
49
33
|
spec: {
|
|
50
34
|
type: 'subscription',
|
|
51
|
-
filter: [
|
|
52
|
-
{
|
|
53
|
-
type: TestType.typename,
|
|
54
|
-
},
|
|
55
|
-
],
|
|
35
|
+
filter: [{ type: TestType.typename }],
|
|
56
36
|
},
|
|
57
37
|
},
|
|
58
38
|
],
|
|
@@ -77,12 +57,11 @@ describe('trigger registry', () => {
|
|
|
77
57
|
const client = (await createInitializedClients(testBuilder))[0];
|
|
78
58
|
const registry = createRegistry(client);
|
|
79
59
|
const space = await client.spaces.create();
|
|
80
|
-
await registry.register(space,
|
|
60
|
+
await registry.register(space, testManifest);
|
|
81
61
|
const { objects } = await space.db.query(Filter.schema(FunctionTrigger)).run();
|
|
82
|
-
expect(objects.length).to.eq(
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
expect(objects.map((object: FunctionTrigger) => object.function).sort()).to.deep.eq(expected);
|
|
62
|
+
expect(objects.length).to.eq(testManifest.triggers?.length);
|
|
63
|
+
const expected = testManifest.triggers?.map((t) => t.function).sort();
|
|
64
|
+
expect(objects.map((o: FunctionTrigger) => o.function).sort()).to.deep.eq(expected);
|
|
86
65
|
});
|
|
87
66
|
});
|
|
88
67
|
|
|
@@ -91,13 +70,13 @@ describe('trigger registry', () => {
|
|
|
91
70
|
const client = (await createInitializedClients(testBuilder))[0];
|
|
92
71
|
const space = await client.spaces.create();
|
|
93
72
|
const registry = createRegistry(client);
|
|
94
|
-
await registry.register(space,
|
|
73
|
+
await registry.register(space, testManifest);
|
|
95
74
|
await registry.open(ctx);
|
|
96
|
-
await
|
|
75
|
+
await waitHasInactiveTriggers(registry, space);
|
|
97
76
|
|
|
98
77
|
const callbackInvoked = new Trigger();
|
|
99
78
|
const { objects: allTriggers } = await space.db.query(Filter.schema(FunctionTrigger)).run();
|
|
100
|
-
const webhookTrigger = allTriggers.find((
|
|
79
|
+
const webhookTrigger = allTriggers.find((t: FunctionTrigger) => t.spec.type === 'webhook')!;
|
|
101
80
|
await registry.activate({ space }, webhookTrigger, async () => {
|
|
102
81
|
callbackInvoked.wake();
|
|
103
82
|
return 200;
|
|
@@ -111,16 +90,15 @@ describe('trigger registry', () => {
|
|
|
111
90
|
const client = (await createInitializedClients(testBuilder))[0];
|
|
112
91
|
const space = await client.spaces.create();
|
|
113
92
|
const registry = createRegistry(client);
|
|
114
|
-
await registry.register(space,
|
|
93
|
+
await registry.register(space, testManifest);
|
|
115
94
|
await registry.open(ctx);
|
|
116
|
-
await
|
|
95
|
+
await waitHasInactiveTriggers(registry, space);
|
|
117
96
|
|
|
118
97
|
const inactiveTrigger = registry.getInactiveTriggers(space)[0];
|
|
119
98
|
await registry.activate({ space }, inactiveTrigger, async () => 200);
|
|
120
99
|
|
|
121
100
|
const updatedInactiveList = registry.getInactiveTriggers(space);
|
|
122
|
-
expect(updatedInactiveList.find((
|
|
123
|
-
.be.undefined;
|
|
101
|
+
expect(updatedInactiveList.find((t: FunctionTrigger) => t.function === inactiveTrigger.function)).to.be.undefined;
|
|
124
102
|
});
|
|
125
103
|
});
|
|
126
104
|
|
|
@@ -129,12 +107,12 @@ describe('trigger registry', () => {
|
|
|
129
107
|
const client = (await createInitializedClients(testBuilder))[0];
|
|
130
108
|
const space = await client.spaces.create();
|
|
131
109
|
const registry = createRegistry(client);
|
|
132
|
-
await registry.register(space,
|
|
110
|
+
await registry.register(space, testManifest);
|
|
133
111
|
await registry.open(ctx);
|
|
134
|
-
await
|
|
112
|
+
await waitHasInactiveTriggers(registry, space);
|
|
135
113
|
|
|
136
114
|
const { objects: allTriggers } = await space.db.query(Filter.schema(FunctionTrigger)).run();
|
|
137
|
-
const echoTrigger = allTriggers.find((
|
|
115
|
+
const echoTrigger = allTriggers.find((t: FunctionTrigger) => t.spec.type === 'subscription')!;
|
|
138
116
|
let count = 0;
|
|
139
117
|
await registry.activate({ space }, echoTrigger, async () => {
|
|
140
118
|
count++;
|
|
@@ -146,6 +124,7 @@ describe('trigger registry', () => {
|
|
|
146
124
|
expect(count).to.eq(1);
|
|
147
125
|
|
|
148
126
|
space.db.remove(echoTrigger);
|
|
127
|
+
|
|
149
128
|
space.db.add(create(TestType, { title: '2' }));
|
|
150
129
|
await sleep(20);
|
|
151
130
|
expect(count).to.eq(1);
|
|
@@ -155,12 +134,12 @@ describe('trigger registry', () => {
|
|
|
155
134
|
const client = (await createInitializedClients(testBuilder))[0];
|
|
156
135
|
const space = await client.spaces.create();
|
|
157
136
|
const registry = createRegistry(client);
|
|
158
|
-
await registry.register(space,
|
|
137
|
+
await registry.register(space, testManifest);
|
|
159
138
|
await registry.open(ctx);
|
|
160
|
-
await
|
|
139
|
+
await waitHasInactiveTriggers(registry, space);
|
|
161
140
|
|
|
162
141
|
const { objects: allTriggers } = await space.db.query(Filter.schema(FunctionTrigger)).run();
|
|
163
|
-
const echoTrigger = allTriggers.find((
|
|
142
|
+
const echoTrigger = allTriggers.find((t: FunctionTrigger) => t.spec.type === 'subscription')!;
|
|
164
143
|
let count = 0;
|
|
165
144
|
await registry.activate({ space }, echoTrigger, async () => {
|
|
166
145
|
count++;
|
|
@@ -176,20 +155,19 @@ describe('trigger registry', () => {
|
|
|
176
155
|
});
|
|
177
156
|
|
|
178
157
|
describe('trigger events', () => {
|
|
179
|
-
test
|
|
158
|
+
test('event fired when all registered when opened', async () => {
|
|
180
159
|
const client = (await createInitializedClients(testBuilder))[0];
|
|
181
160
|
const registry = createRegistry(client);
|
|
182
|
-
const triggers =
|
|
161
|
+
const triggers = createTriggersInSpace(client.spaces.default, 3);
|
|
183
162
|
|
|
184
163
|
const triggersRegistered = new Trigger<FunctionTrigger[]>();
|
|
185
164
|
registry.registered.on((fn) => {
|
|
186
165
|
expect(fn.space.key.toHex()).to.eq(client.spaces.default.key.toHex());
|
|
187
166
|
triggersRegistered.wake(fn.triggers);
|
|
188
167
|
});
|
|
189
|
-
|
|
190
168
|
void registry.open(ctx);
|
|
191
169
|
const functions = await triggersRegistered.wait();
|
|
192
|
-
const expected = triggers.map((
|
|
170
|
+
const expected = triggers.map((obj) => obj.id).sort();
|
|
193
171
|
expect(functions.map((fn) => fn.id).sort()).to.deep.eq(expected);
|
|
194
172
|
});
|
|
195
173
|
|
|
@@ -204,16 +182,16 @@ describe('trigger registry', () => {
|
|
|
204
182
|
triggerRegistered.wake(fn.triggers[0]);
|
|
205
183
|
});
|
|
206
184
|
await registry.open(ctx);
|
|
207
|
-
await registry.register(space, { triggers:
|
|
185
|
+
await registry.register(space, { triggers: testManifest?.triggers?.slice(0, 1) });
|
|
208
186
|
const registered = await triggerRegistered.wait();
|
|
209
|
-
expect(registered.function).to.eq(
|
|
187
|
+
expect(registered.function).to.eq(testManifest.triggers![0].function);
|
|
210
188
|
});
|
|
211
189
|
|
|
212
190
|
test('event fired when a new trigger is removed', async () => {
|
|
213
191
|
const client = (await createInitializedClients(testBuilder))[0];
|
|
214
192
|
const registry = createRegistry(client);
|
|
215
193
|
const space = await client.spaces.create();
|
|
216
|
-
const triggers =
|
|
194
|
+
const triggers = createTriggersInSpace(space, 3);
|
|
217
195
|
|
|
218
196
|
const triggerLoaded = new Trigger();
|
|
219
197
|
registry.registered.on((fn) => triggerLoaded.wake());
|
|
@@ -223,7 +201,7 @@ describe('trigger registry', () => {
|
|
|
223
201
|
expect(fn.triggers.length).to.eq(1);
|
|
224
202
|
triggerRemoved.wake(fn.triggers[0]);
|
|
225
203
|
});
|
|
226
|
-
await registry.register(space,
|
|
204
|
+
await registry.register(space, testManifest);
|
|
227
205
|
await registry.open(ctx);
|
|
228
206
|
await triggerLoaded.wait();
|
|
229
207
|
|
|
@@ -233,23 +211,19 @@ describe('trigger registry', () => {
|
|
|
233
211
|
});
|
|
234
212
|
});
|
|
235
213
|
|
|
214
|
+
const waitHasInactiveTriggers = async (registry: TriggerRegistry, space: Space) => {
|
|
215
|
+
await waitForCondition({ condition: () => registry.getInactiveTriggers(space).length > 0 });
|
|
216
|
+
};
|
|
217
|
+
|
|
236
218
|
const createRegistry = (client: Client) => {
|
|
237
219
|
const registry = new TriggerRegistry(client);
|
|
238
220
|
ctx.onDispose(() => registry.close());
|
|
239
221
|
return registry;
|
|
240
222
|
};
|
|
241
223
|
|
|
242
|
-
const
|
|
243
|
-
const triggers = range(count, () => {
|
|
244
|
-
|
|
245
|
-
return create(FunctionTrigger, object, meta);
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
triggers.forEach((trigger) => space.db.add(trigger));
|
|
224
|
+
const createTriggersInSpace = (space: Space, count: number) => {
|
|
225
|
+
const triggers = range(count, () => create(FunctionTrigger, { ...testManifest.triggers![0] }));
|
|
226
|
+
triggers.forEach((def) => space.db.add(def));
|
|
249
227
|
return triggers;
|
|
250
228
|
};
|
|
251
|
-
|
|
252
|
-
const waitForInactiveTriggers = async (registry: TriggerRegistry, space: Space) => {
|
|
253
|
-
await waitForCondition({ condition: () => registry.getInactiveTriggers(space).length > 0 });
|
|
254
|
-
};
|
|
255
229
|
});
|
|
@@ -4,9 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import { Event } from '@dxos/async';
|
|
6
6
|
import { type Client } from '@dxos/client';
|
|
7
|
-
import { create, Filter,
|
|
7
|
+
import { create, Filter, type Space } from '@dxos/client/echo';
|
|
8
8
|
import { Context, Resource } from '@dxos/context';
|
|
9
|
-
import { ECHO_ATTR_META, foreignKey, foreignKeyEquals, splitMeta } from '@dxos/echo-schema';
|
|
10
9
|
import { invariant } from '@dxos/invariant';
|
|
11
10
|
import { PublicKey } from '@dxos/keys';
|
|
12
11
|
import { log } from '@dxos/log';
|
|
@@ -14,7 +13,6 @@ import { ComplexMap } from '@dxos/util';
|
|
|
14
13
|
|
|
15
14
|
import { createSubscriptionTrigger, createTimerTrigger, createWebhookTrigger, createWebsocketTrigger } from './type';
|
|
16
15
|
import { type FunctionManifest, FunctionTrigger, type FunctionTriggerType, type TriggerSpec } from '../types';
|
|
17
|
-
import { diff, intersection } from '../util';
|
|
18
16
|
|
|
19
17
|
type ResponseCode = number;
|
|
20
18
|
|
|
@@ -98,25 +96,14 @@ export class TriggerRegistry extends Resource {
|
|
|
98
96
|
if (!manifest.triggers?.length) {
|
|
99
97
|
return;
|
|
100
98
|
}
|
|
101
|
-
if (!space.db.graph.runtimeSchemaRegistry.
|
|
99
|
+
if (!space.db.graph.runtimeSchemaRegistry.isSchemaRegistered(FunctionTrigger)) {
|
|
102
100
|
space.db.graph.runtimeSchemaRegistry.registerSchema(FunctionTrigger);
|
|
103
101
|
}
|
|
104
102
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
// TODO(burdon): Warn if not unique.
|
|
110
|
-
const keys = b[ECHO_ATTR_META]?.keys ?? [foreignKey('manifest', [b.function, b.spec.type].join('-'))];
|
|
111
|
-
return intersection(getMeta(a)?.keys ?? [], keys, foreignKeyEquals).length > 0;
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
added.forEach((trigger) => {
|
|
115
|
-
const { meta, object } = splitMeta(trigger);
|
|
116
|
-
space.db.add(create(FunctionTrigger, object, meta));
|
|
117
|
-
});
|
|
118
|
-
// TODO(burdon): Update existing triggers.
|
|
119
|
-
removed.forEach((trigger) => space.db.remove(trigger));
|
|
103
|
+
const reactiveObjects = manifest.triggers.map((template: Omit<FunctionTrigger, 'id'>) =>
|
|
104
|
+
create(FunctionTrigger, { ...template }),
|
|
105
|
+
);
|
|
106
|
+
reactiveObjects.forEach((obj) => space.db.add(obj));
|
|
120
107
|
}
|
|
121
108
|
|
|
122
109
|
protected override async _open(): Promise<void> {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { TextV0Type } from '@braneframe/types';
|
|
6
|
-
import { debounce,
|
|
6
|
+
import { debounce, DeferredTask } from '@dxos/async';
|
|
7
7
|
import { type Context } from '@dxos/context';
|
|
8
8
|
import { createSubscription, Filter, getAutomergeObjectCore, type Query } from '@dxos/echo-db';
|
|
9
9
|
import { log } from '@dxos/log';
|
|
@@ -18,33 +18,26 @@ export const createSubscriptionTrigger: TriggerFactory<SubscriptionTrigger> = as
|
|
|
18
18
|
callback: TriggerCallback,
|
|
19
19
|
) => {
|
|
20
20
|
const objectIds = new Set<string>();
|
|
21
|
-
const task = new
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
await callback({ objects });
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
{ maxFrequency: 4 },
|
|
31
|
-
);
|
|
21
|
+
const task = new DeferredTask(ctx, async () => {
|
|
22
|
+
if (objectIds.size > 0) {
|
|
23
|
+
await callback({ objects: Array.from(objectIds) });
|
|
24
|
+
objectIds.clear();
|
|
25
|
+
}
|
|
26
|
+
});
|
|
32
27
|
|
|
33
28
|
// TODO(burdon): Don't fire initially?
|
|
34
29
|
// TODO(burdon): Create queue. Only allow one invocation per trigger at a time?
|
|
35
30
|
const subscriptions: (() => void)[] = [];
|
|
36
31
|
const subscription = createSubscription(({ added, updated }) => {
|
|
37
|
-
|
|
32
|
+
log.info('updated', { added: added.length, updated: updated.length });
|
|
38
33
|
for (const object of added) {
|
|
39
34
|
objectIds.add(object.id);
|
|
40
35
|
}
|
|
41
36
|
for (const object of updated) {
|
|
42
37
|
objectIds.add(object.id);
|
|
43
38
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
task.trigger();
|
|
47
|
-
}
|
|
39
|
+
|
|
40
|
+
task.schedule();
|
|
48
41
|
});
|
|
49
42
|
|
|
50
43
|
subscriptions.push(() => subscription.unsubscribe());
|
package/src/types.ts
CHANGED
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { AST, S, TypedObject } from '@dxos/echo-schema';
|
|
6
|
+
|
|
7
|
+
// TODO(burdon): Factor out.
|
|
8
|
+
const omitEchoId = <T>(schema: S.Schema<T>): S.Schema<Omit<T, 'id'>> => S.make(AST.omit(schema.ast, ['id']));
|
|
6
9
|
|
|
7
10
|
/**
|
|
8
11
|
* Type discriminator for TriggerSpec.
|
|
@@ -14,7 +17,7 @@ export type FunctionTriggerType = 'subscription' | 'timer' | 'webhook' | 'websoc
|
|
|
14
17
|
|
|
15
18
|
const SubscriptionTriggerSchema = S.struct({
|
|
16
19
|
type: S.literal('subscription'),
|
|
17
|
-
// TODO(burdon): Define query DSL
|
|
20
|
+
// TODO(burdon): Define query DSL.
|
|
18
21
|
filter: S.array(
|
|
19
22
|
S.struct({
|
|
20
23
|
type: S.string,
|
|
@@ -30,14 +33,12 @@ const SubscriptionTriggerSchema = S.struct({
|
|
|
30
33
|
}),
|
|
31
34
|
),
|
|
32
35
|
});
|
|
33
|
-
|
|
34
36
|
export type SubscriptionTrigger = S.Schema.Type<typeof SubscriptionTriggerSchema>;
|
|
35
37
|
|
|
36
38
|
const TimerTriggerSchema = S.struct({
|
|
37
39
|
type: S.literal('timer'),
|
|
38
40
|
cron: S.string,
|
|
39
41
|
});
|
|
40
|
-
|
|
41
42
|
export type TimerTrigger = S.Schema.Type<typeof TimerTriggerSchema>;
|
|
42
43
|
|
|
43
44
|
const WebhookTriggerSchema = S.mutable(
|
|
@@ -48,7 +49,6 @@ const WebhookTriggerSchema = S.mutable(
|
|
|
48
49
|
port: S.optional(S.number),
|
|
49
50
|
}),
|
|
50
51
|
);
|
|
51
|
-
|
|
52
52
|
export type WebhookTrigger = S.Schema.Type<typeof WebhookTriggerSchema>;
|
|
53
53
|
|
|
54
54
|
const WebsocketTriggerSchema = S.struct({
|
|
@@ -56,7 +56,6 @@ const WebsocketTriggerSchema = S.struct({
|
|
|
56
56
|
url: S.string,
|
|
57
57
|
init: S.optional(S.record(S.string, S.any)),
|
|
58
58
|
});
|
|
59
|
-
|
|
60
59
|
export type WebsocketTrigger = S.Schema.Type<typeof WebsocketTriggerSchema>;
|
|
61
60
|
|
|
62
61
|
const TriggerSpecSchema = S.union(
|
|
@@ -65,7 +64,6 @@ const TriggerSpecSchema = S.union(
|
|
|
65
64
|
WebsocketTriggerSchema,
|
|
66
65
|
SubscriptionTriggerSchema,
|
|
67
66
|
);
|
|
68
|
-
|
|
69
67
|
export type TriggerSpec = TimerTrigger | WebhookTrigger | WebsocketTrigger | SubscriptionTrigger;
|
|
70
68
|
|
|
71
69
|
/**
|
|
@@ -86,9 +84,9 @@ export class FunctionTrigger extends TypedObject({
|
|
|
86
84
|
typename: 'dxos.org/type/FunctionTrigger',
|
|
87
85
|
version: '0.1.0',
|
|
88
86
|
})({
|
|
89
|
-
function: S.string.pipe(S.description('Function URI.')),
|
|
90
|
-
// Context
|
|
91
|
-
meta: S.optional(S.
|
|
87
|
+
function: S.string.pipe(S.description('Function ID/URI.')),
|
|
88
|
+
// Context passed to a function.
|
|
89
|
+
meta: S.optional(S.record(S.string, S.any)),
|
|
92
90
|
spec: TriggerSpecSchema,
|
|
93
91
|
}) {}
|
|
94
92
|
|
|
@@ -96,8 +94,8 @@ export class FunctionTrigger extends TypedObject({
|
|
|
96
94
|
* Function manifest file.
|
|
97
95
|
*/
|
|
98
96
|
export const FunctionManifestSchema = S.struct({
|
|
99
|
-
functions: S.optional(S.mutable(S.array(
|
|
100
|
-
triggers: S.optional(S.mutable(S.array(
|
|
97
|
+
functions: S.optional(S.mutable(S.array(omitEchoId(FunctionDef)))),
|
|
98
|
+
triggers: S.optional(S.mutable(S.array(omitEchoId(FunctionTrigger)))),
|
|
101
99
|
});
|
|
102
100
|
|
|
103
101
|
export type FunctionManifest = S.Schema.Type<typeof FunctionManifestSchema>;
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import "@dxos/node-std/globals";
|
|
2
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
3
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
4
|
-
}) : x)(function(x) {
|
|
5
|
-
if (typeof require !== "undefined")
|
|
6
|
-
return require.apply(this, arguments);
|
|
7
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
// inject-globals:@inject-globals
|
|
11
|
-
import {
|
|
12
|
-
global,
|
|
13
|
-
Buffer as Buffer2,
|
|
14
|
-
process
|
|
15
|
-
} from "@dxos/node-std/inject-globals";
|
|
16
|
-
|
|
17
|
-
// packages/core/functions/src/types.ts
|
|
18
|
-
import { RawObject, S, TypedObject } from "@dxos/echo-schema";
|
|
19
|
-
var SubscriptionTriggerSchema = S.struct({
|
|
20
|
-
type: S.literal("subscription"),
|
|
21
|
-
// TODO(burdon): Define query DSL (from ECHO).
|
|
22
|
-
filter: S.array(S.struct({
|
|
23
|
-
type: S.string,
|
|
24
|
-
props: S.optional(S.record(S.string, S.any))
|
|
25
|
-
})),
|
|
26
|
-
options: S.optional(S.struct({
|
|
27
|
-
// Watch changes to object (not just creation).
|
|
28
|
-
deep: S.optional(S.boolean),
|
|
29
|
-
// Debounce changes (delay in ms).
|
|
30
|
-
delay: S.optional(S.number)
|
|
31
|
-
}))
|
|
32
|
-
});
|
|
33
|
-
var TimerTriggerSchema = S.struct({
|
|
34
|
-
type: S.literal("timer"),
|
|
35
|
-
cron: S.string
|
|
36
|
-
});
|
|
37
|
-
var WebhookTriggerSchema = S.mutable(S.struct({
|
|
38
|
-
type: S.literal("webhook"),
|
|
39
|
-
method: S.string,
|
|
40
|
-
// Assigned port.
|
|
41
|
-
port: S.optional(S.number)
|
|
42
|
-
}));
|
|
43
|
-
var WebsocketTriggerSchema = S.struct({
|
|
44
|
-
type: S.literal("websocket"),
|
|
45
|
-
url: S.string,
|
|
46
|
-
init: S.optional(S.record(S.string, S.any))
|
|
47
|
-
});
|
|
48
|
-
var TriggerSpecSchema = S.union(TimerTriggerSchema, WebhookTriggerSchema, WebsocketTriggerSchema, SubscriptionTriggerSchema);
|
|
49
|
-
var FunctionDef = class extends TypedObject({
|
|
50
|
-
typename: "dxos.org/type/FunctionDef",
|
|
51
|
-
version: "0.1.0"
|
|
52
|
-
})({
|
|
53
|
-
uri: S.string,
|
|
54
|
-
description: S.optional(S.string),
|
|
55
|
-
route: S.string,
|
|
56
|
-
// TODO(burdon): NPM/GitHub/Docker/CF URL?
|
|
57
|
-
handler: S.string
|
|
58
|
-
}) {
|
|
59
|
-
};
|
|
60
|
-
var FunctionTrigger = class extends TypedObject({
|
|
61
|
-
typename: "dxos.org/type/FunctionTrigger",
|
|
62
|
-
version: "0.1.0"
|
|
63
|
-
})({
|
|
64
|
-
function: S.string.pipe(S.description("Function URI.")),
|
|
65
|
-
// Context is merged into the event data passed to the function.
|
|
66
|
-
meta: S.optional(S.object),
|
|
67
|
-
spec: TriggerSpecSchema
|
|
68
|
-
}) {
|
|
69
|
-
};
|
|
70
|
-
var FunctionManifestSchema = S.struct({
|
|
71
|
-
functions: S.optional(S.mutable(S.array(RawObject(FunctionDef)))),
|
|
72
|
-
triggers: S.optional(S.mutable(S.array(RawObject(FunctionTrigger))))
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
export {
|
|
76
|
-
__require,
|
|
77
|
-
FunctionDef,
|
|
78
|
-
FunctionTrigger,
|
|
79
|
-
FunctionManifestSchema
|
|
80
|
-
};
|
|
81
|
-
//# sourceMappingURL=chunk-366QG6IX.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/types.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { RawObject, S, TypedObject } from '@dxos/echo-schema';\n\n/**\n * Type discriminator for TriggerSpec.\n * Every spec has a type field of type FunctionTriggerType that we can use to understand which\n * type we're working with.\n * https://www.typescriptlang.org/docs/handbook/2/narrowing.html#discriminated-unions\n */\nexport type FunctionTriggerType = 'subscription' | 'timer' | 'webhook' | 'websocket';\n\nconst SubscriptionTriggerSchema = S.struct({\n type: S.literal('subscription'),\n // TODO(burdon): Define query DSL (from ECHO).\n filter: S.array(\n S.struct({\n type: S.string,\n props: S.optional(S.record(S.string, S.any)),\n }),\n ),\n options: S.optional(\n S.struct({\n // Watch changes to object (not just creation).\n deep: S.optional(S.boolean),\n // Debounce changes (delay in ms).\n delay: S.optional(S.number),\n }),\n ),\n});\n\nexport type SubscriptionTrigger = S.Schema.Type<typeof SubscriptionTriggerSchema>;\n\nconst TimerTriggerSchema = S.struct({\n type: S.literal('timer'),\n cron: S.string,\n});\n\nexport type TimerTrigger = S.Schema.Type<typeof TimerTriggerSchema>;\n\nconst WebhookTriggerSchema = S.mutable(\n S.struct({\n type: S.literal('webhook'),\n method: S.string,\n // Assigned port.\n port: S.optional(S.number),\n }),\n);\n\nexport type WebhookTrigger = S.Schema.Type<typeof WebhookTriggerSchema>;\n\nconst WebsocketTriggerSchema = S.struct({\n type: S.literal('websocket'),\n url: S.string,\n init: S.optional(S.record(S.string, S.any)),\n});\n\nexport type WebsocketTrigger = S.Schema.Type<typeof WebsocketTriggerSchema>;\n\nconst TriggerSpecSchema = S.union(\n TimerTriggerSchema,\n WebhookTriggerSchema,\n WebsocketTriggerSchema,\n SubscriptionTriggerSchema,\n);\n\nexport type TriggerSpec = TimerTrigger | WebhookTrigger | WebsocketTrigger | SubscriptionTrigger;\n\n/**\n * Function definition.\n */\nexport class FunctionDef extends TypedObject({\n typename: 'dxos.org/type/FunctionDef',\n version: '0.1.0',\n})({\n uri: S.string,\n description: S.optional(S.string),\n route: S.string,\n // TODO(burdon): NPM/GitHub/Docker/CF URL?\n handler: S.string,\n}) {}\n\nexport class FunctionTrigger extends TypedObject({\n typename: 'dxos.org/type/FunctionTrigger',\n version: '0.1.0',\n})({\n function: S.string.pipe(S.description('Function URI.')),\n // Context is merged into the event data passed to the function.\n meta: S.optional(S.object),\n spec: TriggerSpecSchema,\n}) {}\n\n/**\n * Function manifest file.\n */\nexport const FunctionManifestSchema = S.struct({\n functions: S.optional(S.mutable(S.array(RawObject(FunctionDef)))),\n triggers: S.optional(S.mutable(S.array(RawObject(FunctionTrigger)))),\n});\n\nexport type FunctionManifest = S.Schema.Type<typeof FunctionManifestSchema>;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAIA,SAASA,WAAWC,GAAGC,mBAAmB;AAU1C,IAAMC,4BAA4BC,EAAEC,OAAO;EACzCC,MAAMF,EAAEG,QAAQ,cAAA;;EAEhBC,QAAQJ,EAAEK,MACRL,EAAEC,OAAO;IACPC,MAAMF,EAAEM;IACRC,OAAOP,EAAEQ,SAASR,EAAES,OAAOT,EAAEM,QAAQN,EAAEU,GAAG,CAAA;EAC5C,CAAA,CAAA;EAEFC,SAASX,EAAEQ,SACTR,EAAEC,OAAO;;IAEPW,MAAMZ,EAAEQ,SAASR,EAAEa,OAAO;;IAE1BC,OAAOd,EAAEQ,SAASR,EAAEe,MAAM;EAC5B,CAAA,CAAA;AAEJ,CAAA;AAIA,IAAMC,qBAAqBhB,EAAEC,OAAO;EAClCC,MAAMF,EAAEG,QAAQ,OAAA;EAChBc,MAAMjB,EAAEM;AACV,CAAA;AAIA,IAAMY,uBAAuBlB,EAAEmB,QAC7BnB,EAAEC,OAAO;EACPC,MAAMF,EAAEG,QAAQ,SAAA;EAChBiB,QAAQpB,EAAEM;;EAEVe,MAAMrB,EAAEQ,SAASR,EAAEe,MAAM;AAC3B,CAAA,CAAA;AAKF,IAAMO,yBAAyBtB,EAAEC,OAAO;EACtCC,MAAMF,EAAEG,QAAQ,WAAA;EAChBoB,KAAKvB,EAAEM;EACPkB,MAAMxB,EAAEQ,SAASR,EAAES,OAAOT,EAAEM,QAAQN,EAAEU,GAAG,CAAA;AAC3C,CAAA;AAIA,IAAMe,oBAAoBzB,EAAE0B,MAC1BV,oBACAE,sBACAI,wBACAvB,yBAAAA;AAQK,IAAM4B,cAAN,cAA0BC,YAAY;EAC3CC,UAAU;EACVC,SAAS;AACX,CAAA,EAAG;EACDC,KAAK/B,EAAEM;EACP0B,aAAahC,EAAEQ,SAASR,EAAEM,MAAM;EAChC2B,OAAOjC,EAAEM;;EAET4B,SAASlC,EAAEM;AACb,CAAA,EAAA;AAAI;AAEG,IAAM6B,kBAAN,cAA8BP,YAAY;EAC/CC,UAAU;EACVC,SAAS;AACX,CAAA,EAAG;EACDM,UAAUpC,EAAEM,OAAO+B,KAAKrC,EAAEgC,YAAY,eAAA,CAAA;;EAEtCM,MAAMtC,EAAEQ,SAASR,EAAEuC,MAAM;EACzBC,MAAMf;AACR,CAAA,EAAA;AAAI;AAKG,IAAMgB,yBAAyBzC,EAAEC,OAAO;EAC7CyC,WAAW1C,EAAEQ,SAASR,EAAEmB,QAAQnB,EAAEK,MAAMsC,UAAUhB,WAAAA,CAAAA,CAAAA,CAAAA;EAClDiB,UAAU5C,EAAEQ,SAASR,EAAEmB,QAAQnB,EAAEK,MAAMsC,UAAUR,eAAAA,CAAAA,CAAAA,CAAAA;AACnD,CAAA;",
|
|
6
|
-
"names": ["RawObject", "S", "TypedObject", "SubscriptionTriggerSchema", "S", "struct", "type", "literal", "filter", "array", "string", "props", "optional", "record", "any", "options", "deep", "boolean", "delay", "number", "TimerTriggerSchema", "cron", "WebhookTriggerSchema", "mutable", "method", "port", "WebsocketTriggerSchema", "url", "init", "TriggerSpecSchema", "union", "FunctionDef", "TypedObject", "typename", "version", "uri", "description", "route", "handler", "FunctionTrigger", "function", "pipe", "meta", "object", "spec", "FunctionManifestSchema", "functions", "RawObject", "triggers"]
|
|
7
|
-
}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var chunk_3VSJ57ZZ_exports = {};
|
|
20
|
-
__export(chunk_3VSJ57ZZ_exports, {
|
|
21
|
-
FunctionDef: () => FunctionDef,
|
|
22
|
-
FunctionManifestSchema: () => FunctionManifestSchema,
|
|
23
|
-
FunctionTrigger: () => FunctionTrigger,
|
|
24
|
-
__require: () => __require
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(chunk_3VSJ57ZZ_exports);
|
|
27
|
-
var import_echo_schema = require("@dxos/echo-schema");
|
|
28
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
29
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
30
|
-
}) : x)(function(x) {
|
|
31
|
-
if (typeof require !== "undefined")
|
|
32
|
-
return require.apply(this, arguments);
|
|
33
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
34
|
-
});
|
|
35
|
-
var SubscriptionTriggerSchema = import_echo_schema.S.struct({
|
|
36
|
-
type: import_echo_schema.S.literal("subscription"),
|
|
37
|
-
// TODO(burdon): Define query DSL (from ECHO).
|
|
38
|
-
filter: import_echo_schema.S.array(import_echo_schema.S.struct({
|
|
39
|
-
type: import_echo_schema.S.string,
|
|
40
|
-
props: import_echo_schema.S.optional(import_echo_schema.S.record(import_echo_schema.S.string, import_echo_schema.S.any))
|
|
41
|
-
})),
|
|
42
|
-
options: import_echo_schema.S.optional(import_echo_schema.S.struct({
|
|
43
|
-
// Watch changes to object (not just creation).
|
|
44
|
-
deep: import_echo_schema.S.optional(import_echo_schema.S.boolean),
|
|
45
|
-
// Debounce changes (delay in ms).
|
|
46
|
-
delay: import_echo_schema.S.optional(import_echo_schema.S.number)
|
|
47
|
-
}))
|
|
48
|
-
});
|
|
49
|
-
var TimerTriggerSchema = import_echo_schema.S.struct({
|
|
50
|
-
type: import_echo_schema.S.literal("timer"),
|
|
51
|
-
cron: import_echo_schema.S.string
|
|
52
|
-
});
|
|
53
|
-
var WebhookTriggerSchema = import_echo_schema.S.mutable(import_echo_schema.S.struct({
|
|
54
|
-
type: import_echo_schema.S.literal("webhook"),
|
|
55
|
-
method: import_echo_schema.S.string,
|
|
56
|
-
// Assigned port.
|
|
57
|
-
port: import_echo_schema.S.optional(import_echo_schema.S.number)
|
|
58
|
-
}));
|
|
59
|
-
var WebsocketTriggerSchema = import_echo_schema.S.struct({
|
|
60
|
-
type: import_echo_schema.S.literal("websocket"),
|
|
61
|
-
url: import_echo_schema.S.string,
|
|
62
|
-
init: import_echo_schema.S.optional(import_echo_schema.S.record(import_echo_schema.S.string, import_echo_schema.S.any))
|
|
63
|
-
});
|
|
64
|
-
var TriggerSpecSchema = import_echo_schema.S.union(TimerTriggerSchema, WebhookTriggerSchema, WebsocketTriggerSchema, SubscriptionTriggerSchema);
|
|
65
|
-
var FunctionDef = class extends (0, import_echo_schema.TypedObject)({
|
|
66
|
-
typename: "dxos.org/type/FunctionDef",
|
|
67
|
-
version: "0.1.0"
|
|
68
|
-
})({
|
|
69
|
-
uri: import_echo_schema.S.string,
|
|
70
|
-
description: import_echo_schema.S.optional(import_echo_schema.S.string),
|
|
71
|
-
route: import_echo_schema.S.string,
|
|
72
|
-
// TODO(burdon): NPM/GitHub/Docker/CF URL?
|
|
73
|
-
handler: import_echo_schema.S.string
|
|
74
|
-
}) {
|
|
75
|
-
};
|
|
76
|
-
var FunctionTrigger = class extends (0, import_echo_schema.TypedObject)({
|
|
77
|
-
typename: "dxos.org/type/FunctionTrigger",
|
|
78
|
-
version: "0.1.0"
|
|
79
|
-
})({
|
|
80
|
-
function: import_echo_schema.S.string.pipe(import_echo_schema.S.description("Function URI.")),
|
|
81
|
-
// Context is merged into the event data passed to the function.
|
|
82
|
-
meta: import_echo_schema.S.optional(import_echo_schema.S.object),
|
|
83
|
-
spec: TriggerSpecSchema
|
|
84
|
-
}) {
|
|
85
|
-
};
|
|
86
|
-
var FunctionManifestSchema = import_echo_schema.S.struct({
|
|
87
|
-
functions: import_echo_schema.S.optional(import_echo_schema.S.mutable(import_echo_schema.S.array((0, import_echo_schema.RawObject)(FunctionDef)))),
|
|
88
|
-
triggers: import_echo_schema.S.optional(import_echo_schema.S.mutable(import_echo_schema.S.array((0, import_echo_schema.RawObject)(FunctionTrigger))))
|
|
89
|
-
});
|
|
90
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
91
|
-
0 && (module.exports = {
|
|
92
|
-
FunctionDef,
|
|
93
|
-
FunctionManifestSchema,
|
|
94
|
-
FunctionTrigger,
|
|
95
|
-
__require
|
|
96
|
-
});
|
|
97
|
-
//# sourceMappingURL=chunk-3VSJ57ZZ.cjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/types.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { RawObject, S, TypedObject } from '@dxos/echo-schema';\n\n/**\n * Type discriminator for TriggerSpec.\n * Every spec has a type field of type FunctionTriggerType that we can use to understand which\n * type we're working with.\n * https://www.typescriptlang.org/docs/handbook/2/narrowing.html#discriminated-unions\n */\nexport type FunctionTriggerType = 'subscription' | 'timer' | 'webhook' | 'websocket';\n\nconst SubscriptionTriggerSchema = S.struct({\n type: S.literal('subscription'),\n // TODO(burdon): Define query DSL (from ECHO).\n filter: S.array(\n S.struct({\n type: S.string,\n props: S.optional(S.record(S.string, S.any)),\n }),\n ),\n options: S.optional(\n S.struct({\n // Watch changes to object (not just creation).\n deep: S.optional(S.boolean),\n // Debounce changes (delay in ms).\n delay: S.optional(S.number),\n }),\n ),\n});\n\nexport type SubscriptionTrigger = S.Schema.Type<typeof SubscriptionTriggerSchema>;\n\nconst TimerTriggerSchema = S.struct({\n type: S.literal('timer'),\n cron: S.string,\n});\n\nexport type TimerTrigger = S.Schema.Type<typeof TimerTriggerSchema>;\n\nconst WebhookTriggerSchema = S.mutable(\n S.struct({\n type: S.literal('webhook'),\n method: S.string,\n // Assigned port.\n port: S.optional(S.number),\n }),\n);\n\nexport type WebhookTrigger = S.Schema.Type<typeof WebhookTriggerSchema>;\n\nconst WebsocketTriggerSchema = S.struct({\n type: S.literal('websocket'),\n url: S.string,\n init: S.optional(S.record(S.string, S.any)),\n});\n\nexport type WebsocketTrigger = S.Schema.Type<typeof WebsocketTriggerSchema>;\n\nconst TriggerSpecSchema = S.union(\n TimerTriggerSchema,\n WebhookTriggerSchema,\n WebsocketTriggerSchema,\n SubscriptionTriggerSchema,\n);\n\nexport type TriggerSpec = TimerTrigger | WebhookTrigger | WebsocketTrigger | SubscriptionTrigger;\n\n/**\n * Function definition.\n */\nexport class FunctionDef extends TypedObject({\n typename: 'dxos.org/type/FunctionDef',\n version: '0.1.0',\n})({\n uri: S.string,\n description: S.optional(S.string),\n route: S.string,\n // TODO(burdon): NPM/GitHub/Docker/CF URL?\n handler: S.string,\n}) {}\n\nexport class FunctionTrigger extends TypedObject({\n typename: 'dxos.org/type/FunctionTrigger',\n version: '0.1.0',\n})({\n function: S.string.pipe(S.description('Function URI.')),\n // Context is merged into the event data passed to the function.\n meta: S.optional(S.object),\n spec: TriggerSpecSchema,\n}) {}\n\n/**\n * Function manifest file.\n */\nexport const FunctionManifestSchema = S.struct({\n functions: S.optional(S.mutable(S.array(RawObject(FunctionDef)))),\n triggers: S.optional(S.mutable(S.array(RawObject(FunctionTrigger)))),\n});\n\nexport type FunctionManifest = S.Schema.Type<typeof FunctionManifestSchema>;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,yBAA0C;;;;;;;;AAU1C,IAAMA,4BAA4BC,qBAAEC,OAAO;EACzCC,MAAMF,qBAAEG,QAAQ,cAAA;;EAEhBC,QAAQJ,qBAAEK,MACRL,qBAAEC,OAAO;IACPC,MAAMF,qBAAEM;IACRC,OAAOP,qBAAEQ,SAASR,qBAAES,OAAOT,qBAAEM,QAAQN,qBAAEU,GAAG,CAAA;EAC5C,CAAA,CAAA;EAEFC,SAASX,qBAAEQ,SACTR,qBAAEC,OAAO;;IAEPW,MAAMZ,qBAAEQ,SAASR,qBAAEa,OAAO;;IAE1BC,OAAOd,qBAAEQ,SAASR,qBAAEe,MAAM;EAC5B,CAAA,CAAA;AAEJ,CAAA;AAIA,IAAMC,qBAAqBhB,qBAAEC,OAAO;EAClCC,MAAMF,qBAAEG,QAAQ,OAAA;EAChBc,MAAMjB,qBAAEM;AACV,CAAA;AAIA,IAAMY,uBAAuBlB,qBAAEmB,QAC7BnB,qBAAEC,OAAO;EACPC,MAAMF,qBAAEG,QAAQ,SAAA;EAChBiB,QAAQpB,qBAAEM;;EAEVe,MAAMrB,qBAAEQ,SAASR,qBAAEe,MAAM;AAC3B,CAAA,CAAA;AAKF,IAAMO,yBAAyBtB,qBAAEC,OAAO;EACtCC,MAAMF,qBAAEG,QAAQ,WAAA;EAChBoB,KAAKvB,qBAAEM;EACPkB,MAAMxB,qBAAEQ,SAASR,qBAAES,OAAOT,qBAAEM,QAAQN,qBAAEU,GAAG,CAAA;AAC3C,CAAA;AAIA,IAAMe,oBAAoBzB,qBAAE0B,MAC1BV,oBACAE,sBACAI,wBACAvB,yBAAAA;AAQK,IAAM4B,cAAN,kBAA0BC,gCAAY;EAC3CC,UAAU;EACVC,SAAS;AACX,CAAA,EAAG;EACDC,KAAK/B,qBAAEM;EACP0B,aAAahC,qBAAEQ,SAASR,qBAAEM,MAAM;EAChC2B,OAAOjC,qBAAEM;;EAET4B,SAASlC,qBAAEM;AACb,CAAA,EAAA;AAAI;AAEG,IAAM6B,kBAAN,kBAA8BP,gCAAY;EAC/CC,UAAU;EACVC,SAAS;AACX,CAAA,EAAG;EACDM,UAAUpC,qBAAEM,OAAO+B,KAAKrC,qBAAEgC,YAAY,eAAA,CAAA;;EAEtCM,MAAMtC,qBAAEQ,SAASR,qBAAEuC,MAAM;EACzBC,MAAMf;AACR,CAAA,EAAA;AAAI;AAKG,IAAMgB,yBAAyBzC,qBAAEC,OAAO;EAC7CyC,WAAW1C,qBAAEQ,SAASR,qBAAEmB,QAAQnB,qBAAEK,UAAMsC,8BAAUhB,WAAAA,CAAAA,CAAAA,CAAAA;EAClDiB,UAAU5C,qBAAEQ,SAASR,qBAAEmB,QAAQnB,qBAAEK,UAAMsC,8BAAUR,eAAAA,CAAAA,CAAAA,CAAAA;AACnD,CAAA;",
|
|
6
|
-
"names": ["SubscriptionTriggerSchema", "S", "struct", "type", "literal", "filter", "array", "string", "props", "optional", "record", "any", "options", "deep", "boolean", "delay", "number", "TimerTriggerSchema", "cron", "WebhookTriggerSchema", "mutable", "method", "port", "WebsocketTriggerSchema", "url", "init", "TriggerSpecSchema", "union", "FunctionDef", "TypedObject", "typename", "version", "uri", "description", "route", "handler", "FunctionTrigger", "function", "pipe", "meta", "object", "spec", "FunctionManifestSchema", "functions", "RawObject", "triggers"]
|
|
7
|
-
}
|