@u-krupaveho-kraba/form-schemas 0.1.0 → 0.1.2

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.
Files changed (2) hide show
  1. package/README.md +68 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,68 @@
1
+ # @topol/form-schemas
2
+
3
+ Zod v4 schemas for the Topol form JSON model: forms, steps, elements, and the
4
+ Campaign/Variant/targeting/trigger contract used for popup targeting and A/B
5
+ testing. Built on [`zod/mini`](https://zod.dev/packages/mini) for a smaller
6
+ runtime footprint.
7
+
8
+ ## Install
9
+
10
+ ```bash
11
+ npm install @topol/form-schemas zod
12
+ ```
13
+
14
+ `zod` (`^4.1.11`) is a peer dependency, not bundled.
15
+
16
+ ## What's in here
17
+
18
+ - **Form schemas** — `FormSchema`, `StepSchema`, `FormElementSchema`, and the
19
+ per-element-type property schemas, describing the full form JSON tree
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.
24
+
25
+ ## Usage
26
+
27
+ ```ts
28
+ import { CampaignSchema } from "@topol/form-schemas";
29
+
30
+ const result = CampaignSchema.safeParse(payload);
31
+ if (!result.success) {
32
+ // result.error describes exactly which field failed and why
33
+ }
34
+ ```
35
+
36
+ ### Generating JSON Schema
37
+
38
+ Both schema families can be serialized to standard JSON Schema (draft
39
+ 2020-12), for validating payloads from non-TypeScript consumers or for
40
+ feeding an LLM the exact shape of valid JSON:
41
+
42
+ ```ts
43
+ import { getFormJsonSchema, getCampaignJsonSchema } from "@topol/form-schemas";
44
+
45
+ const formSchema = getFormJsonSchema();
46
+ const campaignSchema = getCampaignJsonSchema();
47
+ ```
48
+
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
51
+ service in another language) can validate against the exact same contract
52
+ without needing to run TypeScript or zod themselves.
53
+
54
+ ## Versioning
55
+
56
+ This package's semver is independent from the `version`/`formatVersion`
57
+ fields inside the campaign/form JSON payloads themselves. Those in-payload
58
+ fields describe wire-format migration compatibility at runtime; this
59
+ package's version describes the TypeScript contract's own API compatibility.
60
+ A bump in one doesn't imply a bump in the other.
61
+
62
+ ## Source
63
+
64
+ Part of the [Topol](https://topol.io) editors monorepo, which is a private
65
+ repository — the `repository` field above won't resolve for external
66
+ visitors. This package is published publicly because its contents (schema
67
+ shapes, no business logic or credentials) are safe to distribute even though
68
+ the source repo isn't.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@u-krupaveho-kraba/form-schemas",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Zod schemas for Topol form JSON (validation gate + AI generation)",
5
5
  "author": "Topol.io",
6
6
  "license": "ISC",