@lilaquadrat/storage-sdk 0.1.2
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/CHANGELOG.md +29 -0
- package/README.md +183 -0
- package/lib/index.d.ts +102 -0
- package/lib/index.js +261 -0
- package/lib/index.js.map +1 -0
- package/package.json +61 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
|
+
|
|
5
|
+
### [0.1.2](https://ssh.dev.azure.com/v3/lilaquadrat/studio-packages/storage-sdk/compare/v0.1.1...v0.1.2) (2025-12-12)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **studio:** updated studio beta app ([1b6f414](https://ssh.dev.azure.com/v3/lilaquadrat/studio-packages/storage-sdk/commit/1b6f414702acaaff75f53997ffb1caa6bc2e8ce9))
|
|
11
|
+
|
|
12
|
+
### 0.1.1 (2025-12-12)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* **interfaces:** updated interfaces ([8d3e48f](https://ssh.dev.azure.com/v3/lilaquadrat/studio-packages/storage-sdk/commit/8d3e48fe469c47e4227b698c54758fc22db322a9))
|
|
18
|
+
|
|
19
|
+
## [0.1.0] - 2025-12-11
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
- Initial release of @lilaquadrat/storage-sdk
|
|
23
|
+
- Support for file uploads (single and multiple)
|
|
24
|
+
- Support for file downloads
|
|
25
|
+
- Support for listing files with filtering
|
|
26
|
+
- Access token management with automatic caching
|
|
27
|
+
- Chunked upload support for large files
|
|
28
|
+
- Configurable concurrency for batch uploads
|
|
29
|
+
- Logging support with configurable log levels
|
package/README.md
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# @lilaquadrat/storage-sdk
|
|
2
|
+
|
|
3
|
+
SDK for accessing STUDIO storage/media API with support for file uploads, downloads, and listing.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @lilaquadrat/storage-sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
or
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
yarn add @lilaquadrat/storage-sdk
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import StorageSDK from '@lilaquadrat/storage-sdk';
|
|
21
|
+
|
|
22
|
+
// Initialize the SDK
|
|
23
|
+
const storage = new StorageSDK(
|
|
24
|
+
{
|
|
25
|
+
api: 'https://media.lilaquadrat.studio',
|
|
26
|
+
public: 'https://cdn.lilaquadrat.studio',
|
|
27
|
+
secure: 'https://secure.lilaquadrat.studio',
|
|
28
|
+
},
|
|
29
|
+
5, // concurrency
|
|
30
|
+
'info', // log level: 'debug' | 'info' | 'none'
|
|
31
|
+
'your-access-token' // optional access token
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
// Upload a single file
|
|
35
|
+
await storage.upload(
|
|
36
|
+
{
|
|
37
|
+
filename: 'example.jpg',
|
|
38
|
+
size: 1024,
|
|
39
|
+
mimetype: 'image/jpeg',
|
|
40
|
+
fullPath: '/path/to/example.jpg'
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
app: 'media',
|
|
44
|
+
company: 'your-company',
|
|
45
|
+
project: 'your-project',
|
|
46
|
+
thumbnails: true,
|
|
47
|
+
overwrite: false
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
// Upload multiple files
|
|
52
|
+
await storage.uploadMultiple(
|
|
53
|
+
[
|
|
54
|
+
{ filename: 'file1.jpg', size: 1024, mimetype: 'image/jpeg', fullPath: '/path/to/file1.jpg' },
|
|
55
|
+
{ filename: 'file2.png', size: 2048, mimetype: 'image/png', fullPath: '/path/to/file2.png' }
|
|
56
|
+
],
|
|
57
|
+
{
|
|
58
|
+
app: 'media',
|
|
59
|
+
company: 'your-company',
|
|
60
|
+
project: 'your-project'
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
// List files
|
|
65
|
+
const result = await storage.list(
|
|
66
|
+
{
|
|
67
|
+
app: 'media',
|
|
68
|
+
company: 'your-company',
|
|
69
|
+
project: 'your-project'
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
tags: ['image'],
|
|
73
|
+
prefix: 'uploads/',
|
|
74
|
+
ignorePrefix: false
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
// Download a file
|
|
79
|
+
const buffer = await storage.download({
|
|
80
|
+
app: 'media',
|
|
81
|
+
company: 'your-company',
|
|
82
|
+
project: 'your-project',
|
|
83
|
+
prefix: 'uploads',
|
|
84
|
+
filename: 'example.jpg'
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// Get access token
|
|
88
|
+
const token = await storage.getAccessToken('html', 'your-company', 'your-project');
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## API
|
|
92
|
+
|
|
93
|
+
### Constructor
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
new StorageSDK(endpoints: Endpoints, concurrency?: number, logLevel?: LogLevel, accessToken?: string)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
- `endpoints`: Object containing API endpoints (api, public, secure)
|
|
100
|
+
- `concurrency`: Number of concurrent uploads (default: 5)
|
|
101
|
+
- `logLevel`: Logging level - 'debug', 'info', or 'none' (default: 'info')
|
|
102
|
+
- `accessToken`: Optional access token for authentication
|
|
103
|
+
|
|
104
|
+
### Methods
|
|
105
|
+
|
|
106
|
+
#### `upload(file: UploadFile, options: UploadOptions)`
|
|
107
|
+
Upload a single file to the storage.
|
|
108
|
+
|
|
109
|
+
#### `uploadMultiple(files: UploadFile[], options: UploadOptions)`
|
|
110
|
+
Upload multiple files with concurrency control.
|
|
111
|
+
|
|
112
|
+
#### `list(options: Options, params?: ListFilesParams)`
|
|
113
|
+
List files in the storage with optional filtering.
|
|
114
|
+
|
|
115
|
+
#### `download(blob: Storage): Promise<Buffer>`
|
|
116
|
+
Download a file from the storage.
|
|
117
|
+
|
|
118
|
+
#### `getAccessToken(app: string, company: string, project: string): Promise<string>`
|
|
119
|
+
Get an access token for downloading files from secured endpoints. Tokens are cached automatically.
|
|
120
|
+
|
|
121
|
+
## Types
|
|
122
|
+
|
|
123
|
+
### UploadFile
|
|
124
|
+
```typescript
|
|
125
|
+
type UploadFile = {
|
|
126
|
+
filename: string;
|
|
127
|
+
size: number;
|
|
128
|
+
mimetype: string;
|
|
129
|
+
fullPath: string;
|
|
130
|
+
};
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### ListFilesParams
|
|
134
|
+
```typescript
|
|
135
|
+
type ListFilesParams = {
|
|
136
|
+
tags?: string[];
|
|
137
|
+
prefix?: string;
|
|
138
|
+
ignorePrefix?: boolean;
|
|
139
|
+
};
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Endpoints
|
|
143
|
+
```typescript
|
|
144
|
+
type Endpoints = {
|
|
145
|
+
api: string;
|
|
146
|
+
public: string;
|
|
147
|
+
secure: string;
|
|
148
|
+
};
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Development
|
|
152
|
+
|
|
153
|
+
### Building
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
yarn build
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Publishing to npm
|
|
160
|
+
|
|
161
|
+
1. Make sure you're logged in to npm:
|
|
162
|
+
```bash
|
|
163
|
+
npm login
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
2. Update the version and generate changelog:
|
|
167
|
+
```bash
|
|
168
|
+
yarn release
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
3. Publish to npm:
|
|
172
|
+
```bash
|
|
173
|
+
npm publish
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
4. Push the changes and tags:
|
|
177
|
+
```bash
|
|
178
|
+
git push --follow-tags origin main
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## License
|
|
182
|
+
|
|
183
|
+
MIT
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { ObjectIdString, Options, Storage, Upload } from '@lilaquadrat/interfaces';
|
|
2
|
+
type UploadFile = {
|
|
3
|
+
filename: string;
|
|
4
|
+
size: number;
|
|
5
|
+
mimetype: string;
|
|
6
|
+
fullPath: string;
|
|
7
|
+
};
|
|
8
|
+
type LogLevel = 'debug' | 'info' | 'none';
|
|
9
|
+
type ListFilesParams = {
|
|
10
|
+
tags?: string[];
|
|
11
|
+
prefix?: string;
|
|
12
|
+
ignorePrefix?: boolean;
|
|
13
|
+
};
|
|
14
|
+
type Endpoints = {
|
|
15
|
+
api: string;
|
|
16
|
+
public: string;
|
|
17
|
+
secure: string;
|
|
18
|
+
};
|
|
19
|
+
type TokenResponse = {
|
|
20
|
+
token: string;
|
|
21
|
+
expiresIn: number;
|
|
22
|
+
createdAt: number;
|
|
23
|
+
expiresAt: number;
|
|
24
|
+
};
|
|
25
|
+
type CachedToken = {
|
|
26
|
+
token: string;
|
|
27
|
+
expiresAt: number;
|
|
28
|
+
};
|
|
29
|
+
declare class StorageSDK {
|
|
30
|
+
endpoints: {
|
|
31
|
+
api: string;
|
|
32
|
+
public: string;
|
|
33
|
+
secure: string;
|
|
34
|
+
};
|
|
35
|
+
options: {
|
|
36
|
+
chunkSize: number;
|
|
37
|
+
};
|
|
38
|
+
concurrency: number;
|
|
39
|
+
logLevel: LogLevel;
|
|
40
|
+
accessToken?: string;
|
|
41
|
+
private tokenCache;
|
|
42
|
+
constructor(endpoints: Endpoints, concurrency?: number, logLevel?: LogLevel, accessToken?: string);
|
|
43
|
+
private log;
|
|
44
|
+
private createHeaders;
|
|
45
|
+
private createTokenCacheKey;
|
|
46
|
+
calculateChunks(fileSize: number, maxUploadSize: number): number;
|
|
47
|
+
createUrl(input: string[], query?: Record<string, string>): string;
|
|
48
|
+
createUpload(filename: UploadFile, options: Required<Options> & Upload['options'] & Pick<Upload, 'app'>): Promise<{
|
|
49
|
+
url: string;
|
|
50
|
+
method: string | undefined;
|
|
51
|
+
init: RequestInit | undefined;
|
|
52
|
+
ok: boolean;
|
|
53
|
+
status: number;
|
|
54
|
+
statusText: string;
|
|
55
|
+
headers: Headers;
|
|
56
|
+
body: any;
|
|
57
|
+
}>;
|
|
58
|
+
uploadChunk(uploadId: ObjectIdString, file: string, options: Required<Options> & Pick<Upload, 'app'>): Promise<{
|
|
59
|
+
url: string;
|
|
60
|
+
init: RequestInit;
|
|
61
|
+
}[]>;
|
|
62
|
+
executeCall(input: RequestInfo, init?: RequestInit): Promise<{
|
|
63
|
+
url: string;
|
|
64
|
+
method: string | undefined;
|
|
65
|
+
init: RequestInit | undefined;
|
|
66
|
+
ok: boolean;
|
|
67
|
+
status: number;
|
|
68
|
+
statusText: string;
|
|
69
|
+
headers: Headers;
|
|
70
|
+
body: any;
|
|
71
|
+
}>;
|
|
72
|
+
list(options: Required<Options> & Pick<Upload, 'app'>, params?: ListFilesParams): Promise<{
|
|
73
|
+
url: string;
|
|
74
|
+
method: string | undefined;
|
|
75
|
+
init: RequestInit | undefined;
|
|
76
|
+
ok: boolean;
|
|
77
|
+
status: number;
|
|
78
|
+
statusText: string;
|
|
79
|
+
headers: Headers;
|
|
80
|
+
body: any;
|
|
81
|
+
}>;
|
|
82
|
+
/**
|
|
83
|
+
*
|
|
84
|
+
* get a access token to download files from secured endpoints
|
|
85
|
+
* @param app
|
|
86
|
+
* @param company
|
|
87
|
+
* @param project
|
|
88
|
+
* @returns
|
|
89
|
+
*/
|
|
90
|
+
getAccessToken(app: string, company: string, project: string): Promise<string>;
|
|
91
|
+
download(blob: Storage): Promise<Buffer>;
|
|
92
|
+
upload(file: UploadFile, options: Required<Options> & Upload['options'] & Pick<Upload, 'app'>): Promise<{
|
|
93
|
+
success: boolean;
|
|
94
|
+
file: string;
|
|
95
|
+
}>;
|
|
96
|
+
uploadMultiple(files: UploadFile[], options: Required<Options> & Upload['options'] & Pick<Upload, 'app'>): Promise<{
|
|
97
|
+
successCount: number;
|
|
98
|
+
failureCount: number;
|
|
99
|
+
}>;
|
|
100
|
+
}
|
|
101
|
+
export default StorageSDK;
|
|
102
|
+
export type { UploadFile, LogLevel, ListFilesParams, Endpoints, TokenResponse, CachedToken };
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import fs from 'fs';
|
|
11
|
+
import chalk from 'chalk';
|
|
12
|
+
import { batch } from '@lilaquadrat/studio/lib/helpers';
|
|
13
|
+
class StorageSDK {
|
|
14
|
+
constructor(endpoints, concurrency = 5, logLevel = 'info', accessToken) {
|
|
15
|
+
this.endpoints = {
|
|
16
|
+
api: 'https://media.lilaquadrat.studio',
|
|
17
|
+
public: 'https://cdn.lilaquadrat.studio',
|
|
18
|
+
secure: 'https://secure.lilaquadrat.studio',
|
|
19
|
+
};
|
|
20
|
+
this.options = {
|
|
21
|
+
chunkSize: 6 * 1024 * 1024,
|
|
22
|
+
};
|
|
23
|
+
this.tokenCache = new Map();
|
|
24
|
+
this.endpoints = endpoints;
|
|
25
|
+
this.concurrency = concurrency;
|
|
26
|
+
this.logLevel = logLevel;
|
|
27
|
+
this.accessToken = accessToken;
|
|
28
|
+
}
|
|
29
|
+
log(level, message, ...args) {
|
|
30
|
+
const levels = ['none', 'info', 'debug'];
|
|
31
|
+
const currentLevelIndex = levels.indexOf(this.logLevel);
|
|
32
|
+
const messageLevelIndex = levels.indexOf(level);
|
|
33
|
+
if (messageLevelIndex <= currentLevelIndex) {
|
|
34
|
+
console.log(message, ...args);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
createHeaders(additionalHeaders) {
|
|
38
|
+
const headers = Object.assign({ 'studio-app': 'cli' }, additionalHeaders);
|
|
39
|
+
if (this.accessToken) {
|
|
40
|
+
headers.Authorization = `Bearer ${this.accessToken}`;
|
|
41
|
+
}
|
|
42
|
+
return headers;
|
|
43
|
+
}
|
|
44
|
+
createTokenCacheKey(app, company, project) {
|
|
45
|
+
return `${app}:${company}:${project}`;
|
|
46
|
+
}
|
|
47
|
+
calculateChunks(fileSize, maxUploadSize) {
|
|
48
|
+
if (fileSize > maxUploadSize) {
|
|
49
|
+
return Math.ceil(fileSize / maxUploadSize);
|
|
50
|
+
}
|
|
51
|
+
return 1;
|
|
52
|
+
}
|
|
53
|
+
createUrl(input, query) {
|
|
54
|
+
const baseUrl = input.filter((single) => single).join('/');
|
|
55
|
+
if (!query || Object.keys(query).length === 0) {
|
|
56
|
+
return baseUrl;
|
|
57
|
+
}
|
|
58
|
+
const params = new URLSearchParams(query);
|
|
59
|
+
return `${baseUrl}?${params.toString()}`;
|
|
60
|
+
}
|
|
61
|
+
createUpload(filename, options) {
|
|
62
|
+
const payload = Object.assign(Object.assign({}, filename), { chunks: this.calculateChunks(filename.size, this.options.chunkSize), options: {} });
|
|
63
|
+
if (options.thumbnails) {
|
|
64
|
+
if (!payload.options)
|
|
65
|
+
payload.options = {};
|
|
66
|
+
payload.options.thumbnails = true;
|
|
67
|
+
}
|
|
68
|
+
if (options.overwrite) {
|
|
69
|
+
if (!payload.options)
|
|
70
|
+
payload.options = {};
|
|
71
|
+
payload.options.overwrite = true;
|
|
72
|
+
}
|
|
73
|
+
const body = JSON.stringify(payload);
|
|
74
|
+
return this.executeCall(this.createUrl([this.endpoints.api, options.app || '', options.company, options.project, 'upload']), {
|
|
75
|
+
method: 'POST',
|
|
76
|
+
headers: this.createHeaders({ 'Content-Type': 'application/json' }),
|
|
77
|
+
body,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
uploadChunk(uploadId, file, options) {
|
|
81
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
const fileContent = fs.readFileSync(file);
|
|
83
|
+
const totalChunks = this.calculateChunks(fileContent.length, this.options.chunkSize);
|
|
84
|
+
const chunks = totalChunks || 1;
|
|
85
|
+
const calls = [];
|
|
86
|
+
for (let index = 0; index < chunks; index++) {
|
|
87
|
+
const start = index * this.options.chunkSize;
|
|
88
|
+
const end = Math.min(start + this.options.chunkSize, fileContent.length);
|
|
89
|
+
const chunk = fileContent.subarray(start, end);
|
|
90
|
+
const blob = new Blob([chunk]);
|
|
91
|
+
const form = new FormData();
|
|
92
|
+
form.append('file', blob);
|
|
93
|
+
form.append('index', index.toString());
|
|
94
|
+
calls.push({
|
|
95
|
+
url: this.createUrl([this.endpoints.api, options.app || '', options.company, options.project, uploadId]),
|
|
96
|
+
init: {
|
|
97
|
+
method: 'POST',
|
|
98
|
+
headers: this.createHeaders(),
|
|
99
|
+
body: form,
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
return calls;
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
executeCall(input, init) {
|
|
107
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
108
|
+
const response = yield fetch(input, init);
|
|
109
|
+
let body = null;
|
|
110
|
+
const contentType = response.headers.get('content-type');
|
|
111
|
+
if (contentType === null || contentType === void 0 ? void 0 : contentType.includes('application/json')) {
|
|
112
|
+
body = yield response.json();
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
const text = yield response.text();
|
|
116
|
+
body = text || null;
|
|
117
|
+
}
|
|
118
|
+
return {
|
|
119
|
+
url: input.toString(),
|
|
120
|
+
method: init === null || init === void 0 ? void 0 : init.method,
|
|
121
|
+
init,
|
|
122
|
+
ok: response.ok,
|
|
123
|
+
status: response.status,
|
|
124
|
+
statusText: response.statusText,
|
|
125
|
+
headers: response.headers,
|
|
126
|
+
body,
|
|
127
|
+
};
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
list(options, params) {
|
|
131
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
132
|
+
var _a;
|
|
133
|
+
const url = new URL(this.createUrl([this.endpoints.api, options.app || '', options.company, options.project, 'list']));
|
|
134
|
+
console.log('list', url);
|
|
135
|
+
if ((_a = params === null || params === void 0 ? void 0 : params.tags) === null || _a === void 0 ? void 0 : _a.length) {
|
|
136
|
+
params.tags.forEach((tag) => url.searchParams.append('tags', tag));
|
|
137
|
+
}
|
|
138
|
+
if (params === null || params === void 0 ? void 0 : params.prefix) {
|
|
139
|
+
url.searchParams.set('prefix', params.prefix);
|
|
140
|
+
}
|
|
141
|
+
if ((params === null || params === void 0 ? void 0 : params.ignorePrefix) !== undefined) {
|
|
142
|
+
url.searchParams.set('ignorePrefix', String(params.ignorePrefix));
|
|
143
|
+
}
|
|
144
|
+
return this.executeCall(url.toString(), {
|
|
145
|
+
method: 'GET',
|
|
146
|
+
headers: this.createHeaders(),
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
*
|
|
152
|
+
* get a access token to download files from secured endpoints
|
|
153
|
+
* @param app
|
|
154
|
+
* @param company
|
|
155
|
+
* @param project
|
|
156
|
+
* @returns
|
|
157
|
+
*/
|
|
158
|
+
getAccessToken(app, company, project) {
|
|
159
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
160
|
+
var _a;
|
|
161
|
+
const now = Math.floor(Date.now() / 1000);
|
|
162
|
+
const bufferTime = 300; // 5 minutes buffer before expiration
|
|
163
|
+
const cacheKey = this.createTokenCacheKey(app, company, project);
|
|
164
|
+
const cachedToken = this.tokenCache.get(cacheKey);
|
|
165
|
+
// Check if we have a valid cached token
|
|
166
|
+
if (cachedToken && (cachedToken.expiresAt - now) > bufferTime) {
|
|
167
|
+
return cachedToken.token;
|
|
168
|
+
}
|
|
169
|
+
const url = this.createUrl([this.endpoints.api, app, company, project, 'token']);
|
|
170
|
+
const response = yield this.executeCall(url.toString(), {
|
|
171
|
+
method: 'GET',
|
|
172
|
+
headers: this.createHeaders(),
|
|
173
|
+
});
|
|
174
|
+
if (!response.ok) {
|
|
175
|
+
throw new Error(`GET_ACCESS_TOKEN_FAILED_${response.status}_${((_a = response.body) === null || _a === void 0 ? void 0 : _a.message) || response.statusText}`);
|
|
176
|
+
}
|
|
177
|
+
// Cache the token if the request was successful
|
|
178
|
+
if (response.body) {
|
|
179
|
+
const tokenData = response.body;
|
|
180
|
+
this.tokenCache.set(cacheKey, {
|
|
181
|
+
token: tokenData.token,
|
|
182
|
+
expiresAt: tokenData.expiresAt,
|
|
183
|
+
});
|
|
184
|
+
return tokenData.token;
|
|
185
|
+
}
|
|
186
|
+
throw new Error('GET_ACCESS_TOKEN_FAILED_NO_BODY');
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
download(blob) {
|
|
190
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
191
|
+
if (!blob.company || !blob.project || !blob.prefix || !blob.filename) {
|
|
192
|
+
throw new Error('DOWNLOAD_FAILED_MISSING_REQUIRED_FIELDS');
|
|
193
|
+
}
|
|
194
|
+
const endpoint = blob.app === 'media'
|
|
195
|
+
? this.endpoints.public
|
|
196
|
+
: this.endpoints.secure;
|
|
197
|
+
const app = blob.app !== 'media'
|
|
198
|
+
? blob.app
|
|
199
|
+
: undefined;
|
|
200
|
+
const token = yield this.getAccessToken('html', blob.company, blob.project);
|
|
201
|
+
const url = this.createUrl([endpoint, app, blob.company, blob.project, blob.prefix, blob.filename].filter(Boolean), { token });
|
|
202
|
+
const response = yield fetch(url);
|
|
203
|
+
if (!response.ok) {
|
|
204
|
+
throw new Error(`DOWNLOAD_FAILED_${response.status}_${response.statusText}`);
|
|
205
|
+
}
|
|
206
|
+
const arrayBuffer = yield response.arrayBuffer();
|
|
207
|
+
return Buffer.from(arrayBuffer);
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
upload(file, options) {
|
|
211
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
212
|
+
var _a;
|
|
213
|
+
// Create upload record
|
|
214
|
+
const uploadResponse = yield this.createUpload(file, options);
|
|
215
|
+
if (!uploadResponse.ok || !uploadResponse.body) {
|
|
216
|
+
throw new Error(`CREATE_UPLOAD_FAILED_${uploadResponse.status}_${((_a = uploadResponse.body) === null || _a === void 0 ? void 0 : _a.message) || 'No body'}`);
|
|
217
|
+
}
|
|
218
|
+
// Get upload calls for this file
|
|
219
|
+
const uploadCalls = yield this.uploadChunk(uploadResponse.body, file.fullPath, { company: options.company, project: options.project, app: options.app });
|
|
220
|
+
// Execute all chunks for this file sequentially
|
|
221
|
+
for (const call of uploadCalls) {
|
|
222
|
+
const result = yield this.executeCall(call.url, call.init);
|
|
223
|
+
if (!result.ok) {
|
|
224
|
+
throw new Error(`Chunk upload failed: ${result.statusText}`);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return { success: true, file: file.filename };
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
uploadMultiple(files, options) {
|
|
231
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
232
|
+
this.log('info', chalk.bgBlue.white(`Found ${files.length} files to upload`));
|
|
233
|
+
this.log('debug', chalk.bgBlue.white(`Using concurrency limit: ${this.concurrency}`));
|
|
234
|
+
this.log('info', ' ');
|
|
235
|
+
let successCount = 0;
|
|
236
|
+
let failureCount = 0;
|
|
237
|
+
yield batch(files, (file, index) => __awaiter(this, void 0, void 0, function* () {
|
|
238
|
+
try {
|
|
239
|
+
this.log('debug', chalk.gray(`[${index + 1}/${files.length}] Processing: ${file.filename}`));
|
|
240
|
+
yield this.upload(file, options);
|
|
241
|
+
successCount++;
|
|
242
|
+
this.log('info', chalk.green(`✓ [${index + 1}/${files.length}] Uploaded: ${file.filename}`));
|
|
243
|
+
}
|
|
244
|
+
catch (error) {
|
|
245
|
+
failureCount++;
|
|
246
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
247
|
+
console.error(chalk.red(`✗ [${index + 1}/${files.length}] Failed: ${file.filename} - ${errorMessage}`));
|
|
248
|
+
throw error;
|
|
249
|
+
}
|
|
250
|
+
}), this.concurrency);
|
|
251
|
+
this.log('info', ' ');
|
|
252
|
+
this.log('info', chalk.bgGreen.black(`Successfully uploaded: ${successCount} files`));
|
|
253
|
+
if (failureCount > 0) {
|
|
254
|
+
console.log(chalk.bgRed.white(`Failed to upload: ${failureCount} files`));
|
|
255
|
+
}
|
|
256
|
+
return { successCount, failureCount };
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
export default StorageSDK;
|
|
261
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAC;AAmCxD,MAAM,UAAU;IAoBd,YAAY,SAAoB,EAAE,cAAsB,CAAC,EAAE,WAAqB,MAAM,EAAE,WAAoB;QAlB5G,cAAS,GAAG;YACV,GAAG,EAAE,kCAAkC;YACvC,MAAM,EAAE,gCAAgC;YACxC,MAAM,EAAE,mCAAmC;SAC5C,CAAC;QAEF,YAAO,GAAG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I,CAAC,QAAQ,MAAM,YAAY,EAAE,CAAC,CAAC,CAAC;oBACxG,MAAM,KAAK,CAAC;gBAEd,CAAC;YAEH,CAAC,CAAA,EACD,IAAI,CAAC,WAAW,CACjB,CAAC;YAEF,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YACvB,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,0BAA0B,YAAY,QAAQ,CAAC,CAAC,CAAC;YAEtF,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;gBAErB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,qBAAqB,YAAY,QAAQ,CAAC,CAAC,CAAC;YAE5E,CAAC;YAED,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC;QAExC,CAAC;KAAA;CAEF;AAED,eAAe,UAAU,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lilaquadrat/storage-sdk",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "SDK for accessing STUDIO storage/media API",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"author": {
|
|
7
|
+
"email": "m.schuebel@lila2.de",
|
|
8
|
+
"name": "Mathias Schübel",
|
|
9
|
+
"url": "https://lilaquadrat.de"
|
|
10
|
+
},
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"homepage": "https://lilaquadrat.de",
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsc",
|
|
15
|
+
"prepare": "tsc",
|
|
16
|
+
"release": "standard-version",
|
|
17
|
+
"test": "jest",
|
|
18
|
+
"test:coverage": "jest --coverage",
|
|
19
|
+
"test:watch": "jest --watch"
|
|
20
|
+
},
|
|
21
|
+
"module": "lib/index.js",
|
|
22
|
+
"main": "lib/index.js",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"import": "./lib/index.js",
|
|
26
|
+
"types": "./lib/index.d.ts"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"types": "lib/index.d.ts",
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=18"
|
|
32
|
+
},
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"lib/**/*",
|
|
38
|
+
"README.md",
|
|
39
|
+
"CHANGELOG.md"
|
|
40
|
+
],
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@lilaquadrat/interfaces": "^1.32.0",
|
|
43
|
+
"@lilaquadrat/studio": "^10.0.0-beta.2",
|
|
44
|
+
"chalk": "^4.1.2"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@types/jest": "^29.5.10",
|
|
48
|
+
"@types/node": "^18.16.0",
|
|
49
|
+
"commitizen": "^4.3.1",
|
|
50
|
+
"cz-conventional-changelog": "^3.3.0",
|
|
51
|
+
"jest": "^29.5.0",
|
|
52
|
+
"standard-version": "^9.5.0",
|
|
53
|
+
"ts-jest": "^29.0.5",
|
|
54
|
+
"typescript": "^5.0.4"
|
|
55
|
+
},
|
|
56
|
+
"config": {
|
|
57
|
+
"commitizen": {
|
|
58
|
+
"path": "./node_modules/cz-conventional-changelog"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|