@openlup/platform 0.28.0 → 0.29.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/CHANGELOG.md +219 -18
- package/README.md +143 -4
- package/dist/composition/index.d.ts +1 -0
- package/dist/composition/index.js +1 -0
- package/dist/composition/marketingContribution.d.ts +21 -0
- package/dist/composition/marketingContribution.js +29 -0
- package/dist/marketing/acquisitionCaseSchemas.d.ts +103 -0
- package/dist/marketing/acquisitionCaseSchemas.js +53 -0
- package/dist/marketing/acquisitionEvidenceSchemas.d.ts +105 -0
- package/dist/marketing/acquisitionEvidenceSchemas.js +55 -0
- package/dist/marketing/analytics/dataLayer.d.ts +18 -0
- package/dist/marketing/analytics/dataLayer.js +111 -0
- package/dist/marketing/analytics/noop.d.ts +9 -0
- package/dist/marketing/analytics/noop.js +8 -0
- package/dist/marketing/analytics/purchaseFacts.d.ts +4 -0
- package/dist/marketing/analytics/purchaseFacts.js +69 -0
- package/dist/marketing/analytics/routePolicy.d.ts +10 -0
- package/dist/marketing/analytics/routePolicy.js +59 -0
- package/dist/marketing/consentEvidence.d.ts +8 -0
- package/dist/marketing/consentEvidence.js +32 -0
- package/dist/marketing/contactLegal.d.ts +14 -0
- package/dist/marketing/contactLegal.js +19 -0
- package/dist/marketing/contracts/acquisition.d.ts +88 -0
- package/dist/marketing/contracts/acquisition.js +1 -0
- package/dist/marketing/contracts/acquisitionPorts.d.ts +49 -0
- package/dist/marketing/contracts/acquisitionPorts.js +1 -0
- package/dist/marketing/contracts/analytics.d.ts +144 -0
- package/dist/marketing/contracts/analytics.js +1 -0
- package/dist/marketing/contracts/contactLegal.d.ts +53 -0
- package/dist/marketing/contracts/contactLegal.js +1 -0
- package/dist/marketing/contracts/index.d.ts +6 -0
- package/dist/marketing/contracts/index.js +1 -0
- package/dist/marketing/contracts/prelaunch.d.ts +39 -0
- package/dist/marketing/contracts/prelaunch.js +1 -0
- package/dist/marketing/index.d.ts +16 -0
- package/dist/marketing/index.js +14 -0
- package/dist/marketing/prelaunchAcquisitionSchemas.d.ts +116 -0
- package/dist/marketing/prelaunchAcquisitionSchemas.js +51 -0
- package/dist/marketing/seo/jsonLd.d.ts +157 -0
- package/dist/marketing/seo/jsonLd.js +127 -0
- package/dist/marketing/seo/metadata.d.ts +41 -0
- package/dist/marketing/seo/metadata.js +36 -0
- package/dist/marketing/seo/serializeJsonLd.d.ts +1 -0
- package/dist/marketing/seo/serializeJsonLd.js +6 -0
- package/dist/marketing/seo/urls.d.ts +14 -0
- package/dist/marketing/seo/urls.js +23 -0
- package/dist/marketing/server/acquisitionCaseDirect.d.ts +4 -0
- package/dist/marketing/server/acquisitionCaseDirect.js +88 -0
- package/dist/marketing/server/acquisitionCaseHandlers.d.ts +28 -0
- package/dist/marketing/server/acquisitionCaseHandlers.js +40 -0
- package/dist/marketing/server/acquisitionCasePorts.d.ts +42 -0
- package/dist/marketing/server/acquisitionCasePorts.js +1 -0
- package/dist/marketing/server/acquisitionEvidenceDirect.d.ts +5 -0
- package/dist/marketing/server/acquisitionEvidenceDirect.js +100 -0
- package/dist/marketing/server/analyticsContext.d.ts +3 -0
- package/dist/marketing/server/analyticsContext.js +65 -0
- package/dist/marketing/server/analyticsContextPorts.d.ts +31 -0
- package/dist/marketing/server/analyticsContextPorts.js +1 -0
- package/dist/marketing/server/bindings.d.ts +14 -0
- package/dist/marketing/server/bindings.js +18 -0
- package/dist/marketing/server/directPorts.d.ts +26 -0
- package/dist/marketing/server/directPorts.js +1 -0
- package/dist/marketing/server/index.d.ts +14 -0
- package/dist/marketing/server/index.js +11 -0
- package/dist/marketing/server/postgres/acquisitionCaseRoutines.d.ts +10 -0
- package/dist/marketing/server/postgres/acquisitionCaseRoutines.js +204 -0
- package/dist/marketing/server/postgres/acquisitionEvidenceRoutines.d.ts +10 -0
- package/dist/marketing/server/postgres/acquisitionEvidenceRoutines.js +107 -0
- package/dist/marketing/server/postgres/index.d.ts +3 -0
- package/dist/marketing/server/postgres/index.js +3 -0
- package/dist/marketing/server/prelaunchAcquisitionDirect.d.ts +4 -0
- package/dist/marketing/server/prelaunchAcquisitionDirect.js +122 -0
- package/dist/marketing/server/privacyContributor.d.ts +66 -0
- package/dist/marketing/server/privacyContributor.js +87 -0
- package/dist/marketing/server/research/adminSurveyResponsesHandler.d.ts +9 -0
- package/dist/marketing/server/research/adminSurveyResponsesHandler.js +53 -0
- package/dist/marketing/server/research/managedSurveyResponseSubmit.d.ts +39 -0
- package/dist/marketing/server/research/managedSurveyResponseSubmit.js +102 -0
- package/dist/marketing/server/research/surveyResponseSubmitHandler.d.ts +8 -0
- package/dist/marketing/server/research/surveyResponseSubmitHandler.js +41 -0
- package/dist/marketing/validation.d.ts +2 -0
- package/dist/marketing/validation.js +3 -0
- package/package.json +22 -2
- package/release-gates.json +72 -4
- package/src/composition/index.ts +1 -0
- package/src/composition/marketingContribution.ts +37 -0
- package/src/marketing/acquisitionCaseSchemas.ts +75 -0
- package/src/marketing/acquisitionEvidenceSchemas.ts +72 -0
- package/src/marketing/analytics/dataLayer.ts +100 -0
- package/src/marketing/analytics/noop.ts +14 -0
- package/src/marketing/analytics/purchaseFacts.ts +63 -0
- package/src/marketing/analytics/routePolicy.ts +55 -0
- package/src/marketing/consentEvidence.ts +36 -0
- package/src/marketing/contactLegal.ts +22 -0
- package/src/marketing/contracts/acquisition.ts +50 -0
- package/src/marketing/contracts/acquisitionPorts.ts +48 -0
- package/src/marketing/contracts/analytics.ts +88 -0
- package/src/marketing/contracts/contactLegal.ts +41 -0
- package/src/marketing/contracts/index.ts +17 -0
- package/src/marketing/contracts/prelaunch.ts +15 -0
- package/src/marketing/index.ts +16 -0
- package/src/marketing/prelaunchAcquisitionSchemas.ts +64 -0
- package/src/marketing/seo/jsonLd.ts +153 -0
- package/src/marketing/seo/metadata.ts +62 -0
- package/src/marketing/seo/serializeJsonLd.ts +6 -0
- package/src/marketing/seo/urls.ts +34 -0
- package/src/marketing/server/acquisitionCaseDirect.ts +67 -0
- package/src/marketing/server/acquisitionCaseHandlers.ts +57 -0
- package/src/marketing/server/acquisitionCasePorts.ts +42 -0
- package/src/marketing/server/acquisitionEvidenceDirect.ts +76 -0
- package/src/marketing/server/analyticsContext.ts +55 -0
- package/src/marketing/server/analyticsContextPorts.ts +28 -0
- package/src/marketing/server/bindings.ts +27 -0
- package/src/marketing/server/directPorts.ts +27 -0
- package/src/marketing/server/index.ts +14 -0
- package/src/marketing/server/postgres/acquisitionCaseRoutines.ts +218 -0
- package/src/marketing/server/postgres/acquisitionEvidenceRoutines.ts +103 -0
- package/src/marketing/server/postgres/index.ts +3 -0
- package/src/marketing/server/prelaunchAcquisitionDirect.ts +121 -0
- package/src/marketing/server/privacyContributor.ts +123 -0
- package/src/marketing/server/research/adminSurveyResponsesHandler.ts +78 -0
- package/src/marketing/server/research/managedSurveyResponseSubmit.ts +158 -0
- package/src/marketing/server/research/surveyResponseSubmitHandler.ts +57 -0
- package/src/marketing/validation.ts +3 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AcquisitionCaseListResponse, AcquisitionCaseProjection, AcquisitionNewsletterConsentEvent,
|
|
3
|
+
AcquisitionNewsletterConsentResponse, AcquisitionSurveyListQuery, AcquisitionSurveyListResponse,
|
|
4
|
+
AcquisitionSurveySubmit, AcquisitionSurveySubmitResponse,
|
|
5
|
+
} from "./acquisition.js";
|
|
6
|
+
|
|
7
|
+
export type AcquisitionCaseFailureKind =
|
|
8
|
+
| "conflict"
|
|
9
|
+
| "invalid"
|
|
10
|
+
| "not_found"
|
|
11
|
+
| "rate_limited"
|
|
12
|
+
| "unavailable";
|
|
13
|
+
|
|
14
|
+
export type AcquisitionCaseResult<T> =
|
|
15
|
+
| { ok: true; value: T; replayed?: boolean }
|
|
16
|
+
| { ok: false; error: { kind: AcquisitionCaseFailureKind } };
|
|
17
|
+
|
|
18
|
+
export interface AcquisitionCaseListQuery {
|
|
19
|
+
actorRef: string;
|
|
20
|
+
scope: "public_tester_application";
|
|
21
|
+
cursor?: string;
|
|
22
|
+
limit: number;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface AcquisitionCaseGetQuery {
|
|
26
|
+
actorRef: string;
|
|
27
|
+
scope: "public_tester_application";
|
|
28
|
+
caseRef: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface AcquisitionCasePort {
|
|
32
|
+
list(query: AcquisitionCaseListQuery): Promise<AcquisitionCaseResult<AcquisitionCaseListResponse>>;
|
|
33
|
+
get(query: AcquisitionCaseGetQuery): Promise<AcquisitionCaseResult<AcquisitionCaseProjection>>;
|
|
34
|
+
activeCount(scope: "public_tester_application"): Promise<AcquisitionCaseResult<number>>;
|
|
35
|
+
close(): Promise<void>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export type AcquisitionEvidenceFailure = "invalid" | "not_found" | "conflict" | "unavailable";
|
|
39
|
+
export type AcquisitionEvidenceResult<T> =
|
|
40
|
+
| { ok: true; value: T }
|
|
41
|
+
| { ok: false; error: { kind: AcquisitionEvidenceFailure } };
|
|
42
|
+
|
|
43
|
+
export interface AcquisitionEvidencePort {
|
|
44
|
+
submitSurvey(input: AcquisitionSurveySubmit & { idempotencyKey: string }): Promise<AcquisitionEvidenceResult<AcquisitionSurveySubmitResponse>>;
|
|
45
|
+
listSurveys(input: AcquisitionSurveyListQuery & { actorReference: string }): Promise<AcquisitionEvidenceResult<AcquisitionSurveyListResponse>>;
|
|
46
|
+
applyNewsletterConsent(input: AcquisitionNewsletterConsentEvent): Promise<AcquisitionEvidenceResult<AcquisitionNewsletterConsentResponse>>;
|
|
47
|
+
close(): Promise<void>;
|
|
48
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/** The host supplies its own literal step vocabulary. */
|
|
2
|
+
export type AnalyticsStepName<StepName extends string = string> = StepName;
|
|
3
|
+
export interface AnalyticsCheckoutItem { item_id: string; quantity: number }
|
|
4
|
+
export interface AnalyticsPurchaseItem extends AnalyticsCheckoutItem {
|
|
5
|
+
item_variant?: string;
|
|
6
|
+
price: number;
|
|
7
|
+
discount: number;
|
|
8
|
+
}
|
|
9
|
+
export type AnalyticsCheckoutMode = "one_time" | "subscription";
|
|
10
|
+
/** No answer describes an ended wait, without asserting payment failure. */
|
|
11
|
+
export type AnalyticsPaymentWaitOutcome = "confirmed" | "refused" | "no_answer";
|
|
12
|
+
export interface AnalyticsEventMap<StepName extends string = string> {
|
|
13
|
+
page_view: { page_path: string };
|
|
14
|
+
configurator_start: { entry_view: "hero" | "configurator" };
|
|
15
|
+
configurator_step_view: { step_number: number; step_name: AnalyticsStepName<StepName> };
|
|
16
|
+
begin_checkout: { checkout_mode: AnalyticsCheckoutMode; items: AnalyticsCheckoutItem[] };
|
|
17
|
+
purchase: {
|
|
18
|
+
transaction_id: string;
|
|
19
|
+
currency: string;
|
|
20
|
+
value: number;
|
|
21
|
+
shipping: number;
|
|
22
|
+
tax: number;
|
|
23
|
+
checkout_mode: AnalyticsCheckoutMode;
|
|
24
|
+
items: AnalyticsPurchaseItem[];
|
|
25
|
+
};
|
|
26
|
+
// Wait observations carry no identity, amount, currency or payment method.
|
|
27
|
+
payment_wait_start: { checkoutMode: AnalyticsCheckoutMode };
|
|
28
|
+
payment_wait_end: { outcome: AnalyticsPaymentWaitOutcome; checkoutMode: AnalyticsCheckoutMode };
|
|
29
|
+
configurator_draft_restored: { draft_context: "public" };
|
|
30
|
+
configurator_draft_save_failed: { draft_context: "public"; reason: "unavailable" | "quota" | "conflict" };
|
|
31
|
+
configurator_draft_reset: { draft_context: "public" };
|
|
32
|
+
}
|
|
33
|
+
export type AnalyticsEventName = keyof AnalyticsEventMap;
|
|
34
|
+
|
|
35
|
+
export interface AnalyticsSinkAttemptMask { deployment: boolean; optional: boolean }
|
|
36
|
+
/** Synchronous local acceptance only; never transport delivery or business acknowledgement. */
|
|
37
|
+
export interface AnalyticsSinkAdmission { deployment: boolean; optional: boolean }
|
|
38
|
+
export interface AnalyticsCookieConsent {
|
|
39
|
+
necessary: boolean; functional: boolean; analytics: boolean; marketing: boolean;
|
|
40
|
+
}
|
|
41
|
+
export type AnalyticsBrowserWindow = Pick<Window, "localStorage" | "addEventListener" | "removeEventListener"> & {
|
|
42
|
+
dataLayer?: unknown[];
|
|
43
|
+
};
|
|
44
|
+
export interface AnalyticsDataLayerOptions<StepName extends string = string> {
|
|
45
|
+
consentStorageKey?: string;
|
|
46
|
+
consentChangeEvent?: string;
|
|
47
|
+
/** Host wire names, analytics first then advertising in supplied order. Omission disables consent commands and optional event admission. */
|
|
48
|
+
consentSignalNames?: { analytics: string; advertising: readonly string[] };
|
|
49
|
+
eventPrefix?: string;
|
|
50
|
+
readContainerId?: () => string | null;
|
|
51
|
+
trackDeploymentEvent?: <K extends AnalyticsEventName>(event: K, properties: AnalyticsEventMap<StepName>[K]) => boolean;
|
|
52
|
+
getWindow?: () => AnalyticsBrowserWindow | undefined;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface AnalyticsRoutePolicyInput {
|
|
56
|
+
publicPaths: readonly string[];
|
|
57
|
+
redirectSources: readonly string[];
|
|
58
|
+
privatePathPrefixes: readonly string[];
|
|
59
|
+
privateAuthPaths: readonly string[];
|
|
60
|
+
capabilityPathPrefixes: readonly string[];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Only paid recap facts read by the projection; money remains the host's truth. */
|
|
64
|
+
export interface PurchaseOrder {
|
|
65
|
+
orderId: string;
|
|
66
|
+
status: string;
|
|
67
|
+
paymentStatus: string | null;
|
|
68
|
+
checkoutKind: "one_time" | "subscription_initial" | "subscription_renewal" | null;
|
|
69
|
+
moneyReconciled: boolean;
|
|
70
|
+
items: Array<{ sku: string | null; variantCode: string | null; quantity: number;
|
|
71
|
+
catalogTotalGross: number; effectiveNet: number; vatRateBps: number }>;
|
|
72
|
+
totals: { tax: { amountMinor: number }; total: { amountMinor: number; currency: string } };
|
|
73
|
+
}
|
|
74
|
+
export type PurchaseSuppressionReason = "order_not_paid" | "payment_not_succeeded"
|
|
75
|
+
| "checkout_kind_unsupported" | "money_unreconciled" | "items_empty" | "sku_missing"
|
|
76
|
+
| "quantity_invalid" | "line_money_invalid" | "net_discount_invalid"
|
|
77
|
+
| "item_limit_exceeded" | "shipping_net_invalid";
|
|
78
|
+
|
|
79
|
+
export interface MarketingHistoricalConsentCommand { consentedAt: string | null; listId: string | null }
|
|
80
|
+
/** Native state literals are compatibility inputs supplied by the host adapter. */
|
|
81
|
+
export interface MarketingHistoricalConsentState {
|
|
82
|
+
consent: "SUBSCRIBED" | "UNSUBSCRIBED" | "NEVER_SUBSCRIBED" | "unknown";
|
|
83
|
+
nativeConsentAt?: string | null;
|
|
84
|
+
suppressions: Array<{ reason: "UNSUBSCRIBE" | "SPAM_REPORT" | "USER_SUPPRESSED" | "HARD_BOUNCE" | "INVALID_EMAIL" | "unknown";
|
|
85
|
+
listId: string | null }>;
|
|
86
|
+
}
|
|
87
|
+
export type MarketingHistoricalConsentResult = { kind: "ready"; providerConsentedAt: string }
|
|
88
|
+
| { kind: "defer"; retryAt: string } | { kind: "hold"; reason: string };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export interface OrganizationFacts {
|
|
2
|
+
name: string;
|
|
3
|
+
legalName: string;
|
|
4
|
+
url: string;
|
|
5
|
+
logo: { url: string; contentUrl: string; width: number; height: number };
|
|
6
|
+
email: string;
|
|
7
|
+
vatID: string;
|
|
8
|
+
taxID: string;
|
|
9
|
+
areaServed: string;
|
|
10
|
+
sameAs: string[];
|
|
11
|
+
contactPoint: { email: string; contactType: string; availableLanguage: string[] };
|
|
12
|
+
address: {
|
|
13
|
+
streetAddress: string;
|
|
14
|
+
addressLocality: string;
|
|
15
|
+
postalCode: string;
|
|
16
|
+
addressRegion: string;
|
|
17
|
+
addressCountry: string;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface ContactContent {
|
|
22
|
+
organization: OrganizationFacts;
|
|
23
|
+
supportEmail: string;
|
|
24
|
+
addressLine: string;
|
|
25
|
+
registrationIdentifiers: { label: string; value: string }[];
|
|
26
|
+
registrationAuthority?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface LegalDocumentContent {
|
|
30
|
+
title: string;
|
|
31
|
+
intro: string;
|
|
32
|
+
sections: { title: string; body: string }[];
|
|
33
|
+
lastUpdated?: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface PrivacyProcessorDisclosure {
|
|
37
|
+
processorName: string;
|
|
38
|
+
purpose: string;
|
|
39
|
+
dataCategories: string[];
|
|
40
|
+
details?: string;
|
|
41
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type * from "./acquisition.js";
|
|
2
|
+
export type {
|
|
3
|
+
MarketingResearchJson,
|
|
4
|
+
ResearchSurveyType,
|
|
5
|
+
AdminSurveyResponsesRequest,
|
|
6
|
+
AdminSurveyResponseRow,
|
|
7
|
+
AdminSurveyResponsesResponse,
|
|
8
|
+
ResearchSurveySubmitRequest,
|
|
9
|
+
ResearchSurveySubmitResponse,
|
|
10
|
+
MarketingResearchSurveyResponsesReadPort,
|
|
11
|
+
MarketingResearchSurveyRequestHeaders,
|
|
12
|
+
MarketingResearchSurveySubmitPort,
|
|
13
|
+
} from "@openlup/core/marketing/research";
|
|
14
|
+
export type * from "./acquisitionPorts.js";
|
|
15
|
+
export type * from "./prelaunch.js";
|
|
16
|
+
export type * from "./analytics.js";
|
|
17
|
+
export type * from "./contactLegal.js";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type PrelaunchAcquisitionListRequest = { view: "prelaunch_acquisition_v1"; cursor?: string | undefined; limit: number };
|
|
2
|
+
export type PrelaunchAcquisitionDetailRequest = { sourceRef: string };
|
|
3
|
+
export type PrelaunchAcquisitionLead = {
|
|
4
|
+
sourceRef: string;
|
|
5
|
+
contactRef: string;
|
|
6
|
+
sourceKind: "tester_application";
|
|
7
|
+
consent: { consentVersion: string; policyVersion: string; recordedAt: string; locale: "en" | "pl"; sourcePath: "/tester-application" };
|
|
8
|
+
addressReference: { source: string; reference: string; revision: string; provenance: string } | null;
|
|
9
|
+
state: "submitted" | "approved" | "active" | "rejected" | "withdrawn";
|
|
10
|
+
version: number;
|
|
11
|
+
createdAt: string;
|
|
12
|
+
updatedAt: string;
|
|
13
|
+
};
|
|
14
|
+
export type PrelaunchAcquisitionListResponse = { contractVersion: "prelaunch_acquisition_v1"; leads: PrelaunchAcquisitionLead[]; nextCursor: string | null };
|
|
15
|
+
export type PrelaunchAcquisitionDetailResponse = { contractVersion: "prelaunch_acquisition_v1"; lead: PrelaunchAcquisitionLead };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export * from "./acquisitionCaseSchemas.js";
|
|
2
|
+
export * from "./acquisitionEvidenceSchemas.js";
|
|
3
|
+
export * from "@openlup/core/marketing/research";
|
|
4
|
+
export * from "./prelaunchAcquisitionSchemas.js";
|
|
5
|
+
export type * from "./contracts/acquisitionPorts.js";
|
|
6
|
+
export * from "./analytics/noop.js";
|
|
7
|
+
export * from "./analytics/dataLayer.js";
|
|
8
|
+
export * from "./analytics/routePolicy.js";
|
|
9
|
+
export * from "./analytics/purchaseFacts.js";
|
|
10
|
+
export * from "./consentEvidence.js";
|
|
11
|
+
export * from "./seo/serializeJsonLd.js";
|
|
12
|
+
export * from "./seo/urls.js";
|
|
13
|
+
export * from "./seo/metadata.js";
|
|
14
|
+
export * from "./seo/jsonLd.js";
|
|
15
|
+
export type * from "./contracts/contactLegal.js";
|
|
16
|
+
export * from "./contactLegal.js";
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { z } from "./validation.js";
|
|
2
|
+
|
|
3
|
+
export const PRELAUNCH_ACQUISITION_VIEW = "prelaunch_acquisition_v1" as const;
|
|
4
|
+
export const PRELAUNCH_ACQUISITION_CONTRACT_VERSION = "prelaunch_acquisition_v1" as const;
|
|
5
|
+
|
|
6
|
+
const acquisitionCaseRefSchema = z.string().regex(/^acquisition-case:[0-9a-f-]{36}$/);
|
|
7
|
+
const acquisitionContactRefSchema = z.string().regex(/^acquisition-contact:[0-9a-f-]{36}$/);
|
|
8
|
+
const acquisitionOpaqueRefSchema = z.string().trim().min(8).max(160)
|
|
9
|
+
.regex(/^[A-Za-z0-9][A-Za-z0-9._:-]*$/);
|
|
10
|
+
const acquisitionDateTimeSchema = z.string().datetime({ offset: true });
|
|
11
|
+
|
|
12
|
+
export const prelaunchAcquisitionListRequestSchema = z.object({
|
|
13
|
+
view: z.literal(PRELAUNCH_ACQUISITION_VIEW),
|
|
14
|
+
cursor: acquisitionOpaqueRefSchema.optional(),
|
|
15
|
+
limit: z.coerce.number().int().min(1).max(100).default(25),
|
|
16
|
+
}).strict();
|
|
17
|
+
|
|
18
|
+
export const prelaunchAcquisitionDetailRequestSchema = z.object({
|
|
19
|
+
sourceRef: acquisitionCaseRefSchema,
|
|
20
|
+
}).strict();
|
|
21
|
+
|
|
22
|
+
export const prelaunchAcquisitionLeadSchema = z.object({
|
|
23
|
+
sourceRef: acquisitionCaseRefSchema,
|
|
24
|
+
contactRef: acquisitionContactRefSchema,
|
|
25
|
+
sourceKind: z.literal("tester_application"),
|
|
26
|
+
consent: z.object({
|
|
27
|
+
consentVersion: z.string().min(1).max(64),
|
|
28
|
+
policyVersion: z.string().min(1).max(64),
|
|
29
|
+
recordedAt: acquisitionDateTimeSchema,
|
|
30
|
+
locale: z.enum(["en", "pl"]),
|
|
31
|
+
sourcePath: z.literal("/tester-application"),
|
|
32
|
+
}).strict(),
|
|
33
|
+
addressReference: z.object({
|
|
34
|
+
source: z.string().trim().min(1).max(48).regex(/^[a-z][a-z0-9_-]*$/),
|
|
35
|
+
reference: acquisitionOpaqueRefSchema,
|
|
36
|
+
revision: z.string().trim().min(1).max(64).regex(/^[A-Za-z0-9][A-Za-z0-9._:-]*$/),
|
|
37
|
+
provenance: z.string().trim().min(1).max(64).regex(/^[a-z][a-z0-9_-]*$/),
|
|
38
|
+
}).strict().nullable(),
|
|
39
|
+
state: z.enum(["submitted", "approved", "active", "rejected", "withdrawn"]),
|
|
40
|
+
version: z.number().int().positive(),
|
|
41
|
+
createdAt: acquisitionDateTimeSchema,
|
|
42
|
+
updatedAt: acquisitionDateTimeSchema,
|
|
43
|
+
}).strict().superRefine((value, context) => {
|
|
44
|
+
if (value.state !== "withdrawn" && value.addressReference === null) {
|
|
45
|
+
context.addIssue({ code: z.ZodIssueCode.custom, path: ["addressReference"], message: "active case requires address reference" });
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
export const prelaunchAcquisitionListResponseSchema = z.object({
|
|
50
|
+
contractVersion: z.literal(PRELAUNCH_ACQUISITION_CONTRACT_VERSION),
|
|
51
|
+
leads: z.array(prelaunchAcquisitionLeadSchema).max(100),
|
|
52
|
+
nextCursor: acquisitionOpaqueRefSchema.nullable(),
|
|
53
|
+
}).strict();
|
|
54
|
+
|
|
55
|
+
export const prelaunchAcquisitionDetailResponseSchema = z.object({
|
|
56
|
+
contractVersion: z.literal(PRELAUNCH_ACQUISITION_CONTRACT_VERSION),
|
|
57
|
+
lead: prelaunchAcquisitionLeadSchema,
|
|
58
|
+
}).strict();
|
|
59
|
+
|
|
60
|
+
export type PrelaunchAcquisitionListRequest = z.infer<typeof prelaunchAcquisitionListRequestSchema>;
|
|
61
|
+
export type PrelaunchAcquisitionDetailRequest = z.infer<typeof prelaunchAcquisitionDetailRequestSchema>;
|
|
62
|
+
export type PrelaunchAcquisitionLead = z.infer<typeof prelaunchAcquisitionLeadSchema>;
|
|
63
|
+
export type PrelaunchAcquisitionListResponse = z.infer<typeof prelaunchAcquisitionListResponseSchema>;
|
|
64
|
+
export type PrelaunchAcquisitionDetailResponse = z.infer<typeof prelaunchAcquisitionDetailResponseSchema>;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import type { OrganizationFacts } from "../contracts/contactLegal.js";
|
|
2
|
+
|
|
3
|
+
export type JsonLdNode = Record<string, unknown> & { "@context"?: string; "@id"?: string };
|
|
4
|
+
|
|
5
|
+
export function jsonLdGraph(...nodes: JsonLdNode[]) {
|
|
6
|
+
const seen = new Set<string>();
|
|
7
|
+
const graph = nodes.flatMap(({ "@context": _context, ...node }) => {
|
|
8
|
+
if (node["@id"] && seen.has(node["@id"] as string)) return [];
|
|
9
|
+
if (node["@id"]) seen.add(node["@id"] as string);
|
|
10
|
+
return [node];
|
|
11
|
+
});
|
|
12
|
+
return { "@context": "https://schema.org", "@graph": graph };
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function entityIds(origin: string) {
|
|
16
|
+
const site = origin.replace(/\/$/, "");
|
|
17
|
+
return {
|
|
18
|
+
organization: `${site}/#organization`,
|
|
19
|
+
website: `${site}/#website`,
|
|
20
|
+
brand: `${site}/#brand`,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function organizationLd(origin: string, type: "Organization" | "OnlineStore", facts: OrganizationFacts) {
|
|
25
|
+
return {
|
|
26
|
+
"@context": "https://schema.org",
|
|
27
|
+
"@id": entityIds(origin).organization,
|
|
28
|
+
"@type": type,
|
|
29
|
+
name: facts.name,
|
|
30
|
+
legalName: facts.legalName,
|
|
31
|
+
url: facts.url,
|
|
32
|
+
logo: {
|
|
33
|
+
"@type": "ImageObject",
|
|
34
|
+
url: facts.logo.url,
|
|
35
|
+
contentUrl: facts.logo.contentUrl,
|
|
36
|
+
width: facts.logo.width,
|
|
37
|
+
height: facts.logo.height,
|
|
38
|
+
},
|
|
39
|
+
email: facts.email,
|
|
40
|
+
vatID: facts.vatID,
|
|
41
|
+
taxID: facts.taxID,
|
|
42
|
+
areaServed: facts.areaServed,
|
|
43
|
+
sameAs: facts.sameAs,
|
|
44
|
+
contactPoint: {
|
|
45
|
+
"@type": "ContactPoint",
|
|
46
|
+
email: facts.contactPoint.email,
|
|
47
|
+
contactType: facts.contactPoint.contactType,
|
|
48
|
+
availableLanguage: facts.contactPoint.availableLanguage,
|
|
49
|
+
},
|
|
50
|
+
address: {
|
|
51
|
+
"@type": "PostalAddress",
|
|
52
|
+
streetAddress: facts.address.streetAddress,
|
|
53
|
+
addressLocality: facts.address.addressLocality,
|
|
54
|
+
postalCode: facts.address.postalCode,
|
|
55
|
+
addressRegion: facts.address.addressRegion,
|
|
56
|
+
addressCountry: facts.address.addressCountry,
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function brandLd(origin: string, name: string, url: string) {
|
|
62
|
+
return { "@context": "https://schema.org", "@id": entityIds(origin).brand, "@type": "Brand", name, url };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function websiteLd(origin: string, name: string, url: string, inLanguage: string[]) {
|
|
66
|
+
return {
|
|
67
|
+
"@context": "https://schema.org",
|
|
68
|
+
"@id": entityIds(origin).website,
|
|
69
|
+
"@type": "WebSite",
|
|
70
|
+
name,
|
|
71
|
+
url,
|
|
72
|
+
inLanguage,
|
|
73
|
+
publisher: { "@id": entityIds(origin).organization },
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function contactPageLd(origin: string, pageUrl: string) {
|
|
78
|
+
return {
|
|
79
|
+
"@context": "https://schema.org",
|
|
80
|
+
"@id": `${pageUrl.replace(/\/$/, "")}#webpage`,
|
|
81
|
+
"@type": "ContactPage",
|
|
82
|
+
url: pageUrl,
|
|
83
|
+
publisher: { "@id": entityIds(origin).organization },
|
|
84
|
+
mainEntity: { "@id": entityIds(origin).organization },
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface NetContent { unscaled: number; scale: number; unit: string }
|
|
89
|
+
|
|
90
|
+
export function schemaWeight(netContent: NetContent) {
|
|
91
|
+
const { unscaled, scale, unit } = netContent;
|
|
92
|
+
const unitCode = unit === "GRAM" || unit === "G" ? "GRM" : unit;
|
|
93
|
+
return { "@type": "QuantitativeValue", value: unscaled / 10 ** scale, unitCode };
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface ProductFacts {
|
|
97
|
+
url: string;
|
|
98
|
+
name: string;
|
|
99
|
+
inLanguage: string;
|
|
100
|
+
brandName: string;
|
|
101
|
+
category?: string;
|
|
102
|
+
images: string[];
|
|
103
|
+
sku?: string;
|
|
104
|
+
gtin13?: string;
|
|
105
|
+
netContent?: NetContent;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function productLd(origin: string, product: ProductFacts) {
|
|
109
|
+
return {
|
|
110
|
+
"@context": "https://schema.org",
|
|
111
|
+
"@id": `${product.url.replace(/\/$/, "")}#product`,
|
|
112
|
+
"@type": "Product",
|
|
113
|
+
name: product.name,
|
|
114
|
+
inLanguage: product.inLanguage,
|
|
115
|
+
brand: { "@id": entityIds(origin).brand, "@type": "Brand", name: product.brandName },
|
|
116
|
+
manufacturer: { "@id": entityIds(origin).organization },
|
|
117
|
+
...(product.category !== undefined ? { category: product.category } : {}),
|
|
118
|
+
image: product.images,
|
|
119
|
+
...(product.sku !== undefined ? { sku: product.sku } : {}),
|
|
120
|
+
...(product.gtin13 !== undefined ? { gtin13: product.gtin13 } : {}),
|
|
121
|
+
...(product.netContent ? { weight: schemaWeight(product.netContent) } : {}),
|
|
122
|
+
url: product.url,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const pageEntityId = (pageUrl: string, fragment: string) => `${pageUrl.replace(/\/$/, "")}#${fragment}`;
|
|
127
|
+
|
|
128
|
+
export function faqPageLd(faqs: { question: string; answer: string }[], pageUrl: string) {
|
|
129
|
+
return {
|
|
130
|
+
"@context": "https://schema.org",
|
|
131
|
+
"@id": pageEntityId(pageUrl, "faq"),
|
|
132
|
+
"@type": "FAQPage",
|
|
133
|
+
mainEntity: faqs.map((faq) => ({
|
|
134
|
+
"@type": "Question",
|
|
135
|
+
name: faq.question,
|
|
136
|
+
acceptedAnswer: { "@type": "Answer", text: faq.answer },
|
|
137
|
+
})),
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export function breadcrumbLd(items: { name: string; url?: string }[], pageUrl: string) {
|
|
142
|
+
return {
|
|
143
|
+
"@context": "https://schema.org",
|
|
144
|
+
"@id": pageEntityId(pageUrl, "breadcrumb"),
|
|
145
|
+
"@type": "BreadcrumbList",
|
|
146
|
+
itemListElement: items.map((item, index) => ({
|
|
147
|
+
"@type": "ListItem",
|
|
148
|
+
position: index + 1,
|
|
149
|
+
name: item.name,
|
|
150
|
+
...(item.url ? { item: item.url } : {}),
|
|
151
|
+
})),
|
|
152
|
+
};
|
|
153
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { jsonLdGraph, type JsonLdNode } from "./jsonLd.js";
|
|
2
|
+
import { serializeJsonLd } from "./serializeJsonLd.js";
|
|
3
|
+
import { canonicalUrlForRoute, hreflangLinksForRoute, type SiteRoute } from "./urls.js";
|
|
4
|
+
|
|
5
|
+
export type HeadTag =
|
|
6
|
+
| { kind: "meta"; name: string; content: string }
|
|
7
|
+
| { kind: "meta"; property: string; content: string }
|
|
8
|
+
| { kind: "link"; rel: "canonical" | "alternate"; href: string; hrefLang?: string };
|
|
9
|
+
|
|
10
|
+
export interface HeadFacts {
|
|
11
|
+
origin: string;
|
|
12
|
+
route: SiteRoute;
|
|
13
|
+
routes: readonly SiteRoute[];
|
|
14
|
+
xDefaultLocale: string;
|
|
15
|
+
htmlLang: string;
|
|
16
|
+
title: string;
|
|
17
|
+
description: string;
|
|
18
|
+
siteName: string;
|
|
19
|
+
ogImage: string;
|
|
20
|
+
ogImageWidth: number;
|
|
21
|
+
ogImageHeight: number;
|
|
22
|
+
ogLocale: string;
|
|
23
|
+
alternateOgLocale?: string;
|
|
24
|
+
twitterImage: string;
|
|
25
|
+
twitterHandle: string;
|
|
26
|
+
noindex?: boolean;
|
|
27
|
+
jsonLd?: JsonLdNode | JsonLdNode[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function buildHeadDescriptor(facts: HeadFacts): { htmlLang: string; title: string; tags: HeadTag[]; jsonLd: string | null } {
|
|
31
|
+
const canonicalUrl = canonicalUrlForRoute(facts.origin, facts.route);
|
|
32
|
+
const nodes = facts.jsonLd ? (Array.isArray(facts.jsonLd) ? facts.jsonLd : [facts.jsonLd]) : [];
|
|
33
|
+
const tags: HeadTag[] = [
|
|
34
|
+
{ kind: "meta", name: "description", content: facts.description },
|
|
35
|
+
{ kind: "link", rel: "canonical", href: canonicalUrl },
|
|
36
|
+
...(facts.noindex ? [{ kind: "meta" as const, name: "robots", content: "noindex, nofollow" }] : []),
|
|
37
|
+
{ kind: "meta", property: "og:title", content: facts.title },
|
|
38
|
+
{ kind: "meta", property: "og:description", content: facts.description },
|
|
39
|
+
{ kind: "meta", property: "og:image", content: facts.ogImage },
|
|
40
|
+
{ kind: "meta", property: "og:image:width", content: String(facts.ogImageWidth) },
|
|
41
|
+
{ kind: "meta", property: "og:image:height", content: String(facts.ogImageHeight) },
|
|
42
|
+
{ kind: "meta", property: "og:type", content: "website" },
|
|
43
|
+
{ kind: "meta", property: "og:site_name", content: facts.siteName },
|
|
44
|
+
{ kind: "meta", property: "og:url", content: canonicalUrl },
|
|
45
|
+
{ kind: "meta", property: "og:locale", content: facts.ogLocale },
|
|
46
|
+
...(facts.alternateOgLocale ? [{ kind: "meta" as const, property: "og:locale:alternate", content: facts.alternateOgLocale }] : []),
|
|
47
|
+
{ kind: "meta", name: "twitter:card", content: "summary_large_image" },
|
|
48
|
+
{ kind: "meta", name: "twitter:site", content: facts.twitterHandle },
|
|
49
|
+
{ kind: "meta", name: "twitter:title", content: facts.title },
|
|
50
|
+
{ kind: "meta", name: "twitter:description", content: facts.description },
|
|
51
|
+
{ kind: "meta", name: "twitter:image", content: facts.twitterImage },
|
|
52
|
+
...hreflangLinksForRoute(facts.origin, facts.route, facts.routes, facts.xDefaultLocale).map((link) => ({
|
|
53
|
+
kind: "link" as const, rel: "alternate" as const, hrefLang: link.hrefLang, href: link.href,
|
|
54
|
+
})),
|
|
55
|
+
];
|
|
56
|
+
return {
|
|
57
|
+
htmlLang: facts.htmlLang,
|
|
58
|
+
title: facts.title,
|
|
59
|
+
tags,
|
|
60
|
+
jsonLd: nodes.length > 0 ? serializeJsonLd(jsonLdGraph(...nodes)) : null,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export interface SiteRoute {
|
|
2
|
+
id: string;
|
|
3
|
+
locale: string;
|
|
4
|
+
canonicalPath: string;
|
|
5
|
+
alternateRouteId?: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface HreflangLink { hrefLang: string; href: string }
|
|
9
|
+
|
|
10
|
+
export function normalizeSitePath(pathname: string): string {
|
|
11
|
+
const path = pathname.startsWith("/") ? pathname : `/${pathname}`;
|
|
12
|
+
return path.length > 1 ? path.replace(/\/$/, "") : path;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function absoluteSiteUrl(origin: string, pathname: string): string {
|
|
16
|
+
const site = origin.replace(/\/$/, "");
|
|
17
|
+
const path = normalizeSitePath(pathname);
|
|
18
|
+
return path === "/" ? `${site}/` : `${site}${path}`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function canonicalUrlForRoute(origin: string, route: SiteRoute): string {
|
|
22
|
+
return absoluteSiteUrl(origin, route.canonicalPath);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function hreflangLinksForRoute(origin: string, route: SiteRoute, routes: readonly SiteRoute[], xDefaultLocale: string): HreflangLink[] {
|
|
26
|
+
const alternate = route.alternateRouteId ? routes.find((candidate) => candidate.id === route.alternateRouteId) : undefined;
|
|
27
|
+
if (!alternate) return [];
|
|
28
|
+
const pair = [route, alternate].sort((a, b) => a.locale.localeCompare(b.locale));
|
|
29
|
+
const preferred = pair.find((candidate) => candidate.locale === xDefaultLocale);
|
|
30
|
+
return [
|
|
31
|
+
...pair.map((candidate) => ({ hrefLang: candidate.locale, href: canonicalUrlForRoute(origin, candidate) })),
|
|
32
|
+
{ hrefLang: "x-default", href: canonicalUrlForRoute(origin, preferred ?? pair[0]) },
|
|
33
|
+
];
|
|
34
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { HttpRequest, HttpResponse } from "../../http/index.js";
|
|
2
|
+
import type { BffResponder } from "../../bff/index.js";
|
|
3
|
+
import type { AcquisitionCaseDirectDeps, AcquisitionCaseBindingResolver } from "./directPorts.js";
|
|
4
|
+
import { ACQUISITION_CASE_VIEW, acquisitionCaseActiveCountResponseSchema, acquisitionCaseListRequestSchema, acquisitionCaseListResponseSchema } from "../acquisitionCaseSchemas.js";
|
|
5
|
+
import type { AcquisitionCaseFailureKind } from "../contracts/index.js";
|
|
6
|
+
|
|
7
|
+
export function createAcquisitionCaseListDirectHandler(options: AcquisitionCaseDirectDeps) {
|
|
8
|
+
const { respond, authorize, resolveBinding, isDirect } = options;
|
|
9
|
+
const { sendBffSuccess, sendMethodNotAllowed } = respond;
|
|
10
|
+
return async (req: HttpRequest, res: HttpResponse): Promise<void> => {
|
|
11
|
+
if (!isDirect() || first(req.query.view) !== ACQUISITION_CASE_VIEW) return unavailable(res, respond);
|
|
12
|
+
if (req.method !== "GET") return sendMethodNotAllowed(res, ["GET"]);
|
|
13
|
+
const actorRef = await authorize(req, res);
|
|
14
|
+
if (!actorRef) return;
|
|
15
|
+
const request = acquisitionCaseListRequestSchema.safeParse({
|
|
16
|
+
view: first(req.query.view), cursor: first(req.query.cursor), limit: integer(first(req.query.limit), 25),
|
|
17
|
+
});
|
|
18
|
+
if (!request.success) return badRequest(res, respond, request.error.flatten());
|
|
19
|
+
const binding = await bindingOrError(res, respond, resolveBinding);
|
|
20
|
+
if (!binding) return;
|
|
21
|
+
const result = await operationOrError(res, respond, () => binding.handlers.list(actorRef, request.data));
|
|
22
|
+
if (!result) return;
|
|
23
|
+
if (result.ok === false) return failure(res, respond, result.error.kind);
|
|
24
|
+
const response = acquisitionCaseListResponseSchema.safeParse(result.value);
|
|
25
|
+
if (!response.success) return invalidResponse(res, respond);
|
|
26
|
+
sendBffSuccess(res, response.data);
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function createAcquisitionCaseActiveCountDirectHandler(options: AcquisitionCaseDirectDeps) {
|
|
31
|
+
const { respond, resolveBinding, isDirect } = options;
|
|
32
|
+
const { sendBffSuccess, sendMethodNotAllowed } = respond;
|
|
33
|
+
return async (req: HttpRequest, res: HttpResponse): Promise<void> => {
|
|
34
|
+
if (!isDirect()) return unavailable(res, respond);
|
|
35
|
+
if (req.method !== "GET") return sendMethodNotAllowed(res, ["GET"]);
|
|
36
|
+
const binding = await bindingOrError(res, respond, resolveBinding);
|
|
37
|
+
if (!binding) return;
|
|
38
|
+
const result = await operationOrError(res, respond, () => binding.handlers.activeCount());
|
|
39
|
+
if (!result) return;
|
|
40
|
+
if (result.ok === false) return failure(res, respond, result.error.kind);
|
|
41
|
+
const response = acquisitionCaseActiveCountResponseSchema.safeParse(result.value);
|
|
42
|
+
if (!response.success) return invalidResponse(res, respond);
|
|
43
|
+
sendBffSuccess(res, response.data);
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async function bindingOrError(res: HttpResponse, respond: BffResponder, resolve: AcquisitionCaseBindingResolver) {
|
|
48
|
+
try { const binding = await resolve(); if (binding) return binding; } catch { /* fail closed below */ }
|
|
49
|
+
respond.sendBffError(res, "UPSTREAM_UNAVAILABLE", "Acquisition case service unavailable");
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
async function operationOrError<T>(res: HttpResponse, respond: BffResponder, operation: () => Promise<T>): Promise<T | null> {
|
|
53
|
+
try { return await operation(); } catch { respond.sendBffError(res, "UPSTREAM_UNAVAILABLE", "Acquisition case service unavailable"); return null; }
|
|
54
|
+
}
|
|
55
|
+
function first(value: string | string[] | undefined): string | undefined { return Array.isArray(value) ? value[0] : value; }
|
|
56
|
+
function integer(value: string | undefined, fallback: number): number { return value === undefined ? fallback : Number(value); }
|
|
57
|
+
function badRequest(res: HttpResponse, respond: BffResponder, details?: unknown): void { respond.sendBffError(res, "BAD_REQUEST", "Invalid acquisition case request", { details }); }
|
|
58
|
+
function unavailable(res: HttpResponse, respond: BffResponder): void { respond.sendBffError(res, "NOT_FOUND", "Acquisition case unavailable"); }
|
|
59
|
+
function invalidResponse(res: HttpResponse, respond: BffResponder): void { respond.sendBffError(res, "INVALID_RESPONSE", "Acquisition case returned invalid response"); }
|
|
60
|
+
function failure(res: HttpResponse, respond: BffResponder, kind: AcquisitionCaseFailureKind): void {
|
|
61
|
+
if (kind === "invalid") return badRequest(res, respond);
|
|
62
|
+
if (kind === "conflict") return respond.sendBffError(res, "CONFLICT", "Acquisition case request conflicts with prior state");
|
|
63
|
+
if (kind === "rate_limited") return respond.sendBffError(res, "RATE_LIMITED", "Acquisition submission rate limited");
|
|
64
|
+
if (kind === "not_found") return unavailable(res, respond);
|
|
65
|
+
respond.sendBffError(res, "UPSTREAM_UNAVAILABLE", "Acquisition case service unavailable");
|
|
66
|
+
}
|
|
67
|
+
|