@ensnode/ensdb-sdk 1.10.1 → 1.11.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.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { EnsIndexerPublicConfig, EnsDbPublicConfig, CrossChainIndexingStatusSnapshot, Unvalidated } from '@ensnode/ensnode-sdk';
1
+ import { EnsDbPublicConfig, IndexingMetadataContext, IndexingMetadataContextInitialized, Unvalidated } from '@ensnode/ensnode-sdk';
2
+ export { IndexingMetadataContext, IndexingMetadataContextInitialized, IndexingMetadataContextStatusCodes, IndexingMetadataContextUninitialized } from '@ensnode/ensnode-sdk';
2
3
  import { NodePgDatabase } from 'drizzle-orm/node-postgres';
3
- import { a as abstractEnsIndexerSchema } from './index-DN0SGSyd.js';
4
+ import { a as abstractEnsIndexerSchema } from './index-C0lByZGy.js';
4
5
  import { e as ensNodeSchema } from './index-BHoa233Z.js';
5
6
  import 'drizzle-orm/pg-core';
6
7
  import 'drizzle-orm';
@@ -152,27 +153,26 @@ declare class EnsDbReader<ConcreteEnsIndexerSchema extends AbstractEnsIndexerSch
152
153
  */
153
154
  get ensNodeSchema(): EnsNodeSchema;
154
155
  /**
155
- * Get ENSDb Version
156
- *
157
- * @returns the existing record, or `undefined`.
156
+ * Check if the ENSDb instance is healthy by running a simple query
157
+ * against it.
158
158
  */
159
- getEnsDbVersion(): Promise<string | undefined>;
159
+ isHealthy(): Promise<boolean>;
160
160
  /**
161
- * Get ENSIndexer Public Config
162
- *
163
- * @returns the existing record, or `undefined`.
161
+ * Check if the ENSDb instance is ready by verifying that
162
+ * the {@link IndexingMetadataContext} has been initialized for
163
+ * the ENSIndexer Schema used by this ENSDbReader instance.
164
164
  */
165
- getEnsIndexerPublicConfig(): Promise<EnsIndexerPublicConfig | undefined>;
165
+ isReady(): Promise<boolean>;
166
166
  /**
167
167
  * Build ENSDb Public Config
168
168
  */
169
169
  buildEnsDbPublicConfig(): Promise<EnsDbPublicConfig>;
170
170
  /**
171
- * Get Indexing Status Snapshot
171
+ * Get Indexing Metadata Context
172
172
  *
173
- * @returns the existing record, or `undefined`.
173
+ * @returns the initialized record, or a default uninitialized one if no record exists in ENSDb.
174
174
  */
175
- getIndexingStatusSnapshot(): Promise<CrossChainIndexingStatusSnapshot | undefined>;
175
+ getIndexingMetadataContext(): Promise<IndexingMetadataContext>;
176
176
  /**
177
177
  * Get ENSNode Metadata record
178
178
  *
@@ -205,32 +205,31 @@ declare class EnsDbReader<ConcreteEnsIndexerSchema extends AbstractEnsIndexerSch
205
205
  * - updating ENSNode Metadata records in ENSDb for the given ENSIndexer instance.
206
206
  */
