@notionhq/apps 0.0.15 → 0.0.17

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 (70) hide show
  1. package/AGENTS.md +13 -0
  2. package/README.md +69 -2
  3. package/dist/connections.d.ts +39 -11
  4. package/dist/connections.d.ts.map +1 -1
  5. package/dist/connections.js +85 -21
  6. package/dist/index.d.ts +1 -0
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +2 -0
  9. package/dist/notion-as-code/database.d.ts +26 -3
  10. package/dist/notion-as-code/database.d.ts.map +1 -1
  11. package/dist/notion-as-code/database.js +27 -0
  12. package/dist/notion-as-code/handles.d.ts +2 -0
  13. package/dist/notion-as-code/handles.d.ts.map +1 -1
  14. package/dist/notion-as-code/handles.js +2 -0
  15. package/dist/notion-as-code/index.d.ts +4 -1
  16. package/dist/notion-as-code/index.d.ts.map +1 -1
  17. package/dist/notion-as-code/intents.d.ts +2 -1
  18. package/dist/notion-as-code/intents.d.ts.map +1 -1
  19. package/dist/notion-as-code/page.d.ts +3 -3
  20. package/dist/notion-as-code/page.d.ts.map +1 -1
  21. package/dist/notion-as-code/page.js +2 -7
  22. package/dist/notion-as-code/teamspace.d.ts +3 -3
  23. package/dist/notion-as-code/teamspace.d.ts.map +1 -1
  24. package/dist/notion-as-code/teamspace.js +2 -7
  25. package/dist/notion-as-code/view.d.ts +12 -0
  26. package/dist/notion-as-code/view.d.ts.map +1 -0
  27. package/dist/notion-as-code/view.js +13 -0
  28. package/dist/notion-as-code/views-types.test.d.ts +2 -0
  29. package/dist/notion-as-code/views-types.test.d.ts.map +1 -0
  30. package/dist/notion-as-code/views.d.ts +469 -0
  31. package/dist/notion-as-code/views.d.ts.map +1 -0
  32. package/dist/notion-as-code/views.js +0 -0
  33. package/dist/oauth.d.ts +11 -0
  34. package/dist/oauth.d.ts.map +1 -0
  35. package/dist/oauth.js +26 -0
  36. package/dist/providers.generated.d.ts +26 -86
  37. package/dist/providers.generated.d.ts.map +1 -1
  38. package/dist/providers.generated.js +54 -66
  39. package/dist/triggers.generated.d.ts +3 -3
  40. package/dist/triggers.generated.d.ts.map +1 -1
  41. package/dist/workflow.d.ts +8 -8
  42. package/dist/workflow.d.ts.map +1 -1
  43. package/dist/workflow.js +12 -6
  44. package/docs/CONNECTIONS.md +70 -22
  45. package/package.json +3 -1
  46. package/skills/connections/SKILL.md +85 -0
  47. package/skills/custom-blocks/SKILL.md +45 -0
  48. package/skills/notion-as-code/SKILL.md +195 -0
  49. package/skills/sync/SKILL.md +98 -0
  50. package/skills/workflow/SKILL.md +123 -0
  51. package/src/cli/build.test.ts +95 -3
  52. package/src/connections.test.ts +205 -41
  53. package/src/connections.ts +144 -38
  54. package/src/index.ts +1 -0
  55. package/src/notion-as-code/database.ts +75 -5
  56. package/src/notion-as-code/handles.ts +2 -0
  57. package/src/notion-as-code/index.ts +59 -0
  58. package/src/notion-as-code/intents.ts +2 -2
  59. package/src/notion-as-code/page.ts +3 -11
  60. package/src/notion-as-code/teamspace.ts +3 -11
  61. package/src/notion-as-code/view.ts +23 -0
  62. package/src/notion-as-code/views-types.test.ts +59 -0
  63. package/src/notion-as-code/views.ts +554 -0
  64. package/src/oauth.ts +40 -0
  65. package/src/providers.generated.ts +68 -163
  66. package/src/triggers.generated.ts +4 -4
  67. package/src/workflow-connections-types.test.ts +16 -10
  68. package/src/workflow-types.test.ts +88 -16
  69. package/src/workflow.test.ts +45 -17
  70. package/src/workflow.ts +31 -17
