@managesome/eposmatic-toolkit 0.4.32 → 0.4.35
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/esm/constants/MATERIALIZED_REPORTS.js +22 -4
- package/esm/constants/enums/offers.js +0 -6
- package/esm/helpers/materialized-reports/index.js +1 -0
- package/esm/helpers/materialized-reports/materialized-index-bootstrap.js +4 -0
- package/esm/helpers/materialized-reports/materialized-prep-time-classification-helpers.js +12 -8
- package/esm/helpers/materialized-reports/materialized-prep-time-close-day-helpers.js +141 -10
- package/esm/helpers/materialized-reports/materialized-prep-time-compile-helpers.js +7 -3
- package/esm/helpers/materialized-reports/materialized-prep-time-read-helpers.js +638 -0
- package/esm/helpers/types/materialized-reports-apis.js +10 -0
- package/esm/schemas/models/index.js +0 -1
- package/esm/schemas/models/materialized_tenant_prep_time_entries.js +2 -2
- package/esm/schemas/types/index.js +0 -1
- package/lib/constants/MATERIALIZED_REPORTS.d.ts +17 -4
- package/lib/constants/MATERIALIZED_REPORTS.js +24 -6
- package/lib/constants/enums/offers.d.ts +0 -5
- package/lib/constants/enums/offers.js +1 -7
- package/lib/helpers/materialized-reports/index.d.ts +1 -0
- package/lib/helpers/materialized-reports/index.js +1 -0
- package/lib/helpers/materialized-reports/materialized-index-bootstrap.js +4 -0
- package/lib/helpers/materialized-reports/materialized-prep-time-classification-helpers.js +12 -8
- package/lib/helpers/materialized-reports/materialized-prep-time-close-day-helpers.d.ts +22 -0
- package/lib/helpers/materialized-reports/materialized-prep-time-close-day-helpers.js +142 -9
- package/lib/helpers/materialized-reports/materialized-prep-time-compile-helpers.js +6 -2
- package/lib/helpers/materialized-reports/materialized-prep-time-read-helpers.d.ts +198 -0
- package/lib/helpers/materialized-reports/materialized-prep-time-read-helpers.js +666 -0
- package/lib/helpers/types/materialized-reports-apis.d.ts +145 -1
- package/lib/helpers/types/materialized-reports-apis.js +11 -0
- package/lib/schemas/models/index.d.ts +0 -1
- package/lib/schemas/models/index.js +0 -1
- package/lib/schemas/models/materialized_tenant_prep_time_entries.d.ts +6 -6
- package/lib/schemas/models/materialized_tenant_prep_time_entries.js +1 -1
- package/lib/schemas/types/index.d.ts +0 -1
- package/lib/schemas/types/index.js +0 -1
- package/lib/schemas/types/materialized_tenant_prep_time_reports.d.ts +7 -5
- package/lib/tests/materialized-reports/materialized-prep-time-classification.test.js +28 -5
- package/lib/tests/materialized-reports/materialized-prep-time-close-day.test.js +33 -1
- package/lib/tests/materialized-reports/materialized-prep-time-compile.test.js +10 -1
- package/lib/tests/materialized-reports/materialized-prep-time-constants.test.js +14 -1
- package/lib/tests/materialized-reports/materialized-prep-time-duration-consistency.test.js +135 -0
- package/lib/tests/materialized-reports/materialized-prep-time-plan.test.js +106 -0
- package/lib/tests/materialized-reports/materialized-prep-time-read-helpers.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-prep-time-read-helpers.test.js +620 -0
- package/lib/tests/offers-matrix.test.d.ts +1 -0
- package/lib/tests/offers-matrix.test.js +401 -0
- package/package.json +1 -1
- package/esm/schemas/models/rewards_usage.js +0 -61
- package/lib/schemas/models/rewards_usage.d.ts +0 -53
- package/lib/schemas/models/rewards_usage.js +0 -64
- package/lib/schemas/types/rewards_usage.d.ts +0 -13
- package/lib/schemas/types/rewards_usage.js +0 -2
- /package/{esm/schemas/types/rewards_usage.js → lib/tests/materialized-reports/materialized-prep-time-duration-consistency.test.d.ts} +0 -0
|
@@ -86,6 +86,20 @@ describe('buildTenantPrepTimeCloseDayPlan', () => {
|
|
|
86
86
|
expect(write.report.prep_time_counters[KEY].coverage.item_count).toBe(3);
|
|
87
87
|
}
|
|
88
88
|
});
|
|
89
|
+
it('FOLDS ENTRY rows only for the month-capped item periods', () => {
|
|
90
|
+
const plan = build({
|
|
91
|
+
reports: [report('localDate', '2026-09-14', { coverage: { item_count: 1 } })],
|
|
92
|
+
entries: [entry('localDate', '2026-09-14', { prep_time_entries: { [KEY]: { rows: [entryRowFixture()] } } })],
|
|
93
|
+
});
|
|
94
|
+
const periodEntryScopes = plan.entryWrites
|
|
95
|
+
.filter((write) => write.report.scope_context !== 'localDate')
|
|
96
|
+
.map((write) => write.report.scope_context)
|
|
97
|
+
.sort();
|
|
98
|
+
expect(periodEntryScopes).toEqual(['localMonth', 'localWeek', 'localWeekOfYear']);
|
|
99
|
+
expect(periodEntryScopes).not.toContain('localQuarter');
|
|
100
|
+
expect(periodEntryScopes).not.toContain('localSemester');
|
|
101
|
+
expect(periodEntryScopes).not.toContain('localYear');
|
|
102
|
+
});
|
|
89
103
|
it('ACCUMULATES two closed days into the same month', () => {
|
|
90
104
|
// Day 13 is already stored; day 14 is being closed now.
|
|
91
105
|
const storedDay13 = report('localDate', '2026-09-13', { coverage: { item_count: 2 } });
|
|
@@ -174,3 +188,95 @@ describe('buildTenantPrepTimeCloseDayPlan', () => {
|
|
|
174
188
|
expect((0, materialized_prep_time_close_day_helpers_1.needsMaterializedPrepTimeReportWrite)(stored, newer)).toBe(true);
|
|
175
189
|
});
|
|
176
190
|
});
|
|
191
|
+
/** A day/period entry document (rows are irrelevant to the iteration contract). */
|
|
192
|
+
const entryRowFixture = () => ({
|
|
193
|
+
entry_key: 'item:1',
|
|
194
|
+
order_id: 'order-1',
|
|
195
|
+
item_id: '1',
|
|
196
|
+
item_name: 'Burger',
|
|
197
|
+
category_name: 'Mains',
|
|
198
|
+
anchor: 'MEASURED',
|
|
199
|
+
duration_minutes: 9,
|
|
200
|
+
prep_started_at: new Date('2026-09-14T10:00:00.000Z'),
|
|
201
|
+
ready_at: new Date('2026-09-14T10:09:00.000Z'),
|
|
202
|
+
is_ready: true,
|
|
203
|
+
target_at: null,
|
|
204
|
+
target_source: null,
|
|
205
|
+
delta_minutes: null,
|
|
206
|
+
staff_id: null,
|
|
207
|
+
staff_name: null,
|
|
208
|
+
order_status: 'COMPLETED',
|
|
209
|
+
platform: 'POS_WALK-IN',
|
|
210
|
+
created_at: new Date('2026-09-14T09:55:00.000Z'),
|
|
211
|
+
local_hour: '2026-09-14 10',
|
|
212
|
+
});
|
|
213
|
+
const entry = (scope, field, over = {}) => ({
|
|
214
|
+
_id: scope + '|' + field,
|
|
215
|
+
tenant_id: 'tenant-a',
|
|
216
|
+
brand_id: 'brand-a',
|
|
217
|
+
scope_context: scope,
|
|
218
|
+
scope_field: field,
|
|
219
|
+
day_index: scope === 'localDate' ? 'MON' : null,
|
|
220
|
+
sale_type_key_filters: ['ORDER_STATUS', 'PLATFORM'],
|
|
221
|
+
prep_time_entries: { [KEY]: { rows: [] } },
|
|
222
|
+
schema_version: 1,
|
|
223
|
+
source_watermark: new Date('2026-09-14T23:00:00.000Z'),
|
|
224
|
+
computed_at: new Date('2026-09-14T23:00:00.000Z'),
|
|
225
|
+
createdAt: new Date('2026-09-14T23:00:00.000Z'),
|
|
226
|
+
updatedAt: new Date('2026-09-14T23:00:00.000Z'),
|
|
227
|
+
...over,
|
|
228
|
+
});
|
|
229
|
+
describe('buildTenantPrepTimeCloseDayPlan - reclose iterations + force', () => {
|
|
230
|
+
it('ADVANCES the report and entry iterations on a forced reclose', () => {
|
|
231
|
+
const existingDay = report('localDate', '2026-09-14', {
|
|
232
|
+
coverage: { item_count: 2 },
|
|
233
|
+
iteration: 4,
|
|
234
|
+
});
|
|
235
|
+
const existingDayEntry = entry('localDate', '2026-09-14', { iteration: 6 });
|
|
236
|
+
const plan = build({
|
|
237
|
+
reports: [report('localDate', '2026-09-14', { coverage: { item_count: 3 } })],
|
|
238
|
+
entries: [entry('localDate', '2026-09-14')],
|
|
239
|
+
existing: [existingDay],
|
|
240
|
+
existingEntries: [existingDayEntry],
|
|
241
|
+
reason: 'RECLOSE',
|
|
242
|
+
force: true,
|
|
243
|
+
});
|
|
244
|
+
const dayWrite = plan.writes.find((write) => write.report.scope_context === 'localDate');
|
|
245
|
+
expect(dayWrite.report.iteration).toBe(5);
|
|
246
|
+
expect(dayWrite.iteration.iteration).toBe(5);
|
|
247
|
+
const dayEntryWrite = plan.entryWrites.find((write) => write.report.scope_context === 'localDate');
|
|
248
|
+
expect(dayEntryWrite.report.iteration).toBe(7);
|
|
249
|
+
expect(dayEntryWrite.iteration.iteration).toBe(7);
|
|
250
|
+
});
|
|
251
|
+
it('SKIPS an unchanged reclose without force and writes nothing', () => {
|
|
252
|
+
const existingDay = report('localDate', '2026-09-14', {
|
|
253
|
+
coverage: { item_count: 3 },
|
|
254
|
+
iteration: 4,
|
|
255
|
+
source_watermark: new Date('2026-09-14T23:05:00.000Z'),
|
|
256
|
+
});
|
|
257
|
+
const existingDayEntry = entry('localDate', '2026-09-14', {
|
|
258
|
+
iteration: 6,
|
|
259
|
+
source_watermark: new Date('2026-09-14T23:05:00.000Z'),
|
|
260
|
+
});
|
|
261
|
+
const plan = build({
|
|
262
|
+
reports: [
|
|
263
|
+
report('localDate', '2026-09-14', {
|
|
264
|
+
coverage: { item_count: 3 },
|
|
265
|
+
source_watermark: new Date('2026-09-14T23:00:00.000Z'),
|
|
266
|
+
}),
|
|
267
|
+
],
|
|
268
|
+
entries: [
|
|
269
|
+
entry('localDate', '2026-09-14', {
|
|
270
|
+
source_watermark: new Date('2026-09-14T23:00:00.000Z'),
|
|
271
|
+
}),
|
|
272
|
+
],
|
|
273
|
+
existing: [existingDay],
|
|
274
|
+
existingEntries: [existingDayEntry],
|
|
275
|
+
reason: 'RECLOSE',
|
|
276
|
+
});
|
|
277
|
+
expect(plan.writes.some((write) => write.report.scope_context === 'localDate')).toBe(false);
|
|
278
|
+
expect(plan.entryWrites.some((write) => write.report.scope_context === 'localDate')).toBe(false);
|
|
279
|
+
expect(plan.skippedDocuments.length).toBeGreaterThan(0);
|
|
280
|
+
expect(plan.skippedEntryDocuments.length).toBeGreaterThan(0);
|
|
281
|
+
});
|
|
282
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|