mirror of
https://github.com/Kong/insomnia.git
synced 2026-06-03 21:55:53 -04:00
Move insomnia-data models, services, database code, and common utilities into a dedicated workspace package. Update consumers to import from the new package entrypoints and declare workspace dependencies for the extracted package.
24 lines
504 B
TypeScript
24 lines
504 B
TypeScript
import type { CookieJar } from 'insomnia-data';
|
|
import { v4 as uuidv4 } from 'uuid';
|
|
|
|
/** Ensure every cookie has an ID property */
|
|
function migrateCookieId(cookieJar: CookieJar) {
|
|
for (const cookie of cookieJar.cookies) {
|
|
if (!cookie.id) {
|
|
cookie.id = uuidv4();
|
|
}
|
|
}
|
|
|
|
return cookieJar;
|
|
}
|
|
|
|
export function migrate(doc: CookieJar) {
|
|
try {
|
|
doc = migrateCookieId(doc);
|
|
return doc;
|
|
} catch (e) {
|
|
console.log('[db] Error during cookie jar migration', e);
|
|
throw e;
|
|
}
|
|
}
|