signalk-backup 0.1.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 (43) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +71 -0
  3. package/assets/icon.png +0 -0
  4. package/assets/icon.svg +46 -0
  5. package/package.json +91 -0
  6. package/plugin/backup-client.d.ts +60 -0
  7. package/plugin/backup-client.d.ts.map +1 -0
  8. package/plugin/backup-client.js +87 -0
  9. package/plugin/backup-client.js.map +1 -0
  10. package/plugin/config/schema.d.ts +32 -0
  11. package/plugin/config/schema.d.ts.map +1 -0
  12. package/plugin/config/schema.js +83 -0
  13. package/plugin/config/schema.js.map +1 -0
  14. package/plugin/database-export/index.d.ts +33 -0
  15. package/plugin/database-export/index.d.ts.map +1 -0
  16. package/plugin/database-export/index.js +55 -0
  17. package/plugin/database-export/index.js.map +1 -0
  18. package/plugin/database-export/questdb.d.ts +41 -0
  19. package/plugin/database-export/questdb.d.ts.map +1 -0
  20. package/plugin/database-export/questdb.js +143 -0
  21. package/plugin/database-export/questdb.js.map +1 -0
  22. package/plugin/database-export/types.d.ts +30 -0
  23. package/plugin/database-export/types.d.ts.map +1 -0
  24. package/plugin/database-export/types.js +10 -0
  25. package/plugin/database-export/types.js.map +1 -0
  26. package/plugin/index.d.ts +4 -0
  27. package/plugin/index.d.ts.map +1 -0
  28. package/plugin/index.js +477 -0
  29. package/plugin/index.js.map +1 -0
  30. package/plugin/proxy.d.ts +13 -0
  31. package/plugin/proxy.d.ts.map +1 -0
  32. package/plugin/proxy.js +100 -0
  33. package/plugin/proxy.js.map +1 -0
  34. package/plugin/types.d.ts +121 -0
  35. package/plugin/types.d.ts.map +1 -0
  36. package/plugin/types.js +2 -0
  37. package/plugin/types.js.map +1 -0
  38. package/public/assets/index-B7P78qlq.js +2 -0
  39. package/public/assets/index-B7P78qlq.js.map +1 -0
  40. package/public/assets/main-DQRPJ7oa.js +11 -0
  41. package/public/assets/main-DQRPJ7oa.js.map +1 -0
  42. package/public/icon.svg +46 -0
  43. package/public/index.html +27 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for describing the origin of the Work and
