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