@payloadcms/drizzle 3.0.0-canary.518fabe → 3.0.0-canary.51be7be
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.js +1 -1
- package/dist/count.js.map +1 -1
- package/dist/createGlobalVersion.d.ts +1 -1
- package/dist/createGlobalVersion.d.ts.map +1 -1
- package/dist/createGlobalVersion.js +6 -2
- package/dist/createGlobalVersion.js.map +1 -1
- package/dist/createVersion.d.ts +1 -1
- package/dist/createVersion.d.ts.map +1 -1
- package/dist/createVersion.js +18 -13
- package/dist/createVersion.js.map +1 -1
- package/dist/deleteOne.d.ts.map +1 -1
- package/dist/deleteOne.js +5 -3
- package/dist/deleteOne.js.map +1 -1
- package/dist/deleteVersions.js +1 -1
- package/dist/deleteVersions.js.map +1 -1
- package/dist/exports/postgres.d.ts +1 -0
- package/dist/exports/postgres.d.ts.map +1 -1
- package/dist/exports/postgres.js +1 -0
- package/dist/exports/postgres.js.map +1 -1
- package/dist/find/buildFindManyArgs.d.ts +9 -3
- package/dist/find/buildFindManyArgs.d.ts.map +1 -1
- package/dist/find/buildFindManyArgs.js +6 -1
- package/dist/find/buildFindManyArgs.js.map +1 -1
- package/dist/find/findMany.d.ts +1 -1
- package/dist/find/findMany.d.ts.map +1 -1
- package/dist/find/findMany.js +6 -3
- package/dist/find/findMany.js.map +1 -1
- package/dist/find/traverseFields.d.ts +6 -3
- package/dist/find/traverseFields.d.ts.map +1 -1
- package/dist/find/traverseFields.js +125 -2
- package/dist/find/traverseFields.js.map +1 -1
- package/dist/find.d.ts.map +1 -1
- package/dist/find.js +2 -1
- package/dist/find.js.map +1 -1
- package/dist/findGlobalVersions.js +1 -1
- package/dist/findGlobalVersions.js.map +1 -1
- package/dist/findOne.d.ts +1 -1
- package/dist/findOne.d.ts.map +1 -1
- package/dist/findOne.js +2 -1
- package/dist/findOne.js.map +1 -1
- package/dist/findVersions.js +1 -1
- package/dist/findVersions.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/migrateReset.js +1 -1
- package/dist/migrateReset.js.map +1 -1
- package/dist/postgres/countDistinct.d.ts.map +1 -1
- package/dist/postgres/countDistinct.js +3 -3
- package/dist/postgres/countDistinct.js.map +1 -1
- package/dist/postgres/createDatabase.d.ts +14 -0
- package/dist/postgres/createDatabase.d.ts.map +1 -0
- package/dist/postgres/createDatabase.js +76 -0
- package/dist/postgres/createDatabase.js.map +1 -0
- package/dist/postgres/defaultSnapshot.d.ts.map +1 -1
- package/dist/postgres/defaultSnapshot.js +2 -1
- package/dist/postgres/defaultSnapshot.js.map +1 -1
- package/dist/postgres/init.d.ts.map +1 -1
- package/dist/postgres/init.js +13 -3
- package/dist/postgres/init.js.map +1 -1
- package/dist/postgres/schema/build.d.ts +5 -2
- package/dist/postgres/schema/build.d.ts.map +1 -1
- package/dist/postgres/schema/build.js +34 -6
- package/dist/postgres/schema/build.js.map +1 -1
- package/dist/postgres/schema/createIndex.d.ts +2 -3
- package/dist/postgres/schema/createIndex.d.ts.map +1 -1
- package/dist/postgres/schema/createIndex.js +3 -3
- package/dist/postgres/schema/createIndex.js.map +1 -1
- package/dist/postgres/schema/traverseFields.d.ts +5 -2
- package/dist/postgres/schema/traverseFields.d.ts.map +1 -1
- package/dist/postgres/schema/traverseFields.js +73 -20
- package/dist/postgres/schema/traverseFields.js.map +1 -1
- package/dist/postgres/types.d.ts +33 -6
- package/dist/postgres/types.d.ts.map +1 -1
- package/dist/postgres/types.js.map +1 -1
- package/dist/queries/buildAndOrConditions.d.ts +1 -1
- package/dist/queries/buildAndOrConditions.d.ts.map +1 -1
- package/dist/queries/buildAndOrConditions.js +2 -2
- package/dist/queries/buildAndOrConditions.js.map +1 -1
- package/dist/queries/buildOrderBy.d.ts +18 -0
- package/dist/queries/buildOrderBy.d.ts.map +1 -0
- package/dist/queries/buildOrderBy.js +52 -0
- package/dist/queries/buildOrderBy.js.map +1 -0
- package/dist/queries/buildQuery.d.ts +5 -4
- package/dist/queries/buildQuery.d.ts.map +1 -1
- package/dist/queries/buildQuery.js +12 -47
- package/dist/queries/buildQuery.js.map +1 -1
- package/dist/queries/getTableColumnFromPath.d.ts +8 -3
- package/dist/queries/getTableColumnFromPath.d.ts.map +1 -1
- package/dist/queries/getTableColumnFromPath.js +63 -16
- package/dist/queries/getTableColumnFromPath.js.map +1 -1
- package/dist/queries/parseParams.d.ts +1 -1
- package/dist/queries/parseParams.d.ts.map +1 -1
- package/dist/queries/parseParams.js +32 -4
- package/dist/queries/parseParams.js.map +1 -1
- package/dist/queries/sanitizeQueryValue.d.ts +12 -1
- package/dist/queries/sanitizeQueryValue.d.ts.map +1 -1
- package/dist/queries/sanitizeQueryValue.js +66 -16
- package/dist/queries/sanitizeQueryValue.js.map +1 -1
- package/dist/queryDrafts.d.ts.map +1 -1
- package/dist/queryDrafts.js +2 -4
- package/dist/queryDrafts.js.map +1 -1
- package/dist/transform/read/index.d.ts +3 -2
- package/dist/transform/read/index.d.ts.map +1 -1
- package/dist/transform/read/index.js +2 -1
- package/dist/transform/read/index.js.map +1 -1
- package/dist/transform/read/traverseFields.d.ts +6 -2
- package/dist/transform/read/traverseFields.d.ts.map +1 -1
- package/dist/transform/read/traverseFields.js +80 -8
- package/dist/transform/read/traverseFields.js.map +1 -1
- package/dist/transform/write/traverseFields.d.ts.map +1 -1
- package/dist/transform/write/traverseFields.js +20 -3
- package/dist/transform/write/traverseFields.js.map +1 -1
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/update.d.ts.map +1 -1
- package/dist/update.js +3 -2
- package/dist/update.js.map +1 -1
- package/dist/updateGlobalVersion.js +2 -2
- package/dist/updateGlobalVersion.js.map +1 -1
- package/dist/updateVersion.js +2 -2
- package/dist/updateVersion.js.map +1 -1
- package/dist/upsertRow/index.d.ts +1 -1
- package/dist/upsertRow/index.d.ts.map +1 -1
- package/dist/upsertRow/index.js +4 -2
- package/dist/upsertRow/index.js.map +1 -1
- package/dist/upsertRow/insertArrays.d.ts.map +1 -1
- package/dist/upsertRow/insertArrays.js +4 -1
- package/dist/upsertRow/insertArrays.js.map +1 -1
- package/dist/upsertRow/types.d.ts +4 -1
- package/dist/upsertRow/types.d.ts.map +1 -1
- package/dist/upsertRow/types.js.map +1 -1
- package/dist/utilities/buildIndexName.d.ts +7 -0
- package/dist/utilities/buildIndexName.d.ts.map +1 -0
- package/dist/utilities/buildIndexName.js +14 -0
- package/dist/utilities/buildIndexName.js.map +1 -0
- package/dist/utilities/executeSchemaHooks.d.ts +24 -0
- package/dist/utilities/executeSchemaHooks.d.ts.map +1 -0
- package/dist/utilities/executeSchemaHooks.js +21 -0
- package/dist/utilities/executeSchemaHooks.js.map +1 -0
- package/dist/utilities/extendDrizzleTable.d.ts +19 -0
- package/dist/utilities/extendDrizzleTable.d.ts.map +1 -0
- package/dist/utilities/extendDrizzleTable.js +38 -0
- package/dist/utilities/extendDrizzleTable.js.map +1 -0
- package/dist/utilities/getCollectionIdType.d.ts +7 -0
- package/dist/utilities/getCollectionIdType.d.ts.map +1 -0
- package/dist/utilities/getCollectionIdType.js +11 -0
- package/dist/utilities/getCollectionIdType.js.map +1 -0
- package/dist/utilities/isPolymorphicRelationship.d.ts +6 -0
- package/dist/utilities/isPolymorphicRelationship.d.ts.map +1 -0
- package/dist/utilities/isPolymorphicRelationship.js +5 -0
- package/dist/utilities/isPolymorphicRelationship.js.map +1 -0
- package/package.json +6 -6
package/dist/queryDrafts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/queryDrafts.ts"],"sourcesContent":["import type { PayloadRequest, QueryDrafts, SanitizedCollectionConfig } from 'payload'\n\nimport { buildVersionCollectionFields, combineQueries } from 'payload'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { DrizzleAdapter } from './types.js'\n\nimport { findMany } from './find/findMany.js'\n\nexport const queryDrafts: QueryDrafts = async function queryDrafts(\n this: DrizzleAdapter,\n { collection, limit, locale, page = 1, pagination, req = {} as PayloadRequest, sort, where },\n) {\n const collectionConfig: SanitizedCollectionConfig = this.payload.collections[collection].config\n const tableName = this.tableNameMap.get(\n `_${toSnakeCase(collectionConfig.slug)}${this.versionsSuffix}`,\n )\n const fields = buildVersionCollectionFields(collectionConfig)\n\n const combinedWhere = combineQueries({ latest: { equals: true } }, where)\n\n const result = await findMany({\n adapter: this,\n fields,\n limit,\n locale,\n page,\n pagination,\n req,\n sort,\n tableName,\n where: combinedWhere,\n })\n\n return {\n ...result,\n docs: result.docs.map((doc) => {\n doc = {\n id: doc.parent,\n ...doc.version,\n
|
|
1
|
+
{"version":3,"sources":["../src/queryDrafts.ts"],"sourcesContent":["import type { PayloadRequest, QueryDrafts, SanitizedCollectionConfig } from 'payload'\n\nimport { buildVersionCollectionFields, combineQueries } from 'payload'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { DrizzleAdapter } from './types.js'\n\nimport { findMany } from './find/findMany.js'\n\nexport const queryDrafts: QueryDrafts = async function queryDrafts(\n this: DrizzleAdapter,\n { collection, limit, locale, page = 1, pagination, req = {} as PayloadRequest, sort, where },\n) {\n const collectionConfig: SanitizedCollectionConfig = this.payload.collections[collection].config\n const tableName = this.tableNameMap.get(\n `_${toSnakeCase(collectionConfig.slug)}${this.versionsSuffix}`,\n )\n const fields = buildVersionCollectionFields(this.payload.config, collectionConfig)\n\n const combinedWhere = combineQueries({ latest: { equals: true } }, where)\n\n const result = await findMany({\n adapter: this,\n fields,\n limit,\n locale,\n page,\n pagination,\n req,\n sort,\n tableName,\n where: combinedWhere,\n })\n\n return {\n ...result,\n docs: result.docs.map((doc) => {\n doc = {\n id: doc.parent,\n ...doc.version,\n }\n\n return doc\n }),\n }\n}\n"],"names":["buildVersionCollectionFields","combineQueries","toSnakeCase","findMany","queryDrafts","collection","limit","locale","page","pagination","req","sort","where","collectionConfig","payload","collections","config","tableName","tableNameMap","get","slug","versionsSuffix","fields","combinedWhere","latest","equals","result","adapter","docs","map","doc","id","parent","version"],"mappings":"AAEA,SAASA,4BAA4B,EAAEC,cAAc,QAAQ,UAAS;AACtE,OAAOC,iBAAiB,gBAAe;AAIvC,SAASC,QAAQ,QAAQ,qBAAoB;AAE7C,OAAO,MAAMC,cAA2B,eAAeA,YAErD,EAAEC,UAAU,EAAEC,KAAK,EAAEC,MAAM,EAAEC,OAAO,CAAC,EAAEC,UAAU,EAAEC,MAAM,CAAC,CAAmB,EAAEC,IAAI,EAAEC,KAAK,EAAE;IAE5F,MAAMC,mBAA8C,IAAI,CAACC,OAAO,CAACC,WAAW,CAACV,WAAW,CAACW,MAAM;IAC/F,MAAMC,YAAY,IAAI,CAACC,YAAY,CAACC,GAAG,CACrC,CAAC,CAAC,EAAEjB,YAAYW,iBAAiBO,IAAI,EAAE,EAAE,IAAI,CAACC,cAAc,CAAC,CAAC;IAEhE,MAAMC,SAAStB,6BAA6B,IAAI,CAACc,OAAO,CAACE,MAAM,EAAEH;IAEjE,MAAMU,gBAAgBtB,eAAe;QAAEuB,QAAQ;YAAEC,QAAQ;QAAK;IAAE,GAAGb;IAEnE,MAAMc,SAAS,MAAMvB,SAAS;QAC5BwB,SAAS,IAAI;QACbL;QACAhB;QACAC;QACAC;QACAC;QACAC;QACAC;QACAM;QACAL,OAAOW;IACT;IAEA,OAAO;QACL,GAAGG,MAAM;QACTE,MAAMF,OAAOE,IAAI,CAACC,GAAG,CAAC,CAACC;YACrBA,MAAM;gBACJC,IAAID,IAAIE,MAAM;gBACd,GAAGF,IAAIG,OAAO;YAChB;YAEA,OAAOH;QACT;IACF;AACF,EAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Field, SanitizedConfig, TypeWithID } from 'payload';
|
|
1
|
+
import type { Field, JoinQuery, SanitizedConfig, TypeWithID } from 'payload';
|
|
2
2
|
import type { DrizzleAdapter } from '../../types.js';
|
|
3
3
|
type TransformArgs = {
|
|
4
4
|
adapter: DrizzleAdapter;
|
|
@@ -6,8 +6,9 @@ type TransformArgs = {
|
|
|
6
6
|
data: Record<string, unknown>;
|
|
7
7
|
fallbackLocale?: false | string;
|
|
8
8
|
fields: Field[];
|
|
9
|
+
joinQuery?: JoinQuery;
|
|
9
10
|
locale?: string;
|
|
10
11
|
};
|
|
11
|
-
export declare const transform: <T extends Record<string, unknown> | TypeWithID>({ adapter, config, data, fields, }: TransformArgs) => T;
|
|
12
|
+
export declare const transform: <T extends Record<string, unknown> | TypeWithID>({ adapter, config, data, fields, joinQuery, }: TransformArgs) => T;
|
|
12
13
|
export {};
|
|
13
14
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transform/read/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transform/read/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAE5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAMpD,KAAK,aAAa,GAAG;IACnB,OAAO,EAAE,cAAc,CAAA;IACvB,MAAM,EAAE,eAAe,CAAA;IACvB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,cAAc,CAAC,EAAE,KAAK,GAAG,MAAM,CAAA;IAC/B,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAID,eAAO,MAAM,SAAS,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,UAAU,iDAMrE,aAAa,KAAG,CA4ClB,CAAA"}
|
|
@@ -3,7 +3,7 @@ import { createPathMap } from '../../utilities/createRelationshipMap.js';
|
|
|
3
3
|
import { traverseFields } from './traverseFields.js';
|
|
4
4
|
// This is the entry point to transform Drizzle output data
|
|
5
5
|
// into the shape Payload expects based on field schema
|
|
6
|
-
export const transform = ({ adapter, config, data, fields })=>{
|
|
6
|
+
export const transform = ({ adapter, config, data, fields, joinQuery })=>{
|
|
7
7
|
let relationships = {};
|
|
8
8
|
let texts = {};
|
|
9
9
|
let numbers = {};
|
|
@@ -31,6 +31,7 @@ export const transform = ({ adapter, config, data, fields })=>{
|
|
|
31
31
|
deletions,
|
|
32
32
|
fieldPrefix: '',
|
|
33
33
|
fields,
|
|
34
|
+
joinQuery,
|
|
34
35
|
numbers,
|
|
35
36
|
path: '',
|
|
36
37
|
relationships,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/transform/read/index.ts"],"sourcesContent":["import type { Field, SanitizedConfig, TypeWithID } from 'payload'\n\nimport type { DrizzleAdapter } from '../../types.js'\n\nimport { createBlocksMap } from '../../utilities/createBlocksMap.js'\nimport { createPathMap } from '../../utilities/createRelationshipMap.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype TransformArgs = {\n adapter: DrizzleAdapter\n config: SanitizedConfig\n data: Record<string, unknown>\n fallbackLocale?: false | string\n fields: Field[]\n locale?: string\n}\n\n// This is the entry point to transform Drizzle output data\n// into the shape Payload expects based on field schema\nexport const transform = <T extends Record<string, unknown> | TypeWithID>({\n adapter,\n config,\n data,\n fields,\n}: TransformArgs): T => {\n let relationships: Record<string, Record<string, unknown>[]> = {}\n let texts: Record<string, Record<string, unknown>[]> = {}\n let numbers: Record<string, Record<string, unknown>[]> = {}\n\n if ('_rels' in data) {\n relationships = createPathMap(data._rels)\n delete data._rels\n }\n\n if ('_texts' in data) {\n texts = createPathMap(data._texts)\n delete data._texts\n }\n\n if ('_numbers' in data) {\n numbers = createPathMap(data._numbers)\n delete data._numbers\n }\n\n const blocks = createBlocksMap(data)\n const deletions = []\n\n const result = traverseFields<T>({\n adapter,\n blocks,\n config,\n dataRef: {\n id: data.id,\n },\n deletions,\n fieldPrefix: '',\n fields,\n numbers,\n path: '',\n relationships,\n table: data,\n texts,\n })\n\n deletions.forEach((deletion) => deletion())\n\n return result\n}\n"],"names":["createBlocksMap","createPathMap","traverseFields","transform","adapter","config","data","fields","relationships","texts","numbers","_rels","_texts","_numbers","blocks","deletions","result","dataRef","id","fieldPrefix","path","table","forEach","deletion"],"mappings":"AAIA,SAASA,eAAe,QAAQ,qCAAoC;AACpE,SAASC,aAAa,QAAQ,2CAA0C;AACxE,SAASC,cAAc,QAAQ,sBAAqB;
|
|
1
|
+
{"version":3,"sources":["../../../src/transform/read/index.ts"],"sourcesContent":["import type { Field, JoinQuery, SanitizedConfig, TypeWithID } from 'payload'\n\nimport type { DrizzleAdapter } from '../../types.js'\n\nimport { createBlocksMap } from '../../utilities/createBlocksMap.js'\nimport { createPathMap } from '../../utilities/createRelationshipMap.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype TransformArgs = {\n adapter: DrizzleAdapter\n config: SanitizedConfig\n data: Record<string, unknown>\n fallbackLocale?: false | string\n fields: Field[]\n joinQuery?: JoinQuery\n locale?: string\n}\n\n// This is the entry point to transform Drizzle output data\n// into the shape Payload expects based on field schema\nexport const transform = <T extends Record<string, unknown> | TypeWithID>({\n adapter,\n config,\n data,\n fields,\n joinQuery,\n}: TransformArgs): T => {\n let relationships: Record<string, Record<string, unknown>[]> = {}\n let texts: Record<string, Record<string, unknown>[]> = {}\n let numbers: Record<string, Record<string, unknown>[]> = {}\n\n if ('_rels' in data) {\n relationships = createPathMap(data._rels)\n delete data._rels\n }\n\n if ('_texts' in data) {\n texts = createPathMap(data._texts)\n delete data._texts\n }\n\n if ('_numbers' in data) {\n numbers = createPathMap(data._numbers)\n delete data._numbers\n }\n\n const blocks = createBlocksMap(data)\n const deletions = []\n\n const result = traverseFields<T>({\n adapter,\n blocks,\n config,\n dataRef: {\n id: data.id,\n },\n deletions,\n fieldPrefix: '',\n fields,\n joinQuery,\n numbers,\n path: '',\n relationships,\n table: data,\n texts,\n })\n\n deletions.forEach((deletion) => deletion())\n\n return result\n}\n"],"names":["createBlocksMap","createPathMap","traverseFields","transform","adapter","config","data","fields","joinQuery","relationships","texts","numbers","_rels","_texts","_numbers","blocks","deletions","result","dataRef","id","fieldPrefix","path","table","forEach","deletion"],"mappings":"AAIA,SAASA,eAAe,QAAQ,qCAAoC;AACpE,SAASC,aAAa,QAAQ,2CAA0C;AACxE,SAASC,cAAc,QAAQ,sBAAqB;AAYpD,2DAA2D;AAC3D,uDAAuD;AACvD,OAAO,MAAMC,YAAY,CAAiD,EACxEC,OAAO,EACPC,MAAM,EACNC,IAAI,EACJC,MAAM,EACNC,SAAS,EACK;IACd,IAAIC,gBAA2D,CAAC;IAChE,IAAIC,QAAmD,CAAC;IACxD,IAAIC,UAAqD,CAAC;IAE1D,IAAI,WAAWL,MAAM;QACnBG,gBAAgBR,cAAcK,KAAKM,KAAK;QACxC,OAAON,KAAKM,KAAK;IACnB;IAEA,IAAI,YAAYN,MAAM;QACpBI,QAAQT,cAAcK,KAAKO,MAAM;QACjC,OAAOP,KAAKO,MAAM;IACpB;IAEA,IAAI,cAAcP,MAAM;QACtBK,UAAUV,cAAcK,KAAKQ,QAAQ;QACrC,OAAOR,KAAKQ,QAAQ;IACtB;IAEA,MAAMC,SAASf,gBAAgBM;IAC/B,MAAMU,YAAY,EAAE;IAEpB,MAAMC,SAASf,eAAkB;QAC/BE;QACAW;QACAV;QACAa,SAAS;YACPC,IAAIb,KAAKa,EAAE;QACb;QACAH;QACAI,aAAa;QACbb;QACAC;QACAG;QACAU,MAAM;QACNZ;QACAa,OAAOhB;QACPI;IACF;IAEAM,UAAUO,OAAO,CAAC,CAACC,WAAaA;IAEhC,OAAOP;AACT,EAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Field, SanitizedConfig, TabAsField } from 'payload';
|
|
1
|
+
import type { Field, JoinQuery, SanitizedConfig, TabAsField } from 'payload';
|
|
2
2
|
import type { DrizzleAdapter } from '../../types.js';
|
|
3
3
|
import type { BlocksMap } from '../../utilities/createBlocksMap.js';
|
|
4
4
|
type TraverseFieldsArgs = {
|
|
@@ -30,6 +30,10 @@ type TraverseFieldsArgs = {
|
|
|
30
30
|
* An array of Payload fields to traverse
|
|
31
31
|
*/
|
|
32
32
|
fields: (Field | TabAsField)[];
|
|
33
|
+
/**
|
|
34
|
+
*
|
|
35
|
+
*/
|
|
36
|
+
joinQuery?: JoinQuery;
|
|
33
37
|
/**
|
|
34
38
|
* All hasMany number fields, as returned by Drizzle, keyed on an object by field path
|
|
35
39
|
*/
|
|
@@ -55,6 +59,6 @@ type TraverseFieldsArgs = {
|
|
|
55
59
|
*/
|
|
56
60
|
withinArrayOrBlockLocale?: string;
|
|
57
61
|
};
|
|
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;
|
|
62
|
+
export declare const traverseFields: <T extends Record<string, unknown>>({ adapter, blocks, config, dataRef, deletions, fieldPrefix, fields, joinQuery, numbers, path, relationships, table, texts, withinArrayOrBlockLocale, }: TraverseFieldsArgs) => T;
|
|
59
63
|
export {};
|
|
60
64
|
//# 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;
|
|
1
|
+
{"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../../src/transform/read/traverseFields.ts"],"names":[],"mappings":"AAAA,OAAO,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e7D,kBAAkB,KAAG,CA2lBvB,CAAA"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { fieldAffectsData } from 'payload/shared';
|
|
1
|
+
import { fieldAffectsData, fieldIsVirtual } from 'payload/shared';
|
|
2
2
|
import { transformHasManyNumber } from './hasManyNumber.js';
|
|
3
3
|
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, withinArrayOrBlockLocale })=>{
|
|
7
|
+
export const traverseFields = ({ adapter, blocks, config, dataRef, deletions, fieldPrefix, fields, joinQuery, 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') {
|
|
@@ -19,6 +19,7 @@ export const traverseFields = ({ adapter, blocks, config, dataRef, deletions, fi
|
|
|
19
19
|
...tab,
|
|
20
20
|
type: 'tab'
|
|
21
21
|
})),
|
|
22
|
+
joinQuery,
|
|
22
23
|
numbers,
|
|
23
24
|
path,
|
|
24
25
|
relationships,
|
|
@@ -36,6 +37,7 @@ export const traverseFields = ({ adapter, blocks, config, dataRef, deletions, fi
|
|
|
36
37
|
deletions,
|
|
37
38
|
fieldPrefix,
|
|
38
39
|
fields: field.fields,
|
|
40
|
+
joinQuery,
|
|
39
41
|
numbers,
|
|
40
42
|
path,
|
|
41
43
|
relationships,
|
|
@@ -45,8 +47,11 @@ export const traverseFields = ({ adapter, blocks, config, dataRef, deletions, fi
|
|
|
45
47
|
});
|
|
46
48
|
}
|
|
47
49
|
if (fieldAffectsData(field)) {
|
|
50
|
+
if (fieldIsVirtual(field)) {
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
48
53
|
const fieldName = `${fieldPrefix || ''}${field.name}`;
|
|
49
|
-
|
|
54
|
+
let fieldData = table[fieldName];
|
|
50
55
|
const localizedFieldData = {};
|
|
51
56
|
const valuesToTransform = [];
|
|
52
57
|
if (fieldPrefix) {
|
|
@@ -126,10 +131,11 @@ export const traverseFields = ({ adapter, blocks, config, dataRef, deletions, fi
|
|
|
126
131
|
}
|
|
127
132
|
if (field.type === 'blocks') {
|
|
128
133
|
const blockFieldPath = `${sanitizedPath}${field.name}`;
|
|
129
|
-
|
|
134
|
+
const blocksByPath = blocks[blockFieldPath];
|
|
135
|
+
if (Array.isArray(blocksByPath)) {
|
|
130
136
|
if (field.localized) {
|
|
131
137
|
result[field.name] = {};
|
|
132
|
-
|
|
138
|
+
blocksByPath.forEach((row)=>{
|
|
133
139
|
if (row._uuid) {
|
|
134
140
|
row.id = row._uuid;
|
|
135
141
|
delete row._uuid;
|
|
@@ -168,7 +174,21 @@ export const traverseFields = ({ adapter, blocks, config, dataRef, deletions, fi
|
|
|
168
174
|
});
|
|
169
175
|
});
|
|
170
176
|
} else {
|
|
171
|
-
|
|
177
|
+
// Add locale-specific index to have a proper blockFieldPath for current locale
|
|
178
|
+
// because blocks can be in the same array for different locales!
|
|
179
|
+
if (withinArrayOrBlockLocale && config.localization) {
|
|
180
|
+
for (const locale of config.localization.localeCodes){
|
|
181
|
+
let localeIndex = 0;
|
|
182
|
+
for(let i = 0; i < blocksByPath.length; i++){
|
|
183
|
+
const row = blocksByPath[i];
|
|
184
|
+
if (row._locale === locale) {
|
|
185
|
+
row._index = localeIndex;
|
|
186
|
+
localeIndex++;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
result[field.name] = blocksByPath.reduce((acc, row, i)=>{
|
|
172
192
|
delete row._order;
|
|
173
193
|
if (row._uuid) {
|
|
174
194
|
row.id = row._uuid;
|
|
@@ -180,6 +200,10 @@ export const traverseFields = ({ adapter, blocks, config, dataRef, deletions, fi
|
|
|
180
200
|
if (row._locale) {
|
|
181
201
|
delete row._locale;
|
|
182
202
|
}
|
|
203
|
+
if (typeof row._index === 'number') {
|
|
204
|
+
i = row._index;
|
|
205
|
+
delete row._index;
|
|
206
|
+
}
|
|
183
207
|
acc.push(traverseFields({
|
|
184
208
|
adapter,
|
|
185
209
|
blocks,
|
|
@@ -264,6 +288,44 @@ export const traverseFields = ({ adapter, blocks, config, dataRef, deletions, fi
|
|
|
264
288
|
return result;
|
|
265
289
|
}
|
|
266
290
|
}
|
|
291
|
+
if (field.type === 'join') {
|
|
292
|
+
const { limit = 10 } = joinQuery?.[`${fieldPrefix.replaceAll('_', '.')}${field.name}`] || {};
|
|
293
|
+
// raw hasMany results from SQLite
|
|
294
|
+
if (typeof fieldData === 'string') {
|
|
295
|
+
fieldData = JSON.parse(fieldData);
|
|
296
|
+
}
|
|
297
|
+
let fieldResult;
|
|
298
|
+
if (Array.isArray(fieldData)) {
|
|
299
|
+
if (field.localized) {
|
|
300
|
+
fieldResult = fieldData.reduce((joinResult, row)=>{
|
|
301
|
+
if (typeof row._locale === 'string') {
|
|
302
|
+
if (!joinResult[row._locale]) {
|
|
303
|
+
joinResult[row._locale] = {
|
|
304
|
+
docs: [],
|
|
305
|
+
hasNextPage: false
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
joinResult[row._locale].docs.push(row._parentID);
|
|
309
|
+
}
|
|
310
|
+
return joinResult;
|
|
311
|
+
}, {});
|
|
312
|
+
Object.keys(fieldResult).forEach((locale)=>{
|
|
313
|
+
fieldResult[locale].hasNextPage = fieldResult[locale].docs.length > limit;
|
|
314
|
+
fieldResult[locale].docs = fieldResult[locale].docs.slice(0, limit);
|
|
315
|
+
});
|
|
316
|
+
} else {
|
|
317
|
+
const hasNextPage = limit !== 0 && fieldData.length > limit;
|
|
318
|
+
fieldResult = {
|
|
319
|
+
docs: (hasNextPage ? fieldData.slice(0, limit) : fieldData).map(({ id })=>({
|
|
320
|
+
id
|
|
321
|
+
})),
|
|
322
|
+
hasNextPage
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
result[field.name] = fieldResult;
|
|
327
|
+
return result;
|
|
328
|
+
}
|
|
267
329
|
if (field.type === 'text' && field?.hasMany) {
|
|
268
330
|
const textPathMatch = texts[`${sanitizedPath}${field.name}`];
|
|
269
331
|
if (!textPathMatch) {
|
|
@@ -345,16 +407,26 @@ export const traverseFields = ({ adapter, blocks, config, dataRef, deletions, fi
|
|
|
345
407
|
return selectResult;
|
|
346
408
|
}, {});
|
|
347
409
|
} else {
|
|
348
|
-
|
|
410
|
+
let selectData = fieldData;
|
|
411
|
+
if (withinArrayOrBlockLocale) {
|
|
412
|
+
selectData = selectData.filter(({ locale })=>locale === withinArrayOrBlockLocale);
|
|
413
|
+
}
|
|
414
|
+
result[field.name] = selectData.map(({ value })=>value);
|
|
349
415
|
}
|
|
350
416
|
}
|
|
351
417
|
return result;
|
|
352
418
|
}
|
|
353
419
|
if (field.localized && Array.isArray(table._locales)) {
|
|
420
|
+
if (!table._locales.length && adapter.payload.config.localization) {
|
|
421
|
+
adapter.payload.config.localization.localeCodes.forEach((_locale)=>table._locales.push({
|
|
422
|
+
_locale
|
|
423
|
+
}));
|
|
424
|
+
}
|
|
354
425
|
table._locales.forEach((localeRow)=>{
|
|
355
426
|
valuesToTransform.push({
|
|
356
427
|
ref: localizedFieldData,
|
|
357
428
|
table: {
|
|
429
|
+
...table,
|
|
358
430
|
...localeRow
|
|
359
431
|
}
|
|
360
432
|
});
|
|
@@ -393,7 +465,7 @@ export const traverseFields = ({ adapter, blocks, config, dataRef, deletions, fi
|
|
|
393
465
|
relationships,
|
|
394
466
|
table,
|
|
395
467
|
texts,
|
|
396
|
-
withinArrayOrBlockLocale
|
|
468
|
+
withinArrayOrBlockLocale: locale || withinArrayOrBlockLocale
|
|
397
469
|
});
|
|
398
470
|
if ('_order' in ref) {
|
|
399
471
|
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 * 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;AAKj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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"}
|
|
1
|
+
{"version":3,"sources":["../../../src/transform/read/traverseFields.ts"],"sourcesContent":["import type { Field, JoinQuery, SanitizedConfig, TabAsField } from 'payload'\n\nimport { fieldAffectsData, fieldIsVirtual } 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 *\n */\n joinQuery?: JoinQuery\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 joinQuery,\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 joinQuery,\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 joinQuery,\n numbers,\n path,\n relationships,\n table,\n texts,\n withinArrayOrBlockLocale,\n })\n }\n\n if (fieldAffectsData(field)) {\n if (fieldIsVirtual(field)) {\n return result\n }\n\n const fieldName = `${fieldPrefix || ''}${field.name}`\n let 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 const blocksByPath = blocks[blockFieldPath]\n\n if (Array.isArray(blocksByPath)) {\n if (field.localized) {\n result[field.name] = {}\n\n blocksByPath.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 // Add locale-specific index to have a proper blockFieldPath for current locale\n // because blocks can be in the same array for different locales!\n if (withinArrayOrBlockLocale && config.localization) {\n for (const locale of config.localization.localeCodes) {\n let localeIndex = 0\n\n for (let i = 0; i < blocksByPath.length; i++) {\n const row = blocksByPath[i]\n if (row._locale === locale) {\n row._index = localeIndex\n localeIndex++\n }\n }\n }\n }\n\n result[field.name] = blocksByPath.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 if (typeof row._index === 'number') {\n i = row._index\n delete row._index\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\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 === 'join') {\n const { limit = 10 } = joinQuery?.[`${fieldPrefix.replaceAll('_', '.')}${field.name}`] || {}\n\n // raw hasMany results from SQLite\n if (typeof fieldData === 'string') {\n fieldData = JSON.parse(fieldData)\n }\n\n let fieldResult:\n | { docs: unknown[]; hasNextPage: boolean }\n | Record<string, { docs: unknown[]; hasNextPage: boolean }>\n if (Array.isArray(fieldData)) {\n if (field.localized) {\n fieldResult = fieldData.reduce((joinResult, row) => {\n if (typeof row._locale === 'string') {\n if (!joinResult[row._locale]) {\n joinResult[row._locale] = {\n docs: [],\n hasNextPage: false,\n }\n }\n joinResult[row._locale].docs.push(row._parentID)\n }\n\n return joinResult\n }, {})\n Object.keys(fieldResult).forEach((locale) => {\n fieldResult[locale].hasNextPage = fieldResult[locale].docs.length > limit\n fieldResult[locale].docs = fieldResult[locale].docs.slice(0, limit)\n })\n } else {\n const hasNextPage = limit !== 0 && fieldData.length > limit\n fieldResult = {\n docs: (hasNextPage ? fieldData.slice(0, limit) : fieldData).map(({ id }) => ({\n id,\n })),\n hasNextPage,\n }\n }\n }\n\n result[field.name] = fieldResult\n return result\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 let selectData = fieldData\n if (withinArrayOrBlockLocale) {\n selectData = selectData.filter(({ locale }) => locale === withinArrayOrBlockLocale)\n }\n result[field.name] = selectData.map(({ value }) => value)\n }\n }\n return result\n }\n\n if (field.localized && Array.isArray(table._locales)) {\n if (!table._locales.length && adapter.payload.config.localization) {\n adapter.payload.config.localization.localeCodes.forEach((_locale) =>\n (table._locales as unknown[]).push({ _locale }),\n )\n }\n\n table._locales.forEach((localeRow) => {\n valuesToTransform.push({\n ref: localizedFieldData,\n table: {\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: locale || 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","fieldIsVirtual","transformHasManyNumber","transformHasManyText","transformRelationship","traverseFields","adapter","blocks","config","dataRef","deletions","fieldPrefix","fields","joinQuery","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","blocksByPath","forEach","Object","entries","localizedBlocks","block","find","slug","blockType","blockResult","localization","localeCodes","localeIndex","length","_index","relationTo","hasMany","locales","_locales","localeRow","ref","relationPathMatch","defaultLocale","relationsByLocale","relations","limit","replaceAll","JSON","parse","fieldResult","joinResult","docs","hasNextPage","_parentID","keys","slice","textPathMatch","textsByLocale","textRows","numberPathMatch","numbersByLocale","numberRows","selectResult","value","selectData","filter","payload","val","groupFieldPrefix","groupData","refKey","String","Number","parseFloat","Date","toISOString","collections","customIDType"],"mappings":"AAEA,SAASA,gBAAgB,EAAEC,cAAc,QAAQ,iBAAgB;AAKjE,SAASC,sBAAsB,QAAQ,qBAAoB;AAC3D,SAASC,oBAAoB,QAAQ,mBAAkB;AACvD,SAASC,qBAAqB,QAAQ,oBAAmB;AA6DzD,iDAAiD;AACjD,kDAAkD;AAClD,OAAO,MAAMC,iBAAiB,CAAoC,EAChEC,OAAO,EACPC,MAAM,EACNC,MAAM,EACNC,OAAO,EACPC,SAAS,EACTC,WAAW,EACXC,MAAM,EACNC,SAAS,EACTC,OAAO,EACPC,IAAI,EACJC,aAAa,EACbC,KAAK,EACLC,KAAK,EACLC,wBAAwB,EACL;IACnB,MAAMC,gBAAgBL,OAAO,CAAC,EAAEA,KAAK,CAAC,CAAC,GAAGA;IAE1C,MAAMM,YAAYT,OAAOU,MAAM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AAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,OAAO,EAAE;QACP,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAC1C,CAAA;IACD,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;IAClC;;OAEG;IACH,eAAe,EAAE,MAAM,CAAA;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;IACxC,qBAAqB,EAAE,oBAAoB,EAAE,CAAA;IAC7C,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC5B,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,sQAsBxB,IAAI,SA8gBN,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { fieldAffectsData } from 'payload/shared';
|
|
1
|
+
import { fieldAffectsData, fieldIsVirtual } from 'payload/shared';
|
|
2
2
|
import toSnakeCase from 'to-snake-case';
|
|
3
3
|
import { isArrayOfRows } from '../../utilities/isArrayOfRows.js';
|
|
4
4
|
import { transformArray } from './array.js';
|
|
@@ -13,6 +13,9 @@ export const traverseFields = ({ adapter, arrays, baseTableName, blocks, blocksT
|
|
|
13
13
|
let fieldName = '';
|
|
14
14
|
let fieldData;
|
|
15
15
|
if (fieldAffectsData(field)) {
|
|
16
|
+
if (fieldIsVirtual(field)) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
16
19
|
columnName = `${columnPrefix || ''}${toSnakeCase(field.name)}`;
|
|
17
20
|
fieldName = `${fieldPrefix || ''}${field.name}`;
|
|
18
21
|
fieldData = data[field.name];
|
|
@@ -118,6 +121,8 @@ export const traverseFields = ({ adapter, arrays, baseTableName, blocks, blocksT
|
|
|
118
121
|
if (typeof data[field.name] === 'object' && data[field.name] !== null) {
|
|
119
122
|
if (field.localized) {
|
|
120
123
|
Object.entries(data[field.name]).forEach(([localeKey, localeData])=>{
|
|
124
|
+
// preserve array ID if there is
|
|
125
|
+
localeData._uuid = data.id || data._uuid;
|
|
121
126
|
traverseFields({
|
|
122
127
|
adapter,
|
|
123
128
|
arrays,
|
|
@@ -143,6 +148,9 @@ export const traverseFields = ({ adapter, arrays, baseTableName, blocks, blocksT
|
|
|
143
148
|
});
|
|
144
149
|
});
|
|
145
150
|
} else {
|
|
151
|
+
// preserve array ID if there is
|
|
152
|
+
const groupData = data[field.name];
|
|
153
|
+
groupData._uuid = data.id || data._uuid;
|
|
146
154
|
traverseFields({
|
|
147
155
|
adapter,
|
|
148
156
|
arrays,
|
|
@@ -150,7 +158,7 @@ export const traverseFields = ({ adapter, arrays, baseTableName, blocks, blocksT
|
|
|
150
158
|
blocks,
|
|
151
159
|
blocksToDelete,
|
|
152
160
|
columnPrefix: `${columnName}_`,
|
|
153
|
-
data:
|
|
161
|
+
data: groupData,
|
|
154
162
|
existingLocales,
|
|
155
163
|
fieldPrefix: `${fieldName}_`,
|
|
156
164
|
fields: field.fields,
|
|
@@ -172,9 +180,14 @@ export const traverseFields = ({ adapter, arrays, baseTableName, blocks, blocksT
|
|
|
172
180
|
if (field.type === 'tabs') {
|
|
173
181
|
field.tabs.forEach((tab)=>{
|
|
174
182
|
if ('name' in tab) {
|
|
183
|
+
if (fieldIsVirtual(tab)) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
175
186
|
if (typeof data[tab.name] === 'object' && data[tab.name] !== null) {
|
|
176
187
|
if (tab.localized) {
|
|
177
188
|
Object.entries(data[tab.name]).forEach(([localeKey, localeData])=>{
|
|
189
|
+
// preserve array ID if there is
|
|
190
|
+
localeData._uuid = data.id || data._uuid;
|
|
178
191
|
traverseFields({
|
|
179
192
|
adapter,
|
|
180
193
|
arrays,
|
|
@@ -200,6 +213,9 @@ export const traverseFields = ({ adapter, arrays, baseTableName, blocks, blocksT
|
|
|
200
213
|
});
|
|
201
214
|
});
|
|
202
215
|
} else {
|
|
216
|
+
const tabData = data[tab.name];
|
|
217
|
+
// preserve array ID if there is
|
|
218
|
+
tabData._uuid = data.id || data._uuid;
|
|
203
219
|
traverseFields({
|
|
204
220
|
adapter,
|
|
205
221
|
arrays,
|
|
@@ -207,7 +223,7 @@ export const traverseFields = ({ adapter, arrays, baseTableName, blocks, blocksT
|
|
|
207
223
|
blocks,
|
|
208
224
|
blocksToDelete,
|
|
209
225
|
columnPrefix: `${columnPrefix || ''}${toSnakeCase(tab.name)}_`,
|
|
210
|
-
data:
|
|
226
|
+
data: tabData,
|
|
211
227
|
existingLocales,
|
|
212
228
|
fieldPrefix: `${fieldPrefix || ''}${tab.name}_`,
|
|
213
229
|
fields: tab.fields,
|
|
@@ -262,6 +278,7 @@ export const traverseFields = ({ adapter, arrays, baseTableName, blocks, blocksT
|
|
|
262
278
|
existingLocales,
|
|
263
279
|
fieldPrefix,
|
|
264
280
|
fields: field.fields,
|
|
281
|
+
forcedLocale,
|
|
265
282
|
locales,
|
|
266
283
|
numbers,
|
|
267
284
|
parentTableName,
|