@managesome/eposmatic-toolkit 0.4.60 → 0.4.62

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.
Files changed (96) hide show
  1. package/esm/constants/MATERIALIZED_REPORTS.js +254 -4
  2. package/esm/constants/TENANT_ENUMS.js +15 -0
  3. package/esm/constants/WORKER_ENDPOINTS.js +12 -0
  4. package/esm/helpers/materialized-reports/index.js +8 -0
  5. package/esm/helpers/materialized-reports/materialized-day-readiness.js +2 -2
  6. package/esm/helpers/materialized-reports/materialized-dinein-accumulator-helpers.js +557 -0
  7. package/esm/helpers/materialized-reports/materialized-dinein-classification-helpers.js +447 -0
  8. package/esm/helpers/materialized-reports/materialized-dinein-close-day-helpers.js +372 -0
  9. package/esm/helpers/materialized-reports/materialized-dinein-compile-helpers.js +500 -0
  10. package/esm/helpers/materialized-reports/materialized-dinein-entry-pages.js +218 -0
  11. package/esm/helpers/materialized-reports/materialized-dinein-key-helpers.js +87 -0
  12. package/esm/helpers/materialized-reports/materialized-index-bootstrap.js +7 -1
  13. package/esm/helpers/materialized-reports/materialized-report-drilldown-rows.js +8 -0
  14. package/esm/helpers/materialized-reports/materialized-report-runs.js +143 -0
  15. package/esm/helpers/materialized-reports/report-platform/definition.js +93 -1
  16. package/esm/helpers/materialized-reports/tenant-dinein-formatter.js +240 -0
  17. package/esm/helpers/reporting-contract/report-contract.js +3 -0
  18. package/esm/schemas/models/index.js +3 -0
  19. package/esm/schemas/models/materialized_tenant_dinein_entries.js +57 -0
  20. package/esm/schemas/models/materialized_tenant_dinein_reports.js +73 -0
  21. package/esm/schemas/models/materialized_tenant_report_runs.js +105 -0
  22. package/esm/schemas/models/tenant_active_jobs.js +19 -1
  23. package/esm/schemas/types/index.js +3 -0
  24. package/esm/schemas/types/materialized_report_drilldown_rows.js +1 -0
  25. package/esm/schemas/types/materialized_tenant_dinein_entries.js +1 -0
  26. package/esm/schemas/types/materialized_tenant_dinein_reports.js +6 -0
  27. package/esm/schemas/types/materialized_tenant_report_runs.js +1 -0
  28. package/lib/constants/MATERIALIZED_REPORTS.d.ts +229 -4
  29. package/lib/constants/MATERIALIZED_REPORTS.js +255 -5
  30. package/lib/constants/TENANT_ENUMS.d.ts +14 -0
  31. package/lib/constants/TENANT_ENUMS.js +16 -1
  32. package/lib/constants/WORKER_ENDPOINTS.d.ts +12 -0
  33. package/lib/constants/WORKER_ENDPOINTS.js +12 -0
  34. package/lib/helpers/materialized-reports/index.d.ts +8 -0
  35. package/lib/helpers/materialized-reports/index.js +8 -0
  36. package/lib/helpers/materialized-reports/materialized-day-readiness.d.ts +1 -1
  37. package/lib/helpers/materialized-reports/materialized-day-readiness.js +2 -2
  38. package/lib/helpers/materialized-reports/materialized-dinein-accumulator-helpers.d.ts +67 -0
  39. package/lib/helpers/materialized-reports/materialized-dinein-accumulator-helpers.js +582 -0
  40. package/lib/helpers/materialized-reports/materialized-dinein-classification-helpers.d.ts +245 -0
  41. package/lib/helpers/materialized-reports/materialized-dinein-classification-helpers.js +469 -0
  42. package/lib/helpers/materialized-reports/materialized-dinein-close-day-helpers.d.ts +110 -0
  43. package/lib/helpers/materialized-reports/materialized-dinein-close-day-helpers.js +384 -0
  44. package/lib/helpers/materialized-reports/materialized-dinein-compile-helpers.d.ts +73 -0
  45. package/lib/helpers/materialized-reports/materialized-dinein-compile-helpers.js +504 -0
  46. package/lib/helpers/materialized-reports/materialized-dinein-entry-pages.d.ts +69 -0
  47. package/lib/helpers/materialized-reports/materialized-dinein-entry-pages.js +231 -0
  48. package/lib/helpers/materialized-reports/materialized-dinein-key-helpers.d.ts +44 -0
  49. package/lib/helpers/materialized-reports/materialized-dinein-key-helpers.js +96 -0
  50. package/lib/helpers/materialized-reports/materialized-index-bootstrap.js +6 -0
  51. package/lib/helpers/materialized-reports/materialized-report-drilldown-rows.js +8 -0
  52. package/lib/helpers/materialized-reports/materialized-report-runs.d.ts +105 -0
  53. package/lib/helpers/materialized-reports/materialized-report-runs.js +156 -0
  54. package/lib/helpers/materialized-reports/report-platform/definition.js +92 -0
  55. package/lib/helpers/materialized-reports/tenant-dinein-formatter.d.ts +225 -0
  56. package/lib/helpers/materialized-reports/tenant-dinein-formatter.js +243 -0
  57. package/lib/helpers/reporting-contract/report-contract.d.ts +1 -0
  58. package/lib/helpers/reporting-contract/report-contract.js +3 -0
  59. package/lib/helpers/types/workers.d.ts +65 -0
  60. package/lib/schemas/models/index.d.ts +3 -0
  61. package/lib/schemas/models/index.js +3 -0
  62. package/lib/schemas/models/materialized_tenant_day_readiness.d.ts +3 -3
  63. package/lib/schemas/models/materialized_tenant_dinein_entries.d.ts +100 -0
  64. package/lib/schemas/models/materialized_tenant_dinein_entries.js +60 -0
  65. package/lib/schemas/models/materialized_tenant_dinein_reports.d.ts +111 -0
  66. package/lib/schemas/models/materialized_tenant_dinein_reports.js +76 -0
  67. package/lib/schemas/models/materialized_tenant_report_runs.d.ts +97 -0
  68. package/lib/schemas/models/materialized_tenant_report_runs.js +108 -0
  69. package/lib/schemas/models/tenant_active_jobs.d.ts +12 -3
  70. package/lib/schemas/models/tenant_active_jobs.js +18 -0
  71. package/lib/schemas/types/index.d.ts +3 -0
  72. package/lib/schemas/types/index.js +3 -0
  73. package/lib/schemas/types/materialized_report_drilldown_rows.d.ts +1 -1
  74. package/lib/schemas/types/materialized_report_drilldown_rows.js +1 -0
  75. package/lib/schemas/types/materialized_tenant_dinein_entries.d.ts +127 -0
  76. package/lib/schemas/types/materialized_tenant_dinein_entries.js +2 -0
  77. package/lib/schemas/types/materialized_tenant_dinein_reports.d.ts +326 -0
  78. package/lib/schemas/types/materialized_tenant_dinein_reports.js +9 -0
  79. package/lib/schemas/types/materialized_tenant_report_runs.d.ts +55 -0
  80. package/lib/schemas/types/materialized_tenant_report_runs.js +2 -0
  81. package/lib/schemas/types/tenant_active_jobs.d.ts +15 -1
  82. package/lib/tests/materialized-reports/dinein-fixtures.d.ts +29 -0
  83. package/lib/tests/materialized-reports/dinein-fixtures.js +130 -0
  84. package/lib/tests/materialized-reports/materialized-day-readiness.test.js +3 -2
  85. package/lib/tests/materialized-reports/materialized-dinein-compile.test.d.ts +1 -0
  86. package/lib/tests/materialized-reports/materialized-dinein-compile.test.js +807 -0
  87. package/lib/tests/materialized-reports/materialized-dinein-plan.test.d.ts +1 -0
  88. package/lib/tests/materialized-reports/materialized-dinein-plan.test.js +419 -0
  89. package/lib/tests/materialized-reports/materialized-report-runs.test.d.ts +1 -0
  90. package/lib/tests/materialized-reports/materialized-report-runs.test.js +116 -0
  91. package/lib/tests/materialized-reports/materialized-tenant-dinein-schema.test.d.ts +1 -0
  92. package/lib/tests/materialized-reports/materialized-tenant-dinein-schema.test.js +185 -0
  93. package/lib/tests/materialized-reports/report-platform/registry-conformance.test.js +15 -2
  94. package/lib/tests/materialized-reports/tenant-dinein-formatter.test.d.ts +1 -0
  95. package/lib/tests/materialized-reports/tenant-dinein-formatter.test.js +458 -0
  96. package/package.json +1 -1
