@notionhq/custom-blocks-dev-shell 0.1.114 → 0.1.115

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.
Files changed (131) hide show
  1. package/README.md +27 -14
  2. package/bin/cli.js +3 -1
  3. package/dist/assets/index-DXzPwq_J.js +11 -0
  4. package/dist/index.html +1 -1
  5. package/dist-cli/cli/binding-cli-flags.js +33 -0
  6. package/dist-cli/cli/binding-errors.js +15 -0
  7. package/dist-cli/{build-block-registry.js → cli/build-block-registry.js} +2 -0
  8. package/dist-cli/{convert-values.js → cli/convert-values.js} +5 -5
  9. package/dist-cli/{convert.js → cli/convert.js} +3 -3
  10. package/dist-cli/cli/data-source-files.js +6 -0
  11. package/dist-cli/{data-sources.js → cli/data-sources.js} +12 -65
  12. package/dist-cli/{dev-shell-launcher.js → cli/dev-shell-launcher.js} +23 -10
  13. package/dist-cli/{errors.js → cli/errors.js} +5 -1
  14. package/dist-cli/cli/launcher-bindings.js +144 -0
  15. package/dist-cli/{published-cli.js → cli/published-cli.js} +2 -2
  16. package/dist-cli/{worker-manifest.js → cli/worker-manifest.js} +18 -1
  17. package/dist-cli/protocol/contrast.d.ts +4 -0
  18. package/dist-cli/protocol/contrast.js +3 -0
  19. package/dist-cli/protocol/dataSources/dataSource.d.ts +786 -0
  20. package/dist-cli/protocol/dataSources/dataSource.js +66 -0
  21. package/dist-cli/protocol/dataSources/dataSourcePage.d.ts +74 -0
  22. package/dist-cli/protocol/dataSources/dataSourcePage.js +15 -0
  23. package/dist-cli/protocol/dataSources/dataSourceValue.d.ts +66 -0
  24. package/dist-cli/protocol/dataSources/dataSourceValue.js +14 -0
  25. package/dist-cli/protocol/dataSources/dateValue.d.ts +157 -0
  26. package/dist-cli/protocol/dataSources/dateValue.js +61 -0
  27. package/dist-cli/protocol/dataSources/errors.d.ts +8 -0
  28. package/dist-cli/protocol/dataSources/errors.js +7 -0
  29. package/dist-cli/protocol/dataSources/propertySchema.d.ts +200 -0
  30. package/dist-cli/protocol/dataSources/propertySchema.js +174 -0
  31. package/dist-cli/protocol/dataSources/recordPointer.d.ts +9 -0
  32. package/dist-cli/protocol/dataSources/recordPointer.js +8 -0
  33. package/dist-cli/protocol/dataSources/sortDirection.d.ts +3 -0
  34. package/dist-cli/protocol/dataSources/sortDirection.js +2 -0
  35. package/dist-cli/protocol/errors.d.ts +12 -0
  36. package/dist-cli/protocol/errors.js +6 -0
  37. package/dist-cli/protocol/ids.d.ts +31 -0
  38. package/dist-cli/protocol/ids.js +26 -0
  39. package/dist-cli/protocol/index.d.ts +53 -0
  40. package/dist-cli/protocol/index.js +53 -0
  41. package/dist-cli/protocol/manifest.d.ts +67 -0
  42. package/dist-cli/protocol/manifest.js +36 -0
  43. package/dist-cli/protocol/messages/connect.d.ts +54 -0
  44. package/dist-cli/protocol/messages/connect.js +39 -0
  45. package/dist-cli/protocol/messages/contrastModeChanged.d.ts +7 -0
  46. package/dist-cli/protocol/messages/contrastModeChanged.js +7 -0
  47. package/dist-cli/protocol/messages/createPage.d.ts +290 -0
  48. package/dist-cli/protocol/messages/createPage.js +51 -0
  49. package/dist-cli/protocol/messages/createPageResult.d.ts +897 -0
  50. package/dist-cli/protocol/messages/createPageResult.js +43 -0
  51. package/dist-cli/protocol/messages/currentUserChanged.d.ts +18 -0
  52. package/dist-cli/protocol/messages/currentUserChanged.js +9 -0
  53. package/dist-cli/protocol/messages/dataSourcesChanged.d.ts +157 -0
  54. package/dist-cli/protocol/messages/dataSourcesChanged.js +13 -0
  55. package/dist-cli/protocol/messages/getPage.d.ts +902 -0
  56. package/dist-cli/protocol/messages/getPage.js +48 -0
  57. package/dist-cli/protocol/messages/getUser.d.ts +44 -0
  58. package/dist-cli/protocol/messages/getUser.js +32 -0
  59. package/dist-cli/protocol/messages/hostToSandbox.d.ts +4385 -0
  60. package/dist-cli/protocol/messages/hostToSandbox.js +48 -0
  61. package/dist-cli/protocol/messages/incomingType.d.ts +9 -0
  62. package/dist-cli/protocol/messages/incomingType.js +17 -0
  63. package/dist-cli/protocol/messages/init.d.ts +273 -0
  64. package/dist-cli/protocol/messages/init.js +57 -0
  65. package/dist-cli/protocol/messages/initResult.d.ts +37 -0
  66. package/dist-cli/protocol/messages/initResult.js +29 -0
  67. package/dist-cli/protocol/messages/invalidHostMessage.d.ts +14 -0
  68. package/dist-cli/protocol/messages/invalidHostMessage.js +13 -0
  69. package/dist-cli/protocol/messages/invalidSandboxMessage.d.ts +14 -0
  70. package/dist-cli/protocol/messages/invalidSandboxMessage.js +13 -0
  71. package/dist-cli/protocol/messages/isInitHandshakeMessage.d.ts +4 -0
  72. package/dist-cli/protocol/messages/isInitHandshakeMessage.js +11 -0
  73. package/dist-cli/protocol/messages/listUsers.d.ts +52 -0
  74. package/dist-cli/protocol/messages/listUsers.js +33 -0
  75. package/dist-cli/protocol/messages/messagePayload.d.ts +19 -0
  76. package/dist-cli/protocol/messages/messagePayload.js +1 -0
  77. package/dist-cli/protocol/messages/openExternalUrl.d.ts +32 -0
  78. package/dist-cli/protocol/messages/openExternalUrl.js +26 -0
  79. package/dist-cli/protocol/messages/openPage.d.ts +38 -0
  80. package/dist-cli/protocol/messages/openPage.js +34 -0
  81. package/dist-cli/protocol/messages/pageChanged.d.ts +32 -0
  82. package/dist-cli/protocol/messages/pageChanged.js +9 -0
  83. package/dist-cli/protocol/messages/parentChanged.d.ts +26 -0
  84. package/dist-cli/protocol/messages/parentChanged.js +9 -0
  85. package/dist-cli/protocol/messages/queryDataSource.d.ts +1446 -0
  86. package/dist-cli/protocol/messages/queryDataSource.js +252 -0
  87. package/dist-cli/protocol/messages/queryDataSourceResult.d.ts +686 -0
  88. package/dist-cli/protocol/messages/queryDataSourceResult.js +44 -0
  89. package/dist-cli/protocol/messages/resize.d.ts +11 -0
  90. package/dist-cli/protocol/messages/resize.js +10 -0
  91. package/dist-cli/protocol/messages/sandboxToHost.d.ts +1091 -0
  92. package/dist-cli/protocol/messages/sandboxToHost.js +33 -0
  93. package/dist-cli/protocol/messages/themeChanged.d.ts +10 -0
  94. package/dist-cli/protocol/messages/themeChanged.js +10 -0
  95. package/dist-cli/protocol/messages/unsubscribeDataSourceQuery.d.ts +10 -0
  96. package/dist-cli/protocol/messages/unsubscribeDataSourceQuery.js +9 -0
  97. package/dist-cli/protocol/messages/updatePage.d.ts +271 -0
  98. package/dist-cli/protocol/messages/updatePage.js +23 -0
  99. package/dist-cli/protocol/messages/updatePageResult.d.ts +895 -0
  100. package/dist-cli/protocol/messages/updatePageResult.js +41 -0
  101. package/dist-cli/protocol/pages/page.d.ts +1422 -0
  102. package/dist-cli/protocol/pages/page.js +318 -0
  103. package/dist-cli/protocol/parent.d.ts +32 -0
  104. package/dist-cli/protocol/parent.js +13 -0
  105. package/dist-cli/protocol/protocolVersion.d.ts +8 -0
  106. package/dist-cli/protocol/protocolVersion.js +11 -0
  107. package/dist-cli/protocol/theme.d.ts +3 -0
  108. package/dist-cli/protocol/theme.js +2 -0
  109. package/dist-cli/protocol/users/user.d.ts +32 -0
  110. package/dist-cli/protocol/users/user.js +20 -0
  111. package/dist-cli/shared/block-registry.js +28 -0
  112. package/dist-cli/shared/data-source.js +22 -0
  113. package/dist-cli/shared/runtime-config.js +10 -0
  114. package/dist-cli/shared/sample-data-source.js +12 -0
  115. package/docs/bindings.md +79 -27
  116. package/package.json +5 -26
  117. package/dist/assets/index-F02ZboyS.js +0 -11
  118. package/dist-cli/date-value.js +0 -46
  119. package/dist-cli/resolve-bindings.js +0 -39
  120. package/dist-cli/source-bindings.js +0 -17
  121. /package/dist-cli/{block-csp.js → cli/block-csp.js} +0 -0
  122. /package/dist-cli/{dev-shell-run.js → cli/dev-shell-run.js} +0 -0
  123. /package/dist-cli/{materialize.js → cli/materialize.js} +0 -0
  124. /package/dist-cli/{ports.js → cli/ports.js} +0 -0
  125. /package/dist-cli/{prebuilt.js → cli/prebuilt.js} +0 -0
  126. /package/dist-cli/{runtime-error-client.js → cli/runtime-error-client.js} +0 -0
  127. /package/dist-cli/{serve-ui.js → cli/serve-ui.js} +0 -0
  128. /package/dist-cli/{shared-server.js → cli/shared-server.js} +0 -0
  129. /package/dist-cli/{utils.js → cli/utils.js} +0 -0
  130. /package/dist-cli/{vite-block-server.js → cli/vite-block-server.js} +0 -0
  131. /package/dist-cli/{vite-middleware.js → cli/vite-middleware.js} +0 -0
@@ -0,0 +1,252 @@
1
+ import * as v from "valibot";
2
+ import { notionSortDirectionSchema } from "../dataSources/sortDirection.js";
3
+ import { notionDataSourceIdSchema, notionPageIdSchema } from "../ids.js";
4
+ const relationPageIdSchema = v.pipe(notionPageIdSchema, v.regex(/^(?:[0-9a-f]{32}|[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12})$/i), v.transform(id => id
5
+ .replaceAll("-", "")
6
+ .toLowerCase()
7
+ .replace(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/, "$1-$2-$3-$4-$5")));
8
+ export const customBlockRelationFilterOperatorSchema = v.union([
9
+ v.strictObject({ contains: relationPageIdSchema }),
10
+ v.strictObject({ does_not_contain: relationPageIdSchema }),
11
+ ]);
12
+ const emptyOperatorSchema = v.union([
13
+ v.strictObject({ is_empty: v.literal(true) }),
14
+ v.strictObject({ is_not_empty: v.literal(true) }),
15
+ ]);
16
+ const stringOrStringArraySchema = v.union([v.string(), v.array(v.string())]);
17
+ const customBlockPersonFilterValueSchema = v.strictObject({
18
+ object: v.picklist(["user", "group"]),
19
+ id: v.pipe(v.string(), v.minLength(1)),
20
+ });
21
+ export const customBlockPeopleFilterOperatorSchema = v.union([
22
+ v.strictObject({ contains: customBlockPersonFilterValueSchema }),
23
+ v.strictObject({ does_not_contain: customBlockPersonFilterValueSchema }),
24
+ emptyOperatorSchema,
25
+ ]);
26
+ /**
27
+ * Creator filters accept only human user targets.
28
+ * Returned creator values may refer to other actor types.
29
+ */
30
+ const customBlockCreatorFilterValueSchema = v.strictObject({
31
+ object: v.literal("user"),
32
+ id: v.pipe(v.string(), v.minLength(1), v.maxLength(2_000)),
33
+ });
34
+ export const customBlockCreatedByFilterOperatorSchema = v.union([
35
+ v.strictObject({ contains: customBlockCreatorFilterValueSchema }),
36
+ v.strictObject({ does_not_contain: customBlockCreatorFilterValueSchema }),
37
+ v.strictObject({ is_empty: v.literal(true) }),
38
+ v.strictObject({ is_not_empty: v.literal(true) }),
39
+ ]);
40
+ export const customBlockTextFilterOperatorSchema = v.union([
41
+ v.strictObject({ equals: v.string() }),
42
+ v.strictObject({ does_not_equal: v.string() }),
43
+ v.strictObject({ contains: v.string() }),
44
+ v.strictObject({ does_not_contain: v.string() }),
45
+ v.strictObject({ starts_with: v.string() }),
46
+ v.strictObject({ ends_with: v.string() }),
47
+ emptyOperatorSchema,
48
+ ]);
49
+ export const customBlockNumberFilterOperatorSchema = v.union([
50
+ v.strictObject({ equals: v.number() }),
51
+ v.strictObject({ does_not_equal: v.number() }),
52
+ v.strictObject({ greater_than: v.number() }),
53
+ v.strictObject({ less_than: v.number() }),
54
+ v.strictObject({ greater_than_or_equal_to: v.number() }),
55
+ v.strictObject({ less_than_or_equal_to: v.number() }),
56
+ emptyOperatorSchema,
57
+ ]);
58
+ export const customBlockCheckboxFilterOperatorSchema = v.union([
59
+ v.strictObject({ equals: v.boolean() }),
60
+ v.strictObject({ does_not_equal: v.boolean() }),
61
+ ]);
62
+ export const customBlockOptionFilterOperatorSchema = v.union([
63
+ v.strictObject({ equals: stringOrStringArraySchema }),
64
+ v.strictObject({ does_not_equal: stringOrStringArraySchema }),
65
+ emptyOperatorSchema,
66
+ ]);
67
+ export const customBlockStatusGroupNameSchema = v.picklist([
68
+ "To-do",
69
+ "In progress",
70
+ "Complete",
71
+ "Current",
72
+ "Future",
73
+ ]);
74
+ const customBlockStatusGroupFilterValueSchema = v.union([
75
+ customBlockStatusGroupNameSchema,
76
+ v.pipe(v.array(customBlockStatusGroupNameSchema), v.minLength(1), v.maxLength(5)),
77
+ ]);
78
+ export const customBlockStatusGroupFilterOperatorSchema = v.union([
79
+ v.strictObject({ group_equals: customBlockStatusGroupFilterValueSchema }),
80
+ v.strictObject({
81
+ group_does_not_equal: customBlockStatusGroupFilterValueSchema,
82
+ }),
83
+ ]);
84
+ export const customBlockStatusFilterOperatorSchema = v.union([
85
+ customBlockOptionFilterOperatorSchema,
86
+ customBlockStatusGroupFilterOperatorSchema,
87
+ ]);
88
+ export const customBlockContainsFilterOperatorSchema = v.union([
89
+ v.strictObject({ contains: stringOrStringArraySchema }),
90
+ v.strictObject({ contains_all: stringOrStringArraySchema }),
91
+ v.strictObject({ does_not_contain: stringOrStringArraySchema }),
92
+ emptyOperatorSchema,
93
+ ]);
94
+ const dateTargetSchema = v.picklist(["start_date", "end_date"]);
95
+ export const customBlockRelativeDateValueSchema = v.picklist([
96
+ "today",
97
+ "tomorrow",
98
+ "yesterday",
99
+ "one_week_ago",
100
+ "one_week_from_now",
101
+ "one_month_ago",
102
+ "one_month_from_now",
103
+ ]);
104
+ const dateComparisonValueSchema = v.union([
105
+ customBlockRelativeDateValueSchema,
106
+ v.string(),
107
+ ]);
108
+ export const customBlockDateFilterOperatorSchema = v.union([
109
+ v.strictObject({
110
+ target: v.optional(dateTargetSchema),
111
+ equals: dateComparisonValueSchema,
112
+ }),
113
+ v.strictObject({
114
+ target: v.optional(dateTargetSchema),
115
+ before: dateComparisonValueSchema,
116
+ }),
117
+ v.strictObject({
118
+ target: v.optional(dateTargetSchema),
119
+ after: dateComparisonValueSchema,
120
+ }),
121
+ v.strictObject({
122
+ target: v.optional(dateTargetSchema),
123
+ on_or_before: dateComparisonValueSchema,
124
+ }),
125
+ v.strictObject({
126
+ target: v.optional(dateTargetSchema),
127
+ on_or_after: dateComparisonValueSchema,
128
+ }),
129
+ v.strictObject({
130
+ target: v.optional(dateTargetSchema),
131
+ this_week: v.strictObject({}),
132
+ }),
133
+ v.strictObject({
134
+ target: v.optional(dateTargetSchema),
135
+ past_week: v.strictObject({}),
136
+ }),
137
+ v.strictObject({
138
+ target: v.optional(dateTargetSchema),
139
+ past_month: v.strictObject({}),
140
+ }),
141
+ v.strictObject({
142
+ target: v.optional(dateTargetSchema),
143
+ past_year: v.strictObject({}),
144
+ }),
145
+ v.strictObject({
146
+ target: v.optional(dateTargetSchema),
147
+ next_week: v.strictObject({}),
148
+ }),
149
+ v.strictObject({
150
+ target: v.optional(dateTargetSchema),
151
+ next_month: v.strictObject({}),
152
+ }),
153
+ v.strictObject({
154
+ target: v.optional(dateTargetSchema),
155
+ next_year: v.strictObject({}),
156
+ }),
157
+ v.strictObject({
158
+ target: v.optional(dateTargetSchema),
159
+ is_empty: v.literal(true),
160
+ }),
161
+ v.strictObject({
162
+ target: v.optional(dateTargetSchema),
163
+ is_not_empty: v.literal(true),
164
+ }),
165
+ ]);
166
+ export const resolvedCustomBlockDataSourcePropertyFilterSchema = v.union([
167
+ v.strictObject({
168
+ propertyId: v.string(),
169
+ relation: customBlockRelationFilterOperatorSchema,
170
+ }),
171
+ v.strictObject({
172
+ propertyId: v.string(),
173
+ created_by: customBlockCreatedByFilterOperatorSchema,
174
+ }),
175
+ v.strictObject({
176
+ propertyId: v.string(),
177
+ title: customBlockTextFilterOperatorSchema,
178
+ }),
179
+ v.strictObject({
180
+ propertyId: v.string(),
181
+ rich_text: customBlockTextFilterOperatorSchema,
182
+ }),
183
+ v.strictObject({
184
+ propertyId: v.string(),
185
+ url: customBlockTextFilterOperatorSchema,
186
+ }),
187
+ v.strictObject({
188
+ propertyId: v.string(),
189
+ email: customBlockTextFilterOperatorSchema,
190
+ }),
191
+ v.strictObject({
192
+ propertyId: v.string(),
193
+ phone_number: customBlockTextFilterOperatorSchema,
194
+ }),
195
+ v.strictObject({
196
+ propertyId: v.string(),
197
+ number: customBlockNumberFilterOperatorSchema,
198
+ }),
199
+ v.strictObject({
200
+ propertyId: v.string(),
201
+ checkbox: customBlockCheckboxFilterOperatorSchema,
202
+ }),
203
+ v.strictObject({
204
+ propertyId: v.string(),
205
+ select: customBlockOptionFilterOperatorSchema,
206
+ }),
207
+ v.strictObject({
208
+ propertyId: v.string(),
209
+ multi_select: customBlockContainsFilterOperatorSchema,
210
+ }),
211
+ v.strictObject({
212
+ propertyId: v.string(),
213
+ status: customBlockStatusFilterOperatorSchema,
214
+ }),
215
+ v.strictObject({
216
+ propertyId: v.string(),
217
+ date: customBlockDateFilterOperatorSchema,
218
+ }),
219
+ v.strictObject({
220
+ propertyId: v.string(),
221
+ people: customBlockPeopleFilterOperatorSchema,
222
+ }),
223
+ ]);
224
+ export const resolvedCustomBlockDataSourceFilterSchema = v.union([
225
+ resolvedCustomBlockDataSourcePropertyFilterSchema,
226
+ v.strictObject({
227
+ and: v.array(resolvedCustomBlockDataSourcePropertyFilterSchema),
228
+ }),
229
+ ]);
230
+ /** Maximum number of sort properties accepted in one data source query. */
231
+ export const CUSTOM_BLOCK_DATA_SOURCE_QUERY_MAX_SORTS = 10;
232
+ export const resolvedCustomBlockDataSourceSortSchema = v.strictObject({
233
+ propertyId: v.string(),
234
+ direction: notionSortDirectionSchema,
235
+ });
236
+ /**
237
+ * Message sent by the sandbox to ask the host for the current rows in a resolved
238
+ * Notion data source.
239
+ */
240
+ export const queryDataSourceMessageSchema = v.object({
241
+ type: v.literal("queryDataSource"),
242
+ /** Stable for the lifetime of this query subscription. */
243
+ subscriptionId: v.string(),
244
+ /** The raw Notion data source ID to read from. */
245
+ dataSourceId: notionDataSourceIdSchema,
246
+ /** The number of items to return in each subscription update. */
247
+ limit: v.number(),
248
+ /** A sandbox-resolved property filter. */
249
+ filter: v.optional(resolvedCustomBlockDataSourceFilterSchema),
250
+ /** Sandbox-resolved property sorts, in priority order. */
251
+ sorts: v.optional(v.array(resolvedCustomBlockDataSourceSortSchema)),
252
+ });