@darseen/vaze 1.0.0 → 1.0.1

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 ADDED
@@ -0,0 +1,170 @@
1
+ # Vaze SDK
2
+
3
+ <div align="center">
4
+
5
+ <img src="../../.github/images/vaze.png" alt="logo" width="200"/>
6
+
7
+ ![NPM Downloads](https://img.shields.io/npm/dm/@darseen/vaze?style=for-the-badge)
8
+ ![NPM Version](https://img.shields.io/npm/v/@darseen/vaze?style=for-the-badge)
9
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=for-the-badge)](https://opensource.org/licenses/MIT)
10
+
11
+ **@darseen/vaze** The official JavaScript/TypeScript SDK for Vaze, a self-hosted, local-first file storage and hosting service. This SDK provides a simple and type-safe way to interact with your Vaze instance's API from your Node.js backend or frontend applications.
12
+
13
+ ## </div>
14
+
15
+ # Installation
16
+
17
+ Install the package using your preferred package manager:
18
+
19
+ ```
20
+ npm install @darseen/vaze
21
+ # or
22
+ yarn add @darseen/vaze
23
+ # or
24
+ pnpm add @darseen/vaze
25
+ ```
26
+
27
+ # Initialization
28
+
29
+ To use the SDK, you must instantiate the `Vaze` client. You can provide your configuration either directly through the constructor options or via environment variables. Using Constructor Options
30
+
31
+ ```ts
32
+ import Vaze from "@darseen/vaze";
33
+
34
+ const vaze = new Vaze({
35
+ vazeUrl: "http://your-server-ip:3000",
36
+ apiKey: "YOUR_API_KEY",
37
+ });
38
+ ```
39
+
40
+ # Using Environment Variables
41
+
42
+ If you set `VAZE_URL` and `VAZE_API_KEY` in your environment, you can initialize the client without passing arguments:
43
+
44
+ ```ts
45
+ import Vaze from "@darseen/vaze";
46
+
47
+ // Automatically picks up process.env.VAZE_URL and process.env.VAZE_API_KEY
48
+ const vaze = new Vaze();
49
+ ```
50
+
51
+ # API Documentation
52
+
53
+ The SDK is divided into two main modules: `files` and `folders`. All methods are asynchronous and return a standard `ApiResponse` object containing either `data` or an `error`. Files API Access file-related methods via `vaze.files.getAll(options?)` Retrieve a paginated list of all files.
54
+
55
+ - options (optional):
56
+ - `limit`
57
+ - `offset`
58
+ - `orderBy`
59
+ - `orderDirection`
60
+
61
+ ```ts
62
+ const { data, error } = await vaze.files.getAll({
63
+ limit: 10,
64
+ orderBy: "created_at",
65
+ orderDirection: "DESC",
66
+ });
67
+
68
+ if (data) {
69
+ console.log(data.files);
70
+ }
71
+ ```
72
+
73
+ `getById(id)` Retrieve a specific file by its ID.
74
+
75
+ ```ts
76
+ const { data, error } = await vaze.files.getById("file-id");
77
+ ```
78
+
79
+ `getByName(name, options?)` Search for files by name.
80
+
81
+ ```ts
82
+ const { data, error } = await vaze.files.getByName("document.pdf", {
83
+ limit: 5,
84
+ });
85
+ ```
86
+
87
+ `upload(data)` Upload one or multiple files to your Vaze instance.
88
+
89
+ - data:
90
+ - `files` (File[]): An array of standard `File` objects.
91
+ - `folder?` (string): The ID or name of the target folder.
92
+
93
+ ```ts
94
+ const { data, error } = await vaze.files.upload({
95
+ files,
96
+ folder: "optional-folder-name", // example: "documents" or "projects/work" (supports sub-folders)
97
+ });
98
+ ```
99
+
100
+ `rename(data)` Rename an existing file.
101
+
102
+ - data:
103
+ - `id` (string): The ID of the file to rename.
104
+ - `name` (string): The new name for the file.
105
+
106
+ ```ts
107
+ const { data, error } = await vaze.files.rename({
108
+ id: "file-id-123",
109
+ name: "new-document-name.pdf",
110
+ });
111
+ ```
112
+
113
+ `delete(id)` Delete a file by its ID.
114
+
115
+ ```ts
116
+ const { data, error } = await vaze.files.delete("file-id-123");
117
+ ```
118
+
119
+ Folders API Access folder-related methods via `vaze.folders`. `get(options?)` Retrieve folders and their contents.
120
+
121
+ - options (optional):
122
+ - `id`
123
+ - `path` example: "projects/work"
124
+ - `limit`
125
+ - `offset`
126
+ - `orderBy`
127
+ - `orderDirection`
128
+
129
+ ```ts
130
+ const { data, error } = await vaze.folders.get({
131
+ path: "/documents/work",
132
+ limit: 20,
133
+ });
134
+
135
+ if (data) {
136
+ console.log("Files:", data.files);
137
+ console.log("Sub-folders:", data.folders);
138
+ }
139
+ ```
140
+
141
+ `create(folder)` Create a new folder.
142
+
143
+ - folder: The name or path of the new folder. Example: "projects" or "projects/work"
144
+
145
+ ```ts
146
+ const { data, error } = await vaze.folders.create("projects/work");
147
+ ```
148
+
149
+ `rename(data)` Rename an existing folder.
150
+
151
+ - data:
152
+ - `id`: The ID of the folder to rename.
153
+ - `name`: The new name.
154
+
155
+ ```ts
156
+ const { data, error } = await vaze.folders.rename({
157
+ id: "folder-id-456",
158
+ name: "new-name",
159
+ });
160
+ ```
161
+
162
+ `delete(id)` Delete a folder by its ID.
163
+
164
+ ```ts
165
+ const { data, error } = await vaze.folders.delete("folder-id");
166
+ ```
167
+
168
+ # Types
169
+
170
+ This SDK is built with TypeScript and exports all necessary types to ensure type safety in your applications. Types such as `FileWithUrl`, `Folder`, and `ApiResponse`.
package/dist/index.d.cts CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as _repo_types from '@repo/types';
2
2
  import { ApiResponse, FileWithUrl, Folder } from '@repo/types';
3
+ export { ApiResponse, FileWithUrl as File, Folder } from '@repo/types';
3
4
 
4
5
  declare class Base {
5
6
  private apiKey;
@@ -32,7 +33,7 @@ declare class Files extends Base {
32
33
  files: FileWithUrl[];
33
34
  }>>;
34
35
  upload(data: {
35
- files: File[];
36
+ files: FileWithUrl[];
36
37
  folder?: string;
37
38
  }): Promise<_repo_types.ApiResponse<{
38
39
  files: FileWithUrl[];
@@ -68,6 +69,7 @@ declare class Folders extends Base {
68
69
 
69
70
  interface IVaze {
70
71
  files: Files;
72
+ folders: Folders;
71
73
  }
72
74
 
73
75
  declare class Vaze extends Base implements IVaze {
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as _repo_types from '@repo/types';
2
2
  import { ApiResponse, FileWithUrl, Folder } from '@repo/types';
3
+ export { ApiResponse, FileWithUrl as File, Folder } from '@repo/types';
3
4
 
4
5
  declare class Base {
5
6
  private apiKey;
@@ -32,7 +33,7 @@ declare class Files extends Base {
32
33
  files: FileWithUrl[];
33
34
  }>>;
34
35
  upload(data: {
35
- files: File[];
36
+ files: FileWithUrl[];
36
37
  folder?: string;
37
38
  }): Promise<_repo_types.ApiResponse<{
38
39
  files: FileWithUrl[];
@@ -68,6 +69,7 @@ declare class Folders extends Base {
68
69
 
69
70
  interface IVaze {
70
71
  files: Files;
72
+ folders: Folders;
71
73
  }
72
74
 
73
75
  declare class Vaze extends Base implements IVaze {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@darseen/vaze",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Vaze Self-Hosted file storage and hosting service SKD.",
5
5
  "keywords": [
6
6
  "api",
@@ -1,28 +0,0 @@
1
-
2
- > @darseen/vaze@1.0.0 prebuild /home/runner/work/vaze/vaze/packages/sdk
3
- > pnpm lint && rimraf ./dist
4
-
5
-
6
- > @darseen/vaze@1.0.0 lint /home/runner/work/vaze/vaze/packages/sdk
7
- > tsc --noEmit
8
-
9
-
10
- > @darseen/vaze@1.0.0 build /home/runner/work/vaze/vaze/packages/sdk
11
- > tsup
12
-
13
- CLI Building entry: src/index.ts
14
- CLI Using tsconfig: tsconfig.json
15
- CLI tsup v8.5.1
16
- CLI Using tsup config: /home/runner/work/vaze/vaze/packages/sdk/tsup.config.ts
17
- CLI Target: esnext
18
- CLI Cleaning output folder
19
- CJS Build start
20
- ESM Build start
21
- ESM dist/index.js 3.70 KB
22
- ESM ⚡️ Build success in 67ms
23
- CJS dist/index.cjs 3.74 KB
24
- CJS ⚡️ Build success in 71ms
25
- DTS Build start
26
- DTS ⚡️ Build success in 776ms
27
- DTS dist/index.d.cts 2.23 KB
28
- DTS dist/index.d.ts 2.23 KB
package/README DELETED
File without changes