@notionhq/custom-blocks-host 0.1.23 → 0.1.25

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 (37) hide show
  1. package/README.md +13 -8
  2. package/dist/createCustomBlockHost.d.ts +8 -6
  3. package/dist/createCustomBlockHost.d.ts.map +1 -1
  4. package/dist/createCustomBlockHost.js +31 -18
  5. package/dist/lifecycle/normalizeHostToSandboxMessage.d.ts +6 -0
  6. package/dist/lifecycle/normalizeHostToSandboxMessage.d.ts.map +1 -0
  7. package/dist/lifecycle/normalizeHostToSandboxMessage.js +38 -0
  8. package/dist/protocol/dataSources/dataSource.d.ts +61 -6
  9. package/dist/protocol/dataSources/dataSource.js +35 -6
  10. package/dist/protocol/dataSources/propertySchema.d.ts +2 -0
  11. package/dist/protocol/dataSources/propertySchema.js +7 -0
  12. package/dist/protocol/messages/createPageResult.d.ts +1 -1
  13. package/dist/protocol/messages/getPage.d.ts +1 -1
  14. package/dist/protocol/messages/hostToSandbox.d.ts +10 -4
  15. package/dist/protocol/messages/init.d.ts +5 -2
  16. package/dist/protocol/messages/openPage.d.ts +1 -1
  17. package/dist/protocol/messages/pageChanged.d.ts +5 -2
  18. package/dist/protocol/messages/queryDataSource.d.ts +485 -485
  19. package/dist/protocol/messages/queryDataSource.js +43 -43
  20. package/dist/protocol/messages/queryDataSourceResult.d.ts +1 -1
  21. package/dist/protocol/messages/sandboxToHost.d.ts +178 -178
  22. package/dist/protocol/messages/updatePageResult.d.ts +1 -1
  23. package/dist/protocol/pages/page.d.ts +5 -2
  24. package/dist/protocol/pages/page.js +15 -9
  25. package/dist/protocol/protocolVersion.d.ts +1 -1
  26. package/dist/protocol/protocolVersion.js +1 -1
  27. package/dist/queries/validateQueryDataSourceFilter.d.ts +1 -1
  28. package/dist/queries/validateQueryDataSourceFilter.d.ts.map +1 -1
  29. package/dist/queries/validateQueryDataSourceFilter.js +8 -4
  30. package/dist/queries/validateQueryDataSourceSorts.d.ts +1 -1
  31. package/dist/queries/validateQueryDataSourceSorts.d.ts.map +1 -1
  32. package/dist/queries/validateQueryDataSourceSorts.js +3 -5
  33. package/package.json +1 -1
  34. package/src/createCustomBlockHost.ts +54 -31
  35. package/src/lifecycle/normalizeHostToSandboxMessage.ts +46 -0
  36. package/src/queries/validateQueryDataSourceFilter.ts +9 -5
  37. package/src/queries/validateQueryDataSourceSorts.ts +4 -10
@@ -1,119 +1,119 @@
1
1
  import * as v from "valibot";
2
2
  import { notionDataSourceIdSchema } from "../ids.js";
3
3
  const emptyOperatorSchema = v.union([
4
- v.object({ is_empty: v.literal(true) }),
5
- v.object({ is_not_empty: v.literal(true) }),
4
+ v.strictObject({ is_empty: v.literal(true) }),
5
+ v.strictObject({ is_not_empty: v.literal(true) }),
6
6
  ]);
7
7
  const stringOrStringArraySchema = v.union([v.string(), v.array(v.string())]);
