altalandi 0.4.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.
package/client.d.ts CHANGED
@@ -1,113 +1,117 @@
1
- export type SourceLang = "auto" | "en" | "is";
2
- export type Domain = "general" | "marketing" | "data-analysis" | "childrens-fiction";
3
- export type Register = "formal" | "neutral" | "warm";
4
- export type WriterTier = "standard" | "max";
5
- export type ScoringTier = "none" | "fast" | "rigorous";
6
-
7
- export interface GlossaryTerm {
8
- en: string;
9
- is: string;
10
- note?: string;
11
- }
12
-
13
- export interface FetchResponseLike {
14
- ok: boolean;
15
- status: number;
16
- statusText?: string;
17
- text(): Promise<string>;
18
- }
19
-
20
- export type FetchLike = (
21
- url: string,
22
- init: {
23
- method: string;
24
- headers: Record<string, string>;
25
- body: string;
26
- signal: any;
27
- },
28
- ) => Promise<FetchResponseLike>;
29
-
30
- export interface RefineOptions {
31
- sourceLang?: SourceLang;
32
- domain?: Domain;
33
- register?: Register;
34
- preserveMeaning?: boolean;
35
- scoreNativeness?: boolean;
36
- /** IS-refine: keep the original unless improvement is verified. */
37
- onlyImprove?: boolean;
38
- /** Optional EN→IS monolingual polish pass; false by default. */
39
- polishPass?: boolean;
40
- writer?: WriterTier;
41
- scoring?: ScoringTier;
42
- glossary?: GlossaryTerm[];
43
- returnDiffs?: boolean;
44
- /** Defaults to ALTALANDI_API_KEY. Never put a key in source control. */
45
- apiKey?: string;
46
- /** Defaults to https://altalandi.is/api. */
47
- baseUrl?: string;
48
- /** Per-request timeout in milliseconds; defaults to 300000. */
49
- timeoutMs?: number;
50
- /** Optional fetch-compatible implementation, useful for controlled runtimes and tests. */
51
- fetch?: FetchLike;
52
- }
53
-
54
- export interface RefineDiff {
55
- before: string;
56
- after: string;
57
- layer: "L1" | "L2" | "L3";
58
- reason: string;
59
- }
60
-
61
- export interface RefineQuality {
62
- nativenessScore: number | null;
63
- translationeseTells: string[];
64
- iceBertScore: number | null;
65
- morphologyOk: boolean | null;
66
- calqueFlags: string[];
67
- englishRemnants: string[];
68
- encodingArtifacts: string[];
69
- }
70
-
71
- export interface RefineResult {
72
- id: string;
73
- output: string;
74
- sourceLang: "en" | "is";
75
- diffs: RefineDiff[];
76
- quality: RefineQuality;
77
- /** Only strict true is a completed verification; null means skipped/unavailable. */
78
- meaningPreserved: boolean | null;
79
- meaningNotes: string;
80
- modelUsed: string;
81
- tier?: { writer: WriterTier; scoring: ScoringTier };
82
- billedTier?: { writer: WriterTier; scoring: ScoringTier };
83
- warnings: string[];
84
- }
85
-
86
- export type VerifiedRefineResult = RefineResult & { meaningPreserved: true };
87
-
88
- export interface AltalandiErrorOptions {
89
- code?: string;
90
- status?: number;
91
- }
92
-
93
- export class AltalandiError extends Error {
94
- readonly code: string;
95
- readonly status?: number;
96
- constructor(message: string, options?: AltalandiErrorOptions);
97
- }
98
-
99
- export class MeaningVerificationError extends AltalandiError {
100
- readonly verdict: false | null;
101
- constructor(verdict: boolean | null | undefined);
102
- }
103
-
104
- /** Refine text and return the full hosted API response. */
105
- export function refine(text: string, options?: RefineOptions): Promise<RefineResult>;
106
-
107
- /** Refine text and throw unless meaningPreserved is strict true. */
108
- export function refineVerified(text: string, options?: RefineOptions): Promise<VerifiedRefineResult>;
109
-
110
- /** Narrow an existing result to one with a verified meaning verdict. */
111
- export function assertMeaningVerified(
112
- result: RefineResult,
113
- ): asserts result is VerifiedRefineResult;
1
+ export type SourceLang = "auto" | "en" | "is";
2
+ export type Domain = "general" | "marketing" | "data-analysis" | "childrens-fiction";
3
+ export type Register = "formal" | "neutral" | "warm";
4
+ export type WriterTier = "standard" | "max";
5
+ export type ScoringTier = "none" | "fast" | "rigorous";
6
+
7
+ export interface GlossaryTerm {
8
+ en: string;
9
+ is: string;
10
+ note?: string;
11
+ }
12
+
13
+ export interface FetchResponseLike {
14
+ ok: boolean;
15
+ status: number;
16
+ statusText?: string;
17
+ text(): Promise<string>;
18
+ }
19
+
20
+ export type FetchLike = (
21
+ url: string,
22
+ init: {
23
+ method: string;
24
+ headers: Record<string, string>;
25
+ body: string;
26
+ signal: any;
27
+ },
28
+ ) => Promise<FetchResponseLike>;
29
+
30
+ export interface RefineOptions {
31
+ sourceLang?: SourceLang;
32
+ domain?: Domain;
33
+ register?: Register;
34
+ preserveMeaning?: boolean;
35
+ scoreNativeness?: boolean;
36
+ /** IS-refine: keep the original unless improvement is verified. */
37
+ onlyImprove?: boolean;
38
+ /** Optional EN→IS monolingual polish pass; false by default. */
39
+ polishPass?: boolean;
40
+ writer?: WriterTier;
41
+ scoring?: ScoringTier;
42
+ glossary?: GlossaryTerm[];
43
+ returnDiffs?: boolean;
44
+ /** Let Altalandi keep this text and its output to improve the service. Only with the person's consent; default false. */
45
+ contribute?: boolean;
46
+ /** Defaults to ALTALANDI_API_KEY. Never put a key in source control. */
47
+ apiKey?: string;
48
+ /** Defaults to https://altalandi.is/api. */
49
+ baseUrl?: string;
50
+ /** Per-request timeout in milliseconds; defaults to 300000. */
51
+ timeoutMs?: number;
52
+ /** Optional fetch-compatible implementation, useful for controlled runtimes and tests. */
53
+ fetch?: FetchLike;
54
+ }
55
+
56
+ export interface RefineDiff {
57
+ before: string;
58
+ after: string;
59
+ layer: "L1" | "L2" | "L3";
60
+ reason: string;
61
+ }
62
+
63
+ export interface RefineQuality {
64
+ nativenessScore: number | null;
65
+ translationeseTells: string[];
66
+ iceBertScore: number | null;
67
+ morphologyOk: boolean | null;
68
+ calqueFlags: string[];
69
+ englishRemnants: string[];
70
+ encodingArtifacts: string[];
71
+ }
72
+
73
+ export interface RefineResult {
74
+ id: string;
75
+ output: string;
76
+ sourceLang: "en" | "is";
77
+ diffs: RefineDiff[];
78
+ quality: RefineQuality;
79
+ /** Only strict true is a completed verification; null means skipped/unavailable. */
80
+ meaningPreserved: boolean | null;
81
+ meaningNotes: string;
82
+ modelUsed: string;
83
+ tier?: { writer: WriterTier; scoring: ScoringTier };
84
+ billedTier?: { writer: WriterTier; scoring: ScoringTier };
85
+ warnings: string[];
86
+ /** true when a test key made the call: no model ran, nothing was charged, output = input. */
87
+ test?: boolean | null;
88
+ }
89
+
90
+ export type VerifiedRefineResult = RefineResult & { meaningPreserved: true };
91
+
92
+ export interface AltalandiErrorOptions {
93
+ code?: string;
94
+ status?: number;
95
+ }
96
+
97
+ export class AltalandiError extends Error {
98
+ readonly code: string;
99
+ readonly status?: number;
100
+ constructor(message: string, options?: AltalandiErrorOptions);
101
+ }
102
+
103
+ export class MeaningVerificationError extends AltalandiError {
104
+ readonly verdict: false | null;
105
+ constructor(verdict: boolean | null | undefined);
106
+ }
107
+
108
+ /** Refine text and return the full hosted API response. */
109
+ export function refine(text: string, options?: RefineOptions): Promise<RefineResult>;
110
+
111
+ /** Refine text and throw unless meaningPreserved is strict true. */
112
+ export function refineVerified(text: string, options?: RefineOptions): Promise<VerifiedRefineResult>;
113
+
114
+ /** Narrow an existing result to one with a verified meaning verdict. */
115
+ export function assertMeaningVerified(
116
+ result: RefineResult,
117
+ ): asserts result is VerifiedRefineResult;