@payloadcms/drizzle 3.0.0-canary.483db21 → 3.0.0-canary.518fabe
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/count.d.ts.map +1 -1
- package/dist/count.js.map +1 -1
- package/dist/createTableName.d.ts.map +1 -1
- package/dist/createTableName.js +6 -2
- package/dist/createTableName.js.map +1 -1
- package/dist/createVersion.d.ts.map +1 -1
- package/dist/createVersion.js +3 -1
- package/dist/createVersion.js.map +1 -1
- package/dist/destroy.d.ts.map +1 -1
- package/dist/destroy.js +3 -1
- package/dist/destroy.js.map +1 -1
- package/dist/exports/postgres.d.ts +14 -0
- package/dist/exports/postgres.d.ts.map +1 -0
- package/dist/exports/postgres.js +15 -0
- package/dist/exports/postgres.js.map +1 -0
- package/dist/find/buildFindManyArgs.d.ts +4 -4
- package/dist/find/buildFindManyArgs.d.ts.map +1 -1
- package/dist/find/buildFindManyArgs.js +1 -0
- package/dist/find/buildFindManyArgs.js.map +1 -1
- package/dist/find/traverseFields.d.ts +2 -1
- package/dist/find/traverseFields.d.ts.map +1 -1
- package/dist/find/traverseFields.js +24 -16
- package/dist/find/traverseFields.js.map +1 -1
- package/dist/findMigrationDir.d.ts.map +1 -1
- package/dist/findMigrationDir.js +3 -1
- package/dist/findMigrationDir.js.map +1 -1
- package/dist/migrate.js +2 -7
- package/dist/migrate.js.map +1 -1
- package/dist/migrateDown.d.ts.map +1 -1
- package/dist/migrateDown.js +1 -1
- package/dist/migrateDown.js.map +1 -1
- package/dist/migrateFresh.d.ts.map +1 -1
- package/dist/migrateFresh.js +1 -0
- package/dist/migrateFresh.js.map +1 -1
- package/dist/migrateRefresh.d.ts.map +1 -1
- package/dist/migrateRefresh.js +2 -1
- package/dist/migrateRefresh.js.map +1 -1
- package/dist/migrateReset.d.ts.map +1 -1
- package/dist/migrateReset.js +4 -2
- package/dist/migrateReset.js.map +1 -1
- package/dist/migrateStatus.js +0 -1
- package/dist/migrateStatus.js.map +1 -1
- package/dist/postgres/countDistinct.d.ts +3 -0
- package/dist/postgres/countDistinct.d.ts.map +1 -0
- package/dist/postgres/countDistinct.js +24 -0
- package/dist/postgres/countDistinct.js.map +1 -0
- package/dist/postgres/createJSONQuery/convertPathToJSONTraversal.d.ts +2 -0
- package/dist/postgres/createJSONQuery/convertPathToJSONTraversal.d.ts.map +1 -0
- package/dist/postgres/createJSONQuery/convertPathToJSONTraversal.js +16 -0
- package/dist/postgres/createJSONQuery/convertPathToJSONTraversal.js.map +1 -0
- package/dist/postgres/createJSONQuery/formatJSONPathSegment.d.ts +2 -0
- package/dist/postgres/createJSONQuery/formatJSONPathSegment.d.ts.map +1 -0
- package/dist/postgres/createJSONQuery/formatJSONPathSegment.js +5 -0
- package/dist/postgres/createJSONQuery/formatJSONPathSegment.js.map +1 -0
- package/dist/postgres/createJSONQuery/index.d.ts +10 -0
- package/dist/postgres/createJSONQuery/index.d.ts.map +1 -0
- package/dist/postgres/createJSONQuery/index.js +54 -0
- package/dist/postgres/createJSONQuery/index.js.map +1 -0
- package/dist/postgres/createMigration.d.ts +3 -0
- package/dist/postgres/createMigration.d.ts.map +1 -0
- package/dist/postgres/createMigration.js +92 -0
- package/dist/postgres/createMigration.js.map +1 -0
- package/dist/postgres/defaultSnapshot.d.ts +3 -0
- package/dist/postgres/defaultSnapshot.d.ts.map +1 -0
- package/dist/postgres/defaultSnapshot.js +17 -0
- package/dist/postgres/defaultSnapshot.js.map +1 -0
- package/dist/postgres/deleteWhere.d.ts +3 -0
- package/dist/postgres/deleteWhere.d.ts.map +1 -0
- package/dist/postgres/deleteWhere.js +6 -0
- package/dist/postgres/deleteWhere.js.map +1 -0
- package/dist/postgres/dropDatabase.d.ts +3 -0
- package/dist/postgres/dropDatabase.d.ts.map +1 -0
- package/dist/postgres/dropDatabase.js +9 -0
- package/dist/postgres/dropDatabase.js.map +1 -0
- package/dist/postgres/execute.d.ts +3 -0
- package/dist/postgres/execute.d.ts.map +1 -0
- package/dist/postgres/execute.js +11 -0
- package/dist/postgres/execute.js.map +1 -0
- package/dist/postgres/getMigrationTemplate.d.ts +4 -0
- package/dist/postgres/getMigrationTemplate.d.ts.map +1 -0
- package/dist/postgres/getMigrationTemplate.js +13 -0
- package/dist/postgres/getMigrationTemplate.js.map +1 -0
- package/dist/postgres/init.d.ts +3 -0
- package/dist/postgres/init.d.ts.map +1 -0
- package/dist/postgres/init.js +95 -0
- package/dist/postgres/init.js.map +1 -0
- package/dist/postgres/insert.d.ts +3 -0
- package/dist/postgres/insert.d.ts.map +1 -0
- package/dist/postgres/insert.js +12 -0
- package/dist/postgres/insert.js.map +1 -0
- package/dist/postgres/requireDrizzleKit.d.ts +3 -0
- package/dist/postgres/requireDrizzleKit.d.ts.map +1 -0
- package/dist/postgres/requireDrizzleKit.js +5 -0
- package/dist/postgres/requireDrizzleKit.js.map +1 -0
- package/dist/postgres/schema/build.d.ts +40 -0
- package/dist/postgres/schema/build.d.ts.map +1 -0
- package/dist/postgres/schema/build.js +377 -0
- package/dist/postgres/schema/build.js.map +1 -0
- package/dist/postgres/schema/createIndex.d.ts +12 -0
- package/dist/postgres/schema/createIndex.d.ts.map +1 -0
- package/dist/postgres/schema/createIndex.js +20 -0
- package/dist/postgres/schema/createIndex.js.map +1 -0
- package/dist/postgres/schema/idToUUID.d.ts +3 -0
- package/dist/postgres/schema/idToUUID.d.ts.map +1 -0
- package/dist/postgres/schema/idToUUID.js +11 -0
- package/dist/postgres/schema/idToUUID.js.map +1 -0
- package/dist/postgres/schema/parentIDColumnMap.d.ts +4 -0
- package/dist/postgres/schema/parentIDColumnMap.d.ts.map +1 -0
- package/dist/postgres/schema/parentIDColumnMap.js +9 -0
- package/dist/postgres/schema/parentIDColumnMap.js.map +1 -0
- package/dist/postgres/schema/setColumnID.d.ts +11 -0
- package/dist/postgres/schema/setColumnID.d.ts.map +1 -0
- package/dist/postgres/schema/setColumnID.js +24 -0
- package/dist/postgres/schema/setColumnID.js.map +1 -0
- package/dist/postgres/schema/traverseFields.d.ts +40 -0
- package/dist/postgres/schema/traverseFields.d.ts.map +1 -0
- package/dist/postgres/schema/traverseFields.js +712 -0
- package/dist/postgres/schema/traverseFields.js.map +1 -0
- package/dist/postgres/schema/withDefault.d.ts +4 -0
- package/dist/postgres/schema/withDefault.d.ts.map +1 -0
- package/dist/postgres/schema/withDefault.js +12 -0
- package/dist/postgres/schema/withDefault.js.map +1 -0
- package/dist/postgres/types.d.ts +112 -0
- package/dist/postgres/types.d.ts.map +1 -0
- package/dist/postgres/types.js +3 -0
- package/dist/postgres/types.js.map +1 -0
- package/dist/queries/buildAndOrConditions.d.ts.map +1 -1
- package/dist/queries/buildAndOrConditions.js +0 -2
- package/dist/queries/buildAndOrConditions.js.map +1 -1
- package/dist/queries/getTableColumnFromPath.d.ts.map +1 -1
- package/dist/queries/getTableColumnFromPath.js +10 -7
- package/dist/queries/getTableColumnFromPath.js.map +1 -1
- package/dist/queries/operatorMap.d.ts.map +1 -1
- package/dist/queries/operatorMap.js.map +1 -1
- package/dist/queries/parseParams.d.ts.map +1 -1
- package/dist/queries/parseParams.js +20 -2
- package/dist/queries/parseParams.js.map +1 -1
- package/dist/queries/sanitizeQueryValue.d.ts.map +1 -1
- package/dist/queries/sanitizeQueryValue.js +15 -7
- package/dist/queries/sanitizeQueryValue.js.map +1 -1
- package/dist/queries/selectDistinct.d.ts +3 -4
- package/dist/queries/selectDistinct.d.ts.map +1 -1
- package/dist/queries/selectDistinct.js.map +1 -1
- package/dist/queryDrafts.d.ts.map +1 -1
- package/dist/queryDrafts.js +0 -1
- package/dist/queryDrafts.js.map +1 -1
- package/dist/transactions/beginTransaction.d.ts.map +1 -1
- package/dist/transactions/beginTransaction.js +5 -1
- package/dist/transactions/beginTransaction.js.map +1 -1
- package/dist/transactions/commitTransaction.d.ts.map +1 -1
- package/dist/transactions/commitTransaction.js +3 -1
- package/dist/transactions/commitTransaction.js.map +1 -1
- package/dist/transform/read/hasManyNumber.d.ts +2 -1
- package/dist/transform/read/hasManyNumber.d.ts.map +1 -1
- package/dist/transform/read/hasManyNumber.js +12 -2
- package/dist/transform/read/hasManyNumber.js.map +1 -1
- package/dist/transform/read/hasManyText.d.ts +2 -1
- package/dist/transform/read/hasManyText.d.ts.map +1 -1
- package/dist/transform/read/hasManyText.js +12 -2
- package/dist/transform/read/hasManyText.js.map +1 -1
- package/dist/transform/read/index.d.ts.map +1 -1
- package/dist/transform/read/index.js +1 -1
- package/dist/transform/read/index.js.map +1 -1
- package/dist/transform/read/relationship.d.ts +2 -1
- package/dist/transform/read/relationship.d.ts.map +1 -1
- package/dist/transform/read/relationship.js +15 -6
- package/dist/transform/read/relationship.js.map +1 -1
- package/dist/transform/read/traverseFields.d.ts +5 -1
- package/dist/transform/read/traverseFields.d.ts.map +1 -1
- package/dist/transform/read/traverseFields.js +93 -51
- package/dist/transform/read/traverseFields.js.map +1 -1
- package/dist/transform/write/array.d.ts +6 -1
- package/dist/transform/write/array.d.ts.map +1 -1
- package/dist/transform/write/array.js +7 -3
- package/dist/transform/write/array.js.map +1 -1
- package/dist/transform/write/blocks.d.ts +8 -3
- package/dist/transform/write/blocks.d.ts.map +1 -1
- package/dist/transform/write/blocks.js +19 -7
- package/dist/transform/write/blocks.js.map +1 -1
- package/dist/transform/write/index.d.ts.map +1 -1
- package/dist/transform/write/index.js +1 -1
- package/dist/transform/write/index.js.map +1 -1
- package/dist/transform/write/relationships.d.ts.map +1 -1
- package/dist/transform/write/relationships.js +6 -2
- package/dist/transform/write/relationships.js.map +1 -1
- package/dist/transform/write/selects.d.ts.map +1 -1
- package/dist/transform/write/selects.js +1 -1
- package/dist/transform/write/selects.js.map +1 -1
- package/dist/transform/write/traverseFields.d.ts +6 -1
- package/dist/transform/write/traverseFields.d.ts.map +1 -1
- package/dist/transform/write/traverseFields.js +38 -16
- package/dist/transform/write/traverseFields.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/upsertRow/deleteExistingRowsByPath.d.ts.map +1 -1
- package/dist/upsertRow/deleteExistingRowsByPath.js +6 -2
- package/dist/upsertRow/deleteExistingRowsByPath.js.map +1 -1
- package/dist/upsertRow/index.d.ts.map +1 -1
- package/dist/upsertRow/index.js +46 -10
- package/dist/upsertRow/index.js.map +1 -1
- package/dist/upsertRow/insertArrays.d.ts.map +1 -1
- package/dist/upsertRow/insertArrays.js +1 -1
- package/dist/upsertRow/insertArrays.js.map +1 -1
- package/dist/upsertRow/types.d.ts +4 -4
- package/dist/upsertRow/types.d.ts.map +1 -1
- package/dist/upsertRow/types.js.map +1 -1
- package/dist/utilities/createBlocksMap.d.ts.map +1 -1
- package/dist/utilities/createBlocksMap.js +4 -2
- package/dist/utilities/createBlocksMap.js.map +1 -1
- package/dist/utilities/createRelationshipMap.d.ts.map +1 -1
- package/dist/utilities/createRelationshipMap.js +3 -1
- package/dist/utilities/createRelationshipMap.js.map +1 -1
- package/dist/utilities/hasLocalesTable.d.ts.map +1 -1
- package/dist/utilities/hasLocalesTable.js +12 -4
- package/dist/utilities/hasLocalesTable.js.map +1 -1
- package/package.json +16 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/transform/read/relationship.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../src/transform/read/relationship.ts"],"sourcesContent":["import type { RelationshipField, UploadField } from 'payload'\n\ntype Args = {\n field: RelationshipField | UploadField\n locale?: string\n ref: Record<string, unknown>\n relations: Record<string, unknown>[]\n withinArrayOrBlockLocale?: string\n}\n\nexport const transformRelationship = ({\n field,\n locale,\n ref,\n relations,\n withinArrayOrBlockLocale,\n}: Args) => {\n let result: unknown\n\n if (!('hasMany' in field) || field.hasMany === false) {\n let relation = relations[0]\n\n if (withinArrayOrBlockLocale) {\n relation = relations.find((rel) => rel.locale === withinArrayOrBlockLocale)\n }\n\n if (relation) {\n // Handle hasOne Poly\n if (Array.isArray(field.relationTo)) {\n const matchedRelation = Object.entries(relation).find(([key, val]) => {\n return val !== null && !['id', 'locale', 'order', 'parent', 'path'].includes(key)\n })\n\n if (matchedRelation) {\n const relationTo = matchedRelation[0].replace('ID', '')\n\n result = {\n relationTo,\n value: matchedRelation[1],\n }\n }\n }\n }\n } else {\n const transformedRelations = []\n\n relations.forEach((relation) => {\n let matchedLocale = true\n\n if (withinArrayOrBlockLocale) {\n matchedLocale = relation.locale === withinArrayOrBlockLocale\n }\n\n // Handle hasMany\n if (!Array.isArray(field.relationTo)) {\n const relatedData = relation[`${field.relationTo}ID`]\n\n if (relatedData && matchedLocale) {\n transformedRelations.push(relatedData)\n }\n } else {\n // Handle hasMany Poly\n const matchedRelation = Object.entries(relation).find(\n ([key, val]) =>\n val !== null &&\n !['id', 'locale', 'order', 'parent', 'path'].includes(key) &&\n matchedLocale,\n )\n\n if (matchedRelation) {\n const relationTo = matchedRelation[0].replace('ID', '')\n\n transformedRelations.push({\n relationTo,\n value: matchedRelation[1],\n })\n }\n }\n })\n\n result = transformedRelations\n }\n\n if (locale) {\n ref[field.name][locale] = result\n } else {\n ref[field.name] = result\n }\n}\n"],"names":["transformRelationship","field","locale","ref","relations","withinArrayOrBlockLocale","result","hasMany","relation","find","rel","Array","isArray","relationTo","matchedRelation","Object","entries","key","val","includes","replace","value","transformedRelations","forEach","matchedLocale","relatedData","push","name"],"mappings":"AAUA,OAAO,MAAMA,wBAAwB,CAAC,EACpCC,KAAK,EACLC,MAAM,EACNC,GAAG,EACHC,SAAS,EACTC,wBAAwB,EACnB;IACL,IAAIC;IAEJ,IAAI,CAAE,CAAA,aAAaL,KAAI,KAAMA,MAAMM,OAAO,KAAK,OAAO;QACpD,IAAIC,WAAWJ,SAAS,CAAC,EAAE;QAE3B,IAAIC,0BAA0B;YAC5BG,WAAWJ,UAAUK,IAAI,CAAC,CAACC,MAAQA,IAAIR,MAAM,KAAKG;QACpD;QAEA,IAAIG,UAAU;YACZ,qBAAqB;YACrB,IAAIG,MAAMC,OAAO,CAACX,MAAMY,UAAU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C,CAACzB,OAAO,GAAGI;IAC5B,OAAO;QACLH,GAAG,CAACF,MAAM0B,IAAI,CAAC,GAAGrB;IACpB;AACF,EAAC"}
|
|
@@ -50,7 +50,11 @@ type TraverseFieldsArgs = {
|
|
|
50
50
|
* All hasMany text fields, as returned by Drizzle, keyed on an object by field path
|
|
51
51
|
*/
|
|
52
52
|
texts: Record<string, Record<string, unknown>[]>;
|
|
53
|
+
/**
|
|
54
|
+
* Set to a locale if this group of fields is within a localized array or block.
|
|
55
|
+
*/
|
|
56
|
+
withinArrayOrBlockLocale?: string;
|
|
53
57
|
};
|
|
54
|
-
export declare const traverseFields: <T extends Record<string, unknown>>({ adapter, blocks, config, dataRef, deletions, fieldPrefix, fields, numbers, path, relationships, table, texts, }: TraverseFieldsArgs) => T;
|
|
58
|
+
export declare const traverseFields: <T extends Record<string, unknown>>({ adapter, blocks, config, dataRef, deletions, fieldPrefix, fields, numbers, path, relationships, table, texts, withinArrayOrBlockLocale, }: TraverseFieldsArgs) => T;
|
|
55
59
|
export {};
|
|
56
60
|
//# sourceMappingURL=traverseFields.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../../src/transform/read/traverseFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAIjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAA;AAMnE,KAAK,kBAAkB,GAAG;IACxB;;OAEG;IACH,OAAO,EAAE,cAAc,CAAA;IACvB;;OAEG;IACH,MAAM,EAAE,SAAS,CAAA;IACjB;;OAEG;IACH,MAAM,EAAE,eAAe,CAAA;IACvB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAChC;;OAEG;IACH,SA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;IACH,MAAM,EAAE,CAAC,KAAK,GAAG,UAAU,CAAC,EAAE,CAAA;IAC9B;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CAAA;IAClD;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CAAA;IACxD;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CAAA;IAChD;;OAEG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAA;CAClC,CAAA;AAID,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,+IAc7D,kBAAkB,KAAG,CAugBvB,CAAA"}
|
|
@@ -4,7 +4,7 @@ import { transformHasManyText } from './hasManyText.js';
|
|
|
4
4
|
import { transformRelationship } from './relationship.js';
|
|
5
5
|
// Traverse fields recursively, transforming data
|
|
6
6
|
// for each field type into required Payload shape
|
|
7
|
-
export const traverseFields = ({ adapter, blocks, config, dataRef, deletions, fieldPrefix, fields, numbers, path, relationships, table, texts })=>{
|
|
7
|
+
export const traverseFields = ({ adapter, blocks, config, dataRef, deletions, fieldPrefix, fields, numbers, path, relationships, table, texts, withinArrayOrBlockLocale })=>{
|
|
8
8
|
const sanitizedPath = path ? `${path}.` : path;
|
|
9
9
|
const formatted = fields.reduce((result, field)=>{
|
|
10
10
|
if (field.type === 'tabs') {
|
|
@@ -23,7 +23,8 @@ export const traverseFields = ({ adapter, blocks, config, dataRef, deletions, fi
|
|
|
23
23
|
path,
|
|
24
24
|
relationships,
|
|
25
25
|
table,
|
|
26
|
-
texts
|
|
26
|
+
texts,
|
|
27
|
+
withinArrayOrBlockLocale
|
|
27
28
|
});
|
|
28
29
|
}
|
|
29
30
|
if (field.type === 'collapsible' || field.type === 'row' || field.type === 'tab' && !('name' in field)) {
|
|
@@ -39,7 +40,8 @@ export const traverseFields = ({ adapter, blocks, config, dataRef, deletions, fi
|
|
|
39
40
|
path,
|
|
40
41
|
relationships,
|
|
41
42
|
table,
|
|
42
|
-
texts
|
|
43
|
+
texts,
|
|
44
|
+
withinArrayOrBlockLocale
|
|
43
45
|
});
|
|
44
46
|
}
|
|
45
47
|
if (fieldAffectsData(field)) {
|
|
@@ -55,7 +57,9 @@ export const traverseFields = ({ adapter, blocks, config, dataRef, deletions, fi
|
|
|
55
57
|
if (field.localized) {
|
|
56
58
|
result[field.name] = fieldData.reduce((arrayResult, row)=>{
|
|
57
59
|
if (typeof row._locale === 'string') {
|
|
58
|
-
if (!arrayResult[row._locale])
|
|
60
|
+
if (!arrayResult[row._locale]) {
|
|
61
|
+
arrayResult[row._locale] = [];
|
|
62
|
+
}
|
|
59
63
|
const locale = row._locale;
|
|
60
64
|
const data = {};
|
|
61
65
|
delete row._locale;
|
|
@@ -75,7 +79,8 @@ export const traverseFields = ({ adapter, blocks, config, dataRef, deletions, fi
|
|
|
75
79
|
path: `${sanitizedPath}${field.name}.${row._order - 1}`,
|
|
76
80
|
relationships,
|
|
77
81
|
table: row,
|
|
78
|
-
texts
|
|
82
|
+
texts,
|
|
83
|
+
withinArrayOrBlockLocale: locale
|
|
79
84
|
});
|
|
80
85
|
if ('_order' in rowResult) {
|
|
81
86
|
delete rowResult._order;
|
|
@@ -85,7 +90,7 @@ export const traverseFields = ({ adapter, blocks, config, dataRef, deletions, fi
|
|
|
85
90
|
return arrayResult;
|
|
86
91
|
}, {});
|
|
87
92
|
} else {
|
|
88
|
-
result[field.name] = fieldData.
|
|
93
|
+
result[field.name] = fieldData.reduce((acc, row, i)=>{
|
|
89
94
|
if (row._uuid) {
|
|
90
95
|
row.id = row._uuid;
|
|
91
96
|
delete row._uuid;
|
|
@@ -93,21 +98,28 @@ export const traverseFields = ({ adapter, blocks, config, dataRef, deletions, fi
|
|
|
93
98
|
if ('_order' in row) {
|
|
94
99
|
delete row._order;
|
|
95
100
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
101
|
+
if (!withinArrayOrBlockLocale || withinArrayOrBlockLocale && withinArrayOrBlockLocale === row._locale) {
|
|
102
|
+
if (row._locale) {
|
|
103
|
+
delete row._locale;
|
|
104
|
+
}
|
|
105
|
+
acc.push(traverseFields({
|
|
106
|
+
adapter,
|
|
107
|
+
blocks,
|
|
108
|
+
config,
|
|
109
|
+
dataRef: row,
|
|
110
|
+
deletions,
|
|
111
|
+
fieldPrefix: '',
|
|
112
|
+
fields: field.fields,
|
|
113
|
+
numbers,
|
|
114
|
+
path: `${sanitizedPath}${field.name}.${i}`,
|
|
115
|
+
relationships,
|
|
116
|
+
table: row,
|
|
117
|
+
texts,
|
|
118
|
+
withinArrayOrBlockLocale
|
|
119
|
+
}));
|
|
120
|
+
}
|
|
121
|
+
return acc;
|
|
122
|
+
}, []);
|
|
111
123
|
}
|
|
112
124
|
}
|
|
113
125
|
return result;
|
|
@@ -123,7 +135,9 @@ export const traverseFields = ({ adapter, blocks, config, dataRef, deletions, fi
|
|
|
123
135
|
delete row._uuid;
|
|
124
136
|
}
|
|
125
137
|
if (typeof row._locale === 'string') {
|
|
126
|
-
if (!result[field.name][row._locale])
|
|
138
|
+
if (!result[field.name][row._locale]) {
|
|
139
|
+
result[field.name][row._locale] = [];
|
|
140
|
+
}
|
|
127
141
|
result[field.name][row._locale].push(row);
|
|
128
142
|
delete row._locale;
|
|
129
143
|
}
|
|
@@ -144,7 +158,8 @@ export const traverseFields = ({ adapter, blocks, config, dataRef, deletions, fi
|
|
|
144
158
|
path: `${blockFieldPath}.${row._order - 1}`,
|
|
145
159
|
relationships,
|
|
146
160
|
table: row,
|
|
147
|
-
texts
|
|
161
|
+
texts,
|
|
162
|
+
withinArrayOrBlockLocale: locale
|
|
148
163
|
});
|
|
149
164
|
delete blockResult._order;
|
|
150
165
|
return blockResult;
|
|
@@ -153,7 +168,7 @@ export const traverseFields = ({ adapter, blocks, config, dataRef, deletions, fi
|
|
|
153
168
|
});
|
|
154
169
|
});
|
|
155
170
|
} else {
|
|
156
|
-
result[field.name] = blocks[blockFieldPath].
|
|
171
|
+
result[field.name] = blocks[blockFieldPath].reduce((acc, row, i)=>{
|
|
157
172
|
delete row._order;
|
|
158
173
|
if (row._uuid) {
|
|
159
174
|
row.id = row._uuid;
|
|
@@ -161,23 +176,32 @@ export const traverseFields = ({ adapter, blocks, config, dataRef, deletions, fi
|
|
|
161
176
|
}
|
|
162
177
|
const block = field.blocks.find(({ slug })=>slug === row.blockType);
|
|
163
178
|
if (block) {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
179
|
+
if (!withinArrayOrBlockLocale || withinArrayOrBlockLocale && withinArrayOrBlockLocale === row._locale) {
|
|
180
|
+
if (row._locale) {
|
|
181
|
+
delete row._locale;
|
|
182
|
+
}
|
|
183
|
+
acc.push(traverseFields({
|
|
184
|
+
adapter,
|
|
185
|
+
blocks,
|
|
186
|
+
config,
|
|
187
|
+
dataRef: row,
|
|
188
|
+
deletions,
|
|
189
|
+
fieldPrefix: '',
|
|
190
|
+
fields: block.fields,
|
|
191
|
+
numbers,
|
|
192
|
+
path: `${blockFieldPath}.${i}`,
|
|
193
|
+
relationships,
|
|
194
|
+
table: row,
|
|
195
|
+
texts,
|
|
196
|
+
withinArrayOrBlockLocale
|
|
197
|
+
}));
|
|
198
|
+
return acc;
|
|
199
|
+
}
|
|
200
|
+
} else {
|
|
201
|
+
acc.push({});
|
|
178
202
|
}
|
|
179
|
-
return
|
|
180
|
-
});
|
|
203
|
+
return acc;
|
|
204
|
+
}, []);
|
|
181
205
|
}
|
|
182
206
|
}
|
|
183
207
|
return result;
|
|
@@ -215,7 +239,9 @@ export const traverseFields = ({ adapter, blocks, config, dataRef, deletions, fi
|
|
|
215
239
|
const relationsByLocale = {};
|
|
216
240
|
relationPathMatch.forEach((row)=>{
|
|
217
241
|
if (typeof row.locale === 'string') {
|
|
218
|
-
if (!relationsByLocale[row.locale])
|
|
242
|
+
if (!relationsByLocale[row.locale]) {
|
|
243
|
+
relationsByLocale[row.locale] = [];
|
|
244
|
+
}
|
|
219
245
|
relationsByLocale[row.locale].push(row);
|
|
220
246
|
}
|
|
221
247
|
});
|
|
@@ -231,7 +257,8 @@ export const traverseFields = ({ adapter, blocks, config, dataRef, deletions, fi
|
|
|
231
257
|
transformRelationship({
|
|
232
258
|
field,
|
|
233
259
|
ref: result,
|
|
234
|
-
relations: relationPathMatch
|
|
260
|
+
relations: relationPathMatch,
|
|
261
|
+
withinArrayOrBlockLocale
|
|
235
262
|
});
|
|
236
263
|
}
|
|
237
264
|
return result;
|
|
@@ -239,13 +266,17 @@ export const traverseFields = ({ adapter, blocks, config, dataRef, deletions, fi
|
|
|
239
266
|
}
|
|
240
267
|
if (field.type === 'text' && field?.hasMany) {
|
|
241
268
|
const textPathMatch = texts[`${sanitizedPath}${field.name}`];
|
|
242
|
-
if (!textPathMatch)
|
|
269
|
+
if (!textPathMatch) {
|
|
270
|
+
return result;
|
|
271
|
+
}
|
|
243
272
|
if (field.localized) {
|
|
244
273
|
result[field.name] = {};
|
|
245
274
|
const textsByLocale = {};
|
|
246
275
|
textPathMatch.forEach((row)=>{
|
|
247
276
|
if (typeof row.locale === 'string') {
|
|
248
|
-
if (!textsByLocale[row.locale])
|
|
277
|
+
if (!textsByLocale[row.locale]) {
|
|
278
|
+
textsByLocale[row.locale] = [];
|
|
279
|
+
}
|
|
249
280
|
textsByLocale[row.locale].push(row);
|
|
250
281
|
}
|
|
251
282
|
});
|
|
@@ -261,20 +292,25 @@ export const traverseFields = ({ adapter, blocks, config, dataRef, deletions, fi
|
|
|
261
292
|
transformHasManyText({
|
|
262
293
|
field,
|
|
263
294
|
ref: result,
|
|
264
|
-
textRows: textPathMatch
|
|
295
|
+
textRows: textPathMatch,
|
|
296
|
+
withinArrayOrBlockLocale
|
|
265
297
|
});
|
|
266
298
|
}
|
|
267
299
|
return result;
|
|
268
300
|
}
|
|
269
301
|
if (field.type === 'number' && field.hasMany) {
|
|
270
302
|
const numberPathMatch = numbers[`${sanitizedPath}${field.name}`];
|
|
271
|
-
if (!numberPathMatch)
|
|
303
|
+
if (!numberPathMatch) {
|
|
304
|
+
return result;
|
|
305
|
+
}
|
|
272
306
|
if (field.localized) {
|
|
273
307
|
result[field.name] = {};
|
|
274
308
|
const numbersByLocale = {};
|
|
275
309
|
numberPathMatch.forEach((row)=>{
|
|
276
310
|
if (typeof row.locale === 'string') {
|
|
277
|
-
if (!numbersByLocale[row.locale])
|
|
311
|
+
if (!numbersByLocale[row.locale]) {
|
|
312
|
+
numbersByLocale[row.locale] = [];
|
|
313
|
+
}
|
|
278
314
|
numbersByLocale[row.locale].push(row);
|
|
279
315
|
}
|
|
280
316
|
});
|
|
@@ -290,7 +326,8 @@ export const traverseFields = ({ adapter, blocks, config, dataRef, deletions, fi
|
|
|
290
326
|
transformHasManyNumber({
|
|
291
327
|
field,
|
|
292
328
|
numberRows: numberPathMatch,
|
|
293
|
-
ref: result
|
|
329
|
+
ref: result,
|
|
330
|
+
withinArrayOrBlockLocale
|
|
294
331
|
});
|
|
295
332
|
}
|
|
296
333
|
return result;
|
|
@@ -300,7 +337,9 @@ export const traverseFields = ({ adapter, blocks, config, dataRef, deletions, fi
|
|
|
300
337
|
if (field.localized) {
|
|
301
338
|
result[field.name] = fieldData.reduce((selectResult, row)=>{
|
|
302
339
|
if (typeof row.locale === 'string') {
|
|
303
|
-
if (!selectResult[row.locale])
|
|
340
|
+
if (!selectResult[row.locale]) {
|
|
341
|
+
selectResult[row.locale] = [];
|
|
342
|
+
}
|
|
304
343
|
selectResult[row.locale].push(row.value);
|
|
305
344
|
}
|
|
306
345
|
return selectResult;
|
|
@@ -338,7 +377,9 @@ export const traverseFields = ({ adapter, blocks, config, dataRef, deletions, fi
|
|
|
338
377
|
const groupData = {};
|
|
339
378
|
const locale = table._locale;
|
|
340
379
|
const refKey = field.localized && locale ? locale : field.name;
|
|
341
|
-
if (field.localized && locale)
|
|
380
|
+
if (field.localized && locale) {
|
|
381
|
+
delete table._locale;
|
|
382
|
+
}
|
|
342
383
|
ref[refKey] = traverseFields({
|
|
343
384
|
adapter,
|
|
344
385
|
blocks,
|
|
@@ -351,7 +392,8 @@ export const traverseFields = ({ adapter, blocks, config, dataRef, deletions, fi
|
|
|
351
392
|
path: `${sanitizedPath}${field.name}`,
|
|
352
393
|
relationships,
|
|
353
394
|
table,
|
|
354
|
-
texts
|
|
395
|
+
texts,
|
|
396
|
+
withinArrayOrBlockLocale
|
|
355
397
|
});
|
|
356
398
|
if ('_order' in ref) {
|
|
357
399
|
delete ref._order;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/transform/read/traverseFields.ts"],"sourcesContent":["import type { Field, SanitizedConfig, TabAsField } from 'payload'\n\nimport { fieldAffectsData } from 'payload/shared'\n\nimport type { DrizzleAdapter } from '../../types.js'\nimport type { BlocksMap } from '../../utilities/createBlocksMap.js'\n\nimport { transformHasManyNumber } from './hasManyNumber.js'\nimport { transformHasManyText } from './hasManyText.js'\nimport { transformRelationship } from './relationship.js'\n\ntype TraverseFieldsArgs = {\n /**\n * The DB adapter\n */\n adapter: DrizzleAdapter\n /**\n * Pre-formatted blocks map\n */\n blocks: BlocksMap\n /**\n * The full Payload config\n */\n config: SanitizedConfig\n /**\n * The data reference to be mutated within this recursive function\n */\n dataRef: Record<string, unknown>\n /**\n * Data that needs to be removed from the result after all fields have populated\n */\n deletions: (() => void)[]\n /**\n * Column prefix can be built up by group and named tab fields\n */\n fieldPrefix: string\n /**\n * An array of Payload fields to traverse\n */\n fields: (Field | TabAsField)[]\n /**\n * All hasMany number fields, as returned by Drizzle, keyed on an object by field path\n */\n numbers: Record<string, Record<string, unknown>[]>\n /**\n * The current field path (in dot notation), used to merge in relationships\n */\n path: string\n /**\n * All related documents, as returned by Drizzle, keyed on an object by field path\n */\n relationships: Record<string, Record<string, unknown>[]>\n /**\n * Data structure representing the nearest table from db\n */\n table: Record<string, unknown>\n /**\n * All hasMany text fields, as returned by Drizzle, keyed on an object by field path\n */\n texts: Record<string, Record<string, unknown>[]>\n}\n\n// Traverse fields recursively, transforming data\n// for each field type into required Payload shape\nexport const traverseFields = <T extends Record<string, unknown>>({\n adapter,\n blocks,\n config,\n dataRef,\n deletions,\n fieldPrefix,\n fields,\n numbers,\n path,\n relationships,\n table,\n texts,\n}: TraverseFieldsArgs): T => {\n const sanitizedPath = path ? `${path}.` : path\n\n const formatted = fields.reduce((result, field) => {\n if (field.type === 'tabs') {\n traverseFields({\n adapter,\n blocks,\n config,\n dataRef,\n deletions,\n fieldPrefix,\n fields: field.tabs.map((tab) => ({ ...tab, type: 'tab' })),\n numbers,\n path,\n relationships,\n table,\n texts,\n })\n }\n\n if (\n field.type === 'collapsible' ||\n field.type === 'row' ||\n (field.type === 'tab' && !('name' in field))\n ) {\n traverseFields({\n adapter,\n blocks,\n config,\n dataRef,\n deletions,\n fieldPrefix,\n fields: field.fields,\n numbers,\n path,\n relationships,\n table,\n texts,\n })\n }\n\n if (fieldAffectsData(field)) {\n const fieldName = `${fieldPrefix || ''}${field.name}`\n const fieldData = table[fieldName]\n const localizedFieldData = {}\n const valuesToTransform: {\n ref: Record<string, unknown>\n table: Record<string, unknown>\n }[] = []\n\n if (fieldPrefix) {\n deletions.push(() => delete table[fieldName])\n }\n\n if (field.type === 'array') {\n if (Array.isArray(fieldData)) {\n if (field.localized) {\n result[field.name] = fieldData.reduce((arrayResult, row) => {\n if (typeof row._locale === 'string') {\n if (!arrayResult[row._locale]) arrayResult[row._locale] = []\n const locale = row._locale\n const data = {}\n delete row._locale\n if (row._uuid) {\n row.id = row._uuid\n delete row._uuid\n }\n\n const rowResult = traverseFields<T>({\n adapter,\n blocks,\n config,\n dataRef: data,\n deletions,\n fieldPrefix: '',\n fields: field.fields,\n numbers,\n path: `${sanitizedPath}${field.name}.${row._order - 1}`,\n relationships,\n table: row,\n texts,\n })\n\n if ('_order' in rowResult) {\n delete rowResult._order\n }\n\n arrayResult[locale].push(rowResult)\n }\n\n return arrayResult\n }, {})\n } else {\n result[field.name] = fieldData.map((row, i) => {\n if (row._uuid) {\n row.id = row._uuid\n delete row._uuid\n }\n\n if ('_order' in row) {\n delete row._order\n }\n\n return traverseFields<T>({\n adapter,\n blocks,\n config,\n dataRef: row,\n deletions,\n fieldPrefix: '',\n fields: field.fields,\n numbers,\n path: `${sanitizedPath}${field.name}.${i}`,\n relationships,\n table: row,\n texts,\n })\n })\n }\n }\n\n return result\n }\n\n if (field.type === 'blocks') {\n const blockFieldPath = `${sanitizedPath}${field.name}`\n\n if (Array.isArray(blocks[blockFieldPath])) {\n if (field.localized) {\n result[field.name] = {}\n\n blocks[blockFieldPath].forEach((row) => {\n if (row._uuid) {\n row.id = row._uuid\n delete row._uuid\n }\n if (typeof row._locale === 'string') {\n if (!result[field.name][row._locale]) result[field.name][row._locale] = []\n result[field.name][row._locale].push(row)\n delete row._locale\n }\n })\n\n Object.entries(result[field.name]).forEach(([locale, localizedBlocks]) => {\n result[field.name][locale] = localizedBlocks.map((row) => {\n const block = field.blocks.find(({ slug }) => slug === row.blockType)\n\n if (block) {\n const blockResult = traverseFields<T>({\n adapter,\n blocks,\n config,\n dataRef: row,\n deletions,\n fieldPrefix: '',\n fields: block.fields,\n numbers,\n path: `${blockFieldPath}.${row._order - 1}`,\n relationships,\n table: row,\n texts,\n })\n\n delete blockResult._order\n return blockResult\n }\n\n return {}\n })\n })\n } else {\n result[field.name] = blocks[blockFieldPath].map((row, i) => {\n delete row._order\n if (row._uuid) {\n row.id = row._uuid\n delete row._uuid\n }\n const block = field.blocks.find(({ slug }) => slug === row.blockType)\n\n if (block) {\n return traverseFields<T>({\n adapter,\n blocks,\n config,\n dataRef: row,\n deletions,\n fieldPrefix: '',\n fields: block.fields,\n numbers,\n path: `${blockFieldPath}.${i}`,\n relationships,\n table: row,\n texts,\n })\n }\n\n return {}\n })\n }\n }\n\n return result\n }\n\n if (field.type === 'relationship' || field.type === 'upload') {\n if (typeof field.relationTo === 'string' && !('hasMany' in field && field.hasMany)) {\n if (\n field.localized &&\n config.localization &&\n config.localization.locales &&\n Array.isArray(table?._locales)\n ) {\n table._locales.forEach((localeRow) => {\n result[field.name] = { [localeRow._locale]: localeRow[fieldName] }\n })\n } else {\n valuesToTransform.push({ ref: result, table })\n }\n } else {\n const relationPathMatch = relationships[`${sanitizedPath}${field.name}`]\n if (!relationPathMatch) {\n if ('hasMany' in field && field.hasMany) {\n if (field.localized && config.localization && config.localization.locales) {\n result[field.name] = {\n [config.localization.defaultLocale]: [],\n }\n } else {\n result[field.name] = []\n }\n }\n\n return result\n }\n\n if (field.localized) {\n result[field.name] = {}\n const relationsByLocale: Record<string, Record<string, unknown>[]> = {}\n\n relationPathMatch.forEach((row) => {\n if (typeof row.locale === 'string') {\n if (!relationsByLocale[row.locale]) relationsByLocale[row.locale] = []\n relationsByLocale[row.locale].push(row)\n }\n })\n\n Object.entries(relationsByLocale).forEach(([locale, relations]) => {\n transformRelationship({\n field,\n locale,\n ref: result,\n relations,\n })\n })\n } else {\n transformRelationship({\n field,\n ref: result,\n relations: relationPathMatch,\n })\n }\n return result\n }\n }\n\n if (field.type === 'text' && field?.hasMany) {\n const textPathMatch = texts[`${sanitizedPath}${field.name}`]\n if (!textPathMatch) return result\n\n if (field.localized) {\n result[field.name] = {}\n const textsByLocale: Record<string, Record<string, unknown>[]> = {}\n\n textPathMatch.forEach((row) => {\n if (typeof row.locale === 'string') {\n if (!textsByLocale[row.locale]) textsByLocale[row.locale] = []\n textsByLocale[row.locale].push(row)\n }\n })\n\n Object.entries(textsByLocale).forEach(([locale, texts]) => {\n transformHasManyText({\n field,\n locale,\n ref: result,\n textRows: texts,\n })\n })\n } else {\n transformHasManyText({\n field,\n ref: result,\n textRows: textPathMatch,\n })\n }\n\n return result\n }\n\n if (field.type === 'number' && field.hasMany) {\n const numberPathMatch = numbers[`${sanitizedPath}${field.name}`]\n if (!numberPathMatch) return result\n\n if (field.localized) {\n result[field.name] = {}\n const numbersByLocale: Record<string, Record<string, unknown>[]> = {}\n\n numberPathMatch.forEach((row) => {\n if (typeof row.locale === 'string') {\n if (!numbersByLocale[row.locale]) numbersByLocale[row.locale] = []\n numbersByLocale[row.locale].push(row)\n }\n })\n\n Object.entries(numbersByLocale).forEach(([locale, numbers]) => {\n transformHasManyNumber({\n field,\n locale,\n numberRows: numbers,\n ref: result,\n })\n })\n } else {\n transformHasManyNumber({\n field,\n numberRows: numberPathMatch,\n ref: result,\n })\n }\n\n return result\n }\n\n if (field.type === 'select' && field.hasMany) {\n if (Array.isArray(fieldData)) {\n if (field.localized) {\n result[field.name] = fieldData.reduce((selectResult, row) => {\n if (typeof row.locale === 'string') {\n if (!selectResult[row.locale]) selectResult[row.locale] = []\n selectResult[row.locale].push(row.value)\n }\n\n return selectResult\n }, {})\n } else {\n result[field.name] = fieldData.map(({ value }) => value)\n }\n }\n return result\n }\n\n if (field.localized && Array.isArray(table._locales)) {\n table._locales.forEach((localeRow) => {\n valuesToTransform.push({\n ref: localizedFieldData,\n table: {\n ...localeRow,\n },\n })\n })\n } else {\n valuesToTransform.push({ ref: result, table })\n }\n\n valuesToTransform.forEach(({ ref, table }) => {\n const fieldData = table[`${fieldPrefix || ''}${field.name}`]\n const locale = table?._locale\n let val = fieldData\n\n switch (field.type) {\n case 'tab':\n case 'group': {\n const groupFieldPrefix = `${fieldPrefix || ''}${field.name}_`\n const groupData = {}\n const locale = table._locale as string\n const refKey = field.localized && locale ? locale : field.name\n\n if (field.localized && locale) delete table._locale\n ref[refKey] = traverseFields<Record<string, unknown>>({\n adapter,\n blocks,\n config,\n dataRef: groupData as Record<string, unknown>,\n deletions,\n fieldPrefix: groupFieldPrefix,\n fields: field.fields,\n numbers,\n path: `${sanitizedPath}${field.name}`,\n relationships,\n table,\n texts,\n })\n\n if ('_order' in ref) {\n delete ref._order\n }\n\n return\n }\n\n case 'text': {\n if (typeof fieldData === 'string') {\n val = String(fieldData)\n }\n\n break\n }\n\n case 'number': {\n if (typeof fieldData === 'string') {\n val = Number.parseFloat(fieldData)\n }\n\n break\n }\n\n case 'date': {\n if (typeof fieldData === 'string') {\n val = new Date(fieldData).toISOString()\n }\n\n break\n }\n\n case 'relationship':\n case 'upload': {\n if (\n val &&\n typeof field.relationTo === 'string' &&\n adapter.payload.collections[field.relationTo].customIDType === 'number'\n ) {\n val = Number(val)\n }\n\n break\n }\n\n default: {\n break\n }\n }\n if (typeof locale === 'string') {\n ref[locale] = val\n } else {\n result[field.name] = val\n }\n })\n\n if (Object.keys(localizedFieldData).length > 0) {\n result[field.name] = localizedFieldData\n }\n\n return result\n }\n\n return result\n }, dataRef)\n\n if (Array.isArray(table._locales)) {\n deletions.push(() => delete table._locales)\n }\n\n return formatted as T\n}\n"],"names":["fieldAffectsData","transformHasManyNumber","transformHasManyText","transformRelationship","traverseFields","adapter","blocks","config","dataRef","deletions","fieldPrefix","fields","numbers","path","relationships","table","texts","sanitizedPath","formatted","reduce","result","field","type","tabs","map","tab","fieldName","name","fieldData","localizedFieldData","valuesToTransform","push","Array","isArray","localized","arrayResult","row","_locale","locale","data","_uuid","id","rowResult","_order","i","blockFieldPath","forEach","Object","entries","localizedBlocks","block","find","slug","blockType","blockResult","relationTo","hasMany","localization","locales","_locales","localeRow","ref","relationPathMatch","defaultLocale","relationsByLocale","relations","textPathMatch","textsByLocale","textRows","numberPathMatch","numbersByLocale","numberRows","selectResult","value","val","groupFieldPrefix","groupData","refKey","String","Number","parseFloat","Date","toISOString","payload","collections","customIDType","keys","length"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ,iBAAgB;AAKjD,SAASC,sBAAsB,QAAQ,qBAAoB;AAC3D,SAASC,oBAAoB,QAAQ,mBAAkB;AACvD,SAASC,qBAAqB,QAAQ,oBAAmB;AAqDzD,iDAAiD;AACjD,kDAAkD;AAClD,OAAO,MAAMC,iBAAiB,CAAoC,EAChEC,OAAO,EACPC,MAAM,EACNC,MAAM,EACNC,OAAO,EACPC,SAAS,EACTC,WAAW,EACXC,MAAM,EACNC,OAAO,EACPC,IAAI,EACJC,aAAa,EACbC,KAAK,EACLC,KAAK,EACc;IACnB,MAAMC,gBAAgBJ,OAAO,CAAC,EAAEA,KAAK,CAAC,CAAC,GAAGA;IAE1C,MAAMK,YAAYP,OAAOQ,MAAM,CAAC,CAACC,QAAQC;QACvC,IAAIA,MAAMC,IAAI,KAAK,QAAQ;YACzBlB,eAAe;gBACbC;gBACAC;gBACAC;gBACAC;gBACAC;gBACAC;gBACAC,QAAQU,MAAME,IAAI,CAACC,GAAG,CAAC,CAACC,MAAS,CAAA;wBAAE,GAAGA,GAAG;wBAAEH,MAAM;oBAAM,CAAA;gBACvDV;gBACAC;gBACAC;gBACAC;gBACAC;YACF;QACF;QAEA,IACEK,MAAMC,IAAI,KAAK,iBACfD,MAAMC,IAAI,KAAK,SACdD,MAAMC,IAAI,KAAK,SAAS,CAAE,CAAA,UAAUD,KAAI,GACzC;YACAjB,eAAe;gBACbC;gBACAC;gBACAC;gBACAC;gBACAC;gBACAC;gBACAC,QAAQU,MAAMV,MAAM;gBACpBC;gBACAC;gBACAC;gBACAC;gBACAC;YACF;QACF;QAEA,IAAIhB,iBAAiBqB,QAAQ;YAC3B,MAAMK,YAAY,CAAC,EAAEhB,eAAe,GAAG,EAAEW,MA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C,OAAO,CAAClB,MAAM4C,QAAQ,GAAG;QACjClD,UAAUsB,IAAI,CAAC,IAAM,OAAOhB,MAAM4C,QAAQ;IAC5C;IAEA,OAAOzC;AACT,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/transform/read/traverseFields.ts"],"sourcesContent":["import type { Field, SanitizedConfig, TabAsField } from 'payload'\n\nimport { fieldAffectsData } from 'payload/shared'\n\nimport type { DrizzleAdapter } from '../../types.js'\nimport type { BlocksMap } from '../../utilities/createBlocksMap.js'\n\nimport { transformHasManyNumber } from './hasManyNumber.js'\nimport { transformHasManyText } from './hasManyText.js'\nimport { transformRelationship } from './relationship.js'\n\ntype TraverseFieldsArgs = {\n /**\n * The DB adapter\n */\n adapter: DrizzleAdapter\n /**\n * Pre-formatted blocks map\n */\n blocks: BlocksMap\n /**\n * The full Payload config\n */\n config: SanitizedConfig\n /**\n * The data reference to be mutated within this recursive function\n */\n dataRef: Record<string, unknown>\n /**\n * Data that needs to be removed from the result after all fields have populated\n */\n deletions: (() => void)[]\n /**\n * Column prefix can be built up by group and named tab fields\n */\n fieldPrefix: string\n /**\n * An array of Payload fields to traverse\n */\n fields: (Field | TabAsField)[]\n /**\n * All hasMany number fields, as returned by Drizzle, keyed on an object by field path\n */\n numbers: Record<string, Record<string, unknown>[]>\n /**\n * The current field path (in dot notation), used to merge in relationships\n */\n path: string\n /**\n * All related documents, as returned by Drizzle, keyed on an object by field path\n */\n relationships: Record<string, Record<string, unknown>[]>\n /**\n * Data structure representing the nearest table from db\n */\n table: Record<string, unknown>\n /**\n * All hasMany text fields, as returned by Drizzle, keyed on an object by field path\n */\n texts: Record<string, Record<string, unknown>[]>\n /**\n * Set to a locale if this group of fields is within a localized array or block.\n */\n withinArrayOrBlockLocale?: string\n}\n\n// Traverse fields recursively, transforming data\n// for each field type into required Payload shape\nexport const traverseFields = <T extends Record<string, unknown>>({\n adapter,\n blocks,\n config,\n dataRef,\n deletions,\n fieldPrefix,\n fields,\n numbers,\n path,\n relationships,\n table,\n texts,\n withinArrayOrBlockLocale,\n}: TraverseFieldsArgs): T => {\n const sanitizedPath = path ? `${path}.` : path\n\n const formatted = fields.reduce((result, field) => {\n if (field.type === 'tabs') {\n traverseFields({\n adapter,\n blocks,\n config,\n dataRef,\n deletions,\n fieldPrefix,\n fields: field.tabs.map((tab) => ({ ...tab, type: 'tab' })),\n numbers,\n path,\n relationships,\n table,\n texts,\n withinArrayOrBlockLocale,\n })\n }\n\n if (\n field.type === 'collapsible' ||\n field.type === 'row' ||\n (field.type === 'tab' && !('name' in field))\n ) {\n traverseFields({\n adapter,\n blocks,\n config,\n dataRef,\n deletions,\n fieldPrefix,\n fields: field.fields,\n numbers,\n path,\n relationships,\n table,\n texts,\n withinArrayOrBlockLocale,\n })\n }\n\n if (fieldAffectsData(field)) {\n const fieldName = `${fieldPrefix || ''}${field.name}`\n const fieldData = table[fieldName]\n const localizedFieldData = {}\n const valuesToTransform: {\n ref: Record<string, unknown>\n table: Record<string, unknown>\n }[] = []\n\n if (fieldPrefix) {\n deletions.push(() => delete table[fieldName])\n }\n\n if (field.type === 'array') {\n if (Array.isArray(fieldData)) {\n if (field.localized) {\n result[field.name] = fieldData.reduce((arrayResult, row) => {\n if (typeof row._locale === 'string') {\n if (!arrayResult[row._locale]) {\n arrayResult[row._locale] = []\n }\n const locale = row._locale\n const data = {}\n delete row._locale\n if (row._uuid) {\n row.id = row._uuid\n delete row._uuid\n }\n\n const rowResult = traverseFields<T>({\n adapter,\n blocks,\n config,\n dataRef: data,\n deletions,\n fieldPrefix: '',\n fields: field.fields,\n numbers,\n path: `${sanitizedPath}${field.name}.${row._order - 1}`,\n relationships,\n table: row,\n texts,\n withinArrayOrBlockLocale: locale,\n })\n\n if ('_order' in rowResult) {\n delete rowResult._order\n }\n\n arrayResult[locale].push(rowResult)\n }\n\n return arrayResult\n }, {})\n } else {\n result[field.name] = fieldData.reduce((acc, row, i) => {\n if (row._uuid) {\n row.id = row._uuid\n delete row._uuid\n }\n\n if ('_order' in row) {\n delete row._order\n }\n\n if (\n !withinArrayOrBlockLocale ||\n (withinArrayOrBlockLocale && withinArrayOrBlockLocale === row._locale)\n ) {\n if (row._locale) {\n delete row._locale\n }\n\n acc.push(\n traverseFields<T>({\n adapter,\n blocks,\n config,\n dataRef: row,\n deletions,\n fieldPrefix: '',\n fields: field.fields,\n numbers,\n path: `${sanitizedPath}${field.name}.${i}`,\n relationships,\n table: row,\n texts,\n withinArrayOrBlockLocale,\n }),\n )\n }\n\n return acc\n }, [])\n }\n }\n\n return result\n }\n\n if (field.type === 'blocks') {\n const blockFieldPath = `${sanitizedPath}${field.name}`\n\n if (Array.isArray(blocks[blockFieldPath])) {\n if (field.localized) {\n result[field.name] = {}\n\n blocks[blockFieldPath].forEach((row) => {\n if (row._uuid) {\n row.id = row._uuid\n delete row._uuid\n }\n if (typeof row._locale === 'string') {\n if (!result[field.name][row._locale]) {\n result[field.name][row._locale] = []\n }\n result[field.name][row._locale].push(row)\n delete row._locale\n }\n })\n\n Object.entries(result[field.name]).forEach(([locale, localizedBlocks]) => {\n result[field.name][locale] = localizedBlocks.map((row) => {\n const block = field.blocks.find(({ slug }) => slug === row.blockType)\n\n if (block) {\n const blockResult = traverseFields<T>({\n adapter,\n blocks,\n config,\n dataRef: row,\n deletions,\n fieldPrefix: '',\n fields: block.fields,\n numbers,\n path: `${blockFieldPath}.${row._order - 1}`,\n relationships,\n table: row,\n texts,\n withinArrayOrBlockLocale: locale,\n })\n\n delete blockResult._order\n return blockResult\n }\n\n return {}\n })\n })\n } else {\n result[field.name] = blocks[blockFieldPath].reduce((acc, row, i) => {\n delete row._order\n if (row._uuid) {\n row.id = row._uuid\n delete row._uuid\n }\n const block = field.blocks.find(({ slug }) => slug === row.blockType)\n\n if (block) {\n if (\n !withinArrayOrBlockLocale ||\n (withinArrayOrBlockLocale && withinArrayOrBlockLocale === row._locale)\n ) {\n if (row._locale) {\n delete row._locale\n }\n\n acc.push(\n traverseFields<T>({\n adapter,\n blocks,\n config,\n dataRef: row,\n deletions,\n fieldPrefix: '',\n fields: block.fields,\n numbers,\n path: `${blockFieldPath}.${i}`,\n relationships,\n table: row,\n texts,\n withinArrayOrBlockLocale,\n }),\n )\n\n return acc\n }\n } else {\n acc.push({})\n }\n\n return acc\n }, [])\n }\n }\n\n return result\n }\n\n if (field.type === 'relationship' || field.type === 'upload') {\n if (typeof field.relationTo === 'string' && !('hasMany' in field && field.hasMany)) {\n if (\n field.localized &&\n config.localization &&\n config.localization.locales &&\n Array.isArray(table?._locales)\n ) {\n table._locales.forEach((localeRow) => {\n result[field.name] = { [localeRow._locale]: localeRow[fieldName] }\n })\n } else {\n valuesToTransform.push({ ref: result, table })\n }\n } else {\n const relationPathMatch = relationships[`${sanitizedPath}${field.name}`]\n if (!relationPathMatch) {\n if ('hasMany' in field && field.hasMany) {\n if (field.localized && config.localization && config.localization.locales) {\n result[field.name] = {\n [config.localization.defaultLocale]: [],\n }\n } else {\n result[field.name] = []\n }\n }\n\n return result\n }\n\n if (field.localized) {\n result[field.name] = {}\n const relationsByLocale: Record<string, Record<string, unknown>[]> = {}\n\n relationPathMatch.forEach((row) => {\n if (typeof row.locale === 'string') {\n if (!relationsByLocale[row.locale]) {\n relationsByLocale[row.locale] = []\n }\n relationsByLocale[row.locale].push(row)\n }\n })\n\n Object.entries(relationsByLocale).forEach(([locale, relations]) => {\n transformRelationship({\n field,\n locale,\n ref: result,\n relations,\n })\n })\n } else {\n transformRelationship({\n field,\n ref: result,\n relations: relationPathMatch,\n withinArrayOrBlockLocale,\n })\n }\n return result\n }\n }\n\n if (field.type === 'text' && field?.hasMany) {\n const textPathMatch = texts[`${sanitizedPath}${field.name}`]\n if (!textPathMatch) {\n return result\n }\n\n if (field.localized) {\n result[field.name] = {}\n const textsByLocale: Record<string, Record<string, unknown>[]> = {}\n\n textPathMatch.forEach((row) => {\n if (typeof row.locale === 'string') {\n if (!textsByLocale[row.locale]) {\n textsByLocale[row.locale] = []\n }\n textsByLocale[row.locale].push(row)\n }\n })\n\n Object.entries(textsByLocale).forEach(([locale, texts]) => {\n transformHasManyText({\n field,\n locale,\n ref: result,\n textRows: texts,\n })\n })\n } else {\n transformHasManyText({\n field,\n ref: result,\n textRows: textPathMatch,\n withinArrayOrBlockLocale,\n })\n }\n\n return result\n }\n\n if (field.type === 'number' && field.hasMany) {\n const numberPathMatch = numbers[`${sanitizedPath}${field.name}`]\n if (!numberPathMatch) {\n return result\n }\n\n if (field.localized) {\n result[field.name] = {}\n const numbersByLocale: Record<string, Record<string, unknown>[]> = {}\n\n numberPathMatch.forEach((row) => {\n if (typeof row.locale === 'string') {\n if (!numbersByLocale[row.locale]) {\n numbersByLocale[row.locale] = []\n }\n numbersByLocale[row.locale].push(row)\n }\n })\n\n Object.entries(numbersByLocale).forEach(([locale, numbers]) => {\n transformHasManyNumber({\n field,\n locale,\n numberRows: numbers,\n ref: result,\n })\n })\n } else {\n transformHasManyNumber({\n field,\n numberRows: numberPathMatch,\n ref: result,\n withinArrayOrBlockLocale,\n })\n }\n\n return result\n }\n\n if (field.type === 'select' && field.hasMany) {\n if (Array.isArray(fieldData)) {\n if (field.localized) {\n result[field.name] = fieldData.reduce((selectResult, row) => {\n if (typeof row.locale === 'string') {\n if (!selectResult[row.locale]) {\n selectResult[row.locale] = []\n }\n selectResult[row.locale].push(row.value)\n }\n\n return selectResult\n }, {})\n } else {\n result[field.name] = fieldData.map(({ value }) => value)\n }\n }\n return result\n }\n\n if (field.localized && Array.isArray(table._locales)) {\n table._locales.forEach((localeRow) => {\n valuesToTransform.push({\n ref: localizedFieldData,\n table: {\n ...localeRow,\n },\n })\n })\n } else {\n valuesToTransform.push({ ref: result, table })\n }\n\n valuesToTransform.forEach(({ ref, table }) => {\n const fieldData = table[`${fieldPrefix || ''}${field.name}`]\n const locale = table?._locale\n let val = fieldData\n\n switch (field.type) {\n case 'tab':\n case 'group': {\n const groupFieldPrefix = `${fieldPrefix || ''}${field.name}_`\n const groupData = {}\n const locale = table._locale as string\n const refKey = field.localized && locale ? locale : field.name\n\n if (field.localized && locale) {\n delete table._locale\n }\n ref[refKey] = traverseFields<Record<string, unknown>>({\n adapter,\n blocks,\n config,\n dataRef: groupData as Record<string, unknown>,\n deletions,\n fieldPrefix: groupFieldPrefix,\n fields: field.fields,\n numbers,\n path: `${sanitizedPath}${field.name}`,\n relationships,\n table,\n texts,\n withinArrayOrBlockLocale,\n })\n\n if ('_order' in ref) {\n delete ref._order\n }\n\n return\n }\n\n case 'text': {\n if (typeof fieldData === 'string') {\n val = String(fieldData)\n }\n\n break\n }\n\n case 'number': {\n if (typeof fieldData === 'string') {\n val = Number.parseFloat(fieldData)\n }\n\n break\n }\n\n case 'date': {\n if (typeof fieldData === 'string') {\n val = new Date(fieldData).toISOString()\n }\n\n break\n }\n\n case 'relationship':\n case 'upload': {\n if (\n val &&\n typeof field.relationTo === 'string' &&\n adapter.payload.collections[field.relationTo].customIDType === 'number'\n ) {\n val = Number(val)\n }\n\n break\n }\n\n default: {\n break\n }\n }\n if (typeof locale === 'string') {\n ref[locale] = val\n } else {\n result[field.name] = val\n }\n })\n\n if (Object.keys(localizedFieldData).length > 0) {\n result[field.name] = localizedFieldData\n }\n\n return result\n }\n\n return result\n }, dataRef)\n\n if (Array.isArray(table._locales)) {\n deletions.push(() => delete table._locales)\n }\n\n return formatted as T\n}\n"],"names":["fieldAffectsData","transformHasManyNumber","transformHasManyText","transformRelationship","traverseFields","adapter","blocks","config","dataRef","deletions","fieldPrefix","fields","numbers","path","relationships","table","texts","withinArrayOrBlockLocale","sanitizedPath","formatted","reduce","result","field","type","tabs","map","tab","fieldName","name","fieldData","localizedFieldData","valuesToTransform","push","Array","isArray","localized","arrayResult","row","_locale","locale","data","_uuid","id","rowResult","_order","acc","i","blockFieldPath","forEach","Object","entries","localizedBlocks","block","find","slug","blockType","blockResult","relationTo","hasMany","localization","locales","_locales","localeRow","ref","relationPathMatch","defaultLocale","relationsByLocale","relations","textPathMatch","textsByLocale","textRows","numberPathMatch","numbersByLocale","numberRows","selectResult","value","val","groupFieldPrefix","groupData","refKey","String","Number","parseFloat","Date","toISOString","payload","collections","customIDType","keys","length"],"mappings":"AAEA,SAASA,gBAAgB,QAAQ,iBAAgB;AAKjD,SAASC,sBAAsB,QAAQ,qBAAoB;AAC3D,SAASC,oBAAoB,QAAQ,mBAAkB;AACvD,SAASC,qBAAqB,QAAQ,oBAAmB;AAyDzD,iDAAiD;AACjD,kDAAkD;AAClD,OAAO,MAAMC,iBAAiB,CAAoC,EAChEC,OAAO,EACPC,MAAM,EACNC,MAAM,EACNC,OAAO,EACPC,SAAS,EACTC,WAAW,EACXC,MAAM,EACNC,OAAO,EACPC,IAAI,EACJC,aAAa,EACbC,KAAK,EACLC,KAAK,EACLC,wBAAwB,EACL;IACnB,MAAMC,gBAAgBL,OAAO,CAAC,EAAEA,KAAK,CAAC,CAAC,GAAGA;IAE1C,MAAMM,YAAYR,OAAOS,MAAM,CAAC,CAACC,QAAQC;QACvC,IAAIA,MAAMC,IAAI,KAAK,QAAQ;YACzBnB,eAAe;gBACbC;gBACAC;gBACAC;gBACAC;gBACAC;gBACAC;gBACAC,QAAQW,MAAME,IAAI,CAACC,GAAG,CAAC,CAACC,MAAS,CAAA;wBAAE,GAAGA,GAAG;wBAAEH,MAAM;oBAAM,CAAA;gBACvDX;gBACAC;gBACAC;gBACAC;gBACAC;gBACAC;YACF;QACF;QAEA,IACEK,MAAMC,IAAI,KAAK,iBACfD,MAAMC,IAAI,KAAK,SACdD,MAAMC,IAAI,KAAK,SAAS,CAAE,CAAA,UAAUD,KAAI,GACzC;YACAlB,eAAe;gBACbC;gBACAC;gBACAC;gBACAC;gBACAC;gBACAC;gBACAC,QAAQW,MAAMX,MAAM;gBACpBC;gBACAC;gBACAC;gBACAC;gBACAC;gBACAC;YACF;QACF;QAEA,IAAIjB,iBAAiBsB,QAAQ;YAC3B,MAAMK,YAAY,CAAC,EAAEjB,eAAe,GAAG,EAAEY,MAAMM,IAAI,CAAC,CAAC;YACrD,M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4BACvC;4BAEA;wBACF;oBAEA,KAAK;oBACL,KAAK;wBAAU;4BACb,IACER,OACA,OAAOtD,MAAMmC,UAAU,KAAK,YAC5BpD,QAAQgF,OAAO,CAACC,WAAW,CAAChE,MAAMmC,UAAU,CAAC,CAAC8B,YAAY,KAAK,UAC/D;gCACAX,MAAMK,OAAOL;4BACf;4BAEA;wBACF;oBAEA;wBAAS;4BACP;wBACF;gBACF;gBACA,IAAI,OAAOrC,WAAW,UAAU;oBAC9BwB,GAAG,CAACxB,OAAO,GAAGqC;gBAChB,OAAO;oBACLvD,MAAM,CAACC,MAAMM,IAAI,CAAC,GAAGgD;gBACvB;YACF;YAEA,IAAI3B,OAAOuC,IAAI,CAAC1D,oBAAoB2D,MAAM,GAAG,GAAG;gBAC9CpE,MAAM,CAACC,MAAMM,IAAI,CAAC,GAAGE;YACvB;YAEA,OAAOT;QACT;QAEA,OAAOA;IACT,GAAGb;IAEH,IAAIyB,MAAMC,OAAO,CAACnB,MAAM8C,QAAQ,GAAG;QACjCpD,UAAUuB,IAAI,CAAC,IAAM,OAAOjB,MAAM8C,QAAQ;IAC5C;IAEA,OAAO1C;AACT,EAAC"}
|
|
@@ -20,7 +20,12 @@ type Args = {
|
|
|
20
20
|
[tableName: string]: Record<string, unknown>[];
|
|
21
21
|
};
|
|
22
22
|
texts: Record<string, unknown>[];
|
|
23
|
+
/**
|
|
24
|
+
* Set to a locale code if this set of fields is traversed within a
|
|
25
|
+
* localized array or block field
|
|
26
|
+
*/
|
|
27
|
+
withinArrayOrBlockLocale?: string;
|
|
23
28
|
};
|
|
24
|
-
export declare const transformArray: ({ adapter, arrayTableName, baseTableName, blocks, blocksToDelete, data, field, locale, numbers, path, relationships, relationshipsToDelete, selects, texts, }: Args) => ArrayRowToInsert[];
|
|
29
|
+
export declare const transformArray: ({ adapter, arrayTableName, baseTableName, blocks, blocksToDelete, data, field, locale, numbers, path, relationships, relationshipsToDelete, selects, texts, withinArrayOrBlockLocale, }: Args) => ArrayRowToInsert[];
|
|
25
30
|
export {};
|
|
26
31
|
//# sourceMappingURL=array.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../../src/transform/write/array.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../../src/transform/write/array.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEzC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAK1F,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,cAAc,CAAA;IACvB,cAAc,EAAE,MAAM,CAAA;IACtB,aAAa,EAAE,MAAM,CAAA;IACrB,MAAM,EAAE;QACN,CAAC,SAAS,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAAA;KACxC,CAAA;IACD,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAC3B,IAAI,EAAE,OAAO,CAAA;IACb,KAAK,EAAE,UAAU,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;IAClC,IAAI,EAAE,MAAM,CAAA;IACZ,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;IACxC,qBAAqB,EAAE,oBAAoB,EAAE,CAAA;IAC7C,OAAO,EAAE;QACP,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;KAC/C,CAAA;IACD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;IAChC;;;OAGG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAA;CAClC,CAAA;AAED,eAAO,MAAM,cAAc,4LAgBxB,IAAI,uBAkEN,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { isArrayOfRows } from '../../utilities/isArrayOfRows.js';
|
|
2
2
|
import { traverseFields } from './traverseFields.js';
|
|
3
|
-
export const transformArray = ({ adapter, arrayTableName, baseTableName, blocks, blocksToDelete, data, field, locale, numbers, path, relationships, relationshipsToDelete, selects, texts })=>{
|
|
3
|
+
export const transformArray = ({ adapter, arrayTableName, baseTableName, blocks, blocksToDelete, data, field, locale, numbers, path, relationships, relationshipsToDelete, selects, texts, withinArrayOrBlockLocale })=>{
|
|
4
4
|
const newRows = [];
|
|
5
5
|
const hasUUID = adapter.tables[arrayTableName]._uuid;
|
|
6
6
|
if (isArrayOfRows(data)) {
|
|
@@ -29,6 +29,9 @@ export const transformArray = ({ adapter, arrayTableName, baseTableName, blocks,
|
|
|
29
29
|
if (field.localized) {
|
|
30
30
|
newRow.row._locale = locale;
|
|
31
31
|
}
|
|
32
|
+
if (withinArrayOrBlockLocale) {
|
|
33
|
+
newRow.row._locale = withinArrayOrBlockLocale;
|
|
34
|
+
}
|
|
32
35
|
traverseFields({
|
|
33
36
|
adapter,
|
|
34
37
|
arrays: newRow.arrays,
|
|
@@ -47,7 +50,8 @@ export const transformArray = ({ adapter, arrayTableName, baseTableName, blocks,
|
|
|
47
50
|
relationshipsToDelete,
|
|
48
51
|
row: newRow.row,
|
|
49
52
|
selects,
|
|
50
|
-
texts
|
|
53
|
+
texts,
|
|
54
|
+
withinArrayOrBlockLocale
|
|
51
55
|
});
|
|
52
56
|
newRows.push(newRow);
|
|
53
57
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/transform/write/array.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../src/transform/write/array.ts"],"sourcesContent":["import type { ArrayField } from 'payload'\n\nimport type { DrizzleAdapter } from '../../types.js'\nimport type { ArrayRowToInsert, BlockRowToInsert, RelationshipToDelete } from './types.js'\n\nimport { isArrayOfRows } from '../../utilities/isArrayOfRows.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype Args = {\n adapter: DrizzleAdapter\n arrayTableName: string\n baseTableName: string\n blocks: {\n [blockType: string]: BlockRowToInsert[]\n }\n blocksToDelete: Set<string>\n data: unknown\n field: ArrayField\n locale?: string\n numbers: Record<string, unknown>[]\n path: string\n relationships: Record<string, unknown>[]\n relationshipsToDelete: RelationshipToDelete[]\n selects: {\n [tableName: string]: Record<string, unknown>[]\n }\n texts: Record<string, unknown>[]\n /**\n * Set to a locale code if this set of fields is traversed within a\n * localized array or block field\n */\n withinArrayOrBlockLocale?: string\n}\n\nexport const transformArray = ({\n adapter,\n arrayTableName,\n baseTableName,\n blocks,\n blocksToDelete,\n data,\n field,\n locale,\n numbers,\n path,\n relationships,\n relationshipsToDelete,\n selects,\n texts,\n withinArrayOrBlockLocale,\n}: Args) => {\n const newRows: ArrayRowToInsert[] = []\n\n const hasUUID = adapter.tables[arrayTableName]._uuid\n\n if (isArrayOfRows(data)) {\n data.forEach((arrayRow, i) => {\n const newRow: ArrayRowToInsert = {\n arrays: {},\n locales: {},\n row: {\n _order: i + 1,\n },\n }\n\n // If we have declared a _uuid field on arrays,\n // that means the ID has to be unique,\n // and our ids within arrays are not unique.\n // So move the ID to a uuid field for storage\n // and allow the database to generate a serial id automatically\n if (hasUUID) {\n newRow.row._uuid = arrayRow.id\n delete arrayRow.id\n }\n\n if (locale) {\n newRow.locales[locale] = {\n _locale: locale,\n }\n }\n\n if (field.localized) {\n newRow.row._locale = locale\n }\n\n if (withinArrayOrBlockLocale) {\n newRow.row._locale = withinArrayOrBlockLocale\n }\n\n traverseFields({\n adapter,\n arrays: newRow.arrays,\n baseTableName,\n blocks,\n blocksToDelete,\n columnPrefix: '',\n data: arrayRow,\n fieldPrefix: '',\n fields: field.fields,\n locales: newRow.locales,\n numbers,\n parentTableName: arrayTableName,\n path: `${path || ''}${field.name}.${i}.`,\n relationships,\n relationshipsToDelete,\n row: newRow.row,\n selects,\n texts,\n withinArrayOrBlockLocale,\n })\n\n newRows.push(newRow)\n })\n }\n\n return newRows\n}\n"],"names":["isArrayOfRows","traverseFields","transformArray","adapter","arrayTableName","baseTableName","blocks","blocksToDelete","data","field","locale","numbers","path","relationships","relationshipsToDelete","selects","texts","withinArrayOrBlockLocale","newRows","hasUUID","tables","_uuid","forEach","arrayRow","i","newRow","arrays","locales","row","_order","id","_locale","localized","columnPrefix","fieldPrefix","fields","parentTableName","name","push"],"mappings":"AAKA,SAASA,aAAa,QAAQ,mCAAkC;AAChE,SAASC,cAAc,QAAQ,sBAAqB;AA4BpD,OAAO,MAAMC,iBAAiB,CAAC,EAC7BC,OAAO,EACPC,cAAc,EACdC,aAAa,EACbC,MAAM,EACNC,cAAc,EACdC,IAAI,EACJC,KAAK,EACLC,MAAM,EACNC,OAAO,EACPC,IAAI,EACJC,aAAa,EACbC,qBAAqB,EACrBC,OAAO,EACPC,KAAK,EACLC,wBAAwB,EACnB;IACL,MAAMC,UAA8B,EAAE;IAEtC,MAAMC,UAAUhB,QAAQiB,MAAM,CAAChB,eAAe,CAACiB,KAAK;IAEpD,IAAIrB,cAAcQ,OAAO;QACvBA,KAAKc,OAAO,CAAC,CAACC,UAAUC;YACtB,MAAMC,SAA2B;gBAC/BC,QAAQ,CAAC;gBACTC,SAAS,CAAC;gBACVC,KAAK;oBACHC,QAAQL,IAAI;gBACd;YACF;YAEA,+CAA+C;YAC/C,sCAAsC;YACtC,4CAA4C;YAC5C,6CAA6C;YAC7C,+DAA+D;YAC/D,IAAIL,SAAS;gBACXM,OAAOG,GAAG,CAACP,KAAK,GAAGE,SAASO,EAAE;gBAC9B,OAAOP,SAASO,EAAE;YACpB;YAEA,IAAIpB,QAAQ;gBACVe,OAAOE,OAAO,CAACjB,OAAO,GAAG;oBACvBqB,SAASrB;gBACX;YACF;YAEA,IAAID,MAAMuB,SAAS,EAAE;gBACnBP,OAAOG,GAAG,CAACG,OAAO,GAAGrB;YACvB;YAEA,IAAIO,0BAA0B;gBAC5BQ,OAAOG,GAAG,CAACG,OAAO,GAAGd;YACvB;YAEAhB,eAAe;gBACbE;gBACAuB,QAAQD,OAAOC,MAAM;gBACrBrB;gBACAC;gBACAC;gBACA0B,cAAc;gBACdzB,MAAMe;gBACNW,aAAa;gBACbC,QAAQ1B,MAAM0B,MAAM;gBACpBR,SAASF,OAAOE,OAAO;gBACvBhB;gBACAyB,iBAAiBhC;gBACjBQ,MAAM,CAAC,EAAEA,QAAQ,GAAG,EAAEH,MAAM4B,IAAI,CAAC,CAAC,EAAEb,EAAE,CAAC,CAAC;gBACxCX;gBACAC;gBACAc,KAAKH,OAAOG,GAAG;gBACfb;gBACAC;gBACAC;YACF;YAEAC,QAAQoB,IAAI,CAACb;QACf;IACF;IAEA,OAAOP;AACT,EAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BlocksField } from 'payload';
|
|
2
2
|
import type { DrizzleAdapter } from '../../types.js';
|
|
3
3
|
import type { BlockRowToInsert, RelationshipToDelete } from './types.js';
|
|
4
4
|
type Args = {
|
|
@@ -9,7 +9,7 @@ type Args = {
|
|
|
9
9
|
};
|
|
10
10
|
blocksToDelete: Set<string>;
|
|
11
11
|
data: Record<string, unknown>[];
|
|
12
|
-
field:
|
|
12
|
+
field: BlocksField;
|
|
13
13
|
locale?: string;
|
|
14
14
|
numbers: Record<string, unknown>[];
|
|
15
15
|
path: string;
|
|
@@ -19,7 +19,12 @@ type Args = {
|
|
|
19
19
|
[tableName: string]: Record<string, unknown>[];
|
|
20
20
|
};
|
|
21
21
|
texts: Record<string, unknown>[];
|
|
22
|
+
/**
|
|
23
|
+
* Set to a locale code if this set of fields is traversed within a
|
|
24
|
+
* localized array or block field
|
|
25
|
+
*/
|
|
26
|
+
withinArrayOrBlockLocale?: string;
|
|
22
27
|
};
|
|
23
|
-
export declare const transformBlocks: ({ adapter, baseTableName, blocks, blocksToDelete, data, field, locale, numbers, path, relationships, relationshipsToDelete, selects, texts, }: Args) => void;
|
|
28
|
+
export declare const transformBlocks: ({ adapter, baseTableName, blocks, blocksToDelete, data, field, locale, numbers, path, relationships, relationshipsToDelete, selects, texts, withinArrayOrBlockLocale, }: Args) => void;
|
|
24
29
|
export {};
|
|
25
30
|
//# sourceMappingURL=blocks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../../../src/transform/write/blocks.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../../../src/transform/write/blocks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAI1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAIxE,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,cAAc,CAAA;IACvB,aAAa,EAAE,MAAM,CAAA;IACrB,MAAM,EAAE;QACN,CAAC,SAAS,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAAA;KACxC,CAAA;IACD,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAC3B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;IAC/B,KAAK,EAAE,WAAW,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;IAClC,IAAI,EAAE,MAAM,CAAA;IACZ,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;IACxC,qBAAqB,EAAE,oBAAoB,EAAE,CAAA;IAC7C,OAAO,EAAE;QACP,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;KAC/C,CAAA;IACD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;IAChC;;;OAGG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAA;CAClC,CAAA;AACD,eAAO,MAAM,eAAe,4KAezB,IAAI,SAqEN,CAAA"}
|