@darseen/vaze 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.
@@ -0,0 +1,28 @@
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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mohammed Alsammarrai
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README ADDED
File without changes
package/dist/index.cjs ADDED
@@ -0,0 +1,141 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/base.ts
2
+ var Base = class {
3
+
4
+
5
+ constructor(options = {}) {
6
+ const vazeUrl = options.vazeUrl || process.env.VAZE_URL;
7
+ const apiKey = options.apiKey || process.env.VAZE_API_KEY;
8
+ if (!vazeUrl) {
9
+ throw new Error(
10
+ "You must provide a Vaze URL or set the VAZE_URL environment variable."
11
+ );
12
+ }
13
+ if (!apiKey) {
14
+ throw new Error(
15
+ "You must provide an API key or set the VAZE_API_KEY environment variable."
16
+ );
17
+ }
18
+ this.apiKey = apiKey;
19
+ this.vazeUrl = vazeUrl;
20
+ }
21
+ async request(method, url, body, headers) {
22
+ try {
23
+ const fetchHeaders = {
24
+ "API-Key": this.apiKey,
25
+ ...headers
26
+ };
27
+ const isFormData = body instanceof FormData;
28
+ if (!isFormData && !fetchHeaders["Content-Type"]) {
29
+ fetchHeaders["Content-Type"] = "application/json";
30
+ }
31
+ const response = await fetch(url, {
32
+ method,
33
+ headers: fetchHeaders,
34
+ body: isFormData ? body : JSON.stringify(body)
35
+ });
36
+ return await response.json();
37
+ } catch (error) {
38
+ console.log("Request error:", error);
39
+ return {
40
+ data: null,
41
+ error: {
42
+ message: "An error occurred while making the request."
43
+ }
44
+ };
45
+ }
46
+ }
47
+ };
48
+
49
+ // src/files.ts
50
+ var Files = class extends Base {
51
+ async getAll(options) {
52
+ const url = new URL("/api/files", this.vazeUrl);
53
+ if (options) {
54
+ for (const [key, value] of Object.entries(options)) {
55
+ url.searchParams.set(key, value.toString());
56
+ }
57
+ }
58
+ return await this.request("GET", url.toString());
59
+ }
60
+ async getById(id) {
61
+ const url = new URL(`/api/files`, this.vazeUrl);
62
+ url.searchParams.set("id", id);
63
+ return await this.request("GET", url.toString());
64
+ }
65
+ async getByName(name, options) {
66
+ const url = new URL(`/api/files`, this.vazeUrl);
67
+ url.searchParams.set("name", name);
68
+ if (options) {
69
+ for (const [key, value] of Object.entries(options)) {
70
+ url.searchParams.set(key, value.toString());
71
+ }
72
+ }
73
+ return await this.request("GET", url.toString());
74
+ }
75
+ async upload(data) {
76
+ const { files, folder } = data;
77
+ const url = new URL("/api/files", this.vazeUrl);
78
+ const formData = new FormData();
79
+ if (folder) formData.append("folder", folder);
80
+ files.forEach((file) => {
81
+ formData.append("files", file);
82
+ });
83
+ return await this.request(
84
+ "POST",
85
+ url.toString(),
86
+ formData
87
+ );
88
+ }
89
+ async rename(data) {
90
+ const url = new URL(`/api/files`, this.vazeUrl);
91
+ return await this.request("PUT", url.toString(), data);
92
+ }
93
+ async delete(id) {
94
+ const url = new URL(`/api/files`, this.vazeUrl);
95
+ return await this.request("DELETE", url.toString(), { id });
96
+ }
97
+ };
98
+
99
+ // src/folders.ts
100
+ var Folders = class extends Base {
101
+ async get(options) {
102
+ const url = new URL("/api/folders", this.vazeUrl);
103
+ if (options) {
104
+ for (const [key, value] of Object.entries(options)) {
105
+ url.searchParams.set(key, value.toString());
106
+ }
107
+ }
108
+ return await this.request(
109
+ "GET",
110
+ url.toString()
111
+ );
112
+ }
113
+ async create(folder) {
114
+ const url = new URL("/api/folders", this.vazeUrl);
115
+ return await this.request("POST", url.toString(), {
116
+ folder
117
+ });
118
+ }
119
+ async rename(data) {
120
+ const url = new URL("/api/folders", this.vazeUrl);
121
+ return await this.request("PUT", url.toString(), data);
122
+ }
123
+ async delete(id) {
124
+ const url = new URL("/api/folders", this.vazeUrl);
125
+ return await this.request("DELETE", url.toString(), { id });
126
+ }
127
+ };
128
+
129
+ // src/index.ts
130
+ var Vaze = class extends Base {
131
+
132
+
133
+ constructor(options = {}) {
134
+ super(options);
135
+ this.files = new Files();
136
+ this.folders = new Folders();
137
+ }
138
+ };
139
+
140
+
141
+ exports.default = Vaze;
@@ -0,0 +1,82 @@
1
+ import * as _repo_types from '@repo/types';
2
+ import { ApiResponse, FileWithUrl, Folder } from '@repo/types';
3
+
4
+ declare class Base {
5
+ private apiKey;
6
+ protected vazeUrl: string;
7
+ constructor(options?: {
8
+ apiKey?: string;
9
+ vazeUrl?: string;
10
+ });
11
+ protected request<T>(method: string, url: string, body?: Record<string, any> | FormData, headers?: Record<string, string>): Promise<ApiResponse<T>>;
12
+ }
13
+
14
+ declare class Files extends Base {
15
+ getAll(options?: {
16
+ limit?: number;
17
+ offset?: number;
18
+ orderBy?: "created_at" | "updated_at" | "name" | "size";
19
+ orderDirection?: "ASC" | "DESC";
20
+ }): Promise<_repo_types.ApiResponse<{
21
+ files: FileWithUrl[];
22
+ }>>;
23
+ getById(id: string): Promise<_repo_types.ApiResponse<{
24
+ file: FileWithUrl;
25
+ }>>;
26
+ getByName(name: string, options?: {
27
+ limit?: number;
28
+ offset?: number;
29
+ orderBy?: "created_at" | "updated_at" | "name" | "size";
30
+ orderDirection?: "ASC" | "DESC";
31
+ }): Promise<_repo_types.ApiResponse<{
32
+ files: FileWithUrl[];
33
+ }>>;
34
+ upload(data: {
35
+ files: File[];
36
+ folder?: string;
37
+ }): Promise<_repo_types.ApiResponse<{
38
+ files: FileWithUrl[];
39
+ }>>;
40
+ rename(data: {
41
+ id: string;
42
+ name: string;
43
+ }): Promise<_repo_types.ApiResponse<null>>;
44
+ delete(id: string): Promise<_repo_types.ApiResponse<null>>;
45
+ }
46
+
47
+ declare class Folders extends Base {
48
+ get(options?: {
49
+ id?: string;
50
+ path?: string;
51
+ limit?: number;
52
+ offset?: number;
53
+ orderBy?: "created_at" | "updated_at" | "name";
54
+ orderDirection?: "ASC" | "DESC";
55
+ }): Promise<_repo_types.ApiResponse<{
56
+ files: FileWithUrl[];
57
+ folders: Folder[];
58
+ }>>;
59
+ create(folder: string): Promise<_repo_types.ApiResponse<{
60
+ folder: Folder;
61
+ }>>;
62
+ rename(data: {
63
+ id: string;
64
+ name: string;
65
+ }): Promise<_repo_types.ApiResponse<null>>;
66
+ delete(id: string): Promise<_repo_types.ApiResponse<null>>;
67
+ }
68
+
69
+ interface IVaze {
70
+ files: Files;
71
+ }
72
+
73
+ declare class Vaze extends Base implements IVaze {
74
+ files: Files;
75
+ folders: Folders;
76
+ constructor(options?: {
77
+ apiKey?: string;
78
+ vazeUrl?: string;
79
+ });
80
+ }
81
+
82
+ export { Vaze as default };
@@ -0,0 +1,82 @@
1
+ import * as _repo_types from '@repo/types';
2
+ import { ApiResponse, FileWithUrl, Folder } from '@repo/types';
3
+
4
+ declare class Base {
5
+ private apiKey;
6
+ protected vazeUrl: string;
7
+ constructor(options?: {
8
+ apiKey?: string;
9
+ vazeUrl?: string;
10
+ });
11
+ protected request<T>(method: string, url: string, body?: Record<string, any> | FormData, headers?: Record<string, string>): Promise<ApiResponse<T>>;
12
+ }
13
+
14
+ declare class Files extends Base {
15
+ getAll(options?: {
16
+ limit?: number;
17
+ offset?: number;
18
+ orderBy?: "created_at" | "updated_at" | "name" | "size";
19
+ orderDirection?: "ASC" | "DESC";
20
+ }): Promise<_repo_types.ApiResponse<{
21
+ files: FileWithUrl[];
22
+ }>>;
23
+ getById(id: string): Promise<_repo_types.ApiResponse<{
24
+ file: FileWithUrl;
25
+ }>>;
26
+ getByName(name: string, options?: {
27
+ limit?: number;
28
+ offset?: number;
29
+ orderBy?: "created_at" | "updated_at" | "name" | "size";
30
+ orderDirection?: "ASC" | "DESC";
31
+ }): Promise<_repo_types.ApiResponse<{
32
+ files: FileWithUrl[];
33
+ }>>;
34
+ upload(data: {
35
+ files: File[];
36
+ folder?: string;
37
+ }): Promise<_repo_types.ApiResponse<{
38
+ files: FileWithUrl[];
39
+ }>>;
40
+ rename(data: {
41
+ id: string;
42
+ name: string;
43
+ }): Promise<_repo_types.ApiResponse<null>>;
44
+ delete(id: string): Promise<_repo_types.ApiResponse<null>>;
45
+ }
46
+
47
+ declare class Folders extends Base {
48
+ get(options?: {
49
+ id?: string;
50
+ path?: string;
51
+ limit?: number;
52
+ offset?: number;
53
+ orderBy?: "created_at" | "updated_at" | "name";
54
+ orderDirection?: "ASC" | "DESC";
55
+ }): Promise<_repo_types.ApiResponse<{
56
+ files: FileWithUrl[];
57
+ folders: Folder[];
58
+ }>>;
59
+ create(folder: string): Promise<_repo_types.ApiResponse<{
60
+ folder: Folder;
61
+ }>>;
62
+ rename(data: {
63
+ id: string;
64
+ name: string;
65
+ }): Promise<_repo_types.ApiResponse<null>>;
66
+ delete(id: string): Promise<_repo_types.ApiResponse<null>>;
67
+ }
68
+
69
+ interface IVaze {
70
+ files: Files;
71
+ }
72
+
73
+ declare class Vaze extends Base implements IVaze {
74
+ files: Files;
75
+ folders: Folders;
76
+ constructor(options?: {
77
+ apiKey?: string;
78
+ vazeUrl?: string;
79
+ });
80
+ }
81
+
82
+ export { Vaze as default };
package/dist/index.js ADDED
@@ -0,0 +1,141 @@
1
+ // src/base.ts
2
+ var Base = class {
3
+ apiKey;
4
+ vazeUrl;
5
+ constructor(options = {}) {
6
+ const vazeUrl = options.vazeUrl || process.env.VAZE_URL;
7
+ const apiKey = options.apiKey || process.env.VAZE_API_KEY;
8
+ if (!vazeUrl) {
9
+ throw new Error(
10
+ "You must provide a Vaze URL or set the VAZE_URL environment variable."
11
+ );
12
+ }
13
+ if (!apiKey) {
14
+ throw new Error(
15
+ "You must provide an API key or set the VAZE_API_KEY environment variable."
16
+ );
17
+ }
18
+ this.apiKey = apiKey;
19
+ this.vazeUrl = vazeUrl;
20
+ }
21
+ async request(method, url, body, headers) {
22
+ try {
23
+ const fetchHeaders = {
24
+ "API-Key": this.apiKey,
25
+ ...headers
26
+ };
27
+ const isFormData = body instanceof FormData;
28
+ if (!isFormData && !fetchHeaders["Content-Type"]) {
29
+ fetchHeaders["Content-Type"] = "application/json";
30
+ }
31
+ const response = await fetch(url, {
32
+ method,
33
+ headers: fetchHeaders,
34
+ body: isFormData ? body : JSON.stringify(body)
35
+ });
36
+ return await response.json();
37
+ } catch (error) {
38
+ console.log("Request error:", error);
39
+ return {
40
+ data: null,
41
+ error: {
42
+ message: "An error occurred while making the request."
43
+ }
44
+ };
45
+ }
46
+ }
47
+ };
48
+
49
+ // src/files.ts
50
+ var Files = class extends Base {
51
+ async getAll(options) {
52
+ const url = new URL("/api/files", this.vazeUrl);
53
+ if (options) {
54
+ for (const [key, value] of Object.entries(options)) {
55
+ url.searchParams.set(key, value.toString());
56
+ }
57
+ }
58
+ return await this.request("GET", url.toString());
59
+ }
60
+ async getById(id) {
61
+ const url = new URL(`/api/files`, this.vazeUrl);
62
+ url.searchParams.set("id", id);
63
+ return await this.request("GET", url.toString());
64
+ }
65
+ async getByName(name, options) {
66
+ const url = new URL(`/api/files`, this.vazeUrl);
67
+ url.searchParams.set("name", name);
68
+ if (options) {
69
+ for (const [key, value] of Object.entries(options)) {
70
+ url.searchParams.set(key, value.toString());
71
+ }
72
+ }
73
+ return await this.request("GET", url.toString());
74
+ }
75
+ async upload(data) {
76
+ const { files, folder } = data;
77
+ const url = new URL("/api/files", this.vazeUrl);
78
+ const formData = new FormData();
79
+ if (folder) formData.append("folder", folder);
80
+ files.forEach((file) => {
81
+ formData.append("files", file);
82
+ });
83
+ return await this.request(
84
+ "POST",
85
+ url.toString(),
86
+ formData
87
+ );
88
+ }
89
+ async rename(data) {
90
+ const url = new URL(`/api/files`, this.vazeUrl);
91
+ return await this.request("PUT", url.toString(), data);
92
+ }
93
+ async delete(id) {
94
+ const url = new URL(`/api/files`, this.vazeUrl);
95
+ return await this.request("DELETE", url.toString(), { id });
96
+ }
97
+ };
98
+
99
+ // src/folders.ts
100
+ var Folders = class extends Base {
101
+ async get(options) {
102
+ const url = new URL("/api/folders", this.vazeUrl);
103
+ if (options) {
104
+ for (const [key, value] of Object.entries(options)) {
105
+ url.searchParams.set(key, value.toString());
106
+ }
107
+ }
108
+ return await this.request(
109
+ "GET",
110
+ url.toString()
111
+ );
112
+ }
113
+ async create(folder) {
114
+ const url = new URL("/api/folders", this.vazeUrl);
115
+ return await this.request("POST", url.toString(), {
116
+ folder
117
+ });
118
+ }
119
+ async rename(data) {
120
+ const url = new URL("/api/folders", this.vazeUrl);
121
+ return await this.request("PUT", url.toString(), data);
122
+ }
123
+ async delete(id) {
124
+ const url = new URL("/api/folders", this.vazeUrl);
125
+ return await this.request("DELETE", url.toString(), { id });
126
+ }
127
+ };
128
+
129
+ // src/index.ts
130
+ var Vaze = class extends Base {
131
+ files;
132
+ folders;
133
+ constructor(options = {}) {
134
+ super(options);
135
+ this.files = new Files();
136
+ this.folders = new Folders();
137
+ }
138
+ };
139
+ export {
140
+ Vaze as default
141
+ };
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@darseen/vaze",
3
+ "version": "1.0.0",
4
+ "description": "Vaze Self-Hosted file storage and hosting service SKD.",
5
+ "keywords": [
6
+ "api",
7
+ "sdk",
8
+ "self-hosting",
9
+ "storage",
10
+ "files",
11
+ "file",
12
+ "file-storage",
13
+ "vaze"
14
+ ],
15
+ "homepage": "https://github.com/darseen/vaze#readme",
16
+ "bugs": {
17
+ "url": "https://github.com/darseen/vaze/issues"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/darseen/vaze.git"
22
+ },
23
+ "license": "MIT",
24
+ "author": "darseen",
25
+ "type": "module",
26
+ "exports": {
27
+ ".": {
28
+ "import": "./dist/index.js",
29
+ "types": "./dist/index.d.ts"
30
+ }
31
+ },
32
+ "devDependencies": {
33
+ "@types/node": "^25.5.0",
34
+ "rimraf": "^6.1.3",
35
+ "tsup": "^8.5.1",
36
+ "@repo/types": "1.0.0"
37
+ },
38
+ "scripts": {
39
+ "lint": "tsc --noEmit",
40
+ "prebuild": "pnpm lint && rimraf ./dist",
41
+ "build": "tsup",
42
+ "release": "pnpm build && pnpm publish --provenance --no-git-checks --access public"
43
+ }
44
+ }