From 1817ce0847d51554d3ef508b930cdc443720180d Mon Sep 17 00:00:00 2001 From: Drew Willcoxon Date: Wed, 12 Mar 2025 20:20:09 +0000 Subject: [PATCH] Bug 1952588 - Vendor application-services to 138 for Suggest geo expansion. r=bdk,daisuke This vendors the `desktop-138` branch [1] of application-services. The `main` branch currently does not have some PRs that desktop needs because they break mobile, and we need this on desktop ASAP. This patch is larger than usual because the vendor includes some major changes to the application-services `suggest` component, including new and changed API. As a consequence this patch includes the following important changes: ## New `suggest` API & uniffi `SuggestStoreBuilder::remote_settings_service` and `RemoteSettingsService::new` are exposed to JS as synchronous functions. There's no need for them to be off-main-thread. ## Telemetry The labels of `suggest.ingest_time`, `ingest_download_time` and `query_time` had to be updated due to changes in the Rust component. These are minor updates that don't need a data review. ## Urlbar I had to make the following changes to urlbar. I tried to keep them to a minimum for now. There are opportunities for improvements in follow-ups. * Appropriate minimal integration changes to `SuggestBackendRust` for creating the `SuggestStore` and setting up the RS config * The Rust component uses new RS collections, which breaks tests. I tried to fix them without touching too many lines. There are definitely opportunities to improve these tests and test helpers that I'd like to come back to. * A fix to `RemoteSettingsServer` that's required due to the new RS client used by the Rust component ## Late writes due to the new RS client & `AsyncShutdown` This is a urlbar change but it's worth calling out separately. I pushed all these changes to tryserver, and there was a failure at the end of the browser Suggest tests due to `LateWriteObserver` [2]. The late write happens when the app exits: `SuggestStore` is dropped, which causes the new app-services RS client to drop its Sqlite connection, which causes Sqlite to sync the RS client's DB to disk. This hasn't been a problem before because `suggest` currently uses the old RS client, which doesn't keep a DB. (`suggest` does have its own separate Sqlite DB, and I didn't investigate why this isn't a problem for it, mainly because it makes sense that the new RS client would sync its DB when it's dropped and that might be considered a "late write" when it happens on app shutdown.) According to the stack in the log, `SuggestStore` is dropped by `nsCycleCollector`. I can't see how `SuggestBackendRust.#store` is involved in a cycle, and I don't know if something in this patch is causing a cycle where there wasn't one before. Maybe there always was. And I don't know if the cycle is what's causing the all this to happen too late on shutdown. Maybe it's unrelated. (I'll paste the stack in a Phabricator comment.) The `SuggestStore` is definitely kept alive until `AsyncShutdown.profileBeforeChange` since we have a barrier for that phase that calls `interrupt()` on it. Maybe that's simply the problem and we're using a phase that's too late in shutdown. But again I don't know why it wouldn't also be a problem for Suggest's own DB. The only fix I found is to replace `AsyncShutdown.profileBeforeChange` with either `quitApplicationGranted` or `profileChangeTeardown`, and then null out `#store` in the callback (after we call `interrupt()` on it). I assume that fixes it because `profileBeforeChange` runs later than those other two phases. So I replaced `profileBeforeChange` with `profileChangeTeardown`. I don't know which of `quitApplicationGranted` or `profileChangeTeardown` is better. I think it probably doesn't matter. I chose `profileChangeTeardown` because it's closer to `profileBeforeChange`. (The order is: `quitApplicationGranted`, `profileChangeTeardown`, `profileBeforeChange`.) [1] https://github.com/mozilla/application-services/tree/desktop-138 [2] https://treeherder.mozilla.org/jobs?repo=try&revision=1639f87aa46f1afaf50901d80c8282861700019b Differential Revision: https://phabricator.services.mozilla.com/D240919 --- .cargo/config.toml.in | 4 +- Cargo.lock | 32 +- Cargo.toml | 18 +- browser/components/urlbar/metrics.yaml | 9 +- .../urlbar/private/SuggestBackendRust.sys.mjs | 123 ++- ...ser_glean_telemetry_fakespot_engagement.js | 5 +- .../tests/engagementTelemetry/browser/head.js | 9 +- .../QuickSuggestTestUtils.sys.mjs | 77 +- .../quicksuggest/RemoteSettingsServer.sys.mjs | 8 +- .../browser/browser_quicksuggest.js | 11 +- .../browser/browser_quicksuggest_block.js | 11 +- .../browser/browser_quicksuggest_indexes.js | 11 +- .../browser/browser_quicksuggest_ping_amp.js | 3 +- .../browser_telemetry_suggestMetrics.js | 17 +- .../quicksuggest/unit/test_quicksuggest.js | 48 +- .../unit/test_quicksuggest_exposures.js | 8 +- .../test_quicksuggest_exposures_locales.js | 12 +- .../unit/test_quicksuggest_merino.js | 31 +- .../unit/test_quicksuggest_scoreMap.js | 16 +- .../quicksuggest/unit/test_rust_ingest.js | 2 +- .../urlbar/tests/unit/test_exposure.js | 27 +- .../rust/remote_settings/.cargo-checksum.json | 2 +- third_party/rust/remote_settings/src/lib.rs | 5 + third_party/rust/suggest/.cargo-checksum.json | 2 +- .../rust/suggest/src/benchmarks/client.rs | 23 +- .../rust/suggest/src/benchmarks/ingest.rs | 103 ++- .../rust/suggest/src/benchmarks/mod.rs | 24 +- third_party/rust/suggest/src/db.rs | 169 +--- third_party/rust/suggest/src/geoname.rs | 511 +++++++----- third_party/rust/suggest/src/provider.rs | 136 +++- third_party/rust/suggest/src/query.rs | 8 - third_party/rust/suggest/src/rs.rs | 348 ++++----- third_party/rust/suggest/src/schema.rs | 29 +- third_party/rust/suggest/src/store.rs | 725 ++++++++---------- third_party/rust/suggest/src/suggestion.rs | 5 - .../rust/suggest/src/testing/client.rs | 317 +++----- third_party/rust/suggest/src/testing/data.rs | 34 - third_party/rust/suggest/src/testing/mod.rs | 2 +- third_party/rust/suggest/src/weather.rs | 127 +-- .../generated/RustRemoteSettings.sys.mjs | 35 +- .../components/generated/RustSearch.sys.mjs | 12 +- .../components/generated/RustSuggest.sys.mjs | 123 +-- .../components/generated/RustTabs.sys.mjs | 50 +- .../generated/RustWebextstorage.sys.mjs | 44 +- .../uniffi-bindgen-gecko-js/config.toml | 2 + .../fixtures/generated/RustArithmetic.sys.mjs | 8 +- .../generated/RustCustomTypes.sys.mjs | 2 +- .../generated/RustExternalTypes.sys.mjs | 6 +- .../generated/RustFixtureCallbacks.sys.mjs | 6 +- .../fixtures/generated/RustFutures.sys.mjs | 50 +- .../fixtures/generated/RustGeometry.sys.mjs | 4 +- .../fixtures/generated/RustRefcounts.sys.mjs | 6 +- .../fixtures/generated/RustRondpoint.sys.mjs | 120 +-- .../fixtures/generated/RustSprites.sys.mjs | 12 +- .../fixtures/generated/RustTodolist.sys.mjs | 30 +- .../RustUniffiTraitInterfaces.sys.mjs | 6 +- .../uniffi-js/UniFFIGeneratedScaffolding.cpp | 440 ++++++----- 57 files changed, 2020 insertions(+), 1988 deletions(-) diff --git a/.cargo/config.toml.in b/.cargo/config.toml.in index 1540c0f0bb21..4e0d9b9ce0e9 100644 --- a/.cargo/config.toml.in +++ b/.cargo/config.toml.in @@ -70,9 +70,9 @@ git = "https://github.com/jfkthame/mapped_hyph.git" rev = "eff105f6ad7ec9b79816cfc1985a28e5340ad14b" replace-with = "vendored-sources" -[source."git+https://github.com/mozilla/application-services?rev=f7947a60b3e9957b97229d6dd08b458532e79c1c"] +[source."git+https://github.com/mozilla/application-services?branch=desktop-138"] git = "https://github.com/mozilla/application-services" -rev = "f7947a60b3e9957b97229d6dd08b458532e79c1c" +branch = "desktop-138" replace-with = "vendored-sources" [source."git+https://github.com/mozilla/audioipc?rev=e6f44a2bd1e57d11dfc737632a9e849077632330"] diff --git a/Cargo.lock b/Cargo.lock index 15deecdbc097..b057007c790c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1802,7 +1802,7 @@ dependencies = [ [[package]] name = "error-support" version = "0.1.0" -source = "git+https://github.com/mozilla/application-services?rev=f7947a60b3e9957b97229d6dd08b458532e79c1c#f7947a60b3e9957b97229d6dd08b458532e79c1c" +source = "git+https://github.com/mozilla/application-services?branch=desktop-138#52a67ed74c51d23b962de4e002e088bee5e5d24e" dependencies = [ "error-support-macros", "lazy_static", @@ -1814,7 +1814,7 @@ dependencies = [ [[package]] name = "error-support-macros" version = "0.1.0" -source = "git+https://github.com/mozilla/application-services?rev=f7947a60b3e9957b97229d6dd08b458532e79c1c#f7947a60b3e9957b97229d6dd08b458532e79c1c" +source = "git+https://github.com/mozilla/application-services?branch=desktop-138#52a67ed74c51d23b962de4e002e088bee5e5d24e" dependencies = [ "proc-macro2", "quote", @@ -1931,7 +1931,7 @@ dependencies = [ [[package]] name = "firefox-versioning" version = "0.1.0" -source = "git+https://github.com/mozilla/application-services?rev=f7947a60b3e9957b97229d6dd08b458532e79c1c#f7947a60b3e9957b97229d6dd08b458532e79c1c" +source = "git+https://github.com/mozilla/application-services?branch=desktop-138#52a67ed74c51d23b962de4e002e088bee5e5d24e" dependencies = [ "serde_json", "thiserror 1.999.999", @@ -3216,7 +3216,7 @@ dependencies = [ [[package]] name = "interrupt-support" version = "0.1.0" -source = "git+https://github.com/mozilla/application-services?rev=f7947a60b3e9957b97229d6dd08b458532e79c1c#f7947a60b3e9957b97229d6dd08b458532e79c1c" +source = "git+https://github.com/mozilla/application-services?branch=desktop-138#52a67ed74c51d23b962de4e002e088bee5e5d24e" dependencies = [ "lazy_static", "parking_lot", @@ -4920,7 +4920,7 @@ checksum = "d01a5bd0424d00070b0098dd17ebca6f961a959dead1dbcbbbc1d1cd8d3deeba" [[package]] name = "payload-support" version = "0.1.0" -source = "git+https://github.com/mozilla/application-services?rev=f7947a60b3e9957b97229d6dd08b458532e79c1c#f7947a60b3e9957b97229d6dd08b458532e79c1c" +source = "git+https://github.com/mozilla/application-services?branch=desktop-138#52a67ed74c51d23b962de4e002e088bee5e5d24e" dependencies = [ "serde", "serde_derive", @@ -5416,7 +5416,7 @@ checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" [[package]] name = "relevancy" version = "0.1.0" -source = "git+https://github.com/mozilla/application-services?rev=f7947a60b3e9957b97229d6dd08b458532e79c1c#f7947a60b3e9957b97229d6dd08b458532e79c1c" +source = "git+https://github.com/mozilla/application-services?branch=desktop-138#52a67ed74c51d23b962de4e002e088bee5e5d24e" dependencies = [ "anyhow", "base64 0.21.3", @@ -5441,7 +5441,7 @@ dependencies = [ [[package]] name = "remote_settings" version = "0.1.0" -source = "git+https://github.com/mozilla/application-services?rev=f7947a60b3e9957b97229d6dd08b458532e79c1c#f7947a60b3e9957b97229d6dd08b458532e79c1c" +source = "git+https://github.com/mozilla/application-services?branch=desktop-138#52a67ed74c51d23b962de4e002e088bee5e5d24e" dependencies = [ "anyhow", "camino", @@ -5724,7 +5724,7 @@ dependencies = [ [[package]] name = "search" version = "0.1.0" -source = "git+https://github.com/mozilla/application-services?rev=f7947a60b3e9957b97229d6dd08b458532e79c1c#f7947a60b3e9957b97229d6dd08b458532e79c1c" +source = "git+https://github.com/mozilla/application-services?branch=desktop-138#52a67ed74c51d23b962de4e002e088bee5e5d24e" dependencies = [ "error-support", "firefox-versioning", @@ -6014,7 +6014,7 @@ dependencies = [ [[package]] name = "sql-support" version = "0.1.0" -source = "git+https://github.com/mozilla/application-services?rev=f7947a60b3e9957b97229d6dd08b458532e79c1c#f7947a60b3e9957b97229d6dd08b458532e79c1c" +source = "git+https://github.com/mozilla/application-services?branch=desktop-138#52a67ed74c51d23b962de4e002e088bee5e5d24e" dependencies = [ "interrupt-support", "lazy_static", @@ -6214,7 +6214,7 @@ checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "suggest" version = "0.1.0" -source = "git+https://github.com/mozilla/application-services?rev=f7947a60b3e9957b97229d6dd08b458532e79c1c#f7947a60b3e9957b97229d6dd08b458532e79c1c" +source = "git+https://github.com/mozilla/application-services?branch=desktop-138#52a67ed74c51d23b962de4e002e088bee5e5d24e" dependencies = [ "anyhow", "chrono", @@ -6266,7 +6266,7 @@ dependencies = [ [[package]] name = "sync-guid" version = "0.1.0" -source = "git+https://github.com/mozilla/application-services?rev=f7947a60b3e9957b97229d6dd08b458532e79c1c#f7947a60b3e9957b97229d6dd08b458532e79c1c" +source = "git+https://github.com/mozilla/application-services?branch=desktop-138#52a67ed74c51d23b962de4e002e088bee5e5d24e" dependencies = [ "base64 0.21.3", "rand", @@ -6277,7 +6277,7 @@ dependencies = [ [[package]] name = "sync15" version = "0.1.0" -source = "git+https://github.com/mozilla/application-services?rev=f7947a60b3e9957b97229d6dd08b458532e79c1c#f7947a60b3e9957b97229d6dd08b458532e79c1c" +source = "git+https://github.com/mozilla/application-services?branch=desktop-138#52a67ed74c51d23b962de4e002e088bee5e5d24e" dependencies = [ "anyhow", "error-support", @@ -6317,7 +6317,7 @@ dependencies = [ [[package]] name = "tabs" version = "0.1.0" -source = "git+https://github.com/mozilla/application-services?rev=f7947a60b3e9957b97229d6dd08b458532e79c1c#f7947a60b3e9957b97229d6dd08b458532e79c1c" +source = "git+https://github.com/mozilla/application-services?branch=desktop-138#52a67ed74c51d23b962de4e002e088bee5e5d24e" dependencies = [ "anyhow", "error-support", @@ -6661,7 +6661,7 @@ checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" [[package]] name = "types" version = "0.1.0" -source = "git+https://github.com/mozilla/application-services?rev=f7947a60b3e9957b97229d6dd08b458532e79c1c#f7947a60b3e9957b97229d6dd08b458532e79c1c" +source = "git+https://github.com/mozilla/application-services?branch=desktop-138#52a67ed74c51d23b962de4e002e088bee5e5d24e" dependencies = [ "rusqlite", "serde", @@ -7041,7 +7041,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "viaduct" version = "0.1.0" -source = "git+https://github.com/mozilla/application-services?rev=f7947a60b3e9957b97229d6dd08b458532e79c1c#f7947a60b3e9957b97229d6dd08b458532e79c1c" +source = "git+https://github.com/mozilla/application-services?branch=desktop-138#52a67ed74c51d23b962de4e002e088bee5e5d24e" dependencies = [ "ffi-support", "log", @@ -7211,7 +7211,7 @@ dependencies = [ [[package]] name = "webext-storage" version = "0.1.0" -source = "git+https://github.com/mozilla/application-services?rev=f7947a60b3e9957b97229d6dd08b458532e79c1c#f7947a60b3e9957b97229d6dd08b458532e79c1c" +source = "git+https://github.com/mozilla/application-services?branch=desktop-138#52a67ed74c51d23b962de4e002e088bee5e5d24e" dependencies = [ "anyhow", "error-support", diff --git a/Cargo.toml b/Cargo.toml index b42cb1832655..61603a3b2e33 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -235,14 +235,14 @@ malloc_size_of_derive = { path = "xpcom/rust/malloc_size_of_derive" } objc = { git = "https://github.com/glandium/rust-objc", rev = "4de89f5aa9851ceca4d40e7ac1e2759410c04324" } # application-services overrides to make updating them all simpler. -interrupt-support = { git = "https://github.com/mozilla/application-services", rev = "f7947a60b3e9957b97229d6dd08b458532e79c1c" } -relevancy = { git = "https://github.com/mozilla/application-services", rev = "f7947a60b3e9957b97229d6dd08b458532e79c1c" } -search = { git = "https://github.com/mozilla/application-services", rev = "f7947a60b3e9957b97229d6dd08b458532e79c1c" } -sql-support = { git = "https://github.com/mozilla/application-services", rev = "f7947a60b3e9957b97229d6dd08b458532e79c1c" } -suggest = { git = "https://github.com/mozilla/application-services", rev = "f7947a60b3e9957b97229d6dd08b458532e79c1c" } -sync15 = { git = "https://github.com/mozilla/application-services", rev = "f7947a60b3e9957b97229d6dd08b458532e79c1c" } -tabs = { git = "https://github.com/mozilla/application-services", rev = "f7947a60b3e9957b97229d6dd08b458532e79c1c" } -viaduct = { git = "https://github.com/mozilla/application-services", rev = "f7947a60b3e9957b97229d6dd08b458532e79c1c" } -webext-storage = { git = "https://github.com/mozilla/application-services", rev = "f7947a60b3e9957b97229d6dd08b458532e79c1c" } +interrupt-support = { git = "https://github.com/mozilla/application-services", branch = "desktop-138" } +relevancy = { git = "https://github.com/mozilla/application-services", branch = "desktop-138" } +search = { git = "https://github.com/mozilla/application-services", branch = "desktop-138" } +sql-support = { git = "https://github.com/mozilla/application-services", branch = "desktop-138" } +suggest = { git = "https://github.com/mozilla/application-services", branch = "desktop-138" } +sync15 = { git = "https://github.com/mozilla/application-services", branch = "desktop-138" } +tabs = { git = "https://github.com/mozilla/application-services", branch = "desktop-138" } +viaduct = { git = "https://github.com/mozilla/application-services", branch = "desktop-138" } +webext-storage = { git = "https://github.com/mozilla/application-services", branch = "desktop-138" } allocator-api2 = { path = "third_party/rust/allocator-api2" } diff --git a/browser/components/urlbar/metrics.yaml b/browser/components/urlbar/metrics.yaml index f744c15b56cd..e90e73e67112 100644 --- a/browser/components/urlbar/metrics.yaml +++ b/browser/components/urlbar/metrics.yaml @@ -946,14 +946,14 @@ suggest: time_unit: microsecond labels: - icon - - data + - amp + - wikipedia - amo-suggestions - pocket-suggestions - yelp-suggestions - mdn-suggestions - weather - configuration - - amp-mobile-suggestions - fakespot-suggestions bugs: - https://bugzilla.mozilla.org/show_bug.cgi?id=1908397 @@ -972,14 +972,14 @@ suggest: time_unit: microsecond labels: - icon - - data + - amp + - wikipedia - amo-suggestions - pocket-suggestions - yelp-suggestions - mdn-suggestions - weather - configuration - - amp-mobile-suggestions - fakespot-suggestions bugs: - https://bugzilla.mozilla.org/show_bug.cgi?id=1908397 @@ -998,7 +998,6 @@ suggest: time_unit: microsecond labels: - amp - - ampmobile - wikipedia - amo - pocket diff --git a/browser/components/urlbar/private/SuggestBackendRust.sys.mjs b/browser/components/urlbar/private/SuggestBackendRust.sys.mjs index 2ce540bf61fe..38edaf7193b7 100644 --- a/browser/components/urlbar/private/SuggestBackendRust.sys.mjs +++ b/browser/components/urlbar/private/SuggestBackendRust.sys.mjs @@ -13,7 +13,10 @@ ChromeUtils.defineESModuleGetters(lazy, { InterruptKind: "resource://gre/modules/RustSuggest.sys.mjs", ObjectUtils: "resource://gre/modules/ObjectUtils.sys.mjs", QuickSuggest: "resource:///modules/QuickSuggest.sys.mjs", - RemoteSettingsServer: "resource://gre/modules/RustSuggest.sys.mjs", + RemoteSettingsConfig2: "resource://gre/modules/RustRemoteSettings.sys.mjs", + RemoteSettingsContext: "resource://gre/modules/RustRemoteSettings.sys.mjs", + RemoteSettingsServer: "resource://gre/modules/RustRemoteSettings.sys.mjs", + RemoteSettingsService: "resource://gre/modules/RustRemoteSettings.sys.mjs", SuggestIngestionConstraints: "resource://gre/modules/RustSuggest.sys.mjs", SuggestStoreBuilder: "resource://gre/modules/RustSuggest.sys.mjs", Suggestion: "resource://gre/modules/RustSuggest.sys.mjs", @@ -328,6 +331,13 @@ export class SuggestBackendRust extends SuggestBackend { this.#ingestAll(); } + /** + * @returns {string} + * The path of `suggest.sqlite`, where the Rust component stores ingested + * suggestions. It also stores dismissed suggestions, which is why we keep + * this file in the profile directory, but desktop doesn't currently use the + * Rust component for that. + */ get #storeDataPath() { return PathUtils.join( Services.dirsvc.get("ProfD", Ci.nsIFile).path, @@ -335,6 +345,15 @@ export class SuggestBackendRust extends SuggestBackend { ); } + /** + * @returns {string} + * The path of the directory that should contain the remote settings cache + * used internally by the Rust component. + */ + get #remoteSettingsStoragePath() { + return Services.dirsvc.get("ProfLD", Ci.nsIFile).path; + } + /** * @returns {Array} * Each item in this array identifies an enabled Rust suggestion type and @@ -361,25 +380,8 @@ export class SuggestBackendRust extends SuggestBackend { } #init() { - // If the RS config hasn't been set, bail. `this.#store` will remain null, - // effectively disabling Rust suggestions. - if (!this.#remoteSettingsServer) { - return; - } - - // Initialize the store. - this.logger.info("Initializing SuggestStore", { - path: this.#storeDataPath, - }); - let builder = lazy.SuggestStoreBuilder.init() - .dataPath(this.#storeDataPath) - .loadExtension(AppConstants.SQLITE_LIBRARY_FILENAME, "sqlite3_fts5_init") - .remoteSettingsServer(this.#remoteSettingsServer) - .remoteSettingsBucketName(this.#remoteSettingsBucketName); - try { - this.#store = builder.build(); - } catch (error) { - this.logger.error("Error initializing SuggestStore", error); + this.#store = this.#makeStore(); + if (!this.#store) { return; } @@ -390,12 +392,21 @@ export class SuggestBackendRust extends SuggestBackend { ); this.logger.debug("Last ingest time (seconds)", lastIngestSecs); - // Interrupt any ongoing ingests (WRITE) and queries (READ) on shutdown. - // Note that `interrupt()` runs on the main thread and is not async; see - // toolkit/components/uniffi-bindgen-gecko-js/config.toml - this.#shutdownBlocker = () => + // Add our shutdown blocker. + this.#shutdownBlocker = () => { + // Interrupt any ongoing ingests (WRITE) and queries (READ). + // `interrupt()` runs on the main thread and is not async; see + // toolkit/components/uniffi-bindgen-gecko-js/config.toml this.#store?.interrupt(lazy.InterruptKind.READ_WRITE); - lazy.AsyncShutdown.profileBeforeChange.addBlocker( + + // Null the store so it's destroyed now instead of later when `this` is + // collected. The store's Sqlite DBs are synced when dropped (its DB and + // its RS client's DB), which causes a `LateWriteObserver` test failure if + // it happens too late during shutdown. + this.#store = null; + this.#shutdownBlocker = null; + }; + lazy.AsyncShutdown.profileChangeTeardown.addBlocker( "QuickSuggest: Interrupt the Rust component", this.#shutdownBlocker ); @@ -414,13 +425,73 @@ export class SuggestBackendRust extends SuggestBackend { this.#ingestAll(); } + #makeStore() { + this.logger.info("Creating SuggestStore", { + server: this.#remoteSettingsServer, + bucketName: this.#remoteSettingsBucketName, + dataPath: this.#storeDataPath, + storagePath: this.#remoteSettingsStoragePath, + }); + + if (!this.#remoteSettingsServer) { + return null; + } + + let rsService; + try { + rsService = lazy.RemoteSettingsService.init( + this.#remoteSettingsStoragePath, + new lazy.RemoteSettingsConfig2({ + server: this.#remoteSettingsServer, + bucketName: this.#remoteSettingsBucketName, + appContext: new lazy.RemoteSettingsContext({ + appName: Services.appinfo.name || "", + appId: Services.appinfo.ID || "", + channel: AppConstants.IS_ESR + ? "esr" + : AppConstants.MOZ_UPDATE_CHANNEL, + }), + }) + ); + } catch (error) { + this.logger.error("Error creating RemoteSettingsService", error); + return null; + } + + let builder; + try { + builder = lazy.SuggestStoreBuilder.init() + .dataPath(this.#storeDataPath) + .remoteSettingsService(rsService) + .loadExtension( + AppConstants.SQLITE_LIBRARY_FILENAME, + "sqlite3_fts5_init" + ); + } catch (error) { + this.logger.error("Error creating SuggestStoreBuilder", error); + return null; + } + + let store; + try { + store = builder.build(); + } catch (error) { + this.logger.error("Error creating SuggestStore", error); + return null; + } + + return store; + } + #uninit() { this.#store = null; this.#providerConstraintsByIngestedSuggestionType.clear(); this.#configsBySuggestionType.clear(); lazy.timerManager.unregisterTimer(INGEST_TIMER_ID); - lazy.AsyncShutdown.profileBeforeChange.removeBlocker(this.#shutdownBlocker); + lazy.AsyncShutdown.profileChangeTeardown.removeBlocker( + this.#shutdownBlocker + ); this.#shutdownBlocker = null; } diff --git a/browser/components/urlbar/tests/engagementTelemetry/browser/browser_glean_telemetry_fakespot_engagement.js b/browser/components/urlbar/tests/engagementTelemetry/browser/browser_glean_telemetry_fakespot_engagement.js index 0824d8d6c928..c516b605a10c 100644 --- a/browser/components/urlbar/tests/engagementTelemetry/browser/browser_glean_telemetry_fakespot_engagement.js +++ b/browser/components/urlbar/tests/engagementTelemetry/browser/browser_glean_telemetry_fakespot_engagement.js @@ -33,7 +33,10 @@ add_setup(async function test_setup() { ], }, { - type: "data", + // eslint-disable-next-line mozilla/valid-lazy + collection: lazy.QuickSuggestTestUtils.RS_COLLECTION.AMP, + // eslint-disable-next-line mozilla/valid-lazy + type: lazy.QuickSuggestTestUtils.RS_TYPE.AMP, // eslint-disable-next-line mozilla/valid-lazy attachment: [lazy.QuickSuggestTestUtils.ampRemoteSettings()], }, diff --git a/browser/components/urlbar/tests/engagementTelemetry/browser/head.js b/browser/components/urlbar/tests/engagementTelemetry/browser/head.js index 5db0ae4264ac..e9b6ecd29513 100644 --- a/browser/components/urlbar/tests/engagementTelemetry/browser/head.js +++ b/browser/components/urlbar/tests/engagementTelemetry/browser/head.js @@ -98,11 +98,18 @@ async function ensureQuickSuggestInit({ ...args } = {}) { return lazy.QuickSuggestTestUtils.ensureQuickSuggestInit({ remoteSettingsRecords: [ { - type: "data", + collection: lazy.QuickSuggestTestUtils.RS_COLLECTION.AMP, + type: lazy.QuickSuggestTestUtils.RS_TYPE.AMP, attachment: [ lazy.QuickSuggestTestUtils.ampRemoteSettings({ keywords: ["amp", "amp and wikipedia"], }), + ], + }, + { + collection: lazy.QuickSuggestTestUtils.RS_COLLECTION.OTHER, + type: lazy.QuickSuggestTestUtils.RS_TYPE.WIKIPEDIA, + attachment: [ lazy.QuickSuggestTestUtils.wikipediaRemoteSettings({ keywords: ["wikipedia", "amp and wikipedia"], }), diff --git a/browser/components/urlbar/tests/quicksuggest/QuickSuggestTestUtils.sys.mjs b/browser/components/urlbar/tests/quicksuggest/QuickSuggestTestUtils.sys.mjs index 2c99700ad7b3..8f1e35da2778 100644 --- a/browser/components/urlbar/tests/quicksuggest/QuickSuggestTestUtils.sys.mjs +++ b/browser/components/urlbar/tests/quicksuggest/QuickSuggestTestUtils.sys.mjs @@ -130,6 +130,20 @@ class _QuickSuggestTestUtils { } } + get RS_COLLECTION() { + return { + AMP: "quicksuggest-amp", + OTHER: "quicksuggest-other", + }; + } + + get RS_TYPE() { + return { + AMP: "amp", + WIKIPEDIA: "wikipedia", + }; + } + get DEFAULT_CONFIG() { // Return a clone so callers can modify it. return Cu.cloneInto(DEFAULT_CONFIG, this); @@ -148,7 +162,7 @@ class _QuickSuggestTestUtils { * - `record.attachment` - Optional. This should be the attachment itself * and not its metadata. It should be a JSONable object. * - `record.collection` - Optional. The name of the RS collection that - * the record should be added to. Defaults to "quicksuggest". + * the record should be added to. Defaults to "quicksuggest-other". * @param {Array} options.merinoSuggestions * Array of Merino suggestion objects. If given, this function will start * the mock Merino server and set `quicksuggest.dataCollection.enabled` to @@ -189,19 +203,6 @@ class _QuickSuggestTestUtils { this.#log("ensureQuickSuggestInit", "Awaiting ExperimentAPI.ready"); await lazy.ExperimentAPI.ready(); - // Make a Map from collection name to the array of records that should be - // added to that collection. - let recordsByCollection = remoteSettingsRecords.reduce((memo, record) => { - let collection = record.collection || "quicksuggest"; - let records = memo.get(collection); - if (!records) { - records = []; - memo.set(collection, records); - } - records.push(record); - return memo; - }, new Map()); - // Set up the local remote settings server. this.#log("ensureQuickSuggestInit", "Preparing remote settings server"); if (!this.#remoteSettingsServer) { @@ -209,11 +210,13 @@ class _QuickSuggestTestUtils { } this.#remoteSettingsServer.removeRecords(); - for (let [collection, records] of recordsByCollection.entries()) { + for (let [collection, records] of this.#recordsByCollection( + remoteSettingsRecords + )) { await this.#remoteSettingsServer.addRecords({ collection, records }); } await this.#remoteSettingsServer.addRecords({ - collection: "quicksuggest", + collection: this.RS_COLLECTION.OTHER, records: [{ type: "configuration", configuration: config }], }); @@ -299,10 +302,15 @@ class _QuickSuggestTestUtils { */ async setRemoteSettingsRecords(records, { forceSync = true } = {}) { this.#log("setRemoteSettingsRecords", "Started"); - await this.#remoteSettingsServer.setRecords({ - collection: "quicksuggest", - records, - }); + + this.#remoteSettingsServer.removeRecords(); + for (let [collection, recs] of this.#recordsByCollection(records)) { + await this.#remoteSettingsServer.addRecords({ + collection, + records: recs, + }); + } + if (forceSync) { this.#log("setRemoteSettingsRecords", "Forcing sync"); await this.forceSync(); @@ -324,7 +332,7 @@ class _QuickSuggestTestUtils { let type = "configuration"; this.#remoteSettingsServer.removeRecords({ type }); await this.#remoteSettingsServer.addRecords({ - collection: "quicksuggest", + collection: this.RS_COLLECTION.OTHER, records: [{ type, configuration: config }], }); this.#log("setConfig", "Forcing sync"); @@ -1308,6 +1316,33 @@ class _QuickSuggestTestUtils { this.info?.(`QuickSuggestTestUtils.${fnName} ${msg}`); } + #recordsByCollection(records) { + // Make a Map from collection name to the array of records that should be + // added to that collection. + let recordsByCollection = records.reduce((memo, record) => { + let collection = record.collection || this.RS_COLLECTION.OTHER; + let recs = memo.get(collection); + if (!recs) { + recs = []; + memo.set(collection, recs); + } + recs.push(record); + return memo; + }, new Map()); + + // Make sure the two main collections, "quicksuggest-amp" and + // "quicksuggest-other", are present. Otherwise the Rust component will log + // 404 errors because it expects them to exist. The errors are harmless but + // annoying. + for (let collection of Object.values(this.RS_COLLECTION)) { + if (!recordsByCollection.has(collection)) { + recordsByCollection.set(collection, []); + } + } + + return recordsByCollection; + } + #remoteSettingsServer; } diff --git a/browser/components/urlbar/tests/quicksuggest/RemoteSettingsServer.sys.mjs b/browser/components/urlbar/tests/quicksuggest/RemoteSettingsServer.sys.mjs index f91e1d55789e..e88c4db3fcca 100644 --- a/browser/components/urlbar/tests/quicksuggest/RemoteSettingsServer.sys.mjs +++ b/browser/components/urlbar/tests/quicksuggest/RemoteSettingsServer.sys.mjs @@ -315,7 +315,13 @@ export class RemoteSettingsServer { ? lazy.HTTP_404 : { body: { - metadata: null, + metadata: { + bucket, + signature: { + signature: "", + x5u: "", + }, + }, timestamp: this.#lastModified, changes: records, }, diff --git a/browser/components/urlbar/tests/quicksuggest/browser/browser_quicksuggest.js b/browser/components/urlbar/tests/quicksuggest/browser/browser_quicksuggest.js index 39acc714a9ec..533dcb73c50d 100644 --- a/browser/components/urlbar/tests/quicksuggest/browser/browser_quicksuggest.js +++ b/browser/components/urlbar/tests/quicksuggest/browser/browser_quicksuggest.js @@ -41,11 +41,18 @@ add_setup(async function () { await PlacesUtils.bookmarks.eraseEverything(); await UrlbarTestUtils.formHistory.clear(); + let isAmp = suggestion => suggestion.iab_category == "22 - Shopping"; await QuickSuggestTestUtils.ensureQuickSuggestInit({ remoteSettingsRecords: [ { - type: "data", - attachment: REMOTE_SETTINGS_RESULTS, + collection: QuickSuggestTestUtils.RS_COLLECTION.AMP, + type: QuickSuggestTestUtils.RS_TYPE.AMP, + attachment: REMOTE_SETTINGS_RESULTS.filter(isAmp), + }, + { + collection: QuickSuggestTestUtils.RS_COLLECTION.OTHER, + type: QuickSuggestTestUtils.RS_TYPE.WIKIPEDIA, + attachment: REMOTE_SETTINGS_RESULTS.filter(s => !isAmp(s)), }, ], merinoSuggestions: [], diff --git a/browser/components/urlbar/tests/quicksuggest/browser/browser_quicksuggest_block.js b/browser/components/urlbar/tests/quicksuggest/browser/browser_quicksuggest_block.js index f893d2da123e..62c3178d30fc 100644 --- a/browser/components/urlbar/tests/quicksuggest/browser/browser_quicksuggest_block.js +++ b/browser/components/urlbar/tests/quicksuggest/browser/browser_quicksuggest_block.js @@ -50,11 +50,18 @@ add_setup(async function () { await QuickSuggest.blockedSuggestions._test_readyPromise; await QuickSuggest.blockedSuggestions.clear(); + let isAmp = suggestion => suggestion.iab_category == "22 - Shopping"; await QuickSuggestTestUtils.ensureQuickSuggestInit({ remoteSettingsRecords: [ { - type: "data", - attachment: REMOTE_SETTINGS_RESULTS, + collection: QuickSuggestTestUtils.RS_COLLECTION.AMP, + type: QuickSuggestTestUtils.RS_TYPE.AMP, + attachment: REMOTE_SETTINGS_RESULTS.filter(isAmp), + }, + { + collection: QuickSuggestTestUtils.RS_COLLECTION.OTHER, + type: QuickSuggestTestUtils.RS_TYPE.WIKIPEDIA, + attachment: REMOTE_SETTINGS_RESULTS.filter(s => !isAmp(s)), }, ], }); diff --git a/browser/components/urlbar/tests/quicksuggest/browser/browser_quicksuggest_indexes.js b/browser/components/urlbar/tests/quicksuggest/browser/browser_quicksuggest_indexes.js index 4fa5bba3abd2..167fc4b4bd5f 100644 --- a/browser/components/urlbar/tests/quicksuggest/browser/browser_quicksuggest_indexes.js +++ b/browser/components/urlbar/tests/quicksuggest/browser/browser_quicksuggest_indexes.js @@ -42,11 +42,18 @@ add_setup(async function () { // suggestions so the suggested index of sponsored suggestions should be -1. await SearchTestUtils.installSearchExtension({}, { setAsDefault: true }); + let isAmp = suggestion => suggestion.iab_category == "22 - Shopping"; await QuickSuggestTestUtils.ensureQuickSuggestInit({ remoteSettingsRecords: [ { - type: "data", - attachment: REMOTE_SETTINGS_RESULTS, + collection: QuickSuggestTestUtils.RS_COLLECTION.AMP, + type: QuickSuggestTestUtils.RS_TYPE.AMP, + attachment: REMOTE_SETTINGS_RESULTS.filter(isAmp), + }, + { + collection: QuickSuggestTestUtils.RS_COLLECTION.OTHER, + type: QuickSuggestTestUtils.RS_TYPE.WIKIPEDIA, + attachment: REMOTE_SETTINGS_RESULTS.filter(s => !isAmp(s)), }, ], }); diff --git a/browser/components/urlbar/tests/quicksuggest/browser/browser_quicksuggest_ping_amp.js b/browser/components/urlbar/tests/quicksuggest/browser/browser_quicksuggest_ping_amp.js index 793bdb9f922b..f635b54ff674 100644 --- a/browser/components/urlbar/tests/quicksuggest/browser/browser_quicksuggest_ping_amp.js +++ b/browser/components/urlbar/tests/quicksuggest/browser/browser_quicksuggest_ping_amp.js @@ -17,7 +17,8 @@ add_setup(async function () { await initQuickSuggestPingTest({ remoteSettingsRecords: [ { - type: "data", + collection: QuickSuggestTestUtils.RS_COLLECTION.AMP, + type: QuickSuggestTestUtils.RS_TYPE.AMP, attachment: [SUGGESTION], }, ], diff --git a/browser/components/urlbar/tests/quicksuggest/browser/browser_telemetry_suggestMetrics.js b/browser/components/urlbar/tests/quicksuggest/browser/browser_telemetry_suggestMetrics.js index bb2ca85436a8..bc7689f99d27 100644 --- a/browser/components/urlbar/tests/quicksuggest/browser/browser_telemetry_suggestMetrics.js +++ b/browser/components/urlbar/tests/quicksuggest/browser/browser_telemetry_suggestMetrics.js @@ -5,7 +5,8 @@ const lazy = {}; const EXPECTED_INGEST_LABELS = [ // Remote settings `type` field values for the default providers - "data", + QuickSuggestTestUtils.RS_TYPE.AMP, + QuickSuggestTestUtils.RS_TYPE.WIKIPEDIA, "amo-suggestions", "yelp-suggestions", "mdn-suggestions", @@ -24,7 +25,8 @@ const EXPECTED_QUERY_LABELS = [ const REMOTE_SETTINGS_RECORDS = [ { - type: "data", + collection: QuickSuggestTestUtils.RS_COLLECTION.AMP, + type: QuickSuggestTestUtils.RS_TYPE.AMP, attachment: [QuickSuggestTestUtils.ampRemoteSettings()], }, ]; @@ -108,7 +110,8 @@ add_task(async function ingest_changed() { await QuickSuggestTestUtils.setRemoteSettingsRecords([ { - type: "data", + collection: QuickSuggestTestUtils.RS_COLLECTION.AMP, + type: QuickSuggestTestUtils.RS_TYPE.AMP, attachment: [ QuickSuggestTestUtils.ampRemoteSettings({ keywords: ["a new keyword"], @@ -131,18 +134,20 @@ add_task(async function ingest_changed() { ); checkLabeledTimingDistributionMetricIncreased( "suggest.ingestTime", - "data", + QuickSuggestTestUtils.RS_TYPE.AMP, oldIngestTimeValues, newIngestTimeValues ); checkLabeledTimingDistributionMetricIncreased( "suggest.ingestDownloadTime", - "data", + QuickSuggestTestUtils.RS_TYPE.AMP, oldIngestDownloadTimeValues, newIngestDownloadTimeValues ); - for (let label of EXPECTED_INGEST_LABELS.filter(l => l != "data")) { + for (let label of EXPECTED_INGEST_LABELS.filter( + l => l != QuickSuggestTestUtils.RS_TYPE.AMP + )) { checkLabeledTimingDistributionMetricUnchanged( "suggest.ingestTime", label, diff --git a/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest.js b/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest.js index 36fc0cd94853..aa5ae48eab06 100644 --- a/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest.js +++ b/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest.js @@ -168,22 +168,8 @@ add_setup(async function init() { UrlbarPrefs.set("scotchBonnet.enableOverride", false); - const testDataTypeResults = [ - Object.assign({}, REMOTE_SETTINGS_RESULTS[0], { title: "test-data-type" }), - ]; - - await QuickSuggestTestUtils.ensureQuickSuggestInit({ - remoteSettingsRecords: [ - { - type: "data", - attachment: REMOTE_SETTINGS_RESULTS, - }, - { - type: "test-data-type", - attachment: testDataTypeResults, - }, - ], - }); + await QuickSuggestTestUtils.ensureQuickSuggestInit(); + await resetRemoteSettingsData(); }); add_task(async function telemetryType_sponsored() { @@ -1438,12 +1424,7 @@ async function doSponsoredPriorityTest({ quickSuggestSponsoredPriority: true, }); - await QuickSuggestTestUtils.setRemoteSettingsRecords([ - { - type: "data", - attachment: remoteSettingsData, - }, - ]); + await resetRemoteSettingsData(remoteSettingsData); await QuickSuggestTestUtils.setConfig(remoteSettingsConfig); await check_results({ @@ -1455,12 +1436,7 @@ async function doSponsoredPriorityTest({ }); await cleanUpNimbusEnable(); - await QuickSuggestTestUtils.setRemoteSettingsRecords([ - { - type: "data", - attachment: REMOTE_SETTINGS_RESULTS, - }, - ]); + await resetRemoteSettingsData(); await QuickSuggestTestUtils.setConfig(QuickSuggestTestUtils.DEFAULT_CONFIG); } @@ -1913,3 +1889,19 @@ async function doAmpMatchingStrategyTest({ sandbox.restore(); } + +async function resetRemoteSettingsData(data = REMOTE_SETTINGS_RESULTS) { + let isAmp = suggestion => suggestion.iab_category == "22 - Shopping"; + await QuickSuggestTestUtils.setRemoteSettingsRecords([ + { + collection: QuickSuggestTestUtils.RS_COLLECTION.AMP, + type: QuickSuggestTestUtils.RS_TYPE.AMP, + attachment: data.filter(isAmp), + }, + { + collection: QuickSuggestTestUtils.RS_COLLECTION.OTHER, + type: QuickSuggestTestUtils.RS_TYPE.WIKIPEDIA, + attachment: data.filter(s => !isAmp(s)), + }, + ]); +} diff --git a/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_exposures.js b/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_exposures.js index 44b687047b09..d9e1f0a70d60 100644 --- a/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_exposures.js +++ b/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_exposures.js @@ -22,7 +22,7 @@ const REMOTE_SETTINGS_RECORDS = [ }, }, { - type: "data", + type: QuickSuggestTestUtils.RS_TYPE.WIKIPEDIA, attachment: [QuickSuggestTestUtils.wikipediaRemoteSettings()], }, ]; @@ -31,7 +31,11 @@ add_setup(async function () { // Add many exposure and AMP suggestions that have the "maxresults" keyword. let maxResults = UrlbarPrefs.get("maxRichResults"); Assert.greater(maxResults, 0, "This test expects maxRichResults to be > 0"); - let ampRecord = { type: "data", attachment: [] }; + let ampRecord = { + collection: QuickSuggestTestUtils.RS_COLLECTION.AMP, + type: QuickSuggestTestUtils.RS_TYPE.AMP, + attachment: [], + }; REMOTE_SETTINGS_RECORDS.push(ampRecord); for (let i = 0; i < maxResults; i++) { ampRecord.attachment.push( diff --git a/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_exposures_locales.js b/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_exposures_locales.js index a3fafabed14a..3b1130e8436a 100644 --- a/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_exposures_locales.js +++ b/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_exposures_locales.js @@ -24,11 +24,13 @@ const REMOTE_SETTINGS_RECORDS = [ }, }, { - type: "data", - attachment: [ - QuickSuggestTestUtils.ampRemoteSettings(), - QuickSuggestTestUtils.wikipediaRemoteSettings(), - ], + collection: QuickSuggestTestUtils.RS_COLLECTION.AMP, + type: QuickSuggestTestUtils.RS_TYPE.AMP, + attachment: [QuickSuggestTestUtils.ampRemoteSettings()], + }, + { + type: QuickSuggestTestUtils.RS_TYPE.WIKIPEDIA, + attachment: [QuickSuggestTestUtils.wikipediaRemoteSettings()], }, ]; diff --git a/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_merino.js b/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_merino.js index 1d8e13d47651..bd1aeef05e92 100644 --- a/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_merino.js +++ b/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_merino.js @@ -39,17 +39,12 @@ add_setup(async () => { // Set up the remote settings client with the test data. await QuickSuggestTestUtils.ensureQuickSuggestInit({ - remoteSettingsRecords: [ - { - type: "data", - attachment: REMOTE_SETTINGS_RESULTS, - }, - ], prefs: [ ["suggest.quicksuggest.nonsponsored", true], ["suggest.quicksuggest.sponsored", true], ], }); + await resetRemoteSettingsData(); Assert.equal( typeof DEFAULT_SUGGESTION_SCORE, @@ -81,12 +76,7 @@ add_task(async function merinoDisabled() { UrlbarPrefs.set("merino.endpointURL", mockEndpointUrl); - await QuickSuggestTestUtils.setRemoteSettingsRecords([ - { - type: "data", - attachment: REMOTE_SETTINGS_RESULTS, - }, - ]); + await resetRemoteSettingsData(); }); // Tests with Merino enabled but with data collection disabled. Results should @@ -108,12 +98,7 @@ add_task(async function dataCollectionDisabled() { matches: [], }); - await QuickSuggestTestUtils.setRemoteSettingsRecords([ - { - type: "data", - attachment: REMOTE_SETTINGS_RESULTS, - }, - ]); + await resetRemoteSettingsData(); }); // When the Merino suggestion has a higher score than the remote settings @@ -551,3 +536,13 @@ async function doUnmanagedTest({ pref, suggestion }) { function merinoClient() { return QuickSuggest.getFeature("SuggestBackendMerino")?.client; } + +async function resetRemoteSettingsData() { + await QuickSuggestTestUtils.setRemoteSettingsRecords([ + { + collection: QuickSuggestTestUtils.RS_COLLECTION.AMP, + type: QuickSuggestTestUtils.RS_TYPE.AMP, + attachment: REMOTE_SETTINGS_RESULTS, + }, + ]); +} diff --git a/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_scoreMap.js b/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_scoreMap.js index 322f6e738a30..37fd34fcf37d 100644 --- a/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_scoreMap.js +++ b/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_scoreMap.js @@ -25,7 +25,8 @@ const { DEFAULT_SUGGESTION_SCORE } = UrlbarProviderQuickSuggest; const REMOTE_SETTINGS_RECORDS = [ { - type: "data", + collection: QuickSuggestTestUtils.RS_COLLECTION.AMP, + type: QuickSuggestTestUtils.RS_TYPE.AMP, attachment: [ // sponsored without score QuickSuggestTestUtils.ampRemoteSettings({ @@ -51,6 +52,12 @@ const REMOTE_SETTINGS_RECORDS = [ url: "https://example.com/sponsored-with-score", title: "Sponsored with score", }), + ], + }, + { + collection: QuickSuggestTestUtils.RS_COLLECTION.OTHER, + type: QuickSuggestTestUtils.RS_TYPE.WIKIPEDIA, + attachment: [ // nonsponsored without score QuickSuggestTestUtils.wikipediaRemoteSettings({ score: undefined, @@ -95,10 +102,11 @@ const REMOTE_SETTINGS_RECORDS = [ const ADM_RECORD = REMOTE_SETTINGS_RECORDS[0]; const SPONSORED_WITHOUT_SCORE = ADM_RECORD.attachment[0]; const SPONSORED_WITH_SCORE = ADM_RECORD.attachment[1]; -const NONSPONSORED_WITHOUT_SCORE = ADM_RECORD.attachment[2]; -const NONSPONSORED_WITH_SCORE = ADM_RECORD.attachment[3]; +const WIKIPEDIA_RECORD = REMOTE_SETTINGS_RECORDS[1]; +const NONSPONSORED_WITHOUT_SCORE = WIKIPEDIA_RECORD.attachment[0]; +const NONSPONSORED_WITH_SCORE = WIKIPEDIA_RECORD.attachment[1]; -const ADDON_RECORD = REMOTE_SETTINGS_RECORDS[1]; +const ADDON_RECORD = REMOTE_SETTINGS_RECORDS[2]; const ADDON_WITH_SCORE = ADDON_RECORD.attachment[0]; const MERINO_SPONSORED_SUGGESTION = { diff --git a/browser/components/urlbar/tests/quicksuggest/unit/test_rust_ingest.js b/browser/components/urlbar/tests/quicksuggest/unit/test_rust_ingest.js index 189555b9f8a5..bcff502680b8 100644 --- a/browser/components/urlbar/tests/quicksuggest/unit/test_rust_ingest.js +++ b/browser/components/urlbar/tests/quicksuggest/unit/test_rust_ingest.js @@ -232,7 +232,7 @@ add_task(async function shutdown() { let spy = sandbox.spy(QuickSuggest.rustBackend._test_store, "interrupt"); Services.prefs.setBoolPref("toolkit.asyncshutdown.testing", true); - AsyncShutdown.profileBeforeChange._trigger(); + AsyncShutdown.profileChangeTeardown._trigger(); let calls = spy.getCalls(); Assert.equal( diff --git a/browser/components/urlbar/tests/unit/test_exposure.js b/browser/components/urlbar/tests/unit/test_exposure.js index 2ba1cc1b7d3c..157c174bfd06 100644 --- a/browser/components/urlbar/tests/unit/test_exposure.js +++ b/browser/components/urlbar/tests/unit/test_exposure.js @@ -10,21 +10,26 @@ ChromeUtils.defineESModuleGetters(this, { "resource:///modules/UrlbarProviderQuickSuggest.sys.mjs", }); -const REMOTE_SETTINGS_RESULTS = [ - QuickSuggestTestUtils.ampRemoteSettings({ - keywords: ["amp", "amp and wikipedia"], - }), - QuickSuggestTestUtils.wikipediaRemoteSettings({ - keywords: ["wikipedia", "amp and wikipedia"], - }), -]; - add_setup(async function setup() { await QuickSuggestTestUtils.ensureQuickSuggestInit({ remoteSettingsRecords: [ { - type: "data", - attachment: REMOTE_SETTINGS_RESULTS, + collection: QuickSuggestTestUtils.RS_COLLECTION.AMP, + type: QuickSuggestTestUtils.RS_TYPE.AMP, + attachment: [ + QuickSuggestTestUtils.ampRemoteSettings({ + keywords: ["amp", "amp and wikipedia"], + }), + ], + }, + { + collection: QuickSuggestTestUtils.RS_COLLECTION.OTHER, + type: QuickSuggestTestUtils.RS_TYPE.WIKIPEDIA, + attachment: [ + QuickSuggestTestUtils.wikipediaRemoteSettings({ + keywords: ["wikipedia", "amp and wikipedia"], + }), + ], }, ], prefs: [ diff --git a/third_party/rust/remote_settings/.cargo-checksum.json b/third_party/rust/remote_settings/.cargo-checksum.json index 2c5434af243b..f705e6573504 100644 --- a/third_party/rust/remote_settings/.cargo-checksum.json +++ b/third_party/rust/remote_settings/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"5d106662de7bd8f65f1c50edb46a11f54f38a91e08ccf57521978d42086fb53e","dumps/main/attachments/regions/world":"00b308033d44f61612b962f572765d14a3999586d92fc8b9fff2217a1ae070e8","dumps/main/attachments/regions/world-buffered":"1d3ed6954fac2a5b31302f5d3e8186c5fa08a20239afc0643ca5dfbb4d8a86fc","dumps/main/attachments/regions/world-buffered.meta.json":"914a71376a152036aceccb6877e079fbb9e3373c6219f24f00dd30e901a72cce","dumps/main/attachments/regions/world.meta.json":"2a47d77834997b98e563265d299723e7f7fd64c8c7a5731afc722862333d6fbd","dumps/main/regions.json":"e8990158373f82d3f89fed5089cf29e4177cc85904479128728e05025e9a0c0c","dumps/main/search-config-v2.json":"c33698dd66ed7f9dbbda857cad4f890455189e932e24c0d3b335e3e95b65239f","dumps/main/search-telemetry-v2.json":"140b3d322d6e317d97542725920be9f29c6b1d9c5f224e8c31995dddfec6bf1b","src/cache.rs":"c6179802017b43885136e7d64004890cc13e8c2d4742e04073cf404b578f63db","src/client.rs":"875a0bc5c8b3572ed86cd4b43277a715f95592c3d8ab1dd6528394ab6ad71ec3","src/config.rs":"603c7241483861a8c690464f4b50dd3dc281da7edf8aa522f90f175b85a7fa5f","src/error.rs":"20e40a0229842e12888bc43c4159e078f1d09272a43c51dae87989f76952f93b","src/jexl_filter.rs":"e4a9e29a80b216d777771434aaa6c58f627288e4b59ffa11c83dbd8e37889aa5","src/lib.rs":"fbf4e1f270380af00747294ec77ab6bfb724aa38e83bcb8d33fac3f1107850d5","src/macros.rs":"6b06d0ba42ee95235bfd71bac1a0eed02f60c894775ebee64165648b10e932c4","src/schema.rs":"348e0d5ad1840aaae796b537d21381ef91bd75be262138bfec376d9f88d205b3","src/service.rs":"73da6cecc8c804b8e55d35ea3c71c1dd1e4099ad60532b7b0da153f9cde1eb21","src/signatures.rs":"baa2dae76abd8166158fea4676e67e17c17b65af6968de52768350409dbd7092","src/storage.rs":"5ae489964d82a0305a6b250d92f4c1925cc722e44890c24f681dd97b0258b9f4","uniffi.toml":"bd7cc0e7c1981f53938f429c4f2541ac454ed4160a8a0b4670659e38acd23ee5"},"package":null} \ No newline at end of file +{"files":{"Cargo.toml":"5d106662de7bd8f65f1c50edb46a11f54f38a91e08ccf57521978d42086fb53e","dumps/main/attachments/regions/world":"00b308033d44f61612b962f572765d14a3999586d92fc8b9fff2217a1ae070e8","dumps/main/attachments/regions/world-buffered":"1d3ed6954fac2a5b31302f5d3e8186c5fa08a20239afc0643ca5dfbb4d8a86fc","dumps/main/attachments/regions/world-buffered.meta.json":"914a71376a152036aceccb6877e079fbb9e3373c6219f24f00dd30e901a72cce","dumps/main/attachments/regions/world.meta.json":"2a47d77834997b98e563265d299723e7f7fd64c8c7a5731afc722862333d6fbd","dumps/main/regions.json":"e8990158373f82d3f89fed5089cf29e4177cc85904479128728e05025e9a0c0c","dumps/main/search-config-v2.json":"c33698dd66ed7f9dbbda857cad4f890455189e932e24c0d3b335e3e95b65239f","dumps/main/search-telemetry-v2.json":"140b3d322d6e317d97542725920be9f29c6b1d9c5f224e8c31995dddfec6bf1b","src/cache.rs":"c6179802017b43885136e7d64004890cc13e8c2d4742e04073cf404b578f63db","src/client.rs":"875a0bc5c8b3572ed86cd4b43277a715f95592c3d8ab1dd6528394ab6ad71ec3","src/config.rs":"603c7241483861a8c690464f4b50dd3dc281da7edf8aa522f90f175b85a7fa5f","src/error.rs":"20e40a0229842e12888bc43c4159e078f1d09272a43c51dae87989f76952f93b","src/jexl_filter.rs":"e4a9e29a80b216d777771434aaa6c58f627288e4b59ffa11c83dbd8e37889aa5","src/lib.rs":"464157ddf3b906c8f480c73dc3161890c8bc76cc95345c6857fee7a57385dc29","src/macros.rs":"6b06d0ba42ee95235bfd71bac1a0eed02f60c894775ebee64165648b10e932c4","src/schema.rs":"348e0d5ad1840aaae796b537d21381ef91bd75be262138bfec376d9f88d205b3","src/service.rs":"73da6cecc8c804b8e55d35ea3c71c1dd1e4099ad60532b7b0da153f9cde1eb21","src/signatures.rs":"baa2dae76abd8166158fea4676e67e17c17b65af6968de52768350409dbd7092","src/storage.rs":"5ae489964d82a0305a6b250d92f4c1925cc722e44890c24f681dd97b0258b9f4","uniffi.toml":"bd7cc0e7c1981f53938f429c4f2541ac454ed4160a8a0b4670659e38acd23ee5"},"package":null} \ No newline at end of file diff --git a/third_party/rust/remote_settings/src/lib.rs b/third_party/rust/remote_settings/src/lib.rs index f0a1a8ad2536..fc6fe782109c 100644 --- a/third_party/rust/remote_settings/src/lib.rs +++ b/third_party/rust/remote_settings/src/lib.rs @@ -198,6 +198,11 @@ impl RemoteSettingsClient { pub fn get_attachment(&self, record: &RemoteSettingsRecord) -> ApiResult> { self.internal.get_attachment(record) } + + #[handle_error(Error)] + pub fn sync(&self) -> ApiResult<()> { + self.internal.sync() + } } impl RemoteSettingsClient { diff --git a/third_party/rust/suggest/.cargo-checksum.json b/third_party/rust/suggest/.cargo-checksum.json index 2a34cf8353de..20f792c0bde1 100644 --- a/third_party/rust/suggest/.cargo-checksum.json +++ b/third_party/rust/suggest/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"b02cecce9453963daaaa3b10cd21ca52741496cc3a67de6a3f8b2a7fe45af044","README.md":"5e28baf874b643d756228bdab345e287bf107d3182dfe6a18aafadcc4b9a3fc9","benches/benchmark_all.rs":"5909dfb1e62793afb1f2bc15b75914527a4d14fce6796307c04a309e45c0598c","metrics.yaml":"0540ab2271aeab7f07335c7ceec12acde942995f9dcb3c29070489aa61899d56","src/benchmarks/README.md":"ccee8dbddba8762d0453fa855bd6984137b224b8c019f3dd8e86a3c303f51d71","src/benchmarks/client.rs":"a777c0b876a481a21f9d5fbb696b42672ed0b4af359f62f047ac8240d3e35853","src/benchmarks/geoname.rs":"00fab05cf9465cf8e22e143cde75a81885411001b240af00efda4071975d0563","src/benchmarks/ingest.rs":"d4bde332287cc4a8d95fd7852d7563537f30c578e218a01d32ea7a3d50af3811","src/benchmarks/mod.rs":"1f21f3d3773f88e42c736eed8f770d09bc3fcee559988dbff79a1b02f250b9c5","src/benchmarks/query.rs":"d54946063e72cf98e7f46d94665c17c66af637774c2bb50cd5798dbe63d74f3c","src/bin/debug_ingestion_sizes.rs":"ce6e810be7b3fc19e826d75b622b82cfab5a1a99397a6d0833c2c4eebff2d364","src/config.rs":"0ca876e845841bb6429862c0904c82265003f53b55aea053fac60aed278586a7","src/db.rs":"0aa826507cceaff99cf5f45040ff0cd8cc5424346f0341f0d3ad27c685f30e74","src/error.rs":"e2ef3ec0e0b2b8ecbb8f2f1717d4cb753af06913b8395d086b7643098ad100a7","src/fakespot.rs":"f501c9fe5296e7c130a9fcb532b861465717652cb5ef688230bc7a3b94df91b1","src/geoname.rs":"811f7b26e547be5557bdefb3867206dd4f30237eaef6b3602bef683db5f44586","src/lib.rs":"67d77bf55498ce57c9e607d34e2bc5820403dda1207e85bf1f1c79d235d862f7","src/metrics.rs":"871f0d834efbbc9e26d61f66fa31f0021dcf41444746cd7c082f93ba9628e399","src/pocket.rs":"1316668840ec9b4ea886223921dc9d3b5a1731d1a5206c0b1089f2a6c45c1b7b","src/provider.rs":"b1ec744b867eb5bb40c7e52750e0ff8cb1b34568583e3a625a8d1740517eed6e","src/query.rs":"dcf3c3ddb72564d61b93a0360da6e6e8cb6e62d75b9a743e4a4cf19fb800af68","src/rs.rs":"1d636fac6fdf332c8d14905766d1a1993b7070e0e9f4ca3e427ce9940d8ace5b","src/schema.rs":"ca93e8bbc2d1d42487177f242838f9a36c03ac387b031c8a9f2c0d21cec245a0","src/store.rs":"f4236f04a53a4f8e5f25d210e83cbdeb84f25696cf9229207320f4f3cf930a46","src/suggestion.rs":"cdfc2a60355dfb15dec3d941f1d8137daa2f2ed08465717460e04075911d182b","src/testing/client.rs":"f8c9bd32d0f4cf364daebe114d580c7e36a83b69c07884d14170969620d9a437","src/testing/data.rs":"d92561f8a95cce108c43e5ed040ef9104bc4f370c01f47fe041c2f2c2a493ee0","src/testing/mod.rs":"4d2781c77ed9ace9d80d6d00c63a06bf28a4156f223616fffe3c07e64a8041db","src/util.rs":"52c6ec405637afa2d1a89f29fbbb7dcc341546b6deb97d326c4490bbf8713cb0","src/weather.rs":"8e8958a5a16f09f7d33efc6036d4ba980a2eea53c2d16bcbb37debebde28ef61","src/yelp.rs":"0b9dfa698d9c3162d47c0103d1799838d444345f9d7f943eedc6bcc98fd8b57d","uniffi.toml":"8205e4679ac26d53e70af0f85c013fd27cda1119f4322aebf5f2b9403d45a611"},"package":null} \ No newline at end of file +{"files":{"Cargo.toml":"b02cecce9453963daaaa3b10cd21ca52741496cc3a67de6a3f8b2a7fe45af044","README.md":"5e28baf874b643d756228bdab345e287bf107d3182dfe6a18aafadcc4b9a3fc9","benches/benchmark_all.rs":"5909dfb1e62793afb1f2bc15b75914527a4d14fce6796307c04a309e45c0598c","metrics.yaml":"0540ab2271aeab7f07335c7ceec12acde942995f9dcb3c29070489aa61899d56","src/benchmarks/README.md":"ccee8dbddba8762d0453fa855bd6984137b224b8c019f3dd8e86a3c303f51d71","src/benchmarks/client.rs":"e5897d4e2eda06809fa6dc6db4e780b9ef266f613fb113aa6613b83f7005dd0b","src/benchmarks/geoname.rs":"00fab05cf9465cf8e22e143cde75a81885411001b240af00efda4071975d0563","src/benchmarks/ingest.rs":"1f3b5eca704c51bc8f972e7a3492a518516461e5834f97a5f7d1855a048ab16b","src/benchmarks/mod.rs":"ac8965ca749f2932dc90299b159026c73416afadde1f2e71a2613d7d58d6ac3d","src/benchmarks/query.rs":"d54946063e72cf98e7f46d94665c17c66af637774c2bb50cd5798dbe63d74f3c","src/bin/debug_ingestion_sizes.rs":"ce6e810be7b3fc19e826d75b622b82cfab5a1a99397a6d0833c2c4eebff2d364","src/config.rs":"0ca876e845841bb6429862c0904c82265003f53b55aea053fac60aed278586a7","src/db.rs":"e41cbfb922d3c4123ee014f3bcd17c2819aead424c68b51256377a0c8740ef4c","src/error.rs":"e2ef3ec0e0b2b8ecbb8f2f1717d4cb753af06913b8395d086b7643098ad100a7","src/fakespot.rs":"f501c9fe5296e7c130a9fcb532b861465717652cb5ef688230bc7a3b94df91b1","src/geoname.rs":"77376dbc7d06532a7797a93b863f150317df7f31d9200d375c8ea489ac8bee6f","src/lib.rs":"67d77bf55498ce57c9e607d34e2bc5820403dda1207e85bf1f1c79d235d862f7","src/metrics.rs":"871f0d834efbbc9e26d61f66fa31f0021dcf41444746cd7c082f93ba9628e399","src/pocket.rs":"1316668840ec9b4ea886223921dc9d3b5a1731d1a5206c0b1089f2a6c45c1b7b","src/provider.rs":"eaf893b55473d0f6ce7fbc45a70e5d994b054c1d369453eeb12c3d3cf0c1dc31","src/query.rs":"3556e2c76e3fa20f93fa78173162c79bf11fefba930deaa762fa7c5d85cd6f41","src/rs.rs":"c41facd0bd1706065f29267cbf230cb8baae4b34aae85f487b90fd7620bdc0d2","src/schema.rs":"7d0e176e278cca33a76aa83efcbef882d08c3036bc63b930f4f29fd352aafe72","src/store.rs":"200620f428a70e0fa6ae505be07870335843fe5381f26cd1244cdf9817b17b32","src/suggestion.rs":"7e295a534d6914e6c70cc14e0bc7df953b1b266232c812175c82e1a58d0305f9","src/testing/client.rs":"47a32fd84c733001f11e8bfff94dc8c060b6b0780346dca5ddc7a5f5489c1d85","src/testing/data.rs":"2a25c4ba7997f0bd5d1815666dff31b8db845f6f22f3635e878921695a4e783c","src/testing/mod.rs":"dce5a18cc2e6b951304e613055dd8e6b0d89c90934eee55e424ecfdf92f745a5","src/util.rs":"52c6ec405637afa2d1a89f29fbbb7dcc341546b6deb97d326c4490bbf8713cb0","src/weather.rs":"7cc9167dcdfca49d6ad91eba6fba4d5fd49f45052f25a7fe3ad6749d3e6783fb","src/yelp.rs":"0b9dfa698d9c3162d47c0103d1799838d444345f9d7f943eedc6bcc98fd8b57d","uniffi.toml":"8205e4679ac26d53e70af0f85c013fd27cda1119f4322aebf5f2b9403d45a611"},"package":null} \ No newline at end of file diff --git a/third_party/rust/suggest/src/benchmarks/client.rs b/third_party/rust/suggest/src/benchmarks/client.rs index 8c36f4911677..640772c4258e 100644 --- a/third_party/rust/suggest/src/benchmarks/client.rs +++ b/third_party/rust/suggest/src/benchmarks/client.rs @@ -4,7 +4,7 @@ use std::collections::HashMap; -use crate::{db::SuggestDao, error::Error, rs, Result}; +use crate::{error::Error, rs, Result}; /// Remotes settings client for benchmarking /// @@ -24,16 +24,25 @@ impl RemoteSettingsBenchmarkClient { remote_settings::RemoteSettings::new(remote_settings::RemoteSettingsConfig { server: None, bucket_name: None, - collection_name: "quicksuggest".to_owned(), + collection_name: rs::Collection::Amp.name().to_owned(), server_url: None, })?, - rs::Collection::Quicksuggest, + rs::Collection::Amp, )?; new_benchmark_client.fetch_data_with_client( remote_settings::RemoteSettings::new(remote_settings::RemoteSettingsConfig { server: None, bucket_name: None, - collection_name: "fakespot-suggest-products".to_owned(), + collection_name: rs::Collection::Other.name().to_owned(), + server_url: None, + })?, + rs::Collection::Other, + )?; + new_benchmark_client.fetch_data_with_client( + remote_settings::RemoteSettings::new(remote_settings::RemoteSettingsConfig { + server: None, + bucket_name: None, + collection_name: rs::Collection::Fakespot.name().to_owned(), server_url: None, })?, rs::Collection::Fakespot, @@ -87,11 +96,7 @@ impl RemoteSettingsBenchmarkClient { } impl rs::Client for RemoteSettingsBenchmarkClient { - fn get_records( - &self, - collection: rs::Collection, - _db: &mut SuggestDao, - ) -> Result> { + fn get_records(&self, collection: rs::Collection) -> Result> { Ok(self .records .iter() diff --git a/third_party/rust/suggest/src/benchmarks/ingest.rs b/third_party/rust/suggest/src/benchmarks/ingest.rs index 99ad6cac691f..c4be3cd9c3a0 100644 --- a/third_party/rust/suggest/src/benchmarks/ingest.rs +++ b/third_party/rust/suggest/src/benchmarks/ingest.rs @@ -6,7 +6,8 @@ use std::sync::OnceLock; use crate::{ benchmarks::{client::RemoteSettingsBenchmarkClient, unique_db_filename, BenchmarkWithInput}, - rs::SuggestRecordType, + provider::SuggestionProvider, + rs::{Collection, SuggestRecordType}, store::SuggestStoreInner, SuggestIngestionConstraints, }; @@ -14,6 +15,7 @@ use crate::{ pub struct IngestBenchmark { temp_dir: tempfile::TempDir, client: RemoteSettingsBenchmarkClient, + collection: Collection, record_type: SuggestRecordType, reingest: bool, } @@ -31,11 +33,24 @@ fn get_benchmark_client() -> RemoteSettingsBenchmarkClient { } impl IngestBenchmark { - pub fn new(record_type: SuggestRecordType, reingest: bool) -> Self { + pub fn new(provider: SuggestionProvider, reingest: bool) -> Self { + Self::new_with_record_type( + provider.primary_collection(), + provider.primary_record_type(), + reingest, + ) + } + + pub fn new_with_record_type( + collection: Collection, + record_type: SuggestRecordType, + reingest: bool, + ) -> Self { let temp_dir = tempfile::tempdir().unwrap(); Self { client: get_benchmark_client(), temp_dir, + collection, record_type, reingest, } @@ -58,7 +73,7 @@ impl BenchmarkWithInput for IngestBenchmark { let store = SuggestStoreInner::new(data_path, vec![], self.client.clone()); store.ensure_db_initialized(); if self.reingest { - store.ingest_records_by_type(self.record_type); + store.ingest_records_by_type(self.collection, self.record_type); store.force_reingest(); } InputType(store) @@ -66,7 +81,7 @@ impl BenchmarkWithInput for IngestBenchmark { fn benchmarked_code(&self, _: &Self::GlobalInput, input: Self::IterationInput) { let InputType(store) = input; - store.ingest_records_by_type(self.record_type); + store.ingest_records_by_type(self.collection, self.record_type); } } @@ -74,84 +89,104 @@ impl BenchmarkWithInput for IngestBenchmark { pub fn all_benchmarks() -> Vec<(&'static str, IngestBenchmark)> { vec![ ( - "ingest-icon", - IngestBenchmark::new(SuggestRecordType::Icon, false), + "ingest-icon-amp", + IngestBenchmark::new_with_record_type(Collection::Amp, SuggestRecordType::Icon, false), ), ( - "ingest-again-icon", - IngestBenchmark::new(SuggestRecordType::Icon, true), + "ingest-again-icon-amp", + IngestBenchmark::new_with_record_type(Collection::Amp, SuggestRecordType::Icon, true), ), ( - "ingest-amp-wikipedia", - IngestBenchmark::new(SuggestRecordType::AmpWikipedia, false), + "ingest-icon-other", + IngestBenchmark::new_with_record_type( + Collection::Other, + SuggestRecordType::Icon, + false, + ), ), ( - "ingest-again-amp-wikipedia", - IngestBenchmark::new(SuggestRecordType::AmpWikipedia, true), + "ingest-again-icon-other", + IngestBenchmark::new_with_record_type(Collection::Other, SuggestRecordType::Icon, true), + ), + ( + "ingest-amp", + IngestBenchmark::new(SuggestionProvider::Amp, false), + ), + ( + "ingest-again-amp", + IngestBenchmark::new(SuggestionProvider::Amp, true), + ), + ( + "ingest-wikipedia", + IngestBenchmark::new(SuggestionProvider::Wikipedia, false), + ), + ( + "ingest-again-wikipedia", + IngestBenchmark::new(SuggestionProvider::Wikipedia, true), ), ( "ingest-amo", - IngestBenchmark::new(SuggestRecordType::Amo, false), + IngestBenchmark::new(SuggestionProvider::Amo, false), ), ( "ingest-again-amo", - IngestBenchmark::new(SuggestRecordType::Amo, true), + IngestBenchmark::new(SuggestionProvider::Amo, true), ), ( "ingest-pocket", - IngestBenchmark::new(SuggestRecordType::Pocket, false), + IngestBenchmark::new(SuggestionProvider::Pocket, false), ), ( "ingest-again-pocket", - IngestBenchmark::new(SuggestRecordType::Pocket, true), + IngestBenchmark::new(SuggestionProvider::Pocket, true), ), ( "ingest-yelp", - IngestBenchmark::new(SuggestRecordType::Yelp, false), + IngestBenchmark::new(SuggestionProvider::Yelp, false), ), ( "ingest-again-yelp", - IngestBenchmark::new(SuggestRecordType::Yelp, true), + IngestBenchmark::new(SuggestionProvider::Yelp, true), ), ( "ingest-mdn", - IngestBenchmark::new(SuggestRecordType::Mdn, false), + IngestBenchmark::new(SuggestionProvider::Mdn, false), ), ( "ingest-again-mdn", - IngestBenchmark::new(SuggestRecordType::Mdn, true), + IngestBenchmark::new(SuggestionProvider::Mdn, true), ), ( "ingest-weather", - IngestBenchmark::new(SuggestRecordType::Weather, false), + IngestBenchmark::new(SuggestionProvider::Weather, false), ), ( "ingest-again-weather", - IngestBenchmark::new(SuggestRecordType::Weather, true), + IngestBenchmark::new(SuggestionProvider::Weather, true), ), ( "ingest-global-config", - IngestBenchmark::new(SuggestRecordType::GlobalConfig, false), + IngestBenchmark::new_with_record_type( + Collection::Other, + SuggestRecordType::GlobalConfig, + false, + ), ), ( "ingest-again-global-config", - IngestBenchmark::new(SuggestRecordType::GlobalConfig, true), - ), - ( - "ingest-amp-mobile", - IngestBenchmark::new(SuggestRecordType::AmpMobile, false), - ), - ( - "ingest-again-amp-mobile", - IngestBenchmark::new(SuggestRecordType::AmpMobile, true), + IngestBenchmark::new_with_record_type( + Collection::Other, + SuggestRecordType::GlobalConfig, + true, + ), ), ( "ingest-fakespot", - IngestBenchmark::new(SuggestRecordType::Fakespot, false), + IngestBenchmark::new(SuggestionProvider::Fakespot, false), ), ( "ingest-again-fakespot", - IngestBenchmark::new(SuggestRecordType::Fakespot, true), + IngestBenchmark::new(SuggestionProvider::Fakespot, true), ), ] } diff --git a/third_party/rust/suggest/src/benchmarks/mod.rs b/third_party/rust/suggest/src/benchmarks/mod.rs index 7a315348669d..70183ce5331f 100644 --- a/third_party/rust/suggest/src/benchmarks/mod.rs +++ b/third_party/rust/suggest/src/benchmarks/mod.rs @@ -20,6 +20,9 @@ use std::{ use tempfile::TempDir; use crate::{SuggestIngestionConstraints, SuggestStore}; +use remote_settings::{RemoteSettingsConfig2, RemoteSettingsContext, RemoteSettingsService}; + +use std::sync::Arc; pub mod client; pub mod geoname; @@ -76,8 +79,15 @@ fn new_store() -> SuggestStore { let (starter_dir, starter_db_path) = starter.get_or_insert_with(|| { let temp_dir = tempfile::tempdir().unwrap(); let db_path = temp_dir.path().join(unique_db_filename()); - let store = - SuggestStore::new(&db_path.to_string_lossy(), None).expect("Error building store"); + let rs_config = RemoteSettingsConfig2 { + bucket_name: None, + server: None, + app_context: Some(RemoteSettingsContext::default()), + }; + let remote_settings_service = + Arc::new(RemoteSettingsService::new("".to_string(), rs_config).unwrap()); + let store = SuggestStore::new(&db_path.to_string_lossy(), remote_settings_service) + .expect("Error building store"); store .ingest(SuggestIngestionConstraints::all_providers()) .expect("Error during ingestion"); @@ -86,8 +96,16 @@ fn new_store() -> SuggestStore { }); let db_path = starter_dir.path().join(unique_db_filename()); + let rs_config = RemoteSettingsConfig2 { + bucket_name: None, + server: None, + app_context: Some(RemoteSettingsContext::default()), + }; + let remote_settings_service = + Arc::new(RemoteSettingsService::new("".to_string(), rs_config).unwrap()); std::fs::copy(starter_db_path, &db_path).expect("Error copying starter DB file"); - SuggestStore::new(&db_path.to_string_lossy(), None).expect("Error building store") + SuggestStore::new(&db_path.to_string_lossy(), remote_settings_service) + .expect("Error building store") } /// Cleanup the temp directory created for SuggestStore instances used in the benchmarks. diff --git a/third_party/rust/suggest/src/db.rs b/third_party/rust/suggest/src/db.rs index a80de8013c99..f1e877c3f9f3 100644 --- a/third_party/rust/suggest/src/db.rs +++ b/third_party/rust/suggest/src/db.rs @@ -7,11 +7,10 @@ use std::{cell::OnceCell, path::Path, sync::Arc}; use interrupt_support::{SqlInterruptHandle, SqlInterruptScope}; use parking_lot::{Mutex, MutexGuard}; -use remote_settings::RemoteSettingsResponse; use rusqlite::{ named_params, types::{FromSql, ToSql}, - Connection, OptionalExtension, + Connection, }; use sql_support::{open_database, repeat_sql_vars, ConnExt}; @@ -24,12 +23,12 @@ use crate::{ provider::{AmpMatchingStrategy, SuggestionProvider}, query::{full_keywords_to_fts_content, FtsQuery}, rs::{ - DownloadedAmoSuggestion, DownloadedAmpSuggestion, DownloadedAmpWikipediaSuggestion, - DownloadedExposureSuggestion, DownloadedFakespotSuggestion, DownloadedMdnSuggestion, - DownloadedPocketSuggestion, DownloadedWikipediaSuggestion, Record, SuggestRecordId, + DownloadedAmoSuggestion, DownloadedAmpSuggestion, DownloadedExposureSuggestion, + DownloadedFakespotSuggestion, DownloadedMdnSuggestion, DownloadedPocketSuggestion, + DownloadedWikipediaSuggestion, Record, SuggestRecordId, }, schema::{clear_database, SuggestConnectionInitializer}, - suggestion::{cook_raw_suggestion_url, AmpSuggestionType, FtsMatchInfo, Suggestion}, + suggestion::{cook_raw_suggestion_url, FtsMatchInfo, Suggestion}, util::full_keyword, weather::WeatherCache, Result, SuggestionQuery, @@ -202,52 +201,6 @@ impl<'a> SuggestDao<'a> { // // These methods implement CRUD operations - pub fn read_cached_rs_data(&self, collection: &str) -> Option { - match self.try_read_cached_rs_data(collection) { - Ok(result) => result, - Err(e) => { - // Return None on failure . If the cached data is corrupted, maybe because the - // RemoteSettingsResponse schema changed, then we want to just continue on. This also matches - // the proposed API from #6328, so it should be easier to adapt this code once - // that's merged. - error_support::report_error!("suggest-rs-cache-read", "{e}"); - None - } - } - } - - pub fn write_cached_rs_data(&mut self, collection: &str, data: &RemoteSettingsResponse) { - if let Err(e) = self.try_write_cached_rs_data(collection, data) { - // Return None on failure for the same reason as in [Self::read_cached_rs_data] - error_support::report_error!("suggest-rs-cache-write", "{e}"); - } - } - - fn try_read_cached_rs_data(&self, collection: &str) -> Result> { - let mut stmt = self - .conn - .prepare_cached("SELECT data FROM rs_cache WHERE collection = ?")?; - let data = stmt - .query_row((collection,), |row| row.get::<_, Vec>(0)) - .optional()?; - match data { - Some(data) => Ok(Some(rmp_serde::decode::from_slice(data.as_slice())?)), - None => Ok(None), - } - } - - fn try_write_cached_rs_data( - &mut self, - collection: &str, - data: &RemoteSettingsResponse, - ) -> Result<()> { - let mut stmt = self - .conn - .prepare_cached("INSERT OR REPLACE INTO rs_cache(collection, data) VALUES(?, ?)")?; - stmt.execute((collection, rmp_serde::encode::to_vec(data)?))?; - Ok(()) - } - pub fn get_ingested_records(&self) -> Result> { let mut stmt = self .conn @@ -302,25 +255,21 @@ impl<'a> SuggestDao<'a> { } /// Fetches Suggestions of type Amp provider that match the given query - pub fn fetch_amp_suggestions( - &self, - query: &SuggestionQuery, - suggestion_type: AmpSuggestionType, - ) -> Result> { + pub fn fetch_amp_suggestions(&self, query: &SuggestionQuery) -> Result> { let strategy = query .provider_constraints .as_ref() .and_then(|c| c.amp_alternative_matching.as_ref()); match strategy { - None => self.fetch_amp_suggestions_using_keywords(query, suggestion_type, true), + None => self.fetch_amp_suggestions_using_keywords(query, true), Some(AmpMatchingStrategy::NoKeywordExpansion) => { - self.fetch_amp_suggestions_using_keywords(query, suggestion_type, false) + self.fetch_amp_suggestions_using_keywords(query, false) } Some(AmpMatchingStrategy::FtsAgainstFullKeywords) => { - self.fetch_amp_suggestions_using_fts(query, suggestion_type, "full_keywords") + self.fetch_amp_suggestions_using_fts(query, "full_keywords") } Some(AmpMatchingStrategy::FtsAgainstTitle) => { - self.fetch_amp_suggestions_using_fts(query, suggestion_type, "title") + self.fetch_amp_suggestions_using_fts(query, "title") } } } @@ -328,14 +277,9 @@ impl<'a> SuggestDao<'a> { pub fn fetch_amp_suggestions_using_keywords( &self, query: &SuggestionQuery, - suggestion_type: AmpSuggestionType, allow_keyword_expansion: bool, ) -> Result> { let keyword_lowercased = &query.keyword.to_lowercase(); - let provider = match suggestion_type { - AmpSuggestionType::Mobile => SuggestionProvider::AmpMobile, - AmpSuggestionType::Desktop => SuggestionProvider::Amp, - }; let where_extra = if allow_keyword_expansion { "" } else { @@ -369,7 +313,7 @@ impl<'a> SuggestDao<'a> { ), named_params! { ":keyword": keyword_lowercased, - ":provider": provider + ":provider": SuggestionProvider::Amp, }, |row| -> Result { let suggestion_id: i64 = row.get("id")?; @@ -448,15 +392,10 @@ impl<'a> SuggestDao<'a> { pub fn fetch_amp_suggestions_using_fts( &self, query: &SuggestionQuery, - suggestion_type: AmpSuggestionType, fts_column: &str, ) -> Result> { let fts_query = query.fts_query(); let match_arg = &fts_query.match_arg; - let provider = match suggestion_type { - AmpSuggestionType::Mobile => SuggestionProvider::AmpMobile, - AmpSuggestionType::Desktop => SuggestionProvider::Amp, - }; let suggestions = self.conn.query_rows_and_then_cached( &format!( r#" @@ -480,7 +419,7 @@ impl<'a> SuggestDao<'a> { "# ), named_params! { - ":provider": provider + ":provider": SuggestionProvider::Amp, }, |row| -> Result { let suggestion_id: i64 = row.get("id")?; @@ -1114,59 +1053,43 @@ impl<'a> SuggestDao<'a> { Ok(()) } - /// Inserts all suggestions from a downloaded AMP-Wikipedia attachment into - /// the database. - pub fn insert_amp_wikipedia_suggestions( + /// Inserts suggestions from an AMP attachment into the database. + pub fn insert_amp_suggestions( &mut self, record_id: &SuggestRecordId, - suggestions: &[DownloadedAmpWikipediaSuggestion], + suggestions: &[DownloadedAmpSuggestion], enable_fts: bool, ) -> Result<()> { // Prepare statements outside of the loop. This results in a large performance // improvement on a fresh ingest, since there are so many rows. let mut suggestion_insert = SuggestionInsertStatement::new(self.conn)?; let mut amp_insert = AmpInsertStatement::new(self.conn)?; - let mut wiki_insert = WikipediaInsertStatement::new(self.conn)?; let mut keyword_insert = KeywordInsertStatement::new(self.conn)?; let mut fts_insert = AmpFtsInsertStatement::new(self.conn)?; for suggestion in suggestions { self.scope.err_if_interrupted()?; - let common_details = suggestion.common_details(); - let provider = suggestion.provider(); - let suggestion_id = suggestion_insert.execute( record_id, - &common_details.title, - &common_details.url, - common_details.score.unwrap_or(DEFAULT_SUGGESTION_SCORE), - provider, + &suggestion.title, + &suggestion.url, + suggestion.score.unwrap_or(DEFAULT_SUGGESTION_SCORE), + SuggestionProvider::Amp, )?; - match suggestion { - DownloadedAmpWikipediaSuggestion::Amp(amp) => { - amp_insert.execute(suggestion_id, amp)?; - } - DownloadedAmpWikipediaSuggestion::Wikipedia(wikipedia) => { - wiki_insert.execute(suggestion_id, wikipedia)?; - } - } + amp_insert.execute(suggestion_id, suggestion)?; if enable_fts { fts_insert.execute( suggestion_id, - &common_details.full_keywords_fts_column(), - &common_details.title, + &suggestion.full_keywords_fts_column(), + &suggestion.title, )?; } let mut full_keyword_inserter = FullKeywordInserter::new(self.conn, suggestion_id); - for keyword in common_details.keywords() { - let full_keyword_id = match (suggestion, keyword.full_keyword) { - // Try to associate full keyword data. Only do this for AMP, we decided to - // skip it for Wikipedia in https://bugzilla.mozilla.org/show_bug.cgi?id=1876217 - (DownloadedAmpWikipediaSuggestion::Amp(_), Some(full_keyword)) => { - Some(full_keyword_inserter.maybe_insert(full_keyword)?) - } - _ => None, + for keyword in suggestion.keywords() { + let full_keyword_id = if let Some(full_keyword) = keyword.full_keyword { + Some(full_keyword_inserter.maybe_insert(full_keyword)?) + } else { + None }; - keyword_insert.execute( suggestion_id, keyword.keyword, @@ -1178,40 +1101,30 @@ impl<'a> SuggestDao<'a> { Ok(()) } - /// Inserts all suggestions from a downloaded AMP-Mobile attachment into - /// the database. - pub fn insert_amp_mobile_suggestions( + /// Inserts suggestions from a Wikipedia attachment into the database. + pub fn insert_wikipedia_suggestions( &mut self, record_id: &SuggestRecordId, - suggestions: &[DownloadedAmpSuggestion], + suggestions: &[DownloadedWikipediaSuggestion], ) -> Result<()> { + // Prepare statements outside of the loop. This results in a large performance + // improvement on a fresh ingest, since there are so many rows. let mut suggestion_insert = SuggestionInsertStatement::new(self.conn)?; - let mut amp_insert = AmpInsertStatement::new(self.conn)?; + let mut wiki_insert = WikipediaInsertStatement::new(self.conn)?; let mut keyword_insert = KeywordInsertStatement::new(self.conn)?; for suggestion in suggestions { self.scope.err_if_interrupted()?; - let common_details = &suggestion.common_details; let suggestion_id = suggestion_insert.execute( record_id, - &common_details.title, - &common_details.url, - common_details.score.unwrap_or(DEFAULT_SUGGESTION_SCORE), - SuggestionProvider::AmpMobile, + &suggestion.title, + &suggestion.url, + suggestion.score.unwrap_or(DEFAULT_SUGGESTION_SCORE), + SuggestionProvider::Wikipedia, )?; - amp_insert.execute(suggestion_id, suggestion)?; - - let mut full_keyword_inserter = FullKeywordInserter::new(self.conn, suggestion_id); - for keyword in common_details.keywords() { - let full_keyword_id = keyword - .full_keyword - .map(|full_keyword| full_keyword_inserter.maybe_insert(full_keyword)) - .transpose()?; - keyword_insert.execute( - suggestion_id, - keyword.keyword, - full_keyword_id, - keyword.rank, - )?; + wiki_insert.execute(suggestion_id, suggestion)?; + for keyword in suggestion.keywords() { + // Don't update `full_keywords`, see bug 1876217. + keyword_insert.execute(suggestion_id, keyword.keyword, None, keyword.rank)?; } } Ok(()) diff --git a/third_party/rust/suggest/src/geoname.rs b/third_party/rust/suggest/src/geoname.rs index 4cc46068e95d..58e073791fb2 100644 --- a/third_party/rust/suggest/src/geoname.rs +++ b/third_party/rust/suggest/src/geoname.rs @@ -396,7 +396,7 @@ struct GeonameInsertStatement<'conn>(rusqlite::Statement<'conn>); impl<'conn> GeonameInsertStatement<'conn> { fn new(conn: &'conn Connection) -> Result { Ok(Self(conn.prepare( - "INSERT INTO geonames( + "INSERT OR REPLACE INTO geonames( id, record_id, name, @@ -437,7 +437,7 @@ struct GeonameAlternateInsertStatement<'conn>(rusqlite::Statement<'conn>); impl<'conn> GeonameAlternateInsertStatement<'conn> { fn new(conn: &'conn Connection) -> Result { Ok(Self(conn.prepare( - "INSERT INTO geonames_alternates( + "INSERT OR REPLACE INTO geonames_alternates( name, geoname_id, iso_language @@ -460,7 +460,7 @@ struct GeonameMetricsInsertStatement<'conn>(rusqlite::Statement<'conn>); impl<'conn> GeonameMetricsInsertStatement<'conn> { pub(crate) fn new(conn: &'conn Connection) -> Result { Ok(Self(conn.prepare( - "INSERT INTO geonames_metrics( + "INSERT OR REPLACE INTO geonames_metrics( record_id, max_name_length, max_name_word_count @@ -487,204 +487,221 @@ impl<'conn> GeonameMetricsInsertStatement<'conn> { pub(crate) mod tests { use super::*; use crate::{ - provider::SuggestionProvider, store::tests::TestStore, testing::*, + provider::SuggestionProvider, + rs::{Collection, SuggestRecordType}, + store::tests::TestStore, + testing::*, SuggestIngestionConstraints, }; + use serde_json::Value as JsonValue; pub(crate) const LONG_NAME: &str = "aaa bbb ccc ddd eee fff ggg hhh iii jjj kkk lll mmm nnn ooo ppp qqq rrr sss ttt uuu vvv www x yyy zzz"; + pub(crate) fn geoname_mock_record(id: &str, json: JsonValue) -> MockRecord { + MockRecord { + collection: Collection::Other, + record_type: SuggestRecordType::Geonames, + id: id.to_string(), + inline_data: None, + attachment: Some(MockAttachment::Json(json)), + } + } + pub(crate) fn new_test_store() -> TestStore { - TestStore::new(MockRemoteSettingsClient::default().with_record( - "geonames", - "geonames-0", - json!({ - "max_alternate_name_length": LONG_NAME.len(), - "max_alternate_name_word_count": LONG_NAME.split_whitespace().collect::>().len(), - "geonames": [ - // Waterloo, AL - { - "id": 1, - "name": "Waterloo", - "latitude": "34.91814", - "longitude": "-88.0642", - "feature_class": "P", - "feature_code": "PPL", - "country_code": "US", - "admin1_code": "AL", - "population": 200, - "alternate_names": ["waterloo"], - "alternate_names_2": [ - { "name": "waterloo" }, - ], - }, - // AL - { - "id": 2, - "name": "Alabama", - "latitude": "32.75041", - "longitude": "-86.75026", - "feature_class": "A", - "feature_code": "ADM1", - "country_code": "US", - "admin1_code": "AL", - "population": 4530315, - "alternate_names": ["al", "alabama"], - "alternate_names_2": [ - { "name": "alabama" }, - { "name": "al", "iso_language": "abbr" }, - ], - }, - // Waterloo, IA - { - "id": 3, - "name": "Waterloo", - "latitude": "42.49276", - "longitude": "-92.34296", - "feature_class": "P", - "feature_code": "PPLA2", - "country_code": "US", - "admin1_code": "IA", - "population": 68460, - "alternate_names": ["waterloo"], - "alternate_names_2": [ - { "name": "waterloo" }, - ], - }, - // IA - { - "id": 4, - "name": "Iowa", - "latitude": "42.00027", - "longitude": "-93.50049", - "feature_class": "A", - "feature_code": "ADM1", - "country_code": "US", - "admin1_code": "IA", - "population": 2955010, - "alternate_names": ["ia", "iowa"], - "alternate_names_2": [ - { "name": "iowa" }, - { "name": "ia", "iso_language": "abbr" }, - ], - }, - // Waterloo (Lake, not a city or region) - { - "id": 5, - "name": "waterloo lake", - "latitude": "31.25044", - "longitude": "-99.25061", - "feature_class": "H", - "feature_code": "LK", - "country_code": "US", - "admin1_code": "TX", - "population": 0, - "alternate_names_2": [ - { "name": "waterloo lake" }, - { "name": "waterloo", "iso_language": "en" }, - ], - }, - // New York City - { - "id": 6, - "name": "New York City", - "latitude": "40.71427", - "longitude": "-74.00597", - "feature_class": "P", - "feature_code": "PPL", - "country_code": "US", - "admin1_code": "NY", - "population": 8804190, - "alternate_names_2": [ - { "name": "new york city" }, - { "name": "new york", "iso_language": "en" }, - { "name": "nyc", "iso_language": "abbr" }, - { "name": "ny", "iso_language": "abbr" }, - ], - }, - // Rochester, NY - { - "id": 7, - "name": "Rochester", - "latitude": "43.15478", - "longitude": "-77.61556", - "feature_class": "P", - "feature_code": "PPLA2", - "country_code": "US", - "admin1_code": "NY", - "population": 209802, - "alternate_names_2": [ - { "name": "rochester" }, - { "name": "roc", "iso_language": "iata" }, - ], - }, - // NY state - { - "id": 8, - "name": "New York", - "latitude": "43.00035", - "longitude": "-75.4999", - "feature_class": "A", - "feature_code": "ADM1", - "country_code": "US", - "admin1_code": "NY", - "population": 19274244, - "alternate_names_2": [ - { "name": "new york" }, - { "name": "ny", "iso_language": "abbr" }, - ], - }, - // Waco, TX: Has a surprising IATA airport code that's a - // common English word and not a prefix of the city name - { - "id": 9, - "name": "Waco", - "latitude": "31.54933", - "longitude": "-97.14667", - "feature_class": "P", - "feature_code": "PPLA2", - "country_code": "US", - "admin1_code": "TX", - "population": 132356, - "alternate_names_2": [ - { "name": "waco" }, - { "name": "act", "iso_language": "iata" }, - ], - }, - // TX - { - "id": 10, - "name": "Texas", - "latitude": "31.25044", - "longitude": "-99.25061", - "feature_class": "A", - "feature_code": "ADM1", - "country_code": "US", - "admin1_code": "TX", - "population": 22875689, - "alternate_names_2": [ - { "name": "texas" }, - { "name": "tx", "iso_language": "abbr" }, - ], - }, - // Made-up city with a long name - { - "id": 999, - "name": "Long Name", - "latitude": "38.06084", - "longitude": "-97.92977", - "feature_class": "P", - "feature_code": "PPLA2", - "country_code": "US", - "admin1_code": "NY", - "population": 2, - "alternate_names_2": [ - { "name": "long name" }, - { "name": LONG_NAME, "iso_language": "en" }, - ], - }, - ], - }), - )) + TestStore::new( + MockRemoteSettingsClient::default() + .with_record(geoname_mock_record("geonames-0", geonames_data())), + ) + } + + fn geonames_data() -> serde_json::Value { + json!({ + "max_alternate_name_length": LONG_NAME.len(), + "max_alternate_name_word_count": LONG_NAME.split_whitespace().collect::>().len(), + "geonames": [ + // Waterloo, AL + { + "id": 1, + "name": "Waterloo", + "latitude": "34.91814", + "longitude": "-88.0642", + "feature_class": "P", + "feature_code": "PPL", + "country_code": "US", + "admin1_code": "AL", + "population": 200, + "alternate_names": ["waterloo"], + "alternate_names_2": [ + { "name": "waterloo" }, + ], + }, + // AL + { + "id": 2, + "name": "Alabama", + "latitude": "32.75041", + "longitude": "-86.75026", + "feature_class": "A", + "feature_code": "ADM1", + "country_code": "US", + "admin1_code": "AL", + "population": 4530315, + "alternate_names": ["al", "alabama"], + "alternate_names_2": [ + { "name": "alabama" }, + { "name": "al", "iso_language": "abbr" }, + ], + }, + // Waterloo, IA + { + "id": 3, + "name": "Waterloo", + "latitude": "42.49276", + "longitude": "-92.34296", + "feature_class": "P", + "feature_code": "PPLA2", + "country_code": "US", + "admin1_code": "IA", + "population": 68460, + "alternate_names": ["waterloo"], + "alternate_names_2": [ + { "name": "waterloo" }, + ], + }, + // IA + { + "id": 4, + "name": "Iowa", + "latitude": "42.00027", + "longitude": "-93.50049", + "feature_class": "A", + "feature_code": "ADM1", + "country_code": "US", + "admin1_code": "IA", + "population": 2955010, + "alternate_names": ["ia", "iowa"], + "alternate_names_2": [ + { "name": "iowa" }, + { "name": "ia", "iso_language": "abbr" }, + ], + }, + // Waterloo (Lake, not a city or region) + { + "id": 5, + "name": "waterloo lake", + "latitude": "31.25044", + "longitude": "-99.25061", + "feature_class": "H", + "feature_code": "LK", + "country_code": "US", + "admin1_code": "TX", + "population": 0, + "alternate_names_2": [ + { "name": "waterloo lake" }, + { "name": "waterloo", "iso_language": "en" }, + ], + }, + // New York City + { + "id": 6, + "name": "New York City", + "latitude": "40.71427", + "longitude": "-74.00597", + "feature_class": "P", + "feature_code": "PPL", + "country_code": "US", + "admin1_code": "NY", + "population": 8804190, + "alternate_names_2": [ + { "name": "new york city" }, + { "name": "new york", "iso_language": "en" }, + { "name": "nyc", "iso_language": "abbr" }, + { "name": "ny", "iso_language": "abbr" }, + ], + }, + // Rochester, NY + { + "id": 7, + "name": "Rochester", + "latitude": "43.15478", + "longitude": "-77.61556", + "feature_class": "P", + "feature_code": "PPLA2", + "country_code": "US", + "admin1_code": "NY", + "population": 209802, + "alternate_names_2": [ + { "name": "rochester" }, + { "name": "roc", "iso_language": "iata" }, + ], + }, + // NY state + { + "id": 8, + "name": "New York", + "latitude": "43.00035", + "longitude": "-75.4999", + "feature_class": "A", + "feature_code": "ADM1", + "country_code": "US", + "admin1_code": "NY", + "population": 19274244, + "alternate_names_2": [ + { "name": "new york" }, + { "name": "ny", "iso_language": "abbr" }, + ], + }, + // Waco, TX: Has a surprising IATA airport code that's a + // common English word and not a prefix of the city name + { + "id": 9, + "name": "Waco", + "latitude": "31.54933", + "longitude": "-97.14667", + "feature_class": "P", + "feature_code": "PPLA2", + "country_code": "US", + "admin1_code": "TX", + "population": 132356, + "alternate_names_2": [ + { "name": "waco" }, + { "name": "act", "iso_language": "iata" }, + ], + }, + // TX + { + "id": 10, + "name": "Texas", + "latitude": "31.25044", + "longitude": "-99.25061", + "feature_class": "A", + "feature_code": "ADM1", + "country_code": "US", + "admin1_code": "TX", + "population": 22875689, + "alternate_names_2": [ + { "name": "texas" }, + { "name": "tx", "iso_language": "abbr" }, + ], + }, + // Made-up city with a long name + { + "id": 999, + "name": "Long Name", + "latitude": "38.06084", + "longitude": "-97.92977", + "feature_class": "P", + "feature_code": "PPLA2", + "country_code": "US", + "admin1_code": "NY", + "population": 2, + "alternate_names_2": [ + { "name": "long name" }, + { "name": LONG_NAME, "iso_language": "en" }, + ], + }, + ], + }) } pub(crate) fn waterloo_al() -> Geoname { @@ -1288,24 +1305,22 @@ pub(crate) mod tests { // metrics so the other values don't matter. let mut store = TestStore::new( MockRemoteSettingsClient::default() - .with_record( - "geonames", + .with_record(geoname_mock_record( "geonames-0", json!({ "max_alternate_name_length": 10, "max_alternate_name_word_count": 5, "geonames": [] }), - ) - .with_record( - "geonames", + )) + .with_record(geoname_mock_record( "geonames-1", json!({ "max_alternate_name_length": 20, "max_alternate_name_word_count": 2, "geonames": [] }), - ), + )), ); // Ingest weather to also ingest geonames. @@ -1324,7 +1339,7 @@ pub(crate) mod tests { // Delete the first record. The metrics should change. store .client_mut() - .delete_record("quicksuggest", "geonames-0"); + .delete_record(geoname_mock_record("geonames-0", json!({}))); store.ingest(SuggestIngestionConstraints { providers: Some(vec![SuggestionProvider::Weather]), ..SuggestIngestionConstraints::all_providers() @@ -1337,15 +1352,14 @@ pub(crate) mod tests { })?; // Add a new record. The metrics should change again. - store.client_mut().add_record( - "geonames", + store.client_mut().add_record(geoname_mock_record( "geonames-3", json!({ "max_alternate_name_length": 15, "max_alternate_name_word_count": 3, "geonames": [] }), - ); + )); store.ingest(SuggestIngestionConstraints { providers: Some(vec![SuggestionProvider::Weather]), ..SuggestIngestionConstraints::all_providers() @@ -1394,7 +1408,7 @@ pub(crate) mod tests { // Delete the record. store .client_mut() - .delete_record("quicksuggest", "geonames-0"); + .delete_record(geoname_mock_record("geonames-0", json!({}))); store.ingest(SuggestIngestionConstraints { providers: Some(vec![SuggestionProvider::Weather]), ..SuggestIngestionConstraints::all_providers() @@ -1425,6 +1439,91 @@ pub(crate) mod tests { Ok(()) } + #[test] + fn geonames_reingest() -> anyhow::Result<()> { + before_each(); + + // Create the store with the test data and ingest. + let mut store = new_test_store(); + store.ingest(SuggestIngestionConstraints { + providers: Some(vec![SuggestionProvider::Weather]), + ..SuggestIngestionConstraints::all_providers() + }); + + // Get the table counts. + let (geonames_count, alternates_count) = store.read(|dao| { + Ok(( + dao.conn.query_row_and_then( + "SELECT count(*) FROM geonames", + [], + |row| -> Result { Ok(row.get(0)?) }, + )?, + dao.conn.query_row_and_then( + "SELECT count(*) FROM geonames_alternates", + [], + |row| -> Result { Ok(row.get(0)?) }, + )?, + )) + })?; + + assert_ne!(geonames_count, 0); + assert_ne!(alternates_count, 0); + + // Delete the record and add a new record with a new ID that has the + // same data. + store + .client_mut() + .delete_record(geoname_mock_record("geonames-0", json!({}))) + .add_record(geoname_mock_record("geonames-1", geonames_data())); + + // Ingest again. + store.ingest(SuggestIngestionConstraints { + providers: Some(vec![SuggestionProvider::Weather]), + ..SuggestIngestionConstraints::all_providers() + }); + + // Make sure we have a match. + store.read(|dao| { + assert_eq!( + dao.fetch_geonames("waterloo", false, None, None)?, + vec![ + GeonameMatch { + geoname: waterloo_ia(), + match_type: GeonameMatchType::Name, + prefix: false, + }, + GeonameMatch { + geoname: waterloo_al(), + match_type: GeonameMatchType::Name, + prefix: false, + }, + ], + ); + Ok(()) + })?; + + // Get the table counts again. They should be the same as before. + let (new_geonames_count, new_alternates_count) = store.read(|dao| { + Ok(( + dao.conn.query_row_and_then( + "SELECT count(*) FROM geonames", + [], + |row| -> Result { Ok(row.get(0)?) }, + )?, + dao.conn.query_row_and_then( + "SELECT count(*) FROM geonames_alternates", + [], + |row| -> Result { Ok(row.get(0)?) }, + )?, + )) + })?; + + assert_eq!(geonames_count, new_geonames_count); + assert_eq!(alternates_count, new_alternates_count); + + Ok(()) + } + #[test] fn geonames_store_api() -> anyhow::Result<()> { before_each(); diff --git a/third_party/rust/suggest/src/provider.rs b/third_party/rust/suggest/src/provider.rs index e521a3b22c36..1503eb5c8ecf 100644 --- a/third_party/rust/suggest/src/provider.rs +++ b/third_party/rust/suggest/src/provider.rs @@ -3,24 +3,32 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use std::fmt; +use std::{ + collections::{HashMap, HashSet}, + fmt, +}; use rusqlite::{ types::{FromSql, FromSqlError, FromSqlResult, ToSql, ToSqlOutput, ValueRef}, Result as RusqliteResult, }; -use crate::rs::SuggestRecordType; +use crate::rs::{Collection, SuggestRecordType}; + +#[cfg(test)] +use serde_json::Value as JsonValue; + +#[cfg(test)] +use crate::testing::{MockAttachment, MockIcon, MockRecord}; /// Record types from these providers will be ingested when consumers do not /// specify providers in `SuggestIngestionConstraints`. -pub(crate) const DEFAULT_INGEST_PROVIDERS: [SuggestionProvider; 6] = [ +pub(crate) const DEFAULT_INGEST_PROVIDERS: [SuggestionProvider; 5] = [ SuggestionProvider::Amp, SuggestionProvider::Wikipedia, SuggestionProvider::Amo, SuggestionProvider::Yelp, SuggestionProvider::Mdn, - SuggestionProvider::AmpMobile, ]; /// A provider is a source of search suggestions. @@ -34,9 +42,8 @@ pub enum SuggestionProvider { Yelp = 5, Mdn = 6, Weather = 7, - AmpMobile = 8, - Fakespot = 9, - Exposure = 10, + Fakespot = 8, + Exposure = 9, } impl fmt::Display for SuggestionProvider { @@ -49,7 +56,6 @@ impl fmt::Display for SuggestionProvider { Self::Yelp => write!(f, "yelp"), Self::Mdn => write!(f, "mdn"), Self::Weather => write!(f, "weather"), - Self::AmpMobile => write!(f, "ampmobile"), Self::Fakespot => write!(f, "fakespot"), Self::Exposure => write!(f, "exposure"), } @@ -67,7 +73,7 @@ impl FromSql for SuggestionProvider { } impl SuggestionProvider { - pub fn all() -> [Self; 10] { + pub fn all() -> [Self; 9] { [ Self::Amp, Self::Wikipedia, @@ -76,7 +82,6 @@ impl SuggestionProvider { Self::Yelp, Self::Mdn, Self::Weather, - Self::AmpMobile, Self::Fakespot, Self::Exposure, ] @@ -92,27 +97,74 @@ impl SuggestionProvider { 5 => Some(Self::Yelp), 6 => Some(Self::Mdn), 7 => Some(Self::Weather), - 8 => Some(Self::AmpMobile), - 9 => Some(Self::Fakespot), - 10 => Some(Self::Exposure), + 8 => Some(Self::Fakespot), + 9 => Some(Self::Exposure), _ => None, } } - pub(crate) fn record_types(&self) -> Vec { + /// The collection that stores the provider's primary record. + pub(crate) fn primary_collection(&self) -> Collection { match self { - Self::Amp => vec![SuggestRecordType::AmpWikipedia], - Self::Wikipedia => vec![SuggestRecordType::AmpWikipedia], - Self::Amo => vec![SuggestRecordType::Amo], - Self::Pocket => vec![SuggestRecordType::Pocket], - Self::Yelp => vec![SuggestRecordType::Yelp, SuggestRecordType::Geonames], - Self::Mdn => vec![SuggestRecordType::Mdn], - Self::Weather => vec![SuggestRecordType::Weather, SuggestRecordType::Geonames], - Self::AmpMobile => vec![SuggestRecordType::AmpMobile], - Self::Fakespot => vec![SuggestRecordType::Fakespot], - Self::Exposure => vec![SuggestRecordType::Exposure], + Self::Amp => Collection::Amp, + Self::Fakespot => Collection::Fakespot, + _ => Collection::Other, } } + + /// The provider's primary record type. + pub(crate) fn primary_record_type(&self) -> SuggestRecordType { + match self { + Self::Amp => SuggestRecordType::Amp, + Self::Wikipedia => SuggestRecordType::Wikipedia, + Self::Amo => SuggestRecordType::Amo, + Self::Pocket => SuggestRecordType::Pocket, + Self::Yelp => SuggestRecordType::Yelp, + Self::Mdn => SuggestRecordType::Mdn, + Self::Weather => SuggestRecordType::Weather, + Self::Fakespot => SuggestRecordType::Fakespot, + Self::Exposure => SuggestRecordType::Exposure, + } + } + + /// Other record types and their collections that the provider depends on. + fn secondary_record_types(&self) -> Option>> { + match self { + Self::Amp => Some(HashMap::from([( + Collection::Amp, + HashSet::from([SuggestRecordType::Icon]), + )])), + Self::Wikipedia => Some(HashMap::from([( + Collection::Other, + HashSet::from([SuggestRecordType::Icon]), + )])), + Self::Yelp => Some(HashMap::from([( + Collection::Other, + HashSet::from([SuggestRecordType::Icon, SuggestRecordType::Geonames]), + )])), + Self::Weather => Some(HashMap::from([( + Collection::Other, + HashSet::from([SuggestRecordType::Geonames]), + )])), + Self::Fakespot => Some(HashMap::from([( + Collection::Fakespot, + HashSet::from([SuggestRecordType::Icon]), + )])), + _ => None, + } + } + + /// All record types and their collections that the provider depends on, + /// including primary and secondary records. + pub(crate) fn record_types_by_collection( + &self, + ) -> HashMap> { + let mut rts = self.secondary_record_types().unwrap_or_default(); + rts.entry(self.primary_collection()) + .or_default() + .insert(self.primary_record_type()); + rts + } } impl ToSql for SuggestionProvider { @@ -121,6 +173,42 @@ impl ToSql for SuggestionProvider { } } +#[cfg(test)] +impl SuggestionProvider { + pub fn record(&self, record_id: &str, attachment: JsonValue) -> MockRecord { + self.full_record(record_id, None, Some(MockAttachment::Json(attachment))) + } + + pub fn empty_record(&self, record_id: &str) -> MockRecord { + self.full_record(record_id, None, None) + } + + pub fn full_record( + &self, + record_id: &str, + inline_data: Option, + attachment: Option, + ) -> MockRecord { + MockRecord { + collection: self.primary_collection(), + record_type: self.primary_record_type(), + id: record_id.to_string(), + inline_data, + attachment, + } + } + + pub fn icon(&self, icon: MockIcon) -> MockRecord { + MockRecord { + collection: self.primary_collection(), + record_type: SuggestRecordType::Icon, + id: format!("icon-{}", icon.id), + inline_data: None, + attachment: Some(MockAttachment::Icon(icon)), + } + } +} + /// Some providers manage multiple suggestion subtypes. Queries, ingests, and /// other operations on those providers must be constrained to a desired subtype. #[derive(Clone, Default, Debug, uniffi::Record)] diff --git a/third_party/rust/suggest/src/query.rs b/third_party/rust/suggest/src/query.rs index 1b32cbc79705..9f44a0e7b6b9 100644 --- a/third_party/rust/suggest/src/query.rs +++ b/third_party/rust/suggest/src/query.rs @@ -69,14 +69,6 @@ impl SuggestionQuery { } } - pub fn amp_mobile(keyword: &str) -> Self { - Self { - keyword: keyword.into(), - providers: vec![SuggestionProvider::AmpMobile], - ..Self::default() - } - } - pub fn amo(keyword: &str) -> Self { Self { keyword: keyword.into(), diff --git a/third_party/rust/suggest/src/rs.rs b/third_party/rust/suggest/src/rs.rs index 809c12d1ba70..00c4f3442e5a 100644 --- a/third_party/rust/suggest/src/rs.rs +++ b/third_party/rust/suggest/src/rs.rs @@ -31,27 +31,30 @@ //! the new suggestion in their results, and return `Suggestion::T` variants //! as needed. -use std::fmt; +use std::{fmt, sync::Arc}; -use remote_settings::{Attachment, RemoteSettingsRecord}; -use serde::{Deserialize, Deserializer}; - -use crate::{ - db::SuggestDao, error::Error, provider::SuggestionProvider, - query::full_keywords_to_fts_content, Result, +use remote_settings::{ + Attachment, RemoteSettingsClient, RemoteSettingsError, RemoteSettingsRecord, + RemoteSettingsService, }; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_json::{Map, Value}; + +use crate::{error::Error, query::full_keywords_to_fts_content, Result}; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum Collection { - Quicksuggest, + Amp, Fakespot, + Other, } impl Collection { pub fn name(&self) -> &'static str { match self { - Self::Quicksuggest => "quicksuggest", + Self::Amp => "quicksuggest-amp", Self::Fakespot => "fakespot-suggest-products", + Self::Other => "quicksuggest-other", } } } @@ -69,85 +72,59 @@ pub(crate) trait Client { /// client-side filtering. /// /// Records that can't be parsed as [SuggestRecord] are ignored. - fn get_records(&self, collection: Collection, dao: &mut SuggestDao) -> Result>; + fn get_records(&self, collection: Collection) -> Result>; fn download_attachment(&self, record: &Record) -> Result>; } /// Implements the [Client] trait using a real remote settings client -pub struct RemoteSettingsClient { +pub struct SuggestRemoteSettingsClient { // Create a separate client for each collection name - quicksuggest_client: remote_settings::RemoteSettings, - fakespot_client: remote_settings::RemoteSettings, + amp_client: Arc, + other_client: Arc, + fakespot_client: Arc, } -impl RemoteSettingsClient { - pub fn new( - server: Option, - bucket_name: Option, - server_url: Option, - ) -> Result { +impl SuggestRemoteSettingsClient { + pub fn new(rs_service: &RemoteSettingsService) -> Result { Ok(Self { - quicksuggest_client: remote_settings::RemoteSettings::new( - remote_settings::RemoteSettingsConfig { - server: server.clone(), - bucket_name: bucket_name.clone(), - collection_name: "quicksuggest".to_owned(), - server_url: server_url.clone(), - }, - )?, - fakespot_client: remote_settings::RemoteSettings::new( - remote_settings::RemoteSettingsConfig { - server, - bucket_name, - collection_name: "fakespot-suggest-products".to_owned(), - server_url, - }, - )?, + amp_client: rs_service.make_client(Collection::Amp.name().to_owned())?, + other_client: rs_service.make_client(Collection::Other.name().to_owned())?, + fakespot_client: rs_service.make_client(Collection::Fakespot.name().to_owned())?, }) } - fn client_for_collection(&self, collection: Collection) -> &remote_settings::RemoteSettings { + fn client_for_collection(&self, collection: Collection) -> &RemoteSettingsClient { match collection { + Collection::Amp => &self.amp_client, + Collection::Other => &self.other_client, Collection::Fakespot => &self.fakespot_client, - Collection::Quicksuggest => &self.quicksuggest_client, } } } -impl Client for RemoteSettingsClient { - fn get_records(&self, collection: Collection, dao: &mut SuggestDao) -> Result> { - // For now, handle the cache manually. Once 6328 is merged, we should be able to delegate - // this to remote_settings. +impl Client for SuggestRemoteSettingsClient { + fn get_records(&self, collection: Collection) -> Result> { let client = self.client_for_collection(collection); - let cache = dao.read_cached_rs_data(collection.name()); - let last_modified = match &cache { - Some(response) => response.last_modified, - None => 0, - }; - let response = match cache { - None => client.get_records()?, - Some(cache) => remote_settings::cache::merge_cache_and_response( - cache, - client.get_records_since(last_modified)?, - ), - }; - if last_modified != response.last_modified { - dao.write_cached_rs_data(collection.name(), &response); + client.sync()?; + let response = client.get_records(false); + match response { + Some(r) => Ok(r + .into_iter() + .filter_map(|r| Record::new(r, collection).ok()) + .collect()), + None => Err(Error::RemoteSettings(RemoteSettingsError::Other { + reason: "Unable to get records".to_owned(), + })), } - - Ok(response - .records - .into_iter() - .filter_map(|r| Record::new(r, collection).ok()) - .collect()) } fn download_attachment(&self, record: &Record) -> Result> { + let converted_record: RemoteSettingsRecord = record.clone().into(); match &record.attachment { - Some(a) => Ok(self + Some(_) => Ok(self .client_for_collection(record.collection) - .get_attachment(&a.location)?), + .get_attachment(&converted_record)?), None => Err(Error::MissingAttachment(record.id.to_string())), } } @@ -181,17 +158,31 @@ impl Record { } } +impl From for RemoteSettingsRecord { + fn from(record: Record) -> Self { + RemoteSettingsRecord { + id: record.id.to_string(), + last_modified: record.last_modified, + deleted: false, + attachment: record.attachment.clone(), + fields: record.payload.to_json_map(), + } + } +} + /// A record in the Suggest Remote Settings collection. /// /// Most Suggest records don't carry inline fields except for `type`. /// Suggestions themselves are typically stored in each record's attachment. -#[derive(Clone, Debug, Deserialize)] +#[derive(Clone, Debug, Deserialize, Serialize)] #[serde(tag = "type")] pub(crate) enum SuggestRecord { #[serde(rename = "icon")] Icon, - #[serde(rename = "data")] - AmpWikipedia, + #[serde(rename = "amp")] + Amp, + #[serde(rename = "wikipedia")] + Wikipedia, #[serde(rename = "amo-suggestions")] Amo, #[serde(rename = "pocket-suggestions")] @@ -204,8 +195,6 @@ pub(crate) enum SuggestRecord { Weather, #[serde(rename = "configuration")] GlobalConfig(DownloadedGlobalConfig), - #[serde(rename = "amp-mobile-suggestions")] - AmpMobile, #[serde(rename = "fakespot-suggestions")] Fakespot, #[serde(rename = "exposure-suggestions")] @@ -214,20 +203,29 @@ pub(crate) enum SuggestRecord { Geonames, } +impl SuggestRecord { + fn to_json_map(&self) -> Map { + match serde_json::to_value(self) { + Ok(Value::Object(map)) => map, + _ => unreachable!(), + } + } +} + /// Enum for the different record types that can be consumed. /// Extracting this from the serialization enum so that we can /// extend it to get type metadata. #[derive(Copy, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)] pub enum SuggestRecordType { Icon, - AmpWikipedia, + Amp, + Wikipedia, Amo, Pocket, Yelp, Mdn, Weather, GlobalConfig, - AmpMobile, Fakespot, Exposure, Geonames, @@ -237,14 +235,14 @@ impl From<&SuggestRecord> for SuggestRecordType { fn from(suggest_record: &SuggestRecord) -> Self { match suggest_record { SuggestRecord::Amo => Self::Amo, - SuggestRecord::AmpWikipedia => Self::AmpWikipedia, + SuggestRecord::Amp => Self::Amp, + SuggestRecord::Wikipedia => Self::Wikipedia, SuggestRecord::Icon => Self::Icon, SuggestRecord::Mdn => Self::Mdn, SuggestRecord::Pocket => Self::Pocket, SuggestRecord::Weather => Self::Weather, SuggestRecord::Yelp => Self::Yelp, SuggestRecord::GlobalConfig(_) => Self::GlobalConfig, - SuggestRecord::AmpMobile => Self::AmpMobile, SuggestRecord::Fakespot => Self::Fakespot, SuggestRecord::Exposure(_) => Self::Exposure, SuggestRecord::Geonames => Self::Geonames, @@ -266,14 +264,14 @@ impl SuggestRecordType { pub fn all() -> &'static [SuggestRecordType] { &[ Self::Icon, - Self::AmpWikipedia, + Self::Amp, + Self::Wikipedia, Self::Amo, Self::Pocket, Self::Yelp, Self::Mdn, Self::Weather, Self::GlobalConfig, - Self::AmpMobile, Self::Fakespot, Self::Exposure, Self::Geonames, @@ -283,26 +281,19 @@ impl SuggestRecordType { pub fn as_str(&self) -> &str { match self { Self::Icon => "icon", - Self::AmpWikipedia => "data", + Self::Amp => "amp", + Self::Wikipedia => "wikipedia", Self::Amo => "amo-suggestions", Self::Pocket => "pocket-suggestions", Self::Yelp => "yelp-suggestions", Self::Mdn => "mdn-suggestions", Self::Weather => "weather", Self::GlobalConfig => "configuration", - Self::AmpMobile => "amp-mobile-suggestions", Self::Fakespot => "fakespot-suggestions", Self::Exposure => "exposure-suggestions", Self::Geonames => "geonames", } } - - pub fn collection(&self) -> Collection { - match self { - Self::Fakespot => Collection::Fakespot, - _ => Collection::Quicksuggest, - } - } } /// Represents either a single value, or a list of values. This is used to @@ -359,22 +350,15 @@ impl fmt::Display for SuggestRecordId { } } -/// Fields that are common to all downloaded suggestions. +/// An AMP suggestion to ingest from an AMP attachment. #[derive(Clone, Debug, Default, Deserialize)] -pub(crate) struct DownloadedSuggestionCommonDetails { +pub(crate) struct DownloadedAmpSuggestion { pub keywords: Vec, pub title: String, pub url: String, pub score: Option, #[serde(default)] pub full_keywords: Vec<(String, usize)>, -} - -/// An AMP suggestion to ingest from an AMP-Wikipedia attachment. -#[derive(Clone, Debug, Default, Deserialize)] -pub(crate) struct DownloadedAmpSuggestion { - #[serde(flatten)] - pub common_details: DownloadedSuggestionCommonDetails, pub advertiser: String, #[serde(rename = "id")] pub block_id: i32, @@ -385,59 +369,45 @@ pub(crate) struct DownloadedAmpSuggestion { pub icon_id: String, } -/// A Wikipedia suggestion to ingest from an AMP-Wikipedia attachment. +/// A Wikipedia suggestion to ingest from a Wikipedia attachment. #[derive(Clone, Debug, Default, Deserialize)] pub(crate) struct DownloadedWikipediaSuggestion { - #[serde(flatten)] - pub common_details: DownloadedSuggestionCommonDetails, + pub keywords: Vec, + pub title: String, + pub url: String, + pub score: Option, + #[serde(default)] + pub full_keywords: Vec<(String, usize)>, #[serde(rename = "icon")] pub icon_id: String, } -/// A suggestion to ingest from an AMP-Wikipedia attachment downloaded from -/// Remote Settings. -#[derive(Clone, Debug)] -pub(crate) enum DownloadedAmpWikipediaSuggestion { - Amp(DownloadedAmpSuggestion), - Wikipedia(DownloadedWikipediaSuggestion), +/// Iterate over all AMP/Wikipedia-style keywords. +pub fn iterate_keywords<'a>( + keywords: &'a [String], + full_keywords: &'a [(String, usize)], +) -> impl Iterator> { + let full_keywords_iter = full_keywords + .iter() + .flat_map(|(full_keyword, repeat_for)| { + std::iter::repeat(Some(full_keyword.as_str())).take(*repeat_for) + }) + .chain(std::iter::repeat(None)); // In case of insufficient full keywords, just fill in with infinite `None`s + // + keywords + .iter() + .zip(full_keywords_iter) + .enumerate() + .map(move |(i, (keyword, full_keyword))| AmpKeyword { + rank: i, + keyword, + full_keyword, + }) } -impl DownloadedAmpWikipediaSuggestion { - /// Returns the details that are common to AMP and Wikipedia suggestions. - pub fn common_details(&self) -> &DownloadedSuggestionCommonDetails { - match self { - Self::Amp(DownloadedAmpSuggestion { common_details, .. }) => common_details, - Self::Wikipedia(DownloadedWikipediaSuggestion { common_details, .. }) => common_details, - } - } - - /// Returns the provider of this suggestion. - pub fn provider(&self) -> SuggestionProvider { - match self { - DownloadedAmpWikipediaSuggestion::Amp(_) => SuggestionProvider::Amp, - DownloadedAmpWikipediaSuggestion::Wikipedia(_) => SuggestionProvider::Wikipedia, - } - } -} - -impl DownloadedSuggestionCommonDetails { - /// Iterate over all keywords for this suggestion +impl DownloadedAmpSuggestion { pub fn keywords(&self) -> impl Iterator> { - let full_keywords = self - .full_keywords - .iter() - .flat_map(|(full_keyword, repeat_for)| { - std::iter::repeat(Some(full_keyword.as_str())).take(*repeat_for) - }) - .chain(std::iter::repeat(None)); // In case of insufficient full keywords, just fill in with infinite `None`s - // - self.keywords.iter().zip(full_keywords).enumerate().map( - move |(i, (keyword, full_keyword))| AmpKeyword { - rank: i, - keyword, - full_keyword, - }, - ) + iterate_keywords(&self.keywords, &self.full_keywords) } pub fn full_keywords_fts_column(&self) -> String { @@ -445,6 +415,12 @@ impl DownloadedSuggestionCommonDetails { } } +impl DownloadedWikipediaSuggestion { + pub fn keywords(&self) -> impl Iterator> { + iterate_keywords(&self.keywords, &self.full_keywords) + } +} + #[derive(Debug, PartialEq, Eq)] pub(crate) struct AmpKeyword<'a> { pub rank: usize, @@ -452,44 +428,6 @@ pub(crate) struct AmpKeyword<'a> { pub full_keyword: Option<&'a str>, } -impl<'de> Deserialize<'de> for DownloadedAmpWikipediaSuggestion { - fn deserialize( - deserializer: D, - ) -> std::result::Result - where - D: Deserializer<'de>, - { - // AMP and Wikipedia suggestions use the same schema. To separate them, - // we use a "maybe tagged" outer enum with tagged and untagged variants, - // and a "tagged" inner enum. - // - // Wikipedia suggestions will deserialize successfully into the tagged - // variant. AMP suggestions will try the tagged variant, fail, and fall - // back to the untagged variant. - // - // This approach works around serde-rs/serde#912. - - #[derive(Deserialize)] - #[serde(untagged)] - enum MaybeTagged { - Tagged(Tagged), - Untagged(DownloadedAmpSuggestion), - } - - #[derive(Deserialize)] - #[serde(tag = "advertiser")] - enum Tagged { - #[serde(rename = "Wikipedia")] - Wikipedia(DownloadedWikipediaSuggestion), - } - - Ok(match MaybeTagged::deserialize(deserializer)? { - MaybeTagged::Tagged(Tagged::Wikipedia(wikipedia)) => Self::Wikipedia(wikipedia), - MaybeTagged::Untagged(amp) => Self::Amp(amp), - }) - } -} - /// An AMO suggestion to ingest from an attachment #[derive(Clone, Debug, Deserialize)] pub(crate) struct DownloadedAmoSuggestion { @@ -564,7 +502,7 @@ pub(crate) struct DownloadedFakespotSuggestion { } /// An exposure suggestion record's inline data -#[derive(Clone, Debug, Deserialize)] +#[derive(Clone, Debug, Deserialize, Serialize)] pub(crate) struct DownloadedExposureRecord { pub suggestion_type: String, } @@ -644,11 +582,11 @@ impl FullOrPrefixKeywords { } /// Global Suggest configuration data to ingest from a configuration record -#[derive(Clone, Debug, Deserialize)] +#[derive(Clone, Debug, Deserialize, Serialize)] pub(crate) struct DownloadedGlobalConfig { pub configuration: DownloadedGlobalConfigInner, } -#[derive(Clone, Debug, Deserialize)] +#[derive(Clone, Debug, Deserialize, Serialize)] pub(crate) struct DownloadedGlobalConfigInner { /// The maximum number of times the user can click "Show less frequently" /// for a suggestion in the UI. @@ -670,24 +608,21 @@ mod test { #[test] fn test_full_keywords() { - let suggestion = DownloadedAmpWikipediaSuggestion::Amp(DownloadedAmpSuggestion { - common_details: DownloadedSuggestionCommonDetails { - keywords: vec![ - String::from("f"), - String::from("fo"), - String::from("foo"), - String::from("foo b"), - String::from("foo ba"), - String::from("foo bar"), - ], - full_keywords: vec![(String::from("foo"), 3), (String::from("foo bar"), 3)], - ..DownloadedSuggestionCommonDetails::default() - }, + let suggestion = DownloadedAmpSuggestion { + keywords: vec![ + String::from("f"), + String::from("fo"), + String::from("foo"), + String::from("foo b"), + String::from("foo ba"), + String::from("foo bar"), + ], + full_keywords: vec![(String::from("foo"), 3), (String::from("foo bar"), 3)], ..DownloadedAmpSuggestion::default() - }); + }; assert_eq!( - Vec::from_iter(suggestion.common_details().keywords()), + Vec::from_iter(suggestion.keywords()), vec![ AmpKeyword { rank: 0, @@ -725,25 +660,22 @@ mod test { #[test] fn test_missing_full_keywords() { - let suggestion = DownloadedAmpWikipediaSuggestion::Amp(DownloadedAmpSuggestion { - common_details: DownloadedSuggestionCommonDetails { - keywords: vec![ - String::from("f"), - String::from("fo"), - String::from("foo"), - String::from("foo b"), - String::from("foo ba"), - String::from("foo bar"), - ], - // Only the first 3 keywords have full keywords associated with them - full_keywords: vec![(String::from("foo"), 3)], - ..DownloadedSuggestionCommonDetails::default() - }, + let suggestion = DownloadedAmpSuggestion { + keywords: vec![ + String::from("f"), + String::from("fo"), + String::from("foo"), + String::from("foo b"), + String::from("foo ba"), + String::from("foo bar"), + ], + // Only the first 3 keywords have full keywords associated with them + full_keywords: vec![(String::from("foo"), 3)], ..DownloadedAmpSuggestion::default() - }); + }; assert_eq!( - Vec::from_iter(suggestion.common_details().keywords()), + Vec::from_iter(suggestion.keywords()), vec![ AmpKeyword { rank: 0, diff --git a/third_party/rust/suggest/src/schema.rs b/third_party/rust/suggest/src/schema.rs index 82f56b87bed0..9c7dbd678321 100644 --- a/third_party/rust/suggest/src/schema.rs +++ b/third_party/rust/suggest/src/schema.rs @@ -23,7 +23,7 @@ use sql_support::{ /// `clear_database()` by adding their names to `conditional_tables`, unless /// they are cleared via a deletion trigger or there's some other good /// reason not to do so. -pub const VERSION: u32 = 32; +pub const VERSION: u32 = 33; /// The current Suggest database schema. pub const SQL: &str = " @@ -32,11 +32,6 @@ CREATE TABLE meta( value NOT NULL ) WITHOUT ROWID; -CREATE TABLE rs_cache( - collection TEXT PRIMARY KEY, - data TEXT NOT NULL -) WITHOUT ROWID; - CREATE TABLE ingested_records( id TEXT, collection TEXT, @@ -616,6 +611,11 @@ impl ConnectionInitializer for SuggestConnectionInitializer<'_> { )?; Ok(()) } + 32 => { + // Drop rs_cache since it's no longer needed. + tx.execute_batch("DROP TABLE rs_cache;")?; + Ok(()) + } _ => Err(open_database::Error::IncompatibleVersion(version)), } } @@ -643,7 +643,6 @@ pub fn clear_database(db: &Connection) -> rusqlite::Result<()> { "geonames_metrics", "ingested_records", "keywords_metrics", - "rs_cache", ]; for t in conditional_tables { let table_exists = db.exists("SELECT 1 FROM sqlite_master WHERE name = ?", [t])?; @@ -792,38 +791,28 @@ PRAGMA user_version=16; let db_file = MigratedDatabaseFile::new(SuggestConnectionInitializer::default(), V16_SCHEMA); - // Upgrade to v25, the first version with with `ingested_records` and - // `rs_cache` tables. + // Upgrade to v25, the first version with with `ingested_records` tables. db_file.upgrade_to(25); - // Insert some ingested records and cache data. + // Insert some ingested records. let conn = db_file.open(); conn.execute( "INSERT INTO ingested_records(id, collection, type, last_modified) VALUES(?, ?, ?, ?)", ("record-id", "quicksuggest", "record-type", 1), )?; - conn.execute( - "INSERT INTO rs_cache(collection, data) VALUES(?, ?)", - ("quicksuggest", "some data"), - )?; conn.close().expect("Connection should be closed"); // Finish upgrading to the current version. db_file.upgrade_to(VERSION); db_file.assert_schema_matches_new_database(); - // `ingested_records` and `rs_cache` should be empty. + // `ingested_records` should be empty. let conn = db_file.open(); assert_eq!( conn.query_one::("SELECT count(*) FROM ingested_records")?, 0, "ingested_records should be empty" ); - assert_eq!( - conn.query_one::("SELECT count(*) FROM rs_cache")?, - 0, - "rs_cache should be empty" - ); conn.close().expect("Connection should be closed"); Ok(()) diff --git a/third_party/rust/suggest/src/store.rs b/third_party/rust/suggest/src/store.rs index 7a5b916433da..53a478f1434d 100644 --- a/third_party/rust/suggest/src/store.rs +++ b/third_party/rust/suggest/src/store.rs @@ -4,7 +4,7 @@ */ use std::{ - collections::{hash_map::Entry, BTreeSet, HashMap, HashSet}, + collections::{hash_map::Entry, HashMap, HashSet}, path::{Path, PathBuf}, sync::Arc, }; @@ -12,7 +12,7 @@ use std::{ use error_support::{breadcrumb, handle_error}; use once_cell::sync::OnceCell; use parking_lot::Mutex; -use remote_settings::{self, RemoteSettingsConfig, RemoteSettingsServer, RemoteSettingsService}; +use remote_settings::{self, RemoteSettingsError, RemoteSettingsServer, RemoteSettingsService}; use serde::de::DeserializeOwned; @@ -24,10 +24,9 @@ use crate::{ metrics::{MetricsContext, SuggestIngestionMetrics, SuggestQueryMetrics}, provider::{SuggestionProvider, SuggestionProviderConstraints, DEFAULT_INGEST_PROVIDERS}, rs::{ - Client, Collection, DownloadedExposureRecord, Record, RemoteSettingsClient, - SuggestAttachment, SuggestRecord, SuggestRecordId, SuggestRecordType, + Client, Collection, DownloadedExposureRecord, Record, SuggestAttachment, SuggestRecord, + SuggestRecordId, SuggestRecordType, SuggestRemoteSettingsClient, }, - suggestion::AmpSuggestionType, QueryWithMetricsResult, Result, SuggestApiResult, Suggestion, SuggestionQuery, }; @@ -42,6 +41,7 @@ pub struct SuggestStoreBuilder(Mutex); struct SuggestStoreBuilderInner { data_path: Option, remote_settings_server: Option, + remote_settings_service: Option>, remote_settings_bucket_name: Option, extensions_to_load: Vec, } @@ -82,10 +82,9 @@ impl SuggestStoreBuilder { pub fn remote_settings_service( self: Arc, - _rs_service: Arc, + rs_service: Arc, ) -> Arc { - // When #6607 lands, this will set the remote settings service. - // For now, it just exists so we can move consumers over to the new API ahead of time. + self.0.lock().remote_settings_service = Some(rs_service); self } @@ -114,15 +113,17 @@ impl SuggestStoreBuilder { .data_path .clone() .ok_or_else(|| Error::SuggestStoreBuilder("data_path not specified".to_owned()))?; - - let client = RemoteSettingsClient::new( - inner.remote_settings_server.clone(), - inner.remote_settings_bucket_name.clone(), - None, - )?; - + let rs_service = inner.remote_settings_service.clone().ok_or_else(|| { + Error::RemoteSettings(RemoteSettingsError::Other { + reason: "remote_settings_service_not_specified".to_string(), + }) + })?; Ok(Arc::new(SuggestStore { - inner: SuggestStoreInner::new(data_path, extensions_to_load, client), + inner: SuggestStoreInner::new( + data_path, + extensions_to_load, + SuggestRemoteSettingsClient::new(&rs_service)?, + ), })) } } @@ -169,30 +170,19 @@ pub enum InterruptKind { /// on the first launch. #[derive(uniffi::Object)] pub struct SuggestStore { - inner: SuggestStoreInner, + inner: SuggestStoreInner, } #[uniffi::export] impl SuggestStore { /// Creates a Suggest store. #[handle_error(Error)] - #[uniffi::constructor(default(settings_config = None))] + #[uniffi::constructor()] pub fn new( path: &str, - settings_config: Option, + remote_settings_service: Arc, ) -> SuggestApiResult { - let client = match settings_config { - Some(settings_config) => RemoteSettingsClient::new( - settings_config.server, - settings_config.bucket_name, - settings_config.server_url, - // Note: collection name is ignored, since we fetch from multiple collections - // (fakespot-suggest-products and quicksuggest). No consumer sets it to a - // non-default value anyways. - )?, - None => RemoteSettingsClient::new(None, None, None)?, - }; - + let client = SuggestRemoteSettingsClient::new(&remote_settings_service)?; Ok(Self { inner: SuggestStoreInner::new(path.to_owned(), vec![], client), }) @@ -350,7 +340,6 @@ impl SuggestIngestionConstraints { SuggestionProvider::Yelp, SuggestionProvider::Mdn, SuggestionProvider::Weather, - SuggestionProvider::AmpMobile, SuggestionProvider::Fakespot, SuggestionProvider::Exposure, ]), @@ -425,12 +414,7 @@ impl SuggestStoreInner { for provider in unique_providers { let new_suggestions = metrics.measure_query(provider.to_string(), || { reader.read(|dao| match provider { - SuggestionProvider::Amp => { - dao.fetch_amp_suggestions(&query, AmpSuggestionType::Desktop) - } - SuggestionProvider::AmpMobile => { - dao.fetch_amp_suggestions(&query, AmpSuggestionType::Mobile) - } + SuggestionProvider::Amp => dao.fetch_amp_suggestions(&query), SuggestionProvider::Wikipedia => dao.fetch_wikipedia_suggestions(&query), SuggestionProvider::Amo => dao.fetch_amo_suggestions(&query), SuggestionProvider::Pocket => dao.fetch_pocket_suggestions(&query), @@ -545,30 +529,26 @@ where // Figure out which record types we're ingesting and group them by // collection. A record type may be used by multiple providers, but we - // want to ingest each one at most once. - let mut record_types_by_collection = HashMap::>::new(); - for p in constraints + // want to ingest each one at most once. We always ingest some types + // like global config. + let mut record_types_by_collection = HashMap::from([( + Collection::Other, + HashSet::from([SuggestRecordType::GlobalConfig]), + )]); + for provider in constraints .providers .as_ref() .unwrap_or(&DEFAULT_INGEST_PROVIDERS.to_vec()) .iter() { - for t in p.record_types() { + for (collection, provider_rts) in provider.record_types_by_collection() { record_types_by_collection - .entry(t.collection()) + .entry(collection) .or_default() - .insert(t); + .extend(provider_rts.into_iter()); } } - // Always ingest these record types. - for rt in [SuggestRecordType::Icon, SuggestRecordType::GlobalConfig] { - record_types_by_collection - .entry(rt.collection()) - .or_default() - .insert(rt); - } - // Create a single write scope for all DB operations let mut write_scope = writer.write_scope()?; @@ -578,8 +558,7 @@ where // For each collection, fetch all records for (collection, record_types) in record_types_by_collection { breadcrumb!("Ingesting collection {}", collection.name()); - let records = - write_scope.write(|dao| self.settings_client.get_records(collection, dao))?; + let records = self.settings_client.get_records(collection)?; // For each record type in that collection, calculate the changes and pass them to // [Self::ingest_records] @@ -655,18 +634,18 @@ where context: &mut MetricsContext, ) -> Result<()> { match &record.payload { - SuggestRecord::AmpWikipedia => { + SuggestRecord::Amp => { self.download_attachment(dao, record, context, |dao, record_id, suggestions| { - dao.insert_amp_wikipedia_suggestions( + dao.insert_amp_suggestions( record_id, suggestions, constraints.amp_matching_uses_fts(), ) })?; } - SuggestRecord::AmpMobile => { + SuggestRecord::Wikipedia => { self.download_attachment(dao, record, context, |dao, record_id, suggestions| { - dao.insert_amp_mobile_suggestions(record_id, suggestions) + dao.insert_wikipedia_suggestions(record_id, suggestions) })?; } SuggestRecord::Icon => { @@ -776,7 +755,7 @@ where Ok(!dao.is_exposure_suggestion_ingested(&record.id)? && constraints.matches_exposure_record(r)) } - SuggestRecord::AmpWikipedia => { + SuggestRecord::Amp => { Ok(constraints.amp_matching_uses_fts() && !dao.is_amp_fts_data_ingested(&record.id)?) } @@ -847,16 +826,15 @@ where .expect("Error performing checkpoint"); } - pub fn ingest_records_by_type(&self, ingest_record_type: SuggestRecordType) { + pub fn ingest_records_by_type( + &self, + collection: Collection, + ingest_record_type: SuggestRecordType, + ) { let writer = &self.dbs().unwrap().writer; let mut context = MetricsContext::default(); let ingested_records = writer.read(|dao| dao.get_ingested_records()).unwrap(); - let records = writer - .write(|dao| { - self.settings_client - .get_records(ingest_record_type.collection(), dao) - }) - .unwrap(); + let records = self.settings_client.get_records(collection).unwrap(); let changes = RecordChanges::new( records @@ -870,7 +848,7 @@ where .write(|dao| { self.process_changes( dao, - ingest_record_type.collection(), + collection, changes, &SuggestIngestionConstraints::default(), &mut context, @@ -1047,8 +1025,8 @@ pub(crate) mod tests { let store = TestStore::new( MockRemoteSettingsClient::default() - .with_record("data", "1234", json![los_pollos_amp()]) - .with_icon(los_pollos_icon()), + .with_record(SuggestionProvider::Amp.record("1234", json![los_pollos_amp()])) + .with_record(SuggestionProvider::Amp.icon(los_pollos_icon())), ); store.ingest(SuggestIngestionConstraints::all_providers()); assert_eq!( @@ -1063,11 +1041,10 @@ pub(crate) mod tests { fn ingest_empty_only() -> anyhow::Result<()> { before_each(); - let mut store = TestStore::new(MockRemoteSettingsClient::default().with_record( - "data", - "1234", - json![los_pollos_amp()], - )); + let mut store = TestStore::new( + MockRemoteSettingsClient::default() + .with_record(SuggestionProvider::Amp.record("1234", json![los_pollos_amp()])), + ); // suggestions_table_empty returns true before the ingestion is complete assert!(store.read(|dao| dao.suggestions_table_empty())?); // This ingestion should run, since the DB is empty @@ -1080,10 +1057,10 @@ pub(crate) mod tests { // This ingestion should not run since the DB is no longer empty store.client_mut().update_record( - "data", - "1234", - json!([los_pollos_amp(), good_place_eats_amp()]), + SuggestionProvider::Amp + .record("1234", json!([los_pollos_amp(), good_place_eats_amp()])), ); + store.ingest(SuggestIngestionConstraints { empty_only: true, ..SuggestIngestionConstraints::all_providers() @@ -1103,12 +1080,11 @@ pub(crate) mod tests { let store = TestStore::new( MockRemoteSettingsClient::default() .with_record( - "data", - "1234", - json!([los_pollos_amp(), good_place_eats_amp()]), + SuggestionProvider::Amp + .record("1234", json!([los_pollos_amp(), good_place_eats_amp()])), ) - .with_icon(los_pollos_icon()) - .with_icon(good_place_eats_icon()), + .with_record(SuggestionProvider::Amp.icon(los_pollos_icon())) + .with_record(SuggestionProvider::Amp.icon(good_place_eats_icon())), ); // This ingestion should run, since the DB is empty store.ingest(SuggestIngestionConstraints::all_providers()); @@ -1126,11 +1102,12 @@ pub(crate) mod tests { } #[test] - fn ingest_full_keywords() -> anyhow::Result<()> { + fn ingest_amp_full_keywords() -> anyhow::Result<()> { before_each(); let store = TestStore::new(MockRemoteSettingsClient::default() - .with_record("data", "1234", json!([ + .with_record( + SuggestionProvider::Amp.record("1234", json!([ // AMP attachment with full keyword data los_pollos_amp().merge(json!({ "keywords": ["lo", "los", "los p", "los pollos", "los pollos h", "los pollos hermanos"], @@ -1143,27 +1120,9 @@ pub(crate) mod tests { })), // AMP attachment without full keyword data good_place_eats_amp(), - // Wikipedia attachment with full keyword data. We should ignore the full - // keyword data for Wikipedia suggestions - california_wiki(), - // california_wiki().merge(json!({ - // "keywords": ["cal", "cali", "california"], - // "full_keywords": [("california institute of technology", 3)], - // })), - ])) - .with_record("amp-mobile-suggestions", "2468", json!([ - // Amp mobile attachment with full keyword data - a1a_amp_mobile().merge(json!({ - "keywords": ["a1a", "ca", "car", "car wash"], - "full_keywords": [ - ("A1A Car Wash", 1), - ("car wash", 3), - ], - })), - ])) - .with_icon(los_pollos_icon()) - .with_icon(good_place_eats_icon()) - .with_icon(california_icon()) + ]))) + .with_record(SuggestionProvider::Amp.icon(los_pollos_icon())) + .with_record(SuggestionProvider::Amp.icon(good_place_eats_icon())) ); store.ingest(SuggestIngestionConstraints::all_providers()); @@ -1175,11 +1134,36 @@ pub(crate) mod tests { assert_eq!( store.fetch_suggestions(SuggestionQuery::amp("la")), - // Good place eats did not have full keywords, so this one is calculated with the - // keywords.rs code + // Good place eats did not have full keywords, so this one is + // calculated at runtime vec![good_place_eats_suggestion("lasagna", None)], ); + Ok(()) + } + + #[test] + fn ingest_wikipedia_full_keywords() -> anyhow::Result<()> { + before_each(); + + let store = TestStore::new( + MockRemoteSettingsClient::default() + .with_record(SuggestionProvider::Wikipedia.record( + "1234", + json!([ + // Wikipedia attachment with full keyword data. We should ignore the full + // keyword data for Wikipedia suggestions + california_wiki(), + // california_wiki().merge(json!({ + // "keywords": ["cal", "cali", "california"], + // "full_keywords": [("california institute of technology", 3)], + // })), + ]), + )) + .with_record(SuggestionProvider::Wikipedia.icon(california_icon())), + ); + store.ingest(SuggestIngestionConstraints::all_providers()); + assert_eq!( store.fetch_suggestions(SuggestionQuery::wikipedia("cal")), // Even though this had a full_keywords field, we should ignore it since it's a @@ -1187,12 +1171,6 @@ pub(crate) mod tests { vec![california_suggestion("california")], ); - assert_eq!( - store.fetch_suggestions(SuggestionQuery::amp_mobile("a1a")), - // This keyword comes from the provided full_keywords list. - vec![a1a_suggestion("A1A Car Wash", None)], - ); - Ok(()) } @@ -1207,14 +1185,14 @@ pub(crate) mod tests { // keywords (i.e. it was the result of keyword expansion). // * There's a `los pollos ` keyword with an extra space .with_record( - "data", + SuggestionProvider::Amp.record( "1234", los_pollos_amp().merge(json!({ "keywords": ["los", "los pollos", "los pollos ", "los pollos hermanos", "chicken"], "full_keywords": [("los pollos", 3), ("los pollos hermanos", 2)], })) - ) - .with_icon(los_pollos_icon()), + )) + .with_record(SuggestionProvider::Amp.icon(los_pollos_icon())), ); store.ingest(SuggestIngestionConstraints::all_providers()); assert_eq!( @@ -1253,15 +1231,14 @@ pub(crate) mod tests { let store = TestStore::new( MockRemoteSettingsClient::default() // Make sure there's full keywords to match against - .with_record( - "data", + .with_record(SuggestionProvider::Amp.record( "1234", los_pollos_amp().merge(json!({ "keywords": ["los", "los pollos", "los pollos ", "los pollos hermanos"], "full_keywords": [("los pollos", 3), ("los pollos hermanos", 1)], })), - ) - .with_icon(los_pollos_icon()), + )) + .with_record(SuggestionProvider::Amp.icon(los_pollos_icon())), ); store.ingest(SuggestIngestionConstraints::amp_with_fts()); assert_eq!( @@ -1291,8 +1268,8 @@ pub(crate) mod tests { let store = TestStore::new( MockRemoteSettingsClient::default() - .with_record("data", "1234", los_pollos_amp()) - .with_icon(los_pollos_icon()), + .with_record(SuggestionProvider::Amp.record("1234", los_pollos_amp())) + .with_record(SuggestionProvider::Amp.icon(los_pollos_icon())), ); store.ingest(SuggestIngestionConstraints::amp_with_fts()); assert_eq!( @@ -1325,8 +1302,8 @@ pub(crate) mod tests { let store = TestStore::new( MockRemoteSettingsClient::default() // This record contains just one JSON object, rather than an array of them - .with_record("data", "1234", los_pollos_amp()) - .with_icon(los_pollos_icon()), + .with_record(SuggestionProvider::Amp.record("1234", los_pollos_amp())) + .with_record(SuggestionProvider::Amp.icon(los_pollos_icon())), ); store.ingest(SuggestIngestionConstraints::all_providers()); assert_eq!( @@ -1342,29 +1319,31 @@ pub(crate) mod tests { fn reingest_amp_suggestions() -> anyhow::Result<()> { before_each(); - let mut store = TestStore::new(MockRemoteSettingsClient::default().with_record( - "data", - "1234", - json!([los_pollos_amp(), good_place_eats_amp()]), - )); + let mut store = TestStore::new( + MockRemoteSettingsClient::default().with_record( + SuggestionProvider::Amp + .record("1234", json!([los_pollos_amp(), good_place_eats_amp()])), + ), + ); // Ingest once store.ingest(SuggestIngestionConstraints::all_providers()); // Update the snapshot with new suggestions: Los pollos has a new name and Good place eats // is now serving Penne - store.client_mut().update_record( - "data", - "1234", - json!([ - los_pollos_amp().merge(json!({ - "title": "Los Pollos Hermanos - Now Serving at 14 Locations!", - })), - good_place_eats_amp().merge(json!({ - "keywords": ["pe", "pen", "penne", "penne for your thoughts"], - "title": "Penne for Your Thoughts", - "url": "https://penne.biz", - })) - ]), - ); + store + .client_mut() + .update_record(SuggestionProvider::Amp.record( + "1234", + json!([ + los_pollos_amp().merge(json!({ + "title": "Los Pollos Hermanos - Now Serving at 14 Locations!", + })), + good_place_eats_amp().merge(json!({ + "keywords": ["pe", "pen", "penne", "penne for your thoughts"], + "title": "Penne for Your Thoughts", + "url": "https://penne.biz", + })) + ]), + )); store.ingest(SuggestIngestionConstraints::all_providers()); assert!(matches!( @@ -1388,15 +1367,14 @@ pub(crate) mod tests { // Ingest with FTS enabled, this will populate the FTS table let store = TestStore::new( MockRemoteSettingsClient::default() - .with_record( - "data", + .with_record(SuggestionProvider::Amp.record( "data-1", json!([los_pollos_amp().merge(json!({ "keywords": ["los", "los pollos", "los pollos ", "los pollos hermanos"], "full_keywords": [("los pollos", 3), ("los pollos hermanos", 1)], }))]), - ) - .with_icon(los_pollos_icon()), + )) + .with_record(SuggestionProvider::Amp.icon(los_pollos_icon())), ); // Ingest without FTS store.ingest(SuggestIngestionConstraints::amp_without_fts()); @@ -1432,12 +1410,11 @@ pub(crate) mod tests { let mut store = TestStore::new( MockRemoteSettingsClient::default() .with_record( - "data", - "1234", - json!([los_pollos_amp(), good_place_eats_amp()]), + SuggestionProvider::Amp + .record("1234", json!([los_pollos_amp(), good_place_eats_amp()])), ) - .with_icon(los_pollos_icon()) - .with_icon(good_place_eats_icon()), + .with_record(SuggestionProvider::Amp.icon(los_pollos_icon())) + .with_record(SuggestionProvider::Amp.icon(good_place_eats_icon())), ); // This ingestion should run, since the DB is empty store.ingest(SuggestIngestionConstraints::all_providers()); @@ -1447,24 +1424,23 @@ pub(crate) mod tests { // - Good place eats gets new data only store .client_mut() - .update_record( - "data", + .update_record(SuggestionProvider::Amp.record( "1234", json!([ los_pollos_amp().merge(json!({"icon": "1000"})), good_place_eats_amp() ]), - ) - .delete_icon(los_pollos_icon()) - .add_icon(MockIcon { + )) + .delete_record(SuggestionProvider::Amp.icon(los_pollos_icon())) + .add_record(SuggestionProvider::Amp.icon(MockIcon { id: "1000", data: "new-los-pollos-icon", ..los_pollos_icon() - }) - .update_icon(MockIcon { + })) + .update_record(SuggestionProvider::Amp.icon(MockIcon { data: "new-good-place-eats-icon", ..good_place_eats_icon() - }); + })); store.ingest(SuggestIngestionConstraints::all_providers()); assert!(matches!( @@ -1487,11 +1463,10 @@ pub(crate) mod tests { let mut store = TestStore::new( MockRemoteSettingsClient::default() - .with_record("amo-suggestions", "data-1", json!([relay_amo()])) + .with_record(SuggestionProvider::Amo.record("data-1", json!([relay_amo()]))) .with_record( - "amo-suggestions", - "data-2", - json!([dark_mode_amo(), foxy_guestures_amo()]), + SuggestionProvider::Amo + .record("data-2", json!([dark_mode_amo(), foxy_guestures_amo()])), ), ); @@ -1514,15 +1489,14 @@ pub(crate) mod tests { // third, and add the fourth. store .client_mut() - .update_record("amo-suggestions", "data-1", json!([relay_amo()])) - .update_record( - "amo-suggestions", + .update_record(SuggestionProvider::Amo.record("data-1", json!([relay_amo()]))) + .update_record(SuggestionProvider::Amo.record( "data-2", json!([ dark_mode_amo().merge(json!({"title": "Updated second suggestion"})), new_tab_override_amo(), ]), - ); + )); store.ingest(SuggestIngestionConstraints::all_providers()); assert_eq!( @@ -1552,10 +1526,12 @@ pub(crate) mod tests { let mut store = TestStore::new( MockRemoteSettingsClient::default() - .with_record("data", "data-1", json!([los_pollos_amp()])) - .with_record("data", "data-2", json!([good_place_eats_amp()])) - .with_icon(los_pollos_icon()) - .with_icon(good_place_eats_icon()), + .with_record(SuggestionProvider::Amp.record("data-1", json!([los_pollos_amp()]))) + .with_record( + SuggestionProvider::Amp.record("data-2", json!([good_place_eats_amp()])), + ) + .with_record(SuggestionProvider::Amp.icon(los_pollos_icon())) + .with_record(SuggestionProvider::Amp.icon(good_place_eats_icon())), ); store.ingest(SuggestIngestionConstraints::all_providers()); assert_eq!( @@ -1570,8 +1546,8 @@ pub(crate) mod tests { // recognize that they're missing and delete them. store .client_mut() - .delete_record("quicksuggest", "data-1") - .delete_icon(good_place_eats_icon()); + .delete_record(SuggestionProvider::Amp.empty_record("data-1")) + .delete_record(SuggestionProvider::Amp.icon(good_place_eats_icon())); store.ingest(SuggestIngestionConstraints::all_providers()); assert_eq!(store.fetch_suggestions(SuggestionQuery::amp("lo")), vec![]); @@ -1591,10 +1567,12 @@ pub(crate) mod tests { let store = TestStore::new( MockRemoteSettingsClient::default() - .with_record("data", "data-1", json!([los_pollos_amp()])) - .with_record("data", "data-2", json!([good_place_eats_amp()])) - .with_icon(los_pollos_icon()) - .with_icon(good_place_eats_icon()), + .with_record(SuggestionProvider::Amp.record("data-1", json!([los_pollos_amp()]))) + .with_record( + SuggestionProvider::Amp.record("data-2", json!([good_place_eats_amp()])), + ) + .with_record(SuggestionProvider::Amp.icon(los_pollos_icon())) + .with_record(SuggestionProvider::Amp.icon(good_place_eats_icon())), ); store.ingest(SuggestIngestionConstraints::all_providers()); assert!(store.count_rows("suggestions") > 0); @@ -1617,32 +1595,27 @@ pub(crate) mod tests { let store = TestStore::new( MockRemoteSettingsClient::default() .with_record( - "data", - "data-1", - json!([ - good_place_eats_amp(), - california_wiki(), - caltech_wiki(), - multimatch_wiki(), - ]), + SuggestionProvider::Amp.record("data-1", json!([good_place_eats_amp(),])), + ) + .with_record(SuggestionProvider::Wikipedia.record( + "wikipedia-1", + json!([california_wiki(), caltech_wiki(), multimatch_wiki(),]), + )) + .with_record( + SuggestionProvider::Amo + .record("data-2", json!([relay_amo(), multimatch_amo(),])), ) .with_record( - "amo-suggestions", - "data-2", - json!([relay_amo(), multimatch_amo(),]), + SuggestionProvider::Pocket + .record("data-3", json!([burnout_pocket(), multimatch_pocket(),])), ) - .with_record( - "pocket-suggestions", - "data-3", - json!([burnout_pocket(), multimatch_pocket(),]), - ) - .with_record("yelp-suggestions", "data-4", json!([ramen_yelp(),])) - .with_record("mdn-suggestions", "data-5", json!([array_mdn(),])) - .with_icon(good_place_eats_icon()) - .with_icon(california_icon()) - .with_icon(caltech_icon()) - .with_icon(yelp_favicon()) - .with_icon(multimatch_wiki_icon()), + .with_record(SuggestionProvider::Yelp.record("data-4", json!([ramen_yelp(),]))) + .with_record(SuggestionProvider::Mdn.record("data-5", json!([array_mdn(),]))) + .with_record(SuggestionProvider::Amp.icon(good_place_eats_icon())) + .with_record(SuggestionProvider::Wikipedia.icon(california_icon())) + .with_record(SuggestionProvider::Wikipedia.icon(caltech_icon())) + .with_record(SuggestionProvider::Yelp.icon(yelp_favicon())) + .with_record(SuggestionProvider::Wikipedia.icon(multimatch_wiki_icon())), ); store.ingest(SuggestIngestionConstraints::all_providers()); @@ -2033,8 +2006,7 @@ pub(crate) mod tests { // where the scores are manually set. We will test that the fetched suggestions are in // the correct order. MockRemoteSettingsClient::default() - .with_record( - "data", + .with_record(SuggestionProvider::Amp.record( "data-1", json!([ los_pollos_amp().merge(json!({ @@ -2045,13 +2017,15 @@ pub(crate) mod tests { "keywords": ["amp wiki match"], "score": 0.1, })), - california_wiki().merge(json!({ - "keywords": ["amp wiki match", "pocket wiki match"], - })), ]), - ) - .with_record( - "pocket-suggestions", + )) + .with_record(SuggestionProvider::Wikipedia.record( + "wikipedia-1", + json!([california_wiki().merge(json!({ + "keywords": ["amp wiki match", "pocket wiki match"], + })),]), + )) + .with_record(SuggestionProvider::Pocket.record( "data-3", json!([ burnout_pocket().merge(json!({ @@ -2063,10 +2037,10 @@ pub(crate) mod tests { "score": 0.88, })), ]), - ) - .with_icon(los_pollos_icon()) - .with_icon(good_place_eats_icon()) - .with_icon(california_icon()), + )) + .with_record(SuggestionProvider::Amp.icon(los_pollos_icon())) + .with_record(SuggestionProvider::Amp.icon(good_place_eats_icon())) + .with_record(SuggestionProvider::Wikipedia.icon(california_icon())), ); store.ingest(SuggestIngestionConstraints::all_providers()); @@ -2110,37 +2084,6 @@ pub(crate) mod tests { Ok(()) } - // Tests querying multiple suggestions with multiple keywords with same prefix keyword - #[test] - fn query_with_amp_mobile_provider() -> anyhow::Result<()> { - before_each(); - - // Use the exact same data for both the Amp and AmpMobile record - let store = TestStore::new( - MockRemoteSettingsClient::default() - .with_record( - "amp-mobile-suggestions", - "amp-mobile-1", - json!([good_place_eats_amp()]), - ) - .with_record("data", "data-1", json!([good_place_eats_amp()])) - // This icon is shared by both records which is kind of weird and probably not how - // things would work in practice, but it's okay for the tests. - .with_icon(good_place_eats_icon()), - ); - store.ingest(SuggestIngestionConstraints::all_providers()); - // The query results should be exactly the same for both the Amp and AmpMobile data - assert_eq!( - store.fetch_suggestions(SuggestionQuery::amp_mobile("las")), - vec![good_place_eats_suggestion("lasagna", None)] - ); - assert_eq!( - store.fetch_suggestions(SuggestionQuery::amp("las")), - vec![good_place_eats_suggestion("lasagna", None)] - ); - Ok(()) - } - /// Tests ingesting malformed Remote Settings records that we understand, /// but that are missing fields, or aren't in the format we expect. #[test] @@ -2149,13 +2092,31 @@ pub(crate) mod tests { let store = TestStore::new( MockRemoteSettingsClient::default() - // Amp/Wikipedia record without an attachment. - .with_record_but_no_attachment("data", "data-1") + // Amp record without an attachment. + .with_record(SuggestionProvider::Amp.empty_record("data-1")) + // Wikipedia record without an attachment. + .with_record(SuggestionProvider::Wikipedia.empty_record("wikipedia-1")) // Icon record without an attachment. - .with_record_but_no_attachment("icon", "icon-1") + .with_record(MockRecord { + collection: Collection::Amp, + record_type: SuggestRecordType::Icon, + id: "icon-1".to_string(), + inline_data: None, + attachment: None, + }) // Icon record with an ID that's not `icon-{id}`, so suggestions in // the data attachment won't be able to reference it. - .with_record("icon", "bad-icon-id", json!("i-am-an-icon")), + .with_record(MockRecord { + collection: Collection::Amp, + record_type: SuggestRecordType::Icon, + id: "bad-icon-id".to_string(), + inline_data: None, + attachment: Some(MockAttachment::Icon(MockIcon { + id: "bad-icon-id", + data: "", + mimetype: "image/png", + })), + }), ); store.ingest(SuggestIngestionConstraints::all_providers()); @@ -2181,9 +2142,9 @@ pub(crate) mod tests { let store = TestStore::new( MockRemoteSettingsClient::default() - .with_record("data", "data-1", json!([los_pollos_amp()])) - .with_record("yelp-suggestions", "yelp-1", json!([ramen_yelp()])) - .with_icon(los_pollos_icon()), + .with_record(SuggestionProvider::Amp.record("data-1", json!([los_pollos_amp()]))) + .with_record(SuggestionProvider::Yelp.record("yelp-1", json!([ramen_yelp()]))) + .with_record(SuggestionProvider::Amp.icon(los_pollos_icon())), ); let constraints = SuggestIngestionConstraints { @@ -2214,10 +2175,11 @@ pub(crate) mod tests { let store = TestStore::new( MockRemoteSettingsClient::default() // valid record - .with_record("data", "data-1", json!([good_place_eats_amp()])) - // This attachment is missing the `title` field and is invalid .with_record( - "data", + SuggestionProvider::Amp.record("data-1", json!([good_place_eats_amp()])), + ) + // This attachment is missing the `title` field and is invalid + .with_record(SuggestionProvider::Amp.record( "data-2", json!([{ "id": 1, @@ -2230,8 +2192,8 @@ pub(crate) mod tests { "click_url": "https://example.com/click_url", "score": 0.3 }]), - ) - .with_icon(good_place_eats_icon()), + )) + .with_record(SuggestionProvider::Amp.icon(good_place_eats_icon())), ); store.ingest(SuggestIngestionConstraints::all_providers()); @@ -2251,11 +2213,10 @@ pub(crate) mod tests { fn query_mdn() -> anyhow::Result<()> { before_each(); - let store = TestStore::new(MockRemoteSettingsClient::default().with_record( - "mdn-suggestions", - "mdn-1", - json!([array_mdn()]), - )); + let store = TestStore::new( + MockRemoteSettingsClient::default() + .with_record(SuggestionProvider::Mdn.record("mdn-1", json!([array_mdn()]))), + ); store.ingest(SuggestIngestionConstraints::all_providers()); // prefix assert_eq!( @@ -2289,13 +2250,9 @@ pub(crate) mod tests { fn query_no_yelp_icon_data() -> anyhow::Result<()> { before_each(); - let store = TestStore::new( - MockRemoteSettingsClient::default().with_record( - "yelp-suggestions", - "yelp-1", - json!([ramen_yelp()]), - ), // Note: yelp_favicon() is missing - ); + let store = TestStore::new(MockRemoteSettingsClient::default().with_record( + SuggestionProvider::Yelp.record("yelp-1", json!([ramen_yelp()])), // Note: yelp_favicon() is missing + )); store.ingest(SuggestIngestionConstraints::all_providers()); assert!(matches!( store.fetch_suggestions(SuggestionQuery::yelp("ramen")).as_slice(), @@ -2309,15 +2266,18 @@ pub(crate) mod tests { fn fetch_global_config() -> anyhow::Result<()> { before_each(); - let store = TestStore::new(MockRemoteSettingsClient::default().with_inline_record( - "configuration", - "configuration-1", - json!({ + let store = TestStore::new(MockRemoteSettingsClient::default().with_record(MockRecord { + collection: Collection::Other, + record_type: SuggestRecordType::GlobalConfig, + id: "configuration-1".to_string(), + inline_data: Some(json!({ "configuration": { "show_less_frequently_cap": 3, }, - }), - )); + })), + attachment: None, + })); + store.ingest(SuggestIngestionConstraints::all_providers()); assert_eq!( store.fetch_global_config(), @@ -2365,15 +2325,16 @@ pub(crate) mod tests { before_each(); let store = TestStore::new(MockRemoteSettingsClient::default().with_record( - "weather", - "weather-1", - json!({ - "min_keyword_length": 3, - "score": 0.24, - "max_keyword_length": 1, - "max_keyword_word_count": 1, - "keywords": [] - }), + SuggestionProvider::Weather.record( + "weather-1", + json!({ + "min_keyword_length": 3, + "score": 0.24, + "max_keyword_length": 1, + "max_keyword_word_count": 1, + "keywords": [] + }), + ), )); store.ingest(SuggestIngestionConstraints::all_providers()); @@ -2398,45 +2359,37 @@ pub(crate) mod tests { let store = TestStore::new( MockRemoteSettingsClient::default() - .with_record( - "data", + .with_record(SuggestionProvider::Amp.record( "data-1", - json!([ - good_place_eats_amp().merge(json!({"keywords": ["cats"]})), - california_wiki().merge(json!({"keywords": ["cats"]})), - ]), - ) - .with_record( - "amo-suggestions", + json!([good_place_eats_amp().merge(json!({"keywords": ["cats"]})),]), + )) + .with_record(SuggestionProvider::Wikipedia.record( + "wikipedia-1", + json!([california_wiki().merge(json!({"keywords": ["cats"]})),]), + )) + .with_record(SuggestionProvider::Amo.record( "amo-1", json!([relay_amo().merge(json!({"keywords": ["cats"]})),]), - ) - .with_record( - "pocket-suggestions", + )) + .with_record(SuggestionProvider::Pocket.record( "pocket-1", json!([burnout_pocket().merge(json!({ "lowConfidenceKeywords": ["cats"], }))]), - ) - .with_record( - "mdn-suggestions", + )) + .with_record(SuggestionProvider::Mdn.record( "mdn-1", json!([array_mdn().merge(json!({"keywords": ["cats"]})),]), - ) - .with_record( - "amp-mobile-suggestions", - "amp-mobile-1", - json!([a1a_amp_mobile().merge(json!({"keywords": ["cats"]})),]), - ) - .with_icon(good_place_eats_icon()) - .with_icon(caltech_icon()), + )) + .with_record(SuggestionProvider::Amp.icon(good_place_eats_icon())) + .with_record(SuggestionProvider::Wikipedia.icon(caltech_icon())), ); store.ingest(SuggestIngestionConstraints::all_providers()); // A query for cats should return all suggestions let query = SuggestionQuery::all_providers("cats"); let results = store.fetch_suggestions(query.clone()); - assert_eq!(results.len(), 6); + assert_eq!(results.len(), 5); for result in results { store @@ -2449,7 +2402,7 @@ pub(crate) mod tests { // Clearing the dismissals should cause them to be returned again store.inner.clear_dismissed_suggestions()?; - assert_eq!(store.fetch_suggestions(query.clone()).len(), 6); + assert_eq!(store.fetch_suggestions(query.clone()).len(), 5); Ok(()) } @@ -2460,12 +2413,11 @@ pub(crate) mod tests { let store = TestStore::new( MockRemoteSettingsClient::default() - .with_record( - "fakespot-suggestions", + .with_record(SuggestionProvider::Fakespot.record( "fakespot-1", json!([snowglobe_fakespot(), simpsons_fakespot()]), - ) - .with_icon(fakespot_amazon_icon()), + )) + .with_record(SuggestionProvider::Fakespot.icon(fakespot_amazon_icon())), ); store.ingest(SuggestIngestionConstraints::all_providers()); assert_eq!( @@ -2524,8 +2476,7 @@ pub(crate) mod tests { let store = TestStore::new( MockRemoteSettingsClient::default() - .with_record( - "fakespot-suggestions", + .with_record(SuggestionProvider::Fakespot.record( "fakespot-1", json!([ // Snow normally returns the snowglobe first. Test using the keyword field @@ -2533,8 +2484,8 @@ pub(crate) mod tests { snowglobe_fakespot(), simpsons_fakespot().merge(json!({"keywords": "snow"})), ]), - ) - .with_icon(fakespot_amazon_icon()), + )) + .with_record(SuggestionProvider::Fakespot.icon(fakespot_amazon_icon())), ); store.ingest(SuggestIngestionConstraints::all_providers()); assert_eq!( @@ -2557,12 +2508,11 @@ pub(crate) mod tests { let store = TestStore::new( MockRemoteSettingsClient::default() - .with_record( - "fakespot-suggestions", + .with_record(SuggestionProvider::Fakespot.record( "fakespot-1", json!([snowglobe_fakespot(), simpsons_fakespot()]), - ) - .with_icon(fakespot_amazon_icon()), + )) + .with_record(SuggestionProvider::Fakespot.icon(fakespot_amazon_icon())), ); store.ingest(SuggestIngestionConstraints::all_providers()); assert_eq!( @@ -2596,25 +2546,25 @@ pub(crate) mod tests { let mut store = TestStore::new( MockRemoteSettingsClient::default() - .with_record( - "fakespot-suggestions", + .with_record(SuggestionProvider::Fakespot.record( "fakespot-1", json!([snowglobe_fakespot(), simpsons_fakespot()]), - ) - .with_icon(fakespot_amazon_icon()), + )) + .with_record(SuggestionProvider::Fakespot.icon(fakespot_amazon_icon())), ); store.ingest(SuggestIngestionConstraints::all_providers()); // Update the snapshot so that: // - The Simpsons entry is deleted // - Snow globes now use sea glass instead of glitter - store.client_mut().update_record( - "fakespot-suggestions", - "fakespot-1", - json!([ + store + .client_mut() + .update_record(SuggestionProvider::Fakespot.record( + "fakespot-1", + json!([ snowglobe_fakespot().merge(json!({"title": "Make Your Own Sea Glass Snow Globes"})) ]), - ); + )); store.ingest(SuggestIngestionConstraints::all_providers()); assert_eq!( @@ -2647,15 +2597,14 @@ pub(crate) mod tests { MockRemoteSettingsClient::default() // This record is in the fakespot-suggest-products collection .with_record( - "fakespot-suggestions", - "fakespot-1", - json!([snowglobe_fakespot()]), + SuggestionProvider::Fakespot + .record("fakespot-1", json!([snowglobe_fakespot()])), ) - // This record is in the quicksuggest collection, but it has a fakespot record ID + // This record is in the Amp collection, but it has a fakespot record ID // for some reason. - .with_record("data", "fakespot-1", json![los_pollos_amp()]) - .with_icon(los_pollos_icon()) - .with_icon(fakespot_amazon_icon()), + .with_record(SuggestionProvider::Amp.record("fakespot-1", json![los_pollos_amp()])) + .with_record(SuggestionProvider::Amp.icon(los_pollos_icon())) + .with_record(SuggestionProvider::Fakespot.icon(fakespot_amazon_icon())), ); store.ingest(SuggestIngestionConstraints::all_providers()); assert_eq!( @@ -2673,8 +2622,8 @@ pub(crate) mod tests { // Test deleting one of the records store .client_mut() - .delete_record("quicksuggest", "fakespot-1") - .delete_icon(los_pollos_icon()); + .delete_record(SuggestionProvider::Amp.empty_record("fakespot-1")) + .delete_record(SuggestionProvider::Amp.icon(los_pollos_icon())); store.ingest(SuggestIngestionConstraints::all_providers()); // FIXME(Bug 1912283): this setup currently deletes both suggestions, since // `drop_suggestions` only checks against record ID. @@ -2702,8 +2651,8 @@ pub(crate) mod tests { .map(String::as_str) .collect::>(), HashSet::from([ - "quicksuggest:icon-fakespot-amazon", - "fakespot-suggest-products:fakespot-1" + "fakespot-suggest-products:fakespot-1", + "fakespot-suggest-products:icon-fakespot-amazon", ]), ); Ok(()) @@ -2715,13 +2664,12 @@ pub(crate) mod tests { let store = TestStore::new( MockRemoteSettingsClient::default() - .with_full_record( - "exposure-suggestions", + .with_record(SuggestionProvider::Exposure.full_record( "exposure-0", Some(json!({ "suggestion_type": "aaa", })), - Some(json!({ + Some(MockAttachment::Json(json!({ "keywords": [ "aaa keyword", "both keyword", @@ -2729,22 +2677,21 @@ pub(crate) mod tests { ["choco", ["bo", "late"]], ["dup", ["licate 1", "licate 2"]], ], - })), - ) - .with_full_record( - "exposure-suggestions", + }))), + )) + .with_record(SuggestionProvider::Exposure.full_record( "exposure-1", Some(json!({ "suggestion_type": "bbb", })), - Some(json!({ + Some(MockAttachment::Json(json!({ "keywords": [ "bbb keyword", "both keyword", ["common prefix", [" bbb"]], ], - })), - ), + }))), + )), ); store.ingest(SuggestIngestionConstraints { providers: Some(vec![SuggestionProvider::Exposure]), @@ -2992,32 +2939,30 @@ pub(crate) mod tests { let mut store = TestStore::new( MockRemoteSettingsClient::default() - .with_full_record( - "exposure-suggestions", + .with_record(SuggestionProvider::Exposure.full_record( "exposure-0", Some(json!({ "suggestion_type": "aaa", })), - Some(json!({ + Some(MockAttachment::Json(json!({ "keywords": [ "record 0 keyword", ["sug", ["gest"]], ], - })), - ) - .with_full_record( - "exposure-suggestions", + }))), + )) + .with_record(SuggestionProvider::Exposure.full_record( "exposure-1", Some(json!({ "suggestion_type": "aaa", })), - Some(json!({ + Some(MockAttachment::Json(json!({ "keywords": [ "record 1 keyword", ["sug", ["arplum"]], ], - })), - ), + }))), + )), ); store.ingest(SuggestIngestionConstraints { providers: Some(vec![SuggestionProvider::Exposure]), @@ -3056,7 +3001,7 @@ pub(crate) mod tests { // Delete the first record. store .client_mut() - .delete_record(Collection::Quicksuggest.name(), "exposure-0"); + .delete_record(SuggestionProvider::Exposure.empty_record("exposure-0")); store.ingest(SuggestIngestionConstraints { providers: Some(vec![SuggestionProvider::Exposure]), provider_constraints: Some(SuggestionProviderConstraints { @@ -3106,26 +3051,24 @@ pub(crate) mod tests { // Create suggestions with types "aaa" and "bbb". let store = TestStore::new( MockRemoteSettingsClient::default() - .with_full_record( - "exposure-suggestions", + .with_record(SuggestionProvider::Exposure.full_record( "exposure-0", Some(json!({ "suggestion_type": "aaa", })), - Some(json!({ + Some(MockAttachment::Json(json!({ "keywords": ["aaa keyword", "both keyword"], - })), - ) - .with_full_record( - "exposure-suggestions", + }))), + )) + .with_record(SuggestionProvider::Exposure.full_record( "exposure-1", Some(json!({ "suggestion_type": "bbb", })), - Some(json!({ + Some(MockAttachment::Json(json!({ "keywords": ["bbb keyword", "both keyword"], - })), - ), + }))), + )), ); // Ingest but don't pass in any provider constraints. The records will @@ -3232,15 +3175,16 @@ pub(crate) mod tests { before_each(); // Create an exposure suggestion and ingest it. - let mut store = TestStore::new(MockRemoteSettingsClient::default().with_full_record( - "exposure-suggestions", - "exposure-0", - Some(json!({ - "suggestion_type": "aaa", - })), - Some(json!({ - "keywords": ["old keyword"], - })), + let mut store = TestStore::new(MockRemoteSettingsClient::default().with_record( + SuggestionProvider::Exposure.full_record( + "exposure-0", + Some(json!({ + "suggestion_type": "aaa", + })), + Some(MockAttachment::Json(json!({ + "keywords": ["old keyword"], + }))), + ), )); store.ingest(SuggestIngestionConstraints { providers: Some(vec![SuggestionProvider::Exposure]), @@ -3252,16 +3196,17 @@ pub(crate) mod tests { }); // Add a new record of the same exposure type. - store.client_mut().add_full_record( - "exposure-suggestions", - "exposure-1", - Some(json!({ - "suggestion_type": "aaa", - })), - Some(json!({ - "keywords": ["new keyword"], - })), - ); + store + .client_mut() + .add_record(SuggestionProvider::Exposure.full_record( + "exposure-1", + Some(json!({ + "suggestion_type": "aaa", + })), + Some(MockAttachment::Json(json!({ + "keywords": ["new keyword"], + }))), + )); // Ingest, but don't ingest the exposure type. The store will download // the new record but shouldn't ingest its attachment. diff --git a/third_party/rust/suggest/src/suggestion.rs b/third_party/rust/suggest/src/suggestion.rs index 5ce9766a16e2..2520edb94406 100644 --- a/third_party/rust/suggest/src/suggestion.rs +++ b/third_party/rust/suggest/src/suggestion.rs @@ -16,11 +16,6 @@ const TIMESTAMP_TEMPLATE: &str = "%YYYYMMDDHH%"; /// 2 bytes shorter than [`TIMESTAMP_TEMPLATE`]. const TIMESTAMP_LENGTH: usize = 10; -/// Suggestion Types for Amp -pub(crate) enum AmpSuggestionType { - Mobile, - Desktop, -} /// A suggestion from the database to show in the address bar. #[derive(Clone, Debug, PartialEq, uniffi::Enum)] pub enum Suggestion { diff --git a/third_party/rust/suggest/src/testing/client.rs b/third_party/rust/suggest/src/testing/client.rs index 2d8034d28347..0979952fe4dc 100644 --- a/third_party/rust/suggest/src/testing/client.rs +++ b/third_party/rust/suggest/src/testing/client.rs @@ -9,7 +9,6 @@ use serde_json::json; use serde_json::Value as JsonValue; use crate::{ - db::SuggestDao, error::Error, rs::{Client, Collection, Record, SuggestRecordId, SuggestRecordType}, testing::JsonExt, @@ -36,148 +35,19 @@ impl Default for MockRemoteSettingsClient { } } -fn record_type_for_str(record_type_str: &str) -> SuggestRecordType { - for record_type in SuggestRecordType::all() { - if record_type.as_str() == record_type_str { - return *record_type; - } - } - panic!("Invalid record type string: {record_type_str}"); -} - impl MockRemoteSettingsClient { // Consuming Builder API, this is best for constructing the initial client - pub fn with_record(mut self, record_type: &str, record_id: &str, items: JsonValue) -> Self { - self.add_record(record_type, record_id, items); - self - } - - pub fn with_icon(mut self, icon: MockIcon) -> Self { - self.add_icon(icon); - self - } - - pub fn with_record_but_no_attachment(mut self, record_type: &str, record_id: &str) -> Self { - self.add_record_but_no_attachment(record_type, record_id); - self - } - - pub fn with_inline_record( - mut self, - record_type: &str, - record_id: &str, - inline_data: JsonValue, - ) -> Self { - self.add_inline_record(record_type, record_id, inline_data); - self - } - - pub fn with_full_record( - mut self, - record_type: &str, - record_id: &str, - inline_data: Option, - items: Option, - ) -> Self { - self.add_full_record(record_type, record_id, inline_data, items); + pub fn with_record(mut self, record: MockRecord) -> Self { + self.add_record(record); self } // Non-Consuming Builder API, this is best for updating an existing client /// Add a record to the mock data - /// - /// A single record typically contains multiple items in the attachment data. Pass all of them - /// as the `items` param. - pub fn add_record( - &mut self, - record_type: &str, - record_id: &str, - items: JsonValue, - ) -> &mut Self { - self.add_full_record(record_type, record_id, None, Some(items)) - } - - /// Add a record for an icon to the mock data - pub fn add_icon(&mut self, icon: MockIcon) -> &mut Self { - let icon_id = icon.id; - let record_id = format!("icon-{icon_id}"); - let location = format!("icon-{icon_id}.png"); - self.records.push(Record { - id: SuggestRecordId::new(record_id.to_string()), - last_modified: self.last_modified_timestamp, - collection: Collection::Quicksuggest, - attachment: Some(Attachment { - filename: location.clone(), - mimetype: icon.mimetype.into(), - hash: "".into(), - size: 0, - location: location.clone(), - }), - payload: serde_json::from_value(json!({"type": "icon"})).unwrap(), - }); - self.attachments - .insert(location, icon.data.as_bytes().to_vec()); - self - } - - /// Add a record without attachment data - pub fn add_record_but_no_attachment( - &mut self, - record_type: &str, - record_id: &str, - ) -> &mut Self { - self.add_full_record(record_type, record_id, None, None) - } - - /// Add a record to the mock data, with data stored inline rather than in an attachment - /// - /// Use this for record types like weather where the data it stored in the record itself rather - /// than in an attachment. - pub fn add_inline_record( - &mut self, - record_type: &str, - record_id: &str, - inline_data: JsonValue, - ) -> &mut Self { - self.add_full_record(record_type, record_id, Some(inline_data), None) - } - - /// Add a record with optional extra fields stored inline and attachment - /// items - pub fn add_full_record( - &mut self, - record_type: &str, - record_id: &str, - inline_data: Option, - items: Option, - ) -> &mut Self { - let location = format!("{record_type}-{record_id}.json"); - self.records.push(Record { - id: SuggestRecordId::new(record_id.to_string()), - collection: record_type_for_str(record_type).collection(), - last_modified: self.last_modified_timestamp, - payload: serde_json::from_value( - json!({ - "type": record_type, - }) - .merge(inline_data.unwrap_or(json!({}))), - ) - .unwrap(), - attachment: items.as_ref().map(|_| Attachment { - filename: location.clone(), - mimetype: "application/json".into(), - hash: "".into(), - size: 0, - location: location.clone(), - }), - }); - if let Some(i) = items { - self.attachments.insert( - location, - serde_json::to_vec(&i).expect("error serializing attachment data"), - ); - } + pub fn add_record(&mut self, mock_record: MockRecord) -> &mut Self { + self.insert_attachment(&mock_record); + self.records.push(self.record_from_mock(mock_record)); self } @@ -185,90 +55,61 @@ impl MockRemoteSettingsClient { // clients /// Update a record, storing a new payload and bumping the modified time - pub fn update_record( - &mut self, - record_type: &str, - record_id: &str, - items: JsonValue, - ) -> &mut Self { - let record = self - .records - .iter_mut() - .find(|r| r.id.as_str() == record_id) - .unwrap_or_else(|| panic!("update_record: {record_id} not found")); - let attachment_data = self - .attachments - .get_mut( - &record - .attachment - .as_ref() - .expect("update_record: no attachment") - .location, - ) - .unwrap_or_else(|| panic!("update_record: attachment not found for {record_id}")); - - record.last_modified += 1; - record.payload = serde_json::from_value(json!({"type": record_type})).unwrap(); - *attachment_data = serde_json::to_vec(&items).expect("error serializing attachment data"); - self - } - - /// Update an icon record, storing a new payload and bumping the modified time - pub fn update_icon(&mut self, icon: MockIcon) -> &mut Self { - let icon_id = &icon.id; - let record_id = format!("icon-{icon_id}"); - let record = self - .records - .iter_mut() - .find(|r| r.id.as_str() == record_id) - .unwrap_or_else(|| panic!("update_icon: {record_id} not found")); - let attachment_data = self - .attachments - .get_mut( - &record - .attachment - .as_ref() - .expect("update_icon: no attachment") - .location, - ) - .unwrap_or_else(|| panic!("update_icon: attachment not found for {icon_id}")); - - record.last_modified += 1; - *attachment_data = icon.data.as_bytes().to_vec(); - self - } - - /// Delete a record and it's attachment - pub fn delete_record(&mut self, collection: &str, record_id: &str) -> &mut Self { - let idx = self + pub fn update_record(&mut self, mock_record: MockRecord) -> &mut Self { + let index = self .records .iter() - .position(|r| r.id.as_str() == record_id && r.collection.name() == collection) - .unwrap_or_else(|| panic!("delete_record: {collection}:{record_id} not found")); - let deleted = self.records.remove(idx); - if let Some(a) = deleted.attachment { - self.attachments.remove(&a.location); - } + .position(|r| mock_record.matches_record(r)) + .unwrap_or_else(|| panic!("update_record: {} not found", mock_record.qualified_id())); + + self.insert_attachment(&mock_record); + + let mut record = self.record_from_mock(mock_record); + record.last_modified += 1; + self.records.splice(index..=index, std::iter::once(record)); + self } - pub fn delete_icon(&mut self, icon: MockIcon) -> &mut Self { - self.delete_record("quicksuggest", &format!("icon-{}", icon.id)) + /// Delete a record and its attachment + pub fn delete_record(&mut self, mock_record: MockRecord) -> &mut Self { + let index = self + .records + .iter() + .position(|r| mock_record.matches_record(r)) + .unwrap_or_else(|| panic!("delete_record: {} not found", mock_record.qualified_id())); + self.records.remove(index); + self.attachments.remove(&mock_record.qualified_id()); + self } -} -pub struct MockIcon { - pub id: &'static str, - pub data: &'static str, - pub mimetype: &'static str, + pub fn insert_attachment(&mut self, mock_record: &MockRecord) { + if let Some(bytes) = mock_record.attachment.as_ref().map(|a| match a { + MockAttachment::Json(items) => serde_json::to_vec(&items).unwrap_or_else(|_| { + panic!( + "error serializing attachment data: {}", + mock_record.qualified_id() + ) + }), + MockAttachment::Icon(icon) => icon.data.as_bytes().to_vec(), + }) { + self.attachments.insert(mock_record.qualified_id(), bytes); + } + } + + fn record_from_mock(&self, mock_record: MockRecord) -> Record { + let mut record: Record = mock_record.into(); + record.last_modified = self.last_modified_timestamp; + record + } } impl Client for MockRemoteSettingsClient { - fn get_records(&self, collection: Collection, _db: &mut SuggestDao) -> Result> { + fn get_records(&self, collection: Collection) -> Result> { Ok(self .records .iter() - .filter(|r| collection == r.record_type().collection()) + .filter(|r| collection == r.collection) .cloned() .collect()) } @@ -284,3 +125,67 @@ impl Client for MockRemoteSettingsClient { } } } + +pub struct MockRecord { + pub collection: Collection, + pub record_type: SuggestRecordType, + pub id: String, + pub inline_data: Option, + pub attachment: Option, +} + +impl MockRecord { + pub fn qualified_id(&self) -> String { + format!("{}:{}", self.collection.name(), self.id) + } + + fn matches_record(&self, record: &Record) -> bool { + self.collection == record.collection && self.id.as_str() == record.id.as_str() + } +} + +impl From for Record { + fn from(mock_record: MockRecord) -> Self { + let attachment = mock_record.attachment.as_ref().map(|a| match a { + MockAttachment::Json(_) => Attachment { + filename: mock_record.id.to_string(), + location: mock_record.qualified_id(), + mimetype: "application/json".into(), + hash: "".into(), + size: 0, + }, + MockAttachment::Icon(icon) => Attachment { + filename: mock_record.id.to_string(), + location: mock_record.qualified_id(), + mimetype: icon.mimetype.to_string(), + hash: "".into(), + size: 0, + }, + }); + + Self { + id: SuggestRecordId::new(mock_record.id), + collection: mock_record.collection, + last_modified: 0, + payload: serde_json::from_value( + json!({ + "type": mock_record.record_type.as_str(), + }) + .merge(mock_record.inline_data.unwrap_or(json!({}))), + ) + .unwrap(), + attachment, + } + } +} + +pub enum MockAttachment { + Json(JsonValue), + Icon(MockIcon), +} + +pub struct MockIcon { + pub id: &'static str, + pub data: &'static str, + pub mimetype: &'static str, +} diff --git a/third_party/rust/suggest/src/testing/data.rs b/third_party/rust/suggest/src/testing/data.rs index 7f3707649958..0ee291c70a1f 100644 --- a/third_party/rust/suggest/src/testing/data.rs +++ b/third_party/rust/suggest/src/testing/data.rs @@ -157,40 +157,6 @@ pub fn caltech_suggestion(full_keyword: &str) -> Suggestion { } } -pub fn a1a_amp_mobile() -> JsonValue { - json!({ - "id": 300, - "advertiser": "A1A Car Wash", - "iab_category": "2 - Auto", - "keywords": ["a1a", "ca", "car", "car wash"], - "title": "A1A Car Wash", - "url": "https://www.a1a-wash.biz", - "icon": "200", - "impression_url": "https://example.com/impression_url", - "click_url": "https://example.com/click_url", - "score": 0.3 - }) -} - -pub fn a1a_suggestion(full_keyword: &str, fts_match_info: Option) -> Suggestion { - Suggestion::Amp { - title: "A1A Car Wash".into(), - url: "https://www.a1a-wash.biz".into(), - raw_url: "https://www.a1a-wash.biz".into(), - icon: None, - icon_mimetype: None, - block_id: 300, - advertiser: "A1A Car Wash".into(), - iab_category: "2 - Auto".into(), - impression_url: "https://example.com/impression_url".into(), - click_url: "https://example.com/click_url".into(), - raw_click_url: "https://example.com/click_url".into(), - score: 0.3, - full_keyword: full_keyword.to_string(), - fts_match_info, - } -} - pub fn relay_amo() -> JsonValue { json!({ "title": "Firefox Relay", diff --git a/third_party/rust/suggest/src/testing/mod.rs b/third_party/rust/suggest/src/testing/mod.rs index 6359bf7a7f3a..4a61c9341c9e 100644 --- a/third_party/rust/suggest/src/testing/mod.rs +++ b/third_party/rust/suggest/src/testing/mod.rs @@ -5,7 +5,7 @@ mod client; mod data; -pub use client::{MockIcon, MockRemoteSettingsClient}; +pub use client::{MockAttachment, MockIcon, MockRecord, MockRemoteSettingsClient}; pub use data::*; use crate::Suggestion; diff --git a/third_party/rust/suggest/src/weather.rs b/third_party/rust/suggest/src/weather.rs index 28ee1463a19c..5d94b68897c0 100644 --- a/third_party/rust/suggest/src/weather.rs +++ b/third_party/rust/suggest/src/weather.rs @@ -494,15 +494,16 @@ mod tests { fn weather_provider_config() -> anyhow::Result<()> { before_each(); let store = TestStore::new(MockRemoteSettingsClient::default().with_record( - "weather", - "weather-1", - json!({ - "min_keyword_length": 3, - "keywords": ["ab", "xyz", "weather"], - "max_keyword_length": "weather".len(), - "max_keyword_word_count": 1, - "score": 0.24 - }), + SuggestionProvider::Weather.record( + "weather-1", + json!({ + "min_keyword_length": 3, + "keywords": ["ab", "xyz", "weather"], + "max_keyword_length": "weather".len(), + "max_keyword_word_count": 1, + "score": 0.24 + }), + ), )); store.ingest(SuggestIngestionConstraints { providers: Some(vec![SuggestionProvider::Weather]), @@ -523,16 +524,17 @@ mod tests { before_each(); let store = TestStore::new(MockRemoteSettingsClient::default().with_record( - "weather", - "weather-1", - json!({ - // min_keyword_length > 0 means prefixes are allowed. - "min_keyword_length": 5, - "keywords": ["ab", "xyz", "cdefg", "weather"], - "max_keyword_length": "weather".len(), - "max_keyword_word_count": 1, - "score": 0.24 - }), + SuggestionProvider::Weather.record( + "weather-1", + json!({ + // min_keyword_length > 0 means prefixes are allowed. + "min_keyword_length": 5, + "keywords": ["ab", "xyz", "cdefg", "weather"], + "max_keyword_length": "weather".len(), + "max_keyword_word_count": 1, + "score": 0.24 + }), + ), )); store.ingest(SuggestIngestionConstraints { @@ -600,16 +602,17 @@ mod tests { before_each(); let store = TestStore::new(MockRemoteSettingsClient::default().with_record( - "weather", - "weather-1", - json!({ - // min_keyword_length == 0 means prefixes are not allowed. - "min_keyword_length": 0, - "keywords": ["weather"], - "max_keyword_length": "weather".len(), - "max_keyword_word_count": 1, - "score": 0.24 - }), + SuggestionProvider::Weather.record( + "weather-1", + json!({ + // min_keyword_length == 0 means prefixes are not allowed. + "min_keyword_length": 0, + "keywords": ["weather"], + "max_keyword_length": "weather".len(), + "max_keyword_word_count": 1, + "score": 0.24 + }), + ), )); store.ingest(SuggestIngestionConstraints { @@ -645,21 +648,22 @@ mod tests { before_each(); let mut store = geoname::tests::new_test_store(); - store.client_mut().add_record( - "weather", - "weather-1", - json!({ - // Include a keyword that's a prefix of another keyword -- - // "weather" and "weather near me" -- so that when a test - // matches both we can verify only one suggestion is returned, - // not two. - "keywords": ["ab", "xyz", "weather", "weather near me"], - "min_keyword_length": 5, - "max_keyword_length": "weather".len(), - "max_keyword_word_count": 1, - "score": 0.24 - }), - ); + store + .client_mut() + .add_record(SuggestionProvider::Weather.record( + "weather-1", + json!({ + // Include a keyword that's a prefix of another keyword -- + // "weather" and "weather near me" -- so that when a test + // matches both we can verify only one suggestion is returned, + // not two. + "keywords": ["ab", "xyz", "weather", "weather near me"], + "min_keyword_length": 5, + "max_keyword_length": "weather".len(), + "max_keyword_word_count": 1, + "score": 0.24 + }), + )); store.ingest(SuggestIngestionConstraints { providers: Some(vec![SuggestionProvider::Weather]), @@ -1480,8 +1484,7 @@ mod tests { // metrics so the other values don't matter. let mut store = TestStore::new( MockRemoteSettingsClient::default() - .with_record( - "weather", + .with_record(SuggestionProvider::Weather.record( "weather-0", json!({ "max_keyword_length": 10, @@ -1490,9 +1493,8 @@ mod tests { "score": 0.24, "keywords": [] }), - ) - .with_record( - "weather", + )) + .with_record(SuggestionProvider::Weather.record( "weather-1", json!({ "max_keyword_length": 20, @@ -1501,7 +1503,7 @@ mod tests { "score": 0.24, "keywords": [] }), - ), + )), ); store.ingest(SuggestIngestionConstraints { @@ -1519,7 +1521,7 @@ mod tests { // Delete the first record. The metrics should change. store .client_mut() - .delete_record("quicksuggest", "weather-0"); + .delete_record(SuggestionProvider::Weather.empty_record("weather-0")); store.ingest(SuggestIngestionConstraints { providers: Some(vec![SuggestionProvider::Weather]), ..SuggestIngestionConstraints::all_providers() @@ -1532,17 +1534,18 @@ mod tests { })?; // Add a new record. The metrics should change again. - store.client_mut().add_record( - "weather", - "weather-3", - json!({ - "max_keyword_length": 15, - "max_keyword_word_count": 3, - "min_keyword_length": 3, - "score": 0.24, - "keywords": [] - }), - ); + store + .client_mut() + .add_record(SuggestionProvider::Weather.record( + "weather-3", + json!({ + "max_keyword_length": 15, + "max_keyword_word_count": 3, + "min_keyword_length": 3, + "score": 0.24, + "keywords": [] + }), + )); store.ingest(SuggestIngestionConstraints { providers: Some(vec![SuggestionProvider::Weather]), ..SuggestIngestionConstraints::all_providers() diff --git a/toolkit/components/uniffi-bindgen-gecko-js/components/generated/RustRemoteSettings.sys.mjs b/toolkit/components/uniffi-bindgen-gecko-js/components/generated/RustRemoteSettings.sys.mjs index cb56ad6c138f..afe7ab166b9b 100644 --- a/toolkit/components/uniffi-bindgen-gecko-js/components/generated/RustRemoteSettings.sys.mjs +++ b/toolkit/components/uniffi-bindgen-gecko-js/components/generated/RustRemoteSettings.sys.mjs @@ -765,6 +765,25 @@ export class RemoteSettingsClient { } } + /** + * sync + */ + sync() { + const liftResult = (result) => undefined; + const liftError = (data) => FfiConverterTypeRemoteSettingsError.lift(data); + const functionCall = () => { + return UniFFIScaffolding.callAsyncWrapper( + 21, // remote_settings:uniffi_remote_settings_fn_method_remotesettingsclient_sync + FfiConverterTypeRemoteSettingsClient.lower(this), + ) + } + try { + return functionCall().then((result) => handleRustResult(result, liftResult, liftError)); + } catch (error) { + return Promise.reject(error) + } + } + } // Export the FFIConverter object to make external types work. @@ -841,17 +860,13 @@ export class RemoteSettingsService { } throw e; } - return UniFFIScaffolding.callAsyncWrapper( - 24, // remote_settings:uniffi_remote_settings_fn_constructor_remotesettingsservice_new + return UniFFIScaffolding.callSync( + 25, // remote_settings:uniffi_remote_settings_fn_constructor_remotesettingsservice_new FfiConverterString.lower(storageDir), FfiConverterTypeRemoteSettingsConfig2.lower(config), ) } - try { - return functionCall().then((result) => handleRustResult(result, liftResult, liftError)); - } catch (error) { - return Promise.reject(error) - }} + return handleRustResult(functionCall(), liftResult, liftError);} /** * Create a new Remote Settings client @@ -870,7 +885,7 @@ export class RemoteSettingsService { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 21, // remote_settings:uniffi_remote_settings_fn_method_remotesettingsservice_make_client + 22, // remote_settings:uniffi_remote_settings_fn_method_remotesettingsservice_make_client FfiConverterTypeRemoteSettingsService.lower(this), FfiConverterString.lower(collectionName), ) @@ -891,7 +906,7 @@ export class RemoteSettingsService { const liftError = (data) => FfiConverterTypeRemoteSettingsError.lift(data); const functionCall = () => { return UniFFIScaffolding.callAsyncWrapper( - 22, // remote_settings:uniffi_remote_settings_fn_method_remotesettingsservice_sync + 23, // remote_settings:uniffi_remote_settings_fn_method_remotesettingsservice_sync FfiConverterTypeRemoteSettingsService.lower(this), ) } @@ -924,7 +939,7 @@ export class RemoteSettingsService { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 23, // remote_settings:uniffi_remote_settings_fn_method_remotesettingsservice_update_config + 24, // remote_settings:uniffi_remote_settings_fn_method_remotesettingsservice_update_config FfiConverterTypeRemoteSettingsService.lower(this), FfiConverterTypeRemoteSettingsConfig2.lower(config), ) diff --git a/toolkit/components/uniffi-bindgen-gecko-js/components/generated/RustSearch.sys.mjs b/toolkit/components/uniffi-bindgen-gecko-js/components/generated/RustSearch.sys.mjs index 6cd3530d2c78..b371983d8dc8 100644 --- a/toolkit/components/uniffi-bindgen-gecko-js/components/generated/RustSearch.sys.mjs +++ b/toolkit/components/uniffi-bindgen-gecko-js/components/generated/RustSearch.sys.mjs @@ -396,7 +396,7 @@ export class SearchEngineSelector { const liftError = null; const functionCall = () => { return UniFFIScaffolding.callSync( - 30, // search:uniffi_search_fn_constructor_searchengineselector_new + 31, // search:uniffi_search_fn_constructor_searchengineselector_new ) } return handleRustResult(functionCall(), liftResult, liftError);} @@ -411,7 +411,7 @@ export class SearchEngineSelector { const liftError = null; const functionCall = () => { return UniFFIScaffolding.callSync( - 25, // search:uniffi_search_fn_method_searchengineselector_clear_search_config + 26, // search:uniffi_search_fn_method_searchengineselector_clear_search_config FfiConverterTypeSearchEngineSelector.lower(this), ) } @@ -437,7 +437,7 @@ export class SearchEngineSelector { throw e; } return UniFFIScaffolding.callSync( - 26, // search:uniffi_search_fn_method_searchengineselector_filter_engine_configuration + 27, // search:uniffi_search_fn_method_searchengineselector_filter_engine_configuration FfiConverterTypeSearchEngineSelector.lower(this), FfiConverterTypeSearchUserEnvironment.lower(userEnvironment), ) @@ -461,7 +461,7 @@ export class SearchEngineSelector { throw e; } return UniFFIScaffolding.callSync( - 27, // search:uniffi_search_fn_method_searchengineselector_set_config_overrides + 28, // search:uniffi_search_fn_method_searchengineselector_set_config_overrides FfiConverterTypeSearchEngineSelector.lower(this), FfiConverterString.lower(overrides), ) @@ -489,7 +489,7 @@ export class SearchEngineSelector { throw e; } return UniFFIScaffolding.callSync( - 28, // search:uniffi_search_fn_method_searchengineselector_set_search_config + 29, // search:uniffi_search_fn_method_searchengineselector_set_search_config FfiConverterTypeSearchEngineSelector.lower(this), FfiConverterString.lower(configuration), ) @@ -530,7 +530,7 @@ export class SearchEngineSelector { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 29, // search:uniffi_search_fn_method_searchengineselector_use_remote_settings_server + 30, // search:uniffi_search_fn_method_searchengineselector_use_remote_settings_server FfiConverterTypeSearchEngineSelector.lower(this), FfiConverterTypeRemoteSettingsService.lower(service), FfiConverterBool.lower(applyEngineOverrides), diff --git a/toolkit/components/uniffi-bindgen-gecko-js/components/generated/RustSuggest.sys.mjs b/toolkit/components/uniffi-bindgen-gecko-js/components/generated/RustSuggest.sys.mjs index a28f9bd607e1..c4d88a6cc3cb 100644 --- a/toolkit/components/uniffi-bindgen-gecko-js/components/generated/RustSuggest.sys.mjs +++ b/toolkit/components/uniffi-bindgen-gecko-js/components/generated/RustSuggest.sys.mjs @@ -530,7 +530,7 @@ export class SuggestStore { * Creates a Suggest store. * @returns {SuggestStore} */ - static init(path,settingsConfig = null) { + static init(path,remoteSettingsService) { const liftResult = (result) => FfiConverterTypeSuggestStore.lift(result); const liftError = (data) => FfiConverterTypeSuggestApiError.lift(data); const functionCall = () => { @@ -543,17 +543,17 @@ export class SuggestStore { throw e; } try { - FfiConverterOptionalTypeRemoteSettingsConfig.checkType(settingsConfig) + FfiConverterTypeRemoteSettingsService.checkType(remoteSettingsService) } catch (e) { if (e instanceof UniFFITypeError) { - e.addItemDescriptionPart("settingsConfig"); + e.addItemDescriptionPart("remoteSettingsService"); } throw e; } return UniFFIScaffolding.callSync( - 42, // suggest:uniffi_suggest_fn_constructor_suggeststore_new + 43, // suggest:uniffi_suggest_fn_constructor_suggeststore_new FfiConverterString.lower(path), - FfiConverterOptionalTypeRemoteSettingsConfig.lower(settingsConfig), + FfiConverterTypeRemoteSettingsService.lower(remoteSettingsService), ) } return handleRustResult(functionCall(), liftResult, liftError);} @@ -566,7 +566,7 @@ export class SuggestStore { const liftError = (data) => FfiConverterTypeSuggestApiError.lift(data); const functionCall = () => { return UniFFIScaffolding.callAsyncWrapper( - 32, // suggest:uniffi_suggest_fn_method_suggeststore_clear + 33, // suggest:uniffi_suggest_fn_method_suggeststore_clear FfiConverterTypeSuggestStore.lower(this), ) } @@ -585,7 +585,7 @@ export class SuggestStore { const liftError = (data) => FfiConverterTypeSuggestApiError.lift(data); const functionCall = () => { return UniFFIScaffolding.callAsyncWrapper( - 33, // suggest:uniffi_suggest_fn_method_suggeststore_clear_dismissed_suggestions + 34, // suggest:uniffi_suggest_fn_method_suggeststore_clear_dismissed_suggestions FfiConverterTypeSuggestStore.lower(this), ) } @@ -616,7 +616,7 @@ export class SuggestStore { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 34, // suggest:uniffi_suggest_fn_method_suggeststore_dismiss_suggestion + 35, // suggest:uniffi_suggest_fn_method_suggeststore_dismiss_suggestion FfiConverterTypeSuggestStore.lower(this), FfiConverterString.lower(suggestionUrl), ) @@ -691,7 +691,7 @@ export class SuggestStore { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 35, // suggest:uniffi_suggest_fn_method_suggeststore_fetch_geonames + 36, // suggest:uniffi_suggest_fn_method_suggeststore_fetch_geonames FfiConverterTypeSuggestStore.lower(this), FfiConverterString.lower(query), FfiConverterBool.lower(matchNamePrefix), @@ -715,7 +715,7 @@ export class SuggestStore { const liftError = (data) => FfiConverterTypeSuggestApiError.lift(data); const functionCall = () => { return UniFFIScaffolding.callAsyncWrapper( - 36, // suggest:uniffi_suggest_fn_method_suggeststore_fetch_global_config + 37, // suggest:uniffi_suggest_fn_method_suggeststore_fetch_global_config FfiConverterTypeSuggestStore.lower(this), ) } @@ -743,7 +743,7 @@ export class SuggestStore { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 37, // suggest:uniffi_suggest_fn_method_suggeststore_fetch_provider_config + 38, // suggest:uniffi_suggest_fn_method_suggeststore_fetch_provider_config FfiConverterTypeSuggestStore.lower(this), FfiConverterTypeSuggestionProvider.lower(provider), ) @@ -772,7 +772,7 @@ export class SuggestStore { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 38, // suggest:uniffi_suggest_fn_method_suggeststore_ingest + 39, // suggest:uniffi_suggest_fn_method_suggeststore_ingest FfiConverterTypeSuggestStore.lower(this), FfiConverterTypeSuggestIngestionConstraints.lower(constraints), ) @@ -804,7 +804,7 @@ export class SuggestStore { throw e; } return UniFFIScaffolding.callSync( - 39, // suggest:uniffi_suggest_fn_method_suggeststore_interrupt + 40, // suggest:uniffi_suggest_fn_method_suggeststore_interrupt FfiConverterTypeSuggestStore.lower(this), FfiConverterOptionalTypeInterruptKind.lower(kind), ) @@ -829,7 +829,7 @@ export class SuggestStore { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 40, // suggest:uniffi_suggest_fn_method_suggeststore_query + 41, // suggest:uniffi_suggest_fn_method_suggeststore_query FfiConverterTypeSuggestStore.lower(this), FfiConverterTypeSuggestionQuery.lower(query), ) @@ -858,7 +858,7 @@ export class SuggestStore { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 41, // suggest:uniffi_suggest_fn_method_suggeststore_query_with_metrics + 42, // suggest:uniffi_suggest_fn_method_suggeststore_query_with_metrics FfiConverterTypeSuggestStore.lower(this), FfiConverterTypeSuggestionQuery.lower(query), ) @@ -929,7 +929,7 @@ export class SuggestStoreBuilder { const liftError = null; const functionCall = () => { return UniFFIScaffolding.callSync( - 50, // suggest:uniffi_suggest_fn_constructor_suggeststorebuilder_new + 51, // suggest:uniffi_suggest_fn_constructor_suggeststorebuilder_new ) } return handleRustResult(functionCall(), liftResult, liftError);} @@ -943,7 +943,7 @@ export class SuggestStoreBuilder { const liftError = (data) => FfiConverterTypeSuggestApiError.lift(data); const functionCall = () => { return UniFFIScaffolding.callSync( - 43, // suggest:uniffi_suggest_fn_method_suggeststorebuilder_build + 44, // suggest:uniffi_suggest_fn_method_suggeststorebuilder_build FfiConverterTypeSuggestStoreBuilder.lower(this), ) } @@ -967,7 +967,7 @@ export class SuggestStoreBuilder { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 44, // suggest:uniffi_suggest_fn_method_suggeststorebuilder_cache_path + 45, // suggest:uniffi_suggest_fn_method_suggeststorebuilder_cache_path FfiConverterTypeSuggestStoreBuilder.lower(this), FfiConverterString.lower(path), ) @@ -996,7 +996,7 @@ export class SuggestStoreBuilder { throw e; } return UniFFIScaffolding.callSync( - 45, // suggest:uniffi_suggest_fn_method_suggeststorebuilder_data_path + 46, // suggest:uniffi_suggest_fn_method_suggeststorebuilder_data_path FfiConverterTypeSuggestStoreBuilder.lower(this), FfiConverterString.lower(path), ) @@ -1033,7 +1033,7 @@ export class SuggestStoreBuilder { throw e; } return UniFFIScaffolding.callSync( - 46, // suggest:uniffi_suggest_fn_method_suggeststorebuilder_load_extension + 47, // suggest:uniffi_suggest_fn_method_suggeststorebuilder_load_extension FfiConverterTypeSuggestStoreBuilder.lower(this), FfiConverterString.lower(library), FfiConverterOptionalstring.lower(entryPoint), @@ -1059,7 +1059,7 @@ export class SuggestStoreBuilder { throw e; } return UniFFIScaffolding.callSync( - 47, // suggest:uniffi_suggest_fn_method_suggeststorebuilder_remote_settings_bucket_name + 48, // suggest:uniffi_suggest_fn_method_suggeststorebuilder_remote_settings_bucket_name FfiConverterTypeSuggestStoreBuilder.lower(this), FfiConverterString.lower(bucketName), ) @@ -1084,7 +1084,7 @@ export class SuggestStoreBuilder { throw e; } return UniFFIScaffolding.callSync( - 48, // suggest:uniffi_suggest_fn_method_suggeststorebuilder_remote_settings_server + 49, // suggest:uniffi_suggest_fn_method_suggeststorebuilder_remote_settings_server FfiConverterTypeSuggestStoreBuilder.lower(this), FfiConverterTypeRemoteSettingsServer.lower(server), ) @@ -1108,17 +1108,13 @@ export class SuggestStoreBuilder { } throw e; } - return UniFFIScaffolding.callAsyncWrapper( - 49, // suggest:uniffi_suggest_fn_method_suggeststorebuilder_remote_settings_service + return UniFFIScaffolding.callSync( + 50, // suggest:uniffi_suggest_fn_method_suggeststorebuilder_remote_settings_service FfiConverterTypeSuggestStoreBuilder.lower(this), FfiConverterTypeRemoteSettingsService.lower(rsService), ) } - try { - return functionCall().then((result) => handleRustResult(result, liftResult, liftError)); - } catch (error) { - return Promise.reject(error) - } + return handleRustResult(functionCall(), liftResult, liftError); } } @@ -3208,18 +3204,14 @@ export const SuggestionProvider = { * WEATHER */ WEATHER: 7, - /** - * AMP_MOBILE - */ - AMP_MOBILE: 8, /** * FAKESPOT */ - FAKESPOT: 9, + FAKESPOT: 8, /** * EXPOSURE */ - EXPOSURE: 10, + EXPOSURE: 9, }; Object.freeze(SuggestionProvider); @@ -3242,10 +3234,8 @@ export class FfiConverterTypeSuggestionProvider extends FfiConverterArrayBuffer case 7: return SuggestionProvider.WEATHER case 8: - return SuggestionProvider.AMP_MOBILE - case 9: return SuggestionProvider.FAKESPOT - case 10: + case 9: return SuggestionProvider.EXPOSURE default: throw new UniFFITypeError("Unknown SuggestionProvider variant"); @@ -3281,16 +3271,12 @@ export class FfiConverterTypeSuggestionProvider extends FfiConverterArrayBuffer dataStream.writeInt32(7); return; } - if (value === SuggestionProvider.AMP_MOBILE) { + if (value === SuggestionProvider.FAKESPOT) { dataStream.writeInt32(8); return; } - if (value === SuggestionProvider.FAKESPOT) { - dataStream.writeInt32(9); - return; - } if (value === SuggestionProvider.EXPOSURE) { - dataStream.writeInt32(10); + dataStream.writeInt32(9); return; } throw new UniFFITypeError("Unknown SuggestionProvider variant"); @@ -3301,7 +3287,7 @@ export class FfiConverterTypeSuggestionProvider extends FfiConverterArrayBuffer } static checkType(value) { - if (!Number.isInteger(value) || value < 1 || value > 10) { + if (!Number.isInteger(value) || value < 1 || value > 9) { throw new UniFFITypeError(`${value} is not a valid value for SuggestionProvider`); } } @@ -3789,43 +3775,6 @@ export class FfiConverterOptionalSequenceTypeSuggestionProvider extends FfiConve } } -// Export the FFIConverter object to make external types work. -export class FfiConverterOptionalTypeRemoteSettingsConfig extends FfiConverterArrayBuffer { - static checkType(value) { - if (value !== undefined && value !== null) { - FfiConverterTypeRemoteSettingsConfig.checkType(value) - } - } - - static read(dataStream) { - const code = dataStream.readUint8(0); - switch (code) { - case 0: - return null - case 1: - return FfiConverterTypeRemoteSettingsConfig.read(dataStream) - default: - throw new UniFFIError(`Unexpected code: ${code}`); - } - } - - static write(dataStream, value) { - if (value === null || value === undefined) { - dataStream.writeUint8(0); - return; - } - dataStream.writeUint8(1); - FfiConverterTypeRemoteSettingsConfig.write(dataStream, value) - } - - static computeSize(value) { - if (value === null || value === undefined) { - return 1; - } - return 1 + FfiConverterTypeRemoteSettingsConfig.computeSize(value) - } -} - // Export the FFIConverter object to make external types work. export class FfiConverterSequencestring extends FfiConverterArrayBuffer { static read(dataStream) { @@ -4090,14 +4039,6 @@ export class FfiConverterSequenceTypeSuggestionProvider extends FfiConverterArra } } -import { - FfiConverterTypeRemoteSettingsConfig, - RemoteSettingsConfig, -} from "resource://gre/modules/RustRemoteSettings.sys.mjs"; - -// Export the FFIConverter object to make external types work. -export { FfiConverterTypeRemoteSettingsConfig, RemoteSettingsConfig }; - import { FfiConverterTypeRemoteSettingsServer, RemoteSettingsServer, @@ -4146,7 +4087,7 @@ export function rawSuggestionUrlMatches(rawUrl,cookedUrl) { throw e; } return UniFFIScaffolding.callSync( - 31, // suggest:uniffi_suggest_fn_func_raw_suggestion_url_matches + 32, // suggest:uniffi_suggest_fn_func_raw_suggestion_url_matches FfiConverterString.lower(rawUrl), FfiConverterString.lower(cookedUrl), ) diff --git a/toolkit/components/uniffi-bindgen-gecko-js/components/generated/RustTabs.sys.mjs b/toolkit/components/uniffi-bindgen-gecko-js/components/generated/RustTabs.sys.mjs index e5c869e4eaa6..514cd7a52069 100644 --- a/toolkit/components/uniffi-bindgen-gecko-js/components/generated/RustTabs.sys.mjs +++ b/toolkit/components/uniffi-bindgen-gecko-js/components/generated/RustTabs.sys.mjs @@ -448,7 +448,7 @@ export class RemoteCommandStore { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 51, // tabs:uniffi_tabs_fn_method_remotecommandstore_add_remote_command + 52, // tabs:uniffi_tabs_fn_method_remotecommandstore_add_remote_command FfiConverterTypeRemoteCommandStore.lower(this), FfiConverterString.lower(deviceId), FfiConverterTypeRemoteCommand.lower(command), @@ -494,7 +494,7 @@ export class RemoteCommandStore { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 52, // tabs:uniffi_tabs_fn_method_remotecommandstore_add_remote_command_at + 53, // tabs:uniffi_tabs_fn_method_remotecommandstore_add_remote_command_at FfiConverterTypeRemoteCommandStore.lower(this), FfiConverterString.lower(deviceId), FfiConverterTypeRemoteCommand.lower(command), @@ -517,7 +517,7 @@ export class RemoteCommandStore { const liftError = (data) => FfiConverterTypeTabsApiError.lift(data); const functionCall = () => { return UniFFIScaffolding.callAsyncWrapper( - 53, // tabs:uniffi_tabs_fn_method_remotecommandstore_get_unsent_commands + 54, // tabs:uniffi_tabs_fn_method_remotecommandstore_get_unsent_commands FfiConverterTypeRemoteCommandStore.lower(this), ) } @@ -554,7 +554,7 @@ export class RemoteCommandStore { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 54, // tabs:uniffi_tabs_fn_method_remotecommandstore_remove_remote_command + 55, // tabs:uniffi_tabs_fn_method_remotecommandstore_remove_remote_command FfiConverterTypeRemoteCommandStore.lower(this), FfiConverterString.lower(deviceId), FfiConverterTypeRemoteCommand.lower(command), @@ -584,7 +584,7 @@ export class RemoteCommandStore { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 55, // tabs:uniffi_tabs_fn_method_remotecommandstore_set_pending_command_sent + 56, // tabs:uniffi_tabs_fn_method_remotecommandstore_set_pending_command_sent FfiConverterTypeRemoteCommandStore.lower(this), FfiConverterTypePendingCommand.lower(command), ) @@ -655,7 +655,7 @@ export class TabsBridgedEngine { const liftError = (data) => FfiConverterTypeTabsApiError.lift(data); const functionCall = () => { return UniFFIScaffolding.callAsyncWrapper( - 56, // tabs:uniffi_tabs_fn_method_tabsbridgedengine_apply + 57, // tabs:uniffi_tabs_fn_method_tabsbridgedengine_apply FfiConverterTypeTabsBridgedEngine.lower(this), ) } @@ -683,7 +683,7 @@ export class TabsBridgedEngine { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 57, // tabs:uniffi_tabs_fn_method_tabsbridgedengine_ensure_current_sync_id + 58, // tabs:uniffi_tabs_fn_method_tabsbridgedengine_ensure_current_sync_id FfiConverterTypeTabsBridgedEngine.lower(this), FfiConverterString.lower(newSyncId), ) @@ -704,7 +704,7 @@ export class TabsBridgedEngine { const liftError = (data) => FfiConverterTypeTabsApiError.lift(data); const functionCall = () => { return UniFFIScaffolding.callAsyncWrapper( - 58, // tabs:uniffi_tabs_fn_method_tabsbridgedengine_last_sync + 59, // tabs:uniffi_tabs_fn_method_tabsbridgedengine_last_sync FfiConverterTypeTabsBridgedEngine.lower(this), ) } @@ -731,7 +731,7 @@ export class TabsBridgedEngine { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 59, // tabs:uniffi_tabs_fn_method_tabsbridgedengine_prepare_for_sync + 60, // tabs:uniffi_tabs_fn_method_tabsbridgedengine_prepare_for_sync FfiConverterTypeTabsBridgedEngine.lower(this), FfiConverterString.lower(clientData), ) @@ -751,7 +751,7 @@ export class TabsBridgedEngine { const liftError = (data) => FfiConverterTypeTabsApiError.lift(data); const functionCall = () => { return UniFFIScaffolding.callAsyncWrapper( - 60, // tabs:uniffi_tabs_fn_method_tabsbridgedengine_reset + 61, // tabs:uniffi_tabs_fn_method_tabsbridgedengine_reset FfiConverterTypeTabsBridgedEngine.lower(this), ) } @@ -771,7 +771,7 @@ export class TabsBridgedEngine { const liftError = (data) => FfiConverterTypeTabsApiError.lift(data); const functionCall = () => { return UniFFIScaffolding.callAsyncWrapper( - 61, // tabs:uniffi_tabs_fn_method_tabsbridgedengine_reset_sync_id + 62, // tabs:uniffi_tabs_fn_method_tabsbridgedengine_reset_sync_id FfiConverterTypeTabsBridgedEngine.lower(this), ) } @@ -798,7 +798,7 @@ export class TabsBridgedEngine { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 62, // tabs:uniffi_tabs_fn_method_tabsbridgedengine_set_last_sync + 63, // tabs:uniffi_tabs_fn_method_tabsbridgedengine_set_last_sync FfiConverterTypeTabsBridgedEngine.lower(this), FfiConverterI64.lower(lastSync), ) @@ -834,7 +834,7 @@ export class TabsBridgedEngine { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 63, // tabs:uniffi_tabs_fn_method_tabsbridgedengine_set_uploaded + 64, // tabs:uniffi_tabs_fn_method_tabsbridgedengine_set_uploaded FfiConverterTypeTabsBridgedEngine.lower(this), FfiConverterI64.lower(newTimestamp), FfiConverterSequenceTypeTabsGuid.lower(uploadedIds), @@ -863,7 +863,7 @@ export class TabsBridgedEngine { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 64, // tabs:uniffi_tabs_fn_method_tabsbridgedengine_store_incoming + 65, // tabs:uniffi_tabs_fn_method_tabsbridgedengine_store_incoming FfiConverterTypeTabsBridgedEngine.lower(this), FfiConverterSequencestring.lower(incomingEnvelopesAsJson), ) @@ -883,7 +883,7 @@ export class TabsBridgedEngine { const liftError = (data) => FfiConverterTypeTabsApiError.lift(data); const functionCall = () => { return UniFFIScaffolding.callAsyncWrapper( - 65, // tabs:uniffi_tabs_fn_method_tabsbridgedengine_sync_finished + 66, // tabs:uniffi_tabs_fn_method_tabsbridgedengine_sync_finished FfiConverterTypeTabsBridgedEngine.lower(this), ) } @@ -903,7 +903,7 @@ export class TabsBridgedEngine { const liftError = (data) => FfiConverterTypeTabsApiError.lift(data); const functionCall = () => { return UniFFIScaffolding.callAsyncWrapper( - 66, // tabs:uniffi_tabs_fn_method_tabsbridgedengine_sync_id + 67, // tabs:uniffi_tabs_fn_method_tabsbridgedengine_sync_id FfiConverterTypeTabsBridgedEngine.lower(this), ) } @@ -922,7 +922,7 @@ export class TabsBridgedEngine { const liftError = (data) => FfiConverterTypeTabsApiError.lift(data); const functionCall = () => { return UniFFIScaffolding.callAsyncWrapper( - 67, // tabs:uniffi_tabs_fn_method_tabsbridgedengine_sync_started + 68, // tabs:uniffi_tabs_fn_method_tabsbridgedengine_sync_started FfiConverterTypeTabsBridgedEngine.lower(this), ) } @@ -941,7 +941,7 @@ export class TabsBridgedEngine { const liftError = (data) => FfiConverterTypeTabsApiError.lift(data); const functionCall = () => { return UniFFIScaffolding.callAsyncWrapper( - 68, // tabs:uniffi_tabs_fn_method_tabsbridgedengine_wipe + 69, // tabs:uniffi_tabs_fn_method_tabsbridgedengine_wipe FfiConverterTypeTabsBridgedEngine.lower(this), ) } @@ -1016,7 +1016,7 @@ export class TabsStore { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 75, // tabs:uniffi_tabs_fn_constructor_tabsstore_new + 76, // tabs:uniffi_tabs_fn_constructor_tabsstore_new FfiConverterString.lower(path), ) } @@ -1035,7 +1035,7 @@ export class TabsStore { const liftError = null; const functionCall = () => { return UniFFIScaffolding.callAsyncWrapper( - 69, // tabs:uniffi_tabs_fn_method_tabsstore_bridged_engine + 70, // tabs:uniffi_tabs_fn_method_tabsstore_bridged_engine FfiConverterTypeTabsStore.lower(this), ) } @@ -1054,7 +1054,7 @@ export class TabsStore { const liftError = null; const functionCall = () => { return UniFFIScaffolding.callAsyncWrapper( - 70, // tabs:uniffi_tabs_fn_method_tabsstore_close_connection + 71, // tabs:uniffi_tabs_fn_method_tabsstore_close_connection FfiConverterTypeTabsStore.lower(this), ) } @@ -1074,7 +1074,7 @@ export class TabsStore { const liftError = null; const functionCall = () => { return UniFFIScaffolding.callAsyncWrapper( - 71, // tabs:uniffi_tabs_fn_method_tabsstore_get_all + 72, // tabs:uniffi_tabs_fn_method_tabsstore_get_all FfiConverterTypeTabsStore.lower(this), ) } @@ -1094,7 +1094,7 @@ export class TabsStore { const liftError = null; const functionCall = () => { return UniFFIScaffolding.callAsyncWrapper( - 72, // tabs:uniffi_tabs_fn_method_tabsstore_new_remote_command_store + 73, // tabs:uniffi_tabs_fn_method_tabsstore_new_remote_command_store FfiConverterTypeTabsStore.lower(this), ) } @@ -1113,7 +1113,7 @@ export class TabsStore { const liftError = null; const functionCall = () => { return UniFFIScaffolding.callAsyncWrapper( - 73, // tabs:uniffi_tabs_fn_method_tabsstore_register_with_sync_manager + 74, // tabs:uniffi_tabs_fn_method_tabsstore_register_with_sync_manager FfiConverterTypeTabsStore.lower(this), ) } @@ -1140,7 +1140,7 @@ export class TabsStore { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 74, // tabs:uniffi_tabs_fn_method_tabsstore_set_local_tabs + 75, // tabs:uniffi_tabs_fn_method_tabsstore_set_local_tabs FfiConverterTypeTabsStore.lower(this), FfiConverterSequenceTypeRemoteTabRecord.lower(remoteTabs), ) diff --git a/toolkit/components/uniffi-bindgen-gecko-js/components/generated/RustWebextstorage.sys.mjs b/toolkit/components/uniffi-bindgen-gecko-js/components/generated/RustWebextstorage.sys.mjs index f87ccebcd797..95a8c3a4d138 100644 --- a/toolkit/components/uniffi-bindgen-gecko-js/components/generated/RustWebextstorage.sys.mjs +++ b/toolkit/components/uniffi-bindgen-gecko-js/components/generated/RustWebextstorage.sys.mjs @@ -417,7 +417,7 @@ export class WebExtStorageBridgedEngine { const liftError = (data) => FfiConverterTypeWebExtStorageApiError.lift(data); const functionCall = () => { return UniFFIScaffolding.callAsyncWrapper( - 76, // webextstorage:uniffi_webext_storage_fn_method_webextstoragebridgedengine_apply + 77, // webextstorage:uniffi_webext_storage_fn_method_webextstoragebridgedengine_apply FfiConverterTypeWebExtStorageBridgedEngine.lower(this), ) } @@ -445,7 +445,7 @@ export class WebExtStorageBridgedEngine { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 77, // webextstorage:uniffi_webext_storage_fn_method_webextstoragebridgedengine_ensure_current_sync_id + 78, // webextstorage:uniffi_webext_storage_fn_method_webextstoragebridgedengine_ensure_current_sync_id FfiConverterTypeWebExtStorageBridgedEngine.lower(this), FfiConverterString.lower(newSyncId), ) @@ -466,7 +466,7 @@ export class WebExtStorageBridgedEngine { const liftError = (data) => FfiConverterTypeWebExtStorageApiError.lift(data); const functionCall = () => { return UniFFIScaffolding.callAsyncWrapper( - 78, // webextstorage:uniffi_webext_storage_fn_method_webextstoragebridgedengine_last_sync + 79, // webextstorage:uniffi_webext_storage_fn_method_webextstoragebridgedengine_last_sync FfiConverterTypeWebExtStorageBridgedEngine.lower(this), ) } @@ -493,7 +493,7 @@ export class WebExtStorageBridgedEngine { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 79, // webextstorage:uniffi_webext_storage_fn_method_webextstoragebridgedengine_prepare_for_sync + 80, // webextstorage:uniffi_webext_storage_fn_method_webextstoragebridgedengine_prepare_for_sync FfiConverterTypeWebExtStorageBridgedEngine.lower(this), FfiConverterString.lower(clientData), ) @@ -513,7 +513,7 @@ export class WebExtStorageBridgedEngine { const liftError = (data) => FfiConverterTypeWebExtStorageApiError.lift(data); const functionCall = () => { return UniFFIScaffolding.callAsyncWrapper( - 80, // webextstorage:uniffi_webext_storage_fn_method_webextstoragebridgedengine_reset + 81, // webextstorage:uniffi_webext_storage_fn_method_webextstoragebridgedengine_reset FfiConverterTypeWebExtStorageBridgedEngine.lower(this), ) } @@ -533,7 +533,7 @@ export class WebExtStorageBridgedEngine { const liftError = (data) => FfiConverterTypeWebExtStorageApiError.lift(data); const functionCall = () => { return UniFFIScaffolding.callAsyncWrapper( - 81, // webextstorage:uniffi_webext_storage_fn_method_webextstoragebridgedengine_reset_sync_id + 82, // webextstorage:uniffi_webext_storage_fn_method_webextstoragebridgedengine_reset_sync_id FfiConverterTypeWebExtStorageBridgedEngine.lower(this), ) } @@ -560,7 +560,7 @@ export class WebExtStorageBridgedEngine { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 82, // webextstorage:uniffi_webext_storage_fn_method_webextstoragebridgedengine_set_last_sync + 83, // webextstorage:uniffi_webext_storage_fn_method_webextstoragebridgedengine_set_last_sync FfiConverterTypeWebExtStorageBridgedEngine.lower(this), FfiConverterI64.lower(lastSync), ) @@ -596,7 +596,7 @@ export class WebExtStorageBridgedEngine { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 83, // webextstorage:uniffi_webext_storage_fn_method_webextstoragebridgedengine_set_uploaded + 84, // webextstorage:uniffi_webext_storage_fn_method_webextstoragebridgedengine_set_uploaded FfiConverterTypeWebExtStorageBridgedEngine.lower(this), FfiConverterI64.lower(serverModifiedMillis), FfiConverterSequenceTypeGuid.lower(guids), @@ -625,7 +625,7 @@ export class WebExtStorageBridgedEngine { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 84, // webextstorage:uniffi_webext_storage_fn_method_webextstoragebridgedengine_store_incoming + 85, // webextstorage:uniffi_webext_storage_fn_method_webextstoragebridgedengine_store_incoming FfiConverterTypeWebExtStorageBridgedEngine.lower(this), FfiConverterSequencestring.lower(incoming), ) @@ -645,7 +645,7 @@ export class WebExtStorageBridgedEngine { const liftError = (data) => FfiConverterTypeWebExtStorageApiError.lift(data); const functionCall = () => { return UniFFIScaffolding.callAsyncWrapper( - 85, // webextstorage:uniffi_webext_storage_fn_method_webextstoragebridgedengine_sync_finished + 86, // webextstorage:uniffi_webext_storage_fn_method_webextstoragebridgedengine_sync_finished FfiConverterTypeWebExtStorageBridgedEngine.lower(this), ) } @@ -665,7 +665,7 @@ export class WebExtStorageBridgedEngine { const liftError = (data) => FfiConverterTypeWebExtStorageApiError.lift(data); const functionCall = () => { return UniFFIScaffolding.callAsyncWrapper( - 86, // webextstorage:uniffi_webext_storage_fn_method_webextstoragebridgedengine_sync_id + 87, // webextstorage:uniffi_webext_storage_fn_method_webextstoragebridgedengine_sync_id FfiConverterTypeWebExtStorageBridgedEngine.lower(this), ) } @@ -684,7 +684,7 @@ export class WebExtStorageBridgedEngine { const liftError = (data) => FfiConverterTypeWebExtStorageApiError.lift(data); const functionCall = () => { return UniFFIScaffolding.callAsyncWrapper( - 87, // webextstorage:uniffi_webext_storage_fn_method_webextstoragebridgedengine_sync_started + 88, // webextstorage:uniffi_webext_storage_fn_method_webextstoragebridgedengine_sync_started FfiConverterTypeWebExtStorageBridgedEngine.lower(this), ) } @@ -703,7 +703,7 @@ export class WebExtStorageBridgedEngine { const liftError = (data) => FfiConverterTypeWebExtStorageApiError.lift(data); const functionCall = () => { return UniFFIScaffolding.callAsyncWrapper( - 88, // webextstorage:uniffi_webext_storage_fn_method_webextstoragebridgedengine_wipe + 89, // webextstorage:uniffi_webext_storage_fn_method_webextstoragebridgedengine_wipe FfiConverterTypeWebExtStorageBridgedEngine.lower(this), ) } @@ -778,7 +778,7 @@ export class WebExtStorageStore { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 97, // webextstorage:uniffi_webext_storage_fn_constructor_webextstoragestore_new + 98, // webextstorage:uniffi_webext_storage_fn_constructor_webextstoragestore_new FfiConverterString.lower(path), ) } @@ -797,7 +797,7 @@ export class WebExtStorageStore { const liftError = null; const functionCall = () => { return UniFFIScaffolding.callAsyncWrapper( - 89, // webextstorage:uniffi_webext_storage_fn_method_webextstoragestore_bridged_engine + 90, // webextstorage:uniffi_webext_storage_fn_method_webextstoragestore_bridged_engine FfiConverterTypeWebExtStorageStore.lower(this), ) } @@ -825,7 +825,7 @@ export class WebExtStorageStore { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 90, // webextstorage:uniffi_webext_storage_fn_method_webextstoragestore_clear + 91, // webextstorage:uniffi_webext_storage_fn_method_webextstoragestore_clear FfiConverterTypeWebExtStorageStore.lower(this), FfiConverterString.lower(extId), ) @@ -845,7 +845,7 @@ export class WebExtStorageStore { const liftError = (data) => FfiConverterTypeWebExtStorageApiError.lift(data); const functionCall = () => { return UniFFIScaffolding.callAsyncWrapper( - 91, // webextstorage:uniffi_webext_storage_fn_method_webextstoragestore_close + 92, // webextstorage:uniffi_webext_storage_fn_method_webextstoragestore_close FfiConverterTypeWebExtStorageStore.lower(this), ) } @@ -881,7 +881,7 @@ export class WebExtStorageStore { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 92, // webextstorage:uniffi_webext_storage_fn_method_webextstoragestore_get + 93, // webextstorage:uniffi_webext_storage_fn_method_webextstoragestore_get FfiConverterTypeWebExtStorageStore.lower(this), FfiConverterString.lower(extId), FfiConverterTypeJsonValue.lower(keys), @@ -919,7 +919,7 @@ export class WebExtStorageStore { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 93, // webextstorage:uniffi_webext_storage_fn_method_webextstoragestore_get_bytes_in_use + 94, // webextstorage:uniffi_webext_storage_fn_method_webextstoragestore_get_bytes_in_use FfiConverterTypeWebExtStorageStore.lower(this), FfiConverterString.lower(extId), FfiConverterTypeJsonValue.lower(keys), @@ -941,7 +941,7 @@ export class WebExtStorageStore { const liftError = (data) => FfiConverterTypeWebExtStorageApiError.lift(data); const functionCall = () => { return UniFFIScaffolding.callAsyncWrapper( - 94, // webextstorage:uniffi_webext_storage_fn_method_webextstoragestore_get_synced_changes + 95, // webextstorage:uniffi_webext_storage_fn_method_webextstoragestore_get_synced_changes FfiConverterTypeWebExtStorageStore.lower(this), ) } @@ -977,7 +977,7 @@ export class WebExtStorageStore { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 95, // webextstorage:uniffi_webext_storage_fn_method_webextstoragestore_remove + 96, // webextstorage:uniffi_webext_storage_fn_method_webextstoragestore_remove FfiConverterTypeWebExtStorageStore.lower(this), FfiConverterString.lower(extId), FfiConverterTypeJsonValue.lower(keys), @@ -1015,7 +1015,7 @@ export class WebExtStorageStore { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 96, // webextstorage:uniffi_webext_storage_fn_method_webextstoragestore_set + 97, // webextstorage:uniffi_webext_storage_fn_method_webextstoragestore_set FfiConverterTypeWebExtStorageStore.lower(this), FfiConverterString.lower(extId), FfiConverterTypeJsonValue.lower(val), diff --git a/toolkit/components/uniffi-bindgen-gecko-js/config.toml b/toolkit/components/uniffi-bindgen-gecko-js/config.toml index 156585de98a9..4bfe82e1376f 100644 --- a/toolkit/components/uniffi-bindgen-gecko-js/config.toml +++ b/toolkit/components/uniffi-bindgen-gecko-js/config.toml @@ -34,6 +34,7 @@ main_thread = [ "SuggestStoreBuilder.load_extension", "SuggestStoreBuilder.remote_settings_bucket_name", "SuggestStoreBuilder.remote_settings_server", + "SuggestStoreBuilder.remote_settings_service", "SuggestStoreBuilder.build", ] @@ -54,6 +55,7 @@ enable = true # These are exceptions to the async wrapping. These functions must not be `await`ed. main_thread = [ "RemoteSettings.new", + "RemoteSettingsService.new", ] [error_support.async_wrappers] diff --git a/toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated/RustArithmetic.sys.mjs b/toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated/RustArithmetic.sys.mjs index fba4a3e313a1..c5a4779bc248 100644 --- a/toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated/RustArithmetic.sys.mjs +++ b/toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated/RustArithmetic.sys.mjs @@ -431,7 +431,7 @@ export function add(a,b) { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 98, // arithmetic:uniffi_arithmetical_fn_func_add + 99, // arithmetic:uniffi_arithmetical_fn_func_add FfiConverterU64.lower(a), FfiConverterU64.lower(b), ) @@ -469,7 +469,7 @@ export function div(dividend,divisor) { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 99, // arithmetic:uniffi_arithmetical_fn_func_div + 100, // arithmetic:uniffi_arithmetical_fn_func_div FfiConverterU64.lower(dividend), FfiConverterU64.lower(divisor), ) @@ -507,7 +507,7 @@ export function equal(a,b) { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 100, // arithmetic:uniffi_arithmetical_fn_func_equal + 101, // arithmetic:uniffi_arithmetical_fn_func_equal FfiConverterU64.lower(a), FfiConverterU64.lower(b), ) @@ -545,7 +545,7 @@ export function sub(a,b) { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 101, // arithmetic:uniffi_arithmetical_fn_func_sub + 102, // arithmetic:uniffi_arithmetical_fn_func_sub FfiConverterU64.lower(a), FfiConverterU64.lower(b), ) diff --git a/toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated/RustCustomTypes.sys.mjs b/toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated/RustCustomTypes.sys.mjs index 04322ea28649..ad07813cbeb1 100644 --- a/toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated/RustCustomTypes.sys.mjs +++ b/toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated/RustCustomTypes.sys.mjs @@ -513,7 +513,7 @@ export function getCustomTypesDemo(demo) { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 102, // custom_types:uniffi_uniffi_custom_types_fn_func_get_custom_types_demo + 103, // custom_types:uniffi_uniffi_custom_types_fn_func_get_custom_types_demo FfiConverterOptionalTypeCustomTypesDemo.lower(demo), ) } diff --git a/toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated/RustExternalTypes.sys.mjs b/toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated/RustExternalTypes.sys.mjs index f9995c783002..fcb5cfaf7341 100644 --- a/toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated/RustExternalTypes.sys.mjs +++ b/toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated/RustExternalTypes.sys.mjs @@ -437,7 +437,7 @@ export function gradient(value) { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 103, // external_types:uniffi_uniffi_fixture_external_types_fn_func_gradient + 104, // external_types:uniffi_uniffi_fixture_external_types_fn_func_gradient FfiConverterOptionalTypeLine.lower(value), ) } @@ -474,7 +474,7 @@ export function intersection(ln1,ln2) { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 104, // external_types:uniffi_uniffi_fixture_external_types_fn_func_intersection + 105, // external_types:uniffi_uniffi_fixture_external_types_fn_func_intersection FfiConverterTypeLine.lower(ln1), FfiConverterTypeLine.lower(ln2), ) @@ -503,7 +503,7 @@ export function moveSpriteToOrigin(sprite) { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 105, // external_types:uniffi_uniffi_fixture_external_types_fn_func_move_sprite_to_origin + 106, // external_types:uniffi_uniffi_fixture_external_types_fn_func_move_sprite_to_origin FfiConverterTypeSprite.lower(sprite), ) } diff --git a/toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated/RustFixtureCallbacks.sys.mjs b/toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated/RustFixtureCallbacks.sys.mjs index 9861024d4da8..664f40dcd3fe 100644 --- a/toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated/RustFixtureCallbacks.sys.mjs +++ b/toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated/RustFixtureCallbacks.sys.mjs @@ -737,7 +737,7 @@ export function callLogRepeat(logger,message,count,exclude) { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 106, // fixture_callbacks:uniffi_uniffi_fixture_callbacks_fn_func_call_log_repeat + 107, // fixture_callbacks:uniffi_uniffi_fixture_callbacks_fn_func_call_log_repeat FfiConverterTypeLogger.lower(logger), FfiConverterString.lower(message), FfiConverterU32.lower(count), @@ -776,7 +776,7 @@ export function logEvenNumbers(logger,items) { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 107, // fixture_callbacks:uniffi_uniffi_fixture_callbacks_fn_func_log_even_numbers + 108, // fixture_callbacks:uniffi_uniffi_fixture_callbacks_fn_func_log_even_numbers FfiConverterTypeLogger.lower(logger), FfiConverterSequencei32.lower(items), ) @@ -813,7 +813,7 @@ export function logEvenNumbersMainThread(logger,items) { throw e; } return UniFFIScaffolding.callSync( - 108, // fixture_callbacks:uniffi_uniffi_fixture_callbacks_fn_func_log_even_numbers_main_thread + 109, // fixture_callbacks:uniffi_uniffi_fixture_callbacks_fn_func_log_even_numbers_main_thread FfiConverterTypeLogger.lower(logger), FfiConverterSequencei32.lower(items), ) diff --git a/toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated/RustFutures.sys.mjs b/toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated/RustFutures.sys.mjs index acc28f2fa202..ec1735135b63 100644 --- a/toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated/RustFutures.sys.mjs +++ b/toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated/RustFutures.sys.mjs @@ -662,7 +662,7 @@ export class FutureTester { const liftError = null; const functionCall = () => { return UniFFIScaffolding.callSync( - 129, // futures:uniffi_uniffi_fixture_futures_fn_constructor_futuretester_init + 130, // futures:uniffi_uniffi_fixture_futures_fn_constructor_futuretester_init ) } return handleRustResult(functionCall(), liftResult, liftError);} @@ -687,7 +687,7 @@ export class FutureTester { throw e; } return UniFFIScaffolding.callSync( - 126, // futures:uniffi_uniffi_fixture_futures_fn_method_futuretester_complete_futures + 127, // futures:uniffi_uniffi_fixture_futures_fn_method_futuretester_complete_futures FfiConverterTypeFutureTester.lower(this), FfiConverterU8.lower(value), ) @@ -704,7 +704,7 @@ export class FutureTester { const liftError = null; const functionCall = () => { return UniFFIScaffolding.callAsync( - 127, // futures:uniffi_uniffi_fixture_futures_fn_method_futuretester_make_future + 128, // futures:uniffi_uniffi_fixture_futures_fn_method_futuretester_make_future FfiConverterTypeFutureTester.lower(this), ) } @@ -724,7 +724,7 @@ export class FutureTester { const liftError = null; const functionCall = () => { return UniFFIScaffolding.callSync( - 128, // futures:uniffi_uniffi_fixture_futures_fn_method_futuretester_wake_futures + 129, // futures:uniffi_uniffi_fixture_futures_fn_method_futuretester_wake_futures FfiConverterTypeFutureTester.lower(this), ) } @@ -787,7 +787,7 @@ export class RustTask { const liftError = null; const functionCall = () => { return UniFFIScaffolding.callSync( - 130, // futures:uniffi_uniffi_fixture_futures_fn_method_rusttask_run + 131, // futures:uniffi_uniffi_fixture_futures_fn_method_rusttask_run FfiConverterTypeRustTask.lower(this), ) } @@ -858,7 +858,7 @@ export class Traveller { throw e; } return UniFFIScaffolding.callSync( - 132, // futures:uniffi_uniffi_fixture_futures_fn_constructor_traveller_new + 133, // futures:uniffi_uniffi_fixture_futures_fn_constructor_traveller_new FfiConverterString.lower(name), ) } @@ -873,7 +873,7 @@ export class Traveller { const liftError = null; const functionCall = () => { return UniFFIScaffolding.callSync( - 131, // futures:uniffi_uniffi_fixture_futures_fn_method_traveller_name + 132, // futures:uniffi_uniffi_fixture_futures_fn_method_traveller_name FfiConverterTypeTraveller.lower(this), ) } @@ -950,7 +950,7 @@ export class WorkerQueue { throw e; } return UniFFIScaffolding.callSync( - 133, // futures:uniffi_uniffi_fixture_futures_fn_method_workerqueue_add_task + 134, // futures:uniffi_uniffi_fixture_futures_fn_method_workerqueue_add_task FfiConverterTypeWorkerQueue.lower(this), FfiConverterTypeRustTask.lower(task), ) @@ -1104,7 +1104,7 @@ export function expensiveComputation() { const liftError = null; const functionCall = () => { return UniFFIScaffolding.callAsync( - 109, // futures:uniffi_uniffi_fixture_futures_fn_func_expensive_computation + 110, // futures:uniffi_uniffi_fixture_futures_fn_func_expensive_computation ) } try { @@ -1127,7 +1127,7 @@ export function initializeGeckoGlobalWorkerQueue() { const liftError = null; const functionCall = () => { return UniFFIScaffolding.callSync( - 110, // futures:uniffi_uniffi_fixture_futures_fn_func_initialize_gecko_global_worker_queue + 111, // futures:uniffi_uniffi_fixture_futures_fn_func_initialize_gecko_global_worker_queue ) } return handleRustResult(functionCall(), liftResult, liftError); @@ -1151,7 +1151,7 @@ export function initializeGlobalWorkerQueue(workerQueue) { throw e; } return UniFFIScaffolding.callSync( - 111, // futures:uniffi_uniffi_fixture_futures_fn_func_initialize_global_worker_queue + 112, // futures:uniffi_uniffi_fixture_futures_fn_func_initialize_global_worker_queue FfiConverterTypeWorkerQueue.lower(workerQueue), ) } @@ -1176,7 +1176,7 @@ export function roundtripF32(v) { throw e; } return UniFFIScaffolding.callAsync( - 112, // futures:uniffi_uniffi_fixture_futures_fn_func_roundtrip_f32 + 113, // futures:uniffi_uniffi_fixture_futures_fn_func_roundtrip_f32 FfiConverterF32.lower(v), ) } @@ -1205,7 +1205,7 @@ export function roundtripF64(v) { throw e; } return UniFFIScaffolding.callAsync( - 113, // futures:uniffi_uniffi_fixture_futures_fn_func_roundtrip_f64 + 114, // futures:uniffi_uniffi_fixture_futures_fn_func_roundtrip_f64 FfiConverterF64.lower(v), ) } @@ -1234,7 +1234,7 @@ export function roundtripI16(v) { throw e; } return UniFFIScaffolding.callAsync( - 114, // futures:uniffi_uniffi_fixture_futures_fn_func_roundtrip_i16 + 115, // futures:uniffi_uniffi_fixture_futures_fn_func_roundtrip_i16 FfiConverterI16.lower(v), ) } @@ -1263,7 +1263,7 @@ export function roundtripI32(v) { throw e; } return UniFFIScaffolding.callAsync( - 115, // futures:uniffi_uniffi_fixture_futures_fn_func_roundtrip_i32 + 116, // futures:uniffi_uniffi_fixture_futures_fn_func_roundtrip_i32 FfiConverterI32.lower(v), ) } @@ -1292,7 +1292,7 @@ export function roundtripI64(v) { throw e; } return UniFFIScaffolding.callAsync( - 116, // futures:uniffi_uniffi_fixture_futures_fn_func_roundtrip_i64 + 117, // futures:uniffi_uniffi_fixture_futures_fn_func_roundtrip_i64 FfiConverterI64.lower(v), ) } @@ -1321,7 +1321,7 @@ export function roundtripI8(v) { throw e; } return UniFFIScaffolding.callAsync( - 117, // futures:uniffi_uniffi_fixture_futures_fn_func_roundtrip_i8 + 118, // futures:uniffi_uniffi_fixture_futures_fn_func_roundtrip_i8 FfiConverterI8.lower(v), ) } @@ -1350,7 +1350,7 @@ export function roundtripMap(v) { throw e; } return UniFFIScaffolding.callAsync( - 118, // futures:uniffi_uniffi_fixture_futures_fn_func_roundtrip_map + 119, // futures:uniffi_uniffi_fixture_futures_fn_func_roundtrip_map FfiConverterMapStringString.lower(v), ) } @@ -1379,7 +1379,7 @@ export function roundtripObj(v) { throw e; } return UniFFIScaffolding.callAsync( - 119, // futures:uniffi_uniffi_fixture_futures_fn_func_roundtrip_obj + 120, // futures:uniffi_uniffi_fixture_futures_fn_func_roundtrip_obj FfiConverterTypeTraveller.lower(v), ) } @@ -1408,7 +1408,7 @@ export function roundtripString(v) { throw e; } return UniFFIScaffolding.callAsync( - 120, // futures:uniffi_uniffi_fixture_futures_fn_func_roundtrip_string + 121, // futures:uniffi_uniffi_fixture_futures_fn_func_roundtrip_string FfiConverterString.lower(v), ) } @@ -1437,7 +1437,7 @@ export function roundtripU16(v) { throw e; } return UniFFIScaffolding.callAsync( - 121, // futures:uniffi_uniffi_fixture_futures_fn_func_roundtrip_u16 + 122, // futures:uniffi_uniffi_fixture_futures_fn_func_roundtrip_u16 FfiConverterU16.lower(v), ) } @@ -1466,7 +1466,7 @@ export function roundtripU32(v) { throw e; } return UniFFIScaffolding.callAsync( - 122, // futures:uniffi_uniffi_fixture_futures_fn_func_roundtrip_u32 + 123, // futures:uniffi_uniffi_fixture_futures_fn_func_roundtrip_u32 FfiConverterU32.lower(v), ) } @@ -1495,7 +1495,7 @@ export function roundtripU64(v) { throw e; } return UniFFIScaffolding.callAsync( - 123, // futures:uniffi_uniffi_fixture_futures_fn_func_roundtrip_u64 + 124, // futures:uniffi_uniffi_fixture_futures_fn_func_roundtrip_u64 FfiConverterU64.lower(v), ) } @@ -1524,7 +1524,7 @@ export function roundtripU8(v) { throw e; } return UniFFIScaffolding.callAsync( - 124, // futures:uniffi_uniffi_fixture_futures_fn_func_roundtrip_u8 + 125, // futures:uniffi_uniffi_fixture_futures_fn_func_roundtrip_u8 FfiConverterU8.lower(v), ) } @@ -1553,7 +1553,7 @@ export function roundtripVec(v) { throw e; } return UniFFIScaffolding.callAsync( - 125, // futures:uniffi_uniffi_fixture_futures_fn_func_roundtrip_vec + 126, // futures:uniffi_uniffi_fixture_futures_fn_func_roundtrip_vec FfiConverterSequenceu32.lower(v), ) } diff --git a/toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated/RustGeometry.sys.mjs b/toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated/RustGeometry.sys.mjs index ef24677d9b2d..3395be0651b4 100644 --- a/toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated/RustGeometry.sys.mjs +++ b/toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated/RustGeometry.sys.mjs @@ -542,7 +542,7 @@ export function gradient(ln) { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 134, // geometry:uniffi_uniffi_geometry_fn_func_gradient + 135, // geometry:uniffi_uniffi_geometry_fn_func_gradient FfiConverterTypeLine.lower(ln), ) } @@ -579,7 +579,7 @@ export function intersection(ln1,ln2) { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 135, // geometry:uniffi_uniffi_geometry_fn_func_intersection + 136, // geometry:uniffi_uniffi_geometry_fn_func_intersection FfiConverterTypeLine.lower(ln1), FfiConverterTypeLine.lower(ln2), ) diff --git a/toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated/RustRefcounts.sys.mjs b/toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated/RustRefcounts.sys.mjs index 5925d4ea0b90..baeb3a8e2c49 100644 --- a/toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated/RustRefcounts.sys.mjs +++ b/toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated/RustRefcounts.sys.mjs @@ -371,7 +371,7 @@ export class SingletonObject { const liftError = null; const functionCall = () => { return UniFFIScaffolding.callSync( - 138, // refcounts:uniffi_uniffi_fixture_refcounts_fn_method_singletonobject_method + 139, // refcounts:uniffi_uniffi_fixture_refcounts_fn_method_singletonobject_method FfiConverterTypeSingletonObject.lower(this), ) } @@ -423,7 +423,7 @@ export function getJsRefcount() { const liftError = null; const functionCall = () => { return UniFFIScaffolding.callSync( - 136, // refcounts:uniffi_uniffi_fixture_refcounts_fn_func_get_js_refcount + 137, // refcounts:uniffi_uniffi_fixture_refcounts_fn_func_get_js_refcount ) } return handleRustResult(functionCall(), liftResult, liftError); @@ -439,7 +439,7 @@ export function getSingleton() { const liftError = null; const functionCall = () => { return UniFFIScaffolding.callSync( - 137, // refcounts:uniffi_uniffi_fixture_refcounts_fn_func_get_singleton + 138, // refcounts:uniffi_uniffi_fixture_refcounts_fn_func_get_singleton ) } return handleRustResult(functionCall(), liftResult, liftError); diff --git a/toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated/RustRondpoint.sys.mjs b/toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated/RustRondpoint.sys.mjs index 1d199def344d..cfd83602fdac 100644 --- a/toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated/RustRondpoint.sys.mjs +++ b/toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated/RustRondpoint.sys.mjs @@ -665,7 +665,7 @@ export class Optionneur { const liftError = null; const functionCall = () => { return UniFFIScaffolding.callAsyncWrapper( - 169, // rondpoint:uniffi_uniffi_rondpoint_fn_constructor_optionneur_new + 170, // rondpoint:uniffi_uniffi_rondpoint_fn_constructor_optionneur_new ) } try { @@ -691,7 +691,7 @@ export class Optionneur { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 144, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_boolean + 145, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_boolean FfiConverterTypeOptionneur.lower(this), FfiConverterBool.lower(value), ) @@ -720,7 +720,7 @@ export class Optionneur { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 145, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_enum + 146, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_enum FfiConverterTypeOptionneur.lower(this), FfiConverterTypeEnumeration.lower(value), ) @@ -749,7 +749,7 @@ export class Optionneur { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 146, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_f32 + 147, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_f32 FfiConverterTypeOptionneur.lower(this), FfiConverterF32.lower(value), ) @@ -778,7 +778,7 @@ export class Optionneur { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 147, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_f64 + 148, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_f64 FfiConverterTypeOptionneur.lower(this), FfiConverterF64.lower(value), ) @@ -807,7 +807,7 @@ export class Optionneur { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 148, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i16_dec + 149, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i16_dec FfiConverterTypeOptionneur.lower(this), FfiConverterI16.lower(value), ) @@ -836,7 +836,7 @@ export class Optionneur { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 149, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i16_hex + 150, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i16_hex FfiConverterTypeOptionneur.lower(this), FfiConverterI16.lower(value), ) @@ -865,7 +865,7 @@ export class Optionneur { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 150, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i32_dec + 151, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i32_dec FfiConverterTypeOptionneur.lower(this), FfiConverterI32.lower(value), ) @@ -894,7 +894,7 @@ export class Optionneur { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 151, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i32_hex + 152, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i32_hex FfiConverterTypeOptionneur.lower(this), FfiConverterI32.lower(value), ) @@ -923,7 +923,7 @@ export class Optionneur { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 152, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i64_dec + 153, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i64_dec FfiConverterTypeOptionneur.lower(this), FfiConverterI64.lower(value), ) @@ -952,7 +952,7 @@ export class Optionneur { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 153, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i64_hex + 154, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i64_hex FfiConverterTypeOptionneur.lower(this), FfiConverterI64.lower(value), ) @@ -981,7 +981,7 @@ export class Optionneur { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 154, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i8_dec + 155, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i8_dec FfiConverterTypeOptionneur.lower(this), FfiConverterI8.lower(value), ) @@ -1010,7 +1010,7 @@ export class Optionneur { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 155, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i8_hex + 156, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_i8_hex FfiConverterTypeOptionneur.lower(this), FfiConverterI8.lower(value), ) @@ -1039,7 +1039,7 @@ export class Optionneur { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 156, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_null + 157, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_null FfiConverterTypeOptionneur.lower(this), FfiConverterOptionalstring.lower(value), ) @@ -1068,7 +1068,7 @@ export class Optionneur { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 157, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_sequence + 158, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_sequence FfiConverterTypeOptionneur.lower(this), FfiConverterSequencestring.lower(value), ) @@ -1097,7 +1097,7 @@ export class Optionneur { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 158, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_string + 159, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_string FfiConverterTypeOptionneur.lower(this), FfiConverterString.lower(value), ) @@ -1126,7 +1126,7 @@ export class Optionneur { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 159, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u16_dec + 160, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u16_dec FfiConverterTypeOptionneur.lower(this), FfiConverterU16.lower(value), ) @@ -1155,7 +1155,7 @@ export class Optionneur { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 160, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u16_hex + 161, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u16_hex FfiConverterTypeOptionneur.lower(this), FfiConverterU16.lower(value), ) @@ -1184,7 +1184,7 @@ export class Optionneur { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 161, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u32_dec + 162, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u32_dec FfiConverterTypeOptionneur.lower(this), FfiConverterU32.lower(value), ) @@ -1213,7 +1213,7 @@ export class Optionneur { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 162, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u32_hex + 163, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u32_hex FfiConverterTypeOptionneur.lower(this), FfiConverterU32.lower(value), ) @@ -1242,7 +1242,7 @@ export class Optionneur { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 163, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u32_oct + 164, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u32_oct FfiConverterTypeOptionneur.lower(this), FfiConverterU32.lower(value), ) @@ -1271,7 +1271,7 @@ export class Optionneur { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 164, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u64_dec + 165, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u64_dec FfiConverterTypeOptionneur.lower(this), FfiConverterU64.lower(value), ) @@ -1300,7 +1300,7 @@ export class Optionneur { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 165, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u64_hex + 166, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u64_hex FfiConverterTypeOptionneur.lower(this), FfiConverterU64.lower(value), ) @@ -1329,7 +1329,7 @@ export class Optionneur { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 166, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u8_dec + 167, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u8_dec FfiConverterTypeOptionneur.lower(this), FfiConverterU8.lower(value), ) @@ -1358,7 +1358,7 @@ export class Optionneur { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 167, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u8_hex + 168, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_u8_hex FfiConverterTypeOptionneur.lower(this), FfiConverterU8.lower(value), ) @@ -1387,7 +1387,7 @@ export class Optionneur { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 168, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_zero + 169, // rondpoint:uniffi_uniffi_rondpoint_fn_method_optionneur_sinon_zero FfiConverterTypeOptionneur.lower(this), FfiConverterOptionali32.lower(value), ) @@ -1455,7 +1455,7 @@ export class Retourneur { const liftError = null; const functionCall = () => { return UniFFIScaffolding.callAsyncWrapper( - 185, // rondpoint:uniffi_uniffi_rondpoint_fn_constructor_retourneur_new + 186, // rondpoint:uniffi_uniffi_rondpoint_fn_constructor_retourneur_new ) } try { @@ -1481,7 +1481,7 @@ export class Retourneur { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 170, // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_boolean + 171, // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_boolean FfiConverterTypeRetourneur.lower(this), FfiConverterBool.lower(value), ) @@ -1510,7 +1510,7 @@ export class Retourneur { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 171, // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_double + 172, // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_double FfiConverterTypeRetourneur.lower(this), FfiConverterF64.lower(value), ) @@ -1539,7 +1539,7 @@ export class Retourneur { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 172, // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_float + 173, // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_float FfiConverterTypeRetourneur.lower(this), FfiConverterF32.lower(value), ) @@ -1568,7 +1568,7 @@ export class Retourneur { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 173, // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_i16 + 174, // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_i16 FfiConverterTypeRetourneur.lower(this), FfiConverterI16.lower(value), ) @@ -1597,7 +1597,7 @@ export class Retourneur { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 174, // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_i32 + 175, // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_i32 FfiConverterTypeRetourneur.lower(this), FfiConverterI32.lower(value), ) @@ -1626,7 +1626,7 @@ export class Retourneur { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 175, // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_i64 + 176, // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_i64 FfiConverterTypeRetourneur.lower(this), FfiConverterI64.lower(value), ) @@ -1655,7 +1655,7 @@ export class Retourneur { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 176, // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_i8 + 177, // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_i8 FfiConverterTypeRetourneur.lower(this), FfiConverterI8.lower(value), ) @@ -1684,7 +1684,7 @@ export class Retourneur { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 177, // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_nombres + 178, // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_nombres FfiConverterTypeRetourneur.lower(this), FfiConverterTypeDictionnaireNombres.lower(value), ) @@ -1713,7 +1713,7 @@ export class Retourneur { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 178, // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_nombres_signes + 179, // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_nombres_signes FfiConverterTypeRetourneur.lower(this), FfiConverterTypeDictionnaireNombresSignes.lower(value), ) @@ -1742,7 +1742,7 @@ export class Retourneur { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 179, // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_optionneur_dictionnaire + 180, // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_optionneur_dictionnaire FfiConverterTypeRetourneur.lower(this), FfiConverterTypeOptionneurDictionnaire.lower(value), ) @@ -1771,7 +1771,7 @@ export class Retourneur { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 180, // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_string + 181, // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_string FfiConverterTypeRetourneur.lower(this), FfiConverterString.lower(value), ) @@ -1800,7 +1800,7 @@ export class Retourneur { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 181, // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_u16 + 182, // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_u16 FfiConverterTypeRetourneur.lower(this), FfiConverterU16.lower(value), ) @@ -1829,7 +1829,7 @@ export class Retourneur { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 182, // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_u32 + 183, // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_u32 FfiConverterTypeRetourneur.lower(this), FfiConverterU32.lower(value), ) @@ -1858,7 +1858,7 @@ export class Retourneur { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 183, // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_u64 + 184, // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_u64 FfiConverterTypeRetourneur.lower(this), FfiConverterU64.lower(value), ) @@ -1887,7 +1887,7 @@ export class Retourneur { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 184, // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_u8 + 185, // rondpoint:uniffi_uniffi_rondpoint_fn_method_retourneur_identique_u8 FfiConverterTypeRetourneur.lower(this), FfiConverterU8.lower(value), ) @@ -1955,7 +1955,7 @@ export class Stringifier { const liftError = null; const functionCall = () => { return UniFFIScaffolding.callAsyncWrapper( - 198, // rondpoint:uniffi_uniffi_rondpoint_fn_constructor_stringifier_new + 199, // rondpoint:uniffi_uniffi_rondpoint_fn_constructor_stringifier_new ) } try { @@ -1981,7 +1981,7 @@ export class Stringifier { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 186, // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_boolean + 187, // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_boolean FfiConverterTypeStringifier.lower(this), FfiConverterBool.lower(value), ) @@ -2010,7 +2010,7 @@ export class Stringifier { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 187, // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_double + 188, // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_double FfiConverterTypeStringifier.lower(this), FfiConverterF64.lower(value), ) @@ -2039,7 +2039,7 @@ export class Stringifier { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 188, // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_float + 189, // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_float FfiConverterTypeStringifier.lower(this), FfiConverterF32.lower(value), ) @@ -2068,7 +2068,7 @@ export class Stringifier { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 189, // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_i16 + 190, // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_i16 FfiConverterTypeStringifier.lower(this), FfiConverterI16.lower(value), ) @@ -2097,7 +2097,7 @@ export class Stringifier { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 190, // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_i32 + 191, // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_i32 FfiConverterTypeStringifier.lower(this), FfiConverterI32.lower(value), ) @@ -2126,7 +2126,7 @@ export class Stringifier { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 191, // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_i64 + 192, // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_i64 FfiConverterTypeStringifier.lower(this), FfiConverterI64.lower(value), ) @@ -2155,7 +2155,7 @@ export class Stringifier { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 192, // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_i8 + 193, // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_i8 FfiConverterTypeStringifier.lower(this), FfiConverterI8.lower(value), ) @@ -2184,7 +2184,7 @@ export class Stringifier { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 193, // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_u16 + 194, // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_u16 FfiConverterTypeStringifier.lower(this), FfiConverterU16.lower(value), ) @@ -2213,7 +2213,7 @@ export class Stringifier { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 194, // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_u32 + 195, // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_u32 FfiConverterTypeStringifier.lower(this), FfiConverterU32.lower(value), ) @@ -2242,7 +2242,7 @@ export class Stringifier { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 195, // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_u64 + 196, // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_u64 FfiConverterTypeStringifier.lower(this), FfiConverterU64.lower(value), ) @@ -2271,7 +2271,7 @@ export class Stringifier { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 196, // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_u8 + 197, // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_to_string_u8 FfiConverterTypeStringifier.lower(this), FfiConverterU8.lower(value), ) @@ -2300,7 +2300,7 @@ export class Stringifier { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 197, // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_well_known_string + 198, // rondpoint:uniffi_uniffi_rondpoint_fn_method_stringifier_well_known_string FfiConverterTypeStringifier.lower(this), FfiConverterString.lower(value), ) @@ -3677,7 +3677,7 @@ export function copieCarte(c) { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 139, // rondpoint:uniffi_uniffi_rondpoint_fn_func_copie_carte + 140, // rondpoint:uniffi_uniffi_rondpoint_fn_func_copie_carte FfiConverterMapStringTypeEnumerationAvecDonnees.lower(c), ) } @@ -3706,7 +3706,7 @@ export function copieDictionnaire(d) { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 140, // rondpoint:uniffi_uniffi_rondpoint_fn_func_copie_dictionnaire + 141, // rondpoint:uniffi_uniffi_rondpoint_fn_func_copie_dictionnaire FfiConverterTypeDictionnaire.lower(d), ) } @@ -3735,7 +3735,7 @@ export function copieEnumeration(e) { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 141, // rondpoint:uniffi_uniffi_rondpoint_fn_func_copie_enumeration + 142, // rondpoint:uniffi_uniffi_rondpoint_fn_func_copie_enumeration FfiConverterTypeEnumeration.lower(e), ) } @@ -3764,7 +3764,7 @@ export function copieEnumerations(e) { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 142, // rondpoint:uniffi_uniffi_rondpoint_fn_func_copie_enumerations + 143, // rondpoint:uniffi_uniffi_rondpoint_fn_func_copie_enumerations FfiConverterSequenceTypeEnumeration.lower(e), ) } @@ -3793,7 +3793,7 @@ export function switcheroo(b) { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 143, // rondpoint:uniffi_uniffi_rondpoint_fn_func_switcheroo + 144, // rondpoint:uniffi_uniffi_rondpoint_fn_func_switcheroo FfiConverterBool.lower(b), ) } diff --git a/toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated/RustSprites.sys.mjs b/toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated/RustSprites.sys.mjs index 97986a27731d..cd33d6cea168 100644 --- a/toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated/RustSprites.sys.mjs +++ b/toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated/RustSprites.sys.mjs @@ -370,7 +370,7 @@ export class Sprite { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 203, // sprites:uniffi_uniffi_sprites_fn_constructor_sprite_new + 204, // sprites:uniffi_uniffi_sprites_fn_constructor_sprite_new FfiConverterOptionalTypePoint.lower(initialPosition), ) } @@ -404,7 +404,7 @@ export class Sprite { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 204, // sprites:uniffi_uniffi_sprites_fn_constructor_sprite_new_relative_to + 205, // sprites:uniffi_uniffi_sprites_fn_constructor_sprite_new_relative_to FfiConverterTypePoint.lower(reference), FfiConverterTypeVector.lower(direction), ) @@ -424,7 +424,7 @@ export class Sprite { const liftError = null; const functionCall = () => { return UniFFIScaffolding.callAsyncWrapper( - 200, // sprites:uniffi_uniffi_sprites_fn_method_sprite_get_position + 201, // sprites:uniffi_uniffi_sprites_fn_method_sprite_get_position FfiConverterTypeSprite.lower(this), ) } @@ -451,7 +451,7 @@ export class Sprite { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 201, // sprites:uniffi_uniffi_sprites_fn_method_sprite_move_by + 202, // sprites:uniffi_uniffi_sprites_fn_method_sprite_move_by FfiConverterTypeSprite.lower(this), FfiConverterTypeVector.lower(direction), ) @@ -479,7 +479,7 @@ export class Sprite { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 202, // sprites:uniffi_uniffi_sprites_fn_method_sprite_move_to + 203, // sprites:uniffi_uniffi_sprites_fn_method_sprite_move_to FfiConverterTypeSprite.lower(this), FfiConverterTypePoint.lower(position), ) @@ -755,7 +755,7 @@ export function translate(p,v) { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 199, // sprites:uniffi_uniffi_sprites_fn_func_translate + 200, // sprites:uniffi_uniffi_sprites_fn_func_translate FfiConverterTypePoint.lower(p), FfiConverterTypeVector.lower(v), ) diff --git a/toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated/RustTodolist.sys.mjs b/toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated/RustTodolist.sys.mjs index 270559fde569..93b68a7e22d3 100644 --- a/toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated/RustTodolist.sys.mjs +++ b/toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated/RustTodolist.sys.mjs @@ -343,7 +343,7 @@ export class TodoList { const liftError = null; const functionCall = () => { return UniFFIScaffolding.callAsyncWrapper( - 219, // todolist:uniffi_uniffi_todolist_fn_constructor_todolist_new + 220, // todolist:uniffi_uniffi_todolist_fn_constructor_todolist_new ) } try { @@ -368,7 +368,7 @@ export class TodoList { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 208, // todolist:uniffi_uniffi_todolist_fn_method_todolist_add_entries + 209, // todolist:uniffi_uniffi_todolist_fn_method_todolist_add_entries FfiConverterTypeTodoList.lower(this), FfiConverterSequenceTypeTodoEntry.lower(entries), ) @@ -396,7 +396,7 @@ export class TodoList { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 209, // todolist:uniffi_uniffi_todolist_fn_method_todolist_add_entry + 210, // todolist:uniffi_uniffi_todolist_fn_method_todolist_add_entry FfiConverterTypeTodoList.lower(this), FfiConverterTypeTodoEntry.lower(entry), ) @@ -424,7 +424,7 @@ export class TodoList { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 210, // todolist:uniffi_uniffi_todolist_fn_method_todolist_add_item + 211, // todolist:uniffi_uniffi_todolist_fn_method_todolist_add_item FfiConverterTypeTodoList.lower(this), FfiConverterString.lower(todo), ) @@ -452,7 +452,7 @@ export class TodoList { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 211, // todolist:uniffi_uniffi_todolist_fn_method_todolist_add_items + 212, // todolist:uniffi_uniffi_todolist_fn_method_todolist_add_items FfiConverterTypeTodoList.lower(this), FfiConverterSequencestring.lower(items), ) @@ -480,7 +480,7 @@ export class TodoList { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 212, // todolist:uniffi_uniffi_todolist_fn_method_todolist_clear_item + 213, // todolist:uniffi_uniffi_todolist_fn_method_todolist_clear_item FfiConverterTypeTodoList.lower(this), FfiConverterString.lower(todo), ) @@ -501,7 +501,7 @@ export class TodoList { const liftError = null; const functionCall = () => { return UniFFIScaffolding.callAsyncWrapper( - 213, // todolist:uniffi_uniffi_todolist_fn_method_todolist_get_entries + 214, // todolist:uniffi_uniffi_todolist_fn_method_todolist_get_entries FfiConverterTypeTodoList.lower(this), ) } @@ -521,7 +521,7 @@ export class TodoList { const liftError = (data) => FfiConverterTypeTodoError.lift(data); const functionCall = () => { return UniFFIScaffolding.callAsyncWrapper( - 214, // todolist:uniffi_uniffi_todolist_fn_method_todolist_get_first + 215, // todolist:uniffi_uniffi_todolist_fn_method_todolist_get_first FfiConverterTypeTodoList.lower(this), ) } @@ -541,7 +541,7 @@ export class TodoList { const liftError = null; const functionCall = () => { return UniFFIScaffolding.callAsyncWrapper( - 215, // todolist:uniffi_uniffi_todolist_fn_method_todolist_get_items + 216, // todolist:uniffi_uniffi_todolist_fn_method_todolist_get_items FfiConverterTypeTodoList.lower(this), ) } @@ -561,7 +561,7 @@ export class TodoList { const liftError = (data) => FfiConverterTypeTodoError.lift(data); const functionCall = () => { return UniFFIScaffolding.callAsyncWrapper( - 216, // todolist:uniffi_uniffi_todolist_fn_method_todolist_get_last + 217, // todolist:uniffi_uniffi_todolist_fn_method_todolist_get_last FfiConverterTypeTodoList.lower(this), ) } @@ -581,7 +581,7 @@ export class TodoList { const liftError = (data) => FfiConverterTypeTodoError.lift(data); const functionCall = () => { return UniFFIScaffolding.callAsyncWrapper( - 217, // todolist:uniffi_uniffi_todolist_fn_method_todolist_get_last_entry + 218, // todolist:uniffi_uniffi_todolist_fn_method_todolist_get_last_entry FfiConverterTypeTodoList.lower(this), ) } @@ -600,7 +600,7 @@ export class TodoList { const liftError = null; const functionCall = () => { return UniFFIScaffolding.callAsyncWrapper( - 218, // todolist:uniffi_uniffi_todolist_fn_method_todolist_make_default + 219, // todolist:uniffi_uniffi_todolist_fn_method_todolist_make_default FfiConverterTypeTodoList.lower(this), ) } @@ -992,7 +992,7 @@ export function createEntryWith(todo) { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 205, // todolist:uniffi_uniffi_todolist_fn_func_create_entry_with + 206, // todolist:uniffi_uniffi_todolist_fn_func_create_entry_with FfiConverterString.lower(todo), ) } @@ -1013,7 +1013,7 @@ export function getDefaultList() { const liftError = null; const functionCall = () => { return UniFFIScaffolding.callAsyncWrapper( - 206, // todolist:uniffi_uniffi_todolist_fn_func_get_default_list + 207, // todolist:uniffi_uniffi_todolist_fn_func_get_default_list ) } try { @@ -1040,7 +1040,7 @@ export function setDefaultList(list) { throw e; } return UniFFIScaffolding.callAsyncWrapper( - 207, // todolist:uniffi_uniffi_todolist_fn_func_set_default_list + 208, // todolist:uniffi_uniffi_todolist_fn_func_set_default_list FfiConverterTypeTodoList.lower(list), ) } diff --git a/toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated/RustUniffiTraitInterfaces.sys.mjs b/toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated/RustUniffiTraitInterfaces.sys.mjs index 181b14bd1fdd..a7ece0503d1b 100644 --- a/toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated/RustUniffiTraitInterfaces.sys.mjs +++ b/toolkit/components/uniffi-bindgen-gecko-js/fixtures/generated/RustUniffiTraitInterfaces.sys.mjs @@ -388,7 +388,7 @@ export class Calc { throw e; } return UniFFIScaffolding.callSync( - 222, // uniffi_trait_interfaces:uniffi_uniffi_trait_interfaces_fn_method_calc_add + 223, // uniffi_trait_interfaces:uniffi_uniffi_trait_interfaces_fn_method_calc_add FfiConverterTypeCalc.lower(this), FfiConverterU32.lower(a), FfiConverterU32.lower(b), @@ -442,7 +442,7 @@ export function makeBuggyCalculator() { const liftError = null; const functionCall = () => { return UniFFIScaffolding.callSync( - 220, // uniffi_trait_interfaces:uniffi_uniffi_trait_interfaces_fn_func_make_buggy_calculator + 221, // uniffi_trait_interfaces:uniffi_uniffi_trait_interfaces_fn_func_make_buggy_calculator ) } return handleRustResult(functionCall(), liftResult, liftError); @@ -458,7 +458,7 @@ export function makeCalculator() { const liftError = null; const functionCall = () => { return UniFFIScaffolding.callSync( - 221, // uniffi_trait_interfaces:uniffi_uniffi_trait_interfaces_fn_func_make_calculator + 222, // uniffi_trait_interfaces:uniffi_uniffi_trait_interfaces_fn_func_make_calculator ) } return handleRustResult(functionCall(), liftResult, liftError); diff --git a/toolkit/components/uniffi-js/UniFFIGeneratedScaffolding.cpp b/toolkit/components/uniffi-js/UniFFIGeneratedScaffolding.cpp index 82437011183d..6a0b630cbb26 100644 --- a/toolkit/components/uniffi-js/UniFFIGeneratedScaffolding.cpp +++ b/toolkit/components/uniffi-js/UniFFIGeneratedScaffolding.cpp @@ -269,6 +269,7 @@ extern "C" { RustBuffer uniffi_remote_settings_fn_method_remotesettingsclient_get_attachment(void*, RustBuffer, RustCallStatus*); RustBuffer uniffi_remote_settings_fn_method_remotesettingsclient_get_records(void*, int8_t, RustCallStatus*); RustBuffer uniffi_remote_settings_fn_method_remotesettingsclient_get_records_map(void*, int8_t, RustCallStatus*); + void uniffi_remote_settings_fn_method_remotesettingsclient_sync(void*, RustCallStatus*); void* uniffi_remote_settings_fn_clone_remotesettingsservice(void*, RustCallStatus*); void uniffi_remote_settings_fn_free_remotesettingsservice(void*, RustCallStatus*); void* uniffi_remote_settings_fn_constructor_remotesettingsservice_new(RustBuffer, RustBuffer, RustCallStatus*); @@ -338,6 +339,7 @@ extern "C" { uint16_t uniffi_remote_settings_checksum_method_remotesettingsclient_get_attachment(); uint16_t uniffi_remote_settings_checksum_method_remotesettingsclient_get_records(); uint16_t uniffi_remote_settings_checksum_method_remotesettingsclient_get_records_map(); + uint16_t uniffi_remote_settings_checksum_method_remotesettingsclient_sync(); uint16_t uniffi_remote_settings_checksum_method_remotesettingsservice_make_client(); uint16_t uniffi_remote_settings_checksum_method_remotesettingsservice_sync(); uint16_t uniffi_remote_settings_checksum_method_remotesettingsservice_update_config(); @@ -417,7 +419,7 @@ extern "C" { uint32_t ffi_search_uniffi_contract_version(); void* uniffi_suggest_fn_clone_suggeststore(void*, RustCallStatus*); void uniffi_suggest_fn_free_suggeststore(void*, RustCallStatus*); - void* uniffi_suggest_fn_constructor_suggeststore_new(RustBuffer, RustBuffer, RustCallStatus*); + void* uniffi_suggest_fn_constructor_suggeststore_new(RustBuffer, void*, RustCallStatus*); void uniffi_suggest_fn_method_suggeststore_clear(void*, RustCallStatus*); void uniffi_suggest_fn_method_suggeststore_clear_dismissed_suggestions(void*, RustCallStatus*); void uniffi_suggest_fn_method_suggeststore_dismiss_suggestion(void*, RustBuffer, RustCallStatus*); @@ -2999,6 +3001,31 @@ public: ); } }; +class ScaffoldingCallHandlerUniffiRemoteSettingsFnMethodRemotesettingsclientSync : public UniffiSyncCallHandler { +private: + // PrepareRustArgs stores the resulting arguments in these fields + typename ScaffoldingObjectConverter<&kRemoteSettingsRemoteSettingsClientPointerType>::IntermediateType mPtr; + + // MakeRustCall stores the result of the call in these fields + +public: + void PrepareRustArgs(const dom::Sequence& aArgs, ErrorResult& aError) override { + ScaffoldingObjectConverter<&kRemoteSettingsRemoteSettingsClientPointerType>::FromJs(aArgs[0], &mPtr, aError); + if (aError.Failed()) { + return; + } + } + + void MakeRustCall(RustCallStatus* aOutStatus) override { + uniffi_remote_settings_fn_method_remotesettingsclient_sync( + ScaffoldingObjectConverter<&kRemoteSettingsRemoteSettingsClientPointerType>::IntoRust(std::move(mPtr)), + aOutStatus + ); + } + + virtual void ExtractSuccessfulCallResult(JSContext* aCx, dom::Optional& aDest, ErrorResult& aError) override { + } +}; class ScaffoldingCallHandlerUniffiRemoteSettingsFnMethodRemotesettingsserviceMakeClient : public UniffiSyncCallHandler { private: // PrepareRustArgs stores the resulting arguments in these fields @@ -3744,7 +3771,7 @@ class ScaffoldingCallHandlerUniffiSuggestFnConstructorSuggeststoreNew : public U private: // PrepareRustArgs stores the resulting arguments in these fields typename ScaffoldingConverter::IntermediateType mPath; - typename ScaffoldingConverter::IntermediateType mSettingsConfig; + typename ScaffoldingObjectConverter<&kRemoteSettingsRemoteSettingsServicePointerType>::IntermediateType mRemoteSettingsService; // MakeRustCall stores the result of the call in these fields typename ScaffoldingObjectConverter<&kSuggestSuggestStorePointerType>::IntermediateType mUniffiReturnValue; @@ -3755,7 +3782,7 @@ public: if (aError.Failed()) { return; } - ScaffoldingConverter::FromJs(aArgs[1], &mSettingsConfig, aError); + ScaffoldingObjectConverter<&kRemoteSettingsRemoteSettingsServicePointerType>::FromJs(aArgs[1], &mRemoteSettingsService, aError); if (aError.Failed()) { return; } @@ -3765,7 +3792,7 @@ public: mUniffiReturnValue = ScaffoldingObjectConverter<&kSuggestSuggestStorePointerType>::FromRust( uniffi_suggest_fn_constructor_suggeststore_new( ScaffoldingConverter::IntoRust(std::move(mPath)), - ScaffoldingConverter::IntoRust(std::move(mSettingsConfig)), + ScaffoldingObjectConverter<&kRemoteSettingsRemoteSettingsServicePointerType>::IntoRust(std::move(mRemoteSettingsService)), aOutStatus ) ); @@ -10300,563 +10327,566 @@ UniquePtr GetSyncCallHandler(uint64_t aId) { return MakeUnique(); } case 21: { - return MakeUnique(); + return MakeUnique(); } case 22: { - return MakeUnique(); + return MakeUnique(); } case 23: { - return MakeUnique(); + return MakeUnique(); } case 24: { - return MakeUnique(); + return MakeUnique(); } case 25: { - return MakeUnique(); + return MakeUnique(); } case 26: { - return MakeUnique(); + return MakeUnique(); } case 27: { - return MakeUnique(); + return MakeUnique(); } case 28: { - return MakeUnique(); + return MakeUnique(); } case 29: { - return MakeUnique(); + return MakeUnique(); } case 30: { - return MakeUnique(); + return MakeUnique(); } case 31: { - return MakeUnique(); + return MakeUnique(); } case 32: { - return MakeUnique(); + return MakeUnique(); } case 33: { - return MakeUnique(); + return MakeUnique(); } case 34: { - return MakeUnique(); + return MakeUnique(); } case 35: { - return MakeUnique(); + return MakeUnique(); } case 36: { - return MakeUnique(); + return MakeUnique(); } case 37: { - return MakeUnique(); + return MakeUnique(); } case 38: { - return MakeUnique(); + return MakeUnique(); } case 39: { - return MakeUnique(); + return MakeUnique(); } case 40: { - return MakeUnique(); + return MakeUnique(); } case 41: { - return MakeUnique(); + return MakeUnique(); } case 42: { - return MakeUnique(); + return MakeUnique(); } case 43: { - return MakeUnique(); + return MakeUnique(); } case 44: { - return MakeUnique(); + return MakeUnique(); } case 45: { - return MakeUnique(); + return MakeUnique(); } case 46: { - return MakeUnique(); + return MakeUnique(); } case 47: { - return MakeUnique(); + return MakeUnique(); } case 48: { - return MakeUnique(); + return MakeUnique(); } case 49: { - return MakeUnique(); + return MakeUnique(); } case 50: { - return MakeUnique(); + return MakeUnique(); } case 51: { - return MakeUnique(); + return MakeUnique(); } case 52: { - return MakeUnique(); + return MakeUnique(); } case 53: { - return MakeUnique(); + return MakeUnique(); } case 54: { - return MakeUnique(); + return MakeUnique(); } case 55: { - return MakeUnique(); + return MakeUnique(); } case 56: { - return MakeUnique(); + return MakeUnique(); } case 57: { - return MakeUnique(); + return MakeUnique(); } case 58: { - return MakeUnique(); + return MakeUnique(); } case 59: { - return MakeUnique(); + return MakeUnique(); } case 60: { - return MakeUnique(); + return MakeUnique(); } case 61: { - return MakeUnique(); + return MakeUnique(); } case 62: { - return MakeUnique(); + return MakeUnique(); } case 63: { - return MakeUnique(); + return MakeUnique(); } case 64: { - return MakeUnique(); + return MakeUnique(); } case 65: { - return MakeUnique(); + return MakeUnique(); } case 66: { - return MakeUnique(); + return MakeUnique(); } case 67: { - return MakeUnique(); + return MakeUnique(); } case 68: { - return MakeUnique(); + return MakeUnique(); } case 69: { - return MakeUnique(); + return MakeUnique(); } case 70: { - return MakeUnique(); + return MakeUnique(); } case 71: { - return MakeUnique(); + return MakeUnique(); } case 72: { - return MakeUnique(); + return MakeUnique(); } case 73: { - return MakeUnique(); + return MakeUnique(); } case 74: { - return MakeUnique(); + return MakeUnique(); } case 75: { - return MakeUnique(); + return MakeUnique(); } case 76: { - return MakeUnique(); + return MakeUnique(); } case 77: { - return MakeUnique(); + return MakeUnique(); } case 78: { - return MakeUnique(); + return MakeUnique(); } case 79: { - return MakeUnique(); + return MakeUnique(); } case 80: { - return MakeUnique(); + return MakeUnique(); } case 81: { - return MakeUnique(); + return MakeUnique(); } case 82: { - return MakeUnique(); + return MakeUnique(); } case 83: { - return MakeUnique(); + return MakeUnique(); } case 84: { - return MakeUnique(); + return MakeUnique(); } case 85: { - return MakeUnique(); + return MakeUnique(); } case 86: { - return MakeUnique(); + return MakeUnique(); } case 87: { - return MakeUnique(); + return MakeUnique(); } case 88: { - return MakeUnique(); + return MakeUnique(); } case 89: { - return MakeUnique(); + return MakeUnique(); } case 90: { - return MakeUnique(); + return MakeUnique(); } case 91: { - return MakeUnique(); + return MakeUnique(); } case 92: { - return MakeUnique(); + return MakeUnique(); } case 93: { - return MakeUnique(); + return MakeUnique(); } case 94: { - return MakeUnique(); + return MakeUnique(); } case 95: { - return MakeUnique(); + return MakeUnique(); } case 96: { - return MakeUnique(); + return MakeUnique(); } case 97: { + return MakeUnique(); + } + case 98: { return MakeUnique(); } #ifdef MOZ_UNIFFI_FIXTURES - case 98: { + case 99: { return MakeUnique(); } - case 99: { + case 100: { return MakeUnique(); } - case 100: { + case 101: { return MakeUnique(); } - case 101: { + case 102: { return MakeUnique(); } - case 102: { + case 103: { return MakeUnique(); } - case 103: { + case 104: { return MakeUnique(); } - case 104: { + case 105: { return MakeUnique(); } - case 105: { + case 106: { return MakeUnique(); } - case 106: { + case 107: { return MakeUnique(); } - case 107: { + case 108: { return MakeUnique(); } - case 108: { + case 109: { return MakeUnique(); } - case 110: { + case 111: { return MakeUnique(); } - case 111: { + case 112: { return MakeUnique(); } - case 126: { + case 127: { return MakeUnique(); } - case 128: { + case 129: { return MakeUnique(); } - case 129: { + case 130: { return MakeUnique(); } - case 130: { + case 131: { return MakeUnique(); } - case 131: { + case 132: { return MakeUnique(); } - case 132: { + case 133: { return MakeUnique(); } - case 133: { + case 134: { return MakeUnique(); } - case 134: { + case 135: { return MakeUnique(); } - case 135: { + case 136: { return MakeUnique(); } - case 136: { + case 137: { return MakeUnique(); } - case 137: { + case 138: { return MakeUnique(); } - case 138: { + case 139: { return MakeUnique(); } - case 139: { + case 140: { return MakeUnique(); } - case 140: { + case 141: { return MakeUnique(); } - case 141: { + case 142: { return MakeUnique(); } - case 142: { + case 143: { return MakeUnique(); } - case 143: { + case 144: { return MakeUnique(); } - case 144: { + case 145: { return MakeUnique(); } - case 145: { + case 146: { return MakeUnique(); } - case 146: { + case 147: { return MakeUnique(); } - case 147: { + case 148: { return MakeUnique(); } - case 148: { + case 149: { return MakeUnique(); } - case 149: { + case 150: { return MakeUnique(); } - case 150: { + case 151: { return MakeUnique(); } - case 151: { + case 152: { return MakeUnique(); } - case 152: { + case 153: { return MakeUnique(); } - case 153: { + case 154: { return MakeUnique(); } - case 154: { + case 155: { return MakeUnique(); } - case 155: { + case 156: { return MakeUnique(); } - case 156: { + case 157: { return MakeUnique(); } - case 157: { + case 158: { return MakeUnique(); } - case 158: { + case 159: { return MakeUnique(); } - case 159: { + case 160: { return MakeUnique(); } - case 160: { + case 161: { return MakeUnique(); } - case 161: { + case 162: { return MakeUnique(); } - case 162: { + case 163: { return MakeUnique(); } - case 163: { + case 164: { return MakeUnique(); } - case 164: { + case 165: { return MakeUnique(); } - case 165: { + case 166: { return MakeUnique(); } - case 166: { + case 167: { return MakeUnique(); } - case 167: { + case 168: { return MakeUnique(); } - case 168: { + case 169: { return MakeUnique(); } - case 169: { + case 170: { return MakeUnique(); } - case 170: { + case 171: { return MakeUnique(); } - case 171: { + case 172: { return MakeUnique(); } - case 172: { + case 173: { return MakeUnique(); } - case 173: { + case 174: { return MakeUnique(); } - case 174: { + case 175: { return MakeUnique(); } - case 175: { + case 176: { return MakeUnique(); } - case 176: { + case 177: { return MakeUnique(); } - case 177: { + case 178: { return MakeUnique(); } - case 178: { + case 179: { return MakeUnique(); } - case 179: { + case 180: { return MakeUnique(); } - case 180: { + case 181: { return MakeUnique(); } - case 181: { + case 182: { return MakeUnique(); } - case 182: { + case 183: { return MakeUnique(); } - case 183: { + case 184: { return MakeUnique(); } - case 184: { + case 185: { return MakeUnique(); } - case 185: { + case 186: { return MakeUnique(); } - case 186: { + case 187: { return MakeUnique(); } - case 187: { + case 188: { return MakeUnique(); } - case 188: { + case 189: { return MakeUnique(); } - case 189: { + case 190: { return MakeUnique(); } - case 190: { + case 191: { return MakeUnique(); } - case 191: { + case 192: { return MakeUnique(); } - case 192: { + case 193: { return MakeUnique(); } - case 193: { + case 194: { return MakeUnique(); } - case 194: { + case 195: { return MakeUnique(); } - case 195: { + case 196: { return MakeUnique(); } - case 196: { + case 197: { return MakeUnique(); } - case 197: { + case 198: { return MakeUnique(); } - case 198: { + case 199: { return MakeUnique(); } - case 199: { + case 200: { return MakeUnique(); } - case 200: { + case 201: { return MakeUnique(); } - case 201: { + case 202: { return MakeUnique(); } - case 202: { + case 203: { return MakeUnique(); } - case 203: { + case 204: { return MakeUnique(); } - case 204: { + case 205: { return MakeUnique(); } - case 205: { + case 206: { return MakeUnique(); } - case 206: { + case 207: { return MakeUnique(); } - case 207: { + case 208: { return MakeUnique(); } - case 208: { + case 209: { return MakeUnique(); } - case 209: { + case 210: { return MakeUnique(); } - case 210: { + case 211: { return MakeUnique(); } - case 211: { + case 212: { return MakeUnique(); } - case 212: { + case 213: { return MakeUnique(); } - case 213: { + case 214: { return MakeUnique(); } - case 214: { + case 215: { return MakeUnique(); } - case 215: { + case 216: { return MakeUnique(); } - case 216: { + case 217: { return MakeUnique(); } - case 217: { + case 218: { return MakeUnique(); } - case 218: { + case 219: { return MakeUnique(); } - case 219: { + case 220: { return MakeUnique(); } - case 220: { + case 221: { return MakeUnique(); } - case 221: { + case 222: { return MakeUnique(); } - case 222: { + case 223: { return MakeUnique(); } #endif /* MOZ_UNIFFI_FIXTURES */ @@ -10871,52 +10901,52 @@ UniquePtr GetAsyncCallHandler(uint64_t aId) { #ifdef MOZ_UNIFFI_FIXTURES - case 109: { + case 110: { return MakeUnique(); } - case 112: { + case 113: { return MakeUnique(); } - case 113: { + case 114: { return MakeUnique(); } - case 114: { + case 115: { return MakeUnique(); } - case 115: { + case 116: { return MakeUnique(); } - case 116: { + case 117: { return MakeUnique(); } - case 117: { + case 118: { return MakeUnique(); } - case 118: { + case 119: { return MakeUnique(); } - case 119: { + case 120: { return MakeUnique(); } - case 120: { + case 121: { return MakeUnique(); } - case 121: { + case 122: { return MakeUnique(); } - case 122: { + case 123: { return MakeUnique(); } - case 123: { + case 124: { return MakeUnique(); } - case 124: { + case 125: { return MakeUnique(); } - case 125: { + case 126: { return MakeUnique(); } - case 127: { + case 128: { return MakeUnique(); } #endif /* MOZ_UNIFFI_FIXTURES */