@kalutskii/foundation 0.7.0 → 0.7.2

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/README.md CHANGED
@@ -288,4 +288,6 @@ bun run lint
288
288
  bun run test
289
289
  bun run typecheck
290
290
  bun run build
291
+
292
+ just quality-assurance
291
293
  ```
package/dist/index.d.ts CHANGED
@@ -66,6 +66,16 @@ declare function respond<T extends object = Record<string, never>, S extends Suc
66
66
  status: S;
67
67
  data?: T;
68
68
  }): Response & TypedResponse<APISuccess<T> | APIError, S, 'json'>;
69
+ /**
70
+ * Responds with a file download, setting the appropriate headers for content disposition and type.
71
+ * Supports specifying a filename and optional content type, defaulting to 'application/octet-stream'.
72
+ */
73
+ declare function fileRespond<S extends SuccessStatusCode>(c: Context, options: {
74
+ status: S;
75
+ content: Uint8Array<ArrayBuffer>;
76
+ filename: string;
77
+ contentType?: string;
78
+ }): Response;
69
79
 
70
80
  /**
71
81
  * Factory for creating successful API responses with serializable data.
@@ -498,4 +508,4 @@ declare const asQuery: <T extends z.ZodTypeAny>(schema: T) => z.ZodPreprocess<T>
498
508
  */
499
509
  declare const isPlainObject: (value: unknown) => value is Record<string, unknown>;
500
510
 
501
- export { type APIContractData, type APIContractError, type APIContractResult, type APIError, type APISuccess, type AsQuery, type AtLeastOne, EXCEPTION_STATUS_CODES, type ExceptionStatusCode, type FetchResult, type JWTServiceOptions, type JWTSignOptions, type MeasuredExecution, type Payload, type PayloadSchema, type ReplaceDotsWithUnderscores, SUCCESS_STATUS_CODES, type Simplify, type StringEnumRecord, type SuccessStatusCode, type ZodBulkExcludeSelection, type ZodBulkIncludeSelection, type ZodBulkSelection, ZodJWTService, type ZodPaginationOptions, type ZodSearchSchemaOptions, asQuery, createStringEnumRecord, failure, fetchAndThrow, fetchSafely, formatTime, generateRandomString, getColoredHTTPStatus, getFormattedDate, getFormattedTime, getUTCOffset, getZonedTime, honoLoggingHandler, isPlainObject, log, measureExecutionTime, onHandlerError, parseQueryValue, respond, safeExecute, sqlWhere, success, zodAtLeastOne, zodBulkSelectionSchema, zodPaginationSchema, zodPaginationShape, zodSearchSchema };
511
+ export { type APIContractData, type APIContractError, type APIContractResult, type APIError, type APISuccess, type AsQuery, type AtLeastOne, EXCEPTION_STATUS_CODES, type ExceptionStatusCode, type FetchResult, type JWTServiceOptions, type JWTSignOptions, type MeasuredExecution, type Payload, type PayloadSchema, type ReplaceDotsWithUnderscores, SUCCESS_STATUS_CODES, type Simplify, type StringEnumRecord, type SuccessStatusCode, type ZodBulkExcludeSelection, type ZodBulkIncludeSelection, type ZodBulkSelection, ZodJWTService, type ZodPaginationOptions, type ZodSearchSchemaOptions, asQuery, createStringEnumRecord, failure, fetchAndThrow, fetchSafely, fileRespond, formatTime, generateRandomString, getColoredHTTPStatus, getFormattedDate, getFormattedTime, getUTCOffset, getZonedTime, honoLoggingHandler, isPlainObject, log, measureExecutionTime, onHandlerError, parseQueryValue, respond, safeExecute, sqlWhere, success, zodAtLeastOne, zodBulkSelectionSchema, zodPaginationSchema, zodPaginationShape, zodSearchSchema };
package/dist/index.js CHANGED
@@ -123,6 +123,11 @@ var honoLoggingHandler = async (c, next) => {
123
123
  function respond(c, options) {
124
124
  return c.json(success({ status: options.status, data: options.data ?? {} }), options.status);
125
125
  }
126
+ function fileRespond(c, options) {
127
+ c.header("Content-Disposition", `attachment; filename="${options.filename}"`);
128
+ c.header("Content-Type", options.contentType ?? "application/octet-stream");
129
+ return c.body(options.content, options.status);
130
+ }
126
131
 
127
132
  // src/http/http.constants.ts
128
133
  var SUCCESS_STATUS_CODES = [200, 201, 202, 307];
@@ -304,6 +309,7 @@ export {
304
309
  failure,
305
310
  fetchAndThrow,
306
311
  fetchSafely,
312
+ fileRespond,
307
313
  formatTime,
308
314
  generateRandomString,
309
315
  getColoredHTTPStatus,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kalutskii/foundation",
3
- "version": "0.7.0",
3
+ "version": "0.7.2",
4
4
  "description": "Typescript collection of most common utilities, schemas and functions among private projects.",
5
5
  "type": "module",
6
6
  "repository": {