@pie-qti/transform-core 0.1.1 → 0.1.5

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 (129) hide show
  1. package/dist/config/config-loader.d.ts +25 -0
  2. package/dist/config/config-loader.d.ts.map +1 -0
  3. package/dist/config/config-loader.js +142 -0
  4. package/dist/config/config-loader.js.map +1 -0
  5. package/dist/config/plugin-loader.d.ts +19 -0
  6. package/dist/config/plugin-loader.d.ts.map +1 -0
  7. package/dist/config/plugin-loader.js +62 -0
  8. package/dist/config/plugin-loader.js.map +1 -0
  9. package/dist/config/vendor-registry.d.ts +21 -0
  10. package/dist/config/vendor-registry.d.ts.map +1 -0
  11. package/dist/config/vendor-registry.js +91 -0
  12. package/dist/config/vendor-registry.js.map +1 -0
  13. package/dist/detectors/pie-detector.d.ts +19 -0
  14. package/dist/detectors/pie-detector.d.ts.map +1 -0
  15. package/dist/detectors/pie-detector.js +46 -0
  16. package/dist/detectors/pie-detector.js.map +1 -0
  17. package/dist/detectors/qti-detector.d.ts +20 -0
  18. package/dist/detectors/qti-detector.d.ts.map +1 -0
  19. package/dist/detectors/qti-detector.js +34 -0
  20. package/dist/detectors/qti-detector.js.map +1 -0
  21. package/dist/detectors/qti22-detector.d.ts +20 -0
  22. package/dist/detectors/qti22-detector.d.ts.map +1 -0
  23. package/dist/detectors/qti22-detector.js +34 -0
  24. package/dist/detectors/qti22-detector.js.map +1 -0
  25. package/dist/engine/index.d.ts +1 -1
  26. package/dist/engine/index.d.ts.map +1 -1
  27. package/dist/engine/index.js +1 -1
  28. package/dist/engine/index.js.map +1 -1
  29. package/dist/engine/transform-engine.d.ts +27 -10
  30. package/dist/engine/transform-engine.d.ts.map +1 -1
  31. package/dist/engine/transform-engine.js +96 -85
  32. package/dist/engine/transform-engine.js.map +1 -1
  33. package/dist/index.d.ts +8 -1
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +11 -1
  36. package/dist/index.js.map +1 -1
  37. package/dist/orchestration/activities/detect-format-activity.d.ts +18 -0
  38. package/dist/orchestration/activities/detect-format-activity.d.ts.map +1 -0
  39. package/dist/orchestration/activities/detect-format-activity.js +51 -0
  40. package/dist/orchestration/activities/detect-format-activity.js.map +1 -0
  41. package/dist/orchestration/activities/detect-vendor-activity.d.ts +25 -0
  42. package/dist/orchestration/activities/detect-vendor-activity.d.ts.map +1 -0
  43. package/dist/orchestration/activities/detect-vendor-activity.js +27 -0
  44. package/dist/orchestration/activities/detect-vendor-activity.js.map +1 -0
  45. package/dist/orchestration/activities/index.d.ts +18 -0
  46. package/dist/orchestration/activities/index.d.ts.map +1 -0
  47. package/dist/orchestration/activities/index.js +11 -0
  48. package/dist/orchestration/activities/index.js.map +1 -0
  49. package/dist/orchestration/activities/parse-xml-activity.d.ts +18 -0
  50. package/dist/orchestration/activities/parse-xml-activity.d.ts.map +1 -0
  51. package/dist/orchestration/activities/parse-xml-activity.js +37 -0
  52. package/dist/orchestration/activities/parse-xml-activity.js.map +1 -0
  53. package/dist/orchestration/activities/read-content-activity.d.ts +24 -0
  54. package/dist/orchestration/activities/read-content-activity.d.ts.map +1 -0
  55. package/dist/orchestration/activities/read-content-activity.js +49 -0
  56. package/dist/orchestration/activities/read-content-activity.js.map +1 -0
  57. package/dist/orchestration/activities/transform-qti-to-pie-activity.d.ts +23 -0
  58. package/dist/orchestration/activities/transform-qti-to-pie-activity.d.ts.map +1 -0
  59. package/dist/orchestration/activities/transform-qti-to-pie-activity.js +48 -0
  60. package/dist/orchestration/activities/transform-qti-to-pie-activity.js.map +1 -0
  61. package/dist/orchestration/activities/validate-qti-activity.d.ts +19 -0
  62. package/dist/orchestration/activities/validate-qti-activity.d.ts.map +1 -0
  63. package/dist/orchestration/activities/validate-qti-activity.js +47 -0
  64. package/dist/orchestration/activities/validate-qti-activity.js.map +1 -0
  65. package/dist/orchestration/activities/write-content-activity.d.ts +22 -0
  66. package/dist/orchestration/activities/write-content-activity.d.ts.map +1 -0
  67. package/dist/orchestration/activities/write-content-activity.js +36 -0
  68. package/dist/orchestration/activities/write-content-activity.js.map +1 -0
  69. package/dist/orchestration/in-memory-orchestrator.d.ts +44 -0
  70. package/dist/orchestration/in-memory-orchestrator.d.ts.map +1 -0
  71. package/dist/orchestration/in-memory-orchestrator.js +375 -0
  72. package/dist/orchestration/in-memory-orchestrator.js.map +1 -0
  73. package/dist/orchestration/index.d.ts +7 -0
  74. package/dist/orchestration/index.d.ts.map +1 -0
  75. package/dist/orchestration/index.js +10 -0
  76. package/dist/orchestration/index.js.map +1 -0
  77. package/dist/orchestration/workflows/batch-transform-workflow.d.ts +58 -0
  78. package/dist/orchestration/workflows/batch-transform-workflow.d.ts.map +1 -0
  79. package/dist/orchestration/workflows/batch-transform-workflow.js +100 -0
  80. package/dist/orchestration/workflows/batch-transform-workflow.js.map +1 -0
  81. package/dist/orchestration/workflows/index.d.ts +8 -0
  82. package/dist/orchestration/workflows/index.d.ts.map +1 -0
  83. package/dist/orchestration/workflows/index.js +6 -0
  84. package/dist/orchestration/workflows/index.js.map +1 -0
  85. package/dist/orchestration/workflows/transform-item-workflow.d.ts +57 -0
  86. package/dist/orchestration/workflows/transform-item-workflow.d.ts.map +1 -0
  87. package/dist/orchestration/workflows/transform-item-workflow.js +148 -0
  88. package/dist/orchestration/workflows/transform-item-workflow.js.map +1 -0
  89. package/dist/registry/format-detector-registry.d.ts +55 -0
  90. package/dist/registry/format-detector-registry.d.ts.map +1 -0
  91. package/dist/registry/format-detector-registry.js +55 -0
  92. package/dist/registry/format-detector-registry.js.map +1 -0
  93. package/dist/registry/index.d.ts +1 -1
  94. package/dist/registry/index.d.ts.map +1 -1
  95. package/dist/registry/index.js +1 -1
  96. package/dist/registry/index.js.map +1 -1
  97. package/dist/registry/plugin-registry.d.ts +1 -0
  98. package/dist/registry/plugin-registry.d.ts.map +1 -1
  99. package/dist/registry/plugin-registry.js +6 -2
  100. package/dist/registry/plugin-registry.js.map +1 -1
  101. package/dist/utils/errors.d.ts +79 -0
  102. package/dist/utils/errors.d.ts.map +1 -0
  103. package/dist/utils/errors.js +159 -0
  104. package/dist/utils/errors.js.map +1 -0
  105. package/dist/utils/index.d.ts +1 -1
  106. package/dist/utils/index.d.ts.map +1 -1
  107. package/dist/utils/index.js +1 -1
  108. package/dist/utils/index.js.map +1 -1
  109. package/dist/utils/logger.d.ts +9 -37
  110. package/dist/utils/logger.d.ts.map +1 -1
  111. package/dist/utils/logger.js +10 -58
  112. package/dist/utils/logger.js.map +1 -1
  113. package/package.json +69 -36
  114. package/.turbo/turbo-build.log +0 -1
  115. package/CHANGELOG.md +0 -10
  116. package/VALIDATION.md +0 -217
  117. package/src/engine/index.ts +0 -1
  118. package/src/engine/transform-engine.ts +0 -257
  119. package/src/index.ts +0 -18
  120. package/src/registry/index.ts +0 -1
  121. package/src/registry/plugin-registry.ts +0 -116
  122. package/src/utils/index.ts +0 -1
  123. package/src/utils/logger.ts +0 -79
  124. package/src/utils/validator.ts +0 -193
  125. package/tests/plugin-registry.test.ts +0 -154
  126. package/tests/transform-engine.test.ts +0 -168
  127. package/tests/validator.test.ts +0 -234
  128. package/tsconfig.json +0 -13
  129. package/tsconfig.tsbuildinfo +0 -1
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Transform Item Workflow
3
+ *
4
+ * Orchestrates the transformation of a single QTI item to PIE format
5
+ */
6
+ import type { WorkflowDefinition, TransformFormat, TransformPlugin, TransformContext, StorageBackend } from '@pie-qti/transform-types';
7
+ export interface TransformItemInput {
8
+ /** Source content (XML string or URI to read from) */
9
+ content: string;
10
+ /** Item identifier */
11
+ itemId: string;
12
+ /** Source format (if known, otherwise will be detected) */
13
+ sourceFormat?: TransformFormat;
14
+ /** Target format */
15
+ targetFormat: TransformFormat;
16
+ /** Transform plugin to use */
17
+ plugin: TransformPlugin;
18
+ /** Transform context */
19
+ context: TransformContext;
20
+ /** Storage backend (if content is a URI) */
21
+ storage?: StorageBackend;
22
+ /** Output URI (if content should be written) */
23
+ outputUri?: string;
24
+ /** Skip validation */
25
+ skipValidation?: boolean;
26
+ }
27
+ export interface TransformItemOutput {
28
+ /** Transformed PIE configuration */
29
+ pieConfig: unknown;
30
+ /** Warnings from transformation */
31
+ warnings: unknown[];
32
+ /** Validation errors (if any) */
33
+ errors: string[];
34
+ /** Transformation metadata */
35
+ metadata: {
36
+ sourceFormat: TransformFormat;
37
+ targetFormat: TransformFormat;
38
+ itemId: string;
39
+ timestamp: Date;
40
+ processingTime: number;
41
+ vendorDetected?: string;
42
+ };
43
+ }
44
+ /**
45
+ * Workflow for transforming a single QTI item to PIE
46
+ *
47
+ * Steps:
48
+ * 1. Read content (if URI provided)
49
+ * 2. Detect format (if not provided)
50
+ * 3. Validate QTI (optional)
51
+ * 4. Parse XML
52
+ * 5. Detect vendor
53
+ * 6. Transform QTI to PIE
54
+ * 7. Write output (if outputUri provided)
55
+ */
56
+ export declare const TransformItemWorkflow: WorkflowDefinition<TransformItemInput, TransformItemOutput>;
57
+ //# sourceMappingURL=transform-item-workflow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform-item-workflow.d.ts","sourceRoot":"","sources":["../../../src/orchestration/workflows/transform-item-workflow.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,eAAe,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAWvI,MAAM,WAAW,kBAAkB;IACjC,sDAAsD;IACtD,OAAO,EAAE,MAAM,CAAC;IAChB,sBAAsB;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,2DAA2D;IAC3D,YAAY,CAAC,EAAE,eAAe,CAAC;IAC/B,oBAAoB;IACpB,YAAY,EAAE,eAAe,CAAC;IAC9B,8BAA8B;IAC9B,MAAM,EAAE,eAAe,CAAC;IACxB,wBAAwB;IACxB,OAAO,EAAE,gBAAgB,CAAC;IAC1B,4CAA4C;IAC5C,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,gDAAgD;IAChD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sBAAsB;IACtB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,mBAAmB;IAClC,oCAAoC;IACpC,SAAS,EAAE,OAAO,CAAC;IACnB,mCAAmC;IACnC,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,iCAAiC;IACjC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,8BAA8B;IAC9B,QAAQ,EAAE;QACR,YAAY,EAAE,eAAe,CAAC;QAC9B,YAAY,EAAE,eAAe,CAAC;QAC9B,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,IAAI,CAAC;QAChB,cAAc,EAAE,MAAM,CAAC;QACvB,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC;CACH;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,qBAAqB,EAAE,kBAAkB,CAAC,kBAAkB,EAAE,mBAAmB,CAqJ7F,CAAC"}
@@ -0,0 +1,148 @@
1
+ /**
2
+ * Transform Item Workflow
3
+ *
4
+ * Orchestrates the transformation of a single QTI item to PIE format
5
+ */
6
+ import { DetectFormatActivity, DetectVendorActivity, ParseXmlActivity, ReadContentActivity, TransformQtiToPieActivity, ValidateQtiActivity, WriteContentActivity, } from '../activities/index.js';
7
+ /**
8
+ * Workflow for transforming a single QTI item to PIE
9
+ *
10
+ * Steps:
11
+ * 1. Read content (if URI provided)
12
+ * 2. Detect format (if not provided)
13
+ * 3. Validate QTI (optional)
14
+ * 4. Parse XML
15
+ * 5. Detect vendor
16
+ * 6. Transform QTI to PIE
17
+ * 7. Write output (if outputUri provided)
18
+ */
19
+ export const TransformItemWorkflow = {
20
+ type: 'transform-item',
21
+ version: '1.0',
22
+ name: 'Transform QTI Item to PIE',
23
+ async execute(ctx, input) {
24
+ const startTime = ctx.now();
25
+ ctx.log('info', `Starting transformation workflow for item: ${input.itemId}`);
26
+ ctx.reportProgress({
27
+ currentStep: 'initialization',
28
+ completedSteps: 0,
29
+ totalSteps: input.skipValidation ? 6 : 7,
30
+ percentage: 0,
31
+ message: 'Initializing transformation',
32
+ });
33
+ // Step 1: Read content if URI provided
34
+ let xml = input.content;
35
+ if (input.storage && input.content.startsWith('storage://')) {
36
+ ctx.reportProgress({
37
+ currentStep: 'read-content',
38
+ completedSteps: 0,
39
+ totalSteps: input.skipValidation ? 6 : 7,
40
+ percentage: 0,
41
+ message: 'Reading content from storage',
42
+ });
43
+ const readResult = await ctx.executeActivity(ReadContentActivity, {
44
+ uri: input.content,
45
+ storage: input.storage,
46
+ });
47
+ xml = readResult.content;
48
+ }
49
+ // Step 2: Detect format if not provided
50
+ const sourceFormat = input.sourceFormat || (await ctx.executeActivity(DetectFormatActivity, {
51
+ content: xml,
52
+ })).format;
53
+ ctx.log('info', `Source format: ${sourceFormat}`);
54
+ // Step 3: Validate QTI (optional)
55
+ const errors = [];
56
+ if (!input.skipValidation && sourceFormat.startsWith('qti')) {
57
+ ctx.reportProgress({
58
+ currentStep: 'validate-qti',
59
+ completedSteps: 1,
60
+ totalSteps: 7,
61
+ percentage: 14,
62
+ message: 'Validating QTI content',
63
+ });
64
+ const validation = await ctx.executeActivity(ValidateQtiActivity, { xml });
65
+ if (!validation.valid) {
66
+ errors.push(...validation.errors);
67
+ ctx.log('warn', `Validation found ${validation.errors.length} errors`);
68
+ }
69
+ }
70
+ // Step 4: Parse XML
71
+ ctx.reportProgress({
72
+ currentStep: 'parse-xml',
73
+ completedSteps: input.skipValidation ? 1 : 2,
74
+ totalSteps: input.skipValidation ? 6 : 7,
75
+ percentage: input.skipValidation ? 17 : 29,
76
+ message: 'Parsing XML',
77
+ });
78
+ const { doc } = await ctx.executeActivity(ParseXmlActivity, { xml });
79
+ // Step 5: Detect vendor
80
+ ctx.reportProgress({
81
+ currentStep: 'detect-vendor',
82
+ completedSteps: input.skipValidation ? 2 : 3,
83
+ totalSteps: input.skipValidation ? 6 : 7,
84
+ percentage: input.skipValidation ? 33 : 43,
85
+ message: 'Detecting vendor',
86
+ });
87
+ const { vendorInfo } = await ctx.executeActivity(DetectVendorActivity, { xml, doc });
88
+ // Step 6: Transform QTI to PIE
89
+ ctx.reportProgress({
90
+ currentStep: 'transform',
91
+ completedSteps: input.skipValidation ? 3 : 4,
92
+ totalSteps: input.skipValidation ? 6 : 7,
93
+ percentage: input.skipValidation ? 50 : 57,
94
+ message: 'Transforming to PIE',
95
+ });
96
+ const { pieConfig, warnings } = await ctx.executeActivity(TransformQtiToPieActivity, {
97
+ xml,
98
+ itemId: input.itemId,
99
+ vendorInfo,
100
+ plugin: input.plugin,
101
+ context: input.context,
102
+ });
103
+ // Step 7: Write output (if outputUri provided)
104
+ if (input.outputUri && input.storage) {
105
+ ctx.reportProgress({
106
+ currentStep: 'write-output',
107
+ completedSteps: input.skipValidation ? 4 : 5,
108
+ totalSteps: input.skipValidation ? 6 : 7,
109
+ percentage: input.skipValidation ? 67 : 71,
110
+ message: 'Writing output',
111
+ });
112
+ await ctx.executeActivity(WriteContentActivity, {
113
+ uri: input.outputUri,
114
+ content: JSON.stringify(pieConfig, null, 2),
115
+ storage: input.storage,
116
+ });
117
+ }
118
+ // Complete
119
+ ctx.reportProgress({
120
+ currentStep: 'complete',
121
+ completedSteps: input.skipValidation ? 6 : 7,
122
+ totalSteps: input.skipValidation ? 6 : 7,
123
+ percentage: 100,
124
+ message: 'Transformation complete',
125
+ });
126
+ const endTime = ctx.now();
127
+ const processingTime = endTime.getTime() - startTime.getTime();
128
+ ctx.log('info', `Transformation complete in ${processingTime}ms`);
129
+ return {
130
+ pieConfig,
131
+ warnings,
132
+ errors,
133
+ metadata: {
134
+ sourceFormat,
135
+ targetFormat: input.targetFormat,
136
+ itemId: input.itemId,
137
+ timestamp: endTime,
138
+ processingTime,
139
+ vendorDetected: vendorInfo?.vendor,
140
+ },
141
+ };
142
+ },
143
+ timeout: {
144
+ workflowTimeout: 300000, // 5 minutes
145
+ activityTimeout: 120000, // 2 minutes
146
+ },
147
+ };
148
+ //# sourceMappingURL=transform-item-workflow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform-item-workflow.js","sourceRoot":"","sources":["../../../src/orchestration/workflows/transform-item-workflow.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,gBAAgB,EAChB,mBAAmB,EACnB,yBAAyB,EACzB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,wBAAwB,CAAC;AAyChC;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAgE;IAChG,IAAI,EAAE,gBAAgB;IACtB,OAAO,EAAE,KAAK;IACd,IAAI,EAAE,2BAA2B;IAEjC,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK;QACtB,MAAM,SAAS,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC;QAC5B,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,8CAA8C,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;QAE9E,GAAG,CAAC,cAAc,CAAC;YACjB,WAAW,EAAE,gBAAgB;YAC7B,cAAc,EAAE,CAAC;YACjB,UAAU,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACxC,UAAU,EAAE,CAAC;YACb,OAAO,EAAE,6BAA6B;SACvC,CAAC,CAAC;QAEH,uCAAuC;QACvC,IAAI,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC;QACxB,IAAI,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;YAC5D,GAAG,CAAC,cAAc,CAAC;gBACjB,WAAW,EAAE,cAAc;gBAC3B,cAAc,EAAE,CAAC;gBACjB,UAAU,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACxC,UAAU,EAAE,CAAC;gBACb,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AyB;SACnC,CAAC,CAAC;QAEH,MAAM,OAAO,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC;QAC1B,MAAM,cAAc,GAAG,OAAO,CAAC,OAAO,EAAE,GAAG,SAAS,CAAC,OAAO,EAAE,CAAC;QAE/D,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,8BAA8B,cAAc,IAAI,CAAC,CAAC;QAElE,OAAO;YACL,SAAS;YACT,QAAQ;YACR,MAAM;YACN,QAAQ,EAAE;gBACR,YAAY;gBACZ,YAAY,EAAE,KAAK,CAAC,YAAY;gBAChC,MAAM,EAAE,KAAK,CAAC,MAAM;gBACpB,SAAS,EAAE,OAAO;gBAClB,cAAc;gBACd,cAAc,EAAE,UAAU,EAAE,MAAM;aACnC;SACF,CAAC;IACJ,CAAC;IAED,OAAO,EAAE;QACP,eAAe,EAAE,MAAM,EAAE,YAAY;QACrC,eAAe,EAAE,MAAM,EAAE,YAAY;KACtC;CACF,CAAC"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Format Detector Registry
3
+ * Priority-based registry for pluggable format detection
4
+ */
5
+ import type { TransformFormat } from '@pie-qti/transform-types';
6
+ /**
7
+ * Format detector interface
8
+ * Detects if input matches a specific format
9
+ */
10
+ export interface FormatDetector {
11
+ /** Unique identifier for this detector */
12
+ readonly id: string;
13
+ /** Format ID this detector identifies */
14
+ readonly formatId: TransformFormat;
15
+ /**
16
+ * Priority for detection order
17
+ * Higher priority detectors are checked first
18
+ */
19
+ readonly priority: number;
20
+ /**
21
+ * Detect if input matches this format
22
+ * @param input Input content (string or object)
23
+ * @returns true if format matches, false otherwise
24
+ */
25
+ detect(input: string | object): boolean | Promise<boolean>;
26
+ }
27
+ /**
28
+ * Registry for format detectors
29
+ * Maintains priority-ordered list of format detectors
30
+ */
31
+ export declare class FormatDetectorRegistry {
32
+ private detectors;
33
+ /**
34
+ * Register a format detector
35
+ * Detectors are automatically sorted by priority
36
+ */
37
+ register(detector: FormatDetector): void;
38
+ /**
39
+ * Detect format of input
40
+ * Tries each detector in priority order until one matches
41
+ * @param input Input content to detect
42
+ * @returns Format ID if detected, null if no match
43
+ */
44
+ detectFormat(input: string | object): Promise<TransformFormat | null>;
45
+ /**
46
+ * Get all registered detectors
47
+ * @returns Array of registered detectors (sorted by priority)
48
+ */
49
+ getDetectors(): ReadonlyArray<FormatDetector>;
50
+ /**
51
+ * Clear all registered detectors
52
+ */
53
+ clear(): void;
54
+ }
55
+ //# sourceMappingURL=format-detector-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-detector-registry.d.ts","sourceRoot":"","sources":["../../src/registry/format-detector-registry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAEhE;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC9B,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAEpB,yCAAyC;IACzC,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAC;IAEnC;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC3D;AAED;;;GAGG;AACH,qBAAa,sBAAsB;IAClC,OAAO,CAAC,SAAS,CAAwB;IAEzC;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI;IAMxC;;;;;OAKG;IACG,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;IAe3E;;;OAGG;IACH,YAAY,IAAI,aAAa,CAAC,cAAc,CAAC;IAI7C;;OAEG;IACH,KAAK,IAAI,IAAI;CAGb"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Format Detector Registry
3
+ * Priority-based registry for pluggable format detection
4
+ */
5
+ /**
6
+ * Registry for format detectors
7
+ * Maintains priority-ordered list of format detectors
8
+ */
9
+ export class FormatDetectorRegistry {
10
+ detectors = [];
11
+ /**
12
+ * Register a format detector
13
+ * Detectors are automatically sorted by priority
14
+ */
15
+ register(detector) {
16
+ this.detectors.push(detector);
17
+ // Sort by priority (highest first)
18
+ this.detectors.sort((a, b) => b.priority - a.priority);
19
+ }
20
+ /**
21
+ * Detect format of input
22
+ * Tries each detector in priority order until one matches
23
+ * @param input Input content to detect
24
+ * @returns Format ID if detected, null if no match
25
+ */
26
+ async detectFormat(input) {
27
+ for (const detector of this.detectors) {
28
+ try {
29
+ const matches = await detector.detect(input);
30
+ if (matches) {
31
+ return detector.formatId;
32
+ }
33
+ }
34
+ catch (error) {
35
+ // Detector error - skip to next detector
36
+ console.warn(`Format detector ${detector.id} failed:`, error);
37
+ }
38
+ }
39
+ return null;
40
+ }
41
+ /**
42
+ * Get all registered detectors
43
+ * @returns Array of registered detectors (sorted by priority)
44
+ */
45
+ getDetectors() {
46
+ return this.detectors;
47
+ }
48
+ /**
49
+ * Clear all registered detectors
50
+ */
51
+ clear() {
52
+ this.detectors = [];
53
+ }
54
+ }
55
+ //# sourceMappingURL=format-detector-registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-detector-registry.js","sourceRoot":"","sources":["../../src/registry/format-detector-registry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA6BH;;;GAGG;AACH,MAAM,OAAO,sBAAsB;IAC1B,SAAS,GAAqB,EAAE,CAAC;IAEzC;;;OAGG;IACH,QAAQ,CAAC,QAAwB;QAChC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC9B,mCAAmC;QACnC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC;IACxD,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,YAAY,CAAC,KAAsB;QACxC,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACvC,IAAI,CAAC;gBACJ,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBAC7C,IAAI,OAAO,EAAE,CAAC;oBACb,OAAO,QAAQ,CAAC,QAAQ,CAAC;gBAC1B,CAAC;YACF,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,yCAAyC;gBACzC,OAAO,CAAC,IAAI,CAAC,mBAAmB,QAAQ,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;YAC/D,CAAC;QACF,CAAC;QACD,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;;OAGG;IACH,YAAY;QACX,OAAO,IAAI,CAAC,SAAS,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,KAAK;QACJ,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;IACrB,CAAC;CACD"}
@@ -1,2 +1,2 @@
1
- export * from './plugin-registry';
1
+ export * from './plugin-registry.js';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/registry/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/registry/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
@@ -1,2 +1,2 @@
1
- export * from './plugin-registry';
1
+ export * from './plugin-registry.js';
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/registry/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/registry/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
@@ -28,6 +28,7 @@ export declare class PluginRegistry {
28
28
  getAll(): TransformPlugin[];
29
29
  /**
30
30
  * Find plugin that can handle transformation from source to target format
31
+ * If multiple plugins match, returns the one with highest priority
31
32
  */
32
33
  findPlugin(sourceFormat: TransformFormat, targetFormat: TransformFormat): TransformPlugin | undefined;
33
34
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-registry.d.ts","sourceRoot":"","sources":["../../src/registry/plugin-registry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,eAAe,EAChB,MAAM,0BAA0B,CAAC;AAElC,qBAAa,cAAc;IACzB,OAAO,CAAC,OAAO,CAAsC;IAErD;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI;IAQvC;;OAEG;IACH,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAIrC;;OAEG;IACH,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS;IAIlD;;OAEG;IACH,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAI9B;;OAEG;IACH,MAAM,IAAI,eAAe,EAAE;IAI3B;;OAEG;IACH,UAAU,CACR,YAAY,EAAE,eAAe,EAC7B,YAAY,EAAE,eAAe,GAC5B,eAAe,GAAG,SAAS;IAQ9B;;OAEG;IACG,qBAAqB,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAa9E;;OAEG;IACH,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,eAAe,EAAE;IAM7D;;OAEG;IACH,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,eAAe,EAAE;IAM7D;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;CACF"}
1
+ {"version":3,"file":"plugin-registry.d.ts","sourceRoot":"","sources":["../../src/registry/plugin-registry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,eAAe,EAChB,MAAM,0BAA0B,CAAC;AAElC,qBAAa,cAAc;IACzB,OAAO,CAAC,OAAO,CAAsC;IAErD;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI;IAQvC;;OAEG;IACH,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAIrC;;OAEG;IACH,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS;IAIlD;;OAEG;IACH,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAI9B;;OAEG;IACH,MAAM,IAAI,eAAe,EAAE;IAI3B;;;OAGG;IACH,UAAU,CACR,YAAY,EAAE,eAAe,EAC7B,YAAY,EAAE,eAAe,GAC5B,eAAe,GAAG,SAAS;IAY9B;;OAEG;IACG,qBAAqB,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAa9E;;OAEG;IACH,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,eAAe,EAAE;IAM7D;;OAEG;IACH,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,eAAe,EAAE;IAM7D;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;CACF"}
@@ -40,10 +40,14 @@ export class PluginRegistry {
40
40
  }
41
41
  /**
42
42
  * Find plugin that can handle transformation from source to target format
43
+ * If multiple plugins match, returns the one with highest priority
43
44
  */
44
45
  findPlugin(sourceFormat, targetFormat) {
45
- return Array.from(this.plugins.values()).find((plugin) => plugin.sourceFormat === sourceFormat &&
46
- plugin.targetFormat === targetFormat);
46
+ const candidates = Array.from(this.plugins.values())
47
+ .filter((plugin) => plugin.sourceFormat === sourceFormat &&
48
+ plugin.targetFormat === targetFormat)
49
+ .sort((a, b) => (b.priority ?? 100) - (a.priority ?? 100));
50
+ return candidates[0];
47
51
  }
48
52
  /**
49
53
  * Find plugins that can handle the given input
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-registry.js","sourceRoot":"","sources":["../../src/registry/plugin-registry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,MAAM,OAAO,cAAc;IACjB,OAAO,GAAG,IAAI,GAAG,EAA2B,CAAC;IAErD;;OAEG;IACH,QAAQ,CAAC,MAAuB;QAC9B,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,mBAAmB,MAAM,CAAC,EAAE,yBAAyB,CAAC,CAAC;QACzE,CAAC;QAED,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IACtC,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,QAAgB;QACzB,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC;IAED;;OAEG;IACH,GAAG,CAAC,QAAgB;QAClB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACpC,CAAC;IAED;;OAEG;IACH,GAAG,CAAC,QAAgB;QAClB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACpC,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED;;OAEG;IACH,UAAU,CACR,YAA6B,EAC7B,YAA6B;QAE7B,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAC3C,CAAC,MAAM,EAAE,EAAE,CACT,MAAM,CAAC,YAAY,KAAK,YAAY;YACpC,M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AC;IAED;;OAEG;IACH,KAAK,CAAC,qBAAqB,CAAC,KAAqB;QAC/C,MAAM,UAAU,GAAsB,EAAE,CAAC;QAEzC,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;YAC3C,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;YAChD,IAAI,SAAS,EAAE,CAAC;gBACd,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC;QAED,OAAO,UAAU,CAAC;IACpB,CAAC;IAED;;OAEG;IACH,iBAAiB,CAAC,MAAuB;QACvC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAC7C,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,YAAY,KAAK,MAAM,CAC3C,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,iBAAiB,CAAC,MAAuB;QACvC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAC7C,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,YAAY,KAAK,MAAM,CAC3C,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;IAC3B,CAAC;CACF"}
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Error Utilities
3
+ * Helpers for creating and handling categorized transform errors
4
+ */
5
+ import type { TransformError } from '@pie-qti/transform-types';
6
+ import { ErrorCategory } from '@pie-qti/transform-types';
7
+ /**
8
+ * Options for creating a transform error
9
+ */
10
+ export interface CreateErrorOptions {
11
+ message: string;
12
+ code?: string;
13
+ itemId?: string;
14
+ category: ErrorCategory;
15
+ recoverable?: boolean;
16
+ cause?: Error;
17
+ context?: Record<string, unknown>;
18
+ }
19
+ /**
20
+ * Create a categorized transform error
21
+ */
22
+ export declare function createError(options: CreateErrorOptions): TransformError;
23
+ /**
24
+ * Create a validation error (user input issue)
25
+ */
26
+ export declare function createValidationError(message: string, options?: Partial<Omit<CreateErrorOptions, 'message' | 'category'>>): TransformError;
27
+ /**
28
+ * Create a configuration error (setup issue)
29
+ */
30
+ export declare function createConfigurationError(message: string, options?: Partial<Omit<CreateErrorOptions, 'message' | 'category'>>): TransformError;
31
+ /**
32
+ * Create an internal error (bug or unexpected state)
33
+ */
34
+ export declare function createInternalError(message: string, options?: Partial<Omit<CreateErrorOptions, 'message' | 'category'>>): TransformError;
35
+ /**
36
+ * Create an external error (service/network failure)
37
+ */
38
+ export declare function createExternalError(message: string, options?: Partial<Omit<CreateErrorOptions, 'message' | 'category'>>): TransformError;
39
+ /**
40
+ * Check if error should be retried
41
+ */
42
+ export declare function shouldRetry(error: TransformError): boolean;
43
+ /**
44
+ * Check if error should be shown to user
45
+ */
46
+ export declare function shouldShowToUser(error: TransformError): boolean;
47
+ /**
48
+ * Check if error requires ops team notification
49
+ */
50
+ export declare function shouldNotifyOps(error: TransformError): boolean;
51
+ /**
52
+ * Get suggested action for error
53
+ */
54
+ export declare function getSuggestedAction(error: TransformError): string;
55
+ /**
56
+ * Wrap a caught error as a TransformError
57
+ */
58
+ export declare function wrapError(caught: unknown, category: ErrorCategory, context?: Record<string, unknown>): TransformError;
59
+ /**
60
+ * Format error for logging
61
+ */
62
+ export declare function formatError(error: TransformError): string;
63
+ /**
64
+ * Check if error is validation error
65
+ */
66
+ export declare function isValidationError(error: TransformError): boolean;
67
+ /**
68
+ * Check if error is configuration error
69
+ */
70
+ export declare function isConfigurationError(error: TransformError): boolean;
71
+ /**
72
+ * Check if error is internal error
73
+ */
74
+ export declare function isInternalError(error: TransformError): boolean;
75
+ /**
76
+ * Check if error is external error
77
+ */
78
+ export declare function isExternalError(error: TransformError): boolean;
79
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,aAAa,CAAC;IACxB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,cAAc,CAUvE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACpC,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,kBAAkB,EAAE,SAAS,GAAG,UAAU,CAAC,CAAC,GACjE,cAAc,CAOhB;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACvC,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,kBAAkB,EAAE,SAAS,GAAG,UAAU,CAAC,CAAC,GACjE,cAAc,CAOhB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAClC,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,kBAAkB,EAAE,SAAS,GAAG,UAAU,CAAC,CAAC,GACjE,cAAc,CAOhB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAClC,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,kBAAkB,EAAE,SAAS,GAAG,UAAU,CAAC,CAAC,GACjE,cAAc,CAOhB;AAgBD;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAE1D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAE/D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAK9D;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,CAWhE;AAED;;GAEG;AACH,wBAAgB,SAAS,CACxB,MAAM,EAAE,OAAO,EACf,QAAQ,EAAE,aAAa,EACvB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,cAAc,CAShB;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,CASzD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAEhE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAEnE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAE9D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAE9D"}
@@ -0,0 +1,159 @@
1
+ /**
2
+ * Error Utilities
3
+ * Helpers for creating and handling categorized transform errors
4
+ */
5
+ import { ErrorCategory } from '@pie-qti/transform-types';
6
+ /**
7
+ * Create a categorized transform error
8
+ */
9
+ export function createError(options) {
10
+ return {
11
+ message: options.message,
12
+ code: options.code,
13
+ itemId: options.itemId,
14
+ category: options.category,
15
+ recoverable: options.recoverable ?? isRecoverableByDefault(options.category),
16
+ cause: options.cause,
17
+ context: options.context,
18
+ };
19
+ }
20
+ /**
21
+ * Create a validation error (user input issue)
22
+ */
23
+ export function createValidationError(message, options) {
24
+ return createError({
25
+ message,
26
+ category: ErrorCategory.VALIDATION,
27
+ recoverable: true,
28
+ ...options,
29
+ });
30
+ }
31
+ /**
32
+ * Create a configuration error (setup issue)
33
+ */
34
+ export function createConfigurationError(message, options) {
35
+ return createError({
36
+ message,
37
+ category: ErrorCategory.CONFIGURATION,
38
+ recoverable: false,
39
+ ...options,
40
+ });
41
+ }
42
+ /**
43
+ * Create an internal error (bug or unexpected state)
44
+ */
45
+ export function createInternalError(message, options) {
46
+ return createError({
47
+ message,
48
+ category: ErrorCategory.INTERNAL,
49
+ recoverable: false,
50
+ ...options,
51
+ });
52
+ }
53
+ /**
54
+ * Create an external error (service/network failure)
55
+ */
56
+ export function createExternalError(message, options) {
57
+ return createError({
58
+ message,
59
+ category: ErrorCategory.EXTERNAL,
60
+ recoverable: true,
61
+ ...options,
62
+ });
63
+ }
64
+ /**
65
+ * Check if error is recoverable by default based on category
66
+ */
67
+ function isRecoverableByDefault(category) {
68
+ switch (category) {
69
+ case ErrorCategory.VALIDATION:
70
+ case ErrorCategory.EXTERNAL:
71
+ return true;
72
+ case ErrorCategory.CONFIGURATION:
73
+ case ErrorCategory.INTERNAL:
74
+ return false;
75
+ }
76
+ }
77
+ /**
78
+ * Check if error should be retried
79
+ */
80
+ export function shouldRetry(error) {
81
+ return error.recoverable && error.category === ErrorCategory.EXTERNAL;
82
+ }
83
+ /**
84
+ * Check if error should be shown to user
85
+ */
86
+ export function shouldShowToUser(error) {
87
+ return error.category === ErrorCategory.VALIDATION;
88
+ }
89
+ /**
90
+ * Check if error requires ops team notification
91
+ */
92
+ export function shouldNotifyOps(error) {
93
+ return (error.category === ErrorCategory.CONFIGURATION ||
94
+ error.category === ErrorCategory.INTERNAL);
95
+ }
96
+ /**
97
+ * Get suggested action for error
98
+ */
99
+ export function getSuggestedAction(error) {
100
+ switch (error.category) {
101
+ case ErrorCategory.VALIDATION:
102
+ return 'Fix the input and try again';
103
+ case ErrorCategory.CONFIGURATION:
104
+ return 'Check configuration and credentials';
105
+ case ErrorCategory.INTERNAL:
106
+ return 'Contact support with error details';
107
+ case ErrorCategory.EXTERNAL:
108
+ return 'Retry the operation after a delay';
109
+ }
110
+ }
111
+ /**
112
+ * Wrap a caught error as a TransformError
113
+ */
114
+ export function wrapError(caught, category, context) {
115
+ const cause = caught instanceof Error ? caught : new Error(String(caught));
116
+ return createError({
117
+ message: cause.message,
118
+ category,
119
+ cause,
120
+ context,
121
+ });
122
+ }
123
+ /**
124
+ * Format error for logging
125
+ */
126
+ export function formatError(error) {
127
+ const parts = [
128
+ `[${error.category.toUpperCase()}]`,
129
+ error.code ? `[${error.code}]` : '',
130
+ error.itemId ? `[item:${error.itemId}]` : '',
131
+ error.message,
132
+ ];
133
+ return parts.filter(Boolean).join(' ');
134
+ }
135
+ /**
136
+ * Check if error is validation error
137
+ */
138
+ export function isValidationError(error) {
139
+ return error.category === ErrorCategory.VALIDATION;
140
+ }
141
+ /**
142
+ * Check if error is configuration error
143
+ */
144
+ export function isConfigurationError(error) {
145
+ return error.category === ErrorCategory.CONFIGURATION;
146
+ }
147
+ /**
148
+ * Check if error is internal error
149
+ */
150
+ export function isInternalError(error) {
151
+ return error.category === ErrorCategory.INTERNAL;
152
+ }
153
+ /**
154
+ * Check if error is external error
155
+ */
156
+ export function isExternalError(error) {
157
+ return error.category === ErrorCategory.EXTERNAL;
158
+ }
159
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAezD;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,OAA2B;IACtD,OAAO;QACN,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,IAAI,EAAE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