@lyxa.ai/core 1.4.96 → 1.4.97

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.
@@ -22,7 +22,7 @@ Perfect for sharing types between frontend and backend applications.
22
22
 
23
23
  ## Version
24
24
 
25
- Version: 1.4.96
25
+ Version: 1.4.97
26
26
 
27
27
  ## Dependencies
28
28
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lyxa.ai/types",
3
- "version": "1.4.96",
3
+ "version": "1.4.97",
4
4
  "description": "Lyxa type definitions and validation schemas for both frontend and backend",
5
5
  "author": "elie <42282499+Internalizable@users.noreply.github.com>",
6
6
  "license": "MIT",
@@ -17,7 +17,13 @@ async function removeEntityFromAppInstance(fcmToken) {
17
17
  }
18
18
  async function addEntityToAppInstance(deviceId, entityType, entityId) {
19
19
  const model = models_1.AppInstanceModel;
20
- await model.updateOne({ deviceId: deviceId, entityType: entityType }, { $set: { entityId: entityId } });
20
+ const entityTypeQuery = [enum_1.NotificationAccountType.SHOP, enum_1.NotificationAccountType.PROFESSIONAL].includes(entityType)
21
+ ? { $in: [enum_1.NotificationAccountType.SHOP, enum_1.NotificationAccountType.PROFESSIONAL] }
22
+ : entityType;
23
+ await model.updateOne({
24
+ deviceId,
25
+ entityType: entityTypeQuery,
26
+ }, { $set: { entityId, entityType } });
21
27
  }
