lens-content-processor 0.3.0 → 0.5.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.
Files changed (78) hide show
  1. package/dist/bundler/article.d.ts +7 -2
  2. package/dist/bundler/article.js +19 -8
  3. package/dist/bundler/article.js.map +1 -1
  4. package/dist/bundler/video.d.ts +12 -6
  5. package/dist/bundler/video.js +57 -34
  6. package/dist/bundler/video.js.map +1 -1
  7. package/dist/cli.d.ts +11 -2
  8. package/dist/cli.js +36 -19
  9. package/dist/cli.js.map +1 -1
  10. package/dist/content-schema.js +64 -15
  11. package/dist/content-schema.js.map +1 -1
  12. package/dist/dedupe-errors.d.ts +14 -0
  13. package/dist/dedupe-errors.js +33 -0
  14. package/dist/dedupe-errors.js.map +1 -0
  15. package/dist/flattener/index.d.ts +22 -28
  16. package/dist/flattener/index.js +773 -613
  17. package/dist/flattener/index.js.map +1 -1
  18. package/dist/flattener/resolve-text-links.d.ts +25 -0
  19. package/dist/flattener/resolve-text-links.js +248 -0
  20. package/dist/flattener/resolve-text-links.js.map +1 -0
  21. package/dist/flattener/test-helpers.d.ts +23 -0
  22. package/dist/flattener/test-helpers.js +56 -0
  23. package/dist/flattener/test-helpers.js.map +1 -0
  24. package/dist/index.d.ts +66 -20
  25. package/dist/index.js +327 -152
  26. package/dist/index.js.map +1 -1
  27. package/dist/parser/article.d.ts +3 -2
  28. package/dist/parser/article.js +80 -12
  29. package/dist/parser/article.js.map +1 -1
  30. package/dist/parser/course.d.ts +1 -1
  31. package/dist/parser/course.js +88 -28
  32. package/dist/parser/course.js.map +1 -1
  33. package/dist/parser/frontmatter.d.ts +1 -1
  34. package/dist/parser/frontmatter.js +38 -12
  35. package/dist/parser/frontmatter.js.map +1 -1
  36. package/dist/parser/learning-outcome.d.ts +12 -2
  37. package/dist/parser/learning-outcome.js +177 -96
  38. package/dist/parser/learning-outcome.js.map +1 -1
  39. package/dist/parser/lens.d.ts +52 -28
  40. package/dist/parser/lens.js +283 -260
  41. package/dist/parser/lens.js.map +1 -1
  42. package/dist/parser/module.d.ts +7 -15
  43. package/dist/parser/module.js +139 -170
  44. package/dist/parser/module.js.map +1 -1
  45. package/dist/parser/sections.d.ts +14 -1
  46. package/dist/parser/sections.js +94 -81
  47. package/dist/parser/sections.js.map +1 -1
  48. package/dist/parser/video-transcript.d.ts +2 -1
  49. package/dist/parser/video-transcript.js +10 -6
  50. package/dist/parser/video-transcript.js.map +1 -1
  51. package/dist/reference-graph.d.ts +8 -0
  52. package/dist/reference-graph.js +105 -0
  53. package/dist/reference-graph.js.map +1 -0
  54. package/dist/validator/card-module-membership.d.ts +2 -0
  55. package/dist/validator/card-module-membership.js +80 -0
  56. package/dist/validator/card-module-membership.js.map +1 -0
  57. package/dist/validator/directives.d.ts +12 -0
  58. package/dist/validator/directives.js +428 -0
  59. package/dist/validator/directives.js.map +1 -0
  60. package/dist/validator/field-values.js +14 -0
  61. package/dist/validator/field-values.js.map +1 -1
  62. package/dist/validator/output-integrity.js +5 -5
  63. package/dist/validator/output-integrity.js.map +1 -1
  64. package/dist/validator/segment-fields.d.ts +1 -1
  65. package/dist/validator/segment-fields.js +2 -2
  66. package/dist/validator/segment-fields.js.map +1 -1
  67. package/dist/validator/test-segments.d.ts +12 -0
  68. package/dist/validator/test-segments.js +40 -0
  69. package/dist/validator/test-segments.js.map +1 -0
  70. package/dist/validator/url-reachability.d.ts +2 -1
  71. package/dist/validator/url-reachability.js +42 -20
  72. package/dist/validator/url-reachability.js.map +1 -1
  73. package/dist/validator/uuid.js +9 -6
  74. package/dist/validator/uuid.js.map +1 -1
  75. package/package.json +1 -1
  76. package/dist/validator/chat-precedence.d.ts +0 -9
  77. package/dist/validator/chat-precedence.js +0 -32
  78. package/dist/validator/chat-precedence.js.map +0 -1