@@ -565,7 +565,9 @@ export declare enum MATERIALIZED_REPORT_TYPE_ENUM {
565
565
  TENANT_PAYMENTS_COMPARISON_REPORTS = "TENANT_PAYMENTS_COMPARISON_REPORTS",
566
566
  TENANT_PAYMENTS_COMPARISON_ENTRIES = "TENANT_PAYMENTS_COMPARISON_ENTRIES",
567
567
  TENANT_DIALER_REPORTS = "TENANT_DIALER_REPORTS",
568
- TENANT_DIALER_ENTRIES = "TENANT_DIALER_ENTRIES"
568
+ TENANT_DIALER_ENTRIES = "TENANT_DIALER_ENTRIES",
569
+ TENANT_DINEIN_REPORTS = "TENANT_DINEIN_REPORTS",
570
+ TENANT_DINEIN_ENTRIES = "TENANT_DINEIN_ENTRIES"
569
571
  }
570
572
  export declare const ALL_MATERIALIZED_REPORT_TYPES: MATERIALIZED_REPORT_TYPE_ENUM[];
571
573
  /**
@@ -734,8 +736,162 @@ export declare const MATERIALIZED_DIALER_HOUR_KEYS: string[];
734
736
  export declare const MATERIALIZED_DIALER_REPORT_MAX_BSON_BYTES: number;
735
737
  export declare const MATERIALIZED_DIALER_ENTRY_MAX_BSON_BYTES: number;
736
738
  /**
737
- * COMMITTED-READINESS ledger for the five reports written by END_TENANT_DAY and
738
- * the range sync: Overview, Discounts, Prep Time, Delivery and Dialer.
739
+ * The Dinein report: covers, checks, seated occupancy, courses, split bills,
740
+ * reservations and guest experience for the dine-in population.
741
+ *
742
+ * ## Population
743
+ *
744
+ * `orders` with `dinein_details != null` for the order's OWN `localDate`. The
745
+ * deleted split PARENT is excluded from sales/order counts (the children are the
746
+ * collectable checks) and is read only for rating/review discovery.
747
+ *
748
+ * ## Two collections, one report
749
+ *
750
+ * `materialized_tenant_dinein_reports` is COUNTERS ONLY, keyed by
751
+ * `<ORDER_STATUS>:<PLATFORM>` (`sale_type_key_filters`); the reservation block is
752
+ * day-level because a reservation has no order and must never be dropped by an
753
+ * order-status/platform filter. `materialized_tenant_dinein_entries` holds ONE
754
+ * PAGE per source day (the discounts/delivery/dialer page model).
755
+ */
756
+ /**
757
+ * The two collections are named/versioned by their model modules
758
+ * (`materialized_tenant_dinein_reports` / `..._entries`), exactly like the other
759
+ * materialized report collections.
760
+ */
761
+ /**
762
+ * Scopes materialized by `materialized_tenant_dinein_reports`.
763
+ *
764
+ * NO `localHour`: the hour dimension is the `by_hour` map inside the document
765
+ * (the sales/covers-by-hour chart), exactly like Delivery. `localDate` is the day
766
+ * the ORDER was sold on (`order.localDate`), never the fingerprint's creation
767
+ * day: a table can close after midnight and still belong to the day it was sold.
768
+ */
769
+ export declare const MATERIALIZED_DINEIN_REPORT_SCOPES: MATERIALIZED_REPORT_SCOPE_ENUM[];
770
+ /**
771
+ * Entry scopes. A PERIOD entry document is PAGE-PARTITIONED by source day
772
+ * (`page = <source localDate>`) so a document is bounded by ONE day's checks; a
773
+ * month is covered by its 28-31 pages. There is no quarter/semester/year entry
774
+ * document, and a broad details selection is served from the month pages it
775
+ * touches (never refused).
776
+ */
777
+ export declare const MATERIALIZED_DINEIN_ENTRY_SCOPES: MATERIALIZED_REPORT_SCOPE_ENUM[];
778
+ /** Page key of the DAY-scoped entry document (the day scope is already one day). */
779
+ export declare const MATERIALIZED_DINEIN_ENTRY_PAGE_ALL = "all";
780
+ /**
781
+ * Ordered key filters of the dinein report (`COMPLETED:POS_DINE-IN`) — the SAME
782
+ * two dimensions every order-shaped materialized counter document declares. They
783
+ * are the only filters the SUMMARY can apply exactly, because they are the key
784
+ * grammar; origin / table / floor / split / offline are ROW filters and are
785
+ * declared `appliesTo: DETAILS` (a summary request that sends one is REJECTED,
786
+ * never silently answered unfiltered).
787
+ */
788
+ export declare const DINEIN_KEY_FILTERS: MATERIALIZED_REPORT_KEY_FILTER_ENUM[];
789
+ /** Token for a missing key/row dimension. A missing dimension is never dropped. */
790
+ export declare const MATERIALIZED_DINEIN_UNKNOWN_TOKEN = "UNKNOWN";
791
+ /** Key-component separator (`<ORDER_STATUS>:<PLATFORM>`). */
792
+ export declare const MATERIALIZED_DINEIN_KEY_SEPARATOR = ":";
793
+ /**
794
+ * Token of the ONE overflow row every BOUNDED map keeps after its top-N
795
+ * (tables / floors / courses / service-charge rates), so a capped map still
796
+ * reconciles against the document totals instead of silently dropping rows.
797
+ */
798
+ export declare const MATERIALIZED_DINEIN_OTHER_TOKEN = "__OTHER__";
799
+ /** Per-document caps of the bounded maps (ranked `key ASC` after the metric). */
800
+ export declare const MATERIALIZED_DINEIN_TABLE_LIMIT = 200;
801
+ export declare const MATERIALIZED_DINEIN_FLOOR_LIMIT = 50;
802
+ export declare const MATERIALIZED_DINEIN_COURSE_LIMIT = 50;
803
+ export declare const MATERIALIZED_DINEIN_SERVICE_CHARGE_RATE_LIMIT = 50;
804
+ /**
805
+ * Caps of the two BOUNDED SUMMARY SNAPSHOTS.
806
+ *
807
+ * `upcoming_reservations` and `top_edited_checks` are display-only tables, not a
808
+ * second pagination source (the Orders tab always uses the cursor read). The DAY
809
+ * document keeps its own top-N; a PERIOD document re-ranks the union of its day
810
+ * documents' snapshots and keeps top-N again, so a month cannot grow the arrays.
811
+ */
812
+ export declare const MATERIALIZED_DINEIN_UPCOMING_RESERVATION_LIMIT = 10;
813
+ export declare const MATERIALIZED_DINEIN_TOP_EDITED_CHECK_LIMIT = 10;
814
+ /** The 24 hour keys of `by_hour`, initialized to 0 so absence is unambiguously zero. */
815
+ export declare const MATERIALIZED_DINEIN_HOUR_KEYS: string[];
816
+ /**
817
+ * `delete_reason` of a split parent that was auto-deleted by the split flow.
818
+ *
819
+ * The parent still carries the rating/review of the visit but is NOT a
820
+ * collectable check: it never contributes sales or an order count.
821
+ */
822
+ export declare const MATERIALIZED_DINEIN_SPLIT_PARENT_DELETE_REASON = "Auto Deleted on Split";
823
+ /**
824
+ * Where the first version of a check was taken. Derived from the OLDEST
825
+ * iteration (or the current order when it has none) — see
826
+ * `classifyMaterializedDineinOrigin`.
827
+ */
828
+ export declare enum MATERIALIZED_DINEIN_ORIGIN_ENUM {
829
+ /** `POS_DINE-IN` — a terminal the guest ordered at. */
830
+ POS_DIRECT = "POS_DIRECT",
831
+ /** `APP_DINE-IN` / `WEB_DINE-IN` WITH a staff or order-taker — a staff tablet. */
832
+ STAFF_TABLET = "STAFF_TABLET",
833
+ /** `APP_DINE-IN` / `WEB_DINE-IN`, no staff, but a consumer phone — QR self-order. */
834
+ QR_SELF_ORDER = "QR_SELF_ORDER",
835
+ /** Anything else. Never invented into one of the three real origins. */
836
+ UNKNOWN_ORIGIN = "UNKNOWN_ORIGIN"
837
+ }
838
+ export declare const ALL_MATERIALIZED_DINEIN_ORIGINS: MATERIALIZED_DINEIN_ORIGIN_ENUM[];
839
+ /** The role a counted check plays in a split bill. The parent never appears as a row. */
840
+ export declare enum MATERIALIZED_DINEIN_SPLIT_ROLE_ENUM {
841
+ NONE = "NONE",
842
+ CHILD = "CHILD"
843
+ }
844
+ export declare const ALL_MATERIALIZED_DINEIN_SPLIT_ROLES: MATERIALIZED_DINEIN_SPLIT_ROLE_ENUM[];
845
+ /** Payment classification used by `card_amount` / `cash_amount` / `other_amount`. */
846
+ export declare enum MATERIALIZED_DINEIN_PAYMENT_CLASS_ENUM {
847
+ CASH = "CASH",
848
+ CARD = "CARD",
849
+ OTHER = "OTHER"
850
+ }
851
+ export declare const ALL_MATERIALIZED_DINEIN_PAYMENT_CLASSES: MATERIALIZED_DINEIN_PAYMENT_CLASS_ENUM[];
852
+ /**
853
+ * Per-collection BSON budgets (bytes). MongoDB's hard limit is 16 MiB per
854
+ * document; 15 MiB is the owner-approved practical ceiling for the dinein
855
+ * report and each entry page (same as Delivery/Dialer). A writer that exceeds
856
+ * its budget fails at COMPILE/PLAN time with the collection + day + scope in the
857
+ * message — never midway through the close transaction with a server-side
858
+ * "object too large" error.
859
+ */
860
+ export declare const MATERIALIZED_DINEIN_REPORT_MAX_BSON_BYTES: number;
861
+ export declare const MATERIALIZED_DINEIN_ENTRY_MAX_BSON_BYTES: number;
862
+ /**
863
+ * SOURCE-collection indexes the Dinein writer needs, DECLARED ONLY.
864
+ *
865
+ * The services run with `autoIndex: false`; nothing here is applied at runtime.
866
+ * `dinein_tables_fingerprints` is queried by the day's order ids (session join)
867
+ * and by `createdAt` (the table-close event scan); `reservations` is queried by
868
+ * the tenant-local `reservation_time` day. Creating these indexes is an OWNER
869
+ * deploy step (see the operations index plan).
870
+ */
871
+ export declare const MATERIALIZED_DINEIN_FINGERPRINTS_ORDER_INDEX_OPTIONS: {
872
+ key: {
873
+ tenant_id: number;
874
+ order_id: number;
875
+ };
876
+ name: string;
877
+ }[];
878
+ export declare const MATERIALIZED_DINEIN_FINGERPRINTS_CREATED_AT_INDEX_OPTIONS: {
879
+ key: {
880
+ tenant_id: number;
881
+ createdAt: number;
882
+ };
883
+ name: string;
884
+ }[];
885
+ export declare const MATERIALIZED_DINEIN_RESERVATIONS_TIME_INDEX_OPTIONS: {
886
+ key: {
887
+ tenant_id: number;
888
+ reservation_time: number;
889
+ };
890
+ name: string;
891
+ }[];
892
+ /**
893
+ * COMMITTED-READINESS ledger for the SIX reports written by END_TENANT_DAY and
894
+ * the range sync: Overview, Discounts, Prep Time, Delivery, Dialer and Dinein.
739
895
  *
740
896
  * One row per (tenant_id, localDate, report_key, schema_version). The row is
741
897
  * written in the SAME transaction/session as the report documents, so it can
@@ -769,5 +925,74 @@ export declare const ALL_MATERIALIZED_REPORT_READINESS_STATUSES: MATERIALIZED_RE
769
925
  * The ONLY reports that own a readiness row. Adding another report here means
770
926
  * giving it a writer that participates in the same day transaction.
771
927
  */
