@autofleet/sadot 1.6.18-beta.1 → 1.6.18-beta.4

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 (230) hide show
  1. package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/decorate.js +10 -0
  2. package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/decorateMetadata.js +7 -0
  3. package/dist/{chunk-DJulfCLt.js → _virtual/rolldown_runtime.js} +1 -1
  4. package/dist/index.d.ts +14 -394
  5. package/dist/index.js +19 -33430
  6. package/dist/node_modules/accepts/index.js +175 -0
  7. package/dist/node_modules/array-flatten/array-flatten.js +56 -0
  8. package/dist/node_modules/body-parser/index.js +135 -0
  9. package/dist/node_modules/body-parser/lib/read.js +164 -0
  10. package/dist/node_modules/body-parser/lib/types/json.js +200 -0
  11. package/dist/node_modules/body-parser/lib/types/raw.js +85 -0
  12. package/dist/node_modules/body-parser/lib/types/text.js +101 -0
  13. package/dist/node_modules/body-parser/lib/types/urlencoded.js +217 -0
  14. package/dist/node_modules/body-parser/node_modules/qs/lib/formats.js +29 -0
  15. package/dist/node_modules/body-parser/node_modules/qs/lib/index.js +21 -0
  16. package/dist/node_modules/body-parser/node_modules/qs/lib/parse.js +182 -0
  17. package/dist/node_modules/body-parser/node_modules/qs/lib/stringify.js +187 -0
  18. package/dist/node_modules/body-parser/node_modules/qs/lib/utils.js +173 -0
  19. package/dist/node_modules/bytes/index.js +121 -0
  20. package/dist/node_modules/call-bind-apply-helpers/actualApply.js +20 -0
  21. package/dist/node_modules/call-bind-apply-helpers/functionApply.js +12 -0
  22. package/dist/node_modules/call-bind-apply-helpers/functionCall.js +12 -0
  23. package/dist/node_modules/call-bind-apply-helpers/index.js +23 -0
  24. package/dist/node_modules/call-bind-apply-helpers/reflectApply.js +12 -0
  25. package/dist/node_modules/call-bound/index.js +22 -0
  26. package/dist/node_modules/content-disposition/index.js +309 -0
  27. package/dist/node_modules/content-type/index.js +151 -0
  28. package/dist/node_modules/cookie/index.js +245 -0
  29. package/dist/node_modules/cookie-signature/index.js +48 -0
  30. package/dist/node_modules/debug/node_modules/has-flag/index.js +17 -0
  31. package/dist/node_modules/debug/node_modules/supports-color/index.js +70 -0
  32. package/dist/node_modules/debug/src/browser.js +203 -0
  33. package/dist/node_modules/debug/src/common.js +209 -0
  34. package/dist/node_modules/debug/src/index.js +18 -0
  35. package/dist/node_modules/debug/src/node.js +215 -0
  36. package/dist/node_modules/depd/index.js +316 -0
  37. package/dist/node_modules/destroy/index.js +155 -0
  38. package/dist/node_modules/dunder-proto/get.js +27 -0
  39. package/dist/node_modules/ee-first/index.js +75 -0
  40. package/dist/node_modules/encodeurl/index.js +56 -0
  41. package/dist/node_modules/es-define-property/index.js +18 -0
  42. package/dist/node_modules/es-errors/eval.js +12 -0
  43. package/dist/node_modules/es-errors/index.js +12 -0
  44. package/dist/node_modules/es-errors/range.js +12 -0
  45. package/dist/node_modules/es-errors/ref.js +12 -0
  46. package/dist/node_modules/es-errors/syntax.js +12 -0
  47. package/dist/node_modules/es-errors/type.js +12 -0
  48. package/dist/node_modules/es-errors/uri.js +12 -0
  49. package/dist/node_modules/es-object-atoms/index.js +12 -0
  50. package/dist/node_modules/escape-html/index.js +67 -0
  51. package/dist/node_modules/etag/index.js +82 -0
  52. package/dist/node_modules/express/index.js +19 -0
  53. package/dist/node_modules/express/lib/application.js +503 -0
  54. package/dist/node_modules/express/lib/express.js +114 -0
  55. package/dist/node_modules/express/lib/middleware/init.js +44 -0
  56. package/dist/node_modules/express/lib/middleware/query.js +47 -0
  57. package/dist/node_modules/express/lib/request.js +422 -0
  58. package/dist/node_modules/express/lib/response.js +867 -0
  59. package/dist/node_modules/express/lib/router/index.js +424 -0
  60. package/dist/node_modules/express/lib/router/layer.js +140 -0
  61. package/dist/node_modules/express/lib/router/route.js +158 -0
  62. package/dist/node_modules/express/lib/utils.js +247 -0
  63. package/dist/node_modules/express/lib/view.js +135 -0
  64. package/dist/node_modules/express/node_modules/qs/lib/formats.js +29 -0
  65. package/dist/node_modules/express/node_modules/qs/lib/index.js +21 -0
  66. package/dist/node_modules/express/node_modules/qs/lib/parse.js +182 -0
  67. package/dist/node_modules/express/node_modules/qs/lib/stringify.js +187 -0
  68. package/dist/node_modules/express/node_modules/qs/lib/utils.js +173 -0
  69. package/dist/node_modules/finalhandler/index.js +234 -0
  70. package/dist/node_modules/forwarded/index.js +67 -0
  71. package/dist/node_modules/fresh/index.js +96 -0
  72. package/dist/node_modules/function-bind/implementation.js +58 -0
  73. package/dist/node_modules/function-bind/index.js +13 -0
  74. package/dist/node_modules/get-intrinsic/index.js +357 -0
  75. package/dist/node_modules/get-proto/Object.getPrototypeOf.js +14 -0
  76. package/dist/node_modules/get-proto/Reflect.getPrototypeOf.js +12 -0
  77. package/dist/node_modules/get-proto/index.js +25 -0
  78. package/dist/node_modules/gopd/gOPD.js +12 -0
  79. package/dist/node_modules/gopd/index.js +19 -0
  80. package/dist/node_modules/has-symbols/index.js +21 -0
  81. package/dist/node_modules/has-symbols/shams.js +35 -0
  82. package/dist/node_modules/hasown/index.js +16 -0
  83. package/dist/node_modules/http-errors/index.js +207 -0
  84. package/dist/node_modules/iconv-lite/encodings/dbcs-codec.js +321 -0
  85. package/dist/node_modules/iconv-lite/encodings/dbcs-data.js +126 -0
  86. package/dist/node_modules/iconv-lite/encodings/index.js +32 -0
  87. package/dist/node_modules/iconv-lite/encodings/internal.js +135 -0
  88. package/dist/node_modules/iconv-lite/encodings/sbcs-codec.js +53 -0
  89. package/dist/node_modules/iconv-lite/encodings/sbcs-data-generated.js +458 -0
  90. package/dist/node_modules/iconv-lite/encodings/sbcs-data.js +150 -0
  91. package/dist/node_modules/iconv-lite/encodings/tables/big5-added.js +172 -0
  92. package/dist/node_modules/iconv-lite/encodings/tables/cp936.js +2587 -0
  93. package/dist/node_modules/iconv-lite/encodings/tables/cp949.js +2223 -0
  94. package/dist/node_modules/iconv-lite/encodings/tables/cp950.js +230 -0
  95. package/dist/node_modules/iconv-lite/encodings/tables/eucjp.js +428 -0
  96. package/dist/node_modules/iconv-lite/encodings/tables/gb18030-ranges.js +430 -0
  97. package/dist/node_modules/iconv-lite/encodings/tables/gbk-added.js +232 -0
  98. package/dist/node_modules/iconv-lite/encodings/tables/shiftjis.js +295 -0
  99. package/dist/node_modules/iconv-lite/encodings/utf16.js +107 -0
  100. package/dist/node_modules/iconv-lite/encodings/utf7.js +183 -0
  101. package/dist/node_modules/iconv-lite/lib/bom-handling.js +45 -0
  102. package/dist/node_modules/iconv-lite/lib/extend-node.js +150 -0
  103. package/dist/node_modules/iconv-lite/lib/index.js +96 -0
  104. package/dist/node_modules/iconv-lite/lib/streams.js +97 -0
  105. package/dist/node_modules/inherits/inherits.js +20 -0
  106. package/dist/node_modules/inherits/inherits_browser.js +30 -0
  107. package/dist/node_modules/ipaddr.js/lib/ipaddr.js +677 -0
  108. package/dist/node_modules/math-intrinsics/abs.js +12 -0
  109. package/dist/node_modules/math-intrinsics/floor.js +12 -0
  110. package/dist/node_modules/math-intrinsics/isNaN.js +14 -0
  111. package/dist/node_modules/math-intrinsics/max.js +12 -0
  112. package/dist/node_modules/math-intrinsics/min.js +12 -0
  113. package/dist/node_modules/math-intrinsics/pow.js +12 -0
  114. package/dist/node_modules/math-intrinsics/round.js +12 -0
  115. package/dist/node_modules/math-intrinsics/sign.js +17 -0
  116. package/dist/node_modules/merge-descriptors/index.js +46 -0
  117. package/dist/node_modules/methods/index.js +69 -0
  118. package/dist/node_modules/mime/mime.js +79 -0
  119. package/dist/node_modules/mime/types.js +1104 -0
  120. package/dist/node_modules/mime-types/index.js +123 -0
  121. package/dist/node_modules/mime-types/node_modules/mime-db/db.js +7051 -0
  122. package/dist/node_modules/mime-types/node_modules/mime-db/index.js +21 -0
  123. package/dist/node_modules/ms/index.js +124 -0
  124. package/dist/node_modules/negotiator/index.js +76 -0
  125. package/dist/node_modules/negotiator/lib/charset.js +132 -0
  126. package/dist/node_modules/negotiator/lib/encoding.js +143 -0
  127. package/dist/node_modules/negotiator/lib/language.js +138 -0
  128. package/dist/node_modules/negotiator/lib/mediaType.js +200 -0
  129. package/dist/node_modules/object-inspect/index.js +389 -0
  130. package/dist/node_modules/object-inspect/util.inspect.js +11 -0
  131. package/dist/node_modules/on-finished/index.js +178 -0
  132. package/dist/node_modules/parseurl/index.js +111 -0
  133. package/dist/node_modules/path-to-regexp/index.js +118 -0
  134. package/dist/node_modules/proxy-addr/index.js +212 -0
  135. package/dist/node_modules/range-parser/index.js +110 -0
  136. package/dist/node_modules/raw-body/index.js +209 -0
  137. package/dist/node_modules/safe-buffer/index.js +46 -0
  138. package/dist/node_modules/safer-buffer/safer.js +48 -0
  139. package/dist/node_modules/send/index.js +801 -0
  140. package/dist/node_modules/send/node_modules/encodeurl/index.js +56 -0
  141. package/dist/node_modules/serve-static/index.js +134 -0
  142. package/dist/node_modules/setprototypeof/index.js +19 -0
  143. package/dist/node_modules/side-channel/index.js +45 -0
  144. package/dist/node_modules/side-channel-list/index.js +84 -0
  145. package/dist/node_modules/side-channel-map/index.js +62 -0
  146. package/dist/node_modules/side-channel-weakmap/index.js +73 -0
  147. package/dist/node_modules/statuses/codes.js +75 -0
  148. package/dist/node_modules/statuses/index.js +108 -0
  149. package/dist/node_modules/toidentifier/index.js +32 -0
  150. package/dist/node_modules/type-is/index.js +179 -0
  151. package/dist/node_modules/type-is/node_modules/media-typer/index.js +186 -0
  152. package/dist/node_modules/unpipe/index.js +50 -0
  153. package/dist/node_modules/utils-merge/index.js +28 -0
  154. package/dist/node_modules/vary/index.js +95 -0
  155. package/dist/packages/sadot/src/api/index.js +11 -0
  156. package/dist/packages/sadot/src/api/v1/definition/index.js +112 -0
  157. package/dist/packages/sadot/src/api/v1/definition/validations.js +125 -0
  158. package/dist/packages/sadot/src/api/v1/errors.js +13 -0
  159. package/dist/packages/sadot/src/api/v1/index.js +15 -0
  160. package/dist/packages/sadot/src/api/v1/templates/index.js +76 -0
  161. package/dist/packages/sadot/src/api/v1/validator/index.js +114 -0
  162. package/dist/packages/sadot/src/api/v1/validator/validations.d.ts +22 -0
  163. package/dist/packages/sadot/src/api/v1/validator/validations.js +38 -0
  164. package/dist/packages/sadot/src/errors/index.js +55 -0
  165. package/dist/packages/sadot/src/events/index.js +50 -0
  166. package/dist/packages/sadot/src/hooks/enrich.js +175 -0
  167. package/dist/packages/sadot/src/hooks/find.js +22 -0
  168. package/dist/packages/sadot/src/hooks/hooks.js +302 -0
  169. package/dist/packages/sadot/src/hooks/index.js +5 -0
  170. package/dist/packages/sadot/src/hooks/utils/updateInstanceValues.js +27 -0
  171. package/dist/packages/sadot/src/init-state.d.ts +35 -0
  172. package/dist/packages/sadot/src/init-state.js +55 -0
  173. package/dist/packages/sadot/src/mat-path-state.js +9 -0
  174. package/dist/packages/sadot/src/migrations/001-create-core-tables.js +68 -0
  175. package/dist/packages/sadot/src/migrations/002-create-custom-field-entries.js +25 -0
  176. package/dist/packages/sadot/src/migrations/003-create-custom-field-model-type-map.js +33 -0
  177. package/dist/packages/sadot/src/migrations/004-create-field-policy-tables.js +27 -0
  178. package/dist/packages/sadot/src/migrations/index.js +89 -0
  179. package/dist/packages/sadot/src/models/CustomFieldDefinition.d.ts +40 -0
  180. package/dist/packages/sadot/src/models/CustomFieldDefinition.js +146 -0
  181. package/dist/packages/sadot/src/models/CustomFieldEntries.d.ts +15 -0
  182. package/dist/packages/sadot/src/models/CustomFieldEntries.js +70 -0
  183. package/dist/packages/sadot/src/models/CustomFieldModelTypeMap.d.ts +14 -0
  184. package/dist/packages/sadot/src/models/CustomFieldModelTypeMap.js +61 -0
  185. package/dist/packages/sadot/src/models/CustomFieldValue.d.ts +20 -0
  186. package/dist/packages/sadot/src/models/CustomFieldValue.js +108 -0
  187. package/dist/packages/sadot/src/models/CustomValidator.d.ts +18 -0
  188. package/dist/packages/sadot/src/models/CustomValidator.js +67 -0
  189. package/dist/packages/sadot/src/models/FieldPolicy.d.ts +23 -0
  190. package/dist/packages/sadot/src/models/FieldPolicy.js +49 -0
  191. package/dist/packages/sadot/src/models/index.d.ts +7 -0
  192. package/dist/packages/sadot/src/models/index.js +161 -0
  193. package/dist/packages/sadot/src/models/tests/AssociatedTestModel.js +50 -0
  194. package/dist/packages/sadot/src/models/tests/TestModel.js +42 -0
  195. package/dist/packages/sadot/src/models/tests/contextAwareModels/ContextAwareTestModel.js +34 -0
  196. package/dist/packages/sadot/src/models/tests/contextAwareModels/ContextTestModel.js +32 -0
  197. package/dist/packages/sadot/src/repository/definition.js +212 -0
  198. package/dist/packages/sadot/src/repository/entries.js +67 -0
  199. package/dist/packages/sadot/src/repository/field-policy.d.ts +29 -0
  200. package/dist/packages/sadot/src/repository/field-policy.js +33 -0
  201. package/dist/packages/sadot/src/repository/utils/formatValues.js +14 -0
  202. package/dist/packages/sadot/src/repository/validator.js +54 -0
  203. package/dist/packages/sadot/src/repository/value.js +76 -0
  204. package/dist/packages/sadot/src/scopes/filter.d.ts +22 -0
  205. package/dist/packages/sadot/src/scopes/filter.js +54 -0
  206. package/dist/packages/sadot/src/scopes/helpers/filter.helpers.d.ts +16 -0
  207. package/dist/packages/sadot/src/scopes/helpers/filter.helpers.js +147 -0
  208. package/dist/packages/sadot/src/scopes/index.js +3 -0
  209. package/dist/packages/sadot/src/types/index.d.ts +70 -0
  210. package/dist/packages/sadot/src/utils/constants/index.d.ts +23 -0
  211. package/dist/packages/sadot/src/utils/constants/index.js +29 -0
  212. package/dist/packages/sadot/src/utils/db/index.js +14 -0
  213. package/dist/packages/sadot/src/utils/helpers/index.d.ts +30 -0
  214. package/dist/packages/sadot/src/utils/helpers/index.js +21 -0
  215. package/dist/packages/sadot/src/utils/init.js +111 -0
  216. package/dist/packages/sadot/src/utils/logger/index.js +12 -0
  217. package/dist/packages/sadot/src/utils/scopeAttributes.js +11 -0
  218. package/dist/packages/sadot/src/utils/validations/index.js +32 -0
  219. package/dist/packages/sadot/src/utils/validations/schema/custom-fields.d.ts +6 -0
  220. package/dist/packages/sadot/src/utils/validations/schema/custom-fields.js +7 -0
  221. package/dist/packages/sadot/src/utils/validations/schema/validator-schema.js +99 -0
  222. package/dist/packages/sadot/src/utils/validations/validators/index.js +42 -0
  223. package/dist/packages/sadot/src/utils/validations/validators/multi-select-dropdown.validator.js +7 -0
  224. package/dist/packages/sadot/src/utils/validations/validators/multi-select-status.validator.js +10 -0
  225. package/dist/packages/sadot/src/utils/validations/validators/multi-select.helpers.js +10 -0
  226. package/dist/packages/sadot/src/utils/validations/validators/select.validator.js +10 -0
  227. package/dist/packages/sadot/src/utils/validations/validators/status.validator.js +10 -0
  228. package/package.json +23 -23
  229. package/dist/index.cjs +0 -33544
  230. package/dist/index.d.cts +0 -408
