@pwf-dev/core 0.1.1

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 ADDED
@@ -0,0 +1,65 @@
1
+ # @pwf-dev/core
2
+
3
+ TypeScript/JavaScript core library for parsing, validating, and generating PWF files in Node.js and browser environments.
4
+
5
+ ## Install (local workspace)
6
+
7
+ ```bash
8
+ npm install
9
+ npm run build
10
+ ```
11
+
12
+ Generate API docs:
13
+ ```bash
14
+ npm run docs
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ ```ts
20
+ import {
21
+ parsePlan,
22
+ parseHistory,
23
+ validatePlan,
24
+ validateHistory,
25
+ PlanBuilder,
26
+ isValidationIssueList,
27
+ toYAML
28
+ } from '@pwf-dev/core';
29
+
30
+ const plan = parsePlan(yamlString);
31
+ const history = parseHistory(yamlString);
32
+
33
+ if (!isValidationIssueList(plan)) {
34
+ const planErrors = validatePlan(plan);
35
+ console.log(planErrors);
36
+ }
37
+
38
+ if (!isValidationIssueList(history)) {
39
+ const historyErrors = validateHistory(history, { strict: false });
40
+ console.log(historyErrors);
41
+ }
42
+
43
+ const builtPlan = new PlanBuilder()
44
+ .version(1)
45
+ .meta({ title: 'My Plan', daysPerWeek: 3 })
46
+ .addDay('Push Day')
47
+ .addExercise('Bench Press', {
48
+ modality: 'strength',
49
+ target_sets: 3,
50
+ target_reps: 5
51
+ })
52
+ .build();
53
+
54
+ const yaml = builtPlan.toYAML();
55
+ const yamlAlt = toYAML(builtPlan);
56
+ ```
57
+
58
+ IIFE bundles expose `PwfCore` when loaded via a `<script>` tag.
59
+
60
+ ## Notes
61
+
62
+ - Validation uses the PWF JSON Schemas in `schema/`.
63
+ - Parser methods return either a parsed object or a list of validation issues.
64
+ - Error paths are formatted in a dotted/array syntax (e.g. `cycle.days[0].exercises[0].name`).
65
+ - Regenerate TypeScript types from schema with `npm run generate:types`.