@dxos/functions 0.5.3-main.6f2dfea → 0.5.3-main.79e0565
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 +764 -476
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +745 -471
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- 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 +32 -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 +7 -10
- package/dist/types/src/runtime/dev-server.d.ts.map +1 -1
- package/dist/types/src/runtime/scheduler.d.ts +11 -59
- 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 +1 -0
- package/dist/types/src/testing/test/handler.d.ts.map +1 -1
- 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 +131 -111
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/src/util.d.ts +15 -0
- package/dist/types/src/util.d.ts.map +1 -0
- package/dist/types/src/util.test.d.ts +2 -0
- package/dist/types/src/util.test.d.ts.map +1 -0
- package/package.json +14 -12
- package/schema/functions.json +140 -112
- 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 +50 -27
- package/src/index.ts +2 -0
- package/src/runtime/dev-server.test.ts +15 -35
- package/src/runtime/dev-server.ts +40 -23
- package/src/runtime/scheduler.test.ts +54 -75
- package/src/runtime/scheduler.ts +75 -300
- 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 +8 -2
- 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 +255 -0
- package/src/trigger/trigger-registry.ts +189 -0
- package/src/trigger/type/index.ts +8 -0
- package/src/trigger/type/subscription-trigger.ts +80 -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 +58 -40
- package/src/util.test.ts +43 -0
- package/src/util.ts +48 -0
|
@@ -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,UAAU,CAAe;gBAGxB,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;YAmBR,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,CAiBpF,CAAC"}
|
|
@@ -1 +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;
|
|
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":"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,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"}
|
|
@@ -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,CAkEzE,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,21 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
declare const WebsocketTriggerSchema: S.struct<{
|
|
10
|
-
url: S.$string;
|
|
11
|
-
init: S.PropertySignature<"?:", {
|
|
12
|
-
readonly [x: string]: any;
|
|
13
|
-
} | undefined, never, "?:", {
|
|
14
|
-
readonly [x: string]: any;
|
|
15
|
-
} | undefined, never>;
|
|
16
|
-
}>;
|
|
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';
|
|
17
9
|
declare const SubscriptionTriggerSchema: S.struct<{
|
|
18
|
-
|
|
10
|
+
type: S.literal<["subscription"]>;
|
|
19
11
|
filter: S.array<S.struct<{
|
|
20
12
|
type: S.$string;
|
|
21
13
|
props: S.PropertySignature<"?:", {
|
|
@@ -32,150 +24,178 @@ declare const SubscriptionTriggerSchema: S.struct<{
|
|
|
32
24
|
readonly delay?: number | undefined;
|
|
33
25
|
} | undefined, never>;
|
|
34
26
|
}>;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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<"?:", {
|
|
38
43
|
readonly [x: string]: any;
|
|
39
44
|
} | undefined, never, "?:", {
|
|
40
45
|
readonly [x: string]: any;
|
|
41
46
|
} | undefined, never>;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
readonly [x: string]: any;
|
|
63
|
-
} | undefined;
|
|
64
|
-
} | undefined, never>;
|
|
65
|
-
subscription: S.PropertySignature<"?:", {
|
|
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?: object | undefined;
|
|
66
|
+
spec: {
|
|
66
67
|
readonly filter: readonly {
|
|
67
68
|
readonly type: string;
|
|
68
69
|
readonly props?: {
|
|
69
70
|
readonly [x: string]: any;
|
|
70
71
|
} | undefined;
|
|
71
72
|
}[];
|
|
72
|
-
readonly
|
|
73
|
+
readonly type: "subscription";
|
|
73
74
|
readonly options?: {
|
|
74
75
|
readonly deep?: boolean | undefined;
|
|
75
76
|
readonly delay?: number | undefined;
|
|
76
77
|
} | undefined;
|
|
77
|
-
} |
|
|
78
|
-
readonly
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
readonly
|
|
86
|
-
|
|
87
|
-
|
|
78
|
+
} | {
|
|
79
|
+
readonly type: "timer";
|
|
80
|
+
readonly cron: string;
|
|
81
|
+
} | {
|
|
82
|
+
port?: number | undefined;
|
|
83
|
+
type: "webhook";
|
|
84
|
+
method: string;
|
|
85
|
+
} | {
|
|
86
|
+
readonly type: "websocket";
|
|
87
|
+
readonly url: string;
|
|
88
|
+
readonly init?: {
|
|
89
|
+
readonly [x: string]: any;
|
|
88
90
|
} | undefined;
|
|
89
|
-
}
|
|
91
|
+
};
|
|
92
|
+
} & {
|
|
93
|
+
id: string;
|
|
90
94
|
}>;
|
|
91
|
-
export
|
|
92
|
-
|
|
93
|
-
export type WebsocketTrigger = S.Schema.Type<typeof WebsocketTriggerSchema>;
|
|
94
|
-
export type SubscriptionTrigger = S.Schema.Type<typeof SubscriptionTriggerSchema>;
|
|
95
|
-
export type FunctionTrigger = S.Schema.Type<typeof FunctionTriggerSchema>;
|
|
96
|
-
/**
|
|
97
|
-
* Function definition.
|
|
98
|
-
*/
|
|
99
|
-
declare const FunctionDefSchema: S.struct<{
|
|
100
|
-
id: S.$string;
|
|
101
|
-
description: S.PropertySignature<"?:", string | undefined, never, "?:", string | undefined, never>;
|
|
102
|
-
path: S.$string;
|
|
103
|
-
handler: S.$string;
|
|
104
|
-
}>;
|
|
105
|
-
export type FunctionDef = S.Schema.Type<typeof FunctionDefSchema>;
|
|
95
|
+
export declare class FunctionTrigger extends FunctionTrigger_base {
|
|
96
|
+
}
|
|
106
97
|
/**
|
|
107
98
|
* Function manifest file.
|
|
108
99
|
*/
|
|
109
100
|
export declare const FunctionManifestSchema: S.struct<{
|
|
110
|
-
functions: S.
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
readonly timer?: {
|
|
122
|
-
readonly cron: string;
|
|
123
|
-
} | undefined;
|
|
124
|
-
readonly webhook?: {
|
|
125
|
-
port?: number | undefined;
|
|
126
|
-
method: string;
|
|
101
|
+
functions: S.PropertySignature<"?:", ({
|
|
102
|
+
handler: string;
|
|
103
|
+
uri: string;
|
|
104
|
+
description?: string | undefined;
|
|
105
|
+
route: string;
|
|
106
|
+
} & {
|
|
107
|
+
"@meta"?: {
|
|
108
|
+
readonly keys: {
|
|
109
|
+
readonly id: string;
|
|
110
|
+
readonly source: string;
|
|
111
|
+
}[];
|
|
127
112
|
} | undefined;
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
113
|
+
})[] | undefined, never, "?:", ({
|
|
114
|
+
handler: string;
|
|
115
|
+
uri: string;
|
|
116
|
+
description?: string | undefined;
|
|
117
|
+
route: string;
|
|
118
|
+
} & {
|
|
119
|
+
"@meta"?: {
|
|
120
|
+
readonly keys: {
|
|
121
|
+
readonly id: string;
|
|
122
|
+
readonly source: string;
|
|
123
|
+
}[];
|
|
133
124
|
} | undefined;
|
|
134
|
-
|
|
125
|
+
})[] | undefined, never>;
|
|
126
|
+
triggers: S.PropertySignature<"?:", ({
|
|
127
|
+
function: string;
|
|
128
|
+
meta?: object | undefined;
|
|
129
|
+
spec: {
|
|
135
130
|
readonly filter: readonly {
|
|
136
131
|
readonly type: string;
|
|
137
132
|
readonly props?: {
|
|
138
133
|
readonly [x: string]: any;
|
|
139
134
|
} | undefined;
|
|
140
135
|
}[];
|
|
141
|
-
readonly
|
|
136
|
+
readonly type: "subscription";
|
|
142
137
|
readonly options?: {
|
|
143
138
|
readonly deep?: boolean | undefined;
|
|
144
139
|
readonly delay?: number | undefined;
|
|
145
140
|
} | undefined;
|
|
146
|
-
} |
|
|
147
|
-
|
|
148
|
-
readonly function: string;
|
|
149
|
-
readonly context?: {
|
|
150
|
-
readonly [x: string]: any;
|
|
151
|
-
} | undefined;
|
|
152
|
-
readonly timer?: {
|
|
141
|
+
} | {
|
|
142
|
+
readonly type: "timer";
|
|
153
143
|
readonly cron: string;
|
|
154
|
-
} |
|
|
155
|
-
readonly webhook?: {
|
|
156
|
-
method: string;
|
|
144
|
+
} | {
|
|
157
145
|
port?: number | undefined;
|
|
158
|
-
|
|
159
|
-
|
|
146
|
+
type: "webhook";
|
|
147
|
+
method: string;
|
|
148
|
+
} | {
|
|
149
|
+
readonly type: "websocket";
|
|
160
150
|
readonly url: string;
|
|
161
151
|
readonly init?: {
|
|
162
152
|
readonly [x: string]: any;
|
|
163
153
|
} | undefined;
|
|
154
|
+
};
|
|
155
|
+
} & {
|
|
156
|
+
"@meta"?: {
|
|
157
|
+
readonly keys: {
|
|
158
|
+
readonly id: string;
|
|
159
|
+
readonly source: string;
|
|
160
|
+
}[];
|
|
164
161
|
} | undefined;
|
|
165
|
-
|
|
162
|
+
})[] | undefined, never, "?:", ({
|
|
163
|
+
function: string;
|
|
164
|
+
meta?: object | undefined;
|
|
165
|
+
spec: {
|
|
166
166
|
readonly filter: readonly {
|
|
167
167
|
readonly type: string;
|
|
168
168
|
readonly props?: {
|
|
169
169
|
readonly [x: string]: any;
|
|
170
170
|
} | undefined;
|
|
171
171
|
}[];
|
|
172
|
-
readonly
|
|
172
|
+
readonly type: "subscription";
|
|
173
173
|
readonly options?: {
|
|
174
174
|
readonly deep?: boolean | undefined;
|
|
175
175
|
readonly delay?: number | undefined;
|
|
176
176
|
} | undefined;
|
|
177
|
+
} | {
|
|
178
|
+
readonly type: "timer";
|
|
179
|
+
readonly cron: string;
|
|
180
|
+
} | {
|
|
181
|
+
port?: number | undefined;
|
|
182
|
+
type: "webhook";
|
|
183
|
+
method: string;
|
|
184
|
+
} | {
|
|
185
|
+
readonly type: "websocket";
|
|
186
|
+
readonly url: string;
|
|
187
|
+
readonly init?: {
|
|
188
|
+
readonly [x: string]: any;
|
|
189
|
+
} | undefined;
|
|
190
|
+
};
|
|
191
|
+
} & {
|
|
192
|
+
"@meta"?: {
|
|
193
|
+
readonly keys: {
|
|
194
|
+
readonly id: string;
|
|
195
|
+
readonly source: string;
|
|
196
|
+
}[];
|
|
177
197
|
} | undefined;
|
|
178
|
-
}[] | undefined, never>;
|
|
198
|
+
})[] | undefined, never>;
|
|
179
199
|
}>;
|
|
180
200
|
export type FunctionManifest = S.Schema.Type<typeof FunctionManifestSchema>;
|
|
181
201
|
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,EAAa,CAAC,EAAe,MAAM,mBAAmB,CAAC;AAE9D;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAAG,cAAc,GAAG,OAAO,GAAG,SAAS,GAAG,WAAW,CAAC;AAErF,QAAA,MAAM,yBAAyB;;;;;;;;;;;;;;;;;EAiB7B,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAElF,QAAA,MAAM,kBAAkB;;;EAGtB,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAEpE,QAAA,MAAM,oBAAoB;;;;GAOzB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAExE,QAAA,MAAM,sBAAsB;;;;;;;;EAI1B,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAS5E,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"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type Comparator<A, B = A> = (a: A, b: B) => boolean;
|
|
2
|
+
export type DiffResult<A, B = A> = {
|
|
3
|
+
added: B[];
|
|
4
|
+
updated: A[];
|
|
5
|
+
removed: A[];
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @param previous
|
|
10
|
+
* @param next
|
|
11
|
+
* @param comparator
|
|
12
|
+
*/
|
|
13
|
+
export declare const diff: <A, B = A>(previous: readonly A[], next: readonly B[], comparator: Comparator<A, B>) => DiffResult<A, B>;
|
|
14
|
+
export declare const intersection: <A, B = A>(a: A[], b: B[], comparator: Comparator<A, B>) => A[];
|
|
15
|
+
//# sourceMappingURL=util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/util.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,UAAU,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,OAAO,CAAC;AAE3D,MAAM,MAAM,UAAU,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI;IACjC,KAAK,EAAE,CAAC,EAAE,CAAC;IACX,OAAO,EAAE,CAAC,EAAE,CAAC;IACb,OAAO,EAAE,CAAC,EAAE,CAAC;CACd,CAAC;AAEF;;;;;GAKG;AAEH,eAAO,MAAM,IAAI,0GAwBhB,CAAC;AAGF,eAAO,MAAM,YAAY,iEACuC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.test.d.ts","sourceRoot":"","sources":["../../../src/util.test.ts"],"names":[],"mappings":""}
|
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.79e0565",
|
|
4
4
|
"description": "Functions SDK and runtime.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -20,27 +20,29 @@
|
|
|
20
20
|
"src"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@effect/schema": "^0.64.20",
|
|
24
23
|
"@preact/signals-core": "^1.6.0",
|
|
25
24
|
"cron": "^3.1.6",
|
|
26
25
|
"effect": "^2.4.19",
|
|
27
26
|
"express": "^4.19.2",
|
|
28
27
|
"get-port-please": "^3.1.1",
|
|
29
28
|
"ws": "^8.14.2",
|
|
30
|
-
"@braneframe/types": "0.5.3-main.
|
|
31
|
-
"@dxos/
|
|
32
|
-
"@dxos/
|
|
33
|
-
"@dxos/
|
|
34
|
-
"@dxos/
|
|
35
|
-
"@dxos/
|
|
36
|
-
"@dxos/
|
|
37
|
-
"@dxos/
|
|
38
|
-
"@dxos/
|
|
29
|
+
"@braneframe/types": "0.5.3-main.79e0565",
|
|
30
|
+
"@dxos/async": "0.5.3-main.79e0565",
|
|
31
|
+
"@dxos/client": "0.5.3-main.79e0565",
|
|
32
|
+
"@dxos/context": "0.5.3-main.79e0565",
|
|
33
|
+
"@dxos/echo-db": "0.5.3-main.79e0565",
|
|
34
|
+
"@dxos/invariant": "0.5.3-main.79e0565",
|
|
35
|
+
"@dxos/echo-schema": "0.5.3-main.79e0565",
|
|
36
|
+
"@dxos/keys": "0.5.3-main.79e0565",
|
|
37
|
+
"@dxos/node-std": "0.5.3-main.79e0565",
|
|
38
|
+
"@dxos/util": "0.5.3-main.79e0565",
|
|
39
|
+
"@dxos/protocols": "0.5.3-main.79e0565",
|
|
40
|
+
"@dxos/log": "0.5.3-main.79e0565"
|
|
39
41
|
},
|
|
40
42
|
"devDependencies": {
|
|
41
43
|
"@types/express": "^4.17.17",
|
|
42
44
|
"@types/ws": "^7.4.0",
|
|
43
|
-
"@dxos/agent": "0.5.3-main.
|
|
45
|
+
"@dxos/agent": "0.5.3-main.79e0565"
|
|
44
46
|
},
|
|
45
47
|
"publishConfig": {
|
|
46
48
|
"access": "public"
|