@dimah-s3/core 1.7.0 → 2.0.0-beta.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.
Files changed (78) hide show
  1. package/README.md +32 -13
  2. package/dist/create-s3-client.d.ts +3 -0
  3. package/dist/create-s3-client.d.ts.map +1 -1
  4. package/dist/error-codes.d.ts +297 -29
  5. package/dist/error-codes.d.ts.map +1 -1
  6. package/dist/error.d.ts +46 -14
  7. package/dist/error.d.ts.map +1 -1
  8. package/dist/helpers/base64url.d.ts +18 -0
  9. package/dist/helpers/base64url.d.ts.map +1 -0
  10. package/dist/helpers/build-content-disposition.d.ts +4 -4
  11. package/dist/helpers/build-content-disposition.d.ts.map +1 -1
  12. package/dist/helpers/build-object-key.d.ts.map +1 -1
  13. package/dist/helpers/checksum.d.ts +8 -2
  14. package/dist/helpers/checksum.d.ts.map +1 -1
  15. package/dist/helpers/content-type.d.ts +17 -0
  16. package/dist/helpers/content-type.d.ts.map +1 -0
  17. package/dist/helpers/fit-file-name.d.ts +15 -0
  18. package/dist/helpers/fit-file-name.d.ts.map +1 -0
  19. package/dist/helpers/index.d.ts +7 -9
  20. package/dist/helpers/index.d.ts.map +1 -1
  21. package/dist/helpers/magic-bytes.d.ts +9 -2
  22. package/dist/helpers/magic-bytes.d.ts.map +1 -1
  23. package/dist/helpers/normalize-object-key.d.ts +8 -3
  24. package/dist/helpers/normalize-object-key.d.ts.map +1 -1
  25. package/dist/helpers/parse-file-name.d.ts +5 -0
  26. package/dist/helpers/parse-file-name.d.ts.map +1 -1
  27. package/dist/helpers/public-object-url.d.ts.map +1 -1
  28. package/dist/helpers/resolve-inline-disposition.d.ts +16 -6
  29. package/dist/helpers/resolve-inline-disposition.d.ts.map +1 -1
  30. package/dist/helpers/strip-slashes.d.ts +5 -0
  31. package/dist/helpers/strip-slashes.d.ts.map +1 -0
  32. package/dist/helpers/validate-file.d.ts +13 -16
  33. package/dist/helpers/validate-file.d.ts.map +1 -1
  34. package/dist/index.d.ts +2 -2
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +713 -465
  37. package/dist/index.js.map +1 -1
  38. package/dist/limits.d.ts +30 -0
  39. package/dist/limits.d.ts.map +1 -0
  40. package/dist/plugin/create-s3-fetch.d.ts +5 -3
  41. package/dist/plugin/create-s3-fetch.d.ts.map +1 -1
  42. package/dist/plugin/types.d.ts +13 -4
  43. package/dist/plugin/types.d.ts.map +1 -1
  44. package/dist/routes.d.ts +10 -4
  45. package/dist/routes.d.ts.map +1 -1
  46. package/dist/schema/catalog.d.ts +30 -39
  47. package/dist/schema/catalog.d.ts.map +1 -1
  48. package/dist/schema/delete.d.ts +1 -2
  49. package/dist/schema/delete.d.ts.map +1 -1
  50. package/dist/schema/download.d.ts +16 -3
  51. package/dist/schema/download.d.ts.map +1 -1
  52. package/dist/schema/index.d.ts +5 -9
  53. package/dist/schema/index.d.ts.map +1 -1
  54. package/dist/schema/index.js +221 -0
  55. package/dist/schema/index.js.map +1 -0
  56. package/dist/schema/multipart.d.ts +6 -29
  57. package/dist/schema/multipart.d.ts.map +1 -1
  58. package/dist/schema/shared.d.ts +25 -17
  59. package/dist/schema/shared.d.ts.map +1 -1
  60. package/dist/schema/upload.d.ts +10 -7
  61. package/dist/schema/upload.d.ts.map +1 -1
  62. package/dist/types/index.d.ts +2 -2
  63. package/dist/types/index.d.ts.map +1 -1
  64. package/dist/types/requests.d.ts +25 -31
  65. package/dist/types/requests.d.ts.map +1 -1
  66. package/dist/types/responses.d.ts +96 -83
  67. package/dist/types/responses.d.ts.map +1 -1
  68. package/package.json +9 -4
  69. package/dist/helpers/format-file-size.d.ts +0 -18
  70. package/dist/helpers/format-file-size.d.ts.map +0 -1
  71. package/dist/helpers/sanitize-file-name.d.ts +0 -3
  72. package/dist/helpers/sanitize-file-name.d.ts.map +0 -1
  73. package/dist/helpers/truncate-file-name.d.ts +0 -5
  74. package/dist/helpers/truncate-file-name.d.ts.map +0 -1
  75. package/dist/schema/error.d.ts +0 -14
  76. package/dist/schema/error.d.ts.map +0 -1
  77. package/dist/schema/file.d.ts +0 -12
  78. package/dist/schema/file.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../src/schema/upload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAUzB,eAAO,MAAM,gBAAgB;;;;;;;kBAQ3B,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;kBAG5B,CAAC"}
