@payloadcms/live-preview
Advanced tools
Comparing version 1.0.0-beta.3 to 3.0.0-beta.16
export declare const handleMessage: <T>(args: { | ||
depth: number; | ||
apiRoute?: string; | ||
depth?: number; | ||
event: MessageEvent; | ||
@@ -4,0 +5,0 @@ initialData: T; |
@@ -1,26 +0,34 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "handleMessage", { | ||
enumerable: true, | ||
get: function() { | ||
return handleMessage; | ||
} | ||
}); | ||
const _ = require("."); | ||
const handleMessage = async (args)=>{ | ||
const { depth, event, initialData, serverURL } = args; | ||
if (event.origin === serverURL && event.data) { | ||
const eventData = JSON.parse(event?.data); | ||
if (eventData.type === 'livePreview') { | ||
const mergedData = await (0, _.mergeData)({ | ||
depth, | ||
fieldSchema: eventData.fieldSchemaJSON, | ||
incomingData: eventData.data, | ||
initialData, | ||
serverURL | ||
}); | ||
return mergedData; | ||
import { mergeData } from './mergeData.js'; | ||
// For performance reasons, `fieldSchemaJSON` will only be sent once on the initial message | ||
// We need to cache this value so that it can be used across subsequent messages | ||
// To do this, save `fieldSchemaJSON` when it arrives as a global variable | ||
// Send this cached value to `mergeData`, instead of `eventData.fieldSchemaJSON` directly | ||
let payloadLivePreviewFieldSchema = undefined // TODO: type this from `fieldSchemaToJSON` return type | ||
; | ||
// Each time the data is merged, cache the result as a `previousData` variable | ||
// This will ensure changes compound overtop of each other | ||
let payloadLivePreviewPreviousData = undefined; | ||
export const handleMessage = async (args)=>{ | ||
const { apiRoute, depth, event, initialData, serverURL } = args; | ||
if (event.origin === serverURL && event.data && typeof event.data === 'object' && event.data.type === 'payload-live-preview') { | ||
const { data, externallyUpdatedRelationship, fieldSchemaJSON } = event.data; | ||
if (!payloadLivePreviewFieldSchema && fieldSchemaJSON) { | ||
payloadLivePreviewFieldSchema = fieldSchemaJSON; | ||
} | ||
if (!payloadLivePreviewFieldSchema) { | ||
// eslint-disable-next-line no-console | ||
console.warn('Payload Live Preview: No `fieldSchemaJSON` was received from the parent window. Unable to merge data.'); | ||
return initialData; | ||
} | ||
const mergedData = await mergeData({ | ||
apiRoute, | ||
depth, | ||
externallyUpdatedRelationship, | ||
fieldSchema: payloadLivePreviewFieldSchema, | ||
incomingData: data, | ||
initialData: payloadLivePreviewPreviousData || initialData, | ||
serverURL | ||
}); | ||
payloadLivePreviewPreviousData = mergedData; | ||
return mergedData; | ||
} | ||
@@ -30,2 +38,2 @@ return initialData; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9oYW5kbGVNZXNzYWdlLnRzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IG1lcmdlRGF0YSB9IGZyb20gJy4nXG5cbmV4cG9ydCBjb25zdCBoYW5kbGVNZXNzYWdlID0gYXN5bmMgPFQ+KGFyZ3M6IHtcbiAgZGVwdGg6IG51bWJlclxuICBldmVudDogTWVzc2FnZUV2ZW50XG4gIGluaXRpYWxEYXRhOiBUXG4gIHNlcnZlclVSTDogc3RyaW5nXG59KTogUHJvbWlzZTxUPiA9PiB7XG4gIGNvbnN0IHsgZGVwdGgsIGV2ZW50LCBpbml0aWFsRGF0YSwgc2VydmVyVVJMIH0gPSBhcmdzXG5cbiAgaWYgKGV2ZW50Lm9yaWdpbiA9PT0gc2VydmVyVVJMICYmIGV2ZW50LmRhdGEpIHtcbiAgICBjb25zdCBldmVudERhdGEgPSBKU09OLnBhcnNlKGV2ZW50Py5kYXRhKVxuXG4gICAgaWYgKGV2ZW50RGF0YS50eXBlID09PSAnbGl2ZVByZXZpZXcnKSB7XG4gICAgICBjb25zdCBtZXJnZWREYXRhID0gYXdhaXQgbWVyZ2VEYXRhPFQ+KHtcbiAgICAgICAgZGVwdGgsXG4gICAgICAgIGZpZWxkU2NoZW1hOiBldmVudERhdGEuZmllbGRTY2hlbWFKU09OLFxuICAgICAgICBpbmNvbWluZ0RhdGE6IGV2ZW50RGF0YS5kYXRhLFxuICAgICAgICBpbml0aWFsRGF0YSxcbiAgICAgICAgc2VydmVyVVJMLFxuICAgICAgfSlcblxuICAgICAgcmV0dXJuIG1lcmdlZERhdGFcbiAgICB9XG4gIH1cblxuICByZXR1cm4gaW5pdGlhbERhdGFcbn1cbiJdLCJuYW1lcyI6WyJoYW5kbGVNZXNzYWdlIiwiYXJncyIsImRlcHRoIiwiZXZlbnQiLCJpbml0aWFsRGF0YSIsInNlcnZlclVSTCIsIm9yaWdpbiIsImRhdGEiLCJldmVudERhdGEiLCJKU09OIiwicGFyc2UiLCJ0eXBlIiwibWVyZ2VkRGF0YSIsIm1lcmdlRGF0YSIsImZpZWxkU2NoZW1hIiwiZmllbGRTY2hlbWFKU09OIiwiaW5jb21pbmdEYXRhIl0sIm1hcHBpbmdzIjoiOzs7OytCQUVhQTs7O2VBQUFBOzs7a0JBRmE7QUFFbkIsTUFBTUEsZ0JBQWdCLE9BQVVDO0lBTXJDLE1BQU0sRUFBRUMsS0FBSyxFQUFFQyxLQUFLLEVBQUVDLFdBQVcsRUFBRUMsU0FBUyxFQUFFLEdBQUdKO0lBRWpELElBQUlFLE1BQU1HLE1BQU0sS0FBS0QsYUFBYUYsTUFBTUksSUFBSSxFQUFFO1FBQzVDLE1BQU1DLFlBQVlDLEtBQUtDLEtBQUssQ0FBQ1AsT0FBT0k7UUFFcEMsSUFBSUMsVUFBVUcsSUFBSSxLQUFLLGVBQWU7WUFDcEMsTUFBTUMsYUFBYSxNQUFNQyxJQUFBQSxXQUFTLEVBQUk7Z0JBQ3BDWDtnQkFDQVksYUFBYU4sVUFBVU8sZUFBZTtnQkFDdENDLGNBQWNSLFVBQVVELElBQUk7Z0JBQzVCSDtnQkFDQUM7WUFDRjtZQUVBLE9BQU9PO1FBQ1Q7SUFDRjtJQUVBLE9BQU9SO0FBQ1QifQ== | ||
//# sourceMappingURL=handleMessage.js.map |
@@ -1,5 +0,6 @@ | ||
export { handleMessage } from './handleMessage'; | ||
export { mergeData } from './mergeData'; | ||
export { subscribe } from './subscribe'; | ||
export { unsubscribe } from './unsubscribe'; | ||
export { handleMessage } from './handleMessage.js'; | ||
export { mergeData } from './mergeData.js'; | ||
export { ready } from './ready.js'; | ||
export { subscribe } from './subscribe.js'; | ||
export { unsubscribe } from './unsubscribe.js'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,30 +0,7 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
function _export(target, all) { | ||
for(var name in all)Object.defineProperty(target, name, { | ||
enumerable: true, | ||
get: all[name] | ||
}); | ||
} | ||
_export(exports, { | ||
handleMessage: function() { | ||
return _handleMessage.handleMessage; | ||
}, | ||
mergeData: function() { | ||
return _mergeData.mergeData; | ||
}, | ||
subscribe: function() { | ||
return _subscribe.subscribe; | ||
}, | ||
unsubscribe: function() { | ||
return _unsubscribe.unsubscribe; | ||
} | ||
}); | ||
const _handleMessage = require("./handleMessage"); | ||
const _mergeData = require("./mergeData"); | ||
const _subscribe = require("./subscribe"); | ||
const _unsubscribe = require("./unsubscribe"); | ||
export { handleMessage } from './handleMessage.js'; | ||
export { mergeData } from './mergeData.js'; | ||
export { ready } from './ready.js'; | ||
export { subscribe } from './subscribe.js'; | ||
export { unsubscribe } from './unsubscribe.js'; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgeyBoYW5kbGVNZXNzYWdlIH0gZnJvbSAnLi9oYW5kbGVNZXNzYWdlJ1xuZXhwb3J0IHsgbWVyZ2VEYXRhIH0gZnJvbSAnLi9tZXJnZURhdGEnXG5leHBvcnQgeyBzdWJzY3JpYmUgfSBmcm9tICcuL3N1YnNjcmliZSdcbmV4cG9ydCB7IHVuc3Vic2NyaWJlIH0gZnJvbSAnLi91bnN1YnNjcmliZSdcbiJdLCJuYW1lcyI6WyJoYW5kbGVNZXNzYWdlIiwibWVyZ2VEYXRhIiwic3Vic2NyaWJlIiwidW5zdWJzY3JpYmUiXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7O0lBQVNBLGFBQWE7ZUFBYkEsNEJBQWE7O0lBQ2JDLFNBQVM7ZUFBVEEsb0JBQVM7O0lBQ1RDLFNBQVM7ZUFBVEEsb0JBQVM7O0lBQ1RDLFdBQVc7ZUFBWEEsd0JBQVc7OzsrQkFIVTsyQkFDSjsyQkFDQTs2QkFDRSJ9 | ||
//# sourceMappingURL=index.js.map |
@@ -1,10 +0,20 @@ | ||
export type MergeLiveDataArgs<T> = { | ||
import type { fieldSchemaToJSON } from 'payload/utilities'; | ||
import type { UpdatedDocument } from './types.js'; | ||
export declare const mergeData: <T>(args: { | ||
apiRoute?: string; | ||
depth: number; | ||
fieldSchema: Record<string, unknown>[]; | ||
incomingData: T; | ||
collectionPopulationRequestHandler?: ({ apiPath, endpoint, serverURL, }: { | ||
apiPath: string; | ||
endpoint: string; | ||
serverURL: string; | ||
}) => Promise<Response>; | ||
depth?: number; | ||
externallyUpdatedRelationship?: UpdatedDocument; | ||
fieldSchema: ReturnType<typeof fieldSchemaToJSON>; | ||
incomingData: Partial<T>; | ||
initialData: T; | ||
returnNumberOfRequests?: boolean; | ||
serverURL: string; | ||
}; | ||
export declare const mergeData: <T>({ apiRoute, depth, fieldSchema, incomingData, initialData, serverURL, }: MergeLiveDataArgs<T>) => Promise<T>; | ||
}) => Promise<T & { | ||
_numberOfRequests?: number; | ||
}>; | ||
//# sourceMappingURL=mergeData.d.ts.map |
@@ -1,30 +0,56 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "mergeData", { | ||
enumerable: true, | ||
get: function() { | ||
return mergeData; | ||
} | ||
}); | ||
const _traverseFields = require("./traverseFields"); | ||
const mergeData = async ({ apiRoute, depth, fieldSchema, incomingData, initialData, serverURL })=>{ | ||
import { traverseFields } from './traverseFields.js'; | ||
const defaultRequestHandler = ({ apiPath, endpoint, serverURL })=>{ | ||
const url = `${serverURL}${apiPath}/${endpoint}`; | ||
return fetch(url, { | ||
credentials: 'include', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
} | ||
}); | ||
}; | ||
export const mergeData = async (args)=>{ | ||
const { apiRoute, depth, externallyUpdatedRelationship, fieldSchema, incomingData, initialData, returnNumberOfRequests, serverURL } = args; | ||
const result = { | ||
...initialData | ||
}; | ||
const populationPromises = []; | ||
(0, _traverseFields.traverseFields)({ | ||
apiRoute, | ||
depth, | ||
const populationsByCollection = {}; | ||
traverseFields({ | ||
externallyUpdatedRelationship, | ||
fieldSchema, | ||
incomingData, | ||
populationPromises, | ||
result, | ||
serverURL | ||
populationsByCollection, | ||
result | ||
}); | ||
await Promise.all(populationPromises); | ||
return result; | ||
await Promise.all(Object.entries(populationsByCollection).map(async ([collection, populations])=>{ | ||
let res; | ||
const ids = new Set(populations.map(({ id })=>id)); | ||
const requestHandler = args.collectionPopulationRequestHandler || defaultRequestHandler; | ||
try { | ||
res = await requestHandler({ | ||
apiPath: apiRoute || '/api', | ||
endpoint: `${collection}?depth=${depth}&where[id][in]=${Array.from(ids).join(',')}`, | ||
serverURL | ||
}).then((res)=>res.json()); | ||
if (res?.docs?.length > 0) { | ||
res.docs.forEach((doc)=>{ | ||
populationsByCollection[collection].forEach((population)=>{ | ||
if (population.id === doc.id) { | ||
population.ref[population.accessor] = doc; | ||
} | ||
}); | ||
}); | ||
} | ||
} catch (err) { | ||
console.error(err) // eslint-disable-line no-console | ||
; | ||
} | ||
})); | ||
return { | ||
...result, | ||
...returnNumberOfRequests ? { | ||
_numberOfRequests: Object.keys(populationsByCollection).length | ||
} : {} | ||
}; | ||
}; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9tZXJnZURhdGEudHMiXSwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgdHJh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WlzZXMiLCJ0cmF2ZXJzZUZpZWxkcyIsIlByb21pc2UiLCJhbGwiXSwibWFwcGluZ3MiOiI7Ozs7K0JBV2FBOzs7ZUFBQUE7OztnQ0FYa0I7QUFXeEIsTUFBTUEsWUFBWSxPQUFVLEVBQ2pDQyxRQUFRLEVBQ1JDLEtBQUssRUFDTEMsV0FBVyxFQUNYQyxZQUFZLEVBQ1pDLFdBQVcsRUFDWEMsU0FBUyxFQUNZO0lBQ3JCLE1BQU1DLFNBQVM7UUFBRSxHQUFHRixXQUFXO0lBQUM7SUFFaEMsTUFBTUcscUJBQXNDLEVBQUU7SUFFOUNDLElBQUFBLDhCQUFjLEVBQUM7UUFDYlI7UUFDQUM7UUFDQUM7UUFDQUM7UUFDQUk7UUFDQUQ7UUFDQUQ7SUFDRjtJQUVBLE1BQU1JLFFBQVFDLEdBQUcsQ0FBQ0g7SUFFbEIsT0FBT0Q7QUFDVCJ9 | ||
//# sourceMappingURL=mergeData.js.map |
export declare const subscribe: <T>(args: { | ||
apiRoute?: string; | ||
callback: (data: T) => void; | ||
depth: number; | ||
depth?: number; | ||
initialData: T; | ||
serverURL: string; | ||
}) => (event: MessageEvent) => void; | ||
}) => ((event: MessageEvent) => void); | ||
//# sourceMappingURL=subscribe.d.ts.map |
@@ -1,30 +0,20 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "subscribe", { | ||
enumerable: true, | ||
get: function() { | ||
return subscribe; | ||
} | ||
}); | ||
const _ = require("."); | ||
const subscribe = (args)=>{ | ||
const { callback, depth, initialData, serverURL } = args; | ||
import { handleMessage } from './handleMessage.js'; | ||
export const subscribe = (args)=>{ | ||
const { apiRoute, callback, depth, initialData, serverURL } = args; | ||
const onMessage = async (event)=>{ | ||
const mergedData = await handleMessage({ | ||
apiRoute, | ||
depth, | ||
event, | ||
initialData, | ||
serverURL | ||
}); | ||
callback(mergedData); | ||
}; | ||
if (typeof window !== 'undefined') { | ||
const handleMessageCallback = async (event)=>{ | ||
const mergedData = await (0, _.handleMessage)({ | ||
depth, | ||
event, | ||
initialData, | ||
serverURL | ||
}); | ||
callback(mergedData); | ||
}; | ||
window.addEventListener('message', handleMessageCallback); | ||
window.parent.postMessage('ready', serverURL); | ||
return handleMessageCallback; | ||
window.addEventListener('message', onMessage); | ||
} | ||
return onMessage; | ||
}; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9zdWJzY3JpYmUudHMiXSwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgaGFuZGxlTWVzc2FnZSB9IGZyb20gJy4nXG5cbmV4cG9ydCBjb25zdCBzdWJzY3JpYmUgPSA8VD4oYXJnczoge1xuICBjYWxsYmFjazogKGRhdGE6IFQpID0+IHZvaWRcbiAgZGVwdGg6IG51bWJlclxuICBpbml0aWFsRGF0YTogVFxuICBzZXJ2ZXJVUkw6IHN0cmluZ1xufSk6ICgoZXZlbnQ6IE1lc3NhZ2VFdmVudCkgPT4gdm9pZCkgPT4ge1xuICBjb25zdCB7IGNhbGxiYWNrLCBkZXB0aCwgaW5pdGlhbERhdGEsIHNlcnZlclVSTCB9ID0gYXJnc1xuXG4gIGlmICh0eXBlb2Ygd2luZG93ICE9PSAndW5kZWZpbmVkJykge1xuICAgIGNvbnN0IGhhbmRsZU1lc3NhZ2VDYWxsYmFjayA9IGFzeW5jIChldmVudDogTWVzc2FnZUV2ZW50KSA9PiB7XG4gICAgICBjb25zdCBtZXJnZWREYXRhID0gYXdhaXQgaGFuZGxlTWVzc2FnZSh7IGRlcHRoLCBldmVudCwgaW5pdGlhbERhdGEsIHNlcnZlclVSTCB9KVxuICAgICAgY2FsbGJhY2sobWVyZ2VkRGF0YSlcbiAgICB9XG5cbiAgICB3aW5kb3cuYWRkRXZlbnRMaXN0ZW5lcignbWVzc2FnZScsIGhhbmRsZU1lc3NhZ2VDYWxsYmFjaylcbiAgICB3aW5kb3cucGFyZW50LnBvc3RNZXNzYWdlKCdyZWFkeScsIHNlcnZlclVSTClcblxuICAgIHJldHVybiBoYW5kbGVNZXNzYWdlQ2FsbGJhY2tcbiAgfVxufVxuIl0sIm5hbWVzIjpbInN1YnNjcmliZSIsImFyZ3MiLCJjYWxsYmFjayIsImRlcHRoIiwiaW5pdGlhbERhdGEiLCJzZXJ2ZXJVUkwiLCJ3aW5kb3ciLCJoYW5kbGVNZXNzYWdlQ2FsbGJhY2siLCJldmVudCIsIm1lcmdlZERhdGEiLCJoYW5kbGVNZXNzYWdlIiwiYWRkRXZlbnRMaXN0ZW5lciIsInBhcmVudCIsInBvc3RNZXNzYWdlIl0sIm1hcHBpbmdzIjoiOzs7OytCQUVhQTs7O2VBQUFBOzs7a0JBRmlCO0FBRXZCLE1BQU1BLFlBQVksQ0FBSUM7SUFNM0IsTUFBTSxFQUFFQyxRQUFRLEVBQUVDLEtBQUssRUFBRUMsV0FBVyxFQUFFQyxTQUFTLEVBQUUsR0FBR0o7SUFFcEQsSUFBSSxPQUFPSyxXQUFXLGFBQWE7UUFDakMsTUFBTUMsd0JBQXdCLE9BQU9DO1lBQ25DLE1BQU1DLGFBQWEsTUFBTUMsSUFBQUEsZUFBYSxFQUFDO2dCQUFFUDtnQkFBT0s7Z0JBQU9KO2dCQUFhQztZQUFVO1lBQzlFSCxTQUFTTztRQUNYO1FBRUFILE9BQU9LLGdCQUFnQixDQUFDLFdBQVdKO1FBQ25DRCxPQUFPTSxNQUFNLENBQUNDLFdBQVcsQ0FBQyxTQUFTUjtRQUVuQyxPQUFPRTtJQUNUO0FBQ0YifQ== | ||
//# sourceMappingURL=subscribe.js.map |
@@ -1,12 +0,10 @@ | ||
type Args<T> = { | ||
apiRoute?: string; | ||
depth: number; | ||
fieldSchema: Record<string, unknown>[]; | ||
import type { fieldSchemaToJSON } from 'payload/utilities'; | ||
import type { PopulationsByCollection, UpdatedDocument } from './types.js'; | ||
export declare const traverseFields: <T>(args: { | ||
externallyUpdatedRelationship?: UpdatedDocument; | ||
fieldSchema: ReturnType<typeof fieldSchemaToJSON>; | ||
incomingData: T; | ||
populationPromises: Promise<void>[]; | ||
populationsByCollection: PopulationsByCollection; | ||
result: T; | ||
serverURL: string; | ||
}; | ||
export declare const traverseFields: <T>({ apiRoute, depth, fieldSchema, incomingData, populationPromises, result, serverURL, }: Args<T>) => void; | ||
export {}; | ||
}) => void; | ||
//# sourceMappingURL=traverseFields.d.ts.map |
@@ -1,35 +0,33 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "traverseFields", { | ||
enumerable: true, | ||
get: function() { | ||
return traverseFields; | ||
} | ||
}); | ||
const _promise = require("./promise"); | ||
const traverseFields = ({ apiRoute, depth, fieldSchema, incomingData, populationPromises, result, serverURL })=>{ | ||
fieldSchema.forEach((field)=>{ | ||
if ('name' in field && typeof field.name === 'string') { | ||
// TODO: type this | ||
const fieldName = field.name; | ||
switch(field.type){ | ||
import { traverseRichText } from './traverseRichText.js'; | ||
export const traverseFields = (args)=>{ | ||
const { externallyUpdatedRelationship, fieldSchema: fieldSchemas, incomingData, populationsByCollection, result } = args; | ||
fieldSchemas.forEach((fieldSchema)=>{ | ||
if ('name' in fieldSchema && typeof fieldSchema.name === 'string') { | ||
const fieldName = fieldSchema.name; | ||
switch(fieldSchema.type){ | ||
case 'richText': | ||
result[fieldName] = traverseRichText({ | ||
externallyUpdatedRelationship, | ||
incomingData: incomingData[fieldName], | ||
populationsByCollection, | ||
result: result[fieldName] | ||
}); | ||
break; | ||
case 'array': | ||
if (Array.isArray(incomingData[fieldName])) { | ||
result[fieldName] = incomingData[fieldName].map((row, i)=>{ | ||
const hasExistingRow = Array.isArray(result[fieldName]) && typeof result[fieldName][i] === 'object' && result[fieldName][i] !== null; | ||
const newRow = hasExistingRow ? { | ||
...result[fieldName][i] | ||
} : {}; | ||
result[fieldName] = incomingData[fieldName].map((incomingRow, i)=>{ | ||
if (!result[fieldName]) { | ||
result[fieldName] = []; | ||
} | ||
if (!result[fieldName][i]) { | ||
result[fieldName][i] = {}; | ||
} | ||
traverseFields({ | ||
apiRoute, | ||
depth, | ||
fieldSchema: field.fields, | ||
incomingData: row, | ||
populationPromises, | ||
result: newRow, | ||
serverURL | ||
externallyUpdatedRelationship, | ||
fieldSchema: fieldSchema.fields, | ||
incomingData: incomingRow, | ||
populationsByCollection, | ||
result: result[fieldName][i] | ||
}); | ||
return newRow; | ||
return result[fieldName][i]; | ||
}); | ||
@@ -40,24 +38,26 @@ } | ||
if (Array.isArray(incomingData[fieldName])) { | ||
result[fieldName] = incomingData[fieldName].map((row, i)=>{ | ||
const matchedBlock = field.blocks[row.blockType]; | ||
const hasExistingRow = Array.isArray(result[fieldName]) && typeof result[fieldName][i] === 'object' && result[fieldName][i] !== null && result[fieldName][i].blockType === row.blockType; | ||
const newRow = hasExistingRow ? { | ||
...result[fieldName][i] | ||
} : { | ||
blockType: matchedBlock.slug | ||
}; | ||
result[fieldName] = incomingData[fieldName].map((incomingBlock, i)=>{ | ||
const incomingBlockJSON = fieldSchema.blocks[incomingBlock.blockType]; | ||
if (!result[fieldName]) { | ||
result[fieldName] = []; | ||
} | ||
if (!result[fieldName][i] || result[fieldName][i].id !== incomingBlock.id || result[fieldName][i].blockType !== incomingBlock.blockType) { | ||
result[fieldName][i] = { | ||
blockType: incomingBlock.blockType | ||
}; | ||
} | ||
traverseFields({ | ||
apiRoute, | ||
depth, | ||
fieldSchema: matchedBlock.fields, | ||
incomingData: row, | ||
populationPromises, | ||
result: newRow, | ||
serverURL | ||
externallyUpdatedRelationship, | ||
fieldSchema: incomingBlockJSON.fields, | ||
incomingData: incomingBlock, | ||
populationsByCollection, | ||
result: result[fieldName][i] | ||
}); | ||
return newRow; | ||
return result[fieldName][i]; | ||
}); | ||
} else { | ||
result[fieldName] = []; | ||
} | ||
break; | ||
case 'tab': | ||
case 'tabs': | ||
case 'group': | ||
@@ -68,9 +68,7 @@ if (!result[fieldName]) { | ||
traverseFields({ | ||
apiRoute, | ||
depth, | ||
fieldSchema: field.fields, | ||
externallyUpdatedRelationship, | ||
fieldSchema: fieldSchema.fields, | ||
incomingData: incomingData[fieldName] || {}, | ||
populationPromises, | ||
result: result[fieldName], | ||
serverURL | ||
populationsByCollection, | ||
result: result[fieldName] | ||
}); | ||
@@ -80,40 +78,46 @@ break; | ||
case 'relationship': | ||
if (field.hasMany && Array.isArray(incomingData[fieldName])) { | ||
const existingValue = Array.isArray(result[fieldName]) ? [ | ||
...result[fieldName] | ||
] : []; | ||
result[fieldName] = Array.isArray(result[fieldName]) ? [ | ||
...result[fieldName] | ||
].slice(0, incomingData[fieldName].length) : []; | ||
incomingData[fieldName].forEach((relation, i)=>{ | ||
// Handle `hasMany` relationships | ||
if (fieldSchema.hasMany && Array.isArray(incomingData[fieldName])) { | ||
if (!result[fieldName] || !incomingData[fieldName].length) { | ||
result[fieldName] = []; | ||
} | ||
incomingData[fieldName].forEach((incomingRelation, i)=>{ | ||
// Handle `hasMany` polymorphic | ||
if (Array.isArray(field.relationTo)) { | ||
const existingID = existingValue[i]?.value?.id; | ||
if (existingID !== relation.value || existingValue[i]?.relationTo !== relation.relationTo) { | ||
if (Array.isArray(fieldSchema.relationTo)) { | ||
// if the field doesn't exist on the result, create it | ||
// the value will be populated later | ||
if (!result[fieldName][i]) { | ||
result[fieldName][i] = { | ||
relationTo: relation.relationTo | ||
relationTo: incomingRelation.relationTo | ||
}; | ||
populationPromises.push((0, _promise.promise)({ | ||
id: relation.value, | ||
} | ||
const oldID = result[fieldName][i]?.value?.id; | ||
const oldRelation = result[fieldName][i]?.relationTo; | ||
const newID = incomingRelation.value; | ||
const newRelation = incomingRelation.relationTo; | ||
const hasChanged = newID !== oldID || newRelation !== oldRelation; | ||
const hasUpdated = newRelation === externallyUpdatedRelationship?.entitySlug && newID === externallyUpdatedRelationship?.id; | ||
if (hasChanged || hasUpdated) { | ||
if (!populationsByCollection[newRelation]) { | ||
populationsByCollection[newRelation] = []; | ||
} | ||
populationsByCollection[newRelation].push({ | ||
id: incomingRelation.value, | ||
accessor: 'value', | ||
apiRoute, | ||
collection: relation.relationTo, | ||
depth, | ||
ref: result[fieldName][i], | ||
serverURL | ||
})); | ||
ref: result[fieldName][i] | ||
}); | ||
} | ||
} else { | ||
// Handle `hasMany` singular | ||
const existingID = existingValue[i]?.id; | ||
if (existingID !== relation) { | ||
populationPromises.push((0, _promise.promise)({ | ||
id: relation, | ||
// Handle `hasMany` monomorphic | ||
const hasChanged = incomingRelation !== result[fieldName][i]?.id; | ||
const hasUpdated = fieldSchema.relationTo === externallyUpdatedRelationship?.entitySlug && incomingRelation === externallyUpdatedRelationship?.id; | ||
if (hasChanged || hasUpdated) { | ||
if (!populationsByCollection[fieldSchema.relationTo]) { | ||
populationsByCollection[fieldSchema.relationTo] = []; | ||
} | ||
populationsByCollection[fieldSchema.relationTo].push({ | ||
id: incomingRelation, | ||
accessor: i, | ||
apiRoute, | ||
collection: String(field.relationTo), | ||
depth, | ||
ref: result[fieldName], | ||
serverURL | ||
})); | ||
ref: result[fieldName] | ||
}); | ||
} | ||
@@ -124,48 +128,59 @@ } | ||
// Handle `hasOne` polymorphic | ||
if (Array.isArray(field.relationTo)) { | ||
const hasNewValue = typeof incomingData[fieldName] === 'object' && incomingData[fieldName] !== null; | ||
const hasOldValue = typeof result[fieldName] === 'object' && result[fieldName] !== null; | ||
const newValue = hasNewValue ? incomingData[fieldName].value : ''; | ||
if (Array.isArray(fieldSchema.relationTo)) { | ||
// if the field doesn't exist on the result, create it | ||
// the value will be populated later | ||
if (!result[fieldName]) { | ||
result[fieldName] = { | ||
relationTo: incomingData[fieldName]?.relationTo | ||
}; | ||
} | ||
const hasNewValue = incomingData[fieldName] && typeof incomingData[fieldName] === 'object' && incomingData[fieldName] !== null; | ||
const hasOldValue = result[fieldName] && typeof result[fieldName] === 'object' && result[fieldName] !== null; | ||
const newID = hasNewValue ? typeof incomingData[fieldName].value === 'object' ? incomingData[fieldName].value.id : incomingData[fieldName].value : ''; | ||
const oldID = hasOldValue ? typeof result[fieldName].value === 'object' ? result[fieldName].value.id : result[fieldName].value : ''; | ||
const newRelation = hasNewValue ? incomingData[fieldName].relationTo : ''; | ||
const oldValue = hasOldValue ? result[fieldName].value : ''; | ||
const oldRelation = hasOldValue ? result[fieldName].relationTo : ''; | ||
if (newValue !== oldValue || newRelation !== oldRelation) { | ||
if (newValue) { | ||
if (!result[fieldName]) { | ||
result[fieldName] = { | ||
relationTo: newRelation | ||
}; | ||
const hasChanged = newID !== oldID || newRelation !== oldRelation; | ||
const hasUpdated = newRelation === externallyUpdatedRelationship?.entitySlug && newID === externallyUpdatedRelationship?.id; | ||
// if the new value/relation is different from the old value/relation | ||
// populate the new value, otherwise leave it alone | ||
if (hasChanged || hasUpdated) { | ||
// if the new value is not empty, populate it | ||
// otherwise set the value to null | ||
if (newID) { | ||
if (!populationsByCollection[newRelation]) { | ||
populationsByCollection[newRelation] = []; | ||
} | ||
populationPromises.push((0, _promise.promise)({ | ||
id: newValue, | ||
populationsByCollection[newRelation].push({ | ||
id: newID, | ||
accessor: 'value', | ||
apiRoute, | ||
collection: newRelation, | ||
depth, | ||
ref: result[fieldName], | ||
serverURL | ||
})); | ||
ref: result[fieldName] | ||
}); | ||
} else { | ||
result[fieldName] = null; | ||
} | ||
} else { | ||
result[fieldName] = null; | ||
} | ||
} else { | ||
const hasNewValue = typeof incomingData[fieldName] === 'object' && incomingData[fieldName] !== null; | ||
const hasOldValue = typeof result[fieldName] === 'object' && result[fieldName] !== null; | ||
const newValue = hasNewValue ? incomingData[fieldName].value : ''; | ||
const oldValue = hasOldValue ? result[fieldName].value : ''; | ||
if (newValue !== oldValue) { | ||
if (newValue) { | ||
populationPromises.push((0, _promise.promise)({ | ||
id: newValue, | ||
// Handle `hasOne` monomorphic | ||
const newID = incomingData[fieldName] && typeof incomingData[fieldName] === 'object' && incomingData[fieldName].id || incomingData[fieldName]; | ||
const oldID = result[fieldName] && typeof result[fieldName] === 'object' && result[fieldName].id || result[fieldName]; | ||
const hasChanged = newID !== oldID; | ||
const hasUpdated = fieldSchema.relationTo === externallyUpdatedRelationship?.entitySlug && newID === externallyUpdatedRelationship?.id; | ||
// if the new value is different from the old value | ||
// populate the new value, otherwise leave it alone | ||
if (hasChanged || hasUpdated) { | ||
// if the new value is not empty, populate it | ||
// otherwise set the value to null | ||
if (newID) { | ||
if (!populationsByCollection[fieldSchema.relationTo]) { | ||
populationsByCollection[fieldSchema.relationTo] = []; | ||
} | ||
populationsByCollection[fieldSchema.relationTo].push({ | ||
id: newID, | ||
accessor: fieldName, | ||
apiRoute, | ||
collection: String(field.relationTo), | ||
depth, | ||
ref: result, | ||
serverURL | ||
})); | ||
ref: result | ||
}); | ||
} else { | ||
result[fieldName] = null; | ||
} | ||
} else { | ||
result[fieldName] = null; | ||
} | ||
@@ -180,5 +195,4 @@ } | ||
}); | ||
return null; | ||
}; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy90cmF2ZXJzZUZpZWxkcy50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBwcm9taXNlIH0gZnJvbSAnLi9wcm9taXNlJ1xuXG50eXBlIEFyZ3M8VD4gPSB7XG4gIGFwaVJvdXRlPzogc3RyaW5nXG4gIGRlcHRoOiBudW1iZXJcbiAgZmllbGRTY2hlbWE6IFJlY29yZDxzdHJpbmcsIHVua25vd24+W11cbiAgaW5jb21pbmdEYXRhOiBUXG4gIHBvcHVsYXRpb25Qcm9taXNlczogUHJvbWlzZTx2b2lkPltdXG4gIHJlc3VsdDogVFxuICBzZXJ2ZXJVUkw6IHN0cmluZ1xufVxuXG5leHBvcnQgY29uc3QgdHJhdmVyc2VGaWVsZHMgPSA8VD4oe1xuICBhcGlSb3V0ZSxcbiAgZGVwdGgsXG4gIGZpZWxkU2NoZW1hLFxuICBpbmNvbWluZ0RhdGEsXG4gIHBvcHVsY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93bj5bXSwgLy8gVE9ETzogdHlwZSB0aGlzXG4gICAgICAgICAgICAgICAgaW5jb21pbmdEYXRhOiByb3csXG4gICAgICAgICAgICAgICAgcG9wdWxhdGlvblByb21pc2VzLFxuICAgICAgICAgICAgICAgIHJlc3VsdDogbmV3Um93LFxuICAgICAgICAgICAgICAgIHNlcnZlclVSTCxcbiAgICAgICAgICAgICAgfSlcblxuICAgICAgICAgICAgICByZXR1cm4gbmV3Um93XG4gICAgICAgICAgICB9KVxuICAgICAgICAgIH1cbiAgICAgICAgICBicmVha1xuXG4gICAgICAgIGNhc2UgJ2Jsb2Nrcyc6XG4gICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkoaW5jb21pbmdEYXRhW2ZpZWxkTmFtZV0pKSB7XG4gICAgICAgICAgICByZXN1bHRbZmllbGROYW1lXSA9IGluY29taW5nRGF0YVtmaWVsZE5hbWVdLm1hcCgocm93LCBpKSA9PiB7XG4gICAgICAgICAgICAgIGNvbnN0IG1hdGNoZWRCbG9jayA9IGZpZWxkLmJsb2Nrc1tyb3cuYmxvY2tUeXBlXVxuXG4gICAgICAgICAgICAgIGNvbnN0IGhhc0V4aXN0aW5nUm93ID1cbiAgICAgICAgICAgICAgICBBcnJheS5pc0FycmF5KHJlc3VsdFtmaWVsZE5hbWVdKSAmJlxuICAgICAgICAgICAgICAgIHR5cGVvZiByZXN1bHRbZmllbGROYW1lXVtpXSA9PT0gJ29iamVjdCcgJiZcbiAgICAgICAgICAgICAgICByZXN1bHRbZmllbGROYW1lXVtpXSAhPT0gbnVsbCAmJlxuICAgICAgICAgICAgICAgIHJlc3VsdFtmaWVsZE5hbWVdW2ldLmJsb2NrVHlwZSA9PT0gcm93LmJsb2NrVHlwZVxuXG4gICAgICAgICAgICAgIGNvbnN0IG5ld1JvdyA9IGhhc0V4aXN0aW5nUm93XG4gICAgICAgICAgICAgICAgPyB7IC4uLnJlc3VsdFtmaWVsZE5hbWVdW2ldIH1cbiAgICAgICAgICAgICAgICA6IHtcbiAgICAgICAgICAgICAgICAgICAgYmxvY2tUeXBlOiBtYXRjaGVkQmxvY2suc2x1ZyxcbiAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICB0cmF2ZXJzZUZpZWxkcyh7XG4gICAgICAgICAgICAgICAgYXBpUm91dGUsXG4gICAgICAgICAgICAgICAgZGVwdGgsXG4gICAgICAgICAgICAgICAgZmllbGRTY2hlbWE6IG1hdGNoZWRCbG9jay5maWVsZHMgYXMgUmVjb3JkPHN0cmluZywgdW5rbm93bj5bXSwgLy8gVE9ETzogdHlwZSB0aGlzXG4gICAgICAgICAgICAgICAgaW5jb21pbmdEYXRhOiByb3csXG4gICAgICAgICAgICAgICAgcG9wdWxhdGlvblByb21pc2VzLFxuICAgICAgICAgICAgICAgIHJlc3VsdDogbmV3Um93LFxuICAgICAgICAgICAgICAgIHNlcnZlclVSTCxcbiAgICAgICAgICAgICAgfSlcblxuICAgICAgICAgICAgICByZXR1cm4gbmV3Um93XG4gICAgICAgICAgICB9KVxuICAgICAgICAgIH1cbiAgICAgICAgICBicmVha1xuXG4gICAgICAgIGNhc2UgJ3RhYic6XG4gICAgICAgIGNhc2UgJ2dyb3VwJzpcbiAgICAgICAgICBpZiAoIXJlc3VsdFtmaWVsZE5hbWVdKSB7XG4gICAgICAgICAgICByZXN1bHRbZmllbGROYW1lXSA9IHt9XG4gICAgICAgICAgfVxuXG4gICAgICAgICAgdHJhdmVyc2VGaWVsZHMoe1xuICAgICAgICAgICAgYXBpUm91dGUsXG4gICAgICAgICAgICBkZXB0aCxcbiAgICAgICAgICAgIGZpZWxkU2NoZW1hOiBmaWVsZC5maWVsZHMgYXMgUmVjb3JkPHN0cmluZywgdW5rbm93bj5bXSwgLy8gVE9ETzogdHlwZSB0aGlzXG4gICAgICAgICAgICBpbmNvbWluZ0RhdGE6IGluY29taW5nRGF0YVtmaWVsZE5hbWVdIHx8IHt9LFxuICAgICAgICAgICAgcG9wdWxhdGlvblByb21pc2VzLFxuICAgICAgICAgICAgcmVzdWx0OiByZXN1bHRbZmllbGROYW1lXSxcbiAgICAgICAgICAgIHNlcnZlclVSTCxcbiAgICAgICAgICB9KVxuXG4gICAgICAgICAgYnJlYWtcblxuICAgICAgICBjYXNlICd1cGxvYWQnOlxuICAgICAgICBjYXNlICdyZWxhdGlvbnNoaXAnOlxuICAgICAgICAgIGlmIChmaWVsZC5oYXNNYW55ICYmIEFycmF5LmlzQXJyYXkoaW5jb21pbmdEYXRhW2ZpZWxkTmFtZV0pKSB7XG4gICAgICAgICAgICBjb25zdCBleGlzdGluZ1ZhbHVlID0gQXJyYXkuaXNBcnJheShyZXN1bHRbZmllbGROYW1lXSkgPyBbLi4ucmVzdWx0W2ZpZWxkTmFtZV1dIDogW11cbiAgICAgICAgICAgIHJlc3VsdFtmaWVsZE5hbWVdID0gQXJyYXkuaXNBcnJheShyZXN1bHRbZmllbGROYW1lXSlcbiAgICAgICAgICAgICAgPyBbLi4ucmVzdWx0W2ZpZWxkTmFtZV1dLnNsaWNlKDAsIGluY29taW5nRGF0YVtmaWVsZE5hbWVdLmxlbmd0aClcbiAgICAgICAgICAgICAgOiBbXVxuXG4gICAgICAgICAgICBpbmNvbWluZ0RhdGFbZmllbGROYW1lXS5mb3JFYWNoKChyZWxhdGlvbiwgaSkgPT4ge1xuICAgICAgICAgICAgICAvLyBIYW5kbGUgYGhhc01hbnlgIHBvbHltb3JwaGljXG4gICAgICAgICAgICAgIGlmIChBcnJheS5pc0FycmF5KGZpZWxkLnJlbGF0aW9uVG8pKSB7XG4gICAgICAgICAgICAgICAgY29uc3QgZXhpc3RpbmdJRCA9IGV4aXN0aW5nVmFsdWVbaV0/LnZhbHVlPy5pZFxuXG4gICAgICAgICAgICAgICAgaWYgKFxuICAgICAgICAgICAgICAgICAgZXhpc3RpbmdJRCAhPT0gcmVsYXRpb24udmFsdWUgfHxcbiAgICAgICAgICAgICAgICAgIGV4aXN0aW5nVmFsdWVbaV0/LnJlbGF0aW9uVG8gIT09IHJlbGF0aW9uLnJlbGF0aW9uVG9cbiAgICAgICAgICAgICAgICApIHtcbiAgICAgICAgICAgICAgICAgIHJlc3VsdFtmaWVsZE5hbWVdW2ldID0ge1xuICAgICAgICAgICAgICAgICAgICByZWxhdGlvblRvOiByZWxhdGlvbi5yZWxhdGlvblRvLFxuICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICBwb3B1bGF0aW9uUHJvbWlzZXMucHVzaChcbiAgICAgICAgICAgICAgICAgICAgcHJvbWlzZSh7XG4gICAgICAgICAgICAgICAgICAgICAgaWQ6IHJlbGF0aW9uLnZhbHVlLFxuICAgICAgICAgICAgICAgICAgICAgIGFjY2Vzc29yOiAndmFsdWUnLFxuICAgICAgICAgICAgICAgICAgICAgIGFwaVJvdXRlLFxuICAgICAgICAgICAgICAgICAgICAgIGNvbGxlY3Rpb246IHJlbGF0aW9uLnJlbGF0aW9uVG8sXG4gICAgICAgICAgICAgICAgICAgICAgZGVwdGgsXG4gICAgICAgICAgICAgICAgICAgICAgcmVmOiByZXN1bHRbZmllbGROYW1lXVtpXSxcbiAgICAgICAgICAgICAgICAgICAgICBzZXJ2ZXJVUkwsXG4gICAgICAgICAgICAgICAgICAgIH0pLFxuICAgICAgICAgICAgICAgICAgKVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAvLyBIYW5kbGUgYGhhc01hbnlgIHNpbmd1bGFyXG4gICAgICAgICAgICAgICAgY29uc3QgZXhpc3RpbmdJRCA9IGV4aXN0aW5nVmFsdWVbaV0/LmlkXG5cbiAgICAgICAgICAgICAgICBpZiAoZXhpc3RpbmdJRCAhPT0gcmVsYXRpb24pIHtcbiAgICAgICAgICAgICAgICAgIHBvcHVsYXRpb25Qcm9taXNlcy5wdXNoKFxuICAgICAgICAgICAgICAgICAgICBwcm9taXNlKHtcbiAgICAgICAgICAgICAgICAgICAgICBpZDogcmVsYXRpb24sXG4gICAgICAgICAgICAgICAgICAgICAgYWNjZXNzb3I6IGksXG4gICAgICAgICAgICAgICAgICAgICAgYXBpUm91dGUsXG4gICAgICAgICAgICAgICAgICAgICAgY29sbGVjdGlvbjogU3RyaW5nKGZpZWxkLnJlbGF0aW9uVG8pLFxuICAgICAgICAgICAgICAgICAgICAgIGRlcHRoLFxuICAgICAgICAgICAgICAgICAgICAgIHJlZjogcmVzdWx0W2ZpZWxkTmFtZV0sXG4gICAgICAgICAgICAgICAgICAgICAgc2VydmVyVVJMLFxuICAgICAgICAgICAgICAgICAgICB9KSxcbiAgICAgICAgICAgICAgICAgIClcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pXG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIC8vIEhhbmRsZSBgaGFzT25lYCBwb2x5bW9ycGhpY1xuICAgICAgICAgICAgaWYgKEFycmF5LmlzQXJyYXkoZmllbGQucmVsYXRpb25UbykpIHtcbiAgICAgICAgICAgICAgY29uc3QgaGFzTmV3VmFsdWUgPVxuICAgICAgICAgICAgICAgIHR5cGVvZiBpbmNvbWluZ0RhdGFbZmllbGROYW1lXSA9PT0gJ29iamVjdCcgJiYgaW5jb21pbmdEYXRhW2ZpZWxkTmFtZV0gIT09IG51bGxcbiAgICAgICAgICAgICAgY29uc3QgaGFzT2xkVmFsdWUgPVxuICAgICAgICAgICAgICAgIHR5cGVvZiByZXN1bHRbZmllbGROYW1lXSA9PT0gJ29iamVjdCcgJiYgcmVzdWx0W2ZpZWxkTmFtZV0gIT09IG51bGxcblxuICAgICAgICAgICAgICBjb25zdCBuZXdWYWx1ZSA9IGhhc05ld1ZhbHVlID8gaW5jb21pbmdEYXRhW2ZpZWxkTmFtZV0udmFsdWUgOiAnJ1xuICAgICAgICAgICAgICBjb25zdCBuZXdSZWxhdGlvbiA9IGhhc05ld1ZhbHVlID8gaW5jb21pbmdEYXRhW2ZpZWxkTmFtZV0ucmVsYXRpb25UbyA6ICcnXG5cbiAgICAgICAgICAgICAgY29uc3Qgb2xkVmFsdWUgPSBoYXNPbGRWYWx1ZSA/IHJlc3VsdFtmaWVsZE5hbWVdLnZhbHVlIDogJydcbiAgICAgICAgICAgICAgY29uc3Qgb2xkUmVsYXRpb24gPSBoYXNPbGRWYWx1ZSA/IHJlc3VsdFtmaWVsZE5hbWVdLnJlbGF0aW9uVG8gOiAnJ1xuXG4gICAgICAgICAgICAgIGlmIChuZXdWYWx1ZSAhPT0gb2xkVmFsdWUgfHwgbmV3UmVsYXRpb24gIT09IG9sZFJlbGF0aW9uKSB7XG4gICAgICAgICAgICAgICAgaWYgKG5ld1ZhbHVlKSB7XG4gICAgICAgICAgICAgICAgICBpZiAoIXJlc3VsdFtmaWVsZE5hbWVdKSB7XG4gICAgICAgICAgICAgICAgICAgIHJlc3VsdFtmaWVsZE5hbWVdID0ge1xuICAgICAgICAgICAgICAgICAgICAgIHJlbGF0aW9uVG86IG5ld1JlbGF0aW9uLFxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgIHBvcHVsYXRpb25Qcm9taXNlcy5wdXNoKFxuICAgICAgICAgICAgICAgICAgICBwcm9taXNlKHtcbiAgICAgICAgICAgICAgICAgICAgICBpZDogbmV3VmFsdWUsXG4gICAgICAgICAgICAgICAgICAgICAgYWNjZXNzb3I6ICd2YWx1ZScsXG4gICAgICAgICAgICAgICAgICAgICAgYXBpUm91dGUsXG4gICAgICAgICAgICAgICAgICAgICAgY29sbGVjdGlvbjogbmV3UmVsYXRpb24sXG4gICAgICAgICAgICAgICAgICAgICAgZGVwdGgsXG4gICAgICAgICAgICAgICAgICAgICAgcmVmOiByZXN1bHRbZmllbGROYW1lXSxcbiAgICAgICAgICAgICAgICAgICAgICBzZXJ2ZXJVUkwsXG4gICAgICAgICAgICAgICAgICAgIH0pLFxuICAgICAgICAgICAgICAgICAgKVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICByZXN1bHRbZmllbGROYW1lXSA9IG51bGxcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgY29uc3QgaGFzTmV3VmFsdWUgPVxuICAgICAgICAgICAgICAgIHR5cGVvZiBpbmNvbWluZ0RhdGFbZmllbGROYW1lXSA9PT0gJ29iamVjdCcgJiYgaW5jb21pbmdEYXRhW2ZpZWxkTmFtZV0gIT09IG51bGxcbiAgICAgICAgICAgICAgY29uc3QgaGFzT2xkVmFsdWUgPVxuICAgICAgICAgICAgICAgIHR5cGVvZiByZXN1bHRbZmllbGROYW1lXSA9PT0gJ29iamVjdCcgJiYgcmVzdWx0W2ZpZWxkTmFtZV0gIT09IG51bGxcblxuICAgICAgICAgICAgICBjb25zdCBuZXdWYWx1ZSA9IGhhc05ld1ZhbHVlID8gaW5jb21pbmdEYXRhW2ZpZWxkTmFtZV0udmFsdWUgOiAnJ1xuXG4gICAgICAgICAgICAgIGNvbnN0IG9sZFZhbHVlID0gaGFzT2xkVmFsdWUgPyByZXN1bHRbZmllbGROYW1lXS52YWx1ZSA6ICcnXG5cbiAgICAgICAgICAgICAgaWYgKG5ld1ZhbHVlICE9PSBvbGRWYWx1ZSkge1xuICAgICAgICAgICAgICAgIGlmIChuZXdWYWx1ZSkge1xuICAgICAgICAgICAgICAgICAgcG9wdWxhdGlvblByb21pc2VzLnB1c2goXG4gICAgICAgICAgICAgICAgICAgIHByb21pc2Uoe1xuICAgICAgICAgICAgICAgICAgICAgIGlkOiBuZXdWYWx1ZSxcbiAgICAgICAgICAgICAgICAgICAgICBhY2Nlc3NvcjogZmllbGROYW1lLFxuICAgICAgICAgICAgICAgICAgICAgIGFwaVJvdXRlLFxuICAgICAgICAgICAgICAgICAgICAgIGNvbGxlY3Rpb246IFN0cmluZyhmaWVsZC5yZWxhdGlvblRvKSxcbiAgICAgICAgICAgICAgICAgICAgICBkZXB0aCxcbiAgICAgICAgICAgICAgICAgICAgICByZWY6IHJlc3VsdCBhcyBSZWNvcmQ8c3RyaW5nLCB1bmtub3duPixcbiAgICAgICAgICAgICAgICAgICAgICBzZXJ2ZXJVUkwsXG4gICAgICAgICAgICAgICAgICAgIH0pLFxuICAgICAgICAgICAgICAgICAgKVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICByZXN1bHRbZmllbGROYW1lXSA9IG51bGxcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cblxuICAgICAgICAgIGJyZWFrXG5cbiAgICAgICAgZGVmYXVsdDpcbiAgICAgICAgICByZXN1bHRbZmllbGROYW1lXSA9IGluY29taW5nRGF0YVtmaWVsZE5hbWVdXG4gICAgICB9XG4gICAgfVxuICB9KVxuXG4gIHJldHVybiBudWxsXG59XG4iXSwibmFtZXMiOlsidHJhdmVyc2VGaWVsZHMiLCJhcGlSb3V0ZSIsImRlcHRoIiwiZmllbGRTY2hlbWEiLCJpbmNvbWluZ0RhdGEiLCJwb3B1bGF0aW9uUHJvbWlzZXMiLCJyZXN1bHQiLCJzZXJ2ZXJVUkwiLCJmb3JFYWNoIiwiZmllbGQiLCJuYW1lIiwiZmllbGROYW1lIiwidHlwZSIsIkFycmF5IiwiaXNBcnJheSIsIm1hcCIsInJvdyIsImkiLCJoYXNFeGlzdGluZ1JvdyIsIm5ld1JvdyIsImZpZWxkcyIsIm1hdGNoZWRCbG9jayIsImJsb2NrcyIsImJsb2NrVHlwZSIsInNsdWciLCJoYXNNYW55IiwiZXhpc3RpbmdWYWx1ZSIsInNsaWNlIiwibGVuZ3RoIiwicmVsYXRpb24iLCJyZWxhdGlvblRvIiwiZXhpc3RpbmdJRCIsInZhbHVlIiwiaWQiLCJwdXNoIiwicHJvbWlzZSIsImFjY2Vzc29yIiwiY29sbGVjdGlvbiIsInJlZiIsIlN0cmluZyIsImhhc05ld1Zhb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FBQ3FCLEtBQUssR0FBRzs0QkFFL0QsTUFBTVksV0FBV0gsY0FBY25DLE1BQU0sQ0FBQ0ssVUFBVSxDQUFDcUIsS0FBSyxHQUFHOzRCQUV6RCxJQUFJVSxhQUFhRSxVQUFVO2dDQUN6QixJQUFJRixVQUFVO29DQUNackMsbUJBQW1CNkIsSUFBSSxDQUNyQkMsSUFBQUEsZ0JBQU8sRUFBQzt3Q0FDTkYsSUFBSVM7d0NBQ0pOLFVBQVV6Qjt3Q0FDVlY7d0NBQ0FvQyxZQUFZRSxPQUFPOUIsTUFBTXFCLFVBQVU7d0NBQ25DNUI7d0NBQ0FvQyxLQUFLaEM7d0NBQ0xDO29DQUNGO2dDQUVKOzRCQUNGLE9BQU87Z0NBQ0xELE1BQU0sQ0FBQ0ssVUFBVSxHQUFHOzRCQUN0Qjt3QkFDRjtvQkFDRjtvQkFFQTtnQkFFRjtvQkFDRUwsTUFBTSxDQUFDSyxVQUFVLEdBQUdQLFlBQVksQ0FBQ08sVUFBVTtZQUMvQztRQUNGO0lBQ0Y7SUFFQSxPQUFPO0FBQ1QifQ== | ||
//# sourceMappingURL=traverseFields.js.map |
export type LivePreviewArgs = {}; | ||
export type LivePreview = void; | ||
export type PopulationsByCollection = { | ||
[slug: string]: Array<{ | ||
accessor: number | string; | ||
id: number | string; | ||
ref: Record<string, unknown>; | ||
}>; | ||
}; | ||
export type UpdatedDocument = { | ||
entitySlug: string; | ||
id?: number | string; | ||
updatedAt: string; | ||
}; | ||
//# sourceMappingURL=types.d.ts.map |
@@ -1,6 +0,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
// TODO: import this from `payload/admin/components/utilities/DocumentEvents/types.ts` | ||
export { }; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9 | ||
//# sourceMappingURL=types.js.map |
@@ -1,12 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "unsubscribe", { | ||
enumerable: true, | ||
get: function() { | ||
return unsubscribe; | ||
} | ||
}); | ||
const unsubscribe = (callback)=>{ | ||
export const unsubscribe = (callback)=>{ | ||
if (typeof window !== 'undefined') { | ||
@@ -17,2 +7,2 @@ window.removeEventListener('message', callback); | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy91bnN1YnNjcmliZS50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgY29uc3QgdW5zdWJzY3JpYmUgPSAoY2FsbGJhY2s6IChldmVudDogTWVzc2FnZUV2ZW50KSA9PiB2b2lkKSA9PiB7XG4gIGlmICh0eXBlb2Ygd2luZG93ICE9PSAndW5kZWZpbmVkJykge1xuICAgIHdpbmRvdy5yZW1vdmVFdmVudExpc3RlbmVyKCdtZXNzYWdlJywgY2FsbGJhY2spXG4gIH1cbn1cbiJdLCJuYW1lcyI6WyJ1bnN1YnNjcmliZSIsImNhbGxiYWNrIiwid2luZG93IiwicmVtb3ZlRXZlbnRMaXN0ZW5lciJdLCJtYXBwaW5ncyI6Ijs7OzsrQkFBYUE7OztlQUFBQTs7O0FBQU4sTUFBTUEsY0FBYyxDQUFDQztJQUMxQixJQUFJLE9BQU9DLFdBQVcsYUFBYTtRQUNqQ0EsT0FBT0MsbUJBQW1CLENBQUMsV0FBV0Y7SUFDeEM7QUFDRiJ9 | ||
//# sourceMappingURL=unsubscribe.js.map |
{ | ||
"name": "@payloadcms/live-preview", | ||
"version": "1.0.0-beta.3", | ||
"version": "3.0.0-beta.16", | ||
"description": "The official live preview JavaScript SDK for Payload", | ||
"repository": "https://github.com/payloadcms/payload", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/payloadcms/payload.git", | ||
"directory": "packages/live-preview" | ||
}, | ||
"license": "MIT", | ||
@@ -11,12 +15,14 @@ "homepage": "https://payloadcms.com", | ||
"types": "./dist/index.d.ts", | ||
"dependencies": { | ||
"react": "18.2.0" | ||
}, | ||
"type": "module", | ||
"devDependencies": { | ||
"@types/node": "20.5.7", | ||
"@types/react": "18.2.15", | ||
"@payloadcms/eslint-config": "0.0.1", | ||
"payload": "2.0.0-beta.30" | ||
"@payloadcms/eslint-config": "3.0.0-beta.16", | ||
"payload": "3.0.0-beta.16" | ||
}, | ||
"exports": null, | ||
"exports": { | ||
".": { | ||
"import": "./dist/index.js", | ||
"require": "./dist/index.js", | ||
"types": "./dist/index.d.ts" | ||
} | ||
}, | ||
"publishConfig": { | ||
@@ -23,0 +29,0 @@ "registry": "https://registry.npmjs.org/" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
62656
0
2
47
470
0
Yes
2
- Removedreact@18.2.0
- Removedjs-tokens@4.0.0(transitive)
- Removedloose-envify@1.4.0(transitive)
- Removedreact@18.2.0(transitive)