@webiny/app-headless-cms 6.4.11 → 6.4.12-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HeadlessCMS.js +1 -1
- package/HeadlessCMS.js.map +1 -1
- package/admin/components/ContentEntries/BulkActions/ActionDelete.d.ts +2 -2
- package/admin/components/ContentEntries/BulkActions/ActionMove.d.ts +2 -2
- package/admin/components/ContentEntries/BulkActions/ActionPublish.d.ts +2 -2
- package/admin/components/ContentEntries/BulkActions/ActionUnpublish.d.ts +2 -2
- package/admin/components/ContentModelEditor/ContentModelEditor.js +1 -1
- package/admin/components/ContentModelEditor/ContentModelEditor.js.map +1 -1
- package/admin/components/FieldEditor/Field.js +4 -4
- package/admin/components/FieldEditor/Field.js.map +1 -1
- package/admin/plugins/fieldRenderers/ref/advanced/components/AdvancedMultipleReferenceField.js +5 -5
- package/admin/plugins/fieldRenderers/ref/advanced/components/AdvancedMultipleReferenceField.js.map +1 -1
- package/admin/plugins/fieldRenderers/ref/advanced/components/AdvancedSingleReferenceField.js +4 -4
- package/admin/plugins/fieldRenderers/ref/advanced/components/AdvancedSingleReferenceField.js.map +1 -1
- package/admin/plugins/fieldRenderers/ref/advanced/hooks/useEntries.js +2 -3
- package/admin/plugins/fieldRenderers/ref/advanced/hooks/useEntries.js.map +1 -1
- package/admin/plugins/fieldRenderers/ref/components/helpers.js +1 -1
- package/admin/plugins/fieldRenderers/ref/components/helpers.js.map +1 -1
- package/admin/plugins/fieldRenderers/ref/components/useReference.js +1 -1
- package/admin/plugins/fieldRenderers/ref/components/useReference.js.map +1 -1
- package/admin/plugins/fieldValidators/date/availableValidators.js +1 -1
- package/admin/plugins/fieldValidators/date/availableValidators.js.map +1 -1
- package/admin/plugins/fieldValidators/date/createDateInputField.js +2 -2
- package/admin/plugins/fieldValidators/date/createDateInputField.js.map +1 -1
- package/admin/plugins/fieldValidators/dateGte.js +1 -1
- package/admin/plugins/fieldValidators/dateGte.js.map +1 -1
- package/admin/plugins/fieldValidators/dateLte.js +1 -1
- package/admin/plugins/fieldValidators/dateLte.js.map +1 -1
- package/admin/plugins/fields/ref/renderInfo.js +1 -1
- package/admin/plugins/fields/ref/renderInfo.js.map +1 -1
- package/admin/plugins/transformers/dateTransformer.js +5 -5
- package/admin/plugins/transformers/dateTransformer.js.map +1 -1
- package/admin/plugins/transformers/numberTransformer.js +1 -1
- package/admin/plugins/transformers/numberTransformer.js.map +1 -1
- package/admin/views/contentEntries/ContentEntriesContainer.js +1 -1
- package/admin/views/contentEntries/ContentEntriesContainer.js.map +1 -1
- package/admin/views/contentModels/exporting/runExport.js +2 -4
- package/admin/views/contentModels/exporting/runExport.js.map +1 -1
- package/admin/views/contentModels/exporting/useModelExport.js +1 -1
- package/admin/views/contentModels/exporting/useModelExport.js.map +1 -1
- package/admin/views/contentModels/fullDelete/dialog/Content.js +2 -2
- package/admin/views/contentModels/fullDelete/dialog/Content.js.map +1 -1
- package/admin/views/contentModels/fullDelete/dialog/process.js +2 -2
- package/admin/views/contentModels/fullDelete/dialog/process.js.map +1 -1
- package/admin/views/contentModels/fullDelete/types.js.map +1 -1
- package/admin/views/contentModels/helpers/apiNameValidator.js +1 -1
- package/admin/views/contentModels/helpers/apiNameValidator.js.map +1 -1
- package/admin/views/contentModels/importing/ImportContext.js +6 -6
- package/admin/views/contentModels/importing/ImportContext.js.map +1 -1
- package/admin/views/contentModels/importing/components/FileUpload.js +1 -1
- package/admin/views/contentModels/importing/components/FileUpload.js.map +1 -1
- package/admin/views/contentModels/importing/components/Model/DataListModelItem.js +3 -3
- package/admin/views/contentModels/importing/components/Model/DataListModelItem.js.map +1 -1
- package/admin/views/contentModels/importing/components/Model/DataListModelItemInfo.js +2 -2
- package/admin/views/contentModels/importing/components/Model/DataListModelItemInfo.js.map +1 -1
- package/package.json +31 -31
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/plugins/fieldRenderers/ref/components/useReference.js","sources":["../../../../../../src/admin/plugins/fieldRenderers/ref/components/useReference.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { useApolloClient, useModelFieldGraphqlContext } from \"~/admin/hooks/index.js\";\nimport type {\n CmsEntryGetQueryResponse,\n CmsEntryGetQueryVariables,\n CmsEntrySearchQueryResponse,\n CmsEntrySearchQueryVariables\n} from \"./graphql.js\";\nimport { SEARCH_CONTENT_ENTRIES, GET_CONTENT_ENTRY } from \"./graphql.js\";\nimport type { CmsModelField, CmsModel } from \"~/types.js\";\nimport type { BindComponentRenderProp } from \"@webiny/form\";\nimport type { OptionItem, OptionItemCollection } from \"./types.js\";\nimport {\n convertReferenceEntriesToOptionCollection,\n convertReferenceEntryToOption\n} from \"./helpers.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\n\ninterface UseReferenceHookArgs {\n bind: BindComponentRenderProp;\n field: CmsModelField;\n}\n\ninterface UseReferenceHookValue {\n onChange: (value: any, entry: OptionItem) => void;\n setSearch: (value: string) => void;\n value: OptionItem | null;\n loading: boolean;\n options: OptionItem[];\n}\n\ntype UseReferenceHook = (args: UseReferenceHookArgs) => UseReferenceHookValue;\n\nconst getValueHash = (value: any): string | null => {\n if (!value || (!value.id && !value.entryId)) {\n return null;\n } else if (value.entryId) {\n return value.entryId;\n }\n const { id } = parseIdentifier(value.id);\n return id;\n};\n\nexport const useReference: UseReferenceHook = ({ bind, field }) => {\n const allEntries = useRef<OptionItemCollection>({});\n const client = useApolloClient();\n const [search, setSearch] = useState<string>(\"\");\n const [loading, setLoading] = useState<boolean>(false);\n const [entries, setEntries] = useState<OptionItemCollection>({});\n const [latestEntries, setLatestEntries] = useState<OptionItemCollection>({});\n const [valueEntry, setValueEntry] = useState<OptionItem | null>(null);\n const requestContext = useModelFieldGraphqlContext();\n\n const models = (field.settings ? field.settings.models || [] : []) as Pick<\n CmsModel,\n \"modelId\" | \"name\"\n >[];\n const modelsHash = models.map(model => model.modelId).join(\",\");\n\n const value = bind.value;\n const valueHash = getValueHash(value);\n\n const searchEntries = async () => {\n if (!search) {\n return;\n }\n\n setLoading(true);\n const { data } = await client.query<\n CmsEntrySearchQueryResponse,\n CmsEntrySearchQueryVariables\n >({\n query: SEARCH_CONTENT_ENTRIES,\n variables: {\n modelIds: models.map(m => m.modelId),\n query: search,\n limit: 10\n },\n context: requestContext\n });\n setLoading(false);\n\n const collection = convertReferenceEntriesToOptionCollection(data.content.data);\n if (valueEntry) {\n collection[valueEntry.entryId] = valueEntry;\n }\n allEntries.current = {\n ...allEntries.current,\n ...collection\n };\n\n setEntries(collection);\n };\n\n useEffect(() => {\n searchEntries();\n }, [search]);\n\n useEffect(() => {\n if (models.length === 0) {\n return;\n }\n client\n .query<CmsEntrySearchQueryResponse, CmsEntrySearchQueryVariables>({\n query: SEARCH_CONTENT_ENTRIES,\n variables: {\n modelIds: models.map(m => m.modelId),\n limit: 10\n },\n /**\n * We cannot update this query response in cache after a reference entry being created/deleted,\n * which result in cached response being stale, therefore, we're setting the fetchPolicy to \"network-only\" to by passing cache.\n */\n fetchPolicy: \"network-only\",\n context: requestContext\n })\n .then(({ data }) => {\n const latestEntryData = convertReferenceEntriesToOptionCollection(\n data.content.data\n );\n if (valueEntry) {\n latestEntryData[valueEntry.entryId] = valueEntry;\n }\n\n setLatestEntries(latestEntryData);\n allEntries.current = {\n ...allEntries.current,\n ...latestEntryData\n };\n });\n }, [modelsHash]);\n\n useEffect(() => {\n if (!value || !models) {\n setValueEntry(() => null);\n return;\n }\n\n const entry = valueHash ? allEntries.current[valueHash] : null;\n if (entry) {\n /**\n * if entry exists set valueEntry to that one so we do not load new one\n */\n setValueEntry(() => {\n return entry;\n });\n return;\n }\n\n setLoading(true);\n /**\n * Query loads both latest and published entries.\n * We do this in a single query because there might not be a published entry so we can use the latest one.\n */\n client\n .query<CmsEntryGetQueryResponse, CmsEntryGetQueryVariables>({\n query: GET_CONTENT_ENTRY,\n variables: {\n entry: {\n modelId: value.modelId,\n id: value.id\n }\n },\n context: requestContext\n })\n .then(res => {\n setLoading(false);\n const dataEntry = res.data.latest.data;\n if (!dataEntry) {\n return;\n }\n const option: OptionItem = {\n ...convertReferenceEntryToOption(dataEntry),\n latest: dataEntry.id,\n published: res.data.published.data ? res.data.published.data.id : null\n };\n allEntries.current[option.entryId] = option;\n setLatestEntries(prev => {\n return {\n ...prev,\n [option.entryId]: {\n ...option\n }\n };\n });\n /**\n * Calculate a couple of props for the Autocomplete component.\n */\n setValueEntry(() => {\n return option;\n });\n });\n }, [valueHash, modelsHash]);\n\n const onChange = useCallback((value: string, entry: OptionItem) => {\n if (value !== null) {\n setSearch(\"\");\n\n setValueEntry(() => {\n return entry;\n });\n\n bind.onChange({\n modelId: entry.modelId,\n id: entry.id\n });\n return;\n }\n\n setValueEntry(() => null);\n bind.onChange(null);\n }, []);\n\n /**\n * Format options for the Autocomplete component.\n */\n const options = useMemo(() => Object.values(entries), [valueHash, entries]);\n\n /**\n * Format default options for the Autocomplete component.\n */\n const defaultOptions = useMemo(() => {\n return Object.values(latestEntries);\n }, [valueHash, latestEntries]);\n\n const outputOptions: OptionItem[] = (search && options ? options : defaultOptions) || [];\n\n if (valueEntry && outputOptions.some(opt => opt.entryId === valueEntry.entryId) === false) {\n outputOptions.push(valueEntry);\n }\n\n return {\n onChange,\n setSearch,\n value: valueEntry,\n loading,\n options: outputOptions\n };\n};\n"],"names":["getValueHash","value","id","parseIdentifier","useReference","bind","field","allEntries","useRef","client","useApolloClient","search","setSearch","useState","loading","setLoading","entries","setEntries","latestEntries","setLatestEntries","valueEntry","setValueEntry","requestContext","useModelFieldGraphqlContext","models","modelsHash","model","valueHash","searchEntries","data","SEARCH_CONTENT_ENTRIES","m","collection","convertReferenceEntriesToOptionCollection","useEffect","latestEntryData","entry","GET_CONTENT_ENTRY","res","dataEntry","option","convertReferenceEntryToOption","prev","onChange","useCallback","options","useMemo","Object","defaultOptions","outputOptions","opt"],"mappings":";;;;;AAiCA,MAAMA,eAAe,CAACC;IAClB,IAAI,CAACA,SAAU,CAACA,MAAM,EAAE,IAAI,CAACA,MAAM,OAAO,EACtC,OAAO;IACJ,IAAIA,MAAM,OAAO,EACpB,OAAOA,MAAM,OAAO;IAExB,MAAM,EAAEC,EAAE,EAAE,GAAGC,gBAAgBF,MAAM,EAAE;IACvC,OAAOC;AACX;AAEO,MAAME,eAAiC,CAAC,EAAEC,IAAI,EAAEC,KAAK,EAAE;IAC1D,MAAMC,aAAaC,OAA6B,CAAC;IACjD,MAAMC,SAASC;IACf,MAAM,CAACC,QAAQC,UAAU,GAAGC,SAAiB;IAC7C,MAAM,CAACC,SAASC,WAAW,GAAGF,SAAkB;IAChD,MAAM,CAACG,SAASC,WAAW,GAAGJ,SAA+B,CAAC;IAC9D,MAAM,CAACK,eAAeC,iBAAiB,GAAGN,SAA+B,CAAC;IAC1E,MAAM,CAACO,YAAYC,cAAc,GAAGR,SAA4B;IAChE,MAAMS,iBAAiBC;IAEvB,MAAMC,SAAUlB,MAAM,QAAQ,GAAGA,MAAM,QAAQ,CAAC,MAAM,IAAI,EAAE,GAAG,EAAE;IAIjE,MAAMmB,aAAaD,OAAO,GAAG,CAACE,CAAAA,QAASA,MAAM,OAAO,EAAE,IAAI,CAAC;IAE3D,MAAMzB,QAAQI,KAAK,KAAK;IACxB,MAAMsB,YAAY3B,aAAaC;IAE/B,MAAM2B,gBAAgB;QAClB,IAAI,CAACjB,QACD;QAGJI,WAAW;QACX,MAAM,EAAEc,IAAI,EAAE,GAAG,MAAMpB,OAAO,KAAK,CAGjC;YACE,OAAOqB;YACP,WAAW;gBACP,UAAUN,OAAO,GAAG,CAACO,CAAAA,IAAKA,EAAE,OAAO;gBACnC,OAAOpB;gBACP,OAAO;YACX;YACA,SAASW;QACb;QACAP,WAAW;QAEX,MAAMiB,aAAaC,0CAA0CJ,KAAK,OAAO,CAAC,IAAI;QAC9E,IAAIT,YACAY,UAAU,CAACZ,WAAW,OAAO,CAAC,GAAGA;QAErCb,WAAW,OAAO,GAAG;YACjB,GAAGA,WAAW,OAAO;YACrB,GAAGyB,UAAU;QACjB;QAEAf,WAAWe;IACf;IAEAE,UAAU;QACNN;IACJ,GAAG;QAACjB;KAAO;IAEXuB,UAAU;QACN,IAAIV,AAAkB,MAAlBA,OAAO,MAAM,EACb;QAEJf,OACK,KAAK,CAA4D;YAC9D,OAAOqB;YACP,WAAW;gBACP,UAAUN,OAAO,GAAG,CAACO,CAAAA,IAAKA,EAAE,OAAO;gBACnC,OAAO;YACX;YAKA,aAAa;YACb,SAAST;QACb,GACC,IAAI,CAAC,CAAC,EAAEO,IAAI,EAAE;YACX,MAAMM,kBAAkBF,0CACpBJ,KAAK,OAAO,CAAC,IAAI;YAErB,IAAIT,YACAe,eAAe,CAACf,WAAW,OAAO,CAAC,GAAGA;YAG1CD,iBAAiBgB;YACjB5B,WAAW,OAAO,GAAG;gBACjB,GAAGA,WAAW,OAAO;gBACrB,GAAG4B,eAAe;YACtB;QACJ;IACR,GAAG;QAACV;KAAW;IAEfS,UAAU;QACN,IAAI,CAACjC,SAAS,CAACuB,QAAQ,YACnBH,cAAc,IAAM;QAIxB,MAAMe,QAAQT,YAAYpB,WAAW,OAAO,CAACoB,UAAU,GAAG;QAC1D,IAAIS,OAAO,YAIPf,cAAc,IACHe;QAKfrB,WAAW;QAKXN,OACK,KAAK,CAAsD;YACxD,OAAO4B;YACP,WAAW;gBACP,OAAO;oBACH,SAASpC,MAAM,OAAO;oBACtB,IAAIA,MAAM,EAAE;gBAChB;YACJ;YACA,SAASqB;QACb,GACC,IAAI,CAACgB,CAAAA;YACFvB,WAAW;YACX,MAAMwB,YAAYD,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI;YACtC,IAAI,CAACC,WACD;YAEJ,MAAMC,SAAqB;gBACvB,GAAGC,8BAA8BF,UAAU;gBAC3C,QAAQA,UAAU,EAAE;gBACpB,WAAWD,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,GAAGA,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,GAAG;YACtE;YACA/B,WAAW,OAAO,CAACiC,OAAO,OAAO,CAAC,GAAGA;YACrCrB,iBAAiBuB,CAAAA,OACN;oBACH,GAAGA,IAAI;oBACP,CAACF,OAAO,OAAO,CAAC,EAAE;wBACd,GAAGA,MAAM;oBACb;gBACJ;YAKJnB,cAAc,IACHmB;QAEf;IACR,GAAG;QAACb;QAAWF;KAAW;IAE1B,MAAMkB,WAAWC,YAAY,CAAC3C,OAAemC;QACzC,IAAInC,AAAU,SAAVA,OAAgB;YAChBW,UAAU;YAEVS,cAAc,IACHe;YAGX/B,KAAK,QAAQ,CAAC;gBACV,SAAS+B,MAAM,OAAO;gBACtB,IAAIA,MAAM,EAAE;YAChB;YACA;QACJ;QAEAf,cAAc,IAAM;QACpBhB,KAAK,QAAQ,CAAC;IAClB,GAAG,EAAE;IAKL,MAAMwC,UAAUC,QAAQ,IAAMC,OAAO,MAAM,CAAC/B,UAAU;QAACW;QAAWX;KAAQ;IAK1E,MAAMgC,iBAAiBF,QAAQ,IACpBC,OAAO,MAAM,CAAC7B,gBACtB;QAACS;QAAWT;KAAc;IAE7B,MAAM+B,gBAA+BtC,AAAAA,CAAAA,UAAUkC,UAAUA,UAAUG,cAAa,KAAM,EAAE;IAExF,IAAI5B,cAAc6B,AAAkE,UAAlEA,cAAc,IAAI,CAACC,CAAAA,MAAOA,IAAI,OAAO,KAAK9B,WAAW,OAAO,GAC1E6B,cAAc,IAAI,CAAC7B;IAGvB,OAAO;QACHuB;QACA/B;QACA,OAAOQ;QACPN;QACA,SAASmC;IACb;AACJ"}
|
|
1
|
+
{"version":3,"file":"admin/plugins/fieldRenderers/ref/components/useReference.js","sources":["../../../../../../src/admin/plugins/fieldRenderers/ref/components/useReference.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { useApolloClient, useModelFieldGraphqlContext } from \"~/admin/hooks/index.js\";\nimport type {\n CmsEntryGetQueryResponse,\n CmsEntryGetQueryVariables,\n CmsEntrySearchQueryResponse,\n CmsEntrySearchQueryVariables\n} from \"./graphql.js\";\nimport { SEARCH_CONTENT_ENTRIES, GET_CONTENT_ENTRY } from \"./graphql.js\";\nimport type { CmsModelField, CmsModel } from \"~/types.js\";\nimport type { BindComponentRenderProp } from \"@webiny/form\";\nimport type { OptionItem, OptionItemCollection } from \"./types.js\";\nimport {\n convertReferenceEntriesToOptionCollection,\n convertReferenceEntryToOption\n} from \"./helpers.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\n\ninterface UseReferenceHookArgs {\n bind: BindComponentRenderProp;\n field: CmsModelField;\n}\n\ninterface UseReferenceHookValue {\n onChange: (value: any, entry: OptionItem) => void;\n setSearch: (value: string) => void;\n value: OptionItem | null;\n loading: boolean;\n options: OptionItem[];\n}\n\ntype UseReferenceHook = (args: UseReferenceHookArgs) => UseReferenceHookValue;\n\nconst getValueHash = (value: any): string | null => {\n if (!value || (!value.id && !value.entryId)) {\n return null;\n } else if (value.entryId) {\n return value.entryId;\n }\n const { id } = parseIdentifier(value.id);\n return id;\n};\n\nexport const useReference: UseReferenceHook = ({ bind, field }) => {\n const allEntries = useRef<OptionItemCollection>({});\n const client = useApolloClient();\n const [search, setSearch] = useState<string>(\"\");\n const [loading, setLoading] = useState<boolean>(false);\n const [entries, setEntries] = useState<OptionItemCollection>({});\n const [latestEntries, setLatestEntries] = useState<OptionItemCollection>({});\n const [valueEntry, setValueEntry] = useState<OptionItem | null>(null);\n const requestContext = useModelFieldGraphqlContext();\n\n const models = (field.settings ? field.settings.models || [] : []) as Pick<\n CmsModel,\n \"modelId\" | \"name\"\n >[];\n const modelsHash = models.map(model => model.modelId).join(\",\");\n\n const value = bind.value;\n const valueHash = getValueHash(value);\n\n const searchEntries = async () => {\n if (!search) {\n return;\n }\n\n setLoading(true);\n const { data } = await client.query<\n CmsEntrySearchQueryResponse,\n CmsEntrySearchQueryVariables\n >({\n query: SEARCH_CONTENT_ENTRIES,\n variables: {\n modelIds: models.map(m => m.modelId),\n query: search,\n limit: 10\n },\n context: requestContext\n });\n setLoading(false);\n\n const collection = convertReferenceEntriesToOptionCollection(data.content.data);\n if (valueEntry) {\n collection[valueEntry.entryId] = valueEntry;\n }\n allEntries.current = {\n ...allEntries.current,\n ...collection\n };\n\n setEntries(collection);\n };\n\n useEffect(() => {\n searchEntries();\n }, [search]);\n\n useEffect(() => {\n if (models.length === 0) {\n return;\n }\n client\n .query<CmsEntrySearchQueryResponse, CmsEntrySearchQueryVariables>({\n query: SEARCH_CONTENT_ENTRIES,\n variables: {\n modelIds: models.map(m => m.modelId),\n limit: 10\n },\n /**\n * We cannot update this query response in cache after a reference entry being created/deleted,\n * which result in cached response being stale, therefore, we're setting the fetchPolicy to \"network-only\" to by passing cache.\n */\n fetchPolicy: \"network-only\",\n context: requestContext\n })\n .then(({ data }) => {\n const latestEntryData = convertReferenceEntriesToOptionCollection(\n data.content.data\n );\n if (valueEntry) {\n latestEntryData[valueEntry.entryId] = valueEntry;\n }\n\n setLatestEntries(latestEntryData);\n allEntries.current = {\n ...allEntries.current,\n ...latestEntryData\n };\n });\n }, [modelsHash]);\n\n useEffect(() => {\n if (!value || !models) {\n setValueEntry(() => null);\n return;\n }\n\n const entry = valueHash ? allEntries.current[valueHash] : null;\n if (entry) {\n /**\n * if entry exists set valueEntry to that one so we do not load new one\n */\n setValueEntry(() => {\n return entry;\n });\n return;\n }\n\n setLoading(true);\n /**\n * Query loads both latest and published entries.\n * We do this in a single query because there might not be a published entry so we can use the latest one.\n */\n client\n .query<CmsEntryGetQueryResponse, CmsEntryGetQueryVariables>({\n query: GET_CONTENT_ENTRY,\n variables: {\n entry: {\n modelId: value.modelId,\n id: value.id\n }\n },\n context: requestContext\n })\n .then(res => {\n setLoading(false);\n const dataEntry = res.data.latest.data;\n if (!dataEntry) {\n return;\n }\n const option: OptionItem = {\n ...convertReferenceEntryToOption(dataEntry),\n latest: dataEntry.id,\n published: res.data.published.data ? res.data.published.data.id : null\n };\n allEntries.current[option.entryId] = option;\n setLatestEntries(prev => {\n return {\n ...prev,\n [option.entryId]: {\n ...option\n }\n };\n });\n /**\n * Calculate a couple of props for the Autocomplete component.\n */\n setValueEntry(() => {\n return option;\n });\n });\n }, [valueHash, modelsHash]);\n\n const onChange = useCallback((value: string, entry: OptionItem) => {\n if (value !== null) {\n setSearch(\"\");\n\n setValueEntry(() => {\n return entry;\n });\n\n bind.onChange({\n modelId: entry.modelId,\n id: entry.id\n });\n return;\n }\n\n setValueEntry(() => null);\n bind.onChange(null);\n }, []);\n\n /**\n * Format options for the Autocomplete component.\n */\n const options = useMemo(() => Object.values(entries), [valueHash, entries]);\n\n /**\n * Format default options for the Autocomplete component.\n */\n const defaultOptions = useMemo(() => {\n return Object.values(latestEntries);\n }, [valueHash, latestEntries]);\n\n const outputOptions: OptionItem[] = (search && options ? options : defaultOptions) || [];\n\n if (valueEntry && outputOptions.some(opt => opt.entryId === valueEntry.entryId) === false) {\n outputOptions.push(valueEntry);\n }\n\n return {\n onChange,\n setSearch,\n value: valueEntry,\n loading,\n options: outputOptions\n };\n};\n"],"names":["getValueHash","value","id","parseIdentifier","useReference","bind","field","allEntries","useRef","client","useApolloClient","search","setSearch","useState","loading","setLoading","entries","setEntries","latestEntries","setLatestEntries","valueEntry","setValueEntry","requestContext","useModelFieldGraphqlContext","models","modelsHash","model","valueHash","searchEntries","data","SEARCH_CONTENT_ENTRIES","m","collection","convertReferenceEntriesToOptionCollection","useEffect","latestEntryData","entry","GET_CONTENT_ENTRY","res","dataEntry","option","convertReferenceEntryToOption","prev","onChange","useCallback","options","useMemo","Object","defaultOptions","outputOptions","opt"],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/plugins/fieldValidators/date/availableValidators.js","sources":["../../../../../src/admin/plugins/fieldValidators/date/availableValidators.ts"],"sourcesContent":["export const getAvailableValidators = (type?: string): string[] => {\n const validators = [\"required\"];\n if (!type) {\n return validators;\n } else if (type === \"time\") {\n return validators.concat([\"timeGte\", \"timeLte\"]);\n }\n return validators.concat([\"dateGte\", \"dateLte\"]);\n};\n"],"names":["getAvailableValidators","type","validators"],"mappings":"AAAO,MAAMA,yBAAyB,CAACC;IACnC,MAAMC,aAAa;QAAC;KAAW;IAC/B,IAAI,CAACD,MACD,OAAOC;
|
|
1
|
+
{"version":3,"file":"admin/plugins/fieldValidators/date/availableValidators.js","sources":["../../../../../src/admin/plugins/fieldValidators/date/availableValidators.ts"],"sourcesContent":["export const getAvailableValidators = (type?: string): string[] => {\n const validators = [\"required\"];\n if (!type) {\n return validators;\n } else if (type === \"time\") {\n return validators.concat([\"timeGte\", \"timeLte\"]);\n }\n return validators.concat([\"dateGte\", \"dateLte\"]);\n};\n"],"names":["getAvailableValidators","type","validators"],"mappings":"AAAO,MAAMA,yBAAyB,CAACC;IACnC,MAAMC,aAAa;QAAC;KAAW;IAC/B,IAAI,CAACD,MACD,OAAOC;SACJ,IAAID,AAAS,WAATA,MACP,OAAOC,WAAW,MAAM,CAAC;QAAC;QAAW;KAAU;IAEnD,OAAOA,WAAW,MAAM,CAAC;QAAC;QAAW;KAAU;AACnD"}
|
|
@@ -9,11 +9,11 @@ const createInputField = (field, bind)=>{
|
|
|
9
9
|
field: field,
|
|
10
10
|
bind: bind
|
|
11
11
|
});
|
|
12
|
-
if ("dateTimeWithTimezone" === type) return /*#__PURE__*/ react.createElement(DateTimeWithTimezone, {
|
|
12
|
+
else if ("dateTimeWithTimezone" === type) return /*#__PURE__*/ react.createElement(DateTimeWithTimezone, {
|
|
13
13
|
field: field,
|
|
14
14
|
bind: bind
|
|
15
15
|
});
|
|
16
|
-
if ("time" === type) return /*#__PURE__*/ react.createElement(Time, {
|
|
16
|
+
else if ("time" === type) return /*#__PURE__*/ react.createElement(Time, {
|
|
17
17
|
field: field,
|
|
18
18
|
bind: bind
|
|
19
19
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/plugins/fieldValidators/date/createDateInputField.js","sources":["../../../../../src/admin/plugins/fieldValidators/date/createDateInputField.tsx"],"sourcesContent":["import React from \"react\";\nimport { DateTimeWithoutTimezone } from \"../../fieldRenderers/dateTime/DateTimeWithoutTimezone.js\";\nimport { DateTimeWithTimezone } from \"../../fieldRenderers/dateTime/DateTimeWithTimezone.js\";\nimport { Time } from \"../../fieldRenderers/dateTime/Time.js\";\nimport type { CmsModelField } from \"~/types.js\";\nimport { DateOnly } from \"~/admin/plugins/fieldRenderers/dateTime/DateOnly.js\";\nimport type { BindComponentRenderProp } from \"@webiny/form\";\n\nexport const createInputField = (field: CmsModelField, bind: BindComponentRenderProp) => {\n const type = field.settings ? field.settings.type : null;\n if (type === \"dateTimeWithoutTimezone\") {\n return <DateTimeWithoutTimezone field={field} bind={bind} />;\n } else if (type === \"dateTimeWithTimezone\") {\n return <DateTimeWithTimezone field={field} bind={bind} />;\n } else if (type === \"time\") {\n return <Time field={field} bind={bind} />;\n }\n return <DateOnly bind={bind} field={field} />;\n};\n"],"names":["createInputField","field","bind","type","DateTimeWithoutTimezone","DateTimeWithTimezone","Time","DateOnly"],"mappings":";;;;;AAQO,MAAMA,mBAAmB,CAACC,OAAsBC;IACnD,MAAMC,OAAOF,MAAM,QAAQ,GAAGA,MAAM,QAAQ,CAAC,IAAI,GAAG;IACpD,IAAIE,AAAS,8BAATA,MACA,OAAO,WAAP,GAAO,oBAACC,yBAAuBA;QAAC,OAAOH;QAAO,MAAMC;;
|
|
1
|
+
{"version":3,"file":"admin/plugins/fieldValidators/date/createDateInputField.js","sources":["../../../../../src/admin/plugins/fieldValidators/date/createDateInputField.tsx"],"sourcesContent":["import React from \"react\";\nimport { DateTimeWithoutTimezone } from \"../../fieldRenderers/dateTime/DateTimeWithoutTimezone.js\";\nimport { DateTimeWithTimezone } from \"../../fieldRenderers/dateTime/DateTimeWithTimezone.js\";\nimport { Time } from \"../../fieldRenderers/dateTime/Time.js\";\nimport type { CmsModelField } from \"~/types.js\";\nimport { DateOnly } from \"~/admin/plugins/fieldRenderers/dateTime/DateOnly.js\";\nimport type { BindComponentRenderProp } from \"@webiny/form\";\n\nexport const createInputField = (field: CmsModelField, bind: BindComponentRenderProp) => {\n const type = field.settings ? field.settings.type : null;\n if (type === \"dateTimeWithoutTimezone\") {\n return <DateTimeWithoutTimezone field={field} bind={bind} />;\n } else if (type === \"dateTimeWithTimezone\") {\n return <DateTimeWithTimezone field={field} bind={bind} />;\n } else if (type === \"time\") {\n return <Time field={field} bind={bind} />;\n }\n return <DateOnly bind={bind} field={field} />;\n};\n"],"names":["createInputField","field","bind","type","DateTimeWithoutTimezone","DateTimeWithTimezone","Time","DateOnly"],"mappings":";;;;;AAQO,MAAMA,mBAAmB,CAACC,OAAsBC;IACnD,MAAMC,OAAOF,MAAM,QAAQ,GAAGA,MAAM,QAAQ,CAAC,IAAI,GAAG;IACpD,IAAIE,AAAS,8BAATA,MACA,OAAO,WAAP,GAAO,oBAACC,yBAAuBA;QAAC,OAAOH;QAAO,MAAMC;;SACjD,IAAIC,AAAS,2BAATA,MACP,OAAO,WAAP,GAAO,oBAACE,sBAAoBA;QAAC,OAAOJ;QAAO,MAAMC;;SAC9C,IAAIC,AAAS,WAATA,MACP,OAAO,WAAP,GAAO,oBAACG,MAAIA;QAAC,OAAOL;QAAO,MAAMC;;IAErC,OAAO,WAAP,GAAO,oBAACK,UAAQA;QAAC,MAAML;QAAM,OAAOD;;AACxC"}
|
|
@@ -37,7 +37,7 @@ const dateGte = ()=>({
|
|
|
37
37
|
validate: async (value, { validator })=>{
|
|
38
38
|
const { value: gteValue, type } = validator.settings;
|
|
39
39
|
if (void 0 === gteValue) return true;
|
|
40
|
-
if ("time" === type) return validation.validate(value, `timeGte:${gteValue}`);
|
|
40
|
+
else if ("time" === type) return validation.validate(value, `timeGte:${gteValue}`);
|
|
41
41
|
return validation.validate(value, `dateGte:${gteValue}`);
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/plugins/fieldValidators/dateGte.js","sources":["../../../../src/admin/plugins/fieldValidators/dateGte.tsx"],"sourcesContent":["import React from \"react\";\nimport { Grid, FormComponentNote } from \"@webiny/admin-ui\";\nimport { validation } from \"@webiny/validation\";\nimport type { CmsModelFieldValidatorPlugin } from \"~/types.js\";\nimport { createInputField } from \"./date/createDateInputField.js\";\nimport { getAvailableValidators } from \"./date/availableValidators.js\";\n\nimport { useModelField } from \"~/admin/hooks/index.js\";\nimport { Bind } from \"@webiny/form\";\n\nfunction DateGteSettings() {\n const { field } = useModelField();\n const type = field.settings ? field.settings.type : undefined;\n const availableValidators = getAvailableValidators(type).join(\",\");\n return (\n <Grid.Column span={12}>\n <Bind name={\"settings.type\"}>\n {bind => {\n if (bind.value !== type) {\n bind.onChange(type);\n }\n return <></>;\n }}\n </Bind>\n <Bind name={\"settings.value\"} validators={validation.create(availableValidators)}>\n {bind => {\n return (\n <>\n {createInputField(field, bind)}\n <FormComponentNote\n text={\"This is the earliest date/time that will be allowed.\"}\n />\n </>\n );\n }}\n </Bind>\n </Grid.Column>\n );\n}\n\nexport default (): CmsModelFieldValidatorPlugin => ({\n type: \"cms-model-field-validator\",\n name: \"cms-editor-field-validator-date-gte\",\n validator: {\n name: \"dateGte\",\n label: \"Later or equal\",\n description: \"Entered date/time must be equal or later compared to the provided date.\",\n defaultMessage: `Date/time is earlier than the provided one.`,\n renderSettings() {\n return <DateGteSettings />;\n },\n validate: async (value, { validator }) => {\n const { value: gteValue, type } = validator.settings;\n if (typeof gteValue === \"undefined\") {\n return true;\n } else if (type === \"time\") {\n return validation.validate(value, `timeGte:${gteValue}`);\n }\n return validation.validate(value, `dateGte:${gteValue}`);\n }\n }\n});\n"],"names":["DateGteSettings","field","useModelField","type","undefined","availableValidators","getAvailableValidators","Grid","Bind","bind","validation","createInputField","FormComponentNote","value","validator","gteValue"],"mappings":";;;;;;;AAUA,SAASA;IACL,MAAM,EAAEC,KAAK,EAAE,GAAGC;IAClB,MAAMC,OAAOF,MAAM,QAAQ,GAAGA,MAAM,QAAQ,CAAC,IAAI,GAAGG;IACpD,MAAMC,sBAAsBC,uBAAuBH,MAAM,IAAI,CAAC;IAC9D,OAAO,WAAP,GACI,oBAACI,KAAK,MAAM;QAAC,MAAM;qBACf,oBAACC,MAAIA;QAAC,MAAM;OACPC,CAAAA;QACG,IAAIA,KAAK,KAAK,KAAKN,MACfM,KAAK,QAAQ,CAACN;QAElB,OAAO,WAAP,GAAO;IACX,kBAEJ,oBAACK,MAAIA;QAAC,MAAM;QAAkB,YAAYE,WAAW,MAAM,CAACL;OACvDI,CAAAA,OACU,WAAP,GACI,0CACKE,iBAAiBV,OAAOQ,OAAAA,WAAAA,GACzB,oBAACG,mBAAiBA;YACd,MAAM;;AAQtC;AAEA,gBAAgB,IAAoC;QAChD,MAAM;QACN,MAAM;QACN,WAAW;YACP,MAAM;YACN,OAAO;YACP,aAAa;YACb,gBAAgB;YAChB;gBACI,OAAO,WAAP,GAAO,oBAACZ,iBAAeA;YAC3B;YACA,UAAU,OAAOa,OAAO,EAAEC,SAAS,EAAE;gBACjC,MAAM,EAAE,OAAOC,QAAQ,EAAEZ,IAAI,EAAE,GAAGW,UAAU,QAAQ;gBACpD,IAAI,AAAoB,WAAbC,UACP,OAAO;
|
|
1
|
+
{"version":3,"file":"admin/plugins/fieldValidators/dateGte.js","sources":["../../../../src/admin/plugins/fieldValidators/dateGte.tsx"],"sourcesContent":["import React from \"react\";\nimport { Grid, FormComponentNote } from \"@webiny/admin-ui\";\nimport { validation } from \"@webiny/validation\";\nimport type { CmsModelFieldValidatorPlugin } from \"~/types.js\";\nimport { createInputField } from \"./date/createDateInputField.js\";\nimport { getAvailableValidators } from \"./date/availableValidators.js\";\n\nimport { useModelField } from \"~/admin/hooks/index.js\";\nimport { Bind } from \"@webiny/form\";\n\nfunction DateGteSettings() {\n const { field } = useModelField();\n const type = field.settings ? field.settings.type : undefined;\n const availableValidators = getAvailableValidators(type).join(\",\");\n return (\n <Grid.Column span={12}>\n <Bind name={\"settings.type\"}>\n {bind => {\n if (bind.value !== type) {\n bind.onChange(type);\n }\n return <></>;\n }}\n </Bind>\n <Bind name={\"settings.value\"} validators={validation.create(availableValidators)}>\n {bind => {\n return (\n <>\n {createInputField(field, bind)}\n <FormComponentNote\n text={\"This is the earliest date/time that will be allowed.\"}\n />\n </>\n );\n }}\n </Bind>\n </Grid.Column>\n );\n}\n\nexport default (): CmsModelFieldValidatorPlugin => ({\n type: \"cms-model-field-validator\",\n name: \"cms-editor-field-validator-date-gte\",\n validator: {\n name: \"dateGte\",\n label: \"Later or equal\",\n description: \"Entered date/time must be equal or later compared to the provided date.\",\n defaultMessage: `Date/time is earlier than the provided one.`,\n renderSettings() {\n return <DateGteSettings />;\n },\n validate: async (value, { validator }) => {\n const { value: gteValue, type } = validator.settings;\n if (typeof gteValue === \"undefined\") {\n return true;\n } else if (type === \"time\") {\n return validation.validate(value, `timeGte:${gteValue}`);\n }\n return validation.validate(value, `dateGte:${gteValue}`);\n }\n }\n});\n"],"names":["DateGteSettings","field","useModelField","type","undefined","availableValidators","getAvailableValidators","Grid","Bind","bind","validation","createInputField","FormComponentNote","value","validator","gteValue"],"mappings":";;;;;;;AAUA,SAASA;IACL,MAAM,EAAEC,KAAK,EAAE,GAAGC;IAClB,MAAMC,OAAOF,MAAM,QAAQ,GAAGA,MAAM,QAAQ,CAAC,IAAI,GAAGG;IACpD,MAAMC,sBAAsBC,uBAAuBH,MAAM,IAAI,CAAC;IAC9D,OAAO,WAAP,GACI,oBAACI,KAAK,MAAM;QAAC,MAAM;qBACf,oBAACC,MAAIA;QAAC,MAAM;OACPC,CAAAA;QACG,IAAIA,KAAK,KAAK,KAAKN,MACfM,KAAK,QAAQ,CAACN;QAElB,OAAO,WAAP,GAAO;IACX,kBAEJ,oBAACK,MAAIA;QAAC,MAAM;QAAkB,YAAYE,WAAW,MAAM,CAACL;OACvDI,CAAAA,OACU,WAAP,GACI,0CACKE,iBAAiBV,OAAOQ,OAAAA,WAAAA,GACzB,oBAACG,mBAAiBA;YACd,MAAM;;AAQtC;AAEA,gBAAgB,IAAoC;QAChD,MAAM;QACN,MAAM;QACN,WAAW;YACP,MAAM;YACN,OAAO;YACP,aAAa;YACb,gBAAgB;YAChB;gBACI,OAAO,WAAP,GAAO,oBAACZ,iBAAeA;YAC3B;YACA,UAAU,OAAOa,OAAO,EAAEC,SAAS,EAAE;gBACjC,MAAM,EAAE,OAAOC,QAAQ,EAAEZ,IAAI,EAAE,GAAGW,UAAU,QAAQ;gBACpD,IAAI,AAAoB,WAAbC,UACP,OAAO;qBACJ,IAAIZ,AAAS,WAATA,MACP,OAAOO,WAAW,QAAQ,CAACG,OAAO,CAAC,QAAQ,EAAEE,UAAU;gBAE3D,OAAOL,WAAW,QAAQ,CAACG,OAAO,CAAC,QAAQ,EAAEE,UAAU;YAC3D;QACJ;IACJ"}
|
|
@@ -37,7 +37,7 @@ const dateLte = ()=>({
|
|
|
37
37
|
validate: async (value, { validator })=>{
|
|
38
38
|
const { value: lteValue, type } = validator.settings;
|
|
39
39
|
if (void 0 === lteValue) return true;
|
|
40
|
-
if ("time" === type) return validation.validate(value, `timeLte:${lteValue}`);
|
|
40
|
+
else if ("time" === type) return validation.validate(value, `timeLte:${lteValue}`);
|
|
41
41
|
return validation.validate(value, `dateLte:${lteValue}`);
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/plugins/fieldValidators/dateLte.js","sources":["../../../../src/admin/plugins/fieldValidators/dateLte.tsx"],"sourcesContent":["import React from \"react\";\nimport { Grid, FormComponentNote } from \"@webiny/admin-ui\";\nimport { validation } from \"@webiny/validation\";\nimport type { CmsModelFieldValidatorPlugin } from \"~/types.js\";\nimport { createInputField } from \"./date/createDateInputField.js\";\n\nimport { getAvailableValidators } from \"./date/availableValidators.js\";\nimport { useModelField } from \"~/admin/hooks/index.js\";\nimport { Bind } from \"@webiny/form\";\n\nfunction DateLteSettings() {\n const { field } = useModelField();\n const type = field.settings ? field.settings.type : undefined;\n const availableValidators = getAvailableValidators(type).join(\",\");\n return (\n <Grid.Column span={12}>\n <Bind name={\"settings.type\"}>\n {bind => {\n if (bind.value !== type) {\n bind.onChange(type);\n }\n return <></>;\n }}\n </Bind>\n <Bind name={\"settings.value\"} validators={validation.create(availableValidators)}>\n {bind => {\n return (\n <>\n {createInputField(field, bind)}\n <FormComponentNote\n text={\"This is the latest date/time that will be allowed.\"}\n />\n </>\n );\n }}\n </Bind>\n </Grid.Column>\n );\n}\n\nexport default (): CmsModelFieldValidatorPlugin => ({\n type: \"cms-model-field-validator\",\n name: \"cms-editor-field-validator-date-lte\",\n validator: {\n name: \"dateLte\",\n label: \"Earlier or equal\",\n description: \"Entered date/time must be equal or earlier compared to the provided date.\",\n defaultMessage: `Date/time is later than the provided one.`,\n renderSettings() {\n return <DateLteSettings />;\n },\n validate: async (value, { validator }) => {\n const { value: lteValue, type } = validator.settings;\n if (typeof lteValue === \"undefined\") {\n return true;\n } else if (type === \"time\") {\n return validation.validate(value, `timeLte:${lteValue}`);\n }\n return validation.validate(value, `dateLte:${lteValue}`);\n }\n }\n});\n"],"names":["DateLteSettings","field","useModelField","type","undefined","availableValidators","getAvailableValidators","Grid","Bind","bind","validation","createInputField","FormComponentNote","value","validator","lteValue"],"mappings":";;;;;;;AAUA,SAASA;IACL,MAAM,EAAEC,KAAK,EAAE,GAAGC;IAClB,MAAMC,OAAOF,MAAM,QAAQ,GAAGA,MAAM,QAAQ,CAAC,IAAI,GAAGG;IACpD,MAAMC,sBAAsBC,uBAAuBH,MAAM,IAAI,CAAC;IAC9D,OAAO,WAAP,GACI,oBAACI,KAAK,MAAM;QAAC,MAAM;qBACf,oBAACC,MAAIA;QAAC,MAAM;OACPC,CAAAA;QACG,IAAIA,KAAK,KAAK,KAAKN,MACfM,KAAK,QAAQ,CAACN;QAElB,OAAO,WAAP,GAAO;IACX,kBAEJ,oBAACK,MAAIA;QAAC,MAAM;QAAkB,YAAYE,WAAW,MAAM,CAACL;OACvDI,CAAAA,OACU,WAAP,GACI,0CACKE,iBAAiBV,OAAOQ,OAAAA,WAAAA,GACzB,oBAACG,mBAAiBA;YACd,MAAM;;AAQtC;AAEA,gBAAgB,IAAoC;QAChD,MAAM;QACN,MAAM;QACN,WAAW;YACP,MAAM;YACN,OAAO;YACP,aAAa;YACb,gBAAgB;YAChB;gBACI,OAAO,WAAP,GAAO,oBAACZ,iBAAeA;YAC3B;YACA,UAAU,OAAOa,OAAO,EAAEC,SAAS,EAAE;gBACjC,MAAM,EAAE,OAAOC,QAAQ,EAAEZ,IAAI,EAAE,GAAGW,UAAU,QAAQ;gBACpD,IAAI,AAAoB,WAAbC,UACP,OAAO;
|
|
1
|
+
{"version":3,"file":"admin/plugins/fieldValidators/dateLte.js","sources":["../../../../src/admin/plugins/fieldValidators/dateLte.tsx"],"sourcesContent":["import React from \"react\";\nimport { Grid, FormComponentNote } from \"@webiny/admin-ui\";\nimport { validation } from \"@webiny/validation\";\nimport type { CmsModelFieldValidatorPlugin } from \"~/types.js\";\nimport { createInputField } from \"./date/createDateInputField.js\";\n\nimport { getAvailableValidators } from \"./date/availableValidators.js\";\nimport { useModelField } from \"~/admin/hooks/index.js\";\nimport { Bind } from \"@webiny/form\";\n\nfunction DateLteSettings() {\n const { field } = useModelField();\n const type = field.settings ? field.settings.type : undefined;\n const availableValidators = getAvailableValidators(type).join(\",\");\n return (\n <Grid.Column span={12}>\n <Bind name={\"settings.type\"}>\n {bind => {\n if (bind.value !== type) {\n bind.onChange(type);\n }\n return <></>;\n }}\n </Bind>\n <Bind name={\"settings.value\"} validators={validation.create(availableValidators)}>\n {bind => {\n return (\n <>\n {createInputField(field, bind)}\n <FormComponentNote\n text={\"This is the latest date/time that will be allowed.\"}\n />\n </>\n );\n }}\n </Bind>\n </Grid.Column>\n );\n}\n\nexport default (): CmsModelFieldValidatorPlugin => ({\n type: \"cms-model-field-validator\",\n name: \"cms-editor-field-validator-date-lte\",\n validator: {\n name: \"dateLte\",\n label: \"Earlier or equal\",\n description: \"Entered date/time must be equal or earlier compared to the provided date.\",\n defaultMessage: `Date/time is later than the provided one.`,\n renderSettings() {\n return <DateLteSettings />;\n },\n validate: async (value, { validator }) => {\n const { value: lteValue, type } = validator.settings;\n if (typeof lteValue === \"undefined\") {\n return true;\n } else if (type === \"time\") {\n return validation.validate(value, `timeLte:${lteValue}`);\n }\n return validation.validate(value, `dateLte:${lteValue}`);\n }\n }\n});\n"],"names":["DateLteSettings","field","useModelField","type","undefined","availableValidators","getAvailableValidators","Grid","Bind","bind","validation","createInputField","FormComponentNote","value","validator","lteValue"],"mappings":";;;;;;;AAUA,SAASA;IACL,MAAM,EAAEC,KAAK,EAAE,GAAGC;IAClB,MAAMC,OAAOF,MAAM,QAAQ,GAAGA,MAAM,QAAQ,CAAC,IAAI,GAAGG;IACpD,MAAMC,sBAAsBC,uBAAuBH,MAAM,IAAI,CAAC;IAC9D,OAAO,WAAP,GACI,oBAACI,KAAK,MAAM;QAAC,MAAM;qBACf,oBAACC,MAAIA;QAAC,MAAM;OACPC,CAAAA;QACG,IAAIA,KAAK,KAAK,KAAKN,MACfM,KAAK,QAAQ,CAACN;QAElB,OAAO,WAAP,GAAO;IACX,kBAEJ,oBAACK,MAAIA;QAAC,MAAM;QAAkB,YAAYE,WAAW,MAAM,CAACL;OACvDI,CAAAA,OACU,WAAP,GACI,0CACKE,iBAAiBV,OAAOQ,OAAAA,WAAAA,GACzB,oBAACG,mBAAiBA;YACd,MAAM;;AAQtC;AAEA,gBAAgB,IAAoC;QAChD,MAAM;QACN,MAAM;QACN,WAAW;YACP,MAAM;YACN,OAAO;YACP,aAAa;YACb,gBAAgB;YAChB;gBACI,OAAO,WAAP,GAAO,oBAACZ,iBAAeA;YAC3B;YACA,UAAU,OAAOa,OAAO,EAAEC,SAAS,EAAE;gBACjC,MAAM,EAAE,OAAOC,QAAQ,EAAEZ,IAAI,EAAE,GAAGW,UAAU,QAAQ;gBACpD,IAAI,AAAoB,WAAbC,UACP,OAAO;qBACJ,IAAIZ,AAAS,WAATA,MACP,OAAOO,WAAW,QAAQ,CAACG,OAAO,CAAC,QAAQ,EAAEE,UAAU;gBAE3D,OAAOL,WAAW,QAAQ,CAACG,OAAO,CAAC,QAAQ,EAAEE,UAAU;YAC3D;QACJ;IACJ"}
|
|
@@ -20,7 +20,7 @@ const RenderInfo = ({ field })=>{
|
|
|
20
20
|
const [models, setModels] = useState([]);
|
|
21
21
|
useEffect(()=>{
|
|
22
22
|
if (!data || loading) return;
|
|
23
|
-
if (error) return void showSnackbar(error.message);
|
|
23
|
+
else if (error) return void showSnackbar(error.message);
|
|
24
24
|
setModels(data.listContentModels?.data || []);
|
|
25
25
|
}, [
|
|
26
26
|
data,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/plugins/fields/ref/renderInfo.js","sources":["../../../../../src/admin/plugins/fields/ref/renderInfo.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useState } from \"react\";\nimport type { CmsModel as BaseCmsModel, CmsModelField } from \"~/types.js\";\nimport { useQuery } from \"~/admin/hooks/index.js\";\nimport type { ListReferencedModelsQueryResult } from \"~/admin/plugins/fields/ref/graphql.js\";\nimport { LIST_REFERENCED_MODELS } from \"~/admin/plugins/fields/ref/graphql.js\";\nimport { useSnackbar } from \"@webiny/app-admin\";\nimport { Tag } from \"@webiny/admin-ui\";\n\ntype CmsModel = Pick<BaseCmsModel, \"modelId\" | \"name\">;\n\ninterface BadgeProps {\n model: CmsModel;\n}\n\nconst Badge = ({ model }: BadgeProps) => {\n return <Tag content={model.name} />;\n};\n\ninterface RenderInfoParams {\n field: CmsModelField;\n model: CmsModel;\n}\n\nconst takeBadges = 1;\n\nexport const renderInfo = ({ model, field }: RenderInfoParams) => {\n return <RenderInfo model={model} field={field} />;\n};\n\nconst RenderInfo = ({ field }: RenderInfoParams) => {\n const hasAnyModels = (field.settings?.models || []).length > 0;\n const { data, loading, error } = useQuery<ListReferencedModelsQueryResult>(\n LIST_REFERENCED_MODELS,\n {\n skip: !hasAnyModels\n }\n );\n\n const { showSnackbar } = useSnackbar();\n\n const [models, setModels] = useState<CmsModel[]>([]);\n\n useEffect(() => {\n if (!data || loading) {\n return;\n } else if (error) {\n showSnackbar(error.message);\n return;\n }\n\n setModels(data.listContentModels?.data || []);\n }, [data, loading]);\n\n const { items, badges } = useMemo(() => {\n const fieldModels = (field.settings?.models || [])\n .map(model => {\n return models.find(m => m.modelId === model.modelId);\n })\n .filter(Boolean) as CmsModel[];\n return {\n items: fieldModels.slice(0, takeBadges),\n badges: fieldModels.length - takeBadges\n };\n }, [models, field]);\n\n if (models.length === 0) {\n return null;\n }\n\n return (\n <div className={\"flex justify-end items-center gap-sm\"}>\n {items.map(model => {\n return <Badge key={`model-${model.modelId}`} model={model} />;\n })}\n {badges > 0 && <Tag content={`+${badges}`}></Tag>}\n </div>\n );\n};\n"],"names":["Badge","model","Tag","takeBadges","renderInfo","field","RenderInfo","hasAnyModels","data","loading","error","useQuery","LIST_REFERENCED_MODELS","showSnackbar","useSnackbar","models","setModels","useState","useEffect","items","badges","useMemo","fieldModels","m","Boolean"],"mappings":";;;;;AAcA,MAAMA,QAAQ,CAAC,EAAEC,KAAK,EAAc,GACzB,WAAP,GAAO,oBAACC,KAAGA;QAAC,SAASD,MAAM,IAAI;;AAQnC,MAAME,aAAa;AAEZ,MAAMC,aAAa,CAAC,EAAEH,KAAK,EAAEI,KAAK,EAAoB,GAClD,WAAP,GAAO,oBAACC,YAAUA;QAAC,OAAOL;QAAO,OAAOI;;AAG5C,MAAMC,aAAa,CAAC,EAAED,KAAK,EAAoB;IAC3C,MAAME,eAAgBF,AAAAA,CAAAA,MAAM,QAAQ,EAAE,UAAU,EAAC,EAAG,MAAM,GAAG;IAC7D,MAAM,EAAEG,IAAI,EAAEC,OAAO,EAAEC,KAAK,EAAE,GAAGC,SAC7BC,wBACA;QACI,MAAM,CAACL;IACX;IAGJ,MAAM,EAAEM,YAAY,EAAE,GAAGC;IAEzB,MAAM,CAACC,QAAQC,UAAU,GAAGC,SAAqB,EAAE;IAEnDC,UAAU;QACN,IAAI,CAACV,QAAQC,SACT;
|
|
1
|
+
{"version":3,"file":"admin/plugins/fields/ref/renderInfo.js","sources":["../../../../../src/admin/plugins/fields/ref/renderInfo.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useState } from \"react\";\nimport type { CmsModel as BaseCmsModel, CmsModelField } from \"~/types.js\";\nimport { useQuery } from \"~/admin/hooks/index.js\";\nimport type { ListReferencedModelsQueryResult } from \"~/admin/plugins/fields/ref/graphql.js\";\nimport { LIST_REFERENCED_MODELS } from \"~/admin/plugins/fields/ref/graphql.js\";\nimport { useSnackbar } from \"@webiny/app-admin\";\nimport { Tag } from \"@webiny/admin-ui\";\n\ntype CmsModel = Pick<BaseCmsModel, \"modelId\" | \"name\">;\n\ninterface BadgeProps {\n model: CmsModel;\n}\n\nconst Badge = ({ model }: BadgeProps) => {\n return <Tag content={model.name} />;\n};\n\ninterface RenderInfoParams {\n field: CmsModelField;\n model: CmsModel;\n}\n\nconst takeBadges = 1;\n\nexport const renderInfo = ({ model, field }: RenderInfoParams) => {\n return <RenderInfo model={model} field={field} />;\n};\n\nconst RenderInfo = ({ field }: RenderInfoParams) => {\n const hasAnyModels = (field.settings?.models || []).length > 0;\n const { data, loading, error } = useQuery<ListReferencedModelsQueryResult>(\n LIST_REFERENCED_MODELS,\n {\n skip: !hasAnyModels\n }\n );\n\n const { showSnackbar } = useSnackbar();\n\n const [models, setModels] = useState<CmsModel[]>([]);\n\n useEffect(() => {\n if (!data || loading) {\n return;\n } else if (error) {\n showSnackbar(error.message);\n return;\n }\n\n setModels(data.listContentModels?.data || []);\n }, [data, loading]);\n\n const { items, badges } = useMemo(() => {\n const fieldModels = (field.settings?.models || [])\n .map(model => {\n return models.find(m => m.modelId === model.modelId);\n })\n .filter(Boolean) as CmsModel[];\n return {\n items: fieldModels.slice(0, takeBadges),\n badges: fieldModels.length - takeBadges\n };\n }, [models, field]);\n\n if (models.length === 0) {\n return null;\n }\n\n return (\n <div className={\"flex justify-end items-center gap-sm\"}>\n {items.map(model => {\n return <Badge key={`model-${model.modelId}`} model={model} />;\n })}\n {badges > 0 && <Tag content={`+${badges}`}></Tag>}\n </div>\n );\n};\n"],"names":["Badge","model","Tag","takeBadges","renderInfo","field","RenderInfo","hasAnyModels","data","loading","error","useQuery","LIST_REFERENCED_MODELS","showSnackbar","useSnackbar","models","setModels","useState","useEffect","items","badges","useMemo","fieldModels","m","Boolean"],"mappings":";;;;;AAcA,MAAMA,QAAQ,CAAC,EAAEC,KAAK,EAAc,GACzB,WAAP,GAAO,oBAACC,KAAGA;QAAC,SAASD,MAAM,IAAI;;AAQnC,MAAME,aAAa;AAEZ,MAAMC,aAAa,CAAC,EAAEH,KAAK,EAAEI,KAAK,EAAoB,GAClD,WAAP,GAAO,oBAACC,YAAUA;QAAC,OAAOL;QAAO,OAAOI;;AAG5C,MAAMC,aAAa,CAAC,EAAED,KAAK,EAAoB;IAC3C,MAAME,eAAgBF,AAAAA,CAAAA,MAAM,QAAQ,EAAE,UAAU,EAAC,EAAG,MAAM,GAAG;IAC7D,MAAM,EAAEG,IAAI,EAAEC,OAAO,EAAEC,KAAK,EAAE,GAAGC,SAC7BC,wBACA;QACI,MAAM,CAACL;IACX;IAGJ,MAAM,EAAEM,YAAY,EAAE,GAAGC;IAEzB,MAAM,CAACC,QAAQC,UAAU,GAAGC,SAAqB,EAAE;IAEnDC,UAAU;QACN,IAAI,CAACV,QAAQC,SACT;aACG,IAAIC,OAAO,YACdG,aAAaH,MAAM,OAAO;QAI9BM,UAAUR,KAAK,iBAAiB,EAAE,QAAQ,EAAE;IAChD,GAAG;QAACA;QAAMC;KAAQ;IAElB,MAAM,EAAEU,KAAK,EAAEC,MAAM,EAAE,GAAGC,QAAQ;QAC9B,MAAMC,cAAejB,AAAAA,CAAAA,MAAM,QAAQ,EAAE,UAAU,EAAC,EAC3C,GAAG,CAACJ,CAAAA,QACMc,OAAO,IAAI,CAACQ,CAAAA,IAAKA,EAAE,OAAO,KAAKtB,MAAM,OAAO,GAEtD,MAAM,CAACuB;QACZ,OAAO;YACH,OAAOF,YAAY,KAAK,CAAC,GAAGnB;YAC5B,QAAQmB,YAAY,MAAM,GAAGnB;QACjC;IACJ,GAAG;QAACY;QAAQV;KAAM;IAElB,IAAIU,AAAkB,MAAlBA,OAAO,MAAM,EACb,OAAO;IAGX,OAAO,WAAP,GACI,oBAAC;QAAI,WAAW;OACXI,MAAM,GAAG,CAAClB,CAAAA,QACA,WAAP,GAAO,oBAACD,OAAKA;YAAC,KAAK,CAAC,MAAM,EAAEC,MAAM,OAAO,EAAE;YAAE,OAAOA;aAEvDmB,SAAS,KAAK,WAAL,GAAK,oBAAClB,KAAGA;QAAC,SAAS,CAAC,CAAC,EAAEkB,QAAQ;;AAGrD"}
|
|
@@ -18,7 +18,7 @@ const extractTimeZone = (value)=>{
|
|
|
18
18
|
new Date().toISOString(),
|
|
19
19
|
"00:00"
|
|
20
20
|
];
|
|
21
|
-
result = value.includes("+") ? value.split("+") : value.split("-");
|
|
21
|
+
else result = value.includes("+") ? value.split("+") : value.split("-");
|
|
22
22
|
if (!result || 2 !== result.length) throw new _webiny_error("Could not determine time and timezone out of given value.", "TIME_ZONE_ERROR", {
|
|
23
23
|
value
|
|
24
24
|
});
|
|
@@ -26,17 +26,17 @@ const extractTimeZone = (value)=>{
|
|
|
26
26
|
};
|
|
27
27
|
const extractTime = (value, def = null)=>{
|
|
28
28
|
if (!value) return null;
|
|
29
|
-
if (false === value.includes(":")) throw new _webiny_error("Time value is missing : separators.", "TIME_ERROR", {
|
|
29
|
+
else if (false === value.includes(":")) throw new _webiny_error("Time value is missing : separators.", "TIME_ERROR", {
|
|
30
30
|
value
|
|
31
31
|
});
|
|
32
32
|
const result = value.split(":");
|
|
33
33
|
if (3 === result.length) return value;
|
|
34
|
-
if (2 === result.length) return `${value}:00`;
|
|
34
|
+
else if (2 === result.length) return `${value}:00`;
|
|
35
35
|
return def;
|
|
36
36
|
};
|
|
37
37
|
const dateTimeWithTimezone = (value)=>{
|
|
38
38
|
if (!value) return null;
|
|
39
|
-
if (false === value.includes("T")) return value;
|
|
39
|
+
else if (false === value.includes("T")) return value;
|
|
40
40
|
const [initialDate, initialTimeZone] = value.split("T");
|
|
41
41
|
let date;
|
|
42
42
|
try {
|
|
@@ -55,7 +55,7 @@ const dateTimeWithTimezone = (value)=>{
|
|
|
55
55
|
};
|
|
56
56
|
const dateTimeWithoutTimezone = (value)=>{
|
|
57
57
|
if (!value) return null;
|
|
58
|
-
if (false === value.includes(" ")) return value;
|
|
58
|
+
else if (false === value.includes(" ")) return value;
|
|
59
59
|
try {
|
|
60
60
|
return new Date(`${value.replace(" ", "T")}.000Z`).toISOString();
|
|
61
61
|
} catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/plugins/transformers/dateTransformer.js","sources":["../../../../src/admin/plugins/transformers/dateTransformer.ts"],"sourcesContent":["import type { CmsFieldValueTransformer } from \"~/types.js\";\nimport WebinyError from \"@webiny/error\";\n\ninterface TransformerCallable<T> {\n (value?: T): string | null;\n}\nconst dateOnly: TransformerCallable<string> = value => {\n if (!value) {\n return null;\n }\n try {\n const date = new Date(value).toISOString();\n return date.slice(0, 10);\n } catch (error) {\n throw new WebinyError(`Could not transform value to a date.`, \"TRANSFORM_ERROR\", {\n error,\n type: \"date\",\n value\n });\n }\n};\n\nconst extractTimeZone = (value?: string): [string, string] => {\n let result: string[];\n if (!value) {\n return [new Date().toISOString(), \"00:00\"];\n } else if (value.includes(\"+\")) {\n result = value.split(\"+\");\n } else {\n result = value.split(\"-\");\n }\n if (!result || result.length !== 2) {\n throw new WebinyError(\n `Could not determine time and timezone out of given value.`,\n \"TIME_ZONE_ERROR\",\n {\n value\n }\n );\n }\n return result as [string, string];\n};\n\nconst extractTime = (value?: string, def: string | null = null): string | null => {\n if (!value) {\n return null;\n } else if (value.includes(\":\") === false) {\n throw new WebinyError(\"Time value is missing : separators.\", \"TIME_ERROR\", {\n value\n });\n }\n const result = value.split(\":\");\n if (result.length === 3) {\n return value;\n } else if (result.length === 2) {\n return `${value}:00`;\n }\n return def;\n};\n\nconst dateTimeWithTimezone: TransformerCallable<string> = value => {\n if (!value) {\n return null;\n } else if (value.includes(\"T\") === false) {\n return value;\n }\n\n const [initialDate, initialTimeZone] = value.split(\"T\");\n\n let date: string;\n\n try {\n const dateObj = new Date(initialDate);\n date = dateObj.toISOString().slice(0, 10);\n } catch {\n throw new WebinyError(\n \"Could not transform received date into Date object.\",\n \"DATE_TRANSFORM_ERROR\",\n {\n value,\n date: initialDate,\n time: initialTimeZone\n }\n );\n }\n const [initialTime] = extractTimeZone(initialTimeZone);\n\n const time = extractTime(initialTime, \"00:00:00\") as string;\n\n return value.replace(initialDate, date).replace(initialTime, time);\n};\n\nconst dateTimeWithoutTimezone: TransformerCallable<string> = (value): string | null => {\n if (!value) {\n return null;\n } else if (value.includes(\" \") === false) {\n return value;\n }\n try {\n return new Date(`${value.replace(\" \", \"T\")}.000Z`).toISOString();\n } catch (error) {\n throw new WebinyError(`Could not transform value to a date.`, \"TRANSFORM_ERROR\", {\n error,\n type: \"dateTimeWithoutTimezone\",\n value\n });\n }\n};\n\nconst time: TransformerCallable<string> = value => {\n if (!value) {\n return null;\n }\n return extractTime(value);\n};\n\nconst transformers: Record<string, TransformerCallable<string>> = {\n time,\n date: dateOnly,\n dateTimeWithoutTimezone,\n dateTimeWithTimezone\n};\n\nexport const createDateTransformer = (): CmsFieldValueTransformer => ({\n type: \"cms-field-value-transformer\",\n name: \"cms-field-value-transformer-date\",\n fieldType: \"datetime\",\n transform: (value: any, field) => {\n // check types in packages/app-headless-cms/src/admin/plugins/fieldRenderers/dateTime/dateTimeField.tsx\n const type = field.settings && field.settings.type ? String(field.settings.type) : null;\n if (!type) {\n return value;\n }\n const transform = transformers[type];\n\n if (!transform) {\n return value;\n }\n\n return transform(value);\n }\n});\n"],"names":["dateOnly","value","date","Date","error","WebinyError","extractTimeZone","result","extractTime","def","dateTimeWithTimezone","initialDate","initialTimeZone","dateObj","initialTime","time","dateTimeWithoutTimezone","transformers","createDateTransformer","field","type","String","transform"],"mappings":";AAMA,MAAMA,WAAwCC,CAAAA;IAC1C,IAAI,CAACA,OACD,OAAO;IAEX,IAAI;QACA,MAAMC,OAAO,IAAIC,KAAKF,OAAO,WAAW;QACxC,OAAOC,KAAK,KAAK,CAAC,GAAG;IACzB,EAAE,OAAOE,OAAO;QACZ,MAAM,IAAIC,cAAY,wCAAwC,mBAAmB;YAC7ED;YACA,MAAM;YACNH;QACJ;IACJ;AACJ;AAEA,MAAMK,kBAAkB,CAACL;IACrB,IAAIM;IACJ,IAAI,CAACN,OACD,OAAO;QAAC,IAAIE,OAAO,WAAW;QAAI;KAAQ;
|
|
1
|
+
{"version":3,"file":"admin/plugins/transformers/dateTransformer.js","sources":["../../../../src/admin/plugins/transformers/dateTransformer.ts"],"sourcesContent":["import type { CmsFieldValueTransformer } from \"~/types.js\";\nimport WebinyError from \"@webiny/error\";\n\ninterface TransformerCallable<T> {\n (value?: T): string | null;\n}\nconst dateOnly: TransformerCallable<string> = value => {\n if (!value) {\n return null;\n }\n try {\n const date = new Date(value).toISOString();\n return date.slice(0, 10);\n } catch (error) {\n throw new WebinyError(`Could not transform value to a date.`, \"TRANSFORM_ERROR\", {\n error,\n type: \"date\",\n value\n });\n }\n};\n\nconst extractTimeZone = (value?: string): [string, string] => {\n let result: string[];\n if (!value) {\n return [new Date().toISOString(), \"00:00\"];\n } else if (value.includes(\"+\")) {\n result = value.split(\"+\");\n } else {\n result = value.split(\"-\");\n }\n if (!result || result.length !== 2) {\n throw new WebinyError(\n `Could not determine time and timezone out of given value.`,\n \"TIME_ZONE_ERROR\",\n {\n value\n }\n );\n }\n return result as [string, string];\n};\n\nconst extractTime = (value?: string, def: string | null = null): string | null => {\n if (!value) {\n return null;\n } else if (value.includes(\":\") === false) {\n throw new WebinyError(\"Time value is missing : separators.\", \"TIME_ERROR\", {\n value\n });\n }\n const result = value.split(\":\");\n if (result.length === 3) {\n return value;\n } else if (result.length === 2) {\n return `${value}:00`;\n }\n return def;\n};\n\nconst dateTimeWithTimezone: TransformerCallable<string> = value => {\n if (!value) {\n return null;\n } else if (value.includes(\"T\") === false) {\n return value;\n }\n\n const [initialDate, initialTimeZone] = value.split(\"T\");\n\n let date: string;\n\n try {\n const dateObj = new Date(initialDate);\n date = dateObj.toISOString().slice(0, 10);\n } catch {\n throw new WebinyError(\n \"Could not transform received date into Date object.\",\n \"DATE_TRANSFORM_ERROR\",\n {\n value,\n date: initialDate,\n time: initialTimeZone\n }\n );\n }\n const [initialTime] = extractTimeZone(initialTimeZone);\n\n const time = extractTime(initialTime, \"00:00:00\") as string;\n\n return value.replace(initialDate, date).replace(initialTime, time);\n};\n\nconst dateTimeWithoutTimezone: TransformerCallable<string> = (value): string | null => {\n if (!value) {\n return null;\n } else if (value.includes(\" \") === false) {\n return value;\n }\n try {\n return new Date(`${value.replace(\" \", \"T\")}.000Z`).toISOString();\n } catch (error) {\n throw new WebinyError(`Could not transform value to a date.`, \"TRANSFORM_ERROR\", {\n error,\n type: \"dateTimeWithoutTimezone\",\n value\n });\n }\n};\n\nconst time: TransformerCallable<string> = value => {\n if (!value) {\n return null;\n }\n return extractTime(value);\n};\n\nconst transformers: Record<string, TransformerCallable<string>> = {\n time,\n date: dateOnly,\n dateTimeWithoutTimezone,\n dateTimeWithTimezone\n};\n\nexport const createDateTransformer = (): CmsFieldValueTransformer => ({\n type: \"cms-field-value-transformer\",\n name: \"cms-field-value-transformer-date\",\n fieldType: \"datetime\",\n transform: (value: any, field) => {\n // check types in packages/app-headless-cms/src/admin/plugins/fieldRenderers/dateTime/dateTimeField.tsx\n const type = field.settings && field.settings.type ? String(field.settings.type) : null;\n if (!type) {\n return value;\n }\n const transform = transformers[type];\n\n if (!transform) {\n return value;\n }\n\n return transform(value);\n }\n});\n"],"names":["dateOnly","value","date","Date","error","WebinyError","extractTimeZone","result","extractTime","def","dateTimeWithTimezone","initialDate","initialTimeZone","dateObj","initialTime","time","dateTimeWithoutTimezone","transformers","createDateTransformer","field","type","String","transform"],"mappings":";AAMA,MAAMA,WAAwCC,CAAAA;IAC1C,IAAI,CAACA,OACD,OAAO;IAEX,IAAI;QACA,MAAMC,OAAO,IAAIC,KAAKF,OAAO,WAAW;QACxC,OAAOC,KAAK,KAAK,CAAC,GAAG;IACzB,EAAE,OAAOE,OAAO;QACZ,MAAM,IAAIC,cAAY,wCAAwC,mBAAmB;YAC7ED;YACA,MAAM;YACNH;QACJ;IACJ;AACJ;AAEA,MAAMK,kBAAkB,CAACL;IACrB,IAAIM;IACJ,IAAI,CAACN,OACD,OAAO;QAAC,IAAIE,OAAO,WAAW;QAAI;KAAQ;SAE1CI,SADON,MAAM,QAAQ,CAAC,OACbA,MAAM,KAAK,CAAC,OAEZA,MAAM,KAAK,CAAC;IAEzB,IAAI,CAACM,UAAUA,AAAkB,MAAlBA,OAAO,MAAM,EACxB,MAAM,IAAIF,cACN,6DACA,mBACA;QACIJ;IACJ;IAGR,OAAOM;AACX;AAEA,MAAMC,cAAc,CAACP,OAAgBQ,MAAqB,IAAI;IAC1D,IAAI,CAACR,OACD,OAAO;SACJ,IAAIA,AAAwB,UAAxBA,MAAM,QAAQ,CAAC,MACtB,MAAM,IAAII,cAAY,uCAAuC,cAAc;QACvEJ;IACJ;IAEJ,MAAMM,SAASN,MAAM,KAAK,CAAC;IAC3B,IAAIM,AAAkB,MAAlBA,OAAO,MAAM,EACb,OAAON;SACJ,IAAIM,AAAkB,MAAlBA,OAAO,MAAM,EACpB,OAAO,GAAGN,MAAM,GAAG,CAAC;IAExB,OAAOQ;AACX;AAEA,MAAMC,uBAAoDT,CAAAA;IACtD,IAAI,CAACA,OACD,OAAO;SACJ,IAAIA,AAAwB,UAAxBA,MAAM,QAAQ,CAAC,MACtB,OAAOA;IAGX,MAAM,CAACU,aAAaC,gBAAgB,GAAGX,MAAM,KAAK,CAAC;IAEnD,IAAIC;IAEJ,IAAI;QACA,MAAMW,UAAU,IAAIV,KAAKQ;QACzBT,OAAOW,QAAQ,WAAW,GAAG,KAAK,CAAC,GAAG;IAC1C,EAAE,OAAM;QACJ,MAAM,IAAIR,cACN,uDACA,wBACA;YACIJ;YACA,MAAMU;YACN,MAAMC;QACV;IAER;IACA,MAAM,CAACE,YAAY,GAAGR,gBAAgBM;IAEtC,MAAMG,OAAOP,YAAYM,aAAa;IAEtC,OAAOb,MAAM,OAAO,CAACU,aAAaT,MAAM,OAAO,CAACY,aAAaC;AACjE;AAEA,MAAMC,0BAAuD,CAACf;IAC1D,IAAI,CAACA,OACD,OAAO;SACJ,IAAIA,AAAwB,UAAxBA,MAAM,QAAQ,CAAC,MACtB,OAAOA;IAEX,IAAI;QACA,OAAO,IAAIE,KAAK,GAAGF,MAAM,OAAO,CAAC,KAAK,KAAK,KAAK,CAAC,EAAE,WAAW;IAClE,EAAE,OAAOG,OAAO;QACZ,MAAM,IAAIC,cAAY,wCAAwC,mBAAmB;YAC7ED;YACA,MAAM;YACNH;QACJ;IACJ;AACJ;AAEA,MAAMc,uBAAoCd,CAAAA;IACtC,IAAI,CAACA,OACD,OAAO;IAEX,OAAOO,YAAYP;AACvB;AAEA,MAAMgB,eAA4D;IAC9DF,MAAAA;IACA,MAAMf;IACNgB,yBAAAA;IACAN,sBAAAA;AACJ;AAEO,MAAMQ,wBAAwB,IAAiC;QAClE,MAAM;QACN,MAAM;QACN,WAAW;QACX,WAAW,CAACjB,OAAYkB;YAEpB,MAAMC,OAAOD,MAAM,QAAQ,IAAIA,MAAM,QAAQ,CAAC,IAAI,GAAGE,OAAOF,MAAM,QAAQ,CAAC,IAAI,IAAI;YACnF,IAAI,CAACC,MACD,OAAOnB;YAEX,MAAMqB,YAAYL,YAAY,CAACG,KAAK;YAEpC,IAAI,CAACE,WACD,OAAOrB;YAGX,OAAOqB,UAAUrB;QACrB;IACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/plugins/transformers/numberTransformer.js","sources":["../../../../src/admin/plugins/transformers/numberTransformer.ts"],"sourcesContent":["import type { CmsFieldValueTransformer } from \"~/types.js\";\n\nexport const createNumberTransformer = (): CmsFieldValueTransformer => ({\n type: \"cms-field-value-transformer\",\n name: \"cms-field-value-transformer-number\",\n fieldType: \"number\",\n transform: value => {\n if (Array.isArray(value) === true) {\n return (value as string[]).map(v => {\n if (v === null || v === undefined || v === \"\") {\n return null;\n }\n return Number(v);\n });\n } else if (value === null || value === undefined || value === \"\") {\n return null;\n }\n return Number(value as string);\n }\n});\n"],"names":["createNumberTransformer","value","Array","v","Number"],"mappings":"AAEO,MAAMA,0BAA0B,IAAiC;QACpE,MAAM;QACN,MAAM;QACN,WAAW;QACX,WAAWC,CAAAA;YACP,IAAIC,AAAyB,SAAzBA,MAAM,OAAO,CAACD,QACd,OAAQA,MAAmB,GAAG,CAACE,CAAAA;gBAC3B,IAAIA,QAAAA,KAAiCA,AAAM,OAANA,GACjC,OAAO;gBAEX,OAAOC,OAAOD;YAClB;
|
|
1
|
+
{"version":3,"file":"admin/plugins/transformers/numberTransformer.js","sources":["../../../../src/admin/plugins/transformers/numberTransformer.ts"],"sourcesContent":["import type { CmsFieldValueTransformer } from \"~/types.js\";\n\nexport const createNumberTransformer = (): CmsFieldValueTransformer => ({\n type: \"cms-field-value-transformer\",\n name: \"cms-field-value-transformer-number\",\n fieldType: \"number\",\n transform: value => {\n if (Array.isArray(value) === true) {\n return (value as string[]).map(v => {\n if (v === null || v === undefined || v === \"\") {\n return null;\n }\n return Number(v);\n });\n } else if (value === null || value === undefined || value === \"\") {\n return null;\n }\n return Number(value as string);\n }\n});\n"],"names":["createNumberTransformer","value","Array","v","Number"],"mappings":"AAEO,MAAMA,0BAA0B,IAAiC;QACpE,MAAM;QACN,MAAM;QACN,WAAW;QACX,WAAWC,CAAAA;YACP,IAAIC,AAAyB,SAAzBA,MAAM,OAAO,CAACD,QACd,OAAQA,MAAmB,GAAG,CAACE,CAAAA;gBAC3B,IAAIA,QAAAA,KAAiCA,AAAM,OAANA,GACjC,OAAO;gBAEX,OAAOC,OAAOD;YAClB;iBACG,IAAIF,QAAAA,SAAyCA,AAAU,OAAVA,OAChD,OAAO;YAEX,OAAOG,OAAOH;QAClB;IACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/views/contentEntries/ContentEntriesContainer.js","sources":["../../../../src/admin/views/contentEntries/ContentEntriesContainer.tsx"],"sourcesContent":["import React, { useState } from \"react\";\nimport get from \"lodash/get.js\";\nimport { useRoute, useRouter, useSnackbar } from \"@webiny/app-admin\";\nimport { i18n } from \"@webiny/app/i18n/index.js\";\nimport type {\n GetCmsModelQueryResponse,\n GetCmsModelQueryVariables\n} from \"~/admin/graphql/contentModels.js\";\nimport { GET_CONTENT_MODEL } from \"~/admin/graphql/contentModels.js\";\nimport { useQuery } from \"../../hooks/index.js\";\nimport type { CmsModel } from \"~/types.js\";\nimport { ModelProvider } from \"~/admin/components/ModelProvider/index.js\";\nimport { LoadingContentModel } from \"~/admin/components/ContentEntries/LoadingContentModel/index.js\";\nimport { Routes } from \"~/routes.js\";\n\nconst t = i18n.ns(\"app-headless-cms/admin/content-entries\");\n\ninterface ContentEntriesContainerProps {\n children: React.ReactNode;\n}\n\nexport const ContentEntriesContainer = ({ children }: ContentEntriesContainerProps) => {\n const { goToRoute } = useRouter();\n const { route } = useRoute(Routes.ContentEntries.List);\n const { modelId } = route.params;\n const [contentModel, setContentModel] = useState<CmsModel | null>(null);\n const { showSnackbar } = useSnackbar();\n\n const { loading, error } = useQuery<GetCmsModelQueryResponse, GetCmsModelQueryVariables>(\n GET_CONTENT_MODEL,\n {\n skip: !modelId,\n variables: {\n modelId: modelId as string\n },\n onCompleted: data => {\n const contentModel = get(data, \"getContentModel.data\", null);\n if (contentModel) {\n return setContentModel(contentModel);\n }\n\n goToRoute(Routes.ContentModels.List);\n showSnackbar(\n t`Could not load model \"{modelId}\". Redirecting...`({\n modelId\n })\n );\n }\n }\n );\n\n if (!contentModel || loading) {\n return <LoadingContentModel />;\n } else if (error) {\n showSnackbar(error.message);\n return null;\n }\n\n return <ModelProvider model={contentModel}>{children}</ModelProvider>;\n};\n"],"names":["t","i18n","ContentEntriesContainer","children","goToRoute","useRouter","route","useRoute","Routes","modelId","contentModel","setContentModel","useState","showSnackbar","useSnackbar","loading","error","useQuery","GET_CONTENT_MODEL","data","get","LoadingContentModel","ModelProvider"],"mappings":";;;;;;;;;AAeA,MAAMA,IAAIC,KAAK,EAAE,CAAC;AAMX,MAAMC,0BAA0B,CAAC,EAAEC,QAAQ,EAAgC;IAC9E,MAAM,EAAEC,SAAS,EAAE,GAAGC;IACtB,MAAM,EAAEC,KAAK,EAAE,GAAGC,SAASC,OAAO,cAAc,CAAC,IAAI;IACrD,MAAM,EAAEC,OAAO,EAAE,GAAGH,MAAM,MAAM;IAChC,MAAM,CAACI,cAAcC,gBAAgB,GAAGC,SAA0B;IAClE,MAAM,EAAEC,YAAY,EAAE,GAAGC;IAEzB,MAAM,EAAEC,OAAO,EAAEC,KAAK,EAAE,GAAGC,SACvBC,mBACA;QACI,MAAM,CAACT;QACP,WAAW;YACP,SAASA;QACb;QACA,aAAaU,CAAAA;YACT,MAAMT,eAAeU,IAAID,MAAM,wBAAwB;YACvD,IAAIT,cACA,OAAOC,gBAAgBD;YAG3BN,UAAUI,OAAO,aAAa,CAAC,IAAI;YACnCK,aACIb,CAAC,CAAC,gDAAgD,CAAC,CAAC;gBAChDS;YACJ;QAER;IACJ;IAGJ,IAAI,CAACC,gBAAgBK,SACjB,OAAO,WAAP,GAAO,oBAACM,qBAAmBA;
|
|
1
|
+
{"version":3,"file":"admin/views/contentEntries/ContentEntriesContainer.js","sources":["../../../../src/admin/views/contentEntries/ContentEntriesContainer.tsx"],"sourcesContent":["import React, { useState } from \"react\";\nimport get from \"lodash/get.js\";\nimport { useRoute, useRouter, useSnackbar } from \"@webiny/app-admin\";\nimport { i18n } from \"@webiny/app/i18n/index.js\";\nimport type {\n GetCmsModelQueryResponse,\n GetCmsModelQueryVariables\n} from \"~/admin/graphql/contentModels.js\";\nimport { GET_CONTENT_MODEL } from \"~/admin/graphql/contentModels.js\";\nimport { useQuery } from \"../../hooks/index.js\";\nimport type { CmsModel } from \"~/types.js\";\nimport { ModelProvider } from \"~/admin/components/ModelProvider/index.js\";\nimport { LoadingContentModel } from \"~/admin/components/ContentEntries/LoadingContentModel/index.js\";\nimport { Routes } from \"~/routes.js\";\n\nconst t = i18n.ns(\"app-headless-cms/admin/content-entries\");\n\ninterface ContentEntriesContainerProps {\n children: React.ReactNode;\n}\n\nexport const ContentEntriesContainer = ({ children }: ContentEntriesContainerProps) => {\n const { goToRoute } = useRouter();\n const { route } = useRoute(Routes.ContentEntries.List);\n const { modelId } = route.params;\n const [contentModel, setContentModel] = useState<CmsModel | null>(null);\n const { showSnackbar } = useSnackbar();\n\n const { loading, error } = useQuery<GetCmsModelQueryResponse, GetCmsModelQueryVariables>(\n GET_CONTENT_MODEL,\n {\n skip: !modelId,\n variables: {\n modelId: modelId as string\n },\n onCompleted: data => {\n const contentModel = get(data, \"getContentModel.data\", null);\n if (contentModel) {\n return setContentModel(contentModel);\n }\n\n goToRoute(Routes.ContentModels.List);\n showSnackbar(\n t`Could not load model \"{modelId}\". Redirecting...`({\n modelId\n })\n );\n }\n }\n );\n\n if (!contentModel || loading) {\n return <LoadingContentModel />;\n } else if (error) {\n showSnackbar(error.message);\n return null;\n }\n\n return <ModelProvider model={contentModel}>{children}</ModelProvider>;\n};\n"],"names":["t","i18n","ContentEntriesContainer","children","goToRoute","useRouter","route","useRoute","Routes","modelId","contentModel","setContentModel","useState","showSnackbar","useSnackbar","loading","error","useQuery","GET_CONTENT_MODEL","data","get","LoadingContentModel","ModelProvider"],"mappings":";;;;;;;;;AAeA,MAAMA,IAAIC,KAAK,EAAE,CAAC;AAMX,MAAMC,0BAA0B,CAAC,EAAEC,QAAQ,EAAgC;IAC9E,MAAM,EAAEC,SAAS,EAAE,GAAGC;IACtB,MAAM,EAAEC,KAAK,EAAE,GAAGC,SAASC,OAAO,cAAc,CAAC,IAAI;IACrD,MAAM,EAAEC,OAAO,EAAE,GAAGH,MAAM,MAAM;IAChC,MAAM,CAACI,cAAcC,gBAAgB,GAAGC,SAA0B;IAClE,MAAM,EAAEC,YAAY,EAAE,GAAGC;IAEzB,MAAM,EAAEC,OAAO,EAAEC,KAAK,EAAE,GAAGC,SACvBC,mBACA;QACI,MAAM,CAACT;QACP,WAAW;YACP,SAASA;QACb;QACA,aAAaU,CAAAA;YACT,MAAMT,eAAeU,IAAID,MAAM,wBAAwB;YACvD,IAAIT,cACA,OAAOC,gBAAgBD;YAG3BN,UAAUI,OAAO,aAAa,CAAC,IAAI;YACnCK,aACIb,CAAC,CAAC,gDAAgD,CAAC,CAAC;gBAChDS;YACJ;QAER;IACJ;IAGJ,IAAI,CAACC,gBAAgBK,SACjB,OAAO,WAAP,GAAO,oBAACM,qBAAmBA;SACxB,IAAIL,OAAO;QACdH,aAAaG,MAAM,OAAO;QAC1B,OAAO;IACX;IAEA,OAAO,WAAP,GAAO,oBAACM,eAAaA;QAAC,OAAOZ;OAAeP;AAChD"}
|
|
@@ -11,8 +11,7 @@ const runExport = async ({ client, models })=>{
|
|
|
11
11
|
return {
|
|
12
12
|
error: result.errors[0]
|
|
13
13
|
};
|
|
14
|
-
}
|
|
15
|
-
if (!result.data?.exportStructure) {
|
|
14
|
+
} else if (!result.data?.exportStructure) {
|
|
16
15
|
const message = "There is no object returned from the exportStructure query.";
|
|
17
16
|
console.error(message);
|
|
18
17
|
return {
|
|
@@ -27,8 +26,7 @@ const runExport = async ({ client, models })=>{
|
|
|
27
26
|
return {
|
|
28
27
|
error
|
|
29
28
|
};
|
|
30
|
-
}
|
|
31
|
-
if (!data) {
|
|
29
|
+
} else if (!data) {
|
|
32
30
|
const message = "There is no data returned from the exportStructure query.";
|
|
33
31
|
return {
|
|
34
32
|
error: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/views/contentModels/exporting/runExport.js","sources":["../../../../../src/admin/views/contentModels/exporting/runExport.ts"],"sourcesContent":["import type ApolloClient from \"apollo-client\";\nimport type { CmsGroup, CmsModel } from \"@webiny/app-headless-cms-common/types/index.js\";\nimport { CMS_EXPORT_STRUCTURE_QUERY } from \"./graphql.js\";\n\ninterface Params {\n client: ApolloClient<any>;\n models?: string[];\n}\n\ninterface ResponseData {\n groups: CmsGroup[];\n models: CmsModel[];\n}\n\ninterface Response {\n error?: Partial<Error>;\n data?: ResponseData;\n}\n\nexport const runExport = async ({ client, models }: Params): Promise<Response> => {\n const variables: Record<string, any> = {};\n if (models?.length) {\n variables.models = models;\n }\n const result = await client.query({\n query: CMS_EXPORT_STRUCTURE_QUERY,\n variables\n });\n\n if (result.errors?.length) {\n console.error(result.errors);\n return {\n error: result.errors[0]\n };\n } else if (!result.data?.exportStructure) {\n const message = `There is no object returned from the exportStructure query.`;\n console.error(message);\n return {\n error: {\n message\n }\n };\n }\n const { data, error } = result.data.exportStructure;\n if (error) {\n console.error(error.message);\n return {\n error\n };\n } else if (!data) {\n const message = `There is no data returned from the exportStructure query.`;\n return {\n error: {\n message\n }\n };\n }\n try {\n return {\n data: JSON.parse(data)\n };\n } catch (ex) {\n console.error(ex.message);\n return {\n error: ex\n };\n }\n};\n"],"names":["runExport","client","models","variables","result","CMS_EXPORT_STRUCTURE_QUERY","console","message","data","error","JSON","ex"],"mappings":";AAmBO,MAAMA,YAAY,OAAO,EAAEC,MAAM,EAAEC,MAAM,EAAU;IACtD,MAAMC,YAAiC,CAAC;IACxC,IAAID,QAAQ,QACRC,UAAU,MAAM,GAAGD;IAEvB,MAAME,SAAS,MAAMH,OAAO,KAAK,CAAC;QAC9B,OAAOI;QACPF;IACJ;IAEA,IAAIC,OAAO,MAAM,EAAE,QAAQ;QACvBE,QAAQ,KAAK,CAACF,OAAO,MAAM;QAC3B,OAAO;YACH,OAAOA,OAAO,MAAM,CAAC,EAAE;QAC3B;IACJ
|
|
1
|
+
{"version":3,"file":"admin/views/contentModels/exporting/runExport.js","sources":["../../../../../src/admin/views/contentModels/exporting/runExport.ts"],"sourcesContent":["import type ApolloClient from \"apollo-client\";\nimport type { CmsGroup, CmsModel } from \"@webiny/app-headless-cms-common/types/index.js\";\nimport { CMS_EXPORT_STRUCTURE_QUERY } from \"./graphql.js\";\n\ninterface Params {\n client: ApolloClient<any>;\n models?: string[];\n}\n\ninterface ResponseData {\n groups: CmsGroup[];\n models: CmsModel[];\n}\n\ninterface Response {\n error?: Partial<Error>;\n data?: ResponseData;\n}\n\nexport const runExport = async ({ client, models }: Params): Promise<Response> => {\n const variables: Record<string, any> = {};\n if (models?.length) {\n variables.models = models;\n }\n const result = await client.query({\n query: CMS_EXPORT_STRUCTURE_QUERY,\n variables\n });\n\n if (result.errors?.length) {\n console.error(result.errors);\n return {\n error: result.errors[0]\n };\n } else if (!result.data?.exportStructure) {\n const message = `There is no object returned from the exportStructure query.`;\n console.error(message);\n return {\n error: {\n message\n }\n };\n }\n const { data, error } = result.data.exportStructure;\n if (error) {\n console.error(error.message);\n return {\n error\n };\n } else if (!data) {\n const message = `There is no data returned from the exportStructure query.`;\n return {\n error: {\n message\n }\n };\n }\n try {\n return {\n data: JSON.parse(data)\n };\n } catch (ex) {\n console.error(ex.message);\n return {\n error: ex\n };\n }\n};\n"],"names":["runExport","client","models","variables","result","CMS_EXPORT_STRUCTURE_QUERY","console","message","data","error","JSON","ex"],"mappings":";AAmBO,MAAMA,YAAY,OAAO,EAAEC,MAAM,EAAEC,MAAM,EAAU;IACtD,MAAMC,YAAiC,CAAC;IACxC,IAAID,QAAQ,QACRC,UAAU,MAAM,GAAGD;IAEvB,MAAME,SAAS,MAAMH,OAAO,KAAK,CAAC;QAC9B,OAAOI;QACPF;IACJ;IAEA,IAAIC,OAAO,MAAM,EAAE,QAAQ;QACvBE,QAAQ,KAAK,CAACF,OAAO,MAAM;QAC3B,OAAO;YACH,OAAOA,OAAO,MAAM,CAAC,EAAE;QAC3B;IACJ,OAAO,IAAI,CAACA,OAAO,IAAI,EAAE,iBAAiB;QACtC,MAAMG,UAAU;QAChBD,QAAQ,KAAK,CAACC;QACd,OAAO;YACH,OAAO;gBACHA;YACJ;QACJ;IACJ;IACA,MAAM,EAAEC,IAAI,EAAEC,KAAK,EAAE,GAAGL,OAAO,IAAI,CAAC,eAAe;IACnD,IAAIK,OAAO;QACPH,QAAQ,KAAK,CAACG,MAAM,OAAO;QAC3B,OAAO;YACHA;QACJ;IACJ,OAAO,IAAI,CAACD,MAAM;QACd,MAAMD,UAAU;QAChB,OAAO;YACH,OAAO;gBACHA;YACJ;QACJ;IACJ;IACA,IAAI;QACA,OAAO;YACH,MAAMG,KAAK,KAAK,CAACF;QACrB;IACJ,EAAE,OAAOG,IAAI;QACTL,QAAQ,KAAK,CAACK,GAAG,OAAO;QACxB,OAAO;YACH,OAAOA;QACX;IACJ;AACJ"}
|
|
@@ -13,7 +13,7 @@ const useModelExport = ()=>{
|
|
|
13
13
|
models
|
|
14
14
|
});
|
|
15
15
|
if (result.error) return showSnackbar(result.error.message);
|
|
16
|
-
if (!result.data?.models?.length) return showSnackbar("No data returned from the exportStructure query.");
|
|
16
|
+
else if (!result.data?.models?.length) return showSnackbar("No data returned from the exportStructure query.");
|
|
17
17
|
download(result.data);
|
|
18
18
|
})();
|
|
19
19
|
}, []);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/views/contentModels/exporting/useModelExport.js","sources":["../../../../../src/admin/views/contentModels/exporting/useModelExport.ts"],"sourcesContent":["import { useCallback } from \"react\";\nimport type { CmsModel } from \"~/types.js\";\nimport { useApolloClient } from \"~/admin/hooks/index.js\";\nimport { runExport } from \"./runExport.js\";\nimport { useSnackbar } from \"@webiny/app-admin\";\nimport { download } from \"./download.js\";\n\nexport const useModelExport = () => {\n const client = useApolloClient();\n const { showSnackbar } = useSnackbar();\n\n const handleModelsExport = useCallback((models?: string[]) => {\n (async () => {\n const result = await runExport({\n client,\n models\n });\n if (result.error) {\n return showSnackbar(result.error.message);\n } else if (!result.data?.models?.length) {\n return showSnackbar(\"No data returned from the exportStructure query.\");\n }\n download(result.data);\n })();\n }, []);\n\n const handleModelExport = useCallback(\n (model: CmsModel) => {\n return () => {\n handleModelsExport([model.modelId]);\n };\n },\n [handleModelsExport]\n );\n\n return {\n handleModelsExport,\n handleModelExport\n };\n};\n"],"names":["useModelExport","client","useApolloClient","showSnackbar","useSnackbar","handleModelsExport","useCallback","models","result","runExport","download","handleModelExport","model"],"mappings":";;;;;AAOO,MAAMA,iBAAiB;IAC1B,MAAMC,SAASC;IACf,MAAM,EAAEC,YAAY,EAAE,GAAGC;IAEzB,MAAMC,qBAAqBC,YAAY,CAACC;QACnC;YACG,MAAMC,SAAS,MAAMC,UAAU;gBAC3BR;gBACAM;YACJ;YACA,IAAIC,OAAO,KAAK,EACZ,OAAOL,aAAaK,OAAO,KAAK,CAAC,OAAO;
|
|
1
|
+
{"version":3,"file":"admin/views/contentModels/exporting/useModelExport.js","sources":["../../../../../src/admin/views/contentModels/exporting/useModelExport.ts"],"sourcesContent":["import { useCallback } from \"react\";\nimport type { CmsModel } from \"~/types.js\";\nimport { useApolloClient } from \"~/admin/hooks/index.js\";\nimport { runExport } from \"./runExport.js\";\nimport { useSnackbar } from \"@webiny/app-admin\";\nimport { download } from \"./download.js\";\n\nexport const useModelExport = () => {\n const client = useApolloClient();\n const { showSnackbar } = useSnackbar();\n\n const handleModelsExport = useCallback((models?: string[]) => {\n (async () => {\n const result = await runExport({\n client,\n models\n });\n if (result.error) {\n return showSnackbar(result.error.message);\n } else if (!result.data?.models?.length) {\n return showSnackbar(\"No data returned from the exportStructure query.\");\n }\n download(result.data);\n })();\n }, []);\n\n const handleModelExport = useCallback(\n (model: CmsModel) => {\n return () => {\n handleModelsExport([model.modelId]);\n };\n },\n [handleModelsExport]\n );\n\n return {\n handleModelsExport,\n handleModelExport\n };\n};\n"],"names":["useModelExport","client","useApolloClient","showSnackbar","useSnackbar","handleModelsExport","useCallback","models","result","runExport","download","handleModelExport","model"],"mappings":";;;;;AAOO,MAAMA,iBAAiB;IAC1B,MAAMC,SAASC;IACf,MAAM,EAAEC,YAAY,EAAE,GAAGC;IAEzB,MAAMC,qBAAqBC,YAAY,CAACC;QACnC;YACG,MAAMC,SAAS,MAAMC,UAAU;gBAC3BR;gBACAM;YACJ;YACA,IAAIC,OAAO,KAAK,EACZ,OAAOL,aAAaK,OAAO,KAAK,CAAC,OAAO;iBACrC,IAAI,CAACA,OAAO,IAAI,EAAE,QAAQ,QAC7B,OAAOL,aAAa;YAExBO,SAASF,OAAO,IAAI;QACxB;IACJ,GAAG,EAAE;IAEL,MAAMG,oBAAoBL,YACtB,CAACM,QACU;YACHP,mBAAmB;gBAACO,MAAM,OAAO;aAAC;QACtC,GAEJ;QAACP;KAAmB;IAGxB,OAAO;QACHA;QACAM;IACJ;AACJ"}
|
|
@@ -6,10 +6,10 @@ import { OverlayLoader } from "@webiny/admin-ui";
|
|
|
6
6
|
import { Processed } from "./Processed.js";
|
|
7
7
|
const Content = ({ confirmation, setConfirmation, error, model, status })=>{
|
|
8
8
|
if (!model) return /*#__PURE__*/ react.createElement("p", null, "Model not found.");
|
|
9
|
-
if (status === FullyDeleteModelStateStatus.NONE) return /*#__PURE__*/ react.createElement(Information, {
|
|
9
|
+
else if (status === FullyDeleteModelStateStatus.NONE) return /*#__PURE__*/ react.createElement(Information, {
|
|
10
10
|
model: model
|
|
11
11
|
});
|
|
12
|
-
if (status === FullyDeleteModelStateStatus.PROCESSED) return /*#__PURE__*/ react.createElement(Processed, {
|
|
12
|
+
else if (status === FullyDeleteModelStateStatus.PROCESSED) return /*#__PURE__*/ react.createElement(Processed, {
|
|
13
13
|
model: model
|
|
14
14
|
});
|
|
15
15
|
return /*#__PURE__*/ react.createElement(react.Fragment, null, status === FullyDeleteModelStateStatus.CONFIRMED && /*#__PURE__*/ react.createElement(OverlayLoader, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/views/contentModels/fullDelete/dialog/Content.js","sources":["../../../../../../src/admin/views/contentModels/fullDelete/dialog/Content.tsx"],"sourcesContent":["import React from \"react\";\nimport type { CmsErrorResponse, CmsModel } from \"~/types.js\";\nimport { FullyDeleteModelStateStatus } from \"../types.js\";\nimport { Information } from \"./Information.js\";\nimport { Confirmation } from \"./Confirmation.js\";\nimport { OverlayLoader } from \"@webiny/admin-ui\";\nimport { Processed } from \"./Processed.js\";\n\nexport interface IContentProps {\n model: CmsModel | null;\n confirmation: string;\n setConfirmation: (value: string) => void;\n error: CmsErrorResponse | null;\n status: FullyDeleteModelStateStatus;\n}\n\nexport const Content = ({ confirmation, setConfirmation, error, model, status }: IContentProps) => {\n if (!model) {\n return <p>Model not found.</p>;\n } else if (status === FullyDeleteModelStateStatus.NONE) {\n return <Information model={model} />;\n } else if (status === FullyDeleteModelStateStatus.PROCESSED) {\n return <Processed model={model} />;\n }\n\n return (\n <>\n {status === FullyDeleteModelStateStatus.CONFIRMED && (\n <OverlayLoader text={\"Starting the deletion process...\"} />\n )}\n <Confirmation\n model={model}\n setConfirmation={setConfirmation}\n confirmation={confirmation}\n error={error}\n />\n </>\n );\n};\n"],"names":["Content","confirmation","setConfirmation","error","model","status","FullyDeleteModelStateStatus","Information","Processed","OverlayLoader","Confirmation"],"mappings":";;;;;;AAgBO,MAAMA,UAAU,CAAC,EAAEC,YAAY,EAAEC,eAAe,EAAEC,KAAK,EAAEC,KAAK,EAAEC,MAAM,EAAiB;IAC1F,IAAI,CAACD,OACD,OAAO,WAAP,GAAO,oBAAC,WAAE;
|
|
1
|
+
{"version":3,"file":"admin/views/contentModels/fullDelete/dialog/Content.js","sources":["../../../../../../src/admin/views/contentModels/fullDelete/dialog/Content.tsx"],"sourcesContent":["import React from \"react\";\nimport type { CmsErrorResponse, CmsModel } from \"~/types.js\";\nimport { FullyDeleteModelStateStatus } from \"../types.js\";\nimport { Information } from \"./Information.js\";\nimport { Confirmation } from \"./Confirmation.js\";\nimport { OverlayLoader } from \"@webiny/admin-ui\";\nimport { Processed } from \"./Processed.js\";\n\nexport interface IContentProps {\n model: CmsModel | null;\n confirmation: string;\n setConfirmation: (value: string) => void;\n error: CmsErrorResponse | null;\n status: FullyDeleteModelStateStatus;\n}\n\nexport const Content = ({ confirmation, setConfirmation, error, model, status }: IContentProps) => {\n if (!model) {\n return <p>Model not found.</p>;\n } else if (status === FullyDeleteModelStateStatus.NONE) {\n return <Information model={model} />;\n } else if (status === FullyDeleteModelStateStatus.PROCESSED) {\n return <Processed model={model} />;\n }\n\n return (\n <>\n {status === FullyDeleteModelStateStatus.CONFIRMED && (\n <OverlayLoader text={\"Starting the deletion process...\"} />\n )}\n <Confirmation\n model={model}\n setConfirmation={setConfirmation}\n confirmation={confirmation}\n error={error}\n />\n </>\n );\n};\n"],"names":["Content","confirmation","setConfirmation","error","model","status","FullyDeleteModelStateStatus","Information","Processed","OverlayLoader","Confirmation"],"mappings":";;;;;;AAgBO,MAAMA,UAAU,CAAC,EAAEC,YAAY,EAAEC,eAAe,EAAEC,KAAK,EAAEC,KAAK,EAAEC,MAAM,EAAiB;IAC1F,IAAI,CAACD,OACD,OAAO,WAAP,GAAO,oBAAC,WAAE;SACP,IAAIC,WAAWC,4BAA4B,IAAI,EAClD,OAAO,WAAP,GAAO,oBAACC,aAAWA;QAAC,OAAOH;;SACxB,IAAIC,WAAWC,4BAA4B,SAAS,EACvD,OAAO,WAAP,GAAO,oBAACE,WAASA;QAAC,OAAOJ;;IAG7B,OAAO,WAAP,GACI,0CACKC,WAAWC,4BAA4B,SAAS,IAAI,WAAJ,GAC7C,oBAACG,eAAaA;QAAC,MAAM;sBAEzB,oBAACC,cAAYA;QACT,OAAON;QACP,iBAAiBF;QACjB,cAAcD;QACd,OAAOE;;AAIvB"}
|
|
@@ -20,10 +20,10 @@ const createProcessConfirmation = ({ client })=>async ({ model, confirmation, on
|
|
|
20
20
|
data: {}
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
|
-
if (fullyDeleteModel.error) return {
|
|
23
|
+
else if (fullyDeleteModel.error) return {
|
|
24
24
|
error: fullyDeleteModel.error
|
|
25
25
|
};
|
|
26
|
-
if (!fullyDeleteModel.data) {
|
|
26
|
+
else if (!fullyDeleteModel.data) {
|
|
27
27
|
const graphQlError = result.errors?.[0];
|
|
28
28
|
const error = {
|
|
29
29
|
message: graphQlError?.message || "No data received.",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/views/contentModels/fullDelete/dialog/process.js","sources":["../../../../../../src/admin/views/contentModels/fullDelete/dialog/process.ts"],"sourcesContent":["import type ApolloClient from \"apollo-client\";\nimport type {\n IDeleteCmsModelTask,\n IFullyDeleteCmsModelMutationResponse,\n IFullyDeleteCmsModelMutationVariables\n} from \"~/admin/viewsGraphql.js\";\nimport { FULLY_DELETE_CONTENT_MODEL } from \"~/admin/viewsGraphql.js\";\nimport type { CmsErrorResponse, CmsModel } from \"~/types.js\";\nimport type { DataProxy } from \"apollo-cache\";\n\nexport interface ICreateProcessParams {\n client: ApolloClient<any>;\n}\n\nexport interface IProcessParams {\n confirmation: string;\n model: CmsModel;\n onSuccess: (cache: DataProxy, data: IDeleteCmsModelTask) => void;\n}\n\nexport interface IProcessResponseSuccess {\n error?: never;\n data: IDeleteCmsModelTask;\n}\n\nexport interface IProcessResponseError {\n error: CmsErrorResponse;\n data?: never;\n}\n\ntype IProcessResponse = IProcessResponseSuccess | IProcessResponseError;\n\nexport const createProcessConfirmation = ({ client }: ICreateProcessParams) => {\n return async ({\n model,\n confirmation,\n onSuccess\n }: IProcessParams): Promise<IProcessResponse> => {\n try {\n const result = await client.mutate<\n IFullyDeleteCmsModelMutationResponse,\n IFullyDeleteCmsModelMutationVariables\n >({\n mutation: FULLY_DELETE_CONTENT_MODEL,\n variables: {\n modelId: model.modelId,\n confirmation: confirmation\n },\n update: (cache, { data }) => {\n if (!data?.fullyDeleteModel?.data) {\n return;\n }\n onSuccess(cache, data.fullyDeleteModel.data);\n }\n });\n const fullyDeleteModel = result.data?.fullyDeleteModel;\n if (!fullyDeleteModel) {\n return {\n error: {\n message:\n \"Missing data on Mutation Response. Please check your network tab for more info.\",\n code: \"FULLY_DELETE_MODEL_ERROR\",\n data: {}\n }\n };\n } else if (fullyDeleteModel.error) {\n return {\n error: fullyDeleteModel.error\n };\n } else if (!fullyDeleteModel.data) {\n const graphQlError = result.errors?.[0];\n const error = {\n message: graphQlError?.message || \"No data received.\",\n code: \"FULLY_DELETE_MODEL_NO_DATA\",\n data: {}\n };\n return {\n error\n };\n }\n return {\n data: fullyDeleteModel.data\n };\n } catch (ex) {\n return {\n error: ex\n };\n }\n };\n};\n"],"names":["createProcessConfirmation","client","model","confirmation","onSuccess","result","FULLY_DELETE_CONTENT_MODEL","cache","data","fullyDeleteModel","graphQlError","error","ex"],"mappings":";AAgCO,MAAMA,4BAA4B,CAAC,EAAEC,MAAM,EAAwB,GAC/D,OAAO,EACVC,KAAK,EACLC,YAAY,EACZC,SAAS,EACI;QACb,IAAI;YACA,MAAMC,SAAS,MAAMJ,OAAO,MAAM,CAGhC;gBACE,UAAUK;gBACV,WAAW;oBACP,SAASJ,MAAM,OAAO;oBACtB,cAAcC;gBAClB;gBACA,QAAQ,CAACI,OAAO,EAAEC,IAAI,EAAE;oBACpB,IAAI,CAACA,MAAM,kBAAkB,MACzB;oBAEJJ,UAAUG,OAAOC,KAAK,gBAAgB,CAAC,IAAI;gBAC/C;YACJ;YACA,MAAMC,mBAAmBJ,OAAO,IAAI,EAAE;YACtC,IAAI,CAACI,kBACD,OAAO;gBACH,OAAO;oBACH,SACI;oBACJ,MAAM;oBACN,MAAM,CAAC;gBACX;YACJ;
|
|
1
|
+
{"version":3,"file":"admin/views/contentModels/fullDelete/dialog/process.js","sources":["../../../../../../src/admin/views/contentModels/fullDelete/dialog/process.ts"],"sourcesContent":["import type ApolloClient from \"apollo-client\";\nimport type {\n IDeleteCmsModelTask,\n IFullyDeleteCmsModelMutationResponse,\n IFullyDeleteCmsModelMutationVariables\n} from \"~/admin/viewsGraphql.js\";\nimport { FULLY_DELETE_CONTENT_MODEL } from \"~/admin/viewsGraphql.js\";\nimport type { CmsErrorResponse, CmsModel } from \"~/types.js\";\nimport type { DataProxy } from \"apollo-cache\";\n\nexport interface ICreateProcessParams {\n client: ApolloClient<any>;\n}\n\nexport interface IProcessParams {\n confirmation: string;\n model: CmsModel;\n onSuccess: (cache: DataProxy, data: IDeleteCmsModelTask) => void;\n}\n\nexport interface IProcessResponseSuccess {\n error?: never;\n data: IDeleteCmsModelTask;\n}\n\nexport interface IProcessResponseError {\n error: CmsErrorResponse;\n data?: never;\n}\n\ntype IProcessResponse = IProcessResponseSuccess | IProcessResponseError;\n\nexport const createProcessConfirmation = ({ client }: ICreateProcessParams) => {\n return async ({\n model,\n confirmation,\n onSuccess\n }: IProcessParams): Promise<IProcessResponse> => {\n try {\n const result = await client.mutate<\n IFullyDeleteCmsModelMutationResponse,\n IFullyDeleteCmsModelMutationVariables\n >({\n mutation: FULLY_DELETE_CONTENT_MODEL,\n variables: {\n modelId: model.modelId,\n confirmation: confirmation\n },\n update: (cache, { data }) => {\n if (!data?.fullyDeleteModel?.data) {\n return;\n }\n onSuccess(cache, data.fullyDeleteModel.data);\n }\n });\n const fullyDeleteModel = result.data?.fullyDeleteModel;\n if (!fullyDeleteModel) {\n return {\n error: {\n message:\n \"Missing data on Mutation Response. Please check your network tab for more info.\",\n code: \"FULLY_DELETE_MODEL_ERROR\",\n data: {}\n }\n };\n } else if (fullyDeleteModel.error) {\n return {\n error: fullyDeleteModel.error\n };\n } else if (!fullyDeleteModel.data) {\n const graphQlError = result.errors?.[0];\n const error = {\n message: graphQlError?.message || \"No data received.\",\n code: \"FULLY_DELETE_MODEL_NO_DATA\",\n data: {}\n };\n return {\n error\n };\n }\n return {\n data: fullyDeleteModel.data\n };\n } catch (ex) {\n return {\n error: ex\n };\n }\n };\n};\n"],"names":["createProcessConfirmation","client","model","confirmation","onSuccess","result","FULLY_DELETE_CONTENT_MODEL","cache","data","fullyDeleteModel","graphQlError","error","ex"],"mappings":";AAgCO,MAAMA,4BAA4B,CAAC,EAAEC,MAAM,EAAwB,GAC/D,OAAO,EACVC,KAAK,EACLC,YAAY,EACZC,SAAS,EACI;QACb,IAAI;YACA,MAAMC,SAAS,MAAMJ,OAAO,MAAM,CAGhC;gBACE,UAAUK;gBACV,WAAW;oBACP,SAASJ,MAAM,OAAO;oBACtB,cAAcC;gBAClB;gBACA,QAAQ,CAACI,OAAO,EAAEC,IAAI,EAAE;oBACpB,IAAI,CAACA,MAAM,kBAAkB,MACzB;oBAEJJ,UAAUG,OAAOC,KAAK,gBAAgB,CAAC,IAAI;gBAC/C;YACJ;YACA,MAAMC,mBAAmBJ,OAAO,IAAI,EAAE;YACtC,IAAI,CAACI,kBACD,OAAO;gBACH,OAAO;oBACH,SACI;oBACJ,MAAM;oBACN,MAAM,CAAC;gBACX;YACJ;iBACG,IAAIA,iBAAiB,KAAK,EAC7B,OAAO;gBACH,OAAOA,iBAAiB,KAAK;YACjC;iBACG,IAAI,CAACA,iBAAiB,IAAI,EAAE;gBAC/B,MAAMC,eAAeL,OAAO,MAAM,EAAE,CAAC,EAAE;gBACvC,MAAMM,QAAQ;oBACV,SAASD,cAAc,WAAW;oBAClC,MAAM;oBACN,MAAM,CAAC;gBACX;gBACA,OAAO;oBACHC;gBACJ;YACJ;YACA,OAAO;gBACH,MAAMF,iBAAiB,IAAI;YAC/B;QACJ,EAAE,OAAOG,IAAI;YACT,OAAO;gBACH,OAAOA;YACX;QACJ;IACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/views/contentModels/fullDelete/types.js","sources":["../../../../../src/admin/views/contentModels/fullDelete/types.ts"],"sourcesContent":["import type { CmsErrorResponse, CmsModel } from \"~/types.js\";\nimport type { IDeleteCmsModelTask } from \"~/admin/viewsGraphql.js\";\n\nexport enum FullyDeleteModelStateStatus {\n NONE = 0,\n UNDERSTOOD = 1,\n CONFIRMED = 2,\n PROCESSED = 3,\n ERROR = 999\n}\n\nexport interface IFullyDeleteModelState {\n status: FullyDeleteModelStateStatus;\n confirmation: string;\n model: CmsModel;\n error: CmsErrorResponse | null;\n task: IDeleteCmsModelTask | null;\n}\n"],"names":["FullyDeleteModelStateStatus"],"mappings":"AAGO,IAAKA,oCAA2BA,WAAAA,GAAAA,SAA3BA,2BAA2B
|
|
1
|
+
{"version":3,"file":"admin/views/contentModels/fullDelete/types.js","sources":["../../../../../src/admin/views/contentModels/fullDelete/types.ts"],"sourcesContent":["import type { CmsErrorResponse, CmsModel } from \"~/types.js\";\nimport type { IDeleteCmsModelTask } from \"~/admin/viewsGraphql.js\";\n\nexport enum FullyDeleteModelStateStatus {\n NONE = 0,\n UNDERSTOOD = 1,\n CONFIRMED = 2,\n PROCESSED = 3,\n ERROR = 999\n}\n\nexport interface IFullyDeleteModelState {\n status: FullyDeleteModelStateStatus;\n confirmation: string;\n model: CmsModel;\n error: CmsErrorResponse | null;\n task: IDeleteCmsModelTask | null;\n}\n"],"names":["FullyDeleteModelStateStatus"],"mappings":"AAGO,IAAKA,oCAA2BA,WAAAA,GAAAA,SAA3BA,2BAA2B;sEAC5B;4EACM;2EACD;2EACA;uEACJ;WALAA"}
|
|
@@ -32,7 +32,7 @@ const createApiNameValidator = (params)=>{
|
|
|
32
32
|
if (null !== matched) throw new Error(`The name must not end with "${ending}".`);
|
|
33
33
|
}
|
|
34
34
|
if (models.some((m)=>m.singularApiName === value)) throw new Error(`"${name}" API name already exists. Please pick a different value.`);
|
|
35
|
-
if (models.some((m)=>m.pluralApiName === value)) throw new Error(`"${name}" API name already exists. Please pick a different value.`);
|
|
35
|
+
else if (models.some((m)=>m.pluralApiName === value)) throw new Error(`"${name}" API name already exists. Please pick a different value.`);
|
|
36
36
|
const { data } = await client.query({
|
|
37
37
|
query: SCHEMA_TYPES,
|
|
38
38
|
fetchPolicy: "network-only"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/views/contentModels/helpers/apiNameValidator.js","sources":["../../../../../src/admin/views/contentModels/helpers/apiNameValidator.ts"],"sourcesContent":["import lodashUpperFirst from \"lodash/upperFirst.js\";\nimport lodashCamelCase from \"lodash/camelCase.js\";\nimport gql from \"graphql-tag\";\nimport type ApolloClient from \"apollo-client\";\nimport type { CmsModel } from \"~/types.js\";\n\n/**\n * This list is to disallow creating models that might interfere with GraphQL schema creation.\n * Add more if required.\n */\nconst disallowedModelIdEndingList: string[] = [\"Response\", \"List\", \"Meta\", \"Input\", \"Sorter\"];\n\nconst SCHEMA_TYPES = gql`\n query ListSchemaTypes {\n __schema {\n types {\n name\n }\n }\n }\n`;\n\ninterface SchemaTypes {\n __schema: {\n types: { name: string }[];\n };\n}\n\ninterface Params {\n models: CmsModel[];\n client: ApolloClient<any>;\n}\n\nexport const createApiNameValidator = (params: Params) => {\n const { models, client } = params;\n return async (name: string): Promise<boolean> => {\n const value = (name || \"\").trim();\n if (!value) {\n throw new Error(\"The name is required.\");\n } else if (!value.charAt(0).match(/[a-zA-Z]/)) {\n throw new Error(\"The name can't start with a number.\");\n }\n\n const transformed = lodashUpperFirst(lodashCamelCase(value));\n if (transformed !== value) {\n throw new Error(\n `The name \"${value}\" must be in form of Upper First + Camel Cased word. For example: \"ArticleCategory\", \"ArticleAuthor\" or \"BlogCategories\".`\n );\n }\n /**\n * We need to check for models that might interfere with GraphQL schema creation.\n *\n * First, there are some reserved words that we need to check for.\n */\n for (const ending of disallowedModelIdEndingList) {\n const re = new RegExp(`${ending}$`, \"i\");\n const matched = value.match(re);\n if (matched === null) {\n continue;\n }\n throw new Error(`The name must not end with \"${ending}\".`);\n }\n /**\n * Then we check the GraphQL schema for types that might interfere with the model creation.\n */\n if (models.some(m => m.singularApiName === value)) {\n throw new Error(`\"${name}\" API name already exists. Please pick a different value.`);\n } else if (models.some(m => m.pluralApiName === value)) {\n throw new Error(`\"${name}\" API name already exists. Please pick a different value.`);\n }\n\n // Validate GraphQL Schema type\n const { data } = await client.query<SchemaTypes>({\n query: SCHEMA_TYPES,\n fetchPolicy: \"network-only\"\n });\n\n const types = data.__schema.types.map(t => t.name);\n\n if (types.includes(transformed)) {\n throw new Error(\n `\"${name}\" type already exists in the GraphQL schema. Please pick a different name.`\n );\n }\n\n return true;\n };\n};\n"],"names":["disallowedModelIdEndingList","SCHEMA_TYPES","gql","createApiNameValidator","params","models","client","name","value","Error","transformed","lodashUpperFirst","lodashCamelCase","ending","re","RegExp","matched","m","data","types","t"],"mappings":";;;AAUA,MAAMA,8BAAwC;IAAC;IAAY;IAAQ;IAAQ;IAAS;CAAS;AAE7F,MAAMC,eAAeC,WAAG,CAAC;;;;;;;;AAQzB,CAAC;AAaM,MAAMC,yBAAyB,CAACC;IACnC,MAAM,EAAEC,MAAM,EAAEC,MAAM,EAAE,GAAGF;IAC3B,OAAO,OAAOG;QACV,MAAMC,QAASD,AAAAA,CAAAA,QAAQ,EAAC,EAAG,IAAI;QAC/B,IAAKC,OAEE;YAAA,IAAI,CAACA,MAAM,MAAM,CAAC,GAAG,KAAK,CAAC,aAC9B,MAAM,IAAIC,MAAM;QACpB,OAHI,MAAM,IAAIA,MAAM;QAKpB,MAAMC,cAAcC,WAAiBC,UAAgBJ;QACrD,IAAIE,gBAAgBF,OAChB,MAAM,IAAIC,MACN,CAAC,UAAU,EAAED,MAAM,yHAAyH,CAAC;QAQrJ,KAAK,MAAMK,UAAUb,4BAA6B;YAC9C,MAAMc,KAAK,IAAIC,OAAO,GAAGF,OAAO,CAAC,CAAC,EAAE;YACpC,MAAMG,UAAUR,MAAM,KAAK,CAACM;YAC5B,IAAIE,AAAY,SAAZA,SAGJ,MAAM,IAAIP,MAAM,CAAC,4BAA4B,EAAEI,OAAO,EAAE,CAAC;QAC7D;QAIA,IAAIR,OAAO,IAAI,CAACY,CAAAA,IAAKA,EAAE,eAAe,KAAKT,QACvC,MAAM,IAAIC,MAAM,CAAC,CAAC,EAAEF,KAAK,yDAAyD,CAAC;
|
|
1
|
+
{"version":3,"file":"admin/views/contentModels/helpers/apiNameValidator.js","sources":["../../../../../src/admin/views/contentModels/helpers/apiNameValidator.ts"],"sourcesContent":["import lodashUpperFirst from \"lodash/upperFirst.js\";\nimport lodashCamelCase from \"lodash/camelCase.js\";\nimport gql from \"graphql-tag\";\nimport type ApolloClient from \"apollo-client\";\nimport type { CmsModel } from \"~/types.js\";\n\n/**\n * This list is to disallow creating models that might interfere with GraphQL schema creation.\n * Add more if required.\n */\nconst disallowedModelIdEndingList: string[] = [\"Response\", \"List\", \"Meta\", \"Input\", \"Sorter\"];\n\nconst SCHEMA_TYPES = gql`\n query ListSchemaTypes {\n __schema {\n types {\n name\n }\n }\n }\n`;\n\ninterface SchemaTypes {\n __schema: {\n types: { name: string }[];\n };\n}\n\ninterface Params {\n models: CmsModel[];\n client: ApolloClient<any>;\n}\n\nexport const createApiNameValidator = (params: Params) => {\n const { models, client } = params;\n return async (name: string): Promise<boolean> => {\n const value = (name || \"\").trim();\n if (!value) {\n throw new Error(\"The name is required.\");\n } else if (!value.charAt(0).match(/[a-zA-Z]/)) {\n throw new Error(\"The name can't start with a number.\");\n }\n\n const transformed = lodashUpperFirst(lodashCamelCase(value));\n if (transformed !== value) {\n throw new Error(\n `The name \"${value}\" must be in form of Upper First + Camel Cased word. For example: \"ArticleCategory\", \"ArticleAuthor\" or \"BlogCategories\".`\n );\n }\n /**\n * We need to check for models that might interfere with GraphQL schema creation.\n *\n * First, there are some reserved words that we need to check for.\n */\n for (const ending of disallowedModelIdEndingList) {\n const re = new RegExp(`${ending}$`, \"i\");\n const matched = value.match(re);\n if (matched === null) {\n continue;\n }\n throw new Error(`The name must not end with \"${ending}\".`);\n }\n /**\n * Then we check the GraphQL schema for types that might interfere with the model creation.\n */\n if (models.some(m => m.singularApiName === value)) {\n throw new Error(`\"${name}\" API name already exists. Please pick a different value.`);\n } else if (models.some(m => m.pluralApiName === value)) {\n throw new Error(`\"${name}\" API name already exists. Please pick a different value.`);\n }\n\n // Validate GraphQL Schema type\n const { data } = await client.query<SchemaTypes>({\n query: SCHEMA_TYPES,\n fetchPolicy: \"network-only\"\n });\n\n const types = data.__schema.types.map(t => t.name);\n\n if (types.includes(transformed)) {\n throw new Error(\n `\"${name}\" type already exists in the GraphQL schema. Please pick a different name.`\n );\n }\n\n return true;\n };\n};\n"],"names":["disallowedModelIdEndingList","SCHEMA_TYPES","gql","createApiNameValidator","params","models","client","name","value","Error","transformed","lodashUpperFirst","lodashCamelCase","ending","re","RegExp","matched","m","data","types","t"],"mappings":";;;AAUA,MAAMA,8BAAwC;IAAC;IAAY;IAAQ;IAAQ;IAAS;CAAS;AAE7F,MAAMC,eAAeC,WAAG,CAAC;;;;;;;;AAQzB,CAAC;AAaM,MAAMC,yBAAyB,CAACC;IACnC,MAAM,EAAEC,MAAM,EAAEC,MAAM,EAAE,GAAGF;IAC3B,OAAO,OAAOG;QACV,MAAMC,QAASD,AAAAA,CAAAA,QAAQ,EAAC,EAAG,IAAI;QAC/B,IAAKC,OAEE;YAAA,IAAI,CAACA,MAAM,MAAM,CAAC,GAAG,KAAK,CAAC,aAC9B,MAAM,IAAIC,MAAM;QACpB,OAHI,MAAM,IAAIA,MAAM;QAKpB,MAAMC,cAAcC,WAAiBC,UAAgBJ;QACrD,IAAIE,gBAAgBF,OAChB,MAAM,IAAIC,MACN,CAAC,UAAU,EAAED,MAAM,yHAAyH,CAAC;QAQrJ,KAAK,MAAMK,UAAUb,4BAA6B;YAC9C,MAAMc,KAAK,IAAIC,OAAO,GAAGF,OAAO,CAAC,CAAC,EAAE;YACpC,MAAMG,UAAUR,MAAM,KAAK,CAACM;YAC5B,IAAIE,AAAY,SAAZA,SAGJ,MAAM,IAAIP,MAAM,CAAC,4BAA4B,EAAEI,OAAO,EAAE,CAAC;QAC7D;QAIA,IAAIR,OAAO,IAAI,CAACY,CAAAA,IAAKA,EAAE,eAAe,KAAKT,QACvC,MAAM,IAAIC,MAAM,CAAC,CAAC,EAAEF,KAAK,yDAAyD,CAAC;aAChF,IAAIF,OAAO,IAAI,CAACY,CAAAA,IAAKA,EAAE,aAAa,KAAKT,QAC5C,MAAM,IAAIC,MAAM,CAAC,CAAC,EAAEF,KAAK,yDAAyD,CAAC;QAIvF,MAAM,EAAEW,IAAI,EAAE,GAAG,MAAMZ,OAAO,KAAK,CAAc;YAC7C,OAAOL;YACP,aAAa;QACjB;QAEA,MAAMkB,QAAQD,KAAK,QAAQ,CAAC,KAAK,CAAC,GAAG,CAACE,CAAAA,IAAKA,EAAE,IAAI;QAEjD,IAAID,MAAM,QAAQ,CAACT,cACf,MAAM,IAAID,MACN,CAAC,CAAC,EAAEF,KAAK,0EAA0E,CAAC;QAI5F,OAAO;IACX;AACJ"}
|
|
@@ -34,7 +34,7 @@ const createSelected = (params)=>{
|
|
|
34
34
|
for (const id of item.related){
|
|
35
35
|
const model = models.find((model)=>model.id === id);
|
|
36
36
|
if (!model) continue;
|
|
37
|
-
if (selected.has(model.id) || model.imported) continue;
|
|
37
|
+
else if (selected.has(model.id) || model.imported) continue;
|
|
38
38
|
const related = createSelected({
|
|
39
39
|
previous: selected,
|
|
40
40
|
models,
|
|
@@ -125,7 +125,7 @@ const ImportContextProvider = ({ children })=>{
|
|
|
125
125
|
error.message
|
|
126
126
|
]
|
|
127
127
|
}));
|
|
128
|
-
if (!data) return void setState((prev)=>({
|
|
128
|
+
else if (!data) return void setState((prev)=>({
|
|
129
129
|
...prev,
|
|
130
130
|
loading: false,
|
|
131
131
|
errors: [
|
|
@@ -161,9 +161,9 @@ const ImportContextProvider = ({ children })=>{
|
|
|
161
161
|
]);
|
|
162
162
|
const handleModelsImport = useCallback(async ()=>{
|
|
163
163
|
if (!state.data) return void console.error("Cannot import models without any data.");
|
|
164
|
-
if (!state.groups?.length) return void console.error("Cannot import models without any groups.");
|
|
165
|
-
if (!state.models?.length) return void console.error("Cannot import models because none are selected.");
|
|
166
|
-
if (0 === Array.from(state.selected.keys()).length) return void console.error("Cannot import models because none are selected.");
|
|
164
|
+
else if (!state.groups?.length) return void console.error("Cannot import models without any groups.");
|
|
165
|
+
else if (!state.models?.length) return void console.error("Cannot import models because none are selected.");
|
|
166
|
+
else if (0 === Array.from(state.selected.keys()).length) return void console.error("Cannot import models because none are selected.");
|
|
167
167
|
setState((prev)=>({
|
|
168
168
|
...prev,
|
|
169
169
|
loading: true
|
|
@@ -196,7 +196,7 @@ const ImportContextProvider = ({ children })=>{
|
|
|
196
196
|
error.message
|
|
197
197
|
]
|
|
198
198
|
}));
|
|
199
|
-
if (!data) return void setState((prev)=>({
|
|
199
|
+
else if (!data) return void setState((prev)=>({
|
|
200
200
|
...prev,
|
|
201
201
|
loading: false,
|
|
202
202
|
validated: false,
|