only_ever_generator 8.0.2 → 8.0.4

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 (91) hide show
  1. package/dist/bootstrap/app.d.ts +1 -1
  2. package/dist/bootstrap/app.d.ts.map +1 -1
  3. package/dist/bootstrap/app.js +1 -1
  4. package/dist/bootstrap/app.js.map +1 -1
  5. package/dist/card_gen/generate_cards.d.ts.map +1 -1
  6. package/dist/card_gen/generate_cards.js.map +1 -1
  7. package/dist/index.d.ts +2 -27
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +83 -46
  10. package/dist/index.js.map +1 -1
  11. package/package.json +1 -1
  12. package/src/bootstrap/app.ts +313 -0
  13. package/src/card_gen/generate_cards.ts +1 -0
  14. package/src/index.ts +95 -60
  15. package/MODULAR_REFACTORING_SUMMARY.md +0 -217
  16. package/README.md +0 -608
  17. package/dist/configs/card_generator_config.d.ts +0 -41
  18. package/dist/configs/card_generator_config.d.ts.map +0 -1
  19. package/dist/configs/card_generator_config.js +0 -17
  20. package/dist/configs/card_generator_config.js.map +0 -1
  21. package/dist/configs/concept_facts_generator_config.d.ts +0 -28
  22. package/dist/configs/concept_facts_generator_config.d.ts.map +0 -1
  23. package/dist/configs/concept_facts_generator_config.js +0 -12
  24. package/dist/configs/concept_facts_generator_config.js.map +0 -1
  25. package/dist/configs/consolidator_config.d.ts +0 -20
  26. package/dist/configs/consolidator_config.d.ts.map +0 -1
  27. package/dist/configs/consolidator_config.js +0 -14
  28. package/dist/configs/consolidator_config.js.map +0 -1
  29. package/dist/configs/embedding_generator_config.d.ts +0 -13
  30. package/dist/configs/embedding_generator_config.d.ts.map +0 -1
  31. package/dist/configs/embedding_generator_config.js +0 -11
  32. package/dist/configs/embedding_generator_config.js.map +0 -1
  33. package/dist/configs/parser_config.d.ts +0 -31
  34. package/dist/configs/parser_config.d.ts.map +0 -1
  35. package/dist/configs/parser_config.js +0 -26
  36. package/dist/configs/parser_config.js.map +0 -1
  37. package/dist/configs/typology_generator_config.d.ts +0 -26
  38. package/dist/configs/typology_generator_config.d.ts.map +0 -1
  39. package/dist/configs/typology_generator_config.js +0 -12
  40. package/dist/configs/typology_generator_config.js.map +0 -1
  41. package/dist/consolidation/global_consolidator.d.ts +0 -47
  42. package/dist/consolidation/global_consolidator.d.ts.map +0 -1
  43. package/dist/consolidation/global_consolidator.js +0 -94
  44. package/dist/consolidation/global_consolidator.js.map +0 -1
  45. package/dist/consolidation/local_consolidator.d.ts +0 -52
  46. package/dist/consolidation/local_consolidator.d.ts.map +0 -1
  47. package/dist/consolidation/local_consolidator.js +0 -118
  48. package/dist/consolidation/local_consolidator.js.map +0 -1
  49. package/dist/embeddings/embedding_generator.d.ts +0 -30
  50. package/dist/embeddings/embedding_generator.d.ts.map +0 -1
  51. package/dist/embeddings/embedding_generator.js +0 -71
  52. package/dist/embeddings/embedding_generator.js.map +0 -1
  53. package/dist/generators/card_generator.d.ts +0 -20
  54. package/dist/generators/card_generator.d.ts.map +0 -1
  55. package/dist/generators/card_generator.js +0 -239
  56. package/dist/generators/card_generator.js.map +0 -1
  57. package/dist/generators/concept_facts_generator.d.ts +0 -18
  58. package/dist/generators/concept_facts_generator.d.ts.map +0 -1
  59. package/dist/generators/concept_facts_generator.js +0 -153
  60. package/dist/generators/concept_facts_generator.js.map +0 -1
  61. package/dist/generators/typology_generator.d.ts +0 -20
  62. package/dist/generators/typology_generator.d.ts.map +0 -1
  63. package/dist/generators/typology_generator.js +0 -184
  64. package/dist/generators/typology_generator.js.map +0 -1
  65. package/dist/parsers/card_response_parser.d.ts +0 -16
  66. package/dist/parsers/card_response_parser.d.ts.map +0 -1
  67. package/dist/parsers/card_response_parser.js +0 -59
  68. package/dist/parsers/card_response_parser.js.map +0 -1
  69. package/dist/parsers/content_parser.d.ts +0 -27
  70. package/dist/parsers/content_parser.d.ts.map +0 -1
  71. package/dist/parsers/content_parser.js +0 -66
  72. package/dist/parsers/content_parser.js.map +0 -1
  73. package/dist/utils/validation.d.ts +0 -68
  74. package/dist/utils/validation.d.ts.map +0 -1
  75. package/dist/utils/validation.js +0 -203
  76. package/dist/utils/validation.js.map +0 -1
  77. package/src/configs/card_generator_config.ts +0 -58
  78. package/src/configs/concept_facts_generator_config.ts +0 -40
  79. package/src/configs/consolidator_config.ts +0 -33
  80. package/src/configs/embedding_generator_config.ts +0 -20
  81. package/src/configs/parser_config.ts +0 -57
  82. package/src/configs/typology_generator_config.ts +0 -38
  83. package/src/consolidation/global_consolidator.ts +0 -158
  84. package/src/consolidation/local_consolidator.ts +0 -173
  85. package/src/embeddings/embedding_generator.ts +0 -92
  86. package/src/generators/card_generator.ts +0 -258
  87. package/src/generators/concept_facts_generator.ts +0 -175
  88. package/src/generators/typology_generator.ts +0 -208
  89. package/src/parsers/card_response_parser.ts +0 -63
  90. package/src/parsers/content_parser.ts +0 -90
  91. package/src/utils/validation.ts +0 -298
