@payloadcms/plugin-import-export 3.44.0-canary.7 → 3.44.0-canary.9
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/dist/export/flattenObject.d.ts.map +1 -1
- package/dist/export/flattenObject.js +15 -3
- package/dist/export/flattenObject.js.map +1 -1
- package/dist/export/getCustomFieldFunctions.d.ts.map +1 -1
- package/dist/export/getCustomFieldFunctions.js +27 -11
- package/dist/export/getCustomFieldFunctions.js.map +1 -1
- package/dist/types.d.ts +5 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flattenObject.d.ts","sourceRoot":"","sources":["../../src/export/flattenObject.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhD,KAAK,IAAI,GAAG;IACV,GAAG,EAAE,QAAQ,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;CAC9C,CAAA;AAED,eAAO,MAAM,aAAa,6CAKvB,IAAI,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"flattenObject.d.ts","sourceRoot":"","sources":["../../src/export/flattenObject.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhD,KAAK,IAAI,GAAG;IACV,GAAG,EAAE,QAAQ,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;CAC9C,CAAA;AAED,eAAO,MAAM,aAAa,6CAKvB,IAAI,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CA+F/B,CAAA"}
|
|
@@ -10,13 +10,17 @@ export const flattenObject = ({ doc, fields, prefix, toCSVFunctions })=>{
|
|
|
10
10
|
} else {
|
|
11
11
|
if (toCSVFunctions?.[newKey]) {
|
|
12
12
|
const columnName = `${newKey}_${index}`;
|
|
13
|
-
|
|
13
|
+
const result = toCSVFunctions[newKey]({
|
|
14
14
|
columnName,
|
|
15
|
+
data: row,
|
|
15
16
|
doc,
|
|
16
17
|
row,
|
|
17
18
|
siblingDoc,
|
|
18
19
|
value: item
|
|
19
20
|
});
|
|
21
|
+
if (typeof result !== 'undefined') {
|
|
22
|
+
row[columnName] = result;
|
|
23
|
+
}
|
|
20
24
|
} else {
|
|
21
25
|
row[`${newKey}_${index}`] = item;
|
|
22
26
|
}
|
|
@@ -26,23 +30,31 @@ export const flattenObject = ({ doc, fields, prefix, toCSVFunctions })=>{
|
|
|
26
30
|
if (!toCSVFunctions?.[newKey]) {
|
|
27
31
|
flatten(value, newKey);
|
|
28
32
|
} else {
|
|
29
|
-
|
|
33
|
+
const result = toCSVFunctions[newKey]({
|
|
30
34
|
columnName: newKey,
|
|
35
|
+
data: row,
|
|
31
36
|
doc,
|
|
32
37
|
row,
|
|
33
38
|
siblingDoc,
|
|
34
39
|
value
|
|
35
40
|
});
|
|
41
|
+
if (typeof result !== 'undefined') {
|
|
42
|
+
row[newKey] = result;
|
|
43
|
+
}
|
|
36
44
|
}
|
|
37
45
|
} else {
|
|
38
46
|
if (toCSVFunctions?.[newKey]) {
|
|
39
|
-
|
|
47
|
+
const result = toCSVFunctions[newKey]({
|
|
40
48
|
columnName: newKey,
|
|
49
|
+
data: row,
|
|
41
50
|
doc,
|
|
42
51
|
row,
|
|
43
52
|
siblingDoc,
|
|
44
53
|
value
|
|
45
54
|
});
|
|
55
|
+
if (typeof result !== 'undefined') {
|
|
56
|
+
row[newKey] = result;
|
|
57
|
+
}
|
|
46
58
|
} else {
|
|
47
59
|
row[newKey] = value;
|
|
48
60
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/export/flattenObject.ts"],"sourcesContent":["import type { Document } from 'payload'\n\nimport type { ToCSVFunction } from '../types.js'\n\ntype Args = {\n doc: Document\n fields?: string[]\n prefix?: string\n toCSVFunctions: Record<string, ToCSVFunction>\n}\n\nexport const flattenObject = ({\n doc,\n fields,\n prefix,\n toCSVFunctions,\n}: Args): Record<string, unknown> => {\n const row: Record<string, unknown> = {}\n\n const flatten = (siblingDoc: Document, prefix?: string) => {\n Object.entries(siblingDoc).forEach(([key, value]) => {\n const newKey = prefix ? `${prefix}_${key}` : key\n\n if (Array.isArray(value)) {\n value.forEach((item, index) => {\n if (typeof item === 'object' && item !== null) {\n flatten(item, `${newKey}_${index}`)\n } else {\n if (toCSVFunctions?.[newKey]) {\n const columnName = `${newKey}_${index}`\n
|
|
1
|
+
{"version":3,"sources":["../../src/export/flattenObject.ts"],"sourcesContent":["import type { Document } from 'payload'\n\nimport type { ToCSVFunction } from '../types.js'\n\ntype Args = {\n doc: Document\n fields?: string[]\n prefix?: string\n toCSVFunctions: Record<string, ToCSVFunction>\n}\n\nexport const flattenObject = ({\n doc,\n fields,\n prefix,\n toCSVFunctions,\n}: Args): Record<string, unknown> => {\n const row: Record<string, unknown> = {}\n\n const flatten = (siblingDoc: Document, prefix?: string) => {\n Object.entries(siblingDoc).forEach(([key, value]) => {\n const newKey = prefix ? `${prefix}_${key}` : key\n\n if (Array.isArray(value)) {\n value.forEach((item, index) => {\n if (typeof item === 'object' && item !== null) {\n flatten(item, `${newKey}_${index}`)\n } else {\n if (toCSVFunctions?.[newKey]) {\n const columnName = `${newKey}_${index}`\n const result = toCSVFunctions[newKey]({\n columnName,\n data: row,\n doc,\n row,\n siblingDoc,\n value: item,\n })\n if (typeof result !== 'undefined') {\n row[columnName] = result\n }\n } else {\n row[`${newKey}_${index}`] = item\n }\n }\n })\n } else if (typeof value === 'object' && value !== null) {\n if (!toCSVFunctions?.[newKey]) {\n flatten(value, newKey)\n } else {\n const result = toCSVFunctions[newKey]({\n columnName: newKey,\n data: row,\n doc,\n row,\n siblingDoc,\n value,\n })\n if (typeof result !== 'undefined') {\n row[newKey] = result\n }\n }\n } else {\n if (toCSVFunctions?.[newKey]) {\n const result = toCSVFunctions[newKey]({\n columnName: newKey,\n data: row,\n doc,\n row,\n siblingDoc,\n value,\n })\n if (typeof result !== 'undefined') {\n row[newKey] = result\n }\n } else {\n row[newKey] = value\n }\n }\n })\n }\n\n flatten(doc, prefix)\n\n if (Array.isArray(fields) && fields.length > 0) {\n const orderedResult: Record<string, unknown> = {}\n\n const fieldToRegex = (field: string): RegExp => {\n const parts = field.split('.').map((part) => `${part}(?:_\\\\d+)?`)\n const pattern = `^${parts.join('_')}`\n return new RegExp(pattern)\n }\n\n fields.forEach((field) => {\n if (row[field.replace(/\\./g, '_')]) {\n const sanitizedField = field.replace(/\\./g, '_')\n orderedResult[sanitizedField] = row[sanitizedField]\n } else {\n const regex = fieldToRegex(field)\n Object.keys(row).forEach((key) => {\n if (regex.test(key)) {\n orderedResult[key] = row[key]\n }\n })\n }\n })\n\n return orderedResult\n }\n\n return row\n}\n"],"names":["flattenObject","doc","fields","prefix","toCSVFunctions","row","flatten","siblingDoc","Object","entries","forEach","key","value","newKey","Array","isArray","item","index","columnName","result","data","length","orderedResult","fieldToRegex","field","parts","split","map","part","pattern","join","RegExp","replace","sanitizedField","regex","keys","test"],"mappings":"AAWA,OAAO,MAAMA,gBAAgB,CAAC,EAC5BC,GAAG,EACHC,MAAM,EACNC,MAAM,EACNC,cAAc,EACT;IACL,MAAMC,MAA+B,CAAC;IAEtC,MAAMC,UAAU,CAACC,YAAsBJ;QACrCK,OAAOC,OAAO,CAACF,YAAYG,OAAO,CAAC,CAAC,CAACC,KAAKC,MA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OAAO,GAAGD;gBAChB;YACF;QACF;IACF;IAEAN,QAAQL,KAAKE;IAEb,IAAIW,MAAMC,OAAO,CAACb,WAAWA,OAAOmB,MAAM,GAAG,GAAG;QAC9C,MAAMC,gBAAyC,CAAC;QAEhD,MAAMC,eAAe,CAACC;YACpB,MAAMC,QAAQD,MAAME,KAAK,CAAC,KAAKC,GAAG,CAAC,CAACC,OAAS,GAAGA,KAAK,UAAU,CAAC;YAChE,MAAMC,UAAU,CAAC,CAAC,EAAEJ,MAAMK,IAAI,CAAC,MAAM;YACrC,OAAO,IAAIC,OAAOF;QACpB;QAEA3B,OAAOQ,OAAO,CAAC,CAACc;YACd,IAAInB,GAAG,CAACmB,MAAMQ,OAAO,CAAC,OAAO,KAAK,EAAE;gBAClC,MAAMC,iBAAiBT,MAAMQ,OAAO,CAAC,OAAO;gBAC5CV,aAAa,CAACW,eAAe,GAAG5B,GAAG,CAAC4B,eAAe;YACrD,OAAO;gBACL,MAAMC,QAAQX,aAAaC;gBAC3BhB,OAAO2B,IAAI,CAAC9B,KAAKK,OAAO,CAAC,CAACC;oBACxB,IAAIuB,MAAME,IAAI,CAACzB,MAAM;wBACnBW,aAAa,CAACX,IAAI,GAAGN,GAAG,CAACM,IAAI;oBAC/B;gBACF;YACF;QACF;QAEA,OAAOW;IACT;IAEA,OAAOjB;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCustomFieldFunctions.d.ts","sourceRoot":"","sources":["../../src/export/getCustomFieldFunctions.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,iBAAiB,EAGvB,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhD,KAAK,IAAI,GAAG;IACV,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB,MAAM,EAAE,iBAAiB,GAAG,SAAS,CAAA;CACtC,CAAA;AAED,eAAO,MAAM,uBAAuB,wBAGjC,IAAI,KAAG,MAAM,CAAC,MAAM,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"getCustomFieldFunctions.d.ts","sourceRoot":"","sources":["../../src/export/getCustomFieldFunctions.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,iBAAiB,EAGvB,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhD,KAAK,IAAI,GAAG;IACV,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB,MAAM,EAAE,iBAAiB,GAAG,SAAS,CAAA;CACtC,CAAA;AAED,eAAO,MAAM,uBAAuB,wBAGjC,IAAI,KAAG,MAAM,CAAC,MAAM,EAAE,aAAa,CA4FrC,CAAA"}
|
|
@@ -23,10 +23,16 @@ export const getCustomFieldFunctions = ({ fields, select })=>{
|
|
|
23
23
|
// polymorphic single
|
|
24
24
|
// @ts-expect-error ref is untyped
|
|
25
25
|
result[`${ref.prefix}${field.name}`] = ({ data, value })=>{
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
if (value && typeof value === 'object' && 'relationTo' in value && 'value' in value) {
|
|
27
|
+
const relationTo = value.relationTo;
|
|
28
|
+
const relatedDoc = value.value;
|
|
29
|
+
if (relatedDoc && typeof relatedDoc === 'object') {
|
|
30
|
+
// @ts-expect-error ref is untyped
|
|
31
|
+
data[`${ref.prefix}${field.name}_id`] = relatedDoc.id;
|
|
32
|
+
// @ts-expect-error ref is untyped
|
|
33
|
+
data[`${ref.prefix}${field.name}_relationTo`] = relationTo;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
30
36
|
return undefined;
|
|
31
37
|
};
|
|
32
38
|
}
|
|
@@ -38,13 +44,23 @@ export const getCustomFieldFunctions = ({ fields, select })=>{
|
|
|
38
44
|
} else {
|
|
39
45
|
// polymorphic many
|
|
40
46
|
// @ts-expect-error ref is untyped
|
|
41
|
-
result[`${ref.prefix}${field.name}`] = ({ data, value })=>
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
result[`${ref.prefix}${field.name}`] = ({ data, value })=>{
|
|
48
|
+
if (Array.isArray(value)) {
|
|
49
|
+
value.forEach((val, i)=>{
|
|
50
|
+
if (val && typeof val === 'object') {
|
|
51
|
+
const relationTo = val.relationTo;
|
|
52
|
+
const relatedDoc = val.value;
|
|
53
|
+
if (relationTo && relatedDoc && typeof relatedDoc === 'object') {
|
|
54
|
+
// @ts-expect-error ref is untyped
|
|
55
|
+
data[`${ref.prefix}${field.name}_${i}_id`] = relatedDoc.id;
|
|
56
|
+
// @ts-expect-error ref is untyped
|
|
57
|
+
data[`${ref.prefix}${field.name}_${i}_relationTo`] = relationTo;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return undefined;
|
|
63
|
+
};
|
|
48
64
|
}
|
|
49
65
|
}
|
|
50
66
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/export/getCustomFieldFunctions.ts"],"sourcesContent":["import {\n type FlattenedField,\n type SelectIncludeType,\n traverseFields,\n type TraverseFieldsCallback,\n} from 'payload'\n\nimport type { ToCSVFunction } from '../types.js'\n\ntype Args = {\n fields: FlattenedField[]\n select: SelectIncludeType | undefined\n}\n\nexport const getCustomFieldFunctions = ({\n fields,\n select,\n}: Args): Record<string, ToCSVFunction> => {\n const result: Record<string, ToCSVFunction> = {}\n\n const buildCustomFunctions: TraverseFieldsCallback = ({ field, parentRef, ref }) => {\n // @ts-expect-error ref is untyped\n ref.prefix = parentRef.prefix || ''\n if (field.type === 'group' || field.type === 'tab') {\n // @ts-expect-error ref is untyped\n const parentPrefix = parentRef?.prefix ? `${parentRef.prefix}_` : ''\n // @ts-expect-error ref is untyped\n ref.prefix = `${parentPrefix}${field.name}_`\n }\n\n if (typeof field.custom?.['plugin-import-export']?.toCSV === 'function') {\n // @ts-expect-error ref is untyped\n result[`${ref.prefix}${field.name}`] = field.custom['plugin-import-export']?.toCSV\n } else if (field.type === 'relationship' || field.type === 'upload') {\n if (field.hasMany !== true) {\n if (!Array.isArray(field.relationTo)) {\n // monomorphic single\n // @ts-expect-error ref is untyped\n result[`${ref.prefix}${field.name}`] = ({ value }) =>\n typeof value === 'object' && value && 'id' in value ? value.id : value\n } else {\n // polymorphic single\n // @ts-expect-error ref is untyped\n result[`${ref.prefix}${field.name}`] = ({ data, value }) => {\n // @ts-expect-error ref is untyped\n
|
|
1
|
+
{"version":3,"sources":["../../src/export/getCustomFieldFunctions.ts"],"sourcesContent":["import {\n type FlattenedField,\n type SelectIncludeType,\n traverseFields,\n type TraverseFieldsCallback,\n} from 'payload'\n\nimport type { ToCSVFunction } from '../types.js'\n\ntype Args = {\n fields: FlattenedField[]\n select: SelectIncludeType | undefined\n}\n\nexport const getCustomFieldFunctions = ({\n fields,\n select,\n}: Args): Record<string, ToCSVFunction> => {\n const result: Record<string, ToCSVFunction> = {}\n\n const buildCustomFunctions: TraverseFieldsCallback = ({ field, parentRef, ref }) => {\n // @ts-expect-error ref is untyped\n ref.prefix = parentRef.prefix || ''\n if (field.type === 'group' || field.type === 'tab') {\n // @ts-expect-error ref is untyped\n const parentPrefix = parentRef?.prefix ? `${parentRef.prefix}_` : ''\n // @ts-expect-error ref is untyped\n ref.prefix = `${parentPrefix}${field.name}_`\n }\n\n if (typeof field.custom?.['plugin-import-export']?.toCSV === 'function') {\n // @ts-expect-error ref is untyped\n result[`${ref.prefix}${field.name}`] = field.custom['plugin-import-export']?.toCSV\n } else if (field.type === 'relationship' || field.type === 'upload') {\n if (field.hasMany !== true) {\n if (!Array.isArray(field.relationTo)) {\n // monomorphic single\n // @ts-expect-error ref is untyped\n result[`${ref.prefix}${field.name}`] = ({ value }) =>\n typeof value === 'object' && value && 'id' in value ? value.id : value\n } else {\n // polymorphic single\n // @ts-expect-error ref is untyped\n result[`${ref.prefix}${field.name}`] = ({ data, value }) => {\n if (value && typeof value === 'object' && 'relationTo' in value && 'value' in value) {\n const relationTo = (value as { relationTo: string; value: { id: number | string } })\n .relationTo\n const relatedDoc = (value as { relationTo: string; value: { id: number | string } })\n .value\n if (relatedDoc && typeof relatedDoc === 'object') {\n // @ts-expect-error ref is untyped\n data[`${ref.prefix}${field.name}_id`] = relatedDoc.id\n // @ts-expect-error ref is untyped\n data[`${ref.prefix}${field.name}_relationTo`] = relationTo\n }\n }\n return undefined\n }\n }\n } else {\n if (!Array.isArray(field.relationTo)) {\n // monomorphic many\n // @ts-expect-error ref is untyped\n result[`${ref.prefix}${field.name}`] = ({\n value,\n }: {\n value: Record<string, unknown>[]\n }) =>\n value.map((val: number | Record<string, unknown> | string) =>\n typeof val === 'object' ? val.id : val,\n )\n } else {\n // polymorphic many\n // @ts-expect-error ref is untyped\n result[`${ref.prefix}${field.name}`] = ({\n data,\n value,\n }: {\n data: Record<string, unknown>\n value: Array<Record<string, any>> | undefined\n }) => {\n if (Array.isArray(value)) {\n value.forEach((val, i) => {\n if (val && typeof val === 'object') {\n const relationTo = val.relationTo\n const relatedDoc = val.value\n if (relationTo && relatedDoc && typeof relatedDoc === 'object') {\n // @ts-expect-error ref is untyped\n data[`${ref.prefix}${field.name}_${i}_id`] = relatedDoc.id\n // @ts-expect-error ref is untyped\n data[`${ref.prefix}${field.name}_${i}_relationTo`] = relationTo\n }\n }\n })\n }\n return undefined\n }\n }\n }\n }\n\n // TODO: do this so we only return the functions needed based on the select used\n ////@ts-expect-error ref is untyped\n // ref.select = typeof select !== 'undefined' || select[field.name] ? select : {}\n }\n\n traverseFields({ callback: buildCustomFunctions, fields })\n\n return result\n}\n"],"names":["traverseFields","getCustomFieldFunctions","fields","select","result","buildCustomFunctions","field","parentRef","ref","prefix","type","parentPrefix","name","custom","toCSV","hasMany","Array","isArray","relationTo","value","id","data","relatedDoc","undefined","map","val","forEach","i","callback"],"mappings":"AAAA,SAGEA,cAAc,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AAE,GAAG,CAAC,CAAC,GAAGL,WAAWF,EAAE;wCAC1D,kCAAkC;wCAClCC,IAAI,CAAC,GAAGb,IAAIC,MAAM,GAAGH,MAAMM,IAAI,CAAC,CAAC,EAAEe,EAAE,WAAW,CAAC,CAAC,GAAGT;oCACvD;gCACF;4BACF;wBACF;wBACA,OAAOK;oBACT;gBACF;YACF;QACF;IAEA,gFAAgF;IAChF,mCAAmC;IACnC,iFAAiF;IACnF;IAEAvB,eAAe;QAAE4B,UAAUvB;QAAsBH;IAAO;IAExD,OAAOE;AACT,EAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -32,6 +32,11 @@ export type ToCSVFunction = (args: {
|
|
|
32
32
|
* The path of the column for the field, for arrays this includes the index (zero-based)
|
|
33
33
|
*/
|
|
34
34
|
columnName: string;
|
|
35
|
+
/**
|
|
36
|
+
* Alias for `row`, the object that accumulates CSV output.
|
|
37
|
+
* Use this to write additional fields into the exported row.
|
|
38
|
+
*/
|
|
39
|
+
data: Record<string, unknown>;
|
|
35
40
|
/**
|
|
36
41
|
* The top level document
|
|
37
42
|
*/
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAErF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,sBAAsB,CAAA;IAC7B,MAAM,EAAE,YAAY,CAAA;CACrB,GAAG,gBAAgB,CAAA;AAEpB,MAAM,MAAM,wBAAwB,GAAG;IACrC;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;IACtB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;IACf;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B;;;;OAIG;IACH,wBAAwB,CAAC,EAA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MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC5B;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACnC;;OAEG;IACH,KAAK,EAAE,OAAO,CAAA;CACf,KAAK,OAAO,CAAA"}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { CollectionAdminOptions, CollectionConfig, UploadConfig } from 'payload'\n\nexport type CollectionOverride = {\n admin: CollectionAdminOptions\n upload: UploadConfig\n} & CollectionConfig\n\nexport type ImportExportPluginConfig = {\n /**\n * Collections to include the Import/Export controls in\n * Defaults to all collections\n */\n collections?: string[]\n /**\n * If true, enables debug logging\n */\n debug?: boolean\n /**\n * Enable to force the export to run synchronously\n */\n disableJobsQueue?: boolean\n /**\n * This function takes the default export collection configured in the plugin and allows you to override it by modifying and returning it\n * @param collection\n * @returns collection\n */\n overrideExportCollection?: (collection: CollectionOverride) => CollectionOverride\n}\n\n/**\n * Custom function used to modify the outgoing csv data by manipulating the data, siblingData or by returning the desired value\n */\nexport type ToCSVFunction = (args: {\n /**\n * The path of the column for the field, for arrays this includes the index (zero-based)\n */\n columnName: string\n /**\n * The top level document\n */\n doc: Document\n /**\n * The object data that can be manipulated to assign data to the CSV\n */\n row: Record<string, unknown>\n /**\n * The document data at the level where it belongs\n */\n siblingDoc: Record<string, unknown>\n /**\n * The data for the field.\n */\n value: unknown\n}) => unknown\n"],"names":[],"mappings":"AA6BA;;CAEC,GACD,
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { CollectionAdminOptions, CollectionConfig, UploadConfig } from 'payload'\n\nexport type CollectionOverride = {\n admin: CollectionAdminOptions\n upload: UploadConfig\n} & CollectionConfig\n\nexport type ImportExportPluginConfig = {\n /**\n * Collections to include the Import/Export controls in\n * Defaults to all collections\n */\n collections?: string[]\n /**\n * If true, enables debug logging\n */\n debug?: boolean\n /**\n * Enable to force the export to run synchronously\n */\n disableJobsQueue?: boolean\n /**\n * This function takes the default export collection configured in the plugin and allows you to override it by modifying and returning it\n * @param collection\n * @returns collection\n */\n overrideExportCollection?: (collection: CollectionOverride) => CollectionOverride\n}\n\n/**\n * Custom function used to modify the outgoing csv data by manipulating the data, siblingData or by returning the desired value\n */\nexport type ToCSVFunction = (args: {\n /**\n * The path of the column for the field, for arrays this includes the index (zero-based)\n */\n columnName: string\n /**\n * Alias for `row`, the object that accumulates CSV output.\n * Use this to write additional fields into the exported row.\n */\n data: Record<string, unknown>\n /**\n * The top level document\n */\n doc: Document\n /**\n * The object data that can be manipulated to assign data to the CSV\n */\n row: Record<string, unknown>\n /**\n * The document data at the level where it belongs\n */\n siblingDoc: Record<string, unknown>\n /**\n * The data for the field.\n */\n value: unknown\n}) => unknown\n"],"names":[],"mappings":"AA6BA;;CAEC,GACD,WA0Ba"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/plugin-import-export",
|
|
3
|
-
"version": "3.44.0-canary.
|
|
3
|
+
"version": "3.44.0-canary.9",
|
|
4
4
|
"description": "Import-Export plugin for Payload",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"payload",
|
|
@@ -64,17 +64,17 @@
|
|
|
64
64
|
"csv-parse": "^5.6.0",
|
|
65
65
|
"csv-stringify": "^6.5.2",
|
|
66
66
|
"qs-esm": "7.0.2",
|
|
67
|
-
"@payloadcms/translations": "3.44.0-canary.
|
|
68
|
-
"@payloadcms/ui": "3.44.0-canary.
|
|
67
|
+
"@payloadcms/translations": "3.44.0-canary.9",
|
|
68
|
+
"@payloadcms/ui": "3.44.0-canary.9"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@payloadcms/eslint-config": "3.28.0",
|
|
72
|
-
"
|
|
73
|
-
"
|
|
72
|
+
"@payloadcms/ui": "3.44.0-canary.9",
|
|
73
|
+
"payload": "3.44.0-canary.9"
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
76
|
-
"@payloadcms/ui": "3.44.0-canary.
|
|
77
|
-
"payload": "3.44.0-canary.
|
|
76
|
+
"@payloadcms/ui": "3.44.0-canary.9",
|
|
77
|
+
"payload": "3.44.0-canary.9"
|
|
78
78
|
},
|
|
79
79
|
"homepage:": "https://payloadcms.com",
|
|
80
80
|
"scripts": {
|