my-frontend-observer 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 (77) hide show
  1. package/CHANGELOG.md +112 -0
  2. package/README.md +59 -7
  3. package/dist/application/comparisonService.d.ts +56 -0
  4. package/dist/application/comparisonService.js +77 -0
  5. package/dist/application/comparisonService.js.map +1 -0
  6. package/dist/application/frontendContractEvaluationService.d.ts +49 -0
  7. package/dist/application/frontendContractEvaluationService.js +112 -0
  8. package/dist/application/frontendContractEvaluationService.js.map +1 -0
  9. package/dist/application/frontendContractPersistenceService.d.ts +56 -0
  10. package/dist/application/frontendContractPersistenceService.js +91 -0
  11. package/dist/application/frontendContractPersistenceService.js.map +1 -0
  12. package/dist/artifacts/artifactReader.d.ts +19 -0
  13. package/dist/artifacts/artifactReader.js +36 -0
  14. package/dist/artifacts/artifactReader.js.map +1 -0
  15. package/dist/artifacts/comparisonArtifactReader.d.ts +18 -0
  16. package/dist/artifacts/comparisonArtifactReader.js +35 -0
  17. package/dist/artifacts/comparisonArtifactReader.js.map +1 -0
  18. package/dist/artifacts/comparisonArtifactWriter.d.ts +41 -0
  19. package/dist/artifacts/comparisonArtifactWriter.js +67 -0
  20. package/dist/artifacts/comparisonArtifactWriter.js.map +1 -0
  21. package/dist/artifacts/frontendContractArtifactReader.d.ts +24 -0
  22. package/dist/artifacts/frontendContractArtifactReader.js +47 -0
  23. package/dist/artifacts/frontendContractArtifactReader.js.map +1 -0
  24. package/dist/artifacts/frontendContractArtifactWriter.d.ts +34 -0
  25. package/dist/artifacts/frontendContractArtifactWriter.js +70 -0
  26. package/dist/artifacts/frontendContractArtifactWriter.js.map +1 -0
  27. package/dist/artifacts/frontendContractEvaluationArtifactReader.d.ts +17 -0
  28. package/dist/artifacts/frontendContractEvaluationArtifactReader.js +34 -0
  29. package/dist/artifacts/frontendContractEvaluationArtifactReader.js.map +1 -0
  30. package/dist/artifacts/frontendContractEvaluationArtifactWriter.d.ts +32 -0
  31. package/dist/artifacts/frontendContractEvaluationArtifactWriter.js +58 -0
  32. package/dist/artifacts/frontendContractEvaluationArtifactWriter.js.map +1 -0
  33. package/dist/cli.js +712 -3
  34. package/dist/cli.js.map +1 -1
  35. package/dist/domain/comparison.d.ts +198 -0
  36. package/dist/domain/comparison.js +324 -0
  37. package/dist/domain/comparison.js.map +1 -0
  38. package/dist/domain/comparisonEngine.d.ts +48 -0
  39. package/dist/domain/comparisonEngine.js +694 -0
  40. package/dist/domain/comparisonEngine.js.map +1 -0
  41. package/dist/domain/comparisonIdentity.d.ts +13 -0
  42. package/dist/domain/comparisonIdentity.js +46 -0
  43. package/dist/domain/comparisonIdentity.js.map +1 -0
  44. package/dist/domain/evidence.d.ts +2 -0
  45. package/dist/domain/evidence.js +4 -0
  46. package/dist/domain/evidence.js.map +1 -1
  47. package/dist/domain/frontendContractEvaluation.d.ts +57 -0
  48. package/dist/domain/frontendContractEvaluation.js +454 -0
  49. package/dist/domain/frontendContractEvaluation.js.map +1 -0
  50. package/dist/domain/frontendContractEvaluationArtifact.d.ts +65 -0
  51. package/dist/domain/frontendContractEvaluationArtifact.js +108 -0
  52. package/dist/domain/frontendContractEvaluationArtifact.js.map +1 -0
  53. package/dist/domain/frontendContractIdentity.d.ts +39 -0
  54. package/dist/domain/frontendContractIdentity.js +70 -0
  55. package/dist/domain/frontendContractIdentity.js.map +1 -0
  56. package/dist/domain/frontendContracts.d.ts +188 -0
  57. package/dist/domain/frontendContracts.js +260 -0
  58. package/dist/domain/frontendContracts.js.map +1 -0
  59. package/dist/domain/relationships.d.ts +168 -0
  60. package/dist/domain/relationships.js +343 -0
  61. package/dist/domain/relationships.js.map +1 -0
  62. package/dist/index.d.ts +36 -1
  63. package/dist/index.js +20 -1
  64. package/dist/index.js.map +1 -1
  65. package/docs/ARCHITECTURE.md +173 -3
  66. package/docs/CI_CD.md +76 -0
  67. package/docs/COMMANDS.md +299 -0
  68. package/docs/CONTRACTS.md +270 -6
  69. package/docs/CURRENT_STATE.md +183 -8
  70. package/docs/DEVELOPMENT.md +83 -12
  71. package/docs/PROJECT_OVERVIEW.md +18 -8
  72. package/docs/QUICKSTART.md +10 -0
  73. package/docs/RELEASE.md +17 -8
  74. package/docs/ROADMAP.md +10 -0
  75. package/docs/SECURITY.md +26 -1
  76. package/docs/WORKFLOWS.md +113 -6
  77. package/package.json +1 -1
