{"version":3,"file":"documents.mjs","names":["documentBricksFormatter","documentWorkflowsFormatter","mediaFormatter","formatter","documentFieldsFormatter"],"sources":["../../../src/libs/formatters/documents.ts"],"sourcesContent":["import type { FieldRefResponse } from \"../../services/documents-bricks/helpers/fetch-ref-data.js\";\nimport type {\n\tCollectionDocument,\n\tConfig,\n\tDocumentWorkflow,\n\tFieldRef,\n\tFieldRefParams,\n\tFieldTypes,\n\tInternalCollectionDocument,\n\tInternalDocumentBrick,\n\tInternalDocumentField,\n\tLucidBrickTableName,\n} from \"../../types.js\";\nimport type CollectionBuilder from \"../collection/builders/collection-builder/index.js\";\nimport registeredFields, {\n\tregisteredFieldTypes,\n} from \"../collection/custom-fields/registered-fields.js\";\nimport type { CollectionSchemaTable } from \"../collection/schema/types.js\";\nimport type { DocumentWorkflowDetailedQueryResponse } from \"../repositories/document-workflows.js\";\nimport type { DocumentQueryResponse } from \"../repositories/documents.js\";\nimport formatter, {\n\tdocumentBricksFormatter,\n\tdocumentFieldsFormatter,\n\tdocumentWorkflowsFormatter,\n\tmediaFormatter,\n} from \"./index.js\";\nimport type { MediaPosterPropsT } from \"./media.js\";\n\nconst formatMultiple = (props: {\n\tdocuments: DocumentQueryResponse[];\n\tcollection: CollectionBuilder;\n\tconfig: Config;\n\thost: string;\n\thasFields: boolean;\n\thasBricks: boolean;\n\trefData?: FieldRefResponse;\n\trefTypes?: FieldTypes[];\n\tbricksTableSchema: Array<CollectionSchemaTable<LucidBrickTableName>>;\n\tworkflows?: DocumentWorkflowDetailedQueryResponse[];\n}) => {\n\tconst workflowMap =\n\t\tprops.workflows !== undefined\n\t\t\t? new Map(\n\t\t\t\t\tprops.workflows.map((workflow) => [workflow.document_id, workflow]),\n\t\t\t\t)\n\t\t\t: undefined;\n\n\treturn props.documents.map((d) => {\n\t\tlet fields: InternalDocumentField[] | null = null;\n\t\tlet bricks: InternalDocumentBrick[] | null = null;\n\t\tif (props.hasFields) {\n\t\t\tfields = documentBricksFormatter.formatDocumentFields({\n\t\t\t\tbricksQuery: d,\n\t\t\t\tbricksSchema: props.bricksTableSchema,\n\t\t\t\trefData: props.refData || { data: {} },\n\t\t\t\tcollection: props.collection,\n\t\t\t\tconfig: props.config,\n\t\t\t\thost: props.host,\n\t\t\t});\n\t\t}\n\t\tif (props.hasBricks) {\n\t\t\tbricks = documentBricksFormatter.formatMultiple({\n\t\t\t\tbricksQuery: d,\n\t\t\t\tbricksSchema: props.bricksTableSchema,\n\t\t\t\trefData: props.refData || { data: {} },\n\t\t\t\tcollection: props.collection,\n\t\t\t\tconfig: props.config,\n\t\t\t\thost: props.host,\n\t\t\t});\n\t\t}\n\n\t\tconst refs = formatRefs({\n\t\t\tdata: props.refData,\n\t\t\tcollection: props.collection,\n\t\t\tconfig: props.config,\n\t\t\thost: props.host,\n\t\t\tbricksTableSchema: props.bricksTableSchema,\n\t\t\tfieldTypes: props.refTypes,\n\t\t});\n\n\t\treturn formatSingle({\n\t\t\tdocument: d,\n\t\t\tcollection: props.collection,\n\t\t\tconfig: props.config,\n\t\t\tfields: fields,\n\t\t\tbricks: bricks || undefined,\n\t\t\trefs: refs,\n\t\t\tworkflow:\n\t\t\t\tworkflowMap !== undefined\n\t\t\t\t\t? documentWorkflowsFormatter.formatSingle({\n\t\t\t\t\t\t\tcollection: props.collection,\n\t\t\t\t\t\t\tworkflow: workflowMap.get(d.id),\n\t\t\t\t\t\t\thost: props.host,\n\t\t\t\t\t\t})\n\t\t\t\t\t: undefined,\n\t\t\thost: props.host,\n\t\t});\n\t});\n};\n\nconst formatDocumentAuthor = (props: {\n\tid?: number | null;\n\temail?: string | null;\n\tfirstName?: string | null;\n\tlastName?: string | null;\n\tusername?: string | null;\n\tprofilePicture?: MediaPosterPropsT[];\n\thost: string;\n}): InternalCollectionDocument[\"createdBy\"] => {\n\tif (!props.id) return null;\n\n\treturn {\n\t\tid: props.id,\n\t\temail: props.email ?? null,\n\t\tfirstName: props.firstName ?? null,\n\t\tlastName: props.lastName ?? null,\n\t\tusername: props.username ?? null,\n\t\tprofilePicture: mediaFormatter.formatProfilePicture({\n\t\t\tposter: props.profilePicture?.[0],\n\t\t\thost: props.host,\n\t\t}),\n\t};\n};\n\nconst formatSingle = (props: {\n\tdocument: DocumentQueryResponse;\n\tcollection: CollectionBuilder;\n\tbricks?: InternalDocumentBrick[];\n\tfields?: InternalDocumentField[] | null;\n\trefs?: InternalCollectionDocument[\"refs\"];\n\tworkflow?: DocumentWorkflow | null;\n\tconfig: Config;\n\thost: string;\n}): InternalCollectionDocument => {\n\tconst inlineWorkflow =\n\t\tprops.document.workflow_assignees !== undefined\n\t\t\t? documentWorkflowsFormatter.formatSingle({\n\t\t\t\t\tcollection: props.collection,\n\t\t\t\t\tworkflow: {\n\t\t\t\t\t\tid: props.document.workflow_id,\n\t\t\t\t\t\tcollection_key: props.document.collection_key,\n\t\t\t\t\t\tdocument_id: props.document.id,\n\t\t\t\t\t\tstage_key: props.document.workflow_stage_key,\n\t\t\t\t\t\tcreated_by: props.document.workflow_created_by,\n\t\t\t\t\t\tcreated_at: props.document.workflow_created_at,\n\t\t\t\t\t\tupdated_by: props.document.workflow_updated_by,\n\t\t\t\t\t\tupdated_at: props.document.workflow_updated_at,\n\t\t\t\t\t\tassignees: props.document.workflow_assignees,\n\t\t\t\t\t},\n\t\t\t\t\thost: props.host,\n\t\t\t\t})\n\t\t\t: undefined;\n\n\treturn {\n\t\tid: props.document.id,\n\t\tcollectionKey: props.document.collection_key,\n\t\tversion: props.document.version_type ?? null,\n\t\tversionId: props.document.version_id ?? null,\n\t\tversions: formatVersions({\n\t\t\tdocument: props.document,\n\t\t\tcollection: props.collection,\n\t\t}),\n\t\tbricks: props.bricks ?? null,\n\t\tfields: props.fields ?? null,\n\t\trefs: props.refs ?? null,\n\t\tworkflow:\n\t\t\tprops.workflow !== undefined\n\t\t\t\t? props.workflow\n\t\t\t\t: (inlineWorkflow ??\n\t\t\t\t\tdocumentWorkflowsFormatter.formatSummary({\n\t\t\t\t\t\tcollection: props.collection,\n\t\t\t\t\t\tstageKey: props.document.workflow_stage_key,\n\t\t\t\t\t})),\n\t\tisDeleted: formatter.formatBoolean(props.document.is_deleted),\n\t\tcreatedBy: formatDocumentAuthor({\n\t\t\tid: props.document.cb_user_id,\n\t\t\temail: props.document.cb_user_email,\n\t\t\tfirstName: props.document.cb_user_first_name,\n\t\t\tlastName: props.document.cb_user_last_name,\n\t\t\tusername: props.document.cb_user_username,\n\t\t\tprofilePicture: props.document.cb_user_profile_picture,\n\t\t\thost: props.host,\n\t\t}),\n\t\tupdatedBy: formatDocumentAuthor({\n\t\t\tid: props.document.ub_user_id,\n\t\t\temail: props.document.ub_user_email,\n\t\t\tfirstName: props.document.ub_user_first_name,\n\t\t\tlastName: props.document.ub_user_last_name,\n\t\t\tusername: props.document.ub_user_username,\n\t\t\tprofilePicture: props.document.ub_user_profile_picture,\n\t\t\thost: props.host,\n\t\t}),\n\t\tcreatedAt: formatter.formatDate(props.document.created_at),\n\t\tupdatedAt: formatter.formatDate(props.document.updated_at),\n\t} satisfies InternalCollectionDocument;\n};\n\nconst formatVersions = (props: {\n\tdocument: DocumentQueryResponse;\n\tcollection: CollectionBuilder;\n}): InternalCollectionDocument[\"versions\"] => {\n\tconst versions: InternalCollectionDocument[\"versions\"] = {\n\t\tlatest: null,\n\t};\n\n\tif (props.collection.getData.environments) {\n\t\tfor (const env of props.collection.getData.environments) {\n\t\t\tversions[env.key] = null;\n\t\t}\n\t}\n\n\tif (props.document.versions) {\n\t\tfor (const version of props.document.versions) {\n\t\t\tversions[version.type] = {\n\t\t\t\tid: version.id,\n\t\t\t\tpromotedFrom: version.promoted_from,\n\t\t\t\tcontentId: version.content_id,\n\t\t\t\tcreatedAt: formatter.formatDate(version.created_at),\n\t\t\t\tupdatedAt: formatter.formatDate(version.updated_at),\n\t\t\t\tcreatedBy: version.created_by,\n\t\t\t};\n\t\t}\n\t}\n\n\treturn versions;\n};\n\n/**\n * Formats multiple documents into the client-facing document shape while\n * preserving the caller's collection-key generic at the formatter boundary.\n */\nconst formatClientMultiple = <TCollectionKey extends string = string>(props: {\n\tdocuments: DocumentQueryResponse[];\n\tcollection: CollectionBuilder;\n\tconfig: Config;\n\thost: string;\n\thasFields: boolean;\n\thasBricks: boolean;\n\trefData?: FieldRefResponse;\n\trefTypes?: FieldTypes[];\n\tbricksTableSchema: Array<CollectionSchemaTable<LucidBrickTableName>>;\n\tinclude: {\n\t\tbricks: boolean;\n\t\trefs: boolean;\n\t\tmeta: boolean;\n\t};\n}): CollectionDocument<TCollectionKey>[] => {\n\treturn props.documents.map((d) => {\n\t\tlet fields: InternalDocumentField[] | null = null;\n\t\tlet bricks: InternalDocumentBrick[] | null = null;\n\t\tif (props.hasFields) {\n\t\t\tfields = documentBricksFormatter.formatDocumentFields({\n\t\t\t\tbricksQuery: d,\n\t\t\t\tbricksSchema: props.bricksTableSchema,\n\t\t\t\trefData: props.refData || { data: {} },\n\t\t\t\tcollection: props.collection,\n\t\t\t\tconfig: props.config,\n\t\t\t\thost: props.host,\n\t\t\t});\n\t\t}\n\t\tif (props.hasBricks) {\n\t\t\tbricks = documentBricksFormatter.formatMultiple({\n\t\t\t\tbricksQuery: d,\n\t\t\t\tbricksSchema: props.bricksTableSchema,\n\t\t\t\trefData: props.refData || { data: {} },\n\t\t\t\tcollection: props.collection,\n\t\t\t\tconfig: props.config,\n\t\t\t\thost: props.host,\n\t\t\t});\n\t\t}\n\n\t\tconst refs = props.include.refs\n\t\t\t? formatRefs({\n\t\t\t\t\tdata: props.refData,\n\t\t\t\t\tcollection: props.collection,\n\t\t\t\t\tconfig: props.config,\n\t\t\t\t\thost: props.host,\n\t\t\t\t\tbricksTableSchema: props.bricksTableSchema,\n\t\t\t\t\tfieldTypes: props.refTypes,\n\t\t\t\t\tflattenRelationRefFields: true,\n\t\t\t\t})\n\t\t\t: null;\n\n\t\treturn formatClientSingle<TCollectionKey>({\n\t\t\tdocument: d,\n\t\t\tcollection: props.collection,\n\t\t\tconfig: props.config,\n\t\t\tfields: fields,\n\t\t\tbricks: bricks || undefined,\n\t\t\trefs: refs,\n\t\t\thost: props.host,\n\t\t\tinclude: props.include,\n\t\t});\n\t});\n};\n\nconst formatClientMeta = (props: {\n\tdocument: DocumentQueryResponse;\n\tcollection: CollectionBuilder;\n}) => {\n\treturn {\n\t\tversionId: props.document.version_id ?? null,\n\t\tversions: formatVersions({\n\t\t\tdocument: props.document,\n\t\t\tcollection: props.collection,\n\t\t}),\n\t\tcreatedAt: formatter.formatDate(props.document.created_at),\n\t\tupdatedAt: formatter.formatDate(props.document.updated_at),\n\t\tcreatedBy: props.document.created_by ?? null,\n\t\tupdatedBy: props.document.updated_by ?? null,\n\t};\n};\n\nconst formatClientBricks = (\n\tbricks: InternalDocumentBrick[] | null | undefined,\n\tcollection: CollectionBuilder,\n) => {\n\treturn (bricks ?? []).map((brick) => {\n\t\tconst brickInstance = collection.brickInstances.find(\n\t\t\t(b) => b.key === brick.key,\n\t\t);\n\n\t\treturn {\n\t\t\tid: brick.id,\n\t\t\tref: brick.ref,\n\t\t\tkey: brick.key,\n\t\t\ttype: brick.type,\n\t\t\torder: brick.order,\n\t\t\tfields: documentFieldsFormatter.flattenFields(\n\t\t\t\tbrick.fields,\n\t\t\t\tbrickInstance?.clientFieldTree,\n\t\t\t),\n\t\t};\n\t});\n};\n\n/**\n * Formats one document into the client response shape used by the public\n * client and toolkit helpers.\n */\nconst formatClientSingle = <TCollectionKey extends string = string>(props: {\n\tdocument: DocumentQueryResponse;\n\tcollection: CollectionBuilder;\n\tbricks?: InternalDocumentBrick[];\n\tfields?: InternalDocumentField[] | null;\n\trefs?: InternalCollectionDocument[\"refs\"];\n\tconfig: Config;\n\thost: string;\n\tinclude: {\n\t\tbricks: boolean;\n\t\trefs: boolean;\n\t\tmeta: boolean;\n\t};\n}): CollectionDocument<TCollectionKey> => {\n\tconst clientRes: Record<string, unknown> = {\n\t\tid: props.document.id,\n\t\tcollectionKey: props.document.collection_key,\n\t\tversion: props.document.version_type ?? null,\n\t\tfields: documentFieldsFormatter.flattenFields(\n\t\t\tprops.fields ?? [],\n\t\t\tprops.collection.clientFieldTree,\n\t\t),\n\t};\n\n\tif (props.include.bricks) {\n\t\tclientRes.bricks = formatClientBricks(props.bricks, props.collection);\n\t}\n\n\tif (props.include.refs) {\n\t\tclientRes.refs = props.refs ?? {};\n\t}\n\n\tif (props.include.meta) {\n\t\tclientRes.meta = formatClientMeta({\n\t\t\tdocument: props.document,\n\t\t\tcollection: props.collection,\n\t\t});\n\t}\n\n\treturn clientRes as unknown as CollectionDocument<TCollectionKey>;\n};\n\nconst formatRefs = (props: {\n\tdata?: FieldRefResponse;\n\tcollection: CollectionBuilder;\n\tconfig: Config;\n\thost: string;\n\tbricksTableSchema: Array<CollectionSchemaTable<LucidBrickTableName>>;\n\tfieldTypes?: FieldTypes[];\n\tflattenRelationRefFields?: boolean;\n}): Partial<Record<FieldTypes | string, FieldRef[]>> | null => {\n\tconst refs: Partial<Record<FieldTypes | string, FieldRef[]>> = {};\n\tif (!props.data) return null;\n\n\tconst localization = {\n\t\tlocales: props.config.localization.locales.map((l) => l.code),\n\t\tdefault: props.config.localization.defaultLocale,\n\t} satisfies FieldRefParams[\"localization\"];\n\n\tfor (const key of props.fieldTypes ?? registeredFieldTypes) {\n\t\tconst formatRef = registeredFields[key].formatRef;\n\t\tconst refData = props.data.data[key];\n\t\tif (!formatRef || !refData || !Array.isArray(refData)) continue;\n\n\t\tconst formattedRefs: FieldRef[] = [];\n\t\tfor (const item of refData) {\n\t\t\tif (item === null || item === undefined) continue;\n\n\t\t\tconst formattedRef = formatRef(item, {\n\t\t\t\tcollection: props.collection,\n\t\t\t\tconfig: props.config,\n\t\t\t\thost: props.host,\n\t\t\t\tbricksTableSchema: props.bricksTableSchema,\n\t\t\t\trelationRefMeta: props.data?.meta?.relation,\n\t\t\t\tflattenRelationRefFields: props.flattenRelationRefFields,\n\t\t\t\tlocalization: localization,\n\t\t\t});\n\t\t\tif (formattedRef === null) continue;\n\t\t\tformattedRefs.push(formattedRef);\n\t\t}\n\n\t\trefs[key] = formattedRefs;\n\t}\n\n\treturn refs;\n};\n\nexport default {\n\tformatMultiple,\n\tformatSingle,\n\tformatClientMultiple,\n\tformatClientSingle,\n\tformatRefs,\n};\n"],"mappings":"oQA4BA,MAAM,EAAkB,GAWlB,CACL,IAAM,EACL,EAAM,YAAc,IAAA,GAIjB,IAAA,GAHA,IAAI,IACJ,EAAM,UAAU,IAAK,GAAa,CAAC,EAAS,YAAa,CAAQ,CAAC,CACnE,EAGH,OAAO,EAAM,UAAU,IAAK,GAAM,CACjC,IAAI,EAAyC,KACzC,EAAyC,KACzC,EAAM,YACT,EAASA,EAAwB,qBAAqB,CACrD,YAAa,EACb,aAAc,EAAM,kBACpB,QAAS,EAAM,SAAW,CAAE,KAAM,CAAC,CAAE,EACrC,WAAY,EAAM,WAClB,OAAQ,EAAM,OACd,KAAM,EAAM,IACb,CAAC,GAEE,EAAM,YACT,EAASA,EAAwB,eAAe,CAC/C,YAAa,EACb,aAAc,EAAM,kBACpB,QAAS,EAAM,SAAW,CAAE,KAAM,CAAC,CAAE,EACrC,WAAY,EAAM,WAClB,OAAQ,EAAM,OACd,KAAM,EAAM,IACb,CAAC,GAGF,IAAM,EAAO,EAAW,CACvB,KAAM,EAAM,QACZ,WAAY,EAAM,WAClB,OAAQ,EAAM,OACd,KAAM,EAAM,KACZ,kBAAmB,EAAM,kBACzB,WAAY,EAAM,QACnB,CAAC,EAED,OAAO,EAAa,CACnB,SAAU,EACV,WAAY,EAAM,WAClB,OAAQ,EAAM,OACN,SACR,OAAQ,GAAU,IAAA,GACZ,OACN,SACC,IAAgB,IAAA,GAMb,IAAA,GALAC,EAA2B,aAAa,CACxC,WAAY,EAAM,WAClB,SAAU,EAAY,IAAI,EAAE,EAAE,EAC9B,KAAM,EAAM,IACb,CAAC,EAEJ,KAAM,EAAM,IACb,CAAC,CACF,CAAC,CACF,EAEM,EAAwB,GASxB,EAAM,GAEJ,CACN,GAAI,EAAM,G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