feat(storage-uploadthing)!: upgrade to v7 (#8346)

Upgrade uploadthing to v7

The `options` that can be passed to the plugin now mirror the
`UTApiOptions` of v7.

The most notable change is to pass `token` with
`process.env.UPLOADTHING_TOKEN` instead of `apiKey` with
`process.env.UPLOADTHING_SECRET`.

```diff
options: {
- apiKey: process.env.UPLOADTHING_SECRET,
+ token: process.env.UPLOADTHING_TOKEN,
  acl: 'public-read',
},
This commit is contained in:
Elliot DeNolf
2024-11-13 16:27:02 -05:00
committed by GitHub
parent afd69c4d54
commit 4690cd819a
6 changed files with 312 additions and 120 deletions

View File

@@ -23,7 +23,7 @@ export default buildConfig({
[mediaSlug]: true,
},
options: {
apiKey: process.env.UPLOADTHING_SECRET,
token: process.env.UPLOADTHING_TOKEN,
acl: 'public-read',
},
}),

View File

@@ -42,7 +42,7 @@
},
"dependencies": {
"@payloadcms/plugin-cloud-storage": "workspace:*",
"uploadthing": "^6.10.1"
"uploadthing": "7.3.0"
},
"devDependencies": {
"payload": "workspace:*"

80
pnpm-lock.yaml generated
View File

@@ -1420,8 +1420,8 @@ importers:
specifier: workspace:*
version: link:../plugin-cloud-storage
uploadthing:
specifier: ^6.10.1
version: 6.13.3(next@15.0.0(@opentelemetry/api@1.9.0)(@playwright/test@1.48.1)(babel-plugin-macros@3.1.0)(babel-plugin-react-compiler@0.0.0-experimental-24ec0eb-20240918)(react-dom@19.0.0-rc-65a56d0e-20241020(react@19.0.0-rc-65a56d0e-20241020))(react@19.0.0-rc-65a56d0e-20241020)(sass@1.77.4))
specifier: 7.3.0
version: 7.3.0(next@15.0.0(@opentelemetry/api@1.9.0)(@playwright/test@1.48.1)(babel-plugin-macros@3.1.0)(react-dom@19.0.0-rc-65a56d0e-20241020(react@19.0.0-rc-65a56d0e-20241020))(react@19.0.0-rc-65a56d0e-20241020)(sass@1.77.4))
devDependencies:
payload:
specifier: workspace:*
@@ -1780,9 +1780,6 @@ importers:
typescript:
specifier: 5.6.3
version: 5.6.3
uploadthing:
specifier: ^6.10.1
version: 6.13.3(next@15.0.0(@opentelemetry/api@1.9.0)(@playwright/test@1.48.1)(babel-plugin-macros@3.1.0)(babel-plugin-react-compiler@0.0.0-experimental-24ec0eb-20240918)(react-dom@19.0.0-rc-65a56d0e-20241020(react@19.0.0-rc-65a56d0e-20241020))(react@19.0.0-rc-65a56d0e-20241020)(sass@1.77.4))
uuid:
specifier: 10.0.0
version: 10.0.0
@@ -2719,10 +2716,10 @@ packages:
'@drizzle-team/brocli@0.10.2':
resolution: {integrity: sha512-z33Il7l5dKjUgGULTqBsQBQwckHh5AbIuxhdsIxDDiZAzBOrZO6q9ogcWC65kU382AfynTfgNumVcNIjuIua6w==}
'@effect/schema@0.68.18':
resolution: {integrity: sha512-+knLs36muKsyqIvQTB0itGp5Lwy+5jgEC0G5P8wSsrB6EWGFirS87QjbaFYGbg32l/P51RM+9cPMiAEyICwN6g==}
'@effect/platform@0.69.8':
resolution: {integrity: sha512-zhBhg0c1MHMMo+grOc/6wC2/3UETLroruwrYNZ89uDtXl6EOcP5alFP+vW3NToKDA2o0hRh22KNqq4aixA7xXg==}
peerDependencies:
effect: ^3.4.8
effect: ^3.10.3
'@emnapi/core@1.3.1':
resolution: {integrity: sha512-pVGjBIt1Y6gg3EJN8jTcfpP/+uuRksIo055oE/OBkDNcjZqVbfkWCksG1Jp4yZnj3iKWyWX8fdG/j6UDYPbFog==}
@@ -5017,11 +5014,11 @@ packages:
resolution: {integrity: sha512-vG0XZo8AdTH9OE6VFRwAZldNc7qtJ/6NLGWak+BtENuEUXGZgFpihILPiBvKXvJ2nFu27XNGC6rKiwuaoMbYzQ==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
'@uploadthing/mime-types@0.2.10':
resolution: {integrity: sha512-kz3F0oEgAyts25NAGXlUBCWh3mXonbSOQJFGFMawHuIgbUbnzXbe4w5WI+0XdneCbjNmikfWrdWrs8m/7HATfQ==}
'@uploadthing/mime-types@0.3.2':
resolution: {integrity: sha512-WP/K75S/649lM0GUcd9jq4RjeTIc/0bO2UmLx4+usTSNy/x0K8gV0JdLWeUUbmTQtJoHd4ZTSvAdG7ZQgcmXvA==}
'@uploadthing/shared@6.7.9':
resolution: {integrity: sha512-EsHkD31HLBHYB59ZbUVQg1pADtMNf+qjlKwniq+gxXsOOe5heD/zunJStjYWLhwB+C8+SaCPXvM7LiDmv5s/Vw==}
'@uploadthing/shared@7.1.1':
resolution: {integrity: sha512-Nem3jZ6G9AJEBzzDVvwSKV/wLdpADz8LDg+woo9diJTHj1FOjWNzCwb8wMxpEFLM88TWv5Tq8Z1mQepNmC5WIQ==}
'@vercel/blob@0.22.3':
resolution: {integrity: sha512-l0t2KhbOO/I8ZNOl9zypYf1NE0837aO4/CPQNGR/RAxtj8FpdYKjhyUADUXj2gERLQmnhun+teaVs/G7vZJ/TQ==}
@@ -6067,8 +6064,8 @@ packages:
engines: {node: '>=14'}
hasBin: true
effect@3.4.8:
resolution: {integrity: sha512-qOQNrSSN3ITuAtARtN2Ldq6E5f42splY9VV18LqpKOXMwQCCEWkXdns4by3D2CJnDXQD2KCE0iGcRR2KowiQIA==}
effect@3.10.3:
resolution: {integrity: sha512-+Z5bUhzTeqYlfoPsfXMZG1pYadqLBKARD3xwMIoEAESsOhKFOrUsHHNCy2ZZW3/6oa4wokgT01k1zavA4BAQ4w==}
ejs@3.1.10:
resolution: {integrity: sha512-UeJmFfOrAQS8OJWPZ4qtgHyWExa088/MtK5UEyoJGFH67cDEXkZSviOiKRCZ4Xij0zxI3JECgYs3oKx+AizQBA==}
@@ -6562,6 +6559,9 @@ packages:
resolution: {integrity: sha512-wXZV5emFEjrridIgED11OoUKLxiYjAcqot/NJdAkOhlJ+vGzwhOAfcG5OX1jP+S0PcjEn8bdMJv+g2jwQ3Onig==}
engines: {node: '>=8'}
find-my-way-ts@0.1.5:
resolution: {integrity: sha512-4GOTMrpGQVzsCH2ruUn2vmwzV/02zF4q+ybhCIrw/Rkt3L8KWcycdC6aJMctJzwN4fXD4SD5F/4B9Sksh5rE0A==}
find-node-modules@2.1.3:
resolution: {integrity: sha512-UC2I2+nx1ZuOBclWVNdcnbDR5dlrOdVb7xNjmT/lHE+LsgztWks3dG7boJ37yTS/venXw84B/mAW9uHVoC5QRg==}
@@ -7836,6 +7836,9 @@ packages:
ms@2.1.3:
resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==}
multipasta@0.2.5:
resolution: {integrity: sha512-c8eMDb1WwZcE02WVjHoOmUVk7fnKU/RmUcosHACglrWAuPQsEJv+E8430sXj6jNc1jHw0zrS16aCjQh4BcEb4A==}
nanoid@3.3.7:
resolution: {integrity: sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==}
engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
@@ -9041,6 +9044,9 @@ packages:
sprintf-js@1.1.3:
resolution: {integrity: sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA==}
sqids@0.3.0:
resolution: {integrity: sha512-lOQK1ucVg+W6n3FhRwwSeUijxe93b51Bfz5PMRMihVf1iVkl82ePQG7V5vwrhzB11v0NtsR25PSZRGiSomJaJw==}
stable-hash@0.0.4:
resolution: {integrity: sha512-LjdcbuBeLcdETCrPn9i8AYAZ1eCtu4ECAWtP7UleOiZ9LzVxRzzUZEoZ8zB24nhkQnDWyET0I+3sWokSDS3E7g==}
@@ -9573,19 +9579,16 @@ packages:
peerDependencies:
browserslist: '>= 4.21.0'
uploadthing@6.13.3:
resolution: {integrity: sha512-MkwKeuo0cVSJ9XHZgEW67qzCmk8QF1mDNf3cDnDC4v0g7o7mnCWgATyYsKSFURQPLnRvysddDxmsaekDOomXvw==}
uploadthing@7.3.0:
resolution: {integrity: sha512-ALZCOI5m5XyDD9YHCewCrhLFnELeI8xRJfJC4PvGdh9u6PcAyv851UT92JC6BLtJdgB2Fi/o9gPOXMpZkD5pSw==}
engines: {node: '>=18.13.0'}
peerDependencies:
'@effect/platform': '*'
express: '*'
fastify: '*'
h3: '*'
next: '*'
tailwindcss: '*'
peerDependenciesMeta:
'@effect/platform':
optional: true
express:
optional: true
fastify:
@@ -11468,10 +11471,11 @@ snapshots:
'@drizzle-team/brocli@0.10.2': {}
'@effect/schema@0.68.18(effect@3.4.8)':
'@effect/platform@0.69.8(effect@3.10.3)':
dependencies:
effect: 3.4.8
fast-check: 3.23.1
effect: 3.10.3
find-my-way-ts: 0.1.5
multipasta: 0.2.5
'@emnapi/core@1.3.1':
dependencies:
@@ -14173,13 +14177,13 @@ snapshots:
'@typescript-eslint/types': 8.14.0
eslint-visitor-keys: 3.4.3
'@uploadthing/mime-types@0.2.10': {}
'@uploadthing/mime-types@0.3.2': {}
'@uploadthing/shared@6.7.9':
'@uploadthing/shared@7.1.1':
dependencies:
'@uploadthing/mime-types': 0.2.10
effect: 3.4.8
std-env: 3.7.0
'@uploadthing/mime-types': 0.3.2
effect: 3.10.3
sqids: 0.3.0
'@vercel/blob@0.22.3':
dependencies:
@@ -15274,7 +15278,9 @@ snapshots:
minimatch: 9.0.1
semver: 7.6.3
effect@3.4.8: {}
effect@3.10.3:
dependencies:
fast-check: 3.23.1
ejs@3.1.10:
dependencies:
@@ -15987,6 +15993,8 @@ snapshots:
make-dir: 3.1.0
pkg-dir: 4.2.0
find-my-way-ts@0.1.5: {}
find-node-modules@2.1.3:
dependencies:
findup-sync: 4.0.0
@@ -17510,6 +17518,8 @@ snapshots:
ms@2.1.3: {}
multipasta@0.2.5: {}
nanoid@3.3.7: {}
napi-build-utils@1.0.2: {}
@@ -18764,6 +18774,8 @@ snapshots:
sprintf-js@1.1.3: {}
sqids@0.3.0: {}
stable-hash@0.0.4: {}
stack-utils@2.0.6:
@@ -19303,14 +19315,12 @@ snapshots:
escalade: 3.2.0
picocolors: 1.1.1
uploadthing@6.13.3(next@15.0.0(@opentelemetry/api@1.9.0)(@playwright/test@1.48.1)(babel-plugin-macros@3.1.0)(babel-plugin-react-compiler@0.0.0-experimental-24ec0eb-20240918)(react-dom@19.0.0-rc-65a56d0e-20241020(react@19.0.0-rc-65a56d0e-20241020))(react@19.0.0-rc-65a56d0e-20241020)(sass@1.77.4)):
uploadthing@7.3.0(next@15.0.0(@opentelemetry/api@1.9.0)(@playwright/test@1.48.1)(babel-plugin-macros@3.1.0)(react-dom@19.0.0-rc-65a56d0e-20241020(react@19.0.0-rc-65a56d0e-20241020))(react@19.0.0-rc-65a56d0e-20241020)(sass@1.77.4)):
dependencies:
'@effect/schema': 0.68.18(effect@3.4.8)
'@uploadthing/mime-types': 0.2.10
'@uploadthing/shared': 6.7.9
consola: 3.2.3
effect: 3.4.8
std-env: 3.7.0
'@effect/platform': 0.69.8(effect@3.10.3)
'@uploadthing/mime-types': 0.3.2
'@uploadthing/shared': 7.1.1
effect: 3.10.3
optionalDependencies:
next: 15.0.0(@opentelemetry/api@1.9.0)(@playwright/test@1.48.1)(babel-plugin-macros@3.1.0)(babel-plugin-react-compiler@0.0.0-experimental-24ec0eb-20240918)(react-dom@19.0.0-rc-65a56d0e-20241020(react@19.0.0-rc-65a56d0e-20241020))(react@19.0.0-rc-65a56d0e-20241020)(sass@1.77.4)

View File

@@ -9,7 +9,7 @@
"test": "pnpm -C \"../\" run test",
"test:e2e": "pnpm -C \"../\" run test:e2e",
"test:int": "pnpm -C \"../\" run test:int",
"typecheck": "pnpm turbo build --filter test && tsc --project tsconfig.typecheck.json"
"typecheck": "pnpm turbo build --filter payload-test-suite && tsc --project tsconfig.typecheck.json"
},
"lint-staged": {
"**/package.json": "sort-package-json",
@@ -81,7 +81,6 @@
"tempy": "^1.0.1",
"ts-essentials": "10.0.3",
"typescript": "5.6.3",
"uploadthing": "^6.10.1",
"uuid": "10.0.0"
},
"overrides": {

View File

@@ -40,7 +40,7 @@ export default buildConfigWithDefaults({
[mediaSlug]: true,
},
options: {
apiKey: process.env.UPLOADTHING_SECRET,
token: process.env.UPLOADTHING_TOKEN,
acl: 'public-read',
},
}),

View File

@@ -7,130 +7,313 @@
*/
export interface Config {
auth: {
users: UserAuthOperations;
};
collections: {
media: Media
'media-with-prefix': MediaWithPrefix
users: User
'payload-preferences': PayloadPreference
'payload-migrations': PayloadMigration
}
globals: {}
locale: null
media: Media;
'media-with-prefix': MediaWithPrefix;
users: User;
'payload-locked-documents': PayloadLockedDocument;
'payload-preferences': PayloadPreference;
'payload-migrations': PayloadMigration;
};
collectionsJoins: {};
collectionsSelect: {
media: MediaSelect<false> | MediaSelect<true>;
'media-with-prefix': MediaWithPrefixSelect<false> | MediaWithPrefixSelect<true>;
users: UsersSelect<false> | UsersSelect<true>;
'payload-locked-documents': PayloadLockedDocumentsSelect<false> | PayloadLockedDocumentsSelect<true>;
'payload-preferences': PayloadPreferencesSelect<false> | PayloadPreferencesSelect<true>;
'payload-migrations': PayloadMigrationsSelect<false> | PayloadMigrationsSelect<true>;
};
db: {
defaultIDType: string;
};
globals: {};
globalsSelect: {};
locale: null;
user: User & {
collection: 'users'
}
collection: 'users';
};
jobs?: {
tasks: unknown;
workflows?: unknown;
};
}
export interface UserAuthOperations {
forgotPassword: {
email: string;
password: string;
};
login: {
email: string;
password: string;
};
registerFirstUser: {
email: string;
password: string;
};
unlock: {
email: string;
password: string;
};
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "media".
*/
export interface Media {
id: string
alt?: string | null
_key?: string | null
updatedAt: string
createdAt: string
url?: string | null
thumbnailURL?: string | null
filename?: string | null
mimeType?: string | null
filesize?: number | null
width?: number | null
height?: number | null
focalX?: number | null
focalY?: number | null
id: string;
alt?: string | null;
_key?: string | null;
updatedAt: string;
createdAt: string;
url?: string | null;
thumbnailURL?: string | null;
filename?: string | null;
mimeType?: string | null;
filesize?: number | null;
width?: number | null;
height?: number | null;
focalX?: number | null;
focalY?: number | null;
sizes?: {
square?: {
_key?: string | null
url?: string | null
width?: number | null
height?: number | null
mimeType?: string | null
filesize?: number | null
filename?: string | null
}
_key?: string | null;
url?: string | null;
width?: number | null;
height?: number | null;
mimeType?: string | null;
filesize?: number | null;
filename?: string | null;
};
sixteenByNineMedium?: {
_key?: string | null
url?: string | null
width?: number | null
height?: number | null
mimeType?: string | null
filesize?: number | null
filename?: string | null
}
}
_key?: string | null;
url?: string | null;
width?: number | null;
height?: number | null;
mimeType?: string | null;
filesize?: number | null;
filename?: string | null;
};
};
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "media-with-prefix".
*/
export interface MediaWithPrefix {
id: string
updatedAt: string
createdAt: string
url?: string | null
thumbnailURL?: string | null
filename?: string | null
mimeType?: string | null
filesize?: number | null
width?: number | null
height?: number | null
focalX?: number | null
focalY?: number | null
id: string;
updatedAt: string;
createdAt: string;
url?: string | null;
thumbnailURL?: string | null;
filename?: string | null;
mimeType?: string | null;
filesize?: number | null;
width?: number | null;
height?: number | null;
focalX?: number | null;
focalY?: number | null;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "users".
*/
export interface User {
id: string
updatedAt: string
createdAt: string
email: string
resetPasswordToken?: string | null
resetPasswordExpiration?: string | null
salt?: string | null
hash?: string | null
loginAttempts?: number | null
lockUntil?: string | null
password?: string | null
id: string;
updatedAt: string;
createdAt: string;
email: string;
resetPasswordToken?: string | null;
resetPasswordExpiration?: string | null;
salt?: string | null;
hash?: string | null;
loginAttempts?: number | null;
lockUntil?: string | null;
password?: string | null;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "payload-locked-documents".
*/
export interface PayloadLockedDocument {
id: string;
document?:
| ({
relationTo: 'media';
value: string | Media;
} | null)
| ({
relationTo: 'media-with-prefix';
value: string | MediaWithPrefix;
} | null)
| ({
relationTo: 'users';
value: string | User;
} | null);
globalSlug?: string | null;
user: {
relationTo: 'users';
value: string | User;
};
updatedAt: string;
createdAt: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "payload-preferences".
*/
export interface PayloadPreference {
id: string
id: string;
user: {
relationTo: 'users'
value: string | User
}
key?: string | null
relationTo: 'users';
value: string | User;
};
key?: string | null;
value?:
| {
[k: string]: unknown
[k: string]: unknown;
}
| unknown[]
| string
| number
| boolean
| null
updatedAt: string
createdAt: string
| null;
updatedAt: string;
createdAt: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "payload-migrations".
*/
export interface PayloadMigration {
id: string
name?: string | null
batch?: number | null
updatedAt: string
createdAt: string
id: string;
name?: string | null;
batch?: number | null;
updatedAt: string;
createdAt: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "media_select".
*/
export interface MediaSelect<T extends boolean = true> {
alt?: T;
_key?: T;
updatedAt?: T;
createdAt?: T;
url?: T;
thumbnailURL?: T;
filename?: T;
mimeType?: T;
filesize?: T;
width?: T;
height?: T;
focalX?: T;
focalY?: T;
sizes?:
| T
| {
square?:
| T
| {
_key?: T;
url?: T;
width?: T;
height?: T;
mimeType?: T;
filesize?: T;
filename?: T;
};
sixteenByNineMedium?:
| T
| {
_key?: T;
url?: T;
width?: T;
height?: T;
mimeType?: T;
filesize?: T;
filename?: T;
};
};
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "media-with-prefix_select".
*/
export interface MediaWithPrefixSelect<T extends boolean = true> {
updatedAt?: T;
createdAt?: T;
url?: T;
thumbnailURL?: T;
filename?: T;
mimeType?: T;
filesize?: T;
width?: T;
height?: T;
focalX?: T;
focalY?: T;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "users_select".
*/
export interface UsersSelect<T extends boolean = true> {
updatedAt?: T;
createdAt?: T;
email?: T;
resetPasswordToken?: T;
resetPasswordExpiration?: T;
salt?: T;
hash?: T;
loginAttempts?: T;
lockUntil?: T;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "payload-locked-documents_select".
*/
export interface PayloadLockedDocumentsSelect<T extends boolean = true> {
document?: T;
globalSlug?: T;
user?: T;
updatedAt?: T;
createdAt?: T;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "payload-preferences_select".
*/
export interface PayloadPreferencesSelect<T extends boolean = true> {
user?: T;
key?: T;
value?: T;
updatedAt?: T;
createdAt?: T;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "payload-migrations_select".
*/
export interface PayloadMigrationsSelect<T extends boolean = true> {
name?: T;
batch?: T;
updatedAt?: T;
createdAt?: T;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "auth".
*/
export interface Auth {
[k: string]: unknown;
}
declare module 'payload' {
// @ts-ignore
// @ts-ignore
export interface GeneratedTypes extends Config {}
}
}