@sparkvault/sdk-mobile 5.2.1 → 5.2.2
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/notify.d.ts +17 -4
- package/dist/notify.js.map +1 -1
- package/dist/notify.test-d.d.ts +31 -0
- package/dist/notify.test-d.js +18 -0
- package/dist/notify.test-d.js.map +1 -0
- package/package.json +1 -1
- package/src/notify.test-d.ts +42 -0
- package/src/notify.ts +17 -4
package/dist/notify.d.ts
CHANGED
|
@@ -28,13 +28,26 @@ export interface NotificationRow {
|
|
|
28
28
|
read_at: number | null;
|
|
29
29
|
archived_at: number | null;
|
|
30
30
|
/**
|
|
31
|
-
* The grant to open. Present only
|
|
32
|
-
*
|
|
33
|
-
*
|
|
31
|
+
* The grant to open. Present only while a live reveal stands behind it — a
|
|
32
|
+
* SEALED (secure) send that has not been recalled. A cleartext send delivers its
|
|
33
|
+
* content inline in the channel and mints no grant; a recalled row's grant is
|
|
34
|
+
* revoked and the pointer is withheld rather than echoed. Guard before building
|
|
35
|
+
* a URL from it.
|
|
34
36
|
*/
|
|
35
37
|
sparklink_code?: string;
|
|
36
|
-
/**
|
|
38
|
+
/**
|
|
39
|
+
* True only when there is a secure part left to reveal — exactly when
|
|
40
|
+
* `sparklink_code` is present. `false` does NOT mean "cleartext row": a recalled
|
|
41
|
+
* row is unlocked too, with nothing behind it. Branch on `recalled` before
|
|
42
|
+
* treating an unlocked row as plain text.
|
|
43
|
+
*/
|
|
37
44
|
locked: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* The sender took this notification back. The grant is revoked and
|
|
47
|
+
* `sparklink_code` is withheld, so render "no longer available" rather than a
|
|
48
|
+
* tap-to-reveal that opens nothing.
|
|
49
|
+
*/
|
|
50
|
+
recalled: boolean;
|
|
38
51
|
thread_id?: string;
|
|
39
52
|
}
|
|
40
53
|
export interface ListNotificationsOptions {
|
package/dist/notify.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notify.js","sourceRoot":"","sources":["../src/notify.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"notify.js","sourceRoot":"","sources":["../src/notify.ts"],"names":[],"mappings":"AAkIA;;;;GAIG;AACH,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAE/B;;;;;GAKG;AACH,MAAM,OAAO,kBAAkB;IAG7B,YAAY,IAAsB;QAChC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,kDAAkD;IAClD,KAAK,CAAC,QAAQ,CAAC,UAAoC,EAAE;QACnD,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;QACrC,IAAI,OAAO,CAAC,KAAK;YAAE,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;QACtD,IAAI,OAAO,CAAC,KAAK;YAAE,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;QAC9D,IAAI,OAAO,CAAC,MAAM;YAAE,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;QAEzD,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;QAChC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAClC,KAAK,CAAC,CAAC,CAAC,qBAAqB,KAAK,EAAE,CAAC,CAAC,CAAC,mBAAmB,CAC3D,CAAC;QACF,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;IAED,6DAA6D;IAC7D,KAAK,CAAC,cAAc;QAClB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAsB,gCAAgC,CAAC,CAAC;QAC5F,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,SAAS,CACb,cAAsB,EACtB,OAAqC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AAO,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IACtC,CAAC;IAED,6EAA6E;IAC7E,KAAK,CAAC,cAAc,CAAC,SAAiB;QACpC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAyB,2BAA2B,EAAE;YACzF,UAAU,EAAE,SAAS;SACtB,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,qBAAqB,CAAC,SAAiB;QAC3C,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,2BAA2B,EAAE,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;IACtF,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,gBAAgB,CAAC,SAAiB;QACtC,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,6BAA6B,kBAAkB,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IACvF,CAAC;CACF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Notify wire-contract assertions — COMPILE-TIME ONLY.
|
|
3
|
+
*
|
|
4
|
+
* `NotificationRow` has no runtime, so a unit test can never catch it drifting
|
|
5
|
+
* from the server: the transpiler strips it and every assertion passes. This file
|
|
6
|
+
* is the gate instead — `tsc --noEmit` (`pnpm typecheck`, which CI runs on every
|
|
7
|
+
* push and again on every SDK publish) fails the moment the published row stops
|
|
8
|
+
* matching what `apps/api` actually emits.
|
|
9
|
+
*
|
|
10
|
+
* It is deliberately NOT a `*.test.ts`: that suffix is excluded from `tsconfig`,
|
|
11
|
+
* which would put these assertions exactly where the compiler cannot see them.
|
|
12
|
+
*
|
|
13
|
+
* The row shape is shared verbatim with `@sparkvault/sdk-js`, whose own contract
|
|
14
|
+
* file asserts the same three members — both must move together, and the mirrored
|
|
15
|
+
* server source is `apps/api/src/notify/inbox.js` (`projectRow`).
|
|
16
|
+
*/
|
|
17
|
+
import type { NotificationRow } from './notify.js';
|
|
18
|
+
/** Fails to compile unless `T` resolves to exactly `true`. */
|
|
19
|
+
type Assert<T extends true> = T;
|
|
20
|
+
/**
|
|
21
|
+
* Invariant type equality — `A` and `B` must be the SAME type, not merely mutually
|
|
22
|
+
* assignable. Assignability would accept an optional member where the wire always
|
|
23
|
+
* carries one, which is the precise drift these assertions exist to catch.
|
|
24
|
+
*/
|
|
25
|
+
type Equals<A, B> = (<T>() => T extends A ? 1 : 2) extends <T>() => T extends B ? 1 : 2 ? true : false;
|
|
26
|
+
export type NotifyWireContract = [
|
|
27
|
+
Assert<Equals<NotificationRow['recalled'], boolean>>,
|
|
28
|
+
Assert<Equals<NotificationRow['locked'], boolean>>,
|
|
29
|
+
Assert<Equals<NotificationRow['sparklink_code'], string | undefined>>
|
|
30
|
+
];
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Notify wire-contract assertions — COMPILE-TIME ONLY.
|
|
3
|
+
*
|
|
4
|
+
* `NotificationRow` has no runtime, so a unit test can never catch it drifting
|
|
5
|
+
* from the server: the transpiler strips it and every assertion passes. This file
|
|
6
|
+
* is the gate instead — `tsc --noEmit` (`pnpm typecheck`, which CI runs on every
|
|
7
|
+
* push and again on every SDK publish) fails the moment the published row stops
|
|
8
|
+
* matching what `apps/api` actually emits.
|
|
9
|
+
*
|
|
10
|
+
* It is deliberately NOT a `*.test.ts`: that suffix is excluded from `tsconfig`,
|
|
11
|
+
* which would put these assertions exactly where the compiler cannot see them.
|
|
12
|
+
*
|
|
13
|
+
* The row shape is shared verbatim with `@sparkvault/sdk-js`, whose own contract
|
|
14
|
+
* file asserts the same three members — both must move together, and the mirrored
|
|
15
|
+
* server source is `apps/api/src/notify/inbox.js` (`projectRow`).
|
|
16
|
+
*/
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=notify.test-d.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notify.test-d.js","sourceRoot":"","sources":["../src/notify.test-d.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Notify wire-contract assertions — COMPILE-TIME ONLY.
|
|
3
|
+
*
|
|
4
|
+
* `NotificationRow` has no runtime, so a unit test can never catch it drifting
|
|
5
|
+
* from the server: the transpiler strips it and every assertion passes. This file
|
|
6
|
+
* is the gate instead — `tsc --noEmit` (`pnpm typecheck`, which CI runs on every
|
|
7
|
+
* push and again on every SDK publish) fails the moment the published row stops
|
|
8
|
+
* matching what `apps/api` actually emits.
|
|
9
|
+
*
|
|
10
|
+
* It is deliberately NOT a `*.test.ts`: that suffix is excluded from `tsconfig`,
|
|
11
|
+
* which would put these assertions exactly where the compiler cannot see them.
|
|
12
|
+
*
|
|
13
|
+
* The row shape is shared verbatim with `@sparkvault/sdk-js`, whose own contract
|
|
14
|
+
* file asserts the same three members — both must move together, and the mirrored
|
|
15
|
+
* server source is `apps/api/src/notify/inbox.js` (`projectRow`).
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import type { NotificationRow } from './notify.js';
|
|
19
|
+
|
|
20
|
+
/** Fails to compile unless `T` resolves to exactly `true`. */
|
|
21
|
+
type Assert<T extends true> = T;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Invariant type equality — `A` and `B` must be the SAME type, not merely mutually
|
|
25
|
+
* assignable. Assignability would accept an optional member where the wire always
|
|
26
|
+
* carries one, which is the precise drift these assertions exist to catch.
|
|
27
|
+
*/
|
|
28
|
+
type Equals<A, B> = (<T>() => T extends A ? 1 : 2) extends <T>() => T extends B ? 1 : 2
|
|
29
|
+
? true
|
|
30
|
+
: false;
|
|
31
|
+
|
|
32
|
+
export type NotifyWireContract = [
|
|
33
|
+
// `recalled` is `Boolean(row.recalled_at)`, so it is always on the wire: typing
|
|
34
|
+
// it optional would let the app skip the "no longer available" branch and fall
|
|
35
|
+
// through to a reveal that opens nothing.
|
|
36
|
+
Assert<Equals<NotificationRow['recalled'], boolean>>,
|
|
37
|
+
// `locked` is `!recalled && Boolean(row.sparklink_code)` — always present.
|
|
38
|
+
Assert<Equals<NotificationRow['locked'], boolean>>,
|
|
39
|
+
// The pointer is withheld on a recalled row and absent on a cleartext one, so
|
|
40
|
+
// it is optional in both directions and must be guarded before use.
|
|
41
|
+
Assert<Equals<NotificationRow['sparklink_code'], string | undefined>>,
|
|
42
|
+
];
|
package/src/notify.ts
CHANGED
|
@@ -31,13 +31,26 @@ export interface NotificationRow {
|
|
|
31
31
|
read_at: number | null;
|
|
32
32
|
archived_at: number | null;
|
|
33
33
|
/**
|
|
34
|
-
* The grant to open. Present only
|
|
35
|
-
*
|
|
36
|
-
*
|
|
34
|
+
* The grant to open. Present only while a live reveal stands behind it — a
|
|
35
|
+
* SEALED (secure) send that has not been recalled. A cleartext send delivers its
|
|
36
|
+
* content inline in the channel and mints no grant; a recalled row's grant is
|
|
37
|
+
* revoked and the pointer is withheld rather than echoed. Guard before building
|
|
38
|
+
* a URL from it.
|
|
37
39
|
*/
|
|
38
40
|
sparklink_code?: string;
|
|
39
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* True only when there is a secure part left to reveal — exactly when
|
|
43
|
+
* `sparklink_code` is present. `false` does NOT mean "cleartext row": a recalled
|
|
44
|
+
* row is unlocked too, with nothing behind it. Branch on `recalled` before
|
|
45
|
+
* treating an unlocked row as plain text.
|
|
46
|
+
*/
|
|
40
47
|
locked: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* The sender took this notification back. The grant is revoked and
|
|
50
|
+
* `sparklink_code` is withheld, so render "no longer available" rather than a
|
|
51
|
+
* tap-to-reveal that opens nothing.
|
|
52
|
+
*/
|
|
53
|
+
recalled: boolean;
|
|
41
54
|
thread_id?: string;
|
|
42
55
|
}
|
|
43
56
|
|