@lyxa.ai/core 1.3.31 → 1.3.33

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.
@@ -23,6 +23,7 @@ let LyxaLogger = class LyxaLogger {
23
23
  constructor(identifier, mongoURI) {
24
24
  this.logDirectory = path_1.default.join(process.cwd(), 'logs');
25
25
  this.ensureLogDirectoryExists();
26
+ const baseLevel = process.env.NODE_ENV === 'DEV' || process.env.NODE_ENV === undefined ? 'debug' : 'info';
26
27
  const transports = pino_1.pino.transport({
27
28
  targets: [
28
29
  {
@@ -30,7 +31,7 @@ let LyxaLogger = class LyxaLogger {
30
31
  options: {
31
32
  colorize: true,
32
33
  },
33
- level: 'info',
34
+ level: baseLevel,
34
35
  },
35
36
  {
36
37
  target: 'pino/file',
@@ -51,7 +52,7 @@ let LyxaLogger = class LyxaLogger {
51
52
  ],
52
53
  });
53
54
  this._logger = (0, pino_1.pino)({
54
- level: 'info',
55
+ level: baseLevel,
55
56
  }, transports);
56
57
  }
57
58
  ensureLogDirectoryExists() {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["libraries/logger/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,+BAAoC;AACpC,mCAAiC;AAG1B,IAAM,UAAU,GAAhB,MAAM,UAAU;IACL,OAAO,CAAS;IAChB,YAAY,CAAS;IAEtC,YAAY,UAAkB,EAAE,QAAgB;QAC/C,IAAI,CAAC,YAAY,GAAG,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,CAAC,CAAC;QAErD,IAAI,CAAC,wBAAwB,EAAE,CAAC;QAEhC,MAAM,UAAU,GAAG,WAAI,CAAC,SAAS,CAAC;YACjC,OAAO,EAAE;gBACR;oBACC,MAAM,EAAE,aAAa;oBACrB,OAAO,EAAE;wBACR,QAAQ,EAAE,IAAI;qBACd;oBACD,KAAK,EAAE,MAAM;iBACb;gBACD;oBACC,MAAM,EAAE,WAAW;oBACnB,OAAO,EAAE;wBACR,WAAW,EAAE,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,WAAW,CAAC;qBACtD;oBACD,KAAK,EAAE,OAAO;iBACd;gBACD;oBACC,MAAM,EAAE,cAAc;oBACtB,OAAO,EAAE;wBACR,GAAG,EAAE,QAAQ;wBACb,QAAQ,EAAE,WAAW;wBACrB,UAAU,EAAE,UAAU;qBACtB;oBACD,KAAK,EAAE,OAAO;iBACd;aACD;SACD,CAAC,CAAC;QAEH,IAAI,CAAC,OAAO,GAAG,IAAA,WAAI,EAClB;YACC,KAAK,EAAE,MAAM;SACb,EACD,UAAU,CACV,CAAC;IACH,CAAC;IAEO,wBAAwB;QAC/B,IAAI,CAAC;YACJ,YAAE,CAAC,SAAS,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACtD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,OAAO,CAAC,KAAK,CAAC,iCAAiC,EAAE,KAAK,CAAC,CAAC;QACzD,CAAC;IACF,CAAC;IAED,IAAI,MAAM;QACT,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;CACD,CAAA;AAxDY,gCAAU;qBAAV,UAAU;IADtB,IAAA,gBAAO,GAAE;;GACG,UAAU,CAwDtB","sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport { pino, Logger } from 'pino';\nimport { Service } from 'typedi';\n\n@Service()\nexport class LyxaLogger {\n\tprivate readonly _logger: Logger;\n\tprivate readonly logDirectory: string;\n\n\tconstructor(identifier: string, mongoURI: string) {\n\t\tthis.logDirectory = path.join(process.cwd(), 'logs');\n\n\t\tthis.ensureLogDirectoryExists();\n\n\t\tconst transports = pino.transport({\n\t\t\ttargets: [\n\t\t\t\t{\n\t\t\t\t\ttarget: 'pino-pretty',\n\t\t\t\t\toptions: {\n\t\t\t\t\t\tcolorize: true,\n\t\t\t\t\t},\n\t\t\t\t\tlevel: 'info',\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttarget: 'pino/file',\n\t\t\t\t\toptions: {\n\t\t\t\t\t\tdestination: path.join(this.logDirectory, 'error.log'),\n\t\t\t\t\t},\n\t\t\t\t\tlevel: 'error',\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttarget: 'pino-mongodb',\n\t\t\t\t\toptions: {\n\t\t\t\t\t\turi: mongoURI,\n\t\t\t\t\t\tdatabase: 'lyxa-logs',\n\t\t\t\t\t\tcollection: identifier,\n\t\t\t\t\t},\n\t\t\t\t\tlevel: 'error',\n\t\t\t\t},\n\t\t\t],\n\t\t});\n\n\t\tthis._logger = pino(\n\t\t\t{\n\t\t\t\tlevel: 'info',\n\t\t\t},\n\t\t\ttransports\n\t\t);\n\t}\n\n\tprivate ensureLogDirectoryExists(): void {\n\t\ttry {\n\t\t\tfs.mkdirSync(this.logDirectory, { recursive: true });\n\t\t} catch (error) {\n\t\t\tconsole.error('Failed to create log directory:', error);\n\t\t}\n\t}\n\n\tget logger(): Logger {\n\t\treturn this._logger;\n\t}\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["libraries/logger/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,+BAAoC;AACpC,mCAAiC;AAG1B,IAAM,UAAU,GAAhB,MAAM,UAAU;IACL,OAAO,CAAS;IAChB,YAAY,CAAS;IAEtC,YAAY,UAAkB,EAAE,QAAgB;QAC/C,IAAI,CAAC,YAAY,GAAG,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,CAAC,CAAC;QAErD,IAAI,CAAC,wBAAwB,EAAE,CAAC;QAEhC,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;QAE1G,MAAM,UAAU,GAAG,WAAI,CAAC,SAAS,CAAC;YACjC,OAAO,EAAE;gBACR;oBACC,MAAM,EAAE,aAAa;oBACrB,OAAO,EAAE;wBACR,QAAQ,EAAE,IAAI;qBACd;oBACD,KAAK,EAAE,SAAS;iBAChB;gBACD;oBACC,MAAM,EAAE,WAAW;oBACnB,OAAO,EAAE;wBACR,WAAW,EAAE,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,WAAW,CAAC;qBACtD;oBACD,KAAK,EAAE,OAAO;iBACd;gBACD;oBACC,MAAM,EAAE,cAAc;oBACtB,OAAO,EAAE;wBACR,GAAG,EAAE,QAAQ;wBACb,QAAQ,EAAE,WAAW;wBACrB,UAAU,EAAE,UAAU;qBACtB;oBACD,KAAK,EAAE,OAAO;iBACd;aACD;SACD,CAAC,CAAC;QAEH,IAAI,CAAC,OAAO,GAAG,IAAA,WAAI,EAClB;YACC,KAAK,EAAE,SAAS;SAChB,EACD,UAAU,CACV,CAAC;IACH,CAAC;IAEO,wBAAwB;QAC/B,IAAI,CAAC;YACJ,YAAE,CAAC,SAAS,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACtD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,OAAO,CAAC,KAAK,CAAC,iCAAiC,EAAE,KAAK,CAAC,CAAC;QACzD,CAAC;IACF,CAAC;IAED,IAAI,MAAM;QACT,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;CACD,CAAA;AA1DY,gCAAU;qBAAV,UAAU;IADtB,IAAA,gBAAO,GAAE;;GACG,UAAU,CA0DtB","sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport { Logger, pino } from 'pino';\nimport { Service } from 'typedi';\n\n@Service()\nexport class LyxaLogger {\n\tprivate readonly _logger: Logger;\n\tprivate readonly logDirectory: string;\n\n\tconstructor(identifier: string, mongoURI: string) {\n\t\tthis.logDirectory = path.join(process.cwd(), 'logs');\n\n\t\tthis.ensureLogDirectoryExists();\n\n\t\tconst baseLevel = process.env.NODE_ENV === 'DEV' || process.env.NODE_ENV === undefined ? 'debug' : 'info';\n\n\t\tconst transports = pino.transport({\n\t\t\ttargets: [\n\t\t\t\t{\n\t\t\t\t\ttarget: 'pino-pretty',\n\t\t\t\t\toptions: {\n\t\t\t\t\t\tcolorize: true,\n\t\t\t\t\t},\n\t\t\t\t\tlevel: baseLevel,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttarget: 'pino/file',\n\t\t\t\t\toptions: {\n\t\t\t\t\t\tdestination: path.join(this.logDirectory, 'error.log'),\n\t\t\t\t\t},\n\t\t\t\t\tlevel: 'error',\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\ttarget: 'pino-mongodb',\n\t\t\t\t\toptions: {\n\t\t\t\t\t\turi: mongoURI,\n\t\t\t\t\t\tdatabase: 'lyxa-logs',\n\t\t\t\t\t\tcollection: identifier,\n\t\t\t\t\t},\n\t\t\t\t\tlevel: 'error',\n\t\t\t\t},\n\t\t\t],\n\t\t});\n\n\t\tthis._logger = pino(\n\t\t\t{\n\t\t\t\tlevel: baseLevel,\n\t\t\t},\n\t\t\ttransports\n\t\t);\n\t}\n\n\tprivate ensureLogDirectoryExists(): void {\n\t\ttry {\n\t\t\tfs.mkdirSync(this.logDirectory, { recursive: true });\n\t\t} catch (error) {\n\t\t\tconsole.error('Failed to create log directory:', error);\n\t\t}\n\t}\n\n\tget logger(): Logger {\n\t\treturn this._logger;\n\t}\n}\n"]}
@@ -1,6 +1,4 @@
1
- import { Ref } from '@typegoose/typegoose';
2
1
  import { PriceOption, ProductType } from '../../../../utilities/enum';
3
- import { ProductMarketing } from '../product-marketing.model';
4
2
  import { PriceBreakdown } from './price-breakdown.model';
5
3
  export declare class ProductSnap {
6
4
  name: string;
@@ -15,5 +13,4 @@ export declare class ProductSnap {
15
13
  isStockEnabled?: boolean;
16
14
  stockQuantity?: number;
17
15
  orderQuantityLimit?: number;
18
- productMarketing?: Ref<ProductMarketing>;
19
16
  }
@@ -12,7 +12,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.ProductSnap = void 0;
13
13
  const typegoose_1 = require("@typegoose/typegoose");
14
14
  const enum_1 = require("../../../../utilities/enum");
15
- const product_marketing_model_1 = require("../product-marketing.model");
16
15
  const price_breakdown_model_1 = require("./price-breakdown.model");
17
16
  class ProductSnap {
18
17
  name;
@@ -27,7 +26,6 @@ class ProductSnap {
27
26
  isStockEnabled;
28
27
  stockQuantity;
29
28
  orderQuantityLimit;
30
- productMarketing;
31
29
  }
32
30
  exports.ProductSnap = ProductSnap;
33
31
  __decorate([
@@ -78,8 +76,4 @@ __decorate([
78
76
  (0, typegoose_1.prop)({ type: Number, min: 0, max: 999999999 }),
79
77
  __metadata("design:type", Number)
80
78
  ], ProductSnap.prototype, "orderQuantityLimit", void 0);
81
- __decorate([
82
- (0, typegoose_1.prop)({ ref: () => product_marketing_model_1.ProductMarketing }),
83
- __metadata("design:type", Object)
84
- ], ProductSnap.prototype, "productMarketing", void 0);
85
79
  //# sourceMappingURL=product-snap.model.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"product-snap.model.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/product-snap.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAiD;AACjD,qDAAsE;AACtE,wEAA8D;AAC9D,mEAAyD;AAEzD,MAAa,WAAW;IAEhB,IAAI,CAAU;IAGd,OAAO,CAAU;IAGjB,WAAW,CAAe;IAG1B,IAAI,CAAU;IAGd,MAAM,CAAY;IAGlB,WAAW,CAAe;IAG1B,eAAe,CAAoB;IAGnC,WAAW,CAAU;IAGrB,eAAe,CAAW;IAG1B,cAAc,CAAW;IAGzB,aAAa,CAAU;IAGvB,kBAAkB,CAAU;IAG5B,gBAAgB,CAAyB;CAChD;A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":["import { prop, Ref } from '@typegoose/typegoose';\nimport { PriceOption, ProductType } from '../../../../utilities/enum';\nimport { ProductMarketing } from '../product-marketing.model';\nimport { PriceBreakdown } from './price-breakdown.model';\n\nexport class ProductSnap {\n\t@prop({ required: true, type: String })\n\tpublic name!: string;\n\n\t@prop({ type: String })\n\tpublic barcode?: string;\n\n\t@prop({ type: String, enum: ProductType })\n\tpublic productType?: ProductType;\n\n\t@prop({ type: String })\n\tpublic logo?: string;\n\n\t@prop({ type: [String], default: [] })\n\tpublic images?: string[];\n\n\t@prop({ type: String, enum: PriceOption })\n\tpublic priceOption?: PriceOption;\n\n\t@prop({ type: [PriceBreakdown] })\n\tpublic priceBreakdowns?: PriceBreakdown[];\n\n\t@prop({ type: String })\n\tpublic description?: string;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isDrinkIncluded?: boolean;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isStockEnabled?: boolean;\n\n\t@prop({ type: Number })\n\tpublic stockQuantity?: number;\n\n\t@prop({ type: Number, min: 0, max: 999999999 })\n\tpublic orderQuantityLimit?: number;\n\n\t@prop({ ref: () => ProductMarketing })\n\tpublic productMarketing?: Ref<ProductMarketing>;\n}\n"]}
1
+ {"version":3,"file":"product-snap.model.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/product-snap.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAiD;AACjD,qDAAsE;AAEtE,mEAAyD;AAEzD,MAAa,WAAW;IAEhB,IAAI,CAAU;IAGd,OAAO,CAAU;IAGjB,WAAW,CAAe;IAG1B,IAAI,CAAU;IAGd,MAAM,CAAY;IAGlB,WAAW,CAAe;IAG1B,eAAe,CAAoB;IAGnC,WAAW,CAAU;IAGrB,eAAe,CAAW;IAG1B,cAAc,CAAW;IAGzB,aAAa,CAAU;IAGvB,kBAAkB,CAAU;CACnC;AApCD,kCAoCC;AAlCO;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;yCAClB;AAGd;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;4CACC;AAGjB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,kBAAW,EAAE,CAAC;;gDACT;AAG1B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;yCACF;AAGd;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;;2CACb;AAGlB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,kBAAW,EAAE,CAAC;;gDACT;AAG1B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,CAAC,sCAAc,CAAC,EAAE,CAAC;;oDACS;AAGnC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;gDACK;AAGrB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;oDACP;AAG1B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;mDACR;AAGzB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;kDACO;AAGvB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC;;uDACZ","sourcesContent":["import { prop, Ref } from '@typegoose/typegoose';\nimport { PriceOption, ProductType } from '../../../../utilities/enum';\nimport { ProductMarketing } from '../product-marketing.model';\nimport { PriceBreakdown } from './price-breakdown.model';\n\nexport class ProductSnap {\n\t@prop({ required: true, type: String })\n\tpublic name!: string;\n\n\t@prop({ type: String })\n\tpublic barcode?: string;\n\n\t@prop({ type: String, enum: ProductType })\n\tpublic productType?: ProductType;\n\n\t@prop({ type: String })\n\tpublic logo?: string;\n\n\t@prop({ type: [String], default: [] })\n\tpublic images?: string[];\n\n\t@prop({ type: String, enum: PriceOption })\n\tpublic priceOption?: PriceOption;\n\n\t@prop({ type: [PriceBreakdown] })\n\tpublic priceBreakdowns?: PriceBreakdown[];\n\n\t@prop({ type: String })\n\tpublic description?: string;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isDrinkIncluded?: boolean;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isStockEnabled?: boolean;\n\n\t@prop({ type: Number })\n\tpublic stockQuantity?: number;\n\n\t@prop({ type: Number, min: 0, max: 999999999 })\n\tpublic orderQuantityLimit?: number;\n}\n"]}
@@ -12,6 +12,7 @@ import { Category } from './category.model';
12
12
  import { Marketing } from './marketing.model';
13
13
  import { ProductSnap } from './embedded/product-snap.model';
14
14
  import { CartParticipant } from './cart-participant.model';
15
+ import { ProductMarketing } from './product-marketing.model';
15
16
  export declare class LineItem extends TimeStamps {
16
17
  cart: Ref<Cart>;
17
18
  user: Ref<User>;
@@ -22,6 +23,7 @@ export declare class LineItem extends TimeStamps {
22
23
  product: Ref<Product>;
23
24
  productSnap?: ProductSnap;
24
25
  marketings?: Ref<Marketing>[];
26
+ productMarketings?: Ref<ProductMarketing>[];
25
27
  quantity: number;
26
28
  priceOption?: PriceOption;
27
29
  priceBreakdown: OrderPriceBreakdown;
@@ -24,6 +24,7 @@ const category_model_1 = require("./category.model");
24
24
  const marketing_model_1 = require("./marketing.model");
25
25
  const product_snap_model_1 = require("./embedded/product-snap.model");
26
26
  const cart_participant_model_1 = require("./cart-participant.model");
27
+ const product_marketing_model_1 = require("./product-marketing.model");
27
28
  let LineItem = class LineItem extends defaultClasses_1.TimeStamps {
28
29
  cart;
29
30
  user;
@@ -34,6 +35,7 @@ let LineItem = class LineItem extends defaultClasses_1.TimeStamps {
34
35
  product;
35
36
  productSnap;
36
37
  marketings;
38
+ productMarketings;
37
39
  quantity;
38
40
  priceOption;
39
41
  priceBreakdown;
@@ -87,6 +89,10 @@ __decorate([
87
89
  (0, typegoose_1.prop)({ ref: () => marketing_model_1.Marketing, default: [] }),
88
90
  __metadata("design:type", Array)
89
91
  ], LineItem.prototype, "marketings", void 0);
92
+ __decorate([
93
+ (0, typegoose_1.prop)({ ref: () => product_marketing_model_1.ProductMarketing, default: [] }),
94
+ __metadata("design:type", Array)
95
+ ], LineItem.prototype, "productMarketings", void 0);
90
96
  __decorate([
91
97
  (0, typegoose_1.prop)({ min: 1, default: 1 }),
92
98
  __metadata("design:type", Number)
@@ -1 +1 @@
1
- {"version":3,"file":"line-item.model.js","sourceRoot":"/","sources":["libraries/mongo/models/line-item.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA0F;AAC1F,4EAAqE;AACrE,6CAAoC;AACpC,mDAA0C;AAC1C,4EAAuE;AACvE,kDAAgE;AAChE,oFAAyE;AACzE,6CAAoC;AACpC,6CAAoC;AACpC,iDAAwC;AACxC,qDAA4C;AAC5C,uDAA8C;AAC9C,sEAA4D;AAE5D,qEAA2D;AAqBpD,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,2BAAU;IAEhC,IAAI,CAAa;IAGjB,IAAI,CAAa;IAGjB,IAAI,CAAa;IAGjB,MAAM,CAAc;IAGpB,QAAQ,CAAY;IAGpB,QAAQ,CAAiB;IAGzB,OAAO,CAAgB;IAGvB,WAAW,CAAe;IAG1B,UAAU,CAAoB;IAG9B,QAAQ,CAAS;IAGjB,WAAW,CAAe;IAG1B,cAAc,CAAsB;IAGpC,UAAU,CAAyB;IAGnC,kBAAkB,CAAY;IAG9B,mBAAmB,CAAU;IAG7B,eAAe,CAA2B;IAG1C,UAAU,CAAU;IAGpB,iBAAiB,CAAU;IAG3B,wBAAwB,CAAW;IAGnC,gBAAgB,CAAS;IAGzB,MAAM,CAAU;IAGhB,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I,EAAE,MAAM,EAAE,CAAC;;8CACM;AAGtB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;;8CACV;AASrB;IAPN,IAAA,gBAAI,EAAC;QACL,GAAG,EAAE,GAAG,EAAE,CAAC,wCAAe;QAC1B,YAAY,EAAE,MAAM;QACpB,UAAU,EAAE,MAAM;QAClB,OAAO,EAAE,IAAI;QACb,KAAK,EAAE,CAAC,GAAa,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC;KAC9C,CAAC;;iDAC4C;mBA7ElC,QAAQ;IAhBpB,IAAA,wBAAY,EAAC;QACb,aAAa,EAAE;YACd,UAAU,EAAE,WAAW;YACvB,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;YAC1B,QAAQ,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;SAC5B;QACD,OAAO,EAAE;YACR,UAAU,EAAE,oBAAQ,CAAC,KAAK;SAC1B;KACD,CAAC;IACD,IAAA,iBAAK,EAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;IAClB,IAAA,iBAAK,EAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;IAC3B,IAAA,iBAAK,EAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;IACrB,IAAA,iBAAK,EAAC,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC;IAC1B,IAAA,iBAAK,EAAC,EAAE,IAAI,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;IAChC,IAAA,iBAAK,EAAC,EAAE,IAAI,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;GACpB,QAAQ,CA8EpB","sourcesContent":["import { prop, Ref, index, modelOptions, Severity, mongoose } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { Cart } from './cart.model';\nimport { Product } from './product.model';\nimport { OrderPriceBreakdown } from './embedded/price-breakdown.model';\nimport { ItemType, PriceOption } from '../../../utilities/enum';\nimport { LineItemAttribute } from './embedded/line-item-attribute.model';\nimport { User } from './user.model';\nimport { Shop } from './shop.model';\nimport { Parent } from './parent.model';\nimport { Category } from './category.model';\nimport { Marketing } from './marketing.model';\nimport { ProductSnap } from './embedded/product-snap.model';\nimport { Schema } from 'zod';\nimport { CartParticipant } from './cart-participant.model';\n\n/**\n * LineItem model - Represents individual items in a cart\n */\n@modelOptions({\n\tschemaOptions: {\n\t\tcollection: 'lineItems',\n\t\ttoJSON: { virtuals: true },\n\t\ttoObject: { virtuals: true },\n\t},\n\toptions: {\n\t\tallowMixed: Severity.ALLOW,\n\t},\n})\n@index({ cart: 1 })\n@index({ cart: 1, user: 1 })\n@index({ product: 1 })\n@index({ lineItemHash: 1 })\n@index({ shop: 1, deletedAt: 1 })\n@index({ shop: 1, createdAt: 1 })\nexport class LineItem extends TimeStamps {\n\t@prop({ required: true, ref: () => Cart })\n\tpublic cart!: Ref<Cart>;\n\n\t@prop({ required: true, ref: () => User })\n\tpublic user!: Ref<User>;\n\n\t@prop({ required: true, ref: () => Shop })\n\tpublic shop!: Ref<Shop>;\n\n\t@prop({ required: true, ref: () => Parent })\n\tpublic parent: Ref<Parent>;\n\n\t@prop({ required: true, type: String, enum: ItemType })\n\tpublic itemType!: ItemType;\n\n\t@prop({ required: true, ref: () => Category })\n\tpublic category!: Ref<Category>;\n\n\t@prop({ required: true, ref: () => Product })\n\tpublic product!: Ref<Product>;\n\n\t@prop({ type: ProductSnap, _id: false })\n\tpublic productSnap?: ProductSnap;\n\n\t@prop({ ref: () => Marketing, default: [] })\n\tpublic marketings?: Ref<Marketing>[];\n\n\t@prop({ min: 1, default: 1 })\n\tpublic quantity: number;\n\n\t@prop({ type: String, enum: PriceOption, default: PriceOption.SINGLE_PRICE })\n\tpublic priceOption?: PriceOption;\n\n\t@prop({ required: true, type: OrderPriceBreakdown })\n\tpublic priceBreakdown: OrderPriceBreakdown;\n\n\t@prop({ type: () => [[LineItemAttribute]], default: [] })\n\tpublic attributes?: LineItemAttribute[][];\n\n\t@prop({ type: () => [String], default: [] })\n\tpublic removedIngredients?: string[];\n\n\t@prop({ type: String })\n\tpublic specialInstructions?: string;\n\n\t@prop({ type: mongoose.Schema.Types.Mixed })\n\tpublic calculationSnap?: Record<string, unknown>;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isAdjusted: boolean;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isPartialAdjusted: boolean;\n\n\t@prop({ type: Boolean })\n\tpublic isCreatedAfterAdjustment?: boolean;\n\n\t@prop({ default: 0 })\n\tpublic adjustedQuantity: number;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isB1G1: boolean;\n\n\t@prop({ type: String })\n\tpublic adjustReason?: string;\n\n\t@prop({ type: String, select: false })\n\tpublic lineItemHash: string;\n\n\t@prop({\n\t\tref: () => CartParticipant,\n\t\tforeignField: 'cart',\n\t\tlocalField: 'cart',\n\t\tjustOne: true,\n\t\tmatch: (doc: LineItem) => ({ user: doc.user }),\n\t})\n\tpublic cartParticipant?: Ref<CartParticipant>;\n}\n"]}
1
+ {"version":3,"file":"line-item.model.js","sourceRoot":"/","sources":["libraries/mongo/models/line-item.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA0F;AAC1F,4EAAqE;AACrE,6CAAoC;AACpC,mDAA0C;AAC1C,4EAAuE;AACvE,kDAAgE;AAChE,oFAAyE;AACzE,6CAAoC;AACpC,6CAAoC;AACpC,iDAAwC;AACxC,qDAA4C;AAC5C,uDAA8C;AAC9C,sEAA4D;AAC5D,qEAA2D;AAC3D,uEAA6D;AAqBtD,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,2BAAU;IAEhC,IAAI,CAAa;IAGjB,IAAI,CAAa;IAGjB,IAAI,CAAa;IAGjB,MAAM,CAAc;IAGpB,QAAQ,CA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AC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;IAC3B,IAAA,iBAAK,EAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;IACrB,IAAA,iBAAK,EAAC,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC;IAC1B,IAAA,iBAAK,EAAC,EAAE,IAAI,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;IAChC,IAAA,iBAAK,EAAC,EAAE,IAAI,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;GACpB,QAAQ,CAiFpB","sourcesContent":["import { prop, Ref, index, modelOptions, Severity, mongoose } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { Cart } from './cart.model';\nimport { Product } from './product.model';\nimport { OrderPriceBreakdown } from './embedded/price-breakdown.model';\nimport { ItemType, PriceOption } from '../../../utilities/enum';\nimport { LineItemAttribute } from './embedded/line-item-attribute.model';\nimport { User } from './user.model';\nimport { Shop } from './shop.model';\nimport { Parent } from './parent.model';\nimport { Category } from './category.model';\nimport { Marketing } from './marketing.model';\nimport { ProductSnap } from './embedded/product-snap.model';\nimport { CartParticipant } from './cart-participant.model';\nimport { ProductMarketing } from './product-marketing.model';\n\n/**\n * LineItem model - Represents individual items in a cart\n */\n@modelOptions({\n\tschemaOptions: {\n\t\tcollection: 'lineItems',\n\t\ttoJSON: { virtuals: true },\n\t\ttoObject: { virtuals: true },\n\t},\n\toptions: {\n\t\tallowMixed: Severity.ALLOW,\n\t},\n})\n@index({ cart: 1 })\n@index({ cart: 1, user: 1 })\n@index({ product: 1 })\n@index({ lineItemHash: 1 })\n@index({ shop: 1, deletedAt: 1 })\n@index({ shop: 1, createdAt: 1 })\nexport class LineItem extends TimeStamps {\n\t@prop({ required: true, ref: () => Cart })\n\tpublic cart!: Ref<Cart>;\n\n\t@prop({ required: true, ref: () => User })\n\tpublic user!: Ref<User>;\n\n\t@prop({ required: true, ref: () => Shop })\n\tpublic shop!: Ref<Shop>;\n\n\t@prop({ required: true, ref: () => Parent })\n\tpublic parent: Ref<Parent>;\n\n\t@prop({ required: true, type: String, enum: ItemType })\n\tpublic itemType!: ItemType;\n\n\t@prop({ required: true, ref: () => Category })\n\tpublic category!: Ref<Category>;\n\n\t@prop({ required: true, ref: () => Product })\n\tpublic product!: Ref<Product>;\n\n\t@prop({ type: ProductSnap, _id: false })\n\tpublic productSnap?: ProductSnap;\n\n\t@prop({ ref: () => Marketing, default: [] })\n\tpublic marketings?: Ref<Marketing>[];\n\n\t@prop({ ref: () => ProductMarketing, default: [] })\n\tpublic productMarketings?: Ref<ProductMarketing>[];\n\n\t@prop({ min: 1, default: 1 })\n\tpublic quantity: number;\n\n\t@prop({ type: String, enum: PriceOption, default: PriceOption.SINGLE_PRICE })\n\tpublic priceOption?: PriceOption;\n\n\t@prop({ required: true, type: OrderPriceBreakdown })\n\tpublic priceBreakdown: OrderPriceBreakdown;\n\n\t@prop({ type: () => [[LineItemAttribute]], default: [] })\n\tpublic attributes?: LineItemAttribute[][];\n\n\t@prop({ type: () => [String], default: [] })\n\tpublic removedIngredients?: string[];\n\n\t@prop({ type: String })\n\tpublic specialInstructions?: string;\n\n\t@prop({ type: mongoose.Schema.Types.Mixed })\n\tpublic calculationSnap?: Record<string, unknown>;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isAdjusted: boolean;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isPartialAdjusted: boolean;\n\n\t@prop({ type: Boolean })\n\tpublic isCreatedAfterAdjustment?: boolean;\n\n\t@prop({ default: 0 })\n\tpublic adjustedQuantity: number;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isB1G1: boolean;\n\n\t@prop({ type: String })\n\tpublic adjustReason?: string;\n\n\t@prop({ type: String, select: false })\n\tpublic lineItemHash: string;\n\n\t@prop({\n\t\tref: () => CartParticipant,\n\t\tforeignField: 'cart',\n\t\tlocalField: 'cart',\n\t\tjustOne: true,\n\t\tmatch: (doc: LineItem) => ({ user: doc.user }),\n\t})\n\tpublic cartParticipant?: Ref<CartParticipant>;\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { SocketEventType } from '../../../utilities/enum';
2
- import { InputFor } from '../index';
2
+ import { InputFor, OutputFor } from '../core';
3
3
  import { TokenType } from '../../auth';
4
4
  import { ProcedureResolverOptions } from '@trpc/server/unstable-core-do-not-import';
5
5
  import { EntityContext, LyxaHTTPContext } from '../../trpc/context';
@@ -12,5 +12,5 @@ type optsType<TEventType extends SocketEventType, TInput extends InputFor<TEvent
12
12
  usedRefreshToken: boolean | undefined;
13
13
  tokenRenewed: boolean | undefined;
14
14
  }, TInput>;
15
- export declare function createSocketSubscriptionAdapter<TEventType extends SocketEventType, TInput extends InputFor<TEventType>>(eventType: TEventType): (opts: optsType<TEventType, TInput>) => AsyncGenerator<any, void, unknown>;
15
+ export declare function createSocketSubscriptionAdapter<TEventType extends SocketEventType, TInput extends InputFor<TEventType>>(eventType: TEventType): (opts: optsType<TEventType, TInput>) => AsyncGenerator<Awaited<OutputFor<TEventType>>, void, unknown>;
16
16
  export {};
@@ -1,30 +1,29 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createSocketSubscriptionAdapter = createSocketSubscriptionAdapter;
4
- const index_1 = require("../index");
4
+ const core_1 = require("../core");
5
5
  const crypto_1 = require("crypto");
6
6
  const instance_utils_1 = require("../../../utilities/instance.utils");
7
7
  const events_1 = require("events");
8
+ const index_1 = require("../../../index");
8
9
  async function* _createSocketSubscription(eventType, opts) {
9
10
  const { ctx } = opts;
10
- console.log('Options are: ', opts);
11
+ const logger = (0, index_1.getLibraries)().getLogger().logger;
11
12
  const entity = { id: ctx.entity.id, type: ctx.entity.type };
12
- const eventKey = index_1.EventFactory.getSubscriptionKey(eventType, opts.input);
13
+ const eventKey = core_1.EventFactory.getSubscriptionKey(eventType, opts.input);
13
14
  const socketId = (0, crypto_1.randomUUID)();
14
15
  const socketInfo = { socketId, eventKey, instanceId: (0, instance_utils_1.getInstanceId)() };
15
- const localEE = new index_1.LocalEventEmitter(socketId);
16
- await (0, index_1.connectEntityToSocketEvent)(entity, socketInfo);
17
- index_1.LocalSubs.bind(entity, eventKey, localEE);
16
+ const localEE = new core_1.LocalEventEmitter(socketId);
17
+ await (0, core_1.connectEntityToSocketEvent)(entity, socketInfo);
18
+ core_1.LocalSubs.bind(entity, eventKey, localEE);
19
+ logger.debug({ entity, socketId, eventKey }, 'Socket subscription connected');
18
20
  opts.signal?.addEventListener('abort', () => {
19
- index_1.LocalSubs.unbind(entity, eventKey, localEE);
20
- (0, index_1.disconnectEntityFromSocketEvent)(entity, socketInfo).catch(console.error);
21
- console.log('Unsubscribed from event listener:', entity.id, socketId);
22
- console.log('Abort signal reason:', opts.signal?.reason);
23
- console.log('Abort signal reason:', opts.signal);
21
+ core_1.LocalSubs.unbind(entity, eventKey, localEE);
22
+ (0, core_1.disconnectEntityFromSocketEvent)(entity, socketInfo);
23
+ logger.debug({ entity, socketId, eventKey }, 'Socket subscription disconnected');
24
24
  });
25
- yield { _ready: true };
26
25
  for await (const [data] of (0, events_1.on)(localEE.ee, eventKey, { signal: opts.signal })) {
27
- console.log('Yielding event with signal:', opts.signal);
26
+ logger.debug({ entity, socketId, eventKey, data }, 'Socket subscription sending data');
28
27
  yield data;
29
28
  }
30
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"socket-subscription.js","sourceRoot":"/","sources":["libraries/socket/adapters/socket-subscription.ts"],"names":[],"mappings":";;AAqFA,0EAKC;AAzFD,oCASkB;AAClB,mCAAoC;AACpC,sEAAkE;AAIlE,mCAA4B;AA8B5B,KAAK,SAAS,CAAC,CAAC,yBAAyB,CAGvC,SAAqB,EAAE,IAAkC;IAC1D,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAErB,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;IAEnC,MAAM,M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E,QAAQ,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC;QAC9E,OAAO,CAAC,GAAG,CAAC,6BAA6B,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QACxD,MAAM,IAAW,CAAC;IACnB,CAAC;AACF,CAAC;AAED,SAAgB,+BAA+B,CAG7C,SAAqB;IACtB,OAAO,CAAC,IAAkC,EAAE,EAAE,CAAC,yBAAyB,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;AAC3F,CAAC","sourcesContent":["import { SocketEventType } from '../../../utilities/enum';\nimport {\n\tconnectEntityToSocketEvent,\n\tdisconnectEntityFromSocketEvent,\n\tEntitySubscription,\n\tEventFactory,\n\tInputFor,\n\tLocalEventEmitter,\n\tLocalSubs,\n\tOutputFor,\n} from '../index';\nimport { randomUUID } from 'crypto';\nimport { getInstanceId } from '../../../utilities/instance.utils';\nimport { AuthEntityType, TokenType } from '../../auth';\nimport { ProcedureResolverOptions } from '@trpc/server/unstable-core-do-not-import';\nimport { EntityContext, LyxaHTTPContext } from '../../trpc/context';\nimport { on } from 'events';\n\ntype optsType<\n\tTEventType extends SocketEventType,\n\tTInput extends InputFor<TEventType>,\n> = ProcedureResolverOptions<\n\tobject,\n\tLyxaHTTPContext,\n\t{\n\t\tres: import('http').ServerResponse<import('http').IncomingMessage>;\n\t\ttokenType: TokenType | undefined;\n\t\tentity: EntityContext | undefined;\n\t\treq: import('http').IncomingMessage;\n\t\trequestId: string | undefined;\n\t\tusedRefreshToken: boolean | undefined;\n\t\ttokenRenewed: boolean | undefined;\n\t},\n\tTInput\n>;\n\ninterface _SubscriptionContext {\n\tentity?: { id: string; type: AuthEntityType };\n\tsignal?: AbortSignal;\n}\n\ninterface _SubscriptionOpts<TEventType extends SocketEventType, TInput extends InputFor<TEventType>> {\n\tctx: _SubscriptionContext;\n\tinput: TInput;\n}\n\nasync function* _createSocketSubscription<\n\tTEventType extends SocketEventType,\n\tTInput extends InputFor<TEventType>,\n>(eventType: TEventType, opts: optsType<TEventType, TInput>) {\n\tconst { ctx } = opts;\n\n\tconsole.log('Options are: ', opts);\n\n\tconst entity: EntitySubscription = { id: ctx.entity!.id, type: ctx.entity!.type };\n\n\tconst eventKey = EventFactory.getSubscriptionKey(eventType, opts.input);\n\tconst socketId = randomUUID();\n\tconst socketInfo = { socketId, eventKey, instanceId: getInstanceId() };\n\n\tconst localEE = new LocalEventEmitter(socketId);\n\n\t// Setup: connect to Redis and local registry\n\tawait connectEntityToSocketEvent(entity, socketInfo);\n\tLocalSubs.bind(entity, eventKey, localEE);\n\n\t// Cleanup on abort\n\topts.signal?.addEventListener('abort', () => {\n\t\tLocalSubs.unbind(entity, eventKey, localEE);\n\t\tdisconnectEntityFromSocketEvent(entity, socketInfo).catch(console.error);\n\t\tconsole.log('Unsubscribed from event listener:', entity.id, socketId);\n\t\tconsole.log('Abort signal reason:', opts.signal?.reason);\n\t\tconsole.log('Abort signal reason:', opts.signal);\n\t});\n\n\tyield { _ready: true } as any;\n\n\t// Stream events\n\ttype Out = OutputFor<TEventType>;\n\tfor await (const [data] of on(localEE.ee, eventKey, { signal: opts.signal })) {\n\t\tconsole.log('Yielding event with signal:', opts.signal);\n\t\tyield data as Out;\n\t}\n}\n\nexport function createSocketSubscriptionAdapter<\n\tTEventType extends SocketEventType,\n\tTInput extends InputFor<TEventType>,\n>(eventType: TEventType) {\n\treturn (opts: optsType<TEventType, TInput>) => _createSocketSubscription(eventType, opts);\n}\n\n/**\n * @Example\n * const socketRouterTwo = createTRPCRouter({\n * \tonMessage: createAuthenticatedProcedure({ entityTypes: [AuthEntityType.CRM] })\n * \t\t.input(ChatroomMessageSendSocketInputSchema)\n * \t\t.output(zAsyncIterable({ yield: ChatroomMessageSendOutputSchema }))\n * \t\t.subscription(createSocketSubscriptionAdapter(SocketEventType.CHATROOM_MESSAGE_SEND)),\n * });\n */\n"]}
1
+ {"version":3,"file":"socket-subscription.js","sourceRoot":"/","sources":["libraries/socket/adap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AC,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,kCAAkC,CAAC,CAAC;IAClF,CAAC,CAAC,CAAC;IAIH,IAAI,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,IAAA,WAAE,EAAC,OAAO,CAAC,EAAE,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC;QAC9E,MAAM,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,kCAAkC,CAAC,CAAC;QACvF,MAAM,IAAW,CAAC;IACnB,CAAC;AACF,CAAC;AAED,SAAgB,+BAA+B,CAG7C,SAAqB;IACtB,OAAO,CAAC,IAAkC,EAAE,EAAE,CAAC,yBAAyB,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;AAC3F,CAAC","sourcesContent":["import { SocketEventType } from '../../../utilities/enum';\nimport {\n\tconnectEntityToSocketEvent,\n\tdisconnectEntityFromSocketEvent,\n\tEntitySubscription,\n\tEventFactory,\n\tInputFor,\n\tLocalEventEmitter,\n\tLocalSubs,\n\tOutputFor,\n} from '../core';\nimport { randomUUID } from 'crypto';\nimport { getInstanceId } from '../../../utilities/instance.utils';\nimport { AuthEntityType, TokenType } from '../../auth';\nimport { ProcedureResolverOptions } from '@trpc/server/unstable-core-do-not-import';\nimport { EntityContext, LyxaHTTPContext } from '../../trpc/context';\nimport { on } from 'events';\nimport { getLibraries } from '../../../index';\n\ntype optsType<\n\tTEventType extends SocketEventType,\n\tTInput extends InputFor<TEventType>,\n> = ProcedureResolverOptions<\n\tobject,\n\tLyxaHTTPContext,\n\t{\n\t\tres: import('http').ServerResponse<import('http').IncomingMessage>;\n\t\ttokenType: TokenType | undefined;\n\t\tentity: EntityContext | undefined;\n\t\treq: import('http').IncomingMessage;\n\t\trequestId: string | undefined;\n\t\tusedRefreshToken: boolean | undefined;\n\t\ttokenRenewed: boolean | undefined;\n\t},\n\tTInput\n>;\n\ninterface _SubscriptionContext {\n\tentity?: { id: string; type: AuthEntityType };\n\tsignal?: AbortSignal;\n}\n\ninterface _SubscriptionOpts<TEventType extends SocketEventType, TInput extends InputFor<TEventType>> {\n\tctx: _SubscriptionContext;\n\tinput: TInput;\n}\n\nasync function* _createSocketSubscription<\n\tTEventType extends SocketEventType,\n\tTInput extends InputFor<TEventType>,\n>(eventType: TEventType, opts: optsType<TEventType, TInput>) {\n\tconst { ctx } = opts;\n\tconst logger = getLibraries().getLogger().logger;\n\n\tconst entity: EntitySubscription = { id: ctx.entity!.id, type: ctx.entity!.type };\n\tconst eventKey = EventFactory.getSubscriptionKey(eventType, opts.input);\n\tconst socketId = randomUUID();\n\tconst socketInfo = { socketId, eventKey, instanceId: getInstanceId() };\n\n\tconst localEE = new LocalEventEmitter(socketId);\n\n\t// --- CONNECT ---\n\tawait connectEntityToSocketEvent(entity, socketInfo);\n\tLocalSubs.bind(entity, eventKey, localEE);\n\tlogger.debug({ entity, socketId, eventKey }, 'Socket subscription connected');\n\n\t// --- DISCONNECT ---\n\topts.signal?.addEventListener('abort', () => {\n\t\tLocalSubs.unbind(entity, eventKey, localEE);\n\t\tdisconnectEntityFromSocketEvent(entity, socketInfo);\n\t\tlogger.debug({ entity, socketId, eventKey }, 'Socket subscription disconnected');\n\t});\n\n\t// --- STREAM EVENTS ---\n\ttype Out = OutputFor<TEventType>;\n\tfor await (const [data] of on(localEE.ee, eventKey, { signal: opts.signal })) {\n\t\tlogger.debug({ entity, socketId, eventKey, data }, 'Socket subscription sending data');\n\t\tyield data as Out;\n\t}\n}\n\nexport function createSocketSubscriptionAdapter<\n\tTEventType extends SocketEventType,\n\tTInput extends InputFor<TEventType>,\n>(eventType: TEventType) {\n\treturn (opts: optsType<TEventType, TInput>) => _createSocketSubscription(eventType, opts);\n}\n\n/**\n * @Example\n * const socketRouterTwo = createTRPCRouter({\n * \tonMessage: createAuthenticatedProcedure({ entityTypes: [AuthEntityType.CRM] })\n * \t\t.input(ChatroomMessageSendSocketInputSchema)\n * \t\t.output(zAsyncIterable({ yield: ChatroomMessageSendOutputSchema }))\n * \t\t.subscription(createSocketSubscriptionAdapter(SocketEventType.CHATROOM_MESSAGE_SEND)),\n * });\n */\n"]}
@@ -22,7 +22,7 @@ Perfect for sharing types between frontend and backend applications.
22
22
 
23
23
  ## Version
24
24
 
25
- Version: 1.3.31
25
+ Version: 1.3.33
26
26
 
27
27
  ## Dependencies
28
28
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lyxa.ai/types",
3
- "version": "1.3.31",
3
+ "version": "1.3.33",
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",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lyxa.ai/core",
3
- "version": "1.3.31",
3
+ "version": "1.3.33",
4
4
  "description": "The Core system of the Lyxa services.",
5
5
  "author": "elie <42282499+Internalizable@users.noreply.github.com>",
6
6
  "license": "MIT",