diff --git a/.github/workflows/main-migrations.yaml b/.github/workflows/main-migrations.yaml new file mode 100644 index 00000000..3c689deb --- /dev/null +++ b/.github/workflows/main-migrations.yaml @@ -0,0 +1,135 @@ +name: Deploy to production + +on: + push: + branches: + - main + +jobs: + apply-main-migrations: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Cache Node.js modules + uses: actions/cache@v3 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + + - name: Check for changes in migrations folder + id: check_changes + run: | + git fetch origin main + + if git diff --quiet HEAD^ HEAD migrations; then + echo "CHANGES=false" >> $GITHUB_ENV + else + echo "CHANGES=true" >> $GITHUB_ENV + fi + + - name: Set up Node.js + if: ${{ env.CHANGES == 'true' }} + uses: actions/setup-node@v4 + with: + node-version: "20" + + - name: Install dependencies + if: ${{ env.CHANGES == 'true' }} + run: npm install --force + + - name: Run TypeScript script + if: ${{ env.CHANGES == 'true' }} + env: + DATO_API_KEY_OPENEARTH_RWS_VIEWER: ${{ secrets.DATO_API_KEY_OPENEARTH_RWS_VIEWER }} + DATO_API_KEY_OPENEARTH_DATA_VIEWER: ${{ secrets.DATO_API_KEY_OPENEARTH_DATA_VIEWER }} + DATO_API_KEY_NL2120: ${{ secrets.DATO_API_KEY_NL2120 }} + run: npm run migrations:apply-main + + prepare: + needs: apply-main-migrations + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Cache Node.js modules + uses: actions/cache@v3 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: "20" + + - name: Install dependencies + run: npm install --force + + - name: Set matrix data + id: set-matrix + run: | + instances=$(node -e 'console.log(JSON.stringify(require("./config/dato/instances.js").instances))') + echo "matrix=$(echo $instances | jq -c '.')" >> $GITHUB_OUTPUT + echo "matrix is set to: $instances" + + deploy-application: + needs: prepare + runs-on: ubuntu-latest + strategy: + matrix: + include: ${{ fromJson(needs.prepare.outputs.matrix) }} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Cache Node.js modules + uses: actions/cache@v3 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: "20" + + - name: Install dependencies + run: npm install --force + + - name: Build application + run: NODE_OPTIONS="--openssl-legacy-provider" npm run build + env: + DATO_API_KEY_OPENEARTH_RWS_VIEWER: ${{ secrets.DATO_API_KEY_OPENEARTH_RWS_VIEWER }} + DATO_API_KEY_OPENEARTH_DATA_VIEWER: ${{ secrets.DATO_API_KEY_OPENEARTH_DATA_VIEWER }} + DATO_API_KEY_NL2120: ${{ secrets.DATO_API_KEY_NL2120 }} + DATO_INSTANCE_CURRENT: ${{ matrix.name }} + DATO_ENVIRONMENT: main + VUE_APP_MAPBOX_TOKEN: ${{ secrets.VUE_APP_MAPBOX_TOKEN }} + VUE_APP_API_ENDPOINT: ${{ secrets.VUE_APP_API_ENDPOINT }} + VUE_APP_AQUADESK_KEY: ${{ secrets.VUE_APP_AQUADESK_KEY }} + VUE_APP_PIWIK_CONTAINER_ID: ${{ secrets.VUE_APP_PIWIK_CONTAINER_ID }} + VUE_APP_WMR_KEY: ${{ secrets.VUE_APP_WMR_KEY }} + DEEPL_KEY: ${{ secrets.DEEPL_KEY }} + + - name: Deploy to Netlify + uses: nwtgck/actions-netlify@v3.0 + with: + publish-dir: "./dist" + production-branch: main + github-token: ${{ secrets.GITHUB_TOKEN }} + env: + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} + NETLIFY_SITE_ID: ${{ matrix.netlifySiteId }} diff --git a/.github/workflows/staging-migrations.yaml b/.github/workflows/staging-migrations.yaml new file mode 100644 index 00000000..06c420c6 --- /dev/null +++ b/.github/workflows/staging-migrations.yaml @@ -0,0 +1,115 @@ +name: Deploy to staging + +on: + pull_request: + types: [opened, synchronize] + +jobs: + apply-staging-migrations: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Check for changes in migrations folder + id: check_changes + run: | + git fetch origin main + git fetch origin ${{ github.head_ref || github.ref_name }} + git checkout ${{ github.head_ref || github.ref_name }} + + if git diff --quiet origin/main HEAD -- migrations; then + echo "CHANGES=false" >> $GITHUB_ENV + else + echo "CHANGES=true" >> $GITHUB_ENV + fi + + - name: Set up Node.js + if: ${{ env.CHANGES == 'true' }} + uses: actions/setup-node@v4 + with: + node-version: "20" + + - name: Install dependencies + if: ${{ env.CHANGES == 'true' }} + run: npm install --force + + - name: Run TypeScript script + if: ${{ env.CHANGES == 'true' }} + env: + DATO_API_KEY_OPENEARTH_RWS_VIEWER: ${{ secrets.DATO_API_KEY_OPENEARTH_RWS_VIEWER }} + DATO_API_KEY_OPENEARTH_DATA_VIEWER: ${{ secrets.DATO_API_KEY_OPENEARTH_DATA_VIEWER }} + DATO_API_KEY_NL2120: ${{ secrets.DATO_API_KEY_NL2120 }} + run: npm run migrations:apply-staging + + prepare: + needs: apply-staging-migrations + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: "20" + + - name: Install dependencies + run: npm install --force + + - name: Set matrix data + id: set-matrix + run: | + instances=$(node -e 'console.log(JSON.stringify(require("./config/dato/instances.js").instances))') + echo "matrix=$(echo $instances | jq -c '.')" >> $GITHUB_OUTPUT + echo "matrix is set to: $instances" + + deploy-application: + needs: prepare + runs-on: ubuntu-latest + strategy: + matrix: + include: ${{ fromJson(needs.prepare.outputs.matrix) }} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: "20" + + - name: Install dependencies + run: npm install --force + + - name: Build application + run: NODE_OPTIONS="--openssl-legacy-provider" npm run build + env: + DATO_API_KEY_OPENEARTH_RWS_VIEWER: ${{ secrets.DATO_API_KEY_OPENEARTH_RWS_VIEWER }} + DATO_API_KEY_OPENEARTH_DATA_VIEWER: ${{ secrets.DATO_API_KEY_OPENEARTH_DATA_VIEWER }} + DATO_API_KEY_NL2120: ${{ secrets.DATO_API_KEY_NL2120 }} + DATO_INSTANCE_CURRENT: ${{ matrix.name }} + DATO_ENVIRONMENT: staging + VUE_APP_MAPBOX_TOKEN: ${{ secrets.VUE_APP_MAPBOX_TOKEN }} + VUE_APP_API_ENDPOINT: ${{ secrets.VUE_APP_API_ENDPOINT }} + VUE_APP_AQUADESK_KEY: ${{ secrets.VUE_APP_AQUADESK_KEY }} + VUE_APP_PIWIK_CONTAINER_ID: ${{ secrets.VUE_APP_PIWIK_CONTAINER_ID }} + VUE_APP_WMR_KEY: ${{ secrets.VUE_APP_WMR_KEY }} + DEEPL_KEY: ${{ secrets.DEEPL_KEY }} + + - name: Deploy to Netlify + uses: nwtgck/actions-netlify@v3.0 + with: + publish-dir: "./dist" + production-branch: main + github-token: ${{ secrets.GITHUB_TOKEN }} + enable-commit-comment: false + enable-pull-request-comment: true + overwrites-pull-request-comment: true + env: + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} + NETLIFY_SITE_ID: ${{ matrix.netlifySiteId }} diff --git a/README.md b/README.md index f55a7415..e9b21d08 100644 --- a/README.md +++ b/README.md @@ -81,8 +81,25 @@ For each instance: Usage: ```bash -bash npm run migrations:apply-main ``` -This update adds a new section to the `README.md` file, documenting the `apply-main` script and its usage. +## GitHub Actions Workflows + +### Deploy to Production + +The `main-migrations.yaml` workflow is triggered on a push to the `main` branch. It performs the following steps: + +1. Checks out the repository. +1. Checks for changes in the `migrations` folder. +1. If changes are detected, sets up Node.js, installs dependencies, and runs the `migrations:apply-main` script. +1. Deploys the application to Netlify using the specified instances. + +### Deploy to Staging + +The `staging-migrations.yaml` workflow is triggered on pull request events (opened or synchronized). It performs the following steps: + +1. Checks out the repository. +1. Checks for changes in the `migrations` folder. +1. If changes are detected, sets up Node.js, installs dependencies, and runs the `migrations:apply-staging` script. +1. Deploys the application to Netlify using the specified instances. diff --git a/config/dato/datocms.mjs b/config/dato/datocms.mjs index 4a400d70..1c6873aa 100644 --- a/config/dato/datocms.mjs +++ b/config/dato/datocms.mjs @@ -23,7 +23,7 @@ if (!currentInstance) { throw new Error("No current instance found"); } -const token = currentInstance.key; +const token = currentInstance.datoApiKey; const endpoint = process.env.NODE_ENV === 'production' diff --git a/config/dato/instances.d.ts b/config/dato/instances.d.ts index ecd398cb..17f00377 100644 --- a/config/dato/instances.d.ts +++ b/config/dato/instances.d.ts @@ -1,4 +1,5 @@ export const instances: Array<{ name: string; - key: string; + datoApiKey: string; + netlifySiteId: string; }>; diff --git a/config/dato/instances.js b/config/dato/instances.js index 79d5a7d8..38affcad 100644 --- a/config/dato/instances.js +++ b/config/dato/instances.js @@ -5,14 +5,17 @@ dotenv.config(); module.exports.instances = [ { name: "nl2120", - key: process.env.DATO_API_KEY_NL2120, + datoApiKey: process.env.DATO_API_KEY_NL2120, + netlifySiteId: "1f6372f6-c532-4e0e-bba7-dee08678d518", }, { name: "openearth-data-viewer", - key: process.env.DATO_API_KEY_OPENEARTH_DATA_VIEWER, + datoApiKey: process.env.DATO_API_KEY_OPENEARTH_DATA_VIEWER, + netlifySiteId: "1785f3f6-b4cf-42de-bea6-b57d48a5c664", }, { name: "openearth-rws-viewer", - key: process.env.DATO_API_KEY_OPENEARTH_RWS_VIEWER, + datoApiKey: process.env.DATO_API_KEY_OPENEARTH_RWS_VIEWER, + netlifySiteId: "119b8ff3-5b22-4995-b43b-b31f21ba77c3", }, ]; diff --git a/migrations/1727855666_test.ts b/migrations/1727855666_test.ts new file mode 100644 index 00000000..fdcc8559 --- /dev/null +++ b/migrations/1727855666_test.ts @@ -0,0 +1,17 @@ +import { Client } from "@datocms/cli/lib/cma-client-node"; + +export default async function (client: Client): Promise { + const articleModel = await client.itemTypes.create({ + name: "Article", + api_key: "article", + }); + + await client.fields.create(articleModel, { + label: "Title", + api_key: "title", + field_type: "string", + validators: { + required: {}, + }, + }); +} diff --git a/migrations/1729260241_inspireDatasetFields.ts b/migrations/1729260241_inspireDatasetFields.ts new file mode 100644 index 00000000..a03795cf --- /dev/null +++ b/migrations/1729260241_inspireDatasetFields.ts @@ -0,0 +1,1278 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +import { Client, SimpleSchemaTypes } from "@datocms/cli/lib/cma-client-node"; + +export default async function (client: Client) { + const newFields: Record = {}; + const newFieldsets: Record = {}; + + console.log("Creating new fields/fieldsets"); + + const itemTypes = await client.itemTypes.list(); + + const inspireDatasetItemType = itemTypes.find( + (itemType: any) => itemType.api_key === "inspire_dataset" + ) || { id: "" }; + + if (inspireDatasetItemType === undefined) { + throw new Error("Item type 'inspire_dataset' not found"); + } + + const fieldsets = await client.fieldsets.list(inspireDatasetItemType.id); + const findFieldset = (title: string) => + fieldsets.find((fieldset: any) => fieldset.title === title); + + const fields = await client.fields.list(inspireDatasetItemType.id); + const findField = (label: string) => + fields.find((field: any) => field.label === label); + + if (findFieldset("Informatie over de bron")) { + console.log('Fieldset "Informatie over de bron" already exists'); + } else { + console.log( + 'Create fieldset "Informatie over de bron" in model "Inspire Dataset" (`inspire_dataset`)' + ); + newFieldsets["560136"] = await client.fieldsets.create( + inspireDatasetItemType.id, + { + title: "Informatie over de bron", + } + ); + } + + if (findFieldset("Verantwoordelijke organisatie bron")) { + console.log('Fieldset "Verantwoordelijke organisatie bron" already exists'); + } else { + console.log( + 'Create fieldset "Verantwoordelijke organisatie bron" in model "Inspire Dataset" (`inspire_dataset`)' + ); + await client.fieldsets.create(inspireDatasetItemType.id, { + id: "INy1cspgRTCwgrfVa2fTDw", + title: "Verantwoordelijke organisatie bron", + hint: "Gebruik de volledig uitgeschreven naam van de verantwoordelijke organisatie. De afkorting kan toegevoegd worden aan de organisatienaam. verantwoordelijke organisatie van de bron, bij voorkeur uri uit bijvoorbeeld http://standaarden.overheid.nl/owms/terms/Overheidsorganisatie.html", + }); + } + + if (findFieldset("Trefwoorden")) { + console.log('Fieldset "Trefwoorden" already exists'); + } else { + console.log( + 'Create fieldset "Trefwoorden" in model "Inspire Dataset" (`inspire_dataset`)' + ); + newFieldsets["560134"] = await client.fieldsets.create( + inspireDatasetItemType.id, + { + title: "Trefwoorden", + } + ); + } + + if (findFieldset("Beperkingen")) { + console.log('Fieldset "Beperkingen" already exists'); + } else { + console.log( + 'Create fieldset "Beperkingen" in model "Inspire Dataset" (`inspire_dataset`)' + ); + newFieldsets["560132"] = await client.fieldsets.create( + inspireDatasetItemType.id, + { + title: "Beperkingen", + } + ); + } + + if (findFieldset("Ruimtelijke informatie bron")) { + console.log('Fieldset "Ruimtelijke informatie bron" already exists'); + } else { + console.log( + 'Create fieldset "Ruimtelijke informatie bron" in model "Inspire Dataset" (`inspire_dataset`)' + ); + newFieldsets["560133"] = await client.fieldsets.create( + inspireDatasetItemType.id, + { + title: "Ruimtelijke informatie bron", + } + ); + } + + if (findFieldset("Kwaliteitsinformatie")) { + console.log('Fieldset "Kwaliteitsinformatie" already exists'); + } else { + console.log( + 'Create fieldset "Kwaliteitsinformatie" in model "Inspire Dataset" (`inspire_dataset`)' + ); + await client.fieldsets.create(inspireDatasetItemType.id, { + id: "TOSwC4esQFKcXNrW20gK1Q", + title: "Kwaliteitsinformatie", + }); + } + + if (findFieldset("Informatie over de metadata")) { + console.log('Fieldset "Informatie over de metadata" already exists'); + } else { + console.log( + 'Create fieldset "Informatie over de metadata" in model "Inspire Dataset" (`inspire_dataset`)' + ); + newFieldsets["561206"] = await client.fieldsets.create( + inspireDatasetItemType.id, + { + title: "Informatie over de metadata", + } + ); + } + + if (findFieldset("Verantwoordelijke organisatie metadata")) { + console.log( + 'Fieldset "Verantwoordelijke organisatie metadata" already exists' + ); + } else { + console.log( + 'Create fieldset "Verantwoordelijke organisatie metadata" in model "Inspire Dataset" (`inspire_dataset`)' + ); + await client.fieldsets.create(inspireDatasetItemType.id, { + id: "c4ZNV0cQTamwB4mBwbSFpg", + title: "Verantwoordelijke organisatie metadata", + hint: "Dit element bevat de naam van de organisatie verantwoordelijk voor de metadata.", + }); + } + + if (findFieldset("Metadata standaard")) { + console.log('Fieldset "Metadata standaard" already exists'); + } else { + console.log( + 'Create fieldset "Metadata standaard" in model "Inspire Dataset" (`inspire_dataset`)' + ); + await client.fieldsets.create(inspireDatasetItemType.id, { + id: "d5CCVL3pSxGMdchqXBBQJQ", + title: "Metadata standaard", + hint: "De gehanteerde metadata standaard", + }); + } + + if (findField("Trefwoord")) { + console.log( + 'Field "Trefwoord" (`descriptivekeywords_keywords`) already exists' + ); + } else { + console.log( + 'Create Modular Content (Multiple blocks) field "Trefwoord" (`descriptivekeywords_keywords`) in model "Inspire Dataset" (`inspire_dataset`)' + ); + + const item_types = await client.itemTypes.list(); + const metadataTextItemType = item_types.find( + (itemType: any) => itemType.api_key === "metadata_text_item" + ); + + if (metadataTextItemType === undefined) { + throw new Error("Item type 'metadata_text_item' not found"); + } + + newFields["10143360"] = await client.fields.create( + inspireDatasetItemType.id, + { + label: "Trefwoord", + field_type: "rich_text", + api_key: "descriptivekeywords_keywords", + hint: 'Voor datasets en dataset series die betrekking hebben op INSPIRE dient het de relevante thema\u2019s te beschrijven zoals ze zijn gedefinieerd in annex I, II en III van de directive. Zie ook ISO 19115 NL profiel', + validators: { + rich_text_blocks: { item_types: [metadataTextItemType.id] }, + size: { min: 1 }, + }, + appearance: { + addons: [], + editor: "rich_text", + parameters: { start_collapsed: true }, + }, + default_value: null, + } + ); + } + + if (findField("Juridische toegangsrestricties")) { + console.log( + 'Field "Juridische toegangsrestricties" (`resourceconstraints_accessconstraints`) already exists' + ); + } else { + console.log( + 'Create Single-line string field "Juridische toegangsrestricties" (`resourceconstraints_accessconstraints`) in model "Inspire Dataset" (`inspire_dataset`)' + ); + newFields["10143362"] = await client.fields.create( + inspireDatasetItemType.id, + { + label: "Juridische toegangsrestricties", + field_type: "string", + api_key: "resourceconstraints_accessconstraints", + hint: 'Zie ook ISO 19115 NL profiel', + validators: { required: {} }, + appearance: { + addons: [], + editor: "string_select", + parameters: { + options: [ + { + hint: "Exclusief recht voor publicatie, productie, of verkoop van rechten op een literair, theater, muzikaal of artistiek werk, of op het gebruik van een commerci\u00EBle druk of label, toegekend bij wet voor een specifieke periode of tijd aan een auteur, componist, artiest of distributeur.", + label: "Copyright", + value: "Copyright", + }, + { + hint: "Overheid heeft een exclusief recht toegekend om een uitvinding te maken, verkopen, gebruiken of in licentie uit te geven.", + label: "Patent", + value: "Patent", + }, + { + hint: "Geproduceerde of verkochte informatie wachtend op een patent.", + label: "PatentPending", + value: "PatentPending", + }, + { + hint: "Een naam, symbool of ander object om een product te identificeren, wat officieel geregistreerd is en gebruik wettelijk voorbehouden is aan de eigenaar of fabrikant.", + label: "Trademark", + value: "Trademark", + }, + { + hint: "Formele toestemming of iets te doen.", + label: "License", + value: "License", + }, + { + hint: "Recht op een financieel voordeel van en controle hebben op de distributie een niet tastbaar eigendom wat het resultaat is van creativiteit.", + label: "IntellectualPropertyRights", + value: "IntellectualPropertyRights", + }, + { + hint: "Verbod op distributie en gebruik.", + label: "Restricted", + value: "Restricted", + }, + { + hint: "Restrictie niet opgenomen in lijst.", + label: "OtherRestrictions", + value: "OtherRestrictions", + }, + ], + }, + }, + default_value: "Copyright", + } + ); + } + + if (findField("Titel van de bron")) { + console.log('Field "Titel van de bron" (`citation_title`) already exists'); + } else { + console.log( + 'Create Single-line string field "Titel van de bron" (`citation_title`) in model "Inspire Dataset" (`inspire_dataset`)' + ); + newFields["10143371"] = await client.fields.create( + inspireDatasetItemType.id, + { + label: "Titel van de bron", + field_type: "string", + api_key: "citation_title", + hint: 'Dit element dient om de naam van de dataset in vast te leggen. Zie ook ISO 19115 NL profiel\n', + validators: { required: {} }, + appearance: { + addons: [], + editor: "single_line", + parameters: { heading: false, placeholder: null }, + }, + default_value: "", + } + ); + } + + if (findField("Hiƫrarchieniveau")) { + console.log('Field "Hiƫrarchieniveau" (`hierarchylevel`) already exists'); + } else { + console.log( + 'Create Single-line string field "Hi\u00EBrarchieniveau" (`hierarchylevel`) in model "Inspire Dataset" (`inspire_dataset`)' + ); + newFields["10162515"] = await client.fields.create( + inspireDatasetItemType.id, + { + label: "Hi\u00EBrarchieniveau", + field_type: "string", + api_key: "hierarchylevel", + hint: 'Het element geeft aan waarop de metadata betrekking heeft, de dataset of dataset serie. Zie ook ISO 19115 NL profiel', + validators: { required: {}, enum: { values: ["dataset", "series"] } }, + appearance: { + addons: [], + editor: "string_select", + parameters: { + options: [ + { + hint: "Informatie heeft betrekking op de dataset.", + label: "Dataset", + value: "dataset", + }, + { + hint: "Informatie heeft betrekking op de serie.", + label: "Series", + value: "series", + }, + ], + }, + }, + default_value: "dataset", + } + ); + } + + if (findField("Niveau kwaliteitsbeschrijving")) { + console.log( + 'Field "Niveau kwaliteitsbeschrijving" (`level`) already exists' + ); + } else { + console.log( + 'Create Single-line string field "Niveau kwaliteitsbeschrijving" (`level`) in model "Inspire Dataset" (`inspire_dataset`)' + ); + await client.fields.create(inspireDatasetItemType.id, { + id: "MciOlCyATDqKAeWCVthfgg", + label: "Niveau kwaliteitsbeschrijving", + field_type: "string", + api_key: "level", + hint: 'Dit element beschrijft het niveau waarop de kwaliteitsinformatie betrekking heeft. Zie ook ISO 19115 NL profiel', + appearance: { + addons: [], + editor: "string_select", + parameters: { + options: [ + { + hint: "Informatie heeft betrekking op de dataset.", + label: "dataset", + value: "dataset", + }, + { + hint: "Informatie heeft betrekking op de serie.", + label: "series", + value: "series", + }, + ], + }, + }, + default_value: "", + }); + } + + if (findField("Ruimtelijk schema")) { + console.log( + 'Field "Ruimtelijk schema" (`md_spatialrepresentationtypecode`) already exists' + ); + } else { + console.log( + 'Create Single-line string field "Ruimtelijk schema" (`md_spatialrepresentationtypecode`) in model "Inspire Dataset" (`inspire_dataset`)' + ); + await client.fields.create(inspireDatasetItemType.id, { + id: "fFAppifMRJeYDqnflH6d8w", + label: "Ruimtelijk schema", + field_type: "string", + api_key: "md_spatialrepresentationtypecode", + hint: 'Dit element is conditioneel. Dit element is verplicht voor INSPIRE. Er dient een waarde uit de codelijst SpatialRepresentationType gebruikt te worden. Zie verder ISO 19115 NL Profiel', + appearance: { + addons: [], + editor: "string_select", + parameters: { + options: [ + { + hint: "Vector data wordt gebruikt om geografische data te representeren.", + label: "vector", + value: "vector", + }, + { + hint: "Grid data wordt gebruikt om geografische data te representeren", + label: "grid", + value: "grid", + }, + { + hint: "Tekstuele of tabel data wordt gebruikt om geografische data te representeren.", + label: "textTable", + value: "textTable", + }, + { + hint: "Triangulated irregular network", + label: "tin", + value: "tin", + }, + ], + }, + }, + default_value: "vector", + }); + } + + if (findField("Organisatie")) { + console.log('Field "Organisatie" (`organisationname`) already exists'); + } else { + console.log( + 'Create Single-line string field "Organisatie" (`organisationname`) in model "Inspire Dataset" (`inspire_dataset`)' + ); + await client.fields.create(inspireDatasetItemType.id, { + id: "EToHPBiYTSOZ80SxmAWcpg", + label: "Organisatie", + field_type: "string", + api_key: "organisationname", + hint: 'Gebruik de volledig uitgeschreven naam van de verantwoordelijke organisatie. Zie ook ISO 19115 NL profiel', + appearance: { + addons: [], + editor: "single_line", + parameters: { heading: false, placeholder: null }, + }, + default_value: "Rijkswaterstaat", + }); + } + + if (findField("Gebruiksbeperkingen")) { + console.log( + 'Field "Gebruiksbeperkingen" (`resourceconstraints_useconstraints`) already exists' + ); + } else { + console.log( + 'Create Single-line string field "Gebruiksbeperkingen" (`resourceconstraints_useconstraints`) in model "Inspire Dataset" (`inspire_dataset`)' + ); + newFields["10143361"] = await client.fields.create( + inspireDatasetItemType.id, + { + label: "Gebruiksbeperkingen", + field_type: "string", + api_key: "resourceconstraints_useconstraints", + hint: 'Dit element bevat toepassingen waarvoor de dataset niet geschikt is. Standaard waarde is geen gebruiks limitatie. \nZie ook ISO 19115 NL profiel', + appearance: { + addons: [], + editor: "string_select", + parameters: { + options: [ + { + hint: "", + label: "Niet te gebruiken voor navigatie", + value: "Niet te gebruiken voor navigatie", + }, + { + hint: "", + label: "Geen gebruiks limitatie", + value: "Geen gebruiks limitaties", + }, + ], + }, + }, + default_value: "Geen gebruiks limitaties", + } + ); + } + + if (findField("Datumtype van de bron")) { + console.log( + 'Field "Datumtype van de bron" (`citation_date_datetype`) already exists' + ); + } else { + console.log( + 'Create Single-line string field "Datumtype van de bron" (`citation_date_datetype`) in model "Inspire Dataset" (`inspire_dataset`)' + ); + newFields["10143370"] = await client.fields.create( + inspireDatasetItemType.id, + { + label: "Datumtype van de bron", + field_type: "string", + api_key: "citation_date_datetype", + hint: 'Dit element bevat het type gebeurtenis waar de datum betrekking op heeft. Zie ook ISO 19115 NL profiel\n', + validators: { + required: {}, + enum: { values: ["creation", "publication", "revision"] }, + }, + appearance: { + addons: [], + editor: "string_select", + parameters: { + options: [ + { + hint: "Datum waarop de dataset of dataset serie is gecre\u00EBerd.", + label: "Creation", + value: "creation", + }, + { + hint: "Publicatie datum waarop de dataset of dataset serie is gepubliceerd.", + label: "Publication", + value: "publication", + }, + { + hint: "Datum waarop de dataset of dataset serie is gecontroleerd, verbeterd of is gewijzigd.", + label: "Revision", + value: "revision", + }, + ], + }, + }, + default_value: "publication", + } + ); + } + + if (findField("Algemene beschrijving herkomst")) { + console.log( + 'Field "Algemene beschrijving herkomst" (`lineage_statement`) already exists' + ); + } else { + console.log( + 'Create Multiple-paragraph text field "Algemene beschrijving herkomst" (`lineage_statement`) in model "Inspire Dataset" (`inspire_dataset`)' + ); + newFields["10162665"] = await client.fields.create( + inspireDatasetItemType.id, + { + label: "Algemene beschrijving herkomst", + field_type: "text", + api_key: "lineage_statement", + hint: 'Dit element beschrijft de proceshistorie. Zie ook ISO 19115 NL profiel', + validators: { required: {} }, + appearance: { + addons: [], + editor: "textarea", + parameters: { placeholder: null }, + type: "textarea", + }, + default_value: "", + } + ); + } + + if (findField("Links")) { + console.log('Field "Links" (`links`) already exists'); + } else { + console.log( + 'Create Modular Content (Multiple blocks) field "Links" (`links`) in model "Inspire Dataset" (`inspire_dataset`)' + ); + + const metadataLinkItemType = itemTypes.find( + (itemType: any) => itemType.api_key === "metadata_link" + ); + + if (metadataLinkItemType === undefined) { + throw new Error("Item type 'metadata_link' not found"); + } + + newFields["11526998"] = await client.fields.create( + inspireDatasetItemType.id, + { + label: "Links", + field_type: "rich_text", + api_key: "links", + validators: { + rich_text_blocks: { item_types: [metadataLinkItemType.id] }, + }, + appearance: { + addons: [], + editor: "rich_text", + parameters: { start_collapsed: false }, + }, + default_value: null, + } + ); + } + + if (findField("e-mail")) { + console.log('Field "e-mail" (`electronicmailaddress`) already exists'); + } else { + console.log( + 'Create Single-line string field "e-mail" (`electronicmailaddress`) in model "Inspire Dataset" (`inspire_dataset`)' + ); + await client.fields.create(inspireDatasetItemType.id, { + id: "NzxaGK5sSoyuErg9Tabo1Q", + label: "e-mail", + field_type: "string", + api_key: "electronicmailaddress", + hint: 'Dit element bevat het e-mail adres van de verantwoordelijke organisatie van de bron. Gebruik bij voorkeur een functioneel e-mail adres. Zie ook Zie ook ISO 19115 NL profiel', + validators: { format: { predefined_pattern: "email" } }, + appearance: { + addons: [], + editor: "single_line", + parameters: { heading: false, placeholder: null }, + }, + default_value: "waterinfo-extra@rws.nl", + }); + } + + if (findField("Metadatastandaard versie")) { + console.log( + 'Field "Metadatastandaard versie" (`metadatastandardversion`) already exists' + ); + } else { + console.log( + 'Create Single-line string field "Metadatastandaard versie" (`metadatastandardversion`) in model "Inspire Dataset" (`inspire_dataset`)' + ); + await client.fields.create(inspireDatasetItemType.id, { + id: "BEF9VIoJRgiKa6SZSZQTDw", + label: "Metadatastandaard versie", + field_type: "string", + api_key: "metadatastandardversion", + hint: 'Dit element is nodig om uitbreidingen of verdere beperkingen op standaarden aan te geven. Dit element bevat de versie (de volledige naam van het profiel) van de metadatastandaard die wordt gebruikt. Zie ook ISO 19115 NL profiel', + appearance: { + addons: [], + editor: "single_line", + parameters: { heading: false, placeholder: null }, + }, + default_value: + "Nederlands metadata profiel op ISO 19115 voor geografie 2.0.0", + }); + } + + if (findField("Thesaurusname")) { + console.log('Field "Thesaurusname" (`thesaurusname`) already exists'); + } else { + console.log( + 'Create Single-line string field "Thesaurusname" (`thesaurusname`) in model "Inspire Dataset" (`inspire_dataset`)' + ); + await client.fields.create(inspireDatasetItemType.id, { + id: "LoXTVry5RTWfgDj2l9OAhw", + label: "Thesaurusname", + field_type: "string", + api_key: "thesaurusname", + hint: 'Dit is een conditioneel element. Het is verplicht als een trefwoord uit een thesaurus afkomstig is zoals in ieder geval voor de INSPIRE thema\u2019s. Het bevat de naam van de thesaurus waar het trefwoord uit afkomstig is. Voor INSPIRE wordt de naam van de thesaurus gehanteerd, zoals voorgeschreven in de metadataguidelines van INSPIRE. Zie voor GEMET https://www.eionet.europa.eu/gemet/en/themes/. \nZie ook ISO 19115 NL profiel', + appearance: { + addons: [], + editor: "string_select", + parameters: { + options: [ + { hint: "", label: "AQUO IM Metingen", value: "AQUO IM Metingen" }, + { + hint: "", + label: "GEMET \u2013 INSPIRE themes, version 1.0", + value: "GEMET \u2013 INSPIRE themes, version 1.0", + }, + ], + }, + }, + default_value: "AQUO IM Metingen", + }); + } + + if (findField("Datum van de bron")) { + console.log( + 'Field "Datum van de bron" (`citation_date_date`) already exists' + ); + } else { + console.log( + 'Create Date field "Datum van de bron" (`citation_date_date`) in model "Inspire Dataset" (`inspire_dataset`)' + ); + newFields["10143369"] = await client.fields.create( + inspireDatasetItemType.id, + { + label: "Datum van de bron", + field_type: "date", + api_key: "citation_date_date", + hint: 'Op z\u2019n minst \u00E9\u00E9n van de elementen Datum creatie, Datum publicatie of Datum revisie is verplicht. Zie ook ISO 19115 NL profiel\n', + validators: { required: {} }, + appearance: { addons: [], editor: "date_picker", parameters: {} }, + default_value: null, + } + ); + } + + if (findField("rol")) { + console.log('Field "rol" (`role`) already exists'); + } else { + console.log( + 'Create Single-line string field "rol" (`role`) in model "Inspire Dataset" (`inspire_dataset`)' + ); + await client.fields.create(inspireDatasetItemType.id, { + id: "ELSrYu9EQO60TyeUB_bDzA", + label: "rol", + field_type: "string", + api_key: "role", + hint: 'Dit element geeft de rol van de verantwoordelijke organisatie van de bron weer. Zie ook ISO 19115 NL profiel', + appearance: { + addons: [], + editor: "string_select", + parameters: { + options: [ + { + hint: "Partij die de data verstrekt.", + label: "resourceProvider", + value: "resourceProvider", + }, + { + hint: "Partij verantwoordelijk voor het beheer van de data.", + label: "custodian", + value: "custodian", + }, + { + hint: "Partij die eigenaar is van de data.", + label: "owner", + value: "owner", + }, + { + hint: "Partij die de data gebruikt.", + label: "user", + value: "user", + }, + { + hint: "Partij die de data verstrekt.", + label: "distributor", + value: "distributor", + }, + { + hint: "Partij die de data heeft gecre\u00EBerd.", + label: "originator", + value: "originator", + }, + { + hint: "Partij die optreedt als contactpunt voor uitwisselen van kennis of verstrekking van de data.", + label: "pointOfContact", + value: "pointOfContact", + }, + { + hint: "Partij die betrokken was bij de uitvoering van onderzoek.", + label: "principalInvestigator", + value: "principalInvestigator", + }, + { + hint: "Partij die de data heeft bewerkt, zodanig dat de data is gewijzigd.", + label: "processor", + value: "processor", + }, + { + hint: "Partij die de data publiceert.", + label: "publisher", + value: "publisher", + }, + { + hint: "Partij die auteur is van de data.", + label: "author", + value: "author", + }, + ], + }, + }, + default_value: "pointofcontact", + }); + } + + if (findField("Juridische toegangsrestricties")) { + console.log( + 'Field "Juridische toegangsrestricties" (`resourceconstraints_accessconstraints`) already exists' + ); + } else { + console.log( + 'Create Single-line string field "Juridische toegangsrestricties" (`resourceconstraints_accessconstraints`) in model "Inspire Dataset" (`inspire_dataset`)' + ); + newFields["10143362"] = await client.fields.create( + inspireDatasetItemType.id, + { + label: "Juridische toegangsrestricties", + field_type: "string", + api_key: "resourceconstraints_accessconstraints", + hint: 'Zie ook ISO 19115 NL profiel', + validators: { required: {} }, + appearance: { + addons: [], + editor: "string_select", + parameters: { + options: [ + { + hint: "Exclusief recht voor publicatie, productie, of verkoop van rechten op een literair, theater, muzikaal of artistiek werk, of op het gebruik van een commerci\u00EBle druk of label, toegekend bij wet voor een specifieke periode of tijd aan een auteur, componist, artiest of distributeur.", + label: "Copyright", + value: "Copyright", + }, + { + hint: "Overheid heeft een exclusief recht toegekend om een uitvinding te maken, verkopen, gebruiken of in licentie uit te geven.", + label: "Patent", + value: "Patent", + }, + { + hint: "Geproduceerde of verkochte informatie wachtend op een patent.", + label: "PatentPending", + value: "PatentPending", + }, + { + hint: "Een naam, symbool of ander object om een product te identificeren, wat officieel geregistreerd is en gebruik wettelijk voorbehouden is aan de eigenaar of fabrikant.", + label: "Trademark", + value: "Trademark", + }, + { + hint: "Formele toestemming of iets te doen.", + label: "License", + value: "License", + }, + { + hint: "Recht op een financieel voordeel van en controle hebben op de distributie een niet tastbaar eigendom wat het resultaat is van creativiteit.", + label: "IntellectualPropertyRights", + value: "IntellectualPropertyRights", + }, + { + hint: "Verbod op distributie en gebruik.", + label: "Restricted", + value: "Restricted", + }, + { + hint: "Restrictie niet opgenomen in lijst.", + label: "OtherRestrictions", + value: "OtherRestrictions", + }, + ], + }, + }, + default_value: "Copyright", + } + ); + } + + if (findField("Titel van de bron")) { + console.log('Field "Titel van de bron" (`citation_title`) already exists'); + } else { + console.log( + 'Create Single-line string field "Titel van de bron" (`citation_title`) in model "Inspire Dataset" (`inspire_dataset`)' + ); + newFields["10143371"] = await client.fields.create( + inspireDatasetItemType.id, + { + label: "Titel van de bron", + field_type: "string", + api_key: "citation_title", + hint: 'Dit element dient om de naam van de dataset in vast te leggen. Zie ook ISO 19115 NL profiel\n', + validators: { required: {} }, + appearance: { + addons: [], + editor: "single_line", + parameters: { heading: false, placeholder: null }, + }, + default_value: "", + } + ); + } + + if (findField("Hi\u00EBrarchieniveau")) { + console.log( + 'Field "Hi\u00EBrarchieniveau" (`hierarchylevel`) already exists' + ); + } else { + console.log( + 'Create Single-line string field "Hi\u00EBrarchieniveau" (`hierarchylevel`) in model "Inspire Dataset" (`inspire_dataset`)' + ); + newFields["10162515"] = await client.fields.create( + inspireDatasetItemType.id, + { + label: "Hi\u00EBrarchieniveau", + field_type: "string", + api_key: "hierarchylevel", + hint: 'Het element geeft aan waarop de metadata betrekking heeft, de dataset of dataset serie. Zie ook ISO 19115 NL profiel', + validators: { required: {}, enum: { values: ["dataset", "series"] } }, + appearance: { + addons: [], + editor: "string_select", + parameters: { + options: [ + { + hint: "Informatie heeft betrekking op de dataset.", + label: "Dataset", + value: "dataset", + }, + { + hint: "Informatie heeft betrekking op de serie.", + label: "Series", + value: "series", + }, + ], + }, + }, + default_value: "dataset", + } + ); + } + + if (findField("Metadata standaard naam")) { + console.log( + 'Field "Metadata standaard naam" (`metadatastandardname`) already exists' + ); + } else { + console.log( + 'Create Single-line string field "Metadata standaard naam" (`metadatastandardname`) in model "Inspire Dataset" (`inspire_dataset`)' + ); + await client.fields.create(inspireDatasetItemType.id, { + id: "Ei2sKTDgSZO6RsFquxiiaw", + label: "Metadata standaard naam", + field_type: "string", + api_key: "metadatastandardname", + hint: 'Dit element bevat de naam van de gebruikte standaard, om de metadata te beschrijven. Zie ook ISO 19115 NL profiel', + appearance: { + addons: [], + editor: "single_line", + parameters: { heading: false, placeholder: null }, + }, + default_value: "ISO19115", + }); + } + + if (findField("Verantwoordelijk organisatie metadata")) { + console.log( + 'Field "Verantwoordelijk organisatie metadata" (`verantwoordelijk_organisatie_metadata`) already exists' + ); + } else { + console.log( + 'Create Modular Content (Multiple blocks) field "Verantwoordelijk organisatie metadata" (`verantwoordelijk_organisatie_metadata`) in model "Inspire Dataset" (`inspire_dataset`)' + ); + + const metadataOrganisationItemType = itemTypes.find( + (itemType: any) => itemType.api_key === "metadata_organisation" + ); + + if (metadataOrganisationItemType === undefined) { + throw new Error("Item type 'metadata_organisation' not found"); + } + + await client.fields.create(inspireDatasetItemType.id, { + id: "GbevT-_8T1O68xw1ijxFXQ", + label: "Verantwoordelijk organisatie metadata", + field_type: "rich_text", + api_key: "verantwoordelijk_organisatie_metadata", + validators: { + rich_text_blocks: { item_types: [metadataOrganisationItemType.id] }, + }, + appearance: { + addons: [], + editor: "rich_text", + parameters: { start_collapsed: false }, + }, + default_value: null, + }); + } + + if (findField("Samenvatting")) { + console.log('Field "Samenvatting" (`abstract`) already exists'); + } else { + console.log( + 'Create Multiple-paragraph text field "Samenvatting" (`abstract`) in model "Inspire Dataset" (`inspire_dataset`)' + ); + newFields["10143368"] = await client.fields.create( + inspireDatasetItemType.id, + { + label: "Samenvatting", + field_type: "text", + api_key: "abstract", + hint: 'Dit element bevat een beschrijving van de inhoud van de dataset, geef in deze samenvatting publieks vriendelijk informatie over de inhoud van de dataset. Zie ook ISO 19115 NL profiel\n', + validators: { required: {} }, + appearance: { + addons: [], + editor: "textarea", + parameters: { placeholder: null }, + type: "textarea", + }, + default_value: "", + } + ); + } + + if (findField("Onderwerp")) { + console.log('Field "Onderwerp" (`topiccategories`) already exists'); + } else { + console.log( + 'Create Modular Content (Multiple blocks) field "Onderwerp" (`topiccategories`) in model "Inspire Dataset" (`inspire_dataset`)' + ); + + const topicCategoryItemType = itemTypes.find( + (itemType: any) => itemType.api_key === "topic_category" + ); + + if (topicCategoryItemType === undefined) { + throw new Error("Item type 'topic_category' not found"); + } + + newFields["10163089"] = await client.fields.create( + inspireDatasetItemType.id, + { + label: "Onderwerp", + field_type: "rich_text", + api_key: "topiccategories", + hint: "Dit is een specifieke aanduiding die in de catalogus (geonetwork) zorgt voor een categorisering van de gegevens. ", + validators: { + rich_text_blocks: { item_types: [topicCategoryItemType.id] }, + size: { eq: 1 }, + }, + appearance: { + addons: [], + editor: "rich_text", + parameters: { start_collapsed: false }, + }, + default_value: null, + } + ); + } + + if (findField("Taal van de bron")) { + console.log('Field "Taal van de bron" (`language`) already exists'); + } else { + console.log( + 'Create Single-line string field "Taal van de bron" (`language`) in model "Inspire Dataset" (`inspire_dataset`)' + ); + await client.fields.create(inspireDatasetItemType.id, { + id: "Bw5WSGe9TGu_3LhSFjJobw", + label: "Taal van de bron", + field_type: "string", + api_key: "language", + hint: 'Let op, standaard wordt hier \'dut\' ingevuld, omdat de metadata in het Nederlands is. Zie ook ISO 19115 NL profiel', + validators: { enum: { values: ["dut", "eng", "ger", "fre", "zxx"] } }, + appearance: { + addons: [], + editor: "single_line", + parameters: { heading: false, placeholder: null }, + }, + default_value: "dut", + }); + } + + // console.log("Update existing fields/fieldsets"); + + // console.log( + // 'Reorder fields/fieldsets for model "Inspire Dataset" (`inspire_dataset`)' + // ); + // await client.itemTypes.rawReorderFieldsAndFieldsets( + // inspireDatasetItemType.id, + // { + // data: [ + // { + // id: "10143360", + // type: "field", + // attributes: { position: 0 }, + // relationships: { + // fieldset: { data: { id: "560134", type: "fieldset" } }, + // }, + // }, + // { + // id: "10143362", + // type: "field", + // attributes: { position: 0 }, + // relationships: { + // fieldset: { data: { id: "560132", type: "fieldset" } }, + // }, + // }, + // { + // id: "10143371", + // type: "field", + // attributes: { position: 0 }, + // relationships: { + // fieldset: { data: { id: "560136", type: "fieldset" } }, + // }, + // }, + // { + // id: "10162515", + // type: "field", + // attributes: { position: 0 }, + // relationships: { + // fieldset: { data: { id: "561206", type: "fieldset" } }, + // }, + // }, + // { + // id: "MciOlCyATDqKAeWCVthfgg", + // type: "field", + // attributes: { position: 0 }, + // relationships: { + // fieldset: { + // data: { id: "TOSwC4esQFKcXNrW20gK1Q", type: "fieldset" }, + // }, + // }, + // }, + // { + // id: "fFAppifMRJeYDqnflH6d8w", + // type: "field", + // attributes: { position: 0 }, + // relationships: { + // fieldset: { data: { id: "560133", type: "fieldset" } }, + // }, + // }, + // { + // id: "Ei2sKTDgSZO6RsFquxiiaw", + // type: "field", + // attributes: { position: 0 }, + // relationships: { + // fieldset: { + // data: { id: "d5CCVL3pSxGMdchqXBBQJQ", type: "fieldset" }, + // }, + // }, + // }, + // { + // id: "EToHPBiYTSOZ80SxmAWcpg", + // type: "field", + // attributes: { position: 0 }, + // relationships: { + // fieldset: { + // data: { id: "INy1cspgRTCwgrfVa2fTDw", type: "fieldset" }, + // }, + // }, + // }, + // { + // id: "GbevT-_8T1O68xw1ijxFXQ", + // type: "field", + // attributes: { position: 0 }, + // relationships: { + // fieldset: { + // data: { id: "c4ZNV0cQTamwB4mBwbSFpg", type: "fieldset" }, + // }, + // }, + // }, + // { + // id: "10143361", + // type: "field", + // attributes: { position: 1 }, + // relationships: { + // fieldset: { data: { id: "560132", type: "fieldset" } }, + // }, + // }, + // { + // id: "10143370", + // type: "field", + // attributes: { position: 1 }, + // relationships: { + // fieldset: { data: { id: "560136", type: "fieldset" } }, + // }, + // }, + // { + // id: "10162665", + // type: "field", + // attributes: { position: 1 }, + // relationships: { + // fieldset: { + // data: { id: "TOSwC4esQFKcXNrW20gK1Q", type: "fieldset" }, + // }, + // }, + // }, + // { + // id: "11526998", + // type: "field", + // attributes: { position: 1 }, + // relationships: { + // fieldset: { data: { id: "561206", type: "fieldset" } }, + // }, + // }, + // { + // id: "NzxaGK5sSoyuErg9Tabo1Q", + // type: "field", + // attributes: { position: 1 }, + // relationships: { + // fieldset: { + // data: { id: "INy1cspgRTCwgrfVa2fTDw", type: "fieldset" }, + // }, + // }, + // }, + // { + // id: "BEF9VIoJRgiKa6SZSZQTDw", + // type: "field", + // attributes: { position: 1 }, + // relationships: { + // fieldset: { + // data: { id: "d5CCVL3pSxGMdchqXBBQJQ", type: "fieldset" }, + // }, + // }, + // }, + // { + // id: "LoXTVry5RTWfgDj2l9OAhw", + // type: "field", + // attributes: { position: 1 }, + // relationships: { + // fieldset: { data: { id: "560134", type: "fieldset" } }, + // }, + // }, + // { id: "560136", type: "fieldset", attributes: { position: 1 } }, + // { + // id: "10143369", + // type: "field", + // attributes: { position: 2 }, + // relationships: { + // fieldset: { data: { id: "560136", type: "fieldset" } }, + // }, + // }, + // { + // id: "ELSrYu9EQO60TyeUB_bDzA", + // type: "field", + // attributes: { position: 2 }, + // relationships: { + // fieldset: { + // data: { id: "INy1cspgRTCwgrfVa2fTDw", type: "fieldset" }, + // }, + // }, + // }, + // { + // id: "dGuoZGTzS2WwImU1XIca7Q", + // type: "field", + // attributes: { position: 2 }, + // relationships: { + // fieldset: { data: { id: "560134", type: "fieldset" } }, + // }, + // }, + // { + // id: "INy1cspgRTCwgrfVa2fTDw", + // type: "fieldset", + // attributes: { position: 2 }, + // }, + // { + // id: "10143368", + // type: "field", + // attributes: { position: 3 }, + // relationships: { + // fieldset: { data: { id: "560136", type: "fieldset" } }, + // }, + // }, + // { + // id: "bH3ePzx1SqeTPh-VoSw3sQ", + // type: "field", + // attributes: { position: 3 }, + // relationships: { + // fieldset: { data: { id: "560134", type: "fieldset" } }, + // }, + // }, + // { id: "560134", type: "fieldset", attributes: { position: 3 } }, + // { + // id: "10162813", + // type: "field", + // attributes: { position: 4 }, + // relationships: { + // fieldset: { data: { id: "560136", type: "fieldset" } }, + // }, + // }, + // { + // id: "Y-8xFhLdQHCaeqzSX8MUdg", + // type: "field", + // attributes: { position: 4 }, + // relationships: { + // fieldset: { data: { id: "560134", type: "fieldset" } }, + // }, + // }, + // { id: "560132", type: "fieldset", attributes: { position: 4 } }, + // { + // id: "10163089", + // type: "field", + // attributes: { position: 5 }, + // relationships: { + // fieldset: { data: { id: "560136", type: "fieldset" } }, + // }, + // }, + // { id: "560133", type: "fieldset", attributes: { position: 5 } }, + // { + // id: "Bw5WSGe9TGu_3LhSFjJobw", + // type: "field", + // attributes: { position: 6 }, + // relationships: { + // fieldset: { data: { id: "560136", type: "fieldset" } }, + // }, + // }, + // { + // id: "TOSwC4esQFKcXNrW20gK1Q", + // type: "fieldset", + // attributes: { position: 6 }, + // }, + // { id: "561206", type: "fieldset", attributes: { position: 7 } }, + // { + // id: "c4ZNV0cQTamwB4mBwbSFpg", + // type: "fieldset", + // attributes: { position: 8 }, + // }, + // { + // id: "d5CCVL3pSxGMdchqXBBQJQ", + // type: "fieldset", + // attributes: { position: 9 }, + // }, + // ], + // } + // ); + + // console.log("Finalize models/block models"); + + // console.log('Update model "Inspire Dataset" (`inspire_dataset`)'); + // await client.itemTypes.update(inspireDatasetItemType.id, { + // title_field: newFields["10143371"], + // }); +} diff --git a/migrations/1729265706_inspireDatasetFieldsOrder.ts b/migrations/1729265706_inspireDatasetFieldsOrder.ts new file mode 100644 index 00000000..a3b08b8b --- /dev/null +++ b/migrations/1729265706_inspireDatasetFieldsOrder.ts @@ -0,0 +1,285 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +import { Client } from "@datocms/cli/lib/cma-client-node"; + +export default async function (client: Client) { + console.log("Creating new fields/fieldsets"); + + const itemTypes = await client.itemTypes.list(); + const inspireDatasetItemType = itemTypes.find( + (itemType: any) => itemType.api_key === "inspire_dataset" + ) || { id: "" }; + + const fields = await client.fields.list(inspireDatasetItemType.id); + const findField = (label: string) => + fields.find((field: any) => field.label === label); + + let doNotReorderFields: boolean = false; + + if (findField("Thesaurusdatum")) { + console.log('Field "Thesaurusdatum" already exists'); + doNotReorderFields = true; + } else { + console.log( + 'Create Single-line string field "thesauruslink" (`thesauruslink`) in model "Inspire Dataset" (`inspire_dataset`)' + ); + await client.fields.create(inspireDatasetItemType.id, { + id: "NS_cGHM9SGGcfP0KyG4vgw", + label: "thesauruslink", + field_type: "string", + api_key: "thesauruslink", + appearance: { + addons: [], + editor: "single_line", + parameters: { heading: false, placeholder: null }, + }, + default_value: "", + }); + } + + if (findField("Thesaurusdatum")) { + console.log('Field "Thesaurusdatum" already exists'); + doNotReorderFields = true; + } else { + console.log( + 'Create Date field "Thesaurusdatum" (`thesaurusdatum`) in model "Inspire Dataset" (`inspire_dataset`)' + ); + await client.fields.create(inspireDatasetItemType.id, { + id: "FxL4Gm4WRNq9EA4d7tkmRA", + label: "Thesaurusdatum", + field_type: "date", + api_key: "thesaurusdatum", + appearance: { addons: [], editor: "date_picker", parameters: {} }, + default_value: null, + }); + } + + if (findField("Thesaurusdatum type")) { + console.log('Field "Thesaurusdatum type" already exists'); + doNotReorderFields = true; + } else { + console.log( + 'Create Single-line string field "Thesaurusdatum type" (`thesaurusdatum_type`) in model "Inspire Dataset" (`inspire_dataset`)' + ); + await client.fields.create(inspireDatasetItemType.id, { + id: "RMgqrZGfQyKy5tMXDj6Srw", + label: "Thesaurusdatum type", + field_type: "string", + api_key: "thesaurusdatum_type", + appearance: { + addons: [], + editor: "single_line", + parameters: { heading: false, placeholder: null }, + }, + default_value: "", + }); + } + + if (!doNotReorderFields) { + console.log("Update existing fields/fieldsets"); + + console.log( + 'Reorder fields/fieldsets for model "Inspire Dataset" (`inspire_dataset`)' + ); + try { + await client.itemTypes.rawReorderFieldsAndFieldsets( + inspireDatasetItemType.id, + { + data: [ + { + id: "NS_cGHM9SGGcfP0KyG4vgw", + type: "field", + attributes: { position: 3 }, + relationships: { + fieldset: { + data: { id: "KbDtNCwNQAqEGh-9o5G-RA", type: "fieldset" }, + }, + }, + }, + { + id: "FxL4Gm4WRNq9EA4d7tkmRA", + type: "field", + attributes: { position: 4 }, + relationships: { + fieldset: { + data: { id: "KbDtNCwNQAqEGh-9o5G-RA", type: "fieldset" }, + }, + }, + }, + { + id: "RMgqrZGfQyKy5tMXDj6Srw", + type: "field", + attributes: { position: 5 }, + relationships: { + fieldset: { + data: { id: "KbDtNCwNQAqEGh-9o5G-RA", type: "fieldset" }, + }, + }, + }, + { + id: "JdCdVG1LTHa5UmI8NHNGBw", + type: "field", + attributes: { position: 1 }, + relationships: { + fieldset: { + data: { id: "TOSwC4esQFKcXNrW20gK1Q", type: "fieldset" }, + }, + }, + }, + { + id: "MciOlCyATDqKAeWCVthfgg", + type: "field", + attributes: { position: 0 }, + relationships: { + fieldset: { + data: { id: "TOSwC4esQFKcXNrW20gK1Q", type: "fieldset" }, + }, + }, + }, + { + id: "fFAppifMRJeYDqnflH6d8w", + type: "field", + attributes: { position: 3 }, + relationships: { + fieldset: { + data: { id: "IWFo-RIcRFGq75fjuAh35A", type: "fieldset" }, + }, + }, + }, + { + id: "EToHPBiYTSOZ80SxmAWcpg", + type: "field", + attributes: { position: 0 }, + relationships: { + fieldset: { + data: { id: "INy1cspgRTCwgrfVa2fTDw", type: "fieldset" }, + }, + }, + }, + { + id: "bYdFNcOASiuFG5wVKfLYGw", + type: "field", + attributes: { position: 2 }, + relationships: { + fieldset: { + data: { id: "VJVAflbjSxaaCl2OF4vaCA", type: "fieldset" }, + }, + }, + }, + { + id: "BEF9VIoJRgiKa6SZSZQTDw", + type: "field", + attributes: { position: 1 }, + relationships: { + fieldset: { + data: { id: "d5CCVL3pSxGMdchqXBBQJQ", type: "fieldset" }, + }, + }, + }, + { + id: "LoXTVry5RTWfgDj2l9OAhw", + type: "field", + attributes: { position: 2 }, + relationships: { + fieldset: { + data: { id: "KbDtNCwNQAqEGh-9o5G-RA", type: "fieldset" }, + }, + }, + }, + { + id: "NzxaGK5sSoyuErg9Tabo1Q", + type: "field", + attributes: { position: 2 }, + relationships: { + fieldset: { + data: { id: "INy1cspgRTCwgrfVa2fTDw", type: "fieldset" }, + }, + }, + }, + { + id: "ELSrYu9EQO60TyeUB_bDzA", + type: "field", + attributes: { position: 1 }, + relationships: { + fieldset: { + data: { id: "INy1cspgRTCwgrfVa2fTDw", type: "fieldset" }, + }, + }, + }, + { + id: "Ei2sKTDgSZO6RsFquxiiaw", + type: "field", + attributes: { position: 0 }, + relationships: { + fieldset: { + data: { id: "d5CCVL3pSxGMdchqXBBQJQ", type: "fieldset" }, + }, + }, + }, + { + id: "GbevT-_8T1O68xw1ijxFXQ", + type: "field", + attributes: { position: 0 }, + relationships: { + fieldset: { + data: { id: "c4ZNV0cQTamwB4mBwbSFpg", type: "fieldset" }, + }, + }, + }, + { + id: "Bw5WSGe9TGu_3LhSFjJobw", + type: "field", + attributes: { position: 7 }, + relationships: { + fieldset: { + data: { id: "J7A-JpKBROyVXigOyRdNyQ", type: "fieldset" }, + }, + }, + }, + { + id: "KbDtNCwNQAqEGh-9o5G-RA", + type: "fieldset", + attributes: { position: 5 }, + }, + { + id: "LkE2P0h0RlG3N3kKty2fEQ", + type: "fieldset", + attributes: { position: 6 }, + }, + { + id: "IWFo-RIcRFGq75fjuAh35A", + type: "fieldset", + attributes: { position: 2 }, + }, + { + id: "VJVAflbjSxaaCl2OF4vaCA", + type: "fieldset", + attributes: { position: 3 }, + }, + { + id: "INy1cspgRTCwgrfVa2fTDw", + type: "fieldset", + attributes: { position: 4 }, + }, + { + id: "TOSwC4esQFKcXNrW20gK1Q", + type: "fieldset", + attributes: { position: 7 }, + }, + { + id: "c4ZNV0cQTamwB4mBwbSFpg", + type: "fieldset", + attributes: { position: 8 }, + }, + { + id: "d5CCVL3pSxGMdchqXBBQJQ", + type: "fieldset", + attributes: { position: 9 }, + }, + ], + } + ); + } catch (error) { + console.error(error); + } + } +} diff --git a/migrations/1732891349_contacts.ts b/migrations/1732891349_contacts.ts new file mode 100644 index 00000000..9d45889c --- /dev/null +++ b/migrations/1732891349_contacts.ts @@ -0,0 +1,63 @@ +import { Client } from "@datocms/cli/lib/cma-client-node"; + +export default async function (client: Client) { + const itemTypes = await client.itemTypes.list(); + const menuItemType = itemTypes.find( + (itemType: { api_key: string }) => itemType.api_key === "menu" + ) || { id: "" }; + const contactItemType = itemTypes.find( + (itemType: { api_key: string }) => itemType.api_key === "contact" + ) || { id: "" }; + + const fields = await client.fields.list(menuItemType.id); + const findField = (label: string) => + fields.find((field: any) => field.label === label); + + const errorNotificationContactsField = findField( + "Error notification contacts" + ); + if (!errorNotificationContactsField) { + console.log( + 'Create Multiple links field "Error notification contacts" (`error_notification_contacts`) in model "Menu" (`menu`)' + ); + await client.fields.create(menuItemType.id, { + id: "GlLvpmJFTBup26dDM2OMuQ", + label: "Error notification contacts", + field_type: "links", + api_key: "error_notification_contacts", + validators: { + items_item_type: { + on_publish_with_unpublished_references_strategy: "fail", + on_reference_unpublish_strategy: "delete_references", + on_reference_delete_strategy: "delete_references", + item_types: [contactItemType.id], + }, + }, + appearance: { addons: [], editor: "links_select", parameters: {} }, + default_value: null, + }); + } + + const feedbackContactsField = findField("Feedback contacts"); + if (!feedbackContactsField) { + console.log( + 'Create Multiple links field "Feedback contacts" (`feedback_contacts`) in model "Menu" (`menu`)' + ); + await client.fields.create(menuItemType.id, { + id: "CPxFkf5cRPKm0ORLakLX3Q", + label: "Feedback contacts", + field_type: "links", + api_key: "feedback_contacts", + validators: { + items_item_type: { + on_publish_with_unpublished_references_strategy: "fail", + on_reference_unpublish_strategy: "delete_references", + on_reference_delete_strategy: "delete_references", + item_types: [contactItemType.id], + }, + }, + appearance: { addons: [], editor: "links_select", parameters: {} }, + default_value: null, + }); + } +} diff --git a/migrations/1733825239_colophonPresentation.ts b/migrations/1733825239_colophonPresentation.ts new file mode 100644 index 00000000..89b2d1a8 --- /dev/null +++ b/migrations/1733825239_colophonPresentation.ts @@ -0,0 +1,33 @@ +import { Client } from "@datocms/cli/lib/cma-client-node"; + +export default async function (client: Client) { + console.log("Update existing fields/fieldsets"); + + const currentField = await client.fields.find("H7cTIWERTG-z24IE8ILCUw"); + + console.log( + 'Update Multiple-paragraph text field "Acknowledgments" (`acknowledgments`) in model "Menu" (`menu`)' + ); + await client.fields.update("H7cTIWERTG-z24IE8ILCUw", { + appearance: { + addons: currentField.appearance.addons, + editor: "markdown", + parameters: { + toolbar: [ + "heading", + "bold", + "italic", + "strikethrough", + "code", + "unordered_list", + "ordered_list", + "quote", + "link", + "image", + "fullscreen", + ], + }, + type: "markdown", + }, + }); +} diff --git a/package.json b/package.json index f1b1cf46..86a9a70a 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "postinstall": "patch-package", "dato": "node ./config/dato/dump-data.mjs", "prebuild": "npm run dato", - "build": "vue-cli-service build", + "build": "vue-cli-service build && cp netlify.toml dist/netlify.toml", "predev": "npm run dato", "dev": "run-p serve start-server", "fix": "run-s fix:*", diff --git a/scripts/dato/apply-main.ts b/scripts/dato/apply-main.ts index ff450393..3bd5749e 100644 --- a/scripts/dato/apply-main.ts +++ b/scripts/dato/apply-main.ts @@ -7,7 +7,9 @@ async function main() { for (const instance of instances) { console.log(`Managing environments for ${instance.name}`); - const client = new DatoClient(instance.key); + const client = new DatoClient(instance.datoApiKey); + + await client.runCommand(["maintenance:on"]); const existingEnvironments = await client.listEnvironments(); @@ -28,6 +30,8 @@ async function main() { await client.destroyEnvironment("main"); await client.runCommand(["environments:rename", "staging", "main"]); + + await client.runCommand(["maintenance:off"]); } } diff --git a/scripts/dato/apply-staging.ts b/scripts/dato/apply-staging.ts index e2e31709..4ddebe3b 100644 --- a/scripts/dato/apply-staging.ts +++ b/scripts/dato/apply-staging.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ -import { DatoClient } from "./utils.js"; +import { DatoClient } from "./utils"; async function main() { const { instances } = await import("../../config/dato/instances.js"); @@ -7,7 +7,7 @@ async function main() { for (const instance of instances) { console.log(`Setting up staging environment for ${instance.name}`); - const client = new DatoClient(instance.key); + const client = new DatoClient(instance.datoApiKey); const existingEnvironments = await client.listEnvironments(); diff --git a/scripts/dato/create.ts b/scripts/dato/create.ts index 94e57308..d4a41607 100644 --- a/scripts/dato/create.ts +++ b/scripts/dato/create.ts @@ -12,7 +12,7 @@ if (!currentInstance) { throw new Error("No current instance found"); } -const apiKey = currentInstance.key; +const apiKey = currentInstance.datoApiKey; const client = new DatoClient(apiKey); const promptGet = promisify(prompt.get); diff --git a/src/components/AcknowledgmentsDialog/AcknowledgmentsDialog.vue b/src/components/AcknowledgmentsDialog/AcknowledgmentsDialog.vue index 2d0e3e0c..88f1c30c 100644 --- a/src/components/AcknowledgmentsDialog/AcknowledgmentsDialog.vue +++ b/src/components/AcknowledgmentsDialog/AcknowledgmentsDialog.vue @@ -17,7 +17,7 @@ - + @@ -57,4 +57,10 @@ +