@@ -0,0 +1,10 @@
1
+ //#region \0@oxc-project+runtime@0.103.0/helpers/decorate.js
2
+ function __decorate(decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ }
8
+
9
+ //#endregion
10
+ export { __decorate };
@@ -0,0 +1,7 @@
1
+ //#region \0@oxc-project+runtime@0.103.0/helpers/decorateMetadata.js
2
+ function __decorateMetadata(k, v) {
3
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
4
+ }
5
+
6
+ //#endregion
7
+ export { __decorateMetadata };
@@ -19,4 +19,4 @@ var __export = (all, symbols) => {
19
19
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
20
20
 
21
21
  //#endregion
22
- export { __export as n, __require as r, __commonJSMin as t };
22
+ export { __commonJSMin, __export, __require };
package/dist/index.d.ts CHANGED
@@ -1,399 +1,19 @@
1
- import { BindOrReplacements, CreateOptions, IncludeOptions, WhereOptions } from "sequelize";
2
- import { Model, ModelCtor, ModelStatic, Sequelize } from "sequelize-typescript";
3
- import { customFields } from "@autofleet/common-types";
4
- import Joi from "joi";
1
+ import { CUSTOM_FIELDS_FILTER_SCOPE, CustomFieldDefinitionType, supportedEntities } from "./packages/sadot/src/utils/constants/index.js";
2
+ import { CustomFieldValue } from "./packages/sadot/src/models/CustomFieldValue.js";
3
+ import { CustomFieldDefinition } from "./packages/sadot/src/models/CustomFieldDefinition.js";
4
+ import { CustomValidator } from "./packages/sadot/src/models/CustomValidator.js";
5
+ import { CustomFieldOptions, ModelFetcher, Models } from "./packages/sadot/src/types/index.js";
6
+ import { SadotInitializationState } from "./packages/sadot/src/init-state.js";
7
+ import { CustomFieldsSchema } from "./packages/sadot/src/utils/validations/schema/custom-fields.js";
8
+ import { generateCustomFieldSearchQueryPayload, generateRandomString } from "./packages/sadot/src/utils/helpers/index.js";
9
+ import { customFieldsSortScope } from "./packages/sadot/src/scopes/filter.js";
10
+ import { CustomFieldEntries } from "./packages/sadot/src/models/CustomFieldEntries.js";
11
+ import "./packages/sadot/src/models/index.js";
12
+ import { FieldPolicy, ModelInclusion, ModelMode } from "./packages/sadot/src/models/FieldPolicy.js";
13
+ import { field_policy_d_exports } from "./packages/sadot/src/repository/field-policy.js";
14
+ import { Sequelize } from "sequelize-typescript";
5
15
  import { Application } from "express";
6
- import { Literal } from "sequelize/types/utils";
7
16
 
8
- //#region ../zehut/src/user/ApiUser.d.ts
9
- type AccountType = "client" | "user" | "service" | "driver";
10
- type EntityPermissions = Record<string, string[]>;
11
- interface UserExternalData {
12
- element?: {
13
- internalUser: boolean;
14
- };
15
- [key: string]: any;
16
- }
17
- interface UserPayload {
18
- businessModels: EntityPermissions;
19
- fleets: EntityPermissions;
20
- demandSources: EntityPermissions;
21
- businessAccounts?: EntityPermissions;
22
- accountType?: AccountType;
23
- contexts?: EntityPermissions;
24
- createdAt?: string;
25
- externalData?: UserExternalData | null;
26
- authorizedContextPaths?: string[];
27
- }
28
- interface PartialUserPayload {
29
- businessModels?: EntityPermissions;
30
- fleets?: EntityPermissions;
31
- demandSources?: EntityPermissions;
32
- vehicles?: EntityPermissions;
33
- drivers?: EntityPermissions;
34
- businessAccounts?: EntityPermissions;
35
- }
36
- declare class ApiUser {
37
- id?: string | undefined;
38
- accountType?: AccountType | undefined;
39
- contextIds?: string[] | undefined;
40
- requestedContextPaths?: string[] | undefined;
41
- private privatePermissions;
42
- private readonly privateElevatedPermissionsHash;
43
- private privatePermissionsLegacy;
44
- private readonly appPermission;
45
- readonly emptyUser: boolean;
46
- private privateAuthorizedContextPaths;
47
- constructor(id?: string | undefined, accountType?: AccountType | undefined, elevatedPermissions?: PartialUserPayload, contextIds?: string[] | undefined, requestedContextPaths?: string[] | undefined);
48
- getUserPermissions(): Promise<UserPayload>;
49
- useCustomPermissionLoader(customPermissionLoader: (userId: string) => UserPayload | PromiseLike<UserPayload>): Promise<UserPayload>;
50
- get businessModels(): string[];
51
- get fleets(): string[];
52
- get demandSources(): string[];
53
- private getUserProperty;
54
- get elevatedPermissions(): UserPayload;
55
- get permissions(): UserPayload | undefined;
56
- get authorizedContextPaths(): string[];
57
- elevatePermissions(addedPermissions: PartialUserPayload): (() => void) & {
58
- [Symbol.dispose]: () => void;
59
- };
60
- getUserPermissionsLegacy(): Promise<unknown>;
61
- get permissionsLegacy(): any;
62
- getUserAppPermissions(appId: string, clientSecret: string): Promise<UserPayload | undefined>;
63
- extendRequiredContexts(contextIdsToAdd?: string[]): void;
64
- }
65
- //#endregion
66
- //#region ../zehut/src/user/index.d.ts
67
- declare module "express-serve-static-core" {
68
- interface Request {
69
- user: ApiUser;
70
- }
71
- }
72
- //#endregion
73
- //#region ../zehut/src/user/fastify.d.ts
74
- declare module "fastify" {
75
- interface FastifyRequest {
76
- user?: ApiUser;
77
- }
78
- }
79
- //#endregion
80
- //#region ../zehut/src/check-permission.d.ts
81
- declare const getUser: () => ApiUser | undefined;
82
- //#endregion
83
- //#region src/utils/constants/index.d.ts
84
- declare const supportedEntities: readonly ["businessModelId", "fleetId", "demandSourceId"];
85
- /**
86
- * Supported custom field types
87
- */
88
- declare enum CustomFieldDefinitionType {
89
- NUMBER = "number",
90
- BOOLEAN = "boolean",
91
- DATE = "date",
92
- DATETIME = "datetime",
93
- TEXT = "text",
94
- IMAGE = "image",
95
- SELECT = "select",
96
- STATUS = "status",
97
- FILE = "file",
98
- MULTI_SELECT_STATUS = "multi-select-status",
99
- MULTI_SELECT_DROPDOWN = "multi-select-dropdown",
100
- }
101
- declare const CUSTOM_FIELDS_FILTER_SCOPE: typeof customFields.CUSTOM_FIELDS_FILTER_SCOPE;
102
- //#endregion
103
- //#region src/models/CustomFieldValue.d.ts
104
- declare class CustomFieldValue extends Model {
105
- modelId: string;
106
- customFieldDefinitionId: string;
107
- value: any;
108
- createdAt?: Date;
109
- updatedAt?: Date;
110
- deletedAt?: Date;
111
- customFieldDefinition: CustomFieldDefinition;
112
- private static validateValueAgainstDefinition;
113
- static validateCustomFieldValues(instances: CustomFieldValue[]): Promise<void>;
114
- static validateCustomFieldValue(instance: CustomFieldValue): Promise<void>;
115
- static afterSaveHandler(instance: CustomFieldValue[], options: CreateOptions): void;
116
- }
117
- //#endregion
118
- //#region src/models/CustomFieldModelTypeMap.d.ts
119
- declare class CustomFieldModelTypeMap extends Model {
120
- id: string;
121
- modelTypeId: string;
122
- customFieldDefinitionId: string;
123
- customFieldDefinition: CustomFieldDefinition;
124
- createdAt?: Date;
125
- updatedAt?: Date;
126
- }
127
- //#endregion
128
- //#region src/models/CustomFieldDefinition.d.ts
129
- declare class CustomFieldDefinition extends Model {
130
- id: string;
131
- name: string;
132
- displayName?: string;
133
- fieldType: CustomFieldDefinitionType;
134
- validation?: any;
135
- entityId: string;
136
- entityType: string;
137
- modelType: string;
138
- description?: string;
139
- required?: boolean;
140
- disabled?: boolean;
141
- defaultValue?: any;
142
- createdAt?: Date;
143
- updatedAt?: Date;
144
- deletedAt?: Date;
145
- blockEditingFromUI: boolean;
146
- values: CustomFieldValue[];
147
- modelTypeMappings?: CustomFieldModelTypeMap[];
148
- private _modelTypeIds?;
149
- get modelTypeIds(): string[] | undefined;
150
- set modelTypeIds(value: string[] | undefined);
151
- static displayNameDefaultValue(instance: CustomFieldDefinition): void;
152
- static afterSaveHandler(instance: CustomFieldDefinition, options: CreateOptions): void;
153
- /**
154
- * Override toJSON to exclude internal associations from API responses
155
- * The modelTypeMappings association is used internally to optimize queries
156
- * but should not be exposed in the API response (use modelTypeIds instead)
157
- */
158
- toJSON(): object;
159
- }
160
- //#endregion
161
- //#region src/api/v1/validator/validations.d.ts
162
- interface SchemaObject {
163
- type: "object";
164
- properties?: {
165
- before?: object;
166
- after?: object;
167
- };
168
- required?: string[];
169
- allOf?: object[];
170
- anyOf?: object[];
171
- oneOf?: object[];
172
- additionalProperties?: boolean | object;
173
- $id?: string;
174
- $schema?: string;
175
- if?: object;
176
- then?: object;
177
- else?: object;
178
- }
179
- //#endregion
180
- //#region src/models/CustomValidator.d.ts
181
- declare class CustomValidator extends Model {
182
- id: string;
183
- entityId: string;
184
- entityType: string;
185
- modelType: string;
186
- schema: SchemaObject;
187
- disabled: boolean;
188
- createdAt?: Date;
189
- updatedAt?: Date;
190
- static afterSaveHandler(instance: CustomValidator, options: CreateOptions): void;
191
- }
192
- //#endregion
193
- //#region src/types/index.d.ts
194
- type ModelFetcher = (name: string) => any;
195
- interface ModelOptions {
196
- /**
197
- * Include options for the model
198
- */
199
- include?: (entityIds: string | string[]) => IncludeOptions[];
200
- /**
201
- * Custom association for the model
202
- * @param model - The model to associate with
203
- */
204
- customAssociation?: (model: ModelCtor) => void;
205
- /**
206
- * Whether to use the entity id from the instance per scope attribute
207
- */
208
- useEntityIdFromInclude?: boolean;
209
- /**
210
- * Which attributes to include in the model
211
- */
212
- attributes?: string[];
213
- }
214
- interface Models {
215
- name: string;
216
- scopeAttributes: any[];
217
- modelOptions?: ModelOptions;
218
- hasTypeId?: boolean;
219
- /**
220
- * Optional async callback to determine which custom fields are required for an instance.
221
- * Allows consumer applications to override CustomFieldDefinition.required based on custom logic.
222
- * @param instance - The model instance being created/updated
223
- * @param fieldDefinitions - Array of CustomFieldDefinition records
224
- * @param options - Sequelize options including transaction
225
- * @returns Array of field names that should be validated as required
226
- */
227
- getRequiredCustomFields?: (instance: any, fieldDefinitions: CustomFieldDefinition[], options: any) => Promise<string[]> | string[];
228
- creationWebhookHandler?: (instance: any) => any;
229
- updateWebhookHandler?: (instance: any) => any;
230
- deletionWebhookHandler?: (instance: any) => any;
231
- }
232
- interface CustomFieldOptions {
233
- models: Models[];
234
- hasTypeId?: boolean;
235
- databaseConfig: any;
236
- getUser: typeof getUser;
237
- sequelize?: Sequelize;
238
- useCustomFieldsEntries?: boolean;
239
- useValidators?: boolean;
240
- useModelTypeMapping?: boolean;
241
- /**
242
- * When true, use the legacy `sync({ alter: true })` migration approach
243
- * instead of umzug-managed migrations via the `sadot_migrations` table.
244
- * Defaults to false (umzug is used by default).
245
- */
246
- runLegacyMigrations?: boolean;
247
- getRequiredCustomFields?: (instance: any, fieldDefinitions: CustomFieldDefinition[], options: any) => Promise<string[]> | string[];
248
- /**
249
- * Optional predicate that returns true when materialized-path RLS is active for the current
250
- * request. When it returns true, sadot's `userScope` on CFD/CV becomes a no-op so RLS is the
251
- * sole filter (consumer typically decorates CFD/CV with their mat-path manager so RLS applies).
252
- * Pass `matPathManager.isScopingRequest` if using `@autofleet/mat-path-mvp`.
253
- */
254
- isMatPathEnabled?: () => boolean;
255
- }
256
- //#endregion
257
- //#region src/init-state.d.ts
258
- /**
259
- * Tracks the initialization state of sadot's useCustomFields function
260
- * Allows HealthManager to wait for initialization before passing readiness checks
261
- */
262
- declare class SadotInitializationState {
263
- private initPromise;
264
- private initError;
265
- private isInitialized;
266
- private sequelizeInstance;
267
- private ownsSequelizeInstance;
268
- /** Set the initialization promise */
269
- setInitPromise(promise: Promise<Sequelize>, ownsSequelize: boolean): void;
270
- /**
271
- * Get the Sequelize instance
272
- * Returns null if initialization hasn't completed yet, or in cases where it failed.
273
- */
274
- get sequelize(): Sequelize | null;
275
- /**
276
- * Wait for initialization to complete and return the Sequelize instance
277
- * Returns the Sequelize instance only if Sadot created it (owns it)
278
- * Returns undefined if the Sequelize instance was provided externally
279
- * Rejects when initialization fails
280
- */
281
- waitForInitialization(): Promise<Sequelize | undefined>;
282
- /** Check if initialization is complete and successful */
283
- get isReady(): boolean;
284
- /** Get the initialization error if one occurred */
285
- get error(): Error | null;
286
- }
287
- //#endregion
288
- //#region src/utils/validations/schema/custom-fields.d.ts
289
- declare const CustomFieldsSchema: Joi.ObjectSchema<Record<string, any>>;
290
- //#endregion
291
- //#region src/utils/helpers/index.d.ts
292
- /**
293
- * Builds a WHERE clause and replacements for free-text search by custom fields.
294
- *
295
- * This function constructs a WHERE clause and replacement bindings that allow searching
296
- * for a given term within custom fields associated with a specific model type and entity ID.
297
- * The WHERE clause and replacements are designed to be added to the main query.
298
- *
299
- * @param {string} searchTerm - The term to search for within custom fields.
300
- * @param {ModelStatic} model - The Sequelize model representing the entity type to search for.
301
- * @param {string} entityId - The entity ID to filter the custom fields by.
302
- * @param {CustomFieldDefinitionType[]} excludedCustomFieldsTypes - An array of custom field types
303
- * to exclude from the search
304
- *
305
- * @returns {CustomFieldsSearchPayload} - An object containing the WHERE clause and replacements
306
- * for Sequelize.
307
- */
308
- interface CustomFieldsSearchPayload {
309
- where: WhereOptions;
310
- replacements: BindOrReplacements;
311
- }
312
- declare const generateRandomString: (length?: number) => string;
313
- declare const generateCustomFieldSearchQueryPayload: (searchTerm: string, model: ModelStatic, entityId: string, customFieldsTypesToExclude?: CustomFieldDefinitionType[]) => CustomFieldsSearchPayload;
314
- //#endregion
315
- //#region src/scopes/helpers/filter.helpers.d.ts
316
- /**
317
- * Type representing possible condition values.
318
- * Currently supporting strings and arrays of strings.
319
- * More types to be added (TBA).
320
- */
321
- interface ConditionWithOperator {
322
- operator: string;
323
- value: string;
324
- }
325
- type ConditionValue = ConditionWithOperator | ConditionWithOperator[] | string | string[];
326
- //#endregion
327
- //#region src/scopes/filter.d.ts
328
- declare const customFieldsSortScope: (name: string, options?: Pick<CustomFieldOptions, "useCustomFieldsEntries">) => ({
329
- replacementsMap,
330
- scopeValue: sort
331
- }: {
332
- replacementsMap: Record<string, string>;
333
- scopeValue: Record<string, ConditionValue>;
334
- }) => {
335
- attributes: {
336
- include: (string | Literal)[][];
337
- };
338
- order: Literal[];
339
- replacements: Record<string, string>;
340
- } | Record<string, never>;
341
- //#endregion
342
- //#region src/models/CustomFieldEntries.d.ts
343
- declare class CustomFieldEntries extends Model {
344
- modelId: string;
345
- entityId: string;
346
- customFields: Record<string, any>;
347
- modelType: string;
348
- createdAt?: Date;
349
- updatedAt?: Date;
350
- static afterSaveHandler(instance: CustomFieldEntries[], options: CreateOptions): void;
351
- }
352
- //#endregion
353
- //#region src/models/FieldPolicy.d.ts
354
- type ModelMode = "full" | "partial";
355
- type ModelInclusion = {
356
- name: string;
357
- mode: "full";
358
- } | {
359
- name: string;
360
- mode: "partial";
361
- fields: string[];
362
- };
363
- declare class FieldPolicy extends Model {
364
- id: string;
365
- contextId: string;
366
- name: string;
367
- /** Base-level field names to include */
368
- fields: string[];
369
- /** Model inclusions; full = all fields, partial = only listed fields */
370
- models: ModelInclusion[];
371
- }
372
- declare namespace field_policy_d_exports {
373
- export { CreateFieldPolicyData, UpdateFieldPolicyData, create, findAllByContext, findByContextAndName, findById, remove, update };
374
- }
375
- interface CreateFieldPolicyData {
376
- contextId: string;
377
- name: string;
378
- fields?: string[];
379
- models?: ModelInclusion[];
380
- }
381
- interface UpdateFieldPolicyData {
382
- fields?: string[];
383
- models?: ModelInclusion[];
384
- }
385
- declare const findByContextAndName: (contextId: string, name: string) => Promise<FieldPolicy | null>;
386
- declare const findById: (id: string) => Promise<FieldPolicy | null>;
387
- declare const findAllByContext: (contextId: string) => Promise<FieldPolicy[]>;
388
- declare const create: ({
389
- contextId,
390
- name,
391
- fields,
392
- models
393
- }: CreateFieldPolicyData) => Promise<FieldPolicy>;
394
- declare const update: (id: string, data: UpdateFieldPolicyData) => Promise<FieldPolicy | null>;
395
- declare const remove: (id: string) => Promise<number>;
396
- //#endregion
397
17
  //#region src/index.d.ts
398
18
  declare const sadotInitState: SadotInitializationState;
399
19
  /**