@proxy-checkout/server-js 0.1.0-prx-146.161.1 → 0.1.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/README.md +0 -1
- package/dist/cjs/client.d.cts +0 -3
- package/dist/cjs/client.d.ts +0 -3
- package/dist/cjs/client.js +0 -4
- package/dist/cjs/errors.d.cts +1 -1
- package/dist/cjs/errors.d.ts +1 -1
- package/dist/cjs/events.d.cts +1 -10
- package/dist/cjs/events.d.ts +1 -10
- package/dist/cjs/events.js +0 -26
- package/dist/cjs/index.d.cts +1 -2
- package/dist/cjs/index.d.ts +1 -2
- package/dist/cjs/index.js +1 -4
- package/dist/cjs/lifecycle.js +0 -1
- package/dist/cjs/provider-acquisitions.d.cts +0 -23
- package/dist/cjs/provider-acquisitions.d.ts +0 -23
- package/dist/cjs/provider-acquisitions.js +0 -35
- package/dist/cjs/subscriptions.d.cts +0 -18
- package/dist/cjs/subscriptions.d.ts +0 -18
- package/dist/cjs/subscriptions.js +0 -50
- package/dist/cjs/version.d.cts +2 -2
- package/dist/cjs/version.d.ts +2 -2
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/webhook-events.d.cts +0 -17
- package/dist/cjs/webhook-events.d.ts +0 -17
- package/dist/cjs/webhook-events.js +0 -34
- package/dist/esm/client.d.ts +0 -3
- package/dist/esm/client.js +0 -4
- package/dist/esm/errors.d.ts +1 -1
- package/dist/esm/events.d.ts +1 -10
- package/dist/esm/events.js +0 -26
- package/dist/esm/index.d.ts +1 -2
- package/dist/esm/index.js +0 -1
- package/dist/esm/lifecycle.js +0 -1
- package/dist/esm/provider-acquisitions.d.ts +0 -23
- package/dist/esm/provider-acquisitions.js +0 -35
- package/dist/esm/subscriptions.d.ts +0 -18
- package/dist/esm/subscriptions.js +0 -50
- package/dist/esm/version.d.ts +2 -2
- package/dist/esm/version.js +1 -1
- package/dist/esm/webhook-events.d.ts +0 -17
- package/dist/esm/webhook-events.js +0 -34
- package/package.json +1 -1
- package/dist/cjs/live-contract-diagnostics.d.cts +0 -192
- package/dist/cjs/live-contract-diagnostics.d.ts +0 -192
- package/dist/cjs/live-contract-diagnostics.js +0 -557
- package/dist/esm/live-contract-diagnostics.d.ts +0 -192
- package/dist/esm/live-contract-diagnostics.js +0 -553
|
@@ -1,553 +0,0 @@
|
|
|
1
|
-
import { requireBoolean, requireInteger, requireJsonObject, requireNullableString, requireString, } from "./response-validators.js";
|
|
2
|
-
const maxSessions = 100;
|
|
3
|
-
const maxRows = 2_000;
|
|
4
|
-
const runIdPattern = /^stripe-contract-[a-z0-9-]{6,120}$/;
|
|
5
|
-
export const proxyCheckoutLiveContractDiagnosticEndpoints = [
|
|
6
|
-
{
|
|
7
|
-
method: "GET",
|
|
8
|
-
operation: "liveContractDiagnostics.retrieve",
|
|
9
|
-
path: "/stripe_live_contract_diagnostics",
|
|
10
|
-
},
|
|
11
|
-
];
|
|
12
|
-
export class ProxyLiveContractDiagnosticsResource {
|
|
13
|
-
httpClient;
|
|
14
|
-
constructor(httpClient) {
|
|
15
|
-
this.httpClient = httpClient;
|
|
16
|
-
}
|
|
17
|
-
async retrieve(input, options = {}) {
|
|
18
|
-
matchingString(input.runId, "liveContractDiagnostics.retrieve.runId", runIdPattern);
|
|
19
|
-
const query = new URLSearchParams();
|
|
20
|
-
query.set("run_id", input.runId);
|
|
21
|
-
query.set("merchant_psp_config_id", input.merchantPspConfigId);
|
|
22
|
-
const response = await this.httpClient.request("GET", `/stripe_live_contract_diagnostics?${query.toString()}`, undefined, options);
|
|
23
|
-
return parseDiagnostic(response);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
function parseDiagnostic(response) {
|
|
27
|
-
const operation = "liveContractDiagnostics.retrieve";
|
|
28
|
-
const body = exactObject(response, operation, [
|
|
29
|
-
"baseline",
|
|
30
|
-
"config",
|
|
31
|
-
"deployment",
|
|
32
|
-
"run",
|
|
33
|
-
"version",
|
|
34
|
-
]);
|
|
35
|
-
const baseline = exactObject(body.baseline, `${operation}.baseline`, [
|
|
36
|
-
"active_lifecycle_recovery_work",
|
|
37
|
-
"earned_fee_rows",
|
|
38
|
-
"non_none_fee_diagnostic_rows",
|
|
39
|
-
"open_acquisitions",
|
|
40
|
-
"undelivered_outbox_events",
|
|
41
|
-
"unresolved_reconciliation_issues",
|
|
42
|
-
]);
|
|
43
|
-
const config = exactObject(body.config, `${operation}.config`, [
|
|
44
|
-
"account_ref_hash",
|
|
45
|
-
"id",
|
|
46
|
-
"ingress",
|
|
47
|
-
"lifecycle_status",
|
|
48
|
-
"merchant_mode",
|
|
49
|
-
"unattributed_open_acquisition_signal",
|
|
50
|
-
]);
|
|
51
|
-
const deployment = exactObject(body.deployment, `${operation}.deployment`, [
|
|
52
|
-
"artifact_digest",
|
|
53
|
-
"commit_sha",
|
|
54
|
-
"environment",
|
|
55
|
-
"preview_id",
|
|
56
|
-
]);
|
|
57
|
-
const run = exactObject(body.run, `${operation}.run`, ["id", "session_count", "sessions"]);
|
|
58
|
-
const sessions = boundedArray(run.sessions, `${operation}.run.sessions`, maxSessions).map((value, index) => parseSession(value, `${operation}.run.sessions[${index}]`));
|
|
59
|
-
const sessionCount = nonnegativeInteger(run.session_count, `${operation}.run.sessionCount`);
|
|
60
|
-
if (sessionCount !== sessions.length) {
|
|
61
|
-
throw new Error(`Proxy API response field ${operation}.run.sessionCount must match sessions.`);
|
|
62
|
-
}
|
|
63
|
-
const version = requireInteger(body.version, `${operation}.version`);
|
|
64
|
-
if (version !== 1) {
|
|
65
|
-
throw new Error(`Proxy API response field ${operation}.version must be 1.`);
|
|
66
|
-
}
|
|
67
|
-
const merchantMode = requireString(config.merchant_mode, `${operation}.config.merchantMode`);
|
|
68
|
-
if (merchantMode !== "test") {
|
|
69
|
-
throw new Error(`Proxy API response field ${operation}.config.merchantMode must be test.`);
|
|
70
|
-
}
|
|
71
|
-
const deploymentEnvironment = environment(deployment.environment, `${operation}.deployment.environment`);
|
|
72
|
-
const artifactDigest = optionalMatchingString(deployment.artifact_digest, `${operation}.deployment.artifactDigest`, /^[0-9a-f]{64}$/);
|
|
73
|
-
if (artifactDigest === null &&
|
|
74
|
-
(deploymentEnvironment === "preview" || deploymentEnvironment === "production")) {
|
|
75
|
-
throw new Error(`Proxy API response field ${operation}.deployment.artifactDigest is required for deployed environments.`);
|
|
76
|
-
}
|
|
77
|
-
return {
|
|
78
|
-
baseline: {
|
|
79
|
-
activeLifecycleRecoveryWork: nonnegativeInteger(baseline.active_lifecycle_recovery_work, `${operation}.baseline.activeLifecycleRecoveryWork`),
|
|
80
|
-
earnedFeeRows: nonnegativeInteger(baseline.earned_fee_rows, `${operation}.baseline.earnedFeeRows`),
|
|
81
|
-
nonNoneFeeDiagnosticRows: nonnegativeInteger(baseline.non_none_fee_diagnostic_rows, `${operation}.baseline.nonNoneFeeDiagnosticRows`),
|
|
82
|
-
openAcquisitions: nonnegativeInteger(baseline.open_acquisitions, `${operation}.baseline.openAcquisitions`),
|
|
83
|
-
undeliveredOutboxEvents: nonnegativeInteger(baseline.undelivered_outbox_events, `${operation}.baseline.undeliveredOutboxEvents`),
|
|
84
|
-
unresolvedReconciliationIssues: nonnegativeInteger(baseline.unresolved_reconciliation_issues, `${operation}.baseline.unresolvedReconciliationIssues`),
|
|
85
|
-
},
|
|
86
|
-
config: {
|
|
87
|
-
accountRefHash: optionalHash(config.account_ref_hash, `${operation}.config.accountRefHash`),
|
|
88
|
-
id: proxyId(config.id, `${operation}.config.id`, "pspcfg_"),
|
|
89
|
-
ingress: config.ingress === null
|
|
90
|
-
? null
|
|
91
|
-
: parseIngress(config.ingress, `${operation}.config.ingress`),
|
|
92
|
-
lifecycleStatus: requireString(config.lifecycle_status, `${operation}.config.lifecycleStatus`),
|
|
93
|
-
merchantMode,
|
|
94
|
-
unattributedOpenAcquisitionSignal: requireBoolean(config.unattributed_open_acquisition_signal, `${operation}.config.unattributedOpenAcquisitionSignal`),
|
|
95
|
-
},
|
|
96
|
-
deployment: {
|
|
97
|
-
artifactDigest,
|
|
98
|
-
commitSha: matchingString(deployment.commit_sha, `${operation}.deployment.commitSha`, /^[0-9a-f]{40}$/),
|
|
99
|
-
environment: deploymentEnvironment,
|
|
100
|
-
previewId: requireNullableString(deployment.preview_id, `${operation}.deployment.previewId`),
|
|
101
|
-
},
|
|
102
|
-
run: {
|
|
103
|
-
id: matchingString(run.id, `${operation}.run.id`, runIdPattern),
|
|
104
|
-
sessionCount,
|
|
105
|
-
sessions,
|
|
106
|
-
},
|
|
107
|
-
version,
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
function parseSession(value, field) {
|
|
111
|
-
const body = exactObject(value, field, [
|
|
112
|
-
"acquisitions",
|
|
113
|
-
"completed_acquisition_attempt_id",
|
|
114
|
-
"completion_winner_count",
|
|
115
|
-
"domain_events",
|
|
116
|
-
"fees",
|
|
117
|
-
"final_cart",
|
|
118
|
-
"id",
|
|
119
|
-
"invoices",
|
|
120
|
-
"reconciliation_issues",
|
|
121
|
-
"recovery",
|
|
122
|
-
"shadow_comparisons",
|
|
123
|
-
"status",
|
|
124
|
-
"subscriptions",
|
|
125
|
-
]);
|
|
126
|
-
return {
|
|
127
|
-
acquisitions: boundedArray(body.acquisitions, `${field}.acquisitions`, maxRows).map((item, index) => parseAcquisition(item, `${field}.acquisitions[${index}]`)),
|
|
128
|
-
completedAcquisitionAttemptId: optionalProxyId(body.completed_acquisition_attempt_id, `${field}.completedAcquisitionAttemptId`, "pspacq_"),
|
|
129
|
-
completionWinnerCount: nonnegativeInteger(body.completion_winner_count, `${field}.completionWinnerCount`),
|
|
130
|
-
domainEvents: boundedArray(body.domain_events, `${field}.domainEvents`, maxRows).map((item, index) => parseDomainEvent(item, `${field}.domainEvents[${index}]`)),
|
|
131
|
-
fees: boundedArray(body.fees, `${field}.fees`, maxRows).map((item, index) => parseFee(item, `${field}.fees[${index}]`)),
|
|
132
|
-
finalCart: body.final_cart === null ? null : parseFinalCart(body.final_cart, `${field}.finalCart`),
|
|
133
|
-
id: proxyId(body.id, `${field}.id`, "psess_"),
|
|
134
|
-
invoices: boundedArray(body.invoices, `${field}.invoices`, maxRows).map((item, index) => parseInvoice(item, `${field}.invoices[${index}]`)),
|
|
135
|
-
reconciliationIssues: boundedArray(body.reconciliation_issues, `${field}.reconciliationIssues`, maxRows).map((item, index) => parseReconciliationIssue(item, `${field}.reconciliationIssues[${index}]`)),
|
|
136
|
-
recovery: boundedArray(body.recovery, `${field}.recovery`, maxRows).map((item, index) => parseRecovery(item, `${field}.recovery[${index}]`)),
|
|
137
|
-
shadowComparisons: boundedArray(body.shadow_comparisons, `${field}.shadowComparisons`, maxRows).map((item, index) => parseShadowComparison(item, `${field}.shadowComparisons[${index}]`)),
|
|
138
|
-
status: requireString(body.status, `${field}.status`),
|
|
139
|
-
subscriptions: boundedArray(body.subscriptions, `${field}.subscriptions`, maxRows).map((item, index) => parseSubscription(item, `${field}.subscriptions[${index}]`)),
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
function parseAcquisition(value, field) {
|
|
143
|
-
const body = exactObject(value, field, [
|
|
144
|
-
"attempt_number",
|
|
145
|
-
"commercial_mode",
|
|
146
|
-
"completion_recorded",
|
|
147
|
-
"customer_present",
|
|
148
|
-
"direct_subscription_source",
|
|
149
|
-
"id",
|
|
150
|
-
"integration_path",
|
|
151
|
-
"pricing_mode",
|
|
152
|
-
"provider_cart_confirmed",
|
|
153
|
-
"root_object_present",
|
|
154
|
-
"setup_intent_present",
|
|
155
|
-
"setup_intent_evidence_source_type",
|
|
156
|
-
"status",
|
|
157
|
-
"status_reason",
|
|
158
|
-
]);
|
|
159
|
-
return {
|
|
160
|
-
attemptNumber: positiveInteger(body.attempt_number, `${field}.attemptNumber`),
|
|
161
|
-
commercialMode: requireString(body.commercial_mode, `${field}.commercialMode`),
|
|
162
|
-
completionRecorded: requireBoolean(body.completion_recorded, `${field}.completionRecorded`),
|
|
163
|
-
customerPresent: requireBoolean(body.customer_present, `${field}.customerPresent`),
|
|
164
|
-
directSubscriptionSource: requireNullableString(body.direct_subscription_source, `${field}.directSubscriptionSource`),
|
|
165
|
-
id: proxyId(body.id, `${field}.id`, "pspacq_"),
|
|
166
|
-
integrationPath: requireString(body.integration_path, `${field}.integrationPath`),
|
|
167
|
-
pricingMode: requireString(body.pricing_mode, `${field}.pricingMode`),
|
|
168
|
-
providerCartConfirmed: requireBoolean(body.provider_cart_confirmed, `${field}.providerCartConfirmed`),
|
|
169
|
-
rootObjectPresent: requireBoolean(body.root_object_present, `${field}.rootObjectPresent`),
|
|
170
|
-
setupIntentEvidenceSourceType: evidenceSourceType(body.setup_intent_evidence_source_type, `${field}.setupIntentEvidenceSourceType`),
|
|
171
|
-
setupIntentPresent: requireBoolean(body.setup_intent_present, `${field}.setupIntentPresent`),
|
|
172
|
-
status: requireString(body.status, `${field}.status`),
|
|
173
|
-
statusReason: requireNullableString(body.status_reason, `${field}.statusReason`),
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
function parseSubscription(value, field) {
|
|
177
|
-
const body = exactObject(value, field, [
|
|
178
|
-
"configuration_reason",
|
|
179
|
-
"configuration_status",
|
|
180
|
-
"id",
|
|
181
|
-
"latest_payment_status",
|
|
182
|
-
"latest_payment_evidence_source_type",
|
|
183
|
-
"latest_proxy_invoice_id",
|
|
184
|
-
"lifecycle_evidence_source_type",
|
|
185
|
-
"status",
|
|
186
|
-
]);
|
|
187
|
-
return {
|
|
188
|
-
configurationReason: requireNullableString(body.configuration_reason, `${field}.configurationReason`),
|
|
189
|
-
configurationStatus: requireString(body.configuration_status, `${field}.configurationStatus`),
|
|
190
|
-
id: proxyId(body.id, `${field}.id`, "psub_"),
|
|
191
|
-
latestPaymentEvidenceSourceType: evidenceSourceType(body.latest_payment_evidence_source_type, `${field}.latestPaymentEvidenceSourceType`),
|
|
192
|
-
latestPaymentStatus: requireNullableString(body.latest_payment_status, `${field}.latestPaymentStatus`),
|
|
193
|
-
latestProxyInvoiceId: optionalProxyId(body.latest_proxy_invoice_id, `${field}.latestProxyInvoiceId`, "pspsi_"),
|
|
194
|
-
lifecycleEvidenceSourceType: evidenceSourceType(body.lifecycle_evidence_source_type, `${field}.lifecycleEvidenceSourceType`),
|
|
195
|
-
status: requireString(body.status, `${field}.status`),
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
function parseInvoice(value, field) {
|
|
199
|
-
const body = exactObject(value, field, [
|
|
200
|
-
"amount_due_minor",
|
|
201
|
-
"amount_paid_minor",
|
|
202
|
-
"amount_remaining_minor",
|
|
203
|
-
"currency",
|
|
204
|
-
"dispute_observation_count",
|
|
205
|
-
"earned_fee_count",
|
|
206
|
-
"id",
|
|
207
|
-
"linked_payment_intent_fee_count",
|
|
208
|
-
"payment_attempt_count",
|
|
209
|
-
"provider_payment_intent_present",
|
|
210
|
-
"status_evidence_source_type",
|
|
211
|
-
"proxy_subscription_id",
|
|
212
|
-
"refund_observation_count",
|
|
213
|
-
"status",
|
|
214
|
-
]);
|
|
215
|
-
return {
|
|
216
|
-
amountDueMinor: nonnegativeInteger(body.amount_due_minor, `${field}.amountDueMinor`),
|
|
217
|
-
amountPaidMinor: nonnegativeInteger(body.amount_paid_minor, `${field}.amountPaidMinor`),
|
|
218
|
-
amountRemainingMinor: nonnegativeInteger(body.amount_remaining_minor, `${field}.amountRemainingMinor`),
|
|
219
|
-
currency: optionalCurrency(body.currency, `${field}.currency`),
|
|
220
|
-
disputeObservationCount: nonnegativeInteger(body.dispute_observation_count, `${field}.disputeObservationCount`),
|
|
221
|
-
earnedFeeCount: nonnegativeInteger(body.earned_fee_count, `${field}.earnedFeeCount`),
|
|
222
|
-
id: proxyId(body.id, `${field}.id`, "pspsi_"),
|
|
223
|
-
linkedPaymentIntentFeeCount: nonnegativeInteger(body.linked_payment_intent_fee_count, `${field}.linkedPaymentIntentFeeCount`),
|
|
224
|
-
paymentAttemptCount: nonnegativeInteger(body.payment_attempt_count, `${field}.paymentAttemptCount`),
|
|
225
|
-
providerPaymentIntentPresent: requireBoolean(body.provider_payment_intent_present, `${field}.providerPaymentIntentPresent`),
|
|
226
|
-
proxySubscriptionId: proxyId(body.proxy_subscription_id, `${field}.proxySubscriptionId`, "psub_"),
|
|
227
|
-
refundObservationCount: nonnegativeInteger(body.refund_observation_count, `${field}.refundObservationCount`),
|
|
228
|
-
status: requireString(body.status, `${field}.status`),
|
|
229
|
-
statusEvidenceSourceType: evidenceSourceType(body.status_evidence_source_type, `${field}.statusEvidenceSourceType`),
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
|
-
function parseFee(value, field) {
|
|
233
|
-
const body = exactObject(value, field, [
|
|
234
|
-
"basis_diagnostic",
|
|
235
|
-
"billing_currency",
|
|
236
|
-
"earning_object_type",
|
|
237
|
-
"expected_fee_amount_decimal",
|
|
238
|
-
"fixed_fee_minor",
|
|
239
|
-
"id",
|
|
240
|
-
"payment_attempt_id",
|
|
241
|
-
"percentage_basis_amount_minor",
|
|
242
|
-
"percentage_basis_source",
|
|
243
|
-
"percentage_bps",
|
|
244
|
-
"policy_version",
|
|
245
|
-
"provider_acquisition_attempt_id",
|
|
246
|
-
"proxy_subscription_invoice_id",
|
|
247
|
-
]);
|
|
248
|
-
const earningObjectType = requireString(body.earning_object_type, `${field}.earningObjectType`);
|
|
249
|
-
if (earningObjectType !== "invoice" && earningObjectType !== "payment_intent") {
|
|
250
|
-
throw new Error(`Proxy API response field ${field}.earningObjectType is unsupported.`);
|
|
251
|
-
}
|
|
252
|
-
return {
|
|
253
|
-
basisDiagnostic: requireString(body.basis_diagnostic, `${field}.basisDiagnostic`),
|
|
254
|
-
billingCurrency: currency(body.billing_currency, `${field}.billingCurrency`),
|
|
255
|
-
earningObjectType,
|
|
256
|
-
expectedFeeAmountDecimal: matchingString(body.expected_fee_amount_decimal, `${field}.expectedFeeAmountDecimal`, /^(0|[1-9][0-9]*)([.][0-9]+)?$/),
|
|
257
|
-
fixedFeeMinor: nonnegativeInteger(body.fixed_fee_minor, `${field}.fixedFeeMinor`),
|
|
258
|
-
id: proxyId(body.id, `${field}.id`, "strfee_"),
|
|
259
|
-
paymentAttemptId: proxyId(body.payment_attempt_id, `${field}.paymentAttemptId`, "payatt_"),
|
|
260
|
-
percentageBasisAmountMinor: nonnegativeInteger(body.percentage_basis_amount_minor, `${field}.percentageBasisAmountMinor`),
|
|
261
|
-
percentageBasisSource: requireString(body.percentage_basis_source, `${field}.percentageBasisSource`),
|
|
262
|
-
percentageBps: nonnegativeInteger(body.percentage_bps, `${field}.percentageBps`),
|
|
263
|
-
policyVersion: requireString(body.policy_version, `${field}.policyVersion`),
|
|
264
|
-
providerAcquisitionAttemptId: optionalProxyId(body.provider_acquisition_attempt_id, `${field}.providerAcquisitionAttemptId`, "pspacq_"),
|
|
265
|
-
proxySubscriptionInvoiceId: optionalProxyId(body.proxy_subscription_invoice_id, `${field}.proxySubscriptionInvoiceId`, "pspsi_"),
|
|
266
|
-
};
|
|
267
|
-
}
|
|
268
|
-
function parseDomainEvent(value, field) {
|
|
269
|
-
const body = exactObject(value, field, [
|
|
270
|
-
"id",
|
|
271
|
-
"outbox",
|
|
272
|
-
"payment_attempt_id",
|
|
273
|
-
"provider_acquisition_attempt_id",
|
|
274
|
-
"proxy_session_id",
|
|
275
|
-
"proxy_subscription_id",
|
|
276
|
-
"proxy_subscription_invoice_id",
|
|
277
|
-
"type",
|
|
278
|
-
"visibility",
|
|
279
|
-
]);
|
|
280
|
-
return {
|
|
281
|
-
id: proxyId(body.id, `${field}.id`, "evt_"),
|
|
282
|
-
outbox: boundedArray(body.outbox, `${field}.outbox`, maxRows).map((item, index) => parseOutbox(item, `${field}.outbox[${index}]`)),
|
|
283
|
-
paymentAttemptId: optionalProxyId(body.payment_attempt_id, `${field}.paymentAttemptId`, "payatt_"),
|
|
284
|
-
providerAcquisitionAttemptId: optionalProxyId(body.provider_acquisition_attempt_id, `${field}.providerAcquisitionAttemptId`, "pspacq_"),
|
|
285
|
-
proxySessionId: optionalProxyId(body.proxy_session_id, `${field}.proxySessionId`, "psess_"),
|
|
286
|
-
proxySubscriptionId: optionalProxyId(body.proxy_subscription_id, `${field}.proxySubscriptionId`, "psub_"),
|
|
287
|
-
proxySubscriptionInvoiceId: optionalProxyId(body.proxy_subscription_invoice_id, `${field}.proxySubscriptionInvoiceId`, "pspsi_"),
|
|
288
|
-
type: requireString(body.type, `${field}.type`),
|
|
289
|
-
visibility: requireString(body.visibility, `${field}.visibility`),
|
|
290
|
-
};
|
|
291
|
-
}
|
|
292
|
-
function parseOutbox(value, field) {
|
|
293
|
-
const body = exactObject(value, field, [
|
|
294
|
-
"attempt_count",
|
|
295
|
-
"delivery",
|
|
296
|
-
"id",
|
|
297
|
-
"kind",
|
|
298
|
-
"max_attempts",
|
|
299
|
-
"status",
|
|
300
|
-
]);
|
|
301
|
-
return {
|
|
302
|
-
attemptCount: nonnegativeInteger(body.attempt_count, `${field}.attemptCount`),
|
|
303
|
-
delivery: body.delivery === null ? null : parseDelivery(body.delivery, `${field}.delivery`),
|
|
304
|
-
id: proxyId(body.id, `${field}.id`, "out_"),
|
|
305
|
-
kind: requireString(body.kind, `${field}.kind`),
|
|
306
|
-
maxAttempts: positiveInteger(body.max_attempts, `${field}.maxAttempts`),
|
|
307
|
-
status: requireString(body.status, `${field}.status`),
|
|
308
|
-
};
|
|
309
|
-
}
|
|
310
|
-
function parseDelivery(value, field) {
|
|
311
|
-
const body = exactObject(value, field, ["attempt_count", "id", "status", "transport"]);
|
|
312
|
-
const transport = requireString(body.transport, `${field}.transport`);
|
|
313
|
-
if (transport !== "https" && transport !== "local_relay") {
|
|
314
|
-
throw new Error(`Proxy API response field ${field}.transport is unsupported.`);
|
|
315
|
-
}
|
|
316
|
-
return {
|
|
317
|
-
attemptCount: nonnegativeInteger(body.attempt_count, `${field}.attemptCount`),
|
|
318
|
-
id: proxyId(body.id, `${field}.id`, "whdel_"),
|
|
319
|
-
status: requireString(body.status, `${field}.status`),
|
|
320
|
-
transport,
|
|
321
|
-
};
|
|
322
|
-
}
|
|
323
|
-
function parseReconciliationIssue(value, field) {
|
|
324
|
-
const body = exactObject(value, field, [
|
|
325
|
-
"id",
|
|
326
|
-
"issue_type",
|
|
327
|
-
"payment_attempt_id",
|
|
328
|
-
"provider_acquisition_attempt_id",
|
|
329
|
-
"proxy_session_id",
|
|
330
|
-
"proxy_subscription_id",
|
|
331
|
-
"proxy_subscription_invoice_id",
|
|
332
|
-
"status",
|
|
333
|
-
]);
|
|
334
|
-
return {
|
|
335
|
-
id: proxyId(body.id, `${field}.id`, "reciss_"),
|
|
336
|
-
issueType: requireString(body.issue_type, `${field}.issueType`),
|
|
337
|
-
paymentAttemptId: optionalProxyId(body.payment_attempt_id, `${field}.paymentAttemptId`, "payatt_"),
|
|
338
|
-
providerAcquisitionAttemptId: optionalProxyId(body.provider_acquisition_attempt_id, `${field}.providerAcquisitionAttemptId`, "pspacq_"),
|
|
339
|
-
proxySessionId: optionalProxyId(body.proxy_session_id, `${field}.proxySessionId`, "psess_"),
|
|
340
|
-
proxySubscriptionId: optionalProxyId(body.proxy_subscription_id, `${field}.proxySubscriptionId`, "psub_"),
|
|
341
|
-
proxySubscriptionInvoiceId: optionalProxyId(body.proxy_subscription_invoice_id, `${field}.proxySubscriptionInvoiceId`, "pspsi_"),
|
|
342
|
-
status: requireString(body.status, `${field}.status`),
|
|
343
|
-
};
|
|
344
|
-
}
|
|
345
|
-
function parseRecovery(value, field) {
|
|
346
|
-
const body = exactObject(value, field, [
|
|
347
|
-
"attempt_count",
|
|
348
|
-
"capability_ids",
|
|
349
|
-
"evidence_hash",
|
|
350
|
-
"evidence_present",
|
|
351
|
-
"id",
|
|
352
|
-
"max_attempts",
|
|
353
|
-
"provider_acquisition_attempt_id",
|
|
354
|
-
"proxy_session_id",
|
|
355
|
-
"proxy_subscription_id",
|
|
356
|
-
"proxy_subscription_invoice_id",
|
|
357
|
-
"result_disposition",
|
|
358
|
-
"result_reason",
|
|
359
|
-
"status",
|
|
360
|
-
"target_type",
|
|
361
|
-
]);
|
|
362
|
-
return {
|
|
363
|
-
attemptCount: nonnegativeInteger(body.attempt_count, `${field}.attemptCount`),
|
|
364
|
-
capabilityIds: boundedArray(body.capability_ids, `${field}.capabilityIds`, 20).map((item, index) => requireString(item, `${field}.capabilityIds[${index}]`)),
|
|
365
|
-
evidenceHash: optionalMatchingString(body.evidence_hash, `${field}.evidenceHash`, /^sha256:[0-9a-f]{64}$/),
|
|
366
|
-
evidencePresent: requireBoolean(body.evidence_present, `${field}.evidencePresent`),
|
|
367
|
-
id: proxyId(body.id, `${field}.id`, "recwork_"),
|
|
368
|
-
maxAttempts: positiveInteger(body.max_attempts, `${field}.maxAttempts`),
|
|
369
|
-
providerAcquisitionAttemptId: proxyId(body.provider_acquisition_attempt_id, `${field}.providerAcquisitionAttemptId`, "pspacq_"),
|
|
370
|
-
proxySessionId: proxyId(body.proxy_session_id, `${field}.proxySessionId`, "psess_"),
|
|
371
|
-
proxySubscriptionId: optionalProxyId(body.proxy_subscription_id, `${field}.proxySubscriptionId`, "psub_"),
|
|
372
|
-
proxySubscriptionInvoiceId: optionalProxyId(body.proxy_subscription_invoice_id, `${field}.proxySubscriptionInvoiceId`, "pspsi_"),
|
|
373
|
-
resultDisposition: recoveryResultDisposition(body.result_disposition, `${field}.resultDisposition`),
|
|
374
|
-
resultReason: recoveryResultReason(body.result_reason, `${field}.resultReason`),
|
|
375
|
-
status: requireString(body.status, `${field}.status`),
|
|
376
|
-
targetType: requireString(body.target_type, `${field}.targetType`),
|
|
377
|
-
};
|
|
378
|
-
}
|
|
379
|
-
function parseShadowComparison(value, field) {
|
|
380
|
-
const body = exactObject(value, field, [
|
|
381
|
-
"comparison_hash",
|
|
382
|
-
"disposition",
|
|
383
|
-
"observation_count",
|
|
384
|
-
"reason_code",
|
|
385
|
-
]);
|
|
386
|
-
return {
|
|
387
|
-
comparisonHash: matchingString(body.comparison_hash, `${field}.comparisonHash`, /^sha256:[0-9a-f]{64}$/),
|
|
388
|
-
disposition: shadowComparisonDisposition(body.disposition, `${field}.disposition`),
|
|
389
|
-
observationCount: positiveInteger(body.observation_count, `${field}.observationCount`),
|
|
390
|
-
reasonCode: shadowComparisonReasonCode(body.reason_code, `${field}.reasonCode`),
|
|
391
|
-
};
|
|
392
|
-
}
|
|
393
|
-
function parseFinalCart(value, field) {
|
|
394
|
-
const body = exactObject(value, field, [
|
|
395
|
-
"amount_minor",
|
|
396
|
-
"cart_version",
|
|
397
|
-
"currency",
|
|
398
|
-
"finalized_at",
|
|
399
|
-
"line_count",
|
|
400
|
-
"pricing_mode",
|
|
401
|
-
"snapshot_hash",
|
|
402
|
-
]);
|
|
403
|
-
return {
|
|
404
|
-
amountMinor: nonnegativeInteger(body.amount_minor, `${field}.amountMinor`),
|
|
405
|
-
cartVersion: nonnegativeInteger(body.cart_version, `${field}.cartVersion`),
|
|
406
|
-
currency: currency(body.currency, `${field}.currency`),
|
|
407
|
-
finalizedAt: requireString(body.finalized_at, `${field}.finalizedAt`),
|
|
408
|
-
lineCount: nonnegativeInteger(body.line_count, `${field}.lineCount`),
|
|
409
|
-
pricingMode: requireString(body.pricing_mode, `${field}.pricingMode`),
|
|
410
|
-
snapshotHash: matchingString(body.snapshot_hash, `${field}.snapshotHash`, /^sha256:[0-9a-f]{64}$/),
|
|
411
|
-
};
|
|
412
|
-
}
|
|
413
|
-
function parseIngress(value, field) {
|
|
414
|
-
const body = exactObject(value, field, ["api_version", "verification_status"]);
|
|
415
|
-
return {
|
|
416
|
-
apiVersion: requireNullableString(body.api_version, `${field}.apiVersion`),
|
|
417
|
-
verificationStatus: requireString(body.verification_status, `${field}.verificationStatus`),
|
|
418
|
-
};
|
|
419
|
-
}
|
|
420
|
-
function exactObject(value, field, keys) {
|
|
421
|
-
const body = requireJsonObject(value, field);
|
|
422
|
-
const actual = Object.keys(body).sort();
|
|
423
|
-
const expected = [...keys].sort();
|
|
424
|
-
if (actual.length !== expected.length || actual.some((key, index) => key !== expected[index])) {
|
|
425
|
-
throw new Error(`Proxy API response field ${field} must contain only its documented keys.`);
|
|
426
|
-
}
|
|
427
|
-
return body;
|
|
428
|
-
}
|
|
429
|
-
function boundedArray(value, field, max) {
|
|
430
|
-
if (!Array.isArray(value) || value.length > max) {
|
|
431
|
-
throw new Error(`Proxy API response field ${field} must be an array of at most ${max} items.`);
|
|
432
|
-
}
|
|
433
|
-
return value;
|
|
434
|
-
}
|
|
435
|
-
function nonnegativeInteger(value, field) {
|
|
436
|
-
const parsed = requireInteger(value, field);
|
|
437
|
-
if (!Number.isSafeInteger(parsed) || parsed < 0) {
|
|
438
|
-
throw new Error(`Proxy API response field ${field} must be a nonnegative safe integer.`);
|
|
439
|
-
}
|
|
440
|
-
return parsed;
|
|
441
|
-
}
|
|
442
|
-
function positiveInteger(value, field) {
|
|
443
|
-
const parsed = nonnegativeInteger(value, field);
|
|
444
|
-
if (parsed < 1)
|
|
445
|
-
throw new Error(`Proxy API response field ${field} must be positive.`);
|
|
446
|
-
return parsed;
|
|
447
|
-
}
|
|
448
|
-
function matchingString(value, field, pattern) {
|
|
449
|
-
const parsed = requireString(value, field);
|
|
450
|
-
if (!pattern.test(parsed)) {
|
|
451
|
-
throw new Error(`Proxy API response field ${field} has an invalid format.`);
|
|
452
|
-
}
|
|
453
|
-
return parsed;
|
|
454
|
-
}
|
|
455
|
-
function optionalMatchingString(value, field, pattern) {
|
|
456
|
-
return value === null ? null : matchingString(value, field, pattern);
|
|
457
|
-
}
|
|
458
|
-
function proxyId(value, field, prefix) {
|
|
459
|
-
return matchingString(value, field, new RegExp(`^${prefix}[A-Za-z0-9._:-]+$`));
|
|
460
|
-
}
|
|
461
|
-
function optionalProxyId(value, field, prefix) {
|
|
462
|
-
return value === null ? null : proxyId(value, field, prefix);
|
|
463
|
-
}
|
|
464
|
-
function optionalHash(value, field) {
|
|
465
|
-
return value === null ? null : matchingString(value, field, /^sha256:[0-9a-f]{64}$/);
|
|
466
|
-
}
|
|
467
|
-
function evidenceSourceType(value, field) {
|
|
468
|
-
if (value === null)
|
|
469
|
-
return null;
|
|
470
|
-
const parsed = requireString(value, field);
|
|
471
|
-
if (parsed !== "psp_api_response" && parsed !== "webhook_event") {
|
|
472
|
-
throw new Error(`Proxy API response field ${field} is unsupported.`);
|
|
473
|
-
}
|
|
474
|
-
return parsed;
|
|
475
|
-
}
|
|
476
|
-
function recoveryResultDisposition(value, field) {
|
|
477
|
-
if (value === null)
|
|
478
|
-
return null;
|
|
479
|
-
const parsed = requireString(value, field);
|
|
480
|
-
if (parsed !== "action_required" &&
|
|
481
|
-
parsed !== "no_change" &&
|
|
482
|
-
parsed !== "resolved" &&
|
|
483
|
-
parsed !== "retry") {
|
|
484
|
-
throw new Error(`Proxy API response field ${field} is unsupported.`);
|
|
485
|
-
}
|
|
486
|
-
return parsed;
|
|
487
|
-
}
|
|
488
|
-
function recoveryResultReason(value, field) {
|
|
489
|
-
if (value === null)
|
|
490
|
-
return null;
|
|
491
|
-
const parsed = requireString(value, field);
|
|
492
|
-
const allowed = [
|
|
493
|
-
"completion_contender",
|
|
494
|
-
"incomplete_invoice_line_evidence",
|
|
495
|
-
"incomplete_invoice_structure",
|
|
496
|
-
"incomplete_subscription_configuration",
|
|
497
|
-
"invalid_or_unsupported_provider_evidence",
|
|
498
|
-
"known_object_not_found",
|
|
499
|
-
"stripe_credentials_unavailable",
|
|
500
|
-
"subscription_invoice_payment_evidence_conflict",
|
|
501
|
-
"unsupported_invoice_payment_evidence",
|
|
502
|
-
"unsupported_subscription_configuration",
|
|
503
|
-
"unclassified",
|
|
504
|
-
];
|
|
505
|
-
if (!allowed.includes(parsed)) {
|
|
506
|
-
throw new Error(`Proxy API response field ${field} is unsupported.`);
|
|
507
|
-
}
|
|
508
|
-
return parsed;
|
|
509
|
-
}
|
|
510
|
-
function shadowComparisonDisposition(value, field) {
|
|
511
|
-
const parsed = requireString(value, field);
|
|
512
|
-
const allowed = [
|
|
513
|
-
"expected_divergence",
|
|
514
|
-
"legacy_not_applicable",
|
|
515
|
-
"match",
|
|
516
|
-
"unexpected_divergence",
|
|
517
|
-
];
|
|
518
|
-
if (!allowed.includes(parsed)) {
|
|
519
|
-
throw new Error(`Proxy API response field ${field} is unsupported.`);
|
|
520
|
-
}
|
|
521
|
-
return parsed;
|
|
522
|
-
}
|
|
523
|
-
function shadowComparisonReasonCode(value, field) {
|
|
524
|
-
const parsed = requireString(value, field);
|
|
525
|
-
const allowed = [
|
|
526
|
-
"legacy_not_applicable",
|
|
527
|
-
"match",
|
|
528
|
-
"shared_configuration_visibility_added",
|
|
529
|
-
"shared_invoice_fee_and_lifecycle_added",
|
|
530
|
-
"shared_invoice_fee_added",
|
|
531
|
-
"shared_invoice_lifecycle_added",
|
|
532
|
-
"shared_invoice_line_evidence_required",
|
|
533
|
-
"shared_reconciliation_visibility_added",
|
|
534
|
-
"unexpected_divergence",
|
|
535
|
-
];
|
|
536
|
-
if (!allowed.includes(parsed)) {
|
|
537
|
-
throw new Error(`Proxy API response field ${field} is unsupported.`);
|
|
538
|
-
}
|
|
539
|
-
return parsed;
|
|
540
|
-
}
|
|
541
|
-
function currency(value, field) {
|
|
542
|
-
return matchingString(value, field, /^[a-z]{3}$/);
|
|
543
|
-
}
|
|
544
|
-
function optionalCurrency(value, field) {
|
|
545
|
-
return value === null ? null : currency(value, field);
|
|
546
|
-
}
|
|
547
|
-
function environment(value, field) {
|
|
548
|
-
const parsed = requireString(value, field);
|
|
549
|
-
if (parsed !== "local" && parsed !== "preview" && parsed !== "production" && parsed !== "test") {
|
|
550
|
-
throw new Error(`Proxy API response field ${field} is unsupported.`);
|
|
551
|
-
}
|
|
552
|
-
return parsed;
|
|
553
|
-
}
|