@sentio/runtime 2.0.3-rc.2 → 2.1.0-rc.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.
@@ -256,6 +256,9 @@ export declare class FullProcessorServiceImpl implements ProcessorServiceImpleme
256
256
  level?: import("./gen/processor/protos/processor.js").LogLevel | undefined;
257
257
  message?: string | undefined;
258
258
  attributes?: string | undefined;
259
+ attributes2?: {
260
+ [x: string]: any;
261
+ } | undefined;
259
262
  runtimeInfo?: {
260
263
  from?: HandlerType | undefined;
261
264
  } | undefined;
@@ -306,5 +309,6 @@ export declare class FullProcessorServiceImpl implements ProcessorServiceImpleme
306
309
  configUpdated?: boolean | undefined;
307
310
  }>;
308
311
  processBindingsStream(requests: AsyncIterable<DataBinding>, context: CallContext): AsyncGenerator<never, void, unknown>;
309
- protected adjustDataBinding(dataBinding: DataBinding): void;
312
+ private adjustResult;
313
+ private adjustDataBinding;
310
314
  }
@@ -37,12 +37,21 @@ export class FullProcessorServiceImpl {
37
37
  for (const binding of request.bindings) {
38
38
  this.adjustDataBinding(binding);
39
39
  }
40
- return await this.instance.processBindings(request, options);
40
+ const result = await this.instance.processBindings(request, options);
41
+ this.adjustResult(result.result);
42
+ return result;
41
43
  }
42
44
  async *processBindingsStream(requests, context) {
43
45
  throw new Error('Not Implemented for streaming');
44
46
  // y this.instance.processBindingsStream(requests, context)
45
47
  }
