@abtnode/models 1.16.32-beta-4d47ae7f → 1.16.32-beta-17be26d7

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.
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.down = exports.up = void 0;
4
+ const sequelize_1 = require("sequelize");
5
+ const models_1 = require("../../models");
6
+ const models = (0, models_1.getBlockletModels)();
7
+ const up = async ({ context }) => {
8
+ await context.createTable('verify_codes', models.VerifyCode.GENESIS_ATTRIBUTES);
9
+ await context.addColumn('passports', 'scope', { type: sequelize_1.DataTypes.ENUM('passport', 'kyc'), defaultValue: 'passport' });
10
+ await context.sequelize.query('UPDATE passports SET scope="passport"');
11
+ };
12
+ exports.up = up;
13
+ const down = async ({ context }) => {
14
+ await context.dropTable('verify_codes');
15
+ await context.removeColumn('passports', 'scope');
16
+ };
17
+ exports.down = down;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.down = exports.up = void 0;
4
+ const sequelize_1 = require("sequelize");
5
+ const up = async ({ context }) => {
6
+ await context.addColumn('users', 'emailVerified', { type: sequelize_1.DataTypes.BOOLEAN, defaultValue: false });
7
+ await context.addColumn('users', 'phoneVerified', { type: sequelize_1.DataTypes.BOOLEAN, defaultValue: false });
8
+ await context.sequelize.query('UPDATE users SET emailVerified=false,phoneVerified=false');
9
+ };
10
+ exports.up = up;
11
+ const down = async ({ context }) => {
12
+ await context.removeColumn('users', 'emailVerified');
13
+ await context.removeColumn('users', 'phoneVerified');
14
+ };
15
+ exports.down = down;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.down = exports.up = void 0;
4
+ const sequelize_1 = require("sequelize");
5
+ const up = async ({ context }) => {
6
+ await context.addColumn('passports', 'scope', { type: sequelize_1.DataTypes.ENUM('passport', 'kyc'), defaultValue: 'passport' });
7
+ await context.sequelize.query('UPDATE passports SET scope="passport"');
8
+ };
9
+ exports.up = up;
10
+ const down = async ({ context }) => {
11
+ await context.removeColumn('passports', 'scope');
12
+ };
13
+ exports.down = down;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.down = exports.up = void 0;
4
+ const sequelize_1 = require("sequelize");
5
+ const up = async ({ context }) => {
6
+ await context.addColumn('users', 'emailVerified', { type: sequelize_1.DataTypes.BOOLEAN, defaultValue: false });
7
+ await context.addColumn('users', 'phoneVerified', { type: sequelize_1.DataTypes.BOOLEAN, defaultValue: false });
8
+ await context.sequelize.query('UPDATE users SET emailVerified=false,phoneVerified=false');
9
+ };
10
+ exports.up = up;
11
+ const down = async ({ context }) => {
12
+ await context.removeColumn('users', 'emailVerified');
13
+ await context.removeColumn('users', 'phoneVerified');
14
+ };
15
+ exports.down = down;
@@ -28,6 +28,7 @@ export * from './traffic-insight';
28
28
  export * from './runtime-insight';
29
29
  export * from './tag';
30
30
  export * from './tagging';
31
+ export * from './verify-code';
31
32
  export declare function createSequelize(dbPath: string, config?: Record<string, any>): any;
32
33
  export declare function destroySequelize(dbPath: string): void;
