@lyxa.ai/core 1.3.53 → 1.3.55
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/dist/libraries/socket/adapters/socket-subscription.js +15 -1
- package/dist/libraries/socket/adapters/socket-subscription.js.map +1 -1
- package/dist/libraries/socket/events/order-actions.socket.event.d.ts +6 -0
- package/dist/libraries/socket/events/order-actions.socket.event.js +2 -1
- package/dist/libraries/socket/events/order-actions.socket.event.js.map +1 -1
- package/dist/types/README.md +1 -1
- package/dist/types/package.json +1 -1
- package/package.json +1 -1
|
@@ -4,12 +4,26 @@ exports.createSocketSubscriptionAdapter = createSocketSubscriptionAdapter;
|
|
|
4
4
|
const core_1 = require("../core");
|
|
5
5
|
const crypto_1 = require("crypto");
|
|
6
6
|
const instance_utils_1 = require("../../../utilities/instance.utils");
|
|
7
|
+
const auth_1 = require("../../auth");
|
|
7
8
|
const events_1 = require("events");
|
|
8
9
|
const index_1 = require("../../../index");
|
|
10
|
+
function getEntityId(entity) {
|
|
11
|
+
switch (entity.type) {
|
|
12
|
+
case auth_1.AuthEntityType.SELLER:
|
|
13
|
+
const shops = entity.parameters.shops;
|
|
14
|
+
return shops[0];
|
|
15
|
+
default:
|
|
16
|
+
return entity.id;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
9
19
|
async function* _createSocketSubscription(eventType, opts) {
|
|
10
20
|
const { ctx } = opts;
|
|
11
21
|
const logger = (0, index_1.getLibraries)().getLogger().logger;
|
|
12
|
-
|
|
22
|
+
if (!ctx.entity)
|
|
23
|
+
throw new Error('Entity is required for socket subscription');
|
|
24
|
+
const entityId = getEntityId(ctx.entity);
|
|
25
|
+
logger.debug(`Entity ID: ${entityId}`);
|
|
26
|
+
const entity = { id: entityId.toString(), type: ctx.entity.type };
|
|
13
27
|
const eventKey = core_1.EventFactory.getSubscriptionKey(eventType, opts.input);
|
|
14
28
|
const socketId = (0, crypto_1.randomUUID)();
|
|
15
29
|
const socketInfo = { socketId, eventKey, instanceId: (0, instance_utils_1.getInstanceId)() };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socket-subscription.js","sourceRoot":"/","sources":["libraries/socket/adapters/socket-subscription.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"socket-subscription.js","sourceRoot":"/","sources":["libraries/socket/adapters/socket-subscription.ts"],"names":[],"mappings":";;AAkGA,0EAKC;AAtGD,kCASiB;AACjB,mCAAoC;AACpC,sEAAkE;AAClE,qCAAuD;AAGvD,mCAA4B;AAC5B,0CAA8C;AA+B9C,SAAS,WAAW,CAAC,MAAqB;IACzC,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACrB,KAAK,qBAAc,CAAC,MAAM;YACzB,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC,KAAkC,CAAC;YACnE,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;QACjB;YACC,OAAO,MAAM,CAAC,EAAE,CAAC;IACnB,CAAC;AACF,CAAC;AAED,KAAK,SAAS,CAAC,CAAC,yBAAyB,CAGvC,SAAqB,EAAE,IAAkC;IAC1D,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IACrB,MAAM,MAAM,GAAG,IAAA,oBAAY,GAAE,CAAC,SAAS,EAAE,CAAC,MAAM,CAAC;IAGjD,IAAI,CAAC,GAAG,CAAC,MAAM;QAAE,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAC/E,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAEzC,MAAM,CAAC,KAAK,CAAC,cAAc,QAAQ,EAAE,CAAC,CAAC;IACvC,MAAM,MAAM,GAAuB,EAAE,EAAE,EAAE,QAAQ,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAEtF,MAAM,QAAQ,GAAG,mBAAY,CAAC,kBAAkB,CAAC,SAAS,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BAAyB,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';\nimport mongoose from 'mongoose';\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\nfunction getEntityId(entity: EntityContext) {\n\tswitch (entity.type) {\n\t\tcase AuthEntityType.SELLER:\n\t\t\tconst shops = entity.parameters.shops as mongoose.Types.ObjectId[];\n\t\t\treturn shops[0];\n\t\tdefault:\n\t\t\treturn entity.id;\n\t}\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\t// --- USE getEntityId ---\n\tif (!ctx.entity) throw new Error('Entity is required for socket subscription');\n\tconst entityId = getEntityId(ctx.entity);\n\n\tlogger.debug(`Entity ID: ${entityId}`);\n\tconst entity: EntitySubscription = { id: entityId.toString(), 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// --- 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"]}
|
|
@@ -10,6 +10,7 @@ export declare enum OrderAction {
|
|
|
10
10
|
}
|
|
11
11
|
export declare const OrderActionsOutputSchema: z.ZodObject<{
|
|
12
12
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("mongoose").Types.ObjectId, string>, z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>]>;
|
|
13
|
+
shopId: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("mongoose").Types.ObjectId, string>, z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>]>;
|
|
13
14
|
orderId: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
14
15
|
user: z.ZodObject<{
|
|
15
16
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("mongoose").Types.ObjectId, string>, z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>]>;
|
|
@@ -93,6 +94,7 @@ export declare const OrderActionsOutputSchema: z.ZodObject<{
|
|
|
93
94
|
_id: import("mongoose").Types.ObjectId;
|
|
94
95
|
createdAt: Date;
|
|
95
96
|
orderId: string;
|
|
97
|
+
shopId: import("mongoose").Types.ObjectId;
|
|
96
98
|
paymentMethod: PaymentMethod;
|
|
97
99
|
triggerAt: Date;
|
|
98
100
|
adjustedFinance: {
|
|
@@ -120,6 +122,7 @@ export declare const OrderActionsOutputSchema: z.ZodObject<{
|
|
|
120
122
|
_id: string | import("mongoose").Types.ObjectId;
|
|
121
123
|
createdAt: Date;
|
|
122
124
|
orderId: string;
|
|
125
|
+
shopId: string | import("mongoose").Types.ObjectId;
|
|
123
126
|
paymentMethod: PaymentMethod;
|
|
124
127
|
triggerAt: Date;
|
|
125
128
|
adjustedFinance: {
|
|
@@ -160,6 +163,7 @@ export declare class OrderActionsSocketEvent extends BaseSocketEvent<typeof Orde
|
|
|
160
163
|
}>;
|
|
161
164
|
output: z.ZodObject<{
|
|
162
165
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("mongoose").Types.ObjectId, string>, z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>]>;
|
|
166
|
+
shopId: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("mongoose").Types.ObjectId, string>, z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>]>;
|
|
163
167
|
orderId: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
164
168
|
user: z.ZodObject<{
|
|
165
169
|
_id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("mongoose").Types.ObjectId, string>, z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>]>;
|
|
@@ -243,6 +247,7 @@ export declare class OrderActionsSocketEvent extends BaseSocketEvent<typeof Orde
|
|
|
243
247
|
_id: import("mongoose").Types.ObjectId;
|
|
244
248
|
createdAt: Date;
|
|
245
249
|
orderId: string;
|
|
250
|
+
shopId: import("mongoose").Types.ObjectId;
|
|
246
251
|
paymentMethod: PaymentMethod;
|
|
247
252
|
triggerAt: Date;
|
|
248
253
|
adjustedFinance: {
|
|
@@ -270,6 +275,7 @@ export declare class OrderActionsSocketEvent extends BaseSocketEvent<typeof Orde
|
|
|
270
275
|
_id: string | import("mongoose").Types.ObjectId;
|
|
271
276
|
createdAt: Date;
|
|
272
277
|
orderId: string;
|
|
278
|
+
shopId: string | import("mongoose").Types.ObjectId;
|
|
273
279
|
paymentMethod: PaymentMethod;
|
|
274
280
|
triggerAt: Date;
|
|
275
281
|
adjustedFinance: {
|
|
@@ -18,6 +18,7 @@ const OrderUserSchema = zod_1.z.object({
|
|
|
18
18
|
});
|
|
19
19
|
exports.OrderActionsOutputSchema = zod_1.z.object({
|
|
20
20
|
_id: validation_1.ZodValidation.objectId('Order ID'),
|
|
21
|
+
shopId: validation_1.ZodValidation.objectId('shopId'),
|
|
21
22
|
orderId: validation_1.ZodValidation.string('Readable Order ID'),
|
|
22
23
|
user: OrderUserSchema,
|
|
23
24
|
orderStatus: validation_1.ZodValidation.enumType(enum_1.RegularOrderStatus, 'status'),
|
|
@@ -56,7 +57,7 @@ class OrderActionsSocketEvent extends BaseSocketEvent_1.BaseSocketEvent {
|
|
|
56
57
|
super(enum_1.SocketEventType.ORDER_ACTIONS, OrderActionsSocketEvent.schemas, payload);
|
|
57
58
|
}
|
|
58
59
|
getIdentifier() {
|
|
59
|
-
return
|
|
60
|
+
return this.data.shopId.toString();
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
63
|
exports.OrderActionsSocketEvent = OrderActionsSocketEvent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"order-actions.socket.event.js","sourceRoot":"/","sources":["libraries/socket/events/order-actions.socket.event.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,+DAAoE;AACpE,kDAA6F;AAC7F,wDAAqD;AACrD,uEAAoE;AAEpE,IAAY,WAIX;AAJD,WAAY,WAAW;IACtB,gCAAiB,CAAA;IACjB,wCAAyB,CAAA;IACzB,0CAA2B,CAAA;AAC5B,CAAC,EAJW,WAAW,2BAAX,WAAW,QAItB;AAED,MAAM,eAAe,GAAG,OAAC,CAAC,MAAM,CAAC;IAChC,GAAG,EAAE,0BAAa,CAAC,QAAQ,CAAC,SAAS,CAAC;IACtC,IAAI,EAAE,0BAAa,CAAC,MAAM,CAAC,WAAW,CAAC;CACvC,CAAC,CAAC;AAEU,QAAA,wBAAwB,GAAG,OAAC,CAAC,MAAM,CAAC;IAChD,GAAG,EAAE,0BAAa,CAAC,QAAQ,CAAC,UAAU,CAAC;IACvC,OAAO,EAAE,0BAAa,CAAC,MAAM,CAAC,mBAAmB,CAAC;IAClD,IAAI,EAAE,eAAe;IACrB,WAAW,EAAE,0BAAa,CAA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AAQ,CAAC;CACxC,CAAC,CAAC;AAKH,MAAa,uBAAwB,SAAQ,iCAG5C;IACA,MAAM,CAAU,OAAO,GAAG;QACzB,KAAK,EAAE,+BAAuB;QAC9B,MAAM,EAAE,gCAAwB;QAChC,uBAAuB,EAAE,IAAI,iDAAuB,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;KAC/E,CAAC;IAEF,YAAY,OAAmC;QAC9C,KAAK,CAAC,sBAAe,CAAC,aAAa,EAAE,uBAAuB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAChF,CAAC;IAES,aAAa;QACtB,OAAO,
|
|
1
|
+
{"version":3,"file":"order-actions.socket.event.js","sourceRoot":"/","sources":["libraries/socket/events/order-actions.socket.event.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,+DAAoE;AACpE,kDAA6F;AAC7F,wDAAqD;AACrD,uEAAoE;AAEpE,IAAY,WAIX;AAJD,WAAY,WAAW;IACtB,gCAAiB,CAAA;IACjB,wCAAyB,CAAA;IACzB,0CAA2B,CAAA;AAC5B,CAAC,EAJW,WAAW,2BAAX,WAAW,QAItB;AAED,MAAM,eAAe,GAAG,OAAC,CAAC,MAAM,CAAC;IAChC,GAAG,EAAE,0BAAa,CAAC,QAAQ,CAAC,SAAS,CAAC;IACtC,IAAI,EAAE,0BAAa,CAAC,MAAM,CAAC,WAAW,CAAC;CACvC,CAAC,CAAC;AAEU,QAAA,wBAAwB,GAAG,OAAC,CAAC,MAAM,CAAC;IAChD,GAAG,EAAE,0BAAa,CAAC,QAAQ,CAAC,UAAU,CAAC;IACvC,MAAM,EAAE,0BAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC;IACxC,OAAO,EAAE,0BAAa,CAAC,MAAM,CAAC,mBAAmB,CAAC;IAClD,IAAI,EAAE,eAAe;IACrB,WAAW,EAAE,0BAAa,CAAC,QAAQ,CAAC,yBAAkB,EAAE,QAAQ,CAAC;IACjE,WAAW,EAAE,0BAAa,CAAC,QAAQ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U,OAAO,GAAG;QACzB,KAAK,EAAE,+BAAuB;QAC9B,MAAM,EAAE,gCAAwB;QAChC,uBAAuB,EAAE,IAAI,iDAAuB,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;KAC/E,CAAC;IAEF,YAAY,OAAmC;QAC9C,KAAK,CAAC,sBAAe,CAAC,aAAa,EAAE,uBAAuB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAChF,CAAC;IAES,aAAa;QACtB,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;IACpC,CAAC;;AAhBF,0DAiBC","sourcesContent":["import { z } from 'zod';\nimport { DTO, ZodValidation } from '../../../utilities/validation/';\nimport { PaymentMethod, RegularOrderStatus, SocketEventType } from '../../../utilities/enum';\nimport { BaseSocketEvent } from '../BaseSocketEvent';\nimport { SocketNotificationEvent } from './socketNotificationEvent';\n\nexport enum OrderAction {\n\tPLACED = 'placed',\n\tADJUSTMENT = 'adjustment',\n\tREPLACEMENT = 'replacement',\n}\n\nconst OrderUserSchema = z.object({\n\t_id: ZodValidation.objectId('User ID'),\n\tname: ZodValidation.string('User Name'),\n});\n\nexport const OrderActionsOutputSchema = z.object({\n\t_id: ZodValidation.objectId('Order ID'),\n\tshopId: ZodValidation.objectId('shopId'),\n\torderId: ZodValidation.string('Readable Order ID'),\n\tuser: OrderUserSchema,\n\torderStatus: ZodValidation.enumType(RegularOrderStatus, 'status'),\n\torderAction: ZodValidation.enumType(OrderAction, 'orderAction'),\n\tpaymentMethod: ZodValidation.enumType(PaymentMethod, 'paymentMethod'),\n\tpreparationTimeMinutes: ZodValidation.number('Preparation Time (minutes)', {\n\t\tisNonnegative: true,\n\t}),\n\tadjustedFinance: z.object({\n\t\tpaymentMethod: ZodValidation.enumType(PaymentMethod, 'paymentMethod'),\n\t\tshopProfit: ZodValidation.number('shopProfit'),\n\t\tpricing: z.object({\n\t\t\ttotal: ZodValidation.number('total'),\n\t\t\tsecondaryTotal: ZodValidation.number('secondaryTotal'),\n\t\t\tpaidAmount: ZodValidation.number('paidAmount'),\n\t\t\tsecondaryPaidAmount: ZodValidation.number('secondaryPaidAmount'),\n\t\t\tdeliveryFee: ZodValidation.number('deliveryFee'),\n\t\t\tsecondaryDeliveryFee: ZodValidation.number('secondaryDeliveryFee'),\n\t\t\triderTips: ZodValidation.number('riderTip'),\n\t\t\tsecondaryRiderTips: ZodValidation.number('secondaryRiderTips'),\n\t\t}),\n\t}),\n\tcreatedAt: ZodValidation.coerce.date('Order Creation Date'),\n\ttriggerAt: ZodValidation.coerce.date('Order Trigger Date'),\n});\n\nexport const OrderActionsInputSchema = z.object({\n\tshopId: ZodValidation.objectId('shopId'),\n});\n\nexport type OrderActionSocketInputDTO = DTO<typeof OrderActionsInputSchema>;\nexport type OrderActionSocketOutputDTO = DTO<typeof OrderActionsOutputSchema>;\n\nexport class OrderActionsSocketEvent extends BaseSocketEvent<\n\ttypeof OrderActionsInputSchema,\n\ttypeof OrderActionsOutputSchema\n> {\n\tstatic readonly schemas = {\n\t\tinput: OrderActionsInputSchema,\n\t\toutput: OrderActionsOutputSchema,\n\t\tsocketNotificationEvent: new SocketNotificationEvent({ message: 'New Order!' }),\n\t};\n\n\tconstructor(payload: OrderActionSocketOutputDTO) {\n\t\tsuper(SocketEventType.ORDER_ACTIONS, OrderActionsSocketEvent.schemas, payload);\n\t}\n\n\tprotected getIdentifier(): string {\n\t\treturn this.data.shopId.toString();\n\t}\n}\n"]}
|
package/dist/types/README.md
CHANGED
package/dist/types/package.json
CHANGED