1
+ {"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../src/schema/upload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAWzB,eAAO,MAAM,gBAAgB;;;;;;;kBAgB3B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;kBAE3B,CAAC"}
@@ -1,6 +1,6 @@
1
1
  export type { UploadPresignMethod } from "./upload-presign-method";
2
- export type { S3ObjectAcl, S3ApiHeaders, UploadPayload, ConfirmPayload, DownloadPayload, DeletePayload, DeleteBatchPayload, FilePayload, MultipartInitPayload, MultipartSignPartPayload, MultipartListPartsPayload, MultipartCompletedPartRef, MultipartCompletePayload, MultipartAbortPayload, } from "./requests";
3
- export type { DeleteResponse, DeleteBatchItemResult, DeleteBatchResponse, MultipartCompleteResponse, MultipartAbortResponse, DownloadPresignResponse, UploadPresignResponse, MultipartInitResponse, MultipartPartResponse, MultipartPartInfo, MultipartListPartsResponse, UploadConfirmResponse, ConfirmedObjectResponse, S3Api, } from "./responses";
2
+ export type { S3ObjectAcl, S3RequestOptions, UploadPayload, DownloadPayload, FilePayload, DeletePayload, DeleteManyPayload, MultipartInitPayload, MultipartSignPartPayload, TicketPayload, } from "./requests";
3
+ export type { DeleteResponse, DeleteManyResponse, MultipartCompleteResponse, MultipartAbortResponse, DownloadPresignResponse, UploadPresignResponse, MultipartInitResponse, MultipartPartResponse, MultipartPartInfo, MultipartListPartsResponse, UploadConfirmResponse, ConfirmedObjectResponse, S3Api, } from "./responses";
4
4
  export type { RouteCatalogEntry, RouteCatalogResponse } from "../schema/catalog.js";
5
5
  export type { ContentDispositionType } from "../helpers/build-content-disposition.js";
6
6
  export type { DimahS3Routes, InferS3Routes, S3RouteName } from "./routes";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACnE,YAAY,EACV,WAAW,EACX,YAAY,EACZ,aAAa,EACb,cAAc,EACd,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,WAAW,EACX,oBAAoB,EACpB,wBAAwB,EACxB,yBAAyB,EACzB,yBAAyB,EACzB,wBAAwB,EACxB,qBAAqB,GACtB,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,cAAc,EACd,qBAAqB,EACrB,mBAAmB,EACnB,yBAAyB,EACzB,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,0BAA0B,EAC1B,qBAAqB,EACrB,uBAAuB,EACvB,KAAK,GACN,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAChF,YAAY,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAClF,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACnE,YAAY,EACV,WAAW,EACX,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,oBAAoB,EACpB,wBAAwB,EACxB,aAAa,GACd,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,cAAc,EACd,kBAAkB,EAClB,yBAAyB,EACzB,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,0BAA0B,EAC1B,qBAAqB,EACrB,uBAAuB,EACvB,KAAK,GACN,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAChF,YAAY,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAClF,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC"}
@@ -1,47 +1,41 @@
1
1
  import type * as z from "zod";
