@humaan/payload-storage-imagekit 2.3.1 → 2.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type ImageKit from '@imagekit/nodejs';
|
|
2
|
-
import type { PayloadHandler, UploadCollectionSlug } from 'payload';
|
|
3
|
-
type CreateImageKitUploadAuthHandlerArgs = {
|
|
4
|
-
client: ImageKit;
|
|
5
|
-
collections: Partial<Record<UploadCollectionSlug, true>>;
|
|
6
|
-
};
|
|
7
|
-
export declare const createImageKitUploadAuthHandler: ({ client, collections, }: CreateImageKitUploadAuthHandlerArgs) => PayloadHandler;
|
|
8
|
-
export {};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export const createImageKitUploadAuthHandler = ({ client, collections })=>{
|
|
2
|
-
return async (req)=>{
|
|
3
|
-
const collectionSlug = req.routeParams?.collection;
|
|
4
|
-
if (typeof collectionSlug !== 'string' || !(collectionSlug in collections) || collections[collectionSlug] !== true) {
|
|
5
|
-
return Response.json({
|
|
6
|
-
message: 'Collection not found.'
|
|
7
|
-
}, {
|
|
8
|
-
status: 404
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
if (!req.user) {
|
|
12
|
-
return Response.json({
|
|
13
|
-
message: 'Unauthorized.'
|
|
14
|
-
}, {
|
|
15
|
-
status: 401
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
return Response.json(client.helper.getAuthenticationParameters(), {
|
|
19
|
-
headers: {
|
|
20
|
-
'Cache-Control': 'no-store'
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
//# sourceMappingURL=customEndpointHandler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/endpoints/customEndpointHandler.ts"],"sourcesContent":["import type { UploadCollectionSlug, PayloadHandler } from 'payload'\n\nimport type ImageKit from '@imagekit/nodejs'\n\ntype CreateImageKitUploadAuthHandlerArgs = {\n client: ImageKit\n collections: Partial<Record<UploadCollectionSlug, true>>\n}\n\nexport const createImageKitUploadAuthHandler = ({\n client,\n collections,\n}: CreateImageKitUploadAuthHandlerArgs): PayloadHandler => {\n return async (req) => {\n const collectionSlug = req.routeParams?.collection\n\n if (\n typeof collectionSlug !== 'string' ||\n !(collectionSlug in collections) ||\n collections[collectionSlug as UploadCollectionSlug] !== true\n ) {\n return Response.json({ message: 'Collection not found.' }, { status: 404 })\n }\n\n if (!req.user) {\n return Response.json({ message: 'Unauthorized.' }, { status: 401 })\n }\n\n return Response.json(client.helper.getAuthenticationParameters(), {\n headers: {\n 'Cache-Control': 'no-store',\n },\n })\n }\n}\n"],"names":["createImageKitUploadAuthHandler","client","collections","req","collectionSlug","routeParams","collection","Response","json","message","status","user","helper","getAuthenticationParameters","headers"],"mappings":"AASA,OAAO,MAAMA,kCAAkC,CAAC,EAC9CC,MAAM,EACNC,WAAW,EACyB;IACpC,OAAO,OAAOC;QACZ,MAAMC,iBAAiBD,IAAIE,WAAW,EAAEC;QAExC,IACE,OAAOF,mBAAmB,YAC1B,CAAEA,CAAAA,kBAAkBF,WAAU,KAC9BA,WAAW,CAACE,eAAuC,KAAK,MACxD;YACA,OAAOG,SAASC,IAAI,CAAC;gBAAEC,SAAS;YAAwB,GAAG;gBAAEC,QAAQ;YAAI;QAC3E;QAEA,IAAI,CAACP,IAAIQ,IAAI,EAAE;YACb,OAAOJ,SAASC,IAAI,CAAC;gBAAEC,SAAS;YAAgB,GAAG;gBAAEC,QAAQ;YAAI;QACnE;QAEA,OAAOH,SAASC,IAAI,CAACP,OAAOW,MAAM,CAACC,2BAA2B,IAAI;YAChEC,SAAS;gBACP,iBAAiB;YACnB;QACF;IACF;AACF,EAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
type ImageKitCropMode = 'at_least' | 'at_max' | 'extract' | 'force' | 'maintain_ratio' | 'pad_extract' | 'pad_resize';
|
|
2
|
-
type ImageKitFocalStrategy = 'coordinates' | 'custom';
|
|
3
|
-
export type BuildImageKitTransformOptions = {
|
|
4
|
-
additionalTransforms?: string[];
|
|
5
|
-
cropMode?: ImageKitCropMode;
|
|
6
|
-
extractZoomOut?: number;
|
|
7
|
-
focalStrategy?: ImageKitFocalStrategy;
|
|
8
|
-
height?: number;
|
|
9
|
-
width?: number;
|
|
10
|
-
};
|
|
11
|
-
export declare const getImageKitCustomCoordinates: (doc: unknown) => string | undefined;
|
|
12
|
-
export declare const getImageKitThumbnailTransform: (doc: unknown) => string;
|
|
13
|
-
export declare const buildImageKitTransform: (doc: unknown, options: BuildImageKitTransformOptions) => string;
|
|
14
|
-
export declare const buildImageKitURL: (doc: unknown, options: BuildImageKitTransformOptions) => string;
|
|
15
|
-
export {};
|