recipe-scrapers-js 1.0.0-rc.2 → 1.0.0-rc.3

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 CHANGED
@@ -6,6 +6,14 @@ All notable changes to this project will be documented in this file.
6
6
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
7
7
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
8
8
 
9
+ ## [1.0.0-rc.3] - 2025-12-21
10
+
11
+ ### Changed
12
+
13
+ - Enforce positive integer values for recipe time fields (`totalTime`, `cookTime`, `prepTime`)
14
+ - Rename schema helper `zPositiveNumber` to `zPositiveInteger`
15
+ - Stop defaulting nullable schema fields to `null`
16
+
9
17
  ## [1.0.0-rc.2] - 2025-12-20
10
18
 
11
19
  ### Added
@@ -14,8 +22,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
14
22
 
15
23
  ### Changed
16
24
 
17
- - Make `links` field optional, and thus `undefined` in the recipe object, unless link parsing is enabled
18
- - Move schema transform & refinement validations into a helper function `applyRecipeValidations`
25
+ - Make `links` optional; it stays `undefined` unless link parsing is enabled
26
+ - Extract schema transform/refinement validations into `applyRecipeValidations`
19
27
 
20
28
  ## [1.0.0-rc.1] - 2025-12-20
21
29
 
@@ -25,18 +33,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
25
33
 
26
34
  ### Fixed
27
35
 
28
- - Fix main/module/type entriess in package.json; add exports field
36
+ - Fix `main`/`module`/`types` entries in `package.json`; add `exports`
29
37
 
30
38
  ## [1.0.0-rc.0] - 2025-12-20
31
39
 
32
40
  ### Added
33
41
 
