@kalutskii/foundation 0.7.15 → 0.7.17

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 CHANGED
@@ -907,6 +907,15 @@ declare const parseQueryValue: (value: unknown) => unknown;
907
907
  * // { page: 2, isActive: true }
908
908
  */
909
909
  declare const asQuery: <T extends z.ZodTypeAny>(schema: T) => z.ZodPreprocess<T>;
910
+ /**
911
+ * Recursively converts a domain payload into its string-based query representation.
912
+ * Objects and arrays are copied while `null` and `undefined` retain their omission semantics.
913
+ *
914
+ * @example
915
+ * preprocessTransportPayload({ page: 2, enabled: true });
916
+ * // { page: '2', enabled: 'true' }
917
+ */
918
+ declare function preprocessTransportPayload<TValue>(value: TValue): AsQuery<TValue>;
910
919
 
911
920
  /**
912
921
  * Checks whether a value is a plain record backed by `Object.prototype`.
@@ -914,4 +923,4 @@ declare const asQuery: <T extends z.ZodTypeAny>(schema: T) => z.ZodPreprocess<T>
914
923
  */
915
924
  declare const isPlainObject: (value: unknown) => value is Record<string, unknown>;
916
925
 
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 };
926
+ 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, preprocessTransportPayload, redactSensitiveJSON, redactSensitiveSearchParams, respond, safeExecute, sensitiveLogKeyParts, sqlWhere, success, uploadValidationError, uploadValidationErrorsArray, uploadValidationErrorsRecord, validateUploadFile, validateUploadFiles, zodAtLeastOne, zodBulkSelectionSchema, zodPaginationSchema, zodPaginationShape, zodSearchQuerySchema, zodSearchSchema, zodUploadFileSchema };
package/dist/index.js CHANGED
@@ -524,6 +524,20 @@ var parseQueryValue = (value) => {
524
524
  return value;
525
525
  };
526
526
  var asQuery = (schema) => z5.preprocess(parseQueryValue, schema);
527
+ function preprocessTransportPayload(value) {
528
+ if (Array.isArray(value)) {
529
+ return value.map(preprocessTransportPayload);
530
+ }
531
+ if (isPlainObject(value)) {
532
+ const entries = Object.entries(value).map(([key, entryValue]) => {
533
+ return [key, preprocessTransportPayload(entryValue)];
534
+ });
535
+ return Object.fromEntries(entries);
536
+ }
537
+ if (value === null || value === void 0)
538
+ return value;
539
+ return String(value);
540
+ }
527
541
  export {
528
542
  DEFAULT_UPLOAD_MAX_FILE_SIZE,
529
543
  EXCEPTION_STATUS_CODES,
@@ -570,6 +584,7 @@ export {
570
584
  normalizeFileExtension,
571
585
  onHandlerError,
572
586
  parseQueryValue,
587
+ preprocessTransportPayload,
573
588
  redactSensitiveJSON,
574
589
  redactSensitiveSearchParams,
575
590
  respond,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kalutskii/foundation",
3
- "version": "0.7.15",
3
+ "version": "0.7.17",
4
4
  "description": "Typescript collection of most common utilities, schemas and functions among private projects.",
5
5
  "license": "MIT",
6
6
  "type": "module",