@itleanchatbot/shared-models-js-postgres 2.5.0 → 2.6.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itleanchatbot/shared-models-js-postgres",
3
- "version": "2.5.0",
3
+ "version": "2.6.0",
4
4
  "description": "Shared Models JS Postgres",
5
5
  "main": "index.js",
6
6
  "license": "ISC",
@@ -0,0 +1,66 @@
1
+ 'use strict';
2
+
3
+ module.exports = {
4
+ up: async (queryInterface, Sequelize) => {
5
+ await queryInterface.createTable('ApiPreRequests', {
6
+ id: {
7
+ allowNull: false,
8
+ defaultValue: Sequelize.literal('uuid_generate_v4()'),
9
+ primaryKey: true,
10
+ type: Sequelize.UUID,
11
+ },
12
+ ApiId: {
13
+ allowNull: true,
14
+ defaultValue: null,
15
+ type: Sequelize.UUID,
16
+ references: {
17
+ model: 'Apis',
18
+ key: 'id',
19
+ },
20
+ onDelete: 'SET NULL',
21
+ onUpdate: 'CASCADE',
22
+ },
23
+ ApiResourceId: {
24
+ allowNull: true,
25
+ defaultValue: null,
26
+ type: Sequelize.UUID,
27
+ references: {
28
+ model: 'ApiResources',
29
+ key: 'id',
30
+ },
31
+ onDelete: 'SET NULL',
32
+ onUpdate: 'CASCADE',
33
+ },
34
+ PreApiResourceId: {
35
+ allowNull: false,
36
+ type: Sequelize.UUID,
37
+ references: {
38
+ model: 'ApiResources',
39
+ key: 'id',
40
+ },
41
+ onDelete: 'SET NULL',
42
+ onUpdate: 'CASCADE',
43
+ },
44
+ result: {
45
+ allowNull: false,
46
+ type: Sequelize.STRING,
47
+ },
48
+ delayForNewRequest: {
49
+ allowNull: false,
50
+ type: Sequelize.STRING,
51
+ },
52
+ createdAt: {
53
+ allowNull: false,
54
+ type: Sequelize.DATE,
55
+ },
56
+ updatedAt: {
57
+ allowNull: false,
58
+ type: Sequelize.DATE,
59
+ },
60
+ })
61
+ },
62
+
63
+ down: async (queryInterface) => {
64
+ await queryInterface.dropTable('ApiPreRequests')
65
+ }
66
+ };
@@ -0,0 +1,56 @@
1
+
2
+ exports.model = (sequelize, Sequelize) => {
3
+ const ApiPreRequests = sequelize.define('ApiPreRequests', {
4
+ ApiId: {
5
+ allowNull: true,
6
+ defaultValue: null,
7
+ type: Sequelize.UUID,
8
+ references: {
9
+ model: 'Apis',
10
+ key: 'id',
11
+ },
12
+ onDelete: 'SET NULL',
13
+ onUpdate: 'CASCADE',
14
+ },
15
+ PreApiResourceId: {
16
+ allowNull: false,
17
+ type: Sequelize.UUID,
18
+ references: {
19
+ model: 'ApiResources',
20
+ key: 'id',
21
+ },
22
+ onDelete: 'SET NULL',
23
+ onUpdate: 'CASCADE',
24
+ },
25
+ ApiResourceId: {
26
+ allowNull: true,
27
+ defaultValue: null,
28
+ type: Sequelize.UUID,
29
+ references: {
30
+ model: 'ApiResources',
31
+ key: 'id',
32
+ },
33
+ onDelete: 'SET NULL',
34
+ onUpdate: 'CASCADE',
35
+ },
36
+ result: {
37
+ allowNull: false,
38
+ type: Sequelize.STRING,
39
+ },
40
+ delayForNewRequest: {
41
+ allowNull: false,
42
+ type: Sequelize.STRING,
43
+ },
44
+ })
45
+
46
+ ApiPreRequests.associate = (models) => {
47
+ ApiPreRequests.belongsTo(models.ApiResources)
48
+ ApiPreRequests.belongsTo(models.ApiResources, {
49
+ as: 'PreApiResource',
50
+ foreignKey: 'PreApiResourceId'
51
+ })
52
+ ApiPreRequests.belongsTo(models.Apis)
53
+ }
54
+
55
+ return ApiPreRequests
56
+ }
@@ -58,6 +58,11 @@ const ApiResourcesModel = (sequelize, Sequelize) => {
58
58
  ApiResources.associate = (models) => {
59
59
  ApiResources.belongsTo(models.Apis)
60
60
  ApiResources.belongsTo(models.ApiResourcesBodies)
61
+ ApiResources.hasMany(models.ApiPreRequests, {
62
+ as: 'PreApiResource',
63
+ foreignKey: 'PreApiResourceId'
64
+ })
65
+ ApiResources.hasMany(models.ApiPreRequests)
61
66
  ApiResources.hasMany(models.ApiResourcesHeaders)
62
67
  ApiResources.hasMany(models.ApiResourcesQueryStringParams)
63
68
  ApiResources.hasMany(models.ApiResourcesPathParams)
@@ -52,6 +52,7 @@ const API_AUTHENTICATIONS_TYPES = {
52
52
 
53
53
  Api.associate = (models) => {
54
54
  Api.hasMany(models.ApiResources)
55
+ Api.hasMany(models.ApiPreRequests)
55
56
  }
56
57
 
57
58
  return Api