soustack 0.3.0 → 0.4.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 +41 -24
- package/dist/cli/index.js +1703 -607
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.mts +65 -19
- package/dist/index.d.ts +65 -19
- package/dist/index.js +1490 -587
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1489 -587
- package/dist/index.mjs.map +1 -1
- package/dist/{scrape.d.mts → scrape/index.d.mts} +8 -6
- package/dist/{scrape.d.ts → scrape/index.d.ts} +8 -6
- package/dist/{scrape.js → scrape/index.js} +170 -66
- package/dist/scrape/index.js.map +1 -0
- package/dist/{scrape.mjs → scrape/index.mjs} +170 -66
- package/dist/scrape/index.mjs.map +1 -0
- package/package.json +9 -6
- package/dist/scrape.js.map +0 -1
- package/dist/scrape.mjs.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -9,15 +9,17 @@ interface SoustackRecipe {
|
|
|
9
9
|
$schema?: string;
|
|
10
10
|
/** Optional declared validation profile */
|
|
11
11
|
profile?: string;
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
/**
|
|
12
|
+
/** Recipe level: "lite" or "base" */
|
|
13
|
+
level?: "lite" | "base";
|
|
14
|
+
/** Stack declarations as a map: Record<stackName, versionNumber> */
|
|
15
|
+
stacks?: Record<string, number>;
|
|
16
|
+
/** Attribution stack payload */
|
|
15
17
|
attribution?: AttributionModule;
|
|
16
|
-
/** Taxonomy
|
|
18
|
+
/** Taxonomy stack payload */
|
|
17
19
|
taxonomy?: TaxonomyModule;
|
|
18
|
-
/** Media
|
|
20
|
+
/** Media stack payload */
|
|
19
21
|
media?: MediaModule;
|
|
20
|
-
/** Times
|
|
22
|
+
/** Times stack payload */
|
|
21
23
|
times?: TimesModule;
|
|
22
24
|
/** Unique identifier (slug or UUID) */
|
|
23
25
|
id?: string;
|
|
@@ -254,32 +256,76 @@ interface ScaleRecipeOptions {
|
|
|
254
256
|
}
|
|
255
257
|
declare function scaleRecipe(recipe: Recipe, options?: ScaleRecipeOptions): Recipe;
|
|
256
258
|
|
|
257
|
-
type
|
|
258
|
-
interface
|
|
259
|
+
type ConformanceSeverity = "error" | "warning";
|
|
260
|
+
interface ConformanceIssue {
|
|
261
|
+
code: string;
|
|
259
262
|
path: string;
|
|
260
263
|
message: string;
|
|
261
|
-
|
|
264
|
+
severity: ConformanceSeverity;
|
|
262
265
|
}
|
|
263
|
-
|
|
266
|
+
|
|
267
|
+
type ProfileName = "base" | "equipped" | "illustrated" | "lite" | "prepped" | "scalable" | "timed" | "minimal" | "core";
|
|
268
|
+
interface NormalizedError {
|
|
264
269
|
path: string;
|
|
265
270
|
message: string;
|
|
271
|
+
keyword?: string;
|
|
266
272
|
}
|
|
273
|
+
/**
|
|
274
|
+
* Validation modes for recipe validation.
|
|
275
|
+
* - "schema": JSON Schema only
|
|
276
|
+
* - "full": JSON Schema + semantic conformance checks
|
|
277
|
+
*/
|
|
278
|
+
type ValidateMode = "schema" | "full";
|
|
267
279
|
interface ValidateOptions {
|
|
268
280
|
profile?: ProfileName;
|
|
269
281
|
schema?: string;
|
|
270
282
|
collectAllErrors?: boolean;
|
|
283
|
+
mode?: ValidateMode;
|
|
284
|
+
includeNormalized?: boolean;
|
|
271
285
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
286
|
+
/**
|
|
287
|
+
* Result payload for recipe validation. Schema validation always runs first;
|
|
288
|
+
* conformance issues are only included when running in full mode.
|
|
289
|
+
*/
|
|
290
|
+
interface ValidateResult {
|
|
291
|
+
ok: boolean;
|
|
292
|
+
schemaErrors: NormalizedError[];
|
|
293
|
+
conformanceIssues: ConformanceIssue[];
|
|
294
|
+
warnings: string[];
|
|
295
|
+
normalizedRecipe?: Recipe;
|
|
277
296
|
}
|
|
278
|
-
|
|
297
|
+
/**
|
|
298
|
+
* Legacy validateRecipe function - now uses the new validateRecipeSchema internally
|
|
299
|
+
* but maintains backward compatibility with profile/stack-based validation
|
|
300
|
+
* Also includes semantic conformance validation.
|
|
301
|
+
*/
|
|
302
|
+
/**
|
|
303
|
+
* Validates a recipe with explicit validation modes.
|
|
304
|
+
* - mode="schema": JSON Schema only
|
|
305
|
+
* - mode="full": schema + semantic conformance (only if schema passes)
|
|
306
|
+
*/
|
|
307
|
+
declare function validateRecipe(input: any, options?: ValidateOptions): ValidateResult;
|
|
279
308
|
declare function detectProfiles(recipe: any): ProfileName[];
|
|
280
309
|
|
|
281
310
|
declare function fromSchemaOrg(input: unknown): Recipe | null;
|
|
282
311
|
|
|
312
|
+
interface NormalizationResult {
|
|
313
|
+
recipe: Recipe;
|
|
314
|
+
warnings: string[];
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Normalizes a recipe input to the current spec format:
|
|
318
|
+
* - Rejects inputs with legacy field (unsupported)
|
|
319
|
+
* - Converts legacy `stacks` array format to map format
|
|
320
|
+
* - Ensures `stacks` exists even if empty
|
|
321
|
+
* - Preserves existing `stacks` map format
|
|
322
|
+
*
|
|
323
|
+
* @param input - Raw recipe input (may have legacy formats)
|
|
324
|
+
* @returns Normalized recipe with warnings for any issues encountered
|
|
325
|
+
* @throws Error if input contains legacy field
|
|
326
|
+
*/
|
|
327
|
+
declare function normalizeRecipe(input: unknown): NormalizationResult;
|
|
328
|
+
|
|
283
329
|
interface SchemaOrgRecipe$1 {
|
|
284
330
|
'@context'?: string | Array<string | Record<string, unknown>> | Record<string, unknown>;
|
|
285
331
|
'@type'?: string | string[];
|
|
@@ -352,8 +398,8 @@ interface NutritionInformation {
|
|
|
352
398
|
* Convert a Soustack recipe to Schema.org JSON-LD format.
|
|
353
399
|
*
|
|
354
400
|
* BREAKING CHANGE in v0.3.0: This function now targets the "minimal" profile
|
|
355
|
-
* and only includes
|
|
356
|
-
*
|
|
401
|
+
* and only includes stacks that are schemaOrgMappable (as defined in the
|
|
402
|
+
* stacks registry). Non-mappable stacks (e.g., nutrition@1, schedule@1)
|
|
357
403
|
* are excluded from the conversion.
|
|
358
404
|
*/
|
|
359
405
|
declare function toSchemaOrg(recipe: Recipe): SchemaOrgRecipe$1;
|
|
@@ -448,4 +494,4 @@ interface MiseEnPlacePlan {
|
|
|
448
494
|
}
|
|
449
495
|
declare function miseEnPlace(ingredients: Ingredient[]): MiseEnPlacePlan;
|
|
450
496
|
|
|
451
|
-
export { type Alternative, type AttributionModule, type ConvertMode, type ConvertTarget, type ConvertedLineItem, type Equipment, type FrozenStorageMethod, type Ingredient$1 as Ingredient, type IngredientItem, type IngredientSubsection, type Instruction, type InstructionItem, type InstructionSubsection, type LineItem, type MakeAheadComponent, type MediaModule, type Ingredient as MiseEnPlaceIngredient, type MiseEnPlacePlan, type Quantity as MiseEnPlaceQuantity, type MiseEnPlaceTask, MissingEquivalencyError, type NutritionFacts, type ParsedIngredient, type ParsedYield, type Quantity$1 as Quantity, type Recipe, type RoundMode, SOUSTACK_SPEC_VERSION, type Scaling, type ScalingBakersPercentage, type ScalingBase, type ScalingDiscrete, type ScalingFixed, type ScalingLinear, type ScalingProportional, type SimpleTime, type Source, type SoustackInstruction, type SoustackRecipe, type StepTiming, type Storage, type StorageMethod, type StructuredTime, type Substitution, type TaxonomyModule, type Time, type TimesModule, UnknownUnitError, UnsupportedConversionError, type Yield, convertLineItemToMetric, detectProfiles, extractSchemaOrgRecipeFromHTML, fromSchemaOrg, miseEnPlace, scaleRecipe, toSchemaOrg, validateRecipe };
|
|
497
|
+
export { type Alternative, type AttributionModule, type ConvertMode, type ConvertTarget, type ConvertedLineItem, type Equipment, type FrozenStorageMethod, type Ingredient$1 as Ingredient, type IngredientItem, type IngredientSubsection, type Instruction, type InstructionItem, type InstructionSubsection, type LineItem, type MakeAheadComponent, type MediaModule, type Ingredient as MiseEnPlaceIngredient, type MiseEnPlacePlan, type Quantity as MiseEnPlaceQuantity, type MiseEnPlaceTask, MissingEquivalencyError, type NormalizationResult, type NutritionFacts, type ParsedIngredient, type ParsedYield, type Quantity$1 as Quantity, type Recipe, type RoundMode, SOUSTACK_SPEC_VERSION, type Scaling, type ScalingBakersPercentage, type ScalingBase, type ScalingDiscrete, type ScalingFixed, type ScalingLinear, type ScalingProportional, type SimpleTime, type Source, type SoustackInstruction, type SoustackRecipe, type StepTiming, type Storage, type StorageMethod, type StructuredTime, type Substitution, type TaxonomyModule, type Time, type TimesModule, UnknownUnitError, UnsupportedConversionError, type ValidateMode, type ValidateResult, type Yield, convertLineItemToMetric, detectProfiles, extractSchemaOrgRecipeFromHTML, fromSchemaOrg, miseEnPlace, normalizeRecipe, scaleRecipe, toSchemaOrg, validateRecipe };
|
package/dist/index.d.ts
CHANGED
|
@@ -9,15 +9,17 @@ interface SoustackRecipe {
|
|
|
9
9
|
$schema?: string;
|
|
10
10
|
/** Optional declared validation profile */
|
|
11
11
|
profile?: string;
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
/**
|
|
12
|
+
/** Recipe level: "lite" or "base" */
|
|
13
|
+
level?: "lite" | "base";
|
|
14
|
+
/** Stack declarations as a map: Record<stackName, versionNumber> */
|
|
15
|
+
stacks?: Record<string, number>;
|
|
16
|
+
/** Attribution stack payload */
|
|
15
17
|
attribution?: AttributionModule;
|
|
16
|
-
/** Taxonomy
|
|
18
|
+
/** Taxonomy stack payload */
|
|
17
19
|
taxonomy?: TaxonomyModule;
|
|
18
|
-
/** Media
|
|
20
|
+
/** Media stack payload */
|
|
19
21
|
media?: MediaModule;
|
|
20
|
-
/** Times
|
|
22
|
+
/** Times stack payload */
|
|
21
23
|
times?: TimesModule;
|
|
22
24
|
/** Unique identifier (slug or UUID) */
|
|
23
25
|
id?: string;
|
|
@@ -254,32 +256,76 @@ interface ScaleRecipeOptions {
|
|
|
254
256
|
}
|
|
255
257
|
declare function scaleRecipe(recipe: Recipe, options?: ScaleRecipeOptions): Recipe;
|
|
256
258
|
|
|
257
|
-
type
|
|
258
|
-
interface
|
|
259
|
+
type ConformanceSeverity = "error" | "warning";
|
|
260
|
+
interface ConformanceIssue {
|
|
261
|
+
code: string;
|
|
259
262
|
path: string;
|
|
260
263
|
message: string;
|
|
261
|
-
|
|
264
|
+
severity: ConformanceSeverity;
|
|
262
265
|
}
|
|
263
|
-
|
|
266
|
+
|
|
267
|
+
type ProfileName = "base" | "equipped" | "illustrated" | "lite" | "prepped" | "scalable" | "timed" | "minimal" | "core";
|
|
268
|
+
interface NormalizedError {
|
|
264
269
|
path: string;
|
|
265
270
|
message: string;
|
|
271
|
+
keyword?: string;
|
|
266
272
|
}
|
|
273
|
+
/**
|
|
274
|
+
* Validation modes for recipe validation.
|
|
275
|
+
* - "schema": JSON Schema only
|
|
276
|
+
* - "full": JSON Schema + semantic conformance checks
|
|
277
|
+
*/
|
|
278
|
+
type ValidateMode = "schema" | "full";
|
|
267
279
|
interface ValidateOptions {
|
|
268
280
|
profile?: ProfileName;
|
|
269
281
|
schema?: string;
|
|
270
282
|
collectAllErrors?: boolean;
|
|
283
|
+
mode?: ValidateMode;
|
|
284
|
+
includeNormalized?: boolean;
|
|
271
285
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
286
|
+
/**
|
|
287
|
+
* Result payload for recipe validation. Schema validation always runs first;
|
|
288
|
+
* conformance issues are only included when running in full mode.
|
|
289
|
+
*/
|
|
290
|
+
interface ValidateResult {
|
|
291
|
+
ok: boolean;
|
|
292
|
+
schemaErrors: NormalizedError[];
|
|
293
|
+
conformanceIssues: ConformanceIssue[];
|
|
294
|
+
warnings: string[];
|
|
295
|
+
normalizedRecipe?: Recipe;
|
|
277
296
|
}
|
|
278
|
-
|
|
297
|
+
/**
|
|
298
|
+
* Legacy validateRecipe function - now uses the new validateRecipeSchema internally
|
|
299
|
+
* but maintains backward compatibility with profile/stack-based validation
|
|
300
|
+
* Also includes semantic conformance validation.
|
|
301
|
+
*/
|
|
302
|
+
/**
|
|
303
|
+
* Validates a recipe with explicit validation modes.
|
|
304
|
+
* - mode="schema": JSON Schema only
|
|
305
|
+
* - mode="full": schema + semantic conformance (only if schema passes)
|
|
306
|
+
*/
|
|
307
|
+
declare function validateRecipe(input: any, options?: ValidateOptions): ValidateResult;
|
|
279
308
|
declare function detectProfiles(recipe: any): ProfileName[];
|
|
280
309
|
|
|
281
310
|
declare function fromSchemaOrg(input: unknown): Recipe | null;
|
|
282
311
|
|
|
312
|
+
interface NormalizationResult {
|
|
313
|
+
recipe: Recipe;
|
|
314
|
+
warnings: string[];
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Normalizes a recipe input to the current spec format:
|
|
318
|
+
* - Rejects inputs with legacy field (unsupported)
|
|
319
|
+
* - Converts legacy `stacks` array format to map format
|
|
320
|
+
* - Ensures `stacks` exists even if empty
|
|
321
|
+
* - Preserves existing `stacks` map format
|
|
322
|
+
*
|
|
323
|
+
* @param input - Raw recipe input (may have legacy formats)
|
|
324
|
+
* @returns Normalized recipe with warnings for any issues encountered
|
|
325
|
+
* @throws Error if input contains legacy field
|
|
326
|
+
*/
|
|
327
|
+
declare function normalizeRecipe(input: unknown): NormalizationResult;
|
|
328
|
+
|
|
283
329
|
interface SchemaOrgRecipe$1 {
|
|
284
330
|
'@context'?: string | Array<string | Record<string, unknown>> | Record<string, unknown>;
|
|
285
331
|
'@type'?: string | string[];
|
|
@@ -352,8 +398,8 @@ interface NutritionInformation {
|
|
|
352
398
|
* Convert a Soustack recipe to Schema.org JSON-LD format.
|
|
353
399
|
*
|
|
354
400
|
* BREAKING CHANGE in v0.3.0: This function now targets the "minimal" profile
|
|
355
|
-
* and only includes
|
|
356
|
-
*
|
|
401
|
+
* and only includes stacks that are schemaOrgMappable (as defined in the
|
|
402
|
+
* stacks registry). Non-mappable stacks (e.g., nutrition@1, schedule@1)
|
|
357
403
|
* are excluded from the conversion.
|
|
358
404
|
*/
|
|
359
405
|
declare function toSchemaOrg(recipe: Recipe): SchemaOrgRecipe$1;
|
|
@@ -448,4 +494,4 @@ interface MiseEnPlacePlan {
|
|
|
448
494
|
}
|
|
449
495
|
declare function miseEnPlace(ingredients: Ingredient[]): MiseEnPlacePlan;
|
|
450
496
|
|
|
451
|
-
export { type Alternative, type AttributionModule, type ConvertMode, type ConvertTarget, type ConvertedLineItem, type Equipment, type FrozenStorageMethod, type Ingredient$1 as Ingredient, type IngredientItem, type IngredientSubsection, type Instruction, type InstructionItem, type InstructionSubsection, type LineItem, type MakeAheadComponent, type MediaModule, type Ingredient as MiseEnPlaceIngredient, type MiseEnPlacePlan, type Quantity as MiseEnPlaceQuantity, type MiseEnPlaceTask, MissingEquivalencyError, type NutritionFacts, type ParsedIngredient, type ParsedYield, type Quantity$1 as Quantity, type Recipe, type RoundMode, SOUSTACK_SPEC_VERSION, type Scaling, type ScalingBakersPercentage, type ScalingBase, type ScalingDiscrete, type ScalingFixed, type ScalingLinear, type ScalingProportional, type SimpleTime, type Source, type SoustackInstruction, type SoustackRecipe, type StepTiming, type Storage, type StorageMethod, type StructuredTime, type Substitution, type TaxonomyModule, type Time, type TimesModule, UnknownUnitError, UnsupportedConversionError, type Yield, convertLineItemToMetric, detectProfiles, extractSchemaOrgRecipeFromHTML, fromSchemaOrg, miseEnPlace, scaleRecipe, toSchemaOrg, validateRecipe };
|
|
497
|
+
export { type Alternative, type AttributionModule, type ConvertMode, type ConvertTarget, type ConvertedLineItem, type Equipment, type FrozenStorageMethod, type Ingredient$1 as Ingredient, type IngredientItem, type IngredientSubsection, type Instruction, type InstructionItem, type InstructionSubsection, type LineItem, type MakeAheadComponent, type MediaModule, type Ingredient as MiseEnPlaceIngredient, type MiseEnPlacePlan, type Quantity as MiseEnPlaceQuantity, type MiseEnPlaceTask, MissingEquivalencyError, type NormalizationResult, type NutritionFacts, type ParsedIngredient, type ParsedYield, type Quantity$1 as Quantity, type Recipe, type RoundMode, SOUSTACK_SPEC_VERSION, type Scaling, type ScalingBakersPercentage, type ScalingBase, type ScalingDiscrete, type ScalingFixed, type ScalingLinear, type ScalingProportional, type SimpleTime, type Source, type SoustackInstruction, type SoustackRecipe, type StepTiming, type Storage, type StorageMethod, type StructuredTime, type Substitution, type TaxonomyModule, type Time, type TimesModule, UnknownUnitError, UnsupportedConversionError, type ValidateMode, type ValidateResult, type Yield, convertLineItemToMetric, detectProfiles, extractSchemaOrgRecipeFromHTML, fromSchemaOrg, miseEnPlace, normalizeRecipe, scaleRecipe, toSchemaOrg, validateRecipe };
|