207
207
  declare class EnsDbWriter extends EnsDbReader {
208
+ /**
209
+ * Stable arbitrary lock ID for ENSNode Schema migrations to
210
+ * prevent concurrent migration execution across multiple ENSIndexer instances.
211
+ */
212
+ private static readonly MIGRATION_LOCK_ID;
208
213
  /**
209
214
  * Execute pending database migrations for ENSNode Schema in ENSDb.
210
215
  *
216
+ * This function is:
217
+ * - idempotent and can be safely executed multiple times,
218
+ * - safe to execute concurrently across multiple ENSIndexer instances,
219
+ * as it uses a stable arbitrary advisory lock to prevent concurrent
220
+ * execution of migrations.
221
+ *
211
222
  * @param migrationsDirPath - The file path to the directory containing
212
223
  * database migration files for ENSNode Schema.
213
224
  * @throws error when migration execution fails.
214
225
  */
215
226
  migrateEnsNodeSchema(migrationsDirPath: string): Promise<void>;
216
227
  /**
217
- * Upsert ENSDb Version
218
- *
219
- * @throws when upsert operation failed.
220
- */
221
- upsertEnsDbVersion(ensDbVersion: string): Promise<void>;
222
- /**
223
- * Upsert ENSIndexer Public Config
228
+ * Upsert Indexing Metadata Context Initialized
224
229
  *
225
230
  * @throws when upsert operation failed.
226
231
  */
227
- upsertEnsIndexerPublicConfig(ensIndexerPublicConfig: EnsIndexerPublicConfig): Promise<void>;
228
- /**
229
- * Upsert Indexing Status Snapshot
230
- *
231
- * @throws when upsert operation failed.
232
- */
233
- upsertIndexingStatusSnapshot(indexingStatus: CrossChainIndexingStatusSnapshot): Promise<void>;
232
+ upsertIndexingMetadataContext(indexingMetadataContext: IndexingMetadataContextInitialized): Promise<void>;
234
233
  /**
235
234
  * Upsert ENSNode metadata
236
235
  *
@@ -243,29 +242,28 @@ declare class EnsDbWriter extends EnsDbReader {
243
242
  * Keys used to distinguish records in `ensnode_metadata` table in the ENSDb.
244
243
  */
245
244
  declare const EnsNodeMetadataKeys: {
246
- readonly EnsDbVersion: "ensdb_version";
247
- readonly EnsIndexerPublicConfig: "ensindexer_public_config";
248
- readonly EnsIndexerIndexingStatus: "ensindexer_indexing_status";
245
+ readonly IndexingMetadataContext: "indexing_metadata_context";
249
246
  };
250
247
  type EnsNodeMetadataKey = (typeof EnsNodeMetadataKeys)[keyof typeof EnsNodeMetadataKeys];
251
- interface EnsNodeMetadataEnsDbVersion {
252
- key: typeof EnsNodeMetadataKeys.EnsDbVersion;
253
- value: string;
254
- }
255
- interface EnsNodeMetadataEnsIndexerPublicConfig {
256
- key: typeof EnsNodeMetadataKeys.EnsIndexerPublicConfig;
257
- value: EnsIndexerPublicConfig;
258
- }
259
- interface EnsNodeMetadataEnsIndexerIndexingStatus {
260
- key: typeof EnsNodeMetadataKeys.EnsIndexerIndexingStatus;
261
- value: CrossChainIndexingStatusSnapshot;
248
+ /**
249
+ * ENSNode Metadata record for Indexing Metadata Context
250
+ *
251
+ * This record is used to store the Indexing Metadata Context in
252
+ * ENSNode Metadata table for each ENSIndexer instance.
253
+ */
254
+ interface EnsNodeMetadataIndexingMetadataContext {
255
+ key: typeof EnsNodeMetadataKeys.IndexingMetadataContext;
256
+ value: IndexingMetadataContextInitialized;
262
257
  }
263
258
  /**
264
259
  * ENSNode Metadata
265
260
  *
266
- * Union type gathering all variants of ENSNode Metadata.
261
+ * Type alias for ENSNode Metadata records,
262
+ * currently only includes the record for Indexing Metadata Context,
263
+ * but can be extended in the future to include more types of
264
+ * ENSNode Metadata records as needed.
267
265
  */
268
- type EnsNodeMetadata = EnsNodeMetadataEnsDbVersion | EnsNodeMetadataEnsIndexerPublicConfig | EnsNodeMetadataEnsIndexerIndexingStatus;
266
+ type EnsNodeMetadata = EnsNodeMetadataIndexingMetadataContext;
269
267
 
270
268
  /**
271
269
  * Validate ENSDb config
@@ -276,4 +274,4 @@ type EnsNodeMetadata = EnsNodeMetadataEnsDbVersion | EnsNodeMetadataEnsIndexerPu
276
274
  */
277
275
  declare function validateEnsDbConfig(unvalidatedConfig: Unvalidated<EnsDbConfig>): EnsDbConfig;
278
276
 
279
- export { ENSDB_CONNECTION_OPTIONS, ENSDB_SCHEMA_CHECKSUM, type EnsDbConfig, type EnsDbDrizzleClient, EnsDbReader, EnsDbWriter, type EnsNodeMetadata, type EnsNodeMetadataEnsDbVersion, type EnsNodeMetadataEnsIndexerIndexingStatus, type EnsNodeMetadataEnsIndexerPublicConfig, type EnsNodeMetadataKey, EnsNodeMetadataKeys, validateEnsDbConfig };
277
+ export { ENSDB_CONNECTION_OPTIONS, ENSDB_SCHEMA_CHECKSUM, type EnsDbConfig, type EnsDbDrizzleClient, EnsDbReader, EnsDbWriter, type EnsNodeMetadata, type EnsNodeMetadataIndexingMetadataContext, type EnsNodeMetadataKey, EnsNodeMetadataKeys, validateEnsDbConfig };