@zintrust/core 0.4.62 → 0.4.64
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/package.json +1 -1
- package/src/cli/commands/DebuggerCommands.js +1 -1
- package/src/cli/commands/MigrateCommand.js +1 -1
- package/src/cli/workers/QueueWorkRunner.d.ts.map +1 -1
- package/src/cli/workers/QueueWorkRunner.js +9 -1
- package/src/config/logger.d.ts.map +1 -1
- package/src/config/logger.js +327 -10
- package/src/debugger/SystemDebuggerBridge.js +1 -1
- package/src/functions/cloudflare.d.ts +1 -1
- package/src/functions/cloudflare.js +1 -1
- package/src/http/HttpStatus.d.ts +12 -0
- package/src/http/HttpStatus.d.ts.map +1 -0
- package/src/http/HttpStatus.js +80 -0
- package/src/http/Kernel.d.ts.map +1 -1
- package/src/http/Kernel.js +0 -1
- package/src/index.d.ts +2 -1
- package/src/index.d.ts.map +1 -1
- package/src/index.js +4 -4
- package/src/middleware/LoggingMiddleware.d.ts.map +1 -1
- package/src/middleware/LoggingMiddleware.js +12 -6
- package/src/runtime/PluginAutoImports.d.ts.map +1 -1
- package/src/runtime/PluginAutoImports.js +28 -5
- package/src/runtime/WorkersModule.d.ts +2 -2
- package/src/runtime/plugins/system-debugger-runtime.js +1 -1
- package/src/templates/project/basic/app/Toolkit/Broadcast/sendBroadcast.ts.tpl +5 -1
- package/src/templates/project/basic/routes/api.ts.tpl +0 -2
- package/src/templates/project/basic/routes/broadcast.ts.tpl +3 -3
- package/src/tools/broadcast/Broadcast.d.ts +41 -2
- package/src/tools/broadcast/Broadcast.d.ts.map +1 -1
- package/src/tools/broadcast/Broadcast.js +373 -16
- package/src/tools/broadcast/index.d.ts +1 -0
- package/src/tools/broadcast/index.d.ts.map +1 -1
- package/src/zintrust.comon.d.ts +11 -0
- package/src/zintrust.comon.d.ts.map +1 -0
- package/src/zintrust.comon.js +17 -0
- package/src/zintrust.plugins.d.ts +7 -3
- package/src/zintrust.plugins.d.ts.map +1 -1
- package/src/zintrust.plugins.js +9 -3
- package/src/zintrust.plugins.wg.d.ts +1 -0
- package/src/zintrust.plugins.wg.d.ts.map +1 -1
- package/src/zintrust.plugins.wg.js +3 -0
|
@@ -1,9 +1,228 @@
|
|
|
1
|
+
import { isArray, isNonEmptyString, isObject } from '../../helper/index.js';
|
|
1
2
|
import { InMemoryDriver } from './drivers/InMemory.js';
|
|
2
3
|
import { PusherDriver } from './drivers/Pusher.js';
|
|
3
4
|
import { RedisDriver } from './drivers/Redis.js';
|
|
4
5
|
import { RedisHttpsDriver } from './drivers/RedisHttps.js';
|
|
5
6
|
import broadcastConfig from '../../config/broadcast.js';
|
|
7
|
+
import { Env } from '../../config/env.js';
|
|
8
|
+
import { Logger } from '../../config/logger.js';
|
|
6
9
|
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
10
|
+
const INTERNAL_SOCKET_SECRET_HEADER = 'x-zintrust-socket-secret';
|
|
11
|
+
const pickFirstNonEmpty = (...values) => {
|
|
12
|
+
for (const value of values) {
|
|
13
|
+
if (value.trim() !== '') {
|
|
14
|
+
return value.trim();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return '';
|
|
18
|
+
};
|
|
19
|
+
const normalizeChannelScope = (value) => {
|
|
20
|
+
if (!isNonEmptyString(value)) {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
const normalized = value.trim().toLowerCase();
|
|
24
|
+
if (normalized === 'public' ||
|
|
25
|
+
normalized === 'private' ||
|
|
26
|
+
normalized === 'presence' ||
|
|
27
|
+
normalized === 'persistent') {
|
|
28
|
+
return normalized;
|
|
29
|
+
}
|
|
30
|
+
return undefined;
|
|
31
|
+
};
|
|
32
|
+
const getQualifiedChannelScope = (channel) => {
|
|
33
|
+
if (channel.startsWith('private-'))
|
|
34
|
+
return 'private';
|
|
35
|
+
if (channel.startsWith('presence-'))
|
|
36
|
+
return 'presence';
|
|
37
|
+
if (channel.startsWith('persistent-'))
|
|
38
|
+
return 'persistent';
|
|
39
|
+
return undefined;
|
|
40
|
+
};
|
|
41
|
+
const applyChannelScope = (channel, scope) => {
|
|
42
|
+
const normalizedChannel = channel.trim();
|
|
43
|
+
const existingScope = getQualifiedChannelScope(normalizedChannel);
|
|
44
|
+
if (existingScope !== undefined) {
|
|
45
|
+
if (scope !== undefined && scope !== existingScope) {
|
|
46
|
+
throw ErrorFactory.createValidationError(`Broadcast channel scope ${scope} conflicts with fully-qualified channel ${normalizedChannel}.`);
|
|
47
|
+
}
|
|
48
|
+
return normalizedChannel;
|
|
49
|
+
}
|
|
50
|
+
if (scope === undefined || scope === 'public') {
|
|
51
|
+
return normalizedChannel;
|
|
52
|
+
}
|
|
53
|
+
return `${scope}-${normalizedChannel}`;
|
|
54
|
+
};
|
|
55
|
+
const normalizeChannels = (input) => {
|
|
56
|
+
const scope = normalizeChannelScope(input.channelScope ?? input.scope);
|
|
57
|
+
if (isArray(input.channels)) {
|
|
58
|
+
return input.channels
|
|
59
|
+
.filter(isNonEmptyString)
|
|
60
|
+
.map((channel) => applyChannelScope(channel, scope));
|
|
61
|
+
}
|
|
62
|
+
if (isNonEmptyString(input.channel)) {
|
|
63
|
+
return [applyChannelScope(input.channel, scope)];
|
|
64
|
+
}
|
|
65
|
+
return [];
|
|
66
|
+
};
|
|
67
|
+
const appendUnique = (values, nextValue) => {
|
|
68
|
+
if (nextValue !== '' && !values.includes(nextValue)) {
|
|
69
|
+
values.push(nextValue);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
const toAbsoluteBaseUrl = (value) => {
|
|
73
|
+
const trimmed = value.trim();
|
|
74
|
+
if (trimmed === '' || trimmed.startsWith('/')) {
|
|
75
|
+
return '';
|
|
76
|
+
}
|
|
77
|
+
try {
|
|
78
|
+
return new URL(trimmed).toString();
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
try {
|
|
82
|
+
return new URL(`http://${trimmed}`).toString();
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
return '';
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
const getLoopbackAlternativeBaseUrl = (value) => {
|
|
90
|
+
try {
|
|
91
|
+
const parsed = new URL(value);
|
|
92
|
+
if (parsed.hostname === '127.0.0.1') {
|
|
93
|
+
parsed.hostname = 'localhost';
|
|
94
|
+
return parsed.toString();
|
|
95
|
+
}
|
|
96
|
+
if (parsed.hostname === 'localhost' ||
|
|
97
|
+
parsed.hostname === '[::1]' ||
|
|
98
|
+
parsed.hostname === '::1') {
|
|
99
|
+
parsed.hostname = '127.0.0.1';
|
|
100
|
+
return parsed.toString();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
return '';
|
|
105
|
+
}
|
|
106
|
+
return '';
|
|
107
|
+
};
|
|
108
|
+
const getInternalPublishConfig = () => {
|
|
109
|
+
const baseUrls = [];
|
|
110
|
+
appendUnique(baseUrls, toAbsoluteBaseUrl(Env.get('BROADCAST_INTERNAL_URL', '')));
|
|
111
|
+
appendUnique(baseUrls, toAbsoluteBaseUrl(Env.get('APP_URL', '')));
|
|
112
|
+
appendUnique(baseUrls, toAbsoluteBaseUrl(Env.get('BASE_URL', Env.BASE_URL ?? '')));
|
|
113
|
+
const resolvedBaseUrls = [];
|
|
114
|
+
for (const baseUrl of baseUrls) {
|
|
115
|
+
appendUnique(resolvedBaseUrls, baseUrl);
|
|
116
|
+
appendUnique(resolvedBaseUrls, getLoopbackAlternativeBaseUrl(baseUrl));
|
|
117
|
+
}
|
|
118
|
+
const appId = pickFirstNonEmpty(Env.get('PUSHER_APP_ID', ''), Env.get('BROADCAST_APP_ID', '')) || 'internal';
|
|
119
|
+
const secret = pickFirstNonEmpty(Env.get('BROADCAST_SECRET', ''), Env.get('PUSHER_APP_SECRET', ''), Env.get('BROADCAST_APP_SECRET', ''));
|
|
120
|
+
return Object.freeze({
|
|
121
|
+
endpoints: resolvedBaseUrls.map((baseUrl) => new URL(`/apps/${encodeURIComponent(appId)}/events`, baseUrl).toString()),
|
|
122
|
+
appId,
|
|
123
|
+
secret,
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
const parseJsonResponseSafe = async (response) => {
|
|
127
|
+
const raw = await response.text();
|
|
128
|
+
if (raw.trim() === '') {
|
|
129
|
+
return {};
|
|
130
|
+
}
|
|
131
|
+
try {
|
|
132
|
+
return JSON.parse(raw);
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
return { raw };
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
const getDeliveries = (payload) => {
|
|
139
|
+
if (!isObject(payload)) {
|
|
140
|
+
return undefined;
|
|
141
|
+
}
|
|
142
|
+
const deliveries = payload['deliveries'];
|
|
143
|
+
return typeof deliveries === 'number' && Number.isFinite(deliveries) ? deliveries : undefined;
|
|
144
|
+
};
|
|
145
|
+
const describeError = (error) => {
|
|
146
|
+
if (error instanceof Error) {
|
|
147
|
+
return {
|
|
148
|
+
name: error.name,
|
|
149
|
+
message: error.message,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
return String(error);
|
|
153
|
+
};
|
|
154
|
+
const logTransportFallback = (transport, details) => {
|
|
155
|
+
Logger.warn('Broadcast publish transport failed; falling back.', {
|
|
156
|
+
transport,
|
|
157
|
+
...details,
|
|
158
|
+
});
|
|
159
|
+
};
|
|
160
|
+
const requestInternalPublishEndpoint = async (endpoint, secret, payload) => {
|
|
161
|
+
try {
|
|
162
|
+
const response = await globalThis.fetch(endpoint, {
|
|
163
|
+
method: 'POST',
|
|
164
|
+
headers: {
|
|
165
|
+
'content-type': 'application/json',
|
|
166
|
+
...(secret === ''
|
|
167
|
+
? {}
|
|
168
|
+
: {
|
|
169
|
+
[INTERNAL_SOCKET_SECRET_HEADER]: secret,
|
|
170
|
+
authorization: `Bearer ${secret}`,
|
|
171
|
+
}),
|
|
172
|
+
},
|
|
173
|
+
body: JSON.stringify(payload),
|
|
174
|
+
});
|
|
175
|
+
const responseBody = await parseJsonResponseSafe(response);
|
|
176
|
+
if (!response.ok) {
|
|
177
|
+
const error = ErrorFactory.createTryCatchError(`Internal socket publish request failed (${response.status})`, {
|
|
178
|
+
status: response.status,
|
|
179
|
+
endpoint,
|
|
180
|
+
body: responseBody,
|
|
181
|
+
});
|
|
182
|
+
logTransportFallback('internal-http', {
|
|
183
|
+
endpoint,
|
|
184
|
+
status: response.status,
|
|
185
|
+
body: responseBody,
|
|
186
|
+
});
|
|
187
|
+
return { result: null, error };
|
|
188
|
+
}
|
|
189
|
+
const resolvedChannels = isObject(responseBody) && isArray(responseBody['channels'])
|
|
190
|
+
? responseBody['channels'].filter(isNonEmptyString).map((channel) => channel.trim())
|
|
191
|
+
: payload.channels;
|
|
192
|
+
const resolvedEvent = isObject(responseBody) && isNonEmptyString(responseBody['event'])
|
|
193
|
+
? responseBody['event'].trim()
|
|
194
|
+
: payload.event;
|
|
195
|
+
return {
|
|
196
|
+
result: {
|
|
197
|
+
ok: true,
|
|
198
|
+
transport: 'internal-http',
|
|
199
|
+
channels: resolvedChannels,
|
|
200
|
+
event: resolvedEvent,
|
|
201
|
+
deliveries: getDeliveries(responseBody),
|
|
202
|
+
endpoint,
|
|
203
|
+
result: responseBody,
|
|
204
|
+
},
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
catch (error) {
|
|
208
|
+
logTransportFallback('internal-http', {
|
|
209
|
+
endpoint,
|
|
210
|
+
error: describeError(error),
|
|
211
|
+
});
|
|
212
|
+
return { result: null, error };
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
const tryInternalPublishEndpoints = async (endpoints, secret, payload, index = 0, lastError) => {
|
|
216
|
+
const endpoint = endpoints[index];
|
|
217
|
+
if (endpoint === undefined) {
|
|
218
|
+
return { result: null, error: lastError };
|
|
219
|
+
}
|
|
220
|
+
const attempt = await requestInternalPublishEndpoint(endpoint, secret, payload);
|
|
221
|
+
if (attempt.result !== null) {
|
|
222
|
+
return attempt;
|
|
223
|
+
}
|
|
224
|
+
return tryInternalPublishEndpoints(endpoints, secret, payload, index + 1, attempt.error ?? lastError);
|
|
225
|
+
};
|
|
7
226
|
const resolveBroadcasterConfig = async (name) => {
|
|
8
227
|
const selection = (name ?? broadcastConfig.getDriverName()).toString().trim().toLowerCase();
|
|
9
228
|
try {
|
|
@@ -44,39 +263,177 @@ const sendWithConfig = async (config, channel, event, data) => {
|
|
|
44
263
|
}
|
|
45
264
|
throw ErrorFactory.createConfigError(`Broadcast driver not implemented: ${driverName}`);
|
|
46
265
|
};
|
|
266
|
+
const normalizeDelivery = (value) => {
|
|
267
|
+
if (value === 'socket' || value === 'driver') {
|
|
268
|
+
return value;
|
|
269
|
+
}
|
|
270
|
+
return 'auto';
|
|
271
|
+
};
|
|
272
|
+
const normalizePublishInput = (input) => {
|
|
273
|
+
let event = '';
|
|
274
|
+
if (isNonEmptyString(input.event)) {
|
|
275
|
+
event = input.event.trim();
|
|
276
|
+
}
|
|
277
|
+
else if (isNonEmptyString(input.name)) {
|
|
278
|
+
event = input.name.trim();
|
|
279
|
+
}
|
|
280
|
+
const channels = normalizeChannels(input);
|
|
281
|
+
if (event === '' || channels.length === 0) {
|
|
282
|
+
throw ErrorFactory.createValidationError('Broadcast.publish requires event/name and channel/channels.');
|
|
283
|
+
}
|
|
284
|
+
return {
|
|
285
|
+
channels,
|
|
286
|
+
event,
|
|
287
|
+
data: input.data ?? {},
|
|
288
|
+
...(isNonEmptyString(input.socketId) ? { socketId: input.socketId.trim() } : {}),
|
|
289
|
+
delivery: normalizeDelivery(input.delivery),
|
|
290
|
+
...(isNonEmptyString(input.broadcaster) ? { broadcaster: input.broadcaster.trim() } : {}),
|
|
291
|
+
...(input.request === undefined ? {} : { request: input.request }),
|
|
292
|
+
...(input.user === undefined ? {} : { user: input.user }),
|
|
293
|
+
};
|
|
294
|
+
};
|
|
295
|
+
const tryPublishViaSocket = async (input) => {
|
|
296
|
+
try {
|
|
297
|
+
const socketModule = (await import('@zintrust/socket'));
|
|
298
|
+
const socketResult = await socketModule.publishSocketEventFromServer({
|
|
299
|
+
channels: input.channels,
|
|
300
|
+
event: input.event,
|
|
301
|
+
data: input.data,
|
|
302
|
+
socketId: input.socketId,
|
|
303
|
+
request: input.request,
|
|
304
|
+
user: input.user,
|
|
305
|
+
});
|
|
306
|
+
return {
|
|
307
|
+
result: {
|
|
308
|
+
ok: true,
|
|
309
|
+
transport: 'socket',
|
|
310
|
+
channels: socketResult.channels,
|
|
311
|
+
event: socketResult.event,
|
|
312
|
+
deliveries: socketResult.deliveries,
|
|
313
|
+
result: socketResult,
|
|
314
|
+
},
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
catch (error) {
|
|
318
|
+
return { result: null, error };
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
const tryPublishViaInternalHttp = async (input) => {
|
|
322
|
+
const config = getInternalPublishConfig();
|
|
323
|
+
if (config.endpoints.length === 0 || typeof globalThis.fetch !== 'function') {
|
|
324
|
+
return { result: null };
|
|
325
|
+
}
|
|
326
|
+
const payload = {
|
|
327
|
+
channels: input.channels,
|
|
328
|
+
event: input.event,
|
|
329
|
+
data: input.data,
|
|
330
|
+
...(input.socketId === undefined ? {} : { socket_id: input.socketId }),
|
|
331
|
+
};
|
|
332
|
+
return tryInternalPublishEndpoints(config.endpoints, config.secret, payload);
|
|
333
|
+
};
|
|
334
|
+
const publishWithConfig = async (config, broadcasterName, input) => {
|
|
335
|
+
const results = await Promise.all(input.channels.map(async (channel) => sendWithConfig(config, channel, input.event, input.data)));
|
|
336
|
+
return {
|
|
337
|
+
ok: true,
|
|
338
|
+
transport: 'driver',
|
|
339
|
+
channels: input.channels,
|
|
340
|
+
event: input.event,
|
|
341
|
+
driver: config.driver,
|
|
342
|
+
...(broadcasterName === undefined ? {} : { broadcaster: broadcasterName }),
|
|
343
|
+
...(results.length === 1 ? { result: results[0] } : { results }),
|
|
344
|
+
};
|
|
345
|
+
};
|
|
346
|
+
const publishInternal = async (input) => {
|
|
347
|
+
const normalized = normalizePublishInput(input);
|
|
348
|
+
const attemptedTransports = [];
|
|
349
|
+
let lastTransportError;
|
|
350
|
+
if (normalized.delivery !== 'driver') {
|
|
351
|
+
attemptedTransports.push('internal-http');
|
|
352
|
+
const internalHttpResult = await tryPublishViaInternalHttp(normalized);
|
|
353
|
+
if (internalHttpResult.result !== null) {
|
|
354
|
+
return { ...internalHttpResult.result, attemptedTransports };
|
|
355
|
+
}
|
|
356
|
+
if (internalHttpResult.error !== undefined) {
|
|
357
|
+
lastTransportError = internalHttpResult.error;
|
|
358
|
+
}
|
|
359
|
+
attemptedTransports.push('socket');
|
|
360
|
+
const socketResult = await tryPublishViaSocket(normalized);
|
|
361
|
+
if (socketResult.result !== null) {
|
|
362
|
+
return { ...socketResult.result, attemptedTransports };
|
|
363
|
+
}
|
|
364
|
+
if (socketResult.error !== undefined) {
|
|
365
|
+
lastTransportError = socketResult.error;
|
|
366
|
+
logTransportFallback('socket', {
|
|
367
|
+
error: describeError(socketResult.error),
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
if (normalized.delivery === 'socket') {
|
|
372
|
+
if (lastTransportError instanceof Error) {
|
|
373
|
+
throw lastTransportError;
|
|
374
|
+
}
|
|
375
|
+
throw ErrorFactory.createConfigError('Socket publish delivery is not available.');
|
|
376
|
+
}
|
|
377
|
+
attemptedTransports.push('driver');
|
|
378
|
+
const config = await resolveBroadcasterConfig(normalized.broadcaster);
|
|
379
|
+
return {
|
|
380
|
+
...(await publishWithConfig(config, normalized.broadcaster, normalized)),
|
|
381
|
+
attemptedTransports,
|
|
382
|
+
};
|
|
383
|
+
};
|
|
384
|
+
const publishLaterInternal = async (input, options = {}) => {
|
|
385
|
+
const normalized = normalizePublishInput(input);
|
|
386
|
+
const { queueName = 'broadcasts', timestamp = Date.now() } = options;
|
|
387
|
+
const { Queue } = await import('../queue/Queue.js');
|
|
388
|
+
return Queue.enqueue(queueName, {
|
|
389
|
+
type: 'broadcast',
|
|
390
|
+
channel: normalized.channels[0],
|
|
391
|
+
channels: normalized.channels,
|
|
392
|
+
event: normalized.event,
|
|
393
|
+
data: normalized.data,
|
|
394
|
+
...(normalized.socketId === undefined ? {} : { socketId: normalized.socketId }),
|
|
395
|
+
...(normalized.broadcaster === undefined ? {} : { broadcaster: normalized.broadcaster }),
|
|
396
|
+
delivery: normalized.delivery,
|
|
397
|
+
timestamp,
|
|
398
|
+
attempts: 0,
|
|
399
|
+
});
|
|
400
|
+
};
|
|
47
401
|
export const Broadcast = Object.freeze({
|
|
402
|
+
async publish(input) {
|
|
403
|
+
return publishInternal(input);
|
|
404
|
+
},
|
|
48
405
|
async send(channel, event, data) {
|
|
49
|
-
const
|
|
50
|
-
|
|
406
|
+
const result = await publishInternal({ channel, event, data });
|
|
407
|
+
if (result.transport === 'driver') {
|
|
408
|
+
return result.result ?? result.results ?? result;
|
|
409
|
+
}
|
|
410
|
+
return result.result ?? result;
|
|
51
411
|
},
|
|
52
412
|
// Alias for send() - explicit intent for immediate broadcast
|
|
53
413
|
async broadcastNow(channel, event, data) {
|
|
54
414
|
return this.send(channel, event, data);
|
|
55
415
|
},
|
|
416
|
+
async publishLater(input, options = {}) {
|
|
417
|
+
return publishLaterInternal(input, options);
|
|
418
|
+
},
|
|
56
419
|
// Queue broadcast for async processing
|
|
57
420
|
async BroadcastLater(channel, event, data, options = {}) {
|
|
58
|
-
|
|
59
|
-
const { Queue } = await import('../queue/Queue.js');
|
|
60
|
-
const messageId = await Queue.enqueue(queueName, {
|
|
61
|
-
type: 'broadcast',
|
|
62
|
-
channel,
|
|
63
|
-
event,
|
|
64
|
-
data,
|
|
65
|
-
timestamp,
|
|
66
|
-
attempts: 0,
|
|
67
|
-
});
|
|
68
|
-
return messageId;
|
|
421
|
+
return publishLaterInternal({ channel, event, data }, options);
|
|
69
422
|
},
|
|
70
423
|
queue(queueName) {
|
|
71
424
|
return Object.freeze({
|
|
72
|
-
|
|
425
|
+
publishLater: async (input, options = {}) => publishLaterInternal(input, { ...options, queueName }),
|
|
426
|
+
BroadcastLater: async (channel, event, data, options = {}) => publishLaterInternal({ channel, event, data }, { ...options, queueName }),
|
|
73
427
|
});
|
|
74
428
|
},
|
|
75
429
|
broadcaster(name) {
|
|
76
430
|
return Object.freeze({
|
|
77
431
|
send: async (channel, event, data) => {
|
|
78
|
-
const
|
|
79
|
-
return
|
|
432
|
+
const result = await publishWithConfig(await resolveBroadcasterConfig(name), name, normalizePublishInput({ channel, event, data, delivery: 'driver', broadcaster: name }));
|
|
433
|
+
return result.result ?? result.results ?? result;
|
|
434
|
+
},
|
|
435
|
+
publish: async (input) => {
|
|
436
|
+
return publishWithConfig(await resolveBroadcasterConfig(name), name, normalizePublishInput({ ...input, delivery: 'driver', broadcaster: name }));
|
|
80
437
|
},
|
|
81
438
|
});
|
|
82
439
|
},
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { Broadcast } from './Broadcast';
|
|
2
|
+
export type { BroadcastPublishInput, BroadcastPublishResult } from './Broadcast';
|
|
2
3
|
export { BroadcastRegistry } from './BroadcastRegistry';
|
|
3
4
|
export { registerBroadcastersFromRuntimeConfig } from './BroadcastRuntimeRegistration';
|
|
4
5
|
export { BaseDriver } from './drivers/BaseDriver';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/tools/broadcast/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,qCAAqC,EAAE,MAAM,yCAAyC,CAAC;AAChG,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/tools/broadcast/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,YAAY,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC1F,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,qCAAqC,EAAE,MAAM,yCAAyC,CAAC;AAChG,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import '../packages/db-d1/src/register.js';
|
|
2
|
+
import '../packages/db-mysql/src/register.js';
|
|
3
|
+
import '../packages/db-postgres/src/register.js';
|
|
4
|
+
import '../packages/db-sqlite/src/register.js';
|
|
5
|
+
import '../packages/db-sqlserver/src/register.js';
|
|
6
|
+
import '../packages/mail-sendgrid/src/register.js';
|
|
7
|
+
import '../packages/mail-smtp/src/register.js';
|
|
8
|
+
import '@zintrust/queue-monitor';
|
|
9
|
+
import '../packages/queue-redis/src/register.js';
|
|
10
|
+
import '../packages/workers/src/register.js';
|
|
11
|
+
//# sourceMappingURL=zintrust.comon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zintrust.comon.d.ts","sourceRoot":"","sources":["../../src/zintrust.comon.ts"],"names":[],"mappings":"AAQA,OAAO,mCAAmC,CAAC;AAC3C,OAAO,sCAAsC,CAAC;AAC9C,OAAO,yCAAyC,CAAC;AACjD,OAAO,uCAAuC,CAAC;AAC/C,OAAO,0CAA0C,CAAC;AAClD,OAAO,2CAA2C,CAAC;AACnD,OAAO,uCAAuC,CAAC;AAC/C,OAAO,wCAAwC,CAAC;AAChD,OAAO,yCAAyC,CAAC;AACjD,OAAO,qCAAqC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/* eslint-disable no-restricted-imports */
|
|
2
|
+
// /**
|
|
3
|
+
// * ZinTrust comon plugin auto-imports
|
|
4
|
+
// *
|
|
5
|
+
// * This file is managed by `zin plugin install` and contains side-effect
|
|
6
|
+
// * imports that register optional adapters/drivers into core registries.
|
|
7
|
+
// */
|
|
8
|
+
import '../packages/db-d1/src/register.js';
|
|
9
|
+
import '../packages/db-mysql/src/register.js';
|
|
10
|
+
import '../packages/db-postgres/src/register.js';
|
|
11
|
+
import '../packages/db-sqlite/src/register.js';
|
|
12
|
+
import '../packages/db-sqlserver/src/register.js';
|
|
13
|
+
import '../packages/mail-sendgrid/src/register.js';
|
|
14
|
+
import '../packages/mail-smtp/src/register.js';
|
|
15
|
+
import '@zintrust/queue-monitor';
|
|
16
|
+
import '../packages/queue-redis/src/register.js';
|
|
17
|
+
import '../packages/workers/src/register.js';
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* ZinTrust plugin auto-imports
|
|
3
|
+
*
|
|
4
|
+
* In real projects, this file is managed by `zin plugin install` and contains
|
|
5
|
+
* side-effect imports (e.g. `@zintrust/db-sqlite/register`) that register
|
|
6
|
+
* optional adapters/drivers into core registries.
|
|
7
|
+
*
|
|
5
8
|
*/
|
|
9
|
+
export type {};
|
|
6
10
|
export declare const __zintrustGeneratedPluginStub = "zintrust.plugins.ts";
|
|
7
11
|
declare const _default: {};
|
|
8
12
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zintrust.plugins.d.ts","sourceRoot":"","sources":["../../src/zintrust.plugins.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"zintrust.plugins.d.ts","sourceRoot":"","sources":["../../src/zintrust.plugins.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,YAAY,EAAE,CAAC;AAgBf,eAAO,MAAM,6BAA6B,wBAAwB,CAAC;;AACnE,wBAAkB"}
|
package/src/zintrust.plugins.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* ZinTrust plugin auto-imports
|
|
3
|
+
*
|
|
4
|
+
* In real projects, this file is managed by `zin plugin install` and contains
|
|
5
|
+
* side-effect imports (e.g. `@zintrust/db-sqlite/register`) that register
|
|
6
|
+
* optional adapters/drivers into core registries.
|
|
7
|
+
*
|
|
5
8
|
*/
|
|
9
|
+
import * as SystemDebuggerRuntime from './runtime/plugins/system-debugger-runtime.js';
|
|
10
|
+
globalThis.__zintrust_system_debugger_plugin_requested__ = true;
|
|
11
|
+
globalThis.__zintrust_system_debugger_runtime__ = SystemDebuggerRuntime;
|
|
6
12
|
export const __zintrustGeneratedPluginStub = 'zintrust.plugins.ts';
|
|
7
13
|
export default {};
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* This file is created by scripts/ensure-worker-plugins.mjs when missing.
|
|
4
4
|
* It allows optional runtime plugin imports to resolve in CI/scaffolded setups.
|
|
5
5
|
*/
|
|
6
|
+
export type {};
|
|
6
7
|
export declare const __zintrustGeneratedPluginStub = "zintrust.plugins.wg.ts";
|
|
7
8
|
declare const _default: {};
|
|
8
9
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zintrust.plugins.wg.d.ts","sourceRoot":"","sources":["../../src/zintrust.plugins.wg.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"zintrust.plugins.wg.d.ts","sourceRoot":"","sources":["../../src/zintrust.plugins.wg.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,YAAY,EAAE,CAAC;AAgBf,eAAO,MAAM,6BAA6B,2BAA2B,CAAC;;AACtE,wBAAkB"}
|
|
@@ -3,5 +3,8 @@
|
|
|
3
3
|
* This file is created by scripts/ensure-worker-plugins.mjs when missing.
|
|
4
4
|
* It allows optional runtime plugin imports to resolve in CI/scaffolded setups.
|
|
5
5
|
*/
|
|
6
|
+
import * as SystemDebuggerRuntime from './runtime/plugins/system-debugger-runtime.js';
|
|
7
|
+
globalThis.__zintrust_system_debugger_plugin_requested__ = true;
|
|
8
|
+
globalThis.__zintrust_system_debugger_runtime__ = SystemDebuggerRuntime;
|
|
6
9
|
export const __zintrustGeneratedPluginStub = 'zintrust.plugins.wg.ts';
|
|
7
10
|
export default {};
|