Compare commits
20 Commits
absolute-p
...
main
Author | SHA1 | Date |
---|---|---|
DrMint | 7dc5ca6020 | |
DrMint | 0806c74f8c | |
DrMint | 5c059d0410 | |
DrMint | c9cc673419 | |
DrMint | 935b130075 | |
DrMint | 682e1b1cfb | |
DrMint | 47dd0557d5 | |
DrMint | 1fb10535a6 | |
DrMint | 9e7d020ad7 | |
DrMint | 4c467089dc | |
DrMint | 8ab2e8088a | |
DrMint | 5acaf65ade | |
DrMint | 8cd8a67778 | |
DrMint | 1092c97f5d | |
DrMint | b0416b61db | |
DrMint | 8fe41b3989 | |
DrMint | e2cd4a9388 | |
DrMint | dfbf3c9840 | |
DrMint | 6f6c3f5c68 | |
DrMint | faeb61e1f4 |
|
@ -13,8 +13,11 @@ SEEDING_ADMIN_USERNAME=admin_name
|
||||||
SEEDING_ADMIN_EMAIL=email@domain.com
|
SEEDING_ADMIN_EMAIL=email@domain.com
|
||||||
SEEDING_ADMIN_PASSWORD=somepassword
|
SEEDING_ADMIN_PASSWORD=somepassword
|
||||||
|
|
||||||
WEB_HOOK_TOKEN=webhooktoken5e6ea45ef4e66eaa151612bdcb599df
|
WEB_SERVER_HOOK_TOKEN=webhooktoken5e6ea45ef4e66eaa151612bdcb599df
|
||||||
WEB_HOOK_URI=https://accords-library.com/some/path
|
WEB_SERVER_HOOK_URL=https://accords-library.com/some/path
|
||||||
|
|
||||||
|
MEILISEARCH_HOOK_TOKEN=webhooktoken5e6ea45ef4e66eaa151612bdcb599df
|
||||||
|
MEILISEARCH_HOOK_URL=https://meili.domain.com
|
||||||
|
|
||||||
SFTP_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\nxxxxxxxxxx..."
|
SFTP_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\nxxxxxxxxxx..."
|
||||||
SFTP_USERNAME=someuser
|
SFTP_USERNAME=someuser
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
src/shared/*
|
||||||
|
dist
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"editor.rulers": [100],
|
"editor.rulers": [100],
|
||||||
"editor.tabSize": 2,
|
"editor.tabSize": 2,
|
||||||
"typescript.preferences.importModuleSpecifier": "non-relative",
|
"typescript.preferences.importModuleSpecifier": "relative",
|
||||||
"explorer.fileNesting.enabled": true,
|
"explorer.fileNesting.enabled": true,
|
||||||
"explorer.fileNesting.patterns": {
|
"explorer.fileNesting.patterns": {
|
||||||
"package.json": ".git*, package-lock.json, yarn.lock, pnpm-lock.yaml, bun.lockb, .ncurc.*, .nvmrc, *.config.cjs, *.config.js, *.config.ts, *config.json, .*ignore",
|
"package.json": ".git*, package-lock.json, yarn.lock, pnpm-lock.yaml, bun.lockb, .ncurc.*, .nvmrc, *.config.cjs, *.config.js, *.config.ts, *config.json, .*ignore",
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
21
package.json
21
package.json
|
@ -10,7 +10,7 @@
|
||||||
"build:server": "tsc",
|
"build:server": "tsc",
|
||||||
"build": "npm run copyfiles && npm run build:payload && npm run build:server",
|
"build": "npm run copyfiles && npm run build:payload && npm run build:server",
|
||||||
"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/",
|
||||||
"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/types/collections.ts;src/shared/*'",
|
"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",
|
||||||
|
@ -18,22 +18,23 @@
|
||||||
"fetch-submodules": "cd src/shared && git pull && cd ../..",
|
"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",
|
"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 build && npm run serve"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fontsource/vollkorn": "5.0.20",
|
"@fontsource/vollkorn": "5.0.20",
|
||||||
"@iconify-json/material-symbols": "^1.1.83",
|
"@iconify-json/material-symbols": "^1.1.87",
|
||||||
"@payloadcms/bundler-webpack": "1.0.7",
|
"@payloadcms/bundler-webpack": "1.0.7",
|
||||||
"@payloadcms/db-mongodb": "1.5.2",
|
"@payloadcms/db-mongodb": "1.7.2",
|
||||||
"@payloadcms/richtext-lexical": "0.11.2",
|
"@payloadcms/richtext-lexical": "0.11.3",
|
||||||
"cross-env": "7.0.3",
|
"cross-env": "7.0.3",
|
||||||
"dotenv": "^16.4.5",
|
"dotenv": "^16.4.5",
|
||||||
"language-tags": "1.0.9",
|
"language-tags": "1.0.9",
|
||||||
"luxon": "3.4.4",
|
"luxon": "3.5.0",
|
||||||
"payload": "2.23.1",
|
"payload": "2.26.0",
|
||||||
|
"payloadcms-relationships": "github:DrMint/payloadcms-relationships",
|
||||||
"payloadcms-sftp-storage": "1.0.1",
|
"payloadcms-sftp-storage": "1.0.1",
|
||||||
"sharp": "0.33.4",
|
"sharp": "0.33.4",
|
||||||
"styled-components": "6.1.11"
|
"styled-components": "6.1.12"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/express": "4.17.21",
|
"@types/express": "4.17.21",
|
||||||
|
@ -44,11 +45,9 @@
|
||||||
"@types/styled-components": "5.1.34",
|
"@types/styled-components": "5.1.34",
|
||||||
"copyfiles": "2.4.1",
|
"copyfiles": "2.4.1",
|
||||||
"nodemon": "3.1.4",
|
"nodemon": "3.1.4",
|
||||||
"prettier": "3.3.2",
|
"prettier": "3.3.3",
|
||||||
"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 "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";
|
import { RecordersRoles } from "../../shared/payload/constants";
|
||||||
|
|
||||||
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 "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";
|
import { RecordersRoles } from "../../shared/payload/constants";
|
||||||
|
|
||||||
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 "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";
|
import { RecordersRoles } from "../../shared/payload/constants";
|
||||||
|
|
||||||
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 "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";
|
import { RecordersRoles } from "../../shared/payload/constants";
|
||||||
|
|
||||||
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 { rowField } from "src/fields/rowField/rowField";
|
import { rowField } from "../../fields/rowField/rowField";
|
||||||
import { Collections, AttributeTypes } from "src/shared/payload/constants";
|
import { AttributeTypes, Collections } from "../../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 { rowField } from "src/fields/rowField/rowField";
|
import { rowField } from "../../fields/rowField/rowField";
|
||||||
import { Collections, AttributeTypes } from "src/shared/payload/constants";
|
import { Collections, AttributeTypes } from "../../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 { rowField } from "src/fields/rowField/rowField";
|
import { rowField } from "../../fields/rowField/rowField";
|
||||||
import { Collections, AttributeTypes } from "src/shared/payload/constants";
|
import { AttributeTypes, Collections } from "../../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 "src/shared/payload/constants";
|
import { BreakBlockType } from "../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 "src/utils/editor";
|
import { createEditor } from "../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 "src/utils/editor";
|
import { createEditor } from "../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 { breakBlock } from "src/blocks/breakBlock";
|
import { createEditor } from "../utils/editor";
|
||||||
import { transcriptBlock } from "src/blocks/transcriptBlock";
|
import { breakBlock } from "./breakBlock";
|
||||||
import { createEditor } from "src/utils/editor";
|
import { transcriptBlock } from "./transcriptBlock";
|
||||||
|
|
||||||
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 "src/blocks/cueBlock";
|
import { cueBlock } from "./cueBlock";
|
||||||
import { lineBlock } from "src/blocks/lineBlock";
|
import { lineBlock } from "./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 "src/accesses/fields/mustBeAdmin";
|
import { mustBeAdmin } from "../../accesses/fields/mustBeAdmin";
|
||||||
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";
|
import { Collections, CollectionGroups, AttributeTypes } from "../../shared/payload/constants";
|
||||||
|
|
||||||
const fields = {
|
const fields = {
|
||||||
slug: "slug",
|
slug: "slug",
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
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 { Collections, CollectionGroups } from "../../shared/payload/constants";
|
||||||
import { buildCollectionConfig } from "src/utils/collectionConfig";
|
import { buildCollectionConfig } from "../../utils/collectionConfig";
|
||||||
import { createEditor } from "src/utils/editor";
|
import { createEditor } from "../../utils/editor";
|
||||||
import { getByID } from "./endpoints/getByID";
|
import { getByID } from "./endpoints/getByID";
|
||||||
|
|
||||||
const fields = {
|
const fields = {
|
||||||
|
@ -31,6 +31,7 @@ export const Audios = buildCollectionConfig({
|
||||||
admin: {
|
admin: {
|
||||||
group: CollectionGroups.Media,
|
group: CollectionGroups.Media,
|
||||||
preview: ({ id }) => `${process.env.PAYLOAD_PUBLIC_FRONTEND_BASE_URL}/en/audios/${id}`,
|
preview: ({ id }) => `${process.env.PAYLOAD_PUBLIC_FRONTEND_BASE_URL}/en/audios/${id}`,
|
||||||
|
useAsTitle: fields.filename,
|
||||||
defaultColumns: [
|
defaultColumns: [
|
||||||
fields.filename,
|
fields.filename,
|
||||||
fields.thumbnail,
|
fields.thumbnail,
|
||||||
|
|
|
@ -1,20 +1,22 @@
|
||||||
import payload from "payload";
|
import payload from "payload";
|
||||||
import { Collections } from "src/shared/payload/constants";
|
import { Audio } from "../../../types/collections";
|
||||||
|
import { CollectionEndpoint } from "../../../types/payload";
|
||||||
|
import { isAudio, isMediaThumbnail, isNotEmpty } from "../../../utils/asserts";
|
||||||
|
import {
|
||||||
|
convertAttributesToEndpointAttributes,
|
||||||
|
convertCreditsToEndpointCredits,
|
||||||
|
convertMediaThumbnailToEndpointPayloadImage,
|
||||||
|
convertRTCToEndpointRTC,
|
||||||
|
convertRelationshipsToEndpointRelations,
|
||||||
|
getLanguageId,
|
||||||
|
} from "../../../utils/endpoints";
|
||||||
|
import { Collections } from "../../../shared/payload/constants";
|
||||||
import {
|
import {
|
||||||
PayloadMedia,
|
PayloadMedia,
|
||||||
EndpointAudioPreview,
|
EndpointAudioPreview,
|
||||||
EndpointAudio,
|
EndpointAudio,
|
||||||
} from "src/shared/payload/endpoint-types";
|
} from "../../../shared/payload/endpoint-types";
|
||||||
import { CollectionEndpoint } from "src/types/payload";
|
import { findIncomingRelationships } from "payloadcms-relationships";
|
||||||
import { isAudio, isNotEmpty, isMediaThumbnail } from "src/utils/asserts";
|
|
||||||
import {
|
|
||||||
convertAttributesToEndpointAttributes,
|
|
||||||
getLanguageId,
|
|
||||||
convertMediaThumbnailToEndpointPayloadImage,
|
|
||||||
convertRTCToEndpointRTC,
|
|
||||||
convertCreditsToEndpointCredits,
|
|
||||||
} from "src/utils/endpoints";
|
|
||||||
import { Audio } from "src/types/collections";
|
|
||||||
|
|
||||||
export const getByID: CollectionEndpoint = {
|
export const getByID: CollectionEndpoint = {
|
||||||
method: "get",
|
method: "get",
|
||||||
|
@ -44,7 +46,7 @@ export const getByID: CollectionEndpoint = {
|
||||||
return res.sendStatus(404);
|
return res.sendStatus(404);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res.status(200).json(convertAudioToEndpointAudio(result));
|
return res.status(200).json(await convertAudioToEndpointAudio(result));
|
||||||
} catch {
|
} catch {
|
||||||
return res.sendStatus(404);
|
return res.sendStatus(404);
|
||||||
}
|
}
|
||||||
|
@ -79,8 +81,8 @@ export const convertAudioToEndpointAudioPreview = ({
|
||||||
: {}),
|
: {}),
|
||||||
});
|
});
|
||||||
|
|
||||||
const convertAudioToEndpointAudio = (audio: Audio & PayloadMedia): EndpointAudio => {
|
const convertAudioToEndpointAudio = async (audio: Audio & PayloadMedia): Promise<EndpointAudio> => {
|
||||||
const { translations, createdAt, updatedAt, filesize, credits } = audio;
|
const { translations, createdAt, updatedAt, filesize, credits, id } = audio;
|
||||||
return {
|
return {
|
||||||
...convertAudioToEndpointAudioPreview(audio),
|
...convertAudioToEndpointAudioPreview(audio),
|
||||||
createdAt,
|
createdAt,
|
||||||
|
@ -95,5 +97,8 @@ const convertAudioToEndpointAudio = (audio: Audio & PayloadMedia): EndpointAudio
|
||||||
...(isNotEmpty(description) ? { description: convertRTCToEndpointRTC(description) } : {}),
|
...(isNotEmpty(description) ? { description: convertRTCToEndpointRTC(description) } : {}),
|
||||||
})) ?? [],
|
})) ?? [],
|
||||||
credits: convertCreditsToEndpointCredits(credits),
|
credits: convertCreditsToEndpointCredits(credits),
|
||||||
|
backlinks: convertRelationshipsToEndpointRelations(
|
||||||
|
await findIncomingRelationships(Collections.Audios, id)
|
||||||
|
),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,4 +1,14 @@
|
||||||
import { CollectionConfig } from "payload/types";
|
import { CollectionConfig } from "payload/types";
|
||||||
|
import {
|
||||||
|
QuickFilters,
|
||||||
|
languageBasedFilters,
|
||||||
|
publishStatusFilters,
|
||||||
|
} from "../../components/QuickFilters";
|
||||||
|
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";
|
||||||
|
@ -9,17 +19,7 @@ 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 {
|
import { Collections, CollectionGroups } from "../../shared/payload/constants";
|
||||||
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 { translatedFields } from "src/fields/translatedFields/translatedFields";
|
import { translatedFields } from "../../../fields/translatedFields/translatedFields";
|
||||||
import { Collections } from "src/shared/payload/constants";
|
import { Collections } from "../../../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 "src/shared/payload/constants";
|
import { Collections } from "../../../shared/payload/constants";
|
||||||
|
|
||||||
export const pageBlock: Block = {
|
export const pageBlock: Block = {
|
||||||
slug: "pageBlock",
|
slug: "pageBlock",
|
||||||
|
|
|
@ -1,12 +1,16 @@
|
||||||
import payload from "payload";
|
import payload from "payload";
|
||||||
import { convertCollectibleToEndpointCollectiblePreview } from "src/collections/Collectibles/endpoints/getBySlugEndpoint";
|
import { ChronologyEvent, CollectibleBlock } from "../../../types/collections";
|
||||||
import { convertPageToEndpointPagePreview } from "src/collections/Pages/endpoints/getBySlugEndpoint";
|
import { CollectionEndpoint } from "../../../types/payload";
|
||||||
import { Collections } from "src/shared/payload/constants";
|
import { isDefined, isNotEmpty, isPayloadType } from "../../../utils/asserts";
|
||||||
import { EndpointChronologyEvent, EndpointSource } from "src/shared/payload/endpoint-types";
|
import { convertCreditsToEndpointCredits, getDomainFromUrl } from "../../../utils/endpoints";
|
||||||
import { ChronologyEvent, CollectibleBlock } from "src/types/collections";
|
import { convertCollectibleToEndpointCollectiblePreview } from "../../Collectibles/endpoints/getBySlugEndpoint";
|
||||||
import { CollectionEndpoint } from "src/types/payload";
|
import { convertPageToEndpointPagePreview } from "../../Pages/endpoints/getBySlugEndpoint";
|
||||||
import { isDefined, isPayloadType, isNotEmpty } from "src/utils/asserts";
|
import { Collections } from "../../../shared/payload/constants";
|
||||||
import { convertCreditsToEndpointCredits, getDomainFromUrl } from "src/utils/endpoints";
|
import {
|
||||||
|
EndpointChronologyEvent,
|
||||||
|
EndpointCollectibleRelationRange,
|
||||||
|
EndpointRelation,
|
||||||
|
} from "../../../shared/payload/endpoint-types";
|
||||||
|
|
||||||
export const getAllEndpoint: CollectionEndpoint = {
|
export const getAllEndpoint: CollectionEndpoint = {
|
||||||
method: "get",
|
method: "get",
|
||||||
|
@ -48,13 +52,13 @@ export const getAllEndpoint: CollectionEndpoint = {
|
||||||
if (aDay !== bDay) return aDay - bDay;
|
if (aDay !== bDay) return aDay - bDay;
|
||||||
return 0;
|
return 0;
|
||||||
})
|
})
|
||||||
.map<EndpointChronologyEvent>(eventToEndpointEvent);
|
.map<EndpointChronologyEvent>(convertEventToEndpointEvent);
|
||||||
|
|
||||||
res.status(200).json(events);
|
res.status(200).json(events);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const eventToEndpointEvent = ({
|
export const convertEventToEndpointEvent = ({
|
||||||
date: { year, day, month },
|
date: { year, day, month },
|
||||||
events,
|
events,
|
||||||
id,
|
id,
|
||||||
|
@ -80,31 +84,35 @@ export const eventToEndpointEvent = ({
|
||||||
})),
|
})),
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleSources = (sources: ChronologyEvent["events"][number]["sources"]): EndpointSource[] => {
|
const handleSources = (
|
||||||
|
sources: ChronologyEvent["events"][number]["sources"]
|
||||||
|
): EndpointRelation[] => {
|
||||||
return (
|
return (
|
||||||
sources?.flatMap<EndpointSource>((source) => {
|
sources?.flatMap<EndpointRelation>((source) => {
|
||||||
switch (source.blockType) {
|
switch (source.blockType) {
|
||||||
case "collectibleBlock":
|
case "collectibleBlock":
|
||||||
const range = handleRange(source.range);
|
const range = handleRange(source.range);
|
||||||
if (!isPayloadType(source.collectible)) return [];
|
if (!isPayloadType(source.collectible)) return [];
|
||||||
return {
|
return {
|
||||||
type: "collectible",
|
type: Collections.Collectibles,
|
||||||
collectible: convertCollectibleToEndpointCollectiblePreview(source.collectible),
|
value: convertCollectibleToEndpointCollectiblePreview(source.collectible),
|
||||||
...(isDefined(range) ? { range } : {}),
|
...(isDefined(range) ? { range } : {}),
|
||||||
};
|
};
|
||||||
|
|
||||||
case "pageBlock":
|
case "pageBlock":
|
||||||
if (!isPayloadType(source.page)) return [];
|
if (!isPayloadType(source.page)) return [];
|
||||||
return {
|
return {
|
||||||
type: "page",
|
type: Collections.Pages,
|
||||||
page: convertPageToEndpointPagePreview(source.page),
|
value: convertPageToEndpointPagePreview(source.page),
|
||||||
};
|
};
|
||||||
|
|
||||||
case "urlBlock":
|
case "urlBlock":
|
||||||
return {
|
return {
|
||||||
type: "url",
|
type: "url",
|
||||||
url: source.url,
|
value: {
|
||||||
label: getDomainFromUrl(source.url),
|
url: source.url,
|
||||||
|
label: getDomainFromUrl(source.url),
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}) ?? []
|
}) ?? []
|
||||||
|
@ -113,7 +121,7 @@ const handleSources = (sources: ChronologyEvent["events"][number]["sources"]): E
|
||||||
|
|
||||||
const handleRange = (
|
const handleRange = (
|
||||||
rawRange: CollectibleBlock["range"]
|
rawRange: CollectibleBlock["range"]
|
||||||
): Extract<EndpointSource, { type: "collectible" }>["range"] => {
|
): EndpointCollectibleRelationRange | undefined => {
|
||||||
const range = rawRange?.[0];
|
const range = rawRange?.[0];
|
||||||
|
|
||||||
switch (range?.blockType) {
|
switch (range?.blockType) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import payload from "payload";
|
import payload from "payload";
|
||||||
import { eventToEndpointEvent } from "./getAllEndpoint";
|
import { CollectionEndpoint } from "../../../types/payload";
|
||||||
import { Collections } from "src/shared/payload/constants";
|
import { convertEventToEndpointEvent } from "./getAllEndpoint";
|
||||||
import { CollectionEndpoint } from "src/types/payload";
|
import { Collections } from "../../../shared/payload/constants";
|
||||||
|
|
||||||
export const getByID: CollectionEndpoint = {
|
export const getByID: CollectionEndpoint = {
|
||||||
method: "get",
|
method: "get",
|
||||||
|
@ -27,7 +27,7 @@ export const getByID: CollectionEndpoint = {
|
||||||
id: req.params.id,
|
id: req.params.id,
|
||||||
});
|
});
|
||||||
|
|
||||||
return res.status(200).json(eventToEndpointEvent(result));
|
return res.status(200).json(convertEventToEndpointEvent(result));
|
||||||
} catch {
|
} catch {
|
||||||
return res.sendStatus(404);
|
return res.sendStatus(404);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { createStrapiImportEndpoint } from "src/endpoints/createStrapiImportEndpoint";
|
import { createStrapiImportEndpoint } from "../../../endpoints/createStrapiImportEndpoint";
|
||||||
import { Collections } from "src/shared/payload/constants";
|
import { Collections } from "../../../shared/payload/constants";
|
||||||
import { StrapiLanguage } from "src/types/strapi";
|
import { StrapiLanguage } from "../../../types/strapi";
|
||||||
import { isUndefined, isDefined } from "src/utils/asserts";
|
import { isDefined, isUndefined } from "../../../utils/asserts";
|
||||||
import { plainTextToLexical } from "src/utils/string";
|
import { plainTextToLexical } from "../../../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 "src/types/collections";
|
import { ChronologyEvent } from "../../../types/collections";
|
||||||
import { isUndefined, isDefined } from "src/utils/asserts";
|
import { isDefined, isUndefined } from "../../../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 "src/types/collections";
|
import { ChronologyEvent } from "../../../types/collections";
|
||||||
import { isUndefined } from "src/utils/asserts";
|
import { isUndefined } from "../../../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 "src/types/collections";
|
import { ChronologyEvent } from "../../../types/collections";
|
||||||
import { isEmpty } from "src/utils/asserts";
|
import { isEmpty } from "../../../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 "src/types/collections";
|
import { ChronologyEvent } from "../../../types/collections";
|
||||||
import { isEmpty } from "src/utils/asserts";
|
import { isEmpty } from "../../../utils/asserts";
|
||||||
|
|
||||||
export const validateEventsTranslationsTitle: Validate<
|
export const validateEventsTranslationsTitle: Validate<
|
||||||
string | undefined,
|
string | undefined,
|
||||||
|
|
|
@ -1,33 +1,29 @@
|
||||||
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 { attributesField } from "../../fields/attributesField/attributesField";
|
||||||
|
import { componentField } from "../../fields/componentField/componentField";
|
||||||
|
import { creditsField } from "../../fields/creditsField/creditsField";
|
||||||
|
import { imageField } from "../../fields/imageField/imageField";
|
||||||
|
import { rowField } from "../../fields/rowField/rowField";
|
||||||
|
import { 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 { 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 {
|
import {
|
||||||
Collections,
|
Collections,
|
||||||
CollectionGroups,
|
CollectionGroups,
|
||||||
CollectibleNature,
|
CollectibleNature,
|
||||||
CollectibleBindingTypes,
|
CollectibleBindingTypes,
|
||||||
CollectiblePageOrders,
|
CollectiblePageOrders,
|
||||||
} from "src/shared/payload/constants";
|
} from "../../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",
|
||||||
|
@ -695,42 +691,9 @@ export const Collectibles = buildVersionedCollectionConfig({
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
rowField([
|
|
||||||
backPropagationField({
|
|
||||||
name: fields.folders,
|
|
||||||
relationTo: Collections.Folders,
|
|
||||||
hasMany: true,
|
|
||||||
where: ({ id }) => ({
|
|
||||||
and: [
|
|
||||||
{ "files.value": { equals: id } },
|
|
||||||
{ "files.relationTo": { equals: Collections.Collectibles } },
|
|
||||||
] as Where[],
|
|
||||||
}),
|
|
||||||
admin: {
|
|
||||||
description: `You can go to the "Folders" collection to include this collectible in a folder.`,
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
backPropagationField({
|
|
||||||
name: fields.parentItems,
|
|
||||||
relationTo: Collections.Collectibles,
|
|
||||||
hasMany: true,
|
|
||||||
where: ({ id }) => ({ [fields.subitems]: { equals: id } }),
|
|
||||||
}),
|
|
||||||
]),
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
custom: {
|
|
||||||
getBackPropagatedRelationships: ({ subitems, contents }: Collectible) => {
|
|
||||||
const result: string[] = [];
|
|
||||||
subitems?.forEach((subitem) => result.push(isPayloadType(subitem) ? subitem.id : subitem));
|
|
||||||
contents?.forEach(({ content: { relationTo, value } }) => {
|
|
||||||
if (relationTo === "pages") result.push(isPayloadType(value) ? value.id : value);
|
|
||||||
});
|
|
||||||
return result;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -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,37 +1,41 @@
|
||||||
import { convertAudioToEndpointAudioPreview } from "src/collections/Audios/endpoints/getByID";
|
import { createGetByEndpoint } from "../../../endpoints/createGetByEndpoint";
|
||||||
import { convertFileToEndpointFilePreview } from "src/collections/Files/endpoints/getByID";
|
import { Collections, CollectibleNature } from "../../../shared/payload/constants";
|
||||||
import { convertPageToEndpointPagePreview } from "src/collections/Pages/endpoints/getBySlugEndpoint";
|
import {
|
||||||
import { convertRecorderToEndpointRecorderPreview } from "src/collections/Recorders/endpoints/getByID";
|
EndpointCollectiblePreview,
|
||||||
import { convertVideoToEndpointVideoPreview } from "src/collections/Videos/endpoints/getByID";
|
EndpointCollectible,
|
||||||
import { createGetByEndpoint } from "src/endpoints/createGetByEndpoint";
|
} from "../../../shared/payload/endpoint-types";
|
||||||
import { Collections, CollectibleNature } from "src/shared/payload/constants";
|
import { Collectible } from "../../../types/collections";
|
||||||
import { EndpointCollectiblePreview, EndpointCollectible } from "src/shared/payload/endpoint-types";
|
|
||||||
import { Collectible } from "src/types/collections";
|
|
||||||
import {
|
import {
|
||||||
isImage,
|
|
||||||
isPayloadType,
|
|
||||||
isNotEmpty,
|
|
||||||
isDefined,
|
|
||||||
isPayloadArrayType,
|
|
||||||
isPublished,
|
|
||||||
isFile,
|
|
||||||
isScan,
|
|
||||||
isAudio,
|
isAudio,
|
||||||
|
isDefined,
|
||||||
|
isFile,
|
||||||
|
isImage,
|
||||||
|
isNotEmpty,
|
||||||
|
isPayloadArrayType,
|
||||||
|
isPayloadType,
|
||||||
|
isPublished,
|
||||||
|
isScan,
|
||||||
isVideo,
|
isVideo,
|
||||||
} from "src/utils/asserts";
|
} from "../../../utils/asserts";
|
||||||
import {
|
import {
|
||||||
convertImageToEndpointPayloadImage,
|
|
||||||
convertAttributesToEndpointAttributes,
|
convertAttributesToEndpointAttributes,
|
||||||
getDomainFromUrl,
|
convertImageToEndpointPayloadImage,
|
||||||
convertSourceToEndpointSource,
|
convertRelationshipsToEndpointRelations,
|
||||||
convertScanToEndpointScanImage,
|
convertScanToEndpointScanImage,
|
||||||
} from "src/utils/endpoints";
|
getDomainFromUrl,
|
||||||
|
} from "../../../utils/endpoints";
|
||||||
|
import { convertAudioToEndpointAudioPreview } from "../../Audios/endpoints/getByID";
|
||||||
|
import { convertFileToEndpointFilePreview } from "../../Files/endpoints/getByID";
|
||||||
|
import { convertPageToEndpointPagePreview } from "../../Pages/endpoints/getBySlugEndpoint";
|
||||||
|
import { convertRecorderToEndpointRecorderPreview } from "../../Recorders/endpoints/getByID";
|
||||||
|
import { convertVideoToEndpointVideoPreview } from "../../Videos/endpoints/getByID";
|
||||||
|
import { findIncomingRelationships } from "payloadcms-relationships";
|
||||||
|
|
||||||
export const getBySlugEndpoint = createGetByEndpoint({
|
export const getBySlugEndpoint = createGetByEndpoint({
|
||||||
collection: Collections.Collectibles,
|
collection: Collections.Collectibles,
|
||||||
attribute: "slug",
|
attribute: "slug",
|
||||||
depth: 3,
|
depth: 3,
|
||||||
handler: (collectible) => convertCollectibleToEndpointCollectible(collectible),
|
handler: async (collectible) => await convertCollectibleToEndpointCollectible(collectible),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const convertCollectibleToEndpointCollectiblePreview = ({
|
export const convertCollectibleToEndpointCollectiblePreview = ({
|
||||||
|
@ -61,8 +65,11 @@ export const convertCollectibleToEndpointCollectiblePreview = ({
|
||||||
...handlePrice(price, priceEnabled),
|
...handlePrice(price, priceEnabled),
|
||||||
});
|
});
|
||||||
|
|
||||||
const convertCollectibleToEndpointCollectible = (collectible: Collectible): EndpointCollectible => {
|
const convertCollectibleToEndpointCollectible = async (
|
||||||
|
collectible: Collectible
|
||||||
|
): Promise<EndpointCollectible> => {
|
||||||
const {
|
const {
|
||||||
|
id,
|
||||||
nature,
|
nature,
|
||||||
urls,
|
urls,
|
||||||
subitems,
|
subitems,
|
||||||
|
@ -77,8 +84,6 @@ const convertCollectibleToEndpointCollectible = (collectible: Collectible): Endp
|
||||||
weightEnabled,
|
weightEnabled,
|
||||||
pageInfo,
|
pageInfo,
|
||||||
pageInfoEnabled,
|
pageInfoEnabled,
|
||||||
parentItems,
|
|
||||||
folders,
|
|
||||||
backgroundImage,
|
backgroundImage,
|
||||||
translations,
|
translations,
|
||||||
scans: rawScans,
|
scans: rawScans,
|
||||||
|
@ -125,7 +130,9 @@ const convertCollectibleToEndpointCollectible = (collectible: Collectible): Endp
|
||||||
...(isPayloadType(updatedBy)
|
...(isPayloadType(updatedBy)
|
||||||
? { updatedBy: convertRecorderToEndpointRecorderPreview(updatedBy) }
|
? { updatedBy: convertRecorderToEndpointRecorderPreview(updatedBy) }
|
||||||
: {}),
|
: {}),
|
||||||
parentPages: convertSourceToEndpointSource({ collectibles: parentItems, folders }),
|
backlinks: convertRelationshipsToEndpointRelations(
|
||||||
|
await findIncomingRelationships(Collections.Collectibles, id)
|
||||||
|
),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
import { createGetByEndpoint } from "src/endpoints/createGetByEndpoint";
|
import { createGetByEndpoint } from "../../../endpoints/createGetByEndpoint";
|
||||||
import { Collections } from "src/shared/payload/constants";
|
import { Collections } from "../../../shared/payload/constants";
|
||||||
import { EndpointCollectibleGallery } from "src/shared/payload/endpoint-types";
|
import { EndpointCollectibleGallery } from "../../../shared/payload/endpoint-types";
|
||||||
import { isPayloadType, isNotEmpty, isImage } from "src/utils/asserts";
|
import { isImage, isNotEmpty, isPayloadType } from "../../../utils/asserts";
|
||||||
import {
|
import { convertImageToEndpointPayloadImage } from "../../../utils/endpoints";
|
||||||
convertImageToEndpointPayloadImage,
|
import { convertCollectibleToEndpointCollectiblePreview } from "./getBySlugEndpoint";
|
||||||
convertSourceToEndpointSource,
|
|
||||||
} from "src/utils/endpoints";
|
|
||||||
|
|
||||||
export const getBySlugEndpointGallery = createGetByEndpoint({
|
export const getBySlugEndpointGallery = createGetByEndpoint({
|
||||||
collection: Collections.Collectibles,
|
collection: Collections.Collectibles,
|
||||||
|
@ -29,7 +27,12 @@ export const getBySlugEndpointGallery = createGetByEndpoint({
|
||||||
gallery?.flatMap(({ image }) =>
|
gallery?.flatMap(({ image }) =>
|
||||||
isImage(image) ? convertImageToEndpointPayloadImage(image) : []
|
isImage(image) ? convertImageToEndpointPayloadImage(image) : []
|
||||||
) ?? [],
|
) ?? [],
|
||||||
parentPages: convertSourceToEndpointSource({ collectibles: [collectible] }),
|
backlinks: [
|
||||||
|
{
|
||||||
|
type: Collections.Collectibles,
|
||||||
|
value: convertCollectibleToEndpointCollectiblePreview(collectible),
|
||||||
|
},
|
||||||
|
],
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
import payload from "payload";
|
import payload from "payload";
|
||||||
import { convertImageToEndpointImage } from "src/collections/Images/endpoints/getByID";
|
import { Collectible, Image } from "../../../types/collections";
|
||||||
import { Collections } from "src/shared/payload/constants";
|
import { CollectionEndpoint } from "../../../types/payload";
|
||||||
import { EndpointCollectibleGalleryImage } from "src/shared/payload/endpoint-types";
|
import { isDefined, isImage, isNotEmpty, isPayloadType } from "../../../utils/asserts";
|
||||||
import { Collectible } from "src/types/collections";
|
import { convertImageToEndpointImage } from "../../Images/endpoints/getByID";
|
||||||
import { CollectionEndpoint } from "src/types/payload";
|
import { Collections } from "../../../shared/payload/constants";
|
||||||
import { isImage, isPayloadType, isNotEmpty, isDefined } from "src/utils/asserts";
|
import { EndpointCollectibleGalleryImage } from "../../../shared/payload/endpoint-types";
|
||||||
import { convertSourceToEndpointSource } from "src/utils/endpoints";
|
import { convertCollectibleToEndpointCollectiblePreview } from "./getBySlugEndpoint";
|
||||||
import { Image } from "src/types/collections";
|
|
||||||
|
|
||||||
export const getBySlugEndpointGalleryImage: CollectionEndpoint = {
|
export const getBySlugEndpointGalleryImage: CollectionEndpoint = {
|
||||||
path: "/slug/:slug/gallery/:index",
|
path: "/slug/:slug/gallery/:index",
|
||||||
|
@ -52,8 +51,7 @@ export const getBySlugEndpointGalleryImage: CollectionEndpoint = {
|
||||||
const nextIndex = getNextIndex(index, collectible.gallery);
|
const nextIndex = getNextIndex(index, collectible.gallery);
|
||||||
|
|
||||||
const scanPage: EndpointCollectibleGalleryImage = {
|
const scanPage: EndpointCollectibleGalleryImage = {
|
||||||
image: convertImageToEndpointImage(image),
|
image: await convertImageToEndpointImage(image),
|
||||||
parentPages: convertSourceToEndpointSource({ gallery: [collectible] }),
|
|
||||||
slug,
|
slug,
|
||||||
translations:
|
translations:
|
||||||
collectible.translations?.map(({ language, title, description, pretitle, subtitle }) => ({
|
collectible.translations?.map(({ language, title, description, pretitle, subtitle }) => ({
|
||||||
|
@ -65,6 +63,13 @@ export const getBySlugEndpointGalleryImage: CollectionEndpoint = {
|
||||||
})) ?? [],
|
})) ?? [],
|
||||||
...(isDefined(previousIndex) ? { previousIndex } : {}),
|
...(isDefined(previousIndex) ? { previousIndex } : {}),
|
||||||
...(isDefined(nextIndex) ? { nextIndex } : {}),
|
...(isDefined(nextIndex) ? { nextIndex } : {}),
|
||||||
|
backlinks: [
|
||||||
|
{
|
||||||
|
type: Collections.Collectibles,
|
||||||
|
subpage: "gallery",
|
||||||
|
value: convertCollectibleToEndpointCollectiblePreview(collectible),
|
||||||
|
},
|
||||||
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
res.status(200).send(scanPage);
|
res.status(200).send(scanPage);
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
import payload from "payload";
|
import payload from "payload";
|
||||||
import { Collections } from "src/shared/payload/constants";
|
import { Collectible, Scan } from "../../../types/collections";
|
||||||
import { EndpointCollectibleScanPage } from "src/shared/payload/endpoint-types";
|
import { CollectionEndpoint } from "../../../types/payload";
|
||||||
import { Collectible, Scan } from "src/types/collections";
|
import { isDefined, isNotEmpty, isPayloadType, isScan } from "../../../utils/asserts";
|
||||||
import { CollectionEndpoint } from "src/types/payload";
|
import { convertScanToEndpointScanImage } from "../../../utils/endpoints";
|
||||||
import { isScan, isPayloadType, isNotEmpty, isDefined } from "src/utils/asserts";
|
import { Collections } from "../../../shared/payload/constants";
|
||||||
import { convertScanToEndpointScanImage, convertSourceToEndpointSource } from "src/utils/endpoints";
|
import { EndpointCollectibleScanPage } from "../../../shared/payload/endpoint-types";
|
||||||
|
import { convertCollectibleToEndpointCollectiblePreview } from "./getBySlugEndpoint";
|
||||||
|
|
||||||
export const getBySlugEndpointScanPage: CollectionEndpoint = {
|
export const getBySlugEndpointScanPage: CollectionEndpoint = {
|
||||||
path: "/slug/:slug/scans/:index",
|
path: "/slug/:slug/scans/:index",
|
||||||
|
@ -51,7 +52,6 @@ export const getBySlugEndpointScanPage: CollectionEndpoint = {
|
||||||
|
|
||||||
const scanPage: EndpointCollectibleScanPage = {
|
const scanPage: EndpointCollectibleScanPage = {
|
||||||
image: convertScanToEndpointScanImage(scan, index),
|
image: convertScanToEndpointScanImage(scan, index),
|
||||||
parentPages: convertSourceToEndpointSource({ scans: [collectible] }),
|
|
||||||
slug,
|
slug,
|
||||||
translations:
|
translations:
|
||||||
collectible.translations?.map(({ language, title, description, pretitle, subtitle }) => ({
|
collectible.translations?.map(({ language, title, description, pretitle, subtitle }) => ({
|
||||||
|
@ -63,6 +63,13 @@ export const getBySlugEndpointScanPage: CollectionEndpoint = {
|
||||||
})) ?? [],
|
})) ?? [],
|
||||||
...(isDefined(previousIndex) ? { previousIndex } : {}),
|
...(isDefined(previousIndex) ? { previousIndex } : {}),
|
||||||
...(isDefined(nextIndex) ? { nextIndex } : {}),
|
...(isDefined(nextIndex) ? { nextIndex } : {}),
|
||||||
|
backlinks: [
|
||||||
|
{
|
||||||
|
type: Collections.Collectibles,
|
||||||
|
subpage: "scans",
|
||||||
|
value: convertCollectibleToEndpointCollectiblePreview(collectible),
|
||||||
|
},
|
||||||
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
res.status(200).send(scanPage);
|
res.status(200).send(scanPage);
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
import { createGetByEndpoint } from "src/endpoints/createGetByEndpoint";
|
import { createGetByEndpoint } from "../../../endpoints/createGetByEndpoint";
|
||||||
import { Collections } from "src/shared/payload/constants";
|
import { Collections } from "../../../shared/payload/constants";
|
||||||
import { EndpointCollectibleScans } from "src/shared/payload/endpoint-types";
|
import { EndpointCollectibleScans } from "../../../shared/payload/endpoint-types";
|
||||||
import { Collectible } from "src/types/collections";
|
import { Collectible } from "../../../types/collections";
|
||||||
import { isPayloadType, isNotEmpty, isImage, isScan } from "src/utils/asserts";
|
import { isImage, isNotEmpty, isPayloadType, isScan } from "../../../utils/asserts";
|
||||||
import {
|
import {
|
||||||
convertImageToEndpointPayloadImage,
|
|
||||||
convertSourceToEndpointSource,
|
|
||||||
convertCreditsToEndpointCredits,
|
convertCreditsToEndpointCredits,
|
||||||
|
convertImageToEndpointPayloadImage,
|
||||||
convertScanToEndpointScanImage,
|
convertScanToEndpointScanImage,
|
||||||
} from "src/utils/endpoints";
|
} from "../../../utils/endpoints";
|
||||||
|
import { convertCollectibleToEndpointCollectiblePreview } from "./getBySlugEndpoint";
|
||||||
|
|
||||||
export const getBySlugEndpointScans = createGetByEndpoint({
|
export const getBySlugEndpointScans = createGetByEndpoint({
|
||||||
collection: Collections.Collectibles,
|
collection: Collections.Collectibles,
|
||||||
|
@ -29,7 +29,12 @@ export const getBySlugEndpointScans = createGetByEndpoint({
|
||||||
})) ?? [],
|
})) ?? [],
|
||||||
...(isImage(thumbnail) ? { thumbnail: convertImageToEndpointPayloadImage(thumbnail) } : {}),
|
...(isImage(thumbnail) ? { thumbnail: convertImageToEndpointPayloadImage(thumbnail) } : {}),
|
||||||
...(scansEnabled && scans ? handleScans(scans) : { credits: [], pages: [] }),
|
...(scansEnabled && scans ? handleScans(scans) : { credits: [], pages: [] }),
|
||||||
parentPages: convertSourceToEndpointSource({ collectibles: [collectible] }),
|
backlinks: [
|
||||||
|
{
|
||||||
|
type: Collections.Collectibles,
|
||||||
|
value: convertCollectibleToEndpointCollectiblePreview(collectible),
|
||||||
|
},
|
||||||
|
],
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { CollectionConfig } from "payload/types";
|
import { CollectionConfig } from "payload/types";
|
||||||
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";
|
import { Collections, CollectionGroups } from "../../shared/payload/constants";
|
||||||
|
|
||||||
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 { 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 { Collections, CollectionGroups } from "../../shared/payload/constants";
|
||||||
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 "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";
|
import { Collections } from "../../../shared/payload/constants";
|
||||||
|
|
||||||
export const getAllEndpoint: CollectionEndpoint = {
|
export const getAllEndpoint: CollectionEndpoint = {
|
||||||
method: "get",
|
method: "get",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { createStrapiImportEndpoint } from "src/endpoints/createStrapiImportEndpoint";
|
import { createStrapiImportEndpoint } from "../../../endpoints/createStrapiImportEndpoint";
|
||||||
import { Collections } from "src/shared/payload/constants";
|
import { Collections } from "../../../shared/payload/constants";
|
||||||
|
|
||||||
type StrapiLanguage = {
|
type StrapiLanguage = {
|
||||||
code: string;
|
code: string;
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
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 { CollectionGroups, Collections } from "../../shared/payload/constants";
|
||||||
import { buildCollectionConfig } from "src/utils/collectionConfig";
|
import { buildCollectionConfig } from "../../utils/collectionConfig";
|
||||||
import { createEditor } from "src/utils/editor";
|
import { createEditor } from "../../utils/editor";
|
||||||
import { getByID } from "./endpoints/getByID";
|
import { getByID } from "./endpoints/getByID";
|
||||||
|
|
||||||
const fields = {
|
const fields = {
|
||||||
|
|
|
@ -1,16 +1,22 @@
|
||||||
import payload from "payload";
|
import payload from "payload";
|
||||||
import { Collections } from "src/shared/payload/constants";
|
import { File } from "../../../types/collections";
|
||||||
import { PayloadMedia, EndpointFilePreview, EndpointFile } from "src/shared/payload/endpoint-types";
|
import { CollectionEndpoint } from "../../../types/payload";
|
||||||
import { CollectionEndpoint } from "src/types/payload";
|
import { isFile, isMediaThumbnail, isNotEmpty } from "../../../utils/asserts";
|
||||||
import { isFile, isNotEmpty, isMediaThumbnail } from "src/utils/asserts";
|
|
||||||
import {
|
import {
|
||||||
convertAttributesToEndpointAttributes,
|
convertAttributesToEndpointAttributes,
|
||||||
getLanguageId,
|
convertCreditsToEndpointCredits,
|
||||||
convertMediaThumbnailToEndpointPayloadImage,
|
convertMediaThumbnailToEndpointPayloadImage,
|
||||||
convertRTCToEndpointRTC,
|
convertRTCToEndpointRTC,
|
||||||
convertCreditsToEndpointCredits,
|
convertRelationshipsToEndpointRelations,
|
||||||
} from "src/utils/endpoints";
|
getLanguageId,
|
||||||
import { File } from "src/types/collections";
|
} from "../../../utils/endpoints";
|
||||||
|
import { Collections } from "../../../shared/payload/constants";
|
||||||
|
import {
|
||||||
|
PayloadMedia,
|
||||||
|
EndpointFilePreview,
|
||||||
|
EndpointFile,
|
||||||
|
} from "../../../shared/payload/endpoint-types";
|
||||||
|
import { findIncomingRelationships } from "payloadcms-relationships";
|
||||||
|
|
||||||
export const getByID: CollectionEndpoint = {
|
export const getByID: CollectionEndpoint = {
|
||||||
method: "get",
|
method: "get",
|
||||||
|
@ -40,7 +46,7 @@ export const getByID: CollectionEndpoint = {
|
||||||
return res.sendStatus(404);
|
return res.sendStatus(404);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res.status(200).json(convertFileToEndpointFile(result));
|
return res.status(200).json(await convertFileToEndpointFile(result));
|
||||||
} catch {
|
} catch {
|
||||||
return res.sendStatus(404);
|
return res.sendStatus(404);
|
||||||
}
|
}
|
||||||
|
@ -75,8 +81,8 @@ export const convertFileToEndpointFilePreview = ({
|
||||||
: {}),
|
: {}),
|
||||||
});
|
});
|
||||||
|
|
||||||
const convertFileToEndpointFile = (file: File & PayloadMedia): EndpointFile => {
|
const convertFileToEndpointFile = async (file: File & PayloadMedia): Promise<EndpointFile> => {
|
||||||
const { translations, createdAt, updatedAt, filesize, credits } = file;
|
const { translations, createdAt, updatedAt, filesize, credits, id } = file;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...convertFileToEndpointFilePreview(file),
|
...convertFileToEndpointFilePreview(file),
|
||||||
|
@ -92,5 +98,8 @@ const convertFileToEndpointFile = (file: File & PayloadMedia): EndpointFile => {
|
||||||
...(isNotEmpty(description) ? { description: convertRTCToEndpointRTC(description) } : {}),
|
...(isNotEmpty(description) ? { description: convertRTCToEndpointRTC(description) } : {}),
|
||||||
})) ?? [],
|
})) ?? [],
|
||||||
credits: convertCreditsToEndpointCredits(credits),
|
credits: convertCreditsToEndpointCredits(credits),
|
||||||
|
backlinks: convertRelationshipsToEndpointRelations(
|
||||||
|
await findIncomingRelationships(Collections.Files, id)
|
||||||
|
),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,13 +1,10 @@
|
||||||
import { backPropagationField } from "src/fields/backPropagationField/backPropagationField";
|
import { iconField } from "../../fields/iconField/iconField";
|
||||||
import { iconField } from "src/fields/iconField/iconField";
|
import { rowField } from "../../fields/rowField/rowField";
|
||||||
import { rowField } from "src/fields/rowField/rowField";
|
import { slugField } from "../../fields/slugField/slugField";
|
||||||
import { slugField } from "src/fields/slugField/slugField";
|
import { translatedFields } from "../../fields/translatedFields/translatedFields";
|
||||||
import { translatedFields } from "src/fields/translatedFields/translatedFields";
|
import { Collections, CollectionGroups } from "../../shared/payload/constants";
|
||||||
import { Collections, CollectionGroups } from "src/shared/payload/constants";
|
import { buildCollectionConfig } from "../../utils/collectionConfig";
|
||||||
import { Folder } from "src/types/collections";
|
import { createEditor } from "../../utils/editor";
|
||||||
import { isPayloadType } from "src/utils/asserts";
|
|
||||||
import { buildCollectionConfig } from "src/utils/collectionConfig";
|
|
||||||
import { createEditor } from "src/utils/editor";
|
|
||||||
import { getBySlugEndpoint } from "./endpoints/getBySlugEndpoint";
|
import { getBySlugEndpoint } from "./endpoints/getBySlugEndpoint";
|
||||||
|
|
||||||
const fields = {
|
const fields = {
|
||||||
|
@ -44,16 +41,7 @@ export const Folders = buildCollectionConfig({
|
||||||
},
|
},
|
||||||
endpoints: [getBySlugEndpoint],
|
endpoints: [getBySlugEndpoint],
|
||||||
fields: [
|
fields: [
|
||||||
rowField([
|
rowField([slugField({ name: fields.slug }), iconField({ name: fields.icon })]),
|
||||||
slugField({ name: fields.slug }),
|
|
||||||
iconField({ name: fields.icon }),
|
|
||||||
backPropagationField({
|
|
||||||
name: fields.parentFolders,
|
|
||||||
relationTo: Collections.Folders,
|
|
||||||
hasMany: true,
|
|
||||||
where: ({ id }) => ({ "sections.subfolders": { equals: id } }),
|
|
||||||
}),
|
|
||||||
]),
|
|
||||||
translatedFields({
|
translatedFields({
|
||||||
name: fields.translations,
|
name: fields.translations,
|
||||||
admin: { useAsTitle: fields.translationsName },
|
admin: { useAsTitle: fields.translationsName },
|
||||||
|
@ -112,21 +100,4 @@ export const Folders = buildCollectionConfig({
|
||||||
hasMany: true,
|
hasMany: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
custom: {
|
|
||||||
getBackPropagatedRelationships: ({ files, sections }: Folder) => {
|
|
||||||
const result: string[] = [];
|
|
||||||
files?.forEach(({ relationTo, value }) => {
|
|
||||||
if (relationTo === "collectibles" || relationTo === "pages") {
|
|
||||||
result.push(isPayloadType(value) ? value.id : value);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
sections?.forEach(({ subfolders }) =>
|
|
||||||
subfolders?.forEach((folder) => {
|
|
||||||
result.push(isPayloadType(folder) ? folder.id : folder);
|
|
||||||
})
|
|
||||||
);
|
|
||||||
return result;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,24 +1,25 @@
|
||||||
import { convertAudioToEndpointAudioPreview } from "src/collections/Audios/endpoints/getByID";
|
import { createGetByEndpoint } from "../../../endpoints/createGetByEndpoint";
|
||||||
import { convertCollectibleToEndpointCollectiblePreview } from "src/collections/Collectibles/endpoints/getBySlugEndpoint";
|
import { findIncomingRelationships } from "payloadcms-relationships";
|
||||||
import { convertFileToEndpointFilePreview } from "src/collections/Files/endpoints/getByID";
|
import { Collections } from "../../../shared/payload/constants";
|
||||||
import { convertImageToEndpointImagePreview } from "src/collections/Images/endpoints/getByID";
|
import { EndpointFolderPreview, EndpointFolder } from "../../../shared/payload/endpoint-types";
|
||||||
import { convertPageToEndpointPagePreview } from "src/collections/Pages/endpoints/getBySlugEndpoint";
|
import { Folder, Language } from "../../../types/collections";
|
||||||
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,
|
||||||
isFile,
|
} from "../../../utils/asserts";
|
||||||
} from "src/utils/asserts";
|
import { convertRelationshipsToEndpointRelations, getLanguageId } from "../../../utils/endpoints";
|
||||||
import { getLanguageId, convertSourceToEndpointSource } from "src/utils/endpoints";
|
import { convertAudioToEndpointAudioPreview } from "../../Audios/endpoints/getByID";
|
||||||
|
import { convertCollectibleToEndpointCollectiblePreview } from "../../Collectibles/endpoints/getBySlugEndpoint";
|
||||||
|
import { convertFileToEndpointFilePreview } from "../../Files/endpoints/getByID";
|
||||||
|
import { convertImageToEndpointImagePreview } from "../../Images/endpoints/getByID";
|
||||||
|
import { convertPageToEndpointPagePreview } from "../../Pages/endpoints/getBySlugEndpoint";
|
||||||
|
import { convertVideoToEndpointVideoPreview } from "../../Videos/endpoints/getByID";
|
||||||
|
|
||||||
export const getBySlugEndpoint = createGetByEndpoint({
|
export const getBySlugEndpoint = createGetByEndpoint({
|
||||||
collection: Collections.Folders,
|
collection: Collections.Folders,
|
||||||
|
@ -43,8 +44,8 @@ export const convertFolderToEndpointFolderPreview = ({
|
||||||
})) ?? [],
|
})) ?? [],
|
||||||
});
|
});
|
||||||
|
|
||||||
const convertFolderToEndpointFolder = (folder: Folder): EndpointFolder => {
|
const convertFolderToEndpointFolder = async (folder: Folder): Promise<EndpointFolder> => {
|
||||||
const { translations, sections, files, parentFolders } = folder;
|
const { translations, sections, files, id } = folder;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...convertFolderToEndpointFolderPreview(folder),
|
...convertFolderToEndpointFolderPreview(folder),
|
||||||
|
@ -116,7 +117,9 @@ const convertFolderToEndpointFolder = (folder: Folder): EndpointFolder => {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}) ?? [],
|
}) ?? [],
|
||||||
parentPages: convertSourceToEndpointSource({ folders: parentFolders }),
|
backlinks: convertRelationshipsToEndpointRelations(
|
||||||
|
await findIncomingRelationships(Collections.Folders, id)
|
||||||
|
),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { CollectionConfig } from "payload/types";
|
import { CollectionConfig } from "payload/types";
|
||||||
import { QuickFilters, languageBasedFilters } from "src/components/QuickFilters";
|
import { QuickFilters, languageBasedFilters } from "../../components/QuickFilters";
|
||||||
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";
|
import { Collections, CollectionGroups } from "../../shared/payload/constants";
|
||||||
|
|
||||||
const fields = {
|
const fields = {
|
||||||
name: "name",
|
name: "name",
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
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 { Collections } from "../../shared/payload/constants";
|
||||||
import { createEditor } from "src/utils/editor";
|
import { createEditor } from "../../utils/editor";
|
||||||
import {
|
import {
|
||||||
buildImageCollectionConfig,
|
buildImageCollectionConfig,
|
||||||
generateOpenGraphSize,
|
generateOpenGraphSize,
|
||||||
generateWebpSize,
|
generateWebpSize,
|
||||||
} from "src/utils/imageCollectionConfig";
|
} from "../../utils/imageCollectionConfig";
|
||||||
import { getByID } from "./endpoints/getByID";
|
import { getByID } from "./endpoints/getByID";
|
||||||
|
|
||||||
const fields = {
|
const fields = {
|
||||||
|
@ -36,6 +36,7 @@ export const Images = buildImageCollectionConfig({
|
||||||
admin: {
|
admin: {
|
||||||
preview: ({ id }) => `${process.env.PAYLOAD_PUBLIC_FRONTEND_BASE_URL}/en/images/${id}`,
|
preview: ({ id }) => `${process.env.PAYLOAD_PUBLIC_FRONTEND_BASE_URL}/en/images/${id}`,
|
||||||
defaultColumns: [fields.filename, fields.posts, fields.updatedAt],
|
defaultColumns: [fields.filename, fields.posts, fields.updatedAt],
|
||||||
|
useAsTitle: fields.filename,
|
||||||
},
|
},
|
||||||
upload: {
|
upload: {
|
||||||
imageSizes: [
|
imageSizes: [
|
||||||
|
|
|
@ -1,20 +1,22 @@
|
||||||
import payload from "payload";
|
import payload from "payload";
|
||||||
import { Collections } from "src/shared/payload/constants";
|
import { Image } from "../../../types/collections";
|
||||||
|
import { CollectionEndpoint } from "../../../types/payload";
|
||||||
|
import { isImage, isNotEmpty, isPayloadImage } from "../../../utils/asserts";
|
||||||
|
import {
|
||||||
|
convertAttributesToEndpointAttributes,
|
||||||
|
convertCreditsToEndpointCredits,
|
||||||
|
convertRTCToEndpointRTC,
|
||||||
|
convertRelationshipsToEndpointRelations,
|
||||||
|
convertSizesToPayloadImages,
|
||||||
|
getLanguageId,
|
||||||
|
} from "../../../utils/endpoints";
|
||||||
|
import { Collections } from "../../../shared/payload/constants";
|
||||||
import {
|
import {
|
||||||
PayloadImage,
|
PayloadImage,
|
||||||
EndpointImagePreview,
|
EndpointImagePreview,
|
||||||
EndpointImage,
|
EndpointImage,
|
||||||
} from "src/shared/payload/endpoint-types";
|
} from "../../../shared/payload/endpoint-types";
|
||||||
import { CollectionEndpoint } from "src/types/payload";
|
import { findIncomingRelationships } from "payloadcms-relationships";
|
||||||
import { isImage, isNotEmpty, isPayloadImage } from "src/utils/asserts";
|
|
||||||
import {
|
|
||||||
convertAttributesToEndpointAttributes,
|
|
||||||
getLanguageId,
|
|
||||||
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",
|
||||||
|
@ -44,7 +46,7 @@ export const getByID: CollectionEndpoint = {
|
||||||
return res.sendStatus(404);
|
return res.sendStatus(404);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res.status(200).json(convertImageToEndpointImage(result));
|
return res.status(200).json(await convertImageToEndpointImage(result));
|
||||||
} catch {
|
} catch {
|
||||||
return res.sendStatus(404);
|
return res.sendStatus(404);
|
||||||
}
|
}
|
||||||
|
@ -93,8 +95,10 @@ export const convertImageToEndpointImagePreview = ({
|
||||||
...(isPayloadImage(sizes?.og) ? { openGraph: sizes.og } : {}),
|
...(isPayloadImage(sizes?.og) ? { openGraph: sizes.og } : {}),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const convertImageToEndpointImage = (image: Image & PayloadImage): EndpointImage => {
|
export const convertImageToEndpointImage = async (
|
||||||
const { translations, createdAt, updatedAt, filesize, credits } = image;
|
image: Image & PayloadImage
|
||||||
|
): Promise<EndpointImage> => {
|
||||||
|
const { translations, createdAt, updatedAt, filesize, credits, id } = image;
|
||||||
return {
|
return {
|
||||||
...convertImageToEndpointImagePreview(image),
|
...convertImageToEndpointImagePreview(image),
|
||||||
createdAt,
|
createdAt,
|
||||||
|
@ -109,5 +113,8 @@ export const convertImageToEndpointImage = (image: Image & PayloadImage): Endpoi
|
||||||
...(isNotEmpty(description) ? { description: convertRTCToEndpointRTC(description) } : {}),
|
...(isNotEmpty(description) ? { description: convertRTCToEndpointRTC(description) } : {}),
|
||||||
})) ?? [],
|
})) ?? [],
|
||||||
credits: convertCreditsToEndpointCredits(credits),
|
credits: convertCreditsToEndpointCredits(credits),
|
||||||
|
backlinks: convertRelationshipsToEndpointRelations(
|
||||||
|
await findIncomingRelationships(Collections.Images, id)
|
||||||
|
),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
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 { rowField } from "../../fields/rowField/rowField";
|
||||||
|
import { buildCollectionConfig } from "../../utils/collectionConfig";
|
||||||
import { getAllEndpoint } from "./endpoints/getAllEndpoint";
|
import { getAllEndpoint } from "./endpoints/getAllEndpoint";
|
||||||
import { shownOnlyToAdmin } from "src/accesses/collections/shownOnlyToAdmin";
|
import { importFromStrapi } from "./endpoints/importFromStrapi";
|
||||||
import { mustBeAdmin } from "src/accesses/fields/mustBeAdmin";
|
import { Collections, CollectionGroups } from "../../shared/payload/constants";
|
||||||
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",
|
||||||
|
@ -29,7 +30,7 @@ export const Languages = buildCollectionConfig({
|
||||||
},
|
},
|
||||||
access: { create: mustBeAdmin, update: mustBeAdmin, delete: mustBeAdmin },
|
access: { create: mustBeAdmin, update: mustBeAdmin, delete: mustBeAdmin },
|
||||||
timestamps: false,
|
timestamps: false,
|
||||||
endpoints: [getAllEndpoint],
|
endpoints: [importFromStrapi, getAllEndpoint],
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
name: fields.id,
|
name: fields.id,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import payload from "payload";
|
import payload from "payload";
|
||||||
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";
|
import { Collections } from "../../../shared/payload/constants";
|
||||||
|
|
||||||
export const getAllEndpoint: CollectionEndpoint = {
|
export const getAllEndpoint: CollectionEndpoint = {
|
||||||
method: "get",
|
method: "get",
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
import { createStrapiImportEndpoint } from "../../../endpoints/createStrapiImportEndpoint";
|
||||||
|
import { Collections } from "../../../shared/payload/constants";
|
||||||
|
|
||||||
|
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 "src/accesses/collections/shownOnlyToAdmin";
|
import { shownOnlyToAdmin } from "../../accesses/collections/shownOnlyToAdmin";
|
||||||
import { createImageSizesRegenerationEndpoint } from "src/endpoints/imageSizesRegenerationEndpoint";
|
import { createImageSizesRegenerationEndpoint } from "../../endpoints/imageSizesRegenerationEndpoint";
|
||||||
import { Collections } from "src/shared/payload/constants";
|
import { Collections } from "../../shared/payload/constants";
|
||||||
import {
|
import {
|
||||||
buildImageCollectionConfig,
|
buildImageCollectionConfig,
|
||||||
generateOpenGraphSize,
|
generateOpenGraphSize,
|
||||||
generateWebpSize,
|
generateWebpSize,
|
||||||
} from "src/utils/imageCollectionConfig";
|
} from "../../utils/imageCollectionConfig";
|
||||||
|
|
||||||
const fields = {
|
const fields = {
|
||||||
filename: "filename",
|
filename: "filename",
|
||||||
|
|
|
@ -1,22 +1,20 @@
|
||||||
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 { attributesField } from "../../fields/attributesField/attributesField";
|
||||||
|
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 { Collections, CollectionGroups } from "../../shared/payload/constants";
|
||||||
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",
|
||||||
|
@ -31,8 +29,7 @@ const fields = {
|
||||||
summary: "summary",
|
summary: "summary",
|
||||||
content: "content",
|
content: "content",
|
||||||
credits: "credits",
|
credits: "credits",
|
||||||
collectibles: "collectibles",
|
sourceUrls: "sourceUrls",
|
||||||
folders: "folders",
|
|
||||||
} as const satisfies Record<string, string>;
|
} as const satisfies Record<string, string>;
|
||||||
|
|
||||||
export const Pages = buildVersionedCollectionConfig({
|
export const Pages = buildVersionedCollectionConfig({
|
||||||
|
@ -44,13 +41,7 @@ export const Pages = buildVersionedCollectionConfig({
|
||||||
defaultSort: fields.slug,
|
defaultSort: fields.slug,
|
||||||
admin: {
|
admin: {
|
||||||
useAsTitle: fields.slug,
|
useAsTitle: fields.slug,
|
||||||
defaultColumns: [
|
defaultColumns: [fields.slug, fields.thumbnail, fields.backgroundImage, fields.translations],
|
||||||
fields.slug,
|
|
||||||
fields.thumbnail,
|
|
||||||
fields.backgroundImage,
|
|
||||||
fields.translations,
|
|
||||||
fields.folders,
|
|
||||||
],
|
|
||||||
group: CollectionGroups.Collections,
|
group: CollectionGroups.Collections,
|
||||||
preview: ({ slug }) => `${process.env.PAYLOAD_PUBLIC_FRONTEND_BASE_URL}/en/pages/${slug}`,
|
preview: ({ slug }) => `${process.env.PAYLOAD_PUBLIC_FRONTEND_BASE_URL}/en/pages/${slug}`,
|
||||||
components: {
|
components: {
|
||||||
|
@ -123,31 +114,18 @@ export const Pages = buildVersionedCollectionConfig({
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
creditsField({ name: fields.credits }),
|
creditsField({ name: fields.credits }),
|
||||||
|
{
|
||||||
|
name: fields.sourceUrls,
|
||||||
|
label: "Source URLs",
|
||||||
|
type: "text",
|
||||||
|
hasMany: true,
|
||||||
|
admin: {
|
||||||
|
description:
|
||||||
|
"If the content originates from an external source (e.g: fandom.com, an online interview...) you can add a link to the original page(s) here",
|
||||||
|
width: "50%",
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
rowField([
|
|
||||||
backPropagationField({
|
|
||||||
name: fields.folders,
|
|
||||||
relationTo: Collections.Folders,
|
|
||||||
hasMany: true,
|
|
||||||
where: ({ id }) => ({
|
|
||||||
and: [
|
|
||||||
{ "files.value": { equals: id } },
|
|
||||||
{ "files.relationTo": { equals: Collections.Pages } },
|
|
||||||
] as Where[],
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
backPropagationField({
|
|
||||||
name: fields.collectibles,
|
|
||||||
hasMany: true,
|
|
||||||
relationTo: Collections.Collectibles,
|
|
||||||
where: ({ id }) => ({
|
|
||||||
and: [
|
|
||||||
{ "contents.content.value": { equals: id } },
|
|
||||||
{ "contents.content.relationTo": { equals: Collections.Pages } },
|
|
||||||
] as Where[],
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
]),
|
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,26 +1,28 @@
|
||||||
import { convertRecorderToEndpointRecorderPreview } from "src/collections/Recorders/endpoints/getByID";
|
import { createGetByEndpoint } from "../../../endpoints/createGetByEndpoint";
|
||||||
import { createGetByEndpoint } from "src/endpoints/createGetByEndpoint";
|
import { findIncomingRelationships } from "payloadcms-relationships";
|
||||||
import { Collections, BreakBlockType } from "src/shared/payload/constants";
|
import { Collections, BreakBlockType } from "../../../shared/payload/constants";
|
||||||
import {
|
import {
|
||||||
EndpointPagePreview,
|
EndpointPagePreview,
|
||||||
EndpointPage,
|
EndpointPage,
|
||||||
TableOfContentEntry,
|
TableOfContentEntry,
|
||||||
} from "src/shared/payload/endpoint-types";
|
} from "../../../shared/payload/endpoint-types";
|
||||||
import {
|
import {
|
||||||
RichTextContent,
|
RichTextContent,
|
||||||
isNodeBlockNode,
|
isNodeBlockNode,
|
||||||
isBlockNodeSectionBlock,
|
isBlockNodeSectionBlock,
|
||||||
isBlockNodeBreakBlock,
|
isBlockNodeBreakBlock,
|
||||||
} from "src/shared/payload/rich-text";
|
} from "../../../shared/payload/rich-text";
|
||||||
import { Page } from "src/types/collections";
|
import { Page } from "../../../types/collections";
|
||||||
import { isImage, isPayloadType, isNotEmpty } from "src/utils/asserts";
|
import { isImage, isNotEmpty, isPayloadType } from "../../../utils/asserts";
|
||||||
import {
|
import {
|
||||||
convertImageToEndpointPayloadImage,
|
|
||||||
convertAttributesToEndpointAttributes,
|
convertAttributesToEndpointAttributes,
|
||||||
convertRTCToEndpointRTC,
|
|
||||||
convertCreditsToEndpointCredits,
|
convertCreditsToEndpointCredits,
|
||||||
convertSourceToEndpointSource,
|
convertImageToEndpointPayloadImage,
|
||||||
} from "src/utils/endpoints";
|
convertRTCToEndpointRTC,
|
||||||
|
convertRelationshipsToEndpointRelations,
|
||||||
|
getDomainFromUrl,
|
||||||
|
} from "../../../utils/endpoints";
|
||||||
|
import { convertRecorderToEndpointRecorderPreview } from "../../Recorders/endpoints/getByID";
|
||||||
|
|
||||||
export const getBySlugEndpoint = createGetByEndpoint({
|
export const getBySlugEndpoint = createGetByEndpoint({
|
||||||
collection: Collections.Pages,
|
collection: Collections.Pages,
|
||||||
|
@ -49,8 +51,8 @@ export const convertPageToEndpointPagePreview = ({
|
||||||
updatedAt,
|
updatedAt,
|
||||||
});
|
});
|
||||||
|
|
||||||
const convertPageToEndpointPage = (page: Page): EndpointPage => {
|
const convertPageToEndpointPage = async (page: Page): Promise<EndpointPage> => {
|
||||||
const { translations, collectibles, folders, backgroundImage, createdAt, updatedBy } = page;
|
const { translations, backgroundImage, createdAt, updatedBy, id } = page;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...convertPageToEndpointPagePreview(page),
|
...convertPageToEndpointPagePreview(page),
|
||||||
|
@ -58,7 +60,17 @@ const convertPageToEndpointPage = (page: Page): EndpointPage => {
|
||||||
? { backgroundImage: convertImageToEndpointPayloadImage(backgroundImage) }
|
? { backgroundImage: convertImageToEndpointPayloadImage(backgroundImage) }
|
||||||
: {}),
|
: {}),
|
||||||
translations: translations.map(
|
translations: translations.map(
|
||||||
({ content, language, sourceLanguage, title, pretitle, subtitle, summary, credits }) => ({
|
({
|
||||||
|
content,
|
||||||
|
language,
|
||||||
|
sourceLanguage,
|
||||||
|
title,
|
||||||
|
pretitle,
|
||||||
|
subtitle,
|
||||||
|
summary,
|
||||||
|
credits,
|
||||||
|
sourceUrls,
|
||||||
|
}) => ({
|
||||||
language: isPayloadType(language) ? language.id : language,
|
language: isPayloadType(language) ? language.id : language,
|
||||||
sourceLanguage: isPayloadType(sourceLanguage) ? sourceLanguage.id : sourceLanguage,
|
sourceLanguage: isPayloadType(sourceLanguage) ? sourceLanguage.id : sourceLanguage,
|
||||||
...(isNotEmpty(pretitle) ? { pretitle } : {}),
|
...(isNotEmpty(pretitle) ? { pretitle } : {}),
|
||||||
|
@ -68,13 +80,20 @@ const convertPageToEndpointPage = (page: Page): EndpointPage => {
|
||||||
content: convertRTCToEndpointRTC(content),
|
content: convertRTCToEndpointRTC(content),
|
||||||
toc: handleToc(content),
|
toc: handleToc(content),
|
||||||
credits: convertCreditsToEndpointCredits(credits),
|
credits: convertCreditsToEndpointCredits(credits),
|
||||||
|
sourceUrls:
|
||||||
|
sourceUrls?.map((url) => ({
|
||||||
|
url,
|
||||||
|
label: getDomainFromUrl(url),
|
||||||
|
})) ?? [],
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
createdAt,
|
createdAt,
|
||||||
...(isPayloadType(updatedBy)
|
...(isPayloadType(updatedBy)
|
||||||
? { updatedBy: convertRecorderToEndpointRecorderPreview(updatedBy) }
|
? { updatedBy: convertRecorderToEndpointRecorderPreview(updatedBy) }
|
||||||
: {}),
|
: {}),
|
||||||
parentPages: convertSourceToEndpointSource({ collectibles, folders }),
|
backlinks: convertRelationshipsToEndpointRelations(
|
||||||
|
await findIncomingRelationships(Collections.Pages, id)
|
||||||
|
),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
import { mustBeAdminOrSelf } from "src/accesses/collections/mustBeAdminOrSelf";
|
import { mustBeAdmin as mustBeAdminForCollections } from "../../accesses/collections/mustBeAdmin";
|
||||||
import { QuickFilters } from "src/components/QuickFilters";
|
import { mustBeAdminOrSelf } from "../../accesses/collections/mustBeAdminOrSelf";
|
||||||
import { imageField } from "src/fields/imageField/imageField";
|
import { mustBeAdmin as mustBeAdminForFields } from "../../accesses/fields/mustBeAdmin";
|
||||||
import { rowField } from "src/fields/rowField/rowField";
|
import { QuickFilters } from "../../components/QuickFilters";
|
||||||
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 { Collections, CollectionGroups, RecordersRoles } from "../../shared/payload/constants";
|
||||||
|
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,10 +1,13 @@
|
||||||
import payload from "payload";
|
import payload from "payload";
|
||||||
import { Collections } from "src/shared/payload/constants";
|
import { Recorder } from "../../../types/collections";
|
||||||
import { EndpointRecorderPreview, EndpointRecorder } from "src/shared/payload/endpoint-types";
|
import { CollectionEndpoint } from "../../../types/payload";
|
||||||
import { Recorder } from "src/types/collections";
|
import { isImage, isPayloadType } from "../../../utils/asserts";
|
||||||
import { CollectionEndpoint } from "src/types/payload";
|
import {
|
||||||
import { isPayloadType, isImage } from "src/utils/asserts";
|
convertImageToEndpointPayloadImage,
|
||||||
import { convertImageToEndpointPayloadImage, convertRTCToEndpointRTC } from "src/utils/endpoints";
|
convertRTCToEndpointRTC,
|
||||||
|
} from "../../../utils/endpoints";
|
||||||
|
import { Collections } from "../../../shared/payload/constants";
|
||||||
|
import { EndpointRecorderPreview, EndpointRecorder } from "../../../shared/payload/endpoint-types";
|
||||||
|
|
||||||
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 { 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";
|
import { Collections } from "../../../shared/payload/constants";
|
||||||
|
|
||||||
type StrapiRecorder = {
|
type StrapiRecorder = {
|
||||||
username: string;
|
username: string;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { shownOnlyToAdmin } from "src/accesses/collections/shownOnlyToAdmin";
|
import { shownOnlyToAdmin } from "../../accesses/collections/shownOnlyToAdmin";
|
||||||
import { createImageSizesRegenerationEndpoint } from "src/endpoints/imageSizesRegenerationEndpoint";
|
import { createImageSizesRegenerationEndpoint } from "../../endpoints/imageSizesRegenerationEndpoint";
|
||||||
import { Collections } from "src/shared/payload/constants";
|
import { Collections } from "../../shared/payload/constants";
|
||||||
import { buildImageCollectionConfig, generateWebpSize } from "src/utils/imageCollectionConfig";
|
import { buildImageCollectionConfig, generateWebpSize } from "../../utils/imageCollectionConfig";
|
||||||
|
|
||||||
const fields = {
|
const fields = {
|
||||||
filename: "filename",
|
filename: "filename",
|
||||||
|
@ -17,6 +17,7 @@ export const Scans = buildImageCollectionConfig({
|
||||||
plural: "Scans",
|
plural: "Scans",
|
||||||
},
|
},
|
||||||
admin: {
|
admin: {
|
||||||
|
useAsTitle: fields.filename,
|
||||||
defaultColumns: [fields.filename, fields.updatedAt],
|
defaultColumns: [fields.filename, fields.updatedAt],
|
||||||
hidden: shownOnlyToAdmin,
|
hidden: shownOnlyToAdmin,
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { CollectionConfig } from "payload/types";
|
import { CollectionConfig } from "payload/types";
|
||||||
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";
|
import { Collections, CollectionGroups } from "../../shared/payload/constants";
|
||||||
|
|
||||||
const fields = {
|
const fields = {
|
||||||
slug: "slug",
|
slug: "slug",
|
||||||
|
|
|
@ -1,14 +1,12 @@
|
||||||
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 { Collections, CollectionGroups } from "../../shared/payload/constants";
|
||||||
import { Video } from "src/types/collections";
|
import { buildCollectionConfig } from "../../utils/collectionConfig";
|
||||||
import { isPayloadType } from "src/utils/asserts";
|
import { createEditor } from "../../utils/editor";
|
||||||
import { buildCollectionConfig } from "src/utils/collectionConfig";
|
|
||||||
import { createEditor } from "src/utils/editor";
|
|
||||||
import { getByID } from "./endpoints/getByID";
|
import { getByID } from "./endpoints/getByID";
|
||||||
|
|
||||||
const fields = {
|
const fields = {
|
||||||
|
@ -40,6 +38,7 @@ export const Videos = buildCollectionConfig({
|
||||||
labels: { singular: "Video", plural: "Videos" },
|
labels: { singular: "Video", plural: "Videos" },
|
||||||
defaultSort: fields.filename,
|
defaultSort: fields.filename,
|
||||||
admin: {
|
admin: {
|
||||||
|
useAsTitle: fields.filename,
|
||||||
group: CollectionGroups.Media,
|
group: CollectionGroups.Media,
|
||||||
preview: ({ id }) => `${process.env.PAYLOAD_PUBLIC_FRONTEND_BASE_URL}/en/videos/${id}`,
|
preview: ({ id }) => `${process.env.PAYLOAD_PUBLIC_FRONTEND_BASE_URL}/en/videos/${id}`,
|
||||||
defaultColumns: [
|
defaultColumns: [
|
||||||
|
@ -129,12 +128,4 @@ export const Videos = buildCollectionConfig({
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
custom: {
|
|
||||||
getBackPropagatedRelationships: ({ platform, platformEnabled }: Video) => {
|
|
||||||
if (!platform || !platformEnabled) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
return [isPayloadType(platform.channel) ? platform.channel.id : platform.channel];
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,28 +1,30 @@
|
||||||
import payload from "payload";
|
import payload from "payload";
|
||||||
import { Collections } from "src/shared/payload/constants";
|
import { Video } from "../../../types/collections";
|
||||||
|
import { CollectionEndpoint } from "../../../types/payload";
|
||||||
|
import {
|
||||||
|
isDefined,
|
||||||
|
isEmpty,
|
||||||
|
isMediaThumbnail,
|
||||||
|
isNotEmpty,
|
||||||
|
isPayloadType,
|
||||||
|
isUndefined,
|
||||||
|
isVideo,
|
||||||
|
} from "../../../utils/asserts";
|
||||||
|
import {
|
||||||
|
convertAttributesToEndpointAttributes,
|
||||||
|
convertCreditsToEndpointCredits,
|
||||||
|
convertMediaThumbnailToEndpointPayloadImage,
|
||||||
|
convertRTCToEndpointRTC,
|
||||||
|
convertRelationshipsToEndpointRelations,
|
||||||
|
getLanguageId,
|
||||||
|
} from "../../../utils/endpoints";
|
||||||
|
import { Collections } from "../../../shared/payload/constants";
|
||||||
import {
|
import {
|
||||||
PayloadMedia,
|
PayloadMedia,
|
||||||
EndpointVideoPreview,
|
EndpointVideoPreview,
|
||||||
EndpointVideo,
|
EndpointVideo,
|
||||||
} from "src/shared/payload/endpoint-types";
|
} from "../../../shared/payload/endpoint-types";
|
||||||
import { Video } from "src/types/collections";
|
import { findIncomingRelationships } from "payloadcms-relationships";
|
||||||
import { CollectionEndpoint } from "src/types/payload";
|
|
||||||
import {
|
|
||||||
isVideo,
|
|
||||||
isNotEmpty,
|
|
||||||
isMediaThumbnail,
|
|
||||||
isUndefined,
|
|
||||||
isPayloadType,
|
|
||||||
isEmpty,
|
|
||||||
isDefined,
|
|
||||||
} from "src/utils/asserts";
|
|
||||||
import {
|
|
||||||
convertAttributesToEndpointAttributes,
|
|
||||||
getLanguageId,
|
|
||||||
convertMediaThumbnailToEndpointPayloadImage,
|
|
||||||
convertRTCToEndpointRTC,
|
|
||||||
convertCreditsToEndpointCredits,
|
|
||||||
} from "src/utils/endpoints";
|
|
||||||
|
|
||||||
export const getByID: CollectionEndpoint = {
|
export const getByID: CollectionEndpoint = {
|
||||||
method: "get",
|
method: "get",
|
||||||
|
@ -52,7 +54,7 @@ export const getByID: CollectionEndpoint = {
|
||||||
return res.sendStatus(404);
|
return res.sendStatus(404);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res.status(200).json(convertVideoToEndpointVideo(result));
|
return res.status(200).json(await convertVideoToEndpointVideo(result));
|
||||||
} catch {
|
} catch {
|
||||||
return res.sendStatus(404);
|
return res.sendStatus(404);
|
||||||
}
|
}
|
||||||
|
@ -98,8 +100,8 @@ export const convertVideoToEndpointVideoPreview = ({
|
||||||
}) ?? [],
|
}) ?? [],
|
||||||
});
|
});
|
||||||
|
|
||||||
const convertVideoToEndpointVideo = (video: Video & PayloadMedia): EndpointVideo => {
|
const convertVideoToEndpointVideo = async (video: Video & PayloadMedia): Promise<EndpointVideo> => {
|
||||||
const { translations, createdAt, updatedAt, filesize, platform, platformEnabled, credits } =
|
const { translations, createdAt, updatedAt, filesize, platform, platformEnabled, credits, id } =
|
||||||
video;
|
video;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -125,5 +127,8 @@ const convertVideoToEndpointVideo = (video: Video & PayloadMedia): EndpointVideo
|
||||||
}
|
}
|
||||||
: {}),
|
: {}),
|
||||||
credits: convertCreditsToEndpointCredits(credits),
|
credits: convertCreditsToEndpointCredits(credits),
|
||||||
|
backlinks: convertRelationshipsToEndpointRelations(
|
||||||
|
await findIncomingRelationships(Collections.Videos, id)
|
||||||
|
),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
import { CollectionConfig } from "payload/types";
|
import { CollectionConfig } from "payload/types";
|
||||||
import { backPropagationField } from "src/fields/backPropagationField/backPropagationField";
|
import { rowField } from "../../fields/rowField/rowField";
|
||||||
import { rowField } from "src/fields/rowField/rowField";
|
import { buildCollectionConfig } from "../../utils/collectionConfig";
|
||||||
import { Collections, CollectionGroups } from "src/shared/payload/constants";
|
import { Collections, CollectionGroups } from "../../shared/payload/constants";
|
||||||
import { buildCollectionConfig } from "src/utils/collectionConfig";
|
|
||||||
|
|
||||||
const fields = {
|
const fields = {
|
||||||
url: "url",
|
url: "url",
|
||||||
|
@ -31,11 +30,5 @@ export const VideosChannels: CollectionConfig = buildCollectionConfig({
|
||||||
{ name: fields.title, type: "text", required: true },
|
{ name: fields.title, type: "text", required: true },
|
||||||
{ name: fields.subscribers, type: "number", required: true },
|
{ name: fields.subscribers, type: "number", required: true },
|
||||||
]),
|
]),
|
||||||
backPropagationField({
|
|
||||||
name: fields.videos,
|
|
||||||
relationTo: Collections.Videos,
|
|
||||||
hasMany: true,
|
|
||||||
where: ({ id }) => ({ "platform.channel": { equals: id } }),
|
|
||||||
}),
|
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,13 +1,18 @@
|
||||||
import { shownOnlyToAdmin } from "src/accesses/collections/shownOnlyToAdmin";
|
import { shownOnlyToAdmin } from "../../accesses/collections/shownOnlyToAdmin";
|
||||||
import { Collections, CollectionGroups } from "src/shared/payload/constants";
|
import { Collections, CollectionGroups } from "../../shared/payload/constants";
|
||||||
import { buildCollectionConfig } from "src/utils/collectionConfig";
|
import { buildCollectionConfig } from "../../utils/collectionConfig";
|
||||||
|
|
||||||
export const VideosSubtitles = buildCollectionConfig({
|
export const VideosSubtitles = buildCollectionConfig({
|
||||||
slug: Collections.VideosSubtitles,
|
slug: Collections.VideosSubtitles,
|
||||||
labels: { singular: "Video Subtitle", plural: "Videos Subtitles" },
|
labels: { singular: "Video Subtitle", plural: "Videos Subtitles" },
|
||||||
admin: { group: CollectionGroups.Media, disableDuplicate: true, hidden: shownOnlyToAdmin },
|
admin: {
|
||||||
|
useAsTitle: "filename",
|
||||||
|
group: CollectionGroups.Media,
|
||||||
|
disableDuplicate: true,
|
||||||
|
hidden: shownOnlyToAdmin,
|
||||||
|
},
|
||||||
upload: {
|
upload: {
|
||||||
mimeTypes: ["text/*"],
|
// mimeTypes: ["text/*"], Disable because of a bug on Chrome windows where the MIME is detected as application/octet-stream instead of text/vtt or text/plain
|
||||||
disableLocalStorage: true,
|
disableLocalStorage: true,
|
||||||
},
|
},
|
||||||
timestamps: false,
|
timestamps: false,
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { GlobalConfig } from "payload/types";
|
import { GlobalConfig } from "payload/types";
|
||||||
|
import { mustBeAdmin } from "../../accesses/collections/mustBeAdmin";
|
||||||
|
import { imageField } from "../../fields/imageField/imageField";
|
||||||
|
import { rowField } from "../../fields/rowField/rowField";
|
||||||
import { getConfigEndpoint } from "./endpoints/getConfigEndpoint";
|
import { getConfigEndpoint } from "./endpoints/getConfigEndpoint";
|
||||||
import { mustBeAdmin } from "src/accesses/fields/mustBeAdmin";
|
import { Collections, CollectionGroups } from "../../shared/payload/constants";
|
||||||
import { imageField } from "src/fields/imageField/imageField";
|
import { globalAfterChangeSendChangesWebhook } from "../../hooks/afterOperationSendChangesWebhook";
|
||||||
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",
|
||||||
|
@ -32,7 +32,7 @@ export const WebsiteConfig: GlobalConfig = {
|
||||||
access: { update: mustBeAdmin, read: mustBeAdmin },
|
access: { update: mustBeAdmin, read: mustBeAdmin },
|
||||||
endpoints: [getConfigEndpoint],
|
endpoints: [getConfigEndpoint],
|
||||||
hooks: {
|
hooks: {
|
||||||
afterChange: [globalAfterChangeWebhook],
|
afterChange: [globalAfterChangeSendChangesWebhook],
|
||||||
},
|
},
|
||||||
fields: [
|
fields: [
|
||||||
rowField([
|
rowField([
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import payload from "payload";
|
import payload from "payload";
|
||||||
import { convertFolderToEndpointFolderPreview } from "src/collections/Folders/endpoints/getBySlugEndpoint";
|
import { CollectionEndpoint } from "../../../types/payload";
|
||||||
import { Collections } from "src/shared/payload/constants";
|
import { isImage, isPayloadType } from "../../../utils/asserts";
|
||||||
import { EndpointWebsiteConfig } from "src/shared/payload/endpoint-types";
|
import { convertImageToEndpointPayloadImage } from "../../../utils/endpoints";
|
||||||
import { CollectionEndpoint } from "src/types/payload";
|
import { convertFolderToEndpointFolderPreview } from "../../Folders/endpoints/getBySlugEndpoint";
|
||||||
import { isImage, isPayloadType } from "src/utils/asserts";
|
import { Collections } from "../../../shared/payload/constants";
|
||||||
import { convertImageToEndpointPayloadImage } from "src/utils/endpoints";
|
import { EndpointWebsiteConfig } from "../../../shared/payload/endpoint-types";
|
||||||
|
|
||||||
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 { 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 { Collections, CollectionGroups } from "../../shared/payload/constants";
|
||||||
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 "src/shared/payload/constants";
|
import { CollectionEndpoint } from "../../../types/payload";
|
||||||
import { EndpointWording } from "src/shared/payload/endpoint-types";
|
import { isPayloadType } from "../../../utils/asserts";
|
||||||
import { CollectionEndpoint } from "src/types/payload";
|
import { Collections } from "../../../shared/payload/constants";
|
||||||
import { isPayloadType } from "src/utils/asserts";
|
import { EndpointWording } from "../../../shared/payload/endpoint-types";
|
||||||
|
|
||||||
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 "../shared/payload/constants";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
slug: string;
|
slug: string;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import payload, { GeneratedTypes } from "payload";
|
import payload, { GeneratedTypes } from "payload";
|
||||||
import { CollectionEndpoint } from "src/types/payload";
|
import { CollectionEndpoint } from "../types/payload";
|
||||||
import { isPublished } from "src/utils/asserts";
|
import { isPublished } from "../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 "src/types/collections";
|
import { Recorder } from "../types/collections";
|
||||||
import { CollectionEndpoint } from "src/types/payload";
|
import { CollectionEndpoint } from "../types/payload";
|
||||||
import { isDefined } from "src/utils/asserts";
|
import { isDefined } from "../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,11 +1,27 @@
|
||||||
import payload from "payload";
|
import payload from "payload";
|
||||||
import { Endpoint } from "payload/config";
|
import { Endpoint } from "payload/config";
|
||||||
import { Collections } from "src/shared/payload/constants";
|
import { Collections } from "../shared/payload/constants";
|
||||||
import { EndpointAllIds } from "src/shared/payload/endpoint-types";
|
import { EndpointChange } from "../shared/payload/webhooks";
|
||||||
|
import {
|
||||||
|
getEndpointChangesForAudio,
|
||||||
|
getEndpointChangesForChronologyEvent,
|
||||||
|
getEndpointChangesForCollectible,
|
||||||
|
getEndpointChangesForCurrency,
|
||||||
|
getEndpointChangesForFile,
|
||||||
|
getEndpointChangesForFolder,
|
||||||
|
getEndpointChangesForImage,
|
||||||
|
getEndpointChangesForLanguage,
|
||||||
|
getEndpointChangesForPage,
|
||||||
|
getEndpointChangesForRecorder,
|
||||||
|
getEndpointChangesForVideo,
|
||||||
|
getEndpointChangesForWebsiteConfig,
|
||||||
|
getEndpointChangesForWording,
|
||||||
|
} from "../hooks/afterOperationSendChangesWebhook";
|
||||||
|
import { uniqueBy } from "../utils/array";
|
||||||
|
|
||||||
export const getAllIds: Endpoint = {
|
export const getAllEndpoint: Endpoint = {
|
||||||
method: "get",
|
method: "get",
|
||||||
path: "/all-ids",
|
path: "/all",
|
||||||
handler: async (req, res) => {
|
handler: async (req, res) => {
|
||||||
if (!req.user) {
|
if (!req.user) {
|
||||||
return res.status(403).send({
|
return res.status(403).send({
|
||||||
|
@ -95,18 +111,22 @@ export const getAllIds: Endpoint = {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const result: EndpointAllIds = {
|
const result: EndpointChange[] = [
|
||||||
collectibles: { slugs: collectibles.docs.map(({ slug }) => slug) },
|
...getEndpointChangesForWebsiteConfig(),
|
||||||
pages: { slugs: pages.docs.map(({ slug }) => slug) },
|
...getEndpointChangesForLanguage(),
|
||||||
folders: { slugs: folders.docs.map(({ slug }) => slug) },
|
...getEndpointChangesForCurrency(),
|
||||||
videos: { ids: videos.docs.map(({ id }) => id) },
|
...getEndpointChangesForWording(),
|
||||||
audios: { ids: audios.docs.map(({ id }) => id) },
|
...folders.docs.flatMap(getEndpointChangesForFolder),
|
||||||
images: { ids: images.docs.map(({ id }) => id) },
|
...pages.docs.flatMap(getEndpointChangesForPage),
|
||||||
files: { ids: files.docs.map(({ id }) => id) },
|
...collectibles.docs.flatMap(getEndpointChangesForCollectible),
|
||||||
recorders: { ids: recorders.docs.map(({ id }) => id) },
|
...audios.docs.flatMap(getEndpointChangesForAudio),
|
||||||
chronologyEvents: { ids: chronologyEvents.docs.map(({ id }) => id) },
|
...images.docs.flatMap(getEndpointChangesForImage),
|
||||||
};
|
...videos.docs.flatMap(getEndpointChangesForVideo),
|
||||||
|
...files.docs.flatMap(getEndpointChangesForFile),
|
||||||
|
...recorders.docs.flatMap(getEndpointChangesForRecorder),
|
||||||
|
...chronologyEvents.docs.flatMap(getEndpointChangesForChronologyEvent),
|
||||||
|
];
|
||||||
|
|
||||||
return res.status(200).send(result);
|
return res.status(200).send(uniqueBy(result, ({ url }) => url));
|
||||||
},
|
},
|
||||||
};
|
};
|
|
@ -1,208 +0,0 @@
|
||||||
import payload from "payload";
|
|
||||||
import { Endpoint } from "payload/config";
|
|
||||||
import { Collections } from "src/shared/payload/constants";
|
|
||||||
import { EndpointAllSDKUrls } from "src/shared/payload/endpoint-types";
|
|
||||||
import { getSDKEndpoint } from "src/shared/payload/sdk";
|
|
||||||
import { Collectible } from "src/types/collections";
|
|
||||||
|
|
||||||
export const getAllSDKUrlsEndpoint: Endpoint = {
|
|
||||||
method: "get",
|
|
||||||
path: "/all-sdk-urls",
|
|
||||||
handler: async (req, res) => {
|
|
||||||
if (!req.user) {
|
|
||||||
return res.status(403).send({
|
|
||||||
errors: [
|
|
||||||
{
|
|
||||||
message: "You are not allowed to perform this action.",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const collectibles = await payload.find({
|
|
||||||
collection: Collections.Collectibles,
|
|
||||||
depth: 0,
|
|
||||||
pagination: false,
|
|
||||||
user: req.user,
|
|
||||||
where: {
|
|
||||||
_status: {
|
|
||||||
equals: "published",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const pages = await payload.find({
|
|
||||||
collection: Collections.Pages,
|
|
||||||
depth: 0,
|
|
||||||
pagination: false,
|
|
||||||
user: req.user,
|
|
||||||
where: {
|
|
||||||
_status: {
|
|
||||||
equals: "published",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const folders = await payload.find({
|
|
||||||
collection: Collections.Folders,
|
|
||||||
depth: 0,
|
|
||||||
pagination: false,
|
|
||||||
user: req.user,
|
|
||||||
});
|
|
||||||
|
|
||||||
const videos = await payload.find({
|
|
||||||
collection: Collections.Videos,
|
|
||||||
depth: 0,
|
|
||||||
pagination: false,
|
|
||||||
user: req.user,
|
|
||||||
});
|
|
||||||
|
|
||||||
const audios = await payload.find({
|
|
||||||
collection: Collections.Audios,
|
|
||||||
depth: 0,
|
|
||||||
pagination: false,
|
|
||||||
user: req.user,
|
|
||||||
});
|
|
||||||
|
|
||||||
const images = await payload.find({
|
|
||||||
collection: Collections.Images,
|
|
||||||
depth: 0,
|
|
||||||
pagination: false,
|
|
||||||
user: req.user,
|
|
||||||
});
|
|
||||||
|
|
||||||
const files = await payload.find({
|
|
||||||
collection: Collections.Files,
|
|
||||||
depth: 0,
|
|
||||||
pagination: false,
|
|
||||||
user: req.user,
|
|
||||||
});
|
|
||||||
|
|
||||||
const recorders = await payload.find({
|
|
||||||
collection: Collections.Recorders,
|
|
||||||
depth: 0,
|
|
||||||
pagination: false,
|
|
||||||
user: req.user,
|
|
||||||
});
|
|
||||||
|
|
||||||
const chronologyEvents = await payload.find({
|
|
||||||
collection: Collections.ChronologyEvents,
|
|
||||||
depth: 0,
|
|
||||||
pagination: false,
|
|
||||||
user: req.user,
|
|
||||||
where: {
|
|
||||||
_status: {
|
|
||||||
equals: "published",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const urls = new Set([
|
|
||||||
getSDKEndpoint.getConfigEndpoint(),
|
|
||||||
getSDKEndpoint.getLanguagesEndpoint(),
|
|
||||||
getSDKEndpoint.getCurrenciesEndpoint(),
|
|
||||||
getSDKEndpoint.getWordingsEndpoint(),
|
|
||||||
|
|
||||||
...folders.docs.flatMap((doc) => getSDKUrlsForDocument(Collections.Folders, doc)),
|
|
||||||
...pages.docs.flatMap((doc) => getSDKUrlsForDocument(Collections.Pages, doc)),
|
|
||||||
...chronologyEvents.docs.flatMap((doc) =>
|
|
||||||
getSDKUrlsForDocument(Collections.ChronologyEvents, doc)
|
|
||||||
),
|
|
||||||
...videos.docs.flatMap((doc) => getSDKUrlsForDocument(Collections.Videos, doc)),
|
|
||||||
...audios.docs.flatMap((doc) => getSDKUrlsForDocument(Collections.Audios, doc)),
|
|
||||||
...images.docs.flatMap((doc) => getSDKUrlsForDocument(Collections.Images, doc)),
|
|
||||||
...files.docs.flatMap((doc) => getSDKUrlsForDocument(Collections.Files, doc)),
|
|
||||||
...collectibles.docs.flatMap((doc) => getSDKUrlsForDocument(Collections.Collectibles, doc)),
|
|
||||||
...recorders.docs.flatMap((doc) => getSDKUrlsForDocument(Collections.Recorders, doc)),
|
|
||||||
]);
|
|
||||||
|
|
||||||
const result: EndpointAllSDKUrls = {
|
|
||||||
urls: [...urls],
|
|
||||||
};
|
|
||||||
|
|
||||||
return res.status(200).send(result);
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getSDKUrlsForDocument = (collection: Collections, doc: any): string[] => {
|
|
||||||
switch (collection) {
|
|
||||||
case Collections.WebsiteConfig:
|
|
||||||
return [getSDKEndpoint.getConfigEndpoint()];
|
|
||||||
|
|
||||||
case Collections.Folders:
|
|
||||||
return [getSDKEndpoint.getFolderEndpoint(doc.slug)];
|
|
||||||
|
|
||||||
case Collections.Languages:
|
|
||||||
return [getSDKEndpoint.getLanguagesEndpoint()];
|
|
||||||
|
|
||||||
case Collections.Currencies:
|
|
||||||
return [getSDKEndpoint.getCurrenciesEndpoint()];
|
|
||||||
|
|
||||||
case Collections.Wordings:
|
|
||||||
return [getSDKEndpoint.getWordingsEndpoint()];
|
|
||||||
|
|
||||||
case Collections.Pages:
|
|
||||||
return [getSDKEndpoint.getPageEndpoint(doc.slug)];
|
|
||||||
|
|
||||||
case Collections.Collectibles: {
|
|
||||||
const { slug, gallery, scans, scansEnabled } = doc as Collectible;
|
|
||||||
const urls: string[] = [getSDKEndpoint.getCollectibleEndpoint(slug)];
|
|
||||||
if (gallery && gallery.length > 0) {
|
|
||||||
urls.push(getSDKEndpoint.getCollectibleGalleryEndpoint(slug));
|
|
||||||
urls.push(
|
|
||||||
...gallery.map((_, index) =>
|
|
||||||
getSDKEndpoint.getCollectibleGalleryImageEndpoint(slug, index.toString())
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (scans && scansEnabled) {
|
|
||||||
urls.push(getSDKEndpoint.getCollectibleScansEndpoint(slug));
|
|
||||||
// TODO: Add other pages for cover, obi, dustjacket...
|
|
||||||
if (scans.pages) {
|
|
||||||
urls.push(
|
|
||||||
...scans.pages.map(({ page }) =>
|
|
||||||
getSDKEndpoint.getCollectibleScanPageEndpoint(slug, page.toString())
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return urls;
|
|
||||||
}
|
|
||||||
|
|
||||||
case Collections.ChronologyEvents:
|
|
||||||
return [
|
|
||||||
getSDKEndpoint.getChronologyEventsEndpoint(),
|
|
||||||
getSDKEndpoint.getChronologyEventByIDEndpoint(doc.id),
|
|
||||||
];
|
|
||||||
|
|
||||||
case Collections.Images:
|
|
||||||
return [getSDKEndpoint.getImageByIDEndpoint(doc.id)];
|
|
||||||
|
|
||||||
case Collections.Audios:
|
|
||||||
return [getSDKEndpoint.getAudioByIDEndpoint(doc.id)];
|
|
||||||
|
|
||||||
case Collections.Videos:
|
|
||||||
return [getSDKEndpoint.getVideoByIDEndpoint(doc.id)];
|
|
||||||
|
|
||||||
case Collections.Recorders:
|
|
||||||
return [getSDKEndpoint.getRecorderByIDEndpoint(doc.id)];
|
|
||||||
|
|
||||||
case Collections.Files:
|
|
||||||
return [getSDKEndpoint.getFileByIDEndpoint(doc.id)];
|
|
||||||
|
|
||||||
case Collections.Attributes:
|
|
||||||
case Collections.CreditsRole:
|
|
||||||
case Collections.GenericContents:
|
|
||||||
case Collections.MediaThumbnails:
|
|
||||||
case Collections.Scans:
|
|
||||||
case Collections.Tags:
|
|
||||||
case Collections.VideosChannels:
|
|
||||||
case Collections.VideosSubtitles:
|
|
||||||
return [];
|
|
||||||
|
|
||||||
default: {
|
|
||||||
console.warn("Unrecognized collection", collection);
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
|
@ -1,5 +1,5 @@
|
||||||
import payload from "payload";
|
import payload from "payload";
|
||||||
import { CollectionEndpoint } from "src/types/payload";
|
import { CollectionEndpoint } from "../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 "src/blocks/attributeBlocks/numberBlock";
|
import { numberBlock } from "../../blocks/attributeBlocks/numberBlock";
|
||||||
import { tagsBlock } from "src/blocks/attributeBlocks/tagsBlock";
|
import { tagsBlock } from "../../blocks/attributeBlocks/tagsBlock";
|
||||||
import { textBlock } from "src/blocks/attributeBlocks/textBlock";
|
import { textBlock } from "../../blocks/attributeBlocks/textBlock";
|
||||||
|
|
||||||
type AttributesFieldProps = Omit<BlockField, "type" | "blocks">;
|
type AttributesFieldProps = Omit<BlockField, "type" | "blocks">;
|
||||||
|
|
||||||
|
|
|
@ -1,51 +0,0 @@
|
||||||
import payload, { GeneratedTypes } from "payload";
|
|
||||||
import { FieldBase, SingleRelationshipField } from "payload/dist/fields/config/types";
|
|
||||||
import { Where } from "payload/types";
|
|
||||||
import { isEmpty } from "src/utils/asserts";
|
|
||||||
|
|
||||||
type BackPropagationField = FieldBase & {
|
|
||||||
where: (data: any) => Where;
|
|
||||||
relationTo: keyof GeneratedTypes["collections"];
|
|
||||||
hasMany?: boolean;
|
|
||||||
};
|
|
||||||
export const backPropagationField = ({
|
|
||||||
admin,
|
|
||||||
hooks: { beforeChange = [], afterRead = [], ...otherHooks } = {},
|
|
||||||
where,
|
|
||||||
hasMany = false,
|
|
||||||
...params
|
|
||||||
}: BackPropagationField): SingleRelationshipField => ({
|
|
||||||
...params,
|
|
||||||
type: "relationship",
|
|
||||||
hasMany: hasMany,
|
|
||||||
admin: { ...admin, readOnly: true },
|
|
||||||
hooks: {
|
|
||||||
...otherHooks,
|
|
||||||
beforeChange: [
|
|
||||||
...beforeChange,
|
|
||||||
({ siblingData }) => {
|
|
||||||
delete siblingData[params.name];
|
|
||||||
},
|
|
||||||
],
|
|
||||||
afterRead: [
|
|
||||||
...afterRead,
|
|
||||||
async ({ data, context }) => {
|
|
||||||
if (isEmpty(data?.id) || context.stopPropagation) {
|
|
||||||
return hasMany ? [] : undefined;
|
|
||||||
}
|
|
||||||
const result = await payload.find({
|
|
||||||
collection: params.relationTo,
|
|
||||||
where: where(data),
|
|
||||||
limit: 100,
|
|
||||||
depth: 0,
|
|
||||||
context: { stopPropagation: true },
|
|
||||||
});
|
|
||||||
if (hasMany) {
|
|
||||||
return result.docs.map((doc) => doc.id);
|
|
||||||
} else {
|
|
||||||
return result.docs[0]?.id;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
});
|
|
|
@ -1,47 +0,0 @@
|
||||||
import payload, { GeneratedTypes } from "payload";
|
|
||||||
import { SanitizedCollectionConfig, SanitizedGlobalConfig } from "payload/types";
|
|
||||||
|
|
||||||
export const getAddedBackPropagationRelationships = async (
|
|
||||||
config: SanitizedCollectionConfig | SanitizedGlobalConfig,
|
|
||||||
doc: any,
|
|
||||||
previousDoc?: any
|
|
||||||
): Promise<string[]> => {
|
|
||||||
if (!("getBackPropagatedRelationships" in config.custom)) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
const getBackPropagatedRelationships: (doc: any) => string[] =
|
|
||||||
config.custom.getBackPropagatedRelationships;
|
|
||||||
|
|
||||||
if (!previousDoc) {
|
|
||||||
return getBackPropagatedRelationships(doc);
|
|
||||||
}
|
|
||||||
|
|
||||||
let currentIds: string[];
|
|
||||||
let previousIds: string[];
|
|
||||||
|
|
||||||
if (config.versions.drafts) {
|
|
||||||
const versions = await payload.findVersions({
|
|
||||||
collection: config.slug as keyof GeneratedTypes["collections"],
|
|
||||||
sort: "-updatedAt",
|
|
||||||
limit: 2,
|
|
||||||
where: {
|
|
||||||
and: [{ parent: { equals: doc.id } }, { "version._status": { equals: "published" } }],
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const currentVersion = versions.docs[0]?.version;
|
|
||||||
const previousVersion = versions.docs[1]?.version;
|
|
||||||
|
|
||||||
if (!currentVersion) return [];
|
|
||||||
if (!previousVersion) return getBackPropagatedRelationships(currentVersion);
|
|
||||||
|
|
||||||
currentIds = getBackPropagatedRelationships(currentVersion);
|
|
||||||
previousIds = getBackPropagatedRelationships(previousVersion);
|
|
||||||
} else {
|
|
||||||
currentIds = getBackPropagatedRelationships(doc);
|
|
||||||
previousIds = getBackPropagatedRelationships(previousDoc);
|
|
||||||
}
|
|
||||||
|
|
||||||
return currentIds.filter((id) => !previousIds.includes(id));
|
|
||||||
};
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { CollapsibleField, Condition, Field } from "payload/types";
|
import { CollapsibleField, Condition, Field } from "payload/types";
|
||||||
import { capitalize } from "src/utils/string";
|
import { capitalize } from "../../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 { 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";
|
import { Collections } from "../../shared/payload/constants";
|
||||||
|
|
||||||
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 "src/utils/asserts";
|
import { isEmpty } from "../../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 "src/utils/asserts";
|
import { isUndefined } from "../../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 "src/utils/asserts";
|
import { isUndefined } from "../../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 "src/types/collections";
|
import { Language } from "../../types/collections";
|
||||||
import { isDefined } from "src/utils/asserts";
|
import { isDefined } from "../../utils/asserts";
|
||||||
import { formatLanguageCode } from "src/utils/string";
|
import { formatLanguageCode } from "../../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 { 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 "../../shared/payload/constants";
|
||||||
import { Collections } from "src/shared/payload/constants";
|
|
||||||
import { isDefined, isUndefined, hasDuplicates } from "src/utils/asserts";
|
|
||||||
|
|
||||||
const fieldsNames = {
|
const fieldsNames = {
|
||||||
language: "language",
|
language: "language",
|
||||||
|
|
|
@ -0,0 +1,432 @@
|
||||||
|
import { Collections } from "../shared/payload/constants";
|
||||||
|
import { SDKEndpointNames, getSDKEndpoint } from "../shared/payload/sdk";
|
||||||
|
import { EndpointChange } from "../shared/payload/webhooks";
|
||||||
|
import {
|
||||||
|
Audio,
|
||||||
|
ChronologyEvent,
|
||||||
|
Collectible,
|
||||||
|
File,
|
||||||
|
Folder,
|
||||||
|
Image,
|
||||||
|
Page,
|
||||||
|
Recorder,
|
||||||
|
Relationship,
|
||||||
|
Video,
|
||||||
|
} from "../types/collections";
|
||||||
|
import { isDefined, isPayloadType } from "../utils/asserts";
|
||||||
|
import {
|
||||||
|
AfterChangeHook,
|
||||||
|
AfterDeleteHook,
|
||||||
|
BeforeChangeHook,
|
||||||
|
BeforeDeleteHook,
|
||||||
|
} from "payload/dist/collections/config/types";
|
||||||
|
import { GeneratedTypes } from "payload";
|
||||||
|
import { uniqueBy } from "../utils/array";
|
||||||
|
import { GlobalAfterChangeHook } from "payload/types";
|
||||||
|
import { findRelationByID } from "payloadcms-relationships/dist/utils";
|
||||||
|
|
||||||
|
export const beforeChangePrepareChanges: BeforeChangeHook = async ({
|
||||||
|
collection,
|
||||||
|
originalDoc,
|
||||||
|
context,
|
||||||
|
data,
|
||||||
|
}) => {
|
||||||
|
if ("_status" in data && data._status === "draft") return data;
|
||||||
|
if (!originalDoc) return data;
|
||||||
|
|
||||||
|
context.beforeChangeChanges = await getChanges(
|
||||||
|
collection.slug as keyof GeneratedTypes["collections"],
|
||||||
|
originalDoc
|
||||||
|
);
|
||||||
|
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const afterChangeSendChangesWebhook: AfterChangeHook = async ({
|
||||||
|
doc,
|
||||||
|
collection,
|
||||||
|
context,
|
||||||
|
}) => {
|
||||||
|
if ("_status" in doc && doc._status === "draft") return doc;
|
||||||
|
|
||||||
|
const changes = await getChanges(collection.slug as keyof GeneratedTypes["collections"], doc);
|
||||||
|
const previousChanges = context.beforeChangeChanges as EndpointChange[] | undefined;
|
||||||
|
|
||||||
|
if (isDefined(previousChanges)) {
|
||||||
|
await sendWebhookMessage(uniqueBy([...previousChanges, ...changes], ({ url }) => url));
|
||||||
|
} else {
|
||||||
|
await sendWebhookMessage(changes);
|
||||||
|
}
|
||||||
|
|
||||||
|
return doc;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const beforeDeletePrepareChanges: BeforeDeleteHook = async ({ id, collection, context }) => {
|
||||||
|
context.beforeDeleteChanges = await getChanges(
|
||||||
|
collection.slug as keyof GeneratedTypes["collections"],
|
||||||
|
{ id }
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const afterDeleteSendChangesWebhook: AfterDeleteHook = async ({ doc, context }) => {
|
||||||
|
const changes = context.beforeDeleteChanges as EndpointChange[] | undefined;
|
||||||
|
if (isDefined(changes)) {
|
||||||
|
await sendWebhookMessage(changes);
|
||||||
|
}
|
||||||
|
return doc;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const globalAfterChangeSendChangesWebhook: GlobalAfterChangeHook = async ({
|
||||||
|
doc,
|
||||||
|
global,
|
||||||
|
}) => {
|
||||||
|
const changes: EndpointChange[] = [];
|
||||||
|
|
||||||
|
switch (global.slug as keyof GeneratedTypes["globals"]) {
|
||||||
|
case Collections.WebsiteConfig:
|
||||||
|
changes.push(...getEndpointChangesForWebsiteConfig());
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
await sendWebhookMessage(uniqueBy(changes, ({ url }) => url));
|
||||||
|
return doc;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getChanges = async (
|
||||||
|
slug: keyof GeneratedTypes["collections"],
|
||||||
|
doc: any
|
||||||
|
): Promise<EndpointChange[]> => {
|
||||||
|
if (slug === "relationships") return [];
|
||||||
|
if (slug === "payload-migrations") return [];
|
||||||
|
if (slug === "payload-preferences") return [];
|
||||||
|
|
||||||
|
let relation: Relationship;
|
||||||
|
try {
|
||||||
|
relation = await findRelationByID(slug, doc.id);
|
||||||
|
} catch (e) {
|
||||||
|
relation = {
|
||||||
|
id: "",
|
||||||
|
document: {
|
||||||
|
relationTo: slug,
|
||||||
|
value: doc,
|
||||||
|
},
|
||||||
|
outgoingRelations: [],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const changes: EndpointChange[] = getEndpointChangesFromDocument(relation.document);
|
||||||
|
|
||||||
|
relation.incomingRelations?.forEach((relation) =>
|
||||||
|
changes.push(...getEndpointChangesFromIncomingRelation(relation))
|
||||||
|
);
|
||||||
|
|
||||||
|
relation.outgoingRelations?.forEach((relation) =>
|
||||||
|
changes.push(...getEndpointChangesFromOutgoingRelation(relation))
|
||||||
|
);
|
||||||
|
|
||||||
|
return uniqueBy(changes, ({ url }) => url);
|
||||||
|
};
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
const getEndpointChangesFromDocument = ({
|
||||||
|
relationTo,
|
||||||
|
value,
|
||||||
|
}: NonNullable<Relationship["document"]>): EndpointChange[] => {
|
||||||
|
if (!isPayloadType(value)) return [];
|
||||||
|
switch (relationTo) {
|
||||||
|
case Collections.Folders:
|
||||||
|
return getEndpointChangesForFolder(value);
|
||||||
|
|
||||||
|
case Collections.Pages:
|
||||||
|
return getEndpointChangesForPage(value);
|
||||||
|
|
||||||
|
case Collections.Collectibles:
|
||||||
|
return getEndpointChangesForCollectible(value);
|
||||||
|
|
||||||
|
case Collections.Audios:
|
||||||
|
return getEndpointChangesForAudio(value);
|
||||||
|
|
||||||
|
case Collections.Images:
|
||||||
|
return getEndpointChangesForImage(value);
|
||||||
|
|
||||||
|
case Collections.Videos:
|
||||||
|
return getEndpointChangesForVideo(value);
|
||||||
|
|
||||||
|
case Collections.Files:
|
||||||
|
return getEndpointChangesForFile(value);
|
||||||
|
|
||||||
|
case Collections.Recorders:
|
||||||
|
return getEndpointChangesForRecorder(value);
|
||||||
|
|
||||||
|
case Collections.ChronologyEvents:
|
||||||
|
return getEndpointChangesForChronologyEvent(value);
|
||||||
|
|
||||||
|
case Collections.Languages:
|
||||||
|
return getEndpointChangesForLanguage();
|
||||||
|
|
||||||
|
case Collections.Currencies:
|
||||||
|
return getEndpointChangesForCurrency();
|
||||||
|
|
||||||
|
case Collections.Wordings:
|
||||||
|
return getEndpointChangesForWording();
|
||||||
|
|
||||||
|
case Collections.Attributes:
|
||||||
|
case Collections.CreditsRole:
|
||||||
|
case Collections.GenericContents:
|
||||||
|
case Collections.MediaThumbnails:
|
||||||
|
case Collections.Scans:
|
||||||
|
case Collections.Tags:
|
||||||
|
case Collections.VideosChannels:
|
||||||
|
case Collections.VideosSubtitles:
|
||||||
|
default:
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const getEndpointChangesFromIncomingRelation = ({
|
||||||
|
relationTo,
|
||||||
|
value,
|
||||||
|
}: NonNullable<Relationship["incomingRelations"]>[number]): EndpointChange[] => {
|
||||||
|
if (!isPayloadType(value)) return [];
|
||||||
|
switch (relationTo) {
|
||||||
|
case Collections.Folders:
|
||||||
|
return getEndpointChangesForFolder(value);
|
||||||
|
|
||||||
|
case Collections.Pages:
|
||||||
|
return getEndpointChangesForPage(value);
|
||||||
|
|
||||||
|
case Collections.Collectibles:
|
||||||
|
return getEndpointChangesForCollectible(value);
|
||||||
|
|
||||||
|
case Collections.Audios:
|
||||||
|
return getEndpointChangesForAudio(value);
|
||||||
|
|
||||||
|
case Collections.Images:
|
||||||
|
return getEndpointChangesForImage(value);
|
||||||
|
|
||||||
|
case Collections.Videos:
|
||||||
|
return getEndpointChangesForVideo(value);
|
||||||
|
|
||||||
|
case Collections.Files:
|
||||||
|
return getEndpointChangesForFile(value);
|
||||||
|
|
||||||
|
case Collections.Recorders:
|
||||||
|
return getEndpointChangesForRecorder(value);
|
||||||
|
|
||||||
|
case Collections.ChronologyEvents:
|
||||||
|
return getEndpointChangesForChronologyEvent(value);
|
||||||
|
|
||||||
|
case Collections.Languages:
|
||||||
|
case Collections.Currencies:
|
||||||
|
case Collections.Wordings:
|
||||||
|
case Collections.Attributes:
|
||||||
|
case Collections.CreditsRole:
|
||||||
|
case Collections.GenericContents:
|
||||||
|
case Collections.MediaThumbnails:
|
||||||
|
case Collections.Scans:
|
||||||
|
case Collections.Tags:
|
||||||
|
case Collections.VideosChannels:
|
||||||
|
case Collections.VideosSubtitles:
|
||||||
|
default:
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const getEndpointChangesFromOutgoingRelation = ({
|
||||||
|
relationTo,
|
||||||
|
value,
|
||||||
|
}: NonNullable<Relationship["outgoingRelations"]>[number]): EndpointChange[] => {
|
||||||
|
if (!isPayloadType(value)) return [];
|
||||||
|
switch (relationTo) {
|
||||||
|
case Collections.Folders:
|
||||||
|
return getEndpointChangesForFolder(value);
|
||||||
|
|
||||||
|
case Collections.Pages:
|
||||||
|
return getEndpointChangesForPage(value);
|
||||||
|
|
||||||
|
case Collections.Collectibles:
|
||||||
|
return getEndpointChangesForCollectible(value);
|
||||||
|
|
||||||
|
case Collections.Audios:
|
||||||
|
return getEndpointChangesForAudio(value);
|
||||||
|
|
||||||
|
case Collections.Images:
|
||||||
|
return getEndpointChangesForImage(value);
|
||||||
|
|
||||||
|
case Collections.Videos:
|
||||||
|
return getEndpointChangesForVideo(value);
|
||||||
|
|
||||||
|
case Collections.Files:
|
||||||
|
return getEndpointChangesForFile(value);
|
||||||
|
|
||||||
|
case Collections.Languages:
|
||||||
|
case Collections.Currencies:
|
||||||
|
case Collections.Wordings:
|
||||||
|
case Collections.Attributes:
|
||||||
|
case Collections.CreditsRole:
|
||||||
|
case Collections.GenericContents:
|
||||||
|
case Collections.MediaThumbnails:
|
||||||
|
case Collections.Scans:
|
||||||
|
case Collections.Tags:
|
||||||
|
case Collections.VideosChannels:
|
||||||
|
case Collections.VideosSubtitles:
|
||||||
|
case Collections.ChronologyEvents:
|
||||||
|
case Collections.Recorders:
|
||||||
|
default:
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getEndpointChangesForWebsiteConfig = (): EndpointChange[] => [
|
||||||
|
{
|
||||||
|
type: SDKEndpointNames.getWebsiteConfig,
|
||||||
|
url: getSDKEndpoint.getWebsiteConfig(),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export const getEndpointChangesForFolder = ({ slug }: Folder): EndpointChange[] => [
|
||||||
|
{ type: SDKEndpointNames.getFolder, slug, url: getSDKEndpoint.getFolder(slug) },
|
||||||
|
];
|
||||||
|
|
||||||
|
export const getEndpointChangesForLanguage = (): EndpointChange[] => [
|
||||||
|
{ type: SDKEndpointNames.getLanguages, url: getSDKEndpoint.getLanguages() },
|
||||||
|
];
|
||||||
|
|
||||||
|
export const getEndpointChangesForCurrency = (): EndpointChange[] => [
|
||||||
|
{ type: SDKEndpointNames.getCurrencies, url: getSDKEndpoint.getCurrencies() },
|
||||||
|
];
|
||||||
|
|
||||||
|
export const getEndpointChangesForWording = (): EndpointChange[] => [
|
||||||
|
{ type: SDKEndpointNames.getWordings, url: getSDKEndpoint.getWordings() },
|
||||||
|
];
|
||||||
|
|
||||||
|
export const getEndpointChangesForPage = ({ slug }: Page): EndpointChange[] => [
|
||||||
|
{ type: SDKEndpointNames.getPage, slug, url: getSDKEndpoint.getPage(slug) },
|
||||||
|
];
|
||||||
|
|
||||||
|
export const getEndpointChangesForCollectible = ({
|
||||||
|
slug,
|
||||||
|
gallery,
|
||||||
|
scans,
|
||||||
|
scansEnabled,
|
||||||
|
}: Collectible): EndpointChange[] => {
|
||||||
|
const changes: EndpointChange[] = [];
|
||||||
|
|
||||||
|
changes.push({
|
||||||
|
type: SDKEndpointNames.getCollectible,
|
||||||
|
slug,
|
||||||
|
url: getSDKEndpoint.getCollectible(slug),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (gallery && gallery.length > 0) {
|
||||||
|
changes.push({
|
||||||
|
type: SDKEndpointNames.getCollectibleGallery,
|
||||||
|
slug,
|
||||||
|
url: getSDKEndpoint.getCollectibleGallery(slug),
|
||||||
|
});
|
||||||
|
gallery.forEach((_, indexNumber) => {
|
||||||
|
const index = indexNumber.toString();
|
||||||
|
changes.push({
|
||||||
|
type: SDKEndpointNames.getCollectibleGalleryImage,
|
||||||
|
slug,
|
||||||
|
index: index,
|
||||||
|
url: getSDKEndpoint.getCollectibleGalleryImage(slug, index),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (scans && scansEnabled) {
|
||||||
|
changes.push({
|
||||||
|
type: SDKEndpointNames.getCollectibleScans,
|
||||||
|
slug,
|
||||||
|
url: getSDKEndpoint.getCollectibleScans(slug),
|
||||||
|
});
|
||||||
|
|
||||||
|
// TODO: Add other changes for cover, obi, dustjacket...
|
||||||
|
|
||||||
|
scans.pages?.forEach(({ page }) => {
|
||||||
|
const index = page.toString();
|
||||||
|
changes.push({
|
||||||
|
type: SDKEndpointNames.getCollectibleScanPage,
|
||||||
|
slug,
|
||||||
|
index: index,
|
||||||
|
url: getSDKEndpoint.getCollectibleScanPage(slug, index),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return changes;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getEndpointChangesForAudio = ({ id }: Audio): EndpointChange[] => [
|
||||||
|
{ type: SDKEndpointNames.getAudioByID, id, url: getSDKEndpoint.getAudioByID(id) },
|
||||||
|
];
|
||||||
|
|
||||||
|
export const getEndpointChangesForImage = ({ id }: Image): EndpointChange[] => [
|
||||||
|
{ type: SDKEndpointNames.getImageByID, id, url: getSDKEndpoint.getImageByID(id) },
|
||||||
|
];
|
||||||
|
|
||||||
|
export const getEndpointChangesForVideo = ({ id }: Video): EndpointChange[] => [
|
||||||
|
{ type: SDKEndpointNames.getVideoByID, id, url: getSDKEndpoint.getVideoByID(id) },
|
||||||
|
];
|
||||||
|
|
||||||
|
export const getEndpointChangesForFile = ({ id }: File): EndpointChange[] => [
|
||||||
|
{ type: SDKEndpointNames.getFileByID, id, url: getSDKEndpoint.getFileByID(id) },
|
||||||
|
];
|
||||||
|
|
||||||
|
export const getEndpointChangesForRecorder = ({ id }: Recorder): EndpointChange[] => [
|
||||||
|
{ type: SDKEndpointNames.getRecorderByID, id, url: getSDKEndpoint.getRecorderByID(id) },
|
||||||
|
];
|
||||||
|
|
||||||
|
export const getEndpointChangesForChronologyEvent = ({ id }: ChronologyEvent): EndpointChange[] => [
|
||||||
|
{
|
||||||
|
type: SDKEndpointNames.getChronologyEventByID,
|
||||||
|
id,
|
||||||
|
url: getSDKEndpoint.getChronologyEventByID(id),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: SDKEndpointNames.getChronologyEvents,
|
||||||
|
url: getSDKEndpoint.getChronologyEvents(),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
const webhookTargets: { url: string; token: string }[] = [
|
||||||
|
{
|
||||||
|
url: process.env.WEB_SERVER_HOOK_URL ?? "",
|
||||||
|
token: process.env.WEB_SERVER_HOOK_TOKEN ?? "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
url: process.env.MEILISEARCH_HOOK_URL ?? "",
|
||||||
|
token: process.env.MEILISEARCH_HOOK_TOKEN ?? "",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const sendWebhookMessage = async (changes: EndpointChange[]) => {
|
||||||
|
if (changes.length === 0) return;
|
||||||
|
try {
|
||||||
|
await Promise.all(
|
||||||
|
webhookTargets.flatMap(({ url, token }) => {
|
||||||
|
if (!url) return;
|
||||||
|
return fetch(url, {
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify(changes),
|
||||||
|
method: "POST",
|
||||||
|
});
|
||||||
|
})
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
if (e instanceof Error) {
|
||||||
|
console.warn("Error while sending webhook", e.message);
|
||||||
|
} else {
|
||||||
|
console.warn("Error while sending webhook", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
|
@ -1,81 +0,0 @@
|
||||||
import {
|
|
||||||
AfterDeleteHook,
|
|
||||||
AfterChangeHook as CollectionAfterChangeHook,
|
|
||||||
} from "payload/dist/collections/config/types";
|
|
||||||
import { AfterChangeHook as GlobalAfterChangeHook } from "payload/dist/globals/config/types";
|
|
||||||
import { getSDKUrlsForDocument } from "src/endpoints/getAllSDKUrlsEndpoint";
|
|
||||||
import { getAddedBackPropagationRelationships } from "src/fields/backPropagationField/backPropagationUtils";
|
|
||||||
import { Collections } from "src/shared/payload/constants";
|
|
||||||
import { AfterOperationWebHookMessage } from "src/shared/payload/webhooks";
|
|
||||||
|
|
||||||
export const globalAfterChangeWebhook: GlobalAfterChangeHook = async ({
|
|
||||||
global,
|
|
||||||
doc,
|
|
||||||
previousDoc,
|
|
||||||
}) => {
|
|
||||||
const collection = global.slug as Collections;
|
|
||||||
await sendWebhookMessage({
|
|
||||||
collection,
|
|
||||||
addedDependantIds: await getAddedBackPropagationRelationships(global, doc, previousDoc),
|
|
||||||
urls: getSDKUrlsForDocument(collection, doc),
|
|
||||||
});
|
|
||||||
return doc;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const collectionAfterChangeWebhook: CollectionAfterChangeHook = async ({
|
|
||||||
collection,
|
|
||||||
doc,
|
|
||||||
previousDoc,
|
|
||||||
operation,
|
|
||||||
}) => {
|
|
||||||
const collectionSlug = collection.slug as Collections;
|
|
||||||
console.log("afterChange", operation, collectionSlug, doc.id);
|
|
||||||
|
|
||||||
if ("_status" in doc && doc._status === "draft") {
|
|
||||||
return doc;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!("id" in doc)) {
|
|
||||||
return doc;
|
|
||||||
}
|
|
||||||
|
|
||||||
await sendWebhookMessage({
|
|
||||||
collection: collectionSlug,
|
|
||||||
id: doc.id,
|
|
||||||
addedDependantIds: await getAddedBackPropagationRelationships(collection, doc, previousDoc),
|
|
||||||
urls: getSDKUrlsForDocument(collectionSlug, doc),
|
|
||||||
});
|
|
||||||
|
|
||||||
return doc;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const afterDeleteWebhook: AfterDeleteHook = async ({ collection, doc }) => {
|
|
||||||
const collectionSlug = collection.slug as Collections;
|
|
||||||
console.log("afterDelete", collection.slug, doc.id);
|
|
||||||
|
|
||||||
if (!("id" in doc)) {
|
|
||||||
return doc;
|
|
||||||
}
|
|
||||||
|
|
||||||
await sendWebhookMessage({
|
|
||||||
collection: collectionSlug,
|
|
||||||
id: doc.id,
|
|
||||||
addedDependantIds: [],
|
|
||||||
urls: getSDKUrlsForDocument(collectionSlug, doc),
|
|
||||||
});
|
|
||||||
|
|
||||||
return doc;
|
|
||||||
};
|
|
||||||
|
|
||||||
const sendWebhookMessage = async (message: AfterOperationWebHookMessage) => {
|
|
||||||
await fetch(`${process.env.WEB_HOOK_URI}/collection-operation`, {
|
|
||||||
headers: {
|
|
||||||
Authorization: `Bearer ${process.env.WEB_HOOK_TOKEN}`,
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
},
|
|
||||||
body: JSON.stringify(message),
|
|
||||||
method: "POST",
|
|
||||||
}).catch((e) => {
|
|
||||||
console.warn("Error while sending webhook", e);
|
|
||||||
});
|
|
||||||
};
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { BeforeDuplicate } from "payload/types";
|
import { BeforeDuplicate } from "payload/types";
|
||||||
import { CollectionStatus } from "src/shared/payload/constants";
|
import { CollectionStatus } from "../shared/payload/constants";
|
||||||
|
|
||||||
export const beforeDuplicateUnpublish: BeforeDuplicate = ({ data }) => ({
|
export const beforeDuplicateUnpublish: BeforeDuplicate = ({ data }) => ({
|
||||||
...data,
|
...data,
|
||||||
|
|
|
@ -4,34 +4,35 @@ 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 "src/collections/Attributes/Attributes";
|
import { Attributes } from "./collections/Attributes/Attributes";
|
||||||
import { Audios } from "src/collections/Audios/Audios";
|
import { Audios } from "./collections/Audios/Audios";
|
||||||
import { ChronologyEvents } from "src/collections/ChronologyEvents/ChronologyEvents";
|
import { ChronologyEvents } from "./collections/ChronologyEvents/ChronologyEvents";
|
||||||
import { Collectibles } from "src/collections/Collectibles/Collectibles";
|
import { Collectibles } from "./collections/Collectibles/Collectibles";
|
||||||
import { CreditsRoles } from "src/collections/CreditsRoles/CreditsRoles";
|
import { CreditsRoles } from "./collections/CreditsRoles/CreditsRoles";
|
||||||
import { Currencies } from "src/collections/Currencies/Currencies";
|
import { Currencies } from "./collections/Currencies/Currencies";
|
||||||
import { Files } from "src/collections/Files/Files";
|
import { Files } from "./collections/Files/Files";
|
||||||
import { Folders } from "src/collections/Folders/Folders";
|
import { Folders } from "./collections/Folders/Folders";
|
||||||
import { GenericContents } from "src/collections/GenericContents/GenericContents";
|
import { GenericContents } from "./collections/GenericContents/GenericContents";
|
||||||
import { Images } from "src/collections/Images/Images";
|
import { Images } from "./collections/Images/Images";
|
||||||
import { Languages } from "src/collections/Languages/Languages";
|
import { Languages } from "./collections/Languages/Languages";
|
||||||
import { MediaThumbnails } from "src/collections/MediaThumbnails/MediaThumbnails";
|
import { MediaThumbnails } from "./collections/MediaThumbnails/MediaThumbnails";
|
||||||
import { Pages } from "src/collections/Pages/Pages";
|
import { Pages } from "./collections/Pages/Pages";
|
||||||
import { Recorders } from "src/collections/Recorders/Recorders";
|
import { Recorders } from "./collections/Recorders/Recorders";
|
||||||
import { Scans } from "src/collections/Scans/Scans";
|
import { Scans } from "./collections/Scans/Scans";
|
||||||
import { Tags } from "src/collections/Tags/Tags";
|
import { Tags } from "./collections/Tags/Tags";
|
||||||
import { Videos } from "src/collections/Videos/Videos";
|
import { Videos } from "./collections/Videos/Videos";
|
||||||
import { VideosChannels } from "src/collections/VideosChannels/VideosChannels";
|
import { VideosChannels } from "./collections/VideosChannels/VideosChannels";
|
||||||
import { VideosSubtitles } from "src/collections/VideosSubtitles/VideosSubtitles";
|
import { VideosSubtitles } from "./collections/VideosSubtitles/VideosSubtitles";
|
||||||
import { WebsiteConfig } from "src/collections/WebsiteConfig/WebsiteConfig";
|
import { WebsiteConfig } from "./collections/WebsiteConfig/WebsiteConfig";
|
||||||
import { Wordings } from "src/collections/Wordings/Wordings";
|
import { Wordings } from "./collections/Wordings/Wordings";
|
||||||
import { Icon } from "src/components/Icon";
|
import { Icon } from "./components/Icon";
|
||||||
import { Logo } from "src/components/Logo";
|
import { Logo } from "./components/Logo";
|
||||||
import { getAllIds } from "src/endpoints/getAllIdsEndpoint";
|
import { getAllEndpoint } from "./endpoints/getAllEndpoint";
|
||||||
import { getAllSDKUrlsEndpoint } from "src/endpoints/getAllSDKUrlsEndpoint";
|
import { createEditor } from "./utils/editor";
|
||||||
import { Collections } from "src/shared/payload/constants";
|
import { Collections } from "./shared/payload/constants";
|
||||||
import { createEditor } from "src/utils/editor";
|
import { relationshipsPlugin } from "payloadcms-relationships";
|
||||||
// import TsconfigPathsPlugin from "tsconfig-paths-webpack-plugin";
|
import { shownOnlyToAdmin } from "./accesses/collections/shownOnlyToAdmin";
|
||||||
|
import { mustBeAdmin } from "./accesses/fields/mustBeAdmin";
|
||||||
|
|
||||||
const configuredSftpAdapter = sftpAdapter({
|
const configuredSftpAdapter = sftpAdapter({
|
||||||
connectOptions: {
|
connectOptions: {
|
||||||
|
@ -55,22 +56,6 @@ 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: [
|
||||||
|
@ -105,7 +90,7 @@ export default buildConfig({
|
||||||
typescript: {
|
typescript: {
|
||||||
outputFile: path.resolve(__dirname, "types/collections.ts"),
|
outputFile: path.resolve(__dirname, "types/collections.ts"),
|
||||||
},
|
},
|
||||||
endpoints: [getAllSDKUrlsEndpoint, getAllIds],
|
endpoints: [getAllEndpoint],
|
||||||
graphQL: {
|
graphQL: {
|
||||||
disable: true,
|
disable: true,
|
||||||
},
|
},
|
||||||
|
@ -113,6 +98,20 @@ export default buildConfig({
|
||||||
skip: () => true,
|
skip: () => true,
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
|
relationshipsPlugin({
|
||||||
|
// rebuildOnInit: true,
|
||||||
|
collectionConfig: {
|
||||||
|
admin: {
|
||||||
|
hidden: shownOnlyToAdmin,
|
||||||
|
},
|
||||||
|
access: {
|
||||||
|
update: mustBeAdmin,
|
||||||
|
create: mustBeAdmin,
|
||||||
|
delete: mustBeAdmin,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
|
||||||
cloudStorage({
|
cloudStorage({
|
||||||
collections: {
|
collections: {
|
||||||
[Collections.Videos]: {
|
[Collections.Videos]: {
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
import "dotenv/config";
|
import "dotenv/config";
|
||||||
import express from "express";
|
import express from "express";
|
||||||
|
import path from "path";
|
||||||
import payload from "payload";
|
import payload from "payload";
|
||||||
import { Collections, RecordersRoles } from "src/shared/payload/constants";
|
import { isUndefined } from "./utils/asserts";
|
||||||
import { isUndefined, isDefined } from "src/utils/asserts";
|
import { Collections, RecordersRoles } from "./shared/payload/constants";
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
|
@ -27,32 +28,36 @@ const start = async () => {
|
||||||
express: app,
|
express: app,
|
||||||
onInit: async () => {
|
onInit: async () => {
|
||||||
payload.logger.info(`Payload Admin URL: ${payload.getAdminURL()}`);
|
payload.logger.info(`Payload Admin URL: ${payload.getAdminURL()}`);
|
||||||
const recorders = await payload.find({ collection: Collections.Recorders });
|
|
||||||
|
|
||||||
// If no recorders, we seed some initial data
|
const seedFirstUser = async () => {
|
||||||
if (
|
const recorders = await payload.find({ collection: Collections.Recorders });
|
||||||
isDefined(process.env.SEEDING_ADMIN_EMAIL) &&
|
|
||||||
isDefined(process.env.SEEDING_ADMIN_PASSWORD) &&
|
|
||||||
isDefined(process.env.SEEDING_ADMIN_USERNAME)
|
|
||||||
) {
|
|
||||||
if (recorders.docs.length === 0) {
|
|
||||||
payload.logger.info("Seeding some initial data");
|
|
||||||
|
|
||||||
await payload.create({
|
if (recorders.docs.length > 0) return;
|
||||||
collection: Collections.Recorders,
|
if (isUndefined(process.env.SEEDING_ADMIN_EMAIL)) return;
|
||||||
data: {
|
if (isUndefined(process.env.SEEDING_ADMIN_PASSWORD)) return;
|
||||||
email: process.env.SEEDING_ADMIN_EMAIL,
|
if (isUndefined(process.env.SEEDING_ADMIN_USERNAME)) return;
|
||||||
password: process.env.SEEDING_ADMIN_PASSWORD,
|
|
||||||
username: process.env.SEEDING_ADMIN_USERNAME,
|
payload.logger.info("Seeding your first user");
|
||||||
role: [RecordersRoles.Admin, RecordersRoles.Api],
|
|
||||||
anonymize: false,
|
await payload.create({
|
||||||
},
|
collection: Collections.Recorders,
|
||||||
});
|
data: {
|
||||||
}
|
email: process.env.SEEDING_ADMIN_EMAIL,
|
||||||
}
|
password: process.env.SEEDING_ADMIN_PASSWORD,
|
||||||
|
username: process.env.SEEDING_ADMIN_USERNAME,
|
||||||
|
role: [RecordersRoles.Admin, RecordersRoles.Api],
|
||||||
|
anonymize: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
await seedFirstUser();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Add your own express routes here
|
||||||
|
app.use("/public", express.static(path.join(__dirname, "../public")));
|
||||||
|
|
||||||
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: /");
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit c2702ea508dde59264ee66100054bacc0834c029
|
|
@ -40,6 +40,7 @@ export interface Config {
|
||||||
currencies: Currency;
|
currencies: Currency;
|
||||||
wordings: Wording;
|
wordings: Wording;
|
||||||
"generic-contents": GenericContent;
|
"generic-contents": GenericContent;
|
||||||
|
relationships: Relationship;
|
||||||
"payload-preferences": PayloadPreference;
|
"payload-preferences": PayloadPreference;
|
||||||
"payload-migrations": PayloadMigration;
|
"payload-migrations": PayloadMigration;
|
||||||
};
|
};
|
||||||
|
@ -94,10 +95,9 @@ export interface Page {
|
||||||
[k: string]: unknown;
|
[k: string]: unknown;
|
||||||
};
|
};
|
||||||
credits?: Credits;
|
credits?: Credits;
|
||||||
|
sourceUrls?: string[] | null;
|
||||||
id?: string | null;
|
id?: string | null;
|
||||||
}[];
|
}[];
|
||||||
folders?: (string | Folder)[] | null;
|
|
||||||
collectibles?: (string | Collectible)[] | null;
|
|
||||||
updatedBy: string | Recorder;
|
updatedBy: string | Recorder;
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
|
@ -352,79 +352,6 @@ export interface Recorder {
|
||||||
lockUntil?: string | null;
|
lockUntil?: string | null;
|
||||||
password?: string | null;
|
password?: string | null;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* This interface was referenced by `Config`'s JSON-Schema
|
|
||||||
* via the `definition` "folders".
|
|
||||||
*/
|
|
||||||
export interface Folder {
|
|
||||||
id: string;
|
|
||||||
slug: string;
|
|
||||||
icon?: string | null;
|
|
||||||
parentFolders?: (string | Folder)[] | null;
|
|
||||||
translations: {
|
|
||||||
language: string | Language;
|
|
||||||
name: string;
|
|
||||||
description?: {
|
|
||||||
root: {
|
|
||||||
type: string;
|
|
||||||
children: {
|
|
||||||
type: string;
|
|
||||||
version: number;
|
|
||||||
[k: string]: unknown;
|
|
||||||
}[];
|
|
||||||
direction: ("ltr" | "rtl") | null;
|
|
||||||
format: "left" | "start" | "center" | "right" | "end" | "justify" | "";
|
|
||||||
indent: number;
|
|
||||||
version: number;
|
|
||||||
};
|
|
||||||
[k: string]: unknown;
|
|
||||||
} | null;
|
|
||||||
id?: string | null;
|
|
||||||
}[];
|
|
||||||
sections?:
|
|
||||||
| {
|
|
||||||
translations?:
|
|
||||||
| {
|
|
||||||
language: string | Language;
|
|
||||||
name: string;
|
|
||||||
id?: string | null;
|
|
||||||
}[]
|
|
||||||
| null;
|
|
||||||
subfolders?: (string | Folder)[] | null;
|
|
||||||
id?: string | null;
|
|
||||||
}[]
|
|
||||||
| null;
|
|
||||||
files?:
|
|
||||||
| (
|
|
||||||
| {
|
|
||||||
relationTo: "collectibles";
|
|
||||||
value: string | Collectible;
|
|
||||||
}
|
|
||||||
| {
|
|
||||||
relationTo: "pages";
|
|
||||||
value: string | Page;
|
|
||||||
}
|
|
||||||
| {
|
|
||||||
relationTo: "videos";
|
|
||||||
value: string | Video;
|
|
||||||
}
|
|
||||||
| {
|
|
||||||
relationTo: "images";
|
|
||||||
value: string | Image;
|
|
||||||
}
|
|
||||||
| {
|
|
||||||
relationTo: "audios";
|
|
||||||
value: string | Audio;
|
|
||||||
}
|
|
||||||
| {
|
|
||||||
relationTo: "files";
|
|
||||||
value: string | File;
|
|
||||||
}
|
|
||||||
)[]
|
|
||||||
| null;
|
|
||||||
updatedAt: string;
|
|
||||||
createdAt: string;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* This interface was referenced by `Config`'s JSON-Schema
|
* This interface was referenced by `Config`'s JSON-Schema
|
||||||
* via the `definition` "collectibles".
|
* via the `definition` "collectibles".
|
||||||
|
@ -608,8 +535,6 @@ export interface Collectible {
|
||||||
id?: string | null;
|
id?: string | null;
|
||||||
}[]
|
}[]
|
||||||
| null;
|
| null;
|
||||||
folders?: (string | Folder)[] | null;
|
|
||||||
parentItems?: (string | Collectible)[] | null;
|
|
||||||
updatedBy: string | Recorder;
|
updatedBy: string | Recorder;
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
|
@ -951,7 +876,78 @@ export interface VideosChannel {
|
||||||
url: string;
|
url: string;
|
||||||
title: string;
|
title: string;
|
||||||
subscribers: number;
|
subscribers: number;
|
||||||
videos?: (string | Video)[] | null;
|
}
|
||||||
|
/**
|
||||||
|
* This interface was referenced by `Config`'s JSON-Schema
|
||||||
|
* via the `definition` "folders".
|
||||||
|
*/
|
||||||
|
export interface Folder {
|
||||||
|
id: string;
|
||||||
|
slug: string;
|
||||||
|
icon?: string | null;
|
||||||
|
translations: {
|
||||||
|
language: string | Language;
|
||||||
|
name: string;
|
||||||
|
description?: {
|
||||||
|
root: {
|
||||||
|
type: string;
|
||||||
|
children: {
|
||||||
|
type: string;
|
||||||
|
version: number;
|
||||||
|
[k: string]: unknown;
|
||||||
|
}[];
|
||||||
|
direction: ("ltr" | "rtl") | null;
|
||||||
|
format: "left" | "start" | "center" | "right" | "end" | "justify" | "";
|
||||||
|
indent: number;
|
||||||
|
version: number;
|
||||||
|
};
|
||||||
|
[k: string]: unknown;
|
||||||
|
} | null;
|
||||||
|
id?: string | null;
|
||||||
|
}[];
|
||||||
|
sections?:
|
||||||
|
| {
|
||||||
|
translations?:
|
||||||
|
| {
|
||||||
|
language: string | Language;
|
||||||
|
name: string;
|
||||||
|
id?: string | null;
|
||||||
|
}[]
|
||||||
|
| null;
|
||||||
|
subfolders?: (string | Folder)[] | null;
|
||||||
|
id?: string | null;
|
||||||
|
}[]
|
||||||
|
| null;
|
||||||
|
files?:
|
||||||
|
| (
|
||||||
|
| {
|
||||||
|
relationTo: "collectibles";
|
||||||
|
value: string | Collectible;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "pages";
|
||||||
|
value: string | Page;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "videos";
|
||||||
|
value: string | Video;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "images";
|
||||||
|
value: string | Image;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "audios";
|
||||||
|
value: string | Audio;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "files";
|
||||||
|
value: string | File;
|
||||||
|
}
|
||||||
|
)[]
|
||||||
|
| null;
|
||||||
|
updatedAt: string;
|
||||||
|
createdAt: string;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* This interface was referenced by `Config`'s JSON-Schema
|
* This interface was referenced by `Config`'s JSON-Schema
|
||||||
|
@ -1082,6 +1078,262 @@ export interface Wording {
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* This interface was referenced by `Config`'s JSON-Schema
|
||||||
|
* via the `definition` "relationships".
|
||||||
|
*/
|
||||||
|
export interface Relationship {
|
||||||
|
id: string;
|
||||||
|
document:
|
||||||
|
| {
|
||||||
|
relationTo: "pages";
|
||||||
|
value: string | Page;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "collectibles";
|
||||||
|
value: string | Collectible;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "folders";
|
||||||
|
value: string | Folder;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "chronology-events";
|
||||||
|
value: string | ChronologyEvent;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "images";
|
||||||
|
value: string | Image;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "audios";
|
||||||
|
value: string | Audio;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "media-thumbnails";
|
||||||
|
value: string | MediaThumbnail;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "videos";
|
||||||
|
value: string | Video;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "videos-subtitles";
|
||||||
|
value: string | VideoSubtitle;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "videos-channels";
|
||||||
|
value: string | VideosChannel;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "files";
|
||||||
|
value: string | File;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "scans";
|
||||||
|
value: string | Scan;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "tags";
|
||||||
|
value: string | Tag;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "attributes";
|
||||||
|
value: string | Attribute;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "credits-roles";
|
||||||
|
value: string | CreditsRole;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "recorders";
|
||||||
|
value: string | Recorder;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "languages";
|
||||||
|
value: string | Language;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "currencies";
|
||||||
|
value: string | Currency;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "wordings";
|
||||||
|
value: string | Wording;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "generic-contents";
|
||||||
|
value: string | GenericContent;
|
||||||
|
};
|
||||||
|
incomingRelations?:
|
||||||
|
| (
|
||||||
|
| {
|
||||||
|
relationTo: "pages";
|
||||||
|
value: string | Page;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "collectibles";
|
||||||
|
value: string | Collectible;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "folders";
|
||||||
|
value: string | Folder;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "chronology-events";
|
||||||
|
value: string | ChronologyEvent;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "images";
|
||||||
|
value: string | Image;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "audios";
|
||||||
|
value: string | Audio;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "media-thumbnails";
|
||||||
|
value: string | MediaThumbnail;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "videos";
|
||||||
|
value: string | Video;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "videos-subtitles";
|
||||||
|
value: string | VideoSubtitle;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "videos-channels";
|
||||||
|
value: string | VideosChannel;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "files";
|
||||||
|
value: string | File;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "scans";
|
||||||
|
value: string | Scan;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "tags";
|
||||||
|
value: string | Tag;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "attributes";
|
||||||
|
value: string | Attribute;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "credits-roles";
|
||||||
|
value: string | CreditsRole;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "recorders";
|
||||||
|
value: string | Recorder;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "languages";
|
||||||
|
value: string | Language;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "currencies";
|
||||||
|
value: string | Currency;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "wordings";
|
||||||
|
value: string | Wording;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "generic-contents";
|
||||||
|
value: string | GenericContent;
|
||||||
|
}
|
||||||
|
)[]
|
||||||
|
| null;
|
||||||
|
outgoingRelations?:
|
||||||
|
| (
|
||||||
|
| {
|
||||||
|
relationTo: "pages";
|
||||||
|
value: string | Page;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "collectibles";
|
||||||
|
value: string | Collectible;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "folders";
|
||||||
|
value: string | Folder;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "chronology-events";
|
||||||
|
value: string | ChronologyEvent;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "images";
|
||||||
|
value: string | Image;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "audios";
|
||||||
|
value: string | Audio;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "media-thumbnails";
|
||||||
|
value: string | MediaThumbnail;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "videos";
|
||||||
|
value: string | Video;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "videos-subtitles";
|
||||||
|
value: string | VideoSubtitle;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "videos-channels";
|
||||||
|
value: string | VideosChannel;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "files";
|
||||||
|
value: string | File;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "scans";
|
||||||
|
value: string | Scan;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "tags";
|
||||||
|
value: string | Tag;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "attributes";
|
||||||
|
value: string | Attribute;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "credits-roles";
|
||||||
|
value: string | CreditsRole;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "recorders";
|
||||||
|
value: string | Recorder;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "languages";
|
||||||
|
value: string | Language;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "currencies";
|
||||||
|
value: string | Currency;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "wordings";
|
||||||
|
value: string | Wording;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
relationTo: "generic-contents";
|
||||||
|
value: string | GenericContent;
|
||||||
|
}
|
||||||
|
)[]
|
||||||
|
| null;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* This interface was referenced by `Config`'s JSON-Schema
|
* This interface was referenced by `Config`'s JSON-Schema
|
||||||
* via the `definition` "payload-preferences".
|
* via the `definition` "payload-preferences".
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
export const uniqueBy = <T, K extends string | number>(array: T[], getKey: (item: T) => K) => {
|
||||||
|
const alreadyFoundKeys: K[] = [];
|
||||||
|
return array.filter((item) => {
|
||||||
|
var currentItemKey = getKey(item);
|
||||||
|
if (alreadyFoundKeys.includes(currentItemKey)) return false;
|
||||||
|
alreadyFoundKeys.push(currentItemKey);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
};
|
|
@ -1,7 +1,6 @@
|
||||||
import { PayloadImage, PayloadMedia } from "src/shared/payload/endpoint-types";
|
import { PayloadImage, PayloadMedia } from "../shared/payload/endpoint-types";
|
||||||
import { RichTextContent, isNodeParagraphNode } from "src/shared/payload/rich-text";
|
import { RichTextContent, isNodeParagraphNode } from "../shared/payload/rich-text";
|
||||||
import { Scan, MediaThumbnail, Video, Image, Audio } from "src/types/collections";
|
import { Audio, File, Image, MediaThumbnail, Scan, Video } from "../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,20 +1,21 @@
|
||||||
import { GeneratedTypes } from "payload";
|
import { GeneratedTypes } from "payload";
|
||||||
import { CollectionConfig } from "payload/types";
|
import { CollectionConfig } from "payload/types";
|
||||||
import { collectionAfterChangeWebhook, afterDeleteWebhook } from "src/hooks/afterOperationWebhook";
|
import { formatToPascalCase } from "./string";
|
||||||
import { formatToPascalCase } from "src/utils/string";
|
import {
|
||||||
|
afterChangeSendChangesWebhook,
|
||||||
|
afterDeleteSendChangesWebhook,
|
||||||
|
beforeChangePrepareChanges,
|
||||||
|
beforeDeletePrepareChanges,
|
||||||
|
} from "../hooks/afterOperationSendChangesWebhook";
|
||||||
|
|
||||||
type CollectionConfigWithPlugins = CollectionConfig;
|
type CollectionConfigWithPlugins = CollectionConfig;
|
||||||
|
|
||||||
export type BuildCollectionConfig = Omit<
|
export type BuildCollectionConfig = Omit<
|
||||||
CollectionConfigWithPlugins,
|
CollectionConfigWithPlugins,
|
||||||
"slug" | "typescript" | "labels" | "custom"
|
"slug" | "typescript" | "labels"
|
||||||
> & {
|
> & {
|
||||||
slug: keyof GeneratedTypes["collections"];
|
slug: keyof GeneratedTypes["collections"];
|
||||||
labels: { singular: string; plural: string };
|
labels: { singular: string; plural: string };
|
||||||
custom?: {
|
|
||||||
getBackPropagatedRelationships?: (object: any) => string[];
|
|
||||||
[key: string]: unknown;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const buildCollectionConfig = (config: BuildCollectionConfig): CollectionConfig => ({
|
export const buildCollectionConfig = (config: BuildCollectionConfig): CollectionConfig => ({
|
||||||
|
@ -22,7 +23,9 @@ export const buildCollectionConfig = (config: BuildCollectionConfig): Collection
|
||||||
typescript: { interface: formatToPascalCase(config.labels.singular) },
|
typescript: { interface: formatToPascalCase(config.labels.singular) },
|
||||||
hooks: {
|
hooks: {
|
||||||
...config.hooks,
|
...config.hooks,
|
||||||
afterChange: [...(config.hooks?.afterChange ?? []), collectionAfterChangeWebhook],
|
beforeChange: [...(config.hooks?.beforeChange ?? []), beforeChangePrepareChanges],
|
||||||
afterDelete: [...(config.hooks?.afterDelete ?? []), afterDeleteWebhook],
|
afterChange: [...(config.hooks?.afterChange ?? []), afterChangeSendChangesWebhook],
|
||||||
|
beforeDelete: [...(config.hooks?.beforeDelete ?? []), beforeDeletePrepareChanges],
|
||||||
|
afterDelete: [...(config.hooks?.afterDelete ?? []), afterDeleteSendChangesWebhook],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,19 +1,23 @@
|
||||||
import { convertAudioToEndpointAudioPreview } from "src/collections/Audios/endpoints/getByID";
|
import { convertAudioToEndpointAudioPreview } from "../collections/Audios/endpoints/getByID";
|
||||||
import { convertImageToEndpointImagePreview } from "src/collections/Images/endpoints/getByID";
|
import { convertEventToEndpointEvent } from "../collections/ChronologyEvents/endpoints/getAllEndpoint";
|
||||||
import { convertRecorderToEndpointRecorderPreview } from "src/collections/Recorders/endpoints/getByID";
|
import { convertCollectibleToEndpointCollectiblePreview } from "../collections/Collectibles/endpoints/getBySlugEndpoint";
|
||||||
import { convertVideoToEndpointVideoPreview } from "src/collections/Videos/endpoints/getByID";
|
import { convertFileToEndpointFilePreview } from "../collections/Files/endpoints/getByID";
|
||||||
import { AttributeTypes } from "src/shared/payload/constants";
|
import { convertFolderToEndpointFolderPreview } from "../collections/Folders/endpoints/getBySlugEndpoint";
|
||||||
|
import { convertImageToEndpointImagePreview } from "../collections/Images/endpoints/getByID";
|
||||||
|
import { convertPageToEndpointPagePreview } from "../collections/Pages/endpoints/getBySlugEndpoint";
|
||||||
|
import { convertRecorderToEndpointRecorderPreview } from "../collections/Recorders/endpoints/getByID";
|
||||||
|
import { convertVideoToEndpointVideoPreview } from "../collections/Videos/endpoints/getByID";
|
||||||
|
import { AttributeTypes, Collections } from "../shared/payload/constants";
|
||||||
import {
|
import {
|
||||||
EndpointTag,
|
EndpointTag,
|
||||||
EndpointSource,
|
|
||||||
EndpointSourcePreview,
|
|
||||||
EndpointRole,
|
EndpointRole,
|
||||||
EndpointCredit,
|
EndpointCredit,
|
||||||
EndpointAttribute,
|
EndpointAttribute,
|
||||||
PayloadImage,
|
PayloadImage,
|
||||||
EndpointScanImage,
|
EndpointScanImage,
|
||||||
EndpointPayloadImage,
|
EndpointPayloadImage,
|
||||||
} from "src/shared/payload/endpoint-types";
|
EndpointRelation,
|
||||||
|
} from "../shared/payload/endpoint-types";
|
||||||
import {
|
import {
|
||||||
RichTextContent,
|
RichTextContent,
|
||||||
isNodeBlockNode,
|
isNodeBlockNode,
|
||||||
|
@ -26,35 +30,33 @@ import {
|
||||||
isUploadNodeImageNode,
|
isUploadNodeImageNode,
|
||||||
isUploadNodeAudioNode,
|
isUploadNodeAudioNode,
|
||||||
isUploadNodeVideoNode,
|
isUploadNodeVideoNode,
|
||||||
} from "src/shared/payload/rich-text";
|
} from "../shared/payload/rich-text";
|
||||||
import {
|
import {
|
||||||
Image,
|
|
||||||
Audio,
|
Audio,
|
||||||
Video,
|
|
||||||
Collectible,
|
|
||||||
Folder,
|
|
||||||
Language,
|
|
||||||
CreditsRole,
|
|
||||||
Credits,
|
Credits,
|
||||||
TagsBlock,
|
CreditsRole,
|
||||||
NumberBlock,
|
Image,
|
||||||
TextBlock,
|
Language,
|
||||||
Scan,
|
|
||||||
MediaThumbnail,
|
MediaThumbnail,
|
||||||
|
NumberBlock,
|
||||||
|
Relationship,
|
||||||
|
Scan,
|
||||||
Tag,
|
Tag,
|
||||||
} from "src/types/collections";
|
TagsBlock,
|
||||||
|
TextBlock,
|
||||||
|
Video,
|
||||||
|
} from "../types/collections";
|
||||||
import {
|
import {
|
||||||
isPayloadType,
|
|
||||||
isImage,
|
|
||||||
isAudio,
|
isAudio,
|
||||||
isVideo,
|
|
||||||
isNotEmpty,
|
|
||||||
isPayloadArrayType,
|
|
||||||
isPublished,
|
|
||||||
isDefined,
|
isDefined,
|
||||||
isEmpty,
|
isEmpty,
|
||||||
|
isFile,
|
||||||
|
isImage,
|
||||||
|
isPayloadArrayType,
|
||||||
isPayloadImage,
|
isPayloadImage,
|
||||||
} from "src/utils/asserts";
|
isPayloadType,
|
||||||
|
isVideo,
|
||||||
|
} from "./asserts";
|
||||||
|
|
||||||
const convertTagToEndpointTag = ({ id, slug, page, translations }: Tag): EndpointTag => ({
|
const convertTagToEndpointTag = ({ id, slug, page, translations }: Tag): EndpointTag => ({
|
||||||
id,
|
id,
|
||||||
|
@ -139,86 +141,64 @@ export const convertRTCToEndpointRTC = (
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: Handle URL sources
|
export const convertRelationshipsToEndpointRelations = (
|
||||||
export const convertSourceToEndpointSource = ({
|
relationships: Relationship["incomingRelations"] | Relationship["outgoingRelations"]
|
||||||
collectibles,
|
): EndpointRelation[] =>
|
||||||
folders,
|
relationships?.flatMap<EndpointRelation>(({ relationTo, value }) => {
|
||||||
gallery,
|
if (!isPayloadType(value)) return [];
|
||||||
scans,
|
switch (relationTo) {
|
||||||
}: {
|
case Collections.Folders:
|
||||||
collectibles?: (string | Collectible)[] | null | undefined;
|
return { type: Collections.Folders, value: convertFolderToEndpointFolderPreview(value) };
|
||||||
scans?: (string | Collectible)[] | null | undefined;
|
|
||||||
gallery?: (string | Collectible)[] | null | undefined;
|
|
||||||
folders?: (string | Folder)[] | null | undefined;
|
|
||||||
}): EndpointSource[] => {
|
|
||||||
const result: EndpointSource[] = [];
|
|
||||||
|
|
||||||
const convertFolderToEndpointSourcePreview = ({
|
case Collections.Pages:
|
||||||
id,
|
return { type: Collections.Pages, value: convertPageToEndpointPagePreview(value) };
|
||||||
slug,
|
|
||||||
translations,
|
|
||||||
}: Folder): EndpointSourcePreview => ({
|
|
||||||
id,
|
|
||||||
slug,
|
|
||||||
translations: translations.map(({ language, name }) => ({
|
|
||||||
language: isPayloadType(language) ? language.id : language,
|
|
||||||
title: name,
|
|
||||||
})),
|
|
||||||
});
|
|
||||||
|
|
||||||
const convertCollectibleToEndpointSourcePreview = ({
|
case Collections.Collectibles:
|
||||||
id,
|
return {
|
||||||
slug,
|
type: Collections.Collectibles,
|
||||||
translations,
|
value: convertCollectibleToEndpointCollectiblePreview(value),
|
||||||
}: Collectible): EndpointSourcePreview => ({
|
};
|
||||||
id,
|
|
||||||
slug,
|
|
||||||
translations: translations.map(({ language, title, pretitle, subtitle }) => ({
|
|
||||||
language: isPayloadType(language) ? language.id : language,
|
|
||||||
title,
|
|
||||||
...(isNotEmpty(pretitle) ? { pretitle } : {}),
|
|
||||||
...(isNotEmpty(subtitle) ? { subtitle } : {}),
|
|
||||||
})),
|
|
||||||
});
|
|
||||||
|
|
||||||
if (collectibles && isPayloadArrayType(collectibles)) {
|
case Collections.Images:
|
||||||
collectibles.filter(isPublished).forEach((collectible) => {
|
if (!isImage(value)) return [];
|
||||||
result.push({
|
return { type: Collections.Images, value: convertImageToEndpointImagePreview(value) };
|
||||||
type: "collectible",
|
|
||||||
collectible: convertCollectibleToEndpointSourcePreview(collectible),
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (scans && isPayloadArrayType(scans)) {
|
case Collections.Videos:
|
||||||
scans.filter(isPublished).forEach((collectible) => {
|
if (!isVideo(value)) return [];
|
||||||
result.push({
|
return { type: Collections.Videos, value: convertVideoToEndpointVideoPreview(value) };
|
||||||
type: "scans",
|
|
||||||
collectible: convertCollectibleToEndpointSourcePreview(collectible),
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gallery && isPayloadArrayType(gallery)) {
|
case Collections.Audios:
|
||||||
gallery.filter(isPublished).forEach((collectible) => {
|
if (!isAudio(value)) return [];
|
||||||
result.push({
|
return { type: Collections.Audios, value: convertAudioToEndpointAudioPreview(value) };
|
||||||
type: "gallery",
|
|
||||||
collectible: convertCollectibleToEndpointSourcePreview(collectible),
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (folders && isPayloadArrayType(folders)) {
|
case Collections.Files:
|
||||||
folders.forEach((folder) => {
|
if (!isFile(value)) return [];
|
||||||
result.push({
|
return { type: Collections.Files, value: convertFileToEndpointFilePreview(value) };
|
||||||
type: "folder",
|
|
||||||
folder: convertFolderToEndpointSourcePreview(folder),
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
case Collections.Recorders:
|
||||||
};
|
return {
|
||||||
|
type: Collections.Recorders,
|
||||||
|
value: convertRecorderToEndpointRecorderPreview(value),
|
||||||
|
};
|
||||||
|
|
||||||
|
case Collections.ChronologyEvents:
|
||||||
|
return { type: Collections.ChronologyEvents, value: convertEventToEndpointEvent(value) };
|
||||||
|
|
||||||
|
case Collections.MediaThumbnails:
|
||||||
|
case Collections.VideosSubtitles:
|
||||||
|
case Collections.VideosChannels:
|
||||||
|
case Collections.Scans:
|
||||||
|
case Collections.Tags:
|
||||||
|
case Collections.Attributes:
|
||||||
|
case Collections.CreditsRole:
|
||||||
|
case Collections.Languages:
|
||||||
|
case Collections.Currencies:
|
||||||
|
case Collections.Wordings:
|
||||||
|
case Collections.GenericContents:
|
||||||
|
default:
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}) ?? [];
|
||||||
|
|
||||||
export const getDomainFromUrl = (url: string): string => {
|
export const getDomainFromUrl = (url: string): string => {
|
||||||
const urlObject = new URL(url);
|
const urlObject = new URL(url);
|
||||||
|
|
|
@ -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 "src/accesses/publicAccess";
|
import { publicAccess } from "../accesses/publicAccess";
|
||||||
import { CollectionGroups } from "src/shared/payload/constants";
|
import { BuildCollectionConfig, buildCollectionConfig } from "./collectionConfig";
|
||||||
import { BuildCollectionConfig, buildCollectionConfig } from "src/utils/collectionConfig";
|
import { CollectionGroups } from "../shared/payload/constants";
|
||||||
|
|
||||||
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 "src/types/strapi";
|
import { StrapiImage } from "../types/strapi";
|
||||||
import { isDefined } from "src/utils/asserts";
|
import { isDefined } from "./asserts";
|
||||||
|
|
||||||
type UploadStrapiImage = {
|
type UploadStrapiImage = {
|
||||||
image: StrapiImage;
|
image: StrapiImage;
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import tags from "language-tags";
|
import tags from "language-tags";
|
||||||
import { RichTextContent } from "src/shared/payload/rich-text";
|
import { isUndefined } from "./asserts";
|
||||||
import { isUndefined } from "src/utils/asserts";
|
import { RichTextContent } from "../shared/payload/rich-text";
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
export const formatLanguageCode = (code: string): string =>
|
export const formatLanguageCode = (code: string): string =>
|
||||||
tags(code).valid() ? tags(code).language()?.descriptions()[0] ?? code : code;
|
tags(code).valid() ? (tags(code).language()?.descriptions()[0] ?? code) : code;
|
||||||
|
|
||||||
export const capitalize = (string: string): string => {
|
export const capitalize = (string: string): string => {
|
||||||
const [firstLetter, ...otherLetters] = string;
|
const [firstLetter, ...otherLetters] = string;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { CollectionBeforeChangeHook, CollectionConfig, RelationshipField } from "payload/types";
|
import { CollectionBeforeChangeHook, CollectionConfig, RelationshipField } from "payload/types";
|
||||||
import { Collections } from "src/shared/payload/constants";
|
import { BuildCollectionConfig, buildCollectionConfig } from "./collectionConfig";
|
||||||
import { BuildCollectionConfig, buildCollectionConfig } from "src/utils/collectionConfig";
|
import { Collections } from "../shared/payload/constants";
|
||||||
|
|
||||||
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,7 +116,6 @@
|
||||||
"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