@notionhq/workers 0.0.82

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 (73) hide show
  1. package/README.md +22 -0
  2. package/dist/block.d.ts +321 -0
  3. package/dist/block.d.ts.map +1 -0
  4. package/dist/block.js +0 -0
  5. package/dist/builder.d.ts +117 -0
  6. package/dist/builder.d.ts.map +1 -0
  7. package/dist/builder.js +168 -0
  8. package/dist/capabilities/automation.d.ts +91 -0
  9. package/dist/capabilities/automation.d.ts.map +1 -0
  10. package/dist/capabilities/automation.js +40 -0
  11. package/dist/capabilities/automation.test.d.ts +2 -0
  12. package/dist/capabilities/automation.test.d.ts.map +1 -0
  13. package/dist/capabilities/context.d.ts +7 -0
  14. package/dist/capabilities/context.d.ts.map +1 -0
  15. package/dist/capabilities/context.js +15 -0
  16. package/dist/capabilities/oauth.d.ts +120 -0
  17. package/dist/capabilities/oauth.d.ts.map +1 -0
  18. package/dist/capabilities/oauth.js +55 -0
  19. package/dist/capabilities/oauth.test.d.ts +2 -0
  20. package/dist/capabilities/oauth.test.d.ts.map +1 -0
  21. package/dist/capabilities/sync.d.ts +180 -0
  22. package/dist/capabilities/sync.d.ts.map +1 -0
  23. package/dist/capabilities/sync.js +84 -0
  24. package/dist/capabilities/sync.test.d.ts +2 -0
  25. package/dist/capabilities/sync.test.d.ts.map +1 -0
  26. package/dist/capabilities/tool.d.ts +68 -0
  27. package/dist/capabilities/tool.d.ts.map +1 -0
  28. package/dist/capabilities/tool.js +174 -0
  29. package/dist/capabilities/tool.test.d.ts +2 -0
  30. package/dist/capabilities/tool.test.d.ts.map +1 -0
  31. package/dist/error.d.ts +12 -0
  32. package/dist/error.d.ts.map +1 -0
  33. package/dist/error.js +15 -0
  34. package/dist/icon-names.d.ts +6 -0
  35. package/dist/icon-names.d.ts.map +1 -0
  36. package/dist/icon-names.js +0 -0
  37. package/dist/index.d.ts +10 -0
  38. package/dist/index.d.ts.map +1 -0
  39. package/dist/index.js +9 -0
  40. package/dist/json-schema.d.ts +117 -0
  41. package/dist/json-schema.d.ts.map +1 -0
  42. package/dist/json-schema.js +0 -0
  43. package/dist/json-schema.test.d.ts +2 -0
  44. package/dist/json-schema.test.d.ts.map +1 -0
  45. package/dist/schema.d.ts +178 -0
  46. package/dist/schema.d.ts.map +1 -0
  47. package/dist/schema.js +66 -0
  48. package/dist/types.d.ts +206 -0
  49. package/dist/types.d.ts.map +1 -0
  50. package/dist/types.js +0 -0
  51. package/dist/worker.d.ts +177 -0
  52. package/dist/worker.d.ts.map +1 -0
  53. package/dist/worker.js +219 -0
  54. package/package.json +68 -0
  55. package/src/block.ts +529 -0
  56. package/src/builder.ts +299 -0
  57. package/src/capabilities/automation.test.ts +152 -0
  58. package/src/capabilities/automation.ts +130 -0
  59. package/src/capabilities/context.ts +23 -0
  60. package/src/capabilities/oauth.test.ts +52 -0
  61. package/src/capabilities/oauth.ts +157 -0
  62. package/src/capabilities/sync.test.ts +104 -0
  63. package/src/capabilities/sync.ts +311 -0
  64. package/src/capabilities/tool.test.ts +351 -0
  65. package/src/capabilities/tool.ts +279 -0
  66. package/src/error.ts +19 -0
  67. package/src/icon-names.ts +890 -0
  68. package/src/index.ts +34 -0
  69. package/src/json-schema.test.ts +719 -0
  70. package/src/json-schema.ts +179 -0
  71. package/src/schema.ts +241 -0
  72. package/src/types.ts +272 -0
  73. package/src/worker.ts +285 -0
