@ensnode/ensdb-sdk 1.15.2 → 1.17.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/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- import { EnsDbPublicConfig, IndexingMetadataContext, IndexingMetadataContextInitialized, Unvalidated } from '@ensnode/ensnode-sdk';
1
+ import { IndexingMetadataContextInitialized, SerializedIndexingMetadataContextInitialized, EnsDbPublicConfig, IndexingMetadataContext, Unvalidated } from '@ensnode/ensnode-sdk';
2
2
  export { IndexingMetadataContext, IndexingMetadataContextInitialized, IndexingMetadataContextStatusCodes, IndexingMetadataContextUninitialized } from '@ensnode/ensnode-sdk';
3
3
  import { NodePgDatabase } from 'drizzle-orm/node-postgres';
4
- import { a as abstractEnsIndexerSchema } from './index-DH9e7wPl.js';
4
+ import { a as abstractEnsIndexerSchema } from './index-BLniLyqz.js';
5
5
  import { e as ensNodeSchema } from './index-BHoa233Z.js';
6
- import 'ponder';
7
6
  import 'drizzle-orm';
8
7
  import 'drizzle-orm/pg-core';
8
+ import 'ponder';
9
9
  import 'enssdk';
10
10
 
11
11
  /**
@@ -85,6 +85,42 @@ interface EnsDbConfig {
85
85
  */
86
86
  declare const ENSDB_SCHEMA_CHECKSUM: string;
87
87
 
88
+ /**
89
+ * Keys used to distinguish records in `ensnode_metadata` table in the ENSDb.
90
+ */
91
+ declare const EnsNodeMetadataKeys: {
92
+ readonly IndexingMetadataContext: "indexing_metadata_context";
93
+ };
94
+ type EnsNodeMetadataKey = (typeof EnsNodeMetadataKeys)[keyof typeof EnsNodeMetadataKeys];
95
+ /**
96
+ * ENSNode Metadata record for Indexing Metadata Context
97
+ *
98
+ * This record is used to store the Indexing Metadata Context in
99
+ * ENSNode Metadata table for each ENSIndexer instance.
100
+ */
101
+ interface EnsNodeMetadataIndexingMetadataContext {
102
+ key: typeof EnsNodeMetadataKeys.IndexingMetadataContext;
103
+ value: IndexingMetadataContextInitialized;
104
+ }
105
+ /**
106
+ * ENSNode Metadata
107
+ *
108
+ * Type alias for ENSNode Metadata records,
109
+ * currently only includes the record for Indexing Metadata Context,
110
+ * but can be extended in the future to include more types of
111
+ * ENSNode Metadata records as needed.
112
+ */
113
+ type EnsNodeMetadata = EnsNodeMetadataIndexingMetadataContext;
114
+
115
+ interface SerializedEnsNodeMetadataIndexingMetadataContext {
116
+ key: typeof EnsNodeMetadataKeys.IndexingMetadataContext;
117
+ value: SerializedIndexingMetadataContextInitialized;
118
+ }
119
+ /**
120
+ * Serialized representation of {@link EnsNodeMetadata}
121
+ */
122
+ type SerializedEnsNodeMetadata = SerializedEnsNodeMetadataIndexingMetadataContext;
123
+
88
124
  /**
89
125
  * ENSDb Reader
90
126
  *
@@ -167,6 +203,10 @@ declare class EnsDbReader<ConcreteEnsIndexerSchema extends AbstractEnsIndexerSch
167
203
  * Build ENSDb Public Config
168
204
  */
169
205
  buildEnsDbPublicConfig(): Promise<EnsDbPublicConfig>;
206
+ /**
207
+ * Check whether a Postgres schema with the given name exists in the ENSDb instance.
208
+ */
209
+ schemaExists(schemaName: string): Promise<boolean>;
170
210
  /**
171
211
  * Get Indexing Metadata Context
172
212
  *
@@ -180,12 +220,13 @@ declare class EnsDbReader<ConcreteEnsIndexerSchema extends AbstractEnsIndexerSch
180
220
  /**
181
221
  * Get ENSNode Metadata record
182
222
  *
183
- * @returns selected record in ENSDb.
223
+ * @returns the full `{ key, value }` record for the given key under this instance's
224
+ * ENSIndexer Schema, or undefined if no such record exists.
184
225
  * @throws when more than one matching metadata record is found
185
226
  * (should be impossible given the composite PK constraint on
186
227
  * 'ensIndexerSchemaName' and 'key')
187
228
  */