@@ -1,5 +1,5 @@
1
- import { type DataSourceDefinition, type NotionAsCodeIcon, type ResourceId } from "./intents.js";
2
- import { type ChildDatabaseArgs, type DatabaseHandle } from "./database.js";
1
+ import { type NotionAsCodeIcon, type ResourceId } from "./intents.js";
2
+ import { type ChildDatabaseFactory } from "./database.js";
3
3
  import { type ChildPageArgs, type PageHandle } from "./page.js";
4
4
  export type TeamspaceArgs = {
5
5
  resourceId: ResourceId;
@@ -10,7 +10,7 @@ export type TeamspaceArgs = {
10
10
  };
11
11
  export type TeamspaceHandle = {
12
12
  readonly resourceId: string;
13
- addDatabase: <const DataSources extends readonly DataSourceDefinition[]>(args: ChildDatabaseArgs<DataSources>) => DatabaseHandle<DataSources>;
13
+ addDatabase: ChildDatabaseFactory;
14
14
  addPage: (args: ChildPageArgs) => PageHandle;
15
15
  };
16
16
  /** Declare a teamspace that Apps automatically creates in its workspace. */
@@ -1 +1 @@
1
- {"version":3,"file":"teamspace.d.ts","sourceRoot":"","sources":["../../src/notion-as-code/teamspace.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,UAAU,EAEf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAY,KAAK,iBAAiB,EAAE,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AACtF,OAAO,EAAc,KAAK,aAAa,EAAE,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAI5E,MAAM,MAAM,aAAa,GAAG;IAC3B,UAAU,EAAE,UAAU,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,SAAS,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC;IACvD,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,WAAW,EAAE,CAAC,KAAK,CAAC,WAAW,SAAS,SAAS,oBAAoB,EAAE,EACtE,IAAI,EAAE,iBAAiB,CAAC,WAAW,CAAC,KAChC,cAAc,CAAC,WAAW,CAAC,CAAC;IACjC,OAAO,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,UAAU,CAAC;CAC7C,CAAC;AAEF,4EAA4E;AAC5E,wBAAgB,SAAS,CAAC,IAAI,EAAE,aAAa,GAAG,eAAe,CAoB9D"}
1
+ {"version":3,"file":"teamspace.d.ts","sourceRoot":"","sources":["../../src/notion-as-code/teamspace.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,KAAK,gBAAgB,EACrB,KAAK,UAAU,EAEf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAuB,KAAK,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAC/E,OAAO,EAAc,KAAK,aAAa,EAAE,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAI5E,MAAM,MAAM,aAAa,GAAG;IAC3B,UAAU,EAAE,UAAU,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,SAAS,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC;IACvD,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,WAAW,EAAE,oBAAoB,CAAC;IAClC,OAAO,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,UAAU,CAAC;CAC7C,CAAC;AAEF,4EAA4E;AAC5E,wBAAgB,SAAS,CAAC,IAAI,EAAE,aAAa,GAAG,eAAe,CAe9D"}
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  APPS_WORKSPACE_RESOURCE_ID
3
3
  } from "./intents.js";
4
- import { database } from "./database.js";
4
+ import { createChildDatabase } from "./database.js";
5
5
  import { createPage } from "./page.js";
6
6
  import { recordIntent } from "./recorder.js";
7
7
  import { assertUserResourceId } from "./resource.js";
@@ -14,12 +14,7 @@ function teamspace(args) {
14
14
  });
15
15
  return {
16
16
  resourceId: args.resourceId,
17
- addDatabase(databaseArgs) {
18
- return database({
19
- ...databaseArgs,
20
- parent: { type: "resourceId", resourceId: args.resourceId }
21
- });
22
- },
17
+ addDatabase: createChildDatabase({ type: "resourceId", resourceId: args.resourceId }),
23
18
  addPage(pageArgs) {
24
19
  return createPage(pageArgs, { type: "resourceId", resourceId: args.resourceId });
25
20
  }
@@ -0,0 +1,12 @@
1
+ import type { ResourceId } from "./intents.js";
2
+ import type { ViewSchema } from "./views.js";
3
+ /** Declare a view attached to a database resource. */
4
+ export type ViewArgs = ViewSchema & {
5
+ databaseResourceId: ResourceId;
6
+ };
7
+ export type ViewHandle = {
8
+ readonly resourceId: string;
9
+ };
10
+ /** Record a database view for provisioning without making a Notion API request. */
11
+ export declare function view(args: ViewArgs): ViewHandle;
12
+ //# sourceMappingURL=view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/notion-as-code/view.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,sDAAsD;AACtD,MAAM,MAAM,QAAQ,GAAG,UAAU,GAAG;IACnC,kBAAkB,EAAE,UAAU,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACxB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,mFAAmF;AACnF,wBAAgB,IAAI,CAAC,IAAI,EAAE,QAAQ,GAAG,UAAU,CAO/C"}
@@ -0,0 +1,13 @@
1
+ import { recordIntent } from "./recorder.js";
2
+ import { assertUserResourceId } from "./resource.js";
3
+ function view(args) {
4
+ assertUserResourceId(args.resourceId);
5
+ assertUserResourceId(args.databaseResourceId);
6
+ assertUserResourceId(args.dataSourceResourceId);
7
+ const { databaseResourceId, ...schema } = args;
8
+ recordIntent({ type: "view", databaseResourceId, view: schema });
9
+ return { resourceId: args.resourceId };
10
+ }
11
+ export {
12
+ view
13
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=views-types.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"views-types.test.d.ts","sourceRoot":"","sources":["../../src/notion-as-code/views-types.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,469 @@
1
+ import type { NotionAsCodeIcon, NotionAsCodeProperty, ResourceId } from "./intents.js";
2
+ export type ViewType = "table" | "board" | "calendar" | "list" | "gallery" | "feed" | "timeline";
3
+ export type PropertyVisibility = "show" | "hide" | "hide_if_empty";
4
+ /**
5
+ * Format for a single visible property entry in a view (table / board / list /
6
+ * gallery / feed / timeline).
7
+ *
8
+ * `property` must be the `resourceId` of a property in the view's data
9
+ * source, matching the same convention used by board `groupBy.property`,
10
+ * `calendarBy`, and `timelineBy`.
11
+ *
12
+ */
13
+ export type PropertyFormat = {
14
+ /** ResourceId of the property in the view's data source. */
15
+ property: ResourceId;
16
+ visible?: boolean;
17
+ width?: number;
18
+ visibility?: PropertyVisibility;
19
+ };
20
+ /**
21
+ * Format for a single column entry in a board view.
22
+ *
23
+ * `property` must be the `resourceId` of a property in the view's data
24
+ * source, matching the same convention used by `PropertyFormat.property`
25
+ * and board `groupBy.property`.
26
+ *
27
+ */
28
+ export type GroupFormat = {
29
+ /** ResourceId of the property in the view's data source. */
30
+ property: ResourceId;
31
+ hidden?: boolean;
32
+ value?: {
33
+ type: string;
34
+ value?: string | boolean | number | null;
35
+ };
36
+ };
37
+ export type GroupByFormatBase = {
38
+ /** ResourceId of the property in the view's data source. */
39
+ property: ResourceId;
40
+ /** Whether groups with no pages are visible. Defaults to "show". */
41
+ emptyGroupVisibility?: "show" | "hide";
42
+ statusBy?: never;
43
+ };
44
+ export type SelectGroupByFormat = GroupByFormatBase & {
45
+ type: "select" | "multi_select";
46
+ };
47
+ export type StatusGroupByFormat = Omit<GroupByFormatBase, "statusBy"> & {
48
+ type: "status";
49
+ /** Groups status values by their canonical status group or individual option. */
50
+ statusBy?: "group" | "option";
51
+ };
52
+ export type PersonGroupByFormat = GroupByFormatBase & {
53
+ type: "person" | "created_by" | "last_edited_by";
54
+ };
55
+ export type DateGroupByFormat = GroupByFormatBase & {
56
+ type: "date" | "created_time" | "last_edited_time" | "last_visited_time";
57
+ };
58
+ export type TextGroupByFormat = GroupByFormatBase & {
59
+ type: "text" | "title" | "url" | "email" | "phone_number";
60
+ };
61
+ export type NumberGroupByFormat = GroupByFormatBase & {
62
+ type: "number";
63
+ };
64
+ export type CheckboxGroupByFormat = GroupByFormatBase & {
65
+ type: "checkbox";
66
+ };
67
+ export type RelationGroupByFormat = GroupByFormatBase & {
68
+ type: "relation";
69
+ };
70
+ export type LocationGroupByFormat = GroupByFormatBase & {
71
+ type: "location";
72
+ };
73
+ export type FormulaGroupByFormat = GroupByFormatBase & {
74
+ type: "formula";
75
+ };
76
+ /**
77
+ * Board view group-by configuration.
78
+ *
79
+ * `property` must be the `resourceId` of a property in the view's data
80
+ * source, matching the same convention used by `PropertyFormat.property`,
81
+ * `CalendarViewSchema.calendarBy`, and `TimelineViewSchema.timelineBy`.
82
+ *
83
+ */
84
+ export type GroupByFormat = SelectGroupByFormat | StatusGroupByFormat | PersonGroupByFormat | DateGroupByFormat | TextGroupByFormat | NumberGroupByFormat | CheckboxGroupByFormat | RelationGroupByFormat | LocationGroupByFormat | FormulaGroupByFormat;
85
+ export type CoverFormat = {
86
+ type: "page_cover";
87
+ } | {
88
+ type: "page_content";
89
+ } | {
90
+ type: "page_content_first";
91
+ } | {
92
+ type: "property";
93
+ property: string;
94
+ };
95
+ export type CoverSizeFormat = "small" | "medium" | "large";
96
+ export type CoverAspectFormat = "contain" | "cover";
97
+ export type DatabaseViewSortDirection = "ascending" | "descending";
98
+ /**
99
+ * Sort schema for ordering database view results.
100
+ * Sorts are applied in order — all pages are first sorted by the first sort,
101
+ * then ties are broken by the second sort, and so on.
102
+ */
103
+ export type PropertyViewSortSchema = {
104
+ propertyId: string;
105
+ direction: DatabaseViewSortDirection;
106
+ };
107
+ type PropertyType = NotionAsCodeProperty["type"];
108
+ export type DatePropertyTypes = "date" | "created_time" | "last_edited_time";
109
+ export type BasePropertyFilter = {
110
+ propertyId: string;
111
+ type: "property";
112
+ };
113
+ export type TextPropertyFilter = {
114
+ propertyType: Extract<PropertyType, "text" | "title" | "url" | "email" | "phone_number">;
115
+ operator: "string_is" | "string_is_not" | "string_contains" | "string_does_not_contain" | "string_starts_with" | "string_ends_with";
116
+ value: string;
117
+ } & BasePropertyFilter;
118
+ export type NumberPropertyFilter = {
119
+ propertyType: Extract<PropertyType, "number">;
120
+ operator: "number_equals" | "number_does_not_equal" | "number_greater_than" | "number_less_than" | "number_greater_than_or_equal_to" | "number_less_than_or_equal_to";
121
+ value: number;
122
+ } & BasePropertyFilter;
123
+ export type CheckboxPropertyFilter = {
124
+ propertyType: Extract<PropertyType, "checkbox">;
125
+ operator: "checkbox_is" | "checkbox_is_not";
126
+ value: boolean;
127
+ } & BasePropertyFilter;
128
+ export type SelectPropertyFilter = {
129
+ propertyType: Extract<PropertyType, "select">;
130
+ operator: "enum_is" | "enum_is_not";
131
+ value: Array<string>;
132
+ } & BasePropertyFilter;
133
+ export type MultiSelectPropertyFilter = {
134
+ propertyType: Extract<PropertyType, "multi_select">;
135
+ operator: "enum_contains" | "enum_does_not_contain" | "enum_contains_all";
136
+ value: Array<string>;
137
+ } & BasePropertyFilter;
138
+ export type StatusPropertyFilter = {
139
+ propertyType: Extract<PropertyType, "status">;
140
+ operator: "status_is" | "status_is_not";
141
+ value: Array<string>;
142
+ } & BasePropertyFilter;
143
+ /**
144
+ * Date presets resolved relative to today, matching options such as
145
+ * "Today", "Tomorrow", and "One week ago".
146
+ */
147
+ export type RelativeDatePreset = "today" | "tomorrow" | "yesterday" | "one_week_ago" | "one_week_from_now" | "one_month_ago" | "one_month_from_now";
148
+ /**
149
+ * The unit spanned by a relative "is relative to today" date range.
150
+ */
151
+ export type RelativeDateRangeUnit = "day" | "week" | "month" | "year";
152
+ /**
153
+ * Which date a date property filter compares against. Notion date properties
154
+ * can hold a range, and `end_date` reads the far end of it.
155
+ */
156
+ export type DateFilterMode = "start_date" | "end_date";
157
+ export type ExactDatePropertyFilterValue = {
158
+ type: "exact";
159
+ value: string;
160
+ };
161
+ export type RelativeDatePropertyFilterValue = {
162
+ type: "relative";
163
+ value: RelativeDatePreset;
164
+ };
165
+ export type RelativeToTodayDatePropertyFilterValue = {
166
+ type: "relative_to_today";
167
+ value: {
168
+ direction: "past" | "next" | "this";
169
+ count?: number;
170
+ unit: RelativeDateRangeUnit;
171
+ };
172
+ };
173
+ /**
174
+ * Value for the `date_is_within` operator, shown as "Is between" in the UI.
175
+ *
176
+ * Bounds are inclusive `YYYY-MM-DD` dates; supplying only one leaves the range
177
+ * open at the other end.
178
+ *
179
+ */
180
+ export type ExactRangeDatePropertyFilterValue = {
181
+ type: "exact_range";
182
+ value: {
183
+ startDate: string;
184
+ endDate?: string;
185
+ } | {
186
+ startDate?: string;
187
+ endDate: string;
188
+ };
189
+ };
190
+ /**
191
+ * Value for a date property filter.
192
+ *
193
+ * - `exact` matches a calendar date in `YYYY-MM-DD` format.
194
+ * - `relative` matches a date preset such as today or tomorrow.
195
+ * - `relative_to_today` matches a range relative to today. `unit` can be
196
+ * `day`, `week`, `month`, or `year`. `count` defaults to `1` when omitted
197
+ * and is unnecessary for `direction: "this"`.
198
+ * - `exact_range` matches a fixed calendar range, optionally open at one end.
199
+ *
200
+ */
201
+ export type DatePropertyFilterValue = ExactDatePropertyFilterValue | RelativeDatePropertyFilterValue | RelativeToTodayDatePropertyFilterValue | ExactRangeDatePropertyFilterValue;
202
+ /**
203
+ * Date property filter.
204
+ *
205
+ * Single-date operators accept `exact` or `relative` values.
206
+ * `date_is_relative_to` requires a `relative_to_today` value.
207
+ * `date_is_within` requires an `exact_range` value.
208
+ *
209
+ * `dateFilterMode` chooses which end of a date range the comparison reads.
210
+ * It defaults to `"start_date"`. `"end_date"` falls back to the start date for
211
+ * rows whose date is a single day rather than a range, and has no effect on
212
+ * `created_time` / `last_edited_time` properties, which are never ranges.
213
+ *
214
+ * @example Exact date
215
+ * {
216
+ * type: "property",
217
+ * propertyId: "due",
218
+ * propertyType: "date",
219
+ * operator: "date_is_on_or_after",
220
+ * value: { type: "exact", value: "2025-10-03" }
221
+ * }
222
+ *
223
+ * @example Relative date preset
224
+ * {
225
+ * type: "property",
226
+ * propertyId: "due",
227
+ * propertyType: "date",
228
+ * operator: "date_is",
229
+ * value: { type: "relative", value: "today" }
230
+ * }
231
+ *
232
+ * @example Next two months
233
+ * {
234
+ * type: "property",
235
+ * propertyId: "due",
236
+ * propertyType: "date",
237
+ * operator: "date_is_relative_to",
238
+ * value: { type: "relative_to_today", value: { direction: "next", count: 2, unit: "month" } }
239
+ * }
240
+ *
241
+ * @example Sprints that end this week
242
+ * {
243
+ * type: "property",
244
+ * propertyId: "sprint",
245
+ * propertyType: "date",
246
+ * operator: "date_is_relative_to",
247
+ * value: { type: "relative_to_today", value: { direction: "this", unit: "week" } },
248
+ * dateFilterMode: "end_date"
249
+ * }
250
+ *
251
+ * @example Fixed calendar range
252
+ * {
253
+ * type: "property",
254
+ * propertyId: "due",
255
+ * propertyType: "date",
256
+ * operator: "date_is_within",
257
+ * value: { type: "exact_range", value: { startDate: "2026-01-01", endDate: "2026-03-31" } }
258
+ * }
259
+ *
260
+ * @example Range left open at the end
261
+ * {
262
+ * type: "property",
263
+ * propertyId: "due",
264
+ * propertyType: "date",
265
+ * operator: "date_is_within",
266
+ * value: { type: "exact_range", value: { startDate: "2026-01-01" } }
267
+ * }
268
+ *
269
+ */
270
+ export type DatePropertyFilter = ({
271
+ propertyType: DatePropertyTypes;
272
+ operator: "date_is" | "date_is_before" | "date_is_after" | "date_is_on_or_before" | "date_is_on_or_after";
273
+ value: ExactDatePropertyFilterValue | RelativeDatePropertyFilterValue;
274
+ dateFilterMode?: DateFilterMode;
275
+ } & BasePropertyFilter) | ({
276
+ propertyType: DatePropertyTypes;
277
+ operator: "date_is_relative_to";
278
+ value: RelativeToTodayDatePropertyFilterValue;
279
+ dateFilterMode?: DateFilterMode;
280
+ } & BasePropertyFilter) | ({
281
+ propertyType: DatePropertyTypes;
282
+ operator: "date_is_within";
283
+ value: ExactRangeDatePropertyFilterValue;
284
+ dateFilterMode?: DateFilterMode;
285
+ } & BasePropertyFilter);
286
+ export type RelationPropertyFilter = {
287
+ propertyType: Extract<PropertyType, "relation">;
288
+ operator: "relation_contains" | "relation_does_not_contain";
289
+ /** References related pages, or the current page when rendered as a page-layout tab. */
290
+ value: {
291
+ type: "exact";
292
+ value: Array<ResourceId>;
293
+ } | {
294
+ type: "relative";
295
+ value: "this_page";
296
+ };
297
+ } & BasePropertyFilter;
298
+ /**
299
+ * Person property filter — matches rows whose person property contains (or
300
+ * does not contain) the viewer (the `"me"` template variable, resolved at
301
+ * read time).
302
+ */
303
+ export type PersonPropertyFilter = {
304
+ propertyType: Extract<PropertyType, "person" | "created_by" | "last_edited_by">;
305
+ operator: "person_contains" | "person_does_not_contain";
306
+ value: [{
307
+ type: "relative";
308
+ value: "me";
309
+ }];
310
+ } & BasePropertyFilter;
311
+ /**
312
+ * Filter schema for filtering database views by property values.
313
+ * Used in view definitions to specify which pages should be visible.
314
+ *
315
+ * Each filter targets a specific property by ID and applies a type-appropriate
316
+ * filter operator with a comparison value.
317
+ *
318
+ * @example Text property filter
319
+ * {
320
+ * propertyId: "name-prop",
321
+ * type: "property",
322
+ * propertyType: "text",
323
+ * operator: "string_contains",
324
+ * value: "Project"
325
+ * }
326
+ */
327
+ export type PropertyFilterSchema = TextPropertyFilter | NumberPropertyFilter | CheckboxPropertyFilter | SelectPropertyFilter | MultiSelectPropertyFilter | StatusPropertyFilter | DatePropertyFilter | RelationPropertyFilter | PersonPropertyFilter;
328
+ export type FilterSchema = Array<PropertyFilterSchema | AdvancedFilterSchema>;
329
+ export type AdvancedFilterSchema = {
330
+ type: "advanced";
331
+ operator: "and" | "or";
332
+ filters: FilterSchema;
333
+ };
334
+ /**
335
+ * Base view schema shared by all view types.
336
+ *
337
+ * `dataSourceResourceId` must reference a data source created by the script or
338
+ * supplied through existing resources.
339
+ *
340
+ * @example
341
+ * // When creating a database with a data source
342
+ * const db = await notion.database({
343
+ * resourceId: "my-database",
344
+ * dataSources: [{ resourceId: "my-datasource", name: "Main", properties: [...] }]
345
+ * })
346
+ *
347
+ * // Views must reference that data source
348
+ * await db.addView({
349
+ * resourceId: "my-table-view",
350
+ * type: "table",
351
+ * dataSourceResourceId: "my-datasource" // REQUIRED: matches data source above
352
+ * })
353
+ *
354
+ * @example
355
+ * // A linked database can reference another script-created or existing data source
356
+ * const linkedDatabase = await notion.database({
357
+ * resourceId: "linked-database",
358
+ * parent: { type: "resourceId", resourceId: "project-page" },
359
+ * views: [{
360
+ * resourceId: "linked-table-view",
361
+ * type: "table",
362
+ * dataSourceResourceId: "my-datasource" // Created elsewhere or supplied through an existing collection
363
+ * }]
364
+ * })
365
+ */
366
+ export type BaseViewSchema = {
367
+ resourceId: ResourceId;
368
+ name?: string;
369
+ /**
370
+ * Notion icon shown in the view tab, including tabs in database page layouts.
371
+ * View icons do not support emoji or uploaded files. Omit to use the default
372
+ * icon for the view type.
373
+ */
374
+ icon?: Extract<NotionAsCodeIcon, {
375
+ type: "notion_icon";
376
+ }>;
377
+ type: ViewType;
378
+ /** Resource ID of a script-created or existing data source. */
379
+ dataSourceResourceId: ResourceId;
380
+ /**
381
+ * Optional resource ID of a template page in this view's data source to use as
382
+ * the view default template.
383
+ *
384
+ * The referenced page must be created with `template: true` and be parented to
385
+ * this same data source.
386
+ */
387
+ defaultTemplate?: ResourceId;
388
+ /**
389
+ * Optional: create this view as a linked view referenced by `<database>` tags
390
+ * in page content markdown or use it as a tab in a database layout. It does
391
+ * not attach to the database block's main view tabs.
392
+ */
393
+ ephemeral?: boolean;
394
+ sorts?: Array<PropertyViewSortSchema>;
395
+ /** Optional filter to control which pages appear in this view. */
396
+ filters?: FilterSchema;
397
+ /** Whether page icons are shown in this view. */
398
+ showPageIcon?: boolean;
399
+ };
400
+ export type TableViewSchema = BaseViewSchema & {
401
+ type: "table";
402
+ properties?: Array<PropertyFormat>;
403
+ wrap?: boolean;
404
+ groupBy?: GroupByFormat;
405
+ };
406
+ export type BoardViewSchema = BaseViewSchema & {
407
+ type: "board";
408
+ properties?: Array<PropertyFormat>;
409
+ groupBy?: GroupByFormat;
410
+ columns?: Array<GroupFormat>;
411
+ cover?: CoverFormat;
412
+ coverSize?: CoverSizeFormat;
413
+ coverAspect?: CoverAspectFormat;
414
+ wrap?: boolean;
415
+ };
416
+ export type CalendarViewSchema = BaseViewSchema & {
417
+ type: "calendar";
418
+ properties?: Array<PropertyFormat>;
419
+ /**
420
+ * REQUIRED: ResourceId of the date property to use for the calendar.
421
+ * Must match the `resourceId` of a date property in the database schema.
422
+ *
423
+ * @example
424
+ * calendarBy: "due-date-prop" // resourceId of a property of type "date"
425
+ */
426
+ calendarBy: ResourceId;
427
+ showWeekends?: boolean;
428
+ };
429
+ export type ListViewSchema = BaseViewSchema & {
430
+ type: "list";
431
+ properties?: Array<PropertyFormat>;
432
+ groupBy?: GroupByFormat;
433
+ };
434
+ export type GalleryViewSchema = BaseViewSchema & {
435
+ type: "gallery";
436
+ properties?: Array<PropertyFormat>;
437
+ cover?: CoverFormat;
438
+ coverSize?: CoverSizeFormat;
439
+ coverAspect?: CoverAspectFormat;
440
+ };
441
+ export type FeedViewSchema = BaseViewSchema & {
442
+ type: "feed";
443
+ properties?: Array<PropertyFormat>;
444
+ wrap?: boolean;
445
+ showAuthorByline?: boolean;
446
+ };
447
+ export type TimelineViewSchema = BaseViewSchema & {
448
+ type: "timeline";
449
+ properties?: Array<PropertyFormat>;
450
+ tableProperties?: Array<PropertyFormat>;
451
+ /**
452
+ * REQUIRED: ResourceId of the date property to use for the timeline start.
453
+ * Must match the `resourceId` of a date property in the database schema.
454
+ *
455
+ * @example
456
+ * timelineBy: "start-date-prop" // resourceId of a property of type "date"
457
+ */
458
+ timelineBy: ResourceId;
459
+ /**
460
+ * Optional: ResourceId of the date property to use for the timeline end
461
+ * (for date ranges). Must match the `resourceId` of a date property in
462
+ * the database schema.
463
+ */
464
+ timelineByEnd?: ResourceId;
465
+ showTable?: boolean;
466
+ };
467
+ export type ViewSchema = TableViewSchema | BoardViewSchema | CalendarViewSchema | ListViewSchema | GalleryViewSchema | FeedViewSchema | TimelineViewSchema;
468
+ export {};
469
+ //# sourceMappingURL=views.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"views.d.ts","sourceRoot":"","sources":["../../src/notion-as-code/views.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAGvF,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,UAAU,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,UAAU,CAAC;AAEjG,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,MAAM,GAAG,eAAe,CAAC;AAEnE;;;;;;;;GAQG;AACH,MAAM,MAAM,cAAc,GAAG;IAC5B,4DAA4D;IAC5D,QAAQ,EAAE,UAAU,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,kBAAkB,CAAC;CAChC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,GAAG;IACzB,4DAA4D;IAC5D,QAAQ,EAAE,UAAU,CAAC;IACrB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE;QACP,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,IAAI,CAAC;KACzC,CAAC;CACF,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC/B,4DAA4D;IAC5D,QAAQ,EAAE,UAAU,CAAC;IACrB,oEAAoE;IACpE,oBAAoB,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvC,QAAQ,CAAC,EAAE,KAAK,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,iBAAiB,GA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;;OAMG;IACH,UAAU,EAAE,UAAU,CAAC;IACvB;;;;OAIG;IACH,aAAa,CAAC,EAAE,UAAU,CAAC;IAC3B,SAAS,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,UAAU,GACnB,eAAe,GACf,eAAe,GACf,kBAAkB,GAClB,cAAc,GACd,iBAAiB,GACjB,cAAc,GACd,kBAAkB,CAAC"}
File without changes
@@ -0,0 +1,11 @@
1
+ /** OAuth 2.0 provider configuration. The secret value is stored with the app. */
2
+ export type OAuthConfiguration = {
3
+ authorizationEndpoint: string;
4
+ tokenEndpoint: string;
5
+ clientId: string;
6
+ clientSecretEnv: string;
7
+ scope: string;
8
+ authorizationParams?: Record<string, string>;
9
+ accessTokenExpireMs?: number;
10
+ };
11
+ //# sourceMappingURL=oauth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../src/oauth.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,MAAM,MAAM,kBAAkB,GAAG;IAChC,qBAAqB,EAAE,MAAM,CAAC;IAC9B,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,mBAAmB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7C,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC"}
package/dist/oauth.js ADDED
@@ -0,0 +1,26 @@
1
+ function validateOAuthConfiguration(config) {
2
+ if (!config.clientId || !/^[A-Za-z_][A-Za-z0-9_]*$/.test(config.clientSecretEnv))
3
+ throw new Error("OAuth connections require a client ID and clientSecretEnv secret name.");
4
+ for (const endpoint of [config.authorizationEndpoint, config.tokenEndpoint]) {
5
+ const url = new URL(endpoint);
6
+ if (url.protocol !== "https:" || url.username || url.password || url.hash)
7
+ throw new Error("OAuth endpoints must be HTTPS URLs without credentials or fragments.");
8
+ }
9
+ if (config.accessTokenExpireMs !== void 0 && (!Number.isFinite(config.accessTokenExpireMs) || config.accessTokenExpireMs <= 0))
10
+ throw new Error("OAuth token expiry must be positive.");
11
+ if (Object.keys(config.authorizationParams ?? {}).some(
12
+ (key) => [
13
+ "state",
14
+ "redirect_uri",
15
+ "client_id",
16
+ "response_type",
17
+ "code_challenge",
18
+ "code_challenge_method",
19
+ "scope"
20
+ ].includes(key)
21
+ ))
22
+ throw new Error("OAuth authorization parameters cannot override protocol fields.");
23
+ }
24
+ export {
25
+ validateOAuthConfiguration
26
+ };