8
- const customBlockPersonFilterValueSchema = v.object({
8
+ const customBlockPersonFilterValueSchema = v.strictObject({
9
9
  object: v.picklist(["user", "group"]),
10
10
  id: v.pipe(v.string(), v.minLength(1)),
11
11
  });
12
12
  export const customBlockPeopleFilterOperatorSchema = v.union([
13
- v.object({ contains: customBlockPersonFilterValueSchema }),
14
- v.object({ does_not_contain: customBlockPersonFilterValueSchema }),
13
+ v.strictObject({ contains: customBlockPersonFilterValueSchema }),
14
+ v.strictObject({ does_not_contain: customBlockPersonFilterValueSchema }),
15
15
  emptyOperatorSchema,
16
16
  ]);
17
17
  export const customBlockTextFilterOperatorSchema = v.union([
18
- v.object({ equals: v.string() }),
19
- v.object({ does_not_equal: v.string() }),
20
- v.object({ contains: v.string() }),
21
- v.object({ does_not_contain: v.string() }),
22
- v.object({ starts_with: v.string() }),
23
- v.object({ ends_with: v.string() }),
18
+ v.strictObject({ equals: v.string() }),
19
+ v.strictObject({ does_not_equal: v.string() }),
20
+ v.strictObject({ contains: v.string() }),
21
+ v.strictObject({ does_not_contain: v.string() }),
22
+ v.strictObject({ starts_with: v.string() }),
23
+ v.strictObject({ ends_with: v.string() }),
24
24
  emptyOperatorSchema,
25
25
  ]);
26
26
  export const customBlockNumberFilterOperatorSchema = v.union([
27
- v.object({ equals: v.number() }),
28
- v.object({ does_not_equal: v.number() }),
29
- v.object({ greater_than: v.number() }),
30
- v.object({ less_than: v.number() }),
31
- v.object({ greater_than_or_equal_to: v.number() }),
32
- v.object({ less_than_or_equal_to: v.number() }),
27
+ v.strictObject({ equals: v.number() }),
28
+ v.strictObject({ does_not_equal: v.number() }),
29
+ v.strictObject({ greater_than: v.number() }),
30
+ v.strictObject({ less_than: v.number() }),
31
+ v.strictObject({ greater_than_or_equal_to: v.number() }),
32
+ v.strictObject({ less_than_or_equal_to: v.number() }),
33
33
  emptyOperatorSchema,
34
34
  ]);
35
35
  export const customBlockCheckboxFilterOperatorSchema = v.union([
36
- v.object({ equals: v.boolean() }),
37
- v.object({ does_not_equal: v.boolean() }),
36
+ v.strictObject({ equals: v.boolean() }),
37
+ v.strictObject({ does_not_equal: v.boolean() }),
38
38
  ]);
39
39
  export const customBlockOptionFilterOperatorSchema = v.union([
40
- v.object({ equals: stringOrStringArraySchema }),
41
- v.object({ does_not_equal: stringOrStringArraySchema }),
40
+ v.strictObject({ equals: stringOrStringArraySchema }),
41
+ v.strictObject({ does_not_equal: stringOrStringArraySchema }),
42
42
  emptyOperatorSchema,
43
43
  ]);
44
44
  export const customBlockContainsFilterOperatorSchema = v.union([
45
- v.object({ contains: stringOrStringArraySchema }),
46
- v.object({ contains_all: stringOrStringArraySchema }),
47
- v.object({ does_not_contain: stringOrStringArraySchema }),
45
+ v.strictObject({ contains: stringOrStringArraySchema }),
46
+ v.strictObject({ contains_all: stringOrStringArraySchema }),
47
+ v.strictObject({ does_not_contain: stringOrStringArraySchema }),
48
48
  emptyOperatorSchema,
49
49
  ]);
50
50
  export const customBlockDateFilterOperatorSchema = v.union([
51
- v.object({ equals: v.string() }),
52
- v.object({ before: v.string() }),
53
- v.object({ after: v.string() }),
54
- v.object({ on_or_before: v.string() }),
55
- v.object({ on_or_after: v.string() }),
51
+ v.strictObject({ equals: v.string() }),
52
+ v.strictObject({ before: v.string() }),
53
+ v.strictObject({ after: v.string() }),
54
+ v.strictObject({ on_or_before: v.string() }),
55
+ v.strictObject({ on_or_after: v.string() }),
56
56
  emptyOperatorSchema,
57
57
  ]);
58
58
  export const resolvedCustomBlockDataSourcePropertyFilterSchema = v.union([
59
- v.object({
59
+ v.strictObject({
60
60
  propertyId: v.string(),
61
61
  title: customBlockTextFilterOperatorSchema,
62
62
  }),
63
- v.object({
63
+ v.strictObject({
64
64
  propertyId: v.string(),
65
65
  rich_text: customBlockTextFilterOperatorSchema,
66
66
  }),
67
- v.object({
67
+ v.strictObject({
68
68
  propertyId: v.string(),
69
69
  url: customBlockTextFilterOperatorSchema,
70
70
  }),
71
- v.object({
71
+ v.strictObject({
72
72
  propertyId: v.string(),
73
73
  email: customBlockTextFilterOperatorSchema,
74
74
  }),
75
- v.object({
75
+ v.strictObject({
76
76
  propertyId: v.string(),
77
77
  phone_number: customBlockTextFilterOperatorSchema,
78
78
  }),
79
- v.object({
79
+ v.strictObject({
80
80
  propertyId: v.string(),
81
81
  number: customBlockNumberFilterOperatorSchema,
82
82
  }),
83
- v.object({
83
+ v.strictObject({
84
84
  propertyId: v.string(),
85
85
  checkbox: customBlockCheckboxFilterOperatorSchema,
86
86
  }),
87
- v.object({
87
+ v.strictObject({
88
88
  propertyId: v.string(),
89
89
  select: customBlockOptionFilterOperatorSchema,
90
90
  }),
91
- v.object({
91
+ v.strictObject({
92
92
  propertyId: v.string(),
93
93
  multi_select: customBlockContainsFilterOperatorSchema,
94
94
  }),
95
- v.object({
95
+ v.strictObject({
96
96
  propertyId: v.string(),
97
97
  status: customBlockOptionFilterOperatorSchema,
98
98
  }),
99
- v.object({
99
+ v.strictObject({
100
100
  propertyId: v.string(),
101
101
  date: customBlockDateFilterOperatorSchema,
102
102
  }),
103
- v.object({
103
+ v.strictObject({
104
104
  propertyId: v.string(),
105
105
  people: customBlockPeopleFilterOperatorSchema,
106
106
  }),
107
107
  ]);
108
108
  export const resolvedCustomBlockDataSourceFilterSchema = v.union([
109
109
  resolvedCustomBlockDataSourcePropertyFilterSchema,
110
- v.object({
110
+ v.strictObject({
111
111
  and: v.array(resolvedCustomBlockDataSourcePropertyFilterSchema),
112
112
  }),
113
113
  ]);
114
114
  /** Maximum number of sort properties accepted in one data source query. */
115
115
  export const CUSTOM_BLOCK_DATA_SOURCE_QUERY_MAX_SORTS = 10;
116
- export const resolvedCustomBlockDataSourceSortSchema = v.object({
116
+ export const resolvedCustomBlockDataSourceSortSchema = v.strictObject({
117
117
  propertyId: v.string(),
118
118
  direction: v.picklist(["ascending", "descending"]),
119
119
  });
@@ -1,7 +1,7 @@
1
1
  import * as v from "valibot";
2
2
  import type { CustomBlockErrorCode, CustomBlockErrorInfo } from "../errors.js";
3
3
  export declare const customBlockQueryDataSourceErrorCodeSchema: v.StringSchema<undefined>;
4
- export type CustomBlockQueryDataSourceErrorCode = CustomBlockErrorCode<"query_data_source_failed" | "invalid_data_source_query" | "invalid_data_source_query_filter" | "invalid_data_source_query_sort" | "unknown_data_source_key" | "unmapped_data_source">;
4
+ export type CustomBlockQueryDataSourceErrorCode = CustomBlockErrorCode<"query_data_source_failed" | "invalid_data_source_query" | "invalid_data_source_query_filter" | "invalid_data_source_query_sort" | "unknown_data_source_key" | "unmapped_data_source" | "data_source_schema_unavailable">;
5
5
  export type CustomBlockQueryDataSourceErrorInfo = CustomBlockErrorInfo<CustomBlockQueryDataSourceErrorCode>;
6
6
  export declare const customBlockQueryDataSourceErrorInfoSchema: v.ObjectSchema<{
7
7
  readonly code: v.StringSchema<undefined>;