kuzzle 2.21.1 → 2.22.0
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/lib/core/backend/backend.d.ts +2 -1
- package/lib/core/backend/backend.js +15 -13
- package/lib/core/backend/backendSubscription.d.ts +25 -0
- package/lib/core/backend/backendSubscription.js +90 -0
- package/lib/core/backend/index.d.ts +1 -0
- package/lib/core/backend/index.js +1 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EmbeddedSDK } from "../shared/sdk/embeddedSdk";
|
|
2
|
-
import { EventDefinition, JSONObject } from "../../../index";
|
|
2
|
+
import { BackendSubscription, EventDefinition, JSONObject } from "../../../index";
|
|
3
3
|
import { BackendCluster, BackendConfig, BackendController, BackendHook, BackendImport, BackendPipe, BackendPlugin, BackendStorage, BackendVault, BackendOpenApi, InternalLogger, BackendErrors } from "./index";
|
|
4
4
|
export declare class Backend {
|
|
5
5
|
private _kuzzle;
|
|
@@ -121,6 +121,7 @@ export declare class Backend {
|
|
|
121
121
|
* Standard errors
|
|
122
122
|
*/
|
|
123
123
|
errors: BackendErrors;
|
|
124
|
+
subscription: BackendSubscription;
|
|
124
125
|
/**
|
|
125
126
|
* @deprecated
|
|
126
127
|
*
|
|
@@ -51,7 +51,8 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
51
51
|
const kuzzle_1 = __importDefault(require("../../kuzzle"));
|
|
52
52
|
const embeddedSdk_1 = require("../shared/sdk/embeddedSdk");
|
|
53
53
|
const kerror = __importStar(require("../../kerror"));
|
|
54
|
-
const index_1 = require("
|
|
54
|
+
const index_1 = require("../../../index");
|
|
55
|
+
const index_2 = require("./index");
|
|
55
56
|
const assertionError = kerror.wrap("plugin", "assert");
|
|
56
57
|
const runtimeError = kerror.wrap("plugin", "runtime");
|
|
57
58
|
let _app = null;
|
|
@@ -139,18 +140,19 @@ class Backend {
|
|
|
139
140
|
// Silent if no version can be found
|
|
140
141
|
}
|
|
141
142
|
global.app = this;
|
|
142
|
-
this.pipe = new
|
|
143
|
-
this.hook = new
|
|
144
|
-
this.config = new
|
|
145
|
-
this.vault = new
|
|
146
|
-
this.controller = new
|
|
147
|
-
this.plugin = new
|
|
148
|
-
this.storage = new
|
|
149
|
-
this.import = new
|
|
150
|
-
this.log = new
|
|
151
|
-
this.cluster = new
|
|
152
|
-
this.openApi = new
|
|
153
|
-
this.errors = new
|
|
143
|
+
this.pipe = new index_2.BackendPipe(this);
|
|
144
|
+
this.hook = new index_2.BackendHook(this);
|
|
145
|
+
this.config = new index_2.BackendConfig(this);
|
|
146
|
+
this.vault = new index_2.BackendVault(this);
|
|
147
|
+
this.controller = new index_2.BackendController(this);
|
|
148
|
+
this.plugin = new index_2.BackendPlugin(this);
|
|
149
|
+
this.storage = new index_2.BackendStorage(this);
|
|
150
|
+
this.import = new index_2.BackendImport(this);
|
|
151
|
+
this.log = new index_2.InternalLogger(this);
|
|
152
|
+
this.cluster = new index_2.BackendCluster();
|
|
153
|
+
this.openApi = new index_2.BackendOpenApi(this);
|
|
154
|
+
this.errors = new index_2.BackendErrors(this);
|
|
155
|
+
this.subscription = new index_1.BackendSubscription(this);
|
|
154
156
|
this.kerror = kerror;
|
|
155
157
|
try {
|
|
156
158
|
this.commit = this._readCommit();
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { JSONObject } from "kuzzle-sdk";
|
|
2
|
+
import { Connection } from "../../api/request";
|
|
3
|
+
import { ApplicationManager } from "./index";
|
|
4
|
+
export declare class BackendSubscription extends ApplicationManager {
|
|
5
|
+
/**
|
|
6
|
+
* Registers a new realtime subscription on the specified connection
|
|
7
|
+
*
|
|
8
|
+
* @param connection Connection to register the subscription on
|
|
9
|
+
* @param index Index name
|
|
10
|
+
* @param collection Collection name
|
|
11
|
+
* @param filters Subscription filters
|
|
12
|
+
* @param options.volatile Volatile data
|
|
13
|
+
* @param options.scope Subscription scope
|
|
14
|
+
* @param options.users Option for users notifications
|
|
15
|
+
*/
|
|
16
|
+
add(connection: Connection, index: string, collection: string, filters: JSONObject, { volatile, scope, users, }?: {
|
|
17
|
+
volatile?: JSONObject;
|
|
18
|
+
scope?: "in" | "out" | "all" | "none";
|
|
19
|
+
users?: "in" | "out" | "all" | "none";
|
|
20
|
+
}): Promise<{
|
|
21
|
+
roomId: string;
|
|
22
|
+
channel: string;
|
|
23
|
+
}>;
|
|
24
|
+
remove(connection: Connection, roomId: string): Promise<void>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Kuzzle, a backend software, self-hostable and ready to use
|
|
4
|
+
* to power modern apps
|
|
5
|
+
*
|
|
6
|
+
* Copyright 2015-2022 Kuzzle
|
|
7
|
+
* mailto: support AT kuzzle.io
|
|
8
|
+
* website: http://kuzzle.io
|
|
9
|
+
*
|
|
10
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
11
|
+
* you may not use this file except in compliance with the License.
|
|
12
|
+
* You may obtain a copy of the License at
|
|
13
|
+
*
|
|
14
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
+
*
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
17
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19
|
+
* See the License for the specific language governing permissions and
|
|
20
|
+
* limitations under the License.
|
|
21
|
+
*/
|
|
22
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
23
|
+
if (k2 === undefined) k2 = k;
|
|
24
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
25
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
26
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
27
|
+
}
|
|
28
|
+
Object.defineProperty(o, k2, desc);
|
|
29
|
+
}) : (function(o, m, k, k2) {
|
|
30
|
+
if (k2 === undefined) k2 = k;
|
|
31
|
+
o[k2] = m[k];
|
|
32
|
+
}));
|
|
33
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
34
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
35
|
+
}) : function(o, v) {
|
|
36
|
+
o["default"] = v;
|
|
37
|
+
});
|
|
38
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
39
|
+
if (mod && mod.__esModule) return mod;
|
|
40
|
+
var result = {};
|
|
41
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
42
|
+
__setModuleDefault(result, mod);
|
|
43
|
+
return result;
|
|
44
|
+
};
|
|
45
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
exports.BackendSubscription = void 0;
|
|
47
|
+
const request_1 = require("../../api/request");
|
|
48
|
+
const kerror = __importStar(require("../../kerror"));
|
|
49
|
+
const index_1 = require("./index");
|
|
50
|
+
const runtimeError = kerror.wrap("plugin", "runtime");
|
|
51
|
+
class BackendSubscription extends index_1.ApplicationManager {
|
|
52
|
+
/**
|
|
53
|
+
* Registers a new realtime subscription on the specified connection
|
|
54
|
+
*
|
|
55
|
+
* @param connection Connection to register the subscription on
|
|
56
|
+
* @param index Index name
|
|
57
|
+
* @param collection Collection name
|
|
58
|
+
* @param filters Subscription filters
|
|
59
|
+
* @param options.volatile Volatile data
|
|
60
|
+
* @param options.scope Subscription scope
|
|
61
|
+
* @param options.users Option for users notifications
|
|
62
|
+
*/
|
|
63
|
+
async add(connection, index, collection, filters, { volatile, scope, users, } = {}) {
|
|
64
|
+
if (!this._application.started) {
|
|
65
|
+
throw runtimeError.get("unavailable_before_start", "subscriptions.add");
|
|
66
|
+
}
|
|
67
|
+
const subscriptionRequest = new request_1.KuzzleRequest({
|
|
68
|
+
action: "subscribe",
|
|
69
|
+
body: filters,
|
|
70
|
+
collection,
|
|
71
|
+
controller: "realtime",
|
|
72
|
+
index,
|
|
73
|
+
scope,
|
|
74
|
+
users,
|
|
75
|
+
}, {
|
|
76
|
+
connectionId: connection.id,
|
|
77
|
+
volatile,
|
|
78
|
+
});
|
|
79
|
+
const { channel, roomId } = await global.kuzzle.ask("core:realtime:subscribe", subscriptionRequest);
|
|
80
|
+
return { channel, roomId };
|
|
81
|
+
}
|
|
82
|
+
async remove(connection, roomId) {
|
|
83
|
+
if (!this._application.started) {
|
|
84
|
+
throw runtimeError.get("unavailable_before_start", "subscriptions.remove");
|
|
85
|
+
}
|
|
86
|
+
await global.kuzzle.ask("core:realtime:unsubscribe", connection.id, roomId);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.BackendSubscription = BackendSubscription;
|
|
90
|
+
//# sourceMappingURL=backendSubscription.js.map
|
|
@@ -28,4 +28,5 @@ __exportStar(require("./backendVault"), exports);
|
|
|
28
28
|
__exportStar(require("./backendOpenApi"), exports);
|
|
29
29
|
__exportStar(require("./internalLogger"), exports);
|
|
30
30
|
__exportStar(require("./backendErrors"), exports);
|
|
31
|
+
__exportStar(require("./backendSubscription"), exports);
|
|
31
32
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kuzzle",
|
|
3
3
|
"author": "The Kuzzle Team <support@kuzzle.io>",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.22.0",
|
|
5
5
|
"description": "Kuzzle is an open-source solution that handles all the data management through a secured API, with a large choice of protocols.",
|
|
6
6
|
"bin": "bin/start-kuzzle-server",
|
|
7
7
|
"scripts": {
|