diff --git a/apps/centralcms/src/app/(payload)/admin/importMap.js b/apps/centralcms/src/app/(payload)/admin/importMap.js index 1cedadb71..1501893fe 100644 --- a/apps/centralcms/src/app/(payload)/admin/importMap.js +++ b/apps/centralcms/src/app/(payload)/admin/importMap.js @@ -1,84 +1,63 @@ -import { RichTextCell as RichTextCell_0 } from "@payloadcms/richtext-lexical/client"; -import { RichTextField as RichTextField_1 } from "@payloadcms/richtext-lexical/client"; -import { getGenerateComponentMap as getGenerateComponentMap_2 } from "@payloadcms/richtext-lexical/generateComponentMap"; -import { HorizontalRuleFeatureClient as HorizontalRuleFeatureClient_3 } from "@payloadcms/richtext-lexical/client"; -import { InlineToolbarFeatureClient as InlineToolbarFeatureClient_4 } from "@payloadcms/richtext-lexical/client"; -import { FixedToolbarFeatureClient as FixedToolbarFeatureClient_5 } from "@payloadcms/richtext-lexical/client"; -import { HeadingFeatureClient as HeadingFeatureClient_6 } from "@payloadcms/richtext-lexical/client"; -import { BoldFeatureClient as BoldFeatureClient_7 } from "@payloadcms/richtext-lexical/client"; -import { ItalicFeatureClient as ItalicFeatureClient_8 } from "@payloadcms/richtext-lexical/client"; -import { UnderlineFeatureClient as UnderlineFeatureClient_9 } from "@payloadcms/richtext-lexical/client"; -import { StrikethroughFeatureClient as StrikethroughFeatureClient_10 } from "@payloadcms/richtext-lexical/client"; -import { SubscriptFeatureClient as SubscriptFeatureClient_11 } from "@payloadcms/richtext-lexical/client"; -import { SuperscriptFeatureClient as SuperscriptFeatureClient_12 } from "@payloadcms/richtext-lexical/client"; -import { InlineCodeFeatureClient as InlineCodeFeatureClient_13 } from "@payloadcms/richtext-lexical/client"; -import { ParagraphFeatureClient as ParagraphFeatureClient_14 } from "@payloadcms/richtext-lexical/client"; -import { AlignFeatureClient as AlignFeatureClient_15 } from "@payloadcms/richtext-lexical/client"; -import { IndentFeatureClient as IndentFeatureClient_16 } from "@payloadcms/richtext-lexical/client"; -import { UnorderedListFeatureClient as UnorderedListFeatureClient_17 } from "@payloadcms/richtext-lexical/client"; -import { OrderedListFeatureClient as OrderedListFeatureClient_18 } from "@payloadcms/richtext-lexical/client"; -import { ChecklistFeatureClient as ChecklistFeatureClient_19 } from "@payloadcms/richtext-lexical/client"; -import { LinkFeatureClient as LinkFeatureClient_20 } from "@payloadcms/richtext-lexical/client"; -import { RelationshipFeatureClient as RelationshipFeatureClient_21 } from "@payloadcms/richtext-lexical/client"; -import { BlockquoteFeatureClient as BlockquoteFeatureClient_22 } from "@payloadcms/richtext-lexical/client"; -import { UploadFeatureClient as UploadFeatureClient_23 } from "@payloadcms/richtext-lexical/client"; -import { default as default_24 } from "@/payload/components/RowLabel.tsx"; -import { OverviewComponent as OverviewComponent_25 } from "@payloadcms/plugin-seo/client"; -import { MetaTitleComponent as MetaTitleComponent_26 } from "@payloadcms/plugin-seo/client"; -import { MetaImageComponent as MetaImageComponent_27 } from "@payloadcms/plugin-seo/client"; -import { MetaDescriptionComponent as MetaDescriptionComponent_28 } from "@payloadcms/plugin-seo/client"; -import { PreviewComponent as PreviewComponent_29 } from "@payloadcms/plugin-seo/client"; +import { RichTextCell as RichTextCell_0 } from '@payloadcms/richtext-lexical/client' +import { RichTextField as RichTextField_1 } from '@payloadcms/richtext-lexical/client' +import { getGenerateComponentMap as getGenerateComponentMap_2 } from '@payloadcms/richtext-lexical/generateComponentMap' +import { HorizontalRuleFeatureClient as HorizontalRuleFeatureClient_3 } from '@payloadcms/richtext-lexical/client' +import { InlineToolbarFeatureClient as InlineToolbarFeatureClient_4 } from '@payloadcms/richtext-lexical/client' +import { FixedToolbarFeatureClient as FixedToolbarFeatureClient_5 } from '@payloadcms/richtext-lexical/client' +import { HeadingFeatureClient as HeadingFeatureClient_6 } from '@payloadcms/richtext-lexical/client' +import { BoldFeatureClient as BoldFeatureClient_7 } from '@payloadcms/richtext-lexical/client' +import { ItalicFeatureClient as ItalicFeatureClient_8 } from '@payloadcms/richtext-lexical/client' +import { UnderlineFeatureClient as UnderlineFeatureClient_9 } from '@payloadcms/richtext-lexical/client' +import { StrikethroughFeatureClient as StrikethroughFeatureClient_10 } from '@payloadcms/richtext-lexical/client' +import { SubscriptFeatureClient as SubscriptFeatureClient_11 } from '@payloadcms/richtext-lexical/client' +import { SuperscriptFeatureClient as SuperscriptFeatureClient_12 } from '@payloadcms/richtext-lexical/client' +import { InlineCodeFeatureClient as InlineCodeFeatureClient_13 } from '@payloadcms/richtext-lexical/client' +import { ParagraphFeatureClient as ParagraphFeatureClient_14 } from '@payloadcms/richtext-lexical/client' +import { AlignFeatureClient as AlignFeatureClient_15 } from '@payloadcms/richtext-lexical/client' +import { IndentFeatureClient as IndentFeatureClient_16 } from '@payloadcms/richtext-lexical/client' +import { UnorderedListFeatureClient as UnorderedListFeatureClient_17 } from '@payloadcms/richtext-lexical/client' +import { OrderedListFeatureClient as OrderedListFeatureClient_18 } from '@payloadcms/richtext-lexical/client' +import { ChecklistFeatureClient as ChecklistFeatureClient_19 } from '@payloadcms/richtext-lexical/client' +import { LinkFeatureClient as LinkFeatureClient_20 } from '@payloadcms/richtext-lexical/client' +import { RelationshipFeatureClient as RelationshipFeatureClient_21 } from '@payloadcms/richtext-lexical/client' +import { BlockquoteFeatureClient as BlockquoteFeatureClient_22 } from '@payloadcms/richtext-lexical/client' +import { UploadFeatureClient as UploadFeatureClient_23 } from '@payloadcms/richtext-lexical/client' +import { default as default_24 } from '@/payload/components/RowLabel.tsx' +import { OverviewComponent as OverviewComponent_25 } from '@payloadcms/plugin-seo/client' +import { MetaTitleComponent as MetaTitleComponent_26 } from '@payloadcms/plugin-seo/client' +import { MetaImageComponent as MetaImageComponent_27 } from '@payloadcms/plugin-seo/client' +import { MetaDescriptionComponent as MetaDescriptionComponent_28 } from '@payloadcms/plugin-seo/client' +import { PreviewComponent as PreviewComponent_29 } from '@payloadcms/plugin-seo/client' export const importMap = { "@payloadcms/richtext-lexical/client#RichTextCell": RichTextCell_0, "@payloadcms/richtext-lexical/client#RichTextField": RichTextField_1, - "@payloadcms/richtext-lexical/generateComponentMap#getGenerateComponentMap": - getGenerateComponentMap_2, - "@payloadcms/richtext-lexical/client#HorizontalRuleFeatureClient": - HorizontalRuleFeatureClient_3, - "@payloadcms/richtext-lexical/client#InlineToolbarFeatureClient": - InlineToolbarFeatureClient_4, - "@payloadcms/richtext-lexical/client#FixedToolbarFeatureClient": - FixedToolbarFeatureClient_5, - "@payloadcms/richtext-lexical/client#HeadingFeatureClient": - HeadingFeatureClient_6, + "@payloadcms/richtext-lexical/generateComponentMap#getGenerateComponentMap": getGenerateComponentMap_2, + "@payloadcms/richtext-lexical/client#HorizontalRuleFeatureClient": HorizontalRuleFeatureClient_3, + "@payloadcms/richtext-lexical/client#InlineToolbarFeatureClient": InlineToolbarFeatureClient_4, + "@payloadcms/richtext-lexical/client#FixedToolbarFeatureClient": FixedToolbarFeatureClient_5, + "@payloadcms/richtext-lexical/client#HeadingFeatureClient": HeadingFeatureClient_6, "@payloadcms/richtext-lexical/client#BoldFeatureClient": BoldFeatureClient_7, - "@payloadcms/richtext-lexical/client#ItalicFeatureClient": - ItalicFeatureClient_8, - "@payloadcms/richtext-lexical/client#UnderlineFeatureClient": - UnderlineFeatureClient_9, - "@payloadcms/richtext-lexical/client#StrikethroughFeatureClient": - StrikethroughFeatureClient_10, - "@payloadcms/richtext-lexical/client#SubscriptFeatureClient": - SubscriptFeatureClient_11, - "@payloadcms/richtext-lexical/client#SuperscriptFeatureClient": - SuperscriptFeatureClient_12, - "@payloadcms/richtext-lexical/client#InlineCodeFeatureClient": - InlineCodeFeatureClient_13, - "@payloadcms/richtext-lexical/client#ParagraphFeatureClient": - ParagraphFeatureClient_14, - "@payloadcms/richtext-lexical/client#AlignFeatureClient": - AlignFeatureClient_15, - "@payloadcms/richtext-lexical/client#IndentFeatureClient": - IndentFeatureClient_16, - "@payloadcms/richtext-lexical/client#UnorderedListFeatureClient": - UnorderedListFeatureClient_17, - "@payloadcms/richtext-lexical/client#OrderedListFeatureClient": - OrderedListFeatureClient_18, - "@payloadcms/richtext-lexical/client#ChecklistFeatureClient": - ChecklistFeatureClient_19, + "@payloadcms/richtext-lexical/client#ItalicFeatureClient": ItalicFeatureClient_8, + "@payloadcms/richtext-lexical/client#UnderlineFeatureClient": UnderlineFeatureClient_9, + "@payloadcms/richtext-lexical/client#StrikethroughFeatureClient": StrikethroughFeatureClient_10, + "@payloadcms/richtext-lexical/client#SubscriptFeatureClient": SubscriptFeatureClient_11, + "@payloadcms/richtext-lexical/client#SuperscriptFeatureClient": SuperscriptFeatureClient_12, + "@payloadcms/richtext-lexical/client#InlineCodeFeatureClient": InlineCodeFeatureClient_13, + "@payloadcms/richtext-lexical/client#ParagraphFeatureClient": ParagraphFeatureClient_14, + "@payloadcms/richtext-lexical/client#AlignFeatureClient": AlignFeatureClient_15, + "@payloadcms/richtext-lexical/client#IndentFeatureClient": IndentFeatureClient_16, + "@payloadcms/richtext-lexical/client#UnorderedListFeatureClient": UnorderedListFeatureClient_17, + "@payloadcms/richtext-lexical/client#OrderedListFeatureClient": OrderedListFeatureClient_18, + "@payloadcms/richtext-lexical/client#ChecklistFeatureClient": ChecklistFeatureClient_19, "@payloadcms/richtext-lexical/client#LinkFeatureClient": LinkFeatureClient_20, - "@payloadcms/richtext-lexical/client#RelationshipFeatureClient": - RelationshipFeatureClient_21, - "@payloadcms/richtext-lexical/client#BlockquoteFeatureClient": - BlockquoteFeatureClient_22, - "@payloadcms/richtext-lexical/client#UploadFeatureClient": - UploadFeatureClient_23, + "@payloadcms/richtext-lexical/client#RelationshipFeatureClient": RelationshipFeatureClient_21, + "@payloadcms/richtext-lexical/client#BlockquoteFeatureClient": BlockquoteFeatureClient_22, + "@payloadcms/richtext-lexical/client#UploadFeatureClient": UploadFeatureClient_23, "@/payload/components/RowLabel.tsx#default": default_24, "@payloadcms/plugin-seo/client#OverviewComponent": OverviewComponent_25, "@payloadcms/plugin-seo/client#MetaTitleComponent": MetaTitleComponent_26, "@payloadcms/plugin-seo/client#MetaImageComponent": MetaImageComponent_27, - "@payloadcms/plugin-seo/client#MetaDescriptionComponent": - MetaDescriptionComponent_28, - "@payloadcms/plugin-seo/client#PreviewComponent": PreviewComponent_29, -}; + "@payloadcms/plugin-seo/client#MetaDescriptionComponent": MetaDescriptionComponent_28, + "@payloadcms/plugin-seo/client#PreviewComponent": PreviewComponent_29 +} diff --git a/apps/centralcms/src/payload-types.ts b/apps/centralcms/src/payload-types.ts index 658f5e5a8..3e842661d 100644 --- a/apps/centralcms/src/payload-types.ts +++ b/apps/centralcms/src/payload-types.ts @@ -16,7 +16,7 @@ export interface Config { tenants: Tenant; author: Author; donors: Donor; - "guiding-principles": GuidingPrinciple; + 'guiding-principles': GuidingPrinciple; impact: Impact; offices: Office; members: Member; @@ -27,19 +27,19 @@ export interface Config { teams: Team; CodeForAfricaPages: CodeForAfricaPage; RoboshieldPages: RoboshieldPage; - "payload-preferences": PayloadPreference; - "payload-migrations": PayloadMigration; + 'payload-preferences': PayloadPreference; + 'payload-migrations': PayloadMigration; }; db: { defaultIDType: string; }; globals: { - "codeforafrica-site-settings": CodeforafricaSiteSetting; - "roboshield-site-settings": RoboshieldSiteSetting; + 'codeforafrica-site-settings': CodeforafricaSiteSetting; + 'roboshield-site-settings': RoboshieldSiteSetting; }; locale: null; user: User & { - collection: "users"; + collection: 'users'; }; } export interface UserAuthOperations { @@ -68,11 +68,11 @@ export interface User { id: string; firstName?: string | null; lastName?: string | null; - roles: ("super-admin" | "user")[]; + roles: ('super-admin' | 'user')[]; tenants?: | { tenant: string | Tenant; - roles: ("admin" | "user")[]; + roles: ('admin' | 'user')[]; id?: string | null; }[] | null; @@ -166,8 +166,8 @@ export interface GuidingPrinciple { version: number; [k: string]: unknown; }[]; - direction: ("ltr" | "rtl") | null; - format: "left" | "start" | "center" | "right" | "end" | "justify" | ""; + direction: ('ltr' | 'rtl') | null; + format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; indent: number; version: number; }; @@ -191,8 +191,8 @@ export interface Impact { version: number; [k: string]: unknown; }[]; - direction: ("ltr" | "rtl") | null; - format: "left" | "start" | "center" | "right" | "end" | "justify" | ""; + direction: ('ltr' | 'rtl') | null; + format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; indent: number; version: number; }; @@ -220,255 +220,255 @@ export interface Office { zipCode?: string | null; country?: | ( - | "AFG" - | "ALA" - | "ALB" - | "DZA" - | "ASM" - | "AND" - | "AGO" - | "AIA" - | "ATA" - | "ATG" - | "ARG" - | "ARM" - | "ABW" - | "AUS" - | "AUT" - | "AZE" - | "BHS" - | "BHR" - | "BGD" - | "BRB" - | "BLR" - | "BEL" - | "BLZ" - | "BEN" - | "BMU" - | "BTN" - | "BOL" - | "BES" - | "BIH" - | "BWA" - | "BVT" - | "BRA" - | "IOT" - | "BRN" - | "BGR" - | "BFA" - | "BDI" - | "CPV" - | "KHM" - | "CMR" - | "CAN" - | "CYM" - | "CAF" - | "TCD" - | "CHL" - | "CHN" - | "CXR" - | "CCK" - | "COL" - | "COM" - | "COG" - | "COD" - | "COK" - | "CRI" - | "CIV" - | "HRV" - | "CUB" - | "CUW" - | "CYP" - | "CZE" - | "DNK" - | "DJI" - | "DMA" - | "DOM" - | "ECU" - | "EGY" - | "SLV" - | "GNQ" - | "ERI" - | "EST" - | "SWZ" - | "ETH" - | "FLK" - | "FRO" - | "FJI" - | "FIN" - | "FRA" - | "GUF" - | "PYF" - | "ATF" - | "GAB" - | "GMB" - | "GEO" - | "DEU" - | "GHA" - | "GIB" - | "GRC" - | "GRL" - | "GRD" - | "GLP" - | "GUM" - | "GTM" - | "GGY" - | "GIN" - | "GNB" - | "GUY" - | "HTI" - | "HMD" - | "VAT" - | "HND" - | "HKG" - | "HUN" - | "ISL" - | "IND" - | "IDN" - | "IRN" - | "IRQ" - | "IRL" - | "IMN" - | "ISR" - | "ITA" - | "JAM" - | "JPN" - | "JEY" - | "JOR" - | "KAZ" - | "KEN" - | "KIR" - | "PRK" - | "KOR" - | "KWT" - | "KGZ" - | "LAO" - | "LVA" - | "LBN" - | "LSO" - | "LBR" - | "LBY" - | "LIE" - | "LTU" - | "LUX" - | "MAC" - | "MDG" - | "MWI" - | "MYS" - | "MDV" - | "MLI" - | "MLT" - | "MHL" - | "MTQ" - | "MRT" - | "MUS" - | "MYT" - | "MEX" - | "FSM" - | "MDA" - | "MCO" - | "MNG" - | "MNE" - | "MSR" - | "MAR" - | "MOZ" - | "MMR" - | "NAM" - | "NRU" - | "NPL" - | "NLD" - | "NCL" - | "NZL" - | "NIC" - | "NER" - | "NGA" - | "NIU" - | "NFK" - | "MKD" - | "MNP" - | "NOR" - | "OMN" - | "PAK" - | "PLW" - | "PSE" - | "PAN" - | "PNG" - | "PRY" - | "PER" - | "PHL" - | "PCN" - | "POL" - | "PRT" - | "PRI" - | "QAT" - | "REU" - | "ROU" - | "RUS" - | "RWA" - | "BLM" - | "SHN" - | "KNA" - | "LCA" - | "MAF" - | "SPM" - | "VCT" - | "WSM" - | "SMR" - | "STP" - | "SAU" - | "SEN" - | "SRB" - | "SYC" - | "SLE" - | "SGP" - | "SXM" - | "SVK" - | "SVN" - | "SLB" - | "SOM" - | "ZAF" - | "SGS" - | "SSD" - | "ESP" - | "LKA" - | "SDN" - | "SUR" - | "SJM" - | "SWE" - | "CHE" - | "SYR" - | "TWN" - | "TJK" - | "TZA" - | "THA" - | "TLS" - | "TGO" - | "TKL" - | "TON" - | "TTO" - | "TUN" - | "TUR" - | "TKM" - | "TCA" - | "TUV" - | "UGA" - | "UKR" - | "ARE" - | "GBR" - | "USA" - | "UMI" - | "URY" - | "UZB" - | "VUT" - | "VEN" - | "VNM" - | "VGB" - | "VIR" - | "WLF" - | "ESH" - | "YEM" - | "ZMB" - | "ZWE" + | 'AFG' + | 'ALA' + | 'ALB' + | 'DZA' + | 'ASM' + | 'AND' + | 'AGO' + | 'AIA' + | 'ATA' + | 'ATG' + | 'ARG' + | 'ARM' + | 'ABW' + | 'AUS' + | 'AUT' + | 'AZE' + | 'BHS' + | 'BHR' + | 'BGD' + | 'BRB' + | 'BLR' + | 'BEL' + | 'BLZ' + | 'BEN' + | 'BMU' + | 'BTN' + | 'BOL' + | 'BES' + | 'BIH' + | 'BWA' + | 'BVT' + | 'BRA' + | 'IOT' + | 'BRN' + | 'BGR' + | 'BFA' + | 'BDI' + | 'CPV' + | 'KHM' + | 'CMR' + | 'CAN' + | 'CYM' + | 'CAF' + | 'TCD' + | 'CHL' + | 'CHN' + | 'CXR' + | 'CCK' + | 'COL' + | 'COM' + | 'COG' + | 'COD' + | 'COK' + | 'CRI' + | 'CIV' + | 'HRV' + | 'CUB' + | 'CUW' + | 'CYP' + | 'CZE' + | 'DNK' + | 'DJI' + | 'DMA' + | 'DOM' + | 'ECU' + | 'EGY' + | 'SLV' + | 'GNQ' + | 'ERI' + | 'EST' + | 'SWZ' + | 'ETH' + | 'FLK' + | 'FRO' + | 'FJI' + | 'FIN' + | 'FRA' + | 'GUF' + | 'PYF' + | 'ATF' + | 'GAB' + | 'GMB' + | 'GEO' + | 'DEU' + | 'GHA' + | 'GIB' + | 'GRC' + | 'GRL' + | 'GRD' + | 'GLP' + | 'GUM' + | 'GTM' + | 'GGY' + | 'GIN' + | 'GNB' + | 'GUY' + | 'HTI' + | 'HMD' + | 'VAT' + | 'HND' + | 'HKG' + | 'HUN' + | 'ISL' + | 'IND' + | 'IDN' + | 'IRN' + | 'IRQ' + | 'IRL' + | 'IMN' + | 'ISR' + | 'ITA' + | 'JAM' + | 'JPN' + | 'JEY' + | 'JOR' + | 'KAZ' + | 'KEN' + | 'KIR' + | 'PRK' + | 'KOR' + | 'KWT' + | 'KGZ' + | 'LAO' + | 'LVA' + | 'LBN' + | 'LSO' + | 'LBR' + | 'LBY' + | 'LIE' + | 'LTU' + | 'LUX' + | 'MAC' + | 'MDG' + | 'MWI' + | 'MYS' + | 'MDV' + | 'MLI' + | 'MLT' + | 'MHL' + | 'MTQ' + | 'MRT' + | 'MUS' + | 'MYT' + | 'MEX' + | 'FSM' + | 'MDA' + | 'MCO' + | 'MNG' + | 'MNE' + | 'MSR' + | 'MAR' + | 'MOZ' + | 'MMR' + | 'NAM' + | 'NRU' + | 'NPL' + | 'NLD' + | 'NCL' + | 'NZL' + | 'NIC' + | 'NER' + | 'NGA' + | 'NIU' + | 'NFK' + | 'MKD' + | 'MNP' + | 'NOR' + | 'OMN' + | 'PAK' + | 'PLW' + | 'PSE' + | 'PAN' + | 'PNG' + | 'PRY' + | 'PER' + | 'PHL' + | 'PCN' + | 'POL' + | 'PRT' + | 'PRI' + | 'QAT' + | 'REU' + | 'ROU' + | 'RUS' + | 'RWA' + | 'BLM' + | 'SHN' + | 'KNA' + | 'LCA' + | 'MAF' + | 'SPM' + | 'VCT' + | 'WSM' + | 'SMR' + | 'STP' + | 'SAU' + | 'SEN' + | 'SRB' + | 'SYC' + | 'SLE' + | 'SGP' + | 'SXM' + | 'SVK' + | 'SVN' + | 'SLB' + | 'SOM' + | 'ZAF' + | 'SGS' + | 'SSD' + | 'ESP' + | 'LKA' + | 'SDN' + | 'SUR' + | 'SJM' + | 'SWE' + | 'CHE' + | 'SYR' + | 'TWN' + | 'TJK' + | 'TZA' + | 'THA' + | 'TLS' + | 'TGO' + | 'TKL' + | 'TON' + | 'TTO' + | 'TUN' + | 'TUR' + | 'TKM' + | 'TCA' + | 'TUV' + | 'UGA' + | 'UKR' + | 'ARE' + | 'GBR' + | 'USA' + | 'UMI' + | 'URY' + | 'UZB' + | 'VUT' + | 'VEN' + | 'VNM' + | 'VGB' + | 'VIR' + | 'WLF' + | 'ESH' + | 'YEM' + | 'ZMB' + | 'ZWE' ) | null; updatedAt: string; @@ -486,255 +486,255 @@ export interface Member { slug?: string | null; country?: | ( - | "AFG" - | "ALA" - | "ALB" - | "DZA" - | "ASM" - | "AND" - | "AGO" - | "AIA" - | "ATA" - | "ATG" - | "ARG" - | "ARM" - | "ABW" - | "AUS" - | "AUT" - | "AZE" - | "BHS" - | "BHR" - | "BGD" - | "BRB" - | "BLR" - | "BEL" - | "BLZ" - | "BEN" - | "BMU" - | "BTN" - | "BOL" - | "BES" - | "BIH" - | "BWA" - | "BVT" - | "BRA" - | "IOT" - | "BRN" - | "BGR" - | "BFA" - | "BDI" - | "CPV" - | "KHM" - | "CMR" - | "CAN" - | "CYM" - | "CAF" - | "TCD" - | "CHL" - | "CHN" - | "CXR" - | "CCK" - | "COL" - | "COM" - | "COG" - | "COD" - | "COK" - | "CRI" - | "CIV" - | "HRV" - | "CUB" - | "CUW" - | "CYP" - | "CZE" - | "DNK" - | "DJI" - | "DMA" - | "DOM" - | "ECU" - | "EGY" - | "SLV" - | "GNQ" - | "ERI" - | "EST" - | "SWZ" - | "ETH" - | "FLK" - | "FRO" - | "FJI" - | "FIN" - | "FRA" - | "GUF" - | "PYF" - | "ATF" - | "GAB" - | "GMB" - | "GEO" - | "DEU" - | "GHA" - | "GIB" - | "GRC" - | "GRL" - | "GRD" - | "GLP" - | "GUM" - | "GTM" - | "GGY" - | "GIN" - | "GNB" - | "GUY" - | "HTI" - | "HMD" - | "VAT" - | "HND" - | "HKG" - | "HUN" - | "ISL" - | "IND" - | "IDN" - | "IRN" - | "IRQ" - | "IRL" - | "IMN" - | "ISR" - | "ITA" - | "JAM" - | "JPN" - | "JEY" - | "JOR" - | "KAZ" - | "KEN" - | "KIR" - | "PRK" - | "KOR" - | "KWT" - | "KGZ" - | "LAO" - | "LVA" - | "LBN" - | "LSO" - | "LBR" - | "LBY" - | "LIE" - | "LTU" - | "LUX" - | "MAC" - | "MDG" - | "MWI" - | "MYS" - | "MDV" - | "MLI" - | "MLT" - | "MHL" - | "MTQ" - | "MRT" - | "MUS" - | "MYT" - | "MEX" - | "FSM" - | "MDA" - | "MCO" - | "MNG" - | "MNE" - | "MSR" - | "MAR" - | "MOZ" - | "MMR" - | "NAM" - | "NRU" - | "NPL" - | "NLD" - | "NCL" - | "NZL" - | "NIC" - | "NER" - | "NGA" - | "NIU" - | "NFK" - | "MKD" - | "MNP" - | "NOR" - | "OMN" - | "PAK" - | "PLW" - | "PSE" - | "PAN" - | "PNG" - | "PRY" - | "PER" - | "PHL" - | "PCN" - | "POL" - | "PRT" - | "PRI" - | "QAT" - | "REU" - | "ROU" - | "RUS" - | "RWA" - | "BLM" - | "SHN" - | "KNA" - | "LCA" - | "MAF" - | "SPM" - | "VCT" - | "WSM" - | "SMR" - | "STP" - | "SAU" - | "SEN" - | "SRB" - | "SYC" - | "SLE" - | "SGP" - | "SXM" - | "SVK" - | "SVN" - | "SLB" - | "SOM" - | "ZAF" - | "SGS" - | "SSD" - | "ESP" - | "LKA" - | "SDN" - | "SUR" - | "SJM" - | "SWE" - | "CHE" - | "SYR" - | "TWN" - | "TJK" - | "TZA" - | "THA" - | "TLS" - | "TGO" - | "TKL" - | "TON" - | "TTO" - | "TUN" - | "TUR" - | "TKM" - | "TCA" - | "TUV" - | "UGA" - | "UKR" - | "ARE" - | "GBR" - | "USA" - | "UMI" - | "URY" - | "UZB" - | "VUT" - | "VEN" - | "VNM" - | "VGB" - | "VIR" - | "WLF" - | "ESH" - | "YEM" - | "ZMB" - | "ZWE" + | 'AFG' + | 'ALA' + | 'ALB' + | 'DZA' + | 'ASM' + | 'AND' + | 'AGO' + | 'AIA' + | 'ATA' + | 'ATG' + | 'ARG' + | 'ARM' + | 'ABW' + | 'AUS' + | 'AUT' + | 'AZE' + | 'BHS' + | 'BHR' + | 'BGD' + | 'BRB' + | 'BLR' + | 'BEL' + | 'BLZ' + | 'BEN' + | 'BMU' + | 'BTN' + | 'BOL' + | 'BES' + | 'BIH' + | 'BWA' + | 'BVT' + | 'BRA' + | 'IOT' + | 'BRN' + | 'BGR' + | 'BFA' + | 'BDI' + | 'CPV' + | 'KHM' + | 'CMR' + | 'CAN' + | 'CYM' + | 'CAF' + | 'TCD' + | 'CHL' + | 'CHN' + | 'CXR' + | 'CCK' + | 'COL' + | 'COM' + | 'COG' + | 'COD' + | 'COK' + | 'CRI' + | 'CIV' + | 'HRV' + | 'CUB' + | 'CUW' + | 'CYP' + | 'CZE' + | 'DNK' + | 'DJI' + | 'DMA' + | 'DOM' + | 'ECU' + | 'EGY' + | 'SLV' + | 'GNQ' + | 'ERI' + | 'EST' + | 'SWZ' + | 'ETH' + | 'FLK' + | 'FRO' + | 'FJI' + | 'FIN' + | 'FRA' + | 'GUF' + | 'PYF' + | 'ATF' + | 'GAB' + | 'GMB' + | 'GEO' + | 'DEU' + | 'GHA' + | 'GIB' + | 'GRC' + | 'GRL' + | 'GRD' + | 'GLP' + | 'GUM' + | 'GTM' + | 'GGY' + | 'GIN' + | 'GNB' + | 'GUY' + | 'HTI' + | 'HMD' + | 'VAT' + | 'HND' + | 'HKG' + | 'HUN' + | 'ISL' + | 'IND' + | 'IDN' + | 'IRN' + | 'IRQ' + | 'IRL' + | 'IMN' + | 'ISR' + | 'ITA' + | 'JAM' + | 'JPN' + | 'JEY' + | 'JOR' + | 'KAZ' + | 'KEN' + | 'KIR' + | 'PRK' + | 'KOR' + | 'KWT' + | 'KGZ' + | 'LAO' + | 'LVA' + | 'LBN' + | 'LSO' + | 'LBR' + | 'LBY' + | 'LIE' + | 'LTU' + | 'LUX' + | 'MAC' + | 'MDG' + | 'MWI' + | 'MYS' + | 'MDV' + | 'MLI' + | 'MLT' + | 'MHL' + | 'MTQ' + | 'MRT' + | 'MUS' + | 'MYT' + | 'MEX' + | 'FSM' + | 'MDA' + | 'MCO' + | 'MNG' + | 'MNE' + | 'MSR' + | 'MAR' + | 'MOZ' + | 'MMR' + | 'NAM' + | 'NRU' + | 'NPL' + | 'NLD' + | 'NCL' + | 'NZL' + | 'NIC' + | 'NER' + | 'NGA' + | 'NIU' + | 'NFK' + | 'MKD' + | 'MNP' + | 'NOR' + | 'OMN' + | 'PAK' + | 'PLW' + | 'PSE' + | 'PAN' + | 'PNG' + | 'PRY' + | 'PER' + | 'PHL' + | 'PCN' + | 'POL' + | 'PRT' + | 'PRI' + | 'QAT' + | 'REU' + | 'ROU' + | 'RUS' + | 'RWA' + | 'BLM' + | 'SHN' + | 'KNA' + | 'LCA' + | 'MAF' + | 'SPM' + | 'VCT' + | 'WSM' + | 'SMR' + | 'STP' + | 'SAU' + | 'SEN' + | 'SRB' + | 'SYC' + | 'SLE' + | 'SGP' + | 'SXM' + | 'SVK' + | 'SVN' + | 'SLB' + | 'SOM' + | 'ZAF' + | 'SGS' + | 'SSD' + | 'ESP' + | 'LKA' + | 'SDN' + | 'SUR' + | 'SJM' + | 'SWE' + | 'CHE' + | 'SYR' + | 'TWN' + | 'TJK' + | 'TZA' + | 'THA' + | 'TLS' + | 'TGO' + | 'TKL' + | 'TON' + | 'TTO' + | 'TUN' + | 'TUR' + | 'TKM' + | 'TCA' + | 'TUV' + | 'UGA' + | 'UKR' + | 'ARE' + | 'GBR' + | 'USA' + | 'UMI' + | 'URY' + | 'UZB' + | 'VUT' + | 'VEN' + | 'VNM' + | 'VGB' + | 'VIR' + | 'WLF' + | 'ESH' + | 'YEM' + | 'ZMB' + | 'ZWE' ) | null; description: { @@ -745,8 +745,8 @@ export interface Member { version: number; [k: string]: unknown; }[]; - direction: ("ltr" | "rtl") | null; - format: "left" | "start" | "center" | "right" | "end" | "justify" | ""; + direction: ('ltr' | 'rtl') | null; + format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; indent: number; version: number; }; @@ -754,13 +754,7 @@ export interface Member { }; connect?: | { - platform: - | "Facebook" - | "Twitter" - | "Instagram" - | "Linkedin" - | "Github" - | "Slack"; + platform: 'Facebook' | 'Twitter' | 'Instagram' | 'Linkedin' | 'Github' | 'Slack'; url: string; id?: string | null; }[] @@ -797,8 +791,8 @@ export interface Partner { version: number; [k: string]: unknown; }[]; - direction: ("ltr" | "rtl") | null; - format: "left" | "start" | "center" | "right" | "end" | "justify" | ""; + direction: ('ltr' | 'rtl') | null; + format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; indent: number; version: number; }; @@ -806,13 +800,7 @@ export interface Partner { }; connect?: | { - platform: - | "Facebook" - | "Twitter" - | "Instagram" - | "Linkedin" - | "Github" - | "Slack"; + platform: 'Facebook' | 'Twitter' | 'Instagram' | 'Linkedin' | 'Github' | 'Slack'; url: string; id?: string | null; }[] @@ -836,8 +824,8 @@ export interface Project { version: number; [k: string]: unknown; }[]; - direction: ("ltr" | "rtl") | null; - format: "left" | "start" | "center" | "right" | "end" | "justify" | ""; + direction: ('ltr' | 'rtl') | null; + format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; indent: number; version: number; }; @@ -851,8 +839,8 @@ export interface Project { version: number; [k: string]: unknown; }[]; - direction: ("ltr" | "rtl") | null; - format: "left" | "start" | "center" | "right" | "end" | "justify" | ""; + direction: ('ltr' | 'rtl') | null; + format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; indent: number; version: number; }; @@ -861,21 +849,20 @@ export interface Project { tagLine: string; tag: string | Tag; externalLink: { - link: { - label: string; - type?: ("internal" | "custom") | null; - internal?: - | ({ - relationTo: "RoboshieldPages"; - value: string | RoboshieldPage; - } | null) - | ({ - relationTo: "CodeForAfricaPages"; - value: string | CodeForAfricaPage; - } | null); - url?: string | null; - newTab?: boolean | null; - }; + label: string; + linkType?: ('custom' | 'internal') | null; + doc?: + | ({ + relationTo: 'RoboshieldPages'; + value: string | RoboshieldPage; + } | null) + | ({ + relationTo: 'CodeForAfricaPages'; + value: string | CodeForAfricaPage; + } | null); + url?: string | null; + href: string; + newTab?: boolean | null; }; thumbnail: string | Media; badges?: @@ -893,8 +880,8 @@ export interface Project { version: number; [k: string]: unknown; }[]; - direction: ("ltr" | "rtl") | null; - format: "left" | "start" | "center" | "right" | "end" | "justify" | ""; + direction: ('ltr' | 'rtl') | null; + format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; indent: number; version: number; }; @@ -902,21 +889,20 @@ export interface Project { }; links?: | { - type: "source" | "data"; - link: { - label: string; - type?: ("internal" | "custom") | null; - internal?: - | ({ - relationTo: "RoboshieldPages"; - value: string | RoboshieldPage; - } | null) - | ({ - relationTo: "CodeForAfricaPages"; - value: string | CodeForAfricaPage; - } | null); - url?: string | null; - }; + type: 'source' | 'data'; + label: string; + linkType?: ('custom' | 'internal') | null; + doc?: + | ({ + relationTo: 'RoboshieldPages'; + value: string | RoboshieldPage; + } | null) + | ({ + relationTo: 'CodeForAfricaPages'; + value: string | CodeForAfricaPage; + } | null); + url?: string | null; + href: string; id?: string | null; }[] | null; @@ -955,8 +941,8 @@ export interface RoboshieldPage { version: number; [k: string]: unknown; }[]; - direction: ("ltr" | "rtl") | null; - format: "left" | "start" | "center" | "right" | "end" | "justify" | ""; + direction: ('ltr' | 'rtl') | null; + format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; indent: number; version: number; }; @@ -969,7 +955,7 @@ export interface RoboshieldPage { subtitle: string; id?: string | null; blockName?: string | null; - blockType: "page-header"; + blockType: 'page-header'; } | SiteHero | { @@ -984,15 +970,8 @@ export interface RoboshieldPage { version: number; [k: string]: unknown; }[]; - direction: ("ltr" | "rtl") | null; - format: - | "left" - | "start" - | "center" - | "right" - | "end" - | "justify" - | ""; + direction: ('ltr' | 'rtl') | null; + format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; indent: number; version: number; }; @@ -1000,30 +979,30 @@ export interface RoboshieldPage { }; id?: string | null; blockName?: string | null; - blockType: "richtext"; + blockType: 'richtext'; } | { image: string | Media; id?: string | null; blockName?: string | null; - blockType: "mediaBlock"; + blockType: 'mediaBlock'; } | { externalEmbedFields?: { - embedType?: ("url" | "code") | null; + embedType?: ('url' | 'code') | null; url?: string | null; caption?: string | null; code?: string | null; }; id?: string | null; blockName?: string | null; - blockType: "externalEmbed"; + blockType: 'externalEmbed'; } )[] | null; id?: string | null; blockName?: string | null; - blockType: "content"; + blockType: 'content'; } | { title: string; @@ -1039,15 +1018,8 @@ export interface RoboshieldPage { version: number; [k: string]: unknown; }[]; - direction: ("ltr" | "rtl") | null; - format: - | "left" - | "start" - | "center" - | "right" - | "end" - | "justify" - | ""; + direction: ('ltr' | 'rtl') | null; + format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; indent: number; version: number; }; @@ -1059,7 +1031,7 @@ export interface RoboshieldPage { | null; id?: string | null; blockName?: string | null; - blockType: "statistics"; + blockType: 'statistics'; } | { steps?: @@ -1074,15 +1046,8 @@ export interface RoboshieldPage { version: number; [k: string]: unknown; }[]; - direction: ("ltr" | "rtl") | null; - format: - | "left" - | "start" - | "center" - | "right" - | "end" - | "justify" - | ""; + direction: ('ltr' | 'rtl') | null; + format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; indent: number; version: number; }; @@ -1095,7 +1060,7 @@ export interface RoboshieldPage { fetch: string; id?: string | null; blockName?: string | null; - blockType: "existing-robots-txt"; + blockType: 'existing-robots-txt'; } | { title: string; @@ -1107,15 +1072,8 @@ export interface RoboshieldPage { version: number; [k: string]: unknown; }[]; - direction: ("ltr" | "rtl") | null; - format: - | "left" - | "start" - | "center" - | "right" - | "end" - | "justify" - | ""; + direction: ('ltr' | 'rtl') | null; + format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; indent: number; version: number; }; @@ -1135,7 +1093,7 @@ export interface RoboshieldPage { }; id?: string | null; blockName?: string | null; - blockType: "delays"; + blockType: 'delays'; } | { title: string; @@ -1147,15 +1105,8 @@ export interface RoboshieldPage { version: number; [k: string]: unknown; }[]; - direction: ("ltr" | "rtl") | null; - format: - | "left" - | "start" - | "center" - | "right" - | "end" - | "justify" - | ""; + direction: ('ltr' | 'rtl') | null; + format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; indent: number; version: number; }; @@ -1175,7 +1126,7 @@ export interface RoboshieldPage { }; id?: string | null; blockName?: string | null; - blockType: "paths"; + blockType: 'paths'; } | { title: string; @@ -1187,15 +1138,8 @@ export interface RoboshieldPage { version: number; [k: string]: unknown; }[]; - direction: ("ltr" | "rtl") | null; - format: - | "left" - | "start" - | "center" - | "right" - | "end" - | "justify" - | ""; + direction: ('ltr' | 'rtl') | null; + format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; indent: number; version: number; }; @@ -1211,7 +1155,7 @@ export interface RoboshieldPage { }; id?: string | null; blockName?: string | null; - blockType: "block-bots"; + blockType: 'block-bots'; } | { title: string; @@ -1223,15 +1167,8 @@ export interface RoboshieldPage { version: number; [k: string]: unknown; }[]; - direction: ("ltr" | "rtl") | null; - format: - | "left" - | "start" - | "center" - | "right" - | "end" - | "justify" - | ""; + direction: ('ltr' | 'rtl') | null; + format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; indent: number; version: number; }; @@ -1240,7 +1177,7 @@ export interface RoboshieldPage { placeholder: string; id?: string | null; blockName?: string | null; - blockType: "site-maps"; + blockType: 'site-maps'; } | { title: string; @@ -1252,15 +1189,8 @@ export interface RoboshieldPage { version: number; [k: string]: unknown; }[]; - direction: ("ltr" | "rtl") | null; - format: - | "left" - | "start" - | "center" - | "right" - | "end" - | "justify" - | ""; + direction: ('ltr' | 'rtl') | null; + format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; indent: number; version: number; }; @@ -1269,7 +1199,7 @@ export interface RoboshieldPage { placeholder: string; id?: string | null; blockName?: string | null; - blockType: "finish"; + blockType: 'finish'; } )[] | null; @@ -1283,7 +1213,7 @@ export interface RoboshieldPage { }; id?: string | null; blockName?: string | null; - blockType: "robots-txt-generator"; + blockType: 'robots-txt-generator'; } )[] | null; @@ -1302,7 +1232,7 @@ export interface RoboshieldPage { export interface SiteHero { heroHeaders?: | { - headingType?: ("largeHeading" | "subHeading" | "rotatingText") | null; + headingType?: ('largeHeading' | 'subHeading' | 'rotatingText') | null; title?: string | null; id?: string | null; }[] @@ -1315,8 +1245,8 @@ export interface SiteHero { version: number; [k: string]: unknown; }[]; - direction: ("ltr" | "rtl") | null; - format: "left" | "start" | "center" | "right" | "end" | "justify" | ""; + direction: ('ltr' | 'rtl') | null; + format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; indent: number; version: number; }; @@ -1325,7 +1255,7 @@ export interface SiteHero { heroCallToAction?: string | null; id?: string | null; blockName?: string | null; - blockType: "page-hero"; + blockType: 'page-hero'; } /** * This interface was referenced by `Config`'s JSON-Schema @@ -1341,7 +1271,7 @@ export interface CodeForAfricaPage { embedCode: string; id?: string | null; blockName?: string | null; - blockType: "contact-form"; + blockType: 'contact-form'; } | { title: string; @@ -1353,15 +1283,8 @@ export interface CodeForAfricaPage { version: number; [k: string]: unknown; }[]; - direction: ("ltr" | "rtl") | null; - format: - | "left" - | "start" - | "center" - | "right" - | "end" - | "justify" - | ""; + direction: ('ltr' | 'rtl') | null; + format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; indent: number; version: number; }; @@ -1369,14 +1292,14 @@ export interface CodeForAfricaPage { } | null; id?: string | null; blockName?: string | null; - blockType: "error"; + blockType: 'error'; } | { defaultTag: string | Tag; projects: (string | Project)[]; id?: string | null; blockName?: string | null; - blockType: "featured-work"; + blockType: 'featured-work'; } | { title: string; @@ -1388,80 +1311,77 @@ export interface CodeForAfricaPage { stories: { items: (string | Post)[]; action: { - link: { - label: string; - type?: ("internal" | "custom") | null; - internal?: - | ({ - relationTo: "RoboshieldPages"; - value: string | RoboshieldPage; - } | null) - | ({ - relationTo: "CodeForAfricaPages"; - value: string | CodeForAfricaPage; - } | null); - url?: string | null; - newTab?: boolean | null; - }; - }; - }; - id?: string | null; - blockName?: string | null; - blockType: "featured-stories"; - } - | { - title: string; - subtitle: string; - action: { - link: { label: string; - type?: ("internal" | "custom") | null; - internal?: + linkType?: ('custom' | 'internal') | null; + doc?: | ({ - relationTo: "RoboshieldPages"; + relationTo: 'RoboshieldPages'; value: string | RoboshieldPage; } | null) | ({ - relationTo: "CodeForAfricaPages"; + relationTo: 'CodeForAfricaPages'; value: string | CodeForAfricaPage; } | null); url?: string | null; + href: string; newTab?: boolean | null; }; }; id?: string | null; blockName?: string | null; - blockType: "get-in-touch"; + blockType: 'featured-stories'; + } + | { + title: string; + subtitle: string; + action: { + label: string; + linkType?: ('custom' | 'internal') | null; + doc?: + | ({ + relationTo: 'RoboshieldPages'; + value: string | RoboshieldPage; + } | null) + | ({ + relationTo: 'CodeForAfricaPages'; + value: string | CodeForAfricaPage; + } | null); + url?: string | null; + href: string; + newTab?: boolean | null; + }; + id?: string | null; + blockName?: string | null; + blockType: 'get-in-touch'; } | { impacts?: (string | Impact)[] | null; action: { - link: { - label: string; - type?: ("internal" | "custom") | null; - internal?: - | ({ - relationTo: "RoboshieldPages"; - value: string | RoboshieldPage; - } | null) - | ({ - relationTo: "CodeForAfricaPages"; - value: string | CodeForAfricaPage; - } | null); - url?: string | null; - newTab?: boolean | null; - }; + label: string; + linkType?: ('custom' | 'internal') | null; + doc?: + | ({ + relationTo: 'RoboshieldPages'; + value: string | RoboshieldPage; + } | null) + | ({ + relationTo: 'CodeForAfricaPages'; + value: string | CodeForAfricaPage; + } | null); + url?: string | null; + href: string; + newTab?: boolean | null; }; id?: string | null; blockName?: string | null; - blockType: "get-involved"; + blockType: 'get-involved'; } | { title: string; list?: (string | GuidingPrinciple)[] | null; id?: string | null; blockName?: string | null; - blockType: "our-guiding-principles"; + blockType: 'our-guiding-principles'; } | { title: { @@ -1472,15 +1392,8 @@ export interface CodeForAfricaPage { version: number; [k: string]: unknown; }[]; - direction: ("ltr" | "rtl") | null; - format: - | "left" - | "start" - | "center" - | "right" - | "end" - | "justify" - | ""; + direction: ('ltr' | 'rtl') | null; + format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; indent: number; version: number; }; @@ -1496,31 +1409,30 @@ export interface CodeForAfricaPage { image: string | Media; id?: string | null; blockName?: string | null; - blockType: "hero"; + blockType: 'hero'; } | { title: string; subtitle: string; action: { - link: { - label: string; - type?: ("internal" | "custom") | null; - internal?: - | ({ - relationTo: "RoboshieldPages"; - value: string | RoboshieldPage; - } | null) - | ({ - relationTo: "CodeForAfricaPages"; - value: string | CodeForAfricaPage; - } | null); - url?: string | null; - newTab?: boolean | null; - }; + label: string; + linkType?: ('custom' | 'internal') | null; + doc?: + | ({ + relationTo: 'RoboshieldPages'; + value: string | RoboshieldPage; + } | null) + | ({ + relationTo: 'CodeForAfricaPages'; + value: string | CodeForAfricaPage; + } | null); + url?: string | null; + href: string; + newTab?: boolean | null; }; id?: string | null; blockName?: string | null; - blockType: "join-our-slack"; + blockType: 'join-our-slack'; } | { title: string; @@ -1532,51 +1444,43 @@ export interface CodeForAfricaPage { version: number; [k: string]: unknown; }[]; - direction: ("ltr" | "rtl") | null; - format: - | "left" - | "start" - | "center" - | "right" - | "end" - | "justify" - | ""; + direction: ('ltr' | 'rtl') | null; + format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; indent: number; version: number; }; [k: string]: unknown; }; action: { - link: { - label: string; - type?: ("internal" | "custom") | null; - internal?: - | ({ - relationTo: "RoboshieldPages"; - value: string | RoboshieldPage; - } | null) - | ({ - relationTo: "CodeForAfricaPages"; - value: string | CodeForAfricaPage; - } | null); - url?: string | null; - newTab?: boolean | null; - }; + label: string; + linkType?: ('custom' | 'internal') | null; + doc?: + | ({ + relationTo: 'RoboshieldPages'; + value: string | RoboshieldPage; + } | null) + | ({ + relationTo: 'CodeForAfricaPages'; + value: string | CodeForAfricaPage; + } | null); + url?: string | null; + href: string; + newTab?: boolean | null; }; image: string | Media; id?: string | null; blockName?: string | null; - blockType: "meet-our-team"; + blockType: 'meet-our-team'; } | { title: string; subtitle: string; id?: string | null; blockName?: string | null; - blockType: "page-header"; + blockType: 'page-header'; } | { - primaryTag: "stories" | "opportunities"; + primaryTag: 'stories' | 'opportunities'; stories?: { featured?: (string | null) | Post; title: string; @@ -1587,7 +1491,7 @@ export interface CodeForAfricaPage { }; id?: string | null; blockName?: string | null; - blockType: "post-list"; + blockType: 'post-list'; } | { title: string; @@ -1595,7 +1499,7 @@ export interface CodeForAfricaPage { image: string | Media; id?: string | null; blockName?: string | null; - blockType: "custom-page-header"; + blockType: 'custom-page-header'; } | { content: ( @@ -1609,15 +1513,8 @@ export interface CodeForAfricaPage { version: number; [k: string]: unknown; }[]; - direction: ("ltr" | "rtl") | null; - format: - | "left" - | "start" - | "center" - | "right" - | "end" - | "justify" - | ""; + direction: ('ltr' | 'rtl') | null; + format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; indent: number; version: number; }; @@ -1626,7 +1523,7 @@ export interface CodeForAfricaPage { }; id?: string | null; blockName?: string | null; - blockType: "richText"; + blockType: 'richText'; } | { mediaBlockFields: { @@ -1634,37 +1531,37 @@ export interface CodeForAfricaPage { }; id?: string | null; blockName?: string | null; - blockType: "mediaBlock"; + blockType: 'mediaBlock'; } | { embedBlockFields?: { - embedType?: ("url" | "code") | null; + embedType?: ('url' | 'code') | null; url?: string | null; caption?: string | null; code?: string | null; }; id?: string | null; blockName?: string | null; - blockType: "external-embed"; + blockType: 'external-embed'; } )[]; id?: string | null; blockName?: string | null; - blockType: "longform"; + blockType: 'longform'; } | { title: string; offices: (string | Office)[]; id?: string | null; blockName?: string | null; - blockType: "our-offices"; + blockType: 'our-offices'; } | { title: string; impacts?: (string | Impact)[] | null; id?: string | null; blockName?: string | null; - blockType: "our-impact"; + blockType: 'our-impact'; } | { title: string; @@ -1677,15 +1574,8 @@ export interface CodeForAfricaPage { version: number; [k: string]: unknown; }[]; - direction: ("ltr" | "rtl") | null; - format: - | "left" - | "start" - | "center" - | "right" - | "end" - | "justify" - | ""; + direction: ('ltr' | 'rtl') | null; + format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; indent: number; version: number; }; @@ -1693,24 +1583,24 @@ export interface CodeForAfricaPage { }; id?: string | null; blockName?: string | null; - blockType: "our-mission"; + blockType: 'our-mission'; } | { title: string; partners?: (string | Partner)[] | null; id?: string | null; blockName?: string | null; - blockType: "our-partners"; + blockType: 'our-partners'; } | { title: string; - fields?: ("team" | "country")[] | null; + fields?: ('team' | 'country')[] | null; labels: { projects: string; }; id?: string | null; blockName?: string | null; - blockType: "our-team"; + blockType: 'our-team'; } | { title: string; @@ -1724,13 +1614,13 @@ export interface CodeForAfricaPage { }; id?: string | null; blockName?: string | null; - blockType: "our-work"; + blockType: 'our-work'; } )[] | null; updatedAt: string; createdAt: string; - _status?: ("draft" | "published") | null; + _status?: ('draft' | 'published') | null; } /** * This interface was referenced by `Config`'s JSON-Schema @@ -1751,15 +1641,8 @@ export interface Post { version: number; [k: string]: unknown; }[]; - direction: ("ltr" | "rtl") | null; - format: - | "left" - | "start" - | "center" - | "right" - | "end" - | "justify" - | ""; + direction: ('ltr' | 'rtl') | null; + format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; indent: number; version: number; }; @@ -1768,7 +1651,7 @@ export interface Post { }; id?: string | null; blockName?: string | null; - blockType: "richText"; + blockType: 'richText'; } | { mediaBlockFields: { @@ -1776,18 +1659,18 @@ export interface Post { }; id?: string | null; blockName?: string | null; - blockType: "mediaBlock"; + blockType: 'mediaBlock'; } | { embedBlockFields?: { - embedType?: ("url" | "code") | null; + embedType?: ('url' | 'code') | null; url?: string | null; caption?: string | null; code?: string | null; }; id?: string | null; blockName?: string | null; - blockType: "external-embed"; + blockType: 'external-embed'; } )[]; slug?: string | null; @@ -1797,7 +1680,7 @@ export interface Post { excerpt: string; updatedAt: string; createdAt: string; - _status?: ("draft" | "published") | null; + _status?: ('draft' | 'published') | null; } /** * This interface was referenced by `Config`'s JSON-Schema @@ -1806,7 +1689,7 @@ export interface Post { export interface PayloadPreference { id: string; user: { - relationTo: "users"; + relationTo: 'users'; value: string | User; }; key?: string | null; @@ -1848,8 +1731,8 @@ export interface CodeforafricaSiteSetting { version: number; [k: string]: unknown; }[]; - direction: ("ltr" | "rtl") | null; - format: "left" | "start" | "center" | "right" | "end" | "justify" | ""; + direction: ('ltr' | 'rtl') | null; + format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; indent: number; version: number; }; @@ -1860,46 +1743,42 @@ export interface CodeforafricaSiteSetting { primaryNavigation?: { menus?: | { - link: { - label: string; - type?: ("internal" | "custom") | null; - internal?: - | ({ - relationTo: "RoboshieldPages"; - value: string | RoboshieldPage; - } | null) - | ({ - relationTo: "CodeForAfricaPages"; - value: string | CodeForAfricaPage; - } | null); - url?: string | null; - newTab?: boolean | null; - }; + label: string; + linkType?: ('custom' | 'internal') | null; + doc?: + | ({ + relationTo: 'RoboshieldPages'; + value: string | RoboshieldPage; + } | null) + | ({ + relationTo: 'CodeForAfricaPages'; + value: string | CodeForAfricaPage; + } | null); + url?: string | null; + href: string; + newTab?: boolean | null; id?: string | null; }[] | null; - connect?: - | ("Facebook" | "Twitter" | "Instagram" | "Linkedin" | "Github" | "Slack") - | null; + connect?: ('Facebook' | 'Twitter' | 'Instagram' | 'Linkedin' | 'Github' | 'Slack') | null; }; secondaryNavigation?: { menus?: | { - link: { - label: string; - type?: ("internal" | "custom") | null; - internal?: - | ({ - relationTo: "RoboshieldPages"; - value: string | RoboshieldPage; - } | null) - | ({ - relationTo: "CodeForAfricaPages"; - value: string | CodeForAfricaPage; - } | null); - url?: string | null; - newTab?: boolean | null; - }; + label: string; + linkType?: ('custom' | 'internal') | null; + doc?: + | ({ + relationTo: 'RoboshieldPages'; + value: string | RoboshieldPage; + } | null) + | ({ + relationTo: 'CodeForAfricaPages'; + value: string | CodeForAfricaPage; + } | null); + url?: string | null; + href: string; + newTab?: boolean | null; id?: string | null; }[] | null; @@ -1908,13 +1787,7 @@ export interface CodeforafricaSiteSetting { title: string; links?: | { - platform: - | "Facebook" - | "Twitter" - | "Instagram" - | "Linkedin" - | "Github" - | "Slack"; + platform: 'Facebook' | 'Twitter' | 'Instagram' | 'Linkedin' | 'Github' | 'Slack'; url: string; id?: string | null; }[] @@ -1942,8 +1815,8 @@ export interface RoboshieldSiteSetting { version: number; [k: string]: unknown; }[]; - direction: ("ltr" | "rtl") | null; - format: "left" | "start" | "center" | "right" | "end" | "justify" | ""; + direction: ('ltr' | 'rtl') | null; + format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; indent: number; version: number; }; @@ -1954,46 +1827,42 @@ export interface RoboshieldSiteSetting { primaryNavigation?: { menus?: | { - link: { - label: string; - type?: ("internal" | "custom") | null; - internal?: - | ({ - relationTo: "RoboshieldPages"; - value: string | RoboshieldPage; - } | null) - | ({ - relationTo: "CodeForAfricaPages"; - value: string | CodeForAfricaPage; - } | null); - url?: string | null; - newTab?: boolean | null; - }; + label: string; + linkType?: ('custom' | 'internal') | null; + doc?: + | ({ + relationTo: 'RoboshieldPages'; + value: string | RoboshieldPage; + } | null) + | ({ + relationTo: 'CodeForAfricaPages'; + value: string | CodeForAfricaPage; + } | null); + url?: string | null; + href: string; + newTab?: boolean | null; id?: string | null; }[] | null; - connect?: - | ("Facebook" | "Twitter" | "Instagram" | "Linkedin" | "Github" | "Slack") - | null; + connect?: ('Facebook' | 'Twitter' | 'Instagram' | 'Linkedin' | 'Github' | 'Slack') | null; }; secondaryNavigation?: { menus?: | { - link: { - label: string; - type?: ("internal" | "custom") | null; - internal?: - | ({ - relationTo: "RoboshieldPages"; - value: string | RoboshieldPage; - } | null) - | ({ - relationTo: "CodeForAfricaPages"; - value: string | CodeForAfricaPage; - } | null); - url?: string | null; - newTab?: boolean | null; - }; + label: string; + linkType?: ('custom' | 'internal') | null; + doc?: + | ({ + relationTo: 'RoboshieldPages'; + value: string | RoboshieldPage; + } | null) + | ({ + relationTo: 'CodeForAfricaPages'; + value: string | CodeForAfricaPage; + } | null); + url?: string | null; + href: string; + newTab?: boolean | null; id?: string | null; }[] | null; @@ -2002,13 +1871,7 @@ export interface RoboshieldSiteSetting { title: string; links?: | { - platform: - | "Facebook" - | "Twitter" - | "Instagram" - | "Linkedin" - | "Github" - | "Slack"; + platform: 'Facebook' | 'Twitter' | 'Instagram' | 'Linkedin' | 'Github' | 'Slack'; url: string; id?: string | null; }[] @@ -2028,8 +1891,8 @@ export interface RoboshieldSiteSetting { version: number; [k: string]: unknown; }[]; - direction: ("ltr" | "rtl") | null; - format: "left" | "start" | "center" | "right" | "end" | "justify" | ""; + direction: ('ltr' | 'rtl') | null; + format: 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | ''; indent: number; version: number; }; @@ -2039,20 +1902,19 @@ export interface RoboshieldSiteSetting { | { name: string; logo: string | Media; - link: { - label: string; - type?: ("internal" | "custom") | null; - internal?: - | ({ - relationTo: "RoboshieldPages"; - value: string | RoboshieldPage; - } | null) - | ({ - relationTo: "CodeForAfricaPages"; - value: string | CodeForAfricaPage; - } | null); - url?: string | null; - }; + label: string; + linkType?: ('custom' | 'internal') | null; + doc?: + | ({ + relationTo: 'RoboshieldPages'; + value: string | RoboshieldPage; + } | null) + | ({ + relationTo: 'CodeForAfricaPages'; + value: string | CodeForAfricaPage; + } | null); + url?: string | null; + href: string; id?: string | null; }[] | null; @@ -2068,6 +1930,7 @@ export interface Auth { [k: string]: unknown; } -declare module "payload" { + +declare module 'payload' { export interface GeneratedTypes extends Config {} -} +} \ No newline at end of file diff --git a/apps/centralcms/src/payload/fields/links/link.ts b/apps/centralcms/src/payload/fields/links/link.ts index bd914ac98..78b9c61f9 100644 --- a/apps/centralcms/src/payload/fields/links/link.ts +++ b/apps/centralcms/src/payload/fields/links/link.ts @@ -1,103 +1,149 @@ import { deepmerge } from "@mui/utils"; -import { Field } from "payload"; +import mapLinkTypeToHref from "@/payload/utilities/mapLinkTypeToHref"; +import { + RowField, + SanitizedCollectionConfig, + PayloadRequest, + Condition, +} from "payload"; -type LinkType = (options?: { - disableLabel?: boolean; - defaultValue?: string; - disableLinkTypeSelection?: boolean; - disableOpenInNewTab?: boolean; - overrides?: Record; -}) => Field; +interface CollectionBeforeReadHookArgs { + collection: SanitizedCollectionConfig; + siblingData: any; + doc: any; + query: { + [key: string]: any; + }; + req: PayloadRequest; +} -const link: LinkType = ({ - disableLabel = false, +export async function mapLinkToHrefBeforeValidate({ + siblingData, + req: { payload }, +}: CollectionBeforeReadHookArgs) { + // Don't modify original doc. + const doc = { ...siblingData.doc }; + if (typeof doc.value === "string") { + const { relationTo: collection, value: id } = doc; + doc.value = await payload.findByID({ + collection, + id, + // We only need slug from the collection don't expand the whole + // relationship. We may end up getting stuck on infinite recursion if + // collection contain other links. + depth: 0, + }); + } + const href = mapLinkTypeToHref({ ...siblingData, doc }); + + return href; +} + +const link = ({ defaultValue = "internal", + disableLabel = false, disableLinkTypeSelection = false, disableOpenInNewTab = false, overrides = {}, + required = true, } = {}) => { - const linkResult: Field = { - name: "link", - type: "group", - label: false, - admin: { - hideGutter: true, - }, + const linkResult: RowField = { + type: "row", fields: [ { - type: "row", - fields: [ - ...(!disableLabel - ? [ - { - name: "label", - type: "text", - label: "Label", - required: true, - } as Field, - ] - : []), + name: "linkType", + type: "radio", + options: [ { - name: "type", - type: "radio", - admin: { - layout: "horizontal", - hidden: disableLinkTypeSelection, + label: { + en: "Custom URL", }, - defaultValue, - options: [ - { - label: "Internal link", - value: "internal", - }, - { - label: "Custom URL", - value: "custom", - }, - ], + value: "custom", }, { - name: "internal", - type: "relationship", - admin: { - condition: (_, siblingData) => siblingData?.type === "internal", + label: { + en: "Internal link", }, - label: "Document to link to", - maxDepth: 1, - relationTo: ["RoboshieldPages", "CodeForAfricaPages"], - required: true, - }, - { - name: "url", - type: "text", - admin: { - condition: (_, siblingData) => siblingData?.type === "custom", - }, - label: "Custom URL", - required: true, + value: "internal", }, ], + defaultValue, + admin: { + hidden: disableLinkTypeSelection, + }, }, ], }; - let labelFields: any = []; - - if (!disableLabel) { - labelFields.push({ + const linkTypes = [ + { type: "row", fields: [ { - name: "label", + name: "doc", + label: { + en: "Document to link to", + fr: "Document pour lien vers", + pt: "Documento para link para", + }, + type: "relationship", + relationTo: ["RoboshieldPages", "CodeForAfricaPages"], + required, + maxDepth: 1, + admin: { + condition: ((_, siblingData) => + siblingData?.linkType === "internal") as Condition, + }, + }, + { + name: "url", + label: { + en: "Custom URL", + fr: "URL personnalisée", + pt: "URL personalizado", + }, type: "text", - label: "Label", - required: true, + required, + admin: { + condition: ((_, siblingData) => + siblingData?.linkType === "custom") as Condition, + }, + }, + { + name: "href", + type: "text", + required, + admin: { + hidden: true, + }, + hooks: { + beforeValidate: [mapLinkToHrefBeforeValidate], + }, }, ], - }); + }, + ]; + let labelFields: any = []; + if (!disableLabel) { + labelFields = [ + { + type: "row", + fields: [ + { + name: "label", + label: { + en: "Label", + pt: "Rótulo", + }, + type: "text", + required, + }, + ], + }, + ]; } - + linkResult.fields = [...labelFields, ...linkResult.fields, ...linkTypes]; if (!disableOpenInNewTab) { linkResult.fields.push({ type: "row", diff --git a/apps/centralcms/src/payload/fields/links/linkArray.ts b/apps/centralcms/src/payload/fields/links/linkArray.ts index becea1ec9..a0248d184 100644 --- a/apps/centralcms/src/payload/fields/links/linkArray.ts +++ b/apps/centralcms/src/payload/fields/links/linkArray.ts @@ -27,6 +27,7 @@ function linkArray(args: Args) { fields: [link(linkConfig)], admin: { initCollapsed: true, + // TODO (michael): Add proper row label }, }; diff --git a/apps/centralcms/src/payload/fields/links/linkGroup.ts b/apps/centralcms/src/payload/fields/links/linkGroup.ts index 959f6a3a8..65c250f87 100644 --- a/apps/centralcms/src/payload/fields/links/linkGroup.ts +++ b/apps/centralcms/src/payload/fields/links/linkGroup.ts @@ -19,7 +19,7 @@ interface Args { /** * group field consisting of a link field. */ -function linkGroup(args: Args): Field { +function linkGroup(args: Args) { const { linkConfig, overrides = {} } = args ?? {}; const generatedLinkGroup = { name: "link", @@ -28,7 +28,7 @@ function linkGroup(args: Args): Field { fields: [link(linkConfig)], }; - return deepmerge(generatedLinkGroup, overrides) as Field; + return deepmerge(generatedLinkGroup, overrides); } export default linkGroup; diff --git a/apps/centralcms/src/payload/fields/socialLinks.ts b/apps/centralcms/src/payload/fields/socialLinks.ts index bcf7c2633..314060aab 100644 --- a/apps/centralcms/src/payload/fields/socialLinks.ts +++ b/apps/centralcms/src/payload/fields/socialLinks.ts @@ -41,24 +41,6 @@ function socialLinks(overrides: Overrides = { name: "links" }) { label: "Platform", options: socialMediaOptions, required: true, - validate: (val, args) => { - const { data, t } = args || {}; - const { name: linksName = "links" } = overrides as Overrides; - if ( - data?.[linksName]?.filter((l: any) => l.platform === val)?.length > - 1 - ) { - return t("codeforafrica.validation:uniquePlatforms"); - } - - const { - hasMany, - options = socialMediaOptions, - required = true, - } = args; - // @ts-ignore - return select(val, { hasMany, options, required, t }); - }, }, url({ overrides: { diff --git a/apps/roboshield/src/lib/data/common/index.ts b/apps/roboshield/src/lib/data/common/index.ts index c2c410625..5464eef61 100644 --- a/apps/roboshield/src/lib/data/common/index.ts +++ b/apps/roboshield/src/lib/data/common/index.ts @@ -2,7 +2,6 @@ import { GetServerSidePropsContext } from "next"; import { blockify } from "@/roboshield/lib/data/blockify"; import getPageSeoFromMeta from "@/roboshield/lib/data/seo"; -import { Api } from "@/roboshield/lib/payload"; import site from "@/roboshield/utils/site"; import { SettingsSite } from "@/root/payload-types"; @@ -79,13 +78,13 @@ export async function getPageProps( const blocks = await blockify(page.blocks, api); const siteSettings = await api.findGlobal("settings-site"); - const { analytics } = siteSettings; + //const { analytics } = siteSettings; const footer = getFooter(siteSettings); const navbar = getNavBar(siteSettings); const seo = getPageSeoFromMeta(page, siteSettings); return { - analytics, + //analytics, blocks, footer, navbar, diff --git a/apps/roboshield/src/lib/payload/index.ts b/apps/roboshield/src/lib/payload/index.ts index 237d9a7a2..a54221d05 100644 --- a/apps/roboshield/src/lib/payload/index.ts +++ b/apps/roboshield/src/lib/payload/index.ts @@ -1,94 +1,3 @@ -import payload from "payload"; -import { ByIDOptions } from "payload/dist/collections/operations/local/update"; -import { Options } from "payload/dist/globals/operations/local/findOne"; -import { PaginatedDocs } from "payload/database"; -import { Config, Page, SettingsSite } from "@/root/payload-types"; - -export type CollectionConfig = keyof Config["collections"]; -export type CollectionItemTypes = Config["collections"][CollectionConfig]; -export type GlobalConfig = keyof Config["globals"]; - -async function findPage( - slug: string, - options?: Partial>, -): Promise> { - return payload.find({ - ...options, - collection: "pages", - where: { - slug: { - equals: slug, - }, - }, - }) as unknown as PaginatedDocs; -} - -async function getCollection( - collection: CollectionConfig, - options?: Partial>, -): Promise> { - return payload.find({ - limit: 0, - ...options, - collection, - }) as unknown as Promise>; -} - -async function findGlobal( - slug: GlobalConfig, - options?: Partial>, -): Promise { - return payload.findGlobal({ - ...options, - slug, - }) as unknown as Promise; -} - -async function createCollection( - collection: CollectionConfig, - data: any, - options?: Partial>, -): Promise { - return payload.create({ - collection, - data, - ...options, - }) as unknown as Promise; -} - -async function deleteCollection( - collection: CollectionConfig, - options: ByIDOptions, -): Promise { - return payload.delete({ - ...options, - collection, - }) as unknown as Promise; -} - -async function updateCollection( - collection: CollectionConfig, - id: string, - data: any, - options?: ByIDOptions, -): Promise { - const args = { - ...options, - collection, - id, - data, - }; - return payload.update(args) as unknown as Promise; -} -const api = { - createCollection, - deleteCollection, - findGlobal, - findPage, - getCollection, - updateCollection, -}; - -export type Api = typeof api; +import api from "./rest"; export default api; diff --git a/apps/roboshield/src/lib/payload/local.ts b/apps/roboshield/src/lib/payload/local.ts new file mode 100644 index 000000000..237d9a7a2 --- /dev/null +++ b/apps/roboshield/src/lib/payload/local.ts @@ -0,0 +1,94 @@ +import payload from "payload"; +import { ByIDOptions } from "payload/dist/collections/operations/local/update"; +import { Options } from "payload/dist/globals/operations/local/findOne"; +import { PaginatedDocs } from "payload/database"; +import { Config, Page, SettingsSite } from "@/root/payload-types"; + +export type CollectionConfig = keyof Config["collections"]; +export type CollectionItemTypes = Config["collections"][CollectionConfig]; +export type GlobalConfig = keyof Config["globals"]; + +async function findPage( + slug: string, + options?: Partial>, +): Promise> { + return payload.find({ + ...options, + collection: "pages", + where: { + slug: { + equals: slug, + }, + }, + }) as unknown as PaginatedDocs; +} + +async function getCollection( + collection: CollectionConfig, + options?: Partial>, +): Promise> { + return payload.find({ + limit: 0, + ...options, + collection, + }) as unknown as Promise>; +} + +async function findGlobal( + slug: GlobalConfig, + options?: Partial>, +): Promise { + return payload.findGlobal({ + ...options, + slug, + }) as unknown as Promise; +} + +async function createCollection( + collection: CollectionConfig, + data: any, + options?: Partial>, +): Promise { + return payload.create({ + collection, + data, + ...options, + }) as unknown as Promise; +} + +async function deleteCollection( + collection: CollectionConfig, + options: ByIDOptions, +): Promise { + return payload.delete({ + ...options, + collection, + }) as unknown as Promise; +} + +async function updateCollection( + collection: CollectionConfig, + id: string, + data: any, + options?: ByIDOptions, +): Promise { + const args = { + ...options, + collection, + id, + data, + }; + return payload.update(args) as unknown as Promise; +} +const api = { + createCollection, + deleteCollection, + findGlobal, + findPage, + getCollection, + updateCollection, +}; + +export type Api = typeof api; + +export default api; diff --git a/apps/roboshield/src/lib/payload/rest.ts b/apps/roboshield/src/lib/payload/rest.ts new file mode 100644 index 000000000..ca1929e1b --- /dev/null +++ b/apps/roboshield/src/lib/payload/rest.ts @@ -0,0 +1,39 @@ +import { Config } from "@/root/payload-types"; + +export type CollectionConfig = keyof Config["collections"]; +export type CollectionItemTypes = Config["collections"][CollectionConfig]; +export type GlobalConfig = keyof Config["globals"]; + +async function sendRequestToPayload(url: string, options?: any): Promise { + const headers = { + "Content-Type": "application/json", + Authorization: `users API-Key ${process.env.PAYLOAD_API_KEY}`, + }; + + const response = await fetch(url, { ...options, headers }); + + if (!response.ok) { + throw new Error(`API call failed: ${response.status}`); + } + + return response.json(); +} + +async function findPage(slug: string, options?: any): Promise { + const url = `${process.env.PAYLOAD_API_URL}/api/RoboshieldPages?where[slug][equals]=${slug}&depth=1&draft=false`; + return sendRequestToPayload(url, options); +} + +async function findGlobal(slug: GlobalConfig, options?: []): Promise { + const url = `${process.env.PAYLOAD_API_URL}/api/globals/roboshield-site-settings`; + return sendRequestToPayload(url, options); +} + +const api = { + findGlobal, + findPage, +}; + +export type Api = typeof api; + +export default api;