@payloadcms/live-preview 3.0.0-canary.fb81f02 → 3.0.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.
@@ -1 +1 @@
1
- {"version":3,"file":"mergeData.d.ts","sourceRoot":"","sources":["../src/mergeData.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAEvD,OAAO,KAAK,EAA2B,eAAe,EAAE,MAAM,YAAY,CAAA;AAc1E,eAAO,MAAM,SAAS,GAAU,CAAC,QAAQ;IACvC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,kCAAkC,CAAC,EAAE,CAAC,EACpC,OAAO,EACP,QAAQ,EACR,SAAS,GACV,EAAE;QACD,OAAO,EAAE,MAAM,CAAA;QACf,QAAQ,EAAE,MAAM,CAAA;QAChB,SAAS,EAAE,MAAM,CAAA;KAClB,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;IACvB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,6BAA6B,CAAC,EAAE,eAAe,CAAA;IAC/C,WAAW,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAA;IACjD,YAAY,EAAE,OAAO,CAAC,CAAC,CAAC,CAAA;IACxB,WAAW,EAAE,CAAC,CAAA;IACd,sBAAsB,CAAC,EAAE,OAAO,CAAA;IAChC,SAAS,EAAE,MAAM,CAAA;CAClB,KAAG,OAAO,CACT;IACE,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B,GAAG,CAAC,CA4DN,CAAA"}
1
+ {"version":3,"file":"mergeData.d.ts","sourceRoot":"","sources":["../src/mergeData.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAEvD,OAAO,KAAK,EAA2B,eAAe,EAAE,MAAM,YAAY,CAAA;AAc1E,eAAO,MAAM,SAAS,GAAU,CAAC,QAAQ;IACvC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,kCAAkC,CAAC,EAAE,CAAC,EACpC,OAAO,EACP,QAAQ,EACR,SAAS,GACV,EAAE;QACD,OAAO,EAAE,MAAM,CAAA;QACf,QAAQ,EAAE,MAAM,CAAA;QAChB,SAAS,EAAE,MAAM,CAAA;KAClB,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;IACvB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,6BAA6B,CAAC,EAAE,eAAe,CAAA;IAC/C,WAAW,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAA;IACjD,YAAY,EAAE,OAAO,CAAC,CAAC,CAAC,CAAA;IACxB,WAAW,EAAE,CAAC,CAAA;IACd,sBAAsB,CAAC,EAAE,OAAO,CAAA;IAChC,SAAS,EAAE,MAAM,CAAA;CAClB,KAAG,OAAO,CACT;IACE,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B,GAAG,CAAC,CA8DN,CAAA"}
package/dist/mergeData.js CHANGED
@@ -28,7 +28,7 @@ export const mergeData = async (args)=>{
28
28
  try {
29
29
  res = await requestHandler({
30
30
  apiPath: apiRoute || '/api',
31
- endpoint: `${collection}?depth=${depth}&where[id][in]=${Array.from(ids).join(',')}`,
31
+ endpoint: encodeURI(`${collection}?depth=${depth}&where[id][in]=${Array.from(ids).join(',')}`),
32
32
  serverURL
33
33
  }).then((res)=>res.json());
34
34
  if (res?.docs?.length > 0) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/mergeData.ts"],"sourcesContent":["import type { PaginatedDocs } from 'payload'\nimport type { fieldSchemaToJSON } from 'payload/shared'\n\nimport type { PopulationsByCollection, UpdatedDocument } from './types.js'\n\nimport { traverseFields } from './traverseFields.js'\n\nconst defaultRequestHandler = ({ apiPath, endpoint, serverURL }) => {\n const url = `${serverURL}${apiPath}/${endpoint}`\n return fetch(url, {\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n })\n}\n\nexport const mergeData = async <T>(args: {\n apiRoute?: string\n collectionPopulationRequestHandler?: ({\n apiPath,\n endpoint,\n serverURL,\n }: {\n apiPath: string\n endpoint: string\n serverURL: string\n }) => Promise<Response>\n depth?: number\n externallyUpdatedRelationship?: UpdatedDocument\n fieldSchema: ReturnType<typeof fieldSchemaToJSON>\n incomingData: Partial<T>\n initialData: T\n returnNumberOfRequests?: boolean\n serverURL: string\n}): Promise<\n {\n _numberOfRequests?: number\n } & T\n> => {\n const {\n apiRoute,\n depth,\n externallyUpdatedRelationship,\n fieldSchema,\n incomingData,\n initialData,\n returnNumberOfRequests,\n serverURL,\n } = args\n\n const result = { ...initialData }\n\n const populationsByCollection: PopulationsByCollection = {}\n\n traverseFields({\n externallyUpdatedRelationship,\n fieldSchema,\n incomingData,\n populationsByCollection,\n result,\n })\n\n await Promise.all(\n Object.entries(populationsByCollection).map(async ([collection, populations]) => {\n let res: PaginatedDocs\n\n const ids = new Set(populations.map(({ id }) => id))\n const requestHandler = args.collectionPopulationRequestHandler || defaultRequestHandler\n\n try {\n res = await requestHandler({\n apiPath: apiRoute || '/api',\n endpoint: `${collection}?depth=${depth}&where[id][in]=${Array.from(ids).join(',')}`,\n serverURL,\n }).then((res) => res.json())\n\n if (res?.docs?.length > 0) {\n res.docs.forEach((doc) => {\n populationsByCollection[collection].forEach((population) => {\n if (population.id === doc.id) {\n population.ref[population.accessor] = doc\n }\n })\n })\n }\n } catch (err) {\n console.error(err) // eslint-disable-line no-console\n }\n }),\n )\n\n return {\n ...result,\n ...(returnNumberOfRequests\n ? { _numberOfRequests: Object.keys(populationsByCollection).length }\n : {}),\n }\n}\n"],"names":["traverseFields","defaultRequestHandler","apiPath","endpoint","serverURL","url","fetch","credentials","headers","mergeData","args","apiRoute","depth","externallyUpdatedRelationship","fieldSchema","incomingData","initialData","returnNumberOfRequests","result","populationsByCollection","Promise","all","Object","entries","map","collection","populations","res","ids","Set","id","requestHandler","collectionPopulationRequestHandler","Array","from","join","then","json","docs","length","forEach","doc","population","ref","acc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IAAIA,WAAWZ,EAAE,KAAKW,IAAIX,EAAE,EAAE;4BAC5BY,WAAWC,GAAG,CAACD,WAAWE,QAAQ,CAAC,GAAGH;wBACxC;oBACF;gBACF;YACF;QACF,EAAE,OAAOI,KAAK;YACZC,QAAQC,KAAK,CAACF,KAAK,iCAAiC;;QACtD;IACF;IAGF,OAAO;QACL,GAAG3B,MAAM;QACT,GAAID,yBACA;YAAE+B,mBAAmB1B,OAAO2B,IAAI,CAAC9B,yBAAyBoB,MAAM;QAAC,IACjE,CAAC,CAAC;IACR;AACF,EAAC"}
1
+ {"version":3,"sources":["../src/mergeData.ts"],"sourcesContent":["import type { PaginatedDocs } from 'payload'\nimport type { fieldSchemaToJSON } from 'payload/shared'\n\nimport type { PopulationsByCollection, UpdatedDocument } from './types.js'\n\nimport { traverseFields } from './traverseFields.js'\n\nconst defaultRequestHandler = ({ apiPath, endpoint, serverURL }) => {\n const url = `${serverURL}${apiPath}/${endpoint}`\n return fetch(url, {\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n })\n}\n\nexport const mergeData = async <T>(args: {\n apiRoute?: string\n collectionPopulationRequestHandler?: ({\n apiPath,\n endpoint,\n serverURL,\n }: {\n apiPath: string\n endpoint: string\n serverURL: string\n }) => Promise<Response>\n depth?: number\n externallyUpdatedRelationship?: UpdatedDocument\n fieldSchema: ReturnType<typeof fieldSchemaToJSON>\n incomingData: Partial<T>\n initialData: T\n returnNumberOfRequests?: boolean\n serverURL: string\n}): Promise<\n {\n _numberOfRequests?: number\n } & T\n> => {\n const {\n apiRoute,\n depth,\n externallyUpdatedRelationship,\n fieldSchema,\n incomingData,\n initialData,\n returnNumberOfRequests,\n serverURL,\n } = args\n\n const result = { ...initialData }\n\n const populationsByCollection: PopulationsByCollection = {}\n\n traverseFields({\n externallyUpdatedRelationship,\n fieldSchema,\n incomingData,\n populationsByCollection,\n result,\n })\n\n await Promise.all(\n Object.entries(populationsByCollection).map(async ([collection, populations]) => {\n let res: PaginatedDocs\n\n const ids = new Set(populations.map(({ id }) => id))\n const requestHandler = args.collectionPopulationRequestHandler || defaultRequestHandler\n\n try {\n res = await requestHandler({\n apiPath: apiRoute || '/api',\n endpoint: encodeURI(\n `${collection}?depth=${depth}&where[id][in]=${Array.from(ids).join(',')}`,\n ),\n serverURL,\n }).then((res) => res.json())\n\n if (res?.docs?.length > 0) {\n res.docs.forEach((doc) => {\n populationsByCollection[collection].forEach((population) => {\n if (population.id === doc.id) {\n population.ref[population.accessor] = doc\n }\n })\n })\n }\n } catch (err) {\n console.error(err) // eslint-disable-line no-console\n }\n }),\n )\n\n return {\n ...result,\n ...(returnNumberOfRequests\n ? { _numberOfRequests: Object.keys(populationsByCollection).length }\n : {}),\n }\n}\n"],"names":["traverseFields","defaultRequestHandler","apiPath","endpoint","serverURL","url","fetch","credentials","headers","mergeData","args","apiRoute","depth","externallyUpdatedRelationship","fieldSchema","incomingData","initialData","returnNumberOfRequests","result","populationsByCollection","Promise","all","Object","entries","map","collection","populations","res","ids","Set","id","requestHandler","collectionPopulationRequestHandler","encodeURI","Array","from","join","then","json","docs","length","forEach","doc","population","ref","accessor","err","console","error","_numberOfRequests","keys"],"mappings":"AAKA,SAASA,cAAc,QAAQ,sBAAqB;AAEpD,MAAMC,wBAAwB,CAAC,EAAEC,OAAO,EAAEC,QAAQ,EAAEC,SAAS,EAAE;IAC7D,MAAMC,MAAM,CAAC,EAAED,UAAU,EAAEF,QAAQ,CAAC,EAAEC,SAAS,CAAC;IAChD,OAAOG,MAAMD,KAAK;QAChBE,aAAa;QACbC,SAAS;YACP,gBAAgB;QAClB;IACF;AACF;AAEA,OAAO,MAAMC,YAAY,OAAUC;IAuBjC,MAAM,EACJC,QAAQ,EACRC,KAAK,EACLC,6BAA6B,EAC7BC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,sBAAsB,EACtBb,SAAS,EACV,GAAGM;IAEJ,MAAMQ,SAAS;QAAE,GAAGF,WAAW;IAAC;IAEhC,MAAMG,0BAAmD,CAAC;IAE1DnB,eAAe;QACba;QACAC;QACAC;QACAI;QACAD;IACF;IAEA,MAAME,QAAQC,GAAG,CACfC,OAAOC,OAAO,CAACJ,yBAAyBK,GAAG,CAAC,OAAO,CAACC,YAAYC,YAAY;QAC1E,IAAIC;QAEJ,MAAMC,MAAM,IAAIC,IAAIH,YAAYF,GAAG,CAAC,CAAC,EAAEM,EAAE,EAAE,GAAKA;QAChD,MAAMC,iBAAiBrB,KAAKsB,kCAAkC,IAAI/B;QAElE,IAAI;YACF0B,MAAM,MAAMI,eAAe;gBACzB7B,SAASS,YAAY;gBACrBR,UAAU8B,UACR,CAAC,EAAER,WAAW,OAAO,EAAEb,MAAM,eAAe,EAAEsB,MAAMC,IAAI,CAACP,KAAKQ,IAAI,CAAC,KAAK,CAAC;gBAE3EhC;YACF,GAAGiC,IAAI,CAAC,CAACV,MAAQA,IAAIW,IAAI;YAEzB,IAAIX,KAAKY,MAAMC,SAAS,GAAG;gBACzBb,IAAIY,IAAI,CAACE,OAAO,CAAC,CAACC;oBAChBvB,uBAAuB,CAACM,WAAW,CAACgB,OAAO,CAAC,CAACE;wBAC3C,IAAIA,WAAWb,EAAE,KAAKY,IAAIZ,EAAE,EAAE;4BAC5Ba,WAAWC,GAAG,CAACD,WAAWE,QAAQ,CAAC,GAAGH;wBACxC;oBACF;gBACF;YACF;QACF,EAAE,OAAOI,KAAK;YACZC,QAAQC,KAAK,CAACF,KAAK,iCAAiC;;QACtD;IACF;IAGF,OAAO;QACL,GAAG5B,MAAM;QACT,GAAID,yBACA;YAAEgC,mBAAmB3B,OAAO4B,IAAI,CAAC/B,yBAAyBqB,MAAM;QAAC,IACjE,CAAC,CAAC;IACR;AACF,EAAC"}
@@ -5,14 +5,6 @@ export const traverseFields = (args)=>{
5
5
  if ('name' in fieldSchema && typeof fieldSchema.name === 'string') {
6
6
  const fieldName = fieldSchema.name;
7
7
  switch(fieldSchema.type){
8
- case 'richText':
9
- result[fieldName] = traverseRichText({
10
- externallyUpdatedRelationship,
11
- incomingData: incomingData[fieldName],
12
- populationsByCollection,
13
- result: result[fieldName]
14
- });
15
- break;
16
8
  case 'array':
17
9
  if (Array.isArray(incomingData[fieldName])) {
18
10
  result[fieldName] = incomingData[fieldName].map((incomingRow, i)=>{
@@ -58,8 +50,8 @@ export const traverseFields = (args)=>{
58
50
  result[fieldName] = [];
59
51
  }
60
52
  break;
61
- case 'tabs':
62
53
  case 'group':
54
+ case 'tabs':
63
55
  if (!result[fieldName]) {
64
56
  result[fieldName] = {};
65
57
  }
@@ -71,8 +63,8 @@ export const traverseFields = (args)=>{
71
63
  result: result[fieldName]
72
64
  });
73
65
  break;
74
- case 'upload':
75
66
  case 'relationship':
67
+ case 'upload':
76
68
  // Handle `hasMany` relationships
77
69
  if (fieldSchema.hasMany && Array.isArray(incomingData[fieldName])) {
78
70
  if (!result[fieldName] || !incomingData[fieldName].length) {
@@ -183,6 +175,14 @@ export const traverseFields = (args)=>{
183
175
  }
184
176
  }
185
177
  break;
178
+ case 'richText':
179
+ result[fieldName] = traverseRichText({
180
+ externallyUpdatedRelationship,
181
+ incomingData: incomingData[fieldName],
182
+ populationsByCollection,
183
+ result: result[fieldName]
184
+ });
185
+ break;
186
186
  default:
187
187
  result[fieldName] = incomingData[fieldName];
188
188
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/traverseFields.ts"],"sourcesContent":["import type { fieldSchemaToJSON } from 'payload/shared'\n\nimport type { PopulationsByCollection, UpdatedDocument } from './types.js'\n\nimport { traverseRichText } from './traverseRichText.js'\n\nexport const traverseFields = <T>(args: {\n externallyUpdatedRelationship?: UpdatedDocument\n fieldSchema: ReturnType<typeof fieldSchemaToJSON>\n incomingData: T\n populationsByCollection: PopulationsByCollection\n result: T\n}): void => {\n const {\n externallyUpdatedRelationship,\n fieldSchema: fieldSchemas,\n incomingData,\n populationsByCollection,\n result,\n } = args\n\n fieldSchemas.forEach((fieldSchema) => {\n if ('name' in fieldSchema && typeof fieldSchema.name === 'string') {\n const fieldName = fieldSchema.name\n\n switch (fieldSchema.type) {\n case 'richText':\n result[fieldName] = traverseRichText({\n externallyUpdatedRelationship,\n incomingData: incomingData[fieldName],\n populationsByCollection,\n result: result[fieldName],\n })\n\n break\n\n case 'array':\n if (Array.isArray(incomingData[fieldName])) {\n result[fieldName] = incomingData[fieldName].map((incomingRow, i) => {\n if (!result[fieldName]) {\n result[fieldName] = []\n }\n\n if (!result[fieldName][i]) {\n result[fieldName][i] = {}\n }\n\n traverseFields({\n externallyUpdatedRelationship,\n fieldSchema: fieldSchema.fields,\n incomingData: incomingRow,\n populationsByCollection,\n result: result[fieldName][i],\n })\n\n return result[fieldName][i]\n })\n }\n\n break\n\n case 'blocks':\n if (Array.isArray(incomingData[fieldName])) {\n result[fieldName] = incomingData[fieldName].map((incomingBlock, i) => {\n const incomingBlockJSON = fieldSchema.blocks[incomingBlock.blockType]\n\n if (!result[fieldName]) {\n result[fieldName] = []\n }\n\n if (\n !result[fieldName][i] ||\n result[fieldName][i].id !== incomingBlock.id ||\n result[fieldName][i].blockType !== incomingBlock.blockType\n ) {\n result[fieldName][i] = {\n blockType: incomingBlock.blockType,\n }\n }\n\n traverseFields({\n externallyUpdatedRelationship,\n fieldSchema: incomingBlockJSON.fields,\n incomingData: incomingBlock,\n populationsByCollection,\n result: result[fieldName][i],\n })\n\n return result[fieldName][i]\n })\n } else {\n result[fieldName] = []\n }\n\n break\n\n case 'tabs':\n case 'group':\n if (!result[fieldName]) {\n result[fieldName] = {}\n }\n\n traverseFields({\n externallyUpdatedRelationship,\n fieldSchema: fieldSchema.fields,\n incomingData: incomingData[fieldName] || {},\n populationsByCollection,\n result: result[fieldName],\n })\n\n break\n\n case 'upload':\n case 'relationship':\n // Handle `hasMany` relationships\n if (fieldSchema.hasMany && Array.isArray(incomingData[fieldName])) {\n if (!result[fieldName] || !incomingData[fieldName].length) {\n result[fieldName] = []\n }\n\n incomingData[fieldName].forEach((incomingRelation, i) => {\n // Handle `hasMany` polymorphic\n if (Array.isArray(fieldSchema.relationTo)) {\n // if the field doesn't exist on the result, create it\n // the value will be populated later\n if (!result[fieldName][i]) {\n result[fieldName][i] = {\n relationTo: incomingRelation.relationTo,\n }\n }\n\n const oldID = result[fieldName][i]?.value?.id\n const oldRelation = result[fieldName][i]?.relationTo\n const newID = incomingRelation.value\n const newRelation = incomingRelation.relationTo\n\n const hasChanged = newID !== oldID || newRelation !== oldRelation\n const hasUpdated =\n newRelation === externallyUpdatedRelationship?.entitySlug &&\n newID === externallyUpdatedRelationship?.id\n\n if (hasChanged || hasUpdated) {\n if (!populationsByCollection[newRelation]) {\n populationsByCollection[newRelation] = []\n }\n\n populationsByCollection[newRelation].push({\n id: incomingRelation.value,\n accessor: 'value',\n ref: result[fieldName][i],\n })\n }\n } else {\n // Handle `hasMany` monomorphic\n const hasChanged = incomingRelation !== result[fieldName][i]?.id\n const hasUpdated =\n fieldSchema.relationTo === externallyUpdatedRelationship?.entitySlug &&\n incomingRelation === externallyUpdatedRelationship?.id\n\n if (hasChanged || hasUpdated) {\n if (!populationsByCollection[fieldSchema.relationTo]) {\n populationsByCollection[fieldSchema.relationTo] = []\n }\n\n populationsByCollection[fieldSchema.relationTo].push({\n id: incomingRelation,\n accessor: i,\n ref: result[fieldName],\n })\n }\n }\n })\n } else {\n // Handle `hasOne` polymorphic\n if (Array.isArray(fieldSchema.relationTo)) {\n // if the field doesn't exist on the result, create it\n // the value will be populated later\n if (!result[fieldName]) {\n result[fieldName] = {\n relationTo: incomingData[fieldName]?.relationTo,\n }\n }\n\n const hasNewValue =\n incomingData[fieldName] &&\n typeof incomingData[fieldName] === 'object' &&\n incomingData[fieldName] !== null\n\n const hasOldValue =\n result[fieldName] &&\n typeof result[fieldName] === 'object' &&\n result[fieldName] !== null\n\n const newID = hasNewValue\n ? typeof incomingData[fieldName].value === 'object'\n ? incomingData[fieldName].value.id\n : incomingData[fieldName].value\n : ''\n\n const oldID = hasOldValue\n ? typeof result[fieldName].value === 'object'\n ? result[fieldName].value.id\n : result[fieldName].value\n : ''\n\n const newRelation = hasNewValue ? incomingData[fieldName].relationTo : ''\n const oldRelation = hasOldValue ? result[fieldName].relationTo : ''\n\n const hasChanged = newID !== oldID || newRelation !== oldRelation\n const hasUpdated =\n newRelation === externallyUpdatedRelationship?.entitySlug &&\n newID === externallyUpdatedRelationship?.id\n\n // if the new value/relation is different from the old value/relation\n // populate the new value, otherwise leave it alone\n if (hasChanged || hasUpdated) {\n // if the new value is not empty, populate it\n // otherwise set the value to null\n if (newID) {\n if (!populationsByCollection[newRelation]) {\n populationsByCollection[newRelation] = []\n }\n\n populationsByCollection[newRelation].push({\n id: newID,\n accessor: 'value',\n ref: result[fieldName],\n })\n } else {\n result[fieldName] = null\n }\n }\n } else {\n // Handle `hasOne` monomorphic\n const newID: number | string | undefined =\n (incomingData[fieldName] &&\n typeof incomingData[fieldName] === 'object' &&\n incomingData[fieldName].id) ||\n incomingData[fieldName]\n\n const oldID: number | string | undefined =\n (result[fieldName] &&\n typeof result[fieldName] === 'object' &&\n result[fieldName].id) ||\n result[fieldName]\n\n const hasChanged = newID !== oldID\n const hasUpdated =\n fieldSchema.relationTo === externallyUpdatedRelationship?.entitySlug &&\n newID === externallyUpdatedRelationship?.id\n\n // if the new value is different from the old value\n // populate the new value, otherwise leave it alone\n if (hasChanged || hasUpdated) {\n // if the new value is not empty, populate it\n // otherwise set the value to null\n if (newID) {\n if (!populationsByCollection[fieldSchema.relationTo]) {\n populationsByCollection[fieldSchema.relationTo] = []\n }\n\n populationsByCollection[fieldSchema.relationTo].push({\n id: newID,\n accessor: fieldName,\n ref: result as Record<string, unknown>,\n })\n } else {\n result[fieldName] = null\n }\n }\n }\n }\n\n break\n\n default:\n result[fieldName] = incomingData[fieldName]\n }\n }\n })\n}\n"],"names":["traverseRichText","traverseFields","args","externallyUpdatedRelationship","fieldSchema","fieldSchemas","incomingData","populationsByCollection","result","forEach","name","fieldName","type","Array","isArray","map","incomingRow","i","fields","incomingBlock","incomingBlockJSON","blocks","blockType","id","hasMany","length","incomingRelation","relationTo","oldID","value","oldRelation","newID","newRelation","hasChanged","hasUpdated","entitySlug","push","accessor","ref","hasNewValue","hasOldValue"],"mappings":"AAIA,SAASA,gBAAgB,QAAQ,wBAAuB;AAExD,OAAO,MAAMC,iBAAiB,CAAIC;IAOhC,MAAM,EACJC,6BAA6B,EAC7BC,aAAaC,YAAY,EACzBC,YAAY,EACZC,uBAAuB,EACvBC,MAAM,EACP,GAAGN;IAEJG,aAAaI,OAAO,CAAC,CAACL;QACpB,IAAI,UAAUA,eAAe,OAAOA,YAAYM,IAAI,KAAK,UAAU;YACjE,MAAMC,YAAYP,YAAYM,IAAI;YAElC,OAAQN,YAAYQ,IAAI;gBACtB,KAAK;oBACHJ,MAAM,CAACG,UAAU,GAAGX,iBAAiB;wBACnCG;wBACAG,cAAcA,YAAY,CAACK,UAAU;wBACrCJ;wBACAC,QAAQA,MAAM,CAACG,UAAU;oBAC3B;oBAEA;gBAEF,KAAK;oBACH,IAAIE,MAAMC,OAAO,CAACR,YAAY,CAACK,UAAU,GAAG;wBAC1CH,MAAM,CAACG,UAAU,GAAGL,YAAY,CAACK,UAAU,CAACI,GAAG,CAAC,CAACC,aAAaC;4BAC5D,IAAI,CAACT,MAAM,CAACG,UAAU,EAAE;gCACtBH,MAAM,CAACG,UAAU,GAAG,EAAE;4BACxB;4BAEA,IAAI,CAACH,MAAM,CAACG,UAAU,CAACM,EAAE,EAAE;gCACzBT,MAAM,CAACG,UAAU,CAACM,EAAE,GAAG,CAAC;4BAC1B;4BAEAhB,eAAe;gCACbE;gCACAC,aAAaA,YAAYc,MAAM;gCAC/BZ,cAAcU;gCACdT;gCACAC,QAAQA,MAAM,CAACG,UAAU,CAACM,EAAE;4BAC9B;4BAEA,OAAOT,MAAM,CAACG,UAAU,CAACM,EAAE;wBAC7B;oBACF;oBAEA;gBAEF,KAAK;oBACH,IAAIJ,MAAMC,OAAO,CAACR,YAAY,CAACK,UAAU,GAAG;wBAC1CH,MAA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KAAK9B;oCACP;gCACF,OAAO;oCACLA,MAAM,CAACG,UAAU,GAAG;gCACtB;4BACF;wBACF;oBACF;oBAEA;gBAEF;oBACEH,MAAM,CAACG,UAAU,GAAGL,YAAY,CAACK,UAAU;YAC/C;QACF;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../src/traverseFields.ts"],"sourcesContent":["import type { fieldSchemaToJSON } from 'payload/shared'\n\nimport type { PopulationsByCollection, UpdatedDocument } from './types.js'\n\nimport { traverseRichText } from './traverseRichText.js'\n\nexport const traverseFields = <T>(args: {\n externallyUpdatedRelationship?: UpdatedDocument\n fieldSchema: ReturnType<typeof fieldSchemaToJSON>\n incomingData: T\n populationsByCollection: PopulationsByCollection\n result: T\n}): void => {\n const {\n externallyUpdatedRelationship,\n fieldSchema: fieldSchemas,\n incomingData,\n populationsByCollection,\n result,\n } = args\n\n fieldSchemas.forEach((fieldSchema) => {\n if ('name' in fieldSchema && typeof fieldSchema.name === 'string') {\n const fieldName = fieldSchema.name\n\n switch (fieldSchema.type) {\n case 'array':\n if (Array.isArray(incomingData[fieldName])) {\n result[fieldName] = incomingData[fieldName].map((incomingRow, i) => {\n if (!result[fieldName]) {\n result[fieldName] = []\n }\n\n if (!result[fieldName][i]) {\n result[fieldName][i] = {}\n }\n\n traverseFields({\n externallyUpdatedRelationship,\n fieldSchema: fieldSchema.fields,\n incomingData: incomingRow,\n populationsByCollection,\n result: result[fieldName][i],\n })\n\n return result[fieldName][i]\n })\n }\n\n break\n\n case 'blocks':\n if (Array.isArray(incomingData[fieldName])) {\n result[fieldName] = incomingData[fieldName].map((incomingBlock, i) => {\n const incomingBlockJSON = fieldSchema.blocks[incomingBlock.blockType]\n\n if (!result[fieldName]) {\n result[fieldName] = []\n }\n\n if (\n !result[fieldName][i] ||\n result[fieldName][i].id !== incomingBlock.id ||\n result[fieldName][i].blockType !== incomingBlock.blockType\n ) {\n result[fieldName][i] = {\n blockType: incomingBlock.blockType,\n }\n }\n\n traverseFields({\n externallyUpdatedRelationship,\n fieldSchema: incomingBlockJSON.fields,\n incomingData: incomingBlock,\n populationsByCollection,\n result: result[fieldName][i],\n })\n\n return result[fieldName][i]\n })\n } else {\n result[fieldName] = []\n }\n\n break\n\n case 'group':\n\n case 'tabs':\n if (!result[fieldName]) {\n result[fieldName] = {}\n }\n\n traverseFields({\n externallyUpdatedRelationship,\n fieldSchema: fieldSchema.fields,\n incomingData: incomingData[fieldName] || {},\n populationsByCollection,\n result: result[fieldName],\n })\n\n break\n case 'relationship':\n\n case 'upload':\n // Handle `hasMany` relationships\n if (fieldSchema.hasMany && Array.isArray(incomingData[fieldName])) {\n if (!result[fieldName] || !incomingData[fieldName].length) {\n result[fieldName] = []\n }\n\n incomingData[fieldName].forEach((incomingRelation, i) => {\n // Handle `hasMany` polymorphic\n if (Array.isArray(fieldSchema.relationTo)) {\n // if the field doesn't exist on the result, create it\n // the value will be populated later\n if (!result[fieldName][i]) {\n result[fieldName][i] = {\n relationTo: incomingRelation.relationTo,\n }\n }\n\n const oldID = result[fieldName][i]?.value?.id\n const oldRelation = result[fieldName][i]?.relationTo\n const newID = incomingRelation.value\n const newRelation = incomingRelation.relationTo\n\n const hasChanged = newID !== oldID || newRelation !== oldRelation\n const hasUpdated =\n newRelation === externallyUpdatedRelationship?.entitySlug &&\n newID === externallyUpdatedRelationship?.id\n\n if (hasChanged || hasUpdated) {\n if (!populationsByCollection[newRelation]) {\n populationsByCollection[newRelation] = []\n }\n\n populationsByCollection[newRelation].push({\n id: incomingRelation.value,\n accessor: 'value',\n ref: result[fieldName][i],\n })\n }\n } else {\n // Handle `hasMany` monomorphic\n const hasChanged = incomingRelation !== result[fieldName][i]?.id\n const hasUpdated =\n fieldSchema.relationTo === externallyUpdatedRelationship?.entitySlug &&\n incomingRelation === externallyUpdatedRelationship?.id\n\n if (hasChanged || hasUpdated) {\n if (!populationsByCollection[fieldSchema.relationTo]) {\n populationsByCollection[fieldSchema.relationTo] = []\n }\n\n populationsByCollection[fieldSchema.relationTo].push({\n id: incomingRelation,\n accessor: i,\n ref: result[fieldName],\n })\n }\n }\n })\n } else {\n // Handle `hasOne` polymorphic\n if (Array.isArray(fieldSchema.relationTo)) {\n // if the field doesn't exist on the result, create it\n // the value will be populated later\n if (!result[fieldName]) {\n result[fieldName] = {\n relationTo: incomingData[fieldName]?.relationTo,\n }\n }\n\n const hasNewValue =\n incomingData[fieldName] &&\n typeof incomingData[fieldName] === 'object' &&\n incomingData[fieldName] !== null\n\n const hasOldValue =\n result[fieldName] &&\n typeof result[fieldName] === 'object' &&\n result[fieldName] !== null\n\n const newID = hasNewValue\n ? typeof incomingData[fieldName].value === 'object'\n ? incomingData[fieldName].value.id\n : incomingData[fieldName].value\n : ''\n\n const oldID = hasOldValue\n ? typeof result[fieldName].value === 'object'\n ? result[fieldName].value.id\n : result[fieldName].value\n : ''\n\n const newRelation = hasNewValue ? incomingData[fieldName].relationTo : ''\n const oldRelation = hasOldValue ? result[fieldName].relationTo : ''\n\n const hasChanged = newID !== oldID || newRelation !== oldRelation\n const hasUpdated =\n newRelation === externallyUpdatedRelationship?.entitySlug &&\n newID === externallyUpdatedRelationship?.id\n\n // if the new value/relation is different from the old value/relation\n // populate the new value, otherwise leave it alone\n if (hasChanged || hasUpdated) {\n // if the new value is not empty, populate it\n // otherwise set the value to null\n if (newID) {\n if (!populationsByCollection[newRelation]) {\n populationsByCollection[newRelation] = []\n }\n\n populationsByCollection[newRelation].push({\n id: newID,\n accessor: 'value',\n ref: result[fieldName],\n })\n } else {\n result[fieldName] = null\n }\n }\n } else {\n // Handle `hasOne` monomorphic\n const newID: number | string | undefined =\n (incomingData[fieldName] &&\n typeof incomingData[fieldName] === 'object' &&\n incomingData[fieldName].id) ||\n incomingData[fieldName]\n\n const oldID: number | string | undefined =\n (result[fieldName] &&\n typeof result[fieldName] === 'object' &&\n result[fieldName].id) ||\n result[fieldName]\n\n const hasChanged = newID !== oldID\n const hasUpdated =\n fieldSchema.relationTo === externallyUpdatedRelationship?.entitySlug &&\n newID === externallyUpdatedRelationship?.id\n\n // if the new value is different from the old value\n // populate the new value, otherwise leave it alone\n if (hasChanged || hasUpdated) {\n // if the new value is not empty, populate it\n // otherwise set the value to null\n if (newID) {\n if (!populationsByCollection[fieldSchema.relationTo]) {\n populationsByCollection[fieldSchema.relationTo] = []\n }\n\n populationsByCollection[fieldSchema.relationTo].push({\n id: newID,\n accessor: fieldName,\n ref: result as Record<string, unknown>,\n })\n } else {\n result[fieldName] = null\n }\n }\n }\n }\n\n break\n case 'richText':\n result[fieldName] = traverseRichText({\n externallyUpdatedRelationship,\n incomingData: incomingData[fieldName],\n populationsByCollection,\n result: result[fieldName],\n })\n\n break\n\n default:\n result[fieldName] = incomingData[fieldName]\n }\n }\n })\n}\n"],"names":["traverseRichText","traverseFields","args","externallyUpdatedRelationship","fieldSchema","fieldSchemas","incomingData","populationsByCollection","result","forEach","name","fieldName","type","Array","isArray","map","incomingRow","i","fields","incomingBlock","incomingBlockJSON","blocks","blockType","id","hasMany","length","incomingRelation","relationTo","oldID","value","oldRelation","newID","newRelation","hasChanged","hasUpdated","entitySlug","push","accessor","ref","hasNewValue","hasOldValue"],"mappings":"AAIA,SAASA,gBAAgB,QAAQ,wBAAuB;AAExD,OAAO,MAAMC,iBAAiB,CAAIC;IAOhC,MAAM,EACJC,6BAA6B,EAC7BC,aAAaC,YAAY,EACzBC,YAAY,EACZC,uBAAuB,EACvBC,MAAM,EACP,GAAGN;IAEJG,aAAaI,OAAO,CAAC,CAACL;QACpB,IAAI,UAAUA,eAAe,OAAOA,YAAYM,IAAI,KAAK,UAAU;YACjE,MAAMC,YAAYP,YAAYM,IAAI;YAElC,OAAQN,YAAYQ,IAAI;gBACtB,KAAK;oBACH,IAAIC,MAAMC,OAAO,CAACR,YAAY,CAACK,UAAU,GAAG;wBAC1CH,MAAM,CAACG,UAAU,GAAGL,YAAY,CAACK,UAAU,CAACI,GAAG,CAAC,CAACC,aAAaC;4BAC5D,IAAI,CAACT,MAAM,CAACG,UAA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AAMsB,aAAaF,UAAUH;4BAC7B,MAAMM,aACJ9B,YAAYuB,UAAU,KAAKxB,+BAA+BgC,cAC1DJ,UAAU5B,+BAA+BoB;4BAE3C,mDAAmD;4BACnD,mDAAmD;4BACnD,IAAIU,cAAcC,YAAY;gCAC5B,6CAA6C;gCAC7C,kCAAkC;gCAClC,IAAIH,OAAO;oCACT,IAAI,CAACxB,uBAAuB,CAACH,YAAYuB,UAAU,CAAC,EAAE;wCACpDpB,uBAAuB,CAACH,YAAYuB,UAAU,CAAC,GAAG,EAAE;oCACtD;oCAEApB,uBAAuB,CAACH,YAAYuB,UAAU,CAAC,CAACS,IAAI,CAAC;wCACnDb,IAAIQ;wCACJM,UAAU1B;wCACV2B,KAAK9B;oCACP;gCACF,OAAO;oCACLA,MAAM,CAACG,UAAU,GAAG;gCACtB;4BACF;wBACF;oBACF;oBAEA;gBACF,KAAK;oBACHH,MAAM,CAACG,UAAU,GAAGX,iBAAiB;wBACnCG;wBACAG,cAAcA,YAAY,CAACK,UAAU;wBACrCJ;wBACAC,QAAQA,MAAM,CAACG,UAAU;oBAC3B;oBAEA;gBAEF;oBACEH,MAAM,CAACG,UAAU,GAAGL,YAAY,CAACK,UAAU;YAC/C;QACF;IACF;AACF,EAAC"}
package/license.md ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018-2024 Payload CMS, Inc. <info@payloadcms.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ 'Software'), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/live-preview",
3
- "version": "3.0.0-canary.fb81f02",
3
+ "version": "3.0.0",
4
4
  "description": "The official live preview JavaScript SDK for Payload",
5
5
  "homepage": "https://payloadcms.com",
6
6
  "repository": {
@@ -10,6 +10,13 @@
10
10
  },
11
11
  "license": "MIT",
12
12
  "author": "Payload <dev@payloadcms.com> (https://payloadcms.com)",
13
+ "maintainers": [
14
+ {
15
+ "name": "Payload",
16
+ "email": "info@payloadcms.com",
17
+ "url": "https://payloadcms.com"
18
+ }
19
+ ],
13
20
  "type": "module",
14
21
  "exports": {
15
22
  ".": {
@@ -24,8 +31,8 @@
24
31
  "dist"
25
32
  ],
26
33
  "devDependencies": {
27
- "@payloadcms/eslint-config": "3.0.0-beta.59",
28
- "payload": "3.0.0-canary.fb81f02"
34
+ "@payloadcms/eslint-config": "3.0.0-beta.112",
35
+ "payload": "3.0.0"
29
36
  },
30
37
  "publishConfig": {
31
38
  "registry": "https://registry.npmjs.org/"
@@ -35,6 +42,8 @@
35
42
  "build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
36
43
  "build:types": "tsc --emitDeclarationOnly --outDir dist",
37
44
  "clean": "rimraf {dist,*.tsbuildinfo}",
38
- "copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png,json}\" dist/"
45
+ "copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png,json}\" dist/",
46
+ "lint": "eslint .",
47
+ "lint:fix": "eslint . --fix"
39
48
  }
40
49
  }