@lilaquadrat/studio 9.20.2 → 10.0.0-beta.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/lib/cjs/helpers.d.ts +3 -1
- package/lib/cjs/helpers.js +5 -1
- package/lib/cjs/helpers.js.map +1 -1
- package/lib/cjs/models.d.ts +3 -2
- package/lib/cjs/models.js +5 -3
- package/lib/cjs/models.js.map +1 -1
- package/lib/cjs/services.d.ts +5 -2
- package/lib/cjs/services.js +9 -3
- package/lib/cjs/services.js.map +1 -1
- package/lib/cjs/src/AzureBlobStorage.share.js +0 -1
- package/lib/cjs/src/AzureBlobStorage.share.js.map +1 -1
- package/lib/cjs/src/AzureFileStorage.share.js +0 -2
- package/lib/cjs/src/AzureFileStorage.share.js.map +1 -1
- package/lib/cjs/src/Immutable.class.js +1 -2
- package/lib/cjs/src/Immutable.class.js.map +1 -1
- package/lib/cjs/src/aggegations/structures.aggregation.d.ts +6 -2
- package/lib/cjs/src/aggegations/structures.aggregation.js +3 -1
- package/lib/cjs/src/aggegations/structures.aggregation.js.map +1 -1
- package/lib/cjs/src/classes/models.class.js +0 -1
- package/lib/cjs/src/classes/models.class.js.map +1 -1
- package/lib/cjs/src/docker-compose.class.js +1 -1
- package/lib/cjs/src/docker-compose.class.js.map +1 -1
- package/lib/cjs/src/helpers/HttpStatusCode.enum.js +0 -1
- package/lib/cjs/src/helpers/HttpStatusCode.enum.js.map +1 -1
- package/lib/cjs/src/helpers/batch.d.ts +9 -0
- package/lib/cjs/src/helpers/batch.js +38 -0
- package/lib/cjs/src/helpers/batch.js.map +1 -0
- package/lib/cjs/src/helpers/cleanObject.d.ts +1 -1
- package/lib/cjs/src/helpers/cleanObject.js +1 -0
- package/lib/cjs/src/helpers/cleanObject.js.map +1 -1
- package/lib/cjs/src/helpers/filenameHelper.d.ts +9 -0
- package/lib/cjs/src/helpers/filenameHelper.js +21 -0
- package/lib/cjs/src/helpers/filenameHelper.js.map +1 -0
- package/lib/cjs/src/helpers/isDeepEmpty.js +2 -0
- package/lib/cjs/src/helpers/isDeepEmpty.js.map +1 -1
- package/lib/cjs/src/models/permissions.model.js +23 -0
- package/lib/cjs/src/models/permissions.model.js.map +1 -1
- package/lib/cjs/src/models/storage.model.d.ts +4 -0
- package/lib/cjs/src/models/storage.model.js +112 -0
- package/lib/cjs/src/models/storage.model.js.map +1 -0
- package/lib/cjs/src/models/upload.model.d.ts +4 -0
- package/lib/cjs/src/models/upload.model.js +86 -0
- package/lib/cjs/src/models/upload.model.js.map +1 -0
- package/lib/cjs/src/services/ai.service.d.ts +1 -1
- package/lib/cjs/src/services/ai.service.js +6 -4
- package/lib/cjs/src/services/ai.service.js.map +1 -1
- package/lib/cjs/src/services/certificates.service.js +0 -1
- package/lib/cjs/src/services/certificates.service.js.map +1 -1
- package/lib/cjs/src/services/certificatesAction.service.js +1 -1
- package/lib/cjs/src/services/certificatesAction.service.js.map +1 -1
- package/lib/cjs/src/services/customers.service.js +1 -2
- package/lib/cjs/src/services/customers.service.js.map +1 -1
- package/lib/cjs/src/services/domains.service.js +2 -2
- package/lib/cjs/src/services/domains.service.js.map +1 -1
- package/lib/cjs/src/services/editorBase.service.js +7 -4
- package/lib/cjs/src/services/editorBase.service.js.map +1 -1
- package/lib/cjs/src/services/history.service.js +0 -1
- package/lib/cjs/src/services/history.service.js.map +1 -1
- package/lib/cjs/src/services/jetstream.service.d.ts +21 -0
- package/lib/cjs/src/services/jetstream.service.js +100 -0
- package/lib/cjs/src/services/jetstream.service.js.map +1 -0
- package/lib/cjs/src/services/listParticipants.service.js +7 -7
- package/lib/cjs/src/services/listParticipants.service.js.map +1 -1
- package/lib/cjs/src/services/lists.service.js +2 -2
- package/lib/cjs/src/services/lists.service.js.map +1 -1
- package/lib/cjs/src/services/me.service.d.ts +20 -1
- package/lib/cjs/src/services/me.service.js +42 -1
- package/lib/cjs/src/services/me.service.js.map +1 -1
- package/lib/cjs/src/services/media.service.d.ts +7 -2
- package/lib/cjs/src/services/media.service.js +57 -14
- package/lib/cjs/src/services/media.service.js.map +1 -1
- package/lib/cjs/src/services/payments.service.js +1 -1
- package/lib/cjs/src/services/payments.service.js.map +1 -1
- package/lib/cjs/src/services/share.service.d.ts +1 -6
- package/lib/cjs/src/services/share.service.js +0 -18
- package/lib/cjs/src/services/share.service.js.map +1 -1
- package/lib/cjs/src/services/storage.service.d.ts +192 -0
- package/lib/cjs/src/services/storage.service.js +861 -0
- package/lib/cjs/src/services/storage.service.js.map +1 -0
- package/lib/cjs/src/services/structures.service.js +2 -2
- package/lib/cjs/src/services/structures.service.js.map +1 -1
- package/lib/cjs/src/services/upload.service.d.ts +11 -0
- package/lib/cjs/src/services/upload.service.js +72 -0
- package/lib/cjs/src/services/upload.service.js.map +1 -0
- package/lib/esm/frontend.d.ts +2 -1
- package/lib/esm/frontend.js +2 -1
- package/lib/esm/frontend.js.map +1 -1
- package/lib/esm/src/helpers/batch.d.ts +9 -0
- package/lib/esm/src/helpers/batch.js +46 -0
- package/lib/esm/src/helpers/batch.js.map +1 -0
- package/lib/esm/src/helpers/isDeepEmpty.js +2 -0
- package/lib/esm/src/helpers/isDeepEmpty.js.map +1 -1
- package/package.json +34 -14
- package/lib/cjs/src/models/media.model.d.ts +0 -4
- package/lib/cjs/src/models/media.model.js +0 -139
- package/lib/cjs/src/models/media.model.js.map +0 -1
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { ObjectId } from 'mongodb';
|
|
3
|
+
import { Media, ListOfModels, MediaStats, Options, Upload, Stored, UserAppOptionsRequired, MediaMetadata, Storage, StorageFilePaths } from '@lilaquadrat/interfaces';
|
|
4
|
+
import { type MultipartFile } from '@fastify/multipart';
|
|
5
|
+
import Immutable from '../Immutable.class';
|
|
6
|
+
export declare class StorageService extends Immutable<Storage> {
|
|
7
|
+
buckets: {
|
|
8
|
+
cdn: {
|
|
9
|
+
public: boolean;
|
|
10
|
+
overwrite: boolean;
|
|
11
|
+
cache: number;
|
|
12
|
+
};
|
|
13
|
+
hosting: {
|
|
14
|
+
public: boolean;
|
|
15
|
+
overwrite: boolean;
|
|
16
|
+
cache: number;
|
|
17
|
+
};
|
|
18
|
+
secure: {
|
|
19
|
+
public: boolean;
|
|
20
|
+
overwrite: boolean;
|
|
21
|
+
cache: number;
|
|
22
|
+
};
|
|
23
|
+
internal: {
|
|
24
|
+
public: boolean;
|
|
25
|
+
overwrite: boolean;
|
|
26
|
+
cache: number;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
model: import("../classes/modelv2.class").default<Storage, string>;
|
|
30
|
+
options: {
|
|
31
|
+
dataFolder: string;
|
|
32
|
+
uploadFolder: string;
|
|
33
|
+
};
|
|
34
|
+
constructor(options: {
|
|
35
|
+
dataFolder: string;
|
|
36
|
+
uploadFolder: string;
|
|
37
|
+
});
|
|
38
|
+
/**
|
|
39
|
+
* Generates a secure, time-limited token for accessing files in secure storage buckets.
|
|
40
|
+
*
|
|
41
|
+
* The token is cryptographically signed using HMAC-SHA256 and base64url-encoded to be
|
|
42
|
+
* non-human readable and URL-safe.
|
|
43
|
+
*
|
|
44
|
+
* @param fileId - The file identifier (ObjectId or string) to grant access to
|
|
45
|
+
* @param expiresIn - Time in seconds until the token expires (default: 3600 = 1 hour)
|
|
46
|
+
* @param limits - Optional restrictions to apply to the token
|
|
47
|
+
* @param limits.company - Restrict token to specific company
|
|
48
|
+
* @param limits.project - Restrict token to specific project
|
|
49
|
+
* @param limits.app - Restrict token to specific app
|
|
50
|
+
* @param limits.url - Restrict token to specific URL path prefix
|
|
51
|
+
* @param limits.prefix - Restrict token to specific file prefix
|
|
52
|
+
*
|
|
53
|
+
* @returns Base64url-encoded token containing: fileId:expires[:limits]:signature
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* // Generate token valid for 1 hour with no restrictions
|
|
57
|
+
* const { token } = getSecureToken('507f1f77bcf86cd799439011', 3600);
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* // Generate token limited to specific company and project
|
|
61
|
+
* const { token } = getSecureToken('507f1f77bcf86cd799439011', 3600, {
|
|
62
|
+
* company: 'acme',
|
|
63
|
+
* project: 'website'
|
|
64
|
+
* });
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* // Generate token limited to specific URL path
|
|
68
|
+
* const { token } = getSecureToken('507f1f77bcf86cd799439011', 3600, {
|
|
69
|
+
* url: '/company/project/files/'
|
|
70
|
+
* });
|
|
71
|
+
*/
|
|
72
|
+
getSecureToken(fileId: string | ObjectId, expiresIn?: number, limits?: {
|
|
73
|
+
company?: string;
|
|
74
|
+
project?: string;
|
|
75
|
+
app?: string;
|
|
76
|
+
url?: string;
|
|
77
|
+
prefix?: string;
|
|
78
|
+
}): {
|
|
79
|
+
token: string;
|
|
80
|
+
expiresIn: number;
|
|
81
|
+
createdAt: number;
|
|
82
|
+
expiresAt: number;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Validates a secure token and optionally checks if it matches provided limits.
|
|
86
|
+
*
|
|
87
|
+
* Performs validations:
|
|
88
|
+
* 1. Signature verification using HMAC-SHA256
|
|
89
|
+
* 2. Expiration timestamp check
|
|
90
|
+
* 3. Optional limit validation against provided check values
|
|
91
|
+
*
|
|
92
|
+
* @param token - The base64url-encoded token to validate
|
|
93
|
+
* @param checkLimits - Optional values to verify against token's restrictions
|
|
94
|
+
* @param checkLimits.company - Company to check against token limit
|
|
95
|
+
* @param checkLimits.project - Project to check against token limit
|
|
96
|
+
* @param checkLimits.app - App to check against token limit
|
|
97
|
+
* @param checkLimits.url - URL path to check against token limit
|
|
98
|
+
* @param checkLimits.prefix - File prefix to check against token limit
|
|
99
|
+
*
|
|
100
|
+
* @returns true if token is valid and all checks pass, false otherwise
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* // Validate token without checking limits
|
|
104
|
+
* const isValid = validateSecureToken(token);
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* // Validate token and check company/project access
|
|
108
|
+
* const isValid = validateSecureToken(token, {
|
|
109
|
+
* company: 'acme',
|
|
110
|
+
* project: 'website'
|
|
111
|
+
* });
|
|
112
|
+
*/
|
|
113
|
+
validateSecureToken(token: string, checkLimits?: {
|
|
114
|
+
company?: string;
|
|
115
|
+
project?: string;
|
|
116
|
+
app?: string;
|
|
117
|
+
url?: string;
|
|
118
|
+
prefix?: string;
|
|
119
|
+
}): boolean;
|
|
120
|
+
/**
|
|
121
|
+
* Creates a secure download URL with time-limited token for a storage file.
|
|
122
|
+
*
|
|
123
|
+
* @param fileId - The ObjectId of the storage document
|
|
124
|
+
* @param options - Required options containing company, project
|
|
125
|
+
* @param expiresIn - Time in seconds until the token expires (default: 3600 = 1 hour)
|
|
126
|
+
* @param limits - Optional additional restrictions for the token
|
|
127
|
+
*
|
|
128
|
+
* @returns Object containing the full download URL with token and expiration timestamp
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* const download = await createSecureDownload(
|
|
132
|
+
* new ObjectId('507f1f77bcf86cd799439011'),
|
|
133
|
+
* { company: 'acme', project: 'website' },
|
|
134
|
+
* 3600
|
|
135
|
+
* );
|
|
136
|
+
* // Returns: { url: 'https://...?token=...', expiresAt: 1234567890 }
|
|
137
|
+
*/
|
|
138
|
+
createSecureDownload(fileId: ObjectId, options: Required<Options>, expiresIn?: number, limits?: {
|
|
139
|
+
company?: string;
|
|
140
|
+
project?: string;
|
|
141
|
+
app?: string;
|
|
142
|
+
url?: string;
|
|
143
|
+
prefix?: string;
|
|
144
|
+
}): Promise<{
|
|
145
|
+
url: string;
|
|
146
|
+
expiresAt: number;
|
|
147
|
+
}>;
|
|
148
|
+
handleFile(uploadInternalId: ObjectId, index: number, file: MultipartFile | undefined): Promise<Stored<Upload>>;
|
|
149
|
+
complete(upload: Upload, options?: {
|
|
150
|
+
useNode?: boolean;
|
|
151
|
+
}): Promise<StorageFilePaths>;
|
|
152
|
+
writeFile(data: MultipartFile['file'] | Upload['paths'], index: number | undefined, internalId: ObjectId, type: 'upload' | 'file', options?: {
|
|
153
|
+
useNode?: boolean;
|
|
154
|
+
}): Promise<StorageFilePaths>;
|
|
155
|
+
writeFileVersion(data: Buffer, internalId: ObjectId, version: string): Promise<StorageFilePaths>;
|
|
156
|
+
private concatenateFiles;
|
|
157
|
+
private concatenateFilesWithCat;
|
|
158
|
+
removeUploadFiles(upload: Upload): Promise<void>;
|
|
159
|
+
removeLocalFile(relativePath: string): Promise<void>;
|
|
160
|
+
/**
|
|
161
|
+
* creata directory structure for the given file
|
|
162
|
+
* e.g. ``/b1/f1/68fb87d6db4fb20117bcd3ce.000001``
|
|
163
|
+
*/
|
|
164
|
+
fanoutPath(uploadId: string, version?: string): StorageFilePaths;
|
|
165
|
+
uploadPath(uploadId: string, index: number): StorageFilePaths;
|
|
166
|
+
static sanitizeName(name: string): string;
|
|
167
|
+
getMetadata(upload: Upload, metadata?: MediaMetadata): MediaMetadata;
|
|
168
|
+
get(company: string, project?: string, app?: string, query?: any, limit?: {
|
|
169
|
+
skip: number;
|
|
170
|
+
limit: number;
|
|
171
|
+
}): Promise<ListOfModels<Media>>;
|
|
172
|
+
getTags(company: string, project: string, search: string): Promise<string[]>;
|
|
173
|
+
single(company: string, project: string, filename: string): Promise<Media | null>;
|
|
174
|
+
content(company: string, project: string, id: ObjectId): Promise<Media | null>;
|
|
175
|
+
/**
|
|
176
|
+
* checks if the file was already successfully uploaded
|
|
177
|
+
*/
|
|
178
|
+
exists(filename: string, prefix: string | undefined, app: string, options: {
|
|
179
|
+
company: string;
|
|
180
|
+
project: string | undefined;
|
|
181
|
+
}): Promise<boolean>;
|
|
182
|
+
matchSortTags(documents: any[], search: RegExp | string, sort: string): string[];
|
|
183
|
+
checkAllowedSize(filesize: number, allowedSize: number): boolean;
|
|
184
|
+
stats(company: string, project: string): Promise<MediaStats>;
|
|
185
|
+
getByInternalId(internalId: ObjectId, options: Required<Options>): Promise<import("mongodb").WithId<Storage> | null>;
|
|
186
|
+
getPathByFilename(filename: string, app: string, options: Required<Options>): Promise<import("mongodb").WithId<Storage> | null>;
|
|
187
|
+
getByFilename(filename: string, prefix: string | undefined, bucket: string, options: Required<Options>): Promise<import("mongodb").WithId<Storage> | null>;
|
|
188
|
+
removeBlob(internalId: ObjectId, options: Required<UserAppOptionsRequired>): Promise<import("mongodb").DeleteResult>;
|
|
189
|
+
removeBlobVersion(parentId: ObjectId, options: Required<UserAppOptionsRequired>): Promise<void>;
|
|
190
|
+
}
|
|
191
|
+
declare const _default: StorageService;
|
|
192
|
+
export default _default;
|