@autofleet/sadot 0.3.0-beta.9 → 0.3.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/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/models/index.js +22 -28
- package/dist/models/index.js.map +1 -1
- package/dist/repository/value.js +6 -13
- package/dist/repository/value.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/db/index.js +8 -0
- package/dist/utils/db/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +3 -1
- package/src/models/index.ts +27 -33
- package/src/repository/value.ts +0 -8
- package/src/utils/db/index.ts +7 -0
- package/coverage/clover.xml +0 -811
- package/coverage/coverage-final.json +0 -35
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -341
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -196
- package/coverage/lcov-report/src/api/index.html +0 -116
- package/coverage/lcov-report/src/api/index.ts.html +0 -112
- package/coverage/lcov-report/src/api/v1/definition/index.html +0 -131
- package/coverage/lcov-report/src/api/v1/definition/index.ts.html +0 -394
- package/coverage/lcov-report/src/api/v1/definition/validations.ts.html +0 -190
- package/coverage/lcov-report/src/api/v1/errors.ts.html +0 -133
- package/coverage/lcov-report/src/api/v1/index.html +0 -131
- package/coverage/lcov-report/src/api/v1/index.ts.html +0 -112
- package/coverage/lcov-report/src/errors/index.html +0 -116
- package/coverage/lcov-report/src/errors/index.ts.html +0 -211
- package/coverage/lcov-report/src/events/index.html +0 -116
- package/coverage/lcov-report/src/events/index.ts.html +0 -235
- package/coverage/lcov-report/src/hooks/create.ts.html +0 -238
- package/coverage/lcov-report/src/hooks/enrich.ts.html +0 -442
- package/coverage/lcov-report/src/hooks/find.ts.html +0 -166
- package/coverage/lcov-report/src/hooks/index.html +0 -191
- package/coverage/lcov-report/src/hooks/index.ts.html +0 -130
- package/coverage/lcov-report/src/hooks/update.ts.html +0 -202
- package/coverage/lcov-report/src/hooks/workaround.ts.html +0 -226
- package/coverage/lcov-report/src/index.html +0 -116
- package/coverage/lcov-report/src/index.ts.html +0 -382
- package/coverage/lcov-report/src/models/CustomFieldDefinition.ts.html +0 -505
- package/coverage/lcov-report/src/models/CustomFieldValue.ts.html +0 -427
- package/coverage/lcov-report/src/models/index.html +0 -146
- package/coverage/lcov-report/src/models/index.ts.html +0 -289
- package/coverage/lcov-report/src/models/tests/AssociatedTestModel.ts.html +0 -256
- package/coverage/lcov-report/src/models/tests/TestModel.ts.html +0 -232
- package/coverage/lcov-report/src/models/tests/index.html +0 -131
- package/coverage/lcov-report/src/repository/definition.ts.html +0 -418
- package/coverage/lcov-report/src/repository/index.html +0 -131
- package/coverage/lcov-report/src/repository/value.ts.html +0 -406
- package/coverage/lcov-report/src/tests/api/index.html +0 -116
- package/coverage/lcov-report/src/tests/api/test-api.ts.html +0 -199
- package/coverage/lcov-report/src/tests/helpers/database-config.ts.html +0 -127
- package/coverage/lcov-report/src/tests/helpers/index.html +0 -131
- package/coverage/lcov-report/src/tests/helpers/index.ts.html +0 -130
- package/coverage/lcov-report/src/tests/mocks/definition.mock.ts.html +0 -292
- package/coverage/lcov-report/src/tests/mocks/events.mock.ts.html +0 -139
- package/coverage/lcov-report/src/tests/mocks/index.html +0 -146
- package/coverage/lcov-report/src/tests/mocks/testModel.ts.html +0 -196
- package/coverage/lcov-report/src/utils/db/index.html +0 -116
- package/coverage/lcov-report/src/utils/db/index.ts.html +0 -127
- package/coverage/lcov-report/src/utils/logger/index.html +0 -116
- package/coverage/lcov-report/src/utils/logger/index.ts.html +0 -103
- package/coverage/lcov-report/src/utils/validations/custom-fields.ts.html +0 -112
- package/coverage/lcov-report/src/utils/validations/custom.ts.html +0 -202
- package/coverage/lcov-report/src/utils/validations/index.html +0 -176
- package/coverage/lcov-report/src/utils/validations/index.ts.html +0 -142
- package/coverage/lcov-report/src/utils/validations/type.ts.html +0 -220
- package/coverage/lcov-report/src/utils/validations/validators.ts.html +0 -187
- package/coverage/lcov.info +0 -1577
package/src/models/index.ts
CHANGED
|
@@ -41,41 +41,35 @@ const initTables = async (sequelize: Sequelize, getUser): Promise<void> => {
|
|
|
41
41
|
|
|
42
42
|
logger.info('custom-fields: models added');
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
{
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
autoIncrement: false,
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
tableName: 'SequelizeMeta',
|
|
58
|
-
timestamps: false,
|
|
59
|
-
schema: 'public',
|
|
44
|
+
const SequelizeMeta = sequelize.define(
|
|
45
|
+
'SequelizeMeta',
|
|
46
|
+
{
|
|
47
|
+
name: {
|
|
48
|
+
type: DataTypes.STRING,
|
|
49
|
+
allowNull: false,
|
|
50
|
+
unique: true,
|
|
51
|
+
primaryKey: true,
|
|
52
|
+
autoIncrement: false,
|
|
60
53
|
},
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
tableName: 'SequelizeMeta',
|
|
57
|
+
timestamps: false,
|
|
58
|
+
schema: 'public',
|
|
59
|
+
},
|
|
60
|
+
);
|
|
61
|
+
const migrations = await SequelizeMeta.findAll({ raw: true });
|
|
62
|
+
const currentSadotSchemaVersion = migrations
|
|
63
|
+
.reverse().find((m: any) => m.name.includes(SADOT_MIGRATION_PREFIX));
|
|
65
64
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
await CustomFieldValue.sync({ alter: true });
|
|
75
|
-
logger.info('custom-fields: models synced');
|
|
76
|
-
}
|
|
77
|
-
} catch (err) {
|
|
78
|
-
console.log('ANKRI ERROR', err);
|
|
65
|
+
if (
|
|
66
|
+
!currentSadotSchemaVersion
|
|
67
|
+
|| (currentSadotSchemaVersion as any).name !== CUSTOM_FIELDS_SCHEMA_VERSION
|
|
68
|
+
) {
|
|
69
|
+
await CustomFieldDefinition.sync({ alter: true });
|
|
70
|
+
await CustomFieldValue.sync({ alter: true });
|
|
71
|
+
await SequelizeMeta.create({ name: CUSTOM_FIELDS_SCHEMA_VERSION });
|
|
72
|
+
logger.info('custom-fields: models synced');
|
|
79
73
|
}
|
|
80
74
|
};
|
|
81
75
|
|
package/src/repository/value.ts
CHANGED
|
@@ -79,20 +79,12 @@ export const updateValues = async (
|
|
|
79
79
|
customFieldDefinitionId: fieldDefinitions.find((def) => def.name === name).id,
|
|
80
80
|
}));
|
|
81
81
|
|
|
82
|
-
return CustomFieldValue.bulkCreate(values, {
|
|
83
|
-
fields: ['modelId', 'value', 'updatedAt', 'customFieldDefinitionId'],
|
|
84
|
-
updateOnDuplicate: ['value', 'updatedAt'],
|
|
85
|
-
transaction: options.transaction,
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
/*
|
|
89
82
|
return Promise.all(values.map(async (value) => {
|
|
90
83
|
const [cfv] = await CustomFieldValue.upsert(value, {
|
|
91
84
|
transaction: options.transaction,
|
|
92
85
|
});
|
|
93
86
|
return cfv;
|
|
94
87
|
}));
|
|
95
|
-
*/
|
|
96
88
|
};
|
|
97
89
|
|
|
98
90
|
export const deleteValue = (
|
package/src/utils/db/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Sequelize } from 'sequelize-typescript';
|
|
2
|
+
import { QueryTypes } from 'sequelize';
|
|
2
3
|
|
|
3
4
|
export default (databaseConfig: any): Sequelize => {
|
|
4
5
|
const ENV_DEV = 'test';
|
|
@@ -12,3 +13,9 @@ export default (databaseConfig: any): Sequelize => {
|
|
|
12
13
|
}
|
|
13
14
|
return sequelize;
|
|
14
15
|
};
|
|
16
|
+
|
|
17
|
+
export const createSequelizeMeta = (sequelize: Sequelize) => sequelize.query(`
|
|
18
|
+
CREATE TABLE IF NOT EXISTS "SequelizeMeta" (
|
|
19
|
+
name character varying(255) PRIMARY KEY
|
|
20
|
+
);
|
|
21
|
+
`, { type: QueryTypes.SELECT });
|