@code0-tech/tucana 0.0.51 → 0.0.52

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.
@@ -0,0 +1,40 @@
1
+ import {Value} from "../pb/shared.struct_pb.js";
2
+
3
+ type AllowedValue = null | number | string | boolean | Array<AllowedValue> | object;
4
+
5
+ export function constructValue(value: AllowedValue): Value {
6
+ if (value === null) {
7
+ return {kind: {oneofKind: "nullValue", nullValue: 0}};
8
+ }
9
+ if (typeof value === "number") {
10
+ return {kind: {oneofKind: "numberValue", numberValue: value}};
11
+ }
12
+ if (typeof value === "string") {
13
+ return {kind: {oneofKind: "stringValue", stringValue: value}};
14
+ }
15
+ if (typeof value === "boolean") {
16
+ return {kind: {oneofKind: "boolValue", boolValue: value}};
17
+ }
18
+ if (Array.isArray(value)) {
19
+ const listValues = value.map(v => constructValue(v));
20
+ return {
21
+ kind: {
22
+ oneofKind: "listValue",
23
+ listValue: {values: listValues}
24
+ }
25
+ };
26
+ }
27
+ if (typeof value === "object") {
28
+ const structFields: {[key: string]: Value} = {};
29
+ for (const [k, v] of Object.entries(value)) {
30
+ structFields[k] = constructValue(v);
31
+ }
32
+ return {
33
+ kind: {
34
+ oneofKind: "structValue",
35
+ structValue: {fields: structFields}
36
+ }
37
+ };
38
+ }
39
+ throw new Error(`Unsupported value type: ${typeof value}`);
40
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code0-tech/tucana",
3
- "version": "0.0.51",
3
+ "version": "0.0.52",
4
4
  "description": "Code0 GRPC Protocol",
5
5
  "homepage": "https://github.com/code0-tech/tucana#readme",
6
6
  "bugs": {
@@ -25,6 +25,8 @@
25
25
  "protoc": "^33.0.0"
26
26
  },
27
27
  "files": [
28
+ "helpers/*.ts",
29
+ "helpers/*.js",
28
30
  "pb/*.ts",
29
31
  "pb/*.js",
30
32
  "index.js",
@@ -7,7 +7,6 @@ import type { BinaryReadOptions } from "@protobuf-ts/runtime";
7
7
  import type { IBinaryReader } from "@protobuf-ts/runtime";
8
8
  import type { PartialMessage } from "@protobuf-ts/runtime";
9
9
  import { MessageType } from "@protobuf-ts/runtime";
10
- import { Struct } from "./shared.struct_pb";
11
10
  import { Value } from "./shared.struct_pb";
12
11
  import { ExecutionDataType } from "./shared.data_type_pb";
13
12
  /**
@@ -105,9 +104,9 @@ export interface FlowSetting {
105
104
  */
106
105
  flowSettingId: string;
107
106
  /**
108
- * @generated from protobuf field: shared.Struct object = 3
107
+ * @generated from protobuf field: shared.Value value = 3
109
108
  */
110
- object?: Struct;
109
+ value?: Value;
111
110
  }
112
111
  /**
113
112
  * @generated from protobuf message shared.NodeFunction
@@ -5,7 +5,6 @@ import { WireType } from "@protobuf-ts/runtime";
5
5
  import { UnknownFieldHandler } from "@protobuf-ts/runtime";
6
6
  import { reflectionMergePartial } from "@protobuf-ts/runtime";
7
7
  import { MessageType } from "@protobuf-ts/runtime";
8
- import { Struct } from "./shared.struct_pb";
9
8
  import { Value } from "./shared.struct_pb";
10
9
  import { ExecutionDataType } from "./shared.data_type_pb";
11
10
  // @generated message type with reflection information, may provide speed optimized methods
@@ -208,7 +207,7 @@ class FlowSetting$Type extends MessageType {
208
207
  super("shared.FlowSetting", [
209
208
  { no: 1, name: "database_id", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 0 /*LongType.BIGINT*/ },
210
209
  { no: 2, name: "flow_setting_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
211
- { no: 3, name: "object", kind: "message", T: () => Struct }
210
+ { no: 3, name: "value", kind: "message", T: () => Value }
212
211
  ]);
213
212
  }
214
213
  create(value) {
@@ -230,8 +229,8 @@ class FlowSetting$Type extends MessageType {
230
229
  case /* string flow_setting_id */ 2:
231
230
  message.flowSettingId = reader.string();
232
231
  break;
233
- case /* shared.Struct object */ 3:
234
- message.object = Struct.internalBinaryRead(reader, reader.uint32(), options, message.object);
232
+ case /* shared.Value value */ 3:
233
+ message.value = Value.internalBinaryRead(reader, reader.uint32(), options, message.value);
235
234
  break;
236
235
  default:
237
236
  let u = options.readUnknownField;
@@ -251,9 +250,9 @@ class FlowSetting$Type extends MessageType {
251
250
  /* string flow_setting_id = 2; */
252
251
  if (message.flowSettingId !== "")
253
252
  writer.tag(2, WireType.LengthDelimited).string(message.flowSettingId);
254
- /* shared.Struct object = 3; */
255
- if (message.object)
256
- Struct.internalBinaryWrite(message.object, writer.tag(3, WireType.LengthDelimited).fork(), options).join();
253
+ /* shared.Value value = 3; */
254
+ if (message.value)
255
+ Value.internalBinaryWrite(message.value, writer.tag(3, WireType.LengthDelimited).fork(), options).join();
257
256
  let u = options.writeUnknownFields;
258
257
  if (u !== false)
259
258
  (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);