@openlup/platform 0.28.0 → 0.30.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 +369 -156
- package/README.md +220 -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/composition/nodeHost.d.ts +1 -1
- package/dist/composition/nodeHost.js +3 -2
- package/dist/lifecycle/appUpgrade.d.ts +52 -0
- package/dist/lifecycle/appUpgrade.js +180 -0
- package/dist/lifecycle/index.d.ts +2 -0
- package/dist/lifecycle/index.js +2 -0
- package/dist/lifecycle/postgresInstallQualification.d.ts +51 -0
- package/dist/lifecycle/postgresInstallQualification.js +74 -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/dist/migrations/postgresRunner.d.ts +9 -0
- package/dist/migrations/postgresRunner.js +17 -10
- package/dist/operations/adminAlertsSchemas.d.ts +153 -0
- package/dist/operations/adminAlertsSchemas.js +69 -0
- package/dist/operations/adminAlertsView.d.ts +73 -0
- package/dist/operations/adminAlertsView.js +184 -0
- package/dist/operations/alertPagingPolicy.d.ts +15 -0
- package/dist/operations/alertPagingPolicy.js +43 -0
- package/dist/operations/alertThrottlePolicy.d.ts +3 -0
- package/dist/operations/alertThrottlePolicy.js +18 -0
- package/dist/operations/clients.d.ts +17 -0
- package/dist/operations/clients.js +32 -0
- package/dist/operations/contracts/admin.d.ts +93 -0
- package/dist/operations/contracts/admin.js +1 -0
- package/dist/operations/contracts/adminAlertsContracts.d.ts +40 -0
- package/dist/operations/contracts/adminAlertsContracts.js +1 -0
- package/dist/operations/contracts/alertHumanContext.d.ts +7 -0
- package/dist/operations/contracts/alertHumanContext.js +1 -0
- package/dist/operations/contracts/index.d.ts +6 -0
- package/dist/operations/contracts/index.js +6 -0
- package/dist/operations/contracts/observabilityContracts.d.ts +41 -0
- package/dist/operations/contracts/observabilityContracts.js +1 -0
- package/dist/operations/contracts/observabilityPorts.d.ts +18 -0
- package/dist/operations/contracts/observabilityPorts.js +1 -0
- package/dist/operations/contracts/ports.d.ts +19 -0
- package/dist/operations/contracts/ports.js +1 -0
- package/dist/operations/errors.d.ts +6 -0
- package/dist/operations/errors.js +6 -0
- package/dist/operations/index.d.ts +9 -0
- package/dist/operations/index.js +9 -0
- package/dist/operations/schemas.d.ts +138 -0
- package/dist/operations/schemas.js +104 -0
- package/dist/operations/server/adminAlertsHandlers.d.ts +16 -0
- package/dist/operations/server/adminAlertsHandlers.js +35 -0
- package/dist/operations/server/adminPipelineHandlers.d.ts +12 -0
- package/dist/operations/server/adminPipelineHandlers.js +48 -0
- package/dist/operations/server/adminSettingsHandlers.d.ts +14 -0
- package/dist/operations/server/adminSettingsHandlers.js +82 -0
- package/dist/operations/server/controlPlaneHandler.d.ts +7 -0
- package/dist/operations/server/controlPlaneHandler.js +54 -0
- package/dist/operations/server/controlPlaneStore.d.ts +12 -0
- package/dist/operations/server/controlPlaneStore.js +138 -0
- package/dist/operations/server/controlPlaneWatchdog.d.ts +7 -0
- package/dist/operations/server/controlPlaneWatchdog.js +20 -0
- package/dist/operations/server/index.d.ts +12 -0
- package/dist/operations/server/index.js +12 -0
- package/dist/operations/server/migrations.d.ts +14 -0
- package/dist/operations/server/migrations.js +7 -0
- package/dist/operations/server/platformWatchdogDecision.d.ts +34 -0
- package/dist/operations/server/platformWatchdogDecision.js +71 -0
- package/dist/operations/server/platformWatchdogDeliveryPolicy.d.ts +10 -0
- package/dist/operations/server/platformWatchdogDeliveryPolicy.js +53 -0
- package/dist/operations/server/platformWatchdogQueue.d.ts +11 -0
- package/dist/operations/server/platformWatchdogQueue.js +94 -0
- package/dist/operations/server/platformWatchdogService.d.ts +47 -0
- package/dist/operations/server/platformWatchdogService.js +105 -0
- package/dist/operations/validation.d.ts +2 -0
- package/dist/operations/validation.js +3 -0
- package/dist/portability/filesystemObjects.d.ts +12 -0
- package/dist/portability/filesystemObjects.js +191 -0
- package/dist/portability/index.d.ts +5 -0
- package/dist/portability/index.js +4 -0
- package/dist/portability/objects.d.ts +63 -0
- package/dist/portability/objects.js +138 -0
- package/dist/portability/postgresRows.d.ts +64 -0
- package/dist/portability/postgresRows.js +182 -0
- package/dist/scheduler/advisoryLock.js +20 -2
- package/dist/scheduler/nodeScheduler.d.ts +2 -2
- package/dist/scheduler/nodeScheduler.js +35 -6
- package/package.json +47 -2
- package/release-gates.json +143 -9
- package/sql/20260814010000_platform_control_plane.sql +286 -0
- package/src/composition/index.ts +1 -0
- package/src/composition/marketingContribution.ts +37 -0
- package/src/composition/nodeHost.ts +4 -3
- package/src/lifecycle/appUpgrade.ts +186 -0
- package/src/lifecycle/index.ts +19 -0
- package/src/lifecycle/postgresInstallQualification.ts +125 -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
- package/src/migrations/postgresRunner.ts +24 -9
- package/src/operations/adminAlertsSchemas.ts +78 -0
- package/src/operations/adminAlertsView.ts +238 -0
- package/src/operations/alertPagingPolicy.ts +50 -0
- package/src/operations/alertThrottlePolicy.ts +22 -0
- package/src/operations/clients.ts +44 -0
- package/src/operations/contracts/admin.ts +24 -0
- package/src/operations/contracts/adminAlertsContracts.ts +13 -0
- package/src/operations/contracts/alertHumanContext.ts +17 -0
- package/src/operations/contracts/index.ts +6 -0
- package/src/operations/contracts/observabilityContracts.ts +40 -0
- package/src/operations/contracts/observabilityPorts.ts +30 -0
- package/src/operations/contracts/ports.ts +22 -0
- package/src/operations/errors.ts +6 -0
- package/src/operations/index.ts +9 -0
- package/src/operations/schemas.ts +122 -0
- package/src/operations/server/adminAlertsHandlers.ts +61 -0
- package/src/operations/server/adminPipelineHandlers.ts +73 -0
- package/src/operations/server/adminSettingsHandlers.ts +114 -0
- package/src/operations/server/controlPlaneHandler.ts +56 -0
- package/src/operations/server/controlPlaneStore.ts +150 -0
- package/src/operations/server/controlPlaneWatchdog.ts +28 -0
- package/src/operations/server/index.ts +12 -0
- package/src/operations/server/migrations.ts +7 -0
- package/src/operations/server/platformWatchdogDecision.ts +93 -0
- package/src/operations/server/platformWatchdogDeliveryPolicy.ts +92 -0
- package/src/operations/server/platformWatchdogQueue.ts +96 -0
- package/src/operations/server/platformWatchdogService.ts +209 -0
- package/src/operations/validation.ts +3 -0
- package/src/portability/filesystemObjects.ts +138 -0
- package/src/portability/index.ts +12 -0
- package/src/portability/objects.ts +160 -0
- package/src/portability/postgresRows.ts +169 -0
- package/src/scheduler/advisoryLock.ts +20 -5
- package/src/scheduler/nodeScheduler.ts +28 -8
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { z } from "./validation.js";
|
|
2
|
+
export declare const PRELAUNCH_ACQUISITION_VIEW: "prelaunch_acquisition_v1";
|
|
3
|
+
export declare const PRELAUNCH_ACQUISITION_CONTRACT_VERSION: "prelaunch_acquisition_v1";
|
|
4
|
+
export declare const prelaunchAcquisitionListRequestSchema: z.ZodObject<{
|
|
5
|
+
view: z.ZodLiteral<"prelaunch_acquisition_v1">;
|
|
6
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
7
|
+
limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
8
|
+
}, z.core.$strict>;
|
|
9
|
+
export declare const prelaunchAcquisitionDetailRequestSchema: z.ZodObject<{
|
|
10
|
+
sourceRef: z.ZodString;
|
|
11
|
+
}, z.core.$strict>;
|
|
12
|
+
export declare const prelaunchAcquisitionLeadSchema: z.ZodObject<{
|
|
13
|
+
sourceRef: z.ZodString;
|
|
14
|
+
contactRef: z.ZodString;
|
|
15
|
+
sourceKind: z.ZodLiteral<"tester_application">;
|
|
16
|
+
consent: z.ZodObject<{
|
|
17
|
+
consentVersion: z.ZodString;
|
|
18
|
+
policyVersion: z.ZodString;
|
|
19
|
+
recordedAt: z.ZodString;
|
|
20
|
+
locale: z.ZodEnum<{
|
|
21
|
+
en: "en";
|
|
22
|
+
pl: "pl";
|
|
23
|
+
}>;
|
|
24
|
+
sourcePath: z.ZodLiteral<"/tester-application">;
|
|
25
|
+
}, z.core.$strict>;
|
|
26
|
+
addressReference: z.ZodNullable<z.ZodObject<{
|
|
27
|
+
source: z.ZodString;
|
|
28
|
+
reference: z.ZodString;
|
|
29
|
+
revision: z.ZodString;
|
|
30
|
+
provenance: z.ZodString;
|
|
31
|
+
}, z.core.$strict>>;
|
|
32
|
+
state: z.ZodEnum<{
|
|
33
|
+
rejected: "rejected";
|
|
34
|
+
active: "active";
|
|
35
|
+
submitted: "submitted";
|
|
36
|
+
withdrawn: "withdrawn";
|
|
37
|
+
approved: "approved";
|
|
38
|
+
}>;
|
|
39
|
+
version: z.ZodNumber;
|
|
40
|
+
createdAt: z.ZodString;
|
|
41
|
+
updatedAt: z.ZodString;
|
|
42
|
+
}, z.core.$strict>;
|
|
43
|
+
export declare const prelaunchAcquisitionListResponseSchema: z.ZodObject<{
|
|
44
|
+
contractVersion: z.ZodLiteral<"prelaunch_acquisition_v1">;
|
|
45
|
+
leads: z.ZodArray<z.ZodObject<{
|
|
46
|
+
sourceRef: z.ZodString;
|
|
47
|
+
contactRef: z.ZodString;
|
|
48
|
+
sourceKind: z.ZodLiteral<"tester_application">;
|
|
49
|
+
consent: z.ZodObject<{
|
|
50
|
+
consentVersion: z.ZodString;
|
|
51
|
+
policyVersion: z.ZodString;
|
|
52
|
+
recordedAt: z.ZodString;
|
|
53
|
+
locale: z.ZodEnum<{
|
|
54
|
+
en: "en";
|
|
55
|
+
pl: "pl";
|
|
56
|
+
}>;
|
|
57
|
+
sourcePath: z.ZodLiteral<"/tester-application">;
|
|
58
|
+
}, z.core.$strict>;
|
|
59
|
+
addressReference: z.ZodNullable<z.ZodObject<{
|
|
60
|
+
source: z.ZodString;
|
|
61
|
+
reference: z.ZodString;
|
|
62
|
+
revision: z.ZodString;
|
|
63
|
+
provenance: z.ZodString;
|
|
64
|
+
}, z.core.$strict>>;
|
|
65
|
+
state: z.ZodEnum<{
|
|
66
|
+
rejected: "rejected";
|
|
67
|
+
active: "active";
|
|
68
|
+
submitted: "submitted";
|
|
69
|
+
withdrawn: "withdrawn";
|
|
70
|
+
approved: "approved";
|
|
71
|
+
}>;
|
|
72
|
+
version: z.ZodNumber;
|
|
73
|
+
createdAt: z.ZodString;
|
|
74
|
+
updatedAt: z.ZodString;
|
|
75
|
+
}, z.core.$strict>>;
|
|
76
|
+
nextCursor: z.ZodNullable<z.ZodString>;
|
|
77
|
+
}, z.core.$strict>;
|
|
78
|
+
export declare const prelaunchAcquisitionDetailResponseSchema: z.ZodObject<{
|
|
79
|
+
contractVersion: z.ZodLiteral<"prelaunch_acquisition_v1">;
|
|
80
|
+
lead: z.ZodObject<{
|
|
81
|
+
sourceRef: z.ZodString;
|
|
82
|
+
contactRef: z.ZodString;
|
|
83
|
+
sourceKind: z.ZodLiteral<"tester_application">;
|
|
84
|
+
consent: z.ZodObject<{
|
|
85
|
+
consentVersion: z.ZodString;
|
|
86
|
+
policyVersion: z.ZodString;
|
|
87
|
+
recordedAt: z.ZodString;
|
|
88
|
+
locale: z.ZodEnum<{
|
|
89
|
+
en: "en";
|
|
90
|
+
pl: "pl";
|
|
91
|
+
}>;
|
|
92
|
+
sourcePath: z.ZodLiteral<"/tester-application">;
|
|
93
|
+
}, z.core.$strict>;
|
|
94
|
+
addressReference: z.ZodNullable<z.ZodObject<{
|
|
95
|
+
source: z.ZodString;
|
|
96
|
+
reference: z.ZodString;
|
|
97
|
+
revision: z.ZodString;
|
|
98
|
+
provenance: z.ZodString;
|
|
99
|
+
}, z.core.$strict>>;
|
|
100
|
+
state: z.ZodEnum<{
|
|
101
|
+
rejected: "rejected";
|
|
102
|
+
active: "active";
|
|
103
|
+
submitted: "submitted";
|
|
104
|
+
withdrawn: "withdrawn";
|
|
105
|
+
approved: "approved";
|
|
106
|
+
}>;
|
|
107
|
+
version: z.ZodNumber;
|
|
108
|
+
createdAt: z.ZodString;
|
|
109
|
+
updatedAt: z.ZodString;
|
|
110
|
+
}, z.core.$strict>;
|
|
111
|
+
}, z.core.$strict>;
|
|
112
|
+
export type PrelaunchAcquisitionListRequest = z.infer<typeof prelaunchAcquisitionListRequestSchema>;
|
|
113
|
+
export type PrelaunchAcquisitionDetailRequest = z.infer<typeof prelaunchAcquisitionDetailRequestSchema>;
|
|
114
|
+
export type PrelaunchAcquisitionLead = z.infer<typeof prelaunchAcquisitionLeadSchema>;
|
|
115
|
+
export type PrelaunchAcquisitionListResponse = z.infer<typeof prelaunchAcquisitionListResponseSchema>;
|
|
116
|
+
export type PrelaunchAcquisitionDetailResponse = z.infer<typeof prelaunchAcquisitionDetailResponseSchema>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { z } from "./validation.js";
|
|
2
|
+
export const PRELAUNCH_ACQUISITION_VIEW = "prelaunch_acquisition_v1";
|
|
3
|
+
export const PRELAUNCH_ACQUISITION_CONTRACT_VERSION = "prelaunch_acquisition_v1";
|
|
4
|
+
const acquisitionCaseRefSchema = z.string().regex(/^acquisition-case:[0-9a-f-]{36}$/);
|
|
5
|
+
const acquisitionContactRefSchema = z.string().regex(/^acquisition-contact:[0-9a-f-]{36}$/);
|
|
6
|
+
const acquisitionOpaqueRefSchema = z.string().trim().min(8).max(160)
|
|
7
|
+
.regex(/^[A-Za-z0-9][A-Za-z0-9._:-]*$/);
|
|
8
|
+
const acquisitionDateTimeSchema = z.string().datetime({ offset: true });
|
|
9
|
+
export const prelaunchAcquisitionListRequestSchema = z.object({
|
|
10
|
+
view: z.literal(PRELAUNCH_ACQUISITION_VIEW),
|
|
11
|
+
cursor: acquisitionOpaqueRefSchema.optional(),
|
|
12
|
+
limit: z.coerce.number().int().min(1).max(100).default(25),
|
|
13
|
+
}).strict();
|
|
14
|
+
export const prelaunchAcquisitionDetailRequestSchema = z.object({
|
|
15
|
+
sourceRef: acquisitionCaseRefSchema,
|
|
16
|
+
}).strict();
|
|
17
|
+
export const prelaunchAcquisitionLeadSchema = z.object({
|
|
18
|
+
sourceRef: acquisitionCaseRefSchema,
|
|
19
|
+
contactRef: acquisitionContactRefSchema,
|
|
20
|
+
sourceKind: z.literal("tester_application"),
|
|
21
|
+
consent: z.object({
|
|
22
|
+
consentVersion: z.string().min(1).max(64),
|
|
23
|
+
policyVersion: z.string().min(1).max(64),
|
|
24
|
+
recordedAt: acquisitionDateTimeSchema,
|
|
25
|
+
locale: z.enum(["en", "pl"]),
|
|
26
|
+
sourcePath: z.literal("/tester-application"),
|
|
27
|
+
}).strict(),
|
|
28
|
+
addressReference: z.object({
|
|
29
|
+
source: z.string().trim().min(1).max(48).regex(/^[a-z][a-z0-9_-]*$/),
|
|
30
|
+
reference: acquisitionOpaqueRefSchema,
|
|
31
|
+
revision: z.string().trim().min(1).max(64).regex(/^[A-Za-z0-9][A-Za-z0-9._:-]*$/),
|
|
32
|
+
provenance: z.string().trim().min(1).max(64).regex(/^[a-z][a-z0-9_-]*$/),
|
|
33
|
+
}).strict().nullable(),
|
|
34
|
+
state: z.enum(["submitted", "approved", "active", "rejected", "withdrawn"]),
|
|
35
|
+
version: z.number().int().positive(),
|
|
36
|
+
createdAt: acquisitionDateTimeSchema,
|
|
37
|
+
updatedAt: acquisitionDateTimeSchema,
|
|
38
|
+
}).strict().superRefine((value, context) => {
|
|
39
|
+
if (value.state !== "withdrawn" && value.addressReference === null) {
|
|
40
|
+
context.addIssue({ code: z.ZodIssueCode.custom, path: ["addressReference"], message: "active case requires address reference" });
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
export const prelaunchAcquisitionListResponseSchema = z.object({
|
|
44
|
+
contractVersion: z.literal(PRELAUNCH_ACQUISITION_CONTRACT_VERSION),
|
|
45
|
+
leads: z.array(prelaunchAcquisitionLeadSchema).max(100),
|
|
46
|
+
nextCursor: acquisitionOpaqueRefSchema.nullable(),
|
|
47
|
+
}).strict();
|
|
48
|
+
export const prelaunchAcquisitionDetailResponseSchema = z.object({
|
|
49
|
+
contractVersion: z.literal(PRELAUNCH_ACQUISITION_CONTRACT_VERSION),
|
|
50
|
+
lead: prelaunchAcquisitionLeadSchema,
|
|
51
|
+
}).strict();
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import type { OrganizationFacts } from "../contracts/contactLegal.js";
|
|
2
|
+
export type JsonLdNode = Record<string, unknown> & {
|
|
3
|
+
"@context"?: string;
|
|
4
|
+
"@id"?: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function jsonLdGraph(...nodes: JsonLdNode[]): {
|
|
7
|
+
"@context": string;
|
|
8
|
+
"@graph": {
|
|
9
|
+
[x: string]: unknown;
|
|
10
|
+
"@id"?: string;
|
|
11
|
+
}[];
|
|
12
|
+
};
|
|
13
|
+
export declare function entityIds(origin: string): {
|
|
14
|
+
organization: string;
|
|
15
|
+
website: string;
|
|
16
|
+
brand: string;
|
|
17
|
+
};
|
|
18
|
+
export declare function organizationLd(origin: string, type: "Organization" | "OnlineStore", facts: OrganizationFacts): {
|
|
19
|
+
"@context": string;
|
|
20
|
+
"@id": string;
|
|
21
|
+
"@type": "Organization" | "OnlineStore";
|
|
22
|
+
name: string;
|
|
23
|
+
legalName: string;
|
|
24
|
+
url: string;
|
|
25
|
+
logo: {
|
|
26
|
+
"@type": string;
|
|
27
|
+
url: string;
|
|
28
|
+
contentUrl: string;
|
|
29
|
+
width: number;
|
|
30
|
+
height: number;
|
|
31
|
+
};
|
|
32
|
+
email: string;
|
|
33
|
+
vatID: string;
|
|
34
|
+
taxID: string;
|
|
35
|
+
areaServed: string;
|
|
36
|
+
sameAs: string[];
|
|
37
|
+
contactPoint: {
|
|
38
|
+
"@type": string;
|
|
39
|
+
email: string;
|
|
40
|
+
contactType: string;
|
|
41
|
+
availableLanguage: string[];
|
|
42
|
+
};
|
|
43
|
+
address: {
|
|
44
|
+
"@type": string;
|
|
45
|
+
streetAddress: string;
|
|
46
|
+
addressLocality: string;
|
|
47
|
+
postalCode: string;
|
|
48
|
+
addressRegion: string;
|
|
49
|
+
addressCountry: string;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
export declare function brandLd(origin: string, name: string, url: string): {
|
|
53
|
+
"@context": string;
|
|
54
|
+
"@id": string;
|
|
55
|
+
"@type": string;
|
|
56
|
+
name: string;
|
|
57
|
+
url: string;
|
|
58
|
+
};
|
|
59
|
+
export declare function websiteLd(origin: string, name: string, url: string, inLanguage: string[]): {
|
|
60
|
+
"@context": string;
|
|
61
|
+
"@id": string;
|
|
62
|
+
"@type": string;
|
|
63
|
+
name: string;
|
|
64
|
+
url: string;
|
|
65
|
+
inLanguage: string[];
|
|
66
|
+
publisher: {
|
|
67
|
+
"@id": string;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
export declare function contactPageLd(origin: string, pageUrl: string): {
|
|
71
|
+
"@context": string;
|
|
72
|
+
"@id": string;
|
|
73
|
+
"@type": string;
|
|
74
|
+
url: string;
|
|
75
|
+
publisher: {
|
|
76
|
+
"@id": string;
|
|
77
|
+
};
|
|
78
|
+
mainEntity: {
|
|
79
|
+
"@id": string;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
export interface NetContent {
|
|
83
|
+
unscaled: number;
|
|
84
|
+
scale: number;
|
|
85
|
+
unit: string;
|
|
86
|
+
}
|
|
87
|
+
export declare function schemaWeight(netContent: NetContent): {
|
|
88
|
+
"@type": string;
|
|
89
|
+
value: number;
|
|
90
|
+
unitCode: string;
|
|
91
|
+
};
|
|
92
|
+
export interface ProductFacts {
|
|
93
|
+
url: string;
|
|
94
|
+
name: string;
|
|
95
|
+
inLanguage: string;
|
|
96
|
+
brandName: string;
|
|
97
|
+
category?: string;
|
|
98
|
+
images: string[];
|
|
99
|
+
sku?: string;
|
|
100
|
+
gtin13?: string;
|
|
101
|
+
netContent?: NetContent;
|
|
102
|
+
}
|
|
103
|
+
export declare function productLd(origin: string, product: ProductFacts): {
|
|
104
|
+
url: string;
|
|
105
|
+
weight?: {
|
|
106
|
+
"@type": string;
|
|
107
|
+
value: number;
|
|
108
|
+
unitCode: string;
|
|
109
|
+
} | undefined;
|
|
110
|
+
gtin13?: string | undefined;
|
|
111
|
+
sku?: string | undefined;
|
|
112
|
+
image: string[];
|
|
113
|
+
category?: string | undefined;
|
|
114
|
+
"@context": string;
|
|
115
|
+
"@id": string;
|
|
116
|
+
"@type": string;
|
|
117
|
+
name: string;
|
|
118
|
+
inLanguage: string;
|
|
119
|
+
brand: {
|
|
120
|
+
"@id": string;
|
|
121
|
+
"@type": string;
|
|
122
|
+
name: string;
|
|
123
|
+
};
|
|
124
|
+
manufacturer: {
|
|
125
|
+
"@id": string;
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
export declare function faqPageLd(faqs: {
|
|
129
|
+
question: string;
|
|
130
|
+
answer: string;
|
|
131
|
+
}[], pageUrl: string): {
|
|
132
|
+
"@context": string;
|
|
133
|
+
"@id": string;
|
|
134
|
+
"@type": string;
|
|
135
|
+
mainEntity: {
|
|
136
|
+
"@type": string;
|
|
137
|
+
name: string;
|
|
138
|
+
acceptedAnswer: {
|
|
139
|
+
"@type": string;
|
|
140
|
+
text: string;
|
|
141
|
+
};
|
|
142
|
+
}[];
|
|
143
|
+
};
|
|
144
|
+
export declare function breadcrumbLd(items: {
|
|
145
|
+
name: string;
|
|
146
|
+
url?: string;
|
|
147
|
+
}[], pageUrl: string): {
|
|
148
|
+
"@context": string;
|
|
149
|
+
"@id": string;
|
|
150
|
+
"@type": string;
|
|
151
|
+
itemListElement: {
|
|
152
|
+
item?: string | undefined;
|
|
153
|
+
"@type": string;
|
|
154
|
+
position: number;
|
|
155
|
+
name: string;
|
|
156
|
+
}[];
|
|
157
|
+
};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
export function jsonLdGraph(...nodes) {
|
|
2
|
+
const seen = new Set();
|
|
3
|
+
const graph = nodes.flatMap(({ "@context": _context, ...node }) => {
|
|
4
|
+
if (node["@id"] && seen.has(node["@id"]))
|
|
5
|
+
return [];
|
|
6
|
+
if (node["@id"])
|
|
7
|
+
seen.add(node["@id"]);
|
|
8
|
+
return [node];
|
|
9
|
+
});
|
|
10
|
+
return { "@context": "https://schema.org", "@graph": graph };
|
|
11
|
+
}
|
|
12
|
+
export function entityIds(origin) {
|
|
13
|
+
const site = origin.replace(/\/$/, "");
|
|
14
|
+
return {
|
|
15
|
+
organization: `${site}/#organization`,
|
|
16
|
+
website: `${site}/#website`,
|
|
17
|
+
brand: `${site}/#brand`,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export function organizationLd(origin, type, facts) {
|
|
21
|
+
return {
|
|
22
|
+
"@context": "https://schema.org",
|
|
23
|
+
"@id": entityIds(origin).organization,
|
|
24
|
+
"@type": type,
|
|
25
|
+
name: facts.name,
|
|
26
|
+
legalName: facts.legalName,
|
|
27
|
+
url: facts.url,
|
|
28
|
+
logo: {
|
|
29
|
+
"@type": "ImageObject",
|
|
30
|
+
url: facts.logo.url,
|
|
31
|
+
contentUrl: facts.logo.contentUrl,
|
|
32
|
+
width: facts.logo.width,
|
|
33
|
+
height: facts.logo.height,
|
|
34
|
+
},
|
|
35
|
+
email: facts.email,
|
|
36
|
+
vatID: facts.vatID,
|
|
37
|
+
taxID: facts.taxID,
|
|
38
|
+
areaServed: facts.areaServed,
|
|
39
|
+
sameAs: facts.sameAs,
|
|
40
|
+
contactPoint: {
|
|
41
|
+
"@type": "ContactPoint",
|
|
42
|
+
email: facts.contactPoint.email,
|
|
43
|
+
contactType: facts.contactPoint.contactType,
|
|
44
|
+
availableLanguage: facts.contactPoint.availableLanguage,
|
|
45
|
+
},
|
|
46
|
+
address: {
|
|
47
|
+
"@type": "PostalAddress",
|
|
48
|
+
streetAddress: facts.address.streetAddress,
|
|
49
|
+
addressLocality: facts.address.addressLocality,
|
|
50
|
+
postalCode: facts.address.postalCode,
|
|
51
|
+
addressRegion: facts.address.addressRegion,
|
|
52
|
+
addressCountry: facts.address.addressCountry,
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export function brandLd(origin, name, url) {
|
|
57
|
+
return { "@context": "https://schema.org", "@id": entityIds(origin).brand, "@type": "Brand", name, url };
|
|
58
|
+
}
|
|
59
|
+
export function websiteLd(origin, name, url, inLanguage) {
|
|
60
|
+
return {
|
|
61
|
+
"@context": "https://schema.org",
|
|
62
|
+
"@id": entityIds(origin).website,
|
|
63
|
+
"@type": "WebSite",
|
|
64
|
+
name,
|
|
65
|
+
url,
|
|
66
|
+
inLanguage,
|
|
67
|
+
publisher: { "@id": entityIds(origin).organization },
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
export function contactPageLd(origin, pageUrl) {
|
|
71
|
+
return {
|
|
72
|
+
"@context": "https://schema.org",
|
|
73
|
+
"@id": `${pageUrl.replace(/\/$/, "")}#webpage`,
|
|
74
|
+
"@type": "ContactPage",
|
|
75
|
+
url: pageUrl,
|
|
76
|
+
publisher: { "@id": entityIds(origin).organization },
|
|
77
|
+
mainEntity: { "@id": entityIds(origin).organization },
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
export function schemaWeight(netContent) {
|
|
81
|
+
const { unscaled, scale, unit } = netContent;
|
|
82
|
+
const unitCode = unit === "GRAM" || unit === "G" ? "GRM" : unit;
|
|
83
|
+
return { "@type": "QuantitativeValue", value: unscaled / 10 ** scale, unitCode };
|
|
84
|
+
}
|
|
85
|
+
export function productLd(origin, product) {
|
|
86
|
+
return {
|
|
87
|
+
"@context": "https://schema.org",
|
|
88
|
+
"@id": `${product.url.replace(/\/$/, "")}#product`,
|
|
89
|
+
"@type": "Product",
|
|
90
|
+
name: product.name,
|
|
91
|
+
inLanguage: product.inLanguage,
|
|
92
|
+
brand: { "@id": entityIds(origin).brand, "@type": "Brand", name: product.brandName },
|
|
93
|
+
manufacturer: { "@id": entityIds(origin).organization },
|
|
94
|
+
...(product.category !== undefined ? { category: product.category } : {}),
|
|
95
|
+
image: product.images,
|
|
96
|
+
...(product.sku !== undefined ? { sku: product.sku } : {}),
|
|
97
|
+
...(product.gtin13 !== undefined ? { gtin13: product.gtin13 } : {}),
|
|
98
|
+
...(product.netContent ? { weight: schemaWeight(product.netContent) } : {}),
|
|
99
|
+
url: product.url,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
const pageEntityId = (pageUrl, fragment) => `${pageUrl.replace(/\/$/, "")}#${fragment}`;
|
|
103
|
+
export function faqPageLd(faqs, pageUrl) {
|
|
104
|
+
return {
|
|
105
|
+
"@context": "https://schema.org",
|
|
106
|
+
"@id": pageEntityId(pageUrl, "faq"),
|
|
107
|
+
"@type": "FAQPage",
|
|
108
|
+
mainEntity: faqs.map((faq) => ({
|
|
109
|
+
"@type": "Question",
|
|
110
|
+
name: faq.question,
|
|
111
|
+
acceptedAnswer: { "@type": "Answer", text: faq.answer },
|
|
112
|
+
})),
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
export function breadcrumbLd(items, pageUrl) {
|
|
116
|
+
return {
|
|
117
|
+
"@context": "https://schema.org",
|
|
118
|
+
"@id": pageEntityId(pageUrl, "breadcrumb"),
|
|
119
|
+
"@type": "BreadcrumbList",
|
|
120
|
+
itemListElement: items.map((item, index) => ({
|
|
121
|
+
"@type": "ListItem",
|
|
122
|
+
position: index + 1,
|
|
123
|
+
name: item.name,
|
|
124
|
+
...(item.url ? { item: item.url } : {}),
|
|
125
|
+
})),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type JsonLdNode } from "./jsonLd.js";
|
|
2
|
+
import { type SiteRoute } from "./urls.js";
|
|
3
|
+
export type HeadTag = {
|
|
4
|
+
kind: "meta";
|
|
5
|
+
name: string;
|
|
6
|
+
content: string;
|
|
7
|
+
} | {
|
|
8
|
+
kind: "meta";
|
|
9
|
+
property: string;
|
|
10
|
+
content: string;
|
|
11
|
+
} | {
|
|
12
|
+
kind: "link";
|
|
13
|
+
rel: "canonical" | "alternate";
|
|
14
|
+
href: string;
|
|
15
|
+
hrefLang?: string;
|
|
16
|
+
};
|
|
17
|
+
export interface HeadFacts {
|
|
18
|
+
origin: string;
|
|
19
|
+
route: SiteRoute;
|
|
20
|
+
routes: readonly SiteRoute[];
|
|
21
|
+
xDefaultLocale: string;
|
|
22
|
+
htmlLang: string;
|
|
23
|
+
title: string;
|
|
24
|
+
description: string;
|
|
25
|
+
siteName: string;
|
|
26
|
+
ogImage: string;
|
|
27
|
+
ogImageWidth: number;
|
|
28
|
+
ogImageHeight: number;
|
|
29
|
+
ogLocale: string;
|
|
30
|
+
alternateOgLocale?: string;
|
|
31
|
+
twitterImage: string;
|
|
32
|
+
twitterHandle: string;
|
|
33
|
+
noindex?: boolean;
|
|
34
|
+
jsonLd?: JsonLdNode | JsonLdNode[];
|
|
35
|
+
}
|
|
36
|
+
export declare function buildHeadDescriptor(facts: HeadFacts): {
|
|
37
|
+
htmlLang: string;
|
|
38
|
+
title: string;
|
|
39
|
+
tags: HeadTag[];
|
|
40
|
+
jsonLd: string | null;
|
|
41
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsonLdGraph } from "./jsonLd.js";
|
|
2
|
+
import { serializeJsonLd } from "./serializeJsonLd.js";
|
|
3
|
+
import { canonicalUrlForRoute, hreflangLinksForRoute } from "./urls.js";
|
|
4
|
+
export function buildHeadDescriptor(facts) {
|
|
5
|
+
const canonicalUrl = canonicalUrlForRoute(facts.origin, facts.route);
|
|
6
|
+
const nodes = facts.jsonLd ? (Array.isArray(facts.jsonLd) ? facts.jsonLd : [facts.jsonLd]) : [];
|
|
7
|
+
const tags = [
|
|
8
|
+
{ kind: "meta", name: "description", content: facts.description },
|
|
9
|
+
{ kind: "link", rel: "canonical", href: canonicalUrl },
|
|
10
|
+
...(facts.noindex ? [{ kind: "meta", name: "robots", content: "noindex, nofollow" }] : []),
|
|
11
|
+
{ kind: "meta", property: "og:title", content: facts.title },
|
|
12
|
+
{ kind: "meta", property: "og:description", content: facts.description },
|
|
13
|
+
{ kind: "meta", property: "og:image", content: facts.ogImage },
|
|
14
|
+
{ kind: "meta", property: "og:image:width", content: String(facts.ogImageWidth) },
|
|
15
|
+
{ kind: "meta", property: "og:image:height", content: String(facts.ogImageHeight) },
|
|
16
|
+
{ kind: "meta", property: "og:type", content: "website" },
|
|
17
|
+
{ kind: "meta", property: "og:site_name", content: facts.siteName },
|
|
18
|
+
{ kind: "meta", property: "og:url", content: canonicalUrl },
|
|
19
|
+
{ kind: "meta", property: "og:locale", content: facts.ogLocale },
|
|
20
|
+
...(facts.alternateOgLocale ? [{ kind: "meta", property: "og:locale:alternate", content: facts.alternateOgLocale }] : []),
|
|
21
|
+
{ kind: "meta", name: "twitter:card", content: "summary_large_image" },
|
|
22
|
+
{ kind: "meta", name: "twitter:site", content: facts.twitterHandle },
|
|
23
|
+
{ kind: "meta", name: "twitter:title", content: facts.title },
|
|
24
|
+
{ kind: "meta", name: "twitter:description", content: facts.description },
|
|
25
|
+
{ kind: "meta", name: "twitter:image", content: facts.twitterImage },
|
|
26
|
+
...hreflangLinksForRoute(facts.origin, facts.route, facts.routes, facts.xDefaultLocale).map((link) => ({
|
|
27
|
+
kind: "link", rel: "alternate", hrefLang: link.hrefLang, href: link.href,
|
|
28
|
+
})),
|
|
29
|
+
];
|
|
30
|
+
return {
|
|
31
|
+
htmlLang: facts.htmlLang,
|
|
32
|
+
title: facts.title,
|
|
33
|
+
tags,
|
|
34
|
+
jsonLd: nodes.length > 0 ? serializeJsonLd(jsonLdGraph(...nodes)) : null,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function serializeJsonLd(value: object): string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface SiteRoute {
|
|
2
|
+
id: string;
|
|
3
|
+
locale: string;
|
|
4
|
+
canonicalPath: string;
|
|
5
|
+
alternateRouteId?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface HreflangLink {
|
|
8
|
+
hrefLang: string;
|
|
9
|
+
href: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function normalizeSitePath(pathname: string): string;
|
|
12
|
+
export declare function absoluteSiteUrl(origin: string, pathname: string): string;
|
|
13
|
+
export declare function canonicalUrlForRoute(origin: string, route: SiteRoute): string;
|
|
14
|
+
export declare function hreflangLinksForRoute(origin: string, route: SiteRoute, routes: readonly SiteRoute[], xDefaultLocale: string): HreflangLink[];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export function normalizeSitePath(pathname) {
|
|
2
|
+
const path = pathname.startsWith("/") ? pathname : `/${pathname}`;
|
|
3
|
+
return path.length > 1 ? path.replace(/\/$/, "") : path;
|
|
4
|
+
}
|
|
5
|
+
export function absoluteSiteUrl(origin, pathname) {
|
|
6
|
+
const site = origin.replace(/\/$/, "");
|
|
7
|
+
const path = normalizeSitePath(pathname);
|
|
8
|
+
return path === "/" ? `${site}/` : `${site}${path}`;
|
|
9
|
+
}
|
|
10
|
+
export function canonicalUrlForRoute(origin, route) {
|
|
11
|
+
return absoluteSiteUrl(origin, route.canonicalPath);
|
|
12
|
+
}
|
|
13
|
+
export function hreflangLinksForRoute(origin, route, routes, xDefaultLocale) {
|
|
14
|
+
const alternate = route.alternateRouteId ? routes.find((candidate) => candidate.id === route.alternateRouteId) : undefined;
|
|
15
|
+
if (!alternate)
|
|
16
|
+
return [];
|
|
17
|
+
const pair = [route, alternate].sort((a, b) => a.locale.localeCompare(b.locale));
|
|
18
|
+
const preferred = pair.find((candidate) => candidate.locale === xDefaultLocale);
|
|
19
|
+
return [
|
|
20
|
+
...pair.map((candidate) => ({ hrefLang: candidate.locale, href: canonicalUrlForRoute(origin, candidate) })),
|
|
21
|
+
{ hrefLang: "x-default", href: canonicalUrlForRoute(origin, preferred ?? pair[0]) },
|
|
22
|
+
];
|
|
23
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { HttpRequest, HttpResponse } from "../../http/index.js";
|
|
2
|
+
import type { AcquisitionCaseDirectDeps } from "./directPorts.js";
|
|
3
|
+
export declare function createAcquisitionCaseListDirectHandler(options: AcquisitionCaseDirectDeps): (req: HttpRequest, res: HttpResponse) => Promise<void>;
|
|
4
|
+
export declare function createAcquisitionCaseActiveCountDirectHandler(options: AcquisitionCaseDirectDeps): (req: HttpRequest, res: HttpResponse) => Promise<void>;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { ACQUISITION_CASE_VIEW, acquisitionCaseActiveCountResponseSchema, acquisitionCaseListRequestSchema, acquisitionCaseListResponseSchema } from "../acquisitionCaseSchemas.js";
|
|
2
|
+
export function createAcquisitionCaseListDirectHandler(options) {
|
|
3
|
+
const { respond, authorize, resolveBinding, isDirect } = options;
|
|
4
|
+
const { sendBffSuccess, sendMethodNotAllowed } = respond;
|
|
5
|
+
return async (req, res) => {
|
|
6
|
+
if (!isDirect() || first(req.query.view) !== ACQUISITION_CASE_VIEW)
|
|
7
|
+
return unavailable(res, respond);
|
|
8
|
+
if (req.method !== "GET")
|
|
9
|
+
return sendMethodNotAllowed(res, ["GET"]);
|
|
10
|
+
const actorRef = await authorize(req, res);
|
|
11
|
+
if (!actorRef)
|
|
12
|
+
return;
|
|
13
|
+
const request = acquisitionCaseListRequestSchema.safeParse({
|
|
14
|
+
view: first(req.query.view), cursor: first(req.query.cursor), limit: integer(first(req.query.limit), 25),
|
|
15
|
+
});
|
|
16
|
+
if (!request.success)
|
|
17
|
+
return badRequest(res, respond, request.error.flatten());
|
|
18
|
+
const binding = await bindingOrError(res, respond, resolveBinding);
|
|
19
|
+
if (!binding)
|
|
20
|
+
return;
|
|
21
|
+
const result = await operationOrError(res, respond, () => binding.handlers.list(actorRef, request.data));
|
|
22
|
+
if (!result)
|
|
23
|
+
return;
|
|
24
|
+
if (result.ok === false)
|
|
25
|
+
return failure(res, respond, result.error.kind);
|
|
26
|
+
const response = acquisitionCaseListResponseSchema.safeParse(result.value);
|
|
27
|
+
if (!response.success)
|
|
28
|
+
return invalidResponse(res, respond);
|
|
29
|
+
sendBffSuccess(res, response.data);
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export function createAcquisitionCaseActiveCountDirectHandler(options) {
|
|
33
|
+
const { respond, resolveBinding, isDirect } = options;
|
|
34
|
+
const { sendBffSuccess, sendMethodNotAllowed } = respond;
|
|
35
|
+
return async (req, res) => {
|
|
36
|
+
if (!isDirect())
|
|
37
|
+
return unavailable(res, respond);
|
|
38
|
+
if (req.method !== "GET")
|
|
39
|
+
return sendMethodNotAllowed(res, ["GET"]);
|
|
40
|
+
const binding = await bindingOrError(res, respond, resolveBinding);
|
|
41
|
+
if (!binding)
|
|
42
|
+
return;
|
|
43
|
+
const result = await operationOrError(res, respond, () => binding.handlers.activeCount());
|
|
44
|
+
if (!result)
|
|
45
|
+
return;
|
|
46
|
+
if (result.ok === false)
|
|
47
|
+
return failure(res, respond, result.error.kind);
|
|
48
|
+
const response = acquisitionCaseActiveCountResponseSchema.safeParse(result.value);
|
|
49
|
+
if (!response.success)
|
|
50
|
+
return invalidResponse(res, respond);
|
|
51
|
+
sendBffSuccess(res, response.data);
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
async function bindingOrError(res, respond, resolve) {
|
|
55
|
+
try {
|
|
56
|
+
const binding = await resolve();
|
|
57
|
+
if (binding)
|
|
58
|
+
return binding;
|
|
59
|
+
}
|
|
60
|
+
catch { /* fail closed below */ }
|
|
61
|
+
respond.sendBffError(res, "UPSTREAM_UNAVAILABLE", "Acquisition case service unavailable");
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
async function operationOrError(res, respond, operation) {
|
|
65
|
+
try {
|
|
66
|
+
return await operation();
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
respond.sendBffError(res, "UPSTREAM_UNAVAILABLE", "Acquisition case service unavailable");
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function first(value) { return Array.isArray(value) ? value[0] : value; }
|
|
74
|
+
function integer(value, fallback) { return value === undefined ? fallback : Number(value); }
|
|
75
|
+
function badRequest(res, respond, details) { respond.sendBffError(res, "BAD_REQUEST", "Invalid acquisition case request", { details }); }
|
|
76
|
+
function unavailable(res, respond) { respond.sendBffError(res, "NOT_FOUND", "Acquisition case unavailable"); }
|
|
77
|
+
function invalidResponse(res, respond) { respond.sendBffError(res, "INVALID_RESPONSE", "Acquisition case returned invalid response"); }
|
|
78
|
+
function failure(res, respond, kind) {
|
|
79
|
+
if (kind === "invalid")
|
|
80
|
+
return badRequest(res, respond);
|
|
81
|
+
if (kind === "conflict")
|
|
82
|
+
return respond.sendBffError(res, "CONFLICT", "Acquisition case request conflicts with prior state");
|
|
83
|
+
if (kind === "rate_limited")
|
|
84
|
+
return respond.sendBffError(res, "RATE_LIMITED", "Acquisition submission rate limited");
|
|
85
|
+
if (kind === "not_found")
|
|
86
|
+
return unavailable(res, respond);
|
|
87
|
+
respond.sendBffError(res, "UPSTREAM_UNAVAILABLE", "Acquisition case service unavailable");
|
|
88
|
+
}
|