Try migrating to absolute path but payload sucks
This commit is contained in:
parent
d52febb766
commit
6c021fdc94
|
@ -0,0 +1,3 @@
|
||||||
|
[submodule "src/shared"]
|
||||||
|
path = src/shared
|
||||||
|
url = https://github.com/Accords-Library/shared-library.git
|
|
@ -1,9 +1,11 @@
|
||||||
{
|
{
|
||||||
"css.lint.unknownAtRules": "ignore",
|
|
||||||
"editor.rulers": [100],
|
"editor.rulers": [100],
|
||||||
|
"editor.tabSize": 2,
|
||||||
"typescript.preferences.importModuleSpecifier": "non-relative",
|
"typescript.preferences.importModuleSpecifier": "non-relative",
|
||||||
"editor.codeActionsOnSave": {
|
"explorer.fileNesting.enabled": true,
|
||||||
"source.fixAll": "explicit",
|
"explorer.fileNesting.patterns": {
|
||||||
"source.organizeImports": "explicit"
|
"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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,8 @@
|
||||||
"prettier": "3.3.2",
|
"prettier": "3.3.2",
|
||||||
"ts-node": "10.9.2",
|
"ts-node": "10.9.2",
|
||||||
"ts-unused-exports": "10.1.0",
|
"ts-unused-exports": "10.1.0",
|
||||||
|
"tsconfig-paths": "^4.2.0",
|
||||||
|
"tsconfig-paths-webpack-plugin": "^4.1.0",
|
||||||
"typescript": "5.4.5"
|
"typescript": "5.4.5"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -12032,19 +12034,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/tsconfig-paths": {
|
"node_modules/ts-unused-exports/node_modules/json5": {
|
||||||
"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": {
|
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz",
|
||||||
"integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==",
|
"integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==",
|
||||||
|
@ -12056,6 +12046,46 @@
|
||||||
"json5": "lib/cli.js"
|
"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": {
|
"node_modules/tslib": {
|
||||||
"version": "2.6.2",
|
"version": "2.6.2",
|
||||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz",
|
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz",
|
||||||
|
|
|
@ -12,10 +12,11 @@
|
||||||
"serve": "cross-env PAYLOAD_CONFIG_PATH=dist/payload.config.js NODE_ENV=production node dist/server.js",
|
"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/",
|
"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",
|
"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",
|
"prettier": "prettier --list-different --end-of-line auto --write src",
|
||||||
"tsc": "tsc --noEmit",
|
"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",
|
"upgrade": "ncu",
|
||||||
"prod": "rm -rf build && rm -rf dist && npm ci && npm run precommit && npm run build && npm run serve"
|
"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",
|
"prettier": "3.3.2",
|
||||||
"ts-node": "10.9.2",
|
"ts-node": "10.9.2",
|
||||||
"ts-unused-exports": "10.1.0",
|
"ts-unused-exports": "10.1.0",
|
||||||
|
"tsconfig-paths": "^4.2.0",
|
||||||
|
"tsconfig-paths-webpack-plugin": "^4.1.0",
|
||||||
"typescript": "5.4.5"
|
"typescript": "5.4.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Access } from "payload/config";
|
import { Access } from "payload/config";
|
||||||
import { RecordersRoles } from "../../constants";
|
import { RecordersRoles } from "src/shared/payload/constants";
|
||||||
import { Recorder } from "../../types/collections";
|
import { Recorder } from "src/types/collections";
|
||||||
import { isDefined, isUndefined } from "../../utils/asserts";
|
import { isUndefined, isDefined } from "src/utils/asserts";
|
||||||
|
|
||||||
export const mustBeAdmin: Access<unknown, Recorder> = ({ req: { user } }): boolean => {
|
export const mustBeAdmin: Access<unknown, Recorder> = ({ req: { user } }): boolean => {
|
||||||
if (isUndefined(user)) return false;
|
if (isUndefined(user)) return false;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Access } from "payload/config";
|
import { Access } from "payload/config";
|
||||||
import { RecordersRoles } from "../../constants";
|
import { RecordersRoles } from "src/shared/payload/constants";
|
||||||
import { Recorder } from "../../types/collections";
|
import { Recorder } from "src/types/collections";
|
||||||
import { isUndefined } from "../../utils/asserts";
|
import { isUndefined } from "src/utils/asserts";
|
||||||
|
|
||||||
export const mustBeAdminOrSelf: Access<unknown, Recorder> = ({ req: { user } }) => {
|
export const mustBeAdminOrSelf: Access<unknown, Recorder> = ({ req: { user } }) => {
|
||||||
if (isUndefined(user)) return false;
|
if (isUndefined(user)) return false;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { User } from "payload/auth";
|
import { User } from "payload/auth";
|
||||||
import { RecordersRoles } from "../../constants";
|
import { RecordersRoles } from "src/shared/payload/constants";
|
||||||
import { Recorder } from "../../types/collections";
|
import { Recorder } from "src/types/collections";
|
||||||
import { isDefined, isUndefined } from "../../utils/asserts";
|
import { isUndefined, isDefined } from "src/utils/asserts";
|
||||||
|
|
||||||
export const shownOnlyToAdmin = ({ user }: { user: User }): boolean => {
|
export const shownOnlyToAdmin = ({ user }: { user: User }): boolean => {
|
||||||
if (isUndefined(user)) return false;
|
if (isUndefined(user)) return false;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { FieldAccess } from "payload/types";
|
import { FieldAccess } from "payload/types";
|
||||||
import { RecordersRoles } from "../../constants";
|
import { RecordersRoles } from "src/shared/payload/constants";
|
||||||
import { Recorder } from "../../types/collections";
|
import { Recorder } from "src/types/collections";
|
||||||
import { isDefined, isUndefined } from "../../utils/asserts";
|
import { isUndefined, isDefined } from "src/utils/asserts";
|
||||||
|
|
||||||
export const mustBeAdmin: FieldAccess<any, any, Recorder> = ({ req: { user } }): boolean => {
|
export const mustBeAdmin: FieldAccess<any, any, Recorder> = ({ req: { user } }): boolean => {
|
||||||
if (isUndefined(user)) return false;
|
if (isUndefined(user)) return false;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Block } from "payload/types";
|
import { Block } from "payload/types";
|
||||||
import { AttributeTypes, Collections } from "../../constants";
|
import { rowField } from "src/fields/rowField/rowField";
|
||||||
import { rowField } from "../../fields/rowField/rowField";
|
import { Collections, AttributeTypes } from "src/shared/payload/constants";
|
||||||
|
|
||||||
export const numberBlock: Block = {
|
export const numberBlock: Block = {
|
||||||
slug: "numberBlock",
|
slug: "numberBlock",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Block } from "payload/types";
|
import { Block } from "payload/types";
|
||||||
import { AttributeTypes, Collections } from "../../constants";
|
import { rowField } from "src/fields/rowField/rowField";
|
||||||
import { rowField } from "../../fields/rowField/rowField";
|
import { Collections, AttributeTypes } from "src/shared/payload/constants";
|
||||||
|
|
||||||
export const tagsBlock: Block = {
|
export const tagsBlock: Block = {
|
||||||
slug: "tagsBlock",
|
slug: "tagsBlock",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Block } from "payload/types";
|
import { Block } from "payload/types";
|
||||||
import { AttributeTypes, Collections } from "../../constants";
|
import { rowField } from "src/fields/rowField/rowField";
|
||||||
import { rowField } from "../../fields/rowField/rowField";
|
import { Collections, AttributeTypes } from "src/shared/payload/constants";
|
||||||
|
|
||||||
export const textBlock: Block = {
|
export const textBlock: Block = {
|
||||||
slug: "textBlock",
|
slug: "textBlock",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Block } from "payload/types";
|
import { Block } from "payload/types";
|
||||||
import { BreakBlockType } from "../constants";
|
import { BreakBlockType } from "src/shared/payload/constants";
|
||||||
|
|
||||||
export const breakBlock: Block = {
|
export const breakBlock: Block = {
|
||||||
slug: "breakBlock",
|
slug: "breakBlock",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Block } from "payload/types";
|
import { Block } from "payload/types";
|
||||||
import { createEditor } from "../utils/editor";
|
import { createEditor } from "src/utils/editor";
|
||||||
|
|
||||||
export const cueBlock: Block = {
|
export const cueBlock: Block = {
|
||||||
slug: "cueBlock",
|
slug: "cueBlock",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Block } from "payload/types";
|
import { Block } from "payload/types";
|
||||||
import { createEditor } from "../utils/editor";
|
import { createEditor } from "src/utils/editor";
|
||||||
|
|
||||||
export const lineBlock: Block = {
|
export const lineBlock: Block = {
|
||||||
slug: "lineBlock",
|
slug: "lineBlock",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Block } from "payload/types";
|
import { Block } from "payload/types";
|
||||||
import { createEditor } from "../utils/editor";
|
import { breakBlock } from "src/blocks/breakBlock";
|
||||||
import { breakBlock } from "./breakBlock";
|
import { transcriptBlock } from "src/blocks/transcriptBlock";
|
||||||
import { transcriptBlock } from "./transcriptBlock";
|
import { createEditor } from "src/utils/editor";
|
||||||
|
|
||||||
const generateRecursiveSectionBlock = (depth = 1, maxDepth = 5): Block => ({
|
const generateRecursiveSectionBlock = (depth = 1, maxDepth = 5): Block => ({
|
||||||
slug: "sectionBlock",
|
slug: "sectionBlock",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Block } from "payload/types";
|
import { Block } from "payload/types";
|
||||||
import { cueBlock } from "./cueBlock";
|
import { cueBlock } from "src/blocks/cueBlock";
|
||||||
import { lineBlock } from "./lineBlock";
|
import { lineBlock } from "src/blocks/lineBlock";
|
||||||
|
|
||||||
export const transcriptBlock: Block = {
|
export const transcriptBlock: Block = {
|
||||||
slug: "transcriptBlock",
|
slug: "transcriptBlock",
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { CollectionConfig } from "payload/types";
|
import { CollectionConfig } from "payload/types";
|
||||||
import { mustBeAdmin } from "../../accesses/fields/mustBeAdmin";
|
import { mustBeAdmin } from "src/accesses/fields/mustBeAdmin";
|
||||||
import { AttributeTypes, CollectionGroups, Collections } from "../../constants";
|
import { iconField } from "src/fields/iconField/iconField";
|
||||||
import { iconField } from "../../fields/iconField/iconField";
|
import { rowField } from "src/fields/rowField/rowField";
|
||||||
import { rowField } from "../../fields/rowField/rowField";
|
import { slugField } from "src/fields/slugField/slugField";
|
||||||
import { slugField } from "../../fields/slugField/slugField";
|
import { translatedFields } from "src/fields/translatedFields/translatedFields";
|
||||||
import { translatedFields } from "../../fields/translatedFields/translatedFields";
|
import { Collections, CollectionGroups, AttributeTypes } from "src/shared/payload/constants";
|
||||||
import { buildCollectionConfig } from "../../utils/collectionConfig";
|
import { buildCollectionConfig } from "src/utils/collectionConfig";
|
||||||
|
|
||||||
const fields = {
|
const fields = {
|
||||||
slug: "slug",
|
slug: "slug",
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { CollectionGroups, Collections } from "../../constants";
|
import { attributesField } from "src/fields/attributesField/attributesField";
|
||||||
import { attributesField } from "../../fields/attributesField/attributesField";
|
import { creditsField } from "src/fields/creditsField/creditsField";
|
||||||
import { creditsField } from "../../fields/creditsField/creditsField";
|
import { imageField } from "src/fields/imageField/imageField";
|
||||||
import { imageField } from "../../fields/imageField/imageField";
|
import { rowField } from "src/fields/rowField/rowField";
|
||||||
import { rowField } from "../../fields/rowField/rowField";
|
import { translatedFields } from "src/fields/translatedFields/translatedFields";
|
||||||
import { translatedFields } from "../../fields/translatedFields/translatedFields";
|
import { Collections, CollectionGroups } from "src/shared/payload/constants";
|
||||||
import { buildCollectionConfig } from "../../utils/collectionConfig";
|
import { buildCollectionConfig } from "src/utils/collectionConfig";
|
||||||
import { createEditor } from "../../utils/editor";
|
import { createEditor } from "src/utils/editor";
|
||||||
import { getByID } from "./endpoints/getByID";
|
import { getByID } from "./endpoints/getByID";
|
||||||
|
|
||||||
const fields = {
|
const fields = {
|
||||||
|
|
|
@ -1,16 +1,20 @@
|
||||||
import payload from "payload";
|
import payload from "payload";
|
||||||
import { Collections } from "../../../constants";
|
import { Collections } from "src/shared/payload/constants";
|
||||||
import { EndpointAudio, EndpointAudioPreview, PayloadMedia } from "../../../sdk";
|
import {
|
||||||
import { Audio } from "../../../types/collections";
|
PayloadMedia,
|
||||||
import { CollectionEndpoint } from "../../../types/payload";
|
EndpointAudioPreview,
|
||||||
import { isAudio, isMediaThumbnail, isNotEmpty } from "../../../utils/asserts";
|
EndpointAudio,
|
||||||
|
} from "src/shared/payload/endpoint-types";
|
||||||
|
import { CollectionEndpoint } from "src/types/payload";
|
||||||
|
import { isAudio, isNotEmpty, isMediaThumbnail } from "src/utils/asserts";
|
||||||
import {
|
import {
|
||||||
convertAttributesToEndpointAttributes,
|
convertAttributesToEndpointAttributes,
|
||||||
convertCreditsToEndpointCredits,
|
getLanguageId,
|
||||||
convertMediaThumbnailToEndpointPayloadImage,
|
convertMediaThumbnailToEndpointPayloadImage,
|
||||||
convertRTCToEndpointRTC,
|
convertRTCToEndpointRTC,
|
||||||
getLanguageId,
|
convertCreditsToEndpointCredits,
|
||||||
} from "../../../utils/endpoints";
|
} from "src/utils/endpoints";
|
||||||
|
import { Audio } from "src/types/collections";
|
||||||
|
|
||||||
export const getByID: CollectionEndpoint = {
|
export const getByID: CollectionEndpoint = {
|
||||||
method: "get",
|
method: "get",
|
||||||
|
|
|
@ -1,15 +1,4 @@
|
||||||
import { CollectionConfig } from "payload/types";
|
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 { collectibleBlock } from "./blocks/collectibleBlock";
|
||||||
import { pageBlock } from "./blocks/contentBlock";
|
import { pageBlock } from "./blocks/contentBlock";
|
||||||
import { urlBlock } from "./blocks/urlBlock";
|
import { urlBlock } from "./blocks/urlBlock";
|
||||||
|
@ -20,6 +9,17 @@ import { beforeValidatePopulateNameField } from "./hooks/beforeValidatePopulateN
|
||||||
import { validateDate } from "./validations/validateDate";
|
import { validateDate } from "./validations/validateDate";
|
||||||
import { validateEventsTranslationsDescription } from "./validations/validateEventsTranslationsDescription";
|
import { validateEventsTranslationsDescription } from "./validations/validateEventsTranslationsDescription";
|
||||||
import { validateEventsTranslationsTitle } from "./validations/validateEventsTranslationsTitle";
|
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 = {
|
const fields = {
|
||||||
name: "name",
|
name: "name",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Block } from "payload/types";
|
import { Block } from "payload/types";
|
||||||
import { Collections } from "../../../constants";
|
import { translatedFields } from "src/fields/translatedFields/translatedFields";
|
||||||
import { translatedFields } from "../../../fields/translatedFields/translatedFields";
|
import { Collections } from "src/shared/payload/constants";
|
||||||
|
|
||||||
export const collectibleBlock: Block = {
|
export const collectibleBlock: Block = {
|
||||||
slug: "collectibleBlock",
|
slug: "collectibleBlock",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Block } from "payload/types";
|
import { Block } from "payload/types";
|
||||||
import { Collections } from "../../../constants";
|
import { Collections } from "src/shared/payload/constants";
|
||||||
|
|
||||||
export const pageBlock: Block = {
|
export const pageBlock: Block = {
|
||||||
slug: "pageBlock",
|
slug: "pageBlock",
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import payload from "payload";
|
import payload from "payload";
|
||||||
import { Collections } from "../../../constants";
|
import { convertCollectibleToEndpointCollectiblePreview } from "src/collections/Collectibles/endpoints/getBySlugEndpoint";
|
||||||
import { EndpointChronologyEvent, EndpointSource } from "../../../sdk";
|
import { convertPageToEndpointPagePreview } from "src/collections/Pages/endpoints/getBySlugEndpoint";
|
||||||
import { ChronologyEvent, CollectibleBlock } from "../../../types/collections";
|
import { Collections } from "src/shared/payload/constants";
|
||||||
import { CollectionEndpoint } from "../../../types/payload";
|
import { EndpointChronologyEvent, EndpointSource } from "src/shared/payload/endpoint-types";
|
||||||
import { isDefined, isNotEmpty, isPayloadType } from "../../../utils/asserts";
|
import { ChronologyEvent, CollectibleBlock } from "src/types/collections";
|
||||||
import { convertCreditsToEndpointCredits, getDomainFromUrl } from "../../../utils/endpoints";
|
import { CollectionEndpoint } from "src/types/payload";
|
||||||
import { convertCollectibleToEndpointCollectiblePreview } from "../../Collectibles/endpoints/getBySlugEndpoint";
|
import { isDefined, isPayloadType, isNotEmpty } from "src/utils/asserts";
|
||||||
import { convertPageToEndpointPagePreview } from "../../Pages/endpoints/getBySlugEndpoint";
|
import { convertCreditsToEndpointCredits, getDomainFromUrl } from "src/utils/endpoints";
|
||||||
|
|
||||||
export const getAllEndpoint: CollectionEndpoint = {
|
export const getAllEndpoint: CollectionEndpoint = {
|
||||||
method: "get",
|
method: "get",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import payload from "payload";
|
import payload from "payload";
|
||||||
import { Collections } from "../../../constants";
|
|
||||||
import { CollectionEndpoint } from "../../../types/payload";
|
|
||||||
import { eventToEndpointEvent } from "./getAllEndpoint";
|
import { eventToEndpointEvent } from "./getAllEndpoint";
|
||||||
|
import { Collections } from "src/shared/payload/constants";
|
||||||
|
import { CollectionEndpoint } from "src/types/payload";
|
||||||
|
|
||||||
export const getByID: CollectionEndpoint = {
|
export const getByID: CollectionEndpoint = {
|
||||||
method: "get",
|
method: "get",
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { Collections } from "../../../constants";
|
import { createStrapiImportEndpoint } from "src/endpoints/createStrapiImportEndpoint";
|
||||||
import { createStrapiImportEndpoint } from "../../../endpoints/createStrapiImportEndpoint";
|
import { Collections } from "src/shared/payload/constants";
|
||||||
import { StrapiLanguage } from "../../../types/strapi";
|
import { StrapiLanguage } from "src/types/strapi";
|
||||||
import { isDefined, isUndefined } from "../../../utils/asserts";
|
import { isUndefined, isDefined } from "src/utils/asserts";
|
||||||
import { plainTextToLexical } from "../../../utils/string";
|
import { plainTextToLexical } from "src/utils/string";
|
||||||
|
|
||||||
type StrapiChronologyItem = {
|
type StrapiChronologyItem = {
|
||||||
year: number;
|
year: number;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { FieldHook } from "payload/dist/fields/config/types";
|
import { FieldHook } from "payload/dist/fields/config/types";
|
||||||
import { ChronologyEvent } from "../../../types/collections";
|
import { ChronologyEvent } from "src/types/collections";
|
||||||
import { isDefined, isUndefined } from "../../../utils/asserts";
|
import { isUndefined, isDefined } from "src/utils/asserts";
|
||||||
|
|
||||||
export const beforeValidatePopulateNameField: FieldHook<
|
export const beforeValidatePopulateNameField: FieldHook<
|
||||||
ChronologyEvent,
|
ChronologyEvent,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { DateTime } from "luxon";
|
import { DateTime } from "luxon";
|
||||||
import { Validate } from "payload/types";
|
import { Validate } from "payload/types";
|
||||||
import { ChronologyEvent } from "../../../types/collections";
|
import { ChronologyEvent } from "src/types/collections";
|
||||||
import { isUndefined } from "../../../utils/asserts";
|
import { isUndefined } from "src/utils/asserts";
|
||||||
|
|
||||||
export const validateDate: Validate<ChronologyEvent["date"] | undefined> = (date) => {
|
export const validateDate: Validate<ChronologyEvent["date"] | undefined> = (date) => {
|
||||||
if (isUndefined(date)) return "This field is required.";
|
if (isUndefined(date)) return "This field is required.";
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Validate } from "payload/types";
|
import { Validate } from "payload/types";
|
||||||
import { ChronologyEvent } from "../../../types/collections";
|
import { ChronologyEvent } from "src/types/collections";
|
||||||
import { isEmpty } from "../../../utils/asserts";
|
import { isEmpty } from "src/utils/asserts";
|
||||||
|
|
||||||
export const validateEventsTranslationsDescription: Validate<
|
export const validateEventsTranslationsDescription: Validate<
|
||||||
string | undefined,
|
string | undefined,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Validate } from "payload/types";
|
import { Validate } from "payload/types";
|
||||||
import { ChronologyEvent } from "../../../types/collections";
|
import { ChronologyEvent } from "src/types/collections";
|
||||||
import { isEmpty } from "../../../utils/asserts";
|
import { isEmpty } from "src/utils/asserts";
|
||||||
|
|
||||||
export const validateEventsTranslationsTitle: Validate<
|
export const validateEventsTranslationsTitle: Validate<
|
||||||
string | undefined,
|
string | undefined,
|
||||||
|
|
|
@ -1,33 +1,33 @@
|
||||||
import { RowLabelArgs } from "payload/dist/admin/components/forms/RowLabel/types";
|
import { RowLabelArgs } from "payload/dist/admin/components/forms/RowLabel/types";
|
||||||
import { Where } from "payload/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 { RowLabel } from "./components/RowLabel";
|
||||||
import { getBySlugEndpoint } from "./endpoints/getBySlugEndpoint";
|
import { getBySlugEndpoint } from "./endpoints/getBySlugEndpoint";
|
||||||
import { getBySlugEndpointGallery } from "./endpoints/getBySlugEndpointGallery";
|
import { getBySlugEndpointGallery } from "./endpoints/getBySlugEndpointGallery";
|
||||||
import { getBySlugEndpointGalleryImage } from "./endpoints/getBySlugEndpointGalleryImage";
|
import { getBySlugEndpointGalleryImage } from "./endpoints/getBySlugEndpointGalleryImage";
|
||||||
import { getBySlugEndpointScanPage } from "./endpoints/getBySlugEndpointScanPage";
|
import { getBySlugEndpointScanPage } from "./endpoints/getBySlugEndpointScanPage";
|
||||||
import { getBySlugEndpointScans } from "./endpoints/getBySlugEndpointScans";
|
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 = {
|
const fields = {
|
||||||
status: "_status",
|
status: "_status",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
import { isDefined } from "src/utils/asserts";
|
||||||
import styled from "styled-components";
|
import styled from "styled-components";
|
||||||
import { isDefined } from "../../../utils/asserts";
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
page?: number;
|
page?: number;
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
import { CollectibleNature, Collections } from "../../../constants";
|
import { convertAudioToEndpointAudioPreview } from "src/collections/Audios/endpoints/getByID";
|
||||||
import { createGetByEndpoint } from "../../../endpoints/createGetByEndpoint";
|
import { convertFileToEndpointFilePreview } from "src/collections/Files/endpoints/getByID";
|
||||||
import { EndpointCollectible, EndpointCollectiblePreview } from "../../../sdk";
|
import { convertPageToEndpointPagePreview } from "src/collections/Pages/endpoints/getBySlugEndpoint";
|
||||||
import { Collectible } from "../../../types/collections";
|
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 {
|
import {
|
||||||
isAudio,
|
|
||||||
isDefined,
|
|
||||||
isFile,
|
|
||||||
isImage,
|
isImage,
|
||||||
isNotEmpty,
|
|
||||||
isPayloadArrayType,
|
|
||||||
isPayloadType,
|
isPayloadType,
|
||||||
|
isNotEmpty,
|
||||||
|
isDefined,
|
||||||
|
isPayloadArrayType,
|
||||||
isPublished,
|
isPublished,
|
||||||
|
isFile,
|
||||||
isScan,
|
isScan,
|
||||||
|
isAudio,
|
||||||
isVideo,
|
isVideo,
|
||||||
} from "../../../utils/asserts";
|
} from "src/utils/asserts";
|
||||||
import {
|
import {
|
||||||
convertAttributesToEndpointAttributes,
|
|
||||||
convertImageToEndpointPayloadImage,
|
convertImageToEndpointPayloadImage,
|
||||||
convertScanToEndpointScanImage,
|
convertAttributesToEndpointAttributes,
|
||||||
convertSourceToEndpointSource,
|
|
||||||
getDomainFromUrl,
|
getDomainFromUrl,
|
||||||
} from "../../../utils/endpoints";
|
convertSourceToEndpointSource,
|
||||||
import { convertAudioToEndpointAudioPreview } from "../../Audios/endpoints/getByID";
|
convertScanToEndpointScanImage,
|
||||||
import { convertFileToEndpointFilePreview } from "../../Files/endpoints/getByID";
|
} from "src/utils/endpoints";
|
||||||
import { convertPageToEndpointPagePreview } from "../../Pages/endpoints/getBySlugEndpoint";
|
|
||||||
import { convertRecorderToEndpointRecorderPreview } from "../../Recorders/endpoints/getByID";
|
|
||||||
import { convertVideoToEndpointVideoPreview } from "../../Videos/endpoints/getByID";
|
|
||||||
|
|
||||||
export const getBySlugEndpoint = createGetByEndpoint({
|
export const getBySlugEndpoint = createGetByEndpoint({
|
||||||
collection: Collections.Collectibles,
|
collection: Collections.Collectibles,
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { Collections } from "../../../constants";
|
import { createGetByEndpoint } from "src/endpoints/createGetByEndpoint";
|
||||||
import { createGetByEndpoint } from "../../../endpoints/createGetByEndpoint";
|
import { Collections } from "src/shared/payload/constants";
|
||||||
import { EndpointCollectibleGallery } from "../../../sdk";
|
import { EndpointCollectibleGallery } from "src/shared/payload/endpoint-types";
|
||||||
import { isImage, isNotEmpty, isPayloadType } from "../../../utils/asserts";
|
import { isPayloadType, isNotEmpty, isImage } from "src/utils/asserts";
|
||||||
import {
|
import {
|
||||||
convertImageToEndpointPayloadImage,
|
convertImageToEndpointPayloadImage,
|
||||||
convertSourceToEndpointSource,
|
convertSourceToEndpointSource,
|
||||||
} from "../../../utils/endpoints";
|
} from "src/utils/endpoints";
|
||||||
|
|
||||||
export const getBySlugEndpointGallery = createGetByEndpoint({
|
export const getBySlugEndpointGallery = createGetByEndpoint({
|
||||||
collection: Collections.Collectibles,
|
collection: Collections.Collectibles,
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
import payload from "payload";
|
import payload from "payload";
|
||||||
import { Collections } from "../../../constants";
|
import { convertImageToEndpointImage } from "src/collections/Images/endpoints/getByID";
|
||||||
import { EndpointCollectibleGalleryImage } from "../../../sdk";
|
import { Collections } from "src/shared/payload/constants";
|
||||||
import { Collectible, Image } from "../../../types/collections";
|
import { EndpointCollectibleGalleryImage } from "src/shared/payload/endpoint-types";
|
||||||
import { CollectionEndpoint } from "../../../types/payload";
|
import { Collectible } from "src/types/collections";
|
||||||
import { isDefined, isImage, isNotEmpty, isPayloadType } from "../../../utils/asserts";
|
import { CollectionEndpoint } from "src/types/payload";
|
||||||
import { convertSourceToEndpointSource } from "../../../utils/endpoints";
|
import { isImage, isPayloadType, isNotEmpty, isDefined } from "src/utils/asserts";
|
||||||
import { convertImageToEndpointImage } from "../../Images/endpoints/getByID";
|
import { convertSourceToEndpointSource } from "src/utils/endpoints";
|
||||||
|
import { Image } from "src/types/collections";
|
||||||
|
|
||||||
export const getBySlugEndpointGalleryImage: CollectionEndpoint = {
|
export const getBySlugEndpointGalleryImage: CollectionEndpoint = {
|
||||||
path: "/slug/:slug/gallery/:index",
|
path: "/slug/:slug/gallery/:index",
|
||||||
|
|
|
@ -1,13 +1,10 @@
|
||||||
import payload from "payload";
|
import payload from "payload";
|
||||||
import { Collections } from "../../../constants";
|
import { Collections } from "src/shared/payload/constants";
|
||||||
import { EndpointCollectibleScanPage } from "../../../sdk";
|
import { EndpointCollectibleScanPage } from "src/shared/payload/endpoint-types";
|
||||||
import { Collectible, Scan } from "../../../types/collections";
|
import { Collectible, Scan } from "src/types/collections";
|
||||||
import { CollectionEndpoint } from "../../../types/payload";
|
import { CollectionEndpoint } from "src/types/payload";
|
||||||
import { isDefined, isNotEmpty, isPayloadType, isScan } from "../../../utils/asserts";
|
import { isScan, isPayloadType, isNotEmpty, isDefined } from "src/utils/asserts";
|
||||||
import {
|
import { convertScanToEndpointScanImage, convertSourceToEndpointSource } from "src/utils/endpoints";
|
||||||
convertScanToEndpointScanImage,
|
|
||||||
convertSourceToEndpointSource,
|
|
||||||
} from "../../../utils/endpoints";
|
|
||||||
|
|
||||||
export const getBySlugEndpointScanPage: CollectionEndpoint = {
|
export const getBySlugEndpointScanPage: CollectionEndpoint = {
|
||||||
path: "/slug/:slug/scans/:index",
|
path: "/slug/:slug/scans/:index",
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
import { Collections } from "../../../constants";
|
import { createGetByEndpoint } from "src/endpoints/createGetByEndpoint";
|
||||||
import { createGetByEndpoint } from "../../../endpoints/createGetByEndpoint";
|
import { Collections } from "src/shared/payload/constants";
|
||||||
import { EndpointCollectibleScans } from "../../../sdk";
|
import { EndpointCollectibleScans } from "src/shared/payload/endpoint-types";
|
||||||
import { Collectible } from "../../../types/collections";
|
import { Collectible } from "src/types/collections";
|
||||||
import { isImage, isNotEmpty, isPayloadType, isScan } from "../../../utils/asserts";
|
import { isPayloadType, isNotEmpty, isImage, isScan } from "src/utils/asserts";
|
||||||
import {
|
import {
|
||||||
convertCreditsToEndpointCredits,
|
|
||||||
convertImageToEndpointPayloadImage,
|
convertImageToEndpointPayloadImage,
|
||||||
convertScanToEndpointScanImage,
|
|
||||||
convertSourceToEndpointSource,
|
convertSourceToEndpointSource,
|
||||||
} from "../../../utils/endpoints";
|
convertCreditsToEndpointCredits,
|
||||||
|
convertScanToEndpointScanImage,
|
||||||
|
} from "src/utils/endpoints";
|
||||||
|
|
||||||
export const getBySlugEndpointScans = createGetByEndpoint({
|
export const getBySlugEndpointScans = createGetByEndpoint({
|
||||||
collection: Collections.Collectibles,
|
collection: Collections.Collectibles,
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { CollectionConfig } from "payload/types";
|
import { CollectionConfig } from "payload/types";
|
||||||
import { CollectionGroups, Collections } from "../../constants";
|
import { iconField } from "src/fields/iconField/iconField";
|
||||||
import { iconField } from "../../fields/iconField/iconField";
|
import { slugField } from "src/fields/slugField/slugField";
|
||||||
import { slugField } from "../../fields/slugField/slugField";
|
import { translatedFields } from "src/fields/translatedFields/translatedFields";
|
||||||
import { translatedFields } from "../../fields/translatedFields/translatedFields";
|
import { Collections, CollectionGroups } from "src/shared/payload/constants";
|
||||||
import { buildCollectionConfig } from "../../utils/collectionConfig";
|
import { buildCollectionConfig } from "src/utils/collectionConfig";
|
||||||
|
|
||||||
const fields = {
|
const fields = {
|
||||||
slug: "slug",
|
slug: "slug",
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { text } from "payload/dist/fields/validations";
|
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 { getAllEndpoint } from "./endpoints/getAllEndpoint";
|
||||||
import { importFromStrapi } from "./endpoints/importFromStrapi";
|
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 = {
|
const fields = {
|
||||||
id: "id",
|
id: "id",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import payload from "payload";
|
import payload from "payload";
|
||||||
import { Collections } from "../../../constants";
|
import { Collections } from "src/shared/payload/constants";
|
||||||
import { Currency } from "../../../types/collections";
|
import { Currency } from "src/types/collections";
|
||||||
import { CollectionEndpoint } from "../../../types/payload";
|
import { CollectionEndpoint } from "src/types/payload";
|
||||||
|
|
||||||
export const getAllEndpoint: CollectionEndpoint = {
|
export const getAllEndpoint: CollectionEndpoint = {
|
||||||
method: "get",
|
method: "get",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Collections } from "../../../constants";
|
import { createStrapiImportEndpoint } from "src/endpoints/createStrapiImportEndpoint";
|
||||||
import { createStrapiImportEndpoint } from "../../../endpoints/createStrapiImportEndpoint";
|
import { Collections } from "src/shared/payload/constants";
|
||||||
|
|
||||||
type StrapiLanguage = {
|
type StrapiLanguage = {
|
||||||
code: string;
|
code: string;
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { CollectionGroups, Collections } from "../../constants";
|
import { attributesField } from "src/fields/attributesField/attributesField";
|
||||||
import { attributesField } from "../../fields/attributesField/attributesField";
|
import { creditsField } from "src/fields/creditsField/creditsField";
|
||||||
import { creditsField } from "../../fields/creditsField/creditsField";
|
import { imageField } from "src/fields/imageField/imageField";
|
||||||
import { imageField } from "../../fields/imageField/imageField";
|
import { rowField } from "src/fields/rowField/rowField";
|
||||||
import { rowField } from "../../fields/rowField/rowField";
|
import { translatedFields } from "src/fields/translatedFields/translatedFields";
|
||||||
import { translatedFields } from "../../fields/translatedFields/translatedFields";
|
import { Collections, CollectionGroups } from "src/shared/payload/constants";
|
||||||
import { buildCollectionConfig } from "../../utils/collectionConfig";
|
import { buildCollectionConfig } from "src/utils/collectionConfig";
|
||||||
import { createEditor } from "../../utils/editor";
|
import { createEditor } from "src/utils/editor";
|
||||||
import { getByID } from "./endpoints/getByID";
|
import { getByID } from "./endpoints/getByID";
|
||||||
|
|
||||||
const fields = {
|
const fields = {
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
import payload from "payload";
|
import payload from "payload";
|
||||||
import { Collections } from "../../../constants";
|
import { Collections } from "src/shared/payload/constants";
|
||||||
import { EndpointFile, EndpointFilePreview, PayloadMedia } from "../../../sdk";
|
import { PayloadMedia, EndpointFilePreview, EndpointFile } from "src/shared/payload/endpoint-types";
|
||||||
import { File } from "../../../types/collections";
|
import { CollectionEndpoint } from "src/types/payload";
|
||||||
import { CollectionEndpoint } from "../../../types/payload";
|
import { isFile, isNotEmpty, isMediaThumbnail } from "src/utils/asserts";
|
||||||
import { isFile, isMediaThumbnail, isNotEmpty } from "../../../utils/asserts";
|
|
||||||
import {
|
import {
|
||||||
convertAttributesToEndpointAttributes,
|
convertAttributesToEndpointAttributes,
|
||||||
convertCreditsToEndpointCredits,
|
getLanguageId,
|
||||||
convertMediaThumbnailToEndpointPayloadImage,
|
convertMediaThumbnailToEndpointPayloadImage,
|
||||||
convertRTCToEndpointRTC,
|
convertRTCToEndpointRTC,
|
||||||
getLanguageId,
|
convertCreditsToEndpointCredits,
|
||||||
} from "../../../utils/endpoints";
|
} from "src/utils/endpoints";
|
||||||
|
import { File } from "src/types/collections";
|
||||||
|
|
||||||
export const getByID: CollectionEndpoint = {
|
export const getByID: CollectionEndpoint = {
|
||||||
method: "get",
|
method: "get",
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
import { CollectionGroups, Collections } from "../../constants";
|
import { backPropagationField } from "src/fields/backPropagationField/backPropagationField";
|
||||||
import { backPropagationField } from "../../fields/backPropagationField/backPropagationField";
|
import { iconField } from "src/fields/iconField/iconField";
|
||||||
import { iconField } from "../../fields/iconField/iconField";
|
import { rowField } from "src/fields/rowField/rowField";
|
||||||
import { rowField } from "../../fields/rowField/rowField";
|
import { slugField } from "src/fields/slugField/slugField";
|
||||||
import { slugField } from "../../fields/slugField/slugField";
|
import { translatedFields } from "src/fields/translatedFields/translatedFields";
|
||||||
import { translatedFields } from "../../fields/translatedFields/translatedFields";
|
import { Collections, CollectionGroups } from "src/shared/payload/constants";
|
||||||
import { Folder } from "../../types/collections";
|
import { Folder } from "src/types/collections";
|
||||||
import { isPayloadType } from "../../utils/asserts";
|
import { isPayloadType } from "src/utils/asserts";
|
||||||
import { buildCollectionConfig } from "../../utils/collectionConfig";
|
import { buildCollectionConfig } from "src/utils/collectionConfig";
|
||||||
import { createEditor } from "../../utils/editor";
|
import { createEditor } from "src/utils/editor";
|
||||||
import { getBySlugEndpoint } from "./endpoints/getBySlugEndpoint";
|
import { getBySlugEndpoint } from "./endpoints/getBySlugEndpoint";
|
||||||
|
|
||||||
const fields = {
|
const fields = {
|
||||||
|
|
|
@ -1,24 +1,24 @@
|
||||||
import { Collections } from "../../../constants";
|
import { convertAudioToEndpointAudioPreview } from "src/collections/Audios/endpoints/getByID";
|
||||||
import { createGetByEndpoint } from "../../../endpoints/createGetByEndpoint";
|
import { convertCollectibleToEndpointCollectiblePreview } from "src/collections/Collectibles/endpoints/getBySlugEndpoint";
|
||||||
import { EndpointFolder, EndpointFolderPreview } from "../../../sdk";
|
import { convertFileToEndpointFilePreview } from "src/collections/Files/endpoints/getByID";
|
||||||
import { Folder, Language } from "../../../types/collections";
|
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 {
|
import {
|
||||||
isAudio,
|
|
||||||
isDefined,
|
isDefined,
|
||||||
isFile,
|
|
||||||
isImage,
|
|
||||||
isNotEmpty,
|
isNotEmpty,
|
||||||
isPayloadType,
|
isPayloadType,
|
||||||
isPublished,
|
isPublished,
|
||||||
|
isImage,
|
||||||
|
isAudio,
|
||||||
isVideo,
|
isVideo,
|
||||||
} from "../../../utils/asserts";
|
isFile,
|
||||||
import { convertSourceToEndpointSource, getLanguageId } from "../../../utils/endpoints";
|
} from "src/utils/asserts";
|
||||||
import { convertAudioToEndpointAudioPreview } from "../../Audios/endpoints/getByID";
|
import { getLanguageId, convertSourceToEndpointSource } from "src/utils/endpoints";
|
||||||
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";
|
|
||||||
|
|
||||||
export const getBySlugEndpoint = createGetByEndpoint({
|
export const getBySlugEndpoint = createGetByEndpoint({
|
||||||
collection: Collections.Folders,
|
collection: Collections.Folders,
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { CollectionConfig } from "payload/types";
|
import { CollectionConfig } from "payload/types";
|
||||||
import { QuickFilters, languageBasedFilters } from "../../components/QuickFilters";
|
import { QuickFilters, languageBasedFilters } from "src/components/QuickFilters";
|
||||||
import { CollectionGroups, Collections } from "../../constants";
|
import { rowField } from "src/fields/rowField/rowField";
|
||||||
import { rowField } from "../../fields/rowField/rowField";
|
import { translatedFields } from "src/fields/translatedFields/translatedFields";
|
||||||
import { translatedFields } from "../../fields/translatedFields/translatedFields";
|
import { beforeDuplicateAddCopyTo } from "src/hooks/beforeDuplicateAddCopyTo";
|
||||||
import { beforeDuplicateAddCopyTo } from "../../hooks/beforeDuplicateAddCopyTo";
|
import { Collections, CollectionGroups } from "src/shared/payload/constants";
|
||||||
import { buildCollectionConfig } from "../../utils/collectionConfig";
|
import { buildCollectionConfig } from "src/utils/collectionConfig";
|
||||||
|
|
||||||
const fields = {
|
const fields = {
|
||||||
name: "name",
|
name: "name",
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
import { Collections } from "../../constants";
|
import { createImageSizesRegenerationEndpoint } from "src/endpoints/imageSizesRegenerationEndpoint";
|
||||||
import { createImageSizesRegenerationEndpoint } from "../../endpoints/imageSizesRegenerationEndpoint";
|
import { attributesField } from "src/fields/attributesField/attributesField";
|
||||||
import { attributesField } from "../../fields/attributesField/attributesField";
|
import { creditsField } from "src/fields/creditsField/creditsField";
|
||||||
import { creditsField } from "../../fields/creditsField/creditsField";
|
import { rowField } from "src/fields/rowField/rowField";
|
||||||
import { rowField } from "../../fields/rowField/rowField";
|
import { translatedFields } from "src/fields/translatedFields/translatedFields";
|
||||||
import { translatedFields } from "../../fields/translatedFields/translatedFields";
|
import { Collections } from "src/shared/payload/constants";
|
||||||
import { createEditor } from "../../utils/editor";
|
import { createEditor } from "src/utils/editor";
|
||||||
import {
|
import {
|
||||||
buildImageCollectionConfig,
|
buildImageCollectionConfig,
|
||||||
generateOpenGraphSize,
|
generateOpenGraphSize,
|
||||||
generateWebpSize,
|
generateWebpSize,
|
||||||
} from "../../utils/imageCollectionConfig";
|
} from "src/utils/imageCollectionConfig";
|
||||||
import { getByID } from "./endpoints/getByID";
|
import { getByID } from "./endpoints/getByID";
|
||||||
|
|
||||||
const fields = {
|
const fields = {
|
||||||
|
|
|
@ -1,16 +1,20 @@
|
||||||
import payload from "payload";
|
import payload from "payload";
|
||||||
import { Collections } from "../../../constants";
|
import { Collections } from "src/shared/payload/constants";
|
||||||
import { EndpointImage, EndpointImagePreview, PayloadImage } from "../../../sdk";
|
import {
|
||||||
import { Image } from "../../../types/collections";
|
PayloadImage,
|
||||||
import { CollectionEndpoint } from "../../../types/payload";
|
EndpointImagePreview,
|
||||||
import { isImage, isNotEmpty, isPayloadImage } from "../../../utils/asserts";
|
EndpointImage,
|
||||||
|
} from "src/shared/payload/endpoint-types";
|
||||||
|
import { CollectionEndpoint } from "src/types/payload";
|
||||||
|
import { isImage, isNotEmpty, isPayloadImage } from "src/utils/asserts";
|
||||||
import {
|
import {
|
||||||
convertAttributesToEndpointAttributes,
|
convertAttributesToEndpointAttributes,
|
||||||
convertCreditsToEndpointCredits,
|
|
||||||
convertRTCToEndpointRTC,
|
|
||||||
convertSizesToPayloadImages,
|
|
||||||
getLanguageId,
|
getLanguageId,
|
||||||
} from "../../../utils/endpoints";
|
convertSizesToPayloadImages,
|
||||||
|
convertRTCToEndpointRTC,
|
||||||
|
convertCreditsToEndpointCredits,
|
||||||
|
} from "src/utils/endpoints";
|
||||||
|
import { Image } from "src/types/collections";
|
||||||
|
|
||||||
export const getByID: CollectionEndpoint = {
|
export const getByID: CollectionEndpoint = {
|
||||||
method: "get",
|
method: "get",
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
import { text } from "payload/dist/fields/validations";
|
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 { 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 = {
|
const fields = {
|
||||||
id: "id",
|
id: "id",
|
||||||
|
@ -30,7 +29,7 @@ export const Languages = buildCollectionConfig({
|
||||||
},
|
},
|
||||||
access: { create: mustBeAdmin, update: mustBeAdmin, delete: mustBeAdmin },
|
access: { create: mustBeAdmin, update: mustBeAdmin, delete: mustBeAdmin },
|
||||||
timestamps: false,
|
timestamps: false,
|
||||||
endpoints: [importFromStrapi, getAllEndpoint],
|
endpoints: [getAllEndpoint],
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
name: fields.id,
|
name: fields.id,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import payload from "payload";
|
import payload from "payload";
|
||||||
import { Collections } from "../../../constants";
|
import { Collections } from "src/shared/payload/constants";
|
||||||
import { Language } from "../../../types/collections";
|
import { Language } from "src/types/collections";
|
||||||
import { CollectionEndpoint } from "../../../types/payload";
|
import { CollectionEndpoint } from "src/types/payload";
|
||||||
|
|
||||||
export const getAllEndpoint: CollectionEndpoint = {
|
export const getAllEndpoint: CollectionEndpoint = {
|
||||||
method: "get",
|
method: "get",
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
import { Collections } from "../../../constants";
|
|
||||||
import { createStrapiImportEndpoint } from "../../../endpoints/createStrapiImportEndpoint";
|
|
||||||
|
|
||||||
type StrapiLanguage = {
|
|
||||||
name: string;
|
|
||||||
code: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const importFromStrapi = createStrapiImportEndpoint<StrapiLanguage>({
|
|
||||||
strapi: {
|
|
||||||
collection: "languages",
|
|
||||||
params: {},
|
|
||||||
},
|
|
||||||
payload: {
|
|
||||||
collection: Collections.Languages,
|
|
||||||
convert: ({ code, name }) => ({ id: code, name }),
|
|
||||||
},
|
|
||||||
});
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { shownOnlyToAdmin } from "../../accesses/collections/shownOnlyToAdmin";
|
import { shownOnlyToAdmin } from "src/accesses/collections/shownOnlyToAdmin";
|
||||||
import { Collections } from "../../constants";
|
import { createImageSizesRegenerationEndpoint } from "src/endpoints/imageSizesRegenerationEndpoint";
|
||||||
import { createImageSizesRegenerationEndpoint } from "../../endpoints/imageSizesRegenerationEndpoint";
|
import { Collections } from "src/shared/payload/constants";
|
||||||
import {
|
import {
|
||||||
buildImageCollectionConfig,
|
buildImageCollectionConfig,
|
||||||
generateOpenGraphSize,
|
generateOpenGraphSize,
|
||||||
generateWebpSize,
|
generateWebpSize,
|
||||||
} from "../../utils/imageCollectionConfig";
|
} from "src/utils/imageCollectionConfig";
|
||||||
|
|
||||||
const fields = {
|
const fields = {
|
||||||
filename: "filename",
|
filename: "filename",
|
||||||
|
|
|
@ -1,22 +1,22 @@
|
||||||
import { Where } from "payload/types";
|
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 { 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 = {
|
const fields = {
|
||||||
slug: "slug",
|
slug: "slug",
|
||||||
|
|
|
@ -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 {
|
import {
|
||||||
BreakBlockType,
|
|
||||||
Collections,
|
|
||||||
RichTextContent,
|
RichTextContent,
|
||||||
isBlockNodeBreakBlock,
|
|
||||||
isBlockNodeSectionBlock,
|
|
||||||
isNodeBlockNode,
|
isNodeBlockNode,
|
||||||
} from "../../../constants";
|
isBlockNodeSectionBlock,
|
||||||
import { createGetByEndpoint } from "../../../endpoints/createGetByEndpoint";
|
isBlockNodeBreakBlock,
|
||||||
import { EndpointPage, EndpointPagePreview, TableOfContentEntry } from "../../../sdk";
|
} from "src/shared/payload/rich-text";
|
||||||
import { Page } from "../../../types/collections";
|
import { Page } from "src/types/collections";
|
||||||
import { isImage, isNotEmpty, isPayloadType } from "../../../utils/asserts";
|
import { isImage, isPayloadType, isNotEmpty } from "src/utils/asserts";
|
||||||
import {
|
import {
|
||||||
convertAttributesToEndpointAttributes,
|
|
||||||
convertCreditsToEndpointCredits,
|
|
||||||
convertImageToEndpointPayloadImage,
|
convertImageToEndpointPayloadImage,
|
||||||
|
convertAttributesToEndpointAttributes,
|
||||||
convertRTCToEndpointRTC,
|
convertRTCToEndpointRTC,
|
||||||
|
convertCreditsToEndpointCredits,
|
||||||
convertSourceToEndpointSource,
|
convertSourceToEndpointSource,
|
||||||
} from "../../../utils/endpoints";
|
} from "src/utils/endpoints";
|
||||||
import { convertRecorderToEndpointRecorderPreview } from "../../Recorders/endpoints/getByID";
|
|
||||||
|
|
||||||
export const getBySlugEndpoint = createGetByEndpoint({
|
export const getBySlugEndpoint = createGetByEndpoint({
|
||||||
collection: Collections.Pages,
|
collection: Collections.Pages,
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
import { mustBeAdmin as mustBeAdminForCollections } from "../../accesses/collections/mustBeAdmin";
|
import { mustBeAdminOrSelf } from "src/accesses/collections/mustBeAdminOrSelf";
|
||||||
import { mustBeAdminOrSelf } from "../../accesses/collections/mustBeAdminOrSelf";
|
import { QuickFilters } from "src/components/QuickFilters";
|
||||||
import { mustBeAdmin as mustBeAdminForFields } from "../../accesses/fields/mustBeAdmin";
|
import { imageField } from "src/fields/imageField/imageField";
|
||||||
import { QuickFilters } from "../../components/QuickFilters";
|
import { rowField } from "src/fields/rowField/rowField";
|
||||||
import { CollectionGroups, Collections, RecordersRoles } from "../../constants";
|
import { translatedFields } from "src/fields/translatedFields/translatedFields";
|
||||||
import { imageField } from "../../fields/imageField/imageField";
|
import { Collections, CollectionGroups, RecordersRoles } from "src/shared/payload/constants";
|
||||||
import { rowField } from "../../fields/rowField/rowField";
|
import { buildCollectionConfig } from "src/utils/collectionConfig";
|
||||||
import { translatedFields } from "../../fields/translatedFields/translatedFields";
|
import { createEditor } from "src/utils/editor";
|
||||||
import { buildCollectionConfig } from "../../utils/collectionConfig";
|
|
||||||
import { createEditor } from "../../utils/editor";
|
|
||||||
import { getByID } from "./endpoints/getByID";
|
import { getByID } from "./endpoints/getByID";
|
||||||
import { importFromStrapi } from "./endpoints/importFromStrapi";
|
import { importFromStrapi } from "./endpoints/importFromStrapi";
|
||||||
import { beforeLoginMustHaveAtLeastOneRole } from "./hooks/beforeLoginMustHaveAtLeastOneRole";
|
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 = {
|
const fields = {
|
||||||
username: "username",
|
username: "username",
|
||||||
|
|
|
@ -1,13 +1,10 @@
|
||||||
import payload from "payload";
|
import payload from "payload";
|
||||||
import { Collections } from "../../../constants";
|
import { Collections } from "src/shared/payload/constants";
|
||||||
import { EndpointRecorder, EndpointRecorderPreview } from "../../../sdk";
|
import { EndpointRecorderPreview, EndpointRecorder } from "src/shared/payload/endpoint-types";
|
||||||
import { Recorder } from "../../../types/collections";
|
import { Recorder } from "src/types/collections";
|
||||||
import { CollectionEndpoint } from "../../../types/payload";
|
import { CollectionEndpoint } from "src/types/payload";
|
||||||
import { isImage, isPayloadType } from "../../../utils/asserts";
|
import { isPayloadType, isImage } from "src/utils/asserts";
|
||||||
import {
|
import { convertImageToEndpointPayloadImage, convertRTCToEndpointRTC } from "src/utils/endpoints";
|
||||||
convertImageToEndpointPayloadImage,
|
|
||||||
convertRTCToEndpointRTC,
|
|
||||||
} from "../../../utils/endpoints";
|
|
||||||
|
|
||||||
export const getByID: CollectionEndpoint = {
|
export const getByID: CollectionEndpoint = {
|
||||||
method: "get",
|
method: "get",
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import payload from "payload";
|
import payload from "payload";
|
||||||
import { Collections } from "../../../constants";
|
import { createStrapiImportEndpoint } from "src/endpoints/createStrapiImportEndpoint";
|
||||||
import { createStrapiImportEndpoint } from "../../../endpoints/createStrapiImportEndpoint";
|
import { Collections } from "src/shared/payload/constants";
|
||||||
import { Recorder } from "../../../types/collections";
|
import { Recorder } from "src/types/collections";
|
||||||
import { StrapiImage, StrapiLanguage } from "../../../types/strapi";
|
import { StrapiImage, StrapiLanguage } from "src/types/strapi";
|
||||||
import { isDefined } from "../../../utils/asserts";
|
import { isDefined } from "src/utils/asserts";
|
||||||
import { uploadStrapiImage } from "../../../utils/localApi";
|
import { uploadStrapiImage } from "src/utils/localApi";
|
||||||
|
|
||||||
type StrapiRecorder = {
|
type StrapiRecorder = {
|
||||||
username: string;
|
username: string;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { shownOnlyToAdmin } from "../../accesses/collections/shownOnlyToAdmin";
|
import { shownOnlyToAdmin } from "src/accesses/collections/shownOnlyToAdmin";
|
||||||
import { Collections } from "../../constants";
|
import { createImageSizesRegenerationEndpoint } from "src/endpoints/imageSizesRegenerationEndpoint";
|
||||||
import { createImageSizesRegenerationEndpoint } from "../../endpoints/imageSizesRegenerationEndpoint";
|
import { Collections } from "src/shared/payload/constants";
|
||||||
import { buildImageCollectionConfig, generateWebpSize } from "../../utils/imageCollectionConfig";
|
import { buildImageCollectionConfig, generateWebpSize } from "src/utils/imageCollectionConfig";
|
||||||
|
|
||||||
const fields = {
|
const fields = {
|
||||||
filename: "filename",
|
filename: "filename",
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { CollectionConfig } from "payload/types";
|
import { CollectionConfig } from "payload/types";
|
||||||
import { CollectionGroups, Collections } from "../../constants";
|
import { rowField } from "src/fields/rowField/rowField";
|
||||||
import { rowField } from "../../fields/rowField/rowField";
|
import { slugField } from "src/fields/slugField/slugField";
|
||||||
import { slugField } from "../../fields/slugField/slugField";
|
import { translatedFields } from "src/fields/translatedFields/translatedFields";
|
||||||
import { translatedFields } from "../../fields/translatedFields/translatedFields";
|
import { beforeDuplicateAddCopyTo } from "src/hooks/beforeDuplicateAddCopyTo";
|
||||||
import { beforeDuplicateAddCopyTo } from "../../hooks/beforeDuplicateAddCopyTo";
|
import { Collections, CollectionGroups } from "src/shared/payload/constants";
|
||||||
import { buildCollectionConfig } from "../../utils/collectionConfig";
|
import { buildCollectionConfig } from "src/utils/collectionConfig";
|
||||||
|
|
||||||
const fields = {
|
const fields = {
|
||||||
slug: "slug",
|
slug: "slug",
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
import { CollectionGroups, Collections } from "../../constants";
|
import { attributesField } from "src/fields/attributesField/attributesField";
|
||||||
import { attributesField } from "../../fields/attributesField/attributesField";
|
import { componentField } from "src/fields/componentField/componentField";
|
||||||
import { componentField } from "../../fields/componentField/componentField";
|
import { creditsField } from "src/fields/creditsField/creditsField";
|
||||||
import { creditsField } from "../../fields/creditsField/creditsField";
|
import { imageField } from "src/fields/imageField/imageField";
|
||||||
import { imageField } from "../../fields/imageField/imageField";
|
import { rowField } from "src/fields/rowField/rowField";
|
||||||
import { rowField } from "../../fields/rowField/rowField";
|
import { translatedFields } from "src/fields/translatedFields/translatedFields";
|
||||||
import { translatedFields } from "../../fields/translatedFields/translatedFields";
|
import { Collections, CollectionGroups } from "src/shared/payload/constants";
|
||||||
import { Video } from "../../types/collections";
|
import { Video } from "src/types/collections";
|
||||||
import { isPayloadType } from "../../utils/asserts";
|
import { isPayloadType } from "src/utils/asserts";
|
||||||
import { buildCollectionConfig } from "../../utils/collectionConfig";
|
import { buildCollectionConfig } from "src/utils/collectionConfig";
|
||||||
import { createEditor } from "../../utils/editor";
|
import { createEditor } from "src/utils/editor";
|
||||||
import { getByID } from "./endpoints/getByID";
|
import { getByID } from "./endpoints/getByID";
|
||||||
|
|
||||||
const fields = {
|
const fields = {
|
||||||
|
|
|
@ -1,24 +1,28 @@
|
||||||
import payload from "payload";
|
import payload from "payload";
|
||||||
import { Collections } from "../../../constants";
|
import { Collections } from "src/shared/payload/constants";
|
||||||
import { EndpointVideo, EndpointVideoPreview, PayloadMedia } from "../../../sdk";
|
import {
|
||||||
import { Video } from "../../../types/collections";
|
PayloadMedia,
|
||||||
import { CollectionEndpoint } from "../../../types/payload";
|
EndpointVideoPreview,
|
||||||
|
EndpointVideo,
|
||||||
|
} from "src/shared/payload/endpoint-types";
|
||||||
|
import { Video } from "src/types/collections";
|
||||||
|
import { CollectionEndpoint } from "src/types/payload";
|
||||||
import {
|
import {
|
||||||
isDefined,
|
|
||||||
isEmpty,
|
|
||||||
isMediaThumbnail,
|
|
||||||
isNotEmpty,
|
|
||||||
isPayloadType,
|
|
||||||
isUndefined,
|
|
||||||
isVideo,
|
isVideo,
|
||||||
} from "../../../utils/asserts";
|
isNotEmpty,
|
||||||
|
isMediaThumbnail,
|
||||||
|
isUndefined,
|
||||||
|
isPayloadType,
|
||||||
|
isEmpty,
|
||||||
|
isDefined,
|
||||||
|
} from "src/utils/asserts";
|
||||||
import {
|
import {
|
||||||
convertAttributesToEndpointAttributes,
|
convertAttributesToEndpointAttributes,
|
||||||
convertCreditsToEndpointCredits,
|
getLanguageId,
|
||||||
convertMediaThumbnailToEndpointPayloadImage,
|
convertMediaThumbnailToEndpointPayloadImage,
|
||||||
convertRTCToEndpointRTC,
|
convertRTCToEndpointRTC,
|
||||||
getLanguageId,
|
convertCreditsToEndpointCredits,
|
||||||
} from "../../../utils/endpoints";
|
} from "src/utils/endpoints";
|
||||||
|
|
||||||
export const getByID: CollectionEndpoint = {
|
export const getByID: CollectionEndpoint = {
|
||||||
method: "get",
|
method: "get",
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { CollectionConfig } from "payload/types";
|
import { CollectionConfig } from "payload/types";
|
||||||
import { CollectionGroups, Collections } from "../../constants";
|
import { backPropagationField } from "src/fields/backPropagationField/backPropagationField";
|
||||||
import { backPropagationField } from "../../fields/backPropagationField/backPropagationField";
|
import { rowField } from "src/fields/rowField/rowField";
|
||||||
import { rowField } from "../../fields/rowField/rowField";
|
import { Collections, CollectionGroups } from "src/shared/payload/constants";
|
||||||
import { buildCollectionConfig } from "../../utils/collectionConfig";
|
import { buildCollectionConfig } from "src/utils/collectionConfig";
|
||||||
|
|
||||||
const fields = {
|
const fields = {
|
||||||
url: "url",
|
url: "url",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { shownOnlyToAdmin } from "../../accesses/collections/shownOnlyToAdmin";
|
import { shownOnlyToAdmin } from "src/accesses/collections/shownOnlyToAdmin";
|
||||||
import { CollectionGroups, Collections } from "../../constants";
|
import { Collections, CollectionGroups } from "src/shared/payload/constants";
|
||||||
import { buildCollectionConfig } from "../../utils/collectionConfig";
|
import { buildCollectionConfig } from "src/utils/collectionConfig";
|
||||||
|
|
||||||
export const VideosSubtitles = buildCollectionConfig({
|
export const VideosSubtitles = buildCollectionConfig({
|
||||||
slug: Collections.VideosSubtitles,
|
slug: Collections.VideosSubtitles,
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { GlobalConfig } from "payload/types";
|
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 { 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 = {
|
const fields = {
|
||||||
homeBackgroundImage: "homeBackgroundImage",
|
homeBackgroundImage: "homeBackgroundImage",
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import payload from "payload";
|
import payload from "payload";
|
||||||
import { Collections } from "../../../constants";
|
import { convertFolderToEndpointFolderPreview } from "src/collections/Folders/endpoints/getBySlugEndpoint";
|
||||||
import { EndpointWebsiteConfig } from "../../../sdk";
|
import { Collections } from "src/shared/payload/constants";
|
||||||
import { CollectionEndpoint } from "../../../types/payload";
|
import { EndpointWebsiteConfig } from "src/shared/payload/endpoint-types";
|
||||||
import { isImage, isPayloadType } from "../../../utils/asserts";
|
import { CollectionEndpoint } from "src/types/payload";
|
||||||
import { convertImageToEndpointPayloadImage } from "../../../utils/endpoints";
|
import { isImage, isPayloadType } from "src/utils/asserts";
|
||||||
import { convertFolderToEndpointFolderPreview } from "../../Folders/endpoints/getBySlugEndpoint";
|
import { convertImageToEndpointPayloadImage } from "src/utils/endpoints";
|
||||||
|
|
||||||
export const getConfigEndpoint: CollectionEndpoint = {
|
export const getConfigEndpoint: CollectionEndpoint = {
|
||||||
method: "get",
|
method: "get",
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import { CollectionConfig } from "payload/types";
|
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 { 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 = {
|
const fields = {
|
||||||
name: "name",
|
name: "name",
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import payload from "payload";
|
import payload from "payload";
|
||||||
import { Collections } from "../../../constants";
|
import { Collections } from "src/shared/payload/constants";
|
||||||
import { EndpointWording } from "../../../sdk";
|
import { EndpointWording } from "src/shared/payload/endpoint-types";
|
||||||
import { CollectionEndpoint } from "../../../types/payload";
|
import { CollectionEndpoint } from "src/types/payload";
|
||||||
import { isPayloadType } from "../../../utils/asserts";
|
import { isPayloadType } from "src/utils/asserts";
|
||||||
|
|
||||||
export const getAllEndpoint: CollectionEndpoint = {
|
export const getAllEndpoint: CollectionEndpoint = {
|
||||||
method: "get",
|
method: "get",
|
||||||
|
|
|
@ -2,8 +2,8 @@ import { Options } from "payload/dist/collections/operations/local/find";
|
||||||
import QueryString from "qs";
|
import QueryString from "qs";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
|
import { LanguageCodes } from "src/shared/payload/constants";
|
||||||
import styled from "styled-components";
|
import styled from "styled-components";
|
||||||
import { LanguageCodes } from "../constants";
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
slug: string;
|
slug: string;
|
||||||
|
|
312
src/constants.ts
312
src/constants.ts
|
@ -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";
|
|
|
@ -1,6 +1,6 @@
|
||||||
import payload, { GeneratedTypes } from "payload";
|
import payload, { GeneratedTypes } from "payload";
|
||||||
import { CollectionEndpoint } from "../types/payload";
|
import { CollectionEndpoint } from "src/types/payload";
|
||||||
import { isPublished } from "../utils/asserts";
|
import { isPublished } from "src/utils/asserts";
|
||||||
|
|
||||||
interface Params<C extends keyof GeneratedTypes["collections"], R> {
|
interface Params<C extends keyof GeneratedTypes["collections"], R> {
|
||||||
collection: C;
|
collection: C;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import payload, { GeneratedTypes } from "payload";
|
import payload, { GeneratedTypes } from "payload";
|
||||||
import QueryString from "qs";
|
import QueryString from "qs";
|
||||||
import { Recorder } from "../types/collections";
|
import { Recorder } from "src/types/collections";
|
||||||
import { CollectionEndpoint } from "../types/payload";
|
import { CollectionEndpoint } from "src/types/payload";
|
||||||
import { isDefined } from "../utils/asserts";
|
import { isDefined } from "src/utils/asserts";
|
||||||
|
|
||||||
const getAllStrapiEntries = async (collectionSlug: string, params: Object): Promise<any[]> => {
|
const getAllStrapiEntries = async (collectionSlug: string, params: Object): Promise<any[]> => {
|
||||||
let page = 1;
|
let page = 1;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import payload from "payload";
|
import payload from "payload";
|
||||||
import { Endpoint } from "payload/config";
|
import { Endpoint } from "payload/config";
|
||||||
import { Collections } from "../constants";
|
import { Collections } from "src/shared/payload/constants";
|
||||||
import { EndpointAllIds } from "../sdk";
|
import { EndpointAllIds } from "src/shared/payload/endpoint-types";
|
||||||
|
|
||||||
export const getAllIds: Endpoint = {
|
export const getAllIds: Endpoint = {
|
||||||
method: "get",
|
method: "get",
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
import payload from "payload";
|
import payload from "payload";
|
||||||
import { Endpoint } from "payload/config";
|
import { Endpoint } from "payload/config";
|
||||||
import { Collections } from "../constants";
|
import { Collections } from "src/shared/payload/constants";
|
||||||
import { EndpointAllSDKUrls, getSDKEndpoint } from "../sdk";
|
import { EndpointAllSDKUrls } from "src/shared/payload/endpoint-types";
|
||||||
import { Collectible } from "../types/collections";
|
import { getSDKEndpoint } from "src/shared/payload/sdk";
|
||||||
|
import { Collectible } from "src/types/collections";
|
||||||
|
|
||||||
export const getAllSDKUrlsEndpoint: Endpoint = {
|
export const getAllSDKUrlsEndpoint: Endpoint = {
|
||||||
method: "get",
|
method: "get",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import payload from "payload";
|
import payload from "payload";
|
||||||
import { CollectionEndpoint } from "../types/payload";
|
import { CollectionEndpoint } from "src/types/payload";
|
||||||
|
|
||||||
export const createImageSizesRegenerationEndpoint = (
|
export const createImageSizesRegenerationEndpoint = (
|
||||||
collection: "images" | "scans" | "media-thumbnails"
|
collection: "images" | "scans" | "media-thumbnails"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { BlockField } from "payload/dist/fields/config/types";
|
import { BlockField } from "payload/dist/fields/config/types";
|
||||||
import { numberBlock } from "../../blocks/attributeBlocks/numberBlock";
|
import { numberBlock } from "src/blocks/attributeBlocks/numberBlock";
|
||||||
import { tagsBlock } from "../../blocks/attributeBlocks/tagsBlock";
|
import { tagsBlock } from "src/blocks/attributeBlocks/tagsBlock";
|
||||||
import { textBlock } from "../../blocks/attributeBlocks/textBlock";
|
import { textBlock } from "src/blocks/attributeBlocks/textBlock";
|
||||||
|
|
||||||
type AttributesFieldProps = Omit<BlockField, "type" | "blocks">;
|
type AttributesFieldProps = Omit<BlockField, "type" | "blocks">;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import payload, { GeneratedTypes } from "payload";
|
import payload, { GeneratedTypes } from "payload";
|
||||||
import { FieldBase, SingleRelationshipField } from "payload/dist/fields/config/types";
|
import { FieldBase, SingleRelationshipField } from "payload/dist/fields/config/types";
|
||||||
import { Where } from "payload/types";
|
import { Where } from "payload/types";
|
||||||
import { isEmpty } from "../../utils/asserts";
|
import { isEmpty } from "src/utils/asserts";
|
||||||
|
|
||||||
type BackPropagationField = FieldBase & {
|
type BackPropagationField = FieldBase & {
|
||||||
where: (data: any) => Where;
|
where: (data: any) => Where;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { CollapsibleField, Condition, Field } from "payload/types";
|
import { CollapsibleField, Condition, Field } from "payload/types";
|
||||||
import { capitalize } from "../../utils/string";
|
import { capitalize } from "src/utils/string";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
name: string;
|
name: string;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { array } from "payload/dist/fields/validations";
|
import { array } from "payload/dist/fields/validations";
|
||||||
import { ArrayField } from "payload/types";
|
import { ArrayField } from "payload/types";
|
||||||
import { Collections } from "../../constants";
|
import { rowField } from "src/fields/rowField/rowField";
|
||||||
import { Credits } from "../../types/collections";
|
import { Collections } from "src/shared/payload/constants";
|
||||||
import { hasDuplicates, isDefined, isPayloadType, isUndefined } from "../../utils/asserts";
|
import { Credits } from "src/types/collections";
|
||||||
import { rowField } from "../rowField/rowField";
|
import { isDefined, isUndefined, isPayloadType, hasDuplicates } from "src/utils/asserts";
|
||||||
|
|
||||||
type Props = Omit<ArrayField, "type" | "fields">;
|
type Props = Omit<ArrayField, "type" | "fields">;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { icons } from "@iconify-json/material-symbols";
|
import { icons } from "@iconify-json/material-symbols";
|
||||||
import { TextField } from "payload/types";
|
import { TextField } from "payload/types";
|
||||||
import { isEmpty } from "../../utils/asserts";
|
import { isEmpty } from "src/utils/asserts";
|
||||||
|
|
||||||
type Props = Omit<TextField, "type" | "hasMany" | "maxRows" | "minRows">;
|
type Props = Omit<TextField, "type" | "hasMany" | "maxRows" | "minRows">;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Props } from "payload/components/views/Cell";
|
import { Props } from "payload/components/views/Cell";
|
||||||
import React, { useEffect, useMemo, useState } from "react";
|
import React, { useEffect, useMemo, useState } from "react";
|
||||||
import { Link } from "react-router-dom";
|
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 => {
|
export const Cell = ({ cellData, field, rowData, collection }: Props): JSX.Element => {
|
||||||
const [imageURL, setImageURL] = useState<string>();
|
const [imageURL, setImageURL] = useState<string>();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { TextField } from "payload/types";
|
import { TextField } from "payload/types";
|
||||||
import { isUndefined } from "../../utils/asserts";
|
import { isUndefined } from "src/utils/asserts";
|
||||||
|
|
||||||
type Props = Omit<TextField, "type" | "hasMany" | "minRows" | "maxRows">;
|
type Props = Omit<TextField, "type" | "hasMany" | "minRows" | "maxRows">;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { Language } from "../../types/collections";
|
import { Language } from "src/types/collections";
|
||||||
import { isDefined } from "../../utils/asserts";
|
import { isDefined } from "src/utils/asserts";
|
||||||
import { formatLanguageCode } from "../../utils/string";
|
import { formatLanguageCode } from "src/utils/string";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
cellData: { language?: string | Language; title?: string }[];
|
cellData: { language?: string | Language; title?: string }[];
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import React from "react";
|
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 styled from "styled-components";
|
||||||
import { Language } from "../../types/collections";
|
|
||||||
import { isDefined } from "../../utils/asserts";
|
|
||||||
import { formatLanguageCode, shortenEllipsis } from "../../utils/string";
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
language?: Language | string;
|
language?: Language | string;
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { RowLabelArgs } from "payload/dist/admin/components/forms/RowLabel/types";
|
import { RowLabelArgs } from "payload/dist/admin/components/forms/RowLabel/types";
|
||||||
import { array } from "payload/dist/fields/validations";
|
import { array } from "payload/dist/fields/validations";
|
||||||
import { ArrayField, Field } from "payload/types";
|
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 { Cell } from "./Cell";
|
||||||
import { RowLabel } from "./RowLabel";
|
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 = {
|
const fieldsNames = {
|
||||||
language: "language",
|
language: "language",
|
||||||
|
|
|
@ -3,9 +3,10 @@ import {
|
||||||
AfterChangeHook as CollectionAfterChangeHook,
|
AfterChangeHook as CollectionAfterChangeHook,
|
||||||
} from "payload/dist/collections/config/types";
|
} from "payload/dist/collections/config/types";
|
||||||
import { AfterChangeHook as GlobalAfterChangeHook } from "payload/dist/globals/config/types";
|
import { AfterChangeHook as GlobalAfterChangeHook } from "payload/dist/globals/config/types";
|
||||||
import { AfterOperationWebHookMessage, Collections } from "../constants";
|
import { getSDKUrlsForDocument } from "src/endpoints/getAllSDKUrlsEndpoint";
|
||||||
import { getSDKUrlsForDocument } from "../endpoints/getAllSDKUrlsEndpoint";
|
import { getAddedBackPropagationRelationships } from "src/fields/backPropagationField/backPropagationUtils";
|
||||||
import { getAddedBackPropagationRelationships } from "../fields/backPropagationField/backPropagationUtils";
|
import { Collections } from "src/shared/payload/constants";
|
||||||
|
import { AfterOperationWebHookMessage } from "src/shared/payload/webhooks";
|
||||||
|
|
||||||
export const globalAfterChangeWebhook: GlobalAfterChangeHook = async ({
|
export const globalAfterChangeWebhook: GlobalAfterChangeHook = async ({
|
||||||
global,
|
global,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { BeforeDuplicate } from "payload/types";
|
import { BeforeDuplicate } from "payload/types";
|
||||||
import { CollectionStatus } from "../constants";
|
import { CollectionStatus } from "src/shared/payload/constants";
|
||||||
|
|
||||||
export const beforeDuplicateUnpublish: BeforeDuplicate = ({ data }) => ({
|
export const beforeDuplicateUnpublish: BeforeDuplicate = ({ data }) => ({
|
||||||
...data,
|
...data,
|
||||||
|
|
|
@ -4,33 +4,34 @@ import { cloudStorage } from "@payloadcms/plugin-cloud-storage";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import { buildConfig } from "payload/config";
|
import { buildConfig } from "payload/config";
|
||||||
import { sftpAdapter } from "payloadcms-sftp-storage";
|
import { sftpAdapter } from "payloadcms-sftp-storage";
|
||||||
import { Attributes } from "./collections/Attributes/Attributes";
|
import { Attributes } from "src/collections/Attributes/Attributes";
|
||||||
import { Audios } from "./collections/Audios/Audios";
|
import { Audios } from "src/collections/Audios/Audios";
|
||||||
import { ChronologyEvents } from "./collections/ChronologyEvents/ChronologyEvents";
|
import { ChronologyEvents } from "src/collections/ChronologyEvents/ChronologyEvents";
|
||||||
import { Collectibles } from "./collections/Collectibles/Collectibles";
|
import { Collectibles } from "src/collections/Collectibles/Collectibles";
|
||||||
import { CreditsRoles } from "./collections/CreditsRoles/CreditsRoles";
|
import { CreditsRoles } from "src/collections/CreditsRoles/CreditsRoles";
|
||||||
import { Currencies } from "./collections/Currencies/Currencies";
|
import { Currencies } from "src/collections/Currencies/Currencies";
|
||||||
import { Files } from "./collections/Files/Files";
|
import { Files } from "src/collections/Files/Files";
|
||||||
import { Folders } from "./collections/Folders/Folders";
|
import { Folders } from "src/collections/Folders/Folders";
|
||||||
import { GenericContents } from "./collections/GenericContents/GenericContents";
|
import { GenericContents } from "src/collections/GenericContents/GenericContents";
|
||||||
import { Images } from "./collections/Images/Images";
|
import { Images } from "src/collections/Images/Images";
|
||||||
import { Languages } from "./collections/Languages/Languages";
|
import { Languages } from "src/collections/Languages/Languages";
|
||||||
import { MediaThumbnails } from "./collections/MediaThumbnails/MediaThumbnails";
|
import { MediaThumbnails } from "src/collections/MediaThumbnails/MediaThumbnails";
|
||||||
import { Pages } from "./collections/Pages/Pages";
|
import { Pages } from "src/collections/Pages/Pages";
|
||||||
import { Recorders } from "./collections/Recorders/Recorders";
|
import { Recorders } from "src/collections/Recorders/Recorders";
|
||||||
import { Scans } from "./collections/Scans/Scans";
|
import { Scans } from "src/collections/Scans/Scans";
|
||||||
import { Tags } from "./collections/Tags/Tags";
|
import { Tags } from "src/collections/Tags/Tags";
|
||||||
import { Videos } from "./collections/Videos/Videos";
|
import { Videos } from "src/collections/Videos/Videos";
|
||||||
import { VideosChannels } from "./collections/VideosChannels/VideosChannels";
|
import { VideosChannels } from "src/collections/VideosChannels/VideosChannels";
|
||||||
import { VideosSubtitles } from "./collections/VideosSubtitles/VideosSubtitles";
|
import { VideosSubtitles } from "src/collections/VideosSubtitles/VideosSubtitles";
|
||||||
import { WebsiteConfig } from "./collections/WebsiteConfig/WebsiteConfig";
|
import { WebsiteConfig } from "src/collections/WebsiteConfig/WebsiteConfig";
|
||||||
import { Wordings } from "./collections/Wordings/Wordings";
|
import { Wordings } from "src/collections/Wordings/Wordings";
|
||||||
import { Icon } from "./components/Icon";
|
import { Icon } from "src/components/Icon";
|
||||||
import { Logo } from "./components/Logo";
|
import { Logo } from "src/components/Logo";
|
||||||
import { Collections } from "./constants";
|
import { getAllIds } from "src/endpoints/getAllIdsEndpoint";
|
||||||
import { getAllIds } from "./endpoints/getAllIdsEndpoint";
|
import { getAllSDKUrlsEndpoint } from "src/endpoints/getAllSDKUrlsEndpoint";
|
||||||
import { getAllSDKUrlsEndpoint } from "./endpoints/getAllSDKUrlsEndpoint";
|
import { Collections } from "src/shared/payload/constants";
|
||||||
import { createEditor } from "./utils/editor";
|
import { createEditor } from "src/utils/editor";
|
||||||
|
// import TsconfigPathsPlugin from "tsconfig-paths-webpack-plugin";
|
||||||
|
|
||||||
const configuredSftpAdapter = sftpAdapter({
|
const configuredSftpAdapter = sftpAdapter({
|
||||||
connectOptions: {
|
connectOptions: {
|
||||||
|
@ -54,6 +55,22 @@ export default buildConfig({
|
||||||
},
|
},
|
||||||
css: path.resolve(__dirname, "styles.scss"),
|
css: path.resolve(__dirname, "styles.scss"),
|
||||||
bundler: webpackBundler(),
|
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({}),
|
editor: createEditor({}),
|
||||||
collections: [
|
collections: [
|
||||||
|
|
727
src/sdk.ts
727
src/sdk.ts
|
@ -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<EndpointFolderPreview, "translations"> & {
|
|
||||||
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<EndpointPagePreview, "translations"> & {
|
|
||||||
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<EndpointCollectiblePreview, "translations"> & {
|
|
||||||
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<EndpointMediaPreview, "translations"> & {
|
|
||||||
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<T> = {
|
|
||||||
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<T>(endpoint: string): Promise<PayloadSDKResponse<T>> {
|
|
||||||
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<PayloadSDKResponse<EndpointWebsiteConfig>> {
|
|
||||||
return await this.request(getSDKEndpoint.getConfigEndpoint());
|
|
||||||
}
|
|
||||||
async getFolder(slug: string): Promise<PayloadSDKResponse<EndpointFolder>> {
|
|
||||||
return await this.request(getSDKEndpoint.getFolderEndpoint(slug));
|
|
||||||
}
|
|
||||||
async getLanguages(): Promise<PayloadSDKResponse<Language[]>> {
|
|
||||||
return await this.request(getSDKEndpoint.getLanguagesEndpoint());
|
|
||||||
}
|
|
||||||
async getCurrencies(): Promise<PayloadSDKResponse<Currency[]>> {
|
|
||||||
return await this.request(getSDKEndpoint.getCurrenciesEndpoint());
|
|
||||||
}
|
|
||||||
async getWordings(): Promise<PayloadSDKResponse<EndpointWording[]>> {
|
|
||||||
return await this.request(getSDKEndpoint.getWordingsEndpoint());
|
|
||||||
}
|
|
||||||
async getPage(slug: string): Promise<PayloadSDKResponse<EndpointPage>> {
|
|
||||||
return await this.request(getSDKEndpoint.getPageEndpoint(slug));
|
|
||||||
}
|
|
||||||
async getCollectible(slug: string): Promise<PayloadSDKResponse<EndpointCollectible>> {
|
|
||||||
return await this.request(getSDKEndpoint.getCollectibleEndpoint(slug));
|
|
||||||
}
|
|
||||||
async getCollectibleScans(slug: string): Promise<PayloadSDKResponse<EndpointCollectibleScans>> {
|
|
||||||
return await this.request(getSDKEndpoint.getCollectibleScansEndpoint(slug));
|
|
||||||
}
|
|
||||||
async getCollectibleScanPage(
|
|
||||||
slug: string,
|
|
||||||
index: string
|
|
||||||
): Promise<PayloadSDKResponse<EndpointCollectibleScanPage>> {
|
|
||||||
return await this.request(getSDKEndpoint.getCollectibleScanPageEndpoint(slug, index));
|
|
||||||
}
|
|
||||||
async getCollectibleGallery(
|
|
||||||
slug: string
|
|
||||||
): Promise<PayloadSDKResponse<EndpointCollectibleGallery>> {
|
|
||||||
return await this.request(getSDKEndpoint.getCollectibleGalleryEndpoint(slug));
|
|
||||||
}
|
|
||||||
async getCollectibleGalleryImage(
|
|
||||||
slug: string,
|
|
||||||
index: string
|
|
||||||
): Promise<PayloadSDKResponse<EndpointCollectibleGalleryImage>> {
|
|
||||||
return await this.request(getSDKEndpoint.getCollectibleGalleryImageEndpoint(slug, index));
|
|
||||||
}
|
|
||||||
async getChronologyEvents(): Promise<PayloadSDKResponse<EndpointChronologyEvent[]>> {
|
|
||||||
return await this.request(getSDKEndpoint.getChronologyEventsEndpoint());
|
|
||||||
}
|
|
||||||
async getChronologyEventByID(id: string): Promise<PayloadSDKResponse<EndpointChronologyEvent>> {
|
|
||||||
return await this.request(getSDKEndpoint.getChronologyEventByIDEndpoint(id));
|
|
||||||
}
|
|
||||||
async getImageByID(id: string): Promise<PayloadSDKResponse<EndpointImage>> {
|
|
||||||
return await this.request(getSDKEndpoint.getImageByIDEndpoint(id));
|
|
||||||
}
|
|
||||||
async getAudioByID(id: string): Promise<PayloadSDKResponse<EndpointAudio>> {
|
|
||||||
return await this.request(getSDKEndpoint.getAudioByIDEndpoint(id));
|
|
||||||
}
|
|
||||||
async getVideoByID(id: string): Promise<PayloadSDKResponse<EndpointVideo>> {
|
|
||||||
return await this.request(getSDKEndpoint.getVideoByIDEndpoint(id));
|
|
||||||
}
|
|
||||||
async getFileByID(id: string): Promise<PayloadSDKResponse<EndpointFile>> {
|
|
||||||
return await this.request(getSDKEndpoint.getFileByIDEndpoint(id));
|
|
||||||
}
|
|
||||||
async getRecorderByID(id: string): Promise<PayloadSDKResponse<EndpointRecorder>> {
|
|
||||||
return await this.request(getSDKEndpoint.getRecorderByIDEndpoint(id));
|
|
||||||
}
|
|
||||||
async getAllSdkUrls(): Promise<PayloadSDKResponse<EndpointAllSDKUrls>> {
|
|
||||||
return await this.request(getSDKEndpoint.getAllSDKUrlsEndpoint());
|
|
||||||
}
|
|
||||||
async getAllIds(): Promise<PayloadSDKResponse<EndpointAllIds>> {
|
|
||||||
return await this.request(getSDKEndpoint.getAllIds());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +1,8 @@
|
||||||
import "dotenv/config";
|
import "dotenv/config";
|
||||||
import express from "express";
|
import express from "express";
|
||||||
import { readFileSync } from "fs";
|
|
||||||
import path from "path";
|
|
||||||
import payload from "payload";
|
import payload from "payload";
|
||||||
import { Collections, RecordersRoles } from "./constants";
|
import { Collections, RecordersRoles } from "src/shared/payload/constants";
|
||||||
import { isDefined, isUndefined } from "./utils/asserts";
|
import { isUndefined, isDefined } from "src/utils/asserts";
|
||||||
|
|
||||||
const app = express();
|
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) => {
|
app.get("/robots.txt", (_, res) => {
|
||||||
res.type("text/plain");
|
res.type("text/plain");
|
||||||
res.send("User-agent: *\nDisallow: /");
|
res.send("User-agent: *\nDisallow: /");
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { RichTextContent, isNodeParagraphNode } from "../constants";
|
import { PayloadImage, PayloadMedia } from "src/shared/payload/endpoint-types";
|
||||||
import { PayloadImage, PayloadMedia } from "../sdk";
|
import { RichTextContent, isNodeParagraphNode } from "src/shared/payload/rich-text";
|
||||||
import { Audio, File, Image, MediaThumbnail, Scan, Video } from "../types/collections";
|
import { Scan, MediaThumbnail, Video, Image, Audio } from "src/types/collections";
|
||||||
|
import { File } from "src/types/collections";
|
||||||
|
|
||||||
export const isDefined = <T>(value: T | null | undefined): value is T =>
|
export const isDefined = <T>(value: T | null | undefined): value is T =>
|
||||||
value !== null && value !== undefined;
|
value !== null && value !== undefined;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { GeneratedTypes } from "payload";
|
import { GeneratedTypes } from "payload";
|
||||||
import { CollectionConfig } from "payload/types";
|
import { CollectionConfig } from "payload/types";
|
||||||
import { afterDeleteWebhook, collectionAfterChangeWebhook } from "../hooks/afterOperationWebhook";
|
import { collectionAfterChangeWebhook, afterDeleteWebhook } from "src/hooks/afterOperationWebhook";
|
||||||
import { formatToPascalCase } from "./string";
|
import { formatToPascalCase } from "src/utils/string";
|
||||||
|
|
||||||
type CollectionConfigWithPlugins = CollectionConfig;
|
type CollectionConfigWithPlugins = CollectionConfig;
|
||||||
|
|
||||||
|
|
|
@ -1,60 +1,60 @@
|
||||||
import { convertAudioToEndpointAudioPreview } from "../collections/Audios/endpoints/getByID";
|
import { convertAudioToEndpointAudioPreview } from "src/collections/Audios/endpoints/getByID";
|
||||||
import { convertImageToEndpointImagePreview } from "../collections/Images/endpoints/getByID";
|
import { convertImageToEndpointImagePreview } from "src/collections/Images/endpoints/getByID";
|
||||||
import { convertRecorderToEndpointRecorderPreview } from "../collections/Recorders/endpoints/getByID";
|
import { convertRecorderToEndpointRecorderPreview } from "src/collections/Recorders/endpoints/getByID";
|
||||||
import { convertVideoToEndpointVideoPreview } from "../collections/Videos/endpoints/getByID";
|
import { convertVideoToEndpointVideoPreview } from "src/collections/Videos/endpoints/getByID";
|
||||||
|
import { AttributeTypes } from "src/shared/payload/constants";
|
||||||
import {
|
import {
|
||||||
AttributeTypes,
|
EndpointTag,
|
||||||
RichTextBreakBlock,
|
|
||||||
RichTextContent,
|
|
||||||
RichTextSectionBlock,
|
|
||||||
RichTextUploadNode,
|
|
||||||
isBlockNodeBreakBlock,
|
|
||||||
isBlockNodeSectionBlock,
|
|
||||||
isNodeBlockNode,
|
|
||||||
isNodeUploadNode,
|
|
||||||
isUploadNodeAudioNode,
|
|
||||||
isUploadNodeImageNode,
|
|
||||||
isUploadNodeVideoNode,
|
|
||||||
} from "../constants";
|
|
||||||
import {
|
|
||||||
EndpointAttribute,
|
|
||||||
EndpointCredit,
|
|
||||||
EndpointPayloadImage,
|
|
||||||
EndpointRole,
|
|
||||||
EndpointScanImage,
|
|
||||||
EndpointSource,
|
EndpointSource,
|
||||||
EndpointSourcePreview,
|
EndpointSourcePreview,
|
||||||
EndpointTag,
|
EndpointRole,
|
||||||
|
EndpointCredit,
|
||||||
|
EndpointAttribute,
|
||||||
PayloadImage,
|
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 {
|
import {
|
||||||
Audio,
|
|
||||||
Collectible,
|
|
||||||
Credits,
|
|
||||||
CreditsRole,
|
|
||||||
Folder,
|
|
||||||
Image,
|
Image,
|
||||||
Language,
|
Audio,
|
||||||
MediaThumbnail,
|
|
||||||
NumberBlock,
|
|
||||||
Scan,
|
|
||||||
Tag,
|
|
||||||
TagsBlock,
|
|
||||||
TextBlock,
|
|
||||||
Video,
|
Video,
|
||||||
} from "../types/collections";
|
Collectible,
|
||||||
|
Folder,
|
||||||
|
Language,
|
||||||
|
CreditsRole,
|
||||||
|
Credits,
|
||||||
|
TagsBlock,
|
||||||
|
NumberBlock,
|
||||||
|
TextBlock,
|
||||||
|
Scan,
|
||||||
|
MediaThumbnail,
|
||||||
|
Tag,
|
||||||
|
} from "src/types/collections";
|
||||||
import {
|
import {
|
||||||
isAudio,
|
isPayloadType,
|
||||||
isDefined,
|
|
||||||
isEmpty,
|
|
||||||
isImage,
|
isImage,
|
||||||
|
isAudio,
|
||||||
|
isVideo,
|
||||||
isNotEmpty,
|
isNotEmpty,
|
||||||
isPayloadArrayType,
|
isPayloadArrayType,
|
||||||
isPayloadImage,
|
|
||||||
isPayloadType,
|
|
||||||
isPublished,
|
isPublished,
|
||||||
isVideo,
|
isDefined,
|
||||||
} from "./asserts";
|
isEmpty,
|
||||||
|
isPayloadImage,
|
||||||
|
} from "src/utils/asserts";
|
||||||
|
|
||||||
const convertTagToEndpointTag = ({ id, slug, page, translations }: Tag): EndpointTag => ({
|
const convertTagToEndpointTag = ({ id, slug, page, translations }: Tag): EndpointTag => ({
|
||||||
id,
|
id,
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { ImageSize } from "payload/dist/uploads/types";
|
import { ImageSize } from "payload/dist/uploads/types";
|
||||||
import { CollectionConfig } from "payload/types";
|
import { CollectionConfig } from "payload/types";
|
||||||
import { publicAccess } from "../accesses/publicAccess";
|
import { publicAccess } from "src/accesses/publicAccess";
|
||||||
import { CollectionGroups } from "../constants";
|
import { CollectionGroups } from "src/shared/payload/constants";
|
||||||
import { BuildCollectionConfig, buildCollectionConfig } from "./collectionConfig";
|
import { BuildCollectionConfig, buildCollectionConfig } from "src/utils/collectionConfig";
|
||||||
|
|
||||||
const fields = {
|
const fields = {
|
||||||
filename: "filename",
|
filename: "filename",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import payload, { GeneratedTypes } from "payload";
|
import payload, { GeneratedTypes } from "payload";
|
||||||
import { StrapiImage } from "../types/strapi";
|
import { StrapiImage } from "src/types/strapi";
|
||||||
import { isDefined } from "./asserts";
|
import { isDefined } from "src/utils/asserts";
|
||||||
|
|
||||||
type UploadStrapiImage = {
|
type UploadStrapiImage = {
|
||||||
image: StrapiImage;
|
image: StrapiImage;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import tags from "language-tags";
|
import tags from "language-tags";
|
||||||
import { RichTextContent } from "../constants";
|
import { RichTextContent } from "src/shared/payload/rich-text";
|
||||||
import { isUndefined } from "./asserts";
|
import { isUndefined } from "src/utils/asserts";
|
||||||
|
|
||||||
export const shortenEllipsis = (text: string, length: number): string =>
|
export const shortenEllipsis = (text: string, length: number): string =>
|
||||||
text.length - 3 > length ? `${text.substring(0, length)}...` : text;
|
text.length - 3 > length ? `${text.substring(0, length)}...` : text;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { CollectionBeforeChangeHook, CollectionConfig, RelationshipField } from "payload/types";
|
import { CollectionBeforeChangeHook, CollectionConfig, RelationshipField } from "payload/types";
|
||||||
import { Collections } from "../constants";
|
import { Collections } from "src/shared/payload/constants";
|
||||||
import { BuildCollectionConfig, buildCollectionConfig } from "./collectionConfig";
|
import { BuildCollectionConfig, buildCollectionConfig } from "src/utils/collectionConfig";
|
||||||
|
|
||||||
const fields = { updatedBy: "updatedBy" };
|
const fields = { updatedBy: "updatedBy" };
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
"module": "commonjs" /* Specify what module code is generated. */,
|
"module": "commonjs" /* Specify what module code is generated. */,
|
||||||
"rootDir": "./src" /* Specify the root folder within your source files. */,
|
"rootDir": "./src" /* Specify the root folder within your source files. */,
|
||||||
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
|
// "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": {
|
"paths": {
|
||||||
"payload/generated-types": ["./src/payload-types.ts"]
|
"payload/generated-types": ["./src/payload-types.ts"]
|
||||||
} /* Specify a set of entries that re-map imports to additional lookup locations. */,
|
} /* Specify a set of entries that re-map imports to additional lookup locations. */,
|
||||||
|
@ -116,6 +116,7 @@
|
||||||
"exclude": ["node_modules", "dist", "build"],
|
"exclude": ["node_modules", "dist", "build"],
|
||||||
"ts-node": {
|
"ts-node": {
|
||||||
"transpileOnly": true,
|
"transpileOnly": true,
|
||||||
"swc": true
|
"swc": true,
|
||||||
|
"require": ["tsconfig-paths/register"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue