@abtnode/models 1.16.13-beta-d17a7de4 → 1.16.13-beta-90ded76f

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,12 @@
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('certificates', 'status', { type: sequelize_1.DataTypes.STRING });
7
+ };
8
+ exports.up = up;
9
+ const down = async ({ context }) => {
10
+ await context.removeColumn('certificates', 'status');
11
+ };
12
+ 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.getServerModels)();
6
+ const up = async ({ context }) => {
7
+ await context.createTable('traffic_insights', models.TrafficInsight.GENESIS_ATTRIBUTES);
8
+ await context.addIndex('traffic_insights', ['did', 'date'], { unique: true });
9
+ };
10
+ exports.up = up;
11
+ const down = async ({ context }) => {
12
+ await context.dropTable('traffic_insights');
13
+ };
14
+ exports.down = down;
@@ -1,6 +1,6 @@
1
1
  import { TCertificate } from '@abtnode/types';
2
2
  import { DynamicModel } from '../types';
3
- export type CertificateState = Omit<TCertificate, 'name' | 'matchedSites' | 'status'> & {
3
+ export type CertificateState = Omit<TCertificate, 'name' | 'matchedSites'> & {
4
4
  privateKey: string;
5
5
  public: boolean;
6
6
  };
@@ -10,6 +10,9 @@ function createCertificateModel() {
10
10
  static initialize(sequelize) {
11
11
  this.init({
12
12
  ...this.GENESIS_ATTRIBUTES,
13
+ status: {
14
+ type: sequelize_1.DataTypes.STRING,
15
+ },
13
16
  }, {
14
17
  sequelize,
15
18
  indexes: [{ fields: ['domain', 'id'] }],
@@ -21,6 +21,7 @@ export * from './site';
21
21
  export * from './webhook';
22
22
  export * from './connection';
23
23
  export * from './backup';
24
+ export * from './traffic-insight';
24
25
  export declare function createSequelize(dbPath: string, config?: Record<string, any>): any;
25
26
  export declare function destroySequelize(dbPath: string): void;
26
27
  export declare function getServiceModels(): {
@@ -57,6 +58,7 @@ export declare function getServerModels(): {
57
58
  ConnectedAccount: import("../types").DynamicModel<import("./connected-account").ConnectedAccountState>;
58
59
  WebHook: import("../types").DynamicModel<import("./webhook").WebHookState>;
59
60
  Backup: import("../types").DynamicModel<import("./backup").BackupState>;
61
+ TrafficInsight: import("../types").DynamicModel<import("./traffic-insight").TrafficInsightState>;
60
62
  };
61
63
  export declare function getConnectModels(): {
62
64
  Connection: import("../types").DynamicModel<import("./connection").ConnectionState>;
@@ -38,6 +38,7 @@ const site_1 = require("./site");
38
38
  const webhook_1 = require("./webhook");
39
39
  const connection_1 = require("./connection");
40
40
  const backup_1 = require("./backup");
41
+ const traffic_insight_1 = require("./traffic-insight");
41
42
  __exportStar(require("./message"), exports);
42
43
  __exportStar(require("./account"), exports);
43
44
  __exportStar(require("./certificate"), exports);
@@ -60,6 +61,7 @@ __exportStar(require("./site"), exports);
60
61
  __exportStar(require("./webhook"), exports);
61
62
  __exportStar(require("./connection"), exports);
62
63
  __exportStar(require("./backup"), exports);
64
+ __exportStar(require("./traffic-insight"), exports);
63
65
  const instances = new Map();
64
66
  function createSequelize(dbPath, config = {
65
67
  logging: !process.env.DISABLE_SQLITE_LOG &&
@@ -133,6 +135,7 @@ function getServerModels() {
133
135
  ConnectedAccount: (0, connected_account_1.createConnectedAccountModel)(),
134
136
  WebHook: (0, webhook_1.createWebHookModel)(),
135
137
  Backup: (0, backup_1.createBackupModel)(),
138
+ TrafficInsight: (0, traffic_insight_1.createTrafficInsightModel)(),
136
139
  };
137
140
  return models;
138
141
  }
@@ -0,0 +1,8 @@
1
+ import type { TTrafficInsight } from '@abtnode/types';
2
+ import { DynamicModel } from '../types';
3
+ export type TrafficInsightState = TTrafficInsight & {
4
+ id: string;
5
+ createdAt: Date;
6
+ updatedAt: Date;
7
+ };
8
+ export declare function createTrafficInsightModel(): DynamicModel<TrafficInsightState>;
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createTrafficInsightModel = void 0;
4
+ const sequelize_1 = require("sequelize");
5
+ const util_1 = require("../util");
6
+ function createTrafficInsightModel() {
7
+ var _a;
8
+ return _a = class TrafficInsight extends sequelize_1.Model {
9
+ static initialize(sequelize) {
10
+ this.init({
11
+ ...this.GENESIS_ATTRIBUTES,
12
+ }, {
13
+ sequelize,
14
+ modelName: 'TrafficInsight',
15
+ indexes: [{ fields: ['did', 'date'], unique: true }],
16
+ tableName: 'traffic_insights',
17
+ timestamps: true,
18
+ });
19
+ }
20
+ },
21
+ _a.GENESIS_ATTRIBUTES = {
22
+ id: {
23
+ type: sequelize_1.DataTypes.UUID,
24
+ primaryKey: true,
25
+ defaultValue: util_1.generateId,
26
+ },
27
+ did: {
28
+ type: sequelize_1.DataTypes.STRING(40),
29
+ allowNull: false,
30
+ },
31
+ date: {
32
+ type: sequelize_1.DataTypes.STRING(10),
33
+ allowNull: false,
34
+ index: true,
35
+ },
36
+ totalRequests: {
37
+ type: sequelize_1.DataTypes.INTEGER,
38
+ defaultValue: 0,
39
+ },
40
+ validRequests: {
41
+ type: sequelize_1.DataTypes.INTEGER,
42
+ defaultValue: 0,
43
+ },
44
+ failedRequests: {
45
+ type: sequelize_1.DataTypes.INTEGER,
46
+ defaultValue: 0,
47
+ },
48
+ generationTime: {
49
+ type: sequelize_1.DataTypes.INTEGER,
50
+ defaultValue: 0,
51
+ },
52
+ uniqueVisitors: {
53
+ type: sequelize_1.DataTypes.INTEGER,
54
+ defaultValue: 0,
55
+ },
56
+ uniqueFiles: {
57
+ type: sequelize_1.DataTypes.INTEGER,
58
+ defaultValue: 0,
59
+ },
60
+ excludedHits: {
61
+ type: sequelize_1.DataTypes.INTEGER,
62
+ defaultValue: 0,
63
+ },
64
+ uniqueReferrers: {
65
+ type: sequelize_1.DataTypes.INTEGER,
66
+ defaultValue: 0,
67
+ },
68
+ uniqueNotFound: {
69
+ type: sequelize_1.DataTypes.INTEGER,
70
+ defaultValue: 0,
71
+ },
72
+ uniqueStaticFiles: {
73
+ type: sequelize_1.DataTypes.INTEGER,
74
+ defaultValue: 0,
75
+ },
76
+ logSize: {
77
+ type: sequelize_1.DataTypes.INTEGER,
78
+ defaultValue: 0,
79
+ },
80
+ bandwidth: {
81
+ type: sequelize_1.DataTypes.INTEGER,
82
+ defaultValue: 0,
83
+ },
84
+ createdAt: {
85
+ type: sequelize_1.DataTypes.DATE,
86
+ defaultValue: sequelize_1.DataTypes.NOW,
87
+ index: true,
88
+ },
89
+ updatedAt: {
90
+ type: sequelize_1.DataTypes.DATE,
91
+ defaultValue: sequelize_1.DataTypes.NOW,
92
+ index: true,
93
+ },
94
+ },
95
+ _a;
96
+ }
97
+ exports.createTrafficInsightModel = createTrafficInsightModel;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abtnode/models",
3
- "version": "1.16.13-beta-d17a7de4",
3
+ "version": "1.16.13-beta-90ded76f",
4
4
  "description": "Sequelize models for blocklet server and blocklet service",
5
5
  "homepage": "https://github.com/ArcBlock/blocklet-server#readme",
6
6
  "publishConfig": {
@@ -32,8 +32,8 @@
32
32
  "url": "https://github.com/ArcBlock/blocklet-server/issues"
33
33
  },
34
34
  "dependencies": {
35
- "@abtnode/logger": "1.16.13-beta-d17a7de4",
36
- "@abtnode/types": "1.16.13-beta-d17a7de4",
35
+ "@abtnode/logger": "1.16.13-beta-90ded76f",
36
+ "@abtnode/types": "1.16.13-beta-90ded76f",
37
37
  "@nedb/core": "^2.1.5",
38
38
  "lodash.clonedeep": "^4.5.0",
39
39
  "lodash.get": "^4.4.2",
@@ -54,5 +54,5 @@
54
54
  "typescript": "^5.0.4"
55
55
  },
56
56
  "resolutions": {},
57
- "gitHead": "f14750f3b9feeafe80ee88499b2b4a061c2c28c4"
57
+ "gitHead": "e6d4b88fe2cb45e00e5d745e1cd148dc76a019a4"
58
58
  }