@managesome/eposmatic-toolkit 0.4.54 → 0.4.56
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 +91 -0
- package/esm/helpers/materialized-reports/index.js +7 -0
- package/esm/helpers/materialized-reports/materialized-delivery-wipe-targets.js +18 -0
- package/esm/helpers/materialized-reports/materialized-dialer-accumulator-helpers.js +100 -0
- package/esm/helpers/materialized-reports/materialized-dialer-close-day-helpers.js +328 -0
- package/esm/helpers/materialized-reports/materialized-dialer-compile-helpers.js +180 -0
- package/esm/helpers/materialized-reports/materialized-dialer-entry-pages.js +222 -0
- package/esm/helpers/materialized-reports/materialized-dialer-key-helpers.js +82 -0
- package/esm/helpers/materialized-reports/materialized-dialer-masking.js +54 -0
- package/esm/helpers/materialized-reports/materialized-index-bootstrap.js +4 -0
- package/esm/helpers/materialized-reports/materialized-report-drilldown-rows.js +13 -1
- package/esm/helpers/materialized-reports/report-platform/definition.js +85 -1
- package/esm/helpers/materialized-reports/tenant-dialer-formatter.js +95 -0
- package/esm/helpers/reporting-contract/report-contract.js +3 -0
- package/esm/schemas/models/index.js +3 -0
- package/esm/schemas/models/materialized_report_drilldown_rows.js +1 -0
- package/esm/schemas/models/materialized_tenant_dialer_entries.js +65 -0
- package/esm/schemas/models/materialized_tenant_dialer_reports.js +66 -0
- package/esm/schemas/models/tenant_dialer_events.js +133 -0
- package/esm/schemas/types/index.js +3 -0
- package/esm/schemas/types/materialized_report_drilldown_rows.js +1 -0
- package/esm/schemas/types/materialized_tenant_dialer_entries.js +1 -0
- package/esm/schemas/types/materialized_tenant_dialer_reports.js +7 -0
- package/esm/schemas/types/tenant_dialer_events.js +1 -0
- package/lib/constants/MATERIALIZED_REPORTS.d.ts +72 -2
- package/lib/constants/MATERIALIZED_REPORTS.js +93 -1
- package/lib/helpers/materialized-reports/index.d.ts +7 -0
- package/lib/helpers/materialized-reports/index.js +7 -0
- package/lib/helpers/materialized-reports/materialized-delivery-wipe-targets.d.ts +1 -0
- package/lib/helpers/materialized-reports/materialized-delivery-wipe-targets.js +19 -0
- package/lib/helpers/materialized-reports/materialized-dialer-accumulator-helpers.d.ts +39 -0
- package/lib/helpers/materialized-reports/materialized-dialer-accumulator-helpers.js +110 -0
- package/lib/helpers/materialized-reports/materialized-dialer-close-day-helpers.d.ts +90 -0
- package/lib/helpers/materialized-reports/materialized-dialer-close-day-helpers.js +340 -0
- package/lib/helpers/materialized-reports/materialized-dialer-compile-helpers.d.ts +67 -0
- package/lib/helpers/materialized-reports/materialized-dialer-compile-helpers.js +183 -0
- package/lib/helpers/materialized-reports/materialized-dialer-entry-pages.d.ts +97 -0
- package/lib/helpers/materialized-reports/materialized-dialer-entry-pages.js +235 -0
- package/lib/helpers/materialized-reports/materialized-dialer-key-helpers.d.ts +51 -0
- package/lib/helpers/materialized-reports/materialized-dialer-key-helpers.js +90 -0
- package/lib/helpers/materialized-reports/materialized-dialer-masking.d.ts +35 -0
- package/lib/helpers/materialized-reports/materialized-dialer-masking.js +57 -0
- package/lib/helpers/materialized-reports/materialized-index-bootstrap.js +4 -0
- package/lib/helpers/materialized-reports/materialized-report-drilldown-rows.js +13 -1
- package/lib/helpers/materialized-reports/report-platform/definition.js +84 -0
- package/lib/helpers/materialized-reports/tenant-dialer-formatter.d.ts +91 -0
- package/lib/helpers/materialized-reports/tenant-dialer-formatter.js +98 -0
- package/lib/helpers/reporting-contract/report-contract.d.ts +1 -0
- package/lib/helpers/reporting-contract/report-contract.js +3 -0
- package/lib/schemas/models/index.d.ts +3 -0
- package/lib/schemas/models/index.js +3 -0
- package/lib/schemas/models/materialized_report_drilldown_rows.js +1 -0
- package/lib/schemas/models/materialized_tenant_dialer_entries.d.ts +107 -0
- package/lib/schemas/models/materialized_tenant_dialer_entries.js +68 -0
- package/lib/schemas/models/materialized_tenant_dialer_reports.d.ts +100 -0
- package/lib/schemas/models/materialized_tenant_dialer_reports.js +69 -0
- package/lib/schemas/models/tenant-activity-logs.d.ts +3 -3
- package/lib/schemas/models/tenant_dialer_events.d.ts +130 -0
- package/lib/schemas/models/tenant_dialer_events.js +136 -0
- package/lib/schemas/models/warehouse-activity-logs.d.ts +3 -3
- package/lib/schemas/types/index.d.ts +3 -0
- package/lib/schemas/types/index.js +3 -0
- package/lib/schemas/types/materialized_report_drilldown_rows.d.ts +1 -1
- package/lib/schemas/types/materialized_report_drilldown_rows.js +1 -0
- package/lib/schemas/types/materialized_tenant_dialer_entries.d.ts +83 -0
- package/lib/schemas/types/materialized_tenant_dialer_entries.js +2 -0
- package/lib/schemas/types/materialized_tenant_dialer_reports.d.ts +77 -0
- package/lib/schemas/types/materialized_tenant_dialer_reports.js +10 -0
- package/lib/schemas/types/tenant_dialer_events.d.ts +35 -0
- package/lib/schemas/types/tenant_dialer_events.js +2 -0
- package/lib/tests/materialized-reports/materialized-dialer-compile.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-dialer-compile.test.js +213 -0
- package/lib/tests/materialized-reports/materialized-dialer-formatter.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-dialer-formatter.test.js +159 -0
- package/lib/tests/materialized-reports/materialized-dialer-plan.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-dialer-plan.test.js +223 -0
- package/lib/tests/materialized-reports/materialized-tenant-dialer-schema.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-tenant-dialer-schema.test.js +183 -0
- package/lib/tests/materialized-reports/materialized-wipe-tooling.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-wipe-tooling.test.js +37 -0
- package/lib/tests/materialized-reports/report-platform/registry-conformance.test.js +16 -3
- package/lib/tests/tenant-dialer-events-schema.test.d.ts +1 -0
- package/lib/tests/tenant-dialer-events-schema.test.js +191 -0
- package/package.json +1 -1
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
*/
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
exports.MATERIALIZED_DELIVERY_GEO_SCOPES = exports.MATERIALIZED_DELIVERY_GEO_RESOLUTION = exports.MATERIALIZED_DELIVERY_GEO_MAX_KEYS = exports.MATERIALIZED_TENANT_DELIVERY_GEO_SCOPES_SCHEMA_VERSION = exports.MATERIALIZED_TENANT_DELIVERY_GEO_SCOPES_COLLECTION_NAME = exports.MATERIALIZED_TENANT_DELIVERY_GEO_CELLS_SCHEMA_VERSION = exports.MATERIALIZED_DELIVERY_OTHER_TOKEN = exports.MATERIALIZED_DELIVERY_AREA_LIMIT = exports.MATERIALIZED_DELIVERY_RIDER_LIMIT = exports.MATERIALIZED_DELIVERY_DISTANCE_BUCKETS = exports.DELIVERY_KEY_FILTERS = exports.MATERIALIZED_DELIVERY_ENTRY_PAGE_ALL = exports.MATERIALIZED_DELIVERY_ENTRY_SCOPES = exports.MATERIALIZED_DELIVERY_REPORT_SCOPES = exports.MATERIALIZED_CASH_SOURCE_LIMIT = exports.CASH_KEY_FILTERS = exports.MATERIALIZED_CASH_REPORT_SCOPES = exports.ALL_MATERIALIZED_REPORT_CREDIT_BILL_EVENT_TYPES = exports.MATERIALIZED_REPORT_CREDIT_BILL_EVENT_TYPE_ENUM = exports.MATERIALIZED_CREDIT_SETTLEMENT_PAYMENT_TYPE = exports.MATERIALIZED_DISCOUNT_SOURCE_KEY_PREFIX = exports.MATERIALIZED_DISCOUNT_SOURCE_KEY = exports.ALL_MATERIALIZED_DISCOUNT_RATE_KINDS = exports.MATERIALIZED_DISCOUNT_RATE_KIND_ENUM = exports.ALL_MATERIALIZED_DISCOUNT_SOURCE_CLASSES = exports.MATERIALIZED_DISCOUNT_SOURCE_CLASS_ENUM = exports.MATERIALIZED_DISCOUNT_PRICE_OVERRIDE_PREFIX = exports.MATERIALIZED_DISCOUNT_MANUAL_PREFIX = exports.MATERIALIZED_DISCOUNT_SPECIAL_DISCOUNT_ID = exports.MATERIALIZED_DISCOUNT_SOURCE_LIMIT = exports.ALL_MATERIALIZED_DISCOUNT_LEVELS = exports.MATERIALIZED_DISCOUNT_LEVEL_ENUM = exports.ALL_MATERIALIZED_DISCOUNT_ENTRY_KINDS = exports.MATERIALIZED_DISCOUNT_ENTRY_KIND_ENUM = exports.ALL_MATERIALIZED_DISCOUNT_SUB_KINDS = exports.MATERIALIZED_DISCOUNT_SUB_KIND_ENUM = exports.ALL_MATERIALIZED_DISCOUNT_SLOTS = exports.MATERIALIZED_DISCOUNT_SLOT_ENUM = exports.DISCOUNTS_KEY_FILTERS = exports.MATERIALIZED_DISCOUNT_REPORT_SCOPES = exports.MATERIALIZED_DISCOUNT_ENTRY_PAGE_ALL = exports.SALES_OVERVIEW_KEY_FILTERS = exports.ALL_MATERIALIZED_REPORT_KEY_FILTERS = exports.MATERIALIZED_REPORT_KEY_FILTER_ENUM = exports.MATERIALIZED_CREDIT_BILLS_SCOPES = exports.MATERIALIZED_REPORT_SCOPES_WITH_DAY_INDEX = exports.ALL_MATERIALIZED_REPORT_WINDOW_KINDS = exports.MATERIALIZED_REPORT_WINDOW_KIND_ENUM = exports.ALL_MATERIALIZED_REPORT_SCOPES = exports.MATERIALIZED_REPORT_SCOPE_ENUM = void 0;
|
|
14
|
-
exports.ALL_PAYMENTS_COMPARISON_METRICS = exports.PAYMENTS_COMPARISON_METRIC_ENUM = exports.MATERIALIZED_TENANT_PAYMENTS_COMPARISON_ENTRIES_SCHEMA_VERSION = exports.MATERIALIZED_TENANT_PAYMENTS_COMPARISON_REPORTS_SCHEMA_VERSION = exports.PAYMENTS_COMPARISON_KEY_FILTERS = exports.MATERIALIZED_PAYMENTS_COMPARISON_REPORT_SCOPES = exports.MATERIALIZED_TENANT_PAYMENTS_COMPARISON_ENTRIES_COLLECTION_NAME = exports.MATERIALIZED_TENANT_PAYMENTS_COMPARISON_REPORTS_COLLECTION_NAME = exports.MATERIALIZED_TENANT_HOURLY_COMPARISON_ENTRIES_SCHEMA_VERSION = exports.MATERIALIZED_TENANT_HOURLY_COMPARISON_REPORTS_SCHEMA_VERSION = exports.HOURLY_COMPARISON_KEY_FILTERS = exports.MATERIALIZED_HOURLY_COMPARISON_REPORT_SCOPES = exports.MATERIALIZED_TENANT_HOURLY_COMPARISON_ENTRIES_COLLECTION_NAME = exports.MATERIALIZED_TENANT_HOURLY_COMPARISON_REPORTS_COLLECTION_NAME = exports.ALL_SALES_COMPARISON_METRICS = exports.SALES_COMPARISON_METRIC_ENUM = exports.ALL_SALES_COMPARISON_BASELINES = exports.SALES_COMPARISON_BASELINE_ENUM = exports.MATERIALIZED_TENANT_SALES_COMPARISON_ENTRIES_SCHEMA_VERSION = exports.MATERIALIZED_TENANT_SALES_COMPARISON_REPORTS_SCHEMA_VERSION = exports.SALES_COMPARISON_KEY_FILTERS = exports.MATERIALIZED_SALES_COMPARISON_REPORT_SCOPES = exports.MATERIALIZED_TENANT_SALES_COMPARISON_ENTRIES_COLLECTION_NAME = exports.MATERIALIZED_TENANT_SALES_COMPARISON_REPORTS_COLLECTION_NAME = exports.ALL_MATERIALIZED_REPORT_TYPES = exports.MATERIALIZED_REPORT_TYPE_ENUM = exports.ALL_MATERIALIZED_PREP_TIME_TARGETS = exports.MATERIALIZED_PREP_TIME_TARGET_ENUM = exports.MATERIALIZED_PREP_TIME_ON_TIME_MAX_DELTA = exports.MATERIALIZED_PREP_TIME_TOP_BUCKET = exports.MATERIALIZED_PREP_TIME_MAX_MINUTES = exports.ALL_MATERIALIZED_PREP_TIME_BUCKET_LABELS = exports.MATERIALIZED_PREP_TIME_BUCKETS = exports.ALL_MATERIALIZED_PREP_TIME_ANCHORS = exports.MATERIALIZED_PREP_TIME_ANCHOR_ENUM = exports.PREP_TIME_KEY_FILTERS = exports.MATERIALIZED_PREP_TIME_ITEM_MAX_READ_DAYS = exports.MATERIALIZED_PREP_TIME_ITEM_SCOPES = exports.MATERIALIZED_PREP_TIME_REPORT_SCOPES = exports.MATERIALIZED_DELIVERY_GEO_CELL_MAX_BSON_BYTES = exports.MATERIALIZED_DELIVERY_ENTRY_MAX_BSON_BYTES = exports.MATERIALIZED_DELIVERY_REPORT_MAX_BSON_BYTES = exports.MATERIALIZED_DELIVERY_GEO_UNKNOWN_CELL = exports.MATERIALIZED_DELIVERY_GEO_MONTH_RETENTION_MONTHS = exports.MATERIALIZED_DELIVERY_GEO_DAY_RETENTION_DAYS = exports.MATERIALIZED_DELIVERY_GEO_MAX_CELLS = exports.MATERIALIZED_DELIVERY_GEO_MIN_ORDERS = void 0;
|
|
14
|
+
exports.MATERIALIZED_DIALER_ENTRY_PAGE_ALL = exports.MATERIALIZED_DIALER_ENTRY_SCOPES = exports.MATERIALIZED_DIALER_REPORT_SCOPES = exports.ALL_PAYMENTS_COMPARISON_METRICS = exports.PAYMENTS_COMPARISON_METRIC_ENUM = exports.MATERIALIZED_TENANT_PAYMENTS_COMPARISON_ENTRIES_SCHEMA_VERSION = exports.MATERIALIZED_TENANT_PAYMENTS_COMPARISON_REPORTS_SCHEMA_VERSION = exports.PAYMENTS_COMPARISON_KEY_FILTERS = exports.MATERIALIZED_PAYMENTS_COMPARISON_REPORT_SCOPES = exports.MATERIALIZED_TENANT_PAYMENTS_COMPARISON_ENTRIES_COLLECTION_NAME = exports.MATERIALIZED_TENANT_PAYMENTS_COMPARISON_REPORTS_COLLECTION_NAME = exports.MATERIALIZED_TENANT_HOURLY_COMPARISON_ENTRIES_SCHEMA_VERSION = exports.MATERIALIZED_TENANT_HOURLY_COMPARISON_REPORTS_SCHEMA_VERSION = exports.HOURLY_COMPARISON_KEY_FILTERS = exports.MATERIALIZED_HOURLY_COMPARISON_REPORT_SCOPES = exports.MATERIALIZED_TENANT_HOURLY_COMPARISON_ENTRIES_COLLECTION_NAME = exports.MATERIALIZED_TENANT_HOURLY_COMPARISON_REPORTS_COLLECTION_NAME = exports.ALL_SALES_COMPARISON_METRICS = exports.SALES_COMPARISON_METRIC_ENUM = exports.ALL_SALES_COMPARISON_BASELINES = exports.SALES_COMPARISON_BASELINE_ENUM = exports.MATERIALIZED_TENANT_SALES_COMPARISON_ENTRIES_SCHEMA_VERSION = exports.MATERIALIZED_TENANT_SALES_COMPARISON_REPORTS_SCHEMA_VERSION = exports.SALES_COMPARISON_KEY_FILTERS = exports.MATERIALIZED_SALES_COMPARISON_REPORT_SCOPES = exports.MATERIALIZED_TENANT_SALES_COMPARISON_ENTRIES_COLLECTION_NAME = exports.MATERIALIZED_TENANT_SALES_COMPARISON_REPORTS_COLLECTION_NAME = exports.ALL_MATERIALIZED_REPORT_TYPES = exports.MATERIALIZED_REPORT_TYPE_ENUM = exports.ALL_MATERIALIZED_PREP_TIME_TARGETS = exports.MATERIALIZED_PREP_TIME_TARGET_ENUM = exports.MATERIALIZED_PREP_TIME_ON_TIME_MAX_DELTA = exports.MATERIALIZED_PREP_TIME_TOP_BUCKET = exports.MATERIALIZED_PREP_TIME_MAX_MINUTES = exports.ALL_MATERIALIZED_PREP_TIME_BUCKET_LABELS = exports.MATERIALIZED_PREP_TIME_BUCKETS = exports.ALL_MATERIALIZED_PREP_TIME_ANCHORS = exports.MATERIALIZED_PREP_TIME_ANCHOR_ENUM = exports.PREP_TIME_KEY_FILTERS = exports.MATERIALIZED_PREP_TIME_ITEM_MAX_READ_DAYS = exports.MATERIALIZED_PREP_TIME_ITEM_SCOPES = exports.MATERIALIZED_PREP_TIME_REPORT_SCOPES = exports.MATERIALIZED_DELIVERY_GEO_CELL_MAX_BSON_BYTES = exports.MATERIALIZED_DELIVERY_ENTRY_MAX_BSON_BYTES = exports.MATERIALIZED_DELIVERY_REPORT_MAX_BSON_BYTES = exports.MATERIALIZED_DELIVERY_GEO_UNKNOWN_CELL = exports.MATERIALIZED_DELIVERY_GEO_MONTH_RETENTION_MONTHS = exports.MATERIALIZED_DELIVERY_GEO_DAY_RETENTION_DAYS = exports.MATERIALIZED_DELIVERY_GEO_MAX_CELLS = exports.MATERIALIZED_DELIVERY_GEO_MIN_ORDERS = void 0;
|
|
15
|
+
exports.MATERIALIZED_DIALER_ENTRY_MAX_BSON_BYTES = exports.MATERIALIZED_DIALER_REPORT_MAX_BSON_BYTES = exports.MATERIALIZED_DIALER_HOUR_KEYS = exports.MATERIALIZED_DIALER_KEY_SEPARATOR = exports.MATERIALIZED_DIALER_UNKNOWN_TOKEN = exports.DIALER_KEY_FILTERS = void 0;
|
|
15
16
|
/**
|
|
16
17
|
* Time-scope of a materialized report document. Every document covers exactly
|
|
17
18
|
* one tenant × one scope context × one scope value (`scope_field`), and the
|
|
@@ -114,6 +115,12 @@ var MATERIALIZED_REPORT_KEY_FILTER_ENUM;
|
|
|
114
115
|
// OPEN string (live stores carry values outside the enum) and is normalized only
|
|
115
116
|
// for the PAY_LATER -> UNPAID remap.
|
|
116
117
|
MATERIALIZED_REPORT_KEY_FILTER_ENUM["PAYMENT_METHOD"] = "PAYMENT_METHOD";
|
|
118
|
+
// Dialer encodes <ACTION>:<POS_ID>:<STAFF_ID>. The action is the dialer event
|
|
119
|
+
// action; pos/staff identify the terminal and the operator. A component the
|
|
120
|
+
// source does not carry is encoded as `UNKNOWN` (never dropped).
|
|
121
|
+
MATERIALIZED_REPORT_KEY_FILTER_ENUM["ACTION"] = "ACTION";
|
|
122
|
+
MATERIALIZED_REPORT_KEY_FILTER_ENUM["POS_ID"] = "POS_ID";
|
|
123
|
+
MATERIALIZED_REPORT_KEY_FILTER_ENUM["STAFF_ID"] = "STAFF_ID";
|
|
117
124
|
})(MATERIALIZED_REPORT_KEY_FILTER_ENUM || (exports.MATERIALIZED_REPORT_KEY_FILTER_ENUM = MATERIALIZED_REPORT_KEY_FILTER_ENUM = {}));
|
|
118
125
|
exports.ALL_MATERIALIZED_REPORT_KEY_FILTERS = Object.values(MATERIALIZED_REPORT_KEY_FILTER_ENUM);
|
|
119
126
|
/** Ordered key filters of the tenant sales overview report (`PLACED:POS_WALK-IN`). */
|
|
@@ -678,6 +685,8 @@ var MATERIALIZED_REPORT_TYPE_ENUM;
|
|
|
678
685
|
MATERIALIZED_REPORT_TYPE_ENUM["TENANT_HOURLY_COMPARISON_ENTRIES"] = "TENANT_HOURLY_COMPARISON_ENTRIES";
|
|
679
686
|
MATERIALIZED_REPORT_TYPE_ENUM["TENANT_PAYMENTS_COMPARISON_REPORTS"] = "TENANT_PAYMENTS_COMPARISON_REPORTS";
|
|
680
687
|
MATERIALIZED_REPORT_TYPE_ENUM["TENANT_PAYMENTS_COMPARISON_ENTRIES"] = "TENANT_PAYMENTS_COMPARISON_ENTRIES";
|
|
688
|
+
MATERIALIZED_REPORT_TYPE_ENUM["TENANT_DIALER_REPORTS"] = "TENANT_DIALER_REPORTS";
|
|
689
|
+
MATERIALIZED_REPORT_TYPE_ENUM["TENANT_DIALER_ENTRIES"] = "TENANT_DIALER_ENTRIES";
|
|
681
690
|
})(MATERIALIZED_REPORT_TYPE_ENUM || (exports.MATERIALIZED_REPORT_TYPE_ENUM = MATERIALIZED_REPORT_TYPE_ENUM = {}));
|
|
682
691
|
exports.ALL_MATERIALIZED_REPORT_TYPES = Object.values(MATERIALIZED_REPORT_TYPE_ENUM);
|
|
683
692
|
/* =====================> Sales Comparison report <===================== */
|
|
@@ -811,3 +820,86 @@ var PAYMENTS_COMPARISON_METRIC_ENUM;
|
|
|
811
820
|
PAYMENTS_COMPARISON_METRIC_ENUM["AMOUNT_DUE"] = "AMOUNT_DUE";
|
|
812
821
|
})(PAYMENTS_COMPARISON_METRIC_ENUM || (exports.PAYMENTS_COMPARISON_METRIC_ENUM = PAYMENTS_COMPARISON_METRIC_ENUM = {}));
|
|
813
822
|
exports.ALL_PAYMENTS_COMPARISON_METRICS = Object.values(PAYMENTS_COMPARISON_METRIC_ENUM);
|
|
823
|
+
/* =====================> Dialer report <===================== */
|
|
824
|
+
/**
|
|
825
|
+
* Dialer report — the FIRST report whose source is an append-only EVENT stream
|
|
826
|
+
* (`tenant_dialer_events`) rather than order-shaped documents.
|
|
827
|
+
*
|
|
828
|
+
* ## No local date is ever invented
|
|
829
|
+
*
|
|
830
|
+
* A dialer event carries its tenant-local fields only when the POS dialer could
|
|
831
|
+
* resolve the running business day at write time. An event with no `localDate`
|
|
832
|
+
* is UNATTRIBUTED: it is never counted into a day (and never assigned to the
|
|
833
|
+
* close's day), so it cannot be double-counted by a later re-close. The
|
|
834
|
+
* materializer reports the day-window unattributed count instead.
|
|
835
|
+
*
|
|
836
|
+
* ## Counters only — no duration, no order attribution
|
|
837
|
+
*
|
|
838
|
+
* The source stores no duration and the report derives none: a call is a set of
|
|
839
|
+
* EVENTS (`CALL_ANSWERED`, `CALL_ENDED`, …), not one row with a duration. The
|
|
840
|
+
* page derives every rate itself from the counters
|
|
841
|
+
* (`outcome_denominator = answered + missed + declined`); nothing derived is
|
|
842
|
+
* stored.
|
|
843
|
+
*
|
|
844
|
+
* ## Key grammar
|
|
845
|
+
*
|
|
846
|
+
* `<ACTION>:<POS_ID>:<STAFF_ID>` — the three key filters. `STAFF_ID` is
|
|
847
|
+
* nullable in the source, so a missing component is encoded as `UNKNOWN`; the
|
|
848
|
+
* event is never dropped for a missing dimension.
|
|
849
|
+
*/
|
|
850
|
+
/**
|
|
851
|
+
* Pointer scopes. Like every counters report, the period documents are FOLDED
|
|
852
|
+
* from the sibling DAY documents (the writer never reads another day's rows).
|
|
853
|
+
* No `localHour` scope: the hour dimension is a `by_hour` map INSIDE each
|
|
854
|
+
* counter key, which is the shape the Dialer page renders.
|
|
855
|
+
*/
|
|
856
|
+
exports.MATERIALIZED_DIALER_REPORT_SCOPES = [
|
|
857
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_DATE,
|
|
858
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_WEEK,
|
|
859
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_WEEK_OF_YEAR,
|
|
860
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_MONTH,
|
|
861
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_QUARTER,
|
|
862
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_SEMESTER,
|
|
863
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_YEAR,
|
|
864
|
+
];
|
|
865
|
+
/**
|
|
866
|
+
* Entry scopes: the day page plus the three PERIOD pages. Every period scope is
|
|
867
|
+
* PAGE-PARTITIONED by source day, so an entry document is bounded by one day's
|
|
868
|
+
* events. There is no quarter / semester / year entry document.
|
|
869
|
+
*/
|
|
870
|
+
exports.MATERIALIZED_DIALER_ENTRY_SCOPES = [
|
|
871
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_DATE,
|
|
872
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_WEEK,
|
|
873
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_WEEK_OF_YEAR,
|
|
874
|
+
MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_MONTH,
|
|
875
|
+
];
|
|
876
|
+
/**
|
|
877
|
+
* Page key of the DAY-scoped entry document. The day scope is already one day,
|
|
878
|
+
* so it needs no per-source-day partition; the three period scopes use the
|
|
879
|
+
* source `localDate` as their page (`page=<source localDate>`).
|
|
880
|
+
*/
|
|
881
|
+
exports.MATERIALIZED_DIALER_ENTRY_PAGE_ALL = 'all';
|
|
882
|
+
/** Ordered key filters: `<ACTION>:<POS_ID>:<STAFF_ID>`. */
|
|
883
|
+
exports.DIALER_KEY_FILTERS = [
|
|
884
|
+
MATERIALIZED_REPORT_KEY_FILTER_ENUM.ACTION,
|
|
885
|
+
MATERIALIZED_REPORT_KEY_FILTER_ENUM.POS_ID,
|
|
886
|
+
MATERIALIZED_REPORT_KEY_FILTER_ENUM.STAFF_ID,
|
|
887
|
+
];
|
|
888
|
+
/** Token used when a key component is missing (`UNKNOWN`). */
|
|
889
|
+
exports.MATERIALIZED_DIALER_UNKNOWN_TOKEN = 'UNKNOWN';
|
|
890
|
+
/** Key component delimiter. Enum/ids cannot contain it; a raw value is sanitized. */
|
|
891
|
+
exports.MATERIALIZED_DIALER_KEY_SEPARATOR = ':';
|
|
892
|
+
/**
|
|
893
|
+
* The 24 `by_hour` bucket labels — `"0".."23"` (NOT zero-padded; this is the
|
|
894
|
+
* contract the page renders and the stored documents carry). Every counters
|
|
895
|
+
* block initializes all 24 keys, so a missing bucket is unambiguously zero.
|
|
896
|
+
*/
|
|
897
|
+
exports.MATERIALIZED_DIALER_HOUR_KEYS = Array.from({ length: 24 }, (_, hour) => String(hour));
|
|
898
|
+
/**
|
|
899
|
+
* Per-collection BSON budgets. MongoDB's hard limit is 16 MiB per document;
|
|
900
|
+
* 15 MiB is the owner-approved practical ceiling, leaving 1 MiB of headroom.
|
|
901
|
+
* A document that exceeds its budget fails at COMPILE/PLAN time, naming the
|
|
902
|
+
* collection + source day + scope — never midway through the close transaction.
|
|
903
|
+
*/
|
|
904
|
+
exports.MATERIALIZED_DIALER_REPORT_MAX_BSON_BYTES = 15 * 1024 * 1024;
|
|
905
|
+
exports.MATERIALIZED_DIALER_ENTRY_MAX_BSON_BYTES = 15 * 1024 * 1024;
|
|
@@ -24,6 +24,12 @@ export * from './materialized-delivery-compile-helpers';
|
|
|
24
24
|
export * from './materialized-delivery-classification-helpers';
|
|
25
25
|
export * from './materialized-delivery-close-day-helpers';
|
|
26
26
|
export * from './materialized-delivery-index-migration';
|
|
27
|
+
export * from './materialized-dialer-accumulator-helpers';
|
|
28
|
+
export * from './materialized-dialer-close-day-helpers';
|
|
29
|
+
export * from './materialized-dialer-compile-helpers';
|
|
30
|
+
export * from './materialized-dialer-entry-pages';
|
|
31
|
+
export * from './materialized-dialer-key-helpers';
|
|
32
|
+
export * from './materialized-dialer-masking';
|
|
27
33
|
export * from './materialized-day-input-signature';
|
|
28
34
|
export * from './materialized-cash-classification-helpers';
|
|
29
35
|
export * from './materialized-cash-close-day-helpers';
|
|
@@ -50,6 +56,7 @@ export * from './tenant-discount-formatter';
|
|
|
50
56
|
export * from './tenant-discount-source-formatter';
|
|
51
57
|
export * from './tenant-cash-in-out-formatter';
|
|
52
58
|
export * from './tenant-delivery-formatter';
|
|
59
|
+
export * from './tenant-dialer-formatter';
|
|
53
60
|
export * from './tenant-prep-time-formatter';
|
|
54
61
|
export * from './tenant-sales-overview-formatter';
|
|
55
62
|
export * from './tenant-sales-overview-helpers';
|
|
@@ -40,6 +40,12 @@ __exportStar(require("./materialized-delivery-compile-helpers"), exports);
|
|
|
40
40
|
__exportStar(require("./materialized-delivery-classification-helpers"), exports);
|
|
41
41
|
__exportStar(require("./materialized-delivery-close-day-helpers"), exports);
|
|
42
42
|
__exportStar(require("./materialized-delivery-index-migration"), exports);
|
|
43
|
+
__exportStar(require("./materialized-dialer-accumulator-helpers"), exports);
|
|
44
|
+
__exportStar(require("./materialized-dialer-close-day-helpers"), exports);
|
|
45
|
+
__exportStar(require("./materialized-dialer-compile-helpers"), exports);
|
|
46
|
+
__exportStar(require("./materialized-dialer-entry-pages"), exports);
|
|
47
|
+
__exportStar(require("./materialized-dialer-key-helpers"), exports);
|
|
48
|
+
__exportStar(require("./materialized-dialer-masking"), exports);
|
|
43
49
|
__exportStar(require("./materialized-day-input-signature"), exports);
|
|
44
50
|
__exportStar(require("./materialized-cash-classification-helpers"), exports);
|
|
45
51
|
__exportStar(require("./materialized-cash-close-day-helpers"), exports);
|
|
@@ -66,6 +72,7 @@ __exportStar(require("./tenant-discount-formatter"), exports);
|
|
|
66
72
|
__exportStar(require("./tenant-discount-source-formatter"), exports);
|
|
67
73
|
__exportStar(require("./tenant-cash-in-out-formatter"), exports);
|
|
68
74
|
__exportStar(require("./tenant-delivery-formatter"), exports);
|
|
75
|
+
__exportStar(require("./tenant-dialer-formatter"), exports);
|
|
69
76
|
__exportStar(require("./tenant-prep-time-formatter"), exports);
|
|
70
77
|
__exportStar(require("./tenant-sales-overview-formatter"), exports);
|
|
71
78
|
__exportStar(require("./tenant-sales-overview-helpers"), exports);
|
|
@@ -15,3 +15,4 @@ export interface IDeliveryMaterializationWipeTarget {
|
|
|
15
15
|
filter: Record<string, unknown>;
|
|
16
16
|
}
|
|
17
17
|
export declare function buildDeliveryMaterializationWipeTargets(tenantId?: string | null): IDeliveryMaterializationWipeTarget[];
|
|
18
|
+
export declare function assertMaterializedWipeTargets(targets: readonly IDeliveryMaterializationWipeTarget[]): void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.buildDeliveryMaterializationWipeTargets = buildDeliveryMaterializationWipeTargets;
|
|
4
|
+
exports.assertMaterializedWipeTargets = assertMaterializedWipeTargets;
|
|
4
5
|
const MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
|
|
5
6
|
const materialized_report_drilldown_rows_1 = require("../../schemas/models/materialized_report_drilldown_rows");
|
|
6
7
|
const materialized_tenant_delivery_entries_1 = require("../../schemas/models/materialized_tenant_delivery_entries");
|
|
@@ -33,3 +34,21 @@ function buildDeliveryMaterializationWipeTargets(tenantId) {
|
|
|
33
34
|
{ name: materialized_tenant_reports_iterations_1.MATERIALIZED_TENANT_REPORTS_ITERATIONS_COLLECTION_NAME, filter: iterationFilter },
|
|
34
35
|
];
|
|
35
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Phase 5 safety gate: a wipe target may only name a materialized collection
|
|
39
|
+
* and may only filter on tenant/report identity. This is the last line of
|
|
40
|
+
* defence before an operator command talks to MongoDB.
|
|
41
|
+
*/
|
|
42
|
+
const ALLOWED_WIPE_FILTER_KEYS = new Set(['tenant_id', 'report_type', 'snapshot.tenant_id']);
|
|
43
|
+
function assertMaterializedWipeTargets(targets) {
|
|
44
|
+
for (const target of targets) {
|
|
45
|
+
if (!target.name.startsWith('materialized_')) {
|
|
46
|
+
throw new Error(`Refusing wipe: ${target.name} is not a materialized_* collection`);
|
|
47
|
+
}
|
|
48
|
+
for (const key of Object.keys(target.filter)) {
|
|
49
|
+
if (!ALLOWED_WIPE_FILTER_KEYS.has(key)) {
|
|
50
|
+
throw new Error(`Refusing wipe: ${target.name} filters on forbidden key ${key}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { DIALER_TYPES_ENUM } from '../../constants/DIALER_ENUMS';
|
|
2
|
+
import { IDialerCounters } from '../../schemas/types/materialized_tenant_dialer_reports';
|
|
3
|
+
/**
|
|
4
|
+
* Dialer counter accumulation — the ONE place a source event becomes a counter.
|
|
5
|
+
*
|
|
6
|
+
* The counters are pure additive event counts (no money, no duration, no
|
|
7
|
+
* average), so a day compile, a live fold and a close-day period fold all use
|
|
8
|
+
* the same `mergeDialerCounters`. There is no order attribution and no
|
|
9
|
+
* duration: a call is a sequence of events, and the page derives every rate
|
|
10
|
+
* from these integers.
|
|
11
|
+
*
|
|
12
|
+
* `by_hour` always carries all 24 keys (`"0"`..`"23"`), so a missing bucket is
|
|
13
|
+
* unambiguously zero and a period fold is a plain 24-way sum.
|
|
14
|
+
*/
|
|
15
|
+
/** The dialer action → counter-field mapping. One definition, no drift. */
|
|
16
|
+
export declare const MATERIALIZED_DIALER_ACTION_COUNTER: Partial<Record<DIALER_TYPES_ENUM, keyof IDialerCounters>>;
|
|
17
|
+
/** A zeroed 24-hour map. */
|
|
18
|
+
export declare function freshDialerByHour(): Record<string, number>;
|
|
19
|
+
/** A zeroed counter block (all 24 hour keys present). */
|
|
20
|
+
export declare function freshDialerCounters(): IDialerCounters;
|
|
21
|
+
/** The valid `by_hour` key of a tenant-local hour, or `null` when not a whole hour. */
|
|
22
|
+
export declare function dialerHourKey(hour: unknown): string | null;
|
|
23
|
+
/**
|
|
24
|
+
* Adds ONE attributed event to a counter block.
|
|
25
|
+
*
|
|
26
|
+
* `by_hour` is incremented only for an integer hour `0..23`; the compile
|
|
27
|
+
* guarantees attribution already validated the hour, so a caller that passes a
|
|
28
|
+
* malformed hour accrues `events` without inventing a bucket.
|
|
29
|
+
*/
|
|
30
|
+
export declare function addDialerEvent(counters: IDialerCounters, event: {
|
|
31
|
+
action?: unknown;
|
|
32
|
+
localHour?: unknown;
|
|
33
|
+
}): void;
|
|
34
|
+
/** Adds every counter of `source` into `target` (in place); returns `target`. */
|
|
35
|
+
export declare function mergeDialerCounters(target: IDialerCounters, source: IDialerCounters | null | undefined): IDialerCounters;
|
|
36
|
+
/** Folds a list of counter blocks into one — the live/period read helper. */
|
|
37
|
+
export declare function sumDialerCounters(blocks: readonly (IDialerCounters | null | undefined)[] | null | undefined): IDialerCounters;
|
|
38
|
+
/** Folds a key-addressed counter map into one block. */
|
|
39
|
+
export declare function sumDialerCounterMap(counters: Record<string, IDialerCounters> | null | undefined): IDialerCounters;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MATERIALIZED_DIALER_ACTION_COUNTER = void 0;
|
|
4
|
+
exports.freshDialerByHour = freshDialerByHour;
|
|
5
|
+
exports.freshDialerCounters = freshDialerCounters;
|
|
6
|
+
exports.dialerHourKey = dialerHourKey;
|
|
7
|
+
exports.addDialerEvent = addDialerEvent;
|
|
8
|
+
exports.mergeDialerCounters = mergeDialerCounters;
|
|
9
|
+
exports.sumDialerCounters = sumDialerCounters;
|
|
10
|
+
exports.sumDialerCounterMap = sumDialerCounterMap;
|
|
11
|
+
const DIALER_ENUMS_1 = require("../../constants/DIALER_ENUMS");
|
|
12
|
+
const MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
|
|
13
|
+
/**
|
|
14
|
+
* Dialer counter accumulation — the ONE place a source event becomes a counter.
|
|
15
|
+
*
|
|
16
|
+
* The counters are pure additive event counts (no money, no duration, no
|
|
17
|
+
* average), so a day compile, a live fold and a close-day period fold all use
|
|
18
|
+
* the same `mergeDialerCounters`. There is no order attribution and no
|
|
19
|
+
* duration: a call is a sequence of events, and the page derives every rate
|
|
20
|
+
* from these integers.
|
|
21
|
+
*
|
|
22
|
+
* `by_hour` always carries all 24 keys (`"0"`..`"23"`), so a missing bucket is
|
|
23
|
+
* unambiguously zero and a period fold is a plain 24-way sum.
|
|
24
|
+
*/
|
|
25
|
+
/** The dialer action → counter-field mapping. One definition, no drift. */
|
|
26
|
+
exports.MATERIALIZED_DIALER_ACTION_COUNTER = {
|
|
27
|
+
[DIALER_ENUMS_1.DIALER_TYPES_ENUM.INCOMING_CALL]: 'incoming_calls',
|
|
28
|
+
[DIALER_ENUMS_1.DIALER_TYPES_ENUM.OUTGOING_CALL]: 'outgoing_calls',
|
|
29
|
+
[DIALER_ENUMS_1.DIALER_TYPES_ENUM.CALL_ANSWERED]: 'answered',
|
|
30
|
+
[DIALER_ENUMS_1.DIALER_TYPES_ENUM.MISSED_CALL]: 'missed',
|
|
31
|
+
[DIALER_ENUMS_1.DIALER_TYPES_ENUM.CALL_DECLINED]: 'declined',
|
|
32
|
+
[DIALER_ENUMS_1.DIALER_TYPES_ENUM.CALL_ENDED]: 'ended',
|
|
33
|
+
[DIALER_ENUMS_1.DIALER_TYPES_ENUM.POS_PING]: 'pos_pings',
|
|
34
|
+
};
|
|
35
|
+
/** A zeroed 24-hour map. */
|
|
36
|
+
function freshDialerByHour() {
|
|
37
|
+
const byHour = {};
|
|
38
|
+
for (const hour of MATERIALIZED_REPORTS_1.MATERIALIZED_DIALER_HOUR_KEYS)
|
|
39
|
+
byHour[hour] = 0;
|
|
40
|
+
return byHour;
|
|
41
|
+
}
|
|
42
|
+
/** A zeroed counter block (all 24 hour keys present). */
|
|
43
|
+
function freshDialerCounters() {
|
|
44
|
+
return {
|
|
45
|
+
events: 0,
|
|
46
|
+
incoming_calls: 0,
|
|
47
|
+
outgoing_calls: 0,
|
|
48
|
+
answered: 0,
|
|
49
|
+
missed: 0,
|
|
50
|
+
declined: 0,
|
|
51
|
+
ended: 0,
|
|
52
|
+
pos_pings: 0,
|
|
53
|
+
by_hour: freshDialerByHour(),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/** The valid `by_hour` key of a tenant-local hour, or `null` when not a whole hour. */
|
|
57
|
+
function dialerHourKey(hour) {
|
|
58
|
+
const value = Number(hour);
|
|
59
|
+
if (!Number.isInteger(value) || value < 0 || value > 23)
|
|
60
|
+
return null;
|
|
61
|
+
return String(value);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Adds ONE attributed event to a counter block.
|
|
65
|
+
*
|
|
66
|
+
* `by_hour` is incremented only for an integer hour `0..23`; the compile
|
|
67
|
+
* guarantees attribution already validated the hour, so a caller that passes a
|
|
68
|
+
* malformed hour accrues `events` without inventing a bucket.
|
|
69
|
+
*/
|
|
70
|
+
function addDialerEvent(counters, event) {
|
|
71
|
+
counters.events += 1;
|
|
72
|
+
const action = String(event?.action ?? '');
|
|
73
|
+
const field = exports.MATERIALIZED_DIALER_ACTION_COUNTER[action];
|
|
74
|
+
if (field != null) {
|
|
75
|
+
counters[field] += 1;
|
|
76
|
+
}
|
|
77
|
+
const hour = dialerHourKey(event?.localHour);
|
|
78
|
+
if (hour != null) {
|
|
79
|
+
counters.by_hour[hour] = (Number(counters.by_hour[hour]) || 0) + 1;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/** Adds every counter of `source` into `target` (in place); returns `target`. */
|
|
83
|
+
function mergeDialerCounters(target, source) {
|
|
84
|
+
if (source == null)
|
|
85
|
+
return target;
|
|
86
|
+
target.events += Number(source.events) || 0;
|
|
87
|
+
target.incoming_calls += Number(source.incoming_calls) || 0;
|
|
88
|
+
target.outgoing_calls += Number(source.outgoing_calls) || 0;
|
|
89
|
+
target.answered += Number(source.answered) || 0;
|
|
90
|
+
target.missed += Number(source.missed) || 0;
|
|
91
|
+
target.declined += Number(source.declined) || 0;
|
|
92
|
+
target.ended += Number(source.ended) || 0;
|
|
93
|
+
target.pos_pings += Number(source.pos_pings) || 0;
|
|
94
|
+
target.by_hour = target.by_hour ?? freshDialerByHour();
|
|
95
|
+
for (const hour of MATERIALIZED_REPORTS_1.MATERIALIZED_DIALER_HOUR_KEYS) {
|
|
96
|
+
target.by_hour[hour] = (Number(target.by_hour[hour]) || 0) + (Number(source.by_hour?.[hour]) || 0);
|
|
97
|
+
}
|
|
98
|
+
return target;
|
|
99
|
+
}
|
|
100
|
+
/** Folds a list of counter blocks into one — the live/period read helper. */
|
|
101
|
+
function sumDialerCounters(blocks) {
|
|
102
|
+
const total = freshDialerCounters();
|
|
103
|
+
for (const block of blocks ?? [])
|
|
104
|
+
mergeDialerCounters(total, block);
|
|
105
|
+
return total;
|
|
106
|
+
}
|
|
107
|
+
/** Folds a key-addressed counter map into one block. */
|
|
108
|
+
function sumDialerCounterMap(counters) {
|
|
109
|
+
return sumDialerCounters(Object.values(counters ?? {}));
|
|
110
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { MATERIALIZED_REPORT_SCOPE_ENUM } from '../../constants/MATERIALIZED_REPORTS';
|
|
2
|
+
import { IMaterializedTenantDialerEntry } from '../../schemas/types/materialized_tenant_dialer_entries';
|
|
3
|
+
import { IDialerCounters, IMaterializedTenantDialerReport } from '../../schemas/types/materialized_tenant_dialer_reports';
|
|
4
|
+
/**
|
|
5
|
+
* Dialer close-day helpers.
|
|
6
|
+
*
|
|
7
|
+
* ## Period counters are RE-FOLDED from sibling DAY documents
|
|
8
|
+
*
|
|
9
|
+
* A period document is a plain sum of its days' event counters, so removing a
|
|
10
|
+
* day from a period is subtractable in principle — but re-folding is the
|
|
11
|
+
* platform rule and the only way an emptied/recompiled day stays exact. Every
|
|
12
|
+
* touched period is rebuilt from its whole day set (the closing day's fresh
|
|
13
|
+
* document plus the stored sibling DAY documents the caller fetched).
|
|
14
|
+
*
|
|
15
|
+
* ## ENTRY pages are NEVER folded
|
|
16
|
+
*
|
|
17
|
+
* `materialized_tenant_dialer_entries` is page-partitioned by source day: the
|
|
18
|
+
* caller fetches exactly the closing day's pages, each is replaced by its page
|
|
19
|
+
* identity, and a fetched page the day no longer owns is deleted. No other
|
|
20
|
+
* day's page is read, merged or rewritten.
|
|
21
|
+
*/
|
|
22
|
+
/** Period COUNTER scopes this report materializes (everything but the day scope). */
|
|
23
|
+
export declare const MATERIALIZED_DIALER_PERIOD_SCOPES: MATERIALIZED_REPORT_SCOPE_ENUM[];
|
|
24
|
+
/**
|
|
25
|
+
* Every `localDate` label whose DAY counter document can contribute to a period
|
|
26
|
+
* the closing day rolls into. The worker uses it to fetch exactly the sibling
|
|
27
|
+
* DAY counters the period re-fold needs.
|
|
28
|
+
*/
|
|
29
|
+
export declare function getMaterializedDialerReportPeriodDayScopeFields(localDate: string): string[] | null;
|
|
30
|
+
/** True when the scope is the plain day scope. */
|
|
31
|
+
export declare const isMaterializedDialerDayScope: (scopeContext: string) => boolean;
|
|
32
|
+
/** True when the stored document does not already carry this exact content. */
|
|
33
|
+
export declare function needsMaterializedDialerReportWrite(existing: IMaterializedTenantDialerReport | null | undefined, next: IMaterializedTenantDialerReport): boolean;
|
|
34
|
+
/** True when the stored entry page does not already carry these exact rows. */
|
|
35
|
+
export declare function needsMaterializedDialerEntriesWrite(existing: IMaterializedTenantDialerEntry | null | undefined, next: IMaterializedTenantDialerEntry): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Folds the counters of every DAY document belonging to one period scope.
|
|
38
|
+
*
|
|
39
|
+
* The fold is key-addressed: two days that observed the same
|
|
40
|
+
* `<ACTION>:<POS_ID>:<STAFF_ID>` merge their counters; keys only one day
|
|
41
|
+
* observed keep their own block.
|
|
42
|
+
*/
|
|
43
|
+
export declare function foldMaterializedDialerPeriodCounters(input: {
|
|
44
|
+
periodScope: string;
|
|
45
|
+
periodScopeField: string;
|
|
46
|
+
dayDocuments: IMaterializedTenantDialerReport[];
|
|
47
|
+
}): Record<string, IDialerCounters>;
|
|
48
|
+
/** One plan write: the document plus its iteration history row. */
|
|
49
|
+
export interface IMaterializedDialerCloseDayWrite<T> {
|
|
50
|
+
report: T;
|
|
51
|
+
iteration: {
|
|
52
|
+
report_type: string;
|
|
53
|
+
report_id: string;
|
|
54
|
+
iteration: number;
|
|
55
|
+
schema_version: number;
|
|
56
|
+
reason: string;
|
|
57
|
+
snapshot: unknown;
|
|
58
|
+
createdAt: Date;
|
|
59
|
+
updatedAt: Date;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
export interface ITenantDialerCloseDayPlan {
|
|
63
|
+
writes: IMaterializedDialerCloseDayWrite<IMaterializedTenantDialerReport>[];
|
|
64
|
+
entryWrites: IMaterializedDialerCloseDayWrite<IMaterializedTenantDialerEntry>[];
|
|
65
|
+
staleDocuments: IMaterializedTenantDialerReport[];
|
|
66
|
+
staleEntryDocuments: IMaterializedTenantDialerEntry[];
|
|
67
|
+
skippedDocuments: IMaterializedTenantDialerReport[];
|
|
68
|
+
skippedEntryDocuments: IMaterializedTenantDialerEntry[];
|
|
69
|
+
}
|
|
70
|
+
export interface IBuildTenantDialerCloseDayPlanInput {
|
|
71
|
+
tenantId: string;
|
|
72
|
+
reports: IMaterializedTenantDialerReport[];
|
|
73
|
+
entries: IMaterializedTenantDialerEntry[];
|
|
74
|
+
/** The closing day. Required when the day compiled nothing (an emptied day). */
|
|
75
|
+
localDate?: string | null;
|
|
76
|
+
existing?: IMaterializedTenantDialerReport[];
|
|
77
|
+
existingEntries?: IMaterializedTenantDialerEntry[];
|
|
78
|
+
reason: string;
|
|
79
|
+
computedAt?: Date;
|
|
80
|
+
/** Rewrite every touched document even when the watermark says unchanged. */
|
|
81
|
+
force?: boolean;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Builds the close-day plan for ONE tenant-day.
|
|
85
|
+
*
|
|
86
|
+
* The DAY scope comes from the compile. Every touched PERIOD scope is re-folded
|
|
87
|
+
* from its whole day set; the touched set is the union of the closing day's
|
|
88
|
+
* periods AND the periods of any day document this close removes.
|
|
89
|
+
*/
|
|
90
|
+
export declare function buildTenantDialerCloseDayPlan(input: IBuildTenantDialerCloseDayPlanInput | null | undefined): ITenantDialerCloseDayPlan | null;
|