@simplysm/service-common 13.0.75 → 13.0.77

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/README.md CHANGED
@@ -104,10 +104,20 @@ const msg: ServiceErrorMessage = {
104
104
  code: "NOT_FOUND",
105
105
  stack: "...",
106
106
  detail: { id: 42 },
107
+ cause: undefined,
107
108
  },
108
109
  };
109
110
  ```
110
111
 
112
+ | Field | Required | Description |
113
+ |---|---|---|
114
+ | `name` | yes | Error class name |
115
+ | `message` | yes | Error message |
116
+ | `code` | yes | Error code string |
117
+ | `stack` | no | Stack trace |
118
+ | `detail` | no | Additional context |
119
+ | `cause` | no | Underlying cause |
120
+
111
121
  #### `ServiceAuthMessage`
112
122
 
113
123
  Client-sent authentication message carrying a token.
@@ -301,8 +311,8 @@ import type { OrmService } from "@simplysm/service-common";
301
311
 
302
312
  | Method | Description |
303
313
  |---|---|
304
- | `getInfo(opt)` | Returns dialect, database, and schema for a connection config |
305
- | `connect(opt)` | Opens a connection and returns a connection ID |
314
+ | `getInfo(opt)` | Returns dialect, database, and schema for a named connection config |
315
+ | `connect(opt)` | Opens a connection using an inline config object and returns a connection ID |
306
316
  | `close(connId)` | Closes the connection |
307
317
  | `beginTransaction(connId, isolationLevel?)` | Begins a transaction |
308
318
  | `commitTransaction(connId)` | Commits the current transaction |
@@ -311,6 +321,33 @@ import type { OrmService } from "@simplysm/service-common";
311
321
  | `executeDefs(connId, defs, options?)` | Executes a list of `QueryDef` objects |
312
322
  | `bulkInsert(connId, tableName, columnDefs, records)` | Performs a bulk insert |
313
323
 
324
+ **Signatures**
325
+
326
+ ```ts
327
+ getInfo(opt: DbConnOptions & { configName: string }): Promise<{
328
+ dialect: Dialect;
329
+ database?: string;
330
+ schema?: string;
331
+ }>;
332
+
333
+ connect(opt: Record<string, unknown>): Promise<number>;
334
+
335
+ executeParametrized(connId: number, query: string, params?: unknown[]): Promise<unknown[][]>;
336
+
337
+ executeDefs(
338
+ connId: number,
339
+ defs: QueryDef[],
340
+ options?: (ResultMeta | undefined)[],
341
+ ): Promise<unknown[][]>;
342
+
343
+ bulkInsert(
344
+ connId: number,
345
+ tableName: string,
346
+ columnDefs: Record<string, ColumnMeta>,
347
+ records: Record<string, unknown>[],
348
+ ): Promise<void>;
349
+ ```
350
+
314
351
  ---
315
352
 
316
353
  ### `DbConnOptions`
@@ -321,7 +358,7 @@ Options for selecting a database connection configuration.
321
358
  import type { DbConnOptions } from "@simplysm/service-common";
322
359
 
323
360
  type DbConnOptions = {
324
- configName?: string; // Named config key
361
+ configName?: string; // Named config key
325
362
  config?: Record<string, unknown>; // Inline config object
326
363
  };
327
364
  ```
