@autofleet/sadot 1.6.18-beta.7 → 1.6.18-beta.9
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/api/v1/field-policies/index.cjs +4 -2
- package/dist/api/v1/field-policies/index.js +4 -2
- package/dist/migrations/005-add-entity-type-to-field-policies.cjs +20 -0
- package/dist/migrations/005-add-entity-type-to-field-policies.js +18 -0
- package/dist/migrations/index.cjs +6 -0
- package/dist/migrations/index.js +6 -0
- package/dist/models/FieldPolicy.cjs +4 -0
- package/dist/models/FieldPolicy.d.cts +3 -1
- package/dist/models/FieldPolicy.d.ts +3 -1
- package/dist/models/FieldPolicy.js +4 -0
- package/dist/models/index.d.ts +0 -4
- package/dist/repository/field-policy.cjs +2 -1
- package/dist/repository/field-policy.d.cts +4 -1
- package/dist/repository/field-policy.d.ts +4 -1
- package/dist/repository/field-policy.js +2 -1
- package/package.json +23 -23
- package/dist/models/tests/AssociatedTestModel.d.ts +0 -2
- package/dist/models/tests/TestModel.d.ts +0 -2
- package/dist/models/tests/contextAwareModels/ContextAwareTestModel.d.ts +0 -2
- package/dist/models/tests/contextAwareModels/ContextTestModel.d.ts +0 -1
|
@@ -19,7 +19,7 @@ router.get("/", async (_req, res) => {
|
|
|
19
19
|
}
|
|
20
20
|
});
|
|
21
21
|
router.post("/", async (req, res) => {
|
|
22
|
-
const { contextId, name, fields, models } = req.body;
|
|
22
|
+
const { contextId, name, entityType, fields, models } = req.body;
|
|
23
23
|
if (!contextId || !name) {
|
|
24
24
|
res.status(400).json({ error: "contextId and name are required" });
|
|
25
25
|
return;
|
|
@@ -28,6 +28,7 @@ router.post("/", async (req, res) => {
|
|
|
28
28
|
const policy = await require_field_policy.create({
|
|
29
29
|
contextId,
|
|
30
30
|
name,
|
|
31
|
+
entityType,
|
|
31
32
|
fields,
|
|
32
33
|
models
|
|
33
34
|
});
|
|
@@ -45,9 +46,10 @@ router.post("/", async (req, res) => {
|
|
|
45
46
|
});
|
|
46
47
|
router.put("/:policyId", async (req, res) => {
|
|
47
48
|
const { policyId } = req.params;
|
|
48
|
-
const { fields, models } = req.body;
|
|
49
|
+
const { entityType, fields, models } = req.body;
|
|
49
50
|
try {
|
|
50
51
|
const updated = await require_field_policy.update(policyId, {
|
|
52
|
+
entityType,
|
|
51
53
|
fields,
|
|
52
54
|
models
|
|
53
55
|
});
|
|
@@ -18,7 +18,7 @@ router.get("/", async (_req, res) => {
|
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
20
|
router.post("/", async (req, res) => {
|
|
21
|
-
const { contextId, name, fields, models } = req.body;
|
|
21
|
+
const { contextId, name, entityType, fields, models } = req.body;
|
|
22
22
|
if (!contextId || !name) {
|
|
23
23
|
res.status(400).json({ error: "contextId and name are required" });
|
|
24
24
|
return;
|
|
@@ -27,6 +27,7 @@ router.post("/", async (req, res) => {
|
|
|
27
27
|
const policy = await create({
|
|
28
28
|
contextId,
|
|
29
29
|
name,
|
|
30
|
+
entityType,
|
|
30
31
|
fields,
|
|
31
32
|
models
|
|
32
33
|
});
|
|
@@ -44,9 +45,10 @@ router.post("/", async (req, res) => {
|
|
|
44
45
|
});
|
|
45
46
|
router.put("/:policyId", async (req, res) => {
|
|
46
47
|
const { policyId } = req.params;
|
|
47
|
-
const { fields, models } = req.body;
|
|
48
|
+
const { entityType, fields, models } = req.body;
|
|
48
49
|
try {
|
|
49
50
|
const updated = await update(policyId, {
|
|
51
|
+
entityType,
|
|
50
52
|
fields,
|
|
51
53
|
models
|
|
52
54
|
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/migrations/005-add-entity-type-to-field-policies.ts
|
|
3
|
+
const up = async ({ context: queryInterface }) => {
|
|
4
|
+
const { sequelize } = queryInterface;
|
|
5
|
+
await sequelize.query(`
|
|
6
|
+
ALTER TABLE "field_policies"
|
|
7
|
+
ADD COLUMN IF NOT EXISTS "entity_type" VARCHAR
|
|
8
|
+
`);
|
|
9
|
+
};
|
|
10
|
+
const down = async ({ context: queryInterface }) => {
|
|
11
|
+
const { sequelize } = queryInterface;
|
|
12
|
+
await sequelize.query(`
|
|
13
|
+
ALTER TABLE "field_policies"
|
|
14
|
+
DROP COLUMN IF EXISTS "entity_type"
|
|
15
|
+
`);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
exports.down = down;
|
|
20
|
+
exports.up = up;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/migrations/005-add-entity-type-to-field-policies.ts
|
|
2
|
+
const up = async ({ context: queryInterface }) => {
|
|
3
|
+
const { sequelize } = queryInterface;
|
|
4
|
+
await sequelize.query(`
|
|
5
|
+
ALTER TABLE "field_policies"
|
|
6
|
+
ADD COLUMN IF NOT EXISTS "entity_type" VARCHAR
|
|
7
|
+
`);
|
|
8
|
+
};
|
|
9
|
+
const down = async ({ context: queryInterface }) => {
|
|
10
|
+
const { sequelize } = queryInterface;
|
|
11
|
+
await sequelize.query(`
|
|
12
|
+
ALTER TABLE "field_policies"
|
|
13
|
+
DROP COLUMN IF EXISTS "entity_type"
|
|
14
|
+
`);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { down, up };
|
|
@@ -3,6 +3,7 @@ const require_001_create_core_tables = require('./001-create-core-tables.cjs');
|
|
|
3
3
|
const require_002_create_custom_field_entries = require('./002-create-custom-field-entries.cjs');
|
|
4
4
|
const require_003_create_custom_field_model_type_map = require('./003-create-custom-field-model-type-map.cjs');
|
|
5
5
|
const require_004_create_field_policy_tables = require('./004-create-field-policy-tables.cjs');
|
|
6
|
+
const require_005_add_entity_type_to_field_policies = require('./005-add-entity-type-to-field-policies.cjs');
|
|
6
7
|
|
|
7
8
|
//#region src/migrations/index.ts
|
|
8
9
|
const { Umzug, SequelizeStorage } = require("umzug");
|
|
@@ -28,6 +29,11 @@ const buildMigrationList = (options) => {
|
|
|
28
29
|
name: "004-create-field-policy-tables",
|
|
29
30
|
up: require_004_create_field_policy_tables.up,
|
|
30
31
|
down: require_004_create_field_policy_tables.down
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: "005-add-entity-type-to-field-policies",
|
|
35
|
+
up: require_005_add_entity_type_to_field_policies.up,
|
|
36
|
+
down: require_005_add_entity_type_to_field_policies.down
|
|
31
37
|
}
|
|
32
38
|
];
|
|
33
39
|
};
|
package/dist/migrations/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { down, up } from "./001-create-core-tables.js";
|
|
|
4
4
|
import { down as down$1, up as up$1 } from "./002-create-custom-field-entries.js";
|
|
5
5
|
import { down as down$2, up as up$2 } from "./003-create-custom-field-model-type-map.js";
|
|
6
6
|
import { down as down$3, up as up$3 } from "./004-create-field-policy-tables.js";
|
|
7
|
+
import { down as down$4, up as up$4 } from "./005-add-entity-type-to-field-policies.js";
|
|
7
8
|
|
|
8
9
|
//#region src/migrations/index.ts
|
|
9
10
|
const { Umzug, SequelizeStorage } = __require("umzug");
|
|
@@ -29,6 +30,11 @@ const buildMigrationList = (options) => {
|
|
|
29
30
|
name: "004-create-field-policy-tables",
|
|
30
31
|
up: up$3,
|
|
31
32
|
down: down$3
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: "005-add-entity-type-to-field-policies",
|
|
36
|
+
up: up$4,
|
|
37
|
+
down: down$4
|
|
32
38
|
}
|
|
33
39
|
];
|
|
34
40
|
};
|
|
@@ -19,6 +19,10 @@ require_decorate.__decorate([(0, sequelize_typescript.Column)({
|
|
|
19
19
|
type: sequelize_typescript.DataType.UUID,
|
|
20
20
|
allowNull: false
|
|
21
21
|
}), require_decorateMetadata.__decorateMetadata("design:type", String)], FieldPolicy.prototype, "contextId", void 0);
|
|
22
|
+
require_decorate.__decorate([(0, sequelize_typescript.Column)({
|
|
23
|
+
type: sequelize_typescript.DataType.STRING,
|
|
24
|
+
allowNull: true
|
|
25
|
+
}), require_decorateMetadata.__decorateMetadata("design:type", Object)], FieldPolicy.prototype, "entityType", void 0);
|
|
22
26
|
require_decorate.__decorate([(0, sequelize_typescript.Column)({
|
|
23
27
|
type: sequelize_typescript.DataType.STRING,
|
|
24
28
|
allowNull: false
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Model } from "sequelize-typescript";
|
|
2
2
|
|
|
3
3
|
//#region src/models/FieldPolicy.d.ts
|
|
4
|
+
type EntityType = "vehicle" | "driver";
|
|
4
5
|
type ModelMode = "full" | "partial";
|
|
5
6
|
type ModelInclusion = {
|
|
6
7
|
name: string;
|
|
@@ -13,6 +14,7 @@ type ModelInclusion = {
|
|
|
13
14
|
declare class FieldPolicy extends Model {
|
|
14
15
|
id: string;
|
|
15
16
|
contextId: string;
|
|
17
|
+
entityType: EntityType | null;
|
|
16
18
|
name: string;
|
|
17
19
|
/** Base-level field names to include */
|
|
18
20
|
fields: string[];
|
|
@@ -20,4 +22,4 @@ declare class FieldPolicy extends Model {
|
|
|
20
22
|
models: ModelInclusion[];
|
|
21
23
|
}
|
|
22
24
|
//#endregion
|
|
23
|
-
export { FieldPolicy, ModelInclusion, ModelMode };
|
|
25
|
+
export { EntityType, FieldPolicy, ModelInclusion, ModelMode };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Model } from "sequelize-typescript";
|
|
2
2
|
|
|
3
3
|
//#region src/models/FieldPolicy.d.ts
|
|
4
|
+
type EntityType = "vehicle" | "driver";
|
|
4
5
|
type ModelMode = "full" | "partial";
|
|
5
6
|
type ModelInclusion = {
|
|
6
7
|
name: string;
|
|
@@ -13,6 +14,7 @@ type ModelInclusion = {
|
|
|
13
14
|
declare class FieldPolicy extends Model {
|
|
14
15
|
id: string;
|
|
15
16
|
contextId: string;
|
|
17
|
+
entityType: EntityType | null;
|
|
16
18
|
name: string;
|
|
17
19
|
/** Base-level field names to include */
|
|
18
20
|
fields: string[];
|
|
@@ -20,4 +22,4 @@ declare class FieldPolicy extends Model {
|
|
|
20
22
|
models: ModelInclusion[];
|
|
21
23
|
}
|
|
22
24
|
//#endregion
|
|
23
|
-
export { FieldPolicy, ModelInclusion, ModelMode };
|
|
25
|
+
export { EntityType, FieldPolicy, ModelInclusion, ModelMode };
|
|
@@ -18,6 +18,10 @@ __decorate([Column({
|
|
|
18
18
|
type: DataType.UUID,
|
|
19
19
|
allowNull: false
|
|
20
20
|
}), __decorateMetadata("design:type", String)], FieldPolicy.prototype, "contextId", void 0);
|
|
21
|
+
__decorate([Column({
|
|
22
|
+
type: DataType.STRING,
|
|
23
|
+
allowNull: true
|
|
24
|
+
}), __decorateMetadata("design:type", Object)], FieldPolicy.prototype, "entityType", void 0);
|
|
21
25
|
__decorate([Column({
|
|
22
26
|
type: DataType.STRING,
|
|
23
27
|
allowNull: false
|
package/dist/models/index.d.ts
CHANGED
|
@@ -3,9 +3,5 @@ import { CustomFieldModelTypeMap } from "./CustomFieldModelTypeMap.js";
|
|
|
3
3
|
import { CustomFieldDefinition } from "./CustomFieldDefinition.js";
|
|
4
4
|
import { CustomValidator } from "./CustomValidator.js";
|
|
5
5
|
import "../types/index.js";
|
|
6
|
-
import "./tests/AssociatedTestModel.js";
|
|
7
|
-
import "./tests/TestModel.js";
|
|
8
|
-
import "./tests/contextAwareModels/ContextTestModel.js";
|
|
9
|
-
import "./tests/contextAwareModels/ContextAwareTestModel.js";
|
|
10
6
|
import { CustomFieldEntries } from "./CustomFieldEntries.js";
|
|
11
7
|
import { Sequelize } from "sequelize-typescript";
|
|
@@ -20,9 +20,10 @@ const findById = (id) => require_FieldPolicy.default.findByPk(id);
|
|
|
20
20
|
const findAllByContext = (contextId) => require_FieldPolicy.default.findAll({ where: { contextId } });
|
|
21
21
|
const findAll = () => require_FieldPolicy.default.findAll();
|
|
22
22
|
const findAllByContextIds = (contextIds) => require_FieldPolicy.default.findAll({ where: { contextId: contextIds } });
|
|
23
|
-
const create = ({ contextId, name, fields, models }) => require_FieldPolicy.default.create({
|
|
23
|
+
const create = ({ contextId, name, entityType, fields, models }) => require_FieldPolicy.default.create({
|
|
24
24
|
contextId,
|
|
25
25
|
name,
|
|
26
|
+
entityType,
|
|
26
27
|
fields,
|
|
27
28
|
models
|
|
28
29
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FieldPolicy, ModelInclusion } from "../models/FieldPolicy.cjs";
|
|
1
|
+
import { EntityType, FieldPolicy, ModelInclusion } from "../models/FieldPolicy.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/repository/field-policy.d.ts
|
|
4
4
|
declare namespace field_policy_d_exports {
|
|
@@ -7,10 +7,12 @@ declare namespace field_policy_d_exports {
|
|
|
7
7
|
interface CreateFieldPolicyData {
|
|
8
8
|
contextId: string;
|
|
9
9
|
name: string;
|
|
10
|
+
entityType?: EntityType;
|
|
10
11
|
fields?: string[];
|
|
11
12
|
models?: ModelInclusion[];
|
|
12
13
|
}
|
|
13
14
|
interface UpdateFieldPolicyData {
|
|
15
|
+
entityType?: EntityType;
|
|
14
16
|
fields?: string[];
|
|
15
17
|
models?: ModelInclusion[];
|
|
16
18
|
}
|
|
@@ -22,6 +24,7 @@ declare const findAllByContextIds: (contextIds: string[]) => Promise<FieldPolicy
|
|
|
22
24
|
declare const create: ({
|
|
23
25
|
contextId,
|
|
24
26
|
name,
|
|
27
|
+
entityType,
|
|
25
28
|
fields,
|
|
26
29
|
models
|
|
27
30
|
}: CreateFieldPolicyData) => Promise<FieldPolicy>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FieldPolicy, ModelInclusion } from "../models/FieldPolicy.js";
|
|
1
|
+
import { EntityType, FieldPolicy, ModelInclusion } from "../models/FieldPolicy.js";
|
|
2
2
|
|
|
3
3
|
//#region src/repository/field-policy.d.ts
|
|
4
4
|
declare namespace field_policy_d_exports {
|
|
@@ -7,10 +7,12 @@ declare namespace field_policy_d_exports {
|
|
|
7
7
|
interface CreateFieldPolicyData {
|
|
8
8
|
contextId: string;
|
|
9
9
|
name: string;
|
|
10
|
+
entityType?: EntityType;
|
|
10
11
|
fields?: string[];
|
|
11
12
|
models?: ModelInclusion[];
|
|
12
13
|
}
|
|
13
14
|
interface UpdateFieldPolicyData {
|
|
15
|
+
entityType?: EntityType;
|
|
14
16
|
fields?: string[];
|
|
15
17
|
models?: ModelInclusion[];
|
|
16
18
|
}
|
|
@@ -22,6 +24,7 @@ declare const findAllByContextIds: (contextIds: string[]) => Promise<FieldPolicy
|
|
|
22
24
|
declare const create: ({
|
|
23
25
|
contextId,
|
|
24
26
|
name,
|
|
27
|
+
entityType,
|
|
25
28
|
fields,
|
|
26
29
|
models
|
|
27
30
|
}: CreateFieldPolicyData) => Promise<FieldPolicy>;
|
|
@@ -20,9 +20,10 @@ const findById = (id) => FieldPolicy_default.findByPk(id);
|
|
|
20
20
|
const findAllByContext = (contextId) => FieldPolicy_default.findAll({ where: { contextId } });
|
|
21
21
|
const findAll = () => FieldPolicy_default.findAll();
|
|
22
22
|
const findAllByContextIds = (contextIds) => FieldPolicy_default.findAll({ where: { contextId: contextIds } });
|
|
23
|
-
const create = ({ contextId, name, fields, models }) => FieldPolicy_default.create({
|
|
23
|
+
const create = ({ contextId, name, entityType, fields, models }) => FieldPolicy_default.create({
|
|
24
24
|
contextId,
|
|
25
25
|
name,
|
|
26
|
+
entityType,
|
|
26
27
|
fields,
|
|
27
28
|
models
|
|
28
29
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autofleet/sadot",
|
|
3
|
-
"version": "1.6.18-beta.
|
|
3
|
+
"version": "1.6.18-beta.9",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -22,6 +22,15 @@
|
|
|
22
22
|
"dist",
|
|
23
23
|
"README.md"
|
|
24
24
|
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "pnpm -w tsdown -W ./packages/sadot",
|
|
27
|
+
"linter": "eslint .",
|
|
28
|
+
"test": "vitest",
|
|
29
|
+
"test-debug": "node --inspect-brk node_modules/.bin/vitest --testTimeout=10000000",
|
|
30
|
+
"coverage": "vitest --coverage",
|
|
31
|
+
"build-to-local-repo": "node --run build && cp -r dist/* ../$REPO/node_modules/$npm_package_name/dist",
|
|
32
|
+
"watch": "npm-watch build-to-local-repo"
|
|
33
|
+
},
|
|
25
34
|
"watch": {
|
|
26
35
|
"build-to-local-repo": {
|
|
27
36
|
"extensions": [
|
|
@@ -35,28 +44,28 @@
|
|
|
35
44
|
}
|
|
36
45
|
},
|
|
37
46
|
"dependencies": {
|
|
38
|
-
"@autofleet/common-types": "
|
|
47
|
+
"@autofleet/common-types": "catalog:",
|
|
48
|
+
"@autofleet/events": "workspace:^",
|
|
39
49
|
"ajv": "^8.12.0",
|
|
40
50
|
"ajv-errors": "^3.0.0",
|
|
41
51
|
"ajv-formats": "^3.0.1",
|
|
42
52
|
"http-status-codes": "^2.3.0",
|
|
43
53
|
"joi": "^17.7.0",
|
|
44
|
-
"pg": "
|
|
54
|
+
"pg": "catalog:",
|
|
45
55
|
"reflect-metadata": "^0.1.13",
|
|
46
|
-
"sequelize": "
|
|
47
|
-
"sequelize-typescript": "
|
|
48
|
-
"umzug": "^3.8.3"
|
|
49
|
-
"@autofleet/events": "^5.3.22"
|
|
56
|
+
"sequelize": "catalog:",
|
|
57
|
+
"sequelize-typescript": "catalog:",
|
|
58
|
+
"umzug": "^3.8.3"
|
|
50
59
|
},
|
|
51
60
|
"devDependencies": {
|
|
61
|
+
"@autofleet/errors": "workspace:^",
|
|
62
|
+
"@autofleet/logger": "workspace:^",
|
|
63
|
+
"@autofleet/node-common": "workspace:^",
|
|
64
|
+
"@autofleet/zehut": "workspace:^",
|
|
52
65
|
"@types/express": "^4.17.17",
|
|
53
66
|
"express": "^4.21.2",
|
|
54
67
|
"npm-watch": "^0.11.0",
|
|
55
|
-
"supertest": "^7.0.0"
|
|
56
|
-
"@autofleet/logger": "^4.7.0",
|
|
57
|
-
"@autofleet/errors": "^3.3.7",
|
|
58
|
-
"@autofleet/node-common": "^4.3.22",
|
|
59
|
-
"@autofleet/zehut": "^4.13.3"
|
|
68
|
+
"supertest": "^7.0.0"
|
|
60
69
|
},
|
|
61
70
|
"peerDependencies": {
|
|
62
71
|
"@autofleet/errors": "^3",
|
|
@@ -69,14 +78,5 @@
|
|
|
69
78
|
"node": ">=18.0.0"
|
|
70
79
|
},
|
|
71
80
|
"author": "Autofleet",
|
|
72
|
-
"license": "ISC"
|
|
73
|
-
|
|
74
|
-
"build": "pnpm -w tsdown -W ./packages/sadot",
|
|
75
|
-
"linter": "eslint .",
|
|
76
|
-
"test": "vitest",
|
|
77
|
-
"test-debug": "node --inspect-brk node_modules/.bin/vitest --testTimeout=10000000",
|
|
78
|
-
"coverage": "vitest --coverage",
|
|
79
|
-
"build-to-local-repo": "node --run build && cp -r dist/* ../$REPO/node_modules/$npm_package_name/dist",
|
|
80
|
-
"watch": "npm-watch build-to-local-repo"
|
|
81
|
-
}
|
|
82
|
-
}
|
|
81
|
+
"license": "ISC"
|
|
82
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import { Model } from "sequelize-typescript";
|