@chipmobilesdk/rn-notification 0.6.0 → 0.7.0

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.
Files changed (647) hide show
  1. package/CHANGELOG.md +111 -0
  2. package/README.md +8 -6
  3. package/lib/commonjs/advanced.js +139 -0
  4. package/lib/commonjs/advanced.js.map +1 -0
  5. package/lib/commonjs/channel/migrate.js +246 -0
  6. package/lib/commonjs/channel/migrate.js.map +1 -0
  7. package/lib/commonjs/channel/tone-map.js +120 -0
  8. package/lib/commonjs/channel/tone-map.js.map +1 -0
  9. package/lib/commonjs/channel/validate-tone.js +61 -0
  10. package/lib/commonjs/channel/validate-tone.js.map +1 -0
  11. package/lib/commonjs/contract/channel.js +52 -0
  12. package/lib/commonjs/contract/channel.js.map +1 -0
  13. package/lib/commonjs/contract/diagnostics.js +25 -0
  14. package/lib/commonjs/contract/diagnostics.js.map +1 -0
  15. package/lib/commonjs/contract/errors.js +126 -0
  16. package/lib/commonjs/contract/errors.js.map +1 -0
  17. package/lib/commonjs/contract/hash.js +35 -0
  18. package/lib/commonjs/contract/hash.js.map +1 -0
  19. package/lib/commonjs/contract/index.js +94 -0
  20. package/lib/commonjs/contract/index.js.map +1 -0
  21. package/lib/commonjs/contract/interaction.js +37 -0
  22. package/lib/commonjs/contract/interaction.js.map +1 -0
  23. package/lib/commonjs/contract/notification.js +42 -0
  24. package/lib/commonjs/contract/notification.js.map +1 -0
  25. package/lib/commonjs/contract/permission.js +2 -0
  26. package/lib/commonjs/contract/permission.js.map +1 -0
  27. package/lib/commonjs/contract/reconcile.js +6 -0
  28. package/lib/commonjs/contract/reconcile.js.map +1 -0
  29. package/lib/commonjs/contract/recurrence.js +53 -0
  30. package/lib/commonjs/contract/recurrence.js.map +1 -0
  31. package/lib/commonjs/diagnostics/burst.js +89 -0
  32. package/lib/commonjs/diagnostics/burst.js.map +1 -0
  33. package/lib/commonjs/diagnostics/events.js +63 -0
  34. package/lib/commonjs/diagnostics/events.js.map +1 -0
  35. package/lib/commonjs/diagnostics/redact.js +48 -0
  36. package/lib/commonjs/diagnostics/redact.js.map +1 -0
  37. package/lib/commonjs/diagnostics/snapshot.js +68 -0
  38. package/lib/commonjs/diagnostics/snapshot.js.map +1 -0
  39. package/lib/commonjs/engine/adapter.js +6 -0
  40. package/lib/commonjs/engine/adapter.js.map +1 -0
  41. package/lib/commonjs/engine/codec.js +84 -0
  42. package/lib/commonjs/engine/codec.js.map +1 -0
  43. package/lib/commonjs/engine/notify-kit/events.js +148 -0
  44. package/lib/commonjs/engine/notify-kit/events.js.map +1 -0
  45. package/lib/commonjs/engine/notify-kit/module.js +119 -0
  46. package/lib/commonjs/engine/notify-kit/module.js.map +1 -0
  47. package/lib/commonjs/engine/notify-kit/platform/android.js +159 -0
  48. package/lib/commonjs/engine/notify-kit/platform/android.js.map +1 -0
  49. package/lib/commonjs/engine/notify-kit/platform/index.js +57 -0
  50. package/lib/commonjs/engine/notify-kit/platform/index.js.map +1 -0
  51. package/lib/commonjs/engine/notify-kit/platform/ios.js +54 -0
  52. package/lib/commonjs/engine/notify-kit/platform/ios.js.map +1 -0
  53. package/lib/commonjs/engine/notify-kit/platform/types.js +6 -0
  54. package/lib/commonjs/engine/notify-kit/platform/types.js.map +1 -0
  55. package/lib/commonjs/engine/notify-kit-engine.js +260 -0
  56. package/lib/commonjs/engine/notify-kit-engine.js.map +1 -0
  57. package/lib/commonjs/index.js +367 -0
  58. package/lib/commonjs/index.js.map +1 -0
  59. package/lib/commonjs/initialize.js +187 -0
  60. package/lib/commonjs/initialize.js.map +1 -0
  61. package/lib/commonjs/interaction/index.js +120 -0
  62. package/lib/commonjs/interaction/index.js.map +1 -0
  63. package/lib/commonjs/maintenance/cycle.js +108 -0
  64. package/lib/commonjs/maintenance/cycle.js.map +1 -0
  65. package/lib/commonjs/maintenance/permission-refresh.js +39 -0
  66. package/lib/commonjs/maintenance/permission-refresh.js.map +1 -0
  67. package/lib/commonjs/maintenance/reanchor.js +99 -0
  68. package/lib/commonjs/maintenance/reanchor.js.map +1 -0
  69. package/lib/commonjs/maintenance/toggle.js +50 -0
  70. package/lib/commonjs/maintenance/toggle.js.map +1 -0
  71. package/lib/commonjs/maintenance/verify.js +70 -0
  72. package/lib/commonjs/maintenance/verify.js.map +1 -0
  73. package/lib/commonjs/maintenance/window-refresh.js +53 -0
  74. package/lib/commonjs/maintenance/window-refresh.js.map +1 -0
  75. package/lib/commonjs/notifications.js +161 -0
  76. package/lib/commonjs/notifications.js.map +1 -0
  77. package/lib/commonjs/package.json +1 -0
  78. package/lib/commonjs/permission/index.js +182 -0
  79. package/lib/commonjs/permission/index.js.map +1 -0
  80. package/lib/commonjs/permission/state.js +92 -0
  81. package/lib/commonjs/permission/state.js.map +1 -0
  82. package/lib/commonjs/push/envelope.js +141 -0
  83. package/lib/commonjs/push/envelope.js.map +1 -0
  84. package/lib/commonjs/push/fcm-provider.js +122 -0
  85. package/lib/commonjs/push/fcm-provider.js.map +1 -0
  86. package/lib/commonjs/push/gate.js +162 -0
  87. package/lib/commonjs/push/gate.js.map +1 -0
  88. package/lib/commonjs/push/index.js +47 -0
  89. package/lib/commonjs/push/index.js.map +1 -0
  90. package/lib/commonjs/push/instructions.js +101 -0
  91. package/lib/commonjs/push/instructions.js.map +1 -0
  92. package/lib/commonjs/push/provider-adapter.js +6 -0
  93. package/lib/commonjs/push/provider-adapter.js.map +1 -0
  94. package/lib/commonjs/push/signout.js +55 -0
  95. package/lib/commonjs/push/signout.js.map +1 -0
  96. package/lib/commonjs/reconcile/chunk.js +49 -0
  97. package/lib/commonjs/reconcile/chunk.js.map +1 -0
  98. package/lib/commonjs/reconcile/diff.js +105 -0
  99. package/lib/commonjs/reconcile/diff.js.map +1 -0
  100. package/lib/commonjs/reconcile/duplicates.js +60 -0
  101. package/lib/commonjs/reconcile/duplicates.js.map +1 -0
  102. package/lib/commonjs/reconcile/index.js +164 -0
  103. package/lib/commonjs/reconcile/index.js.map +1 -0
  104. package/lib/commonjs/reconcile/truncate.js +50 -0
  105. package/lib/commonjs/reconcile/truncate.js.map +1 -0
  106. package/lib/commonjs/recurrence/clock-guard.js +65 -0
  107. package/lib/commonjs/recurrence/clock-guard.js.map +1 -0
  108. package/lib/commonjs/recurrence/expand.js +254 -0
  109. package/lib/commonjs/recurrence/expand.js.map +1 -0
  110. package/lib/commonjs/recurrence/index.js +212 -0
  111. package/lib/commonjs/recurrence/index.js.map +1 -0
  112. package/lib/commonjs/repeat/expiry.js +41 -0
  113. package/lib/commonjs/repeat/expiry.js.map +1 -0
  114. package/lib/commonjs/repeat/index.js +100 -0
  115. package/lib/commonjs/repeat/index.js.map +1 -0
  116. package/lib/commonjs/repeat/marker.js +58 -0
  117. package/lib/commonjs/repeat/marker.js.map +1 -0
  118. package/lib/commonjs/repeat/place.js +83 -0
  119. package/lib/commonjs/repeat/place.js.map +1 -0
  120. package/lib/commonjs/schedule/anchor.js +243 -0
  121. package/lib/commonjs/schedule/anchor.js.map +1 -0
  122. package/lib/commonjs/schedule/index.js +142 -0
  123. package/lib/commonjs/schedule/index.js.map +1 -0
  124. package/lib/commonjs/schedule/partition.js +59 -0
  125. package/lib/commonjs/schedule/partition.js.map +1 -0
  126. package/lib/commonjs/schedule/resolve-moment.js +72 -0
  127. package/lib/commonjs/schedule/resolve-moment.js.map +1 -0
  128. package/lib/commonjs/schedule/validate-content.js +101 -0
  129. package/lib/commonjs/schedule/validate-content.js.map +1 -0
  130. package/lib/commonjs/schedule/validate-identifier.js +126 -0
  131. package/lib/commonjs/schedule/validate-identifier.js.map +1 -0
  132. package/lib/commonjs/schedule/writer.js +44 -0
  133. package/lib/commonjs/schedule/writer.js.map +1 -0
  134. package/lib/commonjs/state/caps.js +101 -0
  135. package/lib/commonjs/state/caps.js.map +1 -0
  136. package/lib/commonjs/state/dedup-ledger.js +39 -0
  137. package/lib/commonjs/state/dedup-ledger.js.map +1 -0
  138. package/lib/commonjs/state/interaction-buffer.js +98 -0
  139. package/lib/commonjs/state/interaction-buffer.js.map +1 -0
  140. package/lib/commonjs/state/mmkv-store.js +75 -0
  141. package/lib/commonjs/state/mmkv-store.js.map +1 -0
  142. package/lib/commonjs/state/permission-history.js +64 -0
  143. package/lib/commonjs/state/permission-history.js.map +1 -0
  144. package/lib/commonjs/state/record.js +269 -0
  145. package/lib/commonjs/state/record.js.map +1 -0
  146. package/lib/commonjs/state/reset.js +37 -0
  147. package/lib/commonjs/state/reset.js.map +1 -0
  148. package/lib/commonjs/state/series-ledger.js +71 -0
  149. package/lib/commonjs/state/series-ledger.js.map +1 -0
  150. package/lib/commonjs/state/store.js +39 -0
  151. package/lib/commonjs/state/store.js.map +1 -0
  152. package/lib/commonjs/testing/conformance/index.js +218 -0
  153. package/lib/commonjs/testing/conformance/index.js.map +1 -0
  154. package/lib/commonjs/testing/fake-engine.js +338 -0
  155. package/lib/commonjs/testing/fake-engine.js.map +1 -0
  156. package/lib/commonjs/testing/fake-provider.js +93 -0
  157. package/lib/commonjs/testing/fake-provider.js.map +1 -0
  158. package/lib/commonjs/testing/faults.js +59 -0
  159. package/lib/commonjs/testing/faults.js.map +1 -0
  160. package/lib/commonjs/testing/index.js +54 -0
  161. package/lib/commonjs/testing/index.js.map +1 -0
  162. package/lib/commonjs/testing/measure.js +298 -0
  163. package/lib/commonjs/testing/measure.js.map +1 -0
  164. package/lib/module/advanced.js +29 -0
  165. package/lib/module/advanced.js.map +1 -0
  166. package/lib/module/channel/migrate.js +242 -0
  167. package/lib/module/channel/migrate.js.map +1 -0
  168. package/lib/module/channel/tone-map.js +112 -0
  169. package/lib/module/channel/tone-map.js.map +1 -0
  170. package/lib/module/channel/validate-tone.js +57 -0
  171. package/lib/module/channel/validate-tone.js.map +1 -0
  172. package/lib/module/contract/channel.js +48 -0
  173. package/lib/module/contract/channel.js.map +1 -0
  174. package/lib/module/contract/diagnostics.js +21 -0
  175. package/lib/module/contract/diagnostics.js.map +1 -0
  176. package/lib/module/contract/errors.js +119 -0
  177. package/lib/module/contract/errors.js.map +1 -0
  178. package/lib/module/contract/hash.js +29 -0
  179. package/lib/module/contract/hash.js.map +1 -0
  180. package/lib/module/contract/index.js +13 -0
  181. package/lib/module/contract/index.js.map +1 -0
  182. package/lib/module/contract/interaction.js +33 -0
  183. package/lib/module/contract/interaction.js.map +1 -0
  184. package/lib/module/contract/notification.js +38 -0
  185. package/lib/module/contract/notification.js.map +1 -0
  186. package/lib/module/contract/permission.js +2 -0
  187. package/lib/module/contract/permission.js.map +1 -0
  188. package/lib/module/contract/reconcile.js +4 -0
  189. package/lib/module/contract/reconcile.js.map +1 -0
  190. package/lib/module/contract/recurrence.js +49 -0
  191. package/lib/module/contract/recurrence.js.map +1 -0
  192. package/lib/module/diagnostics/burst.js +85 -0
  193. package/lib/module/diagnostics/burst.js.map +1 -0
  194. package/lib/module/diagnostics/events.js +58 -0
  195. package/lib/module/diagnostics/events.js.map +1 -0
  196. package/lib/module/diagnostics/redact.js +44 -0
  197. package/lib/module/diagnostics/redact.js.map +1 -0
  198. package/lib/module/diagnostics/snapshot.js +64 -0
  199. package/lib/module/diagnostics/snapshot.js.map +1 -0
  200. package/lib/module/engine/adapter.js +4 -0
  201. package/lib/module/engine/adapter.js.map +1 -0
  202. package/lib/module/engine/codec.js +79 -0
  203. package/lib/module/engine/codec.js.map +1 -0
  204. package/lib/module/engine/notify-kit/events.js +139 -0
  205. package/lib/module/engine/notify-kit/events.js.map +1 -0
  206. package/lib/module/engine/notify-kit/module.js +113 -0
  207. package/lib/module/engine/notify-kit/module.js.map +1 -0
  208. package/lib/module/engine/notify-kit/platform/android.js +155 -0
  209. package/lib/module/engine/notify-kit/platform/android.js.map +1 -0
  210. package/lib/module/engine/notify-kit/platform/index.js +51 -0
  211. package/lib/module/engine/notify-kit/platform/index.js.map +1 -0
  212. package/lib/module/engine/notify-kit/platform/ios.js +49 -0
  213. package/lib/module/engine/notify-kit/platform/ios.js.map +1 -0
  214. package/lib/module/engine/notify-kit/platform/types.js +4 -0
  215. package/lib/module/engine/notify-kit/platform/types.js.map +1 -0
  216. package/lib/module/engine/notify-kit-engine.js +257 -0
  217. package/lib/module/engine/notify-kit-engine.js.map +1 -0
  218. package/lib/module/index.js +98 -0
  219. package/lib/module/index.js.map +1 -0
  220. package/lib/module/initialize.js +182 -0
  221. package/lib/module/initialize.js.map +1 -0
  222. package/lib/module/interaction/index.js +116 -0
  223. package/lib/module/interaction/index.js.map +1 -0
  224. package/lib/module/maintenance/cycle.js +102 -0
  225. package/lib/module/maintenance/cycle.js.map +1 -0
  226. package/lib/module/maintenance/permission-refresh.js +34 -0
  227. package/lib/module/maintenance/permission-refresh.js.map +1 -0
  228. package/lib/module/maintenance/reanchor.js +94 -0
  229. package/lib/module/maintenance/reanchor.js.map +1 -0
  230. package/lib/module/maintenance/toggle.js +45 -0
  231. package/lib/module/maintenance/toggle.js.map +1 -0
  232. package/lib/module/maintenance/verify.js +65 -0
  233. package/lib/module/maintenance/verify.js.map +1 -0
  234. package/lib/module/maintenance/window-refresh.js +48 -0
  235. package/lib/module/maintenance/window-refresh.js.map +1 -0
  236. package/lib/module/notifications.js +157 -0
  237. package/lib/module/notifications.js.map +1 -0
  238. package/lib/module/package.json +1 -0
  239. package/lib/module/permission/index.js +178 -0
  240. package/lib/module/permission/index.js.map +1 -0
  241. package/lib/module/permission/state.js +83 -0
  242. package/lib/module/permission/state.js.map +1 -0
  243. package/lib/module/push/envelope.js +137 -0
  244. package/lib/module/push/envelope.js.map +1 -0
  245. package/lib/module/push/fcm-provider.js +119 -0
  246. package/lib/module/push/fcm-provider.js.map +1 -0
  247. package/lib/module/push/gate.js +158 -0
  248. package/lib/module/push/gate.js.map +1 -0
  249. package/lib/module/push/index.js +16 -0
  250. package/lib/module/push/index.js.map +1 -0
  251. package/lib/module/push/instructions.js +97 -0
  252. package/lib/module/push/instructions.js.map +1 -0
  253. package/lib/module/push/provider-adapter.js +4 -0
  254. package/lib/module/push/provider-adapter.js.map +1 -0
  255. package/lib/module/push/signout.js +51 -0
  256. package/lib/module/push/signout.js.map +1 -0
  257. package/lib/module/reconcile/chunk.js +43 -0
  258. package/lib/module/reconcile/chunk.js.map +1 -0
  259. package/lib/module/reconcile/diff.js +101 -0
  260. package/lib/module/reconcile/diff.js.map +1 -0
  261. package/lib/module/reconcile/duplicates.js +56 -0
  262. package/lib/module/reconcile/duplicates.js.map +1 -0
  263. package/lib/module/reconcile/index.js +161 -0
  264. package/lib/module/reconcile/index.js.map +1 -0
  265. package/lib/module/reconcile/truncate.js +46 -0
  266. package/lib/module/reconcile/truncate.js.map +1 -0
  267. package/lib/module/recurrence/clock-guard.js +60 -0
  268. package/lib/module/recurrence/clock-guard.js.map +1 -0
  269. package/lib/module/recurrence/expand.js +248 -0
  270. package/lib/module/recurrence/expand.js.map +1 -0
  271. package/lib/module/recurrence/index.js +208 -0
  272. package/lib/module/recurrence/index.js.map +1 -0
  273. package/lib/module/repeat/expiry.js +37 -0
  274. package/lib/module/repeat/expiry.js.map +1 -0
  275. package/lib/module/repeat/index.js +67 -0
  276. package/lib/module/repeat/index.js.map +1 -0
  277. package/lib/module/repeat/marker.js +51 -0
  278. package/lib/module/repeat/marker.js.map +1 -0
  279. package/lib/module/repeat/place.js +79 -0
  280. package/lib/module/repeat/place.js.map +1 -0
  281. package/lib/module/schedule/anchor.js +234 -0
  282. package/lib/module/schedule/anchor.js.map +1 -0
  283. package/lib/module/schedule/index.js +137 -0
  284. package/lib/module/schedule/index.js.map +1 -0
  285. package/lib/module/schedule/partition.js +53 -0
  286. package/lib/module/schedule/partition.js.map +1 -0
  287. package/lib/module/schedule/resolve-moment.js +66 -0
  288. package/lib/module/schedule/resolve-moment.js.map +1 -0
  289. package/lib/module/schedule/validate-content.js +95 -0
  290. package/lib/module/schedule/validate-content.js.map +1 -0
  291. package/lib/module/schedule/validate-identifier.js +119 -0
  292. package/lib/module/schedule/validate-identifier.js.map +1 -0
  293. package/lib/module/schedule/writer.js +40 -0
  294. package/lib/module/schedule/writer.js.map +1 -0
  295. package/lib/module/state/caps.js +96 -0
  296. package/lib/module/state/caps.js.map +1 -0
  297. package/lib/module/state/dedup-ledger.js +34 -0
  298. package/lib/module/state/dedup-ledger.js.map +1 -0
  299. package/lib/module/state/interaction-buffer.js +92 -0
  300. package/lib/module/state/interaction-buffer.js.map +1 -0
  301. package/lib/module/state/mmkv-store.js +71 -0
  302. package/lib/module/state/mmkv-store.js.map +1 -0
  303. package/lib/module/state/permission-history.js +56 -0
  304. package/lib/module/state/permission-history.js.map +1 -0
  305. package/lib/module/state/record.js +264 -0
  306. package/lib/module/state/record.js.map +1 -0
  307. package/lib/module/state/reset.js +32 -0
  308. package/lib/module/state/reset.js.map +1 -0
  309. package/lib/module/state/series-ledger.js +62 -0
  310. package/lib/module/state/series-ledger.js.map +1 -0
  311. package/lib/module/state/store.js +35 -0
  312. package/lib/module/state/store.js.map +1 -0
  313. package/lib/module/testing/conformance/index.js +214 -0
  314. package/lib/module/testing/conformance/index.js.map +1 -0
  315. package/lib/module/testing/fake-engine.js +335 -0
  316. package/lib/module/testing/fake-engine.js.map +1 -0
  317. package/lib/module/testing/fake-provider.js +89 -0
  318. package/lib/module/testing/fake-provider.js.map +1 -0
  319. package/lib/module/testing/faults.js +55 -0
  320. package/lib/module/testing/faults.js.map +1 -0
  321. package/lib/module/testing/index.js +19 -0
  322. package/lib/module/testing/index.js.map +1 -0
  323. package/lib/module/testing/measure.js +294 -0
  324. package/lib/module/testing/measure.js.map +1 -0
  325. package/lib/typescript/commonjs/advanced.d.ts +36 -0
  326. package/lib/typescript/commonjs/advanced.d.ts.map +1 -0
  327. package/lib/typescript/commonjs/channel/migrate.d.ts +38 -0
  328. package/lib/typescript/commonjs/channel/migrate.d.ts.map +1 -0
  329. package/lib/typescript/commonjs/channel/tone-map.d.ts +34 -0
  330. package/lib/typescript/commonjs/channel/tone-map.d.ts.map +1 -0
  331. package/lib/typescript/commonjs/channel/validate-tone.d.ts +23 -0
  332. package/lib/typescript/commonjs/channel/validate-tone.d.ts.map +1 -0
  333. package/lib/typescript/commonjs/contract/channel.d.ts +185 -0
  334. package/lib/typescript/commonjs/contract/channel.d.ts.map +1 -0
  335. package/lib/typescript/commonjs/contract/diagnostics.d.ts +92 -0
  336. package/lib/typescript/commonjs/contract/diagnostics.d.ts.map +1 -0
  337. package/lib/typescript/commonjs/contract/errors.d.ts +91 -0
  338. package/lib/typescript/commonjs/contract/errors.d.ts.map +1 -0
  339. package/lib/typescript/commonjs/contract/hash.d.ts +14 -0
  340. package/lib/typescript/commonjs/contract/hash.d.ts.map +1 -0
  341. package/lib/typescript/commonjs/contract/index.d.ts +10 -0
  342. package/lib/typescript/commonjs/contract/index.d.ts.map +1 -0
  343. package/lib/typescript/commonjs/contract/interaction.d.ts +53 -0
  344. package/lib/typescript/commonjs/contract/interaction.d.ts.map +1 -0
  345. package/lib/typescript/commonjs/contract/notification.d.ts +110 -0
  346. package/lib/typescript/commonjs/contract/notification.d.ts.map +1 -0
  347. package/lib/typescript/commonjs/contract/permission.d.ts +49 -0
  348. package/lib/typescript/commonjs/contract/permission.d.ts.map +1 -0
  349. package/lib/typescript/commonjs/contract/reconcile.d.ts +82 -0
  350. package/lib/typescript/commonjs/contract/reconcile.d.ts.map +1 -0
  351. package/lib/typescript/commonjs/contract/recurrence.d.ts +118 -0
  352. package/lib/typescript/commonjs/contract/recurrence.d.ts.map +1 -0
  353. package/lib/typescript/commonjs/diagnostics/burst.d.ts +39 -0
  354. package/lib/typescript/commonjs/diagnostics/burst.d.ts.map +1 -0
  355. package/lib/typescript/commonjs/diagnostics/events.d.ts +28 -0
  356. package/lib/typescript/commonjs/diagnostics/events.d.ts.map +1 -0
  357. package/lib/typescript/commonjs/diagnostics/redact.d.ts +22 -0
  358. package/lib/typescript/commonjs/diagnostics/redact.d.ts.map +1 -0
  359. package/lib/typescript/commonjs/diagnostics/snapshot.d.ts +40 -0
  360. package/lib/typescript/commonjs/diagnostics/snapshot.d.ts.map +1 -0
  361. package/lib/typescript/commonjs/engine/adapter.d.ts +172 -0
  362. package/lib/typescript/commonjs/engine/adapter.d.ts.map +1 -0
  363. package/lib/typescript/commonjs/engine/codec.d.ts +20 -0
  364. package/lib/typescript/commonjs/engine/codec.d.ts.map +1 -0
  365. package/lib/typescript/commonjs/engine/notify-kit/events.d.ts +37 -0
  366. package/lib/typescript/commonjs/engine/notify-kit/events.d.ts.map +1 -0
  367. package/lib/typescript/commonjs/engine/notify-kit/module.d.ts +103 -0
  368. package/lib/typescript/commonjs/engine/notify-kit/module.d.ts.map +1 -0
  369. package/lib/typescript/commonjs/engine/notify-kit/platform/android.d.ts +3 -0
  370. package/lib/typescript/commonjs/engine/notify-kit/platform/android.d.ts.map +1 -0
  371. package/lib/typescript/commonjs/engine/notify-kit/platform/index.d.ts +12 -0
  372. package/lib/typescript/commonjs/engine/notify-kit/platform/index.d.ts.map +1 -0
  373. package/lib/typescript/commonjs/engine/notify-kit/platform/ios.d.ts +3 -0
  374. package/lib/typescript/commonjs/engine/notify-kit/platform/ios.d.ts.map +1 -0
  375. package/lib/typescript/commonjs/engine/notify-kit/platform/types.d.ts +33 -0
  376. package/lib/typescript/commonjs/engine/notify-kit/platform/types.d.ts.map +1 -0
  377. package/lib/typescript/commonjs/engine/notify-kit-engine.d.ts +25 -0
  378. package/lib/typescript/commonjs/engine/notify-kit-engine.d.ts.map +1 -0
  379. package/lib/typescript/commonjs/index.d.ts +106 -0
  380. package/lib/typescript/commonjs/index.d.ts.map +1 -0
  381. package/lib/typescript/commonjs/initialize.d.ts +74 -0
  382. package/lib/typescript/commonjs/initialize.d.ts.map +1 -0
  383. package/lib/typescript/commonjs/interaction/index.d.ts +53 -0
  384. package/lib/typescript/commonjs/interaction/index.d.ts.map +1 -0
  385. package/lib/typescript/commonjs/maintenance/cycle.d.ts +77 -0
  386. package/lib/typescript/commonjs/maintenance/cycle.d.ts.map +1 -0
  387. package/lib/typescript/commonjs/maintenance/permission-refresh.d.ts +19 -0
  388. package/lib/typescript/commonjs/maintenance/permission-refresh.d.ts.map +1 -0
  389. package/lib/typescript/commonjs/maintenance/reanchor.d.ts +26 -0
  390. package/lib/typescript/commonjs/maintenance/reanchor.d.ts.map +1 -0
  391. package/lib/typescript/commonjs/maintenance/toggle.d.ts +35 -0
  392. package/lib/typescript/commonjs/maintenance/toggle.d.ts.map +1 -0
  393. package/lib/typescript/commonjs/maintenance/verify.d.ts +32 -0
  394. package/lib/typescript/commonjs/maintenance/verify.d.ts.map +1 -0
  395. package/lib/typescript/commonjs/maintenance/window-refresh.d.ts +29 -0
  396. package/lib/typescript/commonjs/maintenance/window-refresh.d.ts.map +1 -0
  397. package/lib/typescript/commonjs/notifications.d.ts +78 -0
  398. package/lib/typescript/commonjs/notifications.d.ts.map +1 -0
  399. package/lib/typescript/commonjs/package.json +1 -0
  400. package/lib/typescript/commonjs/permission/index.d.ts +57 -0
  401. package/lib/typescript/commonjs/permission/index.d.ts.map +1 -0
  402. package/lib/typescript/commonjs/permission/state.d.ts +41 -0
  403. package/lib/typescript/commonjs/permission/state.d.ts.map +1 -0
  404. package/lib/typescript/commonjs/push/envelope.d.ts +33 -0
  405. package/lib/typescript/commonjs/push/envelope.d.ts.map +1 -0
  406. package/lib/typescript/commonjs/push/fcm-provider.d.ts +43 -0
  407. package/lib/typescript/commonjs/push/fcm-provider.d.ts.map +1 -0
  408. package/lib/typescript/commonjs/push/gate.d.ts +57 -0
  409. package/lib/typescript/commonjs/push/gate.d.ts.map +1 -0
  410. package/lib/typescript/commonjs/push/index.d.ts +19 -0
  411. package/lib/typescript/commonjs/push/index.d.ts.map +1 -0
  412. package/lib/typescript/commonjs/push/instructions.d.ts +45 -0
  413. package/lib/typescript/commonjs/push/instructions.d.ts.map +1 -0
  414. package/lib/typescript/commonjs/push/provider-adapter.d.ts +50 -0
  415. package/lib/typescript/commonjs/push/provider-adapter.d.ts.map +1 -0
  416. package/lib/typescript/commonjs/push/signout.d.ts +33 -0
  417. package/lib/typescript/commonjs/push/signout.d.ts.map +1 -0
  418. package/lib/typescript/commonjs/reconcile/chunk.d.ts +24 -0
  419. package/lib/typescript/commonjs/reconcile/chunk.d.ts.map +1 -0
  420. package/lib/typescript/commonjs/reconcile/diff.d.ts +54 -0
  421. package/lib/typescript/commonjs/reconcile/diff.d.ts.map +1 -0
  422. package/lib/typescript/commonjs/reconcile/duplicates.d.ts +32 -0
  423. package/lib/typescript/commonjs/reconcile/duplicates.d.ts.map +1 -0
  424. package/lib/typescript/commonjs/reconcile/index.d.ts +35 -0
  425. package/lib/typescript/commonjs/reconcile/index.d.ts.map +1 -0
  426. package/lib/typescript/commonjs/reconcile/truncate.d.ts +26 -0
  427. package/lib/typescript/commonjs/reconcile/truncate.d.ts.map +1 -0
  428. package/lib/typescript/commonjs/recurrence/clock-guard.d.ts +37 -0
  429. package/lib/typescript/commonjs/recurrence/clock-guard.d.ts.map +1 -0
  430. package/lib/typescript/commonjs/recurrence/expand.d.ts +75 -0
  431. package/lib/typescript/commonjs/recurrence/expand.d.ts.map +1 -0
  432. package/lib/typescript/commonjs/recurrence/index.d.ts +40 -0
  433. package/lib/typescript/commonjs/recurrence/index.d.ts.map +1 -0
  434. package/lib/typescript/commonjs/repeat/expiry.d.ts +23 -0
  435. package/lib/typescript/commonjs/repeat/expiry.d.ts.map +1 -0
  436. package/lib/typescript/commonjs/repeat/index.d.ts +49 -0
  437. package/lib/typescript/commonjs/repeat/index.d.ts.map +1 -0
  438. package/lib/typescript/commonjs/repeat/marker.d.ts +36 -0
  439. package/lib/typescript/commonjs/repeat/marker.d.ts.map +1 -0
  440. package/lib/typescript/commonjs/repeat/place.d.ts +39 -0
  441. package/lib/typescript/commonjs/repeat/place.d.ts.map +1 -0
  442. package/lib/typescript/commonjs/schedule/anchor.d.ts +118 -0
  443. package/lib/typescript/commonjs/schedule/anchor.d.ts.map +1 -0
  444. package/lib/typescript/commonjs/schedule/index.d.ts +40 -0
  445. package/lib/typescript/commonjs/schedule/index.d.ts.map +1 -0
  446. package/lib/typescript/commonjs/schedule/partition.d.ts +29 -0
  447. package/lib/typescript/commonjs/schedule/partition.d.ts.map +1 -0
  448. package/lib/typescript/commonjs/schedule/resolve-moment.d.ts +35 -0
  449. package/lib/typescript/commonjs/schedule/resolve-moment.d.ts.map +1 -0
  450. package/lib/typescript/commonjs/schedule/validate-content.d.ts +42 -0
  451. package/lib/typescript/commonjs/schedule/validate-content.d.ts.map +1 -0
  452. package/lib/typescript/commonjs/schedule/validate-identifier.d.ts +30 -0
  453. package/lib/typescript/commonjs/schedule/validate-identifier.d.ts.map +1 -0
  454. package/lib/typescript/commonjs/schedule/writer.d.ts +36 -0
  455. package/lib/typescript/commonjs/schedule/writer.d.ts.map +1 -0
  456. package/lib/typescript/commonjs/state/caps.d.ts +51 -0
  457. package/lib/typescript/commonjs/state/caps.d.ts.map +1 -0
  458. package/lib/typescript/commonjs/state/dedup-ledger.d.ts +21 -0
  459. package/lib/typescript/commonjs/state/dedup-ledger.d.ts.map +1 -0
  460. package/lib/typescript/commonjs/state/interaction-buffer.d.ts +30 -0
  461. package/lib/typescript/commonjs/state/interaction-buffer.d.ts.map +1 -0
  462. package/lib/typescript/commonjs/state/mmkv-store.d.ts +33 -0
  463. package/lib/typescript/commonjs/state/mmkv-store.d.ts.map +1 -0
  464. package/lib/typescript/commonjs/state/permission-history.d.ts +20 -0
  465. package/lib/typescript/commonjs/state/permission-history.d.ts.map +1 -0
  466. package/lib/typescript/commonjs/state/record.d.ts +134 -0
  467. package/lib/typescript/commonjs/state/record.d.ts.map +1 -0
  468. package/lib/typescript/commonjs/state/reset.d.ts +22 -0
  469. package/lib/typescript/commonjs/state/reset.d.ts.map +1 -0
  470. package/lib/typescript/commonjs/state/series-ledger.d.ts +47 -0
  471. package/lib/typescript/commonjs/state/series-ledger.d.ts.map +1 -0
  472. package/lib/typescript/commonjs/state/store.d.ts +20 -0
  473. package/lib/typescript/commonjs/state/store.d.ts.map +1 -0
  474. package/lib/typescript/commonjs/testing/conformance/index.d.ts +32 -0
  475. package/lib/typescript/commonjs/testing/conformance/index.d.ts.map +1 -0
  476. package/lib/typescript/commonjs/testing/fake-engine.d.ts +91 -0
  477. package/lib/typescript/commonjs/testing/fake-engine.d.ts.map +1 -0
  478. package/lib/typescript/commonjs/testing/fake-provider.d.ts +35 -0
  479. package/lib/typescript/commonjs/testing/fake-provider.d.ts.map +1 -0
  480. package/lib/typescript/commonjs/testing/faults.d.ts +38 -0
  481. package/lib/typescript/commonjs/testing/faults.d.ts.map +1 -0
  482. package/lib/typescript/commonjs/testing/index.d.ts +22 -0
  483. package/lib/typescript/commonjs/testing/index.d.ts.map +1 -0
  484. package/lib/typescript/commonjs/testing/measure.d.ts +59 -0
  485. package/lib/typescript/commonjs/testing/measure.d.ts.map +1 -0
  486. package/lib/typescript/module/advanced.d.ts +36 -0
  487. package/lib/typescript/module/advanced.d.ts.map +1 -0
  488. package/lib/typescript/module/channel/migrate.d.ts +38 -0
  489. package/lib/typescript/module/channel/migrate.d.ts.map +1 -0
  490. package/lib/typescript/module/channel/tone-map.d.ts +34 -0
  491. package/lib/typescript/module/channel/tone-map.d.ts.map +1 -0
  492. package/lib/typescript/module/channel/validate-tone.d.ts +23 -0
  493. package/lib/typescript/module/channel/validate-tone.d.ts.map +1 -0
  494. package/lib/typescript/module/contract/channel.d.ts +185 -0
  495. package/lib/typescript/module/contract/channel.d.ts.map +1 -0
  496. package/lib/typescript/module/contract/diagnostics.d.ts +92 -0
  497. package/lib/typescript/module/contract/diagnostics.d.ts.map +1 -0
  498. package/lib/typescript/module/contract/errors.d.ts +91 -0
  499. package/lib/typescript/module/contract/errors.d.ts.map +1 -0
  500. package/lib/typescript/module/contract/hash.d.ts +14 -0
  501. package/lib/typescript/module/contract/hash.d.ts.map +1 -0
  502. package/lib/typescript/module/contract/index.d.ts +10 -0
  503. package/lib/typescript/module/contract/index.d.ts.map +1 -0
  504. package/lib/typescript/module/contract/interaction.d.ts +53 -0
  505. package/lib/typescript/module/contract/interaction.d.ts.map +1 -0
  506. package/lib/typescript/module/contract/notification.d.ts +110 -0
  507. package/lib/typescript/module/contract/notification.d.ts.map +1 -0
  508. package/lib/typescript/module/contract/permission.d.ts +49 -0
  509. package/lib/typescript/module/contract/permission.d.ts.map +1 -0
  510. package/lib/typescript/module/contract/reconcile.d.ts +82 -0
  511. package/lib/typescript/module/contract/reconcile.d.ts.map +1 -0
  512. package/lib/typescript/module/contract/recurrence.d.ts +118 -0
  513. package/lib/typescript/module/contract/recurrence.d.ts.map +1 -0
  514. package/lib/typescript/module/diagnostics/burst.d.ts +39 -0
  515. package/lib/typescript/module/diagnostics/burst.d.ts.map +1 -0
  516. package/lib/typescript/module/diagnostics/events.d.ts +28 -0
  517. package/lib/typescript/module/diagnostics/events.d.ts.map +1 -0
  518. package/lib/typescript/module/diagnostics/redact.d.ts +22 -0
  519. package/lib/typescript/module/diagnostics/redact.d.ts.map +1 -0
  520. package/lib/typescript/module/diagnostics/snapshot.d.ts +40 -0
  521. package/lib/typescript/module/diagnostics/snapshot.d.ts.map +1 -0
  522. package/lib/typescript/module/engine/adapter.d.ts +172 -0
  523. package/lib/typescript/module/engine/adapter.d.ts.map +1 -0
  524. package/lib/typescript/module/engine/codec.d.ts +20 -0
  525. package/lib/typescript/module/engine/codec.d.ts.map +1 -0
  526. package/lib/typescript/module/engine/notify-kit/events.d.ts +37 -0
  527. package/lib/typescript/module/engine/notify-kit/events.d.ts.map +1 -0
  528. package/lib/typescript/module/engine/notify-kit/module.d.ts +103 -0
  529. package/lib/typescript/module/engine/notify-kit/module.d.ts.map +1 -0
  530. package/lib/typescript/module/engine/notify-kit/platform/android.d.ts +3 -0
  531. package/lib/typescript/module/engine/notify-kit/platform/android.d.ts.map +1 -0
  532. package/lib/typescript/module/engine/notify-kit/platform/index.d.ts +12 -0
  533. package/lib/typescript/module/engine/notify-kit/platform/index.d.ts.map +1 -0
  534. package/lib/typescript/module/engine/notify-kit/platform/ios.d.ts +3 -0
  535. package/lib/typescript/module/engine/notify-kit/platform/ios.d.ts.map +1 -0
  536. package/lib/typescript/module/engine/notify-kit/platform/types.d.ts +33 -0
  537. package/lib/typescript/module/engine/notify-kit/platform/types.d.ts.map +1 -0
  538. package/lib/typescript/module/engine/notify-kit-engine.d.ts +25 -0
  539. package/lib/typescript/module/engine/notify-kit-engine.d.ts.map +1 -0
  540. package/lib/typescript/module/index.d.ts +106 -0
  541. package/lib/typescript/module/index.d.ts.map +1 -0
  542. package/lib/typescript/module/initialize.d.ts +74 -0
  543. package/lib/typescript/module/initialize.d.ts.map +1 -0
  544. package/lib/typescript/module/interaction/index.d.ts +53 -0
  545. package/lib/typescript/module/interaction/index.d.ts.map +1 -0
  546. package/lib/typescript/module/maintenance/cycle.d.ts +77 -0
  547. package/lib/typescript/module/maintenance/cycle.d.ts.map +1 -0
  548. package/lib/typescript/module/maintenance/permission-refresh.d.ts +19 -0
  549. package/lib/typescript/module/maintenance/permission-refresh.d.ts.map +1 -0
  550. package/lib/typescript/module/maintenance/reanchor.d.ts +26 -0
  551. package/lib/typescript/module/maintenance/reanchor.d.ts.map +1 -0
  552. package/lib/typescript/module/maintenance/toggle.d.ts +35 -0
  553. package/lib/typescript/module/maintenance/toggle.d.ts.map +1 -0
  554. package/lib/typescript/module/maintenance/verify.d.ts +32 -0
  555. package/lib/typescript/module/maintenance/verify.d.ts.map +1 -0
  556. package/lib/typescript/module/maintenance/window-refresh.d.ts +29 -0
  557. package/lib/typescript/module/maintenance/window-refresh.d.ts.map +1 -0
  558. package/lib/typescript/module/notifications.d.ts +78 -0
  559. package/lib/typescript/module/notifications.d.ts.map +1 -0
  560. package/lib/typescript/module/package.json +1 -0
  561. package/lib/typescript/module/permission/index.d.ts +57 -0
  562. package/lib/typescript/module/permission/index.d.ts.map +1 -0
  563. package/lib/typescript/module/permission/state.d.ts +41 -0
  564. package/lib/typescript/module/permission/state.d.ts.map +1 -0
  565. package/lib/typescript/module/push/envelope.d.ts +33 -0
  566. package/lib/typescript/module/push/envelope.d.ts.map +1 -0
  567. package/lib/typescript/module/push/fcm-provider.d.ts +43 -0
  568. package/lib/typescript/module/push/fcm-provider.d.ts.map +1 -0
  569. package/lib/typescript/module/push/gate.d.ts +57 -0
  570. package/lib/typescript/module/push/gate.d.ts.map +1 -0
  571. package/lib/typescript/module/push/index.d.ts +19 -0
  572. package/lib/typescript/module/push/index.d.ts.map +1 -0
  573. package/lib/typescript/module/push/instructions.d.ts +45 -0
  574. package/lib/typescript/module/push/instructions.d.ts.map +1 -0
  575. package/lib/typescript/module/push/provider-adapter.d.ts +50 -0
  576. package/lib/typescript/module/push/provider-adapter.d.ts.map +1 -0
  577. package/lib/typescript/module/push/signout.d.ts +33 -0
  578. package/lib/typescript/module/push/signout.d.ts.map +1 -0
  579. package/lib/typescript/module/reconcile/chunk.d.ts +24 -0
  580. package/lib/typescript/module/reconcile/chunk.d.ts.map +1 -0
  581. package/lib/typescript/module/reconcile/diff.d.ts +54 -0
  582. package/lib/typescript/module/reconcile/diff.d.ts.map +1 -0
  583. package/lib/typescript/module/reconcile/duplicates.d.ts +32 -0
  584. package/lib/typescript/module/reconcile/duplicates.d.ts.map +1 -0
  585. package/lib/typescript/module/reconcile/index.d.ts +35 -0
  586. package/lib/typescript/module/reconcile/index.d.ts.map +1 -0
  587. package/lib/typescript/module/reconcile/truncate.d.ts +26 -0
  588. package/lib/typescript/module/reconcile/truncate.d.ts.map +1 -0
  589. package/lib/typescript/module/recurrence/clock-guard.d.ts +37 -0
  590. package/lib/typescript/module/recurrence/clock-guard.d.ts.map +1 -0
  591. package/lib/typescript/module/recurrence/expand.d.ts +75 -0
  592. package/lib/typescript/module/recurrence/expand.d.ts.map +1 -0
  593. package/lib/typescript/module/recurrence/index.d.ts +40 -0
  594. package/lib/typescript/module/recurrence/index.d.ts.map +1 -0
  595. package/lib/typescript/module/repeat/expiry.d.ts +23 -0
  596. package/lib/typescript/module/repeat/expiry.d.ts.map +1 -0
  597. package/lib/typescript/module/repeat/index.d.ts +49 -0
  598. package/lib/typescript/module/repeat/index.d.ts.map +1 -0
  599. package/lib/typescript/module/repeat/marker.d.ts +36 -0
  600. package/lib/typescript/module/repeat/marker.d.ts.map +1 -0
  601. package/lib/typescript/module/repeat/place.d.ts +39 -0
  602. package/lib/typescript/module/repeat/place.d.ts.map +1 -0
  603. package/lib/typescript/module/schedule/anchor.d.ts +118 -0
  604. package/lib/typescript/module/schedule/anchor.d.ts.map +1 -0
  605. package/lib/typescript/module/schedule/index.d.ts +40 -0
  606. package/lib/typescript/module/schedule/index.d.ts.map +1 -0
  607. package/lib/typescript/module/schedule/partition.d.ts +29 -0
  608. package/lib/typescript/module/schedule/partition.d.ts.map +1 -0
  609. package/lib/typescript/module/schedule/resolve-moment.d.ts +35 -0
  610. package/lib/typescript/module/schedule/resolve-moment.d.ts.map +1 -0
  611. package/lib/typescript/module/schedule/validate-content.d.ts +42 -0
  612. package/lib/typescript/module/schedule/validate-content.d.ts.map +1 -0
  613. package/lib/typescript/module/schedule/validate-identifier.d.ts +30 -0
  614. package/lib/typescript/module/schedule/validate-identifier.d.ts.map +1 -0
  615. package/lib/typescript/module/schedule/writer.d.ts +36 -0
  616. package/lib/typescript/module/schedule/writer.d.ts.map +1 -0
  617. package/lib/typescript/module/state/caps.d.ts +51 -0
  618. package/lib/typescript/module/state/caps.d.ts.map +1 -0
  619. package/lib/typescript/module/state/dedup-ledger.d.ts +21 -0
  620. package/lib/typescript/module/state/dedup-ledger.d.ts.map +1 -0
  621. package/lib/typescript/module/state/interaction-buffer.d.ts +30 -0
  622. package/lib/typescript/module/state/interaction-buffer.d.ts.map +1 -0
  623. package/lib/typescript/module/state/mmkv-store.d.ts +33 -0
  624. package/lib/typescript/module/state/mmkv-store.d.ts.map +1 -0
  625. package/lib/typescript/module/state/permission-history.d.ts +20 -0
  626. package/lib/typescript/module/state/permission-history.d.ts.map +1 -0
  627. package/lib/typescript/module/state/record.d.ts +134 -0
  628. package/lib/typescript/module/state/record.d.ts.map +1 -0
  629. package/lib/typescript/module/state/reset.d.ts +22 -0
  630. package/lib/typescript/module/state/reset.d.ts.map +1 -0
  631. package/lib/typescript/module/state/series-ledger.d.ts +47 -0
  632. package/lib/typescript/module/state/series-ledger.d.ts.map +1 -0
  633. package/lib/typescript/module/state/store.d.ts +20 -0
  634. package/lib/typescript/module/state/store.d.ts.map +1 -0
  635. package/lib/typescript/module/testing/conformance/index.d.ts +32 -0
  636. package/lib/typescript/module/testing/conformance/index.d.ts.map +1 -0
  637. package/lib/typescript/module/testing/fake-engine.d.ts +91 -0
  638. package/lib/typescript/module/testing/fake-engine.d.ts.map +1 -0
  639. package/lib/typescript/module/testing/fake-provider.d.ts +35 -0
  640. package/lib/typescript/module/testing/fake-provider.d.ts.map +1 -0
  641. package/lib/typescript/module/testing/faults.d.ts +38 -0
  642. package/lib/typescript/module/testing/faults.d.ts.map +1 -0
  643. package/lib/typescript/module/testing/index.d.ts +22 -0
  644. package/lib/typescript/module/testing/index.d.ts.map +1 -0
  645. package/lib/typescript/module/testing/measure.d.ts +59 -0
  646. package/lib/typescript/module/testing/measure.d.ts.map +1 -0
  647. package/package.json +72 -26
