@sentio/sdk 1.25.3 → 1.26.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 (55) hide show
  1. package/lib/aptos/aptos-processor.d.ts +24 -3
  2. package/lib/aptos/aptos-processor.js +70 -20
  3. package/lib/aptos/aptos-processor.js.map +1 -1
  4. package/lib/aptos/context.d.ts +10 -3
  5. package/lib/aptos/context.js +34 -2
  6. package/lib/aptos/context.js.map +1 -1
  7. package/lib/aptos/index.d.ts +1 -1
  8. package/lib/aptos/index.js +2 -1
  9. package/lib/aptos/index.js.map +1 -1
  10. package/lib/aptos/network.d.ts +1 -2
  11. package/lib/aptos/network.js +1 -1
  12. package/lib/aptos/network.js.map +1 -1
  13. package/lib/core/context.d.ts +2 -5
  14. package/lib/core/context.js +8 -11
  15. package/lib/core/context.js.map +1 -1
  16. package/lib/core/event-tracker.js +1 -1
  17. package/lib/core/event-tracker.js.map +1 -1
  18. package/lib/core/exporter.d.ts +14 -0
  19. package/lib/core/exporter.js +27 -0
  20. package/lib/core/exporter.js.map +1 -0
  21. package/lib/core/logger.js +1 -1
  22. package/lib/core/logger.js.map +1 -1
  23. package/lib/core/meter.js +2 -2
  24. package/lib/core/meter.js.map +1 -1
  25. package/lib/gen/processor/protos/processor.d.ts +54 -9
  26. package/lib/gen/processor/protos/processor.js +317 -25
  27. package/lib/gen/processor/protos/processor.js.map +1 -1
  28. package/lib/processor-state.d.ts +4 -0
  29. package/lib/processor-state.js +2 -0
  30. package/lib/processor-state.js.map +1 -1
  31. package/lib/service.d.ts +4 -0
  32. package/lib/service.js +58 -17
  33. package/lib/service.js.map +1 -1
  34. package/lib/tests/aptos.test.js +25 -0
  35. package/lib/tests/aptos.test.js.map +1 -1
  36. package/lib/tests/erc20.js +7 -0
  37. package/lib/tests/erc20.js.map +1 -1
  38. package/lib/tests/souffl3.js +5 -1
  39. package/lib/tests/souffl3.js.map +1 -1
  40. package/package.json +1 -1
  41. package/src/aptos/aptos-processor.ts +98 -19
  42. package/src/aptos/context.ts +33 -3
  43. package/src/aptos/index.ts +1 -1
  44. package/src/aptos/network.ts +2 -4
  45. package/src/core/context.ts +10 -20
  46. package/src/core/event-tracker.ts +1 -1
  47. package/src/core/exporter.ts +33 -0
  48. package/src/core/logger.ts +1 -1
  49. package/src/core/meter.ts +2 -2
  50. package/src/gen/processor/protos/processor.ts +403 -38
  51. package/src/processor-state.ts +5 -0
  52. package/src/service.ts +65 -19
  53. package/src/tests/aptos.test.ts +28 -0
  54. package/src/tests/erc20.ts +7 -0
  55. package/src/tests/souffl3.ts +6 -1
