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

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