summaryrefslogtreecommitdiffstats
path: root/third_party/rust/suggest/src/suggest.udl
blob: 4a4e3fe9a058b28ec30c2d444aa2aa5babce58d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

[External="remote_settings"]
typedef extern RemoteSettingsConfig;

namespace suggest {

boolean raw_suggestion_url_matches([ByRef] string raw_url, [ByRef] string url);

};

[Error]
interface SuggestApiError {
    // An operation was interrupted by calling `SuggestStore.interrupt()`
    Interrupted();
    // The server requested a backoff after too many requests
    Backoff(u64 seconds);
    Network(string reason);
    Other(string reason);
};

enum SuggestionProvider {
    "Amp",
    "Pocket",
    "Wikipedia",
    "Amo",
    "Yelp",
    "Mdn",
    "Weather",
    "AmpMobile",
};

[Enum]
interface Suggestion {
    Amp(
        string title,
        string url,
        string raw_url,
        sequence<u8>? icon,
        string? icon_mimetype,
        string full_keyword,
        i64 block_id,
        string advertiser,
        string iab_category,
        string impression_url,
        string click_url,
        string raw_click_url,
        f64 score
    );
    Pocket(
        string title,
        string url,
        f64 score,
        boolean is_top_pick
    );
    Wikipedia(
        string title,
        string url,
        sequence<u8>? icon,
        string? icon_mimetype,
        string full_keyword
    );
    Amo(
        string title,
        string url,
        string icon_url,
        string description,
        string? rating,
        i64 number_of_ratings,
        string guid,
        f64 score
    );
    Yelp(
        string url,
        string title,
        sequence<u8>? icon,
        string? icon_mimetype,
        f64 score,
        boolean has_location_sign,
        boolean subject_exact_match,
        string location_param
    );
    Mdn(
        string title,
        string url,
        string description,
        f64 score
    );
    Weather(
        f64 score
    );
};

dictionary SuggestionQuery {
    string keyword;
    sequence<SuggestionProvider> providers;
    i32? limit = null;
};

dictionary SuggestIngestionConstraints {
    u64? max_suggestions = null;
    sequence<SuggestionProvider>? providers = null;
};

dictionary SuggestGlobalConfig {
    i32 show_less_frequently_cap;
};

[Enum]
interface SuggestProviderConfig {
    Weather(
        i32 min_keyword_length
    );
};

interface SuggestStore {
    [Throws=SuggestApiError]
    constructor([ByRef] string path, optional RemoteSettingsConfig? settings_config = null);

    [Throws=SuggestApiError]
    sequence<Suggestion> query(SuggestionQuery query);

    [Throws=SuggestApiError]
    void dismiss_suggestion(string raw_suggestion_url);

    [Throws=SuggestApiError]
    void clear_dismissed_suggestions();

    void interrupt();

    [Throws=SuggestApiError]
    void ingest(SuggestIngestionConstraints constraints);

    [Throws=SuggestApiError]
    void clear();

    [Throws=SuggestApiError]
    SuggestGlobalConfig fetch_global_config();

    [Throws=SuggestApiError]
    SuggestProviderConfig? fetch_provider_config(SuggestionProvider provider);
};

interface SuggestStoreBuilder {
    constructor();

    [Self=ByArc]
    SuggestStoreBuilder data_path(string path);

    // Deprecated: this is no longer used by the suggest component.
    [Self=ByArc]
    SuggestStoreBuilder cache_path(string path);

    [Self=ByArc]
    SuggestStoreBuilder remote_settings_config(RemoteSettingsConfig config);

    [Throws=SuggestApiError]
    SuggestStore build();
};