@@ -1 +1 @@
1
- {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/core/logger.ts"],"names":[],"mappings":";;;AACA,gCAAiD;AACjD,yCAAgD;AAIhD,MAAa,MAAO,SAAQ,8BAAmB;IAC5B,GAAG,CAAa;IAEjC,YAAY,GAAgB,EAAE,IAAI,GAAG,EAAE;QACrC,KAAK,CAAC,oBAAc,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;QAC3C,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;IAChB,CAAC;IAED,QAAQ,CAAC,IAAY;QACnB,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;IACnC,CAAC;IAED,GAAG,CAAC,KAAe,EAAE,OAAY,EAAE,aAAyB,EAAE;QAC5D,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,CAAC,CAAC,OAAO,YAAY,MAAM,CAAC,EAAE;YAC/D,OAAO,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAA;SAC7B;QAED,IAAI,CAAC,KAAK,EAAE,CAAA;QACZ,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;YACjB,mBAAmB;YACnB,QAAQ,EAAE,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,kBAAkB,EAAE,EAAE,EAAE,CAAC;YAC7D,KAAK;YACL,OAAO;YACP,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC;YACtC,WAAW,EAAE,SAAS;SACvB,CAAC,CAAA;IACJ,CAAC;IAED,IAAI,CAAC,GAAQ,EAAE,aAAyB,EAAE;QACxC,IAAI,CAAC,GAAG,CAAC,cAAQ,CAAC,IAAI,EAAE,GAAG,EAAE,UAAU,CAAC,CAAA;IAC1C,CAAC;IAED,IAAI,CAAC,GAAQ,EAAE,aAAyB,EAAE;QACxC,IAAI,CAAC,GAAG,CAAC,cAAQ,CAAC,OAAO,EAAE,GAAG,EAAE,UAAU,CAAC,CAAA;IAC7C,CAAC;IAED,KAAK,CAAC,GAAQ,EAAE,aAAyB,EAAE;QACzC,IAAI,CAAC,GAAG,CAAC,cAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,UAAU,CAAC,CAAA;IAC3C,CAAC;IAED,QAAQ,CAAC,GAAQ,EAAE,aAAyB,EAAE;QAC5C,IAAI,CAAC,GAAG,CAAC,cAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE,UAAU,CAAC,CAAA;IAC9C,CAAC;CACF;AA3CD,wBA2CC","sourcesContent":["import { BaseContext } from './context'\nimport { DataDescriptor, LogLevel } from '../gen'\nimport { DescriptorWithUsage } from './metadata'\n\nexport type Attributes = Record<string, any>\n\nexport class Logger extends DescriptorWithUsage {\n private readonly ctx: BaseContext\n\n constructor(ctx: BaseContext, name = '') {\n super(DataDescriptor.fromPartial({ name }))\n this.ctx = ctx\n }\n\n withName(name: string) {\n return new Logger(this.ctx, name)\n }\n\n log(level: LogLevel, message: any, attributes: Attributes = {}) {\n if (typeof message !== 'string' && !(message instanceof String)) {\n message = message.toString()\n }\n\n this.usage++\n this.ctx.logs.push({\n // name: this.name,\n metadata: this.ctx.getMetaData(this.getShortDescriptor(), {}), // GetRecordMetaData(this.ctx, this, {}),\n level,\n message,\n attributes: JSON.stringify(attributes),\n runtimeInfo: undefined,\n })\n }\n\n info(msg: any, attributes: Attributes = {}) {\n this.log(LogLevel.INFO, msg, attributes)\n }\n\n warn(msg: any, attributes: Attributes = {}) {\n this.log(LogLevel.WARNING, msg, attributes)\n }\n\n error(msg: any, attributes: Attributes = {}) {\n this.log(LogLevel.ERROR, msg, attributes)\n }\n\n critical(msg: any, attributes: Attributes = {}) {\n this.log(LogLevel.CRITICAL, msg, attributes)\n }\n}\n"]}
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/core/logger.ts"],"names":[],"mappings":";;;AACA,gCAAiD;AACjD,yCAAgD;AAIhD,MAAa,MAAO,SAAQ,8BAAmB;IAC5B,GAAG,CAAa;IAEjC,YAAY,GAAgB,EAAE,IAAI,GAAG,EAAE;QACrC,KAAK,CAAC,oBAAc,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;QAC3C,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;IAChB,CAAC;IAED,QAAQ,CAAC,IAAY;QACnB,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;IACnC,CAAC;IAED,GAAG,CAAC,KAAe,EAAE,OAAY,EAAE,aAAyB,EAAE;QAC5D,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,CAAC,CAAC,OAAO,YAAY,MAAM,CAAC,EAAE;YAC/D,OAAO,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAA;SAC7B;QAED,IAAI,CAAC,KAAK,EAAE,CAAA;QACZ,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;YACrB,mBAAmB;YACnB,QAAQ,EAAE,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,kBAAkB,EAAE,EAAE,EAAE,CAAC;YAC7D,KAAK;YACL,OAAO;YACP,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC;YACtC,WAAW,EAAE,SAAS;SACvB,CAAC,CAAA;IACJ,CAAC;IAED,IAAI,CAAC,GAAQ,EAAE,aAAyB,EAAE;QACxC,IAAI,CAAC,GAAG,CAAC,cAAQ,CAAC,IAAI,EAAE,GAAG,EAAE,UAAU,CAAC,CAAA;IAC1C,CAAC;IAED,IAAI,CAAC,GAAQ,EAAE,aAAyB,EAAE;QACxC,IAAI,CAAC,GAAG,CAAC,cAAQ,CAAC,OAAO,EAAE,GAAG,EAAE,UAAU,CAAC,CAAA;IAC7C,CAAC;IAED,KAAK,CAAC,GAAQ,EAAE,aAAyB,EAAE;QACzC,IAAI,CAAC,GAAG,CAAC,cAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,UAAU,CAAC,CAAA;IAC3C,CAAC;IAED,QAAQ,CAAC,GAAQ,EAAE,aAAyB,EAAE;QAC5C,IAAI,CAAC,GAAG,CAAC,cAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE,UAAU,CAAC,CAAA;IAC9C,CAAC;CACF;AA3CD,wBA2CC","sourcesContent":["import { BaseContext } from './context'\nimport { DataDescriptor, LogLevel } from '../gen'\nimport { DescriptorWithUsage } from './metadata'\n\nexport type Attributes = Record<string, any>\n\nexport class Logger extends DescriptorWithUsage {\n private readonly ctx: BaseContext\n\n constructor(ctx: BaseContext, name = '') {\n super(DataDescriptor.fromPartial({ name }))\n this.ctx = ctx\n }\n\n withName(name: string) {\n return new Logger(this.ctx, name)\n }\n\n log(level: LogLevel, message: any, attributes: Attributes = {}) {\n if (typeof message !== 'string' && !(message instanceof String)) {\n message = message.toString()\n }\n\n this.usage++\n this.ctx.res.logs.push({\n // name: this.name,\n metadata: this.ctx.getMetaData(this.getShortDescriptor(), {}), // GetRecordMetaData(this.ctx, this, {}),\n level,\n message,\n attributes: JSON.stringify(attributes),\n runtimeInfo: undefined,\n })\n }\n\n info(msg: any, attributes: Attributes = {}) {\n this.log(LogLevel.INFO, msg, attributes)\n }\n\n warn(msg: any, attributes: Attributes = {}) {\n this.log(LogLevel.WARNING, msg, attributes)\n }\n\n error(msg: any, attributes: Attributes = {}) {\n this.log(LogLevel.ERROR, msg, attributes)\n }\n\n critical(msg: any, attributes: Attributes = {}) {\n this.log(LogLevel.CRITICAL, msg, attributes)\n }\n}\n"]}
package/lib/core/meter.js CHANGED
@@ -64,7 +64,7 @@ class Counter extends Metric {
64
64
  this.record(ctx, value, labels, false);
65
65
  }
66
66
  record(ctx, value, labels, add) {
67
- ctx.counters.push({
67
+ ctx.res.counters.push({
68
68
  metadata: ctx.getMetaData(this.getShortDescriptor(), labels),
69
69
  metricValue: (0, numberish_1.toMetricValue)(value),
70
70
  add: add,
@@ -91,7 +91,7 @@ class CounterBinding {
91
91
  exports.CounterBinding = CounterBinding;
92
92
  class Gauge extends Metric {
93
93
  record(ctx, value, labels = {}) {
94
- ctx.gauges.push({
94
+ ctx.res.gauges.push({
95
95
  metadata: ctx.getMetaData(this.getShortDescriptor(), labels),
96
96
  metricValue: (0, numberish_1.toMetricValue)(value),
97
97
  runtimeInfo: undefined,
@@ -1 +1 @@
1
- {"version":3,"file":"meter.js","sourceRoot":"","sources":["../../src/core/meter.ts"],"names":[],"mappings":";;;AACA,2CAAsD;AACtD,yCAAwD;AACxD,gCAAuC;AAEvC,SAAgB,aAAa,CAAC,IAAY;IACxC,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,gBAAgB,CAAC,CAAA;IAC1C,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;AAC/C,CAAC;AAHD,sCAGC;AAED,SAAgB,YAAY,CAAC,IAAY;IACvC,IAAI,IAAI,KAAK,QAAQ,EAAE;QACrB,OAAO,SAAS,CAAA;KACjB;IACD,OAAO,aAAa,CAAC,IAAI,CAAC,CAAA;AAC5B,CAAC;AALD,oCAKC;AAED,SAAgB,cAAc,CAAC,IAAY;IACzC,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;AAC3B,CAA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BAAkB,EAAE,EAAE,MAAM,CAAC;YAC5D,WAAW,EAAE,IAAA,yBAAa,EAAC,KAAK,CAAC;YACjC,WAAW,EAAE,SAAS;SACvB,CAAC,CAAA;QACF,IAAI,CAAC,KAAK,EAAE,CAAA;IACd,CAAC;CACF;AATD,sBASC;AAED,MAAa,YAAY;IACN,KAAK,CAAO;IACZ,GAAG,CAAa;IAEjC,YAAY,IAAY,EAAE,GAAgB;QACxC,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,CAAA;QAC5B,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;IAChB,CAAC;IAED,MAAM,CAAC,KAAgB,EAAE,SAAiB,EAAE;QAC1C,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,CAAA;IAC5C,CAAC;CACF;AAZD,oCAYC;AAED,MAAa,KAAK;IACC,GAAG,CAAa;IAEjC,YAAY,GAAgB;QAC1B,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;IAChB,CAAC;IAED,OAAO,CAAC,IAAY;QAClB,OAAO,IAAI,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAA;IAC3C,CAAC;IAED,KAAK,CAAC,IAAY;QAChB,OAAO,IAAI,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAA;IACzC,CAAC;CACF;AAdD,sBAcC","sourcesContent":["import { BaseContext } from './context'\nimport { toMetricValue, Numberish } from './numberish'\nimport { DescriptorWithUsage, Labels } from './metadata'\nimport { DataDescriptor } from '../gen'\n\nexport function normalizeName(name: string): string {\n const regex = new RegExp('![_.a-zA-Z0-9]')\n return name.slice(0, 100).replace(regex, '_')\n}\n\nexport function normalizeKey(name: string): string {\n if (name === 'labels') {\n return 'labels_'\n }\n return normalizeName(name)\n}\n\nexport function normalizeValue(name: string): string {\n return name.slice(0, 100)\n}\n\nexport function normalizeLabels(labels: Labels): Labels {\n const normLabels: Labels = {}\n for (const key in labels) {\n normLabels[normalizeKey(key)] = normalizeValue(labels[key])\n }\n return normLabels\n}\n\nexport class MetricDescriptorOptions {\n unit?: string\n description?: string\n sparse?: boolean\n resolutionInSeconds?: number\n}\n\nexport class Metric extends DescriptorWithUsage {\n constructor(name: string, option?: MetricDescriptorOptions) {\n const descriptor = DataDescriptor.fromPartial({ name })\n if (option) {\n if (option.unit) {\n descriptor.unit = option.unit\n }\n if (option.description) {\n descriptor.description = option.description\n }\n if (option.sparse) {\n descriptor.sparse = option.sparse\n }\n if (option.resolutionInSeconds) {\n descriptor.resolutionInSeconds = option.resolutionInSeconds\n }\n }\n super(descriptor)\n }\n}\n\nexport class Counter extends Metric {\n add(ctx: BaseContext, value: Numberish, labels: Labels = {}) {\n this.record(ctx, value, labels, true)\n }\n\n sub(ctx: BaseContext, value: Numberish, labels: Labels = {}) {\n this.record(ctx, value, labels, false)\n }\n\n private record(ctx: BaseContext, value: Numberish, labels: Labels, add: boolean) {\n ctx.counters.push({\n metadata: ctx.getMetaData(this.getShortDescriptor(), labels),\n metricValue: toMetricValue(value),\n add: add,\n runtimeInfo: undefined,\n })\n this.usage++\n }\n}\n\nexport class CounterBinding {\n private readonly ctx: BaseContext\n private readonly counter: Counter\n\n constructor(name: string, ctx: BaseContext) {\n this.counter = new Counter(name)\n this.ctx = ctx\n }\n\n add(value: Numberish, labels: Labels = {}) {\n this.counter.add(this.ctx, value, labels)\n }\n\n sub(value: Numberish, labels: Labels = {}) {\n this.counter.sub(this.ctx, value, labels)\n }\n}\n\nexport class Gauge extends Metric {\n record(ctx: BaseContext, value: Numberish, labels: Labels = {}) {\n ctx.gauges.push({\n metadata: ctx.getMetaData(this.getShortDescriptor(), labels),\n metricValue: toMetricValue(value),\n runtimeInfo: undefined,\n })\n this.usage++\n }\n}\n\nexport class GaugeBinding {\n private readonly gauge: Gauge\n private readonly ctx: BaseContext\n\n constructor(name: string, ctx: BaseContext) {\n this.gauge = new Gauge(name)\n this.ctx = ctx\n }\n\n record(value: Numberish, labels: Labels = {}) {\n this.gauge.record(this.ctx, value, labels)\n }\n}\n\nexport class Meter {\n private readonly ctx: BaseContext\n\n constructor(ctx: BaseContext) {\n this.ctx = ctx\n }\n\n Counter(name: string): CounterBinding {\n return new CounterBinding(name, this.ctx)\n }\n\n Gauge(name: string): GaugeBinding {\n return new GaugeBinding(name, this.ctx)\n }\n}\n"]}
1
+ {"version":3,"file":"meter.js","sourceRoot":"","sources":["../../src/core/meter.ts"],"names":[],"mappings":";;;AACA,2CAAsD;AACtD,yCAAwD;AACxD,gCAAuC;AAEvC,SAAgB,aAAa,CAAC,IAAY;IACxC,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,gBAAgB,CAAC,CAAA;IAC1C,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;AAC/C,CAAC;AAHD,sCAGC;AAED,SAAgB,YAAY,CAAC,IAAY;IACvC,IAAI,IAAI,KAAK,QAAQ,EAAE;QACrB,OAAO,SAAS,CAAA;KACjB;IACD,OAAO,aAAa,CAAC,IAAI,CAAC,CAAA;AAC5B,CAAC;AALD,oCAKC;AAED,SAAgB,cAAc,CAAC,IAAY;IACzC,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;AAC3B,CAAC;AAFD,wCAEC;AAED,SAAgB,eAAe,CAAC,MAAc;IAC5C,MAAM,UAAU,GAAW,EAAE,CAAA;IAC7B,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE;QACxB,UAAU,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,GAAG,cAAc,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;KAC5D;IACD,OAAO,UAAU,CAAA;AACnB,CAAC;AAND,0CAMC;AAED,MAAa,uBAAuB;IAClC,IAAI,CAAS;IACb,WAAW,CAAS;IACpB,MAAM,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CAAC,CAAA;QAC5B,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;IAChB,CAAC;IAED,MAAM,CAAC,KAAgB,EAAE,SAAiB,EAAE;QAC1C,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,CAAA;IAC5C,CAAC;CACF;AAZD,oCAYC;AAED,MAAa,KAAK;IACC,GAAG,CAAa;IAEjC,YAAY,GAAgB;QAC1B,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;IAChB,CAAC;IAED,OAAO,CAAC,IAAY;QAClB,OAAO,IAAI,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAA;IAC3C,CAAC;IAED,KAAK,CAAC,IAAY;QAChB,OAAO,IAAI,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAA;IACzC,CAAC;CACF;AAdD,sBAcC","sourcesContent":["import { BaseContext } from './context'\nimport { toMetricValue, Numberish } from './numberish'\nimport { DescriptorWithUsage, Labels } from './metadata'\nimport { DataDescriptor } from '../gen'\n\nexport function normalizeName(name: string): string {\n const regex = new RegExp('![_.a-zA-Z0-9]')\n return name.slice(0, 100).replace(regex, '_')\n}\n\nexport function normalizeKey(name: string): string {\n if (name === 'labels') {\n return 'labels_'\n }\n return normalizeName(name)\n}\n\nexport function normalizeValue(name: string): string {\n return name.slice(0, 100)\n}\n\nexport function normalizeLabels(labels: Labels): Labels {\n const normLabels: Labels = {}\n for (const key in labels) {\n normLabels[normalizeKey(key)] = normalizeValue(labels[key])\n }\n return normLabels\n}\n\nexport class MetricDescriptorOptions {\n unit?: string\n description?: string\n sparse?: boolean\n resolutionInSeconds?: number\n}\n\nexport class Metric extends DescriptorWithUsage {\n constructor(name: string, option?: MetricDescriptorOptions) {\n const descriptor = DataDescriptor.fromPartial({ name })\n if (option) {\n if (option.unit) {\n descriptor.unit = option.unit\n }\n if (option.description) {\n descriptor.description = option.description\n }\n if (option.sparse) {\n descriptor.sparse = option.sparse\n }\n if (option.resolutionInSeconds) {\n descriptor.resolutionInSeconds = option.resolutionInSeconds\n }\n }\n super(descriptor)\n }\n}\n\nexport class Counter extends Metric {\n add(ctx: BaseContext, value: Numberish, labels: Labels = {}) {\n this.record(ctx, value, labels, true)\n }\n\n sub(ctx: BaseContext, value: Numberish, labels: Labels = {}) {\n this.record(ctx, value, labels, false)\n }\n\n private record(ctx: BaseContext, value: Numberish, labels: Labels, add: boolean) {\n ctx.res.counters.push({\n metadata: ctx.getMetaData(this.getShortDescriptor(), labels),\n metricValue: toMetricValue(value),\n add: add,\n runtimeInfo: undefined,\n })\n this.usage++\n }\n}\n\nexport class CounterBinding {\n private readonly ctx: BaseContext\n private readonly counter: Counter\n\n constructor(name: string, ctx: BaseContext) {\n this.counter = new Counter(name)\n this.ctx = ctx\n }\n\n add(value: Numberish, labels: Labels = {}) {\n this.counter.add(this.ctx, value, labels)\n }\n\n sub(value: Numberish, labels: Labels = {}) {\n this.counter.sub(this.ctx, value, labels)\n }\n}\n\nexport class Gauge extends Metric {\n record(ctx: BaseContext, value: Numberish, labels: Labels = {}) {\n ctx.res.gauges.push({\n metadata: ctx.getMetaData(this.getShortDescriptor(), labels),\n metricValue: toMetricValue(value),\n runtimeInfo: undefined,\n })\n this.usage++\n }\n}\n\nexport class GaugeBinding {\n private readonly gauge: Gauge\n private readonly ctx: BaseContext\n\n constructor(name: string, ctx: BaseContext) {\n this.gauge = new Gauge(name)\n this.ctx = ctx\n }\n\n record(value: Numberish, labels: Labels = {}) {\n this.gauge.record(this.ctx, value, labels)\n }\n}\n\nexport class Meter {\n private readonly ctx: BaseContext\n\n constructor(ctx: BaseContext) {\n this.ctx = ctx\n }\n\n Counter(name: string): CounterBinding {\n return new CounterBinding(name, this.ctx)\n }\n\n Gauge(name: string): GaugeBinding {\n return new GaugeBinding(name, this.ctx)\n }\n}\n"]}
@@ -39,6 +39,7 @@ export interface ProcessConfigResponse {
39
39
  accountConfigs: AccountConfig[];
40
40
  metricConfigs: MetricConfig[];
41
41
  eventTrackingConfigs: EventTrackingConfig[];
42
+ exportConfigs: ExportConfig[];
42
43
  }
43
44
  export interface ContractConfig {
44
45
  contract: ContractInfo | undefined;
@@ -73,6 +74,17 @@ export interface EventTrackingConfig {
73
74
  distinctAggregationByDays: number[];
74
75
  retentionConfig: RetentionConfig | undefined;
75
76
  }
77
+ export interface ExportConfig {
78
+ exportName: string;
79
+ exportType: ExportConfig_ExportType;
80
+ exportUrl: string;
81
+ }
82
+ export declare enum ExportConfig_ExportType {
83
+ WEBHOOK = 0,
84
+ UNRECOGNIZED = -1
85
+ }
86
+ export declare function exportConfig_ExportTypeFromJSON(object: any): ExportConfig_ExportType;
87
+ export declare function exportConfig_ExportTypeToJSON(object: ExportConfig_ExportType): string;
76
88
  export interface MetricConfig {
77
89
  name: string;
78
90
  description: string;
@@ -84,11 +96,17 @@ export interface AccountConfig {
84
96
  chainId: string;
85
97
  address: string;
86
98
  startBlock: Long;
87
- aptosOnVersionConfigs: AptosOnVersionConfig[];
99
+ onIntervalConfigs: OnIntervalConfig[];
100
+ onAptosIntervalConfigs: AptosOnIntervalConfig[];
88
101
  }
89
- export interface AptosOnVersionConfig {
102
+ export interface OnIntervalConfig {
90
103
  handlerId: number;
91
- step: number;
104
+ minutes: number;
105
+ slot: number;
106
+ }
107
+ export interface AptosOnIntervalConfig {
108
+ intervalConfig: OnIntervalConfig | undefined;
109
+ type: string;
92
110
  }
93
111
  export interface ContractInfo {
94
112
  name: string;
@@ -194,6 +212,7 @@ export interface ProcessResult {
194
212
  counters: CounterResult[];
195
213
  logs: LogResult[];
196
214
  events: EventTrackingResult[];
215
+ exports: ExportResult[];
197
216
  }
198
217
  export interface DataDescriptor {
199
218
  name: string;
@@ -256,6 +275,11 @@ export interface EventTrackingResult {
256
275
  attributes: string;
257
276
  runtimeInfo: RuntimeInfo | undefined;
258
277
  }
278
+ export interface ExportResult {
279
+ metadata: RecordMetaData | undefined;
280
+ payload: string;
281
+ runtimeInfo: RuntimeInfo | undefined;
282
+ }
259
283
  export declare const ProjectConfig: {
260
284
  encode(message: ProjectConfig, writer?: _m0.Writer): _m0.Writer;
261
285
  decode(input: _m0.Reader | Uint8Array, length?: number): ProjectConfig;
@@ -305,6 +329,13 @@ export declare const EventTrackingConfig: {
305
329
  toJSON(message: EventTrackingConfig): unknown;
306
330
  fromPartial(object: DeepPartial<EventTrackingConfig>): EventTrackingConfig;
307
331
  };
332
+ export declare const ExportConfig: {
333
+ encode(message: ExportConfig, writer?: _m0.Writer): _m0.Writer;
334
+ decode(input: _m0.Reader | Uint8Array, length?: number): ExportConfig;
335
+ fromJSON(object: any): ExportConfig;
336
+ toJSON(message: ExportConfig): unknown;
337
+ fromPartial(object: DeepPartial<ExportConfig>): ExportConfig;
338
+ };
308
339
  export declare const MetricConfig: {
309
340
  encode(message: MetricConfig, writer?: _m0.Writer): _m0.Writer;
310
341
  decode(input: _m0.Reader | Uint8Array, length?: number): MetricConfig;
@@ -319,12 +350,19 @@ export declare const AccountConfig: {
319
350
  toJSON(message: AccountConfig): unknown;
320
351
  fromPartial(object: DeepPartial<AccountConfig>): AccountConfig;
321
352
  };
322
- export declare const AptosOnVersionConfig: {
323
- encode(message: AptosOnVersionConfig, writer?: _m0.Writer): _m0.Writer;
324
- decode(input: _m0.Reader | Uint8Array, length?: number): AptosOnVersionConfig;
325
- fromJSON(object: any): AptosOnVersionConfig;
326
- toJSON(message: AptosOnVersionConfig): unknown;
327
- fromPartial(object: DeepPartial<AptosOnVersionConfig>): AptosOnVersionConfig;
353
+ export declare const OnIntervalConfig: {
354
+ encode(message: OnIntervalConfig, writer?: _m0.Writer): _m0.Writer;
355
+ decode(input: _m0.Reader | Uint8Array, length?: number): OnIntervalConfig;
356
+ fromJSON(object: any): OnIntervalConfig;
357
+ toJSON(message: OnIntervalConfig): unknown;
358
+ fromPartial(object: DeepPartial<OnIntervalConfig>): OnIntervalConfig;
359
+ };
360
+ export declare const AptosOnIntervalConfig: {
361
+ encode(message: AptosOnIntervalConfig, writer?: _m0.Writer): _m0.Writer;
362
+ decode(input: _m0.Reader | Uint8Array, length?: number): AptosOnIntervalConfig;
363
+ fromJSON(object: any): AptosOnIntervalConfig;
364
+ toJSON(message: AptosOnIntervalConfig): unknown;
365
+ fromPartial(object: DeepPartial<AptosOnIntervalConfig>): AptosOnIntervalConfig;
328
366
  };
329
367
  export declare const ContractInfo: {
330
368
  encode(message: ContractInfo, writer?: _m0.Writer): _m0.Writer;
@@ -571,6 +609,13 @@ export declare const EventTrackingResult: {
571
609
  toJSON(message: EventTrackingResult): unknown;
572
610
  fromPartial(object: DeepPartial<EventTrackingResult>): EventTrackingResult;
573
611
  };
612
+ export declare const ExportResult: {
613
+ encode(message: ExportResult, writer?: _m0.Writer): _m0.Writer;
614
+ decode(input: _m0.Reader | Uint8Array, length?: number): ExportResult;
615
+ fromJSON(object: any): ExportResult;
616
+ toJSON(message: ExportResult): unknown;
617
+ fromPartial(object: DeepPartial<ExportResult>): ExportResult;
618
+ };
574
619
  export declare type ProcessorDefinition = typeof ProcessorDefinition;
575
620
  export declare const ProcessorDefinition: {
576
621
  readonly name: "Processor";