@oxyhq/services 5.13.19 → 5.13.21
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/lib/commonjs/core/OxyServices.js.map +1 -1
- package/lib/commonjs/core/mixins/OxyServices.assets.js +63 -27
- package/lib/commonjs/core/mixins/OxyServices.assets.js.map +1 -1
- package/lib/commonjs/core/mixins/OxyServices.utility.js +3 -0
- package/lib/commonjs/core/mixins/OxyServices.utility.js.map +1 -1
- package/lib/module/core/OxyServices.js.map +1 -1
- package/lib/module/core/mixins/OxyServices.assets.js +63 -27
- package/lib/module/core/mixins/OxyServices.assets.js.map +1 -1
- package/lib/module/core/mixins/OxyServices.utility.js +3 -0
- package/lib/module/core/mixins/OxyServices.utility.js.map +1 -1
- package/lib/typescript/core/OxyServices.d.ts +3 -884
- package/lib/typescript/core/OxyServices.d.ts.map +1 -1
- package/lib/typescript/core/mixins/OxyServices.assets.d.ts +13 -0
- package/lib/typescript/core/mixins/OxyServices.assets.d.ts.map +1 -1
- package/lib/typescript/core/mixins/OxyServices.utility.d.ts.map +1 -1
- package/lib/typescript/core/mixins/index.d.ts +6 -0
- package/lib/typescript/core/mixins/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/core/OxyServices.ts +1 -1
- package/src/core/mixins/OxyServices.assets.ts +98 -26
- package/src/core/mixins/OxyServices.utility.ts +3 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OxyServices.d.ts","sourceRoot":"","sources":["../../../src/core/OxyServices.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AACH,OAAO,
|
|
1
|
+
{"version":3,"file":"OxyServices.d.ts","sourceRoot":"","sources":["../../../src/core/OxyServices.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AACH,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,6BAA6B,EAAE,MAAM,sBAAsB,CAAC;AAG7F,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,QAAA,MAAM,mBAAmB,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAwB,CAAC;AAGxF,qBAAa,WAAY,SAAQ,mBAAmB;gBACtC,MAAM,EAAE,SAAS;CAG9B;AAGD,OAAO,EAAE,sBAAsB,EAAE,6BAA6B,EAAE,CAAC;AAEjE;;GAEG;AACH,eAAO,MAAM,aAAa,yBAAyB,CAAC;AAEpD;;GAEG;AACH,eAAO,MAAM,WAAW,KAAqG,CAAC;AAE9H;;;GAGG;AACH,eAAO,MAAM,SAAS,aAAqE,CAAC"}
|
|
@@ -41,6 +41,15 @@ export declare function OxyServicesAssetsMixin<T extends typeof OxyServicesBase>
|
|
|
41
41
|
* Get file content as blob
|
|
42
42
|
*/
|
|
43
43
|
getFileContentAsBlob(fileId: string, variant?: string): Promise<Blob>;
|
|
44
|
+
/**
|
|
45
|
+
* Get batch access to multiple files
|
|
46
|
+
* Returns URLs and access status for each file
|
|
47
|
+
*/
|
|
48
|
+
getBatchFileAccess(fileIds: string[], context?: string): Promise<Record<string, any>>;
|
|
49
|
+
/**
|
|
50
|
+
* Get download URLs for multiple files efficiently
|
|
51
|
+
*/
|
|
52
|
+
getFileDownloadUrls(fileIds: string[], context?: string): Promise<Record<string, string>>;
|
|
44
53
|
/**
|
|
45
54
|
* Upload raw file data
|
|
46
55
|
*/
|
|
@@ -116,6 +125,10 @@ export declare function OxyServicesAssetsMixin<T extends typeof OxyServicesBase>
|
|
|
116
125
|
* @returns The uploaded and linked asset
|
|
117
126
|
*/
|
|
118
127
|
uploadProfileBanner(file: File, userId: string, app?: string): Promise<any>;
|
|
128
|
+
getAssetUrlCacheTTL(expiresIn?: number): number;
|
|
129
|
+
fetchAssetDownloadUrl(fileId: string, variant?: string, cacheTTL?: number, expiresIn?: number): Promise<string | null>;
|
|
130
|
+
fetchAssetContent(url: string, type: "text"): Promise<string>;
|
|
131
|
+
fetchAssetContent(url: string, type: "blob"): Promise<Blob>;
|
|
119
132
|
httpClient: import("../HttpClient").HttpClient;
|
|
120
133
|
requestManager: import("../RequestManager").RequestManager;
|
|
121
134
|
cloudURL: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OxyServices.assets.d.ts","sourceRoot":"","sources":["../../../../src/core/mixins/OxyServices.assets.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACjG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,OAAO,eAAe,EAAE,IAAI,EAAE,CAAC;kBAEvD,GAAG,EAAE;QAO1B;;WAEG;2BACsB,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;QAS9C;;;;WAIG;mCACwB,MAAM,YAAY,MAAM,cAAc,MAAM,GAAG,MAAM;QAehF;;;;WAIG;wCACmC,MAAM,YAAY,MAAM,cAAc,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"OxyServices.assets.d.ts","sourceRoot":"","sources":["../../../../src/core/mixins/OxyServices.assets.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACjG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,OAAO,eAAe,EAAE,IAAI,EAAE,CAAC;kBAEvD,GAAG,EAAE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AAC,MAAM,GAAG,IAAI,CAAC;+BAkBW,MAAM,QAAQ,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;+BACtC,MAAM,QAAQ,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBAhU1C,CAAC;sBACX,CAAC;yBACjB,CAAC;;;;;;iBA+EwB,CAAC;qBACb,CAAC;;;;;MAuPrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OxyServices.utility.d.ts","sourceRoot":"","sources":["../../../../src/core/mixins/OxyServices.utility.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,QAAQ,EAAQ,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAW3D,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,OAAO,eAAe,EAAE,IAAI,EAAE,CAAC;kBAExD,GAAG,EAAE;QAG1B;;WAEG;+BAC0B,MAAM,GAAG,OAAO,CAAC;YAC5C,GAAG,EAAE,MAAM,CAAC;YACZ,KAAK,EAAE,MAAM,CAAC;YACd,WAAW,EAAE,MAAM,CAAC;YACpB,KAAK,CAAC,EAAE,MAAM,CAAC;SAChB,CAAC;QAgBF;;;;;;;;;;;;;;;;;;;;;;;;;;;;WA4BG;uBACW;YACZ,KAAK,CAAC,EAAE,OAAO,CAAC;YAChB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,GAAG,CAAC;YACnC,QAAQ,CAAC,EAAE,OAAO,CAAC;YACnB,OAAO,CAAC,EAAE,OAAO,CAAC;SACnB,IAIS,KAAK,GAAG,EAAE,KAAK,GAAG,EAAE,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"OxyServices.utility.d.ts","sourceRoot":"","sources":["../../../../src/core/mixins/OxyServices.utility.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,QAAQ,EAAQ,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAW3D,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,OAAO,eAAe,EAAE,IAAI,EAAE,CAAC;kBAExD,GAAG,EAAE;QAG1B;;WAEG;+BAC0B,MAAM,GAAG,OAAO,CAAC;YAC5C,GAAG,EAAE,MAAM,CAAC;YACZ,KAAK,EAAE,MAAM,CAAC;YACd,WAAW,EAAE,MAAM,CAAC;YACpB,KAAK,CAAC,EAAE,MAAM,CAAC;SAChB,CAAC;QAgBF;;;;;;;;;;;;;;;;;;;;;;;;;;;;WA4BG;uBACW;YACZ,KAAK,CAAC,EAAE,OAAO,CAAC;YAChB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,GAAG,CAAC;YACnC,QAAQ,CAAC,EAAE,OAAO,CAAC;YACnB,OAAO,CAAC,EAAE,OAAO,CAAC;SACnB,IAIS,KAAK,GAAG,EAAE,KAAK,GAAG,EAAE,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBAiFG,CAAC;sBAA0B,CAAC;yBAA6B,CAAC;;;;;;iBAuB8mE,CAAC;qBAAwB,CAAC;;;;;MAF/uE"}
|
|
@@ -311,6 +311,8 @@ export declare function composeOxyServices(): {
|
|
|
311
311
|
}>;
|
|
312
312
|
getFileContentAsText(fileId: string, variant?: string): Promise<string>;
|
|
313
313
|
getFileContentAsBlob(fileId: string, variant?: string): Promise<Blob>;
|
|
314
|
+
getBatchFileAccess(fileIds: string[], context?: string): Promise<Record<string, any>>;
|
|
315
|
+
getFileDownloadUrls(fileIds: string[], context?: string): Promise<Record<string, string>>;
|
|
314
316
|
uploadRawFile(file: File | Blob, visibility?: "private" | "public" | "unlisted", metadata?: Record<string, any>): Promise<any>;
|
|
315
317
|
calculateSHA256(file: File | Blob): Promise<string>;
|
|
316
318
|
assetInit(sha256: string, size: number, mime: string): Promise<import("..").AssetInitResponse>;
|
|
@@ -327,6 +329,10 @@ export declare function composeOxyServices(): {
|
|
|
327
329
|
assetUpdateVisibility(fileId: string, visibility: "private" | "public" | "unlisted"): Promise<any>;
|
|
328
330
|
uploadAvatar(file: File, userId: string, app?: string): Promise<any>;
|
|
329
331
|
uploadProfileBanner(file: File, userId: string, app?: string): Promise<any>;
|
|
332
|
+
getAssetUrlCacheTTL(expiresIn?: number): number;
|
|
333
|
+
fetchAssetDownloadUrl(fileId: string, variant?: string, cacheTTL?: number, expiresIn?: number): Promise<string | null>;
|
|
334
|
+
fetchAssetContent(url: string, type: "text"): Promise<string>;
|
|
335
|
+
fetchAssetContent(url: string, type: "blob"): Promise<Blob>;
|
|
330
336
|
httpClient: import("../HttpClient").HttpClient;
|
|
331
337
|
requestManager: import("../RequestManager").RequestManager;
|
|
332
338
|
cloudURL: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/mixins/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAetD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB;;;;;;;;;;;;;aA4Bwe,QAAQ,EAAC,QAAS,EAAC,SAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBAAktF,CAAC;sBAA0B,CAAC;yBAA6B,CAAC;;;;;;iBAA4wF,CAAC;qBAAwB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBAAh2F,CAAC;sBAA0B,CAAC;yBAA6B,CAAC;;;;;;iBAA4wF,CAAC;qBAAwB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBAAh2F,CAAC;sBAA0B,CAAC;yBAA6B,CAAC;;;;;;iBAA4wF,CAAC;qBAAwB,CAAC;;;;;;;;;;;;;;;;;;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package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oxyhq/services",
|
|
3
|
-
"version": "5.13.
|
|
3
|
+
"version": "5.13.21",
|
|
4
4
|
"description": "Reusable OxyHQ module to handle authentication, user management, karma system, device-based session management and more 🚀",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
package/src/core/OxyServices.ts
CHANGED
|
@@ -98,7 +98,7 @@ import { composeOxyServices } from './mixins';
|
|
|
98
98
|
* ```
|
|
99
99
|
*/
|
|
100
100
|
// Compose all mixins into the final OxyServices class
|
|
101
|
-
const OxyServicesComposed = composeOxyServices();
|
|
101
|
+
const OxyServicesComposed: ReturnType<typeof composeOxyServices> = composeOxyServices();
|
|
102
102
|
|
|
103
103
|
// Export as a named class to avoid TypeScript issues with anonymous class types
|
|
104
104
|
export class OxyServices extends OxyServicesComposed {
|
|
@@ -52,16 +52,14 @@ export function OxyServicesAssetsMixin<T extends typeof OxyServicesBase>(Base: T
|
|
|
52
52
|
*/
|
|
53
53
|
async getFileDownloadUrlAsync(fileId: string, variant?: string, expiresIn?: number): Promise<string> {
|
|
54
54
|
try {
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return urlRes?.url || this.getFileDownloadUrl(fileId, variant, expiresIn);
|
|
55
|
+
const url = await this.fetchAssetDownloadUrl(
|
|
56
|
+
fileId,
|
|
57
|
+
variant,
|
|
58
|
+
this.getAssetUrlCacheTTL(expiresIn),
|
|
59
|
+
expiresIn
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
return url || this.getFileDownloadUrl(fileId, variant, expiresIn);
|
|
65
63
|
} catch (error) {
|
|
66
64
|
// Fallback to synchronous method on error
|
|
67
65
|
return this.getFileDownloadUrl(fileId, variant, expiresIn);
|
|
@@ -96,14 +94,17 @@ export function OxyServicesAssetsMixin<T extends typeof OxyServicesBase>(Base: T
|
|
|
96
94
|
*/
|
|
97
95
|
async getFileContentAsText(fileId: string, variant?: string): Promise<string> {
|
|
98
96
|
try {
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
97
|
+
const downloadUrl = await this.fetchAssetDownloadUrl(
|
|
98
|
+
fileId,
|
|
99
|
+
variant,
|
|
100
|
+
this.getAssetUrlCacheTTL()
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
if (!downloadUrl) {
|
|
104
|
+
throw new Error('No download URL returned for asset');
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return await this.fetchAssetContent(downloadUrl, 'text');
|
|
107
108
|
} catch (error) {
|
|
108
109
|
throw this.handleError(error);
|
|
109
110
|
}
|
|
@@ -114,19 +115,53 @@ export function OxyServicesAssetsMixin<T extends typeof OxyServicesBase>(Base: T
|
|
|
114
115
|
*/
|
|
115
116
|
async getFileContentAsBlob(fileId: string, variant?: string): Promise<Blob> {
|
|
116
117
|
try {
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
118
|
+
const downloadUrl = await this.fetchAssetDownloadUrl(
|
|
119
|
+
fileId,
|
|
120
|
+
variant,
|
|
121
|
+
this.getAssetUrlCacheTTL()
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
if (!downloadUrl) {
|
|
125
|
+
throw new Error('No download URL returned for asset');
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return await this.fetchAssetContent(downloadUrl, 'blob');
|
|
129
|
+
} catch (error) {
|
|
130
|
+
throw this.handleError(error);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Get batch access to multiple files
|
|
136
|
+
* Returns URLs and access status for each file
|
|
137
|
+
*/
|
|
138
|
+
async getBatchFileAccess(fileIds: string[], context?: string): Promise<Record<string, any>> {
|
|
139
|
+
try {
|
|
140
|
+
return await this.makeRequest('POST', '/api/assets/batch-access', {
|
|
141
|
+
fileIds,
|
|
142
|
+
context
|
|
121
143
|
});
|
|
122
|
-
const downloadUrl = urlRes?.url;
|
|
123
|
-
const response = await fetch(downloadUrl);
|
|
124
|
-
return await response.blob();
|
|
125
144
|
} catch (error) {
|
|
126
145
|
throw this.handleError(error);
|
|
127
146
|
}
|
|
128
147
|
}
|
|
129
148
|
|
|
149
|
+
/**
|
|
150
|
+
* Get download URLs for multiple files efficiently
|
|
151
|
+
*/
|
|
152
|
+
async getFileDownloadUrls(fileIds: string[], context?: string): Promise<Record<string, string>> {
|
|
153
|
+
const response: any = await this.getBatchFileAccess(fileIds, context);
|
|
154
|
+
const urls: Record<string, string> = {};
|
|
155
|
+
// response.results is the map
|
|
156
|
+
const results = response.results || {};
|
|
157
|
+
for (const [id, result] of Object.entries(results as Record<string, any>)) {
|
|
158
|
+
if (result.allowed && result.url) {
|
|
159
|
+
urls[id] = result.url;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return urls;
|
|
163
|
+
}
|
|
164
|
+
|
|
130
165
|
/**
|
|
131
166
|
* Upload raw file data
|
|
132
167
|
*/
|
|
@@ -407,6 +442,43 @@ export function OxyServicesAssetsMixin<T extends typeof OxyServicesBase>(Base: T
|
|
|
407
442
|
throw this.handleError(error);
|
|
408
443
|
}
|
|
409
444
|
}
|
|
445
|
+
|
|
446
|
+
public getAssetUrlCacheTTL(expiresIn?: number) {
|
|
447
|
+
const desiredTtlMs = (expiresIn ?? 3600) * 1000;
|
|
448
|
+
return Math.min(desiredTtlMs, 10 * 60 * 1000);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
public async fetchAssetDownloadUrl(
|
|
452
|
+
fileId: string,
|
|
453
|
+
variant?: string,
|
|
454
|
+
cacheTTL?: number,
|
|
455
|
+
expiresIn?: number
|
|
456
|
+
): Promise<string | null> {
|
|
457
|
+
const params: any = {};
|
|
458
|
+
if (variant) params.variant = variant;
|
|
459
|
+
if (expiresIn) params.expiresIn = expiresIn;
|
|
460
|
+
|
|
461
|
+
const urlRes = await this.makeRequest<{ url: string }>(
|
|
462
|
+
'GET',
|
|
463
|
+
`/api/assets/${encodeURIComponent(fileId)}/url`,
|
|
464
|
+
Object.keys(params).length ? params : undefined,
|
|
465
|
+
{
|
|
466
|
+
cache: true,
|
|
467
|
+
cacheTTL: cacheTTL ?? 10 * 60 * 1000, // default 10 minutes cache for URLs
|
|
468
|
+
}
|
|
469
|
+
);
|
|
470
|
+
|
|
471
|
+
return urlRes?.url || null;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
public async fetchAssetContent(url: string, type: 'text'): Promise<string>;
|
|
475
|
+
public async fetchAssetContent(url: string, type: 'blob'): Promise<Blob>;
|
|
476
|
+
public async fetchAssetContent(url: string, type: 'text' | 'blob') {
|
|
477
|
+
const response = await fetch(url);
|
|
478
|
+
if (!response?.ok) {
|
|
479
|
+
throw new Error(`Failed to fetch asset content (status ${response?.status})`);
|
|
480
|
+
}
|
|
481
|
+
return type === 'text' ? response.text() : response.blob();
|
|
482
|
+
}
|
|
410
483
|
};
|
|
411
484
|
}
|
|
412
|
-
|
|
@@ -165,6 +165,9 @@ export function OxyServicesUtilityMixin<T extends typeof OxyServicesBase>(Base:
|
|
|
165
165
|
req.accessToken = token;
|
|
166
166
|
req.user = { id: userId } as User;
|
|
167
167
|
|
|
168
|
+
// Automatically authenticate the OxyServices instance so all subsequent API calls are authenticated
|
|
169
|
+
this.setTokens(token);
|
|
170
|
+
|
|
168
171
|
if (debug) {
|
|
169
172
|
console.log(`✅ Auth: Authentication successful for user ${userId}`);
|
|
170
173
|
}
|