From 6c021fdc9442c270ed3f6a41130bc4baac74bd96 Mon Sep 17 00:00:00 2001 From: DrMint <29893320+DrMint@users.noreply.github.com> Date: Sat, 13 Jul 2024 18:18:03 +0200 Subject: [PATCH] Try migrating to absolute path but payload sucks --- .gitmodules | 3 + .vscode/settings.json | 10 +- package-lock.json | 56 +- package.json | 7 +- src/accesses/collections/mustBeAdmin.ts | 6 +- src/accesses/collections/mustBeAdminOrSelf.ts | 6 +- src/accesses/collections/shownOnlyToAdmin.ts | 6 +- src/accesses/fields/mustBeAdmin.ts | 6 +- src/blocks/attributeBlocks/numberBlock.ts | 4 +- src/blocks/attributeBlocks/tagsBlock.ts | 4 +- src/blocks/attributeBlocks/textBlock.ts | 4 +- src/blocks/breakBlock.ts | 2 +- src/blocks/cueBlock.ts | 2 +- src/blocks/lineBlock.ts | 2 +- src/blocks/sectionBlock.ts | 6 +- src/blocks/transcriptBlock.ts | 4 +- src/collections/Attributes/Attributes.ts | 14 +- src/collections/Audios/Audios.ts | 16 +- src/collections/Audios/endpoints/getByID.ts | 20 +- .../ChronologyEvents/ChronologyEvents.ts | 22 +- .../blocks/collectibleBlock.ts | 4 +- .../ChronologyEvents/blocks/contentBlock.ts | 2 +- .../endpoints/getAllEndpoint.ts | 16 +- .../ChronologyEvents/endpoints/getByID.ts | 4 +- .../endpoints/importFromStrapi.ts | 10 +- .../hooks/beforeValidatePopulateNameField.ts | 4 +- .../validations/validateDate.ts | 4 +- .../validateEventsTranslationsDescription.ts | 4 +- .../validateEventsTranslationsTitle.ts | 4 +- src/collections/Collectibles/Collectibles.ts | 44 +- .../Collectibles/components/RowLabel.tsx | 2 +- .../endpoints/getBySlugEndpoint.ts | 38 +- .../endpoints/getBySlugEndpointGallery.ts | 10 +- .../getBySlugEndpointGalleryImage.ts | 15 +- .../endpoints/getBySlugEndpointScanPage.ts | 15 +- .../endpoints/getBySlugEndpointScans.ts | 16 +- src/collections/CreditsRoles/CreditsRoles.ts | 10 +- src/collections/Currencies/Currencies.ts | 8 +- .../Currencies/endpoints/getAllEndpoint.ts | 6 +- .../Currencies/endpoints/importFromStrapi.ts | 4 +- src/collections/Files/Files.ts | 16 +- src/collections/Files/endpoints/getByID.ts | 16 +- src/collections/Folders/Folders.ts | 20 +- .../Folders/endpoints/getBySlugEndpoint.ts | 30 +- .../GenericContents/GenericContents.ts | 12 +- src/collections/Images/Images.ts | 16 +- src/collections/Images/endpoints/getByID.ts | 22 +- src/collections/Languages/Languages.ts | 13 +- .../Languages/endpoints/getAllEndpoint.ts | 6 +- .../Languages/endpoints/importFromStrapi.ts | 18 - .../MediaThumbnails/MediaThumbnails.ts | 8 +- src/collections/Pages/Pages.ts | 34 +- .../Pages/endpoints/getBySlugEndpoint.ts | 29 +- src/collections/Recorders/Recorders.ts | 20 +- .../Recorders/endpoints/getByID.ts | 15 +- .../Recorders/endpoints/importFromStrapi.ts | 12 +- src/collections/Scans/Scans.ts | 8 +- src/collections/Tags/Tags.ts | 12 +- src/collections/Videos/Videos.ts | 22 +- src/collections/Videos/endpoints/getByID.ts | 32 +- .../VideosChannels/VideosChannels.ts | 8 +- .../VideosSubtitles/VideosSubtitles.ts | 6 +- .../WebsiteConfig/WebsiteConfig.ts | 10 +- .../endpoints/getConfigEndpoint.ts | 12 +- src/collections/Wordings/Wordings.ts | 14 +- .../Wordings/endpoints/getAllEndpoint.ts | 8 +- src/components/QuickFilters.tsx | 2 +- src/constants.ts | 312 -------- src/endpoints/createGetByEndpoint.ts | 4 +- src/endpoints/createStrapiImportEndpoint.ts | 6 +- src/endpoints/getAllIdsEndpoint.ts | 4 +- src/endpoints/getAllSDKUrlsEndpoint.ts | 7 +- .../imageSizesRegenerationEndpoint.ts | 2 +- src/fields/attributesField/attributesField.ts | 6 +- .../backPropagationField.ts | 2 +- src/fields/componentField/componentField.ts | 2 +- src/fields/creditsField/creditsField.ts | 8 +- src/fields/iconField/iconField.ts | 2 +- src/fields/imageField/Cell.tsx | 2 +- src/fields/slugField/slugField.ts | 2 +- src/fields/translatedFields/Cell.tsx | 6 +- src/fields/translatedFields/RowLabel.tsx | 6 +- .../translatedFields/translatedFields.ts | 6 +- src/hooks/afterOperationWebhook.ts | 7 +- src/hooks/beforeDuplicateUnpublish.ts | 2 +- src/payload.config.ts | 71 +- src/sdk.ts | 727 ------------------ src/server.ts | 36 +- src/utils/asserts.ts | 7 +- src/utils/collectionConfig.ts | 4 +- src/utils/endpoints.ts | 90 +-- src/utils/imageCollectionConfig.ts | 6 +- src/utils/localApi.ts | 4 +- src/utils/string.ts | 4 +- src/utils/versionedCollectionConfig.ts | 4 +- tsconfig.json | 5 +- 96 files changed, 582 insertions(+), 1603 deletions(-) create mode 100644 .gitmodules delete mode 100644 src/collections/Languages/endpoints/importFromStrapi.ts delete mode 100644 src/constants.ts delete mode 100644 src/sdk.ts diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..2c28f1e --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "src/shared"] + path = src/shared + url = https://github.com/Accords-Library/shared-library.git diff --git a/.vscode/settings.json b/.vscode/settings.json index 9315f09..b4fabdc 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,9 +1,11 @@ { - "css.lint.unknownAtRules": "ignore", "editor.rulers": [100], + "editor.tabSize": 2, "typescript.preferences.importModuleSpecifier": "non-relative", - "editor.codeActionsOnSave": { - "source.fixAll": "explicit", - "source.organizeImports": "explicit" + "explorer.fileNesting.enabled": true, + "explorer.fileNesting.patterns": { + "package.json": ".git*, package-lock.json, yarn.lock, pnpm-lock.yaml, bun.lockb, .ncurc.*, .nvmrc, *.config.cjs, *.config.js, *.config.ts, *config.json, .*ignore", + ".env": ".env.*", + "README.md": "*.md" } } diff --git a/package-lock.json b/package-lock.json index b399a01..7ae0c27 100644 --- a/package-lock.json +++ b/package-lock.json @@ -35,6 +35,8 @@ "prettier": "3.3.2", "ts-node": "10.9.2", "ts-unused-exports": "10.1.0", + "tsconfig-paths": "^4.2.0", + "tsconfig-paths-webpack-plugin": "^4.1.0", "typescript": "5.4.5" } }, @@ -12032,19 +12034,7 @@ } } }, - "node_modules/tsconfig-paths": { - "version": "3.14.2", - "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.2.tgz", - "integrity": "sha512-o/9iXgCYc5L/JxCHPe3Hvh8Q/2xm5Z+p18PESBU6Ff33695QnCHBEjcytY2q19ua7Mbl/DavtBOLq+oG0RCL+g==", - "dev": true, - "dependencies": { - "@types/json5": "^0.0.29", - "json5": "^1.0.2", - "minimist": "^1.2.6", - "strip-bom": "^3.0.0" - } - }, - "node_modules/tsconfig-paths/node_modules/json5": { + "node_modules/ts-unused-exports/node_modules/json5": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz", "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==", @@ -12056,6 +12046,46 @@ "json5": "lib/cli.js" } }, + "node_modules/ts-unused-exports/node_modules/tsconfig-paths": { + "version": "3.15.0", + "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.15.0.tgz", + "integrity": "sha512-2Ac2RgzDe/cn48GvOe3M+o82pEFewD3UPbyoUHHdKasHwJKjds4fLXWf/Ux5kATBKN20oaFGu+jbElp1pos0mg==", + "dev": true, + "dependencies": { + "@types/json5": "^0.0.29", + "json5": "^1.0.2", + "minimist": "^1.2.6", + "strip-bom": "^3.0.0" + } + }, + "node_modules/tsconfig-paths": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-4.2.0.tgz", + "integrity": "sha512-NoZ4roiN7LnbKn9QqE1amc9DJfzvZXxF4xDavcOWt1BPkdx+m+0gJuPM+S0vCe7zTJMYUP0R8pO2XMr+Y8oLIg==", + "dev": true, + "dependencies": { + "json5": "^2.2.2", + "minimist": "^1.2.6", + "strip-bom": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/tsconfig-paths-webpack-plugin": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/tsconfig-paths-webpack-plugin/-/tsconfig-paths-webpack-plugin-4.1.0.tgz", + "integrity": "sha512-xWFISjviPydmtmgeUAuXp4N1fky+VCtfhOkDUFIv5ea7p4wuTomI4QTrXvFBX2S4jZsmyTSrStQl+E+4w+RzxA==", + "dev": true, + "dependencies": { + "chalk": "^4.1.0", + "enhanced-resolve": "^5.7.0", + "tsconfig-paths": "^4.1.2" + }, + "engines": { + "node": ">=10.13.0" + } + }, "node_modules/tslib": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", diff --git a/package.json b/package.json index 07ea198..6ca64e9 100644 --- a/package.json +++ b/package.json @@ -12,10 +12,11 @@ "serve": "cross-env PAYLOAD_CONFIG_PATH=dist/payload.config.js NODE_ENV=production node dist/server.js", "copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png}\" dist/ && copyfiles -u 1 \"src/sdk.ts\" dist/ && copyfiles -u 1 \"src/constants.ts\" dist/ && copyfiles -u 1 \"src/types/collections.ts\" dist/", "generate:types": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts payload generate:types", - "unused-exports": "ts-unused-exports ./tsconfig.json --excludePathsFromReport='src/payload.config.ts;src/constants.ts;src/sdk.ts;src/types/collections.ts'", + "unused-exports": "ts-unused-exports ./tsconfig.json --excludePathsFromReport='src/payload.config.ts;src/types/collections.ts;src/shared/*'", "prettier": "prettier --list-different --end-of-line auto --write src", "tsc": "tsc --noEmit", - "precommit": "npm run generate:types && npm run prettier && npm run unused-exports && npm run tsc", + "fetch-submodules": "cd src/shared && git pull && cd ../..", + "precommit": "npm run fetch-submodules && npm run generate:types && npm run prettier && npm run unused-exports && npm run tsc", "upgrade": "ncu", "prod": "rm -rf build && rm -rf dist && npm ci && npm run precommit && npm run build && npm run serve" }, @@ -46,6 +47,8 @@ "prettier": "3.3.2", "ts-node": "10.9.2", "ts-unused-exports": "10.1.0", + "tsconfig-paths": "^4.2.0", + "tsconfig-paths-webpack-plugin": "^4.1.0", "typescript": "5.4.5" } } diff --git a/src/accesses/collections/mustBeAdmin.ts b/src/accesses/collections/mustBeAdmin.ts index ff533ed..c3436dc 100644 --- a/src/accesses/collections/mustBeAdmin.ts +++ b/src/accesses/collections/mustBeAdmin.ts @@ -1,7 +1,7 @@ import { Access } from "payload/config"; -import { RecordersRoles } from "../../constants"; -import { Recorder } from "../../types/collections"; -import { isDefined, isUndefined } from "../../utils/asserts"; +import { RecordersRoles } from "src/shared/payload/constants"; +import { Recorder } from "src/types/collections"; +import { isUndefined, isDefined } from "src/utils/asserts"; export const mustBeAdmin: Access = ({ req: { user } }): boolean => { if (isUndefined(user)) return false; diff --git a/src/accesses/collections/mustBeAdminOrSelf.ts b/src/accesses/collections/mustBeAdminOrSelf.ts index fd27cfa..62af6e8 100644 --- a/src/accesses/collections/mustBeAdminOrSelf.ts +++ b/src/accesses/collections/mustBeAdminOrSelf.ts @@ -1,7 +1,7 @@ import { Access } from "payload/config"; -import { RecordersRoles } from "../../constants"; -import { Recorder } from "../../types/collections"; -import { isUndefined } from "../../utils/asserts"; +import { RecordersRoles } from "src/shared/payload/constants"; +import { Recorder } from "src/types/collections"; +import { isUndefined } from "src/utils/asserts"; export const mustBeAdminOrSelf: Access = ({ req: { user } }) => { if (isUndefined(user)) return false; diff --git a/src/accesses/collections/shownOnlyToAdmin.ts b/src/accesses/collections/shownOnlyToAdmin.ts index 632b98e..1e2c058 100644 --- a/src/accesses/collections/shownOnlyToAdmin.ts +++ b/src/accesses/collections/shownOnlyToAdmin.ts @@ -1,7 +1,7 @@ import { User } from "payload/auth"; -import { RecordersRoles } from "../../constants"; -import { Recorder } from "../../types/collections"; -import { isDefined, isUndefined } from "../../utils/asserts"; +import { RecordersRoles } from "src/shared/payload/constants"; +import { Recorder } from "src/types/collections"; +import { isUndefined, isDefined } from "src/utils/asserts"; export const shownOnlyToAdmin = ({ user }: { user: User }): boolean => { if (isUndefined(user)) return false; diff --git a/src/accesses/fields/mustBeAdmin.ts b/src/accesses/fields/mustBeAdmin.ts index 1c3c34b..b1c82ac 100644 --- a/src/accesses/fields/mustBeAdmin.ts +++ b/src/accesses/fields/mustBeAdmin.ts @@ -1,7 +1,7 @@ import { FieldAccess } from "payload/types"; -import { RecordersRoles } from "../../constants"; -import { Recorder } from "../../types/collections"; -import { isDefined, isUndefined } from "../../utils/asserts"; +import { RecordersRoles } from "src/shared/payload/constants"; +import { Recorder } from "src/types/collections"; +import { isUndefined, isDefined } from "src/utils/asserts"; export const mustBeAdmin: FieldAccess = ({ req: { user } }): boolean => { if (isUndefined(user)) return false; diff --git a/src/blocks/attributeBlocks/numberBlock.ts b/src/blocks/attributeBlocks/numberBlock.ts index b0e45d4..2c50d81 100644 --- a/src/blocks/attributeBlocks/numberBlock.ts +++ b/src/blocks/attributeBlocks/numberBlock.ts @@ -1,6 +1,6 @@ import { Block } from "payload/types"; -import { AttributeTypes, Collections } from "../../constants"; -import { rowField } from "../../fields/rowField/rowField"; +import { rowField } from "src/fields/rowField/rowField"; +import { Collections, AttributeTypes } from "src/shared/payload/constants"; export const numberBlock: Block = { slug: "numberBlock", diff --git a/src/blocks/attributeBlocks/tagsBlock.ts b/src/blocks/attributeBlocks/tagsBlock.ts index 87dc406..46093e3 100644 --- a/src/blocks/attributeBlocks/tagsBlock.ts +++ b/src/blocks/attributeBlocks/tagsBlock.ts @@ -1,6 +1,6 @@ import { Block } from "payload/types"; -import { AttributeTypes, Collections } from "../../constants"; -import { rowField } from "../../fields/rowField/rowField"; +import { rowField } from "src/fields/rowField/rowField"; +import { Collections, AttributeTypes } from "src/shared/payload/constants"; export const tagsBlock: Block = { slug: "tagsBlock", diff --git a/src/blocks/attributeBlocks/textBlock.ts b/src/blocks/attributeBlocks/textBlock.ts index b006179..9fdd7fd 100644 --- a/src/blocks/attributeBlocks/textBlock.ts +++ b/src/blocks/attributeBlocks/textBlock.ts @@ -1,6 +1,6 @@ import { Block } from "payload/types"; -import { AttributeTypes, Collections } from "../../constants"; -import { rowField } from "../../fields/rowField/rowField"; +import { rowField } from "src/fields/rowField/rowField"; +import { Collections, AttributeTypes } from "src/shared/payload/constants"; export const textBlock: Block = { slug: "textBlock", diff --git a/src/blocks/breakBlock.ts b/src/blocks/breakBlock.ts index d93af4c..b589799 100644 --- a/src/blocks/breakBlock.ts +++ b/src/blocks/breakBlock.ts @@ -1,5 +1,5 @@ import { Block } from "payload/types"; -import { BreakBlockType } from "../constants"; +import { BreakBlockType } from "src/shared/payload/constants"; export const breakBlock: Block = { slug: "breakBlock", diff --git a/src/blocks/cueBlock.ts b/src/blocks/cueBlock.ts index de681c6..2775c63 100644 --- a/src/blocks/cueBlock.ts +++ b/src/blocks/cueBlock.ts @@ -1,5 +1,5 @@ import { Block } from "payload/types"; -import { createEditor } from "../utils/editor"; +import { createEditor } from "src/utils/editor"; export const cueBlock: Block = { slug: "cueBlock", diff --git a/src/blocks/lineBlock.ts b/src/blocks/lineBlock.ts index e5e36f0..ab0d95b 100644 --- a/src/blocks/lineBlock.ts +++ b/src/blocks/lineBlock.ts @@ -1,5 +1,5 @@ import { Block } from "payload/types"; -import { createEditor } from "../utils/editor"; +import { createEditor } from "src/utils/editor"; export const lineBlock: Block = { slug: "lineBlock", diff --git a/src/blocks/sectionBlock.ts b/src/blocks/sectionBlock.ts index f8cbcdc..3a4341d 100644 --- a/src/blocks/sectionBlock.ts +++ b/src/blocks/sectionBlock.ts @@ -1,7 +1,7 @@ import { Block } from "payload/types"; -import { createEditor } from "../utils/editor"; -import { breakBlock } from "./breakBlock"; -import { transcriptBlock } from "./transcriptBlock"; +import { breakBlock } from "src/blocks/breakBlock"; +import { transcriptBlock } from "src/blocks/transcriptBlock"; +import { createEditor } from "src/utils/editor"; const generateRecursiveSectionBlock = (depth = 1, maxDepth = 5): Block => ({ slug: "sectionBlock", diff --git a/src/blocks/transcriptBlock.ts b/src/blocks/transcriptBlock.ts index 085261d..66646b9 100644 --- a/src/blocks/transcriptBlock.ts +++ b/src/blocks/transcriptBlock.ts @@ -1,6 +1,6 @@ import { Block } from "payload/types"; -import { cueBlock } from "./cueBlock"; -import { lineBlock } from "./lineBlock"; +import { cueBlock } from "src/blocks/cueBlock"; +import { lineBlock } from "src/blocks/lineBlock"; export const transcriptBlock: Block = { slug: "transcriptBlock", diff --git a/src/collections/Attributes/Attributes.ts b/src/collections/Attributes/Attributes.ts index 3019c67..8ee8ce9 100644 --- a/src/collections/Attributes/Attributes.ts +++ b/src/collections/Attributes/Attributes.ts @@ -1,11 +1,11 @@ import { CollectionConfig } from "payload/types"; -import { mustBeAdmin } from "../../accesses/fields/mustBeAdmin"; -import { AttributeTypes, CollectionGroups, Collections } from "../../constants"; -import { iconField } from "../../fields/iconField/iconField"; -import { rowField } from "../../fields/rowField/rowField"; -import { slugField } from "../../fields/slugField/slugField"; -import { translatedFields } from "../../fields/translatedFields/translatedFields"; -import { buildCollectionConfig } from "../../utils/collectionConfig"; +import { mustBeAdmin } from "src/accesses/fields/mustBeAdmin"; +import { iconField } from "src/fields/iconField/iconField"; +import { rowField } from "src/fields/rowField/rowField"; +import { slugField } from "src/fields/slugField/slugField"; +import { translatedFields } from "src/fields/translatedFields/translatedFields"; +import { Collections, CollectionGroups, AttributeTypes } from "src/shared/payload/constants"; +import { buildCollectionConfig } from "src/utils/collectionConfig"; const fields = { slug: "slug", diff --git a/src/collections/Audios/Audios.ts b/src/collections/Audios/Audios.ts index 22ff29a..d6a274e 100644 --- a/src/collections/Audios/Audios.ts +++ b/src/collections/Audios/Audios.ts @@ -1,11 +1,11 @@ -import { CollectionGroups, Collections } from "../../constants"; -import { attributesField } from "../../fields/attributesField/attributesField"; -import { creditsField } from "../../fields/creditsField/creditsField"; -import { imageField } from "../../fields/imageField/imageField"; -import { rowField } from "../../fields/rowField/rowField"; -import { translatedFields } from "../../fields/translatedFields/translatedFields"; -import { buildCollectionConfig } from "../../utils/collectionConfig"; -import { createEditor } from "../../utils/editor"; +import { attributesField } from "src/fields/attributesField/attributesField"; +import { creditsField } from "src/fields/creditsField/creditsField"; +import { imageField } from "src/fields/imageField/imageField"; +import { rowField } from "src/fields/rowField/rowField"; +import { translatedFields } from "src/fields/translatedFields/translatedFields"; +import { Collections, CollectionGroups } from "src/shared/payload/constants"; +import { buildCollectionConfig } from "src/utils/collectionConfig"; +import { createEditor } from "src/utils/editor"; import { getByID } from "./endpoints/getByID"; const fields = { diff --git a/src/collections/Audios/endpoints/getByID.ts b/src/collections/Audios/endpoints/getByID.ts index 8ce5449..b44c259 100644 --- a/src/collections/Audios/endpoints/getByID.ts +++ b/src/collections/Audios/endpoints/getByID.ts @@ -1,16 +1,20 @@ import payload from "payload"; -import { Collections } from "../../../constants"; -import { EndpointAudio, EndpointAudioPreview, PayloadMedia } from "../../../sdk"; -import { Audio } from "../../../types/collections"; -import { CollectionEndpoint } from "../../../types/payload"; -import { isAudio, isMediaThumbnail, isNotEmpty } from "../../../utils/asserts"; +import { Collections } from "src/shared/payload/constants"; +import { + PayloadMedia, + EndpointAudioPreview, + EndpointAudio, +} from "src/shared/payload/endpoint-types"; +import { CollectionEndpoint } from "src/types/payload"; +import { isAudio, isNotEmpty, isMediaThumbnail } from "src/utils/asserts"; import { convertAttributesToEndpointAttributes, - convertCreditsToEndpointCredits, + getLanguageId, convertMediaThumbnailToEndpointPayloadImage, convertRTCToEndpointRTC, - getLanguageId, -} from "../../../utils/endpoints"; + convertCreditsToEndpointCredits, +} from "src/utils/endpoints"; +import { Audio } from "src/types/collections"; export const getByID: CollectionEndpoint = { method: "get", diff --git a/src/collections/ChronologyEvents/ChronologyEvents.ts b/src/collections/ChronologyEvents/ChronologyEvents.ts index e407ea5..01813a5 100644 --- a/src/collections/ChronologyEvents/ChronologyEvents.ts +++ b/src/collections/ChronologyEvents/ChronologyEvents.ts @@ -1,15 +1,4 @@ import { CollectionConfig } from "payload/types"; -import { - QuickFilters, - languageBasedFilters, - publishStatusFilters, -} from "../../components/QuickFilters"; -import { CollectionGroups, Collections } from "../../constants"; -import { creditsField } from "../../fields/creditsField/creditsField"; -import { rowField } from "../../fields/rowField/rowField"; -import { translatedFields } from "../../fields/translatedFields/translatedFields"; -import { createEditor } from "../../utils/editor"; -import { buildVersionedCollectionConfig } from "../../utils/versionedCollectionConfig"; import { collectibleBlock } from "./blocks/collectibleBlock"; import { pageBlock } from "./blocks/contentBlock"; import { urlBlock } from "./blocks/urlBlock"; @@ -20,6 +9,17 @@ import { beforeValidatePopulateNameField } from "./hooks/beforeValidatePopulateN import { validateDate } from "./validations/validateDate"; import { validateEventsTranslationsDescription } from "./validations/validateEventsTranslationsDescription"; import { validateEventsTranslationsTitle } from "./validations/validateEventsTranslationsTitle"; +import { + QuickFilters, + languageBasedFilters, + publishStatusFilters, +} from "src/components/QuickFilters"; +import { creditsField } from "src/fields/creditsField/creditsField"; +import { rowField } from "src/fields/rowField/rowField"; +import { translatedFields } from "src/fields/translatedFields/translatedFields"; +import { Collections, CollectionGroups } from "src/shared/payload/constants"; +import { createEditor } from "src/utils/editor"; +import { buildVersionedCollectionConfig } from "src/utils/versionedCollectionConfig"; const fields = { name: "name", diff --git a/src/collections/ChronologyEvents/blocks/collectibleBlock.ts b/src/collections/ChronologyEvents/blocks/collectibleBlock.ts index 850a3d0..a3242b1 100644 --- a/src/collections/ChronologyEvents/blocks/collectibleBlock.ts +++ b/src/collections/ChronologyEvents/blocks/collectibleBlock.ts @@ -1,6 +1,6 @@ import { Block } from "payload/types"; -import { Collections } from "../../../constants"; -import { translatedFields } from "../../../fields/translatedFields/translatedFields"; +import { translatedFields } from "src/fields/translatedFields/translatedFields"; +import { Collections } from "src/shared/payload/constants"; export const collectibleBlock: Block = { slug: "collectibleBlock", diff --git a/src/collections/ChronologyEvents/blocks/contentBlock.ts b/src/collections/ChronologyEvents/blocks/contentBlock.ts index ade726d..d8c5467 100644 --- a/src/collections/ChronologyEvents/blocks/contentBlock.ts +++ b/src/collections/ChronologyEvents/blocks/contentBlock.ts @@ -1,5 +1,5 @@ import { Block } from "payload/types"; -import { Collections } from "../../../constants"; +import { Collections } from "src/shared/payload/constants"; export const pageBlock: Block = { slug: "pageBlock", diff --git a/src/collections/ChronologyEvents/endpoints/getAllEndpoint.ts b/src/collections/ChronologyEvents/endpoints/getAllEndpoint.ts index c88b6c6..8e83ccf 100644 --- a/src/collections/ChronologyEvents/endpoints/getAllEndpoint.ts +++ b/src/collections/ChronologyEvents/endpoints/getAllEndpoint.ts @@ -1,12 +1,12 @@ import payload from "payload"; -import { Collections } from "../../../constants"; -import { EndpointChronologyEvent, EndpointSource } from "../../../sdk"; -import { ChronologyEvent, CollectibleBlock } from "../../../types/collections"; -import { CollectionEndpoint } from "../../../types/payload"; -import { isDefined, isNotEmpty, isPayloadType } from "../../../utils/asserts"; -import { convertCreditsToEndpointCredits, getDomainFromUrl } from "../../../utils/endpoints"; -import { convertCollectibleToEndpointCollectiblePreview } from "../../Collectibles/endpoints/getBySlugEndpoint"; -import { convertPageToEndpointPagePreview } from "../../Pages/endpoints/getBySlugEndpoint"; +import { convertCollectibleToEndpointCollectiblePreview } from "src/collections/Collectibles/endpoints/getBySlugEndpoint"; +import { convertPageToEndpointPagePreview } from "src/collections/Pages/endpoints/getBySlugEndpoint"; +import { Collections } from "src/shared/payload/constants"; +import { EndpointChronologyEvent, EndpointSource } from "src/shared/payload/endpoint-types"; +import { ChronologyEvent, CollectibleBlock } from "src/types/collections"; +import { CollectionEndpoint } from "src/types/payload"; +import { isDefined, isPayloadType, isNotEmpty } from "src/utils/asserts"; +import { convertCreditsToEndpointCredits, getDomainFromUrl } from "src/utils/endpoints"; export const getAllEndpoint: CollectionEndpoint = { method: "get", diff --git a/src/collections/ChronologyEvents/endpoints/getByID.ts b/src/collections/ChronologyEvents/endpoints/getByID.ts index 5c84ee5..48666e6 100644 --- a/src/collections/ChronologyEvents/endpoints/getByID.ts +++ b/src/collections/ChronologyEvents/endpoints/getByID.ts @@ -1,7 +1,7 @@ import payload from "payload"; -import { Collections } from "../../../constants"; -import { CollectionEndpoint } from "../../../types/payload"; import { eventToEndpointEvent } from "./getAllEndpoint"; +import { Collections } from "src/shared/payload/constants"; +import { CollectionEndpoint } from "src/types/payload"; export const getByID: CollectionEndpoint = { method: "get", diff --git a/src/collections/ChronologyEvents/endpoints/importFromStrapi.ts b/src/collections/ChronologyEvents/endpoints/importFromStrapi.ts index d1d9f3a..d1c3844 100644 --- a/src/collections/ChronologyEvents/endpoints/importFromStrapi.ts +++ b/src/collections/ChronologyEvents/endpoints/importFromStrapi.ts @@ -1,8 +1,8 @@ -import { Collections } from "../../../constants"; -import { createStrapiImportEndpoint } from "../../../endpoints/createStrapiImportEndpoint"; -import { StrapiLanguage } from "../../../types/strapi"; -import { isDefined, isUndefined } from "../../../utils/asserts"; -import { plainTextToLexical } from "../../../utils/string"; +import { createStrapiImportEndpoint } from "src/endpoints/createStrapiImportEndpoint"; +import { Collections } from "src/shared/payload/constants"; +import { StrapiLanguage } from "src/types/strapi"; +import { isUndefined, isDefined } from "src/utils/asserts"; +import { plainTextToLexical } from "src/utils/string"; type StrapiChronologyItem = { year: number; diff --git a/src/collections/ChronologyEvents/hooks/beforeValidatePopulateNameField.ts b/src/collections/ChronologyEvents/hooks/beforeValidatePopulateNameField.ts index 9192965..85dd048 100644 --- a/src/collections/ChronologyEvents/hooks/beforeValidatePopulateNameField.ts +++ b/src/collections/ChronologyEvents/hooks/beforeValidatePopulateNameField.ts @@ -1,6 +1,6 @@ import { FieldHook } from "payload/dist/fields/config/types"; -import { ChronologyEvent } from "../../../types/collections"; -import { isDefined, isUndefined } from "../../../utils/asserts"; +import { ChronologyEvent } from "src/types/collections"; +import { isUndefined, isDefined } from "src/utils/asserts"; export const beforeValidatePopulateNameField: FieldHook< ChronologyEvent, diff --git a/src/collections/ChronologyEvents/validations/validateDate.ts b/src/collections/ChronologyEvents/validations/validateDate.ts index 675c03e..ec2da66 100644 --- a/src/collections/ChronologyEvents/validations/validateDate.ts +++ b/src/collections/ChronologyEvents/validations/validateDate.ts @@ -1,7 +1,7 @@ import { DateTime } from "luxon"; import { Validate } from "payload/types"; -import { ChronologyEvent } from "../../../types/collections"; -import { isUndefined } from "../../../utils/asserts"; +import { ChronologyEvent } from "src/types/collections"; +import { isUndefined } from "src/utils/asserts"; export const validateDate: Validate = (date) => { if (isUndefined(date)) return "This field is required."; diff --git a/src/collections/ChronologyEvents/validations/validateEventsTranslationsDescription.ts b/src/collections/ChronologyEvents/validations/validateEventsTranslationsDescription.ts index e9cf957..0882db9 100644 --- a/src/collections/ChronologyEvents/validations/validateEventsTranslationsDescription.ts +++ b/src/collections/ChronologyEvents/validations/validateEventsTranslationsDescription.ts @@ -1,6 +1,6 @@ import { Validate } from "payload/types"; -import { ChronologyEvent } from "../../../types/collections"; -import { isEmpty } from "../../../utils/asserts"; +import { ChronologyEvent } from "src/types/collections"; +import { isEmpty } from "src/utils/asserts"; export const validateEventsTranslationsDescription: Validate< string | undefined, diff --git a/src/collections/ChronologyEvents/validations/validateEventsTranslationsTitle.ts b/src/collections/ChronologyEvents/validations/validateEventsTranslationsTitle.ts index 54ea888..8367a62 100644 --- a/src/collections/ChronologyEvents/validations/validateEventsTranslationsTitle.ts +++ b/src/collections/ChronologyEvents/validations/validateEventsTranslationsTitle.ts @@ -1,6 +1,6 @@ import { Validate } from "payload/types"; -import { ChronologyEvent } from "../../../types/collections"; -import { isEmpty } from "../../../utils/asserts"; +import { ChronologyEvent } from "src/types/collections"; +import { isEmpty } from "src/utils/asserts"; export const validateEventsTranslationsTitle: Validate< string | undefined, diff --git a/src/collections/Collectibles/Collectibles.ts b/src/collections/Collectibles/Collectibles.ts index b6a873c..ab154af 100644 --- a/src/collections/Collectibles/Collectibles.ts +++ b/src/collections/Collectibles/Collectibles.ts @@ -1,33 +1,33 @@ import { RowLabelArgs } from "payload/dist/admin/components/forms/RowLabel/types"; import { Where } from "payload/types"; -import { - CollectibleBindingTypes, - CollectibleNature, - CollectiblePageOrders, - CollectionGroups, - Collections, -} from "../../constants"; -import { attributesField } from "../../fields/attributesField/attributesField"; -import { backPropagationField } from "../../fields/backPropagationField/backPropagationField"; -import { componentField } from "../../fields/componentField/componentField"; -import { creditsField } from "../../fields/creditsField/creditsField"; -import { imageField } from "../../fields/imageField/imageField"; -import { rowField } from "../../fields/rowField/rowField"; -import { slugField } from "../../fields/slugField/slugField"; -import { translatedFields } from "../../fields/translatedFields/translatedFields"; -import { beforeDuplicateAddCopyTo } from "../../hooks/beforeDuplicateAddCopyTo"; -import { beforeDuplicatePiping } from "../../hooks/beforeDuplicatePiping"; -import { beforeDuplicateUnpublish } from "../../hooks/beforeDuplicateUnpublish"; -import { Collectible } from "../../types/collections"; -import { isPayloadType } from "../../utils/asserts"; -import { createEditor } from "../../utils/editor"; -import { buildVersionedCollectionConfig } from "../../utils/versionedCollectionConfig"; import { RowLabel } from "./components/RowLabel"; import { getBySlugEndpoint } from "./endpoints/getBySlugEndpoint"; import { getBySlugEndpointGallery } from "./endpoints/getBySlugEndpointGallery"; import { getBySlugEndpointGalleryImage } from "./endpoints/getBySlugEndpointGalleryImage"; import { getBySlugEndpointScanPage } from "./endpoints/getBySlugEndpointScanPage"; import { getBySlugEndpointScans } from "./endpoints/getBySlugEndpointScans"; +import { attributesField } from "src/fields/attributesField/attributesField"; +import { backPropagationField } from "src/fields/backPropagationField/backPropagationField"; +import { componentField } from "src/fields/componentField/componentField"; +import { creditsField } from "src/fields/creditsField/creditsField"; +import { imageField } from "src/fields/imageField/imageField"; +import { rowField } from "src/fields/rowField/rowField"; +import { slugField } from "src/fields/slugField/slugField"; +import { translatedFields } from "src/fields/translatedFields/translatedFields"; +import { beforeDuplicateAddCopyTo } from "src/hooks/beforeDuplicateAddCopyTo"; +import { beforeDuplicatePiping } from "src/hooks/beforeDuplicatePiping"; +import { beforeDuplicateUnpublish } from "src/hooks/beforeDuplicateUnpublish"; +import { + Collections, + CollectionGroups, + CollectibleNature, + CollectibleBindingTypes, + CollectiblePageOrders, +} from "src/shared/payload/constants"; +import { Collectible } from "src/types/collections"; +import { isPayloadType } from "src/utils/asserts"; +import { createEditor } from "src/utils/editor"; +import { buildVersionedCollectionConfig } from "src/utils/versionedCollectionConfig"; const fields = { status: "_status", diff --git a/src/collections/Collectibles/components/RowLabel.tsx b/src/collections/Collectibles/components/RowLabel.tsx index 47e97ee..01d21de 100644 --- a/src/collections/Collectibles/components/RowLabel.tsx +++ b/src/collections/Collectibles/components/RowLabel.tsx @@ -1,6 +1,6 @@ import React from "react"; +import { isDefined } from "src/utils/asserts"; import styled from "styled-components"; -import { isDefined } from "../../../utils/asserts"; interface Props { page?: number; diff --git a/src/collections/Collectibles/endpoints/getBySlugEndpoint.ts b/src/collections/Collectibles/endpoints/getBySlugEndpoint.ts index cff7a53..842cba3 100644 --- a/src/collections/Collectibles/endpoints/getBySlugEndpoint.ts +++ b/src/collections/Collectibles/endpoints/getBySlugEndpoint.ts @@ -1,31 +1,31 @@ -import { CollectibleNature, Collections } from "../../../constants"; -import { createGetByEndpoint } from "../../../endpoints/createGetByEndpoint"; -import { EndpointCollectible, EndpointCollectiblePreview } from "../../../sdk"; -import { Collectible } from "../../../types/collections"; +import { convertAudioToEndpointAudioPreview } from "src/collections/Audios/endpoints/getByID"; +import { convertFileToEndpointFilePreview } from "src/collections/Files/endpoints/getByID"; +import { convertPageToEndpointPagePreview } from "src/collections/Pages/endpoints/getBySlugEndpoint"; +import { convertRecorderToEndpointRecorderPreview } from "src/collections/Recorders/endpoints/getByID"; +import { convertVideoToEndpointVideoPreview } from "src/collections/Videos/endpoints/getByID"; +import { createGetByEndpoint } from "src/endpoints/createGetByEndpoint"; +import { Collections, CollectibleNature } from "src/shared/payload/constants"; +import { EndpointCollectiblePreview, EndpointCollectible } from "src/shared/payload/endpoint-types"; +import { Collectible } from "src/types/collections"; import { - isAudio, - isDefined, - isFile, isImage, - isNotEmpty, - isPayloadArrayType, isPayloadType, + isNotEmpty, + isDefined, + isPayloadArrayType, isPublished, + isFile, isScan, + isAudio, isVideo, -} from "../../../utils/asserts"; +} from "src/utils/asserts"; import { - convertAttributesToEndpointAttributes, convertImageToEndpointPayloadImage, - convertScanToEndpointScanImage, - convertSourceToEndpointSource, + convertAttributesToEndpointAttributes, getDomainFromUrl, -} from "../../../utils/endpoints"; -import { convertAudioToEndpointAudioPreview } from "../../Audios/endpoints/getByID"; -import { convertFileToEndpointFilePreview } from "../../Files/endpoints/getByID"; -import { convertPageToEndpointPagePreview } from "../../Pages/endpoints/getBySlugEndpoint"; -import { convertRecorderToEndpointRecorderPreview } from "../../Recorders/endpoints/getByID"; -import { convertVideoToEndpointVideoPreview } from "../../Videos/endpoints/getByID"; + convertSourceToEndpointSource, + convertScanToEndpointScanImage, +} from "src/utils/endpoints"; export const getBySlugEndpoint = createGetByEndpoint({ collection: Collections.Collectibles, diff --git a/src/collections/Collectibles/endpoints/getBySlugEndpointGallery.ts b/src/collections/Collectibles/endpoints/getBySlugEndpointGallery.ts index 7d75e86..73b6481 100644 --- a/src/collections/Collectibles/endpoints/getBySlugEndpointGallery.ts +++ b/src/collections/Collectibles/endpoints/getBySlugEndpointGallery.ts @@ -1,11 +1,11 @@ -import { Collections } from "../../../constants"; -import { createGetByEndpoint } from "../../../endpoints/createGetByEndpoint"; -import { EndpointCollectibleGallery } from "../../../sdk"; -import { isImage, isNotEmpty, isPayloadType } from "../../../utils/asserts"; +import { createGetByEndpoint } from "src/endpoints/createGetByEndpoint"; +import { Collections } from "src/shared/payload/constants"; +import { EndpointCollectibleGallery } from "src/shared/payload/endpoint-types"; +import { isPayloadType, isNotEmpty, isImage } from "src/utils/asserts"; import { convertImageToEndpointPayloadImage, convertSourceToEndpointSource, -} from "../../../utils/endpoints"; +} from "src/utils/endpoints"; export const getBySlugEndpointGallery = createGetByEndpoint({ collection: Collections.Collectibles, diff --git a/src/collections/Collectibles/endpoints/getBySlugEndpointGalleryImage.ts b/src/collections/Collectibles/endpoints/getBySlugEndpointGalleryImage.ts index b27bef7..3168ca7 100644 --- a/src/collections/Collectibles/endpoints/getBySlugEndpointGalleryImage.ts +++ b/src/collections/Collectibles/endpoints/getBySlugEndpointGalleryImage.ts @@ -1,11 +1,12 @@ import payload from "payload"; -import { Collections } from "../../../constants"; -import { EndpointCollectibleGalleryImage } from "../../../sdk"; -import { Collectible, Image } from "../../../types/collections"; -import { CollectionEndpoint } from "../../../types/payload"; -import { isDefined, isImage, isNotEmpty, isPayloadType } from "../../../utils/asserts"; -import { convertSourceToEndpointSource } from "../../../utils/endpoints"; -import { convertImageToEndpointImage } from "../../Images/endpoints/getByID"; +import { convertImageToEndpointImage } from "src/collections/Images/endpoints/getByID"; +import { Collections } from "src/shared/payload/constants"; +import { EndpointCollectibleGalleryImage } from "src/shared/payload/endpoint-types"; +import { Collectible } from "src/types/collections"; +import { CollectionEndpoint } from "src/types/payload"; +import { isImage, isPayloadType, isNotEmpty, isDefined } from "src/utils/asserts"; +import { convertSourceToEndpointSource } from "src/utils/endpoints"; +import { Image } from "src/types/collections"; export const getBySlugEndpointGalleryImage: CollectionEndpoint = { path: "/slug/:slug/gallery/:index", diff --git a/src/collections/Collectibles/endpoints/getBySlugEndpointScanPage.ts b/src/collections/Collectibles/endpoints/getBySlugEndpointScanPage.ts index 206ef28..79dc61b 100644 --- a/src/collections/Collectibles/endpoints/getBySlugEndpointScanPage.ts +++ b/src/collections/Collectibles/endpoints/getBySlugEndpointScanPage.ts @@ -1,13 +1,10 @@ import payload from "payload"; -import { Collections } from "../../../constants"; -import { EndpointCollectibleScanPage } from "../../../sdk"; -import { Collectible, Scan } from "../../../types/collections"; -import { CollectionEndpoint } from "../../../types/payload"; -import { isDefined, isNotEmpty, isPayloadType, isScan } from "../../../utils/asserts"; -import { - convertScanToEndpointScanImage, - convertSourceToEndpointSource, -} from "../../../utils/endpoints"; +import { Collections } from "src/shared/payload/constants"; +import { EndpointCollectibleScanPage } from "src/shared/payload/endpoint-types"; +import { Collectible, Scan } from "src/types/collections"; +import { CollectionEndpoint } from "src/types/payload"; +import { isScan, isPayloadType, isNotEmpty, isDefined } from "src/utils/asserts"; +import { convertScanToEndpointScanImage, convertSourceToEndpointSource } from "src/utils/endpoints"; export const getBySlugEndpointScanPage: CollectionEndpoint = { path: "/slug/:slug/scans/:index", diff --git a/src/collections/Collectibles/endpoints/getBySlugEndpointScans.ts b/src/collections/Collectibles/endpoints/getBySlugEndpointScans.ts index 5d5a881..215c133 100644 --- a/src/collections/Collectibles/endpoints/getBySlugEndpointScans.ts +++ b/src/collections/Collectibles/endpoints/getBySlugEndpointScans.ts @@ -1,14 +1,14 @@ -import { Collections } from "../../../constants"; -import { createGetByEndpoint } from "../../../endpoints/createGetByEndpoint"; -import { EndpointCollectibleScans } from "../../../sdk"; -import { Collectible } from "../../../types/collections"; -import { isImage, isNotEmpty, isPayloadType, isScan } from "../../../utils/asserts"; +import { createGetByEndpoint } from "src/endpoints/createGetByEndpoint"; +import { Collections } from "src/shared/payload/constants"; +import { EndpointCollectibleScans } from "src/shared/payload/endpoint-types"; +import { Collectible } from "src/types/collections"; +import { isPayloadType, isNotEmpty, isImage, isScan } from "src/utils/asserts"; import { - convertCreditsToEndpointCredits, convertImageToEndpointPayloadImage, - convertScanToEndpointScanImage, convertSourceToEndpointSource, -} from "../../../utils/endpoints"; + convertCreditsToEndpointCredits, + convertScanToEndpointScanImage, +} from "src/utils/endpoints"; export const getBySlugEndpointScans = createGetByEndpoint({ collection: Collections.Collectibles, diff --git a/src/collections/CreditsRoles/CreditsRoles.ts b/src/collections/CreditsRoles/CreditsRoles.ts index 33c9674..2d80230 100644 --- a/src/collections/CreditsRoles/CreditsRoles.ts +++ b/src/collections/CreditsRoles/CreditsRoles.ts @@ -1,9 +1,9 @@ import { CollectionConfig } from "payload/types"; -import { CollectionGroups, Collections } from "../../constants"; -import { iconField } from "../../fields/iconField/iconField"; -import { slugField } from "../../fields/slugField/slugField"; -import { translatedFields } from "../../fields/translatedFields/translatedFields"; -import { buildCollectionConfig } from "../../utils/collectionConfig"; +import { iconField } from "src/fields/iconField/iconField"; +import { slugField } from "src/fields/slugField/slugField"; +import { translatedFields } from "src/fields/translatedFields/translatedFields"; +import { Collections, CollectionGroups } from "src/shared/payload/constants"; +import { buildCollectionConfig } from "src/utils/collectionConfig"; const fields = { slug: "slug", diff --git a/src/collections/Currencies/Currencies.ts b/src/collections/Currencies/Currencies.ts index 0cc658c..6f8779d 100644 --- a/src/collections/Currencies/Currencies.ts +++ b/src/collections/Currencies/Currencies.ts @@ -1,10 +1,10 @@ import { text } from "payload/dist/fields/validations"; -import { mustBeAdmin } from "../../accesses/collections/mustBeAdmin"; -import { shownOnlyToAdmin } from "../../accesses/collections/shownOnlyToAdmin"; -import { CollectionGroups, Collections } from "../../constants"; -import { buildCollectionConfig } from "../../utils/collectionConfig"; import { getAllEndpoint } from "./endpoints/getAllEndpoint"; import { importFromStrapi } from "./endpoints/importFromStrapi"; +import { shownOnlyToAdmin } from "src/accesses/collections/shownOnlyToAdmin"; +import { mustBeAdmin } from "src/accesses/fields/mustBeAdmin"; +import { Collections, CollectionGroups } from "src/shared/payload/constants"; +import { buildCollectionConfig } from "src/utils/collectionConfig"; const fields = { id: "id", diff --git a/src/collections/Currencies/endpoints/getAllEndpoint.ts b/src/collections/Currencies/endpoints/getAllEndpoint.ts index 28811cd..0256e5c 100644 --- a/src/collections/Currencies/endpoints/getAllEndpoint.ts +++ b/src/collections/Currencies/endpoints/getAllEndpoint.ts @@ -1,7 +1,7 @@ import payload from "payload"; -import { Collections } from "../../../constants"; -import { Currency } from "../../../types/collections"; -import { CollectionEndpoint } from "../../../types/payload"; +import { Collections } from "src/shared/payload/constants"; +import { Currency } from "src/types/collections"; +import { CollectionEndpoint } from "src/types/payload"; export const getAllEndpoint: CollectionEndpoint = { method: "get", diff --git a/src/collections/Currencies/endpoints/importFromStrapi.ts b/src/collections/Currencies/endpoints/importFromStrapi.ts index 6067eb3..ef7c051 100644 --- a/src/collections/Currencies/endpoints/importFromStrapi.ts +++ b/src/collections/Currencies/endpoints/importFromStrapi.ts @@ -1,5 +1,5 @@ -import { Collections } from "../../../constants"; -import { createStrapiImportEndpoint } from "../../../endpoints/createStrapiImportEndpoint"; +import { createStrapiImportEndpoint } from "src/endpoints/createStrapiImportEndpoint"; +import { Collections } from "src/shared/payload/constants"; type StrapiLanguage = { code: string; diff --git a/src/collections/Files/Files.ts b/src/collections/Files/Files.ts index 9c76d3d..14e2331 100644 --- a/src/collections/Files/Files.ts +++ b/src/collections/Files/Files.ts @@ -1,11 +1,11 @@ -import { CollectionGroups, Collections } from "../../constants"; -import { attributesField } from "../../fields/attributesField/attributesField"; -import { creditsField } from "../../fields/creditsField/creditsField"; -import { imageField } from "../../fields/imageField/imageField"; -import { rowField } from "../../fields/rowField/rowField"; -import { translatedFields } from "../../fields/translatedFields/translatedFields"; -import { buildCollectionConfig } from "../../utils/collectionConfig"; -import { createEditor } from "../../utils/editor"; +import { attributesField } from "src/fields/attributesField/attributesField"; +import { creditsField } from "src/fields/creditsField/creditsField"; +import { imageField } from "src/fields/imageField/imageField"; +import { rowField } from "src/fields/rowField/rowField"; +import { translatedFields } from "src/fields/translatedFields/translatedFields"; +import { Collections, CollectionGroups } from "src/shared/payload/constants"; +import { buildCollectionConfig } from "src/utils/collectionConfig"; +import { createEditor } from "src/utils/editor"; import { getByID } from "./endpoints/getByID"; const fields = { diff --git a/src/collections/Files/endpoints/getByID.ts b/src/collections/Files/endpoints/getByID.ts index 17b8dfb..545e61c 100644 --- a/src/collections/Files/endpoints/getByID.ts +++ b/src/collections/Files/endpoints/getByID.ts @@ -1,16 +1,16 @@ import payload from "payload"; -import { Collections } from "../../../constants"; -import { EndpointFile, EndpointFilePreview, PayloadMedia } from "../../../sdk"; -import { File } from "../../../types/collections"; -import { CollectionEndpoint } from "../../../types/payload"; -import { isFile, isMediaThumbnail, isNotEmpty } from "../../../utils/asserts"; +import { Collections } from "src/shared/payload/constants"; +import { PayloadMedia, EndpointFilePreview, EndpointFile } from "src/shared/payload/endpoint-types"; +import { CollectionEndpoint } from "src/types/payload"; +import { isFile, isNotEmpty, isMediaThumbnail } from "src/utils/asserts"; import { convertAttributesToEndpointAttributes, - convertCreditsToEndpointCredits, + getLanguageId, convertMediaThumbnailToEndpointPayloadImage, convertRTCToEndpointRTC, - getLanguageId, -} from "../../../utils/endpoints"; + convertCreditsToEndpointCredits, +} from "src/utils/endpoints"; +import { File } from "src/types/collections"; export const getByID: CollectionEndpoint = { method: "get", diff --git a/src/collections/Folders/Folders.ts b/src/collections/Folders/Folders.ts index b4bcefe..cc66f4d 100644 --- a/src/collections/Folders/Folders.ts +++ b/src/collections/Folders/Folders.ts @@ -1,13 +1,13 @@ -import { CollectionGroups, Collections } from "../../constants"; -import { backPropagationField } from "../../fields/backPropagationField/backPropagationField"; -import { iconField } from "../../fields/iconField/iconField"; -import { rowField } from "../../fields/rowField/rowField"; -import { slugField } from "../../fields/slugField/slugField"; -import { translatedFields } from "../../fields/translatedFields/translatedFields"; -import { Folder } from "../../types/collections"; -import { isPayloadType } from "../../utils/asserts"; -import { buildCollectionConfig } from "../../utils/collectionConfig"; -import { createEditor } from "../../utils/editor"; +import { backPropagationField } from "src/fields/backPropagationField/backPropagationField"; +import { iconField } from "src/fields/iconField/iconField"; +import { rowField } from "src/fields/rowField/rowField"; +import { slugField } from "src/fields/slugField/slugField"; +import { translatedFields } from "src/fields/translatedFields/translatedFields"; +import { Collections, CollectionGroups } from "src/shared/payload/constants"; +import { Folder } from "src/types/collections"; +import { isPayloadType } from "src/utils/asserts"; +import { buildCollectionConfig } from "src/utils/collectionConfig"; +import { createEditor } from "src/utils/editor"; import { getBySlugEndpoint } from "./endpoints/getBySlugEndpoint"; const fields = { diff --git a/src/collections/Folders/endpoints/getBySlugEndpoint.ts b/src/collections/Folders/endpoints/getBySlugEndpoint.ts index fe470d0..4c4e2db 100644 --- a/src/collections/Folders/endpoints/getBySlugEndpoint.ts +++ b/src/collections/Folders/endpoints/getBySlugEndpoint.ts @@ -1,24 +1,24 @@ -import { Collections } from "../../../constants"; -import { createGetByEndpoint } from "../../../endpoints/createGetByEndpoint"; -import { EndpointFolder, EndpointFolderPreview } from "../../../sdk"; -import { Folder, Language } from "../../../types/collections"; +import { convertAudioToEndpointAudioPreview } from "src/collections/Audios/endpoints/getByID"; +import { convertCollectibleToEndpointCollectiblePreview } from "src/collections/Collectibles/endpoints/getBySlugEndpoint"; +import { convertFileToEndpointFilePreview } from "src/collections/Files/endpoints/getByID"; +import { convertImageToEndpointImagePreview } from "src/collections/Images/endpoints/getByID"; +import { convertPageToEndpointPagePreview } from "src/collections/Pages/endpoints/getBySlugEndpoint"; +import { convertVideoToEndpointVideoPreview } from "src/collections/Videos/endpoints/getByID"; +import { createGetByEndpoint } from "src/endpoints/createGetByEndpoint"; +import { Collections } from "src/shared/payload/constants"; +import { EndpointFolderPreview, EndpointFolder } from "src/shared/payload/endpoint-types"; +import { Folder, Language } from "src/types/collections"; import { - isAudio, isDefined, - isFile, - isImage, isNotEmpty, isPayloadType, isPublished, + isImage, + isAudio, isVideo, -} from "../../../utils/asserts"; -import { convertSourceToEndpointSource, getLanguageId } from "../../../utils/endpoints"; -import { convertAudioToEndpointAudioPreview } from "../../Audios/endpoints/getByID"; -import { convertCollectibleToEndpointCollectiblePreview } from "../../Collectibles/endpoints/getBySlugEndpoint"; -import { convertFileToEndpointFilePreview } from "../../Files/endpoints/getByID"; -import { convertImageToEndpointImagePreview } from "../../Images/endpoints/getByID"; -import { convertPageToEndpointPagePreview } from "../../Pages/endpoints/getBySlugEndpoint"; -import { convertVideoToEndpointVideoPreview } from "../../Videos/endpoints/getByID"; + isFile, +} from "src/utils/asserts"; +import { getLanguageId, convertSourceToEndpointSource } from "src/utils/endpoints"; export const getBySlugEndpoint = createGetByEndpoint({ collection: Collections.Folders, diff --git a/src/collections/GenericContents/GenericContents.ts b/src/collections/GenericContents/GenericContents.ts index de25d5c..98f7ad0 100644 --- a/src/collections/GenericContents/GenericContents.ts +++ b/src/collections/GenericContents/GenericContents.ts @@ -1,10 +1,10 @@ import { CollectionConfig } from "payload/types"; -import { QuickFilters, languageBasedFilters } from "../../components/QuickFilters"; -import { CollectionGroups, Collections } from "../../constants"; -import { rowField } from "../../fields/rowField/rowField"; -import { translatedFields } from "../../fields/translatedFields/translatedFields"; -import { beforeDuplicateAddCopyTo } from "../../hooks/beforeDuplicateAddCopyTo"; -import { buildCollectionConfig } from "../../utils/collectionConfig"; +import { QuickFilters, languageBasedFilters } from "src/components/QuickFilters"; +import { rowField } from "src/fields/rowField/rowField"; +import { translatedFields } from "src/fields/translatedFields/translatedFields"; +import { beforeDuplicateAddCopyTo } from "src/hooks/beforeDuplicateAddCopyTo"; +import { Collections, CollectionGroups } from "src/shared/payload/constants"; +import { buildCollectionConfig } from "src/utils/collectionConfig"; const fields = { name: "name", diff --git a/src/collections/Images/Images.ts b/src/collections/Images/Images.ts index f832d8d..f6f75e8 100644 --- a/src/collections/Images/Images.ts +++ b/src/collections/Images/Images.ts @@ -1,15 +1,15 @@ -import { Collections } from "../../constants"; -import { createImageSizesRegenerationEndpoint } from "../../endpoints/imageSizesRegenerationEndpoint"; -import { attributesField } from "../../fields/attributesField/attributesField"; -import { creditsField } from "../../fields/creditsField/creditsField"; -import { rowField } from "../../fields/rowField/rowField"; -import { translatedFields } from "../../fields/translatedFields/translatedFields"; -import { createEditor } from "../../utils/editor"; +import { createImageSizesRegenerationEndpoint } from "src/endpoints/imageSizesRegenerationEndpoint"; +import { attributesField } from "src/fields/attributesField/attributesField"; +import { creditsField } from "src/fields/creditsField/creditsField"; +import { rowField } from "src/fields/rowField/rowField"; +import { translatedFields } from "src/fields/translatedFields/translatedFields"; +import { Collections } from "src/shared/payload/constants"; +import { createEditor } from "src/utils/editor"; import { buildImageCollectionConfig, generateOpenGraphSize, generateWebpSize, -} from "../../utils/imageCollectionConfig"; +} from "src/utils/imageCollectionConfig"; import { getByID } from "./endpoints/getByID"; const fields = { diff --git a/src/collections/Images/endpoints/getByID.ts b/src/collections/Images/endpoints/getByID.ts index d4640f0..2382cb6 100644 --- a/src/collections/Images/endpoints/getByID.ts +++ b/src/collections/Images/endpoints/getByID.ts @@ -1,16 +1,20 @@ import payload from "payload"; -import { Collections } from "../../../constants"; -import { EndpointImage, EndpointImagePreview, PayloadImage } from "../../../sdk"; -import { Image } from "../../../types/collections"; -import { CollectionEndpoint } from "../../../types/payload"; -import { isImage, isNotEmpty, isPayloadImage } from "../../../utils/asserts"; +import { Collections } from "src/shared/payload/constants"; +import { + PayloadImage, + EndpointImagePreview, + EndpointImage, +} from "src/shared/payload/endpoint-types"; +import { CollectionEndpoint } from "src/types/payload"; +import { isImage, isNotEmpty, isPayloadImage } from "src/utils/asserts"; import { convertAttributesToEndpointAttributes, - convertCreditsToEndpointCredits, - convertRTCToEndpointRTC, - convertSizesToPayloadImages, getLanguageId, -} from "../../../utils/endpoints"; + convertSizesToPayloadImages, + convertRTCToEndpointRTC, + convertCreditsToEndpointCredits, +} from "src/utils/endpoints"; +import { Image } from "src/types/collections"; export const getByID: CollectionEndpoint = { method: "get", diff --git a/src/collections/Languages/Languages.ts b/src/collections/Languages/Languages.ts index 817c8ba..48d8f9a 100644 --- a/src/collections/Languages/Languages.ts +++ b/src/collections/Languages/Languages.ts @@ -1,11 +1,10 @@ import { text } from "payload/dist/fields/validations"; -import { mustBeAdmin } from "../../accesses/collections/mustBeAdmin"; -import { shownOnlyToAdmin } from "../../accesses/collections/shownOnlyToAdmin"; -import { CollectionGroups, Collections } from "../../constants"; -import { rowField } from "../../fields/rowField/rowField"; -import { buildCollectionConfig } from "../../utils/collectionConfig"; import { getAllEndpoint } from "./endpoints/getAllEndpoint"; -import { importFromStrapi } from "./endpoints/importFromStrapi"; +import { shownOnlyToAdmin } from "src/accesses/collections/shownOnlyToAdmin"; +import { mustBeAdmin } from "src/accesses/fields/mustBeAdmin"; +import { rowField } from "src/fields/rowField/rowField"; +import { Collections, CollectionGroups } from "src/shared/payload/constants"; +import { buildCollectionConfig } from "src/utils/collectionConfig"; const fields = { id: "id", @@ -30,7 +29,7 @@ export const Languages = buildCollectionConfig({ }, access: { create: mustBeAdmin, update: mustBeAdmin, delete: mustBeAdmin }, timestamps: false, - endpoints: [importFromStrapi, getAllEndpoint], + endpoints: [getAllEndpoint], fields: [ { name: fields.id, diff --git a/src/collections/Languages/endpoints/getAllEndpoint.ts b/src/collections/Languages/endpoints/getAllEndpoint.ts index 8c95684..ded3b27 100644 --- a/src/collections/Languages/endpoints/getAllEndpoint.ts +++ b/src/collections/Languages/endpoints/getAllEndpoint.ts @@ -1,7 +1,7 @@ import payload from "payload"; -import { Collections } from "../../../constants"; -import { Language } from "../../../types/collections"; -import { CollectionEndpoint } from "../../../types/payload"; +import { Collections } from "src/shared/payload/constants"; +import { Language } from "src/types/collections"; +import { CollectionEndpoint } from "src/types/payload"; export const getAllEndpoint: CollectionEndpoint = { method: "get", diff --git a/src/collections/Languages/endpoints/importFromStrapi.ts b/src/collections/Languages/endpoints/importFromStrapi.ts deleted file mode 100644 index 61705df..0000000 --- a/src/collections/Languages/endpoints/importFromStrapi.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Collections } from "../../../constants"; -import { createStrapiImportEndpoint } from "../../../endpoints/createStrapiImportEndpoint"; - -type StrapiLanguage = { - name: string; - code: string; -}; - -export const importFromStrapi = createStrapiImportEndpoint({ - strapi: { - collection: "languages", - params: {}, - }, - payload: { - collection: Collections.Languages, - convert: ({ code, name }) => ({ id: code, name }), - }, -}); diff --git a/src/collections/MediaThumbnails/MediaThumbnails.ts b/src/collections/MediaThumbnails/MediaThumbnails.ts index c72ceef..2770ed6 100644 --- a/src/collections/MediaThumbnails/MediaThumbnails.ts +++ b/src/collections/MediaThumbnails/MediaThumbnails.ts @@ -1,11 +1,11 @@ -import { shownOnlyToAdmin } from "../../accesses/collections/shownOnlyToAdmin"; -import { Collections } from "../../constants"; -import { createImageSizesRegenerationEndpoint } from "../../endpoints/imageSizesRegenerationEndpoint"; +import { shownOnlyToAdmin } from "src/accesses/collections/shownOnlyToAdmin"; +import { createImageSizesRegenerationEndpoint } from "src/endpoints/imageSizesRegenerationEndpoint"; +import { Collections } from "src/shared/payload/constants"; import { buildImageCollectionConfig, generateOpenGraphSize, generateWebpSize, -} from "../../utils/imageCollectionConfig"; +} from "src/utils/imageCollectionConfig"; const fields = { filename: "filename", diff --git a/src/collections/Pages/Pages.ts b/src/collections/Pages/Pages.ts index d091a41..69dace1 100644 --- a/src/collections/Pages/Pages.ts +++ b/src/collections/Pages/Pages.ts @@ -1,22 +1,22 @@ import { Where } from "payload/types"; -import { breakBlock } from "../../blocks/breakBlock"; -import { sectionBlock } from "../../blocks/sectionBlock"; -import { transcriptBlock } from "../../blocks/transcriptBlock"; -import { QuickFilters, publishStatusFilters } from "../../components/QuickFilters"; -import { CollectionGroups, Collections } from "../../constants"; -import { attributesField } from "../../fields/attributesField/attributesField"; -import { backPropagationField } from "../../fields/backPropagationField/backPropagationField"; -import { creditsField } from "../../fields/creditsField/creditsField"; -import { imageField } from "../../fields/imageField/imageField"; -import { rowField } from "../../fields/rowField/rowField"; -import { slugField } from "../../fields/slugField/slugField"; -import { translatedFields } from "../../fields/translatedFields/translatedFields"; -import { beforeDuplicateAddCopyTo } from "../../hooks/beforeDuplicateAddCopyTo"; -import { beforeDuplicatePiping } from "../../hooks/beforeDuplicatePiping"; -import { beforeDuplicateUnpublish } from "../../hooks/beforeDuplicateUnpublish"; -import { createEditor } from "../../utils/editor"; -import { buildVersionedCollectionConfig } from "../../utils/versionedCollectionConfig"; import { getBySlugEndpoint } from "./endpoints/getBySlugEndpoint"; +import { breakBlock } from "src/blocks/breakBlock"; +import { sectionBlock } from "src/blocks/sectionBlock"; +import { transcriptBlock } from "src/blocks/transcriptBlock"; +import { QuickFilters, publishStatusFilters } from "src/components/QuickFilters"; +import { attributesField } from "src/fields/attributesField/attributesField"; +import { backPropagationField } from "src/fields/backPropagationField/backPropagationField"; +import { creditsField } from "src/fields/creditsField/creditsField"; +import { imageField } from "src/fields/imageField/imageField"; +import { rowField } from "src/fields/rowField/rowField"; +import { slugField } from "src/fields/slugField/slugField"; +import { translatedFields } from "src/fields/translatedFields/translatedFields"; +import { beforeDuplicateAddCopyTo } from "src/hooks/beforeDuplicateAddCopyTo"; +import { beforeDuplicatePiping } from "src/hooks/beforeDuplicatePiping"; +import { beforeDuplicateUnpublish } from "src/hooks/beforeDuplicateUnpublish"; +import { Collections, CollectionGroups } from "src/shared/payload/constants"; +import { createEditor } from "src/utils/editor"; +import { buildVersionedCollectionConfig } from "src/utils/versionedCollectionConfig"; const fields = { slug: "slug", diff --git a/src/collections/Pages/endpoints/getBySlugEndpoint.ts b/src/collections/Pages/endpoints/getBySlugEndpoint.ts index 4d12633..1237289 100644 --- a/src/collections/Pages/endpoints/getBySlugEndpoint.ts +++ b/src/collections/Pages/endpoints/getBySlugEndpoint.ts @@ -1,23 +1,26 @@ +import { convertRecorderToEndpointRecorderPreview } from "src/collections/Recorders/endpoints/getByID"; +import { createGetByEndpoint } from "src/endpoints/createGetByEndpoint"; +import { Collections, BreakBlockType } from "src/shared/payload/constants"; +import { + EndpointPagePreview, + EndpointPage, + TableOfContentEntry, +} from "src/shared/payload/endpoint-types"; import { - BreakBlockType, - Collections, RichTextContent, - isBlockNodeBreakBlock, - isBlockNodeSectionBlock, isNodeBlockNode, -} from "../../../constants"; -import { createGetByEndpoint } from "../../../endpoints/createGetByEndpoint"; -import { EndpointPage, EndpointPagePreview, TableOfContentEntry } from "../../../sdk"; -import { Page } from "../../../types/collections"; -import { isImage, isNotEmpty, isPayloadType } from "../../../utils/asserts"; + isBlockNodeSectionBlock, + isBlockNodeBreakBlock, +} from "src/shared/payload/rich-text"; +import { Page } from "src/types/collections"; +import { isImage, isPayloadType, isNotEmpty } from "src/utils/asserts"; import { - convertAttributesToEndpointAttributes, - convertCreditsToEndpointCredits, convertImageToEndpointPayloadImage, + convertAttributesToEndpointAttributes, convertRTCToEndpointRTC, + convertCreditsToEndpointCredits, convertSourceToEndpointSource, -} from "../../../utils/endpoints"; -import { convertRecorderToEndpointRecorderPreview } from "../../Recorders/endpoints/getByID"; +} from "src/utils/endpoints"; export const getBySlugEndpoint = createGetByEndpoint({ collection: Collections.Pages, diff --git a/src/collections/Recorders/Recorders.ts b/src/collections/Recorders/Recorders.ts index 2909bde..ac25cbd 100644 --- a/src/collections/Recorders/Recorders.ts +++ b/src/collections/Recorders/Recorders.ts @@ -1,16 +1,16 @@ -import { mustBeAdmin as mustBeAdminForCollections } from "../../accesses/collections/mustBeAdmin"; -import { mustBeAdminOrSelf } from "../../accesses/collections/mustBeAdminOrSelf"; -import { mustBeAdmin as mustBeAdminForFields } from "../../accesses/fields/mustBeAdmin"; -import { QuickFilters } from "../../components/QuickFilters"; -import { CollectionGroups, Collections, RecordersRoles } from "../../constants"; -import { imageField } from "../../fields/imageField/imageField"; -import { rowField } from "../../fields/rowField/rowField"; -import { translatedFields } from "../../fields/translatedFields/translatedFields"; -import { buildCollectionConfig } from "../../utils/collectionConfig"; -import { createEditor } from "../../utils/editor"; +import { mustBeAdminOrSelf } from "src/accesses/collections/mustBeAdminOrSelf"; +import { QuickFilters } from "src/components/QuickFilters"; +import { imageField } from "src/fields/imageField/imageField"; +import { rowField } from "src/fields/rowField/rowField"; +import { translatedFields } from "src/fields/translatedFields/translatedFields"; +import { Collections, CollectionGroups, RecordersRoles } from "src/shared/payload/constants"; +import { buildCollectionConfig } from "src/utils/collectionConfig"; +import { createEditor } from "src/utils/editor"; import { getByID } from "./endpoints/getByID"; import { importFromStrapi } from "./endpoints/importFromStrapi"; import { beforeLoginMustHaveAtLeastOneRole } from "./hooks/beforeLoginMustHaveAtLeastOneRole"; +import { mustBeAdmin as mustBeAdminForCollections } from "src/accesses/collections/mustBeAdmin"; +import { mustBeAdmin as mustBeAdminForFields } from "src/accesses/fields/mustBeAdmin"; const fields = { username: "username", diff --git a/src/collections/Recorders/endpoints/getByID.ts b/src/collections/Recorders/endpoints/getByID.ts index c6dcb2a..21fccf6 100644 --- a/src/collections/Recorders/endpoints/getByID.ts +++ b/src/collections/Recorders/endpoints/getByID.ts @@ -1,13 +1,10 @@ import payload from "payload"; -import { Collections } from "../../../constants"; -import { EndpointRecorder, EndpointRecorderPreview } from "../../../sdk"; -import { Recorder } from "../../../types/collections"; -import { CollectionEndpoint } from "../../../types/payload"; -import { isImage, isPayloadType } from "../../../utils/asserts"; -import { - convertImageToEndpointPayloadImage, - convertRTCToEndpointRTC, -} from "../../../utils/endpoints"; +import { Collections } from "src/shared/payload/constants"; +import { EndpointRecorderPreview, EndpointRecorder } from "src/shared/payload/endpoint-types"; +import { Recorder } from "src/types/collections"; +import { CollectionEndpoint } from "src/types/payload"; +import { isPayloadType, isImage } from "src/utils/asserts"; +import { convertImageToEndpointPayloadImage, convertRTCToEndpointRTC } from "src/utils/endpoints"; export const getByID: CollectionEndpoint = { method: "get", diff --git a/src/collections/Recorders/endpoints/importFromStrapi.ts b/src/collections/Recorders/endpoints/importFromStrapi.ts index 7b9ef85..b9a454b 100644 --- a/src/collections/Recorders/endpoints/importFromStrapi.ts +++ b/src/collections/Recorders/endpoints/importFromStrapi.ts @@ -1,10 +1,10 @@ import payload from "payload"; -import { Collections } from "../../../constants"; -import { createStrapiImportEndpoint } from "../../../endpoints/createStrapiImportEndpoint"; -import { Recorder } from "../../../types/collections"; -import { StrapiImage, StrapiLanguage } from "../../../types/strapi"; -import { isDefined } from "../../../utils/asserts"; -import { uploadStrapiImage } from "../../../utils/localApi"; +import { createStrapiImportEndpoint } from "src/endpoints/createStrapiImportEndpoint"; +import { Collections } from "src/shared/payload/constants"; +import { Recorder } from "src/types/collections"; +import { StrapiImage, StrapiLanguage } from "src/types/strapi"; +import { isDefined } from "src/utils/asserts"; +import { uploadStrapiImage } from "src/utils/localApi"; type StrapiRecorder = { username: string; diff --git a/src/collections/Scans/Scans.ts b/src/collections/Scans/Scans.ts index 92fb517..5ddf5eb 100644 --- a/src/collections/Scans/Scans.ts +++ b/src/collections/Scans/Scans.ts @@ -1,7 +1,7 @@ -import { shownOnlyToAdmin } from "../../accesses/collections/shownOnlyToAdmin"; -import { Collections } from "../../constants"; -import { createImageSizesRegenerationEndpoint } from "../../endpoints/imageSizesRegenerationEndpoint"; -import { buildImageCollectionConfig, generateWebpSize } from "../../utils/imageCollectionConfig"; +import { shownOnlyToAdmin } from "src/accesses/collections/shownOnlyToAdmin"; +import { createImageSizesRegenerationEndpoint } from "src/endpoints/imageSizesRegenerationEndpoint"; +import { Collections } from "src/shared/payload/constants"; +import { buildImageCollectionConfig, generateWebpSize } from "src/utils/imageCollectionConfig"; const fields = { filename: "filename", diff --git a/src/collections/Tags/Tags.ts b/src/collections/Tags/Tags.ts index f4ef886..654707d 100644 --- a/src/collections/Tags/Tags.ts +++ b/src/collections/Tags/Tags.ts @@ -1,10 +1,10 @@ import { CollectionConfig } from "payload/types"; -import { CollectionGroups, Collections } from "../../constants"; -import { rowField } from "../../fields/rowField/rowField"; -import { slugField } from "../../fields/slugField/slugField"; -import { translatedFields } from "../../fields/translatedFields/translatedFields"; -import { beforeDuplicateAddCopyTo } from "../../hooks/beforeDuplicateAddCopyTo"; -import { buildCollectionConfig } from "../../utils/collectionConfig"; +import { rowField } from "src/fields/rowField/rowField"; +import { slugField } from "src/fields/slugField/slugField"; +import { translatedFields } from "src/fields/translatedFields/translatedFields"; +import { beforeDuplicateAddCopyTo } from "src/hooks/beforeDuplicateAddCopyTo"; +import { Collections, CollectionGroups } from "src/shared/payload/constants"; +import { buildCollectionConfig } from "src/utils/collectionConfig"; const fields = { slug: "slug", diff --git a/src/collections/Videos/Videos.ts b/src/collections/Videos/Videos.ts index fef3537..9adc6d3 100644 --- a/src/collections/Videos/Videos.ts +++ b/src/collections/Videos/Videos.ts @@ -1,14 +1,14 @@ -import { CollectionGroups, Collections } from "../../constants"; -import { attributesField } from "../../fields/attributesField/attributesField"; -import { componentField } from "../../fields/componentField/componentField"; -import { creditsField } from "../../fields/creditsField/creditsField"; -import { imageField } from "../../fields/imageField/imageField"; -import { rowField } from "../../fields/rowField/rowField"; -import { translatedFields } from "../../fields/translatedFields/translatedFields"; -import { Video } from "../../types/collections"; -import { isPayloadType } from "../../utils/asserts"; -import { buildCollectionConfig } from "../../utils/collectionConfig"; -import { createEditor } from "../../utils/editor"; +import { attributesField } from "src/fields/attributesField/attributesField"; +import { componentField } from "src/fields/componentField/componentField"; +import { creditsField } from "src/fields/creditsField/creditsField"; +import { imageField } from "src/fields/imageField/imageField"; +import { rowField } from "src/fields/rowField/rowField"; +import { translatedFields } from "src/fields/translatedFields/translatedFields"; +import { Collections, CollectionGroups } from "src/shared/payload/constants"; +import { Video } from "src/types/collections"; +import { isPayloadType } from "src/utils/asserts"; +import { buildCollectionConfig } from "src/utils/collectionConfig"; +import { createEditor } from "src/utils/editor"; import { getByID } from "./endpoints/getByID"; const fields = { diff --git a/src/collections/Videos/endpoints/getByID.ts b/src/collections/Videos/endpoints/getByID.ts index 0548fef..c4c3c10 100644 --- a/src/collections/Videos/endpoints/getByID.ts +++ b/src/collections/Videos/endpoints/getByID.ts @@ -1,24 +1,28 @@ import payload from "payload"; -import { Collections } from "../../../constants"; -import { EndpointVideo, EndpointVideoPreview, PayloadMedia } from "../../../sdk"; -import { Video } from "../../../types/collections"; -import { CollectionEndpoint } from "../../../types/payload"; +import { Collections } from "src/shared/payload/constants"; +import { + PayloadMedia, + EndpointVideoPreview, + EndpointVideo, +} from "src/shared/payload/endpoint-types"; +import { Video } from "src/types/collections"; +import { CollectionEndpoint } from "src/types/payload"; import { - isDefined, - isEmpty, - isMediaThumbnail, - isNotEmpty, - isPayloadType, - isUndefined, isVideo, -} from "../../../utils/asserts"; + isNotEmpty, + isMediaThumbnail, + isUndefined, + isPayloadType, + isEmpty, + isDefined, +} from "src/utils/asserts"; import { convertAttributesToEndpointAttributes, - convertCreditsToEndpointCredits, + getLanguageId, convertMediaThumbnailToEndpointPayloadImage, convertRTCToEndpointRTC, - getLanguageId, -} from "../../../utils/endpoints"; + convertCreditsToEndpointCredits, +} from "src/utils/endpoints"; export const getByID: CollectionEndpoint = { method: "get", diff --git a/src/collections/VideosChannels/VideosChannels.ts b/src/collections/VideosChannels/VideosChannels.ts index d3bd118..4ca3f26 100644 --- a/src/collections/VideosChannels/VideosChannels.ts +++ b/src/collections/VideosChannels/VideosChannels.ts @@ -1,8 +1,8 @@ import { CollectionConfig } from "payload/types"; -import { CollectionGroups, Collections } from "../../constants"; -import { backPropagationField } from "../../fields/backPropagationField/backPropagationField"; -import { rowField } from "../../fields/rowField/rowField"; -import { buildCollectionConfig } from "../../utils/collectionConfig"; +import { backPropagationField } from "src/fields/backPropagationField/backPropagationField"; +import { rowField } from "src/fields/rowField/rowField"; +import { Collections, CollectionGroups } from "src/shared/payload/constants"; +import { buildCollectionConfig } from "src/utils/collectionConfig"; const fields = { url: "url", diff --git a/src/collections/VideosSubtitles/VideosSubtitles.ts b/src/collections/VideosSubtitles/VideosSubtitles.ts index 4f7ce9c..5f3894b 100644 --- a/src/collections/VideosSubtitles/VideosSubtitles.ts +++ b/src/collections/VideosSubtitles/VideosSubtitles.ts @@ -1,6 +1,6 @@ -import { shownOnlyToAdmin } from "../../accesses/collections/shownOnlyToAdmin"; -import { CollectionGroups, Collections } from "../../constants"; -import { buildCollectionConfig } from "../../utils/collectionConfig"; +import { shownOnlyToAdmin } from "src/accesses/collections/shownOnlyToAdmin"; +import { Collections, CollectionGroups } from "src/shared/payload/constants"; +import { buildCollectionConfig } from "src/utils/collectionConfig"; export const VideosSubtitles = buildCollectionConfig({ slug: Collections.VideosSubtitles, diff --git a/src/collections/WebsiteConfig/WebsiteConfig.ts b/src/collections/WebsiteConfig/WebsiteConfig.ts index 7bc840a..d3d752e 100644 --- a/src/collections/WebsiteConfig/WebsiteConfig.ts +++ b/src/collections/WebsiteConfig/WebsiteConfig.ts @@ -1,10 +1,10 @@ import { GlobalConfig } from "payload/types"; -import { mustBeAdmin } from "../../accesses/collections/mustBeAdmin"; -import { CollectionGroups, Collections } from "../../constants"; -import { imageField } from "../../fields/imageField/imageField"; -import { rowField } from "../../fields/rowField/rowField"; -import { globalAfterChangeWebhook } from "../../hooks/afterOperationWebhook"; import { getConfigEndpoint } from "./endpoints/getConfigEndpoint"; +import { mustBeAdmin } from "src/accesses/fields/mustBeAdmin"; +import { imageField } from "src/fields/imageField/imageField"; +import { rowField } from "src/fields/rowField/rowField"; +import { globalAfterChangeWebhook } from "src/hooks/afterOperationWebhook"; +import { Collections, CollectionGroups } from "src/shared/payload/constants"; const fields = { homeBackgroundImage: "homeBackgroundImage", diff --git a/src/collections/WebsiteConfig/endpoints/getConfigEndpoint.ts b/src/collections/WebsiteConfig/endpoints/getConfigEndpoint.ts index dab72c8..2dd5143 100644 --- a/src/collections/WebsiteConfig/endpoints/getConfigEndpoint.ts +++ b/src/collections/WebsiteConfig/endpoints/getConfigEndpoint.ts @@ -1,10 +1,10 @@ import payload from "payload"; -import { Collections } from "../../../constants"; -import { EndpointWebsiteConfig } from "../../../sdk"; -import { CollectionEndpoint } from "../../../types/payload"; -import { isImage, isPayloadType } from "../../../utils/asserts"; -import { convertImageToEndpointPayloadImage } from "../../../utils/endpoints"; -import { convertFolderToEndpointFolderPreview } from "../../Folders/endpoints/getBySlugEndpoint"; +import { convertFolderToEndpointFolderPreview } from "src/collections/Folders/endpoints/getBySlugEndpoint"; +import { Collections } from "src/shared/payload/constants"; +import { EndpointWebsiteConfig } from "src/shared/payload/endpoint-types"; +import { CollectionEndpoint } from "src/types/payload"; +import { isImage, isPayloadType } from "src/utils/asserts"; +import { convertImageToEndpointPayloadImage } from "src/utils/endpoints"; export const getConfigEndpoint: CollectionEndpoint = { method: "get", diff --git a/src/collections/Wordings/Wordings.ts b/src/collections/Wordings/Wordings.ts index b8096f1..fc55076 100644 --- a/src/collections/Wordings/Wordings.ts +++ b/src/collections/Wordings/Wordings.ts @@ -1,12 +1,12 @@ import { CollectionConfig } from "payload/types"; -import { mustBeAdmin } from "../../accesses/collections/mustBeAdmin"; -import { QuickFilters, languageBasedFilters } from "../../components/QuickFilters"; -import { CollectionGroups, Collections } from "../../constants"; -import { rowField } from "../../fields/rowField/rowField"; -import { translatedFields } from "../../fields/translatedFields/translatedFields"; -import { beforeDuplicateAddCopyTo } from "../../hooks/beforeDuplicateAddCopyTo"; -import { buildCollectionConfig } from "../../utils/collectionConfig"; import { getAllEndpoint } from "./endpoints/getAllEndpoint"; +import { mustBeAdmin } from "src/accesses/fields/mustBeAdmin"; +import { QuickFilters, languageBasedFilters } from "src/components/QuickFilters"; +import { rowField } from "src/fields/rowField/rowField"; +import { translatedFields } from "src/fields/translatedFields/translatedFields"; +import { beforeDuplicateAddCopyTo } from "src/hooks/beforeDuplicateAddCopyTo"; +import { Collections, CollectionGroups } from "src/shared/payload/constants"; +import { buildCollectionConfig } from "src/utils/collectionConfig"; const fields = { name: "name", diff --git a/src/collections/Wordings/endpoints/getAllEndpoint.ts b/src/collections/Wordings/endpoints/getAllEndpoint.ts index bb25c61..db9c6f6 100644 --- a/src/collections/Wordings/endpoints/getAllEndpoint.ts +++ b/src/collections/Wordings/endpoints/getAllEndpoint.ts @@ -1,8 +1,8 @@ import payload from "payload"; -import { Collections } from "../../../constants"; -import { EndpointWording } from "../../../sdk"; -import { CollectionEndpoint } from "../../../types/payload"; -import { isPayloadType } from "../../../utils/asserts"; +import { Collections } from "src/shared/payload/constants"; +import { EndpointWording } from "src/shared/payload/endpoint-types"; +import { CollectionEndpoint } from "src/types/payload"; +import { isPayloadType } from "src/utils/asserts"; export const getAllEndpoint: CollectionEndpoint = { method: "get", diff --git a/src/components/QuickFilters.tsx b/src/components/QuickFilters.tsx index 6eab081..04da486 100644 --- a/src/components/QuickFilters.tsx +++ b/src/components/QuickFilters.tsx @@ -2,8 +2,8 @@ import { Options } from "payload/dist/collections/operations/local/find"; import QueryString from "qs"; import React from "react"; import { Link } from "react-router-dom"; +import { LanguageCodes } from "src/shared/payload/constants"; import styled from "styled-components"; -import { LanguageCodes } from "../constants"; type Props = { slug: string; diff --git a/src/constants.ts b/src/constants.ts deleted file mode 100644 index d221367..0000000 --- a/src/constants.ts +++ /dev/null @@ -1,312 +0,0 @@ -import { EndpointAudioPreview, EndpointImagePreview, EndpointVideoPreview } from "./sdk"; -import type { BreakBlock, SectionBlock, TranscriptBlock } from "./types/collections"; - -// END MOCKING SECTION - -export enum Collections { - Attributes = "attributes", - Audios = "audios", - ChronologyEvents = "chronology-events", - Collectibles = "collectibles", - CreditsRole = "credits-roles", - Currencies = "currencies", - Files = "files", - Folders = "folders", - GenericContents = "generic-contents", - Images = "images", - Languages = "languages", - MediaThumbnails = "media-thumbnails", - Pages = "pages", - Recorders = "recorders", - Scans = "scans", - Tags = "tags", - Videos = "videos", - VideosChannels = "videos-channels", - VideosSubtitles = "videos-subtitles", - Wordings = "wordings", - WebsiteConfig = "website-config", -} - -export enum CollectionGroups { - Collections = "Collections", - Media = "Media", - Meta = "Meta", -} - -export enum LanguageCodes { - en = "English", - fr = "French", - ja = "Japan", - es = "Spanish", - "pt-br" = "Portuguese", - "zh" = "Chinese", -} - -export enum BreakBlockType { - sceneBreak = "Scene break", - space = "Empty space", - solidLine = "Solid line", - dottedLine = "Dotted line", -} - -export enum CollectibleBindingTypes { - Paperback = "Paperback", - Hardcover = "Hardcover", -} - -export enum CollectiblePageOrders { - LeftToRight = "Left to right", - RightToLeft = "Right to left", -} - -export enum CollectibleNature { - Physical = "Physical", - Digital = "Digital", -} - -export enum CollectibleContentType { - None = "None", - Indexes = "Index-based", - Pages = "Page-based", -} - -export enum RecordersRoles { - Admin = "Admin", - Recorder = "Recorder", - Api = "Api", -} - -export enum CollectionStatus { - Draft = "draft", - Published = "published", -} - -export enum AttributeTypes { - Number = "Number", - Text = "Text", - Tags = "Tags", -} - -/* WEB HOOKS */ - -export type AfterOperationWebHookMessage = { - collection: Collections; - id?: string; - addedDependantIds: string[]; - urls: string[]; -}; -/* RICH TEXT */ - -export type RichTextContent = { - root: { - children: RichTextNode[]; - direction: ("ltr" | "rtl") | null; - format: "left" | "start" | "center" | "right" | "end" | "justify" | ""; - indent: number; - type: string; - version: number; - }; - [k: string]: unknown; -}; - -export type RichTextNode = { - type: string; - version: number; - [k: string]: unknown; -}; - -export interface RichTextNodeWithChildren extends RichTextNode { - children: RichTextNode[]; -} - -export interface RichTextParagraphNode extends RichTextNodeWithChildren { - type: "paragraph"; - format: "left" | "start" | "center" | "right" | "end" | "justify" | ""; -} - -export interface RichTextListNode extends RichTextNode { - type: "list"; - children: RichTextNodeWithChildren[]; - listType: string; -} - -export interface RichTextListNumberNode extends RichTextListNode { - listType: "number"; -} - -export interface RichTextListBulletNode extends RichTextListNode { - listType: "bullet"; -} - -export interface RichTextListCheckNode extends RichTextListNode { - listType: "check"; -} - -export interface RichTextLinebreakNode extends RichTextNode { - type: "linebreak"; -} - -export interface RichTextUploadNode extends RichTextNode { - type: "upload"; - relationTo: string; -} - -export interface RichTextUploadImageNode extends RichTextUploadNode { - relationTo: Collections.Images; - value: EndpointImagePreview; -} - -export interface RichTextUploadVideoNode extends RichTextUploadNode { - relationTo: Collections.Videos; - value: EndpointVideoPreview; -} - -export interface RichTextUploadAudioNode extends RichTextUploadNode { - relationTo: Collections.Audios; - value: EndpointAudioPreview; -} - -export interface RichTextTextNode extends RichTextNode { - type: "text"; - format: number; - text: string; -} - -export interface RichTextTabNode extends RichTextNode { - type: "tab"; - format: number; -} - -export interface RichTextLinkNode extends RichTextNodeWithChildren { - type: "link"; - fields: { - linkType: "internal" | "custom"; - }; -} - -export interface RichTextLinkInternalNode extends RichTextLinkNode { - fields: { - linkType: "internal"; - newTab: boolean; - doc: { - relationTo: string; - value: any; - }; - }; -} - -export interface RichTextLinkCustomNode extends RichTextLinkNode { - fields: { - linkType: "custom"; - newTab: boolean; - url: string; - }; -} - -export interface RichTextBlockNode extends RichTextNode { - type: "block"; - fields: { - blockType: string; - }; -} - -export interface RichTextSectionBlock extends RichTextBlockNode { - fields: SectionBlock; - anchorHash: string; -} - -export interface RichTextTranscriptBlock extends RichTextBlockNode { - fields: TranscriptBlock; -} - -export interface RichTextBreakBlock extends RichTextBlockNode { - fields: BreakBlock; - anchorHash: string; -} - -export const isNodeParagraphNode = (node: RichTextNode): node is RichTextParagraphNode => - node.type === "paragraph"; - -export const isNodeUploadNode = (node: RichTextNode): node is RichTextUploadNode => - node.type === "upload"; - -export const isUploadNodeImageNode = (node: RichTextUploadNode): node is RichTextUploadImageNode => - node.relationTo === Collections.Images; - -export const isUploadNodeVideoNode = (node: RichTextUploadNode): node is RichTextUploadVideoNode => - node.relationTo === Collections.Videos; - -export const isUploadNodeAudioNode = (node: RichTextUploadNode): node is RichTextUploadAudioNode => - node.relationTo === Collections.Audios; - -export const isNodeListNode = (node: RichTextNode): node is RichTextListNode => - node.type === "list"; - -export const isListNodeNumberListNode = (node: RichTextListNode): node is RichTextListNumberNode => - node.listType === "number"; - -export const isListNodeBulletListNode = (node: RichTextListNode): node is RichTextListBulletNode => - node.listType === "bullet"; - -export const isListNodeCheckListNode = (node: RichTextListNode): node is RichTextListCheckNode => - node.listType === "check"; - -export const isNodeLinebreakNode = (node: RichTextNode): node is RichTextLinebreakNode => - node.type === "linebreak"; - -export const isNodeTextNode = (node: RichTextNode): node is RichTextTextNode => - node.type === "text"; - -export const isNodeTabNode = (node: RichTextNode): node is RichTextTabNode => node.type === "tab"; - -export const isNodeLinkNode = (node: RichTextNode): node is RichTextLinkNode => - node.type === "link"; - -export const isLinkNodeInternalLinkNode = ( - node: RichTextLinkNode -): node is RichTextLinkInternalNode => node.fields.linkType === "internal"; - -export const isLinkNodeCustomLinkNode = (node: RichTextLinkNode): node is RichTextLinkCustomNode => - node.fields.linkType === "custom"; - -export const isNodeBlockNode = (node: RichTextNode): node is RichTextBlockNode => - node.type === "block"; - -export const isBlockNodeSectionBlock = (node: RichTextBlockNode): node is RichTextSectionBlock => - node.fields.blockType === "sectionBlock"; - -export const isBlockNodeTranscriptBlock = ( - node: RichTextBlockNode -): node is RichTextTranscriptBlock => node.fields.blockType === "transcriptBlock"; - -export const isBlockNodeBreakBlock = (node: RichTextBlockNode): node is RichTextBreakBlock => - node.fields.blockType === "breakBlock"; - -/* BLOCKS */ - -/* TODO: TO BE REMOVED WHEN https://github.com/payloadcms/payload/issues/5216 is closed */ -export interface CueBlock { - content: RichTextContent; - blockType: "cueBlock"; - id?: string | null; - blockName?: string | null; -} - -export interface LineBlock { - content: RichTextContent; - blockType: "lineBlock"; - id?: string | null; - blockName?: string | null; -} - -export interface GenericBlock { - id?: string | null; - blockName?: string | null; - blockType: string; -} - -export const isBlockCueBlock = (block: GenericBlock): block is CueBlock => - block.blockType === "cueBlock"; - -export const isBlockLineBlock = (block: GenericBlock): block is LineBlock => - block.blockType === "lineBlock"; diff --git a/src/endpoints/createGetByEndpoint.ts b/src/endpoints/createGetByEndpoint.ts index 09cf314..79dcdfc 100644 --- a/src/endpoints/createGetByEndpoint.ts +++ b/src/endpoints/createGetByEndpoint.ts @@ -1,6 +1,6 @@ import payload, { GeneratedTypes } from "payload"; -import { CollectionEndpoint } from "../types/payload"; -import { isPublished } from "../utils/asserts"; +import { CollectionEndpoint } from "src/types/payload"; +import { isPublished } from "src/utils/asserts"; interface Params { collection: C; diff --git a/src/endpoints/createStrapiImportEndpoint.ts b/src/endpoints/createStrapiImportEndpoint.ts index 58ebe2c..e716061 100644 --- a/src/endpoints/createStrapiImportEndpoint.ts +++ b/src/endpoints/createStrapiImportEndpoint.ts @@ -1,8 +1,8 @@ import payload, { GeneratedTypes } from "payload"; import QueryString from "qs"; -import { Recorder } from "../types/collections"; -import { CollectionEndpoint } from "../types/payload"; -import { isDefined } from "../utils/asserts"; +import { Recorder } from "src/types/collections"; +import { CollectionEndpoint } from "src/types/payload"; +import { isDefined } from "src/utils/asserts"; const getAllStrapiEntries = async (collectionSlug: string, params: Object): Promise => { let page = 1; diff --git a/src/endpoints/getAllIdsEndpoint.ts b/src/endpoints/getAllIdsEndpoint.ts index e5451cf..79e86e1 100644 --- a/src/endpoints/getAllIdsEndpoint.ts +++ b/src/endpoints/getAllIdsEndpoint.ts @@ -1,7 +1,7 @@ import payload from "payload"; import { Endpoint } from "payload/config"; -import { Collections } from "../constants"; -import { EndpointAllIds } from "../sdk"; +import { Collections } from "src/shared/payload/constants"; +import { EndpointAllIds } from "src/shared/payload/endpoint-types"; export const getAllIds: Endpoint = { method: "get", diff --git a/src/endpoints/getAllSDKUrlsEndpoint.ts b/src/endpoints/getAllSDKUrlsEndpoint.ts index 74b4e83..0103da1 100644 --- a/src/endpoints/getAllSDKUrlsEndpoint.ts +++ b/src/endpoints/getAllSDKUrlsEndpoint.ts @@ -1,8 +1,9 @@ import payload from "payload"; import { Endpoint } from "payload/config"; -import { Collections } from "../constants"; -import { EndpointAllSDKUrls, getSDKEndpoint } from "../sdk"; -import { Collectible } from "../types/collections"; +import { Collections } from "src/shared/payload/constants"; +import { EndpointAllSDKUrls } from "src/shared/payload/endpoint-types"; +import { getSDKEndpoint } from "src/shared/payload/sdk"; +import { Collectible } from "src/types/collections"; export const getAllSDKUrlsEndpoint: Endpoint = { method: "get", diff --git a/src/endpoints/imageSizesRegenerationEndpoint.ts b/src/endpoints/imageSizesRegenerationEndpoint.ts index 039ddb6..76659ae 100644 --- a/src/endpoints/imageSizesRegenerationEndpoint.ts +++ b/src/endpoints/imageSizesRegenerationEndpoint.ts @@ -1,5 +1,5 @@ import payload from "payload"; -import { CollectionEndpoint } from "../types/payload"; +import { CollectionEndpoint } from "src/types/payload"; export const createImageSizesRegenerationEndpoint = ( collection: "images" | "scans" | "media-thumbnails" diff --git a/src/fields/attributesField/attributesField.ts b/src/fields/attributesField/attributesField.ts index 7209fc9..6acf652 100644 --- a/src/fields/attributesField/attributesField.ts +++ b/src/fields/attributesField/attributesField.ts @@ -1,7 +1,7 @@ import { BlockField } from "payload/dist/fields/config/types"; -import { numberBlock } from "../../blocks/attributeBlocks/numberBlock"; -import { tagsBlock } from "../../blocks/attributeBlocks/tagsBlock"; -import { textBlock } from "../../blocks/attributeBlocks/textBlock"; +import { numberBlock } from "src/blocks/attributeBlocks/numberBlock"; +import { tagsBlock } from "src/blocks/attributeBlocks/tagsBlock"; +import { textBlock } from "src/blocks/attributeBlocks/textBlock"; type AttributesFieldProps = Omit; diff --git a/src/fields/backPropagationField/backPropagationField.ts b/src/fields/backPropagationField/backPropagationField.ts index 08e190f..90ab912 100644 --- a/src/fields/backPropagationField/backPropagationField.ts +++ b/src/fields/backPropagationField/backPropagationField.ts @@ -1,7 +1,7 @@ import payload, { GeneratedTypes } from "payload"; import { FieldBase, SingleRelationshipField } from "payload/dist/fields/config/types"; import { Where } from "payload/types"; -import { isEmpty } from "../../utils/asserts"; +import { isEmpty } from "src/utils/asserts"; type BackPropagationField = FieldBase & { where: (data: any) => Where; diff --git a/src/fields/componentField/componentField.ts b/src/fields/componentField/componentField.ts index 08b6258..81eecad 100644 --- a/src/fields/componentField/componentField.ts +++ b/src/fields/componentField/componentField.ts @@ -1,5 +1,5 @@ import { CollapsibleField, Condition, Field } from "payload/types"; -import { capitalize } from "../../utils/string"; +import { capitalize } from "src/utils/string"; type Props = { name: string; diff --git a/src/fields/creditsField/creditsField.ts b/src/fields/creditsField/creditsField.ts index a509549..5c8a21c 100644 --- a/src/fields/creditsField/creditsField.ts +++ b/src/fields/creditsField/creditsField.ts @@ -1,9 +1,9 @@ import { array } from "payload/dist/fields/validations"; import { ArrayField } from "payload/types"; -import { Collections } from "../../constants"; -import { Credits } from "../../types/collections"; -import { hasDuplicates, isDefined, isPayloadType, isUndefined } from "../../utils/asserts"; -import { rowField } from "../rowField/rowField"; +import { rowField } from "src/fields/rowField/rowField"; +import { Collections } from "src/shared/payload/constants"; +import { Credits } from "src/types/collections"; +import { isDefined, isUndefined, isPayloadType, hasDuplicates } from "src/utils/asserts"; type Props = Omit; diff --git a/src/fields/iconField/iconField.ts b/src/fields/iconField/iconField.ts index bba15c7..0cdf2a6 100644 --- a/src/fields/iconField/iconField.ts +++ b/src/fields/iconField/iconField.ts @@ -1,6 +1,6 @@ import { icons } from "@iconify-json/material-symbols"; import { TextField } from "payload/types"; -import { isEmpty } from "../../utils/asserts"; +import { isEmpty } from "src/utils/asserts"; type Props = Omit; diff --git a/src/fields/imageField/Cell.tsx b/src/fields/imageField/Cell.tsx index 17ab1ff..d90687f 100644 --- a/src/fields/imageField/Cell.tsx +++ b/src/fields/imageField/Cell.tsx @@ -1,7 +1,7 @@ import { Props } from "payload/components/views/Cell"; import React, { useEffect, useMemo, useState } from "react"; import { Link } from "react-router-dom"; -import { isUndefined } from "../../utils/asserts"; +import { isUndefined } from "src/utils/asserts"; export const Cell = ({ cellData, field, rowData, collection }: Props): JSX.Element => { const [imageURL, setImageURL] = useState(); diff --git a/src/fields/slugField/slugField.ts b/src/fields/slugField/slugField.ts index 252ed45..5b08396 100644 --- a/src/fields/slugField/slugField.ts +++ b/src/fields/slugField/slugField.ts @@ -1,5 +1,5 @@ import { TextField } from "payload/types"; -import { isUndefined } from "../../utils/asserts"; +import { isUndefined } from "src/utils/asserts"; type Props = Omit; diff --git a/src/fields/translatedFields/Cell.tsx b/src/fields/translatedFields/Cell.tsx index acb2b48..6bef99b 100644 --- a/src/fields/translatedFields/Cell.tsx +++ b/src/fields/translatedFields/Cell.tsx @@ -1,7 +1,7 @@ import React from "react"; -import { Language } from "../../types/collections"; -import { isDefined } from "../../utils/asserts"; -import { formatLanguageCode } from "../../utils/string"; +import { Language } from "src/types/collections"; +import { isDefined } from "src/utils/asserts"; +import { formatLanguageCode } from "src/utils/string"; interface Props { cellData: { language?: string | Language; title?: string }[]; diff --git a/src/fields/translatedFields/RowLabel.tsx b/src/fields/translatedFields/RowLabel.tsx index b047169..5fdddce 100644 --- a/src/fields/translatedFields/RowLabel.tsx +++ b/src/fields/translatedFields/RowLabel.tsx @@ -1,8 +1,8 @@ import React from "react"; +import { Language } from "src/types/collections"; +import { isDefined } from "src/utils/asserts"; +import { formatLanguageCode, shortenEllipsis } from "src/utils/string"; import styled from "styled-components"; -import { Language } from "../../types/collections"; -import { isDefined } from "../../utils/asserts"; -import { formatLanguageCode, shortenEllipsis } from "../../utils/string"; interface Props { language?: Language | string; diff --git a/src/fields/translatedFields/translatedFields.ts b/src/fields/translatedFields/translatedFields.ts index 64149d1..18d7ab1 100644 --- a/src/fields/translatedFields/translatedFields.ts +++ b/src/fields/translatedFields/translatedFields.ts @@ -1,11 +1,11 @@ import { RowLabelArgs } from "payload/dist/admin/components/forms/RowLabel/types"; import { array } from "payload/dist/fields/validations"; import { ArrayField, Field } from "payload/types"; -import { Collections } from "../../constants"; -import { hasDuplicates, isDefined, isUndefined } from "../../utils/asserts"; -import { rowField } from "../rowField/rowField"; import { Cell } from "./Cell"; import { RowLabel } from "./RowLabel"; +import { rowField } from "src/fields/rowField/rowField"; +import { Collections } from "src/shared/payload/constants"; +import { isDefined, isUndefined, hasDuplicates } from "src/utils/asserts"; const fieldsNames = { language: "language", diff --git a/src/hooks/afterOperationWebhook.ts b/src/hooks/afterOperationWebhook.ts index e6f6c2e..cab4634 100644 --- a/src/hooks/afterOperationWebhook.ts +++ b/src/hooks/afterOperationWebhook.ts @@ -3,9 +3,10 @@ import { AfterChangeHook as CollectionAfterChangeHook, } from "payload/dist/collections/config/types"; import { AfterChangeHook as GlobalAfterChangeHook } from "payload/dist/globals/config/types"; -import { AfterOperationWebHookMessage, Collections } from "../constants"; -import { getSDKUrlsForDocument } from "../endpoints/getAllSDKUrlsEndpoint"; -import { getAddedBackPropagationRelationships } from "../fields/backPropagationField/backPropagationUtils"; +import { getSDKUrlsForDocument } from "src/endpoints/getAllSDKUrlsEndpoint"; +import { getAddedBackPropagationRelationships } from "src/fields/backPropagationField/backPropagationUtils"; +import { Collections } from "src/shared/payload/constants"; +import { AfterOperationWebHookMessage } from "src/shared/payload/webhooks"; export const globalAfterChangeWebhook: GlobalAfterChangeHook = async ({ global, diff --git a/src/hooks/beforeDuplicateUnpublish.ts b/src/hooks/beforeDuplicateUnpublish.ts index 42573a3..fb59af4 100644 --- a/src/hooks/beforeDuplicateUnpublish.ts +++ b/src/hooks/beforeDuplicateUnpublish.ts @@ -1,5 +1,5 @@ import { BeforeDuplicate } from "payload/types"; -import { CollectionStatus } from "../constants"; +import { CollectionStatus } from "src/shared/payload/constants"; export const beforeDuplicateUnpublish: BeforeDuplicate = ({ data }) => ({ ...data, diff --git a/src/payload.config.ts b/src/payload.config.ts index c513b0c..d04c02e 100644 --- a/src/payload.config.ts +++ b/src/payload.config.ts @@ -4,33 +4,34 @@ import { cloudStorage } from "@payloadcms/plugin-cloud-storage"; import path from "path"; import { buildConfig } from "payload/config"; import { sftpAdapter } from "payloadcms-sftp-storage"; -import { Attributes } from "./collections/Attributes/Attributes"; -import { Audios } from "./collections/Audios/Audios"; -import { ChronologyEvents } from "./collections/ChronologyEvents/ChronologyEvents"; -import { Collectibles } from "./collections/Collectibles/Collectibles"; -import { CreditsRoles } from "./collections/CreditsRoles/CreditsRoles"; -import { Currencies } from "./collections/Currencies/Currencies"; -import { Files } from "./collections/Files/Files"; -import { Folders } from "./collections/Folders/Folders"; -import { GenericContents } from "./collections/GenericContents/GenericContents"; -import { Images } from "./collections/Images/Images"; -import { Languages } from "./collections/Languages/Languages"; -import { MediaThumbnails } from "./collections/MediaThumbnails/MediaThumbnails"; -import { Pages } from "./collections/Pages/Pages"; -import { Recorders } from "./collections/Recorders/Recorders"; -import { Scans } from "./collections/Scans/Scans"; -import { Tags } from "./collections/Tags/Tags"; -import { Videos } from "./collections/Videos/Videos"; -import { VideosChannels } from "./collections/VideosChannels/VideosChannels"; -import { VideosSubtitles } from "./collections/VideosSubtitles/VideosSubtitles"; -import { WebsiteConfig } from "./collections/WebsiteConfig/WebsiteConfig"; -import { Wordings } from "./collections/Wordings/Wordings"; -import { Icon } from "./components/Icon"; -import { Logo } from "./components/Logo"; -import { Collections } from "./constants"; -import { getAllIds } from "./endpoints/getAllIdsEndpoint"; -import { getAllSDKUrlsEndpoint } from "./endpoints/getAllSDKUrlsEndpoint"; -import { createEditor } from "./utils/editor"; +import { Attributes } from "src/collections/Attributes/Attributes"; +import { Audios } from "src/collections/Audios/Audios"; +import { ChronologyEvents } from "src/collections/ChronologyEvents/ChronologyEvents"; +import { Collectibles } from "src/collections/Collectibles/Collectibles"; +import { CreditsRoles } from "src/collections/CreditsRoles/CreditsRoles"; +import { Currencies } from "src/collections/Currencies/Currencies"; +import { Files } from "src/collections/Files/Files"; +import { Folders } from "src/collections/Folders/Folders"; +import { GenericContents } from "src/collections/GenericContents/GenericContents"; +import { Images } from "src/collections/Images/Images"; +import { Languages } from "src/collections/Languages/Languages"; +import { MediaThumbnails } from "src/collections/MediaThumbnails/MediaThumbnails"; +import { Pages } from "src/collections/Pages/Pages"; +import { Recorders } from "src/collections/Recorders/Recorders"; +import { Scans } from "src/collections/Scans/Scans"; +import { Tags } from "src/collections/Tags/Tags"; +import { Videos } from "src/collections/Videos/Videos"; +import { VideosChannels } from "src/collections/VideosChannels/VideosChannels"; +import { VideosSubtitles } from "src/collections/VideosSubtitles/VideosSubtitles"; +import { WebsiteConfig } from "src/collections/WebsiteConfig/WebsiteConfig"; +import { Wordings } from "src/collections/Wordings/Wordings"; +import { Icon } from "src/components/Icon"; +import { Logo } from "src/components/Logo"; +import { getAllIds } from "src/endpoints/getAllIdsEndpoint"; +import { getAllSDKUrlsEndpoint } from "src/endpoints/getAllSDKUrlsEndpoint"; +import { Collections } from "src/shared/payload/constants"; +import { createEditor } from "src/utils/editor"; +// import TsconfigPathsPlugin from "tsconfig-paths-webpack-plugin"; const configuredSftpAdapter = sftpAdapter({ connectOptions: { @@ -54,6 +55,22 @@ export default buildConfig({ }, css: path.resolve(__dirname, "styles.scss"), bundler: webpackBundler(), + webpack: (config) => ({ + ...config, + resolve: { + ...config.resolve, + // plugins: [ + // ...(config.resolve?.plugins ?? []), + // new TsconfigPathsPlugin({ + // /* options: see below */ + // }), + // ], + alias: { + ...config.resolve?.alias, + "src/": path.resolve(__dirname, "src"), + }, + }, + }), }, editor: createEditor({}), collections: [ diff --git a/src/sdk.ts b/src/sdk.ts deleted file mode 100644 index 4646110..0000000 --- a/src/sdk.ts +++ /dev/null @@ -1,727 +0,0 @@ -import { - AttributeTypes, - CollectibleBindingTypes, - CollectibleNature, - CollectiblePageOrders, - Collections, - RichTextContent, -} from "./constants"; -import { Currency, Language } from "./types/collections"; - -// END MOCKING SECTION - -export type EndpointFolderPreview = { - id: string; - slug: string; - icon?: string; - translations: { - language: string; - title: string; - }[]; -}; - -export type EndpointFolder = Omit & { - translations: (EndpointFolderPreview["translations"][number] & { - description?: RichTextContent; - })[]; - sections: - | { type: "single"; subfolders: EndpointFolderPreview[] } - | { - type: "multiple"; - sections: { - translations: { language: string; name: string }[]; - subfolders: EndpointFolderPreview[]; - }[]; - }; - files: ( - | { - relationTo: Collections.Collectibles; - value: EndpointCollectiblePreview; - } - | { - relationTo: Collections.Pages; - value: EndpointPagePreview; - } - | { - relationTo: Collections.Images; - value: EndpointImagePreview; - } - | { - relationTo: Collections.Audios; - value: EndpointAudioPreview; - } - | { - relationTo: Collections.Videos; - value: EndpointVideoPreview; - } - | { - relationTo: Collections.Files; - value: EndpointFilePreview; - } - )[]; - parentPages: EndpointSource[]; -}; - -export type EndpointWebsiteConfig = { - home: { - backgroundImage?: EndpointPayloadImage; - folders: (EndpointFolderPreview & { - lightThumbnail?: EndpointPayloadImage; - darkThumbnail?: EndpointPayloadImage; - })[]; - }; - timeline: { - backgroundImage?: EndpointPayloadImage; - breaks: number[]; - eventCount: number; - eras: { - startingYear: number; - endingYear: number; - name: string; - }[]; - }; - defaultOpenGraphImage?: EndpointPayloadImage; -}; - -export type EndpointRecorderPreview = { - id: string; - username: string; -}; - -export type EndpointRecorder = EndpointRecorderPreview & { - avatar?: EndpointPayloadImage; - translations: { - language: string; - biography: RichTextContent; - }[]; - languages: string[]; -}; - -export type EndpointWording = { - name: string; - translations: { - language: string; - name: string; - }[]; -}; - -export type EndpointTag = { - id: string; - slug: string; - page?: { slug: string }; - translations: { - language: string; - name: string; - }[]; -}; - -export type EndpointGenericAttribute = { - id: string; - slug: string; - icon: string; - translations: { - language: string; - name: string; - }[]; -}; - -export type EndpointNumberAttribute = EndpointGenericAttribute & { - type: AttributeTypes.Number; - value: number; -}; - -export type EndpointTextAttribute = EndpointGenericAttribute & { - type: AttributeTypes.Text; - value: string; -}; - -export type EndpointTagsAttribute = EndpointGenericAttribute & { - type: AttributeTypes.Tags; - value: EndpointTag[]; -}; - -export type EndpointAttribute = - | EndpointNumberAttribute - | EndpointTextAttribute - | EndpointTagsAttribute; - -export type EndpointRole = { - id: string; - icon: string; - translations: { - language: string; - name: string; - }[]; -}; - -export type EndpointCredit = { - role: EndpointRole; - recorders: EndpointRecorderPreview[]; -}; - -export type EndpointPagePreview = { - id: string; - slug: string; - thumbnail?: EndpointPayloadImage; - attributes: EndpointAttribute[]; - translations: { - language: string; - pretitle?: string; - title: string; - subtitle?: string; - }[]; - updatedAt: string; -}; - -export type EndpointPage = Omit & { - backgroundImage?: EndpointPayloadImage; - translations: (EndpointPagePreview["translations"][number] & { - sourceLanguage: string; - summary?: RichTextContent; - content: RichTextContent; - credits: EndpointCredit[]; - toc: TableOfContentEntry[]; - })[]; - createdAt: string; - updatedBy?: EndpointRecorderPreview; - parentPages: EndpointSource[]; -}; - -export type EndpointCollectiblePreview = { - id: string; - slug: string; - thumbnail?: EndpointPayloadImage; - translations: { - language: string; - pretitle?: string; - title: string; - subtitle?: string; - }[]; - attributes: EndpointAttribute[]; - releaseDate?: string; - languages: string[]; - price?: { - amount: number; - currency: string; - }; -}; - -export type EndpointCollectible = Omit & { - translations: (EndpointCollectiblePreview["translations"][number] & { - description?: RichTextContent; - })[]; - backgroundImage?: EndpointPayloadImage; - nature: CollectibleNature; - gallery?: { count: number; thumbnail: EndpointPayloadImage }; - scans?: { count: number; thumbnail: EndpointPayloadImage }; - urls: { url: string; label: string }[]; - size?: { - width: number; - height: number; - thickness?: number; - }; - weight?: number; - pageInfo?: { - pageCount: number; - bindingType?: CollectibleBindingTypes; - pageOrder?: CollectiblePageOrders; - }; - subitems: EndpointCollectiblePreview[]; - files: EndpointFilePreview[]; - contents: { - content: - | { - relationTo: Collections.Pages; - value: EndpointPagePreview; - } - | { - relationTo: Collections.Audios; - value: EndpointAudioPreview; - } - | { - relationTo: Collections.Videos; - value: EndpointVideoPreview; - } - | { - relationTo: Collections.GenericContents; - value: { - translations: { - language: string; - name: string; - }[]; - }; - }; - - range?: - | { - type: "pageRange"; - start: number; - end: number; - } - | { - type: "timeRange"; - start: string; - end: string; - } - | { - type: "other"; - translations: { - language: string; - note: RichTextContent; - }[]; - }; - }[]; - createdAt: string; - updatedAt: string; - updatedBy?: EndpointRecorderPreview; - parentPages: EndpointSource[]; -}; - -export type EndpointCollectibleScans = { - slug: string; - thumbnail?: EndpointPayloadImage; - translations: { - language: string; - pretitle?: string; - title: string; - subtitle?: string; - description?: RichTextContent; - }[]; - credits: EndpointCredit[]; - cover?: { - front?: EndpointScanImage; - spine?: EndpointScanImage; - back?: EndpointScanImage; - insideFront?: EndpointScanImage; - insideBack?: EndpointScanImage; - flapFront?: EndpointScanImage; - flapBack?: EndpointScanImage; - insideFlapFront?: EndpointScanImage; - insideFlapBack?: EndpointScanImage; - }; - dustjacket?: { - front?: EndpointScanImage; - spine?: EndpointScanImage; - back?: EndpointScanImage; - insideFront?: EndpointScanImage; - insideSpine?: EndpointScanImage; - insideBack?: EndpointScanImage; - flapFront?: EndpointScanImage; - flapBack?: EndpointScanImage; - insideFlapFront?: EndpointScanImage; - insideFlapBack?: EndpointScanImage; - }; - obi?: { - front?: EndpointScanImage; - spine?: EndpointScanImage; - back?: EndpointScanImage; - insideFront?: EndpointScanImage; - insideSpine?: EndpointScanImage; - insideBack?: EndpointScanImage; - flapFront?: EndpointScanImage; - flapBack?: EndpointScanImage; - insideFlapFront?: EndpointScanImage; - insideFlapBack?: EndpointScanImage; - }; - pages: EndpointScanImage[]; - parentPages: EndpointSource[]; -}; - -export type EndpointCollectibleGallery = { - slug: string; - thumbnail?: EndpointPayloadImage; - translations: { - language: string; - pretitle?: string; - title: string; - subtitle?: string; - description?: RichTextContent; - }[]; - images: EndpointPayloadImage[]; - parentPages: EndpointSource[]; -}; - -export type EndpointCollectibleGalleryImage = { - slug: string; - translations: { - language: string; - pretitle?: string; - title: string; - subtitle?: string; - description?: RichTextContent; - }[]; - image: EndpointImage; - previousIndex?: string; - nextIndex?: string; - parentPages: EndpointSource[]; -}; - -export type EndpointCollectibleScanPage = { - slug: string; - translations: { - language: string; - pretitle?: string; - title: string; - subtitle?: string; - description?: RichTextContent; - }[]; - image: EndpointScanImage; - previousIndex?: string; - nextIndex?: string; - parentPages: EndpointSource[]; -}; - -export type EndpointScanImage = PayloadImage & { - index: string; - sizes: PayloadImage[]; -}; - -export type TableOfContentEntry = { - prefix: string; - title: string; - type: "sceneBreak" | "break" | "section"; - index: number; - children: TableOfContentEntry[]; -}; - -export type EndpointChronologyEvent = { - id: string; - date: { - year: number; - month?: number; - day?: number; - }; - events: { - sources: EndpointSource[]; - translations: { - language: string; - sourceLanguage: string; - title?: string; - description?: RichTextContent; - notes?: RichTextContent; - credits: EndpointCredit[]; - }[]; - }[]; -}; - -export type EndpointSourcePreview = { - id: string; - slug: string; - translations: { language: string; pretitle?: string; title: string; subtitle?: string }[]; -}; - -export type EndpointSource = - | { type: "url"; url: string; label: string } - | { - type: "collectible"; - collectible: EndpointSourcePreview; - range?: - | { type: "page"; page: number } - | { type: "timestamp"; timestamp: string } - | { type: "custom"; translations: { language: string; note: string }[] }; - } - | { type: "page"; page: EndpointSourcePreview } - | { type: "folder"; folder: EndpointSourcePreview } - | { type: "scans"; collectible: EndpointSourcePreview } - | { type: "gallery"; collectible: EndpointSourcePreview }; - -export type EndpointMediaPreview = { - id: string; - url: string; - filename: string; - mimeType: string; - attributes: EndpointAttribute[]; - translations: { - language: string; - pretitle?: string; - title: string; - subtitle?: string; - }[]; -}; - -export type EndpointMedia = Omit & { - filesize: number; - updatedAt: string; - createdAt: string; - translations: (EndpointMediaPreview["translations"][number] & { - description?: RichTextContent; - })[]; - credits: EndpointCredit[]; -}; - -export type EndpointImagePreview = EndpointMediaPreview & { - width: number; - height: number; - sizes: PayloadImage[]; - openGraph?: PayloadImage; -}; - -export type EndpointImage = EndpointMedia & { - width: number; - height: number; - sizes: PayloadImage[]; - openGraph?: PayloadImage; -}; - -export type EndpointAudioPreview = EndpointMediaPreview & { - thumbnail?: EndpointPayloadImage; - duration: number; -}; - -export type EndpointAudio = EndpointMedia & { - thumbnail?: EndpointPayloadImage; - duration: number; -}; - -export type EndpointVideoPreview = EndpointMediaPreview & { - thumbnail?: EndpointPayloadImage; - subtitles: { - language: string; - url: string; - }[]; - duration: number; -}; - -export type EndpointVideo = EndpointMedia & { - thumbnail?: EndpointPayloadImage; - subtitles: { - language: string; - url: string; - }[]; - platform?: { - channel: { - url: string; - title: string; - subscribers: number; - }; - views?: number; - likes?: number; - dislikes?: number; - url: string; - publishedDate: string; - }; - duration: number; -}; - -export type EndpointFilePreview = EndpointMediaPreview & { - filesize: number; - thumbnail?: EndpointPayloadImage; -}; - -export type EndpointFile = EndpointMedia & { - filesize: number; - thumbnail?: EndpointPayloadImage; -}; - -export type EndpointPayloadImage = PayloadImage & { - sizes: PayloadImage[]; - openGraph?: PayloadImage; -}; - -export type PayloadMedia = { - id: string; - url: string; - mimeType: string; - filename: string; - filesize: number; -}; - -export type PayloadImage = PayloadMedia & { - width: number; - height: number; -}; - -export type EndpointAllSDKUrls = { - urls: string[]; -}; - -export type EndpointAllIds = { - collectibles: { slugs: string[] }; - pages: { slugs: string[] }; - folders: { slugs: string[] }; - videos: { ids: string[] }; - audios: { ids: string[] }; - images: { ids: string[] }; - files: { ids: string[] }; - recorders: { ids: string[] }; - chronologyEvents: { ids: string[] }; -}; - -// SDK - -export const getSDKEndpoint = { - getConfigEndpoint: () => `/globals/${Collections.WebsiteConfig}/config`, - getFolderEndpoint: (slug: string) => `/${Collections.Folders}/slug/${slug}`, - getLanguagesEndpoint: () => `/${Collections.Languages}/all`, - getCurrenciesEndpoint: () => `/${Collections.Currencies}/all`, - getWordingsEndpoint: () => `/${Collections.Wordings}/all`, - getPageEndpoint: (slug: string) => `/${Collections.Pages}/slug/${slug}`, - getCollectibleEndpoint: (slug: string) => `/${Collections.Collectibles}/slug/${slug}`, - getCollectibleScansEndpoint: (slug: string) => `/${Collections.Collectibles}/slug/${slug}/scans`, - getCollectibleScanPageEndpoint: (slug: string, index: string) => - `/${Collections.Collectibles}/slug/${slug}/scans/${index}`, - getCollectibleGalleryEndpoint: (slug: string) => - `/${Collections.Collectibles}/slug/${slug}/gallery`, - getCollectibleGalleryImageEndpoint: (slug: string, index: string) => - `/${Collections.Collectibles}/slug/${slug}/gallery/${index}`, - getChronologyEventsEndpoint: () => `/${Collections.ChronologyEvents}/all`, - getChronologyEventByIDEndpoint: (id: string) => `/${Collections.ChronologyEvents}/id/${id}`, - getImageByIDEndpoint: (id: string) => `/${Collections.Images}/id/${id}`, - getAudioByIDEndpoint: (id: string) => `/${Collections.Audios}/id/${id}`, - getVideoByIDEndpoint: (id: string) => `/${Collections.Videos}/id/${id}`, - getFileByIDEndpoint: (id: string) => `/${Collections.Files}/id/${id}`, - getRecorderByIDEndpoint: (id: string) => `/${Collections.Recorders}/id/${id}`, - getAllSDKUrlsEndpoint: () => `/all-sdk-urls`, - getAllIds: () => `/all-ids`, - getLoginEndpoint: () => `/${Collections.Recorders}/login`, -}; - -type PayloadSDKResponse = { - data: T; - endpointCalled: string; -}; - -type PayloadTokenCache = { - set: (token: string, expirationTimestamp: number) => void; - get: () => string | undefined; -}; - -type PayloadDataCache = { - set: (url: string, response: any) => void; - get: (url: string) => any | undefined; -}; - -export class PayloadSDK { - private tokenCache: PayloadTokenCache | undefined; - private dataCache: PayloadDataCache | undefined; - - constructor( - private readonly apiURL: string, - private readonly email: string, - private readonly password: string - ) {} - - addTokenCache(tokenCache: PayloadTokenCache) { - this.tokenCache = tokenCache; - } - - addDataCache(dataCache: PayloadDataCache) { - this.dataCache = dataCache; - } - - private logResponse(res: Response) { - console.log(res.status, res.statusText, res.url); - } - - private async refreshToken() { - const loginUrl = `${this.apiURL}${getSDKEndpoint.getLoginEndpoint()}`; - const loginResult = await fetch(loginUrl, { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ email: this.email, password: this.password }), - }); - this.logResponse(loginResult); - - if (loginResult.status !== 200) { - throw new Error("Unable to login"); - } - - const { token, exp } = (await loginResult.json()) as { - token: string; - exp: number; - }; - this.tokenCache?.set(token, exp); - return token; - } - - async request(endpoint: string): Promise> { - const cachedResponse = this.dataCache?.get(endpoint); - if (cachedResponse) { - return cachedResponse; - } - - const result = await fetch(`${this.apiURL}${endpoint}`, { - headers: { - Authorization: `JWT ${this.tokenCache?.get() ?? (await this.refreshToken())}`, - }, - }); - this.logResponse(result); - - if (!result.ok) { - throw new Error("Unhandled fetch error"); - } - - const response = { data: await result.json(), endpointCalled: endpoint }; - this.dataCache?.set(endpoint, response); - return response; - } - - async getConfig(): Promise> { - return await this.request(getSDKEndpoint.getConfigEndpoint()); - } - async getFolder(slug: string): Promise> { - return await this.request(getSDKEndpoint.getFolderEndpoint(slug)); - } - async getLanguages(): Promise> { - return await this.request(getSDKEndpoint.getLanguagesEndpoint()); - } - async getCurrencies(): Promise> { - return await this.request(getSDKEndpoint.getCurrenciesEndpoint()); - } - async getWordings(): Promise> { - return await this.request(getSDKEndpoint.getWordingsEndpoint()); - } - async getPage(slug: string): Promise> { - return await this.request(getSDKEndpoint.getPageEndpoint(slug)); - } - async getCollectible(slug: string): Promise> { - return await this.request(getSDKEndpoint.getCollectibleEndpoint(slug)); - } - async getCollectibleScans(slug: string): Promise> { - return await this.request(getSDKEndpoint.getCollectibleScansEndpoint(slug)); - } - async getCollectibleScanPage( - slug: string, - index: string - ): Promise> { - return await this.request(getSDKEndpoint.getCollectibleScanPageEndpoint(slug, index)); - } - async getCollectibleGallery( - slug: string - ): Promise> { - return await this.request(getSDKEndpoint.getCollectibleGalleryEndpoint(slug)); - } - async getCollectibleGalleryImage( - slug: string, - index: string - ): Promise> { - return await this.request(getSDKEndpoint.getCollectibleGalleryImageEndpoint(slug, index)); - } - async getChronologyEvents(): Promise> { - return await this.request(getSDKEndpoint.getChronologyEventsEndpoint()); - } - async getChronologyEventByID(id: string): Promise> { - return await this.request(getSDKEndpoint.getChronologyEventByIDEndpoint(id)); - } - async getImageByID(id: string): Promise> { - return await this.request(getSDKEndpoint.getImageByIDEndpoint(id)); - } - async getAudioByID(id: string): Promise> { - return await this.request(getSDKEndpoint.getAudioByIDEndpoint(id)); - } - async getVideoByID(id: string): Promise> { - return await this.request(getSDKEndpoint.getVideoByIDEndpoint(id)); - } - async getFileByID(id: string): Promise> { - return await this.request(getSDKEndpoint.getFileByIDEndpoint(id)); - } - async getRecorderByID(id: string): Promise> { - return await this.request(getSDKEndpoint.getRecorderByIDEndpoint(id)); - } - async getAllSdkUrls(): Promise> { - return await this.request(getSDKEndpoint.getAllSDKUrlsEndpoint()); - } - async getAllIds(): Promise> { - return await this.request(getSDKEndpoint.getAllIds()); - } -} diff --git a/src/server.ts b/src/server.ts index d837d40..8e62b82 100644 --- a/src/server.ts +++ b/src/server.ts @@ -1,10 +1,8 @@ import "dotenv/config"; import express from "express"; -import { readFileSync } from "fs"; -import path from "path"; import payload from "payload"; -import { Collections, RecordersRoles } from "./constants"; -import { isDefined, isUndefined } from "./utils/asserts"; +import { Collections, RecordersRoles } from "src/shared/payload/constants"; +import { isUndefined, isDefined } from "src/utils/asserts"; const app = express(); @@ -55,36 +53,6 @@ const start = async () => { }, }); - // Add your own express routes here - app.use("/public", express.static(path.join(__dirname, "../public"))); - - app.get("/api/sdk", (_, res) => { - const removeMockingSection = (text: string): string => { - const lines = text.split("\n"); - const endMockingLine = lines.findIndex((line) => line === "// END MOCKING SECTION") ?? 0; - return lines.slice(endMockingLine + 1).join("\n"); - }; - - const removeDeclare = (text: string): string => { - const lines = text.split("\n"); - const startDeclareLine = lines.findIndex((line) => line.startsWith("declare module")) ?? 0; - return lines.slice(0, startDeclareLine).join("\n"); - }; - - const result = []; - - result.push(removeDeclare(readFileSync(path.join(__dirname, "types/collections.ts"), "utf-8"))); - - result.push("/////////////// CONSTANTS ///////////////"); - result.push(removeMockingSection(readFileSync(path.join(__dirname, "constants.ts"), "utf-8"))); - - result.push("////////////////// SDK //////////////////"); - result.push(removeMockingSection(readFileSync(path.join(__dirname, "sdk.ts"), "utf-8"))); - - res.type("text/plain"); - res.send(result.join("\n\n")); - }); - app.get("/robots.txt", (_, res) => { res.type("text/plain"); res.send("User-agent: *\nDisallow: /"); diff --git a/src/utils/asserts.ts b/src/utils/asserts.ts index 7e5c564..bee2bed 100644 --- a/src/utils/asserts.ts +++ b/src/utils/asserts.ts @@ -1,6 +1,7 @@ -import { RichTextContent, isNodeParagraphNode } from "../constants"; -import { PayloadImage, PayloadMedia } from "../sdk"; -import { Audio, File, Image, MediaThumbnail, Scan, Video } from "../types/collections"; +import { PayloadImage, PayloadMedia } from "src/shared/payload/endpoint-types"; +import { RichTextContent, isNodeParagraphNode } from "src/shared/payload/rich-text"; +import { Scan, MediaThumbnail, Video, Image, Audio } from "src/types/collections"; +import { File } from "src/types/collections"; export const isDefined = (value: T | null | undefined): value is T => value !== null && value !== undefined; diff --git a/src/utils/collectionConfig.ts b/src/utils/collectionConfig.ts index 4180246..ded8ada 100644 --- a/src/utils/collectionConfig.ts +++ b/src/utils/collectionConfig.ts @@ -1,7 +1,7 @@ import { GeneratedTypes } from "payload"; import { CollectionConfig } from "payload/types"; -import { afterDeleteWebhook, collectionAfterChangeWebhook } from "../hooks/afterOperationWebhook"; -import { formatToPascalCase } from "./string"; +import { collectionAfterChangeWebhook, afterDeleteWebhook } from "src/hooks/afterOperationWebhook"; +import { formatToPascalCase } from "src/utils/string"; type CollectionConfigWithPlugins = CollectionConfig; diff --git a/src/utils/endpoints.ts b/src/utils/endpoints.ts index db90e15..99db38e 100644 --- a/src/utils/endpoints.ts +++ b/src/utils/endpoints.ts @@ -1,60 +1,60 @@ -import { convertAudioToEndpointAudioPreview } from "../collections/Audios/endpoints/getByID"; -import { convertImageToEndpointImagePreview } from "../collections/Images/endpoints/getByID"; -import { convertRecorderToEndpointRecorderPreview } from "../collections/Recorders/endpoints/getByID"; -import { convertVideoToEndpointVideoPreview } from "../collections/Videos/endpoints/getByID"; +import { convertAudioToEndpointAudioPreview } from "src/collections/Audios/endpoints/getByID"; +import { convertImageToEndpointImagePreview } from "src/collections/Images/endpoints/getByID"; +import { convertRecorderToEndpointRecorderPreview } from "src/collections/Recorders/endpoints/getByID"; +import { convertVideoToEndpointVideoPreview } from "src/collections/Videos/endpoints/getByID"; +import { AttributeTypes } from "src/shared/payload/constants"; import { - AttributeTypes, - RichTextBreakBlock, - RichTextContent, - RichTextSectionBlock, - RichTextUploadNode, - isBlockNodeBreakBlock, - isBlockNodeSectionBlock, - isNodeBlockNode, - isNodeUploadNode, - isUploadNodeAudioNode, - isUploadNodeImageNode, - isUploadNodeVideoNode, -} from "../constants"; -import { - EndpointAttribute, - EndpointCredit, - EndpointPayloadImage, - EndpointRole, - EndpointScanImage, + EndpointTag, EndpointSource, EndpointSourcePreview, - EndpointTag, + EndpointRole, + EndpointCredit, + EndpointAttribute, PayloadImage, -} from "../sdk"; + EndpointScanImage, + EndpointPayloadImage, +} from "src/shared/payload/endpoint-types"; +import { + RichTextContent, + isNodeBlockNode, + isBlockNodeSectionBlock, + RichTextSectionBlock, + isBlockNodeBreakBlock, + RichTextBreakBlock, + isNodeUploadNode, + RichTextUploadNode, + isUploadNodeImageNode, + isUploadNodeAudioNode, + isUploadNodeVideoNode, +} from "src/shared/payload/rich-text"; import { - Audio, - Collectible, - Credits, - CreditsRole, - Folder, Image, - Language, - MediaThumbnail, - NumberBlock, - Scan, - Tag, - TagsBlock, - TextBlock, + Audio, Video, -} from "../types/collections"; + Collectible, + Folder, + Language, + CreditsRole, + Credits, + TagsBlock, + NumberBlock, + TextBlock, + Scan, + MediaThumbnail, + Tag, +} from "src/types/collections"; import { - isAudio, - isDefined, - isEmpty, + isPayloadType, isImage, + isAudio, + isVideo, isNotEmpty, isPayloadArrayType, - isPayloadImage, - isPayloadType, isPublished, - isVideo, -} from "./asserts"; + isDefined, + isEmpty, + isPayloadImage, +} from "src/utils/asserts"; const convertTagToEndpointTag = ({ id, slug, page, translations }: Tag): EndpointTag => ({ id, diff --git a/src/utils/imageCollectionConfig.ts b/src/utils/imageCollectionConfig.ts index d668073..1ea7e48 100644 --- a/src/utils/imageCollectionConfig.ts +++ b/src/utils/imageCollectionConfig.ts @@ -1,8 +1,8 @@ import { ImageSize } from "payload/dist/uploads/types"; import { CollectionConfig } from "payload/types"; -import { publicAccess } from "../accesses/publicAccess"; -import { CollectionGroups } from "../constants"; -import { BuildCollectionConfig, buildCollectionConfig } from "./collectionConfig"; +import { publicAccess } from "src/accesses/publicAccess"; +import { CollectionGroups } from "src/shared/payload/constants"; +import { BuildCollectionConfig, buildCollectionConfig } from "src/utils/collectionConfig"; const fields = { filename: "filename", diff --git a/src/utils/localApi.ts b/src/utils/localApi.ts index 15a8aeb..af4c2c4 100644 --- a/src/utils/localApi.ts +++ b/src/utils/localApi.ts @@ -1,6 +1,6 @@ import payload, { GeneratedTypes } from "payload"; -import { StrapiImage } from "../types/strapi"; -import { isDefined } from "./asserts"; +import { StrapiImage } from "src/types/strapi"; +import { isDefined } from "src/utils/asserts"; type UploadStrapiImage = { image: StrapiImage; diff --git a/src/utils/string.ts b/src/utils/string.ts index 07b6ef9..1f0f00f 100644 --- a/src/utils/string.ts +++ b/src/utils/string.ts @@ -1,6 +1,6 @@ import tags from "language-tags"; -import { RichTextContent } from "../constants"; -import { isUndefined } from "./asserts"; +import { RichTextContent } from "src/shared/payload/rich-text"; +import { isUndefined } from "src/utils/asserts"; export const shortenEllipsis = (text: string, length: number): string => text.length - 3 > length ? `${text.substring(0, length)}...` : text; diff --git a/src/utils/versionedCollectionConfig.ts b/src/utils/versionedCollectionConfig.ts index 787aca8..b8afc15 100644 --- a/src/utils/versionedCollectionConfig.ts +++ b/src/utils/versionedCollectionConfig.ts @@ -1,6 +1,6 @@ import { CollectionBeforeChangeHook, CollectionConfig, RelationshipField } from "payload/types"; -import { Collections } from "../constants"; -import { BuildCollectionConfig, buildCollectionConfig } from "./collectionConfig"; +import { Collections } from "src/shared/payload/constants"; +import { BuildCollectionConfig, buildCollectionConfig } from "src/utils/collectionConfig"; const fields = { updatedBy: "updatedBy" }; diff --git a/tsconfig.json b/tsconfig.json index 3c01533..5f3eeed 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -32,7 +32,7 @@ "module": "commonjs" /* Specify what module code is generated. */, "rootDir": "./src" /* Specify the root folder within your source files. */, // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ - // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ + "baseUrl": "." /* Specify the base directory to resolve non-relative module names. */, "paths": { "payload/generated-types": ["./src/payload-types.ts"] } /* Specify a set of entries that re-map imports to additional lookup locations. */, @@ -116,6 +116,7 @@ "exclude": ["node_modules", "dist", "build"], "ts-node": { "transpileOnly": true, - "swc": true + "swc": true, + "require": ["tsconfig-paths/register"] } }