omnikey-cli 1.0.23 → 1.0.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,6 +15,7 @@ const logger_1 = require("./logger");
15
15
  const taskInstructionRoutes_1 = require("./taskInstructionRoutes");
16
16
  const config_1 = require("./config");
17
17
  const agentServer_1 = require("./agent/agentServer");
18
+ const appDownload_1 = require("./models/appDownload");
18
19
  const app = (0, express_1.default)();
19
20
  const PORT = Number(config_1.config.port);
20
21
  app.set('trust proxy', 1);
@@ -31,6 +32,14 @@ app.get('/macos/download', (_req, res) => {
31
32
  res.status(404).send('File not found.');
32
33
  return;
33
34
  }
35
+ if (!config_1.config.isSelfHosted) {
36
+ appDownload_1.AppDownload.findOrCreate({
37
+ where: { platform: 'macos' },
38
+ defaults: { platform: 'macos', count: 0 },
39
+ })
40
+ .then(([record]) => record.increment('count'))
41
+ .catch((err) => logger_1.logger.error('Failed to increment macOS download count.', { error: err }));
42
+ }
34
43
  res.set({
35
44
  'Content-Type': 'application/octet-stream',
36
45
  'Content-Disposition': 'attachment; filename="OmniKeyAI.dmg"',
@@ -65,8 +74,8 @@ app.get('/macos/appcast', (req, res) => {
65
74
  const appcastUrl = `${baseUrl}/macos/appcast`;
66
75
  // These should match the values embedded into the macOS app
67
76
  // Info.plist in macOS/build_release_dmg.sh.
68
- const bundleVersion = '18';
69
- const shortVersion = '1.0.17';
77
+ const bundleVersion = '19';
78
+ const shortVersion = '1.0.18';
70
79
  const xml = `<?xml version="1.0" encoding="utf-8"?>
71
80
  <rss version="2.0"
72
81
  xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle"
@@ -94,7 +103,7 @@ app.get('/macos/appcast', (req, res) => {
94
103
  // ── Windows distribution endpoints ───────────────────────────────────────────
95
104
  // These should match the values in windows/OmniKey.Windows.csproj
96
105
  // <Version> and windows/build_release_zip.ps1 $APP_VERSION.
97
- const WIN_VERSION = '1.4';
106
+ const WIN_VERSION = '1.7';
98
107
  const WIN_ZIP_FILENAME = 'OmniKeyAI-windows-win-x64.zip';
99
108
  const WIN_ZIP_PATH = path_1.default.join(process.cwd(), 'windows', WIN_ZIP_FILENAME);
100
109
  // Serves the pre-built ZIP produced by windows/build_release_zip.ps1.
@@ -104,6 +113,14 @@ app.get('/windows/download', (_req, res) => {
104
113
  res.status(404).send('File not found.');
105
114
  return;
106
115
  }
116
+ if (!config_1.config.isSelfHosted) {
117
+ appDownload_1.AppDownload.findOrCreate({
118
+ where: { platform: 'windows' },
119
+ defaults: { platform: 'windows', count: 0 },
120
+ })
121
+ .then(([record]) => record.increment('count'))
122
+ .catch((err) => logger_1.logger.error('Failed to increment Windows download count.', { error: err }));
123
+ }
107
124
  res.set({
108
125
  'Content-Type': 'application/zip',
109
126
  'Content-Disposition': `attachment; filename="${WIN_ZIP_FILENAME}"`,
@@ -138,6 +155,11 @@ app.get('/windows/update', (req, res) => {
138
155
  releaseNotes: '',
139
156
  });
140
157
  });
158
+ app.get('/api/downloads', async (_req, res) => {
159
+ const rows = await appDownload_1.AppDownload.findAll({ where: { platform: ['macos', 'windows'] } });
160
+ const find = (p) => Number(rows.find((r) => r.platform === p)?.count ?? 0);
161
+ res.json({ macos: find('macos'), windows: find('windows') });
162
+ });
141
163
  app.get('/health', (_req, res) => {
142
164
  res.json({ status: 'ok' });
143
165
  });
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.AppDownload = void 0;
7
+ const sequelize_1 = require("sequelize");
8
+ const cuid_1 = __importDefault(require("cuid"));
9
+ const db_1 = require("../db");
10
+ class AppDownload extends sequelize_1.Model {
11
+ }
12
+ exports.AppDownload = AppDownload;
13
+ AppDownload.init({
14
+ id: {
15
+ type: sequelize_1.DataTypes.STRING,
16
+ primaryKey: true,
17
+ allowNull: false,
18
+ defaultValue: () => (0, cuid_1.default)(),
19
+ },
20
+ platform: {
21
+ type: sequelize_1.DataTypes.STRING,
22
+ allowNull: false,
23
+ unique: true,
24
+ },
25
+ count: {
26
+ type: sequelize_1.DataTypes.BIGINT,
27
+ allowNull: false,
28
+ defaultValue: 0,
29
+ },
30
+ }, {
31
+ sequelize: db_1.sequelize,
32
+ tableName: 'app_downloads',
33
+ modelName: 'AppDownload',
34
+ });