@secondlayer/subgraphs 4.1.5 → 4.2.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.
Files changed (39) hide show
  1. package/dist/src/index.d.ts +87 -29
  2. package/dist/src/index.js +376 -128
  3. package/dist/src/index.js.map +9 -7
  4. package/dist/src/runtime/block-processor.d.ts +72 -23
  5. package/dist/src/runtime/block-processor.js +186 -53
  6. package/dist/src/runtime/block-processor.js.map +7 -5
  7. package/dist/src/runtime/catchup.d.ts +72 -23
  8. package/dist/src/runtime/catchup.js +201 -68
  9. package/dist/src/runtime/catchup.js.map +7 -5
  10. package/dist/src/runtime/emitter.js +24 -1
  11. package/dist/src/runtime/emitter.js.map +5 -4
  12. package/dist/src/runtime/processor.js +328 -166
  13. package/dist/src/runtime/processor.js.map +10 -7
  14. package/dist/src/runtime/reindex.d.ts +72 -23
  15. package/dist/src/runtime/reindex.js +238 -105
  16. package/dist/src/runtime/reindex.js.map +7 -5
  17. package/dist/src/runtime/reorg.d.ts +72 -23
  18. package/dist/src/runtime/reorg.js +215 -81
  19. package/dist/src/runtime/reorg.js.map +8 -6
  20. package/dist/src/runtime/runner.d.ts +72 -23
  21. package/dist/src/runtime/runner.js +156 -23
  22. package/dist/src/runtime/runner.js.map +8 -6
  23. package/dist/src/runtime/source-matcher.d.ts +72 -23
  24. package/dist/src/schema/index.d.ts +72 -23
  25. package/dist/src/schema/index.js +115 -1
  26. package/dist/src/schema/index.js.map +3 -3
  27. package/dist/src/service.js +348 -171
  28. package/dist/src/service.js.map +11 -8
  29. package/dist/src/testing/index.d.ts +195 -24
  30. package/dist/src/testing/index.js +448 -25
  31. package/dist/src/testing/index.js.map +9 -6
  32. package/dist/src/triggers/index.d.ts +83 -24
  33. package/dist/src/triggers/index.js +5 -2
  34. package/dist/src/triggers/index.js.map +3 -3
  35. package/dist/src/types.d.ts +73 -24
  36. package/dist/src/validate.d.ts +72 -23
  37. package/dist/src/validate.js +115 -1
  38. package/dist/src/validate.js.map +3 -3
  39. package/package.json +2 -2