@@ -0,0 +1,14 @@
1
+ import type { ContentError } from "./index.js";
2
+ /**
3
+ * Collapse duplicate errors that point at the same problem.
4
+ *
5
+ * A single content file is validated more than once per run: a learning
6
+ * outcome is parsed standalone AND again every time a module that references
7
+ * it is flattened (the flattener re-parses referenced LOs). Each pass runs the
8
+ * same parse code on the same content, so an identical error is emitted once
9
+ * per pass — e.g. one mistake in an LO referenced by one module surfaces twice.
10
+ *
11
+ * Authors should see each problem once. Dedupe on (file, line, severity,
12
+ * message), keeping the first occurrence so report order is stable.
13
+ */
14
+ export declare function dedupeErrors(errors: ContentError[]): ContentError[];
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Collapse duplicate errors that point at the same problem.
3
+ *
4
+ * A single content file is validated more than once per run: a learning
5
+ * outcome is parsed standalone AND again every time a module that references
6
+ * it is flattened (the flattener re-parses referenced LOs). Each pass runs the
7
+ * same parse code on the same content, so an identical error is emitted once
8
+ * per pass — e.g. one mistake in an LO referenced by one module surfaces twice.
9
+ *
10
+ * Authors should see each problem once. Dedupe on (file, line, severity,
11
+ * message), keeping the first occurrence so report order is stable.
12
+ */
13
+ export function dedupeErrors(errors) {
14
+ const seen = new Set();
15
+ const deduped = [];
16
+ for (const error of errors) {
17
+ // \x1f (unit separator) joins the fields: file paths and messages can
18
+ // themselves contain spaces, so a printable separator could let two
19
+ // distinct errors collapse to the same key.
20
+ const key = [
21
+ error.file,
22
+ error.line ?? "",
23
+ error.severity,
24
+ error.message,
25
+ ].join("\x1f");
26
+ if (seen.has(key))
27
+ continue;
28
+ seen.add(key);
29
+ deduped.push(error);
30
+ }
31
+ return deduped;
32
+ }
33
+ //# sourceMappingURL=dedupe-errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dedupe-errors.js","sourceRoot":"","sources":["../src/dedupe-errors.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,YAAY,CAAC,MAAsB;IACjD,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,MAAM,OAAO,GAAmB,EAAE,CAAC;IAEnC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,sEAAsE;QACtE,oEAAoE;QACpE,4CAA4C;QAC5C,MAAM,GAAG,GAAG;YACV,KAAK,CAAC,IAAI;YACV,KAAK,CAAC,IAAI,IAAI,EAAE;YAChB,KAAK,CAAC,QAAQ;YACd,KAAK,CAAC,OAAO;SACd,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACf,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,SAAS;QAC5B,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACd,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -1,40 +1,34 @@
1
- import type { FlattenedModule, ContentError } from '../index.js';
2
- import type { ContentTier } from '../validator/tier.js';
3
- import { type ParsedLens } from '../parser/lens.js';
1
+ import type { FlattenedModule, Section, ContentError } from "../index.js";
2
+ import type { ContentTier } from "../validator/tier.js";
3
+ import { type ParsedLens } from "../parser/lens.js";
4
4
  export interface FlattenModuleResult {
5
5
  module: FlattenedModule | null;
6
+ modules: FlattenedModule[];
6
7
  errors: ContentError[];
7
8
  }
9
+ export type BoundaryMarker = {
10
+ __boundary: true;
11
+ title: string;
12
+ customSlug?: string;
13
+ };
14
+ export type FlatItem = Section | BoundaryMarker;
15
+ export declare function isBoundary(item: FlatItem): item is BoundaryMarker;
16
+ export declare function validateBoundaries(items: FlatItem[], file: string): ContentError[];
17
+ interface VirtualModuleGroup {
18
+ slug: string;
19
+ title: string;
20
+ parentSlug: string;
21
+ parentTitle: string;
22
+ sections: Section[];
23
+ contentId: string | null;
24
+ }
25
+ export declare function splitAtBoundaries(items: FlatItem[], parentSlug: string, parentTitle: string): VirtualModuleGroup[];
8
26
  /**
9
27
  * Flatten a module by resolving all references to Learning Outcomes, Lenses, and content.
10
- *
11
- * This function:
12
- * 1. Parses the module file
13
- * 2. For each Learning Outcome section, resolves the LO file
14
- * 3. For each Lens in the LO, resolves the lens file
15
- * 4. For each segment, extracts content from articles/videos as needed
16
- *
17
- * @param modulePath - Path to the module file within the files Map
18
- * @param files - Map of all file paths to their content
19
- * @param visitedPaths - Optional set of already-visited paths for cycle detection
20
- * @returns Flattened module with resolved sections and segments, plus any errors
21
28
  */
22
29
  export declare function flattenModule(modulePath: string, files: Map<string, string>, visitedPaths?: Set<string>, tierMap?: Map<string, ContentTier>): FlattenModuleResult;
23
30
  /**
24
31
  * Flatten a single Lens file into a FlattenedModule.
25
- *
26
- * This wraps a standalone Lens as a single-section module so it can be
27
- * rendered by the frontend using the existing Module.tsx component.
28
- *
29
- * The resulting module has:
30
- * - slug: 'lens/' + fileNameToSlug(lensPath)
31
- * - title: extracted from source metadata or lens header
32
- * - sections: exactly one section (lens-article, lens-video, or page)
33
- *
34
- * @param lensPath - Path to the lens file within the files Map
35
- * @param files - Map of all file paths to their content
36
- * @param tierMap - Optional tier map for filtering ignored content
37
- * @param preParsedLens - Optional pre-parsed lens to avoid re-parsing
38
- * @returns Flattened module with a single section, plus any errors
39
32
  */
40
33
  export declare function flattenLens(lensPath: string, files: Map<string, string>, tierMap?: Map<string, ContentTier>, preParsedLens?: ParsedLens): FlattenModuleResult;
34
+ export {};