@ensnode/ponder-sdk 1.9.0 → 1.10.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.cjs +67 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +148 -1
- package/dist/index.d.ts +148 -1
- package/dist/index.js +67 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -209,6 +209,127 @@ type ChainId = z.infer<typeof schemaChainId>;
|
|
|
209
209
|
*/
|
|
210
210
|
type ChainIdString = string;
|
|
211
211
|
|
|
212
|
+
/**
|
|
213
|
+
* Represents a single log entry for the Ponder app logger.
|
|
214
|
+
*
|
|
215
|
+
* It is a loose object that:
|
|
216
|
+
* - must contain a `msg` property of type string, and
|
|
217
|
+
* - can optionally include an `error` property of type Error, and
|
|
218
|
+
* - can optionally include any additional properties relevant to
|
|
219
|
+
* the log message. The additional properties can be used to provide more
|
|
220
|
+
* context about the log message, and will be included in the log output.
|
|
221
|
+
*/
|
|
222
|
+
type PonderAppLog = {
|
|
223
|
+
/**
|
|
224
|
+
* Log message
|
|
225
|
+
*/
|
|
226
|
+
msg: string;
|
|
227
|
+
/**
|
|
228
|
+
* Optional error object to log.
|
|
229
|
+
*
|
|
230
|
+
* If provided, the logger will log the error's stack trace and message.
|
|
231
|
+
*/
|
|
232
|
+
error?: unknown;
|
|
233
|
+
/**
|
|
234
|
+
* Optional additional properties.
|
|
235
|
+
*
|
|
236
|
+
* If provided, they will be included in the log output.
|
|
237
|
+
*/
|
|
238
|
+
[key: string]: unknown;
|
|
239
|
+
};
|
|
240
|
+
/**
|
|
241
|
+
* Ponder app logger
|
|
242
|
+
*
|
|
243
|
+
* Represents the logger provided by the Ponder runtime to a local Ponder app.
|
|
244
|
+
* @see https://github.com/ponder-sh/ponder/blob/6fcc15d4234e43862cb6e21c05f3c57f4c2f7464/packages/core/src/internal/logger.ts#L8-L31
|
|
245
|
+
*/
|
|
246
|
+
interface PonderAppLogger {
|
|
247
|
+
/**
|
|
248
|
+
* Logs a message at the "error" level.
|
|
249
|
+
*
|
|
250
|
+
* @param options - The log message and additional properties to log.
|
|
251
|
+
*
|
|
252
|
+
* @example
|
|
253
|
+
* ```ts
|
|
254
|
+
* logger.error({
|
|
255
|
+
* msg: "Incorrect omnichain status",
|
|
256
|
+
* error: new Error("The omnichain status must be either 'omnichain-backfill' or 'omnichain-following'"),
|
|
257
|
+
* expected: "omnichain-backfill or omnichain-following",
|
|
258
|
+
* actual: "omnichain-unstarted"
|
|
259
|
+
* });
|
|
260
|
+
*
|
|
261
|
+
* logger.error({
|
|
262
|
+
* msg: "Incorrect omnichain status",
|
|
263
|
+
* error: new Error("The omnichain status must be either 'omnichain-backfill' or 'omnichain-following'"),
|
|
264
|
+
* });
|
|
265
|
+
*
|
|
266
|
+
* logger.error({
|
|
267
|
+
* msg: "The omnichain status must be either 'omnichain-backfill' or 'omnichain-following'"
|
|
268
|
+
* });
|
|
269
|
+
* ```
|
|
270
|
+
*/
|
|
271
|
+
error<T extends PonderAppLog>(options: T): void;
|
|
272
|
+
/**
|
|
273
|
+
* Logs a message at the "warn" level.
|
|
274
|
+
*
|
|
275
|
+
* @param options - The log message and additional properties to log.
|
|
276
|
+
*
|
|
277
|
+
* @example
|
|
278
|
+
* ```ts
|
|
279
|
+
* logger.warn({
|
|
280
|
+
* msg: "Both the '${PluginName.Subgraph}' and '${PluginName.ENSv2}' plugins are enabled.",
|
|
281
|
+
* effects: "This results in the availability of both the legacy Subgraph-Compatible GraphQL API (/subgraph) _and_ ENSNode's Omnigraph API (/api/omnigraph), and comes with an associated increase in indexing time. If your intent is to have both APIs available in parallel, excellent, otherwise you may benefit from only enabling the plugin for the API you plan to use."
|
|
282
|
+
* });
|
|
283
|
+
*
|
|
284
|
+
* logger.warn({
|
|
285
|
+
* msg: "Both the '${PluginName.Subgraph}' and '${PluginName.ENSv2}' plugins are enabled."
|
|
286
|
+
* });
|
|
287
|
+
* ```
|
|
288
|
+
*/
|
|
289
|
+
warn<T extends PonderAppLog>(options: T): void;
|
|
290
|
+
/**
|
|
291
|
+
* Logs a message at the "info" level.
|
|
292
|
+
* @param options
|
|
293
|
+
*
|
|
294
|
+
* @example
|
|
295
|
+
* ```ts
|
|
296
|
+
* logger.info({
|
|
297
|
+
* msg: "An informational message",
|
|
298
|
+
* details: "Here are some details about the info"
|
|
299
|
+
* });
|
|
300
|
+
* ```
|
|
301
|
+
*/
|
|
302
|
+
info<T extends PonderAppLog>(options: T): void;
|
|
303
|
+
/**
|
|
304
|
+
* Logs a message at the "debug" level.
|
|
305
|
+
* @param options
|
|
306
|
+
*
|
|
307
|
+
* @example
|
|
308
|
+
* ```ts
|
|
309
|
+
* logger.debug({
|
|
310
|
+
* msg: "A debug message",
|
|
311
|
+
* arg1: "Here is some debug information about arg1",
|
|
312
|
+
* arg2: "Here is some debug information about arg2"
|
|
313
|
+
* });
|
|
314
|
+
* ```
|
|
315
|
+
*/
|
|
316
|
+
debug<T extends PonderAppLog>(options: T): void;
|
|
317
|
+
/**
|
|
318
|
+
* Logs a message at the "trace" level.
|
|
319
|
+
* @param options
|
|
320
|
+
*
|
|
321
|
+
* @example
|
|
322
|
+
* ```ts
|
|
323
|
+
* logger.trace({
|
|
324
|
+
* msg: "A trace message",
|
|
325
|
+
* detailA: "Here are some details about the trace message",
|
|
326
|
+
* detailB: "Here are some more details about the trace message"
|
|
327
|
+
* });
|
|
328
|
+
* ```
|
|
329
|
+
*/
|
|
330
|
+
trace<T extends PonderAppLog>(options: T): void;
|
|
331
|
+
}
|
|
332
|
+
|
|
212
333
|
/**
|
|
213
334
|
* Ponder app commands
|
|
214
335
|
*
|
|
@@ -233,6 +354,10 @@ interface PonderAppContext {
|
|
|
233
354
|
* URL of the local Ponder app.
|
|
234
355
|
*/
|
|
235
356
|
localPonderAppUrl: URL;
|
|
357
|
+
/**
|
|
358
|
+
* Logger provided by the Ponder runtime
|
|
359
|
+
*/
|
|
360
|
+
logger: PonderAppLogger;
|
|
236
361
|
}
|
|
237
362
|
|
|
238
363
|
/**
|
|
@@ -519,6 +644,28 @@ declare const schemaRawPonderAppContext: z.ZodObject<{
|
|
|
519
644
|
}>;
|
|
520
645
|
port: z.ZodNumber;
|
|
521
646
|
}, z.core.$strip>;
|
|
647
|
+
logger: z.ZodObject<{
|
|
648
|
+
error: z.ZodFunction<z.ZodTuple<readonly [z.ZodObject<{
|
|
649
|
+
msg: z.ZodString;
|
|
650
|
+
error: z.ZodOptional<z.ZodUnknown>;
|
|
651
|
+
}, z.core.$loose>], null>, z.ZodVoid>;
|
|
652
|
+
warn: z.ZodFunction<z.ZodTuple<readonly [z.ZodObject<{
|
|
653
|
+
msg: z.ZodString;
|
|
654
|
+
error: z.ZodOptional<z.ZodUnknown>;
|
|
655
|
+
}, z.core.$loose>], null>, z.ZodVoid>;
|
|
656
|
+
info: z.ZodFunction<z.ZodTuple<readonly [z.ZodObject<{
|
|
657
|
+
msg: z.ZodString;
|
|
658
|
+
error: z.ZodOptional<z.ZodUnknown>;
|
|
659
|
+
}, z.core.$loose>], null>, z.ZodVoid>;
|
|
660
|
+
debug: z.ZodFunction<z.ZodTuple<readonly [z.ZodObject<{
|
|
661
|
+
msg: z.ZodString;
|
|
662
|
+
error: z.ZodOptional<z.ZodUnknown>;
|
|
663
|
+
}, z.core.$loose>], null>, z.ZodVoid>;
|
|
664
|
+
trace: z.ZodFunction<z.ZodTuple<readonly [z.ZodObject<{
|
|
665
|
+
msg: z.ZodString;
|
|
666
|
+
error: z.ZodOptional<z.ZodUnknown>;
|
|
667
|
+
}, z.core.$loose>], null>, z.ZodVoid>;
|
|
668
|
+
}, z.core.$loose>;
|
|
522
669
|
}, z.core.$strip>;
|
|
523
670
|
/**
|
|
524
671
|
* Type representing the "raw" context of a local Ponder app.
|
|
@@ -770,4 +917,4 @@ declare const schemaUnixTimestamp: z.ZodNumber;
|
|
|
770
917
|
*/
|
|
771
918
|
type UnixTimestamp = z.infer<typeof schemaUnixTimestamp>;
|
|
772
919
|
|
|
773
|
-
export { type BlockNumber, type BlockNumberRange, type BlockNumberRangeBounded, type BlockNumberRangeLeftBounded, type BlockNumberRangeRightBounded, type BlockNumberRangeUnbounded, type BlockNumberRangeWithStartBlock, type BlockRef, type BlockRefRange, type BlockRefRangeBounded, type BlockRefRangeLeftBounded, type BlockRefRangeRightBounded, type BlockRefRangeUnbounded, type BlockRefRangeWithStartBlock, type ChainId, type ChainIdString, type ChainIndexingConfig, type ChainIndexingMetrics, type ChainIndexingMetricsCompleted, type ChainIndexingMetricsHistorical, type ChainIndexingMetricsRealtime, type ChainIndexingState, ChainIndexingStates, type ChainIndexingStatus, type LocalChainIndexingMetrics, type LocalChainIndexingMetricsHistorical, LocalPonderClient, type LocalPonderIndexingMetrics, type PonderAppCommand, PonderAppCommands, type PonderAppContext, type PonderApplicationSettings, type PonderBlockNumberRange, PonderClient, type PonderIndexingMetrics, type PonderIndexingOrdering, PonderIndexingOrderings, type PonderIndexingStatus, type RangeType, RangeTypeIds, type RawPonderAppContext, type UnixTimestamp, buildBlockNumberRange, buildBlockRefRange, deserializePonderAppContext, isBlockRefBefore, isBlockRefBeforeOrEqualTo, isBlockRefEqualTo, mergeBlockNumberRanges, schemaBlockNumber, schemaBlockRef, schemaChainId, schemaInteger, schemaNonnegativeInteger, schemaNonnegativeNumber, schemaNumber, schemaPortNumber, schemaPositiveInteger, schemaPositiveNumber, schemaUnixTimestamp };
|
|
920
|
+
export { type BlockNumber, type BlockNumberRange, type BlockNumberRangeBounded, type BlockNumberRangeLeftBounded, type BlockNumberRangeRightBounded, type BlockNumberRangeUnbounded, type BlockNumberRangeWithStartBlock, type BlockRef, type BlockRefRange, type BlockRefRangeBounded, type BlockRefRangeLeftBounded, type BlockRefRangeRightBounded, type BlockRefRangeUnbounded, type BlockRefRangeWithStartBlock, type ChainId, type ChainIdString, type ChainIndexingConfig, type ChainIndexingMetrics, type ChainIndexingMetricsCompleted, type ChainIndexingMetricsHistorical, type ChainIndexingMetricsRealtime, type ChainIndexingState, ChainIndexingStates, type ChainIndexingStatus, type LocalChainIndexingMetrics, type LocalChainIndexingMetricsHistorical, LocalPonderClient, type LocalPonderIndexingMetrics, type PonderAppCommand, PonderAppCommands, type PonderAppContext, type PonderAppLog, type PonderAppLogger, type PonderApplicationSettings, type PonderBlockNumberRange, PonderClient, type PonderIndexingMetrics, type PonderIndexingOrdering, PonderIndexingOrderings, type PonderIndexingStatus, type RangeType, RangeTypeIds, type RawPonderAppContext, type UnixTimestamp, buildBlockNumberRange, buildBlockRefRange, deserializePonderAppContext, isBlockRefBefore, isBlockRefBeforeOrEqualTo, isBlockRefEqualTo, mergeBlockNumberRanges, schemaBlockNumber, schemaBlockRef, schemaChainId, schemaInteger, schemaNonnegativeInteger, schemaNonnegativeNumber, schemaNumber, schemaPortNumber, schemaPositiveInteger, schemaPositiveNumber, schemaUnixTimestamp };
|
package/dist/index.d.ts
CHANGED
|
@@ -209,6 +209,127 @@ type ChainId = z.infer<typeof schemaChainId>;
|
|
|
209
209
|
*/
|
|
210
210
|
type ChainIdString = string;
|
|
211
211
|
|
|
212
|
+
/**
|
|
213
|
+
* Represents a single log entry for the Ponder app logger.
|
|
214
|
+
*
|
|
215
|
+
* It is a loose object that:
|
|
216
|
+
* - must contain a `msg` property of type string, and
|
|
217
|
+
* - can optionally include an `error` property of type Error, and
|
|
218
|
+
* - can optionally include any additional properties relevant to
|
|
219
|
+
* the log message. The additional properties can be used to provide more
|
|
220
|
+
* context about the log message, and will be included in the log output.
|
|
221
|
+
*/
|
|
222
|
+
type PonderAppLog = {
|
|
223
|
+
/**
|
|
224
|
+
* Log message
|
|
225
|
+
*/
|
|
226
|
+
msg: string;
|
|
227
|
+
/**
|
|
228
|
+
* Optional error object to log.
|
|
229
|
+
*
|
|
230
|
+
* If provided, the logger will log the error's stack trace and message.
|
|
231
|
+
*/
|
|
232
|
+
error?: unknown;
|
|
233
|
+
/**
|
|
234
|
+
* Optional additional properties.
|
|
235
|
+
*
|
|
236
|
+
* If provided, they will be included in the log output.
|
|
237
|
+
*/
|
|
238
|
+
[key: string]: unknown;
|
|
239
|
+
};
|
|
240
|
+
/**
|
|
241
|
+
* Ponder app logger
|
|
242
|
+
*
|
|
243
|
+
* Represents the logger provided by the Ponder runtime to a local Ponder app.
|
|
244
|
+
* @see https://github.com/ponder-sh/ponder/blob/6fcc15d4234e43862cb6e21c05f3c57f4c2f7464/packages/core/src/internal/logger.ts#L8-L31
|
|
245
|
+
*/
|
|
246
|
+
interface PonderAppLogger {
|
|
247
|
+
/**
|
|
248
|
+
* Logs a message at the "error" level.
|
|
249
|
+
*
|
|
250
|
+
* @param options - The log message and additional properties to log.
|
|
251
|
+
*
|
|
252
|
+
* @example
|
|
253
|
+
* ```ts
|
|
254
|
+
* logger.error({
|
|
255
|
+
* msg: "Incorrect omnichain status",
|
|
256
|
+
* error: new Error("The omnichain status must be either 'omnichain-backfill' or 'omnichain-following'"),
|
|
257
|
+
* expected: "omnichain-backfill or omnichain-following",
|
|
258
|
+
* actual: "omnichain-unstarted"
|
|
259
|
+
* });
|
|
260
|
+
*
|
|
261
|
+
* logger.error({
|
|
262
|
+
* msg: "Incorrect omnichain status",
|
|
263
|
+
* error: new Error("The omnichain status must be either 'omnichain-backfill' or 'omnichain-following'"),
|
|
264
|
+
* });
|
|
265
|
+
*
|
|
266
|
+
* logger.error({
|
|
267
|
+
* msg: "The omnichain status must be either 'omnichain-backfill' or 'omnichain-following'"
|
|
268
|
+
* });
|
|
269
|
+
* ```
|
|
270
|
+
*/
|
|
271
|
+
error<T extends PonderAppLog>(options: T): void;
|
|
272
|
+
/**
|
|
273
|
+
* Logs a message at the "warn" level.
|
|
274
|
+
*
|
|
275
|
+
* @param options - The log message and additional properties to log.
|
|
276
|
+
*
|
|
277
|
+
* @example
|
|
278
|
+
* ```ts
|
|
279
|
+
* logger.warn({
|
|
280
|
+
* msg: "Both the '${PluginName.Subgraph}' and '${PluginName.ENSv2}' plugins are enabled.",
|
|
281
|
+
* effects: "This results in the availability of both the legacy Subgraph-Compatible GraphQL API (/subgraph) _and_ ENSNode's Omnigraph API (/api/omnigraph), and comes with an associated increase in indexing time. If your intent is to have both APIs available in parallel, excellent, otherwise you may benefit from only enabling the plugin for the API you plan to use."
|
|
282
|
+
* });
|
|
283
|
+
*
|
|
284
|
+
* logger.warn({
|
|
285
|
+
* msg: "Both the '${PluginName.Subgraph}' and '${PluginName.ENSv2}' plugins are enabled."
|
|
286
|
+
* });
|
|
287
|
+
* ```
|
|
288
|
+
*/
|
|
289
|
+
warn<T extends PonderAppLog>(options: T): void;
|
|
290
|
+
/**
|
|
291
|
+
* Logs a message at the "info" level.
|
|
292
|
+
* @param options
|
|
293
|
+
*
|
|
294
|
+
* @example
|
|
295
|
+
* ```ts
|
|
296
|
+
* logger.info({
|
|
297
|
+
* msg: "An informational message",
|
|
298
|
+
* details: "Here are some details about the info"
|
|
299
|
+
* });
|
|
300
|
+
* ```
|
|
301
|
+
*/
|
|
302
|
+
info<T extends PonderAppLog>(options: T): void;
|
|
303
|
+
/**
|
|
304
|
+
* Logs a message at the "debug" level.
|
|
305
|
+
* @param options
|
|
306
|
+
*
|
|
307
|
+
* @example
|
|
308
|
+
* ```ts
|
|
309
|
+
* logger.debug({
|
|
310
|
+
* msg: "A debug message",
|
|
311
|
+
* arg1: "Here is some debug information about arg1",
|
|
312
|
+
* arg2: "Here is some debug information about arg2"
|
|
313
|
+
* });
|
|
314
|
+
* ```
|
|
315
|
+
*/
|
|
316
|
+
debug<T extends PonderAppLog>(options: T): void;
|
|
317
|
+
/**
|
|
318
|
+
* Logs a message at the "trace" level.
|
|
319
|
+
* @param options
|
|
320
|
+
*
|
|
321
|
+
* @example
|
|
322
|
+
* ```ts
|
|
323
|
+
* logger.trace({
|
|
324
|
+
* msg: "A trace message",
|
|
325
|
+
* detailA: "Here are some details about the trace message",
|
|
326
|
+
* detailB: "Here are some more details about the trace message"
|
|
327
|
+
* });
|
|
328
|
+
* ```
|
|
329
|
+
*/
|
|
330
|
+
trace<T extends PonderAppLog>(options: T): void;
|
|
331
|
+
}
|
|
332
|
+
|
|
212
333
|
/**
|
|
213
334
|
* Ponder app commands
|
|
214
335
|
*
|
|
@@ -233,6 +354,10 @@ interface PonderAppContext {
|
|
|
233
354
|
* URL of the local Ponder app.
|
|
234
355
|
*/
|
|
235
356
|
localPonderAppUrl: URL;
|
|
357
|
+
/**
|
|
358
|
+
* Logger provided by the Ponder runtime
|
|
359
|
+
*/
|
|
360
|
+
logger: PonderAppLogger;
|
|
236
361
|
}
|
|
237
362
|
|
|
238
363
|
/**
|
|
@@ -519,6 +644,28 @@ declare const schemaRawPonderAppContext: z.ZodObject<{
|
|
|
519
644
|
}>;
|
|
520
645
|
port: z.ZodNumber;
|
|
521
646
|
}, z.core.$strip>;
|
|
647
|
+
logger: z.ZodObject<{
|
|
648
|
+
error: z.ZodFunction<z.ZodTuple<readonly [z.ZodObject<{
|
|
649
|
+
msg: z.ZodString;
|
|
650
|
+
error: z.ZodOptional<z.ZodUnknown>;
|
|
651
|
+
}, z.core.$loose>], null>, z.ZodVoid>;
|
|
652
|
+
warn: z.ZodFunction<z.ZodTuple<readonly [z.ZodObject<{
|
|
653
|
+
msg: z.ZodString;
|
|
654
|
+
error: z.ZodOptional<z.ZodUnknown>;
|
|
655
|
+
}, z.core.$loose>], null>, z.ZodVoid>;
|
|
656
|
+
info: z.ZodFunction<z.ZodTuple<readonly [z.ZodObject<{
|
|
657
|
+
msg: z.ZodString;
|
|
658
|
+
error: z.ZodOptional<z.ZodUnknown>;
|
|
659
|
+
}, z.core.$loose>], null>, z.ZodVoid>;
|
|
660
|
+
debug: z.ZodFunction<z.ZodTuple<readonly [z.ZodObject<{
|
|
661
|
+
msg: z.ZodString;
|
|
662
|
+
error: z.ZodOptional<z.ZodUnknown>;
|
|
663
|
+
}, z.core.$loose>], null>, z.ZodVoid>;
|
|
664
|
+
trace: z.ZodFunction<z.ZodTuple<readonly [z.ZodObject<{
|
|
665
|
+
msg: z.ZodString;
|
|
666
|
+
error: z.ZodOptional<z.ZodUnknown>;
|
|
667
|
+
}, z.core.$loose>], null>, z.ZodVoid>;
|
|
668
|
+
}, z.core.$loose>;
|
|
522
669
|
}, z.core.$strip>;
|
|
523
670
|
/**
|
|
524
671
|
* Type representing the "raw" context of a local Ponder app.
|
|
@@ -770,4 +917,4 @@ declare const schemaUnixTimestamp: z.ZodNumber;
|
|
|
770
917
|
*/
|
|
771
918
|
type UnixTimestamp = z.infer<typeof schemaUnixTimestamp>;
|
|
772
919
|
|
|
773
|
-
export { type BlockNumber, type BlockNumberRange, type BlockNumberRangeBounded, type BlockNumberRangeLeftBounded, type BlockNumberRangeRightBounded, type BlockNumberRangeUnbounded, type BlockNumberRangeWithStartBlock, type BlockRef, type BlockRefRange, type BlockRefRangeBounded, type BlockRefRangeLeftBounded, type BlockRefRangeRightBounded, type BlockRefRangeUnbounded, type BlockRefRangeWithStartBlock, type ChainId, type ChainIdString, type ChainIndexingConfig, type ChainIndexingMetrics, type ChainIndexingMetricsCompleted, type ChainIndexingMetricsHistorical, type ChainIndexingMetricsRealtime, type ChainIndexingState, ChainIndexingStates, type ChainIndexingStatus, type LocalChainIndexingMetrics, type LocalChainIndexingMetricsHistorical, LocalPonderClient, type LocalPonderIndexingMetrics, type PonderAppCommand, PonderAppCommands, type PonderAppContext, type PonderApplicationSettings, type PonderBlockNumberRange, PonderClient, type PonderIndexingMetrics, type PonderIndexingOrdering, PonderIndexingOrderings, type PonderIndexingStatus, type RangeType, RangeTypeIds, type RawPonderAppContext, type UnixTimestamp, buildBlockNumberRange, buildBlockRefRange, deserializePonderAppContext, isBlockRefBefore, isBlockRefBeforeOrEqualTo, isBlockRefEqualTo, mergeBlockNumberRanges, schemaBlockNumber, schemaBlockRef, schemaChainId, schemaInteger, schemaNonnegativeInteger, schemaNonnegativeNumber, schemaNumber, schemaPortNumber, schemaPositiveInteger, schemaPositiveNumber, schemaUnixTimestamp };
|
|
920
|
+
export { type BlockNumber, type BlockNumberRange, type BlockNumberRangeBounded, type BlockNumberRangeLeftBounded, type BlockNumberRangeRightBounded, type BlockNumberRangeUnbounded, type BlockNumberRangeWithStartBlock, type BlockRef, type BlockRefRange, type BlockRefRangeBounded, type BlockRefRangeLeftBounded, type BlockRefRangeRightBounded, type BlockRefRangeUnbounded, type BlockRefRangeWithStartBlock, type ChainId, type ChainIdString, type ChainIndexingConfig, type ChainIndexingMetrics, type ChainIndexingMetricsCompleted, type ChainIndexingMetricsHistorical, type ChainIndexingMetricsRealtime, type ChainIndexingState, ChainIndexingStates, type ChainIndexingStatus, type LocalChainIndexingMetrics, type LocalChainIndexingMetricsHistorical, LocalPonderClient, type LocalPonderIndexingMetrics, type PonderAppCommand, PonderAppCommands, type PonderAppContext, type PonderAppLog, type PonderAppLogger, type PonderApplicationSettings, type PonderBlockNumberRange, PonderClient, type PonderIndexingMetrics, type PonderIndexingOrdering, PonderIndexingOrderings, type PonderIndexingStatus, type RangeType, RangeTypeIds, type RawPonderAppContext, type UnixTimestamp, buildBlockNumberRange, buildBlockRefRange, deserializePonderAppContext, isBlockRefBefore, isBlockRefBeforeOrEqualTo, isBlockRefEqualTo, mergeBlockNumberRanges, schemaBlockNumber, schemaBlockRef, schemaChainId, schemaInteger, schemaNonnegativeInteger, schemaNonnegativeNumber, schemaNumber, schemaPortNumber, schemaPositiveInteger, schemaPositiveNumber, schemaUnixTimestamp };
|
package/dist/index.js
CHANGED
|
@@ -1074,21 +1074,85 @@ var PonderClient = class {
|
|
|
1074
1074
|
|
|
1075
1075
|
// src/deserialize/ponder-app-context.ts
|
|
1076
1076
|
import { prettifyError as prettifyError3, z as z6 } from "zod/v4";
|
|
1077
|
+
|
|
1078
|
+
// src/deserialize/ponder-app-logger.ts
|
|
1079
|
+
function isPrimitive(value) {
|
|
1080
|
+
return value === null || typeof value !== "object" && typeof value !== "function";
|
|
1081
|
+
}
|
|
1082
|
+
function replacer(_key, value) {
|
|
1083
|
+
if (typeof value === "bigint") return value.toString();
|
|
1084
|
+
if (value instanceof URL) return value.href;
|
|
1085
|
+
if (value instanceof Map) return Object.fromEntries(value);
|
|
1086
|
+
if (value instanceof Set) return Array.from(value);
|
|
1087
|
+
return value;
|
|
1088
|
+
}
|
|
1089
|
+
function formatLogValue(value) {
|
|
1090
|
+
if (isPrimitive(value)) return value;
|
|
1091
|
+
if (value instanceof Error) return value;
|
|
1092
|
+
try {
|
|
1093
|
+
return JSON.stringify(value, replacer);
|
|
1094
|
+
} catch {
|
|
1095
|
+
return String(value);
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
function wrapLogMethod(fn) {
|
|
1099
|
+
return (options) => {
|
|
1100
|
+
const formattedOptions = Object.fromEntries(
|
|
1101
|
+
Object.entries(options).filter(([key, value]) => {
|
|
1102
|
+
if (key === "error" && !(value instanceof Error)) return false;
|
|
1103
|
+
return true;
|
|
1104
|
+
}).map(([key, value]) => [key, formatLogValue(value)])
|
|
1105
|
+
);
|
|
1106
|
+
return fn(formattedOptions);
|
|
1107
|
+
};
|
|
1108
|
+
}
|
|
1109
|
+
function wrapPonderAppLogger(rawLogger) {
|
|
1110
|
+
return Object.freeze({
|
|
1111
|
+
...rawLogger,
|
|
1112
|
+
error: wrapLogMethod(rawLogger.error.bind(rawLogger)),
|
|
1113
|
+
warn: wrapLogMethod(rawLogger.warn.bind(rawLogger)),
|
|
1114
|
+
info: wrapLogMethod(rawLogger.info.bind(rawLogger)),
|
|
1115
|
+
debug: wrapLogMethod(rawLogger.debug.bind(rawLogger)),
|
|
1116
|
+
trace: wrapLogMethod(rawLogger.trace.bind(rawLogger))
|
|
1117
|
+
});
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
// src/deserialize/ponder-app-context.ts
|
|
1077
1121
|
var schemaPortNumber = z6.number({ error: "Port must be a number." }).int({ error: "Port must be an integer." }).min(1, { error: "Port must be greater than or equal to 1." }).max(65535, { error: "Port must be less than or equal to 65535." });
|
|
1122
|
+
var schemaPonderAppLoggerMethod = z6.function({
|
|
1123
|
+
input: [
|
|
1124
|
+
z6.looseObject({
|
|
1125
|
+
msg: z6.string({ error: "Log message must be a string." }),
|
|
1126
|
+
error: z6.optional(z6.unknown())
|
|
1127
|
+
})
|
|
1128
|
+
],
|
|
1129
|
+
output: z6.void()
|
|
1130
|
+
});
|
|
1131
|
+
var schemaRawPonderAppLogger = z6.looseObject({
|
|
1132
|
+
error: schemaPonderAppLoggerMethod,
|
|
1133
|
+
warn: schemaPonderAppLoggerMethod,
|
|
1134
|
+
info: schemaPonderAppLoggerMethod,
|
|
1135
|
+
debug: schemaPonderAppLoggerMethod,
|
|
1136
|
+
trace: schemaPonderAppLoggerMethod
|
|
1137
|
+
});
|
|
1138
|
+
var schemaPonderAppLogger = schemaRawPonderAppLogger.transform(wrapPonderAppLogger);
|
|
1078
1139
|
var schemaRawPonderAppContext = z6.object({
|
|
1079
1140
|
options: z6.object({
|
|
1080
1141
|
command: z6.enum(PonderAppCommands),
|
|
1081
1142
|
port: schemaPortNumber
|
|
1082
|
-
})
|
|
1143
|
+
}),
|
|
1144
|
+
logger: schemaRawPonderAppLogger
|
|
1083
1145
|
});
|
|
1084
1146
|
var schemaPonderAppContext = z6.object({
|
|
1085
1147
|
command: z6.enum(PonderAppCommands),
|
|
1086
|
-
localPonderAppUrl: z6.instanceof(URL, { error: "localPonderAppUrl must be a valid URL." })
|
|
1148
|
+
localPonderAppUrl: z6.instanceof(URL, { error: "localPonderAppUrl must be a valid URL." }),
|
|
1149
|
+
logger: schemaPonderAppLogger
|
|
1087
1150
|
});
|
|
1088
1151
|
function buildUnvalidatedPonderAppContext(rawPonderAppContext) {
|
|
1089
1152
|
return {
|
|
1090
1153
|
command: rawPonderAppContext.options.command,
|
|
1091
|
-
localPonderAppUrl: new URL(`http://localhost:${rawPonderAppContext.options.port}`)
|
|
1154
|
+
localPonderAppUrl: new URL(`http://localhost:${rawPonderAppContext.options.port}`),
|
|
1155
|
+
logger: rawPonderAppContext.logger
|
|
1092
1156
|
};
|
|
1093
1157
|
}
|
|
1094
1158
|
function deserializePonderAppContext(unvalidatedRawPonderAppContext) {
|