rotion 3.5.7 → 3.6.1

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 (39) hide show
  1. package/dist/exporter/api.d.ts +7 -0
  2. package/dist/exporter/api.js +33 -16
  3. package/dist/exporter/api.js.map +1 -1
  4. package/dist/exporter/database.js +13 -1
  5. package/dist/exporter/database.js.map +1 -1
  6. package/dist/exporter/index.d.ts +1 -0
  7. package/dist/exporter/index.js +1 -0
  8. package/dist/exporter/index.js.map +1 -1
  9. package/dist/exporter/types.d.ts +178 -138
  10. package/dist/exporter/validation.d.ts +15 -0
  11. package/dist/exporter/validation.js +180 -0
  12. package/dist/exporter/validation.js.map +1 -0
  13. package/dist/exporter/variables.d.ts +1 -0
  14. package/dist/exporter/variables.js +1 -0
  15. package/dist/exporter/variables.js.map +1 -1
  16. package/dist/ui/components/Gallery/GallerySelectField/GallerySelectField.d.ts +1 -1
  17. package/dist/ui/components/Gallery/GallerySelectField/GallerySelectField.types.d.ts +1 -1
  18. package/dist/ui/components/List/ListSelectField/ListSelectField.types.d.ts +1 -1
  19. package/dist/ui/components/Table/TableSelectField/TableSelectField.types.d.ts +1 -1
  20. package/dist/ui/components/lib.d.ts +4 -1
  21. package/dist/ui/esm/components/Gallery/GalleryCard/GalleryHandler.js +2 -1
  22. package/dist/ui/esm/components/Gallery/GalleryCard/GalleryHandler.js.map +1 -1
  23. package/dist/ui/esm/components/Gallery/GallerySelectField/GallerySelectField.js +3 -0
  24. package/dist/ui/esm/components/Gallery/GallerySelectField/GallerySelectField.js.map +1 -1
  25. package/dist/ui/esm/components/List/ListHandler.js +2 -1
  26. package/dist/ui/esm/components/List/ListHandler.js.map +1 -1
  27. package/dist/ui/esm/components/Page/CodeBlock/CodeBlock.js +6 -8
  28. package/dist/ui/esm/components/Page/CodeBlock/CodeBlock.js.map +1 -1
  29. package/dist/ui/esm/components/Page/EquationBlock/EquationBlock.js +11 -6
  30. package/dist/ui/esm/components/Page/EquationBlock/EquationBlock.js.map +1 -1
  31. package/dist/ui/esm/components/RichText/Equation/Equation.js +10 -6
  32. package/dist/ui/esm/components/RichText/Equation/Equation.js.map +1 -1
  33. package/dist/ui/esm/components/Table/TableHandler.js +2 -1
  34. package/dist/ui/esm/components/Table/TableHandler.js.map +1 -1
  35. package/dist/ui/esm/components/lib.js +78 -0
  36. package/dist/ui/esm/components/lib.js.map +1 -1
  37. package/dist/ui/index-without-dark.css +1 -1
  38. package/dist/ui/index.css +1 -1
  39. package/package.json +3 -2
@@ -5,6 +5,13 @@ export interface reqAPIWithBackoffArgs {
5
5
  args: unknown;
6
6
  count: number;
7
7
  }
8
+ /**
9
+ * buildAPIErrorMessage keeps the reason of the failure in the message.
10
+ * Without it, a validation error of the notion api -- a filter for a property
11
+ * or an option that no longer exists, for example -- is indistinguishable
12
+ * from a network failure.
13
+ */
14
+ export declare function buildAPIErrorMessage(func: Function, args: unknown, error: unknown): string;
8
15
  export declare function reqAPIWithBackoff<T>({ func, args, count }: reqAPIWithBackoffArgs): Promise<T>;
