@twin.org/web 0.0.4-next.7 → 0.9.0-next.1
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.
|
@@ -201,7 +201,7 @@ export class FetchHelper {
|
|
|
201
201
|
if (Is.integer(options?.cacheTtlMs) && options.cacheTtlMs >= 0) {
|
|
202
202
|
// The cache option is set, so call the same method again but without
|
|
203
203
|
// the cache option to get the result and cache it.
|
|
204
|
-
const cacheResponse = AsyncCache.exec(`${FetchHelper._CACHE_PREFIX}${url}`, options.cacheTtlMs
|
|
204
|
+
const cacheResponse = AsyncCache.exec(`${FetchHelper._CACHE_PREFIX}${url}`, options.cacheTtlMs, async () => FetchHelper.fetchBinary(source, url, method, requestData, ObjectHelper.omit(options, ["cacheTtlMs"])));
|
|
205
205
|
// If the return value is a promise return it, otherwise continue
|
|
206
206
|
// with the regular processing.
|
|
207
207
|
if (Is.promise(cacheResponse)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchHelper.js","sourceRoot":"","sources":["../../../src/utils/fetchHelper.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,YAAY,EAAe,MAAM,gBAAgB,CAAC;AAE9F,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAG7D,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEnD;;GAEG;AACH,MAAM,OAAO,WAAW;IACvB;;OAEG;IACI,MAAM,CAAU,UAAU,iBAAiC;IAElE;;;OAGG;IACK,MAAM,CAAU,aAAa,GAAW,QAAQ,CAAC;IAEzD;;;;;;;;O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AAC,CAAC;IAChE,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,KAAK,CAAC,aAAa,CAAI,GAAW,EAAE,KAAQ;QACzD,MAAM,UAAU,CAAC,GAAG,CAAI,GAAG,WAAW,CAAC,aAAa,GAAG,GAAG,EAAE,EAAE,KAAK,CAAC,CAAC;IACtE,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,gBAAgB,CAAC,GAAW;QACzC,UAAU,CAAC,MAAM,CAAC,GAAG,WAAW,CAAC,aAAa,GAAG,GAAG,EAAE,CAAC,CAAC;IACzD,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { AsyncCache, BaseError, Guards, Is, ObjectHelper, type IError } from \"@twin.org/core\";\nimport { nameof, nameofCamelCase } from \"@twin.org/nameof\";\nimport { FetchError } from \"../errors/fetchError.js\";\nimport { HeaderTypes } from \"../models/headerTypes.js\";\nimport { HttpMethod } from \"../models/httpMethod.js\";\nimport { HttpStatusCode } from \"../models/httpStatusCode.js\";\nimport type { IFetchOptions } from \"../models/IFetchOptions.js\";\nimport type { IHttpHeaders } from \"../models/IHttpHeaders.js\";\nimport { MimeTypes } from \"../models/mimeTypes.js\";\n\n/**\n * Class to helper with fetch operations.\n */\nexport class FetchHelper {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<FetchHelper>();\n\n\t/**\n\t * Prefix to use for cache entries.\n\t * @internal\n\t */\n\tprivate static readonly _CACHE_PREFIX: string = \"fetch_\";\n\n\t/**\n\t * Perform a fetch request.\n\t * @param source The source for the request.\n\t * @param url The url for the request.\n\t * @param method The http method.\n\t * @param body Request to send to the endpoint.\n\t * @param options Options for sending the requests.\n\t * @returns The response.\n\t */\n\tpublic static async fetch(\n\t\tsource: string,\n\t\turl: string,\n\t\tmethod: HttpMethod,\n\t\tbody?: string | Uint8Array,\n\t\toptions?: Omit<IFetchOptions, \"cacheTtlSeconds\">\n\t): Promise<Response> {\n\t\tGuards.string(FetchHelper.CLASS_NAME, nameof(source), source);\n\t\tGuards.string(FetchHelper.CLASS_NAME, nameof(url), url);\n\t\tGuards.arrayOneOf<HttpMethod>(\n\t\t\tFetchHelper.CLASS_NAME,\n\t\t\tnameof(method),\n\t\t\tmethod,\n\t\t\tObject.values(HttpMethod)\n\t\t);\n\t\tif (!Is.undefined(body) && !Is.uint8Array(body)) {\n\t\t\tGuards.string(FetchHelper.CLASS_NAME, nameof(body), body);\n\t\t}\n\t\tif (!Is.undefined(options)) {\n\t\t\tGuards.object<IFetchOptions>(FetchHelper.CLASS_NAME, nameof(options), options);\n\t\t\tif (!Is.undefined(options.headers)) {\n\t\t\t\tGuards.object<IHttpHeaders>(\n\t\t\t\t\tFetchHelper.CLASS_NAME,\n\t\t\t\t\tnameof(options.headers),\n\t\t\t\t\toptions.headers\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (!Is.undefined(options.timeoutMs)) {\n\t\t\t\tGuards.integer(FetchHelper.CLASS_NAME, nameof(options.timeoutMs), options.timeoutMs);\n\t\t\t}\n\t\t\tif (!Is.undefined(options.includeCredentials)) {\n\t\t\t\tGuards.boolean(\n\t\t\t\t\tFetchHelper.CLASS_NAME,\n\t\t\t\t\tnameof(options.includeCredentials),\n\t\t\t\t\toptions.includeCredentials\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (!Is.undefined(options.retryCount)) {\n\t\t\t\tGuards.integer(FetchHelper.CLASS_NAME, nameof(options.retryCount), options.retryCount);\n\t\t\t}\n\t\t\tif (!Is.undefined(options.retryDelayMs)) {\n\t\t\t\tGuards.integer(FetchHelper.CLASS_NAME, nameof(options.retryDelayMs), options.retryDelayMs);\n\t\t\t}\n\t\t}\n\n\t\tlet controller: AbortController | undefined;\n\t\tlet timerId: number | NodeJS.Timeout | undefined;\n\t\tconst retryCount = options?.retryCount ?? 1;\n\t\tconst baseDelayMilliseconds = options?.retryDelayMs ?? 3000;\n\n\t\tlet lastError: IError | undefined;\n\t\tlet attempt;\n\t\tfor (attempt = 0; attempt < retryCount; attempt++) {\n\t\t\tif (attempt > 0) {\n\t\t\t\tconst exponentialBackoffDelay = baseDelayMilliseconds * Math.pow(2, attempt - 1);\n\t\t\t\tawait new Promise(resolve => globalThis.setTimeout(resolve, exponentialBackoffDelay));\n\t\t\t}\n\n\t\t\tif (options?.timeoutMs !== undefined) {\n\t\t\t\tcontroller = new AbortController();\n\t\t\t\ttimerId = globalThis.setTimeout(() => {\n\t\t\t\t\tif (controller) {\n\t\t\t\t\t\tcontroller.abort();\n\t\t\t\t\t}\n\t\t\t\t}, options?.timeoutMs);\n\t\t\t}\n\n\t\t\tlet finalBody;\n\t\t\tif (method === HttpMethod.POST || method === HttpMethod.PUT || method === HttpMethod.PATCH) {\n\t\t\t\tif (Is.string(body)) {\n\t\t\t\t\tfinalBody = body;\n\t\t\t\t} else if (Is.uint8Array(body)) {\n\t\t\t\t\tfinalBody = new Uint8Array(body);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tconst requestOptions: RequestInit = {\n\t\t\t\t\tmethod,\n\t\t\t\t\theaders: options?.headers as HeadersInit,\n\t\t\t\t\tbody: finalBody,\n\t\t\t\t\tsignal: controller ? controller.signal : undefined\n\t\t\t\t};\n\t\t\t\tif (Is.boolean(options?.includeCredentials)) {\n\t\t\t\t\trequestOptions.credentials = \"include\";\n\t\t\t\t}\n\n\t\t\t\tconst response = await fetch(url, requestOptions);\n\n\t\t\t\tif (!response.ok && retryCount > 1) {\n\t\t\t\t\tlastError = new FetchError(\n\t\t\t\t\t\tsource,\n\t\t\t\t\t\t`${nameofCamelCase<FetchHelper>()}.general`,\n\t\t\t\t\t\t(response.status as HttpStatusCode) ?? HttpStatusCode.internalServerError,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\turl,\n\t\t\t\t\t\t\tstatusText: response.statusText\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\treturn response;\n\t\t\t\t}\n\t\t\t} catch (err) {\n\t\t\t\tconst isErr = Is.object<IError>(err);\n\t\t\t\tif (isErr && Is.stringValue(err.message) && err.message.includes(\"Failed to fetch\")) {\n\t\t\t\t\tlastError = new FetchError(\n\t\t\t\t\t\tsource,\n\t\t\t\t\t\t`${nameofCamelCase<FetchHelper>()}.connectivity`,\n\t\t\t\t\t\tHttpStatusCode.serviceUnavailable,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\turl\n\t\t\t\t\t\t},\n\t\t\t\t\t\terr\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tconst isAbort = isErr && err.name === \"AbortError\";\n\t\t\t\t\tconst props: { [id: string]: unknown } = { url };\n\t\t\t\t\tlet httpStatus: HttpStatusCode = HttpStatusCode.internalServerError;\n\t\t\t\t\tif (isAbort) {\n\t\t\t\t\t\thttpStatus = HttpStatusCode.requestTimeout;\n\t\t\t\t\t} else if (isErr && \"httpStatus\" in err) {\n\t\t\t\t\t\thttpStatus = err.httpStatus as HttpStatusCode;\n\t\t\t\t\t}\n\t\t\t\t\tif (isErr && \"statusText\" in err) {\n\t\t\t\t\t\tprops.statusText = err.statusText;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (isAbort) {\n\t\t\t\t\t\tlastError = new FetchError(\n\t\t\t\t\t\t\tsource,\n\t\t\t\t\t\t\t`${nameofCamelCase<FetchHelper>()}.timeout`,\n\t\t\t\t\t\t\thttpStatus,\n\t\t\t\t\t\t\tprops,\n\t\t\t\t\t\t\terr\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tlastError = new FetchError(\n\t\t\t\t\t\t\tsource,\n\t\t\t\t\t\t\t`${nameofCamelCase<FetchHelper>()}.general`,\n\t\t\t\t\t\t\thttpStatus,\n\t\t\t\t\t\t\tprops,\n\t\t\t\t\t\t\terr\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\tif (timerId) {\n\t\t\t\t\tglobalThis.clearTimeout(timerId);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (retryCount > 1 && attempt === retryCount) {\n\t\t\tthrow new FetchError(\n\t\t\t\tsource,\n\t\t\t\t`${nameofCamelCase<FetchHelper>()}.retryLimitExceeded`,\n\t\t\t\tHttpStatusCode.internalServerError,\n\t\t\t\t{ url },\n\t\t\t\tlastError\n\t\t\t);\n\t\t}\n\n\t\tthrow lastError as Error;\n\t}\n\n\t/**\n\t * Perform a request in json format.\n\t * @param source The source for the request.\n\t * @param url The url for the request.\n\t * @param method The http method.\n\t * @param requestData Request to send to the endpoint.\n\t * @param options Options for sending the requests.\n\t * @returns The response.\n\t */\n\tpublic static async fetchJson<T, U>(\n\t\tsource: string,\n\t\turl: string,\n\t\tmethod: HttpMethod,\n\t\trequestData?: T,\n\t\toptions?: IFetchOptions\n\t): Promise<U> {\n\t\tif (Is.integer(options?.cacheTtlMs) && options.cacheTtlMs >= 0) {\n\t\t\t// The cache option is set, so call the same method again but without\n\t\t\t// the cache option to get the result and cache it.\n\t\t\tconst cacheResponse = AsyncCache.exec(\n\t\t\t\t`${FetchHelper._CACHE_PREFIX}${url}`,\n\t\t\t\toptions.cacheTtlMs,\n\t\t\t\tasync () =>\n\t\t\t\t\tFetchHelper.fetchJson<T, U>(\n\t\t\t\t\t\tsource,\n\t\t\t\t\t\turl,\n\t\t\t\t\t\tmethod,\n\t\t\t\t\t\trequestData,\n\t\t\t\t\t\tObjectHelper.omit(options, [\"cacheTtlMs\"])\n\t\t\t\t\t)\n\t\t\t);\n\n\t\t\t// If the return value is a promise return it, otherwise continue\n\t\t\t// with the regular processing.\n\t\t\tif (Is.promise(cacheResponse)) {\n\t\t\t\treturn cacheResponse;\n\t\t\t}\n\t\t}\n\n\t\toptions ??= {};\n\t\toptions.headers ??= {};\n\n\t\tif (\n\t\t\tIs.undefined(options.headers[HeaderTypes.ContentType]) &&\n\t\t\t(method === HttpMethod.POST || method === HttpMethod.PUT || method === HttpMethod.PATCH)\n\t\t) {\n\t\t\toptions.headers[HeaderTypes.ContentType] = MimeTypes.Json;\n\t\t}\n\n\t\tconst response = await FetchHelper.fetch(\n\t\t\tsource,\n\t\t\turl,\n\t\t\tmethod,\n\t\t\trequestData ? JSON.stringify(requestData) : undefined,\n\t\t\toptions\n\t\t);\n\n\t\tif (response.ok) {\n\t\t\tif (response.status === HttpStatusCode.noContent) {\n\t\t\t\treturn {} as U;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\treturn (await response.json()) as U;\n\t\t\t} catch (err) {\n\t\t\t\tthrow new FetchError(\n\t\t\t\t\tsource,\n\t\t\t\t\t`${nameofCamelCase<FetchHelper>()}.decodingJSON`,\n\t\t\t\t\tHttpStatusCode.badRequest,\n\t\t\t\t\t{ url },\n\t\t\t\t\terr\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconst errorResponseData = await response.json();\n\t\tconst errorResponse = BaseError.fromError(errorResponseData);\n\t\tconst isErrorEmpty = BaseError.isEmpty(errorResponse);\n\n\t\tthrow new FetchError(\n\t\t\tsource,\n\t\t\t`${nameofCamelCase<FetchHelper>()}.failureStatusText`,\n\t\t\tresponse.status as HttpStatusCode,\n\t\t\t{\n\t\t\t\tstatusText: response.statusText,\n\t\t\t\turl,\n\t\t\t\tdata: isErrorEmpty ? errorResponseData : undefined\n\t\t\t},\n\t\t\tisErrorEmpty ? undefined : errorResponse\n\t\t);\n\t}\n\n\t/**\n\t * Perform a request for binary data.\n\t * @param source The source for the request.\n\t * @param url The url for the request.\n\t * @param method The http method.\n\t * @param requestData Request to send to the endpoint.\n\t * @param options Options for sending the requests.\n\t * @returns The response.\n\t */\n\tpublic static async fetchBinary<T>(\n\t\tsource: string,\n\t\turl: string,\n\t\tmethod: Extract<HttpMethod, \"GET\" | \"POST\">,\n\t\trequestData?: Uint8Array,\n\t\toptions?: IFetchOptions\n\t): Promise<Uint8Array | T> {\n\t\tif (Is.integer(options?.cacheTtlMs) && options.cacheTtlMs >= 0) {\n\t\t\t// The cache option is set, so call the same method again but without\n\t\t\t// the cache option to get the result and cache it.\n\t\t\tconst cacheResponse = AsyncCache.exec(\n\t\t\t\t`${FetchHelper._CACHE_PREFIX}${url}`,\n\t\t\t\toptions.cacheTtlMs * 1000,\n\t\t\t\tasync () =>\n\t\t\t\t\tFetchHelper.fetchBinary<T>(\n\t\t\t\t\t\tsource,\n\t\t\t\t\t\turl,\n\t\t\t\t\t\tmethod,\n\t\t\t\t\t\trequestData,\n\t\t\t\t\t\tObjectHelper.omit(options, [\"cacheTtlMs\"])\n\t\t\t\t\t)\n\t\t\t);\n\n\t\t\t// If the return value is a promise return it, otherwise continue\n\t\t\t// with the regular processing.\n\t\t\tif (Is.promise(cacheResponse)) {\n\t\t\t\treturn cacheResponse;\n\t\t\t}\n\t\t}\n\n\t\toptions ??= {};\n\t\toptions.headers ??= {};\n\n\t\tif (Is.undefined(options.headers[HeaderTypes.ContentType])) {\n\t\t\toptions.headers[HeaderTypes.ContentType] = MimeTypes.OctetStream;\n\t\t}\n\n\t\tconst response = await FetchHelper.fetch(source, url, method, requestData, options);\n\n\t\tif (response.ok) {\n\t\t\tif (method === HttpMethod.GET) {\n\t\t\t\tif (response.status === HttpStatusCode.noContent) {\n\t\t\t\t\treturn new Uint8Array();\n\t\t\t\t}\n\t\t\t\treturn new Uint8Array(await response.arrayBuffer());\n\t\t\t}\n\t\t\ttry {\n\t\t\t\treturn (await response.json()) as T;\n\t\t\t} catch (err) {\n\t\t\t\tthrow new FetchError(\n\t\t\t\t\tsource,\n\t\t\t\t\t`${nameofCamelCase<FetchHelper>()}.decodingJSON`,\n\t\t\t\t\tHttpStatusCode.badRequest,\n\t\t\t\t\t{ url },\n\t\t\t\t\terr\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconst errorResponseData = await response.json();\n\t\tconst errorResponse = BaseError.fromError(errorResponseData);\n\t\tconst isErrorEmpty = BaseError.isEmpty(errorResponse);\n\n\t\tthrow new FetchError(\n\t\t\tsource,\n\t\t\t`${nameofCamelCase<FetchHelper>()}.failureStatusText`,\n\t\t\tresponse.status as HttpStatusCode,\n\t\t\t{\n\t\t\t\tstatusText: response.statusText,\n\t\t\t\turl,\n\t\t\t\tdata: isErrorEmpty ? errorResponseData : undefined\n\t\t\t},\n\t\t\tisErrorEmpty ? undefined : errorResponse\n\t\t);\n\t}\n\n\t/**\n\t * Clears the cache.\n\t */\n\tpublic static clearCache(): void {\n\t\tAsyncCache.clearCache(FetchHelper._CACHE_PREFIX);\n\t}\n\n\t/**\n\t * Get a cache entry.\n\t * @param url The url for the request.\n\t * @returns The cache entry if it exists.\n\t */\n\tpublic static async getCacheEntry<T>(url: string): Promise<T | undefined> {\n\t\treturn AsyncCache.get<T>(`${FetchHelper._CACHE_PREFIX}${url}`);\n\t}\n\n\t/**\n\t * Set a cache entry.\n\t * @param url The url for the request.\n\t * @param value The value to cache.\n\t * @returns The cache entry if it exists.\n\t */\n\tpublic static async setCacheEntry<T>(url: string, value: T): Promise<void> {\n\t\tawait AsyncCache.set<T>(`${FetchHelper._CACHE_PREFIX}${url}`, value);\n\t}\n\n\t/**\n\t * Remove a cache entry.\n\t * @param url The url for the request.\n\t */\n\tpublic static removeCacheEntry(url: string): void {\n\t\tAsyncCache.remove(`${FetchHelper._CACHE_PREFIX}${url}`);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"fetchHelper.js","sourceRoot":"","sources":["../../../src/utils/fetchHelper.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,YAAY,EAAe,MAAM,gBAAgB,CAAC;AAE9F,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,cAAc,EA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AAU;QACvB,UAAU,CAAC,UAAU,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;IAClD,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,KAAK,CAAC,aAAa,CAAI,GAAW;QAC/C,OAAO,UAAU,CAAC,GAAG,CAAI,GAAG,WAAW,CAAC,aAAa,GAAG,GAAG,EAAE,CAAC,CAAC;IAChE,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,KAAK,CAAC,aAAa,CAAI,GAAW,EAAE,KAAQ;QACzD,MAAM,UAAU,CAAC,GAAG,CAAI,GAAG,WAAW,CAAC,aAAa,GAAG,GAAG,EAAE,EAAE,KAAK,CAAC,CAAC;IACtE,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,gBAAgB,CAAC,GAAW;QACzC,UAAU,CAAC,MAAM,CAAC,GAAG,WAAW,CAAC,aAAa,GAAG,GAAG,EAAE,CAAC,CAAC;IACzD,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { AsyncCache, BaseError, Guards, Is, ObjectHelper, type IError } from \"@twin.org/core\";\nimport { nameof, nameofCamelCase } from \"@twin.org/nameof\";\nimport { FetchError } from \"../errors/fetchError.js\";\nimport { HeaderTypes } from \"../models/headerTypes.js\";\nimport { HttpMethod } from \"../models/httpMethod.js\";\nimport { HttpStatusCode } from \"../models/httpStatusCode.js\";\nimport type { IFetchOptions } from \"../models/IFetchOptions.js\";\nimport type { IHttpHeaders } from \"../models/IHttpHeaders.js\";\nimport { MimeTypes } from \"../models/mimeTypes.js\";\n\n/**\n * Class to helper with fetch operations.\n */\nexport class FetchHelper {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<FetchHelper>();\n\n\t/**\n\t * Prefix to use for cache entries.\n\t * @internal\n\t */\n\tprivate static readonly _CACHE_PREFIX: string = \"fetch_\";\n\n\t/**\n\t * Perform a fetch request.\n\t * @param source The source for the request.\n\t * @param url The url for the request.\n\t * @param method The http method.\n\t * @param body Request to send to the endpoint.\n\t * @param options Options for sending the requests.\n\t * @returns The response.\n\t */\n\tpublic static async fetch(\n\t\tsource: string,\n\t\turl: string,\n\t\tmethod: HttpMethod,\n\t\tbody?: string | Uint8Array,\n\t\toptions?: Omit<IFetchOptions, \"cacheTtlSeconds\">\n\t): Promise<Response> {\n\t\tGuards.string(FetchHelper.CLASS_NAME, nameof(source), source);\n\t\tGuards.string(FetchHelper.CLASS_NAME, nameof(url), url);\n\t\tGuards.arrayOneOf<HttpMethod>(\n\t\t\tFetchHelper.CLASS_NAME,\n\t\t\tnameof(method),\n\t\t\tmethod,\n\t\t\tObject.values(HttpMethod)\n\t\t);\n\t\tif (!Is.undefined(body) && !Is.uint8Array(body)) {\n\t\t\tGuards.string(FetchHelper.CLASS_NAME, nameof(body), body);\n\t\t}\n\t\tif (!Is.undefined(options)) {\n\t\t\tGuards.object<IFetchOptions>(FetchHelper.CLASS_NAME, nameof(options), options);\n\t\t\tif (!Is.undefined(options.headers)) {\n\t\t\t\tGuards.object<IHttpHeaders>(\n\t\t\t\t\tFetchHelper.CLASS_NAME,\n\t\t\t\t\tnameof(options.headers),\n\t\t\t\t\toptions.headers\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (!Is.undefined(options.timeoutMs)) {\n\t\t\t\tGuards.integer(FetchHelper.CLASS_NAME, nameof(options.timeoutMs), options.timeoutMs);\n\t\t\t}\n\t\t\tif (!Is.undefined(options.includeCredentials)) {\n\t\t\t\tGuards.boolean(\n\t\t\t\t\tFetchHelper.CLASS_NAME,\n\t\t\t\t\tnameof(options.includeCredentials),\n\t\t\t\t\toptions.includeCredentials\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (!Is.undefined(options.retryCount)) {\n\t\t\t\tGuards.integer(FetchHelper.CLASS_NAME, nameof(options.retryCount), options.retryCount);\n\t\t\t}\n\t\t\tif (!Is.undefined(options.retryDelayMs)) {\n\t\t\t\tGuards.integer(FetchHelper.CLASS_NAME, nameof(options.retryDelayMs), options.retryDelayMs);\n\t\t\t}\n\t\t}\n\n\t\tlet controller: AbortController | undefined;\n\t\tlet timerId: number | NodeJS.Timeout | undefined;\n\t\tconst retryCount = options?.retryCount ?? 1;\n\t\tconst baseDelayMilliseconds = options?.retryDelayMs ?? 3000;\n\n\t\tlet lastError: IError | undefined;\n\t\tlet attempt;\n\t\tfor (attempt = 0; attempt < retryCount; attempt++) {\n\t\t\tif (attempt > 0) {\n\t\t\t\tconst exponentialBackoffDelay = baseDelayMilliseconds * Math.pow(2, attempt - 1);\n\t\t\t\tawait new Promise(resolve => globalThis.setTimeout(resolve, exponentialBackoffDelay));\n\t\t\t}\n\n\t\t\tif (options?.timeoutMs !== undefined) {\n\t\t\t\tcontroller = new AbortController();\n\t\t\t\ttimerId = globalThis.setTimeout(() => {\n\t\t\t\t\tif (controller) {\n\t\t\t\t\t\tcontroller.abort();\n\t\t\t\t\t}\n\t\t\t\t}, options?.timeoutMs);\n\t\t\t}\n\n\t\t\tlet finalBody;\n\t\t\tif (method === HttpMethod.POST || method === HttpMethod.PUT || method === HttpMethod.PATCH) {\n\t\t\t\tif (Is.string(body)) {\n\t\t\t\t\tfinalBody = body;\n\t\t\t\t} else if (Is.uint8Array(body)) {\n\t\t\t\t\tfinalBody = new Uint8Array(body);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tconst requestOptions: RequestInit = {\n\t\t\t\t\tmethod,\n\t\t\t\t\theaders: options?.headers as HeadersInit,\n\t\t\t\t\tbody: finalBody,\n\t\t\t\t\tsignal: controller ? controller.signal : undefined\n\t\t\t\t};\n\t\t\t\tif (Is.boolean(options?.includeCredentials)) {\n\t\t\t\t\trequestOptions.credentials = \"include\";\n\t\t\t\t}\n\n\t\t\t\tconst response = await fetch(url, requestOptions);\n\n\t\t\t\tif (!response.ok && retryCount > 1) {\n\t\t\t\t\tlastError = new FetchError(\n\t\t\t\t\t\tsource,\n\t\t\t\t\t\t`${nameofCamelCase<FetchHelper>()}.general`,\n\t\t\t\t\t\t(response.status as HttpStatusCode) ?? HttpStatusCode.internalServerError,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\turl,\n\t\t\t\t\t\t\tstatusText: response.statusText\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\treturn response;\n\t\t\t\t}\n\t\t\t} catch (err) {\n\t\t\t\tconst isErr = Is.object<IError>(err);\n\t\t\t\tif (isErr && Is.stringValue(err.message) && err.message.includes(\"Failed to fetch\")) {\n\t\t\t\t\tlastError = new FetchError(\n\t\t\t\t\t\tsource,\n\t\t\t\t\t\t`${nameofCamelCase<FetchHelper>()}.connectivity`,\n\t\t\t\t\t\tHttpStatusCode.serviceUnavailable,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\turl\n\t\t\t\t\t\t},\n\t\t\t\t\t\terr\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tconst isAbort = isErr && err.name === \"AbortError\";\n\t\t\t\t\tconst props: { [id: string]: unknown } = { url };\n\t\t\t\t\tlet httpStatus: HttpStatusCode = HttpStatusCode.internalServerError;\n\t\t\t\t\tif (isAbort) {\n\t\t\t\t\t\thttpStatus = HttpStatusCode.requestTimeout;\n\t\t\t\t\t} else if (isErr && \"httpStatus\" in err) {\n\t\t\t\t\t\thttpStatus = err.httpStatus as HttpStatusCode;\n\t\t\t\t\t}\n\t\t\t\t\tif (isErr && \"statusText\" in err) {\n\t\t\t\t\t\tprops.statusText = err.statusText;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (isAbort) {\n\t\t\t\t\t\tlastError = new FetchError(\n\t\t\t\t\t\t\tsource,\n\t\t\t\t\t\t\t`${nameofCamelCase<FetchHelper>()}.timeout`,\n\t\t\t\t\t\t\thttpStatus,\n\t\t\t\t\t\t\tprops,\n\t\t\t\t\t\t\terr\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tlastError = new FetchError(\n\t\t\t\t\t\t\tsource,\n\t\t\t\t\t\t\t`${nameofCamelCase<FetchHelper>()}.general`,\n\t\t\t\t\t\t\thttpStatus,\n\t\t\t\t\t\t\tprops,\n\t\t\t\t\t\t\terr\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\tif (timerId) {\n\t\t\t\t\tglobalThis.clearTimeout(timerId);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (retryCount > 1 && attempt === retryCount) {\n\t\t\tthrow new FetchError(\n\t\t\t\tsource,\n\t\t\t\t`${nameofCamelCase<FetchHelper>()}.retryLimitExceeded`,\n\t\t\t\tHttpStatusCode.internalServerError,\n\t\t\t\t{ url },\n\t\t\t\tlastError\n\t\t\t);\n\t\t}\n\n\t\tthrow lastError as Error;\n\t}\n\n\t/**\n\t * Perform a request in json format.\n\t * @param source The source for the request.\n\t * @param url The url for the request.\n\t * @param method The http method.\n\t * @param requestData Request to send to the endpoint.\n\t * @param options Options for sending the requests.\n\t * @returns The response.\n\t */\n\tpublic static async fetchJson<T, U>(\n\t\tsource: string,\n\t\turl: string,\n\t\tmethod: HttpMethod,\n\t\trequestData?: T,\n\t\toptions?: IFetchOptions\n\t): Promise<U> {\n\t\tif (Is.integer(options?.cacheTtlMs) && options.cacheTtlMs >= 0) {\n\t\t\t// The cache option is set, so call the same method again but without\n\t\t\t// the cache option to get the result and cache it.\n\t\t\tconst cacheResponse = AsyncCache.exec(\n\t\t\t\t`${FetchHelper._CACHE_PREFIX}${url}`,\n\t\t\t\toptions.cacheTtlMs,\n\t\t\t\tasync () =>\n\t\t\t\t\tFetchHelper.fetchJson<T, U>(\n\t\t\t\t\t\tsource,\n\t\t\t\t\t\turl,\n\t\t\t\t\t\tmethod,\n\t\t\t\t\t\trequestData,\n\t\t\t\t\t\tObjectHelper.omit(options, [\"cacheTtlMs\"])\n\t\t\t\t\t)\n\t\t\t);\n\n\t\t\t// If the return value is a promise return it, otherwise continue\n\t\t\t// with the regular processing.\n\t\t\tif (Is.promise(cacheResponse)) {\n\t\t\t\treturn cacheResponse;\n\t\t\t}\n\t\t}\n\n\t\toptions ??= {};\n\t\toptions.headers ??= {};\n\n\t\tif (\n\t\t\tIs.undefined(options.headers[HeaderTypes.ContentType]) &&\n\t\t\t(method === HttpMethod.POST || method === HttpMethod.PUT || method === HttpMethod.PATCH)\n\t\t) {\n\t\t\toptions.headers[HeaderTypes.ContentType] = MimeTypes.Json;\n\t\t}\n\n\t\tconst response = await FetchHelper.fetch(\n\t\t\tsource,\n\t\t\turl,\n\t\t\tmethod,\n\t\t\trequestData ? JSON.stringify(requestData) : undefined,\n\t\t\toptions\n\t\t);\n\n\t\tif (response.ok) {\n\t\t\tif (response.status === HttpStatusCode.noContent) {\n\t\t\t\treturn {} as U;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\treturn (await response.json()) as U;\n\t\t\t} catch (err) {\n\t\t\t\tthrow new FetchError(\n\t\t\t\t\tsource,\n\t\t\t\t\t`${nameofCamelCase<FetchHelper>()}.decodingJSON`,\n\t\t\t\t\tHttpStatusCode.badRequest,\n\t\t\t\t\t{ url },\n\t\t\t\t\terr\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconst errorResponseData = await response.json();\n\t\tconst errorResponse = BaseError.fromError(errorResponseData);\n\t\tconst isErrorEmpty = BaseError.isEmpty(errorResponse);\n\n\t\tthrow new FetchError(\n\t\t\tsource,\n\t\t\t`${nameofCamelCase<FetchHelper>()}.failureStatusText`,\n\t\t\tresponse.status as HttpStatusCode,\n\t\t\t{\n\t\t\t\tstatusText: response.statusText,\n\t\t\t\turl,\n\t\t\t\tdata: isErrorEmpty ? errorResponseData : undefined\n\t\t\t},\n\t\t\tisErrorEmpty ? undefined : errorResponse\n\t\t);\n\t}\n\n\t/**\n\t * Perform a request for binary data.\n\t * @param source The source for the request.\n\t * @param url The url for the request.\n\t * @param method The http method.\n\t * @param requestData Request to send to the endpoint.\n\t * @param options Options for sending the requests.\n\t * @returns The response.\n\t */\n\tpublic static async fetchBinary<T>(\n\t\tsource: string,\n\t\turl: string,\n\t\tmethod: Extract<HttpMethod, \"GET\" | \"POST\">,\n\t\trequestData?: Uint8Array,\n\t\toptions?: IFetchOptions\n\t): Promise<Uint8Array | T> {\n\t\tif (Is.integer(options?.cacheTtlMs) && options.cacheTtlMs >= 0) {\n\t\t\t// The cache option is set, so call the same method again but without\n\t\t\t// the cache option to get the result and cache it.\n\t\t\tconst cacheResponse = AsyncCache.exec(\n\t\t\t\t`${FetchHelper._CACHE_PREFIX}${url}`,\n\t\t\t\toptions.cacheTtlMs,\n\t\t\t\tasync () =>\n\t\t\t\t\tFetchHelper.fetchBinary<T>(\n\t\t\t\t\t\tsource,\n\t\t\t\t\t\turl,\n\t\t\t\t\t\tmethod,\n\t\t\t\t\t\trequestData,\n\t\t\t\t\t\tObjectHelper.omit(options, [\"cacheTtlMs\"])\n\t\t\t\t\t)\n\t\t\t);\n\n\t\t\t// If the return value is a promise return it, otherwise continue\n\t\t\t// with the regular processing.\n\t\t\tif (Is.promise(cacheResponse)) {\n\t\t\t\treturn cacheResponse;\n\t\t\t}\n\t\t}\n\n\t\toptions ??= {};\n\t\toptions.headers ??= {};\n\n\t\tif (Is.undefined(options.headers[HeaderTypes.ContentType])) {\n\t\t\toptions.headers[HeaderTypes.ContentType] = MimeTypes.OctetStream;\n\t\t}\n\n\t\tconst response = await FetchHelper.fetch(source, url, method, requestData, options);\n\n\t\tif (response.ok) {\n\t\t\tif (method === HttpMethod.GET) {\n\t\t\t\tif (response.status === HttpStatusCode.noContent) {\n\t\t\t\t\treturn new Uint8Array();\n\t\t\t\t}\n\t\t\t\treturn new Uint8Array(await response.arrayBuffer());\n\t\t\t}\n\t\t\ttry {\n\t\t\t\treturn (await response.json()) as T;\n\t\t\t} catch (err) {\n\t\t\t\tthrow new FetchError(\n\t\t\t\t\tsource,\n\t\t\t\t\t`${nameofCamelCase<FetchHelper>()}.decodingJSON`,\n\t\t\t\t\tHttpStatusCode.badRequest,\n\t\t\t\t\t{ url },\n\t\t\t\t\terr\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconst errorResponseData = await response.json();\n\t\tconst errorResponse = BaseError.fromError(errorResponseData);\n\t\tconst isErrorEmpty = BaseError.isEmpty(errorResponse);\n\n\t\tthrow new FetchError(\n\t\t\tsource,\n\t\t\t`${nameofCamelCase<FetchHelper>()}.failureStatusText`,\n\t\t\tresponse.status as HttpStatusCode,\n\t\t\t{\n\t\t\t\tstatusText: response.statusText,\n\t\t\t\turl,\n\t\t\t\tdata: isErrorEmpty ? errorResponseData : undefined\n\t\t\t},\n\t\t\tisErrorEmpty ? undefined : errorResponse\n\t\t);\n\t}\n\n\t/**\n\t * Clears the cache.\n\t */\n\tpublic static clearCache(): void {\n\t\tAsyncCache.clearCache(FetchHelper._CACHE_PREFIX);\n\t}\n\n\t/**\n\t * Get a cache entry.\n\t * @param url The url for the request.\n\t * @returns The cache entry if it exists.\n\t */\n\tpublic static async getCacheEntry<T>(url: string): Promise<T | undefined> {\n\t\treturn AsyncCache.get<T>(`${FetchHelper._CACHE_PREFIX}${url}`);\n\t}\n\n\t/**\n\t * Set a cache entry.\n\t * @param url The url for the request.\n\t * @param value The value to cache.\n\t * @returns The cache entry if it exists.\n\t */\n\tpublic static async setCacheEntry<T>(url: string, value: T): Promise<void> {\n\t\tawait AsyncCache.set<T>(`${FetchHelper._CACHE_PREFIX}${url}`, value);\n\t}\n\n\t/**\n\t * Remove a cache entry.\n\t * @param url The url for the request.\n\t */\n\tpublic static removeCacheEntry(url: string): void {\n\t\tAsyncCache.remove(`${FetchHelper._CACHE_PREFIX}${url}`);\n\t}\n}\n"]}
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,246 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.9.0-next.1](https://github.com/iotaledger/twin-framework/compare/web-v0.9.0-next.0...web-v0.9.0-next.1) (2026-06-22)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add additional header types ([#222](https://github.com/iotaledger/twin-framework/issues/222)) ([05f01cf](https://github.com/iotaledger/twin-framework/commit/05f01cf34b7bcec561ee989f679281b1cacdf032))
|
|
9
|
+
* add context id features ([#206](https://github.com/iotaledger/twin-framework/issues/206)) ([ef0d4ee](https://github.com/iotaledger/twin-framework/commit/ef0d4ee11a4f5fc6cc6f52a4958ce905c04ee13b))
|
|
10
|
+
* add cookie helper method to web package ([#217](https://github.com/iotaledger/twin-framework/issues/217)) ([043c632](https://github.com/iotaledger/twin-framework/commit/043c63298bff96f70bdefed56b82afef42ec3f44))
|
|
11
|
+
* add header helper for common bearer support ([0c940b2](https://github.com/iotaledger/twin-framework/commit/0c940b29cccf0c3bb5b4aa8a01f1998010e44d51))
|
|
12
|
+
* add IEntitySchemaDiff and entitySchemaDiff utility ([#282](https://github.com/iotaledger/twin-framework/issues/282)) ([9d63e94](https://github.com/iotaledger/twin-framework/commit/9d63e94021ee2ffc138004ee68cf53d08a6b17f9))
|
|
13
|
+
* add jwk enc property overrides ([18b6309](https://github.com/iotaledger/twin-framework/commit/18b63092a386b56ea7fcd7e12865ac6e1b47cc1e))
|
|
14
|
+
* add Link header array support ([aff32a3](https://github.com/iotaledger/twin-framework/commit/aff32a3ff8ad3d076cade7c889444220706bfb1e))
|
|
15
|
+
* add rsa cipher support ([7af6cc6](https://github.com/iotaledger/twin-framework/commit/7af6cc67512d3363bd4a2f2e87bd7733c2800147))
|
|
16
|
+
* add/update http and mime types ([#229](https://github.com/iotaledger/twin-framework/issues/229)) ([d50154a](https://github.com/iotaledger/twin-framework/commit/d50154a484711b67feb42ea20a94e4415e53d392))
|
|
17
|
+
* adding link header helper ([#225](https://github.com/iotaledger/twin-framework/issues/225)) ([703c072](https://github.com/iotaledger/twin-framework/commit/703c0725aceac6b6ec0c4fa729ef832d12fb3fd7))
|
|
18
|
+
* additional http header extraction ([#262](https://github.com/iotaledger/twin-framework/issues/262)) ([124fa3f](https://github.com/iotaledger/twin-framework/commit/124fa3fdd118ed17f973d4b46842f5b7f35365c2))
|
|
19
|
+
* additional http link feature support ([b68b4cc](https://github.com/iotaledger/twin-framework/commit/b68b4cc6a6e3cf02f91e794353714e26a49fe66c))
|
|
20
|
+
* additional nameof operators ([a5aab60](https://github.com/iotaledger/twin-framework/commit/a5aab60bf66a86f1b7ff8af7c4f044cb03706d50))
|
|
21
|
+
* eslint migration to flat config ([74427d7](https://github.com/iotaledger/twin-framework/commit/74427d78d342167f7850e49ab87269326355befe))
|
|
22
|
+
* improve bearer creation and extraction ([b9ddd6d](https://github.com/iotaledger/twin-framework/commit/b9ddd6dae0cb558e2227f0ec5e9cd21f85957400))
|
|
23
|
+
* improve bearer creation and extraction ([29a347a](https://github.com/iotaledger/twin-framework/commit/29a347a760cb3bc5eb819112e84f1ac99430e72b))
|
|
24
|
+
* improve signatures ([cdd24be](https://github.com/iotaledger/twin-framework/commit/cdd24be6fb898d33955b6f2f93c3ddbd73582269))
|
|
25
|
+
* locales validation ([#197](https://github.com/iotaledger/twin-framework/issues/197)) ([55fdadb](https://github.com/iotaledger/twin-framework/commit/55fdadb13595ce0047f787bd1d4135d429a99f12))
|
|
26
|
+
* relocate core packages from tools ([bcab8f3](https://github.com/iotaledger/twin-framework/commit/bcab8f3160442ea4fcaf442947462504f3d6a17d))
|
|
27
|
+
* typescript 6 update ([1d10f31](https://github.com/iotaledger/twin-framework/commit/1d10f31e6516ec622773f45e88af82fe749b384a))
|
|
28
|
+
* update dependencies ([4da77ab](https://github.com/iotaledger/twin-framework/commit/4da77ab30f499e52825ac5a76f51436ceb59c26e))
|
|
29
|
+
* update dependencies ([f3bd015](https://github.com/iotaledger/twin-framework/commit/f3bd015efd169196b7e0335f5cab876ba6ca1d75))
|
|
30
|
+
* use body on patch verb ([28627e5](https://github.com/iotaledger/twin-framework/commit/28627e527d033d433acefe0e9fde52ba88c0d047))
|
|
31
|
+
* use cause instead of inner for errors ([1f4acc4](https://github.com/iotaledger/twin-framework/commit/1f4acc4d7a6b71a134d9547da9bf40de1e1e49da))
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
### Bug Fixes
|
|
35
|
+
|
|
36
|
+
* ensure __decorate is defined for decorators ([103a563](https://github.com/iotaledger/twin-framework/commit/103a563ce01ebdef6240d2e590e7b026e8692684))
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
### Dependencies
|
|
40
|
+
|
|
41
|
+
* The following workspace dependencies were updated
|
|
42
|
+
* dependencies
|
|
43
|
+
* @twin.org/core bumped from 0.9.0-next.0 to 0.9.0-next.1
|
|
44
|
+
* @twin.org/crypto bumped from 0.9.0-next.0 to 0.9.0-next.1
|
|
45
|
+
* @twin.org/nameof bumped from 0.9.0-next.0 to 0.9.0-next.1
|
|
46
|
+
* devDependencies
|
|
47
|
+
* @twin.org/nameof-transformer bumped from 0.9.0-next.0 to 0.9.0-next.1
|
|
48
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.9.0-next.0 to 0.9.0-next.1
|
|
49
|
+
* @twin.org/validate-locales bumped from 0.9.0-next.0 to 0.9.0-next.1
|
|
50
|
+
|
|
51
|
+
## [0.0.4-next.15](https://github.com/iotaledger/twin-framework/compare/web-v0.0.4-next.14...web-v0.0.4-next.15) (2026-06-19)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
### Miscellaneous Chores
|
|
55
|
+
|
|
56
|
+
* **web:** Synchronize repo versions
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
### Dependencies
|
|
60
|
+
|
|
61
|
+
* The following workspace dependencies were updated
|
|
62
|
+
* dependencies
|
|
63
|
+
* @twin.org/core bumped from 0.0.4-next.14 to 0.0.4-next.15
|
|
64
|
+
* @twin.org/crypto bumped from 0.0.4-next.14 to 0.0.4-next.15
|
|
65
|
+
* @twin.org/nameof bumped from 0.0.4-next.14 to 0.0.4-next.15
|
|
66
|
+
* devDependencies
|
|
67
|
+
* @twin.org/nameof-transformer bumped from 0.0.4-next.14 to 0.0.4-next.15
|
|
68
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.4-next.14 to 0.0.4-next.15
|
|
69
|
+
* @twin.org/validate-locales bumped from 0.0.4-next.14 to 0.0.4-next.15
|
|
70
|
+
|
|
71
|
+
## [0.0.4-next.14](https://github.com/iotaledger/twin-framework/compare/web-v0.0.4-next.13...web-v0.0.4-next.14) (2026-06-18)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
### Miscellaneous Chores
|
|
75
|
+
|
|
76
|
+
* **web:** Synchronize repo versions
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
### Dependencies
|
|
80
|
+
|
|
81
|
+
* The following workspace dependencies were updated
|
|
82
|
+
* dependencies
|
|
83
|
+
* @twin.org/core bumped from 0.0.4-next.13 to 0.0.4-next.14
|
|
84
|
+
* @twin.org/crypto bumped from 0.0.4-next.13 to 0.0.4-next.14
|
|
85
|
+
* @twin.org/nameof bumped from 0.0.4-next.13 to 0.0.4-next.14
|
|
86
|
+
* devDependencies
|
|
87
|
+
* @twin.org/nameof-transformer bumped from 0.0.4-next.13 to 0.0.4-next.14
|
|
88
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.4-next.13 to 0.0.4-next.14
|
|
89
|
+
* @twin.org/validate-locales bumped from 0.0.4-next.13 to 0.0.4-next.14
|
|
90
|
+
|
|
91
|
+
## [0.0.4-next.13](https://github.com/iotaledger/twin-framework/compare/web-v0.0.4-next.12...web-v0.0.4-next.13) (2026-06-18)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
### Miscellaneous Chores
|
|
95
|
+
|
|
96
|
+
* **web:** Synchronize repo versions
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
### Dependencies
|
|
100
|
+
|
|
101
|
+
* The following workspace dependencies were updated
|
|
102
|
+
* dependencies
|
|
103
|
+
* @twin.org/core bumped from 0.0.4-next.12 to 0.0.4-next.13
|
|
104
|
+
* @twin.org/crypto bumped from 0.0.4-next.12 to 0.0.4-next.13
|
|
105
|
+
* @twin.org/nameof bumped from 0.0.4-next.12 to 0.0.4-next.13
|
|
106
|
+
* devDependencies
|
|
107
|
+
* @twin.org/nameof-transformer bumped from 0.0.4-next.12 to 0.0.4-next.13
|
|
108
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.4-next.12 to 0.0.4-next.13
|
|
109
|
+
* @twin.org/validate-locales bumped from 0.0.4-next.12 to 0.0.4-next.13
|
|
110
|
+
|
|
111
|
+
## [0.0.4-next.12](https://github.com/iotaledger/twin-framework/compare/web-v0.0.4-next.11...web-v0.0.4-next.12) (2026-06-18)
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
### Miscellaneous Chores
|
|
115
|
+
|
|
116
|
+
* **web:** Synchronize repo versions
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
### Dependencies
|
|
120
|
+
|
|
121
|
+
* The following workspace dependencies were updated
|
|
122
|
+
* dependencies
|
|
123
|
+
* @twin.org/core bumped from 0.0.4-next.11 to 0.0.4-next.12
|
|
124
|
+
* @twin.org/crypto bumped from 0.0.4-next.11 to 0.0.4-next.12
|
|
125
|
+
* @twin.org/nameof bumped from 0.0.4-next.11 to 0.0.4-next.12
|
|
126
|
+
* devDependencies
|
|
127
|
+
* @twin.org/nameof-transformer bumped from 0.0.4-next.11 to 0.0.4-next.12
|
|
128
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.4-next.11 to 0.0.4-next.12
|
|
129
|
+
* @twin.org/validate-locales bumped from 0.0.4-next.11 to 0.0.4-next.12
|
|
130
|
+
|
|
131
|
+
## [0.0.4-next.11](https://github.com/iotaledger/twin-framework/compare/web-v0.0.4-next.10...web-v0.0.4-next.11) (2026-06-15)
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
### Miscellaneous Chores
|
|
135
|
+
|
|
136
|
+
* **web:** Synchronize repo versions
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
### Dependencies
|
|
140
|
+
|
|
141
|
+
* The following workspace dependencies were updated
|
|
142
|
+
* dependencies
|
|
143
|
+
* @twin.org/core bumped from 0.0.4-next.10 to 0.0.4-next.11
|
|
144
|
+
* @twin.org/crypto bumped from 0.0.4-next.10 to 0.0.4-next.11
|
|
145
|
+
* @twin.org/nameof bumped from 0.0.4-next.10 to 0.0.4-next.11
|
|
146
|
+
* devDependencies
|
|
147
|
+
* @twin.org/nameof-transformer bumped from 0.0.4-next.10 to 0.0.4-next.11
|
|
148
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.4-next.10 to 0.0.4-next.11
|
|
149
|
+
* @twin.org/validate-locales bumped from 0.0.4-next.10 to 0.0.4-next.11
|
|
150
|
+
|
|
151
|
+
## [0.0.4-next.10](https://github.com/iotaledger/twin-framework/compare/web-v0.0.4-next.9...web-v0.0.4-next.10) (2026-06-15)
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
### Features
|
|
155
|
+
|
|
156
|
+
* add additional header types ([#222](https://github.com/iotaledger/twin-framework/issues/222)) ([05f01cf](https://github.com/iotaledger/twin-framework/commit/05f01cf34b7bcec561ee989f679281b1cacdf032))
|
|
157
|
+
* add context id features ([#206](https://github.com/iotaledger/twin-framework/issues/206)) ([ef0d4ee](https://github.com/iotaledger/twin-framework/commit/ef0d4ee11a4f5fc6cc6f52a4958ce905c04ee13b))
|
|
158
|
+
* add cookie helper method to web package ([#217](https://github.com/iotaledger/twin-framework/issues/217)) ([043c632](https://github.com/iotaledger/twin-framework/commit/043c63298bff96f70bdefed56b82afef42ec3f44))
|
|
159
|
+
* add guards arrayEndsWith and arrayStartsWith ([95d875e](https://github.com/iotaledger/twin-framework/commit/95d875ec8ccb4713c145fdde941d4cfedcec2ed3))
|
|
160
|
+
* add header helper for common bearer support ([0c940b2](https://github.com/iotaledger/twin-framework/commit/0c940b29cccf0c3bb5b4aa8a01f1998010e44d51))
|
|
161
|
+
* add IEntitySchemaDiff and entitySchemaDiff utility ([#282](https://github.com/iotaledger/twin-framework/issues/282)) ([9d63e94](https://github.com/iotaledger/twin-framework/commit/9d63e94021ee2ffc138004ee68cf53d08a6b17f9))
|
|
162
|
+
* add jwk enc property overrides ([18b6309](https://github.com/iotaledger/twin-framework/commit/18b63092a386b56ea7fcd7e12865ac6e1b47cc1e))
|
|
163
|
+
* add kid method to Jwk ([bc9239e](https://github.com/iotaledger/twin-framework/commit/bc9239ed9896a053d83e00ca221e962704ebc277))
|
|
164
|
+
* add Link header array support ([aff32a3](https://github.com/iotaledger/twin-framework/commit/aff32a3ff8ad3d076cade7c889444220706bfb1e))
|
|
165
|
+
* add rsa cipher support ([7af6cc6](https://github.com/iotaledger/twin-framework/commit/7af6cc67512d3363bd4a2f2e87bd7733c2800147))
|
|
166
|
+
* add zlib/deflate mime types detection ([72c472b](https://github.com/iotaledger/twin-framework/commit/72c472b5a35a973e7109336f5b6cdd84dbb8bbcb))
|
|
167
|
+
* add/update http and mime types ([#229](https://github.com/iotaledger/twin-framework/issues/229)) ([d50154a](https://github.com/iotaledger/twin-framework/commit/d50154a484711b67feb42ea20a94e4415e53d392))
|
|
168
|
+
* adding link header helper ([#225](https://github.com/iotaledger/twin-framework/issues/225)) ([703c072](https://github.com/iotaledger/twin-framework/commit/703c0725aceac6b6ec0c4fa729ef832d12fb3fd7))
|
|
169
|
+
* additional http header extraction ([#262](https://github.com/iotaledger/twin-framework/issues/262)) ([124fa3f](https://github.com/iotaledger/twin-framework/commit/124fa3fdd118ed17f973d4b46842f5b7f35365c2))
|
|
170
|
+
* additional http link feature support ([b68b4cc](https://github.com/iotaledger/twin-framework/commit/b68b4cc6a6e3cf02f91e794353714e26a49fe66c))
|
|
171
|
+
* additional nameof operators ([a5aab60](https://github.com/iotaledger/twin-framework/commit/a5aab60bf66a86f1b7ff8af7c4f044cb03706d50))
|
|
172
|
+
* ensure the alg is the correct one when generating JWK or JWS ([#136](https://github.com/iotaledger/twin-framework/issues/136)) ([46a5af1](https://github.com/iotaledger/twin-framework/commit/46a5af127192d7048068275d14f555f09add3642))
|
|
173
|
+
* eslint migration to flat config ([74427d7](https://github.com/iotaledger/twin-framework/commit/74427d78d342167f7850e49ab87269326355befe))
|
|
174
|
+
* improve bearer creation and extraction ([b9ddd6d](https://github.com/iotaledger/twin-framework/commit/b9ddd6dae0cb558e2227f0ec5e9cd21f85957400))
|
|
175
|
+
* improve bearer creation and extraction ([29a347a](https://github.com/iotaledger/twin-framework/commit/29a347a760cb3bc5eb819112e84f1ac99430e72b))
|
|
176
|
+
* improve signatures ([cdd24be](https://github.com/iotaledger/twin-framework/commit/cdd24be6fb898d33955b6f2f93c3ddbd73582269))
|
|
177
|
+
* locales validation ([#197](https://github.com/iotaledger/twin-framework/issues/197)) ([55fdadb](https://github.com/iotaledger/twin-framework/commit/55fdadb13595ce0047f787bd1d4135d429a99f12))
|
|
178
|
+
* propagate includeStackTrace on error conversion ([098fc72](https://github.com/iotaledger/twin-framework/commit/098fc729939ea3127f2bdcc0ddb6754096c5f919))
|
|
179
|
+
* relocate core packages from tools ([bcab8f3](https://github.com/iotaledger/twin-framework/commit/bcab8f3160442ea4fcaf442947462504f3d6a17d))
|
|
180
|
+
* typescript 6 update ([1d10f31](https://github.com/iotaledger/twin-framework/commit/1d10f31e6516ec622773f45e88af82fe749b384a))
|
|
181
|
+
* update dependencies ([4da77ab](https://github.com/iotaledger/twin-framework/commit/4da77ab30f499e52825ac5a76f51436ceb59c26e))
|
|
182
|
+
* update dependencies ([f3bd015](https://github.com/iotaledger/twin-framework/commit/f3bd015efd169196b7e0335f5cab876ba6ca1d75))
|
|
183
|
+
* use body on patch verb ([28627e5](https://github.com/iotaledger/twin-framework/commit/28627e527d033d433acefe0e9fde52ba88c0d047))
|
|
184
|
+
* use cause instead of inner for errors ([1f4acc4](https://github.com/iotaledger/twin-framework/commit/1f4acc4d7a6b71a134d9547da9bf40de1e1e49da))
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
### Bug Fixes
|
|
188
|
+
|
|
189
|
+
* ensure __decorate is defined for decorators ([103a563](https://github.com/iotaledger/twin-framework/commit/103a563ce01ebdef6240d2e590e7b026e8692684))
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
### Dependencies
|
|
193
|
+
|
|
194
|
+
* The following workspace dependencies were updated
|
|
195
|
+
* dependencies
|
|
196
|
+
* @twin.org/core bumped from 0.0.4-next.9 to 0.0.4-next.10
|
|
197
|
+
* @twin.org/crypto bumped from 0.0.4-next.9 to 0.0.4-next.10
|
|
198
|
+
* @twin.org/nameof bumped from 0.0.4-next.9 to 0.0.4-next.10
|
|
199
|
+
* devDependencies
|
|
200
|
+
* @twin.org/nameof-transformer bumped from 0.0.4-next.9 to 0.0.4-next.10
|
|
201
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.4-next.9 to 0.0.4-next.10
|
|
202
|
+
* @twin.org/validate-locales bumped from 0.0.4-next.9 to 0.0.4-next.10
|
|
203
|
+
|
|
204
|
+
## [0.0.4-next.9](https://github.com/iotaledger/twin-framework/compare/web-v0.0.4-next.8...web-v0.0.4-next.9) (2026-06-15)
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
### Miscellaneous Chores
|
|
208
|
+
|
|
209
|
+
* **web:** Synchronize repo versions
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
### Dependencies
|
|
213
|
+
|
|
214
|
+
* The following workspace dependencies were updated
|
|
215
|
+
* dependencies
|
|
216
|
+
* @twin.org/core bumped from 0.0.4-next.8 to 0.0.4-next.9
|
|
217
|
+
* @twin.org/crypto bumped from 0.0.4-next.8 to 0.0.4-next.9
|
|
218
|
+
* @twin.org/nameof bumped from 0.0.4-next.8 to 0.0.4-next.9
|
|
219
|
+
* devDependencies
|
|
220
|
+
* @twin.org/nameof-transformer bumped from 0.0.4-next.8 to 0.0.4-next.9
|
|
221
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.4-next.8 to 0.0.4-next.9
|
|
222
|
+
* @twin.org/validate-locales bumped from 0.0.4-next.8 to 0.0.4-next.9
|
|
223
|
+
|
|
224
|
+
## [0.0.4-next.8](https://github.com/iotaledger/twin-framework/compare/web-v0.0.4-next.7...web-v0.0.4-next.8) (2026-06-10)
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
### Miscellaneous Chores
|
|
228
|
+
|
|
229
|
+
* **web:** Synchronize repo versions
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
### Dependencies
|
|
233
|
+
|
|
234
|
+
* The following workspace dependencies were updated
|
|
235
|
+
* dependencies
|
|
236
|
+
* @twin.org/core bumped from 0.0.4-next.7 to 0.0.4-next.8
|
|
237
|
+
* @twin.org/crypto bumped from 0.0.4-next.7 to 0.0.4-next.8
|
|
238
|
+
* @twin.org/nameof bumped from 0.0.4-next.7 to 0.0.4-next.8
|
|
239
|
+
* devDependencies
|
|
240
|
+
* @twin.org/nameof-transformer bumped from 0.0.4-next.7 to 0.0.4-next.8
|
|
241
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.4-next.7 to 0.0.4-next.8
|
|
242
|
+
* @twin.org/validate-locales bumped from 0.0.4-next.7 to 0.0.4-next.8
|
|
243
|
+
|
|
3
244
|
## [0.0.4-next.7](https://github.com/iotaledger/twin-framework/compare/web-v0.0.4-next.6...web-v0.0.4-next.7) (2026-06-10)
|
|
4
245
|
|
|
5
246
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/web",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.9.0-next.1",
|
|
4
4
|
"description": "Classes for use with web operations",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
"node": ">=20.0.0"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@twin.org/core": "0.0
|
|
18
|
-
"@twin.org/crypto": "0.0
|
|
19
|
-
"@twin.org/nameof": "0.0
|
|
17
|
+
"@twin.org/core": "0.9.0-next.1",
|
|
18
|
+
"@twin.org/crypto": "0.9.0-next.1",
|
|
19
|
+
"@twin.org/nameof": "0.9.0-next.1",
|
|
20
20
|
"jose": "6.2.3"
|
|
21
21
|
},
|
|
22
22
|
"main": "./dist/es/index.js",
|