@ensnode/ponder-sdk 1.8.1 → 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.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
  *
@@ -229,6 +350,14 @@ interface PonderAppContext {
229
350
  * Command used to start the Ponder app.
230
351
  */
231
352
  command: PonderAppCommand;
353
+ /**
354
+ * URL of the local Ponder app.
355
+ */
356
+ localPonderAppUrl: URL;
357
+ /**
358
+ * Logger provided by the Ponder runtime
359
+ */
360
+ logger: PonderAppLogger;
232
361
  }
233
362
 
234
363
  /**
@@ -500,13 +629,43 @@ type Unvalidated<T> = DeepPartial<T>;
500
629
  * @see https://github.com/ponder-sh/ponder/blob/6fcc15d4234e43862cb6e21c05f3c57f4c2f7464/packages/core/src/internal/common.ts#L7-L15
501
630
  */
502
631
 
632
+ /**
633
+ * Schema representing a valid port number for the Ponder app to listen on.
634
+ */
635
+ declare const schemaPortNumber: z.ZodNumber;
503
636
  /**
504
637
  * Type representing the "raw" context of a local Ponder app.
505
638
  */
506
639
  declare const schemaRawPonderAppContext: z.ZodObject<{
507
640
  options: z.ZodObject<{
508
- command: z.ZodString;
641
+ command: z.ZodEnum<{
642
+ readonly Dev: "dev";
643
+ readonly Start: "start";
644
+ }>;
645
+ port: z.ZodNumber;
509
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>;
510
669
  }, z.core.$strip>;
511
670
  /**
512
671
  * Type representing the "raw" context of a local Ponder app.
@@ -645,14 +804,13 @@ declare class LocalPonderClient extends PonderClient {
645
804
  */
646
805
  private ponderAppContext;
647
806
  /**
648
- * @param localPonderAppUrl URL of the local Ponder app to connect to.
649
807
  * @param indexedChainIds Configured indexed chain IDs which are used to validate and filter the Ponder app metadata to only include entries for indexed chains.
650
808
  * @param indexedBlockranges Configured indexing blockrange for each indexed chain.
651
809
  * @param ponderPublicClients All cached public clients provided by the local Ponder app
652
810
  * (may include non-indexed chains).
653
811
  * @param ponderAppContext The internal context of the local Ponder app.
654
812
  */
655
- constructor(localPonderAppUrl: URL, indexedChainIds: Set<ChainId>, indexedBlockranges: Map<ChainId, BlockNumberRangeWithStartBlock>, ponderPublicClients: Record<ChainIdString, CachedPublicClient>, ponderAppContext: PonderAppContext);
813
+ constructor(indexedChainIds: Set<ChainId>, indexedBlockranges: Map<ChainId, BlockNumberRangeWithStartBlock>, ponderPublicClients: Record<ChainIdString, CachedPublicClient>, ponderAppContext: PonderAppContext);
656
814
  /**
657
815
  * Get the blockrange that is configured to be indexed for a specific chain ID.
658
816
  *
@@ -759,4 +917,4 @@ declare const schemaUnixTimestamp: z.ZodNumber;
759
917
  */
760
918
  type UnixTimestamp = z.infer<typeof schemaUnixTimestamp>;
761
919
 
762
- 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, 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
  *
@@ -229,6 +350,14 @@ interface PonderAppContext {
229
350
  * Command used to start the Ponder app.
230
351
  */
231
352
  command: PonderAppCommand;
353
+ /**
354
+ * URL of the local Ponder app.
355
+ */
356
+ localPonderAppUrl: URL;
357
+ /**
358
+ * Logger provided by the Ponder runtime
359
+ */
360
+ logger: PonderAppLogger;
232
361
  }
233
362
 
234
363
  /**
@@ -500,13 +629,43 @@ type Unvalidated<T> = DeepPartial<T>;
500
629
  * @see https://github.com/ponder-sh/ponder/blob/6fcc15d4234e43862cb6e21c05f3c57f4c2f7464/packages/core/src/internal/common.ts#L7-L15
501
630
  */
502
631
 
632
+ /**
633
+ * Schema representing a valid port number for the Ponder app to listen on.
634
+ */
635
+ declare const schemaPortNumber: z.ZodNumber;
503
636
  /**
504
637
  * Type representing the "raw" context of a local Ponder app.
505
638
  */
506
639
  declare const schemaRawPonderAppContext: z.ZodObject<{
507
640
  options: z.ZodObject<{
508
- command: z.ZodString;
641
+ command: z.ZodEnum<{
642
+ readonly Dev: "dev";
643
+ readonly Start: "start";
644
+ }>;
645
+ port: z.ZodNumber;
509
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>;
510
669
  }, z.core.$strip>;
511
670
  /**
512
671
  * Type representing the "raw" context of a local Ponder app.
@@ -645,14 +804,13 @@ declare class LocalPonderClient extends PonderClient {
645
804
  */
646
805
  private ponderAppContext;
647
806
  /**
648
- * @param localPonderAppUrl URL of the local Ponder app to connect to.
649
807
  * @param indexedChainIds Configured indexed chain IDs which are used to validate and filter the Ponder app metadata to only include entries for indexed chains.
650
808
  * @param indexedBlockranges Configured indexing blockrange for each indexed chain.
651
809
  * @param ponderPublicClients All cached public clients provided by the local Ponder app
652
810
  * (may include non-indexed chains).
653
811
  * @param ponderAppContext The internal context of the local Ponder app.
654
812
  */
655
- constructor(localPonderAppUrl: URL, indexedChainIds: Set<ChainId>, indexedBlockranges: Map<ChainId, BlockNumberRangeWithStartBlock>, ponderPublicClients: Record<ChainIdString, CachedPublicClient>, ponderAppContext: PonderAppContext);
813
+ constructor(indexedChainIds: Set<ChainId>, indexedBlockranges: Map<ChainId, BlockNumberRangeWithStartBlock>, ponderPublicClients: Record<ChainIdString, CachedPublicClient>, ponderAppContext: PonderAppContext);
656
814
  /**
657
815
  * Get the blockrange that is configured to be indexed for a specific chain ID.
658
816
  *
@@ -759,4 +917,4 @@ declare const schemaUnixTimestamp: z.ZodNumber;
759
917
  */
760
918
  type UnixTimestamp = z.infer<typeof schemaUnixTimestamp>;
761
919
 
762
- 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, 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,17 +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
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);
1077
1139
  var schemaRawPonderAppContext = z6.object({
1078
1140
  options: z6.object({
1079
- command: z6.string()
1080
- })
1141
+ command: z6.enum(PonderAppCommands),
1142
+ port: schemaPortNumber
1143
+ }),
1144
+ logger: schemaRawPonderAppLogger
1081
1145
  });
