@unisource/sdk 0.8.0 → 1.1.0-beta.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 +4 -4
- package/dist/index.d.mts +9 -83
- package/dist/index.mjs +5 -122
- package/dist/legacy-draft-7fqlx-KW.d.mts +84 -0
- package/dist/legacy-draft-D0hgtTqN.mjs +126 -0
- package/dist/v2/index.d.mts +212 -0
- package/dist/v2/index.mjs +194 -0
- package/package.json +19 -9
- package/src/client.ts +0 -700
- package/src/fileRecords.ts +0 -108
- package/src/folders.ts +0 -97
- package/src/index.ts +0 -289
- package/src/mainStorage.ts +0 -51
- package/src/primitives.ts +0 -43
- package/src/releases.ts +0 -236
- package/src/services.ts +0 -169
- package/src/shareLinks.ts +0 -109
- package/src/uploads.ts +0 -189
- package/src/v2.ts +0 -69
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { a as BulkOperationResponse, c as FolderListV2Query, d as bulkFolderIdsSchema, f as bulkFolderMoveRequestSchema, g as folderListV2QuerySchema, h as folderBreadcrumbsResponseSchema, i as BulkFolderMoveRequest, l as bulkFileIdsSchema, m as fileRecordsListV2QuerySchema, n as BulkFileMoveRequest, o as FileRecordsListV2Query, p as bulkOperationResponseSchema, r as BulkFolderIds, s as FolderBreadcrumbsResponse, t as BulkFileIds, u as bulkFileMoveRequestSchema } from "../legacy-draft-7fqlx-KW.mjs";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
//#region src/v2/types.d.ts
|
|
5
|
+
type SortBy = 'created_at' | 'updated_at' | 'name' | 'size';
|
|
6
|
+
type SortDir = 'asc' | 'desc';
|
|
7
|
+
type TrashFilter = 'active' | 'trashed' | 'all';
|
|
8
|
+
interface V2ListQuery {
|
|
9
|
+
folder_id?: string | null;
|
|
10
|
+
search?: string;
|
|
11
|
+
mime_type?: string;
|
|
12
|
+
trash?: TrashFilter;
|
|
13
|
+
sort_by?: SortBy;
|
|
14
|
+
sort_dir?: SortDir;
|
|
15
|
+
cursor?: string;
|
|
16
|
+
limit?: number;
|
|
17
|
+
}
|
|
18
|
+
interface V2Page {
|
|
19
|
+
limit: number;
|
|
20
|
+
next_cursor: string | null;
|
|
21
|
+
}
|
|
22
|
+
interface V2ListResponse<T> {
|
|
23
|
+
items: T[];
|
|
24
|
+
page: V2Page;
|
|
25
|
+
}
|
|
26
|
+
interface V2ErrorBody {
|
|
27
|
+
error: {
|
|
28
|
+
code: string;
|
|
29
|
+
message: string;
|
|
30
|
+
details?: unknown;
|
|
31
|
+
request_id: string;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/v2/files.d.ts
|
|
36
|
+
declare const v2FileSchema: z.ZodObject<{
|
|
37
|
+
id: z.ZodString;
|
|
38
|
+
service_id: z.ZodString;
|
|
39
|
+
user_id: z.ZodString;
|
|
40
|
+
folder_id: z.ZodNullable<z.ZodString>;
|
|
41
|
+
upload_id: z.ZodNullable<z.ZodString>;
|
|
42
|
+
filename: z.ZodString;
|
|
43
|
+
size: z.ZodNumber;
|
|
44
|
+
mime_type: z.ZodString;
|
|
45
|
+
storage_destination: z.ZodEnum<{
|
|
46
|
+
appwrite: "appwrite";
|
|
47
|
+
r2: "r2";
|
|
48
|
+
}>;
|
|
49
|
+
is_trashed: z.ZodBoolean;
|
|
50
|
+
trashed_at: z.ZodNullable<z.ZodNumber>;
|
|
51
|
+
created_at: z.ZodNumber;
|
|
52
|
+
updated_at: z.ZodNumber;
|
|
53
|
+
}, z.core.$strip>;
|
|
54
|
+
type V2File = z.infer<typeof v2FileSchema>;
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region src/v2/folders.d.ts
|
|
57
|
+
declare const v2FolderSchema: z.ZodObject<{
|
|
58
|
+
id: z.ZodString;
|
|
59
|
+
service_id: z.ZodString;
|
|
60
|
+
user_id: z.ZodString;
|
|
61
|
+
parent_id: z.ZodNullable<z.ZodString>;
|
|
62
|
+
name: z.ZodString;
|
|
63
|
+
color_tag: z.ZodNullable<z.ZodString>;
|
|
64
|
+
is_trashed: z.ZodBoolean;
|
|
65
|
+
trashed_at: z.ZodNullable<z.ZodNumber>;
|
|
66
|
+
created_at: z.ZodNumber;
|
|
67
|
+
updated_at: z.ZodNumber;
|
|
68
|
+
}, z.core.$strip>;
|
|
69
|
+
type V2Folder = z.infer<typeof v2FolderSchema>;
|
|
70
|
+
declare const v2FolderListQuerySchema: z.ZodObject<{
|
|
71
|
+
parent_id: z.ZodOptional<z.ZodString>;
|
|
72
|
+
search: z.ZodOptional<z.ZodString>;
|
|
73
|
+
trash: z.ZodOptional<z.ZodEnum<{
|
|
74
|
+
active: "active";
|
|
75
|
+
all: "all";
|
|
76
|
+
trashed: "trashed";
|
|
77
|
+
}>>;
|
|
78
|
+
sort_by: z.ZodOptional<z.ZodEnum<{
|
|
79
|
+
created_at: "created_at";
|
|
80
|
+
name: "name";
|
|
81
|
+
updated_at: "updated_at";
|
|
82
|
+
}>>;
|
|
83
|
+
sort_dir: z.ZodOptional<z.ZodEnum<{
|
|
84
|
+
asc: "asc";
|
|
85
|
+
desc: "desc";
|
|
86
|
+
}>>;
|
|
87
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
88
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
89
|
+
}, z.core.$strip>;
|
|
90
|
+
type V2FolderListQuery = z.infer<typeof v2FolderListQuerySchema>;
|
|
91
|
+
declare const v2FolderListResponseSchema: z.ZodObject<{
|
|
92
|
+
items: z.ZodArray<z.ZodObject<{
|
|
93
|
+
id: z.ZodString;
|
|
94
|
+
service_id: z.ZodString;
|
|
95
|
+
user_id: z.ZodString;
|
|
96
|
+
parent_id: z.ZodNullable<z.ZodString>;
|
|
97
|
+
name: z.ZodString;
|
|
98
|
+
color_tag: z.ZodNullable<z.ZodString>;
|
|
99
|
+
is_trashed: z.ZodBoolean;
|
|
100
|
+
trashed_at: z.ZodNullable<z.ZodNumber>;
|
|
101
|
+
created_at: z.ZodNumber;
|
|
102
|
+
updated_at: z.ZodNumber;
|
|
103
|
+
}, z.core.$strip>>;
|
|
104
|
+
page: z.ZodObject<{
|
|
105
|
+
limit: z.ZodNumber;
|
|
106
|
+
next_cursor: z.ZodNullable<z.ZodString>;
|
|
107
|
+
}, z.core.$strip>;
|
|
108
|
+
}, z.core.$strip>;
|
|
109
|
+
type V2FolderListResponse = z.infer<typeof v2FolderListResponseSchema>;
|
|
110
|
+
//#endregion
|
|
111
|
+
//#region src/v2/schemas.d.ts
|
|
112
|
+
declare const v2ListQuerySchema: z.ZodObject<{
|
|
113
|
+
folder_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
114
|
+
search: z.ZodOptional<z.ZodString>;
|
|
115
|
+
mime_type: z.ZodOptional<z.ZodString>;
|
|
116
|
+
trash: z.ZodOptional<z.ZodEnum<{
|
|
117
|
+
active: "active";
|
|
118
|
+
all: "all";
|
|
119
|
+
trashed: "trashed";
|
|
120
|
+
}>>;
|
|
121
|
+
sort_by: z.ZodOptional<z.ZodEnum<{
|
|
122
|
+
created_at: "created_at";
|
|
123
|
+
name: "name";
|
|
124
|
+
size: "size";
|
|
125
|
+
updated_at: "updated_at";
|
|
126
|
+
}>>;
|
|
127
|
+
sort_dir: z.ZodOptional<z.ZodEnum<{
|
|
128
|
+
asc: "asc";
|
|
129
|
+
desc: "desc";
|
|
130
|
+
}>>;
|
|
131
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
132
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
133
|
+
}, z.core.$strip>;
|
|
134
|
+
declare const v2PageSchema: z.ZodObject<{
|
|
135
|
+
limit: z.ZodNumber;
|
|
136
|
+
next_cursor: z.ZodNullable<z.ZodString>;
|
|
137
|
+
}, z.core.$strip>;
|
|
138
|
+
declare function v2ListResponseSchema<T extends z.ZodTypeAny>(itemSchema: T): z.ZodObject<{
|
|
139
|
+
items: z.ZodArray<T>;
|
|
140
|
+
page: z.ZodObject<{
|
|
141
|
+
limit: z.ZodNumber;
|
|
142
|
+
next_cursor: z.ZodNullable<z.ZodString>;
|
|
143
|
+
}, z.core.$strip>;
|
|
144
|
+
}, z.core.$strip>;
|
|
145
|
+
declare const v2ErrorSchema: z.ZodObject<{
|
|
146
|
+
error: z.ZodObject<{
|
|
147
|
+
code: z.ZodString;
|
|
148
|
+
message: z.ZodString;
|
|
149
|
+
details: z.ZodOptional<z.ZodUnknown>;
|
|
150
|
+
request_id: z.ZodString;
|
|
151
|
+
}, z.core.$strip>;
|
|
152
|
+
}, z.core.$strip>;
|
|
153
|
+
declare const v2FilesListResponseSchema: z.ZodObject<{
|
|
154
|
+
items: z.ZodArray<z.ZodObject<{
|
|
155
|
+
id: z.ZodString;
|
|
156
|
+
service_id: z.ZodString;
|
|
157
|
+
user_id: z.ZodString;
|
|
158
|
+
folder_id: z.ZodNullable<z.ZodString>;
|
|
159
|
+
upload_id: z.ZodNullable<z.ZodString>;
|
|
160
|
+
filename: z.ZodString;
|
|
161
|
+
size: z.ZodNumber;
|
|
162
|
+
mime_type: z.ZodString;
|
|
163
|
+
storage_destination: z.ZodEnum<{
|
|
164
|
+
appwrite: "appwrite";
|
|
165
|
+
r2: "r2";
|
|
166
|
+
}>;
|
|
167
|
+
is_trashed: z.ZodBoolean;
|
|
168
|
+
trashed_at: z.ZodNullable<z.ZodNumber>;
|
|
169
|
+
created_at: z.ZodNumber;
|
|
170
|
+
updated_at: z.ZodNumber;
|
|
171
|
+
}, z.core.$strip>>;
|
|
172
|
+
page: z.ZodObject<{
|
|
173
|
+
limit: z.ZodNumber;
|
|
174
|
+
next_cursor: z.ZodNullable<z.ZodString>;
|
|
175
|
+
}, z.core.$strip>;
|
|
176
|
+
}, z.core.$strip>;
|
|
177
|
+
//#endregion
|
|
178
|
+
//#region src/v2/errors.d.ts
|
|
179
|
+
declare class UnisourceV2Error extends Error {
|
|
180
|
+
readonly status: number;
|
|
181
|
+
readonly code: string;
|
|
182
|
+
readonly requestId: string;
|
|
183
|
+
readonly details?: unknown;
|
|
184
|
+
constructor(message: string, status: number, code: string, requestId: string, details?: unknown);
|
|
185
|
+
}
|
|
186
|
+
//#endregion
|
|
187
|
+
//#region src/v2/client.d.ts
|
|
188
|
+
interface UnisourceV2ClientConfig {
|
|
189
|
+
baseUrl: string;
|
|
190
|
+
serviceId: string;
|
|
191
|
+
getToken: () => string | null | undefined | Promise<string | null | undefined>;
|
|
192
|
+
/** Set to true to suppress the beta warning in console */
|
|
193
|
+
silentBeta?: boolean;
|
|
194
|
+
}
|
|
195
|
+
declare class UnisourceV2Client {
|
|
196
|
+
private config;
|
|
197
|
+
constructor(config: UnisourceV2ClientConfig);
|
|
198
|
+
readonly files: {
|
|
199
|
+
list: (query?: V2ListQuery, signal?: AbortSignal, options?: {
|
|
200
|
+
asUser?: string;
|
|
201
|
+
}) => Promise<V2ListResponse<V2File>>;
|
|
202
|
+
};
|
|
203
|
+
readonly folders: {
|
|
204
|
+
list: (query?: V2FolderListQuery, signal?: AbortSignal, options?: {
|
|
205
|
+
asUser?: string;
|
|
206
|
+
}) => Promise<V2FolderListResponse>;
|
|
207
|
+
};
|
|
208
|
+
private _filesList;
|
|
209
|
+
private _foldersList;
|
|
210
|
+
}
|
|
211
|
+
//#endregion
|
|
212
|
+
export { BulkFileIds, BulkFileMoveRequest, BulkFolderIds, BulkFolderMoveRequest, BulkOperationResponse, FileRecordsListV2Query, FolderBreadcrumbsResponse, FolderListV2Query, SortBy, SortDir, TrashFilter, UnisourceV2Client, type UnisourceV2ClientConfig, UnisourceV2Error, V2ErrorBody, V2File, V2Folder, V2FolderListQuery, V2FolderListResponse, V2ListQuery, V2ListResponse, V2Page, bulkFileIdsSchema, bulkFileMoveRequestSchema, bulkFolderIdsSchema, bulkFolderMoveRequestSchema, bulkOperationResponseSchema, fileRecordsListV2QuerySchema, folderBreadcrumbsResponseSchema, folderListV2QuerySchema, v2ErrorSchema, v2FileSchema, v2FilesListResponseSchema, v2FolderListQuerySchema, v2FolderListResponseSchema, v2FolderSchema, v2ListQuerySchema, v2ListResponseSchema, v2PageSchema };
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { a as bulkOperationResponseSchema, c as folderListV2QuerySchema, i as bulkFolderMoveRequestSchema, n as bulkFileMoveRequestSchema, o as fileRecordsListV2QuerySchema, r as bulkFolderIdsSchema, s as folderBreadcrumbsResponseSchema, t as bulkFileIdsSchema } from "../legacy-draft-D0hgtTqN.mjs";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region src/v2/files.ts
|
|
4
|
+
const v2FileSchema = z.object({
|
|
5
|
+
id: z.string(),
|
|
6
|
+
service_id: z.string(),
|
|
7
|
+
user_id: z.string(),
|
|
8
|
+
folder_id: z.string().nullable(),
|
|
9
|
+
upload_id: z.string().nullable(),
|
|
10
|
+
filename: z.string(),
|
|
11
|
+
size: z.number(),
|
|
12
|
+
mime_type: z.string(),
|
|
13
|
+
storage_destination: z.enum(["r2", "appwrite"]),
|
|
14
|
+
is_trashed: z.boolean(),
|
|
15
|
+
trashed_at: z.number().nullable(),
|
|
16
|
+
created_at: z.number(),
|
|
17
|
+
updated_at: z.number()
|
|
18
|
+
});
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/v2/schemas.ts
|
|
21
|
+
const v2ListQuerySchema = z.object({
|
|
22
|
+
folder_id: z.string().nullable().optional(),
|
|
23
|
+
search: z.string().optional(),
|
|
24
|
+
mime_type: z.string().optional(),
|
|
25
|
+
trash: z.enum([
|
|
26
|
+
"active",
|
|
27
|
+
"trashed",
|
|
28
|
+
"all"
|
|
29
|
+
]).optional(),
|
|
30
|
+
sort_by: z.enum([
|
|
31
|
+
"created_at",
|
|
32
|
+
"updated_at",
|
|
33
|
+
"name",
|
|
34
|
+
"size"
|
|
35
|
+
]).optional(),
|
|
36
|
+
sort_dir: z.enum(["asc", "desc"]).optional(),
|
|
37
|
+
cursor: z.string().optional(),
|
|
38
|
+
limit: z.number().int().min(1).optional()
|
|
39
|
+
});
|
|
40
|
+
const v2PageSchema = z.object({
|
|
41
|
+
limit: z.number(),
|
|
42
|
+
next_cursor: z.string().nullable()
|
|
43
|
+
});
|
|
44
|
+
function v2ListResponseSchema(itemSchema) {
|
|
45
|
+
return z.object({
|
|
46
|
+
items: z.array(itemSchema),
|
|
47
|
+
page: v2PageSchema
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
const v2ErrorSchema = z.object({ error: z.object({
|
|
51
|
+
code: z.string(),
|
|
52
|
+
message: z.string(),
|
|
53
|
+
details: z.unknown().optional(),
|
|
54
|
+
request_id: z.string()
|
|
55
|
+
}) });
|
|
56
|
+
const v2FilesListResponseSchema = v2ListResponseSchema(v2FileSchema);
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/v2/folders.ts
|
|
59
|
+
const v2FolderSchema = z.object({
|
|
60
|
+
id: z.string(),
|
|
61
|
+
service_id: z.string(),
|
|
62
|
+
user_id: z.string(),
|
|
63
|
+
parent_id: z.string().nullable(),
|
|
64
|
+
name: z.string(),
|
|
65
|
+
color_tag: z.string().nullable(),
|
|
66
|
+
is_trashed: z.boolean(),
|
|
67
|
+
trashed_at: z.number().nullable(),
|
|
68
|
+
created_at: z.number(),
|
|
69
|
+
updated_at: z.number()
|
|
70
|
+
});
|
|
71
|
+
const v2FolderListQuerySchema = z.object({
|
|
72
|
+
parent_id: z.string().optional(),
|
|
73
|
+
search: z.string().max(100).optional(),
|
|
74
|
+
trash: z.enum([
|
|
75
|
+
"active",
|
|
76
|
+
"trashed",
|
|
77
|
+
"all"
|
|
78
|
+
]).optional(),
|
|
79
|
+
sort_by: z.enum([
|
|
80
|
+
"created_at",
|
|
81
|
+
"updated_at",
|
|
82
|
+
"name"
|
|
83
|
+
]).optional(),
|
|
84
|
+
sort_dir: z.enum(["asc", "desc"]).optional(),
|
|
85
|
+
cursor: z.string().optional(),
|
|
86
|
+
limit: z.number().int().min(1).max(100).optional()
|
|
87
|
+
});
|
|
88
|
+
const v2FolderListResponseSchema = v2ListResponseSchema(v2FolderSchema);
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region src/v2/errors.ts
|
|
91
|
+
var UnisourceV2Error = class extends Error {
|
|
92
|
+
constructor(message, status, code, requestId, details) {
|
|
93
|
+
super(message);
|
|
94
|
+
this.status = status;
|
|
95
|
+
this.code = code;
|
|
96
|
+
this.requestId = requestId;
|
|
97
|
+
this.details = details;
|
|
98
|
+
this.name = "UnisourceV2Error";
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
//#endregion
|
|
102
|
+
//#region src/v2/client.ts
|
|
103
|
+
let warned = false;
|
|
104
|
+
function parseErrorBody(value) {
|
|
105
|
+
if (!value || typeof value !== "object") return {};
|
|
106
|
+
const error = value.error;
|
|
107
|
+
if (!error || typeof error !== "object") return {};
|
|
108
|
+
const payload = error;
|
|
109
|
+
return { error: {
|
|
110
|
+
code: typeof payload.code === "string" ? payload.code : void 0,
|
|
111
|
+
message: typeof payload.message === "string" ? payload.message : void 0,
|
|
112
|
+
details: payload.details
|
|
113
|
+
} };
|
|
114
|
+
}
|
|
115
|
+
var UnisourceV2Client = class {
|
|
116
|
+
config;
|
|
117
|
+
constructor(config) {
|
|
118
|
+
this.config = config;
|
|
119
|
+
if (!warned && !config.silentBeta) {
|
|
120
|
+
console.warn("[unisource-sdk] V2 API is in beta. Breaking changes possible. See https://docs.unisource.example/v2 for stability commitments.");
|
|
121
|
+
warned = true;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
files = { list: (query, signal, options) => this._filesList(query, signal, options) };
|
|
125
|
+
folders = { list: (query, signal, options) => this._foldersList(query, signal, options) };
|
|
126
|
+
async _filesList(query, signal, options) {
|
|
127
|
+
const token = await this.config.getToken();
|
|
128
|
+
const headers = { "X-Service-ID": this.config.serviceId };
|
|
129
|
+
if (token) headers["Authorization"] = `Bearer ${token}`;
|
|
130
|
+
if (options?.asUser) headers["X-Target-User-ID"] = options.asUser;
|
|
131
|
+
const url = new URL("/v2/files", this.config.baseUrl);
|
|
132
|
+
if (query) for (const [k, v] of Object.entries(query)) {
|
|
133
|
+
if (v === void 0) continue;
|
|
134
|
+
url.searchParams.set(k, v === null ? "null" : String(v));
|
|
135
|
+
}
|
|
136
|
+
let response;
|
|
137
|
+
try {
|
|
138
|
+
response = await fetch(url.toString(), {
|
|
139
|
+
method: "GET",
|
|
140
|
+
headers,
|
|
141
|
+
signal
|
|
142
|
+
});
|
|
143
|
+
} catch (err) {
|
|
144
|
+
throw new Error(`Network request failed: ${err}`);
|
|
145
|
+
}
|
|
146
|
+
if (!response.ok) {
|
|
147
|
+
const requestId = response.headers.get("X-Request-Id") ?? "unknown";
|
|
148
|
+
let body;
|
|
149
|
+
try {
|
|
150
|
+
body = parseErrorBody(await response.json());
|
|
151
|
+
} catch {
|
|
152
|
+
body = {};
|
|
153
|
+
}
|
|
154
|
+
throw new UnisourceV2Error(body.error?.message ?? response.statusText, response.status, body.error?.code ?? "unknown", requestId, body.error?.details);
|
|
155
|
+
}
|
|
156
|
+
const data = await response.json();
|
|
157
|
+
return v2ListResponseSchema(v2FileSchema).parse(data);
|
|
158
|
+
}
|
|
159
|
+
async _foldersList(query, signal, options) {
|
|
160
|
+
const token = await this.config.getToken();
|
|
161
|
+
const headers = { "X-Service-ID": this.config.serviceId };
|
|
162
|
+
if (token) headers["Authorization"] = `Bearer ${token}`;
|
|
163
|
+
if (options?.asUser) headers["X-Target-User-ID"] = options.asUser;
|
|
164
|
+
const url = new URL("/v2/folders", this.config.baseUrl);
|
|
165
|
+
if (query) for (const [k, v] of Object.entries(query)) {
|
|
166
|
+
if (v === void 0) continue;
|
|
167
|
+
url.searchParams.set(k, v === null ? "null" : String(v));
|
|
168
|
+
}
|
|
169
|
+
let response;
|
|
170
|
+
try {
|
|
171
|
+
response = await fetch(url.toString(), {
|
|
172
|
+
method: "GET",
|
|
173
|
+
headers,
|
|
174
|
+
signal
|
|
175
|
+
});
|
|
176
|
+
} catch (err) {
|
|
177
|
+
throw new Error(`Network request failed: ${err}`);
|
|
178
|
+
}
|
|
179
|
+
if (!response.ok) {
|
|
180
|
+
const requestId = response.headers.get("X-Request-Id") ?? "unknown";
|
|
181
|
+
let body;
|
|
182
|
+
try {
|
|
183
|
+
body = parseErrorBody(await response.json());
|
|
184
|
+
} catch {
|
|
185
|
+
body = {};
|
|
186
|
+
}
|
|
187
|
+
throw new UnisourceV2Error(body.error?.message ?? response.statusText, response.status, body.error?.code ?? "unknown", requestId, body.error?.details);
|
|
188
|
+
}
|
|
189
|
+
const data = await response.json();
|
|
190
|
+
return v2FolderListResponseSchema.parse(data);
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
//#endregion
|
|
194
|
+
export { UnisourceV2Client, UnisourceV2Error, bulkFileIdsSchema, bulkFileMoveRequestSchema, bulkFolderIdsSchema, bulkFolderMoveRequestSchema, bulkOperationResponseSchema, fileRecordsListV2QuerySchema, folderBreadcrumbsResponseSchema, folderListV2QuerySchema, v2ErrorSchema, v2FileSchema, v2FilesListResponseSchema, v2FolderListQuerySchema, v2FolderListResponseSchema, v2FolderSchema, v2ListQuerySchema, v2ListResponseSchema, v2PageSchema };
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@unisource/sdk",
|
|
3
3
|
"private": false,
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "
|
|
5
|
+
"version": "1.1.0-beta.0",
|
|
6
6
|
"description": "Wspolne kontrakty danych dla backendu i frontendu UniSource.",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"publishConfig": {
|
|
@@ -14,13 +14,24 @@
|
|
|
14
14
|
"import": "./dist/index.mjs",
|
|
15
15
|
"default": "./dist/index.mjs"
|
|
16
16
|
},
|
|
17
|
+
"./v2": {
|
|
18
|
+
"types": "./dist/v2/index.d.mts",
|
|
19
|
+
"import": "./dist/v2/index.mjs",
|
|
20
|
+
"default": "./dist/v2/index.mjs"
|
|
21
|
+
},
|
|
17
22
|
"./package.json": "./package.json"
|
|
18
23
|
},
|
|
19
24
|
"types": "./dist/index.d.mts",
|
|
20
25
|
"files": [
|
|
21
|
-
"dist"
|
|
22
|
-
"src"
|
|
26
|
+
"dist"
|
|
23
27
|
],
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "tsdown",
|
|
30
|
+
"dev": "tsdown --watch",
|
|
31
|
+
"test": "pnpm run build && vitest",
|
|
32
|
+
"typecheck": "tsc --noEmit",
|
|
33
|
+
"prepublishOnly": "pnpm run build"
|
|
34
|
+
},
|
|
24
35
|
"devDependencies": {
|
|
25
36
|
"@types/node": "^25.5.0",
|
|
26
37
|
"@typescript/native-preview": "7.0.0-dev.20260328.1",
|
|
@@ -31,10 +42,9 @@
|
|
|
31
42
|
"dependencies": {
|
|
32
43
|
"zod": "^4.3.6"
|
|
33
44
|
},
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"typecheck": "tsc --noEmit"
|
|
45
|
+
"repository": {
|
|
46
|
+
"type": "git",
|
|
47
|
+
"url": "https://github.com/Dan1el-19/UniSource.git",
|
|
48
|
+
"directory": "packages/unisource-sdk"
|
|
39
49
|
}
|
|
40
|
-
}
|
|
50
|
+
}
|