772
- export declare const MATERIALIZED_READINESS_REPORT_KEYS: readonly ["OVERVIEW", "DISCOUNTS", "PREP_TIME", "DELIVERY", "DIALER"];
928
+ export declare const MATERIALIZED_READINESS_REPORT_KEYS: readonly ["OVERVIEW", "DISCOUNTS", "PREP_TIME", "DELIVERY", "DIALER", "DINEIN"];
773
929
  export type TMaterializedReadinessReportKey = (typeof MATERIALIZED_READINESS_REPORT_KEYS)[number];
930
+ /**
931
+ * DURABLE OPERATIONAL LEDGER of one report's execution, SEPARATE from
932
+ * readiness.
933
+ *
934
+ * Readiness answers "may a historical read treat this tenant-day-report as
935
+ * final?" (only COMMITTED / NEEDS_RECONCILIATION ever appear there).
936
+ * This ledger answers "what happened to the execution?" and is the ONLY place
937
+ * a failed attempt is recorded (PENDING / RUNNING / RETRYING / COMMITTED /
938
+ * FAILED), so a FAILED report never - and can never - look materialized.
939
+ *
940
+ * One row per `(tenant_id, localDate, report_key, schema_version)`. The row is
941
+ * operational state: it is written OUTSIDE the report transaction (a rollback
942
+ * must not erase the fact that the attempt happened). Readiness is written
943
+ * INSIDE the report transaction. The two therefore have different lifecycles
944
+ * and are deliberately different collections.
945
+ *
946
+ * Phase 1 replaces the one all-report END_TENANT_DAY transaction with one
947
+ * transaction per report: each report commits (or fails) on its own, and this
948
+ * ledger is the operator-visible record of that per-report outcome.
949
+ */
950
+ export declare const MATERIALIZED_TENANT_REPORT_RUNS_COLLECTION_NAME = "materialized_tenant_report_runs";
951
+ /** Version of the report-run row shape. Pinned to 1 with the other collections. */
952
+ export declare const MATERIALIZED_TENANT_REPORT_RUNS_SCHEMA_VERSION = 1;
953
+ /** The execution state of one tenant-day-report run. */
954
+ export declare enum MATERIALIZED_TENANT_REPORT_RUN_STATUS_ENUM {
955
+ /** The row exists but no attempt has started yet. */
956
+ PENDING = "PENDING",
957
+ /** An attempt is executing (its own transaction is open or about to open). */
958
+ RUNNING = "RUNNING",
959
+ /** A transient failure happened; another attempt is starting. */
960
+ RETRYING = "RETRYING",
961
+ /** The report transaction committed: documents + readiness are durable. */
962
+ COMMITTED = "COMMITTED",
963
+ /** Every allowed attempt was exhausted; readiness was NOT written. */
964
+ FAILED = "FAILED"
965
+ }
966
+ export declare const ALL_MATERIALIZED_TENANT_REPORT_RUN_STATUSES: MATERIALIZED_TENANT_REPORT_RUN_STATUS_ENUM[];
967
+ /** States in which an execution currently owns the report (retry is refused). */
968
+ export declare const MATERIALIZED_TENANT_REPORT_RUN_IN_FLIGHT_STATUSES: readonly [MATERIALIZED_TENANT_REPORT_RUN_STATUS_ENUM.PENDING, MATERIALIZED_TENANT_REPORT_RUN_STATUS_ENUM.RUNNING, MATERIALIZED_TENANT_REPORT_RUN_STATUS_ENUM.RETRYING];
969
+ /**
970
+ * Bounded attempt budget of ONE report execution (transient errors only).
971
+ * A deterministic code/compile error is NEVER retried inside the job.
972
+ */
973
+ export declare const MATERIALIZED_TENANT_REPORT_RUN_MAX_ATTEMPTS = 2;
974
+ /** Bounded size of the stored `last_error` (single-line, PII-redacted). */
975
+ export declare const MATERIALIZED_TENANT_REPORT_RUN_ERROR_MAX_LENGTH = 500;
976
+ /**
977
+ * Stale window of a report-run row (RUNNING / RETRYING).
978
+ *
979
+ * A run that has not reached a terminal state within this window MAY have been
980
+ * interrupted (process crash). Recovery NEVER trusts the age alone: it also
981
+ * requires the tenant's active-job heartbeat to be stale, so a live long-running
982
+ * report is never taken over. The value mirrors the active-job lease window
983
+ * (30 minutes) so both fences agree.
984
+ */
985
+ export declare const MATERIALIZED_TENANT_REPORT_RUN_STALE_MS: number;
986
+ /**
987
+ * Durable `last_error` of a run recovered after an interruption with NO
988
+ * readiness row (the report transaction provably did not commit).
989
+ */
990
+ export declare const MATERIALIZED_REPORT_RUN_INTERRUPTED_ERROR = "INTERRUPTED_RUN";
991
+ /**
992
+ * Durable `last_error` of a run whose transaction COMMIT outcome is UNKNOWN.
993
+ *
994
+ * Such a run is deliberately left NON-terminal (`RUNNING`): the transaction may
995
+ * have committed. Stale-run recovery settles it from ownership-checked
996
+ * readiness (`readiness.run_id === run.run_id`), never by guessing here.
997
+ */
998
+ export declare const MATERIALIZED_REPORT_RUN_COMMIT_OUTCOME_UNKNOWN_ERROR = "COMMIT_OUTCOME_UNKNOWN";
@@ -12,7 +12,7 @@
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
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_READINESS_REPORT_KEYS = exports.ALL_MATERIALIZED_REPORT_READINESS_STATUSES = exports.MATERIALIZED_REPORT_READINESS_STATUS_ENUM = exports.MATERIALIZED_TENANT_DAY_READINESS_SCHEMA_VERSION = exports.MATERIALIZED_TENANT_DAY_READINESS_COLLECTION_NAME = 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
+ exports.MATERIALIZED_REPORT_RUN_COMMIT_OUTCOME_UNKNOWN_ERROR = exports.MATERIALIZED_REPORT_RUN_INTERRUPTED_ERROR = exports.MATERIALIZED_TENANT_REPORT_RUN_STALE_MS = exports.MATERIALIZED_TENANT_REPORT_RUN_ERROR_MAX_LENGTH = exports.MATERIALIZED_TENANT_REPORT_RUN_MAX_ATTEMPTS = exports.MATERIALIZED_TENANT_REPORT_RUN_IN_FLIGHT_STATUSES = exports.ALL_MATERIALIZED_TENANT_REPORT_RUN_STATUSES = exports.MATERIALIZED_TENANT_REPORT_RUN_STATUS_ENUM = exports.MATERIALIZED_TENANT_REPORT_RUNS_SCHEMA_VERSION = exports.MATERIALIZED_TENANT_REPORT_RUNS_COLLECTION_NAME = exports.MATERIALIZED_READINESS_REPORT_KEYS = exports.ALL_MATERIALIZED_REPORT_READINESS_STATUSES = exports.MATERIALIZED_REPORT_READINESS_STATUS_ENUM = exports.MATERIALIZED_TENANT_DAY_READINESS_SCHEMA_VERSION = exports.MATERIALIZED_TENANT_DAY_READINESS_COLLECTION_NAME = exports.MATERIALIZED_DINEIN_RESERVATIONS_TIME_INDEX_OPTIONS = exports.MATERIALIZED_DINEIN_FINGERPRINTS_CREATED_AT_INDEX_OPTIONS = exports.MATERIALIZED_DINEIN_FINGERPRINTS_ORDER_INDEX_OPTIONS = exports.MATERIALIZED_DINEIN_ENTRY_MAX_BSON_BYTES = exports.MATERIALIZED_DINEIN_REPORT_MAX_BSON_BYTES = exports.ALL_MATERIALIZED_DINEIN_PAYMENT_CLASSES = exports.MATERIALIZED_DINEIN_PAYMENT_CLASS_ENUM = exports.ALL_MATERIALIZED_DINEIN_SPLIT_ROLES = exports.MATERIALIZED_DINEIN_SPLIT_ROLE_ENUM = exports.ALL_MATERIALIZED_DINEIN_ORIGINS = exports.MATERIALIZED_DINEIN_ORIGIN_ENUM = exports.MATERIALIZED_DINEIN_SPLIT_PARENT_DELETE_REASON = exports.MATERIALIZED_DINEIN_HOUR_KEYS = exports.MATERIALIZED_DINEIN_TOP_EDITED_CHECK_LIMIT = exports.MATERIALIZED_DINEIN_UPCOMING_RESERVATION_LIMIT = exports.MATERIALIZED_DINEIN_SERVICE_CHARGE_RATE_LIMIT = exports.MATERIALIZED_DINEIN_COURSE_LIMIT = exports.MATERIALIZED_DINEIN_FLOOR_LIMIT = exports.MATERIALIZED_DINEIN_TABLE_LIMIT = exports.MATERIALIZED_DINEIN_OTHER_TOKEN = exports.MATERIALIZED_DINEIN_KEY_SEPARATOR = exports.MATERIALIZED_DINEIN_UNKNOWN_TOKEN = exports.DINEIN_KEY_FILTERS = exports.MATERIALIZED_DINEIN_ENTRY_PAGE_ALL = exports.MATERIALIZED_DINEIN_ENTRY_SCOPES = exports.MATERIALIZED_DINEIN_REPORT_SCOPES = 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;
16
16
  /**
17
17
  * Time-scope of a materialized report document. Every document covers exactly
18
18
  * one tenant × one scope context × one scope value (`scope_field`), and the
@@ -687,6 +687,8 @@ var MATERIALIZED_REPORT_TYPE_ENUM;
687
687
  MATERIALIZED_REPORT_TYPE_ENUM["TENANT_PAYMENTS_COMPARISON_ENTRIES"] = "TENANT_PAYMENTS_COMPARISON_ENTRIES";
688
688
  MATERIALIZED_REPORT_TYPE_ENUM["TENANT_DIALER_REPORTS"] = "TENANT_DIALER_REPORTS";
689
689
  MATERIALIZED_REPORT_TYPE_ENUM["TENANT_DIALER_ENTRIES"] = "TENANT_DIALER_ENTRIES";
690
+ MATERIALIZED_REPORT_TYPE_ENUM["TENANT_DINEIN_REPORTS"] = "TENANT_DINEIN_REPORTS";
691
+ MATERIALIZED_REPORT_TYPE_ENUM["TENANT_DINEIN_ENTRIES"] = "TENANT_DINEIN_ENTRIES";
690
692
  })(MATERIALIZED_REPORT_TYPE_ENUM || (exports.MATERIALIZED_REPORT_TYPE_ENUM = MATERIALIZED_REPORT_TYPE_ENUM = {}));
691
693
  exports.ALL_MATERIALIZED_REPORT_TYPES = Object.values(MATERIALIZED_REPORT_TYPE_ENUM);
692
694
  /* =====================> Sales Comparison report <===================== */
