@lyxa.ai/core 1.4.299 → 1.4.301
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/llm/interfaces/common-llm-interfaces.d.ts +2 -2
- package/dist/libraries/llm/interfaces/common-llm-interfaces.js.map +1 -1
- package/dist/libraries/llm/providers/openai-provider.js +6 -6
- package/dist/libraries/llm/providers/openai-provider.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/order-pricing.model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/regular-order-finance.model.d.ts +1 -0
- package/dist/libraries/mongo/models/embedded/regular-order-finance.model.js +5 -0
- package/dist/libraries/mongo/models/embedded/regular-order-finance.model.js.map +1 -1
- package/dist/libraries/socket/events/chatroom-message-send.socket.event.d.ts +13 -13
- package/dist/libraries/socket/events/order-actions.socket.event.d.ts +36 -36
- package/dist/libraries/socket/events/rider-location-update.socket.event.d.ts +8 -8
- package/dist/libraries/socket/events/ticket-actions.socket.event.d.ts +13 -13
- package/dist/libraries/socket/events/ticket-assign.socket.event.d.ts +8 -8
- package/dist/types/README.md +1 -1
- package/dist/types/package.json +1 -1
- package/dist/utilities/pagination.d.ts +3 -3
- package/dist/utilities/validation/common-validation.d.ts +82 -82
- package/package.json +1 -1
|
@@ -10,7 +10,7 @@ export interface IAICompletionProvider {
|
|
|
10
10
|
}): Promise<TextVariantResult[]>;
|
|
11
11
|
}
|
|
12
12
|
export interface TextVariantResult {
|
|
13
|
-
|
|
13
|
+
id: string;
|
|
14
14
|
original: string;
|
|
15
15
|
arabic?: string[];
|
|
16
16
|
arabizi?: string[];
|
|
@@ -23,6 +23,6 @@ export interface AiConfiguration {
|
|
|
23
23
|
prompt?: string;
|
|
24
24
|
}
|
|
25
25
|
export interface ItemTextInput {
|
|
26
|
-
|
|
26
|
+
id: string;
|
|
27
27
|
text: string;
|
|
28
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common-llm-interfaces.js","sourceRoot":"/","sources":["libraries/llm/interfaces/common-llm-interfaces.ts"],"names":[],"mappings":"","sourcesContent":["import { LLMProvider } from '../llm-provider-service';\n\nexport interface IAICompletionProvider {\n\tgenerateSearchVariantsChunksInBatch(\n\t\titems: ItemTextInput[],\n\t\tmodel?: string,\n\t\tinstructions?: string,\n\t\toptions?: {\n\t\t\tchunkSize?: number;\n\t\t\tmaxArabic?: number;\n\t\t\tmaxArabizi?: number;\n\t\t\tmaxTransliteration?: number;\n\t\t\tpollIntervalMs?: number;\n\t\t\tmaxWaitMs?: number;\n\t\t}\n\t): Promise<TextVariantResult[]>;\n}\n\nexport interface TextVariantResult {\n\
|
|
1
|
+
{"version":3,"file":"common-llm-interfaces.js","sourceRoot":"/","sources":["libraries/llm/interfaces/common-llm-interfaces.ts"],"names":[],"mappings":"","sourcesContent":["import { LLMProvider } from '../llm-provider-service';\n\nexport interface IAICompletionProvider {\n\tgenerateSearchVariantsChunksInBatch(\n\t\titems: ItemTextInput[],\n\t\tmodel?: string,\n\t\tinstructions?: string,\n\t\toptions?: {\n\t\t\tchunkSize?: number;\n\t\t\tmaxArabic?: number;\n\t\t\tmaxArabizi?: number;\n\t\t\tmaxTransliteration?: number;\n\t\t\tpollIntervalMs?: number;\n\t\t\tmaxWaitMs?: number;\n\t\t}\n\t): Promise<TextVariantResult[]>;\n}\n\nexport interface TextVariantResult {\n\tid: string;\n\toriginal: string;\n\tarabic?: string[];\n\tarabizi?: string[];\n\tarabicTransliteration?: string[];\n}\n\nexport interface AiConfiguration {\n\tprovider: LLMProvider;\n\tmodel?: string;\n\tinstructions?: string;\n\tprompt?: string;\n}\n\nexport interface ItemTextInput {\n\tid: string;\n\ttext: string;\n}\n"]}
|
|
@@ -72,7 +72,7 @@ class OpenAICompletionProvider {
|
|
|
72
72
|
body: {
|
|
73
73
|
model: finalModel,
|
|
74
74
|
instructions: finalInstructions,
|
|
75
|
-
input: JSON.stringify(chunkItems.map(({
|
|
75
|
+
input: JSON.stringify(chunkItems.map(({ id, text }) => ({ id: id, text }))),
|
|
76
76
|
text: {
|
|
77
77
|
format: {
|
|
78
78
|
type: 'json_schema',
|
|
@@ -125,13 +125,13 @@ class OpenAICompletionProvider {
|
|
|
125
125
|
console.error(`generateSearchVariantsChunksInBatch: failed to parse output for ${chunkId}`, outputText);
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
|
-
return items.map(({
|
|
129
|
-
const r = resultsById.get(
|
|
128
|
+
return items.map(({ id, text }) => {
|
|
129
|
+
const r = resultsById.get(id);
|
|
130
130
|
if (!r) {
|
|
131
|
-
console.error(`generateSearchVariantsChunksInBatch: no result for itemId=${
|
|
132
|
-
return {
|
|
131
|
+
console.error(`generateSearchVariantsChunksInBatch: no result for itemId=${id}`);
|
|
132
|
+
return { id, original: text };
|
|
133
133
|
}
|
|
134
|
-
return {
|
|
134
|
+
return { id, original: text, ...r };
|
|
135
135
|
});
|
|
136
136
|
}
|
|
137
137
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai-provider.js","sourceRoot":"/","sources":["libraries/llm/providers/openai-provider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAwC;AAGxC,MAAa,wBAAwB;IACnB,MAAM,CAAS;IACf,KAAK,CAAS;IAE/B,YAAY,MAA0B,EAAE,QAAgB,YAAY;QACnE,IAAI,CAAC,MAAM,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,kEAAkE,CAAC,CAAC;QACrF,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,IAAI,gBAAM,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;QACrC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACpB,CAAC;IAcD,KAAK,CAAC,mCAAmC,CACxC,KAAsB,EACtB,KAAc,EACd,YAAqB,EACrB,OAOC;QAED,MAAM,UAAU,GAAG,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC;QACv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,MAAM,CAAC,CAAC;QACtC,CAAC;QAED,OAAO,MAAM,CAAC;IACf,CAAC;CACD;AAzRD,4DAyRC","sourcesContent":["import OpenAI, { toFile } from 'openai';\nimport { IAICompletionProvider, ItemTextInput, TextVariantResult } from '../interfaces/common-llm-interfaces';\n\nexport class OpenAICompletionProvider implements IAICompletionProvider {\n\tprivate readonly client: OpenAI;\n\tprivate readonly model: string;\n\n\tconstructor(apiKey: string | undefined, model: string = 'gpt-5-nano') {\n\t\tif (!apiKey) {\n\t\t\tthrow new Error('OPENAI_API_KEY is required to construct OpenAICompletionProvider');\n\t\t}\n\t\tthis.client = new OpenAI({ apiKey });\n\t\tthis.model = model;\n\t}\n\n\t// ── Cost-optimized batch path ────────────────────────────────────\n\t// Implements everything discussed:\n\t// 1. Chunking — groups items (default 200/chunk) into one line per\n\t// chunk, so `instructions` is billed once per chunk instead of\n\t// once per item (biggest single cost lever).\n\t// 2. Short output keys — model emits {id, ar, az, tr} instead of\n\t// {itemId, arabic, arabizi, arabicTransliteration}; mapped back\n\t// to full field names locally, at zero token cost.\n\t// 3. Capped array lengths — schema enforces maxItems (not just a\n\t// prose suggestion), so the model can't drift to longer arrays.\n\t// 4. No echoed fields — model never re-emits itemId/original text;\n\t// both are re-attached locally from the input you already have.\n\tasync generateSearchVariantsChunksInBatch(\n\t\titems: ItemTextInput[],\n\t\tmodel?: string,\n\t\tinstructions?: string,\n\t\toptions?: {\n\t\t\tchunkSize?: number; // items per chunk/line — tune after testing token usage\n\t\t\tmaxArabic?: number; // cap on `arabic` variants (set to 1 for a single string-like result)\n\t\t\tmaxArabizi?: number; // cap on `arabizi` variants\n\t\t\tmaxTransliteration?: number; // cap on `arabicTransliteration` variants\n\t\t\tpollIntervalMs?: number;\n\t\t\tmaxWaitMs?: number;\n\t\t}\n\t): Promise<TextVariantResult[]> {\n\t\tconst finalModel = model ?? this.model;\n\t\tconst chunkSize = options?.chunkSize ?? 200;\n\t\tconst maxArabic = options?.maxArabic ?? 1;\n\t\tconst maxArabizi = options?.maxArabizi ?? 2;\n\t\tconst maxTransliteration = options?.maxTransliteration ?? 1;\n\n\t\ttry {\n\t\t\tconst finalInstructions =\n\t\t\t\tinstructions ??\n\t\t\t\tthis.buildOptimizedInstructions({\n\t\t\t\t\tmaxArabic,\n\t\t\t\t\tmaxArabizi,\n\t\t\t\t\tmaxTransliteration,\n\t\t\t\t});\n\n\t\t\tconst chunkSchema = this.buildOptimizedChunkSchema({ maxArabic, maxArabizi, maxTransliteration });\n\n\t\t\tconst chunks = this.chunkItems(items, chunkSize);\n\n\t\t\tif (chunks.length > 50_000) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Too many chunks (${chunks.length}) for a single batch file — increase chunkSize or split into multiple batch submissions.`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconsole.log(\n\t\t\t\t`generateSearchVariantsChunksInBatch: model=${finalModel} items=${items.length} chunkSize=${chunkSize} chunks=${chunks.length}`\n\t\t\t);\n\n\t\t\t// 1. Build JSONL — ONE line per chunk, not per item\n\t\t\tconst jsonl = chunks\n\t\t\t\t.map((chunkItems, i) =>\n\t\t\t\t\tJSON.stringify({\n\t\t\t\t\t\tcustom_id: `chunk-${i}`,\n\t\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\t\turl: '/v1/responses',\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\tmodel: finalModel,\n\t\t\t\t\t\t\tinstructions: finalInstructions,\n\t\t\t\t\t\t\t// Only send what the model needs to generate from: id + text.\n\t\t\t\t\t\t\t// No other fields, no restating of instructions per item.\n\t\t\t\t\t\t\tinput: JSON.stringify(chunkItems.map(({ itemId, text }) => ({ id: itemId, text }))),\n\t\t\t\t\t\t\ttext: {\n\t\t\t\t\t\t\t\tformat: {\n\t\t\t\t\t\t\t\t\ttype: 'json_schema',\n\t\t\t\t\t\t\t\t\tname: 'text_variants_batch',\n\t\t\t\t\t\t\t\t\tschema: chunkSchema,\n\t\t\t\t\t\t\t\t\tstrict: true,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t})\n\t\t\t\t)\n\t\t\t\t.join('\\n');\n\n\t\t\t// 2. Upload input file\n\t\t\tconst inputFile = await this.client.files.create({\n\t\t\t\tfile: await toFile(Buffer.from(jsonl, 'utf-8'), 'batch-input-optimized.jsonl'),\n\t\t\t\tpurpose: 'batch',\n\t\t\t});\n\n\t\t\t// 3. Create batch job\n\t\t\tlet batch = await this.client.batches.create({\n\t\t\t\tinput_file_id: inputFile.id,\n\t\t\t\tendpoint: '/v1/responses',\n\t\t\t\tcompletion_window: '24h',\n\t\t\t});\n\n\t\t\t// 4. Poll until done\n\t\t\tbatch = await this.pollBatch(batch.id, options?.pollIntervalMs, options?.maxWaitMs);\n\n\t\t\tif (batch.status !== 'completed') {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Batch ${batch.id} ended with status \"${batch.status}\" (${batch.request_counts?.failed ?? 0} failed)`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// 5. Parse output — keyed by chunk custom_id, each containing an array of per-item results\n\t\t\tconst outputByChunk = await this.readJsonlFile(batch.output_file_id);\n\t\t\tconst errorsByChunk = await this.readJsonlFile(batch.error_file_id);\n\n\t\t\t// 6. Flatten chunk results into a per-itemId map, expanding short keys back to full field names\n\t\t\tconst resultsById = new Map<string, Partial<TextVariantResult>>();\n\n\t\t\tfor (const [chunkId, record] of outputByChunk.entries()) {\n\t\t\t\tconst body = record?.response?.body;\n\t\t\t\tconst outputText =\n\t\t\t\t\tbody?.output_text ??\n\t\t\t\t\tbody?.output\n\t\t\t\t\t\t?.find((o: any) => o.type === 'message')\n\t\t\t\t\t\t?.content?.find((c: any) => c.type === 'output_text')?.text;\n\n\t\t\t\tif (!outputText) {\n\t\t\t\t\tconst err = errorsByChunk.get(chunkId);\n\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t`generateSearchVariantsChunksInBatch: no output for ${chunkId}`,\n\t\t\t\t\t\terr ?? record?.error\n\t\t\t\t\t);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tconst parsed = JSON.parse(outputText) as {\n\t\t\t\t\t\tresults: Array<{ id: string; ar: string[]; az: string[]; tr: string[] }>;\n\t\t\t\t\t};\n\t\t\t\t\tfor (const r of parsed.results) {\n\t\t\t\t\t\tresultsById.set(r.id, {\n\t\t\t\t\t\t\tarabic: r.ar,\n\t\t\t\t\t\t\tarabizi: r.az,\n\t\t\t\t\t\t\tarabicTransliteration: r.tr,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t} catch {\n\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t`generateSearchVariantsChunksInBatch: failed to parse output for ${chunkId}`,\n\t\t\t\t\t\toutputText\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// 7. Merge back with original items, preserving order and filling gaps\n\t\t\treturn items.map(({ itemId, text }) => {\n\t\t\t\tconst r = resultsById.get(itemId);\n\t\t\t\tif (!r) {\n\t\t\t\t\tconsole.error(`generateSearchVariantsChunksInBatch: no result for itemId=${itemId}`);\n\t\t\t\t\treturn { itemId, original: text };\n\t\t\t\t}\n\t\t\t\treturn { itemId, original: text, ...r } as TextVariantResult;\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tconsole.error('generateSearchVariantsChunksInBatch failed', {\n\t\t\t\terror,\n\t\t\t\titemCount: items.length,\n\t\t\t\tmodel: finalModel,\n\t\t\t});\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t// ── Helpers ──────────────────────────────────────────────────────\n\n\t// Compact instructions for the optimized path: short-key output format,\n\t// explicit array caps stated in prose (schema also enforces them),\n\t// and an explicit \"no commentary inside values\" rule to stop the model\n\t// padding fields with parenthetical notes.\n\tprivate buildOptimizedInstructions(caps: {\n\t\tmaxArabic: number;\n\t\tmaxArabizi: number;\n\t\tmaxTransliteration: number;\n\t}): string {\n\t\treturn [\n\t\t\t'You generate search-name variants for a food delivery app product/shop name.',\n\t\t\t'You will receive a JSON array of items, each with \"id\" and \"text\".',\n\t\t\t'For EACH item, return an object with:',\n\t\t\t`- id: the exact id provided (unchanged)`,\n\t\t\t`- ar: Arabic translation(s) in Arabic script, max ${caps.maxArabic}.`,\n\t\t\t`- az: Arabizi spelling(s) (Latin script/numerals, e.g. \"zaytoon\"), max ${caps.maxArabizi}.`,\n\t\t\t`- tr: Arabic-script transliteration(s) of the original word (not translated), max ${caps.maxTransliteration}.`,\n\t\t\t'Return one result per input item, same order, no items skipped or merged.',\n\t\t\t'Values must contain only the term itself — no parenthetical notes, no commentary.',\n\t\t\t'Return strict JSON matching the schema. No extra commentary, no extra fields.',\n\t\t].join('\\n');\n\t}\n\n\t// Schema for the OPTIMIZED chunk path: wraps a `results` array (one\n\t// entry per item in the chunk), short keys, and hard maxItems caps.\n\tprivate buildOptimizedChunkSchema(caps: {\n\t\tmaxArabic: number;\n\t\tmaxArabizi: number;\n\t\tmaxTransliteration: number;\n\t}) {\n\t\treturn {\n\t\t\ttype: 'object',\n\t\t\tproperties: {\n\t\t\t\tresults: {\n\t\t\t\t\ttype: 'array',\n\t\t\t\t\titems: {\n\t\t\t\t\t\ttype: 'object',\n\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\tid: { type: 'string' },\n\t\t\t\t\t\t\tar: { type: 'array', items: { type: 'string' }, minItems: 1, maxItems: caps.maxArabic },\n\t\t\t\t\t\t\taz: { type: 'array', items: { type: 'string' }, minItems: 1, maxItems: caps.maxArabizi },\n\t\t\t\t\t\t\ttr: {\n\t\t\t\t\t\t\t\ttype: 'array',\n\t\t\t\t\t\t\t\titems: { type: 'string' },\n\t\t\t\t\t\t\t\tminItems: 1,\n\t\t\t\t\t\t\t\tmaxItems: caps.maxTransliteration,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\trequired: ['id', 'ar', 'az', 'tr'],\n\t\t\t\t\t\tadditionalProperties: false,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\trequired: ['results'],\n\t\t\tadditionalProperties: false,\n\t\t};\n\t}\n\n\tprivate chunkItems<T>(items: T[], size: number): T[][] {\n\t\tconst out: T[][] = [];\n\t\tfor (let i = 0; i < items.length; i += size) {\n\t\t\tout.push(items.slice(i, i + size));\n\t\t}\n\t\treturn out;\n\t}\n\n\tprivate async pollBatch(\n\t\tbatchId: string,\n\t\tintervalMs = 5000,\n\t\tmaxWaitMs = 24 * 60 * 60 * 1000\n\t): Promise<OpenAI.Batches.Batch> {\n\t\tconst terminal = new Set(['completed', 'failed', 'expired', 'cancelled']);\n\t\tconst start = Date.now();\n\n\t\twhile (true) {\n\t\t\tconst batch = await this.client.batches.retrieve(batchId);\n\t\t\tconsole.log(\n\t\t\t\t`pollBatch: ${batchId} status=${batch.status} elapsed=${Math.round((Date.now() - start) / 1000)}s`\n\t\t\t);\n\t\t\tif (terminal.has(batch.status)) return batch;\n\n\t\t\tif (Date.now() - start > maxWaitMs) {\n\t\t\t\tthrow new Error(`Batch ${batchId} did not finish within ${maxWaitMs}ms (status: ${batch.status})`);\n\t\t\t}\n\n\t\t\tawait new Promise(resolve => setTimeout(resolve, intervalMs));\n\t\t}\n\t}\n\n\tprivate async readJsonlFile(fileId: string | null | undefined): Promise<Map<string, any>> {\n\t\tconst result = new Map<string, any>();\n\t\tif (!fileId) return result;\n\n\t\tconst fileResponse = await this.client.files.content(fileId);\n\t\tconst text = await fileResponse.text();\n\n\t\tfor (const line of text.split('\\n').filter(Boolean)) {\n\t\t\tconst record = JSON.parse(line);\n\t\t\tresult.set(record.custom_id, record);\n\t\t}\n\n\t\treturn result;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"openai-provider.js","sourceRoot":"/","sources":["libraries/llm/providers/openai-provider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAwC;AAGxC,MAAa,wBAAwB;IACnB,MAAM,CA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C,IAAI,CAAC,MAAM;YAAE,OAAO,MAAM,CAAC;QAE3B,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC7D,MAAM,IAAI,GAAG,MAAM,YAAY,CAAC,IAAI,EAAE,CAAC;QAEvC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;YACrD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAChC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QACtC,CAAC;QAED,OAAO,MAAM,CAAC;IACf,CAAC;CACD;AAzRD,4DAyRC","sourcesContent":["import OpenAI, { toFile } from 'openai';\nimport { IAICompletionProvider, ItemTextInput, TextVariantResult } from '../interfaces/common-llm-interfaces';\n\nexport class OpenAICompletionProvider implements IAICompletionProvider {\n\tprivate readonly client: OpenAI;\n\tprivate readonly model: string;\n\n\tconstructor(apiKey: string | undefined, model: string = 'gpt-5-nano') {\n\t\tif (!apiKey) {\n\t\t\tthrow new Error('OPENAI_API_KEY is required to construct OpenAICompletionProvider');\n\t\t}\n\t\tthis.client = new OpenAI({ apiKey });\n\t\tthis.model = model;\n\t}\n\n\t// ── Cost-optimized batch path ────────────────────────────────────\n\t// Implements everything discussed:\n\t// 1. Chunking — groups items (default 200/chunk) into one line per\n\t// chunk, so `instructions` is billed once per chunk instead of\n\t// once per item (biggest single cost lever).\n\t// 2. Short output keys — model emits {id, ar, az, tr} instead of\n\t// {id, arabic, arabizi, arabicTransliteration}; mapped back\n\t// to full field names locally, at zero token cost.\n\t// 3. Capped array lengths — schema enforces maxItems (not just a\n\t// prose suggestion), so the model can't drift to longer arrays.\n\t// 4. No echoed fields — model never re-emits id/original text;\n\t// both are re-attached locally from the input you already have.\n\tasync generateSearchVariantsChunksInBatch(\n\t\titems: ItemTextInput[],\n\t\tmodel?: string,\n\t\tinstructions?: string,\n\t\toptions?: {\n\t\t\tchunkSize?: number; // items per chunk/line — tune after testing token usage\n\t\t\tmaxArabic?: number; // cap on `arabic` variants (set to 1 for a single string-like result)\n\t\t\tmaxArabizi?: number; // cap on `arabizi` variants\n\t\t\tmaxTransliteration?: number; // cap on `arabicTransliteration` variants\n\t\t\tpollIntervalMs?: number;\n\t\t\tmaxWaitMs?: number;\n\t\t}\n\t): Promise<TextVariantResult[]> {\n\t\tconst finalModel = model ?? this.model;\n\t\tconst chunkSize = options?.chunkSize ?? 200;\n\t\tconst maxArabic = options?.maxArabic ?? 1;\n\t\tconst maxArabizi = options?.maxArabizi ?? 2;\n\t\tconst maxTransliteration = options?.maxTransliteration ?? 1;\n\n\t\ttry {\n\t\t\tconst finalInstructions =\n\t\t\t\tinstructions ??\n\t\t\t\tthis.buildOptimizedInstructions({\n\t\t\t\t\tmaxArabic,\n\t\t\t\t\tmaxArabizi,\n\t\t\t\t\tmaxTransliteration,\n\t\t\t\t});\n\n\t\t\tconst chunkSchema = this.buildOptimizedChunkSchema({ maxArabic, maxArabizi, maxTransliteration });\n\n\t\t\tconst chunks = this.chunkItems(items, chunkSize);\n\n\t\t\tif (chunks.length > 50_000) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Too many chunks (${chunks.length}) for a single batch file — increase chunkSize or split into multiple batch submissions.`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconsole.log(\n\t\t\t\t`generateSearchVariantsChunksInBatch: model=${finalModel} items=${items.length} chunkSize=${chunkSize} chunks=${chunks.length}`\n\t\t\t);\n\n\t\t\t// 1. Build JSONL — ONE line per chunk, not per item\n\t\t\tconst jsonl = chunks\n\t\t\t\t.map((chunkItems, i) =>\n\t\t\t\t\tJSON.stringify({\n\t\t\t\t\t\tcustom_id: `chunk-${i}`,\n\t\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\t\turl: '/v1/responses',\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\tmodel: finalModel,\n\t\t\t\t\t\t\tinstructions: finalInstructions,\n\t\t\t\t\t\t\t// Only send what the model needs to generate from: id + text.\n\t\t\t\t\t\t\t// No other fields, no restating of instructions per item.\n\t\t\t\t\t\t\tinput: JSON.stringify(chunkItems.map(({ id, text }) => ({ id: id, text }))),\n\t\t\t\t\t\t\ttext: {\n\t\t\t\t\t\t\t\tformat: {\n\t\t\t\t\t\t\t\t\ttype: 'json_schema',\n\t\t\t\t\t\t\t\t\tname: 'text_variants_batch',\n\t\t\t\t\t\t\t\t\tschema: chunkSchema,\n\t\t\t\t\t\t\t\t\tstrict: true,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t})\n\t\t\t\t)\n\t\t\t\t.join('\\n');\n\n\t\t\t// 2. Upload input file\n\t\t\tconst inputFile = await this.client.files.create({\n\t\t\t\tfile: await toFile(Buffer.from(jsonl, 'utf-8'), 'batch-input-optimized.jsonl'),\n\t\t\t\tpurpose: 'batch',\n\t\t\t});\n\n\t\t\t// 3. Create batch job\n\t\t\tlet batch = await this.client.batches.create({\n\t\t\t\tinput_file_id: inputFile.id,\n\t\t\t\tendpoint: '/v1/responses',\n\t\t\t\tcompletion_window: '24h',\n\t\t\t});\n\n\t\t\t// 4. Poll until done\n\t\t\tbatch = await this.pollBatch(batch.id, options?.pollIntervalMs, options?.maxWaitMs);\n\n\t\t\tif (batch.status !== 'completed') {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Batch ${batch.id} ended with status \"${batch.status}\" (${batch.request_counts?.failed ?? 0} failed)`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// 5. Parse output — keyed by chunk custom_id, each containing an array of per-item results\n\t\t\tconst outputByChunk = await this.readJsonlFile(batch.output_file_id);\n\t\t\tconst errorsByChunk = await this.readJsonlFile(batch.error_file_id);\n\n\t\t\t// 6. Flatten chunk results into a per-itemId map, expanding short keys back to full field names\n\t\t\tconst resultsById = new Map<string, Partial<TextVariantResult>>();\n\n\t\t\tfor (const [chunkId, record] of outputByChunk.entries()) {\n\t\t\t\tconst body = record?.response?.body;\n\t\t\t\tconst outputText =\n\t\t\t\t\tbody?.output_text ??\n\t\t\t\t\tbody?.output\n\t\t\t\t\t\t?.find((o: any) => o.type === 'message')\n\t\t\t\t\t\t?.content?.find((c: any) => c.type === 'output_text')?.text;\n\n\t\t\t\tif (!outputText) {\n\t\t\t\t\tconst err = errorsByChunk.get(chunkId);\n\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t`generateSearchVariantsChunksInBatch: no output for ${chunkId}`,\n\t\t\t\t\t\terr ?? record?.error\n\t\t\t\t\t);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tconst parsed = JSON.parse(outputText) as {\n\t\t\t\t\t\tresults: Array<{ id: string; ar: string[]; az: string[]; tr: string[] }>;\n\t\t\t\t\t};\n\t\t\t\t\tfor (const r of parsed.results) {\n\t\t\t\t\t\tresultsById.set(r.id, {\n\t\t\t\t\t\t\tarabic: r.ar,\n\t\t\t\t\t\t\tarabizi: r.az,\n\t\t\t\t\t\t\tarabicTransliteration: r.tr,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t} catch {\n\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t`generateSearchVariantsChunksInBatch: failed to parse output for ${chunkId}`,\n\t\t\t\t\t\toutputText\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// 7. Merge back with original items, preserving order and filling gaps\n\t\t\treturn items.map(({ id, text }) => {\n\t\t\t\tconst r = resultsById.get(id);\n\t\t\t\tif (!r) {\n\t\t\t\t\tconsole.error(`generateSearchVariantsChunksInBatch: no result for itemId=${id}`);\n\t\t\t\t\treturn { id, original: text };\n\t\t\t\t}\n\t\t\t\treturn { id, original: text, ...r } as TextVariantResult;\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tconsole.error('generateSearchVariantsChunksInBatch failed', {\n\t\t\t\terror,\n\t\t\t\titemCount: items.length,\n\t\t\t\tmodel: finalModel,\n\t\t\t});\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t// ── Helpers ──────────────────────────────────────────────────────\n\n\t// Compact instructions for the optimized path: short-key output format,\n\t// explicit array caps stated in prose (schema also enforces them),\n\t// and an explicit \"no commentary inside values\" rule to stop the model\n\t// padding fields with parenthetical notes.\n\tprivate buildOptimizedInstructions(caps: {\n\t\tmaxArabic: number;\n\t\tmaxArabizi: number;\n\t\tmaxTransliteration: number;\n\t}): string {\n\t\treturn [\n\t\t\t'You generate search-name variants for a food delivery app product/shop name.',\n\t\t\t'You will receive a JSON array of items, each with \"id\" and \"text\".',\n\t\t\t'For EACH item, return an object with:',\n\t\t\t`- id: the exact id provided (unchanged)`,\n\t\t\t`- ar: Arabic translation(s) in Arabic script, max ${caps.maxArabic}.`,\n\t\t\t`- az: Arabizi spelling(s) (Latin script/numerals, e.g. \"zaytoon\"), max ${caps.maxArabizi}.`,\n\t\t\t`- tr: Arabic-script transliteration(s) of the original word (not translated), max ${caps.maxTransliteration}.`,\n\t\t\t'Return one result per input item, same order, no items skipped or merged.',\n\t\t\t'Values must contain only the term itself — no parenthetical notes, no commentary.',\n\t\t\t'Return strict JSON matching the schema. No extra commentary, no extra fields.',\n\t\t].join('\\n');\n\t}\n\n\t// Schema for the OPTIMIZED chunk path: wraps a `results` array (one\n\t// entry per item in the chunk), short keys, and hard maxItems caps.\n\tprivate buildOptimizedChunkSchema(caps: {\n\t\tmaxArabic: number;\n\t\tmaxArabizi: number;\n\t\tmaxTransliteration: number;\n\t}) {\n\t\treturn {\n\t\t\ttype: 'object',\n\t\t\tproperties: {\n\t\t\t\tresults: {\n\t\t\t\t\ttype: 'array',\n\t\t\t\t\titems: {\n\t\t\t\t\t\ttype: 'object',\n\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\tid: { type: 'string' },\n\t\t\t\t\t\t\tar: { type: 'array', items: { type: 'string' }, minItems: 1, maxItems: caps.maxArabic },\n\t\t\t\t\t\t\taz: { type: 'array', items: { type: 'string' }, minItems: 1, maxItems: caps.maxArabizi },\n\t\t\t\t\t\t\ttr: {\n\t\t\t\t\t\t\t\ttype: 'array',\n\t\t\t\t\t\t\t\titems: { type: 'string' },\n\t\t\t\t\t\t\t\tminItems: 1,\n\t\t\t\t\t\t\t\tmaxItems: caps.maxTransliteration,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\trequired: ['id', 'ar', 'az', 'tr'],\n\t\t\t\t\t\tadditionalProperties: false,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\trequired: ['results'],\n\t\t\tadditionalProperties: false,\n\t\t};\n\t}\n\n\tprivate chunkItems<T>(items: T[], size: number): T[][] {\n\t\tconst out: T[][] = [];\n\t\tfor (let i = 0; i < items.length; i += size) {\n\t\t\tout.push(items.slice(i, i + size));\n\t\t}\n\t\treturn out;\n\t}\n\n\tprivate async pollBatch(\n\t\tbatchId: string,\n\t\tintervalMs = 5000,\n\t\tmaxWaitMs = 24 * 60 * 60 * 1000\n\t): Promise<OpenAI.Batches.Batch> {\n\t\tconst terminal = new Set(['completed', 'failed', 'expired', 'cancelled']);\n\t\tconst start = Date.now();\n\n\t\twhile (true) {\n\t\t\tconst batch = await this.client.batches.retrieve(batchId);\n\t\t\tconsole.log(\n\t\t\t\t`pollBatch: ${batchId} status=${batch.status} elapsed=${Math.round((Date.now() - start) / 1000)}s`\n\t\t\t);\n\t\t\tif (terminal.has(batch.status)) return batch;\n\n\t\t\tif (Date.now() - start > maxWaitMs) {\n\t\t\t\tthrow new Error(`Batch ${batchId} did not finish within ${maxWaitMs}ms (status: ${batch.status})`);\n\t\t\t}\n\n\t\t\tawait new Promise(resolve => setTimeout(resolve, intervalMs));\n\t\t}\n\t}\n\n\tprivate async readJsonlFile(fileId: string | null | undefined): Promise<Map<string, any>> {\n\t\tconst result = new Map<string, any>();\n\t\tif (!fileId) return result;\n\n\t\tconst fileResponse = await this.client.files.content(fileId);\n\t\tconst text = await fileResponse.text();\n\n\t\tfor (const line of text.split('\\n').filter(Boolean)) {\n\t\t\tconst record = JSON.parse(line);\n\t\t\tresult.set(record.custom_id, record);\n\t\t}\n\n\t\treturn result;\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"order-pricing.model.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/order-pricing.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA4C;AAE5C,MAAa,YAAY;IAEjB,QAAQ,CAAU;IAGlB,iBAAiB,CAAU;IAG3B,WAAW,CAAU;IAGrB,oBAAoB,CAAU;IAG9B,SAAS,CAAU;IAGnB,kBAAkB,CAAU;IAG5B,kBAAkB,CAAU;IAG5B,2BAA2B,CAAU;IAGrC,KAAK,CAAU;IAGf,cAAc,CAAU;IAGxB,MAAM,CAAU;IAGhB,eAAe,CAAU;IAGzB,aAAa,CAAU;IAGvB,sBAAsB,CAAU;IAGhC,UAAU,CAAU;IAGpB,mBAAmB,CAAU;CACpC;AAhDD,oCAgDC;AA9CO;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;8CACV;AAGlB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;uDACD;AAG3B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;iDACP;AAGrB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;0DACE;AAG9B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;+C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I,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;+DACA;AAG5B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;wEACS","sourcesContent":["import { prop } from '@typegoose/typegoose';\n\nexport class OrderPricing {\n\t@prop({ type: Number, default: 0 })\n\tpublic subtotal?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondarySubtotal?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic deliveryFee?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondaryDeliveryFee?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic riderTips?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondaryRiderTips?: number;\n\n\t@prop({ type: Number, default: 0 }) // negative wallet deduction\n\tpublic outstandingBalance?: number;\n\n\t@prop({ type: Number, default: 0 }) // negative wallet deduction\n\tpublic secondaryOutstandingBalance?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic total?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondaryTotal?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic wallet?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondaryWallet?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic reserveWallet?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondaryReserveWallet?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic paidAmount?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondaryPaidAmount?: number;\n}\n\nexport class CourierOrderPricing extends OrderPricing {\n\t// below field are only available for purchase and delivery order\n\t@prop({ type: Number, default: 0 })\n\tpublic initialItemTotal?: number; // This is initial subTotal,\n\t// updated item price in subTotal is stored in subTotal field after rider put amount\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondaryInitialItemTotal?: number;\n}\n\nexport class RegularOrderPricing extends OrderPricing {\n\t@prop({ type: Number, default: 0 })\n\tpublic discount?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondaryDiscount?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic couponDiscount?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondaryCouponDiscount?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic punchMarketingDiscount?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondaryPunchMarketingDiscount?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic b1g1Discount?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondaryB1g1Discount?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic spendToGetDiscount?: number
|
|
1
|
+
{"version":3,"file":"order-pricing.model.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/order-pricing.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA4C;AAE5C,MAAa,YAAY;IAEjB,QAAQ,CAAU;IAGlB,iBAAiB,CAAU;IAG3B,WAAW,CAAU;IAGrB,oBAAoB,CAAU;IAG9B,SAAS,CAAU;IAGnB,kBAAkB,CAAU;IAG5B,kBAAkB,CAAU;IAG5B,2BAA2B,CAAU;IAGrC,KAAK,CAAU;IAGf,cAAc,CAAU;IAGxB,MAAM,CAAU;IAGhB,eAAe,CAAU;IAGzB,aAAa,CAAU;IAGvB,sBAAsB,CAAU;IAGhC,UAAU,CAAU;IAGpB,mBAAmB,CAAU;CACpC;AAhDD,oCAgDC;AA9CO;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;8CACV;AAGlB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;uDACD;AAG3B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAA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C;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;yDACN;AAGtB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;kEACG;AAG/B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;+DACA;AAG5B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;wEACS","sourcesContent":["import { prop } from '@typegoose/typegoose';\n\nexport class OrderPricing {\n\t@prop({ type: Number, default: 0 })\n\tpublic subtotal?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondarySubtotal?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic deliveryFee?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondaryDeliveryFee?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic riderTips?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondaryRiderTips?: number;\n\n\t@prop({ type: Number, default: 0 }) // negative wallet deduction\n\tpublic outstandingBalance?: number;\n\n\t@prop({ type: Number, default: 0 }) // negative wallet deduction\n\tpublic secondaryOutstandingBalance?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic total?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondaryTotal?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic wallet?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondaryWallet?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic reserveWallet?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondaryReserveWallet?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic paidAmount?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondaryPaidAmount?: number;\n}\n\nexport class CourierOrderPricing extends OrderPricing {\n\t// below field are only available for purchase and delivery order\n\t@prop({ type: Number, default: 0 })\n\tpublic initialItemTotal?: number; // This is initial subTotal,\n\t// updated item price in subTotal is stored in subTotal field after rider put amount\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondaryInitialItemTotal?: number;\n}\n\nexport class RegularOrderPricing extends OrderPricing {\n\t@prop({ type: Number, default: 0 })\n\tpublic discount?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondaryDiscount?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic couponDiscount?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondaryCouponDiscount?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic punchMarketingDiscount?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondaryPunchMarketingDiscount?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic b1g1Discount?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondaryB1g1Discount?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic spendToGetDiscount?: number; // deprecated\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondarySpendToGetDiscount?: number; // deprecated\n}\n"]}
|
|
@@ -27,6 +27,7 @@ class RegularOrderFinance extends order_finance_model_1.OrderFinance {
|
|
|
27
27
|
coupon;
|
|
28
28
|
freeDelivery;
|
|
29
29
|
spendToGet;
|
|
30
|
+
spendToGetTiers;
|
|
30
31
|
cashBackAmounts;
|
|
31
32
|
}
|
|
32
33
|
exports.RegularOrderFinance = RegularOrderFinance;
|
|
@@ -66,6 +67,10 @@ __decorate([
|
|
|
66
67
|
(0, typegoose_1.prop)({ type: () => marketing_cut_model_1.SpendToGetDetails }),
|
|
67
68
|
__metadata("design:type", marketing_cut_model_1.SpendToGetDetails)
|
|
68
69
|
], RegularOrderFinance.prototype, "spendToGet", void 0);
|
|
70
|
+
__decorate([
|
|
71
|
+
(0, typegoose_1.prop)({ type: () => [marketing_cut_model_1.SpendToGetDetails], default: [] }),
|
|
72
|
+
__metadata("design:type", Array)
|
|
73
|
+
], RegularOrderFinance.prototype, "spendToGetTiers", void 0);
|
|
69
74
|
__decorate([
|
|
70
75
|
(0, typegoose_1.prop)({ type: () => cashback_amounts_model_1.Cashback }),
|
|
71
76
|
__metadata("design:type", cashback_amounts_model_1.Cashback)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"regular-order-finance.model.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/regular-order-finance.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA4C;AAC5C,+DAAqD;AACrD,2DAA8D;AAC9D,qDAA4C;AAC5C,yEAAiG;AACjG,+DAA4D;AAC5D,qEAAoD;AAEpD,MAAa,mBAAoB,SAAQ,kCAAY;IAE7C,OAAO,CAAuB;IAG9B,aAAa,CAAsB;IAGnC,UAAU,CAAsB;IAGhC,GAAG,CAAO;IAGV,QAAQ,CAAgB;IAGxB,QAAQ,CAAgB;IAGxB,MAAM,CAAiB;IAGvB,YAAY,CAAgB;IAG5B,UAAU,CAAqB;IAG/B,eAAe,CAAY;CAClC;
|
|
1
|
+
{"version":3,"file":"regular-order-finance.model.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/regular-order-finance.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA4C;AAC5C,+DAAqD;AACrD,2DAA8D;AAC9D,qDAA4C;AAC5C,yEAAiG;AACjG,+DAA4D;AAC5D,qEAAoD;AAEpD,MAAa,mBAAoB,SAAQ,kCAAY;IAE7C,OAAO,CAAuB;IAG9B,aAAa,CAAsB;IAGnC,UAAU,CAAsB;IAGhC,GAAG,CAAO;IAGV,QAAQ,CAAgB;IAGxB,QAAQ,CAAgB;IAGxB,MAAM,CAAiB;IAGvB,YAAY,CAAgB;IAG5B,UAAU,CAAqB;IAG/B,eAAe,CAAuB;IAGtC,eAAe,CAAY;CAClC;AAjCD,kDAiCC;AA/BO;IAD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C","sourcesContent":["import { prop } from '@typegoose/typegoose';\nimport { OrderFinance } from './order-finance.model';\nimport { RegularOrderProfit } from '../embedded/profit.model';\nimport { Vat } from '../embedded/vat.model';\nimport { CouponDetails, MarketingCut, SpendToGetDetails } from '../embedded/marketing-cut.model';\nimport { RegularOrderPricing } from './order-pricing.model';\nimport { Cashback } from './cashback-amounts.model';\n\nexport class RegularOrderFinance extends OrderFinance {\n\t@prop({ required: true, type: () => RegularOrderPricing })\n\tpublic pricing!: RegularOrderPricing;\n\n\t@prop({ type: () => RegularOrderProfit })\n\tpublic companyProfit?: RegularOrderProfit;\n\n\t@prop({ type: () => RegularOrderProfit })\n\tpublic shopProfit?: RegularOrderProfit;\n\n\t@prop({ type: () => Vat })\n\tpublic vat?: Vat;\n\n\t@prop({ type: () => MarketingCut })\n\tpublic discount?: MarketingCut;\n\n\t@prop({ type: () => MarketingCut })\n\tpublic buy1get1?: MarketingCut;\n\n\t@prop({ type: () => CouponDetails })\n\tpublic coupon?: CouponDetails;\n\n\t@prop({ type: () => MarketingCut })\n\tpublic freeDelivery?: MarketingCut;\n\n\t@prop({ type: () => SpendToGetDetails })\n\tpublic spendToGet?: SpendToGetDetails; // depracted\n\n\t@prop({ type: () => [SpendToGetDetails], default: [] })\n\tpublic spendToGetTiers?: SpendToGetDetails[];\n\n\t@prop({ type: () => Cashback })\n\tpublic cashBackAmounts?: Cashback;\n}\n"]}
|
|
@@ -63,8 +63,8 @@ export declare const ChatroomMessageSendOutputSchema: z.ZodObject<{
|
|
|
63
63
|
orderId: z.ZodOptional<z.ZodEffects<z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>, import("mongoose").Types.ObjectId, import("mongoose").Types.ObjectId>>;
|
|
64
64
|
createdAt: z.ZodEffects<z.ZodEffects<z.ZodDate, Date, Date>, Date, Date>;
|
|
65
65
|
}, "strip", z.ZodTypeAny, {
|
|
66
|
-
_id: import("mongoose").Types.ObjectId;
|
|
67
66
|
createdAt: Date;
|
|
67
|
+
_id: import("mongoose").Types.ObjectId;
|
|
68
68
|
sender: {
|
|
69
69
|
type: UserRef;
|
|
70
70
|
name: string;
|
|
@@ -85,12 +85,12 @@ export declare const ChatroomMessageSendOutputSchema: z.ZodObject<{
|
|
|
85
85
|
longitude?: number | undefined;
|
|
86
86
|
} | undefined;
|
|
87
87
|
orderId?: import("mongoose").Types.ObjectId | undefined;
|
|
88
|
-
ticketId?: import("mongoose").Types.ObjectId | undefined;
|
|
89
88
|
content?: string | undefined;
|
|
89
|
+
ticketId?: import("mongoose").Types.ObjectId | undefined;
|
|
90
90
|
chatroomId?: import("mongoose").Types.ObjectId | undefined;
|
|
91
91
|
}, {
|
|
92
|
-
_id: import("mongoose").Types.ObjectId;
|
|
93
92
|
createdAt: Date;
|
|
93
|
+
_id: import("mongoose").Types.ObjectId;
|
|
94
94
|
sender: {
|
|
95
95
|
type: UserRef;
|
|
96
96
|
name: string;
|
|
@@ -111,8 +111,8 @@ export declare const ChatroomMessageSendOutputSchema: z.ZodObject<{
|
|
|
111
111
|
longitude?: number | undefined;
|
|
112
112
|
} | undefined;
|
|
113
113
|
orderId?: import("mongoose").Types.ObjectId | undefined;
|
|
114
|
-
ticketId?: import("mongoose").Types.ObjectId | undefined;
|
|
115
114
|
content?: string | undefined;
|
|
115
|
+
ticketId?: import("mongoose").Types.ObjectId | undefined;
|
|
116
116
|
chatroomId?: import("mongoose").Types.ObjectId | undefined;
|
|
117
117
|
}>;
|
|
118
118
|
export declare const ChatroomMessageSendPushOutputSchema: z.ZodObject<{
|
|
@@ -124,14 +124,14 @@ export declare const ChatroomMessageSendPushOutputSchema: z.ZodObject<{
|
|
|
124
124
|
}, "strip", z.ZodTypeAny, {
|
|
125
125
|
type: ChatroomType;
|
|
126
126
|
orderId?: import("mongoose").Types.ObjectId | undefined;
|
|
127
|
-
ticketId?: import("mongoose").Types.ObjectId | undefined;
|
|
128
127
|
lastMessage?: string | undefined;
|
|
128
|
+
ticketId?: import("mongoose").Types.ObjectId | undefined;
|
|
129
129
|
chatroomId?: import("mongoose").Types.ObjectId | undefined;
|
|
130
130
|
}, {
|
|
131
131
|
type: ChatroomType;
|
|
132
132
|
orderId?: import("mongoose").Types.ObjectId | undefined;
|
|
133
|
-
ticketId?: import("mongoose").Types.ObjectId | undefined;
|
|
134
133
|
lastMessage?: string | undefined;
|
|
134
|
+
ticketId?: import("mongoose").Types.ObjectId | undefined;
|
|
135
135
|
chatroomId?: import("mongoose").Types.ObjectId | undefined;
|
|
136
136
|
}>;
|
|
137
137
|
export type ChatlistMessageSendPushOutputDTO = DTO<typeof ChatroomMessageSendPushOutputSchema>;
|
|
@@ -199,8 +199,8 @@ export declare class ChatroomMessageSendSocketEvent extends BaseSocketEvent<type
|
|
|
199
199
|
orderId: z.ZodOptional<z.ZodEffects<z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>, import("mongoose").Types.ObjectId, import("mongoose").Types.ObjectId>>;
|
|
200
200
|
createdAt: z.ZodEffects<z.ZodEffects<z.ZodDate, Date, Date>, Date, Date>;
|
|
201
201
|
}, "strip", z.ZodTypeAny, {
|
|
202
|
-
_id: import("mongoose").Types.ObjectId;
|
|
203
202
|
createdAt: Date;
|
|
203
|
+
_id: import("mongoose").Types.ObjectId;
|
|
204
204
|
sender: {
|
|
205
205
|
type: UserRef;
|
|
206
206
|
name: string;
|
|
@@ -221,12 +221,12 @@ export declare class ChatroomMessageSendSocketEvent extends BaseSocketEvent<type
|
|
|
221
221
|
longitude?: number | undefined;
|
|
222
222
|
} | undefined;
|
|
223
223
|
orderId?: import("mongoose").Types.ObjectId | undefined;
|
|
224
|
-
ticketId?: import("mongoose").Types.ObjectId | undefined;
|
|
225
224
|
content?: string | undefined;
|
|
225
|
+
ticketId?: import("mongoose").Types.ObjectId | undefined;
|
|
226
226
|
chatroomId?: import("mongoose").Types.ObjectId | undefined;
|
|
227
227
|
}, {
|
|
228
|
-
_id: import("mongoose").Types.ObjectId;
|
|
229
228
|
createdAt: Date;
|
|
229
|
+
_id: import("mongoose").Types.ObjectId;
|
|
230
230
|
sender: {
|
|
231
231
|
type: UserRef;
|
|
232
232
|
name: string;
|
|
@@ -247,8 +247,8 @@ export declare class ChatroomMessageSendSocketEvent extends BaseSocketEvent<type
|
|
|
247
247
|
longitude?: number | undefined;
|
|
248
248
|
} | undefined;
|
|
249
249
|
orderId?: import("mongoose").Types.ObjectId | undefined;
|
|
250
|
-
ticketId?: import("mongoose").Types.ObjectId | undefined;
|
|
251
250
|
content?: string | undefined;
|
|
251
|
+
ticketId?: import("mongoose").Types.ObjectId | undefined;
|
|
252
252
|
chatroomId?: import("mongoose").Types.ObjectId | undefined;
|
|
253
253
|
}>;
|
|
254
254
|
pushNotificationOutput: z.ZodObject<{
|
|
@@ -260,14 +260,14 @@ export declare class ChatroomMessageSendSocketEvent extends BaseSocketEvent<type
|
|
|
260
260
|
}, "strip", z.ZodTypeAny, {
|
|
261
261
|
type: ChatroomType;
|
|
262
262
|
orderId?: import("mongoose").Types.ObjectId | undefined;
|
|
263
|
-
ticketId?: import("mongoose").Types.ObjectId | undefined;
|
|
264
263
|
lastMessage?: string | undefined;
|
|
264
|
+
ticketId?: import("mongoose").Types.ObjectId | undefined;
|
|
265
265
|
chatroomId?: import("mongoose").Types.ObjectId | undefined;
|
|
266
266
|
}, {
|
|
267
267
|
type: ChatroomType;
|
|
268
268
|
orderId?: import("mongoose").Types.ObjectId | undefined;
|
|
269
|
-
ticketId?: import("mongoose").Types.ObjectId | undefined;
|
|
270
269
|
lastMessage?: string | undefined;
|
|
270
|
+
ticketId?: import("mongoose").Types.ObjectId | undefined;
|
|
271
271
|
chatroomId?: import("mongoose").Types.ObjectId | undefined;
|
|
272
272
|
}>;
|
|
273
273
|
};
|
|
@@ -278,8 +278,8 @@ export declare class ChatroomMessageSendSocketEvent extends BaseSocketEvent<type
|
|
|
278
278
|
getPushNotificationPayload(): {
|
|
279
279
|
type: ChatroomType;
|
|
280
280
|
orderId?: import("mongoose").Types.ObjectId | undefined;
|
|
281
|
-
ticketId?: import("mongoose").Types.ObjectId | undefined;
|
|
282
281
|
lastMessage?: string | undefined;
|
|
282
|
+
ticketId?: import("mongoose").Types.ObjectId | undefined;
|
|
283
283
|
chatroomId?: import("mongoose").Types.ObjectId | undefined;
|
|
284
284
|
} | undefined;
|
|
285
285
|
protected getIdentifier(): string;
|
|
@@ -39,108 +39,108 @@ export declare const OrderActionsOutputSchema: z.ZodObject<{
|
|
|
39
39
|
riderTips: z.ZodNumber;
|
|
40
40
|
secondaryRiderTips: z.ZodNumber;
|
|
41
41
|
}, "strip", z.ZodTypeAny, {
|
|
42
|
-
total: number;
|
|
43
42
|
deliveryFee: number;
|
|
44
43
|
secondaryDeliveryFee: number;
|
|
45
44
|
riderTips: number;
|
|
46
45
|
secondaryRiderTips: number;
|
|
46
|
+
total: number;
|
|
47
47
|
secondaryTotal: number;
|
|
48
48
|
paidAmount: number;
|
|
49
49
|
secondaryPaidAmount: number;
|
|
50
50
|
}, {
|
|
51
|
-
total: number;
|
|
52
51
|
deliveryFee: number;
|
|
53
52
|
secondaryDeliveryFee: number;
|
|
54
53
|
riderTips: number;
|
|
55
54
|
secondaryRiderTips: number;
|
|
55
|
+
total: number;
|
|
56
56
|
secondaryTotal: number;
|
|
57
57
|
paidAmount: number;
|
|
58
58
|
secondaryPaidAmount: number;
|
|
59
59
|
}>;
|
|
60
60
|
}, "strip", z.ZodTypeAny, {
|
|
61
|
-
paymentMethod: PaymentMethod;
|
|
62
61
|
pricing: {
|
|
63
|
-
total: number;
|
|
64
62
|
deliveryFee: number;
|
|
65
63
|
secondaryDeliveryFee: number;
|
|
66
64
|
riderTips: number;
|
|
67
65
|
secondaryRiderTips: number;
|
|
66
|
+
total: number;
|
|
68
67
|
secondaryTotal: number;
|
|
69
68
|
paidAmount: number;
|
|
70
69
|
secondaryPaidAmount: number;
|
|
71
70
|
};
|
|
72
71
|
shopProfit: number;
|
|
73
|
-
}, {
|
|
74
72
|
paymentMethod: PaymentMethod;
|
|
73
|
+
}, {
|
|
75
74
|
pricing: {
|
|
76
|
-
total: number;
|
|
77
75
|
deliveryFee: number;
|
|
78
76
|
secondaryDeliveryFee: number;
|
|
79
77
|
riderTips: number;
|
|
80
78
|
secondaryRiderTips: number;
|
|
79
|
+
total: number;
|
|
81
80
|
secondaryTotal: number;
|
|
82
81
|
paidAmount: number;
|
|
83
82
|
secondaryPaidAmount: number;
|
|
84
83
|
};
|
|
85
84
|
shopProfit: number;
|
|
85
|
+
paymentMethod: PaymentMethod;
|
|
86
86
|
}>;
|
|
87
87
|
createdAt: z.ZodEffects<z.ZodEffects<z.ZodDate, Date, Date>, Date, Date>;
|
|
88
88
|
triggerAt: z.ZodEffects<z.ZodEffects<z.ZodDate, Date, Date>, Date, Date>;
|
|
89
89
|
orderActionType: z.ZodNativeEnum<typeof OrderAction>;
|
|
90
90
|
}, "strip", z.ZodTypeAny, {
|
|
91
|
-
_id: import("mongoose").Types.ObjectId;
|
|
92
|
-
createdAt: Date;
|
|
93
91
|
user: {
|
|
94
92
|
_id: import("mongoose").Types.ObjectId;
|
|
95
93
|
name: string;
|
|
96
94
|
};
|
|
97
|
-
|
|
95
|
+
createdAt: Date;
|
|
96
|
+
_id: import("mongoose").Types.ObjectId;
|
|
98
97
|
shopId: import("mongoose").Types.ObjectId;
|
|
99
|
-
|
|
98
|
+
orderId: string;
|
|
100
99
|
triggerAt: Date;
|
|
101
100
|
adjustedFinance: {
|
|
102
|
-
paymentMethod: PaymentMethod;
|
|
103
101
|
pricing: {
|
|
104
|
-
total: number;
|
|
105
102
|
deliveryFee: number;
|
|
106
103
|
secondaryDeliveryFee: number;
|
|
107
104
|
riderTips: number;
|
|
108
105
|
secondaryRiderTips: number;
|
|
106
|
+
total: number;
|
|
109
107
|
secondaryTotal: number;
|
|
110
108
|
paidAmount: number;
|
|
111
109
|
secondaryPaidAmount: number;
|
|
112
110
|
};
|
|
113
111
|
shopProfit: number;
|
|
112
|
+
paymentMethod: PaymentMethod;
|
|
114
113
|
};
|
|
114
|
+
paymentMethod: PaymentMethod;
|
|
115
115
|
orderActionType: OrderAction;
|
|
116
116
|
orderStatus: RegularOrderStatus;
|
|
117
117
|
orderAction: OrderAction;
|
|
118
118
|
preparationTimeMinutes: number;
|
|
119
119
|
}, {
|
|
120
|
-
_id: string | import("mongoose").Types.ObjectId;
|
|
121
|
-
createdAt: Date;
|
|
122
120
|
user: {
|
|
123
121
|
_id: string | import("mongoose").Types.ObjectId;
|
|
124
122
|
name: string;
|
|
125
123
|
};
|
|
126
|
-
|
|
124
|
+
createdAt: Date;
|
|
125
|
+
_id: string | import("mongoose").Types.ObjectId;
|
|
127
126
|
shopId: string | import("mongoose").Types.ObjectId;
|
|
128
|
-
|
|
127
|
+
orderId: string;
|
|
129
128
|
triggerAt: Date;
|
|
130
129
|
adjustedFinance: {
|
|
131
|
-
paymentMethod: PaymentMethod;
|
|
132
130
|
pricing: {
|
|
133
|
-
total: number;
|
|
134
131
|
deliveryFee: number;
|
|
135
132
|
secondaryDeliveryFee: number;
|
|
136
133
|
riderTips: number;
|
|
137
134
|
secondaryRiderTips: number;
|
|
135
|
+
total: number;
|
|
138
136
|
secondaryTotal: number;
|
|
139
137
|
paidAmount: number;
|
|
140
138
|
secondaryPaidAmount: number;
|
|
141
139
|
};
|
|
142
140
|
shopProfit: number;
|
|
141
|
+
paymentMethod: PaymentMethod;
|
|
143
142
|
};
|
|
143
|
+
paymentMethod: PaymentMethod;
|
|
144
144
|
orderActionType: OrderAction;
|
|
145
145
|
orderStatus: RegularOrderStatus;
|
|
146
146
|
orderAction: OrderAction;
|
|
@@ -183,108 +183,108 @@ export declare class OrderActionsSocketEvent extends BaseSocketEvent<typeof Orde
|
|
|
183
183
|
riderTips: z.ZodNumber;
|
|
184
184
|
secondaryRiderTips: z.ZodNumber;
|
|
185
185
|
}, "strip", z.ZodTypeAny, {
|
|
186
|
-
total: number;
|
|
187
186
|
deliveryFee: number;
|
|
188
187
|
secondaryDeliveryFee: number;
|
|
189
188
|
riderTips: number;
|
|
190
189
|
secondaryRiderTips: number;
|
|
190
|
+
total: number;
|
|
191
191
|
secondaryTotal: number;
|
|
192
192
|
paidAmount: number;
|
|
193
193
|
secondaryPaidAmount: number;
|
|
194
194
|
}, {
|
|
195
|
-
total: number;
|
|
196
195
|
deliveryFee: number;
|
|
197
196
|
secondaryDeliveryFee: number;
|
|
198
197
|
riderTips: number;
|
|
199
198
|
secondaryRiderTips: number;
|
|
199
|
+
total: number;
|
|
200
200
|
secondaryTotal: number;
|
|
201
201
|
paidAmount: number;
|
|
202
202
|
secondaryPaidAmount: number;
|
|
203
203
|
}>;
|
|
204
204
|
}, "strip", z.ZodTypeAny, {
|
|
205
|
-
paymentMethod: PaymentMethod;
|
|
206
205
|
pricing: {
|
|
207
|
-
total: number;
|
|
208
206
|
deliveryFee: number;
|
|
209
207
|
secondaryDeliveryFee: number;
|
|
210
208
|
riderTips: number;
|
|
211
209
|
secondaryRiderTips: number;
|
|
210
|
+
total: number;
|
|
212
211
|
secondaryTotal: number;
|
|
213
212
|
paidAmount: number;
|
|
214
213
|
secondaryPaidAmount: number;
|
|
215
214
|
};
|
|
216
215
|
shopProfit: number;
|
|
217
|
-
}, {
|
|
218
216
|
paymentMethod: PaymentMethod;
|
|
217
|
+
}, {
|
|
219
218
|
pricing: {
|
|
220
|
-
total: number;
|
|
221
219
|
deliveryFee: number;
|
|
222
220
|
secondaryDeliveryFee: number;
|
|
223
221
|
riderTips: number;
|
|
224
222
|
secondaryRiderTips: number;
|
|
223
|
+
total: number;
|
|
225
224
|
secondaryTotal: number;
|
|
226
225
|
paidAmount: number;
|
|
227
226
|
secondaryPaidAmount: number;
|
|
228
227
|
};
|
|
229
228
|
shopProfit: number;
|
|
229
|
+
paymentMethod: PaymentMethod;
|
|
230
230
|
}>;
|
|
231
231
|
createdAt: z.ZodEffects<z.ZodEffects<z.ZodDate, Date, Date>, Date, Date>;
|
|
232
232
|
triggerAt: z.ZodEffects<z.ZodEffects<z.ZodDate, Date, Date>, Date, Date>;
|
|
233
233
|
orderActionType: z.ZodNativeEnum<typeof OrderAction>;
|
|
234
234
|
}, "strip", z.ZodTypeAny, {
|
|
235
|
-
_id: import("mongoose").Types.ObjectId;
|
|
236
|
-
createdAt: Date;
|
|
237
235
|
user: {
|
|
238
236
|
_id: import("mongoose").Types.ObjectId;
|
|
239
237
|
name: string;
|
|
240
238
|
};
|
|
241
|
-
|
|
239
|
+
createdAt: Date;
|
|
240
|
+
_id: import("mongoose").Types.ObjectId;
|
|
242
241
|
shopId: import("mongoose").Types.ObjectId;
|
|
243
|
-
|
|
242
|
+
orderId: string;
|
|
244
243
|
triggerAt: Date;
|
|
245
244
|
adjustedFinance: {
|
|
246
|
-
paymentMethod: PaymentMethod;
|
|
247
245
|
pricing: {
|
|
248
|
-
total: number;
|
|
249
246
|
deliveryFee: number;
|
|
250
247
|
secondaryDeliveryFee: number;
|
|
251
248
|
riderTips: number;
|
|
252
249
|
secondaryRiderTips: number;
|
|
250
|
+
total: number;
|
|
253
251
|
secondaryTotal: number;
|
|
254
252
|
paidAmount: number;
|
|
255
253
|
secondaryPaidAmount: number;
|
|
256
254
|
};
|
|
257
255
|
shopProfit: number;
|
|
256
|
+
paymentMethod: PaymentMethod;
|
|
258
257
|
};
|
|
258
|
+
paymentMethod: PaymentMethod;
|
|
259
259
|
orderActionType: OrderAction;
|
|
260
260
|
orderStatus: RegularOrderStatus;
|
|
261
261
|
orderAction: OrderAction;
|
|
262
262
|
preparationTimeMinutes: number;
|
|
263
263
|
}, {
|
|
264
|
-
_id: string | import("mongoose").Types.ObjectId;
|
|
265
|
-
createdAt: Date;
|
|
266
264
|
user: {
|
|
267
265
|
_id: string | import("mongoose").Types.ObjectId;
|
|
268
266
|
name: string;
|
|
269
267
|
};
|
|
270
|
-
|
|
268
|
+
createdAt: Date;
|
|
269
|
+
_id: string | import("mongoose").Types.ObjectId;
|
|
271
270
|
shopId: string | import("mongoose").Types.ObjectId;
|
|
272
|
-
|
|
271
|
+
orderId: string;
|
|
273
272
|
triggerAt: Date;
|
|
274
273
|
adjustedFinance: {
|
|
275
|
-
paymentMethod: PaymentMethod;
|
|
276
274
|
pricing: {
|
|
277
|
-
total: number;
|
|
278
275
|
deliveryFee: number;
|
|
279
276
|
secondaryDeliveryFee: number;
|
|
280
277
|
riderTips: number;
|
|
281
278
|
secondaryRiderTips: number;
|
|
279
|
+
total: number;
|
|
282
280
|
secondaryTotal: number;
|
|
283
281
|
paidAmount: number;
|
|
284
282
|
secondaryPaidAmount: number;
|
|
285
283
|
};
|
|
286
284
|
shopProfit: number;
|
|
285
|
+
paymentMethod: PaymentMethod;
|
|
287
286
|
};
|
|
287
|
+
paymentMethod: PaymentMethod;
|
|
288
288
|
orderActionType: OrderAction;
|
|
289
289
|
orderStatus: RegularOrderStatus;
|
|
290
290
|
orderAction: OrderAction;
|
|
@@ -19,18 +19,18 @@ export declare const RiderLocationUpdateSocketOutputSchema: z.ZodObject<{
|
|
|
19
19
|
bearing: z.ZodOptional<z.ZodNumber>;
|
|
20
20
|
updatedAt: z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, Date, string>, z.ZodDate]>, Date, string | Date>, Date, string | Date>;
|
|
21
21
|
}, "strip", z.ZodTypeAny, {
|
|
22
|
-
_id: import("mongoose").Types.ObjectId;
|
|
23
22
|
updatedAt: Date;
|
|
23
|
+
_id: import("mongoose").Types.ObjectId;
|
|
24
|
+
riderId: import("mongoose").Types.ObjectId;
|
|
24
25
|
latitude: number;
|
|
25
26
|
longitude: number;
|
|
26
|
-
riderId: import("mongoose").Types.ObjectId;
|
|
27
27
|
bearing?: number | undefined;
|
|
28
28
|
}, {
|
|
29
|
-
_id: string | import("mongoose").Types.ObjectId;
|
|
30
29
|
updatedAt: string | Date;
|
|
30
|
+
_id: string | import("mongoose").Types.ObjectId;
|
|
31
|
+
riderId: string | import("mongoose").Types.ObjectId;
|
|
31
32
|
latitude: number;
|
|
32
33
|
longitude: number;
|
|
33
|
-
riderId: string | import("mongoose").Types.ObjectId;
|
|
34
34
|
bearing?: number | undefined;
|
|
35
35
|
}>;
|
|
36
36
|
export type RiderLocationUpdateSocketInputDTO = DTO<typeof RiderLocationUpdateSocketInputSchema>;
|
|
@@ -55,18 +55,18 @@ export declare class RiderLocationUpdateSocketEvent extends BaseSocketEvent<type
|
|
|
55
55
|
bearing: z.ZodOptional<z.ZodNumber>;
|
|
56
56
|
updatedAt: z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, Date, string>, z.ZodDate]>, Date, string | Date>, Date, string | Date>;
|
|
57
57
|
}, "strip", z.ZodTypeAny, {
|
|
58
|
-
_id: import("mongoose").Types.ObjectId;
|
|
59
58
|
updatedAt: Date;
|
|
59
|
+
_id: import("mongoose").Types.ObjectId;
|
|
60
|
+
riderId: import("mongoose").Types.ObjectId;
|
|
60
61
|
latitude: number;
|
|
61
62
|
longitude: number;
|
|
62
|
-
riderId: import("mongoose").Types.ObjectId;
|
|
63
63
|
bearing?: number | undefined;
|
|
64
64
|
}, {
|
|
65
|
-
_id: string | import("mongoose").Types.ObjectId;
|
|
66
65
|
updatedAt: string | Date;
|
|
66
|
+
_id: string | import("mongoose").Types.ObjectId;
|
|
67
|
+
riderId: string | import("mongoose").Types.ObjectId;
|
|
67
68
|
latitude: number;
|
|
68
69
|
longitude: number;
|
|
69
|
-
riderId: string | import("mongoose").Types.ObjectId;
|
|
70
70
|
bearing?: number | undefined;
|
|
71
71
|
}>;
|
|
72
72
|
};
|