@@ -0,0 +1,234 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Time-zone anchoring and re-anchoring.
5
+ *
6
+ * Wall-clock is the default because reminders are wall-clock things: an 08:00
7
+ * reminder should stay 08:00 after the user crosses a time zone, and a caller
8
+ * who does not choose should get what their users expect rather than a silent
9
+ * shift.
10
+ *
11
+ * The cost is re-anchoring. When the device zone changes, every scheduled
12
+ * wall-clock entry must be rewritten to preserve the clock time it named, and
13
+ * every absolute entry must be left completely alone.
14
+ *
15
+ * The limit this cannot fix is stated rather than hidden: a wall-clock
16
+ * notification whose moment arrives while the app has not run since the zone
17
+ * changed fires at the previously anchored instant. The anchoring generation on
18
+ * each entry is what makes that detectable instead of invisible.
19
+ */
20
+
21
+ import { getDateTimeFormat, isValidTimeZone as isZoneValid, lazyPeer } from '@chipmobilesdk/rn-core';
22
+ import { DEFAULT_ANCHORING_MODE } from "../contract/notification.js";
23
+
24
+ /** Reads the platform time zone. Injected so the pure logic needs no native module. */
25
+
26
+ const localizePeer = lazyPeer('react-native-localize', () => {
27
+ // Inside `try`, so Metro bundles an app that leaves this optional peer out.
28
+ try {
29
+ return require('react-native-localize');
30
+ } catch (cause) {
31
+ throw cause;
32
+ }
33
+ });
34
+
35
+ /**
36
+ * Resolves the platform zone via `react-native-localize`.
37
+ *
38
+ * Pure JavaScript is not sufficient here: `Intl.DateTimeFormat().resolvedOptions().timeZone`
39
+ * is documented in React Native as not reliably updating when the device zone
40
+ * changes, so it cannot back re-anchoring. Falls back to `Intl` only when the
41
+ * module is absent, which is better than failing outright.
42
+ */
43
+ export function createPlatformTimeZoneReader() {
44
+ return () => {
45
+ const localize = localizePeer.get();
46
+ try {
47
+ if (localize.ok) return localize.module.getTimeZone();
48
+ return Intl.DateTimeFormat().resolvedOptions().timeZone ?? 'UTC';
49
+ } catch {
50
+ try {
51
+ return Intl.DateTimeFormat().resolvedOptions().timeZone ?? 'UTC';
52
+ } catch {
53
+ return 'UTC';
54
+ }
55
+ }
56
+ };
57
+ }
58
+
59
+ /** The calendar fields a wall-clock moment actually names. */
60
+
61
+ /**
62
+ * Whether a zone name is one the runtime can actually format against.
63
+ *
64
+ * Hermes throws a hard `JSRangeErrorException: Invalid timezone name!` for a
65
+ * bad zone, which kills the JavaScript thread rather than returning an error.
66
+ * A stored anchoring generation is data that can be wrong — a corrupted record,
67
+ * an entry written by an older build, or a defect like the one that stored a
68
+ * tone id here — so it must be checked before it reaches `Intl`.
69
+ */
70
+ export function isValidTimeZone(timeZone) {
71
+ // rn-core memoizes the answer per zone: a recurrence expansion asks thousands
72
+ // of times about the same few zones (PERF-01).
73
+ return isZoneValid(timeZone);
74
+ }
75
+
76
+ /** The options `partsInZone` formats with; one shared formatter per zone. */
77
+ const PARTS_OPTIONS = {
78
+ year: 'numeric',
79
+ month: '2-digit',
80
+ day: '2-digit',
81
+ hour: '2-digit',
82
+ minute: '2-digit',
83
+ second: '2-digit',
84
+ hour12: false
85
+ };
86
+
87
+ /**
88
+ * Decomposes an instant into the clock reading it produces in a given zone.
89
+ *
90
+ * Falls back to UTC for an unusable zone rather than throwing: a bad stored
91
+ * value should degrade one entry's anchoring, not crash the app.
92
+ */
93
+ export function partsInZone(instant, timeZone) {
94
+ const zone = isValidTimeZone(timeZone) ? timeZone : 'UTC';
95
+ // Built once per zone and reused (PERF-01): constructing one per call was
96
+ // most of the cost of expanding a recurrence.
97
+ const formatter = getDateTimeFormat('en-US', {
98
+ ...PARTS_OPTIONS,
99
+ timeZone: zone
100
+ });
101
+ const fields = {};
102
+ for (const part of formatter.formatToParts(new Date(instant))) {
103
+ if (part.type !== 'literal') {
104
+ fields[part.type] = Number.parseInt(part.value, 10);
105
+ }
106
+ }
107
+ return {
108
+ year: fields.year,
109
+ month: fields.month,
110
+ day: fields.day,
111
+ // Intl renders midnight as hour 24 in some environments; normalize it.
112
+ hour: fields.hour === 24 ? 0 : fields.hour,
113
+ minute: fields.minute,
114
+ second: fields.second
115
+ };
116
+ }
117
+
118
+ /** The zone's offset from UTC, in milliseconds, at a given instant. */
119
+ function offsetAt(instant, timeZone) {
120
+ const parts = partsInZone(instant, timeZone);
121
+ const asUtc = Date.UTC(parts.year, parts.month - 1, parts.day, parts.hour, parts.minute, parts.second);
122
+ return asUtc - Math.floor(instant / 1000) * 1000;
123
+ }
124
+
125
+ /**
126
+ * Finds the instant at which a zone shows the given clock reading.
127
+ *
128
+ * Two passes, because the offset itself depends on the instant: the first guess
129
+ * uses the offset at the naive UTC interpretation, the second corrects for a
130
+ * daylight-saving boundary crossed by that guess.
131
+ *
132
+ * Daylight-saving resolution, per the documented rule:
133
+ * - a clock time that does not exist resolves **forward** to the next valid instant;
134
+ * - a clock time that occurs twice resolves to its **first** occurrence, so
135
+ * exactly one notification results rather than two.
136
+ */
137
+ export function instantForParts(parts, timeZone) {
138
+ const naive = Date.UTC(parts.year, parts.month - 1, parts.day, parts.hour, parts.minute, parts.second);
139
+ let candidate = naive - offsetAt(naive, timeZone);
140
+ candidate = naive - offsetAt(candidate, timeZone);
141
+ const rendered = partsInZone(candidate, timeZone);
142
+ if (rendered.hour === parts.hour && rendered.minute === parts.minute) {
143
+ // Ambiguous readings (the repeated hour) land here on the first, earlier
144
+ // offset, which is the documented choice.
145
+ return candidate;
146
+ }
147
+
148
+ // The reading does not exist in this zone — a spring-forward gap. Step
149
+ // forward to the next instant that does exist rather than skipping the
150
+ // occurrence or failing.
151
+ const gapStep = 60 * 60 * 1000;
152
+ for (let attempt = 1; attempt <= 4; attempt += 1) {
153
+ const shifted = candidate + gapStep * attempt;
154
+ const shiftedParts = partsInZone(shifted, timeZone);
155
+ if (shiftedParts.day === parts.day || shiftedParts.hour > parts.hour) {
156
+ return shifted;
157
+ }
158
+ }
159
+ return candidate;
160
+ }
161
+ /**
162
+ * Resolves a caller-supplied moment into a firing instant.
163
+ *
164
+ * An absolute moment passes through untouched — that is the entire distinction.
165
+ */
166
+ export function anchorMoment(input, timeZone) {
167
+ const anchoring = input.anchoring ?? DEFAULT_ANCHORING_MODE;
168
+ if (anchoring === 'absolute') {
169
+ return {
170
+ resolvedAt: input.at,
171
+ anchoring
172
+ };
173
+ }
174
+ return {
175
+ resolvedAt: input.at,
176
+ anchoring,
177
+ generation: timeZone
178
+ };
179
+ }
180
+ /**
181
+ * Computes what a zone change requires.
182
+ *
183
+ * Returns an empty plan when the zone has not moved, which is what makes
184
+ * re-anchoring idempotent: the no-change check costs one comparison per entry
185
+ * and issues zero platform operations.
186
+ */
187
+ export function planReAnchor(pending, currentZone) {
188
+ const rewrites = [];
189
+ const unreadableGeneration = [];
190
+ let fromZone;
191
+ for (const entry of pending) {
192
+ // Absolute-instant entries are never re-anchored, re-scheduled, or touched.
193
+ if (entry.anchoring === 'absolute') continue;
194
+ const generation = entry.anchoringGeneration;
195
+ if (generation === undefined || generation === currentZone) continue;
196
+
197
+ // A stored generation is data, and data can be wrong. Re-anchoring against
198
+ // a zone the runtime cannot read would move the entry to an arbitrary
199
+ // instant, which is worse than leaving it where it is and saying so.
200
+ if (!isValidTimeZone(generation)) {
201
+ unreadableGeneration.push(entry.id);
202
+ continue;
203
+ }
204
+ fromZone ??= generation;
205
+
206
+ // Preserve the clock reading the entry originally named, not the instant.
207
+ const originalParts = partsInZone(entry.resolvedAt, generation);
208
+ const resolvedAt = instantForParts(originalParts, currentZone);
209
+ if (resolvedAt !== entry.resolvedAt) {
210
+ rewrites.push({
211
+ entry,
212
+ resolvedAt
213
+ });
214
+ }
215
+ }
216
+ return {
217
+ rewrites,
218
+ fromZone,
219
+ toZone: currentZone,
220
+ zoneChanged: rewrites.length > 0 || fromZone !== undefined,
221
+ unreadableGeneration
222
+ };
223
+ }
224
+
225
+ /**
226
+ * True when an entry was anchored against a zone the device has since left.
227
+ *
228
+ * This is the FR-007c condition: the entry will fire at its old instant, and a
229
+ * consumer can detect and explain that rather than being told nothing happened.
230
+ */
231
+ export function isStaleAnchor(entry, currentZone) {
232
+ return entry.anchoring === 'wallClock' && entry.anchoringGeneration !== undefined && entry.anchoringGeneration !== currentZone;
233
+ }
234
+ //# sourceMappingURL=anchor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getDateTimeFormat","isValidTimeZone","isZoneValid","lazyPeer","DEFAULT_ANCHORING_MODE","localizePeer","require","cause","createPlatformTimeZoneReader","localize","get","ok","module","getTimeZone","Intl","DateTimeFormat","resolvedOptions","timeZone","PARTS_OPTIONS","year","month","day","hour","minute","second","hour12","partsInZone","instant","zone","formatter","fields","part","formatToParts","Date","type","Number","parseInt","value","offsetAt","parts","asUtc","UTC","Math","floor","instantForParts","naive","candidate","rendered","gapStep","attempt","shifted","shiftedParts","anchorMoment","input","anchoring","resolvedAt","at","generation","planReAnchor","pending","currentZone","rewrites","unreadableGeneration","fromZone","entry","anchoringGeneration","undefined","push","id","originalParts","toZone","zoneChanged","length","isStaleAnchor"],"sourceRoot":"../../../src","sources":["schedule/anchor.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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CAACT,UAAU,EAAE;MACpCM,QAAQ,CAACM,IAAI,CAAC;QAAEH,KAAK;QAAET;MAAW,CAAC,CAAC;IACrC;EACD;EAEA,OAAO;IACNM,QAAQ;IACRE,QAAQ;IACRO,MAAM,EAAEV,WAAW;IACnBW,WAAW,EAAEV,QAAQ,CAACW,MAAM,GAAG,CAAC,IAAIT,QAAQ,KAAKG,SAAS;IAC1DJ;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASW,aAAaA,CAACT,KAAmB,EAAEJ,WAAmB,EAAW;EAChF,OACCI,KAAK,CAACV,SAAS,KAAK,WAAW,IAC/BU,KAAK,CAACC,mBAAmB,KAAKC,SAAS,IACvCF,KAAK,CAACC,mBAAmB,KAAKL,WAAW;AAE3C","ignoreList":[]}
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * The scheduling operations.
5
+ *
6
+ * Validation runs in a fixed order and completes entirely before any platform
7
+ * call: identifier, tags, content, moment shape, tone, actions, routing size.
8
+ * A caller therefore never sees a native-level error surface through the
9
+ * package, and a rejected request leaves the device untouched.
10
+ *
11
+ * Scheduling an identifier that already has a notification **replaces** it.
12
+ * That is the defined semantic rather than a side effect, which is what lets a
13
+ * caller stop tracking whether it has already scheduled something.
14
+ */
15
+
16
+ import { DIAGNOSTIC_CODES, NotificationError } from "../contract/errors.js";
17
+ import { MAX_ACTIONS_PER_NOTIFICATION, MAX_ROUTING_PAYLOAD_BYTES } from "../contract/interaction.js";
18
+ import { validateIdentifier, validateOptionalTag } from "./validate-identifier.js";
19
+ import { validateContent, byteLength } from "./validate-content.js";
20
+ import { resolveMoment, validateMoment } from "./resolve-moment.js";
21
+ import { anchorMoment } from "./anchor.js";
22
+ import { idsForTag } from "./partition.js";
23
+ import { createScheduleWriter } from "./writer.js";
24
+ /** Validates a request completely, before the engine is touched at all. */
25
+ export function validateRequest(request, resolveTone) {
26
+ validateIdentifier(request.id, 'id');
27
+ validateOptionalTag(request.ownerTag, 'ownerTag');
28
+ validateOptionalTag(request.groupTag, 'groupTag');
29
+ validateContent(request.content);
30
+ validateMoment(request.moment);
31
+ const tone = resolveTone(request.tone);
32
+ if (tone === undefined) {
33
+ throw new NotificationError(DIAGNOSTIC_CODES.UNDECLARED_TONE, `Tone "${request.tone}" was never declared in the package configuration. Declare it before scheduling against it.`, {
34
+ toneId: request.tone
35
+ });
36
+ }
37
+ if (request.actions !== undefined) {
38
+ if (request.actions.length > MAX_ACTIONS_PER_NOTIFICATION) {
39
+ throw new NotificationError(DIAGNOSTIC_CODES.TOO_MANY_ACTIONS, `A notification may carry at most ${MAX_ACTIONS_PER_NOTIFICATION} actions; ${request.actions.length} were supplied.`, {
40
+ count: request.actions.length,
41
+ limit: MAX_ACTIONS_PER_NOTIFICATION
42
+ });
43
+ }
44
+ for (const action of request.actions) {
45
+ validateIdentifier(action.id, 'actionId');
46
+ }
47
+ }
48
+ if (request.routing !== undefined) {
49
+ // Sized at schedule time rather than discovered as truncated at tap time,
50
+ // which is where an over-large payload would otherwise surface.
51
+ const size = byteLength(JSON.stringify(request.routing));
52
+ if (size > MAX_ROUTING_PAYLOAD_BYTES) {
53
+ throw new NotificationError(DIAGNOSTIC_CODES.ROUTING_PAYLOAD_TOO_LARGE, `Routing payload is ${size} bytes, over the ${MAX_ROUTING_PAYLOAD_BYTES}-byte limit.`, {
54
+ bytes: size,
55
+ limit: MAX_ROUTING_PAYLOAD_BYTES
56
+ });
57
+ }
58
+ }
59
+ return tone;
60
+ }
61
+ export function createScheduler(deps) {
62
+ const emit = deps.emit ?? (() => {});
63
+ const writer = createScheduleWriter(deps.engine);
64
+ const scheduleOne = async (request, options = {}) => {
65
+ const tone = validateRequest(request, deps.resolveTone);
66
+ const zone = deps.timeZone();
67
+ const anchored = anchorMoment(request.moment, zone);
68
+ const resolution = resolveMoment(anchored.resolvedAt, deps.now());
69
+
70
+ // Identifiers only where the engine can list them cheaply: reading every
71
+ // pending payload across the bridge just to answer "was this one already
72
+ // there" cost a full read per schedule (NOT-08).
73
+ const replaced = deps.engine.pendingIds ? (await deps.engine.pendingIds()).includes(request.id) : (await deps.engine.getPending()).some(entry => entry.id === request.id);
74
+
75
+ // Approximate mode is a degradation, not a refusal: the notification is
76
+ // still scheduled and the caller is told it may arrive late.
77
+ const approximate = !deps.canScheduleExactly();
78
+ if (approximate) {
79
+ emit(DIAGNOSTIC_CODES.EXACT_ALARM_UNAVAILABLE, 'Scheduled in approximate mode; delivery may be late.', {
80
+ id: request.id
81
+ });
82
+ }
83
+ await writer.write({
84
+ request,
85
+ resolvedAt: resolution.at,
86
+ tone,
87
+ // The zone this was anchored against, so `getPending` can report it and a
88
+ // consumer can detect a stale anchor (FR-007c). Absent for absolute
89
+ // moments, which are never anchored to a zone.
90
+ anchoringGeneration: anchored.generation,
91
+ approximate,
92
+ seriesId: options.seriesId,
93
+ pushCreated: options.pushCreated
94
+ });
95
+ return {
96
+ id: request.id,
97
+ resolvedAt: resolution.at,
98
+ anchoring: anchored.anchoring,
99
+ replaced,
100
+ deliveredImmediately: resolution.kind === 'immediate',
101
+ mayBeDelayed: approximate
102
+ };
103
+ };
104
+ return {
105
+ schedule: scheduleOne,
106
+ async cancel(id) {
107
+ validateIdentifier(id, 'id');
108
+ // A marker guarding a notification that no longer exists would fire
109
+ // against nothing. Harmless, but it holds platform capacity a real
110
+ // notification could use.
111
+ await writer.cancel(id);
112
+ },
113
+ async cancelByGroup(groupTag) {
114
+ validateIdentifier(groupTag, 'groupTag');
115
+ const ids = idsForTag(await deps.engine.getPending(), 'group', groupTag);
116
+ await deps.engine.cancelMany(ids);
117
+ const pass = writer.pass();
118
+ for (const id of ids) await pass.releaseStop(id);
119
+ return ids;
120
+ },
121
+ async cancelByOwner(ownerTag) {
122
+ validateIdentifier(ownerTag, 'ownerTag');
123
+ const ids = idsForTag(await deps.engine.getPending(), 'owner', ownerTag);
124
+ await deps.engine.cancelMany(ids);
125
+ const pass = writer.pass();
126
+ for (const id of ids) await pass.releaseStop(id);
127
+ return ids;
128
+ },
129
+ async cancelAll() {
130
+ await deps.engine.cancelAll();
131
+ },
132
+ async getPending() {
133
+ return deps.engine.getPending();
134
+ }
135
+ };
136
+ }
137
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["DIAGNOSTIC_CODES","NotificationError","MAX_ACTIONS_PER_NOTIFICATION","MAX_ROUTING_PAYLOAD_BYTES","validateIdentifier","validateOptionalTag","validateContent","byteLength","resolveMoment","validateMoment","anchorMoment","idsForTag","createScheduleWriter","validateRequest","request","resolveTone","id","ownerTag","groupTag","content","moment","tone","undefined","UNDECLARED_TONE","toneId","actions","length","TOO_MANY_ACTIONS","count","limit","action","routing","size","JSON","stringify","ROUTING_PAYLOAD_TOO_LARGE","bytes","createScheduler","deps","emit","writer","engine","scheduleOne","options","zone","timeZone","anchored","resolution","resolvedAt","now","replaced","pendingIds","includes","getPending","some","entry","approximate","canScheduleExactly","EXACT_ALARM_UNAVAILABLE","write","at","anchoringGeneration","generation","seriesId","pushCreated","anchoring","deliveredImmediately","kind","mayBeDelayed","schedule","cancel","cancelByGroup","ids","cancelMany","pass","releaseStop","cancelByOwner","cancelAll"],"sourceRoot":"../../../src","sources":["schedule/index.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA,SAASA,gBAAgB,EAAEC,iBAAiB,QAAQ,uBAAoB;AACxE,SAASC,4BAA4B,EAAEC,yBAAyB,QAAQ,4BAAyB;AACjG,SAASC,kBAAkB,EAAEC,mBAAmB,QAAQ,0BAAuB;AAC/E,SAASC,eAAe,EAAEC,UAAU,QAAQ,uBAAoB;AAChE,SAASC,aAAa,EAAEC,cAAc,QAAQ,qBAAkB;AAChE,SAASC,YAAY,QAA6B,aAAU;AAC5D,SAASC,SAAS,QAAQ,gBAAa;AACvC,SAASC,oBAAoB,QAAQ,aAAU;AAY/C;AACA,OAAO,SAASC,eAAeA,CAC9BC,O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AAK,MAAM1D,EAAE,IAAIwD,GAAG,EAAE,MAAME,IAAI,CAACC,WAAW,CAAC3D,EAAE,CAAC;MAChD,OAAOwD,GAAG;IACX,CAAC;IAED,MAAMI,aAAaA,CAAC3D,QAAgB,EAA8B;MACjEb,kBAAkB,CAACa,QAAQ,EAAE,UAAU,CAAC;MACxC,MAAMuD,GAAG,GAAG7D,SAAS,CAAC,MAAM2B,IAAI,CAACG,MAAM,CAACY,UAAU,CAAC,CAAC,EAAE,OAAO,EAAEpC,QAAQ,CAAC;MACxE,MAAMqB,IAAI,CAACG,MAAM,CAACgC,UAAU,CAACD,GAAG,CAAC;MACjC,MAAME,IAAI,GAAGlC,MAAM,CAACkC,IAAI,CAAC,CAAC;MAC1B,KAAK,MAAM1D,EAAE,IAAIwD,GAAG,EAAE,MAAME,IAAI,CAACC,WAAW,CAAC3D,EAAE,CAAC;MAChD,OAAOwD,GAAG;IACX,CAAC;IAED,MAAMK,SAASA,CAAA,EAAkB;MAChC,MAAMvC,IAAI,CAACG,MAAM,CAACoC,SAAS,CAAC,CAAC;IAC9B,CAAC;IAED,MAAMxB,UAAUA,CAAA,EAAqC;MACpD,OAAOf,IAAI,CAACG,MAAM,CAACY,UAAU,CAAC,CAAC;IAChC;EACD,CAAC;AACF","ignoreList":[]}
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Owner-tag and group-tag partitioning.
5
+ *
6
+ * A tag is an opaque label the caller supplies and the package never
7
+ * interprets. That is deliberate: modelling identity would mean acquiring an
8
+ * opinion about it, and this package is forbidden from knowing anything about
9
+ * accounts, tenants, or users.
10
+ *
11
+ * What the tag buys is one call — "clear this account's notifications" — on a
12
+ * shared device, without the package ever learning what an account is.
13
+ */
14
+
15
+ /** Selects entries carrying a tag. Comparison is exact; nothing is normalized. */
16
+ export function selectByTag(entries, kind, tag) {
17
+ return entries.filter(entry => kind === 'owner' ? entry.ownerTag === tag : entry.groupTag === tag);
18
+ }
19
+
20
+ /** Identifiers to cancel for a tag. */
21
+ export function idsForTag(entries, kind, tag) {
22
+ return selectByTag(entries, kind, tag).map(entry => entry.id);
23
+ }
24
+
25
+ /**
26
+ * Groups entries by a tag, keeping untagged entries under a distinct bucket.
27
+ *
28
+ * Untagged is not the same as any tag: an entry with no owner belongs to no
29
+ * account, and folding it into one would make a sign-out delete notifications
30
+ * that were never that account's.
31
+ */
32
+ export function partition(entries, kind) {
33
+ const tagged = new Map();
34
+ const untagged = [];
35
+ for (const entry of entries) {
36
+ const tag = kind === 'owner' ? entry.ownerTag : entry.groupTag;
37
+ if (tag === undefined) {
38
+ untagged.push(entry);
39
+ continue;
40
+ }
41
+ const bucket = tagged.get(tag);
42
+ if (bucket === undefined) {
43
+ tagged.set(tag, [entry]);
44
+ } else {
45
+ bucket.push(entry);
46
+ }
47
+ }
48
+ return {
49
+ tagged,
50
+ untagged
51
+ };
52
+ }
53
+ //# sourceMappingURL=partition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["selectByTag","entries","kind","tag","filter","entry","ownerTag","groupTag","idsForTag","map","id","partition","tagged","Map","untagged","undefined","push","bucket","get","set"],"sourceRoot":"../../../src","sources":["schedule/partition.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA,OAAO,SAASA,WAAWA,CAC1BC,OAAgC,EAChCC,IAAmB,EACnBC,GAAW,EACe;EAC1B,OAAOF,OAAO,CAACG,MAAM,CAACC,KAAK,IAC1BH,IAAI,KAAK,OAAO,GAAGG,KAAK,CAACC,QAAQ,KAAKH,GAAG,GAAGE,KAAK,CAACE,QAAQ,KAAKJ,GAChE,CAAC;AACF;;AAEA;AACA,OAAO,SAASK,SAASA,CACxBP,OAAgC,EAChCC,IAAmB,EACnBC,GAAW,EACS;EACpB,OAAOH,WAAW,CAACC,OAAO,EAAEC,IAAI,EAAEC,GAAG,CAAC,CAACM,GAAG,CAACJ,KAAK,IAAIA,KAAK,CAACK,EAAE,CAAC;AAC9D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,SAASA,CACxBV,OAAgC,EAChCC,IAAmB,EAIlB;EACD,MAAMU,MAAM,GAAG,IAAIC,GAAG,CAAyB,CAAC;EAChD,MAAMC,QAAwB,GAAG,EAAE;EAEnC,KAAK,MAAMT,KAAK,IAAIJ,OAAO,EAAE;IAC5B,MAAME,GAAG,GAAGD,IAAI,KAAK,OAAO,GAAGG,KAAK,CAACC,QAAQ,GAAGD,KAAK,CAACE,QAAQ;IAC9D,IAAIJ,GAAG,KAAKY,SAAS,EAAE;MACtBD,QAAQ,CAACE,IAAI,CAACX,KAAK,CAAC;MACpB;IACD;IACA,MAAMY,MAAM,GAAGL,MAAM,CAACM,GAAG,CAACf,GAAG,CAAC;IAC9B,IAAIc,MAAM,KAAKF,SAAS,EAAE;MACzBH,MAAM,CAACO,GAAG,CAAChB,GAAG,EAAE,CAACE,KAAK,CAAC,CAAC;IACzB,CAAC,MAAM;MACNY,MAAM,CAACD,IAAI,CAACX,KAAK,CAAC;IACnB;EACD;EAEA,OAAO;IAAEO,MAAM;IAAEE;EAAS,CAAC;AAC5B","ignoreList":[]}
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Delivery moment resolution.
5
+ *
6
+ * Two rules, and they are two sides of one decision rather than a threshold:
7
+ * a moment more than the tolerance in the past is a caller error and is
8
+ * refused; a moment a few seconds in the past is a processing delay and is
9
+ * delivered promptly. Both outcomes are reported, so a caller never has to
10
+ * guess which happened.
11
+ *
12
+ * Sixty seconds is long enough to absorb reconciling a large desired set, cold
13
+ * start work, and clock skew, and short enough that a genuinely stale schedule
14
+ * is still caught rather than fired at the user minutes late with no
15
+ * explanation.
16
+ */
17
+
18
+ import { DIAGNOSTIC_CODES, NotificationError } from "../contract/errors.js";
19
+ export const PAST_TOLERANCE_MS = 60_000;
20
+ /**
21
+ * Classifies a resolved instant against now.
22
+ *
23
+ * Takes an already-anchored instant: anchoring decides *which* instant a moment
24
+ * means, and this decides whether that instant is usable. Keeping them separate
25
+ * is what lets each be tested without the other.
26
+ */
27
+ export function resolveMoment(resolvedAt, now) {
28
+ if (!Number.isFinite(resolvedAt)) {
29
+ throw new NotificationError(DIAGNOSTIC_CODES.MOMENT_IN_PAST, 'A delivery moment must be a finite epoch-millisecond timestamp.', {
30
+ received: String(resolvedAt)
31
+ });
32
+ }
33
+ if (resolvedAt >= now) {
34
+ return {
35
+ kind: 'future',
36
+ at: resolvedAt
37
+ };
38
+ }
39
+ const lateBy = now - resolvedAt;
40
+ if (lateBy <= PAST_TOLERANCE_MS) {
41
+ return {
42
+ kind: 'immediate',
43
+ at: now,
44
+ lateBy
45
+ };
46
+ }
47
+ throw new NotificationError(DIAGNOSTIC_CODES.MOMENT_IN_PAST, `Delivery moment is ${Math.round(lateBy / 1000)}s in the past, beyond the ${PAST_TOLERANCE_MS / 1000}s tolerance. ` + 'It was not scheduled, because handing it to the platform would fire it immediately without explanation.', {
48
+ lateByMs: lateBy,
49
+ toleranceMs: PAST_TOLERANCE_MS
50
+ });
51
+ }
52
+
53
+ /** Validates the shape of a caller-supplied moment before anchoring resolves it. */
54
+ export function validateMoment(moment) {
55
+ if (typeof moment.at !== 'number' || !Number.isFinite(moment.at)) {
56
+ throw new NotificationError(DIAGNOSTIC_CODES.MOMENT_IN_PAST, 'A delivery moment must carry a finite epoch-millisecond `at` value.', {
57
+ received: typeof moment.at
58
+ });
59
+ }
60
+ if (moment.anchoring !== undefined && moment.anchoring !== 'wallClock' && moment.anchoring !== 'absolute') {
61
+ throw new NotificationError(DIAGNOSTIC_CODES.MOMENT_IN_PAST, 'Anchoring must be either "wallClock" or "absolute".', {
62
+ received: String(moment.anchoring)
63
+ });
64
+ }
65
+ }
66
+ //# sourceMappingURL=resolve-moment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["DIAGNOSTIC_CODES","NotificationError","PAST_TOLERANCE_MS","resolveMoment","resolvedAt","now","Number","isFinite","MOMENT_IN_PAST","received","String","kind","at","lateBy","Math","round","lateByMs","toleranceMs","validateMoment","moment","anchoring","undefined"],"sourceRoot":"../../../src","sources":["schedule/resolve-moment.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,gBAAgB,EAAEC,iBAAiB,QAAQ,uBAAoB;AAGxE,OAAO,MAAMC,iBAAiB,GAAG,MAAM;AAMvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAACC,UAAkB,EAAEC,GAAW,EAAoB;EAChF,IAAI,CAACC,MAAM,CAACC,QAAQ,CAACH,UAAU,CAAC,EAAE;IACjC,MAAM,IAAIH,iBAAiB,CAC1BD,gBAAgB,CAACQ,cAAc,EAC/B,iEAAiE,EACjE;MAAEC,QAAQ,EAAEC,MAAM,CAACN,UAAU;IAAE,CAChC,CAAC;EACF;EAEA,IAAIA,UAAU,IAAIC,GAAG,EAAE;IACtB,OAAO;MAAEM,IAAI,EAAE,QAAQ;MAAEC,EAAE,EAAER;IAAW,CAAC;EAC1C;EAEA,MAAMS,MAAM,GAAGR,GAAG,GAAGD,UAAU;EAE/B,IAAIS,MAAM,IAAIX,iBAAiB,EAAE;IAChC,OAAO;MAAES,IAAI,EAAE,WAAW;MAAEC,EAAE,EAAEP,GAAG;MAAEQ;IAAO,CAAC;EAC9C;EAEA,MAAM,IAAIZ,iBAAiB,CAC1BD,gBAAgB,CAACQ,cAAc,EAC/B,sBAAsBM,IAAI,CAACC,KAAK,CAACF,MAAM,GAAG,IAAI,CAAC,6BAA6BX,iBAAiB,GAAG,IAAI,eAAe,GAClH,yGAAyG,EAC1G;IAAEc,QAAQ,EAAEH,MAAM;IAAEI,WAAW,EAAEf;EAAkB,CACpD,CAAC;AACF;;AAEA;AACA,OAAO,SAASgB,cAAcA,CAACC,MAAsB,EAAQ;EAC5D,IAAI,OAAOA,MAAM,CAACP,EAAE,KAAK,QAAQ,IAAI,CAACN,MAAM,CAACC,QAAQ,CAACY,MAAM,CAACP,EAAE,CAAC,EAAE;IACjE,MAAM,IAAIX,iBAAiB,CAC1BD,gBAAgB,CAACQ,cAAc,EAC/B,qEAAqE,EACrE;MAAEC,QAAQ,EAAE,OAAOU,MAAM,CAACP;IAAG,CAC9B,CAAC;EACF;EAEA,IACCO,MAAM,CAACC,SAAS,KAAKC,SAAS,IAC9BF,MAAM,CAACC,SAAS,KAAK,WAAW,IAChCD,MAAM,CAACC,SAAS,KAAK,UAAU,EAC9B;IACD,MAAM,IAAInB,iBAAiB,CAC1BD,gBAAgB,CAACQ,cAAc,EAC/B,qDAAqD,EACrD;MAAEC,QAAQ,EAAEC,MAAM,CAACS,MAAM,CAACC,SAAS;IAAE,CACtC,CAAC;EACF;AACD","ignoreList":[]}
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Content validation.
5
+ *
6
+ * The package passes content through **unchanged** and never truncates it.
7
+ * Display truncation is the platform's decision and differs between them; a
8
+ * library that pre-truncated would be guessing at a rule it does not own, and
9
+ * would corrupt content that would have displayed fine.
10
+ *
11
+ * What it does refuse is content over the platform's hard payload limit, where
12
+ * the alternative is not a shortened notification but a failed or undefined
13
+ * delivery. That is a real error and is reported as one, before any platform
14
+ * call.
15
+ */
16
+
17
+ import { DIAGNOSTIC_CODES, NotificationError } from "../contract/errors.js";
18
+ /**
19
+ * Hard payload ceilings.
20
+ *
21
+ * These are *not* display limits. A title longer than a phone shows is fine and
22
+ * is passed through; the README documents where each platform visually
23
+ * truncates so a caller can decide for itself.
24
+ *
25
+ * The total is deliberately lower than the sum of the parts, so it actually
26
+ * binds — a per-field check that can never be exceeded in aggregate would be
27
+ * dead code. It sits under the 4 KB payload budget both platforms enforce,
28
+ * leaving headroom for the routing payload that shares it.
29
+ */
30
+ export const CONTENT_LIMITS = {
31
+ maxTitleBytes: 512,
32
+ maxBodyBytes: 3072,
33
+ maxSubtitleBytes: 512,
34
+ maxTotalBytes: 3584
35
+ };
36
+
37
+ /** UTF-8 byte length — the unit the platforms actually bound. */
38
+ export function byteLength(value) {
39
+ let bytes = 0;
40
+ for (const char of value) {
41
+ const code = char.codePointAt(0) ?? 0;
42
+ if (code <= 0x7f) bytes += 1;else if (code <= 0x7ff) bytes += 2;else if (code <= 0xffff) bytes += 3;else bytes += 4;
43
+ }
44
+ return bytes;
45
+ }
46
+ function requireString(value, field) {
47
+ if (typeof value !== 'string') {
48
+ throw new NotificationError(DIAGNOSTIC_CODES.CONTENT_TOO_LARGE, `Notification content field "${field}" must be a string of resolved display text. The package performs no locale resolution.`, {
49
+ field,
50
+ received: typeof value
51
+ });
52
+ }
53
+ return value;
54
+ }
55
+
56
+ /**
57
+ * Validates content and returns it **byte-identical**.
58
+ *
59
+ * The return value is the same object reference where possible, so nothing
60
+ * downstream can mistake this for a transformation step.
61
+ */
62
+ export function validateContent(content) {
63
+ const title = requireString(content.title, 'title');
64
+ const body = requireString(content.body, 'body');
65
+ const subtitle = content.subtitle === undefined ? undefined : requireString(content.subtitle, 'subtitle');
66
+ if (title.length === 0 && body.length === 0) {
67
+ throw new NotificationError(DIAGNOSTIC_CODES.CONTENT_TOO_LARGE, 'A notification must carry a title or a body; both were empty.', {
68
+ field: 'title+body'
69
+ });
70
+ }
71
+ const checks = [['title', title, CONTENT_LIMITS.maxTitleBytes], ['body', body, CONTENT_LIMITS.maxBodyBytes]];
72
+ if (subtitle !== undefined) {
73
+ checks.push(['subtitle', subtitle, CONTENT_LIMITS.maxSubtitleBytes]);
74
+ }
75
+ for (const [field, value, limit] of checks) {
76
+ const size = byteLength(value);
77
+ if (size > limit) {
78
+ throw new NotificationError(DIAGNOSTIC_CODES.CONTENT_TOO_LARGE, `Notification "${field}" is ${size} bytes, over the ${limit}-byte platform limit. ` + "It was refused rather than truncated, because the package does not decide where a caller's content should be cut.", {
79
+ field,
80
+ bytes: size,
81
+ limit
82
+ });
83
+ }
84
+ }
85
+ const total = byteLength(title) + byteLength(body) + (subtitle ? byteLength(subtitle) : 0);
86
+ if (total > CONTENT_LIMITS.maxTotalBytes) {
87
+ throw new NotificationError(DIAGNOSTIC_CODES.CONTENT_TOO_LARGE, `Notification content totals ${total} bytes, over the ${CONTENT_LIMITS.maxTotalBytes}-byte payload limit.`, {
88
+ field: 'total',
89
+ bytes: total,
90
+ limit: CONTENT_LIMITS.maxTotalBytes
91
+ });
92
+ }
93
+ return content;
94
+ }
95
+ //# sourceMappingURL=validate-content.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["DIAGNOSTIC_CODES","NotificationError","CONTENT_LIMITS","maxTitleBytes","maxBodyBytes","maxSubtitleBytes","maxTotalBytes","byteLength","value","bytes","char","code","codePointAt","requireString","field","CONTENT_TOO_LARGE","received","validateContent","content","title","body","subtitle","undefined","length","checks","push","limit","size","total"],"sourceRoot":"../../../src","sources":["schedule/validate-content.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,gBAAgB,EAAEC,iBAAiB,QAAQ,uBAAoB;AAGxE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,cAAc,GAAG;EAC7BC,aAAa,EAAE,GAAG;EAClBC,YAAY,EAAE,IAAI;EAClBC,gBAAgB,EAAE,GAAG;EACrBC,aAAa,EAAE;AAChB,CAAU;;AAEV;AACA,OAAO,SAASC,UAAUA,CAACC,KAAa,EAAU;EACjD,IAAIC,KAAK,GAAG,CAAC;EACb,KAAK,MAAMC,IAAI,IAAIF,KAAK,EAAE;IACzB,MAAMG,IAAI,GAAGD,IAAI,CAACE,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC;IACrC,IAAID,IAAI,IAAI,IAAI,EAAEF,KAAK,IAAI,CAAC,CAAC,KACxB,IAAIE,IAAI,IAAI,KAAK,EAAEF,KAAK,IAAI,CAAC,CAAC,KAC9B,IAAIE,IAAI,IAAI,MAAM,E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