@dimah-s3/core 0.8.5 → 1.0.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/dist/error-codes.d.ts +8 -0
- package/dist/error-codes.d.ts.map +1 -1
- package/dist/index.js +14 -5
- package/dist/index.js.map +1 -1
- package/dist/schema/download.d.ts.map +1 -1
- package/dist/schema/index.d.ts +1 -1
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/multipart.d.ts +1 -1
- package/dist/schema/multipart.d.ts.map +1 -1
- package/dist/schema/shared.d.ts +10 -0
- package/dist/schema/shared.d.ts.map +1 -1
- package/dist/schema/upload.d.ts.map +1 -1
- package/dist/types/requests.d.ts.map +1 -1
- package/dist/types/responses.d.ts +3 -0
- package/dist/types/responses.d.ts.map +1 -1
- package/package.json +4 -3
package/dist/error-codes.d.ts
CHANGED
|
@@ -61,6 +61,14 @@ export declare const S3_ERROR_CODES: {
|
|
|
61
61
|
readonly code: "FILE_SIZE_REQUIRED_MULTIPART";
|
|
62
62
|
readonly message: "fileSize is required when multipart.requireFileSize is enabled";
|
|
63
63
|
};
|
|
64
|
+
readonly MULTIPART_PART_MISSING: {
|
|
65
|
+
readonly code: "MULTIPART_PART_MISSING";
|
|
66
|
+
readonly message: "Uploaded part {partNumber} was not found";
|
|
67
|
+
};
|
|
68
|
+
readonly PAYLOAD_TOO_LARGE: {
|
|
69
|
+
readonly code: "PAYLOAD_TOO_LARGE";
|
|
70
|
+
readonly message: "Payload too large";
|
|
71
|
+
};
|
|
64
72
|
readonly VALIDATION_ERROR: {
|
|
65
73
|
readonly code: "VALIDATION_ERROR";
|
|
66
74
|
readonly message: "Validation Error";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-codes.d.ts","sourceRoot":"","sources":["../src/error-codes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACrE,QAAQ,EAAE,CAAC,GACV;IAAE,QAAQ,EAAE,CAAC,IAAI,MAAM,CAAC,GAAG;QAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;QAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;KAAE;CAAE,CAQ3E;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc
|
|
1
|
+
{"version":3,"file":"error-codes.d.ts","sourceRoot":"","sources":["../src/error-codes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACrE,QAAQ,EAAE,CAAC,GACV;IAAE,QAAQ,EAAE,CAAC,IAAI,MAAM,CAAC,GAAG;QAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;QAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;KAAE;CAAE,CAQ3E;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmBzB,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,MAAM,OAAO,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -107,17 +107,22 @@ function truncateFileName(name, maxChars = 48) {
|
|
|
107
107
|
}
|
|
108
108
|
return name.slice(0, available) + "\u2026 " + ext;
|
|
109
109
|
}
|
|
110
|
+
var S3_DEFAULT_EXPIRES_IN = 600;
|
|
111
|
+
var S3_MAX_EXPIRES_IN = 604800;
|
|
112
|
+
var S3_MAX_POST_OBJECT_BYTES = 5 * 1024 * 1024 * 1024;
|
|
110
113
|
var trimmedString = z.string().trim().min(1);
|
|
111
114
|
var optionalTrimmedString = z.string().trim().min(1).optional();
|
|
112
115
|
var s3ObjectAclSchema = z.enum(["private", "public-read"]);
|
|
113
116
|
var metadataSchema = z.record(z.string(), z.string());
|
|
117
|
+
var optionalExpiresInSchema = z.number().positive().max(S3_MAX_EXPIRES_IN).optional();
|
|
118
|
+
var optionalCoerceExpiresInSchema = z.coerce.number().positive().max(S3_MAX_EXPIRES_IN).optional();
|
|
114
119
|
var uploadBodySchema = z.object({
|
|
115
120
|
key: trimmedString,
|
|
116
121
|
contentType: optionalTrimmedString,
|
|
117
122
|
fileSize: z.number().positive().optional(),
|
|
118
123
|
metadata: metadataSchema.optional(),
|
|
119
124
|
bucket: optionalTrimmedString,
|
|
120
|
-
expiresIn:
|
|
125
|
+
expiresIn: optionalExpiresInSchema,
|
|
121
126
|
acl: s3ObjectAclSchema.optional(),
|
|
122
127
|
fileName: optionalTrimmedString
|
|
123
128
|
});
|
|
@@ -129,20 +134,22 @@ var downloadQuerySchema = z.object({
|
|
|
129
134
|
key: trimmedString,
|
|
130
135
|
bucket: optionalTrimmedString,
|
|
131
136
|
fileName: optionalTrimmedString,
|
|
132
|
-
expiresIn:
|
|
137
|
+
expiresIn: optionalCoerceExpiresInSchema
|
|
133
138
|
});
|
|
134
139
|
var deleteQuerySchema = z.object({
|
|
135
140
|
key: trimmedString,
|
|
136
141
|
bucket: optionalTrimmedString
|
|
137
142
|
});
|
|
138
|
-
var multipartInitBodySchema = uploadBodySchema
|
|
143
|
+
var multipartInitBodySchema = uploadBodySchema.omit({
|
|
144
|
+
expiresIn: true
|
|
145
|
+
});
|
|
139
146
|
var multipartSignPartBodySchema = z.object({
|
|
140
147
|
key: trimmedString,
|
|
141
148
|
uploadId: trimmedString,
|
|
142
149
|
partNumber: z.number().int().positive(),
|
|
143
150
|
partSize: z.number().positive().optional(),
|
|
144
151
|
bucket: optionalTrimmedString,
|
|
145
|
-
expiresIn:
|
|
152
|
+
expiresIn: optionalExpiresInSchema
|
|
146
153
|
});
|
|
147
154
|
var multipartListPartsQuerySchema = z.object({
|
|
148
155
|
key: trimmedString,
|
|
@@ -191,6 +198,8 @@ var S3_ERROR_CODES = defineErrorCodes({
|
|
|
191
198
|
S3_NETWORK_ERROR: "S3 endpoint unreachable ({code}): check your endpoint URL and network connectivity",
|
|
192
199
|
FILE_SIZE_REQUIRED_UPLOAD: "fileSize is required when upload.requireFileSize is enabled",
|
|
193
200
|
FILE_SIZE_REQUIRED_MULTIPART: "fileSize is required when multipart.requireFileSize is enabled",
|
|
201
|
+
MULTIPART_PART_MISSING: "Uploaded part {partNumber} was not found",
|
|
202
|
+
PAYLOAD_TOO_LARGE: "Payload too large",
|
|
194
203
|
VALIDATION_ERROR: "Validation Error"
|
|
195
204
|
});
|
|
196
205
|
|
|
@@ -422,6 +431,6 @@ function createS3Client(options) {
|
|
|
422
431
|
};
|
|
423
432
|
}
|
|
424
433
|
|
|
425
|
-
export { DimahS3Error, RESERVED_CLIENT_KEYS, S3_API_BASE_PATH, S3_API_ROUTES, S3_ERROR_CODES, buildContentDisposition, buildObjectKey, confirmBodySchema, createS3Client, createS3Fetch, defaultObjectKey, defineClientPlugin, defineErrorCodes, deleteQuerySchema, downloadQuerySchema, formatFileSize, getFileExtension, isAPIError, isDimahS3Error, isS3ErrorCode, metadataSchema, multipartAbortBodySchema, multipartCompleteBodySchema, multipartInitBodySchema, multipartListPartsQuerySchema, multipartSignPartBodySchema, normalizeS3ApiBasePath, optionalTrimmedString, parseFileName, pluginPath, s3ErrorParamsSchema, s3FetchErrorSchema, s3ObjectAclSchema, sanitizeFileName, trimmedString, truncateFileName, uploadBodySchema, validateFile };
|
|
434
|
+
export { DimahS3Error, RESERVED_CLIENT_KEYS, S3_API_BASE_PATH, S3_API_ROUTES, S3_DEFAULT_EXPIRES_IN, S3_ERROR_CODES, S3_MAX_EXPIRES_IN, S3_MAX_POST_OBJECT_BYTES, buildContentDisposition, buildObjectKey, confirmBodySchema, createS3Client, createS3Fetch, defaultObjectKey, defineClientPlugin, defineErrorCodes, deleteQuerySchema, downloadQuerySchema, formatFileSize, getFileExtension, isAPIError, isDimahS3Error, isS3ErrorCode, metadataSchema, multipartAbortBodySchema, multipartCompleteBodySchema, multipartInitBodySchema, multipartListPartsQuerySchema, multipartSignPartBodySchema, normalizeS3ApiBasePath, optionalCoerceExpiresInSchema, optionalExpiresInSchema, optionalTrimmedString, parseFileName, pluginPath, s3ErrorParamsSchema, s3FetchErrorSchema, s3ObjectAclSchema, sanitizeFileName, trimmedString, truncateFileName, uploadBodySchema, validateFile };
|
|
426
435
|
//# sourceMappingURL=index.js.map
|
|
427
436
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/helpers/validate-file.ts","../src/helpers/build-object-key.ts","../src/helpers/get-file-extension.ts","../src/helpers/parse-file-name.ts","../src/helpers/format-file-size.ts","../src/helpers/build-content-disposition.ts","../src/helpers/sanitize-file-name.ts","../src/helpers/default-object-key.ts","../src/helpers/truncate-file-name.ts","../src/schema/shared.ts","../src/schema/upload.ts","../src/schema/download.ts","../src/schema/delete.ts","../src/schema/multipart.ts","../src/schema/error.ts","../src/error-codes.ts","../src/error.ts","../src/routes.ts","../src/plugin/create-s3-fetch.ts","../src/plugin/define-client-plugin.ts","../src/plugin/plugin-path.ts","../src/plugin/types.ts","../src/create-s3-client.ts"],"names":["z"],"mappings":";;;;;AAiBO,SAAS,YAAA,CACd,MACA,OAAA,EAC0B;AAC1B,EAAA,IAAI,OAAA,CAAQ,QAAQ,MAAA,EAAQ;AAC1B,IAAA,MAAM,OAAA,GAAU,OAAA,CAAQ,MAAA,CAAO,IAAA,CAAK,CAAC,IAAA,KAAS;AAC5C,MAAA,IAAI,IAAA,CAAK,UAAA,CAAW,GAAG,CAAA,EAAG;AACxB,QAAA,OAAO,KAAK,IAAA,CAAK,WAAA,GAAc,QAAA,CAAS,IAAA,CAAK,aAAa,CAAA;AAAA,MAC5D;AACA,MAAA,IAAI,IAAA,CAAK,QAAA,CAAS,IAAI,CAAA,EAAG;AACvB,QAAA,OAAO,KAAK,IAAA,C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F;AACF;AA6BO,SAAS,eACd,OAAA,EACyB;AACzB,EAAA,MAAM,EAAE,UAAU,OAAA,EAAS,OAAA,EAAS,GAAG,YAAA,EAAa,GAAI,WAAW,EAAC;AACpE,EAAA,MAAM,IAAA,GAAO,sBAAA,CAAuB,OAAA,IAAW,QAAA,IAAY,gBAAgB,CAAA;AAC3E,EAAA,MAAM,MAAA,GAAS,aAAA,CAAc,IAAA,EAAM,YAAY,CAAA;AAE/C,EAAA,MAAM,GAAA,GAAM,cAAc,MAAM,CAAA;AAEhC,EAAA,MAAM,gBAAyC,EAAC;AAChD,EAAA,KAAA,MAAW,MAAA,IAAU,OAAA,IAAW,EAAC,EAAG;AAClC,IAAA,IAAK,oBAAA,CAA2C,QAAA,CAAS,MAAA,CAAO,EAAE,CAAA,EAAG;AACnE,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,CAAA,kBAAA,EAAqB,OAAO,EAAE,CAAA,+BAAA;AAAA,OAChC;AAAA,IACF;AACA,IAAA,IAAI,MAAA,CAAO,MAAM,aAAA,EAAe;AAC9B,MAAA,MAAM,IAAI,KAAA,CAAM,CAAA,4BAAA,EAA+B,MAAA,CAAO,EAAE,CAAA,EAAA,CAAI,CAAA;AAAA,IAC9D;AACA,IAAA,aAAA,CAAc,MAAA,CAAO,EAAE,CAAA,GAAI,MAAA,CAAO,WAAW,MAAM,CAAA;AAAA,EACrD;AAEA,EAAA,OAAO;AAAA,IACL,GAAG,GAAA;AAAA,IACH,GAAG,aAAA;AAAA,IACH,YAAA,EAAc,cAAA;AAAA,IACd,MAAA;AAAA,IACA,QAAQ;AAAC,GACX;AACF","file":"index.js","sourcesContent":["/** Machine-readable codes for client-side file validation failures. */\nexport type ValidateFileErrorCode =\n \"FILE_TYPE_NOT_ALLOWED\" | \"FILE_EMPTY\" | \"FILE_TOO_LARGE\";\n\n/** Result of {@link validateFile} when the file fails a check. */\nexport type ValidateFileError = {\n code: ValidateFileErrorCode;\n /** English fallback message (localize via Fuma when a translator is available). */\n message: string;\n /** Interpolation params for i18n (e.g. `{ type }`, `{ size }`). */\n params?: Record<string, string | number>;\n};\n\n/**\n * Client-side accept / size / empty checks before starting an upload.\n * Returns `null` when the file is valid.\n */\nexport function validateFile(\n file: File,\n options: { accept?: string[]; maxFileSize?: number },\n): ValidateFileError | null {\n if (options.accept?.length) {\n const allowed = options.accept.some((type) => {\n if (type.startsWith(\".\")) {\n return file.name.toLowerCase().endsWith(type.toLowerCase());\n }\n if (type.endsWith(\"/*\")) {\n return file.type.startsWith(type.replace(\"/*\", \"/\"));\n }\n return file.type === type;\n });\n if (!allowed) {\n const ext = file.name.includes(\".\") ? file.name.split(\".\").pop() : null;\n const type = ext ? `.${ext}` : file.type || \"unknown\";\n return {\n code: \"FILE_TYPE_NOT_ALLOWED\",\n message: `File type \"${type}\" is not allowed`,\n params: { type },\n };\n }\n }\n\n if (file.size === 0) {\n return {\n code: \"FILE_EMPTY\",\n message: \"File is empty\",\n };\n }\n\n if (options.maxFileSize && file.size > options.maxFileSize) {\n const maxMB = (options.maxFileSize / (1024 * 1024)).toFixed(1);\n return {\n code: \"FILE_TOO_LARGE\",\n message: `File size exceeds ${maxMB} MB limit`,\n params: { size: `${maxMB} MB` },\n };\n }\n\n return null;\n}\n","export function buildObjectKey(...parts: string[]): string {\n return parts\n .map((p) => p.replace(/^\\/+|\\/+$/g, \"\"))\n .filter(Boolean)\n .join(\"/\");\n}\n","export function getFileExtension(fileName: string): string {\n const dotIndex = fileName.lastIndexOf(\".\");\n if (dotIndex < 1) return \"\";\n return fileName.slice(dotIndex + 1).toLowerCase();\n}\n","export function parseFileName(\n contentDisposition: string | null | undefined,\n): string | undefined {\n if (!contentDisposition) return undefined;\n\n const utf8Match = contentDisposition.match(/filename\\*=UTF-8''([^;,\\s]+)/i);\n if (utf8Match) {\n try {\n return decodeURIComponent(utf8Match[1]);\n } catch {\n /* ignore malformed encoding */\n }\n }\n\n const asciiMatch = contentDisposition.match(/filename=\"([^\"]*)\"/i);\n return asciiMatch?.[1];\n}\n","export function formatFileSize(bytes: number): string {\n if (bytes === 0) return \"0 B\";\n const units = [\"B\", \"KB\", \"MB\", \"GB\", \"TB\"];\n const i = Math.floor(Math.log(bytes) / Math.log(1024));\n const size = bytes / Math.pow(1024, i);\n return `${size.toFixed(i === 0 ? 0 : 1)} ${units[i]}`;\n}\n","/**\n * Builds a RFC 6266 `Content-Disposition` value for a file attachment.\n *\n * Includes both the ASCII-safe `filename` fallback and the RFC 5987\n * `filename*` parameter for full Unicode support.\n */\nexport function buildContentDisposition(fileName: string): string {\n const ascii = fileName.replace(/[^\\x20-\\x7E]/g, \"_\").replace(/[\"\\\\]/g, \"_\");\n const encoded = encodeURIComponent(fileName);\n return `attachment; filename=\"${ascii}\"; filename*=UTF-8''${encoded}`;\n}\n","/** Sanitizes a file name for safe use in URL query parameters. */\nexport function sanitizeFileName(fileName: string): string {\n return fileName.replace(/[\"\\\\\\r\\n]/g, \"_\");\n}\n","import { sanitizeFileName } from \"./sanitize-file-name\";\n\n/**\n * Default object key for client uploads: a UUID prefix plus the sanitized\n * file name so two selections never overwrite the same key.\n */\nexport function defaultObjectKey(file: File): string {\n return `${crypto.randomUUID()}/${sanitizeFileName(file.name)}`;\n}\n","/**\n * Truncates a filename while preserving the extension when possible.\n */\nexport function truncateFileName(name: string, maxChars = 48): string {\n if (name.length <= maxChars) return name;\n const dotIndex = name.lastIndexOf(\".\");\n if (dotIndex <= 0) {\n return name.slice(0, maxChars - 1) + \"…\";\n }\n const ext = name.slice(dotIndex);\n const available = maxChars - ext.length - 1;\n if (available <= 0) {\n return name.slice(0, maxChars - 1) + \"…\";\n }\n return name.slice(0, available) + \"… \" + ext;\n}\n","import { z } from \"zod\";\n\n/** Non-empty trimmed string. */\nexport const trimmedString = z.string().trim().min(1);\n\n/** Optional non-empty trimmed string (empty / missing → omitted). */\nexport const optionalTrimmedString = z.string().trim().min(1).optional();\n\nexport const s3ObjectAclSchema = z.enum([\"private\", \"public-read\"]);\n\nexport const metadataSchema = z.record(z.string(), z.string());\n","import { z } from \"zod\";\nimport {\n metadataSchema,\n optionalTrimmedString,\n s3ObjectAclSchema,\n trimmedString,\n} from \"./shared\";\n\nexport const uploadBodySchema = z.object({\n key: trimmedString,\n contentType: optionalTrimmedString,\n fileSize: z.number().positive().optional(),\n metadata: metadataSchema.optional(),\n bucket: optionalTrimmedString,\n expiresIn: z.number().positive().optional(),\n acl: s3ObjectAclSchema.optional(),\n fileName: optionalTrimmedString,\n});\n\nexport const confirmBodySchema = z.object({\n key: trimmedString,\n bucket: optionalTrimmedString,\n});\n","import { z } from \"zod\";\nimport { optionalTrimmedString, trimmedString } from \"./shared\";\n\n/** Query string — numbers arrive as strings. */\nexport const downloadQuerySchema = z.object({\n key: trimmedString,\n bucket: optionalTrimmedString,\n fileName: optionalTrimmedString,\n expiresIn: z.coerce.number().positive().optional(),\n});\n","import { z } from \"zod\";\nimport { optionalTrimmedString, trimmedString } from \"./shared\";\n\nexport const deleteQuerySchema = z.object({\n key: trimmedString,\n bucket: optionalTrimmedString,\n});\n","import { z } from \"zod\";\nimport { uploadBodySchema } from \"./upload\";\nimport { optionalTrimmedString, trimmedString } from \"./shared\";\n\nexport const multipartInitBodySchema = uploadBodySchema;\n\nexport const multipartSignPartBodySchema = z.object({\n key: trimmedString,\n uploadId: trimmedString,\n partNumber: z.number().int().positive(),\n partSize: z.number().positive().optional(),\n bucket: optionalTrimmedString,\n expiresIn: z.number().positive().optional(),\n});\n\nexport const multipartListPartsQuerySchema = z.object({\n key: trimmedString,\n uploadId: trimmedString,\n bucket: optionalTrimmedString,\n});\n\nexport const multipartCompleteBodySchema = z.object({\n key: trimmedString,\n uploadId: trimmedString,\n parts: z.array(z.object({ partNumber: z.number().int().positive() })).min(1),\n bucket: optionalTrimmedString,\n});\n\nexport const multipartAbortBodySchema = z.object({\n key: trimmedString,\n uploadId: trimmedString,\n bucket: optionalTrimmedString,\n});\n","import { z } from \"zod\";\n\n/** `params` bag on API error JSON. */\nexport const s3ErrorParamsSchema = z.record(\n z.string(),\n z.union([z.string(), z.number()]),\n);\n\n/**\n * better-fetch `errorSchema` — same `{ message, code?, params? }` body\n * better-call serializes from `DimahS3Error`.\n */\nexport const s3FetchErrorSchema = z.object({\n message: z.string(),\n code: z.string().optional(),\n params: s3ErrorParamsSchema.optional(),\n});\n\nexport type S3FetchError = z.infer<typeof s3FetchErrorSchema>;\n","/**\n * Pair each stable API `code` with its English `message`.\n * Same shape as Better Auth `defineErrorCodes`.\n */\nexport function defineErrorCodes<const T extends Record<string, string>>(\n messages: T,\n): { readonly [K in keyof T]: { readonly code: K; readonly message: T[K] } } {\n const codes = {} as {\n [K in keyof T]: { readonly code: K; readonly message: T[K] };\n };\n for (const code of Object.keys(messages) as (keyof T)[]) {\n codes[code] = { code, message: messages[code] };\n }\n return codes;\n}\n\n/**\n * Domain error catalog. Zod failures share {@link S3_ERROR_CODES.VALIDATION_ERROR};\n * HTTP 404 for unknown routes uses {@link S3_ERROR_CODES.NOT_FOUND}.\n */\nexport const S3_ERROR_CODES = defineErrorCodes({\n NOT_FOUND: \"Not Found\",\n UNAUTHORIZED: \"Unauthorized\",\n FORBIDDEN: \"Forbidden\",\n CONFLICT: \"Conflict\",\n INTERNAL_ERROR: \"Internal server error\",\n OBJECT_NOT_FOUND: \"Object not found\",\n FEATURE_DISABLED: \"{feature} is disabled\",\n INVALID_KEY: \"Object key is invalid\",\n INVALID_BUCKET: \"Bucket is not allowed\",\n S3_NETWORK_ERROR:\n \"S3 endpoint unreachable ({code}): check your endpoint URL and network connectivity\",\n FILE_SIZE_REQUIRED_UPLOAD:\n \"fileSize is required when upload.requireFileSize is enabled\",\n FILE_SIZE_REQUIRED_MULTIPART:\n \"fileSize is required when multipart.requireFileSize is enabled\",\n VALIDATION_ERROR: \"Validation Error\",\n});\n\nexport type S3ErrorCode = keyof typeof S3_ERROR_CODES;\n","import { APIError } from \"better-call/error\";\nimport { type S3ErrorCode } from \"./error-codes\";\n\nexport {\n defineErrorCodes,\n S3_ERROR_CODES,\n type S3ErrorCode,\n} from \"./error-codes\";\n\nexport type DimahS3ErrorParams = Record<string, string | number>;\n\nexport type DimahS3ErrorStatus = NonNullable<\n ConstructorParameters<typeof APIError>[0]\n>;\n\nexport type DimahS3ErrorBody = {\n message?: string;\n code?: string;\n cause?: unknown;\n params?: DimahS3ErrorParams;\n} & Record<string, unknown>;\n\ntype RawError = {\n code: string;\n message: string;\n params?: DimahS3ErrorParams;\n};\n\n/**\n * Typed API error. Same constructor as better-call {@link APIError}\n * (`status`, `body`) so `ctx.error(...)` and `DimahS3Error.from(...)` share\n * a shape. HTTP serializes `{ message, code?, params? }` via native `toResponse`.\n */\nexport class DimahS3Error extends APIError {\n constructor(\n status: DimahS3ErrorStatus = \"BAD_REQUEST\",\n body?: DimahS3ErrorBody,\n headers?: HeadersInit,\n ) {\n const { cause, ...rest } = body ?? {};\n super(status, Object.keys(rest).length > 0 ? rest : undefined, headers);\n this.name = \"DimahS3Error\";\n if (cause !== undefined) {\n this.cause = cause;\n }\n }\n\n get code(): string | undefined {\n return this.body?.code;\n }\n\n get params(): DimahS3ErrorParams | undefined {\n return this.body?.params as DimahS3ErrorParams | undefined;\n }\n\n /** Throw a catalog (or custom) `{ code, message }` with an HTTP status. */\n static from(status: DimahS3ErrorStatus, error: RawError): DimahS3Error {\n return new DimahS3Error(status, {\n message: error.message,\n code: error.code,\n ...(error.params !== undefined ? { params: error.params } : {}),\n });\n }\n\n static fromStatus(\n status: DimahS3ErrorStatus,\n body?: DimahS3ErrorBody,\n ): DimahS3Error {\n return new DimahS3Error(status, body);\n }\n}\n\n/** True for {@link DimahS3Error} and better-call `APIError` (including duck-typed copies). */\nexport function isAPIError(error: unknown): error is APIError {\n if (error instanceof APIError) return true;\n const name = (error as { name?: string } | null)?.name;\n return name === \"APIError\" || name === \"DimahS3Error\";\n}\n\nexport function isDimahS3Error(error: unknown): error is DimahS3Error {\n return (\n error instanceof DimahS3Error ||\n (error as { name?: string } | null)?.name === \"DimahS3Error\"\n );\n}\n\n/** True when `error` is a {@link DimahS3Error} with this catalog `code`. */\nexport function isS3ErrorCode<C extends S3ErrorCode>(\n error: unknown,\n code: C,\n): error is DimahS3Error & { code: C } {\n return isDimahS3Error(error) && error.code === code;\n}\n","/** Default mount path for the catch-all route (`app/api/s3/[...s3]/route.ts`). */\nexport const S3_API_BASE_PATH = \"/api/s3\";\n\nexport function normalizeS3ApiBasePath(basePath: string): string {\n return basePath.replace(/\\/$/, \"\");\n}\n\n/** Relative paths under {@link S3_API_BASE_PATH}. Always start with `/`. */\nexport const S3_API_ROUTES = {\n upload: \"/presign/upload\",\n uploadConfirm: \"/presign/upload/confirm\",\n download: \"/presign/download\",\n delete: \"/delete\",\n multipartInit: \"/presign/multipart/init\",\n multipartPart: \"/presign/multipart/part\",\n multipartComplete: \"/presign/multipart/complete\",\n multipartAbort: \"/presign/multipart/abort\",\n multipartListParts: \"/presign/multipart/parts\",\n} as const;\n","import { createFetch } from \"@better-fetch/fetch\";\nimport type { Status } from \"better-call/error\";\nimport { DimahS3Error } from \"../error\";\nimport { s3FetchErrorSchema } from \"../schema/error\";\nimport type { S3ClientFetchOptions, S3Fetch } from \"./types\";\n\nasync function resolveHeaders(\n headers: S3ClientFetchOptions[\"headers\"],\n): Promise<HeadersInit | undefined> {\n if (headers == null) return undefined;\n if (typeof headers === \"function\") return headers();\n return headers;\n}\n\nfunction fallbackMessage(error: {\n statusText: string;\n error?: unknown;\n}): string {\n if (typeof error.error === \"string\" && error.error.trim()) {\n return error.error;\n }\n return error.statusText || \"Request failed\";\n}\n\n/**\n * better-fetch `onError` receives the JSON body spread with `status` /\n * `statusText` — not a `BetterFetchError` instance.\n */\nfunction dimahErrorFromFetch(error: {\n status: number;\n statusText: string;\n error?: unknown;\n}): DimahS3Error {\n const status = error.status as Status;\n const parsed = s3FetchErrorSchema.safeParse(error);\n if (parsed.success) {\n const { message, code, params } = parsed.data;\n return new DimahS3Error(status, {\n message,\n ...(code !== undefined ? { code } : {}),\n ...(params !== undefined ? { params } : {}),\n });\n }\n return new DimahS3Error(status, { message: fallbackMessage(error) });\n}\n\n/**\n * Shared `$fetch` for core routes and client plugins.\n * `base` is a normalized API prefix (e.g. `/api/s3`).\n *\n * Non-OK JSON matching {@link s3FetchErrorSchema} throws {@link DimahS3Error}.\n * `throw: true` is the better-fetch flag; `onError` maps onto the same class\n * the server throws so `instanceof DimahS3Error` works in the browser.\n */\nexport function createS3Fetch(\n base: string,\n options?: S3ClientFetchOptions,\n): S3Fetch {\n return createFetch({\n baseURL: base,\n throw: true,\n errorSchema: s3FetchErrorSchema,\n customFetchImpl: options?.fetch,\n credentials: options?.credentials,\n onRequest: async (ctx) => {\n const extra = await resolveHeaders(options?.headers);\n if (!extra) return ctx;\n const headers = new Headers(ctx.headers);\n new Headers(extra).forEach((value, key) => {\n headers.set(key, value);\n });\n return { ...ctx, headers };\n },\n onError: (ctx) => {\n throw dimahErrorFromFetch(ctx.error);\n },\n });\n}\n","import type { S3ClientPlugin } from \"./types\";\n\n/**\n * Identity helper that preserves literal `id` and method types for\n * {@link createS3Client} inference (`api[id]`).\n *\n * `$InferServerPlugin` must share the same `id` as the client plugin.\n *\n * ```ts\n * export function dbClient() {\n * return defineClientPlugin({\n * id: \"db\",\n * $InferServerPlugin: {} as ReturnType<typeof db>,\n * getActions: ($fetch) => ({\n * listObjects: () => $fetch(\"/db/objects\", { method: \"GET\" }),\n * }),\n * });\n * }\n * ```\n */\nexport function defineClientPlugin<\n Id extends string,\n TMethods extends Record<string, unknown> = Record<string, unknown>,\n TServer extends { id: Id } = { id: Id },\n>(\n plugin: S3ClientPlugin<Id, TMethods, TServer>,\n): S3ClientPlugin<Id, TMethods, TServer> {\n return plugin;\n}\n","/**\n * Build a plugin HTTP path under `basePath`.\n * Server endpoints and client `getActions` share this so URLs never diverge.\n *\n * @example\n * pluginPath(\"db\", \"objects\") // \"/db/objects\"\n */\nexport function pluginPath(pluginId: string, path: string): string {\n return `/${pluginId}/${path.replace(/^\\/+/, \"\")}`;\n}\n","import type { BetterFetch } from \"@better-fetch/fetch\";\n\n/**\n * Shared `$fetch` for core routes and client plugins.\n * Always created with `throw: true` and `errorSchema` (`s3FetchErrorSchema`) —\n * non-OK JSON becomes {@link DimahS3Error} via `onError`.\n */\nexport type S3Fetch = BetterFetch<{ throw: true }>;\n\n/**\n * Optional fetch configuration for {@link createS3Client}.\n * Applied to core routes and every client plugin sharing the same `$fetch`.\n */\nexport type S3ClientFetchOptions = {\n /** Defaults to global `fetch` — override for SSR, tests, or logging. */\n fetch?: typeof fetch;\n /** e.g. `\"include\"` to send cookies cross-origin. */\n credentials?: RequestCredentials;\n /**\n * Static headers or a (possibly async) factory called per request —\n * useful for Authorization tokens.\n */\n headers?: HeadersInit | (() => HeadersInit | Promise<HeadersInit>);\n};\n\n/**\n * Browser / isomorphic client plugin — mirrors server `DimahS3Plugin`\n * (literal `id` + methods flattened onto the `createS3Client` result).\n *\n * @typeParam Id — unique plugin id; becomes `api[id]`.\n * @typeParam TMethods — methods returned by {@link S3ClientPlugin.getActions}.\n * @typeParam TServer — matching server plugin; `$InferServerPlugin` must share `id`.\n */\nexport type S3ClientPlugin<\n Id extends string = string,\n TMethods extends Record<string, unknown> = Record<string, unknown>,\n TServer extends { id: string } = { id: Id },\n> = {\n id: Id;\n /**\n * Type-only pointer at the matching server plugin (`ReturnType<typeof db>`).\n * Constrains `id` to match the server plugin's `id`.\n */\n $InferServerPlugin?: TServer & { id: Id };\n /** Build typed methods that call plugin endpoints via the shared `$fetch`. */\n getActions: ($fetch: S3Fetch) => TMethods;\n};\n\n/** Map client plugin ids → their method bags. */\nexport type ClientPluginMethodsMap<P extends readonly S3ClientPlugin[]> = {\n [K in P[number] as K[\"id\"]]: K extends S3ClientPlugin<string, infer M>\n ? M\n : never;\n};\n\n/** Keys reserved on the `createS3Client` result — client plugins may not use these as ids. */\nexport const RESERVED_CLIENT_KEYS = [\n \"upload\",\n \"confirm\",\n \"download\",\n \"delete\",\n \"multipart\",\n \"$ERROR_CODES\",\n \"$fetch\",\n \"$Infer\",\n \"Provider\",\n \"useApi\",\n] as const;\n\nexport type ReservedClientKey = (typeof RESERVED_CLIENT_KEYS)[number];\n","import type {\n DeleteResponse,\n MultipartAbortResponse,\n MultipartCompleteResponse,\n MultipartInitResponse,\n MultipartListPartsResponse,\n MultipartPartResponse,\n PresignResponse,\n S3Api,\n UploadConfirmResponse,\n UploadPresignResponse,\n} from \"./types\";\nimport { sanitizeFileName } from \"./helpers/sanitize-file-name\";\nimport { S3_ERROR_CODES } from \"./error\";\nimport {\n createS3Fetch,\n RESERVED_CLIENT_KEYS,\n type ClientPluginMethodsMap,\n type S3ClientFetchOptions,\n type S3ClientPlugin,\n type S3Fetch,\n} from \"./plugin\";\nimport {\n normalizeS3ApiBasePath,\n S3_API_BASE_PATH,\n S3_API_ROUTES,\n} from \"./routes\";\n\n/** Options for {@link createS3Client}. */\nexport type CreateS3ClientOptions<\n P extends readonly S3ClientPlugin[] = readonly S3ClientPlugin[],\n> = {\n /** API path prefix — must match server `basePath`. @default \"/api/s3\" */\n basePath?: string;\n /**\n * Absolute client origin + path (e.g. `https://api.example.com/api/s3`).\n * Wins over {@link basePath} when both are set.\n */\n baseURL?: string;\n /** Client plugins (e.g. `dbClient()` from `@dimah-s3/db/client`). */\n plugins?: P;\n} & S3ClientFetchOptions;\n\n/** Strip server-only `headers` before sending over HTTP. */\nfunction withoutHeaders<T extends { headers?: HeadersInit }>(\n value: T,\n): Omit<T, \"headers\"> {\n const { headers: _headers, ...rest } = value;\n return rest;\n}\n\nfunction createCoreApi($fetch: S3Fetch): S3Api {\n return {\n upload(payload) {\n return $fetch<UploadPresignResponse>(S3_API_ROUTES.upload, {\n method: \"POST\",\n body: withoutHeaders(payload),\n });\n },\n\n confirm(payload) {\n return $fetch<UploadConfirmResponse>(S3_API_ROUTES.uploadConfirm, {\n method: \"POST\",\n body: withoutHeaders(payload),\n });\n },\n\n download(key, options?) {\n const { fileName, bucket, expiresIn } = options ?? {};\n return $fetch<PresignResponse>(S3_API_ROUTES.download, {\n method: \"GET\",\n query: {\n key,\n fileName: fileName ? sanitizeFileName(fileName) : undefined,\n bucket,\n expiresIn,\n },\n });\n },\n\n delete(key, options?) {\n const { bucket } = options ?? {};\n return $fetch<DeleteResponse>(S3_API_ROUTES.delete, {\n method: \"DELETE\",\n query: { key, bucket },\n });\n },\n\n multipart: {\n init(payload) {\n return $fetch<MultipartInitResponse>(S3_API_ROUTES.multipartInit, {\n method: \"POST\",\n body: withoutHeaders(payload),\n });\n },\n\n signPart(payload) {\n return $fetch<MultipartPartResponse>(S3_API_ROUTES.multipartPart, {\n method: \"POST\",\n body: withoutHeaders(payload),\n });\n },\n\n listParts(payload) {\n const { key, uploadId, bucket } = withoutHeaders(payload);\n return $fetch<MultipartListPartsResponse>(\n S3_API_ROUTES.multipartListParts,\n { method: \"GET\", query: { key, uploadId, bucket } },\n );\n },\n\n complete(payload) {\n return $fetch<MultipartCompleteResponse>(\n S3_API_ROUTES.multipartComplete,\n {\n method: \"POST\",\n body: withoutHeaders(payload),\n },\n );\n },\n\n abort(payload) {\n return $fetch<MultipartAbortResponse>(S3_API_ROUTES.multipartAbort, {\n method: \"POST\",\n body: withoutHeaders(payload),\n });\n },\n },\n };\n}\n\n/** Browser client returned by {@link createS3Client}. */\nexport type CreateS3ClientResult<P extends readonly S3ClientPlugin[] = []> =\n S3Api &\n ClientPluginMethodsMap<P> & {\n $ERROR_CODES: typeof S3_ERROR_CODES;\n $fetch: S3Fetch;\n $Infer: { plugins: P };\n };\n\n/**\n * Browser (or isomorphic) client for the dimah-s3 HTTP API.\n *\n * For React apps prefer `createS3Client` from `@dimah-s3/react` — same options,\n * plus a bound `Provider` / typed `useApi` on the client object.\n *\n * ```ts\n * import { createS3Client } from \"@dimah-s3/core\";\n * import { dbClient } from \"@dimah-s3/db/client\";\n *\n * export const api = createS3Client({\n * basePath: \"/api/s3\",\n * plugins: [dbClient()],\n * });\n *\n * await api.db.listObjects();\n * ```\n */\nexport function createS3Client<const P extends readonly S3ClientPlugin[] = []>(\n options?: CreateS3ClientOptions<P>,\n): CreateS3ClientResult<P> {\n const { basePath, baseURL, plugins, ...fetchOptions } = options ?? {};\n const base = normalizeS3ApiBasePath(baseURL ?? basePath ?? S3_API_BASE_PATH);\n const $fetch = createS3Fetch(base, fetchOptions);\n\n const api = createCoreApi($fetch);\n\n const pluginMethods: Record<string, unknown> = {};\n for (const plugin of plugins ?? []) {\n if ((RESERVED_CLIENT_KEYS as readonly string[]).includes(plugin.id)) {\n throw new Error(\n `Client plugin id \"${plugin.id}\" is reserved on the S3 client.`,\n );\n }\n if (plugin.id in pluginMethods) {\n throw new Error(`Duplicate client plugin id \"${plugin.id}\".`);\n }\n pluginMethods[plugin.id] = plugin.getActions($fetch);\n }\n\n return {\n ...api,\n ...pluginMethods,\n $ERROR_CODES: S3_ERROR_CODES,\n $fetch,\n $Infer: {} as CreateS3ClientResult<P>[\"$Infer\"],\n } as CreateS3ClientResult<P>;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/helpers/validate-file.ts","../src/helpers/build-object-key.ts","../src/helpers/get-file-extension.ts","../src/helpers/parse-file-name.ts","../src/helpers/format-file-size.ts","../src/helpers/build-content-disposition.ts","../src/helpers/sanitize-file-name.ts","../src/helpers/default-object-key.ts","../src/helpers/truncate-file-name.ts","../src/schema/shared.ts","../src/schema/upload.ts","../src/schema/download.ts","../src/schema/delete.ts","../src/schema/multipart.ts","../src/schema/error.ts","../src/error-codes.ts","../src/error.ts","../src/routes.ts","../src/plugin/create-s3-fetch.ts","../src/plugin/define-client-plugin.ts","../src/plugin/plugin-path.ts","../src/plugin/types.ts","../src/create-s3-client.ts"],"names":["z"],"mappings":";;;;;AAiBO,SAAS,YAAA,CACd,MACA,OAAA,EAC0B;AAC1B,EAAA,IAAI,OAAA,CAAQ,QAAQ,MAAA,EAAQ;AAC1B,IAAA,MAAM,OAAA,GAAU,OAAA,CAAQ,MAAA,CAAO,IAAA,CAAK,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e;AAC9B,MAAA,MAAM,IAAI,KAAA,CAAM,CAAA,4BAAA,EAA+B,MAAA,CAAO,EAAE,CAAA,EAAA,CAAI,CAAA;AAAA,IAC9D;AACA,IAAA,aAAA,CAAc,MAAA,CAAO,EAAE,CAAA,GAAI,MAAA,CAAO,WAAW,MAAM,CAAA;AAAA,EACrD;AAEA,EAAA,OAAO;AAAA,IACL,GAAG,GAAA;AAAA,IACH,GAAG,aAAA;AAAA,IACH,YAAA,EAAc,cAAA;AAAA,IACd,MAAA;AAAA,IACA,QAAQ;AAAC,GACX;AACF","file":"index.js","sourcesContent":["/** Machine-readable codes for client-side file validation failures. */\nexport type ValidateFileErrorCode =\n \"FILE_TYPE_NOT_ALLOWED\" | \"FILE_EMPTY\" | \"FILE_TOO_LARGE\";\n\n/** Result of {@link validateFile} when the file fails a check. */\nexport type ValidateFileError = {\n code: ValidateFileErrorCode;\n /** English fallback message (localize via Fuma when a translator is available). */\n message: string;\n /** Interpolation params for i18n (e.g. `{ type }`, `{ size }`). */\n params?: Record<string, string | number>;\n};\n\n/**\n * Client-side accept / size / empty checks before starting an upload.\n * Returns `null` when the file is valid.\n */\nexport function validateFile(\n file: File,\n options: { accept?: string[]; maxFileSize?: number },\n): ValidateFileError | null {\n if (options.accept?.length) {\n const allowed = options.accept.some((type) => {\n if (type.startsWith(\".\")) {\n return file.name.toLowerCase().endsWith(type.toLowerCase());\n }\n if (type.endsWith(\"/*\")) {\n return file.type.startsWith(type.replace(\"/*\", \"/\"));\n }\n return file.type === type;\n });\n if (!allowed) {\n const ext = file.name.includes(\".\") ? file.name.split(\".\").pop() : null;\n const type = ext ? `.${ext}` : file.type || \"unknown\";\n return {\n code: \"FILE_TYPE_NOT_ALLOWED\",\n message: `File type \"${type}\" is not allowed`,\n params: { type },\n };\n }\n }\n\n if (file.size === 0) {\n return {\n code: \"FILE_EMPTY\",\n message: \"File is empty\",\n };\n }\n\n if (options.maxFileSize && file.size > options.maxFileSize) {\n const maxMB = (options.maxFileSize / (1024 * 1024)).toFixed(1);\n return {\n code: \"FILE_TOO_LARGE\",\n message: `File size exceeds ${maxMB} MB limit`,\n params: { size: `${maxMB} MB` },\n };\n }\n\n return null;\n}\n","export function buildObjectKey(...parts: string[]): string {\n return parts\n .map((p) => p.replace(/^\\/+|\\/+$/g, \"\"))\n .filter(Boolean)\n .join(\"/\");\n}\n","export function getFileExtension(fileName: string): string {\n const dotIndex = fileName.lastIndexOf(\".\");\n if (dotIndex < 1) return \"\";\n return fileName.slice(dotIndex + 1).toLowerCase();\n}\n","export function parseFileName(\n contentDisposition: string | null | undefined,\n): string | undefined {\n if (!contentDisposition) return undefined;\n\n const utf8Match = contentDisposition.match(/filename\\*=UTF-8''([^;,\\s]+)/i);\n if (utf8Match) {\n try {\n return decodeURIComponent(utf8Match[1]);\n } catch {\n /* ignore malformed encoding */\n }\n }\n\n const asciiMatch = contentDisposition.match(/filename=\"([^\"]*)\"/i);\n return asciiMatch?.[1];\n}\n","export function formatFileSize(bytes: number): string {\n if (bytes === 0) return \"0 B\";\n const units = [\"B\", \"KB\", \"MB\", \"GB\", \"TB\"];\n const i = Math.floor(Math.log(bytes) / Math.log(1024));\n const size = bytes / Math.pow(1024, i);\n return `${size.toFixed(i === 0 ? 0 : 1)} ${units[i]}`;\n}\n","/**\n * Builds a RFC 6266 `Content-Disposition` value for a file attachment.\n *\n * Includes both the ASCII-safe `filename` fallback and the RFC 5987\n * `filename*` parameter for full Unicode support.\n */\nexport function buildContentDisposition(fileName: string): string {\n const ascii = fileName.replace(/[^\\x20-\\x7E]/g, \"_\").replace(/[\"\\\\]/g, \"_\");\n const encoded = encodeURIComponent(fileName);\n return `attachment; filename=\"${ascii}\"; filename*=UTF-8''${encoded}`;\n}\n","/** Sanitizes a file name for safe use in URL query parameters. */\nexport function sanitizeFileName(fileName: string): string {\n return fileName.replace(/[\"\\\\\\r\\n]/g, \"_\");\n}\n","import { sanitizeFileName } from \"./sanitize-file-name\";\n\n/**\n * Default object key for client uploads: a UUID prefix plus the sanitized\n * file name so two selections never overwrite the same key.\n */\nexport function defaultObjectKey(file: File): string {\n return `${crypto.randomUUID()}/${sanitizeFileName(file.name)}`;\n}\n","/**\n * Truncates a filename while preserving the extension when possible.\n */\nexport function truncateFileName(name: string, maxChars = 48): string {\n if (name.length <= maxChars) return name;\n const dotIndex = name.lastIndexOf(\".\");\n if (dotIndex <= 0) {\n return name.slice(0, maxChars - 1) + \"…\";\n }\n const ext = name.slice(dotIndex);\n const available = maxChars - ext.length - 1;\n if (available <= 0) {\n return name.slice(0, maxChars - 1) + \"…\";\n }\n return name.slice(0, available) + \"… \" + ext;\n}\n","import { z } from \"zod\";\n\n/** Fallback when the client omits `expiresIn`. */\nexport const S3_DEFAULT_EXPIRES_IN = 600;\n\n/** AWS SigV4 presign maximum (7 days), in seconds. */\nexport const S3_MAX_EXPIRES_IN = 604_800;\n\n/** S3 POST object maximum (5 GiB), in bytes. */\nexport const S3_MAX_POST_OBJECT_BYTES = 5 * 1024 * 1024 * 1024;\n\n/** Non-empty trimmed string. */\nexport const trimmedString = z.string().trim().min(1);\n\n/** Optional non-empty trimmed string (empty / missing → omitted). */\nexport const optionalTrimmedString = z.string().trim().min(1).optional();\n\nexport const s3ObjectAclSchema = z.enum([\"private\", \"public-read\"]);\n\nexport const metadataSchema = z.record(z.string(), z.string());\n\n/** Optional body `expiresIn` — positive seconds, capped at {@link S3_MAX_EXPIRES_IN}. */\nexport const optionalExpiresInSchema = z\n .number()\n .positive()\n .max(S3_MAX_EXPIRES_IN)\n .optional();\n\n/** Optional query `expiresIn` — numbers arrive as strings. */\nexport const optionalCoerceExpiresInSchema = z.coerce\n .number()\n .positive()\n .max(S3_MAX_EXPIRES_IN)\n .optional();\n","import { z } from \"zod\";\nimport {\n metadataSchema,\n optionalExpiresInSchema,\n optionalTrimmedString,\n s3ObjectAclSchema,\n trimmedString,\n} from \"./shared\";\n\nexport const uploadBodySchema = z.object({\n key: trimmedString,\n contentType: optionalTrimmedString,\n fileSize: z.number().positive().optional(),\n metadata: metadataSchema.optional(),\n bucket: optionalTrimmedString,\n expiresIn: optionalExpiresInSchema,\n acl: s3ObjectAclSchema.optional(),\n fileName: optionalTrimmedString,\n});\n\nexport const confirmBodySchema = z.object({\n key: trimmedString,\n bucket: optionalTrimmedString,\n});\n","import { z } from \"zod\";\nimport {\n optionalCoerceExpiresInSchema,\n optionalTrimmedString,\n trimmedString,\n} from \"./shared\";\n\n/** Query string — numbers arrive as strings. */\nexport const downloadQuerySchema = z.object({\n key: trimmedString,\n bucket: optionalTrimmedString,\n fileName: optionalTrimmedString,\n expiresIn: optionalCoerceExpiresInSchema,\n});\n","import { z } from \"zod\";\nimport { optionalTrimmedString, trimmedString } from \"./shared\";\n\nexport const deleteQuerySchema = z.object({\n key: trimmedString,\n bucket: optionalTrimmedString,\n});\n","import { z } from \"zod\";\nimport { uploadBodySchema } from \"./upload\";\nimport {\n optionalExpiresInSchema,\n optionalTrimmedString,\n trimmedString,\n} from \"./shared\";\n\n/** Same as upload, without `expiresIn` (init does not presign). */\nexport const multipartInitBodySchema = uploadBodySchema.omit({\n expiresIn: true,\n});\n\nexport const multipartSignPartBodySchema = z.object({\n key: trimmedString,\n uploadId: trimmedString,\n partNumber: z.number().int().positive(),\n partSize: z.number().positive().optional(),\n bucket: optionalTrimmedString,\n expiresIn: optionalExpiresInSchema,\n});\n\nexport const multipartListPartsQuerySchema = z.object({\n key: trimmedString,\n uploadId: trimmedString,\n bucket: optionalTrimmedString,\n});\n\nexport const multipartCompleteBodySchema = z.object({\n key: trimmedString,\n uploadId: trimmedString,\n parts: z.array(z.object({ partNumber: z.number().int().positive() })).min(1),\n bucket: optionalTrimmedString,\n});\n\nexport const multipartAbortBodySchema = z.object({\n key: trimmedString,\n uploadId: trimmedString,\n bucket: optionalTrimmedString,\n});\n","import { z } from \"zod\";\n\n/** `params` bag on API error JSON. */\nexport const s3ErrorParamsSchema = z.record(\n z.string(),\n z.union([z.string(), z.number()]),\n);\n\n/**\n * better-fetch `errorSchema` — same `{ message, code?, params? }` body\n * better-call serializes from `DimahS3Error`.\n */\nexport const s3FetchErrorSchema = z.object({\n message: z.string(),\n code: z.string().optional(),\n params: s3ErrorParamsSchema.optional(),\n});\n\nexport type S3FetchError = z.infer<typeof s3FetchErrorSchema>;\n","/**\n * Pair each stable API `code` with its English `message`.\n * Same shape as Better Auth `defineErrorCodes`.\n */\nexport function defineErrorCodes<const T extends Record<string, string>>(\n messages: T,\n): { readonly [K in keyof T]: { readonly code: K; readonly message: T[K] } } {\n const codes = {} as {\n [K in keyof T]: { readonly code: K; readonly message: T[K] };\n };\n for (const code of Object.keys(messages) as (keyof T)[]) {\n codes[code] = { code, message: messages[code] };\n }\n return codes;\n}\n\n/**\n * Domain error catalog. Zod failures share {@link S3_ERROR_CODES.VALIDATION_ERROR};\n * HTTP 404 for unknown routes uses {@link S3_ERROR_CODES.NOT_FOUND}.\n */\nexport const S3_ERROR_CODES = defineErrorCodes({\n NOT_FOUND: \"Not Found\",\n UNAUTHORIZED: \"Unauthorized\",\n FORBIDDEN: \"Forbidden\",\n CONFLICT: \"Conflict\",\n INTERNAL_ERROR: \"Internal server error\",\n OBJECT_NOT_FOUND: \"Object not found\",\n FEATURE_DISABLED: \"{feature} is disabled\",\n INVALID_KEY: \"Object key is invalid\",\n INVALID_BUCKET: \"Bucket is not allowed\",\n S3_NETWORK_ERROR:\n \"S3 endpoint unreachable ({code}): check your endpoint URL and network connectivity\",\n FILE_SIZE_REQUIRED_UPLOAD:\n \"fileSize is required when upload.requireFileSize is enabled\",\n FILE_SIZE_REQUIRED_MULTIPART:\n \"fileSize is required when multipart.requireFileSize is enabled\",\n MULTIPART_PART_MISSING: \"Uploaded part {partNumber} was not found\",\n PAYLOAD_TOO_LARGE: \"Payload too large\",\n VALIDATION_ERROR: \"Validation Error\",\n});\n\nexport type S3ErrorCode = keyof typeof S3_ERROR_CODES;\n","import { APIError } from \"better-call/error\";\nimport { type S3ErrorCode } from \"./error-codes\";\n\nexport {\n defineErrorCodes,\n S3_ERROR_CODES,\n type S3ErrorCode,\n} from \"./error-codes\";\n\nexport type DimahS3ErrorParams = Record<string, string | number>;\n\nexport type DimahS3ErrorStatus = NonNullable<\n ConstructorParameters<typeof APIError>[0]\n>;\n\nexport type DimahS3ErrorBody = {\n message?: string;\n code?: string;\n cause?: unknown;\n params?: DimahS3ErrorParams;\n} & Record<string, unknown>;\n\ntype RawError = {\n code: string;\n message: string;\n params?: DimahS3ErrorParams;\n};\n\n/**\n * Typed API error. Same constructor as better-call {@link APIError}\n * (`status`, `body`) so `ctx.error(...)` and `DimahS3Error.from(...)` share\n * a shape. HTTP serializes `{ message, code?, params? }` via native `toResponse`.\n */\nexport class DimahS3Error extends APIError {\n constructor(\n status: DimahS3ErrorStatus = \"BAD_REQUEST\",\n body?: DimahS3ErrorBody,\n headers?: HeadersInit,\n ) {\n const { cause, ...rest } = body ?? {};\n super(status, Object.keys(rest).length > 0 ? rest : undefined, headers);\n this.name = \"DimahS3Error\";\n if (cause !== undefined) {\n this.cause = cause;\n }\n }\n\n get code(): string | undefined {\n return this.body?.code;\n }\n\n get params(): DimahS3ErrorParams | undefined {\n return this.body?.params as DimahS3ErrorParams | undefined;\n }\n\n /** Throw a catalog (or custom) `{ code, message }` with an HTTP status. */\n static from(status: DimahS3ErrorStatus, error: RawError): DimahS3Error {\n return new DimahS3Error(status, {\n message: error.message,\n code: error.code,\n ...(error.params !== undefined ? { params: error.params } : {}),\n });\n }\n\n static fromStatus(\n status: DimahS3ErrorStatus,\n body?: DimahS3ErrorBody,\n ): DimahS3Error {\n return new DimahS3Error(status, body);\n }\n}\n\n/** True for {@link DimahS3Error} and better-call `APIError` (including duck-typed copies). */\nexport function isAPIError(error: unknown): error is APIError {\n if (error instanceof APIError) return true;\n const name = (error as { name?: string } | null)?.name;\n return name === \"APIError\" || name === \"DimahS3Error\";\n}\n\nexport function isDimahS3Error(error: unknown): error is DimahS3Error {\n return (\n error instanceof DimahS3Error ||\n (error as { name?: string } | null)?.name === \"DimahS3Error\"\n );\n}\n\n/** True when `error` is a {@link DimahS3Error} with this catalog `code`. */\nexport function isS3ErrorCode<C extends S3ErrorCode>(\n error: unknown,\n code: C,\n): error is DimahS3Error & { code: C } {\n return isDimahS3Error(error) && error.code === code;\n}\n","/** Default mount path for the catch-all route (`app/api/s3/[...s3]/route.ts`). */\nexport const S3_API_BASE_PATH = \"/api/s3\";\n\nexport function normalizeS3ApiBasePath(basePath: string): string {\n return basePath.replace(/\\/$/, \"\");\n}\n\n/** Relative paths under {@link S3_API_BASE_PATH}. Always start with `/`. */\nexport const S3_API_ROUTES = {\n upload: \"/presign/upload\",\n uploadConfirm: \"/presign/upload/confirm\",\n download: \"/presign/download\",\n delete: \"/delete\",\n multipartInit: \"/presign/multipart/init\",\n multipartPart: \"/presign/multipart/part\",\n multipartComplete: \"/presign/multipart/complete\",\n multipartAbort: \"/presign/multipart/abort\",\n multipartListParts: \"/presign/multipart/parts\",\n} as const;\n","import { createFetch } from \"@better-fetch/fetch\";\nimport type { Status } from \"better-call/error\";\nimport { DimahS3Error } from \"@/error\";\nimport { s3FetchErrorSchema } from \"@/schema/error\";\nimport type { S3ClientFetchOptions, S3Fetch } from \"./types\";\n\nasync function resolveHeaders(\n headers: S3ClientFetchOptions[\"headers\"],\n): Promise<HeadersInit | undefined> {\n if (headers == null) return undefined;\n if (typeof headers === \"function\") return headers();\n return headers;\n}\n\nfunction fallbackMessage(error: {\n statusText: string;\n error?: unknown;\n}): string {\n if (typeof error.error === \"string\" && error.error.trim()) {\n return error.error;\n }\n return error.statusText || \"Request failed\";\n}\n\n/**\n * better-fetch `onError` receives the JSON body spread with `status` /\n * `statusText` — not a `BetterFetchError` instance.\n */\nfunction dimahErrorFromFetch(error: {\n status: number;\n statusText: string;\n error?: unknown;\n}): DimahS3Error {\n const status = error.status as Status;\n const parsed = s3FetchErrorSchema.safeParse(error);\n if (parsed.success) {\n const { message, code, params } = parsed.data;\n return new DimahS3Error(status, {\n message,\n ...(code !== undefined ? { code } : {}),\n ...(params !== undefined ? { params } : {}),\n });\n }\n return new DimahS3Error(status, { message: fallbackMessage(error) });\n}\n\n/**\n * Shared `$fetch` for core routes and client plugins.\n * `base` is a normalized API prefix (e.g. `/api/s3`).\n *\n * Non-OK JSON matching {@link s3FetchErrorSchema} throws {@link DimahS3Error}.\n * `throw: true` is the better-fetch flag; `onError` maps onto the same class\n * the server throws so `instanceof DimahS3Error` works in the browser.\n */\nexport function createS3Fetch(\n base: string,\n options?: S3ClientFetchOptions,\n): S3Fetch {\n return createFetch({\n baseURL: base,\n throw: true,\n errorSchema: s3FetchErrorSchema,\n customFetchImpl: options?.fetch,\n credentials: options?.credentials,\n onRequest: async (ctx) => {\n const extra = await resolveHeaders(options?.headers);\n if (!extra) return ctx;\n const headers = new Headers(ctx.headers);\n new Headers(extra).forEach((value, key) => {\n headers.set(key, value);\n });\n return { ...ctx, headers };\n },\n onError: (ctx) => {\n throw dimahErrorFromFetch(ctx.error);\n },\n });\n}\n","import type { S3ClientPlugin } from \"./types\";\n\n/**\n * Identity helper that preserves literal `id` and method types for\n * {@link createS3Client} inference (`api[id]`).\n *\n * `$InferServerPlugin` must share the same `id` as the client plugin.\n *\n * ```ts\n * export function dbClient() {\n * return defineClientPlugin({\n * id: \"db\",\n * $InferServerPlugin: {} as ReturnType<typeof db>,\n * getActions: ($fetch) => ({\n * listObjects: () => $fetch(\"/db/objects\", { method: \"GET\" }),\n * }),\n * });\n * }\n * ```\n */\nexport function defineClientPlugin<\n Id extends string,\n TMethods extends Record<string, unknown> = Record<string, unknown>,\n TServer extends { id: Id } = { id: Id },\n>(\n plugin: S3ClientPlugin<Id, TMethods, TServer>,\n): S3ClientPlugin<Id, TMethods, TServer> {\n return plugin;\n}\n","/**\n * Build a plugin HTTP path under `basePath`.\n * Server endpoints and client `getActions` share this so URLs never diverge.\n *\n * @example\n * pluginPath(\"db\", \"objects\") // \"/db/objects\"\n */\nexport function pluginPath(pluginId: string, path: string): string {\n return `/${pluginId}/${path.replace(/^\\/+/, \"\")}`;\n}\n","import type { BetterFetch } from \"@better-fetch/fetch\";\n\n/**\n * Shared `$fetch` for core routes and client plugins.\n * Always created with `throw: true` and `errorSchema` (`s3FetchErrorSchema`) —\n * non-OK JSON becomes {@link DimahS3Error} via `onError`.\n */\nexport type S3Fetch = BetterFetch<{ throw: true }>;\n\n/**\n * Optional fetch configuration for {@link createS3Client}.\n * Applied to core routes and every client plugin sharing the same `$fetch`.\n */\nexport type S3ClientFetchOptions = {\n /** Defaults to global `fetch` — override for SSR, tests, or logging. */\n fetch?: typeof fetch;\n /** e.g. `\"include\"` to send cookies cross-origin. */\n credentials?: RequestCredentials;\n /**\n * Static headers or a (possibly async) factory called per request —\n * useful for Authorization tokens.\n */\n headers?: HeadersInit | (() => HeadersInit | Promise<HeadersInit>);\n};\n\n/**\n * Browser / isomorphic client plugin — mirrors server `DimahS3Plugin`\n * (literal `id` + methods flattened onto the `createS3Client` result).\n *\n * @typeParam Id — unique plugin id; becomes `api[id]`.\n * @typeParam TMethods — methods returned by {@link S3ClientPlugin.getActions}.\n * @typeParam TServer — matching server plugin; `$InferServerPlugin` must share `id`.\n */\nexport type S3ClientPlugin<\n Id extends string = string,\n TMethods extends Record<string, unknown> = Record<string, unknown>,\n TServer extends { id: string } = { id: Id },\n> = {\n id: Id;\n /**\n * Type-only pointer at the matching server plugin (`ReturnType<typeof db>`).\n * Constrains `id` to match the server plugin's `id`.\n */\n $InferServerPlugin?: TServer & { id: Id };\n /** Build typed methods that call plugin endpoints via the shared `$fetch`. */\n getActions: ($fetch: S3Fetch) => TMethods;\n};\n\n/** Map client plugin ids → their method bags. */\nexport type ClientPluginMethodsMap<P extends readonly S3ClientPlugin[]> = {\n [K in P[number] as K[\"id\"]]: K extends S3ClientPlugin<string, infer M>\n ? M\n : never;\n};\n\n/** Keys reserved on the `createS3Client` result — client plugins may not use these as ids. */\nexport const RESERVED_CLIENT_KEYS = [\n \"upload\",\n \"confirm\",\n \"download\",\n \"delete\",\n \"multipart\",\n \"$ERROR_CODES\",\n \"$fetch\",\n \"$Infer\",\n \"Provider\",\n \"useApi\",\n] as const;\n\nexport type ReservedClientKey = (typeof RESERVED_CLIENT_KEYS)[number];\n","import type {\n DeleteResponse,\n MultipartAbortResponse,\n MultipartCompleteResponse,\n MultipartInitResponse,\n MultipartListPartsResponse,\n MultipartPartResponse,\n PresignResponse,\n S3Api,\n UploadConfirmResponse,\n UploadPresignResponse,\n} from \"./types\";\nimport { sanitizeFileName } from \"./helpers/sanitize-file-name\";\nimport { S3_ERROR_CODES } from \"./error\";\nimport {\n createS3Fetch,\n RESERVED_CLIENT_KEYS,\n type ClientPluginMethodsMap,\n type S3ClientFetchOptions,\n type S3ClientPlugin,\n type S3Fetch,\n} from \"./plugin\";\nimport {\n normalizeS3ApiBasePath,\n S3_API_BASE_PATH,\n S3_API_ROUTES,\n} from \"./routes\";\n\n/** Options for {@link createS3Client}. */\nexport type CreateS3ClientOptions<\n P extends readonly S3ClientPlugin[] = readonly S3ClientPlugin[],\n> = {\n /** API path prefix — must match server `basePath`. @default \"/api/s3\" */\n basePath?: string;\n /**\n * Absolute client origin + path (e.g. `https://api.example.com/api/s3`).\n * Wins over {@link basePath} when both are set.\n */\n baseURL?: string;\n /** Client plugins (e.g. `dbClient()` from `@dimah-s3/db/client`). */\n plugins?: P;\n} & S3ClientFetchOptions;\n\n/** Strip server-only `headers` before sending over HTTP. */\nfunction withoutHeaders<T extends { headers?: HeadersInit }>(\n value: T,\n): Omit<T, \"headers\"> {\n const { headers: _headers, ...rest } = value;\n return rest;\n}\n\nfunction createCoreApi($fetch: S3Fetch): S3Api {\n return {\n upload(payload) {\n return $fetch<UploadPresignResponse>(S3_API_ROUTES.upload, {\n method: \"POST\",\n body: withoutHeaders(payload),\n });\n },\n\n confirm(payload) {\n return $fetch<UploadConfirmResponse>(S3_API_ROUTES.uploadConfirm, {\n method: \"POST\",\n body: withoutHeaders(payload),\n });\n },\n\n download(key, options?) {\n const { fileName, bucket, expiresIn } = options ?? {};\n return $fetch<PresignResponse>(S3_API_ROUTES.download, {\n method: \"GET\",\n query: {\n key,\n fileName: fileName ? sanitizeFileName(fileName) : undefined,\n bucket,\n expiresIn,\n },\n });\n },\n\n delete(key, options?) {\n const { bucket } = options ?? {};\n return $fetch<DeleteResponse>(S3_API_ROUTES.delete, {\n method: \"DELETE\",\n query: { key, bucket },\n });\n },\n\n multipart: {\n init(payload) {\n return $fetch<MultipartInitResponse>(S3_API_ROUTES.multipartInit, {\n method: \"POST\",\n body: withoutHeaders(payload),\n });\n },\n\n signPart(payload) {\n return $fetch<MultipartPartResponse>(S3_API_ROUTES.multipartPart, {\n method: \"POST\",\n body: withoutHeaders(payload),\n });\n },\n\n listParts(payload) {\n const { key, uploadId, bucket } = withoutHeaders(payload);\n return $fetch<MultipartListPartsResponse>(\n S3_API_ROUTES.multipartListParts,\n { method: \"GET\", query: { key, uploadId, bucket } },\n );\n },\n\n complete(payload) {\n return $fetch<MultipartCompleteResponse>(\n S3_API_ROUTES.multipartComplete,\n {\n method: \"POST\",\n body: withoutHeaders(payload),\n },\n );\n },\n\n abort(payload) {\n return $fetch<MultipartAbortResponse>(S3_API_ROUTES.multipartAbort, {\n method: \"POST\",\n body: withoutHeaders(payload),\n });\n },\n },\n };\n}\n\n/** Browser client returned by {@link createS3Client}. */\nexport type CreateS3ClientResult<P extends readonly S3ClientPlugin[] = []> =\n S3Api &\n ClientPluginMethodsMap<P> & {\n $ERROR_CODES: typeof S3_ERROR_CODES;\n $fetch: S3Fetch;\n $Infer: { plugins: P };\n };\n\n/**\n * Browser (or isomorphic) client for the dimah-s3 HTTP API.\n *\n * For React apps prefer `createS3Client` from `@dimah-s3/react` — same options,\n * plus a bound `Provider` / typed `useApi` on the client object.\n *\n * ```ts\n * import { createS3Client } from \"@dimah-s3/core\";\n * import { dbClient } from \"@dimah-s3/db/client\";\n *\n * export const api = createS3Client({\n * basePath: \"/api/s3\",\n * plugins: [dbClient()],\n * });\n *\n * await api.db.listObjects();\n * ```\n */\nexport function createS3Client<const P extends readonly S3ClientPlugin[] = []>(\n options?: CreateS3ClientOptions<P>,\n): CreateS3ClientResult<P> {\n const { basePath, baseURL, plugins, ...fetchOptions } = options ?? {};\n const base = normalizeS3ApiBasePath(baseURL ?? basePath ?? S3_API_BASE_PATH);\n const $fetch = createS3Fetch(base, fetchOptions);\n\n const api = createCoreApi($fetch);\n\n const pluginMethods: Record<string, unknown> = {};\n for (const plugin of plugins ?? []) {\n if ((RESERVED_CLIENT_KEYS as readonly string[]).includes(plugin.id)) {\n throw new Error(\n `Client plugin id \"${plugin.id}\" is reserved on the S3 client.`,\n );\n }\n if (plugin.id in pluginMethods) {\n throw new Error(`Duplicate client plugin id \"${plugin.id}\".`);\n }\n pluginMethods[plugin.id] = plugin.getActions($fetch);\n }\n\n return {\n ...api,\n ...pluginMethods,\n $ERROR_CODES: S3_ERROR_CODES,\n $fetch,\n $Infer: {} as CreateS3ClientResult<P>[\"$Infer\"],\n } as CreateS3ClientResult<P>;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../../src/schema/download.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../../src/schema/download.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,gDAAgD;AAChD,eAAO,MAAM,mBAAmB;;;;;iBAK9B,CAAC"}
|
package/dist/schema/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { metadataSchema, optionalTrimmedString, s3ObjectAclSchema, trimmedString, } from "./shared";
|
|
1
|
+
export { metadataSchema, optionalCoerceExpiresInSchema, optionalExpiresInSchema, optionalTrimmedString, s3ObjectAclSchema, S3_DEFAULT_EXPIRES_IN, S3_MAX_EXPIRES_IN, S3_MAX_POST_OBJECT_BYTES, trimmedString, } from "./shared";
|
|
2
2
|
export { confirmBodySchema, uploadBodySchema } from "./upload";
|
|
3
3
|
export { downloadQuerySchema } from "./download";
|
|
4
4
|
export { deleteQuerySchema } from "./delete";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schema/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,iBAAiB,EACjB,aAAa,GACd,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EACL,wBAAwB,EACxB,2BAA2B,EAC3B,uBAAuB,EACvB,6BAA6B,EAC7B,2BAA2B,GAC5B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAClE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schema/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,6BAA6B,EAC7B,uBAAuB,EACvB,qBAAqB,EACrB,iBAAiB,EACjB,qBAAqB,EACrB,iBAAiB,EACjB,wBAAwB,EACxB,aAAa,GACd,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EACL,wBAAwB,EACxB,2BAA2B,EAC3B,uBAAuB,EACvB,6BAA6B,EAC7B,2BAA2B,GAC5B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAClE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
/** Same as upload, without `expiresIn` (init does not presign). */
|
|
2
3
|
export declare const multipartInitBodySchema: z.ZodObject<{
|
|
3
4
|
key: z.ZodString;
|
|
4
5
|
contentType: z.ZodOptional<z.ZodString>;
|
|
5
6
|
fileSize: z.ZodOptional<z.ZodNumber>;
|
|
6
7
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
7
8
|
bucket: z.ZodOptional<z.ZodString>;
|
|
8
|
-
expiresIn: z.ZodOptional<z.ZodNumber>;
|
|
9
9
|
acl: z.ZodOptional<z.ZodEnum<{
|
|
10
10
|
private: "private";
|
|
11
11
|
"public-read": "public-read";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multipart.d.ts","sourceRoot":"","sources":["../../src/schema/multipart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"multipart.d.ts","sourceRoot":"","sources":["../../src/schema/multipart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQxB,mEAAmE;AACnE,eAAO,MAAM,uBAAuB;;;;;;;;;;;iBAElC,CAAC;AAEH,eAAO,MAAM,2BAA2B;;;;;;;iBAOtC,CAAC;AAEH,eAAO,MAAM,6BAA6B;;;;iBAIxC,CAAC;AAEH,eAAO,MAAM,2BAA2B;;;;;;;iBAKtC,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;iBAInC,CAAC"}
|
package/dist/schema/shared.d.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
/** Fallback when the client omits `expiresIn`. */
|
|
3
|
+
export declare const S3_DEFAULT_EXPIRES_IN = 600;
|
|
4
|
+
/** AWS SigV4 presign maximum (7 days), in seconds. */
|
|
5
|
+
export declare const S3_MAX_EXPIRES_IN = 604800;
|
|
6
|
+
/** S3 POST object maximum (5 GiB), in bytes. */
|
|
7
|
+
export declare const S3_MAX_POST_OBJECT_BYTES: number;
|
|
2
8
|
/** Non-empty trimmed string. */
|
|
3
9
|
export declare const trimmedString: z.ZodString;
|
|
4
10
|
/** Optional non-empty trimmed string (empty / missing → omitted). */
|
|
@@ -8,4 +14,8 @@ export declare const s3ObjectAclSchema: z.ZodEnum<{
|
|
|
8
14
|
"public-read": "public-read";
|
|
9
15
|
}>;
|
|
10
16
|
export declare const metadataSchema: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
17
|
+
/** Optional body `expiresIn` — positive seconds, capped at {@link S3_MAX_EXPIRES_IN}. */
|
|
18
|
+
export declare const optionalExpiresInSchema: z.ZodOptional<z.ZodNumber>;
|
|
19
|
+
/** Optional query `expiresIn` — numbers arrive as strings. */
|
|
20
|
+
export declare const optionalCoerceExpiresInSchema: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
11
21
|
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/schema/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,gCAAgC;AAChC,eAAO,MAAM,aAAa,aAA2B,CAAC;AAEtD,qEAAqE;AACrE,eAAO,MAAM,qBAAqB,4BAAsC,CAAC;AAEzE,eAAO,MAAM,iBAAiB;;;EAAqC,CAAC;AAEpE,eAAO,MAAM,cAAc,uCAAmC,CAAC"}
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/schema/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,kDAAkD;AAClD,eAAO,MAAM,qBAAqB,MAAM,CAAC;AAEzC,sDAAsD;AACtD,eAAO,MAAM,iBAAiB,SAAU,CAAC;AAEzC,gDAAgD;AAChD,eAAO,MAAM,wBAAwB,QAAyB,CAAC;AAE/D,gCAAgC;AAChC,eAAO,MAAM,aAAa,aAA2B,CAAC;AAEtD,qEAAqE;AACrE,eAAO,MAAM,qBAAqB,4BAAsC,CAAC;AAEzE,eAAO,MAAM,iBAAiB;;;EAAqC,CAAC;AAEpE,eAAO,MAAM,cAAc,uCAAmC,CAAC;AAE/D,yFAAyF;AACzF,eAAO,MAAM,uBAAuB,4BAIvB,CAAC;AAEd,8DAA8D;AAC9D,eAAO,MAAM,6BAA6B,4CAI7B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../src/schema/upload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../src/schema/upload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AASxB,eAAO,MAAM,gBAAgB;;;;;;;;;;;;iBAS3B,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;iBAG5B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requests.d.ts","sourceRoot":"","sources":["../../src/types/requests.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"requests.d.ts","sourceRoot":"","sources":["../../src/types/requests.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,iBAAi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AM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAC5C,OAAO,2BAA2B,CACnC,GACC,YAAY,CAAC;AAEf,qDAAqD;AACrD,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAC7C,OAAO,6BAA6B,CACrC,GACC,YAAY,CAAC;AAEf,iFAAiF;AACjF,MAAM,MAAM,yBAAyB,GAAG;IACtC,2BAA2B;IAC3B,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,oDAAoD;AACpD,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAC5C,OAAO,2BAA2B,CACnC,GACC,YAAY,CAAC;AAEf,iDAAiD;AACjD,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,GAC1E,YAAY,CAAC"}
|
|
@@ -25,6 +25,9 @@ export type MultipartCompleteResponse = {
|
|
|
25
25
|
/** Response from {@link S3Api.multipart.abort}. */
|
|
26
26
|
export type MultipartAbortResponse = {
|
|
27
27
|
aborted: boolean;
|
|
28
|
+
bucket: string;
|
|
29
|
+
key: string;
|
|
30
|
+
uploadId: string;
|
|
28
31
|
};
|
|
29
32
|
/** Presigned GET URL for download. */
|
|
30
33
|
export type PresignResponse = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"responses.d.ts","sourceRoot":"","sources":["../../src/types/responses.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,eAAe,EACf,qBAAqB,EACrB,wBAAwB,EACxB,oBAAoB,EACpB,yBAAyB,EACzB,wBAAwB,EACxB,WAAW,EACX,aAAa,EACb,mBAAmB,EACpB,MAAM,YAAY,CAAC;AAEpB,0CAA0C;AAC1C,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,sDAAsD;AAC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0B,CAAC,CAAC;QACzC,QAAQ,EAAE,CACR,OAAO,EAAE,wBAAwB,KAC9B,OAAO,CAAC,yBAAyB,CAAC,CAAC;QACxC,KAAK,EAAE,CAAC,OAAO,EAAE,qBAAqB,KAAK,OAAO,CAAC,sBAAsB,CAAC,CAAC;KAC5E,CAAC;CACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dimah-s3/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.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",
|
|
@@ -41,7 +41,8 @@
|
|
|
41
41
|
"zod": "^4.4.3"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"eslint": "^10.
|
|
44
|
+
"eslint": "^10.9.0",
|
|
45
|
+
"tsc-alias": "^1.9.2",
|
|
45
46
|
"tsup": "^8.5.1",
|
|
46
47
|
"typescript": "7.0.2",
|
|
47
48
|
"vitest": "^4.1.11",
|
|
@@ -52,7 +53,7 @@
|
|
|
52
53
|
"access": "public"
|
|
53
54
|
},
|
|
54
55
|
"scripts": {
|
|
55
|
-
"build": "tsup --config tsup.config.ts && tsc --emitDeclarationOnly -p tsconfig.build.json",
|
|
56
|
+
"build": "tsup --config tsup.config.ts && tsc --emitDeclarationOnly -p tsconfig.build.json && tsc-alias",
|
|
56
57
|
"lint": "eslint",
|
|
57
58
|
"check-types": "tsc --noEmit",
|
|
58
59
|
"test": "vitest run"
|