@g9tm/app-diagnostic 0.3.0 → 0.3.1
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.
- package/package.json +1 -1
- package/src/live/bundle.ts +5 -2
- package/src/live/channel.ts +6 -1
- package/src/live/handlers.ts +9 -2
- package/src/live/upload.ts +3 -0
- package/src/tester/engine.ts +854 -854
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@g9tm/app-diagnostic",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Device diagnostics client for apps in the field: tester reports (resumable upload) to a G9AppDiagnostic gateway. No platform code: the host reads the archive.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
package/src/live/bundle.ts
CHANGED
|
@@ -21,6 +21,8 @@ export interface BundleManifestInput {
|
|
|
21
21
|
readonly username?: string | null;
|
|
22
22
|
readonly note?: string | null;
|
|
23
23
|
readonly scopes: BackupBuildRequestPayload;
|
|
24
|
+
/** The app advertises `backup-changed-rows`: a lighter copy asked for is what bundle.json names (the .NET ManifestAsync). */
|
|
25
|
+
readonly changedRowsHonoured?: boolean;
|
|
24
26
|
readonly now?: () => number;
|
|
25
27
|
}
|
|
26
28
|
|
|
@@ -48,8 +50,9 @@ export function bundleManifest(m: BundleManifestInput): string {
|
|
|
48
50
|
preferences: s.includePreferences,
|
|
49
51
|
secureStorage: s.includeSecureStorage,
|
|
50
52
|
},
|
|
51
|
-
// Which database copy
|
|
52
|
-
|
|
53
|
+
// Which database copy was asked for: «changed-rows-only» only from an app that honours it. The app's own
|
|
54
|
+
// sqlite/rows.json and the upload's sqliteChangedRowsOnly say what the copy really is.
|
|
55
|
+
sqliteRows: !s.includeSqlite ? null : s.sqliteChangedRowsOnly === true && m.changedRowsHonoured === true ? 'changed-rows-only' : 'full',
|
|
53
56
|
},
|
|
54
57
|
null,
|
|
55
58
|
2,
|
package/src/live/channel.ts
CHANGED
|
@@ -142,6 +142,11 @@ export interface LiveChannelOptions {
|
|
|
142
142
|
/** The build: presence carries it, every bundle's manifest too. */
|
|
143
143
|
readonly branch?: string | null;
|
|
144
144
|
readonly commit?: string | null;
|
|
145
|
+
/**
|
|
146
|
+
* What THIS app serves beyond the package (DeviceCapabilities): e.g. `backup-changed-rows` when its backup honours
|
|
147
|
+
* `sqliteChangedRowsOnly`. Presence carries them after the package's own, each once.
|
|
148
|
+
*/
|
|
149
|
+
readonly extraCapabilities?: readonly string[];
|
|
145
150
|
readonly log?: DiagnosticLog;
|
|
146
151
|
readonly onError?: (where: string, error: unknown) => void;
|
|
147
152
|
readonly now?: () => number;
|
|
@@ -477,7 +482,7 @@ export class LiveChannel {
|
|
|
477
482
|
...rest,
|
|
478
483
|
...(withAvatar && avatarBase64 ? { avatarBase64 } : {}),
|
|
479
484
|
clientId: this.clientId,
|
|
480
|
-
capabilities: CURRENT_CAPABILITIES.
|
|
485
|
+
capabilities: [...new Set([...CURRENT_CAPABILITIES, ...(this.options.extraCapabilities ?? [])])],
|
|
481
486
|
...(this.options.branch ? { buildBranch: this.options.branch } : {}),
|
|
482
487
|
...(this.options.commit ? { buildCommit: this.options.commit } : {}),
|
|
483
488
|
lastSeenUtc: new Date(this.now()).toISOString(),
|
package/src/live/handlers.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// connection. Product commands (sync control, NFC, a QA bridge) are the app's extensions.
|
|
6
6
|
import { base64ToBytes, utf8Decode } from '../bytes.ts';
|
|
7
7
|
import { type DiagnosticFiles, type DiagnosticZipEntry, errorText } from '../host.ts';
|
|
8
|
-
import { DeviceHubListeners, DeviceHubMethods } from '../wire.ts';
|
|
8
|
+
import { DeviceCapabilities, DeviceHubListeners, DeviceHubMethods } from '../wire.ts';
|
|
9
9
|
import { BUNDLE_ENTRY, bundleFileName, bundleManifest, type BundleKind, normalizeScopes } from './bundle.ts';
|
|
10
10
|
import type { ILiveKeepAlive, LiveChannel } from './channel.ts';
|
|
11
11
|
import type { BackupBuildRequestPayload, LogFileReadRequestPayload, RemoteInputCommand, SqlExecRequestPayload, SqlResultPayload } from './models.ts';
|
|
@@ -23,7 +23,12 @@ export interface ILiveSqlTarget {
|
|
|
23
23
|
/** The app's diagnostic bundle (ILiveBackupSource): what goes in for the scopes asked; the channel adds its own entries. */
|
|
24
24
|
export interface ILiveBackupSource {
|
|
25
25
|
/** Zips the app's entries for `scopes` plus `extra` (bundle.json, a report) into `out`. */
|
|
26
|
-
build(request: { readonly kind: BundleKind; readonly scopes: BackupBuildRequestPayload; readonly out: string; readonly extra: readonly DiagnosticZipEntry[] }): Promise<{
|
|
26
|
+
build(request: { readonly kind: BundleKind; readonly scopes: BackupBuildRequestPayload; readonly out: string; readonly extra: readonly DiagnosticZipEntry[] }): Promise<{
|
|
27
|
+
readonly path: string;
|
|
28
|
+
readonly containsSensitive: boolean;
|
|
29
|
+
/** The database copy really holds only the changed rows (asked for AND made); absent = the whole database. */
|
|
30
|
+
readonly sqliteChangedRowsOnly?: boolean;
|
|
31
|
+
}>;
|
|
27
32
|
/** The password envelope (the wire profile's backupMagic): `source` → `destination`. */
|
|
28
33
|
encrypt?(source: string, destination: string, password: string): Promise<void>;
|
|
29
34
|
}
|
|
@@ -384,6 +389,7 @@ export async function sendBundle(o: LiveHandlerOptions, kind: BundleKind, scopes
|
|
|
384
389
|
username: await channel.options.host.username().catch(() => null),
|
|
385
390
|
note: s.note ?? null,
|
|
386
391
|
scopes,
|
|
392
|
+
changedRowsHonoured: (channel.options.extraCapabilities ?? []).includes(DeviceCapabilities.backupChangedRows),
|
|
387
393
|
now,
|
|
388
394
|
});
|
|
389
395
|
const built = await o.backup.build({ kind, scopes, out, extra: [{ name: BUNDLE_ENTRY, text: manifest }, ...(s.extra ?? [])] });
|
|
@@ -414,6 +420,7 @@ export async function sendBundle(o: LiveHandlerOptions, kind: BundleKind, scopes
|
|
|
414
420
|
geoDatabase: scopes.includeGeoDatabase,
|
|
415
421
|
preferences: scopes.includePreferences,
|
|
416
422
|
secureStorage: scopes.includeSecureStorage,
|
|
423
|
+
sqliteChangedRowsOnly: scopes.includeSqlite && built.sqliteChangedRowsOnly === true,
|
|
417
424
|
},
|
|
418
425
|
...(s.resumeToken !== undefined ? { resumeToken: s.resumeToken } : {}),
|
|
419
426
|
},
|
package/src/live/upload.ts
CHANGED
|
@@ -64,6 +64,8 @@ export interface BundleUploadRequest {
|
|
|
64
64
|
readonly geoDatabase?: boolean;
|
|
65
65
|
readonly preferences?: boolean;
|
|
66
66
|
readonly secureStorage?: boolean;
|
|
67
|
+
/** The database copy holds only the changed rows of the app's heavy tables (what the app really made). */
|
|
68
|
+
readonly sqliteChangedRowsOnly?: boolean;
|
|
67
69
|
};
|
|
68
70
|
/** A token from an earlier, interrupted run of the SAME file. */
|
|
69
71
|
readonly resumeToken?: string | null;
|
|
@@ -118,6 +120,7 @@ export async function uploadBundle(hub: HubInvoker, files: DiagnosticFiles, requ
|
|
|
118
120
|
includeLogs: request.include.logs,
|
|
119
121
|
includePreferences: request.include.preferences ?? false,
|
|
120
122
|
includeSecureStorage: request.include.secureStorage ?? false,
|
|
123
|
+
sqliteChangedRowsOnly: request.include.sqliteChangedRowsOnly === true,
|
|
121
124
|
source: request.source,
|
|
122
125
|
};
|
|
123
126
|
const answer = await hub.invoke<BackupUploadInitResponse>(DeviceHubMethods.backupUploadInit, init);
|