@mj-biz-apps/orders-entities 5.20.0 → 5.21.0
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/dist/OrderHeaderEntity.d.ts +2 -2
- package/dist/OrderHeaderEntity.js +2 -2
- package/dist/accessOverride.d.ts +24 -0
- package/dist/accessOverride.d.ts.map +1 -0
- package/dist/accessOverride.js +31 -0
- package/dist/accessOverride.js.map +1 -0
- package/dist/checkout-attribution.d.ts +19 -0
- package/dist/checkout-attribution.d.ts.map +1 -0
- package/dist/checkout-attribution.js +18 -0
- package/dist/checkout-attribution.js.map +1 -0
- package/dist/checkout-questions.d.ts +87 -0
- package/dist/checkout-questions.d.ts.map +1 -0
- package/dist/checkout-questions.js +138 -0
- package/dist/checkout-questions.js.map +1 -0
- package/dist/configuration-types.d.ts +7 -0
- package/dist/configuration-types.d.ts.map +1 -1
- package/dist/generated/entities/__mj_BizAppsOrders.d.ts +1154 -73
- package/dist/generated/entities/__mj_BizAppsOrders.d.ts.map +1 -1
- package/dist/generated/entities/__mj_BizAppsOrders.js +1607 -19
- package/dist/generated/entities/__mj_BizAppsOrders.js.map +1 -1
- package/dist/generated/remote_operations.d.ts +76 -0
- package/dist/generated/remote_operations.d.ts.map +1 -1
- package/dist/generated/remote_operations.js +36 -0
- package/dist/generated/remote_operations.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -156,8 +156,8 @@ export declare class OrderHeaderEntity extends mjBizAppsOrdersOrderHeaderEntity
|
|
|
156
156
|
* sale counts in is decided by where the customer was on the date of sale. An address that is
|
|
157
157
|
* set cannot be replaced or cleared. An empty one may be filled, as an empty bill-to party may
|
|
158
158
|
* be filled after confirm, and the server snapshots it on that save.
|
|
159
|
-
* `
|
|
160
|
-
* `
|
|
159
|
+
* `trg_OrderHeader_ImmutableAfterConfirm` (51015) and
|
|
160
|
+
* `trg_OrderLine_ImmutableAfterConfirm` (51016) hold the same rule at the database; this
|
|
161
161
|
* says so before the round trip, against the field that was changed.
|
|
162
162
|
*
|
|
163
163
|
* The snapshots are the server's to write, from the Address rows, so a change to one from
|
|
@@ -353,8 +353,8 @@ let OrderHeaderEntity = OrderHeaderEntity_1 = class OrderHeaderEntity extends mj
|
|
|
353
353
|
* sale counts in is decided by where the customer was on the date of sale. An address that is
|
|
354
354
|
* set cannot be replaced or cleared. An empty one may be filled, as an empty bill-to party may
|
|
355
355
|
* be filled after confirm, and the server snapshots it on that save.
|
|
356
|
-
* `
|
|
357
|
-
* `
|
|
356
|
+
* `trg_OrderHeader_ImmutableAfterConfirm` (51015) and
|
|
357
|
+
* `trg_OrderLine_ImmutableAfterConfirm` (51016) hold the same rule at the database; this
|
|
358
358
|
* says so before the round trip, against the field that was changed.
|
|
359
359
|
*
|
|
360
360
|
* The snapshots are the server's to write, from the Address rows, so a change to one from
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Access overrides — exceptions to payment-gated access on an order (bizapps-orders#268).
|
|
3
|
+
*
|
|
4
|
+
* MJ.BizApps.Orders.Access.Override parent; holding it grants both children
|
|
5
|
+
* MJ.BizApps.Orders.Access.Override.WaivePaymentHold request a WaivePaymentHold override
|
|
6
|
+
* MJ.BizApps.Orders.Access.Override.DeferCutoff request a DeferCutoff override
|
|
7
|
+
*
|
|
8
|
+
* These govern who may REQUEST an override. Who may approve one is not settled (bizapps-orders#360).
|
|
9
|
+
*
|
|
10
|
+
* Shared so the browser and the server read the same names and the same rule. The server refuses a
|
|
11
|
+
* request outright when the rows are missing from metadata; this answer is false in that case.
|
|
12
|
+
*/
|
|
13
|
+
import { type AuthorizationInfo, type IMetadataProvider, type UserInfo } from '@memberjunction/core';
|
|
14
|
+
export type AccessOverrideKind = 'WaivePaymentHold' | 'DeferCutoff';
|
|
15
|
+
export declare const ACCESS_OVERRIDE_AUTH: {
|
|
16
|
+
readonly Parent: "MJ.BizApps.Orders.Access.Override";
|
|
17
|
+
readonly WaivePaymentHold: "MJ.BizApps.Orders.Access.Override.WaivePaymentHold";
|
|
18
|
+
readonly DeferCutoff: "MJ.BizApps.Orders.Access.Override.DeferCutoff";
|
|
19
|
+
};
|
|
20
|
+
/** The override types `user` may request, directly or through the parent authorization. */
|
|
21
|
+
export declare function userRequestableAccessOverrides(user: UserInfo | null | undefined, provider?: IMetadataProvider | {
|
|
22
|
+
Authorizations?: AuthorizationInfo[];
|
|
23
|
+
}): AccessOverrideKind[];
|
|
24
|
+
//# sourceMappingURL=accessOverride.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accessOverride.d.ts","sourceRoot":"","sources":["../src/accessOverride.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAGH,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,QAAQ,EAChB,MAAM,sBAAsB,CAAC;AAE9B,MAAM,MAAM,kBAAkB,GAAG,kBAAkB,GAAG,aAAa,CAAC;AAEpE,eAAO,MAAM,oBAAoB;;;;CAIvB,CAAC;AAEX,2FAA2F;AAC3F,wBAAgB,8BAA8B,CAC1C,IAAI,EAAE,QAAQ,GAAG,IAAI,GAAG,SAAS,EACjC,QAAQ,CAAC,EAAE,iBAAiB,GAAG;IAAE,cAAc,CAAC,EAAE,iBAAiB,EAAE,CAAA;CAAE,GACxE,kBAAkB,EAAE,CAStB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Access overrides — exceptions to payment-gated access on an order (bizapps-orders#268).
|
|
3
|
+
*
|
|
4
|
+
* MJ.BizApps.Orders.Access.Override parent; holding it grants both children
|
|
5
|
+
* MJ.BizApps.Orders.Access.Override.WaivePaymentHold request a WaivePaymentHold override
|
|
6
|
+
* MJ.BizApps.Orders.Access.Override.DeferCutoff request a DeferCutoff override
|
|
7
|
+
*
|
|
8
|
+
* These govern who may REQUEST an override. Who may approve one is not settled (bizapps-orders#360).
|
|
9
|
+
*
|
|
10
|
+
* Shared so the browser and the server read the same names and the same rule. The server refuses a
|
|
11
|
+
* request outright when the rows are missing from metadata; this answer is false in that case.
|
|
12
|
+
*/
|
|
13
|
+
import { AuthorizationEvaluator, Metadata, } from '@memberjunction/core';
|
|
14
|
+
export const ACCESS_OVERRIDE_AUTH = {
|
|
15
|
+
Parent: 'MJ.BizApps.Orders.Access.Override',
|
|
16
|
+
WaivePaymentHold: 'MJ.BizApps.Orders.Access.Override.WaivePaymentHold',
|
|
17
|
+
DeferCutoff: 'MJ.BizApps.Orders.Access.Override.DeferCutoff',
|
|
18
|
+
};
|
|
19
|
+
/** The override types `user` may request, directly or through the parent authorization. */
|
|
20
|
+
export function userRequestableAccessOverrides(user, provider) {
|
|
21
|
+
if (!user)
|
|
22
|
+
return [];
|
|
23
|
+
const auths = provider?.Authorizations ?? new Metadata().Authorizations ?? [];
|
|
24
|
+
const evaluator = new AuthorizationEvaluator();
|
|
25
|
+
const holds = (name) => {
|
|
26
|
+
const auth = auths.find((a) => a.Name === name);
|
|
27
|
+
return !!auth && evaluator.UserCanExecuteWithAncestors(auth, user, auths);
|
|
28
|
+
};
|
|
29
|
+
return ['WaivePaymentHold', 'DeferCutoff'].filter((t) => holds(ACCESS_OVERRIDE_AUTH[t]));
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=accessOverride.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accessOverride.js","sourceRoot":"","sources":["../src/accessOverride.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EACH,sBAAsB,EACtB,QAAQ,GAIX,MAAM,sBAAsB,CAAC;AAI9B,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAChC,MAAM,EAAE,mCAAmC;IAC3C,gBAAgB,EAAE,oDAAoD;IACtE,WAAW,EAAE,+CAA+C;CACtD,CAAC;AAEX,2FAA2F;AAC3F,MAAM,UAAU,8BAA8B,CAC1C,IAAiC,EACjC,QAAuE;IAEvE,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAC;IACrB,MAAM,KAAK,GAAG,QAAQ,EAAE,cAAc,IAAI,IAAI,QAAQ,EAAE,CAAC,cAAc,IAAI,EAAE,CAAC;IAC9E,MAAM,SAAS,GAAG,IAAI,sBAAsB,EAAE,CAAC;IAC/C,MAAM,KAAK,GAAG,CAAC,IAAY,EAAW,EAAE;QACpC,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;QAChD,OAAO,CAAC,CAAC,IAAI,IAAI,SAAS,CAAC,2BAA2B,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IAC9E,CAAC,CAAC;IACF,OAAQ,CAAC,kBAAkB,EAAE,aAAa,CAAW,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACxG,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a checkout came from, as the embedding host states it (for example a chat or voice agent
|
|
3
|
+
* that opens the checkout inside its own panel, with the conversation it came from).
|
|
4
|
+
*
|
|
5
|
+
* Kept on the checkout session (`MetadataJSON.Attribution`), which points at the order once it
|
|
6
|
+
* confirms (`DraftOrderID`). It is reporting data: an attribution that cannot be read is dropped,
|
|
7
|
+
* never a reason to refuse a buyer's checkout. Pure, so the browser and the server share it.
|
|
8
|
+
*/
|
|
9
|
+
export interface CheckoutAttribution {
|
|
10
|
+
/** The channel, e.g. `voice_agent`. Letters, digits and `_ - . :`, at most 50 characters. */
|
|
11
|
+
Source: string;
|
|
12
|
+
/** The host's own reference, e.g. a conversation id. At most 200 printable characters. */
|
|
13
|
+
Reference: string | null;
|
|
14
|
+
}
|
|
15
|
+
export declare const MAX_ATTRIBUTION_SOURCE_LENGTH = 50;
|
|
16
|
+
export declare const MAX_ATTRIBUTION_REFERENCE_LENGTH = 200;
|
|
17
|
+
/** The attribution to keep, or null when there is none or it cannot be read. */
|
|
18
|
+
export declare function NormalizeCheckoutAttribution(input: unknown): CheckoutAttribution | null;
|
|
19
|
+
//# sourceMappingURL=checkout-attribution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkout-attribution.d.ts","sourceRoot":"","sources":["../src/checkout-attribution.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,WAAW,mBAAmB;IAChC,6FAA6F;IAC7F,MAAM,EAAE,MAAM,CAAC;IACf,0FAA0F;IAC1F,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,eAAO,MAAM,6BAA6B,KAAK,CAAC;AAChD,eAAO,MAAM,gCAAgC,MAAM,CAAC;AAMpD,gFAAgF;AAChF,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,OAAO,GAAG,mBAAmB,GAAG,IAAI,CAQvF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const MAX_ATTRIBUTION_SOURCE_LENGTH = 50;
|
|
2
|
+
export const MAX_ATTRIBUTION_REFERENCE_LENGTH = 200;
|
|
3
|
+
const SOURCE = /^[A-Za-z0-9_.:-]+$/;
|
|
4
|
+
// Printable, no control characters: it ends up in reports and exports.
|
|
5
|
+
const PRINTABLE = /^[^\u0000-\u001f\u007f]+$/;
|
|
6
|
+
/** The attribution to keep, or null when there is none or it cannot be read. */
|
|
7
|
+
export function NormalizeCheckoutAttribution(input) {
|
|
8
|
+
if (!input || typeof input !== 'object' || Array.isArray(input))
|
|
9
|
+
return null;
|
|
10
|
+
const raw = input;
|
|
11
|
+
const source = typeof raw['source'] === 'string' ? raw['source'].trim() : '';
|
|
12
|
+
if (!source || source.length > MAX_ATTRIBUTION_SOURCE_LENGTH || !SOURCE.test(source))
|
|
13
|
+
return null;
|
|
14
|
+
const refRaw = typeof raw['reference'] === 'string' ? raw['reference'].trim() : '';
|
|
15
|
+
const reference = refRaw && refRaw.length <= MAX_ATTRIBUTION_REFERENCE_LENGTH && PRINTABLE.test(refRaw) ? refRaw : null;
|
|
16
|
+
return { Source: source, Reference: reference };
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=checkout-attribution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkout-attribution.js","sourceRoot":"","sources":["../src/checkout-attribution.ts"],"names":[],"mappings":"AAeA,MAAM,CAAC,MAAM,6BAA6B,GAAG,EAAE,CAAC;AAChD,MAAM,CAAC,MAAM,gCAAgC,GAAG,GAAG,CAAC;AAEpD,MAAM,MAAM,GAAG,oBAAoB,CAAC;AACpC,uEAAuE;AACvE,MAAM,SAAS,GAAG,2BAA2B,CAAC;AAE9C,gFAAgF;AAChF,MAAM,UAAU,4BAA4B,CAAC,KAAc;IACvD,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAC7E,MAAM,GAAG,GAAG,KAAgC,CAAC;IAC7C,MAAM,MAAM,GAAG,OAAO,GAAG,CAAC,QAAQ,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC7E,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,6BAA6B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;QAAE,OAAO,IAAI,CAAC;IAClG,MAAM,MAAM,GAAG,OAAO,GAAG,CAAC,WAAW,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACnF,MAAM,SAAS,GAAG,MAAM,IAAI,MAAM,CAAC,MAAM,IAAI,gCAAgC,IAAI,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;IACxH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Questions a checkout widget asks the buyer before payment, and the check their answers pass.
|
|
3
|
+
*
|
|
4
|
+
* The questions live in the widget's Configuration (`questions`), not in any entity's columns, so
|
|
5
|
+
* a host can ask "How did you hear about us?" without a schema change. Pure; no database, no
|
|
6
|
+
* provider. The browser runs the same check to gate the Pay button, and the server runs it on the
|
|
7
|
+
* answers it stored before it opens a payment intent or completes the checkout — the server check
|
|
8
|
+
* is the one that counts.
|
|
9
|
+
*
|
|
10
|
+
* Answers are judged against the widget's own question list, never against anything the buyer
|
|
11
|
+
* sent: a key the widget does not ask is refused, and a select answer must be one of its options.
|
|
12
|
+
*/
|
|
13
|
+
/** One choice of a `select` question. A bare string is both its value and its label. */
|
|
14
|
+
export interface CheckoutQuestionOption {
|
|
15
|
+
value: string;
|
|
16
|
+
label: string;
|
|
17
|
+
}
|
|
18
|
+
export interface CheckoutQuestion {
|
|
19
|
+
/** Stable identifier, recorded on the order as `QuestionKey`. */
|
|
20
|
+
key: string;
|
|
21
|
+
/** The question as the buyer sees it. */
|
|
22
|
+
label: string;
|
|
23
|
+
type: 'select' | 'text';
|
|
24
|
+
/** Required for `select`. */
|
|
25
|
+
options?: Array<string | CheckoutQuestionOption>;
|
|
26
|
+
required?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* The value of the option that needs a free-text answer ("Other"). Choosing it makes the
|
|
29
|
+
* text answer required. `select` only.
|
|
30
|
+
*/
|
|
31
|
+
otherOptionKey?: string;
|
|
32
|
+
/** Longest accepted answer. Defaults to, and may not exceed, {@link MAX_CHECKOUT_ANSWER_LENGTH}. */
|
|
33
|
+
maxLength?: number;
|
|
34
|
+
}
|
|
35
|
+
/** The buyer's answer to one question, as the checkout edge receives it. */
|
|
36
|
+
export interface CheckoutAnswerInput {
|
|
37
|
+
Value?: string;
|
|
38
|
+
/** The free-text answer given after choosing the question's `otherOptionKey` option. */
|
|
39
|
+
OtherText?: string;
|
|
40
|
+
}
|
|
41
|
+
/** Answers keyed by question key. */
|
|
42
|
+
export type CheckoutAnswersInput = Record<string, CheckoutAnswerInput>;
|
|
43
|
+
/** An answer that passed the check, shaped as the order records it. */
|
|
44
|
+
export interface ResolvedCheckoutAnswer {
|
|
45
|
+
QuestionKey: string;
|
|
46
|
+
QuestionLabel: string;
|
|
47
|
+
Answer: string;
|
|
48
|
+
OtherText: string | null;
|
|
49
|
+
}
|
|
50
|
+
export interface CheckoutAnswersCheck {
|
|
51
|
+
/** Every answered question, in the widget's question order. Empty when `Error` is set. */
|
|
52
|
+
Answers: ResolvedCheckoutAnswer[];
|
|
53
|
+
/** Why the answers were refused, worded for the buyer. */
|
|
54
|
+
Error?: string;
|
|
55
|
+
}
|
|
56
|
+
/** Column widths of OrderCheckoutAnswer. */
|
|
57
|
+
export declare const MAX_CHECKOUT_QUESTION_KEY_LENGTH = 100;
|
|
58
|
+
export declare const MAX_CHECKOUT_QUESTION_LABEL_LENGTH = 500;
|
|
59
|
+
export declare const MAX_CHECKOUT_ANSWER_LENGTH = 1000;
|
|
60
|
+
/** Message for a widget whose `questions` cannot be read; the checkout is refused, not skipped. */
|
|
61
|
+
export declare const INVALID_CHECKOUT_QUESTIONS_MESSAGE = "This checkout is not configured correctly (its questions are invalid).";
|
|
62
|
+
export declare function CheckoutQuestionOptionValue(option: string | CheckoutQuestionOption): string;
|
|
63
|
+
export declare function CheckoutQuestionOptionLabel(option: string | CheckoutQuestionOption): string;
|
|
64
|
+
/**
|
|
65
|
+
* The widget's questions, or an error when `questions` is present but malformed.
|
|
66
|
+
*
|
|
67
|
+
* A malformed list refuses the checkout rather than dropping the bad entries: a required question
|
|
68
|
+
* that silently disappeared would let every order through without the answer the host asked for.
|
|
69
|
+
*/
|
|
70
|
+
export declare function ReadCheckoutQuestions(raw: unknown): {
|
|
71
|
+
Questions: CheckoutQuestion[];
|
|
72
|
+
Error?: string;
|
|
73
|
+
};
|
|
74
|
+
/** Longest answer a question accepts: its own `maxLength`, capped at the column width. */
|
|
75
|
+
export declare function CheckoutAnswerMaxLength(question: CheckoutQuestion): number;
|
|
76
|
+
/**
|
|
77
|
+
* Check the buyer's answers against the widget's questions.
|
|
78
|
+
*
|
|
79
|
+
* Refuses: answers that are not an object, a key the widget does not ask, a missing required
|
|
80
|
+
* answer, a select answer that is not one of its options, the "Other" option without its text,
|
|
81
|
+
* and an answer longer than the question accepts. Answers are trimmed; text given alongside an
|
|
82
|
+
* option other than "Other" is dropped.
|
|
83
|
+
*/
|
|
84
|
+
export declare function CheckAnswersAgainstQuestions(questions: CheckoutQuestion[], answers: unknown): CheckoutAnswersCheck;
|
|
85
|
+
/** {@link ReadCheckoutQuestions} then {@link CheckAnswersAgainstQuestions}, for a raw Configuration value. */
|
|
86
|
+
export declare function CheckCheckoutAnswers(rawQuestions: unknown, answers: unknown): CheckoutAnswersCheck;
|
|
87
|
+
//# sourceMappingURL=checkout-questions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkout-questions.d.ts","sourceRoot":"","sources":["../src/checkout-questions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,wFAAwF;AACxF,MAAM,WAAW,sBAAsB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC7B,iEAAiE;IACjE,GAAG,EAAE,MAAM,CAAC;IACZ,yCAAyC;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,QAAQ,GAAG,MAAM,CAAC;IACx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AC,EAAE,MAAM,CAAA;CAAE,CAYrG;AAsBD,0FAA0F;AAC1F,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,MAAM,CAE1E;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAAC,SAAS,EAAE,gBAAgB,EAAE,EAAE,OAAO,EAAE,OAAO,GAAG,oBAAoB,CAgDlH;AAED,8GAA8G;AAC9G,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,oBAAoB,CAIlG"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Questions a checkout widget asks the buyer before payment, and the check their answers pass.
|
|
3
|
+
*
|
|
4
|
+
* The questions live in the widget's Configuration (`questions`), not in any entity's columns, so
|
|
5
|
+
* a host can ask "How did you hear about us?" without a schema change. Pure; no database, no
|
|
6
|
+
* provider. The browser runs the same check to gate the Pay button, and the server runs it on the
|
|
7
|
+
* answers it stored before it opens a payment intent or completes the checkout — the server check
|
|
8
|
+
* is the one that counts.
|
|
9
|
+
*
|
|
10
|
+
* Answers are judged against the widget's own question list, never against anything the buyer
|
|
11
|
+
* sent: a key the widget does not ask is refused, and a select answer must be one of its options.
|
|
12
|
+
*/
|
|
13
|
+
/** Column widths of OrderCheckoutAnswer. */
|
|
14
|
+
export const MAX_CHECKOUT_QUESTION_KEY_LENGTH = 100;
|
|
15
|
+
export const MAX_CHECKOUT_QUESTION_LABEL_LENGTH = 500;
|
|
16
|
+
export const MAX_CHECKOUT_ANSWER_LENGTH = 1000;
|
|
17
|
+
/** Message for a widget whose `questions` cannot be read; the checkout is refused, not skipped. */
|
|
18
|
+
export const INVALID_CHECKOUT_QUESTIONS_MESSAGE = 'This checkout is not configured correctly (its questions are invalid).';
|
|
19
|
+
export function CheckoutQuestionOptionValue(option) {
|
|
20
|
+
return typeof option === 'string' ? option : option.value;
|
|
21
|
+
}
|
|
22
|
+
export function CheckoutQuestionOptionLabel(option) {
|
|
23
|
+
return typeof option === 'string' ? option : option.label;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The widget's questions, or an error when `questions` is present but malformed.
|
|
27
|
+
*
|
|
28
|
+
* A malformed list refuses the checkout rather than dropping the bad entries: a required question
|
|
29
|
+
* that silently disappeared would let every order through without the answer the host asked for.
|
|
30
|
+
*/
|
|
31
|
+
export function ReadCheckoutQuestions(raw) {
|
|
32
|
+
if (raw === undefined || raw === null)
|
|
33
|
+
return { Questions: [] };
|
|
34
|
+
if (!Array.isArray(raw))
|
|
35
|
+
return { Questions: [], Error: INVALID_CHECKOUT_QUESTIONS_MESSAGE };
|
|
36
|
+
const keys = new Set();
|
|
37
|
+
for (const q of raw) {
|
|
38
|
+
if (!IsValidQuestion(q) || keys.has(q.key)) {
|
|
39
|
+
return { Questions: [], Error: INVALID_CHECKOUT_QUESTIONS_MESSAGE };
|
|
40
|
+
}
|
|
41
|
+
keys.add(q.key);
|
|
42
|
+
}
|
|
43
|
+
return { Questions: raw };
|
|
44
|
+
}
|
|
45
|
+
function IsValidQuestion(q) {
|
|
46
|
+
if (!q || typeof q !== 'object')
|
|
47
|
+
return false;
|
|
48
|
+
const c = q;
|
|
49
|
+
if (typeof c.key !== 'string' || !c.key.trim() || c.key.length > MAX_CHECKOUT_QUESTION_KEY_LENGTH)
|
|
50
|
+
return false;
|
|
51
|
+
if (typeof c.label !== 'string' || !c.label.trim() || c.label.length > MAX_CHECKOUT_QUESTION_LABEL_LENGTH)
|
|
52
|
+
return false;
|
|
53
|
+
if (c.maxLength !== undefined && (!Number.isInteger(c.maxLength) || c.maxLength < 1))
|
|
54
|
+
return false;
|
|
55
|
+
if (c.type === 'text')
|
|
56
|
+
return c.options === undefined && c.otherOptionKey === undefined;
|
|
57
|
+
if (c.type !== 'select')
|
|
58
|
+
return false;
|
|
59
|
+
if (!Array.isArray(c.options) || c.options.length === 0)
|
|
60
|
+
return false;
|
|
61
|
+
const values = new Set();
|
|
62
|
+
for (const o of c.options) {
|
|
63
|
+
const value = typeof o === 'string' ? o : o && typeof o === 'object' ? o.value : undefined;
|
|
64
|
+
const label = typeof o === 'string' ? o : o && typeof o === 'object' ? o.label : undefined;
|
|
65
|
+
if (typeof value !== 'string' || !value || typeof label !== 'string' || !label || values.has(value))
|
|
66
|
+
return false;
|
|
67
|
+
if (value.length > MAX_CHECKOUT_ANSWER_LENGTH)
|
|
68
|
+
return false;
|
|
69
|
+
values.add(value);
|
|
70
|
+
}
|
|
71
|
+
return c.otherOptionKey === undefined || values.has(c.otherOptionKey);
|
|
72
|
+
}
|
|
73
|
+
/** Longest answer a question accepts: its own `maxLength`, capped at the column width. */
|
|
74
|
+
export function CheckoutAnswerMaxLength(question) {
|
|
75
|
+
return Math.min(question.maxLength ?? MAX_CHECKOUT_ANSWER_LENGTH, MAX_CHECKOUT_ANSWER_LENGTH);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Check the buyer's answers against the widget's questions.
|
|
79
|
+
*
|
|
80
|
+
* Refuses: answers that are not an object, a key the widget does not ask, a missing required
|
|
81
|
+
* answer, a select answer that is not one of its options, the "Other" option without its text,
|
|
82
|
+
* and an answer longer than the question accepts. Answers are trimmed; text given alongside an
|
|
83
|
+
* option other than "Other" is dropped.
|
|
84
|
+
*/
|
|
85
|
+
export function CheckAnswersAgainstQuestions(questions, answers) {
|
|
86
|
+
const refuse = (error) => ({ Answers: [], Error: error });
|
|
87
|
+
if (answers !== undefined && answers !== null && (typeof answers !== 'object' || Array.isArray(answers))) {
|
|
88
|
+
return refuse('The checkout answers could not be read.');
|
|
89
|
+
}
|
|
90
|
+
const input = (answers ?? {});
|
|
91
|
+
const asked = new Set(questions.map((q) => q.key));
|
|
92
|
+
for (const key of Object.keys(input)) {
|
|
93
|
+
if (!asked.has(key))
|
|
94
|
+
return refuse('An answer was sent for a question this checkout does not ask.');
|
|
95
|
+
}
|
|
96
|
+
const resolved = [];
|
|
97
|
+
for (const q of questions) {
|
|
98
|
+
const raw = input[q.key];
|
|
99
|
+
if (raw !== undefined && raw !== null && (typeof raw !== 'object' || Array.isArray(raw))) {
|
|
100
|
+
return refuse(`The answer to "${q.label}" could not be read.`);
|
|
101
|
+
}
|
|
102
|
+
const entry = (raw ?? {});
|
|
103
|
+
const value = typeof entry.Value === 'string' ? entry.Value.trim() : '';
|
|
104
|
+
const otherText = typeof entry.OtherText === 'string' ? entry.OtherText.trim() : '';
|
|
105
|
+
if (!value) {
|
|
106
|
+
if (q.required)
|
|
107
|
+
return refuse(`"${q.label}" needs an answer.`);
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
if (value.length > CheckoutAnswerMaxLength(q)) {
|
|
111
|
+
return refuse(`The answer to "${q.label}" is too long (at most ${CheckoutAnswerMaxLength(q)} characters).`);
|
|
112
|
+
}
|
|
113
|
+
let recordedOther = null;
|
|
114
|
+
if (q.type === 'select') {
|
|
115
|
+
if (!(q.options ?? []).some((o) => CheckoutQuestionOptionValue(o) === value)) {
|
|
116
|
+
return refuse(`"${value}" is not one of the choices for "${q.label}".`);
|
|
117
|
+
}
|
|
118
|
+
if (q.otherOptionKey !== undefined && value === q.otherOptionKey) {
|
|
119
|
+
if (!otherText)
|
|
120
|
+
return refuse(`Please say more about your answer to "${q.label}".`);
|
|
121
|
+
if (otherText.length > MAX_CHECKOUT_ANSWER_LENGTH) {
|
|
122
|
+
return refuse(`The answer to "${q.label}" is too long (at most ${MAX_CHECKOUT_ANSWER_LENGTH} characters).`);
|
|
123
|
+
}
|
|
124
|
+
recordedOther = otherText;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
resolved.push({ QuestionKey: q.key, QuestionLabel: q.label, Answer: value, OtherText: recordedOther });
|
|
128
|
+
}
|
|
129
|
+
return { Answers: resolved };
|
|
130
|
+
}
|
|
131
|
+
/** {@link ReadCheckoutQuestions} then {@link CheckAnswersAgainstQuestions}, for a raw Configuration value. */
|
|
132
|
+
export function CheckCheckoutAnswers(rawQuestions, answers) {
|
|
133
|
+
const read = ReadCheckoutQuestions(rawQuestions);
|
|
134
|
+
if (read.Error)
|
|
135
|
+
return { Answers: [], Error: read.Error };
|
|
136
|
+
return CheckAnswersAgainstQuestions(read.Questions, answers);
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=checkout-questions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkout-questions.js","sourceRoot":"","sources":["../src/checkout-questions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAmDH,4CAA4C;AAC5C,MAAM,CAAC,MAAM,gCAAgC,GAAG,GAAG,CAAC;AACpD,MAAM,CAAC,MAAM,kCAAkC,GAAG,GAAG,CAAC;AACtD,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAI,CAAC;AAE/C,mGAAmG;AACnG,MAAM,CAAC,MAAM,kCAAkC,GAAG,wEAAwE,CAAC;AAE3H,MAAM,UAAU,2BAA2B,CAAC,MAAuC;IAC/E,OAAO,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,2BAA2B,CAAC,MAAuC;IAC/E,OAAO,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;AAC9D,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,GAAY;IAC9C,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;IAChE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;QAAE,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,KAAK,EAAE,kCAAkC,EAAE,CAAC;IAE7F,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,KAAK,MAAM,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M,CAAC,kBAAkB,CAAC,CAAC,KAAK,0BAA0B,0BAA0B,eAAe,CAAC,CAAC;gBAChH,CAAC;gBACD,aAAa,GAAG,SAAS,CAAC;YAC9B,CAAC;QACL,CAAC;QAED,QAAQ,CAAC,IAAI,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,GAAG,EAAE,aAAa,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC,CAAC;IAC3G,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;AACjC,CAAC;AAED,8GAA8G;AAC9G,MAAM,UAAU,oBAAoB,CAAC,YAAqB,EAAE,OAAgB;IACxE,MAAM,IAAI,GAAG,qBAAqB,CAAC,YAAY,CAAC,CAAC;IACjD,IAAI,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;IAC1D,OAAO,4BAA4B,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AACjE,CAAC"}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @module @mj-biz-apps/orders-entities/configuration-types
|
|
8
8
|
*/
|
|
9
|
+
import type { CheckoutQuestion } from './checkout-questions.js';
|
|
9
10
|
export interface CustomUIThemeConfiguration {
|
|
10
11
|
primaryColor?: string;
|
|
11
12
|
accentColor?: string;
|
|
@@ -121,6 +122,12 @@ export interface CheckoutWidgetConfiguration {
|
|
|
121
122
|
value: string | number;
|
|
122
123
|
}>;
|
|
123
124
|
}>;
|
|
125
|
+
/**
|
|
126
|
+
* Questions the buyer answers before paying, such as "How did you hear about us?". Not
|
|
127
|
+
* columns on any entity: the answers are recorded on the confirmed order as Order Checkout
|
|
128
|
+
* Answers. A required question blocks the payment intent and completion until answered.
|
|
129
|
+
*/
|
|
130
|
+
questions?: CheckoutQuestion[];
|
|
124
131
|
/**
|
|
125
132
|
* The PaymentProvider row id used to open payment intents for this widget's sessions.
|
|
126
133
|
* Admin-authored, server-resolved — never accepted from the client. Required before a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configuration-types.d.ts","sourceRoot":"","sources":["../src/configuration-types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,WAAW,0BAA0B;IACvC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,qBAAqB;IAClC;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,KAAK,CAAC,EAAE,0BAA0B,CAAC;IACnC;;OAEG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B;;OAEG;IACH,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,0BAA0B;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC,CAAC;IAC3D,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1B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