@@ -0,0 +1,58 @@
1
+ import { mkdir, writeFile, rename, rm, access } from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ import { isValidFrontendContractEvaluationArtifact } from '../domain/frontendContractEvaluationArtifact.js';
4
+ import { DIAGNOSTIC_SEVERITY } from '../domain/diagnostics.js';
5
+ export const EVALUATION_MANIFEST_FILENAME = 'manifest.json';
6
+ function writeFailure(message, details) {
7
+ const diagnostic = {
8
+ code: 'artifact-write-failure',
9
+ severity: DIAGNOSTIC_SEVERITY['artifact-write-failure'],
10
+ message,
11
+ ...(details === undefined ? {} : { details }),
12
+ };
13
+ return { ok: false, diagnostics: [diagnostic] };
14
+ }
15
+ async function pathExists(candidate) {
16
+ return access(candidate).then(() => true, () => false);
17
+ }
18
+ /**
19
+ * Persists one already-built, already-valid `FrontendContractEvaluationArtifact`
20
+ * as `<outputLocation>/<evaluationId>/manifest.json` only - no screenshot is
21
+ * copied (the artifact's `before`/`after` fields already point back to the
22
+ * source observations). Same atomic-write discipline as
23
+ * `artifactWriter.ts#writeObservationArtifact`/`comparisonArtifactWriter.ts#writeComparisonArtifact`
24
+ * without sharing their implementation: sibling temporary directory, then one
25
+ * atomic rename. `evaluationId` is fresh per execution (see
26
+ * `frontendContractIdentity.ts#buildFrontendContractInstanceIdentity`), so an
27
+ * existing directory at the final path is a genuine collision and is
28
+ * rejected rather than overwritten - a legitimate PASS or FAIL evaluation
29
+ * result is never silently replaced. A `FAIL` verdict is a legitimate,
30
+ * persistable evaluation result, not a write failure; only an unpersistable
31
+ * artifact (invalid shape, or a real filesystem error) is reported as
32
+ * `ok: false`.
33
+ */
34
+ export async function writeFrontendContractEvaluationArtifact(artifact, outputLocation, options = {}) {
35
+ const validation = isValidFrontendContractEvaluationArtifact(artifact);
36
+ if (!validation.valid)
37
+ return writeFailure(`refusing to persist an invalid FrontendContractEvaluationArtifact: ${validation.reason}`);
38
+ const cwd = options.cwd ?? process.cwd();
39
+ const outputRoot = path.resolve(cwd, outputLocation);
40
+ const finalRoot = path.join(outputRoot, artifact.evaluationId);
41
+ const tempRoot = path.join(outputRoot, `.tmp-${artifact.evaluationId}`);
42
+ if (await pathExists(finalRoot)) {
43
+ return writeFailure(`an evaluation artifact already exists at "${artifact.evaluationId}"; refusing to overwrite it`, { artifactRoot: finalRoot });
44
+ }
45
+ try {
46
+ await rm(tempRoot, { recursive: true, force: true });
47
+ await mkdir(tempRoot, { recursive: true });
48
+ await writeFile(path.join(tempRoot, EVALUATION_MANIFEST_FILENAME), JSON.stringify(artifact, null, 2), 'utf8');
49
+ await rename(tempRoot, finalRoot);
50
+ return { ok: true, artifactRoot: finalRoot, manifestPath: path.join(finalRoot, EVALUATION_MANIFEST_FILENAME) };
51
+ }
52
+ catch (err) {
53
+ await rm(tempRoot, { recursive: true, force: true }).catch(() => undefined);
54
+ const message = err instanceof Error ? err.message : String(err);
55
+ return writeFailure(`failed to persist evaluation artifact: ${message}`);
56
+ }
57
+ }
58
+ //# sourceMappingURL=frontendContractEvaluationArtifactWriter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frontendContractEvaluationArtifactWriter.js","sourceRoot":"","sources":["../../src/artifacts/frontendContractEvaluationArtifactWriter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,yCAAyC,EAAE,MAAM,iDAAiD,CAAC;AAE5G,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B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