2
- import type { confirmBodySchema, uploadBodySchema } from "../schema/upload.js";
3
- import type { downloadQuerySchema } from "../schema/download.js";
4
- import type { deleteBatchBodySchema, deleteQuerySchema } from "../schema/delete.js";
5
- import type { fileQuerySchema } from "../schema/file.js";
2
+ import type { ticketBodySchema, uploadBodySchema } from "../schema/upload.js";
3
+ import type { downloadQuerySchema, fileQuerySchema } from "../schema/download.js";
4
+ import type { deleteManyBodySchema, deleteQuerySchema } from "../schema/delete.js";
6
5
  import type { S3RouteName } from "./routes";
7
- import type { multipartAbortBodySchema, multipartCompleteBodySchema, multipartCompletedPartSchema, multipartInitBodySchema, multipartListPartsQuerySchema, multipartSignPartBodySchema } from "../schema/multipart.js";
6
+ import type { multipartInitBodySchema, multipartSignPartBodySchema } from "../schema/multipart.js";
8
7
  import type { s3ObjectAclSchema } from "../schema/shared.js";
9
8
  export type { UploadPresignMethod } from "./upload-presign-method";
10
9
  /** S3 object ACL. */
11
10
  export type S3ObjectAcl = z.output<typeof s3ObjectAclSchema>;
