@dxos/plugin-debug 0.8.3 → 0.8.4-main.1c7ec43d41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/index.mjs +19 -123
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/translations.mjs +81 -0
- package/dist/lib/browser/translations.mjs.map +7 -0
- package/dist/types/src/DebugPlugin.d.ts +4 -1
- package/dist/types/src/DebugPlugin.d.ts.map +1 -1
- package/dist/types/src/DebugPlugin.node.d.ts +5 -0
- package/dist/types/src/DebugPlugin.node.d.ts.map +1 -0
- package/dist/types/src/DebugPlugin.test.d.ts +2 -0
- package/dist/types/src/DebugPlugin.test.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts +4 -2
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +8 -5
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-context.d.ts +4 -2
- package/dist/types/src/capabilities/react-context.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts +7 -2
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/settings.d.ts +5 -2
- package/dist/types/src/capabilities/settings.d.ts.map +1 -1
- package/dist/types/src/components/DebugSettings/DebugSettings.d.ts +11 -0
- package/dist/types/src/components/DebugSettings/DebugSettings.d.ts.map +1 -0
- package/dist/types/src/components/DebugSettings/DebugSettings.stories.d.ts +99 -0
- package/dist/types/src/components/DebugSettings/DebugSettings.stories.d.ts.map +1 -0
- package/dist/types/src/components/DebugSettings/index.d.ts +2 -0
- package/dist/types/src/components/DebugSettings/index.d.ts.map +1 -0
- package/dist/types/src/components/SchemaTable/SchemaTable.d.ts.map +1 -0
- package/dist/types/src/components/SchemaTable/index.d.ts +2 -0
- package/dist/types/src/components/SchemaTable/index.d.ts.map +1 -0
- package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts +6 -4
- package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts.map +1 -1
- package/dist/types/src/components/SpaceGenerator/draw-util.d.ts.map +1 -1
- package/dist/types/src/components/SpaceGenerator/index.d.ts +2 -2
- package/dist/types/src/components/SpaceGenerator/index.d.ts.map +1 -1
- package/dist/types/src/components/SpaceGenerator/presets.d.ts +5 -8
- package/dist/types/src/components/SpaceGenerator/presets.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +4 -9
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/DebugGraph/DebugGraph.d.ts +8 -0
- package/dist/types/src/containers/DebugGraph/DebugGraph.d.ts.map +1 -0
- package/dist/types/src/containers/DebugGraph/index.d.ts +2 -0
- package/dist/types/src/containers/DebugGraph/index.d.ts.map +1 -0
- package/dist/types/src/containers/DebugObjectPanel/DebugObjectPanel.d.ts +6 -0
- package/dist/types/src/containers/DebugObjectPanel/DebugObjectPanel.d.ts.map +1 -0
- package/dist/types/src/containers/DebugObjectPanel/index.d.ts +2 -0
- package/dist/types/src/containers/DebugObjectPanel/index.d.ts.map +1 -0
- package/dist/types/src/containers/DebugSpaceObjectsPanel/DebugSpaceObjectsPanel.d.ts +5 -0
- package/dist/types/src/containers/DebugSpaceObjectsPanel/DebugSpaceObjectsPanel.d.ts.map +1 -0
- package/dist/types/src/containers/DebugSpaceObjectsPanel/index.d.ts +2 -0
- package/dist/types/src/containers/DebugSpaceObjectsPanel/index.d.ts.map +1 -0
- package/dist/types/src/containers/DebugStatus/DebugStatus.d.ts.map +1 -0
- package/dist/types/src/containers/DebugStatus/index.d.ts +2 -0
- package/dist/types/src/containers/DebugStatus/index.d.ts.map +1 -0
- package/dist/types/src/{components → containers/DevtoolsOverviewContainer}/DevtoolsOverviewContainer.d.ts +0 -1
- package/dist/types/src/containers/DevtoolsOverviewContainer/DevtoolsOverviewContainer.d.ts.map +1 -0
- package/dist/types/src/containers/DevtoolsOverviewContainer/index.d.ts +2 -0
- package/dist/types/src/containers/DevtoolsOverviewContainer/index.d.ts.map +1 -0
- package/dist/types/src/containers/SpaceGenerator/SpaceGenerator.d.ts +11 -0
- package/dist/types/src/containers/SpaceGenerator/SpaceGenerator.d.ts.map +1 -0
- package/dist/types/src/containers/SpaceGenerator/index.d.ts +2 -0
- package/dist/types/src/containers/SpaceGenerator/index.d.ts.map +1 -0
- package/dist/types/src/{components → containers/Wireframe}/Wireframe.d.ts +2 -2
- package/dist/types/src/containers/Wireframe/Wireframe.d.ts.map +1 -0
- package/dist/types/src/containers/Wireframe/index.d.ts +2 -0
- package/dist/types/src/containers/Wireframe/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +9 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +3 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -3
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +83 -60
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Settings.d.ts +8 -0
- package/dist/types/src/types/Settings.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +69 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +99 -73
- package/src/DebugPlugin.node.ts +18 -0
- package/src/DebugPlugin.test.ts +29 -0
- package/src/DebugPlugin.tsx +30 -37
- package/src/capabilities/app-graph-builder.ts +361 -413
- package/src/capabilities/index.ts +5 -5
- package/src/capabilities/react-context.tsx +16 -7
- package/src/capabilities/react-surface.tsx +381 -339
- package/src/capabilities/settings.ts +24 -12
- package/src/components/DebugSettings/DebugSettings.stories.tsx +36 -0
- package/src/components/DebugSettings/DebugSettings.tsx +262 -0
- package/src/components/DebugSettings/index.ts +5 -0
- package/src/components/SchemaTable/index.ts +5 -0
- package/src/components/SpaceGenerator/ObjectGenerator.tsx +44 -46
- package/src/components/SpaceGenerator/draw-util.ts +13 -13
- package/src/components/SpaceGenerator/index.ts +2 -3
- package/src/components/SpaceGenerator/presets.ts +527 -263
- package/src/components/index.ts +4 -8
- package/src/containers/DebugGraph/DebugGraph.tsx +14 -0
- package/src/containers/DebugGraph/index.ts +5 -0
- package/src/containers/DebugObjectPanel/DebugObjectPanel.tsx +76 -0
- package/src/containers/DebugObjectPanel/index.ts +5 -0
- package/src/containers/DebugSpaceObjectsPanel/DebugSpaceObjectsPanel.tsx +47 -0
- package/src/containers/DebugSpaceObjectsPanel/index.ts +5 -0
- package/src/{components → containers/DebugStatus}/DebugStatus.tsx +43 -21
- package/src/containers/DebugStatus/index.ts +5 -0
- package/src/containers/DevtoolsOverviewContainer/DevtoolsOverviewContainer.tsx +25 -0
- package/src/containers/DevtoolsOverviewContainer/index.ts +5 -0
- package/src/containers/SpaceGenerator/SpaceGenerator.tsx +126 -0
- package/src/containers/SpaceGenerator/index.ts +5 -0
- package/src/{components → containers/Wireframe}/Wireframe.tsx +8 -12
- package/src/containers/Wireframe/index.ts +5 -0
- package/src/containers/index.ts +13 -0
- package/src/index.ts +7 -1
- package/src/meta.ts +8 -7
- package/src/translations.ts +80 -59
- package/src/types/Settings.ts +16 -0
- package/src/{types.ts → types/index.ts} +20 -11
- package/dist/lib/browser/DebugApp-WSEJPCKY.mjs +0 -225
- package/dist/lib/browser/DebugApp-WSEJPCKY.mjs.map +0 -7
- package/dist/lib/browser/DevtoolsOverviewContainer-IIIWO77Q.mjs +0 -25
- package/dist/lib/browser/DevtoolsOverviewContainer-IIIWO77Q.mjs.map +0 -7
- package/dist/lib/browser/SpaceGenerator-VB6IB2LL.mjs +0 -1238
- package/dist/lib/browser/SpaceGenerator-VB6IB2LL.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-6HHJMKVU.mjs +0 -597
- package/dist/lib/browser/app-graph-builder-6HHJMKVU.mjs.map +0 -7
- package/dist/lib/browser/chunk-47JOZTT2.mjs +0 -18
- package/dist/lib/browser/chunk-47JOZTT2.mjs.map +0 -7
- package/dist/lib/browser/chunk-KS3YBEL7.mjs +0 -68
- package/dist/lib/browser/chunk-KS3YBEL7.mjs.map +0 -7
- package/dist/lib/browser/react-context-ZQRD2WG2.mjs +0 -16
- package/dist/lib/browser/react-context-ZQRD2WG2.mjs.map +0 -7
- package/dist/lib/browser/react-surface-UI6OK73H.mjs +0 -768
- package/dist/lib/browser/react-surface-UI6OK73H.mjs.map +0 -7
- package/dist/lib/browser/settings-SXQWSIM4.mjs +0 -22
- package/dist/lib/browser/settings-SXQWSIM4.mjs.map +0 -7
- package/dist/types/src/components/Container.d.ts +0 -5
- package/dist/types/src/components/Container.d.ts.map +0 -1
- package/dist/types/src/components/DebugApp/DebugApp.d.ts +0 -6
- package/dist/types/src/components/DebugApp/DebugApp.d.ts.map +0 -1
- package/dist/types/src/components/DebugApp/Tree.d.ts +0 -18
- package/dist/types/src/components/DebugApp/Tree.d.ts.map +0 -1
- package/dist/types/src/components/DebugApp/index.d.ts +0 -3
- package/dist/types/src/components/DebugApp/index.d.ts.map +0 -1
- package/dist/types/src/components/DebugObjectPanel.d.ts +0 -7
- package/dist/types/src/components/DebugObjectPanel.d.ts.map +0 -1
- package/dist/types/src/components/DebugSettings.d.ts +0 -6
- package/dist/types/src/components/DebugSettings.d.ts.map +0 -1
- package/dist/types/src/components/DebugStatus.d.ts.map +0 -1
- package/dist/types/src/components/DevtoolsOverviewContainer.d.ts.map +0 -1
- package/dist/types/src/components/SpaceGenerator/SchemaTable.d.ts.map +0 -1
- package/dist/types/src/components/SpaceGenerator/SpaceGenerator.d.ts +0 -9
- package/dist/types/src/components/SpaceGenerator/SpaceGenerator.d.ts.map +0 -1
- package/dist/types/src/components/SpaceGenerator/SpaceGenerator.stories.d.ts +0 -6
- package/dist/types/src/components/SpaceGenerator/SpaceGenerator.stories.d.ts.map +0 -1
- package/dist/types/src/components/Wireframe.d.ts.map +0 -1
- package/dist/types/src/types.d.ts +0 -63
- package/dist/types/src/types.d.ts.map +0 -1
- package/src/components/Container.tsx +0 -15
- package/src/components/DebugApp/DebugApp.tsx +0 -77
- package/src/components/DebugApp/Tree.tsx +0 -103
- package/src/components/DebugApp/index.ts +0 -7
- package/src/components/DebugObjectPanel.tsx +0 -35
- package/src/components/DebugSettings.tsx +0 -151
- package/src/components/DevtoolsOverviewContainer.tsx +0 -20
- package/src/components/SpaceGenerator/SpaceGenerator.stories.tsx +0 -52
- package/src/components/SpaceGenerator/SpaceGenerator.tsx +0 -179
- /package/dist/types/src/components/{SpaceGenerator → SchemaTable}/SchemaTable.d.ts +0 -0
- /package/dist/types/src/{components → containers/DebugStatus}/DebugStatus.d.ts +0 -0
- /package/src/components/{SpaceGenerator → SchemaTable}/SchemaTable.tsx +0 -0
|
@@ -2,68 +2,245 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
|
+
import { AgentPrompt, WebSearchBlueprint } from '@dxos/assistant-toolkit';
|
|
8
|
+
import { Routine, Trigger, Operation } from '@dxos/compute';
|
|
7
9
|
import { type ComputeGraphModel, NODE_INPUT } from '@dxos/conductor';
|
|
8
|
-
import { DXN, Key, Obj, Ref,
|
|
9
|
-
import { FunctionTrigger, TriggerKind, EmailTriggerOutput, type TriggerType } from '@dxos/functions';
|
|
10
|
+
import { DXN, Feed, Filter, JsonSchema, Key, Obj, Query, type QueryAST, Ref, Tag } from '@dxos/echo';
|
|
10
11
|
import { invariant } from '@dxos/invariant';
|
|
11
|
-
import {
|
|
12
|
+
import { InboxOperation } from '@dxos/plugin-inbox/operations';
|
|
13
|
+
import { Mailbox } from '@dxos/plugin-inbox/types';
|
|
14
|
+
import { Markdown } from '@dxos/plugin-markdown/types';
|
|
15
|
+
import { type Space } from '@dxos/react-client/echo';
|
|
12
16
|
import {
|
|
13
17
|
type ComputeShape,
|
|
14
18
|
createAppend,
|
|
15
19
|
createChat,
|
|
16
20
|
createComputeGraph,
|
|
17
21
|
createConstant,
|
|
22
|
+
createFeed,
|
|
18
23
|
createFunction,
|
|
19
24
|
createGpt,
|
|
20
|
-
createQueue,
|
|
21
|
-
createSurface,
|
|
22
25
|
createRandom,
|
|
26
|
+
createSurface,
|
|
23
27
|
createTemplate,
|
|
24
28
|
createText,
|
|
25
29
|
createTrigger,
|
|
26
30
|
} from '@dxos/react-ui-canvas-compute';
|
|
27
|
-
import {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
pointsToRect,
|
|
32
|
-
rectToPoints,
|
|
33
|
-
} from '@dxos/react-ui-canvas-editor';
|
|
34
|
-
import { TableType } from '@dxos/react-ui-table';
|
|
35
|
-
import { range } from '@dxos/util';
|
|
31
|
+
import { CanvasBoard, CanvasGraphModel, pointMultiply, pointsToRect, rectToPoints } from '@dxos/react-ui-canvas-editor';
|
|
32
|
+
import { ViewModel } from '@dxos/schema';
|
|
33
|
+
import { Message, Organization, Person, Pipeline } from '@dxos/types';
|
|
34
|
+
import { range, trim } from '@dxos/util';
|
|
36
35
|
|
|
37
36
|
import { type ObjectGenerator } from './ObjectGenerator';
|
|
38
37
|
|
|
39
38
|
export enum PresetName {
|
|
40
|
-
|
|
39
|
+
DXOS_TEAM = 'dxos-team',
|
|
40
|
+
ORG_RESEARCH_PROJECT = 'org-research-project',
|
|
41
|
+
// EMAIL_TABLE = 'email-table',
|
|
41
42
|
GPT_QUEUE = 'webhook-gpt-queue',
|
|
42
43
|
CHAT_GPT = 'chat-gpt-text',
|
|
43
|
-
EMAIL_WITH_SUMMARY = 'email-gptSummary-table',
|
|
44
|
+
// EMAIL_WITH_SUMMARY = 'email-gptSummary-table',
|
|
44
45
|
OBJECT_CHANGE_QUEUE = 'objectChange-queue',
|
|
45
|
-
FOREX_FUNCTION_CALL = 'forex-function-call',
|
|
46
46
|
TIMER_TICK_QUEUE = 'timerTick-queue',
|
|
47
|
+
FOREX_FUNCTION_CALL = 'forex-function-call',
|
|
47
48
|
DISCORD_MESSAGES = 'discord-messages',
|
|
48
|
-
KANBAN_QUEUE = 'kanban-queue',
|
|
49
|
+
// KANBAN_QUEUE = 'kanban-queue',
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
export const generator = () => ({
|
|
52
|
-
schemas: [
|
|
53
|
+
schemas: [CanvasBoard.CanvasBoard, Trigger.Trigger] as any[],
|
|
53
54
|
types: Object.values(PresetName).map((name) => ({ typename: name })),
|
|
54
55
|
items: [
|
|
56
|
+
[
|
|
57
|
+
PresetName.DXOS_TEAM,
|
|
58
|
+
async (space, n, cb) => {
|
|
59
|
+
const objects = range(n, () => {
|
|
60
|
+
const org = space.db.add(
|
|
61
|
+
Obj.make(Organization.Organization, {
|
|
62
|
+
name: 'DXOS',
|
|
63
|
+
website: 'https://dxos.org',
|
|
64
|
+
}),
|
|
65
|
+
);
|
|
66
|
+
const doc = space.db.add(
|
|
67
|
+
Markdown.make({
|
|
68
|
+
name: 'DXOS Research',
|
|
69
|
+
content: 'DXOS builds Composer, an open-source AI-powered malleable application.',
|
|
70
|
+
}),
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
const tag = space.db.add(Tag.make({ label: 'Investor' }));
|
|
74
|
+
const tagDxn = Obj.getDXN(tag).toString();
|
|
75
|
+
Obj.update(doc, (doc) => {
|
|
76
|
+
Obj.getMeta(doc).tags = [tagDxn];
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// space.db.add(
|
|
80
|
+
// Relation.make(HasSubject, {
|
|
81
|
+
// [Relation.Source]: doc,
|
|
82
|
+
// [Relation.Target]: org,
|
|
83
|
+
// completedAt: new Date().toISOString(),
|
|
84
|
+
// }),
|
|
85
|
+
// );
|
|
86
|
+
|
|
87
|
+
space.db.add(
|
|
88
|
+
Obj.make(Person.Person, { [Obj.Meta]: { tags: [tagDxn] }, fullName: 'Rich', organization: Ref.make(org) }),
|
|
89
|
+
);
|
|
90
|
+
space.db.add(
|
|
91
|
+
Obj.make(Person.Person, {
|
|
92
|
+
fullName: 'Josiah',
|
|
93
|
+
organization: Ref.make(org),
|
|
94
|
+
}),
|
|
95
|
+
);
|
|
96
|
+
space.db.add(
|
|
97
|
+
Obj.make(Person.Person, {
|
|
98
|
+
fullName: 'Dima',
|
|
99
|
+
organization: Ref.make(org),
|
|
100
|
+
}),
|
|
101
|
+
);
|
|
102
|
+
space.db.add(
|
|
103
|
+
Obj.make(Person.Person, {
|
|
104
|
+
fullName: 'Mykola',
|
|
105
|
+
organization: Ref.make(org),
|
|
106
|
+
}),
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
return doc;
|
|
110
|
+
});
|
|
111
|
+
cb?.(objects);
|
|
112
|
+
return objects;
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
[
|
|
116
|
+
PresetName.ORG_RESEARCH_PROJECT,
|
|
117
|
+
async (space, n, cb) => {
|
|
118
|
+
const mailboxes = await space.db.query(Filter.type(Mailbox.Mailbox)).run();
|
|
119
|
+
const mailbox = mailboxes[0];
|
|
120
|
+
invariant(mailbox, 'Mailbox not found');
|
|
121
|
+
const mailboxFeed = await mailbox.feed?.tryLoad();
|
|
122
|
+
invariant(mailboxFeed, 'Mailbox missing feed reference');
|
|
123
|
+
const queueDxn = Feed.getQueueDxn(mailboxFeed)?.toString();
|
|
124
|
+
invariant(queueDxn, 'Mailbox feed missing queue DXN key');
|
|
125
|
+
const tag = await space.db.query(Filter.type(Tag.Tag, { label: 'Investor' })).first();
|
|
126
|
+
const tagDxn = Obj.getDXN(tag).toString();
|
|
127
|
+
|
|
128
|
+
const objects = range(n, () => {
|
|
129
|
+
const contactsQuery = Query.select(Filter.type(Person.Person)).select(Filter.tag(tagDxn));
|
|
130
|
+
const organizationsQuery = Query.select(Filter.type(Organization.Organization)).select(Filter.tag(tagDxn));
|
|
131
|
+
const notesQuery = Query.select(Filter.type(Markdown.Document)).select(Filter.tag(tagDxn));
|
|
132
|
+
|
|
133
|
+
space.db.add(
|
|
134
|
+
Trigger.make({
|
|
135
|
+
enabled: true,
|
|
136
|
+
spec: Trigger.specTimer('* * * * *'), // Every minute.
|
|
137
|
+
function: Ref.make(Operation.serialize(InboxOperation.GoogleMailSync)),
|
|
138
|
+
input: {
|
|
139
|
+
mailbox: Ref.make(mailbox),
|
|
140
|
+
},
|
|
141
|
+
}),
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
const researchPrompt = space.db.add(
|
|
145
|
+
Routine.make({
|
|
146
|
+
name: 'Research',
|
|
147
|
+
description: 'Research organization',
|
|
148
|
+
input: Schema.Struct({
|
|
149
|
+
org: Schema.Any,
|
|
150
|
+
}),
|
|
151
|
+
output: Schema.Any,
|
|
152
|
+
|
|
153
|
+
// TODO(dmaretskyi): This mocks research (returns pre-baked result), the actual research might take compute minutes.
|
|
154
|
+
// Remove the mock prompt to do the actual research.
|
|
155
|
+
instructions: trim`
|
|
156
|
+
Research the organization provided as input.
|
|
157
|
+
Create a research note for it at the end.
|
|
158
|
+
NOTE: Do mocked reseach (set mockSearch to true).
|
|
159
|
+
`,
|
|
160
|
+
blueprints: [Ref.make(WebSearchBlueprint.make())],
|
|
161
|
+
}),
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
space.db.add(
|
|
165
|
+
Trigger.make({
|
|
166
|
+
enabled: true,
|
|
167
|
+
spec: Trigger.specSubscription(organizationsQuery),
|
|
168
|
+
function: Ref.make(Operation.serialize(AgentPrompt)),
|
|
169
|
+
input: {
|
|
170
|
+
prompt: Ref.make(researchPrompt),
|
|
171
|
+
input: '{{event.subject}}',
|
|
172
|
+
},
|
|
173
|
+
}),
|
|
174
|
+
);
|
|
175
|
+
|
|
176
|
+
const mailboxView = ViewModel.make({
|
|
177
|
+
query: Query.select(
|
|
178
|
+
Filter.type(Message.Message, {
|
|
179
|
+
properties: { labels: Filter.contains('investor') },
|
|
180
|
+
}),
|
|
181
|
+
).from({
|
|
182
|
+
queues: [queueDxn],
|
|
183
|
+
}),
|
|
184
|
+
jsonSchema: JsonSchema.toJsonSchema(Message.Message),
|
|
185
|
+
});
|
|
186
|
+
const contactsView = ViewModel.make({
|
|
187
|
+
query: contactsQuery,
|
|
188
|
+
jsonSchema: JsonSchema.toJsonSchema(Person.Person),
|
|
189
|
+
});
|
|
190
|
+
const organizationsView = ViewModel.make({
|
|
191
|
+
query: organizationsQuery,
|
|
192
|
+
jsonSchema: JsonSchema.toJsonSchema(Organization.Organization),
|
|
193
|
+
});
|
|
194
|
+
const notesView = ViewModel.make({
|
|
195
|
+
query: notesQuery,
|
|
196
|
+
jsonSchema: JsonSchema.toJsonSchema(Markdown.Document),
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
return space.db.add(
|
|
200
|
+
Pipeline.make({
|
|
201
|
+
name: 'Investor Research',
|
|
202
|
+
columns: [
|
|
203
|
+
{
|
|
204
|
+
name: 'Mailbox',
|
|
205
|
+
view: Ref.make(mailboxView),
|
|
206
|
+
order: [],
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
name: 'Contacts',
|
|
210
|
+
view: Ref.make(contactsView),
|
|
211
|
+
order: [],
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
name: 'Organizations',
|
|
215
|
+
view: Ref.make(organizationsView),
|
|
216
|
+
order: [],
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
name: 'Notes',
|
|
220
|
+
view: Ref.make(notesView),
|
|
221
|
+
order: [],
|
|
222
|
+
},
|
|
223
|
+
],
|
|
224
|
+
}),
|
|
225
|
+
);
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
cb?.(objects.flat());
|
|
229
|
+
return objects.flat();
|
|
230
|
+
},
|
|
231
|
+
],
|
|
55
232
|
[
|
|
56
233
|
PresetName.GPT_QUEUE,
|
|
57
234
|
async (space, n, cb) => {
|
|
58
235
|
const objects = range(n, () => {
|
|
59
236
|
const canvasModel = CanvasGraphModel.create<ComputeShape>();
|
|
60
237
|
|
|
61
|
-
let functionTrigger:
|
|
238
|
+
let functionTrigger: Trigger.Trigger | undefined;
|
|
62
239
|
canvasModel.builder.call((builder) => {
|
|
63
240
|
const gpt = canvasModel.createNode(createGpt(position({ x: 0, y: -14 })));
|
|
64
241
|
const triggerShape = createTrigger({
|
|
65
242
|
spaceId: space.id,
|
|
66
|
-
triggerKind:
|
|
243
|
+
triggerKind: 'webhook',
|
|
67
244
|
...position({ x: -18, y: -2 }),
|
|
68
245
|
});
|
|
69
246
|
const trigger = canvasModel.createNode(triggerShape);
|
|
@@ -72,10 +249,24 @@ export const generator = () => ({
|
|
|
72
249
|
const append = canvasModel.createNode(createAppend(position({ x: 10, y: 6 })));
|
|
73
250
|
|
|
74
251
|
builder
|
|
75
|
-
.createEdge({
|
|
252
|
+
.createEdge({
|
|
253
|
+
source: trigger.id,
|
|
254
|
+
target: gpt.id,
|
|
255
|
+
input: 'prompt',
|
|
256
|
+
output: 'bodyText',
|
|
257
|
+
})
|
|
76
258
|
.createEdge({ source: gpt.id, target: text.id, output: 'text' })
|
|
77
|
-
.createEdge({
|
|
78
|
-
|
|
259
|
+
.createEdge({
|
|
260
|
+
source: queueId.id,
|
|
261
|
+
target: append.id,
|
|
262
|
+
input: 'id',
|
|
263
|
+
})
|
|
264
|
+
.createEdge({
|
|
265
|
+
source: gpt.id,
|
|
266
|
+
target: append.id,
|
|
267
|
+
output: 'messages',
|
|
268
|
+
input: 'items',
|
|
269
|
+
});
|
|
79
270
|
|
|
80
271
|
functionTrigger = triggerShape.functionTrigger!.target!;
|
|
81
272
|
});
|
|
@@ -97,8 +288,11 @@ export const generator = () => ({
|
|
|
97
288
|
const objects = range(n, () => {
|
|
98
289
|
const { canvasModel, computeModel } = createQueueSinkPreset(
|
|
99
290
|
space,
|
|
100
|
-
|
|
101
|
-
(triggerSpec) =>
|
|
291
|
+
'subscription',
|
|
292
|
+
(triggerSpec) =>
|
|
293
|
+
(triggerSpec.query = {
|
|
294
|
+
ast: Query.select(Filter.typename('org.dxos.type.chess')).ast as Obj.Mutable<QueryAST.Query>,
|
|
295
|
+
}),
|
|
102
296
|
'type',
|
|
103
297
|
);
|
|
104
298
|
return addToSpace(PresetName.OBJECT_CHANGE_QUEUE, space, canvasModel, computeModel);
|
|
@@ -114,7 +308,7 @@ export const generator = () => ({
|
|
|
114
308
|
const objects = range(n, () => {
|
|
115
309
|
const { canvasModel, computeModel } = createQueueSinkPreset(
|
|
116
310
|
space,
|
|
117
|
-
|
|
311
|
+
'timer',
|
|
118
312
|
(triggerSpec) => (triggerSpec.cron = '*/5 * * * * *'),
|
|
119
313
|
'result',
|
|
120
314
|
);
|
|
@@ -125,72 +319,73 @@ export const generator = () => ({
|
|
|
125
319
|
},
|
|
126
320
|
],
|
|
127
321
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
322
|
+
// TODO(wittjosiah): Remove?
|
|
323
|
+
// [
|
|
324
|
+
// PresetName.EMAIL_TABLE,
|
|
325
|
+
// async (space, n, cb) => {
|
|
326
|
+
// const objects = range(n, () => {
|
|
327
|
+
// const canvasModel = CanvasGraphModel.create<ComputeShape>();
|
|
328
|
+
|
|
329
|
+
// const results = space.db.query(Filter.type(TableType)).runSync();
|
|
330
|
+
// const emailTable = results.find((r) => r.object?.view?.target?.query?.typename?.endsWith('Email'));
|
|
331
|
+
// invariant(emailTable, 'Email table not found.');
|
|
332
|
+
|
|
333
|
+
// const template = canvasModel.createNode(
|
|
334
|
+
// createTemplate({
|
|
335
|
+
// valueType: 'object',
|
|
336
|
+
// ...rawPosition({ centerX: -80, centerY: -64, width: 320, height: 320 }),
|
|
337
|
+
// }),
|
|
338
|
+
// );
|
|
339
|
+
// const templateContent = ['{'];
|
|
340
|
+
|
|
341
|
+
// let functionTrigger: FunctionTrigger | undefined;
|
|
342
|
+
// canvasModel.builder.call((builder) => {
|
|
343
|
+
// const triggerShape = createTrigger({
|
|
344
|
+
// spaceId: space.id,
|
|
345
|
+
// triggerKind: 'email',
|
|
346
|
+
// ...position({ x: -18, y: -2 }),
|
|
347
|
+
// });
|
|
348
|
+
// const trigger = canvasModel.createNode(triggerShape);
|
|
349
|
+
|
|
350
|
+
// const tableId = canvasModel.createNode(
|
|
351
|
+
// createConstant({
|
|
352
|
+
// value: DXN.fromLocalObjectId(emailTable.id).toString(),
|
|
353
|
+
// ...position({ x: -18, y: 5, width: 8, height: 6 }),
|
|
354
|
+
// }),
|
|
355
|
+
// );
|
|
356
|
+
|
|
357
|
+
// const appendToTable = canvasModel.createNode(createAppend(position({ x: 10, y: 6 })));
|
|
358
|
+
|
|
359
|
+
// const properties = SchemaAST.getPropertySignatures(EmailTriggerOutput.ast);
|
|
360
|
+
// for (let i = 0; i < properties.length; i++) {
|
|
361
|
+
// const propName = properties[i].name.toString();
|
|
362
|
+
// builder.createEdge({ source: trigger.id, target: template.id, input: propName, output: propName });
|
|
363
|
+
// templateContent.push(` "${propName}": "{{${propName}}}"` + (i === properties.length - 1 ? '' : ','));
|
|
364
|
+
// }
|
|
365
|
+
// templateContent.push('}');
|
|
366
|
+
|
|
367
|
+
// builder
|
|
368
|
+
// .createEdge({ source: tableId.id, target: appendToTable.id, input: 'id' })
|
|
369
|
+
// .createEdge({ source: template.id, target: appendToTable.id, input: 'items' });
|
|
370
|
+
|
|
371
|
+
// functionTrigger = triggerShape.functionTrigger!.target!;
|
|
372
|
+
// });
|
|
373
|
+
|
|
374
|
+
// const computeModel = createComputeGraph(canvasModel);
|
|
375
|
+
|
|
376
|
+
// const templateComputeNode = computeModel.nodes.find((n) => n.id === template.node);
|
|
377
|
+
// invariant(templateComputeNode, 'Template compute node was not created.');
|
|
378
|
+
// templateComputeNode.value = templateContent.join('\n');
|
|
379
|
+
// templateComputeNode.inputSchema = JsonSchema.toJsonSchema(EmailTriggerOutput);
|
|
380
|
+
|
|
381
|
+
// attachTrigger(functionTrigger, computeModel);
|
|
382
|
+
|
|
383
|
+
// return addToSpace(PresetName.EMAIL_TABLE, space, canvasModel, computeModel);
|
|
384
|
+
// });
|
|
385
|
+
// cb?.(objects);
|
|
386
|
+
// return objects;
|
|
387
|
+
// },
|
|
388
|
+
// ],
|
|
194
389
|
|
|
195
390
|
[
|
|
196
391
|
PresetName.CHAT_GPT,
|
|
@@ -209,8 +404,17 @@ export const generator = () => ({
|
|
|
209
404
|
builder
|
|
210
405
|
.createEdge({ source: chat.id, target: gpt.id, input: 'prompt' })
|
|
211
406
|
.createEdge({ source: gpt.id, target: text.id, output: 'text' })
|
|
212
|
-
.createEdge({
|
|
213
|
-
|
|
407
|
+
.createEdge({
|
|
408
|
+
source: queueId.id,
|
|
409
|
+
target: append.id,
|
|
410
|
+
input: 'id',
|
|
411
|
+
})
|
|
412
|
+
.createEdge({
|
|
413
|
+
source: gpt.id,
|
|
414
|
+
target: append.id,
|
|
415
|
+
output: 'messages',
|
|
416
|
+
input: 'items',
|
|
417
|
+
});
|
|
214
418
|
});
|
|
215
419
|
|
|
216
420
|
const computeModel = createComputeGraph(canvasModel);
|
|
@@ -222,99 +426,100 @@ export const generator = () => ({
|
|
|
222
426
|
},
|
|
223
427
|
],
|
|
224
428
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
429
|
+
// TODO(wittjosiah): Remove?
|
|
430
|
+
// [
|
|
431
|
+
// PresetName.EMAIL_WITH_SUMMARY,
|
|
432
|
+
// async (space, n, cb) => {
|
|
433
|
+
// const objects = range(n, () => {
|
|
434
|
+
// const canvasModel = CanvasGraphModel.create<ComputeShape>();
|
|
435
|
+
|
|
436
|
+
// const results = space.db.query(Filter.type(TableType)).runSync();
|
|
437
|
+
// const emailTable = results.find((r) => r.object?.view?.target?.query?.typename?.endsWith('Email'));
|
|
438
|
+
// invariant(emailTable, 'Email table not found.');
|
|
439
|
+
|
|
440
|
+
// const template = canvasModel.createNode(
|
|
441
|
+
// createTemplate({
|
|
442
|
+
// valueType: 'object',
|
|
443
|
+
// ...rawPosition({ centerX: 192, centerY: -176, width: 320, height: 320 }),
|
|
444
|
+
// }),
|
|
445
|
+
// );
|
|
446
|
+
// const templateContent = ['{'];
|
|
447
|
+
|
|
448
|
+
// let functionTrigger: FunctionTrigger | undefined;
|
|
449
|
+
// canvasModel.builder.call((builder) => {
|
|
450
|
+
// const gpt = canvasModel.createNode(
|
|
451
|
+
// createGpt(rawPosition({ centerX: -400, centerY: -112, width: 256, height: 202 })),
|
|
452
|
+
// );
|
|
453
|
+
// const systemPrompt = canvasModel.createNode(
|
|
454
|
+
// createConstant({
|
|
455
|
+
// value: "use one word to describe content category. don't write anything else",
|
|
456
|
+
// ...rawPosition({ centerX: -800, centerY: -160, width: 192, height: 128 }),
|
|
457
|
+
// }),
|
|
458
|
+
// );
|
|
459
|
+
// const triggerShape = createTrigger({
|
|
460
|
+
// spaceId: space.id,
|
|
461
|
+
// triggerKind: 'email',
|
|
462
|
+
// ...rawPosition({ centerX: -736, centerY: -384, width: 182, height: 192 }),
|
|
463
|
+
// });
|
|
464
|
+
// const trigger = canvasModel.createNode(triggerShape);
|
|
465
|
+
|
|
466
|
+
// const { queueId } = setupQueue(space, canvasModel, {
|
|
467
|
+
// idPosition: { centerX: -720, centerY: 224, width: 192, height: 256 },
|
|
468
|
+
// queuePosition: { centerX: -144, centerY: 416, width: 320, height: 448 },
|
|
469
|
+
// });
|
|
470
|
+
// const appendToQueue = canvasModel.createNode(
|
|
471
|
+
// createAppend(rawPosition({ centerX: -80, centerY: 96, width: 122, height: 128 })),
|
|
472
|
+
// );
|
|
473
|
+
|
|
474
|
+
// const tableId = canvasModel.createNode(
|
|
475
|
+
// createConstant({
|
|
476
|
+
// value: DXN.fromLocalObjectId(emailTable.id).toString(),
|
|
477
|
+
// ...rawPosition({ centerX: -112, centerY: -544, width: 192, height: 256 }),
|
|
478
|
+
// }),
|
|
479
|
+
// );
|
|
480
|
+
|
|
481
|
+
// const appendToTable = canvasModel.createNode(
|
|
482
|
+
// createAppend(rawPosition({ centerX: 560, centerY: -416, width: 128, height: 122 })),
|
|
483
|
+
// );
|
|
484
|
+
|
|
485
|
+
// templateContent.push(' "category": "{{text}}",');
|
|
486
|
+
// builder.createEdge({ source: gpt.id, target: template.id, input: 'text', output: 'text' });
|
|
487
|
+
|
|
488
|
+
// const properties = SchemaAST.getPropertySignatures(EmailTriggerOutput.ast);
|
|
489
|
+
// for (let i = 0; i < properties.length; i++) {
|
|
490
|
+
// const propName = properties[i].name.toString();
|
|
491
|
+
// builder.createEdge({ source: trigger.id, target: template.id, input: propName, output: propName });
|
|
492
|
+
// templateContent.push(` "${propName}": "{{${propName}}}"` + (i === properties.length - 1 ? '' : ','));
|
|
493
|
+
// }
|
|
494
|
+
// templateContent.push('}');
|
|
495
|
+
|
|
496
|
+
// builder
|
|
497
|
+
// .createEdge({ source: tableId.id, target: appendToTable.id, input: 'id' })
|
|
498
|
+
// .createEdge({ source: queueId.id, target: appendToQueue.id, input: 'id' })
|
|
499
|
+
// .createEdge({ source: gpt.id, target: appendToQueue.id, output: 'messages', input: 'items' })
|
|
500
|
+
// .createEdge({ source: systemPrompt.id, target: gpt.id, input: 'systemPrompt' })
|
|
501
|
+
// .createEdge({ source: trigger.id, target: gpt.id, input: 'prompt', output: 'body' })
|
|
502
|
+
// .createEdge({ source: template.id, target: appendToTable.id, input: 'items' });
|
|
503
|
+
|
|
504
|
+
// functionTrigger = triggerShape.functionTrigger!.target!;
|
|
505
|
+
// });
|
|
506
|
+
|
|
507
|
+
// const computeModel = createComputeGraph(canvasModel);
|
|
508
|
+
|
|
509
|
+
// const templateComputeNode = computeModel.nodes.find((n) => n.id === template.node);
|
|
510
|
+
// invariant(templateComputeNode, 'Template compute node was not created.');
|
|
511
|
+
// templateComputeNode.value = templateContent.join('\n');
|
|
512
|
+
// const extendedSchema = Schema.extend(EmailTriggerOutput, Schema.Struct({ text: Schema.String }));
|
|
513
|
+
// templateComputeNode.inputSchema = JsonSchema.toJsonSchema(extendedSchema);
|
|
514
|
+
|
|
515
|
+
// attachTrigger(functionTrigger, computeModel);
|
|
516
|
+
|
|
517
|
+
// return addToSpace(PresetName.EMAIL_WITH_SUMMARY, space, canvasModel, computeModel);
|
|
518
|
+
// });
|
|
519
|
+
// cb?.(objects);
|
|
520
|
+
// return objects;
|
|
521
|
+
// },
|
|
522
|
+
// ],
|
|
318
523
|
|
|
319
524
|
[
|
|
320
525
|
PresetName.FOREX_FUNCTION_CALL,
|
|
@@ -333,9 +538,21 @@ export const generator = () => ({
|
|
|
333
538
|
const view = canvasModel.createNode(createSurface(position({ x: 12, y: 0 })));
|
|
334
539
|
|
|
335
540
|
builder
|
|
336
|
-
.createEdge({
|
|
337
|
-
|
|
338
|
-
|
|
541
|
+
.createEdge({
|
|
542
|
+
source: sourceCurrency.id,
|
|
543
|
+
target: converter.id,
|
|
544
|
+
input: 'from',
|
|
545
|
+
})
|
|
546
|
+
.createEdge({
|
|
547
|
+
source: targetCurrency.id,
|
|
548
|
+
target: converter.id,
|
|
549
|
+
input: 'to',
|
|
550
|
+
})
|
|
551
|
+
.createEdge({
|
|
552
|
+
source: converter.id,
|
|
553
|
+
target: view.id,
|
|
554
|
+
output: 'rate',
|
|
555
|
+
});
|
|
339
556
|
});
|
|
340
557
|
|
|
341
558
|
const computeModel = createComputeGraph(canvasModel);
|
|
@@ -353,17 +570,20 @@ export const generator = () => ({
|
|
|
353
570
|
const objects = range(n, () => {
|
|
354
571
|
const canvasModel = CanvasGraphModel.create<ComputeShape>();
|
|
355
572
|
|
|
356
|
-
let functionTrigger:
|
|
573
|
+
let functionTrigger: Trigger.Trigger | undefined;
|
|
357
574
|
canvasModel.builder.call((builder) => {
|
|
358
575
|
const triggerShape = createTrigger({
|
|
359
576
|
spaceId: space.id,
|
|
360
|
-
triggerKind:
|
|
577
|
+
triggerKind: 'timer',
|
|
361
578
|
...position({ x: -10, y: -5 }),
|
|
362
579
|
});
|
|
363
580
|
const trigger = canvasModel.createNode(triggerShape);
|
|
364
581
|
// DXOS dev-null channel.
|
|
365
582
|
const channelId = canvasModel.createNode(
|
|
366
|
-
createConstant({
|
|
583
|
+
createConstant({
|
|
584
|
+
value: '1088569858767212554',
|
|
585
|
+
...position({ x: -10, y: 0 }),
|
|
586
|
+
}),
|
|
367
587
|
);
|
|
368
588
|
const queueId = canvasModel.createNode(
|
|
369
589
|
createConstant({
|
|
@@ -373,14 +593,34 @@ export const generator = () => ({
|
|
|
373
593
|
);
|
|
374
594
|
const converter = canvasModel.createNode(createFunction(position({ x: 0, y: 0 })));
|
|
375
595
|
const view = canvasModel.createNode(createText(position({ x: 12, y: 0 })));
|
|
376
|
-
const queue = canvasModel.createNode(
|
|
596
|
+
const queue = canvasModel.createNode(createFeed(position({ x: 0, y: 12 })));
|
|
377
597
|
|
|
378
598
|
builder
|
|
379
|
-
.createEdge({
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
599
|
+
.createEdge({
|
|
600
|
+
source: trigger.id,
|
|
601
|
+
target: converter.id,
|
|
602
|
+
input: 'tick',
|
|
603
|
+
})
|
|
604
|
+
.createEdge({
|
|
605
|
+
source: channelId.id,
|
|
606
|
+
target: converter.id,
|
|
607
|
+
input: 'channelId',
|
|
608
|
+
})
|
|
609
|
+
.createEdge({
|
|
610
|
+
source: queueId.id,
|
|
611
|
+
target: converter.id,
|
|
612
|
+
input: 'queueId',
|
|
613
|
+
})
|
|
614
|
+
.createEdge({
|
|
615
|
+
source: converter.id,
|
|
616
|
+
target: view.id,
|
|
617
|
+
output: 'newMessages',
|
|
618
|
+
})
|
|
619
|
+
.createEdge({
|
|
620
|
+
source: queueId.id,
|
|
621
|
+
target: queue.id,
|
|
622
|
+
input: 'input',
|
|
623
|
+
});
|
|
384
624
|
|
|
385
625
|
functionTrigger = triggerShape.functionTrigger!.target!;
|
|
386
626
|
});
|
|
@@ -395,61 +635,62 @@ export const generator = () => ({
|
|
|
395
635
|
},
|
|
396
636
|
],
|
|
397
637
|
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
638
|
+
// TODO(wittjosiah): Remove?
|
|
639
|
+
// [
|
|
640
|
+
// PresetName.KANBAN_QUEUE,
|
|
641
|
+
// async (space, n, cb) => {
|
|
642
|
+
// const objects = range(n, () => {
|
|
643
|
+
// const canvasModel = CanvasGraphModel.create<ComputeShape>();
|
|
644
|
+
|
|
645
|
+
// // TODO(wittjosiah): Integrate directly w/ Kanban.
|
|
646
|
+
// // const results = space.db.query(Filter.type(KanbanType)).runSync();
|
|
647
|
+
// // const kanban = results.find((r) => r.object?.cardView?.target?.query?.type?.endsWith('Message'));
|
|
648
|
+
// // invariant(kanban, 'Kanban not found.');
|
|
649
|
+
|
|
650
|
+
// const results = space.db.query(Filter.type(TableType)).runSync();
|
|
651
|
+
// const messages = results.find((r) => r.object?.view?.target?.query?.typename?.endsWith('Message'));
|
|
652
|
+
// invariant(messages, 'Table not found.');
|
|
653
|
+
|
|
654
|
+
// let functionTrigger: FunctionTrigger | undefined;
|
|
655
|
+
// canvasModel.builder.call((builder) => {
|
|
656
|
+
// const triggerShape = createTrigger({
|
|
657
|
+
// spaceId: space.id,
|
|
658
|
+
// triggerKind: 'queue',
|
|
659
|
+
// ...position({ x: -10, y: -5 }),
|
|
660
|
+
// });
|
|
661
|
+
// const trigger = canvasModel.createNode(triggerShape);
|
|
662
|
+
|
|
663
|
+
// const tableId = canvasModel.createNode(
|
|
664
|
+
// createConstant({
|
|
665
|
+
// value: DXN.fromLocalObjectId(messages.id).toString(),
|
|
666
|
+
// ...position({ x: -10, y: 5 }),
|
|
667
|
+
// }),
|
|
668
|
+
// );
|
|
669
|
+
// const appendToTable = canvasModel.createNode(createAppend(position({ x: 10, y: 0 })));
|
|
670
|
+
|
|
671
|
+
// builder
|
|
672
|
+
// .createEdge({ source: tableId.id, target: appendToTable.id, input: 'id' })
|
|
673
|
+
// .createEdge({ source: trigger.id, target: appendToTable.id, input: 'items', output: 'item' });
|
|
674
|
+
|
|
675
|
+
// functionTrigger = triggerShape.functionTrigger!.target!;
|
|
676
|
+
// });
|
|
677
|
+
|
|
678
|
+
// const computeModel = createComputeGraph(canvasModel);
|
|
679
|
+
// attachTrigger(functionTrigger, computeModel);
|
|
680
|
+
|
|
681
|
+
// return addToSpace(PresetName.KANBAN_QUEUE, space, canvasModel, computeModel);
|
|
682
|
+
// });
|
|
683
|
+
// cb?.(objects);
|
|
684
|
+
// return objects;
|
|
685
|
+
// },
|
|
686
|
+
// ],
|
|
446
687
|
] as [PresetName, ObjectGenerator<any>][],
|
|
447
688
|
});
|
|
448
689
|
|
|
449
|
-
const createQueueSinkPreset = <SpecType extends
|
|
690
|
+
const createQueueSinkPreset = <SpecType extends Trigger.Kind>(
|
|
450
691
|
space: Space,
|
|
451
692
|
triggerKind: SpecType,
|
|
452
|
-
initSpec: (spec: Extract<
|
|
693
|
+
initSpec: (spec: Obj.Mutable<Extract<Trigger.Spec, { kind: SpecType }>>) => void,
|
|
453
694
|
triggerOutputName: string,
|
|
454
695
|
) => {
|
|
455
696
|
const canvasModel = CanvasGraphModel.create<ComputeShape>();
|
|
@@ -461,7 +702,7 @@ const createQueueSinkPreset = <SpecType extends TriggerKind>(
|
|
|
461
702
|
}),
|
|
462
703
|
);
|
|
463
704
|
|
|
464
|
-
let functionTrigger:
|
|
705
|
+
let functionTrigger: Trigger.Trigger | undefined;
|
|
465
706
|
canvasModel.builder.call((builder) => {
|
|
466
707
|
const triggerShape = createTrigger({
|
|
467
708
|
spaceId: space.id,
|
|
@@ -482,7 +723,12 @@ const createQueueSinkPreset = <SpecType extends TriggerKind>(
|
|
|
482
723
|
builder
|
|
483
724
|
.createEdge({ source: queueId.id, target: append.id, input: 'id' })
|
|
484
725
|
.createEdge({ source: template.id, target: append.id, input: 'items' })
|
|
485
|
-
.createEdge({
|
|
726
|
+
.createEdge({
|
|
727
|
+
source: trigger.id,
|
|
728
|
+
target: template.id,
|
|
729
|
+
output: triggerOutputName,
|
|
730
|
+
input: 'type',
|
|
731
|
+
})
|
|
486
732
|
.createEdge({
|
|
487
733
|
source: random.id,
|
|
488
734
|
target: template.id,
|
|
@@ -492,15 +738,20 @@ const createQueueSinkPreset = <SpecType extends TriggerKind>(
|
|
|
492
738
|
functionTrigger = triggerShape.functionTrigger!.target!;
|
|
493
739
|
const triggerSpec = functionTrigger.spec;
|
|
494
740
|
invariant(triggerSpec && triggerSpec.kind === triggerKind, 'No trigger spec.');
|
|
495
|
-
|
|
741
|
+
Obj.update(functionTrigger, (functionTrigger) => {
|
|
742
|
+
initSpec(functionTrigger.spec as any);
|
|
743
|
+
});
|
|
496
744
|
});
|
|
497
745
|
|
|
498
746
|
const computeModel = createComputeGraph(canvasModel);
|
|
499
747
|
|
|
500
748
|
const templateComputeNode = computeModel.nodes.find((n) => n.id === template.node);
|
|
501
749
|
invariant(templateComputeNode, 'Template compute node was not created.');
|
|
750
|
+
// NOTE: These are plain object mutations during model construction, not ECHO object mutations.
|
|
502
751
|
templateComputeNode.value = ['{', ' "@type": "{{type}}",', ' "id": "@{{changeId}}"', '}'].join('\n');
|
|
503
|
-
templateComputeNode.inputSchema =
|
|
752
|
+
templateComputeNode.inputSchema = JsonSchema.toJsonSchema(
|
|
753
|
+
Schema.Struct({ type: Schema.String, changeId: Schema.String }),
|
|
754
|
+
);
|
|
504
755
|
attachTrigger(functionTrigger, computeModel);
|
|
505
756
|
|
|
506
757
|
return { canvasModel, computeModel };
|
|
@@ -508,7 +759,7 @@ const createQueueSinkPreset = <SpecType extends TriggerKind>(
|
|
|
508
759
|
|
|
509
760
|
const addToSpace = (name: string, space: Space, canvas: CanvasGraphModel, compute: ComputeGraphModel) => {
|
|
510
761
|
return space.db.add(
|
|
511
|
-
Obj.make(
|
|
762
|
+
Obj.make(CanvasBoard.CanvasBoard, {
|
|
512
763
|
name,
|
|
513
764
|
computeGraph: Ref.make(compute.root),
|
|
514
765
|
layout: canvas.graph,
|
|
@@ -528,7 +779,7 @@ const setupQueue = (
|
|
|
528
779
|
}),
|
|
529
780
|
);
|
|
530
781
|
const queue = canvasModel.createNode(
|
|
531
|
-
|
|
782
|
+
createFeed(
|
|
532
783
|
args?.queuePosition ? rawPosition(args.queuePosition) : position({ x: -3, y: 3, width: 14, height: 10 }),
|
|
533
784
|
),
|
|
534
785
|
);
|
|
@@ -536,17 +787,27 @@ const setupQueue = (
|
|
|
536
787
|
return { queue, queueId };
|
|
537
788
|
};
|
|
538
789
|
|
|
539
|
-
const attachTrigger = (functionTrigger:
|
|
790
|
+
const attachTrigger = (functionTrigger: Trigger.Trigger | undefined, computeModel: ComputeGraphModel) => {
|
|
540
791
|
invariant(functionTrigger);
|
|
541
|
-
functionTrigger.function = Ref.make(computeModel.root);
|
|
542
792
|
const inputNode = computeModel.nodes.find((node) => node.type === NODE_INPUT)!;
|
|
543
|
-
functionTrigger
|
|
793
|
+
Obj.update(functionTrigger, (functionTrigger) => {
|
|
794
|
+
functionTrigger.function = Ref.make(computeModel.root);
|
|
795
|
+
functionTrigger.inputNodeId = inputNode.id;
|
|
796
|
+
});
|
|
544
797
|
};
|
|
545
798
|
|
|
546
|
-
type RawPositionInput = {
|
|
799
|
+
type RawPositionInput = {
|
|
800
|
+
centerX: number;
|
|
801
|
+
centerY: number;
|
|
802
|
+
width: number;
|
|
803
|
+
height: number;
|
|
804
|
+
};
|
|
547
805
|
|
|
548
806
|
const rawPosition = (args: RawPositionInput) => {
|
|
549
|
-
return {
|
|
807
|
+
return {
|
|
808
|
+
center: { x: args.centerX, y: args.centerY },
|
|
809
|
+
size: { width: args.width, height: args.height },
|
|
810
|
+
};
|
|
550
811
|
};
|
|
551
812
|
|
|
552
813
|
const position = (rect: { x: number; y: number; width?: number; height?: number }) => {
|
|
@@ -554,7 +815,10 @@ const position = (rect: { x: number; y: number; width?: number; height?: number
|
|
|
554
815
|
const [center, size] = rectToPoints({ width: 0, height: 0, ...rect });
|
|
555
816
|
const { x, y, width, height } = pointsToRect([pointMultiply(center, snap), pointMultiply(size, snap)]);
|
|
556
817
|
if (width && height) {
|
|
557
|
-
return {
|
|
818
|
+
return {
|
|
819
|
+
center: { x, y },
|
|
820
|
+
size: width && height ? { width, height } : undefined,
|
|
821
|
+
};
|
|
558
822
|
} else {
|
|
559
823
|
return { center: { x, y } };
|
|
560
824
|
}
|