@@ -119,7 +119,12 @@ type TraitScope = {
119
119
  *
120
120
  * ```ts
121
121
  * sources: {
122
- * registry: { type: "print_event", contractId: REGISTRY, topic: "pool-created" },
122
+ * registry: {
123
+ * type: "print_event",
124
+ * contractId: REGISTRY,
125
+ * topic: "pool-created",
126
+ * prints: { "pool-created": { pool: "principal" } },
127
+ * },
123
128
  * swaps: {
124
129
  * type: "print_event",
125
130
  * topic: "swap",
@@ -203,6 +208,9 @@ interface ContractCallFilter extends TraitScope, FactoryScope {
203
208
  * decoded function arguments. Dev-provided; serialized into the deployed
204
209
  * definition and used at runtime to decode args by name. Omit to keep
205
210
  * `event.args` as a positional `unknown[]`.
211
+ *
212
+ * Deploy validation requires `abi` whenever `functionName` is set
213
+ * (`normalizeAbi()` from `@secondlayer/stacks/clarity`).
206
214
  */
207
215
  abi?: AbiContract2;
208
216
  }
@@ -233,29 +241,70 @@ type PrintField = ColumnType | {
233
241
  } | {
234
242
  list: PrintField
235
243
  };
236
- interface PrintEventFilter extends TraitScope, FactoryScope {
237
- type: "print_event";
238
- /** One contract id, or a set of them (max 20). Supports `*` wildcards.
239
- * COMPOSES with `trait` — the matcher ANDs them, so the pair means
240
- * "contracts conforming to this trait, narrowed to these ids". (The Index
241
- * read API refuses the combination, but that is its query planner's
242
- * constraint, not a semantic one.) */
243
- contractId?: string | readonly string[];
244
- topic?: string;
245
- /**
246
- * Per-topic field schema. When declared, the handler's `event` is a
247
- * discriminated union keyed by `topic` and `event.data` is typed per topic
248
- * (e.g. `{ "completed-deposit": { amount: "uint", sender: "principal" } }`).
249
- * Nested tuples, lists, and optional fields are expressible — see
250
- * {@link PrintField}.
251
- *
252
- * Declaring `prints` also opts the source into RUNTIME validation: an
253
- * event whose decoded payload does not match is skipped and logged rather
254
- * than written as nulls (and the deploy-time field lint is promoted from
255
- * a warning to an error).
256
- */
257
- prints?: Record<string, Record<string, PrintField>>;
244
+ /**
245
+ * Per-topic field schema for a print_event source. When declared, the handler's
246
+ * `event` is a discriminated union keyed by `topic` and `event.data` is typed
247
+ * per topic. Nested tuples, lists, and optional fields — see {@link PrintField}.
248
+ *
249
+ * Also opts the source into RUNTIME validation: a payload that does not match
250
+ * is skipped and logged rather than written as nulls.
251
+ */
252
+ type PrintEventPrints = Record<string, Record<string, PrintField>>;
253
+ /**
254
+ * One column in a static identity map. Literals only — the bundler never
255
+ * executes user code, so `{ from: "tokenX" }` is valid and `from("tokenX")`
256
+ * is not.
257
+ */
258
+ type MaterializeColumn = {
259
+ from: string
260
+ } | {
261
+ fromTx: "sender" | "txId"
262
+ } | {
263
+ fromBlock: "height" | "hash" | "timestamp"
264
+ };
265
+ /** Static insert from a source event — replaces a 1:1 handler. */
266
+ interface MaterializeSpec {
267
+ table: string;
268
+ /** Keys = schema column names (snake). */
269
+ columns: Record<string, MaterializeColumn>;
258
270
  }
271
+ type PrintEventFields = FactoryScope & {
272
+ type: "print_event"
273
+ topic?: string
274
+ /** Identity map: insert without a handler function. XOR with handlers[name]. */
275
+ materialize?: MaterializeSpec
276
+ };
277
+ /**
278
+ * Pinned to one or more contract ids with no trait — `prints` is required so
279
+ * `event.data` is typed and empty-table handlers cannot typecheck.
280
+ */
281
+ type PinnedPrintEventFilter = PrintEventFields & {
282
+ contractId: string | readonly string[]
283
+ trait?: undefined
284
+ prints: PrintEventPrints
285
+ };
286
+ /**
287
+ * Trait-scoped print source (optionally narrowed by contractId). No single
288
+ * schema — `prints` stays optional.
289
+ */
290
+ type TraitPrintEventFilter = PrintEventFields & {
291
+ contractId?: string | readonly string[]
292
+ trait: string
293
+ prints?: PrintEventPrints
294
+ };
295
+ /**
296
+ * Unpinned / factory-only print source (no contractId). `prints` optional.
297
+ */
298
+ type UnpinnedPrintEventFilter = PrintEventFields & {
299
+ contractId?: undefined
300
+ trait?: string
301
+ prints?: PrintEventPrints
302
+ };
303
+ /**
304
+ * Print-event filter. Pinned sources (contractId set, no trait) require
305
+ * `prints`; trait and unpinned sources may omit it.
306
+ */
307
+ type PrintEventFilter = PinnedPrintEventFilter | TraitPrintEventFilter | UnpinnedPrintEventFilter;
259
308
  /** All subgraph filter types — discriminated on `type` */
260
309
  type SubgraphFilter = StxTransferFilter | StxMintFilter | StxBurnFilter | StxLockFilter | FtTransferFilter | FtMintFilter | FtBurnFilter | NftTransferFilter | NftMintFilter | NftBurnFilter | ContractCallFilter | ContractDeployFilter | PrintEventFilter;
261
310
  /** Transaction metadata available in handlers */