diff --git a/apps/mobile/app/screens/settings/settings-data.tsx b/apps/mobile/app/screens/settings/settings-data.tsx
index 47b6d2a7b..4a77ebd4f 100644
--- a/apps/mobile/app/screens/settings/settings-data.tsx
+++ b/apps/mobile/app/screens/settings/settings-data.tsx
@@ -144,21 +144,20 @@ export const settingsGroups: SettingSection[] = [
"dddd, MMMM D, YYYY h:mm A"
);
+ const trialEndDate = dayjs(user?.subscription?.start)
+ .add(
+ user?.subscription?.productId?.includes("monthly") ? 7 : 14,
+ "day"
+ )
+ .format("dddd, MMMM D, YYYY h:mm A");
+
if (
user.subscription?.plan !== SubscriptionPlan.FREE &&
user.subscription?.productId
) {
const status = user.subscription?.status;
return status === SubscriptionStatus.TRIAL
- ? strings.trialEndsOn(
- dayjs(user?.subscription?.start)
- .add(
- user?.subscription?.productId?.includes("monthly")
- ? 7
- : 14
- )
- .format("dddd, MMMM D, YYYY h:mm A")
- )
+ ? strings.trialOnGoing(trialEndDate)
: status === SubscriptionStatus.ACTIVE
? strings.subRenewOn(expiryDate)
: status === SubscriptionStatus.CANCELED ||
diff --git a/packages/intl/locale/en.po b/packages/intl/locale/en.po
index 87de5c852..85cf3d006 100644
--- a/packages/intl/locale/en.po
+++ b/packages/intl/locale/en.po
@@ -7501,6 +7501,10 @@ msgstr "Your free trial has started"
msgid "Your free trial is ending soon"
msgstr "Your free trial is ending soon"
+#: src/strings.ts:2622
+msgid "Your free trial is on-going. Your subscription will start on {trialExpiryDate}"
+msgstr "Your free trial is on-going. Your subscription will start on {trialExpiryDate}"
+
#: src/strings.ts:1778
msgid "Your full name"
msgstr "Your full name"
diff --git a/packages/intl/locale/pseudo-LOCALE.po b/packages/intl/locale/pseudo-LOCALE.po
index afc3aa41b..6f484938f 100644
--- a/packages/intl/locale/pseudo-LOCALE.po
+++ b/packages/intl/locale/pseudo-LOCALE.po
@@ -7444,6 +7444,10 @@ msgstr ""
#: src/strings.ts:1403
msgid "Your free trial is ending soon"
+msgstr "<<<<<<< HEAD"
+
+#: src/strings.ts:2622
+msgid "Your free trial is on-going. Your subscription will start on {trialExpiryDate}"
msgstr ""
#: src/strings.ts:1778
diff --git a/packages/intl/src/strings.ts b/packages/intl/src/strings.ts
index 11d913c27..0826f27ee 100644
--- a/packages/intl/src/strings.ts
+++ b/packages/intl/src/strings.ts
@@ -2617,5 +2617,7 @@ Use this if changes from other devices are not appearing on this device. This wi
lineHeightDesc: () => t`Adjust the line height of the editor`,
enterTitle: () => t`Enter title`,
dayFormat: () => t`Day format`,
- dayFormatDesc: () => t`Choose how day is displayed in the app`
+ dayFormatDesc: () => t`Choose how day is displayed in the app`,
+ trialOnGoing: (trialExpiryDate: string) =>
+ t`Your free trial is on-going. Your subscription will start on ${trialExpiryDate}`
};
diff --git a/servers/themes/package-lock.json b/servers/themes/package-lock.json
index 78d22a6d3..bbbcb20c2 100644
--- a/servers/themes/package-lock.json
+++ b/servers/themes/package-lock.json
@@ -1,19 +1,19 @@
{
"name": "@notesnook/themes-server",
- "version": "1.0.1",
+ "version": "1.0.3",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@notesnook/themes-server",
- "version": "1.0.1",
+ "version": "1.0.3",
"license": "ISC",
"dependencies": {
"@notesnook/theme": "file:../../packages/theme",
"@orama/orama": "^1.0.8",
- "@sagi.io/workers-kv": "^0.0.15",
"@trpc/server": "10.45.2",
"async-mutex": "0.5.0",
+ "cloudflare": "^5.2.0",
"cors": "^2.8.5",
"react": "18.3.1",
"util": "^0.12.5",
@@ -21,7 +21,7 @@
},
"devDependencies": {
"@types/cors": "^2.8.13",
- "esbuild": "^0.21.5",
+ "esbuild": "0.21.5",
"vite-node": "2.1.8"
}
},
@@ -700,12 +700,6 @@
"win32"
]
},
- "node_modules/@sagi.io/workers-kv": {
- "version": "0.0.15",
- "resolved": "https://registry.npmjs.org/@sagi.io/workers-kv/-/workers-kv-0.0.15.tgz",
- "integrity": "sha512-a7TyxTGCkrFmGVn39kdtMqYQFXSvqme50Dffm6nPpNHh3PL+xSd3pRArKn9kRb6qTkUg/xxwaPiE2dmiEtdJEQ==",
- "license": "MIT"
- },
"node_modules/@trpc/server": {
"version": "10.45.2",
"resolved": "https://registry.npmjs.org/@trpc/server/-/server-10.45.2.tgz",
@@ -732,8 +726,41 @@
"node_modules/@types/node": {
"version": "20.4.2",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.4.2.tgz",
- "integrity": "sha512-Dd0BYtWgnWJKwO1jkmTrzofjK2QXXcai0dmtzvIBhcA+RsG5h8R3xlyta0kGOZRNfL9GuRtb1knmPEhQrePCEw==",
- "dev": true
+ "integrity": "sha512-Dd0BYtWgnWJKwO1jkmTrzofjK2QXXcai0dmtzvIBhcA+RsG5h8R3xlyta0kGOZRNfL9GuRtb1knmPEhQrePCEw=="
+ },
+ "node_modules/@types/node-fetch": {
+ "version": "2.6.13",
+ "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.13.tgz",
+ "integrity": "sha512-QGpRVpzSaUs30JBSGPjOg4Uveu384erbHBoT1zeONvyCfwQxIkUshLAOqN/k9EjGviPRmWTTe6aH2qySWKTVSw==",
+ "license": "MIT",
+ "dependencies": {
+ "@types/node": "*",
+ "form-data": "^4.0.4"
+ }
+ },
+ "node_modules/abort-controller": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz",
+ "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==",
+ "license": "MIT",
+ "dependencies": {
+ "event-target-shim": "^5.0.0"
+ },
+ "engines": {
+ "node": ">=6.5"
+ }
+ },
+ "node_modules/agentkeepalive": {
+ "version": "4.6.0",
+ "resolved": "https://registry.npmjs.org/agentkeepalive/-/agentkeepalive-4.6.0.tgz",
+ "integrity": "sha512-kja8j7PjmncONqaTsB8fQ+wE2mSU2DJ9D4XKoJ5PFWIdRMa6SLSN1ff4mOr4jCbfRSsxR4keIiySJU0N9T5hIQ==",
+ "license": "MIT",
+ "dependencies": {
+ "humanize-ms": "^1.2.1"
+ },
+ "engines": {
+ "node": ">= 8.0.0"
+ }
},
"node_modules/async-mutex": {
"version": "0.5.0",
@@ -743,6 +770,12 @@
"tslib": "^2.4.0"
}
},
+ "node_modules/asynckit": {
+ "version": "0.4.0",
+ "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
+ "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==",
+ "license": "MIT"
+ },
"node_modules/available-typed-arrays": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz",
@@ -814,6 +847,42 @@
"url": "https://github.com/sponsors/ljharb"
}
},
+ "node_modules/cloudflare": {
+ "version": "5.2.0",
+ "resolved": "https://registry.npmjs.org/cloudflare/-/cloudflare-5.2.0.tgz",
+ "integrity": "sha512-dVzqDpPFYR9ApEC9e+JJshFJZXcw4HzM8W+3DHzO5oy9+8rLC53G7x6fEf9A7/gSuSCxuvndzui5qJKftfIM9A==",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "@types/node": "^18.11.18",
+ "@types/node-fetch": "^2.6.4",
+ "abort-controller": "^3.0.0",
+ "agentkeepalive": "^4.2.1",
+ "form-data-encoder": "1.7.2",
+ "formdata-node": "^4.3.2",
+ "node-fetch": "^2.6.7"
+ }
+ },
+ "node_modules/cloudflare/node_modules/@types/node": {
+ "version": "18.19.130",
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.130.tgz",
+ "integrity": "sha512-GRaXQx6jGfL8sKfaIDD6OupbIHBr9jv7Jnaml9tB7l4v068PAOXqfcujMMo5PhbIs6ggR1XODELqahT2R8v0fg==",
+ "license": "MIT",
+ "dependencies": {
+ "undici-types": "~5.26.4"
+ }
+ },
+ "node_modules/combined-stream": {
+ "version": "1.0.8",
+ "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
+ "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
+ "license": "MIT",
+ "dependencies": {
+ "delayed-stream": "~1.0.0"
+ },
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
"node_modules/cors": {
"version": "2.8.5",
"resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz",
@@ -860,6 +929,15 @@
"url": "https://github.com/sponsors/ljharb"
}
},
+ "node_modules/delayed-stream": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
+ "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=0.4.0"
+ }
+ },
"node_modules/dunder-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
@@ -910,6 +988,21 @@
"node": ">= 0.4"
}
},
+ "node_modules/es-set-tostringtag": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz",
+ "integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==",
+ "license": "MIT",
+ "dependencies": {
+ "es-errors": "^1.3.0",
+ "get-intrinsic": "^1.2.6",
+ "has-tostringtag": "^1.0.2",
+ "hasown": "^2.0.2"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ }
+ },
"node_modules/esbuild": {
"version": "0.21.5",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.21.5.tgz",
@@ -949,6 +1042,15 @@
"@esbuild/win32-x64": "0.21.5"
}
},
+ "node_modules/event-target-shim": {
+ "version": "5.0.1",
+ "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz",
+ "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=6"
+ }
+ },
"node_modules/for-each": {
"version": "0.3.5",
"resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.5.tgz",
@@ -964,6 +1066,41 @@
"url": "https://github.com/sponsors/ljharb"
}
},
+ "node_modules/form-data": {
+ "version": "4.0.5",
+ "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.5.tgz",
+ "integrity": "sha512-8RipRLol37bNs2bhoV67fiTEvdTrbMUYcFTiy3+wuuOnUog2QBHCZWXDRijWQfAkhBj2Uf5UnVaiWwA5vdd82w==",
+ "license": "MIT",
+ "dependencies": {
+ "asynckit": "^0.4.0",
+ "combined-stream": "^1.0.8",
+ "es-set-tostringtag": "^2.1.0",
+ "hasown": "^2.0.2",
+ "mime-types": "^2.1.12"
+ },
+ "engines": {
+ "node": ">= 6"
+ }
+ },
+ "node_modules/form-data-encoder": {
+ "version": "1.7.2",
+ "resolved": "https://registry.npmjs.org/form-data-encoder/-/form-data-encoder-1.7.2.tgz",
+ "integrity": "sha512-qfqtYan3rxrnCk1VYaA4H+Ms9xdpPqvLZa6xmMgFvhO32x7/3J/ExcTd6qpxM0vH2GdMI+poehyBZvqfMTto8A==",
+ "license": "MIT"
+ },
+ "node_modules/formdata-node": {
+ "version": "4.4.1",
+ "resolved": "https://registry.npmjs.org/formdata-node/-/formdata-node-4.4.1.tgz",
+ "integrity": "sha512-0iirZp3uVDjVGt9p49aTaqjk84TrglENEDuqfdlZQ1roC9CWlPk6Avf8EEnZNcAqPonwkG35x4n3ww/1THYAeQ==",
+ "license": "MIT",
+ "dependencies": {
+ "node-domexception": "1.0.0",
+ "web-streams-polyfill": "4.0.0-beta.3"
+ },
+ "engines": {
+ "node": ">= 12.20"
+ }
+ },
"node_modules/fsevents": {
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
@@ -1087,6 +1224,15 @@
"node": ">= 0.4"
}
},
+ "node_modules/humanize-ms": {
+ "version": "1.2.1",
+ "resolved": "https://registry.npmjs.org/humanize-ms/-/humanize-ms-1.2.1.tgz",
+ "integrity": "sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ==",
+ "license": "MIT",
+ "dependencies": {
+ "ms": "^2.0.0"
+ }
+ },
"node_modules/inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
@@ -1173,11 +1319,31 @@
"node": ">= 0.4"
}
},
+ "node_modules/mime-db": {
+ "version": "1.52.0",
+ "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
+ "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/mime-types": {
+ "version": "2.1.35",
+ "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
+ "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
+ "license": "MIT",
+ "dependencies": {
+ "mime-db": "1.52.0"
+ },
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
"node_modules/ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
- "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
- "dev": true
+ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
},
"node_modules/nanoid": {
"version": "3.3.8",
@@ -1197,6 +1363,46 @@
"node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
}
},
+ "node_modules/node-domexception": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz",
+ "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==",
+ "deprecated": "Use your platform's native DOMException instead",
+ "funding": [
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/jimmywarting"
+ },
+ {
+ "type": "github",
+ "url": "https://paypal.me/jimmywarting"
+ }
+ ],
+ "license": "MIT",
+ "engines": {
+ "node": ">=10.5.0"
+ }
+ },
+ "node_modules/node-fetch": {
+ "version": "2.7.0",
+ "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz",
+ "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==",
+ "license": "MIT",
+ "dependencies": {
+ "whatwg-url": "^5.0.0"
+ },
+ "engines": {
+ "node": "4.x || >=6.0.0"
+ },
+ "peerDependencies": {
+ "encoding": "^0.1.0"
+ },
+ "peerDependenciesMeta": {
+ "encoding": {
+ "optional": true
+ }
+ }
+ },
"node_modules/object-assign": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
@@ -1329,11 +1535,23 @@
"node": ">=0.10.0"
}
},
+ "node_modules/tr46": {
+ "version": "0.0.3",
+ "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
+ "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==",
+ "license": "MIT"
+ },
"node_modules/tslib": {
"version": "2.6.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.0.tgz",
"integrity": "sha512-7At1WUettjcSRHXCyYtTselblcHl9PJFFVKiCAy/bY97+BPZXSQ2wbq0P9s8tK2G7dFQfNnlJnPAiArVBVBsfA=="
},
+ "node_modules/undici-types": {
+ "version": "5.26.5",
+ "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
+ "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==",
+ "license": "MIT"
+ },
"node_modules/util": {
"version": "0.12.5",
"resolved": "https://registry.npmjs.org/util/-/util-0.12.5.tgz",
@@ -1435,6 +1653,31 @@
"url": "https://opencollective.com/vitest"
}
},
+ "node_modules/web-streams-polyfill": {
+ "version": "4.0.0-beta.3",
+ "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-4.0.0-beta.3.tgz",
+ "integrity": "sha512-QW95TCTaHmsYfHDybGMwO5IJIM93I/6vTRk+daHTWFPhwh+C8Cg7j7XyKrwrj8Ib6vYXe0ocYNrmzY4xAAN6ug==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 14"
+ }
+ },
+ "node_modules/webidl-conversions": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
+ "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==",
+ "license": "BSD-2-Clause"
+ },
+ "node_modules/whatwg-url": {
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
+ "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==",
+ "license": "MIT",
+ "dependencies": {
+ "tr46": "~0.0.3",
+ "webidl-conversions": "^3.0.0"
+ }
+ },
"node_modules/which-typed-array": {
"version": "1.1.19",
"resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.19.tgz",
@@ -1780,11 +2023,6 @@
"dev": true,
"optional": true
},
- "@sagi.io/workers-kv": {
- "version": "0.0.15",
- "resolved": "https://registry.npmjs.org/@sagi.io/workers-kv/-/workers-kv-0.0.15.tgz",
- "integrity": "sha512-a7TyxTGCkrFmGVn39kdtMqYQFXSvqme50Dffm6nPpNHh3PL+xSd3pRArKn9kRb6qTkUg/xxwaPiE2dmiEtdJEQ=="
- },
"@trpc/server": {
"version": "10.45.2",
"resolved": "https://registry.npmjs.org/@trpc/server/-/server-10.45.2.tgz",
@@ -1808,8 +2046,32 @@
"@types/node": {
"version": "20.4.2",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.4.2.tgz",
- "integrity": "sha512-Dd0BYtWgnWJKwO1jkmTrzofjK2QXXcai0dmtzvIBhcA+RsG5h8R3xlyta0kGOZRNfL9GuRtb1knmPEhQrePCEw==",
- "dev": true
+ "integrity": "sha512-Dd0BYtWgnWJKwO1jkmTrzofjK2QXXcai0dmtzvIBhcA+RsG5h8R3xlyta0kGOZRNfL9GuRtb1knmPEhQrePCEw=="
+ },
+ "@types/node-fetch": {
+ "version": "2.6.13",
+ "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.13.tgz",
+ "integrity": "sha512-QGpRVpzSaUs30JBSGPjOg4Uveu384erbHBoT1zeONvyCfwQxIkUshLAOqN/k9EjGviPRmWTTe6aH2qySWKTVSw==",
+ "requires": {
+ "@types/node": "*",
+ "form-data": "^4.0.4"
+ }
+ },
+ "abort-controller": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz",
+ "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==",
+ "requires": {
+ "event-target-shim": "^5.0.0"
+ }
+ },
+ "agentkeepalive": {
+ "version": "4.6.0",
+ "resolved": "https://registry.npmjs.org/agentkeepalive/-/agentkeepalive-4.6.0.tgz",
+ "integrity": "sha512-kja8j7PjmncONqaTsB8fQ+wE2mSU2DJ9D4XKoJ5PFWIdRMa6SLSN1ff4mOr4jCbfRSsxR4keIiySJU0N9T5hIQ==",
+ "requires": {
+ "humanize-ms": "^1.2.1"
+ }
},
"async-mutex": {
"version": "0.5.0",
@@ -1819,6 +2081,11 @@
"tslib": "^2.4.0"
}
},
+ "asynckit": {
+ "version": "0.4.0",
+ "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
+ "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
+ },
"available-typed-arrays": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz",
@@ -1862,6 +2129,38 @@
"get-intrinsic": "^1.3.0"
}
},
+ "cloudflare": {
+ "version": "5.2.0",
+ "resolved": "https://registry.npmjs.org/cloudflare/-/cloudflare-5.2.0.tgz",
+ "integrity": "sha512-dVzqDpPFYR9ApEC9e+JJshFJZXcw4HzM8W+3DHzO5oy9+8rLC53G7x6fEf9A7/gSuSCxuvndzui5qJKftfIM9A==",
+ "requires": {
+ "@types/node": "^18.11.18",
+ "@types/node-fetch": "^2.6.4",
+ "abort-controller": "^3.0.0",
+ "agentkeepalive": "^4.2.1",
+ "form-data-encoder": "1.7.2",
+ "formdata-node": "^4.3.2",
+ "node-fetch": "^2.6.7"
+ },
+ "dependencies": {
+ "@types/node": {
+ "version": "18.19.130",
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.130.tgz",
+ "integrity": "sha512-GRaXQx6jGfL8sKfaIDD6OupbIHBr9jv7Jnaml9tB7l4v068PAOXqfcujMMo5PhbIs6ggR1XODELqahT2R8v0fg==",
+ "requires": {
+ "undici-types": "~5.26.4"
+ }
+ }
+ }
+ },
+ "combined-stream": {
+ "version": "1.0.8",
+ "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
+ "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
+ "requires": {
+ "delayed-stream": "~1.0.0"
+ }
+ },
"cors": {
"version": "2.8.5",
"resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz",
@@ -1890,6 +2189,11 @@
"gopd": "^1.0.1"
}
},
+ "delayed-stream": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
+ "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ=="
+ },
"dunder-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
@@ -1924,6 +2228,17 @@
"es-errors": "^1.3.0"
}
},
+ "es-set-tostringtag": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz",
+ "integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==",
+ "requires": {
+ "es-errors": "^1.3.0",
+ "get-intrinsic": "^1.2.6",
+ "has-tostringtag": "^1.0.2",
+ "hasown": "^2.0.2"
+ }
+ },
"esbuild": {
"version": "0.21.5",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.21.5.tgz",
@@ -1955,6 +2270,11 @@
"@esbuild/win32-x64": "0.21.5"
}
},
+ "event-target-shim": {
+ "version": "5.0.1",
+ "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz",
+ "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ=="
+ },
"for-each": {
"version": "0.3.5",
"resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.5.tgz",
@@ -1963,6 +2283,32 @@
"is-callable": "^1.2.7"
}
},
+ "form-data": {
+ "version": "4.0.5",
+ "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.5.tgz",
+ "integrity": "sha512-8RipRLol37bNs2bhoV67fiTEvdTrbMUYcFTiy3+wuuOnUog2QBHCZWXDRijWQfAkhBj2Uf5UnVaiWwA5vdd82w==",
+ "requires": {
+ "asynckit": "^0.4.0",
+ "combined-stream": "^1.0.8",
+ "es-set-tostringtag": "^2.1.0",
+ "hasown": "^2.0.2",
+ "mime-types": "^2.1.12"
+ }
+ },
+ "form-data-encoder": {
+ "version": "1.7.2",
+ "resolved": "https://registry.npmjs.org/form-data-encoder/-/form-data-encoder-1.7.2.tgz",
+ "integrity": "sha512-qfqtYan3rxrnCk1VYaA4H+Ms9xdpPqvLZa6xmMgFvhO32x7/3J/ExcTd6qpxM0vH2GdMI+poehyBZvqfMTto8A=="
+ },
+ "formdata-node": {
+ "version": "4.4.1",
+ "resolved": "https://registry.npmjs.org/formdata-node/-/formdata-node-4.4.1.tgz",
+ "integrity": "sha512-0iirZp3uVDjVGt9p49aTaqjk84TrglENEDuqfdlZQ1roC9CWlPk6Avf8EEnZNcAqPonwkG35x4n3ww/1THYAeQ==",
+ "requires": {
+ "node-domexception": "1.0.0",
+ "web-streams-polyfill": "4.0.0-beta.3"
+ }
+ },
"fsevents": {
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
@@ -2035,6 +2381,14 @@
"function-bind": "^1.1.2"
}
},
+ "humanize-ms": {
+ "version": "1.2.1",
+ "resolved": "https://registry.npmjs.org/humanize-ms/-/humanize-ms-1.2.1.tgz",
+ "integrity": "sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ==",
+ "requires": {
+ "ms": "^2.0.0"
+ }
+ },
"inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
@@ -2088,11 +2442,23 @@
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
"integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g=="
},
+ "mime-db": {
+ "version": "1.52.0",
+ "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
+ "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg=="
+ },
+ "mime-types": {
+ "version": "2.1.35",
+ "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
+ "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
+ "requires": {
+ "mime-db": "1.52.0"
+ }
+ },
"ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
- "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
- "dev": true
+ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
},
"nanoid": {
"version": "3.3.8",
@@ -2100,6 +2466,19 @@
"integrity": "sha512-WNLf5Sd8oZxOm+TzppcYk8gVOgP+l58xNy58D0nbUnOxOWRWvlcCV4kUF7ltmI6PsrLl/BgKEyS4mqsGChFN0w==",
"dev": true
},
+ "node-domexception": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz",
+ "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ=="
+ },
+ "node-fetch": {
+ "version": "2.7.0",
+ "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz",
+ "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==",
+ "requires": {
+ "whatwg-url": "^5.0.0"
+ }
+ },
"object-assign": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
@@ -2189,11 +2568,21 @@
"integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==",
"dev": true
},
+ "tr46": {
+ "version": "0.0.3",
+ "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
+ "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw=="
+ },
"tslib": {
"version": "2.6.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.0.tgz",
"integrity": "sha512-7At1WUettjcSRHXCyYtTselblcHl9PJFFVKiCAy/bY97+BPZXSQ2wbq0P9s8tK2G7dFQfNnlJnPAiArVBVBsfA=="
},
+ "undici-types": {
+ "version": "5.26.5",
+ "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
+ "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA=="
+ },
"util": {
"version": "0.12.5",
"resolved": "https://registry.npmjs.org/util/-/util-0.12.5.tgz",
@@ -2236,6 +2625,25 @@
"vite": "^5.0.0"
}
},
+ "web-streams-polyfill": {
+ "version": "4.0.0-beta.3",
+ "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-4.0.0-beta.3.tgz",
+ "integrity": "sha512-QW95TCTaHmsYfHDybGMwO5IJIM93I/6vTRk+daHTWFPhwh+C8Cg7j7XyKrwrj8Ib6vYXe0ocYNrmzY4xAAN6ug=="
+ },
+ "webidl-conversions": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
+ "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ=="
+ },
+ "whatwg-url": {
+ "version": "5.0.0",
+ "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
+ "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==",
+ "requires": {
+ "tr46": "~0.0.3",
+ "webidl-conversions": "^3.0.0"
+ }
+ },
"which-typed-array": {
"version": "1.1.19",
"resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.19.tgz",
diff --git a/servers/themes/package.json b/servers/themes/package.json
index 10c576ca9..9efadb5e2 100644
--- a/servers/themes/package.json
+++ b/servers/themes/package.json
@@ -1,6 +1,6 @@
{
"name": "@notesnook/themes-server",
- "version": "1.0.1",
+ "version": "1.0.3",
"description": "A simple rest api for notesnook themes",
"private": "true",
"main": "src/index.ts",
@@ -13,9 +13,9 @@
"dependencies": {
"@notesnook/theme": "file:../../packages/theme",
"@orama/orama": "^1.0.8",
- "@sagi.io/workers-kv": "^0.0.15",
"@trpc/server": "10.45.2",
"async-mutex": "0.5.0",
+ "cloudflare": "^5.2.0",
"cors": "^2.8.5",
"react": "18.3.1",
"util": "^0.12.5",
diff --git a/servers/themes/src/api.ts b/servers/themes/src/api.ts
index bd64fcc5b..3fb03f8ea 100644
--- a/servers/themes/src/api.ts
+++ b/servers/themes/src/api.ts
@@ -19,7 +19,7 @@ along with this program. If not, see .
import { z } from "zod";
import { InstallsCounter } from "./constants";
-import { findTheme, getThemes } from "./orama";
+import { findTheme, getThemes, updateTotalInstalls } from "./orama";
import { syncThemes } from "./sync";
import { publicProcedure, router } from "./trpc";
import { THEME_COMPATIBILITY_VERSION } from "@notesnook/theme";
@@ -41,7 +41,12 @@ export const ThemesAPI = router({
const theme = await findTheme(id, compatibilityVersion);
if (!theme) return;
- if (userId) await InstallsCounter.increment(theme.id, userId);
+ if (userId) {
+ updateTotalInstalls(
+ theme,
+ await InstallsCounter.increment(theme.id, userId)
+ );
+ }
return theme;
}),
updateTheme: publicProcedure
diff --git a/servers/themes/src/counter/fs.ts b/servers/themes/src/counter/fs.ts
index 16e5c4511..e06ab0e0a 100644
--- a/servers/themes/src/counter/fs.ts
+++ b/servers/themes/src/counter/fs.ts
@@ -30,12 +30,13 @@ export class FsCounter {
}
async increment(key: string, uid: string) {
- await this.mutex.runExclusive(async () => {
+ return await this.mutex.runExclusive(async () => {
const counts = await this.all();
counts[key] = counts[key] || [];
- if (counts[key].includes(uid)) return;
+ if (counts[key].includes(uid)) return counts[key].length;
counts[key].push(uid);
await this.save(counts);
+ return counts[key].length;
});
}
@@ -43,10 +44,13 @@ export class FsCounter {
await writeFile(this.path, JSON.stringify(counts));
}
- counts(key: string): Promise {
- return this.all().then((counts) => {
- return (counts[key] || []).length;
- });
+ async counts(keys: string[]): Promise> {
+ const all = await this.all();
+ const result: Record = {};
+ for (const key of keys) {
+ result[key] = (all[key] || []).length;
+ }
+ return result;
}
private async all(): Promise {
diff --git a/servers/themes/src/counter/kv.ts b/servers/themes/src/counter/kv.ts
index f17e0ee70..378ecf37e 100644
--- a/servers/themes/src/counter/kv.ts
+++ b/servers/themes/src/counter/kv.ts
@@ -18,59 +18,76 @@ along with this program. If not, see .
*/
import { Mutex } from "async-mutex";
-import WorkersKVREST from "@sagi.io/workers-kv";
+import { Cloudflare } from "cloudflare";
+type WorkersKVRESTConfig = {
+ cfAccountId: string;
+ cfAuthToken: string;
+ namespaceId: string;
+};
export class KVCounter {
- private readonly kv: WorkersKVREST;
+ private readonly client: Cloudflare;
private readonly mutex: Mutex;
- constructor(config: {
- cfAccountId: string;
- cfAuthToken: string;
- namespaceId: string;
- }) {
+ private installs: Record = {};
+ constructor(private readonly config: WorkersKVRESTConfig) {
this.mutex = new Mutex();
- this.kv = new WorkersKVREST(config);
+ this.client = new Cloudflare({
+ apiToken: this.config.cfAuthToken
+ });
}
async increment(key: string, uid: string) {
- await this.mutex.runExclusive(async () => {
- const existing = await read(this.kv, key, []);
- await write(this.kv, key, Array.from(new Set([...existing, uid])));
+ return await this.mutex.runExclusive(async () => {
+ const existing = this.installs[key] || [];
+ const installsSet = Array.from(new Set([...existing, uid]));
+ await write(this.client, this.config, key, installsSet);
+ this.installs[key] = installsSet;
+ return installsSet.length;
});
}
- async counts(key: string): Promise {
- const installs = await read(this.kv, key, []);
- return installs.length;
- }
-}
-
-async function read(
- kv: WorkersKVREST,
- key: string,
- fallback: T
-): Promise {
- try {
- const response = await kv.readKey({
- key
- });
- if (typeof response === "object" && !response.success) {
- // console.error("failed:", response.errors);
- return fallback;
+ async counts(keys: string[]): Promise> {
+ const result: Record = {};
+ const installs = await readMulti(this.client, this.config, keys);
+ for (const [key, value] of Object.entries(installs)) {
+ result[key] = value.length;
}
- return (
- JSON.parse(typeof response === "string" ? response : response.result) ||
- fallback
- );
- } catch (e) {
- // console.error(e);
- return fallback;
+ this.installs = installs;
+ return result;
}
}
-async function write(kv: WorkersKVREST, key: string, data: T) {
- await kv.writeKey({
- key,
+async function readMulti(
+ client: Cloudflare,
+ config: WorkersKVRESTConfig,
+ keys: string[]
+): Promise> {
+ try {
+ const response = await client.kv.namespaces.bulkGet(config.namespaceId, {
+ account_id: config.cfAccountId,
+ keys,
+ type: "json",
+ withMetadata: false
+ });
+ const result: Record = {};
+ for (const [key, value] of Object.entries(response?.values || {})) {
+ result[key] = value;
+ }
+ return result;
+ } catch (e) {
+ console.error(e);
+ return {};
+ }
+}
+
+function write(
+ client: Cloudflare,
+ config: WorkersKVRESTConfig,
+ key: string,
+ data: T
+) {
+ return client.kv.namespaces.values.update(config.namespaceId, key, {
+ account_id: config.cfAccountId,
value: JSON.stringify(data)
});
}
diff --git a/servers/themes/src/orama.ts b/servers/themes/src/orama.ts
index 8785042b7..8f970c97f 100644
--- a/servers/themes/src/orama.ts
+++ b/servers/themes/src/orama.ts
@@ -16,10 +16,9 @@ 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 .
*/
-import { Orama, SearchParams, create, search } from "@orama/orama";
+import { Orama, SearchParams, create, search, update } from "@orama/orama";
import { CompiledThemeDefinition, ThemeMetadata } from "./sync";
import { ThemeQuerySchema } from "./schemas";
-import { InstallsCounter } from "./constants";
export let ThemesDatabase: Orama | null = null;
export async function initializeDatabase(): Promise {
@@ -31,7 +30,8 @@ export async function initializeDatabase(): Promise {
colorScheme: "string",
compatibilityVersion: "number",
description: "string",
- tags: "string[]"
+ tags: "string[]",
+ totalInstalls: "number"
},
id: "notesnook-themes"
});
@@ -54,6 +54,14 @@ export async function findTheme(
return results.hits[0].document as CompiledThemeDefinition;
}
+export async function updateTotalInstalls(
+ theme: CompiledThemeDefinition,
+ totalInstalls: number
+) {
+ if (!ThemesDatabase) await initializeDatabase();
+ await update(ThemesDatabase!, theme.id, { ...theme, totalInstalls });
+}
+
export async function getThemes(query: (typeof ThemeQuerySchema)["_type"]) {
if (!ThemesDatabase) await initializeDatabase();
@@ -61,6 +69,10 @@ export async function getThemes(query: (typeof ThemeQuerySchema)["_type"]) {
const count = query.limit;
const searchParams: SearchParams = {
+ sortBy: {
+ property: "totalInstalls",
+ order: "DESC"
+ },
where: {
compatibilityVersion: {
eq: query.compatibilityVersion
@@ -96,8 +108,7 @@ export async function getThemes(query: (typeof ThemeQuerySchema)["_type"]) {
themes.push({
...theme,
scopes: undefined,
- codeBlockCSS: undefined,
- totalInstalls: await InstallsCounter.counts(theme.id)
+ codeBlockCSS: undefined
} as ThemeMetadata);
}
diff --git a/servers/themes/src/server.ts b/servers/themes/src/server.ts
index d1c0d5dce..63895bfd5 100644
--- a/servers/themes/src/server.ts
+++ b/servers/themes/src/server.ts
@@ -32,6 +32,9 @@ server.listen(PORT, HOST);
console.log(`Server started successfully on: http://${HOST}:${PORT}/`);
syncThemes();
+setInterval(() => {
+ syncThemes();
+}, 1000 * 60 * 60); // every hour
if (import.meta.hot) {
import.meta.hot.on("vite:beforeFullReload", () => {
diff --git a/servers/themes/src/sync.ts b/servers/themes/src/sync.ts
index 379b90a84..576ae215e 100644
--- a/servers/themes/src/sync.ts
+++ b/servers/themes/src/sync.ts
@@ -20,7 +20,11 @@ import { execSync } from "child_process";
import fs from "node:fs";
import { readdir, readFile } from "fs/promises";
import path from "path";
-import { THEMES_REPO_URL, THEME_REPO_DIR_PATH } from "./constants";
+import {
+ InstallsCounter,
+ THEMES_REPO_URL,
+ THEME_REPO_DIR_PATH
+} from "./constants";
import { insertMultiple } from "@orama/orama";
import { initializeDatabase } from "./orama";
import {
@@ -96,6 +100,12 @@ async function generateThemesMetadata() {
});
}
}
+ const installs = await InstallsCounter.counts(
+ themeDefinitions.map((t) => t.id)
+ );
+ for (const theme of themeDefinitions) {
+ theme.totalInstalls = installs[theme.id] || 0;
+ }
await insertMultiple(db, themeDefinitions);
console.log("Metadata generated and cached.");
}