188
- private getEnsNodeMetadata;
229
+ getEnsNodeMetadata<EnsNodeMetadataType extends SerializedEnsNodeMetadata>(metadata: Pick<EnsNodeMetadataType, "key">): Promise<EnsNodeMetadataType | undefined>;
189
230
  /**
190
231
  * Get PostgreSQL version for the server hosting the ENSDb instance.
191
232
  *
@@ -228,6 +269,17 @@ declare class EnsDbWriter extends EnsDbReader {
228
269
  * @throws error when migration execution fails.
229
270
  */
230
271
  migrateEnsNodeSchema(migrationsDirPath: string): Promise<void>;
272
+ /**
273
+ * Drop a Postgres schema (and everything in it) from the ENSDb instance, if it exists.
274
+ */
275
+ dropSchema(schemaName: string): Promise<void>;
276
+ /**
277
+ * Rename a Postgres schema within the ENSDb instance.
278
+ *
279
+ * The Postgres schema name does not affect Ponder's build_id, so renaming a restored ENSIndexer
280
+ * schema is safe for resume.
281
+ */
282
+ renameSchema(fromSchemaName: string, toSchemaName: string): Promise<void>;
231
283
  /**
232
284
  * Upsert Indexing Metadata Context Initialized
233
285
  *
@@ -235,40 +287,16 @@ declare class EnsDbWriter extends EnsDbReader {
235
287
  */
236
288
  upsertIndexingMetadataContext(indexingMetadataContext: IndexingMetadataContextInitialized): Promise<void>;
237
289
  /**
238
- * Upsert ENSNode metadata
290
+ * Write (upsert) an ENSNode metadata record under this instance's ENSIndexer Schema.
239
291
  *
240
- * @throws when upsert operation failed.
292
+ * Re-keys the record to this writer's {@link ensIndexerSchemaName}, so metadata read from one
293
+ * ENSIndexer Schema can be written under a different (e.g. renamed) one.
294
+ *
295
+ * @throws when the upsert operation failed.
241
296
  */
242
- private upsertEnsNodeMetadata;
297
+ writeEnsNodeMetadata(metadata: SerializedEnsNodeMetadata): Promise<void>;
243
298
  }
244
299
 
245
- /**
246
- * Keys used to distinguish records in `ensnode_metadata` table in the ENSDb.
247
- */
248
- declare const EnsNodeMetadataKeys: {
249
- readonly IndexingMetadataContext: "indexing_metadata_context";
250
- };
251
- type EnsNodeMetadataKey = (typeof EnsNodeMetadataKeys)[keyof typeof EnsNodeMetadataKeys];
252
- /**
253
- * ENSNode Metadata record for Indexing Metadata Context
254
- *
255
- * This record is used to store the Indexing Metadata Context in
256
- * ENSNode Metadata table for each ENSIndexer instance.
257
- */
258
- interface EnsNodeMetadataIndexingMetadataContext {
259
- key: typeof EnsNodeMetadataKeys.IndexingMetadataContext;
260
- value: IndexingMetadataContextInitialized;
261
- }
262
- /**
263
- * ENSNode Metadata
264
- *
265
- * Type alias for ENSNode Metadata records,
266
- * currently only includes the record for Indexing Metadata Context,
267
- * but can be extended in the future to include more types of
268
- * ENSNode Metadata records as needed.
269
- */
270
- type EnsNodeMetadata = EnsNodeMetadataIndexingMetadataContext;
271
-
272
300
  /**
273
301
  * Validate ENSDb config
274
302
  *
@@ -278,4 +306,4 @@ type EnsNodeMetadata = EnsNodeMetadataIndexingMetadataContext;
278
306
  */
279
307
  declare function validateEnsDbConfig(unvalidatedConfig: Unvalidated<EnsDbConfig>): EnsDbConfig;
280
308
 
281
- export { ENSDB_CONNECTION_OPTIONS, ENSDB_SCHEMA_CHECKSUM, type EnsDbConfig, type EnsDbDrizzleClient, EnsDbReader, EnsDbWriter, type EnsNodeMetadata, type EnsNodeMetadataIndexingMetadataContext, type EnsNodeMetadataKey, EnsNodeMetadataKeys, validateEnsDbConfig };
309
+ export { ENSDB_CONNECTION_OPTIONS, ENSDB_SCHEMA_CHECKSUM, type EnsDbConfig, type EnsDbDrizzleClient, EnsDbReader, EnsDbWriter, type EnsNodeMetadata, type EnsNodeMetadataIndexingMetadataContext, type EnsNodeMetadataKey, EnsNodeMetadataKeys, type SerializedEnsNodeMetadata, type SerializedEnsNodeMetadataIndexingMetadataContext, validateEnsDbConfig };