@interncom/diplomatic 0.3.2 → 0.3.3

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.
@@ -10,7 +10,10 @@ export declare const HOSTS_TABLE = "hosts";
10
10
  export declare const UPLOAD_QUEUE_TABLE = "uploadQueue";
11
11
  export declare const DOWNLOAD_QUEUE_TABLE = "downloadQueue";
12
12
  export declare const MESSAGES_TABLE = "messages";
13
- /** Index on messages.apld — pending apply is apld === false. */
13
+ /**
14
+ * Index on messages.apld. Values are "f" (pending) / "t" (applied) —
15
+ * booleans are not valid IndexedDB keys; single-char strings keep keys compact.
16
+ */
14
17
  export declare const MESSAGES_APLD_INDEX = "apld";
15
18
  /** Schema version: v3 adds messages.apld index for the apply queue. */
16
19
  export declare const DIPLOMATIC_STORE_DB_VERSION = 3;
@@ -77,15 +77,17 @@ export interface IStoredMessageFields {
77
77
  body?: EncodedMessage;
78
78
  }
79
79
  /**
80
- * What may come back from IDB (pre-apld rows can omit the field).
80
+ * What may come back from storage (pre-apld rows can omit the field).
81
+ * IDB stores "t"|"f" (booleans are not valid IndexedDB index keys).
81
82
  * Prefer {@link normalizeStoredMessageData} before use.
82
83
  */
83
84
  export interface IStoredMessageData extends IStoredMessageFields {
84
- apld?: boolean;
85
+ apld?: boolean | "t" | "f";
85
86
  }
86
87
  /**
87
- * Required shape for every put into the message archive.
88
+ * Required shape for every put into the message archive (app/API layer).
88
89
  * Callers must set `apld` (false until applied, then true).
90
+ * The IDB adapter persists this as "t"|"f" for indexing.
89
91
  */
90
92
  export type IStoredMessageWrite = IStoredMessageFields & {
91
93
  apld: boolean;
@@ -100,7 +102,12 @@ export interface IStoredMessage {
100
102
  body?: EncodedMessage;
101
103
  applied: boolean;
102
104
  }
103
- /** Coerce legacy rows missing `apld` to pending (`false`). */
105
+ /**
106
+ * Coerce stored `apld` to boolean.
107
+ * Applied: true | "t". Pending: false | "f" | missing.
108
+ */
109
+ export declare function apldFromStored(v: unknown): boolean;
110
+ /** Coerce storage rows to the write shape with boolean apld. */
104
111
  export declare function normalizeStoredMessageData(data: IStoredMessageData): IStoredMessageWrite;
105
112
  /** Pending apply when not yet marked applied. */
106
113
  export declare function isPendingApply(data: IStoredMessageData): boolean;