@shipstatic/types 0.4.17 → 0.4.19
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/dist/index.d.ts +29 -2
- package/dist/index.js +51 -0
- package/package.json +1 -1
- package/src/index.ts +62 -2
package/dist/index.d.ts
CHANGED
|
@@ -138,6 +138,8 @@ export interface DomainDnsResponse {
|
|
|
138
138
|
export interface DomainRecordsResponse {
|
|
139
139
|
/** The domain name */
|
|
140
140
|
domain: string;
|
|
141
|
+
/** The apex (registered) domain where DNS records are managed */
|
|
142
|
+
apex: string;
|
|
141
143
|
/** Required DNS records for configuration */
|
|
142
144
|
records: DnsRecord[];
|
|
143
145
|
}
|
|
@@ -337,6 +339,9 @@ export declare class ShipError extends Error {
|
|
|
337
339
|
export declare function isShipError(error: unknown): error is ShipError;
|
|
338
340
|
/**
|
|
339
341
|
* Platform configuration response from API
|
|
342
|
+
*
|
|
343
|
+
* Contains ONLY dynamic, runtime-specific values (plan-based limits).
|
|
344
|
+
* Static constants (MIME types, validation rules) live as exported constants.
|
|
340
345
|
*/
|
|
341
346
|
export interface ConfigResponse {
|
|
342
347
|
/** Maximum individual file size in bytes */
|
|
@@ -345,9 +350,31 @@ export interface ConfigResponse {
|
|
|
345
350
|
maxFilesCount: number;
|
|
346
351
|
/** Maximum total deployment size in bytes */
|
|
347
352
|
maxTotalSize: number;
|
|
348
|
-
/** Allowed MIME type categories for file validation */
|
|
349
|
-
allowedMimeTypes: string[];
|
|
350
353
|
}
|
|
354
|
+
/**
|
|
355
|
+
* Allowed MIME types and prefixes for file uploads.
|
|
356
|
+
*
|
|
357
|
+
* This is a static platform constant, not per-user configuration.
|
|
358
|
+
* Safe to share across frontend/backend due to atomic deploys.
|
|
359
|
+
*
|
|
360
|
+
* Validation rules:
|
|
361
|
+
* - Exact match: 'application/json' allows only 'application/json'
|
|
362
|
+
* - Prefix match: 'text/' allows 'text/plain', 'text/html', etc.
|
|
363
|
+
*/
|
|
364
|
+
export declare const ALLOWED_MIME_TYPES: readonly ["text/", "image/", "audio/", "video/", "font/", "model/", "application/json", "application/javascript", "application/pdf", "application/xml", "application/manifest+json", "application/toml", "application/font-woff", "application/font-woff2", "application/x-font-woff", "application/x-woff", "application/vnd.ms-fontobject", "application/x-font-ttf", "application/x-font-truetype", "application/x-font-otf", "application/x-font-opentype"];
|
|
365
|
+
/**
|
|
366
|
+
* Check if a MIME type is allowed for upload.
|
|
367
|
+
*
|
|
368
|
+
* Supports both exact matches and prefix matches:
|
|
369
|
+
* - 'application/json' matches 'application/json' exactly
|
|
370
|
+
* - 'text/' matches 'text/plain', 'text/html', etc.
|
|
371
|
+
*
|
|
372
|
+
* @example
|
|
373
|
+
* isAllowedMimeType('text/plain') // true (prefix match)
|
|
374
|
+
* isAllowedMimeType('application/json') // true (exact match)
|
|
375
|
+
* isAllowedMimeType('application/wasm') // false (not allowed)
|
|
376
|
+
*/
|
|
377
|
+
export declare function isAllowedMimeType(mimeType: string): boolean;
|
|
351
378
|
/**
|
|
352
379
|
* Generic success response wrapper
|
|
353
380
|
*/
|
package/dist/index.js
CHANGED
|
@@ -199,6 +199,57 @@ export function isShipError(error) {
|
|
|
199
199
|
error.name === 'ShipError' &&
|
|
200
200
|
'status' in error);
|
|
201
201
|
}
|
|
202
|
+
/**
|
|
203
|
+
* Allowed MIME types and prefixes for file uploads.
|
|
204
|
+
*
|
|
205
|
+
* This is a static platform constant, not per-user configuration.
|
|
206
|
+
* Safe to share across frontend/backend due to atomic deploys.
|
|
207
|
+
*
|
|
208
|
+
* Validation rules:
|
|
209
|
+
* - Exact match: 'application/json' allows only 'application/json'
|
|
210
|
+
* - Prefix match: 'text/' allows 'text/plain', 'text/html', etc.
|
|
211
|
+
*/
|
|
212
|
+
export const ALLOWED_MIME_TYPES = [
|
|
213
|
+
// Common web content (prefix matches)
|
|
214
|
+
'text/', // All text types
|
|
215
|
+
'image/', // All image types
|
|
216
|
+
'audio/', // All audio types
|
|
217
|
+
'video/', // All video types
|
|
218
|
+
'font/', // Modern font types (font/woff, font/woff2, font/ttf, font/otf)
|
|
219
|
+
'model/', // 3D models
|
|
220
|
+
// Specific application types (exact matches)
|
|
221
|
+
'application/json',
|
|
222
|
+
'application/javascript',
|
|
223
|
+
'application/pdf',
|
|
224
|
+
'application/xml',
|
|
225
|
+
'application/manifest+json',
|
|
226
|
+
'application/toml',
|
|
227
|
+
// Legacy font MIME types (for Bootstrap, Font Awesome, etc.)
|
|
228
|
+
'application/font-woff',
|
|
229
|
+
'application/font-woff2',
|
|
230
|
+
'application/x-font-woff',
|
|
231
|
+
'application/x-woff',
|
|
232
|
+
'application/vnd.ms-fontobject', // .eot files (IE compatibility)
|
|
233
|
+
'application/x-font-ttf',
|
|
234
|
+
'application/x-font-truetype',
|
|
235
|
+
'application/x-font-otf',
|
|
236
|
+
'application/x-font-opentype',
|
|
237
|
+
];
|
|
238
|
+
/**
|
|
239
|
+
* Check if a MIME type is allowed for upload.
|
|
240
|
+
*
|
|
241
|
+
* Supports both exact matches and prefix matches:
|
|
242
|
+
* - 'application/json' matches 'application/json' exactly
|
|
243
|
+
* - 'text/' matches 'text/plain', 'text/html', etc.
|
|
244
|
+
*
|
|
245
|
+
* @example
|
|
246
|
+
* isAllowedMimeType('text/plain') // true (prefix match)
|
|
247
|
+
* isAllowedMimeType('application/json') // true (exact match)
|
|
248
|
+
* isAllowedMimeType('application/wasm') // false (not allowed)
|
|
249
|
+
*/
|
|
250
|
+
export function isAllowedMimeType(mimeType) {
|
|
251
|
+
return ALLOWED_MIME_TYPES.some(allowed => mimeType === allowed || mimeType.startsWith(allowed));
|
|
252
|
+
}
|
|
202
253
|
// API Key Configuration
|
|
203
254
|
export const API_KEY_PREFIX = 'ship-';
|
|
204
255
|
export const API_KEY_HEX_LENGTH = 64;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -158,6 +158,8 @@ export interface DomainDnsResponse {
|
|
|
158
158
|
export interface DomainRecordsResponse {
|
|
159
159
|
/** The domain name */
|
|
160
160
|
domain: string;
|
|
161
|
+
/** The apex (registered) domain where DNS records are managed */
|
|
162
|
+
apex: string;
|
|
161
163
|
/** Required DNS records for configuration */
|
|
162
164
|
records: DnsRecord[];
|
|
163
165
|
}
|
|
@@ -490,6 +492,9 @@ export function isShipError(error: unknown): error is ShipError {
|
|
|
490
492
|
|
|
491
493
|
/**
|
|
492
494
|
* Platform configuration response from API
|
|
495
|
+
*
|
|
496
|
+
* Contains ONLY dynamic, runtime-specific values (plan-based limits).
|
|
497
|
+
* Static constants (MIME types, validation rules) live as exported constants.
|
|
493
498
|
*/
|
|
494
499
|
export interface ConfigResponse {
|
|
495
500
|
/** Maximum individual file size in bytes */
|
|
@@ -498,8 +503,63 @@ export interface ConfigResponse {
|
|
|
498
503
|
maxFilesCount: number;
|
|
499
504
|
/** Maximum total deployment size in bytes */
|
|
500
505
|
maxTotalSize: number;
|
|
501
|
-
|
|
502
|
-
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* Allowed MIME types and prefixes for file uploads.
|
|
510
|
+
*
|
|
511
|
+
* This is a static platform constant, not per-user configuration.
|
|
512
|
+
* Safe to share across frontend/backend due to atomic deploys.
|
|
513
|
+
*
|
|
514
|
+
* Validation rules:
|
|
515
|
+
* - Exact match: 'application/json' allows only 'application/json'
|
|
516
|
+
* - Prefix match: 'text/' allows 'text/plain', 'text/html', etc.
|
|
517
|
+
*/
|
|
518
|
+
export const ALLOWED_MIME_TYPES = [
|
|
519
|
+
// Common web content (prefix matches)
|
|
520
|
+
'text/', // All text types
|
|
521
|
+
'image/', // All image types
|
|
522
|
+
'audio/', // All audio types
|
|
523
|
+
'video/', // All video types
|
|
524
|
+
'font/', // Modern font types (font/woff, font/woff2, font/ttf, font/otf)
|
|
525
|
+
'model/', // 3D models
|
|
526
|
+
|
|
527
|
+
// Specific application types (exact matches)
|
|
528
|
+
'application/json',
|
|
529
|
+
'application/javascript',
|
|
530
|
+
'application/pdf',
|
|
531
|
+
'application/xml',
|
|
532
|
+
'application/manifest+json',
|
|
533
|
+
'application/toml',
|
|
534
|
+
|
|
535
|
+
// Legacy font MIME types (for Bootstrap, Font Awesome, etc.)
|
|
536
|
+
'application/font-woff',
|
|
537
|
+
'application/font-woff2',
|
|
538
|
+
'application/x-font-woff',
|
|
539
|
+
'application/x-woff',
|
|
540
|
+
'application/vnd.ms-fontobject', // .eot files (IE compatibility)
|
|
541
|
+
'application/x-font-ttf',
|
|
542
|
+
'application/x-font-truetype',
|
|
543
|
+
'application/x-font-otf',
|
|
544
|
+
'application/x-font-opentype',
|
|
545
|
+
] as const;
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
* Check if a MIME type is allowed for upload.
|
|
549
|
+
*
|
|
550
|
+
* Supports both exact matches and prefix matches:
|
|
551
|
+
* - 'application/json' matches 'application/json' exactly
|
|
552
|
+
* - 'text/' matches 'text/plain', 'text/html', etc.
|
|
553
|
+
*
|
|
554
|
+
* @example
|
|
555
|
+
* isAllowedMimeType('text/plain') // true (prefix match)
|
|
556
|
+
* isAllowedMimeType('application/json') // true (exact match)
|
|
557
|
+
* isAllowedMimeType('application/wasm') // false (not allowed)
|
|
558
|
+
*/
|
|
559
|
+
export function isAllowedMimeType(mimeType: string): boolean {
|
|
560
|
+
return ALLOWED_MIME_TYPES.some(allowed =>
|
|
561
|
+
mimeType === allowed || mimeType.startsWith(allowed)
|
|
562
|
+
);
|
|
503
563
|
}
|
|
504
564
|
|
|
505
565
|
// =============================================================================
|