22
28
  async function addAppInstance(data, entityType, entityId) {
23
29
  const model = models_1.AppInstanceModel;
@@ -1 +1 @@
1
- {"version":3,"file":"app-instance.js","sourceRoot":"/","sources":["utilities/app-instance.ts"],"names":[],"mappings":";;AAQA,8CAIC;AAKD,kEAGC;AAKD,wDAOC;AAKD,wCAqBC;AAED,8CAeC;AA3ED,sDAA0E;AAE1E,iCAA6D;AAMtD,KAAK,UAAU,iBAAiB,CAAC,QAAgB;IACvD,MAAM,KAAK,GAAG,yBAA0E,CAAC;IAEzF,MAAM,KAAK,CAAC,YAAY,CAAC,EAAE,QAAQ,EAAE,QAAQ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CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAClD,CAAC;aAAM,CAAC;YACP,MAAM,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACxC,CAAC;IACF,CAAC;IACD,IAAI,IAAI,CAAC,MAAM,KAAK,iBAAU,CAAC,GAAG,EAAE,CAAC;QACpC,MAAM,cAAc,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;IAClD,CAAC;AACF,CAAC","sourcesContent":["import { AppInstance, AppInstanceModel } from '../libraries/mongo/models';\nimport { SoftDeleteModel } from '../libraries/mongo/plugins/soft-delete-plugin';\nimport { ActionType, NotificationAccountType } from './enum';\nimport { UpdateFcmTokenInputDTO } from './validation';\n\n/**\n * A helper to remove record of an app instance using an fcm token\n */\nexport async function removeAppInstance(fcmToken: string) {\n\tconst model = AppInstanceModel as typeof AppInstanceModel & SoftDeleteModel<AppInstance>;\n\n\tawait model.deleteRecord({ fcmToken: fcmToken }, true);\n}\n\n/**\n * A helper to remove the entity from an app instance using an fcm token\n */\nexport async function removeEntityFromAppInstance(fcmToken: string) {\n\tconst model = AppInstanceModel as typeof AppInstanceModel & SoftDeleteModel<AppInstance>;\n\tawait model.updateOne({ fcmToken: fcmToken }, { $unset: { entityId: 1 } });\n}\n\n/**\n * A helper to add the entity to an app instance using device id and entity type\n */\nexport async function addEntityToAppInstance(\n\tdeviceId: string,\n\tentityType: NotificationAccountType,\n\tentityId: string\n) {\n\tconst model = AppInstanceModel as typeof AppInstanceModel & SoftDeleteModel<AppInstance>;\n\tawait model.updateOne({ deviceId: deviceId, entityType: entityType }, { $set: { entityId: entityId } });\n}\n\n/**\n * A helper to add record of an app instance\n */\nexport async function addAppInstance(\n\tdata: UpdateFcmTokenInputDTO,\n\tentityType: NotificationAccountType,\n\tentityId?: string\n) {\n\tconst model = AppInstanceModel as typeof AppInstanceModel & SoftDeleteModel<AppInstance>;\n\n\tawait model.updateOne(\n\t\t{ fcmToken: data.fcmToken },\n\t\t{\n\t\t\t$set: {\n\t\t\t\tdeviceId: data.deviceId,\n\t\t\t\tentityType: entityType,\n\t\t\t\tentityId: entityId,\n\t\t\t\tplatform: data.platform,\n\t\t\t\tappVersion: data.appVersion,\n\t\t\t\tfcmToken: data.fcmToken,\n\t\t\t},\n\t\t},\n\t\t{ upsert: true }\n\t);\n}\n\nexport async function updateAppInstance(\n\tdata: UpdateFcmTokenInputDTO,\n\tentityType: NotificationAccountType,\n\tentityId?: string\n) {\n\tif (data.action === ActionType.REMOVE) {\n\t\tif (entityId) {\n\t\t\tawait removeEntityFromAppInstance(data.fcmToken);\n\t\t} else {\n\t\t\tawait removeAppInstance(data.fcmToken);\n\t\t}\n\t}\n\tif (data.action === ActionType.ADD) {\n\t\tawait addAppInstance(data, entityType, entityId);\n\t}\n}\n"]}
1
+ {"version":3,"file":"app-instance.js","sourceRoot":"/","sources":["utilities/app-instance.ts"],"names":[],"mappings":";;AAQA,8CAIC;AAKD,kEAGC;AAKD,wDAmBC;AAKD,wCAqBC;AAED,8CAeC;AAvFD,sDAA0E;AAE1E,iCAA6D;AAMtD,KAAK,UAAU,iBAAiB,CAAC,QAAgB;IACvD,MAAM,KAAK,GAAG,yBAA0E,CAAC;IAEzF,MAAM,KAAK,CAAC,YAAY,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,IAAI,CAAC,CAAC;AACxD,CAAC;AAKM,KAAK,UAAU,2BAA2B,CAAC,QAAgB;IACjE,MAAM,KAAK,GAAG,yBAA0E,CAAC;IACzF,MAAM,KAAK,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;AAC5E,CAAC;AAKM,KAAK,UAAU,sBAAsB,CAC3C,QAAgB,EAChB,UAAmC,EACnC,QAAgB;IAEhB,MAAM,KAAK,GAAG,yBAA0E,CAAC;IACzF,MAAM,eAAe,GAAG,CAAC,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GAAG,EAAE,CAAC;QACpC,MAAM,cAAc,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;IAClD,CAAC;AACF,CAAC","sourcesContent":["import { AppInstance, AppInstanceModel } from '../libraries/mongo/models';\nimport { SoftDeleteModel } from '../libraries/mongo/plugins/soft-delete-plugin';\nimport { ActionType, NotificationAccountType } from './enum';\nimport { UpdateFcmTokenInputDTO } from './validation';\n\n/**\n * A helper to remove record of an app instance using an fcm token\n */\nexport async function removeAppInstance(fcmToken: string) {\n\tconst model = AppInstanceModel as typeof AppInstanceModel & SoftDeleteModel<AppInstance>;\n\n\tawait model.deleteRecord({ fcmToken: fcmToken }, true);\n}\n\n/**\n * A helper to remove the entity from an app instance using an fcm token\n */\nexport async function removeEntityFromAppInstance(fcmToken: string) {\n\tconst model = AppInstanceModel as typeof AppInstanceModel & SoftDeleteModel<AppInstance>;\n\tawait model.updateOne({ fcmToken: fcmToken }, { $unset: { entityId: 1 } });\n}\n\n/**\n * A helper to add the entity to an app instance using device id and entity type\n */\nexport async function addEntityToAppInstance(\n\tdeviceId: string,\n\tentityType: NotificationAccountType,\n\tentityId: string\n) {\n\tconst model = AppInstanceModel as typeof AppInstanceModel & SoftDeleteModel<AppInstance>;\n\tconst entityTypeQuery = [NotificationAccountType.SHOP, NotificationAccountType.PROFESSIONAL].includes(\n\t\tentityType\n\t)\n\t\t? { $in: [NotificationAccountType.SHOP, NotificationAccountType.PROFESSIONAL] }\n\t\t: entityType;\n\n\tawait model.updateOne(\n\t\t{\n\t\t\tdeviceId,\n\t\t\tentityType: entityTypeQuery,\n\t\t},\n\t\t{ $set: { entityId, entityType } }\n\t);\n}\n\n/**\n * A helper to add record of an app instance\n */\nexport async function addAppInstance(\n\tdata: UpdateFcmTokenInputDTO,\n\tentityType: NotificationAccountType,\n\tentityId?: string\n) {\n\tconst model = AppInstanceModel as typeof AppInstanceModel & SoftDeleteModel<AppInstance>;\n\n\tawait model.updateOne(\n\t\t{ fcmToken: data.fcmToken },\n\t\t{\n\t\t\t$set: {\n\t\t\t\tdeviceId: data.deviceId,\n\t\t\t\tentityType: entityType,\n\t\t\t\tentityId: entityId,\n\t\t\t\tplatform: data.platform,\n\t\t\t\tappVersion: data.appVersion,\n\t\t\t\tfcmToken: data.fcmToken,\n\t\t\t},\n\t\t},\n\t\t{ upsert: true }\n\t);\n}\n\nexport async function updateAppInstance(\n\tdata: UpdateFcmTokenInputDTO,\n\tentityType: NotificationAccountType,\n\tentityId?: string\n) {\n\tif (data.action === ActionType.REMOVE) {\n\t\tif (entityId) {\n\t\t\tawait removeEntityFromAppInstance(data.fcmToken);\n\t\t} else {\n\t\t\tawait removeAppInstance(data.fcmToken);\n\t\t}\n\t}\n\tif (data.action === ActionType.ADD) {\n\t\tawait addAppInstance(data, entityType, entityId);\n\t}\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lyxa.ai/core",
3
- "version": "1.4.96",
3
+ "version": "1.4.97",
4
4
  "description": "The Core system of the Lyxa services.",
5
5
  "author": "elie <42282499+Internalizable@users.noreply.github.com>",
6
6
  "license": "MIT",