9
16
  export interface reqAPIWithBackoffAndCacheArgs {
10
17
  name: string;
@@ -3,6 +3,28 @@ import { isNotionClientError, APIErrorCode, ClientErrorCode, LogLevel, } from '@
3
3
  import { atoh, readCache, writeCache, isAvailableCache, } from './files.js';
4
4
  import { cacheDir, waitingTimeSec, waitTimeSecAfterLimit, auth, debug, } from './variables.js';
5
5
  export const notion = new Client({ auth, logLevel: debug ? LogLevel.DEBUG : LogLevel.ERROR });
6
+ const retryableErrorCodes = [
7
+ APIErrorCode.RateLimited,
8
+ APIErrorCode.InternalServerError,
9
+ ClientErrorCode.ResponseError,
10
+ ClientErrorCode.RequestTimeout,
11
+ ];
12
+ const truncate = (str, max = 1000) => {
13
+ return str.length > max ? `${str.slice(0, max)}...` : str;
14
+ };
15
+ /**
16
+ * buildAPIErrorMessage keeps the reason of the failure in the message.
17
+ * Without it, a validation error of the notion api -- a filter for a property
18
+ * or an option that no longer exists, for example -- is indistinguishable
19
+ * from a network failure.
20
+ */
21
+ export function buildAPIErrorMessage(func, args, error) {
22
+ const name = func.name === '' ? 'anonymous' : func.name;
23
+ const reason = error && typeof error === 'object' && isNotionClientError(error)
24
+ ? `${error.code}: ${error.message}`
25
+ : `${error}`;
26
+ return `request to notion api failed: ${name} -- ${reason}\n args: ${truncate(JSON.stringify(args) ?? 'undefined')}`;
27
+ }
6
28
  export async function reqAPIWithBackoff({ func, args, count }) {
7
29
  if (count < 1) {
8
30
  throw new Error('backoff count exceeded');
@@ -15,28 +37,23 @@ export async function reqAPIWithBackoff({ func, args, count }) {
15
37
  }
16
38
  }
17
39
  catch (error) {
18
- if (error && typeof error === 'object' && isNotionClientError(error)) {
19
- switch (error.code) {
20
- case APIErrorCode.RateLimited:
21
- case APIErrorCode.InternalServerError:
22
- case ClientErrorCode.ResponseError:
23
- case ClientErrorCode.RequestTimeout:
24
- if (debug) {
25
- console.log(`reqAPIWithBackoff backoff(${count}) -- error code: ${error.code}`);
26
- }
27
- if (waitTimeSecAfterLimit > 0) {
28
- await new Promise(resolve => setTimeout(resolve, waitTimeSecAfterLimit));
29
- }
30
- res = await reqAPIWithBackoff({ func, args, count: count - 1 });
31
- break;
40
+ const retryable = error && typeof error === 'object' && isNotionClientError(error) && retryableErrorCodes.includes(error.code);
41
+ if (retryable && count > 1) {
42
+ if (debug) {
43
+ console.log(`reqAPIWithBackoff backoff(${count}) -- error: ${error}`);
44
+ }
45
+ if (waitTimeSecAfterLimit > 0) {
46
+ await new Promise(resolve => setTimeout(resolve, waitTimeSecAfterLimit));
32
47
  }
48
+ return await reqAPIWithBackoff({ func, args, count: count - 1 });
33
49
  }
34
50
  if (debug) {
35
51
  console.error(`reqAPIWithBackoff error -- func: ${func.name}, args: ${JSON.stringify(args)}, error: ${error}`);
36
52
  }
53
+ throw new Error(buildAPIErrorMessage(func, args, error), { cause: error });
37
54
  }
38
- if (res === null) {
39
- throw new Error(`request to notion api failed: ${func.name}`);
55
+ if (res === null || res === undefined) {
56
+ throw new Error(`request to notion api failed: ${func.name === '' ? 'anonymous' : func.name} -- empty response`);
40
57
  }
41
58
  return res;
42
59
  }
@@ -1 +1 @@
1
- {"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/exporter/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EACL,mBAAmB,EACnB,YAAY,EACZ,eAAe,EACf,QAAQ,GACT,MAAM,kBAAkB,CAAA;AACzB,OAAO,EACL,IAAI,EACJ,SAAS,EACT,UAAU,EACV,gBAAgB,GACjB,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,QAAQ,EACR,cAAc,EACd,qBAAqB,EACrB,IAAI,EACJ,KAAK,GACN,MAAM,gBAAgB,CAAA;AAEvB,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAA;AAQ7F,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAK,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAyB;IACtF,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAA;IAC3C,CAAC;IAED,IAAI,GAAG,GAAW,IAAI,CAAA;IAEtB,IAAI,CAAC;QACH,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAM,CAAA;QAC3B,IAAI,cAAc,GAAG,CAAC,EAAE,CAAC;YACvB,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC,CAAA;QACnE,CAAC;IACH,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACxB,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI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
@@ -1,9 +1,14 @@
1
1
  import { reqAPIWithBackoff, notion, } from './api.js';
2
2
  import { getNotionIconUrl } from './page.js';
3
- import { cacheDir, incrementalCache, debug, } from './variables.js';
3
+ import { cacheDir, incrementalCache, debug, skipQueryValidation, } from './variables.js';
4
+ import { validateQuery, buildQueryValidationMessage, } from './validation.js';
4
5
  import { atoh, createDirWhenNotfound, saveImage, readCache, writeCache, isAvailableCache, isEmpty, } from './files.js';
5
6
  import { savePageCover, savePageIcon, } from './page.js';
6
7
  import { withFileLock } from './mutex.js';
8
+ const databaseLabel = (meta, database_id) => {
9
+ const title = (meta.title ?? []).map(v => v.plain_text).join('').trim();
10
+ return title === '' ? database_id : `"${title}" (${database_id})`;
11
+ };
7
12
  /**
8
13
  * FetchDatabase retrieves database and download images in from blocks.
9
14
  * And create cache that includes filepath of downloaded images.
@@ -63,6 +68,13 @@ export const FetchDatabase = async (p) => {
63
68
  if (dataSource && dataSource.properties) {
64
69
  meta.properties = dataSource.properties;
65
70
  }
71
+ // Tell which part of the query is wrong before the notion api rejects it
72
+ if (!skipQueryValidation) {
73
+ const errors = validateQuery({ properties: meta.properties, filter: params.filter, sorts: params.sorts });
74
+ if (errors.length > 0) {
75
+ throw new Error(buildQueryValidationMessage(`database ${databaseLabel(meta, database_id)}`, errors));
76
+ }
77
+ }
66
78
  // Remove database_id and add data_source_id to params
67
79
  const queryParams = { ...params, data_source_id };
68
80
  delete queryParams.database_id;
@@ -1 +1 @@
1
- {"version":3,"file":"database.js","sourceRoot":"","sources":["../../src/exporter/database.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,MAAM,GACP,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EACL,QAAQ,EACR,gBAAgB,EAChB,KAAK,GACN,MAAM,gBAAgB,CAAA;AACvB,OAAO,EACL,IAAI,EACJ,qBAAqB,EACrB,SAAS,EACT,SAAS,EACT,UAAU,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,CAAC,EAAE,EAAE,CAAC,CAAA;YACxE,EAAE,CAAC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,IAAI,CAAA;QACzB,CAAC;aAAM,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YACnC,MAAM,GAAG,GAAG,gBAAgB,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YAC1C,MAAM,IAAI,GAAG,MAAM,SAAS,CAAC,GAAG,EAAE,iBAAiB,EAAE,CAAC,EAAE,EAAE,CAAC,CAC1D;YAAC,EAAU,CAAC,IAAI,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,GAAG,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,CAAA;QAC7E,CAAC;IACH,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,KAAK,EAAE,CAAC;YACV,OAAO,CAAC,GAAG,CAAC,iCAAiC,CAAC,EAAE,CAAC,CAAA;QACnD,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -3,3 +3,4 @@ export * from './database.js';
3
3
  export * from './page.js';
4
4
  export * from './types.js';
5
5
  export * from './breadcrumbs.js';
6
+ export * from './validation.js';
@@ -3,4 +3,5 @@ export * from './database.js';
3
3
  export * from './page.js';
4
4
  export * from './types.js';
5
5
  export * from './breadcrumbs.js';
6
+ export * from './validation.js';
6
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/exporter/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,kBAAkB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/exporter/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA"}
@@ -1,4 +1,4 @@
1
- import type { QueryDataSourceResponse, ListBlockChildrenResponse, ParagraphBlockObjectResponse, Heading1BlockObjectResponse, Heading2BlockObjectResponse, Heading3BlockObjectResponse, BulletedListItemBlockObjectResponse, NumberedListItemBlockObjectResponse, QuoteBlockObjectResponse, ToDoBlockObjectResponse, ToggleBlockObjectResponse, TemplateBlockObjectResponse, SyncedBlockBlockObjectResponse, ChildPageBlockObjectResponse, ChildDatabaseBlockObjectResponse, EquationBlockObjectResponse, CodeBlockObjectResponse, CalloutBlockObjectResponse, DividerBlockObjectResponse, BreadcrumbBlockObjectResponse, TableOfContentsBlockObjectResponse, ColumnListBlockObjectResponse, ColumnBlockObjectResponse, LinkToPageBlockObjectResponse, TableBlockObjectResponse, TableRowBlockObjectResponse, EmbedBlockObjectResponse, BookmarkBlockObjectResponse, ImageBlockObjectResponse, VideoBlockObjectResponse, PdfBlockObjectResponse, FileBlockObjectResponse, AudioBlockObjectResponse, LinkPreviewBlockObjectResponse, UnsupportedBlockObjectResponse, RichTextItemResponse, GetPagePropertyResponse, PageObjectResponse, UserObjectResponse, DatabaseObjectResponse, TextRichTextItemResponse } from '@notionhq/client/build/src/api-endpoints.js';
1
+ import type { QueryDataSourceResponse, ListBlockChildrenResponse, ParagraphBlockObjectResponse, Heading1BlockObjectResponse, Heading2BlockObjectResponse, Heading3BlockObjectResponse, BulletedListItemBlockObjectResponse, NumberedListItemBlockObjectResponse, QuoteBlockObjectResponse, ToDoBlockObjectResponse, ToggleBlockObjectResponse, TemplateBlockObjectResponse, SyncedBlockBlockObjectResponse, ChildPageBlockObjectResponse, ChildDatabaseBlockObjectResponse, EquationBlockObjectResponse, CodeBlockObjectResponse, CalloutBlockObjectResponse, DividerBlockObjectResponse, BreadcrumbBlockObjectResponse, TableOfContentsBlockObjectResponse, ColumnListBlockObjectResponse, ColumnBlockObjectResponse, LinkToPageBlockObjectResponse, TableBlockObjectResponse, TableRowBlockObjectResponse, EmbedBlockObjectResponse, BookmarkBlockObjectResponse, ImageBlockObjectResponse, VideoBlockObjectResponse, PdfBlockObjectResponse, FileBlockObjectResponse, AudioBlockObjectResponse, LinkPreviewBlockObjectResponse, UnsupportedBlockObjectResponse, RichTextItemResponse, NumberFormat, GetPagePropertyResponse, PageObjectResponse, UserObjectResponse, DatabaseObjectResponse } from '@notionhq/client/build/src/api-endpoints.js';
2
2
  import { LinkPreviewGithubRepo, LinkPreviewGithubIssue } from './github.js';
3
3
  export * from '@notionhq/client/build/src/api-endpoints.js';
4
4
  export type IdRequest = string | string;
@@ -376,106 +376,7 @@ export type DBPageBase = {
376
376
  } | null;
377
377
  properties: {};
378
378
  };
379
- export type DBProperties = Record<string, {
380
- type: 'title';
381
- title: Array<RichTextItemResponse>;
382
- id: string;
383
- } | {
384
- type: 'rich_text';
385
- rich_text: Array<RichTextItemResponse>;
386
- id: string;
387
- } | {
388
- type: 'number';
389
- number: number | null;
390
- id: string;
391
- } | {
392
- type: 'url';
393
- url: string | null;
394
- id: string;
395
- } | {
396
- type: 'select';
397
- select: SelectPropertyResponse | null;
398
- id: string;
399
- } | {
400
- type: 'multi_select';
401
- multi_select: Array<SelectPropertyResponse>;
402
- id: string;
403
- } | {
404
- type: 'people';
405
- people: Array<PartialUserObjectResponse>;
406
- id: string;
407
- } | {
408
- type: 'email';
409
- email: string | null;
410
- id: string;
411
- } | {
412
- type: 'phone_number';
413
- phone_number: string | null;
414
- id: string;
415
- } | {
416
- type: 'date';
417
- date: DateResponse | null;
418
- id: string;
419
- } | {
420
- type: 'files';
421
- files: Array<{
422
- file: {
423
- url: string;
424
- expiry_time: string;
425
- };
426
- name: StringRequest;
427
- type?: 'file';
428
- } | {
429
- external: {
430
- url: TextRequest;
431
- };
432
- name: StringRequest;
433
- type?: 'external';
434
- }>;
435
- id: string;
436
- } | {
437
- type: 'checkbox';
438
- checkbox: boolean;
439
- id: string;
440
- } | {
441
- type: 'formula';
442
- formula: {
443
- type: 'string';
444
- string: string | null;
445
- } | {
446
- type: 'date';
447
- date: DateResponse | null;
448
- } | {
449
- type: 'number';
450
- number: number | null;
451
- } | {
452
- type: 'boolean';
453
- boolean: boolean | null;
454
- };
455
- id: string;
456
- } | {
457
- type: 'relation';
458
- relation: Array<{
459
- id: string;
460
- }>;
461
- id: string;
462
- } | {
463
- type: 'created_time';
464
- created_time: string;
465
- id: string;
466
- } | {
467
- type: 'created_by';
468
- created_by: PartialUserObjectResponse;
469
- id: string;
470
- } | {
471
- type: 'last_edited_time';
472
- last_edited_time: string;
473
- id: string;
474
- } | {
475
- type: 'last_edited_by';
476
- last_edited_by: PartialUserObjectResponse;
477
- id: string;
478
- }>;
379
+ export type DBProperties = Record<string, DatabasePropertyValue>;
479
380
  export type QueryDatabaseResponseResult = {
480
381
  parent: {
481
382
  type: 'database_id';
@@ -626,28 +527,43 @@ export type Parent = {
626
527
  type: "agent_id";
627
528
  agent_id: string;
628
529
  };
629
- export type DatabaseProperty = DatabasePropertyConfigResponse;
630
- export type DatabasePropertyConfigResponse = NumberDatabasePropertyConfigResponse | FormulaDatabasePropertyConfigResponse | SelectDatabasePropertyConfigResponse | MultiSelectDatabasePropertyConfigResponse | StatusDatabasePropertyConfigResponse | RelationDatabasePropertyConfigResponse | RollupDatabasePropertyConfigResponse | UniqueIdDatabasePropertyConfigResponse | TitleDatabasePropertyConfigResponse | RichTextDatabasePropertyConfigResponse | UrlDatabasePropertyConfigResponse | PeopleDatabasePropertyConfigResponse | FilesDatabasePropertyConfigResponse | EmailDatabasePropertyConfigResponse | PhoneNumberDatabasePropertyConfigResponse | DateDatabasePropertyConfigResponse | CheckboxDatabasePropertyConfigResponse | CreatedByDatabasePropertyConfigResponse | CreatedTimeDatabasePropertyConfigResponse | LastEditedByDatabasePropertyConfigResponse | LastEditedTimeDatabasePropertyConfigResponse;
530
+ export type DatabaseProperty = DatabasePropertyValue;
531
+ export type DatabasePropertyConfigResponse = DatabasePropertyConfigResponseCommon & (NumberDatabasePropertyConfigResponse | FormulaDatabasePropertyConfigResponse | SelectDatabasePropertyConfigResponse | MultiSelectDatabasePropertyConfigResponse | StatusDatabasePropertyConfigResponse | RelationDatabasePropertyConfigResponse | RollupDatabasePropertyConfigResponse | UniqueIdDatabasePropertyConfigResponse | TitleDatabasePropertyConfigResponse | RichTextDatabasePropertyConfigResponse | UrlDatabasePropertyConfigResponse | PeopleDatabasePropertyConfigResponse | FilesDatabasePropertyConfigResponse | EmailDatabasePropertyConfigResponse | PhoneNumberDatabasePropertyConfigResponse | DateDatabasePropertyConfigResponse | CheckboxDatabasePropertyConfigResponse | CreatedByDatabasePropertyConfigResponse | CreatedTimeDatabasePropertyConfigResponse | LastEditedByDatabasePropertyConfigResponse | LastEditedTimeDatabasePropertyConfigResponse | ButtonDatabasePropertyConfigResponse | VerificationDatabasePropertyConfigResponse);
532
+ export type DatabasePropertyConfigResponseCommon = {
533
+ id: string;
534
+ name: string;
535
+ description: string | null;
536
+ };
631
537
  type RollupFunction = "count" | "count_values" | "empty" | "not_empty" | "unique" | "show_unique" | "percent_empty" | "percent_not_empty" | "sum" | "average" | "median" | "min" | "max" | "range" | "earliest_date" | "latest_date" | "date_range" | "checked" | "unchecked" | "percent_checked" | "percent_unchecked" | "count_per_group" | "percent_per_group" | "show_original";
538
+ export type SelectOptionResponse = SelectPropertyResponse & {
539
+ description: string | null;
540
+ };
541
+ export type StatusOptionResponse = StatusPropertyResponse & {
542
+ description: string | null;
543
+ };
632
544
  export type NumberDatabasePropertyConfigResponse = {
633
545
  type: "number";
634
- number: number | null;
635
- id: string;
546
+ number: {
547
+ format: NumberFormat;
548
+ };
636
549
  };
637
550
  export type FormulaDatabasePropertyConfigResponse = {
638
551
  type: "formula";
639
- formula: NumberDatabasePropertyConfigResponse;
640
- id: string;
552
+ formula: {
553
+ expression: string;
554
+ };
641
555
  };
642
556
  export type SelectDatabasePropertyConfigResponse = {
643
557
  type: "select";
644
- select: SelectPropertyResponse;
645
- id: string;
558
+ select: {
559
+ options: Array<SelectOptionResponse>;
560
+ };
646
561
  };
647
562
  export type MultiSelectDatabasePropertyConfigResponse = {
648
563
  type: "multi_select";
649
- multi_select: SelectPropertyResponse[];
650
- id: string;
564
+ multi_select: {
565
+ options: Array<SelectOptionResponse>;
566
+ };
651
567
  };
652
568
  export type StatusPropertyResponse = {
653
569
  id: StringRequest;
@@ -657,7 +573,7 @@ export type StatusPropertyResponse = {
657
573
  export type StatusDatabasePropertyConfigResponse = {
658
574
  type: "status";
659
575
  status: {
660
- options: Array<StatusPropertyResponse>;
576
+ options: Array<StatusOptionResponse>;
661
577
  groups: Array<{
662
578
  id: StringRequest;
663
579
  name: StringRequest;
@@ -665,12 +581,10 @@ export type StatusDatabasePropertyConfigResponse = {
665
581
  option_ids: Array<string>;
666
582
  }>;
667
583
  };
668
- id: string;
669
584
  };
670
585
  export type SinglePropertyDatabasePropertyRelationConfigResponse = {
671
586
  type: "single_property";
672
587
  single_property: EmptyObject;
673
- database_id: IdRequest;
674
588
  };
675
589
  export type DualPropertyDatabasePropertyRelationConfigResponse = {
676
590
  type: "dual_property";
@@ -678,13 +592,14 @@ export type DualPropertyDatabasePropertyRelationConfigResponse = {
678
592
  synced_property_id: StringRequest;
679
593
  synced_property_name: StringRequest;
680
594
  };
681
- database_id: IdRequest;
682
595
  };
683
- export type DatabasePropertyRelationConfigResponse = SinglePropertyDatabasePropertyRelationConfigResponse | DualPropertyDatabasePropertyRelationConfigResponse;
596
+ export type DatabasePropertyRelationConfigResponse = {
597
+ database_id: IdRequest;
598
+ data_source_id: IdRequest;
599
+ } & (SinglePropertyDatabasePropertyRelationConfigResponse | DualPropertyDatabasePropertyRelationConfigResponse);
684
600
  export type RelationDatabasePropertyConfigResponse = {
685
601
  type: "relation";
686
602
  relation: DatabasePropertyRelationConfigResponse;
687
- id: string;
688
603
  };
689
604
  export type RollupDatabasePropertyConfigResponse = {
690
605
  type: "rollup";
@@ -695,79 +610,204 @@ export type RollupDatabasePropertyConfigResponse = {
695
610
  relation_property_id: string;
696
611
  function: RollupFunction;
697
612
  };
698
- id: string;
699
613
  };
700
614
  export type UniqueIdDatabasePropertyConfigResponse = {
701
615
  type: "unique_id";
702
616
  unique_id: {
703
617
  prefix: string | null;
704
618
  };
705
- id: string;
706
619
  };
707
620
  export type TitleDatabasePropertyConfigResponse = {
708
621
  type: "title";
709
- title: TextRichTextItemResponse[];
710
- id: string;
622
+ title: EmptyObject;
711
623
  };
712
624
  export type RichTextDatabasePropertyConfigResponse = {
713
625
  type: "rich_text";
714
- rich_text: TextRichTextItemResponse[];
715
- id: string;
626
+ rich_text: EmptyObject;
716
627
  };
717
628
  export type UrlDatabasePropertyConfigResponse = {
718
629
  type: "url";
719
- url: string | null;
720
- id: string;
630
+ url: EmptyObject;
721
631
  };
722
632
  export type PeopleDatabasePropertyConfigResponse = {
723
633
  type: "people";
724
634
  people: EmptyObject;
725
- id: string;
726
635
  };
727
636
  export type FilesDatabasePropertyConfigResponse = {
728
637
  type: "files";
729
638
  files: EmptyObject;
730
- id: string;
731
639
  };
732
640
  export type EmailDatabasePropertyConfigResponse = {
733
641
  type: "email";
734
- email: string | null;
735
- id: string;
642
+ email: EmptyObject;
736
643
  };
737
644
  export type PhoneNumberDatabasePropertyConfigResponse = {
738
645
  type: "phone_number";
739
- phone_number: number | null;
740
- id: string;
646
+ phone_number: EmptyObject;
741
647
  };
742
648
  export type DateDatabasePropertyConfigResponse = {
743
649
  type: "date";
744
- date: DateResponse | null;
745
- id: string;
650
+ date: EmptyObject;
746
651
  };
747
652
  export type CheckboxDatabasePropertyConfigResponse = {
748
653
  type: "checkbox";
749
- checkbox: boolean;
750
- id: string;
654
+ checkbox: EmptyObject;
751
655
  };
752
656
  export type CreatedByDatabasePropertyConfigResponse = {
753
657
  type: "created_by";
754
658
  created_by: EmptyObject;
755
- id: string;
756
659
  };
757
660
  export type CreatedTimeDatabasePropertyConfigResponse = {
758
661
  type: "created_time";
759
662
  created_time: EmptyObject;
760
- id: string;
761
663
  };
762
664
  export type LastEditedByDatabasePropertyConfigResponse = {
763
665
  type: "last_edited_by";
764
666
  last_edited_by: EmptyObject;
765
- id: string;
766
667
  };
767
668
  export type LastEditedTimeDatabasePropertyConfigResponse = {
768
669
  type: "last_edited_time";
769
670
  last_edited_time: EmptyObject;
671
+ };
672
+ export type ButtonDatabasePropertyConfigResponse = {
673
+ type: "button";
674
+ button: EmptyObject;
675
+ };
676
+ export type VerificationDatabasePropertyConfigResponse = {
677
+ type: "verification";
678
+ verification: EmptyObject;
679
+ };
680
+ export type DatabasePropertyValue = {
770
681
  id: string;
682
+ } & (SimpleOrArrayPropertyValueResponse | {
683
+ type: 'rollup';
684
+ rollup: RollupPropertyValueResponse;
685
+ });
686
+ export type SimpleOrArrayPropertyValueResponse = {
687
+ type: 'title';
688
+ title: Array<RichTextItemResponse>;
689
+ } | {
690
+ type: 'rich_text';
691
+ rich_text: Array<RichTextItemResponse>;
692
+ } | {
693
+ type: 'people';
694
+ people: Array<PartialUserObjectResponse>;
695
+ } | {
696
+ type: 'relation';
697
+ relation: Array<{
698
+ id: IdRequest;
699
+ }>;
700
+ } | {
701
+ type: 'number';
702
+ number: number | null;
703
+ } | {
704
+ type: 'url';
705
+ url: string | null;
706
+ } | {
707
+ type: 'select';
708
+ select: SelectPropertyResponse | null;
709
+ } | {
710
+ type: 'multi_select';
711
+ multi_select: Array<SelectPropertyResponse>;
712
+ } | {
713
+ type: 'status';
714
+ status: StatusPropertyResponse | null;
715
+ } | {
716
+ type: 'date';
717
+ date: DateResponse | null;
718
+ } | {
719
+ type: 'email';
720
+ email: string | null;
721
+ } | {
722
+ type: 'phone_number';
723
+ phone_number: string | null;
724
+ } | {
725
+ type: 'checkbox';
726
+ checkbox: boolean;
727
+ } | {
728
+ type: 'files';
729
+ files: Array<FileWithNameResponse>;
730
+ } | {
731
+ type: 'created_by';
732
+ created_by: PartialUserObjectResponse;
733
+ } | {
734
+ type: 'created_time';
735
+ created_time: string;
736
+ } | {
737
+ type: 'last_edited_by';
738
+ last_edited_by: PartialUserObjectResponse;
739
+ } | {
740
+ type: 'last_edited_time';
741
+ last_edited_time: string;
742
+ } | {
743
+ type: 'formula';
744
+ formula: FormulaPropertyValueResponse;
745
+ } | {
746
+ type: 'button';
747
+ button: EmptyObject;
748
+ } | {
749
+ type: 'unique_id';
750
+ unique_id: {
751
+ prefix: string | null;
752
+ number: number | null;
753
+ };
754
+ } | {
755
+ type: 'verification';
756
+ verification: VerificationPropertyValueResponse | null;
757
+ };
758
+ export type FileWithNameResponse = {
759
+ name: StringRequest;
760
+ } & ({
761
+ type: 'file';
762
+ file: {
763
+ url: string;
764
+ expiry_time: string;
765
+ };
766
+ } | {
767
+ type: 'external';
768
+ external: {
769
+ url: TextRequest;
770
+ };
771
+ });
772
+ export type FormulaPropertyValueResponse = {
773
+ type: 'string';
774
+ string: string | null;
775
+ } | {
776
+ type: 'date';
777
+ date: DateResponse | null;
778
+ } | {
779
+ type: 'number';
780
+ number: number | null;
781
+ } | {
782
+ type: 'boolean';
783
+ boolean: boolean | null;
784
+ } | {
785
+ type: 'unsupported';
786
+ unsupported: EmptyObject;
787
+ };
788
+ export type RollupPropertyValueResponse = {
789
+ function: RollupFunction;
790
+ } & ({
791
+ type: 'number';
792
+ number: number | null;
793
+ } | {
794
+ type: 'date';
795
+ date: DateResponse | null;
796
+ } | {
797
+ type: 'array';
798
+ array: Array<SimpleOrArrayPropertyValueResponse>;
799
+ } | {
800
+ type: 'unsupported';
801
+ unsupported: EmptyObject;
802
+ });
803
+ export type VerificationPropertyValueResponse = {
804
+ state: 'unverified';
805
+ date: null;
806
+ verified_by: null;
807
+ } | {
808
+ state: 'verified' | 'expired';
809
+ date: DateResponse | null;
810
+ verified_by: PartialUserObjectResponse | null;
771
811
  };
772
812
  export type ImagePathWithSize = {
773
813
  path: string;
@@ -0,0 +1,15 @@
1
+ import type { DatabasePropertyConfigResponse } from './types.js';
2
+ export type QueryProperties = Record<string, DatabasePropertyConfigResponse>;
3
+ export interface ValidateQueryArgs {
4
+ properties?: QueryProperties | undefined;
5
+ filter?: unknown;
6
+ sorts?: unknown;
7
+ }
8
+ /**
9
+ * validateQuery checks a query against the database properties and returns
10
+ * human readable messages for every problem it finds. The Notion API rejects
11
+ * such a query with a validation error that does not tell which part of the
12
+ * query is wrong, so this runs before the request is sent.
13
+ */
14
+ export declare const validateQuery: ({ properties, filter, sorts }: ValidateQueryArgs) => string[];
15
+ export declare const buildQueryValidationMessage: (target: string, errors: string[]) => string;