From 6de793e94e01b8ed1bcd896f24e93357b85dff59 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sun, 25 Apr 2021 12:54:06 -0700 Subject: [PATCH] =?UTF-8?q?fix:=20uuid=20import=20broken=20by=20dep=20bump?= =?UTF-8?q?=20=F0=9F=A4=A6=E2=80=8D=E2=99=82=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/stores/UiStore.js | 4 ++-- server/api/attachments.js | 4 ++-- server/api/authenticationProviders.test.js | 4 ++-- server/commands/attachmentCreator.js | 4 ++-- server/commands/collectionImporter.js | 4 ++-- server/models/Collection.test.js | 16 ++++++++-------- server/models/Team.js | 4 ++-- server/models/User.js | 4 ++-- server/test/factories.js | 6 +++--- server/test/support.js | 8 ++++---- 10 files changed, 29 insertions(+), 29 deletions(-) diff --git a/app/stores/UiStore.js b/app/stores/UiStore.js index e1d2ef59..376b852b 100644 --- a/app/stores/UiStore.js +++ b/app/stores/UiStore.js @@ -1,7 +1,7 @@ // @flow import { orderBy } from "lodash"; import { observable, action, autorun, computed } from "mobx"; -import { v4 } from "uuid"; +import { v4 as uuidv4 } from "uuid"; import { light as defaultTheme } from "shared/styles/theme"; import Collection from "models/Collection"; import Document from "models/Document"; @@ -204,7 +204,7 @@ class UiStore { return; } - const id = v4(); + const id = uuidv4(); const createdAt = new Date().toISOString(); this.toasts.set(id, { id, diff --git a/server/api/attachments.js b/server/api/attachments.js index 4647506e..677765bb 100644 --- a/server/api/attachments.js +++ b/server/api/attachments.js @@ -1,7 +1,7 @@ // @flow import format from "date-fns/format"; import Router from "koa-router"; -import uuid from "uuid"; +import { v4 as uuidv4 } from "uuid"; import { NotFoundError } from "../errors"; import auth from "../middlewares/authentication"; import { Attachment, Document, Event } from "../models"; @@ -28,7 +28,7 @@ router.post("attachments.create", auth(), async (ctx) => { const { user } = ctx.state; authorize(user, "createAttachment", user.team); - const s3Key = uuid.v4(); + const s3Key = uuidv4(); const acl = ctx.body.public === undefined ? AWS_S3_ACL diff --git a/server/api/authenticationProviders.test.js b/server/api/authenticationProviders.test.js index e60b5da7..66af4760 100644 --- a/server/api/authenticationProviders.test.js +++ b/server/api/authenticationProviders.test.js @@ -1,6 +1,6 @@ // @flow import TestServer from "fetch-test-server"; -import uuid from "uuid"; +import { v4 as uuidv4 } from "uuid"; import app from "../app"; import { buildUser, buildAdmin, buildTeam } from "../test/factories"; import { flushdb } from "../test/support"; @@ -81,7 +81,7 @@ describe("#authenticationProviders.update", () => { const user = await buildAdmin({ teamId: team.id }); await team.createAuthenticationProvider({ name: "google", - providerId: uuid.v4(), + providerId: uuidv4(), }); const authenticationProviders = await team.getAuthenticationProviders(); diff --git a/server/commands/attachmentCreator.js b/server/commands/attachmentCreator.js index 906054cb..bdfa0418 100644 --- a/server/commands/attachmentCreator.js +++ b/server/commands/attachmentCreator.js @@ -1,5 +1,5 @@ // @flow -import uuid from "uuid"; +import { v4 as uuidv4 } from "uuid"; import { Attachment, Event, User } from "../models"; import { uploadToS3FromBuffer } from "../utils/s3"; @@ -18,7 +18,7 @@ export default async function attachmentCreator({ source?: "import", ip: string, }) { - const key = `uploads/${user.id}/${uuid.v4()}/${name}`; + const key = `uploads/${user.id}/${uuidv4()}/${name}`; const acl = process.env.AWS_S3_ACL || "private"; const url = await uploadToS3FromBuffer(buffer, type, key, acl); diff --git a/server/commands/collectionImporter.js b/server/commands/collectionImporter.js index 8b7f05ff..40722aa3 100644 --- a/server/commands/collectionImporter.js +++ b/server/commands/collectionImporter.js @@ -6,7 +6,7 @@ import debug from "debug"; import File from "formidable/lib/file"; import invariant from "invariant"; import { values, keys } from "lodash"; -import uuid from "uuid"; +import { v4 as uuidv4 } from "uuid"; import { parseOutlineExport } from "../../shared/utils/zip"; import { FileImportError } from "../errors"; import { Attachment, Event, Document, Collection, User } from "../models"; @@ -96,7 +96,7 @@ export default async function collectionImporter({ const content = await item.item.async("string"); const name = path.basename(item.name); const tmpDir = os.tmpdir(); - const tmpFilePath = `${tmpDir}/upload-${uuid.v4()}`; + const tmpFilePath = `${tmpDir}/upload-${uuidv4()}`; await fs.promises.writeFile(tmpFilePath, content); const file = new File({ diff --git a/server/models/Collection.test.js b/server/models/Collection.test.js index 70ec0d3f..93b7f3a2 100644 --- a/server/models/Collection.test.js +++ b/server/models/Collection.test.js @@ -1,5 +1,5 @@ /* eslint-disable flowtype/require-valid-file-annotation */ -import uuid from "uuid"; +import { v4 as uuidv4 } from "uuid"; import { Collection, Document } from "../models"; import { buildUser, @@ -22,7 +22,7 @@ describe("#url", () => { describe("#addDocumentToStructure", () => { test("should add as last element without index", async () => { const { collection } = await seed(); - const id = uuid.v4(); + const id = uuidv4(); const newDocument = new Document({ id, title: "New end node", @@ -36,7 +36,7 @@ describe("#addDocumentToStructure", () => { test("should add with an index", async () => { const { collection } = await seed(); - const id = uuid.v4(); + const id = uuidv4(); const newDocument = new Document({ id, title: "New end node", @@ -50,7 +50,7 @@ describe("#addDocumentToStructure", () => { test("should add as a child if with parent", async () => { const { collection, document } = await seed(); - const id = uuid.v4(); + const id = uuidv4(); const newDocument = new Document({ id, title: "New end node", @@ -67,11 +67,11 @@ describe("#addDocumentToStructure", () => { test("should add as a child if with parent with index", async () => { const { collection, document } = await seed(); const newDocument = new Document({ - id: uuid.v4(), + id: uuidv4(), title: "node", parentDocumentId: document.id, }); - const id = uuid.v4(); + const id = uuidv4(); const secondDocument = new Document({ id, title: "New start node", @@ -89,9 +89,9 @@ describe("#addDocumentToStructure", () => { describe("options: documentJson", () => { test("should append supplied json over document's own", async () => { const { collection } = await seed(); - const id = uuid.v4(); + const id = uuidv4(); const newDocument = new Document({ - id: uuid.v4(), + id: uuidv4(), title: "New end node", parentDocumentId: null, }); diff --git a/server/models/Team.js b/server/models/Team.js index 7981e693..ded4bd89 100644 --- a/server/models/Team.js +++ b/server/models/Team.js @@ -3,7 +3,7 @@ import fs from "fs"; import path from "path"; import { URL } from "url"; import util from "util"; -import uuid from "uuid"; +import { v4 as uuidv4 } from "uuid"; import { stripSubdomain, RESERVED_SUBDOMAINS, @@ -120,7 +120,7 @@ const uploadAvatar = async (model) => { try { const newUrl = await uploadToS3FromUrl( avatarUrl, - `avatars/${model.id}/${uuid.v4()}`, + `avatars/${model.id}/${uuidv4()}`, "public-read" ); if (newUrl) model.avatarUrl = newUrl; diff --git a/server/models/User.js b/server/models/User.js index 374378f6..5817bb5c 100644 --- a/server/models/User.js +++ b/server/models/User.js @@ -3,7 +3,7 @@ import crypto from "crypto"; import addMinutes from "date-fns/add_minutes"; import subMinutes from "date-fns/sub_minutes"; import JWT from "jsonwebtoken"; -import uuid from "uuid"; +import { v4 as uuidv4 } from "uuid"; import { languages } from "../../shared/i18n"; import { ValidationError } from "../errors"; import { sendEmail } from "../mailer"; @@ -187,7 +187,7 @@ const uploadAvatar = async (model) => { try { const newUrl = await uploadToS3FromUrl( avatarUrl, - `avatars/${model.id}/${uuid.v4()}`, + `avatars/${model.id}/${uuidv4()}`, "public-read" ); if (newUrl) model.avatarUrl = newUrl; diff --git a/server/test/factories.js b/server/test/factories.js index d6912e48..6d00be31 100644 --- a/server/test/factories.js +++ b/server/test/factories.js @@ -1,5 +1,5 @@ // @flow -import uuid from "uuid"; +import { v4 as uuidv4 } from "uuid"; import { Share, Team, @@ -42,7 +42,7 @@ export function buildTeam(overrides: Object = {}) { authenticationProviders: [ { name: "slack", - providerId: uuid.v4(), + providerId: uuidv4(), }, ], ...overrides, @@ -84,7 +84,7 @@ export async function buildUser(overrides: Object = {}) { authentications: [ { authenticationProviderId: authenticationProvider.id, - providerId: uuid.v4(), + providerId: uuidv4(), }, ], ...overrides, diff --git a/server/test/support.js b/server/test/support.js index 132b88ec..c63f3387 100644 --- a/server/test/support.js +++ b/server/test/support.js @@ -1,5 +1,5 @@ // @flow -import uuid from "uuid"; +import { v4 as uuidv4 } from "uuid"; import { User, Document, Collection, Team } from "../models"; import { sequelize } from "../sequelize"; @@ -23,7 +23,7 @@ export const seed = async () => { authenticationProviders: [ { name: "slack", - providerId: uuid.v4(), + providerId: uuidv4(), }, ], }, @@ -45,7 +45,7 @@ export const seed = async () => { authentications: [ { authenticationProviderId: authenticationProvider.id, - providerId: uuid.v4(), + providerId: uuidv4(), }, ], }, @@ -64,7 +64,7 @@ export const seed = async () => { authentications: [ { authenticationProviderId: authenticationProvider.id, - providerId: uuid.v4(), + providerId: uuidv4(), }, ], },