@dxos/functions 0.5.3-main.f752aaa → 0.5.3-main.fffc127
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/chunk-4D4I3YMJ.mjs +86 -0
- package/dist/lib/browser/chunk-4D4I3YMJ.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +884 -457
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/types.mjs +14 -0
- package/dist/lib/browser/types.mjs.map +7 -0
- package/dist/lib/node/chunk-3UYUR5N5.cjs +103 -0
- package/dist/lib/node/chunk-3UYUR5N5.cjs.map +7 -0
- package/dist/lib/node/index.cjs +868 -447
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/types.cjs +35 -0
- package/dist/lib/node/types.cjs.map +7 -0
- package/dist/types/src/browser/index.d.ts +2 -0
- package/dist/types/src/browser/index.d.ts.map +1 -0
- package/dist/types/src/function/function-registry.d.ts +24 -0
- package/dist/types/src/function/function-registry.d.ts.map +1 -0
- package/dist/types/src/function/function-registry.test.d.ts +2 -0
- package/dist/types/src/function/function-registry.test.d.ts.map +1 -0
- package/dist/types/src/function/index.d.ts +2 -0
- package/dist/types/src/function/index.d.ts.map +1 -0
- package/dist/types/src/handler.d.ts +33 -12
- package/dist/types/src/handler.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/runtime/dev-server.d.ts +16 -13
- package/dist/types/src/runtime/dev-server.d.ts.map +1 -1
- package/dist/types/src/runtime/dev-server.test.d.ts +2 -0
- package/dist/types/src/runtime/dev-server.test.d.ts.map +1 -0
- package/dist/types/src/runtime/scheduler.d.ts +13 -27
- package/dist/types/src/runtime/scheduler.d.ts.map +1 -1
- package/dist/types/src/testing/functions-integration.test.d.ts +2 -0
- package/dist/types/src/testing/functions-integration.test.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +4 -0
- package/dist/types/src/testing/index.d.ts.map +1 -0
- package/dist/types/src/testing/setup.d.ts +5 -0
- package/dist/types/src/testing/setup.d.ts.map +1 -0
- package/dist/types/src/testing/test/handler.d.ts +4 -0
- package/dist/types/src/testing/test/handler.d.ts.map +1 -0
- package/dist/types/src/testing/test/index.d.ts +3 -0
- package/dist/types/src/testing/test/index.d.ts.map +1 -0
- package/dist/types/src/testing/types.d.ts +9 -0
- package/dist/types/src/testing/types.d.ts.map +1 -0
- package/dist/types/src/testing/util.d.ts +3 -0
- package/dist/types/src/testing/util.d.ts.map +1 -0
- package/dist/types/src/trigger/index.d.ts +2 -0
- package/dist/types/src/trigger/index.d.ts.map +1 -0
- package/dist/types/src/trigger/trigger-registry.d.ts +37 -0
- package/dist/types/src/trigger/trigger-registry.d.ts.map +1 -0
- package/dist/types/src/trigger/trigger-registry.test.d.ts +2 -0
- package/dist/types/src/trigger/trigger-registry.test.d.ts.map +1 -0
- package/dist/types/src/trigger/type/index.d.ts +5 -0
- package/dist/types/src/trigger/type/index.d.ts.map +1 -0
- package/dist/types/src/trigger/type/subscription-trigger.d.ts +4 -0
- package/dist/types/src/trigger/type/subscription-trigger.d.ts.map +1 -0
- package/dist/types/src/trigger/type/timer-trigger.d.ts +4 -0
- package/dist/types/src/trigger/type/timer-trigger.d.ts.map +1 -0
- package/dist/types/src/trigger/type/webhook-trigger.d.ts +4 -0
- package/dist/types/src/trigger/type/webhook-trigger.d.ts.map +1 -0
- package/dist/types/src/trigger/type/websocket-trigger.d.ts +13 -0
- package/dist/types/src/trigger/type/websocket-trigger.d.ts.map +1 -0
- package/dist/types/src/types.d.ts +162 -107
- package/dist/types/src/types.d.ts.map +1 -1
- package/package.json +33 -15
- package/schema/functions.json +144 -103
- package/src/browser/index.ts +5 -0
- package/src/function/function-registry.test.ts +105 -0
- package/src/function/function-registry.ts +90 -0
- package/src/function/index.ts +5 -0
- package/src/handler.ts +54 -31
- package/src/index.ts +2 -0
- package/src/runtime/dev-server.test.ts +60 -0
- package/src/runtime/dev-server.ts +104 -53
- package/src/runtime/scheduler.test.ts +61 -73
- package/src/runtime/scheduler.ts +91 -270
- package/src/testing/functions-integration.test.ts +100 -0
- package/src/testing/index.ts +7 -0
- package/src/testing/setup.ts +43 -0
- package/src/testing/test/handler.ts +15 -0
- package/src/testing/test/index.ts +7 -0
- package/src/testing/types.ts +9 -0
- package/src/testing/util.ts +16 -0
- package/src/trigger/index.ts +5 -0
- package/src/trigger/trigger-registry.test.ts +272 -0
- package/src/trigger/trigger-registry.ts +211 -0
- package/src/trigger/type/index.ts +8 -0
- package/src/trigger/type/subscription-trigger.ts +86 -0
- package/src/trigger/type/timer-trigger.ts +45 -0
- package/src/trigger/type/webhook-trigger.ts +48 -0
- package/src/trigger/type/websocket-trigger.ts +92 -0
- package/src/types.ts +87 -48
|
@@ -1,41 +1,27 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import { type
|
|
1
|
+
import { type Space } from '@dxos/client/echo';
|
|
2
|
+
import { type FunctionRegistry } from '../function';
|
|
3
|
+
import { type TriggerRegistry } from '../trigger';
|
|
3
4
|
import { type FunctionManifest } from '../types';
|
|
4
|
-
type Callback = (data:
|
|
5
|
+
export type Callback = (data: any) => Promise<void | number>;
|
|
5
6
|
export type SchedulerOptions = {
|
|
6
7
|
endpoint?: string;
|
|
7
8
|
callback?: Callback;
|
|
8
9
|
};
|
|
9
10
|
/**
|
|
10
|
-
* The scheduler triggers function
|
|
11
|
+
* The scheduler triggers function execution based on various triggers.
|
|
11
12
|
*/
|
|
12
13
|
export declare class Scheduler {
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
readonly functions: FunctionRegistry;
|
|
15
|
+
readonly triggers: TriggerRegistry;
|
|
15
16
|
private readonly _options;
|
|
16
|
-
private
|
|
17
|
-
|
|
17
|
+
private _ctx;
|
|
18
|
+
private readonly _functionUriToCallMutex;
|
|
19
|
+
constructor(functions: FunctionRegistry, triggers: TriggerRegistry, _options?: SchedulerOptions);
|
|
18
20
|
start(): Promise<void>;
|
|
19
21
|
stop(): Promise<void>;
|
|
20
|
-
|
|
21
|
-
private
|
|
22
|
+
register(space: Space, manifest: FunctionManifest): Promise<void>;
|
|
23
|
+
private _safeActivateTriggers;
|
|
24
|
+
private activate;
|
|
22
25
|
private _execFunction;
|
|
23
|
-
/**
|
|
24
|
-
* Cron timer.
|
|
25
|
-
*/
|
|
26
|
-
private _createTimer;
|
|
27
|
-
/**
|
|
28
|
-
* Webhook.
|
|
29
|
-
*/
|
|
30
|
-
private _createWebhook;
|
|
31
|
-
/**
|
|
32
|
-
* Websocket.
|
|
33
|
-
*/
|
|
34
|
-
private _createWebsocket;
|
|
35
|
-
/**
|
|
36
|
-
* ECHO subscription.
|
|
37
|
-
*/
|
|
38
|
-
private _createSubscription;
|
|
39
26
|
}
|
|
40
|
-
export {};
|
|
41
27
|
//# sourceMappingURL=scheduler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scheduler.d.ts","sourceRoot":"","sources":["../../../../src/runtime/scheduler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"scheduler.d.ts","sourceRoot":"","sources":["../../../../src/runtime/scheduler.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAI/C,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAoB,KAAK,gBAAgB,EAAwB,MAAM,UAAU,CAAC;AAEzF,MAAM,MAAM,QAAQ,GAAG,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC,CAAC;AAE7D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB,CAAC;AAEF;;GAEG;AACH,qBAAa,SAAS;aAMF,SAAS,EAAE,gBAAgB;aAC3B,QAAQ,EAAE,eAAe;IACzC,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAP3B,OAAO,CAAC,IAAI,CAAmB;IAE/B,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAA4B;gBAGlD,SAAS,EAAE,gBAAgB,EAC3B,QAAQ,EAAE,eAAe,EACxB,QAAQ,GAAE,gBAAqB;IAU5C,KAAK;IAOL,IAAI;IAOG,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,gBAAgB;YAKhD,qBAAqB;YAWrB,QAAQ;YAwBR,aAAa;CA2C5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functions-integration.test.d.ts","sourceRoot":"","sources":["../../../../src/testing/functions-integration.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,5 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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,CAepF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../../../src/testing/test/handler.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAIrD,eAAO,MAAM,kBAAkB,YAAa,gBAAgB,GAAG,CAAC,SAE/D,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,eAAe,CAAC,GAAG,CAExC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/testing/test/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/testing/types.ts"],"names":[],"mappings":";;;;;AAMA,qBAAa,QAAS,SAAQ,aAE5B;CAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/trigger/index.ts"],"names":[],"mappings":"AAIA,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
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 TriggerFactory<Spec extends TriggerSpec, Options = any> = (ctx: Context, space: Space, spec: Spec, callback: TriggerCallback, options?: Options) => Promise<void>;
|
|
9
|
+
export type TriggerHandlerMap = {
|
|
10
|
+
[type in FunctionTriggerType]: TriggerFactory<any>;
|
|
11
|
+
};
|
|
12
|
+
export type TriggerEvent = {
|
|
13
|
+
space: Space;
|
|
14
|
+
triggers: FunctionTrigger[];
|
|
15
|
+
};
|
|
16
|
+
export declare class TriggerRegistry extends Resource {
|
|
17
|
+
private readonly _client;
|
|
18
|
+
private readonly _options?;
|
|
19
|
+
private readonly _triggersBySpaceKey;
|
|
20
|
+
readonly registered: Event<TriggerEvent>;
|
|
21
|
+
readonly removed: Event<TriggerEvent>;
|
|
22
|
+
constructor(_client: Client, _options?: TriggerHandlerMap | undefined);
|
|
23
|
+
getActiveTriggers(space: Space): FunctionTrigger[];
|
|
24
|
+
getInactiveTriggers(space: Space): FunctionTrigger[];
|
|
25
|
+
activate(space: Space, trigger: FunctionTrigger, callback: TriggerCallback): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Loads triggers from the manifest into the space.
|
|
28
|
+
*/
|
|
29
|
+
register(space: Space, manifest: FunctionManifest): Promise<void>;
|
|
30
|
+
protected _open(): Promise<void>;
|
|
31
|
+
protected _close(_: Context): Promise<void>;
|
|
32
|
+
private _handleNewTriggers;
|
|
33
|
+
private _handleRemovedTriggers;
|
|
34
|
+
private _getTriggers;
|
|
35
|
+
}
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=trigger-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{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E,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,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBhG;;OAEG;IACU,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;cAoCrD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;cA8BtB,MAAM,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAM1D,OAAO,CAAC,kBAAkB;YAiBZ,sBAAsB;IA0BpC,OAAO,CAAC,YAAY;CAIrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trigger-registry.test.d.ts","sourceRoot":"","sources":["../../../../src/trigger/trigger-registry.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscription-trigger.d.ts","sourceRoot":"","sources":["../../../../../src/trigger/type/subscription-trigger.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAwB,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAEhF,eAAO,MAAM,yBAAyB,EAAE,cAAc,CAAC,mBAAmB,CAuEzE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timer-trigger.d.ts","sourceRoot":"","sources":["../../../../../src/trigger/type/timer-trigger.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAwB,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAEhF,eAAO,MAAM,kBAAkB,EAAE,cAAc,CAAC,YAAY,CA8B3D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhook-trigger.d.ts","sourceRoot":"","sources":["../../../../../src/trigger/type/webhook-trigger.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAwB,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAEhF,eAAO,MAAM,oBAAoB,EAAE,cAAc,CAAC,cAAc,CAiC/D,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"websocket-trigger.d.ts","sourceRoot":"","sources":["../../../../../src/trigger/type/websocket-trigger.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAwB,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAEhF,UAAU,uBAAuB;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,cAAc,CAAC,gBAAgB,EAAE,uBAAuB,CAoE5F,CAAC"}
|
|
@@ -1,20 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
readonly [x: string]: any;
|
|
12
|
-
} | undefined, never, "?:", {
|
|
13
|
-
readonly [x: string]: any;
|
|
14
|
-
} | undefined, never>;
|
|
15
|
-
}>;
|
|
16
|
-
declare const SubscriptionTriggerSchema: S.struct<{
|
|
17
|
-
spaceKey: S.PropertySignature<"?:", string | undefined, never, "?:", string | undefined, never>;
|
|
1
|
+
import { S } from '@dxos/echo-schema';
|
|
2
|
+
/**
|
|
3
|
+
* Type discriminator for TriggerSpec.
|
|
4
|
+
* Every spec has a type field of type FunctionTriggerType that we can use to understand which
|
|
5
|
+
* type we're working with.
|
|
6
|
+
* https://www.typescriptlang.org/docs/handbook/2/narrowing.html#discriminated-unions
|
|
7
|
+
*/
|
|
8
|
+
export type FunctionTriggerType = 'subscription' | 'timer' | 'webhook' | 'websocket';
|
|
9
|
+
declare const SubscriptionTriggerSchema: S.mutable<S.struct<{
|
|
10
|
+
type: S.literal<["subscription"]>;
|
|
18
11
|
filter: S.array<S.struct<{
|
|
19
12
|
type: S.$string;
|
|
20
13
|
props: S.PropertySignature<"?:", {
|
|
@@ -30,131 +23,193 @@ declare const SubscriptionTriggerSchema: S.struct<{
|
|
|
30
23
|
readonly deep?: boolean | undefined;
|
|
31
24
|
readonly delay?: number | undefined;
|
|
32
25
|
} | undefined, never>;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
26
|
+
}>>;
|
|
27
|
+
export type SubscriptionTrigger = S.Schema.Type<typeof SubscriptionTriggerSchema>;
|
|
28
|
+
declare const TimerTriggerSchema: S.mutable<S.struct<{
|
|
29
|
+
type: S.literal<["timer"]>;
|
|
30
|
+
cron: S.$string;
|
|
31
|
+
}>>;
|
|
32
|
+
export type TimerTrigger = S.Schema.Type<typeof TimerTriggerSchema>;
|
|
33
|
+
declare const WebhookTriggerSchema: S.mutable<S.struct<{
|
|
34
|
+
type: S.literal<["webhook"]>;
|
|
35
|
+
method: S.$string;
|
|
36
|
+
port: S.PropertySignature<"?:", number | undefined, never, "?:", number | undefined, never>;
|
|
37
|
+
}>>;
|
|
38
|
+
export type WebhookTrigger = S.Schema.Type<typeof WebhookTriggerSchema>;
|
|
39
|
+
declare const WebsocketTriggerSchema: S.mutable<S.struct<{
|
|
40
|
+
type: S.literal<["websocket"]>;
|
|
41
|
+
url: S.$string;
|
|
42
|
+
init: S.PropertySignature<"?:", {
|
|
43
|
+
readonly [x: string]: any;
|
|
51
44
|
} | undefined, never, "?:", {
|
|
52
|
-
readonly
|
|
53
|
-
readonly init?: {
|
|
54
|
-
readonly [x: string]: any;
|
|
55
|
-
} | undefined;
|
|
45
|
+
readonly [x: string]: any;
|
|
56
46
|
} | undefined, never>;
|
|
57
|
-
|
|
58
|
-
|
|
47
|
+
}>>;
|
|
48
|
+
export type WebsocketTrigger = S.Schema.Type<typeof WebsocketTriggerSchema>;
|
|
49
|
+
export type TriggerSpec = TimerTrigger | WebhookTrigger | WebsocketTrigger | SubscriptionTrigger;
|
|
50
|
+
declare const FunctionDef_base: import("@dxos/echo-schema").EchoSchemaClass<{
|
|
51
|
+
handler: string;
|
|
52
|
+
uri: string;
|
|
53
|
+
description?: string | undefined;
|
|
54
|
+
route: string;
|
|
55
|
+
} & {
|
|
56
|
+
id: string;
|
|
57
|
+
}>;
|
|
58
|
+
/**
|
|
59
|
+
* Function definition.
|
|
60
|
+
*/
|
|
61
|
+
export declare class FunctionDef extends FunctionDef_base {
|
|
62
|
+
}
|
|
63
|
+
declare const FunctionTrigger_base: import("@dxos/echo-schema").EchoSchemaClass<{
|
|
64
|
+
function: string;
|
|
65
|
+
enabled?: boolean | undefined;
|
|
66
|
+
meta?: {
|
|
67
|
+
[x: string]: any;
|
|
68
|
+
} | undefined;
|
|
69
|
+
spec: {
|
|
70
|
+
filter: readonly {
|
|
59
71
|
readonly type: string;
|
|
60
72
|
readonly props?: {
|
|
61
73
|
readonly [x: string]: any;
|
|
62
74
|
} | undefined;
|
|
63
75
|
}[];
|
|
64
|
-
|
|
65
|
-
|
|
76
|
+
type: "subscription";
|
|
77
|
+
options?: {
|
|
66
78
|
readonly deep?: boolean | undefined;
|
|
67
79
|
readonly delay?: number | undefined;
|
|
68
80
|
} | undefined;
|
|
69
|
-
} |
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
81
|
+
} | {
|
|
82
|
+
type: "timer";
|
|
83
|
+
cron: string;
|
|
84
|
+
} | {
|
|
85
|
+
port?: number | undefined;
|
|
86
|
+
type: "webhook";
|
|
87
|
+
method: string;
|
|
88
|
+
} | {
|
|
89
|
+
type: "websocket";
|
|
90
|
+
url: string;
|
|
91
|
+
init?: {
|
|
92
|
+
readonly [x: string]: any;
|
|
80
93
|
} | undefined;
|
|
81
|
-
}
|
|
94
|
+
};
|
|
95
|
+
} & {
|
|
96
|
+
id: string;
|
|
82
97
|
}>;
|
|
83
|
-
export type TimerTrigger = S.Schema.Type<typeof TimerTriggerSchema>;
|
|
84
|
-
export type WebhookTrigger = S.Schema.Type<typeof WebhookTriggerSchema>;
|
|
85
|
-
export type WebsocketTrigger = S.Schema.Type<typeof WebsocketTriggerSchema>;
|
|
86
|
-
export type SubscriptionTrigger = S.Schema.Type<typeof SubscriptionTriggerSchema>;
|
|
87
|
-
export type FunctionTrigger = S.Schema.Type<typeof FunctionTriggerSchema>;
|
|
88
98
|
/**
|
|
89
|
-
* Function
|
|
99
|
+
* Function trigger.
|
|
90
100
|
*/
|
|
91
|
-
declare
|
|
92
|
-
|
|
93
|
-
description: S.PropertySignature<"?:", string | undefined, never, "?:", string | undefined, never>;
|
|
94
|
-
name: S.$string;
|
|
95
|
-
handler: S.$string;
|
|
96
|
-
}>;
|
|
97
|
-
export type FunctionDef = S.Schema.Type<typeof FunctionDefSchema>;
|
|
101
|
+
export declare class FunctionTrigger extends FunctionTrigger_base {
|
|
102
|
+
}
|
|
98
103
|
/**
|
|
99
104
|
* Function manifest file.
|
|
100
105
|
*/
|
|
101
106
|
export declare const FunctionManifestSchema: S.struct<{
|
|
102
|
-
functions: S.
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
readonly
|
|
122
|
-
|
|
123
|
-
readonly
|
|
124
|
-
}
|
|
125
|
-
} | undefined
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
107
|
+
functions: S.PropertySignature<"?:", ({
|
|
108
|
+
handler: string;
|
|
109
|
+
uri: string;
|
|
110
|
+
description?: string | undefined;
|
|
111
|
+
route: string;
|
|
112
|
+
} & {
|
|
113
|
+
"@meta"?: {
|
|
114
|
+
readonly keys: {
|
|
115
|
+
readonly id: string;
|
|
116
|
+
readonly source: string;
|
|
117
|
+
}[];
|
|
118
|
+
} | undefined;
|
|
119
|
+
})[] | undefined, never, "?:", ({
|
|
120
|
+
handler: string;
|
|
121
|
+
uri: string;
|
|
122
|
+
description?: string | undefined;
|
|
123
|
+
route: string;
|
|
124
|
+
} & {
|
|
125
|
+
"@meta"?: {
|
|
126
|
+
readonly keys: {
|
|
127
|
+
readonly id: string;
|
|
128
|
+
readonly source: string;
|
|
129
|
+
}[];
|
|
130
|
+
} | undefined;
|
|
131
|
+
})[] | undefined, never>;
|
|
132
|
+
triggers: S.PropertySignature<"?:", ({
|
|
133
|
+
function: string;
|
|
134
|
+
enabled?: boolean | undefined;
|
|
135
|
+
meta?: {
|
|
136
|
+
[x: string]: any;
|
|
137
|
+
} | undefined;
|
|
138
|
+
spec: {
|
|
139
|
+
filter: readonly {
|
|
133
140
|
readonly type: string;
|
|
134
141
|
readonly props?: {
|
|
135
142
|
readonly [x: string]: any;
|
|
136
143
|
} | undefined;
|
|
137
144
|
}[];
|
|
138
|
-
|
|
139
|
-
|
|
145
|
+
type: "subscription";
|
|
146
|
+
options?: {
|
|
140
147
|
readonly deep?: boolean | undefined;
|
|
141
148
|
readonly delay?: number | undefined;
|
|
142
149
|
} | undefined;
|
|
143
|
-
} |
|
|
144
|
-
|
|
150
|
+
} | {
|
|
151
|
+
type: "timer";
|
|
152
|
+
cron: string;
|
|
153
|
+
} | {
|
|
154
|
+
port?: number | undefined;
|
|
155
|
+
type: "webhook";
|
|
156
|
+
method: string;
|
|
157
|
+
} | {
|
|
158
|
+
type: "websocket";
|
|
159
|
+
url: string;
|
|
160
|
+
init?: {
|
|
161
|
+
readonly [x: string]: any;
|
|
162
|
+
} | undefined;
|
|
163
|
+
};
|
|
164
|
+
} & {
|
|
165
|
+
"@meta"?: {
|
|
166
|
+
readonly keys: {
|
|
167
|
+
readonly id: string;
|
|
168
|
+
readonly source: string;
|
|
169
|
+
}[];
|
|
170
|
+
} | undefined;
|
|
171
|
+
})[] | undefined, never, "?:", ({
|
|
172
|
+
function: string;
|
|
173
|
+
enabled?: boolean | undefined;
|
|
174
|
+
meta?: {
|
|
175
|
+
[x: string]: any;
|
|
176
|
+
} | undefined;
|
|
177
|
+
spec: {
|
|
178
|
+
filter: readonly {
|
|
145
179
|
readonly type: string;
|
|
146
180
|
readonly props?: {
|
|
147
181
|
readonly [x: string]: any;
|
|
148
182
|
} | undefined;
|
|
149
183
|
}[];
|
|
150
|
-
|
|
151
|
-
|
|
184
|
+
type: "subscription";
|
|
185
|
+
options?: {
|
|
152
186
|
readonly deep?: boolean | undefined;
|
|
153
187
|
readonly delay?: number | undefined;
|
|
154
188
|
} | undefined;
|
|
155
|
-
} |
|
|
156
|
-
|
|
189
|
+
} | {
|
|
190
|
+
type: "timer";
|
|
191
|
+
cron: string;
|
|
192
|
+
} | {
|
|
193
|
+
port?: number | undefined;
|
|
194
|
+
type: "webhook";
|
|
195
|
+
method: string;
|
|
196
|
+
} | {
|
|
197
|
+
type: "websocket";
|
|
198
|
+
url: string;
|
|
199
|
+
init?: {
|
|
200
|
+
readonly [x: string]: any;
|
|
201
|
+
} | undefined;
|
|
202
|
+
};
|
|
203
|
+
} & {
|
|
204
|
+
"@meta"?: {
|
|
205
|
+
readonly keys: {
|
|
206
|
+
readonly id: string;
|
|
207
|
+
readonly source: string;
|
|
208
|
+
}[];
|
|
209
|
+
} | undefined;
|
|
210
|
+
})[] | undefined, never>;
|
|
157
211
|
}>;
|
|
158
212
|
export type FunctionManifest = S.Schema.Type<typeof FunctionManifestSchema>;
|
|
213
|
+
export declare const FUNCTION_SCHEMA: (typeof FunctionDef | typeof FunctionTrigger)[];
|
|
159
214
|
export {};
|
|
160
215
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AA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