@sentio/runtime 2.2.0 → 2.3.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/service.js CHANGED
@@ -111,7 +111,7 @@ export class ProcessorServiceImpl {
111
111
  }
112
112
  }
113
113
  function recordRuntimeInfo(results, handlerType) {
114
- for (const list of [results.gauges, results.counters, results.logs, results.events, results.exports]) {
114
+ for (const list of [results.gauges, results.counters, results.events, results.exports]) {
115
115
  list.forEach((e) => {
116
116
  e.runtimeInfo = {
117
117
  from: handlerType,
@@ -1 +1 @@
1
- {"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,WAAW,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAE5D,OAAO,EAML,qBAAqB,GAKtB,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAC5D;AAAC,MAAM,CAAC,SAAiB,CAAC,MAAM,GAAG;IAClC,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAA;AACxB,CAAC,CAAA;AAED,MAAM,OAAO,oBAAoB;IACvB,OAAO,GAAG,KAAK,CAAA;IACf,eAAe,CAAuB;IAE7B,MAAM,CAAoB;IAE1B,eAAe,CAAa;IAE7C,YAAY,MAA0B,EAAE,eAA4B;QAClE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,eAAe,GAAG,eAAe,CAAA;IACxC,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,OAA6B,EAAE,OAAoB;QACjE,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACjB,MAAM,IAAI,WAAW,CAAC,MAAM,CAAC,WAAW,EAAE,sBAAsB,CAAC,CAAA;SAClE;QACD,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE;YACzB,MAA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,EAAE,MAAM,OAAO,IAAI,QAAQ,EAAE;YACpC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAA;YACjD,IAAI,OAAO,GAAG,KAAK,CAAA;YACnB,IAAI,aAAa,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE;gBAC1D,MAAM,IAAI,CAAC,SAAS,EAAE,CAAA;gBACtB,OAAO,GAAG,IAAI,CAAA;aACf;YACD,MAAM;gBACJ,MAAM;gBACN,aAAa,EAAE,OAAO;aACvB,CAAA;SACF;IACH,CAAC;CACF;AAED,SAAS,iBAAiB,CAAC,OAAsB,EAAE,WAAwB;IACzE,KAAK,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE;QACpG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;YACjB,CAAC,CAAC,WAAW,GAAG;gBACd,IAAI,EAAE,WAAW;aAClB,CAAA;QACH,CAAC,CAAC,CAAA;KACH;AACH,CAAC","sourcesContent":["import { CallContext, ServerError, Status } from 'nice-grpc'\n\nimport {\n DataBinding,\n HandlerType,\n ProcessBindingResponse,\n ProcessBindingsRequest,\n ProcessConfigRequest,\n ProcessConfigResponse,\n ProcessorServiceImplementation,\n ProcessResult,\n StartRequest,\n Empty,\n} from '@sentio/protos'\n\nimport { PluginManager } from './plugin.js'\nimport { errorString, mergeProcessResults } from './utils.js'\n;(BigInt.prototype as any).toJSON = function () {\n return this.toString()\n}\n\nexport class ProcessorServiceImpl implements ProcessorServiceImplementation {\n private started = false\n private processorConfig: ProcessConfigResponse\n\n private readonly loader: () => Promise<any>\n\n private readonly shutdownHandler?: () => void\n\n constructor(loader: () => Promise<any>, shutdownHandler?: () => void) {\n this.loader = loader\n this.shutdownHandler = shutdownHandler\n }\n\n async getConfig(request: ProcessConfigRequest, context: CallContext): Promise<ProcessConfigResponse> {\n if (!this.started) {\n throw new ServerError(Status.UNAVAILABLE, 'Service Not started.')\n }\n if (!this.processorConfig) {\n throw new ServerError(Status.INTERNAL, 'Process config empty.')\n }\n return this.processorConfig\n }\n\n async configure() {\n this.processorConfig = ProcessConfigResponse.fromPartial({})\n await PluginManager.INSTANCE.configure(this.processorConfig)\n }\n\n async start(request: StartRequest, context: CallContext): Promise<Empty> {\n if (this.started) {\n return {}\n }\n\n try {\n // for (const plugin of ['@sentio/sdk', '@sentio/sdk/eth']) {\n // try {\n // await import(plugin)\n // } catch (e) {\n // console.error('Failed to load plugin: ', plugin)\n // }\n // }\n //\n // for (const plugin of ['@sentio/sdk/aptos', '@sentio/sdk/solana']) {\n // try {\n // await import(plugin)\n // } catch (e) {}\n // }\n\n await this.loader()\n } catch (e) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'Failed to load processor: ' + errorString(e))\n }\n\n await PluginManager.INSTANCE.start(request)\n\n try {\n await this.configure()\n } catch (e) {\n throw new ServerError(Status.INTERNAL, 'Failed to start processor : ' + errorString(e))\n }\n this.started = true\n return {}\n }\n\n async stop(request: Empty, context: CallContext): Promise<Empty> {\n console.log('Server Shutting down in 5 seconds')\n if (this.shutdownHandler) {\n setTimeout(this.shutdownHandler, 5000)\n }\n return {}\n }\n\n async processBindings(request: ProcessBindingsRequest, options?: CallContext): Promise<ProcessBindingResponse> {\n if (!this.started) {\n throw new ServerError(Status.UNAVAILABLE, 'Service Not started.')\n }\n\n const promises = request.bindings.map((binding) => this.processBinding(binding))\n let promise\n try {\n promise = await Promise.all(promises)\n } catch (e) {\n throw e\n }\n const result = mergeProcessResults(promise)\n\n let updated = false\n if (PluginManager.INSTANCE.stateDiff(this.processorConfig)) {\n await this.configure()\n updated = true\n }\n\n return {\n result,\n configUpdated: updated,\n }\n }\n\n async processBinding(request: DataBinding, options?: CallContext): Promise<ProcessResult> {\n const result = await PluginManager.INSTANCE.processBinding(request)\n recordRuntimeInfo(result, request.handlerType)\n return result\n }\n\n async *processBindingsStream(requests: AsyncIterable<DataBinding>, context: CallContext) {\n for await (const request of requests) {\n const result = await this.processBinding(request)\n let updated = false\n if (PluginManager.INSTANCE.stateDiff(this.processorConfig)) {\n await this.configure()\n updated = true\n }\n yield {\n result,\n configUpdated: updated,\n }\n }\n }\n}\n\nfunction recordRuntimeInfo(results: ProcessResult, handlerType: HandlerType) {\n for (const list of [results.gauges, results.counters, results.logs, results.events, results.exports]) {\n list.forEach((e) => {\n e.runtimeInfo = {\n from: handlerType,\n }\n })\n }\n}\n"]}
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,WAAW,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAE5D,OAAO,EAML,qBAAqB,GAKtB,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAC5D;AAAC,MAAM,CAAC,SAAiB,CAAC,MAAM,GAAG;IAClC,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAA;AACxB,CAAC,CAAA;AAED,MAAM,OAAO,oBAAoB;IACvB,OAAO,GAAG,KAAK,CAAA;IACf,eAAe,CAAuB;IAE7B,MAAM,CAAoB;IAE1B,eAAe,CAAa;IAE7C,YAAY,MAA0B,EAAE,eAA4B;QAClE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,eAAe,GAAG,eAAe,CAAA;IACxC,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,OAA6B,EAAE,OAAoB;QACjE,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACjB,MAAM,IAAI,WAAW,CAAC,MAAM,CAAC,WAAW,EAAE,sBAAsB,CAAC,CAAA;SAClE;QACD,IAAI,CAAC,IAAI,CAAC,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AoB;QACrF,IAAI,KAAK,EAAE,MAAM,OAAO,IAAI,QAAQ,EAAE;YACpC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAA;YACjD,IAAI,OAAO,GAAG,KAAK,CAAA;YACnB,IAAI,aAAa,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE;gBAC1D,MAAM,IAAI,CAAC,SAAS,EAAE,CAAA;gBACtB,OAAO,GAAG,IAAI,CAAA;aACf;YACD,MAAM;gBACJ,MAAM;gBACN,aAAa,EAAE,OAAO;aACvB,CAAA;SACF;IACH,CAAC;CACF;AAED,SAAS,iBAAiB,CAAC,OAAsB,EAAE,WAAwB;IACzE,KAAK,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE;QACtF,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;YACjB,CAAC,CAAC,WAAW,GAAG;gBACd,IAAI,EAAE,WAAW;aAClB,CAAA;QACH,CAAC,CAAC,CAAA;KACH;AACH,CAAC","sourcesContent":["import { CallContext, ServerError, Status } from 'nice-grpc'\n\nimport {\n DataBinding,\n HandlerType,\n ProcessBindingResponse,\n ProcessBindingsRequest,\n ProcessConfigRequest,\n ProcessConfigResponse,\n ProcessorServiceImplementation,\n ProcessResult,\n StartRequest,\n Empty,\n} from '@sentio/protos'\n\nimport { PluginManager } from './plugin.js'\nimport { errorString, mergeProcessResults } from './utils.js'\n;(BigInt.prototype as any).toJSON = function () {\n return this.toString()\n}\n\nexport class ProcessorServiceImpl implements ProcessorServiceImplementation {\n private started = false\n private processorConfig: ProcessConfigResponse\n\n private readonly loader: () => Promise<any>\n\n private readonly shutdownHandler?: () => void\n\n constructor(loader: () => Promise<any>, shutdownHandler?: () => void) {\n this.loader = loader\n this.shutdownHandler = shutdownHandler\n }\n\n async getConfig(request: ProcessConfigRequest, context: CallContext): Promise<ProcessConfigResponse> {\n if (!this.started) {\n throw new ServerError(Status.UNAVAILABLE, 'Service Not started.')\n }\n if (!this.processorConfig) {\n throw new ServerError(Status.INTERNAL, 'Process config empty.')\n }\n return this.processorConfig\n }\n\n async configure() {\n this.processorConfig = ProcessConfigResponse.fromPartial({})\n await PluginManager.INSTANCE.configure(this.processorConfig)\n }\n\n async start(request: StartRequest, context: CallContext): Promise<Empty> {\n if (this.started) {\n return {}\n }\n\n try {\n // for (const plugin of ['@sentio/sdk', '@sentio/sdk/eth']) {\n // try {\n // await import(plugin)\n // } catch (e) {\n // console.error('Failed to load plugin: ', plugin)\n // }\n // }\n //\n // for (const plugin of ['@sentio/sdk/aptos', '@sentio/sdk/solana']) {\n // try {\n // await import(plugin)\n // } catch (e) {}\n // }\n\n await this.loader()\n } catch (e) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'Failed to load processor: ' + errorString(e))\n }\n\n await PluginManager.INSTANCE.start(request)\n\n try {\n await this.configure()\n } catch (e) {\n throw new ServerError(Status.INTERNAL, 'Failed to start processor : ' + errorString(e))\n }\n this.started = true\n return {}\n }\n\n async stop(request: Empty, context: CallContext): Promise<Empty> {\n console.log('Server Shutting down in 5 seconds')\n if (this.shutdownHandler) {\n setTimeout(this.shutdownHandler, 5000)\n }\n return {}\n }\n\n async processBindings(request: ProcessBindingsRequest, options?: CallContext): Promise<ProcessBindingResponse> {\n if (!this.started) {\n throw new ServerError(Status.UNAVAILABLE, 'Service Not started.')\n }\n\n const promises = request.bindings.map((binding) => this.processBinding(binding))\n let promise\n try {\n promise = await Promise.all(promises)\n } catch (e) {\n throw e\n }\n const result = mergeProcessResults(promise)\n\n let updated = false\n if (PluginManager.INSTANCE.stateDiff(this.processorConfig)) {\n await this.configure()\n updated = true\n }\n\n return {\n result,\n configUpdated: updated,\n }\n }\n\n async processBinding(request: DataBinding, options?: CallContext): Promise<ProcessResult> {\n const result = await PluginManager.INSTANCE.processBinding(request)\n recordRuntimeInfo(result, request.handlerType)\n return result\n }\n\n async *processBindingsStream(requests: AsyncIterable<DataBinding>, context: CallContext) {\n for await (const request of requests) {\n const result = await this.processBinding(request)\n let updated = false\n if (PluginManager.INSTANCE.stateDiff(this.processorConfig)) {\n await this.configure()\n updated = true\n }\n yield {\n result,\n configUpdated: updated,\n }\n }\n }\n}\n\nfunction recordRuntimeInfo(results: ProcessResult, handlerType: HandlerType) {\n for (const list of [results.gauges, results.counters, results.events, results.exports]) {\n list.forEach((e) => {\n e.runtimeInfo = {\n from: handlerType,\n }\n })\n }\n}\n"]}
package/lib/utils.js CHANGED
@@ -4,7 +4,6 @@ export function mergeProcessResults(results) {
4
4
  for (const r of results) {
5
5
  res.counters = res.counters.concat(r.counters);
6
6
  res.gauges = res.gauges.concat(r.gauges);
7
- res.logs = res.logs.concat(r.logs);
8
7
  res.events = res.events.concat(r.events);
9
8
  res.exports = res.exports.concat(r.exports);
10
9
  }
package/lib/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAE9C,MAAM,UAAU,mBAAmB,CAAC,OAAwB;IAC1D,MAAM,GAAG,GAAG,aAAa,CAAC,WAAW,CAAC,EAAE,CAAC,CAAA;IAEzC,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE;QACvB,GAAG,CAAC,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAA;QAC9C,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;QACxC,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;QAClC,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;QACxC,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;KAC5C;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,CAAQ;IAClC,OAAO,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,OAAO,CAAA;AAC7B,CAAC;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,gBAAgB,CAAA","sourcesContent":["import { ProcessResult } from '@sentio/protos'\n\nexport function mergeProcessResults(results: ProcessResult[]): ProcessResult {\n const res = ProcessResult.fromPartial({})\n\n for (const r of results) {\n res.counters = res.counters.concat(r.counters)\n res.gauges = res.gauges.concat(r.gauges)\n res.logs = res.logs.concat(r.logs)\n res.events = res.events.concat(r.events)\n res.exports = res.exports.concat(r.exports)\n }\n return res\n}\n\nexport function errorString(e: Error): string {\n return e.stack || e.message\n}\n\nexport const USER_PROCESSOR = 'user_processor'\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAE9C,MAAM,UAAU,mBAAmB,CAAC,OAAwB;IAC1D,MAAM,GAAG,GAAG,aAAa,CAAC,WAAW,CAAC,EAAE,CAAC,CAAA;IAEzC,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE;QACvB,GAAG,CAAC,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAA;QAC9C,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;QACxC,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;QACxC,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;KAC5C;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,CAAQ;IAClC,OAAO,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,OAAO,CAAA;AAC7B,CAAC;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,gBAAgB,CAAA","sourcesContent":["import { ProcessResult } from '@sentio/protos'\n\nexport function mergeProcessResults(results: ProcessResult[]): ProcessResult {\n const res = ProcessResult.fromPartial({})\n\n for (const r of results) {\n res.counters = res.counters.concat(r.counters)\n res.gauges = res.gauges.concat(r.gauges)\n res.events = res.events.concat(r.events)\n res.exports = res.exports.concat(r.exports)\n }\n return res\n}\n\nexport function errorString(e: Error): string {\n return e.stack || e.message\n}\n\nexport const USER_PROCESSOR = 'user_processor'\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sentio/runtime",
3
3
  "license": "Apache-2.0",
4
- "version": "2.2.0",
4
+ "version": "2.3.0-rc.2",
5
5
  "scripts": {
6
6
  "compile": "tsc",
7
7
  "build": "yarn compile",
@@ -13,7 +13,7 @@
13
13
  "start_js": "ts-node-esm --files ./lib/processor-runner.js $PWD/../../debug/dist/lib.js"
14
14
  },
15
15
  "dependencies": {
16
- "@sentio/protos": "^2.2.0",
16
+ "@sentio/protos": "^2.3.0-rc.2",
17
17
  "command-line-args": "^5.2.1",
18
18
  "command-line-usage": "^6.1.3",
19
19
  "fs-extra": "^11.0.0",
@@ -45,5 +45,5 @@
45
45
  "!{lib,src}/tests",
46
46
  "!**/*.test.{js,ts}"
47
47
  ],
48
- "gitHead": "48b4487347d7be14ea1e7c8fb782cfc82e05ae3d"
48
+ "gitHead": "cf8fa9ac382b830e87f38c1487d65081e7089c0f"
49
49
  }
@@ -84,13 +84,7 @@ export class FullProcessorServiceImpl implements ProcessorServiceImplementation
84
84
  // y this.instance.processBindingsStream(requests, context)
85
85
  }
86
86
 
87
- private adjustResult(res: ProcessResult): void {
88
- for (const log of res.logs) {
89
- if (log.attributes && !log.attributes2) {
90
- log.attributes2 = JSON.parse(log.attributes)
91
- }
92
- }
93
- }
87
+ private adjustResult(res: ProcessResult): void {}
94
88
 
95
89
  private adjustDataBinding(dataBinding: DataBinding): void {
96
90
  switch (dataBinding.handlerType) {
@@ -37,6 +37,10 @@ export const Empty = {
37
37
  return obj;
38
38
  },
39
39
 
40
+ create(base?: DeepPartial<Empty>): Empty {
41
+ return Empty.fromPartial(base ?? {});
42
+ },
43
+
40
44
  fromPartial(_: DeepPartial<Empty>): Empty {
41
45
  const message = createBaseEmpty();
42
46
  return message;
@@ -107,6 +107,10 @@ export const Struct = {
107
107
  return obj;
108
108
  },
109
109
 
110
+ create(base?: DeepPartial<Struct>): Struct {
111
+ return Struct.fromPartial(base ?? {});
112
+ },
113
+
110
114
  fromPartial(object: DeepPartial<Struct>): Struct {
111
115
  const message = createBaseStruct();
112
116
  message.fields = Object.entries(object.fields ?? {}).reduce<{ [key: string]: any | undefined }>(
@@ -133,9 +137,11 @@ export const Struct = {
133
137
 
134
138
  unwrap(message: Struct): { [key: string]: any } {
135
139
  const object: { [key: string]: any } = {};
136
- Object.keys(message.fields).forEach((key) => {
137
- object[key] = message.fields[key];
138
- });
140
+ if (message.fields) {
141
+ Object.keys(message.fields).forEach((key) => {
142
+ object[key] = message.fields[key];
143
+ });
144
+ }
139
145
  return object;
140
146
  },
141
147
  };
@@ -187,6 +193,10 @@ export const Struct_FieldsEntry = {
187
193
  return obj;
188
194
  },
189
195
 
196
+ create(base?: DeepPartial<Struct_FieldsEntry>): Struct_FieldsEntry {
197
+ return Struct_FieldsEntry.fromPartial(base ?? {});
198
+ },
199
+
190
200
  fromPartial(object: DeepPartial<Struct_FieldsEntry>): Struct_FieldsEntry {
191
201
  const message = createBaseStruct_FieldsEntry();
192
202
  message.key = object.key ?? "";
@@ -285,6 +295,10 @@ export const Value = {
285
295
  return obj;
286
296
  },
287
297
 
298
+ create(base?: DeepPartial<Value>): Value {
299
+ return Value.fromPartial(base ?? {});
300
+ },
301
+
288
302
  fromPartial(object: DeepPartial<Value>): Value {
289
303
  const message = createBaseValue();
290
304
  message.nullValue = object.nullValue ?? undefined;
@@ -298,7 +312,6 @@ export const Value = {
298
312
 
299
313
  wrap(value: any): Value {
300
314
  const result = createBaseValue();
301
-
302
315
  if (value === null) {
303
316
  result.nullValue = NullValue.NULL_VALUE;
304
317
  } else if (typeof value === "boolean") {
@@ -314,19 +327,18 @@ export const Value = {
314
327
  } else if (typeof value !== "undefined") {
315
328
  throw new Error("Unsupported any value type: " + typeof value);
316
329
  }
317
-
318
330
  return result;
319
331
  },
320
332
 
321
- unwrap(message: Value): string | number | boolean | Object | null | Array<any> | undefined {
322
- if (message?.stringValue !== undefined) {
333
+ unwrap(message: any): string | number | boolean | Object | null | Array<any> | undefined {
334
+ if (message.stringValue !== undefined) {
323
335
  return message.stringValue;
324
336
  } else if (message?.numberValue !== undefined) {
325
337
  return message.numberValue;
326
338
  } else if (message?.boolValue !== undefined) {
327
339
  return message.boolValue;
328
340
  } else if (message?.structValue !== undefined) {
329
- return message.structValue;
341
+ return message.structValue as any;
330
342
  } else if (message?.listValue !== undefined) {
331
343
  return message.listValue;
332
344
  } else if (message?.nullValue !== undefined) {
@@ -380,22 +392,28 @@ export const ListValue = {
380
392
  return obj;
381
393
  },
382
394
 
395
+ create(base?: DeepPartial<ListValue>): ListValue {
396
+ return ListValue.fromPartial(base ?? {});
397
+ },
398
+
383
399
  fromPartial(object: DeepPartial<ListValue>): ListValue {
384
400
  const message = createBaseListValue();
385
401
  message.values = object.values?.map((e) => e) || [];
386
402
  return message;
387
403
  },
388
404
 
389
- wrap(value: Array<any> | undefined): ListValue {
405
+ wrap(array: Array<any> | undefined): ListValue {
390
406
  const result = createBaseListValue();
391
-
392
- result.values = value ?? [];
393
-
407
+ result.values = array ?? [];
394
408
  return result;
395
409
  },
396
410
 
397
411
  unwrap(message: ListValue): Array<any> {
398
- return message.values;
412
+ if (message?.hasOwnProperty("values") && Array.isArray(message.values)) {
413
+ return message.values;
414
+ } else {
415
+ return message as any;
416
+ }
399
417
  },
400
418
  };
401
419
 
@@ -57,6 +57,10 @@ export const Timestamp = {
57
57
  return obj;
58
58
  },
59
59
 
60
+ create(base?: DeepPartial<Timestamp>): Timestamp {
61
+ return Timestamp.fromPartial(base ?? {});
62
+ },
63
+
60
64
  fromPartial(object: DeepPartial<Timestamp>): Timestamp {
61
65
  const message = createBaseTimestamp();
62
66
  message.seconds = object.seconds ?? BigInt("0");