@jeromefitz/notion 6.2.0-canary.1 → 7.0.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.
- package/{dist/utils/get-types/_unsupported.mjs → _unsupported-BUIwc9lr.mjs} +2 -2
- package/_unsupported-BUIwc9lr.mjs.map +1 -0
- package/{dist/utils/add-time/index.mjs → add-time-B_LfV4Ex.mjs} +2 -2
- package/add-time-B_LfV4Ex.mjs.map +1 -0
- package/checkbox-Cil1erOZ.mjs +2 -0
- package/checkbox-Cil1erOZ.mjs.map +1 -0
- package/constants/index.d.mts +2 -0
- package/constants/index.mjs +1 -0
- package/{dist/constants/index.mjs → constants-C2jPji6h.mjs} +2 -2
- package/constants-C2jPji6h.mjs.map +1 -0
- package/date-IJAT1r3Y.mjs +2 -0
- package/date-IJAT1r3Y.mjs.map +1 -0
- package/dist-BQciLh9t.mjs +2 -0
- package/dist-BQciLh9t.mjs.map +1 -0
- package/email-DygPLxSo.mjs +2 -0
- package/email-DygPLxSo.mjs.map +1 -0
- package/{dist/utils/get-types/files.mjs → files-Dx1jw5iY.mjs} +2 -2
- package/files-Dx1jw5iY.mjs.map +1 -0
- package/{dist/queries/get-blocks-by-id-children/index.mjs → get-blocks-by-id-children-BRe4p0pZ.mjs} +2 -2
- package/get-blocks-by-id-children-BRe4p0pZ.mjs.map +1 -0
- package/get-data-type-B5X5VOmp.mjs +2 -0
- package/get-data-type-B5X5VOmp.mjs.map +1 -0
- package/get-databases-by-id-query-CI9TMkPN.mjs +2 -0
- package/get-databases-by-id-query-CI9TMkPN.mjs.map +1 -0
- package/{dist/queries/get-deep-fetch-all-children/index.mjs → get-deep-fetch-all-children-DVZ-HFbN.mjs} +2 -2
- package/get-deep-fetch-all-children-DVZ-HFbN.mjs.map +1 -0
- package/{dist/queries/get-info-type/index.mjs → get-info-type-CUsHqtfs.mjs} +2 -2
- package/get-info-type-CUsHqtfs.mjs.map +1 -0
- package/get-notion-listing-JJxOipMx.mjs +2 -0
- package/get-notion-listing-JJxOipMx.mjs.map +1 -0
- package/get-notion-listing-by-date-CSKBdFDQ.mjs +2 -0
- package/get-notion-listing-by-date-CSKBdFDQ.mjs.map +1 -0
- package/get-notion-slug-BecwpT0b.mjs +2 -0
- package/get-notion-slug-BecwpT0b.mjs.map +1 -0
- package/get-notion-slug-by-route-Dh428D_m.mjs +2 -0
- package/get-notion-slug-by-route-Dh428D_m.mjs.map +1 -0
- package/{dist/queries/get-pages-by-id/index.mjs → get-pages-by-id-D_3I7OED.mjs} +2 -2
- package/get-pages-by-id-D_3I7OED.mjs.map +1 -0
- package/get-path-variables-CnBrxTgg.mjs +2 -0
- package/get-path-variables-CnBrxTgg.mjs.map +1 -0
- package/get-query-ljtSpKL5.mjs +2 -0
- package/get-query-ljtSpKL5.mjs.map +1 -0
- package/{dist/utils/get-title/index.mjs → get-title-BWc2Ckhi.mjs} +2 -2
- package/get-title-BWc2Ckhi.mjs.map +1 -0
- package/get-types-Clb6OmBv.mjs +2 -0
- package/{dist/get-types-7QEbhRzY.mjs.map → get-types-Clb6OmBv.mjs.map} +1 -1
- package/{dist/constants/index.d.mts → index-BD5kzRhY.d.mts} +3 -3
- package/index-BD5kzRhY.d.mts.map +1 -0
- package/{dist/utils/get-data-type/index.d.mts → index-BGofpiiB.d.mts} +3 -3
- package/index-BGofpiiB.d.mts.map +1 -0
- package/{dist/queries/get-notion-listing-by-date/index.d.mts → index-BIttGCzA.d.mts} +2 -2
- package/index-BIttGCzA.d.mts.map +1 -0
- package/{dist/queries/get-pages-by-id/index.d.mts → index-C-J3ICp0.d.mts} +2 -2
- package/index-C-J3ICp0.d.mts.map +1 -0
- package/{dist/queries/get-notion-slug-by-route/index.d.mts → index-CLQVoKDp.d.mts} +2 -2
- package/index-CLQVoKDp.d.mts.map +1 -0
- package/{dist/queries/get-databases-by-id-query/index.d.mts → index-CucnheQT.d.mts} +3 -3
- package/index-CucnheQT.d.mts.map +1 -0
- package/{dist/queries/get-path-variables/index.d.mts → index-D16uYjWr.d.mts} +3 -3
- package/index-D16uYjWr.d.mts.map +1 -0
- package/{dist/queries/get-notion-listing/index.d.mts → index-D4Gn1cYC.d.mts} +2 -2
- package/index-D4Gn1cYC.d.mts.map +1 -0
- package/{dist/utils/data-normalized-results/index.d.mts → index-DMqCumJi.d.mts} +2 -2
- package/index-DMqCumJi.d.mts.map +1 -0
- package/{dist/utils/get-types/index.d.mts → index-DZSqTeBx.d.mts} +2 -2
- package/index-DZSqTeBx.d.mts.map +1 -0
- package/{dist/utils/data-normalized/index.d.mts → index-DZjFlXjH.d.mts} +2 -2
- package/index-DZjFlXjH.d.mts.map +1 -0
- package/{dist/queries/get-deep-fetch-all-children/index.d.mts → index-D_fBH_D4.d.mts} +2 -2
- package/index-D_fBH_D4.d.mts.map +1 -0
- package/{dist/queries/get-notion-slug/index.d.mts → index-Dx2yW5u0.d.mts} +2 -2
- package/index-Dx2yW5u0.d.mts.map +1 -0
- package/{dist/utils/add-time/index.d.mts → index-DxiWPo1l.d.mts} +2 -2
- package/index-DxiWPo1l.d.mts.map +1 -0
- package/{dist/queries/get-info-type/index.d.mts → index-H5Qko6iL.d.mts} +2 -2
- package/index-H5Qko6iL.d.mts.map +1 -0
- package/{dist/utils/get-title/index.d.mts → index-iru-ct3u.d.mts} +2 -2
- package/index-iru-ct3u.d.mts.map +1 -0
- package/{dist/queries/get-blocks-by-id-children/index.d.mts → index-oAghjuN5.d.mts} +2 -2
- package/index-oAghjuN5.d.mts.map +1 -0
- package/{dist/queries/get-query/index.d.mts → index-wMZIVRBv.d.mts} +2 -2
- package/index-wMZIVRBv.d.mts.map +1 -0
- package/{dist/index.d.mts → index.d.mts} +1 -1
- package/index.d.mts.map +1 -0
- package/index.mjs +2 -0
- package/index.mjs.map +1 -0
- package/index.test.d.mts +1 -0
- package/index.test.mjs +129 -0
- package/index.test.mjs.map +1 -0
- package/magic-string.es-D6kIB8Km.mjs +18 -0
- package/magic-string.es-D6kIB8Km.mjs.map +1 -0
- package/{dist/utils/get-types/multi-select.mjs → multi-select-BTDQCZWJ.mjs} +2 -2
- package/multi-select-BTDQCZWJ.mjs.map +1 -0
- package/number-DXsVfS7U.mjs +2 -0
- package/number-DXsVfS7U.mjs.map +1 -0
- package/package.json +57 -208
- package/{dist/utils/get-types/people.mjs → people-Ognwaka4.mjs} +2 -2
- package/people-Ognwaka4.mjs.map +1 -0
- package/phone-number-D-jSJ6fm.mjs +2 -0
- package/phone-number-D-jSJ6fm.mjs.map +1 -0
- package/queries/get-blocks-by-id-children/index.d.mts +2 -0
- package/queries/get-blocks-by-id-children/index.mjs +1 -0
- package/queries/get-databases-by-id-query/index.d.mts +2 -0
- package/queries/get-databases-by-id-query/index.mjs +1 -0
- package/queries/get-deep-fetch-all-children/index.d.mts +2 -0
- package/queries/get-deep-fetch-all-children/index.mjs +1 -0
- package/queries/get-info-type/index.d.mts +2 -0
- package/queries/get-info-type/index.mjs +1 -0
- package/queries/get-notion-listing/index.d.mts +2 -0
- package/queries/get-notion-listing/index.mjs +1 -0
- package/queries/get-notion-listing-by-date/index.d.mts +2 -0
- package/queries/get-notion-listing-by-date/index.mjs +1 -0
- package/queries/get-notion-slug/index.d.mts +2 -0
- package/queries/get-notion-slug/index.mjs +1 -0
- package/queries/get-notion-slug-by-route/index.d.mts +2 -0
- package/queries/get-notion-slug-by-route/index.mjs +1 -0
- package/queries/get-pages-by-id/index.d.mts +2 -0
- package/queries/get-pages-by-id/index.mjs +1 -0
- package/queries/get-path-variables/index.d.mts +2 -0
- package/queries/get-path-variables/index.mjs +1 -0
- package/queries/get-query/index.d.mts +2 -0
- package/queries/get-query/index.mjs +1 -0
- package/queries/index.d.mts +12 -0
- package/queries/index.mjs +1 -0
- package/queries-CCGQpuUT.mjs +1 -0
- package/{dist/utils/get-types/rich-text.mjs → rich-text-pNpMuY2o.mjs} +2 -2
- package/rich-text-pNpMuY2o.mjs.map +1 -0
- package/{dist/utils/get-types/select.mjs → select-i6mHDBMN.mjs} +2 -2
- package/select-i6mHDBMN.mjs.map +1 -0
- package/title-vmIyt8-r.mjs +2 -0
- package/title-vmIyt8-r.mjs.map +1 -0
- package/url-D7qu9nU2.mjs +2 -0
- package/url-D7qu9nU2.mjs.map +1 -0
- package/utils/add-time/index.d.mts +2 -0
- package/utils/add-time/index.mjs +1 -0
- package/utils/data-normalized/index.d.mts +2 -0
- package/utils/data-normalized/index.mjs +1 -0
- package/utils/data-normalized-results/index.d.mts +2 -0
- package/utils/data-normalized-results/index.mjs +1 -0
- package/utils/get-data-type/index.d.mts +2 -0
- package/utils/get-data-type/index.mjs +1 -0
- package/utils/get-title/index.d.mts +2 -0
- package/utils/get-title/index.mjs +1 -0
- package/utils/get-types/_unsupported.mjs +1 -0
- package/utils/get-types/checkbox.mjs +1 -0
- package/utils/get-types/date.mjs +1 -0
- package/utils/get-types/email.mjs +1 -0
- package/utils/get-types/files.mjs +1 -0
- package/utils/get-types/index.d.mts +2 -0
- package/utils/get-types/index.mjs +1 -0
- package/utils/get-types/multi-select.mjs +1 -0
- package/utils/get-types/number.mjs +1 -0
- package/utils/get-types/people.mjs +1 -0
- package/utils/get-types/phone-number.mjs +1 -0
- package/utils/get-types/relation.mjs +1 -0
- package/utils/get-types/rich-text.mjs +1 -0
- package/utils/get-types/rollup.mjs +1 -0
- package/utils/get-types/select.mjs +1 -0
- package/utils/get-types/title.mjs +1 -0
- package/utils/get-types/url.mjs +1 -0
- package/utils/index.d.mts +7 -0
- package/utils/index.mjs +1 -0
- package/utils-B1QU_ezs.mjs +2 -0
- package/{dist/utils-SxsCJsDP.mjs.map → utils-B1QU_ezs.mjs.map} +1 -1
- package/.turbo/turbo-build.log +0 -4
- package/.turbo/turbo-lint$colon$ts.log +0 -1
- package/dist/constants/index.d.mts.map +0 -1
- package/dist/constants/index.mjs.map +0 -1
- package/dist/get-types-7QEbhRzY.mjs +0 -2
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs +0 -2
- package/dist/index.mjs.map +0 -1
- package/dist/queries/get-blocks-by-id-children/index.d.mts.map +0 -1
- package/dist/queries/get-blocks-by-id-children/index.mjs.map +0 -1
- package/dist/queries/get-databases-by-id-query/index.d.mts.map +0 -1
- package/dist/queries/get-databases-by-id-query/index.mjs +0 -2
- package/dist/queries/get-databases-by-id-query/index.mjs.map +0 -1
- package/dist/queries/get-deep-fetch-all-children/index.d.mts.map +0 -1
- package/dist/queries/get-deep-fetch-all-children/index.mjs.map +0 -1
- package/dist/queries/get-info-type/index.d.mts.map +0 -1
- package/dist/queries/get-info-type/index.mjs.map +0 -1
- package/dist/queries/get-notion-listing/index.d.mts.map +0 -1
- package/dist/queries/get-notion-listing/index.mjs +0 -2
- package/dist/queries/get-notion-listing/index.mjs.map +0 -1
- package/dist/queries/get-notion-listing-by-date/index.d.mts.map +0 -1
- package/dist/queries/get-notion-listing-by-date/index.mjs +0 -2
- package/dist/queries/get-notion-listing-by-date/index.mjs.map +0 -1
- package/dist/queries/get-notion-slug/index.d.mts.map +0 -1
- package/dist/queries/get-notion-slug/index.mjs +0 -2
- package/dist/queries/get-notion-slug/index.mjs.map +0 -1
- package/dist/queries/get-notion-slug-by-route/index.d.mts.map +0 -1
- package/dist/queries/get-notion-slug-by-route/index.mjs +0 -2
- package/dist/queries/get-notion-slug-by-route/index.mjs.map +0 -1
- package/dist/queries/get-pages-by-id/index.d.mts.map +0 -1
- package/dist/queries/get-pages-by-id/index.mjs.map +0 -1
- package/dist/queries/get-path-variables/index.d.mts.map +0 -1
- package/dist/queries/get-path-variables/index.mjs +0 -2
- package/dist/queries/get-path-variables/index.mjs.map +0 -1
- package/dist/queries/get-query/index.d.mts.map +0 -1
- package/dist/queries/get-query/index.mjs +0 -2
- package/dist/queries/get-query/index.mjs.map +0 -1
- package/dist/queries/index.d.mts +0 -12
- package/dist/queries/index.mjs +0 -1
- package/dist/utils/add-time/index.d.mts.map +0 -1
- package/dist/utils/add-time/index.mjs.map +0 -1
- package/dist/utils/data-normalized/index.d.mts.map +0 -1
- package/dist/utils/data-normalized/index.mjs +0 -1
- package/dist/utils/data-normalized-results/index.d.mts.map +0 -1
- package/dist/utils/data-normalized-results/index.mjs +0 -1
- package/dist/utils/get-data-type/index.d.mts.map +0 -1
- package/dist/utils/get-data-type/index.mjs +0 -2
- package/dist/utils/get-data-type/index.mjs.map +0 -1
- package/dist/utils/get-title/index.d.mts.map +0 -1
- package/dist/utils/get-title/index.mjs.map +0 -1
- package/dist/utils/get-types/_unsupported.mjs.map +0 -1
- package/dist/utils/get-types/checkbox.mjs +0 -2
- package/dist/utils/get-types/checkbox.mjs.map +0 -1
- package/dist/utils/get-types/date.mjs +0 -2
- package/dist/utils/get-types/date.mjs.map +0 -1
- package/dist/utils/get-types/email.mjs +0 -2
- package/dist/utils/get-types/email.mjs.map +0 -1
- package/dist/utils/get-types/files.mjs.map +0 -1
- package/dist/utils/get-types/index.d.mts.map +0 -1
- package/dist/utils/get-types/index.mjs +0 -1
- package/dist/utils/get-types/multi-select.mjs.map +0 -1
- package/dist/utils/get-types/number.mjs +0 -2
- package/dist/utils/get-types/number.mjs.map +0 -1
- package/dist/utils/get-types/people.mjs.map +0 -1
- package/dist/utils/get-types/phone-number.mjs +0 -2
- package/dist/utils/get-types/phone-number.mjs.map +0 -1
- package/dist/utils/get-types/relation.mjs +0 -1
- package/dist/utils/get-types/rich-text.mjs.map +0 -1
- package/dist/utils/get-types/rollup.mjs +0 -1
- package/dist/utils/get-types/select.mjs.map +0 -1
- package/dist/utils/get-types/title.mjs +0 -2
- package/dist/utils/get-types/title.mjs.map +0 -1
- package/dist/utils/get-types/url.mjs +0 -2
- package/dist/utils/get-types/url.mjs.map +0 -1
- package/dist/utils/index.d.mts +0 -7
- package/dist/utils/index.mjs +0 -1
- package/dist/utils-SxsCJsDP.mjs +0 -2
- package/release.config.js +0 -25
- package/src/constants/index.ts +0 -1326
- package/src/index.ts +0 -151
- package/src/queries/get-blocks-by-id-children/index.ts +0 -12
- package/src/queries/get-databases-by-id-query/index.ts +0 -28
- package/src/queries/get-deep-fetch-all-children/index.ts +0 -35
- package/src/queries/get-info-type/index.ts +0 -40
- package/src/queries/get-notion-listing/index.ts +0 -91
- package/src/queries/get-notion-listing-by-date/index.ts +0 -190
- package/src/queries/get-notion-slug/index.ts +0 -64
- package/src/queries/get-notion-slug-by-route/index.ts +0 -201
- package/src/queries/get-pages-by-id/index.ts +0 -12
- package/src/queries/get-path-variables/index.ts +0 -60
- package/src/queries/get-query/index.ts +0 -140
- package/src/queries/index.ts +0 -25
- package/src/schema/index.ts +0 -386
- package/src/utils/add-time/index.ts +0 -16
- package/src/utils/data-normalized/index.ts +0 -49
- package/src/utils/data-normalized-results/index.ts +0 -29
- package/src/utils/get-data-type/index.ts +0 -62
- package/src/utils/get-title/index.ts +0 -21
- package/src/utils/get-types/_unsupported.ts +0 -7
- package/src/utils/get-types/checkbox.ts +0 -3
- package/src/utils/get-types/date.ts +0 -6
- package/src/utils/get-types/email.ts +0 -3
- package/src/utils/get-types/files.ts +0 -67
- package/src/utils/get-types/index.ts +0 -41
- package/src/utils/get-types/multi-select.ts +0 -16
- package/src/utils/get-types/number.ts +0 -6
- package/src/utils/get-types/people.ts +0 -22
- package/src/utils/get-types/phone-number.ts +0 -3
- package/src/utils/get-types/relation.ts +0 -18
- package/src/utils/get-types/rich-text.ts +0 -5
- package/src/utils/get-types/rollup.ts +0 -30
- package/src/utils/get-types/select.ts +0 -21
- package/src/utils/get-types/title.ts +0 -4
- package/src/utils/get-types/url.ts +0 -3
- package/src/utils/index.ts +0 -16
- package/tsconfig.json +0 -15
- package/tsdown.config.ts +0 -14
- /package/{dist/index-BAoq6yHe.d.mts → index-BAoq6yHe.d.mts} +0 -0
- /package/{dist/index-BAoq6yHe.d.mts.map → index-BAoq6yHe.d.mts.map} +0 -0
- /package/{dist/schema → schema}/index.d.mts +0 -0
- /package/{dist/schema → schema}/index.mjs +0 -0
- /package/{dist/utils → utils}/get-types/_unsupported.d.mts +0 -0
- /package/{dist/utils → utils}/get-types/_unsupported.d.mts.map +0 -0
- /package/{dist/utils → utils}/get-types/checkbox.d.mts +0 -0
- /package/{dist/utils → utils}/get-types/checkbox.d.mts.map +0 -0
- /package/{dist/utils → utils}/get-types/date.d.mts +0 -0
- /package/{dist/utils → utils}/get-types/date.d.mts.map +0 -0
- /package/{dist/utils → utils}/get-types/email.d.mts +0 -0
- /package/{dist/utils → utils}/get-types/email.d.mts.map +0 -0
- /package/{dist/utils → utils}/get-types/files.d.mts +0 -0
- /package/{dist/utils → utils}/get-types/files.d.mts.map +0 -0
- /package/{dist/utils → utils}/get-types/multi-select.d.mts +0 -0
- /package/{dist/utils → utils}/get-types/multi-select.d.mts.map +0 -0
- /package/{dist/utils → utils}/get-types/number.d.mts +0 -0
- /package/{dist/utils → utils}/get-types/number.d.mts.map +0 -0
- /package/{dist/utils → utils}/get-types/people.d.mts +0 -0
- /package/{dist/utils → utils}/get-types/people.d.mts.map +0 -0
- /package/{dist/utils → utils}/get-types/phone-number.d.mts +0 -0
- /package/{dist/utils → utils}/get-types/phone-number.d.mts.map +0 -0
- /package/{dist/utils → utils}/get-types/relation.d.mts +0 -0
- /package/{dist/utils → utils}/get-types/relation.d.mts.map +0 -0
- /package/{dist/utils → utils}/get-types/rich-text.d.mts +0 -0
- /package/{dist/utils → utils}/get-types/rich-text.d.mts.map +0 -0
- /package/{dist/utils → utils}/get-types/rollup.d.mts +0 -0
- /package/{dist/utils → utils}/get-types/rollup.d.mts.map +0 -0
- /package/{dist/utils → utils}/get-types/select.d.mts +0 -0
- /package/{dist/utils → utils}/get-types/select.d.mts.map +0 -0
- /package/{dist/utils → utils}/get-types/title.d.mts +0 -0
- /package/{dist/utils → utils}/get-types/title.d.mts.map +0 -0
- /package/{dist/utils → utils}/get-types/url.d.mts +0 -0
- /package/{dist/utils → utils}/get-types/url.d.mts.map +0 -0
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
import { sortObject } from "@jeromefitz/utils";
|
|
2
|
-
import { omit as _omit, size as _size } from "lodash-es";
|
|
3
|
-
|
|
4
|
-
import { DATA_TYPES, PROPERTIES, QUERIES } from "../../constants/index";
|
|
5
|
-
import { addTime, dataNormalized } from "../../utils/index";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @note Determine if PARENT|CHILD should be returned:
|
|
9
|
-
*
|
|
10
|
-
* PARENT
|
|
11
|
-
* - /[parent-routeType]/[slug]
|
|
12
|
-
* - /podcasts/jer-and-ky-and-guest
|
|
13
|
-
*
|
|
14
|
-
* CHILD
|
|
15
|
-
* - /[parent-routeType]/[child-routeType]/[slug]
|
|
16
|
-
* - /podcasts/jer-and-ky-and-guest/am-i-dracula-greg-gillotti
|
|
17
|
-
|
|
18
|
-
*
|
|
19
|
-
*/
|
|
20
|
-
const getNotionSlugByRoute__getDataByParentRouteType = async ({
|
|
21
|
-
config,
|
|
22
|
-
getBlocksByIdChildren,
|
|
23
|
-
getDatabasesByIdQuery,
|
|
24
|
-
getQuery,
|
|
25
|
-
pathVariables,
|
|
26
|
-
routeType,
|
|
27
|
-
// slug,
|
|
28
|
-
}) => {
|
|
29
|
-
const { NOTION } = config;
|
|
30
|
-
const { meta } = pathVariables;
|
|
31
|
-
|
|
32
|
-
const ROUTE_TYPE = routeType.toUpperCase();
|
|
33
|
-
|
|
34
|
-
const [parentSlug, slug] = meta;
|
|
35
|
-
const isChild = _size(meta) === 2;
|
|
36
|
-
|
|
37
|
-
const CHILD = NOTION[ROUTE_TYPE]?.hasChild?.toUpperCase();
|
|
38
|
-
|
|
39
|
-
const __info: any = await getDatabasesByIdQuery({
|
|
40
|
-
database_id: NOTION[isChild ? NOTION[CHILD].routeType.toUpperCase() : ROUTE_TYPE].database_id,
|
|
41
|
-
filter: {
|
|
42
|
-
and: [
|
|
43
|
-
{
|
|
44
|
-
...QUERIES.slug,
|
|
45
|
-
rich_text: { equals: isChild ? slug : parentSlug },
|
|
46
|
-
},
|
|
47
|
-
],
|
|
48
|
-
},
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
const _info = __info?.object === "list" && __info.results[0];
|
|
52
|
-
// @refactor(404)
|
|
53
|
-
if (!_info) {
|
|
54
|
-
return { content: {}, images: {}, info: {}, items: {} };
|
|
55
|
-
}
|
|
56
|
-
const info = _omit(_info, "properties");
|
|
57
|
-
info.properties = sortObject(
|
|
58
|
-
dataNormalized({ config, data: _info, pageId: info.id, pathVariables }),
|
|
59
|
-
);
|
|
60
|
-
const content = await getBlocksByIdChildren({ block_id: info.id });
|
|
61
|
-
let items = {};
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* @note if PARENT then get CHILDREN via `items`
|
|
65
|
-
*/
|
|
66
|
-
if (!isChild) {
|
|
67
|
-
items = await getQuery({
|
|
68
|
-
config,
|
|
69
|
-
reqQuery: {
|
|
70
|
-
databaseType: NOTION[CHILD].routeType.toUpperCase(),
|
|
71
|
-
podcasts: info.id,
|
|
72
|
-
},
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return { content, images: {}, info, items };
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* @note This is unique because the following are different:
|
|
81
|
-
*
|
|
82
|
-
* - /events/2020/05/01/jerome-and
|
|
83
|
-
* - /events/2020/05/08/jerome-and
|
|
84
|
-
* - /[routeType]/[yyyy/mm/dd]/[slug]
|
|
85
|
-
*
|
|
86
|
-
* We actually _do_ use the date for this.
|
|
87
|
-
*
|
|
88
|
-
*/
|
|
89
|
-
const getNotionSlugByRoute__getDataByListingDate = async ({
|
|
90
|
-
config,
|
|
91
|
-
getBlocksByIdChildren,
|
|
92
|
-
getDatabasesByIdQuery,
|
|
93
|
-
// getQuery,
|
|
94
|
-
pathVariables,
|
|
95
|
-
routeType,
|
|
96
|
-
slug,
|
|
97
|
-
}) => {
|
|
98
|
-
const dateTimestamp = new Date().toISOString();
|
|
99
|
-
|
|
100
|
-
const { NOTION } = config;
|
|
101
|
-
const { meta } = pathVariables;
|
|
102
|
-
|
|
103
|
-
const [year, month, day] = meta;
|
|
104
|
-
/**
|
|
105
|
-
* @hack uh... nothing to see here, haha
|
|
106
|
-
*/
|
|
107
|
-
const timestampQuery = new Date(
|
|
108
|
-
`${year ? year : dateTimestamp.slice(0, 4)}-${month ? month : "01"}-${day ? day : "01"}`,
|
|
109
|
-
);
|
|
110
|
-
const property =
|
|
111
|
-
NOTION[routeType.toUpperCase()]?.infoType?.notion ?? PROPERTIES.datePublished.notion;
|
|
112
|
-
|
|
113
|
-
const __info: any = await getDatabasesByIdQuery({
|
|
114
|
-
database_id: NOTION[routeType.toUpperCase()].database_id,
|
|
115
|
-
filter: {
|
|
116
|
-
and: [
|
|
117
|
-
{
|
|
118
|
-
date: {
|
|
119
|
-
on_or_after: addTime(timestampQuery, ""),
|
|
120
|
-
},
|
|
121
|
-
property,
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
date: {
|
|
125
|
-
before: addTime(timestampQuery, "day"),
|
|
126
|
-
},
|
|
127
|
-
property,
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
...QUERIES.slug,
|
|
131
|
-
rich_text: { equals: slug },
|
|
132
|
-
},
|
|
133
|
-
],
|
|
134
|
-
},
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
const _info = __info?.object === "list" && __info.results[0];
|
|
138
|
-
// @refactor(404)
|
|
139
|
-
if (!_info) {
|
|
140
|
-
return { content: {}, images: {}, info: {}, items: {} };
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
const info = _omit(_info, "properties");
|
|
144
|
-
info.properties = sortObject(
|
|
145
|
-
dataNormalized({ config, data: _info, pageId: info.id, pathVariables }),
|
|
146
|
-
);
|
|
147
|
-
const content = await getBlocksByIdChildren({ block_id: info.id });
|
|
148
|
-
|
|
149
|
-
return { content, images: {}, info, items: {} };
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
const getNotionSlugByRoute = async ({
|
|
153
|
-
config,
|
|
154
|
-
getBlocksByIdChildren,
|
|
155
|
-
getDatabasesByIdQuery,
|
|
156
|
-
getQuery,
|
|
157
|
-
pathVariables,
|
|
158
|
-
routeType,
|
|
159
|
-
slug,
|
|
160
|
-
}) => {
|
|
161
|
-
const { NOTION, ROUTE_TYPES_BY_DATA_TYPES } = config;
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* @custom (notion) DATA_TYPES.SLUG_BY_ROUTE -- but customized:
|
|
165
|
-
* Determine if `routeType` is a parent|child
|
|
166
|
-
*
|
|
167
|
-
* // @todo(next-notion) move to `isChild`
|
|
168
|
-
*
|
|
169
|
-
*/
|
|
170
|
-
if (NOTION[routeType?.toUpperCase()]?.hasChild) {
|
|
171
|
-
return await getNotionSlugByRoute__getDataByParentRouteType({
|
|
172
|
-
config,
|
|
173
|
-
getBlocksByIdChildren,
|
|
174
|
-
getDatabasesByIdQuery,
|
|
175
|
-
getQuery,
|
|
176
|
-
pathVariables,
|
|
177
|
-
routeType,
|
|
178
|
-
// slug,
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* @custom (notion) DATA_TYPES.LISTING_BY_DATE
|
|
184
|
-
*
|
|
185
|
-
*/
|
|
186
|
-
if (ROUTE_TYPES_BY_DATA_TYPES[DATA_TYPES.LISTING_BY_DATE].includes(routeType.toUpperCase())) {
|
|
187
|
-
return await getNotionSlugByRoute__getDataByListingDate({
|
|
188
|
-
config,
|
|
189
|
-
getBlocksByIdChildren,
|
|
190
|
-
getDatabasesByIdQuery,
|
|
191
|
-
// getQuery,
|
|
192
|
-
pathVariables,
|
|
193
|
-
routeType,
|
|
194
|
-
slug,
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
return { content: {}, images: {}, info: {}, items: {} };
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
export default getNotionSlugByRoute;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { avoidRateLimit, isUndefined } from "@jeromefitz/utils";
|
|
2
|
-
|
|
3
|
-
// @todo(types)
|
|
4
|
-
const getPagesById = async ({ getPagesRetrieve, page_id }) => {
|
|
5
|
-
if (isUndefined(page_id)) return [];
|
|
6
|
-
await avoidRateLimit(0);
|
|
7
|
-
return await getPagesRetrieve({
|
|
8
|
-
page_id,
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export default getPagesById;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @refactor(lodash)
|
|
3
|
-
*/
|
|
4
|
-
import {
|
|
5
|
-
drop as _drop,
|
|
6
|
-
dropRight as _dropRight,
|
|
7
|
-
first as _first,
|
|
8
|
-
includes as _includes,
|
|
9
|
-
isInteger as _isInteger,
|
|
10
|
-
join as _join,
|
|
11
|
-
last as _last,
|
|
12
|
-
size as _size,
|
|
13
|
-
} from "lodash-es";
|
|
14
|
-
|
|
15
|
-
// import { DATA_TYPES } from '../../constants/index'
|
|
16
|
-
import { getDataType } from "../../utils/index";
|
|
17
|
-
|
|
18
|
-
const getPathVariables = ({ catchAll, config }) => {
|
|
19
|
-
const { NOTION, PAGES__HOMEPAGE, ROUTE_META, ROUTE_TYPES } = config;
|
|
20
|
-
const size: number = _size(catchAll);
|
|
21
|
-
const first: any = _first(catchAll);
|
|
22
|
-
const FIRST = first.toUpperCase();
|
|
23
|
-
const last: any = _last(catchAll);
|
|
24
|
-
// const LAST = last.toUpperCase()
|
|
25
|
-
|
|
26
|
-
const meta =
|
|
27
|
-
size > 1 && _includes(ROUTE_META, FIRST) ? _drop(catchAll) : _drop(_dropRight(catchAll));
|
|
28
|
-
|
|
29
|
-
const routeType =
|
|
30
|
-
first === last && !_includes(ROUTE_TYPES, FIRST) ? NOTION.PAGES.routeType : first;
|
|
31
|
-
const slug = first !== last && !_isInteger(parseInt(last)) ? last : first;
|
|
32
|
-
|
|
33
|
-
const isPage = routeType === NOTION.PAGES.routeType.toLowerCase();
|
|
34
|
-
const isIndex = slug === first;
|
|
35
|
-
const hasMeta = !!meta && _size(meta) !== 0;
|
|
36
|
-
|
|
37
|
-
const url = isPage && first === PAGES__HOMEPAGE ? "" : _join(catchAll, "/");
|
|
38
|
-
|
|
39
|
-
const pathVariables = {
|
|
40
|
-
hasMeta,
|
|
41
|
-
isIndex,
|
|
42
|
-
isPage,
|
|
43
|
-
meta,
|
|
44
|
-
routeType,
|
|
45
|
-
slug,
|
|
46
|
-
url,
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
// console.dir(`> pathVariables`)
|
|
50
|
-
// console.dir(pathVariables)
|
|
51
|
-
|
|
52
|
-
const dataType = getDataType(pathVariables);
|
|
53
|
-
|
|
54
|
-
return {
|
|
55
|
-
...pathVariables,
|
|
56
|
-
dataType,
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
export default getPathVariables;
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { avoidRateLimit, isObjectEmpty } from "@jeromefitz/utils";
|
|
2
|
-
import { map as _map, omit as _omit, size as _size } from "lodash-es";
|
|
3
|
-
|
|
4
|
-
import { PROPERTIES } from "../../constants/index";
|
|
5
|
-
import type { SortItem } from "../../schema/index";
|
|
6
|
-
import dataNormalizedResults from "../../utils/data-normalized-results/index";
|
|
7
|
-
|
|
8
|
-
// const useCache = process.env.NEXT_PUBLIC__NOTION_USE_CACHE
|
|
9
|
-
// const useCache = false
|
|
10
|
-
|
|
11
|
-
const SORTS: SortItem[] = [
|
|
12
|
-
{
|
|
13
|
-
direction: "ascending",
|
|
14
|
-
property: PROPERTIES.slug.notion,
|
|
15
|
-
},
|
|
16
|
-
];
|
|
17
|
-
|
|
18
|
-
// @todo(complexity) 12
|
|
19
|
-
// oxlint-disable-next-line complexity
|
|
20
|
-
const getQuery = async ({ config, notionDatabasesQuery, reqQuery }) => {
|
|
21
|
-
const { NOTION } = config;
|
|
22
|
-
const { databaseType } = reqQuery;
|
|
23
|
-
const routeType = databaseType;
|
|
24
|
-
let hasError = false;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* @setup
|
|
28
|
-
*/
|
|
29
|
-
const DATABASE_TYPE = databaseType.toUpperCase();
|
|
30
|
-
const database_id = NOTION[DATABASE_TYPE].database_id;
|
|
31
|
-
if (!database_id) return [];
|
|
32
|
-
|
|
33
|
-
// @todo(types) any
|
|
34
|
-
let data: any = {},
|
|
35
|
-
items: any = {};
|
|
36
|
-
let filter: any, sorts: any;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* @todo(notion) move this to the api so it can be re-used
|
|
40
|
-
* not hidden in here all hacky
|
|
41
|
-
*
|
|
42
|
-
* @note(notion) right now only need this for episodes of podcasts
|
|
43
|
-
* _OR_ Related Databases (PODCASTS => EPISODES)
|
|
44
|
-
*
|
|
45
|
-
* This is not needed often and can/should probably be handled instead
|
|
46
|
-
* with Relations & Rollups rather than this customization
|
|
47
|
-
*/
|
|
48
|
-
|
|
49
|
-
if (databaseType === "EPISODES") {
|
|
50
|
-
sorts = SORTS;
|
|
51
|
-
const { podcasts } = reqQuery;
|
|
52
|
-
|
|
53
|
-
// @todo(types)
|
|
54
|
-
const filterTagEpisodesByPodcasts: any = [];
|
|
55
|
-
const podcastIds: any = [];
|
|
56
|
-
|
|
57
|
-
// oxlint-disable-next-line no-unused-expressions
|
|
58
|
-
!!podcasts && podcastIds.push(...podcasts?.split(","));
|
|
59
|
-
// oxlint-disable-next-line no-unused-expressions
|
|
60
|
-
_size(podcastIds) > 0 &&
|
|
61
|
-
_map(podcastIds, (id) =>
|
|
62
|
-
filterTagEpisodesByPodcasts.push({
|
|
63
|
-
property: PROPERTIES.relationEpisodes__Podcasts.notion,
|
|
64
|
-
relation: {
|
|
65
|
-
contains: id,
|
|
66
|
-
},
|
|
67
|
-
}),
|
|
68
|
-
);
|
|
69
|
-
filter = { or: [...filterTagEpisodesByPodcasts] };
|
|
70
|
-
} else {
|
|
71
|
-
// console.dir(`no filter`)
|
|
72
|
-
hasError = true;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// /**
|
|
76
|
-
// * @cache pre
|
|
77
|
-
// */
|
|
78
|
-
// if (useCache) {
|
|
79
|
-
// const url = catchAll.join('/')
|
|
80
|
-
// const cacheData = await getCache(url)
|
|
81
|
-
// if (!!cacheData) {
|
|
82
|
-
// data = cacheData
|
|
83
|
-
// }
|
|
84
|
-
// }
|
|
85
|
-
|
|
86
|
-
if (!hasError && (!data || isObjectEmpty(data))) {
|
|
87
|
-
await avoidRateLimit(0);
|
|
88
|
-
// @todo(types) any
|
|
89
|
-
let contentData: Pick<any, number | string | symbol>;
|
|
90
|
-
|
|
91
|
-
// oxlint-disable-next-line no-extra-boolean-cast
|
|
92
|
-
if (!!filter) {
|
|
93
|
-
// @hack(notion)-do-not-return'
|
|
94
|
-
if (filter?.or.length === 0) {
|
|
95
|
-
filter = {
|
|
96
|
-
and: [
|
|
97
|
-
{
|
|
98
|
-
property: PROPERTIES.slug.notion,
|
|
99
|
-
rich_text: { equals: "@hack(notion)-do-not-return" },
|
|
100
|
-
},
|
|
101
|
-
],
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
contentData = await notionDatabasesQuery({
|
|
105
|
-
database_id,
|
|
106
|
-
filter,
|
|
107
|
-
sorts,
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
data = contentData;
|
|
111
|
-
items = dataNormalizedResults({
|
|
112
|
-
config,
|
|
113
|
-
results: contentData.results,
|
|
114
|
-
routeType,
|
|
115
|
-
});
|
|
116
|
-
data = _omit(data, "results");
|
|
117
|
-
data.results = items;
|
|
118
|
-
} else {
|
|
119
|
-
// console.dir(`no filter`)
|
|
120
|
-
hasError = true;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// /**
|
|
124
|
-
// * @cache post
|
|
125
|
-
// */
|
|
126
|
-
// if (useCache && !!data) {
|
|
127
|
-
// const url = catchAll.join('/')
|
|
128
|
-
// // console.dir(url)
|
|
129
|
-
// const isCacheExists = await getCache(url)
|
|
130
|
-
// // console.dir(isCacheExists)
|
|
131
|
-
// if (!isCacheExists || isCacheExists === undefined) {
|
|
132
|
-
// setCache(data, url)
|
|
133
|
-
// }
|
|
134
|
-
// }
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
return data;
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
export default getQuery;
|
package/src/queries/index.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import getBlocksByIdChildren from "./get-blocks-by-id-children/index";
|
|
2
|
-
import getDatabasesByIdQuery from "./get-databases-by-id-query/index";
|
|
3
|
-
import getDeepFetchAllChildren from "./get-deep-fetch-all-children/index";
|
|
4
|
-
import getInfoType from "./get-info-type/index";
|
|
5
|
-
import getNotionListingByDate from "./get-notion-listing-by-date/index";
|
|
6
|
-
import getNotionListing from "./get-notion-listing/index";
|
|
7
|
-
import getNotionSlugByRoute from "./get-notion-slug-by-route/index";
|
|
8
|
-
import getNotionSlug from "./get-notion-slug/index";
|
|
9
|
-
import getPagesById from "./get-pages-by-id/index";
|
|
10
|
-
import getPathVariables from "./get-path-variables/index";
|
|
11
|
-
import getQuery from "./get-query/index";
|
|
12
|
-
|
|
13
|
-
export {
|
|
14
|
-
getBlocksByIdChildren,
|
|
15
|
-
getDatabasesByIdQuery,
|
|
16
|
-
getDeepFetchAllChildren,
|
|
17
|
-
getInfoType,
|
|
18
|
-
getNotionListing,
|
|
19
|
-
getNotionListingByDate,
|
|
20
|
-
getNotionSlug,
|
|
21
|
-
getNotionSlugByRoute,
|
|
22
|
-
getPagesById,
|
|
23
|
-
getPathVariables,
|
|
24
|
-
getQuery,
|
|
25
|
-
};
|