@@ -414,14 +451,14 @@ interface SmtpClientSendOption {
414
451
 
415
452
  ---
416
453
 
417
- ### `SmtpClientDefaultConfig`
454
+ ### `SmtpClientDefaultOptions`
418
455
 
419
456
  Configuration for a default SMTP sender used server-side.
420
457
 
421
458
  ```ts
422
- import type { SmtpClientDefaultConfig } from "@simplysm/service-common";
459
+ import type { SmtpClientDefaultOptions } from "@simplysm/service-common";
423
460
 
424
- interface SmtpClientDefaultConfig {
461
+ interface SmtpClientDefaultOptions {
425
462
  senderName: string;
426
463
  senderEmail?: string;
427
464
  user?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"create-service-protocol.d.ts","sourceRoot":"","sources":["..\\..\\src\\protocol\\create-service-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,uBAAuB,CAAC;AAS/B,OAAO,EAAmB,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAExE;;;;;;;;GAQG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG;QAAE,MAAM,EAAE,KAAK,EAAE,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IAEtF;;OAE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AAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,QAAQ,CAAA;CAAE,GACrD;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjF;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,IAAI,eAAe,CA6KvD"}
@@ -1,11 +1,10 @@
1
1
  import "@simplysm/core-common";
2
2
  import {
3
3
  ArgumentError,
4
- jsonStringify,
5
- jsonParse,
4
+ bytes as bytesU,
5
+ json,
6
6
  LazyGcMap,
7
- Uuid,
8
- bytesConcat
7
+ Uuid
9
8
  } from "@simplysm/core-common";
10
9
  import { PROTOCOL_CONFIG } from "./protocol.types.js";
11
10
  function createServiceProtocol() {
@@ -24,11 +23,11 @@ function createServiceProtocol() {
24
23
  );
25
24
  headerView.setBigUint64(16, BigInt(header.totalSize), false);
26
25
  headerView.setUint32(24, header.index, false);
27
- return bytesConcat([headerBytes, ...bodyBytes ? [bodyBytes] : []]);
26
+ return bytesU.concat([headerBytes, ...bodyBytes ? [bodyBytes] : []]);
28
27
  }
29
28
  return {
30
29
  encode(uuid, message) {
31
- const msgJson = jsonStringify([message.name, ..."body" in message ? [message.body] : []]);
30
+ const msgJson = json.stringify([message.name, ..."body" in message ? [message.body] : []]);
32
31
  const msgBytes = new TextEncoder().encode(msgJson);
33
32
  const totalSize = msgBytes.length;
34
33
  if (totalSize > PROTOCOL_CONFIG.MAX_TOTAL_SIZE) {
@@ -89,10 +88,10 @@ function createServiceProtocol() {
89
88
  };
90
89
  } else {
91
90
  accumulator.delete(uuid);
92
- const resultBytes = bytesConcat(accItem.chunks.filterExists());
91
+ const resultBytes = bytesU.concat(accItem.chunks.filterExists());
93
92
  let messageArr;
94
93
  try {
95
- messageArr = jsonParse(new TextDecoder().decode(resultBytes));
94
+ messageArr = json.parse(new TextDecoder().decode(resultBytes));
96
95
  } catch (err) {
97
96
  throw new ArgumentError("Failed to decode message.", { uuid, cause: err });
98
97
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/protocol/create-service-protocol.ts"],
4
- "mappings": "AACA,OAAO;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,uBAA4C;AAkD9C,SAAS,wBAAyC;AAKvD,QAAM,cAAc,IAAI,UAOtB;AAAA,IACA,YAAY,gBAAgB;AAAA,IAC5B,YAAY,gBAAgB;AAAA,EAC9B,CAAC;AAkBD,WAAS,YACP,QAKA,WACO;AACP,UAAM,cAAc,IAAI,WAAW,EAAE;AAGrC,UAAM,YAAY,IAAI,KAAK,OAAO,IAAI,EAAE,QAAQ;AAChD,gBAAY,IAAI,WAAW,CAAC;AAG5B,UAAM,aAAa,IAAI;AAAA,MACrB,YAAY;AAAA,MACZ,YAAY;AAAA,MACZ,YAAY;AAAA,IACd;AACA,eAAW,aAAa,IAAI,OAAO,OAAO,SAAS,GAAG,KAAK;AAC3D,eAAW,UAAU,IAAI,OAAO,OAAO,KAAK;AAE5C,WAAO,YAAY,CAAC,aAAa,GAAI,YAAY,CAAC,SAAS,IAAI,CAAC,CAAE,CAAC;AAAA,EACrE;AAMA,SAAO;AAAA,IACL,OAAO,MAAc,SAAiE;AACpF,YAAM,UAAU,cAAc,CAAC,QAAQ,MAAM,GAAI,UAAU,UAAU,CAAC,QAAQ,IAAI,IAAI,CAAC,CAAE,CAAC;AAC1F,YAAM,WAAW,IAAI,YAAY,EAAE,OAAO,OAAO;AAEjD,YAAM,YAAY,SAAS;AAG3B,UAAI,YAAY,gBAAgB,gBAAgB;AAC9C,cAAM,IAAI,cAAc,mCAAmC;AAAA,UACzD;AAAA,UACA,SAAS,gBAAgB;AAAA,QAC3B,CAAC;AAAA,MACH;AAGA,UAAI,aAAa,gBAAgB,oBAAoB;AACnD,eAAO,EAAE,QAA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
28
28
  }
29
- export interface SmtpClientDefaultConfig {
29
+ export interface SmtpClientDefaultOptions {
30
30
  senderName: string;
31
31
  senderEmail?: string;
32
32
  user?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"smtp-client-service.types.d.ts","sourceRoot":"","sources":["..\\..\\src\\service-types\\smtp-client-service.types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAC9B,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,6BAA6B;IAC5C,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,wBAAwB,EAAE,CAAC;CAC1C;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,wBAAwB,EAAE,CAAC;CAC1C;AAED,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB"}
1
+ {"version":3,"file":"smtp-client-service.types.d.ts","sourceRoot":"","sources":["..\\..\\src\\service-types\\smtp-client-service.types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAC9B,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,6BAA6B;IAC5C,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,wBAAwB,EAAE,CAAC;CAC1C;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,wBAAwB,EAAE,CAAC;CAC1C;AAED,MAAM,WAAW,wBAAwB;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simplysm/service-common",
3
- "version": "13.0.75",
3
+ "version": "13.0.77",
4
4
  "description": "Simplysm package - Service module (common)",
5
5
  "author": "simplysm",
6
6
  "license": "Apache-2.0",
@@ -19,7 +19,7 @@
19
19
  ],
20
20
  "sideEffects": false,
21
21
  "dependencies": {
22
- "@simplysm/core-common": "13.0.75",
23
- "@simplysm/orm-common": "13.0.75"
22
+ "@simplysm/core-common": "13.0.77",
23
+ "@simplysm/orm-common": "13.0.77"
24
24
  }
25
25
  }
@@ -2,11 +2,10 @@ import type { Bytes } from "@simplysm/core-common";
2
2
  import "@simplysm/core-common";
3
3
  import {
4
4
  ArgumentError,
5
- jsonStringify,
6
- jsonParse,
5
+ bytes as bytesU,
6
+ json,
7
7
  LazyGcMap,
8
8
  Uuid,
9
- bytesConcat,
10
9
  } from "@simplysm/core-common";
11
10
  import { PROTOCOL_CONFIG, type ServiceMessage } from "./protocol.types";
12
11
 
@@ -114,7 +113,7 @@ export function createServiceProtocol(): ServiceProtocol {
114
113
  headerView.setBigUint64(16, BigInt(header.totalSize), false);
115
114
  headerView.setUint32(24, header.index, false);
116
115
 
117
- return bytesConcat([headerBytes, ...(bodyBytes ? [bodyBytes] : [])]);
116
+ return bytesU.concat([headerBytes, ...(bodyBytes ? [bodyBytes] : [])]);
118
117
  }
119
118
 
120
119
  // -------------------------------------------------------------------
@@ -123,7 +122,7 @@ export function createServiceProtocol(): ServiceProtocol {
123
122
 
124
123
  return {
125
124
  encode(uuid: string, message: ServiceMessage): { chunks: Bytes[]; totalSize: number } {
126
- const msgJson = jsonStringify([message.name, ...("body" in message ? [message.body] : [])]);
125
+ const msgJson = json.stringify([message.name, ...("body" in message ? [message.body] : [])]);
127
126
  const msgBytes = new TextEncoder().encode(msgJson);
128
127
 
129
128
  const totalSize = msgBytes.length;
@@ -209,10 +208,10 @@ export function createServiceProtocol(): ServiceProtocol {
209
208
  } else {
210
209
  accumulator.delete(uuid); // Free memory
211
210
 
212
- const resultBytes = bytesConcat(accItem.chunks.filterExists());
211
+ const resultBytes = bytesU.concat(accItem.chunks.filterExists());
213
212
  let messageArr: [string, unknown];
214
213
  try {
215
- messageArr = jsonParse<[string, unknown]>(new TextDecoder().decode(resultBytes));
214
+ messageArr = json.parse<[string, unknown]>(new TextDecoder().decode(resultBytes));
216
215
  } catch (err) {
217
216
  throw new ArgumentError("Failed to decode message.", { uuid, cause: err });
218
217
  }
@@ -30,7 +30,7 @@ export interface SmtpClientSendOption {
30
30
  attachments?: SmtpClientSendAttachment[];
31
31
  }
32
32
 
33
- export interface SmtpClientDefaultConfig {
33
+ export interface SmtpClientDefaultOptions {
34
34
  senderName: string;
35
35
  senderEmail?: string;
36
36
  user?: string;
@@ -8,14 +8,4 @@ describe("defineEvent", () => {
8
8
  expect(evt.eventName).toBe("OrderUpdated");
9
9
  });
10
10
 
11
- it("can be used for type inference (checked at compile time)", () => {
12
- const _evt = defineEvent<{ orderId: number }, { status: string }>("OrderUpdated");
13
-
14
- // Type level verification — fails at compile time if incorrect
15
- const info: typeof _evt.$info = { orderId: 123 };
16
- const data: typeof _evt.$data = { status: "shipped" };
17
-
18
- expect(info.orderId).toBe(123);
19
- expect(data.status).toBe("shipped");
20
- });
21
11
  });
@@ -16,7 +16,7 @@ describe("ServiceProtocol", () => {
16
16
 
17
17
  describe("Encoding", () => {
18
18
  it("encode single message", () => {
19
- const uuid = Uuid.new().toString();
19
+ const uuid = Uuid.generate().toString();
20
20
  const message: ServiceMessage = { name: "test.method", body: [{ test: "data" }] };
21
21
 
22
22
  const result = protocol.encode(uuid, message);
@@ -25,20 +25,8 @@ describe("ServiceProtocol", () => {
25
25
  expect(result.totalSize).toBeGreaterThan(0);
26
26
  });
27
27
 
28
- it("encode message without body", () => {
29
- const uuid = Uuid.new().toString();
30
- const message: ServiceMessage = {
31
- name: "reload",
32
- body: { clientName: undefined, changedFileSet: new Set() },
33
- };
34
-
35
- const result = protocol.encode(uuid, message);
36
-
37
- expect(result.chunks.length).toBe(1);
38
- });
39
-
40
28
  it("throw error when message exceeds 100MB", () => {
41
- const uuid = Uuid.new().toString();
29
+ const uuid = Uuid.generate().toString();
42
30
  // Generate data larger than 100MB
43
31
  const largeData = "x".repeat(101 * 1024 * 1024);
44
32
  const message: ServiceMessage = { name: "test.method", body: [largeData] };
@@ -49,7 +37,7 @@ describe("ServiceProtocol", () => {
49
37
 
50
38
  describe("Decoding", () => {
51
39
  it("decode single message", () => {
52
- const uuid = Uuid.new().toString();
40
+ const uuid = Uuid.generate().toString();
53
41
  const message: ServiceMessage = { name: "test.method", body: [{ value: 123 }] };
54
42
 
55
43
  const encoded = protocol.encode(uuid, message);
@@ -71,7 +59,7 @@ describe("ServiceProtocol", () => {
71
59
  it("throw error when decoded message exceeds 100MB", () => {
72
60
  // Manually create header with totalSize exceeding 100MB
73
61
  const headerBytes = new Uint8Array(28);
74
- const uuidBytes = new Uuid(Uuid.new().toString()).toBytes();
62
+ const uuidBytes = new Uuid(Uuid.generate().toString()).toBytes();
75
63
  headerBytes.set(uuidBytes, 0);
76
64
 
77
65
  const headerView = new DataView(
@@ -88,7 +76,7 @@ describe("ServiceProtocol", () => {
88
76
 
89
77
  describe("Chunking", () => {
90
78
  it("chunk message larger than 3MB", () => {
91
- const uuid = Uuid.new().toString();
79
+ const uuid = Uuid.generate().toString();
92
80
  // Create 4MB data
93
81
  const largeData = "x".repeat(4 * 1024 * 1024);
94
82
  const message: ServiceMessage = { name: "test.method", body: [largeData] };
@@ -99,7 +87,7 @@ describe("ServiceProtocol", () => {
99
87
  });
100
88
 
101
89
  it("assemble chunked message in order", () => {
102
- const uuid = Uuid.new().toString();
90
+ const uuid = Uuid.generate().toString();
103
91
  // 4MB data
104
92
  const largeData = "x".repeat(4 * 1024 * 1024);
105
93
  const message: ServiceMessage = { name: "test.method", body: [largeData] };
@@ -123,7 +111,7 @@ describe("ServiceProtocol", () => {
123
111
  });
124
112
 
125
113
  it("assemble chunked message in reverse order", () => {
126
- const uuid = Uuid.new().toString();
114
+ const uuid = Uuid.generate().toString();
127
115
  // 4MB data
128
116
  const largeData = "x".repeat(4 * 1024 * 1024);
129
117
  const message: ServiceMessage = { name: "test.method", body: [largeData] };
@@ -145,7 +133,7 @@ describe("ServiceProtocol", () => {
145
133
  });
146
134
 
147
135
  it("prevent duplicate packets", () => {
148
- const uuid = Uuid.new().toString();
136
+ const uuid = Uuid.generate().toString();
149
137
  // 4MB data
150
138
  const largeData = "x".repeat(4 * 1024 * 1024);
151
139
  const message: ServiceMessage = { name: "test.method", body: [largeData] };
@@ -174,8 +162,8 @@ describe("ServiceProtocol", () => {
174
162
 
175
163
  describe("UUID interleaving", () => {
176
164
  it("receive chunks from multiple UUIDs in interleaved order", () => {
177
- const uuid1 = Uuid.new().toString();
178
- const uuid2 = Uuid.new().toString();
165
+ const uuid1 = Uuid.generate().toString();
166
+ const uuid2 = Uuid.generate().toString();
179
167
 
180
168
  // Each with 4MB data to trigger chunking
181
169
  const largeData1 = "A".repeat(4 * 1024 * 1024);
@@ -215,65 +203,11 @@ describe("ServiceProtocol", () => {
215
203
  }
216
204
  });
217
205
 
218
- it("receive 3 UUIDs in random order", () => {
219
- const uuids = [Uuid.new().toString(), Uuid.new().toString(), Uuid.new().toString()];
220
- const data = [
221
- "X".repeat(4 * 1024 * 1024),
222
- "Y".repeat(4 * 1024 * 1024),
223
- "Z".repeat(4 * 1024 * 1024),
224
- ];
225
- const messages: ServiceMessage[] = data.map((d, i) => ({
226
- name: `test.method${i}`,
227
- body: [d],
228
- }));
229
-
230
- const encodedList = uuids.map((uuid, i) => protocol.encode(uuid, messages[i]));
231
-
232
- // Combine all chunks into one array
233
- const allChunks: { uuid: string; chunk: Uint8Array; originalIndex: number }[] = [];
234
- encodedList.forEach((encoded, msgIdx) => {
235
- encoded.chunks.forEach((chunk, chunkIdx) => {
236
- allChunks.push({ uuid: uuids[msgIdx], chunk, originalIndex: chunkIdx });
237
- });
238
- });
239
-
240
- // Randomize order (use reverse instead of seed-based shuffle)
241
- allChunks.reverse();
242
-
243
- // Decode all chunks
244
- const results: Map<string, ReturnType<typeof protocol.decode>> = new Map();
245
- for (const { uuid, chunk } of allChunks) {
246
- results.set(uuid, protocol.decode(chunk));
247
- }
248
-
249
- // Verify all messages completed
250
- for (let i = 0; i < 3; i++) {
251
- const result = results.get(uuids[i]);
252
- expect(result?.type).toBe("complete");
253
- if (result?.type === "complete") {
254
- expect(result.message.name).toBe(`test.method${i}`);
255
- expect(result.message.body).toEqual([data[i]]);
256
- }
257
- }
258
- });
259
206
  });
260
207
 
261
208
  describe("Edge cases", () => {
262
- it("handle empty body", () => {
263
- const uuid = Uuid.new().toString();
264
- const message: ServiceMessage = { name: "test.method", body: [""] };
265
-
266
- const encoded = protocol.encode(uuid, message);
267
- const decoded = protocol.decode(encoded.chunks[0]);
268
-
269
- expect(decoded.type).toBe("complete");
270
- if (decoded.type === "complete") {
271
- expect(decoded.message.body).toEqual([""]);
272
- }
273
- });
274
-
275
209
  it("handle null body", () => {
276
- const uuid = Uuid.new().toString();
210
+ const uuid = Uuid.generate().toString();
277
211
  const message: ServiceMessage = { name: "test.method", body: [null] };
278
212
 
279
213
  const encoded = protocol.encode(uuid, message);
@@ -286,27 +220,8 @@ describe("ServiceProtocol", () => {
286
220
  }
287
221
  });
288
222
 
289
- it("serialize complex object", () => {
290
- const uuid = Uuid.new().toString();
291
- const complexData = {
292
- array: [1, 2, 3],
293
- nested: { deep: { value: "test" } },
294
- date: new Date().toISOString(),
295
- unicode: "Korean test 🚀",
296
- };
297
- const message: ServiceMessage = { name: "test.method", body: [complexData] };
298
-
299
- const encoded = protocol.encode(uuid, message);
300
- const decoded = protocol.decode(encoded.chunks[0]);
301
-
302
- expect(decoded.type).toBe("complete");
303
- if (decoded.type === "complete") {
304
- expect(decoded.message.body).toEqual([complexData]);
305
- }
306
- });
307
-
308
223
  it("handle message at exactly 3MB boundary", () => {
309
- const uuid = Uuid.new().toString();
224
+ const uuid = Uuid.generate().toString();
310
225
  // Exactly 3MB
311
226
  const data = "x".repeat(3 * 1024 * 1024 - 50); // Account for some JSON overhead
312
227
  const message: ServiceMessage = { name: "test.method", body: [data] };
@@ -317,7 +232,7 @@ describe("ServiceProtocol", () => {
317
232
  });
318
233
 
319
234
  it("include correct information in progress response", () => {
320
- const uuid = Uuid.new().toString();
235
+ const uuid = Uuid.generate().toString();
321
236
  const largeData = "x".repeat(4 * 1024 * 1024);
322
237
  const message: ServiceMessage = { name: "test.method", body: [largeData] };
323
238