@cloudizero/sdk 0.1.0 → 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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  > Official TypeScript SDK for the **Cloudizero** Zero-Egress Digital Asset Management & Media Delivery Platform.
4
4
 
5
- Seamlessly upload, manage, and deliver media files directly to Cloudflare R2 storage with zero bandwidth egress penalties and instant relational indexing.
5
+ Seamlessly upload, manage, and deliver media files and virtual folders directly to Cloudizero zero-egress storage with zero bandwidth egress penalties and instant relational indexing.
6
6
 
7
7
  ---
8
8
 
@@ -27,19 +27,24 @@ Generate an API Key in your Cloudizero dashboard (`/api-keys`), then initialize
27
27
  ```typescript
28
28
  import { Cloudizero } from "@cloudizero/sdk";
29
29
 
30
- const cz = new Cloudizero({
30
+ // 1. Zero-config (reads CLOUDIZERO_API_KEY from environment, defaults to https://api.cloudizero.com)
31
+ const cz = new Cloudizero();
32
+
33
+ // 2. Or explicit configuration (overriding baseUrl / cdnUrl if needed):
34
+ const czCustom = new Cloudizero({
31
35
  apiKey: process.env.CLOUDIZERO_API_KEY!, // e.g. "cz_live_9f8a..."
32
- baseUrl: "https://cloudizero.wismannur.pro", // your Cloudizero deployment
33
- cdnUrl: "https://cdn-cloudizero.wismannur.pro", // optional public CDN domain
36
+ baseUrl: "https://api.cloudizero.com", // default
37
+ cdnUrl: "https://cdn.cloudizero.com", // default
34
38
  });
35
39
  ```
36
40
 
37
41
  ---
38
42
 
39
- ## 📂 Usage Examples
43
+ ## 📂 File CRUD Operations
40
44
 
41
- ### Direct File Upload (Node.js / Next.js / Express)
45
+ ### 1. Create / Upload File (`upload`)
42
46
 
47
+ #### Direct File Upload (Node.js / Next.js / Express)
43
48
  Upload buffers, byte arrays, or streams directly from your backend services:
44
49
 
45
50
  ```typescript
@@ -50,20 +55,18 @@ const fileBuffer = fs.readFileSync("./avatar.png");
50
55
  const uploaded = await cz.storage.upload({
51
56
  file: fileBuffer,
52
57
  fileName: "avatar.png",
53
- projectId: "ca2454ff-7f1e-421b-b134-4c800f6d58de",
54
- folderId: "profiles", // optional virtual folder
58
+ projectId: "prj_LXAlEW70v24YSc0y",
59
+ folderId: "fld_ARaZjwdPpUqXhDHf", // optional target Folder ID (or omit for root)
55
60
  mimeType: "image/png",
56
61
  });
57
62
 
58
63
  console.log("Uploaded successfully!");
59
- console.log("R2 Key:", uploaded.r2Key);
64
+ console.log("File ID:", uploaded.id);
65
+ console.log("Storage Key:", uploaded.r2Key);
60
66
  console.log("Public URL:", uploaded.url);
61
67
  ```
62
68
 
63
- ---
64
-
65
- ### Browser Upload with Real-time Progress (React / Vue / Vanilla JS)
66
-
69
+ #### Browser Upload with Real-time Progress (React / Vue / Vanilla JS)
67
70
  ```typescript
68
71
  const handleFileInput = async (event: React.ChangeEvent<HTMLInputElement>) => {
69
72
  const file = event.target.files?.[0];
@@ -83,27 +86,111 @@ const handleFileInput = async (event: React.ChangeEvent<HTMLInputElement>) => {
83
86
  };
84
87
  ```
85
88
 
89
+ ### 2. Read File Details (`getFile`)
90
+
91
+ Retrieve file metadata along with a temporary presigned download URL:
92
+
93
+ ```typescript
94
+ const { file, downloadUrl } = await cz.storage.getFile("fil_tsvSl4yYKEOlO4KN");
95
+ console.log("File metadata:", file);
96
+ console.log("Presigned download URL:", downloadUrl);
97
+ ```
98
+
99
+ ### 3. Update File Metadata or Replace Binary (`updateFile` & `replaceFile`)
100
+
101
+ #### Update Metadata (Rename / Move Folder / Trash)
102
+ Renaming a file or moving it to another folder automatically moves the underlying object in storage so the human-readable storage key and CDN URL stay synchronized:
103
+
104
+ ```typescript
105
+ const updated = await cz.storage.updateFile({
106
+ fileId: "fil_tsvSl4yYKEOlO4KN",
107
+ name: "new-avatar-name.png",
108
+ folderId: "fld_ARaZjwdPpUqXhDHf", // or null / "root" to move to project root
109
+ });
110
+
111
+ console.log("Updated Storage Key:", updated.r2Key);
112
+ console.log("Updated CDN URL:", updated.url);
113
+ ```
114
+
115
+ #### Replace File Binary In-Place (`replaceFile`)
116
+ Overwrite an existing file's binary content while preserving its `fileId` (and optionally updating its filename or MIME type):
117
+
118
+ ```typescript
119
+ const newBuffer = fs.readFileSync("./avatar-v2.webp");
120
+
121
+ const replaced = await cz.storage.replaceFile({
122
+ fileId: "fil_tsvSl4yYKEOlO4KN",
123
+ file: newBuffer,
124
+ fileName: "avatar-v2.webp", // optional: omit to keep existing filename & storage key
125
+ mimeType: "image/webp",
126
+ });
127
+
128
+ console.log("Replaced file URL:", replaced.url);
129
+ ```
130
+
131
+ ### 4. Delete File (`deleteFile`)
132
+
133
+ Permanently delete a file from both storage and database:
134
+
135
+ ```typescript
136
+ await cz.storage.deleteFile("fil_tsvSl4yYKEOlO4KN");
137
+ console.log("File permanently removed from storage & DB");
138
+ ```
139
+
86
140
  ---
87
141
 
88
- ### List Project Media & Folders
142
+ ## 📁 Folder CRUD Operations
143
+
144
+ ### 1. Create Folder (`createFolder`)
145
+
146
+ ```typescript
147
+ const folder = await cz.storage.createFolder({
148
+ projectId: "your-project-id",
149
+ name: "Marketing Banners",
150
+ parentId: null, // optional parent folder ID for nested folders
151
+ });
152
+
153
+ console.log("Created folder:", folder.id, folder.path); // e.g. "/marketing-banners"
154
+ ```
155
+
156
+ ### 2. Read & List Folders (`getFolder`, `listFolders`, `listContents`)
89
157
 
90
158
  ```typescript
159
+ // Get a single folder by ID
160
+ const folderInfo = await cz.storage.getFolder("folder-id-here");
161
+
162
+ // List folders in project root (or pass parentId for subfolders)
163
+ const folders = await cz.storage.listFolders({
164
+ projectId: "your-project-id",
165
+ parentId: "root",
166
+ });
167
+
168
+ // List both folders, files, and breadcrumbs in a directory
91
169
  const contents = await cz.storage.listContents({
92
170
  projectId: "your-project-id",
93
- folderId: "profiles", // or omit for root
171
+ folderId: folder.id, // or omit for root
94
172
  });
173
+ ```
174
+
175
+ ### 3. Update Folder (`updateFolder`)
95
176
 
