@managesome/eposmatic-toolkit 0.4.52 → 0.4.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/constants/MATERIALIZED_REPORTS.js +106 -2
- package/esm/constants/enums/delivery.js +13 -0
- package/esm/helpers/materialized-reports/index.js +6 -0
- package/esm/helpers/materialized-reports/materialized-delivery-accumulator-helpers.js +8 -62
- package/esm/helpers/materialized-reports/materialized-delivery-classification-helpers.js +95 -73
- package/esm/helpers/materialized-reports/materialized-delivery-close-day-helpers.js +118 -146
- package/esm/helpers/materialized-reports/materialized-delivery-compile-helpers.js +304 -71
- package/esm/helpers/materialized-reports/materialized-delivery-entry-pages.js +307 -0
- package/esm/helpers/materialized-reports/materialized-delivery-index-migration.js +103 -0
- package/esm/helpers/materialized-reports/materialized-delivery-rows.js +109 -0
- package/esm/helpers/materialized-reports/materialized-delivery-wipe-targets.js +32 -0
- package/esm/helpers/materialized-reports/materialized-document-size.js +65 -0
- package/esm/helpers/materialized-reports/materialized-index-bootstrap.js +31 -16
- package/esm/helpers/materialized-reports/materialized-integer-contract.js +10 -1
- package/esm/helpers/materialized-reports/materialized-prep-time-close-day-helpers.js +3 -91
- package/esm/helpers/materialized-reports/materialized-tenant-delivery-geo-helpers.js +597 -0
- package/esm/helpers/materialized-reports/report-platform/definition.js +508 -0
- package/esm/helpers/materialized-reports/report-platform/index.js +4 -0
- package/esm/helpers/materialized-reports/report-platform/lifecycle/budget.js +27 -0
- package/esm/helpers/materialized-reports/report-platform/lifecycle/cap-metadata.js +12 -0
- package/esm/helpers/materialized-reports/report-platform/lifecycle/entry-pages.js +121 -0
- package/esm/helpers/materialized-reports/report-platform/lifecycle/flat-projection.js +14 -0
- package/esm/helpers/materialized-reports/report-platform/lifecycle/index.js +8 -0
- package/esm/helpers/materialized-reports/report-platform/lifecycle/iteration-row.js +10 -0
- package/esm/helpers/materialized-reports/report-platform/lifecycle/run-stats.js +42 -0
- package/esm/helpers/materialized-reports/report-platform/lifecycle/scope-refs.js +28 -0
- package/esm/helpers/materialized-reports/report-platform/lifecycle/top-n.js +24 -0
- package/esm/helpers/materialized-reports/report-platform/registry.js +23 -0
- package/esm/helpers/materialized-reports/report-platform/validate-report-registry.js +214 -0
- package/esm/helpers/materialized-reports/scope-helpers.js +98 -0
- package/esm/helpers/materialized-reports/tenant-delivery-formatter.js +70 -20
- package/esm/schemas/models/applied_order_discounts.js +103 -0
- package/esm/schemas/models/index.js +12 -10
- package/esm/schemas/models/materialized_tenant_delivery_entries.js +33 -12
- package/esm/schemas/models/materialized_tenant_delivery_geo_cells.js +83 -0
- package/esm/schemas/models/materialized_tenant_delivery_geo_scopes.js +35 -0
- package/esm/schemas/models/materialized_tenant_delivery_reports.js +10 -1
- package/esm/schemas/types/applied_order_discounts.js +1 -0
- package/esm/schemas/types/index.js +14 -12
- package/esm/schemas/types/materialized_tenant_delivery_geo_cells.js +1 -0
- package/esm/schemas/types/materialized_tenant_delivery_geo_scopes.js +1 -0
- package/lib/constants/MATERIALIZED_REPORTS.d.ts +95 -1
- package/lib/constants/MATERIALIZED_REPORTS.js +108 -4
- package/lib/constants/enums/delivery.d.ts +9 -0
- package/lib/constants/enums/delivery.js +14 -1
- package/lib/helpers/materialized-reports/index.d.ts +6 -0
- package/lib/helpers/materialized-reports/index.js +6 -0
- package/lib/helpers/materialized-reports/materialized-delivery-accumulator-helpers.js +8 -62
- package/lib/helpers/materialized-reports/materialized-delivery-classification-helpers.d.ts +36 -9
- package/lib/helpers/materialized-reports/materialized-delivery-classification-helpers.js +94 -72
- package/lib/helpers/materialized-reports/materialized-delivery-close-day-helpers.d.ts +23 -26
- package/lib/helpers/materialized-reports/materialized-delivery-close-day-helpers.js +121 -150
- package/lib/helpers/materialized-reports/materialized-delivery-compile-helpers.d.ts +44 -5
- package/lib/helpers/materialized-reports/materialized-delivery-compile-helpers.js +306 -69
- package/lib/helpers/materialized-reports/materialized-delivery-entry-pages.d.ts +128 -0
- package/lib/helpers/materialized-reports/materialized-delivery-entry-pages.js +322 -0
- package/lib/helpers/materialized-reports/materialized-delivery-index-migration.d.ts +48 -0
- package/lib/helpers/materialized-reports/materialized-delivery-index-migration.js +108 -0
- package/lib/helpers/materialized-reports/materialized-delivery-rows.d.ts +15 -0
- package/lib/helpers/materialized-reports/materialized-delivery-rows.js +115 -0
- package/lib/helpers/materialized-reports/materialized-delivery-wipe-targets.d.ts +17 -0
- package/lib/helpers/materialized-reports/materialized-delivery-wipe-targets.js +35 -0
- package/lib/helpers/materialized-reports/materialized-document-size.d.ts +47 -0
- package/lib/helpers/materialized-reports/materialized-document-size.js +73 -0
- package/lib/helpers/materialized-reports/materialized-index-bootstrap.js +28 -13
- package/lib/helpers/materialized-reports/materialized-integer-contract.js +10 -1
- package/lib/helpers/materialized-reports/materialized-prep-time-close-day-helpers.js +2 -90
- package/lib/helpers/materialized-reports/materialized-tenant-delivery-geo-helpers.d.ts +186 -0
- package/lib/helpers/materialized-reports/materialized-tenant-delivery-geo-helpers.js +620 -0
- package/lib/helpers/materialized-reports/report-platform/definition.d.ts +133 -0
- package/lib/helpers/materialized-reports/report-platform/definition.js +511 -0
- package/lib/helpers/materialized-reports/report-platform/index.d.ts +4 -0
- package/lib/helpers/materialized-reports/report-platform/index.js +20 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/budget.d.ts +8 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/budget.js +31 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/cap-metadata.d.ts +8 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/cap-metadata.js +16 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/entry-pages.d.ts +40 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/entry-pages.js +130 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/flat-projection.d.ts +22 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/flat-projection.js +17 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/index.d.ts +8 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/index.js +24 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/iteration-row.d.ts +13 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/iteration-row.js +13 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/run-stats.d.ts +20 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/run-stats.js +47 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/scope-refs.d.ts +13 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/scope-refs.js +31 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/top-n.d.ts +16 -0
- package/lib/helpers/materialized-reports/report-platform/lifecycle/top-n.js +29 -0
- package/lib/helpers/materialized-reports/report-platform/registry.d.ts +13 -0
- package/lib/helpers/materialized-reports/report-platform/registry.js +31 -0
- package/lib/helpers/materialized-reports/report-platform/validate-report-registry.d.ts +20 -0
- package/lib/helpers/materialized-reports/report-platform/validate-report-registry.js +218 -0
- package/lib/helpers/materialized-reports/scope-helpers.d.ts +8 -0
- package/lib/helpers/materialized-reports/scope-helpers.js +99 -0
- package/lib/helpers/materialized-reports/tenant-delivery-formatter.d.ts +41 -0
- package/lib/helpers/materialized-reports/tenant-delivery-formatter.js +70 -20
- package/lib/helpers/order/payment-collection.d.ts +25 -0
- package/lib/helpers/order/payment-collection.js +51 -0
- package/lib/schemas/models/applied_order_discounts.d.ts +80 -0
- package/lib/schemas/models/applied_order_discounts.js +106 -0
- package/lib/schemas/models/index.d.ts +12 -10
- package/lib/schemas/models/index.js +12 -10
- package/lib/schemas/models/materialized_tenant_delivery_entries.d.ts +31 -9
- package/lib/schemas/models/materialized_tenant_delivery_entries.js +32 -11
- package/lib/schemas/models/materialized_tenant_delivery_geo_cells.d.ts +129 -0
- package/lib/schemas/models/materialized_tenant_delivery_geo_cells.js +86 -0
- package/lib/schemas/models/materialized_tenant_delivery_geo_scopes.d.ts +71 -0
- package/lib/schemas/models/materialized_tenant_delivery_geo_scopes.js +38 -0
- package/lib/schemas/models/materialized_tenant_delivery_reports.d.ts +10 -1
- package/lib/schemas/models/materialized_tenant_delivery_reports.js +10 -1
- package/lib/schemas/models/materialized_tenant_discount_sources.d.ts +15 -15
- package/lib/schemas/types/applied_order_discounts.d.ts +22 -0
- package/lib/schemas/types/applied_order_discounts.js +2 -0
- package/lib/schemas/types/index.d.ts +14 -12
- package/lib/schemas/types/index.js +14 -12
- package/lib/schemas/types/materialized_tenant_delivery_entries.d.ts +36 -4
- package/lib/schemas/types/materialized_tenant_delivery_geo_cells.d.ts +178 -0
- package/lib/schemas/types/materialized_tenant_delivery_geo_cells.js +2 -0
- package/lib/schemas/types/materialized_tenant_delivery_geo_scopes.d.ts +21 -0
- package/lib/schemas/types/materialized_tenant_delivery_geo_scopes.js +2 -0
- package/lib/schemas/types/materialized_tenant_delivery_reports.d.ts +49 -7
- package/lib/tests/materialized-reports/analytics-growth-helpers.test.d.ts +1 -0
- package/lib/tests/materialized-reports/analytics-overview-helpers.test.d.ts +1 -0
- package/lib/tests/materialized-reports/analytics-performance-helpers.test.d.ts +1 -0
- package/lib/tests/materialized-reports/characterization/delivery.characterization.test.d.ts +1 -0
- package/lib/tests/materialized-reports/characterization/delivery.characterization.test.js +229 -0
- package/lib/tests/materialized-reports/characterization/discount.characterization.test.d.ts +1 -0
- package/lib/tests/materialized-reports/characterization/discount.characterization.test.js +99 -0
- package/lib/tests/materialized-reports/characterization/fixtures.d.ts +30 -0
- package/lib/tests/materialized-reports/characterization/fixtures.js +402 -0
- package/lib/tests/materialized-reports/characterization/golden.d.ts +18 -0
- package/lib/tests/materialized-reports/characterization/golden.js +127 -0
- package/lib/tests/materialized-reports/characterization/overview.characterization.test.d.ts +1 -0
- package/lib/tests/materialized-reports/characterization/overview.characterization.test.js +69 -0
- package/lib/tests/materialized-reports/characterization/prep-time.characterization.test.d.ts +1 -0
- package/lib/tests/materialized-reports/characterization/prep-time.characterization.test.js +102 -0
- package/lib/tests/materialized-reports/materialized-delivery-accumulation.test.js +56 -19
- package/lib/tests/materialized-reports/materialized-delivery-budgets.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-delivery-budgets.test.js +91 -0
- package/lib/tests/materialized-reports/materialized-delivery-compile.test.js +271 -15
- package/lib/tests/materialized-reports/materialized-delivery-final-audit.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-delivery-final-audit.test.js +128 -0
- package/lib/tests/materialized-reports/materialized-delivery-fold.test.js +42 -5
- package/lib/tests/materialized-reports/materialized-delivery-formatter.test.js +13 -1
- package/lib/tests/materialized-reports/materialized-delivery-geo.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-delivery-geo.test.js +446 -0
- package/lib/tests/materialized-reports/materialized-delivery-plan.test.js +117 -25
- package/lib/tests/materialized-reports/materialized-delivery-practical.test.d.ts +1 -0
- package/lib/tests/materialized-reports/materialized-delivery-practical.test.js +344 -0
- package/lib/tests/materialized-reports/materialized-integer-contract.test.js +14 -0
- package/lib/tests/materialized-reports/materialized-tenant-sales-overview-reports-schema.test.js +1 -1
- package/lib/tests/materialized-reports/report-platform/lifecycle-primitives.test.d.ts +1 -0
- package/lib/tests/materialized-reports/report-platform/lifecycle-primitives.test.js +177 -0
- package/lib/tests/materialized-reports/report-platform/registry-conformance.test.d.ts +1 -0
- package/lib/tests/materialized-reports/report-platform/registry-conformance.test.js +214 -0
- package/lib/tests/materialized-reports/report-platform/registry-validation.test.d.ts +1 -0
- package/lib/tests/materialized-reports/report-platform/registry-validation.test.js +103 -0
- package/lib/tests/offer-item-resolution.test.js +1 -4
- package/lib/tests/payment-collection-timestamps.test.d.ts +1 -0
- package/lib/tests/payment-collection-timestamps.test.js +71 -0
- package/package.json +6 -2
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stampPaymentCollectionTimestamps = stampPaymentCollectionTimestamps;
|
|
4
|
+
const constants_1 = require("../../constants");
|
|
5
|
+
const toValidDate = (value) => {
|
|
6
|
+
if (value == null)
|
|
7
|
+
return null;
|
|
8
|
+
const date = value instanceof Date ? value : new Date(value);
|
|
9
|
+
return Number.isNaN(date.getTime()) ? null : date;
|
|
10
|
+
};
|
|
11
|
+
/** Stable identity across a merge: subdoc `_id` first, then `payment_id`. */
|
|
12
|
+
const identityOf = (payment) => {
|
|
13
|
+
if (payment._id != null && String(payment._id).trim() !== '') {
|
|
14
|
+
return `id:${String(payment._id)}`;
|
|
15
|
+
}
|
|
16
|
+
if (typeof payment.payment_id === 'string' && payment.payment_id.trim() !== '') {
|
|
17
|
+
return `payment:${payment.payment_id}`;
|
|
18
|
+
}
|
|
19
|
+
return null;
|
|
20
|
+
};
|
|
21
|
+
function stampPaymentCollectionTimestamps(payments, previousPayments = null, options = {}) {
|
|
22
|
+
if (!Array.isArray(payments))
|
|
23
|
+
return [];
|
|
24
|
+
const now = toValidDate(options.now) ?? new Date();
|
|
25
|
+
const previousByIdentity = new Map();
|
|
26
|
+
for (const previous of Array.isArray(previousPayments) ? previousPayments : []) {
|
|
27
|
+
if (previous == null)
|
|
28
|
+
continue;
|
|
29
|
+
const identity = identityOf(previous);
|
|
30
|
+
if (identity != null)
|
|
31
|
+
previousByIdentity.set(identity, previous);
|
|
32
|
+
}
|
|
33
|
+
return payments.map((payment) => {
|
|
34
|
+
if (payment == null)
|
|
35
|
+
return payment;
|
|
36
|
+
const identity = identityOf(payment);
|
|
37
|
+
const previous = identity != null ? previousByIdentity.get(identity) : undefined;
|
|
38
|
+
const previousCollectedAt = toValidDate(previous?.collected_at);
|
|
39
|
+
const amountPaid = Number(payment.amount_paid ?? 0);
|
|
40
|
+
const previousAmountPaid = Number(previous?.amount_paid ?? 0);
|
|
41
|
+
const isFailed = payment.payment_status === constants_1.PAYMENT_STATUS_ENUM.FAILED;
|
|
42
|
+
const isNewCollection = !isFailed &&
|
|
43
|
+
Number.isFinite(amountPaid) &&
|
|
44
|
+
amountPaid > 0 &&
|
|
45
|
+
(previous == null || amountPaid > previousAmountPaid);
|
|
46
|
+
return {
|
|
47
|
+
...payment,
|
|
48
|
+
collected_at: isNewCollection ? now : previousCollectedAt,
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Schema } from 'mongoose';
|
|
2
|
+
export declare const AppliedOrderDiscountsSchema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
3
|
+
timestamps: true;
|
|
4
|
+
versionKey: false;
|
|
5
|
+
minimize: false;
|
|
6
|
+
}, {
|
|
7
|
+
createdAt: NativeDate;
|
|
8
|
+
updatedAt: NativeDate;
|
|
9
|
+
} & {
|
|
10
|
+
_id: import("mongoose").Types.ObjectId;
|
|
11
|
+
type: import("../../constants").DISCOUNT_TYPE_ENUM;
|
|
12
|
+
name: string;
|
|
13
|
+
tenant_id: string;
|
|
14
|
+
order_id: import("mongoose").Types.ObjectId;
|
|
15
|
+
discount_id: string;
|
|
16
|
+
applicability: import("../../constants").DISCOUNT_APPLICABILITY_ENUM;
|
|
17
|
+
platform: import("../../constants").PLATFORMS_ENUM;
|
|
18
|
+
order_amount: number;
|
|
19
|
+
discount_amount: number;
|
|
20
|
+
reason: string;
|
|
21
|
+
staff_id: string;
|
|
22
|
+
staff_phone: string;
|
|
23
|
+
staff_name: string;
|
|
24
|
+
createdAt_mins: number;
|
|
25
|
+
createdAt: NativeDate;
|
|
26
|
+
updatedAt: NativeDate;
|
|
27
|
+
discount_rate?: number | null | undefined;
|
|
28
|
+
reference_number?: string | null | undefined;
|
|
29
|
+
}, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
|
|
30
|
+
createdAt: NativeDate;
|
|
31
|
+
updatedAt: NativeDate;
|
|
32
|
+
} & {
|
|
33
|
+
_id: import("mongoose").Types.ObjectId;
|
|
34
|
+
type: import("../../constants").DISCOUNT_TYPE_ENUM;
|
|
35
|
+
name: string;
|
|
36
|
+
tenant_id: string;
|
|
37
|
+
order_id: import("mongoose").Types.ObjectId;
|
|
38
|
+
discount_id: string;
|
|
39
|
+
applicability: import("../../constants").DISCOUNT_APPLICABILITY_ENUM;
|
|
40
|
+
platform: import("../../constants").PLATFORMS_ENUM;
|
|
41
|
+
order_amount: number;
|
|
42
|
+
discount_amount: number;
|
|
43
|
+
reason: string;
|
|
44
|
+
staff_id: string;
|
|
45
|
+
staff_phone: string;
|
|
46
|
+
staff_name: string;
|
|
47
|
+
createdAt_mins: number;
|
|
48
|
+
createdAt: NativeDate;
|
|
49
|
+
updatedAt: NativeDate;
|
|
50
|
+
discount_rate?: number | null | undefined;
|
|
51
|
+
reference_number?: string | null | undefined;
|
|
52
|
+
}>> & import("mongoose").FlatRecord<{
|
|
53
|
+
createdAt: NativeDate;
|
|
54
|
+
updatedAt: NativeDate;
|
|
55
|
+
} & {
|
|
56
|
+
_id: import("mongoose").Types.ObjectId;
|
|
57
|
+
type: import("../../constants").DISCOUNT_TYPE_ENUM;
|
|
58
|
+
name: string;
|
|
59
|
+
tenant_id: string;
|
|
60
|
+
order_id: import("mongoose").Types.ObjectId;
|
|
61
|
+
discount_id: string;
|
|
62
|
+
applicability: import("../../constants").DISCOUNT_APPLICABILITY_ENUM;
|
|
63
|
+
platform: import("../../constants").PLATFORMS_ENUM;
|
|
64
|
+
order_amount: number;
|
|
65
|
+
discount_amount: number;
|
|
66
|
+
reason: string;
|
|
67
|
+
staff_id: string;
|
|
68
|
+
staff_phone: string;
|
|
69
|
+
staff_name: string;
|
|
70
|
+
createdAt_mins: number;
|
|
71
|
+
createdAt: NativeDate;
|
|
72
|
+
updatedAt: NativeDate;
|
|
73
|
+
discount_rate?: number | null | undefined;
|
|
74
|
+
reference_number?: string | null | undefined;
|
|
75
|
+
}> & Required<{
|
|
76
|
+
_id: import("mongoose").Types.ObjectId;
|
|
77
|
+
}> & {
|
|
78
|
+
__v: number;
|
|
79
|
+
}>;
|
|
80
|
+
export declare const APPLIED_ORDER_DISCOUNTS_COLLECTION_NAME = "applied_order_discounts";
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.APPLIED_ORDER_DISCOUNTS_COLLECTION_NAME = exports.AppliedOrderDiscountsSchema = void 0;
|
|
4
|
+
const mongoose_1 = require("mongoose");
|
|
5
|
+
const constants_1 = require("../../constants");
|
|
6
|
+
exports.AppliedOrderDiscountsSchema = new mongoose_1.Schema({
|
|
7
|
+
_id: {
|
|
8
|
+
type: mongoose_1.Schema.Types.ObjectId,
|
|
9
|
+
required: true,
|
|
10
|
+
immutable: true,
|
|
11
|
+
},
|
|
12
|
+
tenant_id: {
|
|
13
|
+
type: String,
|
|
14
|
+
required: true,
|
|
15
|
+
immutable: true,
|
|
16
|
+
ref: 'tenants',
|
|
17
|
+
},
|
|
18
|
+
order_id: {
|
|
19
|
+
type: mongoose_1.Schema.Types.ObjectId,
|
|
20
|
+
required: true,
|
|
21
|
+
immutable: true,
|
|
22
|
+
},
|
|
23
|
+
discount_id: {
|
|
24
|
+
type: String,
|
|
25
|
+
required: true,
|
|
26
|
+
},
|
|
27
|
+
type: {
|
|
28
|
+
type: String,
|
|
29
|
+
required: true,
|
|
30
|
+
enum: constants_1.ALL_DISCOUNT_TYPES,
|
|
31
|
+
},
|
|
32
|
+
applicability: {
|
|
33
|
+
type: String,
|
|
34
|
+
required: true,
|
|
35
|
+
enum: constants_1.ALL_DISCOUNT_APPLICABILITY_TYPES,
|
|
36
|
+
},
|
|
37
|
+
platform: {
|
|
38
|
+
type: String,
|
|
39
|
+
enum: constants_1.ALL_PLATFORMS,
|
|
40
|
+
required: true,
|
|
41
|
+
},
|
|
42
|
+
name: {
|
|
43
|
+
type: String,
|
|
44
|
+
required: true,
|
|
45
|
+
},
|
|
46
|
+
order_amount: {
|
|
47
|
+
type: Number,
|
|
48
|
+
required: true,
|
|
49
|
+
min: 0,
|
|
50
|
+
},
|
|
51
|
+
discount_amount: {
|
|
52
|
+
type: Number,
|
|
53
|
+
required: true,
|
|
54
|
+
min: 0,
|
|
55
|
+
},
|
|
56
|
+
discount_rate: {
|
|
57
|
+
type: Number,
|
|
58
|
+
required: false,
|
|
59
|
+
default: null,
|
|
60
|
+
},
|
|
61
|
+
reason: {
|
|
62
|
+
type: String,
|
|
63
|
+
required: true,
|
|
64
|
+
},
|
|
65
|
+
reference_number: {
|
|
66
|
+
type: String,
|
|
67
|
+
required: false,
|
|
68
|
+
},
|
|
69
|
+
staff_id: {
|
|
70
|
+
type: String,
|
|
71
|
+
required: true,
|
|
72
|
+
},
|
|
73
|
+
staff_phone: {
|
|
74
|
+
type: String,
|
|
75
|
+
required: true,
|
|
76
|
+
},
|
|
77
|
+
staff_name: {
|
|
78
|
+
type: String,
|
|
79
|
+
required: true,
|
|
80
|
+
},
|
|
81
|
+
createdAt_mins: {
|
|
82
|
+
type: Number,
|
|
83
|
+
required: true,
|
|
84
|
+
immutable: true,
|
|
85
|
+
default: () => {
|
|
86
|
+
const date = new Date();
|
|
87
|
+
return Math.floor(date.getHours() * 60 + date.getMinutes());
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
createdAt: {
|
|
91
|
+
type: mongoose_1.Schema.Types.Date,
|
|
92
|
+
required: true,
|
|
93
|
+
default: () => new Date(),
|
|
94
|
+
immutable: true,
|
|
95
|
+
},
|
|
96
|
+
updatedAt: {
|
|
97
|
+
type: mongoose_1.Schema.Types.Date,
|
|
98
|
+
required: true,
|
|
99
|
+
default: () => new Date(),
|
|
100
|
+
},
|
|
101
|
+
}, {
|
|
102
|
+
timestamps: true,
|
|
103
|
+
versionKey: false,
|
|
104
|
+
minimize: false,
|
|
105
|
+
});
|
|
106
|
+
exports.APPLIED_ORDER_DISCOUNTS_COLLECTION_NAME = 'applied_order_discounts';
|
|
@@ -27,24 +27,26 @@ export * from './item_transactions';
|
|
|
27
27
|
export * from './items';
|
|
28
28
|
export * from './marketing_fingerprints';
|
|
29
29
|
export * from './materialized_credit_bills';
|
|
30
|
-
export * from './
|
|
31
|
-
export * from './
|
|
32
|
-
export * from './materialized_tenant_discount_sources';
|
|
30
|
+
export * from './materialized_report_drilldown_rows';
|
|
31
|
+
export * from './materialized_rider_daily_reports';
|
|
33
32
|
export * from './materialized_tenant_cash_entries';
|
|
33
|
+
export * from './materialized_tenant_cash_reports';
|
|
34
34
|
export * from './materialized_tenant_delivery_entries';
|
|
35
|
+
export * from './materialized_tenant_delivery_geo_cells';
|
|
36
|
+
export * from './materialized_tenant_delivery_geo_scopes';
|
|
35
37
|
export * from './materialized_tenant_delivery_reports';
|
|
36
|
-
export * from './
|
|
37
|
-
export * from './
|
|
38
|
+
export * from './materialized_tenant_discount_entries';
|
|
39
|
+
export * from './materialized_tenant_discount_reports';
|
|
40
|
+
export * from './materialized_tenant_discount_sources';
|
|
41
|
+
export * from './materialized_tenant_hourly_comparison_entries';
|
|
42
|
+
export * from './materialized_tenant_hourly_comparison_reports';
|
|
43
|
+
export * from './materialized_tenant_payments_comparison_entries';
|
|
44
|
+
export * from './materialized_tenant_payments_comparison_reports';
|
|
38
45
|
export * from './materialized_tenant_prep_time_entries';
|
|
39
46
|
export * from './materialized_tenant_prep_time_reports';
|
|
40
47
|
export * from './materialized_tenant_reports_iterations';
|
|
41
|
-
export * from './materialized_report_drilldown_rows';
|
|
42
48
|
export * from './materialized_tenant_sales_comparison_entries';
|
|
43
49
|
export * from './materialized_tenant_sales_comparison_reports';
|
|
44
|
-
export * from './materialized_tenant_hourly_comparison_entries';
|
|
45
|
-
export * from './materialized_tenant_hourly_comparison_reports';
|
|
46
|
-
export * from './materialized_tenant_payments_comparison_entries';
|
|
47
|
-
export * from './materialized_tenant_payments_comparison_reports';
|
|
48
50
|
export * from './materialized_tenant_sales_overview_reports';
|
|
49
51
|
export * from './menus';
|
|
50
52
|
export * from './messaging_devices';
|
|
@@ -43,24 +43,26 @@ __exportStar(require("./item_transactions"), exports);
|
|
|
43
43
|
__exportStar(require("./items"), exports);
|
|
44
44
|
__exportStar(require("./marketing_fingerprints"), exports);
|
|
45
45
|
__exportStar(require("./materialized_credit_bills"), exports);
|
|
46
|
-
__exportStar(require("./
|
|
47
|
-
__exportStar(require("./
|
|
48
|
-
__exportStar(require("./materialized_tenant_discount_sources"), exports);
|
|
46
|
+
__exportStar(require("./materialized_report_drilldown_rows"), exports);
|
|
47
|
+
__exportStar(require("./materialized_rider_daily_reports"), exports);
|
|
49
48
|
__exportStar(require("./materialized_tenant_cash_entries"), exports);
|
|
49
|
+
__exportStar(require("./materialized_tenant_cash_reports"), exports);
|
|
50
50
|
__exportStar(require("./materialized_tenant_delivery_entries"), exports);
|
|
51
|
+
__exportStar(require("./materialized_tenant_delivery_geo_cells"), exports);
|
|
52
|
+
__exportStar(require("./materialized_tenant_delivery_geo_scopes"), exports);
|
|
51
53
|
__exportStar(require("./materialized_tenant_delivery_reports"), exports);
|
|
52
|
-
__exportStar(require("./
|
|
53
|
-
__exportStar(require("./
|
|
54
|
+
__exportStar(require("./materialized_tenant_discount_entries"), exports);
|
|
55
|
+
__exportStar(require("./materialized_tenant_discount_reports"), exports);
|
|
56
|
+
__exportStar(require("./materialized_tenant_discount_sources"), exports);
|
|
57
|
+
__exportStar(require("./materialized_tenant_hourly_comparison_entries"), exports);
|
|
58
|
+
__exportStar(require("./materialized_tenant_hourly_comparison_reports"), exports);
|
|
59
|
+
__exportStar(require("./materialized_tenant_payments_comparison_entries"), exports);
|
|
60
|
+
__exportStar(require("./materialized_tenant_payments_comparison_reports"), exports);
|
|
54
61
|
__exportStar(require("./materialized_tenant_prep_time_entries"), exports);
|
|
55
62
|
__exportStar(require("./materialized_tenant_prep_time_reports"), exports);
|
|
56
63
|
__exportStar(require("./materialized_tenant_reports_iterations"), exports);
|
|
57
|
-
__exportStar(require("./materialized_report_drilldown_rows"), exports);
|
|
58
64
|
__exportStar(require("./materialized_tenant_sales_comparison_entries"), exports);
|
|
59
65
|
__exportStar(require("./materialized_tenant_sales_comparison_reports"), exports);
|
|
60
|
-
__exportStar(require("./materialized_tenant_hourly_comparison_entries"), exports);
|
|
61
|
-
__exportStar(require("./materialized_tenant_hourly_comparison_reports"), exports);
|
|
62
|
-
__exportStar(require("./materialized_tenant_payments_comparison_entries"), exports);
|
|
63
|
-
__exportStar(require("./materialized_tenant_payments_comparison_reports"), exports);
|
|
64
66
|
__exportStar(require("./materialized_tenant_sales_overview_reports"), exports);
|
|
65
67
|
__exportStar(require("./menus"), exports);
|
|
66
68
|
__exportStar(require("./messaging_devices"), exports);
|
|
@@ -2,11 +2,22 @@ import { Schema } from 'mongoose';
|
|
|
2
2
|
/**
|
|
3
3
|
* Mongoose schema for `materialized_tenant_delivery_entries` (M4).
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* PAGE-PARTITIONED by source day, exactly like the discounts entries: the day scope uses
|
|
6
|
+
* `page='all'`, and every period entry scope (week / ISO week / month) uses
|
|
7
|
+
* `page=<source localDate>`, so a document is bounded by ONE day's rows. Quarter /
|
|
8
|
+
* semester / year entry documents do not exist.
|
|
9
|
+
*
|
|
10
|
+
* `delivery_entries` is `Mixed` on purpose: it is a key-addressed map of rows whose keys
|
|
11
|
+
* are the report's `ORDER_STATUS:PLATFORM:CITY` grammar, which Mongoose cannot type precisely without
|
|
12
|
+
* a fixed key set - the keys ARE the data.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* v3 - PAGE-PARTITIONED entry documents (one page per source day, max scope
|
|
16
|
+
* `localMonth`). v2 was one document per period scope, which made a month an unbounded
|
|
17
|
+
* document. Historical v2 documents are not readable by the page-aware read layer and
|
|
18
|
+
* must be re-materialized (re-close the days); the writer deletes the pages it owns.
|
|
8
19
|
*/
|
|
9
|
-
export declare const MATERIALIZED_TENANT_DELIVERY_ENTRIES_SCHEMA_VERSION =
|
|
20
|
+
export declare const MATERIALIZED_TENANT_DELIVERY_ENTRIES_SCHEMA_VERSION = 3;
|
|
10
21
|
export declare const MaterializedTenantDeliveryEntriesSchema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
11
22
|
timestamps: true;
|
|
12
23
|
versionKey: false;
|
|
@@ -28,6 +39,7 @@ export declare const MaterializedTenantDeliveryEntriesSchema: Schema<any, import
|
|
|
28
39
|
source_watermark: NativeDate;
|
|
29
40
|
computed_at: NativeDate;
|
|
30
41
|
off_app_order_count: number;
|
|
42
|
+
page: string;
|
|
31
43
|
delivery_entries?: any;
|
|
32
44
|
}, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
|
|
33
45
|
createdAt: NativeDate;
|
|
@@ -46,6 +58,7 @@ export declare const MaterializedTenantDeliveryEntriesSchema: Schema<any, import
|
|
|
46
58
|
source_watermark: NativeDate;
|
|
47
59
|
computed_at: NativeDate;
|
|
48
60
|
off_app_order_count: number;
|
|
61
|
+
page: string;
|
|
49
62
|
delivery_entries?: any;
|
|
50
63
|
}>> & import("mongoose").FlatRecord<{
|
|
51
64
|
createdAt: NativeDate;
|
|
@@ -64,6 +77,7 @@ export declare const MaterializedTenantDeliveryEntriesSchema: Schema<any, import
|
|
|
64
77
|
source_watermark: NativeDate;
|
|
65
78
|
computed_at: NativeDate;
|
|
66
79
|
off_app_order_count: number;
|
|
80
|
+
page: string;
|
|
67
81
|
delivery_entries?: any;
|
|
68
82
|
}> & {
|
|
69
83
|
_id: import("mongoose").Types.ObjectId;
|
|
@@ -72,18 +86,26 @@ export declare const MaterializedTenantDeliveryEntriesSchema: Schema<any, import
|
|
|
72
86
|
}>;
|
|
73
87
|
export declare const MATERIALIZED_TENANT_DELIVERY_ENTRIES_COLLECTION_NAME = "materialized_tenant_delivery_entries";
|
|
74
88
|
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
89
|
+
* ONE unique index per PAGE: `tenant_id + scope_context + scope_field + page`.
|
|
90
|
+
*
|
|
91
|
+
* The OLD index `{ tenant_id, scope_context, scope_field, day_index }` must NOT survive:
|
|
92
|
+
* period pages all carry `day_index: null`, so it would reject the second page of a
|
|
93
|
+
* month. The OWNER deploy step
|
|
94
|
+
* (`simulations/migrate-delivery-report-indexes.ts --apply`) drops the legacy index by
|
|
95
|
+
* name/key before creating this one. No service calls `ensureMaterializedReportIndexes`
|
|
96
|
+
* automatically; the discounts entry collection has the same migration posture.
|
|
97
|
+
*
|
|
98
|
+
* The same key also serves the multi-page read (tenant + scope prefix, then the pages).
|
|
77
99
|
*/
|
|
78
100
|
export declare const MATERIALIZED_TENANT_DELIVERY_ENTRIES_COLLECTION_INDEXES: {
|
|
79
101
|
_id: {
|
|
80
102
|
_id: number;
|
|
81
103
|
};
|
|
82
|
-
|
|
104
|
+
tenant_id__scope_context__scope_field__page: {
|
|
83
105
|
tenant_id: number;
|
|
84
106
|
scope_context: number;
|
|
85
107
|
scope_field: number;
|
|
86
|
-
|
|
108
|
+
page: number;
|
|
87
109
|
};
|
|
88
110
|
};
|
|
89
111
|
export declare const MATERIALIZED_TENANT_DELIVERY_ENTRIES_INDEX_OPTIONS: {
|
|
@@ -91,7 +113,7 @@ export declare const MATERIALIZED_TENANT_DELIVERY_ENTRIES_INDEX_OPTIONS: {
|
|
|
91
113
|
tenant_id: number;
|
|
92
114
|
scope_context: number;
|
|
93
115
|
scope_field: number;
|
|
94
|
-
|
|
116
|
+
page: number;
|
|
95
117
|
};
|
|
96
118
|
name: string;
|
|
97
119
|
unique: boolean;
|
|
@@ -7,16 +7,29 @@ const MATERIALIZED_REPORTS_1 = require("../../constants/MATERIALIZED_REPORTS");
|
|
|
7
7
|
/**
|
|
8
8
|
* Mongoose schema for `materialized_tenant_delivery_entries` (M4).
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* PAGE-PARTITIONED by source day, exactly like the discounts entries: the day scope uses
|
|
11
|
+
* `page='all'`, and every period entry scope (week / ISO week / month) uses
|
|
12
|
+
* `page=<source localDate>`, so a document is bounded by ONE day's rows. Quarter /
|
|
13
|
+
* semester / year entry documents do not exist.
|
|
14
|
+
*
|
|
15
|
+
* `delivery_entries` is `Mixed` on purpose: it is a key-addressed map of rows whose keys
|
|
16
|
+
* are the report's `ORDER_STATUS:PLATFORM:CITY` grammar, which Mongoose cannot type precisely without
|
|
17
|
+
* a fixed key set - the keys ARE the data.
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* v3 - PAGE-PARTITIONED entry documents (one page per source day, max scope
|
|
21
|
+
* `localMonth`). v2 was one document per period scope, which made a month an unbounded
|
|
22
|
+
* document. Historical v2 documents are not readable by the page-aware read layer and
|
|
23
|
+
* must be re-materialized (re-close the days); the writer deletes the pages it owns.
|
|
13
24
|
*/
|
|
14
|
-
exports.MATERIALIZED_TENANT_DELIVERY_ENTRIES_SCHEMA_VERSION =
|
|
25
|
+
exports.MATERIALIZED_TENANT_DELIVERY_ENTRIES_SCHEMA_VERSION = 3;
|
|
15
26
|
exports.MaterializedTenantDeliveryEntriesSchema = new mongoose_1.Schema({
|
|
16
27
|
tenant_id: { type: String, required: true },
|
|
17
28
|
brand_id: { type: String, required: true },
|
|
18
|
-
scope_context: { type: String, required: true, enum: MATERIALIZED_REPORTS_1.
|
|
29
|
+
scope_context: { type: String, required: true, enum: MATERIALIZED_REPORTS_1.MATERIALIZED_DELIVERY_ENTRY_SCOPES },
|
|
19
30
|
scope_field: { type: String, required: true },
|
|
31
|
+
/** `'all'` for the day scope; the source `YYYY-MM-DD` for a period scope. */
|
|
32
|
+
page: { type: String, required: true, immutable: true },
|
|
20
33
|
day_index: { type: String, default: null, enum: [...ENUMS_1.ALL_DAY_INDEX, null] },
|
|
21
34
|
sale_type_key_filters: {
|
|
22
35
|
type: [String],
|
|
@@ -45,22 +58,30 @@ exports.MaterializedTenantDeliveryEntriesSchema = new mongoose_1.Schema({
|
|
|
45
58
|
}, { timestamps: true, versionKey: false, minimize: false });
|
|
46
59
|
exports.MATERIALIZED_TENANT_DELIVERY_ENTRIES_COLLECTION_NAME = 'materialized_tenant_delivery_entries';
|
|
47
60
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
61
|
+
* ONE unique index per PAGE: `tenant_id + scope_context + scope_field + page`.
|
|
62
|
+
*
|
|
63
|
+
* The OLD index `{ tenant_id, scope_context, scope_field, day_index }` must NOT survive:
|
|
64
|
+
* period pages all carry `day_index: null`, so it would reject the second page of a
|
|
65
|
+
* month. The OWNER deploy step
|
|
66
|
+
* (`simulations/migrate-delivery-report-indexes.ts --apply`) drops the legacy index by
|
|
67
|
+
* name/key before creating this one. No service calls `ensureMaterializedReportIndexes`
|
|
68
|
+
* automatically; the discounts entry collection has the same migration posture.
|
|
69
|
+
*
|
|
70
|
+
* The same key also serves the multi-page read (tenant + scope prefix, then the pages).
|
|
50
71
|
*/
|
|
51
72
|
exports.MATERIALIZED_TENANT_DELIVERY_ENTRIES_COLLECTION_INDEXES = {
|
|
52
73
|
_id: { _id: 1 },
|
|
53
|
-
|
|
74
|
+
tenant_id__scope_context__scope_field__page: {
|
|
54
75
|
tenant_id: 1,
|
|
55
76
|
scope_context: 1,
|
|
56
77
|
scope_field: 1,
|
|
57
|
-
|
|
78
|
+
page: 1,
|
|
58
79
|
},
|
|
59
80
|
};
|
|
60
81
|
exports.MATERIALIZED_TENANT_DELIVERY_ENTRIES_INDEX_OPTIONS = [
|
|
61
82
|
{
|
|
62
|
-
key: { tenant_id: 1, scope_context: 1, scope_field: 1,
|
|
63
|
-
name: '
|
|
83
|
+
key: { tenant_id: 1, scope_context: 1, scope_field: 1, page: 1 },
|
|
84
|
+
name: 'tenant_id__scope_context__scope_field__page',
|
|
64
85
|
unique: true,
|
|
65
86
|
},
|
|
66
87
|
];
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { Schema } from 'mongoose';
|
|
2
|
+
/**
|
|
3
|
+
* Mongoose schema for `materialized_tenant_delivery_geo_cells`.
|
|
4
|
+
*
|
|
5
|
+
* `location` is `Mixed` and DELIBERATELY has no default: the unknown bucket must be
|
|
6
|
+
* written WITHOUT the field, because a 2dsphere index cannot extract a geo key from
|
|
7
|
+
* `null`. A missing field is simply not indexed, which is exactly the intent - the
|
|
8
|
+
* unknown aggregate must never be plottable.
|
|
9
|
+
*
|
|
10
|
+
* `city` is nullable: an order whose joined `delivery_details` has no city still
|
|
11
|
+
* counts in the cell (the position is what the heat map plots), it just carries no
|
|
12
|
+
* label.
|
|
13
|
+
*/
|
|
14
|
+
export declare const MaterializedTenantDeliveryGeoCellSchema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
15
|
+
timestamps: true;
|
|
16
|
+
versionKey: false;
|
|
17
|
+
}, {
|
|
18
|
+
createdAt: NativeDate;
|
|
19
|
+
updatedAt: NativeDate;
|
|
20
|
+
} & {
|
|
21
|
+
createdAt: NativeDate;
|
|
22
|
+
updatedAt: NativeDate;
|
|
23
|
+
brand_id: string;
|
|
24
|
+
tenant_id: string;
|
|
25
|
+
city: string;
|
|
26
|
+
orders: number;
|
|
27
|
+
scope_context: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_REPORT_SCOPE_ENUM;
|
|
28
|
+
scope_field: string;
|
|
29
|
+
schema_version: number;
|
|
30
|
+
computed_at: NativeDate;
|
|
31
|
+
resolution: number;
|
|
32
|
+
h3_cell: string;
|
|
33
|
+
app_orders: number;
|
|
34
|
+
delivery_records: number;
|
|
35
|
+
completed: number;
|
|
36
|
+
cancelled: number;
|
|
37
|
+
net_sale_amount: number;
|
|
38
|
+
delivery_charge_amount: number;
|
|
39
|
+
rider_revenue_amount: number;
|
|
40
|
+
location?: any;
|
|
41
|
+
by_key?: any;
|
|
42
|
+
}, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
|
|
43
|
+
createdAt: NativeDate;
|
|
44
|
+
updatedAt: NativeDate;
|
|
45
|
+
} & {
|
|
46
|
+
createdAt: NativeDate;
|
|
47
|
+
updatedAt: NativeDate;
|
|
48
|
+
brand_id: string;
|
|
49
|
+
tenant_id: string;
|
|
50
|
+
city: string;
|
|
51
|
+
orders: number;
|
|
52
|
+
scope_context: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_REPORT_SCOPE_ENUM;
|
|
53
|
+
scope_field: string;
|
|
54
|
+
schema_version: number;
|
|
55
|
+
computed_at: NativeDate;
|
|
56
|
+
resolution: number;
|
|
57
|
+
h3_cell: string;
|
|
58
|
+
app_orders: number;
|
|
59
|
+
delivery_records: number;
|
|
60
|
+
completed: number;
|
|
61
|
+
cancelled: number;
|
|
62
|
+
net_sale_amount: number;
|
|
63
|
+
delivery_charge_amount: number;
|
|
64
|
+
rider_revenue_amount: number;
|
|
65
|
+
location?: any;
|
|
66
|
+
by_key?: any;
|
|
67
|
+
}>> & import("mongoose").FlatRecord<{
|
|
68
|
+
createdAt: NativeDate;
|
|
69
|
+
updatedAt: NativeDate;
|
|
70
|
+
} & {
|
|
71
|
+
createdAt: NativeDate;
|
|
72
|
+
updatedAt: NativeDate;
|
|
73
|
+
brand_id: string;
|
|
74
|
+
tenant_id: string;
|
|
75
|
+
city: string;
|
|
76
|
+
orders: number;
|
|
77
|
+
scope_context: import("../../constants/MATERIALIZED_REPORTS").MATERIALIZED_REPORT_SCOPE_ENUM;
|
|
78
|
+
scope_field: string;
|
|
79
|
+
schema_version: number;
|
|
80
|
+
computed_at: NativeDate;
|
|
81
|
+
resolution: number;
|
|
82
|
+
h3_cell: string;
|
|
83
|
+
app_orders: number;
|
|
84
|
+
delivery_records: number;
|
|
85
|
+
completed: number;
|
|
86
|
+
cancelled: number;
|
|
87
|
+
net_sale_amount: number;
|
|
88
|
+
delivery_charge_amount: number;
|
|
89
|
+
rider_revenue_amount: number;
|
|
90
|
+
location?: any;
|
|
91
|
+
by_key?: any;
|
|
92
|
+
}> & {
|
|
93
|
+
_id: import("mongoose").Types.ObjectId;
|
|
94
|
+
} & {
|
|
95
|
+
__v: number;
|
|
96
|
+
}>;
|
|
97
|
+
export declare const MATERIALIZED_TENANT_DELIVERY_GEO_CELLS_COLLECTION_NAME = "materialized_tenant_delivery_geo_cells";
|
|
98
|
+
/**
|
|
99
|
+
* The indexes the heat reads/writes assume:
|
|
100
|
+
* 1. the UNIQUE cell identity (one document per tenant/scope/cell);
|
|
101
|
+
* 2. the map's read path - a scope, busiest cells first;
|
|
102
|
+
* 3. the 2dsphere index a future viewport `$geoWithin` read needs.
|
|
103
|
+
*
|
|
104
|
+
* The unknown bucket has no `location`, so it is absent from (3) by design.
|
|
105
|
+
*/
|
|
106
|
+
export declare const MATERIALIZED_TENANT_DELIVERY_GEO_CELLS_COLLECTION_INDEXES: {
|
|
107
|
+
_id: {
|
|
108
|
+
_id: number;
|
|
109
|
+
};
|
|
110
|
+
tenant_id__scope_context__scope_field__h3_cell: {
|
|
111
|
+
tenant_id: number;
|
|
112
|
+
scope_context: number;
|
|
113
|
+
scope_field: number;
|
|
114
|
+
h3_cell: number;
|
|
115
|
+
};
|
|
116
|
+
scope_context__scope_field__orders: {
|
|
117
|
+
scope_context: number;
|
|
118
|
+
scope_field: number;
|
|
119
|
+
orders: number;
|
|
120
|
+
};
|
|
121
|
+
location__2dsphere: {
|
|
122
|
+
location: string;
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
export declare const MATERIALIZED_TENANT_DELIVERY_GEO_CELLS_INDEX_OPTIONS: ReadonlyArray<{
|
|
126
|
+
key: Record<string, number | string>;
|
|
127
|
+
name: string;
|
|
128
|
+
unique?: boolean;
|
|
129
|
+
}>;
|