@autofleet/sadot 1.6.18-beta.21 → 1.6.18-beta.24

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.
Files changed (132) hide show
  1. package/dist/_virtual/rolldown_runtime.cjs +0 -14
  2. package/dist/_virtual/rolldown_runtime.js +1 -15
  3. package/dist/api/v1/definition/index.cjs +4 -4
  4. package/dist/api/v1/index.cjs +0 -2
  5. package/dist/api/v1/validator/index.cjs +4 -2
  6. package/dist/index.cjs +8 -19
  7. package/dist/index.d.cts +12 -13
  8. package/dist/index.d.ts +12 -14
  9. package/dist/index.js +16 -21
  10. package/dist/migrations/index.cjs +1 -13
  11. package/dist/repository/validator.cjs +22 -23
  12. package/dist/{api → sadot/src/api}/v1/definition/index.js +1 -1
  13. package/dist/{api → sadot/src/api}/v1/index.js +0 -2
  14. package/dist/{api → sadot/src/api}/v1/validator/index.js +4 -2
  15. package/dist/{migrations → sadot/src/migrations}/index.js +2 -14
  16. package/dist/{models → sadot/src/models}/CustomFieldDefinition.js +2 -2
  17. package/dist/{models → sadot/src/models}/CustomFieldEntries.js +2 -2
  18. package/dist/{models → sadot/src/models}/CustomFieldModelTypeMap.js +2 -2
  19. package/dist/{models → sadot/src/models}/CustomFieldValue.js +2 -2
  20. package/dist/{models → sadot/src/models}/CustomValidator.js +2 -2
  21. package/dist/sadot/src/models/index.d.cts +7 -0
  22. package/dist/{models → sadot/src/models}/index.d.ts +0 -4
  23. package/dist/{models → sadot/src/models}/tests/AssociatedTestModel.js +2 -2
  24. package/dist/{models → sadot/src/models}/tests/TestModel.js +2 -2
  25. package/dist/{models → sadot/src/models}/tests/contextAwareModels/ContextAwareTestModel.js +2 -2
  26. package/dist/{models → sadot/src/models}/tests/contextAwareModels/ContextTestModel.js +2 -2
  27. package/dist/{repository → sadot/src/repository}/validator.js +22 -22
  28. package/dist/{types → sadot/src/types}/index.d.cts +3 -1
  29. package/dist/{types → sadot/src/types}/index.d.ts +3 -1
  30. package/dist/{utils → sadot/src/utils}/helpers/index.d.cts +2 -1
  31. package/dist/{utils → sadot/src/utils}/helpers/index.d.ts +2 -1
  32. package/dist/{utils → sadot/src/utils}/helpers/index.js +2 -1
  33. package/dist/utils/helpers/index.cjs +3 -1
  34. package/dist/zehut/src/check-permission.d.cts +6 -0
  35. package/dist/zehut/src/check-permission.d.ts +6 -0
  36. package/dist/zehut/src/errors.d.cts +1 -0
  37. package/dist/zehut/src/errors.d.ts +1 -0
  38. package/dist/zehut/src/index.d.cts +6 -0
  39. package/dist/zehut/src/index.d.ts +6 -0
  40. package/dist/zehut/src/permissions/SDK/evaluatePermissions.d.cts +1 -0
  41. package/dist/zehut/src/permissions/SDK/evaluatePermissions.d.ts +1 -0
  42. package/dist/zehut/src/permissions/SDK/types.d.cts +1 -0
  43. package/dist/zehut/src/permissions/SDK/types.d.ts +1 -0
  44. package/dist/zehut/src/permissions/index.d.cts +2 -0
  45. package/dist/zehut/src/permissions/index.d.ts +2 -0
  46. package/dist/zehut/src/permissions/middleware/requirePermissions.d.cts +1 -0
  47. package/dist/zehut/src/permissions/middleware/requirePermissions.d.ts +1 -0
  48. package/dist/zehut/src/user/ApiUser.d.cts +59 -0
  49. package/dist/zehut/src/user/ApiUser.d.ts +59 -0
  50. package/dist/zehut/src/user/fastify.d.cts +8 -0
  51. package/dist/zehut/src/user/fastify.d.ts +8 -0
  52. package/dist/zehut/src/user/index.d.cts +9 -0
  53. package/dist/zehut/src/user/index.d.ts +9 -0
  54. package/package.json +14 -2
  55. package/dist/api/v1/field-policies/index.cjs +0 -104
  56. package/dist/api/v1/field-policies/index.js +0 -103
  57. package/dist/migrations/004-create-field-policy-tables.cjs +0 -29
  58. package/dist/migrations/004-create-field-policy-tables.js +0 -27
  59. package/dist/migrations/005-add-entity-type-to-field-policies.cjs +0 -20
  60. package/dist/migrations/005-add-entity-type-to-field-policies.js +0 -18
  61. package/dist/models/FieldPolicy.cjs +0 -54
  62. package/dist/models/FieldPolicy.d.cts +0 -25
  63. package/dist/models/FieldPolicy.d.ts +0 -25
  64. package/dist/models/FieldPolicy.js +0 -53
  65. package/dist/models/tests/AssociatedTestModel.d.ts +0 -2
  66. package/dist/models/tests/TestModel.d.ts +0 -2
  67. package/dist/models/tests/contextAwareModels/ContextAwareTestModel.d.ts +0 -2
  68. package/dist/models/tests/contextAwareModels/ContextTestModel.d.ts +0 -1
  69. package/dist/repository/field-policy.cjs +0 -69
  70. package/dist/repository/field-policy.d.cts +0 -35
  71. package/dist/repository/field-policy.d.ts +0 -35
  72. package/dist/repository/field-policy.js +0 -59
  73. /package/dist/{api → sadot/src/api}/index.js +0 -0
  74. /package/dist/{api → sadot/src/api}/v1/definition/validations.js +0 -0
  75. /package/dist/{api → sadot/src/api}/v1/errors.js +0 -0
  76. /package/dist/{api → sadot/src/api}/v1/validator/validations.d.cts +0 -0
  77. /package/dist/{api → sadot/src/api}/v1/validator/validations.d.ts +0 -0
  78. /package/dist/{api → sadot/src/api}/v1/validator/validations.js +0 -0
  79. /package/dist/{errors → sadot/src/errors}/index.js +0 -0
  80. /package/dist/{events → sadot/src/events}/index.js +0 -0
  81. /package/dist/{hooks → sadot/src/hooks}/enrich.js +0 -0
  82. /package/dist/{hooks → sadot/src/hooks}/find.js +0 -0
  83. /package/dist/{hooks → sadot/src/hooks}/hooks.js +0 -0
  84. /package/dist/{hooks → sadot/src/hooks}/index.js +0 -0
  85. /package/dist/{hooks → sadot/src/hooks}/utils/updateInstanceValues.js +0 -0
  86. /package/dist/{init-state.d.cts → sadot/src/init-state.d.cts} +0 -0
  87. /package/dist/{init-state.d.ts → sadot/src/init-state.d.ts} +0 -0
  88. /package/dist/{init-state.js → sadot/src/init-state.js} +0 -0
  89. /package/dist/{mat-path-state.js → sadot/src/mat-path-state.js} +0 -0
  90. /package/dist/{migrations → sadot/src/migrations}/001-create-core-tables.js +0 -0
  91. /package/dist/{migrations → sadot/src/migrations}/002-create-custom-field-entries.js +0 -0
  92. /package/dist/{migrations → sadot/src/migrations}/003-create-custom-field-model-type-map.js +0 -0
  93. /package/dist/{models → sadot/src/models}/CustomFieldDefinition.d.cts +0 -0
  94. /package/dist/{models → sadot/src/models}/CustomFieldDefinition.d.ts +0 -0
  95. /package/dist/{models → sadot/src/models}/CustomFieldEntries.d.cts +0 -0
  96. /package/dist/{models → sadot/src/models}/CustomFieldEntries.d.ts +0 -0
  97. /package/dist/{models → sadot/src/models}/CustomFieldModelTypeMap.d.cts +0 -0
  98. /package/dist/{models → sadot/src/models}/CustomFieldModelTypeMap.d.ts +0 -0
  99. /package/dist/{models → sadot/src/models}/CustomFieldValue.d.cts +0 -0
  100. /package/dist/{models → sadot/src/models}/CustomFieldValue.d.ts +0 -0
  101. /package/dist/{models → sadot/src/models}/CustomValidator.d.cts +0 -0
  102. /package/dist/{models → sadot/src/models}/CustomValidator.d.ts +0 -0
  103. /package/dist/{models → sadot/src/models}/index.js +0 -0
  104. /package/dist/{repository → sadot/src/repository}/definition.js +0 -0
  105. /package/dist/{repository → sadot/src/repository}/entries.js +0 -0
  106. /package/dist/{repository → sadot/src/repository}/utils/formatValues.js +0 -0
  107. /package/dist/{repository → sadot/src/repository}/value.js +0 -0
  108. /package/dist/{scopes → sadot/src/scopes}/filter.d.cts +0 -0
  109. /package/dist/{scopes → sadot/src/scopes}/filter.d.ts +0 -0
  110. /package/dist/{scopes → sadot/src/scopes}/filter.js +0 -0
  111. /package/dist/{scopes → sadot/src/scopes}/helpers/filter.helpers.d.cts +0 -0
  112. /package/dist/{scopes → sadot/src/scopes}/helpers/filter.helpers.d.ts +0 -0
  113. /package/dist/{scopes → sadot/src/scopes}/helpers/filter.helpers.js +0 -0
  114. /package/dist/{scopes → sadot/src/scopes}/index.js +0 -0
  115. /package/dist/{utils → sadot/src/utils}/constants/index.d.cts +0 -0
  116. /package/dist/{utils → sadot/src/utils}/constants/index.d.ts +0 -0
  117. /package/dist/{utils → sadot/src/utils}/constants/index.js +0 -0
  118. /package/dist/{utils → sadot/src/utils}/db/index.js +0 -0
  119. /package/dist/{utils → sadot/src/utils}/init.js +0 -0
  120. /package/dist/{utils → sadot/src/utils}/logger/index.js +0 -0
  121. /package/dist/{utils → sadot/src/utils}/scopeAttributes.js +0 -0
  122. /package/dist/{utils → sadot/src/utils}/validations/index.js +0 -0
  123. /package/dist/{utils → sadot/src/utils}/validations/schema/custom-fields.d.cts +0 -0
  124. /package/dist/{utils → sadot/src/utils}/validations/schema/custom-fields.d.ts +0 -0
  125. /package/dist/{utils → sadot/src/utils}/validations/schema/custom-fields.js +0 -0
  126. /package/dist/{utils → sadot/src/utils}/validations/schema/validator-schema.js +0 -0
  127. /package/dist/{utils → sadot/src/utils}/validations/validators/index.js +0 -0
  128. /package/dist/{utils → sadot/src/utils}/validations/validators/multi-select-dropdown.validator.js +0 -0
  129. /package/dist/{utils → sadot/src/utils}/validations/validators/multi-select-status.validator.js +0 -0
  130. /package/dist/{utils → sadot/src/utils}/validations/validators/multi-select.helpers.js +0 -0
  131. /package/dist/{utils → sadot/src/utils}/validations/validators/select.validator.js +0 -0
  132. /package/dist/{utils → sadot/src/utils}/validations/validators/status.validator.js +0 -0