96
- console.log("Folders:", contents.folders);
97
- console.log("Files:", contents.files);
177
+ Rename a folder or move it under a new parent folder. All nested subfolder paths and underlying storage keys for files inside the folder tree are updated automatically:
178
+
179
+ ```typescript
180
+ const updatedFolder = await cz.storage.updateFolder({
181
+ folderId: "folder-id-here",
182
+ name: "Q4 Campaigns",
183
+ parentId: "parent-folder-id", // or null / "root"
184
+ });
98
185
  ```
99
186
 
100
- ---
187
+ ### 4. Delete Folder (`deleteFolder`)
101
188
 
102
- ### Delete Asset Permanently
189
+ Recursively deletes a folder, all its subfolders, and permanently removes all contained files from storage and database:
103
190
 
104
191
  ```typescript
105
- await cz.storage.deleteFile("file-id-here");
106
- console.log("File permanently removed from R2 & DB");
192
+ const result = await cz.storage.deleteFolder("folder-id-here");
193
+ console.log(`Deleted ${result.deletedFoldersCount} folders and ${result.deletedFilesCount} files`);
107
194
  ```
108
195
 
109
196
  ---
@@ -111,10 +198,11 @@ console.log("File permanently removed from R2 & DB");
111
198
  ## 🔒 Security Best Practice
112
199
 
113
200
  * **Secret API Key (`cz_live_...`)**: Keep in server-side environment variables (`process.env.CLOUDIZERO_API_KEY`).
114
- * **Project Restrictions**: When generating an API key, you can restrict it to a specific project to follow the principle of least privilege.
201
+ * **Project Restrictions**: When generating an API key, you can restrict it to specific projects to follow the principle of least privilege.
115
202
 
116
203
  ---
117
204
 
118
205
  ## 📄 License
119
206
 
