@korajs/core 1.0.0-beta.10 → 1.0.0-beta.11
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/dist/bindings/index.cjs.map +1 -1
- package/dist/bindings/index.d.cts +20 -4
- package/dist/bindings/index.d.ts +20 -4
- package/dist/{build-scope-map-B8dpCt6P.d.cts → build-scope-map--0H8l6Tw.d.cts} +1 -1
- package/dist/{build-scope-map-CDpIGOsf.d.ts → build-scope-map-B3R_emUU.d.ts} +1 -1
- package/dist/{events-3z0Tema3.d.cts → events-BPbYUbrE.d.cts} +26 -1
- package/dist/{events-3z0Tema3.d.ts → events-BPbYUbrE.d.ts} +26 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js.map +1 -1
- package/dist/internal.d.cts +2 -2
- package/dist/internal.d.ts +2 -2
- package/dist/{operation-BvBgl-4c.d.cts → operation-DbynlVcp.d.cts} +1 -1
- package/dist/{operation-ClhEbhoV.d.ts → operation-Dt0AtT8u.d.ts} +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/bindings/index.ts","../../src/bindings/create-mutation-controller.ts"],"sourcesContent":["export type {\n\tAuthSyncBinding,\n\tKoraAppLike,\n\tKoraBindingSyncBridge,\n\tKoraBindingSyncStatus,\n\tKoraContextValue,\n\tUseMutationOptions,\n\tUseMutationResultBase,\n\tUseQueryOptions,\n} from './types'\nexport {\n\tcreateMutationController,\n\ttype CreateMutationControllerOptions,\n\ttype MutationController,\n\ttype MutationControllerState,\n} from './create-mutation-controller'\n","import type { UseMutationOptions } from './types'\n\nexport interface MutationControllerState {\n\tisLoading: boolean\n\terror: Error | null\n}\n\nexport interface MutationController<TData, TArgs extends unknown[], TContext = void> {\n\tgetSnapshot(): MutationControllerState\n\tsubscribe(listener: () => void): () => void\n\tmutate(...args: TArgs): void\n\tmutateAsync(...args: TArgs): Promise<TData>\n\treset(): void\n\tdestroy(): void\n}\n\nexport interface CreateMutationControllerOptions<TData, TArgs extends unknown[], TContext = void> {\n\tmutationFn: (...args: TArgs) => Promise<TData>\n\toptions?: UseMutationOptions<TData, TArgs, TContext>\n\t/** Reads latest options on each mutation (for framework hooks with ref-backed options). */\n\tresolveOptions?: () => UseMutationOptions<TData, TArgs, TContext> | undefined\n\tonStateChange?: (state: MutationControllerState) => void\n}\n\n/**\n * Framework-agnostic mutation runner with optimistic lifecycle hooks.\n */\nexport function createMutationController<TData, TArgs extends unknown[], TContext = void>(\n\toptions: CreateMutationControllerOptions<TData, TArgs, TContext>,\n): MutationController<TData, TArgs, TContext> {\n\tlet snapshot: MutationControllerState = { isLoading: false, error: null }\n\tconst listeners = new Set<() => void>()\n\tlet disposed = false\n\tlet inFlight = 0\n\n\tconst notify = (): void => {\n\t\tfor (const listener of listeners) {\n\t\t\tlistener()\n\t\t}\n\t\toptions.onStateChange?.(snapshot)\n\t}\n\n\tconst setSnapshot = (next: MutationControllerState): void => {\n\t\tsnapshot = next\n\t\tnotify()\n\t}\n\n\tconst getSnapshot = (): MutationControllerState => snapshot\n\n\tconst subscribe = (listener: () => void): (() => void) => {\n\t\tlisteners.add(listener)\n\t\treturn () => {\n\t\t\tlisteners.delete(listener)\n\t\t}\n\t}\n\n\tconst reset = (): void => {\n\t\tif (disposed) return\n\t\tsetSnapshot({ isLoading: false, error: null })\n\t}\n\n\tconst mutateAsync = async (...args: TArgs): Promise<TData> => {\n\t\tif (disposed) {\n\t\t\tthrow new Error('Mutation controller is destroyed')\n\t\t}\n\n\t\tconst opts = options.resolveOptions?.() ?? options.options\n\t\tlet context: TContext | undefined\n\n\t\tinFlight++\n\t\tsetSnapshot({ isLoading: true, error: null })\n\n\t\ttry {\n\t\t\tif (opts?.onMutate) {\n\t\t\t\tcontext = await opts.onMutate(...args)\n\t\t\t}\n\n\t\t\tconst result = await options.mutationFn(...args)\n\t\t\tinFlight = Math.max(0, inFlight - 1)\n\t\t\tsetSnapshot({ isLoading: inFlight > 0, error: null })\n\t\t\topts?.onSuccess?.(result, ...args)\n\t\t\topts?.onSettled?.(result, null, ...args)\n\t\t\treturn result\n\t\t} catch (err) {\n\t\t\tconst error = err instanceof Error ? err : new Error(String(err))\n\n\t\t\tif (context !== undefined && opts?.onRollback) {\n\t\t\t\tawait opts.onRollback(context, ...args)\n\t\t\t}\n\n\t\t\tinFlight = Math.max(0, inFlight - 1)\n\t\t\tsetSnapshot({ isLoading: inFlight > 0, error })\n\t\t\topts?.onError?.(error, ...args)\n\t\t\topts?.onSettled?.(undefined, error, ...args)\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tconst mutate = (...args: TArgs): void => {\n\t\tvoid mutateAsync(...args).catch(() => {})\n\t}\n\n\tconst destroy = (): void => {\n\t\tdisposed = true\n\t\tlisteners.clear()\n\t}\n\n\treturn {\n\t\tgetSnapshot,\n\t\tsubscribe,\n\t\tmutate,\n\t\tmutateAsync,\n\t\treset,\n\t\tdestroy,\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC2BO,SAAS,yBACf,SAC6C;AAC7C,MAAI,WAAoC,EAAE,WAAW,OAAO,OAAO,KAAK;AACxE,QAAM,YAAY,oBAAI,IAAgB;AACtC,MAAI,WAAW;AACf,MAAI,WAAW;AAEf,QAAM,SAAS,MAAY;AAC1B,eAAW,YAAY,WAAW;AACjC,eAAS;AAAA,IACV;AACA,YAAQ,gBAAgB,QAAQ;AAAA,EACjC;AAEA,QAAM,cAAc,CAAC,SAAwC;AAC5D,eAAW;AACX,WAAO;AAAA,EACR;AAEA,QAAM,cAAc,MAA+B;AAEnD,QAAM,YAAY,CAAC,aAAuC;AACzD,cAAU,IAAI,QAAQ;AACtB,WAAO,MAAM;AACZ,gBAAU,OAAO,QAAQ;AAAA,IAC1B;AAAA,EACD;AAEA,QAAM,QAAQ,MAAY;AACzB,QAAI,SAAU;AACd,gBA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,IACA;AAAA,EACD;AACD;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/bindings/index.ts","../../src/bindings/create-mutation-controller.ts"],"sourcesContent":["export type {\n\tAuthSyncBinding,\n\tAuthSyncState,\n\tKoraAppLike,\n\tKoraBindingSyncBridge,\n\tKoraBindingSyncStatus,\n\tKoraContextValue,\n\tUseMutationOptions,\n\tUseMutationResultBase,\n\tUseQueryOptions,\n} from './types'\nexport {\n\tcreateMutationController,\n\ttype CreateMutationControllerOptions,\n\ttype MutationController,\n\ttype MutationControllerState,\n} from './create-mutation-controller'\n","import type { UseMutationOptions } from './types'\n\nexport interface MutationControllerState {\n\tisLoading: boolean\n\terror: Error | null\n}\n\nexport interface MutationController<TData, TArgs extends unknown[], TContext = void> {\n\tgetSnapshot(): MutationControllerState\n\tsubscribe(listener: () => void): () => void\n\tmutate(...args: TArgs): void\n\tmutateAsync(...args: TArgs): Promise<TData>\n\treset(): void\n\tdestroy(): void\n}\n\nexport interface CreateMutationControllerOptions<TData, TArgs extends unknown[], TContext = void> {\n\tmutationFn: (...args: TArgs) => Promise<TData>\n\toptions?: UseMutationOptions<TData, TArgs, TContext>\n\t/** Reads latest options on each mutation (for framework hooks with ref-backed options). */\n\tresolveOptions?: () => UseMutationOptions<TData, TArgs, TContext> | undefined\n\tonStateChange?: (state: MutationControllerState) => void\n}\n\n/**\n * Framework-agnostic mutation runner with optimistic lifecycle hooks.\n */\nexport function createMutationController<TData, TArgs extends unknown[], TContext = void>(\n\toptions: CreateMutationControllerOptions<TData, TArgs, TContext>,\n): MutationController<TData, TArgs, TContext> {\n\tlet snapshot: MutationControllerState = { isLoading: false, error: null }\n\tconst listeners = new Set<() => void>()\n\tlet disposed = false\n\tlet inFlight = 0\n\n\tconst notify = (): void => {\n\t\tfor (const listener of listeners) {\n\t\t\tlistener()\n\t\t}\n\t\toptions.onStateChange?.(snapshot)\n\t}\n\n\tconst setSnapshot = (next: MutationControllerState): void => {\n\t\tsnapshot = next\n\t\tnotify()\n\t}\n\n\tconst getSnapshot = (): MutationControllerState => snapshot\n\n\tconst subscribe = (listener: () => void): (() => void) => {\n\t\tlisteners.add(listener)\n\t\treturn () => {\n\t\t\tlisteners.delete(listener)\n\t\t}\n\t}\n\n\tconst reset = (): void => {\n\t\tif (disposed) return\n\t\tsetSnapshot({ isLoading: false, error: null })\n\t}\n\n\tconst mutateAsync = async (...args: TArgs): Promise<TData> => {\n\t\tif (disposed) {\n\t\t\tthrow new Error('Mutation controller is destroyed')\n\t\t}\n\n\t\tconst opts = options.resolveOptions?.() ?? options.options\n\t\tlet context: TContext | undefined\n\n\t\tinFlight++\n\t\tsetSnapshot({ isLoading: true, error: null })\n\n\t\ttry {\n\t\t\tif (opts?.onMutate) {\n\t\t\t\tcontext = await opts.onMutate(...args)\n\t\t\t}\n\n\t\t\tconst result = await options.mutationFn(...args)\n\t\t\tinFlight = Math.max(0, inFlight - 1)\n\t\t\tsetSnapshot({ isLoading: inFlight > 0, error: null })\n\t\t\topts?.onSuccess?.(result, ...args)\n\t\t\topts?.onSettled?.(result, null, ...args)\n\t\t\treturn result\n\t\t} catch (err) {\n\t\t\tconst error = err instanceof Error ? err : new Error(String(err))\n\n\t\t\tif (context !== undefined && opts?.onRollback) {\n\t\t\t\tawait opts.onRollback(context, ...args)\n\t\t\t}\n\n\t\t\tinFlight = Math.max(0, inFlight - 1)\n\t\t\tsetSnapshot({ isLoading: inFlight > 0, error })\n\t\t\topts?.onError?.(error, ...args)\n\t\t\topts?.onSettled?.(undefined, error, ...args)\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tconst mutate = (...args: TArgs): void => {\n\t\tvoid mutateAsync(...args).catch(() => {})\n\t}\n\n\tconst destroy = (): void => {\n\t\tdisposed = true\n\t\tlisteners.clear()\n\t}\n\n\treturn {\n\t\tgetSnapshot,\n\t\tsubscribe,\n\t\tmutate,\n\t\tmutateAsync,\n\t\treset,\n\t\tdestroy,\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;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GAAG,CAAC;AAEhE,UAAI,YAAY,UAAa,MAAM,YAAY;AAC9C,cAAM,KAAK,WAAW,SAAS,GAAG,IAAI;AAAA,MACvC;AAEA,iBAAW,KAAK,IAAI,GAAG,WAAW,CAAC;AACnC,kBAAY,EAAE,WAAW,WAAW,GAAG,MAAM,CAAC;AAC9C,YAAM,UAAU,OAAO,GAAG,IAAI;AAC9B,YAAM,YAAY,QAAW,OAAO,GAAG,IAAI;AAC3C,YAAM;AAAA,IACP;AAAA,EACD;AAEA,QAAM,SAAS,IAAI,SAAsB;AACxC,SAAK,YAAY,GAAG,IAAI,EAAE,MAAM,MAAM;AAAA,IAAC,CAAC;AAAA,EACzC;AAEA,QAAM,UAAU,MAAY;AAC3B,eAAW;AACX,cAAU,MAAM;AAAA,EACjB;AAEA,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;","names":[]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { p as KoraEventEmitter } from '../events-
|
|
2
|
-
import { S as ScopeMap } from '../build-scope-map
|
|
1
|
+
import { p as KoraEventEmitter } from '../events-BPbYUbrE.cjs';
|
|
2
|
+
import { S as ScopeMap } from '../build-scope-map--0H8l6Tw.cjs';
|
|
3
3
|
|
|
4
4
|
/** Sync status shape consumed by framework binding hooks (matches {@link SyncStatusInfo} in `@korajs/sync`). */
|
|
5
5
|
interface KoraBindingSyncStatus {
|
|
6
|
-
status: 'connected' | 'reconnecting' | 'syncing' | 'synced' | 'offline' | 'error' | 'schema-mismatch' | 'clock-error';
|
|
6
|
+
status: 'connected' | 'reconnecting' | 'syncing' | 'synced' | 'offline' | 'error' | 'schema-mismatch' | 'clock-error' | 'auth-required';
|
|
7
7
|
reconnecting: boolean;
|
|
8
8
|
pendingOperations: number;
|
|
9
9
|
lastSyncedAt: number | null;
|
|
@@ -66,6 +66,8 @@ interface AuthSyncBinding {
|
|
|
66
66
|
auth: () => Promise<{
|
|
67
67
|
token: string;
|
|
68
68
|
}>;
|
|
69
|
+
/** Resolve whether sync may currently open a transport. Tokens are never used as readiness signals. */
|
|
70
|
+
resolveSyncState?: () => Promise<AuthSyncState>;
|
|
69
71
|
/** Builds a scope map from the current token and schema. */
|
|
70
72
|
resolveScopeMap?: () => Promise<ScopeMap | undefined>;
|
|
71
73
|
/**
|
|
@@ -78,6 +80,20 @@ interface AuthSyncBinding {
|
|
|
78
80
|
/** Notifies when auth state changes so sync can refresh scope or reconnect. */
|
|
79
81
|
subscribe?: (listener: () => void) => () => void;
|
|
80
82
|
}
|
|
83
|
+
/** Authentication state consumed by the sync and auth-isolated store lifecycles. */
|
|
84
|
+
type AuthSyncState = {
|
|
85
|
+
state: 'loading';
|
|
86
|
+
} | {
|
|
87
|
+
state: 'signed-out';
|
|
88
|
+
mayConnectAnonymously: false;
|
|
89
|
+
} | {
|
|
90
|
+
state: 'anonymous';
|
|
91
|
+
mayConnectAnonymously: true;
|
|
92
|
+
} | {
|
|
93
|
+
state: 'authenticated';
|
|
94
|
+
userId: string;
|
|
95
|
+
token: string;
|
|
96
|
+
};
|
|
81
97
|
|
|
82
98
|
interface MutationControllerState {
|
|
83
99
|
isLoading: boolean;
|
|
@@ -103,4 +119,4 @@ interface CreateMutationControllerOptions<TData, TArgs extends unknown[], TConte
|
|
|
103
119
|
*/
|
|
104
120
|
declare function createMutationController<TData, TArgs extends unknown[], TContext = void>(options: CreateMutationControllerOptions<TData, TArgs, TContext>): MutationController<TData, TArgs, TContext>;
|
|
105
121
|
|
|
106
|
-
export { type AuthSyncBinding, type CreateMutationControllerOptions, type KoraAppLike, type KoraBindingSyncBridge, type KoraBindingSyncStatus, type KoraContextValue, type MutationController, type MutationControllerState, type UseMutationOptions, type UseMutationResultBase, type UseQueryOptions, createMutationController };
|
|
122
|
+
export { type AuthSyncBinding, type AuthSyncState, type CreateMutationControllerOptions, type KoraAppLike, type KoraBindingSyncBridge, type KoraBindingSyncStatus, type KoraContextValue, type MutationController, type MutationControllerState, type UseMutationOptions, type UseMutationResultBase, type UseQueryOptions, createMutationController };
|
package/dist/bindings/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { p as KoraEventEmitter } from '../events-
|
|
2
|
-
import { S as ScopeMap } from '../build-scope-map-
|
|
1
|
+
import { p as KoraEventEmitter } from '../events-BPbYUbrE.js';
|
|
2
|
+
import { S as ScopeMap } from '../build-scope-map-B3R_emUU.js';
|
|
3
3
|
|
|
4
4
|
/** Sync status shape consumed by framework binding hooks (matches {@link SyncStatusInfo} in `@korajs/sync`). */
|
|
5
5
|
interface KoraBindingSyncStatus {
|
|
6
|
-
status: 'connected' | 'reconnecting' | 'syncing' | 'synced' | 'offline' | 'error' | 'schema-mismatch' | 'clock-error';
|
|
6
|
+
status: 'connected' | 'reconnecting' | 'syncing' | 'synced' | 'offline' | 'error' | 'schema-mismatch' | 'clock-error' | 'auth-required';
|
|
7
7
|
reconnecting: boolean;
|
|
8
8
|
pendingOperations: number;
|
|
9
9
|
lastSyncedAt: number | null;
|
|
@@ -66,6 +66,8 @@ interface AuthSyncBinding {
|
|
|
66
66
|
auth: () => Promise<{
|
|
67
67
|
token: string;
|
|
68
68
|
}>;
|
|
69
|
+
/** Resolve whether sync may currently open a transport. Tokens are never used as readiness signals. */
|
|
70
|
+
resolveSyncState?: () => Promise<AuthSyncState>;
|
|
69
71
|
/** Builds a scope map from the current token and schema. */
|
|
70
72
|
resolveScopeMap?: () => Promise<ScopeMap | undefined>;
|
|
71
73
|
/**
|
|
@@ -78,6 +80,20 @@ interface AuthSyncBinding {
|
|
|
78
80
|
/** Notifies when auth state changes so sync can refresh scope or reconnect. */
|
|
79
81
|
subscribe?: (listener: () => void) => () => void;
|
|
80
82
|
}
|
|
83
|
+
/** Authentication state consumed by the sync and auth-isolated store lifecycles. */
|
|
84
|
+
type AuthSyncState = {
|
|
85
|
+
state: 'loading';
|
|
86
|
+
} | {
|
|
87
|
+
state: 'signed-out';
|
|
88
|
+
mayConnectAnonymously: false;
|
|
89
|
+
} | {
|
|
90
|
+
state: 'anonymous';
|
|
91
|
+
mayConnectAnonymously: true;
|
|
92
|
+
} | {
|
|
93
|
+
state: 'authenticated';
|
|
94
|
+
userId: string;
|
|
95
|
+
token: string;
|
|
96
|
+
};
|
|
81
97
|
|
|
82
98
|
interface MutationControllerState {
|
|
83
99
|
isLoading: boolean;
|
|
@@ -103,4 +119,4 @@ interface CreateMutationControllerOptions<TData, TArgs extends unknown[], TConte
|
|
|
103
119
|
*/
|
|
104
120
|
declare function createMutationController<TData, TArgs extends unknown[], TContext = void>(options: CreateMutationControllerOptions<TData, TArgs, TContext>): MutationController<TData, TArgs, TContext>;
|
|
105
121
|
|
|
106
|
-
export { type AuthSyncBinding, type CreateMutationControllerOptions, type KoraAppLike, type KoraBindingSyncBridge, type KoraBindingSyncStatus, type KoraContextValue, type MutationController, type MutationControllerState, type UseMutationOptions, type UseMutationResultBase, type UseQueryOptions, createMutationController };
|
|
122
|
+
export { type AuthSyncBinding, type AuthSyncState, type CreateMutationControllerOptions, type KoraAppLike, type KoraBindingSyncBridge, type KoraBindingSyncStatus, type KoraContextValue, type MutationController, type MutationControllerState, type UseMutationOptions, type UseMutationResultBase, type UseQueryOptions, createMutationController };
|
|
@@ -486,7 +486,7 @@ interface BlobRef {
|
|
|
486
486
|
*/
|
|
487
487
|
interface SyncDiagnosticsSnapshot {
|
|
488
488
|
/** Current developer-facing sync status */
|
|
489
|
-
status: 'connected' | 'reconnecting' | 'syncing' | 'synced' | 'offline' | 'error' | 'schema-mismatch' | 'clock-error';
|
|
489
|
+
status: 'connected' | 'reconnecting' | 'syncing' | 'synced' | 'offline' | 'error' | 'schema-mismatch' | 'clock-error' | 'auth-required';
|
|
490
490
|
/** Timestamp when the current connection was established, or null if disconnected */
|
|
491
491
|
connectedAt: number | null;
|
|
492
492
|
/** Timestamp when the last disconnection occurred, or null if never disconnected */
|
|
@@ -738,6 +738,16 @@ interface SequenceConfig {
|
|
|
738
738
|
startAt?: number;
|
|
739
739
|
}
|
|
740
740
|
|
|
741
|
+
interface SyncApplyFailureEvent {
|
|
742
|
+
operationId: string;
|
|
743
|
+
collection: string;
|
|
744
|
+
recordId: string;
|
|
745
|
+
code: string;
|
|
746
|
+
message: string;
|
|
747
|
+
retriable: boolean;
|
|
748
|
+
firstSeenAt: number;
|
|
749
|
+
retryCount: number;
|
|
750
|
+
}
|
|
741
751
|
/**
|
|
742
752
|
* Trace of a merge decision. Records all inputs and outputs for debugging and DevTools.
|
|
743
753
|
*/
|
|
@@ -795,6 +805,21 @@ type KoraEvent = {
|
|
|
795
805
|
} | {
|
|
796
806
|
type: 'sync:auth-failed';
|
|
797
807
|
reason: string;
|
|
808
|
+
} | {
|
|
809
|
+
type: 'sync:suspended';
|
|
810
|
+
reason: 'auth-loading' | 'auth-required' | 'auth-rejected' | 'device-revoked' | string;
|
|
811
|
+
} | {
|
|
812
|
+
type: 'sync:apply-blocked';
|
|
813
|
+
failure: SyncApplyFailureEvent;
|
|
814
|
+
} | {
|
|
815
|
+
type: 'sync:apply-retrying';
|
|
816
|
+
failure: SyncApplyFailureEvent;
|
|
817
|
+
} | {
|
|
818
|
+
type: 'sync:apply-recovered';
|
|
819
|
+
failure: SyncApplyFailureEvent;
|
|
820
|
+
} | {
|
|
821
|
+
type: 'sync:apply-abandoned';
|
|
822
|
+
failure: SyncApplyFailureEvent;
|
|
798
823
|
} | {
|
|
799
824
|
type: 'sync:clock-skew';
|
|
800
825
|
/** serverTime - localTime in ms. Negative = this device's clock is fast. */
|
|
@@ -486,7 +486,7 @@ interface BlobRef {
|
|
|
486
486
|
*/
|
|
487
487
|
interface SyncDiagnosticsSnapshot {
|
|
488
488
|
/** Current developer-facing sync status */
|
|
489
|
-
status: 'connected' | 'reconnecting' | 'syncing' | 'synced' | 'offline' | 'error' | 'schema-mismatch' | 'clock-error';
|
|
489
|
+
status: 'connected' | 'reconnecting' | 'syncing' | 'synced' | 'offline' | 'error' | 'schema-mismatch' | 'clock-error' | 'auth-required';
|
|
490
490
|
/** Timestamp when the current connection was established, or null if disconnected */
|
|
491
491
|
connectedAt: number | null;
|
|
492
492
|
/** Timestamp when the last disconnection occurred, or null if never disconnected */
|
|
@@ -738,6 +738,16 @@ interface SequenceConfig {
|
|
|
738
738
|
startAt?: number;
|
|
739
739
|
}
|
|
740
740
|
|
|
741
|
+
interface SyncApplyFailureEvent {
|
|
742
|
+
operationId: string;
|
|
743
|
+
collection: string;
|
|
744
|
+
recordId: string;
|
|
745
|
+
code: string;
|
|
746
|
+
message: string;
|
|
747
|
+
retriable: boolean;
|
|
748
|
+
firstSeenAt: number;
|
|
749
|
+
retryCount: number;
|
|
750
|
+
}
|
|
741
751
|
/**
|
|
742
752
|
* Trace of a merge decision. Records all inputs and outputs for debugging and DevTools.
|
|
743
753
|
*/
|
|
@@ -795,6 +805,21 @@ type KoraEvent = {
|
|
|
795
805
|
} | {
|
|
796
806
|
type: 'sync:auth-failed';
|
|
797
807
|
reason: string;
|
|
808
|
+
} | {
|
|
809
|
+
type: 'sync:suspended';
|
|
810
|
+
reason: 'auth-loading' | 'auth-required' | 'auth-rejected' | 'device-revoked' | string;
|
|
811
|
+
} | {
|
|
812
|
+
type: 'sync:apply-blocked';
|
|
813
|
+
failure: SyncApplyFailureEvent;
|
|
814
|
+
} | {
|
|
815
|
+
type: 'sync:apply-retrying';
|
|
816
|
+
failure: SyncApplyFailureEvent;
|
|
817
|
+
} | {
|
|
818
|
+
type: 'sync:apply-recovered';
|
|
819
|
+
failure: SyncApplyFailureEvent;
|
|
820
|
+
} | {
|
|
821
|
+
type: 'sync:apply-abandoned';
|
|
822
|
+
failure: SyncApplyFailureEvent;
|
|
798
823
|
} | {
|
|
799
824
|
type: 'sync:clock-skew';
|
|
800
825
|
/** serverTime - localTime in ms. Negative = this device's clock is fast. */
|