@@ -1,90 +0,0 @@
1
- /**
2
- * Standalone ContentParser module
3
- * Parses and sanitizes source content
4
- */
5
-
6
- import { ParseSourceContent } from "../parse/parse_source_content";
7
- import {
8
- ContentParserConfig,
9
- DEFAULT_CONTENT_PARSER_CONFIG,
10
- } from "../configs/parser_config";
11
- import { validateContentType } from "../utils/validation";
12
-
13
- export interface ParsedContent {
14
- source_id: string;
15
- type: string;
16
- title: string;
17
- content: any[];
18
- headings: string[];
19
- taxonomy?: any;
20
- }
21
-
22
- export class ContentParser {
23
- private config: ContentParserConfig;
24
-
25
- constructor(config: ContentParserConfig) {
26
- this.validateConfig(config);
27
- this.config = { ...DEFAULT_CONTENT_PARSER_CONFIG, ...config };
28
- }
29
-
30
- /**
31
- * Parse raw content into structured format
32
- */
33
- parse(rawContent: any): ParsedContent {
34
- // Create a custom ParseSourceContent instance with our config
35
- const parser = new ParseSourceContent(rawContent);
36
-
37
- // Override the default titles and block types if provided
38
- if (this.config.titlesToRemove) {
39
- parser.titles_to_remove = this.config.titlesToRemove;
40
- }
41
-
42
- if (this.config.blockTypesToRemove) {
43
- parser.block_types_toremove = this.config.blockTypesToRemove;
44
- }
45
-
46
- const parsedData = parser.parseData();
47
-
48
- return {
49
- source_id: parsedData.source_id,
50
- type: parsedData.type,
51
- title: parsedData.title,
52
- content: parsedData.content,
53
- headings: parsedData.headings,
54
- taxonomy: parsedData.taxonomy,
55
- };
56
- }
57
-
58
- /**
59
- * Parse video content with timecode collapsing
60
- */
61
- parseVideoContent(rawContent: any): ParsedContent {
62
- const parser = new ParseSourceContent(rawContent);
63
-
64
- // Override the collapse timecodes method if max duration is specified
65
- if (this.config.maxTimecodeDuration) {
66
- const originalCollapseTimeCodes = parser.collapseTimeCodes.bind(parser);
67
- parser.collapseTimeCodes = (
68
- data: any[],
69
- maxDuration = this.config.maxTimecodeDuration
70
- ) => {
71
- return originalCollapseTimeCodes(data, maxDuration);
72
- };
73
- }
74
-
75
- const parsedData = parser.parseData();
76
-
77
- return {
78
- source_id: parsedData.source_id,
79
- type: parsedData.type,
80
- title: parsedData.title,
81
- content: parsedData.content,
82
- headings: parsedData.headings,
83
- taxonomy: parsedData.taxonomy,
84
- };
85
- }
86
-
87
- private validateConfig(config: ContentParserConfig): void {
88
- validateContentType(config.type);
89
- }
90
- }
@@ -1,298 +0,0 @@
1
- /**
2
- * Input validation utilities for OnlyEver Generator
3
- */
4
-
5
- export class ValidationError extends Error {
6
- constructor(message: string, public field?: string) {
7
- super(message);
8
- this.name = "ValidationError";
9
- }
10
- }
11
-
12
- /**
13
- * Validates that a value is not null or undefined
14
- */
15
- export function validateRequired<T>(
16
- value: T | null | undefined,
17
- fieldName: string
18
- ): T {
19
- if (value === null || value === undefined) {
20
- throw new ValidationError(`${fieldName} is required`, fieldName);
21
- }
22
- return value;
23
- }
24
-
25
- /**
26
- * Validates that a string is not empty
27
- */
28
- export function validateNonEmptyString(
29
- value: string | null | undefined,
30
- fieldName: string
31
- ): string {
32
- const validated = validateRequired(value, fieldName);
33
- if (typeof validated !== "string" || validated.trim().length === 0) {
34
- throw new ValidationError(
35
- `${fieldName} must be a non-empty string`,
36
- fieldName
37
- );
38
- }
39
- return validated;
40
- }
41
-
42
- /**
43
- * Validates that a value is a positive number
44
- */
45
- export function validatePositiveNumber(
46
- value: number | null | undefined,
47
- fieldName: string
48
- ): number {
49
- const validated = validateRequired(value, fieldName);
50
- if (typeof validated !== "number" || validated <= 0) {
51
- throw new ValidationError(
52
- `${fieldName} must be a positive number`,
53
- fieldName
54
- );
55
- }
56
- return validated;
57
- }
58
-
59
- /**
60
- * Validates that a number is within a range
61
- */
62
- export function validateNumberRange(
63
- value: number | null | undefined,
64
- fieldName: string,
65
- min: number,
66
- max: number
67
- ): number {
68
- const validated = validateRequired(value, fieldName);
69
- if (typeof validated !== "number" || validated < min || validated > max) {
70
- throw new ValidationError(
71
- `${fieldName} must be between ${min} and ${max}`,
72
- fieldName
73
- );
74
- }
75
- return validated;
76
- }
77
-
78
- /**
79
- * Validates that a value is one of the allowed values
80
- */
81
- export function validateEnum<T extends string>(
82
- value: T | null | undefined,
83
- fieldName: string,
84
- allowedValues: readonly T[]
85
- ): T {
86
- const validated = validateRequired(value, fieldName);
87
- if (!allowedValues.includes(validated)) {
88
- throw new ValidationError(
89
- `${fieldName} must be one of: ${allowedValues.join(", ")}`,
90
- fieldName
91
- );
92
- }
93
- return validated;
94
- }
95
-
96
- /**
97
- * Validates that a value is an array with at least one element
98
- */
99
- export function validateNonEmptyArray<T>(
100
- value: T[] | null | undefined,
101
- fieldName: string
102
- ): T[] {
103
- const validated = validateRequired(value, fieldName);
104
- if (!Array.isArray(validated) || validated.length === 0) {
105
- throw new ValidationError(
106
- `${fieldName} must be a non-empty array`,
107
- fieldName
108
- );
109
- }
110
- return validated;
111
- }
112
-
113
- /**
114
- * Validates OpenAI API key format
115
- */
116
- export function validateOpenAIKey(apiKey: string | null | undefined): string {
117
- const validated = validateNonEmptyString(apiKey, "OpenAI API key");
118
-
119
- // Basic format validation for OpenAI API keys
120
- if (!validated.startsWith("sk-")) {
121
- throw new ValidationError('OpenAI API key must start with "sk-"', "apiKey");
122
- }
123
-
124
- if (validated.length < 20) {
125
- throw new ValidationError(
126
- "OpenAI API key appears to be too short",
127
- "apiKey"
128
- );
129
- }
130
-
131
- return validated;
132
- }
133
-
134
- /**
135
- * Validates OpenAI model name
136
- */
137
- export function validateOpenAIModel(model: string | null | undefined): string {
138
- const validated = validateNonEmptyString(model, "OpenAI model");
139
-
140
- // Common OpenAI model patterns
141
- const validModels = [
142
- "gpt-4o",
143
- "gpt-4o-mini",
144
- "gpt-4",
145
- "gpt-4-turbo",
146
- "gpt-3.5-turbo",
147
- "gpt-3.5-turbo-16k",
148
- ];
149
-
150
- if (!validModels.some((validModel) => validated.startsWith(validModel))) {
151
- console.warn(
152
- `Model "${validated}" may not be a valid OpenAI model. Valid models include: ${validModels.join(
153
- ", "
154
- )}`
155
- );
156
- }
157
-
158
- return validated;
159
- }
160
-
161
- /**
162
- * Validates prompt ID format
163
- */
164
- export function validatePromptId(
165
- promptId: string | null | undefined,
166
- fieldName: string
167
- ): string {
168
- const validated = validateNonEmptyString(promptId, fieldName);
169
-
170
- // Basic format validation for prompt IDs
171
- if (!validated.startsWith("pmpt_")) {
172
- throw new ValidationError(
173
- `${fieldName} must start with "pmpt_"`,
174
- fieldName
175
- );
176
- }
177
-
178
- if (validated.length < 10) {
179
- throw new ValidationError(
180
- `${fieldName} appears to be too short`,
181
- fieldName
182
- );
183
- }
184
-
185
- return validated;
186
- }
187
-
188
- /**
189
- * Validates content type
190
- */
191
- export function validateContentType(type: string | null | undefined): string {
192
- return validateEnum(type, "content type", ["text", "video"] as const);
193
- }
194
-
195
- /**
196
- * Validates source ID format
197
- */
198
- export function validateSourceId(sourceId: string | null | undefined): string {
199
- const validated = validateNonEmptyString(sourceId, "source ID");
200
-
201
- // Basic validation - should be a reasonable length
202
- if (validated.length < 3) {
203
- throw new ValidationError(
204
- "Source ID must be at least 3 characters long",
205
- "sourceId"
206
- );
207
- }
208
-
209
- return validated;
210
- }
211
-
212
- /**
213
- * Validates similarity threshold
214
- */
215
- export function validateSimilarityThreshold(
216
- threshold: number | null | undefined,
217
- fieldName: string
218
- ): number {
219
- return validateNumberRange(threshold, fieldName, 0, 1);
220
- }
221
-
222
- /**
223
- * Validates embedding dimensions
224
- */
225
- export function validateEmbeddingDimensions(
226
- dimensions: number | null | undefined
227
- ): number {
228
- const validated = validateRequired(dimensions, "embedding dimensions");
229
-
230
- // Common embedding dimensions
231
- const validDimensions = [128, 256, 512, 768, 1024, 1536, 2048];
232
-
233
- if (!validDimensions.includes(validated)) {
234
- console.warn(
235
- `Embedding dimensions ${validated} may not be standard. Common values: ${validDimensions.join(
236
- ", "
237
- )}`
238
- );
239
- }
240
-
241
- return validated;
242
- }
243
-
244
- /**
245
- * Validates that an object has required properties
246
- */
247
- export function validateObjectProperties<T extends Record<string, any>>(
248
- obj: T | null | undefined,
249
- fieldName: string,
250
- requiredProperties: (keyof T)[]
251
- ): T {
252
- const validated = validateRequired(obj, fieldName);
253
-
254
- for (const prop of requiredProperties) {
255
- if (
256
- !(prop in validated) ||
257
- validated[prop] === null ||
258
- validated[prop] === undefined
259
- ) {
260
- throw new ValidationError(
261
- `${fieldName} must have property "${String(prop)}"`,
262
- fieldName
263
- );
264
- }
265
- }
266
-
267
- return validated;
268
- }
269
-
270
- /**
271
- * Validates array of strings
272
- */
273
- export function validateStringArray(
274
- value: string[] | null | undefined,
275
- fieldName: string,
276
- allowEmpty: boolean = true
277
- ): string[] {
278
- const validated = validateRequired(value, fieldName);
279
-
280
- if (!Array.isArray(validated)) {
281
- throw new ValidationError(`${fieldName} must be an array`, fieldName);
282
- }
283
-
284
- if (!allowEmpty && validated.length === 0) {
285
- throw new ValidationError(`${fieldName} must not be empty`, fieldName);
286
- }
287
-
288
- for (let i = 0; i < validated.length; i++) {
289
- if (typeof validated[i] !== "string") {
290
- throw new ValidationError(
291
- `${fieldName}[${i}] must be a string`,
292
- fieldName
293
- );
294
- }
295
- }
296
-
297
- return validated;
298
- }