package/README.md ADDED
@@ -0,0 +1,22 @@
1
+ # Workers SDK
2
+
3
+ ## Development
4
+
5
+ 1. Install [mise](https://mise.jdx.dev/getting-started.html)
6
+ 2. Run `mise install`
7
+ 3. Run `npm run bootstrap`
8
+
9
+ ## Publishing New Versions
10
+
11
+ Increment the package.json version and create a new Git tag:
12
+
13
+ ```shell
14
+ # This also creates a Git tag.
15
+ npm version patch
16
+ ```
17
+
18
+ Then, push the commit and tag:
19
+
20
+ ```shell
21
+ git push origin main --follow-tags
22
+ ```
@@ -0,0 +1,321 @@
1
+ type ApiColor = "default" | "gray" | "brown" | "orange" | "yellow" | "green" | "blue" | "purple" | "pink" | "red" | "gray_background" | "brown_background" | "orange_background" | "yellow_background" | "green_background" | "blue_background" | "purple_background" | "pink_background" | "red_background";
2
+ type RichTextAnnotations = {
3
+ bold: boolean;
4
+ italic: boolean;
5
+ strikethrough: boolean;
6
+ underline: boolean;
7
+ code: boolean;
8
+ color: ApiColor;
9
+ };
10
+ type RichTextBase = {
11
+ plain_text: string;
12
+ href: string | null;
13
+ annotations: RichTextAnnotations;
14
+ };
15
+ type TextContent = {
16
+ content: string;
17
+ link: {
18
+ url: string;
19
+ } | null;
20
+ };
21
+ type EquationContent = {
22
+ expression: string;
23
+ };
24
+ type DateMention = {
25
+ type: "date";
26
+ date: {
27
+ start: string;
28
+ end?: string | null;
29
+ time_zone?: string | null;
30
+ };
31
+ };
32
+ type CustomEmojiMention = {
33
+ type: "custom_emoji";
34
+ custom_emoji: {
35
+ id: string;
36
+ name?: string;
37
+ url?: string;
38
+ };
39
+ };
40
+ type LinkPreviewMention = {
41
+ type: "link_preview";
42
+ link_preview: {
43
+ url: string;
44
+ };
45
+ };
46
+ type LinkMention = {
47
+ type: "link_mention";
48
+ link_mention: {
49
+ href: string;
50
+ };
51
+ };
52
+ type MentionContent = DateMention | CustomEmojiMention | LinkPreviewMention | LinkMention;
53
+ type RichTextItem = RichTextBase & ({
54
+ type: "text";
55
+ text: TextContent;
56
+ } | {
57
+ type: "mention";
58
+ mention: MentionContent;
59
+ } | {
60
+ type: "equation";
61
+ equation: EquationContent;
62
+ });
63
+ type RichText = RichTextItem[];
64
+ type EmojiIcon = {
65
+ type: "emoji";
66
+ emoji: string;
67
+ };
68
+ type ExternalIcon = {
69
+ type: "external";
70
+ external: {
71
+ url: string;
72
+ };
73
+ };
74
+ type FileIcon = {
75
+ type: "file";
76
+ file: {
77
+ url: string;
78
+ expiry_time: string;
79
+ };
80
+ };
81
+ type Icon = EmojiIcon | ExternalIcon | FileIcon;
82
+ type ExternalFile = {
83
+ type: "external";
84
+ external: {
85
+ url: string;
86
+ };
87
+ };
88
+ type HostedFile = {
89
+ type: "file";
90
+ file: {
91
+ url: string;
92
+ expiry_time: string;
93
+ };
94
+ name?: string;
95
+ };
96
+ type FileObject = ExternalFile | HostedFile;
97
+ type BlockBase = {
98
+ object: "block";
99
+ };
100
+ type ParagraphBlock = BlockBase & {
101
+ type: "paragraph";
102
+ paragraph: {
103
+ rich_text: RichText;
104
+ color?: ApiColor;
105
+ children?: Block[];
106
+ };
107
+ };
108
+ type Heading1Block = BlockBase & {
109
+ type: "heading_1";
110
+ heading_1: {
111
+ rich_text: RichText;
112
+ color?: ApiColor;
113
+ is_toggleable?: boolean;
114
+ children?: Block[];
115
+ };
116
+ };
117
+ type Heading2Block = BlockBase & {
118
+ type: "heading_2";
119
+ heading_2: {
120
+ rich_text: RichText;
121
+ color?: ApiColor;
122
+ is_toggleable?: boolean;
123
+ children?: Block[];
124
+ };
125
+ };
126
+ type Heading3Block = BlockBase & {
127
+ type: "heading_3";
128
+ heading_3: {
129
+ rich_text: RichText;
130
+ color?: ApiColor;
131
+ is_toggleable?: boolean;
132
+ children?: Block[];
133
+ };
134
+ };
135
+ type BulletedListItemBlock = BlockBase & {
136
+ type: "bulleted_list_item";
137
+ bulleted_list_item: {
138
+ rich_text: RichText;
139
+ color?: ApiColor;
140
+ children?: Block[];
141
+ };
142
+ };
143
+ type NumberedListItemBlock = BlockBase & {
144
+ type: "numbered_list_item";
145
+ numbered_list_item: {
146
+ rich_text: RichText;
147
+ color?: ApiColor;
148
+ children?: Block[];
149
+ };
150
+ };
151
+ type ToDoBlock = BlockBase & {
152
+ type: "to_do";
153
+ to_do: {
154
+ rich_text: RichText;
155
+ checked: boolean;
156
+ color?: ApiColor;
157
+ children?: Block[];
158
+ };
159
+ };
160
+ type ToggleBlock = BlockBase & {
161
+ type: "toggle";
162
+ toggle: {
163
+ rich_text: RichText;
164
+ color?: ApiColor;
165
+ children?: Block[];
166
+ };
167
+ };
168
+ type QuoteBlock = BlockBase & {
169
+ type: "quote";
170
+ quote: {
171
+ rich_text: RichText;
172
+ color?: ApiColor;
173
+ children?: Block[];
174
+ };
175
+ };
176
+ type CalloutBlock = BlockBase & {
177
+ type: "callout";
178
+ callout: {
179
+ rich_text: RichText;
180
+ icon?: Icon | null;
181
+ color?: ApiColor;
182
+ children?: Block[];
183
+ };
184
+ };
185
+ type CodeBlock = BlockBase & {
186
+ type: "code";
187
+ code: {
188
+ rich_text: RichText;
189
+ caption?: RichText;
190
+ language: string;
191
+ };
192
+ };
193
+ type EquationBlock = BlockBase & {
194
+ type: "equation";
195
+ equation: {
196
+ expression: string;
197
+ };
198
+ };
199
+ type DividerBlock = BlockBase & {
200
+ type: "divider";
201
+ divider: Record<string, never>;
202
+ };
203
+ type BreadcrumbBlock = BlockBase & {
204
+ type: "breadcrumb";
205
+ breadcrumb: Record<string, never>;
206
+ };
207
+ type TableOfContentsBlock = BlockBase & {
208
+ type: "table_of_contents";
209
+ table_of_contents: {
210
+ color?: ApiColor;
211
+ };
212
+ };
213
+ type ColumnListBlock = BlockBase & {
214
+ type: "column_list";
215
+ column_list: {
216
+ children: ColumnBlock[];
217
+ };
218
+ };
219
+ type ColumnBlock = BlockBase & {
220
+ type: "column";
221
+ column: {
222
+ children?: Block[];
223
+ };
224
+ };
225
+ type ImageBlock = BlockBase & {
226
+ type: "image";
227
+ image: FileObject & {
228
+ caption?: RichText;
229
+ };
230
+ };
231
+ type VideoBlock = BlockBase & {
232
+ type: "video";
233
+ video: FileObject & {
234
+ caption?: RichText;
235
+ };
236
+ };
237
+ type AudioBlock = BlockBase & {
238
+ type: "audio";
239
+ audio: FileObject & {
240
+ caption?: RichText;
241
+ };
242
+ };
243
+ type PDFBlock = BlockBase & {
244
+ type: "pdf";
245
+ pdf: FileObject & {
246
+ caption?: RichText;
247
+ };
248
+ };
249
+ type FileBlock = BlockBase & {
250
+ type: "file";
251
+ file: FileObject & {
252
+ caption?: RichText;
253
+ };
254
+ };
255
+ type EmbedBlock = BlockBase & {
256
+ type: "embed";
257
+ embed: {
258
+ url: string;
259
+ caption?: RichText;
260
+ };
261
+ };
262
+ type BookmarkBlock = BlockBase & {
263
+ type: "bookmark";
264
+ bookmark: {
265
+ url: string;
266
+ caption?: RichText;
267
+ };
268
+ };
269
+ type LinkPreviewBlock = BlockBase & {
270
+ type: "link_preview";
271
+ link_preview: {
272
+ url: string;
273
+ };
274
+ };
275
+ type ChildPageBlock = BlockBase & {
276
+ type: "child_page";
277
+ child_page: {
278
+ title: string;
279
+ };
280
+ };
281
+ type ChildDatabaseBlock = BlockBase & {
282
+ type: "child_database";
283
+ child_database: {
284
+ title: string;
285
+ };
286
+ };
287
+ type TemplateBlock = BlockBase & {
288
+ type: "template";
289
+ template: {
290
+ rich_text: RichText;
291
+ children?: Block[];
292
+ };
293
+ };
294
+ type TableBlock = BlockBase & {
295
+ type: "table";
296
+ table: {
297
+ table_width: number;
298
+ has_column_header: boolean;
299
+ has_row_header: boolean;
300
+ children: TableRowBlock[];
301
+ };
302
+ };
303
+ type TableRowBlock = BlockBase & {
304
+ type: "table_row";
305
+ table_row: {
306
+ cells: RichText[];
307
+ };
308
+ };
309
+ type AIBlock = BlockBase & {
310
+ type: "ai_block";
311
+ ai_block: {
312
+ prompt?: string;
313
+ };
314
+ };
315
+ type UnsupportedBlock = BlockBase & {
316
+ type: "unsupported";
317
+ unsupported: Record<string, never>;
318
+ };
319
+ type Block = ParagraphBlock | Heading1Block | Heading2Block | Heading3Block | BulletedListItemBlock | NumberedListItemBlock | ToDoBlock | ToggleBlock | QuoteBlock | CalloutBlock | CodeBlock | EquationBlock | DividerBlock | BreadcrumbBlock | TableOfContentsBlock | ColumnListBlock | ColumnBlock | ImageBlock | VideoBlock | AudioBlock | PDFBlock | FileBlock | EmbedBlock | BookmarkBlock | LinkPreviewBlock | ChildPageBlock | ChildDatabaseBlock | TemplateBlock | TableBlock | TableRowBlock | AIBlock | UnsupportedBlock;
320
+ export type { RichText, RichTextItem, RichTextBase, RichTextAnnotations, TextContent, EquationContent, MentionContent, DateMention, CustomEmojiMention, LinkPreviewMention, LinkMention, ApiColor, Icon, EmojiIcon, ExternalIcon, FileIcon, FileObject, ExternalFile, HostedFile, BlockBase, ParagraphBlock, Heading1Block, Heading2Block, Heading3Block, BulletedListItemBlock, NumberedListItemBlock, ToDoBlock, ToggleBlock, QuoteBlock, CalloutBlock, CodeBlock, EquationBlock, DividerBlock, BreadcrumbBlock, TableOfContentsBlock, ColumnListBlock, ColumnBlock, ImageBlock, VideoBlock, AudioBlock, PDFBlock, FileBlock, EmbedBlock, BookmarkBlock, LinkPreviewBlock, ChildPageBlock, ChildDatabaseBlock, TemplateBlock, TableBlock, TableRowBlock, AIBlock, UnsupportedBlock, Block, };
321
+ //# sourceMappingURL=block.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../src/block.ts"],"names":[],"mappings":"AAKA,KAAK,QAAQ,GACV,SAAS,GACT,MAAM,GACN,OAAO,GACP,QAAQ,GACR,QAAQ,GACR,OAAO,GACP,MAAM,GACN,QAAQ,GACR,MAAM,GACN,KAAK,GACL,iBAAiB,GACjB,kBAAkB,GAClB,mBAAmB,GACnB,mBAAmB,GACnB,kBAAkB,GAClB,iBAAiB,GACjB,mBAAmB,GACnB,iBAAiB,GACjB,gBAAgB,CAAC;AAGpB,KAAK,mBAAmB,GAAG;IAC1B,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,aAAa,EAAE,OAAO,CAAC;IACvB,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,QAAQ,CAAC;CAChB,CAAC;AAGF,KAAK,YAAY,GAAG;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,WAAW,EAAE,mBAAmB,CAAC;CACjC,CAAC;AAGF,KAAK,WAAW,GAAG;I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EACb,aAAa,EACb,qBAAqB,EACrB,qBAAqB,EACrB,SAAS,EACT,WAAW,EACX,UAAU,EACV,YAAY,EACZ,SAAS,EACT,aAAa,EACb,YAAY,EACZ,eAAe,EACf,oBAAoB,EACpB,eAAe,EACf,WAAW,EACX,UAAU,EACV,UAAU,EACV,UAAU,EACV,QAAQ,EACR,SAAS,EACT,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,UAAU,EACV,aAAa,EACb,OAAO,EACP,gBAAgB,EAChB,KAAK,GACL,CAAC"}
package/dist/block.js ADDED
File without changes
@@ -0,0 +1,117 @@
1
+ import type { NoticonName } from "./icon-names.js";
2
+ import type { Icon, NoticonColor, PeopleValue, PlaceValue, RelationReference, TextValue } from "./types.js";
3
+ /**
4
+ * Creates a rich text value.
5
+ */
6
+ export declare function richText(content: string): TextValue;
7
+ /**
8
+ * Creates a URL value.
9
+ */
10
+ export declare function url(url: string): TextValue;
11
+ /**
12
+ * Creates a title value.
13
+ */
14
+ export declare function title(content: string): TextValue;
15
+ /**
16
+ * Creates a text value.
17
+ */
18
+ export declare function text(content: string): TextValue;
19
+ /**
20
+ * Creates an email value.
21
+ */
22
+ export declare function email(email: string): TextValue;
23
+ /**
24
+ * Creates a phone number value.
25
+ */
26
+ export declare function phoneNumber(phone: string): TextValue;
27
+ /**
28
+ * Creates a checkbox value.
29
+ */
30
+ export declare function checkbox(checked: boolean): TextValue;
31
+ /**
32
+ * Creates a file URL value.
33
+ * @param fileUrl - The URL of the file
34
+ * @param fileName - Optional display name for the file (defaults to URL)
35
+ */
36
+ export declare function file(fileUrl: string, fileName?: string): TextValue;
37
+ /**
38
+ * Creates a number value.
39
+ */
40
+ export declare function number(value: number): TextValue;
41
+ /**
42
+ * Creates a date value from a date string (YYYY-MM-DD).
43
+ */
44
+ export declare function date(dateString: string): TextValue;
45
+ /**
46
+ * Creates a datetime value from a Date object.
47
+ */
48
+ export declare function dateTime(date: Date, timeZone?: string): TextValue;
49
+ /**
50
+ * Creates a date range value from date strings.
51
+ */
52
+ export declare function dateRange(startDate: string, endDate: string): TextValue;
53
+ /**
54
+ * Creates a datetime range value from Date objects.
55
+ */
56
+ export declare function dateTimeRange(startDate: Date, endDate: Date, timeZone?: string): TextValue;
57
+ /**
58
+ * Creates a link with custom display text.
59
+ * @param displayText - The text to display
60
+ * @param url - The URL to link to
61
+ */
62
+ export declare function link(displayText: string, url: string): TextValue;
63
+ /**
64
+ * Creates a select value from a single option.
65
+ */
66
+ export declare function select(value: string): TextValue;
67
+ /**
68
+ * Creates a multi-select value from multiple options.
69
+ * @param values - Array of option names to select
70
+ */
71
+ export declare function multiSelect(...values: string[]): TextValue;
72
+ /**
73
+ * Creates a status value from a status option name.
74
+ */
75
+ export declare function status(value: string): TextValue;
76
+ /**
77
+ * Creates a people value from email addresses.
78
+ * @param emails - Array of email addresses for people to include
79
+ */
80
+ export declare function people(...emails: string[]): PeopleValue;
81
+ /**
82
+ * Creates a place value for a geographic location.
83
+ * @param value - The place value with lat/lon coordinates and optional name/address
84
+ */
85
+ export declare function place(value: PlaceValue): PlaceValue;
86
+ /**
87
+ * Creates a relation reference from a primary key of a related record.
88
+ * Use an array of relation references as the property value.
89
+ *
90
+ * @param primaryKey - The primary key of the related record
91
+ * @example
92
+ * ```typescript
93
+ * // Single relation
94
+ * { Project: [Builder.relation("project-123")] }
95
+ *
96
+ * // Multiple relations
97
+ * { Projects: [Builder.relation("project-123"), Builder.relation("project-456")] }
98
+ * ```
99
+ */
100
+ export declare function relation(primaryKey: string): RelationReference;
101
+ /**
102
+ * Creates an emoji icon.
103
+ * @param emoji - An emoji string (e.g., "🎯", "✨", "🚀")
104
+ */
105
+ export declare function emojiIcon(emoji: string): Icon;
106
+ /**
107
+ * Creates a Notion icon with a specific color.
108
+ * @param icon - The name of the Notion icon (e.g., "checkmark", "pizza", "rocket")
109
+ * @param color - The color variant (defaults to "gray")
110
+ */
111
+ export declare function notionIcon(icon: NoticonName, color?: NoticonColor): Icon;
112
+ /**
113
+ * Creates an image icon from an external URL.
114
+ * @param url - The URL of the image (e.g., "https://example.com/icon.png")
115
+ */
116
+ export declare function imageIcon(url: string): Icon;
117
+ //# sourceMappingURL=builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,KAAK,EAEX,IAAI,EACJ,YAAY,EACZ,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,SAAS,EACT,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAEnD;AAED;;GAEG;AACH,wBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAE1C;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAEhD;AAED;;GAEG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAE/C;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAE9C;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAEpD;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,CAEpD;AAED;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAElE;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAK/C;AAED;;GAEG;AACH,wBAAgB,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CASlD;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,IA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
7
+ function title(content) {
8
+ return [[content]];
9
+ }
10
+ function text(content) {
11
+ return [[content]];
12
+ }
13
+ function email(email2) {
14
+ return [[email2]];
15
+ }
16
+ function phoneNumber(phone) {
17
+ return [[phone]];
18
+ }
19
+ function checkbox(checked) {
20
+ return checked ? [["Yes"]] : [["No"]];
21
+ }
22
+ function file(fileUrl, fileName) {
23
+ return [[fileName ?? fileUrl, [["a", fileUrl]]]];
24
+ }
25
+ function number(value) {
26
+ if (Number.isNaN(value)) {
27
+ return [];
28
+ }
29
+ return [[value.toString()]];
30
+ }
31
+ function date(dateString) {
32
+ validateDateString(dateString);
33
+ const dateValue = {
34
+ type: "date",
35
+ start_date: dateString
36
+ };
37
+ return createDateToken(dateValue);
38
+ }
39
+ function dateTime(date2, timeZone) {
40
+ const dateValue = {
41
+ type: "datetime",
42
+ start_date: formatDate(date2),
43
+ start_time: formatTime(date2)
44
+ };
45
+ if (timeZone) {
46
+ dateValue.time_zone = timeZone;
47
+ }
48
+ return createDateToken(dateValue);
49
+ }
50
+ function dateRange(startDate, endDate) {
51
+ validateDateString(startDate);
52
+ validateDateString(endDate);
53
+ const dateValue = {
54
+ type: "daterange",
55
+ start_date: startDate,
56
+ end_date: endDate
57
+ };
58
+ return createDateToken(dateValue);
59
+ }
60
+ function dateTimeRange(startDate, endDate, timeZone) {
61
+ const dateValue = {
62
+ type: "datetimerange",
63
+ start_date: formatDate(startDate),
64
+ start_time: formatTime(startDate),
65
+ end_date: formatDate(endDate),
66
+ end_time: formatTime(endDate)
67
+ };
68
+ if (timeZone) {
69
+ dateValue.time_zone = timeZone;
70
+ }
71
+ return createDateToken(dateValue);
72
+ }
73
+ function link(displayText, url2) {
74
+ return [[displayText, [["a", url2]]]];
75
+ }
76
+ function select(value) {
77
+ return [[value]];
78
+ }
79
+ function multiSelect(...values) {
80
+ if (values.length === 0) {
81
+ return [];
82
+ }
83
+ return [[values.join(",")]];
84
+ }
85
+ function status(value) {
86
+ return [[value]];
87
+ }
88
+ function people(...emails) {
89
+ return emails.map((email2) => ({ email: email2 }));
90
+ }
91
+ function place(value) {
92
+ if (typeof value.lat !== "number" || typeof value.lon !== "number") {
93
+ throw new Error("Place value must have numeric lat and lon coordinates");
94
+ }
95
+ return value;
96
+ }
97
+ function relation(primaryKey) {
98
+ return { type: "primaryKey", value: primaryKey };
99
+ }
100
+ function validateDateString(dateString) {
101
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(dateString)) {
102
+ throw new Error(
103
+ `Invalid date format: ${dateString}. Expected YYYY-MM-DD format.`
104
+ );
105
+ }
106
+ const date2 = new Date(dateString);
107
+ if (Number.isNaN(date2.getTime())) {
108
+ throw new Error(`Invalid date: ${dateString}`);
109
+ }
110
+ }
111
+ function createDateToken(dateValue) {
112
+ return [["\u2023", [["d", dateValue]]]];
113
+ }
114
+ function formatDate(date2) {
115
+ const year = date2.getFullYear();
116
+ const month = String(date2.getMonth() + 1).padStart(2, "0");
117
+ const day = String(date2.getDate()).padStart(2, "0");
118
+ return `${year}-${month}-${day}`;
119
+ }
120
+ function formatTime(date2) {
121
+ const hours = String(date2.getHours()).padStart(2, "0");
122
+ const minutes = String(date2.getMinutes()).padStart(2, "0");
123
+ return `${hours}:${minutes}`;
124
+ }
125
+ function emojiIcon(emoji) {
126
+ return {
127
+ type: "emoji",
128
+ value: emoji
129
+ };
130
+ }
131
+ function notionIcon(icon, color = "gray") {
132
+ return {
133
+ type: "notion",
134
+ icon,
135
+ color
136
+ };
137
+ }
138
+ function imageIcon(url2) {
139
+ return {
140
+ type: "image",
141
+ url: url2
142
+ };
143
+ }
144
+ export {
145
+ checkbox,
146
+ date,
147
+ dateRange,
148
+ dateTime,
149
+ dateTimeRange,
150
+ email,
151
+ emojiIcon,
152
+ file,
153
+ imageIcon,
154
+ link,
155
+ multiSelect,
156
+ notionIcon,
157
+ number,
158
+ people,
159
+ phoneNumber,
160
+ place,
161
+ relation,
162
+ richText,
163
+ select,
164
+ status,
165
+ text,
166
+ title,
167
+ url
168
+ };