@nocobase/plugin-notification-in-app-message 2.1.0-beta.33 → 2.1.0-beta.35
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/dist/externalVersion.js
CHANGED
|
@@ -9,21 +9,21 @@
|
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
11
|
"react": "18.2.0",
|
|
12
|
-
"@nocobase/client": "2.1.0-beta.
|
|
13
|
-
"@nocobase/plugin-notification-manager": "2.1.0-beta.
|
|
14
|
-
"@nocobase/plugin-mobile": "2.1.0-beta.
|
|
15
|
-
"@nocobase/utils": "2.1.0-beta.
|
|
12
|
+
"@nocobase/client": "2.1.0-beta.35",
|
|
13
|
+
"@nocobase/plugin-notification-manager": "2.1.0-beta.35",
|
|
14
|
+
"@nocobase/plugin-mobile": "2.1.0-beta.35",
|
|
15
|
+
"@nocobase/utils": "2.1.0-beta.35",
|
|
16
16
|
"react-i18next": "11.18.6",
|
|
17
|
-
"@nocobase/
|
|
17
|
+
"@nocobase/database": "2.1.0-beta.35",
|
|
18
|
+
"@nocobase/server": "2.1.0-beta.35",
|
|
18
19
|
"sequelize": "6.35.2",
|
|
19
|
-
"@nocobase/actions": "2.1.0-beta.
|
|
20
|
-
"@nocobase/database": "2.1.0-beta.33",
|
|
20
|
+
"@nocobase/actions": "2.1.0-beta.35",
|
|
21
21
|
"antd": "5.24.2",
|
|
22
|
-
"@nocobase/flow-engine": "2.1.0-beta.
|
|
22
|
+
"@nocobase/flow-engine": "2.1.0-beta.35",
|
|
23
23
|
"antd-style": "3.7.1",
|
|
24
24
|
"@emotion/css": "11.13.0",
|
|
25
25
|
"@formily/react": "2.3.7",
|
|
26
|
-
"@nocobase/plugin-workflow": "2.1.0-beta.
|
|
26
|
+
"@nocobase/plugin-workflow": "2.1.0-beta.35",
|
|
27
27
|
"react-router-dom": "6.30.1",
|
|
28
28
|
"@formily/reactive": "2.3.7",
|
|
29
29
|
"@formily/shared": "2.3.7"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"uuid","version":"10.0.0","description":"RFC9562 UUIDs","funding":["https://github.com/sponsors/broofa","https://github.com/sponsors/ctavan"],"commitlint":{"extends":["@commitlint/config-conventional"]},"keywords":["uuid","guid","rfc4122","rfc9562"],"license":"MIT","bin":{"uuid":"dist/bin/uuid"},"sideEffects":false,"main":"./dist/index.js","exports":{".":{"node":{"module":"./dist/esm-node/index.js","require":"./dist/index.js","import":"./wrapper.mjs"},"browser":{"import":"./dist/esm-browser/index.js","require":"./dist/commonjs-browser/index.js"},"default":"./dist/esm-browser/index.js"},"./package.json":"./package.json"},"module":"./dist/esm-node/index.js","browser":{"./dist/esm-node/index.js":"./dist/esm-browser/index.js","./dist/md5.js":"./dist/md5-browser.js","./dist/native.js":"./dist/native-browser.js","./dist/rng.js":"./dist/rng-browser.js","./dist/sha1.js":"./dist/sha1-browser.js"},"files":["CHANGELOG.md","CONTRIBUTING.md","LICENSE.md","README.md","dist","wrapper.mjs"],"devDependencies":{"@babel/cli":"7.24.6","@babel/core":"7.24.6","@babel/eslint-parser":"7.24.6","@babel/plugin-syntax-import-attributes":"7.24.6","@babel/preset-env":"7.24.6","@commitlint/cli":"19.3.0","@commitlint/config-conventional":"19.2.2","@wdio/browserstack-service":"7.16.10","@wdio/cli":"7.16.10","@wdio/jasmine-framework":"7.16.6","@wdio/local-runner":"7.16.10","@wdio/spec-reporter":"7.16.9","@wdio/static-server-service":"7.16.6","bundlewatch":"0.3.3","eslint":"9.4.0","eslint-plugin-prettier":"5.1.3","globals":"15.3.0","husky":"9.0.11","jest":"29.7.0","lint-staged":"15.2.5","neostandard":"0.5.1","npm-run-all":"4.1.5","optional-dev-dependency":"2.0.1","prettier":"3.3.0","random-seed":"0.3.0","runmd":"1.3.9","standard-version":"9.5.0"},"optionalDevDependencies":{"@wdio/browserstack-service":"7.16.10","@wdio/cli":"7.16.10","@wdio/jasmine-framework":"7.16.6","@wdio/local-runner":"7.16.10","@wdio/spec-reporter":"7.16.9","@wdio/static-server-service":"7.16.6"},"scripts":{"examples:browser:webpack:build":"cd examples/browser-webpack && npm install && npm run build","examples:browser:rollup:build":"cd examples/browser-rollup && npm install && npm run build","examples:node:commonjs:test":"cd examples/node-commonjs && npm install && npm test","examples:node:esmodules:test":"cd examples/node-esmodules && npm install && npm test","examples:node:jest:test":"cd examples/node-jest && npm install && npm test","prepare":"husky install","lint":"npm run eslint:check && npm run prettier:check","eslint:check":"eslint src/ test/ examples/ *.js","eslint:fix":"eslint --fix src/ test/ examples/ *.js","pretest":"npm run build","test":"BABEL_ENV=commonjsNode node --throw-deprecation node_modules/.bin/jest test/unit/","test:matching":"BABEL_ENV=commonjsNode node --throw-deprecation node_modules/.bin/jest test/unit/ -t","pretest:browser":"optional-dev-dependency && npm run build && npm-run-all --parallel examples:browser:**","test:browser":"wdio run ./wdio.conf.js","pretest:node":"npm run build","test:node":"npm-run-all --parallel examples:node:**","test:pack":"./scripts/testpack.sh","pretest:benchmark":"npm run build","test:benchmark":"cd examples/benchmark && HUSKY=0 npm install && npm test","prettier:check":"prettier --check .","prettier:fix":"prettier --write .","bundlewatch":"npm run pretest:browser && bundlewatch --config bundlewatch.config.json","md":"runmd --watch --output=README.md README_js.md","docs":"npm run build && npx runmd --output=README.md README_js.md","docs:diff":"npm run docs && git diff --quiet README.md","build":"./scripts/build.sh","prepack":"npm run build","release":"standard-version --no-verify"},"repository":{"type":"git","url":"git+https://github.com/uuidjs/uuid.git"},"lint-staged":{"*":["prettier --no-error-on-unmatched-pattern --write"],"*.{js,jsx}":["eslint --no-error-on-unmatched-pattern --fix"]},"standard-version":{"scripts":{"postchangelog":"prettier --write CHANGELOG.md"}},"packageManager":"npm@10.8.1+sha256.b8807aebb9656758e2872fa6e7c564b506aa2faa9297439a478d471d2fe32483","_lastModified":"2026-05-
|
|
1
|
+
{"name":"uuid","version":"10.0.0","description":"RFC9562 UUIDs","funding":["https://github.com/sponsors/broofa","https://github.com/sponsors/ctavan"],"commitlint":{"extends":["@commitlint/config-conventional"]},"keywords":["uuid","guid","rfc4122","rfc9562"],"license":"MIT","bin":{"uuid":"dist/bin/uuid"},"sideEffects":false,"main":"./dist/index.js","exports":{".":{"node":{"module":"./dist/esm-node/index.js","require":"./dist/index.js","import":"./wrapper.mjs"},"browser":{"import":"./dist/esm-browser/index.js","require":"./dist/commonjs-browser/index.js"},"default":"./dist/esm-browser/index.js"},"./package.json":"./package.json"},"module":"./dist/esm-node/index.js","browser":{"./dist/esm-node/index.js":"./dist/esm-browser/index.js","./dist/md5.js":"./dist/md5-browser.js","./dist/native.js":"./dist/native-browser.js","./dist/rng.js":"./dist/rng-browser.js","./dist/sha1.js":"./dist/sha1-browser.js"},"files":["CHANGELOG.md","CONTRIBUTING.md","LICENSE.md","README.md","dist","wrapper.mjs"],"devDependencies":{"@babel/cli":"7.24.6","@babel/core":"7.24.6","@babel/eslint-parser":"7.24.6","@babel/plugin-syntax-import-attributes":"7.24.6","@babel/preset-env":"7.24.6","@commitlint/cli":"19.3.0","@commitlint/config-conventional":"19.2.2","@wdio/browserstack-service":"7.16.10","@wdio/cli":"7.16.10","@wdio/jasmine-framework":"7.16.6","@wdio/local-runner":"7.16.10","@wdio/spec-reporter":"7.16.9","@wdio/static-server-service":"7.16.6","bundlewatch":"0.3.3","eslint":"9.4.0","eslint-plugin-prettier":"5.1.3","globals":"15.3.0","husky":"9.0.11","jest":"29.7.0","lint-staged":"15.2.5","neostandard":"0.5.1","npm-run-all":"4.1.5","optional-dev-dependency":"2.0.1","prettier":"3.3.0","random-seed":"0.3.0","runmd":"1.3.9","standard-version":"9.5.0"},"optionalDevDependencies":{"@wdio/browserstack-service":"7.16.10","@wdio/cli":"7.16.10","@wdio/jasmine-framework":"7.16.6","@wdio/local-runner":"7.16.10","@wdio/spec-reporter":"7.16.9","@wdio/static-server-service":"7.16.6"},"scripts":{"examples:browser:webpack:build":"cd examples/browser-webpack && npm install && npm run build","examples:browser:rollup:build":"cd examples/browser-rollup && npm install && npm run build","examples:node:commonjs:test":"cd examples/node-commonjs && npm install && npm test","examples:node:esmodules:test":"cd examples/node-esmodules && npm install && npm test","examples:node:jest:test":"cd examples/node-jest && npm install && npm test","prepare":"husky install","lint":"npm run eslint:check && npm run prettier:check","eslint:check":"eslint src/ test/ examples/ *.js","eslint:fix":"eslint --fix src/ test/ examples/ *.js","pretest":"npm run build","test":"BABEL_ENV=commonjsNode node --throw-deprecation node_modules/.bin/jest test/unit/","test:matching":"BABEL_ENV=commonjsNode node --throw-deprecation node_modules/.bin/jest test/unit/ -t","pretest:browser":"optional-dev-dependency && npm run build && npm-run-all --parallel examples:browser:**","test:browser":"wdio run ./wdio.conf.js","pretest:node":"npm run build","test:node":"npm-run-all --parallel examples:node:**","test:pack":"./scripts/testpack.sh","pretest:benchmark":"npm run build","test:benchmark":"cd examples/benchmark && HUSKY=0 npm install && npm test","prettier:check":"prettier --check .","prettier:fix":"prettier --write .","bundlewatch":"npm run pretest:browser && bundlewatch --config bundlewatch.config.json","md":"runmd --watch --output=README.md README_js.md","docs":"npm run build && npx runmd --output=README.md README_js.md","docs:diff":"npm run docs && git diff --quiet README.md","build":"./scripts/build.sh","prepack":"npm run build","release":"standard-version --no-verify"},"repository":{"type":"git","url":"git+https://github.com/uuidjs/uuid.git"},"lint-staged":{"*":["prettier --no-error-on-unmatched-pattern --write"],"*.{js,jsx}":["eslint --no-error-on-unmatched-pattern --fix"]},"standard-version":{"scripts":{"postchangelog":"prettier --write CHANGELOG.md"}},"packageManager":"npm@10.8.1+sha256.b8807aebb9656758e2872fa6e7c564b506aa2faa9297439a478d471d2fe32483","_lastModified":"2026-05-19T16:50:39.357Z"}
|
|
@@ -10,10 +10,12 @@ import { SendFnType, BaseNotificationChannel } from '@nocobase/plugin-notificati
|
|
|
10
10
|
import { InAppMessageFormValues } from '../types';
|
|
11
11
|
export default class InAppNotificationChannel extends BaseNotificationChannel {
|
|
12
12
|
private static readonly SLOW_SEND_THRESHOLD_MS;
|
|
13
|
+
private static readonly MESSAGE_BATCH_SIZE;
|
|
13
14
|
private getMessagePayload;
|
|
14
15
|
private emitMessageEventsAsync;
|
|
15
16
|
private scheduleMessageEvents;
|
|
16
17
|
private emitMessageEvents;
|
|
18
|
+
private persistMessagesInBatches;
|
|
17
19
|
load(): Promise<void>;
|
|
18
20
|
onMessageCreated: (model: any, options: any) => Promise<void>;
|
|
19
21
|
onMessageUpdated: (model: any, options: any) => Promise<void>;
|
|
@@ -47,6 +47,7 @@ var import_defineMyInAppMessages = __toESM(require("./defineMyInAppMessages"));
|
|
|
47
47
|
var import_defineMyInAppChannels = __toESM(require("./defineMyInAppChannels"));
|
|
48
48
|
class InAppNotificationChannel extends import_plugin_notification_manager.BaseNotificationChannel {
|
|
49
49
|
static SLOW_SEND_THRESHOLD_MS = 200;
|
|
50
|
+
static MESSAGE_BATCH_SIZE = 100;
|
|
50
51
|
getMessagePayload(message) {
|
|
51
52
|
return typeof (message == null ? void 0 : message.toJSON) === "function" ? message.toJSON() : message;
|
|
52
53
|
}
|
|
@@ -95,6 +96,47 @@ class InAppNotificationChannel extends import_plugin_notification_manager.BaseNo
|
|
|
95
96
|
});
|
|
96
97
|
}
|
|
97
98
|
}
|
|
99
|
+
async persistMessagesInBatches(options) {
|
|
100
|
+
const { userIds, title, content, channelName, receiveTimestamp, messageOptions, transaction } = options;
|
|
101
|
+
const MessageModel = this.app.db.getModel(import_types2.InAppMessagesDefinition.name);
|
|
102
|
+
const persist = async (activeTransaction) => {
|
|
103
|
+
let persistedCount = 0;
|
|
104
|
+
for (let index = 0; index < userIds.length; index += InAppNotificationChannel.MESSAGE_BATCH_SIZE) {
|
|
105
|
+
const batchUserIds = userIds.slice(index, index + InAppNotificationChannel.MESSAGE_BATCH_SIZE);
|
|
106
|
+
const messageBatch = batchUserIds.map((userId) => ({
|
|
107
|
+
id: (0, import_uuid.v4)(),
|
|
108
|
+
title,
|
|
109
|
+
content,
|
|
110
|
+
status: "unread",
|
|
111
|
+
userId,
|
|
112
|
+
channelName,
|
|
113
|
+
receiveTimestamp,
|
|
114
|
+
options: messageOptions
|
|
115
|
+
}));
|
|
116
|
+
await MessageModel.bulkCreate(messageBatch, {
|
|
117
|
+
hooks: false,
|
|
118
|
+
transaction: activeTransaction,
|
|
119
|
+
validate: false,
|
|
120
|
+
returning: false
|
|
121
|
+
});
|
|
122
|
+
persistedCount += messageBatch.length;
|
|
123
|
+
this.scheduleMessageEvents("created", messageBatch, activeTransaction);
|
|
124
|
+
}
|
|
125
|
+
return persistedCount;
|
|
126
|
+
};
|
|
127
|
+
if (transaction) {
|
|
128
|
+
return persist(transaction);
|
|
129
|
+
}
|
|
130
|
+
const internalTransaction = await this.app.db.sequelize.transaction();
|
|
131
|
+
try {
|
|
132
|
+
const persistedCount = await persist(internalTransaction);
|
|
133
|
+
await internalTransaction.commit();
|
|
134
|
+
return persistedCount;
|
|
135
|
+
} catch (error) {
|
|
136
|
+
await internalTransaction.rollback();
|
|
137
|
+
throw error;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
98
140
|
async load() {
|
|
99
141
|
this.app.db.on(`${import_types2.InAppMessagesDefinition.name}.afterCreate`, this.onMessageCreated);
|
|
100
142
|
this.app.db.on(`${import_types2.InAppMessagesDefinition.name}.afterBulkCreate`, this.onMessageCreated);
|
|
@@ -128,31 +170,23 @@ class InAppNotificationChannel extends import_plugin_notification_manager.BaseNo
|
|
|
128
170
|
return { status: "success", message };
|
|
129
171
|
}
|
|
130
172
|
const receiveTimestamp = Date.now();
|
|
131
|
-
const
|
|
132
|
-
|
|
173
|
+
const persistStartedAt = Date.now();
|
|
174
|
+
const persistedCount = await this.persistMessagesInBatches({
|
|
175
|
+
userIds: uniqueUserIds,
|
|
133
176
|
title,
|
|
134
177
|
content,
|
|
135
|
-
status: "unread",
|
|
136
|
-
userId,
|
|
137
178
|
channelName: channel.name,
|
|
138
179
|
receiveTimestamp,
|
|
139
|
-
options
|
|
140
|
-
|
|
141
|
-
const MessageModel = this.app.db.getModel(import_types2.InAppMessagesDefinition.name);
|
|
142
|
-
const persistStartedAt = Date.now();
|
|
143
|
-
await MessageModel.bulkCreate(messages, {
|
|
144
|
-
hooks: false,
|
|
145
|
-
transaction,
|
|
146
|
-
validate: false,
|
|
147
|
-
returning: false
|
|
180
|
+
messageOptions: options,
|
|
181
|
+
transaction
|
|
148
182
|
});
|
|
149
183
|
const persistMs = Date.now() - persistStartedAt;
|
|
150
|
-
this.scheduleMessageEvents("created", messages, transaction);
|
|
151
184
|
const totalMs = Date.now() - startedAt;
|
|
152
185
|
if (totalMs >= InAppNotificationChannel.SLOW_SEND_THRESHOLD_MS) {
|
|
153
186
|
this.app.logger.warn("in-app notification send is slow", {
|
|
154
187
|
channelName: channel.name,
|
|
155
|
-
userCount:
|
|
188
|
+
userCount: persistedCount,
|
|
189
|
+
batchSize: InAppNotificationChannel.MESSAGE_BATCH_SIZE,
|
|
156
190
|
resolveReceiversMs,
|
|
157
191
|
persistMs,
|
|
158
192
|
totalMs
|
package/dist/server/plugin.js
CHANGED
|
@@ -54,7 +54,7 @@ class PluginNotificationInAppServer extends import_server.Plugin {
|
|
|
54
54
|
const notificationServer = this.pm.get(import_plugin_notification_manager.default);
|
|
55
55
|
const instance = new import_InAppNotificationChannel.default(this.app);
|
|
56
56
|
instance.load();
|
|
57
|
-
notificationServer.registerChannelType({ type: import_types.inAppTypeName, Channel: import_InAppNotificationChannel.default });
|
|
57
|
+
notificationServer.registerChannelType({ type: import_types.inAppTypeName, Channel: import_InAppNotificationChannel.default, useQueue: false });
|
|
58
58
|
}
|
|
59
59
|
async install() {
|
|
60
60
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-notification-in-app-message",
|
|
3
|
-
"version": "2.1.0-beta.
|
|
3
|
+
"version": "2.1.0-beta.35",
|
|
4
4
|
"displayName": "Notification: In-app message",
|
|
5
5
|
"displayName.ru-RU": "Уведомления: Всплывающие сообщения внутри приложения",
|
|
6
6
|
"displayName.zh-CN": "通知:站内信",
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"react-router-dom": "^6.x"
|
|
33
33
|
},
|
|
34
34
|
"license": "Apache-2.0",
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "74310d8b9e9581fcde14b5a93d12b41ddb5bb325"
|
|
36
36
|
}
|