@kalutskii/foundation 0.7.14 → 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 +15 -7
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -533,28 +533,36 @@ declare function formatTime(time: Date, { locale, tz }?: {
|
|
|
533
533
|
|
|
534
534
|
/**
|
|
535
535
|
* Recursively replaces dots in a string literal with underscores.
|
|
536
|
-
* Every other character remains unchanged in the resulting type.
|
|
536
|
+
* Every other character remains unchanged in the resulting literal type.
|
|
537
537
|
*
|
|
538
538
|
* @example
|
|
539
539
|
* type Key = ReplaceDotsWithUnderscores<'foo.bar.baz'>; // `foo_bar_baz`
|
|
540
540
|
*/
|
|
541
|
-
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;
|
|
542
550
|
/**
|
|
543
551
|
* Maps string literals to immutable uppercase enum-like keys.
|
|
544
|
-
* Dots become underscores while
|
|
552
|
+
* Dots and hyphens become underscores while values preserve their original literals.
|
|
545
553
|
*
|
|
546
554
|
* @example
|
|
547
555
|
* type Statuses = StringEnumRecord<readonly ['review.pending', 'published']>;
|
|
548
556
|
*/
|
|
549
557
|
type StringEnumRecord<TValues extends readonly string[]> = Readonly<{
|
|
550
|
-
[Value in TValues[number] as Uppercase<ReplaceDotsWithUnderscores<Value
|
|
558
|
+
[Value in TValues[number] as Uppercase<ReplaceHyphensWithUnderscores<ReplaceDotsWithUnderscores<Value>>>]: Value;
|
|
551
559
|
}>;
|
|
552
560
|
/**
|
|
553
561
|
* Creates an immutable enum-like record from a readonly string array.
|
|
554
|
-
* 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.
|
|
555
563
|
*
|
|
556
564
|
* @example
|
|
557
|
-
* createStringEnumRecord(['foo.s', 'baz'] as const); // `{
|
|
565
|
+
* createStringEnumRecord(['foo-bar.s', 'baz'] as const); // `{ FOO_BAR_S: 'foo-bar.s', BAZ: 'baz' }`
|
|
558
566
|
*/
|
|
559
567
|
declare function createStringEnumRecord<const T extends readonly string[]>(values: T): StringEnumRecord<T>;
|
|
560
568
|
|
|
@@ -906,4 +914,4 @@ declare const asQuery: <T extends z.ZodTypeAny>(schema: T) => z.ZodPreprocess<T>
|
|
|
906
914
|
*/
|
|
907
915
|
declare const isPlainObject: (value: unknown) => value is Record<string, unknown>;
|
|
908
916
|
|
|
909
|
-
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, 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 };
|
|
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
|