@danceroutine/tango-core 1.11.0 → 1.11.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/dist/{TangoError-DdQVQNZU.js → TangoError-Cvgnm026.js} +8 -4
- package/dist/TangoError-Cvgnm026.js.map +1 -0
- package/dist/TangoError-ptR2iApz.d.ts +45 -0
- package/dist/chunk-D7D4PA-g.js +13 -0
- package/dist/errors/index.d.ts +3 -15
- package/dist/errors/index.js +3 -5
- package/dist/{errors-VacGsSaj.js → errors-DpI5Dxmr.js} +45 -36
- package/dist/errors-DpI5Dxmr.js.map +1 -0
- package/dist/http/index.d.ts +2 -10
- package/dist/http/index.js +2 -5
- package/dist/{http-63cMANMG.js → http-6e0y_vd6.js} +95 -79
- package/dist/{http-63cMANMG.js.map → http-6e0y_vd6.js.map} +1 -1
- package/dist/index-B5PoK4LH.d.ts +86 -0
- package/dist/index-D8o4DOOG.d.ts +824 -0
- package/dist/index-DFWodYLS.d.ts +161 -0
- package/dist/index-DPABSINz.d.ts +114 -0
- package/dist/index-MZzjIxgD.d.ts +59 -0
- package/dist/index.d.ts +7 -20
- package/dist/index.js +13 -7
- package/dist/index.js.map +1 -0
- package/dist/logging/index.d.ts +2 -3
- package/dist/logging/index.js +2 -3
- package/dist/logging-UC5uXHET.js +68 -0
- package/dist/logging-UC5uXHET.js.map +1 -0
- package/dist/runtime/index.d.ts +2 -14
- package/dist/runtime/index.js +2 -3
- package/dist/{runtime-B8KkgD3R.js → runtime-BAG_EKuM.js} +44 -35
- package/dist/runtime-BAG_EKuM.js.map +1 -0
- package/dist/sql/index.d.ts +2 -13
- package/dist/sql/index.js +2 -3
- package/dist/{sql-BI3ptL9-.js → sql-CIPnuTYO.js} +21 -16
- package/dist/{sql-BI3ptL9-.js.map → sql-CIPnuTYO.js.map} +1 -1
- package/package.json +3 -3
- package/dist/TangoError-DdQVQNZU.js.map +0 -1
- package/dist/chunk-BkvOhyD0.js +0 -12
- package/dist/errors/AuthenticationError.d.ts +0 -15
- package/dist/errors/ConflictError.d.ts +0 -15
- package/dist/errors/HttpError.d.ts +0 -7
- package/dist/errors/MultipleObjectsReturned.d.ts +0 -11
- package/dist/errors/NotFoundError.d.ts +0 -15
- package/dist/errors/PermissionDenied.d.ts +0 -15
- package/dist/errors/TangoError.d.ts +0 -33
- package/dist/errors/ValidationError.d.ts +0 -14
- package/dist/errors/factories/HttpErrorFactory.d.ts +0 -59
- package/dist/errors/factories/index.d.ts +0 -4
- package/dist/errors-VacGsSaj.js.map +0 -1
- package/dist/http/TangoBody.d.ts +0 -110
- package/dist/http/TangoHeaders.d.ts +0 -191
- package/dist/http/TangoQueryParams.d.ts +0 -81
- package/dist/http/TangoRequest.d.ts +0 -130
- package/dist/http/TangoResponse.d.ts +0 -305
- package/dist/logging/ConsoleLogger.d.ts +0 -15
- package/dist/logging/Logger.d.ts +0 -13
- package/dist/logging/getLogger.d.ts +0 -23
- package/dist/logging-BWeD4HOO.js +0 -48
- package/dist/logging-BWeD4HOO.js.map +0 -1
- package/dist/runtime/binary/index.d.ts +0 -6
- package/dist/runtime/binary/isArrayBuffer.d.ts +0 -4
- package/dist/runtime/binary/isBlob.d.ts +0 -4
- package/dist/runtime/binary/isUint8Array.d.ts +0 -4
- package/dist/runtime/date/index.d.ts +0 -4
- package/dist/runtime/date/isDate.d.ts +0 -4
- package/dist/runtime/error/index.d.ts +0 -4
- package/dist/runtime/error/isError.d.ts +0 -4
- package/dist/runtime/internal/hasTag.d.ts +0 -1
- package/dist/runtime/object/index.d.ts +0 -5
- package/dist/runtime/object/isNil.d.ts +0 -4
- package/dist/runtime/object/isObject.d.ts +0 -4
- package/dist/runtime/web/index.d.ts +0 -7
- package/dist/runtime/web/isFile.d.ts +0 -4
- package/dist/runtime/web/isFormData.d.ts +0 -4
- package/dist/runtime/web/isReadableStream.d.ts +0 -4
- package/dist/runtime/web/isURLSearchParams.d.ts +0 -4
- package/dist/runtime-B8KkgD3R.js.map +0 -1
- package/dist/sql/SqlDialect.d.ts +0 -5
- package/dist/sql/SqlIdentifierRole.d.ts +0 -13
- package/dist/sql/SqlSafetyEngine.d.ts +0 -50
- package/dist/sql/TrustedSqlFragment.d.ts +0 -5
- package/dist/sql/ValidatedSqlIdentifier.d.ts +0 -7
- package/dist/sql/isTrustedSqlFragment.d.ts +0 -5
- package/dist/sql/quoteSqlIdentifier.d.ts +0 -6
- package/dist/sql/trustedSql.d.ts +0 -5
- package/dist/sql/validateSqlIdentifier.d.ts +0 -6
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors-VacGsSaj.js","names":["config: HttpErrorFactoryConfig","value: unknown","error: unknown","error: ZodLikeError","details: Record<string, string[]>","errorClass: new (...args: any[]) => T","handler: (error: T) => HttpError","ErrorClass: new (...args: any[]) => Error","message: string","value: unknown","message: string","details?: ErrorDetails","err: unknown","message: string","value: unknown","message: string","value: unknown","message: string","value: unknown","message: string","value: unknown"],"sources":["../src/errors/factories/HttpErrorFactory.ts","../src/errors/factories/index.ts","../src/errors/ConflictError.ts","../src/errors/ValidationError.ts","../src/errors/MultipleObjectsReturned.ts","../src/errors/NotFoundError.ts","../src/errors/PermissionDenied.ts","../src/errors/AuthenticationError.ts","../src/errors/index.ts"],"sourcesContent":["import { TangoError } from '../TangoError';\nimport type { HttpError } from '../HttpError';\nimport { isError, isObject } from '../../runtime/index';\n\nexport interface HttpErrorFactoryConfig {\n /**\n * When true, raw error messages are included in HTTP responses.\n * When false, generic messages are returned for non-TangoError exceptions.\n * Defaults to true (dev-friendly). Set to false in production.\n */\n exposeErrors?: boolean;\n}\n\ntype ZodLikeIssue = {\n path?: unknown[];\n message?: unknown;\n};\n\ntype ZodLikeError = Error & {\n issues: ZodLikeIssue[];\n};\n\n/**\n * Converts errors into structured HTTP error responses.\n * Supports TangoError subclasses out of the box, and custom error handlers\n * can be registered for third-party or application-specific error types.\n *\n * @example\n * ```typescript\n * // Development (default) — exposes real error messages\n * const devFactory = new HttpErrorFactory();\n *\n * // Production — hides internal error details\n * const prodFactory = new HttpErrorFactory({ exposeErrors: false });\n *\n * // Register a custom handler for a third-party error\n * prodFactory.registerHandler(ZodError, (err) => ({\n * status: 400,\n * body: { error: 'Validation failed', details: err.flatten().fieldErrors },\n * }));\n *\n * // Quick one-shot conversion with dev defaults\n * const httpError = HttpErrorFactory.toHttpError(new NotFoundError('missing'));\n * ```\n */\nexport class HttpErrorFactory {\n static readonly BRAND = 'tango.error_factory.http' as const;\n readonly __tangoBrand: typeof HttpErrorFactory.BRAND = HttpErrorFactory.BRAND;\n\n // oxlint-disable-next-line typescript/no-explicit-any\n private handlers = new Map<new (...args: any[]) => Error, (error: Error) => HttpError>();\n private exposeErrors: boolean;\n\n constructor(config: HttpErrorFactoryConfig = {}) {\n this.exposeErrors = config.exposeErrors ?? true;\n }\n\n /**\n * Narrow an unknown value to `HttpErrorFactory`.\n */\n static isHttpErrorFactory(value: unknown): value is HttpErrorFactory {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as { __tangoBrand?: unknown }).__tangoBrand === HttpErrorFactory.BRAND\n );\n }\n\n /**\n * Convert an unknown error into an `HttpError` using dev-friendly defaults.\n * Shorthand for `new HttpErrorFactory().create(error)`.\n */\n static toHttpError(error: unknown): HttpError {\n return new HttpErrorFactory().create(error);\n }\n\n private static isZodLikeValidationError(error: unknown): error is ZodLikeError {\n return (\n isError(error) &&\n isObject(error) &&\n Array.isArray((error as { issues?: unknown }).issues) &&\n (error as { name?: unknown }).name === 'ZodError'\n );\n }\n\n private static zodLikeErrorDetails(error: ZodLikeError): Record<string, string[]> {\n const details: Record<string, string[]> = {};\n\n for (const issue of error.issues) {\n const key = Array.isArray(issue.path) && issue.path.length > 0 ? String(issue.path.join('.')) : '_schema';\n const message = typeof issue.message === 'string' ? issue.message : 'Invalid value';\n\n const existing = details[key];\n if (existing) {\n existing.push(message);\n } else {\n details[key] = [message];\n }\n }\n\n return details;\n }\n\n /**\n * Register a custom mapper for an application or third-party error type.\n */\n\n // oxlint-disable-next-line typescript/no-explicit-any\n registerHandler<T extends Error>(errorClass: new (...args: any[]) => T, handler: (error: T) => HttpError): this {\n this.handlers.set(errorClass, handler as (error: Error) => HttpError);\n return this;\n }\n\n /**\n * Convert an unknown error into the normalized HTTP error shape Tango uses.\n */\n create(error: unknown): HttpError {\n if (TangoError.isTangoError(error)) {\n return error.toHttpError();\n }\n\n if (HttpErrorFactory.isZodLikeValidationError(error)) {\n return {\n status: 400,\n body: {\n error: error.message || 'Validation failed',\n details: HttpErrorFactory.zodLikeErrorDetails(error),\n },\n };\n }\n\n for (const [ErrorClass, handler] of this.handlers) {\n if (this.isErrorClassInstance(error, ErrorClass)) {\n return handler(error);\n }\n }\n\n if (isError(error)) {\n return {\n status: 500,\n body: {\n error: this.exposeErrors ? error.message : 'Internal Server Error',\n details: null,\n },\n };\n }\n\n return {\n status: 500,\n body: {\n error: 'Unknown error occurred',\n details: null,\n },\n };\n }\n\n // oxlint-disable-next-line typescript/no-explicit-any\n private isErrorClassInstance(error: unknown, ErrorClass: new (...args: any[]) => Error): error is Error {\n if (!isError(error)) {\n return false;\n }\n\n const expectedBrand = (ErrorClass as { BRAND?: unknown }).BRAND;\n if (\n typeof expectedBrand === 'string' &&\n isObject(error) &&\n (error as { __tangoBrand?: unknown }).__tangoBrand === expectedBrand\n ) {\n return true;\n }\n\n const constructorName = (error as { constructor?: { name?: unknown } }).constructor?.name;\n if (typeof constructorName === 'string' && constructorName === ErrorClass.name) {\n return true;\n }\n\n const errorName = (error as { name?: unknown }).name;\n if (typeof errorName === 'string' && errorName === ErrorClass.name) {\n return true;\n }\n\n return false;\n }\n}\n","/**\n * Domain boundary barrel: centralizes this subdomain's public contract.\n */\n\nexport { HttpErrorFactory, type HttpErrorFactoryConfig } from './HttpErrorFactory';\n","import { TangoError, type ErrorDetails } from './TangoError';\n\n/** Error for conflicting resource state (HTTP 409). */\nexport class ConflictError extends TangoError {\n static readonly BRAND = 'tango.error.conflict' as const;\n readonly __tangoBrand: typeof ConflictError.BRAND = ConflictError.BRAND;\n status = 409;\n\n /** Create a conflict error with optional custom message. */\n constructor(message: string = 'Resource conflict') {\n super(message);\n this.name = 'ConflictError';\n Object.setPrototypeOf(this, ConflictError.prototype);\n }\n\n /**\n * Narrow an unknown value to `ConflictError`.\n */\n static isConflictError(value: unknown): value is ConflictError {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as { __tangoBrand?: unknown }).__tangoBrand === ConflictError.BRAND\n );\n }\n\n protected override getErrorName(): string {\n return 'conflict';\n }\n\n protected override getDetails(): ErrorDetails {\n return undefined;\n }\n}\n","import { TangoError, type ErrorDetails } from './TangoError';\n\n/** Error for request validation failures (HTTP 400). */\nexport class ValidationError extends TangoError {\n readonly __tangoValidationErrorBrand = 'tango.error.validation' as const;\n status = 400;\n\n constructor(\n message: string,\n public details?: ErrorDetails\n ) {\n super(message);\n this.name = 'ValidationError';\n Object.setPrototypeOf(this, ValidationError.prototype);\n }\n\n /**\n * Narrow an unknown value to `ValidationError`, including common legacy shapes.\n */\n static isValidationError(err: unknown): err is ValidationError {\n return (\n (!!err &&\n typeof err === 'object' &&\n (err as { __tangoValidationErrorBrand?: string }).__tangoValidationErrorBrand ===\n 'tango.error.validation') ||\n (typeof err === 'object' &&\n err !== null &&\n 'fields' in err &&\n typeof (err as { fields: unknown }).fields === 'object')\n );\n }\n\n protected override getErrorName(): string {\n return 'ValidationError';\n }\n\n protected override getDetails(): ErrorDetails {\n return this.details;\n }\n}\n","import { TangoError, type ErrorDetails } from './TangoError';\n\n/** Error when a queryset lookup returns more than one row (HTTP 409). */\nexport class MultipleObjectsReturned extends TangoError {\n static readonly BRAND = 'tango.error.multiple_objects_returned' as const;\n readonly __tangoBrand: typeof MultipleObjectsReturned.BRAND = MultipleObjectsReturned.BRAND;\n status = 409;\n\n constructor(message: string = 'Multiple objects returned') {\n super(message);\n this.name = 'MultipleObjectsReturned';\n Object.setPrototypeOf(this, MultipleObjectsReturned.prototype);\n }\n\n static isMultipleObjectsReturned(value: unknown): value is MultipleObjectsReturned {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as { __tangoBrand?: unknown }).__tangoBrand === MultipleObjectsReturned.BRAND\n );\n }\n\n protected override getErrorName(): string {\n return 'multiple_objects_returned';\n }\n\n protected override getDetails(): ErrorDetails {\n return undefined;\n }\n}\n","import { TangoError, type ErrorDetails } from './TangoError';\n\n/** Error for missing resources (HTTP 404). */\nexport class NotFoundError extends TangoError {\n static readonly BRAND = 'tango.error.not_found' as const;\n readonly __tangoBrand: typeof NotFoundError.BRAND = NotFoundError.BRAND;\n status = 404;\n\n /** Create a not-found error with optional custom message. */\n constructor(message: string = 'Resource not found') {\n super(message);\n this.name = 'NotFoundError';\n Object.setPrototypeOf(this, NotFoundError.prototype);\n }\n\n /**\n * Narrow an unknown value to `NotFoundError`.\n */\n static isNotFoundError(value: unknown): value is NotFoundError {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as { __tangoBrand?: unknown }).__tangoBrand === NotFoundError.BRAND\n );\n }\n\n protected override getErrorName(): string {\n return 'not_found';\n }\n\n protected override getDetails(): ErrorDetails {\n return undefined;\n }\n}\n","import { TangoError, type ErrorDetails } from './TangoError';\n\n/** Error for authorization failures (HTTP 403). */\nexport class PermissionDenied extends TangoError {\n static readonly BRAND = 'tango.error.permission_denied' as const;\n readonly __tangoBrand: typeof PermissionDenied.BRAND = PermissionDenied.BRAND;\n status = 403;\n\n /** Create a permission-denied error with optional custom message. */\n constructor(message: string = 'Permission denied') {\n super(message);\n this.name = 'PermissionDenied';\n Object.setPrototypeOf(this, PermissionDenied.prototype);\n }\n\n /**\n * Narrow an unknown value to `PermissionDenied`.\n */\n static isPermissionDenied(value: unknown): value is PermissionDenied {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as { __tangoBrand?: unknown }).__tangoBrand === PermissionDenied.BRAND\n );\n }\n\n protected override getErrorName(): string {\n return 'permission_denied';\n }\n\n protected override getDetails(): ErrorDetails {\n return undefined;\n }\n}\n","import { TangoError, type ErrorDetails } from './TangoError';\n\n/** Error for missing/invalid authentication (HTTP 401). */\nexport class AuthenticationError extends TangoError {\n static readonly BRAND = 'tango.error.authentication' as const;\n readonly __tangoBrand: typeof AuthenticationError.BRAND = AuthenticationError.BRAND;\n status = 401;\n\n /** Create an authentication error with optional custom message. */\n constructor(message: string = 'Authentication required') {\n super(message);\n this.name = 'AuthenticationError';\n Object.setPrototypeOf(this, AuthenticationError.prototype);\n }\n\n /**\n * Narrow an unknown value to `AuthenticationError`.\n */\n static isAuthenticationError(value: unknown): value is AuthenticationError {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as { __tangoBrand?: unknown }).__tangoBrand === AuthenticationError.BRAND\n );\n }\n\n protected override getErrorName(): string {\n return 'authentication_error';\n }\n\n protected override getDetails(): ErrorDetails {\n return undefined;\n }\n}\n","/**\n * Domain boundary barrel: centralizes this subdomain's public contract.\n */\n\nimport type { HttpError } from './HttpError';\nimport * as factories from './factories/index';\nimport { TangoError, type ErrorDetails, type ErrorEnvelope, type ProblemDetails } from './TangoError';\nimport { ConflictError } from './ConflictError';\nimport { ValidationError } from './ValidationError';\nimport { MultipleObjectsReturned } from './MultipleObjectsReturned';\nimport { NotFoundError } from './NotFoundError';\nimport { PermissionDenied } from './PermissionDenied';\nimport { AuthenticationError } from './AuthenticationError';\nimport { HttpErrorFactory, type HttpErrorFactoryConfig } from './factories/HttpErrorFactory';\n\nexport {\n AuthenticationError,\n ConflictError,\n HttpErrorFactory,\n MultipleObjectsReturned,\n NotFoundError,\n PermissionDenied,\n TangoError,\n ValidationError,\n factories,\n};\n\nexport type { ErrorDetails, ErrorEnvelope, HttpError, HttpErrorFactoryConfig, ProblemDetails };\n"],"mappings":";;;;;IA6Ca,mBAAN,MAAM,iBAAiB;CAC1B,OAAgB,QAAQ;CACxB,eAAuD,iBAAiB;CAGxE,WAAmB,IAAI;CACvB;CAEA,YAAYA,SAAiC,CAAE,GAAE;AAC7C,OAAK,eAAe,OAAO,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ACZ,SAAO,eAAe,MAAM,oBAAoB,UAAU;CAC7D;;;;CAKD,OAAO,sBAAsBC,OAA8C;AACvE,gBACW,UAAU,YACjB,UAAU,QACT,MAAqC,iBAAiB,oBAAoB;CAElF;CAED,eAA0C;AACtC,SAAO;CACV;CAED,aAA8C;AAC1C,SAAO;CACV;AACJ"}
|
package/dist/http/TangoBody.d.ts
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The full type of body that TangoResponse/TangoBody supports.
|
|
3
|
-
* Unlike the fetch spec BodyInit, this can be directly:
|
|
4
|
-
* - a string, ArrayBuffer, Uint8Array, Blob, FormData, ReadableStream, or JSON-like object, or null/undefined.
|
|
5
|
-
*/
|
|
6
|
-
type HeadersLike = {
|
|
7
|
-
get?: (arg: string) => string | null;
|
|
8
|
-
};
|
|
9
|
-
type TangoBodySource = BodyInit | JsonValue | null;
|
|
10
|
-
/** Recursive JSON value contract used by Tango HTTP helpers. */
|
|
11
|
-
export type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
12
|
-
[key: string]: JsonValue;
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* Unified body reader/clone utility for Tango request/response wrappers.
|
|
16
|
-
*/
|
|
17
|
-
export declare class TangoBody {
|
|
18
|
-
static readonly BRAND: "tango.http.body";
|
|
19
|
-
readonly __tangoBrand: typeof TangoBody.BRAND;
|
|
20
|
-
private bodySourceInternal;
|
|
21
|
-
private bodyUsedInternal;
|
|
22
|
-
private headers?;
|
|
23
|
-
constructor(bodySource: TangoBodySource, headers?: HeadersLike);
|
|
24
|
-
/**
|
|
25
|
-
* Narrow an unknown value to `TangoBody`.
|
|
26
|
-
*/
|
|
27
|
-
static isTangoBody(value: unknown): value is TangoBody;
|
|
28
|
-
/**
|
|
29
|
-
* Expose the original body source for cloning and adapter integration.
|
|
30
|
-
*/
|
|
31
|
-
get bodySource(): TangoBodySource;
|
|
32
|
-
/**
|
|
33
|
-
* Report whether a reader method has already consumed this body.
|
|
34
|
-
*/
|
|
35
|
-
get bodyUsed(): boolean;
|
|
36
|
-
/**
|
|
37
|
-
* Describe the current body shape in a way that is useful for diagnostics.
|
|
38
|
-
*/
|
|
39
|
-
get bodyType(): string;
|
|
40
|
-
/**
|
|
41
|
-
* Returns true if value is a valid JSON value (recursively).
|
|
42
|
-
*/
|
|
43
|
-
static isJsonValue(v: unknown): v is JsonValue;
|
|
44
|
-
/**
|
|
45
|
-
* Deep clone utility for body values. Preserves types and values as in the legacy implementation.
|
|
46
|
-
* If the source is a stream, the stream will be cloned if readable, otherwise throws.
|
|
47
|
-
*/
|
|
48
|
-
static deepCloneBody(body: TangoBodySource): TangoBodySource;
|
|
49
|
-
/**
|
|
50
|
-
* Read a `ReadableStream` into an `ArrayBuffer`.
|
|
51
|
-
*/
|
|
52
|
-
static readStreamToArrayBuffer(stream: ReadableStream<Uint8Array>): Promise<ArrayBuffer>;
|
|
53
|
-
/**
|
|
54
|
-
* Read a `ReadableStream` into a `Uint8Array`.
|
|
55
|
-
*/
|
|
56
|
-
static readStreamToUint8Array(stream: ReadableStream<Uint8Array>): Promise<Uint8Array<ArrayBuffer>>;
|
|
57
|
-
/**
|
|
58
|
-
* Read a `ReadableStream` into UTF-8 text.
|
|
59
|
-
*/
|
|
60
|
-
static readStreamToText(stream: ReadableStream<Uint8Array>): Promise<string>;
|
|
61
|
-
/**
|
|
62
|
-
* Determine the content type for this body, if possible.
|
|
63
|
-
* Respects an explicitly passed header, otherwise infers from value type.
|
|
64
|
-
*/
|
|
65
|
-
static detectContentType(body: TangoBodySource, providedType?: string): string | undefined;
|
|
66
|
-
/**
|
|
67
|
-
* Attempt to determine the content length, in bytes, for this body.
|
|
68
|
-
* Only available for certain body types, otherwise returns undefined.
|
|
69
|
-
*/
|
|
70
|
-
static getContentLength(body: TangoBodySource): Promise<number | undefined>;
|
|
71
|
-
/**
|
|
72
|
-
* Reads the body as an ArrayBuffer.
|
|
73
|
-
*/
|
|
74
|
-
arrayBuffer(): Promise<ArrayBuffer>;
|
|
75
|
-
/**
|
|
76
|
-
* Reads the body as a Blob (browser only).
|
|
77
|
-
*/
|
|
78
|
-
blob(): Promise<Blob>;
|
|
79
|
-
/**
|
|
80
|
-
* Reads the body as a Uint8Array.
|
|
81
|
-
*/
|
|
82
|
-
bytes(): Promise<Uint8Array<ArrayBuffer>>;
|
|
83
|
-
/**
|
|
84
|
-
* Reads the body as FormData.
|
|
85
|
-
* Accepts FormData, or if type is urlencoded or multipart parses a string/bytes.
|
|
86
|
-
*/
|
|
87
|
-
formData(): Promise<FormData>;
|
|
88
|
-
/**
|
|
89
|
-
* Reads and parses the body as JSON (if possible).
|
|
90
|
-
*/
|
|
91
|
-
json<T = unknown>(): Promise<T>;
|
|
92
|
-
/**
|
|
93
|
-
* Reads the body as UTF-8 string.
|
|
94
|
-
*/
|
|
95
|
-
text(): Promise<string>;
|
|
96
|
-
/**
|
|
97
|
-
* Returns the original body value (may be used for streaming or clone).
|
|
98
|
-
*/
|
|
99
|
-
getRawBodyInit(): TangoBodySource;
|
|
100
|
-
/**
|
|
101
|
-
* Clone the body instance and stream if possible.
|
|
102
|
-
* If the source is a stream, the stream will be cloned if readable, otherwise throws.
|
|
103
|
-
*/
|
|
104
|
-
clone(): TangoBody;
|
|
105
|
-
/**
|
|
106
|
-
* Helper for all readers. Only allows reading once.
|
|
107
|
-
*/
|
|
108
|
-
private consumeBody;
|
|
109
|
-
}
|
|
110
|
-
export {};
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TangoHeaders extends the Web Headers class, adding ergonomic helpers
|
|
3
|
-
* for common HTTP header patterns, convenience features, and a consistent API for
|
|
4
|
-
* setting, appending, and deleting headers and cookies. This is designed to be
|
|
5
|
-
* used by TangoResponse and other Tango HTTP utilities.
|
|
6
|
-
* Additionally, provides helpers for safely setting Content-Length based on a known body,
|
|
7
|
-
* and setting Content-Disposition for inline or attachment filenames.
|
|
8
|
-
*
|
|
9
|
-
* Includes helpers for request tracing and correlation headers:
|
|
10
|
-
* - X-Request-Id
|
|
11
|
-
* - traceparent (W3C Trace Context)
|
|
12
|
-
* - Server-Timing
|
|
13
|
-
* - X-Response-Time
|
|
14
|
-
*/
|
|
15
|
-
export declare class TangoHeaders extends Headers {
|
|
16
|
-
static readonly BRAND: "tango.http.headers";
|
|
17
|
-
readonly __tangoBrand: typeof TangoHeaders.BRAND;
|
|
18
|
-
/**
|
|
19
|
-
* Narrow an unknown value to `TangoHeaders`.
|
|
20
|
-
*/
|
|
21
|
-
static isTangoHeaders(value: unknown): value is TangoHeaders;
|
|
22
|
-
/**
|
|
23
|
-
* Serialize a cookie for the Set-Cookie header line.
|
|
24
|
-
*/
|
|
25
|
-
private static serializeCookie;
|
|
26
|
-
private static hasNumberSize;
|
|
27
|
-
private static hasNumberLength;
|
|
28
|
-
private static isNodeBuffer;
|
|
29
|
-
/**
|
|
30
|
-
* Sets the Content-Disposition header with type "inline" and the specified filename.
|
|
31
|
-
* This is useful to indicate that the content should be displayed inline in the browser,
|
|
32
|
-
* but with a suggested filename for saving.
|
|
33
|
-
*
|
|
34
|
-
* @param filename The filename to include in the Content-Disposition header.
|
|
35
|
-
*/
|
|
36
|
-
setContentDispositionInline(filename: string): void;
|
|
37
|
-
/**
|
|
38
|
-
* Sets the Content-Disposition header with type "attachment" and the specified filename.
|
|
39
|
-
* This is useful to indicate that the response should be downloaded as a file.
|
|
40
|
-
*
|
|
41
|
-
* @param filename The filename to include in the Content-Disposition header.
|
|
42
|
-
*/
|
|
43
|
-
setContentDispositionAttachment(filename: string): void;
|
|
44
|
-
/**
|
|
45
|
-
* Create a copy that preserves all header names and values.
|
|
46
|
-
*/
|
|
47
|
-
clone(): TangoHeaders;
|
|
48
|
-
/**
|
|
49
|
-
* Set a header, replacing the existing value.
|
|
50
|
-
*/
|
|
51
|
-
setHeader(name: string, value: string): void;
|
|
52
|
-
/**
|
|
53
|
-
* Append a header, adding to existing value(s) for the name.
|
|
54
|
-
*/
|
|
55
|
-
appendHeader(name: string, value: string): void;
|
|
56
|
-
/**
|
|
57
|
-
* Get a header value (first value if header is repeated).
|
|
58
|
-
*/
|
|
59
|
-
getHeader(name: string): string | null;
|
|
60
|
-
/**
|
|
61
|
-
* Check if a header exists.
|
|
62
|
-
*/
|
|
63
|
-
hasHeader(name: string): boolean;
|
|
64
|
-
/**
|
|
65
|
-
* Delete a header.
|
|
66
|
-
*/
|
|
67
|
-
deleteHeader(name: string): void;
|
|
68
|
-
/**
|
|
69
|
-
* Ensure a header is present only once and fully replaces the old value.
|
|
70
|
-
*/
|
|
71
|
-
ensureUnique(name: string, value: string): void;
|
|
72
|
-
/**
|
|
73
|
-
* Add a field (or fields) to the Vary header, merging with existing values.
|
|
74
|
-
*/
|
|
75
|
-
vary(...fields: string[]): void;
|
|
76
|
-
/**
|
|
77
|
-
* Set a cookie header (for Set-Cookie).
|
|
78
|
-
* @param name
|
|
79
|
-
* @param value
|
|
80
|
-
* @param options
|
|
81
|
-
*/
|
|
82
|
-
setCookie(name: string, value: string, options?: {
|
|
83
|
-
domain?: string;
|
|
84
|
-
expires?: Date;
|
|
85
|
-
httpOnly?: boolean;
|
|
86
|
-
maxAge?: number;
|
|
87
|
-
path?: string;
|
|
88
|
-
sameSite?: 'Strict' | 'Lax' | 'None';
|
|
89
|
-
secure?: boolean;
|
|
90
|
-
priority?: 'Low' | 'Medium' | 'High';
|
|
91
|
-
partitioned?: boolean;
|
|
92
|
-
}): void;
|
|
93
|
-
/**
|
|
94
|
-
* Append (additionally) a new cookie.
|
|
95
|
-
*/
|
|
96
|
-
appendCookie(name: string, value: string, options?: {
|
|
97
|
-
domain?: string;
|
|
98
|
-
expires?: Date;
|
|
99
|
-
httpOnly?: boolean;
|
|
100
|
-
maxAge?: number;
|
|
101
|
-
path?: string;
|
|
102
|
-
sameSite?: 'Strict' | 'Lax' | 'None';
|
|
103
|
-
secure?: boolean;
|
|
104
|
-
priority?: 'Low' | 'Medium' | 'High';
|
|
105
|
-
partitioned?: boolean;
|
|
106
|
-
}): void;
|
|
107
|
-
/**
|
|
108
|
-
* Delete a cookie ("unset" it via expired date).
|
|
109
|
-
*/
|
|
110
|
-
deleteCookie(name: string, options?: {
|
|
111
|
-
domain?: string;
|
|
112
|
-
path?: string;
|
|
113
|
-
sameSite?: 'Strict' | 'Lax' | 'None';
|
|
114
|
-
secure?: boolean;
|
|
115
|
-
priority?: 'Low' | 'Medium' | 'High';
|
|
116
|
-
partitioned?: boolean;
|
|
117
|
-
}): void;
|
|
118
|
-
/**
|
|
119
|
-
* Add or override Cache-Control header with helpers for common policies.
|
|
120
|
-
*/
|
|
121
|
-
cacheControl(control: string | Record<string, string | number | boolean | undefined>): void;
|
|
122
|
-
/**
|
|
123
|
-
* Set the Location header.
|
|
124
|
-
*/
|
|
125
|
-
location(url: string): void;
|
|
126
|
-
/**
|
|
127
|
-
* Set the Content-Type header.
|
|
128
|
-
*/
|
|
129
|
-
contentType(mime: string): void;
|
|
130
|
-
/**
|
|
131
|
-
* Attempt to guess and set the Content-Type header from a file (string or Blob) and optional filename.
|
|
132
|
-
*
|
|
133
|
-
* @param file File-like input (string or Blob)
|
|
134
|
-
* @param filename Optional filename to help guess mime type by extension
|
|
135
|
-
*/
|
|
136
|
-
setContentTypeByFile(file: unknown, filename?: string): void;
|
|
137
|
-
/**
|
|
138
|
-
* Sets the Content-Length header, inferring it from the body if not explicitly provided.
|
|
139
|
-
* If the body is a string, ArrayBuffer, Uint8Array, Blob/Buffer (or has a .size or .length property),
|
|
140
|
-
* the length is computed. For unsupported types, does nothing.
|
|
141
|
-
* Mirrors logic from TangoResponse.ts, but generalized for use anywhere.
|
|
142
|
-
*/
|
|
143
|
-
setContentLengthFromBody(body: unknown): void;
|
|
144
|
-
/**
|
|
145
|
-
* Set or update the X-Request-Id header. Used for associating a request/response with a unique id.
|
|
146
|
-
* @param id The request id value to set.
|
|
147
|
-
*/
|
|
148
|
-
withRequestId(id: string): this;
|
|
149
|
-
/**
|
|
150
|
-
* Set or update the traceparent header. Used for distributed trace context propagation (W3C Trace Context).
|
|
151
|
-
* @param value The traceparent value (should be a valid traceparent header value).
|
|
152
|
-
*/
|
|
153
|
-
withTraceParent(value: string): this;
|
|
154
|
-
/**
|
|
155
|
-
* Set or append a value to the Server-Timing header.
|
|
156
|
-
* For a single metric, supply name, and optionally dur and desc.
|
|
157
|
-
* For advanced usage (many metrics), set the value directly or use appendServerTimingRaw.
|
|
158
|
-
*
|
|
159
|
-
* @param name Name of the server-timing metric (e.g., 'total', 'db').
|
|
160
|
-
* @param dur Optional duration in ms.
|
|
161
|
-
* @param desc Optional string description.
|
|
162
|
-
*/
|
|
163
|
-
withServerTiming(name: string, dur?: number, desc?: string): this;
|
|
164
|
-
/**
|
|
165
|
-
* Directly append a raw Server-Timing metric value.
|
|
166
|
-
* This is useful for advanced cases where you have multiple metrics assembled.
|
|
167
|
-
* @param value The server-timing value chunk to append.
|
|
168
|
-
*/
|
|
169
|
-
appendServerTimingRaw(value: string): this;
|
|
170
|
-
/**
|
|
171
|
-
* Set or update X-Response-Time header.
|
|
172
|
-
* @param ms Elapsed time in milliseconds (number or string for flexibility).
|
|
173
|
-
*/
|
|
174
|
-
withResponseTime(ms: number | string): this;
|
|
175
|
-
/**
|
|
176
|
-
* Return the current value of X-Request-Id.
|
|
177
|
-
*/
|
|
178
|
-
getRequestId(): string | null;
|
|
179
|
-
/**
|
|
180
|
-
* Return the current value of traceparent header.
|
|
181
|
-
*/
|
|
182
|
-
getTraceParent(): string | null;
|
|
183
|
-
/**
|
|
184
|
-
* Return the current Server-Timing string, if set.
|
|
185
|
-
*/
|
|
186
|
-
getServerTiming(): string | null;
|
|
187
|
-
/**
|
|
188
|
-
* Return the current X-Response-Time string, if set.
|
|
189
|
-
*/
|
|
190
|
-
getResponseTime(): string | null;
|
|
191
|
-
}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import type { TangoRequest } from './TangoRequest';
|
|
2
|
-
type QueryParamRecord = Record<string, string | string[] | undefined>;
|
|
3
|
-
type QueryParamMutationValue = string | number | readonly (string | number)[] | null | undefined;
|
|
4
|
-
type QueryParamMutationRecord = Record<string, QueryParamMutationValue>;
|
|
5
|
-
/**
|
|
6
|
-
* Immutable query parameter helper that normalizes framework-specific shapes
|
|
7
|
-
* into one Tango-owned API.
|
|
8
|
-
*/
|
|
9
|
-
export declare class TangoQueryParams {
|
|
10
|
-
static readonly BRAND: "tango.http.query_params";
|
|
11
|
-
readonly __tangoBrand: typeof TangoQueryParams.BRAND;
|
|
12
|
-
private readonly values;
|
|
13
|
-
private constructor();
|
|
14
|
-
/**
|
|
15
|
-
* Narrow an unknown value to `TangoQueryParams`.
|
|
16
|
-
*/
|
|
17
|
-
static isTangoQueryParams(value: unknown): value is TangoQueryParams;
|
|
18
|
-
/**
|
|
19
|
-
* Build query params from a `URLSearchParams` instance.
|
|
20
|
-
*/
|
|
21
|
-
static fromURLSearchParams(params: URLSearchParams): TangoQueryParams;
|
|
22
|
-
/**
|
|
23
|
-
* Build query params from framework record-style search params.
|
|
24
|
-
*/
|
|
25
|
-
static fromRecord(params: QueryParamRecord): TangoQueryParams;
|
|
26
|
-
/**
|
|
27
|
-
* Build query params from a full URL string or URL object.
|
|
28
|
-
*/
|
|
29
|
-
static fromURL(input: string | URL): TangoQueryParams;
|
|
30
|
-
/**
|
|
31
|
-
* Build query params from a request-like object with a URL.
|
|
32
|
-
*/
|
|
33
|
-
static fromRequest(request: Request | TangoRequest): TangoQueryParams;
|
|
34
|
-
/**
|
|
35
|
-
* Get the first value for a query param.
|
|
36
|
-
*/
|
|
37
|
-
get(name: string): string | undefined;
|
|
38
|
-
/**
|
|
39
|
-
* Get all values for a query param.
|
|
40
|
-
*/
|
|
41
|
-
getAll(name: string): string[];
|
|
42
|
-
/**
|
|
43
|
-
* Check whether a query param exists.
|
|
44
|
-
*/
|
|
45
|
-
has(name: string): boolean;
|
|
46
|
-
/**
|
|
47
|
-
* Iterate key -> values entries.
|
|
48
|
-
*/
|
|
49
|
-
entries(): IterableIterator<[string, string[]]>;
|
|
50
|
-
/**
|
|
51
|
-
* Iterate keys present in the query params.
|
|
52
|
-
*/
|
|
53
|
-
keys(): IterableIterator<string>;
|
|
54
|
-
/**
|
|
55
|
-
* Convert back to a native `URLSearchParams` object.
|
|
56
|
-
*/
|
|
57
|
-
toURLSearchParams(): URLSearchParams;
|
|
58
|
-
/**
|
|
59
|
-
* Return a new query param set with selected keys replaced or removed.
|
|
60
|
-
*
|
|
61
|
-
* `undefined`, `null`, and empty arrays remove the key entirely.
|
|
62
|
-
*/
|
|
63
|
-
withValues(updates: QueryParamMutationRecord): TangoQueryParams;
|
|
64
|
-
/**
|
|
65
|
-
* Convert to a relative query string suitable for links.
|
|
66
|
-
*/
|
|
67
|
-
toRelativeURL(): string;
|
|
68
|
-
/**
|
|
69
|
-
* Get a trimmed value, omitting blank strings.
|
|
70
|
-
*/
|
|
71
|
-
getTrimmed(name: string): string | undefined;
|
|
72
|
-
/**
|
|
73
|
-
* Get the free-text search param using Tango's default key.
|
|
74
|
-
*/
|
|
75
|
-
getSearch(key?: string): string | undefined;
|
|
76
|
-
/**
|
|
77
|
-
* Get the ordering param as trimmed field tokens.
|
|
78
|
-
*/
|
|
79
|
-
getOrdering(key?: string): string[];
|
|
80
|
-
}
|
|
81
|
-
export {};
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import type { JsonValue } from './TangoBody';
|
|
2
|
-
import { TangoQueryParams } from './TangoQueryParams';
|
|
3
|
-
type TangoRequestInit = {
|
|
4
|
-
method?: string;
|
|
5
|
-
headers?: HeadersInit;
|
|
6
|
-
body?: BodyInit | JsonValue | null;
|
|
7
|
-
redirect?: RequestRedirect;
|
|
8
|
-
cache?: RequestCache;
|
|
9
|
-
credentials?: RequestCredentials;
|
|
10
|
-
integrity?: string;
|
|
11
|
-
keepalive?: boolean;
|
|
12
|
-
mode?: RequestMode;
|
|
13
|
-
referrer?: string;
|
|
14
|
-
referrerPolicy?: ReferrerPolicy;
|
|
15
|
-
signal?: AbortSignal;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Framework request wrapper that normalizes JSON-like bodies and preserves
|
|
19
|
-
* fetch `Request` compatibility for downstream handlers.
|
|
20
|
-
*/
|
|
21
|
-
export declare class TangoRequest implements Request {
|
|
22
|
-
static readonly BRAND: "tango.http.request";
|
|
23
|
-
readonly __tangoBrand: typeof TangoRequest.BRAND;
|
|
24
|
-
private request;
|
|
25
|
-
private bodySourceValue;
|
|
26
|
-
private queryParamsValue?;
|
|
27
|
-
constructor(input: string | Request, init?: TangoRequestInit);
|
|
28
|
-
/**
|
|
29
|
-
* Narrow an unknown value to `TangoRequest`.
|
|
30
|
-
*/
|
|
31
|
-
static isTangoRequest(value: unknown): value is TangoRequest;
|
|
32
|
-
/**
|
|
33
|
-
* Expose the request cache mode from the underlying fetch request.
|
|
34
|
-
*/
|
|
35
|
-
get cache(): RequestCache;
|
|
36
|
-
/**
|
|
37
|
-
* Expose the request credentials mode from the underlying fetch request.
|
|
38
|
-
*/
|
|
39
|
-
get credentials(): RequestCredentials;
|
|
40
|
-
/**
|
|
41
|
-
* Expose the request destination from the underlying fetch request.
|
|
42
|
-
*/
|
|
43
|
-
get destination(): RequestDestination;
|
|
44
|
-
/**
|
|
45
|
-
* Expose the request headers from the underlying fetch request.
|
|
46
|
-
*/
|
|
47
|
-
get headers(): Headers;
|
|
48
|
-
/**
|
|
49
|
-
* Expose the request integrity value from the underlying fetch request.
|
|
50
|
-
*/
|
|
51
|
-
get integrity(): string;
|
|
52
|
-
/**
|
|
53
|
-
* Expose the request keepalive flag from the underlying fetch request.
|
|
54
|
-
*/
|
|
55
|
-
get keepalive(): boolean;
|
|
56
|
-
/**
|
|
57
|
-
* Expose the normalized HTTP method.
|
|
58
|
-
*/
|
|
59
|
-
get method(): string;
|
|
60
|
-
/**
|
|
61
|
-
* Expose the request mode from the underlying fetch request.
|
|
62
|
-
*/
|
|
63
|
-
get mode(): RequestMode;
|
|
64
|
-
/**
|
|
65
|
-
* Expose the redirect policy from the underlying fetch request.
|
|
66
|
-
*/
|
|
67
|
-
get redirect(): RequestRedirect;
|
|
68
|
-
/**
|
|
69
|
-
* Expose the referrer from the underlying fetch request.
|
|
70
|
-
*/
|
|
71
|
-
get referrer(): string;
|
|
72
|
-
/**
|
|
73
|
-
* Expose the referrer policy from the underlying fetch request.
|
|
74
|
-
*/
|
|
75
|
-
get referrerPolicy(): ReferrerPolicy;
|
|
76
|
-
/**
|
|
77
|
-
* Expose the abort signal from the underlying fetch request.
|
|
78
|
-
*/
|
|
79
|
-
get signal(): AbortSignal;
|
|
80
|
-
/**
|
|
81
|
-
* Expose the absolute request URL.
|
|
82
|
-
*/
|
|
83
|
-
get url(): string;
|
|
84
|
-
/**
|
|
85
|
-
* Expose the readable request body stream when one exists.
|
|
86
|
-
*/
|
|
87
|
-
get body(): Request['body'];
|
|
88
|
-
/**
|
|
89
|
-
* Report whether the body has been consumed.
|
|
90
|
-
*/
|
|
91
|
-
get bodyUsed(): boolean;
|
|
92
|
-
/**
|
|
93
|
-
* Expose the pre-normalized body value used to build the request.
|
|
94
|
-
*/
|
|
95
|
-
get bodySource(): BodyInit | JsonValue | null;
|
|
96
|
-
/**
|
|
97
|
-
* Expose normalized query parameters derived from the request URL.
|
|
98
|
-
*/
|
|
99
|
-
get queryParams(): TangoQueryParams;
|
|
100
|
-
/**
|
|
101
|
-
* Read the request body as an array buffer.
|
|
102
|
-
*/
|
|
103
|
-
arrayBuffer(): Promise<ArrayBuffer>;
|
|
104
|
-
/**
|
|
105
|
-
* Read the request body as a blob.
|
|
106
|
-
*/
|
|
107
|
-
blob(): Promise<Blob>;
|
|
108
|
-
/**
|
|
109
|
-
* Read the request body as bytes, including runtimes without `Request.bytes()`.
|
|
110
|
-
*/
|
|
111
|
-
bytes(): Promise<Uint8Array<ArrayBuffer>>;
|
|
112
|
-
/**
|
|
113
|
-
* Read the request body as form data.
|
|
114
|
-
*/
|
|
115
|
-
formData(): Promise<FormData>;
|
|
116
|
-
/**
|
|
117
|
-
* Parse the request body as JSON.
|
|
118
|
-
*/
|
|
119
|
-
json<T = unknown>(): Promise<T>;
|
|
120
|
-
/**
|
|
121
|
-
* Read the request body as text.
|
|
122
|
-
*/
|
|
123
|
-
text(): Promise<string>;
|
|
124
|
-
/**
|
|
125
|
-
* Clone the request so downstream code can consume it independently.
|
|
126
|
-
*/
|
|
127
|
-
clone(): TangoRequest;
|
|
128
|
-
private normalizeBody;
|
|
129
|
-
}
|
|
130
|
-
export {};
|