@@ -1,27 +0,0 @@
1
- //#region src/migrations/004-create-field-policy-tables.ts
2
- const up = async ({ context: queryInterface }) => {
3
- const { sequelize } = queryInterface;
4
- await sequelize.query(`
5
- CREATE TABLE IF NOT EXISTS "field_policies" (
6
- "id" UUID NOT NULL DEFAULT gen_random_uuid(),
7
- "context_id" UUID NOT NULL,
8
- "name" VARCHAR NOT NULL,
9
- "fields" JSONB NOT NULL DEFAULT '[]',
10
- "models" JSONB NOT NULL DEFAULT '[]',
11
- "created_at" TIMESTAMPTZ NOT NULL,
12
- "updated_at" TIMESTAMPTZ,
13
- PRIMARY KEY ("id")
14
- )
15
- `);
16
- await sequelize.query(`
17
- CREATE UNIQUE INDEX IF NOT EXISTS "unique_context_policy"
18
- ON "field_policies" ("context_id", "name")
19
- `);
20
- };
21
- const down = async ({ context: queryInterface }) => {
22
- const { sequelize } = queryInterface;
23
- await sequelize.query("DROP TABLE IF EXISTS \"field_policies\"");
24
- };
25
-
26
- //#endregion
27
- export { down, up };
@@ -1,20 +0,0 @@
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;
@@ -1,18 +0,0 @@
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 };
@@ -1,54 +0,0 @@
1
- const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
- const require_decorateMetadata = require('../_virtual/_@oxc-project_runtime@0.103.0/helpers/decorateMetadata.cjs');
3
- const require_decorate = require('../_virtual/_@oxc-project_runtime@0.103.0/helpers/decorate.cjs');
4
- let sequelize_typescript = require("sequelize-typescript");
5
- let node_crypto = require("node:crypto");
6
-
7
- //#region src/models/FieldPolicy.ts
8
- let FieldPolicy = class FieldPolicy$1 extends sequelize_typescript.Model {};
9
- require_decorate.__decorate([
10
- sequelize_typescript.PrimaryKey,
11
- (0, sequelize_typescript.Default)(() => (0, node_crypto.randomUUID)()),
12
- (0, sequelize_typescript.Column)({
13
- type: sequelize_typescript.DataType.UUID,
14
- allowNull: false
15
- }),
16
- require_decorateMetadata.__decorateMetadata("design:type", String)
17
- ], FieldPolicy.prototype, "id", void 0);
18
- require_decorate.__decorate([(0, sequelize_typescript.Column)({
19
- type: sequelize_typescript.DataType.UUID,
20
- allowNull: false
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);
26
- require_decorate.__decorate([(0, sequelize_typescript.Column)({
27
- type: sequelize_typescript.DataType.STRING,
28
- allowNull: false
29
- }), require_decorateMetadata.__decorateMetadata("design:type", String)], FieldPolicy.prototype, "name", void 0);
30
- require_decorate.__decorate([(0, sequelize_typescript.Column)({
31
- type: sequelize_typescript.DataType.JSONB,
32
- allowNull: false,
33
- defaultValue: []
34
- }), require_decorateMetadata.__decorateMetadata("design:type", Array)], FieldPolicy.prototype, "fields", void 0);
35
- require_decorate.__decorate([(0, sequelize_typescript.Column)({
36
- type: sequelize_typescript.DataType.JSONB,
37
- allowNull: false,
38
- defaultValue: []
39
- }), require_decorateMetadata.__decorateMetadata("design:type", Array)], FieldPolicy.prototype, "models", void 0);
40
- FieldPolicy = require_decorate.__decorate([(0, sequelize_typescript.Table)({
41
- tableName: "field_policies",
42
- modelName: "FieldPolicy",
43
- timestamps: true,
44
- underscored: true,
45
- indexes: [{
46
- name: "unique_context_policy",
47
- fields: ["context_id", "name"],
48
- unique: true
49
- }]
50
- })], FieldPolicy);
51
- var FieldPolicy_default = FieldPolicy;
52
-
53
- //#endregion
54
- exports.default = FieldPolicy_default;
@@ -1,25 +0,0 @@
1
- import { Model } from "sequelize-typescript";
2
-
3
- //#region src/models/FieldPolicy.d.ts
4
- type EntityType = "vehicle" | "driver";
5
- type ModelMode = "full" | "partial";
6
- type ModelInclusion = {
7
- name: string;
8
- mode: "full";
9
- } | {
10
- name: string;
11
- mode: "partial";
12
- fields: string[];
13
- };
14
- declare class FieldPolicy extends Model {
15
- id: string;
16
- contextId: string;
17
- entityType: EntityType | null;
18
- name: string;
19
- /** Base-level field names to include */
20
- fields: string[];
21
- /** Model inclusions; full = all fields, partial = only listed fields */
22
- models: ModelInclusion[];
23
- }
24
- //#endregion
25
- export { EntityType, FieldPolicy, ModelInclusion, ModelMode };
@@ -1,25 +0,0 @@
1
- import { Model } from "sequelize-typescript";
2
-
3
- //#region src/models/FieldPolicy.d.ts
4
- type EntityType = "vehicle" | "driver";
5
- type ModelMode = "full" | "partial";
6
- type ModelInclusion = {
7
- name: string;
8
- mode: "full";
9
- } | {
10
- name: string;
11
- mode: "partial";
12
- fields: string[];
13
- };
14
- declare class FieldPolicy extends Model {
15
- id: string;
16
- contextId: string;
17
- entityType: EntityType | null;
18
- name: string;
19
- /** Base-level field names to include */
20
- fields: string[];
21
- /** Model inclusions; full = all fields, partial = only listed fields */
22
- models: ModelInclusion[];
23
- }
24
- //#endregion
25
- export { EntityType, FieldPolicy, ModelInclusion, ModelMode };
@@ -1,53 +0,0 @@
1
- import { __decorateMetadata } from "../_virtual/_@oxc-project_runtime@0.103.0/helpers/decorateMetadata.js";
2
- import { __decorate } from "../_virtual/_@oxc-project_runtime@0.103.0/helpers/decorate.js";
3
- import { Column, DataType, Default, Model, PrimaryKey, Table } from "sequelize-typescript";
4
- import { randomUUID } from "node:crypto";
5
-
6
- //#region src/models/FieldPolicy.ts
7
- let FieldPolicy = class FieldPolicy$1 extends Model {};
8
- __decorate([
9
- PrimaryKey,
10
- Default(() => randomUUID()),
11
- Column({
12
- type: DataType.UUID,
13
- allowNull: false
14
- }),
15
- __decorateMetadata("design:type", String)
16
- ], FieldPolicy.prototype, "id", void 0);
17
- __decorate([Column({
18
- type: DataType.UUID,
19
- allowNull: false
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);
25
- __decorate([Column({
26
- type: DataType.STRING,
27
- allowNull: false
28
- }), __decorateMetadata("design:type", String)], FieldPolicy.prototype, "name", void 0);
29
- __decorate([Column({
30
- type: DataType.JSONB,
31
- allowNull: false,
32
- defaultValue: []
33
- }), __decorateMetadata("design:type", Array)], FieldPolicy.prototype, "fields", void 0);
34
- __decorate([Column({
35
- type: DataType.JSONB,
36
- allowNull: false,
37
- defaultValue: []
38
- }), __decorateMetadata("design:type", Array)], FieldPolicy.prototype, "models", void 0);
39
- FieldPolicy = __decorate([Table({
40
- tableName: "field_policies",
41
- modelName: "FieldPolicy",
42
- timestamps: true,
43
- underscored: true,
44
- indexes: [{
45
- name: "unique_context_policy",
46
- fields: ["context_id", "name"],
47
- unique: true
48
- }]
49
- })], FieldPolicy);
50
- var FieldPolicy_default = FieldPolicy;
51
-
52
- //#endregion
53
- export { FieldPolicy_default as default };
@@ -1,2 +0,0 @@
1
- import "./TestModel.js";
2
- import { Model } from "sequelize-typescript";
@@ -1,2 +0,0 @@
1
- import "./AssociatedTestModel.js";
2
- import { Model } from "sequelize-typescript";
@@ -1,2 +0,0 @@
1
- import "./ContextTestModel.js";
2
- import { Model } from "sequelize-typescript";
@@ -1 +0,0 @@
1
- import { Model } from "sequelize-typescript";
@@ -1,69 +0,0 @@
1
- const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
- const require_mat_path_state = require('../mat-path-state.cjs');
3
- const require_FieldPolicy = require('../models/FieldPolicy.cjs');
4
- let sequelize = require("sequelize");
5
-
6
- //#region src/repository/field-policy.ts
7
- var field_policy_exports = /* @__PURE__ */ require_rolldown_runtime.__export({
8
- create: () => create,
9
- findAll: () => findAll,
10
- findAllByContext: () => findAllByContext,
11
- findAllByContextIds: () => findAllByContextIds,
12
- findByContextAndName: () => findByContextAndName,
13
- findById: () => findById,
14
- findEffectivePolicy: () => findEffectivePolicy,
15
- remove: () => remove,
16
- update: () => update
17
- });
18
- const findByContextAndName = (contextId, name) => require_FieldPolicy.default.findOne({ where: {
19
- contextId,
20
- name
21
- } });
22
- const findById = (id) => require_FieldPolicy.default.findByPk(id);
23
- const findAllByContext = (contextId) => require_FieldPolicy.default.findAll({ where: { contextId } });
24
- const findAll = () => require_FieldPolicy.default.findAll();
25
- const findAllByContextIds = (contextIds) => require_FieldPolicy.default.findAll({ where: { contextId: contextIds } });
26
- const create = ({ contextId, name, entityType, fields, models }) => require_FieldPolicy.default.create({
27
- contextId,
28
- name,
29
- entityType,
30
- fields,
31
- models
32
- });
33
- const update = async (id, data) => {
34
- const policy = await require_FieldPolicy.default.findByPk(id);
35
- if (!policy) return null;
36
- return policy.update(data);
37
- };
38
- 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
-
58
- //#endregion
59
- exports.create = create;
60
- Object.defineProperty(exports, 'field_policy_exports', {
61
- enumerable: true,
62
- get: function () {
63
- return field_policy_exports;
64
- }
65
- });
66
- exports.findAll = findAll;
67
- exports.findEffectivePolicy = findEffectivePolicy;
68
- exports.remove = remove;
69
- exports.update = update;
@@ -1,35 +0,0 @@
1
- import { EntityType, FieldPolicy, ModelInclusion } from "../models/FieldPolicy.cjs";
2
-
3
- //#region src/repository/field-policy.d.ts
4
- declare namespace field_policy_d_exports {
5
- export { CreateFieldPolicyData, UpdateFieldPolicyData, create, findAll, findAllByContext, findAllByContextIds, findByContextAndName, findById, findEffectivePolicy, remove, update };
6
- }
7
- interface CreateFieldPolicyData {
8
- contextId: string;
9
- name: string;
10
- entityType?: EntityType;
11
- fields?: string[];
12
- models?: ModelInclusion[];
13
- }
14
- interface UpdateFieldPolicyData {
15
- entityType?: EntityType;
16
- fields?: string[];
17
- models?: ModelInclusion[];
18
- }
19
- declare const findByContextAndName: (contextId: string, name: string) => Promise<FieldPolicy | null>;
20
- declare const findById: (id: string) => Promise<FieldPolicy | null>;
21
- declare const findAllByContext: (contextId: string) => Promise<FieldPolicy[]>;
22
- declare const findAll: () => Promise<FieldPolicy[]>;
23
- declare const findAllByContextIds: (contextIds: string[]) => Promise<FieldPolicy[]>;
24
- declare const create: ({
25
- contextId,
26
- name,
27
- entityType,
28
- fields,
29
- models
30
- }: CreateFieldPolicyData) => Promise<FieldPolicy>;
31
- declare const update: (id: string, data: UpdateFieldPolicyData) => Promise<FieldPolicy | null>;
32
- declare const remove: (id: string) => Promise<number>;
33
- declare const findEffectivePolicy: (entityType: string) => Promise<Record<string, unknown>[]>;
34
- //#endregion
35
- export { field_policy_d_exports };
@@ -1,35 +0,0 @@
1
- import { EntityType, FieldPolicy, ModelInclusion } from "../models/FieldPolicy.js";
2
-
3
- //#region src/repository/field-policy.d.ts
4
- declare namespace field_policy_d_exports {
5
- export { CreateFieldPolicyData, UpdateFieldPolicyData, create, findAll, findAllByContext, findAllByContextIds, findByContextAndName, findById, findEffectivePolicy, remove, update };
6
- }
7
- interface CreateFieldPolicyData {
8
- contextId: string;
9
- name: string;
10
- entityType?: EntityType;
11
- fields?: string[];
12
- models?: ModelInclusion[];
13
- }
14
- interface UpdateFieldPolicyData {
15
- entityType?: EntityType;
16
- fields?: string[];
17
- models?: ModelInclusion[];
18
- }
19
- declare const findByContextAndName: (contextId: string, name: string) => Promise<FieldPolicy | null>;
20
- declare const findById: (id: string) => Promise<FieldPolicy | null>;
21
- declare const findAllByContext: (contextId: string) => Promise<FieldPolicy[]>;
22
- declare const findAll: () => Promise<FieldPolicy[]>;
23
- declare const findAllByContextIds: (contextIds: string[]) => Promise<FieldPolicy[]>;
24
- declare const create: ({
25
- contextId,
26
- name,
27
- entityType,
28
- fields,
29
- models
30
- }: CreateFieldPolicyData) => Promise<FieldPolicy>;
31
- declare const update: (id: string, data: UpdateFieldPolicyData) => Promise<FieldPolicy | null>;
32
- declare const remove: (id: string) => Promise<number>;
33
- declare const findEffectivePolicy: (entityType: string) => Promise<Record<string, unknown>[]>;
34
- //#endregion
35
- export { field_policy_d_exports };
@@ -1,59 +0,0 @@
1
- import { __export } from "../_virtual/rolldown_runtime.js";
2
- import { matPathState } from "../mat-path-state.js";
3
- import FieldPolicy_default from "../models/FieldPolicy.js";
4
- import { QueryTypes } from "sequelize";
5
-
6
- //#region src/repository/field-policy.ts
7
- var field_policy_exports = /* @__PURE__ */ __export({
8
- create: () => create,
9
- findAll: () => findAll,
10
- findAllByContext: () => findAllByContext,
11
- findAllByContextIds: () => findAllByContextIds,
12
- findByContextAndName: () => findByContextAndName,
13
- findById: () => findById,
14
- findEffectivePolicy: () => findEffectivePolicy,
15
- remove: () => remove,
16
- update: () => update
17
- });
18
- const findByContextAndName = (contextId, name) => FieldPolicy_default.findOne({ where: {
19
- contextId,
20
- name
21
- } });
22
- const findById = (id) => FieldPolicy_default.findByPk(id);
23
- const findAllByContext = (contextId) => FieldPolicy_default.findAll({ where: { contextId } });
24
- const findAll = () => FieldPolicy_default.findAll();
25
- const findAllByContextIds = (contextIds) => FieldPolicy_default.findAll({ where: { contextId: contextIds } });
26
- const create = ({ contextId, name, entityType, fields, models }) => FieldPolicy_default.create({
27
- contextId,
28
- name,
29
- entityType,
30
- fields,
31
- models
32
- });
33
- const update = async (id, data) => {
34
- const policy = await FieldPolicy_default.findByPk(id);
35
- if (!policy) return null;
36
- return policy.update(data);
37
- };
38
- 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
-
58
- //#endregion
59
- export { create, field_policy_exports, findAll, findEffectivePolicy, remove, update };
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes