@notionhq/custom-blocks-host 0.1.25 → 0.1.27
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/protocol/messages/queryDataSource.d.ts +101 -0
- package/dist/protocol/messages/queryDataSource.js +18 -0
- package/dist/protocol/messages/sandboxToHost.d.ts +34 -0
- package/dist/queries/validateQueryDataSourceFilter.js +3 -2
- package/package.json +1 -1
- package/src/queries/validateQueryDataSourceFilter.ts +3 -2
|
@@ -20,6 +20,22 @@ export declare const customBlockPeopleFilterOperatorSchema: v.UnionSchema<[v.Str
|
|
|
20
20
|
readonly is_not_empty: v.LiteralSchema<true, undefined>;
|
|
21
21
|
}, undefined>], undefined>], undefined>;
|
|
22
22
|
export type CustomBlockPeopleFilterOperator = v.InferOutput<typeof customBlockPeopleFilterOperatorSchema>;
|
|
23
|
+
export declare const customBlockCreatedByFilterOperatorSchema: v.UnionSchema<[v.StrictObjectSchema<{
|
|
24
|
+
readonly contains: v.StrictObjectSchema<{
|
|
25
|
+
readonly object: v.LiteralSchema<"user", undefined>;
|
|
26
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 2000, undefined>]>;
|
|
27
|
+
}, undefined>;
|
|
28
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
29
|
+
readonly does_not_contain: v.StrictObjectSchema<{
|
|
30
|
+
readonly object: v.LiteralSchema<"user", undefined>;
|
|
31
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 2000, undefined>]>;
|
|
32
|
+
}, undefined>;
|
|
33
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
34
|
+
readonly is_empty: v.LiteralSchema<true, undefined>;
|
|
35
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
36
|
+
readonly is_not_empty: v.LiteralSchema<true, undefined>;
|
|
37
|
+
}, undefined>], undefined>;
|
|
38
|
+
export type CustomBlockCreatedByFilterOperator = v.InferOutput<typeof customBlockCreatedByFilterOperatorSchema>;
|
|
23
39
|
export declare const customBlockTextFilterOperatorSchema: v.UnionSchema<[v.StrictObjectSchema<{
|
|
24
40
|
readonly equals: v.StringSchema<undefined>;
|
|
25
41
|
}, undefined>, v.StrictObjectSchema<{
|
|
@@ -101,6 +117,23 @@ export declare const customBlockDateFilterOperatorSchema: v.UnionSchema<[v.Stric
|
|
|
101
117
|
}, undefined>], undefined>], undefined>;
|
|
102
118
|
export type CustomBlockDateFilterOperator = v.InferOutput<typeof customBlockDateFilterOperatorSchema>;
|
|
103
119
|
export declare const resolvedCustomBlockDataSourcePropertyFilterSchema: v.UnionSchema<[v.StrictObjectSchema<{
|
|
120
|
+
readonly propertyId: v.StringSchema<undefined>;
|
|
121
|
+
readonly created_by: v.UnionSchema<[v.StrictObjectSchema<{
|
|
122
|
+
readonly contains: v.StrictObjectSchema<{
|
|
123
|
+
readonly object: v.LiteralSchema<"user", undefined>;
|
|
124
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 2000, undefined>]>;
|
|
125
|
+
}, undefined>;
|
|
126
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
127
|
+
readonly does_not_contain: v.StrictObjectSchema<{
|
|
128
|
+
readonly object: v.LiteralSchema<"user", undefined>;
|
|
129
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 2000, undefined>]>;
|
|
130
|
+
}, undefined>;
|
|
131
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
132
|
+
readonly is_empty: v.LiteralSchema<true, undefined>;
|
|
133
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
134
|
+
readonly is_not_empty: v.LiteralSchema<true, undefined>;
|
|
135
|
+
}, undefined>], undefined>;
|
|
136
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
104
137
|
readonly propertyId: v.StringSchema<undefined>;
|
|
105
138
|
readonly title: v.UnionSchema<[v.StrictObjectSchema<{
|
|
106
139
|
readonly equals: v.StringSchema<undefined>;
|
|
@@ -293,6 +326,23 @@ export declare const resolvedCustomBlockDataSourcePropertyFilterSchema: v.UnionS
|
|
|
293
326
|
}, undefined>], undefined>;
|
|
294
327
|
export type ResolvedCustomBlockDataSourcePropertyFilter = v.InferOutput<typeof resolvedCustomBlockDataSourcePropertyFilterSchema>;
|
|
295
328
|
export declare const resolvedCustomBlockDataSourceFilterSchema: v.UnionSchema<[v.UnionSchema<[v.StrictObjectSchema<{
|
|
329
|
+
readonly propertyId: v.StringSchema<undefined>;
|
|
330
|
+
readonly created_by: v.UnionSchema<[v.StrictObjectSchema<{
|
|
331
|
+
readonly contains: v.StrictObjectSchema<{
|
|
332
|
+
readonly object: v.LiteralSchema<"user", undefined>;
|
|
333
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 2000, undefined>]>;
|
|
334
|
+
}, undefined>;
|
|
335
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
336
|
+
readonly does_not_contain: v.StrictObjectSchema<{
|
|
337
|
+
readonly object: v.LiteralSchema<"user", undefined>;
|
|
338
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 2000, undefined>]>;
|
|
339
|
+
}, undefined>;
|
|
340
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
341
|
+
readonly is_empty: v.LiteralSchema<true, undefined>;
|
|
342
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
343
|
+
readonly is_not_empty: v.LiteralSchema<true, undefined>;
|
|
344
|
+
}, undefined>], undefined>;
|
|
345
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
296
346
|
readonly propertyId: v.StringSchema<undefined>;
|
|
297
347
|
readonly title: v.UnionSchema<[v.StrictObjectSchema<{
|
|
298
348
|
readonly equals: v.StringSchema<undefined>;
|
|
@@ -484,6 +534,23 @@ export declare const resolvedCustomBlockDataSourceFilterSchema: v.UnionSchema<[v
|
|
|
484
534
|
}, undefined>], undefined>], undefined>;
|
|
485
535
|
}, undefined>], undefined>, v.StrictObjectSchema<{
|
|
486
536
|
readonly and: v.ArraySchema<v.UnionSchema<[v.StrictObjectSchema<{
|
|
537
|
+
readonly propertyId: v.StringSchema<undefined>;
|
|
538
|
+
readonly created_by: v.UnionSchema<[v.StrictObjectSchema<{
|
|
539
|
+
readonly contains: v.StrictObjectSchema<{
|
|
540
|
+
readonly object: v.LiteralSchema<"user", undefined>;
|
|
541
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 2000, undefined>]>;
|
|
542
|
+
}, undefined>;
|
|
543
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
544
|
+
readonly does_not_contain: v.StrictObjectSchema<{
|
|
545
|
+
readonly object: v.LiteralSchema<"user", undefined>;
|
|
546
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 2000, undefined>]>;
|
|
547
|
+
}, undefined>;
|
|
548
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
549
|
+
readonly is_empty: v.LiteralSchema<true, undefined>;
|
|
550
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
551
|
+
readonly is_not_empty: v.LiteralSchema<true, undefined>;
|
|
552
|
+
}, undefined>], undefined>;
|
|
553
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
487
554
|
readonly propertyId: v.StringSchema<undefined>;
|
|
488
555
|
readonly title: v.UnionSchema<[v.StrictObjectSchema<{
|
|
489
556
|
readonly equals: v.StringSchema<undefined>;
|
|
@@ -700,6 +767,23 @@ export declare const queryDataSourceMessageSchema: v.ObjectSchema<{
|
|
|
700
767
|
readonly limit: v.NumberSchema<undefined>;
|
|
701
768
|
/** A sandbox-resolved property filter. */
|
|
702
769
|
readonly filter: v.OptionalSchema<v.UnionSchema<[v.UnionSchema<[v.StrictObjectSchema<{
|
|
770
|
+
readonly propertyId: v.StringSchema<undefined>;
|
|
771
|
+
readonly created_by: v.UnionSchema<[v.StrictObjectSchema<{
|
|
772
|
+
readonly contains: v.StrictObjectSchema<{
|
|
773
|
+
readonly object: v.LiteralSchema<"user", undefined>;
|
|
774
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 2000, undefined>]>;
|
|
775
|
+
}, undefined>;
|
|
776
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
777
|
+
readonly does_not_contain: v.StrictObjectSchema<{
|
|
778
|
+
readonly object: v.LiteralSchema<"user", undefined>;
|
|
779
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 2000, undefined>]>;
|
|
780
|
+
}, undefined>;
|
|
781
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
782
|
+
readonly is_empty: v.LiteralSchema<true, undefined>;
|
|
783
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
784
|
+
readonly is_not_empty: v.LiteralSchema<true, undefined>;
|
|
785
|
+
}, undefined>], undefined>;
|
|
786
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
703
787
|
readonly propertyId: v.StringSchema<undefined>;
|
|
704
788
|
readonly title: v.UnionSchema<[v.StrictObjectSchema<{
|
|
705
789
|
readonly equals: v.StringSchema<undefined>;
|
|
@@ -891,6 +975,23 @@ export declare const queryDataSourceMessageSchema: v.ObjectSchema<{
|
|
|
891
975
|
}, undefined>], undefined>], undefined>;
|
|
892
976
|
}, undefined>], undefined>, v.StrictObjectSchema<{
|
|
893
977
|
readonly and: v.ArraySchema<v.UnionSchema<[v.StrictObjectSchema<{
|
|
978
|
+
readonly propertyId: v.StringSchema<undefined>;
|
|
979
|
+
readonly created_by: v.UnionSchema<[v.StrictObjectSchema<{
|
|
980
|
+
readonly contains: v.StrictObjectSchema<{
|
|
981
|
+
readonly object: v.LiteralSchema<"user", undefined>;
|
|
982
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 2000, undefined>]>;
|
|
983
|
+
}, undefined>;
|
|
984
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
985
|
+
readonly does_not_contain: v.StrictObjectSchema<{
|
|
986
|
+
readonly object: v.LiteralSchema<"user", undefined>;
|
|
987
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 2000, undefined>]>;
|
|
988
|
+
}, undefined>;
|
|
989
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
990
|
+
readonly is_empty: v.LiteralSchema<true, undefined>;
|
|
991
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
992
|
+
readonly is_not_empty: v.LiteralSchema<true, undefined>;
|
|
993
|
+
}, undefined>], undefined>;
|
|
994
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
894
995
|
readonly propertyId: v.StringSchema<undefined>;
|
|
895
996
|
readonly title: v.UnionSchema<[v.StrictObjectSchema<{
|
|
896
997
|
readonly equals: v.StringSchema<undefined>;
|
|
@@ -14,6 +14,20 @@ export const customBlockPeopleFilterOperatorSchema = v.union([
|
|
|
14
14
|
v.strictObject({ does_not_contain: customBlockPersonFilterValueSchema }),
|
|
15
15
|
emptyOperatorSchema,
|
|
16
16
|
]);
|
|
17
|
+
/**
|
|
18
|
+
* Creator filters accept only human user targets.
|
|
19
|
+
* Returned creator values may refer to other actor types.
|
|
20
|
+
*/
|
|
21
|
+
const customBlockCreatorFilterValueSchema = v.strictObject({
|
|
22
|
+
object: v.literal("user"),
|
|
23
|
+
id: v.pipe(v.string(), v.minLength(1), v.maxLength(2_000)),
|
|
24
|
+
});
|
|
25
|
+
export const customBlockCreatedByFilterOperatorSchema = v.union([
|
|
26
|
+
v.strictObject({ contains: customBlockCreatorFilterValueSchema }),
|
|
27
|
+
v.strictObject({ does_not_contain: customBlockCreatorFilterValueSchema }),
|
|
28
|
+
v.strictObject({ is_empty: v.literal(true) }),
|
|
29
|
+
v.strictObject({ is_not_empty: v.literal(true) }),
|
|
30
|
+
]);
|
|
17
31
|
export const customBlockTextFilterOperatorSchema = v.union([
|
|
18
32
|
v.strictObject({ equals: v.string() }),
|
|
19
33
|
v.strictObject({ does_not_equal: v.string() }),
|
|
@@ -56,6 +70,10 @@ export const customBlockDateFilterOperatorSchema = v.union([
|
|
|
56
70
|
emptyOperatorSchema,
|
|
57
71
|
]);
|
|
58
72
|
export const resolvedCustomBlockDataSourcePropertyFilterSchema = v.union([
|
|
73
|
+
v.strictObject({
|
|
74
|
+
propertyId: v.string(),
|
|
75
|
+
created_by: customBlockCreatedByFilterOperatorSchema,
|
|
76
|
+
}),
|
|
59
77
|
v.strictObject({
|
|
60
78
|
propertyId: v.string(),
|
|
61
79
|
title: customBlockTextFilterOperatorSchema,
|
|
@@ -59,6 +59,23 @@ export declare const sandboxToHostMessageSchema: v.VariantSchema<"type", [v.Vari
|
|
|
59
59
|
readonly dataSourceId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionDataSourceId">]>;
|
|
60
60
|
readonly limit: v.NumberSchema<undefined>;
|
|
61
61
|
readonly filter: v.OptionalSchema<v.UnionSchema<[v.UnionSchema<[v.StrictObjectSchema<{
|
|
62
|
+
readonly propertyId: v.StringSchema<undefined>;
|
|
63
|
+
readonly created_by: v.UnionSchema<[v.StrictObjectSchema<{
|
|
64
|
+
readonly contains: v.StrictObjectSchema<{
|
|
65
|
+
readonly object: v.LiteralSchema<"user", undefined>;
|
|
66
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 2000, undefined>]>;
|
|
67
|
+
}, undefined>;
|
|
68
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
69
|
+
readonly does_not_contain: v.StrictObjectSchema<{
|
|
70
|
+
readonly object: v.LiteralSchema<"user", undefined>;
|
|
71
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 2000, undefined>]>;
|
|
72
|
+
}, undefined>;
|
|
73
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
74
|
+
readonly is_empty: v.LiteralSchema<true, undefined>;
|
|
75
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
76
|
+
readonly is_not_empty: v.LiteralSchema<true, undefined>;
|
|
77
|
+
}, undefined>], undefined>;
|
|
78
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
62
79
|
readonly propertyId: v.StringSchema<undefined>;
|
|
63
80
|
readonly title: v.UnionSchema<[v.StrictObjectSchema<{
|
|
64
81
|
readonly equals: v.StringSchema<undefined>;
|
|
@@ -250,6 +267,23 @@ export declare const sandboxToHostMessageSchema: v.VariantSchema<"type", [v.Vari
|
|
|
250
267
|
}, undefined>], undefined>], undefined>;
|
|
251
268
|
}, undefined>], undefined>, v.StrictObjectSchema<{
|
|
252
269
|
readonly and: v.ArraySchema<v.UnionSchema<[v.StrictObjectSchema<{
|
|
270
|
+
readonly propertyId: v.StringSchema<undefined>;
|
|
271
|
+
readonly created_by: v.UnionSchema<[v.StrictObjectSchema<{
|
|
272
|
+
readonly contains: v.StrictObjectSchema<{
|
|
273
|
+
readonly object: v.LiteralSchema<"user", undefined>;
|
|
274
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 2000, undefined>]>;
|
|
275
|
+
}, undefined>;
|
|
276
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
277
|
+
readonly does_not_contain: v.StrictObjectSchema<{
|
|
278
|
+
readonly object: v.LiteralSchema<"user", undefined>;
|
|
279
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 2000, undefined>]>;
|
|
280
|
+
}, undefined>;
|
|
281
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
282
|
+
readonly is_empty: v.LiteralSchema<true, undefined>;
|
|
283
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
284
|
+
readonly is_not_empty: v.LiteralSchema<true, undefined>;
|
|
285
|
+
}, undefined>], undefined>;
|
|
286
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
253
287
|
readonly propertyId: v.StringSchema<undefined>;
|
|
254
288
|
readonly title: v.UnionSchema<[v.StrictObjectSchema<{
|
|
255
289
|
readonly equals: v.StringSchema<undefined>;
|
|
@@ -21,10 +21,11 @@ function validatePropertyFilter(filter, collectionSchema) {
|
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
23
|
const propertySchema = collectionSchema.propertiesById[filter.propertyId];
|
|
24
|
-
|
|
24
|
+
const branch = Object.keys(filter).find(key => key !== "propertyId");
|
|
25
|
+
if (branch !== propertySchema.type) {
|
|
25
26
|
return {
|
|
26
27
|
code: "invalid_data_source_query_filter",
|
|
27
|
-
message: `Data source query filter branch "
|
|
28
|
+
message: `Data source query filter branch "${branch}" does not match property type "${propertySchema.type}".`,
|
|
28
29
|
isRetryable: false,
|
|
29
30
|
};
|
|
30
31
|
}
|
package/package.json
CHANGED
|
@@ -43,10 +43,11 @@ function validatePropertyFilter(
|
|
|
43
43
|
}
|
|
44
44
|
const propertySchema = collectionSchema.propertiesById[filter.propertyId]
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
const branch = Object.keys(filter).find(key => key !== "propertyId")
|
|
47
|
+
if (branch !== propertySchema.type) {
|
|
47
48
|
return {
|
|
48
49
|
code: "invalid_data_source_query_filter",
|
|
49
|
-
message: `Data source query filter branch "
|
|
50
|
+
message: `Data source query filter branch "${branch}" does not match property type "${propertySchema.type}".`,
|
|
50
51
|
isRetryable: false,
|
|
51
52
|
}
|
|
52
53
|
}
|