@dxos/functions 0.7.4 → 0.7.5-main.9cb18ac
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-B3FGASHJ.mjs +125 -0
- package/dist/lib/browser/chunk-B3FGASHJ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-Y2OPAP26.mjs → chunk-BCNGUHHW.mjs} +2 -2
- package/dist/lib/browser/chunk-PKOLPTSC.mjs +163 -0
- package/dist/lib/browser/chunk-PKOLPTSC.mjs.map +7 -0
- package/dist/lib/browser/chunk-XRCXIG74.mjs +12 -0
- package/dist/lib/browser/edge/index.mjs +21 -0
- package/dist/lib/browser/index.mjs +26 -3
- package/dist/lib/browser/index.mjs.map +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +5 -3
- package/dist/lib/browser/testing/index.mjs.map +1 -1
- package/dist/lib/browser/{types.mjs → types/index.mjs} +9 -2
- package/dist/lib/browser/types/index.mjs.map +7 -0
- package/dist/lib/node/chunk-JEQ2X3Z6.cjs +34 -0
- package/dist/lib/node/chunk-JEQ2X3Z6.cjs.map +7 -0
- package/dist/lib/node/chunk-RYEY2RR2.cjs +190 -0
- package/dist/lib/node/chunk-RYEY2RR2.cjs.map +7 -0
- package/dist/lib/node/{chunk-CCULBUSE.cjs → chunk-UHWSNERM.cjs} +15 -15
- package/dist/lib/node/chunk-ZDG466QT.cjs +151 -0
- package/dist/lib/node/chunk-ZDG466QT.cjs.map +7 -0
- package/dist/lib/node/edge/index.cjs +42 -0
- package/dist/lib/node/edge/index.cjs.map +7 -0
- package/dist/lib/node/index.cjs +37 -15
- package/dist/lib/node/index.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +11 -10
- package/dist/lib/node/testing/index.cjs.map +1 -1
- package/dist/lib/node/{types.cjs → types/index.cjs} +16 -9
- package/dist/lib/node/types/index.cjs.map +7 -0
- package/dist/lib/node-esm/chunk-2UWB6JYW.mjs +163 -0
- package/dist/lib/node-esm/chunk-2UWB6JYW.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-CN74WOTT.mjs +125 -0
- package/dist/lib/node-esm/chunk-CN74WOTT.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-DHGBFXSZ.mjs +12 -0
- package/dist/lib/node-esm/chunk-DHGBFXSZ.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-GGGGWYP6.mjs → chunk-TPGS4PIH.mjs} +2 -2
- package/dist/lib/node-esm/edge/index.mjs +21 -0
- package/dist/lib/node-esm/edge/index.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +26 -3
- package/dist/lib/node-esm/index.mjs.map +1 -1
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +5 -3
- package/dist/lib/node-esm/testing/index.mjs.map +1 -1
- package/dist/lib/node-esm/{types.mjs → types/index.mjs} +9 -2
- package/dist/lib/node-esm/types/index.mjs.map +7 -0
- package/dist/types/src/edge/functions.d.ts +25 -0
- package/dist/types/src/edge/functions.d.ts.map +1 -0
- package/dist/types/src/edge/index.d.ts +2 -0
- package/dist/types/src/edge/index.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/testing/types.d.ts +3 -5
- package/dist/types/src/testing/types.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +9 -0
- package/dist/types/src/translations.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +3 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/src/types/schema.d.ts +62 -0
- package/dist/types/src/types/schema.d.ts.map +1 -0
- package/dist/types/src/{types.d.ts → types/types.d.ts} +58 -74
- package/dist/types/src/types/types.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +27 -20
- package/src/edge/functions.ts +116 -0
- package/src/edge/index.ts +5 -0
- package/src/index.ts +1 -0
- package/src/translations.ts +15 -0
- package/src/types/index.ts +6 -0
- package/src/types/schema.ts +48 -0
- package/dist/lib/browser/chunk-N5D5R4Q4.mjs +0 -129
- package/dist/lib/browser/chunk-N5D5R4Q4.mjs.map +0 -7
- package/dist/lib/node/chunk-JMJCJ3SA.cjs +0 -156
- package/dist/lib/node/chunk-JMJCJ3SA.cjs.map +0 -7
- package/dist/lib/node/types.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-2NACE6MJ.mjs +0 -129
- package/dist/lib/node-esm/chunk-2NACE6MJ.mjs.map +0 -7
- package/dist/types/src/types.d.ts.map +0 -1
- /package/dist/lib/browser/{chunk-Y2OPAP26.mjs.map → chunk-BCNGUHHW.mjs.map} +0 -0
- /package/dist/lib/browser/{types.mjs.map → chunk-XRCXIG74.mjs.map} +0 -0
- /package/dist/lib/{node-esm/types.mjs.map → browser/edge/index.mjs.map} +0 -0
- /package/dist/lib/node/{chunk-CCULBUSE.cjs.map → chunk-UHWSNERM.cjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-GGGGWYP6.mjs.map → chunk-TPGS4PIH.mjs.map} +0 -0
- /package/src/{types.ts → types/types.ts} +0 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import "@dxos/node-std/globals";
|
|
2
|
+
|
|
3
|
+
// packages/core/functions/src/edge/functions.ts
|
|
4
|
+
import { EdgeHttpClient } from "@dxos/edge-client";
|
|
5
|
+
import { invariant } from "@dxos/invariant";
|
|
6
|
+
import { log } from "@dxos/log";
|
|
7
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/functions/src/edge/functions.ts";
|
|
8
|
+
var FUNCTIONS_META_KEY = "dxos.org/service/function";
|
|
9
|
+
var FUNCTIONS_PRESET_META_KEY = "dxos.org/service/function-preset";
|
|
10
|
+
var uploadWorkerFunction = async ({ client, name, version, source, spaceId, functionId }) => {
|
|
11
|
+
const edgeUrl = client.config.values.runtime?.services?.edge?.url;
|
|
12
|
+
invariant(edgeUrl, "Edge is not configured.", {
|
|
13
|
+
F: __dxlog_file,
|
|
14
|
+
L: 38,
|
|
15
|
+
S: void 0,
|
|
16
|
+
A: [
|
|
17
|
+
"edgeUrl",
|
|
18
|
+
"'Edge is not configured.'"
|
|
19
|
+
]
|
|
20
|
+
});
|
|
21
|
+
const edgeClient = new EdgeHttpClient(edgeUrl);
|
|
22
|
+
const edgeIdentity = createEdgeIdentity(client);
|
|
23
|
+
edgeClient.setIdentity(edgeIdentity);
|
|
24
|
+
const response = await edgeClient.uploadFunction({
|
|
25
|
+
spaceId,
|
|
26
|
+
functionId
|
|
27
|
+
}, {
|
|
28
|
+
name,
|
|
29
|
+
version,
|
|
30
|
+
script: source
|
|
31
|
+
});
|
|
32
|
+
log("Uploaded", {
|
|
33
|
+
functionId,
|
|
34
|
+
source,
|
|
35
|
+
name,
|
|
36
|
+
identityKey: edgeIdentity.identityKey,
|
|
37
|
+
response
|
|
38
|
+
}, {
|
|
39
|
+
F: __dxlog_file,
|
|
40
|
+
L: 44,
|
|
41
|
+
S: void 0,
|
|
42
|
+
C: (f, a) => f(...a)
|
|
43
|
+
});
|
|
44
|
+
return response;
|
|
45
|
+
};
|
|
46
|
+
var getUserFunctionUrlInMetadata = (meta) => {
|
|
47
|
+
return meta.keys.find((key) => key.source === FUNCTIONS_META_KEY)?.id;
|
|
48
|
+
};
|
|
49
|
+
var setUserFunctionUrlInMetadata = (meta, functionUrl) => {
|
|
50
|
+
const key = meta.keys.find((key2) => key2.source === FUNCTIONS_META_KEY);
|
|
51
|
+
if (key) {
|
|
52
|
+
if (key.id !== functionUrl) {
|
|
53
|
+
throw new Error("Metadata mismatch");
|
|
54
|
+
}
|
|
55
|
+
} else {
|
|
56
|
+
meta.keys.push({
|
|
57
|
+
source: FUNCTIONS_META_KEY,
|
|
58
|
+
id: functionUrl
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
var getInvocationUrl = (functionUrl, edgeUrl, options = {}) => {
|
|
63
|
+
const baseUrl = new URL("functions/", edgeUrl);
|
|
64
|
+
const relativeUrl = functionUrl.replace(/^\//, "");
|
|
65
|
+
const url = new URL(`./${relativeUrl}`, baseUrl.toString());
|
|
66
|
+
options.spaceId && url.searchParams.set("spaceId", options.spaceId);
|
|
67
|
+
options.subjectId && url.searchParams.set("subjectId", options.subjectId);
|
|
68
|
+
url.protocol = "https";
|
|
69
|
+
return url.toString();
|
|
70
|
+
};
|
|
71
|
+
var createEdgeIdentity = (client) => {
|
|
72
|
+
const identity = client.halo.identity.get();
|
|
73
|
+
const device = client.halo.device;
|
|
74
|
+
if (!identity || !device) {
|
|
75
|
+
throw new Error("Identity not available");
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
identityKey: identity.identityKey.toHex(),
|
|
79
|
+
peerKey: device.deviceKey.toHex(),
|
|
80
|
+
presentCredentials: async ({ challenge }) => {
|
|
81
|
+
const identityService = client.services.services.IdentityService;
|
|
82
|
+
const authCredential = await identityService.createAuthCredential();
|
|
83
|
+
return identityService.signPresentation({
|
|
84
|
+
presentation: {
|
|
85
|
+
credentials: [
|
|
86
|
+
authCredential
|
|
87
|
+
]
|
|
88
|
+
},
|
|
89
|
+
nonce: challenge
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
var incrementSemverPatch = (version) => {
|
|
95
|
+
const [major, minor, patch] = version.split(".");
|
|
96
|
+
const patchNum = Number(patch);
|
|
97
|
+
invariant(!Number.isNaN(patchNum), "Unexpected function version format.", {
|
|
98
|
+
F: __dxlog_file,
|
|
99
|
+
L: 105,
|
|
100
|
+
S: void 0,
|
|
101
|
+
A: [
|
|
102
|
+
"!Number.isNaN(patchNum)",
|
|
103
|
+
"'Unexpected function version format.'"
|
|
104
|
+
]
|
|
105
|
+
});
|
|
106
|
+
return [
|
|
107
|
+
major,
|
|
108
|
+
minor,
|
|
109
|
+
String(patchNum + 1)
|
|
110
|
+
].join(".");
|
|
111
|
+
};
|
|
112
|
+
var publicKeyToDid = (key) => {
|
|
113
|
+
return `did:key:${key.toHex()}`;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export {
|
|
117
|
+
FUNCTIONS_PRESET_META_KEY,
|
|
118
|
+
uploadWorkerFunction,
|
|
119
|
+
getUserFunctionUrlInMetadata,
|
|
120
|
+
setUserFunctionUrlInMetadata,
|
|
121
|
+
getInvocationUrl,
|
|
122
|
+
incrementSemverPatch,
|
|
123
|
+
publicKeyToDid
|
|
124
|
+
};
|
|
125
|
+
//# sourceMappingURL=chunk-B3FGASHJ.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/edge/functions.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { type DID } from 'iso-did/types';\n\nimport { type Client } from '@dxos/client';\nimport { type ObjectMeta } from '@dxos/echo-schema';\nimport { EdgeHttpClient, type EdgeIdentity } from '@dxos/edge-client';\nimport { invariant } from '@dxos/invariant';\nimport type { PublicKey, SpaceId } from '@dxos/keys';\nimport { log } from '@dxos/log';\nimport { type UploadFunctionResponseBody } from '@dxos/protocols';\n\n// TODO: use URL scheme for source?\nconst FUNCTIONS_META_KEY = 'dxos.org/service/function';\n\nexport const FUNCTIONS_PRESET_META_KEY = 'dxos.org/service/function-preset';\n\nexport type UploadWorkerArgs = {\n client: Client;\n name?: string;\n source: string;\n version: string;\n functionId?: string;\n spaceId: SpaceId;\n};\n\nexport const uploadWorkerFunction = async ({\n client,\n name,\n version,\n source,\n spaceId,\n functionId,\n}: UploadWorkerArgs): Promise<UploadFunctionResponseBody> => {\n const edgeUrl = client.config.values.runtime?.services?.edge?.url;\n invariant(edgeUrl, 'Edge is not configured.');\n const edgeClient = new EdgeHttpClient(edgeUrl);\n const edgeIdentity = createEdgeIdentity(client);\n edgeClient.setIdentity(edgeIdentity);\n const response = await edgeClient.uploadFunction({ spaceId, functionId }, { name, version, script: source });\n\n log('Uploaded', {\n functionId,\n source,\n name,\n identityKey: edgeIdentity.identityKey,\n response,\n });\n\n return response;\n};\n\nexport const getUserFunctionUrlInMetadata = (meta: ObjectMeta) => {\n return meta.keys.find((key) => key.source === FUNCTIONS_META_KEY)?.id;\n};\n\nexport const setUserFunctionUrlInMetadata = (meta: ObjectMeta, functionUrl: string) => {\n const key = meta.keys.find((key) => key.source === FUNCTIONS_META_KEY);\n if (key) {\n if (key.id !== functionUrl) {\n throw new Error('Metadata mismatch');\n }\n } else {\n meta.keys.push({ source: FUNCTIONS_META_KEY, id: functionUrl });\n }\n};\n\nexport const getInvocationUrl = (functionUrl: string, edgeUrl: string, options: InvocationOptions = {}) => {\n const baseUrl = new URL('functions/', edgeUrl);\n\n // Leading slashes cause the URL to be treated as an absolute path.\n const relativeUrl = functionUrl.replace(/^\\//, '');\n const url = new URL(`./${relativeUrl}`, baseUrl.toString());\n options.spaceId && url.searchParams.set('spaceId', options.spaceId);\n options.subjectId && url.searchParams.set('subjectId', options.subjectId);\n url.protocol = 'https';\n return url.toString();\n};\n\nconst createEdgeIdentity = (client: Client): EdgeIdentity => {\n const identity = client.halo.identity.get();\n const device = client.halo.device;\n if (!identity || !device) {\n throw new Error('Identity not available');\n }\n return {\n identityKey: identity.identityKey.toHex(),\n peerKey: device.deviceKey.toHex(),\n presentCredentials: async ({ challenge }) => {\n const identityService = client.services.services.IdentityService!;\n const authCredential = await identityService.createAuthCredential();\n return identityService.signPresentation({\n presentation: { credentials: [authCredential] },\n nonce: challenge,\n });\n },\n };\n};\n\nexport const incrementSemverPatch = (version: string): string => {\n const [major, minor, patch] = version.split('.');\n const patchNum = Number(patch);\n invariant(!Number.isNaN(patchNum), 'Unexpected function version format.');\n return [major, minor, String(patchNum + 1)].join('.');\n};\n\nexport const publicKeyToDid = (key: PublicKey): DID => {\n return `did:key:${key.toHex()}`;\n};\n\nexport type InvocationOptions = {\n spaceId?: SpaceId;\n subjectId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UNCTIONS_META_KEY", "FUNCTIONS_PRESET_META_KEY", "uploadWorkerFunction", "client", "name", "version", "source", "spaceId", "functionId", "edgeUrl", "config", "values", "runtime", "services", "edge", "url", "edgeClient", "edgeIdentity", "createEdgeIdentity", "setIdentity", "response", "uploadFunction", "script", "identityKey", "getUserFunctionUrlInMetadata", "meta", "keys", "find", "key", "id", "setUserFunctionUrlInMetadata", "functionUrl", "Error", "push", "getInvocationUrl", "options", "baseUrl", "URL", "relativeUrl", "replace", "toString", "searchParams", "set", "subjectId", "protocol", "identity", "halo", "get", "device", "toHex", "peerKey", "deviceKey", "presentCredentials", "challenge", "identityService", "IdentityService", "authCredential", "createAuthCredential", "signPresentation", "presentation", "credentials", "nonce", "incrementSemverPatch", "major", "minor", "patch", "split", "patchNum", "Number", "isNaN", "String", "join", "publicKeyToDid"]
|
|
7
|
+
}
|
|
@@ -2,7 +2,7 @@ import "@dxos/node-std/globals";
|
|
|
2
2
|
import {
|
|
3
3
|
FunctionDef,
|
|
4
4
|
FunctionTrigger
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-PKOLPTSC.mjs";
|
|
6
6
|
|
|
7
7
|
// packages/core/functions/src/function/function-registry.ts
|
|
8
8
|
import { Event } from "@dxos/async";
|
|
@@ -477,4 +477,4 @@ export {
|
|
|
477
477
|
createTimerTrigger,
|
|
478
478
|
TriggerRegistry
|
|
479
479
|
};
|
|
480
|
-
//# sourceMappingURL=chunk-
|
|
480
|
+
//# sourceMappingURL=chunk-BCNGUHHW.mjs.map
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import "@dxos/node-std/globals";
|
|
2
|
+
|
|
3
|
+
// packages/core/functions/src/types/schema.ts
|
|
4
|
+
import { JsonSchemaType, Ref, S, TypedObject } from "@dxos/echo-schema";
|
|
5
|
+
var TextType = class extends TypedObject({
|
|
6
|
+
typename: "dxos.org/type/Text",
|
|
7
|
+
version: "0.1.0"
|
|
8
|
+
})({
|
|
9
|
+
content: S.String
|
|
10
|
+
}) {
|
|
11
|
+
};
|
|
12
|
+
var ScriptType = class extends TypedObject({
|
|
13
|
+
typename: "dxos.org/type/Script",
|
|
14
|
+
version: "0.1.0"
|
|
15
|
+
})({
|
|
16
|
+
// TODO(burdon): Change to URI?
|
|
17
|
+
name: S.optional(S.String),
|
|
18
|
+
description: S.optional(S.String),
|
|
19
|
+
// TODO(burdon): Change to hash of deployed content.
|
|
20
|
+
// Whether source has changed since last deploy.
|
|
21
|
+
changed: S.optional(S.Boolean),
|
|
22
|
+
source: Ref(TextType)
|
|
23
|
+
}) {
|
|
24
|
+
};
|
|
25
|
+
var FunctionType = class extends TypedObject({
|
|
26
|
+
typename: "dxos.org/type/Function",
|
|
27
|
+
version: "0.1.0"
|
|
28
|
+
})({
|
|
29
|
+
// TODO(burdon): Rename to id/uri?
|
|
30
|
+
name: S.NonEmptyString,
|
|
31
|
+
version: S.String,
|
|
32
|
+
// Reference to a source script if it exists within ECHO.
|
|
33
|
+
// TODO(burdon): Don't ref ScriptType directly (core).
|
|
34
|
+
source: S.optional(Ref(ScriptType)),
|
|
35
|
+
inputSchema: S.optional(JsonSchemaType),
|
|
36
|
+
// Local binding to a function name.
|
|
37
|
+
binding: S.optional(S.String)
|
|
38
|
+
}) {
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// packages/core/functions/src/types/types.ts
|
|
42
|
+
import { AST, OptionsAnnotationId, RawObject, S as S2, TypedObject as TypedObject2 } from "@dxos/echo-schema";
|
|
43
|
+
var TriggerKind;
|
|
44
|
+
(function(TriggerKind2) {
|
|
45
|
+
TriggerKind2["Timer"] = "timer";
|
|
46
|
+
TriggerKind2["Webhook"] = "webhook";
|
|
47
|
+
TriggerKind2["Subscription"] = "subscription";
|
|
48
|
+
})(TriggerKind || (TriggerKind = {}));
|
|
49
|
+
var typeLiteralAnnotations = {
|
|
50
|
+
[AST.TitleAnnotationId]: "Type"
|
|
51
|
+
};
|
|
52
|
+
var TimerTriggerSchema = S2.Struct({
|
|
53
|
+
type: S2.Literal("timer").annotations(typeLiteralAnnotations),
|
|
54
|
+
cron: S2.String.annotations({
|
|
55
|
+
[AST.TitleAnnotationId]: "Cron",
|
|
56
|
+
[AST.ExamplesAnnotationId]: [
|
|
57
|
+
"0 0 * * *"
|
|
58
|
+
]
|
|
59
|
+
})
|
|
60
|
+
}).pipe(S2.mutable);
|
|
61
|
+
var WebhookTriggerSchema = S2.Struct({
|
|
62
|
+
type: S2.Literal("webhook").annotations(typeLiteralAnnotations),
|
|
63
|
+
method: S2.optional(S2.String.annotations({
|
|
64
|
+
[AST.TitleAnnotationId]: "Method",
|
|
65
|
+
[OptionsAnnotationId]: [
|
|
66
|
+
"GET",
|
|
67
|
+
"POST"
|
|
68
|
+
]
|
|
69
|
+
})),
|
|
70
|
+
port: S2.optional(S2.Number.annotations({
|
|
71
|
+
[AST.TitleAnnotationId]: "Port"
|
|
72
|
+
}))
|
|
73
|
+
}).pipe(S2.mutable);
|
|
74
|
+
var QuerySchema = S2.Struct({
|
|
75
|
+
type: S2.optional(S2.String.annotations({
|
|
76
|
+
[AST.TitleAnnotationId]: "Type"
|
|
77
|
+
})),
|
|
78
|
+
props: S2.optional(S2.Record({
|
|
79
|
+
key: S2.String,
|
|
80
|
+
value: S2.Any
|
|
81
|
+
}))
|
|
82
|
+
}).annotations({
|
|
83
|
+
[AST.TitleAnnotationId]: "Query"
|
|
84
|
+
});
|
|
85
|
+
var SubscriptionTriggerSchema = S2.Struct({
|
|
86
|
+
type: S2.Literal("subscription").annotations(typeLiteralAnnotations),
|
|
87
|
+
// TODO(burdon): Define query DSL (from ECHO). Reconcile with Table.Query.
|
|
88
|
+
filter: QuerySchema,
|
|
89
|
+
options: S2.optional(S2.Struct({
|
|
90
|
+
// Watch changes to object (not just creation).
|
|
91
|
+
deep: S2.optional(S2.Boolean.annotations({
|
|
92
|
+
[AST.TitleAnnotationId]: "Nested"
|
|
93
|
+
})),
|
|
94
|
+
// Debounce changes (delay in ms).
|
|
95
|
+
delay: S2.optional(S2.Number.annotations({
|
|
96
|
+
[AST.TitleAnnotationId]: "Delay"
|
|
97
|
+
}))
|
|
98
|
+
}).annotations({
|
|
99
|
+
[AST.TitleAnnotationId]: "Options"
|
|
100
|
+
}))
|
|
101
|
+
}).pipe(S2.mutable);
|
|
102
|
+
var TriggerSchema = S2.Union(
|
|
103
|
+
//
|
|
104
|
+
TimerTriggerSchema,
|
|
105
|
+
WebhookTriggerSchema,
|
|
106
|
+
SubscriptionTriggerSchema
|
|
107
|
+
).annotations({
|
|
108
|
+
[AST.TitleAnnotationId]: "Trigger"
|
|
109
|
+
});
|
|
110
|
+
var FunctionTriggerSchema = S2.Struct({
|
|
111
|
+
// TODO(burdon): What type does this reference.
|
|
112
|
+
function: S2.optional(S2.String.annotations({
|
|
113
|
+
[AST.TitleAnnotationId]: "Function"
|
|
114
|
+
})),
|
|
115
|
+
enabled: S2.optional(S2.Boolean.annotations({
|
|
116
|
+
[AST.TitleAnnotationId]: "Enabled"
|
|
117
|
+
})),
|
|
118
|
+
// TODO(burdon): Flatten entire schema.
|
|
119
|
+
spec: S2.optional(TriggerSchema),
|
|
120
|
+
// TODO(burdon): Get meta from function.
|
|
121
|
+
// The `meta` property is merged into the event data passed to the function.
|
|
122
|
+
meta: S2.optional(S2.mutable(S2.Record({
|
|
123
|
+
key: S2.String,
|
|
124
|
+
value: S2.Any
|
|
125
|
+
})))
|
|
126
|
+
});
|
|
127
|
+
var FunctionTrigger = class extends TypedObject2({
|
|
128
|
+
typename: "dxos.org/type/FunctionTrigger",
|
|
129
|
+
version: "0.1.0"
|
|
130
|
+
})(FunctionTriggerSchema.fields) {
|
|
131
|
+
};
|
|
132
|
+
var FunctionDef = class extends TypedObject2({
|
|
133
|
+
typename: "dxos.org/type/FunctionDef",
|
|
134
|
+
version: "0.1.0"
|
|
135
|
+
})({
|
|
136
|
+
uri: S2.String,
|
|
137
|
+
description: S2.optional(S2.String),
|
|
138
|
+
route: S2.String,
|
|
139
|
+
handler: S2.String
|
|
140
|
+
}) {
|
|
141
|
+
};
|
|
142
|
+
var FunctionManifestSchema = S2.Struct({
|
|
143
|
+
functions: S2.optional(S2.mutable(S2.Array(RawObject(FunctionDef)))),
|
|
144
|
+
triggers: S2.optional(S2.mutable(S2.Array(RawObject(FunctionTrigger))))
|
|
145
|
+
});
|
|
146
|
+
var FUNCTION_TYPES = [
|
|
147
|
+
FunctionDef,
|
|
148
|
+
FunctionTrigger
|
|
149
|
+
];
|
|
150
|
+
|
|
151
|
+
export {
|
|
152
|
+
TextType,
|
|
153
|
+
ScriptType,
|
|
154
|
+
FunctionType,
|
|
155
|
+
TriggerKind,
|
|
156
|
+
TriggerSchema,
|
|
157
|
+
FunctionTriggerSchema,
|
|
158
|
+
FunctionTrigger,
|
|
159
|
+
FunctionDef,
|
|
160
|
+
FunctionManifestSchema,
|
|
161
|
+
FUNCTION_TYPES
|
|
162
|
+
};
|
|
163
|
+
//# sourceMappingURL=chunk-PKOLPTSC.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/types/schema.ts", "../../../src/types/types.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { JsonSchemaType, Ref, S, TypedObject } from '@dxos/echo-schema';\n\n// TODO(burdon): Reconcile with plugin-markdown.\nexport class TextType extends TypedObject({ typename: 'dxos.org/type/Text', version: '0.1.0' })({\n content: S.String,\n}) {}\n\n/**\n * Source script.\n */\nexport class ScriptType extends TypedObject({\n typename: 'dxos.org/type/Script',\n version: '0.1.0',\n})({\n // TODO(burdon): Change to URI?\n name: S.optional(S.String),\n description: S.optional(S.String),\n // TODO(burdon): Change to hash of deployed content.\n // Whether source has changed since last deploy.\n changed: S.optional(S.Boolean),\n source: Ref(TextType),\n}) {}\n\n/**\n * Function deployment.\n */\n// TODO(burdon): Move to core/functions.\nexport class FunctionType extends TypedObject({\n typename: 'dxos.org/type/Function',\n version: '0.1.0',\n})({\n // TODO(burdon): Rename to id/uri?\n name: S.NonEmptyString,\n version: S.String,\n\n // Reference to a source script if it exists within ECHO.\n // TODO(burdon): Don't ref ScriptType directly (core).\n source: S.optional(Ref(ScriptType)),\n\n inputSchema: S.optional(JsonSchemaType),\n\n // Local binding to a function name.\n binding: S.optional(S.String),\n}) {}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { AST, OptionsAnnotationId, RawObject, S, TypedObject } from '@dxos/echo-schema';\n\n/**\n * Type discriminator for TriggerType.\n * Every spec has a type field of type TriggerKind that we can use to understand which type we're working with.\n * https://www.typescriptlang.org/docs/handbook/2/narrowing.html#discriminated-unions\n */\nexport enum TriggerKind {\n Timer = 'timer',\n Webhook = 'webhook',\n Subscription = 'subscription',\n}\n\n// TODO(burdon): Rename prop kind.\nconst typeLiteralAnnotations = { [AST.TitleAnnotationId]: 'Type' };\n\n/**\n * Cron timer.\n */\nconst TimerTriggerSchema = S.Struct({\n type: S.Literal(TriggerKind.Timer).annotations(typeLiteralAnnotations),\n cron: S.String.annotations({\n [AST.TitleAnnotationId]: 'Cron',\n [AST.ExamplesAnnotationId]: ['0 0 * * *'],\n }),\n}).pipe(S.mutable);\n\nexport type TimerTrigger = S.Schema.Type<typeof TimerTriggerSchema>;\n\n/**\n * Webhook.\n */\nconst WebhookTriggerSchema = S.Struct({\n type: S.Literal(TriggerKind.Webhook).annotations(typeLiteralAnnotations),\n method: S.optional(\n S.String.annotations({\n [AST.TitleAnnotationId]: 'Method',\n [OptionsAnnotationId]: ['GET', 'POST'],\n }),\n ),\n port: S.optional(\n S.Number.annotations({\n [AST.TitleAnnotationId]: 'Port',\n }),\n ),\n}).pipe(S.mutable);\n\nexport type WebhookTrigger = S.Schema.Type<typeof WebhookTriggerSchema>;\n\n// TODO(burdon): Use ECHO definition (from https://github.com/dxos/dxos/pull/8233).\nconst QuerySchema = S.Struct({\n type: S.optional(S.String.annotations({ [AST.TitleAnnotationId]: 'Type' })),\n props: S.optional(S.Record({ key: S.String, value: S.Any })),\n}).annotations({ [AST.TitleAnnotationId]: 'Query' });\n\n/**\n * Subscription.\n */\nconst SubscriptionTriggerSchema = S.Struct({\n type: S.Literal(TriggerKind.Subscription).annotations(typeLiteralAnnotations),\n // TODO(burdon): Define query DSL (from ECHO). Reconcile with Table.Query.\n filter: QuerySchema,\n options: S.optional(\n S.Struct({\n // Watch changes to object (not just creation).\n deep: S.optional(S.Boolean.annotations({ [AST.TitleAnnotationId]: 'Nested' })),\n // Debounce changes (delay in ms).\n delay: S.optional(S.Number.annotations({ [AST.TitleAnnotationId]: 'Delay' })),\n }).annotations({ [AST.TitleAnnotationId]: 'Options' }),\n ),\n}).pipe(S.mutable);\n\nexport type SubscriptionTrigger = S.Schema.Type<typeof SubscriptionTriggerSchema>;\n\n/**\n * Trigger schema (discriminated union).\n */\nexport const TriggerSchema = S.Union(\n //\n TimerTriggerSchema,\n WebhookTriggerSchema,\n SubscriptionTriggerSchema,\n).annotations({\n [AST.TitleAnnotationId]: 'Trigger',\n});\n\nexport type TriggerType = S.Schema.Type<typeof TriggerSchema>;\n\n/**\n * Function trigger.\n */\nexport const FunctionTriggerSchema = S.Struct({\n // TODO(burdon): What type does this reference.\n function: S.optional(S.String.annotations({ [AST.TitleAnnotationId]: 'Function' })),\n\n enabled: S.optional(S.Boolean.annotations({ [AST.TitleAnnotationId]: 'Enabled' })),\n\n // TODO(burdon): Flatten entire schema.\n spec: S.optional(TriggerSchema),\n\n // TODO(burdon): Get meta from function.\n // The `meta` property is merged into the event data passed to the function.\n meta: S.optional(S.mutable(S.Record({ key: S.String, value: S.Any }))),\n});\n\nexport type FunctionTriggerType = S.Schema.Type<typeof FunctionTriggerSchema>;\n\n/**\n * Function trigger.\n */\nexport class FunctionTrigger extends TypedObject({\n typename: 'dxos.org/type/FunctionTrigger',\n version: '0.1.0',\n})(FunctionTriggerSchema.fields) {}\n\n/**\n * Function definition.\n * @deprecated (Use dxos.org/type/Function)\n */\n// TODO(burdon): Reconcile with FunctionType.\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 handler: S.String,\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\nexport const FUNCTION_TYPES = [FunctionDef, FunctionTrigger];\n"],
|
|
5
|
+
"mappings": ";;;AAIA,SAASA,gBAAgBC,KAAKC,GAAGC,mBAAmB;AAG7C,IAAMC,WAAN,cAAuBC,YAAY;EAAEC,UAAU;EAAsBC,SAAS;AAAQ,CAAA,EAAG;EAC9FC,SAASC,EAAEC;AACb,CAAA,EAAA;AAAI;AAKG,IAAMC,aAAN,cAAyBN,YAAY;EAC1CC,UAAU;EACVC,SAAS;AACX,CAAA,EAAG;;EAEDK,MAAMH,EAAEI,SAASJ,EAAEC,MAAM;EACzBI,aAAaL,EAAEI,SAASJ,EAAEC,MAAM;;;EAGhCK,SAASN,EAAEI,SAASJ,EAAEO,OAAO;EAC7BC,QAAQC,IAAId,QAAAA;AACd,CAAA,EAAA;AAAI;AAMG,IAAMe,eAAN,cAA2Bd,YAAY;EAC5CC,UAAU;EACVC,SAAS;AACX,CAAA,EAAG;;EAEDK,MAAMH,EAAEW;EACRb,SAASE,EAAEC;;;EAIXO,QAAQR,EAAEI,SAASK,IAAIP,UAAAA,CAAAA;EAEvBU,aAAaZ,EAAEI,SAASS,cAAAA;;EAGxBC,SAASd,EAAEI,SAASJ,EAAEC,MAAM;AAC9B,CAAA,EAAA;AAAI;;;AC3CJ,SAASc,KAAKC,qBAAqBC,WAAWC,KAAAA,IAAGC,eAAAA,oBAAmB;;UAOxDC,cAAAA;;;;GAAAA,gBAAAA,cAAAA,CAAAA,EAAA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AES,QAAQT,GAAE+C,MAAMC,UAAUR,WAAAA,CAAAA,CAAAA,CAAAA;EAClDS,UAAUjD,GAAEY,SAASZ,GAAES,QAAQT,GAAE+C,MAAMC,UAAUb,eAAAA,CAAAA,CAAAA,CAAAA;AACnD,CAAA;AAIO,IAAMe,iBAAiB;EAACV;EAAaL;;",
|
|
6
|
+
"names": ["JsonSchemaType", "Ref", "S", "TypedObject", "TextType", "TypedObject", "typename", "version", "content", "S", "String", "ScriptType", "name", "optional", "description", "changed", "Boolean", "source", "Ref", "FunctionType", "NonEmptyString", "inputSchema", "JsonSchemaType", "binding", "AST", "OptionsAnnotationId", "RawObject", "S", "TypedObject", "TriggerKind", "typeLiteralAnnotations", "AST", "TitleAnnotationId", "TimerTriggerSchema", "S", "Struct", "type", "Literal", "annotations", "cron", "String", "ExamplesAnnotationId", "pipe", "mutable", "WebhookTriggerSchema", "method", "optional", "OptionsAnnotationId", "port", "Number", "QuerySchema", "props", "Record", "key", "value", "Any", "SubscriptionTriggerSchema", "filter", "options", "deep", "Boolean", "delay", "TriggerSchema", "Union", "FunctionTriggerSchema", "function", "enabled", "spec", "meta", "FunctionTrigger", "TypedObject", "typename", "version", "fields", "FunctionDef", "uri", "description", "route", "handler", "FunctionManifestSchema", "functions", "Array", "RawObject", "triggers", "FUNCTION_TYPES"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
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") return require.apply(this, arguments);
|
|
6
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export {
|
|
10
|
+
__require
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=chunk-XRCXIG74.mjs.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import "@dxos/node-std/globals";
|
|
2
|
+
import {
|
|
3
|
+
FUNCTIONS_PRESET_META_KEY,
|
|
4
|
+
getInvocationUrl,
|
|
5
|
+
getUserFunctionUrlInMetadata,
|
|
6
|
+
incrementSemverPatch,
|
|
7
|
+
publicKeyToDid,
|
|
8
|
+
setUserFunctionUrlInMetadata,
|
|
9
|
+
uploadWorkerFunction
|
|
10
|
+
} from "../chunk-B3FGASHJ.mjs";
|
|
11
|
+
import "../chunk-XRCXIG74.mjs";
|
|
12
|
+
export {
|
|
13
|
+
FUNCTIONS_PRESET_META_KEY,
|
|
14
|
+
getInvocationUrl,
|
|
15
|
+
getUserFunctionUrlInMetadata,
|
|
16
|
+
incrementSemverPatch,
|
|
17
|
+
publicKeyToDid,
|
|
18
|
+
setUserFunctionUrlInMetadata,
|
|
19
|
+
uploadWorkerFunction
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,19 +1,32 @@
|
|
|
1
1
|
import "@dxos/node-std/globals";
|
|
2
|
+
import {
|
|
3
|
+
FUNCTIONS_PRESET_META_KEY,
|
|
4
|
+
getInvocationUrl,
|
|
5
|
+
getUserFunctionUrlInMetadata,
|
|
6
|
+
incrementSemverPatch,
|
|
7
|
+
publicKeyToDid,
|
|
8
|
+
setUserFunctionUrlInMetadata,
|
|
9
|
+
uploadWorkerFunction
|
|
10
|
+
} from "./chunk-B3FGASHJ.mjs";
|
|
2
11
|
import {
|
|
3
12
|
FunctionRegistry,
|
|
4
13
|
TriggerRegistry,
|
|
5
14
|
createSubscriptionTrigger,
|
|
6
15
|
createTimerTrigger
|
|
7
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-BCNGUHHW.mjs";
|
|
8
17
|
import {
|
|
9
18
|
FUNCTION_TYPES,
|
|
10
19
|
FunctionDef,
|
|
11
20
|
FunctionManifestSchema,
|
|
12
21
|
FunctionTrigger,
|
|
13
22
|
FunctionTriggerSchema,
|
|
23
|
+
FunctionType,
|
|
24
|
+
ScriptType,
|
|
25
|
+
TextType,
|
|
14
26
|
TriggerKind,
|
|
15
27
|
TriggerSchema
|
|
16
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-PKOLPTSC.mjs";
|
|
29
|
+
import "./chunk-XRCXIG74.mjs";
|
|
17
30
|
|
|
18
31
|
// packages/core/functions/src/handler.ts
|
|
19
32
|
import { PublicKey } from "@dxos/client";
|
|
@@ -80,17 +93,27 @@ var registerTypes = (space, types = []) => {
|
|
|
80
93
|
}
|
|
81
94
|
};
|
|
82
95
|
export {
|
|
96
|
+
FUNCTIONS_PRESET_META_KEY,
|
|
83
97
|
FUNCTION_TYPES,
|
|
84
98
|
FunctionDef,
|
|
85
99
|
FunctionManifestSchema,
|
|
86
100
|
FunctionRegistry,
|
|
87
101
|
FunctionTrigger,
|
|
88
102
|
FunctionTriggerSchema,
|
|
103
|
+
FunctionType,
|
|
104
|
+
ScriptType,
|
|
105
|
+
TextType,
|
|
89
106
|
TriggerKind,
|
|
90
107
|
TriggerRegistry,
|
|
91
108
|
TriggerSchema,
|
|
92
109
|
createSubscriptionTrigger,
|
|
93
110
|
createTimerTrigger,
|
|
94
|
-
|
|
111
|
+
getInvocationUrl,
|
|
112
|
+
getUserFunctionUrlInMetadata,
|
|
113
|
+
incrementSemverPatch,
|
|
114
|
+
publicKeyToDid,
|
|
115
|
+
setUserFunctionUrlInMetadata,
|
|
116
|
+
subscriptionHandler,
|
|
117
|
+
uploadWorkerFunction
|
|
95
118
|
};
|
|
96
119
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/handler.ts"],
|
|
4
4
|
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Schema as S } from '@effect/schema';\n\nimport { type Client, PublicKey } from '@dxos/client';\nimport { type Space, type SpaceId } from '@dxos/client/echo';\nimport type { CoreDatabase, ReactiveEchoObject } from '@dxos/echo-db';\nimport { log } from '@dxos/log';\nimport { nonNullable } from '@dxos/util';\n\n// TODO(burdon): Model after http request. Ref Lambda/OpenFaaS.\n// https://docs.aws.amazon.com/lambda/latest/dg/typescript-handler.html\n// https://www.serverless.com/framework/docs/providers/aws/guide/serverless.yml/#functions\n// https://www.npmjs.com/package/aws-lambda\n\n/**\n * Function handler.\n */\nexport type FunctionHandler<TData = {}, TMeta = {}> = (params: {\n context: FunctionContext;\n event: FunctionEvent<TData, TMeta>;\n\n /**\n * @deprecated\n */\n response: FunctionResponse;\n}) => Promise<Response | FunctionResponse | void>;\n\n/**\n * Function context.\n */\nexport interface FunctionContext {\n getSpace: (spaceId: SpaceId) => Promise<SpaceAPI>;\n\n /**\n * Space from which the function was invoked.\n */\n space: SpaceAPI | undefined;\n\n ai: FunctionContextAi;\n\n /**\n * @deprecated\n */\n // TODO(burdon): Limit access to individual space.\n client: Client;\n /**\n * @deprecated\n */\n // TODO(burdon): Replace with storage service abstraction.\n dataDir?: string;\n}\n\nexport interface FunctionContextAi {\n // TODO(dmaretskyi): Refer to cloudflare AI docs for more comprehensive typedefs.\n run(model: string, inputs: any, options?: any): Promise<any>;\n}\n\n/**\n * Event payload.\n */\nexport type FunctionEvent<TData = {}, TMeta = {}> = {\n data: FunctionEventMeta<TMeta> & TData;\n};\n\n/**\n * Metadata from trigger.\n */\nexport type FunctionEventMeta<TMeta = {}> = {\n meta: TMeta;\n};\n\n/**\n * Function response.\n */\nexport type FunctionResponse = {\n status(code: number): FunctionResponse;\n};\n\n//\n// API.\n//\n\n/**\n * Space interface available to functions.\n */\nexport interface SpaceAPI {\n get id(): SpaceId;\n get crud(): CoreDatabase;\n}\n\nconst __assertFunctionSpaceIsCompatibleWithTheClientSpace = () => {\n // eslint-disable-next-line unused-imports/no-unused-vars\n const y: SpaceAPI = {} as Space;\n};\n\n//\n// Subscription utils.\n//\n\nexport type RawSubscriptionData = {\n spaceKey?: string;\n objects?: string[];\n};\n\nexport type SubscriptionData = {\n space?: Space;\n objects?: ReactiveEchoObject<any>[];\n};\n\n/**\n * Handler wrapper for subscription events; extracts space and objects.\n *\n * To test:\n * ```\n * curl -s -X POST -H \"Content-Type: application/json\" --data '{\"space\": \"0446...1cbb\"}' http://localhost:7100/dev/email-extractor\n * ```\n *\n * NOTE: Get space key from devtools or `dx space list --json`\n */\n// TODO(burdon): Evolve into plugin definition like Composer.\nexport const subscriptionHandler = <TMeta>(\n handler: FunctionHandler<SubscriptionData, TMeta>,\n types?: S.Schema<any>[],\n): FunctionHandler<RawSubscriptionData, TMeta> => {\n return async ({ event: { data }, context, response, ...rest }) => {\n const { client } = context;\n const space = data.spaceKey ? client.spaces.get(PublicKey.from(data.spaceKey)) : undefined;\n if (!space) {\n log.error('Invalid space');\n return response.status(500);\n }\n\n registerTypes(space, types);\n const objects = space\n ? data.objects?.map<ReactiveEchoObject<any> | undefined>((id) => space!.db.getObjectById(id)).filter(nonNullable)\n : [];\n\n if (!!data.spaceKey && !space) {\n log.warn('invalid space', { data });\n } else {\n log.info('handler', { space: space?.key.truncate(), objects: objects?.length });\n }\n\n return handler({ event: { data: { ...data, space, objects } }, context, response, ...rest });\n };\n};\n\n// TODO(burdon): Evolve types as part of function metadata.\nconst registerTypes = (space: Space, types: S.Schema<any>[] = []) => {\n const registry = space.db.graph.schemaRegistry;\n for (const type of types) {\n if (!registry.hasSchema(type)) {\n registry.addSchema([type]);\n }\n }\n};\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,SAAsBA,iBAAiB;AAGvC,SAASC,WAAW;AACpB,SAASC,mBAAmB;;AAiHrB,IAAMC,sBAAsB,CACjCC,SACAC,UAAAA;AAEA,SAAO,OAAO,EAAEC,OAAO,EAAEC,KAAI,GAAIC,SAASC,UAAU,GAAGC,KAAAA,MAAM;AAC3D,UAAM,EAAEC,OAAM,IAAKH;AACnB,UAAMI,QAAQL,KAAKM,WAAWF,OAAOG,OAAOC,IAAIC,UAAUC,KAAKV,KAAKM,QAAQ,CAAA,IAAKK;AACjF,QAAI,CAACN,OAAO;AACVO,UAAIC,MAAM,iBAAA,QAAA;;;;;;AACV,aAAOX,SAASY,OAAO,GAAA;IACzB;AAEAC,kBAAcV,OAAOP,KAAAA;AACrB,UAAMkB,UAAUX,QACZL,KAAKgB,SAASC,IAAyC,CAACC,OAAOb,MAAOc,GAAGC,cAAcF,EAAAA,CAAAA,EAAKG,OAAOC,WAAAA,IACnG,CAAA;AAEJ,QAAI,CAAC,CAACtB,KAAKM,YAAY,CAACD,OAAO;AAC7BO,UAAIW,KAAK,iBAAiB;QAAEvB;MAAK,GAAA;;;;;;IACnC,OAAO;AACLY,UAAIY,KAAK,WAAW;QAAEnB,OAAOA,OAAOoB,IAAIC,SAAAA;QAAYV,SAASA,SAASW;MAAO,GAAA;;;;;;IAC/E;AAEA,WAAO9B,QAAQ;MAAEE,OAAO;QAAEC,MAAM;UAAE,GAAGA;UAAMK;UAAOW;QAAQ;MAAE;MAAGf;MAASC;MAAU,GAAGC;IAAK,CAAA;EAC5F;AACF;AAGA,IAAMY,gBAAgB,CAACV,OAAcP,QAAyB,CAAA,MAAE;AAC9D,QAAM8B,WAAWvB,MAAMc,GAAGU,MAAMC;AAChC,aAAWC,QAAQjC,OAAO;AACxB,QAAI,CAAC8B,SAASI,UAAUD,IAAAA,GAAO;AAC7BH,eAASK,UAAU;QAACF;OAAK;IAC3B;EACF;AACF;",
|
|
6
6
|
"names": ["PublicKey", "log", "nonNullable", "subscriptionHandler", "handler", "types", "event", "data", "context", "response", "rest", "client", "space", "spaceKey", "spaces", "get", "PublicKey", "from", "undefined", "log", "error", "status", "registerTypes", "objects", "map", "id", "db", "getObjectById", "filter", "nonNullable", "warn", "info", "key", "truncate", "length", "registry", "graph", "schemaRegistry", "type", "hasSchema", "addSchema"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"packages/core/functions/src/types.ts":{"bytes":14876,"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/function/function-registry.ts":{"bytes":13004,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"packages/core/functions/src/types.ts","kind":"import-statement","original":"../types"}],"format":"esm"},"packages/core/functions/src/function/index.ts":{"bytes":529,"imports":[{"path":"packages/core/functions/src/function/function-registry.ts","kind":"import-statement","original":"./function-registry"}],"format":"esm"},"packages/core/functions/src/handler.ts":{"bytes":10610,"imports":[{"path":"@dxos/client","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/trigger/type/subscription-trigger.ts":{"bytes":10314,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/trigger/type/timer-trigger.ts":{"bytes":4173,"imports":[{"path":"cron","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/trigger/type/index.ts":{"bytes":751,"imports":[{"path":"packages/core/functions/src/trigger/type/subscription-trigger.ts","kind":"import-statement","original":"./subscription-trigger"},{"path":"packages/core/functions/src/trigger/type/timer-trigger.ts","kind":"import-statement","original":"./timer-trigger"}],"format":"esm"},"packages/core/functions/src/trigger/trigger-registry.ts":{"bytes":28465,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"packages/core/functions/src/trigger/type/index.ts","kind":"import-statement","original":"./type"},{"path":"packages/core/functions/src/types.ts","kind":"import-statement","original":"../types"}],"format":"esm"},"packages/core/functions/src/trigger/index.ts":{"bytes":603,"imports":[{"path":"packages/core/functions/src/trigger/trigger-registry.ts","kind":"import-statement","original":"./trigger-registry"},{"path":"packages/core/functions/src/trigger/type/index.ts","kind":"import-statement","original":"./type"}],"format":"esm"},"packages/core/functions/src/index.ts":{"bytes":840,"imports":[{"path":"packages/core/functions/src/function/index.ts","kind":"import-statement","original":"./function"},{"path":"packages/core/functions/src/handler.ts","kind":"import-statement","original":"./handler"},{"path":"packages/core/functions/src/trigger/index.ts","kind":"import-statement","original":"./trigger"},{"path":"packages/core/functions/src/types.ts","kind":"import-statement","original":"./types"}],"format":"esm"},"packages/core/functions/src/testing/types.ts":{"bytes":1131,"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/runtime/dev-server.ts":{"bytes":28958,"imports":[{"path":"express","kind":"import-statement","external":true},{"path":"get-port-please","kind":"import-statement","external":true},{"path":"@dxos/node-std/path","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/runtime/scheduler.ts":{"bytes":21200,"imports":[{"path":"@dxos/node-std/path","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/echo-protocol","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/runtime/index.ts":{"bytes":598,"imports":[{"path":"packages/core/functions/src/runtime/dev-server.ts","kind":"import-statement","original":"./dev-server"},{"path":"packages/core/functions/src/runtime/scheduler.ts","kind":"import-statement","original":"./scheduler"}],"format":"esm"},"packages/core/functions/src/testing/setup.ts":{"bytes":12707,"imports":[{"path":"get-port-please","kind":"import-statement","external":true},{"path":"@dxos/node-std/path","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"packages/core/functions/src/testing/types.ts","kind":"import-statement","original":"./types"},{"path":"packages/core/functions/src/function/index.ts","kind":"import-statement","original":"../function"},{"path":"packages/core/functions/src/runtime/index.ts","kind":"import-statement","original":"../runtime"},{"path":"packages/core/functions/src/trigger/index.ts","kind":"import-statement","original":"../trigger"},{"path":"packages/core/functions/src/types.ts","kind":"import-statement","original":"../types"}],"format":"esm"},"packages/core/functions/src/testing/util.ts":{"bytes":4310,"imports":[{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/client/testing","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/protocols/proto/dxos/client/services","kind":"import-statement","external":true},{"path":"packages/core/functions/src/types.ts","kind":"import-statement","original":"../types"}],"format":"esm"},"packages/core/functions/src/testing/manifest.ts":{"bytes":1139,"imports":[],"format":"esm"},"packages/core/functions/src/testing/index.ts":{"bytes":749,"imports":[{"path":"packages/core/functions/src/testing/setup.ts","kind":"import-statement","original":"./setup"},{"path":"packages/core/functions/src/testing/types.ts","kind":"import-statement","original":"./types"},{"path":"packages/core/functions/src/testing/util.ts","kind":"import-statement","original":"./util"},{"path":"packages/core/functions/src/testing/manifest.ts","kind":"import-statement","original":"./manifest"}],"format":"esm"}},"outputs":{"packages/core/functions/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":5752},"packages/core/functions/dist/lib/browser/index.mjs":{"imports":[{"path":"packages/core/functions/dist/lib/browser/chunk-Y2OPAP26.mjs","kind":"import-statement"},{"path":"packages/core/functions/dist/lib/browser/chunk-N5D5R4Q4.mjs","kind":"import-statement"},{"path":"@dxos/client","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["FUNCTION_TYPES","FunctionDef","FunctionManifestSchema","FunctionRegistry","FunctionTrigger","FunctionTriggerSchema","TriggerKind","TriggerRegistry","TriggerSchema","createSubscriptionTrigger","createTimerTrigger","subscriptionHandler"],"entryPoint":"packages/core/functions/src/index.ts","inputs":{"packages/core/functions/src/index.ts":{"bytesInOutput":0},"packages/core/functions/src/handler.ts":{"bytesInOutput":1624}},"bytes":2297},"packages/core/functions/dist/lib/browser/testing/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":32288},"packages/core/functions/dist/lib/browser/testing/index.mjs":{"imports":[{"path":"packages/core/functions/dist/lib/browser/chunk-Y2OPAP26.mjs","kind":"import-statement"},{"path":"packages/core/functions/dist/lib/browser/chunk-N5D5R4Q4.mjs","kind":"import-statement"},{"path":"get-port-please","kind":"import-statement","external":true},{"path":"@dxos/node-std/path","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"express","kind":"import-statement","external":true},{"path":"get-port-please","kind":"import-statement","external":true},{"path":"@dxos/node-std/path","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/node-std/path","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/echo-protocol","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/client/testing","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/protocols/proto/dxos/client/services","kind":"import-statement","external":true}],"exports":["TestType","createFunctionRuntime","createInitializedClients","inviteMember","startFunctionsHost","testFunctionManifest","triggerWebhook"],"entryPoint":"packages/core/functions/src/testing/index.ts","inputs":{"packages/core/functions/src/testing/setup.ts":{"bytesInOutput":2785},"packages/core/functions/src/testing/types.ts":{"bytesInOutput":182},"packages/core/functions/src/runtime/dev-server.ts":{"bytesInOutput":7870},"packages/core/functions/src/runtime/index.ts":{"bytesInOutput":0},"packages/core/functions/src/runtime/scheduler.ts":{"bytesInOutput":5374},"packages/core/functions/src/testing/index.ts":{"bytesInOutput":0},"packages/core/functions/src/testing/util.ts":{"bytesInOutput":1067},"packages/core/functions/src/testing/manifest.ts":{"bytesInOutput":146}},"bytes":18168},"packages/core/functions/dist/lib/browser/chunk-Y2OPAP26.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":26827},"packages/core/functions/dist/lib/browser/chunk-Y2OPAP26.mjs":{"imports":[{"path":"packages/core/functions/dist/lib/browser/chunk-N5D5R4Q4.mjs","kind":"import-statement"},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"cron","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["FunctionRegistry","TriggerRegistry","createSubscriptionTrigger","createTimerTrigger"],"inputs":{"packages/core/functions/src/function/function-registry.ts":{"bytesInOutput":3046},"packages/core/functions/src/function/index.ts":{"bytesInOutput":0},"packages/core/functions/src/trigger/type/subscription-trigger.ts":{"bytesInOutput":2007},"packages/core/functions/src/trigger/type/timer-trigger.ts":{"bytesInOutput":898},"packages/core/functions/src/trigger/trigger-registry.ts":{"bytesInOutput":7538},"packages/core/functions/src/trigger/type/index.ts":{"bytesInOutput":0},"packages/core/functions/src/trigger/index.ts":{"bytesInOutput":0}},"bytes":13994},"packages/core/functions/dist/lib/browser/types.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"packages/core/functions/dist/lib/browser/types.mjs":{"imports":[{"path":"packages/core/functions/dist/lib/browser/chunk-N5D5R4Q4.mjs","kind":"import-statement"}],"exports":["FUNCTION_TYPES","FunctionDef","FunctionManifestSchema","FunctionTrigger","FunctionTriggerSchema","TriggerKind","TriggerSchema"],"entryPoint":"packages/core/functions/src/types.ts","inputs":{},"bytes":388},"packages/core/functions/dist/lib/browser/chunk-N5D5R4Q4.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":7699},"packages/core/functions/dist/lib/browser/chunk-N5D5R4Q4.mjs":{"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true}],"exports":["FUNCTION_TYPES","FunctionDef","FunctionManifestSchema","FunctionTrigger","FunctionTriggerSchema","TriggerKind","TriggerSchema","__require"],"inputs":{"packages/core/functions/src/types.ts":{"bytesInOutput":3155}},"bytes":3798}}}
|
|
1
|
+
{"inputs":{"packages/core/functions/src/edge/functions.ts":{"bytes":13462,"imports":[{"path":"@dxos/edge-client","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/edge/index.ts":{"bytes":501,"imports":[{"path":"packages/core/functions/src/edge/functions.ts","kind":"import-statement","original":"./functions"}],"format":"esm"},"packages/core/functions/src/types/schema.ts":{"bytes":4663,"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/types/types.ts":{"bytes":14882,"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/types/index.ts":{"bytes":580,"imports":[{"path":"packages/core/functions/src/types/schema.ts","kind":"import-statement","original":"./schema"},{"path":"packages/core/functions/src/types/types.ts","kind":"import-statement","original":"./types"}],"format":"esm"},"packages/core/functions/src/function/function-registry.ts":{"bytes":13004,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"packages/core/functions/src/types/index.ts","kind":"import-statement","original":"../types"}],"format":"esm"},"packages/core/functions/src/function/index.ts":{"bytes":529,"imports":[{"path":"packages/core/functions/src/function/function-registry.ts","kind":"import-statement","original":"./function-registry"}],"format":"esm"},"packages/core/functions/src/handler.ts":{"bytes":10610,"imports":[{"path":"@dxos/client","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/trigger/type/subscription-trigger.ts":{"bytes":10314,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/trigger/type/timer-trigger.ts":{"bytes":4173,"imports":[{"path":"cron","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/trigger/type/index.ts":{"bytes":751,"imports":[{"path":"packages/core/functions/src/trigger/type/subscription-trigger.ts","kind":"import-statement","original":"./subscription-trigger"},{"path":"packages/core/functions/src/trigger/type/timer-trigger.ts","kind":"import-statement","original":"./timer-trigger"}],"format":"esm"},"packages/core/functions/src/trigger/trigger-registry.ts":{"bytes":28465,"imports":[{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"packages/core/functions/src/trigger/type/index.ts","kind":"import-statement","original":"./type"},{"path":"packages/core/functions/src/types/index.ts","kind":"import-statement","original":"../types"}],"format":"esm"},"packages/core/functions/src/trigger/index.ts":{"bytes":603,"imports":[{"path":"packages/core/functions/src/trigger/trigger-registry.ts","kind":"import-statement","original":"./trigger-registry"},{"path":"packages/core/functions/src/trigger/type/index.ts","kind":"import-statement","original":"./type"}],"format":"esm"},"packages/core/functions/src/index.ts":{"bytes":920,"imports":[{"path":"packages/core/functions/src/edge/index.ts","kind":"import-statement","original":"./edge"},{"path":"packages/core/functions/src/function/index.ts","kind":"import-statement","original":"./function"},{"path":"packages/core/functions/src/handler.ts","kind":"import-statement","original":"./handler"},{"path":"packages/core/functions/src/trigger/index.ts","kind":"import-statement","original":"./trigger"},{"path":"packages/core/functions/src/types/index.ts","kind":"import-statement","original":"./types"}],"format":"esm"},"packages/core/functions/src/testing/types.ts":{"bytes":1131,"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/runtime/dev-server.ts":{"bytes":28958,"imports":[{"path":"express","kind":"import-statement","external":true},{"path":"get-port-please","kind":"import-statement","external":true},{"path":"@dxos/node-std/path","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/runtime/scheduler.ts":{"bytes":21200,"imports":[{"path":"@dxos/node-std/path","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/echo-protocol","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"format":"esm"},"packages/core/functions/src/runtime/index.ts":{"bytes":598,"imports":[{"path":"packages/core/functions/src/runtime/dev-server.ts","kind":"import-statement","original":"./dev-server"},{"path":"packages/core/functions/src/runtime/scheduler.ts","kind":"import-statement","original":"./scheduler"}],"format":"esm"},"packages/core/functions/src/testing/setup.ts":{"bytes":12707,"imports":[{"path":"get-port-please","kind":"import-statement","external":true},{"path":"@dxos/node-std/path","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"packages/core/functions/src/testing/types.ts","kind":"import-statement","original":"./types"},{"path":"packages/core/functions/src/function/index.ts","kind":"import-statement","original":"../function"},{"path":"packages/core/functions/src/runtime/index.ts","kind":"import-statement","original":"../runtime"},{"path":"packages/core/functions/src/trigger/index.ts","kind":"import-statement","original":"../trigger"},{"path":"packages/core/functions/src/types/index.ts","kind":"import-statement","original":"../types"}],"format":"esm"},"packages/core/functions/src/testing/util.ts":{"bytes":4310,"imports":[{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/client/testing","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/protocols/proto/dxos/client/services","kind":"import-statement","external":true},{"path":"packages/core/functions/src/types/index.ts","kind":"import-statement","original":"../types"}],"format":"esm"},"packages/core/functions/src/testing/manifest.ts":{"bytes":1139,"imports":[],"format":"esm"},"packages/core/functions/src/testing/index.ts":{"bytes":749,"imports":[{"path":"packages/core/functions/src/testing/setup.ts","kind":"import-statement","original":"./setup"},{"path":"packages/core/functions/src/testing/types.ts","kind":"import-statement","original":"./types"},{"path":"packages/core/functions/src/testing/util.ts","kind":"import-statement","original":"./util"},{"path":"packages/core/functions/src/testing/manifest.ts","kind":"import-statement","original":"./manifest"}],"format":"esm"}},"outputs":{"packages/core/functions/dist/lib/browser/edge/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"packages/core/functions/dist/lib/browser/edge/index.mjs":{"imports":[{"path":"packages/core/functions/dist/lib/browser/chunk-B3FGASHJ.mjs","kind":"import-statement"},{"path":"packages/core/functions/dist/lib/browser/chunk-XRCXIG74.mjs","kind":"import-statement"}],"exports":["FUNCTIONS_PRESET_META_KEY","getInvocationUrl","getUserFunctionUrlInMetadata","incrementSemverPatch","publicKeyToDid","setUserFunctionUrlInMetadata","uploadWorkerFunction"],"entryPoint":"packages/core/functions/src/edge/index.ts","inputs":{},"bytes":509},"packages/core/functions/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":5765},"packages/core/functions/dist/lib/browser/index.mjs":{"imports":[{"path":"packages/core/functions/dist/lib/browser/chunk-B3FGASHJ.mjs","kind":"import-statement"},{"path":"packages/core/functions/dist/lib/browser/chunk-BCNGUHHW.mjs","kind":"import-statement"},{"path":"packages/core/functions/dist/lib/browser/chunk-PKOLPTSC.mjs","kind":"import-statement"},{"path":"packages/core/functions/dist/lib/browser/chunk-XRCXIG74.mjs","kind":"import-statement"},{"path":"@dxos/client","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["FUNCTIONS_PRESET_META_KEY","FUNCTION_TYPES","FunctionDef","FunctionManifestSchema","FunctionRegistry","FunctionTrigger","FunctionTriggerSchema","FunctionType","ScriptType","TextType","TriggerKind","TriggerRegistry","TriggerSchema","createSubscriptionTrigger","createTimerTrigger","getInvocationUrl","getUserFunctionUrlInMetadata","incrementSemverPatch","publicKeyToDid","setUserFunctionUrlInMetadata","subscriptionHandler","uploadWorkerFunction"],"entryPoint":"packages/core/functions/src/index.ts","inputs":{"packages/core/functions/src/index.ts":{"bytesInOutput":0},"packages/core/functions/src/handler.ts":{"bytesInOutput":1624}},"bytes":2809},"packages/core/functions/dist/lib/browser/chunk-B3FGASHJ.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":6942},"packages/core/functions/dist/lib/browser/chunk-B3FGASHJ.mjs":{"imports":[{"path":"@dxos/edge-client","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true}],"exports":["FUNCTIONS_PRESET_META_KEY","getInvocationUrl","getUserFunctionUrlInMetadata","incrementSemverPatch","publicKeyToDid","setUserFunctionUrlInMetadata","uploadWorkerFunction"],"inputs":{"packages/core/functions/src/edge/functions.ts":{"bytesInOutput":3267},"packages/core/functions/src/edge/index.ts":{"bytesInOutput":0}},"bytes":3585},"packages/core/functions/dist/lib/browser/testing/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":32290},"packages/core/functions/dist/lib/browser/testing/index.mjs":{"imports":[{"path":"packages/core/functions/dist/lib/browser/chunk-BCNGUHHW.mjs","kind":"import-statement"},{"path":"packages/core/functions/dist/lib/browser/chunk-PKOLPTSC.mjs","kind":"import-statement"},{"path":"packages/core/functions/dist/lib/browser/chunk-XRCXIG74.mjs","kind":"import-statement"},{"path":"get-port-please","kind":"import-statement","external":true},{"path":"@dxos/node-std/path","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"express","kind":"import-statement","external":true},{"path":"get-port-please","kind":"import-statement","external":true},{"path":"@dxos/node-std/path","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/node-std/path","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/echo-protocol","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/client/testing","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/protocols/proto/dxos/client/services","kind":"import-statement","external":true}],"exports":["TestType","createFunctionRuntime","createInitializedClients","inviteMember","startFunctionsHost","testFunctionManifest","triggerWebhook"],"entryPoint":"packages/core/functions/src/testing/index.ts","inputs":{"packages/core/functions/src/testing/setup.ts":{"bytesInOutput":2785},"packages/core/functions/src/testing/types.ts":{"bytesInOutput":182},"packages/core/functions/src/runtime/dev-server.ts":{"bytesInOutput":7870},"packages/core/functions/src/runtime/index.ts":{"bytesInOutput":0},"packages/core/functions/src/runtime/scheduler.ts":{"bytesInOutput":5374},"packages/core/functions/src/testing/index.ts":{"bytesInOutput":0},"packages/core/functions/src/testing/util.ts":{"bytesInOutput":1067},"packages/core/functions/src/testing/manifest.ts":{"bytesInOutput":146}},"bytes":18208},"packages/core/functions/dist/lib/browser/chunk-BCNGUHHW.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":26827},"packages/core/functions/dist/lib/browser/chunk-BCNGUHHW.mjs":{"imports":[{"path":"packages/core/functions/dist/lib/browser/chunk-PKOLPTSC.mjs","kind":"import-statement"},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/echo-db","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"cron","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/async","kind":"import-statement","external":true},{"path":"@dxos/client/echo","kind":"import-statement","external":true},{"path":"@dxos/context","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/log","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["FunctionRegistry","TriggerRegistry","createSubscriptionTrigger","createTimerTrigger"],"inputs":{"packages/core/functions/src/function/function-registry.ts":{"bytesInOutput":3046},"packages/core/functions/src/function/index.ts":{"bytesInOutput":0},"packages/core/functions/src/trigger/type/subscription-trigger.ts":{"bytesInOutput":2007},"packages/core/functions/src/trigger/type/timer-trigger.ts":{"bytesInOutput":898},"packages/core/functions/src/trigger/trigger-registry.ts":{"bytesInOutput":7538},"packages/core/functions/src/trigger/type/index.ts":{"bytesInOutput":0},"packages/core/functions/src/trigger/index.ts":{"bytesInOutput":0}},"bytes":13994},"packages/core/functions/dist/lib/browser/types/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"packages/core/functions/dist/lib/browser/types/index.mjs":{"imports":[{"path":"packages/core/functions/dist/lib/browser/chunk-PKOLPTSC.mjs","kind":"import-statement"},{"path":"packages/core/functions/dist/lib/browser/chunk-XRCXIG74.mjs","kind":"import-statement"}],"exports":["FUNCTION_TYPES","FunctionDef","FunctionManifestSchema","FunctionTrigger","FunctionTriggerSchema","FunctionType","ScriptType","TextType","TriggerKind","TriggerSchema"],"entryPoint":"packages/core/functions/src/types/index.ts","inputs":{},"bytes":505},"packages/core/functions/dist/lib/browser/chunk-PKOLPTSC.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":9923},"packages/core/functions/dist/lib/browser/chunk-PKOLPTSC.mjs":{"imports":[{"path":"@dxos/echo-schema","kind":"import-statement","external":true},{"path":"@dxos/echo-schema","kind":"import-statement","external":true}],"exports":["FUNCTION_TYPES","FunctionDef","FunctionManifestSchema","FunctionTrigger","FunctionTriggerSchema","FunctionType","ScriptType","TextType","TriggerKind","TriggerSchema"],"inputs":{"packages/core/functions/src/types/schema.ts":{"bytesInOutput":1051},"packages/core/functions/src/types/index.ts":{"bytesInOutput":0},"packages/core/functions/src/types/types.ts":{"bytesInOutput":3230}},"bytes":4642},"packages/core/functions/dist/lib/browser/chunk-XRCXIG74.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"packages/core/functions/dist/lib/browser/chunk-XRCXIG74.mjs":{"imports":[],"exports":["__require"],"inputs":{},"bytes":467}}}
|
|
@@ -2,12 +2,14 @@ import "@dxos/node-std/globals";
|
|
|
2
2
|
import {
|
|
3
3
|
FunctionRegistry,
|
|
4
4
|
TriggerRegistry
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-BCNGUHHW.mjs";
|
|
6
6
|
import {
|
|
7
7
|
FunctionDef,
|
|
8
|
-
FunctionTrigger
|
|
8
|
+
FunctionTrigger
|
|
9
|
+
} from "../chunk-PKOLPTSC.mjs";
|
|
10
|
+
import {
|
|
9
11
|
__require
|
|
10
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-XRCXIG74.mjs";
|
|
11
13
|
|
|
12
14
|
// packages/core/functions/src/testing/setup.ts
|
|
13
15
|
import { getRandomPort } from "get-port-please";
|