kaven-cli 0.4.0 → 0.5.0

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.
Files changed (57) hide show
  1. package/README.md +154 -215
  2. package/dist/EnvManager-NMS3NMIE.js +15 -0
  3. package/dist/MarketplaceClient-YCFH2VU4.js +1 -0
  4. package/dist/chunk-JHLQ46NG.js +1 -0
  5. package/dist/index.d.ts +4 -0
  6. package/dist/index.js +216 -286
  7. package/dist/tier-table-DQMPQSI2.js +6 -0
  8. package/package.json +26 -10
  9. package/dist/commands/auth/login.js +0 -122
  10. package/dist/commands/auth/logout.js +0 -23
  11. package/dist/commands/auth/whoami.js +0 -36
  12. package/dist/commands/cache/index.js +0 -43
  13. package/dist/commands/config/features.js +0 -1026
  14. package/dist/commands/config/index.js +0 -95
  15. package/dist/commands/index.js +0 -2
  16. package/dist/commands/init/index.js +0 -197
  17. package/dist/commands/init-ci/index.js +0 -153
  18. package/dist/commands/license/index.js +0 -10
  19. package/dist/commands/license/status.js +0 -44
  20. package/dist/commands/license/tier-table.js +0 -46
  21. package/dist/commands/marketplace/browse.js +0 -186
  22. package/dist/commands/marketplace/install.js +0 -263
  23. package/dist/commands/marketplace/list.js +0 -122
  24. package/dist/commands/module/activate.js +0 -206
  25. package/dist/commands/module/add.js +0 -69
  26. package/dist/commands/module/doctor.js +0 -175
  27. package/dist/commands/module/publish.js +0 -258
  28. package/dist/commands/module/remove.js +0 -58
  29. package/dist/commands/telemetry/view.js +0 -27
  30. package/dist/commands/upgrade/check.js +0 -162
  31. package/dist/commands/upgrade/index.js +0 -185
  32. package/dist/core/AuthService.js +0 -222
  33. package/dist/core/CacheManager.js +0 -154
  34. package/dist/core/ConfigManager.js +0 -166
  35. package/dist/core/EnvManager.js +0 -196
  36. package/dist/core/ErrorRecovery.js +0 -192
  37. package/dist/core/LicenseService.js +0 -83
  38. package/dist/core/ManifestParser.js +0 -52
  39. package/dist/core/MarkerService.js +0 -62
  40. package/dist/core/ModuleDoctor.js +0 -451
  41. package/dist/core/ModuleInstaller.js +0 -169
  42. package/dist/core/ProjectInitializer.js +0 -166
  43. package/dist/core/RegistryResolver.js +0 -95
  44. package/dist/core/SchemaActivator.js +0 -270
  45. package/dist/core/ScriptRunner.js +0 -73
  46. package/dist/core/SignatureVerifier.js +0 -75
  47. package/dist/core/index.js +0 -2
  48. package/dist/infrastructure/Container.js +0 -37
  49. package/dist/infrastructure/MarketplaceClient.js +0 -399
  50. package/dist/infrastructure/TelemetryBuffer.js +0 -73
  51. package/dist/infrastructure/TransactionalFileSystem.js +0 -77
  52. package/dist/infrastructure/errors.js +0 -63
  53. package/dist/infrastructure/index.js +0 -2
  54. package/dist/types/auth.js +0 -2
  55. package/dist/types/manifest.js +0 -45
  56. package/dist/types/markers.js +0 -10
  57. package/dist/types/marketplace.js +0 -2
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.container = exports.Container = void 0;
4
- class Container {
5
- services = new Map();
6
- factories = new Map();
7
- register(name, factory) {
8
- this.factories.set(name, factory);
9
- }
10
- registerSingleton(name, instance) {
11
- this.services.set(name, instance);
12
- }
13
- resolve(name) {
14
- // Check singletons first
15
- if (this.services.has(name)) {
16
- return this.services.get(name);
17
- }
18
- // Check factories
19
- if (this.factories.has(name)) {
20
- const factory = this.factories.get(name);
21
- if (factory) {
22
- const instance = factory();
23
- // Cache as singleton
24
- this.services.set(name, instance);
25
- return instance;
26
- }
27
- }
28
- throw new Error(`Service not found: ${name}`);
29
- }
30
- clear() {
31
- this.services.clear();
32
- this.factories.clear();
33
- }
34
- }
35
- exports.Container = Container;
36
- // Global container instance
37
- exports.container = new Container();
@@ -1,399 +0,0 @@
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.MarketplaceClient = void 0;
7
- const fs_extra_1 = __importDefault(require("fs-extra"));
8
- const path_1 = __importDefault(require("path"));
9
- const os_1 = __importDefault(require("os"));
10
- const errors_1 = require("./errors");
11
- const DEFAULT_BASE_URL = "https://marketplace.kaven.site";
12
- const REQUEST_TIMEOUT_MS = 30_000;
13
- const MAX_RETRIES = 3;
14
- const INITIAL_RETRY_DELAY_MS = 1_000;
15
- function debug(message) {
16
- if (process.env.KAVEN_DEBUG === "1") {
17
- console.debug(`[kaven:debug] ${message}`);
18
- }
19
- }
20
- /** Load the apiUrl from ~/.kaven/config.json if present. */
21
- async function loadConfigApiUrl() {
22
- try {
23
- const configPath = path_1.default.join(os_1.default.homedir(), ".kaven", "config.json");
24
- if (await fs_extra_1.default.pathExists(configPath)) {
25
- const config = await fs_extra_1.default.readJson(configPath);
26
- if (typeof config.apiUrl === "string" && config.apiUrl) {
27
- return config.apiUrl;
28
- }
29
- }
30
- }
31
- catch {
32
- // Ignore config read errors
33
- }
34
- return null;
35
- }
36
- /** Resolve base URL from env → config file → default. */
37
- async function resolveBaseUrl() {
38
- if (process.env.KAVEN_API_URL) {
39
- return process.env.KAVEN_API_URL.replace(/\/$/, "");
40
- }
41
- const configUrl = await loadConfigApiUrl();
42
- if (configUrl) {
43
- return configUrl.replace(/\/$/, "");
44
- }
45
- return DEFAULT_BASE_URL;
46
- }
47
- /** Sleep helper for retry backoff. */
48
- function sleep(ms) {
49
- return new Promise((resolve) => setTimeout(resolve, ms));
50
- }
51
- /** Determine if the error code / HTTP status is retryable. */
52
- function isRetryable(status) {
53
- return status >= 500;
54
- }
55
- class MarketplaceClient {
56
- baseURLPromise;
57
- authService;
58
- constructor(authService) {
59
- this.authService = authService ?? null;
60
- this.baseURLPromise = resolveBaseUrl();
61
- }
62
- /** Resolve a relative API path to an absolute URL. */
63
- async resolveUrl(path) {
64
- const baseURL = await this.baseURLPromise;
65
- return `${baseURL}${path}`;
66
- }
67
- // ──────────────────────────────────────────────────────────
68
- // Core HTTP helpers
69
- // ──────────────────────────────────────────────────────────
70
- /**
71
- * Make an HTTP request with retry logic and typed error mapping.
72
- * `authenticated` controls whether Authorization header is attached.
73
- */
74
- async request(method, endpoint, options = {}) {
75
- const baseURL = await this.baseURLPromise;
76
- const url = `${baseURL}${endpoint}`;
77
- const { body, authenticated = false } = options;
78
- let lastError = null;
79
- for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
80
- if (attempt > 0) {
81
- const delay = INITIAL_RETRY_DELAY_MS * Math.pow(2, attempt - 1);
82
- debug(`Retry attempt ${attempt} for ${method} ${endpoint} (delay ${delay}ms)`);
83
- await sleep(delay);
84
- }
85
- try {
86
- const headers = {
87
- "Content-Type": "application/json",
88
- Accept: "application/json",
89
- };
90
- if (authenticated && this.authService) {
91
- const token = await this.authService.getValidToken();
92
- headers["Authorization"] = `Bearer ${token}`;
93
- }
94
- debug(`${method} ${url}`);
95
- const controller = new AbortController();
96
- const timeoutId = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
97
- let response;
98
- try {
99
- response = await fetch(url, {
100
- method,
101
- headers,
102
- body: body !== undefined ? JSON.stringify(body) : undefined,
103
- signal: controller.signal,
104
- });
105
- }
106
- finally {
107
- clearTimeout(timeoutId);
108
- }
109
- debug(`Response: ${response.status} ${response.statusText}`);
110
- // Map HTTP errors to typed exceptions
111
- if (!response.ok) {
112
- const errorText = await response.text().catch(() => "");
113
- let errorMessage = errorText;
114
- try {
115
- const errorJson = JSON.parse(errorText);
116
- errorMessage = errorJson.message || errorJson.error || errorText;
117
- }
118
- catch {
119
- // keep raw text
120
- }
121
- switch (response.status) {
122
- case 401:
123
- throw new errors_1.AuthenticationError(errorMessage || "Authentication required");
124
- case 403: {
125
- let requiredTier = "pro";
126
- try {
127
- const parsed = JSON.parse(errorText);
128
- requiredTier = parsed.requiredTier || requiredTier;
129
- }
130
- catch {
131
- // ignore
132
- }
133
- throw new errors_1.LicenseRequiredError(requiredTier, errorMessage || "License required");
134
- }
135
- case 404:
136
- throw new errors_1.NotFoundError(errorMessage || "Resource not found");
137
- case 429: {
138
- const retryAfter = parseInt(response.headers.get("retry-after") ?? "60", 10);
139
- throw new errors_1.RateLimitError(isNaN(retryAfter) ? 60 : retryAfter);
140
- }
141
- default:
142
- if (isRetryable(response.status)) {
143
- lastError = new errors_1.ServerError(errorMessage || `Server error: ${response.status}`);
144
- continue; // retry
145
- }
146
- throw new errors_1.ServerError(errorMessage || `Server error: ${response.status}`);
147
- }
148
- }
149
- // Parse successful response
150
- const contentType = response.headers.get("content-type") ?? "";
151
- if (contentType.includes("application/json")) {
152
- return (await response.json());
153
- }
154
- // Return empty object for no-body responses (204, etc.)
155
- return {};
156
- }
157
- catch (error) {
158
- // Re-throw our typed errors without retrying on 4xx
159
- if (error instanceof errors_1.AuthenticationError ||
160
- error instanceof errors_1.LicenseRequiredError ||
161
- error instanceof errors_1.NotFoundError ||
162
- error instanceof errors_1.RateLimitError) {
163
- throw error;
164
- }
165
- // Network / timeout errors
166
- if (error instanceof TypeError ||
167
- (error instanceof Error && error.name === "AbortError")) {
168
- const networkError = new errors_1.NetworkError(error.name === "AbortError"
169
- ? "Request timed out after 30s"
170
- : `Network error: ${error.message}`);
171
- lastError = networkError;
172
- // Retry on network errors too
173
- if (attempt < MAX_RETRIES)
174
- continue;
175
- throw networkError;
176
- }
177
- // ServerError already stored in lastError, will retry
178
- if (error instanceof errors_1.ServerError) {
179
- lastError = error;
180
- if (attempt < MAX_RETRIES)
181
- continue;
182
- throw error;
183
- }
184
- // Unknown error — don't retry
185
- throw error;
186
- }
187
- }
188
- // All retries exhausted
189
- throw lastError ?? new errors_1.NetworkError("Request failed after retries");
190
- }
191
- // ──────────────────────────────────────────────────────────
192
- // Auth endpoints (unauthenticated)
193
- // ──────────────────────────────────────────────────────────
194
- /**
195
- * Step 1 of Device Code Flow: Request device code from marketplace.
196
- */
197
- async requestDeviceCode() {
198
- return this.request("POST", "/auth/device-code", {
199
- body: { client_id: "kaven-cli" },
200
- authenticated: false,
201
- });
202
- }
203
- /**
204
- * Step 2 of Device Code Flow: Poll for access token.
205
- */
206
- async pollDeviceToken(deviceCode) {
207
- try {
208
- const baseURL = await this.baseURLPromise;
209
- const url = `${baseURL}/auth/token`;
210
- const controller = new AbortController();
211
- const timeoutId = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
212
- let response;
213
- try {
214
- response = await fetch(url, {
215
- method: "POST",
216
- headers: { "Content-Type": "application/json" },
217
- body: JSON.stringify({
218
- device_code: deviceCode,
219
- grant_type: "urn:ietf:params:oauth:grant-type:device_code",
220
- }),
221
- signal: controller.signal,
222
- });
223
- }
224
- finally {
225
- clearTimeout(timeoutId);
226
- }
227
- if (response.ok) {
228
- const tokens = await response.json();
229
- return { status: "success", tokens };
230
- }
231
- const errorData = await response.json().catch(() => ({}));
232
- const errorCode = errorData.error ?? "unknown_error";
233
- switch (errorCode) {
234
- case "authorization_pending":
235
- return { status: "authorization_pending" };
236
- case "slow_down":
237
- return { status: "slow_down" };
238
- case "access_denied":
239
- return { status: "access_denied" };
240
- case "expired_token":
241
- return { status: "expired_token" };
242
- default:
243
- throw new Error(`Unexpected error: ${errorCode}`);
244
- }
245
- }
246
- catch (error) {
247
- const nodeError = error;
248
- if (nodeError.code === "ECONNREFUSED" ||
249
- nodeError.code === "ENOTFOUND") {
250
- throw new errors_1.NetworkError("Network error. Check your connection and try again.");
251
- }
252
- throw error;
253
- }
254
- }
255
- /**
256
- * Refresh access token using refresh token.
257
- */
258
- async refreshToken(refreshToken) {
259
- return this.request("POST", "/auth/refresh", {
260
- body: { refresh_token: refreshToken },
261
- authenticated: false,
262
- });
263
- }
264
- // ──────────────────────────────────────────────────────────
265
- // Module endpoints (authenticated)
266
- // ──────────────────────────────────────────────────────────
267
- /**
268
- * List available modules with optional filters.
269
- */
270
- async listModules(filters) {
271
- const params = new URLSearchParams();
272
- if (filters?.category)
273
- params.set("category", filters.category);
274
- if (filters?.tier)
275
- params.set("tier", filters.tier);
276
- if (filters?.q)
277
- params.set("q", filters.q);
278
- if (filters?.page)
279
- params.set("page", String(filters.page));
280
- if (filters?.pageSize)
281
- params.set("pageSize", String(filters.pageSize));
282
- const query = params.toString();
283
- const endpoint = `/modules${query ? `?${query}` : ""}`;
284
- return this.request("GET", endpoint);
285
- }
286
- /**
287
- * Get a single module by slug.
288
- */
289
- async getModule(slug) {
290
- return this.request("GET", `/modules/${slug}`);
291
- }
292
- /**
293
- * Get a module's manifest for a specific version.
294
- */
295
- async getManifest(slug, version) {
296
- return this.request("GET", `/modules/${slug}/versions/${version}/manifest`);
297
- }
298
- /**
299
- * Create a download token for a module release.
300
- */
301
- async createDownloadToken(moduleSlug, version) {
302
- return this.request("POST", "/download-tokens", {
303
- body: { moduleSlug, version },
304
- authenticated: true,
305
- });
306
- }
307
- // ──────────────────────────────────────────────────────────
308
- // License endpoints
309
- // ──────────────────────────────────────────────────────────
310
- /**
311
- * Validate a license key against the required tier.
312
- */
313
- async validateLicense(licenseKey, requiredTier) {
314
- const response = await this.request('POST', '/licenses/validate', {
315
- body: { licenseKey, requiredTier },
316
- });
317
- return response;
318
- }
319
- /**
320
- * Get full license status including expiry information.
321
- */
322
- async getLicenseStatus(licenseKey) {
323
- return this.request('GET', `/licenses/status?key=${encodeURIComponent(licenseKey)}`);
324
- }
325
- // ──────────────────────────────────────────────────────────
326
- // Legacy / backward-compat methods
327
- // ──────────────────────────────────────────────────────────
328
- /**
329
- * @deprecated Use getManifest(slug, version) instead.
330
- */
331
- async getModuleManifest(moduleId) {
332
- try {
333
- // Try to get latest manifest — for backward-compat we use "latest"
334
- return await this.getManifest(moduleId, "latest");
335
- }
336
- catch (error) {
337
- if (error instanceof errors_1.NotFoundError)
338
- return null;
339
- throw error;
340
- }
341
- }
342
- /**
343
- * Get release details for a specific module version.
344
- * Returns checksum, signature, and publicKey for verification.
345
- */
346
- async getReleaseInfo(slug, version) {
347
- return this.request("GET", `/modules/${slug}/versions/${version}`);
348
- }
349
- // ──────────────────────────────────────────────────────────
350
- // Publish endpoints (authenticated)
351
- // ──────────────────────────────────────────────────────────
352
- /**
353
- * Get a presigned S3 upload URL for a new module release.
354
- */
355
- async getUploadUrl(moduleSlug, version, size) {
356
- return this.request("POST", "/releases/upload-url", {
357
- body: { moduleSlug, version, size },
358
- authenticated: true,
359
- });
360
- }
361
- /**
362
- * Create a release record after uploading the artifact.
363
- */
364
- async createRelease(data) {
365
- return this.request("POST", "/releases", {
366
- body: data,
367
- authenticated: true,
368
- });
369
- }
370
- // ──────────────────────────────────────────────────────────
371
- // Checkout / upgrade endpoints (authenticated)
372
- // ──────────────────────────────────────────────────────────
373
- /**
374
- * Create a Paddle checkout session for tier upgrade.
375
- */
376
- async createCheckoutSession(tier, licenseKey) {
377
- return this.request("POST", "/checkout/session", {
378
- body: { tier, licenseKey },
379
- authenticated: true,
380
- });
381
- }
382
- /**
383
- * Poll the status of an ongoing Paddle checkout session.
384
- */
385
- async getCheckoutStatus(sessionId) {
386
- return this.request("GET", `/checkout/session/${sessionId}/status`, { authenticated: true });
387
- }
388
- // ──────────────────────────────────────────────────────────
389
- // Categories endpoint (authenticated)
390
- // ──────────────────────────────────────────────────────────
391
- /**
392
- * Get all available module categories.
393
- */
394
- async getCategories() {
395
- const result = await this.request("GET", "/modules/categories", { authenticated: true });
396
- return result.categories;
397
- }
398
- }
399
- exports.MarketplaceClient = MarketplaceClient;
@@ -1,73 +0,0 @@
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.TelemetryBuffer = void 0;
7
- const fs_extra_1 = __importDefault(require("fs-extra"));
8
- const path_1 = __importDefault(require("path"));
9
- const os_1 = __importDefault(require("os"));
10
- class TelemetryBuffer {
11
- static instance;
12
- logPath;
13
- buffer = [];
14
- constructor() {
15
- this.logPath = path_1.default.join(os_1.default.homedir(), ".kaven", "telemetry.log");
16
- }
17
- static getInstance() {
18
- if (!TelemetryBuffer.instance) {
19
- TelemetryBuffer.instance = new TelemetryBuffer();
20
- }
21
- return TelemetryBuffer.instance;
22
- }
23
- /**
24
- * Captura um evento de telemetria
25
- */
26
- capture(event, metadata, duration) {
27
- const telemetryEvent = {
28
- event,
29
- timestamp: new Date().toISOString(),
30
- metadata,
31
- duration,
32
- };
33
- this.buffer.push(telemetryEvent);
34
- }
35
- /**
36
- * Persiste os eventos do buffer no arquivo local
37
- */
38
- async flush() {
39
- if (this.buffer.length === 0)
40
- return;
41
- try {
42
- const logDir = path_1.default.dirname(this.logPath);
43
- await fs_extra_1.default.ensureDir(logDir);
44
- const lines = this.buffer.map((e) => JSON.stringify(e)).join("\n") + "\n";
45
- await fs_extra_1.default.appendFile(this.logPath, lines, "utf8");
46
- this.buffer = [];
47
- }
48
- catch (error) {
49
- // Falha silenciosa na telemetria para não interromper fluxo principal
50
- console.debug("Erro ao gravar telemetria:", error);
51
- }
52
- }
53
- /**
54
- * Recupera os últimos eventos registrados
55
- */
56
- async getRecentEvents(limit = 20) {
57
- if (!(await fs_extra_1.default.pathExists(this.logPath)))
58
- return [];
59
- try {
60
- const content = await fs_extra_1.default.readFile(this.logPath, "utf8");
61
- return content
62
- .trim()
63
- .split("\n")
64
- .reverse()
65
- .slice(0, limit)
66
- .map((line) => JSON.parse(line));
67
- }
68
- catch {
69
- return [];
70
- }
71
- }
72
- }
73
- exports.TelemetryBuffer = TelemetryBuffer;
@@ -1,77 +0,0 @@
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.TransactionalFileSystem = void 0;
7
- const fs_extra_1 = __importDefault(require("fs-extra"));
8
- const path_1 = __importDefault(require("path"));
9
- const glob_1 = require("glob");
10
- class TransactionalFileSystem {
11
- projectRoot;
12
- backupDir;
13
- backupId;
14
- filesToBackup = [];
15
- constructor(projectRoot, backupDir = ".agent/backups") {
16
- this.projectRoot = projectRoot;
17
- this.backupDir = path_1.default.join(projectRoot, backupDir);
18
- this.backupId = `backup_${Date.now()}`;
19
- }
20
- async backup(filePaths) {
21
- const backupPath = path_1.default.join(this.backupDir, this.backupId);
22
- await fs_extra_1.default.ensureDir(backupPath);
23
- for (const file of filePaths) {
24
- const absolutePath = path_1.default.resolve(this.projectRoot, file);
25
- if (!(await fs_extra_1.default.pathExists(absolutePath))) {
26
- throw new Error(`File not found for backup: ${file}`);
27
- }
28
- const relativePath = path_1.default.relative(this.projectRoot, absolutePath);
29
- const backupFile = path_1.default.join(backupPath, relativePath);
30
- await fs_extra_1.default.ensureDir(path_1.default.dirname(backupFile));
31
- await fs_extra_1.default.copy(absolutePath, backupFile);
32
- this.filesToBackup.push(absolutePath);
33
- }
34
- console.log(`📦 Backup created: ${this.backupId}`);
35
- }
36
- async rollback() {
37
- const backupPath = path_1.default.join(this.backupDir, this.backupId);
38
- if (!(await fs_extra_1.default.pathExists(backupPath))) {
39
- throw new Error(`Backup not found: ${this.backupId}`);
40
- }
41
- const files = await (0, glob_1.glob)(`${backupPath}/**/*`, { nodir: true });
42
- for (const backupFile of files) {
43
- const relativePath = path_1.default.relative(backupPath, backupFile);
44
- const targetFile = path_1.default.join(this.projectRoot, relativePath);
45
- await fs_extra_1.default.ensureDir(path_1.default.dirname(targetFile));
46
- await fs_extra_1.default.copy(backupFile, targetFile, { overwrite: true });
47
- }
48
- console.log(`♻️ Rollback complete: ${this.backupId}`);
49
- }
50
- async commit() {
51
- const backupPath = path_1.default.join(this.backupDir, this.backupId);
52
- if (await fs_extra_1.default.pathExists(backupPath)) {
53
- await fs_extra_1.default.remove(backupPath);
54
- }
55
- console.log(`✅ Transaction committed`);
56
- }
57
- getBackupId() {
58
- return this.backupId;
59
- }
60
- async cleanup() {
61
- if (!(await fs_extra_1.default.pathExists(this.backupDir)))
62
- return;
63
- const backups = await fs_extra_1.default.readdir(this.backupDir);
64
- const now = Date.now();
65
- const weekInMs = 7 * 24 * 60 * 60 * 1000;
66
- for (const backup of backups) {
67
- const match = backup.match(/backup_(\d+)/);
68
- if (match) {
69
- const timestamp = parseInt(match[1]);
70
- if (now - timestamp > weekInMs) {
71
- await fs_extra_1.default.remove(path_1.default.join(this.backupDir, backup));
72
- }
73
- }
74
- }
75
- }
76
- }
77
- exports.TransactionalFileSystem = TransactionalFileSystem;
@@ -1,63 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SignatureVerificationError = exports.NetworkError = exports.ServerError = exports.RateLimitError = exports.NotFoundError = exports.LicenseRequiredError = exports.AuthenticationError = exports.MarketplaceError = void 0;
4
- class MarketplaceError extends Error {
5
- constructor(message) {
6
- super(message);
7
- this.name = "MarketplaceError";
8
- }
9
- }
10
- exports.MarketplaceError = MarketplaceError;
11
- class AuthenticationError extends MarketplaceError {
12
- constructor(message) {
13
- super(message);
14
- this.name = "AuthenticationError";
15
- }
16
- }
17
- exports.AuthenticationError = AuthenticationError;
18
- class LicenseRequiredError extends MarketplaceError {
19
- requiredTier;
20
- constructor(requiredTier, message) {
21
- super(message);
22
- this.requiredTier = requiredTier;
23
- this.name = "LicenseRequiredError";
24
- }
25
- }
26
- exports.LicenseRequiredError = LicenseRequiredError;
27
- class NotFoundError extends MarketplaceError {
28
- constructor(message) {
29
- super(message);
30
- this.name = "NotFoundError";
31
- }
32
- }
33
- exports.NotFoundError = NotFoundError;
34
- class RateLimitError extends MarketplaceError {
35
- retryAfter;
36
- constructor(retryAfter) {
37
- super(`Rate limited. Try again in ${retryAfter}s`);
38
- this.retryAfter = retryAfter;
39
- this.name = "RateLimitError";
40
- }
41
- }
42
- exports.RateLimitError = RateLimitError;
43
- class ServerError extends MarketplaceError {
44
- constructor(message) {
45
- super(message);
46
- this.name = "ServerError";
47
- }
48
- }
49
- exports.ServerError = ServerError;
50
- class NetworkError extends MarketplaceError {
51
- constructor(message) {
52
- super(message);
53
- this.name = "NetworkError";
54
- }
55
- }
56
- exports.NetworkError = NetworkError;
57
- class SignatureVerificationError extends MarketplaceError {
58
- constructor(message) {
59
- super(message);
60
- this.name = "SignatureVerificationError";
61
- }
62
- }
63
- exports.SignatureVerificationError = SignatureVerificationError;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });