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