@dxos/functions 0.5.3-main.f752aaa → 0.5.3-main.f9b873d
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 +802 -429
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +787 -426
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- 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/registry/function-registry.d.ts +24 -0
- package/dist/types/src/registry/function-registry.d.ts.map +1 -0
- package/dist/types/src/registry/function-registry.test.d.ts +2 -0
- package/dist/types/src/registry/function-registry.test.d.ts.map +1 -0
- package/dist/types/src/registry/index.d.ts +2 -0
- package/dist/types/src/registry/index.d.ts.map +1 -0
- 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 +12 -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 +40 -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 +129 -101
- package/dist/types/src/types.d.ts.map +1 -1
- package/package.json +18 -13
- package/schema/functions.json +128 -101
- package/src/handler.ts +54 -31
- package/src/index.ts +2 -0
- package/src/registry/function-registry.test.ts +105 -0
- package/src/registry/function-registry.ts +84 -0
- package/src/registry/index.ts +5 -0
- package/src/runtime/dev-server.test.ts +60 -0
- package/src/runtime/dev-server.ts +104 -52
- package/src/runtime/scheduler.test.ts +56 -73
- package/src/runtime/scheduler.ts +79 -271
- package/src/testing/functions-integration.test.ts +99 -0
- package/src/testing/index.ts +7 -0
- package/src/testing/setup.ts +45 -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 +229 -0
- package/src/trigger/trigger-registry.ts +176 -0
- package/src/trigger/type/index.ts +8 -0
- package/src/trigger/type/subscription-trigger.ts +73 -0
- package/src/trigger/type/timer-trigger.ts +44 -0
- package/src/trigger/type/webhook-trigger.ts +47 -0
- package/src/trigger/type/websocket-trigger.ts +91 -0
- package/src/types.ts +57 -32
|
@@ -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,CAiBpF,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,40 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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,EAAkB,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAOlD,OAAO,EAAE,KAAK,gBAAgB,EAAE,eAAe,EAAE,KAAK,mBAAmB,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAE9G,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;cAerD,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"}
|
|
@@ -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":"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,CA2DzE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -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":"AAUA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAA6C,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErG,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
|
-
url: S.$string;
|
|
10
|
-
init: S.PropertySignature<"?:", {
|
|
11
|
-
readonly [x: string]: any;
|
|
12
|
-
} | undefined, never, "?:", {
|
|
13
|
-
readonly [x: string]: any;
|
|
14
|
-
} | undefined, never>;
|
|
15
|
-
}>;
|
|
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';
|
|
16
9
|
declare const SubscriptionTriggerSchema: S.struct<{
|
|
17
|
-
|
|
10
|
+
type: S.literal<["subscription"]>;
|
|
18
11
|
filter: S.array<S.struct<{
|
|
19
12
|
type: S.$string;
|
|
20
13
|
props: S.PropertySignature<"?:", {
|
|
@@ -31,129 +24,164 @@ declare const SubscriptionTriggerSchema: S.struct<{
|
|
|
31
24
|
readonly delay?: number | undefined;
|
|
32
25
|
} | undefined, never>;
|
|
33
26
|
}>;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
27
|
+
export type SubscriptionTrigger = S.Schema.Type<typeof SubscriptionTriggerSchema>;
|
|
28
|
+
declare const TimerTriggerSchema: 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.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
|
-
|
|
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
|
+
meta?: {
|
|
66
|
+
readonly [x: string]: any;
|
|
67
|
+
} | undefined;
|
|
68
|
+
spec: {
|
|
58
69
|
readonly filter: readonly {
|
|
59
70
|
readonly type: string;
|
|
60
71
|
readonly props?: {
|
|
61
72
|
readonly [x: string]: any;
|
|
62
73
|
} | undefined;
|
|
63
74
|
}[];
|
|
64
|
-
readonly
|
|
75
|
+
readonly type: "subscription";
|
|
65
76
|
readonly options?: {
|
|
66
77
|
readonly deep?: boolean | undefined;
|
|
67
78
|
readonly delay?: number | undefined;
|
|
68
79
|
} | undefined;
|
|
69
|
-
} |
|
|
70
|
-
readonly
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
readonly
|
|
78
|
-
|
|
79
|
-
|
|
80
|
+
} | {
|
|
81
|
+
readonly type: "timer";
|
|
82
|
+
readonly cron: string;
|
|
83
|
+
} | {
|
|
84
|
+
port?: number | undefined;
|
|
85
|
+
type: "webhook";
|
|
86
|
+
method: string;
|
|
87
|
+
} | {
|
|
88
|
+
readonly type: "websocket";
|
|
89
|
+
readonly url: string;
|
|
90
|
+
readonly init?: {
|
|
91
|
+
readonly [x: string]: any;
|
|
80
92
|
} | undefined;
|
|
81
|
-
}
|
|
93
|
+
};
|
|
94
|
+
} & {
|
|
95
|
+
id: string;
|
|
82
96
|
}>;
|
|
83
|
-
export
|
|
84
|
-
|
|
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
|
-
/**
|
|
89
|
-
* Function definition.
|
|
90
|
-
*/
|
|
91
|
-
declare const FunctionDefSchema: S.struct<{
|
|
92
|
-
id: S.$string;
|
|
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>;
|
|
97
|
+
export declare class FunctionTrigger extends FunctionTrigger_base {
|
|
98
|
+
}
|
|
98
99
|
/**
|
|
99
100
|
* Function manifest file.
|
|
100
101
|
*/
|
|
101
102
|
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
|
-
|
|
122
|
-
|
|
123
|
-
readonly [x: string]: any;
|
|
124
|
-
} | undefined;
|
|
125
|
-
} | undefined, never, "?:", {
|
|
126
|
-
readonly url: string;
|
|
127
|
-
readonly init?: {
|
|
128
|
-
readonly [x: string]: any;
|
|
129
|
-
} | undefined;
|
|
130
|
-
} | undefined, never>;
|
|
131
|
-
subscription: S.PropertySignature<"?:", {
|
|
103
|
+
functions: S.PropertySignature<"?:", Omit<{
|
|
104
|
+
handler: string;
|
|
105
|
+
uri: string;
|
|
106
|
+
description?: string | undefined;
|
|
107
|
+
route: string;
|
|
108
|
+
} & {
|
|
109
|
+
id: string;
|
|
110
|
+
}, "id">[] | undefined, never, "?:", Omit<{
|
|
111
|
+
handler: string;
|
|
112
|
+
uri: string;
|
|
113
|
+
description?: string | undefined;
|
|
114
|
+
route: string;
|
|
115
|
+
} & {
|
|
116
|
+
id: string;
|
|
117
|
+
}, "id">[] | undefined, never>;
|
|
118
|
+
triggers: S.PropertySignature<"?:", Omit<{
|
|
119
|
+
function: string;
|
|
120
|
+
meta?: {
|
|
121
|
+
readonly [x: string]: any;
|
|
122
|
+
} | undefined;
|
|
123
|
+
spec: {
|
|
132
124
|
readonly filter: readonly {
|
|
133
125
|
readonly type: string;
|
|
134
126
|
readonly props?: {
|
|
135
127
|
readonly [x: string]: any;
|
|
136
128
|
} | undefined;
|
|
137
129
|
}[];
|
|
138
|
-
readonly
|
|
130
|
+
readonly type: "subscription";
|
|
139
131
|
readonly options?: {
|
|
140
132
|
readonly deep?: boolean | undefined;
|
|
141
133
|
readonly delay?: number | undefined;
|
|
142
134
|
} | undefined;
|
|
143
|
-
} |
|
|
135
|
+
} | {
|
|
136
|
+
readonly type: "timer";
|
|
137
|
+
readonly cron: string;
|
|
138
|
+
} | {
|
|
139
|
+
port?: number | undefined;
|
|
140
|
+
type: "webhook";
|
|
141
|
+
method: string;
|
|
142
|
+
} | {
|
|
143
|
+
readonly type: "websocket";
|
|
144
|
+
readonly url: string;
|
|
145
|
+
readonly init?: {
|
|
146
|
+
readonly [x: string]: any;
|
|
147
|
+
} | undefined;
|
|
148
|
+
};
|
|
149
|
+
} & {
|
|
150
|
+
id: string;
|
|
151
|
+
}, "id">[] | undefined, never, "?:", Omit<{
|
|
152
|
+
function: string;
|
|
153
|
+
meta?: {
|
|
154
|
+
readonly [x: string]: any;
|
|
155
|
+
} | undefined;
|
|
156
|
+
spec: {
|
|
144
157
|
readonly filter: readonly {
|
|
145
158
|
readonly type: string;
|
|
146
159
|
readonly props?: {
|
|
147
160
|
readonly [x: string]: any;
|
|
148
161
|
} | undefined;
|
|
149
162
|
}[];
|
|
150
|
-
readonly
|
|
163
|
+
readonly type: "subscription";
|
|
151
164
|
readonly options?: {
|
|
152
165
|
readonly deep?: boolean | undefined;
|
|
153
166
|
readonly delay?: number | undefined;
|
|
154
167
|
} | undefined;
|
|
155
|
-
} |
|
|
156
|
-
|
|
168
|
+
} | {
|
|
169
|
+
readonly type: "timer";
|
|
170
|
+
readonly cron: string;
|
|
171
|
+
} | {
|
|
172
|
+
port?: number | undefined;
|
|
173
|
+
type: "webhook";
|
|
174
|
+
method: string;
|
|
175
|
+
} | {
|
|
176
|
+
readonly type: "websocket";
|
|
177
|
+
readonly url: string;
|
|
178
|
+
readonly init?: {
|
|
179
|
+
readonly [x: string]: any;
|
|
180
|
+
} | undefined;
|
|
181
|
+
};
|
|
182
|
+
} & {
|
|
183
|
+
id: string;
|
|
184
|
+
}, "id">[] | undefined, never>;
|
|
157
185
|
}>;
|
|
158
186
|
export type FunctionManifest = S.Schema.Type<typeof FunctionManifestSchema>;
|
|
159
187
|
export {};
|
|
@@ -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":"AAIA,OAAO,EAAO,CAAC,EAAe,MAAM,mBAAmB,CAAC;AAKxD;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAAG,cAAc,GAAG,OAAO,GAAG,SAAS,GAAG,WAAW,CAAC;AAErF,QAAA,MAAM,yBAAyB;;;;;;;;;;;;;;;;;EAiB7B,CAAC;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAElF,QAAA,MAAM,kBAAkB;;;EAGtB,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAEpE,QAAA,MAAM,oBAAoB;;;;GAOzB,CAAC;AACF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAExE,QAAA,MAAM,sBAAsB;;;;;;;;EAI1B,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAQ5E,MAAM,MAAM,WAAW,GAAG,YAAY,GAAG,cAAc,GAAG,gBAAgB,GAAG,mBAAmB,CAAC;;;;;;;;;AAEjG;;GAEG;AACH,qBAAa,WAAY,SAAQ,gBAS/B;CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEL,qBAAa,eAAgB,SAAQ,oBAQnC;CAAG;AAEL;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGjC,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,sBAAsB,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/functions",
|
|
3
|
-
"version": "0.5.3-main.
|
|
3
|
+
"version": "0.5.3-main.f9b873d",
|
|
4
4
|
"description": "Functions SDK and runtime.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -20,30 +20,35 @@
|
|
|
20
20
|
"src"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@effect/schema": "0.64.7",
|
|
24
23
|
"@preact/signals-core": "^1.6.0",
|
|
25
24
|
"cron": "^3.1.6",
|
|
25
|
+
"effect": "^2.4.19",
|
|
26
26
|
"express": "^4.19.2",
|
|
27
27
|
"get-port-please": "^3.1.1",
|
|
28
28
|
"ws": "^8.14.2",
|
|
29
|
-
"@braneframe/types": "0.5.3-main.
|
|
30
|
-
"@dxos/async": "0.5.3-main.
|
|
31
|
-
"@dxos/client": "0.5.3-main.
|
|
32
|
-
"@dxos/
|
|
33
|
-
"@dxos/
|
|
34
|
-
"@dxos/
|
|
35
|
-
"@dxos/
|
|
36
|
-
"@dxos/
|
|
37
|
-
"@dxos/
|
|
29
|
+
"@braneframe/types": "0.5.3-main.f9b873d",
|
|
30
|
+
"@dxos/async": "0.5.3-main.f9b873d",
|
|
31
|
+
"@dxos/client": "0.5.3-main.f9b873d",
|
|
32
|
+
"@dxos/context": "0.5.3-main.f9b873d",
|
|
33
|
+
"@dxos/echo-db": "0.5.3-main.f9b873d",
|
|
34
|
+
"@dxos/echo-schema": "0.5.3-main.f9b873d",
|
|
35
|
+
"@dxos/invariant": "0.5.3-main.f9b873d",
|
|
36
|
+
"@dxos/keys": "0.5.3-main.f9b873d",
|
|
37
|
+
"@dxos/log": "0.5.3-main.f9b873d",
|
|
38
|
+
"@dxos/node-std": "0.5.3-main.f9b873d",
|
|
39
|
+
"@dxos/util": "0.5.3-main.f9b873d",
|
|
40
|
+
"@dxos/protocols": "0.5.3-main.f9b873d"
|
|
38
41
|
},
|
|
39
42
|
"devDependencies": {
|
|
40
43
|
"@types/express": "^4.17.17",
|
|
41
|
-
"@types/ws": "^7.4.0"
|
|
44
|
+
"@types/ws": "^7.4.0",
|
|
45
|
+
"@dxos/agent": "0.5.3-main.f9b873d"
|
|
42
46
|
},
|
|
43
47
|
"publishConfig": {
|
|
44
48
|
"access": "public"
|
|
45
49
|
},
|
|
46
50
|
"scripts": {
|
|
47
|
-
"schema": "ts-node ./tools/schema.ts"
|
|
51
|
+
"gen-schema": "ts-node ./tools/schema.ts",
|
|
52
|
+
"prebuild": "pnpm gen-schema"
|
|
48
53
|
}
|
|
49
54
|
}
|