@autofleet/sadot 0.5.4-beta.20 → 0.5.4-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.
@@ -7,4 +7,4 @@ export declare const beforeBulkCreate: (options: any) => void;
7
7
  * A hook to create the custom fields when updating a model instance.
8
8
  * TODO - cleanup if update fail
9
9
  */
10
- export declare const beforeCreate: (scopeAttributes: string[], modelOptions: ModelOptions) => (instance: any, options: any) => Promise<void>;
10
+ export declare const beforeCreate: (scopeAttributes: string[], modelOptions?: ModelOptions) => (instance: any, options: any) => Promise<void>;
@@ -44,7 +44,7 @@ exports.beforeBulkCreate = beforeBulkCreate;
44
44
  * A hook to create the custom fields when updating a model instance.
45
45
  * TODO - cleanup if update fail
46
46
  */
47
- const beforeCreate = (scopeAttributes, modelOptions) => async (instance, options) => {
47
+ const beforeCreate = (scopeAttributes, modelOptions = {}) => async (instance, options) => {
48
48
  const { fields } = options;
49
49
  const modelType = instance.constructor.name;
50
50
  const { scopeAttributeReplacer } = modelOptions;
@@ -45,7 +45,7 @@ const serializeCustomFields = (customFieldValues, customFieldDefinitionsHash) =>
45
45
  /**
46
46
  * A hook to attach the custom fields when fetching a model instances.
47
47
  */
48
- const enrichResults = (modelType, scopeAttributes, getScope, hookType, modelOptions) => async (instancesOrInstance, options) => {
48
+ const enrichResults = (modelType, scopeAttributes, getScope, hookType, modelOptions = {}) => async (instancesOrInstance, options) => {
49
49
  const { scopeAttributeReplacer } = modelOptions;
50
50
  if (options.originalAttributes?.length > 0
51
51
  && !options.originalAttributes?.includes?.('customFields')) {
@@ -7,4 +7,4 @@ export declare const beforeBulkUpdate: (options: any) => void;
7
7
  * A hook to update the custom fields when updating a model instance.
8
8
  * TODO - cleanup if update fail
9
9
  */
10
- export declare const beforeUpdate: (scopeAttributes: string[], modelOptions: ModelOptions) => (instance: any, options: any) => Promise<void>;
10
+ export declare const beforeUpdate: (scopeAttributes: string[], modelOptions?: ModelOptions) => (instance: any, options: any) => Promise<void>;
@@ -43,7 +43,7 @@ exports.beforeBulkUpdate = beforeBulkUpdate;
43
43
  * A hook to update the custom fields when updating a model instance.
44
44
  * TODO - cleanup if update fail
45
45
  */
46
- const beforeUpdate = (scopeAttributes, modelOptions) => async (instance, options) => {
46
+ const beforeUpdate = (scopeAttributes, modelOptions = {}) => async (instance, options) => {
47
47
  logger_1.default.debug('sadot - before update hook');
48
48
  const { fields } = options;
49
49
  const { scopeAttributeReplacer } = modelOptions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/sadot",
3
- "version": "0.5.4-beta.20",
3
+ "version": "0.5.4-beta.21",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -16,7 +16,7 @@ export const beforeBulkCreate = (options): void => {
16
16
  * A hook to create the custom fields when updating a model instance.
17
17
  * TODO - cleanup if update fail
18
18
  */
19
- export const beforeCreate = (scopeAttributes: string[], modelOptions: ModelOptions) => async (
19
+ export const beforeCreate = (scopeAttributes: string[], modelOptions: ModelOptions = {}) => async (
20
20
  instance,
21
21
  options,
22
22
  ): Promise<void> => {
@@ -34,7 +34,7 @@ const enrichResults = (
34
34
  scopeAttributes: string[],
35
35
  getScope,
36
36
  hookType?: SupportedHookTypes,
37
- modelOptions?: ModelOptions,
37
+ modelOptions: ModelOptions = {},
38
38
  ) => async (
39
39
  instancesOrInstance: any | any[],
40
40
  options,
@@ -16,7 +16,7 @@ export const beforeBulkUpdate = (options): void => {
16
16
  * A hook to update the custom fields when updating a model instance.
17
17
  * TODO - cleanup if update fail
18
18
  */
19
- export const beforeUpdate = (scopeAttributes: string[], modelOptions: ModelOptions) => async (
19
+ export const beforeUpdate = (scopeAttributes: string[], modelOptions: ModelOptions = {}) => async (
20
20
  instance,
21
21
  options,
22
22
  ): Promise<void> => {
@@ -6,7 +6,7 @@ export type ModelOptions = {
6
6
  export type Models = {
7
7
  name: string;
8
8
  scopeAttributes: string[];
9
- modelOptions?: ModelOptions
9
+ modelOptions?: ModelOptions;
10
10
  creationWebhookHandler?: (instance: any) => any;
11
11
  updateWebhookHandler?: (instance: any) => any;
12
12
  deletionWebhookHandler?: (instance: any) => any;