global: introducing Notesnook Circle (#8779)

* core: add api for getting Notesnook Circle partners

* web: introduce notesnook circle

* core: export CirclePartner type

* mobile: add notesnook-circle

* web: use strings from intl for notesnook circle

* common: add notesnook circle to features

* web: fix local ips set for hosts

* mobile: fix db hosts

---------

Co-authored-by: Ammar Ahmed <ammarahmed6506@gmail.com>
This commit is contained in:
Abdullah Atta
2025-10-17 08:49:32 +05:00
committed by GitHub
parent b27f064ad4
commit 1f748a4026
21 changed files with 715 additions and 186 deletions

View File

@@ -0,0 +1,48 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2023 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import hosts from "../utils/constants.js";
import http from "../utils/http.js";
import Database from "./index.js";
export type CirclePartner = {
id: string;
name: string;
url: string;
logoBase64: string;
shortDescription: string;
longDescription: string;
offerDescription: string;
codeRedeemUrl?: string;
};
export class Circle {
constructor(private readonly db: Database) {}
partners(): Promise<CirclePartner[] | undefined> {
return http.get(`${hosts.SUBSCRIPTIONS_HOST}/circle/partners`);
}
async redeem(partnerId: string): Promise<{ code?: string } | undefined> {
const token = await this.db.tokenManager.getAccessToken();
return http.get(
`${hosts.SUBSCRIPTIONS_HOST}/circle/redeem?partnerId=${partnerId}`,
token
);
}
}

View File

@@ -82,6 +82,7 @@ import { NNMigrationProvider } from "../database/migrations.js";
import { ConfigStorage } from "../database/config.js";
import { LazyPromise } from "../utils/lazy-promise.js";
import { InboxApiKeys } from "./inbox-api-keys.js";
import { Circle } from "./circle.js";
type EventSourceConstructor = new (
uri: string,
@@ -192,6 +193,7 @@ class Database {
tokenManager = new TokenManager(this.kv);
mfa = new MFAManager(this.tokenManager);
subscriptions = new Subscriptions(this);
circle = new Circle(this);
offers = Offers;
debug = new Debug();
pricing = Pricing;

View File

@@ -39,6 +39,7 @@ export * from "./api/debug.js";
export * from "./api/monographs.js";
export * from "./api/subscriptions.js";
export * from "./api/pricing.js";
export * from "./api/circle.js";
export { VAULT_ERRORS } from "./api/vault.js";
export type { SyncOptions } from "./api/sync/index.js";
export { sanitizeTag } from "./collections/tags.js";