diff --git a/example.js b/example.js index 8803860..a8e68e2 100644 --- a/example.js +++ b/example.js @@ -1,9 +1,9 @@ -const { Substreams, download, unpack } = require("./"); +const { Substreams, download } = require("./"); // User parameters -const url = "https://github.com/pinax-network/subtivity-substreams/releases/download/v0.2.0/subtivity-ethereum-v0.2.0.spkg"; -const outputModule = "map_block_stats"; -const startBlockNum = "300000"; +const url = "https://github.com/streamingfast/substreams-ethereum-quickstart/releases/download/1.0.0/substreams-ethereum-quickstart-v1.0.0.spkg"; +const outputModule = "map_block"; +const startBlockNum = "12292922"; const stopBlockNum = "+10"; (async () => { @@ -16,21 +16,15 @@ const stopBlockNum = "+10"; stopBlockNum, authorization: process.env.SUBSTREAMS_API_TOKEN }); - - // Find Protobuf message types from registry - const { registry } = unpack(spkg); - const BlockStats = registry.findMessage("subtivity.v1.BlockStats"); - if ( !BlockStats) throw new Error("Could not find BlockStats message type"); // first block received substreams.on("start", (cursor, clock) => { console.log({status: "start", cursor, clock}); }); - // on every map output received - substreams.on("mapOutput", (output, clock) => { - const decoded = BlockStats.fromBinary(output.data.value.value); - console.log({decoded, clock}); + // stream of decoded MapOutputs + substreams.on("anyMessage", (message) => { + console.log({message}); }); // end of stream @@ -38,11 +32,6 @@ const stopBlockNum = "+10"; console.log({status: "end", cursor, clock}); }); - // head block time drift - substreams.on("head_block_time_drift", (seconds) => { - console.log({head_block_time_drift: seconds}); - }); - // start streaming Substream substreams.start(); })(); \ No newline at end of file diff --git a/examples/subtivity.ts b/examples/subtivity.ts index c7e6182..6ad2d4d 100644 --- a/examples/subtivity.ts +++ b/examples/subtivity.ts @@ -20,8 +20,8 @@ const authorization = process.env.SUBSTREAMS_API_TOKEN; substreams.on("start", (cursor, clock) => { console.log({status: "start", cursor, clock}); }); - substreams.on("mapOutput", (mapOutput, clock) => { - console.log({mapOutput, clock}); + substreams.on("anyMessage", (message, clock) => { + console.log({message, clock}); }); substreams.start(); })(); \ No newline at end of file diff --git a/package.json b/package.json index 8af48cd..b3ee4e5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "substreams", "description": "Substreams Javascript consumer", - "version": "0.4.2", + "version": "0.5.0", "homepage": "https://github.com/pinax-network/substreams-js", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/proto/pinax/substreams/sink/prometheus/v1/prometheus.proto b/proto/pinax/substreams/sink/prometheus/v1/prometheus.proto new file mode 100644 index 0000000..80b9bc7 --- /dev/null +++ b/proto/pinax/substreams/sink/prometheus/v1/prometheus.proto @@ -0,0 +1,101 @@ +syntax = "proto3"; + +package pinax.substreams.sink.prometheus.v1; + +// Vector of Prometheus metrics +message PrometheusOperations { + repeated PrometheusOperation operations = 1; +} + +message PrometheusOperation { + string name = 1; // Name of the Prometheus metric + map labels = 2; // Labels represents a collection of label name -> value mappings. + oneof operation { + GaugeOp gauge = 3; + CounterOp counter = 4; + HistogramOp histogram = 5; + SummaryOp summary = 6; + } +} + +message GaugeOp { + enum Operation { + // Protobuf default should not be used, this is used so that the consume can ensure that the value was actually specified + OPERATION_UNSPECIFIED = 0; + // Inc increments the Gauge by 1. Use Add to increment it by arbitrary values. + OPERATION_INC = 1; + // Add adds the given value to the Gauge. (The value can be negative, resulting in a decrease of the Gauge.) + OPERATION_ADD = 2; // float + // Set sets the Gauge to an arbitrary value. + OPERATION_SET = 3; // float + // Dec decrements the Gauge by 1. Use Sub to decrement it by arbitrary values. + OPERATION_DEC = 4; + // Sub subtracts the given value from the Gauge. (The value can be negative, resulting in an increase of the Gauge.) + OPERATION_SUB = 5; // float + // SetToCurrentTime sets the Gauge to the current Unix time in seconds. + OPERATION_SET_TO_CURRENT_TIME = 6; + // Remove metrics for the given label values + OPERATION_REMOVE = 7; + // Reset gauge values + OPERATION_RESET = 8; + } + Operation operation = 1; + double value = 2; // Value (Float) to be used in the operation +} + +message CounterOp { + enum Operation { + // Protobuf default should not be used, this is used so that the consume can ensure that the value was actually specified + OPERATION_UNSPECIFIED = 0; + // Increments the Counter by 1. + OPERATION_INC = 1; + // Adds an arbitrary value to a Counter. (Returns an error if the value is < 0.) + OPERATION_ADD = 2; // float + // Remove metrics for the given label values + OPERATION_REMOVE = 7; + // Reset counter values + OPERATION_RESET = 8; + } + Operation operation = 1; + double value = 2; // Value (Float) to be used in the operation +} + +message SummaryOp { + enum Operation { + // Protobuf default should not be used, this is used so that the consume can ensure that the value was actually specified + OPERATION_UNSPECIFIED = 0; + // Observe adds a single observation to the summary. + // Observations are usually positive or zero. + // Negative observations are accepted but prevent current versions of Prometheus from properly detecting counter resets in the sum of observations + OPERATION_OBSERVE = 1; + // Start a timer. Calling the returned function will observe the duration in seconds in the summary. + OPERATION_START_TIMER = 2; + // Remove metrics for the given label values + OPERATION_REMOVE = 7; + // Reset counter values + OPERATION_RESET = 8; + } + Operation operation = 1; + double value = 2; // Value (Float) to be used in the operation +} + +message HistogramOp { + enum Operation { + // Protobuf default should not be used, this is used so that the consume can ensure that the value was actually specified + OPERATION_UNSPECIFIED = 0; + // Observe adds a single observation to the histogram. + // Observations are usually positive or zero. + // Negative observations are accepted but prevent current versions of Prometheus from properly detecting counter resets in the sum of observations. + OPERATION_OBSERVE = 1; + // Start a timer. Calling the returned function will observe the duration in seconds in the summary. + OPERATION_START_TIMER = 2; + // Initialize the metrics for the given combination of labels to zero + OPERATION_ZERO = 3; + // Remove metrics for the given label values + OPERATION_REMOVE = 7; + // Reset counter values + OPERATION_RESET = 8; + } + Operation operation = 1; + double value = 2; // Value (Float) to be used in the operation +} \ No newline at end of file diff --git a/proto/pinax/substreams/sink/winston/v1/winston.proto b/proto/pinax/substreams/sink/winston/v1/winston.proto new file mode 100644 index 0000000..23b64c2 --- /dev/null +++ b/proto/pinax/substreams/sink/winston/v1/winston.proto @@ -0,0 +1,33 @@ +syntax = "proto3"; + +package pinax.substreams.sink.winston.v1; + +option go_package = "github.com/pinax-network/substreams-sink-winston/pb;pbkv"; + +// Vector of Winston Logging messages +message LoggerOperations { + repeated LoggerOperation operations = 1; +} + +message LoggerOperation { + string service = 1; + LoggingLevels level = 2; + string message = 3; + map meta = 4; +} + +// Each level is given a specific integer priority. +// The higher the priority the more important the message is considered to be, +// and the lower the corresponding integer priority. +// For example, as specified exactly in RFC5424 the syslog levels are prioritized from 0 to 7 (highest to lowest). +enum LoggingLevels { + // UNSPECIFIED = 0; // Unspecified: default value + EMERG = 0; // Emergency: system is unusable + ALERT = 1; // Alert: action must be taken immediately + CRIT = 2; // Critical: critical conditions + ERROR = 3; // Error: error conditions + WARNING = 4; // Warning: warning conditions + NOTICE = 5; // Notice: normal but significant condition + INFO = 6; // Informational: informational messages + DEBUG = 7; // Debug: debug-level messages +} \ No newline at end of file diff --git a/proto/sf/substreams/sink/database/v1/database.proto b/proto/sf/substreams/sink/database/v1/database.proto new file mode 100644 index 0000000..7daf85e --- /dev/null +++ b/proto/sf/substreams/sink/database/v1/database.proto @@ -0,0 +1,29 @@ +syntax = "proto3"; + +package sf.substreams.sink.database.v1; + +option go_package = "github.com/streamingfast/substreams-database-change/pb;pbdatabase"; + +message DatabaseChanges { + repeated TableChange table_changes = 1; +} + +message TableChange { + string table = 1; + string pk = 2; + uint64 ordinal = 3; + enum Operation { + UNSET = 0; // Protobuf default should not be used, this is used so that the consume can ensure that the value was actually specified + CREATE = 1; + UPDATE = 2; + DELETE = 3; + } + Operation operation = 4; + repeated Field fields = 5; +} + +message Field { + string name = 1; + string new_value = 2; + string old_value = 3; +} \ No newline at end of file diff --git a/proto/sf/substreams/sink/entity/v1/entity.proto b/proto/sf/substreams/sink/entity/v1/entity.proto new file mode 100644 index 0000000..c16bdc1 --- /dev/null +++ b/proto/sf/substreams/sink/entity/v1/entity.proto @@ -0,0 +1,46 @@ +syntax = "proto3"; + +package sf.substreams.entity.v1; + +message EntityChanges { + repeated EntityChange entity_changes = 5; +} + +message EntityChange { + string entity = 1; + string id = 2; + uint64 ordinal = 3; + enum Operation { + UNSET = 0; // Protobuf default should not be used, this is used so that the consume can ensure that the value was actually specified + CREATE = 1; + UPDATE = 2; + DELETE = 3; + } + Operation operation = 4; + repeated Field fields = 5; +} + +message Value { + oneof typed { + int32 int32 = 1; + string bigdecimal = 2; + string bigint = 3; + string string = 4; + string bytes = 5; + bool bool = 6; + + //reserved 7 to 9; // For future types + + Array array = 10; + } +} + +message Array { + repeated Value value = 1; +} + +message Field { + string name = 1; + optional Value new_value = 3; + optional Value old_value = 5; +} \ No newline at end of file diff --git a/proto/sf/substreams/sink/kv/v1/kv.proto b/proto/sf/substreams/sink/kv/v1/kv.proto new file mode 100644 index 0000000..0b946a5 --- /dev/null +++ b/proto/sf/substreams/sink/kv/v1/kv.proto @@ -0,0 +1,21 @@ +syntax = "proto3"; + +package sf.substreams.sink.kv.v1; + +option go_package = "github.com/streamingfast/substreams-sink-kv/pb;pbkv"; + +message KVOperations { + repeated KVOperation operations = 1; +} + +message KVOperation { + string key = 1; + bytes value = 2; + uint64 ordinal = 3; + enum Type { + UNSET = 0; // Protobuf default should not be used, this is used so that the consume can ensure that the value was actually specified + SET = 1; + DELETE = 2; + } + Type type = 4; +} \ No newline at end of file diff --git a/proto/sf/substreams/sink/kv/v1/read.proto b/proto/sf/substreams/sink/kv/v1/read.proto new file mode 100644 index 0000000..d61fe46 --- /dev/null +++ b/proto/sf/substreams/sink/kv/v1/read.proto @@ -0,0 +1,94 @@ +syntax = "proto3"; + +package sf.substreams.sink.kv.v1; + +option go_package = "github.com/streamingfast/substreams-sink-kv/pb;pbkv"; + +service Kv { + + // Get returns the requested value as bytes if it exists, grpc_error: NOT_FOUND otherwise. + rpc Get(GetRequest) returns (GetResponse); + + // GetMany returns the requested values as bytes if all of them exists, grpc_error: NOT_FOUND otherwise. + rpc GetMany(GetManyRequest) returns (GetManyResponse); + + // GetByPrefix returns the next _limit_ key/value pair that match the requested prefix if any exist, grpc_error: NOT_FOUND otherwise. + rpc GetByPrefix(GetByPrefixRequest) returns (GetByPrefixResponse); + + // Scan returns then next _limit_ key/value pairs starting lexicographically at the given key, grpc_error: NOT_FOUND otherwise. + rpc Scan(ScanRequest) returns (ScanResponse); + +} + +message GetRequest { + + // Key to fetch + string key = 1; +} + + +message GetManyRequest { + + // Keys to fetch + repeated string keys = 1; +} + +message GetByPrefixRequest { + + // server may impose a hard limit, trying to go above it would return grpc_error: INVALID_ARGUMENT + uint64 limit = 1; + + // requested prefix + string prefix = 2; +} + +message ScanRequest { + + // server may impose a hard limit, trying to go above it would return grpc_error: INVALID_ARGUMENT + uint64 limit = 1; + + // scanning will start at this point, lexicographically + string begin = 2; + + // If set, scanning will stop when it reaches this point or above, excluding this exact key + optional string exclusive_end = 3; +} + + +message GetResponse { + + // Value that was found for the requested key + bytes value = 1; +} + + +message GetManyResponse { + + // Values that were found for the requested keys + repeated bytes values = 1; +} + +message GetByPrefixResponse { + + // KV are the key/value pairs that were found with the given prefix + repeated KV key_values = 1; + + // limit_reached is true if there is at least ONE MORE result than the requested limit + bool limit_reached = 2; +} + +message ScanResponse { + + // KV are the key/value pairs that were found during scan + repeated KV key_values = 1; + + // limit_reached is true if there is at least ONE MORE result than the requested limit + bool limit_reached = 2; +} + + + +message KV { + string key = 1; + bytes value = 2; +} diff --git a/proto/sf/substreams/sink/kv/v1/services.proto b/proto/sf/substreams/sink/kv/v1/services.proto new file mode 100644 index 0000000..8503f58 --- /dev/null +++ b/proto/sf/substreams/sink/kv/v1/services.proto @@ -0,0 +1,26 @@ +syntax = "proto3"; +package sf.substreams.sink.kv.v1; + +option go_package = "github.com/streamingfast/substreams-sink-kv/pb;pbkv"; + + +message Config { + int64 start_block = 1; + string input_module = 2; +} + +// This defines a KV Sink to be queried with a generic key access interface (Get, GetMany, Scan, Prefix calls). +message GenericService { + Config sink_config = 1; +} + +// This defines configuration to run a WASM query service on top of the KV store being sync'd. +message WASMQueryService { + Config sink_config = 1; + + // wasm exports: "kv_get_batch", "kv_get", "kv_scan", "kv_prefix" + bytes wasm_query_module = 5; + + // Fully qualified Protobuf Service definition name + string grpc_service = 2; // sf.mycustom.v1.MyService +} \ No newline at end of file diff --git a/proto/sf/substreams/sink/kv/v1/types.proto b/proto/sf/substreams/sink/kv/v1/types.proto new file mode 100644 index 0000000..ba0f50b --- /dev/null +++ b/proto/sf/substreams/sink/kv/v1/types.proto @@ -0,0 +1,18 @@ +syntax = "proto3"; + +package sf.substreams.sink.types.v1; + +option go_package = "github.com/streamingfast/substreams-sink-kv/pb;pbkv"; + +message KVPairs { + repeated KVPair pairs = 2; +} + +message KVPair { + string key = 1; + bytes value = 2; +} + +message KVKeys { + repeated string keys = 1; +} \ No newline at end of file diff --git a/src/generated/pinax/substreams/sink/prometheus/v1/prometheus_pb.ts b/src/generated/pinax/substreams/sink/prometheus/v1/prometheus_pb.ts new file mode 100644 index 0000000..3d9166e --- /dev/null +++ b/src/generated/pinax/substreams/sink/prometheus/v1/prometheus_pb.ts @@ -0,0 +1,551 @@ +// @generated by protoc-gen-es v1.1.1 with parameter "target=ts" +// @generated from file pinax/substreams/sink/prometheus/v1/prometheus.proto (package pinax.substreams.sink.prometheus.v1, syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; +import { Message, proto3 } from "@bufbuild/protobuf"; + +/** + * Vector of Prometheus metrics + * + * @generated from message pinax.substreams.sink.prometheus.v1.PrometheusOperations + */ +export class PrometheusOperations extends Message { + /** + * @generated from field: repeated pinax.substreams.sink.prometheus.v1.PrometheusOperation operations = 1; + */ + operations: PrometheusOperation[] = []; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "pinax.substreams.sink.prometheus.v1.PrometheusOperations"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "operations", kind: "message", T: PrometheusOperation, repeated: true }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): PrometheusOperations { + return new PrometheusOperations().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): PrometheusOperations { + return new PrometheusOperations().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): PrometheusOperations { + return new PrometheusOperations().fromJsonString(jsonString, options); + } + + static equals(a: PrometheusOperations | PlainMessage | undefined, b: PrometheusOperations | PlainMessage | undefined): boolean { + return proto3.util.equals(PrometheusOperations, a, b); + } +} + +/** + * @generated from message pinax.substreams.sink.prometheus.v1.PrometheusOperation + */ +export class PrometheusOperation extends Message { + /** + * Name of the Prometheus metric + * + * @generated from field: string name = 1; + */ + name = ""; + + /** + * Labels represents a collection of label name -> value mappings. + * + * @generated from field: map labels = 2; + */ + labels: { [key: string]: string } = {}; + + /** + * @generated from oneof pinax.substreams.sink.prometheus.v1.PrometheusOperation.operation + */ + operation: { + /** + * @generated from field: pinax.substreams.sink.prometheus.v1.GaugeOp gauge = 3; + */ + value: GaugeOp; + case: "gauge"; + } | { + /** + * @generated from field: pinax.substreams.sink.prometheus.v1.CounterOp counter = 4; + */ + value: CounterOp; + case: "counter"; + } | { + /** + * @generated from field: pinax.substreams.sink.prometheus.v1.HistogramOp histogram = 5; + */ + value: HistogramOp; + case: "histogram"; + } | { + /** + * @generated from field: pinax.substreams.sink.prometheus.v1.SummaryOp summary = 6; + */ + value: SummaryOp; + case: "summary"; + } | { case: undefined; value?: undefined } = { case: undefined }; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "pinax.substreams.sink.prometheus.v1.PrometheusOperation"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "name", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "labels", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "scalar", T: 9 /* ScalarType.STRING */} }, + { no: 3, name: "gauge", kind: "message", T: GaugeOp, oneof: "operation" }, + { no: 4, name: "counter", kind: "message", T: CounterOp, oneof: "operation" }, + { no: 5, name: "histogram", kind: "message", T: HistogramOp, oneof: "operation" }, + { no: 6, name: "summary", kind: "message", T: SummaryOp, oneof: "operation" }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): PrometheusOperation { + return new PrometheusOperation().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): PrometheusOperation { + return new PrometheusOperation().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): PrometheusOperation { + return new PrometheusOperation().fromJsonString(jsonString, options); + } + + static equals(a: PrometheusOperation | PlainMessage | undefined, b: PrometheusOperation | PlainMessage | undefined): boolean { + return proto3.util.equals(PrometheusOperation, a, b); + } +} + +/** + * @generated from message pinax.substreams.sink.prometheus.v1.GaugeOp + */ +export class GaugeOp extends Message { + /** + * @generated from field: pinax.substreams.sink.prometheus.v1.GaugeOp.Operation operation = 1; + */ + operation = GaugeOp_Operation.UNSPECIFIED; + + /** + * Value (Float) to be used in the operation + * + * @generated from field: double value = 2; + */ + value = 0; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "pinax.substreams.sink.prometheus.v1.GaugeOp"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "operation", kind: "enum", T: proto3.getEnumType(GaugeOp_Operation) }, + { no: 2, name: "value", kind: "scalar", T: 1 /* ScalarType.DOUBLE */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): GaugeOp { + return new GaugeOp().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): GaugeOp { + return new GaugeOp().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): GaugeOp { + return new GaugeOp().fromJsonString(jsonString, options); + } + + static equals(a: GaugeOp | PlainMessage | undefined, b: GaugeOp | PlainMessage | undefined): boolean { + return proto3.util.equals(GaugeOp, a, b); + } +} + +/** + * @generated from enum pinax.substreams.sink.prometheus.v1.GaugeOp.Operation + */ +export enum GaugeOp_Operation { + /** + * Protobuf default should not be used, this is used so that the consume can ensure that the value was actually specified + * + * @generated from enum value: OPERATION_UNSPECIFIED = 0; + */ + UNSPECIFIED = 0, + + /** + * Inc increments the Gauge by 1. Use Add to increment it by arbitrary values. + * + * @generated from enum value: OPERATION_INC = 1; + */ + INC = 1, + + /** + * Add adds the given value to the Gauge. (The value can be negative, resulting in a decrease of the Gauge.) + * + * float + * + * @generated from enum value: OPERATION_ADD = 2; + */ + ADD = 2, + + /** + * Set sets the Gauge to an arbitrary value. + * + * float + * + * @generated from enum value: OPERATION_SET = 3; + */ + SET = 3, + + /** + * Dec decrements the Gauge by 1. Use Sub to decrement it by arbitrary values. + * + * @generated from enum value: OPERATION_DEC = 4; + */ + DEC = 4, + + /** + * Sub subtracts the given value from the Gauge. (The value can be negative, resulting in an increase of the Gauge.) + * + * float + * + * @generated from enum value: OPERATION_SUB = 5; + */ + SUB = 5, + + /** + * SetToCurrentTime sets the Gauge to the current Unix time in seconds. + * + * @generated from enum value: OPERATION_SET_TO_CURRENT_TIME = 6; + */ + SET_TO_CURRENT_TIME = 6, + + /** + * Remove metrics for the given label values + * + * @generated from enum value: OPERATION_REMOVE = 7; + */ + REMOVE = 7, + + /** + * Reset gauge values + * + * @generated from enum value: OPERATION_RESET = 8; + */ + RESET = 8, +} +// Retrieve enum metadata with: proto3.getEnumType(GaugeOp_Operation) +proto3.util.setEnumType(GaugeOp_Operation, "pinax.substreams.sink.prometheus.v1.GaugeOp.Operation", [ + { no: 0, name: "OPERATION_UNSPECIFIED" }, + { no: 1, name: "OPERATION_INC" }, + { no: 2, name: "OPERATION_ADD" }, + { no: 3, name: "OPERATION_SET" }, + { no: 4, name: "OPERATION_DEC" }, + { no: 5, name: "OPERATION_SUB" }, + { no: 6, name: "OPERATION_SET_TO_CURRENT_TIME" }, + { no: 7, name: "OPERATION_REMOVE" }, + { no: 8, name: "OPERATION_RESET" }, +]); + +/** + * @generated from message pinax.substreams.sink.prometheus.v1.CounterOp + */ +export class CounterOp extends Message { + /** + * @generated from field: pinax.substreams.sink.prometheus.v1.CounterOp.Operation operation = 1; + */ + operation = CounterOp_Operation.UNSPECIFIED; + + /** + * Value (Float) to be used in the operation + * + * @generated from field: double value = 2; + */ + value = 0; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "pinax.substreams.sink.prometheus.v1.CounterOp"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "operation", kind: "enum", T: proto3.getEnumType(CounterOp_Operation) }, + { no: 2, name: "value", kind: "scalar", T: 1 /* ScalarType.DOUBLE */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): CounterOp { + return new CounterOp().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): CounterOp { + return new CounterOp().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): CounterOp { + return new CounterOp().fromJsonString(jsonString, options); + } + + static equals(a: CounterOp | PlainMessage | undefined, b: CounterOp | PlainMessage | undefined): boolean { + return proto3.util.equals(CounterOp, a, b); + } +} + +/** + * @generated from enum pinax.substreams.sink.prometheus.v1.CounterOp.Operation + */ +export enum CounterOp_Operation { + /** + * Protobuf default should not be used, this is used so that the consume can ensure that the value was actually specified + * + * @generated from enum value: OPERATION_UNSPECIFIED = 0; + */ + UNSPECIFIED = 0, + + /** + * Increments the Counter by 1. + * + * @generated from enum value: OPERATION_INC = 1; + */ + INC = 1, + + /** + * Adds an arbitrary value to a Counter. (Returns an error if the value is < 0.) + * + * float + * + * @generated from enum value: OPERATION_ADD = 2; + */ + ADD = 2, + + /** + * Remove metrics for the given label values + * + * @generated from enum value: OPERATION_REMOVE = 7; + */ + REMOVE = 7, + + /** + * Reset counter values + * + * @generated from enum value: OPERATION_RESET = 8; + */ + RESET = 8, +} +// Retrieve enum metadata with: proto3.getEnumType(CounterOp_Operation) +proto3.util.setEnumType(CounterOp_Operation, "pinax.substreams.sink.prometheus.v1.CounterOp.Operation", [ + { no: 0, name: "OPERATION_UNSPECIFIED" }, + { no: 1, name: "OPERATION_INC" }, + { no: 2, name: "OPERATION_ADD" }, + { no: 7, name: "OPERATION_REMOVE" }, + { no: 8, name: "OPERATION_RESET" }, +]); + +/** + * @generated from message pinax.substreams.sink.prometheus.v1.SummaryOp + */ +export class SummaryOp extends Message { + /** + * @generated from field: pinax.substreams.sink.prometheus.v1.SummaryOp.Operation operation = 1; + */ + operation = SummaryOp_Operation.UNSPECIFIED; + + /** + * Value (Float) to be used in the operation + * + * @generated from field: double value = 2; + */ + value = 0; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "pinax.substreams.sink.prometheus.v1.SummaryOp"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "operation", kind: "enum", T: proto3.getEnumType(SummaryOp_Operation) }, + { no: 2, name: "value", kind: "scalar", T: 1 /* ScalarType.DOUBLE */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): SummaryOp { + return new SummaryOp().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): SummaryOp { + return new SummaryOp().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): SummaryOp { + return new SummaryOp().fromJsonString(jsonString, options); + } + + static equals(a: SummaryOp | PlainMessage | undefined, b: SummaryOp | PlainMessage | undefined): boolean { + return proto3.util.equals(SummaryOp, a, b); + } +} + +/** + * @generated from enum pinax.substreams.sink.prometheus.v1.SummaryOp.Operation + */ +export enum SummaryOp_Operation { + /** + * Protobuf default should not be used, this is used so that the consume can ensure that the value was actually specified + * + * @generated from enum value: OPERATION_UNSPECIFIED = 0; + */ + UNSPECIFIED = 0, + + /** + * Observe adds a single observation to the summary. + * Observations are usually positive or zero. + * Negative observations are accepted but prevent current versions of Prometheus from properly detecting counter resets in the sum of observations + * + * @generated from enum value: OPERATION_OBSERVE = 1; + */ + OBSERVE = 1, + + /** + * Start a timer. Calling the returned function will observe the duration in seconds in the summary. + * + * @generated from enum value: OPERATION_START_TIMER = 2; + */ + START_TIMER = 2, + + /** + * Remove metrics for the given label values + * + * @generated from enum value: OPERATION_REMOVE = 7; + */ + REMOVE = 7, + + /** + * Reset counter values + * + * @generated from enum value: OPERATION_RESET = 8; + */ + RESET = 8, +} +// Retrieve enum metadata with: proto3.getEnumType(SummaryOp_Operation) +proto3.util.setEnumType(SummaryOp_Operation, "pinax.substreams.sink.prometheus.v1.SummaryOp.Operation", [ + { no: 0, name: "OPERATION_UNSPECIFIED" }, + { no: 1, name: "OPERATION_OBSERVE" }, + { no: 2, name: "OPERATION_START_TIMER" }, + { no: 7, name: "OPERATION_REMOVE" }, + { no: 8, name: "OPERATION_RESET" }, +]); + +/** + * @generated from message pinax.substreams.sink.prometheus.v1.HistogramOp + */ +export class HistogramOp extends Message { + /** + * @generated from field: pinax.substreams.sink.prometheus.v1.HistogramOp.Operation operation = 1; + */ + operation = HistogramOp_Operation.UNSPECIFIED; + + /** + * Value (Float) to be used in the operation + * + * @generated from field: double value = 2; + */ + value = 0; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "pinax.substreams.sink.prometheus.v1.HistogramOp"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "operation", kind: "enum", T: proto3.getEnumType(HistogramOp_Operation) }, + { no: 2, name: "value", kind: "scalar", T: 1 /* ScalarType.DOUBLE */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): HistogramOp { + return new HistogramOp().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): HistogramOp { + return new HistogramOp().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): HistogramOp { + return new HistogramOp().fromJsonString(jsonString, options); + } + + static equals(a: HistogramOp | PlainMessage | undefined, b: HistogramOp | PlainMessage | undefined): boolean { + return proto3.util.equals(HistogramOp, a, b); + } +} + +/** + * @generated from enum pinax.substreams.sink.prometheus.v1.HistogramOp.Operation + */ +export enum HistogramOp_Operation { + /** + * Protobuf default should not be used, this is used so that the consume can ensure that the value was actually specified + * + * @generated from enum value: OPERATION_UNSPECIFIED = 0; + */ + UNSPECIFIED = 0, + + /** + * Observe adds a single observation to the histogram. + * Observations are usually positive or zero. + * Negative observations are accepted but prevent current versions of Prometheus from properly detecting counter resets in the sum of observations. + * + * @generated from enum value: OPERATION_OBSERVE = 1; + */ + OBSERVE = 1, + + /** + * Start a timer. Calling the returned function will observe the duration in seconds in the summary. + * + * @generated from enum value: OPERATION_START_TIMER = 2; + */ + START_TIMER = 2, + + /** + * Initialize the metrics for the given combination of labels to zero + * + * @generated from enum value: OPERATION_ZERO = 3; + */ + ZERO = 3, + + /** + * Remove metrics for the given label values + * + * @generated from enum value: OPERATION_REMOVE = 7; + */ + REMOVE = 7, + + /** + * Reset counter values + * + * @generated from enum value: OPERATION_RESET = 8; + */ + RESET = 8, +} +// Retrieve enum metadata with: proto3.getEnumType(HistogramOp_Operation) +proto3.util.setEnumType(HistogramOp_Operation, "pinax.substreams.sink.prometheus.v1.HistogramOp.Operation", [ + { no: 0, name: "OPERATION_UNSPECIFIED" }, + { no: 1, name: "OPERATION_OBSERVE" }, + { no: 2, name: "OPERATION_START_TIMER" }, + { no: 3, name: "OPERATION_ZERO" }, + { no: 7, name: "OPERATION_REMOVE" }, + { no: 8, name: "OPERATION_RESET" }, +]); + diff --git a/src/generated/pinax/substreams/sink/winston/v1/winston_pb.ts b/src/generated/pinax/substreams/sink/winston/v1/winston_pb.ts new file mode 100644 index 0000000..723bee4 --- /dev/null +++ b/src/generated/pinax/substreams/sink/winston/v1/winston_pb.ts @@ -0,0 +1,181 @@ +// @generated by protoc-gen-es v1.1.1 with parameter "target=ts" +// @generated from file pinax/substreams/sink/winston/v1/winston.proto (package pinax.substreams.sink.winston.v1, syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; +import { Message, proto3 } from "@bufbuild/protobuf"; + +/** + * Each level is given a specific integer priority. + * The higher the priority the more important the message is considered to be, + * and the lower the corresponding integer priority. + * For example, as specified exactly in RFC5424 the syslog levels are prioritized from 0 to 7 (highest to lowest). + * + * @generated from enum pinax.substreams.sink.winston.v1.LoggingLevels + */ +export enum LoggingLevels { + /** + * UNSPECIFIED = 0; // Unspecified: default value + * + * Emergency: system is unusable + * + * @generated from enum value: EMERG = 0; + */ + EMERG = 0, + + /** + * Alert: action must be taken immediately + * + * @generated from enum value: ALERT = 1; + */ + ALERT = 1, + + /** + * Critical: critical conditions + * + * @generated from enum value: CRIT = 2; + */ + CRIT = 2, + + /** + * Error: error conditions + * + * @generated from enum value: ERROR = 3; + */ + ERROR = 3, + + /** + * Warning: warning conditions + * + * @generated from enum value: WARNING = 4; + */ + WARNING = 4, + + /** + * Notice: normal but significant condition + * + * @generated from enum value: NOTICE = 5; + */ + NOTICE = 5, + + /** + * Informational: informational messages + * + * @generated from enum value: INFO = 6; + */ + INFO = 6, + + /** + * Debug: debug-level messages + * + * @generated from enum value: DEBUG = 7; + */ + DEBUG = 7, +} +// Retrieve enum metadata with: proto3.getEnumType(LoggingLevels) +proto3.util.setEnumType(LoggingLevels, "pinax.substreams.sink.winston.v1.LoggingLevels", [ + { no: 0, name: "EMERG" }, + { no: 1, name: "ALERT" }, + { no: 2, name: "CRIT" }, + { no: 3, name: "ERROR" }, + { no: 4, name: "WARNING" }, + { no: 5, name: "NOTICE" }, + { no: 6, name: "INFO" }, + { no: 7, name: "DEBUG" }, +]); + +/** + * Vector of Winston Logging messages + * + * @generated from message pinax.substreams.sink.winston.v1.LoggerOperations + */ +export class LoggerOperations extends Message { + /** + * @generated from field: repeated pinax.substreams.sink.winston.v1.LoggerOperation operations = 1; + */ + operations: LoggerOperation[] = []; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "pinax.substreams.sink.winston.v1.LoggerOperations"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "operations", kind: "message", T: LoggerOperation, repeated: true }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): LoggerOperations { + return new LoggerOperations().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): LoggerOperations { + return new LoggerOperations().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): LoggerOperations { + return new LoggerOperations().fromJsonString(jsonString, options); + } + + static equals(a: LoggerOperations | PlainMessage | undefined, b: LoggerOperations | PlainMessage | undefined): boolean { + return proto3.util.equals(LoggerOperations, a, b); + } +} + +/** + * @generated from message pinax.substreams.sink.winston.v1.LoggerOperation + */ +export class LoggerOperation extends Message { + /** + * @generated from field: string service = 1; + */ + service = ""; + + /** + * @generated from field: pinax.substreams.sink.winston.v1.LoggingLevels level = 2; + */ + level = LoggingLevels.EMERG; + + /** + * @generated from field: string message = 3; + */ + message = ""; + + /** + * @generated from field: map meta = 4; + */ + meta: { [key: string]: string } = {}; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "pinax.substreams.sink.winston.v1.LoggerOperation"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "service", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "level", kind: "enum", T: proto3.getEnumType(LoggingLevels) }, + { no: 3, name: "message", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 4, name: "meta", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "scalar", T: 9 /* ScalarType.STRING */} }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): LoggerOperation { + return new LoggerOperation().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): LoggerOperation { + return new LoggerOperation().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): LoggerOperation { + return new LoggerOperation().fromJsonString(jsonString, options); + } + + static equals(a: LoggerOperation | PlainMessage | undefined, b: LoggerOperation | PlainMessage | undefined): boolean { + return proto3.util.equals(LoggerOperation, a, b); + } +} + diff --git a/src/generated/sf/substreams/sink/database/v1/database_pb.ts b/src/generated/sf/substreams/sink/database/v1/database_pb.ts new file mode 100644 index 0000000..69d4337 --- /dev/null +++ b/src/generated/sf/substreams/sink/database/v1/database_pb.ts @@ -0,0 +1,189 @@ +// @generated by protoc-gen-es v1.1.1 with parameter "target=ts" +// @generated from file sf/substreams/sink/database/v1/database.proto (package sf.substreams.sink.database.v1, syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; +import { Message, proto3, protoInt64 } from "@bufbuild/protobuf"; + +/** + * @generated from message sf.substreams.sink.database.v1.DatabaseChanges + */ +export class DatabaseChanges extends Message { + /** + * @generated from field: repeated sf.substreams.sink.database.v1.TableChange table_changes = 1; + */ + tableChanges: TableChange[] = []; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "sf.substreams.sink.database.v1.DatabaseChanges"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "table_changes", kind: "message", T: TableChange, repeated: true }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): DatabaseChanges { + return new DatabaseChanges().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): DatabaseChanges { + return new DatabaseChanges().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): DatabaseChanges { + return new DatabaseChanges().fromJsonString(jsonString, options); + } + + static equals(a: DatabaseChanges | PlainMessage | undefined, b: DatabaseChanges | PlainMessage | undefined): boolean { + return proto3.util.equals(DatabaseChanges, a, b); + } +} + +/** + * @generated from message sf.substreams.sink.database.v1.TableChange + */ +export class TableChange extends Message { + /** + * @generated from field: string table = 1; + */ + table = ""; + + /** + * @generated from field: string pk = 2; + */ + pk = ""; + + /** + * @generated from field: uint64 ordinal = 3; + */ + ordinal = protoInt64.zero; + + /** + * @generated from field: sf.substreams.sink.database.v1.TableChange.Operation operation = 4; + */ + operation = TableChange_Operation.UNSET; + + /** + * @generated from field: repeated sf.substreams.sink.database.v1.Field fields = 5; + */ + fields: Field[] = []; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "sf.substreams.sink.database.v1.TableChange"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "table", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "pk", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 3, name: "ordinal", kind: "scalar", T: 4 /* ScalarType.UINT64 */ }, + { no: 4, name: "operation", kind: "enum", T: proto3.getEnumType(TableChange_Operation) }, + { no: 5, name: "fields", kind: "message", T: Field, repeated: true }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): TableChange { + return new TableChange().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): TableChange { + return new TableChange().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): TableChange { + return new TableChange().fromJsonString(jsonString, options); + } + + static equals(a: TableChange | PlainMessage | undefined, b: TableChange | PlainMessage | undefined): boolean { + return proto3.util.equals(TableChange, a, b); + } +} + +/** + * @generated from enum sf.substreams.sink.database.v1.TableChange.Operation + */ +export enum TableChange_Operation { + /** + * Protobuf default should not be used, this is used so that the consume can ensure that the value was actually specified + * + * @generated from enum value: UNSET = 0; + */ + UNSET = 0, + + /** + * @generated from enum value: CREATE = 1; + */ + CREATE = 1, + + /** + * @generated from enum value: UPDATE = 2; + */ + UPDATE = 2, + + /** + * @generated from enum value: DELETE = 3; + */ + DELETE = 3, +} +// Retrieve enum metadata with: proto3.getEnumType(TableChange_Operation) +proto3.util.setEnumType(TableChange_Operation, "sf.substreams.sink.database.v1.TableChange.Operation", [ + { no: 0, name: "UNSET" }, + { no: 1, name: "CREATE" }, + { no: 2, name: "UPDATE" }, + { no: 3, name: "DELETE" }, +]); + +/** + * @generated from message sf.substreams.sink.database.v1.Field + */ +export class Field extends Message { + /** + * @generated from field: string name = 1; + */ + name = ""; + + /** + * @generated from field: string new_value = 2; + */ + newValue = ""; + + /** + * @generated from field: string old_value = 3; + */ + oldValue = ""; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "sf.substreams.sink.database.v1.Field"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "name", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "new_value", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 3, name: "old_value", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): Field { + return new Field().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): Field { + return new Field().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): Field { + return new Field().fromJsonString(jsonString, options); + } + + static equals(a: Field | PlainMessage | undefined, b: Field | PlainMessage | undefined): boolean { + return proto3.util.equals(Field, a, b); + } +} + diff --git a/src/generated/sf/substreams/sink/entity/v1/entity_pb.ts b/src/generated/sf/substreams/sink/entity/v1/entity_pb.ts new file mode 100644 index 0000000..e40df31 --- /dev/null +++ b/src/generated/sf/substreams/sink/entity/v1/entity_pb.ts @@ -0,0 +1,311 @@ +// @generated by protoc-gen-es v1.1.1 with parameter "target=ts" +// @generated from file sf/substreams/sink/entity/v1/entity.proto (package sf.substreams.entity.v1, syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; +import { Message, proto3, protoInt64 } from "@bufbuild/protobuf"; + +/** + * @generated from message sf.substreams.entity.v1.EntityChanges + */ +export class EntityChanges extends Message { + /** + * @generated from field: repeated sf.substreams.entity.v1.EntityChange entity_changes = 5; + */ + entityChanges: EntityChange[] = []; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "sf.substreams.entity.v1.EntityChanges"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 5, name: "entity_changes", kind: "message", T: EntityChange, repeated: true }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): EntityChanges { + return new EntityChanges().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): EntityChanges { + return new EntityChanges().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): EntityChanges { + return new EntityChanges().fromJsonString(jsonString, options); + } + + static equals(a: EntityChanges | PlainMessage | undefined, b: EntityChanges | PlainMessage | undefined): boolean { + return proto3.util.equals(EntityChanges, a, b); + } +} + +/** + * @generated from message sf.substreams.entity.v1.EntityChange + */ +export class EntityChange extends Message { + /** + * @generated from field: string entity = 1; + */ + entity = ""; + + /** + * @generated from field: string id = 2; + */ + id = ""; + + /** + * @generated from field: uint64 ordinal = 3; + */ + ordinal = protoInt64.zero; + + /** + * @generated from field: sf.substreams.entity.v1.EntityChange.Operation operation = 4; + */ + operation = EntityChange_Operation.UNSET; + + /** + * @generated from field: repeated sf.substreams.entity.v1.Field fields = 5; + */ + fields: Field[] = []; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "sf.substreams.entity.v1.EntityChange"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "entity", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "id", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 3, name: "ordinal", kind: "scalar", T: 4 /* ScalarType.UINT64 */ }, + { no: 4, name: "operation", kind: "enum", T: proto3.getEnumType(EntityChange_Operation) }, + { no: 5, name: "fields", kind: "message", T: Field, repeated: true }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): EntityChange { + return new EntityChange().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): EntityChange { + return new EntityChange().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): EntityChange { + return new EntityChange().fromJsonString(jsonString, options); + } + + static equals(a: EntityChange | PlainMessage | undefined, b: EntityChange | PlainMessage | undefined): boolean { + return proto3.util.equals(EntityChange, a, b); + } +} + +/** + * @generated from enum sf.substreams.entity.v1.EntityChange.Operation + */ +export enum EntityChange_Operation { + /** + * Protobuf default should not be used, this is used so that the consume can ensure that the value was actually specified + * + * @generated from enum value: UNSET = 0; + */ + UNSET = 0, + + /** + * @generated from enum value: CREATE = 1; + */ + CREATE = 1, + + /** + * @generated from enum value: UPDATE = 2; + */ + UPDATE = 2, + + /** + * @generated from enum value: DELETE = 3; + */ + DELETE = 3, +} +// Retrieve enum metadata with: proto3.getEnumType(EntityChange_Operation) +proto3.util.setEnumType(EntityChange_Operation, "sf.substreams.entity.v1.EntityChange.Operation", [ + { no: 0, name: "UNSET" }, + { no: 1, name: "CREATE" }, + { no: 2, name: "UPDATE" }, + { no: 3, name: "DELETE" }, +]); + +/** + * @generated from message sf.substreams.entity.v1.Value + */ +export class Value extends Message { + /** + * @generated from oneof sf.substreams.entity.v1.Value.typed + */ + typed: { + /** + * @generated from field: int32 int32 = 1; + */ + value: number; + case: "int32"; + } | { + /** + * @generated from field: string bigdecimal = 2; + */ + value: string; + case: "bigdecimal"; + } | { + /** + * @generated from field: string bigint = 3; + */ + value: string; + case: "bigint"; + } | { + /** + * @generated from field: string string = 4; + */ + value: string; + case: "string"; + } | { + /** + * @generated from field: string bytes = 5; + */ + value: string; + case: "bytes"; + } | { + /** + * @generated from field: bool bool = 6; + */ + value: boolean; + case: "bool"; + } | { + /** + * @generated from field: sf.substreams.entity.v1.Array array = 10; + */ + value: Array; + case: "array"; + } | { case: undefined; value?: undefined } = { case: undefined }; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "sf.substreams.entity.v1.Value"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "int32", kind: "scalar", T: 5 /* ScalarType.INT32 */, oneof: "typed" }, + { no: 2, name: "bigdecimal", kind: "scalar", T: 9 /* ScalarType.STRING */, oneof: "typed" }, + { no: 3, name: "bigint", kind: "scalar", T: 9 /* ScalarType.STRING */, oneof: "typed" }, + { no: 4, name: "string", kind: "scalar", T: 9 /* ScalarType.STRING */, oneof: "typed" }, + { no: 5, name: "bytes", kind: "scalar", T: 9 /* ScalarType.STRING */, oneof: "typed" }, + { no: 6, name: "bool", kind: "scalar", T: 8 /* ScalarType.BOOL */, oneof: "typed" }, + { no: 10, name: "array", kind: "message", T: Array, oneof: "typed" }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): Value { + return new Value().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): Value { + return new Value().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): Value { + return new Value().fromJsonString(jsonString, options); + } + + static equals(a: Value | PlainMessage | undefined, b: Value | PlainMessage | undefined): boolean { + return proto3.util.equals(Value, a, b); + } +} + +/** + * @generated from message sf.substreams.entity.v1.Array + */ +export class Array extends Message { + /** + * @generated from field: repeated sf.substreams.entity.v1.Value value = 1; + */ + value: Value[] = []; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "sf.substreams.entity.v1.Array"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "value", kind: "message", T: Value, repeated: true }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): Array { + return new Array().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): Array { + return new Array().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): Array { + return new Array().fromJsonString(jsonString, options); + } + + static equals(a: Array | PlainMessage | undefined, b: Array | PlainMessage | undefined): boolean { + return proto3.util.equals(Array, a, b); + } +} + +/** + * @generated from message sf.substreams.entity.v1.Field + */ +export class Field extends Message { + /** + * @generated from field: string name = 1; + */ + name = ""; + + /** + * @generated from field: optional sf.substreams.entity.v1.Value new_value = 3; + */ + newValue?: Value; + + /** + * @generated from field: optional sf.substreams.entity.v1.Value old_value = 5; + */ + oldValue?: Value; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "sf.substreams.entity.v1.Field"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "name", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 3, name: "new_value", kind: "message", T: Value, opt: true }, + { no: 5, name: "old_value", kind: "message", T: Value, opt: true }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): Field { + return new Field().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): Field { + return new Field().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): Field { + return new Field().fromJsonString(jsonString, options); + } + + static equals(a: Field | PlainMessage | undefined, b: Field | PlainMessage | undefined): boolean { + return proto3.util.equals(Field, a, b); + } +} + diff --git a/src/generated/sf/substreams/sink/kv/v1/kv_pb.ts b/src/generated/sf/substreams/sink/kv/v1/kv_pb.ts new file mode 100644 index 0000000..422f1e5 --- /dev/null +++ b/src/generated/sf/substreams/sink/kv/v1/kv_pb.ts @@ -0,0 +1,128 @@ +// @generated by protoc-gen-es v1.1.1 with parameter "target=ts" +// @generated from file sf/substreams/sink/kv/v1/kv.proto (package sf.substreams.sink.kv.v1, syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; +import { Message, proto3, protoInt64 } from "@bufbuild/protobuf"; + +/** + * @generated from message sf.substreams.sink.kv.v1.KVOperations + */ +export class KVOperations extends Message { + /** + * @generated from field: repeated sf.substreams.sink.kv.v1.KVOperation operations = 1; + */ + operations: KVOperation[] = []; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "sf.substreams.sink.kv.v1.KVOperations"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "operations", kind: "message", T: KVOperation, repeated: true }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): KVOperations { + return new KVOperations().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): KVOperations { + return new KVOperations().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): KVOperations { + return new KVOperations().fromJsonString(jsonString, options); + } + + static equals(a: KVOperations | PlainMessage | undefined, b: KVOperations | PlainMessage | undefined): boolean { + return proto3.util.equals(KVOperations, a, b); + } +} + +/** + * @generated from message sf.substreams.sink.kv.v1.KVOperation + */ +export class KVOperation extends Message { + /** + * @generated from field: string key = 1; + */ + key = ""; + + /** + * @generated from field: bytes value = 2; + */ + value = new Uint8Array(0); + + /** + * @generated from field: uint64 ordinal = 3; + */ + ordinal = protoInt64.zero; + + /** + * @generated from field: sf.substreams.sink.kv.v1.KVOperation.Type type = 4; + */ + type = KVOperation_Type.UNSET; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "sf.substreams.sink.kv.v1.KVOperation"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "key", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "value", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + { no: 3, name: "ordinal", kind: "scalar", T: 4 /* ScalarType.UINT64 */ }, + { no: 4, name: "type", kind: "enum", T: proto3.getEnumType(KVOperation_Type) }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): KVOperation { + return new KVOperation().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): KVOperation { + return new KVOperation().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): KVOperation { + return new KVOperation().fromJsonString(jsonString, options); + } + + static equals(a: KVOperation | PlainMessage | undefined, b: KVOperation | PlainMessage | undefined): boolean { + return proto3.util.equals(KVOperation, a, b); + } +} + +/** + * @generated from enum sf.substreams.sink.kv.v1.KVOperation.Type + */ +export enum KVOperation_Type { + /** + * Protobuf default should not be used, this is used so that the consume can ensure that the value was actually specified + * + * @generated from enum value: UNSET = 0; + */ + UNSET = 0, + + /** + * @generated from enum value: SET = 1; + */ + SET = 1, + + /** + * @generated from enum value: DELETE = 2; + */ + DELETE = 2, +} +// Retrieve enum metadata with: proto3.getEnumType(KVOperation_Type) +proto3.util.setEnumType(KVOperation_Type, "sf.substreams.sink.kv.v1.KVOperation.Type", [ + { no: 0, name: "UNSET" }, + { no: 1, name: "SET" }, + { no: 2, name: "DELETE" }, +]); + diff --git a/src/generated/sf/substreams/sink/kv/v1/read_connect.ts b/src/generated/sf/substreams/sink/kv/v1/read_connect.ts new file mode 100644 index 0000000..16e3f42 --- /dev/null +++ b/src/generated/sf/substreams/sink/kv/v1/read_connect.ts @@ -0,0 +1,61 @@ +// @generated by protoc-gen-connect-es v0.8.4 with parameter "target=ts" +// @generated from file sf/substreams/sink/kv/v1/read.proto (package sf.substreams.sink.kv.v1, syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import { GetByPrefixRequest, GetByPrefixResponse, GetManyRequest, GetManyResponse, GetRequest, GetResponse, ScanRequest, ScanResponse } from "./read_pb.js"; +import { MethodKind } from "@bufbuild/protobuf"; + +/** + * @generated from service sf.substreams.sink.kv.v1.Kv + */ +export const Kv = { + typeName: "sf.substreams.sink.kv.v1.Kv", + methods: { + /** + * Get returns the requested value as bytes if it exists, grpc_error: NOT_FOUND otherwise. + * + * @generated from rpc sf.substreams.sink.kv.v1.Kv.Get + */ + get: { + name: "Get", + I: GetRequest, + O: GetResponse, + kind: MethodKind.Unary, + }, + /** + * GetMany returns the requested values as bytes if all of them exists, grpc_error: NOT_FOUND otherwise. + * + * @generated from rpc sf.substreams.sink.kv.v1.Kv.GetMany + */ + getMany: { + name: "GetMany", + I: GetManyRequest, + O: GetManyResponse, + kind: MethodKind.Unary, + }, + /** + * GetByPrefix returns the next _limit_ key/value pair that match the requested prefix if any exist, grpc_error: NOT_FOUND otherwise. + * + * @generated from rpc sf.substreams.sink.kv.v1.Kv.GetByPrefix + */ + getByPrefix: { + name: "GetByPrefix", + I: GetByPrefixRequest, + O: GetByPrefixResponse, + kind: MethodKind.Unary, + }, + /** + * Scan returns then next _limit_ key/value pairs starting lexicographically at the given key, grpc_error: NOT_FOUND otherwise. + * + * @generated from rpc sf.substreams.sink.kv.v1.Kv.Scan + */ + scan: { + name: "Scan", + I: ScanRequest, + O: ScanResponse, + kind: MethodKind.Unary, + }, + } +} as const; + diff --git a/src/generated/sf/substreams/sink/kv/v1/read_pb.ts b/src/generated/sf/substreams/sink/kv/v1/read_pb.ts new file mode 100644 index 0000000..a072f0d --- /dev/null +++ b/src/generated/sf/substreams/sink/kv/v1/read_pb.ts @@ -0,0 +1,403 @@ +// @generated by protoc-gen-es v1.1.1 with parameter "target=ts" +// @generated from file sf/substreams/sink/kv/v1/read.proto (package sf.substreams.sink.kv.v1, syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; +import { Message, proto3, protoInt64 } from "@bufbuild/protobuf"; + +/** + * @generated from message sf.substreams.sink.kv.v1.GetRequest + */ +export class GetRequest extends Message { + /** + * Key to fetch + * + * @generated from field: string key = 1; + */ + key = ""; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "sf.substreams.sink.kv.v1.GetRequest"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "key", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): GetRequest { + return new GetRequest().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): GetRequest { + return new GetRequest().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): GetRequest { + return new GetRequest().fromJsonString(jsonString, options); + } + + static equals(a: GetRequest | PlainMessage | undefined, b: GetRequest | PlainMessage | undefined): boolean { + return proto3.util.equals(GetRequest, a, b); + } +} + +/** + * @generated from message sf.substreams.sink.kv.v1.GetManyRequest + */ +export class GetManyRequest extends Message { + /** + * Keys to fetch + * + * @generated from field: repeated string keys = 1; + */ + keys: string[] = []; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "sf.substreams.sink.kv.v1.GetManyRequest"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "keys", kind: "scalar", T: 9 /* ScalarType.STRING */, repeated: true }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): GetManyRequest { + return new GetManyRequest().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): GetManyRequest { + return new GetManyRequest().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): GetManyRequest { + return new GetManyRequest().fromJsonString(jsonString, options); + } + + static equals(a: GetManyRequest | PlainMessage | undefined, b: GetManyRequest | PlainMessage | undefined): boolean { + return proto3.util.equals(GetManyRequest, a, b); + } +} + +/** + * @generated from message sf.substreams.sink.kv.v1.GetByPrefixRequest + */ +export class GetByPrefixRequest extends Message { + /** + * server may impose a hard limit, trying to go above it would return grpc_error: INVALID_ARGUMENT + * + * @generated from field: uint64 limit = 1; + */ + limit = protoInt64.zero; + + /** + * requested prefix + * + * @generated from field: string prefix = 2; + */ + prefix = ""; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "sf.substreams.sink.kv.v1.GetByPrefixRequest"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "limit", kind: "scalar", T: 4 /* ScalarType.UINT64 */ }, + { no: 2, name: "prefix", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): GetByPrefixRequest { + return new GetByPrefixRequest().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): GetByPrefixRequest { + return new GetByPrefixRequest().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): GetByPrefixRequest { + return new GetByPrefixRequest().fromJsonString(jsonString, options); + } + + static equals(a: GetByPrefixRequest | PlainMessage | undefined, b: GetByPrefixRequest | PlainMessage | undefined): boolean { + return proto3.util.equals(GetByPrefixRequest, a, b); + } +} + +/** + * @generated from message sf.substreams.sink.kv.v1.ScanRequest + */ +export class ScanRequest extends Message { + /** + * server may impose a hard limit, trying to go above it would return grpc_error: INVALID_ARGUMENT + * + * @generated from field: uint64 limit = 1; + */ + limit = protoInt64.zero; + + /** + * scanning will start at this point, lexicographically + * + * @generated from field: string begin = 2; + */ + begin = ""; + + /** + * If set, scanning will stop when it reaches this point or above, excluding this exact key + * + * @generated from field: optional string exclusive_end = 3; + */ + exclusiveEnd?: string; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "sf.substreams.sink.kv.v1.ScanRequest"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "limit", kind: "scalar", T: 4 /* ScalarType.UINT64 */ }, + { no: 2, name: "begin", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 3, name: "exclusive_end", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): ScanRequest { + return new ScanRequest().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): ScanRequest { + return new ScanRequest().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): ScanRequest { + return new ScanRequest().fromJsonString(jsonString, options); + } + + static equals(a: ScanRequest | PlainMessage | undefined, b: ScanRequest | PlainMessage | undefined): boolean { + return proto3.util.equals(ScanRequest, a, b); + } +} + +/** + * @generated from message sf.substreams.sink.kv.v1.GetResponse + */ +export class GetResponse extends Message { + /** + * Value that was found for the requested key + * + * @generated from field: bytes value = 1; + */ + value = new Uint8Array(0); + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "sf.substreams.sink.kv.v1.GetResponse"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "value", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): GetResponse { + return new GetResponse().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): GetResponse { + return new GetResponse().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): GetResponse { + return new GetResponse().fromJsonString(jsonString, options); + } + + static equals(a: GetResponse | PlainMessage | undefined, b: GetResponse | PlainMessage | undefined): boolean { + return proto3.util.equals(GetResponse, a, b); + } +} + +/** + * @generated from message sf.substreams.sink.kv.v1.GetManyResponse + */ +export class GetManyResponse extends Message { + /** + * Values that were found for the requested keys + * + * @generated from field: repeated bytes values = 1; + */ + values: Uint8Array[] = []; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "sf.substreams.sink.kv.v1.GetManyResponse"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "values", kind: "scalar", T: 12 /* ScalarType.BYTES */, repeated: true }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): GetManyResponse { + return new GetManyResponse().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): GetManyResponse { + return new GetManyResponse().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): GetManyResponse { + return new GetManyResponse().fromJsonString(jsonString, options); + } + + static equals(a: GetManyResponse | PlainMessage | undefined, b: GetManyResponse | PlainMessage | undefined): boolean { + return proto3.util.equals(GetManyResponse, a, b); + } +} + +/** + * @generated from message sf.substreams.sink.kv.v1.GetByPrefixResponse + */ +export class GetByPrefixResponse extends Message { + /** + * KV are the key/value pairs that were found with the given prefix + * + * @generated from field: repeated sf.substreams.sink.kv.v1.KV key_values = 1; + */ + keyValues: KV[] = []; + + /** + * limit_reached is true if there is at least ONE MORE result than the requested limit + * + * @generated from field: bool limit_reached = 2; + */ + limitReached = false; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "sf.substreams.sink.kv.v1.GetByPrefixResponse"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "key_values", kind: "message", T: KV, repeated: true }, + { no: 2, name: "limit_reached", kind: "scalar", T: 8 /* ScalarType.BOOL */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): GetByPrefixResponse { + return new GetByPrefixResponse().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): GetByPrefixResponse { + return new GetByPrefixResponse().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): GetByPrefixResponse { + return new GetByPrefixResponse().fromJsonString(jsonString, options); + } + + static equals(a: GetByPrefixResponse | PlainMessage | undefined, b: GetByPrefixResponse | PlainMessage | undefined): boolean { + return proto3.util.equals(GetByPrefixResponse, a, b); + } +} + +/** + * @generated from message sf.substreams.sink.kv.v1.ScanResponse + */ +export class ScanResponse extends Message { + /** + * KV are the key/value pairs that were found during scan + * + * @generated from field: repeated sf.substreams.sink.kv.v1.KV key_values = 1; + */ + keyValues: KV[] = []; + + /** + * limit_reached is true if there is at least ONE MORE result than the requested limit + * + * @generated from field: bool limit_reached = 2; + */ + limitReached = false; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "sf.substreams.sink.kv.v1.ScanResponse"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "key_values", kind: "message", T: KV, repeated: true }, + { no: 2, name: "limit_reached", kind: "scalar", T: 8 /* ScalarType.BOOL */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): ScanResponse { + return new ScanResponse().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): ScanResponse { + return new ScanResponse().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): ScanResponse { + return new ScanResponse().fromJsonString(jsonString, options); + } + + static equals(a: ScanResponse | PlainMessage | undefined, b: ScanResponse | PlainMessage | undefined): boolean { + return proto3.util.equals(ScanResponse, a, b); + } +} + +/** + * @generated from message sf.substreams.sink.kv.v1.KV + */ +export class KV extends Message { + /** + * @generated from field: string key = 1; + */ + key = ""; + + /** + * @generated from field: bytes value = 2; + */ + value = new Uint8Array(0); + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "sf.substreams.sink.kv.v1.KV"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "key", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "value", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): KV { + return new KV().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): KV { + return new KV().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): KV { + return new KV().fromJsonString(jsonString, options); + } + + static equals(a: KV | PlainMessage | undefined, b: KV | PlainMessage | undefined): boolean { + return proto3.util.equals(KV, a, b); + } +} + diff --git a/src/generated/sf/substreams/sink/kv/v1/services_pb.ts b/src/generated/sf/substreams/sink/kv/v1/services_pb.ts new file mode 100644 index 0000000..f5297d8 --- /dev/null +++ b/src/generated/sf/substreams/sink/kv/v1/services_pb.ts @@ -0,0 +1,147 @@ +// @generated by protoc-gen-es v1.1.1 with parameter "target=ts" +// @generated from file sf/substreams/sink/kv/v1/services.proto (package sf.substreams.sink.kv.v1, syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; +import { Message, proto3, protoInt64 } from "@bufbuild/protobuf"; + +/** + * @generated from message sf.substreams.sink.kv.v1.Config + */ +export class Config extends Message { + /** + * @generated from field: int64 start_block = 1; + */ + startBlock = protoInt64.zero; + + /** + * @generated from field: string input_module = 2; + */ + inputModule = ""; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "sf.substreams.sink.kv.v1.Config"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "start_block", kind: "scalar", T: 3 /* ScalarType.INT64 */ }, + { no: 2, name: "input_module", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): Config { + return new Config().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): Config { + return new Config().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): Config { + return new Config().fromJsonString(jsonString, options); + } + + static equals(a: Config | PlainMessage | undefined, b: Config | PlainMessage | undefined): boolean { + return proto3.util.equals(Config, a, b); + } +} + +/** + * This defines a KV Sink to be queried with a generic key access interface (Get, GetMany, Scan, Prefix calls). + * + * @generated from message sf.substreams.sink.kv.v1.GenericService + */ +export class GenericService extends Message { + /** + * @generated from field: sf.substreams.sink.kv.v1.Config sink_config = 1; + */ + sinkConfig?: Config; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "sf.substreams.sink.kv.v1.GenericService"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "sink_config", kind: "message", T: Config }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): GenericService { + return new GenericService().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): GenericService { + return new GenericService().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): GenericService { + return new GenericService().fromJsonString(jsonString, options); + } + + static equals(a: GenericService | PlainMessage | undefined, b: GenericService | PlainMessage | undefined): boolean { + return proto3.util.equals(GenericService, a, b); + } +} + +/** + * This defines configuration to run a WASM query service on top of the KV store being sync'd. + * + * @generated from message sf.substreams.sink.kv.v1.WASMQueryService + */ +export class WASMQueryService extends Message { + /** + * @generated from field: sf.substreams.sink.kv.v1.Config sink_config = 1; + */ + sinkConfig?: Config; + + /** + * wasm exports: "kv_get_batch", "kv_get", "kv_scan", "kv_prefix" + * + * @generated from field: bytes wasm_query_module = 5; + */ + wasmQueryModule = new Uint8Array(0); + + /** + * Fully qualified Protobuf Service definition name + * + * sf.mycustom.v1.MyService + * + * @generated from field: string grpc_service = 2; + */ + grpcService = ""; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "sf.substreams.sink.kv.v1.WASMQueryService"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "sink_config", kind: "message", T: Config }, + { no: 5, name: "wasm_query_module", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + { no: 2, name: "grpc_service", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): WASMQueryService { + return new WASMQueryService().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): WASMQueryService { + return new WASMQueryService().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): WASMQueryService { + return new WASMQueryService().fromJsonString(jsonString, options); + } + + static equals(a: WASMQueryService | PlainMessage | undefined, b: WASMQueryService | PlainMessage | undefined): boolean { + return proto3.util.equals(WASMQueryService, a, b); + } +} + diff --git a/src/generated/sf/substreams/sink/kv/v1/types_pb.ts b/src/generated/sf/substreams/sink/kv/v1/types_pb.ts new file mode 100644 index 0000000..978e681 --- /dev/null +++ b/src/generated/sf/substreams/sink/kv/v1/types_pb.ts @@ -0,0 +1,125 @@ +// @generated by protoc-gen-es v1.1.1 with parameter "target=ts" +// @generated from file sf/substreams/sink/kv/v1/types.proto (package sf.substreams.sink.types.v1, syntax proto3) +/* eslint-disable */ +// @ts-nocheck + +import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; +import { Message, proto3 } from "@bufbuild/protobuf"; + +/** + * @generated from message sf.substreams.sink.types.v1.KVPairs + */ +export class KVPairs extends Message { + /** + * @generated from field: repeated sf.substreams.sink.types.v1.KVPair pairs = 2; + */ + pairs: KVPair[] = []; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "sf.substreams.sink.types.v1.KVPairs"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 2, name: "pairs", kind: "message", T: KVPair, repeated: true }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): KVPairs { + return new KVPairs().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): KVPairs { + return new KVPairs().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): KVPairs { + return new KVPairs().fromJsonString(jsonString, options); + } + + static equals(a: KVPairs | PlainMessage | undefined, b: KVPairs | PlainMessage | undefined): boolean { + return proto3.util.equals(KVPairs, a, b); + } +} + +/** + * @generated from message sf.substreams.sink.types.v1.KVPair + */ +export class KVPair extends Message { + /** + * @generated from field: string key = 1; + */ + key = ""; + + /** + * @generated from field: bytes value = 2; + */ + value = new Uint8Array(0); + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "sf.substreams.sink.types.v1.KVPair"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "key", kind: "scalar", T: 9 /* ScalarType.STRING */ }, + { no: 2, name: "value", kind: "scalar", T: 12 /* ScalarType.BYTES */ }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): KVPair { + return new KVPair().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): KVPair { + return new KVPair().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): KVPair { + return new KVPair().fromJsonString(jsonString, options); + } + + static equals(a: KVPair | PlainMessage | undefined, b: KVPair | PlainMessage | undefined): boolean { + return proto3.util.equals(KVPair, a, b); + } +} + +/** + * @generated from message sf.substreams.sink.types.v1.KVKeys + */ +export class KVKeys extends Message { + /** + * @generated from field: repeated string keys = 1; + */ + keys: string[] = []; + + constructor(data?: PartialMessage) { + super(); + proto3.util.initPartial(data, this); + } + + static readonly runtime: typeof proto3 = proto3; + static readonly typeName = "sf.substreams.sink.types.v1.KVKeys"; + static readonly fields: FieldList = proto3.util.newFieldList(() => [ + { no: 1, name: "keys", kind: "scalar", T: 9 /* ScalarType.STRING */, repeated: true }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): KVKeys { + return new KVKeys().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): KVKeys { + return new KVKeys().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): KVKeys { + return new KVKeys().fromJsonString(jsonString, options); + } + + static equals(a: KVKeys | PlainMessage | undefined, b: KVKeys | PlainMessage | undefined): boolean { + return proto3.util.equals(KVKeys, a, b); + } +} + diff --git a/src/generated/sf/substreams/v1/clock_pb.ts b/src/generated/sf/substreams/v1/clock_pb.ts index f013ccc..1f99296 100644 --- a/src/generated/sf/substreams/v1/clock_pb.ts +++ b/src/generated/sf/substreams/v1/clock_pb.ts @@ -1,4 +1,4 @@ -// @generated by protoc-gen-es v1.1.0 with parameter "target=ts" +// @generated by protoc-gen-es v1.1.1 with parameter "target=ts" // @generated from file sf/substreams/v1/clock.proto (package sf.substreams.v1, syntax proto3) /* eslint-disable */ // @ts-nocheck diff --git a/src/generated/sf/substreams/v1/modules_pb.ts b/src/generated/sf/substreams/v1/modules_pb.ts index 578770b..1b7ea65 100644 --- a/src/generated/sf/substreams/v1/modules_pb.ts +++ b/src/generated/sf/substreams/v1/modules_pb.ts @@ -1,4 +1,4 @@ -// @generated by protoc-gen-es v1.1.0 with parameter "target=ts" +// @generated by protoc-gen-es v1.1.1 with parameter "target=ts" // @generated from file sf/substreams/v1/modules.proto (package sf.substreams.v1, syntax proto3) /* eslint-disable */ // @ts-nocheck diff --git a/src/generated/sf/substreams/v1/package_pb.ts b/src/generated/sf/substreams/v1/package_pb.ts index d0e20fe..4dc42a7 100644 --- a/src/generated/sf/substreams/v1/package_pb.ts +++ b/src/generated/sf/substreams/v1/package_pb.ts @@ -1,4 +1,4 @@ -// @generated by protoc-gen-es v1.1.0 with parameter "target=ts" +// @generated by protoc-gen-es v1.1.1 with parameter "target=ts" // @generated from file sf/substreams/v1/package.proto (package sf.substreams.v1, syntax proto3) /* eslint-disable */ // @ts-nocheck diff --git a/src/generated/sf/substreams/v1/substreams_connect.ts b/src/generated/sf/substreams/v1/substreams_connect.ts index ba88262..0a60028 100644 --- a/src/generated/sf/substreams/v1/substreams_connect.ts +++ b/src/generated/sf/substreams/v1/substreams_connect.ts @@ -1,4 +1,4 @@ -// @generated by protoc-gen-connect-es v0.8.3 with parameter "target=ts" +// @generated by protoc-gen-connect-es v0.8.4 with parameter "target=ts" // @generated from file sf/substreams/v1/substreams.proto (package sf.substreams.v1, syntax proto3) /* eslint-disable */ // @ts-nocheck diff --git a/src/generated/sf/substreams/v1/substreams_pb.ts b/src/generated/sf/substreams/v1/substreams_pb.ts index 5d9c743..060bd3b 100644 --- a/src/generated/sf/substreams/v1/substreams_pb.ts +++ b/src/generated/sf/substreams/v1/substreams_pb.ts @@ -1,4 +1,4 @@ -// @generated by protoc-gen-es v1.1.0 with parameter "target=ts" +// @generated by protoc-gen-es v1.1.1 with parameter "target=ts" // @generated from file sf/substreams/v1/substreams.proto (package sf.substreams.v1, syntax proto3) /* eslint-disable */ // @ts-nocheck diff --git a/src/generated/sf/substreams/v1/test/test_pb.ts b/src/generated/sf/substreams/v1/test/test_pb.ts index fc9adc7..a94f6cd 100644 --- a/src/generated/sf/substreams/v1/test/test_pb.ts +++ b/src/generated/sf/substreams/v1/test/test_pb.ts @@ -1,4 +1,4 @@ -// @generated by protoc-gen-es v1.1.0 with parameter "target=ts" +// @generated by protoc-gen-es v1.1.1 with parameter "target=ts" // @generated from file sf/substreams/v1/test/test.proto (package sf.substreams.v1.test, syntax proto3) /* eslint-disable */ // @ts-nocheck diff --git a/src/index.ts b/src/index.ts index c357db9..7754e12 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,7 +4,8 @@ import { CallOptions, createPromiseClient, Transport } from "@bufbuild/connect"; import { createGrpcTransport } from "@bufbuild/connect-node"; import { createConnectTransport } from "@bufbuild/connect-web"; -import { Any } from "@bufbuild/protobuf" +import { Any, AnyMessage } from "@bufbuild/protobuf" +export { Any, AnyMessage }; // Substream generated code // buf generate buf.build/streamingfast/substreams:develop @@ -12,17 +13,26 @@ import { Stream } from './generated/sf/substreams/v1/substreams_connect.js'; import { Modules } from './generated/sf/substreams/v1/modules_pb.js'; import { BlockScopedData, ForkStep, Request, ModuleOutput, StoreDeltas } from './generated/sf/substreams/v1/substreams_pb.js'; -// Export utils & Typescript interfaces +// Export generated substreams protobufs export * from "./generated/sf/substreams/v1/clock_pb.js"; export * from "./generated/sf/substreams/v1/modules_pb.js"; export * from "./generated/sf/substreams/v1/package_pb.js"; export * from "./generated/sf/substreams/v1/substreams_pb.js"; export * from "./generated/sf/substreams/v1/substreams_connect.js"; + +// Export generated sink protobufs +export { EntityChanges, EntityChange, EntityChange_Operation } from "./generated/sf/substreams/sink/entity/v1/entity_pb.js" +export { DatabaseChanges, TableChange, TableChange_Operation } from "./generated/sf/substreams/sink/database/v1/database_pb.js" +export { KVOperations, KVOperation, KVOperation_Type } from "./generated/sf/substreams/sink/kv/v1/kv_pb.js" +export { PrometheusOperations, PrometheusOperation, GaugeOp, GaugeOp_Operation } from "./generated/pinax/substreams/sink/prometheus/v1/prometheus_pb.js" +export { LoggerOperations, LoggerOperation, LoggingLevels } from "./generated/pinax/substreams/sink/winston/v1/winston_pb.js" + +// Export utils export * from "./utils.js"; export * from "./authorization.js"; // Utils -import { parseBlockData, parseStopBlock, unpack, isNode, calculateHeadBlockTimeDrift } from './utils.js'; +import { parseBlockData, parseStopBlock, unpack, isNode, calculateHeadBlockTimeDrift, decode } from './utils.js'; import { Clock } from './generated/sf/substreams/v1/clock_pb.js'; // types @@ -46,12 +56,13 @@ export interface StoreDelta extends ModuleOutput { export const DEFAULT_HOST = "https://mainnet.eth.streamingfast.io:443"; export const DEFAULT_AUTH = "https://auth.streamingfast.io/v1/auth/issue"; -export const DEFAULT_IPFS = "https://ipfs.io/ipfs/"; +export const DEFAULT_IPFS = "https://ipfs.pinax.network/ipfs/"; type MessageEvents = { block: (block: BlockScopedData) => void; clock: (clock: Clock) => void; mapOutput: (output: MapOutput, clock: Clock) => void; + anyMessage: (message: AnyMessage, clock: Clock) => void; debugStoreDeltas: (output: StoreDelta, clock: Clock) => void; cursor: (cursor: string, clock: Clock) => void; start: (cursor: string, clock: Clock) => void; @@ -180,9 +191,16 @@ export class Substreams extends (EventEmitter as new () => TypedEmitter setTimeout(resolve, ms)) +} + +export function decode(output: ModuleOutput, registry: Registry) { + if ( !output.data.value ) return null; + if ( output.data.case === "mapOutput" ) { + const { value, typeUrl } = output.data.value; + const typeName = typeUrl.replace("type.googleapis.com/", "") + const message = registry.findMessage(typeName); + if ( !message ) return null; + return message.fromBinary(value); + } + return null; } \ No newline at end of file