@openlup/platform 0.27.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 +386 -127
- package/README.md +251 -9
- package/dist/account-support/accountReadFacade.d.ts +8 -0
- package/dist/account-support/accountReadFacade.js +10 -0
- package/dist/account-support/accountReadModels.d.ts +69 -0
- package/dist/account-support/accountReadModels.js +272 -0
- package/dist/account-support/bindings.d.ts +23 -0
- package/dist/account-support/bindings.js +16 -0
- package/dist/account-support/contracts/account.d.ts +281 -0
- package/dist/account-support/contracts/account.js +1 -0
- package/dist/account-support/contracts/capabilities.d.ts +44 -0
- package/dist/account-support/contracts/capabilities.js +1 -0
- package/dist/account-support/contracts/commands.d.ts +307 -0
- package/dist/account-support/contracts/commands.js +1 -0
- package/dist/account-support/contracts/customer360.d.ts +154 -0
- package/dist/account-support/contracts/customer360.js +1 -0
- package/dist/account-support/contracts/index.d.ts +10 -0
- package/dist/account-support/contracts/index.js +1 -0
- package/dist/account-support/contracts/invoice.d.ts +79 -0
- package/dist/account-support/contracts/invoice.js +1 -0
- package/dist/account-support/contracts/operator.d.ts +289 -0
- package/dist/account-support/contracts/operator.js +1 -0
- package/dist/account-support/contribution.d.ts +24 -0
- package/dist/account-support/contribution.js +22 -0
- package/dist/account-support/customer360.d.ts +106 -0
- package/dist/account-support/customer360.js +163 -0
- package/dist/account-support/customerAccountReadDiagnostics.d.ts +11 -0
- package/dist/account-support/customerAccountReadDiagnostics.js +71 -0
- package/dist/account-support/index.d.ts +26 -0
- package/dist/account-support/index.js +15 -0
- package/dist/account-support/invoiceAccess.d.ts +57 -0
- package/dist/account-support/invoiceAccess.js +40 -0
- package/dist/account-support/migrations.d.ts +14 -0
- package/dist/account-support/migrations.js +7 -0
- package/dist/account-support/operatorAuthority.d.ts +67 -0
- package/dist/account-support/operatorAuthority.js +379 -0
- package/dist/account-support/operatorRecovery.d.ts +66 -0
- package/dist/account-support/operatorRecovery.js +129 -0
- package/dist/account-support/orderHistory.d.ts +50 -0
- package/dist/account-support/orderHistory.js +188 -0
- package/dist/account-support/paymentMethodComposition.d.ts +5 -0
- package/dist/account-support/paymentMethodComposition.js +4 -0
- package/dist/account-support/postgresOperatorAuthority.d.ts +16 -0
- package/dist/account-support/postgresOperatorAuthority.js +93 -0
- package/dist/account-support/selfService.d.ts +6 -0
- package/dist/account-support/selfService.js +81 -0
- package/dist/account-support/subscriptionCommandCodec.d.ts +10 -0
- package/dist/account-support/subscriptionCommandCodec.js +38 -0
- package/dist/catalog/draftSchemas.d.ts +1 -1
- package/dist/catalog/foundationSchemas.d.ts +3 -3
- package/dist/catalog/resolvedSkuProjection.d.ts +2 -2
- package/dist/catalog/sellableSchemas.d.ts +2 -2
- package/dist/commerce/checkoutCommandSchemas.d.ts +2 -2
- package/dist/commerce/checkoutResumeSchemas.d.ts +6 -6
- package/dist/commerce/checkoutSchemas.d.ts +12 -12
- package/dist/commerce/commerceReturnsPort.d.ts +2 -2
- package/dist/commerce/configuratorIntentSchemas.d.ts +2 -2
- package/dist/commerce/contractPrimitives.d.ts +8 -8
- package/dist/commerce/customerDefaultsSnapshotSchemas.d.ts +4 -4
- package/dist/commerce/model/omsReadModelHelpers.d.ts +4 -4
- package/dist/commerce/offerAvailabilitySchemas.d.ts +1 -1
- package/dist/commerce/oms/omsContractBase.d.ts +15 -15
- package/dist/commerce/oms/omsContractReadAuxSchemas.d.ts +11 -11
- package/dist/commerce/oms/omsContractReadSchemas.d.ts +121 -121
- package/dist/commerce/oms/omsContractRequests.d.ts +13 -13
- package/dist/commerce/oms/omsControlPlane.d.ts +22 -22
- package/dist/commerce/oms/omsFulfillmentContractSchemas.d.ts +12 -12
- package/dist/commerce/oms/omsFulfillmentDebugSchemas.d.ts +12 -12
- package/dist/commerce/orderReviewContracts.d.ts +33 -33
- package/dist/commerce/outboxEventSchemas.d.ts +4 -4
- package/dist/commerce/schemas.d.ts +21 -21
- package/dist/commerce/server/orderReviewHandlers.d.ts +10 -10
- package/dist/communications/consentPurposeRegistry.d.ts +1 -1
- package/dist/communications/newsletterIntegrationContracts.d.ts +8 -8
- package/dist/composition/accountSupportContribution.d.ts +18 -0
- package/dist/composition/accountSupportContribution.js +21 -0
- package/dist/composition/index.d.ts +2 -0
- package/dist/composition/index.js +2 -0
- package/dist/composition/marketingContribution.d.ts +21 -0
- package/dist/composition/marketingContribution.js +29 -0
- package/dist/fulfillment/handlerSchemas.d.ts +40 -40
- package/dist/identity/customerContracts.d.ts +2 -2
- package/dist/invoicing/snapshot.d.ts +1 -1
- 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/dist/pricing/acquisitionQuoteBinding.d.ts +1 -1
- package/dist/pricing/catalogFactsSchemas.d.ts +1 -1
- package/dist/pricing/quotePromotionEvidence.d.ts +1 -1
- package/dist/pricing/quoteSchemas.d.ts +56 -56
- package/dist/promotions/adminPromotionCodesContracts.d.ts +30 -30
- package/dist/promotions/adminPromotionsContracts.d.ts +14 -14
- package/package.json +32 -2
- package/release-gates.json +99 -4
- package/sql/20261026120000_account_support_operator_authority.sql +693 -0
- package/src/account-support/accountReadFacade.ts +15 -0
- package/src/account-support/accountReadModels.ts +371 -0
- package/src/account-support/bindings.ts +28 -0
- package/src/account-support/contracts/account.ts +306 -0
- package/src/account-support/contracts/capabilities.ts +30 -0
- package/src/account-support/contracts/commands.ts +243 -0
- package/src/account-support/contracts/customer360.ts +150 -0
- package/src/account-support/contracts/index.ts +141 -0
- package/src/account-support/contracts/invoice.ts +44 -0
- package/src/account-support/contracts/operator.ts +123 -0
- package/src/account-support/contribution.ts +35 -0
- package/src/account-support/customer360.ts +268 -0
- package/src/account-support/customerAccountReadDiagnostics.ts +83 -0
- package/src/account-support/index.ts +72 -0
- package/src/account-support/invoiceAccess.ts +63 -0
- package/src/account-support/migrations.ts +7 -0
- package/src/account-support/operatorAuthority.ts +393 -0
- package/src/account-support/operatorRecovery.ts +136 -0
- package/src/account-support/orderHistory.ts +309 -0
- package/src/account-support/paymentMethodComposition.ts +8 -0
- package/src/account-support/postgresOperatorAuthority.ts +92 -0
- package/src/account-support/selfService.ts +83 -0
- package/src/account-support/subscriptionCommandCodec.ts +48 -0
- package/src/composition/accountSupportContribution.ts +28 -0
- package/src/composition/index.ts +2 -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,55 @@
|
|
|
1
|
+
import { z } from "./validation.js";
|
|
2
|
+
export const ACQUISITION_SURVEY_VERSION = "acquisition_survey_v1";
|
|
3
|
+
export const ACQUISITION_NEWSLETTER_VERSION = "acquisition_newsletter_consent_v1";
|
|
4
|
+
const caseReference = z.string().regex(/^acquisition-case:[0-9a-f-]{36}$/);
|
|
5
|
+
const contactReference = z.string().regex(/^acquisition-contact:[0-9a-f-]{36}$/);
|
|
6
|
+
const commandKey = z.string().min(8).max(200).regex(/^[A-Za-z0-9][A-Za-z0-9._:-]+$/);
|
|
7
|
+
const digest = z.string().regex(/^[0-9a-f]{64}$/);
|
|
8
|
+
export const acquisitionSurveySubmitSchema = z.object({
|
|
9
|
+
view: z.literal(ACQUISITION_SURVEY_VERSION),
|
|
10
|
+
caseReference,
|
|
11
|
+
surveyType: z.enum(["producer", "consumer"]),
|
|
12
|
+
responseData: z.record(z.string(), z.unknown()),
|
|
13
|
+
});
|
|
14
|
+
export const acquisitionSurveyEvidenceSchema = z.object({
|
|
15
|
+
evidenceReference: z.string().regex(/^acquisition-survey:[0-9a-f-]{36}$/),
|
|
16
|
+
caseReference,
|
|
17
|
+
contactReference,
|
|
18
|
+
surveyType: z.enum(["producer", "consumer"]),
|
|
19
|
+
responseDigest: digest,
|
|
20
|
+
answerCount: z.number().int().min(1).max(100),
|
|
21
|
+
recordedAt: z.string().datetime({ offset: true }),
|
|
22
|
+
});
|
|
23
|
+
export const acquisitionSurveySubmitResponseSchema = z.object({
|
|
24
|
+
contractVersion: z.literal(ACQUISITION_SURVEY_VERSION),
|
|
25
|
+
evidence: acquisitionSurveyEvidenceSchema,
|
|
26
|
+
replayed: z.boolean(),
|
|
27
|
+
});
|
|
28
|
+
export const acquisitionSurveyListQuerySchema = z.object({
|
|
29
|
+
view: z.literal(ACQUISITION_SURVEY_VERSION),
|
|
30
|
+
surveyType: z.enum(["producer", "consumer"]).optional(),
|
|
31
|
+
limit: z.coerce.number().int().min(1).max(100).default(50),
|
|
32
|
+
});
|
|
33
|
+
export const acquisitionSurveyListResponseSchema = z.object({
|
|
34
|
+
contractVersion: z.literal(ACQUISITION_SURVEY_VERSION),
|
|
35
|
+
rows: z.array(acquisitionSurveyEvidenceSchema),
|
|
36
|
+
totalCount: z.number().int().min(0),
|
|
37
|
+
});
|
|
38
|
+
export const acquisitionNewsletterConsentEventSchema = z.object({
|
|
39
|
+
contractVersion: z.literal(ACQUISITION_NEWSLETTER_VERSION),
|
|
40
|
+
caseReference,
|
|
41
|
+
contactReference,
|
|
42
|
+
eventReference: commandKey,
|
|
43
|
+
eventType: z.enum(["subscribe", "unsubscribe", "suppress", "complaint", "update"]),
|
|
44
|
+
purpose: z.enum(["marketing_launch_offer", "marketing_newsletter"]),
|
|
45
|
+
explicitOptInEvidence: z.boolean().default(false),
|
|
46
|
+
occurredAt: z.string().datetime({ offset: true }),
|
|
47
|
+
}).strict();
|
|
48
|
+
export const acquisitionNewsletterConsentResponseSchema = z.object({
|
|
49
|
+
contractVersion: z.literal(ACQUISITION_NEWSLETTER_VERSION),
|
|
50
|
+
eventReference: commandKey,
|
|
51
|
+
outcome: z.enum(["applied", "ignored", "stale"]),
|
|
52
|
+
consentState: z.enum(["granted", "suppressed"]).nullable(),
|
|
53
|
+
auditReference: z.string().regex(/^acquisition-consent:[0-9a-f-]{36}$/),
|
|
54
|
+
replayed: z.boolean(),
|
|
55
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AnalyticsSinkAttemptMask, AnalyticsSinkAdmission, AnalyticsCookieConsent, AnalyticsDataLayerOptions } from "../contracts/analytics.js";
|
|
2
|
+
export type { AnalyticsSinkAttemptMask, AnalyticsSinkAdmission, AnalyticsCookieConsent, AnalyticsBrowserWindow, AnalyticsDataLayerOptions } from "../contracts/analytics.js";
|
|
3
|
+
import type { AnalyticsEventMap, AnalyticsEventName } from "./noop.js";
|
|
4
|
+
/** Each instance owns loader state; the host supplies browser and deployment policy. */
|
|
5
|
+
export declare function createAnalyticsDataLayer<StepName extends string = string>(options?: AnalyticsDataLayerOptions<StepName>): {
|
|
6
|
+
readCookieConsent: () => AnalyticsCookieConsent | null;
|
|
7
|
+
hasAnalyticsConsent: (consent?: AnalyticsCookieConsent | null) => boolean;
|
|
8
|
+
configuredContainerId: () => string | null;
|
|
9
|
+
subscribeToAnalyticsConsent: (listener: () => void) => () => void;
|
|
10
|
+
isAnalyticsLoaderReady: () => boolean;
|
|
11
|
+
subscribeToAnalyticsLoaderReadiness: (listener: () => void) => () => void;
|
|
12
|
+
markAnalyticsLoaderReady: () => void;
|
|
13
|
+
resetAnalyticsLoaderReadiness: () => void;
|
|
14
|
+
pushAnalyticsConsentDefault: () => void;
|
|
15
|
+
pushAnalyticsConsentUpdate: (granted: boolean) => void;
|
|
16
|
+
pushAnalyticsEvent: <K extends AnalyticsEventName>(event: K, properties: AnalyticsEventMap<StepName>[K]) => boolean;
|
|
17
|
+
emitAnalyticsEvent: <K extends AnalyticsEventName>(event: K, properties: AnalyticsEventMap<StepName>[K], attempts?: AnalyticsSinkAttemptMask) => AnalyticsSinkAdmission;
|
|
18
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { trackDeploymentEvent } from "./noop.js";
|
|
2
|
+
/** Each instance owns loader state; the host supplies browser and deployment policy. */
|
|
3
|
+
export function createAnalyticsDataLayer(options = {}) {
|
|
4
|
+
const { consentStorageKey = "", consentChangeEvent = "", consentSignalNames, eventPrefix = "", readContainerId = () => null, getWindow = () => undefined } = options;
|
|
5
|
+
const deploymentSink = options.trackDeploymentEvent ?? trackDeploymentEvent;
|
|
6
|
+
let analyticsLoaderReady = false;
|
|
7
|
+
const readinessListeners = new Set();
|
|
8
|
+
function readCookieConsent() {
|
|
9
|
+
const browser = getWindow();
|
|
10
|
+
if (!browser)
|
|
11
|
+
return null;
|
|
12
|
+
try {
|
|
13
|
+
const parsed = JSON.parse(browser.localStorage.getItem(consentStorageKey) ?? "");
|
|
14
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
|
|
15
|
+
return null;
|
|
16
|
+
const value = parsed;
|
|
17
|
+
if (typeof value.necessary !== "boolean" || typeof value.functional !== "boolean"
|
|
18
|
+
|| typeof value.analytics !== "boolean" || typeof value.marketing !== "boolean")
|
|
19
|
+
return null;
|
|
20
|
+
return { necessary: value.necessary, functional: value.functional,
|
|
21
|
+
analytics: value.analytics, marketing: value.marketing };
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function hasAnalyticsConsent(consent = readCookieConsent()) { return consent?.analytics === true; }
|
|
28
|
+
function configuredContainerId() { return readContainerId(); }
|
|
29
|
+
function subscribeToAnalyticsConsent(listener) {
|
|
30
|
+
const browser = getWindow();
|
|
31
|
+
if (!browser)
|
|
32
|
+
return () => undefined;
|
|
33
|
+
const onStorage = (event) => { if (event.key === consentStorageKey)
|
|
34
|
+
listener(); };
|
|
35
|
+
browser.addEventListener("storage", onStorage);
|
|
36
|
+
browser.addEventListener(consentChangeEvent, listener);
|
|
37
|
+
return () => {
|
|
38
|
+
browser.removeEventListener("storage", onStorage);
|
|
39
|
+
browser.removeEventListener(consentChangeEvent, listener);
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function isAnalyticsLoaderReady() { return analyticsLoaderReady; }
|
|
43
|
+
function subscribeToAnalyticsLoaderReadiness(listener) {
|
|
44
|
+
readinessListeners.add(listener);
|
|
45
|
+
return () => readinessListeners.delete(listener);
|
|
46
|
+
}
|
|
47
|
+
function markAnalyticsLoaderReady() {
|
|
48
|
+
if (analyticsLoaderReady)
|
|
49
|
+
return;
|
|
50
|
+
analyticsLoaderReady = true;
|
|
51
|
+
for (const listener of readinessListeners)
|
|
52
|
+
listener();
|
|
53
|
+
}
|
|
54
|
+
function resetAnalyticsLoaderReadiness() { analyticsLoaderReady = false; }
|
|
55
|
+
function pushAnalyticsConsentDefault() {
|
|
56
|
+
pushConsentCommand("default", "denied", "denied");
|
|
57
|
+
}
|
|
58
|
+
function pushAnalyticsConsentUpdate(granted) {
|
|
59
|
+
const analyticsState = granted ? "granted" : "denied";
|
|
60
|
+
// Read the separate advertising grant at push time; revocation denies all signals.
|
|
61
|
+
const adState = granted && readCookieConsent()?.marketing === true ? "granted" : "denied";
|
|
62
|
+
pushConsentCommand("update", analyticsState, adState);
|
|
63
|
+
}
|
|
64
|
+
function pushAnalyticsEvent(event, properties) {
|
|
65
|
+
const browser = getWindow();
|
|
66
|
+
if (!consentSignalNames || !browser || !configuredContainerId() || !hasAnalyticsConsent())
|
|
67
|
+
return false;
|
|
68
|
+
if (!browser.dataLayer) {
|
|
69
|
+
browser.dataLayer = [];
|
|
70
|
+
pushAnalyticsConsentDefault();
|
|
71
|
+
pushAnalyticsConsentUpdate(true);
|
|
72
|
+
}
|
|
73
|
+
browser.dataLayer.push({ event: `${eventPrefix}${event}`, ...properties });
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
function emitAnalyticsEvent(event, properties, attempts = { deployment: true, optional: true }) {
|
|
77
|
+
let deployment = false;
|
|
78
|
+
let optional = false;
|
|
79
|
+
if (attempts.deployment) {
|
|
80
|
+
try {
|
|
81
|
+
deployment = deploymentSink(event, properties);
|
|
82
|
+
}
|
|
83
|
+
catch { /* Sink failure never gates the product. */ }
|
|
84
|
+
}
|
|
85
|
+
if (attempts.optional) {
|
|
86
|
+
try {
|
|
87
|
+
optional = pushAnalyticsEvent(event, properties);
|
|
88
|
+
}
|
|
89
|
+
catch { /* Independent best-effort admission. */ }
|
|
90
|
+
}
|
|
91
|
+
return { deployment, optional };
|
|
92
|
+
}
|
|
93
|
+
function pushConsentCommand(action, analyticsState, adState) {
|
|
94
|
+
const browser = getWindow();
|
|
95
|
+
if (!consentSignalNames || !browser?.dataLayer)
|
|
96
|
+
return;
|
|
97
|
+
const settings = { [consentSignalNames.analytics]: analyticsState };
|
|
98
|
+
for (const name of consentSignalNames.advertising)
|
|
99
|
+
settings[name] = adState;
|
|
100
|
+
function consentCommand(..._args) {
|
|
101
|
+
// Consent commands use the array-like arguments object, not an event object.
|
|
102
|
+
// eslint-disable-next-line prefer-rest-params
|
|
103
|
+
browser?.dataLayer?.push(arguments);
|
|
104
|
+
}
|
|
105
|
+
consentCommand("consent", action, settings);
|
|
106
|
+
}
|
|
107
|
+
return { readCookieConsent, hasAnalyticsConsent, configuredContainerId, subscribeToAnalyticsConsent,
|
|
108
|
+
isAnalyticsLoaderReady, subscribeToAnalyticsLoaderReadiness, markAnalyticsLoaderReady,
|
|
109
|
+
resetAnalyticsLoaderReadiness, pushAnalyticsConsentDefault, pushAnalyticsConsentUpdate,
|
|
110
|
+
pushAnalyticsEvent, emitAnalyticsEvent };
|
|
111
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AnalyticsEventMap, AnalyticsEventName } from "../contracts/analytics.js";
|
|
2
|
+
export type { AnalyticsStepName, AnalyticsCheckoutItem, AnalyticsPurchaseItem, AnalyticsCheckoutMode, AnalyticsPaymentWaitOutcome, AnalyticsEventMap, AnalyticsEventName } from "../contracts/analytics.js";
|
|
3
|
+
import type { AnalyticsPort } from "@openlup/core/platform-runtime";
|
|
4
|
+
export declare function initializeDeploymentAnalytics(): void;
|
|
5
|
+
export declare function trackDeploymentEvent<K extends AnalyticsEventName>(_event: K, _properties: AnalyticsEventMap[K]): boolean;
|
|
6
|
+
export declare function syncAdvertisingConsent(): void;
|
|
7
|
+
export declare function trackAdvertisingPurchase(_payload: AnalyticsEventMap["purchase"]): boolean;
|
|
8
|
+
/** Inert composition satisfies the existing platform runtime port. */
|
|
9
|
+
export declare function createNoopAnalytics(): AnalyticsPort;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export function initializeDeploymentAnalytics() { }
|
|
2
|
+
export function trackDeploymentEvent(_event, _properties) { return false; }
|
|
3
|
+
export function syncAdvertisingConsent() { }
|
|
4
|
+
export function trackAdvertisingPurchase(_payload) { return false; }
|
|
5
|
+
/** Inert composition satisfies the existing platform runtime port. */
|
|
6
|
+
export function createNoopAnalytics() {
|
|
7
|
+
return { trackPageView() { }, trackEvent() { } };
|
|
8
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { PurchaseOrder, PurchaseSuppressionReason } from "../contracts/analytics.js";
|
|
2
|
+
export type { PurchaseOrder, PurchaseSuppressionReason } from "../contracts/analytics.js";
|
|
3
|
+
import type { AnalyticsEventMap } from "./noop.js";
|
|
4
|
+
export declare function projectPaidPurchase(recap: PurchaseOrder, suppressPurchase?: (reason: PurchaseSuppressionReason) => null): AnalyticsEventMap["purchase"] | null;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
const MAX_ITEMS = 200;
|
|
2
|
+
export function projectPaidPurchase(recap, suppressPurchase = () => null) {
|
|
3
|
+
if (recap.status !== "paid")
|
|
4
|
+
return suppressPurchase("order_not_paid");
|
|
5
|
+
if (recap.paymentStatus !== "succeeded")
|
|
6
|
+
return suppressPurchase("payment_not_succeeded");
|
|
7
|
+
if (recap.checkoutKind !== "one_time" && recap.checkoutKind !== "subscription_initial"
|
|
8
|
+
&& recap.checkoutKind !== "subscription_renewal")
|
|
9
|
+
return suppressPurchase("checkout_kind_unsupported");
|
|
10
|
+
if (!recap.moneyReconciled)
|
|
11
|
+
return suppressPurchase("money_unreconciled");
|
|
12
|
+
if (recap.items.length === 0)
|
|
13
|
+
return suppressPurchase("items_empty");
|
|
14
|
+
let effectiveNet = 0;
|
|
15
|
+
const items = [];
|
|
16
|
+
for (const item of recap.items) {
|
|
17
|
+
if (!item.sku)
|
|
18
|
+
return suppressPurchase("sku_missing");
|
|
19
|
+
if (!Number.isSafeInteger(item.quantity) || item.quantity <= 0)
|
|
20
|
+
return suppressPurchase("quantity_invalid");
|
|
21
|
+
if (item.quantity > MAX_ITEMS)
|
|
22
|
+
return suppressPurchase("item_limit_exceeded");
|
|
23
|
+
if (!isNonNegativeSafeInteger(item.catalogTotalGross) || !isNonNegativeSafeInteger(item.effectiveNet)
|
|
24
|
+
|| !isNonNegativeSafeInteger(item.vatRateBps) || item.vatRateBps > 10_000)
|
|
25
|
+
return suppressPurchase("line_money_invalid");
|
|
26
|
+
const catalogNet = netFromGross(item.catalogTotalGross, item.vatRateBps);
|
|
27
|
+
const netDiscount = catalogNet - item.effectiveNet;
|
|
28
|
+
if (netDiscount < 0)
|
|
29
|
+
return suppressPurchase("net_discount_invalid");
|
|
30
|
+
const projected = allocateLineItems({ sku: item.sku, variantCode: item.variantCode,
|
|
31
|
+
quantity: item.quantity, effectiveNet: item.effectiveNet, netDiscount });
|
|
32
|
+
if (items.length + projected.length > MAX_ITEMS)
|
|
33
|
+
return suppressPurchase("item_limit_exceeded");
|
|
34
|
+
items.push(...projected);
|
|
35
|
+
effectiveNet += item.effectiveNet;
|
|
36
|
+
}
|
|
37
|
+
const tax = recap.totals.tax.amountMinor;
|
|
38
|
+
const total = recap.totals.total.amountMinor;
|
|
39
|
+
const effectiveShippingNet = total - tax - effectiveNet;
|
|
40
|
+
if (!isNonNegativeSafeInteger(effectiveShippingNet))
|
|
41
|
+
return suppressPurchase("shipping_net_invalid");
|
|
42
|
+
return { transaction_id: recap.orderId, currency: recap.totals.total.currency, value: effectiveNet / 100,
|
|
43
|
+
shipping: effectiveShippingNet / 100, tax: tax / 100,
|
|
44
|
+
checkout_mode: recap.checkoutKind === "one_time" ? "one_time" : "subscription", items };
|
|
45
|
+
}
|
|
46
|
+
function allocateLineItems(input) {
|
|
47
|
+
const priceBase = Math.floor(input.effectiveNet / input.quantity);
|
|
48
|
+
const priceRemainder = input.effectiveNet % input.quantity;
|
|
49
|
+
const discountBase = Math.floor(input.netDiscount / input.quantity);
|
|
50
|
+
const discountRemainder = input.netDiscount % input.quantity;
|
|
51
|
+
const grouped = new Map();
|
|
52
|
+
for (let position = 0; position < input.quantity; position += 1) {
|
|
53
|
+
const priceMinor = priceBase + (position < priceRemainder ? 1 : 0);
|
|
54
|
+
const discountMinor = discountBase + (position < discountRemainder ? 1 : 0);
|
|
55
|
+
const key = `${priceMinor}:${discountMinor}`;
|
|
56
|
+
const current = grouped.get(key);
|
|
57
|
+
if (current)
|
|
58
|
+
current.quantity += 1;
|
|
59
|
+
else
|
|
60
|
+
grouped.set(key, { priceMinor, discountMinor, quantity: 1 });
|
|
61
|
+
}
|
|
62
|
+
return [...grouped.values()].map(group => ({ item_id: input.sku,
|
|
63
|
+
...(input.variantCode ? { item_variant: input.variantCode } : {}), price: group.priceMinor / 100,
|
|
64
|
+
discount: group.discountMinor / 100, quantity: group.quantity }));
|
|
65
|
+
}
|
|
66
|
+
function netFromGross(grossMinor, vatRateBps) {
|
|
67
|
+
return Math.round(grossMinor * 10_000 / (10_000 + vatRateBps));
|
|
68
|
+
}
|
|
69
|
+
function isNonNegativeSafeInteger(value) { return Number.isSafeInteger(value) && value >= 0; }
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AnalyticsRoutePolicyInput } from "../contracts/analytics.js";
|
|
2
|
+
export type { AnalyticsRoutePolicyInput } from "../contracts/analytics.js";
|
|
3
|
+
export declare function normalizeAnalyticsPathname(pathname: string): string;
|
|
4
|
+
/** Route manifests and sensitive paths are explicit host policy. */
|
|
5
|
+
export declare function createAnalyticsRoutePolicy(input: AnalyticsRoutePolicyInput): {
|
|
6
|
+
isSensitiveAnalyticsPath: (pathname: string) => boolean;
|
|
7
|
+
isOptionalAnalyticsRouteEligible: (pathname: string) => boolean;
|
|
8
|
+
isDeploymentAnalyticsRouteEligible: (pathname: string, additionalPublicPaths?: ReadonlySet<string>) => boolean;
|
|
9
|
+
sanitizeDeploymentAnalyticsUrl: (rawUrl: string, currentOrigin: string, additionalPublicPaths?: ReadonlySet<string>) => string | null;
|
|
10
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
const CAMPAIGN_KEYS = ["utm_source", "utm_medium", "utm_campaign", "utm_content", "utm_term"];
|
|
2
|
+
const CAMPAIGN_VALUE = /^[A-Za-z0-9_-]{1,100}$/;
|
|
3
|
+
const NO_ADDITIONAL_PATHS = new Set();
|
|
4
|
+
export function normalizeAnalyticsPathname(pathname) {
|
|
5
|
+
const withLeadingSlash = pathname.startsWith("/") ? pathname : `/${pathname}`;
|
|
6
|
+
const withoutTrailingSlash = withLeadingSlash.length > 1
|
|
7
|
+
? withLeadingSlash.replace(/\/+$/, "") : withLeadingSlash;
|
|
8
|
+
return withoutTrailingSlash.toLowerCase();
|
|
9
|
+
}
|
|
10
|
+
/** Route manifests and sensitive paths are explicit host policy. */
|
|
11
|
+
export function createAnalyticsRoutePolicy(input) {
|
|
12
|
+
const manifestPaths = new Set(input.publicPaths.map(normalizeAnalyticsPathname));
|
|
13
|
+
const redirectPaths = new Set(input.redirectSources.filter(source => !source.includes(":"))
|
|
14
|
+
.map(normalizeAnalyticsPathname));
|
|
15
|
+
function isSensitiveAnalyticsPath(pathname) {
|
|
16
|
+
const capabilityPath = pathname.toLowerCase();
|
|
17
|
+
return input.privatePathPrefixes.some(prefix => pathname === prefix || pathname.startsWith(`${prefix}/`))
|
|
18
|
+
|| input.privateAuthPaths.includes(pathname)
|
|
19
|
+
|| input.capabilityPathPrefixes.some(prefix => capabilityPath === prefix || capabilityPath.startsWith(`${prefix}/`));
|
|
20
|
+
}
|
|
21
|
+
function isOptionalAnalyticsRouteEligible(pathname) {
|
|
22
|
+
return !isSensitiveAnalyticsPath(pathname);
|
|
23
|
+
}
|
|
24
|
+
function isDeploymentAnalyticsRouteEligible(pathname, additionalPublicPaths = NO_ADDITIONAL_PATHS) {
|
|
25
|
+
const path = normalizeAnalyticsPathname(pathname);
|
|
26
|
+
if (isSensitiveAnalyticsPath(path))
|
|
27
|
+
return false;
|
|
28
|
+
return manifestPaths.has(path) || redirectPaths.has(path) || additionalPublicPaths.has(path);
|
|
29
|
+
}
|
|
30
|
+
function sanitizeDeploymentAnalyticsUrl(rawUrl, currentOrigin, additionalPublicPaths) {
|
|
31
|
+
let base;
|
|
32
|
+
let url;
|
|
33
|
+
try {
|
|
34
|
+
base = new URL(currentOrigin);
|
|
35
|
+
url = new URL(rawUrl, base);
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
if ((url.protocol !== "http:" && url.protocol !== "https:") || url.username || url.password
|
|
41
|
+
|| url.origin !== base.origin)
|
|
42
|
+
return null;
|
|
43
|
+
const pathname = normalizeAnalyticsPathname(url.pathname);
|
|
44
|
+
if (!isDeploymentAnalyticsRouteEligible(pathname, additionalPublicPaths))
|
|
45
|
+
return null;
|
|
46
|
+
const campaign = new URLSearchParams();
|
|
47
|
+
for (const key of CAMPAIGN_KEYS) {
|
|
48
|
+
const values = url.searchParams.getAll(key);
|
|
49
|
+
if (values.length === 1 && CAMPAIGN_VALUE.test(values[0]))
|
|
50
|
+
campaign.set(key, values[0]);
|
|
51
|
+
}
|
|
52
|
+
url.pathname = pathname;
|
|
53
|
+
url.search = campaign.toString();
|
|
54
|
+
url.hash = "";
|
|
55
|
+
return url.href;
|
|
56
|
+
}
|
|
57
|
+
return { isSensitiveAnalyticsPath, isOptionalAnalyticsRouteEligible,
|
|
58
|
+
isDeploymentAnalyticsRouteEligible, sanitizeDeploymentAnalyticsUrl };
|
|
59
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { MarketingHistoricalConsentCommand, MarketingHistoricalConsentState, MarketingHistoricalConsentResult } from "./contracts/analytics.js";
|
|
2
|
+
export type { MarketingHistoricalConsentCommand, MarketingHistoricalConsentState, MarketingHistoricalConsentResult } from "./contracts/analytics.js";
|
|
3
|
+
/** Transport chronology after authorization; never changes the local consent grant. */
|
|
4
|
+
export declare function selectMarketingHistoricalConsentTime(input: {
|
|
5
|
+
command: MarketingHistoricalConsentCommand;
|
|
6
|
+
state: MarketingHistoricalConsentState;
|
|
7
|
+
now: Date;
|
|
8
|
+
}): MarketingHistoricalConsentResult;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { z } from "./validation.js";
|
|
2
|
+
const historicalTimestamp = z.string().max(80).datetime({ offset: true });
|
|
3
|
+
const HISTORICAL_MIN_AGE_MS = 5 * 60 * 1000;
|
|
4
|
+
/** Transport chronology after authorization; never changes the local consent grant. */
|
|
5
|
+
export function selectMarketingHistoricalConsentTime(input) {
|
|
6
|
+
const { command, state, now } = input;
|
|
7
|
+
if (!Number.isFinite(now.getTime()))
|
|
8
|
+
return { kind: "hold", reason: "consent_time_invalid" };
|
|
9
|
+
let selected = command.consentedAt;
|
|
10
|
+
if (state.consent === "SUBSCRIBED") {
|
|
11
|
+
const native = historicalTimestamp.safeParse(state.nativeConsentAt);
|
|
12
|
+
if (!native.success || !Number.isFinite(Date.parse(native.data)) || Date.parse(native.data) >= now.getTime()) {
|
|
13
|
+
return { kind: "hold", reason: "provider_state_unknown" };
|
|
14
|
+
}
|
|
15
|
+
const overriding = state.suppressions.some(item => item.reason === "UNSUBSCRIBE"
|
|
16
|
+
&& (item.listId === null || item.listId === command.listId));
|
|
17
|
+
if (!overriding)
|
|
18
|
+
selected = native.data;
|
|
19
|
+
else if (Date.parse(command.consentedAt ?? "") > Date.parse(native.data)) {
|
|
20
|
+
return { kind: "hold", reason: "provider_state_unknown" };
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const parsed = historicalTimestamp.safeParse(selected);
|
|
24
|
+
if (!parsed.success || !Number.isFinite(Date.parse(parsed.data)) || Date.parse(parsed.data) >= now.getTime()) {
|
|
25
|
+
return { kind: "hold", reason: "consent_time_invalid" };
|
|
26
|
+
}
|
|
27
|
+
// Parsing truncates fractional milliseconds; round only the age boundary up.
|
|
28
|
+
const discarded = /\.\d{3}(\d+)(?:Z|[+-]\d{2}:\d{2})$/.exec(parsed.data)?.[1];
|
|
29
|
+
const matureAt = Date.parse(parsed.data) + (discarded && /[1-9]/.test(discarded) ? 1 : 0) + HISTORICAL_MIN_AGE_MS;
|
|
30
|
+
return now.getTime() < matureAt ? { kind: "defer", retryAt: new Date(matureAt).toISOString() }
|
|
31
|
+
: { kind: "ready", providerConsentedAt: parsed.data };
|
|
32
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ContactContent, LegalDocumentContent } from "./contracts/contactLegal.js";
|
|
2
|
+
export declare function contactContent(facts: ContactContent): {
|
|
3
|
+
supportEmail: string;
|
|
4
|
+
companyLines: string[];
|
|
5
|
+
};
|
|
6
|
+
export declare function legalDocumentContent(content: LegalDocumentContent): {
|
|
7
|
+
lastUpdated?: string | undefined;
|
|
8
|
+
title: string;
|
|
9
|
+
intro: string;
|
|
10
|
+
sections: {
|
|
11
|
+
title: string;
|
|
12
|
+
body: string;
|
|
13
|
+
}[];
|
|
14
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export function contactContent(facts) {
|
|
2
|
+
return {
|
|
3
|
+
supportEmail: facts.supportEmail,
|
|
4
|
+
companyLines: [
|
|
5
|
+
facts.organization.legalName,
|
|
6
|
+
facts.addressLine,
|
|
7
|
+
facts.registrationIdentifiers.map(({ label, value }) => `${label} ${value}`).join(" · "),
|
|
8
|
+
...(facts.registrationAuthority !== undefined ? [facts.registrationAuthority] : []),
|
|
9
|
+
],
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export function legalDocumentContent(content) {
|
|
13
|
+
return {
|
|
14
|
+
title: content.title,
|
|
15
|
+
intro: content.intro,
|
|
16
|
+
sections: content.sections.map(({ title, body }) => ({ title, body })),
|
|
17
|
+
...(content.lastUpdated !== undefined ? { lastUpdated: content.lastUpdated } : {}),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
export type AcquisitionOpaqueReference = string;
|
|
2
|
+
export type AcquisitionAddressReference = {
|
|
3
|
+
source: string;
|
|
4
|
+
reference: string;
|
|
5
|
+
revision: string;
|
|
6
|
+
provenance: string;
|
|
7
|
+
};
|
|
8
|
+
export type AcquisitionCaseState = "submitted" | "approved" | "active" | "rejected" | "withdrawn";
|
|
9
|
+
export type AcquisitionCaseProjection = {
|
|
10
|
+
contractVersion: "tester_application_v1";
|
|
11
|
+
caseRef: string;
|
|
12
|
+
contactRef: string;
|
|
13
|
+
sourceKind: "tester_application";
|
|
14
|
+
consent: {
|
|
15
|
+
consentVersion: string;
|
|
16
|
+
policyVersion: string;
|
|
17
|
+
recordedAt: string;
|
|
18
|
+
locale: "en" | "pl";
|
|
19
|
+
sourcePath: "/tester-application";
|
|
20
|
+
};
|
|
21
|
+
addressReference: AcquisitionAddressReference | null;
|
|
22
|
+
state: AcquisitionCaseState;
|
|
23
|
+
version: number;
|
|
24
|
+
createdAt: string;
|
|
25
|
+
updatedAt: string;
|
|
26
|
+
};
|
|
27
|
+
export type AcquisitionCaseListRequest = {
|
|
28
|
+
view: "acquisition_case_v1";
|
|
29
|
+
cursor?: string | undefined;
|
|
30
|
+
limit: number;
|
|
31
|
+
};
|
|
32
|
+
export type AcquisitionCaseListResponse = {
|
|
33
|
+
contractVersion: "tester_application_v1";
|
|
34
|
+
cases: AcquisitionCaseProjection[];
|
|
35
|
+
nextCursor: string | null;
|
|
36
|
+
};
|
|
37
|
+
export type AcquisitionCaseActiveCountResponse = {
|
|
38
|
+
activeTesterCount: number;
|
|
39
|
+
};
|
|
40
|
+
export type AcquisitionIdempotencyKey = string;
|
|
41
|
+
export type AcquisitionSurveySubmit = {
|
|
42
|
+
view: "acquisition_survey_v1";
|
|
43
|
+
caseReference: string;
|
|
44
|
+
surveyType: "producer" | "consumer";
|
|
45
|
+
responseData: Record<string, unknown>;
|
|
46
|
+
};
|
|
47
|
+
export type AcquisitionSurveyEvidence = {
|
|
48
|
+
evidenceReference: string;
|
|
49
|
+
caseReference: string;
|
|
50
|
+
contactReference: string;
|
|
51
|
+
surveyType: "producer" | "consumer";
|
|
52
|
+
responseDigest: string;
|
|
53
|
+
answerCount: number;
|
|
54
|
+
recordedAt: string;
|
|
55
|
+
};
|
|
56
|
+
export type AcquisitionSurveySubmitResponse = {
|
|
57
|
+
contractVersion: "acquisition_survey_v1";
|
|
58
|
+
evidence: AcquisitionSurveyEvidence;
|
|
59
|
+
replayed: boolean;
|
|
60
|
+
};
|
|
61
|
+
export type AcquisitionSurveyListQuery = {
|
|
62
|
+
view: "acquisition_survey_v1";
|
|
63
|
+
surveyType?: "producer" | "consumer" | undefined;
|
|
64
|
+
limit: number;
|
|
65
|
+
};
|
|
66
|
+
export type AcquisitionSurveyListResponse = {
|
|
67
|
+
contractVersion: "acquisition_survey_v1";
|
|
68
|
+
rows: AcquisitionSurveyEvidence[];
|
|
69
|
+
totalCount: number;
|
|
70
|
+
};
|
|
71
|
+
export type AcquisitionNewsletterConsentEvent = {
|
|
72
|
+
contractVersion: "acquisition_newsletter_consent_v1";
|
|
73
|
+
caseReference: string;
|
|
74
|
+
contactReference: string;
|
|
75
|
+
eventReference: string;
|
|
76
|
+
eventType: "subscribe" | "unsubscribe" | "suppress" | "complaint" | "update";
|
|
77
|
+
purpose: "marketing_launch_offer" | "marketing_newsletter";
|
|
78
|
+
explicitOptInEvidence: boolean;
|
|
79
|
+
occurredAt: string;
|
|
80
|
+
};
|
|
81
|
+
export type AcquisitionNewsletterConsentResponse = {
|
|
82
|
+
contractVersion: "acquisition_newsletter_consent_v1";
|
|
83
|
+
eventReference: string;
|
|
84
|
+
outcome: "applied" | "ignored" | "stale";
|
|
85
|
+
consentState: "granted" | "suppressed" | null;
|
|
86
|
+
auditReference: string;
|
|
87
|
+
replayed: boolean;
|
|
88
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { AcquisitionCaseListResponse, AcquisitionCaseProjection, AcquisitionNewsletterConsentEvent, AcquisitionNewsletterConsentResponse, AcquisitionSurveyListQuery, AcquisitionSurveyListResponse, AcquisitionSurveySubmit, AcquisitionSurveySubmitResponse } from "./acquisition.js";
|
|
2
|
+
export type AcquisitionCaseFailureKind = "conflict" | "invalid" | "not_found" | "rate_limited" | "unavailable";
|
|
3
|
+
export type AcquisitionCaseResult<T> = {
|
|
4
|
+
ok: true;
|
|
5
|
+
value: T;
|
|
6
|
+
replayed?: boolean;
|
|
7
|
+
} | {
|
|
8
|
+
ok: false;
|
|
9
|
+
error: {
|
|
10
|
+
kind: AcquisitionCaseFailureKind;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export interface AcquisitionCaseListQuery {
|
|
14
|
+
actorRef: string;
|
|
15
|
+
scope: "public_tester_application";
|
|
16
|
+
cursor?: string;
|
|
17
|
+
limit: number;
|
|
18
|
+
}
|
|
19
|
+
export interface AcquisitionCaseGetQuery {
|
|
20
|
+
actorRef: string;
|
|
21
|
+
scope: "public_tester_application";
|
|
22
|
+
caseRef: string;
|
|
23
|
+
}
|
|
24
|
+
export interface AcquisitionCasePort {
|
|
25
|
+
list(query: AcquisitionCaseListQuery): Promise<AcquisitionCaseResult<AcquisitionCaseListResponse>>;
|
|
26
|
+
get(query: AcquisitionCaseGetQuery): Promise<AcquisitionCaseResult<AcquisitionCaseProjection>>;
|
|
27
|
+
activeCount(scope: "public_tester_application"): Promise<AcquisitionCaseResult<number>>;
|
|
28
|
+
close(): Promise<void>;
|
|
29
|
+
}
|
|
30
|
+
export type AcquisitionEvidenceFailure = "invalid" | "not_found" | "conflict" | "unavailable";
|
|
31
|
+
export type AcquisitionEvidenceResult<T> = {
|
|
32
|
+
ok: true;
|
|
33
|
+
value: T;
|
|
34
|
+
} | {
|
|
35
|
+
ok: false;
|
|
36
|
+
error: {
|
|
37
|
+
kind: AcquisitionEvidenceFailure;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
export interface AcquisitionEvidencePort {
|
|
41
|
+
submitSurvey(input: AcquisitionSurveySubmit & {
|
|
42
|
+
idempotencyKey: string;
|
|
43
|
+
}): Promise<AcquisitionEvidenceResult<AcquisitionSurveySubmitResponse>>;
|
|
44
|
+
listSurveys(input: AcquisitionSurveyListQuery & {
|
|
45
|
+
actorReference: string;
|
|
46
|
+
}): Promise<AcquisitionEvidenceResult<AcquisitionSurveyListResponse>>;
|
|
47
|
+
applyNewsletterConsent(input: AcquisitionNewsletterConsentEvent): Promise<AcquisitionEvidenceResult<AcquisitionNewsletterConsentResponse>>;
|
|
48
|
+
close(): Promise<void>;
|
|
49
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|