@kalutskii/foundation 0.7.13 → 0.7.15
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 +25 -7
- package/dist/index.js +6 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -406,6 +406,16 @@ declare const imageUploadPreset: Readonly<{
|
|
|
406
406
|
maxFilesCount?: number;
|
|
407
407
|
extensionFallback?: boolean;
|
|
408
408
|
}>;
|
|
409
|
+
/**
|
|
410
|
+
* Ready-to-use policy for every image format supporting transparency (alpha channel).
|
|
411
|
+
* Each image may occupy up to 20 MiB while collection capacity remains unrestricted.
|
|
412
|
+
*/
|
|
413
|
+
declare const imageTransparentUploadPreset: Readonly<{
|
|
414
|
+
formats: readonly ["png", "webp", "svg"];
|
|
415
|
+
maxFileSize: number;
|
|
416
|
+
maxFilesCount?: number;
|
|
417
|
+
extensionFallback?: boolean;
|
|
418
|
+
}>;
|
|
409
419
|
/**
|
|
410
420
|
* Ready-to-use policy for every document format supported by the upload catalog.
|
|
411
421
|
* Each document may occupy up to 20 MiB while collection capacity remains unrestricted.
|
|
@@ -523,28 +533,36 @@ declare function formatTime(time: Date, { locale, tz }?: {
|
|
|
523
533
|
|
|
524
534
|
/**
|
|
525
535
|
* Recursively replaces dots in a string literal with underscores.
|
|
526
|
-
* Every other character remains unchanged in the resulting type.
|
|
536
|
+
* Every other character remains unchanged in the resulting literal type.
|
|
527
537
|
*
|
|
528
538
|
* @example
|
|
529
539
|
* type Key = ReplaceDotsWithUnderscores<'foo.bar.baz'>; // `foo_bar_baz`
|
|
530
540
|
*/
|
|
531
|
-
type ReplaceDotsWithUnderscores<TValue extends string> = TValue extends `${infer Head}.${infer Tail}` ? `${Head}_${ReplaceDotsWithUnderscores<Tail>}` : TValue;
|
|
541
|
+
type ReplaceDotsWithUnderscores<TValue extends string> = TValue extends `${infer Head}.${infer Tail}` ? `${ReplaceDotsWithUnderscores<Head>}_${ReplaceDotsWithUnderscores<Tail>}` : TValue;
|
|
542
|
+
/**
|
|
543
|
+
* Recursively replaces hyphens in a string literal with underscores.
|
|
544
|
+
* Every other character remains unchanged in the resulting literal type.
|
|
545
|
+
*
|
|
546
|
+
* @example
|
|
547
|
+
* type Key = ReplaceHyphensWithUnderscores<'foo-bar-baz'>; // `foo_bar_baz`
|
|
548
|
+
*/
|
|
549
|
+
type ReplaceHyphensWithUnderscores<TValue extends string> = TValue extends `${infer Head}-${infer Tail}` ? `${ReplaceHyphensWithUnderscores<Head>}_${ReplaceHyphensWithUnderscores<Tail>}` : TValue;
|
|
532
550
|
/**
|
|
533
551
|
* Maps string literals to immutable uppercase enum-like keys.
|
|
534
|
-
* Dots become underscores while
|
|
552
|
+
* Dots and hyphens become underscores while values preserve their original literals.
|
|
535
553
|
*
|
|
536
554
|
* @example
|
|
537
555
|
* type Statuses = StringEnumRecord<readonly ['review.pending', 'published']>;
|
|
538
556
|
*/
|
|
539
557
|
type StringEnumRecord<TValues extends readonly string[]> = Readonly<{
|
|
540
|
-
[Value in TValues[number] as Uppercase<ReplaceDotsWithUnderscores<Value
|
|
558
|
+
[Value in TValues[number] as Uppercase<ReplaceHyphensWithUnderscores<ReplaceDotsWithUnderscores<Value>>>]: Value;
|
|
541
559
|
}>;
|
|
542
560
|
/**
|
|
543
561
|
* Creates an immutable enum-like record from a readonly string array.
|
|
544
|
-
* Keys are uppercased and every dot is replaced with an underscore.
|
|
562
|
+
* Keys are uppercased and every dot or hyphen is replaced with an underscore.
|
|
545
563
|
*
|
|
546
564
|
* @example
|
|
547
|
-
* createStringEnumRecord(['foo.s', 'baz'] as const); // `{
|
|
565
|
+
* createStringEnumRecord(['foo-bar.s', 'baz'] as const); // `{ FOO_BAR_S: 'foo-bar.s', BAZ: 'baz' }`
|
|
548
566
|
*/
|
|
549
567
|
declare function createStringEnumRecord<const T extends readonly string[]>(values: T): StringEnumRecord<T>;
|
|
550
568
|
|
|
@@ -896,4 +914,4 @@ declare const asQuery: <T extends z.ZodTypeAny>(schema: T) => z.ZodPreprocess<T>
|
|
|
896
914
|
*/
|
|
897
915
|
declare const isPlainObject: (value: unknown) => value is Record<string, unknown>;
|
|
898
916
|
|
|
899
|
-
export { type APIContractData, type APIContractError, type APIContractResult, type APIError, type APISuccess, type AsQuery, type AtLeastOne, DEFAULT_UPLOAD_MAX_FILE_SIZE, EXCEPTION_STATUS_CODES, type ExceptionStatusCode, type FetchResult, type FileFormat, type FileFormatConfig, type HonoFileRespondOptions, type HonoRespondOptions, type JWTServiceOptions, type JWTSignOptions, type LogLevel, type MeasuredExecution, type Payload, type PayloadSchema, REDACTED_LOG_VALUE, type ReplaceDotsWithUnderscores, SUCCESS_STATUS_CODES, type Simplify, type StringEnumRecord, type SuccessStatusCode, type UploadFilesValidationOptions, type UploadFilesValidationResult, type UploadPreset, type UploadValidationError, type ZodBulkExcludeSelection, type ZodBulkIncludeSelection, type ZodBulkSelection, ZodJWTService, type ZodPaginationOptions, type ZodSearchSchemaOptions, type ZodUploadFileSchemaOptions, asQuery, createStringEnumRecord, createUploadAccept, createZodSearchWhereSchema, defineUploadPreset, documentUploadPreset, failure, fetchAndThrow, fetchSafely, fileFormat, fileFormatsArray, fileFormatsConfig, fileFormatsRecord, fileRespond, formatTime, generateRandomString, getColoredHTTPStatus, getFileExtension, getFormattedDate, getFormattedTime, getUTCOffset, getZonedTime, httpStatusColors, imageUploadPreset, isFileExtensionSupported, isFileFormatSupported, isFileMimeTypeSupported, isPlainObject, log, logLevel, logLevelColors, logLevelsArray, logLevelsRecord, loggingMiddleware, matchesMimeType, measureExecutionTime, normalizeFileExtension, onHandlerError, parseQueryValue, redactSensitiveJSON, redactSensitiveSearchParams, respond, safeExecute, sensitiveLogKeyParts, sqlWhere, success, uploadValidationError, uploadValidationErrorsArray, uploadValidationErrorsRecord, validateUploadFile, validateUploadFiles, zodAtLeastOne, zodBulkSelectionSchema, zodPaginationSchema, zodPaginationShape, zodSearchQuerySchema, zodSearchSchema, zodUploadFileSchema };
|
|
917
|
+
export { type APIContractData, type APIContractError, type APIContractResult, type APIError, type APISuccess, type AsQuery, type AtLeastOne, DEFAULT_UPLOAD_MAX_FILE_SIZE, EXCEPTION_STATUS_CODES, type ExceptionStatusCode, type FetchResult, type FileFormat, type FileFormatConfig, type HonoFileRespondOptions, type HonoRespondOptions, type JWTServiceOptions, type JWTSignOptions, type LogLevel, type MeasuredExecution, type Payload, type PayloadSchema, REDACTED_LOG_VALUE, type ReplaceDotsWithUnderscores, type ReplaceHyphensWithUnderscores, SUCCESS_STATUS_CODES, type Simplify, type StringEnumRecord, type SuccessStatusCode, type UploadFilesValidationOptions, type UploadFilesValidationResult, type UploadPreset, type UploadValidationError, type ZodBulkExcludeSelection, type ZodBulkIncludeSelection, type ZodBulkSelection, ZodJWTService, type ZodPaginationOptions, type ZodSearchSchemaOptions, type ZodUploadFileSchemaOptions, asQuery, createStringEnumRecord, createUploadAccept, createZodSearchWhereSchema, defineUploadPreset, documentUploadPreset, failure, fetchAndThrow, fetchSafely, fileFormat, fileFormatsArray, fileFormatsConfig, fileFormatsRecord, fileRespond, formatTime, generateRandomString, getColoredHTTPStatus, getFileExtension, getFormattedDate, getFormattedTime, getUTCOffset, getZonedTime, httpStatusColors, imageTransparentUploadPreset, imageUploadPreset, isFileExtensionSupported, isFileFormatSupported, isFileMimeTypeSupported, isPlainObject, log, logLevel, logLevelColors, logLevelsArray, logLevelsRecord, loggingMiddleware, matchesMimeType, measureExecutionTime, normalizeFileExtension, onHandlerError, parseQueryValue, redactSensitiveJSON, redactSensitiveSearchParams, respond, safeExecute, sensitiveLogKeyParts, sqlWhere, success, uploadValidationError, uploadValidationErrorsArray, uploadValidationErrorsRecord, validateUploadFile, validateUploadFiles, zodAtLeastOne, zodBulkSelectionSchema, zodPaginationSchema, zodPaginationShape, zodSearchQuerySchema, zodSearchSchema, zodUploadFileSchema };
|
package/dist/index.js
CHANGED
|
@@ -56,7 +56,7 @@ import { blue, green, red, yellow } from "kleur/colors";
|
|
|
56
56
|
|
|
57
57
|
// src/utilities/enums.utilities.ts
|
|
58
58
|
function createStringEnumRecord(values) {
|
|
59
|
-
return Object.freeze(Object.fromEntries(values.map((value) => [value.
|
|
59
|
+
return Object.freeze(Object.fromEntries(values.map((value) => [value.replaceAll(/[.-]/g, "_").toUpperCase(), value])));
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
// src/logging/logging.enums.ts
|
|
@@ -294,6 +294,10 @@ var imageUploadPreset = defineUploadPreset({
|
|
|
294
294
|
formats: [fileFormat.PNG, fileFormat.JPG, fileFormat.WEBP, fileFormat.AVIF, fileFormat.HEIC],
|
|
295
295
|
maxFileSize: DEFAULT_UPLOAD_MAX_FILE_SIZE
|
|
296
296
|
});
|
|
297
|
+
var imageTransparentUploadPreset = defineUploadPreset({
|
|
298
|
+
formats: [fileFormat.PNG, fileFormat.WEBP, fileFormat.SVG],
|
|
299
|
+
maxFileSize: DEFAULT_UPLOAD_MAX_FILE_SIZE
|
|
300
|
+
});
|
|
297
301
|
var documentUploadPreset = defineUploadPreset({
|
|
298
302
|
formats: [fileFormat.PDF, fileFormat.RTF, fileFormat.TXT],
|
|
299
303
|
maxFileSize: DEFAULT_UPLOAD_MAX_FILE_SIZE
|
|
@@ -549,6 +553,7 @@ export {
|
|
|
549
553
|
getUTCOffset,
|
|
550
554
|
getZonedTime,
|
|
551
555
|
httpStatusColors,
|
|
556
|
+
imageTransparentUploadPreset,
|
|
552
557
|
imageUploadPreset,
|
|
553
558
|
isFileExtensionSupported,
|
|
554
559
|
isFileFormatSupported,
|