tuturuuu 0.2.0 → 0.2.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/package.json +15 -25
- package/src/epm.ts +0 -711
- package/src/errors.ts +0 -202
- package/src/external-projects.ts +0 -11
- package/src/index.ts +0 -138
- package/src/storage.ts +0 -1082
- package/src/types.ts +0 -202
package/src/errors.ts
DELETED
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Error classes for the Tuturuuu SDK
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import type { ApiErrorResponse } from './types';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Base error class for all SDK errors
|
|
9
|
-
*/
|
|
10
|
-
export class TuturuuuError extends Error {
|
|
11
|
-
public readonly code?: string;
|
|
12
|
-
public readonly statusCode?: number;
|
|
13
|
-
|
|
14
|
-
constructor(message: string, code?: string, statusCode?: number) {
|
|
15
|
-
super(message);
|
|
16
|
-
this.name = 'TuturuuuError';
|
|
17
|
-
this.code = code;
|
|
18
|
-
this.statusCode = statusCode;
|
|
19
|
-
|
|
20
|
-
// Maintains proper stack trace for where our error was thrown
|
|
21
|
-
(
|
|
22
|
-
Error as typeof Error & {
|
|
23
|
-
captureStackTrace?: (
|
|
24
|
-
targetObject: object,
|
|
25
|
-
constructorOpt?: abstract new (...args: never[]) => unknown
|
|
26
|
-
) => void;
|
|
27
|
-
}
|
|
28
|
-
).captureStackTrace?.(this, this.constructor);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Authentication error (401)
|
|
34
|
-
*/
|
|
35
|
-
export class AuthenticationError extends TuturuuuError {
|
|
36
|
-
constructor(message: string, code?: string) {
|
|
37
|
-
super(message, code, 401);
|
|
38
|
-
this.name = 'AuthenticationError';
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Authorization error (403)
|
|
44
|
-
*/
|
|
45
|
-
export class AuthorizationError extends TuturuuuError {
|
|
46
|
-
constructor(message: string, code?: string) {
|
|
47
|
-
super(message, code, 403);
|
|
48
|
-
this.name = 'AuthorizationError';
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Not found error (404)
|
|
54
|
-
*/
|
|
55
|
-
export class NotFoundError extends TuturuuuError {
|
|
56
|
-
constructor(message: string, code?: string) {
|
|
57
|
-
super(message, code, 404);
|
|
58
|
-
this.name = 'NotFoundError';
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Bad request error (400)
|
|
64
|
-
*/
|
|
65
|
-
export class BadRequestError extends TuturuuuError {
|
|
66
|
-
constructor(message: string, code?: string) {
|
|
67
|
-
super(message, code, 400);
|
|
68
|
-
this.name = 'BadRequestError';
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Conflict error (409)
|
|
74
|
-
*/
|
|
75
|
-
export class ConflictError extends TuturuuuError {
|
|
76
|
-
constructor(message: string, code?: string) {
|
|
77
|
-
super(message, code, 409);
|
|
78
|
-
this.name = 'ConflictError';
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Rate limit error (429)
|
|
84
|
-
*/
|
|
85
|
-
export class RateLimitError extends TuturuuuError {
|
|
86
|
-
/** Number of seconds to wait before retrying (from Retry-After header) */
|
|
87
|
-
public readonly retryAfter?: number;
|
|
88
|
-
/** Unix timestamp when the rate limit resets (from X-RateLimit-Reset header) */
|
|
89
|
-
public readonly resetTime?: number;
|
|
90
|
-
|
|
91
|
-
constructor(
|
|
92
|
-
message: string,
|
|
93
|
-
options?: {
|
|
94
|
-
code?: string;
|
|
95
|
-
retryAfter?: number;
|
|
96
|
-
resetTime?: number;
|
|
97
|
-
}
|
|
98
|
-
) {
|
|
99
|
-
super(message, options?.code, 429);
|
|
100
|
-
this.name = 'RateLimitError';
|
|
101
|
-
this.retryAfter = options?.retryAfter;
|
|
102
|
-
this.resetTime = options?.resetTime;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Internal server error (500)
|
|
108
|
-
*/
|
|
109
|
-
export class InternalServerError extends TuturuuuError {
|
|
110
|
-
constructor(message: string, code?: string) {
|
|
111
|
-
super(message, code, 500);
|
|
112
|
-
this.name = 'InternalServerError';
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Network error
|
|
118
|
-
*/
|
|
119
|
-
export class NetworkError extends TuturuuuError {
|
|
120
|
-
constructor(message: string) {
|
|
121
|
-
super(message, 'NETWORK_ERROR');
|
|
122
|
-
this.name = 'NetworkError';
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Validation error
|
|
128
|
-
*/
|
|
129
|
-
export class ValidationError extends TuturuuuError {
|
|
130
|
-
constructor(message: string) {
|
|
131
|
-
super(message, 'VALIDATION_ERROR', 400);
|
|
132
|
-
this.name = 'ValidationError';
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Options for creating a rate limit error from response headers
|
|
138
|
-
*/
|
|
139
|
-
export interface RateLimitHeaders {
|
|
140
|
-
retryAfter?: string | null;
|
|
141
|
-
resetTime?: string | null;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Helper function to create appropriate error from API response
|
|
146
|
-
*/
|
|
147
|
-
export function createErrorFromResponse(
|
|
148
|
-
response: ApiErrorResponse,
|
|
149
|
-
statusCode: number,
|
|
150
|
-
rateLimitHeaders?: RateLimitHeaders
|
|
151
|
-
): TuturuuuError {
|
|
152
|
-
const { message, code } = response;
|
|
153
|
-
|
|
154
|
-
switch (statusCode) {
|
|
155
|
-
case 400:
|
|
156
|
-
return new BadRequestError(message, code);
|
|
157
|
-
case 401:
|
|
158
|
-
return new AuthenticationError(message, code);
|
|
159
|
-
case 403:
|
|
160
|
-
return new AuthorizationError(message, code);
|
|
161
|
-
case 404:
|
|
162
|
-
return new NotFoundError(message, code);
|
|
163
|
-
case 409:
|
|
164
|
-
return new ConflictError(message, code);
|
|
165
|
-
case 429:
|
|
166
|
-
return new RateLimitError(message, {
|
|
167
|
-
code,
|
|
168
|
-
retryAfter: parseIntSafe(rateLimitHeaders?.retryAfter),
|
|
169
|
-
resetTime: parseIntSafe(rateLimitHeaders?.resetTime),
|
|
170
|
-
});
|
|
171
|
-
case 500:
|
|
172
|
-
case 502:
|
|
173
|
-
case 503:
|
|
174
|
-
case 504:
|
|
175
|
-
return new InternalServerError(message, code);
|
|
176
|
-
default:
|
|
177
|
-
return new TuturuuuError(message, code, statusCode);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* Safely parse a string to integer, returning undefined for invalid values
|
|
183
|
-
*/
|
|
184
|
-
function parseIntSafe(value: string | null | undefined): number | undefined {
|
|
185
|
-
if (!value) return undefined;
|
|
186
|
-
const parsed = parseInt(value, 10);
|
|
187
|
-
return Number.isNaN(parsed) || parsed < 0 ? undefined : parsed;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* Type guard to check if an object is an ApiErrorResponse
|
|
192
|
-
*/
|
|
193
|
-
export function isApiErrorResponse(obj: unknown): obj is ApiErrorResponse {
|
|
194
|
-
return (
|
|
195
|
-
typeof obj === 'object' &&
|
|
196
|
-
obj !== null &&
|
|
197
|
-
'error' in obj &&
|
|
198
|
-
'message' in obj &&
|
|
199
|
-
typeof (obj as any).error === 'string' &&
|
|
200
|
-
typeof (obj as any).message === 'string'
|
|
201
|
-
);
|
|
202
|
-
}
|
package/src/external-projects.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
EpmClient,
|
|
3
|
-
type EpmClientConfig as ExternalProjectsClientConfig,
|
|
4
|
-
isYoolaExternalProjectLoadingData,
|
|
5
|
-
} from './epm';
|
|
6
|
-
|
|
7
|
-
export type { ExternalProjectsClientConfig };
|
|
8
|
-
|
|
9
|
-
export class ExternalProjectsClient extends EpmClient {}
|
|
10
|
-
|
|
11
|
-
export { isYoolaExternalProjectLoadingData };
|
package/src/index.ts
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tuturuuu SDK
|
|
3
|
-
*
|
|
4
|
-
* Official TypeScript/JavaScript SDK for interacting with the Tuturuuu platform.
|
|
5
|
-
* Provides access to storage (files/folders) and documents via API keys.
|
|
6
|
-
*
|
|
7
|
-
* @packageDocumentation
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
export type { EpmClientConfig } from './epm';
|
|
11
|
-
export {
|
|
12
|
-
buildEpmNavigationItems,
|
|
13
|
-
EpmClient,
|
|
14
|
-
getEpmCollectionNavigationConfig,
|
|
15
|
-
getEpmCollectionNavigationTitle,
|
|
16
|
-
isYoolaExternalProjectLoadingData,
|
|
17
|
-
} from './epm';
|
|
18
|
-
// Errors
|
|
19
|
-
export {
|
|
20
|
-
AuthenticationError,
|
|
21
|
-
AuthorizationError,
|
|
22
|
-
BadRequestError,
|
|
23
|
-
ConflictError,
|
|
24
|
-
createErrorFromResponse,
|
|
25
|
-
InternalServerError,
|
|
26
|
-
isApiErrorResponse,
|
|
27
|
-
NetworkError,
|
|
28
|
-
NotFoundError,
|
|
29
|
-
RateLimitError,
|
|
30
|
-
TuturuuuError,
|
|
31
|
-
ValidationError,
|
|
32
|
-
} from './errors';
|
|
33
|
-
export type { ExternalProjectsClientConfig } from './external-projects';
|
|
34
|
-
export { ExternalProjectsClient } from './external-projects';
|
|
35
|
-
export type { RetryConfig, TuturuuuClientConfig } from './storage';
|
|
36
|
-
// Main client
|
|
37
|
-
/**
|
|
38
|
-
* Default Tuturuuu client instance with auto-configured credentials
|
|
39
|
-
*
|
|
40
|
-
* Automatically loads from environment variables:
|
|
41
|
-
* - TUTURUUU_API_KEY (required)
|
|
42
|
-
* - TUTURUUU_BASE_URL (optional, defaults to https://tuturuuu.com/api/v1)
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* ```typescript
|
|
46
|
-
* import { tuturuuu } from 'tuturuuu';
|
|
47
|
-
*
|
|
48
|
-
* const analytics = await tuturuuu.storage.getAnalytics();
|
|
49
|
-
* const files = await tuturuuu.storage.list({ path: 'documents' });
|
|
50
|
-
* ```
|
|
51
|
-
*/
|
|
52
|
-
export {
|
|
53
|
-
DocumentsClient,
|
|
54
|
-
StorageClient,
|
|
55
|
-
TuturuuuClient,
|
|
56
|
-
tuturuuu,
|
|
57
|
-
} from './storage';
|
|
58
|
-
// Types
|
|
59
|
-
export type {
|
|
60
|
-
AnalyticsResponse,
|
|
61
|
-
ApiErrorResponse,
|
|
62
|
-
BatchShareResponse,
|
|
63
|
-
CreateDocumentData,
|
|
64
|
-
CreateFolderResponse,
|
|
65
|
-
CreateSignedUploadUrlOptions,
|
|
66
|
-
DeleteDocumentResponse,
|
|
67
|
-
DeleteResponse,
|
|
68
|
-
Document,
|
|
69
|
-
DocumentResponse,
|
|
70
|
-
DownloadOptions,
|
|
71
|
-
EpmAssetMetadata,
|
|
72
|
-
EpmAssetPayload,
|
|
73
|
-
EpmAssetUpdatePayload,
|
|
74
|
-
EpmAssetUploadOptions,
|
|
75
|
-
EpmBlockPayload,
|
|
76
|
-
EpmBlockUpdatePayload,
|
|
77
|
-
EpmCollectionConfig,
|
|
78
|
-
EpmCollectionNavigationConfig,
|
|
79
|
-
EpmCollectionPayload,
|
|
80
|
-
EpmCollectionUpdatePayload,
|
|
81
|
-
EpmEntryListOptions,
|
|
82
|
-
EpmEntryPayload,
|
|
83
|
-
EpmEntryUpdatePayload,
|
|
84
|
-
EpmPublishEventKind,
|
|
85
|
-
ExternalProjectAdapterKind,
|
|
86
|
-
ExternalProjectAttentionItem,
|
|
87
|
-
ExternalProjectBulkUpdateAction,
|
|
88
|
-
ExternalProjectBulkUpdatePayload,
|
|
89
|
-
ExternalProjectCollection,
|
|
90
|
-
ExternalProjectDeliveryAsset,
|
|
91
|
-
ExternalProjectDeliveryCollection,
|
|
92
|
-
ExternalProjectDeliveryEntry,
|
|
93
|
-
ExternalProjectDeliveryOptions,
|
|
94
|
-
ExternalProjectDeliveryPayload,
|
|
95
|
-
ExternalProjectEntry,
|
|
96
|
-
ExternalProjectEntryStatus,
|
|
97
|
-
ExternalProjectLoadingData,
|
|
98
|
-
ExternalProjectStudioData,
|
|
99
|
-
ExternalProjectSummary,
|
|
100
|
-
ExternalProjectSummaryCollection,
|
|
101
|
-
ExternalProjectSummaryCounts,
|
|
102
|
-
ExternalProjectSummaryQueues,
|
|
103
|
-
GetDocumentResponse,
|
|
104
|
-
ImageResizeMode,
|
|
105
|
-
ImageTransformOptions,
|
|
106
|
-
ListDocumentsOptions,
|
|
107
|
-
ListDocumentsResponse,
|
|
108
|
-
ListStorageOptions,
|
|
109
|
-
ListStorageResponse,
|
|
110
|
-
Pagination,
|
|
111
|
-
ShareOptions,
|
|
112
|
-
ShareResponse,
|
|
113
|
-
SignedUploadUrlResponse,
|
|
114
|
-
SignedUrlData,
|
|
115
|
-
StorageAnalytics,
|
|
116
|
-
StorageObject,
|
|
117
|
-
UpdateDocumentData,
|
|
118
|
-
UploadOptions,
|
|
119
|
-
UploadResponse,
|
|
120
|
-
WorkspaceExternalProjectBinding,
|
|
121
|
-
YoolaExternalProjectArtworkLoadingItem,
|
|
122
|
-
YoolaExternalProjectLoadingData,
|
|
123
|
-
YoolaExternalProjectLoreCapsuleLoadingItem,
|
|
124
|
-
YoolaExternalProjectSectionLoadingItem,
|
|
125
|
-
} from './types';
|
|
126
|
-
// Zod schemas (for external validation if needed)
|
|
127
|
-
export {
|
|
128
|
-
createDocumentDataSchema,
|
|
129
|
-
createSignedUploadUrlOptionsSchema,
|
|
130
|
-
downloadOptionsSchema,
|
|
131
|
-
externalProjectDeliveryOptionsSchema,
|
|
132
|
-
imageTransformOptionsSchema,
|
|
133
|
-
listDocumentsOptionsSchema,
|
|
134
|
-
listStorageOptionsSchema,
|
|
135
|
-
shareOptionsSchema,
|
|
136
|
-
updateDocumentDataSchema,
|
|
137
|
-
uploadOptionsSchema,
|
|
138
|
-
} from './types';
|