@managesome/eposmatic-toolkit 0.4.52 → 0.4.54
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 +106 -2
- package/esm/constants/enums/delivery.js +13 -0
- package/esm/helpers/materialized-reports/index.js +6 -0
- package/esm/helpers/materialized-reports/materialized-delivery-accumulator-helpers.js +8 -62
- package/esm/helpers/materialized-reports/materialized-delivery-classification-helpers.js +95 -73
- package/esm/helpers/materialized-reports/materialized-delivery-close-day-helpers.js +118 -146
- package/esm/helpers/materialized-reports/materialized-delivery-compile-helpers.js +304 -71
- package/esm/helpers/materialized-reports/materialized-delivery-entry-pages.js +307 -0
- package/esm/helpers/materialized-reports/materialized-delivery-index-migration.js +103 -0
- package/esm/helpers/materialized-reports/materialized-delivery-rows.js +109 -0
- package/esm/helpers/materialized-reports/materialized-delivery-wipe-targets.js +32 -0
- package/esm/helpers/materialized-reports/materialized-document-size.js +65 -0
- package/esm/helpers/materialized-reports/materialized-index-bootstrap.js +31 -16
- package/esm/helpers/materialized-reports/materialized-integer-contract.js +10 -1
- package/esm/helpers/materialized-reports/materialized-prep-time-close-day-helpers.js +3 -91
- package/esm/helpers/materialized-reports/materialized-tenant-delivery-geo-helpers.js +597 -0
- package/esm/helpers/materialized-reports/report-platform/definition.js +508 -0
- package/esm/helpers/materialized-reports/report-platform/index.js +4 -0
- package/esm/helpers/materialized-reports/report-platform/lifecycle/budget.js +27 -0
- package/esm/helpers/materialized-reports/report-platform/lifecycle/cap-metadata.js +12 -0
- package/esm/helpers/materialized-reports/report-platform/lifecycle/entry-pages.js +121 -0
- package/esm/helpers/materialized-reports/report-platform/lifecycle/flat-projection.js +14 -0
- package/esm/helpers/materialized-reports/report-platform/lifecycle/index.js +8 -0
- package/esm/helpers/materialized-reports/report-platform/lifecycle/iteration-row.js +10 -0
- package/esm/helpers/materialized-reports/report-platform/lifecycle/run-stats.js +42 -0
- package/esm/helpers/materialized-reports/report-platform/lifecycle/scope-refs.js +28 -0
- package/esm/helpers/materialized-reports/report-platform/lifecycle/top-n.js +24 -0
- package/esm/helpers/materialized-reports/report-platform/registry.js +23 -0
- package/esm/helpers/materialized-reports/report-platform/validate-report-registry.js +214 -0
- package/esm/helpers/materialized-reports/scope-helpers.js +98 -0
- package/esm/helpers/materialized-reports/tenant-delivery-formatter.js +70 -20
- package/esm/schemas/models/applied_order_discounts.js +103 -0
- package/esm/schemas/models/index.js +12 -10
- package/esm/schemas/models/materialized_tenant_delivery_entries.js +33 -12
- package/esm/schemas/models/materialized_tenant_delivery_geo_cells.js +83 -0
- package/esm/schemas/models/materialized_tenant_delivery_geo_scopes.js +35 -0
- package/esm/schemas/models/materialized_tenant_delivery_reports.js +10 -1
- package/esm/schemas/types/applied_order_discounts.js +1 -0
- package/esm/schemas/types/index.js +14 -12
- package/esm/schemas/types/materialized_tenant_delivery_geo_cells.js +1 -0
- package/esm/schemas/types/materialized_tenant_delivery_geo_scopes.js +1 -0
- package/lib/constants/MATERIALIZED_REPORTS.d.ts +95 -1
- package/lib/constants/MATERIALIZED_REPORTS.js +108 -4
- package/lib/constants/enums/delivery.d.ts +9 -0
- package/lib/constants/enums/delivery.js +14 -1
- package/lib/helpers/materialized-reports/index.d.ts +6 -0
- package/lib/helpers/materialized-reports/index.js +6 -0
- package/lib/helpers/materialized-reports/materialized-delivery-accumulator-helpers.js +8 -62
- package/lib/helpers/materialized-reports/materialized-delivery-classification-helpers.d.ts +36 -9
- package/lib/helpers/materialized-reports/materialized-delivery-classification-helpers.js +94 -72
- package/lib/helpers/materialized-reports/materialized-delivery-close-day-helpers.d.ts +23 -26
- package/lib/helpers/materialized-reports/materialized-delivery-close-day-helpers.js +121 -150
- package/lib/helpers/materialized-reports/materialized-delivery-compile-helpers.d.ts +44 -5
- package/lib/helpers/materialized-reports/materialized-delivery-compile-helpers.js +306 -69
- package/lib/helpers/materialized-reports/materialized-delivery-entry-pages.d.ts +128 -0
- package/lib/helpers/materialized-reports/materialized-delivery-entry-pages.js +322 -0
- package/lib/helpers/materialized-reports/materialized-delivery-index-migration.d.ts +48 -0
- package/lib/helpers/materialized-reports/materialized-delivery-index-migration.js +108 -0
- package/lib/helpers/materialized-reports/materialized-delivery-rows.d.ts +15 -0
- package/lib/helpers/materialized-reports/materialized-delivery-rows.js +115 -0
- package/lib/helpers/materialized-reports/materialized-delivery-wipe-targets.d.ts +17 -0
- package/lib/helpers/materialized-reports/materialized-delivery-wipe-targets.js +35 -0
- package/lib/helpers/materialized-reports/materialized-document-size.d.ts +47 -0
- package/lib/helpers/materialized-reports/materialized-document-size.js +73 -0
- package/lib/helpers/materialized-reports/materialized-index-bootstrap.js +28 -13
- package/lib/helpers/materialized-reports/materialized-integer-contract.js +10 -1
- package/lib/helpers/materialized-reports/materialized-prep-time-close-day-helpers.js +2 -90
- package/lib/helpers/materialized-reports/materialized-tenant-delivery-geo-helpers.d.ts +186 -0
- package/lib/helpers/materialized-reports/materialized-tenant-delivery-geo-helpers.js +620 -0
- package/lib/helpers/materialized-reports/report-platform/definition.d.ts +133 -0
- package/lib/helpers/materialized-reports/report-platform/definition.js +511 -0
- package/lib/helpers/materialized-reports/report-platform/index.d.ts +4 -0
- package/lib/helpers/materialized-reports/report-platform/index.js +20 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/budget.d.ts +8 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/budget.js +31 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/cap-metadata.d.ts +8 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/cap-metadata.js +16 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/entry-pages.d.ts +40 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/entry-pages.js +130 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/flat-projection.d.ts +22 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/flat-projection.js +17 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/index.d.ts +8 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/index.js +24 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/iteration-row.d.ts +13 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/iteration-row.js +13 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/run-stats.d.ts +20 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/run-stats.js +47 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/scope-refs.d.ts +13 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/scope-refs.js +31 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/top-n.d.ts +16 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/top-n.js +29 -0
- package/lib/helpers/materialized-reports/report-platform/registry.d.ts +13 -0
- package/lib/helpers/materialized-reports/report-platform/registry.js +31 -0
- package/lib/helpers/materialized-reports/report-platform/validate-report-registry.d.ts +20 -0
- package/lib/helpers/materialized-reports/report-platform/validate-report-registry.js +218 -0
- package/lib/helpers/materialized-reports/scope-helpers.d.ts +8 -0
- package/lib/helpers/materialized-reports/scope-helpers.js +99 -0
- package/lib/helpers/materialized-reports/tenant-delivery-formatter.d.ts +41 -0
- package/lib/helpers/materialized-reports/tenant-delivery-formatter.js +70 -20
- package/lib/helpers/order/payment-collection.d.ts +25 -0
- package/lib/helpers/order/payment-collection.js +51 -0
- package/lib/schemas/models/applied_order_discounts.d.ts +80 -0
- package/lib/schemas/models/applied_order_discounts.js +106 -0
- package/lib/schemas/models/index.d.ts +12 -10
- package/lib/schemas/models/index.js +12 -10
- package/lib/schemas/models/materialized_tenant_delivery_entries.d.ts +31 -9
- package/lib/schemas/models/materialized_tenant_delivery_entries.js +32 -11
- package/lib/schemas/models/materialized_tenant_delivery_geo_cells.d.ts +129 -0
- package/lib/schemas/models/materialized_tenant_delivery_geo_cells.js +86 -0
- package/lib/schemas/models/materialized_tenant_delivery_geo_scopes.d.ts +71 -0
- package/lib/schemas/models/materialized_tenant_delivery_geo_scopes.js +38 -0
- package/lib/schemas/models/materialized_tenant_delivery_reports.d.ts +10 -1
- package/lib/schemas/models/materialized_tenant_delivery_reports.js +10 -1
- package/lib/schemas/models/materialized_tenant_discount_sources.d.ts +15 -15
- package/lib/schemas/types/applied_order_discounts.d.ts +22 -0
- package/lib/schemas/types/applied_order_discounts.js +2 -0
- package/lib/schemas/types/index.d.ts +14 -12
- package/lib/schemas/types/index.js +14 -12
- package/lib/schemas/types/materialized_tenant_delivery_entries.d.ts +36 -4
- package/lib/schemas/types/materialized_tenant_delivery_geo_cells.d.ts +178 -0
- package/lib/schemas/types/materialized_tenant_delivery_geo_cells.js +2 -0
- package/lib/schemas/types/materialized_tenant_delivery_geo_scopes.d.ts +21 -0
- package/lib/schemas/types/materialized_tenant_delivery_geo_scopes.js +2 -0
- package/lib/schemas/types/materialized_tenant_delivery_reports.d.ts +49 -7
- package/lib/tests/materialized-reports/analytics-growth-helpers.test.d.ts +1 -0
- package/lib/tests/materialized-reports/analytics-overview-helpers.test.d.ts +1 -0
- package/lib/tests/materialized-reports/analytics-performance-helpers.test.d.ts +1 -0
- package/lib/tests/materialized-reports/characterization/delivery.characterization.test.d.ts +1 -0
- package/lib/tests/materialized-reports/characterization/delivery.characterization.test.js +229 -0
- package/lib/tests/materialized-reports/characterization/discount.characterization.test.d.ts +1 -0
- package/lib/tests/materialized-reports/characterization/discount.characterization.test.js +99 -0
- package/lib/tests/materialized-reports/characterization/fixtures.d.ts +30 -0
- package/lib/tests/materialized-reports/characterization/fixtures.js +402 -0
- package/lib/tests/materialized-reports/characterization/golden.d.ts +18 -0
- package/lib/tests/materialized-reports/characterization/golden.js +127 -0
- package/lib/tests/materialized-reports/characterization/overview.characterization.test.d.ts +1 -0
- package/lib/tests/materialized-reports/characterization/overview.characterization.test.js +69 -0
- package/lib/tests/materialized-reports/characterization/prep-time.characterization.test.d.ts +1 -0
- package/lib/tests/materialized-reports/characterization/prep-time.characterization.test.js +102 -0
- package/lib/tests/materialized-reports/materialized-delivery-accumulation.test.js +56 -19
- package/lib/tests/materialized-reports/materialized-delivery-budgets.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-delivery-budgets.test.js +91 -0
- package/lib/tests/materialized-reports/materialized-delivery-compile.test.js +271 -15
- package/lib/tests/materialized-reports/materialized-delivery-final-audit.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-delivery-final-audit.test.js +128 -0
- package/lib/tests/materialized-reports/materialized-delivery-fold.test.js +42 -5
- package/lib/tests/materialized-reports/materialized-delivery-formatter.test.js +13 -1
- package/lib/tests/materialized-reports/materialized-delivery-geo.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-delivery-geo.test.js +446 -0
- package/lib/tests/materialized-reports/materialized-delivery-plan.test.js +117 -25
- package/lib/tests/materialized-reports/materialized-delivery-practical.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-delivery-practical.test.js +344 -0
- package/lib/tests/materialized-reports/materialized-integer-contract.test.js +14 -0
- package/lib/tests/materialized-reports/materialized-tenant-sales-overview-reports-schema.test.js +1 -1
- package/lib/tests/materialized-reports/report-platform/lifecycle-primitives.test.d.ts +1 -0
- package/lib/tests/materialized-reports/report-platform/lifecycle-primitives.test.js +177 -0
- package/lib/tests/materialized-reports/report-platform/registry-conformance.test.d.ts +1 -0
- package/lib/tests/materialized-reports/report-platform/registry-conformance.test.js +214 -0
- package/lib/tests/materialized-reports/report-platform/registry-validation.test.d.ts +1 -0
- package/lib/tests/materialized-reports/report-platform/registry-validation.test.js +103 -0
- package/lib/tests/offer-item-resolution.test.js +1 -4
- package/lib/tests/payment-collection-timestamps.test.d.ts +1 -0
- package/lib/tests/payment-collection-timestamps.test.js +71 -0
- package/package.json +6 -2
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
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
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
const fs_1 = __importDefault(require("fs"));
|
|
40
|
+
const path_1 = __importDefault(require("path"));
|
|
41
|
+
const MATERIALIZED_REPORTS_1 = require("../../../constants/MATERIALIZED_REPORTS");
|
|
42
|
+
const overviewModel = __importStar(require("../../../schemas/models/materialized_tenant_sales_overview_reports"));
|
|
43
|
+
const creditModel = __importStar(require("../../../schemas/models/materialized_credit_bills"));
|
|
44
|
+
const discountReportModel = __importStar(require("../../../schemas/models/materialized_tenant_discount_reports"));
|
|
45
|
+
const discountEntryModel = __importStar(require("../../../schemas/models/materialized_tenant_discount_entries"));
|
|
46
|
+
const discountSourceModel = __importStar(require("../../../schemas/models/materialized_tenant_discount_sources"));
|
|
47
|
+
const prepReportModel = __importStar(require("../../../schemas/models/materialized_tenant_prep_time_reports"));
|
|
48
|
+
const prepEntryModel = __importStar(require("../../../schemas/models/materialized_tenant_prep_time_entries"));
|
|
49
|
+
const deliveryReportModel = __importStar(require("../../../schemas/models/materialized_tenant_delivery_reports"));
|
|
50
|
+
const deliveryEntryModel = __importStar(require("../../../schemas/models/materialized_tenant_delivery_entries"));
|
|
51
|
+
const deliveryGeoModel = __importStar(require("../../../schemas/models/materialized_tenant_delivery_geo_cells"));
|
|
52
|
+
const flatModel = __importStar(require("../../../schemas/models/materialized_report_drilldown_rows"));
|
|
53
|
+
const definition_1 = require("../../../helpers/materialized-reports/report-platform/definition");
|
|
54
|
+
const registry_1 = require("../../../helpers/materialized-reports/report-platform/registry");
|
|
55
|
+
const validate_report_registry_1 = require("../../../helpers/materialized-reports/report-platform/validate-report-registry");
|
|
56
|
+
const report_contract_1 = require("../../../helpers/reporting-contract/report-contract");
|
|
57
|
+
const MODEL_BY_COLLECTION = {
|
|
58
|
+
materialized_tenant_sales_overview_reports: {
|
|
59
|
+
collectionName: overviewModel.MATERIALIZED_TENANT_SALES_OVERVIEW_REPORTS_COLLECTION_NAME,
|
|
60
|
+
schemaVersion: overviewModel.MATERIALIZED_TENANT_SALES_OVERVIEW_REPORTS_SCHEMA_VERSION,
|
|
61
|
+
indexOptions: overviewModel.MATERIALIZED_TENANT_SALES_OVERVIEW_REPORTS_INDEX_OPTIONS,
|
|
62
|
+
},
|
|
63
|
+
materialized_tenant_credit_bills: {
|
|
64
|
+
collectionName: creditModel.MATERIALIZED_TENANT_CREDIT_BILLS_COLLECTION_NAME,
|
|
65
|
+
schemaVersion: creditModel.MATERIALIZED_CREDIT_BILLS_SCHEMA_VERSION,
|
|
66
|
+
indexOptions: creditModel.MATERIALIZED_TENANT_CREDIT_BILLS_INDEX_OPTIONS,
|
|
67
|
+
},
|
|
68
|
+
materialized_tenant_discount_reports: {
|
|
69
|
+
collectionName: discountReportModel.MATERIALIZED_TENANT_DISCOUNT_REPORTS_COLLECTION_NAME,
|
|
70
|
+
schemaVersion: discountReportModel.MATERIALIZED_TENANT_DISCOUNT_REPORTS_SCHEMA_VERSION,
|
|
71
|
+
indexOptions: discountReportModel.MATERIALIZED_TENANT_DISCOUNT_REPORTS_INDEX_OPTIONS,
|
|
72
|
+
},
|
|
73
|
+
materialized_tenant_discount_entries: {
|
|
74
|
+
collectionName: discountEntryModel.MATERIALIZED_TENANT_DISCOUNT_ENTRIES_COLLECTION_NAME,
|
|
75
|
+
schemaVersion: discountEntryModel.MATERIALIZED_TENANT_DISCOUNT_ENTRIES_SCHEMA_VERSION,
|
|
76
|
+
indexOptions: discountEntryModel.MATERIALIZED_TENANT_DISCOUNT_ENTRIES_INDEX_OPTIONS,
|
|
77
|
+
},
|
|
78
|
+
materialized_tenant_discount_sources: {
|
|
79
|
+
collectionName: discountSourceModel.MATERIALIZED_TENANT_DISCOUNT_SOURCES_COLLECTION_NAME,
|
|
80
|
+
schemaVersion: discountSourceModel.MATERIALIZED_TENANT_DISCOUNT_SOURCES_SCHEMA_VERSION,
|
|
81
|
+
indexOptions: discountSourceModel.MATERIALIZED_TENANT_DISCOUNT_SOURCES_INDEX_OPTIONS,
|
|
82
|
+
},
|
|
83
|
+
materialized_tenant_prep_time_reports: {
|
|
84
|
+
collectionName: prepReportModel.MATERIALIZED_TENANT_PREP_TIME_REPORTS_COLLECTION_NAME,
|
|
85
|
+
schemaVersion: prepReportModel.MATERIALIZED_TENANT_PREP_TIME_REPORTS_SCHEMA_VERSION,
|
|
86
|
+
indexOptions: prepReportModel.MATERIALIZED_TENANT_PREP_TIME_REPORTS_INDEX_OPTIONS,
|
|
87
|
+
},
|
|
88
|
+
materialized_tenant_prep_time_entries: {
|
|
89
|
+
collectionName: prepEntryModel.MATERIALIZED_TENANT_PREP_TIME_ENTRIES_COLLECTION_NAME,
|
|
90
|
+
schemaVersion: prepEntryModel.MATERIALIZED_TENANT_PREP_TIME_ENTRIES_SCHEMA_VERSION,
|
|
91
|
+
indexOptions: prepEntryModel.MATERIALIZED_TENANT_PREP_TIME_ENTRIES_INDEX_OPTIONS,
|
|
92
|
+
},
|
|
93
|
+
materialized_tenant_delivery_reports: {
|
|
94
|
+
collectionName: deliveryReportModel.MATERIALIZED_TENANT_DELIVERY_REPORTS_COLLECTION_NAME,
|
|
95
|
+
schemaVersion: deliveryReportModel.MATERIALIZED_TENANT_DELIVERY_REPORTS_SCHEMA_VERSION,
|
|
96
|
+
indexOptions: deliveryReportModel.MATERIALIZED_TENANT_DELIVERY_REPORTS_INDEX_OPTIONS,
|
|
97
|
+
},
|
|
98
|
+
materialized_tenant_delivery_entries: {
|
|
99
|
+
collectionName: deliveryEntryModel.MATERIALIZED_TENANT_DELIVERY_ENTRIES_COLLECTION_NAME,
|
|
100
|
+
schemaVersion: deliveryEntryModel.MATERIALIZED_TENANT_DELIVERY_ENTRIES_SCHEMA_VERSION,
|
|
101
|
+
indexOptions: deliveryEntryModel.MATERIALIZED_TENANT_DELIVERY_ENTRIES_INDEX_OPTIONS,
|
|
102
|
+
},
|
|
103
|
+
materialized_tenant_delivery_geo_cells: {
|
|
104
|
+
collectionName: deliveryGeoModel.MATERIALIZED_TENANT_DELIVERY_GEO_CELLS_COLLECTION_NAME,
|
|
105
|
+
schemaVersion: MATERIALIZED_REPORTS_1.MATERIALIZED_TENANT_DELIVERY_GEO_CELLS_SCHEMA_VERSION,
|
|
106
|
+
indexOptions: deliveryGeoModel.MATERIALIZED_TENANT_DELIVERY_GEO_CELLS_INDEX_OPTIONS,
|
|
107
|
+
},
|
|
108
|
+
materialized_tenant_delivery_geo_scopes: {
|
|
109
|
+
collectionName: 'materialized_tenant_delivery_geo_scopes',
|
|
110
|
+
schemaVersion: MATERIALIZED_REPORTS_1.MATERIALIZED_TENANT_DELIVERY_GEO_SCOPES_SCHEMA_VERSION,
|
|
111
|
+
indexOptions: [],
|
|
112
|
+
},
|
|
113
|
+
materialized_report_drilldown_rows: {
|
|
114
|
+
collectionName: flatModel.MATERIALIZED_REPORT_DRILLDOWN_ROWS_COLLECTION_NAME,
|
|
115
|
+
schemaVersion: flatModel.MATERIALIZED_REPORT_DRILLDOWN_ROWS_SCHEMA_VERSION,
|
|
116
|
+
indexOptions: flatModel.MATERIALIZED_REPORT_DRILLDOWN_ROWS_INDEX_OPTIONS,
|
|
117
|
+
},
|
|
118
|
+
materialized_report_drilldown_scopes: {
|
|
119
|
+
collectionName: flatModel.MATERIALIZED_REPORT_DRILLDOWN_SCOPES_COLLECTION_NAME,
|
|
120
|
+
schemaVersion: flatModel.MATERIALIZED_REPORT_DRILLDOWN_ROWS_SCHEMA_VERSION,
|
|
121
|
+
indexOptions: flatModel.MATERIALIZED_REPORT_DRILLDOWN_SCOPES_INDEX_OPTIONS,
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
const definitionCollections = () => definition_1.PRODUCTION_REPORT_DEFINITIONS.flatMap((definition) => [
|
|
125
|
+
definition.report,
|
|
126
|
+
...(definition.entries == null ? [] : [definition.entries]),
|
|
127
|
+
...definition.sideCollections,
|
|
128
|
+
]);
|
|
129
|
+
describe('report registry conformance', () => {
|
|
130
|
+
it('defines exactly the four production reports', () => {
|
|
131
|
+
expect(definition_1.PRODUCTION_REPORT_DEFINITIONS.map((definition) => definition.key)).toEqual([
|
|
132
|
+
report_contract_1.REPORT_KEY_ENUM.OVERVIEW,
|
|
133
|
+
report_contract_1.REPORT_KEY_ENUM.DISCOUNTS,
|
|
134
|
+
report_contract_1.REPORT_KEY_ENUM.PREP_TIME,
|
|
135
|
+
report_contract_1.REPORT_KEY_ENUM.DELIVERY,
|
|
136
|
+
]);
|
|
137
|
+
expect((0, registry_1.getProductionReportDefinitions)()).toHaveLength(4);
|
|
138
|
+
expect(new Set(definition_1.PRODUCTION_REPORT_DEFINITIONS.map((definition) => definition.key)).size).toBe(4);
|
|
139
|
+
expect(definition_1.PRODUCTION_REPORT_DEFINITIONS.every((definition) => definition.status === 'PRODUCTION')).toBe(true);
|
|
140
|
+
});
|
|
141
|
+
it('covers every REPORT_KEY with a definition or an explicit exemption', () => {
|
|
142
|
+
for (const key of report_contract_1.ALL_REPORT_KEYS) {
|
|
143
|
+
const definition = (0, registry_1.getReportDefinition)(key);
|
|
144
|
+
const exemption = definition_1.REPORT_REGISTRY_EXEMPTIONS[key];
|
|
145
|
+
expect(definition != null || exemption != null).toBe(true);
|
|
146
|
+
expect(definition != null && exemption != null).toBe(false);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
it('has no metadata validation errors', () => {
|
|
150
|
+
const validation = (0, validate_report_registry_1.validateReportRegistry)();
|
|
151
|
+
expect(validation.errors).toEqual([]);
|
|
152
|
+
expect(validation.ok).toBe(true);
|
|
153
|
+
});
|
|
154
|
+
it('declares a collection, schema version and index ownership that exist', () => {
|
|
155
|
+
for (const definition of definition_1.PRODUCTION_REPORT_DEFINITIONS) {
|
|
156
|
+
for (const collection of [
|
|
157
|
+
definition.report,
|
|
158
|
+
...(definition.entries == null ? [] : [definition.entries]),
|
|
159
|
+
...definition.sideCollections,
|
|
160
|
+
]) {
|
|
161
|
+
const facts = MODEL_BY_COLLECTION[collection.name];
|
|
162
|
+
expect(facts).toBeDefined();
|
|
163
|
+
expect(facts.collectionName).toBe(collection.name);
|
|
164
|
+
expect(facts.schemaVersion).toBe(collection.schemaVersion);
|
|
165
|
+
expect(collection.indexOwner).toMatch(/^toolkit:/);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
it('declares a positive budget for every collection', () => {
|
|
170
|
+
for (const definition of definition_1.PRODUCTION_REPORT_DEFINITIONS) {
|
|
171
|
+
for (const collection of [
|
|
172
|
+
definition.report,
|
|
173
|
+
...(definition.entries == null ? [] : [definition.entries]),
|
|
174
|
+
...definition.sideCollections,
|
|
175
|
+
]) {
|
|
176
|
+
expect(definition.budgets[collection.name]).toBe(collection.budgetBytes);
|
|
177
|
+
expect(collection.budgetBytes).toBeGreaterThan(0);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
it('keeps entry scopes inside report scopes and respects the month cap', () => {
|
|
182
|
+
for (const definition of definition_1.PRODUCTION_REPORT_DEFINITIONS) {
|
|
183
|
+
for (const scope of definition.entryScopes) {
|
|
184
|
+
expect(definition.reportScopes).toContain(scope);
|
|
185
|
+
}
|
|
186
|
+
if (definition.entryScopes.length > 0) {
|
|
187
|
+
expect(definition.maxEntryScope).toBe('localMonth');
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
it('declares every collection owner and validator ownership (file or explicit debt)', () => {
|
|
192
|
+
const seen = new Set();
|
|
193
|
+
for (const collection of definitionCollections()) {
|
|
194
|
+
expect(collection.indexOwner.trim().length).toBeGreaterThan(0);
|
|
195
|
+
if (collection.validatorFile == null) {
|
|
196
|
+
expect(collection.validatorDebt?.trim().length ?? 0).toBeGreaterThan(0);
|
|
197
|
+
}
|
|
198
|
+
seen.add(collection.name);
|
|
199
|
+
}
|
|
200
|
+
expect(seen.size).toBeGreaterThanOrEqual(10);
|
|
201
|
+
});
|
|
202
|
+
it('keeps metadata files free of forbidden runtime imports', () => {
|
|
203
|
+
const directory = path_1.default.join(process.cwd(), 'src/helpers/materialized-reports/report-platform');
|
|
204
|
+
for (const file of ['definition.ts', 'registry.ts', 'validate-report-registry.ts']) {
|
|
205
|
+
const source = fs_1.default.readFileSync(path_1.default.join(directory, file), 'utf8');
|
|
206
|
+
const code = source.replace(/\/\*[\s\S]*?\*\//g, '').replace(/\/\/.*$/gm, '');
|
|
207
|
+
expect(code).not.toMatch(/from ['"]mongoose['"]/);
|
|
208
|
+
expect(code).not.toMatch(/from ['"]express['"]/);
|
|
209
|
+
expect(code).not.toMatch(/from ['"][^'"]*workers-service/);
|
|
210
|
+
expect(code).not.toMatch(/from ['"][^'"]*operations-service/);
|
|
211
|
+
expect(code).not.toMatch(/from ['"][^'"]*schemas\/models/);
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const definition_1 = require("../../../helpers/materialized-reports/report-platform/definition");
|
|
4
|
+
const validate_report_registry_1 = require("../../../helpers/materialized-reports/report-platform/validate-report-registry");
|
|
5
|
+
const report_contract_1 = require("../../../helpers/reporting-contract/report-contract");
|
|
6
|
+
/**
|
|
7
|
+
* PHASE 2 — registry validator negative cases.
|
|
8
|
+
*
|
|
9
|
+
* Each case mutates ONE field of a valid definition and proves the validator
|
|
10
|
+
* fails for the reason the Phase 2 brief names.
|
|
11
|
+
*/
|
|
12
|
+
const clone = (value) => JSON.parse(JSON.stringify(value));
|
|
13
|
+
const definitions = () => Object.fromEntries(clone(definition_1.PRODUCTION_REPORT_DEFINITIONS).map((definition) => [definition.key, definition]));
|
|
14
|
+
const run = (mutate) => {
|
|
15
|
+
const copy = definitions();
|
|
16
|
+
mutate(copy[report_contract_1.REPORT_KEY_ENUM.OVERVIEW]);
|
|
17
|
+
return (0, validate_report_registry_1.validateReportRegistry)({ definitions: copy });
|
|
18
|
+
};
|
|
19
|
+
describe('report registry validator', () => {
|
|
20
|
+
it('rejects a REPORT_KEY with no definition and no exemption', () => {
|
|
21
|
+
const copy = definitions();
|
|
22
|
+
delete copy[report_contract_1.REPORT_KEY_ENUM.DELIVERY];
|
|
23
|
+
const validation = (0, validate_report_registry_1.validateReportRegistry)({
|
|
24
|
+
definitions: copy,
|
|
25
|
+
exemptions: { ...definition_1.REPORT_REGISTRY_EXEMPTIONS },
|
|
26
|
+
});
|
|
27
|
+
expect(validation.ok).toBe(false);
|
|
28
|
+
expect(validation.errors.some((error) => error.includes('DELIVERY'))).toBe(true);
|
|
29
|
+
});
|
|
30
|
+
it('rejects a missing writer adapter', () => {
|
|
31
|
+
const validation = run((definition) => {
|
|
32
|
+
definition.adapters.writer = '';
|
|
33
|
+
});
|
|
34
|
+
expect(validation.errors.some((error) => error.includes('writer adapter'))).toBe(true);
|
|
35
|
+
});
|
|
36
|
+
it('rejects a missing live adapter', () => {
|
|
37
|
+
const validation = run((definition) => {
|
|
38
|
+
definition.adapters.live = '';
|
|
39
|
+
});
|
|
40
|
+
expect(validation.errors.some((error) => error.includes('live adapter'))).toBe(true);
|
|
41
|
+
});
|
|
42
|
+
it('rejects a missing historical adapter', () => {
|
|
43
|
+
const validation = run((definition) => {
|
|
44
|
+
definition.adapters.historical = '';
|
|
45
|
+
});
|
|
46
|
+
expect(validation.errors.some((error) => error.includes('historical adapter'))).toBe(true);
|
|
47
|
+
});
|
|
48
|
+
it('rejects a schema version that is not positive', () => {
|
|
49
|
+
const validation = run((definition) => {
|
|
50
|
+
definition.report.schemaVersion = 0;
|
|
51
|
+
});
|
|
52
|
+
expect(validation.errors.some((error) => error.includes('schema version'))).toBe(true);
|
|
53
|
+
});
|
|
54
|
+
it('rejects an entry scope outside report scopes', () => {
|
|
55
|
+
const validation = run((definition) => {
|
|
56
|
+
definition.entryScopes = ['localMonth'];
|
|
57
|
+
definition.reportScopes = ['localDate'];
|
|
58
|
+
});
|
|
59
|
+
expect(validation.errors.some((error) => error.includes('outside reportScopes'))).toBe(true);
|
|
60
|
+
});
|
|
61
|
+
it('rejects a collection without a budget declaration', () => {
|
|
62
|
+
const validation = run((definition) => {
|
|
63
|
+
delete definition.budgets[definition.report.name];
|
|
64
|
+
});
|
|
65
|
+
expect(validation.errors.some((error) => error.includes('no budget declaration'))).toBe(true);
|
|
66
|
+
});
|
|
67
|
+
it('rejects a collection without index ownership', () => {
|
|
68
|
+
const validation = run((definition) => {
|
|
69
|
+
definition.report.indexOwner = '';
|
|
70
|
+
});
|
|
71
|
+
expect(validation.errors.some((error) => error.includes('index ownership'))).toBe(true);
|
|
72
|
+
});
|
|
73
|
+
it('rejects a validator omission without an explicit debt note', () => {
|
|
74
|
+
const validation = run((definition) => {
|
|
75
|
+
definition.report.validatorFile = null;
|
|
76
|
+
delete definition.report.validatorDebt;
|
|
77
|
+
});
|
|
78
|
+
expect(validation.errors.some((error) => error.includes('validator'))).toBe(true);
|
|
79
|
+
});
|
|
80
|
+
it('rejects capabilities that disagree with the shared matrix', () => {
|
|
81
|
+
const validation = run((definition) => {
|
|
82
|
+
definition.capabilities.details = true;
|
|
83
|
+
definition.adapters.details = 'unexpected';
|
|
84
|
+
});
|
|
85
|
+
expect(validation.errors.some((error) => error.includes('REPORT_CAPABILITIES'))).toBe(true);
|
|
86
|
+
});
|
|
87
|
+
it('rejects a details capability without a details adapter', () => {
|
|
88
|
+
const validation = run((definition) => {
|
|
89
|
+
definition.key = report_contract_1.REPORT_KEY_ENUM.DISCOUNTS;
|
|
90
|
+
definition.segment = 'discounts';
|
|
91
|
+
definition.capabilities = { live: true, historical: true, details: true };
|
|
92
|
+
delete definition.adapters.details;
|
|
93
|
+
});
|
|
94
|
+
expect(validation.errors.some((error) => error.includes('no details adapter'))).toBe(true);
|
|
95
|
+
});
|
|
96
|
+
it('rejects #N splitting on a non-page entry strategy', () => {
|
|
97
|
+
const validation = run((definition) => {
|
|
98
|
+
definition.entryStorage = 'ONE_PER_SCOPE';
|
|
99
|
+
definition.entrySplit = 'DETERMINISTIC_SUBPAGES';
|
|
100
|
+
});
|
|
101
|
+
expect(validation.errors.some((error) => error.includes('#N splitting'))).toBe(true);
|
|
102
|
+
});
|
|
103
|
+
});
|
|
@@ -141,10 +141,7 @@ describe('getClaimedRewardQuantity / getRemainingRewardQuantity', () => {
|
|
|
141
141
|
expect(result).toBe(6);
|
|
142
142
|
});
|
|
143
143
|
it('subtracts claimed units from the order allowance and never goes negative', () => {
|
|
144
|
-
const cart = categories([
|
|
145
|
-
stamped(2, { loyalty: 'a' }),
|
|
146
|
-
stamped(1, { voucher: 'a' }),
|
|
147
|
-
]);
|
|
144
|
+
const cart = categories([stamped(2, { loyalty: 'a' }), stamped(1, { voucher: 'a' })]);
|
|
148
145
|
expect((0, offer_item_resolution_1.getRemainingRewardQuantity)({ categories: cart, offerId: 'a', allowance: 6 })).toBe(3);
|
|
149
146
|
expect((0, offer_item_resolution_1.getRemainingRewardQuantity)({ categories: cart, offerId: 'a', allowance: 3 })).toBe(0);
|
|
150
147
|
expect((0, offer_item_resolution_1.getRemainingRewardQuantity)({ categories: cart, offerId: 'a', allowance: 1 })).toBe(0);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const constants_1 = require("../constants");
|
|
4
|
+
const payment_collection_1 = require("../helpers/order/payment-collection");
|
|
5
|
+
const NOW = new Date('2026-10-20T14:00:00.000Z');
|
|
6
|
+
const EARLIER = new Date('2026-10-19T10:00:00.000Z');
|
|
7
|
+
const payment = (over = {}) => ({
|
|
8
|
+
_id: '5f0000000000000000000001',
|
|
9
|
+
payment_type: constants_1.PAYMENT_TYPE_ENUM.CASH,
|
|
10
|
+
payment_status: constants_1.PAYMENT_STATUS_ENUM.SETTLED,
|
|
11
|
+
card_details: null,
|
|
12
|
+
amount_paid: 1000,
|
|
13
|
+
amount_due: 1000,
|
|
14
|
+
amount_refunded: 0,
|
|
15
|
+
payment_id: 'pay-1',
|
|
16
|
+
...over,
|
|
17
|
+
});
|
|
18
|
+
describe('stampPaymentCollectionTimestamps', () => {
|
|
19
|
+
it('stamps new collected money and leaves unpaid PAY_LATER empty', () => {
|
|
20
|
+
const [paid, credit] = (0, payment_collection_1.stampPaymentCollectionTimestamps)([
|
|
21
|
+
payment(),
|
|
22
|
+
payment({
|
|
23
|
+
_id: '5f0000000000000000000002',
|
|
24
|
+
payment_id: 'pay-2',
|
|
25
|
+
payment_type: constants_1.PAYMENT_TYPE_ENUM.PAY_LATER,
|
|
26
|
+
payment_status: constants_1.PAYMENT_STATUS_ENUM.PENDING,
|
|
27
|
+
amount_paid: 0,
|
|
28
|
+
amount_due: 5000,
|
|
29
|
+
}),
|
|
30
|
+
], null, { now: NOW });
|
|
31
|
+
expect(paid.collected_at).toBe(NOW);
|
|
32
|
+
expect(credit.collected_at).toBeNull();
|
|
33
|
+
});
|
|
34
|
+
it('ignores a client-supplied collected_at on create', () => {
|
|
35
|
+
const [paid] = (0, payment_collection_1.stampPaymentCollectionTimestamps)([payment({ collected_at: EARLIER })], null, { now: NOW });
|
|
36
|
+
expect(paid.collected_at).toBe(NOW);
|
|
37
|
+
});
|
|
38
|
+
it('preserves the stored timestamp when amount_paid did not increase', () => {
|
|
39
|
+
const previous = payment({ collected_at: EARLIER });
|
|
40
|
+
const [unchanged] = (0, payment_collection_1.stampPaymentCollectionTimestamps)([payment({ collected_at: null })], [previous], { now: NOW });
|
|
41
|
+
expect(unchanged.collected_at).toBe(EARLIER);
|
|
42
|
+
});
|
|
43
|
+
it('stamps the latest collection when a partial amount is collected', () => {
|
|
44
|
+
const previous = payment({ amount_paid: 400, collected_at: EARLIER });
|
|
45
|
+
const [partial] = (0, payment_collection_1.stampPaymentCollectionTimestamps)([payment({ amount_paid: 700 })], [previous], { now: NOW });
|
|
46
|
+
expect(partial.collected_at).toBe(NOW);
|
|
47
|
+
});
|
|
48
|
+
it('does not rewrite the timestamp on a refund / amount decrease', () => {
|
|
49
|
+
const previous = payment({ amount_paid: 1000, collected_at: EARLIER });
|
|
50
|
+
const [refunded] = (0, payment_collection_1.stampPaymentCollectionTimestamps)([payment({ amount_paid: 0, amount_refunded: 1000, payment_status: constants_1.PAYMENT_STATUS_ENUM.REFUNDED })], [previous], { now: NOW });
|
|
51
|
+
expect(refunded.collected_at).toBe(EARLIER);
|
|
52
|
+
});
|
|
53
|
+
it('matches legacy rows by _id when payment_id is null', () => {
|
|
54
|
+
const previous = payment({ payment_id: null, collected_at: EARLIER });
|
|
55
|
+
const [updated] = (0, payment_collection_1.stampPaymentCollectionTimestamps)([payment({ payment_id: null, amount_paid: 1200 })], [previous], { now: NOW });
|
|
56
|
+
expect(updated.collected_at).toBe(NOW);
|
|
57
|
+
});
|
|
58
|
+
it('preserves the stamp when the server reassigns payment_id but _id is stable', () => {
|
|
59
|
+
const previous = payment({ payment_id: 'pay-old', collected_at: EARLIER });
|
|
60
|
+
const [updated] = (0, payment_collection_1.stampPaymentCollectionTimestamps)([payment({ payment_id: 'pay-new' })], [previous], { now: NOW });
|
|
61
|
+
expect(updated.collected_at).toBe(EARLIER);
|
|
62
|
+
});
|
|
63
|
+
it('does not stamp a failed payment', () => {
|
|
64
|
+
const [failed] = (0, payment_collection_1.stampPaymentCollectionTimestamps)([payment({ payment_status: constants_1.PAYMENT_STATUS_ENUM.FAILED })], null, { now: NOW });
|
|
65
|
+
expect(failed.collected_at).toBeNull();
|
|
66
|
+
});
|
|
67
|
+
it('returns an empty array for empty / invalid input', () => {
|
|
68
|
+
expect((0, payment_collection_1.stampPaymentCollectionTimestamps)(null)).toEqual([]);
|
|
69
|
+
expect((0, payment_collection_1.stampPaymentCollectionTimestamps)(undefined)).toEqual([]);
|
|
70
|
+
});
|
|
71
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@managesome/eposmatic-toolkit",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.54",
|
|
4
4
|
"description": "A Toolkit Library for Eposmatic",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "esm/index.js",
|
|
@@ -26,13 +26,17 @@
|
|
|
26
26
|
"fixtures:prep-time": "tsx scripts/analyze-prep-time.ts",
|
|
27
27
|
"fixtures:prep-time-parity": "tsx scripts/analyze-prep-time-parity.ts",
|
|
28
28
|
"fixtures:delivery": "tsx scripts/analyze-delivery.ts",
|
|
29
|
-
"sim:close-day": "tsx simulations/simulate-day-close.ts"
|
|
29
|
+
"sim:close-day": "tsx simulations/simulate-day-close.ts",
|
|
30
|
+
"wipe:delivery": "tsx scripts/wipe-delivery-materialization.ts",
|
|
31
|
+
"measure:report-scale": "npx tsx scripts/measure-report-practical-scale.ts",
|
|
32
|
+
"test:characterization": "jest --config jestconfig.json src/tests/materialized-reports/characterization --runInBand"
|
|
30
33
|
},
|
|
31
34
|
"dependencies": {
|
|
32
35
|
"bson-objectid": "^2.0.4",
|
|
33
36
|
"crypto-js": "^4.2.0",
|
|
34
37
|
"emoji-strip": "^1.0.1",
|
|
35
38
|
"google-libphonenumber": "^3.2.40",
|
|
39
|
+
"h3-js": "^4.5.0",
|
|
36
40
|
"lodash": "^4.17.21",
|
|
37
41
|
"moment": "^2.30.1",
|
|
38
42
|
"mongoose": "^8.13.2"
|