sanity-plugin-internationalized-array
5.2.15.2.2
dist/migrations/index.js.map~
dist/migrations/index.js.mapModified+1−1
Index: package/dist/migrations/index.js.map
===================================================================
--- package/dist/migrations/index.js.map
+++ package/dist/migrations/index.js.map
@@ -1,1 +1,1 @@
-{"version":3,"file":"index.js","names":["defineMigration","set","LANGUAGE_FIELD_NAME","INTERNATIONALIZED_PREFIX","VALUE_SUFFIX","migrateToLanguageField","documentTypes","title","migrate","object","node","type","language","startsWith","endsWith","undefined","oldKey","length","_key"],"sources":["../../migrations/migrateToLanguageField.ts"],"sourcesContent":["import {defineMigration, set} from 'sanity/migrate'\n\n/**\n * The property which will be used to store the language identifier from v5.\n */\nconst LANGUAGE_FIELD_NAME = 'language'\n/**\n * The prefix of the internationalized array type name.\n * Internationalized arrays contain objects with `_type` starting with this prefix\n * and ending with `Value` (e.g. `internationalizedArrayStringValue`).\n */\nconst INTERNATIONALIZED_PREFIX = 'internationalizedArray'\n/**\n * The suffix of the internationalized array value type name.\n */\nconst VALUE_SUFFIX = 'Value'\n\n/**\n * Creates a migration that automatically finds all internationalized array\n * item objects and moves language identifiers from `_key` to the dedicated\n * `language` field, generating new random `_key` values.\n *\n * Detection is automatic: the `object` handler is called for every object in\n * every matching document. If the object has a `_type` matching\n * `internationalizedArray*Value` and is missing the `language` field, it is\n * migrated.\n */\nexport function migrateToLanguageField(documentTypes: string[]) {\n return defineMigration({\n title: 'Migrate internationalized array from _key to language',\n documentTypes,\n migrate: {\n object(node) {\n const type = node['_type']\n const language = node[LANGUAGE_FIELD_NAME]\n\n if (\n typeof type !== 'string' ||\n !type.startsWith(INTERNATIONALIZED_PREFIX) ||\n !type.endsWith(VALUE_SUFFIX)\n ) {\n return undefined\n }\n\n // Already migrated: has a language field.\n if (language && typeof language === 'string') {\n return undefined\n }\n\n // Needs migration: _key holds the language id.\n const oldKey = node['_key']\n if (typeof oldKey !== 'string' || oldKey.length === 0) {\n return undefined\n }\n\n return set({\n ...node,\n _key: undefined,\n [LANGUAGE_FIELD_NAME]: oldKey,\n })\n },\n },\n })\n}\n"],"mappings":";;;;AAKA,MAAME,sBAAsB;;;;;;;;;;;AAsB5B,SAAgBG,uBAAuBC,eAAyB;CAC9D,OAAON,gBAAgB;EACrBO,OAAO;EACPD;EACAE,SAAS,EACPC,OAAOC,MAAM;GACX,IAAMC,OAAOD,KAAK,OACZE,WAAWF,KAAKR;GAWtB,IARE,OAAOS,QAAS,YAChB,CAACA,KAAKE,WAAWV,wBAAwB,KACzC,CAACQ,KAAKG,SAASV,OAAY,KAMzBQ,YAAY,OAAOA,YAAa,UAClC;GAIF,IAAMI,SAASN,KAAK;GAChB,WAAOM,UAAW,YAAYA,OAAOC,WAAW,GAIpD,OAAOhB,IAAI;IACT,GAAGS;IACHQ,MAAMH,KAAAA;KACLb,sBAAsBc;GACzB,CAAC;EACH,EACF;CACF,CAAC;AACH"}
\ No newline at end of file
+{"version":3,"file":"index.js","names":[],"sources":["../../migrations/migrateToLanguageField.ts"],"sourcesContent":["import {defineMigration, set} from 'sanity/migrate'\n\n/**\n * The property which will be used to store the language identifier from v5.\n */\nconst LANGUAGE_FIELD_NAME = 'language'\n/**\n * The prefix of the internationalized array type name.\n * Internationalized arrays contain objects with `_type` starting with this prefix\n * and ending with `Value` (e.g. `internationalizedArrayStringValue`).\n */\nconst INTERNATIONALIZED_PREFIX = 'internationalizedArray'\n/**\n * The suffix of the internationalized array value type name.\n */\nconst VALUE_SUFFIX = 'Value'\n\n/**\n * Creates a migration that automatically finds all internationalized array\n * item objects and moves language identifiers from `_key` to the dedicated\n * `language` field, generating new random `_key` values.\n *\n * Detection is automatic: the `object` handler is called for every object in\n * every matching document. If the object has a `_type` matching\n * `internationalizedArray*Value` and is missing the `language` field, it is\n * migrated.\n */\nexport function migrateToLanguageField(documentTypes: string[]) {\n return defineMigration({\n title: 'Migrate internationalized array from _key to language',\n documentTypes,\n migrate: {\n object(node) {\n const type = node['_type']\n const language = node[LANGUAGE_FIELD_NAME]\n\n if (\n typeof type !== 'string' ||\n !type.startsWith(INTERNATIONALIZED_PREFIX) ||\n !type.endsWith(VALUE_SUFFIX)\n ) {\n return undefined\n }\n\n // Already migrated: has a language field.\n if (language && typeof language === 'string') {\n return undefined\n }\n\n // Needs migration: _key holds the language id.\n const oldKey = node['_key']\n if (typeof oldKey !== 'string' || oldKey.length === 0) {\n return undefined\n }\n\n return set({\n ...node,\n _key: undefined,\n [LANGUAGE_FIELD_NAME]: oldKey,\n })\n },\n },\n })\n}\n"],"mappings":";;;;AAKA,MAAM,sBAAsB;;;;;;;;;;;AAsB5B,SAAgB,uBAAuB,eAAyB;CAC9D,OAAO,gBAAgB;EACrB,OAAO;EACP;EACA,SAAS,EACP,OAAO,MAAM;GACX,IAAM,OAAO,KAAK,OACZ,WAAW,KAAK;GAWtB,IARE,OAAO,QAAS,YAChB,CAAC,KAAK,WAAW,wBAAwB,KACzC,CAAC,KAAK,SAAS,OAAY,KAMzB,YAAY,OAAO,YAAa,UAClC;GAIF,IAAM,SAAS,KAAK;GAChB,WAAO,UAAW,YAAY,OAAO,WAAW,GAIpD,OAAO,IAAI;IACT,GAAG;IACH,MAAM,KAAA;KACL,sBAAsB;GACzB,CAAC;EACH,EACF;CACF,CAAC;AACH"}
\ No newline at end of file