@lyxa.ai/core 1.3.291 → 1.3.293

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.3.291
25
+ Version: 1.3.293
26
26
 
27
27
  ## Dependencies
28
28
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lyxa.ai/types",
3
- "version": "1.3.291",
3
+ "version": "1.3.293",
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",
@@ -1,5 +1,7 @@
1
1
  import { NotificationAccountType } from './enum';
2
2
  import { UpdateFcmTokenInputDTO } from './validation';
3
3
  export declare function removeAppInstance(fcmToken: string): Promise<void>;
4
+ export declare function removeEntityFromAppInstance(fcmToken: string): Promise<void>;
5
+ export declare function addEntityToAppInstance(deviceId: string, entityId: string): Promise<void>;
4
6
  export declare function addAppInstance(data: UpdateFcmTokenInputDTO, entityType: NotificationAccountType, entityId?: string): Promise<void>;
5
7
  export declare function updateAppInstance(data: UpdateFcmTokenInputDTO, entityType: NotificationAccountType, entityId?: string): Promise<void>;
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.removeAppInstance = removeAppInstance;
4
+ exports.removeEntityFromAppInstance = removeEntityFromAppInstance;
5
+ exports.addEntityToAppInstance = addEntityToAppInstance;
4
6
  exports.addAppInstance = addAppInstance;
5
7
  exports.updateAppInstance = updateAppInstance;
6
8
  const models_1 = require("../libraries/mongo/models");
@@ -9,6 +11,14 @@ async function removeAppInstance(fcmToken) {
9
11
  const model = models_1.AppInstanceModel;
10
12
  await model.deleteRecord({ fcmToken: fcmToken }, true);
11
13
  }
14
+ async function removeEntityFromAppInstance(fcmToken) {
15
+ const model = models_1.AppInstanceModel;
16
+ await model.updateOne({ fcmToken: fcmToken }, { $unset: { entityId: 1 } });
17
+ }
18
+ async function addEntityToAppInstance(deviceId, entityId) {
19
+ const model = models_1.AppInstanceModel;
20
+ await model.updateOne({ deviceId: deviceId }, { $set: { entityId: entityId } });
21
+ }
12
22
  async function addAppInstance(data, entityType, entityId) {
13
23
  const model = models_1.AppInstanceModel;
14
24
  await model.updateOne({ fcmToken: data.fcmToken }, {
@@ -25,8 +35,7 @@ async function addAppInstance(data, entityType, entityId) {
25
35
  async function updateAppInstance(data, entityType, entityId) {
26
36
  if (data.action === enum_1.ActionType.REMOVE) {
27
37
  if (entityId) {
28
- const model = models_1.AppInstanceModel;
29
- await model.updateOne({ fcmToken: data.fcmToken }, { $unset: { entityId: 1 } });
38
+ await removeEntityFromAppInstance(data.fcmToken);
30
39
  }
31
40
  else {
32
41
  await removeAppInstance(data.fcmToken);
@@ -1 +1 @@
1
- {"version":3,"file":"app-instance.js","sourceRoot":"/","sources":["utilities/app-instance.ts"],"names":[],"mappings":";;AAQA,8CAIC;AAKD,wCAqBC;AAED,8CAgBC;AAxDD,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,cAAc,CACnC,IAA4B,EAC5B,UAAmC,EACnC,QAAiB;IAEjB,MAAM,KAAK,GAAG,yBAA0E,CAAC;IAEzF,MAAM,KAAK,CAAC,SAAS,CACpB,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,EAC3B;QACC,IAAI,EAAE;YACL,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,UAAU,EAAE,UAAU;YACtB,QAAQ,EAAE,QAAQ;YAClB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACvB;KACD,EACD,EAAE,MAAM,EAAE,IAAI,EAAE,CAChB,CAAC;AACH,CAAC;AAEM,KAAK,UAAU,iBAAiB,CACtC,IAA4B,EAC5B,UAAmC,EACnC,QAAiB;IAEjB,IAAI,IAAI,CAAC,MAAM,KAAK,iBAAU,CAAC,MAAM,EAAE,CAAC;QACvC,IAAI,QAAQ,EAAE,CAAC;YACd,MAAM,KAAK,GAAG,yBAA0E,CAAC;YACzF,MAAM,KAAK,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QACjF,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 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\tconst model = AppInstanceModel as typeof AppInstanceModel & SoftDeleteModel<AppInstance>;\n\t\t\tawait model.updateOne({ fcmToken: data.fcmToken }, { $unset: { entityId: 1 } });\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,wDAGC;AAKD,wCAqBC;AAED,8CAeC;AAvED,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,K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Model } 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 an fcm token\n */\nexport async function addEntityToAppInstance(deviceId: string, entityId: string) {\n\tconst model = AppInstanceModel as typeof AppInstanceModel & SoftDeleteModel<AppInstance>;\n\tawait model.updateOne({ deviceId: deviceId }, { $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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lyxa.ai/core",
3
- "version": "1.3.291",
3
+ "version": "1.3.293",
4
4
  "description": "The Core system of the Lyxa services.",
5
5
  "author": "elie <42282499+Internalizable@users.noreply.github.com>",
6
6
  "license": "MIT",