kuzzle 2.21.1 → 2.23.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/README.md CHANGED
@@ -52,15 +52,14 @@ npx kourou app:scaffold playground
52
52
 
53
53
  🚀 Kourou - Scaffolds a new Kuzzle application
54
54
 
55
- ✔ Creating playground/ directory
56
55
  ✔ Creating and rendering application files
57
- ✔ Installing latest Kuzzle version via NPM and Docker (this can take some time)
58
- [✔] Scaffolding complete! Use "npm run dev:docker" to run your application
56
+
57
+ [✔] Scaffolding complete! Use cd playground && npm run docker npm install install dependencies and then npm run docker:dev to run your application!
59
58
  ```
60
59
 
61
60
  Then you need to run Kuzzle services, Elasticsearch and Redis: `kourou app:start-services`
62
61
 
63
- Finally you can run your application inside Docker with `npm run dev:docker`
62
+ Finally you can run your application inside Docker with `npm run docker:dev`
64
63
 
65
64
  Kuzzle is now listening for requests on the port `7512`!
66
65
 
@@ -115,8 +115,11 @@ class ClusterIdCardHandler {
115
115
  await this.node.evictSelf(message.error);
116
116
  }
117
117
  });
118
- this.refreshWorker.on("close", () => {
119
- this.disposed = true;
118
+ this.refreshWorker.on("close", async () => {
119
+ if (!this.disposed) {
120
+ this.disposed = true;
121
+ await this.node.evictSelf("ID Card renewer worker closed unexpectedly");
122
+ }
120
123
  });
121
124
  // Transfer informations to the worker
122
125
  this.refreshWorker.send({
@@ -140,7 +143,17 @@ class ClusterIdCardHandler {
140
143
  * Helper method to mock worker instantiation in unit tests
141
144
  */
142
145
  constructWorker(path) {
143
- return (0, child_process_1.fork)(path);
146
+ const childProcess = (0, child_process_1.fork)(path);
147
+ const exitHandler = () => {
148
+ if (!childProcess.killed || childProcess.connected) {
149
+ childProcess.kill();
150
+ }
151
+ process.exit();
152
+ };
153
+ process.on("exit", exitHandler);
154
+ process.on("SIGINT", exitHandler);
155
+ process.on("SIGTERM", exitHandler);
156
+ return childProcess;
144
157
  }
145
158
  /**
146
159
  * Start refreshing the ID Card before the worker starts to ensure the ID Card
@@ -135,4 +135,9 @@ process.on("message", async (message) => {
135
135
  }
136
136
  });
137
137
 
138
+ // When the IPC is closed on the main process side
139
+ process.on("disconnect", () => {
140
+ process.exit();
141
+ });
142
+
138
143
  module.exports = { IDCardRenewer };
@@ -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("./index");
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 index_1.BackendPipe(this);
143
- this.hook = new index_1.BackendHook(this);
144
- this.config = new index_1.BackendConfig(this);
145
- this.vault = new index_1.BackendVault(this);
146
- this.controller = new index_1.BackendController(this);
147
- this.plugin = new index_1.BackendPlugin(this);
148
- this.storage = new index_1.BackendStorage(this);
149
- this.import = new index_1.BackendImport(this);
150
- this.log = new index_1.InternalLogger(this);
151
- this.cluster = new index_1.BackendCluster();
152
- this.openApi = new index_1.BackendOpenApi(this);
153
- this.errors = new index_1.BackendErrors(this);
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
@@ -12,3 +12,4 @@ export * from "./backendVault";
12
12
  export * from "./backendOpenApi";
13
13
  export * from "./internalLogger";
14
14
  export * from "./backendErrors";
15
+ export * from "./backendSubscription";
@@ -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.21.1",
4
+ "version": "2.23.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": {
@@ -61,7 +61,7 @@
61
61
  "json-stable-stringify": "^1.0.2",
62
62
  "json2yaml": "^1.1.0",
63
63
  "jsonwebtoken": "^8.5.1",
64
- "koncorde": "^4.0.3",
64
+ "koncorde": "^4.1.0",
65
65
  "kuzzle-plugin-auth-passport-local": "^6.3.6",
66
66
  "kuzzle-plugin-logger": "^3.0.3",
67
67
  "kuzzle-sdk": "^7.10.5",