48
+ adjustResult(res) {
49
+ for (const log of res.logs) {
50
+ if (log.attributes && !log.attributes2) {
51
+ log.attributes2 = JSON.parse(log.attributes);
52
+ }
53
+ }
54
+ }
46
55
  adjustDataBinding(dataBinding) {
47
56
  switch (dataBinding.handlerType) {
48
57
  case HandlerType.APT_EVENT:
@@ -1 +1 @@
1
- {"version":3,"file":"full-service.js","sourceRoot":"","sources":["../src/full-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AACtC,MAAM,OAAO,GAAG,aAAa,CAAC,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,EAAE;wBACrC,gGAAgG;wBAChG,sBAAsB;wBACtB,WAAW,CAAC,IAAI,CAAC,GAAG,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAA;qBACjG;iBACF;gBACD,MAAK;YACP;gBACE,MAAK;SACR;IACH,CAAC;CACF","sourcesContent":["import { CallContext } from 'nice-grpc'\nimport { createRequire } from 'module'\nconst require = createRequire(import.meta.url)\n\n// Different than the simple one which\nimport {\n DataBinding,\n HandlerType,\n ProcessBindingsRequest,\n ProcessConfigRequest,\n ProcessorServiceImplementation,\n StartRequest,\n} from './gen/processor/protos/processor.js'\n\nimport { Empty } from '@sentio/protos'\nimport fs from 'fs-extra'\nimport * as assert from 'assert'\nimport path from 'path'\n\nfunction locatePackageJson(pkgId: string) {\n const m = require.resolve(pkgId)\n\n let dir = path.dirname(m)\n while (!fs.existsSync(path.join(dir, 'package.json'))) {\n dir = path.dirname(dir)\n }\n const content = fs.readFileSync(path.join(dir, 'package.json'), 'utf-8')\n return JSON.parse(content)\n}\n\nexport class FullProcessorServiceImpl implements ProcessorServiceImplementation {\n constructor(instance: ProcessorServiceImplementation) {\n this.instance = instance\n const sdkPackageJson = locatePackageJson('@sentio/sdk')\n const runtimePackageJson = locatePackageJson('@sentio/runtime')\n\n console.log('Runtime version:', runtimePackageJson.version, 'SDK version:', sdkPackageJson.version)\n\n const version = sdkPackageJson.version.split('.')\n this.sdkMinorVersion = parseInt(version[1])\n }\n\n instance: ProcessorServiceImplementation\n sdkMinorVersion: number\n\n async getConfig(request: ProcessConfigRequest, context: CallContext) {\n return await this.instance.getConfig(request, context)\n }\n\n async start(request: StartRequest, context: CallContext) {\n return await this.instance.start(request, context)\n }\n\n async stop(request: Empty, context: CallContext) {\n return await this.instance.stop(request, context)\n }\n\n async processBindings(request: ProcessBindingsRequest, options: CallContext) {\n for (const binding of request.bindings) {\n this.adjustDataBinding(binding)\n }\n return await this.instance.processBindings(request, options)\n }\n\n async *processBindingsStream(requests: AsyncIterable<DataBinding>, context: CallContext) {\n throw new Error('Not Implemented for streaming')\n // y this.instance.processBindingsStream(requests, context)\n }\n\n protected adjustDataBinding(dataBinding: DataBinding): void {\n switch (dataBinding.handlerType) {\n case HandlerType.APT_EVENT:\n if (dataBinding.data?.aptEvent) {\n // const aptEvent = dataBinding.data.aptEvent\n // if (aptEvent.event && this.sdkMinorVersion < 40) {\n // assert.ok(aptEvent.transaction, 'No Transaction')\n // aptEvent.transaction.events = [aptEvent.event]\n // }\n }\n break\n case HandlerType.UNKNOWN:\n if (dataBinding.data?.ethBlock) {\n if (dataBinding.data.raw.length === 0) {\n // This is actually not needed in current system, just as initla test propose, move to test only\n // when this is stable\n dataBinding.data.raw = new TextEncoder().encode(JSON.stringify(dataBinding.data.ethBlock.block))\n }\n }\n break\n default:\n break\n }\n }\n}\n"]}
1
+ {"version":3,"file":"full-service.js","sourceRoot":"","sources":["../src/full-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AACtC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAE9C,sCAAsC;AACtC,OAAO,EAEL,WAAW,GAMZ,MAAM,qCAAqC,CAAA;AAG5C,OAAO,EAAE,MAAM,UAAU,CAAA;AACzB,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB,SAAS,iBAAiB,CAAC,KAAa;IACtC,MAAM,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IAEhC,IAAI,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;IACzB,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC,EAAE;QACrD,GAAG,GAAG,IAAI,CAAC,OAAO,CAA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WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAA;qBACjG;iBACF;gBACD,MAAK;YACP;gBACE,MAAK;SACR;IACH,CAAC;CACF","sourcesContent":["import { CallContext } from 'nice-grpc'\nimport { createRequire } from 'module'\nconst require = createRequire(import.meta.url)\n\n// Different than the simple one which\nimport {\n DataBinding,\n HandlerType,\n ProcessBindingsRequest,\n ProcessConfigRequest,\n ProcessorServiceImplementation,\n StartRequest,\n ProcessResult,\n} from './gen/processor/protos/processor.js'\n\nimport { Empty } from '@sentio/protos'\nimport fs from 'fs-extra'\nimport path from 'path'\n\nfunction locatePackageJson(pkgId: string) {\n const m = require.resolve(pkgId)\n\n let dir = path.dirname(m)\n while (!fs.existsSync(path.join(dir, 'package.json'))) {\n dir = path.dirname(dir)\n }\n const content = fs.readFileSync(path.join(dir, 'package.json'), 'utf-8')\n return JSON.parse(content)\n}\n\nexport class FullProcessorServiceImpl implements ProcessorServiceImplementation {\n constructor(instance: ProcessorServiceImplementation) {\n this.instance = instance\n const sdkPackageJson = locatePackageJson('@sentio/sdk')\n const runtimePackageJson = locatePackageJson('@sentio/runtime')\n\n console.log('Runtime version:', runtimePackageJson.version, 'SDK version:', sdkPackageJson.version)\n\n const version = sdkPackageJson.version.split('.')\n this.sdkMinorVersion = parseInt(version[1])\n }\n\n instance: ProcessorServiceImplementation\n sdkMinorVersion: number\n\n async getConfig(request: ProcessConfigRequest, context: CallContext) {\n return await this.instance.getConfig(request, context)\n }\n\n async start(request: StartRequest, context: CallContext) {\n return await this.instance.start(request, context)\n }\n\n async stop(request: Empty, context: CallContext) {\n return await this.instance.stop(request, context)\n }\n\n async processBindings(request: ProcessBindingsRequest, options: CallContext) {\n for (const binding of request.bindings) {\n this.adjustDataBinding(binding)\n }\n const result = await this.instance.processBindings(request, options)\n this.adjustResult(result.result as ProcessResult)\n return result\n }\n\n async *processBindingsStream(requests: AsyncIterable<DataBinding>, context: CallContext) {\n throw new Error('Not Implemented for streaming')\n // y this.instance.processBindingsStream(requests, context)\n }\n\n private adjustResult(res: ProcessResult): void {\n for (const log of res.logs) {\n if (log.attributes && !log.attributes2) {\n log.attributes2 = JSON.parse(log.attributes)\n }\n }\n }\n\n private adjustDataBinding(dataBinding: DataBinding): void {\n switch (dataBinding.handlerType) {\n case HandlerType.APT_EVENT:\n if (dataBinding.data?.aptEvent) {\n // const aptEvent = dataBinding.data.aptEvent\n // if (aptEvent.event && this.sdkMinorVersion < 40) {\n // assert.ok(aptEvent.transaction, 'No Transaction')\n // aptEvent.transaction.events = [aptEvent.event]\n // }\n }\n break\n case HandlerType.UNKNOWN:\n if (dataBinding.data?.ethBlock) {\n if (dataBinding.data.raw.length === 0) {\n // This is actually not needed in current system, just as initla test propose, move to test only\n // when this is stable\n dataBinding.data.raw = new TextEncoder().encode(JSON.stringify(dataBinding.data.ethBlock.block))\n }\n }\n break\n default:\n break\n }\n }\n}\n"]}
@@ -366,7 +366,11 @@ export interface LogResult {
366
366
  metadata: RecordMetaData | undefined;
367
367
  level: LogLevel;
368
368
  message: string;
369
+ /** @deprecated */
369
370
  attributes: string;
371
+ attributes2: {
372
+ [key: string]: any;
373
+ } | undefined;
370
374
  runtimeInfo: RuntimeInfo | undefined;
371
375
  }
372
376
  export interface EventTrackingResult {
@@ -3938,7 +3938,7 @@ export const CounterResult = {
3938
3938
  },
3939
3939
  };
3940
3940
  function createBaseLogResult() {
3941
- return { metadata: undefined, level: 0, message: "", attributes: "", runtimeInfo: undefined };
3941
+ return { metadata: undefined, level: 0, message: "", attributes: "", attributes2: undefined, runtimeInfo: undefined };
3942
3942
  }
3943
3943
  export const LogResult = {
3944
3944
  encode(message, writer = _m0.Writer.create()) {
@@ -3954,6 +3954,9 @@ export const LogResult = {
3954
3954
  if (message.attributes !== "") {
3955
3955
  writer.uint32(50).string(message.attributes);
3956
3956
  }
3957
+ if (message.attributes2 !== undefined) {
3958
+ Struct.encode(Struct.wrap(message.attributes2), writer.uint32(58).fork()).ldelim();
3959
+ }
3957
3960
  if (message.runtimeInfo !== undefined) {
3958
3961
  RuntimeInfo.encode(message.runtimeInfo, writer.uint32(34).fork()).ldelim();
3959
3962
  }
@@ -3978,6 +3981,9 @@ export const LogResult = {
3978
3981
  case 6:
3979
3982
  message.attributes = reader.string();
3980
3983
  break;
3984
+ case 7:
3985
+ message.attributes2 = Struct.unwrap(Struct.decode(reader, reader.uint32()));
3986
+ break;
3981
3987
  case 4:
3982
3988
  message.runtimeInfo = RuntimeInfo.decode(reader, reader.uint32());
3983
3989
  break;
@@ -3994,6 +4000,7 @@ export const LogResult = {
3994
4000
  level: isSet(object.level) ? logLevelFromJSON(object.level) : 0,
3995
4001
  message: isSet(object.message) ? String(object.message) : "",
3996
4002
  attributes: isSet(object.attributes) ? String(object.attributes) : "",
4003
+ attributes2: isObject(object.attributes2) ? object.attributes2 : undefined,
3997
4004
  runtimeInfo: isSet(object.runtimeInfo) ? RuntimeInfo.fromJSON(object.runtimeInfo) : undefined,
3998
4005
  };
3999
4006
  },
@@ -4004,6 +4011,7 @@ export const LogResult = {
4004
4011
  message.level !== undefined && (obj.level = logLevelToJSON(message.level));
4005
4012
  message.message !== undefined && (obj.message = message.message);
4006
4013
  message.attributes !== undefined && (obj.attributes = message.attributes);
4014
+ message.attributes2 !== undefined && (obj.attributes2 = message.attributes2);
4007
4015
  message.runtimeInfo !== undefined &&
4008
4016
  (obj.runtimeInfo = message.runtimeInfo ? RuntimeInfo.toJSON(message.runtimeInfo) : undefined);
4009
4017
  return obj;
@@ -4016,6 +4024,7 @@ export const LogResult = {
4016
4024
  message.level = object.level ?? 0;
4017
4025
  message.message = object.message ?? "";
4018
4026
  message.attributes = object.attributes ?? "";
4027
+ message.attributes2 = object.attributes2 ?? undefined;
4019
4028
  message.runtimeInfo = (object.runtimeInfo !== undefined && object.runtimeInfo !== null)
4020
4029
  ? RuntimeInfo.fromPartial(object.runtimeInfo)
4021
4030
  : undefined;