@aglyn/plugins-commerce 1.33.2 → 1.34.1
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/package.json +13 -13
- package/src/lib/components/cart.js +3 -1
- package/src/lib/components/cart.js.map +1 -1
- package/src/lib/components/console/catalog-organization-card.component.js +82 -69
- package/src/lib/components/console/catalog-organization-card.component.js.map +1 -1
- package/src/lib/components/console/discounts-card.component.js +46 -25
- package/src/lib/components/console/discounts-card.component.js.map +1 -1
- package/src/lib/components/console/gift-cards-card.component.js +81 -55
- package/src/lib/components/console/gift-cards-card.component.js.map +1 -1
- package/src/lib/components/console/host-coupons-card.component.js +36 -25
- package/src/lib/components/console/host-coupons-card.component.js.map +1 -1
- package/src/lib/components/console/locations-card.component.js +53 -32
- package/src/lib/components/console/locations-card.component.js.map +1 -1
- package/src/lib/components/console/member-posts-card.component.js +35 -32
- package/src/lib/components/console/member-posts-card.component.js.map +1 -1
- package/src/lib/components/console/new-store-tax-question.component.d.ts +17 -0
- package/src/lib/components/console/new-store-tax-question.component.js +197 -0
- package/src/lib/components/console/new-store-tax-question.component.js.map +1 -0
- package/src/lib/components/console/payments-settings-card.component.js +132 -5
- package/src/lib/components/console/payments-settings-card.component.js.map +1 -1
- package/src/lib/components/console/pos/pos-api.d.ts +6 -0
- package/src/lib/components/console/pos/pos-api.js.map +1 -1
- package/src/lib/components/console/pos/pos-tax-notice.component.d.ts +21 -0
- package/src/lib/components/console/pos/pos-tax-notice.component.js +59 -0
- package/src/lib/components/console/pos/pos-tax-notice.component.js.map +1 -0
- package/src/lib/components/console/pos-page.component.js +65 -17
- package/src/lib/components/console/pos-page.component.js.map +1 -1
- package/src/lib/components/console/registers-card.component.js +21 -13
- package/src/lib/components/console/registers-card.component.js.map +1 -1
- package/src/lib/components/console/reviews-moderation-card.component.js +108 -68
- package/src/lib/components/console/reviews-moderation-card.component.js.map +1 -1
- package/src/lib/components/console/site-member-purchases.component.js +5 -3
- package/src/lib/components/console/site-member-purchases.component.js.map +1 -1
- package/src/lib/components/console/subscription-detail-dialog.component.d.ts +2 -0
- package/src/lib/components/console/subscription-detail-dialog.component.js +1 -1
- package/src/lib/components/console/subscription-detail-dialog.component.js.map +1 -1
- package/src/lib/components/console/subscriptions-card.component.js +13 -5
- package/src/lib/components/console/subscriptions-card.component.js.map +1 -1
- package/src/lib/components/console/suppliers-card.component.js +47 -40
- package/src/lib/components/console/suppliers-card.component.js.map +1 -1
- package/src/lib/components/product-choice-cards.js +2 -1
- package/src/lib/components/product-choice-cards.js.map +1 -1
- package/src/lib/components/product-detail.js +9 -4
- package/src/lib/components/product-detail.js.map +1 -1
- package/src/lib/components/product-grid.js +3 -1
- package/src/lib/components/product-grid.js.map +1 -1
- package/src/lib/components/related-products.js +2 -1
- package/src/lib/components/related-products.js.map +1 -1
- package/src/lib/components/store-image-sizing.d.ts +46 -0
- package/src/lib/components/store-image-sizing.js +53 -0
- package/src/lib/components/store-image-sizing.js.map +1 -0
- package/src/lib/components/wishlist.js +2 -1
- package/src/lib/components/wishlist.js.map +1 -1
- package/src/lib/declarations.console-server.js +10 -0
- package/src/lib/declarations.console-server.js.map +1 -1
- package/src/lib/model/commerce-tax-step.d.ts +123 -0
- package/src/lib/model/commerce-tax-step.js +185 -0
- package/src/lib/model/commerce-tax-step.js.map +1 -0
- package/src/lib/model/index.d.ts +1 -0
- package/src/lib/model/index.js +1 -0
- package/src/lib/model/index.js.map +1 -1
- package/src/lib/model/payments-setup-status.d.ts +40 -0
- package/src/lib/model/payments-setup-status.js +63 -0
- package/src/lib/model/payments-setup-status.js.map +1 -1
- package/src/lib/model/subscription-view.d.ts +19 -0
- package/src/lib/model/subscription-view.js +16 -0
- package/src/lib/model/subscription-view.js.map +1 -1
- package/src/lib/model/tap-to-pay-launch.d.ts +103 -0
- package/src/lib/model/tap-to-pay-launch.js +148 -0
- package/src/lib/model/tap-to-pay-launch.js.map +1 -0
- package/src/lib/plugin.js +12 -0
- package/src/lib/plugin.js.map +1 -1
- package/src/lib/server/billing-webhook.js +140 -116
- package/src/lib/server/billing-webhook.js.map +1 -1
- package/src/lib/server/checkout.js +15 -4
- package/src/lib/server/checkout.js.map +1 -1
- package/src/lib/server/connect-return.d.ts +83 -0
- package/src/lib/server/connect-return.js +105 -0
- package/src/lib/server/connect-return.js.map +1 -0
- package/src/lib/server/connect.d.ts +18 -0
- package/src/lib/server/connect.js +60 -6
- package/src/lib/server/connect.js.map +1 -1
- package/src/lib/server/new-store-tax.d.ts +10 -0
- package/src/lib/server/new-store-tax.js +43 -0
- package/src/lib/server/new-store-tax.js.map +1 -0
- package/src/lib/server/pos-payment.js +3 -2
- package/src/lib/server/pos-payment.js.map +1 -1
- package/src/lib/server/pos-tax-step.d.ts +43 -0
- package/src/lib/server/pos-tax-step.js +55 -0
- package/src/lib/server/pos-tax-step.js.map +1 -0
- package/src/lib/server/pos-terminal-connection-token.d.ts +10 -1
- package/src/lib/server/pos-terminal-connection-token.js +18 -7
- package/src/lib/server/pos-terminal-connection-token.js.map +1 -1
- package/src/lib/server/pos-terminal.d.ts +9 -0
- package/src/lib/server/pos-terminal.js +17 -1
- package/src/lib/server/pos-terminal.js.map +1 -1
- package/src/lib/server/site-page-resolver.d.ts +8 -0
- package/src/lib/server/site-page-resolver.js +21 -3
- package/src/lib/server/site-page-resolver.js.map +1 -1
- package/src/lib/server/tap-to-pay-launch-admin.d.ts +18 -0
- package/src/lib/server/tap-to-pay-launch-admin.js +204 -0
- package/src/lib/server/tap-to-pay-launch-admin.js.map +1 -0
- package/src/lib/server/tap-to-pay-launch.d.ts +114 -0
- package/src/lib/server/tap-to-pay-launch.js +408 -0
- package/src/lib/server/tap-to-pay-launch.js.map +1 -0
- package/src/lib/server.js +15 -0
- package/src/lib/server.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/model/index.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Commerce domain model (AGL-411): pure types + logic relocated from the\n * core `@aglyn/aglyn` app-utils — the commerce plugin owns its domain.\n * Context-free and framework-free, so both the plugin's client components\n * and its `/server` handlers (and other plugins/apps via\n * `@aglyn/plugins-commerce/model`) can import it.\n */\nexport * from './commerce'\nexport * from './commerce-cart'\nexport * from './commerce-check-in'\nexport * from './commerce-currency'\nexport * from './commerce-currency-setup'\nexport * from './commerce-connect-transfer'\nexport * from './commerce-discounts'\nexport * from './commerce-dispute'\nexport * from './commerce-topics'\nexport * from './commerce-gift-cards'\nexport * from './commerce-orders'\nexport * from './commerce-quotes'\nexport * from './commerce-quote-pay'\nexport * from './commerce-quote-proofs'\nexport * from './commerce-quote-email'\nexport * from './commerce-quote-messages'\nexport * from './commerce-quote-request'\nexport * from './commerce-invoices'\nexport * from './commerce-printers'\nexport * from './commerce-pos'\nexport * from './commerce-pos-offline'\nexport * from './commerce-pos-kiosk'\nexport * from './product-modifiers'\nexport * from './commerce-promotions'\nexport * from './commerce-receipt'\nexport * from './commerce-reservations'\nexport * from './commerce-shipping'\nexport * from './commerce-stock-holds'\nexport * from './commerce-subscription-status'\nexport * from './subscription-view'\nexport * from './commerce-tax'\nexport * from './commerce-tax-decision'\nexport * from './order-figures'\nexport * from './order-list-fields'\nexport * from './purchase-analytics'\nexport * from './tracking-url'\nexport * from './buyer-notifications'\nexport * from './order-fulfillment'\nexport * from './order-local-fulfillment'\nexport * from './local-fulfillment-settings'\nexport * from './order-events'\nexport * from './commerce-returns'\nexport * from './order-shipping-export'\nexport * from './order-status-view'\nexport * from './order-webhooks'\nexport * from './shipstation'\nexport * from './commerce-payment-methods'\nexport * from './product-channel'\nexport * from './order-annotations'\nexport * from './product-write'\nexport * from './product-reviews'\n"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;CAMC,GACD,cAAc,gBAAY;AAC1B,cAAc,qBAAiB;AAC/B,cAAc,yBAAqB;AACnC,cAAc,yBAAqB;AACnC,cAAc,+BAA2B;AACzC,cAAc,iCAA6B;AAC3C,cAAc,0BAAsB;AACpC,cAAc,wBAAoB;AAClC,cAAc,uBAAmB;AACjC,cAAc,2BAAuB;AACrC,cAAc,uBAAmB;AACjC,cAAc,uBAAmB;AACjC,cAAc,0BAAsB;AACpC,cAAc,6BAAyB;AACvC,cAAc,4BAAwB;AACtC,cAAc,+BAA2B;AACzC,cAAc,8BAA0B;AACxC,cAAc,yBAAqB;AACnC,cAAc,yBAAqB;AACnC,cAAc,oBAAgB;AAC9B,cAAc,4BAAwB;AACtC,cAAc,0BAAsB;AACpC,cAAc,yBAAqB;AACnC,cAAc,2BAAuB;AACrC,cAAc,wBAAoB;AAClC,cAAc,6BAAyB;AACvC,cAAc,yBAAqB;AACnC,cAAc,4BAAwB;AACtC,cAAc,oCAAgC;AAC9C,cAAc,yBAAqB;AACnC,cAAc,oBAAgB;AAC9B,cAAc,6BAAyB;AACvC,cAAc,qBAAiB;AAC/B,cAAc,yBAAqB;AACnC,cAAc,0BAAsB;AACpC,cAAc,oBAAgB;AAC9B,cAAc,2BAAuB;AACrC,cAAc,yBAAqB;AACnC,cAAc,+BAA2B;AACzC,cAAc,kCAA8B;AAC5C,cAAc,oBAAgB;AAC9B,cAAc,wBAAoB;AAClC,cAAc,6BAAyB;AACvC,cAAc,yBAAqB;AACnC,cAAc,sBAAkB;AAChC,cAAc,mBAAe;AAC7B,cAAc,gCAA4B;AAC1C,cAAc,uBAAmB;AACjC,cAAc,yBAAqB;AACnC,cAAc,qBAAiB;AAC/B,cAAc,uBAAmB"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/model/index.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Commerce domain model (AGL-411): pure types + logic relocated from the\n * core `@aglyn/aglyn` app-utils — the commerce plugin owns its domain.\n * Context-free and framework-free, so both the plugin's client components\n * and its `/server` handlers (and other plugins/apps via\n * `@aglyn/plugins-commerce/model`) can import it.\n */\nexport * from './commerce'\nexport * from './commerce-cart'\nexport * from './commerce-check-in'\nexport * from './commerce-currency'\nexport * from './commerce-currency-setup'\nexport * from './commerce-connect-transfer'\nexport * from './commerce-discounts'\nexport * from './commerce-dispute'\nexport * from './commerce-topics'\nexport * from './commerce-gift-cards'\nexport * from './commerce-orders'\nexport * from './commerce-quotes'\nexport * from './commerce-quote-pay'\nexport * from './commerce-quote-proofs'\nexport * from './commerce-quote-email'\nexport * from './commerce-quote-messages'\nexport * from './commerce-quote-request'\nexport * from './commerce-invoices'\nexport * from './commerce-printers'\nexport * from './commerce-pos'\nexport * from './commerce-pos-offline'\nexport * from './commerce-pos-kiosk'\nexport * from './product-modifiers'\nexport * from './commerce-promotions'\nexport * from './commerce-receipt'\nexport * from './commerce-reservations'\nexport * from './commerce-shipping'\nexport * from './commerce-stock-holds'\nexport * from './commerce-subscription-status'\nexport * from './subscription-view'\nexport * from './commerce-tax'\nexport * from './commerce-tax-decision'\nexport * from './commerce-tax-step'\nexport * from './order-figures'\nexport * from './order-list-fields'\nexport * from './purchase-analytics'\nexport * from './tracking-url'\nexport * from './buyer-notifications'\nexport * from './order-fulfillment'\nexport * from './order-local-fulfillment'\nexport * from './local-fulfillment-settings'\nexport * from './order-events'\nexport * from './commerce-returns'\nexport * from './order-shipping-export'\nexport * from './order-status-view'\nexport * from './order-webhooks'\nexport * from './shipstation'\nexport * from './commerce-payment-methods'\nexport * from './product-channel'\nexport * from './order-annotations'\nexport * from './product-write'\nexport * from './product-reviews'\n"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;CAMC,GACD,cAAc,gBAAY;AAC1B,cAAc,qBAAiB;AAC/B,cAAc,yBAAqB;AACnC,cAAc,yBAAqB;AACnC,cAAc,+BAA2B;AACzC,cAAc,iCAA6B;AAC3C,cAAc,0BAAsB;AACpC,cAAc,wBAAoB;AAClC,cAAc,uBAAmB;AACjC,cAAc,2BAAuB;AACrC,cAAc,uBAAmB;AACjC,cAAc,uBAAmB;AACjC,cAAc,0BAAsB;AACpC,cAAc,6BAAyB;AACvC,cAAc,4BAAwB;AACtC,cAAc,+BAA2B;AACzC,cAAc,8BAA0B;AACxC,cAAc,yBAAqB;AACnC,cAAc,yBAAqB;AACnC,cAAc,oBAAgB;AAC9B,cAAc,4BAAwB;AACtC,cAAc,0BAAsB;AACpC,cAAc,yBAAqB;AACnC,cAAc,2BAAuB;AACrC,cAAc,wBAAoB;AAClC,cAAc,6BAAyB;AACvC,cAAc,yBAAqB;AACnC,cAAc,4BAAwB;AACtC,cAAc,oCAAgC;AAC9C,cAAc,yBAAqB;AACnC,cAAc,oBAAgB;AAC9B,cAAc,6BAAyB;AACvC,cAAc,yBAAqB;AACnC,cAAc,qBAAiB;AAC/B,cAAc,yBAAqB;AACnC,cAAc,0BAAsB;AACpC,cAAc,oBAAgB;AAC9B,cAAc,2BAAuB;AACrC,cAAc,yBAAqB;AACnC,cAAc,+BAA2B;AACzC,cAAc,kCAA8B;AAC5C,cAAc,oBAAgB;AAC9B,cAAc,wBAAoB;AAClC,cAAc,6BAAyB;AACvC,cAAc,yBAAqB;AACnC,cAAc,sBAAkB;AAChC,cAAc,mBAAe;AAC7B,cAAc,gCAA4B;AAC1C,cAAc,uBAAmB;AACjC,cAAc,yBAAqB;AACnC,cAAc,qBAAiB;AAC/B,cAAc,uBAAmB"}
|
|
@@ -66,3 +66,43 @@ export declare function paymentsRequirementsNotice(profile: PaymentsSetupProfile
|
|
|
66
66
|
* Stripe's update lands.
|
|
67
67
|
*/
|
|
68
68
|
export declare function paymentsReturnResult(profile: PaymentsSetupProfile | null | undefined, ready: boolean): PaymentsSetupNotice;
|
|
69
|
+
/**
|
|
70
|
+
* ASKING STRIPE AGAIN WHILE IT CHECKS (AGL-4061), the same schedule as the
|
|
71
|
+
* apps' Card readers and Payments screens: quick at first, then every 30
|
|
72
|
+
* seconds, for up to 15 minutes, while the page is in view. The connect
|
|
73
|
+
* route's `sync` answers what Stripe says now and records it on the profile,
|
|
74
|
+
* so the card never waits on the `account.updated` webhook.
|
|
75
|
+
*/
|
|
76
|
+
/** The first waits, about a minute and a half in all, which is usually enough. */
|
|
77
|
+
export declare const PAYMENTS_RECHECK_DELAYS_MS: number[];
|
|
78
|
+
/** After those, how often to ask again while Stripe is still checking. */
|
|
79
|
+
export declare const PAYMENTS_RECHECK_EVERY_MS = 30000;
|
|
80
|
+
/** How long one run keeps asking in all; after it the card says Stripe is still checking and offers Check again. */
|
|
81
|
+
export declare const PAYMENTS_RECHECK_CEILING_MS: number;
|
|
82
|
+
/** Every wait of one run: the quick start, then every `every`, while the waits stay within `ceiling`. */
|
|
83
|
+
export declare function paymentsRecheckWaits(fast?: readonly number[], every?: number, ceiling?: number): number[];
|
|
84
|
+
/** What the connect route's `sync` answers. */
|
|
85
|
+
export interface PaymentsSyncAnswer {
|
|
86
|
+
chargesEnabled?: unknown;
|
|
87
|
+
needsDetails?: unknown;
|
|
88
|
+
detailsSubmitted?: unknown;
|
|
89
|
+
verifying?: unknown;
|
|
90
|
+
}
|
|
91
|
+
/** Stripe is still deciding on details already sent: worth asking again in a moment. */
|
|
92
|
+
export declare function stripeStillChecking(answer: PaymentsSyncAnswer | null | undefined): boolean;
|
|
93
|
+
/** How a run of re-checks ended. */
|
|
94
|
+
export type PaymentsRecheckEnd = 'ready' | 'answered' | 'waited-out' | 'cancelled';
|
|
95
|
+
/**
|
|
96
|
+
* One run: asks now, then again after each of `waits` while Stripe is still
|
|
97
|
+
* checking. A check that does not get through keeps what Stripe said last,
|
|
98
|
+
* so one dropped request never ends the wait. `cancelled` is read after
|
|
99
|
+
* every wait and every answer (the page closing or going out of view).
|
|
100
|
+
*/
|
|
101
|
+
export declare function recheckPayments(options: {
|
|
102
|
+
sync: () => Promise<PaymentsSyncAnswer>;
|
|
103
|
+
onChecking: (checking: boolean) => void;
|
|
104
|
+
onStatus: (answer: PaymentsSyncAnswer) => void;
|
|
105
|
+
cancelled: () => boolean;
|
|
106
|
+
waits?: readonly number[];
|
|
107
|
+
sleep?: (ms: number) => Promise<void>;
|
|
108
|
+
}): Promise<PaymentsRecheckEnd>;
|
|
@@ -99,5 +99,68 @@ const count = (value)=>{
|
|
|
99
99
|
continueSetup: true
|
|
100
100
|
};
|
|
101
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* ASKING STRIPE AGAIN WHILE IT CHECKS (AGL-4061), the same schedule as the
|
|
104
|
+
* apps' Card readers and Payments screens: quick at first, then every 30
|
|
105
|
+
* seconds, for up to 15 minutes, while the page is in view. The connect
|
|
106
|
+
* route's `sync` answers what Stripe says now and records it on the profile,
|
|
107
|
+
* so the card never waits on the `account.updated` webhook.
|
|
108
|
+
*/ /** The first waits, about a minute and a half in all, which is usually enough. */ export const PAYMENTS_RECHECK_DELAYS_MS = [
|
|
109
|
+
3000,
|
|
110
|
+
6000,
|
|
111
|
+
12000,
|
|
112
|
+
24000,
|
|
113
|
+
48000
|
|
114
|
+
];
|
|
115
|
+
/** After those, how often to ask again while Stripe is still checking. */ export const PAYMENTS_RECHECK_EVERY_MS = 30000;
|
|
116
|
+
/** How long one run keeps asking in all; after it the card says Stripe is still checking and offers Check again. */ export const PAYMENTS_RECHECK_CEILING_MS = 15 * 60 * 1000;
|
|
117
|
+
/** Every wait of one run: the quick start, then every `every`, while the waits stay within `ceiling`. */ export function paymentsRecheckWaits(fast = PAYMENTS_RECHECK_DELAYS_MS, every = PAYMENTS_RECHECK_EVERY_MS, ceiling = PAYMENTS_RECHECK_CEILING_MS) {
|
|
118
|
+
const waits = [];
|
|
119
|
+
let total = 0;
|
|
120
|
+
for (const wait of fast){
|
|
121
|
+
if (total + wait > ceiling) return waits;
|
|
122
|
+
waits.push(wait);
|
|
123
|
+
total += wait;
|
|
124
|
+
}
|
|
125
|
+
if (!(every > 0)) return waits;
|
|
126
|
+
while(total + every <= ceiling){
|
|
127
|
+
waits.push(every);
|
|
128
|
+
total += every;
|
|
129
|
+
}
|
|
130
|
+
return waits;
|
|
131
|
+
}
|
|
132
|
+
/** Stripe is still deciding on details already sent: worth asking again in a moment. */ export function stripeStillChecking(answer) {
|
|
133
|
+
return !!answer && answer.chargesEnabled !== true && answer.needsDetails !== true && (answer.verifying === true || answer.detailsSubmitted === true);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* One run: asks now, then again after each of `waits` while Stripe is still
|
|
137
|
+
* checking. A check that does not get through keeps what Stripe said last,
|
|
138
|
+
* so one dropped request never ends the wait. `cancelled` is read after
|
|
139
|
+
* every wait and every answer (the page closing or going out of view).
|
|
140
|
+
*/ export async function recheckPayments(options) {
|
|
141
|
+
var _options_sleep, _options_waits;
|
|
142
|
+
const sleep = (_options_sleep = options.sleep) != null ? _options_sleep : (ms)=>new Promise((done)=>setTimeout(done, ms));
|
|
143
|
+
let known = null;
|
|
144
|
+
for (const wait of [
|
|
145
|
+
0,
|
|
146
|
+
...(_options_waits = options.waits) != null ? _options_waits : paymentsRecheckWaits()
|
|
147
|
+
]){
|
|
148
|
+
if (wait > 0) await sleep(wait);
|
|
149
|
+
if (options.cancelled()) return 'cancelled';
|
|
150
|
+
options.onChecking(true);
|
|
151
|
+
try {
|
|
152
|
+
known = await options.sync();
|
|
153
|
+
options.onStatus(known);
|
|
154
|
+
} catch (unused) {
|
|
155
|
+
// Kept: what Stripe said last still stands.
|
|
156
|
+
} finally{
|
|
157
|
+
options.onChecking(false);
|
|
158
|
+
}
|
|
159
|
+
if (options.cancelled()) return 'cancelled';
|
|
160
|
+
if ((known == null ? void 0 : known.chargesEnabled) === true) return 'ready';
|
|
161
|
+
if (!stripeStillChecking(known)) return 'answered';
|
|
162
|
+
}
|
|
163
|
+
return 'waited-out';
|
|
164
|
+
}
|
|
102
165
|
|
|
103
166
|
//# sourceMappingURL=payments-setup-status.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/model/payments-setup-status.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * WHAT THE PAYMENTS CARD SAYS ABOUT STRIPE SETUP (AGL-4245), from the owner's\n * profile as the connect route and `account.updated` keep it\n * (`merchantRequirementsSummary`). Pure, so the words are tested apart from\n * the card.\n */\n\n/**\n * The query parameter Stripe's onboarding links come back with, on the\n * Payments section: `done` when the owner finished or left the form,\n * `refresh` when the link had expired or was already opened.\n */\nexport const CONNECT_RETURN_PARAM = 'connect'\n\n/** How long a `refresh` return counts as \"already continued once\", so an expired link never loops. */\nexport const CONNECT_REFRESH_GUARD_MS = 2 * 60 * 1000\n\n/** The profile fields read here. Every one may be absent on an older profile. */\nexport interface PaymentsSetupProfile {\n stripeAccountId?: unknown\n stripeChargesEnabled?: unknown\n stripePayoutsEnabled?: unknown\n stripeDetailsSubmitted?: unknown\n stripeRequirementsDueCount?: unknown\n stripeRequirementsPastDueCount?: unknown\n stripeRequirementsDeadlineMs?: unknown\n}\n\n/** A notice the card shows, with whether it offers \"Continue setup\". */\nexport interface PaymentsSetupNotice {\n severity: 'success' | 'info' | 'warning' | 'error'\n text: string\n /** The notice names something only Stripe's form can fix. */\n continueSetup: boolean\n}\n\nconst count = (value: unknown): number => {\n const n = Number(value)\n return Number.isFinite(n) && n > 0 ? Math.floor(n) : 0\n}\n\n/** A deadline as people read it: `March 4, 2027`. */\nexport function paymentsDeadlineText(ms: number, locale?: string): string {\n return new Date(ms).toLocaleDateString(locale, {\n month: 'long',\n day: 'numeric',\n year: 'numeric',\n })\n}\n\n/**\n * The standing notice when Stripe needs more from an owner who has already\n * been through its form once, or null when nothing is due.\n *\n * \"To keep taking payments\" when card payments are already off, else \"to\n * keep payouts running\": Stripe does not say ahead of time which of the two\n * a missed deadline stops, so the notice names the one that is already\n * affected, or payouts while payments still work.\n */\nexport function paymentsRequirementsNotice(\n profile: PaymentsSetupProfile | null | undefined,\n options: { now?: number; locale?: string } = {},\n): PaymentsSetupNotice | null {\n if (!profile?.stripeAccountId || profile.stripeDetailsSubmitted !== true) return null\n const due = count(profile.stripeRequirementsDueCount)\n const pastDue = count(profile.stripeRequirementsPastDueCount)\n if (!due && !pastDue) return null\n const now = options.now ?? Date.now()\n const deadline = Number(profile.stripeRequirementsDeadlineMs)\n const by =\n !pastDue && Number.isFinite(deadline) && deadline > now\n ? ` by ${paymentsDeadlineText(deadline, options.locale)}`\n : ''\n const what =\n profile.stripeChargesEnabled === true ? 'keep payouts running' : 'keep taking payments'\n return {\n severity: pastDue ? 'error' : 'warning',\n text: `Stripe needs more details${by} to ${what}.`,\n continueSetup: true,\n }\n}\n\n/**\n * The result shown on the Payments section after Stripe sends the owner back\n * (`?connect=done`), read from the live profile, so it changes by itself when\n * Stripe's update lands.\n */\nexport function paymentsReturnResult(\n profile: PaymentsSetupProfile | null | undefined,\n ready: boolean,\n): PaymentsSetupNotice {\n const due =\n count(profile?.stripeRequirementsDueCount) + count(profile?.stripeRequirementsPastDueCount)\n if (ready && profile?.stripePayoutsEnabled !== false && !due) {\n return {\n severity: 'success',\n text: 'Payments are set up. Your store is ready to take payments.',\n continueSetup: false,\n }\n }\n if (ready && profile?.stripePayoutsEnabled === false && !due) {\n return {\n severity: 'info',\n text:\n 'Your store can take payments. Stripe is still checking your details ' +\n 'before it sends payouts, and this updates by itself when it is done.',\n continueSetup: false,\n }\n }\n if (ready) {\n return {\n severity: 'warning',\n text: 'Your store can take payments, and Stripe still needs a few more details.',\n continueSetup: true,\n }\n }\n if (profile?.stripeDetailsSubmitted === true && !due) {\n return {\n severity: 'info',\n text:\n 'Stripe is checking your details. This updates by itself when it is ' +\n 'done, and there is nothing more you need to do right now.',\n continueSetup: false,\n }\n }\n return {\n severity: 'warning',\n text: 'Stripe still needs a few details before your store can take payments.',\n continueSetup: true,\n }\n}\n"],"names":["CONNECT_RETURN_PARAM","CONNECT_REFRESH_GUARD_MS","count","value","n","Number","isFinite","Math","floor","paymentsDeadlineText","ms","locale","Date","toLocaleDateString","month","day","year","paymentsRequirementsNotice","profile","options","stripeAccountId","stripeDetailsSubmitted","due","stripeRequirementsDueCount","pastDue","stripeRequirementsPastDueCount","now","deadline","stripeRequirementsDeadlineMs","by","what","stripeChargesEnabled","severity","text","continueSetup","paymentsReturnResult","ready","stripePayoutsEnabled"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;CAKC,GAED;;;;CAIC,GACD,OAAO,MAAMA,uBAAuB,UAAS;AAE7C,oGAAoG,GACpG,OAAO,MAAMC,2BAA2B,IAAI,KAAK,KAAI;AAqBrD,MAAMC,QAAQ,CAACC;IACb,MAAMC,IAAIC,OAAOF;IACjB,OAAOE,OAAOC,QAAQ,CAACF,MAAMA,IAAI,IAAIG,KAAKC,KAAK,CAACJ,KAAK;AACvD;AAEA,mDAAmD,GACnD,OAA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MAAK,SAAS,CAACf,KAAK;QAC5D,OAAO;YACLU,UAAU;YACVC,MACE,yEACA;YACFC,eAAe;QACjB;IACF;IACA,IAAIE,OAAO;QACT,OAAO;YACLJ,UAAU;YACVC,MAAM;YACNC,eAAe;QACjB;IACF;IACA,IAAIhB,CAAAA,2BAAAA,QAASG,sBAAsB,MAAK,QAAQ,CAACC,KAAK;QACpD,OAAO;YACLU,UAAU;YACVC,MACE,wEACA;YACFC,eAAe;QACjB;IACF;IACA,OAAO;QACLF,UAAU;QACVC,MAAM;QACNC,eAAe;IACjB;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/model/payments-setup-status.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * WHAT THE PAYMENTS CARD SAYS ABOUT STRIPE SETUP (AGL-4245), from the owner's\n * profile as the connect route and `account.updated` keep it\n * (`merchantRequirementsSummary`). Pure, so the words are tested apart from\n * the card.\n */\n\n/**\n * The query parameter Stripe's onboarding links come back with, on the\n * Payments section: `done` when the owner finished or left the form,\n * `refresh` when the link had expired or was already opened.\n */\nexport const CONNECT_RETURN_PARAM = 'connect'\n\n/** How long a `refresh` return counts as \"already continued once\", so an expired link never loops. */\nexport const CONNECT_REFRESH_GUARD_MS = 2 * 60 * 1000\n\n/** The profile fields read here. Every one may be absent on an older profile. */\nexport interface PaymentsSetupProfile {\n stripeAccountId?: unknown\n stripeChargesEnabled?: unknown\n stripePayoutsEnabled?: unknown\n stripeDetailsSubmitted?: unknown\n stripeRequirementsDueCount?: unknown\n stripeRequirementsPastDueCount?: unknown\n stripeRequirementsDeadlineMs?: unknown\n}\n\n/** A notice the card shows, with whether it offers \"Continue setup\". */\nexport interface PaymentsSetupNotice {\n severity: 'success' | 'info' | 'warning' | 'error'\n text: string\n /** The notice names something only Stripe's form can fix. */\n continueSetup: boolean\n}\n\nconst count = (value: unknown): number => {\n const n = Number(value)\n return Number.isFinite(n) && n > 0 ? Math.floor(n) : 0\n}\n\n/** A deadline as people read it: `March 4, 2027`. */\nexport function paymentsDeadlineText(ms: number, locale?: string): string {\n return new Date(ms).toLocaleDateString(locale, {\n month: 'long',\n day: 'numeric',\n year: 'numeric',\n })\n}\n\n/**\n * The standing notice when Stripe needs more from an owner who has already\n * been through its form once, or null when nothing is due.\n *\n * \"To keep taking payments\" when card payments are already off, else \"to\n * keep payouts running\": Stripe does not say ahead of time which of the two\n * a missed deadline stops, so the notice names the one that is already\n * affected, or payouts while payments still work.\n */\nexport function paymentsRequirementsNotice(\n profile: PaymentsSetupProfile | null | undefined,\n options: { now?: number; locale?: string } = {},\n): PaymentsSetupNotice | null {\n if (!profile?.stripeAccountId || profile.stripeDetailsSubmitted !== true) return null\n const due = count(profile.stripeRequirementsDueCount)\n const pastDue = count(profile.stripeRequirementsPastDueCount)\n if (!due && !pastDue) return null\n const now = options.now ?? Date.now()\n const deadline = Number(profile.stripeRequirementsDeadlineMs)\n const by =\n !pastDue && Number.isFinite(deadline) && deadline > now\n ? ` by ${paymentsDeadlineText(deadline, options.locale)}`\n : ''\n const what =\n profile.stripeChargesEnabled === true ? 'keep payouts running' : 'keep taking payments'\n return {\n severity: pastDue ? 'error' : 'warning',\n text: `Stripe needs more details${by} to ${what}.`,\n continueSetup: true,\n }\n}\n\n/**\n * The result shown on the Payments section after Stripe sends the owner back\n * (`?connect=done`), read from the live profile, so it changes by itself when\n * Stripe's update lands.\n */\nexport function paymentsReturnResult(\n profile: PaymentsSetupProfile | null | undefined,\n ready: boolean,\n): PaymentsSetupNotice {\n const due =\n count(profile?.stripeRequirementsDueCount) + count(profile?.stripeRequirementsPastDueCount)\n if (ready && profile?.stripePayoutsEnabled !== false && !due) {\n return {\n severity: 'success',\n text: 'Payments are set up. Your store is ready to take payments.',\n continueSetup: false,\n }\n }\n if (ready && profile?.stripePayoutsEnabled === false && !due) {\n return {\n severity: 'info',\n text:\n 'Your store can take payments. Stripe is still checking your details ' +\n 'before it sends payouts, and this updates by itself when it is done.',\n continueSetup: false,\n }\n }\n if (ready) {\n return {\n severity: 'warning',\n text: 'Your store can take payments, and Stripe still needs a few more details.',\n continueSetup: true,\n }\n }\n if (profile?.stripeDetailsSubmitted === true && !due) {\n return {\n severity: 'info',\n text:\n 'Stripe is checking your details. This updates by itself when it is ' +\n 'done, and there is nothing more you need to do right now.',\n continueSetup: false,\n }\n }\n return {\n severity: 'warning',\n text: 'Stripe still needs a few details before your store can take payments.',\n continueSetup: true,\n }\n}\n\n/**\n * ASKING STRIPE AGAIN WHILE IT CHECKS (AGL-4061), the same schedule as the\n * apps' Card readers and Payments screens: quick at first, then every 30\n * seconds, for up to 15 minutes, while the page is in view. The connect\n * route's `sync` answers what Stripe says now and records it on the profile,\n * so the card never waits on the `account.updated` webhook.\n */\n\n/** The first waits, about a minute and a half in all, which is usually enough. */\nexport const PAYMENTS_RECHECK_DELAYS_MS = [3_000, 6_000, 12_000, 24_000, 48_000]\n/** After those, how often to ask again while Stripe is still checking. */\nexport const PAYMENTS_RECHECK_EVERY_MS = 30_000\n/** How long one run keeps asking in all; after it the card says Stripe is still checking and offers Check again. */\nexport const PAYMENTS_RECHECK_CEILING_MS = 15 * 60 * 1000\n\n/** Every wait of one run: the quick start, then every `every`, while the waits stay within `ceiling`. */\nexport function paymentsRecheckWaits(\n fast: readonly number[] = PAYMENTS_RECHECK_DELAYS_MS,\n every: number = PAYMENTS_RECHECK_EVERY_MS,\n ceiling: number = PAYMENTS_RECHECK_CEILING_MS,\n): number[] {\n const waits: number[] = []\n let total = 0\n for (const wait of fast) {\n if (total + wait > ceiling) return waits\n waits.push(wait)\n total += wait\n }\n if (!(every > 0)) return waits\n while (total + every <= ceiling) {\n waits.push(every)\n total += every\n }\n return waits\n}\n\n/** What the connect route's `sync` answers. */\nexport interface PaymentsSyncAnswer {\n chargesEnabled?: unknown\n needsDetails?: unknown\n detailsSubmitted?: unknown\n verifying?: unknown\n}\n\n/** Stripe is still deciding on details already sent: worth asking again in a moment. */\nexport function stripeStillChecking(\n answer: PaymentsSyncAnswer | null | undefined,\n): boolean {\n return (\n !!answer &&\n answer.chargesEnabled !== true &&\n answer.needsDetails !== true &&\n (answer.verifying === true || answer.detailsSubmitted === true)\n )\n}\n\n/** How a run of re-checks ended. */\nexport type PaymentsRecheckEnd =\n 'ready' | 'answered' | 'waited-out' | 'cancelled'\n\n/**\n * One run: asks now, then again after each of `waits` while Stripe is still\n * checking. A check that does not get through keeps what Stripe said last,\n * so one dropped request never ends the wait. `cancelled` is read after\n * every wait and every answer (the page closing or going out of view).\n */\nexport async function recheckPayments(options: {\n sync: () => Promise<PaymentsSyncAnswer>\n onChecking: (checking: boolean) => void\n onStatus: (answer: PaymentsSyncAnswer) => void\n cancelled: () => boolean\n waits?: readonly number[]\n sleep?: (ms: number) => Promise<void>\n}): Promise<PaymentsRecheckEnd> {\n const sleep =\n options.sleep ??\n ((ms: number) => new Promise<void>((done) => setTimeout(done, ms)))\n let known: PaymentsSyncAnswer | null = null\n for (const wait of [0, ...(options.waits ?? paymentsRecheckWaits())]) {\n if (wait > 0) await sleep(wait)\n if (options.cancelled()) return 'cancelled'\n options.onChecking(true)\n try {\n known = await options.sync()\n options.onStatus(known)\n } catch {\n // Kept: what Stripe said last still stands.\n } finally {\n options.onChecking(false)\n }\n if (options.cancelled()) return 'cancelled'\n if (known?.chargesEnabled === true) return 'ready'\n if (!stripeStillChecking(known)) return 'answered'\n }\n return 'waited-out'\n}\n"],"names":["CONNECT_RETURN_PARAM","CONNECT_REFRESH_GUARD_MS","count","value","n","Number","isFinite","Math","floor","paymentsDeadlineText","ms","locale","Date","toLocaleDateString","month","day","year","paymentsRequirementsNotice","profile","options","stripeAccountId","stripeDetailsSubmitted","due","stripeRequirementsDueCount","pastDue","stripeRequirementsPastDueCount","now","deadline","stripeRequirementsDeadlineMs","by","what","stripeChargesEnabled","severity","text","continueSetup","paymentsReturnResult","ready","stripePayoutsEnabled","PAYMENTS_RECHECK_DELAYS_MS","PAYMENTS_RECHECK_EVERY_MS","PAYMENTS_RECHECK_CEILING_MS","paymentsRecheckWaits","fast","every","ceiling","waits","total","wait","push","stripeStillChecking","answer","chargesEnabled","needsDetails","verifying","detailsSubmitted","recheckPayments","sleep","Promise","done","setTimeout","known","cancelled","onChecking","sync","onStatus"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;CAKC,GAED;;;;CAIC,GACD,OAAO,MAAMA,uBAAuB,UAAS;AAE7C,oGAAoG,GACpG,OAAO,MAAMC,2BAA2B,IAAI,KAAK,KAAI;AAqBrD,MAAMC,QAAQ,CAACC;IACb,MAAMC,IAAIC,OAAOF;IACjB,OAAOE,OAAOC,QAAQ,CAACF,MAAMA,IAAI,IAAIG,KAAKC,KAAK,CAACJ,KAAK;AACvD;AAEA,mDAAmD,GACnD,OAAO,SAASK,qBAAqBC,EAAU,EAAEC,MAAe;IAC9D,OAAO,IAAIC,KAAKF,IAAIG,kBAAkB,CAACF,QAAQ;QAC7CG,OAAO;QACPC,KAAK;QACLC,MAAM;IACR;AACF;AAEA;;;;;;;;CAQC,GACD,OAAO,SAASC,2BACdC,OAAgD,EAChDC,UAA6C,CAAC,CAAC;QAMnCA;IAJZ,IAAI,EAACD,2BAAAA,QAASE,eAAe,KAAIF,QAAQG,sBAAsB,KAAK,MAAM,OAAO;IACjF,MAAMC,MAAMpB,MAAMgB,QAAQK,0BAA0B;IACpD,MAAMC,UAAUtB,MAAMgB,QAAQO,8BAA8B;IAC5D,IAAI,CAACH,OAAO,CAACE,SAAS,OAAO;IAC7B,MAAME,OAAMP,eAAAA,QA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M;QACN,4CAA4C;QAC9C,SAAU;YACRzC,QAAQ2C,UAAU,CAAC;QACrB;QACA,IAAI3C,QAAQ0C,SAAS,IAAI,OAAO;QAChC,IAAID,CAAAA,yBAAAA,MAAOT,cAAc,MAAK,MAAM,OAAO;QAC3C,IAAI,CAACF,oBAAoBW,QAAQ,OAAO;IAC1C;IACA,OAAO;AACT"}
|
|
@@ -44,6 +44,25 @@ export declare function subscriptionInterval(value: unknown): SubscriptionBillin
|
|
|
44
44
|
* Rounded to whole cents.
|
|
45
45
|
*/
|
|
46
46
|
export declare function monthlyRecurringCents(totalCents: unknown, taxCents: unknown, interval: unknown): number;
|
|
47
|
+
/**
|
|
48
|
+
* What turns a subscription's charged figures into the store currency's
|
|
49
|
+
* (AGL-4257): the store-currency amount less the charged one, per figure. A
|
|
50
|
+
* subscription sold in another currency stores it beside `totals`, so the
|
|
51
|
+
* monthly recurring figure is one more sum over the same query — a field a
|
|
52
|
+
* document lacks sums as nothing, which is exactly right for every
|
|
53
|
+
* subscription sold in the store currency. Undefined when there is nothing
|
|
54
|
+
* to add.
|
|
55
|
+
*/
|
|
56
|
+
export declare function subscriptionBaseTotalsDelta(totals: {
|
|
57
|
+
totalCents?: number;
|
|
58
|
+
taxCents?: number;
|
|
59
|
+
} | null | undefined, baseTotals: {
|
|
60
|
+
totalCents?: number;
|
|
61
|
+
taxCents?: number;
|
|
62
|
+
} | null | undefined): {
|
|
63
|
+
totalCents: number;
|
|
64
|
+
taxCents: number;
|
|
65
|
+
} | undefined;
|
|
47
66
|
/** The fields of a stored subscription the date line reads. */
|
|
48
67
|
export interface SubscriptionDateFields {
|
|
49
68
|
status?: unknown;
|
|
@@ -79,6 +79,22 @@ export function subscriptionStatusColor(status) {
|
|
|
79
79
|
if (cadence === 'month') return Math.round(net);
|
|
80
80
|
return 0;
|
|
81
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* What turns a subscription's charged figures into the store currency's
|
|
84
|
+
* (AGL-4257): the store-currency amount less the charged one, per figure. A
|
|
85
|
+
* subscription sold in another currency stores it beside `totals`, so the
|
|
86
|
+
* monthly recurring figure is one more sum over the same query — a field a
|
|
87
|
+
* document lacks sums as nothing, which is exactly right for every
|
|
88
|
+
* subscription sold in the store currency. Undefined when there is nothing
|
|
89
|
+
* to add.
|
|
90
|
+
*/ export function subscriptionBaseTotalsDelta(totals, baseTotals) {
|
|
91
|
+
if (!totals || !baseTotals) return undefined;
|
|
92
|
+
const delta = (key)=>Math.round((Number(baseTotals[key]) || 0) - (Number(totals[key]) || 0));
|
|
93
|
+
return {
|
|
94
|
+
totalCents: delta('totalCents'),
|
|
95
|
+
taxCents: delta('taxCents')
|
|
96
|
+
};
|
|
97
|
+
}
|
|
82
98
|
function positiveMs(value) {
|
|
83
99
|
const ms = Number(value);
|
|
84
100
|
return Number.isFinite(ms) && ms > 0 ? ms : undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/model/subscription-view.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * How a storefront subscription (`hosts/{hostId}/subscriptions`) reads to a\n * person (AGL-4191): its status in words, the one date that matters next, and\n * what it is worth a month. One copy for the console's Subscriptions list and\n * the buyer's account page, so the merchant and the subscriber never read two\n * different answers about the same subscription.\n */\n\nexport type SubscriptionBillingInterval = 'month' | 'year'\n\n/** Stripe's subscription statuses, in the merchant's words. */\nexport const SUBSCRIPTION_STATUS_LABELS: Readonly<Record<string, string>> = {\n active: 'Active',\n trialing: 'Trial',\n past_due: 'Past due',\n unpaid: 'Unpaid',\n incomplete: 'Incomplete',\n incomplete_expired: 'Expired',\n canceled: 'Canceled',\n paused: 'Paused',\n}\n\nexport const SUBSCRIPTION_STATUS_COLOR: Readonly<\n Record<string, 'success' | 'info' | 'warning' | 'error' | 'default'>\n> = {\n active: 'success',\n trialing: 'info',\n past_due: 'warning',\n unpaid: 'error',\n incomplete: 'warning',\n}\n\n/** The statuses the console's filter offers, in the order a merchant scans them. */\n// AGL-1715-EXEMPT: the options of the subscriptions list's status filter, a\n// display vocabulary rather than a \"live\" test; nothing is granted or refused\n// by membership in it.\nexport const SUBSCRIPTION_FILTER_STATUSES = [\n 'active',\n 'trialing',\n 'past_due',\n 'unpaid',\n 'incomplete',\n 'canceled',\n] as const\n\n/**\n * The statuses that bring money in every cycle: what monthly recurring revenue\n * counts. A trial has not paid yet, and `unpaid` has stopped paying; `past_due`\n * stays in because Stripe is still collecting and the subscriber has not left,\n * the same reason it stays live for access (`commerce-subscription-status.ts`).\n */\nexport const SUBSCRIPTION_PAYING_STATUSES = ['active', 'past_due'] as const\n\nexport function subscriptionStatusLabel(status: unknown): string {\n const key = String(status ?? '')\n return SUBSCRIPTION_STATUS_LABELS[key] ?? (key ? key.replace(/_/g, ' ') : 'Unknown')\n}\n\nexport function subscriptionStatusColor(\n status: unknown,\n): 'success' | 'info' | 'warning' | 'error' | 'default' {\n return SUBSCRIPTION_STATUS_COLOR[String(status ?? '')] ?? 'default'\n}\n\n/** `month` or `year` from a stored value, or null for anything else. */\nexport function subscriptionInterval(value: unknown): SubscriptionBillingInterval | null {\n return value === 'month' || value === 'year' ? value : null\n}\n\n/**\n * A recurring charge as a monthly figure: a yearly price counts a twelfth.\n * Tax is the government's, not the merchant's revenue, so it is left out.\n * Rounded to whole cents.\n */\nexport function monthlyRecurringCents(\n totalCents: unknown,\n taxCents: unknown,\n interval: unknown,\n): number {\n const net = Math.max(0, (Number(totalCents) || 0) - (Number(taxCents) || 0))\n const cadence = subscriptionInterval(interval)\n if (cadence === 'year') return Math.round(net / 12)\n if (cadence === 'month') return Math.round(net)\n return 0\n}\n\n/** The fields of a stored subscription the date line reads. */\nexport interface SubscriptionDateFields {\n status?: unknown\n cancelAtPeriodEnd?: unknown\n currentPeriodEndMs?: unknown\n /** Set by each paid invoice; the fallback when Stripe sent no period end. */\n paidThroughMs?: unknown\n}\n\nexport type SubscriptionDateKind =\n | 'renews'\n | 'trialEnds'\n | 'ends'\n | 'ended'\n | 'paymentFailed'\n | 'awaitingPayment'\n\nexport interface SubscriptionDateLine {\n kind: SubscriptionDateKind\n /** Absent where the line names no date (\"Payment failed\"). */\n atMs?: number\n}\n\nfunction positiveMs(value: unknown): number | undefined {\n const ms = Number(value)\n return Number.isFinite(ms) && ms > 0 ? ms : undefined\n}\n\n/**\n * The one date that matters next for a subscription, or null when there is\n * nothing honest to say.\n *\n * `cancelAtPeriodEnd` wins over a renewal: a subscriber who cancelled in the\n * billing portal keeps access to the end of the period they paid for and is\n * not charged again, so \"Renews\" would be a promise of a charge that will not\n * happen. A failed payment names no date, because Stripe moves the period end\n * forward while the unpaid invoice is retried, so that date is neither a\n * renewal nor an end.\n */\nexport function subscriptionDateLine(\n subscription: SubscriptionDateFields,\n): SubscriptionDateLine | null {\n const status = String(subscription.status ?? '')\n const periodEnd =\n positiveMs(subscription.currentPeriodEndMs) ?? positiveMs(subscription.paidThroughMs)\n const ending = subscription.cancelAtPeriodEnd === true\n switch (status) {\n case 'active':\n if (!periodEnd) return null\n return { kind: ending ? 'ends' : 'renews', atMs: periodEnd }\n case 'trialing':\n if (!periodEnd) return null\n return { kind: ending ? 'ends' : 'trialEnds', atMs: periodEnd }\n case 'past_due':\n case 'unpaid':\n return { kind: 'paymentFailed' }\n case 'incomplete':\n return { kind: 'awaitingPayment' }\n case 'canceled':\n case 'incomplete_expired':\n return periodEnd ? { kind: 'ended', atMs: periodEnd } : null\n default:\n return null\n }\n}\n\n/** A short date in the reader's own locale: \"Dec 4, 2026\". */\nexport function formatSubscriptionDate(ms: number): string {\n return new Date(ms).toLocaleDateString(undefined, {\n month: 'short',\n day: 'numeric',\n year: 'numeric',\n })\n}\n\n/** The date line in words: \"Renews Dec 4, 2026\", \"Payment failed\". */\nexport function subscriptionDateText(\n line: SubscriptionDateLine | null,\n formatDate: (ms: number) => string = formatSubscriptionDate,\n): string {\n if (!line) return ''\n const on = line.atMs ? formatDate(line.atMs) : ''\n switch (line.kind) {\n case 'renews':\n return `Renews ${on}`\n case 'trialEnds':\n return `Trial ends ${on}`\n case 'ends':\n return `Ends ${on}`\n case 'ended':\n return `Ended ${on}`\n case 'paymentFailed':\n return 'Payment failed'\n case 'awaitingPayment':\n return 'Waiting for the first payment'\n }\n}\n\n/** \"/month\" or \"/year\", or \"\" for a stored value that is neither. */\nexport function subscriptionIntervalSuffix(interval: unknown): string {\n const cadence = subscriptionInterval(interval)\n return cadence ? `/${cadence}` : ''\n}\n\n/**\n * What a subscription's plan is called: the line the subscriber bought, with\n * its quantity when more than one, or the product id for a subscription sold\n * before lines were stored (AGL-1732).\n */\nexport function subscriptionPlanName(subscription: {\n lineItems?: Array<{ name?: string; quantity?: number }>\n productId?: string\n}): string {\n const line = subscription.lineItems?.[0]\n if (line?.name) {\n return (line.quantity ?? 1) > 1 ? `${line.quantity}× ${line.name}` : line.name\n }\n return subscription.productId || 'Subscription'\n}\n"],"names":["SUBSCRIPTION_STATUS_LABELS","active","trialing","past_due","unpaid","incomplete","incomplete_expired","canceled","paused","SUBSCRIPTION_STATUS_COLOR","SUBSCRIPTION_FILTER_STATUSES","SUBSCRIPTION_PAYING_STATUSES","subscriptionStatusLabel","status","key","String","replace","subscriptionStatusColor","subscriptionInterval","value","monthlyRecurringCents","totalCents","taxCents","interval","net","Math","max","Number","cadence","round","positiveMs","ms","isFinite","undefined","subscriptionDateLine","subscription","periodEnd","currentPeriodEndMs","paidThroughMs","ending","cancelAtPeriodEnd","kind","atMs","formatSubscriptionDate","Date","toLocaleDateString","month","day","year","subscriptionDateText","line","formatDate","on","subscriptionIntervalSuffix","subscriptionPlanName","lineItems","name","quantity","productId"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;CAMC,GAID,6DAA6D,GAC7D,OAAO,MAAMA,6BAA+D;IAC1EC,QAAQ;IACRC,UAAU;IACVC,UAAU;IACVC,QAAQ;IACRC,YAAY;IACZC,oBAAoB;IACpBC,UAAU;IACVC,QAAQ;AACV,EAAC;AAED,OAAO,MAAMC,4BAET;IACFR,QAAQ;IACRC,UAAU;IACVC,UAAU;IACVC,QAAQ;IACRC,YAAY;AACd,EAAC;AAED,kFAAkF,GAClF,4EAA4E;AAC5E,8EAA8E;AAC9E,uBAAuB;AACvB,OAAO,MAAMK,+BAA+B;IAC1C;IACA;IACA;IACA;IACA;IACA;CACD,CAAS;AAEV;;;;;CAKC,GACD,OAAO,MAAMC,+BAA+B;IAAC;IAAU;CAAW,CAAS;AAE3E,OAAO,SAASC,wBAAwBC,MAAe;QAE9Cb;IADP,MAAMc,MAAMC,OAAOF,iBAAAA,SAAU;IAC7B,QAAOb,kCAAAA,0BAA0B,CAACc,IAAI,YAA/Bd,kCAAoCc,MAAMA,IAAIE,OAAO,CAAC,MAAM,OAAO;AAC5E;AAEA,OAAO,SAASC,wBACdJ,MAAe;QAERJ;IAAP,QAAOA,oCAAAA,yBAAyB,CAACM,OAAOF,iBAAAA,SAAU,IAAI,YAA/CJ,oCAAmD;AAC5D;AAEA,sEAAsE,GACtE,OAAO,SAASS,qBAAqBC,KAAc;IACjD,OAAOA,UAAU,WAAWA,UAAU,SAASA,QAAQ;AACzD;AAEA;;;;CAIC,GACD,OAAO,SAASC,sBACdC,UAAmB,EACnBC,QAAiB,EACjBC,QAAiB;IAEjB,MAAMC,MAAMC,KAAKC,GAAG,CAAC,GAAG,AAACC,CAAAA,OAAON,eAAe,CAAA,IAAMM,CAAAA,OAAOL,aAAa,CAAA;IACzE,MAAMM,UAAUV,qBAAqBK;IACrC,IAAIK,YAAY,QAAQ,OAAOH,K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I,IAAI;IAC/C,OAAQQ,KAAKT,IAAI;QACf,KAAK;YACH,OAAO,CAAC,OAAO,EAAEW,IAAI;QACvB,KAAK;YACH,OAAO,CAAC,WAAW,EAAEA,IAAI;QAC3B,KAAK;YACH,OAAO,CAAC,KAAK,EAAEA,IAAI;QACrB,KAAK;YACH,OAAO,CAAC,MAAM,EAAEA,IAAI;QACtB,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;IACX;AACF;AAEA,mEAAmE,GACnE,OAAO,SAASC,2BAA2B9B,QAAiB;IAC1D,MAAMK,UAAUV,qBAAqBK;IACrC,OAAOK,UAAU,CAAC,CAAC,EAAEA,SAAS,GAAG;AACnC;AAEA;;;;CAIC,GACD,OAAO,SAAS0B,qBAAqBnB,YAGpC;QACcA;IAAb,MAAMe,QAAOf,0BAAAA,aAAaoB,SAAS,qBAAtBpB,uBAAwB,CAAC,EAAE;IACxC,IAAIe,wBAAAA,KAAMM,IAAI,EAAE;YACNN;QAAR,OAAO,EAACA,iBAAAA,KAAKO,QAAQ,YAAbP,iBAAiB,KAAK,IAAI,GAAGA,KAAKO,QAAQ,CAAC,EAAE,EAAEP,KAAKM,IAAI,EAAE,GAAGN,KAAKM,IAAI;IAChF;IACA,OAAOrB,aAAauB,SAAS,IAAI;AACnC"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/model/subscription-view.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * How a storefront subscription (`hosts/{hostId}/subscriptions`) reads to a\n * person (AGL-4191): its status in words, the one date that matters next, and\n * what it is worth a month. One copy for the console's Subscriptions list and\n * the buyer's account page, so the merchant and the subscriber never read two\n * different answers about the same subscription.\n */\n\nexport type SubscriptionBillingInterval = 'month' | 'year'\n\n/** Stripe's subscription statuses, in the merchant's words. */\nexport const SUBSCRIPTION_STATUS_LABELS: Readonly<Record<string, string>> = {\n active: 'Active',\n trialing: 'Trial',\n past_due: 'Past due',\n unpaid: 'Unpaid',\n incomplete: 'Incomplete',\n incomplete_expired: 'Expired',\n canceled: 'Canceled',\n paused: 'Paused',\n}\n\nexport const SUBSCRIPTION_STATUS_COLOR: Readonly<\n Record<string, 'success' | 'info' | 'warning' | 'error' | 'default'>\n> = {\n active: 'success',\n trialing: 'info',\n past_due: 'warning',\n unpaid: 'error',\n incomplete: 'warning',\n}\n\n/** The statuses the console's filter offers, in the order a merchant scans them. */\n// AGL-1715-EXEMPT: the options of the subscriptions list's status filter, a\n// display vocabulary rather than a \"live\" test; nothing is granted or refused\n// by membership in it.\nexport const SUBSCRIPTION_FILTER_STATUSES = [\n 'active',\n 'trialing',\n 'past_due',\n 'unpaid',\n 'incomplete',\n 'canceled',\n] as const\n\n/**\n * The statuses that bring money in every cycle: what monthly recurring revenue\n * counts. A trial has not paid yet, and `unpaid` has stopped paying; `past_due`\n * stays in because Stripe is still collecting and the subscriber has not left,\n * the same reason it stays live for access (`commerce-subscription-status.ts`).\n */\nexport const SUBSCRIPTION_PAYING_STATUSES = ['active', 'past_due'] as const\n\nexport function subscriptionStatusLabel(status: unknown): string {\n const key = String(status ?? '')\n return SUBSCRIPTION_STATUS_LABELS[key] ?? (key ? key.replace(/_/g, ' ') : 'Unknown')\n}\n\nexport function subscriptionStatusColor(\n status: unknown,\n): 'success' | 'info' | 'warning' | 'error' | 'default' {\n return SUBSCRIPTION_STATUS_COLOR[String(status ?? '')] ?? 'default'\n}\n\n/** `month` or `year` from a stored value, or null for anything else. */\nexport function subscriptionInterval(value: unknown): SubscriptionBillingInterval | null {\n return value === 'month' || value === 'year' ? value : null\n}\n\n/**\n * A recurring charge as a monthly figure: a yearly price counts a twelfth.\n * Tax is the government's, not the merchant's revenue, so it is left out.\n * Rounded to whole cents.\n */\nexport function monthlyRecurringCents(\n totalCents: unknown,\n taxCents: unknown,\n interval: unknown,\n): number {\n const net = Math.max(0, (Number(totalCents) || 0) - (Number(taxCents) || 0))\n const cadence = subscriptionInterval(interval)\n if (cadence === 'year') return Math.round(net / 12)\n if (cadence === 'month') return Math.round(net)\n return 0\n}\n\n/**\n * What turns a subscription's charged figures into the store currency's\n * (AGL-4257): the store-currency amount less the charged one, per figure. A\n * subscription sold in another currency stores it beside `totals`, so the\n * monthly recurring figure is one more sum over the same query — a field a\n * document lacks sums as nothing, which is exactly right for every\n * subscription sold in the store currency. Undefined when there is nothing\n * to add.\n */\nexport function subscriptionBaseTotalsDelta(\n totals: { totalCents?: number; taxCents?: number } | null | undefined,\n baseTotals: { totalCents?: number; taxCents?: number } | null | undefined,\n): { totalCents: number; taxCents: number } | undefined {\n if (!totals || !baseTotals) return undefined\n const delta = (key: 'totalCents' | 'taxCents') =>\n Math.round((Number(baseTotals[key]) || 0) - (Number(totals[key]) || 0))\n return { totalCents: delta('totalCents'), taxCents: delta('taxCents') }\n}\n\n/** The fields of a stored subscription the date line reads. */\nexport interface SubscriptionDateFields {\n status?: unknown\n cancelAtPeriodEnd?: unknown\n currentPeriodEndMs?: unknown\n /** Set by each paid invoice; the fallback when Stripe sent no period end. */\n paidThroughMs?: unknown\n}\n\nexport type SubscriptionDateKind =\n | 'renews'\n | 'trialEnds'\n | 'ends'\n | 'ended'\n | 'paymentFailed'\n | 'awaitingPayment'\n\nexport interface SubscriptionDateLine {\n kind: SubscriptionDateKind\n /** Absent where the line names no date (\"Payment failed\"). */\n atMs?: number\n}\n\nfunction positiveMs(value: unknown): number | undefined {\n const ms = Number(value)\n return Number.isFinite(ms) && ms > 0 ? ms : undefined\n}\n\n/**\n * The one date that matters next for a subscription, or null when there is\n * nothing honest to say.\n *\n * `cancelAtPeriodEnd` wins over a renewal: a subscriber who cancelled in the\n * billing portal keeps access to the end of the period they paid for and is\n * not charged again, so \"Renews\" would be a promise of a charge that will not\n * happen. A failed payment names no date, because Stripe moves the period end\n * forward while the unpaid invoice is retried, so that date is neither a\n * renewal nor an end.\n */\nexport function subscriptionDateLine(\n subscription: SubscriptionDateFields,\n): SubscriptionDateLine | null {\n const status = String(subscription.status ?? '')\n const periodEnd =\n positiveMs(subscription.currentPeriodEndMs) ?? positiveMs(subscription.paidThroughMs)\n const ending = subscription.cancelAtPeriodEnd === true\n switch (status) {\n case 'active':\n if (!periodEnd) return null\n return { kind: ending ? 'ends' : 'renews', atMs: periodEnd }\n case 'trialing':\n if (!periodEnd) return null\n return { kind: ending ? 'ends' : 'trialEnds', atMs: periodEnd }\n case 'past_due':\n case 'unpaid':\n return { kind: 'paymentFailed' }\n case 'incomplete':\n return { kind: 'awaitingPayment' }\n case 'canceled':\n case 'incomplete_expired':\n return periodEnd ? { kind: 'ended', atMs: periodEnd } : null\n default:\n return null\n }\n}\n\n/** A short date in the reader's own locale: \"Dec 4, 2026\". */\nexport function formatSubscriptionDate(ms: number): string {\n return new Date(ms).toLocaleDateString(undefined, {\n month: 'short',\n day: 'numeric',\n year: 'numeric',\n })\n}\n\n/** The date line in words: \"Renews Dec 4, 2026\", \"Payment failed\". */\nexport function subscriptionDateText(\n line: SubscriptionDateLine | null,\n formatDate: (ms: number) => string = formatSubscriptionDate,\n): string {\n if (!line) return ''\n const on = line.atMs ? formatDate(line.atMs) : ''\n switch (line.kind) {\n case 'renews':\n return `Renews ${on}`\n case 'trialEnds':\n return `Trial ends ${on}`\n case 'ends':\n return `Ends ${on}`\n case 'ended':\n return `Ended ${on}`\n case 'paymentFailed':\n return 'Payment failed'\n case 'awaitingPayment':\n return 'Waiting for the first payment'\n }\n}\n\n/** \"/month\" or \"/year\", or \"\" for a stored value that is neither. */\nexport function subscriptionIntervalSuffix(interval: unknown): string {\n const cadence = subscriptionInterval(interval)\n return cadence ? `/${cadence}` : ''\n}\n\n/**\n * What a subscription's plan is called: the line the subscriber bought, with\n * its quantity when more than one, or the product id for a subscription sold\n * before lines were stored (AGL-1732).\n */\nexport function subscriptionPlanName(subscription: {\n lineItems?: Array<{ name?: string; quantity?: number }>\n productId?: string\n}): string {\n const line = subscription.lineItems?.[0]\n if (line?.name) {\n return (line.quantity ?? 1) > 1 ? `${line.quantity}× ${line.name}` : line.name\n }\n return subscription.productId || 'Subscription'\n}\n"],"names":["SUBSCRIPTION_STATUS_LABELS","active","trialing","past_due","unpaid","incomplete","incomplete_expired","canceled","paused","SUBSCRIPTION_STATUS_COLOR","SUBSCRIPTION_FILTER_STATUSES","SUBSCRIPTION_PAYING_STATUSES","subscriptionStatusLabel","status","key","String","replace","subscriptionStatusColor","subscriptionInterval","value","monthlyRecurringCents","totalCents","taxCents","interval","net","Math","max","Number","cadence","round","subscriptionBaseTotalsDelta","totals","baseTotals","undefined","delta","positiveMs","ms","isFinite","subscriptionDateLine","subscription","periodEnd","currentPeriodEndMs","paidThroughMs","ending","cancelAtPeriodEnd","kind","atMs","formatSubscriptionDate","Date","toLocaleDateString","month","day","year","subscriptionDateText","line","formatDate","on","subscriptionIntervalSuffix","subscriptionPlanName","lineItems","name","quantity","productId"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;CAMC,GAID,6DAA6D,GAC7D,OAAO,MAAMA,6BAA+D;IAC1EC,QAAQ;IACRC,UAAU;IACVC,UAAU;IACVC,QAAQ;IACRC,YAAY;IACZC,oBAAoB;IACpBC,UAAU;IACVC,QAAQ;AACV,EAAC;AAED,OAAO,MAAMC,4BAET;IACFR,QAAQ;IACRC,UAAU;IACVC,UAAU;IACVC,QAAQ;IACRC,YAAY;AACd,EAAC;AAED,kFAAkF,GAClF,4EAA4E;AAC5E,8EAA8E;AAC9E,uBAAuB;AACvB,OAAO,MAAMK,+BAA+B;IAC1C;IACA;IACA;IACA;IACA;IACA;CACD,CAAS;AAEV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O,CAAC,KAAK,EAAEA,IAAI;QACrB,KAAK;YACH,OAAO,CAAC,MAAM,EAAEA,IAAI;QACtB,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;IACX;AACF;AAEA,mEAAmE,GACnE,OAAO,SAASC,2BAA2BlC,QAAiB;IAC1D,MAAMK,UAAUV,qBAAqBK;IACrC,OAAOK,UAAU,CAAC,CAAC,EAAEA,SAAS,GAAG;AACnC;AAEA;;;;CAIC,GACD,OAAO,SAAS8B,qBAAqBnB,YAGpC;QACcA;IAAb,MAAMe,QAAOf,0BAAAA,aAAaoB,SAAS,qBAAtBpB,uBAAwB,CAAC,EAAE;IACxC,IAAIe,wBAAAA,KAAMM,IAAI,EAAE;YACNN;QAAR,OAAO,EAACA,iBAAAA,KAAKO,QAAQ,YAAbP,iBAAiB,KAAK,IAAI,GAAGA,KAAKO,QAAQ,CAAC,EAAE,EAAEP,KAAKM,IAAI,EAAE,GAAGN,KAAKM,IAAI;IAChF;IACA,OAAOrB,aAAauB,SAAS,IAAI;AACnC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
/** The deployment setting that says Tap to Pay on iPhone is released in Aglyn POS. */
|
|
18
|
+
export declare const TAP_TO_PAY_RELEASED_ENV = "TAP_TO_PAY_IPHONE_RELEASED";
|
|
19
|
+
/** Whether the deployment says Tap to Pay on iPhone is released: exactly `true`. */
|
|
20
|
+
export declare function tapToPayReleased(env: Record<string, string | undefined>): boolean;
|
|
21
|
+
/** The `users/{uid}` field the launch records each person's sends on. */
|
|
22
|
+
export declare const TAP_TO_PAY_LAUNCH_FIELD = "launchAnnouncements";
|
|
23
|
+
/** The key under it for this launch. */
|
|
24
|
+
export declare const TAP_TO_PAY_LAUNCH_RECORD = "tapToPayIPhone";
|
|
25
|
+
/** The push's type: `MobilePushData.type`. */
|
|
26
|
+
export declare const TAP_TO_PAY_LAUNCH_PUSH_TYPE = "commerce.tapToPayLaunch";
|
|
27
|
+
/** Where the push and the button go, under the store: Card readers, starting Set up Tap to Pay on iPhone. */
|
|
28
|
+
export declare const TAP_TO_PAY_SET_UP_PATH = "/products/pos?setUp=tapToPay";
|
|
29
|
+
/** A store's facts, as read. */
|
|
30
|
+
export interface TapToPayLaunchStore {
|
|
31
|
+
orgId: string;
|
|
32
|
+
hostId: string;
|
|
33
|
+
orgName: string;
|
|
34
|
+
orgSlug: string;
|
|
35
|
+
/** The site's subdomain, which the console's routes are keyed by. */
|
|
36
|
+
hostSlug: string;
|
|
37
|
+
commerceEnabled: boolean;
|
|
38
|
+
/** The selling account may be charged now. */
|
|
39
|
+
chargesReady: boolean;
|
|
40
|
+
/** The store currency, upper case. */
|
|
41
|
+
currency: string;
|
|
42
|
+
registers: number;
|
|
43
|
+
/** The workspace is locked for a ban. */
|
|
44
|
+
banned: boolean;
|
|
45
|
+
canary: boolean;
|
|
46
|
+
/** Owner and admins. */
|
|
47
|
+
managerUids: readonly string[];
|
|
48
|
+
/** Everyone who opened a shift on one of its registers. */
|
|
49
|
+
registerUids: readonly string[];
|
|
50
|
+
}
|
|
51
|
+
/** A person's facts, as read. */
|
|
52
|
+
export interface TapToPayLaunchPerson {
|
|
53
|
+
uid: string;
|
|
54
|
+
email: string | null;
|
|
55
|
+
staff: boolean;
|
|
56
|
+
disabled: boolean;
|
|
57
|
+
/** Said No to product email. */
|
|
58
|
+
declinedProductEmail: boolean;
|
|
59
|
+
/** On the suppression list (bounce, complaint, unsubscribe). */
|
|
60
|
+
suppressed: boolean;
|
|
61
|
+
/** Live Aglyn POS installs on an iPhone or iPad registered for push. */
|
|
62
|
+
posIosDevices: number;
|
|
63
|
+
/** When each was already sent, from their record. */
|
|
64
|
+
emailedAtMs: number | null;
|
|
65
|
+
pushedAtMs: number | null;
|
|
66
|
+
}
|
|
67
|
+
export type TapToPayStoreRefusal = 'commerce-off' | 'not-charging' | 'not-us' | 'no-register' | 'banned' | 'canary';
|
|
68
|
+
export type TapToPayEmailSkip = 'already-sent' | 'no-email' | 'test-account' | 'staff' | 'disabled' | 'declined-product-email' | 'suppressed';
|
|
69
|
+
export type TapToPayPushSkip = 'already-sent' | 'test-account' | 'staff' | 'disabled' | 'no-pos-iphone';
|
|
70
|
+
/** Why a store cannot take Tap to Pay on iPhone, or null when it can. */
|
|
71
|
+
export declare function tapToPayStoreRefusal(store: TapToPayLaunchStore): TapToPayStoreRefusal | null;
|
|
72
|
+
/** A test address: the reserved `.test` domain (seed and canary accounts), never a real mailbox. */
|
|
73
|
+
export declare function isTestAddress(email: string | null | undefined, isCanaryEmail: (email: string) => boolean): boolean;
|
|
74
|
+
/** Why a person is not emailed, or null when they are. */
|
|
75
|
+
export declare function tapToPayEmailSkip(person: TapToPayLaunchPerson, isCanaryEmail: (email: string) => boolean): TapToPayEmailSkip | null;
|
|
76
|
+
/** Why a person is not pushed, or null when they are. */
|
|
77
|
+
export declare function tapToPayPushSkip(person: TapToPayLaunchPerson, isCanaryEmail: (email: string) => boolean): TapToPayPushSkip | null;
|
|
78
|
+
/** One person the launch reaches, about the first of their stores that qualifies. */
|
|
79
|
+
export interface TapToPayLaunchRecipient {
|
|
80
|
+
uid: string;
|
|
81
|
+
store: TapToPayLaunchStore;
|
|
82
|
+
/** Whether they hold the store as its owner or an admin (else: they ran its register). */
|
|
83
|
+
manager: boolean;
|
|
84
|
+
}
|
|
85
|
+
export interface TapToPayLaunchPlan {
|
|
86
|
+
stores: {
|
|
87
|
+
eligible: number;
|
|
88
|
+
refused: Partial<Record<TapToPayStoreRefusal, number>>;
|
|
89
|
+
};
|
|
90
|
+
/** Everyone eligible, before the per-channel rules, in first-store order. */
|
|
91
|
+
audience: TapToPayLaunchRecipient[];
|
|
92
|
+
email: TapToPayLaunchRecipient[];
|
|
93
|
+
push: TapToPayLaunchRecipient[];
|
|
94
|
+
emailSkipped: Partial<Record<TapToPayEmailSkip, number>>;
|
|
95
|
+
pushSkipped: Partial<Record<TapToPayPushSkip, number>>;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Who would be told what. Stores are taken in the order given and each
|
|
99
|
+
* person once, about the first eligible store that names them.
|
|
100
|
+
*/
|
|
101
|
+
export declare function planTapToPayLaunch(stores: readonly TapToPayLaunchStore[], people: ReadonlyMap<string, TapToPayLaunchPerson>, isCanaryEmail: (email: string) => boolean): TapToPayLaunchPlan;
|
|
102
|
+
/** An address as a dry run may show it: the first letter and the domain. */
|
|
103
|
+
export declare function maskAddress(email: string | null | undefined): string;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ /*==========================================
|
|
17
|
+
* WHO IS TOLD THAT TAP TO PAY ON IPHONE IS HERE (AGL-4061).
|
|
18
|
+
*
|
|
19
|
+
* The launch email and push (`tap-to-pay-launch-emails.ts` in the email
|
|
20
|
+
* library holds Apple's words) go to the people who can use Tap to Pay on
|
|
21
|
+
* iPhone in Aglyn POS. Pure, so every rule is tested without Firestore; the
|
|
22
|
+
* server (`server/tap-to-pay-launch.ts`) reads the facts and sends.
|
|
23
|
+
*
|
|
24
|
+
* A STORE can take Tap to Pay on iPhone when all of these hold:
|
|
25
|
+
* - the store runs Commerce;
|
|
26
|
+
* - its selling account can be charged (`stripeChargesEnabled` on the owner's
|
|
27
|
+
* profile, in this deployment's payment mode);
|
|
28
|
+
* - it sells in US dollars: Tap to Pay on iPhone is offered in the United
|
|
29
|
+
* States, and the store currency is the nearest stored fact (the selling
|
|
30
|
+
* account's country is not stored);
|
|
31
|
+
* - it has at least one register;
|
|
32
|
+
* - the workspace is not locked for a ban, and is not the sign-up canary's.
|
|
33
|
+
*
|
|
34
|
+
* A PERSON of such a workspace is EMAILED when they are its owner or an
|
|
35
|
+
* admin, or have opened a shift on one of its registers (the stored sign of
|
|
36
|
+
* someone who has used the register; whether that was in Aglyn POS or the
|
|
37
|
+
* console's register is not stored). Never a staff, disabled, canary or
|
|
38
|
+
* `example.test` account, an address on the suppression list, or someone who
|
|
39
|
+
* said No to product email.
|
|
40
|
+
*
|
|
41
|
+
* A person is PUSHED when they are one of the above (whatever their email
|
|
42
|
+
* answer: the push follows the device's own permission) and have an Aglyn POS
|
|
43
|
+
* install on an iPhone or iPad registered for push. Aglyn POS on Android and
|
|
44
|
+
* on the Mac never receives it: Tap to Pay on iPhone is an iPhone feature.
|
|
45
|
+
*
|
|
46
|
+
* Each person is told once, whichever of their workspaces qualifies first:
|
|
47
|
+
* the send records it on `users/{uid}` and a second run skips them.
|
|
48
|
+
*=========================================*/ /** The deployment setting that says Tap to Pay on iPhone is released in Aglyn POS. */ export const TAP_TO_PAY_RELEASED_ENV = 'TAP_TO_PAY_IPHONE_RELEASED';
|
|
49
|
+
/** Whether the deployment says Tap to Pay on iPhone is released: exactly `true`. */ export function tapToPayReleased(env) {
|
|
50
|
+
var _env_TAP_TO_PAY_RELEASED_ENV;
|
|
51
|
+
return String((_env_TAP_TO_PAY_RELEASED_ENV = env[TAP_TO_PAY_RELEASED_ENV]) != null ? _env_TAP_TO_PAY_RELEASED_ENV : '').trim().toLowerCase() === 'true';
|
|
52
|
+
}
|
|
53
|
+
/** The `users/{uid}` field the launch records each person's sends on. */ export const TAP_TO_PAY_LAUNCH_FIELD = 'launchAnnouncements';
|
|
54
|
+
/** The key under it for this launch. */ export const TAP_TO_PAY_LAUNCH_RECORD = 'tapToPayIPhone';
|
|
55
|
+
/** The push's type: `MobilePushData.type`. */ export const TAP_TO_PAY_LAUNCH_PUSH_TYPE = 'commerce.tapToPayLaunch';
|
|
56
|
+
/** Where the push and the button go, under the store: Card readers, starting Set up Tap to Pay on iPhone. */ export const TAP_TO_PAY_SET_UP_PATH = '/products/pos?setUp=tapToPay';
|
|
57
|
+
/** Why a store cannot take Tap to Pay on iPhone, or null when it can. */ export function tapToPayStoreRefusal(store) {
|
|
58
|
+
if (store.canary) return 'canary';
|
|
59
|
+
if (store.banned) return 'banned';
|
|
60
|
+
if (!store.commerceEnabled) return 'commerce-off';
|
|
61
|
+
if (!store.chargesReady) return 'not-charging';
|
|
62
|
+
if (store.currency.toUpperCase() !== 'USD') return 'not-us';
|
|
63
|
+
if (store.registers < 1) return 'no-register';
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
/** A test address: the reserved `.test` domain (seed and canary accounts), never a real mailbox. */ export function isTestAddress(email, isCanaryEmail) {
|
|
67
|
+
const value = String(email != null ? email : '').trim().toLowerCase();
|
|
68
|
+
if (!value) return false;
|
|
69
|
+
return value.endsWith('.test') || isCanaryEmail(value);
|
|
70
|
+
}
|
|
71
|
+
/** Why a person is not emailed, or null when they are. */ export function tapToPayEmailSkip(person, isCanaryEmail) {
|
|
72
|
+
if (person.emailedAtMs !== null) return 'already-sent';
|
|
73
|
+
if (!person.email) return 'no-email';
|
|
74
|
+
if (isTestAddress(person.email, isCanaryEmail)) return 'test-account';
|
|
75
|
+
if (person.staff) return 'staff';
|
|
76
|
+
if (person.disabled) return 'disabled';
|
|
77
|
+
if (person.declinedProductEmail) return 'declined-product-email';
|
|
78
|
+
if (person.suppressed) return 'suppressed';
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
/** Why a person is not pushed, or null when they are. */ export function tapToPayPushSkip(person, isCanaryEmail) {
|
|
82
|
+
if (person.pushedAtMs !== null) return 'already-sent';
|
|
83
|
+
if (isTestAddress(person.email, isCanaryEmail)) return 'test-account';
|
|
84
|
+
if (person.staff) return 'staff';
|
|
85
|
+
if (person.disabled) return 'disabled';
|
|
86
|
+
if (person.posIosDevices < 1) return 'no-pos-iphone';
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
const count = (map, key)=>{
|
|
90
|
+
var _map_key;
|
|
91
|
+
map[key] = ((_map_key = map[key]) != null ? _map_key : 0) + 1;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Who would be told what. Stores are taken in the order given and each
|
|
95
|
+
* person once, about the first eligible store that names them.
|
|
96
|
+
*/ export function planTapToPayLaunch(stores, people, isCanaryEmail) {
|
|
97
|
+
const plan = {
|
|
98
|
+
stores: {
|
|
99
|
+
eligible: 0,
|
|
100
|
+
refused: {}
|
|
101
|
+
},
|
|
102
|
+
audience: [],
|
|
103
|
+
email: [],
|
|
104
|
+
push: [],
|
|
105
|
+
emailSkipped: {},
|
|
106
|
+
pushSkipped: {}
|
|
107
|
+
};
|
|
108
|
+
const seen = new Set();
|
|
109
|
+
for (const store of stores){
|
|
110
|
+
const refusal = tapToPayStoreRefusal(store);
|
|
111
|
+
if (refusal) {
|
|
112
|
+
count(plan.stores.refused, refusal);
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
plan.stores.eligible += 1;
|
|
116
|
+
const managers = new Set(store.managerUids);
|
|
117
|
+
for (const uid of [
|
|
118
|
+
...store.managerUids,
|
|
119
|
+
...store.registerUids
|
|
120
|
+
]){
|
|
121
|
+
if (!uid || seen.has(uid)) continue;
|
|
122
|
+
const person = people.get(uid);
|
|
123
|
+
if (!person) continue;
|
|
124
|
+
seen.add(uid);
|
|
125
|
+
const recipient = {
|
|
126
|
+
uid,
|
|
127
|
+
store,
|
|
128
|
+
manager: managers.has(uid)
|
|
129
|
+
};
|
|
130
|
+
plan.audience.push(recipient);
|
|
131
|
+
const emailSkip = tapToPayEmailSkip(person, isCanaryEmail);
|
|
132
|
+
if (emailSkip) count(plan.emailSkipped, emailSkip);
|
|
133
|
+
else plan.email.push(recipient);
|
|
134
|
+
const pushSkip = tapToPayPushSkip(person, isCanaryEmail);
|
|
135
|
+
if (pushSkip) count(plan.pushSkipped, pushSkip);
|
|
136
|
+
else plan.push.push(recipient);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return plan;
|
|
140
|
+
}
|
|
141
|
+
/** An address as a dry run may show it: the first letter and the domain. */ export function maskAddress(email) {
|
|
142
|
+
const value = String(email != null ? email : '').trim();
|
|
143
|
+
const at = value.lastIndexOf('@');
|
|
144
|
+
if (at < 1) return '(none)';
|
|
145
|
+
return `${value[0]}***${value.slice(at)}`;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
//# sourceMappingURL=tap-to-pay-launch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/commerce/src/lib/model/tap-to-pay-launch.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/*==========================================\n * WHO IS TOLD THAT TAP TO PAY ON IPHONE IS HERE (AGL-4061).\n *\n * The launch email and push (`tap-to-pay-launch-emails.ts` in the email\n * library holds Apple's words) go to the people who can use Tap to Pay on\n * iPhone in Aglyn POS. Pure, so every rule is tested without Firestore; the\n * server (`server/tap-to-pay-launch.ts`) reads the facts and sends.\n *\n * A STORE can take Tap to Pay on iPhone when all of these hold:\n * - the store runs Commerce;\n * - its selling account can be charged (`stripeChargesEnabled` on the owner's\n * profile, in this deployment's payment mode);\n * - it sells in US dollars: Tap to Pay on iPhone is offered in the United\n * States, and the store currency is the nearest stored fact (the selling\n * account's country is not stored);\n * - it has at least one register;\n * - the workspace is not locked for a ban, and is not the sign-up canary's.\n *\n * A PERSON of such a workspace is EMAILED when they are its owner or an\n * admin, or have opened a shift on one of its registers (the stored sign of\n * someone who has used the register; whether that was in Aglyn POS or the\n * console's register is not stored). Never a staff, disabled, canary or\n * `example.test` account, an address on the suppression list, or someone who\n * said No to product email.\n *\n * A person is PUSHED when they are one of the above (whatever their email\n * answer: the push follows the device's own permission) and have an Aglyn POS\n * install on an iPhone or iPad registered for push. Aglyn POS on Android and\n * on the Mac never receives it: Tap to Pay on iPhone is an iPhone feature.\n *\n * Each person is told once, whichever of their workspaces qualifies first:\n * the send records it on `users/{uid}` and a second run skips them.\n *=========================================*/\n\n/** The deployment setting that says Tap to Pay on iPhone is released in Aglyn POS. */\nexport const TAP_TO_PAY_RELEASED_ENV = 'TAP_TO_PAY_IPHONE_RELEASED'\n\n/** Whether the deployment says Tap to Pay on iPhone is released: exactly `true`. */\nexport function tapToPayReleased(env: Record<string, string | undefined>): boolean {\n return String(env[TAP_TO_PAY_RELEASED_ENV] ?? '').trim().toLowerCase() === 'true'\n}\n\n/** The `users/{uid}` field the launch records each person's sends on. */\nexport const TAP_TO_PAY_LAUNCH_FIELD = 'launchAnnouncements'\n/** The key under it for this launch. */\nexport const TAP_TO_PAY_LAUNCH_RECORD = 'tapToPayIPhone'\n\n/** The push's type: `MobilePushData.type`. */\nexport const TAP_TO_PAY_LAUNCH_PUSH_TYPE = 'commerce.tapToPayLaunch'\n\n/** Where the push and the button go, under the store: Card readers, starting Set up Tap to Pay on iPhone. */\nexport const TAP_TO_PAY_SET_UP_PATH = '/products/pos?setUp=tapToPay'\n\n/** A store's facts, as read. */\nexport interface TapToPayLaunchStore {\n orgId: string\n hostId: string\n orgName: string\n orgSlug: string\n /** The site's subdomain, which the console's routes are keyed by. */\n hostSlug: string\n commerceEnabled: boolean\n /** The selling account may be charged now. */\n chargesReady: boolean\n /** The store currency, upper case. */\n currency: string\n registers: number\n /** The workspace is locked for a ban. */\n banned: boolean\n canary: boolean\n /** Owner and admins. */\n managerUids: readonly string[]\n /** Everyone who opened a shift on one of its registers. */\n registerUids: readonly string[]\n}\n\n/** A person's facts, as read. */\nexport interface TapToPayLaunchPerson {\n uid: string\n email: string | null\n staff: boolean\n disabled: boolean\n /** Said No to product email. */\n declinedProductEmail: boolean\n /** On the suppression list (bounce, complaint, unsubscribe). */\n suppressed: boolean\n /** Live Aglyn POS installs on an iPhone or iPad registered for push. */\n posIosDevices: number\n /** When each was already sent, from their record. */\n emailedAtMs: number | null\n pushedAtMs: number | null\n}\n\nexport type TapToPayStoreRefusal =\n | 'commerce-off'\n | 'not-charging'\n | 'not-us'\n | 'no-register'\n | 'banned'\n | 'canary'\n\nexport type TapToPayEmailSkip =\n | 'already-sent'\n | 'no-email'\n | 'test-account'\n | 'staff'\n | 'disabled'\n | 'declined-product-email'\n | 'suppressed'\n\nexport type TapToPayPushSkip = 'already-sent' | 'test-account' | 'staff' | 'disabled' | 'no-pos-iphone'\n\n/** Why a store cannot take Tap to Pay on iPhone, or null when it can. */\nexport function tapToPayStoreRefusal(store: TapToPayLaunchStore): TapToPayStoreRefusal | null {\n if (store.canary) return 'canary'\n if (store.banned) return 'banned'\n if (!store.commerceEnabled) return 'commerce-off'\n if (!store.chargesReady) return 'not-charging'\n if (store.currency.toUpperCase() !== 'USD') return 'not-us'\n if (store.registers < 1) return 'no-register'\n return null\n}\n\n/** A test address: the reserved `.test` domain (seed and canary accounts), never a real mailbox. */\nexport function isTestAddress(email: string | null | undefined, isCanaryEmail: (email: string) => boolean): boolean {\n const value = String(email ?? '').trim().toLowerCase()\n if (!value) return false\n return value.endsWith('.test') || isCanaryEmail(value)\n}\n\n/** Why a person is not emailed, or null when they are. */\nexport function tapToPayEmailSkip(\n person: TapToPayLaunchPerson,\n isCanaryEmail: (email: string) => boolean,\n): TapToPayEmailSkip | null {\n if (person.emailedAtMs !== null) return 'already-sent'\n if (!person.email) return 'no-email'\n if (isTestAddress(person.email, isCanaryEmail)) return 'test-account'\n if (person.staff) return 'staff'\n if (person.disabled) return 'disabled'\n if (person.declinedProductEmail) return 'declined-product-email'\n if (person.suppressed) return 'suppressed'\n return null\n}\n\n/** Why a person is not pushed, or null when they are. */\nexport function tapToPayPushSkip(\n person: TapToPayLaunchPerson,\n isCanaryEmail: (email: string) => boolean,\n): TapToPayPushSkip | null {\n if (person.pushedAtMs !== null) return 'already-sent'\n if (isTestAddress(person.email, isCanaryEmail)) return 'test-account'\n if (person.staff) return 'staff'\n if (person.disabled) return 'disabled'\n if (person.posIosDevices < 1) return 'no-pos-iphone'\n return null\n}\n\n/** One person the launch reaches, about the first of their stores that qualifies. */\nexport interface TapToPayLaunchRecipient {\n uid: string\n store: TapToPayLaunchStore\n /** Whether they hold the store as its owner or an admin (else: they ran its register). */\n manager: boolean\n}\n\nexport interface TapToPayLaunchPlan {\n stores: { eligible: number; refused: Partial<Record<TapToPayStoreRefusal, number>> }\n /** Everyone eligible, before the per-channel rules, in first-store order. */\n audience: TapToPayLaunchRecipient[]\n email: TapToPayLaunchRecipient[]\n push: TapToPayLaunchRecipient[]\n emailSkipped: Partial<Record<TapToPayEmailSkip, number>>\n pushSkipped: Partial<Record<TapToPayPushSkip, number>>\n}\n\nconst count = <K extends string>(map: Partial<Record<K, number>>, key: K) => {\n map[key] = (map[key] ?? 0) + 1\n}\n\n/**\n * Who would be told what. Stores are taken in the order given and each\n * person once, about the first eligible store that names them.\n */\nexport function planTapToPayLaunch(\n stores: readonly TapToPayLaunchStore[],\n people: ReadonlyMap<string, TapToPayLaunchPerson>,\n isCanaryEmail: (email: string) => boolean,\n): TapToPayLaunchPlan {\n const plan: TapToPayLaunchPlan = {\n stores: { eligible: 0, refused: {} },\n audience: [],\n email: [],\n push: [],\n emailSkipped: {},\n pushSkipped: {},\n }\n const seen = new Set<string>()\n for (const store of stores) {\n const refusal = tapToPayStoreRefusal(store)\n if (refusal) {\n count(plan.stores.refused, refusal)\n continue\n }\n plan.stores.eligible += 1\n const managers = new Set(store.managerUids)\n for (const uid of [...store.managerUids, ...store.registerUids]) {\n if (!uid || seen.has(uid)) continue\n const person = people.get(uid)\n if (!person) continue\n seen.add(uid)\n const recipient: TapToPayLaunchRecipient = { uid, store, manager: managers.has(uid) }\n plan.audience.push(recipient)\n const emailSkip = tapToPayEmailSkip(person, isCanaryEmail)\n if (emailSkip) count(plan.emailSkipped, emailSkip)\n else plan.email.push(recipient)\n const pushSkip = tapToPayPushSkip(person, isCanaryEmail)\n if (pushSkip) count(plan.pushSkipped, pushSkip)\n else plan.push.push(recipient)\n }\n }\n return plan\n}\n\n/** An address as a dry run may show it: the first letter and the domain. */\nexport function maskAddress(email: string | null | undefined): string {\n const value = String(email ?? '').trim()\n const at = value.lastIndexOf('@')\n if (at < 1) return '(none)'\n return `${value[0]}***${value.slice(at)}`\n}\n"],"names":["TAP_TO_PAY_RELEASED_ENV","tapToPayReleased","env","String","trim","toLowerCase","TAP_TO_PAY_LAUNCH_FIELD","TAP_TO_PAY_LAUNCH_RECORD","TAP_TO_PAY_LAUNCH_PUSH_TYPE","TAP_TO_PAY_SET_UP_PATH","tapToPayStoreRefusal","store","canary","banned","commerceEnabled","chargesReady","currency","toUpperCase","registers","isTestAddress","email","isCanaryEmail","value","endsWith","tapToPayEmailSkip","person","emailedAtMs","staff","disabled","declinedProductEmail","suppressed","tapToPayPushSkip","pushedAtMs","posIosDevices","count","map","key","planTapToPayLaunch","stores","people","plan","eligible","refused","audience","push","emailSkipped","pushSkipped","seen","Set","refusal","managers","managerUids","uid","registerUids","has","get","add","recipient","manager","emailSkip","pushSkip","maskAddress","at","lastIndexOf","slice"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2CAgC2C,GAE3C,oFAAoF,GACpF,OAAO,MAAMA,0BAA0B,6BAA4B;AAEnE,kFAAkF,GAClF,OAAO,SAASC,iBAAiBC,GAAuC;QACxDA;IAAd,OAAOC,QAAOD,+BAAAA,GAAG,CAACF,wBAAwB,YAA5BE,+BAAgC,IAAIE,IAAI,GAAGC,WAAW,OAAO;AAC7E;AAEA,uEAAuE,GACvE,OAAO,MAAMC,0BAA0B,sBAAqB;AAC5D,sCAAsC,GACtC,OAAO,MAAMC,2BAA2B,iBAAgB;AAExD,4CAA4C,GAC5C,OAAO,MAAMC,8BAA8B,0BAAyB;AAEpE,2GAA2G,GAC3G,OAAO,MAAMC,yBAAyB,+BAA8B;AA6DpE,uEAAuE,GACvE,OAAO,SAASC,qBAAqBC,KAA0B;IAC7D,IAAIA,MAAMC,MAAM,EAAE,OAAO;IACzB,IAAID,MAAME,MAAM,EAAE,OAAO;IACzB,IAAI,CAACF,MAAMG,eAAe,EAAE,OAAO;IACnC,IAAI,CAACH,MAAMI,YAAY,EAAE,OAAO;IAChC,IAAIJ,MAAMK,QAAQ,CAACC,WAAW,OAAO,OAAO,OAAO;IACnD,IAAIN,MAAMO,SAAS,GAAG,GAAG,OAAO;IAChC,OAAO;AACT;AAEA,kGAAkG,GAClG,OAAO,SAASC,cAAcC,KAAgC,EAAEC,aAAyC;IACvG,MAAMC,QAAQnB,OAAOiB,gBAAAA,QAAS,IAAIhB,IAAI,GAAGC,WAAW;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MW,UAAUvC,qBAAqBC;QACrC,IAAIsC,SAAS;YACXf,MAAMM,KAAKF,MAAM,CAACI,OAAO,EAAEO;YAC3B;QACF;QACAT,KAAKF,MAAM,CAACG,QAAQ,IAAI;QACxB,MAAMS,WAAW,IAAIF,IAAIrC,MAAMwC,WAAW;QAC1C,KAAK,MAAMC,OAAO;eAAIzC,MAAMwC,WAAW;eAAKxC,MAAM0C,YAAY;SAAC,CAAE;YAC/D,IAAI,CAACD,OAAOL,KAAKO,GAAG,CAACF,MAAM;YAC3B,MAAM3B,SAASc,OAAOgB,GAAG,CAACH;YAC1B,IAAI,CAAC3B,QAAQ;YACbsB,KAAKS,GAAG,CAACJ;YACT,MAAMK,YAAqC;gBAAEL;gBAAKzC;gBAAO+C,SAASR,SAASI,GAAG,CAACF;YAAK;YACpFZ,KAAKG,QAAQ,CAACC,IAAI,CAACa;YACnB,MAAME,YAAYnC,kBAAkBC,QAAQJ;YAC5C,IAAIsC,WAAWzB,MAAMM,KAAKK,YAAY,EAAEc;iBACnCnB,KAAKpB,KAAK,CAACwB,IAAI,CAACa;YACrB,MAAMG,WAAW7B,iBAAiBN,QAAQJ;YAC1C,IAAIuC,UAAU1B,MAAMM,KAAKM,WAAW,EAAEc;iBACjCpB,KAAKI,IAAI,CAACA,IAAI,CAACa;QACtB;IACF;IACA,OAAOjB;AACT;AAEA,0EAA0E,GAC1E,OAAO,SAASqB,YAAYzC,KAAgC;IAC1D,MAAME,QAAQnB,OAAOiB,gBAAAA,QAAS,IAAIhB,IAAI;IACtC,MAAM0D,KAAKxC,MAAMyC,WAAW,CAAC;IAC7B,IAAID,KAAK,GAAG,OAAO;IACnB,OAAO,GAAGxC,KAAK,CAAC,EAAE,CAAC,GAAG,EAAEA,MAAM0C,KAAK,CAACF,KAAK;AAC3C"}
|
package/src/lib/plugin.js
CHANGED
|
@@ -26,6 +26,7 @@ const PosHardwareTermsSignPage = lazy(()=>import("./components/console/pos-hardw
|
|
|
26
26
|
const CommerceGlanceCard = lazy(()=>import("./components/console/commerce-glance-card.component.js"));
|
|
27
27
|
const NewestSiteUsersCard = lazy(()=>import("./components/console/newest-site-users-card.component.js"));
|
|
28
28
|
const SiteMemberPurchases = lazy(()=>import("./components/console/site-member-purchases.component.js"));
|
|
29
|
+
/** "Do you charge sales tax?" in Create site (AGL-4061): loads only with that dialog. */ const NewStoreTaxQuestion = lazy(()=>import("./components/console/new-store-tax-question.component.js"));
|
|
29
30
|
import { COMMERCE_CONSOLE_SECTIONS, COMMERCE_RETIRED_SECTIONS } from "./components/commerce-console-sections.js";
|
|
30
31
|
import { BUNDLE_ID } from "./constants/bundle-common.js";
|
|
31
32
|
import { COMMERCE_PERMISSIONS } from "./model/plugin-permissions.js";
|
|
@@ -174,6 +175,17 @@ const QuoteStartFromContact = lazy(()=>import("./components/console/quote-start.
|
|
|
174
175
|
widgetId: 'commerce-quote-from-contact',
|
|
175
176
|
title: 'Start a quote',
|
|
176
177
|
Component: QuoteStartFromContact
|
|
178
|
+
},
|
|
179
|
+
// "Do you charge sales tax?" among Create site's fields (AGL-4061),
|
|
180
|
+
// asked before the site exists, so the store is decided before its
|
|
181
|
+
// first sale. It hands its answer to the dialog and writes nothing; the
|
|
182
|
+
// create applies it (`declarations.console-server.ts`). Creating a site
|
|
183
|
+
// is the create's permission, as the starter picker's.
|
|
184
|
+
{
|
|
185
|
+
slot: 'hostCreateQuestions',
|
|
186
|
+
widgetId: 'commerce-new-store-tax',
|
|
187
|
+
permission: 'hosts.create',
|
|
188
|
+
Component: NewStoreTaxQuestion
|
|
177
189
|
}
|
|
178
190
|
],
|
|
179
191
|
navItems: [
|