@ensnode/ensrainbow-sdk 1.5.1 → 1.7.0
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/client.d.ts +37 -7
- package/dist/client.js +31 -6
- package/dist/client.js.map +1 -1
- package/dist/index.js +31 -6
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/client.d.ts
CHANGED
|
@@ -1,15 +1,26 @@
|
|
|
1
|
-
import { EnsRainbowClientLabelSet, LabelHash, Label, EnsRainbowServerLabelSet } from '@ensnode/ensnode-sdk';
|
|
1
|
+
import { EnsRainbowClientLabelSet, LabelHash, EncodedLabelHash, Label, EnsRainbowServerLabelSet, EnsRainbowPublicConfig } from '@ensnode/ensnode-sdk';
|
|
2
2
|
|
|
3
3
|
declare namespace EnsRainbow {
|
|
4
4
|
export type ApiClientOptions = EnsRainbowApiClientOptions;
|
|
5
5
|
export interface ApiClient {
|
|
6
6
|
count(): Promise<CountResponse>;
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
* @param labelHash The labelhash to heal
|
|
8
|
+
* Get the public configuration of the ENSRainbow service
|
|
10
9
|
*/
|
|
11
|
-
|
|
10
|
+
config(): Promise<ENSRainbowPublicConfig>;
|
|
11
|
+
/**
|
|
12
|
+
* Heal a labelHash to its original label.
|
|
13
|
+
* Accepts a strict `LabelHash`, an `EncodedLabelHash` (bracket-enclosed), or any string
|
|
14
|
+
* that can be normalized (missing `0x` prefix, uppercase hex chars, or 63-char hex).
|
|
15
|
+
* Returns a `HealBadRequestError` if the input cannot be normalized to a valid labelHash.
|
|
16
|
+
*/
|
|
17
|
+
heal(labelHash: LabelHash | EncodedLabelHash | string): Promise<HealResponse>;
|
|
12
18
|
health(): Promise<HealthResponse>;
|
|
19
|
+
/**
|
|
20
|
+
* Get the version information of the ENSRainbow service
|
|
21
|
+
*
|
|
22
|
+
* @deprecated Use {@link ApiClient.config} instead. This method will be removed in a future version.
|
|
23
|
+
*/
|
|
13
24
|
version(): Promise<VersionResponse>;
|
|
14
25
|
getOptions(): Readonly<EnsRainbowApiClientOptions>;
|
|
15
26
|
}
|
|
@@ -80,6 +91,8 @@ declare namespace EnsRainbow {
|
|
|
80
91
|
export type CountResponse = CountSuccess | CountServerError;
|
|
81
92
|
/**
|
|
82
93
|
* ENSRainbow version information.
|
|
94
|
+
*
|
|
95
|
+
* @deprecated Use {@link ENSRainbowPublicConfig} instead. This type will be removed in a future version.
|
|
83
96
|
*/
|
|
84
97
|
export interface VersionInfo {
|
|
85
98
|
/**
|
|
@@ -97,11 +110,20 @@ declare namespace EnsRainbow {
|
|
|
97
110
|
}
|
|
98
111
|
/**
|
|
99
112
|
* Interface for the version endpoint response
|
|
113
|
+
*
|
|
114
|
+
* @deprecated Use {@link ENSRainbowPublicConfig} instead. This type will be removed in a future version.
|
|
100
115
|
*/
|
|
101
116
|
export interface VersionResponse {
|
|
102
117
|
status: typeof StatusCode.Success;
|
|
103
118
|
versionInfo: VersionInfo;
|
|
104
119
|
}
|
|
120
|
+
/**
|
|
121
|
+
* Complete public configuration object for ENSRainbow.
|
|
122
|
+
*
|
|
123
|
+
* Contains all public configuration information about the ENSRainbow service instance,
|
|
124
|
+
* including version, label set information, and record counts.
|
|
125
|
+
*/
|
|
126
|
+
export type ENSRainbowPublicConfig = EnsRainbowPublicConfig;
|
|
105
127
|
export { };
|
|
106
128
|
}
|
|
107
129
|
interface EnsRainbowApiClientOptions {
|
|
@@ -167,8 +189,11 @@ declare class EnsRainbowApiClient implements EnsRainbow.ApiClient {
|
|
|
167
189
|
* - Labels can contain any valid string, including dots, null bytes, or be empty
|
|
168
190
|
* - Clients should handle all possible string values appropriately
|
|
169
191
|
*
|
|
170
|
-
* @param labelHash
|
|
171
|
-
*
|
|
192
|
+
* @param labelHash - A labelHash to heal, either as a strict `LabelHash`, an `EncodedLabelHash`
|
|
193
|
+
* (bracket-enclosed), or any string that can be normalized (missing `0x` prefix, uppercase hex
|
|
194
|
+
* chars, or 63-char hex are all accepted and normalized automatically).
|
|
195
|
+
* @returns a `HealResponse` indicating the result of the request and the healed label if successful.
|
|
196
|
+
* Returns a `HealBadRequestError` if the input cannot be normalized to a valid labelHash.
|
|
172
197
|
* @throws if the request fails due to network failures, DNS lookup failures, request timeouts,
|
|
173
198
|
* CORS violations, or Invalid URLs
|
|
174
199
|
* @example
|
|
@@ -199,7 +224,7 @@ declare class EnsRainbowApiClient implements EnsRainbow.ApiClient {
|
|
|
199
224
|
* // }
|
|
200
225
|
* ```
|
|
201
226
|
*/
|
|
202
|
-
heal(labelHash: LabelHash): Promise<EnsRainbow.HealResponse>;
|
|
227
|
+
heal(labelHash: LabelHash | EncodedLabelHash | string): Promise<EnsRainbow.HealResponse>;
|
|
203
228
|
/**
|
|
204
229
|
* Get Count of Healable Labels
|
|
205
230
|
*
|
|
@@ -237,9 +262,14 @@ declare class EnsRainbowApiClient implements EnsRainbow.ApiClient {
|
|
|
237
262
|
* // }
|
|
238
263
|
*/
|
|
239
264
|
health(): Promise<EnsRainbow.HealthResponse>;
|
|
265
|
+
/**
|
|
266
|
+
* Get the public configuration of the ENSRainbow service.
|
|
267
|
+
*/
|
|
268
|
+
config(): Promise<EnsRainbow.ENSRainbowPublicConfig>;
|
|
240
269
|
/**
|
|
241
270
|
* Get the version information of the ENSRainbow service
|
|
242
271
|
*
|
|
272
|
+
* @deprecated Use {@link EnsRainbowApiClient.config} instead. This method will be removed in a future version.
|
|
243
273
|
* @returns the version information of the ENSRainbow service
|
|
244
274
|
* @throws if the request fails due to network failures, DNS lookup failures, request
|
|
245
275
|
* timeouts, CORS violations, or invalid URLs
|
package/dist/client.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// src/client.ts
|
|
2
2
|
import {
|
|
3
3
|
buildEnsRainbowClientLabelSet,
|
|
4
|
-
LruCache
|
|
4
|
+
LruCache,
|
|
5
|
+
parseLabelHashOrEncodedLabelHash
|
|
5
6
|
} from "@ensnode/ensnode-sdk";
|
|
6
7
|
|
|
7
8
|
// src/consts.ts
|
|
@@ -70,8 +71,11 @@ var EnsRainbowApiClient = class _EnsRainbowApiClient {
|
|
|
70
71
|
* - Labels can contain any valid string, including dots, null bytes, or be empty
|
|
71
72
|
* - Clients should handle all possible string values appropriately
|
|
72
73
|
*
|
|
73
|
-
* @param labelHash
|
|
74
|
-
*
|
|
74
|
+
* @param labelHash - A labelHash to heal, either as a strict `LabelHash`, an `EncodedLabelHash`
|
|
75
|
+
* (bracket-enclosed), or any string that can be normalized (missing `0x` prefix, uppercase hex
|
|
76
|
+
* chars, or 63-char hex are all accepted and normalized automatically).
|
|
77
|
+
* @returns a `HealResponse` indicating the result of the request and the healed label if successful.
|
|
78
|
+
* Returns a `HealBadRequestError` if the input cannot be normalized to a valid labelHash.
|
|
75
79
|
* @throws if the request fails due to network failures, DNS lookup failures, request timeouts,
|
|
76
80
|
* CORS violations, or Invalid URLs
|
|
77
81
|
* @example
|
|
@@ -103,16 +107,26 @@ var EnsRainbowApiClient = class _EnsRainbowApiClient {
|
|
|
103
107
|
* ```
|
|
104
108
|
*/
|
|
105
109
|
async heal(labelHash) {
|
|
106
|
-
|
|
110
|
+
let normalizedLabelHash;
|
|
111
|
+
try {
|
|
112
|
+
normalizedLabelHash = parseLabelHashOrEncodedLabelHash(labelHash);
|
|
113
|
+
} catch (error) {
|
|
114
|
+
return {
|
|
115
|
+
status: StatusCode.Error,
|
|
116
|
+
error: error instanceof Error ? error.message : String(error),
|
|
117
|
+
errorCode: ErrorCode.BadRequest
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
const cachedResult = this.cache.get(normalizedLabelHash);
|
|
107
121
|
if (cachedResult) return cachedResult;
|
|
108
|
-
const url = new URL(`/v1/heal/${
|
|
122
|
+
const url = new URL(`/v1/heal/${normalizedLabelHash}`, this.options.endpointUrl);
|
|
109
123
|
this.labelSetSearchParams.forEach((value, key) => {
|
|
110
124
|
url.searchParams.append(key, value);
|
|
111
125
|
});
|
|
112
126
|
const response = await fetch(url);
|
|
113
127
|
const healResponse = await response.json();
|
|
114
128
|
if (isCacheableHealResponse(healResponse)) {
|
|
115
|
-
this.cache.set(
|
|
129
|
+
this.cache.set(normalizedLabelHash, healResponse);
|
|
116
130
|
}
|
|
117
131
|
return healResponse;
|
|
118
132
|
}
|
|
@@ -159,9 +173,20 @@ var EnsRainbowApiClient = class _EnsRainbowApiClient {
|
|
|
159
173
|
const response = await fetch(new URL("/health", this.options.endpointUrl));
|
|
160
174
|
return response.json();
|
|
161
175
|
}
|
|
176
|
+
/**
|
|
177
|
+
* Get the public configuration of the ENSRainbow service.
|
|
178
|
+
*/
|
|
179
|
+
async config() {
|
|
180
|
+
const response = await fetch(new URL("/v1/config", this.options.endpointUrl));
|
|
181
|
+
if (!response.ok) {
|
|
182
|
+
throw new Error(`Failed to fetch ENSRainbow config: ${response.statusText}`);
|
|
183
|
+
}
|
|
184
|
+
return response.json();
|
|
185
|
+
}
|
|
162
186
|
/**
|
|
163
187
|
* Get the version information of the ENSRainbow service
|
|
164
188
|
*
|
|
189
|
+
* @deprecated Use {@link EnsRainbowApiClient.config} instead. This method will be removed in a future version.
|
|
165
190
|
* @returns the version information of the ENSRainbow service
|
|
166
191
|
* @throws if the request fails due to network failures, DNS lookup failures, request
|
|
167
192
|
* timeouts, CORS violations, or invalid URLs
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/client.ts","../src/consts.ts"],"sourcesContent":["import {\n buildEnsRainbowClientLabelSet,\n type Cache,\n type EnsRainbowClientLabelSet,\n type EnsRainbowServerLabelSet,\n type Label,\n type LabelHash,\n LruCache,\n} from \"@ensnode/ensnode-sdk\";\n\nimport { DEFAULT_ENSRAINBOW_URL, ErrorCode, StatusCode } from \"./consts\";\n\nexport namespace EnsRainbow {\n export type ApiClientOptions = EnsRainbowApiClientOptions;\n\n export interface ApiClient {\n count(): Promise<CountResponse>;\n\n /**\n * Heal a labelhash to its original label\n * @param labelHash The labelhash to heal\n */\n heal(labelHash: LabelHash): Promise<HealResponse>;\n\n health(): Promise<HealthResponse>;\n\n version(): Promise<VersionResponse>;\n\n getOptions(): Readonly<EnsRainbowApiClientOptions>;\n }\n\n type StatusCode = (typeof StatusCode)[keyof typeof StatusCode];\n\n type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];\n\n export interface HealthResponse {\n status: \"ok\";\n }\n\n export interface BaseHealResponse<Status extends StatusCode, Error extends ErrorCode> {\n status: Status;\n label?: Label | never;\n error?: string | never;\n errorCode?: Error | never;\n }\n\n export interface HealSuccess extends BaseHealResponse<typeof StatusCode.Success, never> {\n status: typeof StatusCode.Success;\n label: Label;\n error?: never;\n errorCode?: never;\n }\n\n export interface HealNotFoundError\n extends BaseHealResponse<typeof StatusCode.Error, typeof ErrorCode.NotFound> {\n status: typeof StatusCode.Error;\n label?: never;\n error: string;\n errorCode: typeof ErrorCode.NotFound;\n }\n\n export interface HealServerError\n extends BaseHealResponse<typeof StatusCode.Error, typeof ErrorCode.ServerError> {\n status: typeof StatusCode.Error;\n label?: never;\n error: string;\n errorCode: typeof ErrorCode.ServerError;\n }\n\n export interface HealBadRequestError\n extends BaseHealResponse<typeof StatusCode.Error, typeof ErrorCode.BadRequest> {\n status: typeof StatusCode.Error;\n label?: never;\n error: string;\n errorCode: typeof ErrorCode.BadRequest;\n }\n\n export type HealResponse =\n | HealSuccess\n | HealNotFoundError\n | HealServerError\n | HealBadRequestError;\n export type HealError = Exclude<HealResponse, HealSuccess>;\n\n /**\n * Server errors should not be cached.\n */\n export type CacheableHealResponse = Exclude<HealResponse, HealServerError>;\n\n export interface BaseCountResponse<Status extends StatusCode, Error extends ErrorCode> {\n status: Status;\n count?: number | never;\n timestamp?: string | never;\n error?: string | never;\n errorCode?: Error | never;\n }\n\n export interface CountSuccess extends BaseCountResponse<typeof StatusCode.Success, never> {\n status: typeof StatusCode.Success;\n /** The total count of labels that can be healed by the ENSRainbow instance. Always a\n * non-negative integer. */\n count: number;\n timestamp: string;\n error?: never;\n errorCode?: never;\n }\n\n export interface CountServerError\n extends BaseCountResponse<typeof StatusCode.Error, typeof ErrorCode.ServerError> {\n status: typeof StatusCode.Error;\n count?: never;\n timestamp?: never;\n error: string;\n errorCode: typeof ErrorCode.ServerError;\n }\n\n export type CountResponse = CountSuccess | CountServerError;\n\n /**\n * ENSRainbow version information.\n */\n export interface VersionInfo {\n /**\n * ENSRainbow version.\n */\n version: string;\n\n /**\n * ENSRainbow database schema version.\n */\n dbSchemaVersion: number;\n\n /**\n * The EnsRainbowServerLabelSet managed by the ENSRainbow server.\n */\n labelSet: EnsRainbowServerLabelSet;\n }\n\n /**\n * Interface for the version endpoint response\n */\n export interface VersionResponse {\n status: typeof StatusCode.Success;\n versionInfo: VersionInfo;\n }\n}\n\nexport interface EnsRainbowApiClientOptions {\n /**\n * The maximum number of `HealResponse` values to cache.\n * Must be a non-negative integer.\n * Setting to 0 will disable caching.\n */\n cacheCapacity: number;\n\n /**\n * The URL of an ENSRainbow API endpoint.\n */\n endpointUrl: URL;\n\n /**\n * Optional label set preferences that the ENSRainbow server at endpointUrl is expected to\n * support. If provided, enables deterministic heal results across time, such that only\n * labels from label sets with versions less than or equal to this value will be returned.\n * Therefore, even if the ENSRainbow server later ingests label sets with greater versions\n * than this value, the results returned across time can be deterministic. If\n * provided, heal operations with this EnsRainbowApiClient will validate the ENSRainbow\n * server manages a compatible label set. If not provided no specific labelSetId validation\n * will be performed during heal operations.\n * If `labelSetId` is provided without `labelSetVersion`, the server will use the latest\n * available version.\n * If `labelSetVersion` is defined, only labels from sets less than or equal to this value\n * will be returned.\n * When `labelSetVersion` is defined, `labelSetId` must also be defined.\n */\n labelSet?: EnsRainbowClientLabelSet;\n}\n\n/**\n * ENSRainbow API client\n *\n * @example\n * ```typescript\n * // default options\n * const client = new EnsRainbowApiClient();\n * // custom options\n * const client = new EnsRainbowApiClient({\n * endpointUrl: new URL(\"https://api.ensrainbow.io\"),\n * });\n * ```\n */\nexport class EnsRainbowApiClient implements EnsRainbow.ApiClient {\n private readonly options: EnsRainbowApiClientOptions;\n private readonly cache: Cache<LabelHash, EnsRainbow.CacheableHealResponse>;\n private readonly labelSetSearchParams: URLSearchParams;\n\n public static readonly DEFAULT_CACHE_CAPACITY = 1000;\n\n /**\n * Create default client options.\n *\n * @returns default options\n */\n static defaultOptions(): EnsRainbow.ApiClientOptions {\n return {\n endpointUrl: new URL(DEFAULT_ENSRAINBOW_URL),\n cacheCapacity: EnsRainbowApiClient.DEFAULT_CACHE_CAPACITY,\n labelSet: buildEnsRainbowClientLabelSet(),\n };\n }\n\n constructor(options: Partial<EnsRainbow.ApiClientOptions> = {}) {\n const { labelSet: optionsLabelSet, ...rest } = options;\n const defaultOptions = EnsRainbowApiClient.defaultOptions();\n\n const copiedLabelSet = buildEnsRainbowClientLabelSet(\n optionsLabelSet?.labelSetId,\n optionsLabelSet?.labelSetVersion,\n );\n\n this.options = {\n ...defaultOptions,\n ...rest,\n labelSet: copiedLabelSet,\n };\n\n this.cache = new LruCache<LabelHash, EnsRainbow.CacheableHealResponse>(\n this.options.cacheCapacity,\n );\n\n // Pre-compute query parameters for label set options\n this.labelSetSearchParams = new URLSearchParams();\n if (this.options.labelSet?.labelSetId !== undefined) {\n this.labelSetSearchParams.append(\"label_set_id\", this.options.labelSet.labelSetId);\n }\n if (this.options.labelSet?.labelSetVersion !== undefined) {\n this.labelSetSearchParams.append(\n \"label_set_version\",\n this.options.labelSet.labelSetVersion.toString(),\n );\n }\n }\n\n /**\n * Attempt to [heal](https://ensnode.io/ensrainbow/concepts/glossary#heal) a labelHash to its original label.\n *\n * Note on returned labels: ENSRainbow returns labels exactly as they are\n * represented in source rainbow table data. This means:\n *\n * - Labels may or may not be ENS-normalized\n * - Labels can contain any valid string, including dots, null bytes, or be empty\n * - Clients should handle all possible string values appropriately\n *\n * @param labelHash all lowercase 64-digit hex string with 0x prefix (total length of 66 characters)\n * @returns a `HealResponse` indicating the result of the request and the healed label if successful\n * @throws if the request fails due to network failures, DNS lookup failures, request timeouts,\n * CORS violations, or Invalid URLs\n * @example\n * ```typescript\n * const response = await client.heal(\n * \"0xaf2caa1c2ca1d027f1ac823b529d0a67cd144264b2789fa2ea4d63a67c7103cc\"\n * );\n *\n * console.log(response);\n *\n * // Output:\n * // {\n * // status: \"success\",\n * // label: \"vitalik\"\n * // }\n *\n * const notFoundResponse = await client.heal(\n * \"0xf64dc17ae2e2b9b16dbcb8cb05f35a2e6080a5ff1dc53ac0bc48f0e79111f264\"\n * );\n *\n * console.log(notFoundResponse);\n *\n * // Output:\n * // {\n * // status: \"error\",\n * // error: \"Label not found\",\n * // errorCode: 404\n * // }\n * ```\n */\n async heal(labelHash: LabelHash): Promise<EnsRainbow.HealResponse> {\n const cachedResult = this.cache.get(labelHash);\n if (cachedResult) return cachedResult;\n\n const url = new URL(`/v1/heal/${labelHash}`, this.options.endpointUrl);\n\n // Apply pre-computed label set query parameters\n this.labelSetSearchParams.forEach((value, key) => {\n url.searchParams.append(key, value);\n });\n\n const response = await fetch(url);\n const healResponse = (await response.json()) as EnsRainbow.HealResponse;\n\n if (isCacheableHealResponse(healResponse)) {\n this.cache.set(labelHash, healResponse);\n }\n\n return healResponse;\n }\n\n /**\n * Get Count of Healable Labels\n *\n * @returns a `CountResponse` indicating the result and the timestamp of the request and the\n * number of healable labels if successful\n * @throws if the request fails due to network failures, DNS lookup failures, request timeouts,\n * CORS violations, or Invalid URLs\n * @example\n *\n * const response = await client.count();\n *\n * console.log(response);\n *\n * // {\n * // \"status\": \"success\",\n * // \"count\": 133856894,\n * // \"timestamp\": \"2024-01-30T11:18:56Z\"\n * // }\n *\n */\n async count(): Promise<EnsRainbow.CountResponse> {\n const response = await fetch(new URL(\"/v1/labels/count\", this.options.endpointUrl));\n\n return response.json() as Promise<EnsRainbow.CountResponse>;\n }\n\n /**\n *\n * Simple verification that the service is running, either in your local setup or for the\n * provided hosted instance.\n * @returns a status of ENS Rainbow service\n * @example\n *\n * const response = await client.health();\n *\n * console.log(response);\n *\n * // {\n * // \"status\": \"ok\",\n * // }\n */\n async health(): Promise<EnsRainbow.HealthResponse> {\n const response = await fetch(new URL(\"/health\", this.options.endpointUrl));\n\n return response.json() as Promise<EnsRainbow.HealthResponse>;\n }\n\n /**\n * Get the version information of the ENSRainbow service\n *\n * @returns the version information of the ENSRainbow service\n * @throws if the request fails due to network failures, DNS lookup failures, request\n * timeouts, CORS violations, or invalid URLs\n * @example\n * ```typescript\n * const response = await client.version();\n *\n * console.log(response);\n *\n * // {\n * // \"status\": \"success\",\n * // \"versionInfo\": {\n * // \"version\": \"0.1.0\",\n * // \"dbSchemaVersion\": 2,\n * // \"labelSet\": {\n * // \"labelSetId\": \"subgraph\",\n * // \"labelSetVersion\": 0\n * // }\n * // }\n * // }\n * ```\n */\n async version(): Promise<EnsRainbow.VersionResponse> {\n const response = await fetch(new URL(\"/v1/version\", this.options.endpointUrl));\n\n return response.json() as Promise<EnsRainbow.VersionResponse>;\n }\n\n /**\n * Get a copy of the current client options.\n *\n * @returns a copy of the current client options.\n */\n getOptions(): Readonly<EnsRainbowApiClientOptions> {\n // build a deep copy to prevent modification\n const deepCopy = {\n cacheCapacity: this.options.cacheCapacity,\n endpointUrl: new URL(this.options.endpointUrl.href),\n labelSet: this.options.labelSet ? { ...this.options.labelSet } : undefined,\n } satisfies EnsRainbowApiClientOptions;\n\n return Object.freeze(deepCopy);\n }\n}\n\n/**\n * Determine if a heal response is an error.\n *\n * @param response the heal response to check\n * @returns true if the response is an error, false otherwise\n */\nexport const isHealError = (\n response: EnsRainbow.HealResponse,\n): response is EnsRainbow.HealError => {\n return response.status === StatusCode.Error;\n};\n\n/**\n * Determine if a heal response is cacheable.\n *\n * Server errors at not cachable and should be retried.\n *\n * @param response the heal response to check\n * @returns true if the response is cacheable, false otherwise\n */\nexport const isCacheableHealResponse = (\n response: EnsRainbow.HealResponse,\n): response is EnsRainbow.CacheableHealResponse => {\n return response.status === StatusCode.Success || response.errorCode !== ErrorCode.ServerError;\n};\n","export const DEFAULT_ENSRAINBOW_URL = \"https://api.ensrainbow.io\" as const;\n\nexport const StatusCode = {\n Success: \"success\",\n Error: \"error\",\n} as const;\n\nexport const ErrorCode = {\n BadRequest: 400,\n NotFound: 404,\n ServerError: 500,\n} as const;\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EAMA;AAAA,OACK;;;ACRA,IAAM,yBAAyB;AAE/B,IAAM,aAAa;AAAA,EACxB,SAAS;AAAA,EACT,OAAO;AACT;AAEO,IAAM,YAAY;AAAA,EACvB,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,aAAa;AACf;;;ADoLO,IAAM,sBAAN,MAAM,qBAAoD;AAAA,EAC9C;AAAA,EACA;AAAA,EACA;AAAA,EAEjB,OAAuB,yBAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOhD,OAAO,iBAA8C;AACnD,WAAO;AAAA,MACL,aAAa,IAAI,IAAI,sBAAsB;AAAA,MAC3C,eAAe,qBAAoB;AAAA,MACnC,UAAU,8BAA8B;AAAA,IAC1C;AAAA,EACF;AAAA,EAEA,YAAY,UAAgD,CAAC,GAAG;AAC9D,UAAM,EAAE,UAAU,iBAAiB,GAAG,KAAK,IAAI;AAC/C,UAAM,iBAAiB,qBAAoB,eAAe;AAE1D,UAAM,iBAAiB;AAAA,MACrB,iBAAiB;AAAA,MACjB,iBAAiB;AAAA,IACnB;AAEA,SAAK,UAAU;AAAA,MACb,GAAG;AAAA,MACH,GAAG;AAAA,MACH,UAAU;AAAA,IACZ;AAEA,SAAK,QAAQ,IAAI;AAAA,MACf,KAAK,QAAQ;AAAA,IACf;AAGA,SAAK,uBAAuB,IAAI,gBAAgB;AAChD,QAAI,KAAK,QAAQ,UAAU,eAAe,QAAW;AACnD,WAAK,qBAAqB,OAAO,gBAAgB,KAAK,QAAQ,SAAS,UAAU;AAAA,IACnF;AACA,QAAI,KAAK,QAAQ,UAAU,oBAAoB,QAAW;AACxD,WAAK,qBAAqB;AAAA,QACx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AEzE,WAAO,SAAS,KAAK;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA2BA,MAAM,UAA+C;AACnD,UAAM,WAAW,MAAM,MAAM,IAAI,IAAI,eAAe,KAAK,QAAQ,WAAW,CAAC;AAE7E,WAAO,SAAS,KAAK;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,aAAmD;AAEjD,UAAM,WAAW;AAAA,MACf,eAAe,KAAK,QAAQ;AAAA,MAC5B,aAAa,IAAI,IAAI,KAAK,QAAQ,YAAY,IAAI;AAAA,MAClD,UAAU,KAAK,QAAQ,WAAW,EAAE,GAAG,KAAK,QAAQ,SAAS,IAAI;AAAA,IACnE;AAEA,WAAO,OAAO,OAAO,QAAQ;AAAA,EAC/B;AACF;AAQO,IAAM,cAAc,CACzB,aACqC;AACrC,SAAO,SAAS,WAAW,WAAW;AACxC;AAUO,IAAM,0BAA0B,CACrC,aACiD;AACjD,SAAO,SAAS,WAAW,WAAW,WAAW,SAAS,cAAc,UAAU;AACpF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/client.ts","../src/consts.ts"],"sourcesContent":["import {\n buildEnsRainbowClientLabelSet,\n type Cache,\n type EncodedLabelHash,\n type EnsRainbowClientLabelSet,\n type EnsRainbowPublicConfig,\n type EnsRainbowServerLabelSet,\n type Label,\n type LabelHash,\n LruCache,\n parseLabelHashOrEncodedLabelHash,\n} from \"@ensnode/ensnode-sdk\";\n\nimport { DEFAULT_ENSRAINBOW_URL, ErrorCode, StatusCode } from \"./consts\";\n\nexport namespace EnsRainbow {\n export type ApiClientOptions = EnsRainbowApiClientOptions;\n\n export interface ApiClient {\n count(): Promise<CountResponse>;\n\n /**\n * Get the public configuration of the ENSRainbow service\n */\n config(): Promise<ENSRainbowPublicConfig>;\n\n /**\n * Heal a labelHash to its original label.\n * Accepts a strict `LabelHash`, an `EncodedLabelHash` (bracket-enclosed), or any string\n * that can be normalized (missing `0x` prefix, uppercase hex chars, or 63-char hex).\n * Returns a `HealBadRequestError` if the input cannot be normalized to a valid labelHash.\n */\n heal(labelHash: LabelHash | EncodedLabelHash | string): Promise<HealResponse>;\n\n health(): Promise<HealthResponse>;\n\n /**\n * Get the version information of the ENSRainbow service\n *\n * @deprecated Use {@link ApiClient.config} instead. This method will be removed in a future version.\n */\n version(): Promise<VersionResponse>;\n\n getOptions(): Readonly<EnsRainbowApiClientOptions>;\n }\n\n type StatusCode = (typeof StatusCode)[keyof typeof StatusCode];\n\n type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];\n\n export interface HealthResponse {\n status: \"ok\";\n }\n\n export interface BaseHealResponse<Status extends StatusCode, Error extends ErrorCode> {\n status: Status;\n label?: Label | never;\n error?: string | never;\n errorCode?: Error | never;\n }\n\n export interface HealSuccess extends BaseHealResponse<typeof StatusCode.Success, never> {\n status: typeof StatusCode.Success;\n label: Label;\n error?: never;\n errorCode?: never;\n }\n\n export interface HealNotFoundError\n extends BaseHealResponse<typeof StatusCode.Error, typeof ErrorCode.NotFound> {\n status: typeof StatusCode.Error;\n label?: never;\n error: string;\n errorCode: typeof ErrorCode.NotFound;\n }\n\n export interface HealServerError\n extends BaseHealResponse<typeof StatusCode.Error, typeof ErrorCode.ServerError> {\n status: typeof StatusCode.Error;\n label?: never;\n error: string;\n errorCode: typeof ErrorCode.ServerError;\n }\n\n export interface HealBadRequestError\n extends BaseHealResponse<typeof StatusCode.Error, typeof ErrorCode.BadRequest> {\n status: typeof StatusCode.Error;\n label?: never;\n error: string;\n errorCode: typeof ErrorCode.BadRequest;\n }\n\n export type HealResponse =\n | HealSuccess\n | HealNotFoundError\n | HealServerError\n | HealBadRequestError;\n export type HealError = Exclude<HealResponse, HealSuccess>;\n\n /**\n * Server errors should not be cached.\n */\n export type CacheableHealResponse = Exclude<HealResponse, HealServerError>;\n\n export interface BaseCountResponse<Status extends StatusCode, Error extends ErrorCode> {\n status: Status;\n count?: number | never;\n timestamp?: string | never;\n error?: string | never;\n errorCode?: Error | never;\n }\n\n export interface CountSuccess extends BaseCountResponse<typeof StatusCode.Success, never> {\n status: typeof StatusCode.Success;\n /** The total count of labels that can be healed by the ENSRainbow instance. Always a\n * non-negative integer. */\n count: number;\n timestamp: string;\n error?: never;\n errorCode?: never;\n }\n\n export interface CountServerError\n extends BaseCountResponse<typeof StatusCode.Error, typeof ErrorCode.ServerError> {\n status: typeof StatusCode.Error;\n count?: never;\n timestamp?: never;\n error: string;\n errorCode: typeof ErrorCode.ServerError;\n }\n\n export type CountResponse = CountSuccess | CountServerError;\n\n /**\n * ENSRainbow version information.\n *\n * @deprecated Use {@link ENSRainbowPublicConfig} instead. This type will be removed in a future version.\n */\n export interface VersionInfo {\n /**\n * ENSRainbow version.\n */\n version: string;\n\n /**\n * ENSRainbow database schema version.\n */\n dbSchemaVersion: number;\n\n /**\n * The EnsRainbowServerLabelSet managed by the ENSRainbow server.\n */\n labelSet: EnsRainbowServerLabelSet;\n }\n\n /**\n * Interface for the version endpoint response\n *\n * @deprecated Use {@link ENSRainbowPublicConfig} instead. This type will be removed in a future version.\n */\n export interface VersionResponse {\n status: typeof StatusCode.Success;\n versionInfo: VersionInfo;\n }\n\n /**\n * Complete public configuration object for ENSRainbow.\n *\n * Contains all public configuration information about the ENSRainbow service instance,\n * including version, label set information, and record counts.\n */\n export type ENSRainbowPublicConfig = EnsRainbowPublicConfig;\n}\n\nexport interface EnsRainbowApiClientOptions {\n /**\n * The maximum number of `HealResponse` values to cache.\n * Must be a non-negative integer.\n * Setting to 0 will disable caching.\n */\n cacheCapacity: number;\n\n /**\n * The URL of an ENSRainbow API endpoint.\n */\n endpointUrl: URL;\n\n /**\n * Optional label set preferences that the ENSRainbow server at endpointUrl is expected to\n * support. If provided, enables deterministic heal results across time, such that only\n * labels from label sets with versions less than or equal to this value will be returned.\n * Therefore, even if the ENSRainbow server later ingests label sets with greater versions\n * than this value, the results returned across time can be deterministic. If\n * provided, heal operations with this EnsRainbowApiClient will validate the ENSRainbow\n * server manages a compatible label set. If not provided no specific labelSetId validation\n * will be performed during heal operations.\n * If `labelSetId` is provided without `labelSetVersion`, the server will use the latest\n * available version.\n * If `labelSetVersion` is defined, only labels from sets less than or equal to this value\n * will be returned.\n * When `labelSetVersion` is defined, `labelSetId` must also be defined.\n */\n labelSet?: EnsRainbowClientLabelSet;\n}\n\n/**\n * ENSRainbow API client\n *\n * @example\n * ```typescript\n * // default options\n * const client = new EnsRainbowApiClient();\n * // custom options\n * const client = new EnsRainbowApiClient({\n * endpointUrl: new URL(\"https://api.ensrainbow.io\"),\n * });\n * ```\n */\nexport class EnsRainbowApiClient implements EnsRainbow.ApiClient {\n private readonly options: EnsRainbowApiClientOptions;\n private readonly cache: Cache<LabelHash, EnsRainbow.CacheableHealResponse>;\n private readonly labelSetSearchParams: URLSearchParams;\n\n public static readonly DEFAULT_CACHE_CAPACITY = 1000;\n\n /**\n * Create default client options.\n *\n * @returns default options\n */\n static defaultOptions(): EnsRainbow.ApiClientOptions {\n return {\n endpointUrl: new URL(DEFAULT_ENSRAINBOW_URL),\n cacheCapacity: EnsRainbowApiClient.DEFAULT_CACHE_CAPACITY,\n labelSet: buildEnsRainbowClientLabelSet(),\n };\n }\n\n constructor(options: Partial<EnsRainbow.ApiClientOptions> = {}) {\n const { labelSet: optionsLabelSet, ...rest } = options;\n const defaultOptions = EnsRainbowApiClient.defaultOptions();\n\n const copiedLabelSet = buildEnsRainbowClientLabelSet(\n optionsLabelSet?.labelSetId,\n optionsLabelSet?.labelSetVersion,\n );\n\n this.options = {\n ...defaultOptions,\n ...rest,\n labelSet: copiedLabelSet,\n };\n\n this.cache = new LruCache<LabelHash, EnsRainbow.CacheableHealResponse>(\n this.options.cacheCapacity,\n );\n\n // Pre-compute query parameters for label set options\n this.labelSetSearchParams = new URLSearchParams();\n if (this.options.labelSet?.labelSetId !== undefined) {\n this.labelSetSearchParams.append(\"label_set_id\", this.options.labelSet.labelSetId);\n }\n if (this.options.labelSet?.labelSetVersion !== undefined) {\n this.labelSetSearchParams.append(\n \"label_set_version\",\n this.options.labelSet.labelSetVersion.toString(),\n );\n }\n }\n\n /**\n * Attempt to [heal](https://ensnode.io/ensrainbow/concepts/glossary#heal) a labelHash to its original label.\n *\n * Note on returned labels: ENSRainbow returns labels exactly as they are\n * represented in source rainbow table data. This means:\n *\n * - Labels may or may not be ENS-normalized\n * - Labels can contain any valid string, including dots, null bytes, or be empty\n * - Clients should handle all possible string values appropriately\n *\n * @param labelHash - A labelHash to heal, either as a strict `LabelHash`, an `EncodedLabelHash`\n * (bracket-enclosed), or any string that can be normalized (missing `0x` prefix, uppercase hex\n * chars, or 63-char hex are all accepted and normalized automatically).\n * @returns a `HealResponse` indicating the result of the request and the healed label if successful.\n * Returns a `HealBadRequestError` if the input cannot be normalized to a valid labelHash.\n * @throws if the request fails due to network failures, DNS lookup failures, request timeouts,\n * CORS violations, or Invalid URLs\n * @example\n * ```typescript\n * const response = await client.heal(\n * \"0xaf2caa1c2ca1d027f1ac823b529d0a67cd144264b2789fa2ea4d63a67c7103cc\"\n * );\n *\n * console.log(response);\n *\n * // Output:\n * // {\n * // status: \"success\",\n * // label: \"vitalik\"\n * // }\n *\n * const notFoundResponse = await client.heal(\n * \"0xf64dc17ae2e2b9b16dbcb8cb05f35a2e6080a5ff1dc53ac0bc48f0e79111f264\"\n * );\n *\n * console.log(notFoundResponse);\n *\n * // Output:\n * // {\n * // status: \"error\",\n * // error: \"Label not found\",\n * // errorCode: 404\n * // }\n * ```\n */\n async heal(labelHash: LabelHash | EncodedLabelHash | string): Promise<EnsRainbow.HealResponse> {\n let normalizedLabelHash: LabelHash;\n\n try {\n normalizedLabelHash = parseLabelHashOrEncodedLabelHash(labelHash);\n } catch (error) {\n return {\n status: StatusCode.Error,\n error: error instanceof Error ? error.message : String(error),\n errorCode: ErrorCode.BadRequest,\n } as EnsRainbow.HealBadRequestError;\n }\n\n const cachedResult = this.cache.get(normalizedLabelHash);\n if (cachedResult) return cachedResult;\n\n const url = new URL(`/v1/heal/${normalizedLabelHash}`, this.options.endpointUrl);\n\n // Apply pre-computed label set query parameters\n this.labelSetSearchParams.forEach((value, key) => {\n url.searchParams.append(key, value);\n });\n\n const response = await fetch(url);\n const healResponse = (await response.json()) as EnsRainbow.HealResponse;\n\n if (isCacheableHealResponse(healResponse)) {\n this.cache.set(normalizedLabelHash, healResponse);\n }\n\n return healResponse;\n }\n\n /**\n * Get Count of Healable Labels\n *\n * @returns a `CountResponse` indicating the result and the timestamp of the request and the\n * number of healable labels if successful\n * @throws if the request fails due to network failures, DNS lookup failures, request timeouts,\n * CORS violations, or Invalid URLs\n * @example\n *\n * const response = await client.count();\n *\n * console.log(response);\n *\n * // {\n * // \"status\": \"success\",\n * // \"count\": 133856894,\n * // \"timestamp\": \"2024-01-30T11:18:56Z\"\n * // }\n *\n */\n async count(): Promise<EnsRainbow.CountResponse> {\n const response = await fetch(new URL(\"/v1/labels/count\", this.options.endpointUrl));\n\n return response.json() as Promise<EnsRainbow.CountResponse>;\n }\n\n /**\n *\n * Simple verification that the service is running, either in your local setup or for the\n * provided hosted instance.\n * @returns a status of ENS Rainbow service\n * @example\n *\n * const response = await client.health();\n *\n * console.log(response);\n *\n * // {\n * // \"status\": \"ok\",\n * // }\n */\n async health(): Promise<EnsRainbow.HealthResponse> {\n const response = await fetch(new URL(\"/health\", this.options.endpointUrl));\n\n return response.json() as Promise<EnsRainbow.HealthResponse>;\n }\n\n /**\n * Get the public configuration of the ENSRainbow service.\n */\n async config(): Promise<EnsRainbow.ENSRainbowPublicConfig> {\n const response = await fetch(new URL(\"/v1/config\", this.options.endpointUrl));\n\n if (!response.ok) {\n throw new Error(`Failed to fetch ENSRainbow config: ${response.statusText}`);\n }\n\n return response.json() as Promise<EnsRainbow.ENSRainbowPublicConfig>;\n }\n\n /**\n * Get the version information of the ENSRainbow service\n *\n * @deprecated Use {@link EnsRainbowApiClient.config} instead. This method will be removed in a future version.\n * @returns the version information of the ENSRainbow service\n * @throws if the request fails due to network failures, DNS lookup failures, request\n * timeouts, CORS violations, or invalid URLs\n * @example\n * ```typescript\n * const response = await client.version();\n *\n * console.log(response);\n *\n * // {\n * // \"status\": \"success\",\n * // \"versionInfo\": {\n * // \"version\": \"0.1.0\",\n * // \"dbSchemaVersion\": 2,\n * // \"labelSet\": {\n * // \"labelSetId\": \"subgraph\",\n * // \"labelSetVersion\": 0\n * // }\n * // }\n * // }\n * ```\n */\n async version(): Promise<EnsRainbow.VersionResponse> {\n const response = await fetch(new URL(\"/v1/version\", this.options.endpointUrl));\n\n return response.json() as Promise<EnsRainbow.VersionResponse>;\n }\n\n /**\n * Get a copy of the current client options.\n *\n * @returns a copy of the current client options.\n */\n getOptions(): Readonly<EnsRainbowApiClientOptions> {\n // build a deep copy to prevent modification\n const deepCopy = {\n cacheCapacity: this.options.cacheCapacity,\n endpointUrl: new URL(this.options.endpointUrl.href),\n labelSet: this.options.labelSet ? { ...this.options.labelSet } : undefined,\n } satisfies EnsRainbowApiClientOptions;\n\n return Object.freeze(deepCopy);\n }\n}\n\n/**\n * Determine if a heal response is an error.\n *\n * @param response the heal response to check\n * @returns true if the response is an error, false otherwise\n */\nexport const isHealError = (\n response: EnsRainbow.HealResponse,\n): response is EnsRainbow.HealError => {\n return response.status === StatusCode.Error;\n};\n\n/**\n * Determine if a heal response is cacheable.\n *\n * Server errors at not cachable and should be retried.\n *\n * @param response the heal response to check\n * @returns true if the response is cacheable, false otherwise\n */\nexport const isCacheableHealResponse = (\n response: EnsRainbow.HealResponse,\n): response is EnsRainbow.CacheableHealResponse => {\n return response.status === StatusCode.Success || response.errorCode !== ErrorCode.ServerError;\n};\n","export const DEFAULT_ENSRAINBOW_URL = \"https://api.ensrainbow.io\" as const;\n\nexport const StatusCode = {\n Success: \"success\",\n Error: \"error\",\n} as const;\n\nexport const ErrorCode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ildEnsRainbowClientLabelSet2 } from
|
|
|
4
4
|
// src/client.ts
|
|
5
5
|
import {
|
|
6
6
|
buildEnsRainbowClientLabelSet,
|
|
7
|
-
LruCache
|
|
7
|
+
LruCache,
|
|
8
|
+
parseLabelHashOrEncodedLabelHash
|
|
8
9
|
} from "@ensnode/ensnode-sdk";
|
|
9
10
|
|
|
10
11
|
// src/consts.ts
|
|
@@ -73,8 +74,11 @@ var EnsRainbowApiClient = class _EnsRainbowApiClient {
|
|
|
73
74
|
* - Labels can contain any valid string, including dots, null bytes, or be empty
|
|
74
75
|
* - Clients should handle all possible string values appropriately
|
|
75
76
|
*
|
|
76
|
-
* @param labelHash
|
|
77
|
-
*
|
|
77
|
+
* @param labelHash - A labelHash to heal, either as a strict `LabelHash`, an `EncodedLabelHash`
|
|
78
|
+
* (bracket-enclosed), or any string that can be normalized (missing `0x` prefix, uppercase hex
|
|
79
|
+
* chars, or 63-char hex are all accepted and normalized automatically).
|
|
80
|
+
* @returns a `HealResponse` indicating the result of the request and the healed label if successful.
|
|
81
|
+
* Returns a `HealBadRequestError` if the input cannot be normalized to a valid labelHash.
|
|
78
82
|
* @throws if the request fails due to network failures, DNS lookup failures, request timeouts,
|
|
79
83
|
* CORS violations, or Invalid URLs
|
|
80
84
|
* @example
|
|
@@ -106,16 +110,26 @@ var EnsRainbowApiClient = class _EnsRainbowApiClient {
|
|
|
106
110
|
* ```
|
|
107
111
|
*/
|
|
108
112
|
async heal(labelHash) {
|
|
109
|
-
|
|
113
|
+
let normalizedLabelHash;
|
|
114
|
+
try {
|
|
115
|
+
normalizedLabelHash = parseLabelHashOrEncodedLabelHash(labelHash);
|
|
116
|
+
} catch (error) {
|
|
117
|
+
return {
|
|
118
|
+
status: StatusCode.Error,
|
|
119
|
+
error: error instanceof Error ? error.message : String(error),
|
|
120
|
+
errorCode: ErrorCode.BadRequest
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
const cachedResult = this.cache.get(normalizedLabelHash);
|
|
110
124
|
if (cachedResult) return cachedResult;
|
|
111
|
-
const url = new URL(`/v1/heal/${
|
|
125
|
+
const url = new URL(`/v1/heal/${normalizedLabelHash}`, this.options.endpointUrl);
|
|
112
126
|
this.labelSetSearchParams.forEach((value, key) => {
|
|
113
127
|
url.searchParams.append(key, value);
|
|
114
128
|
});
|
|
115
129
|
const response = await fetch(url);
|
|
116
130
|
const healResponse = await response.json();
|
|
117
131
|
if (isCacheableHealResponse(healResponse)) {
|
|
118
|
-
this.cache.set(
|
|
132
|
+
this.cache.set(normalizedLabelHash, healResponse);
|
|
119
133
|
}
|
|
120
134
|
return healResponse;
|
|
121
135
|
}
|
|
@@ -162,9 +176,20 @@ var EnsRainbowApiClient = class _EnsRainbowApiClient {
|
|
|
162
176
|
const response = await fetch(new URL("/health", this.options.endpointUrl));
|
|
163
177
|
return response.json();
|
|
164
178
|
}
|
|
179
|
+
/**
|
|
180
|
+
* Get the public configuration of the ENSRainbow service.
|
|
181
|
+
*/
|
|
182
|
+
async config() {
|
|
183
|
+
const response = await fetch(new URL("/v1/config", this.options.endpointUrl));
|
|
184
|
+
if (!response.ok) {
|
|
185
|
+
throw new Error(`Failed to fetch ENSRainbow config: ${response.statusText}`);
|
|
186
|
+
}
|
|
187
|
+
return response.json();
|
|
188
|
+
}
|
|
165
189
|
/**
|
|
166
190
|
* Get the version information of the ENSRainbow service
|
|
167
191
|
*
|
|
192
|
+
* @deprecated Use {@link EnsRainbowApiClient.config} instead. This method will be removed in a future version.
|
|
168
193
|
* @returns the version information of the ENSRainbow service
|
|
169
194
|
* @throws if the request fails due to network failures, DNS lookup failures, request
|
|
170
195
|
* timeouts, CORS violations, or invalid URLs
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/client.ts","../src/consts.ts"],"sourcesContent":["// Re-export types from ensnode-sdk that are needed by consumers\nexport type {\n EnsRainbowClientLabelSet,\n EnsRainbowServerLabelSet,\n LabelSetId,\n LabelSetVersion,\n} from \"@ensnode/ensnode-sdk\";\n// Re-export utility functions and classes from ensnode-sdk that are needed by consumers\nexport { buildEnsRainbowClientLabelSet } from \"@ensnode/ensnode-sdk\";\n\nexport * from \"./client\";\nexport * from \"./consts\";\n","import {\n buildEnsRainbowClientLabelSet,\n type Cache,\n type EnsRainbowClientLabelSet,\n type EnsRainbowServerLabelSet,\n type Label,\n type LabelHash,\n LruCache,\n} from \"@ensnode/ensnode-sdk\";\n\nimport { DEFAULT_ENSRAINBOW_URL, ErrorCode, StatusCode } from \"./consts\";\n\nexport namespace EnsRainbow {\n export type ApiClientOptions = EnsRainbowApiClientOptions;\n\n export interface ApiClient {\n count(): Promise<CountResponse>;\n\n /**\n * Heal a labelhash to its original label\n * @param labelHash The labelhash to heal\n */\n heal(labelHash: LabelHash): Promise<HealResponse>;\n\n health(): Promise<HealthResponse>;\n\n version(): Promise<VersionResponse>;\n\n getOptions(): Readonly<EnsRainbowApiClientOptions>;\n }\n\n type StatusCode = (typeof StatusCode)[keyof typeof StatusCode];\n\n type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];\n\n export interface HealthResponse {\n status: \"ok\";\n }\n\n export interface BaseHealResponse<Status extends StatusCode, Error extends ErrorCode> {\n status: Status;\n label?: Label | never;\n error?: string | never;\n errorCode?: Error | never;\n }\n\n export interface HealSuccess extends BaseHealResponse<typeof StatusCode.Success, never> {\n status: typeof StatusCode.Success;\n label: Label;\n error?: never;\n errorCode?: never;\n }\n\n export interface HealNotFoundError\n extends BaseHealResponse<typeof StatusCode.Error, typeof ErrorCode.NotFound> {\n status: typeof StatusCode.Error;\n label?: never;\n error: string;\n errorCode: typeof ErrorCode.NotFound;\n }\n\n export interface HealServerError\n extends BaseHealResponse<typeof StatusCode.Error, typeof ErrorCode.ServerError> {\n status: typeof StatusCode.Error;\n label?: never;\n error: string;\n errorCode: typeof ErrorCode.ServerError;\n }\n\n export interface HealBadRequestError\n extends BaseHealResponse<typeof StatusCode.Error, typeof ErrorCode.BadRequest> {\n status: typeof StatusCode.Error;\n label?: never;\n error: string;\n errorCode: typeof ErrorCode.BadRequest;\n }\n\n export type HealResponse =\n | HealSuccess\n | HealNotFoundError\n | HealServerError\n | HealBadRequestError;\n export type HealError = Exclude<HealResponse, HealSuccess>;\n\n /**\n * Server errors should not be cached.\n */\n export type CacheableHealResponse = Exclude<HealResponse, HealServerError>;\n\n export interface BaseCountResponse<Status extends StatusCode, Error extends ErrorCode> {\n status: Status;\n count?: number | never;\n timestamp?: string | never;\n error?: string | never;\n errorCode?: Error | never;\n }\n\n export interface CountSuccess extends BaseCountResponse<typeof StatusCode.Success, never> {\n status: typeof StatusCode.Success;\n /** The total count of labels that can be healed by the ENSRainbow instance. Always a\n * non-negative integer. */\n count: number;\n timestamp: string;\n error?: never;\n errorCode?: never;\n }\n\n export interface CountServerError\n extends BaseCountResponse<typeof StatusCode.Error, typeof ErrorCode.ServerError> {\n status: typeof StatusCode.Error;\n count?: never;\n timestamp?: never;\n error: string;\n errorCode: typeof ErrorCode.ServerError;\n }\n\n export type CountResponse = CountSuccess | CountServerError;\n\n /**\n * ENSRainbow version information.\n */\n export interface VersionInfo {\n /**\n * ENSRainbow version.\n */\n version: string;\n\n /**\n * ENSRainbow database schema version.\n */\n dbSchemaVersion: number;\n\n /**\n * The EnsRainbowServerLabelSet managed by the ENSRainbow server.\n */\n labelSet: EnsRainbowServerLabelSet;\n }\n\n /**\n * Interface for the version endpoint response\n */\n export interface VersionResponse {\n status: typeof StatusCode.Success;\n versionInfo: VersionInfo;\n }\n}\n\nexport interface EnsRainbowApiClientOptions {\n /**\n * The maximum number of `HealResponse` values to cache.\n * Must be a non-negative integer.\n * Setting to 0 will disable caching.\n */\n cacheCapacity: number;\n\n /**\n * The URL of an ENSRainbow API endpoint.\n */\n endpointUrl: URL;\n\n /**\n * Optional label set preferences that the ENSRainbow server at endpointUrl is expected to\n * support. If provided, enables deterministic heal results across time, such that only\n * labels from label sets with versions less than or equal to this value will be returned.\n * Therefore, even if the ENSRainbow server later ingests label sets with greater versions\n * than this value, the results returned across time can be deterministic. If\n * provided, heal operations with this EnsRainbowApiClient will validate the ENSRainbow\n * server manages a compatible label set. If not provided no specific labelSetId validation\n * will be performed during heal operations.\n * If `labelSetId` is provided without `labelSetVersion`, the server will use the latest\n * available version.\n * If `labelSetVersion` is defined, only labels from sets less than or equal to this value\n * will be returned.\n * When `labelSetVersion` is defined, `labelSetId` must also be defined.\n */\n labelSet?: EnsRainbowClientLabelSet;\n}\n\n/**\n * ENSRainbow API client\n *\n * @example\n * ```typescript\n * // default options\n * const client = new EnsRainbowApiClient();\n * // custom options\n * const client = new EnsRainbowApiClient({\n * endpointUrl: new URL(\"https://api.ensrainbow.io\"),\n * });\n * ```\n */\nexport class EnsRainbowApiClient implements EnsRainbow.ApiClient {\n private readonly options: EnsRainbowApiClientOptions;\n private readonly cache: Cache<LabelHash, EnsRainbow.CacheableHealResponse>;\n private readonly labelSetSearchParams: URLSearchParams;\n\n public static readonly DEFAULT_CACHE_CAPACITY = 1000;\n\n /**\n * Create default client options.\n *\n * @returns default options\n */\n static defaultOptions(): EnsRainbow.ApiClientOptions {\n return {\n endpointUrl: new URL(DEFAULT_ENSRAINBOW_URL),\n cacheCapacity: EnsRainbowApiClient.DEFAULT_CACHE_CAPACITY,\n labelSet: buildEnsRainbowClientLabelSet(),\n };\n }\n\n constructor(options: Partial<EnsRainbow.ApiClientOptions> = {}) {\n const { labelSet: optionsLabelSet, ...rest } = options;\n const defaultOptions = EnsRainbowApiClient.defaultOptions();\n\n const copiedLabelSet = buildEnsRainbowClientLabelSet(\n optionsLabelSet?.labelSetId,\n optionsLabelSet?.labelSetVersion,\n );\n\n this.options = {\n ...defaultOptions,\n ...rest,\n labelSet: copiedLabelSet,\n };\n\n this.cache = new LruCache<LabelHash, EnsRainbow.CacheableHealResponse>(\n this.options.cacheCapacity,\n );\n\n // Pre-compute query parameters for label set options\n this.labelSetSearchParams = new URLSearchParams();\n if (this.options.labelSet?.labelSetId !== undefined) {\n this.labelSetSearchParams.append(\"label_set_id\", this.options.labelSet.labelSetId);\n }\n if (this.options.labelSet?.labelSetVersion !== undefined) {\n this.labelSetSearchParams.append(\n \"label_set_version\",\n this.options.labelSet.labelSetVersion.toString(),\n );\n }\n }\n\n /**\n * Attempt to [heal](https://ensnode.io/ensrainbow/concepts/glossary#heal) a labelHash to its original label.\n *\n * Note on returned labels: ENSRainbow returns labels exactly as they are\n * represented in source rainbow table data. This means:\n *\n * - Labels may or may not be ENS-normalized\n * - Labels can contain any valid string, including dots, null bytes, or be empty\n * - Clients should handle all possible string values appropriately\n *\n * @param labelHash all lowercase 64-digit hex string with 0x prefix (total length of 66 characters)\n * @returns a `HealResponse` indicating the result of the request and the healed label if successful\n * @throws if the request fails due to network failures, DNS lookup failures, request timeouts,\n * CORS violations, or Invalid URLs\n * @example\n * ```typescript\n * const response = await client.heal(\n * \"0xaf2caa1c2ca1d027f1ac823b529d0a67cd144264b2789fa2ea4d63a67c7103cc\"\n * );\n *\n * console.log(response);\n *\n * // Output:\n * // {\n * // status: \"success\",\n * // label: \"vitalik\"\n * // }\n *\n * const notFoundResponse = await client.heal(\n * \"0xf64dc17ae2e2b9b16dbcb8cb05f35a2e6080a5ff1dc53ac0bc48f0e79111f264\"\n * );\n *\n * console.log(notFoundResponse);\n *\n * // Output:\n * // {\n * // status: \"error\",\n * // error: \"Label not found\",\n * // errorCode: 404\n * // }\n * ```\n */\n async heal(labelHash: LabelHash): Promise<EnsRainbow.HealResponse> {\n const cachedResult = this.cache.get(labelHash);\n if (cachedResult) return cachedResult;\n\n const url = new URL(`/v1/heal/${labelHash}`, this.options.endpointUrl);\n\n // Apply pre-computed label set query parameters\n this.labelSetSearchParams.forEach((value, key) => {\n url.searchParams.append(key, value);\n });\n\n const response = await fetch(url);\n const healResponse = (await response.json()) as EnsRainbow.HealResponse;\n\n if (isCacheableHealResponse(healResponse)) {\n this.cache.set(labelHash, healResponse);\n }\n\n return healResponse;\n }\n\n /**\n * Get Count of Healable Labels\n *\n * @returns a `CountResponse` indicating the result and the timestamp of the request and the\n * number of healable labels if successful\n * @throws if the request fails due to network failures, DNS lookup failures, request timeouts,\n * CORS violations, or Invalid URLs\n * @example\n *\n * const response = await client.count();\n *\n * console.log(response);\n *\n * // {\n * // \"status\": \"success\",\n * // \"count\": 133856894,\n * // \"timestamp\": \"2024-01-30T11:18:56Z\"\n * // }\n *\n */\n async count(): Promise<EnsRainbow.CountResponse> {\n const response = await fetch(new URL(\"/v1/labels/count\", this.options.endpointUrl));\n\n return response.json() as Promise<EnsRainbow.CountResponse>;\n }\n\n /**\n *\n * Simple verification that the service is running, either in your local setup or for the\n * provided hosted instance.\n * @returns a status of ENS Rainbow service\n * @example\n *\n * const response = await client.health();\n *\n * console.log(response);\n *\n * // {\n * // \"status\": \"ok\",\n * // }\n */\n async health(): Promise<EnsRainbow.HealthResponse> {\n const response = await fetch(new URL(\"/health\", this.options.endpointUrl));\n\n return response.json() as Promise<EnsRainbow.HealthResponse>;\n }\n\n /**\n * Get the version information of the ENSRainbow service\n *\n * @returns the version information of the ENSRainbow service\n * @throws if the request fails due to network failures, DNS lookup failures, request\n * timeouts, CORS violations, or invalid URLs\n * @example\n * ```typescript\n * const response = await client.version();\n *\n * console.log(response);\n *\n * // {\n * // \"status\": \"success\",\n * // \"versionInfo\": {\n * // \"version\": \"0.1.0\",\n * // \"dbSchemaVersion\": 2,\n * // \"labelSet\": {\n * // \"labelSetId\": \"subgraph\",\n * // \"labelSetVersion\": 0\n * // }\n * // }\n * // }\n * ```\n */\n async version(): Promise<EnsRainbow.VersionResponse> {\n const response = await fetch(new URL(\"/v1/version\", this.options.endpointUrl));\n\n return response.json() as Promise<EnsRainbow.VersionResponse>;\n }\n\n /**\n * Get a copy of the current client options.\n *\n * @returns a copy of the current client options.\n */\n getOptions(): Readonly<EnsRainbowApiClientOptions> {\n // build a deep copy to prevent modification\n const deepCopy = {\n cacheCapacity: this.options.cacheCapacity,\n endpointUrl: new URL(this.options.endpointUrl.href),\n labelSet: this.options.labelSet ? { ...this.options.labelSet } : undefined,\n } satisfies EnsRainbowApiClientOptions;\n\n return Object.freeze(deepCopy);\n }\n}\n\n/**\n * Determine if a heal response is an error.\n *\n * @param response the heal response to check\n * @returns true if the response is an error, false otherwise\n */\nexport const isHealError = (\n response: EnsRainbow.HealResponse,\n): response is EnsRainbow.HealError => {\n return response.status === StatusCode.Error;\n};\n\n/**\n * Determine if a heal response is cacheable.\n *\n * Server errors at not cachable and should be retried.\n *\n * @param response the heal response to check\n * @returns true if the response is cacheable, false otherwise\n */\nexport const isCacheableHealResponse = (\n response: EnsRainbow.HealResponse,\n): response is EnsRainbow.CacheableHealResponse => {\n return response.status === StatusCode.Success || response.errorCode !== ErrorCode.ServerError;\n};\n","export const DEFAULT_ENSRAINBOW_URL = \"https://api.ensrainbow.io\" as const;\n\nexport const StatusCode = {\n Success: \"success\",\n Error: \"error\",\n} as const;\n\nexport const ErrorCode = {\n BadRequest: 400,\n NotFound: 404,\n ServerError: 500,\n} as const;\n"],"mappings":";AAQA,SAAS,iCAAAA,sCAAqC;;;ACR9C;AAAA,EACE;AAAA,EAMA;AAAA,OACK;;;ACRA,IAAM,yBAAyB;AAE/B,IAAM,aAAa;AAAA,EACxB,SAAS;AAAA,EACT,OAAO;AACT;AAEO,IAAM,YAAY;AAAA,EACvB,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,aAAa;AACf;;;ADoLO,IAAM,sBAAN,MAAM,qBAAoD;AAAA,EAC9C;AAAA,EACA;AAAA,EACA;AAAA,EAEjB,OAAuB,yBAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOhD,OAAO,iBAA8C;AACnD,WAAO;AAAA,MACL,aAAa,IAAI,IAAI,sBAAsB;AAAA,MAC3C,eAAe,qBAAoB;AAAA,MACnC,UAAU,8BAA8B;AAAA,IAC1C;AAAA,EACF;AAAA,EAEA,YAAY,UAAgD,CAAC,GAAG;AAC9D,UAAM,EAAE,UAAU,iB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WAAW,WAAW,WAAW,SAAS,cAAc,UAAU;AACpF;","names":["buildEnsRainbowClientLabelSet"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/client.ts","../src/consts.ts"],"sourcesContent":["// Re-export types from ensnode-sdk that are needed by consumers\nexport type {\n EnsRainbowClientLabelSet,\n EnsRainbowServerLabelSet,\n LabelSetId,\n LabelSetVersion,\n} from \"@ensnode/ensnode-sdk\";\n// Re-export utility functions and classes from ensnode-sdk that are needed by consumers\nexport { buildEnsRainbowClientLabelSet } from \"@ensnode/ensnode-sdk\";\n\nexport * from \"./client\";\nexport * from \"./consts\";\n","import {\n buildEnsRainbowClientLabelSet,\n type Cache,\n type EncodedLabelHash,\n type EnsRainbowClientLabelSet,\n type EnsRainbowPublicConfig,\n type EnsRainbowServerLabelSet,\n type Label,\n type LabelHash,\n LruCache,\n parseLabelHashOrEncodedLabelHash,\n} from \"@ensnode/ensnode-sdk\";\n\nimport { DEFAULT_ENSRAINBOW_URL, ErrorCode, StatusCode } from \"./consts\";\n\nexport namespace EnsRainbow {\n export type ApiClientOptions = EnsRainbowApiClientOptions;\n\n export interface ApiClient {\n count(): Promise<CountResponse>;\n\n /**\n * Get the public configuration of the ENSRainbow service\n */\n config(): Promise<ENSRainbowPublicConfig>;\n\n /**\n * Heal a labelHash to its original label.\n * Accepts a strict `LabelHash`, an `EncodedLabelHash` (bracket-enclosed), or any string\n * that can be normalized (missing `0x` prefix, uppercase hex chars, or 63-char hex).\n * Returns a `HealBadRequestError` if the input cannot be normalized to a valid labelHash.\n */\n heal(labelHash: LabelHash | EncodedLabelHash | string): Promise<HealResponse>;\n\n health(): Promise<HealthResponse>;\n\n /**\n * Get the version information of the ENSRainbow service\n *\n * @deprecated Use {@link ApiClient.config} instead. This method will be removed in a future version.\n */\n version(): Promise<VersionResponse>;\n\n getOptions(): Readonly<EnsRainbowApiClientOptions>;\n }\n\n type StatusCode = (typeof StatusCode)[keyof typeof StatusCode];\n\n type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];\n\n export interface HealthResponse {\n status: \"ok\";\n }\n\n export interface BaseHealResponse<Status extends StatusCode, Error extends ErrorCode> {\n status: Status;\n label?: Label | never;\n error?: string | never;\n errorCode?: Error | never;\n }\n\n export interface HealSuccess extends BaseHealResponse<typeof StatusCode.Success, never> {\n status: typeof StatusCode.Success;\n label: Label;\n error?: never;\n errorCode?: never;\n }\n\n export interface HealNotFoundError\n extends BaseHealResponse<typeof StatusCode.Error, typeof ErrorCode.NotFound> {\n status: typeof StatusCode.Error;\n label?: never;\n error: string;\n errorCode: typeof ErrorCode.NotFound;\n }\n\n export interface HealServerError\n extends BaseHealResponse<typeof StatusCode.Error, typeof ErrorCode.ServerError> {\n status: typeof StatusCode.Error;\n label?: never;\n error: string;\n errorCode: typeof ErrorCode.ServerError;\n }\n\n export interface HealBadRequestError\n extends BaseHealResponse<typeof StatusCode.Error, typeof ErrorCode.BadRequest> {\n status: typeof StatusCode.Error;\n label?: never;\n error: string;\n errorCode: typeof ErrorCode.BadRequest;\n }\n\n export type HealResponse =\n | HealSuccess\n | HealNotFoundError\n | HealServerError\n | HealBadRequestError;\n export type HealError = Exclude<HealResponse, HealSuccess>;\n\n /**\n * Server errors should not be cached.\n */\n export type CacheableHealResponse = Exclude<HealResponse, HealServerError>;\n\n export interface BaseCountResponse<Status extends StatusCode, Error extends ErrorCode> {\n status: Status;\n count?: number | never;\n timestamp?: string | never;\n error?: string | never;\n errorCode?: Error | never;\n }\n\n export interface CountSuccess extends BaseCountResponse<typeof StatusCode.Success, never> {\n status: typeof StatusCode.Success;\n /** The total count of labels that can be healed by the ENSRainbow instance. Always a\n * non-negative integer. */\n count: number;\n timestamp: string;\n error?: never;\n errorCode?: never;\n }\n\n export interface CountServerError\n extends BaseCountResponse<typeof StatusCode.Error, typeof ErrorCode.ServerError> {\n status: typeof StatusCode.Error;\n count?: never;\n timestamp?: never;\n error: string;\n errorCode: typeof ErrorCode.ServerError;\n }\n\n export type CountResponse = CountSuccess | CountServerError;\n\n /**\n * ENSRainbow version information.\n *\n * @deprecated Use {@link ENSRainbowPublicConfig} instead. This type will be removed in a future version.\n */\n export interface VersionInfo {\n /**\n * ENSRainbow version.\n */\n version: string;\n\n /**\n * ENSRainbow database schema version.\n */\n dbSchemaVersion: number;\n\n /**\n * The EnsRainbowServerLabelSet managed by the ENSRainbow server.\n */\n labelSet: EnsRainbowServerLabelSet;\n }\n\n /**\n * Interface for the version endpoint response\n *\n * @deprecated Use {@link ENSRainbowPublicConfig} instead. This type will be removed in a future version.\n */\n export interface VersionResponse {\n status: typeof StatusCode.Success;\n versionInfo: VersionInfo;\n }\n\n /**\n * Complete public configuration object for ENSRainbow.\n *\n * Contains all public configuration information about the ENSRainbow service instance,\n * including version, label set information, and record counts.\n */\n export type ENSRainbowPublicConfig = EnsRainbowPublicConfig;\n}\n\nexport interface EnsRainbowApiClientOptions {\n /**\n * The maximum number of `HealResponse` values to cache.\n * Must be a non-negative integer.\n * Setting to 0 will disable caching.\n */\n cacheCapacity: number;\n\n /**\n * The URL of an ENSRainbow API endpoint.\n */\n endpointUrl: URL;\n\n /**\n * Optional label set preferences that the ENSRainbow server at endpointUrl is expected to\n * support. If provided, enables deterministic heal results across time, such that only\n * labels from label sets with versions less than or equal to this value will be returned.\n * Therefore, even if the ENSRainbow server later ingests label sets with greater versions\n * than this value, the results returned across time can be deterministic. If\n * provided, heal operations with this EnsRainbowApiClient will validate the ENSRainbow\n * server manages a compatible label set. If not provided no specific labelSetId validation\n * will be performed during heal operations.\n * If `labelSetId` is provided without `labelSetVersion`, the server will use the latest\n * available version.\n * If `labelSetVersion` is defined, only labels from sets less than or equal to this value\n * will be returned.\n * When `labelSetVersion` is defined, `labelSetId` must also be defined.\n */\n labelSet?: EnsRainbowClientLabelSet;\n}\n\n/**\n * ENSRainbow API client\n *\n * @example\n * ```typescript\n * // default options\n * const client = new EnsRainbowApiClient();\n * // custom options\n * const client = new EnsRainbowApiClient({\n * endpointUrl: new URL(\"https://api.ensrainbow.io\"),\n * });\n * ```\n */\nexport class EnsRainbowApiClient implements EnsRainbow.ApiClient {\n private readonly options: EnsRainbowApiClientOptions;\n private readonly cache: Cache<LabelHash, EnsRainbow.CacheableHealResponse>;\n private readonly labelSetSearchParams: URLSearchParams;\n\n public static readonly DEFAULT_CACHE_CAPACITY = 1000;\n\n /**\n * Create default client options.\n *\n * @returns default options\n */\n static defaultOptions(): EnsRainbow.ApiClientOptions {\n return {\n endpointUrl: new URL(DEFAULT_ENSRAINBOW_URL),\n cacheCapacity: EnsRainbowApiClient.DEFAULT_CACHE_CAPACITY,\n labelSet: buildEnsRainbowClientLabelSet(),\n };\n }\n\n constructor(options: Partial<EnsRainbow.ApiClientOptions> = {}) {\n const { labelSet: optionsLabelSet, ...rest } = options;\n const defaultOptions = EnsRainbowApiClient.defaultOptions();\n\n const copiedLabelSet = buildEnsRainbowClientLabelSet(\n optionsLabelSet?.labelSetId,\n optionsLabelSet?.labelSetVersion,\n );\n\n this.options = {\n ...defaultOptions,\n ...rest,\n labelSet: copiedLabelSet,\n };\n\n this.cache = new LruCache<LabelHash, EnsRainbow.CacheableHealResponse>(\n this.options.cacheCapacity,\n );\n\n // Pre-compute query parameters for label set options\n this.labelSetSearchParams = new URLSearchParams();\n if (this.options.labelSet?.labelSetId !== undefined) {\n this.labelSetSearchParams.append(\"label_set_id\", this.options.labelSet.labelSetId);\n }\n if (this.options.labelSet?.labelSetVersion !== undefined) {\n this.labelSetSearchParams.append(\n \"label_set_version\",\n this.options.labelSet.labelSetVersion.toString(),\n );\n }\n }\n\n /**\n * Attempt to [heal](https://ensnode.io/ensrainbow/concepts/glossary#heal) a labelHash to its original label.\n *\n * Note on returned labels: ENSRainbow returns labels exactly as they are\n * represented in source rainbow table data. This means:\n *\n * - Labels may or may not be ENS-normalized\n * - Labels can contain any valid string, including dots, null bytes, or be empty\n * - Clients should handle all possible string values appropriately\n *\n * @param labelHash - A labelHash to heal, either as a strict `LabelHash`, an `EncodedLabelHash`\n * (bracket-enclosed), or any string that can be normalized (missing `0x` prefix, uppercase hex\n * chars, or 63-char hex are all accepted and normalized automatically).\n * @returns a `HealResponse` indicating the result of the request and the healed label if successful.\n * Returns a `HealBadRequestError` if the input cannot be normalized to a valid labelHash.\n * @throws if the request fails due to network failures, DNS lookup failures, request timeouts,\n * CORS violations, or Invalid URLs\n * @example\n * ```typescript\n * const response = await client.heal(\n * \"0xaf2caa1c2ca1d027f1ac823b529d0a67cd144264b2789fa2ea4d63a67c7103cc\"\n * );\n *\n * console.log(response);\n *\n * // Output:\n * // {\n * // status: \"success\",\n * // label: \"vitalik\"\n * // }\n *\n * const notFoundResponse = await client.heal(\n * \"0xf64dc17ae2e2b9b16dbcb8cb05f35a2e6080a5ff1dc53ac0bc48f0e79111f264\"\n * );\n *\n * console.log(notFoundResponse);\n *\n * // Output:\n * // {\n * // status: \"error\",\n * // error: \"Label not found\",\n * // errorCode: 404\n * // }\n * ```\n */\n async heal(labelHash: LabelHash | EncodedLabelHash | string): Promise<EnsRainbow.HealResponse> {\n let normalizedLabelHash: LabelHash;\n\n try {\n normalizedLabelHash = parseLabelHashOrEncodedLabelHash(labelHash);\n } catch (error) {\n return {\n status: StatusCode.Error,\n error: error instanceof Error ? error.message : String(error),\n errorCode: ErrorCode.BadRequest,\n } as EnsRainbow.HealBadRequestError;\n }\n\n const cachedResult = this.cache.get(normalizedLabelHash);\n if (cachedResult) return cachedResult;\n\n const url = new URL(`/v1/heal/${normalizedLabelHash}`, this.options.endpointUrl);\n\n // Apply pre-computed label set query parameters\n this.labelSetSearchParams.forEach((value, key) => {\n url.searchParams.append(key, value);\n });\n\n const response = await fetch(url);\n const healResponse = (await response.json()) as EnsRainbow.HealResponse;\n\n if (isCacheableHealResponse(healResponse)) {\n this.cache.set(normalizedLabelHash, healResponse);\n }\n\n return healResponse;\n }\n\n /**\n * Get Count of Healable Labels\n *\n * @returns a `CountResponse` indicating the result and the timestamp of the request and the\n * number of healable labels if successful\n * @throws if the request fails due to network failures, DNS lookup failures, request timeouts,\n * CORS violations, or Invalid URLs\n * @example\n *\n * const response = await client.count();\n *\n * console.log(response);\n *\n * // {\n * // \"status\": \"success\",\n * // \"count\": 133856894,\n * // \"timestamp\": \"2024-01-30T11:18:56Z\"\n * // }\n *\n */\n async count(): Promise<EnsRainbow.CountResponse> {\n const response = await fetch(new URL(\"/v1/labels/count\", this.options.endpointUrl));\n\n return response.json() as Promise<EnsRainbow.CountResponse>;\n }\n\n /**\n *\n * Simple verification that the service is running, either in your local setup or for the\n * provided hosted instance.\n * @returns a status of ENS Rainbow service\n * @example\n *\n * const response = await client.health();\n *\n * console.log(response);\n *\n * // {\n * // \"status\": \"ok\",\n * // }\n */\n async health(): Promise<EnsRainbow.HealthResponse> {\n const response = await fetch(new URL(\"/health\", this.options.endpointUrl));\n\n return response.json() as Promise<EnsRainbow.HealthResponse>;\n }\n\n /**\n * Get the public configuration of the ENSRainbow service.\n */\n async config(): Promise<EnsRainbow.ENSRainbowPublicConfig> {\n const response = await fetch(new URL(\"/v1/config\", this.options.endpointUrl));\n\n if (!response.ok) {\n throw new Error(`Failed to fetch ENSRainbow config: ${response.statusText}`);\n }\n\n return response.json() as Promise<EnsRainbow.ENSRainbowPublicConfig>;\n }\n\n /**\n * Get the version information of the ENSRainbow service\n *\n * @deprecated Use {@link EnsRainbowApiClient.config} instead. This method will be removed in a future version.\n * @returns the version information of the ENSRainbow service\n * @throws if the request fails due to network failures, DNS lookup failures, request\n * timeouts, CORS violations, or invalid URLs\n * @example\n * ```typescript\n * const response = await client.version();\n *\n * console.log(response);\n *\n * // {\n * // \"status\": \"success\",\n * // \"versionInfo\": {\n * // \"version\": \"0.1.0\",\n * // \"dbSchemaVersion\": 2,\n * // \"labelSet\": {\n * // \"labelSetId\": \"subgraph\",\n * // \"labelSetVersion\": 0\n * // }\n * // }\n * // }\n * ```\n */\n async version(): Promise<EnsRainbow.VersionResponse> {\n const response = await fetch(new URL(\"/v1/version\", this.options.endpointUrl));\n\n return response.json() as Promise<EnsRainbow.VersionResponse>;\n }\n\n /**\n * Get a copy of the current client options.\n *\n * @returns a copy of the current client options.\n */\n getOptions(): Readonly<EnsRainbowApiClientOptions> {\n // build a deep copy to prevent modification\n const deepCopy = {\n cacheCapacity: this.options.cacheCapacity,\n endpointUrl: new URL(this.options.endpointUrl.href),\n labelSet: this.options.labelSet ? { ...this.options.labelSet } : undefined,\n } satisfies EnsRainbowApiClientOptions;\n\n return Object.freeze(deepCopy);\n }\n}\n\n/**\n * Determine if a heal response is an error.\n *\n * @param response the heal response to check\n * @returns true if the response is an error, false otherwise\n */\nexport const isHealError = (\n response: EnsRainbow.HealResponse,\n): response is EnsRainbow.HealError => {\n return response.status === StatusCode.Error;\n};\n\n/**\n * Determine if a heal response is cacheable.\n *\n * Server errors at not cachable and should be retried.\n *\n * @param response the heal response to check\n * @returns true if the response is cacheable, false otherwise\n */\nexport const isCacheableHealResponse = (\n response: EnsRainbow.HealResponse,\n): response is EnsRainbow.CacheableHealResponse => {\n return response.status === StatusCode.Success || response.errorCode !== ErrorCode.ServerError;\n};\n","export const DEFAULT_ENSRAINBOW_URL = \"https://api.ensrainbow.io\" as const;\n\nexport const StatusCode = {\n Success: \"success\",\n Error: \"error\",\n} as const;\n\nexport const ErrorCode = {\n BadRequest: 400,\n NotFound: 404,\n ServerError: 500,\n} as const;\n"],"mappings":";AAQA,SAAS,iCAAAA,sCAAqC;;;ACR9C;AAAA,EACE;AAAA,EAQA;AAAA,EACA;AAAA,OACK;;;ACXA,IAAM,yBAAyB;AAE/B,IAAM,aAAa;AAAA,EACxB,SAAS;AAAA,EACT,OAAO;AACT;AAEO,IAAM,YAAY;AAAA,EACvB,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,aAAa;AACf;;;AD+MO,IAAM,sBAAN,MAAM,qBAAoD;AAAA,EAC9C;AAAA,EACA;AAAA,EACA;AAAA,EAEjB,OAAuB,yBAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOhD,OAAO,iB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AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA4BA,MAAM,UAA+C;AACnD,UAAM,WAAW,MAAM,MAAM,IAAI,IAAI,eAAe,KAAK,QAAQ,WAAW,CAAC;AAE7E,WAAO,SAAS,KAAK;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,aAAmD;AAEjD,UAAM,WAAW;AAAA,MACf,eAAe,KAAK,QAAQ;AAAA,MAC5B,aAAa,IAAI,IAAI,KAAK,QAAQ,YAAY,IAAI;AAAA,MAClD,UAAU,KAAK,QAAQ,WAAW,EAAE,GAAG,KAAK,QAAQ,SAAS,IAAI;AAAA,IACnE;AAEA,WAAO,OAAO,OAAO,QAAQ;AAAA,EAC/B;AACF;AAQO,IAAM,cAAc,CACzB,aACqC;AACrC,SAAO,SAAS,WAAW,WAAW;AACxC;AAUO,IAAM,0BAA0B,CACrC,aACiD;AACjD,SAAO,SAAS,WAAW,WAAW,WAAW,SAAS,cAAc,UAAU;AACpF;","names":["buildEnsRainbowClientLabelSet"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ensnode/ensrainbow-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "ENSRainbow SDK for interacting with the ENSRainbow API.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -42,13 +42,13 @@
|
|
|
42
42
|
"tsup": "^8.3.6",
|
|
43
43
|
"typescript": "^5.7.3",
|
|
44
44
|
"vitest": "^4.0.2",
|
|
45
|
-
"@ensnode/shared-configs": "1.
|
|
46
|
-
"@ensnode/ensnode-sdk": "1.
|
|
45
|
+
"@ensnode/shared-configs": "1.7.0",
|
|
46
|
+
"@ensnode/ensnode-sdk": "1.7.0"
|
|
47
47
|
},
|
|
48
48
|
"scripts": {
|
|
49
49
|
"prepublish": "tsup",
|
|
50
50
|
"test": "vitest",
|
|
51
|
-
"typecheck": "
|
|
51
|
+
"typecheck": "tsgo --noEmit",
|
|
52
52
|
"lint": "biome check --write .",
|
|
53
53
|
"lint:ci": "biome ci"
|
|
54
54
|
},
|