@dooboostore/simple-boot-http-server 1.0.25 → 1.0.27

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.
Files changed (66) hide show
  1. package/README.md +100 -14
  2. package/dist/cjs/SimpleBootHttpServer.js +34 -18
  3. package/dist/cjs/SimpleBootHttpServer.js.map +2 -2
  4. package/dist/cjs/bundle-entry.js +34 -24
  5. package/dist/cjs/bundle-entry.js.map +2 -2
  6. package/dist/cjs/codes/Mimes.js +2 -0
  7. package/dist/cjs/codes/Mimes.js.map +2 -2
  8. package/dist/cjs/decorators/MethodMapping.js +2 -2
  9. package/dist/cjs/decorators/MethodMapping.js.map +2 -2
  10. package/dist/cjs/filters/ResourceFilter.js +0 -1
  11. package/dist/cjs/filters/ResourceFilter.js.map +2 -2
  12. package/dist/cjs/option/HttpServerOption.js.map +2 -2
  13. package/dist/cjs/proxy/TopicProtocolApiServiceProxy.js +244 -266
  14. package/dist/cjs/proxy/TopicProtocolApiServiceProxy.js.map +3 -3
  15. package/dist/cjs/websocket/WebSocketClient.js +2 -1
  16. package/dist/cjs/websocket/WebSocketClient.js.map +2 -2
  17. package/dist/cjs/websocket/WebSocketManager.js +68 -40
  18. package/dist/cjs/websocket/WebSocketManager.js.map +2 -2
  19. package/dist/esm/SimpleBootHttpServer.js +34 -18
  20. package/dist/esm/SimpleBootHttpServer.js.map +2 -2
  21. package/dist/esm/bundle-entry.js +14 -12
  22. package/dist/esm/bundle-entry.js.map +2 -2
  23. package/dist/esm/codes/Mimes.js +2 -0
  24. package/dist/esm/codes/Mimes.js.map +2 -2
  25. package/dist/esm/decorators/MethodMapping.js +2 -2
  26. package/dist/esm/decorators/MethodMapping.js.map +2 -2
  27. package/dist/esm/filters/ResourceFilter.js +0 -1
  28. package/dist/esm/filters/ResourceFilter.js.map +2 -2
  29. package/dist/esm/option/HttpServerOption.js.map +2 -2
  30. package/dist/esm/proxy/TopicProtocolApiServiceProxy.js +244 -266
  31. package/dist/esm/proxy/TopicProtocolApiServiceProxy.js.map +3 -3
  32. package/dist/esm/websocket/WebSocketClient.js +3 -2
  33. package/dist/esm/websocket/WebSocketClient.js.map +2 -2
  34. package/dist/esm/websocket/WebSocketManager.js +68 -40
  35. package/dist/esm/websocket/WebSocketManager.js.map +2 -2
  36. package/dist/esm-bundle/dooboostore-simple-boot-http-server.esm.js +19134 -9180
  37. package/dist/esm-bundle/dooboostore-simple-boot-http-server.esm.js.map +4 -4
  38. package/dist/types/SimpleBootHttpServer.d.ts.map +1 -1
  39. package/dist/types/bundle-entry.d.ts +7 -12
  40. package/dist/types/bundle-entry.d.ts.map +1 -1
  41. package/dist/types/codes/Mimes.d.ts +2 -0
  42. package/dist/types/codes/Mimes.d.ts.map +1 -1
  43. package/dist/types/decorators/MethodMapping.d.ts +8 -0
  44. package/dist/types/decorators/MethodMapping.d.ts.map +1 -1
  45. package/dist/types/filters/ResourceFilter.d.ts.map +1 -1
  46. package/dist/types/option/HttpServerOption.d.ts +6 -2
  47. package/dist/types/option/HttpServerOption.d.ts.map +1 -1
  48. package/dist/types/proxy/TopicProtocolApiServiceProxy.d.ts +5 -15
  49. package/dist/types/proxy/TopicProtocolApiServiceProxy.d.ts.map +1 -1
  50. package/dist/types/websocket/WebSocketClient.d.ts.map +1 -1
  51. package/dist/types/websocket/WebSocketManager.d.ts +3 -1
  52. package/dist/types/websocket/WebSocketManager.d.ts.map +1 -1
  53. package/dist/umd-bundle/dooboostore-simple-boot-http-server.umd.js +19121 -9173
  54. package/dist/umd-bundle/dooboostore-simple-boot-http-server.umd.js.map +4 -4
  55. package/dist/umd-bundle/websocket-client.umd.js +412 -1482
  56. package/dist/umd-bundle/websocket-client.umd.js.map +4 -4
  57. package/package.json +8 -8
  58. package/src/SimpleBootHttpServer.ts +37 -18
  59. package/src/bundle-entry.ts +12 -12
  60. package/src/codes/Mimes.ts +2 -0
  61. package/src/decorators/MethodMapping.ts +14 -7
  62. package/src/filters/ResourceFilter.ts +0 -1
  63. package/src/option/HttpServerOption.ts +4 -2
  64. package/src/proxy/TopicProtocolApiServiceProxy.ts +260 -275
  65. package/src/websocket/WebSocketClient.ts +3 -2
  66. package/src/websocket/WebSocketManager.ts +69 -41
@@ -7,295 +7,273 @@ var __decorate = function(decorators, target, key, desc) {
7
7
  var __metadata = function(k, v) {
8
8
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
9
  };
10
- var TopicProtocolApiServiceProxy_1;
11
- var _a;
12
- import { getSim, Sim } from "@dooboostore/simple-boot";
10
+ import { getSim, sim } from "@dooboostore/simple-boot";
13
11
  import { HttpHeaders } from "../codes/HttpHeaders.js";
14
12
  import { ApiService } from "@dooboostore/simple-boot";
15
13
  import { RandomUtils } from "@dooboostore/core";
16
- let TopicProtocolApiServiceProxy = TopicProtocolApiServiceProxy_1 = class TopicProtocolApiServiceProxy2 {
17
- constructor(apiService) {
18
- this.apiService = apiService;
19
- }
20
- static isFileValue(value) {
21
- if (typeof File !== "undefined" && value instanceof File) {
22
- return true;
23
- }
24
- if (typeof Blob !== "undefined" && value instanceof Blob) {
25
- return true;
26
- }
27
- if (typeof ArrayBuffer !== "undefined" && value instanceof ArrayBuffer) {
28
- return true;
29
- }
30
- if (typeof Uint8Array !== "undefined" && value instanceof Uint8Array) {
31
- return true;
32
- }
33
- return false;
34
- }
35
- static toFileEntry(value, id) {
36
- if (typeof Blob === "undefined") {
37
- return void 0;
38
- }
39
- if (typeof File !== "undefined" && value instanceof File) {
40
- const blob2 = new Blob([value], { type: value.type });
41
- return { id, file: blob2, filename: value.name };
42
- }
43
- if (value instanceof Blob) {
44
- return { id, file: value };
45
- }
46
- const view = value instanceof Uint8Array ? value : new Uint8Array(value);
47
- const safe = value instanceof Uint8Array ? new Uint8Array(value) : new Uint8Array(view);
48
- const blob = new Blob([safe]);
49
- return { id, file: blob };
50
- }
51
- static buildRequest(target, body, type = "intent") {
52
- const fileEntries = [];
53
- let fileIndex = 0;
54
- const registerFile = (value) => {
55
- const id = `f${++fileIndex}`;
56
- const entry = TopicProtocolApiServiceProxy_1.toFileEntry(value, id);
57
- if (entry) {
58
- fileEntries.push(entry);
59
- return id;
60
- }
61
- return void 0;
62
- };
63
- const replaceFiles = (value) => {
64
- if (TopicProtocolApiServiceProxy_1.isFileValue(value)) {
65
- const id = registerFile(value);
66
- if (id) {
67
- return { $file: id };
68
- }
69
- return value;
70
- }
71
- if (Array.isArray(value)) {
72
- return value.map((item) => replaceFiles(item));
73
- }
74
- if (value && typeof value === "object") {
75
- const result = {};
76
- Object.keys(value).forEach((key) => {
77
- result[key] = replaceFiles(value[key]);
78
- });
79
- return result;
80
- }
81
- return value;
82
- };
83
- const payload = replaceFiles(body);
84
- const request = {
85
- type,
86
- target,
87
- requestUUID: RandomUtils.uuid4(),
88
- body: payload,
89
- files: fileEntries.length > 0 ? fileEntries.map((entry) => ({ id: entry.id })) : void 0
90
- };
91
- return { request, fileEntries };
92
- }
93
- static async parseMultipartMixed(response) {
94
- const contentType = response.headers.get("Content-Type") ?? "";
95
- const boundaryMatch = contentType.match(/boundary=([^;]+)/i);
96
- if (!boundaryMatch) {
97
- return void 0;
98
- }
99
- const boundary = boundaryMatch[1].replace(/^"|"$/g, "");
100
- const buffer = new Uint8Array(await response.arrayBuffer());
101
- const boundaryBytes = new TextEncoder().encode(`--${boundary}`);
102
- const endBoundaryBytes = new TextEncoder().encode(`--${boundary}--`);
103
- const separator = new TextEncoder().encode("\r\n\r\n");
104
- const indexOf = (source, needle, from = 0) => {
105
- for (let i = from; i <= source.length - needle.length; i++) {
106
- let matched = true;
107
- for (let j = 0; j < needle.length; j++) {
108
- if (source[i + j] !== needle[j]) {
109
- matched = false;
110
- break;
111
- }
112
- }
113
- if (matched) {
114
- return i;
115
- }
116
- }
117
- return -1;
118
- };
119
- const parts = [];
120
- let cursor = indexOf(buffer, boundaryBytes, 0);
121
- while (cursor !== -1) {
122
- const nextBoundary = indexOf(buffer, boundaryBytes, cursor + boundaryBytes.length);
123
- const endBoundary = indexOf(buffer, endBoundaryBytes, cursor + boundaryBytes.length);
124
- const isFinal = endBoundary !== -1 && (endBoundary < nextBoundary || nextBoundary === -1);
125
- const partStart = cursor + boundaryBytes.length;
126
- if (isFinal) {
127
- break;
128
- }
129
- let headerStart = partStart;
130
- if (buffer[headerStart] === 13 && buffer[headerStart + 1] === 10) {
131
- headerStart += 2;
132
- }
133
- const headerEnd = indexOf(buffer, separator, headerStart);
134
- if (headerEnd === -1) {
135
- break;
136
- }
137
- const headerText = new TextDecoder().decode(buffer.slice(headerStart, headerEnd));
138
- const headers = {};
139
- headerText.split("\r\n").forEach((line) => {
140
- const idx = line.indexOf(":");
141
- if (idx > -1) {
142
- const key = line.slice(0, idx).trim().toLowerCase();
143
- headers[key] = line.slice(idx + 1).trim();
144
- }
145
- });
146
- const bodyStart = headerEnd + separator.length;
147
- const bodyEnd = nextBoundary === -1 ? buffer.length : nextBoundary - 2;
148
- const body = buffer.slice(bodyStart, bodyEnd);
149
- parts.push({ headers, body });
150
- cursor = nextBoundary;
151
- }
152
- return { boundary, parts };
153
- }
154
- static parseDispositionFilename(disposition) {
155
- if (!disposition) {
156
- return void 0;
157
- }
158
- const match = disposition.match(/filename=\"?([^\";]+)\"?/i);
159
- return match ? match[1] : void 0;
160
- }
161
- static parseDispositionName(disposition) {
162
- if (!disposition) {
163
- return void 0;
164
- }
165
- const match = disposition.match(/name=\"?([^\";]+)\"?/i);
166
- return match ? match[1] : void 0;
14
+ const isFileValue = (value) => {
15
+ if (typeof File !== "undefined" && value instanceof File)
16
+ return true;
17
+ if (typeof Blob !== "undefined" && value instanceof Blob)
18
+ return true;
19
+ if (typeof ArrayBuffer !== "undefined" && value instanceof ArrayBuffer)
20
+ return true;
21
+ if (typeof Uint8Array !== "undefined" && value instanceof Uint8Array)
22
+ return true;
23
+ return false;
24
+ };
25
+ const toFileEntry = (value, id) => {
26
+ if (typeof Blob === "undefined")
27
+ return void 0;
28
+ if (typeof File !== "undefined" && value instanceof File) {
29
+ return { id, file: new Blob([value], { type: value.type }), filename: value.name };
167
30
  }
168
- static replaceFileRefs(value, fileMap) {
169
- if (value && typeof value === "object" && "$file" in value) {
170
- const fileKey = value.$file;
171
- if (typeof fileKey === "string") {
172
- const file = fileMap.get(fileKey);
173
- if (file) {
174
- return file;
175
- }
176
- }
31
+ if (value instanceof Blob)
32
+ return { id, file: value };
33
+ const safe = value instanceof Uint8Array ? new Uint8Array(value) : new Uint8Array(value);
34
+ return { id, file: new Blob([safe]) };
35
+ };
36
+ const buildRequest = (target, body, type = "intent") => {
37
+ const fileEntries = [];
38
+ let fileIndex = 0;
39
+ const registerFile = (value) => {
40
+ const id = `f${++fileIndex}`;
41
+ const entry = toFileEntry(value, id);
42
+ if (entry) {
43
+ fileEntries.push(entry);
44
+ return id;
177
45
  }
178
- if (Array.isArray(value)) {
179
- return value.map((item) => TopicProtocolApiServiceProxy_1.replaceFileRefs(item, fileMap));
46
+ return void 0;
47
+ };
48
+ const replaceFiles = (value) => {
49
+ if (isFileValue(value)) {
50
+ const id = registerFile(value);
51
+ return id ? { $file: id } : value;
180
52
  }
53
+ if (Array.isArray(value))
54
+ return value.map((item) => replaceFiles(item));
181
55
  if (value && typeof value === "object") {
182
56
  const result = {};
183
57
  Object.keys(value).forEach((key) => {
184
- result[key] = TopicProtocolApiServiceProxy_1.replaceFileRefs(value[key], fileMap);
58
+ result[key] = replaceFiles(value[key]);
185
59
  });
186
60
  return result;
187
61
  }
188
62
  return value;
189
- }
190
- static normalizeResponse(value) {
191
- if (value && typeof value === "object" && "state" in value && "body" in value) {
192
- const typed = value;
193
- if (typed.state === "error") {
194
- const message = typeof typed.body === "object" && typed.body && "message" in typed.body ? String(typed.body.message) : "TopicProtocol error";
195
- throw new Error(message);
63
+ };
64
+ const payload = replaceFiles(body);
65
+ const request = {
66
+ type,
67
+ target,
68
+ requestUUID: RandomUtils.uuid4(),
69
+ body: payload,
70
+ files: fileEntries.length > 0 ? fileEntries.map((e) => ({ id: e.id })) : void 0
71
+ };
72
+ return { request, fileEntries };
73
+ };
74
+ const parseDispositionName = (disposition) => {
75
+ const match = disposition?.match(/name=\"?([^\";]+)\"?/i);
76
+ return match ? match[1] : void 0;
77
+ };
78
+ const parseDispositionFilename = (disposition) => {
79
+ const match = disposition?.match(/filename=\"?([^\";]+)\"?/i);
80
+ return match ? match[1] : void 0;
81
+ };
82
+ const parseMultipartMixed = async (response) => {
83
+ const contentType = response.headers.get("Content-Type") ?? "";
84
+ const boundaryMatch = contentType.match(/boundary=([^;]+)/i);
85
+ if (!boundaryMatch)
86
+ return void 0;
87
+ const boundary = boundaryMatch[1].replace(/^"|"$/g, "");
88
+ const buffer = new Uint8Array(await response.arrayBuffer());
89
+ const boundaryBytes = new TextEncoder().encode(`--${boundary}`);
90
+ const endBoundaryBytes = new TextEncoder().encode(`--${boundary}--`);
91
+ const separator = new TextEncoder().encode("\r\n\r\n");
92
+ const indexOf = (source, needle, from = 0) => {
93
+ for (let i = from; i <= source.length - needle.length; i++) {
94
+ let matched = true;
95
+ for (let j = 0; j < needle.length; j++) {
96
+ if (source[i + j] !== needle[j]) {
97
+ matched = false;
98
+ break;
99
+ }
196
100
  }
197
- return typed.body;
101
+ if (matched)
102
+ return i;
198
103
  }
199
- return value;
104
+ return -1;
105
+ };
106
+ const parts = [];
107
+ let cursor = indexOf(buffer, boundaryBytes, 0);
108
+ while (cursor !== -1) {
109
+ const nextBoundary = indexOf(buffer, boundaryBytes, cursor + boundaryBytes.length);
110
+ const endBoundary = indexOf(buffer, endBoundaryBytes, cursor + boundaryBytes.length);
111
+ const isFinal = endBoundary !== -1 && (endBoundary < nextBoundary || nextBoundary === -1);
112
+ const partStart = cursor + boundaryBytes.length;
113
+ if (isFinal)
114
+ break;
115
+ let headerStart = partStart;
116
+ if (buffer[headerStart] === 13 && buffer[headerStart + 1] === 10)
117
+ headerStart += 2;
118
+ const headerEnd = indexOf(buffer, separator, headerStart);
119
+ if (headerEnd === -1)
120
+ break;
121
+ const headerText = new TextDecoder().decode(buffer.slice(headerStart, headerEnd));
122
+ const headers = {};
123
+ headerText.split("\r\n").forEach((line) => {
124
+ const idx = line.indexOf(":");
125
+ if (idx > -1)
126
+ headers[line.slice(0, idx).trim().toLowerCase()] = line.slice(idx + 1).trim();
127
+ });
128
+ const bodyStart = headerEnd + separator.length;
129
+ const bodyEnd = nextBoundary === -1 ? buffer.length : nextBoundary - 2;
130
+ parts.push({ headers, body: buffer.slice(bodyStart, bodyEnd) });
131
+ cursor = nextBoundary;
200
132
  }
201
- static createHandler(apiService) {
202
- return {
203
- get(target, prop, receiver) {
204
- const simConfig = getSim(target);
205
- const value = Reflect.get(target, prop, receiver);
206
- if (typeof value === "function" && simConfig?.symbol) {
207
- return function(...args) {
208
- const f = value;
209
- const p = (userConfig) => {
210
- const symbolValue = Array.isArray(simConfig.symbol) ? simConfig.symbol[0] : simConfig.symbol;
211
- const symbolName = symbolValue?.description ?? String(symbolValue ?? simConfig.symbol);
212
- const targetPath = `Symbol.for(${symbolName}):/${String(prop)}`;
213
- const { request, fileEntries } = TopicProtocolApiServiceProxy_1.buildRequest(targetPath, userConfig?.body, userConfig?.type ?? "intent");
214
- const formData = new FormData();
215
- formData.append("body", JSON.stringify(request));
216
- fileEntries.forEach((entry) => {
217
- if (entry.filename) {
218
- formData.append(entry.id, entry.file, entry.filename);
219
- } else {
220
- formData.append(entry.id, entry.file);
221
- }
222
- });
223
- const headers = {
224
- ...userConfig?.headers ?? {},
225
- [HttpHeaders.XSimpleBootHttpTopicProtocol]: "topic"
226
- };
227
- const endpoint = userConfig?.endpoint ?? "/";
228
- return apiService.post({
229
- target: endpoint,
230
- config: {
231
- responseTransform: userConfig?.bypassTransform ? "response" : userConfig?.transformText ? "text" : async (response) => {
232
- const contentType = response.headers.get("Content-Type") ?? "";
233
- if (contentType.toLowerCase().includes("multipart/mixed")) {
234
- const parsed2 = await TopicProtocolApiServiceProxy_1.parseMultipartMixed(response);
235
- if (!parsed2) {
236
- return void 0;
133
+ return { boundary, parts };
134
+ };
135
+ const replaceFileRefs = (value, fileMap) => {
136
+ if (value && typeof value === "object" && "$file" in value) {
137
+ const fileKey = value.$file;
138
+ if (typeof fileKey === "string") {
139
+ const file = fileMap.get(fileKey);
140
+ if (file)
141
+ return file;
142
+ }
143
+ }
144
+ if (Array.isArray(value))
145
+ return value.map((item) => replaceFileRefs(item, fileMap));
146
+ if (value && typeof value === "object") {
147
+ const result = {};
148
+ Object.keys(value).forEach((key) => {
149
+ result[key] = replaceFileRefs(value[key], fileMap);
150
+ });
151
+ return result;
152
+ }
153
+ return value;
154
+ };
155
+ const normalizeResponse = (value) => {
156
+ if (value && typeof value === "object" && "state" in value && "body" in value) {
157
+ const typed = value;
158
+ if (typed.state === "error") {
159
+ const message = typeof typed.body === "object" && typed.body && "message" in typed.body ? String(typed.body.message) : "TopicProtocol error";
160
+ throw new Error(message);
161
+ }
162
+ return typed.body;
163
+ }
164
+ return value;
165
+ };
166
+ const createTopicHandler = (apiService) => {
167
+ return {
168
+ get(target, prop, receiver) {
169
+ if (prop === "_SimpleBoot_origin")
170
+ return target;
171
+ const simConfig = getSim(target);
172
+ const value = Reflect.get(target, prop, receiver);
173
+ if (typeof value === "function" && simConfig?.symbol) {
174
+ return function(...args) {
175
+ const f = value;
176
+ const p = (userConfig) => {
177
+ const symbolValue = Array.isArray(simConfig.symbol) ? simConfig.symbol[0] : simConfig.symbol;
178
+ const symbolName = symbolValue?.description ?? String(symbolValue ?? simConfig.symbol);
179
+ const targetPath = `Symbol.for(${symbolName}):/${String(prop)}`;
180
+ const { request, fileEntries } = buildRequest(targetPath, userConfig?.body, userConfig?.type ?? "intent");
181
+ const formData = new FormData();
182
+ formData.append("body", JSON.stringify(request));
183
+ fileEntries.forEach((entry) => {
184
+ if (entry.filename)
185
+ formData.append(entry.id, entry.file, entry.filename);
186
+ else
187
+ formData.append(entry.id, entry.file);
188
+ });
189
+ const headers = {
190
+ ...userConfig?.headers ?? {},
191
+ [HttpHeaders.XSimpleBootHttpTopicProtocol]: "topic"
192
+ };
193
+ const endpoint = userConfig?.endpoint ?? "/";
194
+ return apiService.post({
195
+ target: endpoint,
196
+ config: {
197
+ responseTransform: userConfig?.bypassTransform ? "response" : userConfig?.transformText ? "text" : async (response) => {
198
+ const ct = response.headers.get("Content-Type") ?? "";
199
+ if (ct.toLowerCase().includes("multipart/mixed")) {
200
+ const parsed2 = await parseMultipartMixed(response);
201
+ if (!parsed2)
202
+ return void 0;
203
+ const fileMap = /* @__PURE__ */ new Map();
204
+ let jsonBody = void 0;
205
+ parsed2.parts.forEach((part) => {
206
+ const partType = part.headers["content-type"] ?? "";
207
+ const disposition = part.headers["content-disposition"];
208
+ const name = parseDispositionName(disposition);
209
+ if (partType.includes("application/json")) {
210
+ const text2 = new TextDecoder().decode(part.body);
211
+ jsonBody = text2 ? JSON.parse(text2) : void 0;
212
+ return;
237
213
  }
238
- const fileMap = /* @__PURE__ */ new Map();
239
- let jsonBody = void 0;
240
- parsed2.parts.forEach((part) => {
241
- const partType = part.headers["content-type"] ?? "";
242
- const disposition = part.headers["content-disposition"];
243
- const name = TopicProtocolApiServiceProxy_1.parseDispositionName(disposition);
244
- if (partType.includes("application/json")) {
245
- const text2 = new TextDecoder().decode(part.body);
246
- jsonBody = text2 ? JSON.parse(text2) : void 0;
247
- return;
248
- }
249
- const filename = TopicProtocolApiServiceProxy_1.parseDispositionFilename(disposition);
250
- if (name) {
251
- const view = part.body;
252
- const safe = new Uint8Array(view.byteLength);
253
- safe.set(view);
254
- fileMap.set(name, {
255
- name: filename,
256
- mime: partType || "application/octet-stream",
257
- size: view.byteLength,
258
- buffer: safe.buffer
259
- });
260
- }
261
- });
262
- if (jsonBody) {
263
- const replaced = TopicProtocolApiServiceProxy_1.replaceFileRefs(jsonBody, fileMap);
264
- return TopicProtocolApiServiceProxy_1.normalizeResponse(replaced);
214
+ if (name) {
215
+ const filename = parseDispositionFilename(disposition);
216
+ const safe = new Uint8Array(part.body.byteLength);
217
+ safe.set(part.body);
218
+ fileMap.set(name, {
219
+ name: filename,
220
+ mime: partType || "application/octet-stream",
221
+ size: part.body.byteLength,
222
+ buffer: safe.buffer
223
+ });
265
224
  }
266
- return void 0;
267
- }
268
- const text = await response.text();
269
- const parsed = text ? JSON.parse(text) : void 0;
270
- return TopicProtocolApiServiceProxy_1.normalizeResponse(parsed);
271
- },
272
- transformText: userConfig?.transformText,
273
- config: userConfig?.config,
274
- fetch: {
275
- credentials: "include",
276
- headers,
277
- body: formData
225
+ });
226
+ if (jsonBody)
227
+ return normalizeResponse(replaceFileRefs(jsonBody, fileMap));
228
+ return void 0;
278
229
  }
230
+ const text = await response.text();
231
+ const parsed = text ? JSON.parse(text) : void 0;
232
+ return normalizeResponse(parsed);
233
+ },
234
+ transformText: userConfig?.transformText,
235
+ config: userConfig?.config,
236
+ fetch: {
237
+ credentials: "include",
238
+ headers,
239
+ body: formData
279
240
  }
280
- });
281
- };
282
- args.push(p);
283
- return Reflect.apply(f, target, args);
241
+ }
242
+ });
284
243
  };
285
- }
286
- return value;
244
+ args.push(p);
245
+ return Reflect.apply(f, target, args);
246
+ };
287
247
  }
288
- };
289
- }
290
- get(target, prop, receiver) {
291
- return TopicProtocolApiServiceProxy_1.createHandler(this.apiService).get(target, prop, receiver);
292
- }
248
+ return Reflect.get(target, prop, receiver);
249
+ },
250
+ apply(target, thisArg, argArray) {
251
+ console.log("TopicProtocolApiServiceProxy apply");
252
+ return Reflect.apply(target, thisArg, argArray);
253
+ }
254
+ };
255
+ };
256
+ var TopicProtocolApiServiceProxy_default = (config) => {
257
+ var _a;
258
+ let TopicProtocolApiServiceProxy = class TopicProtocolApiServiceProxy {
259
+ constructor(apiService) {
260
+ this.apiService = apiService;
261
+ }
262
+ get(target, prop, receiver) {
263
+ return createTopicHandler(this.apiService).get(target, prop, receiver);
264
+ }
265
+ apply(target, thisArg, argArray) {
266
+ return createTopicHandler(this.apiService).apply(target, thisArg, argArray);
267
+ }
268
+ };
269
+ TopicProtocolApiServiceProxy = __decorate([
270
+ sim(config),
271
+ __metadata("design:paramtypes", [typeof (_a = typeof ApiService !== "undefined" && ApiService) === "function" ? _a : Object])
272
+ ], TopicProtocolApiServiceProxy);
273
+ return TopicProtocolApiServiceProxy;
293
274
  };
294
- TopicProtocolApiServiceProxy = TopicProtocolApiServiceProxy_1 = __decorate([
295
- Sim,
296
- __metadata("design:paramtypes", [typeof (_a = typeof ApiService !== "undefined" && ApiService) === "function" ? _a : Object])
297
- ], TopicProtocolApiServiceProxy);
298
275
  export {
299
- TopicProtocolApiServiceProxy
276
+ createTopicHandler,
277
+ TopicProtocolApiServiceProxy_default as default
300
278
  };
301
279
  //# sourceMappingURL=TopicProtocolApiServiceProxy.js.map