34
42
  - Optional ingredient parsing via [parse-ingredient](https://github.com/jakeboone02/parse-ingredient)
35
- - `parse()` and `safeParse()` methods for Zod schema validated recipe extraction
43
+ - `parse()` and `safeParse()` methods for Zod-validated recipe extraction
36
44
 
37
45
  ### Changed
38
46
 
39
- - **BREAKING**: Renamed `toObject()` method to `toRecipeObject()` for clarity
47
+ - **BREAKING**: Rename `toObject()` method to `toRecipeObject()` for clarity
40
48
  - **BREAKING**: Ingredients and instructions now require grouped structures (each group has `name` and `items`) instead of flat arrays
41
49
 
42
50
  ---
package/dist/index.d.mts CHANGED
@@ -73,7 +73,7 @@ declare const IngredientItemSchema: z.ZodObject<{
73
73
  * Schema for a group of ingredients
74
74
  */
75
75
  declare const IngredientGroupSchema: z.ZodObject<{
76
- name: z.ZodDefault<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
76
+ name: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
77
77
  items: z.ZodArray<z.core.$ZodType<{
78
78
  value: string;
79
79
  parsed?: {
@@ -101,7 +101,7 @@ declare const IngredientGroupSchema: z.ZodObject<{
101
101
  * Must have at least one group with at least one ingredient
102
102
  */
103
103
  declare const IngredientsSchema: z.ZodArray<z.ZodObject<{
104
- name: z.ZodDefault<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
104
+ name: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
105
105
  items: z.ZodArray<z.core.$ZodType<{
106
106
  value: string;
107
107
  parsed?: {
@@ -134,7 +134,7 @@ declare const InstructionItemSchema: z.ZodObject<{
134
134
  * Schema for a group of instruction steps
135
135
  */
136
136
  declare const InstructionGroupSchema: z.ZodObject<{
137
- name: z.ZodDefault<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
137
+ name: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
138
138
  items: z.ZodArray<z.core.$ZodType<{
139
139
  value: string;
140
140
  }, unknown, z.core.$ZodTypeInternals<{
@@ -146,7 +146,7 @@ declare const InstructionGroupSchema: z.ZodObject<{
146
146
  * Must have at least one group with at least one step
147
147
  */
148
148
  declare const InstructionsSchema: z.ZodArray<z.ZodObject<{
149
- name: z.ZodDefault<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
149
+ name: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
150
150
  items: z.ZodArray<z.core.$ZodType<{
151
151
  value: string;
152
152
  }, unknown, z.core.$ZodTypeInternals<{
@@ -182,7 +182,7 @@ declare const RecipeObjectBaseSchema: z.ZodObject<{
182
182
  title: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
183
183
  author: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
184
184
  ingredients: z.ZodArray<z.ZodObject<{
185
- name: z.ZodDefault<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
185
+ name: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
186
186
  items: z.ZodArray<z.core.$ZodType<{
187
187
  value: string;
188
188
  parsed?: {
@@ -206,7 +206,7 @@ declare const RecipeObjectBaseSchema: z.ZodObject<{
206
206
  }, unknown>>>;
207
207
  }, z.core.$strip>>;
208
208
  instructions: z.ZodArray<z.ZodObject<{
209
- name: z.ZodDefault<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
209
+ name: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
210
210
  items: z.ZodArray<z.core.$ZodType<{
211
211
  value: string;
212
212
  }, unknown, z.core.$ZodTypeInternals<{
@@ -215,16 +215,16 @@ declare const RecipeObjectBaseSchema: z.ZodObject<{
215
215
  }, z.core.$strip>>;
216
216
  canonicalUrl: z.ZodURL;
217
217
  image: z.ZodURL;
218
- totalTime: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
219
- cookTime: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
220
- prepTime: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
218
+ totalTime: z.ZodNullable<z.ZodInt>;
219
+ cookTime: z.ZodNullable<z.ZodInt>;
220
+ prepTime: z.ZodNullable<z.ZodInt>;
221
221
  ratings: z.ZodDefault<z.ZodNumber>;
222
222
  ratingsCount: z.ZodDefault<z.ZodInt>;
223
223
  yields: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
224
224
  description: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
225
225
  language: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
226
- siteName: z.ZodDefault<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
227
- cookingMethod: z.ZodDefault<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
226
+ siteName: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
227
+ cookingMethod: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
228
228
  category: z.ZodDefault<z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
229
229
  cuisine: z.ZodDefault<z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
230
230
  keywords: z.ZodDefault<z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
package/dist/index.mjs CHANGED
@@ -48,9 +48,9 @@ const zString = (fieldName, { min = 1, max = 0 } = {}) => z.string(`${fieldName}
48
48
  */
49
49
  const zHttpUrl = (fieldName) => z.httpUrl(`${fieldName} must be a valid URL`);
50
50
  /**
51
- * Helper to create a positive number field
51
+ * Helper to create a positive integer field
52
52
  */
53
- const zPositiveNumber = (fieldName) => z.number(`${fieldName} must be a number`).positive(`${fieldName} must be positive`).nullable().default(null);
53
+ const zPositiveInteger = (fieldName) => z.int(`${fieldName} must be an integer`).positive(`${fieldName} must be positive`).nullable();
54
54
  const zNonEmptyArray = (schema, fieldName) => z.array(schema, `${fieldName} items must be an array`).min(1, `${fieldName} group must have at least one item`);
55
55
 
56
56
  //#endregion
@@ -87,7 +87,7 @@ const IngredientItemSchema = z.object({
87
87
  * Schema for a group of ingredients
88
88
  */
89
89
  const IngredientGroupSchema = z.object({
90
- name: zString("Ingredient group name").nullable().default(null),
90
+ name: zString("Ingredient group name").nullable(),
91
91
  items: zNonEmptyArray(IngredientItemSchema, "Ingredient")
92
92
  });
93
93
  /**
@@ -103,7 +103,7 @@ const InstructionItemSchema = z.object({ value: zString("Instruction value") });
103
103
  * Schema for a group of instruction steps
104
104
  */
105
105
  const InstructionGroupSchema = z.object({
106
- name: zString("Instruction group name").nullable().default(null),
106
+ name: zString("Instruction group name").nullable(),
107
107
  items: zNonEmptyArray(InstructionItemSchema, "Instruction")
108
108
  });
109
109
  /**
@@ -143,16 +143,16 @@ const RecipeObjectBaseSchema = z.object({
143
143
  instructions: InstructionsSchema,
144
144
  canonicalUrl: zHttpUrl("Canonical URL"),
145
145
  image: zHttpUrl("Image"),
146
- totalTime: zPositiveNumber("Total time"),
147
- cookTime: zPositiveNumber("Cook time"),
148
- prepTime: zPositiveNumber("Prep time"),
146
+ totalTime: zPositiveInteger("Total time"),
147
+ cookTime: zPositiveInteger("Cook time"),
148
+ prepTime: zPositiveInteger("Prep time"),
149
149
  ratings: z.number("Ratings must be a number").min(0, "Ratings must be at least 0").max(5, "Ratings must be at most 5").default(0),
150
150
  ratingsCount: z.int("Ratings count must be an integer").nonnegative("Ratings count must be non-negative").default(0),
151
151
  yields: zString("Yields"),
152
152
  description: zString("Description"),
153
153
  language: zString("Language", { min: 2 }).optional().default("en"),
154
- siteName: zString("Site name").nullable().default(null),
155
- cookingMethod: zString("Cooking method").nullable().default(null),
154
+ siteName: zString("Site name").nullable(),
155
+ cookingMethod: zString("Cooking method").nullable(),
156
156
  category: z.array(zString("Category item"), "Category must be an array").default([]),
157
157
  cuisine: z.array(zString("Cuisine item"), "Cuisine must be an array").default([]),
158
158
  keywords: z.array(zString("Keyword item"), "Keywords must be an array").default([]),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "recipe-scrapers-js",
3
- "version": "1.0.0-rc.2",
3
+ "version": "1.0.0-rc.3",
4
4
  "license": "MIT",
5
5
  "description": "A recipe scrapers library",
6
6
  "author": {