@@ -904,11 +906,175 @@ exports.MATERIALIZED_DIALER_HOUR_KEYS = Array.from({ length: 24 }, (_, hour) =>
904
906
  exports.MATERIALIZED_DIALER_REPORT_MAX_BSON_BYTES = 15 * 1024 * 1024;
905
907
  exports.MATERIALIZED_DIALER_ENTRY_MAX_BSON_BYTES = 15 * 1024 * 1024;
906
908
  /* ======================================================================== */
907
- /* Day readiness (five production writers) */
909
+ /* Dinein report (M5) */
908
910
  /* ======================================================================== */
909
911
  /**
910
- * COMMITTED-READINESS ledger for the five reports written by END_TENANT_DAY and
911
- * the range sync: Overview, Discounts, Prep Time, Delivery and Dialer.
912
+ * The Dinein report: covers, checks, seated occupancy, courses, split bills,
913
+ * reservations and guest experience for the dine-in population.
914
+ *
915
+ * ## Population
916
+ *
917
+ * `orders` with `dinein_details != null` for the order's OWN `localDate`. The
918
+ * deleted split PARENT is excluded from sales/order counts (the children are the
919
+ * collectable checks) and is read only for rating/review discovery.
920
+ *
921
+ * ## Two collections, one report
922
+ *
923
+ * `materialized_tenant_dinein_reports` is COUNTERS ONLY, keyed by
924
+ * `<ORDER_STATUS>:<PLATFORM>` (`sale_type_key_filters`); the reservation block is
925
+ * day-level because a reservation has no order and must never be dropped by an
926
+ * order-status/platform filter. `materialized_tenant_dinein_entries` holds ONE
927
+ * PAGE per source day (the discounts/delivery/dialer page model).
928
+ */
929
+ /**
930
+ * The two collections are named/versioned by their model modules
931
+ * (`materialized_tenant_dinein_reports` / `..._entries`), exactly like the other
932
+ * materialized report collections.
933
+ */
934
+ /**
935
+ * Scopes materialized by `materialized_tenant_dinein_reports`.
936
+ *
937
+ * NO `localHour`: the hour dimension is the `by_hour` map inside the document
938
+ * (the sales/covers-by-hour chart), exactly like Delivery. `localDate` is the day
939
+ * the ORDER was sold on (`order.localDate`), never the fingerprint's creation
940
+ * day: a table can close after midnight and still belong to the day it was sold.
941
+ */
942
+ exports.MATERIALIZED_DINEIN_REPORT_SCOPES = [
943
+ MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_DATE,
944
+ MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_WEEK,
945
+ MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_WEEK_OF_YEAR,
946
+ MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_MONTH,
947
+ MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_QUARTER,
948
+ MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_SEMESTER,
949
+ MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_YEAR,
950
+ ];
951
+ /**
952
+ * Entry scopes. A PERIOD entry document is PAGE-PARTITIONED by source day
953
+ * (`page = <source localDate>`) so a document is bounded by ONE day's checks; a
954
+ * month is covered by its 28-31 pages. There is no quarter/semester/year entry
955
+ * document, and a broad details selection is served from the month pages it
956
+ * touches (never refused).
957
+ */
958
+ exports.MATERIALIZED_DINEIN_ENTRY_SCOPES = [
959
+ MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_DATE,
960
+ MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_WEEK,
961
+ MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_WEEK_OF_YEAR,
962
+ MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_MONTH,
963
+ ];
964
+ /** Page key of the DAY-scoped entry document (the day scope is already one day). */
965
+ exports.MATERIALIZED_DINEIN_ENTRY_PAGE_ALL = 'all';
966
+ /**
967
+ * Ordered key filters of the dinein report (`COMPLETED:POS_DINE-IN`) — the SAME
968
+ * two dimensions every order-shaped materialized counter document declares. They
969
+ * are the only filters the SUMMARY can apply exactly, because they are the key
970
+ * grammar; origin / table / floor / split / offline are ROW filters and are
971
+ * declared `appliesTo: DETAILS` (a summary request that sends one is REJECTED,
972
+ * never silently answered unfiltered).
973
+ */
974
+ exports.DINEIN_KEY_FILTERS = [
975
+ MATERIALIZED_REPORT_KEY_FILTER_ENUM.ORDER_STATUS,
976
+ MATERIALIZED_REPORT_KEY_FILTER_ENUM.PLATFORM,
977
+ ];
978
+ /** Token for a missing key/row dimension. A missing dimension is never dropped. */
979
+ exports.MATERIALIZED_DINEIN_UNKNOWN_TOKEN = 'UNKNOWN';
980
+ /** Key-component separator (`<ORDER_STATUS>:<PLATFORM>`). */
981
+ exports.MATERIALIZED_DINEIN_KEY_SEPARATOR = ':';
982
+ /**
983
+ * Token of the ONE overflow row every BOUNDED map keeps after its top-N
984
+ * (tables / floors / courses / service-charge rates), so a capped map still
985
+ * reconciles against the document totals instead of silently dropping rows.
986
+ */
987
+ exports.MATERIALIZED_DINEIN_OTHER_TOKEN = '__OTHER__';
988
+ /** Per-document caps of the bounded maps (ranked `key ASC` after the metric). */
989
+ exports.MATERIALIZED_DINEIN_TABLE_LIMIT = 200;
990
+ exports.MATERIALIZED_DINEIN_FLOOR_LIMIT = 50;
991
+ exports.MATERIALIZED_DINEIN_COURSE_LIMIT = 50;
992
+ exports.MATERIALIZED_DINEIN_SERVICE_CHARGE_RATE_LIMIT = 50;
993
+ /**
994
+ * Caps of the two BOUNDED SUMMARY SNAPSHOTS.
995
+ *
996
+ * `upcoming_reservations` and `top_edited_checks` are display-only tables, not a
997
+ * second pagination source (the Orders tab always uses the cursor read). The DAY
998
+ * document keeps its own top-N; a PERIOD document re-ranks the union of its day
999
+ * documents' snapshots and keeps top-N again, so a month cannot grow the arrays.
1000
+ */
1001
+ exports.MATERIALIZED_DINEIN_UPCOMING_RESERVATION_LIMIT = 10;
1002
+ exports.MATERIALIZED_DINEIN_TOP_EDITED_CHECK_LIMIT = 10;
1003
+ /** The 24 hour keys of `by_hour`, initialized to 0 so absence is unambiguously zero. */
1004
+ exports.MATERIALIZED_DINEIN_HOUR_KEYS = Array.from({ length: 24 }, (_, hour) => String(hour));
1005
+ /**
1006
+ * `delete_reason` of a split parent that was auto-deleted by the split flow.
1007
+ *
1008
+ * The parent still carries the rating/review of the visit but is NOT a
1009
+ * collectable check: it never contributes sales or an order count.
1010
+ */
1011
+ exports.MATERIALIZED_DINEIN_SPLIT_PARENT_DELETE_REASON = 'Auto Deleted on Split';
1012
+ /**
1013
+ * Where the first version of a check was taken. Derived from the OLDEST
1014
+ * iteration (or the current order when it has none) — see
1015
+ * `classifyMaterializedDineinOrigin`.
1016
+ */
1017
+ var MATERIALIZED_DINEIN_ORIGIN_ENUM;
1018
+ (function (MATERIALIZED_DINEIN_ORIGIN_ENUM) {
1019
+ /** `POS_DINE-IN` — a terminal the guest ordered at. */
1020
+ MATERIALIZED_DINEIN_ORIGIN_ENUM["POS_DIRECT"] = "POS_DIRECT";
1021
+ /** `APP_DINE-IN` / `WEB_DINE-IN` WITH a staff or order-taker — a staff tablet. */
1022
+ MATERIALIZED_DINEIN_ORIGIN_ENUM["STAFF_TABLET"] = "STAFF_TABLET";
1023
+ /** `APP_DINE-IN` / `WEB_DINE-IN`, no staff, but a consumer phone — QR self-order. */
1024
+ MATERIALIZED_DINEIN_ORIGIN_ENUM["QR_SELF_ORDER"] = "QR_SELF_ORDER";
1025
+ /** Anything else. Never invented into one of the three real origins. */
1026
+ MATERIALIZED_DINEIN_ORIGIN_ENUM["UNKNOWN_ORIGIN"] = "UNKNOWN_ORIGIN";
1027
+ })(MATERIALIZED_DINEIN_ORIGIN_ENUM || (exports.MATERIALIZED_DINEIN_ORIGIN_ENUM = MATERIALIZED_DINEIN_ORIGIN_ENUM = {}));
1028
+ exports.ALL_MATERIALIZED_DINEIN_ORIGINS = Object.values(MATERIALIZED_DINEIN_ORIGIN_ENUM);
1029
+ /** The role a counted check plays in a split bill. The parent never appears as a row. */
1030
+ var MATERIALIZED_DINEIN_SPLIT_ROLE_ENUM;
1031
+ (function (MATERIALIZED_DINEIN_SPLIT_ROLE_ENUM) {
1032
+ MATERIALIZED_DINEIN_SPLIT_ROLE_ENUM["NONE"] = "NONE";
1033
+ MATERIALIZED_DINEIN_SPLIT_ROLE_ENUM["CHILD"] = "CHILD";
1034
+ })(MATERIALIZED_DINEIN_SPLIT_ROLE_ENUM || (exports.MATERIALIZED_DINEIN_SPLIT_ROLE_ENUM = MATERIALIZED_DINEIN_SPLIT_ROLE_ENUM = {}));
1035
+ exports.ALL_MATERIALIZED_DINEIN_SPLIT_ROLES = Object.values(MATERIALIZED_DINEIN_SPLIT_ROLE_ENUM);
1036
+ /** Payment classification used by `card_amount` / `cash_amount` / `other_amount`. */
1037
+ var MATERIALIZED_DINEIN_PAYMENT_CLASS_ENUM;
1038
+ (function (MATERIALIZED_DINEIN_PAYMENT_CLASS_ENUM) {
1039
+ MATERIALIZED_DINEIN_PAYMENT_CLASS_ENUM["CASH"] = "CASH";
1040
+ MATERIALIZED_DINEIN_PAYMENT_CLASS_ENUM["CARD"] = "CARD";
1041
+ MATERIALIZED_DINEIN_PAYMENT_CLASS_ENUM["OTHER"] = "OTHER";
1042
+ })(MATERIALIZED_DINEIN_PAYMENT_CLASS_ENUM || (exports.MATERIALIZED_DINEIN_PAYMENT_CLASS_ENUM = MATERIALIZED_DINEIN_PAYMENT_CLASS_ENUM = {}));
1043
+ exports.ALL_MATERIALIZED_DINEIN_PAYMENT_CLASSES = Object.values(MATERIALIZED_DINEIN_PAYMENT_CLASS_ENUM);
1044
+ /**
1045
+ * Per-collection BSON budgets (bytes). MongoDB's hard limit is 16 MiB per
1046
+ * document; 15 MiB is the owner-approved practical ceiling for the dinein
1047
+ * report and each entry page (same as Delivery/Dialer). A writer that exceeds
1048
+ * its budget fails at COMPILE/PLAN time with the collection + day + scope in the
1049
+ * message — never midway through the close transaction with a server-side
1050
+ * "object too large" error.
1051
+ */
1052
+ exports.MATERIALIZED_DINEIN_REPORT_MAX_BSON_BYTES = 15 * 1024 * 1024;
1053
+ exports.MATERIALIZED_DINEIN_ENTRY_MAX_BSON_BYTES = 15 * 1024 * 1024;
1054
+ /**
1055
+ * SOURCE-collection indexes the Dinein writer needs, DECLARED ONLY.
1056
+ *
1057
+ * The services run with `autoIndex: false`; nothing here is applied at runtime.
1058
+ * `dinein_tables_fingerprints` is queried by the day's order ids (session join)
1059
+ * and by `createdAt` (the table-close event scan); `reservations` is queried by
1060
+ * the tenant-local `reservation_time` day. Creating these indexes is an OWNER
1061
+ * deploy step (see the operations index plan).
1062
+ */
1063
+ exports.MATERIALIZED_DINEIN_FINGERPRINTS_ORDER_INDEX_OPTIONS = [
1064
+ { key: { tenant_id: 1, order_id: 1 }, name: 'tenant_id__order_id' },
1065
+ ];
1066
+ exports.MATERIALIZED_DINEIN_FINGERPRINTS_CREATED_AT_INDEX_OPTIONS = [
1067
+ { key: { tenant_id: 1, createdAt: -1 }, name: 'tenant_id__createdAt' },
1068
+ ];
1069
+ exports.MATERIALIZED_DINEIN_RESERVATIONS_TIME_INDEX_OPTIONS = [
1070
+ { key: { tenant_id: 1, reservation_time: 1 }, name: 'tenant_id__reservation_time' },
1071
+ ];
1072
+ /* ======================================================================== */
1073
+ /* Day readiness (six production writers) */
1074
+ /* ======================================================================== */
1075
+ /**
1076
+ * COMMITTED-READINESS ledger for the SIX reports written by END_TENANT_DAY and
1077
+ * the range sync: Overview, Discounts, Prep Time, Delivery, Dialer and Dinein.
912
1078
  *
913
1079
  * One row per (tenant_id, localDate, report_key, schema_version). The row is
914
1080
  * written in the SAME transaction/session as the report documents, so it can
@@ -943,4 +1109,88 @@ exports.ALL_MATERIALIZED_REPORT_READINESS_STATUSES = Object.values(MATERIALIZED_
943
1109
  * The ONLY reports that own a readiness row. Adding another report here means
944
1110
  * giving it a writer that participates in the same day transaction.
945
1111
  */
946
- exports.MATERIALIZED_READINESS_REPORT_KEYS = ['OVERVIEW', 'DISCOUNTS', 'PREP_TIME', 'DELIVERY', 'DIALER'];
1112
+ exports.MATERIALIZED_READINESS_REPORT_KEYS = [
1113
+ 'OVERVIEW',
1114
+ 'DISCOUNTS',
1115
+ 'PREP_TIME',
1116
+ 'DELIVERY',
1117
+ 'DIALER',
1118
+ 'DINEIN',
1119
+ ];
1120
+ /* ======================================================================== */
1121
+ /* Report run ledger (ONE row per report execution) */
1122
+ /* ======================================================================== */
1123
+ /**
1124
+ * DURABLE OPERATIONAL LEDGER of one report's execution, SEPARATE from
1125
+ * readiness.
1126
+ *
1127
+ * Readiness answers "may a historical read treat this tenant-day-report as
1128
+ * final?" (only COMMITTED / NEEDS_RECONCILIATION ever appear there).
1129
+ * This ledger answers "what happened to the execution?" and is the ONLY place
1130
+ * a failed attempt is recorded (PENDING / RUNNING / RETRYING / COMMITTED /
1131
+ * FAILED), so a FAILED report never - and can never - look materialized.
1132
+ *
1133
+ * One row per `(tenant_id, localDate, report_key, schema_version)`. The row is
1134
+ * operational state: it is written OUTSIDE the report transaction (a rollback
1135
+ * must not erase the fact that the attempt happened). Readiness is written
1136
+ * INSIDE the report transaction. The two therefore have different lifecycles
1137
+ * and are deliberately different collections.
1138
+ *
1139
+ * Phase 1 replaces the one all-report END_TENANT_DAY transaction with one
1140
+ * transaction per report: each report commits (or fails) on its own, and this
1141
+ * ledger is the operator-visible record of that per-report outcome.
1142
+ */
1143
+ exports.MATERIALIZED_TENANT_REPORT_RUNS_COLLECTION_NAME = 'materialized_tenant_report_runs';
1144
+ /** Version of the report-run row shape. Pinned to 1 with the other collections. */
1145
+ exports.MATERIALIZED_TENANT_REPORT_RUNS_SCHEMA_VERSION = 1;
1146
+ /** The execution state of one tenant-day-report run. */
1147
+ var MATERIALIZED_TENANT_REPORT_RUN_STATUS_ENUM;
1148
+ (function (MATERIALIZED_TENANT_REPORT_RUN_STATUS_ENUM) {
1149
+ /** The row exists but no attempt has started yet. */
1150
+ MATERIALIZED_TENANT_REPORT_RUN_STATUS_ENUM["PENDING"] = "PENDING";
1151
+ /** An attempt is executing (its own transaction is open or about to open). */
1152
+ MATERIALIZED_TENANT_REPORT_RUN_STATUS_ENUM["RUNNING"] = "RUNNING";
1153
+ /** A transient failure happened; another attempt is starting. */
1154
+ MATERIALIZED_TENANT_REPORT_RUN_STATUS_ENUM["RETRYING"] = "RETRYING";
1155
+ /** The report transaction committed: documents + readiness are durable. */
1156
+ MATERIALIZED_TENANT_REPORT_RUN_STATUS_ENUM["COMMITTED"] = "COMMITTED";
1157
+ /** Every allowed attempt was exhausted; readiness was NOT written. */
1158
+ MATERIALIZED_TENANT_REPORT_RUN_STATUS_ENUM["FAILED"] = "FAILED";
1159
+ })(MATERIALIZED_TENANT_REPORT_RUN_STATUS_ENUM || (exports.MATERIALIZED_TENANT_REPORT_RUN_STATUS_ENUM = MATERIALIZED_TENANT_REPORT_RUN_STATUS_ENUM = {}));
1160
+ exports.ALL_MATERIALIZED_TENANT_REPORT_RUN_STATUSES = Object.values(MATERIALIZED_TENANT_REPORT_RUN_STATUS_ENUM);
1161
+ /** States in which an execution currently owns the report (retry is refused). */
1162
+ exports.MATERIALIZED_TENANT_REPORT_RUN_IN_FLIGHT_STATUSES = [
1163
+ MATERIALIZED_TENANT_REPORT_RUN_STATUS_ENUM.PENDING,
1164
+ MATERIALIZED_TENANT_REPORT_RUN_STATUS_ENUM.RUNNING,
1165
+ MATERIALIZED_TENANT_REPORT_RUN_STATUS_ENUM.RETRYING,
1166
+ ];
1167
+ /**
1168
+ * Bounded attempt budget of ONE report execution (transient errors only).
1169
+ * A deterministic code/compile error is NEVER retried inside the job.
1170
+ */
1171
+ exports.MATERIALIZED_TENANT_REPORT_RUN_MAX_ATTEMPTS = 2;
1172
+ /** Bounded size of the stored `last_error` (single-line, PII-redacted). */
1173
+ exports.MATERIALIZED_TENANT_REPORT_RUN_ERROR_MAX_LENGTH = 500;
1174
+ /**
1175
+ * Stale window of a report-run row (RUNNING / RETRYING).
1176
+ *
1177
+ * A run that has not reached a terminal state within this window MAY have been
1178
+ * interrupted (process crash). Recovery NEVER trusts the age alone: it also
1179
+ * requires the tenant's active-job heartbeat to be stale, so a live long-running
1180
+ * report is never taken over. The value mirrors the active-job lease window
1181
+ * (30 minutes) so both fences agree.
1182
+ */
1183
+ exports.MATERIALIZED_TENANT_REPORT_RUN_STALE_MS = 30 * 60 * 1000;
1184
+ /**
1185
+ * Durable `last_error` of a run recovered after an interruption with NO
1186
+ * readiness row (the report transaction provably did not commit).
1187
+ */
1188
+ exports.MATERIALIZED_REPORT_RUN_INTERRUPTED_ERROR = 'INTERRUPTED_RUN';
1189
+ /**
1190
+ * Durable `last_error` of a run whose transaction COMMIT outcome is UNKNOWN.
1191
+ *
1192
+ * Such a run is deliberately left NON-terminal (`RUNNING`): the transaction may
1193
+ * have committed. Stale-run recovery settles it from ownership-checked
1194
+ * readiness (`readiness.run_id === run.run_id`), never by guessing here.
1195
+ */
1196
+ exports.MATERIALIZED_REPORT_RUN_COMMIT_OUTCOME_UNKNOWN_ERROR = 'COMMIT_OUTCOME_UNKNOWN';
@@ -78,3 +78,17 @@ export declare enum TENANT_ACTIVE_JOBS_ENUM {
78
78
  Z_REPORT = "Z_REPORT"
79
79
  }
80
80
  export declare const ALL_TENANT_ACTIVE_JOBS_NAMES: TENANT_ACTIVE_JOBS_ENUM[];
81
+ /**
82
+ * Terminal outcome of ONE close/retry run that owned the tenant's CALENDAR job.
83
+ *
84
+ * `PARTIAL` is the per-report model's outcome: at least one report FAILED while
85
+ * others committed. It is NEVER a readiness status - readiness keeps only
86
+ * COMMITTED / NEEDS_RECONCILIATION; the failed report lives in the operational
87
+ * run ledger (`materialized_tenant_report_runs`).
88
+ */
89
+ export declare enum TENANT_DAY_JOB_OUTCOME_ENUM {
90
+ COMPLETED = "COMPLETED",
91
+ PARTIAL = "PARTIAL",
92
+ FAILED = "FAILED"
93
+ }
94
+ export declare const ALL_TENANT_DAY_JOB_OUTCOMES: TENANT_DAY_JOB_OUTCOME_ENUM[];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ALL_TENANT_ACTIVE_JOBS_NAMES = exports.TENANT_ACTIVE_JOBS_ENUM = exports.ALL_TENANT_ACTIVITY_LOG_SEVERITY_NAMES = exports.TENANT_ACTIVITY_LOG_SEVERITY_ENUM = exports.ALL_TENANT_ACTIVITY_LOG_ACTION_NAMES = exports.TENANT_ACTIVITY_LOG_ACTION_ENUM = exports.ALL_TENANT_ACTIVITY_LOG_ENTITY_TYPE_NAMES = exports.TENANT_ACTIVITY_LOG_ENTITY_TYPE_ENUM = exports.ALL_TENANT_PURCHASE_ORDER_VENDOR_RETURN_STATUS_NAMES = exports.TENANT_PURCHASE_ORDER_VENDOR_RETURN_STATUS_ENUM = exports.ALL_TENANT_PURCHASE_ORDER_STATUS_NAMES = exports.TENANT_PURCHASE_ORDER_STATUS_ENUM = void 0;
3
+ exports.ALL_TENANT_DAY_JOB_OUTCOMES = exports.TENANT_DAY_JOB_OUTCOME_ENUM = exports.ALL_TENANT_ACTIVE_JOBS_NAMES = exports.TENANT_ACTIVE_JOBS_ENUM = exports.ALL_TENANT_ACTIVITY_LOG_SEVERITY_NAMES = exports.TENANT_ACTIVITY_LOG_SEVERITY_ENUM = exports.ALL_TENANT_ACTIVITY_LOG_ACTION_NAMES = exports.TENANT_ACTIVITY_LOG_ACTION_ENUM = exports.ALL_TENANT_ACTIVITY_LOG_ENTITY_TYPE_NAMES = exports.TENANT_ACTIVITY_LOG_ENTITY_TYPE_ENUM = exports.ALL_TENANT_PURCHASE_ORDER_VENDOR_RETURN_STATUS_NAMES = exports.TENANT_PURCHASE_ORDER_VENDOR_RETURN_STATUS_ENUM = exports.ALL_TENANT_PURCHASE_ORDER_STATUS_NAMES = exports.TENANT_PURCHASE_ORDER_STATUS_ENUM = void 0;
4
4
  // ======================>> TENANT PURCHASE ORDER <<====================== //
5
5
  var TENANT_PURCHASE_ORDER_STATUS_ENUM;
6
6
  (function (TENANT_PURCHASE_ORDER_STATUS_ENUM) {
@@ -91,3 +91,18 @@ var TENANT_ACTIVE_JOBS_ENUM;
91
91
  TENANT_ACTIVE_JOBS_ENUM["Z_REPORT"] = "Z_REPORT";
92
92
  })(TENANT_ACTIVE_JOBS_ENUM || (exports.TENANT_ACTIVE_JOBS_ENUM = TENANT_ACTIVE_JOBS_ENUM = {}));
93
93
  exports.ALL_TENANT_ACTIVE_JOBS_NAMES = Object.values(TENANT_ACTIVE_JOBS_ENUM);
94
+ /**
95
+ * Terminal outcome of ONE close/retry run that owned the tenant's CALENDAR job.
96
+ *
97
+ * `PARTIAL` is the per-report model's outcome: at least one report FAILED while
98
+ * others committed. It is NEVER a readiness status - readiness keeps only
99
+ * COMMITTED / NEEDS_RECONCILIATION; the failed report lives in the operational
100
+ * run ledger (`materialized_tenant_report_runs`).
101
+ */
102
+ var TENANT_DAY_JOB_OUTCOME_ENUM;
103
+ (function (TENANT_DAY_JOB_OUTCOME_ENUM) {
104
+ TENANT_DAY_JOB_OUTCOME_ENUM["COMPLETED"] = "COMPLETED";
105
+ TENANT_DAY_JOB_OUTCOME_ENUM["PARTIAL"] = "PARTIAL";
106
+ TENANT_DAY_JOB_OUTCOME_ENUM["FAILED"] = "FAILED";
107
+ })(TENANT_DAY_JOB_OUTCOME_ENUM || (exports.TENANT_DAY_JOB_OUTCOME_ENUM = TENANT_DAY_JOB_OUTCOME_ENUM = {}));
108
+ exports.ALL_TENANT_DAY_JOB_OUTCOMES = Object.values(TENANT_DAY_JOB_OUTCOME_ENUM);
@@ -65,4 +65,16 @@ export declare const WORKER_ENDPOINTS: {
65
65
  readonly POST_WAREHOUSE_ACTIVITY_LOGS: "/post-warehouse-activity-logs";
66
66
  readonly END_INSTORE_SHIFT: "/end-instore-shift";
67
67
  readonly END_TENANT_DAY: "/end-tenant-day";
68
+ /**
69
+ * INTERNAL, report-scoped retry of ONE failed END_TENANT_DAY report.
70
+ * Operations-service is the only caller (POST /materialization/reports/retry).
71
+ * Never a whole-day retry.
72
+ */
73
+ readonly RETRY_MATERIALIZED_REPORT: "/internal/materialization/reports/retry";
74
+ /**
75
+ * INTERNAL, worker-owned recovery of INTERRUPTED report runs (RUNNING /
76
+ * RETRYING). Called before the retry API rejects a RUNNING report and before
77
+ * listing runs for the admin page. Never fabricates readiness.
78
+ */
79
+ readonly RECONCILE_MATERIALIZED_REPORT_RUNS: "/internal/materialization/reports/reconcile";
68
80
  };
@@ -80,4 +80,16 @@ exports.WORKER_ENDPOINTS = {
80
80
  // ========================>> Shift / Business Day / Cash Drawer (compile) <<======================= //
81
81
  END_INSTORE_SHIFT: '/end-instore-shift',
82
82
  END_TENANT_DAY: '/end-tenant-day',
83
+ /**
84
+ * INTERNAL, report-scoped retry of ONE failed END_TENANT_DAY report.
85
+ * Operations-service is the only caller (POST /materialization/reports/retry).
86
+ * Never a whole-day retry.
87
+ */
88
+ RETRY_MATERIALIZED_REPORT: '/internal/materialization/reports/retry',
89
+ /**
90
+ * INTERNAL, worker-owned recovery of INTERRUPTED report runs (RUNNING /
91
+ * RETRYING). Called before the retry API rejects a RUNNING report and before
92
+ * listing runs for the admin page. Never fabricates readiness.
93
+ */
94
+ RECONCILE_MATERIALIZED_REPORT_RUNS: '/internal/materialization/reports/reconcile',
83
95
  };