@uploadcn/server 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +38 -2
- package/dist/fs.d.ts +36 -0
- package/dist/fs.d.ts.map +1 -0
- package/dist/fs.js +216 -0
- package/dist/fs.js.map +1 -0
- package/dist/index.d.ts +193 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +579 -0
- package/dist/index.js.map +1 -0
- package/dist/ocr.d.ts +154 -0
- package/dist/ocr.d.ts.map +1 -0
- package/dist/ocr.js +534 -0
- package/dist/ocr.js.map +1 -0
- package/dist/scan-B8LojfB0.d.ts +114 -0
- package/dist/scan-B8LojfB0.d.ts.map +1 -0
- package/dist/scan.d.ts +2 -0
- package/dist/scan.js +290 -0
- package/dist/scan.js.map +1 -0
- package/dist/signing-DZiuKRaJ.js +52 -0
- package/dist/signing-DZiuKRaJ.js.map +1 -0
- package/dist/storage-CGGIhRB9.d.ts +77 -0
- package/dist/storage-CGGIhRB9.d.ts.map +1 -0
- package/package.json +56 -3
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
//#region src/storage.d.ts
|
|
2
|
+
interface PresignedRequest {
|
|
3
|
+
url: string;
|
|
4
|
+
/** Headers the client must send unchanged (they are part of the signature). */
|
|
5
|
+
headers: Record<string, string>;
|
|
6
|
+
}
|
|
7
|
+
interface StoredObjectInfo {
|
|
8
|
+
size: number;
|
|
9
|
+
etag?: string;
|
|
10
|
+
contentType?: string;
|
|
11
|
+
}
|
|
12
|
+
interface StoragePart {
|
|
13
|
+
partNumber: number;
|
|
14
|
+
etag: string;
|
|
15
|
+
size: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The server-side half of an upload: signing and finalizing. Implement it to
|
|
19
|
+
* support any S3-compatible store, or a completely different backend.
|
|
20
|
+
*/
|
|
21
|
+
interface UploadStorage {
|
|
22
|
+
/** Short identifier, used in logs and errors. */
|
|
23
|
+
readonly name: string;
|
|
24
|
+
presignPut(input: {
|
|
25
|
+
key: string;
|
|
26
|
+
contentType: string;
|
|
27
|
+
contentLength: number;
|
|
28
|
+
expiresIn: number;
|
|
29
|
+
}): Promise<PresignedRequest>;
|
|
30
|
+
createMultipart(input: {
|
|
31
|
+
key: string;
|
|
32
|
+
contentType: string;
|
|
33
|
+
}): Promise<{
|
|
34
|
+
uploadId: string;
|
|
35
|
+
}>;
|
|
36
|
+
presignPart(input: {
|
|
37
|
+
key: string;
|
|
38
|
+
uploadId: string;
|
|
39
|
+
partNumber: number;
|
|
40
|
+
expiresIn: number;
|
|
41
|
+
}): Promise<string>;
|
|
42
|
+
/** Parts stored so far, or `null` if this storage can't list them. */
|
|
43
|
+
listParts(input: {
|
|
44
|
+
key: string;
|
|
45
|
+
uploadId: string;
|
|
46
|
+
}): Promise<StoragePart[] | null>;
|
|
47
|
+
completeMultipart(input: {
|
|
48
|
+
key: string;
|
|
49
|
+
uploadId: string;
|
|
50
|
+
parts: {
|
|
51
|
+
partNumber: number;
|
|
52
|
+
etag: string;
|
|
53
|
+
}[];
|
|
54
|
+
}): Promise<{
|
|
55
|
+
etag?: string;
|
|
56
|
+
}>;
|
|
57
|
+
abortMultipart(input: {
|
|
58
|
+
key: string;
|
|
59
|
+
uploadId: string;
|
|
60
|
+
}): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Object metadata, `null` if it doesn't exist, or `undefined` if this
|
|
63
|
+
* storage can't check (verification is then skipped).
|
|
64
|
+
*/
|
|
65
|
+
headObject(key: string): Promise<StoredObjectInfo | null | undefined>;
|
|
66
|
+
deleteObject(key: string): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* The object's bytes, or `null` if it doesn't exist. Optional; needed to
|
|
69
|
+
* scan or OCR files after they are stored.
|
|
70
|
+
*/
|
|
71
|
+
getObject?(key: string): Promise<ReadableStream<Uint8Array> | null>;
|
|
72
|
+
/** A URL the app can use to read the object (public or signed). */
|
|
73
|
+
getUrl(key: string): Promise<string>;
|
|
74
|
+
}
|
|
75
|
+
//#endregion
|
|
76
|
+
export { UploadStorage as i, StoragePart as n, StoredObjectInfo as r, PresignedRequest as t };
|
|
77
|
+
//# sourceMappingURL=storage-CGGIhRB9.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage-CGGIhRB9.d.ts","names":[],"sources":["../src/storage.ts"],"mappings":";UAAiB;EACf;;EAEA,SAAS;;UAGM;EACf;EACA;EACA;;UAGe;EACf;EACA;EACA;;;;;;UAOe;;WAEN;EACT,WAAW;IACT;IACA;IACA;IACA;MACE,QAAQ;EACZ,gBAAgB;IACd;IACA;MACE;IAAU;;EACd,YAAY;IACV;IACA;IACA;IACA;MACE;;EAEJ,UAAU;IACR;IACA;MACE,QAAQ;EACZ,kBAAkB;IAChB;IACA;IACA;MAAS;MAAoB;;MAC3B;IAAU;;EACd,eAAe;IAAS;IAAa;MAAqB;;;;;EAK1D,WAAW,cAAc,QAAQ;EACjC,aAAa,cAAc;;;;;EAK3B,WAAW,cAAc,QAAQ,eAAe;;EAEhD,OAAO,cAAc"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,59 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uploadcn/server",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Framework-agnostic upload route for UploadCN: presigned S3/R2 uploads, multipart signing, local-disk storage, Cloudinary signing, virus scanning and OCR, using Web standard Request/Response.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"upload",
|
|
7
|
+
"s3",
|
|
8
|
+
"r2",
|
|
9
|
+
"presigned",
|
|
10
|
+
"multipart",
|
|
11
|
+
"nextjs",
|
|
12
|
+
"tanstack-start",
|
|
13
|
+
"virus-scan",
|
|
14
|
+
"clamav",
|
|
15
|
+
"ocr"
|
|
16
|
+
],
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"type": "module",
|
|
19
|
+
"sideEffects": false,
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/uploadcn/uploadcn.git",
|
|
23
|
+
"directory": "packages/server"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist"
|
|
27
|
+
],
|
|
28
|
+
"exports": {
|
|
29
|
+
".": "./dist/index.js",
|
|
30
|
+
"./fs": "./dist/fs.js",
|
|
31
|
+
"./scan": "./dist/scan.js",
|
|
32
|
+
"./ocr": "./dist/ocr.js",
|
|
33
|
+
"./package.json": "./package.json"
|
|
34
|
+
},
|
|
35
|
+
"types": "./dist/index.d.ts",
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"aws4fetch": "^1.0.20",
|
|
38
|
+
"@uploadcn/core": "^0.1.0"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@types/node": "^24.0.0",
|
|
42
|
+
"eslint": "^10.12.0",
|
|
43
|
+
"tsdown": "^0.23.0",
|
|
44
|
+
"typescript": "^5.9.3",
|
|
45
|
+
"vitest": "^5.0.3",
|
|
46
|
+
"@workspace/eslint-config": "0.0.0",
|
|
47
|
+
"@workspace/typescript-config": "0.0.0"
|
|
48
|
+
},
|
|
49
|
+
"publishConfig": {
|
|
50
|
+
"access": "public"
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"build": "tsdown",
|
|
54
|
+
"dev": "tsdown --watch",
|
|
55
|
+
"lint": "eslint .",
|
|
56
|
+
"typecheck": "tsc --noEmit",
|
|
57
|
+
"test": "vitest run"
|
|
58
|
+
}
|
|
6
59
|
}
|