@dxos/functions 0.8.1-staging.391c573 → 0.8.1-staging.97aedb1
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-M7ZGVWUZ.mjs → chunk-HI7YZO2K.mjs} +2 -2
- package/dist/lib/browser/{chunk-UMJKVIP4.mjs → chunk-LT4LR4VU.mjs} +11 -33
- package/dist/lib/browser/chunk-LT4LR4VU.mjs.map +7 -0
- package/dist/lib/browser/{chunk-RTBBW6RI.mjs → chunk-RVSG6WTL.mjs} +119 -18
- package/dist/lib/browser/chunk-RVSG6WTL.mjs.map +7 -0
- package/dist/lib/browser/edge/index.mjs +1 -1
- package/dist/lib/browser/index.mjs +11 -5
- package/dist/lib/browser/index.mjs.map +2 -2
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +2 -2
- package/dist/lib/browser/types/index.mjs +9 -3
- package/dist/lib/node/{chunk-GX3ZLNHY.cjs → chunk-DSUGRAAL.cjs} +124 -20
- package/dist/lib/node/chunk-DSUGRAAL.cjs.map +7 -0
- package/dist/lib/node/{chunk-UHTKCFWT.cjs → chunk-NXZNXVT3.cjs} +15 -37
- package/dist/lib/node/chunk-NXZNXVT3.cjs.map +7 -0
- package/dist/lib/node/{chunk-AOKUMNKK.cjs → chunk-RXMCVAMJ.cjs} +15 -15
- package/dist/lib/node/edge/index.cjs +4 -4
- package/dist/lib/node/edge/index.cjs.map +1 -1
- package/dist/lib/node/index.cjs +35 -29
- package/dist/lib/node/index.cjs.map +2 -2
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +7 -7
- package/dist/lib/node/types/index.cjs +26 -20
- package/dist/lib/node/types/index.cjs.map +2 -2
- package/dist/lib/node-esm/{chunk-NALEEAQL.mjs → chunk-HBD2FZXO.mjs} +119 -18
- package/dist/lib/node-esm/chunk-HBD2FZXO.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-JDOIALGL.mjs → chunk-O2SXVYU5.mjs} +11 -33
- package/dist/lib/node-esm/chunk-O2SXVYU5.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-BYS52HOC.mjs → chunk-SQSJO5HI.mjs} +2 -2
- package/dist/lib/node-esm/edge/index.mjs +1 -1
- package/dist/lib/node-esm/index.mjs +11 -5
- package/dist/lib/node-esm/index.mjs.map +2 -2
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +2 -2
- package/dist/lib/node-esm/types/index.mjs +9 -3
- package/dist/types/src/edge/functions.d.ts +3 -3
- package/dist/types/src/edge/functions.d.ts.map +1 -1
- package/dist/types/src/handler.d.ts +1 -1
- package/dist/types/src/handler.d.ts.map +1 -1
- package/dist/types/src/types/schema.d.ts +20 -26
- package/dist/types/src/types/schema.d.ts.map +1 -1
- package/dist/types/src/types/trace.d.ts +102 -96
- package/dist/types/src/types/trace.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/package.json +18 -18
- package/src/edge/functions.ts +12 -29
- package/src/handler.ts +2 -2
- package/src/runtime/scheduler.test.ts +2 -1
- package/src/types/schema.ts +7 -7
- package/src/types/trace.ts +120 -8
- package/src/types/types.ts +2 -1
- package/dist/lib/browser/chunk-RTBBW6RI.mjs.map +0 -7
- package/dist/lib/browser/chunk-UMJKVIP4.mjs.map +0 -7
- package/dist/lib/node/chunk-GX3ZLNHY.cjs.map +0 -7
- package/dist/lib/node/chunk-UHTKCFWT.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-JDOIALGL.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-NALEEAQL.mjs.map +0 -7
- /package/dist/lib/browser/{chunk-M7ZGVWUZ.mjs.map → chunk-HI7YZO2K.mjs.map} +0 -0
- /package/dist/lib/node/{chunk-AOKUMNKK.cjs.map → chunk-RXMCVAMJ.cjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-BYS52HOC.mjs.map → chunk-SQSJO5HI.mjs.map} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/functions",
|
|
3
|
-
"version": "0.8.1-staging.
|
|
3
|
+
"version": "0.8.1-staging.97aedb1",
|
|
4
4
|
"description": "Functions API and runtime.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -67,27 +67,27 @@
|
|
|
67
67
|
"get-port-please": "^3.1.1",
|
|
68
68
|
"iso-did": "^1.6.0",
|
|
69
69
|
"ws": "^8.14.2",
|
|
70
|
-
"@dxos/async": "0.8.1-staging.
|
|
71
|
-
"@dxos/
|
|
72
|
-
"@dxos/
|
|
73
|
-
"@dxos/echo-db": "0.8.1-staging.
|
|
74
|
-
"@dxos/
|
|
75
|
-
"@dxos/
|
|
76
|
-
"@dxos/
|
|
77
|
-
"@dxos/
|
|
78
|
-
"@dxos/
|
|
79
|
-
"@dxos/
|
|
80
|
-
"@dxos/
|
|
81
|
-
"@dxos/
|
|
82
|
-
"@dxos/
|
|
83
|
-
"@dxos/
|
|
84
|
-
"@dxos/schema": "0.8.1-staging.
|
|
85
|
-
"@dxos/util": "0.8.1-staging.
|
|
70
|
+
"@dxos/async": "0.8.1-staging.97aedb1",
|
|
71
|
+
"@dxos/crypto": "0.8.1-staging.97aedb1",
|
|
72
|
+
"@dxos/client": "0.8.1-staging.97aedb1",
|
|
73
|
+
"@dxos/echo-db": "0.8.1-staging.97aedb1",
|
|
74
|
+
"@dxos/context": "0.8.1-staging.97aedb1",
|
|
75
|
+
"@dxos/echo-schema": "0.8.1-staging.97aedb1",
|
|
76
|
+
"@dxos/edge-client": "0.8.1-staging.97aedb1",
|
|
77
|
+
"@dxos/invariant": "0.8.1-staging.97aedb1",
|
|
78
|
+
"@dxos/echo-protocol": "0.8.1-staging.97aedb1",
|
|
79
|
+
"@dxos/keys": "0.8.1-staging.97aedb1",
|
|
80
|
+
"@dxos/live-object": "0.8.1-staging.97aedb1",
|
|
81
|
+
"@dxos/log": "0.8.1-staging.97aedb1",
|
|
82
|
+
"@dxos/node-std": "0.8.1-staging.97aedb1",
|
|
83
|
+
"@dxos/protocols": "0.8.1-staging.97aedb1",
|
|
84
|
+
"@dxos/schema": "0.8.1-staging.97aedb1",
|
|
85
|
+
"@dxos/util": "0.8.1-staging.97aedb1"
|
|
86
86
|
},
|
|
87
87
|
"devDependencies": {
|
|
88
88
|
"@types/express": "^4.17.17",
|
|
89
89
|
"@types/ws": "^7.4.0",
|
|
90
|
-
"@dxos/agent": "0.8.1-staging.
|
|
90
|
+
"@dxos/agent": "0.8.1-staging.97aedb1"
|
|
91
91
|
},
|
|
92
92
|
"publishConfig": {
|
|
93
93
|
"access": "public"
|
package/src/edge/functions.ts
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
import { type DID } from 'iso-did/types';
|
|
6
6
|
|
|
7
7
|
import { type Client } from '@dxos/client';
|
|
8
|
-
import {
|
|
8
|
+
import { createEdgeIdentity } from '@dxos/client/edge';
|
|
9
|
+
import { EdgeHttpClient } from '@dxos/edge-client';
|
|
9
10
|
import { invariant } from '@dxos/invariant';
|
|
10
11
|
import type { PublicKey, SpaceId } from '@dxos/keys';
|
|
11
12
|
import { log } from '@dxos/log';
|
|
@@ -13,19 +14,19 @@ import { type UploadFunctionResponseBody } from '@dxos/protocols';
|
|
|
13
14
|
|
|
14
15
|
export type UploadWorkerArgs = {
|
|
15
16
|
client: Client;
|
|
16
|
-
|
|
17
|
+
spaceId: SpaceId;
|
|
17
18
|
source: string;
|
|
18
19
|
version: string;
|
|
20
|
+
name?: string;
|
|
19
21
|
functionId?: string;
|
|
20
|
-
spaceId: SpaceId;
|
|
21
22
|
};
|
|
22
23
|
|
|
23
24
|
export const uploadWorkerFunction = async ({
|
|
24
25
|
client,
|
|
25
|
-
|
|
26
|
+
spaceId,
|
|
26
27
|
version,
|
|
27
28
|
source,
|
|
28
|
-
|
|
29
|
+
name,
|
|
29
30
|
functionId,
|
|
30
31
|
}: UploadWorkerArgs): Promise<UploadFunctionResponseBody> => {
|
|
31
32
|
const edgeUrl = client.config.values.runtime?.services?.edge?.url;
|
|
@@ -35,44 +36,26 @@ export const uploadWorkerFunction = async ({
|
|
|
35
36
|
edgeClient.setIdentity(edgeIdentity);
|
|
36
37
|
const response = await edgeClient.uploadFunction({ spaceId, functionId }, { name, version, script: source });
|
|
37
38
|
|
|
38
|
-
|
|
39
|
+
// TODO(burdon): Edge service log.
|
|
40
|
+
log.info('Uploaded', {
|
|
41
|
+
identityKey: edgeIdentity.identityKey,
|
|
39
42
|
functionId,
|
|
40
|
-
source,
|
|
41
43
|
name,
|
|
42
|
-
|
|
44
|
+
source: source.length,
|
|
43
45
|
response,
|
|
44
46
|
});
|
|
45
47
|
|
|
46
48
|
return response;
|
|
47
49
|
};
|
|
48
50
|
|
|
49
|
-
const createEdgeIdentity = (client: Client): EdgeIdentity => {
|
|
50
|
-
const identity = client.halo.identity.get();
|
|
51
|
-
const device = client.halo.device;
|
|
52
|
-
if (!identity || !device) {
|
|
53
|
-
throw new Error('Identity not available');
|
|
54
|
-
}
|
|
55
|
-
return {
|
|
56
|
-
identityKey: identity.identityKey.toHex(),
|
|
57
|
-
peerKey: device.deviceKey.toHex(),
|
|
58
|
-
presentCredentials: async ({ challenge }) => {
|
|
59
|
-
const identityService = client.services.services.IdentityService!;
|
|
60
|
-
const authCredential = await identityService.createAuthCredential();
|
|
61
|
-
return identityService.signPresentation({
|
|
62
|
-
presentation: { credentials: [authCredential] },
|
|
63
|
-
nonce: challenge,
|
|
64
|
-
});
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
|
|
69
51
|
export const incrementSemverPatch = (version: string): string => {
|
|
70
52
|
const [major, minor, patch] = version.split('.');
|
|
71
53
|
const patchNum = Number(patch);
|
|
72
|
-
invariant(!Number.isNaN(patchNum),
|
|
54
|
+
invariant(!Number.isNaN(patchNum), `Unexpected function version format: ${version}`);
|
|
73
55
|
return [major, minor, String(patchNum + 1)].join('.');
|
|
74
56
|
};
|
|
75
57
|
|
|
58
|
+
// TODO(burdon): Factor out.
|
|
76
59
|
export const publicKeyToDid = (key: PublicKey): DID => {
|
|
77
60
|
return `did:key:${key.toHex()}`;
|
|
78
61
|
};
|
package/src/handler.ts
CHANGED
|
@@ -171,7 +171,7 @@ export type SubscriptionData = {
|
|
|
171
171
|
// TODO(burdon): Evolve into plugin definition like Composer.
|
|
172
172
|
export const subscriptionHandler = <TMeta>(
|
|
173
173
|
handler: FunctionHandler<SubscriptionData, TMeta>,
|
|
174
|
-
types?: S.Schema
|
|
174
|
+
types?: S.Schema.AnyNoContext[],
|
|
175
175
|
): FunctionHandler<RawSubscriptionData, TMeta> => {
|
|
176
176
|
return async ({ event: { data }, context, response, ...rest }) => {
|
|
177
177
|
const { client } = context;
|
|
@@ -199,7 +199,7 @@ export const subscriptionHandler = <TMeta>(
|
|
|
199
199
|
};
|
|
200
200
|
|
|
201
201
|
// TODO(burdon): Evolve types as part of function metadata.
|
|
202
|
-
const registerTypes = (space: Space, types: S.Schema
|
|
202
|
+
const registerTypes = (space: Space, types: S.Schema.AnyNoContext[] = []) => {
|
|
203
203
|
const registry = space.db.graph.schemaRegistry;
|
|
204
204
|
for (const type of types) {
|
|
205
205
|
if (!registry.hasSchema(type)) {
|
|
@@ -16,7 +16,8 @@ import { TriggerRegistry } from '../trigger';
|
|
|
16
16
|
import { TriggerKind, type FunctionManifest } from '../types';
|
|
17
17
|
|
|
18
18
|
// TODO(burdon): Test we can add and remove triggers.
|
|
19
|
-
|
|
19
|
+
// Flaky: https://cloud.nx.app/runs/uqhKOBA6JQ/task/functions%3Atest
|
|
20
|
+
describe.skip('scheduler', () => {
|
|
20
21
|
let testBuilder: TestBuilder;
|
|
21
22
|
let client: Client;
|
|
22
23
|
|
package/src/types/schema.ts
CHANGED
|
@@ -2,28 +2,28 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { JsonSchemaType, Ref, S, TypedObject } from '@dxos/echo-schema';
|
|
5
|
+
import { EchoObject, JsonSchemaType, LabelAnnotationId, Ref, S, TypedObject } from '@dxos/echo-schema';
|
|
6
6
|
import { TextType } from '@dxos/schema';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Source script.
|
|
10
10
|
*/
|
|
11
|
-
export
|
|
12
|
-
typename: 'dxos.org/type/Script',
|
|
13
|
-
version: '0.1.0',
|
|
14
|
-
})({
|
|
11
|
+
export const ScriptType = S.Struct({
|
|
15
12
|
name: S.optional(S.String),
|
|
16
13
|
description: S.optional(S.String),
|
|
17
14
|
// TODO(burdon): Change to hash of deployed content.
|
|
18
15
|
// Whether source has changed since last deploy.
|
|
19
16
|
changed: S.optional(S.Boolean),
|
|
20
17
|
source: Ref(TextType),
|
|
21
|
-
})
|
|
18
|
+
})
|
|
19
|
+
.annotations({ [LabelAnnotationId]: 'name' })
|
|
20
|
+
.pipe(EchoObject({ typename: 'dxos.org/type/Script', version: '0.1.0' }));
|
|
21
|
+
|
|
22
|
+
export type ScriptType = S.Schema.Type<typeof ScriptType>;
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
25
|
* Function deployment.
|
|
25
26
|
*/
|
|
26
|
-
// TODO(burdon): Move to core/functions.
|
|
27
27
|
export class FunctionType extends TypedObject({
|
|
28
28
|
typename: 'dxos.org/type/Function',
|
|
29
29
|
version: '0.1.0',
|
package/src/types/trace.ts
CHANGED
|
@@ -3,12 +3,20 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { EchoObject, Expando, ObjectId, Ref, S } from '@dxos/echo-schema';
|
|
6
|
+
import { log } from '@dxos/log';
|
|
6
7
|
|
|
7
|
-
import { FunctionTrigger } from './types';
|
|
8
|
+
import { FunctionTrigger, type FunctionTriggerType } from './types';
|
|
8
9
|
|
|
9
10
|
export enum InvocationOutcome {
|
|
10
11
|
SUCCESS = 'success',
|
|
11
12
|
FAILURE = 'failure',
|
|
13
|
+
PENDING = 'pending',
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// TODO(burdon): Convert to extensible discriminated union of EDGE events.
|
|
17
|
+
export enum InvocationTraceEventType {
|
|
18
|
+
START = 'start',
|
|
19
|
+
END = 'end',
|
|
12
20
|
}
|
|
13
21
|
|
|
14
22
|
export const TraceEventException = S.Struct({
|
|
@@ -17,16 +25,31 @@ export const TraceEventException = S.Struct({
|
|
|
17
25
|
name: S.String,
|
|
18
26
|
stack: S.optional(S.String),
|
|
19
27
|
});
|
|
28
|
+
export type TraceEventException = S.Schema.Type<typeof TraceEventException>;
|
|
20
29
|
|
|
21
|
-
export const
|
|
30
|
+
export const InvocationTraceStartEvent = S.Struct({
|
|
31
|
+
/**
|
|
32
|
+
* Queue message id.
|
|
33
|
+
*/
|
|
22
34
|
id: ObjectId,
|
|
35
|
+
type: S.Literal(InvocationTraceEventType.START),
|
|
36
|
+
/**
|
|
37
|
+
* Invocation id, the same for invocation start and end events.
|
|
38
|
+
*/
|
|
39
|
+
invocationId: ObjectId,
|
|
40
|
+
/**
|
|
41
|
+
* Event generation time.
|
|
42
|
+
*/
|
|
23
43
|
timestampMs: S.Number,
|
|
24
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Data passed to function / workflow as an argument.
|
|
46
|
+
*/
|
|
47
|
+
// TODO(burdon): Input schema?
|
|
25
48
|
input: S.Object,
|
|
26
|
-
durationMs: S.Number,
|
|
27
49
|
/**
|
|
28
50
|
* Queue DXN for function/workflow invocation events.
|
|
29
51
|
*/
|
|
52
|
+
// TODO(burdon): Need reference type for queue. vs. string?
|
|
30
53
|
invocationTraceQueue: Ref(Expando),
|
|
31
54
|
/**
|
|
32
55
|
* DXN of the invoked function/workflow.
|
|
@@ -36,13 +59,32 @@ export const InvocationTraceEvent = S.Struct({
|
|
|
36
59
|
* Present for automatic invocations.
|
|
37
60
|
*/
|
|
38
61
|
trigger: S.optional(Ref(FunctionTrigger)),
|
|
62
|
+
}).pipe(EchoObject({ typename: 'dxos.org/type/InvocationTraceStart', version: '0.1.0' }));
|
|
63
|
+
|
|
64
|
+
export type InvocationTraceStartEvent = S.Schema.Type<typeof InvocationTraceStartEvent>;
|
|
65
|
+
|
|
66
|
+
export const InvocationTraceEndEvent = S.Struct({
|
|
67
|
+
/**
|
|
68
|
+
* Trace event id.
|
|
69
|
+
*/
|
|
70
|
+
id: ObjectId,
|
|
71
|
+
type: S.Literal(InvocationTraceEventType.END),
|
|
39
72
|
/**
|
|
40
|
-
*
|
|
73
|
+
* Invocation id, will be the same for invocation start and end.
|
|
41
74
|
*/
|
|
75
|
+
invocationId: ObjectId,
|
|
76
|
+
/**
|
|
77
|
+
* Event generation time.
|
|
78
|
+
*/
|
|
79
|
+
// TODO(burdon): Remove ms suffix.
|
|
80
|
+
timestampMs: S.Number,
|
|
81
|
+
outcome: S.Enums(InvocationOutcome),
|
|
42
82
|
exception: S.optional(TraceEventException),
|
|
43
|
-
}).pipe(EchoObject('dxos.org/type/
|
|
83
|
+
}).pipe(EchoObject({ typename: 'dxos.org/type/InvocationTraceEnd', version: '0.1.0' }));
|
|
44
84
|
|
|
45
|
-
export type
|
|
85
|
+
export type InvocationTraceEndEvent = S.Schema.Type<typeof InvocationTraceEndEvent>;
|
|
86
|
+
|
|
87
|
+
export type InvocationTraceEvent = InvocationTraceStartEvent | InvocationTraceEndEvent;
|
|
46
88
|
|
|
47
89
|
export const TraceEventLog = S.Struct({
|
|
48
90
|
timestampMs: S.Number,
|
|
@@ -53,6 +95,7 @@ export const TraceEventLog = S.Struct({
|
|
|
53
95
|
|
|
54
96
|
export const TraceEvent = S.Struct({
|
|
55
97
|
id: ObjectId,
|
|
98
|
+
// TODO(burdon): Need enum/numeric result (not string).
|
|
56
99
|
outcome: S.String,
|
|
57
100
|
truncated: S.Boolean,
|
|
58
101
|
/**
|
|
@@ -61,6 +104,75 @@ export const TraceEvent = S.Struct({
|
|
|
61
104
|
ingestionTimestampMs: S.Number,
|
|
62
105
|
logs: S.Array(TraceEventLog),
|
|
63
106
|
exceptions: S.Array(TraceEventException),
|
|
64
|
-
}).pipe(EchoObject('dxos.org/type/TraceEvent', '0.1.0'));
|
|
107
|
+
}).pipe(EchoObject({ typename: 'dxos.org/type/TraceEvent', version: '0.1.0' }));
|
|
65
108
|
|
|
66
109
|
export type TraceEvent = S.Schema.Type<typeof TraceEvent>;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Deprecated InvocationTrace event format.
|
|
113
|
+
* @deprecated
|
|
114
|
+
*/
|
|
115
|
+
// TODO(burdon): Remove.
|
|
116
|
+
export type InvocationSpan = {
|
|
117
|
+
id: string;
|
|
118
|
+
timestampMs: number;
|
|
119
|
+
outcome: InvocationOutcome;
|
|
120
|
+
input: object;
|
|
121
|
+
durationMs: number;
|
|
122
|
+
invocationTraceQueue: Ref<Expando>;
|
|
123
|
+
invocationTarget: Ref<Expando>;
|
|
124
|
+
trigger?: Ref<FunctionTriggerType>;
|
|
125
|
+
exception?: TraceEventException;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
export const createInvocationSpans = (items?: InvocationTraceEvent[]): InvocationSpan[] => {
|
|
129
|
+
if (!items) {
|
|
130
|
+
return [];
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const eventsByInvocationId = new Map<string, { start?: InvocationTraceStartEvent; end?: InvocationTraceEndEvent }>();
|
|
134
|
+
for (const event of items) {
|
|
135
|
+
if (!('invocationId' in event)) {
|
|
136
|
+
// Skip legacy format entries.
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const invocationId = event.invocationId;
|
|
141
|
+
const entry = eventsByInvocationId.get(invocationId) || { start: undefined, end: undefined };
|
|
142
|
+
if (event.type === InvocationTraceEventType.START) {
|
|
143
|
+
entry.start = event as InvocationTraceStartEvent;
|
|
144
|
+
} else if (event.type === InvocationTraceEventType.END) {
|
|
145
|
+
entry.end = event as InvocationTraceEndEvent;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
eventsByInvocationId.set(invocationId, entry);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const now = Date.now();
|
|
152
|
+
const result: InvocationSpan[] = [];
|
|
153
|
+
|
|
154
|
+
// Create spans for each invocation
|
|
155
|
+
for (const [invocationId, { start, end }] of eventsByInvocationId.entries()) {
|
|
156
|
+
if (!start) {
|
|
157
|
+
// No start event, can't create a meaningful span
|
|
158
|
+
log.warn('found end event without matching start', { invocationId });
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const isInProgress = end === undefined;
|
|
163
|
+
|
|
164
|
+
result.push({
|
|
165
|
+
id: invocationId,
|
|
166
|
+
timestampMs: start.timestampMs,
|
|
167
|
+
durationMs: isInProgress ? now - start.timestampMs : end!.timestampMs - start.timestampMs,
|
|
168
|
+
outcome: end?.outcome ?? InvocationOutcome.PENDING,
|
|
169
|
+
exception: end?.exception,
|
|
170
|
+
input: start.input,
|
|
171
|
+
invocationTraceQueue: start.invocationTraceQueue,
|
|
172
|
+
invocationTarget: start.invocationTarget,
|
|
173
|
+
trigger: start.trigger,
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return result;
|
|
178
|
+
};
|
package/src/types/types.ts
CHANGED
|
@@ -119,7 +119,8 @@ export const FunctionTriggerSchema = S.Struct({
|
|
|
119
119
|
// TODO(burdon): Flatten entire schema.
|
|
120
120
|
spec: S.optional(TriggerSchema),
|
|
121
121
|
|
|
122
|
-
// TODO(burdon): Get
|
|
122
|
+
// TODO(burdon): Get schema as partial from function.
|
|
123
|
+
// TODO(wittjosiah): Rename to payload.
|
|
123
124
|
// The `meta` property is merged into the event data passed to the function.
|
|
124
125
|
meta: S.optional(S.mutable(S.Record({ key: S.String, value: S.Any }))),
|
|
125
126
|
});
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/types/schema.ts", "../../../src/types/types.ts", "../../../src/types/trace.ts", "../../../src/types/url.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { JsonSchemaType, Ref, S, TypedObject } from '@dxos/echo-schema';\nimport { TextType } from '@dxos/schema';\n\n/**\n * Source script.\n */\nexport class ScriptType extends TypedObject({\n typename: 'dxos.org/type/Script',\n version: '0.1.0',\n})({\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 description: S.optional(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 outputSchema: 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, DXN } 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 Email = 'email',\n Queue = 'queue',\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\nconst EmailTriggerSchema = S.Struct({\n type: S.Literal(TriggerKind.Email).annotations(typeLiteralAnnotations),\n}).pipe(S.mutable);\n\nexport type EmailTrigger = S.Schema.Type<typeof EmailTriggerSchema>;\n\nconst QueueTriggerSchema = S.Struct({\n type: S.Literal(TriggerKind.Queue).annotations(typeLiteralAnnotations),\n queue: DXN,\n}).pipe(S.mutable);\n\nexport type QueueTrigger = S.Schema.Type<typeof QueueTriggerSchema>;\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 TimerTriggerSchema,\n WebhookTriggerSchema,\n SubscriptionTriggerSchema,\n EmailTriggerSchema,\n QueueTriggerSchema,\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 // TODO(wittjosiah): This should probably be a Ref?\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", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { EchoObject, Expando, ObjectId, Ref, S } from '@dxos/echo-schema';\n\nimport { FunctionTrigger } from './types';\n\nexport enum InvocationOutcome {\n SUCCESS = 'success',\n FAILURE = 'failure',\n}\n\nexport const TraceEventException = S.Struct({\n timestampMs: S.Number,\n message: S.String,\n name: S.String,\n stack: S.optional(S.String),\n});\n\nexport const InvocationTraceEvent = S.Struct({\n id: ObjectId,\n timestampMs: S.Number,\n outcome: S.Enums(InvocationOutcome),\n input: S.Object,\n durationMs: S.Number,\n /**\n * Queue DXN for function/workflow invocation events.\n */\n invocationTraceQueue: Ref(Expando),\n /**\n * DXN of the invoked function/workflow.\n */\n invocationTarget: Ref(Expando),\n /**\n * Present for automatic invocations.\n */\n trigger: S.optional(Ref(FunctionTrigger)),\n /**\n * Present for outcome FAILURE.\n */\n exception: S.optional(TraceEventException),\n}).pipe(EchoObject('dxos.org/type/InvocationTrace', '0.1.0'));\n\nexport type InvocationTraceEvent = S.Schema.Type<typeof InvocationTraceEvent>;\n\nexport const TraceEventLog = S.Struct({\n timestampMs: S.Number,\n level: S.String,\n message: S.String,\n context: S.optional(S.Object),\n});\n\nexport const TraceEvent = S.Struct({\n id: ObjectId,\n outcome: S.String,\n truncated: S.Boolean,\n /**\n * Time when the event was persisted.\n */\n ingestionTimestampMs: S.Number,\n logs: S.Array(TraceEventLog),\n exceptions: S.Array(TraceEventException),\n}).pipe(EchoObject('dxos.org/type/TraceEvent', '0.1.0'));\n\nexport type TraceEvent = S.Schema.Type<typeof TraceEvent>;\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type ObjectMeta } from '@dxos/echo-schema';\nimport { type SpaceId } from '@dxos/keys';\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\nconst isSecure = (protocol: string) => {\n return protocol === 'https:' || protocol === 'wss:';\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 = isSecure(url.protocol) ? 'https' : 'http';\n return url.toString();\n};\n\nexport type InvocationOptions = {\n spaceId?: SpaceId;\n subjectId?: string;\n};\n"],
|
|
5
|
-
"mappings": ";;;AAIA,SAASA,gBAAgBC,KAAKC,GAAGC,mBAAmB;AACpD,SAASC,gBAAgB;AAKlB,IAAMC,aAAN,cAAyBC,YAAY;EAC1CC,UAAU;EACVC,SAAS;AACX,CAAA,EAAG;EACDC,MAAMC,EAAEC,SAASD,EAAEE,MAAM;EACzBC,aAAaH,EAAEC,SAASD,EAAEE,MAAM;;;EAGhCE,SAASJ,EAAEC,SAASD,EAAEK,OAAO;EAC7BC,QAAQC,IAAIC,QAAAA;AACd,CAAA,EAAA;AAAI;AAMG,IAAMC,eAAN,cAA2Bb,YAAY;EAC5CC,UAAU;EACVC,SAAS;AACX,CAAA,EAAG;;EAEDC,MAAMC,EAAEU;EACRZ,SAASE,EAAEE;EAEXC,aAAaH,EAAEC,SAASD,EAAEE,MAAM;;;EAIhCI,QAAQN,EAAEC,SAASM,IAAIZ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CAACH,aAAqBI,SAAiBC,UAA6B,CAAC,MAAC;AACpG,QAAMC,UAAU,IAAIC,IAAI,cAAcH,OAAAA;AAGtC,QAAMI,cAAcR,YAAYS,QAAQ,OAAO,EAAA;AAC/C,QAAMC,MAAM,IAAIH,IAAI,KAAKC,WAAAA,IAAeF,QAAQK,SAAQ,CAAA;AACxDN,UAAQO,WAAWF,IAAIG,aAAaC,IAAI,WAAWT,QAAQO,OAAO;AAClEP,UAAQU,aAAaL,IAAIG,aAAaC,IAAI,aAAaT,QAAQU,SAAS;AACxEL,MAAInB,WAAWD,SAASoB,IAAInB,QAAQ,IAAI,UAAU;AAClD,SAAOmB,IAAIC,SAAQ;AACrB;",
|
|
6
|
-
"names": ["JsonSchemaType", "Ref", "S", "TypedObject", "TextType", "ScriptType", "TypedObject", "typename", "version", "name", "S", "optional", "String", "description", "changed", "Boolean", "source", "Ref", "TextType", "FunctionType", "NonEmptyString", "inputSchema", "JsonSchemaType", "outputSchema", "binding", "AST", "OptionsAnnotationId", "RawObject", "S", "TypedObject", "DXN", "TriggerKind", "typeLiteralAnnotations", "AST", "TitleAnnotationId", "TimerTriggerSchema", "S", "Struct", "type", "Literal", "annotations", "cron", "String", "ExamplesAnnotationId", "pipe", "mutable", "EmailTriggerSchema", "QueueTriggerSchema", "queue", "DXN", "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", "EchoObject", "Expando", "ObjectId", "Ref", "S", "InvocationOutcome", "TraceEventException", "S", "Struct", "timestampMs", "Number", "message", "String", "name", "stack", "optional", "InvocationTraceEvent", "id", "ObjectId", "outcome", "Enums", "input", "Object", "durationMs", "invocationTraceQueue", "Ref", "Expando", "invocationTarget", "trigger", "FunctionTrigger", "exception", "pipe", "EchoObject", "TraceEventLog", "level", "context", "TraceEvent", "truncated", "Boolean", "ingestionTimestampMs", "logs", "Array", "exceptions", "FUNCTIONS_META_KEY", "FUNCTIONS_PRESET_META_KEY", "isSecure", "protocol", "getUserFunctionUrlInMetadata", "meta", "keys", "find", "key", "source", "id", "setUserFunctionUrlInMetadata", "functionUrl", "Error", "push", "getInvocationUrl", "edgeUrl", "options", "baseUrl", "URL", "relativeUrl", "replace", "url", "toString", "spaceId", "searchParams", "set", "subjectId"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
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 { 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\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\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"],
|
|
5
|
-
"mappings": ";;;AAOA,SAASA,sBAAyC;AAClD,SAASC,iBAAiB;AAE1B,SAASC,WAAW;;AAYb,IAAMC,uBAAuB,OAAO,EACzCC,QACAC,MACAC,SACAC,QACAC,SACAC,WAAU,MACO;AACjB,QAAMC,UAAUN,OAAOO,OAAOC,OAAOC,SAASC,UAAUC,MAAMC;AAC9Df,YAAUS,SAAS,2BAAA;;;;;;;;;AACnB,QAAMO,aAAa,IAAIjB,eAAeU,OAAAA;AACtC,QAAMQ,eAAeC,mBAAmBf,MAAAA;AACxCa,aAAWG,YAAYF,YAAAA;AACvB,QAAMG,WAAW,MAAMJ,WAAWK,eAAe;IAAEd;IAASC;EAAW,GAAG;IAAEJ;IAAMC;IAASiB,QAAQhB;EAAO,CAAA;AAE1GL,MAAI,YAAY;IACdO;IACAF;IACAF;IACAmB,aAAaN,aAAaM;IAC1BH;EACF,GAAA;;;;;;AAEA,SAAOA;AACT;AAEA,IAAMF,qBAAqB,CAACf,WAAAA;AAC1B,QAAMqB,WAAWrB,OAAOsB,KAAKD,SAASE,IAAG;AACzC,QAAMC,SAASxB,OAAOsB,KAAKE;AAC3B,MAAI,CAACH,YAAY,CAACG,QAAQ;AACxB,UAAM,IAAIC,MAAM,wBAAA;EAClB;AACA,SAAO;IACLL,aAAaC,SAASD,YAAYM,MAAK;IACvCC,SAASH,OAAOI,UAAUF,MAAK;IAC/BG,oBAAoB,OAAO,EAAEC,UAAS,MAAE;AACtC,YAAMC,kBAAkB/B,OAAOU,SAASA,SAASsB;AACjD,YAAMC,iBAAiB,MAAMF,gBAAgBG,qBAAoB;AACjE,aAAOH,gBAAgBI,iBAAiB;QACtCC,cAAc;UAAEC,aAAa;YAACJ;;QAAgB;QAC9CK,OAAOR;MACT,CAAA;IACF;EACF;AACF;AAEO,IAAMS,uBAAuB,CAACrC,YAAAA;AACnC,QAAM,CAACsC,OAAOC,OAAOC,KAAAA,IAASxC,QAAQyC,MAAM,GAAA;AAC5C,QAAMC,WAAWC,OAAOH,KAAAA;AACxB7C,YAAU,CAACgD,OAAOC,MAAMF,QAAAA,GAAW,uCAAA;;;;;;;;;AACnC,SAAO;IAACJ;IAAOC;IAAOM,OAAOH,WAAW,CAAA;IAAII,KAAK,GAAA;AACnD;AAEO,IAAMC,iBAAiB,CAACC,QAAAA;AAC7B,SAAO,WAAWA,IAAIxB,MAAK,CAAA;AAC7B;",
|
|
6
|
-
"names": ["EdgeHttpClient", "invariant", "log", "uploadWorkerFunction", "client", "name", "version", "source", "spaceId", "functionId", "edgeUrl", "config", "values", "runtime", "services", "edge", "url", "edgeClient", "edgeIdentity", "createEdgeIdentity", "setIdentity", "response", "uploadFunction", "script", "identityKey", "identity", "halo", "get", "device", "Error", "toHex", "peerKey", "deviceKey", "presentCredentials", "challenge", "identityService", "IdentityService", "authCredential", "createAuthCredential", "signPresentation", "presentation", "credentials", "nonce", "incrementSemverPatch", "major", "minor", "patch", "split", "patchNum", "Number", "isNaN", "String", "join", "publicKeyToDid", "key"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/types/schema.ts", "../../../src/types/types.ts", "../../../src/types/trace.ts", "../../../src/types/url.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { JsonSchemaType, Ref, S, TypedObject } from '@dxos/echo-schema';\nimport { TextType } from '@dxos/schema';\n\n/**\n * Source script.\n */\nexport class ScriptType extends TypedObject({\n typename: 'dxos.org/type/Script',\n version: '0.1.0',\n})({\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 description: S.optional(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 outputSchema: 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, DXN } 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 Email = 'email',\n Queue = 'queue',\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\nconst EmailTriggerSchema = S.Struct({\n type: S.Literal(TriggerKind.Email).annotations(typeLiteralAnnotations),\n}).pipe(S.mutable);\n\nexport type EmailTrigger = S.Schema.Type<typeof EmailTriggerSchema>;\n\nconst QueueTriggerSchema = S.Struct({\n type: S.Literal(TriggerKind.Queue).annotations(typeLiteralAnnotations),\n queue: DXN,\n}).pipe(S.mutable);\n\nexport type QueueTrigger = S.Schema.Type<typeof QueueTriggerSchema>;\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 TimerTriggerSchema,\n WebhookTriggerSchema,\n SubscriptionTriggerSchema,\n EmailTriggerSchema,\n QueueTriggerSchema,\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 // TODO(wittjosiah): This should probably be a Ref?\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", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { EchoObject, Expando, ObjectId, Ref, S } from '@dxos/echo-schema';\n\nimport { FunctionTrigger } from './types';\n\nexport enum InvocationOutcome {\n SUCCESS = 'success',\n FAILURE = 'failure',\n}\n\nexport const TraceEventException = S.Struct({\n timestampMs: S.Number,\n message: S.String,\n name: S.String,\n stack: S.optional(S.String),\n});\n\nexport const InvocationTraceEvent = S.Struct({\n id: ObjectId,\n timestampMs: S.Number,\n outcome: S.Enums(InvocationOutcome),\n input: S.Object,\n durationMs: S.Number,\n /**\n * Queue DXN for function/workflow invocation events.\n */\n invocationTraceQueue: Ref(Expando),\n /**\n * DXN of the invoked function/workflow.\n */\n invocationTarget: Ref(Expando),\n /**\n * Present for automatic invocations.\n */\n trigger: S.optional(Ref(FunctionTrigger)),\n /**\n * Present for outcome FAILURE.\n */\n exception: S.optional(TraceEventException),\n}).pipe(EchoObject('dxos.org/type/InvocationTrace', '0.1.0'));\n\nexport type InvocationTraceEvent = S.Schema.Type<typeof InvocationTraceEvent>;\n\nexport const TraceEventLog = S.Struct({\n timestampMs: S.Number,\n level: S.String,\n message: S.String,\n context: S.optional(S.Object),\n});\n\nexport const TraceEvent = S.Struct({\n id: ObjectId,\n outcome: S.String,\n truncated: S.Boolean,\n /**\n * Time when the event was persisted.\n */\n ingestionTimestampMs: S.Number,\n logs: S.Array(TraceEventLog),\n exceptions: S.Array(TraceEventException),\n}).pipe(EchoObject('dxos.org/type/TraceEvent', '0.1.0'));\n\nexport type TraceEvent = S.Schema.Type<typeof TraceEvent>;\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type ObjectMeta } from '@dxos/echo-schema';\nimport { type SpaceId } from '@dxos/keys';\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\nconst isSecure = (protocol: string) => {\n return protocol === 'https:' || protocol === 'wss:';\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 = isSecure(url.protocol) ? 'https' : 'http';\n return url.toString();\n};\n\nexport type InvocationOptions = {\n spaceId?: SpaceId;\n subjectId?: string;\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,yBAAoD;AACpD,oBAAyB;ACDzB,IAAAA,sBAAyE;ACAzE,IAAAA,sBAAsD;AFM/C,IAAMC,aAAN,kBAAyBC,gCAAY;EAC1CC,UAAU;EACVC,SAAS;AACX,CAAA,EAAG;EACDC,MAAMC,qBAAEC,SAASD,qBAAEE,MAAM;EACzBC,aAAaH,qBAAEC,SAASD,qBAAEE,MAAM;;;EAGhCE,SAASJ,qBAAEC,SAASD,qBAAEK,OAAO;EAC7BC,YAAQC,wBAAIC,sBAAAA;AACd,CAAA,EAAA;AAAI;AAMG,IAAMC,eAAN,kBAA2Bb,gCAAY;EAC5CC,UAAU;EACVC,SAAS;AACX,CAAA,EAAG;;EAEDC,MAAMC,qBAAEU;EACRZ,SAASE,qBAAEE;EAEXC,aAAaH,qBAAEC,SAASD,qBAAEE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_schema", "ScriptType", "TypedObject", "typename", "version", "name", "S", "optional", "String", "description", "changed", "Boolean", "source", "Ref", "TextType", "FunctionType", "NonEmptyString", "inputSchema", "JsonSchemaType", "outputSchema", "binding", "TriggerKind", "typeLiteralAnnotations", "AST", "TitleAnnotationId", "TimerTriggerSchema", "Struct", "type", "Literal", "annotations", "cron", "ExamplesAnnotationId", "pipe", "mutable", "EmailTriggerSchema", "QueueTriggerSchema", "queue", "DXN", "WebhookTriggerSchema", "method", "OptionsAnnotationId", "port", "Number", "QuerySchema", "props", "Record", "key", "value", "Any", "SubscriptionTriggerSchema", "filter", "options", "deep", "delay", "TriggerSchema", "Union", "FunctionTriggerSchema", "function", "enabled", "spec", "meta", "FunctionTrigger", "fields", "FunctionDef", "uri", "route", "handler", "FunctionManifestSchema", "functions", "Array", "RawObject", "triggers", "FUNCTION_TYPES", "InvocationOutcome", "TraceEventException", "timestampMs", "message", "stack", "InvocationTraceEvent", "id", "ObjectId", "outcome", "Enums", "input", "Object", "durationMs", "invocationTraceQueue", "Expando", "invocationTarget", "trigger", "exception", "EchoObject", "TraceEventLog", "level", "context", "TraceEvent", "truncated", "ingestionTimestampMs", "logs", "exceptions", "FUNCTIONS_META_KEY", "FUNCTIONS_PRESET_META_KEY", "isSecure", "protocol", "getUserFunctionUrlInMetadata", "keys", "find", "setUserFunctionUrlInMetadata", "functionUrl", "Error", "push", "getInvocationUrl", "edgeUrl", "baseUrl", "URL", "relativeUrl", "replace", "url", "toString", "spaceId", "searchParams", "set", "subjectId"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
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 { 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\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\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"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAOA,yBAAkD;AAClD,uBAA0B;AAE1B,iBAAoB;;AAYb,IAAMA,uBAAuB,OAAO,EACzCC,QACAC,MACAC,SACAC,QACAC,SACAC,WAAU,MACO;AACjB,QAAMC,U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EO,IAAMC,iBAAiB,CAACC,QAAAA;AAC7B,SAAO,WAAWA,IAAIxB,MAAK,CAAA;AAC7B;",
|
|
6
|
-
"names": ["uploadWorkerFunction", "client", "name", "version", "source", "spaceId", "functionId", "edgeUrl", "config", "values", "runtime", "services", "edge", "url", "invariant", "edgeClient", "EdgeHttpClient", "edgeIdentity", "createEdgeIdentity", "setIdentity", "response", "uploadFunction", "script", "log", "identityKey", "identity", "halo", "get", "device", "Error", "toHex", "peerKey", "deviceKey", "presentCredentials", "challenge", "identityService", "IdentityService", "authCredential", "createAuthCredential", "signPresentation", "presentation", "credentials", "nonce", "incrementSemverPatch", "major", "minor", "patch", "split", "patchNum", "Number", "isNaN", "String", "join", "publicKeyToDid", "key"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
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 { 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\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\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"],
|
|
5
|
-
"mappings": ";;;AAOA,SAASA,sBAAyC;AAClD,SAASC,iBAAiB;AAE1B,SAASC,WAAW;;AAYb,IAAMC,uBAAuB,OAAO,EACzCC,QACAC,MACAC,SACAC,QACAC,SACAC,WAAU,MACO;AACjB,QAAMC,UAAUN,OAAOO,OAAOC,OAAOC,SAASC,UAAUC,MAAMC;AAC9Df,YAAUS,SAAS,2BAAA;;;;;;;;;AACnB,QAAMO,aAAa,IAAIjB,eAAeU,OAAAA;AACtC,QAAMQ,eAAeC,mBAAmBf,MAAAA;AACxCa,aAAWG,YAAYF,YAAAA;AACvB,QAAMG,WAAW,MAAMJ,WAAWK,eAAe;IAAEd;IAASC;EAAW,GAAG;IAAEJ;IAAMC;IAASiB,QAAQhB;EAAO,CAAA;AAE1GL,MAAI,YAAY;IACdO;IACAF;IACAF;IACAmB,aAAaN,aAAaM;IAC1BH;EACF,GAAA;;;;;;AAEA,SAAOA;AACT;AAEA,IAAMF,qBAAqB,CAACf,WAAAA;AAC1B,QAAMqB,WAAWrB,OAAOsB,KAAKD,SAASE,IAAG;AACzC,QAAMC,SAASxB,OAAOsB,KAAKE;AAC3B,MAAI,CAACH,YAAY,CAACG,QAAQ;AACxB,UAAM,IAAIC,MAAM,wBAAA;EAClB;AACA,SAAO;IACLL,aAAaC,SAASD,YAAYM,MAAK;IACvCC,SAASH,OAAOI,UAAUF,MAAK;IAC/BG,oBAAoB,OAAO,EAAEC,UAAS,MAAE;AACtC,YAAMC,kBAAkB/B,OAAOU,SAASA,SAASsB;AACjD,YAAMC,iBAAiB,MAAMF,gBAAgBG,qBAAoB;AACjE,aAAOH,gBAAgBI,iBAAiB;QACtCC,cAAc;UAAEC,aAAa;YAACJ;;QAAgB;QAC9CK,OAAOR;MACT,CAAA;IACF;EACF;AACF;AAEO,IAAMS,uBAAuB,CAACrC,YAAAA;AACnC,QAAM,CAACsC,OAAOC,OAAOC,KAAAA,IAASxC,QAAQyC,MAAM,GAAA;AAC5C,QAAMC,WAAWC,OAAOH,KAAAA;AACxB7C,YAAU,CAACgD,OAAOC,MAAMF,QAAAA,GAAW,uCAAA;;;;;;;;;AACnC,SAAO;IAACJ;IAAOC;IAAOM,OAAOH,WAAW,CAAA;IAAII,KAAK,GAAA;AACnD;AAEO,IAAMC,iBAAiB,CAACC,QAAAA;AAC7B,SAAO,WAAWA,IAAIxB,MAAK,CAAA;AAC7B;",
|
|
6
|
-
"names": ["EdgeHttpClient", "invariant", "log", "uploadWorkerFunction", "client", "name", "version", "source", "spaceId", "functionId", "edgeUrl", "config", "values", "runtime", "services", "edge", "url", "edgeClient", "edgeIdentity", "createEdgeIdentity", "setIdentity", "response", "uploadFunction", "script", "identityKey", "identity", "halo", "get", "device", "Error", "toHex", "peerKey", "deviceKey", "presentCredentials", "challenge", "identityService", "IdentityService", "authCredential", "createAuthCredential", "signPresentation", "presentation", "credentials", "nonce", "incrementSemverPatch", "major", "minor", "patch", "split", "patchNum", "Number", "isNaN", "String", "join", "publicKeyToDid", "key"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/types/schema.ts", "../../../src/types/types.ts", "../../../src/types/trace.ts", "../../../src/types/url.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { JsonSchemaType, Ref, S, TypedObject } from '@dxos/echo-schema';\nimport { TextType } from '@dxos/schema';\n\n/**\n * Source script.\n */\nexport class ScriptType extends TypedObject({\n typename: 'dxos.org/type/Script',\n version: '0.1.0',\n})({\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 description: S.optional(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 outputSchema: 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, DXN } 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 Email = 'email',\n Queue = 'queue',\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\nconst EmailTriggerSchema = S.Struct({\n type: S.Literal(TriggerKind.Email).annotations(typeLiteralAnnotations),\n}).pipe(S.mutable);\n\nexport type EmailTrigger = S.Schema.Type<typeof EmailTriggerSchema>;\n\nconst QueueTriggerSchema = S.Struct({\n type: S.Literal(TriggerKind.Queue).annotations(typeLiteralAnnotations),\n queue: DXN,\n}).pipe(S.mutable);\n\nexport type QueueTrigger = S.Schema.Type<typeof QueueTriggerSchema>;\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 TimerTriggerSchema,\n WebhookTriggerSchema,\n SubscriptionTriggerSchema,\n EmailTriggerSchema,\n QueueTriggerSchema,\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 // TODO(wittjosiah): This should probably be a Ref?\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", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { EchoObject, Expando, ObjectId, Ref, S } from '@dxos/echo-schema';\n\nimport { FunctionTrigger } from './types';\n\nexport enum InvocationOutcome {\n SUCCESS = 'success',\n FAILURE = 'failure',\n}\n\nexport const TraceEventException = S.Struct({\n timestampMs: S.Number,\n message: S.String,\n name: S.String,\n stack: S.optional(S.String),\n});\n\nexport const InvocationTraceEvent = S.Struct({\n id: ObjectId,\n timestampMs: S.Number,\n outcome: S.Enums(InvocationOutcome),\n input: S.Object,\n durationMs: S.Number,\n /**\n * Queue DXN for function/workflow invocation events.\n */\n invocationTraceQueue: Ref(Expando),\n /**\n * DXN of the invoked function/workflow.\n */\n invocationTarget: Ref(Expando),\n /**\n * Present for automatic invocations.\n */\n trigger: S.optional(Ref(FunctionTrigger)),\n /**\n * Present for outcome FAILURE.\n */\n exception: S.optional(TraceEventException),\n}).pipe(EchoObject('dxos.org/type/InvocationTrace', '0.1.0'));\n\nexport type InvocationTraceEvent = S.Schema.Type<typeof InvocationTraceEvent>;\n\nexport const TraceEventLog = S.Struct({\n timestampMs: S.Number,\n level: S.String,\n message: S.String,\n context: S.optional(S.Object),\n});\n\nexport const TraceEvent = S.Struct({\n id: ObjectId,\n outcome: S.String,\n truncated: S.Boolean,\n /**\n * Time when the event was persisted.\n */\n ingestionTimestampMs: S.Number,\n logs: S.Array(TraceEventLog),\n exceptions: S.Array(TraceEventException),\n}).pipe(EchoObject('dxos.org/type/TraceEvent', '0.1.0'));\n\nexport type TraceEvent = S.Schema.Type<typeof TraceEvent>;\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type ObjectMeta } from '@dxos/echo-schema';\nimport { type SpaceId } from '@dxos/keys';\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\nconst isSecure = (protocol: string) => {\n return protocol === 'https:' || protocol === 'wss:';\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 = isSecure(url.protocol) ? 'https' : 'http';\n return url.toString();\n};\n\nexport type InvocationOptions = {\n spaceId?: SpaceId;\n subjectId?: string;\n};\n"],
|
|
5
|
-
"mappings": ";;;AAIA,SAASA,gBAAgBC,KAAKC,GAAGC,mBAAmB;AACpD,SAASC,gBAAgB;AAKlB,IAAMC,aAAN,cAAyBC,YAAY;EAC1CC,UAAU;EACVC,SAAS;AACX,CAAA,EAAG;EACDC,MAAMC,EAAEC,SAASD,EAAEE,MAAM;EACzBC,aAAaH,EAAEC,SAASD,EAAEE,MAAM;;;EAGhCE,SAASJ,EAAEC,SAASD,EAAEK,OAAO;EAC7BC,QAAQC,IAAIC,QAAAA;AACd,CAAA,EAAA;AAAI;AAMG,IAAMC,eAAN,cAA2Bb,YAAY;EAC5CC,UAAU;EACVC,SAAS;AACX,CAAA,EAAG;;EAEDC,MAAMC,EAAEU;EACRZ,SAASE,EAAEE;EAEXC,aAAaH,EAAEC,SAASD,EAAEE,MAA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,CAAA;EAC/D;AACF;AAEO,IAAMG,mBAAmB,CAACH,aAAqBI,SAAiBC,UAA6B,CAAC,MAAC;AACpG,QAAMC,UAAU,IAAIC,IAAI,cAAcH,OAAAA;AAGtC,QAAMI,cAAcR,YAAYS,QAAQ,OAAO,EAAA;AAC/C,QAAMC,MAAM,IAAIH,IAAI,KAAKC,WAAAA,IAAeF,QAAQK,SAAQ,CAAA;AACxDN,UAAQO,WAAWF,IAAIG,aAAaC,IAAI,WAAWT,QAAQO,OAAO;AAClEP,UAAQU,aAAaL,IAAIG,aAAaC,IAAI,aAAaT,QAAQU,SAAS;AACxEL,MAAInB,WAAWD,SAASoB,IAAInB,QAAQ,IAAI,UAAU;AAClD,SAAOmB,IAAIC,SAAQ;AACrB;",
|
|
6
|
-
"names": ["JsonSchemaType", "Ref", "S", "TypedObject", "TextType", "ScriptType", "TypedObject", "typename", "version", "name", "S", "optional", "String", "description", "changed", "Boolean", "source", "Ref", "TextType", "FunctionType", "NonEmptyString", "inputSchema", "JsonSchemaType", "outputSchema", "binding", "AST", "OptionsAnnotationId", "RawObject", "S", "TypedObject", "DXN", "TriggerKind", "typeLiteralAnnotations", "AST", "TitleAnnotationId", "TimerTriggerSchema", "S", "Struct", "type", "Literal", "annotations", "cron", "String", "ExamplesAnnotationId", "pipe", "mutable", "EmailTriggerSchema", "QueueTriggerSchema", "queue", "DXN", "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", "EchoObject", "Expando", "ObjectId", "Ref", "S", "InvocationOutcome", "TraceEventException", "S", "Struct", "timestampMs", "Number", "message", "String", "name", "stack", "optional", "InvocationTraceEvent", "id", "ObjectId", "outcome", "Enums", "input", "Object", "durationMs", "invocationTraceQueue", "Ref", "Expando", "invocationTarget", "trigger", "FunctionTrigger", "exception", "pipe", "EchoObject", "TraceEventLog", "level", "context", "TraceEvent", "truncated", "Boolean", "ingestionTimestampMs", "logs", "Array", "exceptions", "FUNCTIONS_META_KEY", "FUNCTIONS_PRESET_META_KEY", "isSecure", "protocol", "getUserFunctionUrlInMetadata", "meta", "keys", "find", "key", "source", "id", "setUserFunctionUrlInMetadata", "functionUrl", "Error", "push", "getInvocationUrl", "edgeUrl", "options", "baseUrl", "URL", "relativeUrl", "replace", "url", "toString", "spaceId", "searchParams", "set", "subjectId"]
|
|
7
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|