@lokalise/ragnarok-api-contracts 4.0.3 → 5.0.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.
@@ -1,144 +0,0 @@
1
- import { z } from 'zod';
2
- import { METRICS_METADATA_SCHEMA } from "./objects.js";
3
- /**
4
- * V2 evaluation result objects.
5
- *
6
- * Unlike V1 (`objects.ts`), every metric carries coverage and reliability metadata so consumers
7
- * can distinguish a perfect score from one computed on a degraded segment set, and can tell an
8
- * unsupported locale pair apart from an integration outage.
9
- *
10
- * V1 schemas remain the source of truth for `/v1/...`; these are additive and used only by `/v2/...`.
11
- */
12
- /**
13
- * Reliability classification of a single computed metric:
14
- * - `perfect` — computed over the full comparable segment set (`computedSegments === comparableSegments`).
15
- * - `degraded` — some segments were excluded, but the surviving set still meets the reliability threshold.
16
- * - `failed` — too few comparable segments to be trustworthy (below the reliability threshold).
17
- */
18
- export const METRIC_STATUS_SCHEMA = z
19
- .enum(['perfect', 'degraded', 'failed'])
20
- .describe('Reliability classification of the computed metric');
21
- /**
22
- * A single metric value paired with the coverage it was computed over and a reliability status.
23
- */
24
- export const METRIC_RESULT_SCHEMA = z.object({
25
- value: z.number().describe('The computed metric value'),
26
- computedSegments: z
27
- .number()
28
- .int()
29
- .min(0)
30
- .describe('Number of segments that successfully contributed to this metric'),
31
- comparableSegments: z
32
- .number()
33
- .int()
34
- .min(0)
35
- .describe('Number of segments in the comparable set for this metric after cross-configuration exclusion. ' +
36
- '`computedSegments` is measured against this denominator to derive `status`.'),
37
- status: METRIC_STATUS_SCHEMA,
38
- });
39
- /**
40
- * V2 per-locale-pair metrics. Each metric is optional (a metric is omitted when it does not apply,
41
- * e.g. BLEU for a pair with no corpus-level computation). The whole object is `null` on the
42
- * locale-pair result when no metrics could be produced (see `LOCALE_PAIR_RESULT_V2_SCHEMA`).
43
- */
44
- export const METRICS_V2_SCHEMA = z
45
- .object({
46
- exactMatch: METRIC_RESULT_SCHEMA.optional().describe('Rate of translations that exactly match the reference (0–1)'),
47
- ter: METRIC_RESULT_SCHEMA.optional().describe('TER score measuring post-editing effort relative to reference length'),
48
- bleu: METRIC_RESULT_SCHEMA.optional().describe('BLEU score measuring n-gram overlap with reference translations'),
49
- meteor: METRIC_RESULT_SCHEMA.optional().describe('METEOR score measuring n-gram overlap with synonym and morphological variant support'),
50
- chrf: METRIC_RESULT_SCHEMA.optional().describe('chrF score measuring character n-gram overlap with reference translations'),
51
- })
52
- .describe('Metrics for a single locale pair, each annotated with coverage and reliability');
53
- /**
54
- * Outcome of translating a locale pair within a run configuration:
55
- * - `success` — all in-scope segments translated.
56
- * - `partial_success` — some segments translated, some failed (metrics computed on the survivors).
57
- * - `unsupported_locale_pair` — the integration does not support this pair; metrics are `null`. Does
58
- * NOT cause cross-configuration exclusion (other configs are unaffected).
59
- * - `integration_failure` — the integration failed to translate the pair (e.g. provider outage);
60
- * metrics are `null` and the pair is excluded from all configs' comparable sets.
61
- */
62
- export const TRANSLATION_STATUS_SCHEMA = z
63
- .enum(['success', 'partial_success', 'unsupported_locale_pair', 'integration_failure'])
64
- .describe('Translation outcome for this locale pair');
65
- export const LOCALE_PAIR_RESULT_V2_SCHEMA = z
66
- .object({
67
- sourceLocale: z.string().describe('Source language locale'),
68
- targetLocale: z.string().describe('Target language locale'),
69
- totalSegments: z
70
- .number()
71
- .int()
72
- .min(0)
73
- .describe('Total number of segments in scope for this locale pair'),
74
- translatedSegments: z
75
- .number()
76
- .int()
77
- .min(0)
78
- .describe('Number of segments that were successfully translated'),
79
- translationStatus: TRANSLATION_STATUS_SCHEMA,
80
- metrics: METRICS_V2_SCHEMA.nullable().describe('Metrics for this locale pair, or `null` when no metrics could be computed ' +
81
- '(`unsupported_locale_pair` or `integration_failure`).'),
82
- })
83
- .describe('V2 evaluation metrics for a single locale pair, with coverage and translation outcome');
84
- /**
85
- * A reference to a locale pair, used to list pairs excluded from a global metric aggregate.
86
- * Intentionally flat (no `reason`): the per-pair `translationStatus` already carries the cause.
87
- */
88
- export const LOCALE_PAIR_REF_SCHEMA = z
89
- .object({
90
- sourceLocale: z.string().describe('Source language locale'),
91
- targetLocale: z.string().describe('Target language locale'),
92
- })
93
- .describe('Reference to a locale pair');
94
- /**
95
- * A global (cross-locale-pair) aggregate for a single metric. Weighted by comparable segments and
96
- * annotated with the locale pairs that were excluded from this metric's aggregation.
97
- */
98
- export const GLOBAL_METRIC_RESULT_SCHEMA = z.object({
99
- value: z.number().describe('The aggregated metric value across all included locale pairs'),
100
- computedSegments: z
101
- .number()
102
- .int()
103
- .min(0)
104
- .describe('Total segments that contributed to this global metric'),
105
- comparableSegments: z
106
- .number()
107
- .int()
108
- .min(0)
109
- .describe('Total comparable segments across all included locale pairs for this metric'),
110
- status: METRIC_STATUS_SCHEMA,
111
- excludedLocalePairs: z
112
- .array(LOCALE_PAIR_REF_SCHEMA)
113
- .describe('Locale pairs excluded from this metric (failed or non-comparable)'),
114
- });
115
- export const GLOBAL_METRICS_V2_SCHEMA = z
116
- .object({
117
- exactMatch: GLOBAL_METRIC_RESULT_SCHEMA.optional(),
118
- ter: GLOBAL_METRIC_RESULT_SCHEMA.optional(),
119
- bleu: GLOBAL_METRIC_RESULT_SCHEMA.optional(),
120
- meteor: GLOBAL_METRIC_RESULT_SCHEMA.optional(),
121
- chrf: GLOBAL_METRIC_RESULT_SCHEMA.optional(),
122
- })
123
- .describe('Per-metric global aggregates across all locale pairs');
124
- export const CONFIGURATION_RESULT_V2_SCHEMA = z
125
- .object({
126
- configurationName: z.string().describe('Name of the run configuration'),
127
- global: GLOBAL_METRICS_V2_SCHEMA.describe('Metrics aggregated across all locale pairs'),
128
- resultsByLocalePair: z
129
- .array(LOCALE_PAIR_RESULT_V2_SCHEMA)
130
- .describe('Metrics per locale pair, including failed and unsupported pairs'),
131
- })
132
- .describe('V2 evaluation metrics for a single run configuration');
133
- export const EVALUATION_V2_SCHEMA = z.object({
134
- id: z.uuid().describe('Unique identifier of the evaluation request'),
135
- ownerId: z.string().describe('Owner identifier (team ID or similar) for this evaluation'),
136
- status: z.enum(['pending', 'completed', 'failed']).describe('Current status of the evaluation'),
137
- metricsMetadata: METRICS_METADATA_SCHEMA.describe('Per-metric metadata for interpreting evaluation scores'),
138
- results: z
139
- .array(CONFIGURATION_RESULT_V2_SCHEMA)
140
- .nullable()
141
- .describe('Evaluation results per run configuration'),
142
- metadata: z.record(z.string(), z.unknown()).nullable(),
143
- });
144
- //# sourceMappingURL=objects-v2.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"objects-v2.js","sourceRoot":"","sources":["../src/objects-v2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AAEtD;;;;;;;;GAQG;AAEH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC;KAClC,IAAI,CAAC,CAAC,SAAS,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;KACvC,QAAQ,CAAC,mDAAmD,CAAC,CAAA;AAIhE;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,2BAA2B,CAAC;IACvD,gBAAgB,EAAE,CAAC;SAChB,MAAM,EAAE;SACR,GAAG,EAAE;SACL,GAAG,CAAC,CAAC,CAAC;SACN,QAAQ,CAAC,iEAAiE,CAAC;IAC9E,kBAAkB,EAAE,CAAC;SAClB,MAAM,EAAE;SACR,GAAG,EAAE;SACL,GAAG,CAAC,CAAC,CAAC;SACN,QAAQ,CACP,gGAAgG;QAC9F,6EAA6E,CAChF;IACH,MAAM,EAAE,oBAAoB;CAC7B,CAAC,CAAA;AAIF;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC;KAC/B,MAAM,CAAC;IACN,UAAU,EAAE,oBAAoB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