create-monolayer-app 0.2.2 → 0.3.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/package.json +2 -2
- package/template/app/routes/files.ts +63 -0
- package/template/app/routes.ts +5 -2
- package/template/oxfmt.config.ts +6 -1
- package/template/oxlint.config.ts +3 -8
- package/template/vendor/file-bucket/client.ts +196 -0
- package/template/vendor/file-bucket/errors.ts +26 -0
- package/template/vendor/file-bucket/index.ts +7 -0
- package/template/vendor/file-bucket/multipart.ts +304 -0
- package/template/vendor/file-bucket/protocol.ts +222 -0
- package/template/vendor/file-bucket/react-router.ts +222 -0
- package/template/vendor/file-bucket/server.ts +544 -0
- package/template/vendor/file-bucket/transfers.ts +23 -0
- package/template/vendor/file-bucket/transport.ts +37 -0
- package/template/vendor/file-bucket/types.ts +153 -0
- package/template/vendor/file-bucket/vite.d.ts +7 -0
- package/template/vendor/file-bucket/vite.js +2482 -0
- package/template/vendor/file-bucket/xml.ts +325 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// Modified
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Shared types for FileBucket and browser transfers.
|
|
7
|
+
* This file has zero runtime dependencies — types only.
|
|
8
|
+
*/
|
|
9
|
+
import type { Readable } from "node:stream";
|
|
10
|
+
|
|
11
|
+
// ── Method options ──────────────────────────────────────────────────────────
|
|
12
|
+
|
|
13
|
+
export interface UploadProgress {
|
|
14
|
+
uploadedBytes: number;
|
|
15
|
+
totalBytes?: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface UploadOptions {
|
|
19
|
+
signal?: AbortSignal;
|
|
20
|
+
/** Successfully transferred bytes; retries are not counted twice. */
|
|
21
|
+
onProgress?: (progress: UploadProgress) => void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type FileUploadBody =
|
|
25
|
+
| string
|
|
26
|
+
| Uint8Array
|
|
27
|
+
| Blob
|
|
28
|
+
| Readable
|
|
29
|
+
| ReadableStream<Uint8Array>;
|
|
30
|
+
|
|
31
|
+
export interface PutOptions extends UploadOptions {
|
|
32
|
+
/** MIME type of the file (e.g., `image/png`). */
|
|
33
|
+
contentType?: string;
|
|
34
|
+
/** Custom metadata key-value pairs. */
|
|
35
|
+
metadata?: Record<string, string>;
|
|
36
|
+
/** Cache-Control header value. */
|
|
37
|
+
cacheControl?: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface MultipartUploadOptions extends Pick<
|
|
41
|
+
PutOptions,
|
|
42
|
+
"contentType" | "metadata" | "cacheControl"
|
|
43
|
+
> {
|
|
44
|
+
/** Expected size in bytes. The browser verifies it before uploading. */
|
|
45
|
+
size: number;
|
|
46
|
+
/** Signed URL lifetime in seconds. Defaults to 3600. */
|
|
47
|
+
expiresIn?: number;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface GetUrlOptions {
|
|
51
|
+
/** Override the download response disposition, for example "attachment". */
|
|
52
|
+
contentDisposition?: string;
|
|
53
|
+
/** URL expiration in seconds. Default: 3600. */
|
|
54
|
+
expiresIn?: number;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface PutUrlOptions extends Pick<
|
|
58
|
+
PutOptions,
|
|
59
|
+
"metadata" | "cacheControl"
|
|
60
|
+
> {
|
|
61
|
+
/** URL expiration in seconds. Default: 3600. */
|
|
62
|
+
expiresIn?: number;
|
|
63
|
+
/** Required content type for the upload. */
|
|
64
|
+
contentType?: string;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface ScanOptions {
|
|
68
|
+
/** Only list files whose keys start with this prefix. */
|
|
69
|
+
prefix?: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// ── Return types ────────────────────────────────────────────────────────────
|
|
73
|
+
|
|
74
|
+
export interface FileContent {
|
|
75
|
+
/** The file body as a Buffer. */
|
|
76
|
+
body: Buffer;
|
|
77
|
+
/** MIME type of the file. */
|
|
78
|
+
contentType: string;
|
|
79
|
+
/** Custom metadata key-value pairs. */
|
|
80
|
+
metadata: Record<string, string>;
|
|
81
|
+
/** File size in bytes. */
|
|
82
|
+
size: number;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface FileInfo {
|
|
86
|
+
/** The object key. */
|
|
87
|
+
path: string;
|
|
88
|
+
/** File size in bytes. */
|
|
89
|
+
size: number;
|
|
90
|
+
/** Last modification timestamp. */
|
|
91
|
+
lastModified: Date;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// ── Client handle types ────────────────────────────
|
|
95
|
+
|
|
96
|
+
/** Client-side download handle. Works server-side and serializes via toJSON() for the wire. */
|
|
97
|
+
export interface FileDownloadClient {
|
|
98
|
+
/** Download the file as a Blob (server) or via fetch (client). */
|
|
99
|
+
download: () => Promise<Blob>;
|
|
100
|
+
/** Get the presigned URL. */
|
|
101
|
+
getUrl: () => string;
|
|
102
|
+
/** Transferable serialization — call explicitly when returning route data. */
|
|
103
|
+
toJSON: () => FileDownloadDescriptor;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** Client-side upload handle. Works server-side and serializes via toJSON() for the wire. */
|
|
107
|
+
export interface FileUploadClient {
|
|
108
|
+
/** Upload a file body to the presigned URL. */
|
|
109
|
+
upload: (
|
|
110
|
+
body: Blob | File | ArrayBuffer | Uint8Array,
|
|
111
|
+
options?: UploadOptions
|
|
112
|
+
) => Promise<void>;
|
|
113
|
+
/** Get the presigned URL. */
|
|
114
|
+
getUrl: () => string;
|
|
115
|
+
/** Transferable serialization — call explicitly when returning route data. */
|
|
116
|
+
toJSON: () => FileUploadDescriptor;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// ── Wire descriptor types ───────────────────────────────────────────────────
|
|
120
|
+
|
|
121
|
+
export interface FileDownloadDescriptor {
|
|
122
|
+
readonly __blocks: "file-bucket/download";
|
|
123
|
+
readonly url: string;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export interface FileUploadDescriptor {
|
|
127
|
+
readonly __blocks: "file-bucket/upload";
|
|
128
|
+
readonly url: string;
|
|
129
|
+
readonly contentType?: string;
|
|
130
|
+
readonly cacheControl?: string;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** A single-use multipart upload session, transferable to the browser. */
|
|
134
|
+
export interface FileMultipartUploadClient {
|
|
135
|
+
upload: (
|
|
136
|
+
body: Blob | File | ArrayBuffer | Uint8Array,
|
|
137
|
+
options?: UploadOptions
|
|
138
|
+
) => Promise<void>;
|
|
139
|
+
/** Cancel active work and release the upload session. Safe to repeat. */
|
|
140
|
+
abort: () => Promise<void>;
|
|
141
|
+
toJSON: () => FileMultipartUploadDescriptor;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface FileMultipartUploadDescriptor {
|
|
145
|
+
readonly __blocks: "file-bucket/multipart-upload";
|
|
146
|
+
readonly uploadId: string;
|
|
147
|
+
readonly size: number;
|
|
148
|
+
readonly partSize: number;
|
|
149
|
+
readonly expiresAt: number;
|
|
150
|
+
readonly partUrls: readonly string[];
|
|
151
|
+
readonly completeUrl: string;
|
|
152
|
+
readonly abortUrl: string;
|
|
153
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Plugin } from "vite";
|
|
2
|
+
export interface S3EmulatorOptions {
|
|
3
|
+
/** S3 port. Defaults to 4566; use 0 for an available port. */
|
|
4
|
+
port?: number;
|
|
5
|
+
}
|
|
6
|
+
/** Start the embedded S3 emulator for Vite development. */
|
|
7
|
+
export declare function s3Emulator(options?: S3EmulatorOptions): Plugin;
|