@managesome/eposmatic-toolkit 0.4.62 → 0.4.63
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_SCHEMA_VERSIONS.js +17 -0
- package/esm/constants/WORKER_ENDPOINTS.js +2 -2
- package/esm/helpers/materialized-reports/index.js +3 -0
- package/esm/helpers/materialized-reports/materialized-credit-bills-helpers.js +3 -3
- package/esm/helpers/materialized-reports/materialized-delivery-close-day-helpers.js +5 -5
- package/esm/helpers/materialized-reports/materialized-delivery-compile-helpers.js +2 -2
- package/esm/helpers/materialized-reports/materialized-dialer-close-day-helpers.js +5 -5
- package/esm/helpers/materialized-reports/materialized-dialer-compile-helpers.js +2 -2
- package/esm/helpers/materialized-reports/materialized-dinein-close-day-helpers.js +5 -5
- package/esm/helpers/materialized-reports/materialized-dinein-compile-helpers.js +2 -2
- package/esm/helpers/materialized-reports/materialized-discount-compile-helpers.js +3 -3
- package/esm/helpers/materialized-reports/materialized-document-size.js +2 -2
- package/esm/helpers/materialized-reports/materialized-prep-time-close-day-helpers.js +3 -3
- package/esm/helpers/materialized-reports/materialized-prep-time-compile-helpers.js +3 -3
- package/esm/helpers/materialized-reports/report-compile.js +38 -0
- package/esm/helpers/materialized-reports/tenant-sales-overview-bson.js +27 -0
- package/esm/helpers/materialized-reports/tenant-sales-overview-helpers.js +3 -22
- package/esm/schemas/models/materialized_credit_bills.js +2 -1
- package/esm/schemas/models/materialized_tenant_delivery_entries.js +2 -1
- package/esm/schemas/models/materialized_tenant_delivery_reports.js +2 -1
- package/esm/schemas/models/materialized_tenant_dialer_entries.js +2 -1
- package/esm/schemas/models/materialized_tenant_dialer_reports.js +2 -1
- package/esm/schemas/models/materialized_tenant_dinein_entries.js +2 -1
- package/esm/schemas/models/materialized_tenant_dinein_reports.js +2 -1
- package/esm/schemas/models/materialized_tenant_sales_overview_reports.js +2 -1
- package/lib/constants/MATERIALIZED_SCHEMA_VERSIONS.d.ts +17 -0
- package/lib/constants/MATERIALIZED_SCHEMA_VERSIONS.js +20 -0
- package/lib/constants/WORKER_ENDPOINTS.d.ts +0 -2
- package/lib/constants/WORKER_ENDPOINTS.js +2 -2
- package/lib/helpers/materialized-reports/index.d.ts +2 -0
- package/lib/helpers/materialized-reports/index.js +26 -0
- package/lib/helpers/materialized-reports/materialized-credit-bills-helpers.js +4 -4
- package/lib/helpers/materialized-reports/materialized-delivery-close-day-helpers.js +6 -6
- package/lib/helpers/materialized-reports/materialized-delivery-compile-helpers.js +4 -4
- package/lib/helpers/materialized-reports/materialized-dialer-close-day-helpers.js +6 -6
- package/lib/helpers/materialized-reports/materialized-dialer-compile-helpers.js +6 -6
- package/lib/helpers/materialized-reports/materialized-dinein-close-day-helpers.js +6 -6
- package/lib/helpers/materialized-reports/materialized-dinein-compile-helpers.js +6 -6
- package/lib/helpers/materialized-reports/materialized-discount-compile-helpers.js +3 -3
- package/lib/helpers/materialized-reports/materialized-document-size.js +2 -5
- package/lib/helpers/materialized-reports/materialized-prep-time-close-day-helpers.js +3 -3
- package/lib/helpers/materialized-reports/materialized-prep-time-compile-helpers.js +3 -3
- package/lib/helpers/materialized-reports/report-compile.d.ts +38 -0
- package/lib/helpers/materialized-reports/report-compile.js +87 -0
- package/lib/helpers/materialized-reports/tenant-sales-overview-bson.d.ts +12 -0
- package/lib/helpers/materialized-reports/tenant-sales-overview-bson.js +33 -0
- package/lib/helpers/materialized-reports/tenant-sales-overview-helpers.d.ts +1 -12
- package/lib/helpers/materialized-reports/tenant-sales-overview-helpers.js +4 -24
- package/lib/schemas/models/materialized_credit_bills.d.ts +29 -46
- package/lib/schemas/models/materialized_credit_bills.js +3 -2
- package/lib/schemas/models/materialized_tenant_cash_entries.d.ts +9 -9
- package/lib/schemas/models/materialized_tenant_cash_reports.d.ts +9 -9
- package/lib/schemas/models/materialized_tenant_delivery_entries.d.ts +11 -10
- package/lib/schemas/models/materialized_tenant_delivery_entries.js +3 -2
- package/lib/schemas/models/materialized_tenant_delivery_geo_cells.d.ts +9 -9
- package/lib/schemas/models/materialized_tenant_delivery_geo_scopes.d.ts +6 -6
- package/lib/schemas/models/materialized_tenant_delivery_reports.d.ts +11 -10
- package/lib/schemas/models/materialized_tenant_delivery_reports.js +3 -2
- package/lib/schemas/models/materialized_tenant_dialer_entries.d.ts +8 -7
- package/lib/schemas/models/materialized_tenant_dialer_entries.js +3 -2
- package/lib/schemas/models/materialized_tenant_dialer_reports.d.ts +11 -10
- package/lib/schemas/models/materialized_tenant_dialer_reports.js +3 -2
- package/lib/schemas/models/materialized_tenant_dinein_entries.d.ts +8 -7
- package/lib/schemas/models/materialized_tenant_dinein_entries.js +3 -2
- package/lib/schemas/models/materialized_tenant_dinein_reports.d.ts +11 -10
- package/lib/schemas/models/materialized_tenant_dinein_reports.js +3 -2
- package/lib/schemas/models/materialized_tenant_discount_entries.d.ts +9 -9
- package/lib/schemas/models/materialized_tenant_discount_reports.d.ts +9 -9
- package/lib/schemas/models/materialized_tenant_discount_sources.d.ts +9 -9
- package/lib/schemas/models/materialized_tenant_hourly_comparison_entries.d.ts +9 -9
- package/lib/schemas/models/materialized_tenant_hourly_comparison_reports.d.ts +9 -9
- package/lib/schemas/models/materialized_tenant_payments_comparison_entries.d.ts +9 -9
- package/lib/schemas/models/materialized_tenant_payments_comparison_reports.d.ts +9 -9
- package/lib/schemas/models/materialized_tenant_prep_time_entries.d.ts +9 -9
- package/lib/schemas/models/materialized_tenant_prep_time_reports.d.ts +9 -9
- package/lib/schemas/models/materialized_tenant_sales_comparison_entries.d.ts +9 -9
- package/lib/schemas/models/materialized_tenant_sales_comparison_reports.d.ts +9 -9
- package/lib/schemas/models/materialized_tenant_sales_overview_reports.d.ts +11 -35
- package/lib/schemas/models/materialized_tenant_sales_overview_reports.js +3 -2
- package/lib/tests/materialized-reports/tenant-sales-overview-close-day-helpers.test.js +2 -1
- package/lib/tests/materialized-reports/tenant-sales-overview-helpers.test.js +5 -4
- package/lib/tests/reporting-contract/no-live-transport.test.js +106 -0
- package/package.json +2 -1
- package/lib/helpers/order/payment-collection.d.ts +0 -25
- package/lib/helpers/order/payment-collection.js +0 -51
- package/lib/schemas/models/applied_order_discounts.d.ts +0 -80
- package/lib/schemas/models/applied_order_discounts.js +0 -106
- package/lib/schemas/types/applied_order_discounts.d.ts +0 -22
- package/lib/schemas/types/applied_order_discounts.js +0 -2
- package/lib/tests/materialized-reports/analytics-overview-helpers.test.d.ts +0 -1
- package/lib/tests/materialized-reports/analytics-performance-helpers.test.d.ts +0 -1
- package/lib/tests/payment-collection-timestamps.test.d.ts +0 -1
- package/lib/tests/payment-collection-timestamps.test.js +0 -71
- /package/lib/tests/{materialized-reports/analytics-growth-helpers.test.d.ts → reporting-contract/no-live-transport.test.d.ts} +0 -0
|
@@ -10,10 +10,33 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
11
11
|
o[k2] = m[k];
|
|
12
12
|
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
13
18
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
19
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
20
|
};
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
16
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.reportCompile = void 0;
|
|
17
40
|
__exportStar(require("./key-helpers"), exports);
|
|
18
41
|
__exportStar(require("./materialized-credit-bills-helpers"), exports);
|
|
19
42
|
__exportStar(require("./materialized-day-readiness"), exports);
|
|
@@ -85,4 +108,7 @@ __exportStar(require("./tenant-dinein-formatter"), exports);
|
|
|
85
108
|
__exportStar(require("./tenant-prep-time-formatter"), exports);
|
|
86
109
|
__exportStar(require("./tenant-sales-overview-formatter"), exports);
|
|
87
110
|
__exportStar(require("./tenant-sales-overview-helpers"), exports);
|
|
111
|
+
__exportStar(require("./tenant-sales-overview-bson"), exports);
|
|
88
112
|
__exportStar(require("./report-platform"), exports);
|
|
113
|
+
// Worker-only PURE compile surface (also importable via the deep lib path).
|
|
114
|
+
exports.reportCompile = __importStar(require("./report-compile"));
|
|
@@ -16,10 +16,10 @@ exports.getMaterializedCreditBillScopeRefsForIssue = getMaterializedCreditBillSc
|
|
|
16
16
|
exports.computeMaterializedCreditBillTotalsFromReports = computeMaterializedCreditBillTotalsFromReports;
|
|
17
17
|
exports.computeMaterializedCreditBillTotalsFromReportsByKey = computeMaterializedCreditBillTotalsFromReportsByKey;
|
|
18
18
|
exports.buildMaterializedCreditBillSelectionFromScopeGroups = buildMaterializedCreditBillSelectionFromScopeGroups;
|
|
19
|
-
const
|
|
19
|
+
const bson_objectid_1 = __importDefault(require("bson-objectid"));
|
|
20
20
|
const constants_1 = require("../../constants");
|
|
21
21
|
const MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
|
|
22
|
-
const
|
|
22
|
+
const MATERIALIZED_SCHEMA_VERSIONS_1 = require("../../constants/MATERIALIZED_SCHEMA_VERSIONS");
|
|
23
23
|
const time_helpers_1 = require("../utils/time-helpers");
|
|
24
24
|
const key_helpers_1 = require("./key-helpers");
|
|
25
25
|
const materialized_day_input_signature_1 = require("./materialized-day-input-signature");
|
|
@@ -543,7 +543,7 @@ function buildMaterializedCreditBillDayReports(input) {
|
|
|
543
543
|
return [];
|
|
544
544
|
const sourceWatermark = watermark ?? computedAt;
|
|
545
545
|
const makeDoc = (scopeContext, scopeField, sections) => ({
|
|
546
|
-
_id: new
|
|
546
|
+
_id: new bson_objectid_1.default().toHexString(),
|
|
547
547
|
tenant_id: tenantId,
|
|
548
548
|
brand_id: brandId,
|
|
549
549
|
scope_context: scopeContext,
|
|
@@ -555,7 +555,7 @@ function buildMaterializedCreditBillDayReports(input) {
|
|
|
555
555
|
sale_type_key_filters: [...MATERIALIZED_REPORTS_1.SALES_OVERVIEW_KEY_FILTERS],
|
|
556
556
|
credit_bills: sections,
|
|
557
557
|
iteration: 1,
|
|
558
|
-
schema_version:
|
|
558
|
+
schema_version: MATERIALIZED_SCHEMA_VERSIONS_1.MATERIALIZED_CREDIT_BILLS_SCHEMA_VERSION,
|
|
559
559
|
source_watermark: sourceWatermark,
|
|
560
560
|
source_input_signature: sourceInputSignature,
|
|
561
561
|
computed_at: computedAt,
|
|
@@ -9,9 +9,9 @@ exports.needsMaterializedDeliveryReportWrite = needsMaterializedDeliveryReportWr
|
|
|
9
9
|
exports.needsMaterializedDeliveryEntriesWrite = needsMaterializedDeliveryEntriesWrite;
|
|
10
10
|
exports.foldMaterializedDeliveryPeriodCounters = foldMaterializedDeliveryPeriodCounters;
|
|
11
11
|
exports.buildTenantDeliveryCloseDayPlan = buildTenantDeliveryCloseDayPlan;
|
|
12
|
-
const
|
|
12
|
+
const bson_objectid_1 = __importDefault(require("bson-objectid"));
|
|
13
13
|
const MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
|
|
14
|
-
const
|
|
14
|
+
const MATERIALIZED_SCHEMA_VERSIONS_1 = require("../../constants/MATERIALIZED_SCHEMA_VERSIONS");
|
|
15
15
|
const materialized_delivery_accumulator_helpers_1 = require("./materialized-delivery-accumulator-helpers");
|
|
16
16
|
const materialized_delivery_classification_helpers_1 = require("./materialized-delivery-classification-helpers");
|
|
17
17
|
const materialized_delivery_compile_helpers_1 = require("./materialized-delivery-compile-helpers");
|
|
@@ -166,7 +166,7 @@ function buildTenantDeliveryCloseDayPlan(input) {
|
|
|
166
166
|
const existing = storedReportsByScope.get(deliveryScopeKey(compiledDateDoc));
|
|
167
167
|
const next = {
|
|
168
168
|
...compiledDateDoc,
|
|
169
|
-
_id: existing?._id ?? new
|
|
169
|
+
_id: existing?._id ?? new bson_objectid_1.default().toHexString(),
|
|
170
170
|
iteration: Number(existing?.iteration ?? 0) + 1,
|
|
171
171
|
};
|
|
172
172
|
if (force || needsMaterializedDeliveryReportWrite(existing, next))
|
|
@@ -248,7 +248,7 @@ function buildTenantDeliveryCloseDayPlan(input) {
|
|
|
248
248
|
counterRows.push({ key, counters: folded[key] });
|
|
249
249
|
}
|
|
250
250
|
const report = {
|
|
251
|
-
_id: existing?._id ?? new
|
|
251
|
+
_id: existing?._id ?? new bson_objectid_1.default().toHexString(),
|
|
252
252
|
tenant_id: tenantId,
|
|
253
253
|
brand_id: existing?.brand_id ?? compiledDateDoc?.brand_id ?? '',
|
|
254
254
|
scope_context: scope,
|
|
@@ -263,7 +263,7 @@ function buildTenantDeliveryCloseDayPlan(input) {
|
|
|
263
263
|
iteration: existing?.iteration,
|
|
264
264
|
// A folded period is always a CURRENT-shape document. v1 data must be wiped and
|
|
265
265
|
// re-closed; it is never upgraded in place.
|
|
266
|
-
schema_version: compiledDateDoc?.schema_version ??
|
|
266
|
+
schema_version: compiledDateDoc?.schema_version ?? MATERIALIZED_SCHEMA_VERSIONS_1.MATERIALIZED_TENANT_DELIVERY_REPORTS_SCHEMA_VERSION,
|
|
267
267
|
// FROM THE DAYS THAT BELONG TO THIS PERIOD - never the stored watermark, and never
|
|
268
268
|
// an unrelated day from another period. Using every sibling day would rewrite a
|
|
269
269
|
// period whenever any other month moved.
|
|
@@ -287,7 +287,7 @@ function buildTenantDeliveryCloseDayPlan(input) {
|
|
|
287
287
|
const existing = storedEntriesByPage.get(key) ?? null;
|
|
288
288
|
const next = {
|
|
289
289
|
...compiled,
|
|
290
|
-
_id: existing?._id ?? new
|
|
290
|
+
_id: existing?._id ?? new bson_objectid_1.default().toHexString(),
|
|
291
291
|
iteration: Number(existing?.iteration ?? 0) + 1,
|
|
292
292
|
};
|
|
293
293
|
if (existing == null || force || needsMaterializedDeliveryEntriesWrite(existing, next)) {
|
|
@@ -9,8 +9,8 @@ exports.compileTenantDeliveryReports = compileTenantDeliveryReports;
|
|
|
9
9
|
const ENUMS_1 = require("../../constants/ENUMS");
|
|
10
10
|
const MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
|
|
11
11
|
const delivery_1 = require("../../constants/enums/delivery");
|
|
12
|
-
const
|
|
13
|
-
const
|
|
12
|
+
const MATERIALIZED_SCHEMA_VERSIONS_1 = require("../../constants/MATERIALIZED_SCHEMA_VERSIONS");
|
|
13
|
+
const MATERIALIZED_SCHEMA_VERSIONS_2 = require("../../constants/MATERIALIZED_SCHEMA_VERSIONS");
|
|
14
14
|
const materialized_delivery_accumulator_helpers_1 = require("./materialized-delivery-accumulator-helpers");
|
|
15
15
|
const materialized_delivery_classification_helpers_1 = require("./materialized-delivery-classification-helpers");
|
|
16
16
|
const materialized_delivery_entry_pages_1 = require("./materialized-delivery-entry-pages");
|
|
@@ -328,7 +328,7 @@ function compileTenantDeliveryReports(input) {
|
|
|
328
328
|
sale_type_key_filters: [...MATERIALIZED_REPORTS_1.DELIVERY_KEY_FILTERS],
|
|
329
329
|
delivery_counters: deliveryCounters,
|
|
330
330
|
delivery_counter_rows: deliveryCounterRows,
|
|
331
|
-
schema_version:
|
|
331
|
+
schema_version: MATERIALIZED_SCHEMA_VERSIONS_2.MATERIALIZED_TENANT_DELIVERY_REPORTS_SCHEMA_VERSION,
|
|
332
332
|
source_watermark: watermark,
|
|
333
333
|
computed_at: computedAt,
|
|
334
334
|
createdAt: computedAt,
|
|
@@ -359,7 +359,7 @@ function compileTenantDeliveryReports(input) {
|
|
|
359
359
|
sale_type_key_filters: [...MATERIALIZED_REPORTS_1.DELIVERY_KEY_FILTERS],
|
|
360
360
|
delivery_entries: entrySections,
|
|
361
361
|
off_app_order_count: offAppCount,
|
|
362
|
-
schema_version:
|
|
362
|
+
schema_version: MATERIALIZED_SCHEMA_VERSIONS_1.MATERIALIZED_TENANT_DELIVERY_ENTRIES_SCHEMA_VERSION,
|
|
363
363
|
source_watermark: watermark,
|
|
364
364
|
computed_at: computedAt,
|
|
365
365
|
createdAt: computedAt,
|
|
@@ -9,9 +9,9 @@ exports.needsMaterializedDialerReportWrite = needsMaterializedDialerReportWrite;
|
|
|
9
9
|
exports.needsMaterializedDialerEntriesWrite = needsMaterializedDialerEntriesWrite;
|
|
10
10
|
exports.foldMaterializedDialerPeriodCounters = foldMaterializedDialerPeriodCounters;
|
|
11
11
|
exports.buildTenantDialerCloseDayPlan = buildTenantDialerCloseDayPlan;
|
|
12
|
-
const
|
|
12
|
+
const bson_objectid_1 = __importDefault(require("bson-objectid"));
|
|
13
13
|
const MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
|
|
14
|
-
const
|
|
14
|
+
const MATERIALIZED_SCHEMA_VERSIONS_1 = require("../../constants/MATERIALIZED_SCHEMA_VERSIONS");
|
|
15
15
|
const materialized_dialer_accumulator_helpers_1 = require("./materialized-dialer-accumulator-helpers");
|
|
16
16
|
const materialized_dialer_entry_pages_1 = require("./materialized-dialer-entry-pages");
|
|
17
17
|
const materialized_document_size_1 = require("./materialized-document-size");
|
|
@@ -166,7 +166,7 @@ function buildTenantDialerCloseDayPlan(input) {
|
|
|
166
166
|
const existing = storedReportsByScope.get(dialerScopeKey(compiledDateDoc));
|
|
167
167
|
const next = {
|
|
168
168
|
...compiledDateDoc,
|
|
169
|
-
_id: existing?._id ?? new
|
|
169
|
+
_id: existing?._id ?? new bson_objectid_1.default().toHexString(),
|
|
170
170
|
iteration: Number(existing?.iteration ?? 0) + 1,
|
|
171
171
|
};
|
|
172
172
|
if (force || needsMaterializedDialerReportWrite(existing, next))
|
|
@@ -239,7 +239,7 @@ function buildTenantDialerCloseDayPlan(input) {
|
|
|
239
239
|
for (const key of keys)
|
|
240
240
|
counters[key] = folded[key];
|
|
241
241
|
const report = {
|
|
242
|
-
_id: existing?._id ?? new
|
|
242
|
+
_id: existing?._id ?? new bson_objectid_1.default().toHexString(),
|
|
243
243
|
tenant_id: tenantId,
|
|
244
244
|
brand_id: existing?.brand_id ?? compiledDateDoc?.brand_id ?? '',
|
|
245
245
|
scope_context: scope,
|
|
@@ -248,7 +248,7 @@ function buildTenantDialerCloseDayPlan(input) {
|
|
|
248
248
|
sale_type_key_filters: [...MATERIALIZED_REPORTS_1.DIALER_KEY_FILTERS],
|
|
249
249
|
dialer_counters: counters,
|
|
250
250
|
iteration: existing?.iteration,
|
|
251
|
-
schema_version: compiledDateDoc?.schema_version ??
|
|
251
|
+
schema_version: compiledDateDoc?.schema_version ?? MATERIALIZED_SCHEMA_VERSIONS_1.MATERIALIZED_TENANT_DIALER_REPORTS_SCHEMA_VERSION,
|
|
252
252
|
// FROM THE DAYS THAT BELONG TO THIS PERIOD — never the stored watermark,
|
|
253
253
|
// and never an unrelated day from another period.
|
|
254
254
|
source_watermark: watermarkOfDays(nextDayDocs.filter((dayDoc) => {
|
|
@@ -271,7 +271,7 @@ function buildTenantDialerCloseDayPlan(input) {
|
|
|
271
271
|
const existing = storedEntriesByPage.get(key) ?? null;
|
|
272
272
|
const next = {
|
|
273
273
|
...compiled,
|
|
274
|
-
_id: existing?._id ?? new
|
|
274
|
+
_id: existing?._id ?? new bson_objectid_1.default().toHexString(),
|
|
275
275
|
iteration: Number(existing?.iteration ?? 0) + 1,
|
|
276
276
|
};
|
|
277
277
|
if (existing == null || force || needsMaterializedDialerEntriesWrite(existing, next)) {
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.compileTenantDialerReports = compileTenantDialerReports;
|
|
4
4
|
const MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
5
|
+
const MATERIALIZED_SCHEMA_VERSIONS_1 = require("../../constants/MATERIALIZED_SCHEMA_VERSIONS");
|
|
6
|
+
const MATERIALIZED_SCHEMA_VERSIONS_2 = require("../../constants/MATERIALIZED_SCHEMA_VERSIONS");
|
|
7
|
+
const materialized_tenant_dialer_reports_1 = require("../../schemas/types/materialized_tenant_dialer_reports");
|
|
8
8
|
const materialized_dialer_accumulator_helpers_1 = require("./materialized-dialer-accumulator-helpers");
|
|
9
9
|
const materialized_dialer_entry_pages_1 = require("./materialized-dialer-entry-pages");
|
|
10
10
|
const materialized_dialer_key_helpers_1 = require("./materialized-dialer-key-helpers");
|
|
@@ -116,9 +116,9 @@ function compileTenantDialerReports(input) {
|
|
|
116
116
|
scope_context: MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_DATE,
|
|
117
117
|
scope_field: localDate,
|
|
118
118
|
day_index: dayIndex,
|
|
119
|
-
sale_type_key_filters: [...
|
|
119
|
+
sale_type_key_filters: [...materialized_tenant_dialer_reports_1.MATERIALIZED_DIALER_REPORT_KEY_FILTERS],
|
|
120
120
|
dialer_counters: dialerCounters,
|
|
121
|
-
schema_version:
|
|
121
|
+
schema_version: MATERIALIZED_SCHEMA_VERSIONS_2.MATERIALIZED_TENANT_DIALER_REPORTS_SCHEMA_VERSION,
|
|
122
122
|
source_watermark: watermark,
|
|
123
123
|
computed_at: computedAt,
|
|
124
124
|
createdAt: computedAt,
|
|
@@ -144,7 +144,7 @@ function compileTenantDialerReports(input) {
|
|
|
144
144
|
page,
|
|
145
145
|
day_index: scope === MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_DATE ? dayIndex : null,
|
|
146
146
|
dialer_entries: entrySections,
|
|
147
|
-
schema_version:
|
|
147
|
+
schema_version: MATERIALIZED_SCHEMA_VERSIONS_1.MATERIALIZED_TENANT_DIALER_ENTRIES_SCHEMA_VERSION,
|
|
148
148
|
source_watermark: watermark,
|
|
149
149
|
computed_at: computedAt,
|
|
150
150
|
createdAt: computedAt,
|
|
@@ -9,9 +9,9 @@ exports.needsMaterializedDineinReportWrite = needsMaterializedDineinReportWrite;
|
|
|
9
9
|
exports.needsMaterializedDineinEntriesWrite = needsMaterializedDineinEntriesWrite;
|
|
10
10
|
exports.foldMaterializedDineinPeriodCounters = foldMaterializedDineinPeriodCounters;
|
|
11
11
|
exports.buildTenantDineinCloseDayPlan = buildTenantDineinCloseDayPlan;
|
|
12
|
-
const
|
|
12
|
+
const bson_objectid_1 = __importDefault(require("bson-objectid"));
|
|
13
13
|
const MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
|
|
14
|
-
const
|
|
14
|
+
const MATERIALIZED_SCHEMA_VERSIONS_1 = require("../../constants/MATERIALIZED_SCHEMA_VERSIONS");
|
|
15
15
|
const materialized_dinein_accumulator_helpers_1 = require("./materialized-dinein-accumulator-helpers");
|
|
16
16
|
const materialized_document_size_1 = require("./materialized-document-size");
|
|
17
17
|
const materialized_dinein_entry_pages_1 = require("./materialized-dinein-entry-pages");
|
|
@@ -183,7 +183,7 @@ function buildTenantDineinCloseDayPlan(input) {
|
|
|
183
183
|
const existing = storedReportsByScope.get(dineinScopeKey(compiledDateDoc));
|
|
184
184
|
const next = {
|
|
185
185
|
...compiledDateDoc,
|
|
186
|
-
_id: existing?._id ?? new
|
|
186
|
+
_id: existing?._id ?? new bson_objectid_1.default().toHexString(),
|
|
187
187
|
iteration: Number(existing?.iteration ?? 0) + 1,
|
|
188
188
|
};
|
|
189
189
|
if (force || needsMaterializedDineinReportWrite(existing, next))
|
|
@@ -271,7 +271,7 @@ function buildTenantDineinCloseDayPlan(input) {
|
|
|
271
271
|
for (const key of keys)
|
|
272
272
|
counters[key] = folded.counters[key];
|
|
273
273
|
const report = {
|
|
274
|
-
_id: existing?._id ?? new
|
|
274
|
+
_id: existing?._id ?? new bson_objectid_1.default().toHexString(),
|
|
275
275
|
tenant_id: tenantId,
|
|
276
276
|
brand_id: existing?.brand_id ?? compiledDateDoc?.brand_id ?? '',
|
|
277
277
|
scope_context: scope,
|
|
@@ -287,7 +287,7 @@ function buildTenantDineinCloseDayPlan(input) {
|
|
|
287
287
|
top_edited_checks: folded.topEditedChecks,
|
|
288
288
|
iteration: existing?.iteration,
|
|
289
289
|
// A folded period is always a CURRENT-shape document.
|
|
290
|
-
schema_version: compiledDateDoc?.schema_version ??
|
|
290
|
+
schema_version: compiledDateDoc?.schema_version ?? MATERIALIZED_SCHEMA_VERSIONS_1.MATERIALIZED_TENANT_DINEIN_REPORTS_SCHEMA_VERSION,
|
|
291
291
|
// FROM THE DAYS THAT BELONG TO THIS PERIOD - never the stored watermark.
|
|
292
292
|
source_watermark: watermarkOfDays(nextDayDocs.filter((dayDoc) => {
|
|
293
293
|
const fields = (0, scope_helpers_1.getMaterializedPeriodScopeFields)(String(dayDoc?.scope_field));
|
|
@@ -309,7 +309,7 @@ function buildTenantDineinCloseDayPlan(input) {
|
|
|
309
309
|
const existing = storedEntriesByPage.get(key) ?? null;
|
|
310
310
|
const next = {
|
|
311
311
|
...compiled,
|
|
312
|
-
_id: existing?._id ?? new
|
|
312
|
+
_id: existing?._id ?? new bson_objectid_1.default().toHexString(),
|
|
313
313
|
iteration: Number(existing?.iteration ?? 0) + 1,
|
|
314
314
|
};
|
|
315
315
|
if (existing == null || force || needsMaterializedDineinEntriesWrite(existing, next)) {
|
|
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.maskReservationGuestLabel = maskReservationGuestLabel;
|
|
4
4
|
exports.compileTenantDineinReports = compileTenantDineinReports;
|
|
5
5
|
const MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
6
|
+
const MATERIALIZED_SCHEMA_VERSIONS_1 = require("../../constants/MATERIALIZED_SCHEMA_VERSIONS");
|
|
7
|
+
const MATERIALIZED_SCHEMA_VERSIONS_2 = require("../../constants/MATERIALIZED_SCHEMA_VERSIONS");
|
|
8
|
+
const materialized_tenant_dinein_reports_1 = require("../../schemas/types/materialized_tenant_dinein_reports");
|
|
9
9
|
const materialized_dinein_accumulator_helpers_1 = require("./materialized-dinein-accumulator-helpers");
|
|
10
10
|
const materialized_dinein_classification_helpers_1 = require("./materialized-dinein-classification-helpers");
|
|
11
11
|
const materialized_dinein_entry_pages_1 = require("./materialized-dinein-entry-pages");
|
|
@@ -429,12 +429,12 @@ function compileTenantDineinReports(input) {
|
|
|
429
429
|
scope_context: MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_DATE,
|
|
430
430
|
scope_field: localDate,
|
|
431
431
|
day_index: dayIndex,
|
|
432
|
-
sale_type_key_filters: [...
|
|
432
|
+
sale_type_key_filters: [...materialized_tenant_dinein_reports_1.MATERIALIZED_DINEIN_REPORT_KEY_FILTERS],
|
|
433
433
|
dinein_counters: dineinCounters,
|
|
434
434
|
reservation_counters: reservationCounters,
|
|
435
435
|
upcoming_reservations: (0, materialized_dinein_accumulator_helpers_1.mergeMaterializedDineinUpcomingReservations)([upcomingReservations], MATERIALIZED_REPORTS_1.MATERIALIZED_DINEIN_UPCOMING_RESERVATION_LIMIT),
|
|
436
436
|
top_edited_checks: (0, materialized_dinein_accumulator_helpers_1.mergeMaterializedDineinTopEditedChecks)([topEditedChecks], MATERIALIZED_REPORTS_1.MATERIALIZED_DINEIN_TOP_EDITED_CHECK_LIMIT),
|
|
437
|
-
schema_version:
|
|
437
|
+
schema_version: MATERIALIZED_SCHEMA_VERSIONS_2.MATERIALIZED_TENANT_DINEIN_REPORTS_SCHEMA_VERSION,
|
|
438
438
|
source_watermark: watermark,
|
|
439
439
|
computed_at: computedAt,
|
|
440
440
|
createdAt: computedAt,
|
|
@@ -470,7 +470,7 @@ function compileTenantDineinReports(input) {
|
|
|
470
470
|
page,
|
|
471
471
|
day_index: scope === MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_DATE ? dayIndex : null,
|
|
472
472
|
dinein_entries: sections,
|
|
473
|
-
schema_version:
|
|
473
|
+
schema_version: MATERIALIZED_SCHEMA_VERSIONS_1.MATERIALIZED_TENANT_DINEIN_ENTRIES_SCHEMA_VERSION,
|
|
474
474
|
source_watermark: watermark,
|
|
475
475
|
computed_at: computedAt,
|
|
476
476
|
createdAt: computedAt,
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.MATERIALIZED_DISCOUNT_COMPILED_SCOPES = void 0;
|
|
7
7
|
exports.compileTenantDiscountReports = compileTenantDiscountReports;
|
|
8
|
-
const
|
|
8
|
+
const bson_objectid_1 = __importDefault(require("bson-objectid"));
|
|
9
9
|
const MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
|
|
10
10
|
const materialized_discount_accumulator_helpers_1 = require("./materialized-discount-accumulator-helpers");
|
|
11
11
|
const materialized_discount_classification_helpers_1 = require("./materialized-discount-classification-helpers");
|
|
@@ -163,7 +163,7 @@ function compileTenantDiscountReports(input) {
|
|
|
163
163
|
const docWatermark = watermark ?? sourceWatermark;
|
|
164
164
|
const isDateScoped = scope === MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_DATE || scope === MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_HOUR;
|
|
165
165
|
reports.push({
|
|
166
|
-
_id: new
|
|
166
|
+
_id: new bson_objectid_1.default().toHexString(),
|
|
167
167
|
tenant_id: tenantId,
|
|
168
168
|
brand_id: brandId,
|
|
169
169
|
scope_context: scope,
|
|
@@ -186,7 +186,7 @@ function compileTenantDiscountReports(input) {
|
|
|
186
186
|
// Entries documents exist only when there is at least one row.
|
|
187
187
|
if (Object.keys(entrySections).length > 0) {
|
|
188
188
|
entriesDocs.push({
|
|
189
|
-
_id: new
|
|
189
|
+
_id: new bson_objectid_1.default().toHexString(),
|
|
190
190
|
tenant_id: tenantId,
|
|
191
191
|
brand_id: brandId,
|
|
192
192
|
scope_context: scope,
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.materializedDocumentBsonBytes = materializedDocumentBsonBytes;
|
|
7
4
|
exports.assertMaterializedDocumentSize = assertMaterializedDocumentSize;
|
|
8
5
|
exports.assertMaterializedDocumentsSize = assertMaterializedDocumentsSize;
|
|
9
|
-
const
|
|
6
|
+
const bson_1 = require("bson");
|
|
10
7
|
/**
|
|
11
8
|
* The BSON SIZE BUDGET of a materialized report/entry/geo document.
|
|
12
9
|
*
|
|
@@ -39,7 +36,7 @@ const mongoose_1 = __importDefault(require("mongoose"));
|
|
|
39
36
|
function materializedDocumentBsonBytes(document) {
|
|
40
37
|
if (document == null)
|
|
41
38
|
return 0;
|
|
42
|
-
return
|
|
39
|
+
return (0, bson_1.calculateObjectSize)(document);
|
|
43
40
|
}
|
|
44
41
|
/**
|
|
45
42
|
* Throws when ONE document exceeds its budget.
|
|
@@ -12,7 +12,7 @@ exports.getMaterializedPrepTimePeriodDayScopeFields = getMaterializedPrepTimePer
|
|
|
12
12
|
exports.getMaterializedPrepTimeReportPeriodDayScopeFields = getMaterializedPrepTimeReportPeriodDayScopeFields;
|
|
13
13
|
exports.needsMaterializedPrepTimeReportWrite = needsMaterializedPrepTimeReportWrite;
|
|
14
14
|
exports.buildTenantPrepTimeCloseDayPlan = buildTenantPrepTimeCloseDayPlan;
|
|
15
|
-
const
|
|
15
|
+
const bson_objectid_1 = __importDefault(require("bson-objectid"));
|
|
16
16
|
const MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
|
|
17
17
|
const materialized_prep_time_classification_helpers_1 = require("./materialized-prep-time-classification-helpers");
|
|
18
18
|
const materialized_prep_time_compile_helpers_1 = require("./materialized-prep-time-compile-helpers");
|
|
@@ -375,7 +375,7 @@ function buildTenantPrepTimeCloseDayPlan(input) {
|
|
|
375
375
|
const report = {
|
|
376
376
|
// A period document created by the fold gets a fresh id; an existing one keeps
|
|
377
377
|
// its identity so the upsert targets the same row.
|
|
378
|
-
_id: existingDoc?._id ?? new
|
|
378
|
+
_id: existingDoc?._id ?? new bson_objectid_1.default().toHexString(),
|
|
379
379
|
tenant_id: tenantId,
|
|
380
380
|
brand_id: existingDoc?.brand_id ?? reports[0]?.brand_id ?? '',
|
|
381
381
|
scope_context: scope,
|
|
@@ -486,7 +486,7 @@ function buildTenantPrepTimeCloseDayPlan(input) {
|
|
|
486
486
|
}
|
|
487
487
|
}
|
|
488
488
|
const report = {
|
|
489
|
-
_id: existingDoc?._id ?? new
|
|
489
|
+
_id: existingDoc?._id ?? new bson_objectid_1.default().toHexString(),
|
|
490
490
|
tenant_id: tenantId,
|
|
491
491
|
brand_id: existingDoc?.brand_id ?? entries[0]?.brand_id ?? '',
|
|
492
492
|
scope_context: scope,
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.mergeMaterializedPrepTimeCounters = mergeMaterializedPrepTimeCounters;
|
|
7
7
|
exports.compileTenantPrepTimeReports = compileTenantPrepTimeReports;
|
|
8
|
-
const
|
|
8
|
+
const bson_objectid_1 = __importDefault(require("bson-objectid"));
|
|
9
9
|
const MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
|
|
10
10
|
const materialized_prep_time_classification_helpers_1 = require("./materialized-prep-time-classification-helpers");
|
|
11
11
|
const scope_helpers_1 = require("./scope-helpers");
|
|
@@ -176,7 +176,7 @@ function compileTenantPrepTimeReports(input) {
|
|
|
176
176
|
const docWatermark = watermark ?? sourceWatermark;
|
|
177
177
|
const isDateScoped = scopeContext === MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_DATE;
|
|
178
178
|
reports.push({
|
|
179
|
-
_id: new
|
|
179
|
+
_id: new bson_objectid_1.default().toHexString(),
|
|
180
180
|
tenant_id: tenantId,
|
|
181
181
|
brand_id: brandId,
|
|
182
182
|
scope_context: scopeContext,
|
|
@@ -194,7 +194,7 @@ function compileTenantPrepTimeReports(input) {
|
|
|
194
194
|
});
|
|
195
195
|
if (itemScopes.has(scopeContext) && Object.keys(entrySections).length > 0) {
|
|
196
196
|
entries.push({
|
|
197
|
-
_id: new
|
|
197
|
+
_id: new bson_objectid_1.default().toHexString(),
|
|
198
198
|
tenant_id: tenantId,
|
|
199
199
|
brand_id: brandId,
|
|
200
200
|
scope_context: scopeContext,
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PURE materialized-report COMPILE entrypoint.
|
|
3
|
+
*
|
|
4
|
+
* This module is the workers-service Piscina worker's toolkit surface. Its
|
|
5
|
+
* transitive import graph contains NO mongoose, NO schema model, NO DB
|
|
6
|
+
* initializer and NO model registration: every close-day plan/compile helper
|
|
7
|
+
* was moved to pure modules (schema-version constants live in
|
|
8
|
+
* `constants/MATERIALIZED_SCHEMA_VERSIONS`, ObjectIds are generated with
|
|
9
|
+
* `bson-objectid`, document size uses the `bson` calculator).
|
|
10
|
+
*
|
|
11
|
+
* Import the ROOT toolkit barrel for the service-facing API; import THIS module
|
|
12
|
+
* (or its built `lib/helpers/materialized-reports/report-compile.js` path) from
|
|
13
|
+
* a worker.
|
|
14
|
+
*/
|
|
15
|
+
export { MATERIALIZED_DINEIN_ORIGIN_ENUM, MATERIALIZED_DINEIN_REPORT_SCOPES, MATERIALIZED_DINEIN_SPLIT_PARENT_DELETE_REASON, MATERIALIZED_DINEIN_UNKNOWN_TOKEN, MATERIALIZED_PREP_TIME_ITEM_SCOPES, MATERIALIZED_PREP_TIME_REPORT_SCOPES, MATERIALIZED_REPORT_SCOPE_ENUM, } from '../../constants/MATERIALIZED_REPORTS';
|
|
16
|
+
export { MATERIALIZED_CREDIT_BILLS_SCHEMA_VERSION, MATERIALIZED_TENANT_DINEIN_ENTRIES_SCHEMA_VERSION, MATERIALIZED_TENANT_DINEIN_REPORTS_SCHEMA_VERSION, } from '../../constants/MATERIALIZED_SCHEMA_VERSIONS';
|
|
17
|
+
export { SALES_OVERVIEW_KEY_FILTERS } from '../../constants/MATERIALIZED_REPORTS';
|
|
18
|
+
export { REPORT_SALE_TYPE_ENUM } from '../../constants/ANALYTICS';
|
|
19
|
+
export { compileTenantPrepTimeReports } from './materialized-prep-time-compile-helpers';
|
|
20
|
+
export { buildTenantPrepTimeCloseDayPlan, getMaterializedPrepTimePeriodDayScopeFields, getMaterializedPrepTimeReportPeriodDayScopeFields, } from './materialized-prep-time-close-day-helpers';
|
|
21
|
+
export { compileTenantDiscountReports } from './materialized-discount-compile-helpers';
|
|
22
|
+
export { buildTenantDiscountCloseDayPlan } from './materialized-discount-close-day-helpers';
|
|
23
|
+
export { compileTenantDeliveryReports } from './materialized-delivery-compile-helpers';
|
|
24
|
+
export { buildTenantDeliveryCloseDayPlan } from './materialized-delivery-close-day-helpers';
|
|
25
|
+
export { compileTenantDeliveryGeoCellsWithStats } from './materialized-tenant-delivery-geo-helpers';
|
|
26
|
+
export { compileTenantDialerReports } from './materialized-dialer-compile-helpers';
|
|
27
|
+
export { buildTenantDialerCloseDayPlan } from './materialized-dialer-close-day-helpers';
|
|
28
|
+
export { compileTenantDineinReports } from './materialized-dinein-compile-helpers';
|
|
29
|
+
export { buildTenantDineinCloseDayPlan, foldMaterializedDineinPeriodCounters, } from './materialized-dinein-close-day-helpers';
|
|
30
|
+
export { pruneDocumentDineinMaps } from './materialized-dinein-accumulator-helpers';
|
|
31
|
+
export { dineinKeyPassesFilters } from './materialized-dinein-key-helpers';
|
|
32
|
+
export { mergeMaterializedDineinEntryPages } from './materialized-dinein-entry-pages';
|
|
33
|
+
export { getMaterializedPeriodScopeFields, parseMaterializedLocalDate } from './scope-helpers';
|
|
34
|
+
export { REPORT_KEY_ENUM, REPORT_MODE_ENUM, buildReportDetailsResponse, buildReportMeta, buildReportResponse, } from '../reporting-contract/report-contract';
|
|
35
|
+
export { convertOrdersToMaterializedTenantSalesOverviewReports, sumMaterializedTenantSalesOverviewReports, } from './tenant-sales-overview-helpers';
|
|
36
|
+
export { buildTenantSalesOverviewCloseDayPlan } from './tenant-sales-overview-close-day-helpers';
|
|
37
|
+
export { applyCreditResolutionToReportDocuments, buildMaterializedCreditBillSelectionFromScopeGroups, computeMaterializedCreditBillTotalsFromReportsByKey, getMaterializedCreditBillScopeRefsForDay, getMaterializedCreditBillScopeRefsForIssue, resolveCreditBillDay, } from './materialized-credit-bills-helpers';
|
|
38
|
+
export { normalizeOverviewAggregatedShape } from '../reporting-contract/overview-contract';
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* PURE materialized-report COMPILE entrypoint.
|
|
4
|
+
*
|
|
5
|
+
* This module is the workers-service Piscina worker's toolkit surface. Its
|
|
6
|
+
* transitive import graph contains NO mongoose, NO schema model, NO DB
|
|
7
|
+
* initializer and NO model registration: every close-day plan/compile helper
|
|
8
|
+
* was moved to pure modules (schema-version constants live in
|
|
9
|
+
* `constants/MATERIALIZED_SCHEMA_VERSIONS`, ObjectIds are generated with
|
|
10
|
+
* `bson-objectid`, document size uses the `bson` calculator).
|
|
11
|
+
*
|
|
12
|
+
* Import the ROOT toolkit barrel for the service-facing API; import THIS module
|
|
13
|
+
* (or its built `lib/helpers/materialized-reports/report-compile.js` path) from
|
|
14
|
+
* a worker.
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.normalizeOverviewAggregatedShape = exports.resolveCreditBillDay = exports.getMaterializedCreditBillScopeRefsForIssue = exports.getMaterializedCreditBillScopeRefsForDay = exports.computeMaterializedCreditBillTotalsFromReportsByKey = exports.buildMaterializedCreditBillSelectionFromScopeGroups = exports.applyCreditResolutionToReportDocuments = exports.buildTenantSalesOverviewCloseDayPlan = exports.sumMaterializedTenantSalesOverviewReports = exports.convertOrdersToMaterializedTenantSalesOverviewReports = exports.buildReportResponse = exports.buildReportMeta = exports.buildReportDetailsResponse = exports.REPORT_MODE_ENUM = exports.REPORT_KEY_ENUM = exports.parseMaterializedLocalDate = exports.getMaterializedPeriodScopeFields = exports.mergeMaterializedDineinEntryPages = exports.dineinKeyPassesFilters = exports.pruneDocumentDineinMaps = exports.foldMaterializedDineinPeriodCounters = exports.buildTenantDineinCloseDayPlan = exports.compileTenantDineinReports = exports.buildTenantDialerCloseDayPlan = exports.compileTenantDialerReports = exports.compileTenantDeliveryGeoCellsWithStats = exports.buildTenantDeliveryCloseDayPlan = exports.compileTenantDeliveryReports = exports.buildTenantDiscountCloseDayPlan = exports.compileTenantDiscountReports = exports.getMaterializedPrepTimeReportPeriodDayScopeFields = exports.getMaterializedPrepTimePeriodDayScopeFields = exports.buildTenantPrepTimeCloseDayPlan = exports.compileTenantPrepTimeReports = exports.REPORT_SALE_TYPE_ENUM = exports.SALES_OVERVIEW_KEY_FILTERS = exports.MATERIALIZED_TENANT_DINEIN_REPORTS_SCHEMA_VERSION = exports.MATERIALIZED_TENANT_DINEIN_ENTRIES_SCHEMA_VERSION = exports.MATERIALIZED_CREDIT_BILLS_SCHEMA_VERSION = exports.MATERIALIZED_REPORT_SCOPE_ENUM = exports.MATERIALIZED_PREP_TIME_REPORT_SCOPES = exports.MATERIALIZED_PREP_TIME_ITEM_SCOPES = exports.MATERIALIZED_DINEIN_UNKNOWN_TOKEN = exports.MATERIALIZED_DINEIN_SPLIT_PARENT_DELETE_REASON = exports.MATERIALIZED_DINEIN_REPORT_SCOPES = exports.MATERIALIZED_DINEIN_ORIGIN_ENUM = void 0;
|
|
18
|
+
var MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
|
|
19
|
+
Object.defineProperty(exports, "MATERIALIZED_DINEIN_ORIGIN_ENUM", { enumerable: true, get: function () { return MATERIALIZED_REPORTS_1.MATERIALIZED_DINEIN_ORIGIN_ENUM; } });
|
|
20
|
+
Object.defineProperty(exports, "MATERIALIZED_DINEIN_REPORT_SCOPES", { enumerable: true, get: function () { return MATERIALIZED_REPORTS_1.MATERIALIZED_DINEIN_REPORT_SCOPES; } });
|
|
21
|
+
Object.defineProperty(exports, "MATERIALIZED_DINEIN_SPLIT_PARENT_DELETE_REASON", { enumerable: true, get: function () { return MATERIALIZED_REPORTS_1.MATERIALIZED_DINEIN_SPLIT_PARENT_DELETE_REASON; } });
|
|
22
|
+
Object.defineProperty(exports, "MATERIALIZED_DINEIN_UNKNOWN_TOKEN", { enumerable: true, get: function () { return MATERIALIZED_REPORTS_1.MATERIALIZED_DINEIN_UNKNOWN_TOKEN; } });
|
|
23
|
+
Object.defineProperty(exports, "MATERIALIZED_PREP_TIME_ITEM_SCOPES", { enumerable: true, get: function () { return MATERIALIZED_REPORTS_1.MATERIALIZED_PREP_TIME_ITEM_SCOPES; } });
|
|
24
|
+
Object.defineProperty(exports, "MATERIALIZED_PREP_TIME_REPORT_SCOPES", { enumerable: true, get: function () { return MATERIALIZED_REPORTS_1.MATERIALIZED_PREP_TIME_REPORT_SCOPES; } });
|
|
25
|
+
Object.defineProperty(exports, "MATERIALIZED_REPORT_SCOPE_ENUM", { enumerable: true, get: function () { return MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_SCOPE_ENUM; } });
|
|
26
|
+
var MATERIALIZED_SCHEMA_VERSIONS_1 = require("../../constants/MATERIALIZED_SCHEMA_VERSIONS");
|
|
27
|
+
Object.defineProperty(exports, "MATERIALIZED_CREDIT_BILLS_SCHEMA_VERSION", { enumerable: true, get: function () { return MATERIALIZED_SCHEMA_VERSIONS_1.MATERIALIZED_CREDIT_BILLS_SCHEMA_VERSION; } });
|
|
28
|
+
Object.defineProperty(exports, "MATERIALIZED_TENANT_DINEIN_ENTRIES_SCHEMA_VERSION", { enumerable: true, get: function () { return MATERIALIZED_SCHEMA_VERSIONS_1.MATERIALIZED_TENANT_DINEIN_ENTRIES_SCHEMA_VERSION; } });
|
|
29
|
+
Object.defineProperty(exports, "MATERIALIZED_TENANT_DINEIN_REPORTS_SCHEMA_VERSION", { enumerable: true, get: function () { return MATERIALIZED_SCHEMA_VERSIONS_1.MATERIALIZED_TENANT_DINEIN_REPORTS_SCHEMA_VERSION; } });
|
|
30
|
+
var MATERIALIZED_REPORTS_2 = require("../../constants/MATERIALIZED_REPORTS");
|
|
31
|
+
Object.defineProperty(exports, "SALES_OVERVIEW_KEY_FILTERS", { enumerable: true, get: function () { return MATERIALIZED_REPORTS_2.SALES_OVERVIEW_KEY_FILTERS; } });
|
|
32
|
+
var ANALYTICS_1 = require("../../constants/ANALYTICS");
|
|
33
|
+
Object.defineProperty(exports, "REPORT_SALE_TYPE_ENUM", { enumerable: true, get: function () { return ANALYTICS_1.REPORT_SALE_TYPE_ENUM; } });
|
|
34
|
+
var materialized_prep_time_compile_helpers_1 = require("./materialized-prep-time-compile-helpers");
|
|
35
|
+
Object.defineProperty(exports, "compileTenantPrepTimeReports", { enumerable: true, get: function () { return materialized_prep_time_compile_helpers_1.compileTenantPrepTimeReports; } });
|
|
36
|
+
var materialized_prep_time_close_day_helpers_1 = require("./materialized-prep-time-close-day-helpers");
|
|
37
|
+
Object.defineProperty(exports, "buildTenantPrepTimeCloseDayPlan", { enumerable: true, get: function () { return materialized_prep_time_close_day_helpers_1.buildTenantPrepTimeCloseDayPlan; } });
|
|
38
|
+
Object.defineProperty(exports, "getMaterializedPrepTimePeriodDayScopeFields", { enumerable: true, get: function () { return materialized_prep_time_close_day_helpers_1.getMaterializedPrepTimePeriodDayScopeFields; } });
|
|
39
|
+
Object.defineProperty(exports, "getMaterializedPrepTimeReportPeriodDayScopeFields", { enumerable: true, get: function () { return materialized_prep_time_close_day_helpers_1.getMaterializedPrepTimeReportPeriodDayScopeFields; } });
|
|
40
|
+
var materialized_discount_compile_helpers_1 = require("./materialized-discount-compile-helpers");
|
|
41
|
+
Object.defineProperty(exports, "compileTenantDiscountReports", { enumerable: true, get: function () { return materialized_discount_compile_helpers_1.compileTenantDiscountReports; } });
|
|
42
|
+
var materialized_discount_close_day_helpers_1 = require("./materialized-discount-close-day-helpers");
|
|
43
|
+
Object.defineProperty(exports, "buildTenantDiscountCloseDayPlan", { enumerable: true, get: function () { return materialized_discount_close_day_helpers_1.buildTenantDiscountCloseDayPlan; } });
|
|
44
|
+
var materialized_delivery_compile_helpers_1 = require("./materialized-delivery-compile-helpers");
|
|
45
|
+
Object.defineProperty(exports, "compileTenantDeliveryReports", { enumerable: true, get: function () { return materialized_delivery_compile_helpers_1.compileTenantDeliveryReports; } });
|
|
46
|
+
var materialized_delivery_close_day_helpers_1 = require("./materialized-delivery-close-day-helpers");
|
|
47
|
+
Object.defineProperty(exports, "buildTenantDeliveryCloseDayPlan", { enumerable: true, get: function () { return materialized_delivery_close_day_helpers_1.buildTenantDeliveryCloseDayPlan; } });
|
|
48
|
+
var materialized_tenant_delivery_geo_helpers_1 = require("./materialized-tenant-delivery-geo-helpers");
|
|
49
|
+
Object.defineProperty(exports, "compileTenantDeliveryGeoCellsWithStats", { enumerable: true, get: function () { return materialized_tenant_delivery_geo_helpers_1.compileTenantDeliveryGeoCellsWithStats; } });
|
|
50
|
+
var materialized_dialer_compile_helpers_1 = require("./materialized-dialer-compile-helpers");
|
|
51
|
+
Object.defineProperty(exports, "compileTenantDialerReports", { enumerable: true, get: function () { return materialized_dialer_compile_helpers_1.compileTenantDialerReports; } });
|
|
52
|
+
var materialized_dialer_close_day_helpers_1 = require("./materialized-dialer-close-day-helpers");
|
|
53
|
+
Object.defineProperty(exports, "buildTenantDialerCloseDayPlan", { enumerable: true, get: function () { return materialized_dialer_close_day_helpers_1.buildTenantDialerCloseDayPlan; } });
|
|
54
|
+
var materialized_dinein_compile_helpers_1 = require("./materialized-dinein-compile-helpers");
|
|
55
|
+
Object.defineProperty(exports, "compileTenantDineinReports", { enumerable: true, get: function () { return materialized_dinein_compile_helpers_1.compileTenantDineinReports; } });
|
|
56
|
+
var materialized_dinein_close_day_helpers_1 = require("./materialized-dinein-close-day-helpers");
|
|
57
|
+
Object.defineProperty(exports, "buildTenantDineinCloseDayPlan", { enumerable: true, get: function () { return materialized_dinein_close_day_helpers_1.buildTenantDineinCloseDayPlan; } });
|
|
58
|
+
Object.defineProperty(exports, "foldMaterializedDineinPeriodCounters", { enumerable: true, get: function () { return materialized_dinein_close_day_helpers_1.foldMaterializedDineinPeriodCounters; } });
|
|
59
|
+
var materialized_dinein_accumulator_helpers_1 = require("./materialized-dinein-accumulator-helpers");
|
|
60
|
+
Object.defineProperty(exports, "pruneDocumentDineinMaps", { enumerable: true, get: function () { return materialized_dinein_accumulator_helpers_1.pruneDocumentDineinMaps; } });
|
|
61
|
+
var materialized_dinein_key_helpers_1 = require("./materialized-dinein-key-helpers");
|
|
62
|
+
Object.defineProperty(exports, "dineinKeyPassesFilters", { enumerable: true, get: function () { return materialized_dinein_key_helpers_1.dineinKeyPassesFilters; } });
|
|
63
|
+
var materialized_dinein_entry_pages_1 = require("./materialized-dinein-entry-pages");
|
|
64
|
+
Object.defineProperty(exports, "mergeMaterializedDineinEntryPages", { enumerable: true, get: function () { return materialized_dinein_entry_pages_1.mergeMaterializedDineinEntryPages; } });
|
|
65
|
+
var scope_helpers_1 = require("./scope-helpers");
|
|
66
|
+
Object.defineProperty(exports, "getMaterializedPeriodScopeFields", { enumerable: true, get: function () { return scope_helpers_1.getMaterializedPeriodScopeFields; } });
|
|
67
|
+
Object.defineProperty(exports, "parseMaterializedLocalDate", { enumerable: true, get: function () { return scope_helpers_1.parseMaterializedLocalDate; } });
|
|
68
|
+
var report_contract_1 = require("../reporting-contract/report-contract");
|
|
69
|
+
Object.defineProperty(exports, "REPORT_KEY_ENUM", { enumerable: true, get: function () { return report_contract_1.REPORT_KEY_ENUM; } });
|
|
70
|
+
Object.defineProperty(exports, "REPORT_MODE_ENUM", { enumerable: true, get: function () { return report_contract_1.REPORT_MODE_ENUM; } });
|
|
71
|
+
Object.defineProperty(exports, "buildReportDetailsResponse", { enumerable: true, get: function () { return report_contract_1.buildReportDetailsResponse; } });
|
|
72
|
+
Object.defineProperty(exports, "buildReportMeta", { enumerable: true, get: function () { return report_contract_1.buildReportMeta; } });
|
|
73
|
+
Object.defineProperty(exports, "buildReportResponse", { enumerable: true, get: function () { return report_contract_1.buildReportResponse; } });
|
|
74
|
+
var tenant_sales_overview_helpers_1 = require("./tenant-sales-overview-helpers");
|
|
75
|
+
Object.defineProperty(exports, "convertOrdersToMaterializedTenantSalesOverviewReports", { enumerable: true, get: function () { return tenant_sales_overview_helpers_1.convertOrdersToMaterializedTenantSalesOverviewReports; } });
|
|
76
|
+
Object.defineProperty(exports, "sumMaterializedTenantSalesOverviewReports", { enumerable: true, get: function () { return tenant_sales_overview_helpers_1.sumMaterializedTenantSalesOverviewReports; } });
|
|
77
|
+
var tenant_sales_overview_close_day_helpers_1 = require("./tenant-sales-overview-close-day-helpers");
|
|
78
|
+
Object.defineProperty(exports, "buildTenantSalesOverviewCloseDayPlan", { enumerable: true, get: function () { return tenant_sales_overview_close_day_helpers_1.buildTenantSalesOverviewCloseDayPlan; } });
|
|
79
|
+
var materialized_credit_bills_helpers_1 = require("./materialized-credit-bills-helpers");
|
|
80
|
+
Object.defineProperty(exports, "applyCreditResolutionToReportDocuments", { enumerable: true, get: function () { return materialized_credit_bills_helpers_1.applyCreditResolutionToReportDocuments; } });
|
|
81
|
+
Object.defineProperty(exports, "buildMaterializedCreditBillSelectionFromScopeGroups", { enumerable: true, get: function () { return materialized_credit_bills_helpers_1.buildMaterializedCreditBillSelectionFromScopeGroups; } });
|
|
82
|
+
Object.defineProperty(exports, "computeMaterializedCreditBillTotalsFromReportsByKey", { enumerable: true, get: function () { return materialized_credit_bills_helpers_1.computeMaterializedCreditBillTotalsFromReportsByKey; } });
|
|
83
|
+
Object.defineProperty(exports, "getMaterializedCreditBillScopeRefsForDay", { enumerable: true, get: function () { return materialized_credit_bills_helpers_1.getMaterializedCreditBillScopeRefsForDay; } });
|
|
84
|
+
Object.defineProperty(exports, "getMaterializedCreditBillScopeRefsForIssue", { enumerable: true, get: function () { return materialized_credit_bills_helpers_1.getMaterializedCreditBillScopeRefsForIssue; } });
|
|
85
|
+
Object.defineProperty(exports, "resolveCreditBillDay", { enumerable: true, get: function () { return materialized_credit_bills_helpers_1.resolveCreditBillDay; } });
|
|
86
|
+
var overview_contract_1 = require("../reporting-contract/overview-contract");
|
|
87
|
+
Object.defineProperty(exports, "normalizeOverviewAggregatedShape", { enumerable: true, get: function () { return overview_contract_1.normalizeOverviewAggregatedShape; } });
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import mongoose from 'mongoose';
|
|
2
|
+
import type { IMaterializedTenantSalesOverviewReport } from '../../schemas/types/materialized_tenant_sales_overview_reports';
|
|
3
|
+
/**
|
|
4
|
+
* Casts a JSON materialized report through the collection's mongoose schema,
|
|
5
|
+
* returning a hydrated document ready to be saved / bulk-written (the
|
|
6
|
+
* `sale_type_metrics` plain object becomes a `Map`, date strings become
|
|
7
|
+
* `Date` instances, etc.).
|
|
8
|
+
*
|
|
9
|
+
* The document is NOT validated here — `save()` / `Model.validate()` still
|
|
10
|
+
* runs the schema validators.
|
|
11
|
+
*/
|
|
12
|
+
export declare function convertMaterializedTenantSalesOverviewReportJsonToBson(report: IMaterializedTenantSalesOverviewReport): mongoose.HydratedDocument<IMaterializedTenantSalesOverviewReport>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.convertMaterializedTenantSalesOverviewReportJsonToBson = convertMaterializedTenantSalesOverviewReportJsonToBson;
|
|
7
|
+
const mongoose_1 = __importDefault(require("mongoose"));
|
|
8
|
+
const materialized_tenant_sales_overview_reports_1 = require("../../schemas/models/materialized_tenant_sales_overview_reports");
|
|
9
|
+
/**
|
|
10
|
+
* MAIN-THREAD-ONLY Overview persistence adapter.
|
|
11
|
+
*
|
|
12
|
+
* Deliberately SPLIT from `tenant-sales-overview-helpers.ts`: the compile
|
|
13
|
+
* helpers must stay mongoose-free for the workers-service Piscina compile
|
|
14
|
+
* graph, while the BSON casting step needs the mongoose schema. Importing this
|
|
15
|
+
* file is the ONLY way to pull mongoose into the Overview compile path — and
|
|
16
|
+
* the worker never imports it.
|
|
17
|
+
*/
|
|
18
|
+
function getMaterializedTenantSalesOverviewReportModel() {
|
|
19
|
+
return (mongoose_1.default.models[materialized_tenant_sales_overview_reports_1.MATERIALIZED_TENANT_SALES_OVERVIEW_REPORTS_COLLECTION_NAME] ??
|
|
20
|
+
mongoose_1.default.model(materialized_tenant_sales_overview_reports_1.MATERIALIZED_TENANT_SALES_OVERVIEW_REPORTS_COLLECTION_NAME, materialized_tenant_sales_overview_reports_1.MaterializedTenantSalesOverviewReportSchema, materialized_tenant_sales_overview_reports_1.MATERIALIZED_TENANT_SALES_OVERVIEW_REPORTS_COLLECTION_NAME));
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Casts a JSON materialized report through the collection's mongoose schema,
|
|
24
|
+
* returning a hydrated document ready to be saved / bulk-written (the
|
|
25
|
+
* `sale_type_metrics` plain object becomes a `Map`, date strings become
|
|
26
|
+
* `Date` instances, etc.).
|
|
27
|
+
*
|
|
28
|
+
* The document is NOT validated here — `save()` / `Model.validate()` still
|
|
29
|
+
* runs the schema validators.
|
|
30
|
+
*/
|
|
31
|
+
function convertMaterializedTenantSalesOverviewReportJsonToBson(report) {
|
|
32
|
+
return new (getMaterializedTenantSalesOverviewReportModel())(report);
|
|
33
|
+
}
|