@u-krupaveho-kraba/form-schemas 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -18,16 +18,19 @@ npm install @topol/form-schemas zod
18
18
  - **Form schemas** — `FormSchema`, `StepSchema`, `FormElementSchema`, and the
19
19
  per-element-type property schemas, describing the full form JSON tree
20
20
  rendered by the Topol form widget.
21
- - **Campaign schemas** — `CampaignSchema`, `VariantSchema`,
22
- `CampaignTargetingSchema`, `TriggerConditionSchema`, and `CampaignsFileSchema`,
23
- describing a campaign's targeting rules, display trigger, and A/B variants.
21
+ - **Campaign schemas** — `CampaignItemSchema`, `VariantSchema`,
22
+ `CampaignTargetingSchema`, `TriggerConditionSchema`, and
23
+ `CampaignItemsFileSchema`, describing one independently-evaluated
24
+ CampaignItem's targeting rules, display trigger, and A/B variants (there is
25
+ no `Campaign` wrapper -- `CampaignItem` is the atomic authored/published
26
+ unit, ADR 0025).
24
27
 
25
28
  ## Usage
26
29
 
27
30
  ```ts
28
- import { CampaignSchema } from "@topol/form-schemas";
31
+ import { CampaignItemSchema } from "@topol/form-schemas";
29
32
 
30
- const result = CampaignSchema.safeParse(payload);
33
+ const result = CampaignItemSchema.safeParse(payload);
31
34
  if (!result.success) {
32
35
  // result.error describes exactly which field failed and why
33
36
  }
@@ -40,14 +43,14 @@ Both schema families can be serialized to standard JSON Schema (draft
40
43
  feeding an LLM the exact shape of valid JSON:
41
44
 
42
45
  ```ts
43
- import { getFormJsonSchema, getCampaignJsonSchema } from "@topol/form-schemas";
46
+ import { getFormJsonSchema, getCampaignItemJsonSchema } from "@topol/form-schemas";
44
47
 
45
48
  const formSchema = getFormJsonSchema();
46
- const campaignSchema = getCampaignJsonSchema();
49
+ const campaignItemSchema = getCampaignItemJsonSchema();
47
50
  ```
48
51
 
49
- The generated Campaign JSON Schema also ships pre-built in the package at
50
- `schema/campaign.schema.json`, so non-TypeScript consumers (e.g. a backend
52
+ The generated CampaignItem JSON Schema also ships pre-built in the package at
53
+ `schema/campaignItem.schema.json`, so non-TypeScript consumers (e.g. a backend
51
54
  service in another language) can validate against the exact same contract
52
55
  without needing to run TypeScript or zod themselves.
53
56
 
package/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as z from "zod/mini";
2
2
  import { FormSchema } from "./schemas/form.js";
3
- import { CampaignSchema } from "./schemas/campaign.js";
3
+ import { CampaignItemSchema } from "./schemas/campaign.js";
4
4
  export * from "./schemas/helpers.js";
5
5
  export * from "./schemas/formDisplay.js";
6
6
  export * from "./schemas/elementProperties.js";
@@ -16,10 +16,13 @@ export function getFormJsonSchema() {
16
16
  return z.toJSONSchema(FormSchema);
17
17
  }
18
18
  /**
19
- * Serializes the Campaign contract as standard JSON Schema — the artifact
20
- * exported to ecomailapp so its PHP publish job can validate against the
21
- * real schema instead of drifting silently (ticket 115/118, ADR 0017).
19
+ * Serializes the CampaignItem contract as standard JSON Schema — the
20
+ * artifact exported to ecomailapp so its PHP publish job can validate each
21
+ * item it builds against the real schema instead of drifting silently
22
+ * (ticket 115/118, ADR 0017). Renamed from `getCampaignJsonSchema` by ADR
23
+ * 0025: there is no `Campaign` wrapper left to serialize, `CampaignItem` is
24
+ * now the atomic authored/published unit.
22
25
  */
23
- export function getCampaignJsonSchema() {
24
- return z.toJSONSchema(CampaignSchema);
26
+ export function getCampaignItemJsonSchema() {
27
+ return z.toJSONSchema(CampaignItemSchema);
25
28
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@u-krupaveho-kraba/form-schemas",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Zod schemas for Topol form JSON (validation gate + AI generation)",
5
5
  "author": "Topol.io",
6
6
  "license": "ISC",