UNPKG

@lucidcms/core

Version:

The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.

1 lines 1.63 kB
{"version":3,"file":"normalise-column.mjs","names":[],"sources":["../../../../src/libs/collection/helpers/normalise-column.ts"],"sourcesContent":["import type { CollectionSchemaColumn } from \"../../../libs/collection/schema/types.js\";\nimport type { InferredColumn } from \"../../../types.js\";\n\n/**\n * Normalises the column schema for both the columns inferred from collection/brick's along with inferred columns from the DB Adapter implementation\n */\nconst normaliseColumn = (\n\tcolumn: CollectionSchemaColumn | InferredColumn,\n\tsource: CollectionSchemaColumn[\"source\"],\n): CollectionSchemaColumn => {\n\treturn {\n\t\tsource: source,\n\t\tname: column.name,\n\t\tcanAutoRemove:\n\t\t\t\"canAutoRemove\" in column ? (column.canAutoRemove ?? true) : true,\n\t\ttype: column.type,\n\t\tnullable: column.nullable ?? false,\n\t\tdefault: column.default ?? null,\n\t\tforeignKey: column.foreignKey\n\t\t\t? {\n\t\t\t\t\ttable: column.foreignKey.table,\n\t\t\t\t\tcolumn: column.foreignKey.column,\n\t\t\t\t\tonDelete: column.foreignKey.onDelete ?? \"no action\",\n\t\t\t\t\tonUpdate: column.foreignKey.onUpdate ?? \"no action\",\n\t\t\t\t}\n\t\t\t: undefined,\n\t\tunique: column.unique ?? false,\n\t\tprimary: column.primary ?? false,\n\t};\n};\n\nexport default normaliseColumn;\n"],"mappings":"AAMA,MAAM,GACL,EACA,KAEO,CACE,SACR,KAAM,EAAO,KACb,cACC,kBAAmB,EAAU,EAAO,eAAiB,GAAQ,GAC9D,KAAM,EAAO,KACb,SAAU,EAAO,UAAY,GAC7B,QAAS,EAAO,SAAW,KAC3B,WAAY,EAAO,WAChB,CACA,MAAO,EAAO,WAAW,MACzB,OAAQ,EAAO,WAAW,OAC1B,SAAU,EAAO,WAAW,UAAY,YACxC,SAAU,EAAO,WAAW,UAAY,WACzC,EACC,IAAA,GACH,OAAQ,EAAO,QAAU,GACzB,QAAS,EAAO,SAAW,EAC5B"}