@notionhq/workers 0.6.0 → 0.7.0
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/block.d.ts +321 -0
- package/dist/block.d.ts.map +1 -0
- package/dist/block.js +0 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/worker.d.ts +1 -41
- package/dist/worker.d.ts.map +1 -1
- package/dist/worker.js +0 -50
- package/package.json +1 -1
- package/src/block.ts +525 -0
- package/src/index.ts +0 -7
- package/src/worker.test.ts +0 -147
- package/src/worker.ts +1 -59
- package/dist/capabilities/custom-block.d.ts +0 -124
- package/dist/capabilities/custom-block.d.ts.map +0 -1
- package/dist/capabilities/custom-block.js +0 -22
- package/src/capabilities/custom-block.ts +0 -181
package/src/block.ts
ADDED
|
@@ -0,0 +1,525 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Block Type Definitions
|
|
3
|
+
// ============================================================================
|
|
4
|
+
|
|
5
|
+
// Color types
|
|
6
|
+
type ApiColor =
|
|
7
|
+
| "default"
|
|
8
|
+
| "gray"
|
|
9
|
+
| "brown"
|
|
10
|
+
| "orange"
|
|
11
|
+
| "yellow"
|
|
12
|
+
| "green"
|
|
13
|
+
| "blue"
|
|
14
|
+
| "purple"
|
|
15
|
+
| "pink"
|
|
16
|
+
| "red"
|
|
17
|
+
| "gray_background"
|
|
18
|
+
| "brown_background"
|
|
19
|
+
| "orange_background"
|
|
20
|
+
| "yellow_background"
|
|
21
|
+
| "green_background"
|
|
22
|
+
| "blue_background"
|
|
23
|
+
| "purple_background"
|
|
24
|
+
| "pink_background"
|
|
25
|
+
| "red_background";
|
|
26
|
+
|
|
27
|
+
// Rich text annotations
|
|
28
|
+
type RichTextAnnotations = {
|
|
29
|
+
bold: boolean;
|
|
30
|
+
italic: boolean;
|
|
31
|
+
strikethrough: boolean;
|
|
32
|
+
underline: boolean;
|
|
33
|
+
code: boolean;
|
|
34
|
+
color: ApiColor;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// Base rich text structure
|
|
38
|
+
type RichTextBase = {
|
|
39
|
+
plain_text: string;
|
|
40
|
+
href: string | null;
|
|
41
|
+
annotations: RichTextAnnotations;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// Text content
|
|
45
|
+
type TextContent = {
|
|
46
|
+
content: string;
|
|
47
|
+
link: { url: string } | null;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// Equation content
|
|
51
|
+
type EquationContent = {
|
|
52
|
+
expression: string;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// Date mention
|
|
56
|
+
type DateMention = {
|
|
57
|
+
type: "date";
|
|
58
|
+
date: {
|
|
59
|
+
start: string;
|
|
60
|
+
end?: string | null;
|
|
61
|
+
time_zone?: string | null;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// Custom emoji mention
|
|
66
|
+
type CustomEmojiMention = {
|
|
67
|
+
type: "custom_emoji";
|
|
68
|
+
custom_emoji: {
|
|
69
|
+
id: string;
|
|
70
|
+
name?: string;
|
|
71
|
+
url?: string;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
// Link preview mention
|
|
76
|
+
type LinkPreviewMention = {
|
|
77
|
+
type: "link_preview";
|
|
78
|
+
link_preview: {
|
|
79
|
+
url: string;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
// Link mention
|
|
84
|
+
type LinkMention = {
|
|
85
|
+
type: "link_mention";
|
|
86
|
+
link_mention: {
|
|
87
|
+
href: string;
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
// All mention types
|
|
92
|
+
type MentionContent = DateMention | CustomEmojiMention | LinkPreviewMention | LinkMention;
|
|
93
|
+
|
|
94
|
+
// Rich text item
|
|
95
|
+
type RichTextItem = RichTextBase &
|
|
96
|
+
(
|
|
97
|
+
| { type: "text"; text: TextContent }
|
|
98
|
+
| { type: "mention"; mention: MentionContent }
|
|
99
|
+
| { type: "equation"; equation: EquationContent }
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
// Rich text array
|
|
103
|
+
type RichText = RichTextItem[];
|
|
104
|
+
|
|
105
|
+
// Icon types
|
|
106
|
+
type EmojiIcon = {
|
|
107
|
+
type: "emoji";
|
|
108
|
+
emoji: string;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
type ExternalIcon = {
|
|
112
|
+
type: "external";
|
|
113
|
+
external: { url: string };
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
type FileIcon = {
|
|
117
|
+
type: "file";
|
|
118
|
+
file: {
|
|
119
|
+
url: string;
|
|
120
|
+
expiry_time: string;
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
type Icon = EmojiIcon | ExternalIcon | FileIcon;
|
|
125
|
+
|
|
126
|
+
// File object types
|
|
127
|
+
type ExternalFile = {
|
|
128
|
+
type: "external";
|
|
129
|
+
external: {
|
|
130
|
+
url: string;
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
type HostedFile = {
|
|
135
|
+
type: "file";
|
|
136
|
+
file: {
|
|
137
|
+
url: string;
|
|
138
|
+
expiry_time: string;
|
|
139
|
+
};
|
|
140
|
+
name?: string;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
type FileObject = ExternalFile | HostedFile;
|
|
144
|
+
|
|
145
|
+
// Base block structure
|
|
146
|
+
type BlockBase = {
|
|
147
|
+
object: "block";
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
// Text blocks
|
|
151
|
+
type ParagraphBlock = BlockBase & {
|
|
152
|
+
type: "paragraph";
|
|
153
|
+
paragraph: {
|
|
154
|
+
rich_text: RichText;
|
|
155
|
+
color?: ApiColor;
|
|
156
|
+
children?: Block[];
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
type Heading1Block = BlockBase & {
|
|
161
|
+
type: "heading_1";
|
|
162
|
+
heading_1: {
|
|
163
|
+
rich_text: RichText;
|
|
164
|
+
color?: ApiColor;
|
|
165
|
+
is_toggleable?: boolean;
|
|
166
|
+
children?: Block[];
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
type Heading2Block = BlockBase & {
|
|
171
|
+
type: "heading_2";
|
|
172
|
+
heading_2: {
|
|
173
|
+
rich_text: RichText;
|
|
174
|
+
color?: ApiColor;
|
|
175
|
+
is_toggleable?: boolean;
|
|
176
|
+
children?: Block[];
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
type Heading3Block = BlockBase & {
|
|
181
|
+
type: "heading_3";
|
|
182
|
+
heading_3: {
|
|
183
|
+
rich_text: RichText;
|
|
184
|
+
color?: ApiColor;
|
|
185
|
+
is_toggleable?: boolean;
|
|
186
|
+
children?: Block[];
|
|
187
|
+
};
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
type BulletedListItemBlock = BlockBase & {
|
|
191
|
+
type: "bulleted_list_item";
|
|
192
|
+
bulleted_list_item: {
|
|
193
|
+
rich_text: RichText;
|
|
194
|
+
color?: ApiColor;
|
|
195
|
+
children?: Block[];
|
|
196
|
+
};
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
type NumberedListItemBlock = BlockBase & {
|
|
200
|
+
type: "numbered_list_item";
|
|
201
|
+
numbered_list_item: {
|
|
202
|
+
rich_text: RichText;
|
|
203
|
+
color?: ApiColor;
|
|
204
|
+
children?: Block[];
|
|
205
|
+
};
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
type ToDoBlock = BlockBase & {
|
|
209
|
+
type: "to_do";
|
|
210
|
+
to_do: {
|
|
211
|
+
rich_text: RichText;
|
|
212
|
+
checked: boolean;
|
|
213
|
+
color?: ApiColor;
|
|
214
|
+
children?: Block[];
|
|
215
|
+
};
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
type ToggleBlock = BlockBase & {
|
|
219
|
+
type: "toggle";
|
|
220
|
+
toggle: {
|
|
221
|
+
rich_text: RichText;
|
|
222
|
+
color?: ApiColor;
|
|
223
|
+
children?: Block[];
|
|
224
|
+
};
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
type QuoteBlock = BlockBase & {
|
|
228
|
+
type: "quote";
|
|
229
|
+
quote: {
|
|
230
|
+
rich_text: RichText;
|
|
231
|
+
color?: ApiColor;
|
|
232
|
+
children?: Block[];
|
|
233
|
+
};
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
type CalloutBlock = BlockBase & {
|
|
237
|
+
type: "callout";
|
|
238
|
+
callout: {
|
|
239
|
+
rich_text: RichText;
|
|
240
|
+
icon?: Icon | null;
|
|
241
|
+
color?: ApiColor;
|
|
242
|
+
children?: Block[];
|
|
243
|
+
};
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
// Code block
|
|
247
|
+
type CodeBlock = BlockBase & {
|
|
248
|
+
type: "code";
|
|
249
|
+
code: {
|
|
250
|
+
rich_text: RichText;
|
|
251
|
+
caption?: RichText;
|
|
252
|
+
language: string;
|
|
253
|
+
};
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
// Equation block
|
|
257
|
+
type EquationBlock = BlockBase & {
|
|
258
|
+
type: "equation";
|
|
259
|
+
equation: {
|
|
260
|
+
expression: string;
|
|
261
|
+
};
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
// Divider block
|
|
265
|
+
type DividerBlock = BlockBase & {
|
|
266
|
+
type: "divider";
|
|
267
|
+
divider: Record<string, never>;
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
// Breadcrumb block
|
|
271
|
+
type BreadcrumbBlock = BlockBase & {
|
|
272
|
+
type: "breadcrumb";
|
|
273
|
+
breadcrumb: Record<string, never>;
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
// Table of contents block
|
|
277
|
+
type TableOfContentsBlock = BlockBase & {
|
|
278
|
+
type: "table_of_contents";
|
|
279
|
+
table_of_contents: {
|
|
280
|
+
color?: ApiColor;
|
|
281
|
+
};
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
// Column layout blocks
|
|
285
|
+
type ColumnListBlock = BlockBase & {
|
|
286
|
+
type: "column_list";
|
|
287
|
+
column_list: {
|
|
288
|
+
children: ColumnBlock[];
|
|
289
|
+
};
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
type ColumnBlock = BlockBase & {
|
|
293
|
+
type: "column";
|
|
294
|
+
column: {
|
|
295
|
+
children?: Block[];
|
|
296
|
+
};
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
// Media blocks
|
|
300
|
+
type ImageBlock = BlockBase & {
|
|
301
|
+
type: "image";
|
|
302
|
+
image: FileObject & {
|
|
303
|
+
caption?: RichText;
|
|
304
|
+
};
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
type VideoBlock = BlockBase & {
|
|
308
|
+
type: "video";
|
|
309
|
+
video: FileObject & {
|
|
310
|
+
caption?: RichText;
|
|
311
|
+
};
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
type AudioBlock = BlockBase & {
|
|
315
|
+
type: "audio";
|
|
316
|
+
audio: FileObject & {
|
|
317
|
+
caption?: RichText;
|
|
318
|
+
};
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
type PDFBlock = BlockBase & {
|
|
322
|
+
type: "pdf";
|
|
323
|
+
pdf: FileObject & {
|
|
324
|
+
caption?: RichText;
|
|
325
|
+
};
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
type FileBlock = BlockBase & {
|
|
329
|
+
type: "file";
|
|
330
|
+
file: FileObject & {
|
|
331
|
+
caption?: RichText;
|
|
332
|
+
};
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
// Embed and bookmark blocks
|
|
336
|
+
type EmbedBlock = BlockBase & {
|
|
337
|
+
type: "embed";
|
|
338
|
+
embed: {
|
|
339
|
+
url: string;
|
|
340
|
+
caption?: RichText;
|
|
341
|
+
};
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
type BookmarkBlock = BlockBase & {
|
|
345
|
+
type: "bookmark";
|
|
346
|
+
bookmark: {
|
|
347
|
+
url: string;
|
|
348
|
+
caption?: RichText;
|
|
349
|
+
};
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
// Link preview block
|
|
353
|
+
type LinkPreviewBlock = BlockBase & {
|
|
354
|
+
type: "link_preview";
|
|
355
|
+
link_preview: {
|
|
356
|
+
url: string;
|
|
357
|
+
};
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
// Reference blocks
|
|
361
|
+
type ChildPageBlock = BlockBase & {
|
|
362
|
+
type: "child_page";
|
|
363
|
+
child_page: {
|
|
364
|
+
title: string;
|
|
365
|
+
};
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
type ChildDatabaseBlock = BlockBase & {
|
|
369
|
+
type: "child_database";
|
|
370
|
+
child_database: {
|
|
371
|
+
title: string;
|
|
372
|
+
};
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
// type LinkToPageBlock = BlockBase & {
|
|
376
|
+
// type: "link_to_page"
|
|
377
|
+
// link_to_page:
|
|
378
|
+
// | { type: "page_id"; page_id: string }
|
|
379
|
+
// | { type: "database_id"; database_id: string }
|
|
380
|
+
// }
|
|
381
|
+
|
|
382
|
+
// // Synced block
|
|
383
|
+
// type SyncedBlock = BlockBase & {
|
|
384
|
+
// type: "synced_block"
|
|
385
|
+
// synced_block: {
|
|
386
|
+
// synced_from: {
|
|
387
|
+
// type: "block_id"
|
|
388
|
+
// block_id: string
|
|
389
|
+
// } | null
|
|
390
|
+
// children?: Block[]
|
|
391
|
+
// }
|
|
392
|
+
// }
|
|
393
|
+
|
|
394
|
+
// Template block
|
|
395
|
+
type TemplateBlock = BlockBase & {
|
|
396
|
+
type: "template";
|
|
397
|
+
template: {
|
|
398
|
+
rich_text: RichText;
|
|
399
|
+
children?: Block[];
|
|
400
|
+
};
|
|
401
|
+
};
|
|
402
|
+
|
|
403
|
+
// Table blocks
|
|
404
|
+
type TableBlock = BlockBase & {
|
|
405
|
+
type: "table";
|
|
406
|
+
table: {
|
|
407
|
+
table_width: number;
|
|
408
|
+
has_column_header: boolean;
|
|
409
|
+
has_row_header: boolean;
|
|
410
|
+
children: TableRowBlock[];
|
|
411
|
+
};
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
type TableRowBlock = BlockBase & {
|
|
415
|
+
type: "table_row";
|
|
416
|
+
table_row: {
|
|
417
|
+
cells: RichText[];
|
|
418
|
+
};
|
|
419
|
+
};
|
|
420
|
+
|
|
421
|
+
// AI block
|
|
422
|
+
type AIBlock = BlockBase & {
|
|
423
|
+
type: "ai_block";
|
|
424
|
+
ai_block: {
|
|
425
|
+
prompt?: string;
|
|
426
|
+
};
|
|
427
|
+
};
|
|
428
|
+
|
|
429
|
+
// Unsupported block
|
|
430
|
+
type UnsupportedBlock = BlockBase & {
|
|
431
|
+
type: "unsupported";
|
|
432
|
+
unsupported: Record<string, never>;
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
// All block types union
|
|
436
|
+
type Block =
|
|
437
|
+
| ParagraphBlock
|
|
438
|
+
| Heading1Block
|
|
439
|
+
| Heading2Block
|
|
440
|
+
| Heading3Block
|
|
441
|
+
| BulletedListItemBlock
|
|
442
|
+
| NumberedListItemBlock
|
|
443
|
+
| ToDoBlock
|
|
444
|
+
| ToggleBlock
|
|
445
|
+
| QuoteBlock
|
|
446
|
+
| CalloutBlock
|
|
447
|
+
| CodeBlock
|
|
448
|
+
| EquationBlock
|
|
449
|
+
| DividerBlock
|
|
450
|
+
| BreadcrumbBlock
|
|
451
|
+
| TableOfContentsBlock
|
|
452
|
+
| ColumnListBlock
|
|
453
|
+
| ColumnBlock
|
|
454
|
+
| ImageBlock
|
|
455
|
+
| VideoBlock
|
|
456
|
+
| AudioBlock
|
|
457
|
+
| PDFBlock
|
|
458
|
+
| FileBlock
|
|
459
|
+
| EmbedBlock
|
|
460
|
+
| BookmarkBlock
|
|
461
|
+
| LinkPreviewBlock
|
|
462
|
+
| ChildPageBlock
|
|
463
|
+
| ChildDatabaseBlock
|
|
464
|
+
| TemplateBlock
|
|
465
|
+
| TableBlock
|
|
466
|
+
| TableRowBlock
|
|
467
|
+
| AIBlock
|
|
468
|
+
| UnsupportedBlock;
|
|
469
|
+
|
|
470
|
+
// Export all types
|
|
471
|
+
export type {
|
|
472
|
+
AIBlock,
|
|
473
|
+
ApiColor,
|
|
474
|
+
AudioBlock,
|
|
475
|
+
Block,
|
|
476
|
+
BlockBase,
|
|
477
|
+
BookmarkBlock,
|
|
478
|
+
BreadcrumbBlock,
|
|
479
|
+
BulletedListItemBlock,
|
|
480
|
+
CalloutBlock,
|
|
481
|
+
ChildDatabaseBlock,
|
|
482
|
+
ChildPageBlock,
|
|
483
|
+
CodeBlock,
|
|
484
|
+
ColumnBlock,
|
|
485
|
+
ColumnListBlock,
|
|
486
|
+
CustomEmojiMention,
|
|
487
|
+
DateMention,
|
|
488
|
+
DividerBlock,
|
|
489
|
+
EmbedBlock,
|
|
490
|
+
EmojiIcon,
|
|
491
|
+
EquationBlock,
|
|
492
|
+
EquationContent,
|
|
493
|
+
ExternalFile,
|
|
494
|
+
ExternalIcon,
|
|
495
|
+
FileBlock,
|
|
496
|
+
FileIcon,
|
|
497
|
+
FileObject,
|
|
498
|
+
Heading1Block,
|
|
499
|
+
Heading2Block,
|
|
500
|
+
Heading3Block,
|
|
501
|
+
HostedFile,
|
|
502
|
+
Icon,
|
|
503
|
+
ImageBlock,
|
|
504
|
+
LinkMention,
|
|
505
|
+
LinkPreviewBlock,
|
|
506
|
+
LinkPreviewMention,
|
|
507
|
+
MentionContent,
|
|
508
|
+
NumberedListItemBlock,
|
|
509
|
+
ParagraphBlock,
|
|
510
|
+
PDFBlock,
|
|
511
|
+
QuoteBlock,
|
|
512
|
+
RichText,
|
|
513
|
+
RichTextAnnotations,
|
|
514
|
+
RichTextBase,
|
|
515
|
+
RichTextItem,
|
|
516
|
+
TableBlock,
|
|
517
|
+
TableOfContentsBlock,
|
|
518
|
+
TableRowBlock,
|
|
519
|
+
TemplateBlock,
|
|
520
|
+
TextContent,
|
|
521
|
+
ToDoBlock,
|
|
522
|
+
ToggleBlock,
|
|
523
|
+
UnsupportedBlock,
|
|
524
|
+
VideoBlock,
|
|
525
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
export type {
|
|
2
|
-
CustomBlockCapability,
|
|
3
|
-
CustomBlockCapabilityConfig,
|
|
4
|
-
CustomBlockConfiguration,
|
|
5
|
-
CustomBlockManifest,
|
|
6
|
-
CustomBlockManifestDataSource,
|
|
7
|
-
} from "./capabilities/custom-block.js";
|
|
8
1
|
export { emojiIcon, imageCover, imageIcon, notionIcon, place } from "./builder.js";
|
|
9
2
|
export type {
|
|
10
3
|
AiConnectorArchetype,
|
package/src/worker.test.ts
CHANGED
|
@@ -141,153 +141,6 @@ describe("Worker", () => {
|
|
|
141
141
|
]);
|
|
142
142
|
});
|
|
143
143
|
|
|
144
|
-
it("registers a project custom block from a folder path (type defaults to project)", () => {
|
|
145
|
-
const worker = new Worker();
|
|
146
|
-
|
|
147
|
-
worker.customBlock("visualBlock", {
|
|
148
|
-
path: "./views/visual",
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
expect(worker.manifest.capabilities).toEqual([
|
|
152
|
-
{
|
|
153
|
-
_tag: "custom_block",
|
|
154
|
-
key: "visualBlock",
|
|
155
|
-
config: {
|
|
156
|
-
source: { type: "project", path: "./views/visual" },
|
|
157
|
-
manifest: {
|
|
158
|
-
version: 1,
|
|
159
|
-
dataSources: {},
|
|
160
|
-
},
|
|
161
|
-
},
|
|
162
|
-
},
|
|
163
|
-
]);
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
it("carries a project's custom build command and output dir", () => {
|
|
167
|
-
const worker = new Worker();
|
|
168
|
-
|
|
169
|
-
worker.customBlock("built", {
|
|
170
|
-
path: "./app",
|
|
171
|
-
command: "npm run build-prod",
|
|
172
|
-
output: "build",
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
expect(worker.manifest.capabilities).toEqual([
|
|
176
|
-
{
|
|
177
|
-
_tag: "custom_block",
|
|
178
|
-
key: "built",
|
|
179
|
-
config: {
|
|
180
|
-
source: {
|
|
181
|
-
type: "project",
|
|
182
|
-
path: "./app",
|
|
183
|
-
command: "npm run build-prod",
|
|
184
|
-
output: "build",
|
|
185
|
-
},
|
|
186
|
-
manifest: { version: 1, dataSources: {} },
|
|
187
|
-
},
|
|
188
|
-
},
|
|
189
|
-
]);
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
it("registers a static custom block served as-is", () => {
|
|
193
|
-
const worker = new Worker();
|
|
194
|
-
|
|
195
|
-
worker.customBlock("prebuilt", { type: "static", path: "./dist" });
|
|
196
|
-
|
|
197
|
-
expect(worker.manifest.capabilities).toEqual([
|
|
198
|
-
{
|
|
199
|
-
_tag: "custom_block",
|
|
200
|
-
key: "prebuilt",
|
|
201
|
-
config: {
|
|
202
|
-
source: { type: "static", path: "./dist" },
|
|
203
|
-
manifest: { version: 1, dataSources: {} },
|
|
204
|
-
},
|
|
205
|
-
},
|
|
206
|
-
]);
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
it("carries the author-declared data-source schema verbatim into the manifest", () => {
|
|
210
|
-
const worker = new Worker();
|
|
211
|
-
|
|
212
|
-
worker.customBlock("issueBoard", {
|
|
213
|
-
path: "./views/issueBoard",
|
|
214
|
-
dataSources: {
|
|
215
|
-
issues: {
|
|
216
|
-
name: "Issues",
|
|
217
|
-
description: "The team's issues",
|
|
218
|
-
icon: { type: "emoji", emoji: "🐛" },
|
|
219
|
-
properties: {
|
|
220
|
-
title: { name: "Title", type: "title" },
|
|
221
|
-
status: {
|
|
222
|
-
name: "Status",
|
|
223
|
-
description: "Workflow state",
|
|
224
|
-
type: "status",
|
|
225
|
-
},
|
|
226
|
-
},
|
|
227
|
-
},
|
|
228
|
-
},
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
expect(worker.manifest.capabilities).toEqual([
|
|
232
|
-
{
|
|
233
|
-
_tag: "custom_block",
|
|
234
|
-
key: "issueBoard",
|
|
235
|
-
config: {
|
|
236
|
-
source: { type: "project", path: "./views/issueBoard" },
|
|
237
|
-
manifest: {
|
|
238
|
-
version: 1,
|
|
239
|
-
dataSources: {
|
|
240
|
-
issues: {
|
|
241
|
-
name: "Issues",
|
|
242
|
-
description: "The team's issues",
|
|
243
|
-
icon: { type: "emoji", emoji: "🐛" },
|
|
244
|
-
properties: {
|
|
245
|
-
title: { name: "Title", type: "title" },
|
|
246
|
-
status: {
|
|
247
|
-
name: "Status",
|
|
248
|
-
description: "Workflow state",
|
|
249
|
-
type: "status",
|
|
250
|
-
},
|
|
251
|
-
},
|
|
252
|
-
},
|
|
253
|
-
},
|
|
254
|
-
},
|
|
255
|
-
},
|
|
256
|
-
},
|
|
257
|
-
]);
|
|
258
|
-
});
|
|
259
|
-
|
|
260
|
-
it("threads a top-level manifest version into the generated manifest", () => {
|
|
261
|
-
const worker = new Worker();
|
|
262
|
-
|
|
263
|
-
worker.customBlock("versioned", {
|
|
264
|
-
path: "./views/versioned",
|
|
265
|
-
version: 1,
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
expect(worker.manifest.capabilities).toEqual([
|
|
269
|
-
{
|
|
270
|
-
_tag: "custom_block",
|
|
271
|
-
key: "versioned",
|
|
272
|
-
config: {
|
|
273
|
-
source: { type: "project", path: "./views/versioned" },
|
|
274
|
-
manifest: { version: 1, dataSources: {} },
|
|
275
|
-
},
|
|
276
|
-
},
|
|
277
|
-
]);
|
|
278
|
-
});
|
|
279
|
-
|
|
280
|
-
it("cannot run a custom block capability", async () => {
|
|
281
|
-
const worker = new Worker();
|
|
282
|
-
worker.customBlock("visualBlock", {
|
|
283
|
-
path: "./views/visual",
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
await expect(worker.run("visualBlock", {})).rejects.toThrow(
|
|
287
|
-
'Cannot run custom block capability "visualBlock"',
|
|
288
|
-
);
|
|
289
|
-
});
|
|
290
|
-
|
|
291
144
|
it("rejects duplicate keys across databases, pacers, and capabilities", () => {
|
|
292
145
|
const worker = new Worker();
|
|
293
146
|
const db = worker.database("shared-key", {
|