@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.
- package/CHANGELOG.md +111 -0
- package/README.md +8 -6
- package/lib/commonjs/advanced.js +139 -0
- package/lib/commonjs/advanced.js.map +1 -0
- package/lib/commonjs/channel/migrate.js +246 -0
- package/lib/commonjs/channel/migrate.js.map +1 -0
- package/lib/commonjs/channel/tone-map.js +120 -0
- package/lib/commonjs/channel/tone-map.js.map +1 -0
- package/lib/commonjs/channel/validate-tone.js +61 -0
- package/lib/commonjs/channel/validate-tone.js.map +1 -0
- package/lib/commonjs/contract/channel.js +52 -0
- package/lib/commonjs/contract/channel.js.map +1 -0
- package/lib/commonjs/contract/diagnostics.js +25 -0
- package/lib/commonjs/contract/diagnostics.js.map +1 -0
- package/lib/commonjs/contract/errors.js +126 -0
- package/lib/commonjs/contract/errors.js.map +1 -0
- package/lib/commonjs/contract/hash.js +35 -0
- package/lib/commonjs/contract/hash.js.map +1 -0
- package/lib/commonjs/contract/index.js +94 -0
- package/lib/commonjs/contract/index.js.map +1 -0
- package/lib/commonjs/contract/interaction.js +37 -0
- package/lib/commonjs/contract/interaction.js.map +1 -0
- package/lib/commonjs/contract/notification.js +42 -0
- package/lib/commonjs/contract/notification.js.map +1 -0
- package/lib/commonjs/contract/permission.js +2 -0
- package/lib/commonjs/contract/permission.js.map +1 -0
- package/lib/commonjs/contract/reconcile.js +6 -0
- package/lib/commonjs/contract/reconcile.js.map +1 -0
- package/lib/commonjs/contract/recurrence.js +53 -0
- package/lib/commonjs/contract/recurrence.js.map +1 -0
- package/lib/commonjs/diagnostics/burst.js +89 -0
- package/lib/commonjs/diagnostics/burst.js.map +1 -0
- package/lib/commonjs/diagnostics/events.js +63 -0
- package/lib/commonjs/diagnostics/events.js.map +1 -0
- package/lib/commonjs/diagnostics/redact.js +48 -0
- package/lib/commonjs/diagnostics/redact.js.map +1 -0
- package/lib/commonjs/diagnostics/snapshot.js +68 -0
- package/lib/commonjs/diagnostics/snapshot.js.map +1 -0
- package/lib/commonjs/engine/adapter.js +6 -0
- package/lib/commonjs/engine/adapter.js.map +1 -0
- package/lib/commonjs/engine/codec.js +84 -0
- package/lib/commonjs/engine/codec.js.map +1 -0
- package/lib/commonjs/engine/notify-kit/events.js +148 -0
- package/lib/commonjs/engine/notify-kit/events.js.map +1 -0
- package/lib/commonjs/engine/notify-kit/module.js +119 -0
- package/lib/commonjs/engine/notify-kit/module.js.map +1 -0
- package/lib/commonjs/engine/notify-kit/platform/android.js +159 -0
- package/lib/commonjs/engine/notify-kit/platform/android.js.map +1 -0
- package/lib/commonjs/engine/notify-kit/platform/index.js +57 -0
- package/lib/commonjs/engine/notify-kit/platform/index.js.map +1 -0
- package/lib/commonjs/engine/notify-kit/platform/ios.js +54 -0
- package/lib/commonjs/engine/notify-kit/platform/ios.js.map +1 -0
- package/lib/commonjs/engine/notify-kit/platform/types.js +6 -0
- package/lib/commonjs/engine/notify-kit/platform/types.js.map +1 -0
- package/lib/commonjs/engine/notify-kit-engine.js +260 -0
- package/lib/commonjs/engine/notify-kit-engine.js.map +1 -0
- package/lib/commonjs/index.js +367 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/initialize.js +187 -0
- package/lib/commonjs/initialize.js.map +1 -0
- package/lib/commonjs/interaction/index.js +120 -0
- package/lib/commonjs/interaction/index.js.map +1 -0
- package/lib/commonjs/maintenance/cycle.js +108 -0
- package/lib/commonjs/maintenance/cycle.js.map +1 -0
- package/lib/commonjs/maintenance/permission-refresh.js +39 -0
- package/lib/commonjs/maintenance/permission-refresh.js.map +1 -0
- package/lib/commonjs/maintenance/reanchor.js +99 -0
- package/lib/commonjs/maintenance/reanchor.js.map +1 -0
- package/lib/commonjs/maintenance/toggle.js +50 -0
- package/lib/commonjs/maintenance/toggle.js.map +1 -0
- package/lib/commonjs/maintenance/verify.js +70 -0
- package/lib/commonjs/maintenance/verify.js.map +1 -0
- package/lib/commonjs/maintenance/window-refresh.js +53 -0
- package/lib/commonjs/maintenance/window-refresh.js.map +1 -0
- package/lib/commonjs/notifications.js +161 -0
- package/lib/commonjs/notifications.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/permission/index.js +182 -0
- package/lib/commonjs/permission/index.js.map +1 -0
- package/lib/commonjs/permission/state.js +92 -0
- package/lib/commonjs/permission/state.js.map +1 -0
- package/lib/commonjs/push/envelope.js +141 -0
- package/lib/commonjs/push/envelope.js.map +1 -0
- package/lib/commonjs/push/fcm-provider.js +122 -0
- package/lib/commonjs/push/fcm-provider.js.map +1 -0
- package/lib/commonjs/push/gate.js +162 -0
- package/lib/commonjs/push/gate.js.map +1 -0
- package/lib/commonjs/push/index.js +47 -0
- package/lib/commonjs/push/index.js.map +1 -0
- package/lib/commonjs/push/instructions.js +101 -0
- package/lib/commonjs/push/instructions.js.map +1 -0
- package/lib/commonjs/push/provider-adapter.js +6 -0
- package/lib/commonjs/push/provider-adapter.js.map +1 -0
- package/lib/commonjs/push/signout.js +55 -0
- package/lib/commonjs/push/signout.js.map +1 -0
- package/lib/commonjs/reconcile/chunk.js +49 -0
- package/lib/commonjs/reconcile/chunk.js.map +1 -0
- package/lib/commonjs/reconcile/diff.js +105 -0
- package/lib/commonjs/reconcile/diff.js.map +1 -0
- package/lib/commonjs/reconcile/duplicates.js +60 -0
- package/lib/commonjs/reconcile/duplicates.js.map +1 -0
- package/lib/commonjs/reconcile/index.js +164 -0
- package/lib/commonjs/reconcile/index.js.map +1 -0
- package/lib/commonjs/reconcile/truncate.js +50 -0
- package/lib/commonjs/reconcile/truncate.js.map +1 -0
- package/lib/commonjs/recurrence/clock-guard.js +65 -0
- package/lib/commonjs/recurrence/clock-guard.js.map +1 -0
- package/lib/commonjs/recurrence/expand.js +254 -0
- package/lib/commonjs/recurrence/expand.js.map +1 -0
- package/lib/commonjs/recurrence/index.js +212 -0
- package/lib/commonjs/recurrence/index.js.map +1 -0
- package/lib/commonjs/repeat/expiry.js +41 -0
- package/lib/commonjs/repeat/expiry.js.map +1 -0
- package/lib/commonjs/repeat/index.js +100 -0
- package/lib/commonjs/repeat/index.js.map +1 -0
- package/lib/commonjs/repeat/marker.js +58 -0
- package/lib/commonjs/repeat/marker.js.map +1 -0
- package/lib/commonjs/repeat/place.js +83 -0
- package/lib/commonjs/repeat/place.js.map +1 -0
- package/lib/commonjs/schedule/anchor.js +243 -0
- package/lib/commonjs/schedule/anchor.js.map +1 -0
- package/lib/commonjs/schedule/index.js +142 -0
- package/lib/commonjs/schedule/index.js.map +1 -0
- package/lib/commonjs/schedule/partition.js +59 -0
- package/lib/commonjs/schedule/partition.js.map +1 -0
- package/lib/commonjs/schedule/resolve-moment.js +72 -0
- package/lib/commonjs/schedule/resolve-moment.js.map +1 -0
- package/lib/commonjs/schedule/validate-content.js +101 -0
- package/lib/commonjs/schedule/validate-content.js.map +1 -0
- package/lib/commonjs/schedule/validate-identifier.js +126 -0
- package/lib/commonjs/schedule/validate-identifier.js.map +1 -0
- package/lib/commonjs/schedule/writer.js +44 -0
- package/lib/commonjs/schedule/writer.js.map +1 -0
- package/lib/commonjs/state/caps.js +101 -0
- package/lib/commonjs/state/caps.js.map +1 -0
- package/lib/commonjs/state/dedup-ledger.js +39 -0
- package/lib/commonjs/state/dedup-ledger.js.map +1 -0
- package/lib/commonjs/state/interaction-buffer.js +98 -0
- package/lib/commonjs/state/interaction-buffer.js.map +1 -0
- package/lib/commonjs/state/mmkv-store.js +75 -0
- package/lib/commonjs/state/mmkv-store.js.map +1 -0
- package/lib/commonjs/state/permission-history.js +64 -0
- package/lib/commonjs/state/permission-history.js.map +1 -0
- package/lib/commonjs/state/record.js +269 -0
- package/lib/commonjs/state/record.js.map +1 -0
- package/lib/commonjs/state/reset.js +37 -0
- package/lib/commonjs/state/reset.js.map +1 -0
- package/lib/commonjs/state/series-ledger.js +71 -0
- package/lib/commonjs/state/series-ledger.js.map +1 -0
- package/lib/commonjs/state/store.js +39 -0
- package/lib/commonjs/state/store.js.map +1 -0
- package/lib/commonjs/testing/conformance/index.js +218 -0
- package/lib/commonjs/testing/conformance/index.js.map +1 -0
- package/lib/commonjs/testing/fake-engine.js +338 -0
- package/lib/commonjs/testing/fake-engine.js.map +1 -0
- package/lib/commonjs/testing/fake-provider.js +93 -0
- package/lib/commonjs/testing/fake-provider.js.map +1 -0
- package/lib/commonjs/testing/faults.js +59 -0
- package/lib/commonjs/testing/faults.js.map +1 -0
- package/lib/commonjs/testing/index.js +54 -0
- package/lib/commonjs/testing/index.js.map +1 -0
- package/lib/commonjs/testing/measure.js +298 -0
- package/lib/commonjs/testing/measure.js.map +1 -0
- package/lib/module/advanced.js +29 -0
- package/lib/module/advanced.js.map +1 -0
- package/lib/module/channel/migrate.js +242 -0
- package/lib/module/channel/migrate.js.map +1 -0
- package/lib/module/channel/tone-map.js +112 -0
- package/lib/module/channel/tone-map.js.map +1 -0
- package/lib/module/channel/validate-tone.js +57 -0
- package/lib/module/channel/validate-tone.js.map +1 -0
- package/lib/module/contract/channel.js +48 -0
- package/lib/module/contract/channel.js.map +1 -0
- package/lib/module/contract/diagnostics.js +21 -0
- package/lib/module/contract/diagnostics.js.map +1 -0
- package/lib/module/contract/errors.js +119 -0
- package/lib/module/contract/errors.js.map +1 -0
- package/lib/module/contract/hash.js +29 -0
- package/lib/module/contract/hash.js.map +1 -0
- package/lib/module/contract/index.js +13 -0
- package/lib/module/contract/index.js.map +1 -0
- package/lib/module/contract/interaction.js +33 -0
- package/lib/module/contract/interaction.js.map +1 -0
- package/lib/module/contract/notification.js +38 -0
- package/lib/module/contract/notification.js.map +1 -0
- package/lib/module/contract/permission.js +2 -0
- package/lib/module/contract/permission.js.map +1 -0
- package/lib/module/contract/reconcile.js +4 -0
- package/lib/module/contract/reconcile.js.map +1 -0
- package/lib/module/contract/recurrence.js +49 -0
- package/lib/module/contract/recurrence.js.map +1 -0
- package/lib/module/diagnostics/burst.js +85 -0
- package/lib/module/diagnostics/burst.js.map +1 -0
- package/lib/module/diagnostics/events.js +58 -0
- package/lib/module/diagnostics/events.js.map +1 -0
- package/lib/module/diagnostics/redact.js +44 -0
- package/lib/module/diagnostics/redact.js.map +1 -0
- package/lib/module/diagnostics/snapshot.js +64 -0
- package/lib/module/diagnostics/snapshot.js.map +1 -0
- package/lib/module/engine/adapter.js +4 -0
- package/lib/module/engine/adapter.js.map +1 -0
- package/lib/module/engine/codec.js +79 -0
- package/lib/module/engine/codec.js.map +1 -0
- package/lib/module/engine/notify-kit/events.js +139 -0
- package/lib/module/engine/notify-kit/events.js.map +1 -0
- package/lib/module/engine/notify-kit/module.js +113 -0
- package/lib/module/engine/notify-kit/module.js.map +1 -0
- package/lib/module/engine/notify-kit/platform/android.js +155 -0
- package/lib/module/engine/notify-kit/platform/android.js.map +1 -0
- package/lib/module/engine/notify-kit/platform/index.js +51 -0
- package/lib/module/engine/notify-kit/platform/index.js.map +1 -0
- package/lib/module/engine/notify-kit/platform/ios.js +49 -0
- package/lib/module/engine/notify-kit/platform/ios.js.map +1 -0
- package/lib/module/engine/notify-kit/platform/types.js +4 -0
- package/lib/module/engine/notify-kit/platform/types.js.map +1 -0
- package/lib/module/engine/notify-kit-engine.js +257 -0
- package/lib/module/engine/notify-kit-engine.js.map +1 -0
- package/lib/module/index.js +98 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/initialize.js +182 -0
- package/lib/module/initialize.js.map +1 -0
- package/lib/module/interaction/index.js +116 -0
- package/lib/module/interaction/index.js.map +1 -0
- package/lib/module/maintenance/cycle.js +102 -0
- package/lib/module/maintenance/cycle.js.map +1 -0
- package/lib/module/maintenance/permission-refresh.js +34 -0
- package/lib/module/maintenance/permission-refresh.js.map +1 -0
- package/lib/module/maintenance/reanchor.js +94 -0
- package/lib/module/maintenance/reanchor.js.map +1 -0
- package/lib/module/maintenance/toggle.js +45 -0
- package/lib/module/maintenance/toggle.js.map +1 -0
- package/lib/module/maintenance/verify.js +65 -0
- package/lib/module/maintenance/verify.js.map +1 -0
- package/lib/module/maintenance/window-refresh.js +48 -0
- package/lib/module/maintenance/window-refresh.js.map +1 -0
- package/lib/module/notifications.js +157 -0
- package/lib/module/notifications.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/permission/index.js +178 -0
- package/lib/module/permission/index.js.map +1 -0
- package/lib/module/permission/state.js +83 -0
- package/lib/module/permission/state.js.map +1 -0
- package/lib/module/push/envelope.js +137 -0
- package/lib/module/push/envelope.js.map +1 -0
- package/lib/module/push/fcm-provider.js +119 -0
- package/lib/module/push/fcm-provider.js.map +1 -0
- package/lib/module/push/gate.js +158 -0
- package/lib/module/push/gate.js.map +1 -0
- package/lib/module/push/index.js +16 -0
- package/lib/module/push/index.js.map +1 -0
- package/lib/module/push/instructions.js +97 -0
- package/lib/module/push/instructions.js.map +1 -0
- package/lib/module/push/provider-adapter.js +4 -0
- package/lib/module/push/provider-adapter.js.map +1 -0
- package/lib/module/push/signout.js +51 -0
- package/lib/module/push/signout.js.map +1 -0
- package/lib/module/reconcile/chunk.js +43 -0
- package/lib/module/reconcile/chunk.js.map +1 -0
- package/lib/module/reconcile/diff.js +101 -0
- package/lib/module/reconcile/diff.js.map +1 -0
- package/lib/module/reconcile/duplicates.js +56 -0
- package/lib/module/reconcile/duplicates.js.map +1 -0
- package/lib/module/reconcile/index.js +161 -0
- package/lib/module/reconcile/index.js.map +1 -0
- package/lib/module/reconcile/truncate.js +46 -0
- package/lib/module/reconcile/truncate.js.map +1 -0
- package/lib/module/recurrence/clock-guard.js +60 -0
- package/lib/module/recurrence/clock-guard.js.map +1 -0
- package/lib/module/recurrence/expand.js +248 -0
- package/lib/module/recurrence/expand.js.map +1 -0
- package/lib/module/recurrence/index.js +208 -0
- package/lib/module/recurrence/index.js.map +1 -0
- package/lib/module/repeat/expiry.js +37 -0
- package/lib/module/repeat/expiry.js.map +1 -0
- package/lib/module/repeat/index.js +67 -0
- package/lib/module/repeat/index.js.map +1 -0
- package/lib/module/repeat/marker.js +51 -0
- package/lib/module/repeat/marker.js.map +1 -0
- package/lib/module/repeat/place.js +79 -0
- package/lib/module/repeat/place.js.map +1 -0
- package/lib/module/schedule/anchor.js +234 -0
- package/lib/module/schedule/anchor.js.map +1 -0
- package/lib/module/schedule/index.js +137 -0
- package/lib/module/schedule/index.js.map +1 -0
- package/lib/module/schedule/partition.js +53 -0
- package/lib/module/schedule/partition.js.map +1 -0
- package/lib/module/schedule/resolve-moment.js +66 -0
- package/lib/module/schedule/resolve-moment.js.map +1 -0
- package/lib/module/schedule/validate-content.js +95 -0
- package/lib/module/schedule/validate-content.js.map +1 -0
- package/lib/module/schedule/validate-identifier.js +119 -0
- package/lib/module/schedule/validate-identifier.js.map +1 -0
- package/lib/module/schedule/writer.js +40 -0
- package/lib/module/schedule/writer.js.map +1 -0
- package/lib/module/state/caps.js +96 -0
- package/lib/module/state/caps.js.map +1 -0
- package/lib/module/state/dedup-ledger.js +34 -0
- package/lib/module/state/dedup-ledger.js.map +1 -0
- package/lib/module/state/interaction-buffer.js +92 -0
- package/lib/module/state/interaction-buffer.js.map +1 -0
- package/lib/module/state/mmkv-store.js +71 -0
- package/lib/module/state/mmkv-store.js.map +1 -0
- package/lib/module/state/permission-history.js +56 -0
- package/lib/module/state/permission-history.js.map +1 -0
- package/lib/module/state/record.js +264 -0
- package/lib/module/state/record.js.map +1 -0
- package/lib/module/state/reset.js +32 -0
- package/lib/module/state/reset.js.map +1 -0
- package/lib/module/state/series-ledger.js +62 -0
- package/lib/module/state/series-ledger.js.map +1 -0
- package/lib/module/state/store.js +35 -0
- package/lib/module/state/store.js.map +1 -0
- package/lib/module/testing/conformance/index.js +214 -0
- package/lib/module/testing/conformance/index.js.map +1 -0
- package/lib/module/testing/fake-engine.js +335 -0
- package/lib/module/testing/fake-engine.js.map +1 -0
- package/lib/module/testing/fake-provider.js +89 -0
- package/lib/module/testing/fake-provider.js.map +1 -0
- package/lib/module/testing/faults.js +55 -0
- package/lib/module/testing/faults.js.map +1 -0
- package/lib/module/testing/index.js +19 -0
- package/lib/module/testing/index.js.map +1 -0
- package/lib/module/testing/measure.js +294 -0
- package/lib/module/testing/measure.js.map +1 -0
- package/lib/typescript/commonjs/advanced.d.ts +36 -0
- package/lib/typescript/commonjs/advanced.d.ts.map +1 -0
- package/lib/typescript/commonjs/channel/migrate.d.ts +38 -0
- package/lib/typescript/commonjs/channel/migrate.d.ts.map +1 -0
- package/lib/typescript/commonjs/channel/tone-map.d.ts +34 -0
- package/lib/typescript/commonjs/channel/tone-map.d.ts.map +1 -0
- package/lib/typescript/commonjs/channel/validate-tone.d.ts +23 -0
- package/lib/typescript/commonjs/channel/validate-tone.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/channel.d.ts +185 -0
- package/lib/typescript/commonjs/contract/channel.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/diagnostics.d.ts +92 -0
- package/lib/typescript/commonjs/contract/diagnostics.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/errors.d.ts +91 -0
- package/lib/typescript/commonjs/contract/errors.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/hash.d.ts +14 -0
- package/lib/typescript/commonjs/contract/hash.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/index.d.ts +10 -0
- package/lib/typescript/commonjs/contract/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/interaction.d.ts +53 -0
- package/lib/typescript/commonjs/contract/interaction.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/notification.d.ts +110 -0
- package/lib/typescript/commonjs/contract/notification.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/permission.d.ts +49 -0
- package/lib/typescript/commonjs/contract/permission.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/reconcile.d.ts +82 -0
- package/lib/typescript/commonjs/contract/reconcile.d.ts.map +1 -0
- package/lib/typescript/commonjs/contract/recurrence.d.ts +118 -0
- package/lib/typescript/commonjs/contract/recurrence.d.ts.map +1 -0
- package/lib/typescript/commonjs/diagnostics/burst.d.ts +39 -0
- package/lib/typescript/commonjs/diagnostics/burst.d.ts.map +1 -0
- package/lib/typescript/commonjs/diagnostics/events.d.ts +28 -0
- package/lib/typescript/commonjs/diagnostics/events.d.ts.map +1 -0
- package/lib/typescript/commonjs/diagnostics/redact.d.ts +22 -0
- package/lib/typescript/commonjs/diagnostics/redact.d.ts.map +1 -0
- package/lib/typescript/commonjs/diagnostics/snapshot.d.ts +40 -0
- package/lib/typescript/commonjs/diagnostics/snapshot.d.ts.map +1 -0
- package/lib/typescript/commonjs/engine/adapter.d.ts +172 -0
- package/lib/typescript/commonjs/engine/adapter.d.ts.map +1 -0
- package/lib/typescript/commonjs/engine/codec.d.ts +20 -0
- package/lib/typescript/commonjs/engine/codec.d.ts.map +1 -0
- package/lib/typescript/commonjs/engine/notify-kit/events.d.ts +37 -0
- package/lib/typescript/commonjs/engine/notify-kit/events.d.ts.map +1 -0
- package/lib/typescript/commonjs/engine/notify-kit/module.d.ts +103 -0
- package/lib/typescript/commonjs/engine/notify-kit/module.d.ts.map +1 -0
- package/lib/typescript/commonjs/engine/notify-kit/platform/android.d.ts +3 -0
- package/lib/typescript/commonjs/engine/notify-kit/platform/android.d.ts.map +1 -0
- package/lib/typescript/commonjs/engine/notify-kit/platform/index.d.ts +12 -0
- package/lib/typescript/commonjs/engine/notify-kit/platform/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/engine/notify-kit/platform/ios.d.ts +3 -0
- package/lib/typescript/commonjs/engine/notify-kit/platform/ios.d.ts.map +1 -0
- package/lib/typescript/commonjs/engine/notify-kit/platform/types.d.ts +33 -0
- package/lib/typescript/commonjs/engine/notify-kit/platform/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/engine/notify-kit-engine.d.ts +25 -0
- package/lib/typescript/commonjs/engine/notify-kit-engine.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +106 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/initialize.d.ts +74 -0
- package/lib/typescript/commonjs/initialize.d.ts.map +1 -0
- package/lib/typescript/commonjs/interaction/index.d.ts +53 -0
- package/lib/typescript/commonjs/interaction/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/maintenance/cycle.d.ts +77 -0
- package/lib/typescript/commonjs/maintenance/cycle.d.ts.map +1 -0
- package/lib/typescript/commonjs/maintenance/permission-refresh.d.ts +19 -0
- package/lib/typescript/commonjs/maintenance/permission-refresh.d.ts.map +1 -0
- package/lib/typescript/commonjs/maintenance/reanchor.d.ts +26 -0
- package/lib/typescript/commonjs/maintenance/reanchor.d.ts.map +1 -0
- package/lib/typescript/commonjs/maintenance/toggle.d.ts +35 -0
- package/lib/typescript/commonjs/maintenance/toggle.d.ts.map +1 -0
- package/lib/typescript/commonjs/maintenance/verify.d.ts +32 -0
- package/lib/typescript/commonjs/maintenance/verify.d.ts.map +1 -0
- package/lib/typescript/commonjs/maintenance/window-refresh.d.ts +29 -0
- package/lib/typescript/commonjs/maintenance/window-refresh.d.ts.map +1 -0
- package/lib/typescript/commonjs/notifications.d.ts +78 -0
- package/lib/typescript/commonjs/notifications.d.ts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/permission/index.d.ts +57 -0
- package/lib/typescript/commonjs/permission/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/permission/state.d.ts +41 -0
- package/lib/typescript/commonjs/permission/state.d.ts.map +1 -0
- package/lib/typescript/commonjs/push/envelope.d.ts +33 -0
- package/lib/typescript/commonjs/push/envelope.d.ts.map +1 -0
- package/lib/typescript/commonjs/push/fcm-provider.d.ts +43 -0
- package/lib/typescript/commonjs/push/fcm-provider.d.ts.map +1 -0
- package/lib/typescript/commonjs/push/gate.d.ts +57 -0
- package/lib/typescript/commonjs/push/gate.d.ts.map +1 -0
- package/lib/typescript/commonjs/push/index.d.ts +19 -0
- package/lib/typescript/commonjs/push/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/push/instructions.d.ts +45 -0
- package/lib/typescript/commonjs/push/instructions.d.ts.map +1 -0
- package/lib/typescript/commonjs/push/provider-adapter.d.ts +50 -0
- package/lib/typescript/commonjs/push/provider-adapter.d.ts.map +1 -0
- package/lib/typescript/commonjs/push/signout.d.ts +33 -0
- package/lib/typescript/commonjs/push/signout.d.ts.map +1 -0
- package/lib/typescript/commonjs/reconcile/chunk.d.ts +24 -0
- package/lib/typescript/commonjs/reconcile/chunk.d.ts.map +1 -0
- package/lib/typescript/commonjs/reconcile/diff.d.ts +54 -0
- package/lib/typescript/commonjs/reconcile/diff.d.ts.map +1 -0
- package/lib/typescript/commonjs/reconcile/duplicates.d.ts +32 -0
- package/lib/typescript/commonjs/reconcile/duplicates.d.ts.map +1 -0
- package/lib/typescript/commonjs/reconcile/index.d.ts +35 -0
- package/lib/typescript/commonjs/reconcile/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/reconcile/truncate.d.ts +26 -0
- package/lib/typescript/commonjs/reconcile/truncate.d.ts.map +1 -0
- package/lib/typescript/commonjs/recurrence/clock-guard.d.ts +37 -0
- package/lib/typescript/commonjs/recurrence/clock-guard.d.ts.map +1 -0
- package/lib/typescript/commonjs/recurrence/expand.d.ts +75 -0
- package/lib/typescript/commonjs/recurrence/expand.d.ts.map +1 -0
- package/lib/typescript/commonjs/recurrence/index.d.ts +40 -0
- package/lib/typescript/commonjs/recurrence/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/repeat/expiry.d.ts +23 -0
- package/lib/typescript/commonjs/repeat/expiry.d.ts.map +1 -0
- package/lib/typescript/commonjs/repeat/index.d.ts +49 -0
- package/lib/typescript/commonjs/repeat/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/repeat/marker.d.ts +36 -0
- package/lib/typescript/commonjs/repeat/marker.d.ts.map +1 -0
- package/lib/typescript/commonjs/repeat/place.d.ts +39 -0
- package/lib/typescript/commonjs/repeat/place.d.ts.map +1 -0
- package/lib/typescript/commonjs/schedule/anchor.d.ts +118 -0
- package/lib/typescript/commonjs/schedule/anchor.d.ts.map +1 -0
- package/lib/typescript/commonjs/schedule/index.d.ts +40 -0
- package/lib/typescript/commonjs/schedule/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/schedule/partition.d.ts +29 -0
- package/lib/typescript/commonjs/schedule/partition.d.ts.map +1 -0
- package/lib/typescript/commonjs/schedule/resolve-moment.d.ts +35 -0
- package/lib/typescript/commonjs/schedule/resolve-moment.d.ts.map +1 -0
- package/lib/typescript/commonjs/schedule/validate-content.d.ts +42 -0
- package/lib/typescript/commonjs/schedule/validate-content.d.ts.map +1 -0
- package/lib/typescript/commonjs/schedule/validate-identifier.d.ts +30 -0
- package/lib/typescript/commonjs/schedule/validate-identifier.d.ts.map +1 -0
- package/lib/typescript/commonjs/schedule/writer.d.ts +36 -0
- package/lib/typescript/commonjs/schedule/writer.d.ts.map +1 -0
- package/lib/typescript/commonjs/state/caps.d.ts +51 -0
- package/lib/typescript/commonjs/state/caps.d.ts.map +1 -0
- package/lib/typescript/commonjs/state/dedup-ledger.d.ts +21 -0
- package/lib/typescript/commonjs/state/dedup-ledger.d.ts.map +1 -0
- package/lib/typescript/commonjs/state/interaction-buffer.d.ts +30 -0
- package/lib/typescript/commonjs/state/interaction-buffer.d.ts.map +1 -0
- package/lib/typescript/commonjs/state/mmkv-store.d.ts +33 -0
- package/lib/typescript/commonjs/state/mmkv-store.d.ts.map +1 -0
- package/lib/typescript/commonjs/state/permission-history.d.ts +20 -0
- package/lib/typescript/commonjs/state/permission-history.d.ts.map +1 -0
- package/lib/typescript/commonjs/state/record.d.ts +134 -0
- package/lib/typescript/commonjs/state/record.d.ts.map +1 -0
- package/lib/typescript/commonjs/state/reset.d.ts +22 -0
- package/lib/typescript/commonjs/state/reset.d.ts.map +1 -0
- package/lib/typescript/commonjs/state/series-ledger.d.ts +47 -0
- package/lib/typescript/commonjs/state/series-ledger.d.ts.map +1 -0
- package/lib/typescript/commonjs/state/store.d.ts +20 -0
- package/lib/typescript/commonjs/state/store.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/conformance/index.d.ts +32 -0
- package/lib/typescript/commonjs/testing/conformance/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/fake-engine.d.ts +91 -0
- package/lib/typescript/commonjs/testing/fake-engine.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/fake-provider.d.ts +35 -0
- package/lib/typescript/commonjs/testing/fake-provider.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/faults.d.ts +38 -0
- package/lib/typescript/commonjs/testing/faults.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/index.d.ts +22 -0
- package/lib/typescript/commonjs/testing/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/measure.d.ts +59 -0
- package/lib/typescript/commonjs/testing/measure.d.ts.map +1 -0
- package/lib/typescript/module/advanced.d.ts +36 -0
- package/lib/typescript/module/advanced.d.ts.map +1 -0
- package/lib/typescript/module/channel/migrate.d.ts +38 -0
- package/lib/typescript/module/channel/migrate.d.ts.map +1 -0
- package/lib/typescript/module/channel/tone-map.d.ts +34 -0
- package/lib/typescript/module/channel/tone-map.d.ts.map +1 -0
- package/lib/typescript/module/channel/validate-tone.d.ts +23 -0
- package/lib/typescript/module/channel/validate-tone.d.ts.map +1 -0
- package/lib/typescript/module/contract/channel.d.ts +185 -0
- package/lib/typescript/module/contract/channel.d.ts.map +1 -0
- package/lib/typescript/module/contract/diagnostics.d.ts +92 -0
- package/lib/typescript/module/contract/diagnostics.d.ts.map +1 -0
- package/lib/typescript/module/contract/errors.d.ts +91 -0
- package/lib/typescript/module/contract/errors.d.ts.map +1 -0
- package/lib/typescript/module/contract/hash.d.ts +14 -0
- package/lib/typescript/module/contract/hash.d.ts.map +1 -0
- package/lib/typescript/module/contract/index.d.ts +10 -0
- package/lib/typescript/module/contract/index.d.ts.map +1 -0
- package/lib/typescript/module/contract/interaction.d.ts +53 -0
- package/lib/typescript/module/contract/interaction.d.ts.map +1 -0
- package/lib/typescript/module/contract/notification.d.ts +110 -0
- package/lib/typescript/module/contract/notification.d.ts.map +1 -0
- package/lib/typescript/module/contract/permission.d.ts +49 -0
- package/lib/typescript/module/contract/permission.d.ts.map +1 -0
- package/lib/typescript/module/contract/reconcile.d.ts +82 -0
- package/lib/typescript/module/contract/reconcile.d.ts.map +1 -0
- package/lib/typescript/module/contract/recurrence.d.ts +118 -0
- package/lib/typescript/module/contract/recurrence.d.ts.map +1 -0
- package/lib/typescript/module/diagnostics/burst.d.ts +39 -0
- package/lib/typescript/module/diagnostics/burst.d.ts.map +1 -0
- package/lib/typescript/module/diagnostics/events.d.ts +28 -0
- package/lib/typescript/module/diagnostics/events.d.ts.map +1 -0
- package/lib/typescript/module/diagnostics/redact.d.ts +22 -0
- package/lib/typescript/module/diagnostics/redact.d.ts.map +1 -0
- package/lib/typescript/module/diagnostics/snapshot.d.ts +40 -0
- package/lib/typescript/module/diagnostics/snapshot.d.ts.map +1 -0
- package/lib/typescript/module/engine/adapter.d.ts +172 -0
- package/lib/typescript/module/engine/adapter.d.ts.map +1 -0
- package/lib/typescript/module/engine/codec.d.ts +20 -0
- package/lib/typescript/module/engine/codec.d.ts.map +1 -0
- package/lib/typescript/module/engine/notify-kit/events.d.ts +37 -0
- package/lib/typescript/module/engine/notify-kit/events.d.ts.map +1 -0
- package/lib/typescript/module/engine/notify-kit/module.d.ts +103 -0
- package/lib/typescript/module/engine/notify-kit/module.d.ts.map +1 -0
- package/lib/typescript/module/engine/notify-kit/platform/android.d.ts +3 -0
- package/lib/typescript/module/engine/notify-kit/platform/android.d.ts.map +1 -0
- package/lib/typescript/module/engine/notify-kit/platform/index.d.ts +12 -0
- package/lib/typescript/module/engine/notify-kit/platform/index.d.ts.map +1 -0
- package/lib/typescript/module/engine/notify-kit/platform/ios.d.ts +3 -0
- package/lib/typescript/module/engine/notify-kit/platform/ios.d.ts.map +1 -0
- package/lib/typescript/module/engine/notify-kit/platform/types.d.ts +33 -0
- package/lib/typescript/module/engine/notify-kit/platform/types.d.ts.map +1 -0
- package/lib/typescript/module/engine/notify-kit-engine.d.ts +25 -0
- package/lib/typescript/module/engine/notify-kit-engine.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +106 -0
- package/lib/typescript/module/index.d.ts.map +1 -0
- package/lib/typescript/module/initialize.d.ts +74 -0
- package/lib/typescript/module/initialize.d.ts.map +1 -0
- package/lib/typescript/module/interaction/index.d.ts +53 -0
- package/lib/typescript/module/interaction/index.d.ts.map +1 -0
- package/lib/typescript/module/maintenance/cycle.d.ts +77 -0
- package/lib/typescript/module/maintenance/cycle.d.ts.map +1 -0
- package/lib/typescript/module/maintenance/permission-refresh.d.ts +19 -0
- package/lib/typescript/module/maintenance/permission-refresh.d.ts.map +1 -0
- package/lib/typescript/module/maintenance/reanchor.d.ts +26 -0
- package/lib/typescript/module/maintenance/reanchor.d.ts.map +1 -0
- package/lib/typescript/module/maintenance/toggle.d.ts +35 -0
- package/lib/typescript/module/maintenance/toggle.d.ts.map +1 -0
- package/lib/typescript/module/maintenance/verify.d.ts +32 -0
- package/lib/typescript/module/maintenance/verify.d.ts.map +1 -0
- package/lib/typescript/module/maintenance/window-refresh.d.ts +29 -0
- package/lib/typescript/module/maintenance/window-refresh.d.ts.map +1 -0
- package/lib/typescript/module/notifications.d.ts +78 -0
- package/lib/typescript/module/notifications.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/permission/index.d.ts +57 -0
- package/lib/typescript/module/permission/index.d.ts.map +1 -0
- package/lib/typescript/module/permission/state.d.ts +41 -0
- package/lib/typescript/module/permission/state.d.ts.map +1 -0
- package/lib/typescript/module/push/envelope.d.ts +33 -0
- package/lib/typescript/module/push/envelope.d.ts.map +1 -0
- package/lib/typescript/module/push/fcm-provider.d.ts +43 -0
- package/lib/typescript/module/push/fcm-provider.d.ts.map +1 -0
- package/lib/typescript/module/push/gate.d.ts +57 -0
- package/lib/typescript/module/push/gate.d.ts.map +1 -0
- package/lib/typescript/module/push/index.d.ts +19 -0
- package/lib/typescript/module/push/index.d.ts.map +1 -0
- package/lib/typescript/module/push/instructions.d.ts +45 -0
- package/lib/typescript/module/push/instructions.d.ts.map +1 -0
- package/lib/typescript/module/push/provider-adapter.d.ts +50 -0
- package/lib/typescript/module/push/provider-adapter.d.ts.map +1 -0
- package/lib/typescript/module/push/signout.d.ts +33 -0
- package/lib/typescript/module/push/signout.d.ts.map +1 -0
- package/lib/typescript/module/reconcile/chunk.d.ts +24 -0
- package/lib/typescript/module/reconcile/chunk.d.ts.map +1 -0
- package/lib/typescript/module/reconcile/diff.d.ts +54 -0
- package/lib/typescript/module/reconcile/diff.d.ts.map +1 -0
- package/lib/typescript/module/reconcile/duplicates.d.ts +32 -0
- package/lib/typescript/module/reconcile/duplicates.d.ts.map +1 -0
- package/lib/typescript/module/reconcile/index.d.ts +35 -0
- package/lib/typescript/module/reconcile/index.d.ts.map +1 -0
- package/lib/typescript/module/reconcile/truncate.d.ts +26 -0
- package/lib/typescript/module/reconcile/truncate.d.ts.map +1 -0
- package/lib/typescript/module/recurrence/clock-guard.d.ts +37 -0
- package/lib/typescript/module/recurrence/clock-guard.d.ts.map +1 -0
- package/lib/typescript/module/recurrence/expand.d.ts +75 -0
- package/lib/typescript/module/recurrence/expand.d.ts.map +1 -0
- package/lib/typescript/module/recurrence/index.d.ts +40 -0
- package/lib/typescript/module/recurrence/index.d.ts.map +1 -0
- package/lib/typescript/module/repeat/expiry.d.ts +23 -0
- package/lib/typescript/module/repeat/expiry.d.ts.map +1 -0
- package/lib/typescript/module/repeat/index.d.ts +49 -0
- package/lib/typescript/module/repeat/index.d.ts.map +1 -0
- package/lib/typescript/module/repeat/marker.d.ts +36 -0
- package/lib/typescript/module/repeat/marker.d.ts.map +1 -0
- package/lib/typescript/module/repeat/place.d.ts +39 -0
- package/lib/typescript/module/repeat/place.d.ts.map +1 -0
- package/lib/typescript/module/schedule/anchor.d.ts +118 -0
- package/lib/typescript/module/schedule/anchor.d.ts.map +1 -0
- package/lib/typescript/module/schedule/index.d.ts +40 -0
- package/lib/typescript/module/schedule/index.d.ts.map +1 -0
- package/lib/typescript/module/schedule/partition.d.ts +29 -0
- package/lib/typescript/module/schedule/partition.d.ts.map +1 -0
- package/lib/typescript/module/schedule/resolve-moment.d.ts +35 -0
- package/lib/typescript/module/schedule/resolve-moment.d.ts.map +1 -0
- package/lib/typescript/module/schedule/validate-content.d.ts +42 -0
- package/lib/typescript/module/schedule/validate-content.d.ts.map +1 -0
- package/lib/typescript/module/schedule/validate-identifier.d.ts +30 -0
- package/lib/typescript/module/schedule/validate-identifier.d.ts.map +1 -0
- package/lib/typescript/module/schedule/writer.d.ts +36 -0
- package/lib/typescript/module/schedule/writer.d.ts.map +1 -0
- package/lib/typescript/module/state/caps.d.ts +51 -0
- package/lib/typescript/module/state/caps.d.ts.map +1 -0
- package/lib/typescript/module/state/dedup-ledger.d.ts +21 -0
- package/lib/typescript/module/state/dedup-ledger.d.ts.map +1 -0
- package/lib/typescript/module/state/interaction-buffer.d.ts +30 -0
- package/lib/typescript/module/state/interaction-buffer.d.ts.map +1 -0
- package/lib/typescript/module/state/mmkv-store.d.ts +33 -0
- package/lib/typescript/module/state/mmkv-store.d.ts.map +1 -0
- package/lib/typescript/module/state/permission-history.d.ts +20 -0
- package/lib/typescript/module/state/permission-history.d.ts.map +1 -0
- package/lib/typescript/module/state/record.d.ts +134 -0
- package/lib/typescript/module/state/record.d.ts.map +1 -0
- package/lib/typescript/module/state/reset.d.ts +22 -0
- package/lib/typescript/module/state/reset.d.ts.map +1 -0
- package/lib/typescript/module/state/series-ledger.d.ts +47 -0
- package/lib/typescript/module/state/series-ledger.d.ts.map +1 -0
- package/lib/typescript/module/state/store.d.ts +20 -0
- package/lib/typescript/module/state/store.d.ts.map +1 -0
- package/lib/typescript/module/testing/conformance/index.d.ts +32 -0
- package/lib/typescript/module/testing/conformance/index.d.ts.map +1 -0
- package/lib/typescript/module/testing/fake-engine.d.ts +91 -0
- package/lib/typescript/module/testing/fake-engine.d.ts.map +1 -0
- package/lib/typescript/module/testing/fake-provider.d.ts +35 -0
- package/lib/typescript/module/testing/fake-provider.d.ts.map +1 -0
- package/lib/typescript/module/testing/faults.d.ts +38 -0
- package/lib/typescript/module/testing/faults.d.ts.map +1 -0
- package/lib/typescript/module/testing/index.d.ts +22 -0
- package/lib/typescript/module/testing/index.d.ts.map +1 -0
- package/lib/typescript/module/testing/measure.d.ts +59 -0
- package/lib/typescript/module/testing/measure.d.ts.map +1 -0
- package/package.json +72 -26
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Channel declaration and migration.
|
|
5
|
+
*
|
|
6
|
+
* Android channels are immutable once created: declaring a channel whose id
|
|
7
|
+
* already exists silently keeps the original configuration. That single fact is
|
|
8
|
+
* why changing a tone is a **migration** rather than an assignment, and why
|
|
9
|
+
* this package keeps its own ledger — the platform will not tell you which
|
|
10
|
+
* version of a channel a device already holds.
|
|
11
|
+
*
|
|
12
|
+
* Migration creates the new channel, re-homes notifications still pointing at
|
|
13
|
+
* the old one, and only then retires it. That order matters: retiring first
|
|
14
|
+
* would leave live notifications attached to a channel that no longer exists.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { DIAGNOSTIC_CODES } from "../contract/errors.js";
|
|
18
|
+
import { channelIdFor, resolveTone, toneLabelFingerprint } from "./tone-map.js";
|
|
19
|
+
import { validateToneDeclarations } from "./validate-tone.js";
|
|
20
|
+
import { createScheduleWriter } from "../schedule/writer.js";
|
|
21
|
+
function ledgerFor(state, toneId) {
|
|
22
|
+
return state.read().migrationLedger.find(entry => entry.toneId === toneId && !entry.retired);
|
|
23
|
+
}
|
|
24
|
+
function recordApplied(state, tone, now, retiredChannelId, labelFingerprint) {
|
|
25
|
+
state.update('migrationLedger', current => {
|
|
26
|
+
const withoutTone = current.filter(entry => entry.toneId !== tone.id);
|
|
27
|
+
const retired = retiredChannelId === undefined ? [] : [{
|
|
28
|
+
at: now,
|
|
29
|
+
toneId: tone.id,
|
|
30
|
+
appliedVersion: 0,
|
|
31
|
+
channelId: retiredChannelId,
|
|
32
|
+
retired: true
|
|
33
|
+
}];
|
|
34
|
+
return [...withoutTone, ...retired, {
|
|
35
|
+
at: now,
|
|
36
|
+
toneId: tone.id,
|
|
37
|
+
appliedVersion: tone.version,
|
|
38
|
+
channelId: channelIdFor(tone.id, tone.version),
|
|
39
|
+
retired: false,
|
|
40
|
+
labelFingerprint
|
|
41
|
+
}];
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
export function createChannels(deps) {
|
|
45
|
+
const emit = deps.emit ?? (() => {});
|
|
46
|
+
// Re-homing re-writes each notification on the new channel; its stop marker
|
|
47
|
+
// has to follow, or it would retire with the old channel.
|
|
48
|
+
const writer = createScheduleWriter(deps.engine);
|
|
49
|
+
const applyTones = async (tones, groups) => {
|
|
50
|
+
// Validation completes before the first engine call, so a rejected
|
|
51
|
+
// declaration leaves the device exactly as it was — the same order the
|
|
52
|
+
// scheduler has always used.
|
|
53
|
+
validateToneDeclarations(tones);
|
|
54
|
+
const now = deps.now();
|
|
55
|
+
const created = [];
|
|
56
|
+
const migrated = [];
|
|
57
|
+
const labelsRefreshed = [];
|
|
58
|
+
const retired = [];
|
|
59
|
+
const reHomed = [];
|
|
60
|
+
const cancelled = [];
|
|
61
|
+
const bypassUnavailable = [];
|
|
62
|
+
const repeatUnavailable = [];
|
|
63
|
+
const unchanged = [];
|
|
64
|
+
if (groups.length > 0) {
|
|
65
|
+
await deps.engine.declareGroups(groups);
|
|
66
|
+
}
|
|
67
|
+
const capabilities = await deps.engine.getCapabilities();
|
|
68
|
+
for (const tone of tones) {
|
|
69
|
+
const previous = ledgerFor(deps.state, tone.id);
|
|
70
|
+
const resolved = resolveTone(tone);
|
|
71
|
+
const fingerprint = toneLabelFingerprint(tone);
|
|
72
|
+
|
|
73
|
+
// Refusals are reported for every tone that asked, whether or not
|
|
74
|
+
// anything else about it moved. A platform declining an attribute
|
|
75
|
+
// says nothing about whether the channel is new.
|
|
76
|
+
if (tone.bypassDoNotDisturb === true && !capabilities.supportsDoNotDisturbBypass) {
|
|
77
|
+
// Reported honestly rather than silently dropped — a consumer that
|
|
78
|
+
// asked for a bypass deserves to know the platform refused.
|
|
79
|
+
bypassUnavailable.push(tone.id);
|
|
80
|
+
emit(DIAGNOSTIC_CODES.DND_BYPASS_UNAVAILABLE, `Tone "${tone.id}" requested a Do Not Disturb bypass, which this platform does not permit.`, {
|
|
81
|
+
toneId: tone.id
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
if (tone.repeatAlert !== undefined) {
|
|
85
|
+
if (!capabilities.supportsRepeatingAlert) {
|
|
86
|
+
repeatUnavailable.push(tone.id);
|
|
87
|
+
emit(DIAGNOSTIC_CODES.REPEAT_ALERT_UNAVAILABLE, `Tone "${tone.id}" requested a repeating alert, which this platform does not offer. The notification still delivers and still sounds once.`, {
|
|
88
|
+
toneId: tone.id
|
|
89
|
+
});
|
|
90
|
+
} else if (!deps.engine.hasBackgroundDeliveryHandler()) {
|
|
91
|
+
// Said out loud at declaration time, because the alternative is a
|
|
92
|
+
// user meeting it as a phone that will not stop ringing.
|
|
93
|
+
emit(DIAGNOSTIC_CODES.REPEAT_STOP_HANDLER_MISSING, `Tone "${tone.id}" declares a repeating alert, but no background notification handler is registered. Its alert will not stop on its own while the app is not running. Call registerBackgroundNotificationHandler at module scope in index.js.`, {
|
|
94
|
+
toneId: tone.id
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const versionMoved = previous !== undefined && previous.appliedVersion !== tone.version;
|
|
99
|
+
if (previous !== undefined && !versionMoved) {
|
|
100
|
+
// The version is the same, so nothing the platform freezes has
|
|
101
|
+
// changed. Only the labels can still be stale — and correcting
|
|
102
|
+
// those must cost the user nothing, so the platform is touched
|
|
103
|
+
// only when the fingerprint actually moved.
|
|
104
|
+
if (previous.labelFingerprint === fingerprint) {
|
|
105
|
+
unchanged.push(tone.id);
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
const outcome = await deps.engine.declareTone(resolved);
|
|
109
|
+
if (outcome === 'created') {
|
|
110
|
+
// The channel was gone — deleted by the user, or lost with the
|
|
111
|
+
// app's data — so this is a first declaration rather than a
|
|
112
|
+
// refresh, whatever our ledger believed.
|
|
113
|
+
created.push(resolved.android.channelId);
|
|
114
|
+
} else if (outcome === 'labelsRefreshed') {
|
|
115
|
+
labelsRefreshed.push(tone.id);
|
|
116
|
+
emit(DIAGNOSTIC_CODES.TONE_LABELS_REFRESHED, `Tone "${tone.id}" had its name and description updated in place. No channel was recreated, so every setting the user adjusted on it is untouched.`, {
|
|
117
|
+
toneId: tone.id
|
|
118
|
+
});
|
|
119
|
+
} else {
|
|
120
|
+
unchanged.push(tone.id);
|
|
121
|
+
}
|
|
122
|
+
recordApplied(deps.state, tone, now, undefined, fingerprint);
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
const outcome = await deps.engine.declareTone(resolved);
|
|
126
|
+
if (outcome === 'created') {
|
|
127
|
+
created.push(resolved.android.channelId);
|
|
128
|
+
}
|
|
129
|
+
if (previous === undefined) {
|
|
130
|
+
recordApplied(deps.state, tone, now, undefined, fingerprint);
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// A version moved, so this is a migration rather than a first
|
|
135
|
+
// declaration. Re-home before retiring: the reverse order would leave
|
|
136
|
+
// live notifications attached to a channel that no longer exists.
|
|
137
|
+
emit(DIAGNOSTIC_CODES.CHANNEL_MIGRATION_REQUIRED, `Tone "${tone.id}" moved from version ${previous.appliedVersion} to ${tone.version}. Android channels are immutable, so a new channel was created and the old one is being retired.`, {
|
|
138
|
+
toneId: tone.id,
|
|
139
|
+
from: previous.appliedVersion,
|
|
140
|
+
to: tone.version
|
|
141
|
+
});
|
|
142
|
+
const pending = await deps.engine.getPending();
|
|
143
|
+
const affected = pending.filter(entry => entry.tone === tone.id);
|
|
144
|
+
for (const entry of affected) {
|
|
145
|
+
await writer.write({
|
|
146
|
+
request: {
|
|
147
|
+
id: entry.id,
|
|
148
|
+
content: entry.content,
|
|
149
|
+
tone: entry.tone,
|
|
150
|
+
moment: {
|
|
151
|
+
at: entry.resolvedAt,
|
|
152
|
+
anchoring: entry.anchoring
|
|
153
|
+
},
|
|
154
|
+
routing: entry.routing,
|
|
155
|
+
actions: entry.actions,
|
|
156
|
+
ownerTag: entry.ownerTag,
|
|
157
|
+
groupTag: entry.groupTag
|
|
158
|
+
},
|
|
159
|
+
resolvedAt: entry.resolvedAt,
|
|
160
|
+
tone: resolved,
|
|
161
|
+
// Re-homing changes the channel, not the anchoring — preserve it.
|
|
162
|
+
anchoringGeneration: entry.anchoringGeneration,
|
|
163
|
+
approximate: entry.mayBeDelayed,
|
|
164
|
+
seriesId: entry.seriesId,
|
|
165
|
+
pushCreated: entry.pushCreated
|
|
166
|
+
});
|
|
167
|
+
reHomed.push(entry.id);
|
|
168
|
+
}
|
|
169
|
+
const didRetire = await deps.engine.retireTone(previous.channelId);
|
|
170
|
+
if (didRetire) {
|
|
171
|
+
retired.push(previous.channelId);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// A version move outranks a label change: the new channel simply
|
|
175
|
+
// carries the new labels, and reporting it as a refresh would hide a
|
|
176
|
+
// migration the consumer needs to know about.
|
|
177
|
+
migrated.push({
|
|
178
|
+
toneId: tone.id,
|
|
179
|
+
from: previous.appliedVersion,
|
|
180
|
+
to: tone.version
|
|
181
|
+
});
|
|
182
|
+
recordApplied(deps.state, tone, now, previous.channelId, fingerprint);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// Anything left on a retired channel would be an orphan — a notification
|
|
186
|
+
// the user can no longer control from system settings.
|
|
187
|
+
const orphans = await findOrphans(deps, tones);
|
|
188
|
+
if (orphans.length > 0) {
|
|
189
|
+
await deps.engine.cancelMany(orphans);
|
|
190
|
+
cancelled.push(...orphans);
|
|
191
|
+
emit(DIAGNOSTIC_CODES.CHANNEL_ORPHANS_FOUND, `${orphans.length} notification(s) remained on a retired channel and were cancelled, rather than left uncontrollable from system settings.`, {
|
|
192
|
+
count: orphans.length
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
return {
|
|
196
|
+
created,
|
|
197
|
+
migrated,
|
|
198
|
+
labelsRefreshed,
|
|
199
|
+
retired,
|
|
200
|
+
reHomed,
|
|
201
|
+
cancelled,
|
|
202
|
+
bypassUnavailable,
|
|
203
|
+
repeatUnavailable,
|
|
204
|
+
unchanged
|
|
205
|
+
};
|
|
206
|
+
};
|
|
207
|
+
return {
|
|
208
|
+
/**
|
|
209
|
+
* Applies a tone configuration, migrating any tone whose version moved.
|
|
210
|
+
*
|
|
211
|
+
* Applying an unchanged configuration performs no work at all: no channel
|
|
212
|
+
* is recreated and no migration is triggered.
|
|
213
|
+
*/
|
|
214
|
+
apply(tones, groups = []) {
|
|
215
|
+
// The declared channels are read once for the whole apply rather than once
|
|
216
|
+
// per tone, when the engine can hold them (NOT-08).
|
|
217
|
+
const run = () => applyTones(tones, groups);
|
|
218
|
+
return deps.engine.withChannelSnapshot ? deps.engine.withChannelSnapshot(run) : run();
|
|
219
|
+
},
|
|
220
|
+
/** Which version of each tone this device actually holds. */
|
|
221
|
+
appliedVersions() {
|
|
222
|
+
return deps.state.read().migrationLedger.filter(entry => !entry.retired).map(entry => ({
|
|
223
|
+
toneId: entry.toneId,
|
|
224
|
+
appliedVersion: entry.appliedVersion
|
|
225
|
+
}));
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/** Notifications whose tone is no longer declared at all. */
|
|
231
|
+
async function findOrphans(deps, tones) {
|
|
232
|
+
const declared = new Set(tones.map(tone => tone.id));
|
|
233
|
+
// Only tones this package once applied can leave orphans (NOT-05). An entry
|
|
234
|
+
// with no tone metadata was scheduled by other code through the same engine,
|
|
235
|
+
// and a tone the ledger has never seen is not ours to judge either: cancelling
|
|
236
|
+
// on "not in this call's list" silently deleted other libraries' notifications,
|
|
237
|
+
// and a feature module's own when it applied only its subset of tones.
|
|
238
|
+
const onceApplied = new Set(deps.state.read().migrationLedger.map(entry => entry.toneId));
|
|
239
|
+
const pending = await deps.engine.getPending();
|
|
240
|
+
return pending.filter(entry => entry.tone !== '' && onceApplied.has(entry.tone) && !declared.has(entry.tone)).map(entry => entry.id);
|
|
241
|
+
}
|
|
242
|
+
//# sourceMappingURL=migrate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["DIAGNOSTIC_CODES","channelIdFor","resolveTone","toneLabelFingerprint","validateToneDeclarations","createScheduleWriter","ledgerFor","state","toneId","read","migrationLedger","find","entry","retired","recordApplied","tone","now","retiredChannelId","labelFingerprint","update","current","withoutTone","filter","id","undefined","at","appliedVersion","channelId","version","createChannels","deps","emit","writer","engine","applyTones","tones","groups","created","migrated","labelsRefreshed","reHomed","cancelled","bypassUnavailable","repeatUnavailable","unchanged","length","declareGroups","capabilities","getCapabilities","previous","resolved","fingerprint","bypassDoNotDisturb","supportsDoNotDisturbBypass","push","DND_BYPASS_UNAVAILABLE","repeatAlert","supportsRepeatingAlert","REPEAT_ALERT_UNAVAILABLE","hasBackgroundDeliveryHandler","REPEAT_STOP_HANDLER_MISSING","versionMoved","outcome","declareTone","android","TONE_LABELS_REFRESHED","CHANNEL_MIGRATION_REQUIRED","from","to","pending","getPending","affected","write","request","content","moment","resolvedAt","anchoring","routing","actions","ownerTag","groupTag","anchoringGeneration","approximate","mayBeDelayed","seriesId","pushCreated","didRetire","retireTone","orphans","findOrphans","cancelMany","CHANNEL_ORPHANS_FOUND","count","apply","run","withChannelSnapshot","appliedVersions","map","declared","Set","onceApplied","has"],"sourceRoot":"../../../src","sources":["channel/migrate.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA,SAASA,gBAAgB,QAAQ,uBAAoB;AACrD,SAASC,YAAY,EAAEC,WAAW,EAAE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QAAEJ,MAAM,EAAEI,KAAK,CAACJ,MAAM;QAAEkB,cAAc,EAAEd,KAAK,CAACc;MAAe,CAAC,CAAC,CAAC;IACjF;EACD,CAAC;AACF;;AAEA;AACA,eAAegE,WAAWA,CACzB5D,IAAyB,EACzBK,KAAiC,EACJ;EAC7B,MAAMgE,QAAQ,GAAG,IAAIC,GAAG,CAACjE,KAAK,CAAC+D,GAAG,CAACnF,IAAI,IAAIA,IAAI,CAACQ,EAAE,CAAC,CAAC;EACpD;EACA;EACA;EACA;EACA;EACA,MAAM8E,WAAW,GAAG,IAAID,GAAG,CAACtE,IAAI,CAACvB,KAAK,CAACE,IAAI,CAAC,CAAC,CAACC,eAAe,CAACwF,GAAG,CAACtF,KAAK,IAAIA,KAAK,CAACJ,MAAM,CAAC,CAAC;EACzF,MAAM6D,OAAO,GAAG,MAAMvC,IAAI,CAACG,MAAM,CAACqC,UAAU,CAAC,CAAC;EAC9C,OAAOD,OAAO,CACZ/C,MAAM,CAACV,KAAK,IAAIA,KAAK,CAACG,IAAI,KAAK,EAAE,IAAIsF,WAAW,CAACC,GAAG,CAAC1F,KAAK,CAACG,IAAI,CAAC,IAAI,CAACoF,QAAQ,CAACG,GAAG,CAAC1F,KAAK,CAACG,IAAI,CAAC,CAAC,CAC9FmF,GAAG,CAACtF,KAAK,IAAIA,KAAK,CAACW,EAAE,CAAC;AACzB","ignoreList":[]}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Tone-to-platform mapping.
|
|
5
|
+
*
|
|
6
|
+
* A tone is declared once and realized on each platform here, so consumer code
|
|
7
|
+
* contains zero platform branches. The two platforms model urgency differently
|
|
8
|
+
* — Android by channel importance, iOS by interruption level — and reconciling
|
|
9
|
+
* that difference is exactly the work this package exists to absorb.
|
|
10
|
+
*
|
|
11
|
+
* The channel id carries the tone version. Android channels are immutable once
|
|
12
|
+
* created and re-declaration is silently ignored, so a configuration change has
|
|
13
|
+
* to produce a *new* channel or it will never reach a device that already holds
|
|
14
|
+
* the old one.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { fnv1a, hex8 } from "../contract/hash.js";
|
|
18
|
+
const ANDROID_IMPORTANCE = {
|
|
19
|
+
min: 'min',
|
|
20
|
+
low: 'low',
|
|
21
|
+
default: 'default',
|
|
22
|
+
high: 'high',
|
|
23
|
+
// Android has no level above `high`; max urgency is expressed by the DND
|
|
24
|
+
// bypass rather than by a distinct importance.
|
|
25
|
+
max: 'high'
|
|
26
|
+
};
|
|
27
|
+
const IOS_INTERRUPTION = {
|
|
28
|
+
min: 'passive',
|
|
29
|
+
low: 'passive',
|
|
30
|
+
default: 'active',
|
|
31
|
+
high: 'active',
|
|
32
|
+
// `timeSensitive` is the highest level available without the Critical Alerts
|
|
33
|
+
// entitlement, which is out of scope for v1.
|
|
34
|
+
max: 'timeSensitive'
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/** Channel id for a tone at a given version. Stable, derived, never random. */
|
|
38
|
+
export function channelIdFor(toneId, version) {
|
|
39
|
+
return `${toneId}.v${version}`;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Extracts the tone and version encoded in a channel id, if it is one of ours. */
|
|
43
|
+
export function parseChannelId(channelId) {
|
|
44
|
+
const separator = channelId.lastIndexOf('.v');
|
|
45
|
+
if (separator === -1) return undefined;
|
|
46
|
+
const version = Number.parseInt(channelId.slice(separator + 2), 10);
|
|
47
|
+
if (!Number.isInteger(version) || version < 1) return undefined;
|
|
48
|
+
return {
|
|
49
|
+
toneId: channelId.slice(0, separator),
|
|
50
|
+
version
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export function resolveTone(tone) {
|
|
54
|
+
const silent = tone.sound?.enabled === false;
|
|
55
|
+
const repeats = tone.repeatAlert !== undefined;
|
|
56
|
+
return {
|
|
57
|
+
toneId: tone.id,
|
|
58
|
+
version: tone.version,
|
|
59
|
+
android: {
|
|
60
|
+
channelId: channelIdFor(tone.id, tone.version),
|
|
61
|
+
// The declared label, not the identifier. Passing the identifier here
|
|
62
|
+
// is what put a technical string on the one screen these exist for.
|
|
63
|
+
name: tone.name,
|
|
64
|
+
description: tone.description,
|
|
65
|
+
importance: ANDROID_IMPORTANCE[tone.urgency],
|
|
66
|
+
sound: silent ? undefined : tone.sound?.name,
|
|
67
|
+
vibration: tone.vibration ?? false,
|
|
68
|
+
badge: tone.badge ?? false,
|
|
69
|
+
bypassDnd: tone.bypassDoNotDisturb ?? false,
|
|
70
|
+
groupId: tone.groupId,
|
|
71
|
+
// Both are per-notification rather than channel configuration, which
|
|
72
|
+
// is precisely why neither obliges a consumer to bump `version`.
|
|
73
|
+
loopSound: repeats,
|
|
74
|
+
alarmCategory: tone.timeSensitive ?? false,
|
|
75
|
+
repeatForMs: tone.repeatAlert?.forMs
|
|
76
|
+
},
|
|
77
|
+
ios: {
|
|
78
|
+
// iOS categories are not versioned: they carry actions rather than
|
|
79
|
+
// user-adjustable settings, so re-declaring one is harmless.
|
|
80
|
+
categoryId: tone.id,
|
|
81
|
+
interruptionLevel: tone.timeSensitive === true ? 'timeSensitive' : IOS_INTERRUPTION[tone.urgency],
|
|
82
|
+
sound: silent ? undefined : tone.sound?.name,
|
|
83
|
+
badge: tone.badge ?? false,
|
|
84
|
+
// iOS exposes no looping-sound API at all. Recorded as data so the
|
|
85
|
+
// refusal can be reported rather than discovered.
|
|
86
|
+
repeatRefused: repeats
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* A stable fingerprint of a tone's user-visible labels.
|
|
93
|
+
*
|
|
94
|
+
* Lets an unchanged configuration skip the platform entirely, which is what
|
|
95
|
+
* keeps "re-applying changes nothing" literally true rather than merely
|
|
96
|
+
* approximately true. A hash rather than the labels themselves, so persisted
|
|
97
|
+
* state continues to hold no consumer-supplied text.
|
|
98
|
+
*/
|
|
99
|
+
export function toneLabelFingerprint(tone) {
|
|
100
|
+
// The separator matters: without it, a name of "ab" with description "c" and
|
|
101
|
+
// a name of "a" with description "bc" would fingerprint identically, and one
|
|
102
|
+
// of the two would never get its correction.
|
|
103
|
+
const source = `${tone.name}\u0000${tone.description ?? ''}`;
|
|
104
|
+
return hex8(fnv1a(source));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** Builds a lookup over a declared configuration. */
|
|
108
|
+
export function createToneResolver(tones) {
|
|
109
|
+
const resolved = new Map(tones.map(tone => [tone.id, resolveTone(tone)]));
|
|
110
|
+
return toneId => resolved.get(toneId);
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=tone-map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["fnv1a","hex8","ANDROID_IMPORTANCE","min","low","default","high","max","IOS_INTERRUPTION","channelIdFor","toneId","version","parseChannelId","channelId","separator","lastIndexOf","undefined","Number","parseInt","slice","isInteger","resolveTone","tone","silent","sound","enabled","repeats","repeatAlert","id","android","name","description","importance","urgency","vibration","badge","bypassDnd","bypassDoNotDisturb","groupId","loopSound","alarmCategory","timeSensitive","repeatForMs","forMs","ios","categoryId","interruptionLevel","repeatRefused","toneLabelFingerprint","source","createToneResolver","tones","resolved","Map","map","get"],"sourceRoot":"../../../src","sources":["channel/tone-map.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,KAAK,EAAEC,IAAI,QAAQ,qBAAkB;AAK9C,MAAMC,kBAA0D,GAAG;EAClEC,GAAG,EAAE,KAAK;EACVC,GAAG,EAAE,KAAK;EACVC,OAAO,EAAE,SAAS;EAClBC,IAAI,EAAE,MAAM;EACZ;EACA;EACAC,GAAG,EAAE;AACN,CAAC;AAED,MAAMC,gBAAsD,GAAG;EAC9DL,GAAG,EAAE,SAAS;EACdC,GAAG,EAAE,SAAS;EACdC,OAAO,EAAE,QAAQ;EACjBC,IAAI,EAAE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AM,IAAI0C,QAAQ,CAACG,GAAG,CAAC7C,MAAM,CAAC;AACtC","ignoreList":[]}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Tone declaration validation.
|
|
5
|
+
*
|
|
6
|
+
* Runs before the first engine call, like every other validation in this
|
|
7
|
+
* package: a rejected declaration must leave the device exactly as it was.
|
|
8
|
+
*
|
|
9
|
+
* Only the new alert attributes are checked here. The rest of a tone has always
|
|
10
|
+
* been validated by the platform's own charset and shape rules, and duplicating
|
|
11
|
+
* those would create two sources of truth for the same constraint.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { REPEAT_ALERT_BOUNDS } from "../contract/channel.js";
|
|
15
|
+
import { DIAGNOSTIC_CODES, NotificationError } from "../contract/errors.js";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Throws when a tone's repeating alert is unusable.
|
|
19
|
+
*
|
|
20
|
+
* The type already forbids a repeat without a duration. What it cannot forbid
|
|
21
|
+
* is a duration of zero, a fractional millisecond, or an hour and a half — and
|
|
22
|
+
* an alert that repeats for an unchecked span is the failure this whole feature
|
|
23
|
+
* exists to prevent.
|
|
24
|
+
*/
|
|
25
|
+
export function validateToneDeclaration(tone) {
|
|
26
|
+
const repeat = tone.repeatAlert;
|
|
27
|
+
if (repeat === undefined) return;
|
|
28
|
+
if (!Number.isInteger(repeat.forMs)) {
|
|
29
|
+
throw new NotificationError(DIAGNOSTIC_CODES.INVALID_TONE_REPEAT, `Tone "${tone.id}" declared a repeating alert whose duration is not a whole number of milliseconds.`, {
|
|
30
|
+
toneId: tone.id,
|
|
31
|
+
forMs: repeat.forMs
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
if (repeat.forMs < REPEAT_ALERT_BOUNDS.minMs || repeat.forMs > REPEAT_ALERT_BOUNDS.maxMs) {
|
|
35
|
+
throw new NotificationError(DIAGNOSTIC_CODES.INVALID_TONE_REPEAT, `Tone "${tone.id}" declared a repeating alert of ${repeat.forMs}ms, outside the permitted ${REPEAT_ALERT_BOUNDS.minMs}–${REPEAT_ALERT_BOUNDS.maxMs}ms range. A shorter repeat is indistinguishable from a single chime; a longer one outlasts anyone's willingness to respond.`, {
|
|
36
|
+
toneId: tone.id,
|
|
37
|
+
forMs: repeat.forMs,
|
|
38
|
+
...REPEAT_ALERT_BOUNDS
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
if (tone.sound?.enabled === false) {
|
|
42
|
+
// Two instructions that cannot both be honoured. Picking one silently
|
|
43
|
+
// would ship whichever the reader did not expect, and the consumer would
|
|
44
|
+
// discover it on a device rather than here.
|
|
45
|
+
throw new NotificationError(DIAGNOSTIC_CODES.INVALID_TONE_REPEAT, `Tone "${tone.id}" declares both a repeating alert and a silent sound. Repeating silence is not a behaviour; drop one of the two.`, {
|
|
46
|
+
toneId: tone.id
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Validates a whole configuration before any of it is applied. */
|
|
52
|
+
export function validateToneDeclarations(tones) {
|
|
53
|
+
for (const tone of tones) {
|
|
54
|
+
validateToneDeclaration(tone);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=validate-tone.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["REPEAT_ALERT_BOUNDS","DIAGNOSTIC_CODES","NotificationError","validateToneDeclaration","tone","repeat","repeatAlert","undefined","Number","isInteger","forMs","INVALID_TONE_REPEAT","id","toneId","minMs","maxMs","sound","enabled","validateToneDeclarations","tones"],"sourceRoot":"../../../src","sources":["channel/validate-tone.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,mBAAmB,QAAQ,wBAAqB;AACzD,SAASC,gBAAgB,EAAEC,iBAAiB,QAAQ,uBAAoB;;AAExE;AACA;AACA;AACA;AACA;AACA;A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
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Channel, category, and tone declaration types.
|
|
5
|
+
*
|
|
6
|
+
* A tone is declared once and mapped by the package to each platform's
|
|
7
|
+
* equivalent concepts, so consumer code contains no platform branches.
|
|
8
|
+
*
|
|
9
|
+
* Two tones must never be merged into one: channel configuration belongs to
|
|
10
|
+
* the user, and collapsing two tones collapses two independent user choices.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/** How insistently a notification asks for attention. */
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A repeating alert and the bound on how long it may repeat.
|
|
17
|
+
*
|
|
18
|
+
* The two are one object rather than two fields because an unbounded repeating
|
|
19
|
+
* alert must be *unrepresentable*, not merely discouraged. A boolean `repeat`
|
|
20
|
+
* beside an optional duration would make the dangerous state the easiest one to
|
|
21
|
+
* write, and the dangerous state here is a phone that keeps sounding until its
|
|
22
|
+
* owner comes home to it.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The declarable range for a repeating alert.
|
|
27
|
+
*
|
|
28
|
+
* The floor exists because a repeat shorter than a minute is indistinguishable
|
|
29
|
+
* from a single chime and buys nothing for the complexity it costs. The ceiling
|
|
30
|
+
* exists because an hour is already past the point where a person who has not
|
|
31
|
+
* responded is going to.
|
|
32
|
+
*/
|
|
33
|
+
export const REPEAT_ALERT_BOUNDS = {
|
|
34
|
+
minMs: 60_000,
|
|
35
|
+
maxMs: 3_600_000
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/** What a tone resolves to on each platform. Internal to the engine adapter. */
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Outcome of applying a channel configuration, including any migration performed.
|
|
42
|
+
*
|
|
43
|
+
* A tone appears in exactly one of `created`, `migrated`, `labelsRefreshed`, and
|
|
44
|
+
* `unchanged`. The `*Unavailable` arrays are orthogonal and may accompany any of
|
|
45
|
+
* them: a platform refusing an attribute says nothing about whether the tone was
|
|
46
|
+
* newly created.
|
|
47
|
+
*/
|
|
48
|
+
//# sourceMappingURL=channel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["REPEAT_ALERT_BOUNDS","minMs","maxMs"],"sourceRoot":"../../../src","sources":["contract/channel.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,mBAAmB,GAAG;EAClCC,KAAK,EAAE,MAAM;EACbC,KAAK,EAAE;AACR,CAAU;;AA6DV;;AAgDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Diagnostics and configuration types.
|
|
5
|
+
*
|
|
6
|
+
* The package's stated purpose is to make invisible notification failures
|
|
7
|
+
* diagnosable, so every lifecycle transition emits a structured event with a
|
|
8
|
+
* stable identifier — and none of those events carries content by default.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** Health of one persisted collection against its cap. */
|
|
12
|
+
|
|
13
|
+
/** The readable answer to "why didn't it arrive". */
|
|
14
|
+
|
|
15
|
+
/** Abnormal notification volume. Reported, never acted upon. */
|
|
16
|
+
|
|
17
|
+
export const DEFAULT_BURST_THRESHOLD = {
|
|
18
|
+
perMinute: 10,
|
|
19
|
+
perHour: 60
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=diagnostics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["DEFAULT_BURST_THRESHOLD","perMinute","perHour"],"sourceRoot":"../../../src","sources":["contract/diagnostics.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAyBA;;AAgBA;;AAgBA;;AAMA,OAAO,MAAMA,uBAAuC,GAAG;EACtDC,SAAS,EAAE,EAAE;EACbC,OAAO,EAAE;AACV,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Typed error taxonomy and stable diagnostic identifiers.
|
|
5
|
+
*
|
|
6
|
+
* Every failure condition carries its own identifier. None collapses into a
|
|
7
|
+
* generic failure — an error that says only "scheduling failed" reproduces the
|
|
8
|
+
* problem this package exists to solve.
|
|
9
|
+
*
|
|
10
|
+
* Identifiers are stable across releases and safe to switch on. Adding new ones
|
|
11
|
+
* is an additive minor change.
|
|
12
|
+
*
|
|
13
|
+
* See `specs/009-rn-notification-package/contracts/errors.md`.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { SdkError } from '@chipmobilesdk/rn-core';
|
|
17
|
+
import { redactContext } from "../diagnostics/redact.js";
|
|
18
|
+
export const DIAGNOSTIC_CODES = {
|
|
19
|
+
// --- Validation: raised before any platform call -------------------------
|
|
20
|
+
INVALID_ID_EMPTY: 'INVALID_ID_EMPTY',
|
|
21
|
+
INVALID_ID_LENGTH: 'INVALID_ID_LENGTH',
|
|
22
|
+
INVALID_ID_CHARSET: 'INVALID_ID_CHARSET',
|
|
23
|
+
INVALID_OWNER_TAG: 'INVALID_OWNER_TAG',
|
|
24
|
+
INVALID_GROUP_TAG: 'INVALID_GROUP_TAG',
|
|
25
|
+
MOMENT_IN_PAST: 'MOMENT_IN_PAST',
|
|
26
|
+
UNDECLARED_TONE: 'UNDECLARED_TONE',
|
|
27
|
+
ROUTING_PAYLOAD_TOO_LARGE: 'ROUTING_PAYLOAD_TOO_LARGE',
|
|
28
|
+
CONTENT_TOO_LARGE: 'CONTENT_TOO_LARGE',
|
|
29
|
+
TOO_MANY_ACTIONS: 'TOO_MANY_ACTIONS',
|
|
30
|
+
INVALID_RECURRENCE: 'INVALID_RECURRENCE',
|
|
31
|
+
INVALID_TONE_REPEAT: 'INVALID_TONE_REPEAT',
|
|
32
|
+
// --- Reconciliation ------------------------------------------------------
|
|
33
|
+
DUPLICATE_IDENTIFIER: 'DUPLICATE_IDENTIFIER',
|
|
34
|
+
TRUNCATED_OVER_CEILING: 'TRUNCATED_OVER_CEILING',
|
|
35
|
+
RECONCILE_INTERRUPTED: 'RECONCILE_INTERRUPTED',
|
|
36
|
+
PENDING_SET_DISCREPANCY: 'PENDING_SET_DISCREPANCY',
|
|
37
|
+
// --- Permissions ---------------------------------------------------------
|
|
38
|
+
DISPLAY_PERMISSION_DENIED: 'DISPLAY_PERMISSION_DENIED',
|
|
39
|
+
DISPLAY_PERMISSION_PERMANENT: 'DISPLAY_PERMISSION_PERMANENT',
|
|
40
|
+
EXACT_ALARM_UNAVAILABLE: 'EXACT_ALARM_UNAVAILABLE',
|
|
41
|
+
SETTINGS_UNAVAILABLE: 'SETTINGS_UNAVAILABLE',
|
|
42
|
+
BACKGROUND_RESTRICTED: 'BACKGROUND_RESTRICTED',
|
|
43
|
+
BACKGROUND_RESTRICTION_UNKNOWN: 'BACKGROUND_RESTRICTION_UNKNOWN',
|
|
44
|
+
// --- Channels ------------------------------------------------------------
|
|
45
|
+
CHANNEL_MIGRATION_REQUIRED: 'CHANNEL_MIGRATION_REQUIRED',
|
|
46
|
+
CHANNEL_MIGRATION_FAILED: 'CHANNEL_MIGRATION_FAILED',
|
|
47
|
+
CHANNEL_ORPHANS_FOUND: 'CHANNEL_ORPHANS_FOUND',
|
|
48
|
+
DND_BYPASS_UNAVAILABLE: 'DND_BYPASS_UNAVAILABLE',
|
|
49
|
+
TONE_LABELS_REFRESHED: 'TONE_LABELS_REFRESHED',
|
|
50
|
+
REPEAT_ALERT_UNAVAILABLE: 'REPEAT_ALERT_UNAVAILABLE',
|
|
51
|
+
REPEAT_STOP_HANDLER_MISSING: 'REPEAT_STOP_HANDLER_MISSING',
|
|
52
|
+
// --- Interaction ---------------------------------------------------------
|
|
53
|
+
TARGET_MISSING: 'TARGET_MISSING',
|
|
54
|
+
INTERACTION_BUFFER_EVICTED: 'INTERACTION_BUFFER_EVICTED',
|
|
55
|
+
BACKGROUND_WINDOW_EXCEEDED: 'BACKGROUND_WINDOW_EXCEEDED',
|
|
56
|
+
// --- Push ----------------------------------------------------------------
|
|
57
|
+
PUSH_UNAVAILABLE: 'PUSH_UNAVAILABLE',
|
|
58
|
+
TOKEN_UNAVAILABLE: 'TOKEN_UNAVAILABLE',
|
|
59
|
+
TOKEN_INVALIDATION_FAILED: 'TOKEN_INVALIDATION_FAILED',
|
|
60
|
+
PAYLOAD_MALFORMED: 'PAYLOAD_MALFORMED',
|
|
61
|
+
PAYLOAD_VERSION_SKEW: 'PAYLOAD_VERSION_SKEW',
|
|
62
|
+
PAYLOAD_DUPLICATE: 'PAYLOAD_DUPLICATE',
|
|
63
|
+
PUSH_UNDELIVERABLE: 'PUSH_UNDELIVERABLE',
|
|
64
|
+
// --- Persisted state -----------------------------------------------------
|
|
65
|
+
STATE_CORRUPT_REBUILT: 'STATE_CORRUPT_REBUILT',
|
|
66
|
+
STATE_WRITE_FAILED: 'STATE_WRITE_FAILED',
|
|
67
|
+
/** The durable store could not open; state lasts for this session only. */
|
|
68
|
+
STATE_STORE_DEGRADED: 'STATE_STORE_DEGRADED',
|
|
69
|
+
STATE_CAP_EVICTED: 'STATE_CAP_EVICTED',
|
|
70
|
+
/**
|
|
71
|
+
* A ledger holds more live entries than its cap (0.6.0). They are all kept:
|
|
72
|
+
* dropping a live series or channel record would lose a migration or reset a
|
|
73
|
+
* series count. Reported so the cap can be raised or the app's use reviewed.
|
|
74
|
+
*/
|
|
75
|
+
STATE_CAP_EXCEEDED: 'STATE_CAP_EXCEEDED',
|
|
76
|
+
// --- Volume --------------------------------------------------------------
|
|
77
|
+
BURST_THRESHOLD_EXCEEDED: 'BURST_THRESHOLD_EXCEEDED',
|
|
78
|
+
// --- Maintenance (0.4.0) -------------------------------------------------
|
|
79
|
+
/** An automatic maintenance cycle threw. Reported here because no caller awaits it. */
|
|
80
|
+
MAINTENANCE_FAILED: 'MAINTENANCE_FAILED'
|
|
81
|
+
};
|
|
82
|
+
/** Every identifier, for exhaustiveness tests and the documentation table. */
|
|
83
|
+
export const ALL_DIAGNOSTIC_CODES = Object.freeze(Object.values(DIAGNOSTIC_CODES));
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* A typed package failure.
|
|
87
|
+
*
|
|
88
|
+
* Carries enough context to choose a recovery, and never carries notification
|
|
89
|
+
* body text, routing payload values, or token material. Where a value violated
|
|
90
|
+
* a rule, the *shape* of the violation is reported — a length, a character
|
|
91
|
+
* position — rather than the value itself.
|
|
92
|
+
*/
|
|
93
|
+
export class NotificationError extends SdkError {
|
|
94
|
+
constructor(code, message, context) {
|
|
95
|
+
super('rn-notification', code, {
|
|
96
|
+
message
|
|
97
|
+
});
|
|
98
|
+
this.name = 'NotificationError';
|
|
99
|
+
// Redacted on the way in: an error object reaches crash reporters, which
|
|
100
|
+
// never run with verbose diagnostics.
|
|
101
|
+
const redacted = redactContext(context, false);
|
|
102
|
+
if (redacted !== undefined) {
|
|
103
|
+
this.context = redacted;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
export function isNotificationError(value) {
|
|
108
|
+
return value instanceof NotificationError;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Conditions that are reported outcomes rather than failures: the operation
|
|
113
|
+
* succeeded, and something the caller needs to know happened alongside it.
|
|
114
|
+
*/
|
|
115
|
+
export const NON_FAILURE_CODES = Object.freeze([DIAGNOSTIC_CODES.TRUNCATED_OVER_CEILING, DIAGNOSTIC_CODES.PENDING_SET_DISCREPANCY, DIAGNOSTIC_CODES.EXACT_ALARM_UNAVAILABLE, DIAGNOSTIC_CODES.TARGET_MISSING, DIAGNOSTIC_CODES.BURST_THRESHOLD_EXCEEDED, DIAGNOSTIC_CODES.PAYLOAD_VERSION_SKEW, DIAGNOSTIC_CODES.PAYLOAD_DUPLICATE, DIAGNOSTIC_CODES.STATE_CAP_EVICTED, DIAGNOSTIC_CODES.STATE_CAP_EXCEEDED, DIAGNOSTIC_CODES.STATE_CORRUPT_REBUILT, DIAGNOSTIC_CODES.BACKGROUND_RESTRICTION_UNKNOWN, DIAGNOSTIC_CODES.DND_BYPASS_UNAVAILABLE, DIAGNOSTIC_CODES.TONE_LABELS_REFRESHED, DIAGNOSTIC_CODES.REPEAT_ALERT_UNAVAILABLE, DIAGNOSTIC_CODES.REPEAT_STOP_HANDLER_MISSING]);
|
|
116
|
+
export function isNonFailure(code) {
|
|
117
|
+
return NON_FAILURE_CODES.includes(code);
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["SdkError","redactContext","DIAGNOSTIC_CODES","INVALID_ID_EMPTY","INVALID_ID_LENGTH","INVALID_ID_CHARSET","INVALID_OWNER_TAG","INVALID_GROUP_TAG","MOMENT_IN_PAST","UNDECLARED_TONE","ROUTING_PAYLOAD_TOO_LARGE","CONTENT_TOO_LARGE","TOO_MANY_ACTIONS","INVALID_RECURRENCE","INVALID_TONE_REPEAT","DUPLICATE_IDENTIFIER","TRUNCATED_OVER_CEILING","RECONCILE_INTERRUPTED","PENDING_SET_DISCREPANCY","DISPLAY_PERMISSION_DENIED","DISPLAY_PERMISSION_PERMANENT","EXACT_ALARM_UNAVAILABLE","SETTINGS_UNAVAILABLE","BACKGROUND_RESTRICTED","BACKGROUND_RESTRICTION_UNKNOWN","CHANNEL_MIGRATION_REQUIRED","CHANNEL_MIGRATION_FAILED","CHANNEL_ORPHANS_FOUND","DND_BYPASS_UNAVAILABLE","TONE_LABELS_REFRESHED","REPEAT_ALERT_UNAVAILABLE","REPEAT_STOP_HANDLER_MISSING","TARGET_MISSING","INTERACTION_BUFFER_EVICTED","BACKGROUND_WINDOW_EXCEEDED","PUSH_UNAVAILABLE","TOKEN_UNAVAILABLE","TOKEN_INVALIDATION_FAILED","PAYLOAD_MALFORMED","PAYLOAD_VERSION_SKEW","PAYLOAD_DUPLICATE","PUSH_UNDELIVERABLE","STATE_CORRUPT_REBUILT","STATE_WRITE_FAILED","STATE_STORE_DEGRADED","STATE_CAP_EVICTED","STATE_CAP_EXCEEDED","BURST_THRESHOLD_EXCEEDED","MAINTENANCE_FAILED","ALL_DIAGNOSTIC_CODES","Object","freeze","values","NotificationError","constructor","code","message","context","name","redacted","undefined","isNotificationError","value","NON_FAILURE_CODES","isNonFailure","includes"],"sourceRoot":"../../../src","sources":["contract/errors.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,QAAQ,QAAQ,wBAAwB;AAEjD,SAASC,aAAa,QAAQ,0BAAuB;AAErD,OAAO,MAAMC,gBAAgB,GAAG;EAC/B;EACAC,gBAAgB,EAAE,kBAAkB;EACpCC,iBAAiB,EAAE,mBAAmB;EACtCC,kBAAkB,EAAE,oBAAoB;EACxCC,iBAAiB,EAAE,mBAAmB;EACtCC,iBAAiB,EAAE,mBAAmB;EACtCC,cAAc,EAAE,gBAAgB;EAChCC,eAAe,EAAE,iBAAiB;EAClCC,yBAAyB,EAAE,2BAA2B;EACtDC,iBAAiB,EAAE,mBAAmB;EACtCC,gBAAgB,EAAE,kBAAkB;EACpCC,kBAAkB,EAAE,oBAAoB;EACxCC,mBAAmB,EAAE,qBAAqB;EAE1C;EACAC,oBAAoB,EAAE,sBAAsB;EAC5CC,sBAAsB,EAAE,wBAAwB;EAChDC,qBAAqB,EAAE,uBAAuB;EAC9CC,uBAAuB,EAAE,yBAAyB;EAElD;EACAC,yBAAyB,EAAE,2BAA2B;EACtDC,4BAA4B,EAAE,8BAA8B;EAC5DC,uBAAuB,EAAE,yBAAyB;EAClDC,oBAAoB,EAAE,sBAAsB;EAC5CC,qBAAqB,EAAE,uBAAuB;EAC9CC,8BAA8B,EAAE,gCAA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