@abtnode/models 1.16.36 → 1.16.37-beta-20241224-013714-a79db7d3
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/migrations/blocklet/20241122000000-notification-receivers.js +14 -0
- package/lib/migrations/blocklet/20241216000000-notification.js +92 -0
- package/lib/migrations/server/20241122000000-notification-receivers.js +14 -0
- package/lib/migrations/server/20241216000000-notification.js +92 -0
- package/lib/models/index.d.ts +4 -2
- package/lib/models/index.js +3 -0
- package/lib/models/notification-receivers.d.ts +4 -0
- package/lib/models/notification-receivers.js +85 -0
- package/lib/models/notification.d.ts +1 -1
- package/lib/models/notification.js +41 -11
- package/lib/states/base.js +4 -2
- package/package.json +5 -5
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.down = exports.up = void 0;
|
|
4
|
+
const models_1 = require("../../models");
|
|
5
|
+
const models = (0, models_1.getBlockletModels)();
|
|
6
|
+
// eslint-disable-next-line import/prefer-default-export
|
|
7
|
+
const up = async ({ context }) => {
|
|
8
|
+
await context.createTable('notification_receivers', models.NotificationReceivers.GENESIS_ATTRIBUTES);
|
|
9
|
+
};
|
|
10
|
+
exports.up = up;
|
|
11
|
+
const down = async ({ context }) => {
|
|
12
|
+
await context.dropTable('notification_receivers');
|
|
13
|
+
};
|
|
14
|
+
exports.down = down;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.down = exports.up = void 0;
|
|
4
|
+
const sequelize_1 = require("sequelize");
|
|
5
|
+
// eslint-disable-next-line import/prefer-default-export
|
|
6
|
+
const up = async ({ context }) => {
|
|
7
|
+
await context.changeColumn('notifications', 'receiver', {
|
|
8
|
+
type: sequelize_1.DataTypes.STRING(40),
|
|
9
|
+
allowNull: true, // 修改为允许空值
|
|
10
|
+
});
|
|
11
|
+
await context.changeColumn('notifications', 'action', {
|
|
12
|
+
type: sequelize_1.DataTypes.STRING(255),
|
|
13
|
+
allowNull: true, // 修改为允许空值
|
|
14
|
+
});
|
|
15
|
+
await context.changeColumn('notifications', 'entityType', {
|
|
16
|
+
type: sequelize_1.DataTypes.STRING(32),
|
|
17
|
+
allowNull: true, // 修改为允许空值
|
|
18
|
+
});
|
|
19
|
+
await context.changeColumn('notifications', 'entityId', {
|
|
20
|
+
type: sequelize_1.DataTypes.STRING(40),
|
|
21
|
+
allowNull: true, // 修改为允许空值
|
|
22
|
+
});
|
|
23
|
+
// 冗余字段
|
|
24
|
+
await context.removeColumn('notifications', 'updatedAt');
|
|
25
|
+
// 新增字段
|
|
26
|
+
const columnsToAdd = {
|
|
27
|
+
attachments: {
|
|
28
|
+
type: sequelize_1.DataTypes.JSON,
|
|
29
|
+
allowNull: true,
|
|
30
|
+
},
|
|
31
|
+
blocks: {
|
|
32
|
+
type: sequelize_1.DataTypes.JSON,
|
|
33
|
+
allowNull: true,
|
|
34
|
+
},
|
|
35
|
+
actions: {
|
|
36
|
+
type: sequelize_1.DataTypes.JSON,
|
|
37
|
+
allowNull: true,
|
|
38
|
+
},
|
|
39
|
+
componentDid: {
|
|
40
|
+
type: sequelize_1.DataTypes.STRING(40),
|
|
41
|
+
allowNull: true,
|
|
42
|
+
},
|
|
43
|
+
source: {
|
|
44
|
+
type: sequelize_1.DataTypes.ENUM('system', 'component'),
|
|
45
|
+
allowNull: true,
|
|
46
|
+
defaultValue: 'system',
|
|
47
|
+
},
|
|
48
|
+
type: {
|
|
49
|
+
type: sequelize_1.DataTypes.ENUM('notification', 'connect', 'feed', 'hi', 'passthrough'),
|
|
50
|
+
allowNull: false,
|
|
51
|
+
defaultValue: 'notification',
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
const tableDescriptions = await context.describeTable('notifications');
|
|
55
|
+
const promises = [];
|
|
56
|
+
for (const [columnName, columnDefinition] of Object.entries(columnsToAdd)) {
|
|
57
|
+
if (!tableDescriptions[columnName]) {
|
|
58
|
+
promises.push(context.addColumn('notifications', columnName, columnDefinition));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
await Promise.all(promises);
|
|
62
|
+
};
|
|
63
|
+
exports.up = up;
|
|
64
|
+
const down = async ({ context }) => {
|
|
65
|
+
await context.changeColumn('notifications', 'receiver', {
|
|
66
|
+
type: sequelize_1.DataTypes.STRING(40),
|
|
67
|
+
allowNull: false, // 修改为允许空值
|
|
68
|
+
});
|
|
69
|
+
await context.changeColumn('notifications', 'action', {
|
|
70
|
+
type: sequelize_1.DataTypes.STRING(255),
|
|
71
|
+
allowNull: false, // 修改为允许空值
|
|
72
|
+
});
|
|
73
|
+
await context.changeColumn('notifications', 'entityType', {
|
|
74
|
+
type: sequelize_1.DataTypes.STRING(32),
|
|
75
|
+
allowNull: false, // 修改为允许空值
|
|
76
|
+
});
|
|
77
|
+
await context.changeColumn('notifications', 'entityId', {
|
|
78
|
+
type: sequelize_1.DataTypes.STRING(40),
|
|
79
|
+
allowNull: false, // 修改为允许空值
|
|
80
|
+
});
|
|
81
|
+
await context.addColumn('notifications', 'updatedAt', {
|
|
82
|
+
type: sequelize_1.DataTypes.DATE,
|
|
83
|
+
defaultValue: sequelize_1.DataTypes.NOW,
|
|
84
|
+
});
|
|
85
|
+
await context.removeColumn('notifications', 'attachments');
|
|
86
|
+
await context.removeColumn('notifications', 'blocks');
|
|
87
|
+
await context.removeColumn('notifications', 'actions');
|
|
88
|
+
await context.removeColumn('notifications', 'componentDid');
|
|
89
|
+
await context.removeColumn('notifications', 'source');
|
|
90
|
+
await context.removeColumn('notifications', 'type');
|
|
91
|
+
};
|
|
92
|
+
exports.down = down;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.down = exports.up = void 0;
|
|
4
|
+
const models_1 = require("../../models");
|
|
5
|
+
const models = (0, models_1.getBlockletModels)();
|
|
6
|
+
// eslint-disable-next-line import/prefer-default-export
|
|
7
|
+
const up = async ({ context }) => {
|
|
8
|
+
await context.createTable('notification_receivers', models.NotificationReceivers.GENESIS_ATTRIBUTES);
|
|
9
|
+
};
|
|
10
|
+
exports.up = up;
|
|
11
|
+
const down = async ({ context }) => {
|
|
12
|
+
await context.dropTable('notification_receivers');
|
|
13
|
+
};
|
|
14
|
+
exports.down = down;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.down = exports.up = void 0;
|
|
4
|
+
const sequelize_1 = require("sequelize");
|
|
5
|
+
// eslint-disable-next-line import/prefer-default-export
|
|
6
|
+
const up = async ({ context }) => {
|
|
7
|
+
await context.changeColumn('notifications', 'receiver', {
|
|
8
|
+
type: sequelize_1.DataTypes.STRING(40),
|
|
9
|
+
allowNull: true, // 修改为允许空值
|
|
10
|
+
});
|
|
11
|
+
await context.changeColumn('notifications', 'action', {
|
|
12
|
+
type: sequelize_1.DataTypes.STRING(255),
|
|
13
|
+
allowNull: true, // 修改为允许空值
|
|
14
|
+
});
|
|
15
|
+
await context.changeColumn('notifications', 'entityType', {
|
|
16
|
+
type: sequelize_1.DataTypes.STRING(32),
|
|
17
|
+
allowNull: true, // 修改为允许空值
|
|
18
|
+
});
|
|
19
|
+
await context.changeColumn('notifications', 'entityId', {
|
|
20
|
+
type: sequelize_1.DataTypes.STRING(40),
|
|
21
|
+
allowNull: true, // 修改为允许空值
|
|
22
|
+
});
|
|
23
|
+
// 冗余字段
|
|
24
|
+
await context.removeColumn('notifications', 'updatedAt');
|
|
25
|
+
// 新增字段
|
|
26
|
+
const columnsToAdd = {
|
|
27
|
+
attachments: {
|
|
28
|
+
type: sequelize_1.DataTypes.JSON,
|
|
29
|
+
allowNull: true,
|
|
30
|
+
},
|
|
31
|
+
blocks: {
|
|
32
|
+
type: sequelize_1.DataTypes.JSON,
|
|
33
|
+
allowNull: true,
|
|
34
|
+
},
|
|
35
|
+
actions: {
|
|
36
|
+
type: sequelize_1.DataTypes.JSON,
|
|
37
|
+
allowNull: true,
|
|
38
|
+
},
|
|
39
|
+
componentDid: {
|
|
40
|
+
type: sequelize_1.DataTypes.STRING(40),
|
|
41
|
+
allowNull: true,
|
|
42
|
+
},
|
|
43
|
+
source: {
|
|
44
|
+
type: sequelize_1.DataTypes.ENUM('system', 'component'),
|
|
45
|
+
allowNull: true,
|
|
46
|
+
defaultValue: 'system',
|
|
47
|
+
},
|
|
48
|
+
type: {
|
|
49
|
+
type: sequelize_1.DataTypes.ENUM('notification', 'connect', 'feed', 'hi', 'passthrough'),
|
|
50
|
+
allowNull: false,
|
|
51
|
+
defaultValue: 'notification',
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
const tableDescriptions = await context.describeTable('notifications');
|
|
55
|
+
const promises = [];
|
|
56
|
+
for (const [columnName, columnDefinition] of Object.entries(columnsToAdd)) {
|
|
57
|
+
if (!tableDescriptions[columnName]) {
|
|
58
|
+
promises.push(context.addColumn('notifications', columnName, columnDefinition));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
await Promise.all(promises);
|
|
62
|
+
};
|
|
63
|
+
exports.up = up;
|
|
64
|
+
const down = async ({ context }) => {
|
|
65
|
+
await context.changeColumn('notifications', 'receiver', {
|
|
66
|
+
type: sequelize_1.DataTypes.STRING(40),
|
|
67
|
+
allowNull: false, // 修改为允许空值
|
|
68
|
+
});
|
|
69
|
+
await context.changeColumn('notifications', 'action', {
|
|
70
|
+
type: sequelize_1.DataTypes.STRING(255),
|
|
71
|
+
allowNull: false, // 修改为允许空值
|
|
72
|
+
});
|
|
73
|
+
await context.changeColumn('notifications', 'entityType', {
|
|
74
|
+
type: sequelize_1.DataTypes.STRING(32),
|
|
75
|
+
allowNull: false, // 修改为允许空值
|
|
76
|
+
});
|
|
77
|
+
await context.changeColumn('notifications', 'entityId', {
|
|
78
|
+
type: sequelize_1.DataTypes.STRING(40),
|
|
79
|
+
allowNull: false, // 修改为允许空值
|
|
80
|
+
});
|
|
81
|
+
await context.addColumn('notifications', 'updatedAt', {
|
|
82
|
+
type: sequelize_1.DataTypes.DATE,
|
|
83
|
+
defaultValue: sequelize_1.DataTypes.NOW,
|
|
84
|
+
});
|
|
85
|
+
await context.removeColumn('notifications', 'attachments');
|
|
86
|
+
await context.removeColumn('notifications', 'blocks');
|
|
87
|
+
await context.removeColumn('notifications', 'actions');
|
|
88
|
+
await context.removeColumn('notifications', 'componentDid');
|
|
89
|
+
await context.removeColumn('notifications', 'source');
|
|
90
|
+
await context.removeColumn('notifications', 'type');
|
|
91
|
+
};
|
|
92
|
+
exports.down = down;
|
package/lib/models/index.d.ts
CHANGED
|
@@ -54,7 +54,8 @@ export declare function getBlockletModels(): {
|
|
|
54
54
|
Tagging: import("../types").DynamicModel<import("./tagging").TaggingState>;
|
|
55
55
|
Project: import("../types").DynamicModel<import("./project").ProjectState>;
|
|
56
56
|
Release: import("../types").DynamicModel<import("./release").ReleaseState>;
|
|
57
|
-
Notification: import("../types").DynamicModel<import("
|
|
57
|
+
Notification: import("../types").DynamicModel<import("./notification").NotificationState>;
|
|
58
|
+
NotificationReceivers: import("../types").DynamicModel<import("@abtnode/types").TNotificationReceiver>;
|
|
58
59
|
VerifyCode: import("../types").DynamicModel<import("./verify-code").VerifyCodeState>;
|
|
59
60
|
SecurityRule: import("../types").DynamicModel<import("./security-rule").SecurityRuleState>;
|
|
60
61
|
AccessPolicy: import("../types").DynamicModel<import("./access-policy").AccessPolicyState>;
|
|
@@ -68,7 +69,8 @@ export declare function getServerModels(): {
|
|
|
68
69
|
Cache: import("../types").DynamicModel<import("./cache").CacheState>;
|
|
69
70
|
Job: import("../types").DynamicModel<import("./job").JobState>;
|
|
70
71
|
Migration: import("../types").DynamicModel<import("./migration").MigrationState>;
|
|
71
|
-
Notification: import("../types").DynamicModel<import("
|
|
72
|
+
Notification: import("../types").DynamicModel<import("./notification").NotificationState>;
|
|
73
|
+
NotificationReceivers: import("../types").DynamicModel<import("@abtnode/types").TNotificationReceiver>;
|
|
72
74
|
Rbac: import("../types").DynamicModel<import("./rbac").RbacState>;
|
|
73
75
|
Server: import("../types").DynamicModel<import("./server").ServerState>;
|
|
74
76
|
Session: import("../types").DynamicModel<import("./session").SessionState>;
|
package/lib/models/index.js
CHANGED
|
@@ -41,6 +41,7 @@ const cache_1 = require("./cache");
|
|
|
41
41
|
const job_1 = require("./job");
|
|
42
42
|
const migration_1 = require("./migration");
|
|
43
43
|
const notification_1 = require("./notification");
|
|
44
|
+
const notification_receivers_1 = require("./notification-receivers");
|
|
44
45
|
const server_1 = require("./server");
|
|
45
46
|
const site_1 = require("./site");
|
|
46
47
|
const webhook_1 = require("./webhook");
|
|
@@ -147,6 +148,7 @@ function getBlockletModels() {
|
|
|
147
148
|
Project: (0, project_1.createProjectModel)(),
|
|
148
149
|
Release: (0, release_1.createReleaseModel)(),
|
|
149
150
|
Notification: (0, notification_1.createNotificationModel)(),
|
|
151
|
+
NotificationReceivers: (0, notification_receivers_1.createNotificationReceiversModel)(),
|
|
150
152
|
VerifyCode: (0, verify_code_1.createVerifyCodeModel)(),
|
|
151
153
|
SecurityRule: (0, security_rule_1.createSecurityRuleModel)(),
|
|
152
154
|
AccessPolicy: (0, access_policy_1.createAccessPolicyModel)(),
|
|
@@ -164,6 +166,7 @@ function getServerModels() {
|
|
|
164
166
|
Job: (0, job_1.createJobModel)(),
|
|
165
167
|
Migration: (0, migration_1.createMigrationModel)(),
|
|
166
168
|
Notification: (0, notification_1.createNotificationModel)(),
|
|
169
|
+
NotificationReceivers: (0, notification_receivers_1.createNotificationReceiversModel)(),
|
|
167
170
|
Rbac: (0, rbac_1.createRbacModel)(),
|
|
168
171
|
Server: (0, server_1.createServerModel)(),
|
|
169
172
|
Session: (0, session_1.createSessionModel)(),
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createNotificationReceiversModel = createNotificationReceiversModel;
|
|
4
|
+
const sequelize_1 = require("sequelize");
|
|
5
|
+
const util_1 = require("../util");
|
|
6
|
+
function createNotificationReceiversModel() {
|
|
7
|
+
var _a;
|
|
8
|
+
return _a = class NotificationReceivers extends sequelize_1.Model {
|
|
9
|
+
static initialize(sequelize) {
|
|
10
|
+
this.init({
|
|
11
|
+
...this.GENESIS_ATTRIBUTES,
|
|
12
|
+
}, {
|
|
13
|
+
sequelize,
|
|
14
|
+
modelName: 'NotificationReceivers',
|
|
15
|
+
indexes: [{ fields: ['notificationId'] }, { fields: ['receiver'] }],
|
|
16
|
+
tableName: 'notification_receivers',
|
|
17
|
+
timestamps: true,
|
|
18
|
+
updatedAt: false,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
static associate(models) {
|
|
22
|
+
_a.belongsTo(models.Notification, {
|
|
23
|
+
foreignKey: 'notificationId',
|
|
24
|
+
as: 'notification',
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
_a.GENESIS_ATTRIBUTES = {
|
|
29
|
+
id: {
|
|
30
|
+
type: sequelize_1.DataTypes.STRING(40),
|
|
31
|
+
primaryKey: true,
|
|
32
|
+
defaultValue: util_1.generateId,
|
|
33
|
+
},
|
|
34
|
+
notificationId: {
|
|
35
|
+
type: sequelize_1.DataTypes.STRING(40),
|
|
36
|
+
allowNull: false,
|
|
37
|
+
index: true,
|
|
38
|
+
},
|
|
39
|
+
receiver: {
|
|
40
|
+
type: sequelize_1.DataTypes.STRING(40),
|
|
41
|
+
allowNull: false,
|
|
42
|
+
},
|
|
43
|
+
read: {
|
|
44
|
+
type: sequelize_1.DataTypes.BOOLEAN,
|
|
45
|
+
defaultValue: false,
|
|
46
|
+
},
|
|
47
|
+
readAt: {
|
|
48
|
+
type: sequelize_1.DataTypes.DATE,
|
|
49
|
+
defaultValue: sequelize_1.DataTypes.NOW,
|
|
50
|
+
},
|
|
51
|
+
walletSendStatus: {
|
|
52
|
+
type: sequelize_1.DataTypes.NUMBER,
|
|
53
|
+
defaultValue: 0,
|
|
54
|
+
allowNull: false,
|
|
55
|
+
},
|
|
56
|
+
walletSendAt: {
|
|
57
|
+
type: sequelize_1.DataTypes.DATE,
|
|
58
|
+
defaultValue: sequelize_1.DataTypes.NOW,
|
|
59
|
+
},
|
|
60
|
+
pushKitSendStatus: {
|
|
61
|
+
type: sequelize_1.DataTypes.NUMBER,
|
|
62
|
+
defaultValue: 0,
|
|
63
|
+
allowNull: false,
|
|
64
|
+
},
|
|
65
|
+
pushKitSendAt: {
|
|
66
|
+
type: sequelize_1.DataTypes.DATE,
|
|
67
|
+
defaultValue: sequelize_1.DataTypes.NOW,
|
|
68
|
+
},
|
|
69
|
+
emailSendStatus: {
|
|
70
|
+
type: sequelize_1.DataTypes.NUMBER,
|
|
71
|
+
defaultValue: 0,
|
|
72
|
+
allowNull: false,
|
|
73
|
+
},
|
|
74
|
+
emailSendAt: {
|
|
75
|
+
type: sequelize_1.DataTypes.DATE,
|
|
76
|
+
defaultValue: sequelize_1.DataTypes.NOW,
|
|
77
|
+
},
|
|
78
|
+
createdAt: {
|
|
79
|
+
type: sequelize_1.DataTypes.DATE,
|
|
80
|
+
defaultValue: sequelize_1.DataTypes.NOW,
|
|
81
|
+
index: true,
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
_a;
|
|
85
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { TNotification } from '@abtnode/types';
|
|
2
2
|
import { DynamicModel } from '../types';
|
|
3
|
-
export type NotificationState = TNotification & {}
|
|
3
|
+
export type NotificationState = Omit<TNotification & {}, 'receivers'>;
|
|
4
4
|
export declare function createNotificationModel(): DynamicModel<NotificationState>;
|
|
@@ -9,12 +9,51 @@ function createNotificationModel() {
|
|
|
9
9
|
static initialize(sequelize) {
|
|
10
10
|
this.init({
|
|
11
11
|
...this.GENESIS_ATTRIBUTES,
|
|
12
|
+
/* 新增字段 */
|
|
13
|
+
attachments: {
|
|
14
|
+
type: sequelize_1.DataTypes.JSON,
|
|
15
|
+
allowNull: true,
|
|
16
|
+
},
|
|
17
|
+
blocks: {
|
|
18
|
+
type: sequelize_1.DataTypes.JSON,
|
|
19
|
+
allowNull: true,
|
|
20
|
+
},
|
|
21
|
+
actions: {
|
|
22
|
+
type: sequelize_1.DataTypes.JSON,
|
|
23
|
+
allowNull: true,
|
|
24
|
+
},
|
|
25
|
+
componentDid: {
|
|
26
|
+
type: sequelize_1.DataTypes.STRING(40),
|
|
27
|
+
allowNull: true,
|
|
28
|
+
},
|
|
29
|
+
source: {
|
|
30
|
+
type: sequelize_1.DataTypes.ENUM('system', 'component'),
|
|
31
|
+
allowNull: true,
|
|
32
|
+
defaultValue: 'system',
|
|
33
|
+
},
|
|
34
|
+
type: {
|
|
35
|
+
type: sequelize_1.DataTypes.ENUM('notification', 'connect', 'feed', 'hi', 'passthrough'),
|
|
36
|
+
allowNull: false,
|
|
37
|
+
defaultValue: 'notification',
|
|
38
|
+
},
|
|
12
39
|
}, {
|
|
13
40
|
sequelize,
|
|
14
41
|
modelName: 'Notification',
|
|
15
|
-
indexes: [
|
|
42
|
+
indexes: [
|
|
43
|
+
{ fields: ['sender'] },
|
|
44
|
+
{ fields: ['receiver'] },
|
|
45
|
+
{ fields: ['componentDid'] },
|
|
46
|
+
{ fields: ['severity'] },
|
|
47
|
+
],
|
|
16
48
|
tableName: 'notifications',
|
|
17
49
|
timestamps: true,
|
|
50
|
+
updatedAt: false,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
static associate(models) {
|
|
54
|
+
_a.hasMany(models.NotificationReceivers, {
|
|
55
|
+
foreignKey: 'notificationId',
|
|
56
|
+
as: 'receivers',
|
|
18
57
|
});
|
|
19
58
|
}
|
|
20
59
|
},
|
|
@@ -30,7 +69,6 @@ function createNotificationModel() {
|
|
|
30
69
|
},
|
|
31
70
|
receiver: {
|
|
32
71
|
type: sequelize_1.DataTypes.STRING(40),
|
|
33
|
-
allowNull: false,
|
|
34
72
|
},
|
|
35
73
|
title: {
|
|
36
74
|
type: sequelize_1.DataTypes.STRING(255),
|
|
@@ -42,18 +80,15 @@ function createNotificationModel() {
|
|
|
42
80
|
},
|
|
43
81
|
action: {
|
|
44
82
|
type: sequelize_1.DataTypes.STRING(255),
|
|
45
|
-
allowNull: false,
|
|
46
83
|
},
|
|
47
84
|
entityType: {
|
|
48
85
|
type: sequelize_1.DataTypes.STRING(32),
|
|
49
|
-
allowNull: false,
|
|
50
86
|
},
|
|
51
87
|
entityId: {
|
|
52
88
|
type: sequelize_1.DataTypes.STRING(40),
|
|
53
|
-
allowNull: false,
|
|
54
89
|
},
|
|
55
90
|
severity: {
|
|
56
|
-
type: sequelize_1.DataTypes.
|
|
91
|
+
type: sequelize_1.DataTypes.ENUM('info', 'success', 'error', 'warning'),
|
|
57
92
|
allowNull: false,
|
|
58
93
|
},
|
|
59
94
|
read: {
|
|
@@ -66,11 +101,6 @@ function createNotificationModel() {
|
|
|
66
101
|
defaultValue: sequelize_1.DataTypes.NOW,
|
|
67
102
|
index: true,
|
|
68
103
|
},
|
|
69
|
-
updatedAt: {
|
|
70
|
-
type: sequelize_1.DataTypes.DATE,
|
|
71
|
-
defaultValue: sequelize_1.DataTypes.NOW,
|
|
72
|
-
index: true,
|
|
73
|
-
},
|
|
74
104
|
},
|
|
75
105
|
_a;
|
|
76
106
|
}
|
package/lib/states/base.js
CHANGED
|
@@ -41,8 +41,9 @@ class BaseState extends events_1.EventEmitter {
|
|
|
41
41
|
});
|
|
42
42
|
return this.model.findOne(params).then((x) => x?.toJSON());
|
|
43
43
|
}
|
|
44
|
-
count(condition = {}) {
|
|
45
|
-
|
|
44
|
+
async count(condition = {}) {
|
|
45
|
+
const count = await this.model.count({ ...(0, util_1.formatConditions)(condition) });
|
|
46
|
+
return count;
|
|
46
47
|
}
|
|
47
48
|
async insert(doc) {
|
|
48
49
|
const newDoc = await this.model.create(doc, { returning: true });
|
|
@@ -88,6 +89,7 @@ class BaseState extends events_1.EventEmitter {
|
|
|
88
89
|
this.count({
|
|
89
90
|
distinct: true,
|
|
90
91
|
where: params.where,
|
|
92
|
+
include: params.include ?? [],
|
|
91
93
|
replacements: condition?.replacements ?? {},
|
|
92
94
|
}),
|
|
93
95
|
this.model.findAll(params),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abtnode/models",
|
|
3
|
-
"version": "1.16.
|
|
3
|
+
"version": "1.16.37-beta-20241224-013714-a79db7d3",
|
|
4
4
|
"description": "Sequelize models for blocklet server and blocklet service",
|
|
5
5
|
"homepage": "https://github.com/ArcBlock/blocklet-server#readme",
|
|
6
6
|
"publishConfig": {
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
"url": "https://github.com/ArcBlock/blocklet-server/issues"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@abtnode/constant": "1.16.
|
|
37
|
-
"@abtnode/logger": "1.16.
|
|
38
|
-
"@abtnode/types": "1.16.
|
|
36
|
+
"@abtnode/constant": "1.16.37-beta-20241224-013714-a79db7d3",
|
|
37
|
+
"@abtnode/logger": "1.16.37-beta-20241224-013714-a79db7d3",
|
|
38
|
+
"@abtnode/types": "1.16.37-beta-20241224-013714-a79db7d3",
|
|
39
39
|
"lodash.clonedeep": "^4.5.0",
|
|
40
40
|
"lodash.isempty": "^4.4.0",
|
|
41
41
|
"sequelize": "^6.35.0",
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"typescript": "^5.6.3"
|
|
56
56
|
},
|
|
57
57
|
"resolutions": {},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "040363d1ac077f7d4b4ee29e6c3bfc3e61c3ce3f"
|
|
59
59
|
}
|