@prismicio/client
Version:
The official JavaScript + TypeScript client library for Prismic
1 lines • 3.9 kB
Source Map (JSON)
{"version":3,"file":"Asset.cjs","sources":["../../../../src/types/migration/Asset.ts"],"sourcesContent":["import type { Asset } from \"../api/asset/asset\"\nimport type { FilledImageFieldImage } from \"../value/image\"\nimport type { LinkToMediaField } from \"../value/linkToMedia\"\nimport { type RTImageNode } from \"../value/richText\"\n\nimport type { InjectMigrationSpecificTypes } from \"./Document\"\n\n/**\n * An asset to be uploaded to Prismic media library.\n */\nexport type MigrationAssetConfig = {\n\t/**\n\t * ID the assets is indexed with on the migration instance.\n\t *\n\t * @remarks\n\t * This property's value is not necessarily the same as the as the one in the\n\t * `file` property. It is mainly used for deduplication within a `Migration`\n\t * instance.\n\t */\n\tid: string | URL | File | NonNullable<ConstructorParameters<File>[0]>[0]\n\n\t/**\n\t * File to be uploaded as an asset.\n\t */\n\tfile: string | URL | File | NonNullable<ConstructorParameters<File>[0]>[0]\n\n\t/**\n\t * Filename of the asset.\n\t */\n\tfilename: string\n\n\t/**\n\t * Notes about the asset. Notes are private and only visible in Prismic media\n\t * library.\n\t */\n\tnotes?: string\n\n\t/**\n\t * Credits and copyright for the asset if any.\n\t */\n\tcredits?: string\n\n\t/**\n\t * Alternate text for the asset.\n\t */\n\talt?: string\n\n\t/**\n\t * Tags associated with the asset.\n\t *\n\t * @remarks\n\t * Tags should be at least 3 characters long and 20 characters at most.\n\t */\n\ttags?: string[]\n}\n\n/**\n * An image field in a migration.\n */\nexport type MigrationImage =\n\t| PrismicMigrationAsset\n\t| ({\n\t\t\t/**\n\t\t\t * A reference to the migration asset used to resolve the image field's\n\t\t\t * value.\n\t\t\t */\n\t\t\tid: PrismicMigrationAsset\n\t } & Record<string, PrismicMigrationAsset>)\n\n/**\n * A link to media field in a migration.\n */\nexport type MigrationLinkToMedia = Pick<\n\tLinkToMediaField<\"filled\">,\n\t\"link_type\" | \"text\"\n> & {\n\t/**\n\t * A reference to the migration asset used to resolve the link to media\n\t * field's value.\n\t */\n\tid: PrismicMigrationAsset\n}\n\n/**\n * The minimum amount of information needed to represent a link to media field\n * with the migration API.\n */\nexport type MigrationLinkToMediaField =\n\t| Pick<LinkToMediaField<\"filled\">, \"link_type\" | \"id\" | \"text\">\n\t| LinkToMediaField<\"empty\">\n\n/**\n * A rich text image node in a migration.\n */\nexport type MigrationRTImageNode = InjectMigrationSpecificTypes<\n\tPick<RTImageNode, \"type\" | \"linkTo\">\n> & {\n\t/**\n\t * A reference to the migration asset used to resolve the rich text image\n\t * node's value.\n\t */\n\tid: PrismicMigrationAsset\n}\n\n/**\n * A migration asset used with the Prismic Migration API.\n */\nexport class PrismicMigrationAsset {\n\t/**\n\t * Asset object from Prismic, available once created.\n\t */\n\tasset?: Asset\n\n\t/**\n\t * Configuration of the asset.\n\t */\n\tconfig: MigrationAssetConfig\n\n\t/**\n\t * The initial field value this migration field was created with.\n\t */\n\toriginalField?:\n\t\t| FilledImageFieldImage\n\t\t| LinkToMediaField<\"filled\">\n\t\t| RTImageNode\n\n\t/**\n\t * Creates a migration asset used with the Prismic Migration API.\n\t *\n\t * @param config - Configuration of the asset.\n\t * @param initialField - The initial field value if any.\n\t *\n\t * @returns A migration asset instance.\n\t */\n\tconstructor(\n\t\tconfig: MigrationAssetConfig,\n\t\tinitialField?:\n\t\t\t| FilledImageFieldImage\n\t\t\t| LinkToMediaField<\"filled\">\n\t\t\t| RTImageNode,\n\t) {\n\t\tthis.config = config\n\t\tthis.originalField = initialField\n\t}\n}\n"],"names":[],"mappings":";;;;;MA2Ga,sBAAqB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA2BjC,YACC,QACA,cAGc;AA5Bf;AAAA;AAAA;AAAA;AAKA;AAAA;AAAA;AAAA;AAKA;AAAA;AAAA;AAAA;AAoBC,SAAK,SAAS;AACd,SAAK,gBAAgB;AAAA,EAAA;AAEtB;;"}