@dxos/functions 0.5.3-main.8b66fe2 → 0.5.3-main.8ffbbae
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 +493 -692
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +486 -675
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/types/src/index.d.ts +0 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/runtime/dev-server.d.ts +10 -7
- package/dist/types/src/runtime/dev-server.d.ts.map +1 -1
- package/dist/types/src/runtime/scheduler.d.ts +59 -11
- package/dist/types/src/runtime/scheduler.d.ts.map +1 -1
- package/dist/types/src/testing/test/handler.d.ts +0 -1
- package/dist/types/src/testing/test/handler.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +111 -131
- package/dist/types/src/types.d.ts.map +1 -1
- package/package.json +14 -30
- package/schema/functions.json +116 -139
- package/src/index.ts +0 -2
- package/src/runtime/dev-server.test.ts +35 -15
- package/src/runtime/dev-server.ts +20 -37
- package/src/runtime/scheduler.test.ts +75 -54
- package/src/runtime/scheduler.ts +298 -66
- package/src/testing/test/handler.ts +2 -8
- package/src/types.ts +42 -58
- 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 +0 -24
- 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/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 -4
- package/dist/types/src/testing/index.d.ts.map +0 -1
- package/dist/types/src/testing/setup.d.ts +0 -5
- package/dist/types/src/testing/setup.d.ts.map +0 -1
- package/dist/types/src/testing/types.d.ts +0 -9
- package/dist/types/src/testing/types.d.ts.map +0 -1
- package/dist/types/src/testing/util.d.ts +0 -3
- package/dist/types/src/testing/util.d.ts.map +0 -1
- package/dist/types/src/trigger/index.d.ts +0 -2
- package/dist/types/src/trigger/index.d.ts.map +0 -1
- package/dist/types/src/trigger/trigger-registry.d.ts +0 -40
- 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 -5
- 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/trigger/type/websocket-trigger.d.ts +0 -13
- package/dist/types/src/trigger/type/websocket-trigger.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.test.ts +0 -105
- package/src/function/function-registry.ts +0 -90
- package/src/function/index.ts +0 -5
- package/src/testing/functions-integration.test.ts +0 -99
- package/src/testing/index.ts +0 -7
- package/src/testing/setup.ts +0 -45
- package/src/testing/types.ts +0 -9
- package/src/testing/util.ts +0 -16
- package/src/trigger/index.ts +0 -5
- package/src/trigger/trigger-registry.test.ts +0 -255
- package/src/trigger/trigger-registry.ts +0 -189
- package/src/trigger/type/index.ts +0 -8
- package/src/trigger/type/subscription-trigger.ts +0 -80
- package/src/trigger/type/timer-trigger.ts +0 -44
- package/src/trigger/type/webhook-trigger.ts +0 -47
- package/src/trigger/type/websocket-trigger.ts +0 -91
- package/src/util.test.ts +0 -43
- package/src/util.ts +0 -48
package/src/types.ts
CHANGED
|
@@ -2,19 +2,28 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as S from '@effect/schema/Schema';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
const TimerTriggerSchema = S.struct({
|
|
8
|
+
cron: S.string,
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
const WebhookTriggerSchema = S.mutable(
|
|
12
|
+
S.struct({
|
|
13
|
+
method: S.string,
|
|
14
|
+
// Assigned port.
|
|
15
|
+
port: S.optional(S.number),
|
|
16
|
+
}),
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
const WebsocketTriggerSchema = S.struct({
|
|
20
|
+
url: S.string,
|
|
21
|
+
init: S.optional(S.record(S.string, S.any)),
|
|
22
|
+
});
|
|
14
23
|
|
|
15
24
|
const SubscriptionTriggerSchema = S.struct({
|
|
16
|
-
|
|
17
|
-
// TODO(burdon): Define query DSL
|
|
25
|
+
spaceKey: S.optional(S.string),
|
|
26
|
+
// TODO(burdon): Define query DSL.
|
|
18
27
|
filter: S.array(
|
|
19
28
|
S.struct({
|
|
20
29
|
type: S.string,
|
|
@@ -31,73 +40,48 @@ const SubscriptionTriggerSchema = S.struct({
|
|
|
31
40
|
),
|
|
32
41
|
});
|
|
33
42
|
|
|
34
|
-
|
|
43
|
+
const FunctionTriggerSchema = S.struct({
|
|
44
|
+
function: S.string.pipe(S.description('Function ID/URI.')),
|
|
35
45
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
cron: S.string,
|
|
39
|
-
});
|
|
46
|
+
// Context passed to function.
|
|
47
|
+
meta: S.optional(S.record(S.string, S.any)),
|
|
40
48
|
|
|
41
|
-
|
|
49
|
+
// Triggers.
|
|
50
|
+
timer: S.optional(TimerTriggerSchema),
|
|
51
|
+
webhook: S.optional(WebhookTriggerSchema),
|
|
52
|
+
websocket: S.optional(WebsocketTriggerSchema),
|
|
53
|
+
subscription: S.optional(SubscriptionTriggerSchema),
|
|
54
|
+
});
|
|
42
55
|
|
|
43
|
-
|
|
44
|
-
S.struct({
|
|
45
|
-
type: S.literal('webhook'),
|
|
46
|
-
method: S.string,
|
|
47
|
-
// Assigned port.
|
|
48
|
-
port: S.optional(S.number),
|
|
49
|
-
}),
|
|
50
|
-
);
|
|
56
|
+
export type FunctionTrigger = S.Schema.Type<typeof FunctionTriggerSchema>;
|
|
51
57
|
|
|
58
|
+
export type TimerTrigger = S.Schema.Type<typeof TimerTriggerSchema>;
|
|
52
59
|
export type WebhookTrigger = S.Schema.Type<typeof WebhookTriggerSchema>;
|
|
53
|
-
|
|
54
|
-
const WebsocketTriggerSchema = S.struct({
|
|
55
|
-
type: S.literal('websocket'),
|
|
56
|
-
url: S.string,
|
|
57
|
-
init: S.optional(S.record(S.string, S.any)),
|
|
58
|
-
});
|
|
59
|
-
|
|
60
60
|
export type WebsocketTrigger = S.Schema.Type<typeof WebsocketTriggerSchema>;
|
|
61
|
-
|
|
62
|
-
const TriggerSpecSchema = S.union(
|
|
63
|
-
TimerTriggerSchema,
|
|
64
|
-
WebhookTriggerSchema,
|
|
65
|
-
WebsocketTriggerSchema,
|
|
66
|
-
SubscriptionTriggerSchema,
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
export type TriggerSpec = TimerTrigger | WebhookTrigger | WebsocketTrigger | SubscriptionTrigger;
|
|
61
|
+
export type SubscriptionTrigger = S.Schema.Type<typeof SubscriptionTriggerSchema>;
|
|
70
62
|
|
|
71
63
|
/**
|
|
72
64
|
* Function definition.
|
|
73
65
|
*/
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
uri: S.string,
|
|
66
|
+
// TODO(burdon): Name vs. path?
|
|
67
|
+
const FunctionDefSchema = S.struct({
|
|
68
|
+
id: S.string,
|
|
69
|
+
// name: S.string,
|
|
79
70
|
description: S.optional(S.string),
|
|
80
|
-
|
|
71
|
+
// TODO(burdon): Rename route?
|
|
72
|
+
path: S.string,
|
|
81
73
|
// TODO(burdon): NPM/GitHub/Docker/CF URL?
|
|
82
74
|
handler: S.string,
|
|
83
|
-
})
|
|
75
|
+
});
|
|
84
76
|
|
|
85
|
-
export
|
|
86
|
-
typename: 'dxos.org/type/FunctionTrigger',
|
|
87
|
-
version: '0.1.0',
|
|
88
|
-
})({
|
|
89
|
-
function: S.string.pipe(S.description('Function URI.')),
|
|
90
|
-
// Context is merged into the event data passed to the function.
|
|
91
|
-
meta: S.optional(S.object),
|
|
92
|
-
spec: TriggerSpecSchema,
|
|
93
|
-
}) {}
|
|
77
|
+
export type FunctionDef = S.Schema.Type<typeof FunctionDefSchema>;
|
|
94
78
|
|
|
95
79
|
/**
|
|
96
80
|
* Function manifest file.
|
|
97
81
|
*/
|
|
98
82
|
export const FunctionManifestSchema = S.struct({
|
|
99
|
-
functions: S.
|
|
100
|
-
triggers: S.optional(S.mutable(S.array(
|
|
83
|
+
functions: S.mutable(S.array(FunctionDefSchema)),
|
|
84
|
+
triggers: S.optional(S.mutable(S.array(FunctionTriggerSchema))),
|
|
101
85
|
});
|
|
102
86
|
|
|
103
87
|
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
|
-
}
|
package/dist/lib/node/types.cjs
DELETED
|
@@ -1,33 +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 types_exports = {};
|
|
20
|
-
__export(types_exports, {
|
|
21
|
-
FunctionDef: () => import_chunk_3VSJ57ZZ.FunctionDef,
|
|
22
|
-
FunctionManifestSchema: () => import_chunk_3VSJ57ZZ.FunctionManifestSchema,
|
|
23
|
-
FunctionTrigger: () => import_chunk_3VSJ57ZZ.FunctionTrigger
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(types_exports);
|
|
26
|
-
var import_chunk_3VSJ57ZZ = require("./chunk-3VSJ57ZZ.cjs");
|
|
27
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
-
0 && (module.exports = {
|
|
29
|
-
FunctionDef,
|
|
30
|
-
FunctionManifestSchema,
|
|
31
|
-
FunctionTrigger
|
|
32
|
-
});
|
|
33
|
-
//# sourceMappingURL=types.cjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["types.cjs"],
|
|
4
|
-
"sourcesContent": ["import {\n FunctionDef,\n FunctionManifestSchema,\n FunctionTrigger\n} from \"./chunk-3VSJ57ZZ.cjs\";\nexport {\n FunctionDef,\n FunctionManifestSchema,\n FunctionTrigger\n};\n//# sourceMappingURL=types.cjs.map\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAIO;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Event } from '@dxos/async';
|
|
2
|
-
import { type Client } from '@dxos/client';
|
|
3
|
-
import { type Space } from '@dxos/client/echo';
|
|
4
|
-
import { type Context, Resource } from '@dxos/context';
|
|
5
|
-
import { FunctionDef, type FunctionManifest } from '../types';
|
|
6
|
-
export type FunctionsRegisteredEvent = {
|
|
7
|
-
space: Space;
|
|
8
|
-
added: FunctionDef[];
|
|
9
|
-
};
|
|
10
|
-
export declare class FunctionRegistry extends Resource {
|
|
11
|
-
private readonly _client;
|
|
12
|
-
private readonly _functionBySpaceKey;
|
|
13
|
-
readonly registered: Event<FunctionsRegisteredEvent>;
|
|
14
|
-
constructor(_client: Client);
|
|
15
|
-
getFunctions(space: Space): FunctionDef[];
|
|
16
|
-
/**
|
|
17
|
-
* Loads function definitions from the manifest into the space.
|
|
18
|
-
* We first load all the definitions from the space to deduplicate by functionId.
|
|
19
|
-
*/
|
|
20
|
-
register(space: Space, functions: FunctionManifest['functions']): Promise<void>;
|
|
21
|
-
protected _open(): Promise<void>;
|
|
22
|
-
protected _close(_: Context): Promise<void>;
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=function-registry.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"function-registry.d.ts","sourceRoot":"","sources":["../../../../src/function/function-registry.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAkB,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,KAAK,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAKvD,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAG9D,MAAM,MAAM,wBAAwB,GAAG;IACrC,KAAK,EAAE,KAAK,CAAC;IACb,KAAK,EAAE,WAAW,EAAE,CAAC;CACtB,CAAC;AAEF,qBAAa,gBAAiB,SAAQ,QAAQ;IAKhC,OAAO,CAAC,QAAQ,CAAC,OAAO;IAJpC,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAA4D;IAEhG,SAAgB,UAAU,kCAAyC;gBAEtC,OAAO,EAAE,MAAM;IAIrC,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,WAAW,EAAE;IAIhD;;;OAGG;IACU,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,gBAAgB,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;cAiBnE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;cAgCtB,MAAM,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAG3D"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"function-registry.test.d.ts","sourceRoot":"","sources":["../../../../src/function/function-registry.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/function/index.ts"],"names":[],"mappings":"AAIA,cAAc,qBAAqB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"functions-integration.test.d.ts","sourceRoot":"","sources":["../../../../src/testing/functions-integration.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/testing/index.ts"],"names":[],"mappings":"AAIA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { Client, Config } from '@dxos/client';
|
|
2
|
-
import { type TestBuilder } from '@dxos/client/testing';
|
|
3
|
-
export declare const createInitializedClients: (testBuilder: TestBuilder, count?: number, config?: Config) => Promise<Client[]>;
|
|
4
|
-
export declare const createFunctionRuntime: (testBuilder: TestBuilder) => Promise<Client>;
|
|
5
|
-
//# sourceMappingURL=setup.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../../../src/testing/setup.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAQxD,eAAO,MAAM,wBAAwB,gBAAuB,WAAW,UAAS,MAAM,WAAe,MAAM,sBAW1G,CAAC;AAEF,eAAO,MAAM,qBAAqB,gBAAuB,WAAW,KAAG,QAAQ,MAAM,CAiBpF,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/testing/types.ts"],"names":[],"mappings":";;;;;AAMA,qBAAa,QAAS,SAAQ,aAE5B;CAAG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../../src/testing/util.ts"],"names":[],"mappings":"AAIA,OAAO,EAAU,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAKvD,eAAO,MAAM,cAAc,UAAiB,KAAK,OAAO,MAAM,kBAM7D,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/trigger/index.ts"],"names":[],"mappings":"AAIA,cAAc,oBAAoB,CAAC"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { Event } from '@dxos/async';
|
|
2
|
-
import { type Client } from '@dxos/client';
|
|
3
|
-
import { type Space } from '@dxos/client/echo';
|
|
4
|
-
import { Context, Resource } from '@dxos/context';
|
|
5
|
-
import { type FunctionManifest, FunctionTrigger, type FunctionTriggerType, type TriggerSpec } from '../types';
|
|
6
|
-
type ResponseCode = number;
|
|
7
|
-
export type TriggerCallback = (args: object) => Promise<ResponseCode>;
|
|
8
|
-
export type TriggerContext = {
|
|
9
|
-
space: Space;
|
|
10
|
-
};
|
|
11
|
-
export type TriggerFactory<Spec extends TriggerSpec, Options = any> = (ctx: Context, context: TriggerContext, spec: Spec, callback: TriggerCallback, options?: Options) => Promise<void>;
|
|
12
|
-
export type TriggerHandlerMap = {
|
|
13
|
-
[type in FunctionTriggerType]: TriggerFactory<any>;
|
|
14
|
-
};
|
|
15
|
-
export type TriggerEvent = {
|
|
16
|
-
space: Space;
|
|
17
|
-
triggers: FunctionTrigger[];
|
|
18
|
-
};
|
|
19
|
-
export declare class TriggerRegistry extends Resource {
|
|
20
|
-
private readonly _client;
|
|
21
|
-
private readonly _options?;
|
|
22
|
-
private readonly _triggersBySpaceKey;
|
|
23
|
-
readonly registered: Event<TriggerEvent>;
|
|
24
|
-
readonly removed: Event<TriggerEvent>;
|
|
25
|
-
constructor(_client: Client, _options?: TriggerHandlerMap | undefined);
|
|
26
|
-
getActiveTriggers(space: Space): FunctionTrigger[];
|
|
27
|
-
getInactiveTriggers(space: Space): FunctionTrigger[];
|
|
28
|
-
activate(triggerCtx: TriggerContext, trigger: FunctionTrigger, callback: TriggerCallback): Promise<void>;
|
|
29
|
-
/**
|
|
30
|
-
* Loads triggers from the manifest into the space.
|
|
31
|
-
*/
|
|
32
|
-
register(space: Space, manifest: FunctionManifest): Promise<void>;
|
|
33
|
-
protected _open(): Promise<void>;
|
|
34
|
-
protected _close(_: Context): Promise<void>;
|
|
35
|
-
private _handleNewTriggers;
|
|
36
|
-
private _handleRemovedTriggers;
|
|
37
|
-
private _getTriggers;
|
|
38
|
-
}
|
|
39
|
-
export {};
|
|
40
|
-
//# sourceMappingURL=trigger-registry.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"trigger-registry.d.ts","sourceRoot":"","sources":["../../../../src/trigger/trigger-registry.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAA2B,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAQlD,OAAO,EAAE,KAAK,gBAAgB,EAAE,eAAe,EAAE,KAAK,mBAAmB,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAG9G,KAAK,YAAY,GAAG,MAAM,CAAC;AAE3B,MAAM,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,YAAY,CAAC,CAAC;AAEtE,MAAM,MAAM,cAAc,GAAG;IAAE,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC;AAG9C,MAAM,MAAM,cAAc,CAAC,IAAI,SAAS,WAAW,EAAE,OAAO,GAAG,GAAG,IAAI,CACpE,GAAG,EAAE,OAAO,EACZ,OAAO,EAAE,cAAc,EACvB,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,eAAe,EACzB,OAAO,CAAC,EAAE,OAAO,KACd,OAAO,CAAC,IAAI,CAAC,CAAC;AAEnB,MAAM,MAAM,iBAAiB,GAAG;KAAG,IAAI,IAAI,mBAAmB,GAAG,cAAc,CAAC,GAAG,CAAC;CAAE,CAAC;AASvF,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,eAAe,EAAE,CAAC;CAC7B,CAAC;AAOF,qBAAa,eAAgB,SAAQ,QAAQ;IAOzC,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC;IAP5B,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAkE;IAEtG,SAAgB,UAAU,sBAA6B;IACvD,SAAgB,OAAO,sBAA6B;gBAGjC,OAAO,EAAE,MAAM,EACf,QAAQ,CAAC,+BAAmB;IAKxC,iBAAiB,CAAC,KAAK,EAAE,KAAK,GAAG,eAAe,EAAE;IAIlD,mBAAmB,CAAC,KAAK,EAAE,KAAK,GAAG,eAAe,EAAE;IAIrD,QAAQ,CAAC,UAAU,EAAE,cAAc,EAAE,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAmB9G;;OAEG;IACU,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;cA0BrD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;cAyBtB,MAAM,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAI1D,OAAO,CAAC,kBAAkB;YAaZ,sBAAsB;IAqBpC,OAAO,CAAC,YAAY;CAIrB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"trigger-registry.test.d.ts","sourceRoot":"","sources":["../../../../src/trigger/trigger-registry.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/trigger/type/index.ts"],"names":[],"mappings":"AAIA,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"subscription-trigger.d.ts","sourceRoot":"","sources":["../../../../../src/trigger/type/subscription-trigger.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAA6C,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErG,eAAO,MAAM,yBAAyB,EAAE,cAAc,CAAC,mBAAmB,CAkEzE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"timer-trigger.d.ts","sourceRoot":"","sources":["../../../../../src/trigger/type/timer-trigger.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAA6C,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErG,eAAO,MAAM,kBAAkB,EAAE,cAAc,CAAC,YAAY,CA8B3D,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"webhook-trigger.d.ts","sourceRoot":"","sources":["../../../../../src/trigger/type/webhook-trigger.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAA6C,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErG,eAAO,MAAM,oBAAoB,EAAE,cAAc,CAAC,cAAc,CAiC/D,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { type WebsocketTrigger } from '../../types';
|
|
2
|
-
import { type TriggerFactory } from '../trigger-registry';
|
|
3
|
-
interface WebsocketTriggerOptions {
|
|
4
|
-
retryDelay: number;
|
|
5
|
-
maxAttempts: number;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Websocket.
|
|
9
|
-
* NOTE: The port must be unique, so the same hook cannot be used for multiple spaces.
|
|
10
|
-
*/
|
|
11
|
-
export declare const createWebsocketTrigger: TriggerFactory<WebsocketTrigger, WebsocketTriggerOptions>;
|
|
12
|
-
export {};
|
|
13
|
-
//# sourceMappingURL=websocket-trigger.d.ts.map
|