@managesome/eposmatic-toolkit 0.4.53 → 0.4.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/helpers/materialized-reports/index.js +1 -0
- package/esm/helpers/materialized-reports/report-platform/definition.js +508 -0
- package/esm/helpers/materialized-reports/report-platform/index.js +4 -0
- package/esm/helpers/materialized-reports/report-platform/lifecycle/budget.js +27 -0
- package/esm/helpers/materialized-reports/report-platform/lifecycle/cap-metadata.js +12 -0
- package/esm/helpers/materialized-reports/report-platform/lifecycle/entry-pages.js +121 -0
- package/esm/helpers/materialized-reports/report-platform/lifecycle/flat-projection.js +14 -0
- package/esm/helpers/materialized-reports/report-platform/lifecycle/index.js +8 -0
- package/esm/helpers/materialized-reports/report-platform/lifecycle/iteration-row.js +10 -0
- package/esm/helpers/materialized-reports/report-platform/lifecycle/run-stats.js +42 -0
- package/esm/helpers/materialized-reports/report-platform/lifecycle/scope-refs.js +28 -0
- package/esm/helpers/materialized-reports/report-platform/lifecycle/top-n.js +24 -0
- package/esm/helpers/materialized-reports/report-platform/registry.js +23 -0
- package/esm/helpers/materialized-reports/report-platform/validate-report-registry.js +214 -0
- package/lib/helpers/materialized-reports/index.d.ts +1 -0
- package/lib/helpers/materialized-reports/index.js +1 -0
- package/lib/helpers/materialized-reports/report-platform/definition.d.ts +133 -0
- package/lib/helpers/materialized-reports/report-platform/definition.js +511 -0
- package/lib/helpers/materialized-reports/report-platform/index.d.ts +4 -0
- package/lib/helpers/materialized-reports/report-platform/index.js +20 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/budget.d.ts +8 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/budget.js +31 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/cap-metadata.d.ts +8 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/cap-metadata.js +16 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/entry-pages.d.ts +40 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/entry-pages.js +130 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/flat-projection.d.ts +22 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/flat-projection.js +17 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/index.d.ts +8 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/index.js +24 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/iteration-row.d.ts +13 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/iteration-row.js +13 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/run-stats.d.ts +20 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/run-stats.js +47 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/scope-refs.d.ts +13 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/scope-refs.js +31 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/top-n.d.ts +16 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/top-n.js +29 -0
- package/lib/helpers/materialized-reports/report-platform/registry.d.ts +13 -0
- package/lib/helpers/materialized-reports/report-platform/registry.js +31 -0
- package/lib/helpers/materialized-reports/report-platform/validate-report-registry.d.ts +20 -0
- package/lib/helpers/materialized-reports/report-platform/validate-report-registry.js +218 -0
- package/lib/tests/materialized-reports/characterization/delivery.characterization.test.d.ts +1 -0
- package/lib/tests/materialized-reports/characterization/delivery.characterization.test.js +229 -0
- package/lib/tests/materialized-reports/characterization/discount.characterization.test.d.ts +1 -0
- package/lib/tests/materialized-reports/characterization/discount.characterization.test.js +99 -0
- package/lib/tests/materialized-reports/characterization/fixtures.d.ts +30 -0
- package/lib/tests/materialized-reports/characterization/fixtures.js +402 -0
- package/lib/tests/materialized-reports/characterization/golden.d.ts +18 -0
- package/lib/tests/materialized-reports/characterization/golden.js +127 -0
- package/lib/tests/materialized-reports/characterization/overview.characterization.test.d.ts +1 -0
- package/lib/tests/materialized-reports/characterization/overview.characterization.test.js +69 -0
- package/lib/tests/materialized-reports/characterization/prep-time.characterization.test.d.ts +1 -0
- package/lib/tests/materialized-reports/characterization/prep-time.characterization.test.js +102 -0
- package/lib/tests/materialized-reports/report-platform/lifecycle-primitives.test.d.ts +1 -0
- package/lib/tests/materialized-reports/report-platform/lifecycle-primitives.test.js +177 -0
- package/lib/tests/materialized-reports/report-platform/registry-conformance.test.d.ts +1 -0
- package/lib/tests/materialized-reports/report-platform/registry-conformance.test.js +214 -0
- package/lib/tests/materialized-reports/report-platform/registry-validation.test.d.ts +1 -0
- package/lib/tests/materialized-reports/report-platform/registry-validation.test.js +103 -0
- package/package.json +4 -2
|
@@ -0,0 +1,511 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.REPORT_REGISTRY_EXEMPTIONS = exports.PRODUCTION_REPORT_DEFINITIONS = exports.REPORT_DEFINITIONS = exports.REPORT_RETENTION_UNIT = exports.REPORT_PROJECTION = exports.REPORT_CURSOR_KIND = exports.REPORT_HISTORICAL_LENS = exports.REPORT_LIVE_SOURCE = exports.REPORT_WRITE_GUARD = exports.REPORT_ENTRY_SPLIT = exports.REPORT_ENTRY_STORAGE = exports.REPORT_DEFINITION_STATUS = void 0;
|
|
4
|
+
const MATERIALIZED_REPORTS_1 = require("../../../constants/MATERIALIZED_REPORTS");
|
|
5
|
+
const report_contract_1 = require("../../reporting-contract/report-contract");
|
|
6
|
+
/**
|
|
7
|
+
* PHASE 2 — DECLARATIVE REPORT DEFINITIONS.
|
|
8
|
+
*
|
|
9
|
+
* This module is METADATA ONLY. It must not import Mongoose, Express, database
|
|
10
|
+
* code, workers-service or operations-service. Metric compilation, document
|
|
11
|
+
* schemas and formatters stay report-specific.
|
|
12
|
+
*
|
|
13
|
+
* Schema versions are declared as literals here so this module stays free of
|
|
14
|
+
* schema/model imports. The conformance suite compares every literal with the
|
|
15
|
+
* exported model constant; drift fails the build.
|
|
16
|
+
*/
|
|
17
|
+
var REPORT_DEFINITION_STATUS;
|
|
18
|
+
(function (REPORT_DEFINITION_STATUS) {
|
|
19
|
+
REPORT_DEFINITION_STATUS["PRODUCTION"] = "PRODUCTION";
|
|
20
|
+
REPORT_DEFINITION_STATUS["READ_ONLY"] = "READ_ONLY";
|
|
21
|
+
REPORT_DEFINITION_STATUS["PLANNED"] = "PLANNED";
|
|
22
|
+
})(REPORT_DEFINITION_STATUS || (exports.REPORT_DEFINITION_STATUS = REPORT_DEFINITION_STATUS = {}));
|
|
23
|
+
var REPORT_ENTRY_STORAGE;
|
|
24
|
+
(function (REPORT_ENTRY_STORAGE) {
|
|
25
|
+
/** No itemized collection. */
|
|
26
|
+
REPORT_ENTRY_STORAGE["NONE"] = "NONE";
|
|
27
|
+
/** One entry document per (tenant, scope, field); Prep Time today. */
|
|
28
|
+
REPORT_ENTRY_STORAGE["ONE_PER_SCOPE"] = "ONE_PER_SCOPE";
|
|
29
|
+
/** One entry document per source day; Discounts and Delivery today. */
|
|
30
|
+
REPORT_ENTRY_STORAGE["PAGE_PER_SOURCE_DAY"] = "PAGE_PER_SOURCE_DAY";
|
|
31
|
+
})(REPORT_ENTRY_STORAGE || (exports.REPORT_ENTRY_STORAGE = REPORT_ENTRY_STORAGE = {}));
|
|
32
|
+
var REPORT_ENTRY_SPLIT;
|
|
33
|
+
(function (REPORT_ENTRY_SPLIT) {
|
|
34
|
+
REPORT_ENTRY_SPLIT["NONE"] = "NONE";
|
|
35
|
+
/** Deterministic `page#0`, `page#1`, ... when one page exceeds its budget. */
|
|
36
|
+
REPORT_ENTRY_SPLIT["DETERMINISTIC_SUBPAGES"] = "DETERMINISTIC_SUBPAGES";
|
|
37
|
+
})(REPORT_ENTRY_SPLIT || (exports.REPORT_ENTRY_SPLIT = REPORT_ENTRY_SPLIT = {}));
|
|
38
|
+
var REPORT_WRITE_GUARD;
|
|
39
|
+
(function (REPORT_WRITE_GUARD) {
|
|
40
|
+
REPORT_WRITE_GUARD["NONE"] = "NONE";
|
|
41
|
+
REPORT_WRITE_GUARD["WATERMARK"] = "WATERMARK";
|
|
42
|
+
REPORT_WRITE_GUARD["WATERMARK_AND_DIGEST"] = "WATERMARK_AND_DIGEST";
|
|
43
|
+
})(REPORT_WRITE_GUARD || (exports.REPORT_WRITE_GUARD = REPORT_WRITE_GUARD = {}));
|
|
44
|
+
var REPORT_LIVE_SOURCE;
|
|
45
|
+
(function (REPORT_LIVE_SOURCE) {
|
|
46
|
+
REPORT_LIVE_SOURCE["RAW"] = "RAW";
|
|
47
|
+
REPORT_LIVE_SOURCE["RAW_PLUS_MATERIALIZED"] = "RAW_PLUS_MATERIALIZED";
|
|
48
|
+
})(REPORT_LIVE_SOURCE || (exports.REPORT_LIVE_SOURCE = REPORT_LIVE_SOURCE = {}));
|
|
49
|
+
var REPORT_HISTORICAL_LENS;
|
|
50
|
+
(function (REPORT_HISTORICAL_LENS) {
|
|
51
|
+
REPORT_HISTORICAL_LENS["DOCUMENT_FOLD"] = "DOCUMENT_FOLD";
|
|
52
|
+
REPORT_HISTORICAL_LENS["COUNTER_ROWS"] = "COUNTER_ROWS";
|
|
53
|
+
})(REPORT_HISTORICAL_LENS || (exports.REPORT_HISTORICAL_LENS = REPORT_HISTORICAL_LENS = {}));
|
|
54
|
+
var REPORT_CURSOR_KIND;
|
|
55
|
+
(function (REPORT_CURSOR_KIND) {
|
|
56
|
+
REPORT_CURSOR_KIND["NONE"] = "NONE";
|
|
57
|
+
REPORT_CURSOR_KIND["KEYSET_STRUCTURED"] = "KEYSET_STRUCTURED";
|
|
58
|
+
REPORT_CURSOR_KIND["SIGNED_QUERY"] = "SIGNED_QUERY";
|
|
59
|
+
})(REPORT_CURSOR_KIND || (exports.REPORT_CURSOR_KIND = REPORT_CURSOR_KIND = {}));
|
|
60
|
+
var REPORT_PROJECTION;
|
|
61
|
+
(function (REPORT_PROJECTION) {
|
|
62
|
+
REPORT_PROJECTION["FLAT_DRILLDOWN"] = "FLAT_DRILLDOWN";
|
|
63
|
+
REPORT_PROJECTION["DISCOUNT_SOURCES"] = "DISCOUNT_SOURCES";
|
|
64
|
+
REPORT_PROJECTION["DELIVERY_GEO"] = "DELIVERY_GEO";
|
|
65
|
+
})(REPORT_PROJECTION || (exports.REPORT_PROJECTION = REPORT_PROJECTION = {}));
|
|
66
|
+
var REPORT_RETENTION_UNIT;
|
|
67
|
+
(function (REPORT_RETENTION_UNIT) {
|
|
68
|
+
REPORT_RETENTION_UNIT["DAY"] = "DAY";
|
|
69
|
+
REPORT_RETENTION_UNIT["MONTH"] = "MONTH";
|
|
70
|
+
})(REPORT_RETENTION_UNIT || (exports.REPORT_RETENTION_UNIT = REPORT_RETENTION_UNIT = {}));
|
|
71
|
+
const DOCUMENT_BUDGET = 15 * 1024 * 1024;
|
|
72
|
+
const GEO_SCOPE_BUDGET = 2 * 1024 * 1024;
|
|
73
|
+
const FLAT_ROWS = {
|
|
74
|
+
name: 'materialized_report_drilldown_rows',
|
|
75
|
+
schemaVersion: 1,
|
|
76
|
+
budgetBytes: DOCUMENT_BUDGET,
|
|
77
|
+
enforced: false,
|
|
78
|
+
validatorFile: null,
|
|
79
|
+
validatorDebt: 'No schema validator exists for the flat drill-down rows yet.',
|
|
80
|
+
indexOwner: 'toolkit:MATERIALIZED_REPORT_DRILLDOWN_ROWS_INDEX_OPTIONS',
|
|
81
|
+
migrationId: null,
|
|
82
|
+
};
|
|
83
|
+
const FLAT_SCOPES = {
|
|
84
|
+
name: 'materialized_report_drilldown_scopes',
|
|
85
|
+
schemaVersion: 1,
|
|
86
|
+
budgetBytes: DOCUMENT_BUDGET,
|
|
87
|
+
enforced: false,
|
|
88
|
+
validatorFile: null,
|
|
89
|
+
validatorDebt: 'No schema validator exists for the flat drill-down scopes yet.',
|
|
90
|
+
indexOwner: 'toolkit:MATERIALIZED_REPORT_DRILLDOWN_SCOPES_INDEX_OPTIONS',
|
|
91
|
+
migrationId: null,
|
|
92
|
+
};
|
|
93
|
+
const CLIENT_KEY_FILTERS = [
|
|
94
|
+
{
|
|
95
|
+
id: MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_KEY_FILTER_ENUM.ORDER_STATUS,
|
|
96
|
+
kind: 'KEY_COMPONENT',
|
|
97
|
+
mode: 'CLIENT',
|
|
98
|
+
appliesTo: 'BOTH',
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
id: MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_KEY_FILTER_ENUM.PLATFORM,
|
|
102
|
+
kind: 'KEY_COMPONENT',
|
|
103
|
+
mode: 'CLIENT',
|
|
104
|
+
appliesTo: 'BOTH',
|
|
105
|
+
},
|
|
106
|
+
{ id: 'DAY_INDEX', kind: 'ROW', mode: 'CLIENT', appliesTo: 'SUMMARY' },
|
|
107
|
+
];
|
|
108
|
+
const OVERVIEW_DEFINITION = {
|
|
109
|
+
key: report_contract_1.REPORT_KEY_ENUM.OVERVIEW,
|
|
110
|
+
segment: 'overview',
|
|
111
|
+
reportType: MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_TYPE_ENUM.TENANT_SALES_OVERVIEW,
|
|
112
|
+
capabilities: { live: true, historical: true, details: false },
|
|
113
|
+
status: REPORT_DEFINITION_STATUS.PRODUCTION,
|
|
114
|
+
report: {
|
|
115
|
+
name: 'materialized_tenant_sales_overview_reports',
|
|
116
|
+
schemaVersion: 1,
|
|
117
|
+
budgetBytes: DOCUMENT_BUDGET,
|
|
118
|
+
enforced: false,
|
|
119
|
+
validatorFile: 'materialized_tenant_sales_overview_reports.bson',
|
|
120
|
+
indexOwner: 'toolkit:MATERIALIZED_TENANT_SALES_OVERVIEW_REPORTS_INDEX_OPTIONS',
|
|
121
|
+
migrationId: null,
|
|
122
|
+
},
|
|
123
|
+
sideCollections: [
|
|
124
|
+
{
|
|
125
|
+
name: 'materialized_tenant_credit_bills',
|
|
126
|
+
schemaVersion: 1,
|
|
127
|
+
budgetBytes: DOCUMENT_BUDGET,
|
|
128
|
+
enforced: false,
|
|
129
|
+
validatorFile: 'materialized_tenant_credit_bills.bson',
|
|
130
|
+
indexOwner: 'toolkit:MATERIALIZED_TENANT_CREDIT_BILLS_INDEX_OPTIONS',
|
|
131
|
+
migrationId: null,
|
|
132
|
+
},
|
|
133
|
+
],
|
|
134
|
+
reportScopes: [...MATERIALIZED_REPORTS_1.ALL_MATERIALIZED_REPORT_SCOPES],
|
|
135
|
+
entryScopes: [],
|
|
136
|
+
entryStorage: REPORT_ENTRY_STORAGE.NONE,
|
|
137
|
+
entrySplit: REPORT_ENTRY_SPLIT.NONE,
|
|
138
|
+
maxReportScope: MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_YEAR,
|
|
139
|
+
maxEntryScope: null,
|
|
140
|
+
projections: [],
|
|
141
|
+
budgets: {
|
|
142
|
+
materialized_tenant_sales_overview_reports: DOCUMENT_BUDGET,
|
|
143
|
+
materialized_tenant_credit_bills: DOCUMENT_BUDGET,
|
|
144
|
+
},
|
|
145
|
+
retention: [],
|
|
146
|
+
writeGuard: REPORT_WRITE_GUARD.WATERMARK_AND_DIGEST,
|
|
147
|
+
liveSource: REPORT_LIVE_SOURCE.RAW_PLUS_MATERIALIZED,
|
|
148
|
+
historicalLens: REPORT_HISTORICAL_LENS.DOCUMENT_FOLD,
|
|
149
|
+
completeness: { summary: 'ALL_SCOPES', details: 'NONE' },
|
|
150
|
+
filters: CLIENT_KEY_FILTERS,
|
|
151
|
+
cursor: REPORT_CURSOR_KIND.NONE,
|
|
152
|
+
adapters: {
|
|
153
|
+
writer: 'materializeOverviewReport',
|
|
154
|
+
live: 'getLiveTenantSalesOverviewReports',
|
|
155
|
+
historical: 'getMaterializedTenantSalesOverviewReports',
|
|
156
|
+
},
|
|
157
|
+
owner: 'reporting-platform',
|
|
158
|
+
notes: [
|
|
159
|
+
'Map-only counters: no sales_overview_counter_rows.',
|
|
160
|
+
'LIVE is raw + stored credit ledger and resolves the running day server-side.',
|
|
161
|
+
'Writes the credit ledger and may patch prior issue-day counters.',
|
|
162
|
+
],
|
|
163
|
+
};
|
|
164
|
+
const DISCOUNTS_DEFINITION = {
|
|
165
|
+
key: report_contract_1.REPORT_KEY_ENUM.DISCOUNTS,
|
|
166
|
+
segment: 'discounts',
|
|
167
|
+
reportType: MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_TYPE_ENUM.TENANT_DISCOUNT_REPORTS,
|
|
168
|
+
capabilities: { live: true, historical: true, details: true },
|
|
169
|
+
status: REPORT_DEFINITION_STATUS.PRODUCTION,
|
|
170
|
+
report: {
|
|
171
|
+
name: 'materialized_tenant_discount_reports',
|
|
172
|
+
schemaVersion: 1,
|
|
173
|
+
budgetBytes: DOCUMENT_BUDGET,
|
|
174
|
+
enforced: false,
|
|
175
|
+
validatorFile: 'materialized_tenant_discount_reports.bson',
|
|
176
|
+
indexOwner: 'toolkit:MATERIALIZED_TENANT_DISCOUNT_REPORTS_INDEX_OPTIONS',
|
|
177
|
+
migrationId: 'discount-entry-page-index',
|
|
178
|
+
},
|
|
179
|
+
entries: {
|
|
180
|
+
name: 'materialized_tenant_discount_entries',
|
|
181
|
+
schemaVersion: 1,
|
|
182
|
+
budgetBytes: DOCUMENT_BUDGET,
|
|
183
|
+
enforced: false,
|
|
184
|
+
validatorFile: 'materialized_tenant_discount_entries.bson',
|
|
185
|
+
indexOwner: 'toolkit:MATERIALIZED_TENANT_DISCOUNT_ENTRIES_INDEX_OPTIONS',
|
|
186
|
+
migrationId: 'discount-entry-page-index',
|
|
187
|
+
},
|
|
188
|
+
sideCollections: [
|
|
189
|
+
{
|
|
190
|
+
name: 'materialized_tenant_discount_sources',
|
|
191
|
+
schemaVersion: 1,
|
|
192
|
+
budgetBytes: DOCUMENT_BUDGET,
|
|
193
|
+
enforced: false,
|
|
194
|
+
validatorFile: null,
|
|
195
|
+
validatorDebt: 'No schema validator exists for the discount source projection yet.',
|
|
196
|
+
indexOwner: 'toolkit:MATERIALIZED_TENANT_DISCOUNT_SOURCES_INDEX_OPTIONS',
|
|
197
|
+
migrationId: null,
|
|
198
|
+
},
|
|
199
|
+
FLAT_ROWS,
|
|
200
|
+
FLAT_SCOPES,
|
|
201
|
+
],
|
|
202
|
+
reportScopes: [...MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_REPORT_SCOPES],
|
|
203
|
+
entryScopes: [...MATERIALIZED_REPORTS_1.MATERIALIZED_DISCOUNT_REPORT_SCOPES],
|
|
204
|
+
entryStorage: REPORT_ENTRY_STORAGE.PAGE_PER_SOURCE_DAY,
|
|
205
|
+
entrySplit: REPORT_ENTRY_SPLIT.NONE,
|
|
206
|
+
maxReportScope: MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_MONTH,
|
|
207
|
+
maxEntryScope: MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_MONTH,
|
|
208
|
+
projections: [REPORT_PROJECTION.DISCOUNT_SOURCES, REPORT_PROJECTION.FLAT_DRILLDOWN],
|
|
209
|
+
budgets: {
|
|
210
|
+
materialized_tenant_discount_reports: DOCUMENT_BUDGET,
|
|
211
|
+
materialized_tenant_discount_entries: DOCUMENT_BUDGET,
|
|
212
|
+
materialized_tenant_discount_sources: DOCUMENT_BUDGET,
|
|
213
|
+
materialized_report_drilldown_rows: DOCUMENT_BUDGET,
|
|
214
|
+
materialized_report_drilldown_scopes: DOCUMENT_BUDGET,
|
|
215
|
+
},
|
|
216
|
+
retention: [],
|
|
217
|
+
writeGuard: REPORT_WRITE_GUARD.WATERMARK_AND_DIGEST,
|
|
218
|
+
liveSource: REPORT_LIVE_SOURCE.RAW,
|
|
219
|
+
historicalLens: REPORT_HISTORICAL_LENS.COUNTER_ROWS,
|
|
220
|
+
completeness: { summary: 'NONE', details: 'FLAT_PROJECTION' },
|
|
221
|
+
filters: [
|
|
222
|
+
...CLIENT_KEY_FILTERS,
|
|
223
|
+
{
|
|
224
|
+
id: 'DETAILS_VIEW',
|
|
225
|
+
kind: 'REQUEST',
|
|
226
|
+
mode: 'SERVER',
|
|
227
|
+
appliesTo: 'DETAILS',
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
id: 'SOURCE_KEY_LEVEL',
|
|
231
|
+
kind: 'REQUEST',
|
|
232
|
+
mode: 'SERVER',
|
|
233
|
+
appliesTo: 'DETAILS',
|
|
234
|
+
},
|
|
235
|
+
],
|
|
236
|
+
cursor: REPORT_CURSOR_KIND.KEYSET_STRUCTURED,
|
|
237
|
+
adapters: {
|
|
238
|
+
writer: 'materializeDiscountReport',
|
|
239
|
+
live: 'getLiveTenantDiscountReports',
|
|
240
|
+
historical: 'getMaterializedTenantDiscountReports',
|
|
241
|
+
details: 'getMaterializedDiscountDetailsPage',
|
|
242
|
+
},
|
|
243
|
+
owner: 'reporting-platform',
|
|
244
|
+
notes: [
|
|
245
|
+
'Month-capped scope set; a wider selection is refused, never narrowed.',
|
|
246
|
+
'Page-partitioned entries; no #N splitter and no budget assertion today.',
|
|
247
|
+
'Derived source projection has no independent iteration history.',
|
|
248
|
+
],
|
|
249
|
+
};
|
|
250
|
+
const PREP_TIME_DEFINITION = {
|
|
251
|
+
key: report_contract_1.REPORT_KEY_ENUM.PREP_TIME,
|
|
252
|
+
segment: 'prep-time',
|
|
253
|
+
reportType: MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_TYPE_ENUM.TENANT_PREP_TIME_REPORTS,
|
|
254
|
+
capabilities: { live: true, historical: true, details: true },
|
|
255
|
+
status: REPORT_DEFINITION_STATUS.PRODUCTION,
|
|
256
|
+
report: {
|
|
257
|
+
name: 'materialized_tenant_prep_time_reports',
|
|
258
|
+
schemaVersion: 1,
|
|
259
|
+
budgetBytes: DOCUMENT_BUDGET,
|
|
260
|
+
enforced: false,
|
|
261
|
+
validatorFile: 'materialized_tenant_prep_time_reports.bson',
|
|
262
|
+
indexOwner: 'toolkit:MATERIALIZED_TENANT_PREP_TIME_REPORTS_INDEX_OPTIONS',
|
|
263
|
+
migrationId: null,
|
|
264
|
+
},
|
|
265
|
+
entries: {
|
|
266
|
+
name: 'materialized_tenant_prep_time_entries',
|
|
267
|
+
schemaVersion: 1,
|
|
268
|
+
budgetBytes: DOCUMENT_BUDGET,
|
|
269
|
+
enforced: false,
|
|
270
|
+
validatorFile: 'materialized_tenant_prep_time_entries.bson',
|
|
271
|
+
indexOwner: 'toolkit:MATERIALIZED_TENANT_PREP_TIME_ENTRIES_INDEX_OPTIONS',
|
|
272
|
+
migrationId: null,
|
|
273
|
+
},
|
|
274
|
+
sideCollections: [FLAT_ROWS, FLAT_SCOPES],
|
|
275
|
+
reportScopes: [...MATERIALIZED_REPORTS_1.MATERIALIZED_PREP_TIME_REPORT_SCOPES],
|
|
276
|
+
entryScopes: [...MATERIALIZED_REPORTS_1.MATERIALIZED_PREP_TIME_ITEM_SCOPES],
|
|
277
|
+
entryStorage: REPORT_ENTRY_STORAGE.ONE_PER_SCOPE,
|
|
278
|
+
entrySplit: REPORT_ENTRY_SPLIT.NONE,
|
|
279
|
+
maxReportScope: MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_YEAR,
|
|
280
|
+
maxEntryScope: MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_MONTH,
|
|
281
|
+
projections: [REPORT_PROJECTION.FLAT_DRILLDOWN],
|
|
282
|
+
budgets: {
|
|
283
|
+
materialized_tenant_prep_time_reports: DOCUMENT_BUDGET,
|
|
284
|
+
materialized_tenant_prep_time_entries: DOCUMENT_BUDGET,
|
|
285
|
+
materialized_report_drilldown_rows: DOCUMENT_BUDGET,
|
|
286
|
+
materialized_report_drilldown_scopes: DOCUMENT_BUDGET,
|
|
287
|
+
},
|
|
288
|
+
retention: [],
|
|
289
|
+
writeGuard: REPORT_WRITE_GUARD.WATERMARK,
|
|
290
|
+
liveSource: REPORT_LIVE_SOURCE.RAW,
|
|
291
|
+
historicalLens: REPORT_HISTORICAL_LENS.COUNTER_ROWS,
|
|
292
|
+
completeness: { summary: 'NONE', details: 'FLAT_PROJECTION' },
|
|
293
|
+
filters: [
|
|
294
|
+
...CLIENT_KEY_FILTERS,
|
|
295
|
+
{ id: 'DETAILS_VIEW', kind: 'REQUEST', mode: 'SERVER', appliesTo: 'DETAILS' },
|
|
296
|
+
{ id: 'LATE_ONLY', kind: 'REQUEST', mode: 'SERVER', appliesTo: 'DETAILS' },
|
|
297
|
+
{ id: 'ITEM_ID', kind: 'REQUEST', mode: 'SERVER', appliesTo: 'DETAILS' },
|
|
298
|
+
{
|
|
299
|
+
id: 'EXCLUDE_CANCELLED',
|
|
300
|
+
kind: 'REQUEST',
|
|
301
|
+
mode: 'SERVER',
|
|
302
|
+
appliesTo: 'DETAILS',
|
|
303
|
+
},
|
|
304
|
+
],
|
|
305
|
+
cursor: REPORT_CURSOR_KIND.SIGNED_QUERY,
|
|
306
|
+
adapters: {
|
|
307
|
+
writer: 'materializePrepTimeReport',
|
|
308
|
+
live: 'getLiveTenantPrepTimeReports',
|
|
309
|
+
historical: 'getMaterializedTenantPrepTimeReports',
|
|
310
|
+
details: 'getMaterializedPrepTimeDetailsPage',
|
|
311
|
+
},
|
|
312
|
+
owner: 'reporting-platform',
|
|
313
|
+
notes: [
|
|
314
|
+
'Coverage-first counters: MEASURED/UNMEASURED anchor split and target provenance.',
|
|
315
|
+
'No hour scope; entries are one document per scope, not pages.',
|
|
316
|
+
'Item reads are capped at 31 effective days at the route.',
|
|
317
|
+
],
|
|
318
|
+
};
|
|
319
|
+
const DELIVERY_DEFINITION = {
|
|
320
|
+
key: report_contract_1.REPORT_KEY_ENUM.DELIVERY,
|
|
321
|
+
segment: 'delivery',
|
|
322
|
+
reportType: MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_TYPE_ENUM.TENANT_DELIVERY_REPORTS,
|
|
323
|
+
capabilities: { live: true, historical: true, details: true },
|
|
324
|
+
status: REPORT_DEFINITION_STATUS.PRODUCTION,
|
|
325
|
+
report: {
|
|
326
|
+
name: 'materialized_tenant_delivery_reports',
|
|
327
|
+
schemaVersion: 2,
|
|
328
|
+
budgetBytes: MATERIALIZED_REPORTS_1.MATERIALIZED_DELIVERY_REPORT_MAX_BSON_BYTES,
|
|
329
|
+
enforced: true,
|
|
330
|
+
validatorFile: 'materialized_tenant_delivery_reports.bson',
|
|
331
|
+
indexOwner: 'toolkit:MATERIALIZED_TENANT_DELIVERY_REPORTS_INDEX_OPTIONS',
|
|
332
|
+
migrationId: 'delivery-page-index-2026-10-27',
|
|
333
|
+
},
|
|
334
|
+
entries: {
|
|
335
|
+
name: 'materialized_tenant_delivery_entries',
|
|
336
|
+
schemaVersion: 3,
|
|
337
|
+
budgetBytes: MATERIALIZED_REPORTS_1.MATERIALIZED_DELIVERY_ENTRY_MAX_BSON_BYTES,
|
|
338
|
+
enforced: true,
|
|
339
|
+
validatorFile: 'materialized_tenant_delivery_entries.bson',
|
|
340
|
+
indexOwner: 'toolkit:MATERIALIZED_TENANT_DELIVERY_ENTRIES_INDEX_OPTIONS',
|
|
341
|
+
migrationId: 'delivery-page-index-2026-10-27',
|
|
342
|
+
},
|
|
343
|
+
sideCollections: [
|
|
344
|
+
{
|
|
345
|
+
name: 'materialized_tenant_delivery_geo_cells',
|
|
346
|
+
schemaVersion: 1,
|
|
347
|
+
budgetBytes: MATERIALIZED_REPORTS_1.MATERIALIZED_DELIVERY_GEO_CELL_MAX_BSON_BYTES,
|
|
348
|
+
enforced: true,
|
|
349
|
+
validatorFile: 'materialized_tenant_delivery_geo_cells.bson',
|
|
350
|
+
indexOwner: 'toolkit:MATERIALIZED_TENANT_DELIVERY_GEO_CELLS_INDEX_OPTIONS',
|
|
351
|
+
migrationId: 'delivery-page-index-2026-10-27',
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
name: 'materialized_tenant_delivery_geo_scopes',
|
|
355
|
+
schemaVersion: 1,
|
|
356
|
+
budgetBytes: GEO_SCOPE_BUDGET,
|
|
357
|
+
enforced: false,
|
|
358
|
+
validatorFile: 'materialized_tenant_delivery_geo_scopes.bson',
|
|
359
|
+
indexOwner: 'toolkit:MATERIALIZED_TENANT_DELIVERY_GEO_SCOPES_INDEX_OPTIONS',
|
|
360
|
+
migrationId: 'delivery-page-index-2026-10-27',
|
|
361
|
+
},
|
|
362
|
+
FLAT_ROWS,
|
|
363
|
+
FLAT_SCOPES,
|
|
364
|
+
],
|
|
365
|
+
reportScopes: [...MATERIALIZED_REPORTS_1.MATERIALIZED_DELIVERY_REPORT_SCOPES],
|
|
366
|
+
entryScopes: [...MATERIALIZED_REPORTS_1.MATERIALIZED_DELIVERY_ENTRY_SCOPES],
|
|
367
|
+
entryStorage: REPORT_ENTRY_STORAGE.PAGE_PER_SOURCE_DAY,
|
|
368
|
+
entrySplit: REPORT_ENTRY_SPLIT.DETERMINISTIC_SUBPAGES,
|
|
369
|
+
maxReportScope: MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_YEAR,
|
|
370
|
+
maxEntryScope: MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_SCOPE_ENUM.LOCAL_MONTH,
|
|
371
|
+
projections: [REPORT_PROJECTION.FLAT_DRILLDOWN, REPORT_PROJECTION.DELIVERY_GEO],
|
|
372
|
+
budgets: {
|
|
373
|
+
materialized_tenant_delivery_reports: MATERIALIZED_REPORTS_1.MATERIALIZED_DELIVERY_REPORT_MAX_BSON_BYTES,
|
|
374
|
+
materialized_tenant_delivery_entries: MATERIALIZED_REPORTS_1.MATERIALIZED_DELIVERY_ENTRY_MAX_BSON_BYTES,
|
|
375
|
+
materialized_tenant_delivery_geo_cells: MATERIALIZED_REPORTS_1.MATERIALIZED_DELIVERY_GEO_CELL_MAX_BSON_BYTES,
|
|
376
|
+
materialized_tenant_delivery_geo_scopes: GEO_SCOPE_BUDGET,
|
|
377
|
+
materialized_report_drilldown_rows: DOCUMENT_BUDGET,
|
|
378
|
+
materialized_report_drilldown_scopes: DOCUMENT_BUDGET,
|
|
379
|
+
},
|
|
380
|
+
retention: [
|
|
381
|
+
{
|
|
382
|
+
collection: 'materialized_tenant_delivery_geo_cells',
|
|
383
|
+
unit: REPORT_RETENTION_UNIT.DAY,
|
|
384
|
+
amount: 90,
|
|
385
|
+
},
|
|
386
|
+
{
|
|
387
|
+
collection: 'materialized_tenant_delivery_geo_cells',
|
|
388
|
+
unit: REPORT_RETENTION_UNIT.MONTH,
|
|
389
|
+
amount: 24,
|
|
390
|
+
},
|
|
391
|
+
],
|
|
392
|
+
writeGuard: REPORT_WRITE_GUARD.WATERMARK,
|
|
393
|
+
liveSource: REPORT_LIVE_SOURCE.RAW,
|
|
394
|
+
historicalLens: REPORT_HISTORICAL_LENS.COUNTER_ROWS,
|
|
395
|
+
completeness: { summary: 'NONE', details: 'FLAT_PROJECTION' },
|
|
396
|
+
filters: [
|
|
397
|
+
{
|
|
398
|
+
id: MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_KEY_FILTER_ENUM.ORDER_STATUS,
|
|
399
|
+
kind: 'KEY_COMPONENT',
|
|
400
|
+
mode: 'SERVER',
|
|
401
|
+
appliesTo: 'BOTH',
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
id: MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_KEY_FILTER_ENUM.PLATFORM,
|
|
405
|
+
kind: 'KEY_COMPONENT',
|
|
406
|
+
mode: 'SERVER',
|
|
407
|
+
appliesTo: 'BOTH',
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
id: MATERIALIZED_REPORTS_1.MATERIALIZED_REPORT_KEY_FILTER_ENUM.CITY,
|
|
411
|
+
kind: 'KEY_COMPONENT',
|
|
412
|
+
mode: 'SERVER',
|
|
413
|
+
appliesTo: 'BOTH',
|
|
414
|
+
},
|
|
415
|
+
{ id: 'RIDER_ID', kind: 'ROW', mode: 'SERVER', appliesTo: 'BOTH' },
|
|
416
|
+
{ id: 'DETAILS_VIEW', kind: 'REQUEST', mode: 'SERVER', appliesTo: 'DETAILS' },
|
|
417
|
+
],
|
|
418
|
+
cursor: REPORT_CURSOR_KIND.KEYSET_STRUCTURED,
|
|
419
|
+
adapters: {
|
|
420
|
+
writer: 'materializeDeliveryReport',
|
|
421
|
+
live: 'getLiveTenantDeliveryReports',
|
|
422
|
+
historical: 'getMaterializedTenantDeliveryReports',
|
|
423
|
+
details: 'getMaterializedDeliveryDetailsPage',
|
|
424
|
+
},
|
|
425
|
+
owner: 'reporting-platform',
|
|
426
|
+
notes: [
|
|
427
|
+
'Separate H3 geo collection and cap metadata; live geo is computed in memory.',
|
|
428
|
+
'Cross-day completion re-materializes the prior ORDER day within the same transaction.',
|
|
429
|
+
'Page entries split deterministically into #N sub-pages.',
|
|
430
|
+
'Historical totals do not pin schema_version today (baseline debt).',
|
|
431
|
+
],
|
|
432
|
+
};
|
|
433
|
+
exports.REPORT_DEFINITIONS = {
|
|
434
|
+
[OVERVIEW_DEFINITION.key]: OVERVIEW_DEFINITION,
|
|
435
|
+
[DISCOUNTS_DEFINITION.key]: DISCOUNTS_DEFINITION,
|
|
436
|
+
[PREP_TIME_DEFINITION.key]: PREP_TIME_DEFINITION,
|
|
437
|
+
[DELIVERY_DEFINITION.key]: DELIVERY_DEFINITION,
|
|
438
|
+
};
|
|
439
|
+
exports.PRODUCTION_REPORT_DEFINITIONS = [
|
|
440
|
+
OVERVIEW_DEFINITION,
|
|
441
|
+
DISCOUNTS_DEFINITION,
|
|
442
|
+
PREP_TIME_DEFINITION,
|
|
443
|
+
DELIVERY_DEFINITION,
|
|
444
|
+
];
|
|
445
|
+
exports.REPORT_REGISTRY_EXEMPTIONS = {
|
|
446
|
+
[report_contract_1.REPORT_KEY_ENUM.CASH_IN_OUT]: {
|
|
447
|
+
key: report_contract_1.REPORT_KEY_ENUM.CASH_IN_OUT,
|
|
448
|
+
status: REPORT_DEFINITION_STATUS.READ_ONLY,
|
|
449
|
+
reason: 'Read adapters exist but there is no production END_TENANT_DAY writer.',
|
|
450
|
+
},
|
|
451
|
+
[report_contract_1.REPORT_KEY_ENUM.SALES_COMPARISON]: {
|
|
452
|
+
key: report_contract_1.REPORT_KEY_ENUM.SALES_COMPARISON,
|
|
453
|
+
status: REPORT_DEFINITION_STATUS.READ_ONLY,
|
|
454
|
+
reason: 'Read adapters exist but there is no production END_TENANT_DAY writer.',
|
|
455
|
+
},
|
|
456
|
+
[report_contract_1.REPORT_KEY_ENUM.HOURLY_COMPARISON]: {
|
|
457
|
+
key: report_contract_1.REPORT_KEY_ENUM.HOURLY_COMPARISON,
|
|
458
|
+
status: REPORT_DEFINITION_STATUS.READ_ONLY,
|
|
459
|
+
reason: 'Read adapters exist but there is no production END_TENANT_DAY writer.',
|
|
460
|
+
},
|
|
461
|
+
[report_contract_1.REPORT_KEY_ENUM.PAYMENTS_COMPARISON]: {
|
|
462
|
+
key: report_contract_1.REPORT_KEY_ENUM.PAYMENTS_COMPARISON,
|
|
463
|
+
status: REPORT_DEFINITION_STATUS.READ_ONLY,
|
|
464
|
+
reason: 'Read adapters exist but there is no production END_TENANT_DAY writer.',
|
|
465
|
+
},
|
|
466
|
+
[report_contract_1.REPORT_KEY_ENUM.CREDIT_BILLS]: {
|
|
467
|
+
key: report_contract_1.REPORT_KEY_ENUM.CREDIT_BILLS,
|
|
468
|
+
status: REPORT_DEFINITION_STATUS.READ_ONLY,
|
|
469
|
+
reason: 'Historical-only ledger; no live read adapter.',
|
|
470
|
+
},
|
|
471
|
+
[report_contract_1.REPORT_KEY_ENUM.ITERATIONS]: {
|
|
472
|
+
key: report_contract_1.REPORT_KEY_ENUM.ITERATIONS,
|
|
473
|
+
status: REPORT_DEFINITION_STATUS.READ_ONLY,
|
|
474
|
+
reason: 'Shared history read, not a report family.',
|
|
475
|
+
},
|
|
476
|
+
[report_contract_1.REPORT_KEY_ENUM.SUMMARY]: {
|
|
477
|
+
key: report_contract_1.REPORT_KEY_ENUM.SUMMARY,
|
|
478
|
+
status: REPORT_DEFINITION_STATUS.PLANNED,
|
|
479
|
+
reason: 'No implementation.',
|
|
480
|
+
},
|
|
481
|
+
[report_contract_1.REPORT_KEY_ENUM.X_REPORT]: {
|
|
482
|
+
key: report_contract_1.REPORT_KEY_ENUM.X_REPORT,
|
|
483
|
+
status: REPORT_DEFINITION_STATUS.PLANNED,
|
|
484
|
+
reason: 'No implementation.',
|
|
485
|
+
},
|
|
486
|
+
[report_contract_1.REPORT_KEY_ENUM.Z_REPORT]: {
|
|
487
|
+
key: report_contract_1.REPORT_KEY_ENUM.Z_REPORT,
|
|
488
|
+
status: REPORT_DEFINITION_STATUS.PLANNED,
|
|
489
|
+
reason: 'No implementation.',
|
|
490
|
+
},
|
|
491
|
+
[report_contract_1.REPORT_KEY_ENUM.ITEMS]: {
|
|
492
|
+
key: report_contract_1.REPORT_KEY_ENUM.ITEMS,
|
|
493
|
+
status: REPORT_DEFINITION_STATUS.PLANNED,
|
|
494
|
+
reason: 'No implementation.',
|
|
495
|
+
},
|
|
496
|
+
[report_contract_1.REPORT_KEY_ENUM.ITEMS_COMPARISON]: {
|
|
497
|
+
key: report_contract_1.REPORT_KEY_ENUM.ITEMS_COMPARISON,
|
|
498
|
+
status: REPORT_DEFINITION_STATUS.PLANNED,
|
|
499
|
+
reason: 'No implementation.',
|
|
500
|
+
},
|
|
501
|
+
[report_contract_1.REPORT_KEY_ENUM.VOID_ITEMS]: {
|
|
502
|
+
key: report_contract_1.REPORT_KEY_ENUM.VOID_ITEMS,
|
|
503
|
+
status: REPORT_DEFINITION_STATUS.PLANNED,
|
|
504
|
+
reason: 'No implementation.',
|
|
505
|
+
},
|
|
506
|
+
[report_contract_1.REPORT_KEY_ENUM.REVIEWS_RATINGS]: {
|
|
507
|
+
key: report_contract_1.REPORT_KEY_ENUM.REVIEWS_RATINGS,
|
|
508
|
+
status: REPORT_DEFINITION_STATUS.PLANNED,
|
|
509
|
+
reason: 'No implementation.',
|
|
510
|
+
},
|
|
511
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./definition"), exports);
|
|
18
|
+
__exportStar(require("./registry"), exports);
|
|
19
|
+
__exportStar(require("./validate-report-registry"), exports);
|
|
20
|
+
__exportStar(require("./lifecycle"), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { IReportDefinition } from '../definition';
|
|
2
|
+
/** PHASE 2 — per-collection budget lookup + assertion. */
|
|
3
|
+
export type TReportBudgetKind = 'report' | 'entries' | 'side';
|
|
4
|
+
export declare function getReportCollectionBudget(definition: Pick<IReportDefinition, 'budgets' | 'report' | 'entries' | 'sideCollections'>, kind: TReportBudgetKind, collectionName?: string): number | null;
|
|
5
|
+
export declare function assertReportDocumentBudget(definition: Pick<IReportDefinition, 'key' | 'budgets' | 'report' | 'entries' | 'sideCollections'>, kind: TReportBudgetKind, document: unknown, options?: {
|
|
6
|
+
collectionName?: string;
|
|
7
|
+
label?: string;
|
|
8
|
+
}): void;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getReportCollectionBudget = getReportCollectionBudget;
|
|
4
|
+
exports.assertReportDocumentBudget = assertReportDocumentBudget;
|
|
5
|
+
const materialized_document_size_1 = require("../../materialized-document-size");
|
|
6
|
+
function getReportCollectionBudget(definition, kind, collectionName) {
|
|
7
|
+
if (kind === 'report')
|
|
8
|
+
return definition.budgets[definition.report.name] ?? null;
|
|
9
|
+
if (kind === 'entries') {
|
|
10
|
+
if (definition.entries == null)
|
|
11
|
+
return null;
|
|
12
|
+
return definition.budgets[definition.entries.name] ?? null;
|
|
13
|
+
}
|
|
14
|
+
if (collectionName == null)
|
|
15
|
+
return null;
|
|
16
|
+
if (!definition.sideCollections.some((collection) => collection.name === collectionName)) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
return definition.budgets[collectionName] ?? null;
|
|
20
|
+
}
|
|
21
|
+
function assertReportDocumentBudget(definition, kind, document, options = {}) {
|
|
22
|
+
const budget = getReportCollectionBudget(definition, kind, options.collectionName);
|
|
23
|
+
if (budget == null) {
|
|
24
|
+
throw new Error(`assertReportDocumentBudget: ${definition.key} has no budget for ${kind}${options.collectionName == null ? '' : `:${options.collectionName}`}`);
|
|
25
|
+
}
|
|
26
|
+
(0, materialized_document_size_1.assertMaterializedDocumentSize)(document, {
|
|
27
|
+
collection: options.collectionName ?? (kind === 'report' ? definition.report.name : definition.entries?.name),
|
|
28
|
+
label: options.label ?? definition.key,
|
|
29
|
+
maxBytes: budget,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** PHASE 2 — generic suppression/cap metadata merge. */
|
|
2
|
+
export interface IReportCapMetadata {
|
|
3
|
+
cappedCellCount: number;
|
|
4
|
+
cappedOrderCount: number;
|
|
5
|
+
exact: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare const EMPTY_REPORT_CAP_METADATA: IReportCapMetadata;
|
|
8
|
+
export declare function mergeReportCapMetadata(left: IReportCapMetadata | null | undefined, right: IReportCapMetadata | null | undefined): IReportCapMetadata;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EMPTY_REPORT_CAP_METADATA = void 0;
|
|
4
|
+
exports.mergeReportCapMetadata = mergeReportCapMetadata;
|
|
5
|
+
exports.EMPTY_REPORT_CAP_METADATA = {
|
|
6
|
+
cappedCellCount: 0,
|
|
7
|
+
cappedOrderCount: 0,
|
|
8
|
+
exact: true,
|
|
9
|
+
};
|
|
10
|
+
function mergeReportCapMetadata(left, right) {
|
|
11
|
+
return {
|
|
12
|
+
cappedCellCount: Number(left?.cappedCellCount ?? 0) + Number(right?.cappedCellCount ?? 0),
|
|
13
|
+
cappedOrderCount: Number(left?.cappedOrderCount ?? 0) + Number(right?.cappedOrderCount ?? 0),
|
|
14
|
+
exact: (left?.exact ?? true) && (right?.exact ?? true),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type IReportDefinition } from '../definition';
|
|
2
|
+
/**
|
|
3
|
+
* PHASE 2 — generic entry page identity + deterministic #N splitter.
|
|
4
|
+
*
|
|
5
|
+
* The splitter is a generic transcription of the CURRENT Delivery splitter. It
|
|
6
|
+
* is not wired into any writer; the equivalence test runs both implementations
|
|
7
|
+
* over the same compiled Delivery page and requires byte-identical output.
|
|
8
|
+
*/
|
|
9
|
+
export declare const ENTRY_PAGE_ALL = "all";
|
|
10
|
+
export declare function isEntryPageScope(scope: unknown): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* `page` value for one entry scope, matching Discounts and Delivery:
|
|
13
|
+
* day/hour scopes are already one day -> `all`; period scopes use the SOURCE day.
|
|
14
|
+
* Reports with `ONE_PER_SCOPE` or `NONE` return null.
|
|
15
|
+
*/
|
|
16
|
+
export declare function resolveEntryPageForScope(definition: Pick<IReportDefinition, 'entryStorage'>, scopeContext: unknown, sourceLocalDate: string): string | null;
|
|
17
|
+
export declare function entryPageBase(page: unknown): string;
|
|
18
|
+
export declare function isEntryPageForSourceDay(definition: Pick<IReportDefinition, 'entryStorage'>, scopeContext: unknown, page: unknown, sourceLocalDate: string): boolean;
|
|
19
|
+
export declare function buildEntrySubPage(basePage: string, index: number): string;
|
|
20
|
+
export interface IEntryPageSections {
|
|
21
|
+
[key: string]: {
|
|
22
|
+
rows: unknown[];
|
|
23
|
+
} | null | undefined;
|
|
24
|
+
}
|
|
25
|
+
export interface IEntryPageSplitSpec<TDocument> {
|
|
26
|
+
document: TDocument;
|
|
27
|
+
maxBytes: number;
|
|
28
|
+
/** `page` of the document (may already carry a `#N` suffix). */
|
|
29
|
+
pageOf: (document: TDocument) => string;
|
|
30
|
+
/** The itemized sections; null/undefined means "nothing to split". */
|
|
31
|
+
sectionsOf: (document: TDocument) => IEntryPageSections | null;
|
|
32
|
+
/** Rebuild with a new page and sections; all other fields are preserved. */
|
|
33
|
+
rebuild: (document: TDocument, page: string, sections: IEntryPageSections) => TDocument;
|
|
34
|
+
scopeLabel?: (document: TDocument) => string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Splits one oversized entry page into deterministic `page#0`, `page#1`, ...
|
|
38
|
+
* chunks. A page that fits keeps its original identity.
|
|
39
|
+
*/
|
|
40
|
+
export declare function splitEntryPage<TDocument>(spec: IEntryPageSplitSpec<TDocument>): TDocument[];
|