@dinoxx/dinox-cli 2.13.0 → 2.13.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.
|
@@ -5,8 +5,6 @@ import { resolveConfig } from '../../config/resolve.js';
|
|
|
5
5
|
import { restoreSuspendedDaemonLocked, suspendDaemonForExclusiveAccessLocked } from '../../daemon/lifecycle.js';
|
|
6
6
|
import { acquireDaemonStartLock } from '../../daemon/pid.js';
|
|
7
7
|
import { fetchCredentialsWithAuthorization } from '../../powersync/connector.js';
|
|
8
|
-
import { closePowerSyncAndReleaseOwner, connectPowerSync, getStatusSnapshot } from '../../powersync/runtime.js';
|
|
9
|
-
import { runSingleSyncPass } from '../../powersync/syncPass.js';
|
|
10
8
|
import type { CommandGroupDescriptor } from '../descriptor/types.js';
|
|
11
9
|
import { printHumanReadableWarning } from '../../utils/output.js';
|
|
12
10
|
export declare function releaseOwnerLeases(releases: ReadonlyArray<() => Promise<void>>): Promise<unknown[]>;
|
|
@@ -17,10 +15,6 @@ type AuthLoginDependencies = {
|
|
|
17
15
|
fetchCredentials: typeof fetchCredentialsWithAuthorization;
|
|
18
16
|
fetchUserInfo: typeof fetchUserInfoWithAuthorization;
|
|
19
17
|
suspendDaemon: typeof suspendDaemonForExclusiveAccessLocked;
|
|
20
|
-
connectPowerSync: typeof connectPowerSync;
|
|
21
|
-
runSingleSyncPass: typeof runSingleSyncPass;
|
|
22
|
-
getStatusSnapshot: typeof getStatusSnapshot;
|
|
23
|
-
closePowerSyncAndReleaseOwner: typeof closePowerSyncAndReleaseOwner;
|
|
24
18
|
updateConfig: typeof updateConfig;
|
|
25
19
|
restoreDaemon: typeof restoreSuspendedDaemonLocked;
|
|
26
20
|
printWarning: typeof printHumanReadableWarning;
|
|
@@ -13,8 +13,7 @@ import { autoInstallDaemonService, describeDaemonServiceAutoInstall } from '../.
|
|
|
13
13
|
import { acquireDaemonStartLock } from '../../daemon/pid.js';
|
|
14
14
|
import { fetchCredentialsWithAuthorization } from '../../powersync/connector.js';
|
|
15
15
|
import { withExclusivePowerSync } from '../../powersync/exclusiveRuntime.js';
|
|
16
|
-
import { acquirePowerSyncOwnerLease,
|
|
17
|
-
import { runSingleSyncPass } from '../../powersync/syncPass.js';
|
|
16
|
+
import { acquirePowerSyncOwnerLease, getStatusSnapshot, } from '../../powersync/runtime.js';
|
|
18
17
|
import { registerCommandGroup } from '../descriptor/register.js';
|
|
19
18
|
import { FORMAT_OPTIONS, OFFLINE_OPTIONS, SYNC_TIMEOUT_OPTIONS } from '../schema/globalOptions.js';
|
|
20
19
|
import { normalizeAuthToken, readEnvAuthToken } from '../../utils/authToken.js';
|
|
@@ -106,10 +105,6 @@ const authLoginDependencies = {
|
|
|
106
105
|
fetchCredentials: fetchCredentialsWithAuthorization,
|
|
107
106
|
fetchUserInfo: fetchUserInfoWithAuthorization,
|
|
108
107
|
suspendDaemon: suspendDaemonForExclusiveAccessLocked,
|
|
109
|
-
connectPowerSync,
|
|
110
|
-
runSingleSyncPass,
|
|
111
|
-
getStatusSnapshot,
|
|
112
|
-
closePowerSyncAndReleaseOwner,
|
|
113
108
|
updateConfig,
|
|
114
109
|
restoreDaemon: restoreSuspendedDaemonLocked,
|
|
115
110
|
printWarning: printHumanReadableWarning,
|
|
@@ -122,7 +117,6 @@ export async function performAuthLogin(rawToken, syncTimeout, overrides = {}) {
|
|
|
122
117
|
const releaseStartLock = await dependencies.acquireDaemonStartLock(parseSyncTimeoutMs(syncTimeout) ?? 10_000);
|
|
123
118
|
let previousConfig = null;
|
|
124
119
|
let suspended = null;
|
|
125
|
-
let restoreAllowed = true;
|
|
126
120
|
let lifecycleLockReleaseError;
|
|
127
121
|
let outcome;
|
|
128
122
|
try {
|
|
@@ -145,37 +139,6 @@ export async function performAuthLogin(rawToken, syncTimeout, overrides = {}) {
|
|
|
145
139
|
const verifiedConfig = mergeAuthIdentityIntoConfig(previousConfig, rawToken, identity);
|
|
146
140
|
const verifiedResolved = dependencies.resolveConfig(verifiedConfig);
|
|
147
141
|
suspended = await dependencies.suspendDaemon(previousResolved, timeoutMs, { forceStop: true });
|
|
148
|
-
const { db, dbPath, stale, releaseOwner } = await dependencies.connectPowerSync({
|
|
149
|
-
config: verifiedResolved,
|
|
150
|
-
offline: false,
|
|
151
|
-
timeoutMs,
|
|
152
|
-
});
|
|
153
|
-
let syncOutcome;
|
|
154
|
-
try {
|
|
155
|
-
await dependencies.runSingleSyncPass(db, timeoutMs);
|
|
156
|
-
syncOutcome = {
|
|
157
|
-
ok: true,
|
|
158
|
-
lastSyncedAt: dependencies.getStatusSnapshot(db).lastSyncedAt,
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
catch (error) {
|
|
162
|
-
syncOutcome = { ok: false, error };
|
|
163
|
-
}
|
|
164
|
-
let cleanupError;
|
|
165
|
-
try {
|
|
166
|
-
await dependencies.closePowerSyncAndReleaseOwner(db, releaseOwner);
|
|
167
|
-
}
|
|
168
|
-
catch (error) {
|
|
169
|
-
cleanupError = error;
|
|
170
|
-
restoreAllowed = false;
|
|
171
|
-
dependencies.printWarning(`warning: failed to close the login verification runtime safely: ${authLoginErrorMessage(error)}`);
|
|
172
|
-
}
|
|
173
|
-
if (!syncOutcome.ok) {
|
|
174
|
-
throw syncOutcome.error;
|
|
175
|
-
}
|
|
176
|
-
if (cleanupError) {
|
|
177
|
-
throw cleanupError;
|
|
178
|
-
}
|
|
179
142
|
await dependencies.updateConfig((current) => {
|
|
180
143
|
if (!persistedAuthStateMatches(current, previousConfig)) {
|
|
181
144
|
throw new DinoxError('Authentication changed while login was being verified.', {
|
|
@@ -192,16 +155,16 @@ export async function performAuthLogin(rawToken, syncTimeout, overrides = {}) {
|
|
|
192
155
|
ok: true,
|
|
193
156
|
verified: true,
|
|
194
157
|
endpoint: verifiedResolved.powersync.endpoint,
|
|
195
|
-
dbPath,
|
|
196
|
-
stale,
|
|
197
|
-
lastSyncedAt:
|
|
158
|
+
dbPath: getPowerSyncDbPath(identity.userId),
|
|
159
|
+
stale: true,
|
|
160
|
+
lastSyncedAt: null,
|
|
198
161
|
userId: identity.userId,
|
|
199
162
|
},
|
|
200
163
|
};
|
|
201
164
|
}
|
|
202
165
|
catch (error) {
|
|
203
166
|
outcome = { ok: false, error };
|
|
204
|
-
if (previousConfig && suspended
|
|
167
|
+
if (previousConfig && suspended) {
|
|
205
168
|
try {
|
|
206
169
|
const current = await dependencies.loadConfig();
|
|
207
170
|
if (persistedAuthStateMatches(current, previousConfig)) {
|
|
@@ -315,12 +278,7 @@ async function runAuthLogin(context) {
|
|
|
315
278
|
printHumanReadableLine(`- endpoint: ${result.endpoint}`);
|
|
316
279
|
printHumanReadableLine(`- db: ${result.dbPath}`);
|
|
317
280
|
printHumanReadableLine(`- userId: ${result.userId}`);
|
|
318
|
-
|
|
319
|
-
printHumanReadableLine(`- lastSyncedAt: ${result.lastSyncedAt}`);
|
|
320
|
-
}
|
|
321
|
-
if (result.stale) {
|
|
322
|
-
printHumanReadableLine('- warning: initial sync timed out; local cache may be stale');
|
|
323
|
-
}
|
|
281
|
+
printHumanReadableLine('- initial sync continues in the background; run `dino sync` to wait for it');
|
|
324
282
|
const serviceNote = describeDaemonServiceAutoInstall(daemonService);
|
|
325
283
|
if (serviceNote)
|
|
326
284
|
printHumanReadableWarning(serviceNote);
|
|
@@ -567,7 +525,7 @@ export const authCommandGroup = {
|
|
|
567
525
|
commands: [
|
|
568
526
|
{
|
|
569
527
|
name: 'login',
|
|
570
|
-
description: 'Log in by scanning a QR code
|
|
528
|
+
description: 'Log in by scanning a QR code or with a token; the initial sync continues in the background',
|
|
571
529
|
arguments: [{ syntax: '[token]', description: 'Login token (omit to scan a QR code, or when using --token-stdin)' }],
|
|
572
530
|
options: [{ flags: '--token-stdin', description: 'Read the login token from piped stdin instead of argv', type: 'boolean' }],
|
|
573
531
|
schema: {
|
|
@@ -577,7 +535,7 @@ export const authCommandGroup = {
|
|
|
577
535
|
globalOptions: AUTH_LOGIN_GLOBAL_OPTIONS,
|
|
578
536
|
output: {
|
|
579
537
|
type: 'structured',
|
|
580
|
-
summary: 'Login verification result',
|
|
538
|
+
summary: 'Login verification result (initial sync is not awaited)',
|
|
581
539
|
fields: ['verified', 'endpoint', 'dbPath', 'stale', 'lastSyncedAt', 'userId', 'daemonService'],
|
|
582
540
|
},
|
|
583
541
|
examples: [
|