fix(payload-cloud): add ts strict mode and fix a couple of wrong runtime behaviors (#10570)
This commit is contained in:
@@ -7,7 +7,7 @@ type NodemailerAdapter = ReturnType<typeof nodemailerAdapter>
|
|||||||
|
|
||||||
export const payloadCloudEmail = async (
|
export const payloadCloudEmail = async (
|
||||||
args: PayloadCloudEmailOptions,
|
args: PayloadCloudEmailOptions,
|
||||||
): Promise<NodemailerAdapter> | undefined => {
|
): Promise<NodemailerAdapter | undefined> => {
|
||||||
if (process.env.PAYLOAD_CLOUD !== 'true' || !args) {
|
if (process.env.PAYLOAD_CLOUD !== 'true' || !args) {
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,10 @@ export const getAfterDeleteHook = ({
|
|||||||
const { identityID, storageClient } = await getStorageClient()
|
const { identityID, storageClient } = await getStorageClient()
|
||||||
|
|
||||||
const filesToDelete: string[] = [
|
const filesToDelete: string[] = [
|
||||||
doc.filename,
|
doc.filename || '',
|
||||||
...Object.values(doc?.sizes || []).map((resizedFileData) => resizedFileData?.filename),
|
...Object.values(doc?.sizes || [])
|
||||||
|
.map((resizedFileData) => resizedFileData.filename)
|
||||||
|
.filter((filename): filename is string => filename !== null),
|
||||||
]
|
]
|
||||||
|
|
||||||
const promises = filesToDelete.map(async (filename) => {
|
const promises = filesToDelete.map(async (filename) => {
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ export const payloadCloudPlugin =
|
|||||||
return config
|
return config
|
||||||
}
|
}
|
||||||
|
|
||||||
const oldAutoRunCopy = config.jobs.autoRun
|
const oldAutoRunCopy = config.jobs.autoRun ?? []
|
||||||
|
|
||||||
const newAutoRun = async (payload: Payload) => {
|
const newAutoRun = async (payload: Payload) => {
|
||||||
const instance = generateRandomString()
|
const instance = generateRandomString()
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ interface Args {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Convert a stream into a promise that resolves with a Buffer
|
// Convert a stream into a promise that resolves with a Buffer
|
||||||
const streamToBuffer = async (readableStream) => {
|
const streamToBuffer = async (readableStream: any) => {
|
||||||
const chunks = []
|
const chunks = []
|
||||||
for await (const chunk of readableStream) {
|
for await (const chunk of readableStream) {
|
||||||
chunks.push(typeof chunk === 'string' ? Buffer.from(chunk) : chunk)
|
chunks.push(typeof chunk === 'string' ? Buffer.from(chunk) : chunk)
|
||||||
@@ -52,7 +52,7 @@ export const getStaticHandler = ({ cachingOptions, collection }: Args): StaticHa
|
|||||||
Key: key,
|
Key: key,
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!object.Body) {
|
if (!object.Body || !object.ContentType || !object.ETag) {
|
||||||
return new Response(null, { status: 404, statusText: 'Not Found' })
|
return new Response(null, { status: 404, statusText: 'Not Found' })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,13 @@ export const authAsCognitoUser = async (
|
|||||||
return sessionAndToken
|
return sessionAndToken
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!process.env.PAYLOAD_CLOUD_COGNITO_USER_POOL_CLIENT_ID) {
|
||||||
|
throw new Error('PAYLOAD_CLOUD_COGNITO_USER_POOL_CLIENT_ID is required')
|
||||||
|
}
|
||||||
|
if (!process.env.PAYLOAD_CLOUD_COGNITO_USER_POOL_ID) {
|
||||||
|
throw new Error('PAYLOAD_CLOUD_COGNITO_USER_POOL_ID is required')
|
||||||
|
}
|
||||||
|
|
||||||
const userPool = new CognitoUserPool({
|
const userPool = new CognitoUserPool({
|
||||||
ClientId: process.env.PAYLOAD_CLOUD_COGNITO_USER_POOL_CLIENT_ID,
|
ClientId: process.env.PAYLOAD_CLOUD_COGNITO_USER_POOL_CLIENT_ID,
|
||||||
UserPoolId: process.env.PAYLOAD_CLOUD_COGNITO_USER_POOL_ID,
|
UserPoolId: process.env.PAYLOAD_CLOUD_COGNITO_USER_POOL_ID,
|
||||||
|
|||||||
@@ -23,6 +23,16 @@ export const getStorageClient: GetStorageClient = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!process.env.PAYLOAD_CLOUD_PROJECT_ID) {
|
||||||
|
throw new Error('PAYLOAD_CLOUD_PROJECT_ID is required')
|
||||||
|
}
|
||||||
|
if (!process.env.PAYLOAD_CLOUD_COGNITO_PASSWORD) {
|
||||||
|
throw new Error('PAYLOAD_CLOUD_COGNITO_PASSWORD is required')
|
||||||
|
}
|
||||||
|
if (!process.env.PAYLOAD_CLOUD_COGNITO_IDENTITY_POOL_ID) {
|
||||||
|
throw new Error('PAYLOAD_CLOUD_COGNITO_IDENTITY_POOL_ID is required')
|
||||||
|
}
|
||||||
|
|
||||||
session = await authAsCognitoUser(
|
session = await authAsCognitoUser(
|
||||||
process.env.PAYLOAD_CLOUD_PROJECT_ID,
|
process.env.PAYLOAD_CLOUD_PROJECT_ID,
|
||||||
process.env.PAYLOAD_CLOUD_COGNITO_PASSWORD,
|
process.env.PAYLOAD_CLOUD_COGNITO_PASSWORD,
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
{
|
{
|
||||||
"extends": "../../tsconfig.base.json",
|
"extends": "../../tsconfig.base.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"strict": true
|
||||||
|
},
|
||||||
"references": [{ "path": "../payload" }]
|
"references": [{ "path": "../payload" }]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user