141
+ reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Support. While redistributing the Work or
166
+ Derivative Works thereof, You may choose to offer, and charge a
167
+ fee for, acceptance of support, warranty, indemnity, or other
168
+ liability obligations and/or rights consistent with this License.
169
+ However, in accepting such obligations, You may act only on Your
170
+ own behalf and on Your sole responsibility, not on behalf of any
171
+ other Contributor, and only if You agree to indemnify, defend,
172
+ and hold each Contributor harmless for any liability incurred by,
173
+ or claims asserted against, such Contributor by reason of your
174
+ accepting any such warranty or support.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Dirk Wahrheit
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
200
+ implied. See the License for the specific language governing permissions
201
+ and limitations under the License.
package/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # signalk-backup
2
+
3
+ Scheduled deduplicated backups of your SignalK config (and optionally history) to local storage and Google Drive.
4
+
5
+ The plugin is a thin shell: it asks [signalk-container](https://github.com/dirkwa/signalk-container) to run the backup engine in a container ([signalk-backup-server](https://github.com/dirkwa/signalk-backup-server)) and presents a redirect to the engine's UI as a SignalK webapp. All backup work — Kopia snapshots, rclone Google Drive sync, scheduling, restore-with-rollback — happens inside the container.
6
+
7
+ ## Features
8
+
9
+ - **Content-addressable deduplication** — Kopia stores file blobs once across all snapshots; identical config files between hourly/daily/weekly retention tiers cost nothing
10
+ - **Cloud sync to Google Drive** — optional, opt-in. Uses rclone with `drive.file` scope (the app only sees files it created)
11
+ - **Scheduled backups** — hourly / daily / weekly / on-startup tiers, each with independent retention
12
+ - **Restore with safety backup** — every restore creates a snapshot of the current state first, so a botched restore can be rolled back automatically
13
+ - **First-run safe default** — installs with a daily local-only schedule already seeded; no surprise data egress
14
+ - **Update detection** — checks ghcr.io for new container images via signalk-container's centralized update service
15
+
16
+ ## Requirements
17
+
18
+ - SignalK Server ≥ 2.24.0
19
+ - Node 22 or newer (24 recommended)
20
+ - [signalk-container](https://github.com/dirkwa/signalk-container) ≥ 0.1.6 (provides the container runtime)
21
+ - Podman or Docker on the host
22
+
23
+ ## Install
24
+
25
+ ```bash
26
+ # Via the SignalK Admin UI: Server → Appstore → "signalk-backup"
27
+ # (auto-enables on install — first-run schedules a daily local backup)
28
+ ```
29
+
30
+ The plugin pulls `ghcr.io/dirkwa/signalk-backup-server:latest` on first run. The container is small (~80 MB compressed). Subsequent updates are detected and surfaced in the signalk-container config panel.
31
+
32
+ ## How it works
33
+
34
+ ```
35
+ Your browser
36
+ └── /plugins/signalk-backup/ ← redirect HTML
37
+ └── plugin proxies /api/gui-url
38
+ └── backup-server container UI
39
+ (snapshots, restore wizard, cloud sync, settings)
40
+ ```
41
+
42
+ When you visit `/plugins/signalk-backup/` in the SignalK Admin UI, the plugin's redirect HTML asks `/plugins/signalk-backup/api/gui-url` for the current backup-server location and bounces your browser there. This means the UI version is always in sync with the running container.
43
+
44
+ ## Configuration
45
+
46
+ Most configuration lives in the **Backup Console** (open it from the redirect, or from the SignalK Admin UI plugin config: "Open Backup Console"). The Console handles:
47
+
48
+ - Backup schedule (hourly / daily / weekly / startup) and retention tiers
49
+ - Backup excludes (paths to skip — default: `node_modules/`, `charts*/`)
50
+ - Repository password (Kopia encryption key)
51
+ - Cloud sync mode (off / manual / daily / weekly)
52
+ - Google Drive connection (one-click OAuth via `rclone authorize drive`)
53
+ - Snapshot browser, restore wizard
54
+
55
+ The SignalK Admin UI plugin panel (small) handles only deployment-level settings:
56
+
57
+ - `managedContainer` — whether to manage the container yourself or point at an external backup-server
58
+ - `imageTag` — pin a specific version or use a floating tag like `latest`
59
+ - `externalUrl` — only used when `managedContainer: false`
60
+ - `logLevel` — forwarded to the container
61
+
62
+ ## License
63
+
64
+ Apache-2.0
65
+
66
+ ## See also
67
+
68
+ - [signalk-backup-server](https://github.com/dirkwa/signalk-backup-server) — the container image
69
+ - [signalk-container](https://github.com/dirkwa/signalk-container) — runtime substrate
70
+ - [Kopia](https://kopia.io/) — backup engine
71
+ - [rclone](https://rclone.org/) — cloud transport
Binary file
@@ -0,0 +1,46 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" width="256" height="256">
3
+ <!--
4
+ signalk-backup icon
5
+ A shield (backup, protection) over a SignalK-blue wave field with a
6
+ checkmark at center (snapshot completed). Two-tone, scales cleanly to
7
+ 16px favicon size — kept simple geometry, no fine detail.
8
+ -->
9
+ <defs>
10
+ <linearGradient id="seaGrad" x1="0" x2="0" y1="0" y2="1">
11
+ <stop offset="0%" stop-color="#1a73c4"/>
12
+ <stop offset="100%" stop-color="#0d4d8a"/>
13
+ </linearGradient>
14
+ <linearGradient id="shieldGrad" x1="0" x2="0" y1="0" y2="1">
15
+ <stop offset="0%" stop-color="#fafbfc"/>
16
+ <stop offset="100%" stop-color="#e6ebf0"/>
17
+ </linearGradient>
18
+ </defs>
19
+
20
+ <!-- background disc -->
21
+ <circle cx="128" cy="128" r="120" fill="url(#seaGrad)"/>
22
+
23
+ <!-- waves -->
24
+ <path d="M 28 168 Q 64 152, 100 168 T 172 168 T 228 168 V 200 H 28 Z"
25
+ fill="#ffffff" fill-opacity="0.18"/>
26
+ <path d="M 28 188 Q 64 174, 100 188 T 172 188 T 228 188 V 220 H 28 Z"
27
+ fill="#ffffff" fill-opacity="0.12"/>
28
+
29
+ <!-- shield body -->
30
+ <path d="M 128 40
31
+ L 196 64
32
+ L 196 124
33
+ Q 196 168, 128 200
34
+ Q 60 168, 60 124
35
+ L 60 64 Z"
36
+ fill="url(#shieldGrad)"
37
+ stroke="#0d4d8a" stroke-width="6" stroke-linejoin="round"/>
38
+
39
+ <!-- checkmark -->
40
+ <path d="M 90 128 L 118 156 L 170 96"
41
+ fill="none"
42
+ stroke="#10b981"
43
+ stroke-width="16"
44
+ stroke-linecap="round"
45
+ stroke-linejoin="round"/>
46
+ </svg>
package/package.json ADDED
@@ -0,0 +1,91 @@
1
+ {
2
+ "name": "signalk-backup",
3
+ "version": "0.1.0",
4
+ "description": "Scheduled deduplicated backups of SignalK config to local storage and Google Drive (via Kopia + rclone)",
5
+ "main": "plugin/index.js",
6
+ "type": "module",
7
+ "signalk-plugin-enabled-by-default": true,
8
+ "scripts": {
9
+ "format": "prettier --write 'src/**/*.ts' 'test/**/*.ts' 'webapp/**/*.{ts,tsx,html}' && eslint --fix 'src/**/*.ts' 'test/**/*.ts' 'webapp/**/*.{ts,tsx}'",
10
+ "lint": "eslint 'src/**/*.ts' 'test/**/*.ts' 'webapp/**/*.{ts,tsx}'",
11
+ "typecheck:webapp": "tsc -p tsconfig.webapp.json",
12
+ "build:plugin": "tsc",
13
+ "build:webapp": "vite build",
14
+ "build": "npm run build:plugin && npm run typecheck:webapp && npm run build:webapp",
15
+ "build:all": "npm run lint && npm run build && npm run test",
16
+ "dev": "vite",
17
+ "test": "vitest run",
18
+ "prepublishOnly": "npm run build"
19
+ },
20
+ "keywords": [
21
+ "signalk-node-server-plugin",
22
+ "signalk-webapp",
23
+ "signalk-category-utility",
24
+ "backup",
25
+ "kopia",
26
+ "rclone",
27
+ "google-drive"
28
+ ],
29
+ "signalk": {
30
+ "displayName": "Backup",
31
+ "appIcon": "assets/icon.png",
32
+ "webapp": {
33
+ "name": "Backup",
34
+ "description": "Scheduled deduplicated backups to local storage and Google Drive"
35
+ },
36
+ "requires": [
37
+ "signalk-container"
38
+ ]
39
+ },
40
+ "files": [
41
+ "plugin/**/*",
42
+ "public/**/*",
43
+ "assets/**/*",
44
+ "docs/**/*"
45
+ ],
46
+ "engines": {
47
+ "node": ">=22.5.0",
48
+ "signalk": ">=2.24.0"
49
+ },
50
+ "dependencies": {
51
+ "@sinclair/typebox": "^0.34.0"
52
+ },
53
+ "peerDependencies": {
54
+ "signalk-container": ">=0.1.6"
55
+ },
56
+ "peerDependenciesMeta": {
57
+ "signalk-container": {
58
+ "optional": true
59
+ }
60
+ },
61
+ "devDependencies": {
62
+ "@eslint/js": "^10.0.1",
63
+ "@signalk/server-admin-ui-dependencies": "^2.23.0",
64
+ "@signalk/server-api": "^2.24.0",
65
+ "@types/express": "^5.0.0",
66
+ "@types/node": "^22.0.0",
67
+ "@types/react": "^19.2.14",
68
+ "@types/react-dom": "^19.2.3",
69
+ "@types/supertest": "^7.2.0",
70
+ "@vitejs/plugin-react": "^6.0.1",
71
+ "bootstrap": "^5.3.8",
72
+ "eslint": "^10.3.0",
73
+ "eslint-config-prettier": "^10.0.0",
74
+ "eslint-plugin-prettier": "^5.0.0",
75
+ "express": "^5.2.1",
76
+ "prettier": "^3.0.0",
77
+ "react": "^19.2.6",
78
+ "react-dom": "^19.2.6",
79
+ "reactstrap": "^9.2.3",
80
+ "supertest": "^7.2.2",
81
+ "typescript": "^6.0.3",
82
+ "typescript-eslint": "^8.0.0",
83
+ "vite": "^8.0.11",
84
+ "vitest": "^4.1.5"
85
+ },
86
+ "repository": {
87
+ "type": "git",
88
+ "url": "git+https://github.com/dirkwa/signalk-backup.git"
89
+ },
90
+ "license": "Apache-2.0"
91
+ }
@@ -0,0 +1,60 @@
1
+ /**
2
+ * HTTP client for talking to the backup-server container's API.
3
+ *
4
+ * Uses Node's built-in fetch (Node 22+). The plugin discovers the actual
5
+ * base URL via signalk-container's resolveContainerAddress() after
6
+ * ensureRunning(), then constructs this client.
7
+ *
8
+ * Methods used by the plugin's first-run logic:
9
+ * - waitForReady() — poll /api/health until 200 or timeout
10
+ * - getSettings() — GET /api/settings (read scheduler/cloud config)
11
+ * - putSettings() — PUT /api/settings (seed default schedule on first run)
12
+ * - getGuiUrl() — GET /api/gui-url (used by the redirect HTML's proxy)
13
+ *
14
+ * The full API surface (backups list/create/restore, cloud sync, etc.) is
15
+ * exercised by the container's own UI. The plugin doesn't need to wrap it.
16
+ */
17
+ export interface BackupServerSettings {
18
+ scheduler?: {
19
+ configured?: boolean;
20
+ daily?: {
21
+ enabled: boolean;
22
+ retain: number;
23
+ };
24
+ hourly?: {
25
+ enabled: boolean;
26
+ retain: number;
27
+ };
28
+ weekly?: {
29
+ enabled: boolean;
30
+ retain: number;
31
+ };
32
+ startup?: {
33
+ enabled: boolean;
34
+ retain: number;
35
+ };
36
+ };
37
+ cloud?: {
38
+ mode?: 'off' | 'manual' | 'daily' | 'weekly';
39
+ };
40
+ excludes?: string[];
41
+ [key: string]: unknown;
42
+ }
43
+ export interface BackupServerHealth {
44
+ status: string;
45
+ uptime?: number;
46
+ version?: string;
47
+ }
48
+ export declare class BackupClient {
49
+ private readonly baseUrl;
50
+ constructor(baseUrl: string);
51
+ private request;
52
+ waitForReady(maxMs?: number, intervalMs?: number): Promise<void>;
53
+ getSettings(): Promise<BackupServerSettings>;
54
+ putSettings(patch: Partial<BackupServerSettings>): Promise<BackupServerSettings>;
55
+ getGuiUrl(): Promise<{
56
+ url: string;
57
+ }>;
58
+ get base(): string;
59
+ }
60
+ //# sourceMappingURL=backup-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backup-client.d.ts","sourceRoot":"","sources":["../src/backup-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,WAAW,oBAAoB;IACnC,SAAS,CAAC,EAAE;QACV,UAAU,CAAC,EAAE,OAAO,CAAA;QACpB,KAAK,CAAC,EAAE;YAAE,OAAO,EAAE,OAAO,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,CAAA;QAC5C,MAAM,CAAC,EAAE;YAAE,OAAO,EAAE,OAAO,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,CAAA;QAC7C,MAAM,CAAC,EAAE;YAAE,OAAO,EAAE,OAAO,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,CAAA;QAC7C,OAAO,CAAC,EAAE;YAAE,OAAO,EAAE,OAAO,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,CAAA;KAC/C,CAAA;IACD,KAAK,CAAC,EAAE;QACN,IAAI,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAA;KAC7C,CAAA;IACD,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,qBAAa,YAAY;IACX,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,MAAM;YAE9B,OAAO;IAqCf,YAAY,CAAC,KAAK,SAAS,EAAE,UAAU,SAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAmB9D,WAAW,IAAI,OAAO,CAAC,oBAAoB,CAAC;IAI5C,WAAW,CAAC,KAAK,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAOhF,SAAS,IAAI,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IAI3C,IAAI,IAAI,IAAI,MAAM,CAEjB;CACF"}
@@ -0,0 +1,87 @@
1
+ /**
2
+ * HTTP client for talking to the backup-server container's API.
3
+ *
4
+ * Uses Node's built-in fetch (Node 22+). The plugin discovers the actual
5
+ * base URL via signalk-container's resolveContainerAddress() after
6
+ * ensureRunning(), then constructs this client.
7
+ *
8
+ * Methods used by the plugin's first-run logic:
9
+ * - waitForReady() — poll /api/health until 200 or timeout
10
+ * - getSettings() — GET /api/settings (read scheduler/cloud config)
11
+ * - putSettings() — PUT /api/settings (seed default schedule on first run)
12
+ * - getGuiUrl() — GET /api/gui-url (used by the redirect HTML's proxy)
13
+ *
14
+ * The full API surface (backups list/create/restore, cloud sync, etc.) is
15
+ * exercised by the container's own UI. The plugin doesn't need to wrap it.
16
+ */
17
+ export class BackupClient {
18
+ baseUrl;
19
+ constructor(baseUrl) {
20
+ this.baseUrl = baseUrl;
21
+ }
22
+ async request(path, init = {}) {
23
+ const controller = new AbortController();
24
+ const timeoutMs = init.timeoutMs ?? 10_000;
25
+ const timer = setTimeout(() => {
26
+ controller.abort();
27
+ }, timeoutMs);
28
+ try {
29
+ const headers = {
30
+ 'Content-Type': 'application/json',
31
+ ...(init.headers ?? {})
32
+ };
33
+ const res = await fetch(`${this.baseUrl}${path}`, {
34
+ ...init,
35
+ signal: controller.signal,
36
+ headers
37
+ });
38
+ if (!res.ok) {
39
+ const body = await res.text();
40
+ throw new Error(`backup-server ${path} ${res.status}: ${body.slice(0, 200)}`);
41
+ }
42
+ const raw = await res.json();
43
+ if (raw !== null && typeof raw === 'object' && 'success' in raw) {
44
+ const wrapped = raw;
45
+ if (!wrapped.success) {
46
+ throw new Error(`backup-server ${path} not-ok: ${JSON.stringify(wrapped.error)}`);
47
+ }
48
+ return wrapped.data;
49
+ }
50
+ return raw;
51
+ }
52
+ finally {
53
+ clearTimeout(timer);
54
+ }
55
+ }
56
+ async waitForReady(maxMs = 30_000, intervalMs = 1000) {
57
+ const deadline = Date.now() + maxMs;
58
+ let lastErr;
59
+ while (Date.now() < deadline) {
60
+ try {
61
+ await this.request('/api/health', { timeoutMs: 2000 });
62
+ return;
63
+ }
64
+ catch (err) {
65
+ lastErr = err;
66
+ await new Promise((r) => setTimeout(r, intervalMs));
67
+ }
68
+ }
69
+ throw new Error(`backup-server did not become ready within ${maxMs}ms: ${lastErr instanceof Error ? lastErr.message : String(lastErr)}`);
70
+ }
71
+ async getSettings() {
72
+ return this.request('/api/settings');
73
+ }
74
+ async putSettings(patch) {
75
+ return this.request('/api/settings', {
76
+ method: 'PUT',
77
+ body: JSON.stringify(patch)
78
+ });
79
+ }
80
+ async getGuiUrl() {
81
+ return this.request('/api/gui-url');
82
+ }
83
+ get base() {
84
+ return this.baseUrl;
85
+ }
86
+ }
87
+ //# sourceMappingURL=backup-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backup-client.js","sourceRoot":"","sources":["../src/backup-client.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,32 @@
1
+ import { Static } from '@sinclair/typebox';
2
+ /**
3
+ * Schema for the SignalK Admin UI plugin config form.
4
+ *
5
+ * Most user-facing settings (schedule, retention, cloud sync, exclusions)
6
+ * live inside the backup-server container's own UI — open it via the
7
+ * "Open Backup Console" link from /plugins/signalk-backup/. The fields
8
+ * below are only the per-deployment knobs the SignalK admin needs.
9
+ */
10
+ export declare const ConfigSchema: import("@sinclair/typebox").TObject<{
11
+ managedContainer: import("@sinclair/typebox").TBoolean;
12
+ imageTag: import("@sinclair/typebox").TString;
13
+ externalUrl: import("@sinclair/typebox").TString;
14
+ logLevel: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"trace">, import("@sinclair/typebox").TLiteral<"debug">, import("@sinclair/typebox").TLiteral<"info">, import("@sinclair/typebox").TLiteral<"warn">, import("@sinclair/typebox").TLiteral<"error">, import("@sinclair/typebox").TLiteral<"fatal">]>;
15
+ databaseExport: import("@sinclair/typebox").TObject<{
16
+ questdb: import("@sinclair/typebox").TBoolean;
17
+ intervalMinutes: import("@sinclair/typebox").TNumber;
18
+ }>;
19
+ }>;
20
+ export type Config = Static<typeof ConfigSchema>;
21
+ /**
22
+ * Materialised defaults — Signal K only uses the schema's `default` fields
23
+ * to seed the Admin UI form, NOT to inject defaults into the runtime config
24
+ * object passed to `plugin.start()`. When the plugin is auto-enabled
25
+ * (signalk-plugin-enabled-by-default) or enabled without saving the form,
26
+ * start() receives `{}`. Spread SCHEMA_DEFAULTS in start() so every field
27
+ * is present at runtime.
28
+ *
29
+ * See AGENTS.md §"Plugin-specific gotchas".
30
+ */
31
+ export declare const SCHEMA_DEFAULTS: Config;
32
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/config/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAEhD;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY;;;;;;;;;EA8DvB,CAAA;AAEF,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,YAAY,CAAC,CAAA;AAEhD;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,EAAE,MAS7B,CAAA"}