12
- /**
13
- * Server-side auth context for `dimahS3().api` calls (guards / db scope).
14
- * Ignored by {@link createS3Client} — never sent over the wire.
15
- */
16
- export type S3ApiHeaders = {
17
- /** Forwarded into a synthetic `Request` for server-side `api` calls. */
11
+ /** Per-call options for {@link S3Api} methods in the browser. */
12
+ export type S3RequestOptions = {
13
+ /** Aborts the request. */
14
+ signal?: AbortSignal;
15
+ /** Merged over the client headers. Per-call values win. */
18
16
  headers?: HeadersInit;
19
17
  };
20
- type WithNamedRoute<T> = Omit<T, "route"> & {
18
+ type Named<T> = Omit<T, "route"> & {
21
19
  route: S3RouteName;
22
- } & S3ApiHeaders;
20
+ };
23
21
  /** Payload for {@link S3Api.upload}. */
24
- export type UploadPayload = WithNamedRoute<z.output<typeof uploadBodySchema>>;
25
- /** Payload for {@link S3Api.confirm}. */
26
- export type ConfirmPayload = WithNamedRoute<z.output<typeof confirmBodySchema>>;
22
+ export type UploadPayload = Named<z.output<typeof uploadBodySchema>>;
23
+ /**
24
+ * Payload of every call that carries only an upload ticket:
25
+ * {@link S3Api.confirm} and the multipart `listParts`, `complete` and
26
+ * `abort`.
27
+ */
28
+ export type TicketPayload = z.output<typeof ticketBodySchema>;
27
29
  /** Payload for {@link S3Api.download}. */
28
- export type DownloadPayload = WithNamedRoute<z.output<typeof downloadQuerySchema>>;
30
+ export type DownloadPayload = Named<z.output<typeof downloadQuerySchema>>;
31
+ /** Query for the same-origin proxy download (`GET /file`). */
32
+ export type FilePayload = Named<z.output<typeof fileQuerySchema>>;
29
33
  /** Payload for {@link S3Api.delete}. */
30
- export type DeletePayload = WithNamedRoute<z.output<typeof deleteQuerySchema>>;
34
+ export type DeletePayload = Named<z.output<typeof deleteQuerySchema>>;
31
35
  /** Payload for {@link S3Api.deleteMany}. */
32
- export type DeleteBatchPayload = WithNamedRoute<z.output<typeof deleteBatchBodySchema>>;
33
- /** Payload for {@link S3Api.file} (proxy download query). */
34
- export type FilePayload = WithNamedRoute<z.output<typeof fileQuerySchema>>;
36
+ export type DeleteManyPayload = Named<z.output<typeof deleteManyBodySchema>>;
35
37
  /** Payload for {@link S3Api.multipart.init}. */
36
- export type MultipartInitPayload = WithNamedRoute<z.output<typeof multipartInitBodySchema>>;
38
+ export type MultipartInitPayload = Named<z.output<typeof multipartInitBodySchema>>;
37
39
  /** Payload for {@link S3Api.multipart.signPart}. */
38
- export type MultipartSignPartPayload = WithNamedRoute<z.output<typeof multipartSignPartBodySchema>>;
39
- /** Payload for {@link S3Api.multipart.listParts}. */
40
- export type MultipartListPartsPayload = WithNamedRoute<z.output<typeof multipartListPartsQuerySchema>>;
41
- /** A completed multipart part reference for {@link S3Api.multipart.complete}. */
42
- export type MultipartCompletedPartRef = z.output<typeof multipartCompletedPartSchema>;
43
- /** Payload for {@link S3Api.multipart.complete}. */
44
- export type MultipartCompletePayload = WithNamedRoute<z.output<typeof multipartCompleteBodySchema>>;
45
- /** Payload for {@link S3Api.multipart.abort}. */
46
- export type MultipartAbortPayload = WithNamedRoute<z.output<typeof multipartAbortBodySchema>>;
40
+ export type MultipartSignPartPayload = z.output<typeof multipartSignPartBodySchema>;
47
41
  //# sourceMappingURL=requests.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"requests.d.ts","sourceRoot":"","sources":["../../src/types/requests.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,CAAC,MAAM,KAAK,CAAC;AAC9B,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAChF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,KAAK,EACV,wBAAwB,EACxB,2BAA2B,EAC3B,4BAA4B,EAC5B,uBAAuB,EACvB,6BAA6B,EAC7B,2BAA2B,EAC5B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,YAAY,EAA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, MultipartInitPayload, MultipartListPartsPayload, MultipartSignPartPayload, S3ObjectAcl, UploadPayload, UploadPresignMethod } from "./requests";
1
+ import type { S3ErrorShape } from "../error-codes.js";
2
+ import type { DeleteManyPayload, DeletePayload, DownloadPayload, MultipartInitPayload, MultipartSignPartPayload, TicketPayload, S3ObjectAcl, S3RequestOptions, UploadPayload, UploadPresignMethod } from "./requests";
2
3
  import type { RouteCatalogResponse } from "../schema/catalog.js";
3
4
  import type { ContentDispositionType } from "../helpers/build-content-disposition.js";
4
- /**
5
- * Response from {@link S3Api.delete}. Delete is idempotent: a key with no
6
- * object still succeeds, with `existed: false`.
7
- */
5
+ /** Response from {@link S3Api.delete}. Delete is idempotent. */
8
6
  export type DeleteResponse = {
9
- success: true;
10
- bucket: string;
11
- key: string;
12
- /** `false` when the object was never uploaded or is already gone. */
13
- existed: boolean;
14
- };
15
- /** Per-key result from {@link S3Api.deleteMany}. */
16
- export type DeleteBatchItemResult = {
7
+ /** S3 object key. */
17
8
  key: string;
18
- success: boolean;
19
- /** Set when `success` is true. Same meaning as {@link DeleteResponse.existed}. */
20
- existed?: boolean;
21
- error?: {
22
- code: string;
23
- message: string;
24
- };
9
+ /** Target bucket. */
10
+ bucket: string;
25
11
  };
26
12
  /** Response from {@link S3Api.deleteMany}. */
27
- export type DeleteBatchResponse = {
28
- results: DeleteBatchItemResult[];
13
+ export type DeleteManyResponse = {
14
+ /** Keys that were deleted. */
15
+ deleted: string[];
16
+ /** Keys that failed, each with its error body. */
17
+ failed: Array<{
18
+ key: string;
19
+ error: S3ErrorShape;
20
+ }>;
29
21
  };
30
22
  /** Verified object metadata after confirm or multipart complete. */
31
23
  export type ConfirmedObjectResponse = {
@@ -33,51 +25,25 @@ export type ConfirmedObjectResponse = {
33
25
  key: string;
34
26
  /** Target bucket. */
35
27
  bucket: string;
28
+ /** Stored file name. */
29
+ name?: string;
30
+ /** Verified size in bytes, from HeadObject. */
31
+ size: number;
36
32
  /** MIME type from HeadObject. */
37
- contentType?: string;
38
- /** Verified size in bytes. */
39
- contentLength: number;
33
+ type?: string;
40
34
  /** ETag from HeadObject. */
41
35
  eTag?: string;
42
- /** Object metadata. */
43
- metadata: Record<string, string>;
44
- /** ACL from the upload policy (`upload.acl` / `object`). */
45
- acl?: S3ObjectAcl;
46
- /** Stored filename. */
47
- fileName?: string;
48
36
  /** S3 version ID. */
49
37
  versionId?: string;
50
38
  /** Last modified timestamp. */
51
39
  lastModified?: string;
40
+ /** User metadata, without internal keys. */
41
+ metadata: Record<string, string>;
42
+ /** ACL from the upload policy (`upload.acl` / `object`). */
43
+ acl?: S3ObjectAcl;
52
44
  };
53
45
  /** Response from {@link S3Api.confirm}. */
54
46
  export type UploadConfirmResponse = ConfirmedObjectResponse;
55
- /** Response from {@link S3Api.multipart.complete}. */
56
- export type MultipartCompleteResponse = ConfirmedObjectResponse & {
57
- uploadId: string;
58
- };
59
- /** Response from {@link S3Api.multipart.abort}. */
60
- export type MultipartAbortResponse = {
61
- aborted: boolean;
62
- bucket: string;
63
- key: string;
64
- uploadId: string;
65
- };
66
- /** Presigned GET URL for download, or a same-origin proxy URL. */
67
- export type DownloadPresignResponse = {
68
- /** S3 object key. */
69
- key: string;
70
- /** Target bucket. */
71
- bucket: string;
72
- /** Presigned URL, or the same-origin `/file` URL when `mode` is `"proxy"`. */
73
- url: string;
74
- /** Validity in seconds. `0` when `mode` is `"proxy"` (session-bound). */
75
- expiresIn: number;
76
- /** How the browser should fetch the object. @default "presign" */
77
- mode?: "presign" | "proxy";
78
- /** Content-Disposition used on the signed / proxied GET. */
79
- disposition?: ContentDispositionType;
80
- };
81
47
  type UploadPresignBase = {
82
48
  /** S3 object key. */
83
49
  key: string;
@@ -85,20 +51,22 @@ type UploadPresignBase = {
85
51
  bucket: string;
86
52
  /** Presigned upload URL. */
87
53
  url: string;
88
- /** Validity in seconds. */
54
+ /** URL validity in seconds. */
89
55
  expiresIn: number;
56
+ /** Upload ticket. Send it to {@link S3Api.confirm}. */
57
+ ticket: string;
90
58
  };
91
59
  /** Presigned upload URL and method-specific fields. */
92
60
  export type UploadPresignResponse = UploadPresignBase & ({
93
61
  method: Extract<UploadPresignMethod, "POST">;
94
- /** Form fields — append to FormData before the file. */
62
+ /** Form fields. Append them to FormData before the file. */
95
63
  fields: Record<string, string>;
96
64
  } | {
97
65
  method: Extract<UploadPresignMethod, "PUT">;
98
- /** Request headers for the PUT. */
66
+ /** Send exactly these on the PUT, never `Content-Length` or `Host`. */
99
67
  headers: Record<string, string>;
100
68
  });
101
- /** Response from multipart upload initialization. */
69
+ /** Response from {@link S3Api.multipart.init}. The server picks the part layout. */
102
70
  export type MultipartInitResponse = {
103
71
  /** S3 object key. */
104
72
  key: string;
@@ -106,6 +74,14 @@ export type MultipartInitResponse = {
106
74
  bucket: string;
107
75
  /** S3 multipart upload ID. */
108
76
  uploadId: string;
77
+ /** Upload ticket. Send it to every later multipart call. */
78
+ ticket: string;
79
+ /** Size of every part except the last, in bytes. */
80
+ partSize: number;
81
+ /** Number of parts to upload. */
82
+ partCount: number;
83
+ /** Every part must send a SHA-256 checksum. */
84
+ checksum: boolean;
109
85
  };
110
86
  /** Presigned URL for a single multipart part. */
111
87
  export type MultipartPartResponse = {
@@ -113,14 +89,12 @@ export type MultipartPartResponse = {
113
89
  url: string;
114
90
  /** 1-based part number. */
115
91
  partNumber: number;
116
- /** Multipart upload ID. */
117
- uploadId: string;
118
- /** Target bucket. */
119
- bucket: string;
120
- /** Validity in seconds. */
92
+ /** Exact byte size signed into this part's URL. */
93
+ size: number;
94
+ /** URL validity in seconds. */
121
95
  expiresIn: number;
122
- /** Exact byte size locked into this part's presigned URL signature. */
123
- partSize: number;
96
+ /** Send exactly these on the part PUT. */
97
+ headers: Record<string, string>;
124
98
  };
125
99
  /** A part already uploaded in a multipart session. */
126
100
  export type MultipartPartInfo = {
@@ -130,30 +104,69 @@ export type MultipartPartInfo = {
130
104
  size: number;
131
105
  /** Part ETag from S3. */
132
106
  eTag: string;
107
+ /** Base64 SHA-256 of the part, when S3 stored one. */
108
+ checksum?: string;
133
109
  };
134
- /** Response from listing uploaded multipart parts. */
110
+ /** Response from {@link S3Api.multipart.listParts}. */
135
111
  export type MultipartListPartsResponse = {
136
112
  parts: MultipartPartInfo[];
137
113
  };
114
+ /** Response from {@link S3Api.multipart.complete}. */
115
+ export type MultipartCompleteResponse = ConfirmedObjectResponse & {
116
+ uploadId: string;
117
+ };
118
+ /** Response from {@link S3Api.multipart.abort}. */
119
+ export type MultipartAbortResponse = {
120
+ /** S3 object key. */
121
+ key: string;
122
+ /** Target bucket. */
123
+ bucket: string;
124
+ /** Aborted multipart upload ID. */
125
+ uploadId: string;
126
+ };
127
+ /**
128
+ * Presigned GET URL for download, or a same-origin proxy URL. Narrow on
129
+ * `mode`: only a presigned URL expires.
130
+ */
131
+ export type DownloadPresignResponse = {
132
+ /** S3 object key. */
133
+ key: string;
134
+ /** Target bucket. */
135
+ bucket: string;
136
+ /** Content-Disposition used on the signed or proxied GET. */
137
+ disposition: ContentDispositionType;
138
+ } & ({
139
+ mode: "presign";
140
+ /** Presigned S3 URL. */
141
+ url: string;
142
+ /** URL validity in seconds. */
143
+ expiresIn: number;
144
+ } | {
145
+ mode: "proxy";
146
+ /** The `/file` URL. It does not expire: each request is authorized again. */
147
+ url: string;
148
+ expiresIn?: never;
149
+ });
138
150
  /**
139
151
  * Presign API protocol shared by `@dimah-s3/react` hooks and `@dimah-s3/server`.
140
152
  *
141
- * Implement with `createS3Client()` from `@dimah-s3/core` / `@dimah-s3/react`,
142
- * or any custom backend.
153
+ * Every method takes per-call `options` last. In the browser they are
154
+ * {@link S3RequestOptions}. Implement with `createS3Client()` from
155
+ * `@dimah-s3/core`, or with any custom backend.
143
156
  */
144
- export type S3Api = {
145
- upload: (payload: UploadPayload) => Promise<UploadPresignResponse>;
146
- confirm: (payload: ConfirmPayload) => Promise<UploadConfirmResponse>;
147
- download: (payload: DownloadPayload) => Promise<DownloadPresignResponse>;
148
- catalog: () => Promise<RouteCatalogResponse>;
149
- delete: (payload: DeletePayload) => Promise<DeleteResponse>;
150
- deleteMany: (payload: DeleteBatchPayload) => Promise<DeleteBatchResponse>;
157
+ export type S3Api<O = S3RequestOptions> = {
158
+ upload(payload: UploadPayload, options?: O): Promise<UploadPresignResponse>;
159
+ confirm(payload: TicketPayload, options?: O): Promise<UploadConfirmResponse>;
160
+ download(payload: DownloadPayload, options?: O): Promise<DownloadPresignResponse>;
161
+ catalog(options?: O): Promise<RouteCatalogResponse>;
162
+ delete(payload: DeletePayload, options?: O): Promise<DeleteResponse>;
163
+ deleteMany(payload: DeleteManyPayload, options?: O): Promise<DeleteManyResponse>;
151
164
  multipart: {
152
- init: (payload: MultipartInitPayload) => Promise<MultipartInitResponse>;
153
- signPart: (payload: MultipartSignPartPayload) => Promise<MultipartPartResponse>;
154
- listParts: (payload: MultipartListPartsPayload) => Promise<MultipartListPartsResponse>;
155
- complete: (payload: MultipartCompletePayload) => Promise<MultipartCompleteResponse>;
156
- abort: (payload: MultipartAbortPayload) => Promise<MultipartAbortResponse>;
165
+ init(payload: MultipartInitPayload, options?: O): Promise<MultipartInitResponse>;
166
+ signPart(payload: MultipartSignPartPayload, options?: O): Promise<MultipartPartResponse>;
167
+ listParts(payload: TicketPayload, options?: O): Promise<MultipartListPartsResponse>;
168
+ complete(payload: TicketPayload, options?: O): Promise<MultipartCompleteResponse>;
169
+ abort(payload: TicketPayload, options?: O): Promise<MultipartAbortResponse>;
157
170
  };
158
171
  };
159
172
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"responses.d.ts","sourceRoot":"","sources":["../../src/types/responses.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,eAAe,EACf,qBAAqB,EACrB,wBAAwB,EACxB,oBAAoB,EACpB,yBAAyB,EACzB,wBAAwB,EACxB,WAAW,EACX,aAAa,EACb,mBAAmB,EACpB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,oBA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,MAAM,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IACrE,UAAU,CACR,OAAO,EAAE,iBAAiB,EAC1B,OAAO,CAAC,EAAE,CAAC,GACV,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAC/B,SAAS,EAAE;QACT,IAAI,CACF,OAAO,EAAE,oBAAoB,EAC7B,OAAO,CAAC,EAAE,CAAC,GACV,OAAO,CAAC,qBAAqB,CAAC,CAAC;QAClC,QAAQ,CACN,OAAO,EAAE,wBAAwB,EACjC,OAAO,CAAC,EAAE,CAAC,GACV,OAAO,CAAC,qBAAqB,CAAC,CAAC;QAClC,SAAS,CACP,OAAO,EAAE,aAAa,EACtB,OAAO,CAAC,EAAE,CAAC,GACV,OAAO,CAAC,0BAA0B,CAAC,CAAC;QACvC,QAAQ,CACN,OAAO,EAAE,aAAa,EACtB,OAAO,CAAC,EAAE,CAAC,GACV,OAAO,CAAC,yBAAyB,CAAC,CAAC;QACtC,KAAK,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;KAC7E,CAAC;CACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dimah-s3/core",
3
- "version": "1.7.0",
3
+ "version": "2.0.0-beta.0",
4
4
  "description": "Typed S3 presign protocol and fetch client shared by @dimah-s3/server and @dimah-s3/react",
5
5
  "keywords": [
6
6
  "s3",
@@ -11,7 +11,7 @@
11
11
  "protocol",
12
12
  "typescript"
13
13
  ],
14
- "homepage": "https://s3.dimah.dev/docs/core",
14
+ "homepage": "https://v2.s3.dimah.dev/docs/core",
15
15
  "bugs": {
16
16
  "url": "https://github.com/dimah-kz/dimah-s3/issues"
17
17
  },
@@ -28,6 +28,10 @@
28
28
  ".": {
29
29
  "types": "./dist/index.d.ts",
30
30
  "default": "./dist/index.js"
31
+ },
32
+ "./schema": {
33
+ "types": "./dist/schema/index.d.ts",
34
+ "default": "./dist/schema/index.js"
31
35
  }
32
36
  },
33
37
  "files": [
@@ -35,6 +39,7 @@
35
39
  ],
36
40
  "dependencies": {
37
41
  "@better-fetch/fetch": "1.3.3",
42
+ "@noble/hashes": "^2.4.0",
38
43
  "better-call": "1.4.4",
39
44
  "zod": "^4.6.7"
40
45
  },
@@ -43,8 +48,8 @@
43
48
  "@workspace/tsup-config": "0.0.0",
44
49
  "@workspace/typescript-config": "0.0.1",
45
50
  "@workspace/vitest-config": "0.0.7",
46
- "eslint": "^10.13.0",
47
- "tsc-alias": "^1.9.9",
51
+ "eslint": "^10.14.0",
52
+ "tsc-alias": "^1.9.10",
48
53
  "tsup": "^9.0.0",
49
54
  "typescript": "7.0.2",
50
55
  "vitest": "^5.0.5"
@@ -1,18 +0,0 @@
1
- /** Binary size units used by {@link formatFileSize}. */
2
- export type FileSizeUnit = "B" | "KB" | "MB" | "GB" | "TB" | "PB" | "EB";
3
- /** Options for {@link formatFileSize}. */
4
- export type FormatFileSizeOptions = {
5
- /**
6
- * Locale for digits and the decimal mark, such as `"fa"` for `۱۲٫۴`.
7
- * @default "en-US"
8
- */
9
- locale?: string | readonly string[];
10
- /** Unit labels, such as translated ones. Missing units stay `B`, `KB`, … */
11
- units?: Partial<Record<FileSizeUnit, string>>;
12
- };
13
- /**
14
- * Formats a byte count with 1024-based units: `1.2 MB`, `512 B`.
15
- * Pass `locale` for native digits and `units` for translated labels.
16
- */
17
- export declare function formatFileSize(bytes: number, options?: FormatFileSizeOptions): string;
18
- //# sourceMappingURL=format-file-size.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"format-file-size.d.ts","sourceRoot":"","sources":["../../src/helpers/format-file-size.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,MAAM,MAAM,YAAY,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAYzE,0CAA0C;AAC1C,MAAM,MAAM,qBAAqB,GAAG;IAClC;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC;IACpC,4EAA4E;IAC5E,KAAK,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC;CAC/C,CAAC;AAwBF;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,qBAA0B,GAClC,MAAM,CAWR"}
@@ -1,3 +0,0 @@
1
- /** Sanitizes a file name for Content-Disposition, query params, and object keys. */
2
- export declare function sanitizeFileName(fileName: string): string;
3
- //# sourceMappingURL=sanitize-file-name.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sanitize-file-name.d.ts","sourceRoot":"","sources":["../../src/helpers/sanitize-file-name.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEzD"}
@@ -1,5 +0,0 @@
1
- /**
2
- * Truncates a filename while preserving the extension when possible.
3
- */
4
- export declare function truncateFileName(name: string, maxChars?: number): string;
5
- //# sourceMappingURL=truncate-file-name.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"truncate-file-name.d.ts","sourceRoot":"","sources":["../../src/helpers/truncate-file-name.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,SAAK,GAAG,MAAM,CAYpE"}
@@ -1,14 +0,0 @@
1
- import * as z from "zod";
2
- /** `params` bag on API error JSON. */
3
- export declare const s3ErrorParamsSchema: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
4
- /**
5
- * better-fetch `errorSchema` — same `{ message, code?, params? }` body
6
- * better-call serializes from `APIError`.
7
- */
8
- export declare const s3FetchErrorSchema: z.ZodObject<{
9
- message: z.ZodString;
10
- code: z.ZodOptional<z.ZodString>;
11
- params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
12
- }, z.core.$strip>;
13
- export type S3FetchError = z.output<typeof s3FetchErrorSchema>;
14
- //# sourceMappingURL=error.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/schema/error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAEzB,sCAAsC;AACtC,eAAO,MAAM,mBAAmB,2EAG/B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB;;;;iBAI7B,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
@@ -1,12 +0,0 @@
1
- import * as z from "zod";
2
- /** Query for the same-origin proxy download (`GET /file`). */
3
- export declare const fileQuerySchema: z.ZodObject<{
4
- route: z.ZodString;
5
- key: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
6
- fileName: z.ZodPreprocess<z.ZodOptional<z.ZodString>, unknown>;
7
- disposition: z.ZodOptional<z.ZodEnum<{
8
- attachment: "attachment";
9
- inline: "inline";
10
- }>>;
11
- }, z.core.$strict>;
12
- //# sourceMappingURL=file.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/schema/file.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAQzB,8DAA8D;AAC9D,eAAO,MAAM,eAAe;;;;;;;;kBAK1B,CAAC"}