1082
1146
  var schemaPonderAppContext = z6.object({
1083
- command: z6.enum(PonderAppCommands)
1147
+ command: z6.enum(PonderAppCommands),
1148
+ localPonderAppUrl: z6.instanceof(URL, { error: "localPonderAppUrl must be a valid URL." }),
1149
+ logger: schemaPonderAppLogger
1084
1150
  });
1085
1151
  function buildUnvalidatedPonderAppContext(rawPonderAppContext) {
1086
1152
  return {
1087
- command: rawPonderAppContext.options.command
1153
+ command: rawPonderAppContext.options.command,
1154
+ localPonderAppUrl: new URL(`http://localhost:${rawPonderAppContext.options.port}`),
1155
+ logger: rawPonderAppContext.logger
1088
1156
  };
1089
1157
  }
1090
1158
  function deserializePonderAppContext(unvalidatedRawPonderAppContext) {
@@ -1133,15 +1201,14 @@ var LocalPonderClient = class _LocalPonderClient extends PonderClient {
1133
1201
  */
1134
1202
  ponderAppContext;
1135
1203
  /**
1136
- * @param localPonderAppUrl URL of the local Ponder app to connect to.
1137
1204
  * @param indexedChainIds Configured indexed chain IDs which are used to validate and filter the Ponder app metadata to only include entries for indexed chains.
1138
1205
  * @param indexedBlockranges Configured indexing blockrange for each indexed chain.
1139
1206
  * @param ponderPublicClients All cached public clients provided by the local Ponder app
1140
1207
  * (may include non-indexed chains).
1141
1208
  * @param ponderAppContext The internal context of the local Ponder app.
1142
1209
  */
1143
- constructor(localPonderAppUrl, indexedChainIds, indexedBlockranges, ponderPublicClients, ponderAppContext) {
1144
- super(localPonderAppUrl);
1210
+ constructor(indexedChainIds, indexedBlockranges, ponderPublicClients, ponderAppContext) {
1211
+ super(ponderAppContext.localPonderAppUrl);
1145
1212
  this.indexedChainIds = indexedChainIds;
1146
1213
  const cachedPublicClients = _LocalPonderClient.buildCachedPublicClients(ponderPublicClients);
1147
1214
  this.indexedBlockranges = _LocalPonderClient.selectEntriesForIndexedChainsOnly(
@@ -1339,6 +1406,7 @@ export {
1339
1406
  schemaNonnegativeInteger,
1340
1407
  schemaNonnegativeNumber,
1341
1408
  schemaNumber,
1409
+ schemaPortNumber,
1342
1410
  schemaPositiveInteger,
1343
1411
  schemaPositiveNumber,
1344
1412
  schemaUnixTimestamp