1.0.17 • Published 3 years ago

@greenberry/datocms-migration-utils v1.0.17

Weekly downloads
120
License
MIT
Repository
github
Last release
3 years ago

@greenberry/datocms-migration-utils

A collection of utils to help with the development of DatoCMS migration files.

Installation

yarn add @greenberry/datocms-migration-utils -D

API

Each field creator method need 3 arguments a working DatoCMS SiteClient, field options and the modelId you want to attach the field to.

await createFieldMethod(client, options, modelId);

Field Options

createBoolean

KeyTypeRequired
labelString
apiKeyString
hintString
localizedBoolean
requiredBoolean

createColor

KeyTypeRequired
labelString
apiKeyString
hintString
localizedBoolean
requiredBoolean
presetColors[#000]
enableAlphaBoolean

createCTA

KeyTypeRequired
labelString
apiKeyString
hintString
localizedBoolean
requiredBoolean

createDate

KeyTypeRequired
labelString
apiKeyString
hintString
localizedBoolean
requiredBoolean
dateRange{min: 'ISO-8601', max: 'ISO-8601'}

createDateTime

KeyTypeRequired
labelString
apiKeyString
hintString
localizedBoolean
requiredBoolean
dateRange{min: 'ISO-8601', max: 'ISO-8601'}

createEnum

KeyTypeRequired
labelString
apiKeyString
optionsString
defaultValueString
hintString
localizedBoolean
requiredBoolean

createImage

KeyTypeRequired
labelString
apiKeyString
hintString
localizedBoolean
requiredBoolean

createLink

KeyTypeRequired
labelString
apiKeyString
itemsItemType ID
hintString
localizedBoolean
requiredBoolean
uniqueBoolean

createLinks

KeyTypeRequired
labelString
apiKeyString
itemsItemType ID
size{ min: Number, max: Number }
hintString
localizedBoolean
requiredBoolean

createModularContent

KeyTypeRequired
labelString
apiKeyString
blockIdsItemType ID
hintString
localizedBoolean
requiredBoolean

createNumber

KeyTypeRequired
labelString
apiKeyString
hintString
localizedBoolean
requiredBoolean

createSEO

KeyTypeRequired
labelString
apiKeyString
hintString
localizedBoolean

createSingleLine

KeyTypeRequired
labelString
apiKeyString
hintString
localizedBoolean
requiredBoolean
headingBoolean

createSlug

KeyTypeRequired
labelString
apiKeyString
titleFieldField
prefixString
hintString
localizedBoolean
requiredBoolean

createTextArea

KeyTypeRequired
labelString
apiKeyString
hintString
localizedBoolean
requiredBoolean

createWysiwyg

KeyTypeRequired
labelString
apiKeyString
hintString
localizedBoolean
requiredBoolean
toolbarArray

updateModularContent

KeyTypeRequired
labelString
apiKeyString
localizedBoolean
hintString
blockIdsItemType ID

uploadFile

KeyTypeRequired

Color formatting

DatoCMS only accepts a specific format when filling colors. That is why we added a util to format hex values in a shape acceptable by DatoCMS.

const color = formatColor('#000000');
console.log(color);
// {
//   red: 0,
//   blue: 0,
//   green: 0,
//   alpha: 255,
// }

formatColor also accepts a second argument to specify the alpha of the color, this works in the same way as CSS opacity.

const color = formatColor('#000000', 0.8);
console.log(color);
// {
//   red: 0,
//   blue: 0,
//   green: 0,
//   alpha: 204,
// }
1.0.17

3 years ago

1.0.16

3 years ago

1.0.14

3 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago