@bisondesk/commons-sdk 1.0.346 → 1.0.347

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/money.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  import { Decimal } from 'decimal.js';
2
2
  export declare const roundMoney: (value: Decimal | string) => Decimal;
3
+ export declare const isAmountWithinToleranceSame: (amount1: Decimal | string, amount2: Decimal | string) => boolean;
3
4
  //# sourceMappingURL=money.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"money.d.ts","sourceRoot":"/","sources":["money.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,eAAO,MAAM,UAAU,UAAW,OAAO,GAAG,MAAM,YACc,CAAC"}
1
+ {"version":3,"file":"money.d.ts","sourceRoot":"/","sources":["money.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,eAAO,MAAM,UAAU,UAAW,OAAO,GAAG,MAAM,YACc,CAAC;AAGjE,eAAO,MAAM,2BAA2B,YAAa,OAAO,GAAG,MAAM,WAAW,OAAO,GAAG,MAAM,YACnB,CAAC"}
package/lib/money.js CHANGED
@@ -1,3 +1,4 @@
1
1
  import { Decimal } from 'decimal.js';
2
2
  export const roundMoney = (value) => new Decimal(value).toDecimalPlaces(2, Decimal.ROUND_HALF_EVEN);
3
+ export const isAmountWithinToleranceSame = (amount1, amount2) => roundMoney(amount1).minus(roundMoney(amount2)).abs().lessThanOrEqualTo(0.1);
3
4
  //# sourceMappingURL=money.js.map
package/lib/money.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"money.js","sourceRoot":"/","sources":["money.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAuB,EAAE,EAAE,CACpD,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,eAAe,CAAC,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC","sourcesContent":["import { Decimal } from 'decimal.js';\n\nexport const roundMoney = (value: Decimal | string) =>\n new Decimal(value).toDecimalPlaces(2, Decimal.ROUND_HALF_EVEN);\n"]}
1
+ {"version":3,"file":"money.js","sourceRoot":"/","sources":["money.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAuB,EAAE,EAAE,CACpD,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,eAAe,CAAC,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;AAGjE,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,OAAyB,EAAE,OAAyB,EAAE,EAAE,CAClG,UAAU,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC","sourcesContent":["import { Decimal } from 'decimal.js';\n\nexport const roundMoney = (value: Decimal | string) =>\n new Decimal(value).toDecimalPlaces(2, Decimal.ROUND_HALF_EVEN);\n\n// We tolerate a 10 cent rounding difference\nexport const isAmountWithinToleranceSame = (amount1: Decimal | string, amount2: Decimal | string) =>\n roundMoney(amount1).minus(roundMoney(amount2)).abs().lessThanOrEqualTo(0.1);\n"]}
@@ -12,6 +12,7 @@ type BaseMeta = {
12
12
  export type NewNotificationsEvent<T extends BaseMeta = BaseMeta> = {
13
13
  tenantId: string;
14
14
  notifications: NewNotification<T>[];
15
+ dedupId?: string;
15
16
  };
16
17
  type BaseNotification<T extends BaseMeta = BaseMeta> = {
17
18
  sourceId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"notifications.d.ts","sourceRoot":"/","sources":["notifications.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAg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AE,2BAA2B,CAAC;CACtC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"notifications.js","sourceRoot":"/","sources":["notifications.ts"],"names":[],"mappings":"AAEA,MAAM,CAAN,IAAY,2BAEX;AAFD,WAAY,2BAA2B;IACrC,kDAAmB,CAAA;AACrB,CAAC,EAFW,2BAA2B,GAA3B,2BAA2B,KAA3B,2BAA2B,QAEtC;AACD,MAAM,CAAN,IAAY,sBAGX;AAHD,WAAY,sBAAsB;IAChC,2CAAiB,CAAA;IACjB,uCAAa,CAAA;AACf,CAAC,EAHW,sBAAsB,GAAtB,sBAAsB,KAAtB,sBAAsB,QAGjC;AAoDD,MAAM,CAAN,IAAY,mBAGX;AAHD,WAAY,mBAAmB;IAC7B,wCAAiB,CAAA;IACjB,4CAAqB,CAAA;AACvB,CAAC,EAHW,mBAAmB,GAAnB,mBAAmB,KAAnB,mBAAmB,QAG9B","sourcesContent":["import { BusinessEntityIds } from './constants.js';\n\nexport enum GroupableNotificationOrigin {\n Message = 'message',\n}\nexport enum NotificationVisibility {\n UNREAD = 'unread',\n READ = 'read',\n}\n\ntype BaseMeta = {\n snippet?: string;\n};\n\nexport type NewNotificationsEvent<T extends BaseMeta = BaseMeta> = {\n tenantId: string;\n notifications: NewNotification<T>[];\n};\n\ntype BaseNotification<T extends BaseMeta = BaseMeta> = {\n sourceId: string; // userId\n destinationId: string; // userId\n businessEntityId: BusinessEntityIds;\n recordId: string;\n recordTitle?: string;\n meta: T;\n origin: string;\n};\n\nexport type NewNotification<T extends BaseMeta = BaseMeta> = BaseNotification<T>;\n\nexport type Notification<T extends BaseMeta = BaseMeta> = BaseNotification<T> & {\n id: string;\n createdAt: string;\n visibility: NotificationVisibility;\n archived: boolean;\n};\n\nexport type NotificationReadUpdates = {\n /* not passing a value means read all */\n notificationIds: string[] | undefined;\n origin?: GroupableNotificationOrigin;\n};\n\nexport type NotificationArchiveUpdates = {\n notificationIds: string[];\n origin?: GroupableNotificationOrigin;\n};\n\nexport type NotificationsInfo = NotificationsStats & {\n externalPushAppId?: string;\n};\n\nexport type NotificationsStats = {\n unreadCount: number;\n unseen: boolean;\n latestSeenAt?: string;\n latestNotificationAt?: string;\n};\n\nexport enum NotificationsFilter {\n Unread = 'unread',\n Archived = 'archived',\n}\n\nexport type NotificationsQuery = {\n limit?: number;\n filter?: NotificationsFilter;\n nextToken?: string;\n origin?: GroupableNotificationOrigin;\n};\n"]}
1
+ {"version":3,"file":"notifications.js","sourceRoot":"/","sources":["notifications.ts"],"names":[],"mappings":"AAEA,MAAM,CAAN,IAAY,2BAEX;AAFD,WAAY,2BAA2B;IACrC,kDAAmB,CAAA;AACrB,CAAC,EAFW,2BAA2B,GAA3B,2BAA2B,KAA3B,2BAA2B,QAEtC;AACD,MAAM,CAAN,IAAY,sBAGX;AAHD,WAAY,sBAAsB;IAChC,2CAAiB,CAAA;IACjB,uCAAa,CAAA;AACf,CAAC,EAHW,sBAAsB,GAAtB,sBAAsB,KAAtB,sBAAsB,QAGjC;AAqDD,MAAM,CAAN,IAAY,mBAGX;AAHD,WAAY,mBAAmB;IAC7B,wCAAiB,CAAA;IACjB,4CAAqB,CAAA;AACvB,CAAC,EAHW,mBAAmB,GAAnB,mBAAmB,KAAnB,mBAAmB,QAG9B","sourcesContent":["import { BusinessEntityIds } from './constants.js';\n\nexport enum GroupableNotificationOrigin {\n Message = 'message',\n}\nexport enum NotificationVisibility {\n UNREAD = 'unread',\n READ = 'read',\n}\n\ntype BaseMeta = {\n snippet?: string;\n};\n\nexport type NewNotificationsEvent<T extends BaseMeta = BaseMeta> = {\n tenantId: string;\n notifications: NewNotification<T>[];\n dedupId?: string;\n};\n\ntype BaseNotification<T extends BaseMeta = BaseMeta> = {\n sourceId: string; // userId\n destinationId: string; // userId\n businessEntityId: BusinessEntityIds;\n recordId: string;\n recordTitle?: string;\n meta: T;\n origin: string;\n};\n\nexport type NewNotification<T extends BaseMeta = BaseMeta> = BaseNotification<T>;\n\nexport type Notification<T extends BaseMeta = BaseMeta> = BaseNotification<T> & {\n id: string;\n createdAt: string;\n visibility: NotificationVisibility;\n archived: boolean;\n};\n\nexport type NotificationReadUpdates = {\n /* not passing a value means read all */\n notificationIds: string[] | undefined;\n origin?: GroupableNotificationOrigin;\n};\n\nexport type NotificationArchiveUpdates = {\n notificationIds: string[];\n origin?: GroupableNotificationOrigin;\n};\n\nexport type NotificationsInfo = NotificationsStats & {\n externalPushAppId?: string;\n};\n\nexport type NotificationsStats = {\n unreadCount: number;\n unseen: boolean;\n latestSeenAt?: string;\n latestNotificationAt?: string;\n};\n\nexport enum NotificationsFilter {\n Unread = 'unread',\n Archived = 'archived',\n}\n\nexport type NotificationsQuery = {\n limit?: number;\n filter?: NotificationsFilter;\n nextToken?: string;\n origin?: GroupableNotificationOrigin;\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bisondesk/commons-sdk",
3
- "version": "1.0.346",
3
+ "version": "1.0.347",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "build": "npx tsc --build tsconfig.deploy.json",
package/src/money.ts CHANGED
@@ -2,3 +2,7 @@ import { Decimal } from 'decimal.js';
2
2
 
3
3
  export const roundMoney = (value: Decimal | string) =>
4
4
  new Decimal(value).toDecimalPlaces(2, Decimal.ROUND_HALF_EVEN);
5
+
6
+ // We tolerate a 10 cent rounding difference
7
+ export const isAmountWithinToleranceSame = (amount1: Decimal | string, amount2: Decimal | string) =>
8
+ roundMoney(amount1).minus(roundMoney(amount2)).abs().lessThanOrEqualTo(0.1);
@@ -15,6 +15,7 @@ type BaseMeta = {
15
15
  export type NewNotificationsEvent<T extends BaseMeta = BaseMeta> = {
16
16
  tenantId: string;
17
17
  notifications: NewNotification<T>[];
18
+ dedupId?: string;
18
19
  };
19
20
 
20
21
  type BaseNotification<T extends BaseMeta = BaseMeta> = {