33
34
  export declare function getServiceModels(): {
@@ -51,6 +52,7 @@ export declare function getBlockletModels(): {
51
52
  Project: import("../types").DynamicModel<import("./project").ProjectState>;
52
53
  Release: import("../types").DynamicModel<import("./release").ReleaseState>;
53
54
  Notification: import("../types").DynamicModel<import("@abtnode/types").TNotification>;
55
+ VerifyCode: import("../types").DynamicModel<import("./verify-code").VerifyCodeState>;
54
56
  };
55
57
  export declare function getServerModels(): {
56
58
  AccessKey: import("../types").DynamicModel<import("./access-key").AccessKeyState>;
@@ -54,6 +54,7 @@ const project_1 = require("./project");
54
54
  const release_1 = require("./release");
55
55
  const user_session_1 = require("./user-session");
56
56
  const connection_v2_1 = require("./connection-v2");
57
+ const verify_code_1 = require("./verify-code");
57
58
  __exportStar(require("./message"), exports);
58
59
  __exportStar(require("./account"), exports);
59
60
  __exportStar(require("./certificate"), exports);
@@ -82,6 +83,7 @@ __exportStar(require("./traffic-insight"), exports);
82
83
  __exportStar(require("./runtime-insight"), exports);
83
84
  __exportStar(require("./tag"), exports);
84
85
  __exportStar(require("./tagging"), exports);
86
+ __exportStar(require("./verify-code"), exports);
85
87
  const logEnabled = !process.env.DISABLE_SQLITE_LOG &&
86
88
  (process.env.DEBUG === '@abtnode/models' || ['production', 'test'].includes(process.env.NODE_ENV) === false);
87
89
  const instances = new Map();
@@ -139,6 +141,7 @@ function getBlockletModels() {
139
141
  Project: (0, project_1.createProjectModel)(),
140
142
  Release: (0, release_1.createReleaseModel)(),
141
143
  Notification: (0, notification_1.createNotificationModel)(),
144
+ VerifyCode: (0, verify_code_1.createVerifyCodeModel)(),
142
145
  };
143
146
  return models;
144
147
  }
@@ -1,8 +1,10 @@
1
1
  import { TPassport } from '@abtnode/types';
2
+ import type { LiteralUnion } from 'type-fest';
2
3
  import { DynamicModel } from '../types';
3
4
  export type PassportState = TPassport & {
4
5
  firstLoginAt: Date;
5
6
  lastLoginAt: Date;
6
7
  lastLoginIp: string;
8
+ scope: LiteralUnion<'passport' | 'kyc', string>;
7
9
  };
8
10
  export declare function createPassportModel(): DynamicModel<PassportState>;
@@ -8,6 +8,10 @@ function createPassportModel() {
8
8
  static initialize(sequelize) {
9
9
  this.init({
10
10
  ...this.GENESIS_ATTRIBUTES,
11
+ scope: {
12
+ type: sequelize_1.DataTypes.ENUM('passport', 'kyc'),
13
+ defaultValue: 'passport',
14
+ },
11
15
  }, {
12
16
  sequelize,
13
17
  modelName: 'Passport',
@@ -66,8 +70,10 @@ function createPassportModel() {
66
70
  index: true,
67
71
  defaultValue: 'valid',
68
72
  },
73
+ // used to store passport/kyc sub types: owner/admin/member/email/phone
69
74
  role: {
70
75
  type: sequelize_1.DataTypes.STRING(32),
76
+ allowNull: true,
71
77
  },
72
78
  firstLoginAt: {
73
79
  type: sequelize_1.DataTypes.DATE,
@@ -33,6 +33,14 @@ function createUserModel() {
33
33
  type: sequelize_1.DataTypes.SMALLINT,
34
34
  defaultValue: 0,
35
35
  },
36
+ emailVerified: {
37
+ type: sequelize_1.DataTypes.BOOLEAN,
38
+ defaultValue: false,
39
+ },
40
+ phoneVerified: {
41
+ type: sequelize_1.DataTypes.BOOLEAN,
42
+ defaultValue: false,
43
+ },
36
44
  }, {
37
45
  sequelize,
38
46
  modelName: 'User',
@@ -0,0 +1,18 @@
1
+ import type { LiteralUnion } from 'type-fest';
2
+ import { DynamicModel } from '../types';
3
+ export type VerifyCodeState = {
4
+ id: number;
5
+ code: string;
6
+ subject: string;
7
+ digest: string;
8
+ scope: LiteralUnion<'email' | 'phone', string>;
9
+ verified: boolean;
10
+ verifiedAt?: Date;
11
+ expired: boolean;
12
+ expiredAt?: Date;
13
+ sent: boolean;
14
+ sentAt?: Date;
15
+ createdAt: string;
16
+ updatedAt: string;
17
+ };
18
+ export declare function createVerifyCodeModel(): DynamicModel<VerifyCodeState>;
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createVerifyCodeModel = createVerifyCodeModel;
4
+ const sequelize_1 = require("sequelize");
5
+ function createVerifyCodeModel() {
6
+ var _a;
7
+ return _a = class VerifyCode extends sequelize_1.Model {
8
+ static initialize(sequelize) {
9
+ this.init({
10
+ ...this.GENESIS_ATTRIBUTES,
11
+ }, {
12
+ sequelize,
13
+ modelName: 'VerifyCode',
14
+ tableName: 'verify_codes',
15
+ timestamps: true,
16
+ });
17
+ }
18
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
19
+ static associate(models) { }
20
+ },
21
+ _a.GENESIS_ATTRIBUTES = {
22
+ id: {
23
+ type: sequelize_1.DataTypes.INTEGER,
24
+ autoIncrement: true,
25
+ primaryKey: true,
26
+ },
27
+ code: {
28
+ type: sequelize_1.DataTypes.STRING(8),
29
+ index: true,
30
+ unique: true,
31
+ allowNull: false,
32
+ },
33
+ subject: {
34
+ type: sequelize_1.DataTypes.STRING(255),
35
+ index: true,
36
+ allowNull: false,
37
+ },
38
+ digest: {
39
+ type: sequelize_1.DataTypes.STRING(32),
40
+ index: true,
41
+ allowNull: false,
42
+ },
43
+ scope: {
44
+ type: sequelize_1.DataTypes.ENUM('email', 'phone'),
45
+ allowNull: false,
46
+ },
47
+ verified: {
48
+ type: sequelize_1.DataTypes.BOOLEAN,
49
+ defaultValue: false,
50
+ },
51
+ verifiedAt: {
52
+ type: sequelize_1.DataTypes.DATE,
53
+ },
54
+ expired: {
55
+ type: sequelize_1.DataTypes.BOOLEAN,
56
+ defaultValue: false,
57
+ },
58
+ expiredAt: {
59
+ type: sequelize_1.DataTypes.DATE,
60
+ },
61
+ sent: {
62
+ type: sequelize_1.DataTypes.BOOLEAN,
63
+ defaultValue: false,
64
+ },
65
+ sentAt: {
66
+ type: sequelize_1.DataTypes.DATE,
67
+ },
68
+ createdAt: {
69
+ type: sequelize_1.DataTypes.DATE,
70
+ defaultValue: sequelize_1.DataTypes.NOW,
71
+ index: true,
72
+ },
73
+ updatedAt: {
74
+ type: sequelize_1.DataTypes.DATE,
75
+ defaultValue: sequelize_1.DataTypes.NOW,
76
+ index: true,
77
+ },
78
+ },
79
+ _a;
80
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abtnode/models",
3
- "version": "1.16.32-beta-4d47ae7f",
3
+ "version": "1.16.32-beta-17be26d7",
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,8 +33,8 @@
33
33
  "url": "https://github.com/ArcBlock/blocklet-server/issues"
34
34
  },
35
35
  "dependencies": {
36
- "@abtnode/logger": "1.16.32-beta-4d47ae7f",
37
- "@abtnode/types": "1.16.32-beta-4d47ae7f",
36
+ "@abtnode/logger": "1.16.32-beta-17be26d7",
37
+ "@abtnode/types": "1.16.32-beta-17be26d7",
38
38
  "lodash.clonedeep": "^4.5.0",
39
39
  "lodash.isempty": "^4.4.0",
40
40
  "sequelize": "^6.35.0",
@@ -54,5 +54,5 @@
54
54
  "typescript": "^5.0.4"
55
55
  },
56
56
  "resolutions": {},
57
- "gitHead": "740b8032aa02e19b888bf6a257840089696613ef"
57
+ "gitHead": "9fa42d5a545aea6d57d2e1c51849fe227c8acb5e"
58
58
  }