@autofleet/sadot 1.6.18-beta.21 → 1.6.18-beta.22
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 +1 -13
- package/dist/api/v1/field-policies/index.js +2 -14
- package/dist/api/v1/validator/index.cjs +1 -1
- package/dist/api/v1/validator/index.js +1 -1
- package/dist/models/index.d.ts +0 -4
- package/dist/repository/field-policy.cjs +0 -22
- package/dist/repository/field-policy.d.cts +1 -2
- package/dist/repository/field-policy.d.ts +1 -2
- package/dist/repository/field-policy.js +1 -22
- package/dist/repository/validator.cjs +2 -1
- package/dist/repository/validator.js +2 -1
- package/package.json +3 -3
- 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
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_index = require('../../../utils/logger/index.cjs');
|
|
3
3
|
const require_errors = require('../errors.cjs');
|
|
4
|
-
const require_mat_path_state = require('../../../mat-path-state.cjs');
|
|
5
4
|
const require_field_policy = require('../../../repository/field-policy.cjs');
|
|
6
5
|
let sequelize = require("sequelize");
|
|
7
6
|
let _autofleet_node_common = require("@autofleet/node-common");
|
|
@@ -12,18 +11,7 @@ const router = (0, _autofleet_node_common.Router)({
|
|
|
12
11
|
mergeParams: true
|
|
13
12
|
});
|
|
14
13
|
router.get("/effective", async (req, res) => {
|
|
15
|
-
|
|
16
|
-
if (!withMatPath) return res.status(501).json({ error: "Effective field policy resolution is not configured" });
|
|
17
|
-
const entityType = req.params.entityType;
|
|
18
|
-
try {
|
|
19
|
-
const [policy] = await require_field_policy.findEffectivePolicy(entityType);
|
|
20
|
-
return res.status(200).json(policy ?? null);
|
|
21
|
-
} catch (err) {
|
|
22
|
-
return require_errors.default(err, res, {
|
|
23
|
-
logger: require_index.default,
|
|
24
|
-
message: "Error resolving effective field policy"
|
|
25
|
-
});
|
|
26
|
-
}
|
|
14
|
+
return res.status(200);
|
|
27
15
|
});
|
|
28
16
|
router.get("/", async (_req, res) => {
|
|
29
17
|
try {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import logger_default from "../../../utils/logger/index.js";
|
|
2
2
|
import errors_default from "../errors.js";
|
|
3
|
-
import {
|
|
4
|
-
import { create, findAll, findEffectivePolicy, remove, update } from "../../../repository/field-policy.js";
|
|
3
|
+
import { create, findAll, remove, update } from "../../../repository/field-policy.js";
|
|
5
4
|
import { UniqueConstraintError } from "sequelize";
|
|
6
5
|
import { Router } from "@autofleet/node-common";
|
|
7
6
|
|
|
@@ -11,18 +10,7 @@ const router = Router({
|
|
|
11
10
|
mergeParams: true
|
|
12
11
|
});
|
|
13
12
|
router.get("/effective", async (req, res) => {
|
|
14
|
-
|
|
15
|
-
if (!withMatPath) return res.status(501).json({ error: "Effective field policy resolution is not configured" });
|
|
16
|
-
const entityType = req.params.entityType;
|
|
17
|
-
try {
|
|
18
|
-
const [policy] = await findEffectivePolicy(entityType);
|
|
19
|
-
return res.status(200).json(policy ?? null);
|
|
20
|
-
} catch (err) {
|
|
21
|
-
return errors_default(err, res, {
|
|
22
|
-
logger: logger_default,
|
|
23
|
-
message: "Error resolving effective field policy"
|
|
24
|
-
});
|
|
25
|
-
}
|
|
13
|
+
return res.status(200);
|
|
26
14
|
});
|
|
27
15
|
router.get("/", async (_req, res) => {
|
|
28
16
|
try {
|
|
@@ -62,7 +62,7 @@ router.get("/effective", async (req, res) => {
|
|
|
62
62
|
if (!withMatPath) return res.status(http_status_codes.StatusCodes.NOT_IMPLEMENTED).json({ error: "Effective validator resolution is not configured" });
|
|
63
63
|
try {
|
|
64
64
|
const { modelName } = req.params;
|
|
65
|
-
const [validator] = await require_validator.findEffective(modelName);
|
|
65
|
+
const [validator] = await require_validator.findEffective(modelName, "AF.1");
|
|
66
66
|
return res.status(http_status_codes.StatusCodes.OK).json(validator ?? null);
|
|
67
67
|
} catch (err) {
|
|
68
68
|
return require_errors.default(err, res, {
|
|
@@ -61,7 +61,7 @@ router.get("/effective", async (req, res) => {
|
|
|
61
61
|
if (!withMatPath) return res.status(StatusCodes.NOT_IMPLEMENTED).json({ error: "Effective validator resolution is not configured" });
|
|
62
62
|
try {
|
|
63
63
|
const { modelName } = req.params;
|
|
64
|
-
const [validator] = await findEffective(modelName);
|
|
64
|
+
const [validator] = await findEffective(modelName, "AF.1");
|
|
65
65
|
return res.status(StatusCodes.OK).json(validator ?? null);
|
|
66
66
|
} catch (err) {
|
|
67
67
|
return errors_default(err, res, {
|
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";
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const require_mat_path_state = require('../mat-path-state.cjs');
|
|
3
2
|
const require_FieldPolicy = require('../models/FieldPolicy.cjs');
|
|
4
|
-
let sequelize = require("sequelize");
|
|
5
3
|
|
|
6
4
|
//#region src/repository/field-policy.ts
|
|
7
5
|
var field_policy_exports = /* @__PURE__ */ require_rolldown_runtime.__export({
|
|
@@ -11,7 +9,6 @@ var field_policy_exports = /* @__PURE__ */ require_rolldown_runtime.__export({
|
|
|
11
9
|
findAllByContextIds: () => findAllByContextIds,
|
|
12
10
|
findByContextAndName: () => findByContextAndName,
|
|
13
11
|
findById: () => findById,
|
|
14
|
-
findEffectivePolicy: () => findEffectivePolicy,
|
|
15
12
|
remove: () => remove,
|
|
16
13
|
update: () => update
|
|
17
14
|
});
|
|
@@ -36,24 +33,6 @@ const update = async (id, data) => {
|
|
|
36
33
|
return policy.update(data);
|
|
37
34
|
};
|
|
38
35
|
const remove = (id) => require_FieldPolicy.default.destroy({ where: { id } });
|
|
39
|
-
const findEffectivePolicy = (entityType) => {
|
|
40
|
-
const tableName = require_FieldPolicy.default.getTableName();
|
|
41
|
-
const EFFECTIVE_POLICY_QUERY = `
|
|
42
|
-
SELECT fp.*
|
|
43
|
-
FROM "${tableName}" fp
|
|
44
|
-
LEFT JOIN context_entity_path cep ON cep.deleted_at IS NULL
|
|
45
|
-
AND cep.entity_id = fp.context_id
|
|
46
|
-
AND cep.entity_type = 'context'
|
|
47
|
-
AND cep.path @> ANY(current_setting('mat_path.paths', true)::ltree[])
|
|
48
|
-
WHERE fp.entity_type = $1
|
|
49
|
-
ORDER BY COALESCE(nlevel(cep.path), 0) DESC
|
|
50
|
-
LIMIT 1`;
|
|
51
|
-
return require_mat_path_state.matPathState.withMatPath(tableName, (transaction) => require_FieldPolicy.default.sequelize.query(EFFECTIVE_POLICY_QUERY, {
|
|
52
|
-
bind: [entityType],
|
|
53
|
-
type: sequelize.QueryTypes.SELECT,
|
|
54
|
-
transaction
|
|
55
|
-
}));
|
|
56
|
-
};
|
|
57
36
|
|
|
58
37
|
//#endregion
|
|
59
38
|
exports.create = create;
|
|
@@ -64,6 +43,5 @@ Object.defineProperty(exports, 'field_policy_exports', {
|
|
|
64
43
|
}
|
|
65
44
|
});
|
|
66
45
|
exports.findAll = findAll;
|
|
67
|
-
exports.findEffectivePolicy = findEffectivePolicy;
|
|
68
46
|
exports.remove = remove;
|
|
69
47
|
exports.update = update;
|
|
@@ -2,7 +2,7 @@ import { EntityType, FieldPolicy, ModelInclusion } from "../models/FieldPolicy.c
|
|
|
2
2
|
|
|
3
3
|
//#region src/repository/field-policy.d.ts
|
|
4
4
|
declare namespace field_policy_d_exports {
|
|
5
|
-
export { CreateFieldPolicyData, UpdateFieldPolicyData, create, findAll, findAllByContext, findAllByContextIds, findByContextAndName, findById,
|
|
5
|
+
export { CreateFieldPolicyData, UpdateFieldPolicyData, create, findAll, findAllByContext, findAllByContextIds, findByContextAndName, findById, remove, update };
|
|
6
6
|
}
|
|
7
7
|
interface CreateFieldPolicyData {
|
|
8
8
|
contextId: string;
|
|
@@ -30,6 +30,5 @@ declare const create: ({
|
|
|
30
30
|
}: CreateFieldPolicyData) => Promise<FieldPolicy>;
|
|
31
31
|
declare const update: (id: string, data: UpdateFieldPolicyData) => Promise<FieldPolicy | null>;
|
|
32
32
|
declare const remove: (id: string) => Promise<number>;
|
|
33
|
-
declare const findEffectivePolicy: (entityType: string) => Promise<Record<string, unknown>[]>;
|
|
34
33
|
//#endregion
|
|
35
34
|
export { field_policy_d_exports };
|
|
@@ -2,7 +2,7 @@ import { EntityType, FieldPolicy, ModelInclusion } from "../models/FieldPolicy.j
|
|
|
2
2
|
|
|
3
3
|
//#region src/repository/field-policy.d.ts
|
|
4
4
|
declare namespace field_policy_d_exports {
|
|
5
|
-
export { CreateFieldPolicyData, UpdateFieldPolicyData, create, findAll, findAllByContext, findAllByContextIds, findByContextAndName, findById,
|
|
5
|
+
export { CreateFieldPolicyData, UpdateFieldPolicyData, create, findAll, findAllByContext, findAllByContextIds, findByContextAndName, findById, remove, update };
|
|
6
6
|
}
|
|
7
7
|
interface CreateFieldPolicyData {
|
|
8
8
|
contextId: string;
|
|
@@ -30,6 +30,5 @@ declare const create: ({
|
|
|
30
30
|
}: CreateFieldPolicyData) => Promise<FieldPolicy>;
|
|
31
31
|
declare const update: (id: string, data: UpdateFieldPolicyData) => Promise<FieldPolicy | null>;
|
|
32
32
|
declare const remove: (id: string) => Promise<number>;
|
|
33
|
-
declare const findEffectivePolicy: (entityType: string) => Promise<Record<string, unknown>[]>;
|
|
34
33
|
//#endregion
|
|
35
34
|
export { field_policy_d_exports };
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { __export } from "../_virtual/rolldown_runtime.js";
|
|
2
|
-
import { matPathState } from "../mat-path-state.js";
|
|
3
2
|
import FieldPolicy_default from "../models/FieldPolicy.js";
|
|
4
|
-
import { QueryTypes } from "sequelize";
|
|
5
3
|
|
|
6
4
|
//#region src/repository/field-policy.ts
|
|
7
5
|
var field_policy_exports = /* @__PURE__ */ __export({
|
|
@@ -11,7 +9,6 @@ var field_policy_exports = /* @__PURE__ */ __export({
|
|
|
11
9
|
findAllByContextIds: () => findAllByContextIds,
|
|
12
10
|
findByContextAndName: () => findByContextAndName,
|
|
13
11
|
findById: () => findById,
|
|
14
|
-
findEffectivePolicy: () => findEffectivePolicy,
|
|
15
12
|
remove: () => remove,
|
|
16
13
|
update: () => update
|
|
17
14
|
});
|
|
@@ -36,24 +33,6 @@ const update = async (id, data) => {
|
|
|
36
33
|
return policy.update(data);
|
|
37
34
|
};
|
|
38
35
|
const remove = (id) => FieldPolicy_default.destroy({ where: { id } });
|
|
39
|
-
const findEffectivePolicy = (entityType) => {
|
|
40
|
-
const tableName = FieldPolicy_default.getTableName();
|
|
41
|
-
const EFFECTIVE_POLICY_QUERY = `
|
|
42
|
-
SELECT fp.*
|
|
43
|
-
FROM "${tableName}" fp
|
|
44
|
-
LEFT JOIN context_entity_path cep ON cep.deleted_at IS NULL
|
|
45
|
-
AND cep.entity_id = fp.context_id
|
|
46
|
-
AND cep.entity_type = 'context'
|
|
47
|
-
AND cep.path @> ANY(current_setting('mat_path.paths', true)::ltree[])
|
|
48
|
-
WHERE fp.entity_type = $1
|
|
49
|
-
ORDER BY COALESCE(nlevel(cep.path), 0) DESC
|
|
50
|
-
LIMIT 1`;
|
|
51
|
-
return matPathState.withMatPath(tableName, (transaction) => FieldPolicy_default.sequelize.query(EFFECTIVE_POLICY_QUERY, {
|
|
52
|
-
bind: [entityType],
|
|
53
|
-
type: QueryTypes.SELECT,
|
|
54
|
-
transaction
|
|
55
|
-
}));
|
|
56
|
-
};
|
|
57
36
|
|
|
58
37
|
//#endregion
|
|
59
|
-
export { create, field_policy_exports, findAll,
|
|
38
|
+
export { create, field_policy_exports, findAll, remove, update };
|
|
@@ -2,6 +2,7 @@ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
|
2
2
|
const require_index = require('../utils/logger/index.cjs');
|
|
3
3
|
const require_CustomValidator = require('../models/CustomValidator.cjs');
|
|
4
4
|
require('../models/index.cjs');
|
|
5
|
+
let sequelize = require("sequelize");
|
|
5
6
|
let sequelize_lib_sequelize = require("sequelize/lib/sequelize");
|
|
6
7
|
sequelize_lib_sequelize = require_rolldown_runtime.__toESM(sequelize_lib_sequelize);
|
|
7
8
|
|
|
@@ -65,7 +66,7 @@ const findEffective = async (entityType = "Vehicle", requestPath) => {
|
|
|
65
66
|
try {
|
|
66
67
|
await sequelize_lib_sequelize.default.query(QUERY, {
|
|
67
68
|
bind: [entityType],
|
|
68
|
-
type:
|
|
69
|
+
type: sequelize.QueryTypes.SELECT
|
|
69
70
|
});
|
|
70
71
|
return {
|
|
71
72
|
...result.schema.properties.after,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import logger_default from "../utils/logger/index.js";
|
|
2
2
|
import CustomValidator_default from "../models/CustomValidator.js";
|
|
3
3
|
import "../models/index.js";
|
|
4
|
+
import { QueryTypes } from "sequelize";
|
|
4
5
|
import sequelize from "sequelize/lib/sequelize";
|
|
5
6
|
|
|
6
7
|
//#region src/repository/validator.ts
|
|
@@ -63,7 +64,7 @@ const findEffective = async (entityType = "Vehicle", requestPath) => {
|
|
|
63
64
|
try {
|
|
64
65
|
await sequelize.query(QUERY, {
|
|
65
66
|
bind: [entityType],
|
|
66
|
-
type:
|
|
67
|
+
type: QueryTypes.SELECT
|
|
67
68
|
});
|
|
68
69
|
return {
|
|
69
70
|
...result.schema.properties.after,
|
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.22",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -53,10 +53,10 @@
|
|
|
53
53
|
"express": "^4.21.2",
|
|
54
54
|
"npm-watch": "^0.11.0",
|
|
55
55
|
"supertest": "^7.0.0",
|
|
56
|
-
"@autofleet/node-common": "^4.3.22",
|
|
57
56
|
"@autofleet/logger": "^4.7.0",
|
|
57
|
+
"@autofleet/zehut": "^4.13.4",
|
|
58
58
|
"@autofleet/errors": "^3.3.7",
|
|
59
|
-
"@autofleet/
|
|
59
|
+
"@autofleet/node-common": "^4.3.22"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
62
|
"@autofleet/errors": "^3",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import { Model } from "sequelize-typescript";
|