@fatehan/tsrp 1.0.12 → 1.0.13

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.
@@ -5,63 +5,69 @@
5
5
  // protoc v3.21.12
6
6
  // source: packets/messages.proto
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.DeviceMessage = exports.DeviceAnswer = exports.DeviceCommandAkn = exports.DeviceCommand = exports.DeviceCommandAkn_Status = exports.protobufPackage = void 0;
9
- exports.deviceCommandAkn_StatusFromJSON = deviceCommandAkn_StatusFromJSON;
10
- exports.deviceCommandAkn_StatusToJSON = deviceCommandAkn_StatusToJSON;
8
+ exports.Command = exports.CommandAkn = exports.CommandContent = exports.CommandStatus = exports.protobufPackage = void 0;
9
+ exports.commandStatusFromJSON = commandStatusFromJSON;
10
+ exports.commandStatusToJSON = commandStatusToJSON;
11
11
  /* eslint-disable */
12
12
  const wire_1 = require("@bufbuild/protobuf/wire");
13
13
  exports.protobufPackage = "com.fatehan.packets";
14
- var DeviceCommandAkn_Status;
15
- (function (DeviceCommandAkn_Status) {
16
- DeviceCommandAkn_Status[DeviceCommandAkn_Status["OFFLINE"] = 0] = "OFFLINE";
17
- DeviceCommandAkn_Status[DeviceCommandAkn_Status["SENT"] = 1] = "SENT";
18
- DeviceCommandAkn_Status[DeviceCommandAkn_Status["ERROR"] = 2] = "ERROR";
19
- DeviceCommandAkn_Status[DeviceCommandAkn_Status["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
20
- })(DeviceCommandAkn_Status || (exports.DeviceCommandAkn_Status = DeviceCommandAkn_Status = {}));
21
- function deviceCommandAkn_StatusFromJSON(object) {
14
+ var CommandStatus;
15
+ (function (CommandStatus) {
16
+ CommandStatus[CommandStatus["PENDING"] = 0] = "PENDING";
17
+ CommandStatus[CommandStatus["OFFLINE"] = 1] = "OFFLINE";
18
+ CommandStatus[CommandStatus["ERROR"] = 2] = "ERROR";
19
+ CommandStatus[CommandStatus["SENT"] = 3] = "SENT";
20
+ CommandStatus[CommandStatus["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
21
+ })(CommandStatus || (exports.CommandStatus = CommandStatus = {}));
22
+ function commandStatusFromJSON(object) {
22
23
  switch (object) {
23
24
  case 0:
24
- case "OFFLINE":
25
- return DeviceCommandAkn_Status.OFFLINE;
25
+ case "PENDING":
26
+ return CommandStatus.PENDING;
26
27
  case 1:
27
- case "SENT":
28
- return DeviceCommandAkn_Status.SENT;
28
+ case "OFFLINE":
29
+ return CommandStatus.OFFLINE;
29
30
  case 2:
30
31
  case "ERROR":
31
- return DeviceCommandAkn_Status.ERROR;
32
+ return CommandStatus.ERROR;
33
+ case 3:
34
+ case "SENT":
35
+ return CommandStatus.SENT;
32
36
  case -1:
33
37
  case "UNRECOGNIZED":
34
38
  default:
35
- return DeviceCommandAkn_Status.UNRECOGNIZED;
39
+ return CommandStatus.UNRECOGNIZED;
36
40
  }
37
41
  }
38
- function deviceCommandAkn_StatusToJSON(object) {
42
+ function commandStatusToJSON(object) {
39
43
  switch (object) {
40
- case DeviceCommandAkn_Status.OFFLINE:
44
+ case CommandStatus.PENDING:
45
+ return "PENDING";
46
+ case CommandStatus.OFFLINE:
41
47
  return "OFFLINE";
42
- case DeviceCommandAkn_Status.SENT:
43
- return "SENT";
44
- case DeviceCommandAkn_Status.ERROR:
48
+ case CommandStatus.ERROR:
45
49
  return "ERROR";
46
- case DeviceCommandAkn_Status.UNRECOGNIZED:
50
+ case CommandStatus.SENT:
51
+ return "SENT";
52
+ case CommandStatus.UNRECOGNIZED:
47
53
  default:
48
54
  return "UNRECOGNIZED";
49
55
  }
50
56
  }
51
- function createBaseDeviceCommand() {
52
- return { command: "" };
57
+ function createBaseCommandContent() {
58
+ return { message: "" };
53
59
  }
54
- exports.DeviceCommand = {
60
+ exports.CommandContent = {
55
61
  encode(message, writer = new wire_1.BinaryWriter()) {
56
- if (message.command !== "") {
57
- writer.uint32(10).string(message.command);
62
+ if (message.message !== "") {
63
+ writer.uint32(10).string(message.message);
58
64
  }
59
65
  return writer;
60
66
  },
61
67
  decode(input, length) {
62
68
  const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
63
69
  let end = length === undefined ? reader.len : reader.pos + length;
64
- const message = createBaseDeviceCommand();
70
+ const message = createBaseCommandContent();
65
71
  while (reader.pos < end) {
66
72
  const tag = reader.uint32();
67
73
  switch (tag >>> 3) {
@@ -69,7 +75,7 @@ exports.DeviceCommand = {
69
75
  if (tag !== 10) {
70
76
  break;
71
77
  }
72
- message.command = reader.string();
78
+ message.message = reader.string();
73
79
  continue;
74
80
  }
75
81
  }
@@ -81,45 +87,42 @@ exports.DeviceCommand = {
81
87
  return message;
82
88
  },
83
89
  fromJSON(object) {
84
- return { command: isSet(object.command) ? globalThis.String(object.command) : "" };
90
+ return { message: isSet(object.message) ? globalThis.String(object.message) : "" };
85
91
  },
86
92
  toJSON(message) {
87
93
  const obj = {};
88
- if (message.command !== "") {
89
- obj.command = message.command;
94
+ if (message.message !== "") {
95
+ obj.message = message.message;
90
96
  }
91
97
  return obj;
92
98
  },
93
99
  create(base) {
94
- return exports.DeviceCommand.fromPartial(base !== null && base !== void 0 ? base : {});
100
+ return exports.CommandContent.fromPartial(base !== null && base !== void 0 ? base : {});
95
101
  },
96
102
  fromPartial(object) {
97
103
  var _a;
98
- const message = createBaseDeviceCommand();
99
- message.command = (_a = object.command) !== null && _a !== void 0 ? _a : "";
104
+ const message = createBaseCommandContent();
105
+ message.message = (_a = object.message) !== null && _a !== void 0 ? _a : "";
100
106
  return message;
101
107
  },
102
108
  };
103
- function createBaseDeviceCommandAkn() {
104
- return { status: 0, code: undefined, message: undefined };
109
+ function createBaseCommandAkn() {
110
+ return { code: 0, message: "" };
105
111
  }
106
- exports.DeviceCommandAkn = {
112
+ exports.CommandAkn = {
107
113
  encode(message, writer = new wire_1.BinaryWriter()) {
108
- if (message.status !== 0) {
109
- writer.uint32(8).int32(message.status);
114
+ if (message.code !== 0) {
115
+ writer.uint32(8).sint32(message.code);
110
116
  }
111
- if (message.code !== undefined) {
112
- writer.uint32(16).sint64(message.code);
113
- }
114
- if (message.message !== undefined) {
115
- writer.uint32(26).string(message.message);
117
+ if (message.message !== "") {
118
+ writer.uint32(18).string(message.message);
116
119
  }
117
120
  return writer;
118
121
  },
119
122
  decode(input, length) {
120
123
  const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
121
124
  let end = length === undefined ? reader.len : reader.pos + length;
122
- const message = createBaseDeviceCommandAkn();
125
+ const message = createBaseCommandAkn();
123
126
  while (reader.pos < end) {
124
127
  const tag = reader.uint32();
125
128
  switch (tag >>> 3) {
@@ -127,18 +130,11 @@ exports.DeviceCommandAkn = {
127
130
  if (tag !== 8) {
128
131
  break;
129
132
  }
130
- message.status = reader.int32();
133
+ message.code = reader.sint32();
131
134
  continue;
132
135
  }
133
136
  case 2: {
134
- if (tag !== 16) {
135
- break;
136
- }
137
- message.code = longToNumber(reader.sint64());
138
- continue;
139
- }
140
- case 3: {
141
- if (tag !== 26) {
137
+ if (tag !== 18) {
142
138
  break;
143
139
  }
144
140
  message.message = reader.string();
@@ -154,114 +150,66 @@ exports.DeviceCommandAkn = {
154
150
  },
155
151
  fromJSON(object) {
156
152
  return {
157
- status: isSet(object.status) ? deviceCommandAkn_StatusFromJSON(object.status) : 0,
158
- code: isSet(object.code) ? globalThis.Number(object.code) : undefined,
159
- message: isSet(object.message) ? globalThis.String(object.message) : undefined,
153
+ code: isSet(object.code) ? globalThis.Number(object.code) : 0,
154
+ message: isSet(object.message) ? globalThis.String(object.message) : "",
160
155
  };
161
156
  },
162
157
  toJSON(message) {
163
158
  const obj = {};
164
- if (message.status !== 0) {
165
- obj.status = deviceCommandAkn_StatusToJSON(message.status);
166
- }
167
- if (message.code !== undefined) {
159
+ if (message.code !== 0) {
168
160
  obj.code = Math.round(message.code);
169
161
  }
170
- if (message.message !== undefined) {
162
+ if (message.message !== "") {
171
163
  obj.message = message.message;
172
164
  }
173
165
  return obj;
174
166
  },
175
167
  create(base) {
176
- return exports.DeviceCommandAkn.fromPartial(base !== null && base !== void 0 ? base : {});
168
+ return exports.CommandAkn.fromPartial(base !== null && base !== void 0 ? base : {});
177
169
  },
178
170
  fromPartial(object) {
179
- var _a, _b, _c;
180
- const message = createBaseDeviceCommandAkn();
181
- message.status = (_a = object.status) !== null && _a !== void 0 ? _a : 0;
182
- message.code = (_b = object.code) !== null && _b !== void 0 ? _b : undefined;
183
- message.message = (_c = object.message) !== null && _c !== void 0 ? _c : undefined;
171
+ var _a, _b;
172
+ const message = createBaseCommandAkn();
173
+ message.code = (_a = object.code) !== null && _a !== void 0 ? _a : 0;
174
+ message.message = (_b = object.message) !== null && _b !== void 0 ? _b : "";
184
175
  return message;
185
176
  },
186
177
  };
187
- function createBaseDeviceAnswer() {
188
- return { answer: "" };
178
+ function createBaseCommand() {
179
+ return { id: 0, deviceId: 0, userId: 0, commandId: 0, replyId: 0, status: 0, command: undefined, akn: undefined };
189
180
  }
190
- exports.DeviceAnswer = {
181
+ exports.Command = {
191
182
  encode(message, writer = new wire_1.BinaryWriter()) {
192
- if (message.answer !== "") {
193
- writer.uint32(10).string(message.answer);
183
+ if (message.id !== 0) {
184
+ writer.uint32(8).uint64(message.id);
194
185
  }
195
- return writer;
196
- },
197
- decode(input, length) {
198
- const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
199
- let end = length === undefined ? reader.len : reader.pos + length;
200
- const message = createBaseDeviceAnswer();
201
- while (reader.pos < end) {
202
- const tag = reader.uint32();
203
- switch (tag >>> 3) {
204
- case 1: {
205
- if (tag !== 10) {
206
- break;
207
- }
208
- message.answer = reader.string();
209
- continue;
210
- }
211
- }
212
- if ((tag & 7) === 4 || tag === 0) {
213
- break;
214
- }
215
- reader.skip(tag & 7);
186
+ if (message.deviceId !== 0) {
187
+ writer.uint32(16).uint64(message.deviceId);
216
188
  }
217
- return message;
218
- },
219
- fromJSON(object) {
220
- return { answer: isSet(object.answer) ? globalThis.String(object.answer) : "" };
221
- },
222
- toJSON(message) {
223
- const obj = {};
224
- if (message.answer !== "") {
225
- obj.answer = message.answer;
189
+ if (message.userId !== 0) {
190
+ writer.uint32(24).uint64(message.userId);
226
191
  }
227
- return obj;
228
- },
229
- create(base) {
230
- return exports.DeviceAnswer.fromPartial(base !== null && base !== void 0 ? base : {});
231
- },
232
- fromPartial(object) {
233
- var _a;
234
- const message = createBaseDeviceAnswer();
235
- message.answer = (_a = object.answer) !== null && _a !== void 0 ? _a : "";
236
- return message;
237
- },
238
- };
239
- function createBaseDeviceMessage() {
240
- return { deviceId: 0, transactionId: 0, command: undefined, akn: undefined, answer: undefined };
241
- }
242
- exports.DeviceMessage = {
243
- encode(message, writer = new wire_1.BinaryWriter()) {
244
- if (message.deviceId !== 0) {
245
- writer.uint32(8).uint64(message.deviceId);
192
+ if (message.commandId !== 0) {
193
+ writer.uint32(32).uint64(message.commandId);
194
+ }
195
+ if (message.replyId !== 0) {
196
+ writer.uint32(40).uint64(message.replyId);
246
197
  }
247
- if (message.transactionId !== 0) {
248
- writer.uint32(16).uint64(message.transactionId);
198
+ if (message.status !== 0) {
199
+ writer.uint32(48).int32(message.status);
249
200
  }
250
201
  if (message.command !== undefined) {
251
- exports.DeviceCommand.encode(message.command, writer.uint32(26).fork()).join();
202
+ exports.CommandContent.encode(message.command, writer.uint32(58).fork()).join();
252
203
  }
253
204
  if (message.akn !== undefined) {
254
- exports.DeviceCommandAkn.encode(message.akn, writer.uint32(34).fork()).join();
255
- }
256
- if (message.answer !== undefined) {
257
- exports.DeviceAnswer.encode(message.answer, writer.uint32(42).fork()).join();
205
+ exports.CommandAkn.encode(message.akn, writer.uint32(66).fork()).join();
258
206
  }
259
207
  return writer;
260
208
  },
261
209
  decode(input, length) {
262
210
  const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
263
211
  let end = length === undefined ? reader.len : reader.pos + length;
264
- const message = createBaseDeviceMessage();
212
+ const message = createBaseCommand();
265
213
  while (reader.pos < end) {
266
214
  const tag = reader.uint32();
267
215
  switch (tag >>> 3) {
@@ -269,35 +217,56 @@ exports.DeviceMessage = {
269
217
  if (tag !== 8) {
270
218
  break;
271
219
  }
272
- message.deviceId = longToNumber(reader.uint64());
220
+ message.id = longToNumber(reader.uint64());
273
221
  continue;
274
222
  }
275
223
  case 2: {
276
224
  if (tag !== 16) {
277
225
  break;
278
226
  }
279
- message.transactionId = longToNumber(reader.uint64());
227
+ message.deviceId = longToNumber(reader.uint64());
280
228
  continue;
281
229
  }
282
230
  case 3: {
283
- if (tag !== 26) {
231
+ if (tag !== 24) {
284
232
  break;
285
233
  }
286
- message.command = exports.DeviceCommand.decode(reader, reader.uint32());
234
+ message.userId = longToNumber(reader.uint64());
287
235
  continue;
288
236
  }
289
237
  case 4: {
290
- if (tag !== 34) {
238
+ if (tag !== 32) {
291
239
  break;
292
240
  }
293
- message.akn = exports.DeviceCommandAkn.decode(reader, reader.uint32());
241
+ message.commandId = longToNumber(reader.uint64());
294
242
  continue;
295
243
  }
296
244
  case 5: {
297
- if (tag !== 42) {
245
+ if (tag !== 40) {
246
+ break;
247
+ }
248
+ message.replyId = longToNumber(reader.uint64());
249
+ continue;
250
+ }
251
+ case 6: {
252
+ if (tag !== 48) {
298
253
  break;
299
254
  }
300
- message.answer = exports.DeviceAnswer.decode(reader, reader.uint32());
255
+ message.status = reader.int32();
256
+ continue;
257
+ }
258
+ case 7: {
259
+ if (tag !== 58) {
260
+ break;
261
+ }
262
+ message.command = exports.CommandContent.decode(reader, reader.uint32());
263
+ continue;
264
+ }
265
+ case 8: {
266
+ if (tag !== 66) {
267
+ break;
268
+ }
269
+ message.akn = exports.CommandAkn.decode(reader, reader.uint32());
301
270
  continue;
302
271
  }
303
272
  }
@@ -310,49 +279,60 @@ exports.DeviceMessage = {
310
279
  },
311
280
  fromJSON(object) {
312
281
  return {
282
+ id: isSet(object.id) ? globalThis.Number(object.id) : 0,
313
283
  deviceId: isSet(object.device_id) ? globalThis.Number(object.device_id) : 0,
314
- transactionId: isSet(object.transaction_id) ? globalThis.Number(object.transaction_id) : 0,
315
- command: isSet(object.command) ? exports.DeviceCommand.fromJSON(object.command) : undefined,
316
- akn: isSet(object.akn) ? exports.DeviceCommandAkn.fromJSON(object.akn) : undefined,
317
- answer: isSet(object.answer) ? exports.DeviceAnswer.fromJSON(object.answer) : undefined,
284
+ userId: isSet(object.user_id) ? globalThis.Number(object.user_id) : 0,
285
+ commandId: isSet(object.command_id) ? globalThis.Number(object.command_id) : 0,
286
+ replyId: isSet(object.reply_id) ? globalThis.Number(object.reply_id) : 0,
287
+ status: isSet(object.status) ? commandStatusFromJSON(object.status) : 0,
288
+ command: isSet(object.command) ? exports.CommandContent.fromJSON(object.command) : undefined,
289
+ akn: isSet(object.akn) ? exports.CommandAkn.fromJSON(object.akn) : undefined,
318
290
  };
319
291
  },
320
292
  toJSON(message) {
321
293
  const obj = {};
294
+ if (message.id !== 0) {
295
+ obj.id = Math.round(message.id);
296
+ }
322
297
  if (message.deviceId !== 0) {
323
298
  obj.device_id = Math.round(message.deviceId);
324
299
  }
325
- if (message.transactionId !== 0) {
326
- obj.transaction_id = Math.round(message.transactionId);
300
+ if (message.userId !== 0) {
301
+ obj.user_id = Math.round(message.userId);
302
+ }
303
+ if (message.commandId !== 0) {
304
+ obj.command_id = Math.round(message.commandId);
305
+ }
306
+ if (message.replyId !== 0) {
307
+ obj.reply_id = Math.round(message.replyId);
308
+ }
309
+ if (message.status !== 0) {
310
+ obj.status = commandStatusToJSON(message.status);
327
311
  }
328
312
  if (message.command !== undefined) {
329
- obj.command = exports.DeviceCommand.toJSON(message.command);
313
+ obj.command = exports.CommandContent.toJSON(message.command);
330
314
  }
331
315
  if (message.akn !== undefined) {
332
- obj.akn = exports.DeviceCommandAkn.toJSON(message.akn);
333
- }
334
- if (message.answer !== undefined) {
335
- obj.answer = exports.DeviceAnswer.toJSON(message.answer);
316
+ obj.akn = exports.CommandAkn.toJSON(message.akn);
336
317
  }
337
318
  return obj;
338
319
  },
339
320
  create(base) {
340
- return exports.DeviceMessage.fromPartial(base !== null && base !== void 0 ? base : {});
321
+ return exports.Command.fromPartial(base !== null && base !== void 0 ? base : {});
341
322
  },
342
323
  fromPartial(object) {
343
- var _a, _b;
344
- const message = createBaseDeviceMessage();
345
- message.deviceId = (_a = object.deviceId) !== null && _a !== void 0 ? _a : 0;
346
- message.transactionId = (_b = object.transactionId) !== null && _b !== void 0 ? _b : 0;
324
+ var _a, _b, _c, _d, _e, _f;
325
+ const message = createBaseCommand();
326
+ message.id = (_a = object.id) !== null && _a !== void 0 ? _a : 0;
327
+ message.deviceId = (_b = object.deviceId) !== null && _b !== void 0 ? _b : 0;
328
+ message.userId = (_c = object.userId) !== null && _c !== void 0 ? _c : 0;
329
+ message.commandId = (_d = object.commandId) !== null && _d !== void 0 ? _d : 0;
330
+ message.replyId = (_e = object.replyId) !== null && _e !== void 0 ? _e : 0;
331
+ message.status = (_f = object.status) !== null && _f !== void 0 ? _f : 0;
347
332
  message.command = (object.command !== undefined && object.command !== null)
348
- ? exports.DeviceCommand.fromPartial(object.command)
349
- : undefined;
350
- message.akn = (object.akn !== undefined && object.akn !== null)
351
- ? exports.DeviceCommandAkn.fromPartial(object.akn)
352
- : undefined;
353
- message.answer = (object.answer !== undefined && object.answer !== null)
354
- ? exports.DeviceAnswer.fromPartial(object.answer)
333
+ ? exports.CommandContent.fromPartial(object.command)
355
334
  : undefined;
335
+ message.akn = (object.akn !== undefined && object.akn !== null) ? exports.CommandAkn.fromPartial(object.akn) : undefined;
356
336
  return message;
357
337
  },
358
338
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fatehan/tsrp",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "description": "fatehan main models",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",