kuzzle 2.17.7 → 2.18.1
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/bin/start-kuzzle-server +1 -1
- package/lib/api/controllers/adminController.js +1 -1
- package/lib/api/controllers/authController.js +9 -3
- package/lib/api/controllers/baseController.js +1 -1
- package/lib/api/controllers/bulkController.js +1 -1
- package/lib/api/controllers/clusterController.js +1 -1
- package/lib/api/controllers/collectionController.js +1 -1
- package/lib/api/controllers/documentController.js +13 -4
- package/lib/api/controllers/index.js +1 -1
- package/lib/api/controllers/indexController.js +11 -7
- package/lib/api/controllers/memoryStorageController.js +1 -1
- package/lib/api/controllers/realtimeController.js +1 -1
- package/lib/api/controllers/securityController.js +80 -42
- package/lib/api/controllers/serverController.js +3 -2
- package/lib/api/documentExtractor.js +3 -2
- package/lib/api/funnel.js +1 -1
- package/lib/api/httpRoutes.js +7 -5
- package/lib/api/openapi/OpenApiManager.js +5 -1
- package/lib/api/openapi/components/document/get.yaml +1 -1
- package/lib/api/openapi/components/document/index.d.ts +2 -0
- package/lib/api/openapi/components/document/index.js +6 -1
- package/lib/api/openapi/components/document/mCreateOrReplace.yaml +93 -0
- package/lib/api/openapi/components/document/update.yaml +1 -1
- package/lib/api/openapi/components/index.d.ts +1 -0
- package/lib/api/openapi/components/index.js +1 -0
- package/lib/api/openapi/components/security/index.d.ts +2 -0
- package/lib/api/openapi/components/security/index.js +10 -0
- package/lib/api/openapi/components/security/upsertUser.yaml +59 -0
- package/lib/api/openapi/openApiGenerator.js +1 -1
- package/lib/api/rateLimiter.js +1 -1
- package/lib/api/request/kuzzleRequest.d.ts +46 -0
- package/lib/api/request/kuzzleRequest.js +147 -19
- package/lib/api/request/requestContext.js +1 -1
- package/lib/api/request/requestInput.js +1 -1
- package/lib/api/request/requestResponse.js +26 -1
- package/lib/cluster/command.js +1 -1
- package/lib/cluster/idCardHandler.js +1 -1
- package/lib/cluster/index.js +1 -1
- package/lib/cluster/node.js +8 -8
- package/lib/cluster/publisher.js +1 -1
- package/lib/cluster/state.js +1 -1
- package/lib/cluster/subscriber.js +4 -1
- package/lib/config/documentEventAliases.js +1 -1
- package/lib/config/index.js +1 -1
- package/lib/core/auth/formatProcessing.js +1 -1
- package/lib/core/auth/passportResponse.js +1 -1
- package/lib/core/auth/passportWrapper.js +1 -1
- package/lib/core/auth/tokenManager.js +1 -1
- package/lib/core/backend/applicationManager.js +1 -1
- package/lib/core/backend/backend.js +1 -1
- package/lib/core/backend/backendCluster.js +1 -1
- package/lib/core/backend/backendConfig.js +1 -1
- package/lib/core/backend/backendController.d.ts +7 -1
- package/lib/core/backend/backendController.js +16 -4
- package/lib/core/backend/backendErrors.js +1 -1
- package/lib/core/backend/backendHook.js +1 -1
- package/lib/core/backend/backendImport.js +1 -1
- package/lib/core/backend/backendOpenApi.js +1 -1
- package/lib/core/backend/backendPipe.js +1 -1
- package/lib/core/backend/backendPlugin.js +1 -1
- package/lib/core/backend/backendStorage.js +1 -1
- package/lib/core/backend/backendVault.js +1 -1
- package/lib/core/backend/internalLogger.js +1 -1
- package/lib/core/cache/cacheDbEnum.js +1 -1
- package/lib/core/cache/cacheEngine.js +1 -1
- package/lib/core/network/accessLogger.js +1 -1
- package/lib/core/network/clientConnection.js +1 -1
- package/lib/core/network/context.js +1 -1
- package/lib/core/network/entryPoint.js +6 -6
- package/lib/core/network/httpRouter/index.js +1 -1
- package/lib/core/network/httpRouter/routeHandler.js +1 -1
- package/lib/core/network/httpRouter/routePart.js +1 -1
- package/lib/core/network/protocolManifest.js +1 -1
- package/lib/core/network/protocols/httpMessage.js +1 -1
- package/lib/core/network/protocols/httpwsProtocol.js +13 -16
- package/lib/core/network/protocols/internalProtocol.js +1 -1
- package/lib/core/network/protocols/mqttProtocol.js +4 -3
- package/lib/core/network/protocols/protocol.js +1 -1
- package/lib/core/network/router.js +11 -2
- package/lib/core/plugin/plugin.js +8 -1
- package/lib/core/plugin/pluginContext.js +1 -1
- package/lib/core/plugin/pluginManifest.js +1 -1
- package/lib/core/plugin/pluginRepository.js +1 -1
- package/lib/core/plugin/pluginsManager.js +1 -1
- package/lib/core/plugin/privilegedContext.js +1 -1
- package/lib/core/realtime/actionEnum.js +1 -1
- package/lib/core/realtime/channel.js +1 -1
- package/lib/core/realtime/connectionRooms.js +1 -1
- package/lib/core/realtime/hotelClerk.js +66 -24
- package/lib/core/realtime/index.js +1 -1
- package/lib/core/realtime/notification/document.js +1 -1
- package/lib/core/realtime/notification/index.js +1 -1
- package/lib/core/realtime/notification/server.js +1 -1
- package/lib/core/realtime/notification/user.js +1 -1
- package/lib/core/realtime/notifier.js +1 -1
- package/lib/core/realtime/room.js +1 -1
- package/lib/core/realtime/subscription.js +1 -1
- package/lib/core/security/index.js +1 -1
- package/lib/core/security/profileRepository.js +1 -1
- package/lib/core/security/roleRepository.js +1 -1
- package/lib/core/security/securityLoader.js +1 -1
- package/lib/core/security/tokenRepository.js +1 -1
- package/lib/core/security/userRepository.js +1 -1
- package/lib/core/shared/KoncordeWrapper.js +1 -1
- package/lib/core/shared/abstractManifest.js +1 -1
- package/lib/core/shared/repository.js +1 -1
- package/lib/core/shared/sdk/embeddedSdk.d.ts +2 -2
- package/lib/core/shared/sdk/embeddedSdk.js +4 -3
- package/lib/core/shared/sdk/funnelProtocol.d.ts +13 -0
- package/lib/core/shared/sdk/funnelProtocol.js +76 -81
- package/lib/core/shared/sdk/impersonatedSdk.js +1 -1
- package/lib/core/shared/store.js +1 -1
- package/lib/core/statistics/index.js +1 -1
- package/lib/core/statistics/statistics.js +1 -1
- package/lib/core/storage/clientAdapter.js +1 -1
- package/lib/core/storage/indexCache.js +1 -1
- package/lib/core/storage/storageEngine.js +1 -1
- package/lib/core/storage/storeScopeEnum.js +1 -1
- package/lib/core/validation/baseType.js +1 -1
- package/lib/core/validation/index.js +1 -1
- package/lib/core/validation/types/anything.js +1 -1
- package/lib/core/validation/types/boolean.js +1 -1
- package/lib/core/validation/types/date.js +1 -1
- package/lib/core/validation/types/email.js +1 -1
- package/lib/core/validation/types/enum.js +1 -1
- package/lib/core/validation/types/geoPoint.js +1 -1
- package/lib/core/validation/types/geoShape.js +1 -1
- package/lib/core/validation/types/integer.js +1 -1
- package/lib/core/validation/types/ipAddress.js +1 -1
- package/lib/core/validation/types/numeric.js +1 -1
- package/lib/core/validation/types/object.js +1 -1
- package/lib/core/validation/types/string.js +1 -1
- package/lib/core/validation/types/url.js +1 -1
- package/lib/core/validation/validation.js +1 -1
- package/lib/kerror/codes/1-services.json +1 -1
- package/lib/kerror/codes/index.js +1 -1
- package/lib/kerror/errors/badRequestError.js +1 -1
- package/lib/kerror/errors/externalServiceError.js +1 -1
- package/lib/kerror/errors/forbiddenError.js +1 -1
- package/lib/kerror/errors/gatewayTimeoutError.js +1 -1
- package/lib/kerror/errors/index.js +1 -1
- package/lib/kerror/errors/internalError.js +1 -1
- package/lib/kerror/errors/kuzzleError.d.ts +1 -1
- package/lib/kerror/errors/kuzzleError.js +1 -1
- package/lib/kerror/errors/multipleErrorsError.js +1 -1
- package/lib/kerror/errors/notFoundError.js +1 -1
- package/lib/kerror/errors/partialError.js +1 -1
- package/lib/kerror/errors/pluginImplementationError.js +1 -1
- package/lib/kerror/errors/preconditionError.js +1 -1
- package/lib/kerror/errors/serviceUnavailableError.js +1 -1
- package/lib/kerror/errors/sizeLimitError.js +1 -1
- package/lib/kerror/errors/tooManyRequestsError.js +1 -1
- package/lib/kerror/errors/unauthorizedError.js +1 -1
- package/lib/kerror/index.js +2 -4
- package/lib/kuzzle/dumpGenerator.js +1 -1
- package/lib/kuzzle/event/kuzzleEventEmitter.js +39 -1
- package/lib/kuzzle/event/pipeRunner.js +1 -1
- package/lib/kuzzle/event/waterfall.js +1 -1
- package/lib/kuzzle/index.js +1 -1
- package/lib/kuzzle/internalIndexHandler.js +1 -1
- package/lib/kuzzle/kuzzle.js +1 -1
- package/lib/kuzzle/kuzzleStateEnum.js +1 -1
- package/lib/kuzzle/log.js +1 -1
- package/lib/kuzzle/vault.js +1 -1
- package/lib/model/security/profile.js +1 -1
- package/lib/model/security/rights.js +1 -1
- package/lib/model/security/role.js +1 -1
- package/lib/model/security/token.js +1 -1
- package/lib/model/security/user.js +6 -7
- package/lib/model/storage/apiKey.js +1 -1
- package/lib/model/storage/baseModel.js +1 -1
- package/lib/service/cache/redis.js +1 -1
- package/lib/service/service.js +1 -1
- package/lib/service/storage/elasticsearch.js +108 -39
- package/lib/service/storage/esWrapper.js +1 -1
- package/lib/service/storage/queryTranslator.js +1 -1
- package/lib/types/Controller.js +1 -1
- package/lib/types/ControllerDefinition.js +1 -1
- package/lib/types/Deprecation.js +1 -1
- package/lib/types/EventHandler.js +1 -1
- package/lib/types/KuzzleDocument.d.ts +3 -0
- package/lib/types/Plugin.js +1 -1
- package/lib/types/PluginManifest.js +1 -1
- package/lib/types/RequestPayload.js +1 -1
- package/lib/types/ResponsePayload.js +1 -1
- package/lib/types/StrategyDefinition.js +1 -1
- package/lib/types/Token.js +1 -1
- package/lib/types/User.js +1 -1
- package/lib/types/index.d.ts +0 -1
- package/lib/types/index.js +1 -2
- package/lib/util/array.js +1 -1
- package/lib/util/assertType.js +1 -1
- package/lib/util/asyncStore.js +1 -1
- package/lib/util/debug.js +1 -1
- package/lib/util/deprecate.js +1 -1
- package/lib/util/didYouMean.js +1 -1
- package/lib/util/dump-collection.d.ts +35 -0
- package/lib/util/dump-collection.js +11 -8
- package/lib/util/extractFields.js +1 -1
- package/lib/util/inflector.js +1 -1
- package/lib/util/koncordeCompat.js +1 -1
- package/lib/util/memoize.js +1 -1
- package/lib/util/mutex.js +1 -1
- package/lib/util/name-generator.js +1 -1
- package/lib/util/promback.js +1 -1
- package/lib/util/requestAssertions.js +1 -1
- package/lib/util/safeObject.js +1 -1
- package/lib/util/stackTrace.js +56 -17
- package/lib/util/wildcard.js +1 -1
- package/package-lock.json +102 -83
- package/package.json +18 -17
- package/lib/core/network/removeErrorStack.js +0 -56
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Kuzzle, a backend software, self-hostable and ready to use
|
|
3
3
|
* to power modern apps
|
|
4
4
|
*
|
|
5
|
-
* Copyright 2015-
|
|
5
|
+
* Copyright 2015-2022 Kuzzle
|
|
6
6
|
* mailto: support AT kuzzle.io
|
|
7
7
|
* website: http://kuzzle.io
|
|
8
8
|
*
|
|
@@ -22,12 +22,13 @@
|
|
|
22
22
|
'use strict';
|
|
23
23
|
|
|
24
24
|
const net = require('net');
|
|
25
|
+
|
|
25
26
|
const aedes = require('aedes');
|
|
26
27
|
|
|
27
28
|
const ClientConnection = require('../clientConnection');
|
|
28
29
|
const Protocol = require('./protocol');
|
|
29
30
|
const { Request } = require('../../../api/request');
|
|
30
|
-
const
|
|
31
|
+
const { removeStacktrace } = require('../../../util/stackTrace');
|
|
31
32
|
const kerror = require('../../../kerror').wrap('network', 'mqtt');
|
|
32
33
|
const debug = require('../../../util/debug')('kuzzle:network:protocols:mqtt');
|
|
33
34
|
|
|
@@ -238,7 +239,7 @@ class MqttProtocol extends Protocol {
|
|
|
238
239
|
connection,
|
|
239
240
|
error: kerror.getFrom(error, 'unexpected_error', error.message)
|
|
240
241
|
});
|
|
241
|
-
this._respond(client,
|
|
242
|
+
this._respond(client, removeStacktrace(errReq.response.toJSON()));
|
|
242
243
|
}
|
|
243
244
|
|
|
244
245
|
_authorizePublish (client, packet, callback) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Kuzzle, a backend software, self-hostable and ready to use
|
|
3
3
|
* to power modern apps
|
|
4
4
|
*
|
|
5
|
-
* Copyright 2015-
|
|
5
|
+
* Copyright 2015-2022 Kuzzle
|
|
6
6
|
* mailto: support AT kuzzle.io
|
|
7
7
|
* website: http://kuzzle.io
|
|
8
8
|
*
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
const { Request } = require('../../api/request');
|
|
25
25
|
const kerror = require('../../kerror');
|
|
26
26
|
const HttpRouter = require('./httpRouter');
|
|
27
|
+
const { removeStacktrace } = require('../../util/stackTrace');
|
|
27
28
|
|
|
28
29
|
/**
|
|
29
30
|
* @class Router
|
|
@@ -189,7 +190,15 @@ class Router {
|
|
|
189
190
|
cb(request);
|
|
190
191
|
}
|
|
191
192
|
else {
|
|
192
|
-
global.kuzzle.funnel.execute(mutatedRequest, (err, result) =>
|
|
193
|
+
global.kuzzle.funnel.execute(mutatedRequest, (err, result) => {
|
|
194
|
+
const _res = result || request;
|
|
195
|
+
|
|
196
|
+
if (err && ! _res.error) {
|
|
197
|
+
_res.setError(err);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
cb(removeStacktrace(_res));
|
|
201
|
+
});
|
|
193
202
|
}
|
|
194
203
|
});
|
|
195
204
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Kuzzle, a backend software, self-hostable and ready to use
|
|
3
3
|
* to power modern apps
|
|
4
4
|
*
|
|
5
|
-
* Copyright 2015-
|
|
5
|
+
* Copyright 2015-2022 Kuzzle
|
|
6
6
|
* mailto: support AT kuzzle.io
|
|
7
7
|
* website: http://kuzzle.io
|
|
8
8
|
*
|
|
@@ -300,6 +300,13 @@ class Plugin {
|
|
|
300
300
|
'Controller definition must be an object');
|
|
301
301
|
}
|
|
302
302
|
|
|
303
|
+
if (! isPlainObject(definition.actions)) {
|
|
304
|
+
throw assertionError.get(
|
|
305
|
+
'invalid_controller_definition',
|
|
306
|
+
name,
|
|
307
|
+
'Controller definition "actions" property must be an object');
|
|
308
|
+
}
|
|
309
|
+
|
|
303
310
|
for (const [action, actionDefinition] of Object.entries(definition.actions)) {
|
|
304
311
|
const actionProperties = Object.keys(actionDefinition);
|
|
305
312
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Kuzzle, a backend software, self-hostable and ready to use
|
|
4
4
|
* to power modern apps
|
|
5
5
|
*
|
|
6
|
-
* Copyright 2015-
|
|
6
|
+
* Copyright 2015-2022 Kuzzle
|
|
7
7
|
* mailto: support AT kuzzle.io
|
|
8
8
|
* website: http://kuzzle.io
|
|
9
9
|
*
|
|
@@ -218,20 +218,37 @@ class HotelClerk {
|
|
|
218
218
|
throw kerror.get('api', 'assert', 'koncorde_dsl_error', e.message);
|
|
219
219
|
}
|
|
220
220
|
this.createRoom(normalized);
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
221
|
+
/**
|
|
222
|
+
* You might wonder why in the world is there a callback here.
|
|
223
|
+
* The fact is that to prevent the event loop from switching to another function
|
|
224
|
+
* we need to keep descending the execution stack without returning in a function that has been awaited
|
|
225
|
+
* otherwise once we return to the await keyword the event loop will switch to another function.
|
|
226
|
+
*
|
|
227
|
+
* Everything needs to be atomic (multiple operation done without interruption) otherwise we might
|
|
228
|
+
* run into some issues where the room is created but another request has deleted it before we can
|
|
229
|
+
* subscribe to it.
|
|
230
|
+
* All because the subscription was not atomic.
|
|
231
|
+
*
|
|
232
|
+
* So to keep the context of execution we use a lambda that we give to the subscribeToRoom function
|
|
233
|
+
* and we execute it right after the subscription this way we keep descending the execution stack without returning and
|
|
234
|
+
* without switching context.
|
|
235
|
+
*/
|
|
236
|
+
const afterSubscribeCallback = async (subscribed) => {
|
|
237
|
+
if (subscribed) {
|
|
238
|
+
global.kuzzle.call('core:realtime:subscribe:after', normalized.id);
|
|
239
|
+
// @deprecated -- to be removed in next major version
|
|
240
|
+
// we have to recreate the old "diff" object
|
|
241
|
+
await global.kuzzle.pipe('core:hotelClerk:addSubscription', {
|
|
242
|
+
changed: subscribed,
|
|
243
|
+
collection,
|
|
244
|
+
connectionId: request.context.connection.id,
|
|
245
|
+
filters: normalized.filter,
|
|
246
|
+
index,
|
|
247
|
+
roomId: normalized.id,
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
const { channel } = await this.subscribeToRoom(normalized.id, request, afterSubscribeCallback);
|
|
235
252
|
const subscription = new subscription_1.Subscription(index, collection, request.input.body, normalized.id, request.context.connection.id, request.context.user);
|
|
236
253
|
global.kuzzle.emit('core:realtime:user:subscribe:after', subscription);
|
|
237
254
|
return {
|
|
@@ -260,10 +277,27 @@ class HotelClerk {
|
|
|
260
277
|
}
|
|
261
278
|
this.createRoom(normalized);
|
|
262
279
|
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
280
|
+
/**
|
|
281
|
+
* You might wonder why in the world is there a callback here.
|
|
282
|
+
* The fact is that to prevent the event loop from switching to another function
|
|
283
|
+
* we need to keep descending the execution stack without returning in a function that has been awaited
|
|
284
|
+
* otherwise once we return to the await keyword the event loop will switch to another function.
|
|
285
|
+
*
|
|
286
|
+
* Everything needs to be atomic (multiple operation done without interruption) otherwise we might
|
|
287
|
+
* run into some issues where the room is created but another request has deleted it before we can
|
|
288
|
+
* subscribe to it.
|
|
289
|
+
* All because the subscription was not atomic.
|
|
290
|
+
*
|
|
291
|
+
* So to keep the context of execution we use a lambda that we give to the subscribeToRoom function
|
|
292
|
+
* and we execute it right after the subscription this way we keep descending the execution stack without returning and
|
|
293
|
+
* without switching context.
|
|
294
|
+
*/
|
|
295
|
+
const afterSubscribeCallback = async (subscribed, cluster) => {
|
|
296
|
+
if (cluster && subscribed) {
|
|
297
|
+
global.kuzzle.call('core:realtime:subscribe:after', roomId);
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
const { channel } = await this.subscribeToRoom(roomId, request, afterSubscribeCallback);
|
|
267
301
|
return {
|
|
268
302
|
channel,
|
|
269
303
|
roomId,
|
|
@@ -347,7 +381,7 @@ class HotelClerk {
|
|
|
347
381
|
throw realtimeError.get('too_many_rooms');
|
|
348
382
|
}
|
|
349
383
|
this.koncorde.store(normalized);
|
|
350
|
-
global.kuzzle.
|
|
384
|
+
global.kuzzle.call('core:realtime:room:create:after', normalized);
|
|
351
385
|
// @deprecated -- to be removed in the next major version of kuzzle
|
|
352
386
|
global.kuzzle.emit('room:new', { collection, index, roomId });
|
|
353
387
|
/*
|
|
@@ -395,8 +429,14 @@ class HotelClerk {
|
|
|
395
429
|
global.kuzzle.entryPoint.leaveChannel(channel, connectionId);
|
|
396
430
|
}
|
|
397
431
|
room.removeConnection(connectionId);
|
|
432
|
+
// Used to know whether the room has been deleted or not during the unsubscription
|
|
433
|
+
// We need to store this information for later since we cannot checks if the room exists or has more than 0 subscriber
|
|
434
|
+
// later because the room might have been recreated by the time we need to send the notification
|
|
435
|
+
// all because of the `await this.removeRoom(roomId)`.
|
|
436
|
+
let roomDeleted = false;
|
|
398
437
|
if (room.size === 0) {
|
|
399
438
|
await this.removeRoom(roomId);
|
|
439
|
+
roomDeleted = true;
|
|
400
440
|
}
|
|
401
441
|
// even if the room is deleted for this node, another one may need the
|
|
402
442
|
// notification
|
|
@@ -407,13 +447,13 @@ class HotelClerk {
|
|
|
407
447
|
index: room.index,
|
|
408
448
|
volatile,
|
|
409
449
|
}, requestContext);
|
|
410
|
-
await this.module.notifier.notifyUser(roomId, request, 'out', { count: room.size });
|
|
411
450
|
// Do not send an unsubscription notification if the room has been destroyed
|
|
412
451
|
// because the other nodes already had destroyed it in the full state
|
|
413
452
|
if (notify
|
|
414
453
|
&& this.rooms.has(roomId)
|
|
415
|
-
&& room.channels.size > 0
|
|
416
|
-
|
|
454
|
+
&& room.channels.size > 0
|
|
455
|
+
&& !roomDeleted) {
|
|
456
|
+
global.kuzzle.call('core:realtime:unsubscribe:after', roomId);
|
|
417
457
|
// @deprecated -- to be removed in next major version
|
|
418
458
|
await global.kuzzle.pipe('core:hotelClerk:removeRoomForCustomer', {
|
|
419
459
|
requestContext,
|
|
@@ -424,6 +464,7 @@ class HotelClerk {
|
|
|
424
464
|
},
|
|
425
465
|
});
|
|
426
466
|
}
|
|
467
|
+
await this.module.notifier.notifyUser(roomId, request, 'out', { count: room.size });
|
|
427
468
|
const kuid = global.kuzzle.tokenManager.getKuidFromConnection(connectionId);
|
|
428
469
|
const subscription = new subscription_1.Subscription(room.index, room.collection, undefined, roomId, connectionId, { _id: kuid });
|
|
429
470
|
global.kuzzle.emit('core:realtime:user:unsubscribe:after', {
|
|
@@ -474,7 +515,7 @@ class HotelClerk {
|
|
|
474
515
|
* on the room if it does not already exists.
|
|
475
516
|
*
|
|
476
517
|
*/
|
|
477
|
-
async subscribeToRoom(roomId, request) {
|
|
518
|
+
async subscribeToRoom(roomId, request, afterSubscribeCallback) {
|
|
478
519
|
let subscribed = false;
|
|
479
520
|
let notifyPromise;
|
|
480
521
|
const { scope, users, propagate } = request.input.args;
|
|
@@ -492,6 +533,7 @@ class HotelClerk {
|
|
|
492
533
|
}
|
|
493
534
|
global.kuzzle.entryPoint.joinChannel(channel.name, connectionId);
|
|
494
535
|
room.createChannel(channel);
|
|
536
|
+
await afterSubscribeCallback(subscribed, channel.cluster);
|
|
495
537
|
await notifyPromise;
|
|
496
538
|
return {
|
|
497
539
|
channel: channel.name,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RealtimeController, Notification, JSONObject, ScopeOption, UserOption, Kuzzle } from 'kuzzle-sdk';
|
|
2
|
-
import {
|
|
1
|
+
import { RealtimeController, Notification, JSONObject, ScopeOption, UserOption, Kuzzle, RequestPayload } from 'kuzzle-sdk';
|
|
2
|
+
import { ResponsePayload } from '../../../types';
|
|
3
3
|
interface EmbeddedRealtime extends RealtimeController {
|
|
4
4
|
/**
|
|
5
5
|
* Subscribes by providing a set of filters: messages, document changes
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Kuzzle, a backend software, self-hostable and ready to use
|
|
4
4
|
* to power modern apps
|
|
5
5
|
*
|
|
6
|
-
* Copyright 2015-
|
|
6
|
+
* Copyright 2015-2022 Kuzzle
|
|
7
7
|
* mailto: support AT kuzzle.io
|
|
8
8
|
* website: http://kuzzle.io
|
|
9
9
|
*
|
|
@@ -48,7 +48,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
48
48
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
49
|
exports.EmbeddedSDK = void 0;
|
|
50
50
|
const kuzzle_sdk_1 = require("kuzzle-sdk");
|
|
51
|
-
const funnelProtocol_1 =
|
|
51
|
+
const funnelProtocol_1 = require("./funnelProtocol");
|
|
52
52
|
const safeObject_1 = require("../../../util/safeObject");
|
|
53
53
|
const kerror = __importStar(require("../../../kerror"));
|
|
54
54
|
const impersonatedSdk_1 = __importDefault(require("./impersonatedSdk"));
|
|
@@ -58,7 +58,8 @@ const contextError = kerror.wrap('plugin', 'context');
|
|
|
58
58
|
*/
|
|
59
59
|
class EmbeddedSDK extends kuzzle_sdk_1.Kuzzle {
|
|
60
60
|
constructor() {
|
|
61
|
-
|
|
61
|
+
// FunnelProtocol is not technically a valid SDK protocol
|
|
62
|
+
super(new funnelProtocol_1.FunnelProtocol(), { autoResubscribe: false });
|
|
62
63
|
}
|
|
63
64
|
/**
|
|
64
65
|
* Returns a new SDK impersonated with the provided user.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { KuzzleEventEmitter, RequestPayload } from 'kuzzle-sdk';
|
|
2
|
+
export declare class FunnelProtocol extends KuzzleEventEmitter {
|
|
3
|
+
private id;
|
|
4
|
+
private connectionId;
|
|
5
|
+
constructor();
|
|
6
|
+
isReady(): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Hydrate the user and execute SDK query
|
|
9
|
+
*/
|
|
10
|
+
query(request: RequestPayload): Promise<{
|
|
11
|
+
result: any;
|
|
12
|
+
}>;
|
|
13
|
+
}
|