120
- MIT © [Wisman Nur](https://wismannur.pro)
207
+ MIT © [Cloudizero](https://www.cloudizero.com)
208
+
package/dist/client.d.ts CHANGED
@@ -1,10 +1,15 @@
1
1
  import { CloudizeroConfig } from "./types.js";
2
2
  import { StorageClient } from "./storage.js";
3
+ import { ProjectsClient } from "./projects.js";
3
4
  export declare class Cloudizero {
4
5
  /**
5
6
  * Media Storage & Ingestion methods
6
7
  */
7
8
  readonly storage: StorageClient;
8
- constructor(config: CloudizeroConfig);
9
+ /**
10
+ * Project Management methods
11
+ */
12
+ readonly projects: ProjectsClient;
13
+ constructor(config?: CloudizeroConfig);
9
14
  }
10
15
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,qBAAa,UAAU;IACrB;;OAEG;IACH,SAAgB,OAAO,EAAE,aAAa,CAAC;gBAE3B,MAAM,EAAE,gBAAgB;CAGrC"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,qBAAa,UAAU;IACrB;;OAEG;IACH,SAAgB,OAAO,EAAE,aAAa,CAAC;IAEvC;;OAEG;IACH,SAAgB,QAAQ,EAAE,cAAc,CAAC;gBAE7B,MAAM,GAAE,gBAAqB;CAI1C"}
package/dist/client.js CHANGED
@@ -1,11 +1,17 @@
1
1
  import { StorageClient } from "./storage.js";
2
+ import { ProjectsClient } from "./projects.js";
2
3
  export class Cloudizero {
3
4
  /**
4
5
  * Media Storage & Ingestion methods
5
6
  */
6
7
  storage;
7
- constructor(config) {
8
+ /**
9
+ * Project Management methods
10
+ */
11
+ projects;
12
+ constructor(config = {}) {
8
13
  this.storage = new StorageClient(config);
14
+ this.projects = new ProjectsClient(config);
9
15
  }
10
16
  }
11
17
  //# sourceMappingURL=client.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,MAAM,OAAO,UAAU;IACrB;;OAEG;IACa,OAAO,CAAgB;IAEvC,YAAY,MAAwB;QAClC,IAAI,CAAC,OAAO,GAAG,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC;CACF"}
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,MAAM,OAAO,UAAU;IACrB;;OAEG;IACa,OAAO,CAAgB;IAEvC;;OAEG;IACa,QAAQ,CAAiB;IAEzC,YAAY,SAA2B,EAAE;QACvC,IAAI,CAAC,OAAO,GAAG,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC;QACzC,IAAI,CAAC,QAAQ,GAAG,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC;IAC7C,CAAC;CACF"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export { Cloudizero } from "./client.js";
2
2
  export { StorageClient } from "./storage.js";
3
+ export { ProjectsClient } from "./projects.js";
3
4
  export { CloudizeroError } from "./errors.js";
4
- export type { CloudizeroConfig, UploadOptions, UploadedFile, StorageContents, UploadPayload, } from "./types.js";
5
+ export type { CloudizeroConfig, UploadOptions, UpdateFileOptions, ReplaceFileOptions, UploadedFile, FilePageItem, FilePagesResult, ExtractPdfResult, StorageFolder, CreateFolderOptions, ListFoldersOptions, UpdateFolderOptions, DeleteFolderResult, StorageContents, UploadPayload, Project, CreateProjectOptions, UpdateProjectOptions, DeleteProjectResult, } from "./types.js";
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,YAAY,EACV,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,eAAe,EACf,aAAa,GACd,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,YAAY,EACV,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,OAAO,EACP,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export { Cloudizero } from "./client.js";
2
2
  export { StorageClient } from "./storage.js";
3
+ export { ProjectsClient } from "./projects.js";
3
4
  export { CloudizeroError } from "./errors.js";
4
5
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { CloudizeroConfig, Project, CreateProjectOptions, UpdateProjectOptions, DeleteProjectResult } from "./types.js";
2
+ export declare class ProjectsClient {
3
+ private readonly apiKey;
4
+ private readonly baseUrl;
5
+ constructor(config?: CloudizeroConfig);
6
+ /**
7
+ * [READ] Lists all accessible projects for the authenticated API key.
8
+ * If the API key is scoped to specific projects, only scoped projects are returned.
9
+ */
10
+ list(): Promise<Project[]>;
11
+ /**
12
+ * [CREATE] Creates a new project.
13
+ * Requires an API key with All Projects / Global Access (not scoped to specific projects).
14
+ */
15
+ create(options: CreateProjectOptions): Promise<Project>;
16
+ /**
17
+ * [UPDATE] Updates an existing project's name or description.
18
+ */
19
+ update(projectId: string, options: UpdateProjectOptions): Promise<Project>;
20
+ /**
21
+ * [DELETE] Permanently deletes a project, including all associated files and folders.
22
+ */
23
+ delete(projectId: string): Promise<DeleteProjectResult>;
24
+ }
25
+ //# sourceMappingURL=projects.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projects.d.ts","sourceRoot":"","sources":["../src/projects.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,OAAO,EACP,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,YAAY,CAAC;AAGpB,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;gBAErB,MAAM,GAAE,gBAAqB;IAuBzC;;;OAGG;IACG,IAAI,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAmBhC;;;OAGG;IACG,MAAM,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,OAAO,CAAC;IAsB7D;;OAEG;IACG,MAAM,CACV,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,OAAO,CAAC;IAyBnB;;OAEG;IACG,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAsB9D"}
@@ -0,0 +1,93 @@
1
+ import { CloudizeroError } from "./errors.js";
2
+ export class ProjectsClient {
3
+ apiKey;
4
+ baseUrl;
5
+ constructor(config = {}) {
6
+ const resolvedApiKey = config.apiKey ||
7
+ (typeof process !== "undefined" && process.env?.CLOUDIZERO_API_KEY
8
+ ? process.env.CLOUDIZERO_API_KEY
9
+ : "");
10
+ if (!resolvedApiKey) {
11
+ throw new CloudizeroError("Cloudizero API key is required. Pass it via config { apiKey: 'cz_live_...' } or define CLOUDIZERO_API_KEY in your environment.");
12
+ }
13
+ const resolvedBaseUrl = config.baseUrl ||
14
+ (typeof process !== "undefined" && process.env?.CLOUDIZERO_BASE_URL
15
+ ? process.env.CLOUDIZERO_BASE_URL
16
+ : "https://api.cloudizero.com");
17
+ this.apiKey = resolvedApiKey;
18
+ this.baseUrl = resolvedBaseUrl.replace(/\/+$/, "");
19
+ }
20
+ /**
21
+ * [READ] Lists all accessible projects for the authenticated API key.
22
+ * If the API key is scoped to specific projects, only scoped projects are returned.
23
+ */
24
+ async list() {
25
+ const res = await fetch(`${this.baseUrl}/api/projects`, {
26
+ headers: {
27
+ Authorization: `Bearer ${this.apiKey}`,
28
+ },
29
+ });
30
+ if (!res.ok) {
31
+ const err = await res.json().catch(() => ({}));
32
+ throw new CloudizeroError(err.error || `Failed to list projects (${res.status})`, res.status, err);
33
+ }
34
+ return res.json();
35
+ }
36
+ /**
37
+ * [CREATE] Creates a new project.
38
+ * Requires an API key with All Projects / Global Access (not scoped to specific projects).
39
+ */
40
+ async create(options) {
41
+ const res = await fetch(`${this.baseUrl}/api/projects`, {
42
+ method: "POST",
43
+ headers: {
44
+ "Content-Type": "application/json",
45
+ Authorization: `Bearer ${this.apiKey}`,
46
+ },
47
+ body: JSON.stringify(options),
48
+ });
49
+ if (!res.ok) {
50
+ const err = await res.json().catch(() => ({}));
51
+ throw new CloudizeroError(err.error || `Failed to create project (${res.status})`, res.status, err);
52
+ }
53
+ return res.json();
54
+ }
55
+ /**
56
+ * [UPDATE] Updates an existing project's name or description.
57
+ */
58
+ async update(projectId, options) {
59
+ const res = await fetch(`${this.baseUrl}/api/projects`, {
60
+ method: "PATCH",
61
+ headers: {
62
+ "Content-Type": "application/json",
63
+ Authorization: `Bearer ${this.apiKey}`,
64
+ },
65
+ body: JSON.stringify({
66
+ projectId,
67
+ ...options,
68
+ }),
69
+ });
70
+ if (!res.ok) {
71
+ const err = await res.json().catch(() => ({}));
72
+ throw new CloudizeroError(err.error || `Failed to update project (${res.status})`, res.status, err);
73
+ }
74
+ return res.json();
75
+ }
76
+ /**
77
+ * [DELETE] Permanently deletes a project, including all associated files and folders.
78
+ */
79
+ async delete(projectId) {
80
+ const res = await fetch(`${this.baseUrl}/api/projects?projectId=${encodeURIComponent(projectId)}`, {
81
+ method: "DELETE",
82
+ headers: {
83
+ Authorization: `Bearer ${this.apiKey}`,
84
+ },
85
+ });
86
+ if (!res.ok) {
87
+ const err = await res.json().catch(() => ({}));
88
+ throw new CloudizeroError(err.error || `Failed to delete project (${res.status})`, res.status, err);
89
+ }
90
+ return res.json();
91
+ }
92
+ }
93
+ //# sourceMappingURL=projects.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projects.js","sourceRoot":"","sources":["../src/projects.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,OAAO,cAAc;IACR,MAAM,CAAS;IACf,OAAO,CAAS;IAEjC,YAAY,SAA2B,EAAE;QACvC,MAAM,cAAc,GAClB,MAAM,CAAC,MAAM;YACb,CAAC,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE,kBAAkB;gBAChE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB;gBAChC,CAAC,CAAC,EAAE,CAAC,CAAC;QAEV,IAAI,CAAC,cAAc,EAAE,CAAC;YACpB,MAAM,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AM,KAAK,CACrB,GAAG,IAAI,CAAC,OAAO,2BAA2B,kBAAkB,CAAC,SAAS,CAAC,EAAE,EACzE;YACE,MAAM,EAAE,QAAQ;YAChB,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,IAAI,CAAC,MAAM,EAAE;aACvC;SACF,CACF,CAAC;QAEF,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;YACZ,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YAC/C,MAAM,IAAI,eAAe,CACvB,GAAG,CAAC,KAAK,IAAI,6BAA6B,GAAG,CAAC,MAAM,GAAG,EACvD,GAAG,CAAC,MAAM,EACV,GAAG,CACJ,CAAC;QACJ,CAAC;QAED,OAAO,GAAG,CAAC,IAAI,EAAE,CAAC;IACpB,CAAC;CACF"}
package/dist/storage.d.ts CHANGED
@@ -1,27 +1,57 @@
1
- import { CloudizeroConfig, UploadOptions, UploadedFile, StorageContents } from "./types.js";
1
+ import { CloudizeroConfig, UploadOptions, UpdateFileOptions, ReplaceFileOptions, UploadedFile, StorageFolder, CreateFolderOptions, ListFoldersOptions, UpdateFolderOptions, DeleteFolderResult, StorageContents, FilePagesResult, ExtractPdfResult } from "./types.js";
2
2
  export declare class StorageClient {
3
3
  private readonly apiKey;
4
4
  private readonly baseUrl;
5
5
  private readonly cdnUrl?;
6
- constructor(config: CloudizeroConfig);
6
+ constructor(config?: CloudizeroConfig);
7
7
  /**
8
- * Uploads a file directly to Cloudflare R2 via presigned PUT URL and records metadata.
8
+ * [CREATE] Uploads a file directly to Cloudizero storage via presigned PUT URL and records metadata.
9
9
  */
10
10
  upload(options: UploadOptions): Promise<UploadedFile>;
11
11
  /**
12
- * Gets file details and generates a presigned private download URL
12
+ * [READ] Gets file details and generates a presigned private download URL
13
13
  */
14
14
  getFile(fileId: string): Promise<{
15
15
  file: UploadedFile;
16
16
  downloadUrl: string;
17
17
  }>;
18
18
  /**
19
- * Deletes a file permanently from Cloudflare R2 and Neon DB
19
+ * [UPDATE] Updates file metadata (rename, move folder, trash toggle) and/or replaces its binary content in storage.
20
+ * When renaming or moving folders, the underlying storage object key is automatically moved to stay in sync.
21
+ */
22
+ updateFile(options: UpdateFileOptions): Promise<UploadedFile>;
23
+ /**
24
+ * [UPDATE - BINARY REPLACE] Replaces the binary content of an existing file while preserving its fileId.
25
+ * Optionally updates the file name, folder, MIME type, or dimensions.
26
+ */
27
+ replaceFile(options: ReplaceFileOptions): Promise<UploadedFile>;
28
+ /**
29
+ * [DELETE] Deletes a file permanently from Cloudizero storage and database
20
30
  */
21
31
  deleteFile(fileId: string): Promise<{
22
32
  success: boolean;
23
33
  message: string;
24
34
  }>;
35
+ /**
36
+ * [CREATE] Creates a new virtual folder within a project
37
+ */
38
+ createFolder(options: CreateFolderOptions): Promise<StorageFolder>;
39
+ /**
40
+ * [READ] Gets a single folder by its ID
41
+ */
42
+ getFolder(folderId: string): Promise<StorageFolder>;
43
+ /**
44
+ * [READ] Lists folders within a project (or inside a specific parent folder)
45
+ */
46
+ listFolders(options: ListFoldersOptions): Promise<StorageFolder[]>;
47
+ /**
48
+ * [UPDATE] Renames or moves a folder, recursively updating paths and storage object keys for all nested files
49
+ */
50
+ updateFolder(options: UpdateFolderOptions): Promise<StorageFolder>;
51
+ /**
52
+ * [DELETE] Deletes a folder and recursively removes all nested subfolders and files from storage and database
53
+ */
54
+ deleteFolder(folderId: string): Promise<DeleteFolderResult>;
25
55
  /**
26
56
  * Lists folders and files in a directory
27
57
  */
@@ -29,6 +59,14 @@ export declare class StorageClient {
29
59
  projectId: string;
30
60
  folderId?: string;
31
61
  }): Promise<StorageContents>;
62
+ /**
63
+ * [DOCUMENT INTELLIGENCE] Retrieves extracted pages, page dimensions, thumbnail URL, and chapters for a document.
64
+ */
65
+ getFilePages(fileId: string): Promise<FilePagesResult>;
66
+ /**
67
+ * [DOCUMENT INTELLIGENCE] Dispatches asynchronous PDF page extraction and thumbnail generation for a PDF file.
68
+ */
69
+ extractPdfPages(fileId: string): Promise<ExtractPdfResult>;
32
70
  private getByteLength;
33
71
  private uploadBinary;
34
72
  }
@@ -1 +1 @@
1
- {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,eAAe,EAChB,MAAM,YAAY,CAAC;AAGpB,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAS;gBAErB,MAAM,EAAE,gBAAgB;IASpC;;OAEG;IACG,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;IAkF3D;;OAEG;IACG,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,YAAY,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC;IAwBnF;;OAEG;IACG,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAoBhF;;OAEG;IACG,YAAY,CAAC,MAAM,EAAE;QACzB,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC,eAAe,CAAC;IA+B5B,OAAO,CAAC,aAAa;YAeP,YAAY;CA+D3B"}
1
+ {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,kBAAkB,EAClB,mBAA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,YAAY,CAAC,MAAM,EAAE;QACzB,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC,eAAe,CAAC;IAoC5B;;OAEG;IACG,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAmC5D;;OAEG;IACG,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAuBhE,OAAO,CAAC,aAAa;YAeP,YAAY;CA+D3B"}
package/dist/storage.js CHANGED
@@ -1,21 +1,57 @@
1
1
  import { CloudizeroError } from "./errors.js";
2
+ const BLOCKED_EXTENSIONS = new Set([
3
+ "exe", "dll", "so", "dylib", "bin", "com", "bat", "cmd", "scr", "vbs",
4
+ "ps1", "apk", "app", "dmg", "pkg", "iso", "msi",
5
+ "sh", "bash", "zsh", "fish",
6
+ "py", "pyc", "js", "mjs", "cjs", "ts", "tsx", "jsx", "php", "phtml", "cgi", "pl", "rb", "lua", "go", "rs", "c", "cpp", "java", "class", "jar",
7
+ "html", "htm", "xhtml", "jsp", "asp", "aspx",
8
+ "env", "pem", "key", "crt", "sql", "db", "sqlite"
9
+ ]);
10
+ function assertValidDamFileName(fileName) {
11
+ if (!fileName)
12
+ return;
13
+ const parts = fileName.toLowerCase().split(".");
14
+ if (parts.length < 2)
15
+ return;
16
+ for (let i = 1; i < parts.length; i++) {
17
+ if (BLOCKED_EXTENSIONS.has(parts[i])) {
18
+ throw new CloudizeroError(`Invalid asset format for file '${fileName}'. Cloudizero DAM only accepts media and document assets. Executable and script files are strictly prohibited.`, 400);
19
+ }
20
+ }
21
+ }
2
22
  export class StorageClient {
3
23
  apiKey;
4
24
  baseUrl;
5
25
  cdnUrl;
6
- constructor(config) {
7
- if (!config.apiKey) {
8
- throw new CloudizeroError("Cloudizero API key is required");
26
+ constructor(config = {}) {
27
+ const resolvedApiKey = config.apiKey ||
28
+ (typeof process !== "undefined" && process.env?.CLOUDIZERO_API_KEY
29
+ ? process.env.CLOUDIZERO_API_KEY
30
+ : "");
31
+ if (!resolvedApiKey) {
32
+ throw new CloudizeroError("Cloudizero API key is required. Pass it via config { apiKey: 'cz_live_...' } or define CLOUDIZERO_API_KEY in your environment.");
9
33
  }
10
- this.apiKey = config.apiKey;
11
- this.baseUrl = (config.baseUrl || "http://localhost:7010").replace(/\/+$/, "");
12
- this.cdnUrl = config.cdnUrl ? config.cdnUrl.replace(/\/+$/, "") : undefined;
34
+ const resolvedBaseUrl = config.baseUrl ||
35
+ (typeof process !== "undefined" && process.env?.CLOUDIZERO_BASE_URL
36
+ ? process.env.CLOUDIZERO_BASE_URL
37
+ : "https://api.cloudizero.com");
38
+ const resolvedCdnUrl = config.cdnUrl ||
39
+ (typeof process !== "undefined" && process.env?.CLOUDIZERO_CDN_URL
40
+ ? process.env.CLOUDIZERO_CDN_URL
41
+ : "https://cdn.cloudizero.com");
42
+ this.apiKey = resolvedApiKey;
43
+ this.baseUrl = resolvedBaseUrl.replace(/\/+$/, "");
44
+ this.cdnUrl = resolvedCdnUrl ? resolvedCdnUrl.replace(/\/+$/, "") : undefined;
13
45
  }
46
+ // ==========================================
47
+ // FILE CRUD OPERATIONS
48
+ // ==========================================
14
49
  /**
15
- * Uploads a file directly to Cloudflare R2 via presigned PUT URL and records metadata.
50
+ * [CREATE] Uploads a file directly to Cloudizero storage via presigned PUT URL and records metadata.
16
51
  */
17
52
  async upload(options) {
18
53
  const { file, fileName, projectId, folderId, mimeType = "application/octet-stream", width, height, onProgress, } = options;
54
+ assertValidDamFileName(fileName);
19
55
  const fileSize = this.getByteLength(file);
20
56
  // 1. Request Presigned Upload Ticket
21
57
  const presignRes = await fetch(`${this.baseUrl}/api/storage/presign`, {
@@ -37,7 +73,7 @@ export class StorageClient {
37
73
  throw new CloudizeroError(err.error || `Presign failed with status ${presignRes.status}`, presignRes.status, err);
38
74
  }
39
75
  const { uploadUrl, r2Key, fileId, finalFileName } = await presignRes.json();
40
- // 2. Direct S3 PUT Upload to Cloudflare R2
76
+ // 2. Direct PUT Upload to Cloudizero Storage
41
77
  await this.uploadBinary(uploadUrl, file, mimeType, onProgress);
42
78
  // 3. Record Metadata in Cloudizero
43
79
  const completeRes = await fetch(`${this.baseUrl}/api/storage/complete`, {
@@ -65,14 +101,17 @@ export class StorageClient {
65
101
  const recordedFile = await completeRes.json();
66
102
  if (this.cdnUrl) {
67
103
  recordedFile.url = `${this.cdnUrl}/${recordedFile.r2Key}`;
104
+ if (recordedFile.thumbnailKey) {
105
+ recordedFile.thumbnailUrl = `${this.cdnUrl}/${recordedFile.thumbnailKey}`;
106
+ }
68
107
  }
69
108
  return recordedFile;
70
109
  }
71
110
  /**
72
- * Gets file details and generates a presigned private download URL
111
+ * [READ] Gets file details and generates a presigned private download URL
73
112
  */
74
113
  async getFile(fileId) {
75
- const res = await fetch(`${this.baseUrl}/api/storage/files?fileId=${fileId}`, {
114
+ const res = await fetch(`${this.baseUrl}/api/storage/files?fileId=${encodeURIComponent(fileId)}`, {
76
115
  headers: {
77
116
  Authorization: `Bearer ${this.apiKey}`,
78
117
  },
@@ -84,14 +123,80 @@ export class StorageClient {
84
123
  const data = await res.json();
85
124
  if (this.cdnUrl && data.file) {
86
125
  data.file.url = `${this.cdnUrl}/${data.file.r2Key}`;
126
+ if (data.file.thumbnailKey) {
127
+ data.file.thumbnailUrl = `${this.cdnUrl}/${data.file.thumbnailKey}`;
128
+ }
87
129
  }
88
130
  return data;
89
131
  }
90
132
  /**
91
- * Deletes a file permanently from Cloudflare R2 and Neon DB
133
+ * [UPDATE] Updates file metadata (rename, move folder, trash toggle) and/or replaces its binary content in storage.
134
+ * When renaming or moving folders, the underlying storage object key is automatically moved to stay in sync.
135
+ */
136
+ async updateFile(options) {
137
+ const { fileId, name, folderId, isTrash, file, mimeType, width, height, onProgress, } = options;
138
+ if (name) {
139
+ assertValidDamFileName(name);
140
+ }
141
+ const isReplacingBinary = file !== undefined;
142
+ const size = isReplacingBinary ? this.getByteLength(file) : undefined;
143
+ const res = await fetch(`${this.baseUrl}/api/storage/files`, {
144
+ method: "PATCH",
145
+ headers: {
146
+ "Content-Type": "application/json",
147
+ Authorization: `Bearer ${this.apiKey}`,
148
+ },
149
+ body: JSON.stringify({
150
+ fileId,
151
+ ...(name !== undefined ? { name } : {}),
152
+ ...(folderId !== undefined
153
+ ? { folderId: folderId && folderId !== "root" ? folderId : null }
154
+ : {}),
155
+ ...(isTrash !== undefined ? { isTrash } : {}),
156
+ ...(mimeType !== undefined ? { mimeType } : {}),
157
+ ...(size !== undefined ? { size } : {}),
158
+ ...(width !== undefined ? { width } : {}),
159
+ ...(height !== undefined ? { height } : {}),
160
+ ...(isReplacingBinary ? { requestReplaceUploadUrl: true } : {}),
161
+ }),
162
+ });
163
+ if (!res.ok) {
164
+ const err = await res.json().catch(() => ({}));
165
+ throw new CloudizeroError(err.error || `Failed to update file (${res.status})`, res.status, err);
166
+ }
167
+ const data = await res.json();
168
+ if (isReplacingBinary && data.uploadUrl) {
169
+ await this.uploadBinary(data.uploadUrl, file, mimeType || data.file.mimeType || "application/octet-stream", onProgress);
170
+ }
171
+ if (this.cdnUrl && data.file) {
172
+ data.file.url = `${this.cdnUrl}/${data.file.r2Key}`;
173
+ if (data.file.thumbnailKey) {
174
+ data.file.thumbnailUrl = `${this.cdnUrl}/${data.file.thumbnailKey}`;
175
+ }
176
+ }
177
+ return data.file;
178
+ }
179
+ /**
180
+ * [UPDATE - BINARY REPLACE] Replaces the binary content of an existing file while preserving its fileId.
181
+ * Optionally updates the file name, folder, MIME type, or dimensions.
182
+ */
183
+ async replaceFile(options) {
184
+ return this.updateFile({
185
+ fileId: options.fileId,
186
+ file: options.file,
187
+ name: options.fileName,
188
+ folderId: options.folderId,
189
+ mimeType: options.mimeType,
190
+ width: options.width,
191
+ height: options.height,
192
+ onProgress: options.onProgress,
193
+ });
194
+ }
195
+ /**
196
+ * [DELETE] Deletes a file permanently from Cloudizero storage and database
92
197
  */
93
198
  async deleteFile(fileId) {
94
- const res = await fetch(`${this.baseUrl}/api/storage/files?fileId=${fileId}`, {
199
+ const res = await fetch(`${this.baseUrl}/api/storage/files?fileId=${encodeURIComponent(fileId)}`, {
95
200
  method: "DELETE",
96
201
  headers: {
97
202
  Authorization: `Bearer ${this.apiKey}`,
@@ -103,12 +208,115 @@ export class StorageClient {
103
208
  }
104
209
  return res.json();
105
210
  }
211
+ // ==========================================
212
+ // FOLDER CRUD OPERATIONS
213
+ // ==========================================
214
+ /**
215
+ * [CREATE] Creates a new virtual folder within a project
216
+ */
217
+ async createFolder(options) {
218
+ const { projectId, name, parentId, path } = options;
219
+ const res = await fetch(`${this.baseUrl}/api/storage/folders`, {
220
+ method: "POST",
221
+ headers: {
222
+ "Content-Type": "application/json",
223
+ Authorization: `Bearer ${this.apiKey}`,
224
+ },
225
+ body: JSON.stringify({
226
+ projectId,
227
+ name,
228
+ parentId: parentId && parentId !== "root" ? parentId : null,
229
+ ...(path ? { path } : {}),
230
+ }),
231
+ });
232
+ if (!res.ok) {
233
+ const err = await res.json().catch(() => ({}));
234
+ throw new CloudizeroError(err.error || `Failed to create folder (${res.status})`, res.status, err);
235
+ }
236
+ return res.json();
237
+ }
238
+ /**
239
+ * [READ] Gets a single folder by its ID
240
+ */
241
+ async getFolder(folderId) {
242
+ const res = await fetch(`${this.baseUrl}/api/storage/folders?folderId=${encodeURIComponent(folderId)}`, {
243
+ headers: {
244
+ Authorization: `Bearer ${this.apiKey}`,
245
+ },
246
+ });
247
+ if (!res.ok) {
248
+ const err = await res.json().catch(() => ({}));
249
+ throw new CloudizeroError(err.error || `Failed to get folder (${res.status})`, res.status, err);
250
+ }
251
+ return res.json();
252
+ }
253
+ /**
254
+ * [READ] Lists folders within a project (or inside a specific parent folder)
255
+ */
256
+ async listFolders(options) {
257
+ const { projectId, parentId = "root" } = options;
258
+ const targetParent = parentId || "root";
259
+ const res = await fetch(`${this.baseUrl}/api/storage/folders?projectId=${encodeURIComponent(projectId)}&parentId=${encodeURIComponent(targetParent)}`, {
260
+ headers: {
261
+ Authorization: `Bearer ${this.apiKey}`,
262
+ },
263
+ });
264
+ if (!res.ok) {
265
+ const err = await res.json().catch(() => ({}));
266
+ throw new CloudizeroError(err.error || `Failed to list folders (${res.status})`, res.status, err);
267
+ }
268
+ return res.json();
269
+ }
270
+ /**
271
+ * [UPDATE] Renames or moves a folder, recursively updating paths and storage object keys for all nested files
272
+ */
273
+ async updateFolder(options) {
274
+ const { folderId, name, parentId } = options;
275
+ const res = await fetch(`${this.baseUrl}/api/storage/folders`, {
276
+ method: "PATCH",
277
+ headers: {
278
+ "Content-Type": "application/json",
279
+ Authorization: `Bearer ${this.apiKey}`,
280
+ },
281
+ body: JSON.stringify({
282
+ folderId,
283
+ ...(name !== undefined ? { name } : {}),
284
+ ...(parentId !== undefined
285
+ ? { parentId: parentId && parentId !== "root" ? parentId : null }
286
+ : {}),
287
+ }),
288
+ });
289
+ if (!res.ok) {
290
+ const err = await res.json().catch(() => ({}));
291
+ throw new CloudizeroError(err.error || `Failed to update folder (${res.status})`, res.status, err);
292
+ }
293
+ return res.json();
294
+ }
295
+ /**
296
+ * [DELETE] Deletes a folder and recursively removes all nested subfolders and files from storage and database
297
+ */
298
+ async deleteFolder(folderId) {
299
+ const res = await fetch(`${this.baseUrl}/api/storage/folders?folderId=${encodeURIComponent(folderId)}`, {
300
+ method: "DELETE",
301
+ headers: {
302
+ Authorization: `Bearer ${this.apiKey}`,
303
+ },
304
+ });
305
+ if (!res.ok) {
306
+ const err = await res.json().catch(() => ({}));
307
+ throw new CloudizeroError(err.error || `Failed to delete folder (${res.status})`, res.status, err);
308
+ }
309
+ return res.json();
310
+ }
311
+ // ==========================================
312
+ // DIRECTORY BROWSING
313
+ // ==========================================
106
314
  /**
107
315
  * Lists folders and files in a directory
108
316
  */
109
317
  async listContents(params) {
110
318
  const { projectId, folderId = "root" } = params;
111
- const res = await fetch(`${this.baseUrl}/api/storage/contents?projectId=${projectId}&folderId=${folderId}`, {
319
+ const res = await fetch(`${this.baseUrl}/api/storage/contents?projectId=${encodeURIComponent(projectId)}&folderId=${encodeURIComponent(folderId)}`, {
112
320
  headers: {
113
321
  Authorization: `Bearer ${this.apiKey}`,
114
322
  },
@@ -122,10 +330,57 @@ export class StorageClient {
122
330
  data.files = data.files.map((f) => ({
123
331
  ...f,
124
332
  url: `${this.cdnUrl}/${f.r2Key}`,
333
+ thumbnailUrl: f.thumbnailKey ? `${this.cdnUrl}/${f.thumbnailKey}` : undefined,
125
334
  }));
126
335
  }
127
336
  return data;
128
337
  }
338
+ // ==========================================
339
+ // DOCUMENT INTELLIGENCE & PDF EXTRACTION
340
+ // ==========================================
341
+ /**
342
+ * [DOCUMENT INTELLIGENCE] Retrieves extracted pages, page dimensions, thumbnail URL, and chapters for a document.
343
+ */
344
+ async getFilePages(fileId) {
345
+ const res = await fetch(`${this.baseUrl}/api/v1/files/${encodeURIComponent(fileId)}/pages`, {
346
+ headers: {
347
+ Authorization: `Bearer ${this.apiKey}`,
348
+ },
349
+ });
350
+ if (!res.ok) {
351
+ const err = await res.json().catch(() => ({}));
352
+ throw new CloudizeroError(err.error || `Failed to get file pages (${res.status})`, res.status, err);
353
+ }
354
+ const data = await res.json();
355
+ if (this.cdnUrl) {
356
+ if (data.thumbnailKey) {
357
+ data.thumbnailUrl = `${this.cdnUrl}/${data.thumbnailKey}`;
358
+ }
359
+ if (data.pages) {
360
+ data.pages = data.pages.map((p) => ({
361
+ ...p,
362
+ url: `${this.cdnUrl}/${p.r2Key}`,
363
+ }));
364
+ }
365
+ }
366
+ return data;
367
+ }
368
+ /**
369
+ * [DOCUMENT INTELLIGENCE] Dispatches asynchronous PDF page extraction and thumbnail generation for a PDF file.
370
+ */
371
+ async extractPdfPages(fileId) {
372
+ const res = await fetch(`${this.baseUrl}/api/storage/files/${encodeURIComponent(fileId)}/extract`, {
373
+ method: "POST",
374
+ headers: {
375
+ Authorization: `Bearer ${this.apiKey}`,
376
+ },
377
+ });
378
+ if (!res.ok) {
379
+ const err = await res.json().catch(() => ({}));
380
+ throw new CloudizeroError(err.error || `Failed to dispatch PDF extraction (${res.status})`, res.status, err);
381
+ }
382
+ return res.json();
383
+ }
129
384
  getByteLength(file) {
130
385
  if (typeof file === "object" && file !== null) {
131
386
  if ("size" in file && typeof file.size === "number") {
@@ -160,10 +415,10 @@ export class StorageClient {
160
415
  resolve();
161
416
  }
162
417
  else {
163
- reject(new CloudizeroError(`R2 upload failed with HTTP status ${xhr.status}`, xhr.status));
418
+ reject(new CloudizeroError(`Direct storage upload failed with HTTP status ${xhr.status}`, xhr.status));
164
419
  }
165
420
  };
166
- xhr.onerror = () => reject(new CloudizeroError("Network error occurred during direct R2 upload"));
421
+ xhr.onerror = () => reject(new CloudizeroError("Network error occurred during direct storage upload"));
167
422
  xhr.send(file);
168
423
  });
169
424
  }
@@ -176,7 +431,7 @@ export class StorageClient {
176
431
  body: file,
177
432
  });
178
433
  if (!res.ok) {
179
- throw new CloudizeroError(`R2 upload failed with HTTP status ${res.status}`, res.status);
434
+ throw new CloudizeroError(`Direct storage upload failed with HTTP status ${res.status}`, res.status);
180
435
  }
181
436
  if (onProgress) {
182
437
  const size = this.getByteLength(file);
@@ -1 +1 @@
1
- {"version":3,"file":"storage.js","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,OAAO,aAAa;IACP,MAAM,CAAS;IACf,OAAO,CAAS;IAChB,MAAM,CAAU;IAEjC,YAAY,MAAwB;QAClC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;YACnB,MAAM,IAAI,eAAe,CAAC,gCAAgC,CAAC,CAAC;QAC9D,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,OAAO,GAAG,CAAC,MAAM,CAAC,OAAO,IAAI,uBAAuB,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE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;IACH,CAAC;CACF"}
package/dist/types.d.ts CHANGED
@@ -1,16 +1,17 @@
1
1
  export interface CloudizeroConfig {
2
2
  /**
3
- * Cloudizero API Key starting with `cz_live_`
3
+ * Cloudizero API Key starting with `cz_live_`.
4
+ * If omitted, falls back to `process.env.CLOUDIZERO_API_KEY`.
4
5
  */
5
- apiKey: string;
6
+ apiKey?: string;
6
7
  /**
7
- * The base URL of your Cloudizero deployment.
8
- * Defaults to `https://cloudizero.com` (or current app URL).
8
+ * The base URL of your Cloudizero API deployment.
9
+ * Defaults to `process.env.CLOUDIZERO_BASE_URL` or `https://api.cloudizero.com`.
9
10
  */
10
11
  baseUrl?: string;
11
12
  /**
12
- * The public CDN URL for serving assets (e.g. `https://cdn.wismannur.pro`).
13
- * Optional; if provided, will be attached to uploaded file results as `url`.
13
+ * The public CDN URL for serving assets (e.g. `https://cdn.cloudizero.com`).
14
+ * Defaults to `process.env.CLOUDIZERO_CDN_URL` or `https://cdn.cloudizero.com`.
14
15
  */
15
16
  cdnUrl?: string;
16
17
  }
@@ -28,11 +29,11 @@ export interface UploadOptions {
28
29
  */
29
30
  fileName: string;
30
31
  /**
31
- * The target Project ID
32
+ * The target Project ID (e.g. `prj_...`)
32
33
  */
33
34
  projectId: string;
34
35
  /**
35
- * Optional target Folder ID within the project
36
+ * Optional target Folder ID within the project (e.g. `fld_...`)
36
37
  */
37
38
  folderId?: string | null;
38
39
  /**
@@ -57,6 +58,89 @@ export interface UploadOptions {
57
58
  percent: number;
58
59
  }) => void;
59
60
  }
61
+ export interface UpdateFileOptions {
62
+ /**
63
+ * The ID of the file to update (e.g. `fil_...`)
64
+ */
65
+ fileId: string;
66
+ /**
67
+ * Optional new file name (e.g. `hero-banner.webp`).
68
+ * Automatically moves/renames the underlying object in storage.
69
+ */
70
+ name?: string;
71
+ /**
72
+ * Optional target Folder ID to move the file into (e.g. `fld_...`, or `null` / `"root"` moves to root).
73
+ * Automatically moves the underlying object in storage.
74
+ */
75
+ folderId?: string | null;
76
+ /**
77
+ * Optional soft-delete trash status
78
+ */
79
+ isTrash?: boolean;
80
+ /**
81
+ * Optional binary payload to replace the file content in-place.
82
+ * If provided, the SDK will upload the new binary to storage and update metadata.
83
+ */
84
+ file?: UploadPayload;
85
+ /**
86
+ * Optional MIME type when replacing file content
87
+ */
88
+ mimeType?: string;
89
+ /**
90
+ * Optional updated image width
91
+ */
92
+ width?: number | null;
93
+ /**
94
+ * Optional updated image height
95
+ */
96
+ height?: number | null;
97
+ /**
98
+ * Upload progress callback (used when `file` binary payload is provided)
99
+ */
100
+ onProgress?: (progress: {
101
+ loaded: number;
102
+ total: number;
103
+ percent: number;
104
+ }) => void;
105
+ }
106
+ export interface ReplaceFileOptions {
107
+ /**
108
+ * The ID of the existing file to replace (e.g. `fil_...`)
109
+ */
110
+ fileId: string;
111
+ /**
112
+ * New binary file payload
113
+ */
114
+ file: UploadPayload;
115
+ /**
116
+ * Optional new file name (if omitted, keeps existing file name)
117
+ */
118
+ fileName?: string;
119
+ /**
120
+ * Optional new target Folder ID (if omitted, keeps existing folder)
121
+ */
122
+ folderId?: string | null;
123
+ /**
124
+ * Optional MIME type of the new file
125
+ */
126
+ mimeType?: string;
127
+ /**
128
+ * Optional new width
129
+ */
130
+ width?: number | null;
131
+ /**
132
+ * Optional new height
133
+ */
134
+ height?: number | null;
135
+ /**
136
+ * Upload progress callback
137
+ */
138
+ onProgress?: (progress: {
139
+ loaded: number;
140
+ total: number;
141
+ percent: number;
142
+ }) => void;
143
+ }
60
144
  export interface UploadedFile {
61
145
  id: string;
62
146
  projectId: string;
@@ -66,8 +150,36 @@ export interface UploadedFile {
66
150
  size: number;
67
151
  width: number | null;
68
152
  height: number | null;
153
+ /**
154
+ * Unique Cloudizero storage object key path
155
+ */
69
156
  r2Key: string;
157
+ /**
158
+ * Storage key for document thumbnail (if generated)
159
+ */
160
+ thumbnailKey?: string | null;
161
+ /**
162
+ * Resolved public CDN thumbnail URL (if generated)
163
+ */
164
+ thumbnailUrl?: string | null;
165
+ /**
166
+ * Processing status for asynchronous pipelines (e.g. PDF extraction)
167
+ */
168
+ processingStatus?: "ready" | "failed" | "processing" | "pending" | string | null;
169
+ /**
170
+ * Total number of pages for multi-page documents (e.g. PDF)
171
+ */
172
+ pageCount?: number | null;
173
+ /**
174
+ * Document table of contents / chapters (if extracted)
175
+ */
176
+ chapters?: Array<{
177
+ title: string;
178
+ page: number;
179
+ level?: number;
180
+ }> | null;
70
181
  etag: string | null;
182
+ isTrash?: boolean;
71
183
  createdAt: string;
72
184
  updatedAt: string;
73
185
  /**
@@ -75,6 +187,118 @@ export interface UploadedFile {
75
187
  */
76
188
  url?: string;
77
189
  }
190
+ export interface FilePageItem {
191
+ pageNumber: number;
192
+ /**
193
+ * Unique Cloudizero storage object key path for the extracted page image
194
+ */
195
+ r2Key: string;
196
+ url: string;
197
+ width: number;
198
+ height: number;
199
+ size: number;
200
+ }
201
+ export interface FilePagesResult {
202
+ fileId: string;
203
+ fileName: string;
204
+ mimeType: string;
205
+ processingStatus: "ready" | "failed" | "processing" | "pending" | string;
206
+ pageCount: number;
207
+ thumbnailKey: string | null;
208
+ thumbnailUrl: string | null;
209
+ chapters: Array<{
210
+ title: string;
211
+ page: number;
212
+ level?: number;
213
+ }>;
214
+ pages: FilePageItem[];
215
+ }
216
+ export interface ExtractPdfResult {
217
+ success: boolean;
218
+ message: string;
219
+ jobId?: string;
220
+ [key: string]: unknown;
221
+ }
222
+ export interface StorageFolder {
223
+ id: string;
224
+ projectId: string;
225
+ parentId: string | null;
226
+ name: string;
227
+ path: string;
228
+ createdAt: string;
229
+ updatedAt: string;
230
+ }
231
+ export interface CreateFolderOptions {
232
+ /**
233
+ * Target Project ID (e.g. `prj_...`)
234
+ */
235
+ projectId: string;
236
+ /**
237
+ * Folder display name (e.g. `avatars` or `Marketing Banners`)
238
+ */
239
+ name: string;
240
+ /**
241
+ * Optional parent Folder ID (e.g. `fld_...`, or `null` / `"root"` for project root)
242
+ */
243
+ parentId?: string | null;
244
+ /**
245
+ * Optional custom virtual path (auto-generated from parent path + slugified name if omitted)
246
+ */
247
+ path?: string;
248
+ }
249
+ export interface ListFoldersOptions {
250
+ /**
251
+ * Target Project ID (e.g. `prj_...`)
252
+ */
253
+ projectId: string;
254
+ /**
255
+ * Optional parent Folder ID (e.g. `fld_...`, or `null` / `"root"` lists root-level folders)
256
+ */
257
+ parentId?: string | null;
258
+ }
259
+ export interface UpdateFolderOptions {
260
+ /**
261
+ * The ID of the folder to update (e.g. `fld_...`)
262
+ */
263
+ folderId: string;
264
+ /**
265
+ * Optional new folder name.
266
+ * Automatically updates paths and moves underlying storage objects for all nested files.
267
+ */
268
+ name?: string;
269
+ /**
270
+ * Optional new parent Folder ID (e.g. `fld_...`, or `null` / `"root"` moves folder to project root).
271
+ * Automatically updates paths and moves underlying storage objects for all nested files.
272
+ */
273
+ parentId?: string | null;
274
+ }
275
+ export interface DeleteFolderResult {
276
+ success: boolean;
277
+ message: string;
278
+ deletedFoldersCount: number;
279
+ deletedFilesCount: number;
280
+ }
281
+ export interface Project {
282
+ id: string;
283
+ userId: string;
284
+ name: string;
285
+ description?: string | null;
286
+ sortOrder: number;
287
+ createdAt: string;
288
+ updatedAt: string;
289
+ }
290
+ export interface CreateProjectOptions {
291
+ name: string;
292
+ description?: string;
293
+ }
294
+ export interface UpdateProjectOptions {
295
+ name?: string;
296
+ description?: string;
297
+ }
298
+ export interface DeleteProjectResult {
299
+ success: boolean;
300
+ message: string;
301
+ }
78
302
  export interface StorageContents {
79
303
  project: {
80
304
  id: string;
@@ -85,12 +309,7 @@ export interface StorageContents {
85
309
  id: string;
86
310
  name: string;
87
311
  }[];
88
- folders: {
89
- id: string;
90
- name: string;
91
- path: string;
92
- createdAt: string;
93
- }[];
312
+ folders: StorageFolder[];
94
313
  files: UploadedFile[];
95
314
  }
96
315
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mapp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,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IACF,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,EAAE;QACX,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;KACd,EAAE,CAAC;IACJ,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,KAAK,EAAE,YAAY,EAAE,CAAC;CACvB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudizero/sdk",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "description": "Official TypeScript SDK for Cloudizero Zero-Egress Media Platform",
6
6
  "main": "./dist/index.js",
@@ -16,24 +16,16 @@
16
16
  "dist",
17
17
  "README.md"
18
18
  ],
19
- "scripts": {
20
- "build": "tsc",
21
- "typecheck": "tsc --noEmit"
22
- },
23
19
  "publishConfig": {
24
20
  "access": "public"
25
21
  },
26
- "repository": {
27
- "type": "git",
28
- "url": "https://github.com/wismannur/cloudizero.git",
29
- "directory": "packages/sdk"
30
- },
31
- "homepage": "https://cloudizero.wismannur.pro",
22
+ "homepage": "https://www.cloudizero.com/docs",
32
23
  "keywords": [
33
24
  "cloudizero",
34
25
  "dam",
35
26
  "zero-egress",
36
- "cloudflare-r2",
27
+ "object-storage",
28
+ "media-storage",
37
29
  "media-upload",
38
30
  "sdk"
39
31
  ],
@@ -41,6 +33,9 @@
41
33
  "license": "MIT",
42
34
  "devDependencies": {
43
35
  "typescript": "^5.0.0"
36
+ },
37
+ "scripts": {
38
+ "build": "tsc",
39
+ "typecheck": "tsc --noEmit"
44
40
  }
45
- }
46
-
41
+ }