@chipmobilesdk/rn-notification 0.5.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 +184 -0
- package/README.md +108 -16
- 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 +74 -23
- package/skills/sdk-rn-notification/SKILL.md +6 -5
- package/src/advanced.ts +35 -0
- package/src/channel/migrate.ts +176 -158
- package/src/channel/tone-map.ts +2 -10
- package/src/contract/errors.ts +7 -0
- package/src/contract/hash.ts +26 -0
- package/src/engine/adapter.ts +21 -1
- package/src/engine/notify-kit/events.ts +155 -0
- package/src/engine/notify-kit/module.ts +148 -0
- package/src/engine/notify-kit/platform/android.ts +172 -0
- package/src/engine/notify-kit/platform/index.ts +55 -0
- package/src/engine/notify-kit/platform/ios.ts +54 -0
- package/src/engine/notify-kit/platform/types.ts +40 -0
- package/src/engine/notify-kit-engine.ts +96 -477
- package/src/index.ts +9 -0
- package/src/notifications.ts +195 -0
- package/src/permission/index.ts +65 -4
- package/src/push/fcm-provider.ts +14 -4
- package/src/push/gate.ts +27 -5
- package/src/reconcile/diff.ts +38 -27
- package/src/reconcile/index.ts +13 -4
- package/src/recurrence/index.ts +2 -1
- package/src/repeat/expiry.ts +2 -6
- package/src/repeat/index.ts +45 -1
- package/src/repeat/marker.ts +1 -22
- package/src/repeat/place.ts +74 -35
- package/src/schedule/index.ts +10 -4
- package/src/schedule/partition.ts +0 -19
- package/src/schedule/validate-identifier.ts +8 -6
- package/src/schedule/writer.ts +13 -4
- package/src/state/caps.ts +28 -3
- package/src/state/permission-history.ts +25 -0
- package/src/state/record.ts +110 -20
- package/src/testing/fake-engine.ts +17 -1
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Burst detection.
|
|
5
|
+
*
|
|
6
|
+
* Both platforms apply undocumented delivery rate limits and will silently drop
|
|
7
|
+
* or delay past them — which is exactly the invisible failure this package
|
|
8
|
+
* exists to eliminate. So volume is watched and reported.
|
|
9
|
+
*
|
|
10
|
+
* It is **not** acted upon. Nothing is throttled, delayed, coalesced, or
|
|
11
|
+
* dropped: deciding which of a user's notifications to suppress is a product
|
|
12
|
+
* decision the package has no basis to make. Noticing that something abnormal
|
|
13
|
+
* is happening is one it can.
|
|
14
|
+
*
|
|
15
|
+
* Counters are in memory only. A burst is a live condition, and persisting it
|
|
16
|
+
* would expand the state contract for no diagnostic gain.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { DEFAULT_BURST_THRESHOLD } from "../contract/diagnostics.js";
|
|
20
|
+
import { DIAGNOSTIC_CODES } from "../contract/errors.js";
|
|
21
|
+
const MINUTE_MS = 60_000;
|
|
22
|
+
const HOUR_MS = 60 * MINUTE_MS;
|
|
23
|
+
export function createBurstDetector(deps = {}) {
|
|
24
|
+
const threshold = deps.threshold ?? DEFAULT_BURST_THRESHOLD;
|
|
25
|
+
const emit = deps.emit ?? (() => {});
|
|
26
|
+
/** Per owner tag, because one busy account should not implicate another. */
|
|
27
|
+
const timestamps = new Map();
|
|
28
|
+
/** Prevents one sustained burst producing a diagnostic per notification. */
|
|
29
|
+
const reportedAt = new Map();
|
|
30
|
+
const prune = (tag, now) => {
|
|
31
|
+
const kept = (timestamps.get(tag) ?? []).filter(at => now - at <= HOUR_MS);
|
|
32
|
+
timestamps.set(tag, kept);
|
|
33
|
+
return kept;
|
|
34
|
+
};
|
|
35
|
+
return {
|
|
36
|
+
/**
|
|
37
|
+
* Records one presented notification and reports if the threshold is crossed.
|
|
38
|
+
*
|
|
39
|
+
* Always returns after recording — the caller delivers regardless of what
|
|
40
|
+
* this says.
|
|
41
|
+
*/
|
|
42
|
+
record(now, ownerTag = '*') {
|
|
43
|
+
const kept = prune(ownerTag, now);
|
|
44
|
+
kept.push(now);
|
|
45
|
+
const lastMinute = kept.filter(at => now - at <= MINUTE_MS).length;
|
|
46
|
+
const lastHour = kept.length;
|
|
47
|
+
const exceeded = lastMinute > threshold.perMinute || lastHour > threshold.perHour;
|
|
48
|
+
if (exceeded) {
|
|
49
|
+
const last = reportedAt.get(ownerTag) ?? 0;
|
|
50
|
+
// One report per minute per tag; a sustained burst is one condition,
|
|
51
|
+
// not a hundred.
|
|
52
|
+
if (now - last >= MINUTE_MS) {
|
|
53
|
+
reportedAt.set(ownerTag, now);
|
|
54
|
+
emit(DIAGNOSTIC_CODES.BURST_THRESHOLD_EXCEEDED, `Abnormal notification volume: ${lastMinute} in the last minute and ${lastHour} in the last hour (thresholds ${threshold.perMinute}/minute, ${threshold.perHour}/hour). Every notification was still delivered — the package throttles nothing.`, {
|
|
55
|
+
ownerTag,
|
|
56
|
+
lastMinute,
|
|
57
|
+
lastHour,
|
|
58
|
+
threshold
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
ownerTag,
|
|
64
|
+
lastMinute,
|
|
65
|
+
lastHour,
|
|
66
|
+
exceeded
|
|
67
|
+
};
|
|
68
|
+
},
|
|
69
|
+
status(now, ownerTag = '*') {
|
|
70
|
+
const kept = prune(ownerTag, now);
|
|
71
|
+
const lastMinute = kept.filter(at => now - at <= MINUTE_MS).length;
|
|
72
|
+
return {
|
|
73
|
+
ownerTag,
|
|
74
|
+
lastMinute,
|
|
75
|
+
lastHour: kept.length,
|
|
76
|
+
exceeded: lastMinute > threshold.perMinute || kept.length > threshold.perHour
|
|
77
|
+
};
|
|
78
|
+
},
|
|
79
|
+
reset() {
|
|
80
|
+
timestamps.clear();
|
|
81
|
+
reportedAt.clear();
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=burst.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["DEFAULT_BURST_THRESHOLD","DIAGNOSTIC_CODES","MINUTE_MS","HOUR_MS","createBurstDetector","deps","threshold","emit","timestamps","Map","reportedAt","prune","tag","now","kept","get","filter","at","set","record","ownerTag","push","lastMinute","length","lastHour","exceeded","perMinute","perHour","last","BURST_THRESHOLD_EXCEEDED","status","reset","clear"],"sourceRoot":"../../../src","sources":["diagnostics/burst.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,uBAAuB,QAAQ,4BAAyB;AACjE,SAASC,gBAAgB,QAAQ,uBAAoB;AAErD,MAAMC,SAAS,GAAG,MAAM;AACxB,MAAMC,OAAO,GAAG,EAAE,GAAGD,SAAS;AAc9B,OAAO,SAASE,mBAAmBA,CAACC,IAA+B,GAAG,CAAC,CAAC,EAAE;EACzE,MAAMC,SAAS,GAAGD,IAAI,CAACC,SAAS,IAAIN,uBAAuB;EAC3D,MAAMO,IAAI,GAAGF,IAAI,CAACE,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC;EACpC;EACA,MAAMC,UAAU,GAAG,IAAIC,GAAG,CAAmB,CAAC;EAC9C;EACA,MAAMC,UAAU,GAAG,IAAID,GAAG,CAAiB,CAAC;EAE5C,MAAME,KAAK,GAAGA,CAACC,GAAW,EAAEC,GAAW,KAAe;IACrD,MAAMC,IAAI,GAAG,CAACN,UAAU,CAACO,GAAG,CAACH,GAAG,CAAC,IAAI,EAAE,EAAEI,MAAM,CAACC,EAAE,IAAIJ,GAAG,GAAGI,EAAE,IAAId,OAAO,CAAC;IAC1EK,UAAU,CAACU,GAAG,CAACN,GAAG,EAAEE,IAAI,CAAC;IACzB,OAAOA,IAAI;EACZ,CAAC;EAED,OAAO;IACN;AACF;AACA;AACA;AACA;AACA;IACEK,MAAMA,CAACN,GAAW,EAAEO,QAAQ,GAAG,GAAG,EAAe;MAChD,MAAMN,IAAI,GAAGH,KAAK,CAACS,QAAQ,EAAEP,GAAG,CAAC;MACjC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,IAAI,CAACS,MAAM,GAAGjB,SAAS,CAACqB;MACvE,CAAC;IACF,CAAC;IAEDI,KAAKA,CAAA,EAAS;MACbvB,UAAU,CAACwB,KAAK,CAAC,CAAC;MAClBtB,UAAU,CAACsB,KAAK,CAAC,CAAC;IACnB;EACD,CAAC;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The structured event stream.
|
|
5
|
+
*
|
|
6
|
+
* With no sink attached the package emits nothing and buffers nothing. A
|
|
7
|
+
* library that writes to the console in production has decided something for
|
|
8
|
+
* its consumer; this one routes events wherever the app already sends its logs,
|
|
9
|
+
* or stays silent.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { createDiagnosticChannel } from '@chipmobilesdk/rn-core';
|
|
13
|
+
import { isNonFailure } from "../contract/errors.js";
|
|
14
|
+
import { redactContext } from "./redact.js";
|
|
15
|
+
const channel = createDiagnosticChannel('rn-notification');
|
|
16
|
+
export class DiagnosticEmitter {
|
|
17
|
+
constructor(options = {}) {
|
|
18
|
+
this.sink = options.sink;
|
|
19
|
+
this.verbose = options.verbose ?? false;
|
|
20
|
+
this.now = options.now ?? (() => Date.now());
|
|
21
|
+
}
|
|
22
|
+
setSink(sink) {
|
|
23
|
+
this.sink = sink;
|
|
24
|
+
}
|
|
25
|
+
setVerbose(verbose) {
|
|
26
|
+
this.verbose = verbose;
|
|
27
|
+
}
|
|
28
|
+
get hasSink() {
|
|
29
|
+
return this.sink !== undefined;
|
|
30
|
+
}
|
|
31
|
+
emit(code, message, context, severity) {
|
|
32
|
+
const resolvedSeverity = severity ?? (isNonFailure(code) ? 'info' : 'error');
|
|
33
|
+
// The app's SDK sinks (`installSdkSink`, CORE-08) never get content, even
|
|
34
|
+
// with verbose diagnostics on: verbose is for this package's own sink.
|
|
35
|
+
channel.emit(code, resolvedSeverity, redactContext(context, false));
|
|
36
|
+
|
|
37
|
+
// No sink means no work at all — not a buffer that grows until one appears.
|
|
38
|
+
if (this.sink === undefined) return;
|
|
39
|
+
const event = {
|
|
40
|
+
code,
|
|
41
|
+
severity: resolvedSeverity,
|
|
42
|
+
message,
|
|
43
|
+
at: this.now(),
|
|
44
|
+
context: redactContext(context, this.verbose)
|
|
45
|
+
};
|
|
46
|
+
try {
|
|
47
|
+
this.sink(event);
|
|
48
|
+
} catch {
|
|
49
|
+
// A failing sink is the consumer's problem and must never become ours.
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Lifecycle transitions that are not failures: scheduled, delivered, reconciled. */
|
|
54
|
+
info(code, message, context) {
|
|
55
|
+
this.emit(code, message, context, 'info');
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createDiagnosticChannel","isNonFailure","redactContext","channel","DiagnosticEmitter","constructor","options","sink","verbose","now","Date","setSink","setVerbose","hasSink","undefined","emit","code","message","context","severity","resolvedSeverity","event","at","info"],"sourceRoot":"../../../src","sources":["diagnostics/events.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,uBAAuB,QAAQ,wBAAwB;AAIhE,SAASC,YAAY,QAAQ,uBAAoB;AACjD,SAASC,aAAa,QAAQ,aAAU;AAQxC,MAAMC,OAAO,GAAGH,uBAAuB,CAAiB,iBAAiB,CAAC;AAE1E,OAAO,MAAMI,iBAAiB,CAAC;EAK9BC,WAAWA,CAACC,OAAuB,GAAG,CAAC,CAAC,EAAE;IACzC,IAAI,CAACC,IAAI,GAAGD,OAAO,CAACC,IAAI;IACxB,IAAI,CAACC,OAAO,GAAGF,OAAO,CAACE,OAAO,IAAI,KAAK;IACvC,IAAI,CAACC,GAAG,GAAGH,OAAO,CAACG,GAAG,KAAK,MAAMC,IAAI,CAACD,GAAG,CAAC,CAAC,CAAC;EAC7C;EAEAE,OAAOA,CAACJ,IAA2B,EAAQ;IAC1C,IAAI,CAACA,IAAI,GAAGA,IAAI;EACjB;EAEAK,UAAUA,CAACJ,OAAgB,EAAQ;IAClC,IAAI,CAACA,OAAO,GAAGA,OAAO;EACvB;EAEA,IAAIK,OAAOA,CAAA,EAAY;IACtB,OAAO,IAAI,CAACN,IAAI,KAAKO,SAAS;EAC/B;EAEAC,IAAIA,CACHC,IAAoB,EACpBC,OAAe,EACfC,OAA2C,EAC3CC,QAA6B,EACtB;IACP,MAAMC,gBAAgB,GAAGD,QAAQ,KAAKlB,YAAY,CAACe,IAAI,CAAC,GAAG,MAAM,GAAG,OAAO,CAAC;IAC5E;IACA;IACAb,OAAO,CAACY,IAAI,CAACC,IAAI,EAAEI,gBAAgB,EAAElB,aAAa,CAACgB,OAAO,EAAE,KAAK,CAAC,CAAC;;IAEnE;IACA,IAAI,IAAI,CAACX,IAAI,KAAKO,SAAS,EAAE;IAE7B,MAAMO,KAAsB,GAAG;MAC9BL,IAAI;MACJG,QAAQ,EAAEC,gBAAgB;MAC1BH,OAAO;MACPK,EAAE,EAAE,IAAI,CAACb,GAAG,CAAC,CAAC;MACdS,OAAO,EAAEhB,aAAa,CAACgB,OAAO,EAAE,IAAI,CAACV,OAAO;IAC7C,CAAC;IAED,IAAI;MACH,IAAI,CAACD,IAAI,CAACc,KAAK,CAAC;IACjB,CAAC,CAAC,MAAM;MACP;IAAA;EAEF;;EAEA;EACAE,IAAIA,CAACP,IAAoB,EAAEC,OAAe,EAAEC,OAA2C,EAAQ;IAC9F,IAAI,CAACH,IAAI,CAACC,IAAI,EAAEC,OAAO,EAAEC,OAAO,EAAE,MAAM,CAAC;EAC1C;AACD","ignoreList":[]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Content redaction for diagnostics.
|
|
5
|
+
*
|
|
6
|
+
* A notification library that logs notification bodies has turned a diagnostic
|
|
7
|
+
* aid into a privacy incident. Nothing content-bearing reaches an event unless
|
|
8
|
+
* verbose diagnostics is explicitly enabled — and that setting is documented as
|
|
9
|
+
* unsuitable for production.
|
|
10
|
+
*
|
|
11
|
+
* Values are replaced by their *shape* — a length, a type, a character position
|
|
12
|
+
* — which is what actually helps someone debug a validation failure anyway.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { createRedactor } from '@chipmobilesdk/rn-core';
|
|
16
|
+
|
|
17
|
+
/** Keys whose values are never emitted at any verbosity below verbose. */
|
|
18
|
+
const REDACTED_KEYS = new Set(['title', 'body', 'subtitle', 'content', 'routing', 'routingPayload', 'payload', 'token', 'pushToken', 'inputText', 'text', 'data']);
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* rn-core's redactor: the keys above are replaced by their shape (a length, a
|
|
22
|
+
* type), and every other string is pattern-redacted, so a token or an e-mail
|
|
23
|
+
* address under an innocent key such as `reason` does not get through either.
|
|
24
|
+
*/
|
|
25
|
+
const redactor = createRedactor({
|
|
26
|
+
shapeKeys: REDACTED_KEYS
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Strips content values from a diagnostic context.
|
|
31
|
+
*
|
|
32
|
+
* Recurses so a nested `{ request: { content: { body } } }` is caught — a
|
|
33
|
+
* top-level-only scrub is the kind of redaction that leaks the first time
|
|
34
|
+
* anyone nests a payload.
|
|
35
|
+
*/
|
|
36
|
+
export function redactContext(context, verbose) {
|
|
37
|
+
return verbose ? context : redactor.context(context);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** True when a key would be redacted. Exported so tests can assert the policy directly. */
|
|
41
|
+
export function isRedactedKey(key) {
|
|
42
|
+
return REDACTED_KEYS.has(key);
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=redact.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createRedactor","REDACTED_KEYS","Set","redactor","shapeKeys","redactContext","context","verbose","isRedactedKey","key","has"],"sourceRoot":"../../../src","sources":["diagnostics/redact.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,cAAc,QAAQ,wBAAwB;;AAEvD;AACA,MAAMC,aAAa,GAAG,IAAIC,GAAG,CAAC,CAC7B,OAAO,EACP,MAAM,EACN,UAAU,EACV,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,SAAS,EACT,OAAO,EACP,WAAW,EACX,WAAW,EACX,MAAM,EACN,MAAM,CACN,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA,MAAMC,QAAQ,GAAGH,cAAc,CAAC;EAAEI,SAAS,EAAEH;AAAc,CAAC,CAAC;;AAE7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASI,aAAaA,CAC5BC,OAAsD,EACtDC,OAAgB,EACgC;EAChD,OAAOA,OAAO,GAAGD,OAAO,GAAGH,QAAQ,CAACG,OAAO,CAACA,OAAO,CAAC;AACrD;;AAEA;AACA,OAAO,SAASE,aAAaA,CAACC,GAAW,EAAW;EACnD,OAAOR,aAAa,CAACS,GAAG,CAACD,GAAG,CAAC;AAC9B","ignoreList":[]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The state snapshot.
|
|
5
|
+
*
|
|
6
|
+
* The readable answer to "why didn't it arrive?" — assembled in one place so
|
|
7
|
+
* that question can be answered without attaching a native debugger.
|
|
8
|
+
*
|
|
9
|
+
* The push token appears as **presence only**. Its value is never exposed here
|
|
10
|
+
* or anywhere else, because a snapshot is the thing most likely to be pasted
|
|
11
|
+
* into a bug report.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { describeShape } from '@chipmobilesdk/rn-core';
|
|
15
|
+
/**
|
|
16
|
+
* A pending entry with content replaced by its shape. A snapshot is the thing
|
|
17
|
+
* most likely to be pasted into a bug report, so it never carries notification
|
|
18
|
+
* text or routing values unless verbose diagnostics is on (NOT-14).
|
|
19
|
+
*/
|
|
20
|
+
function withoutContent(entry) {
|
|
21
|
+
const {
|
|
22
|
+
content,
|
|
23
|
+
routing
|
|
24
|
+
} = entry;
|
|
25
|
+
return {
|
|
26
|
+
...entry,
|
|
27
|
+
content: {
|
|
28
|
+
title: describeShape(content.title),
|
|
29
|
+
body: describeShape(content.body),
|
|
30
|
+
...(content.subtitle === undefined ? {} : {
|
|
31
|
+
subtitle: describeShape(content.subtitle)
|
|
32
|
+
})
|
|
33
|
+
},
|
|
34
|
+
...(routing === undefined ? {} : {
|
|
35
|
+
routing: Object.fromEntries(Object.entries(routing).map(([key, value]) => [key, describeShape(value)]))
|
|
36
|
+
})
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export function createSnapshot(deps) {
|
|
40
|
+
return {
|
|
41
|
+
async capture() {
|
|
42
|
+
const [permissions, restrictions, pending] = await Promise.all([deps.permissions(), deps.restrictions(), deps.engine.getPending()]);
|
|
43
|
+
const maintenance = deps.lastMaintenance();
|
|
44
|
+
const discrepancy = maintenance?.discrepancy;
|
|
45
|
+
return {
|
|
46
|
+
permissions,
|
|
47
|
+
restrictions,
|
|
48
|
+
tones: deps.appliedTones().map(tone => ({
|
|
49
|
+
id: tone.toneId,
|
|
50
|
+
appliedVersion: tone.appliedVersion
|
|
51
|
+
})),
|
|
52
|
+
pendingCount: pending.length,
|
|
53
|
+
pending: deps.verbose?.() ? pending : pending.map(entry => withoutContent(entry)),
|
|
54
|
+
lastReconcile: deps.lastReconcile(),
|
|
55
|
+
lastMaintenance: maintenance,
|
|
56
|
+
discrepancy,
|
|
57
|
+
stateHealth: deps.state.health(),
|
|
58
|
+
pushTokenPresent: deps.hasPushToken(),
|
|
59
|
+
capturedAt: deps.now()
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=snapshot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["describeShape","withoutContent","entry","content","routing","title","body","subtitle","undefined","Object","fromEntries","entries","map","key","value","createSnapshot","deps","capture","permissions","restrictions","pending","Promise","all","engine","getPending","maintenance","lastMaintenance","discrepancy","tones","appliedTones","tone","id","toneId","appliedVersion","pendingCount","length","verbose","lastReconcile","stateHealth","state","health","pushTokenPresent","hasPushToken","capturedAt","now"],"sourceRoot":"../../../src","sources":["diagnostics/snapshot.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,aAAa,QAAQ,wBAAwB;AA8BtD;AACA;AACA;AACA;AACA;AACA,SAASC,cAAcA,CAACC,KAAmB,EAAgB;EAC1D,MAAM;IAAEC,OAAO;IAAEC;EAAQ,CAAC,GAAGF,KAAK;EAClC,OAAO;IACN,GAAGA,KAAK;IACRC,OAAO,EAAE;MACRE,KAAK,EAAEL,aAAa,CAACG,OAAO,CAACE,KAAK,CAAC;MACnCC,IAAI,EAAEN,aAAa,CAACG,OAAO,CAACG,IAAI,CAAC;MACjC,IAAIH,OAAO,CAACI,QAAQ,KAAKC,SAAS,GAAG,CAAC,CAAC,GAAG;QAAED,QAAQ,EAAEP,aAAa,CAACG,OAAO,CAACI,QAAQ;MAAE,CAAC;IACxF,CAAC;IACD,IAAIH,OAAO,KAAKI,SAAS,GACtB,CAAC,CAAC,GACF;MACAJ,OAAO,EAAEK,MAAM,CAACC,WAAW,CAC1BD,MAAM,CAACE,OAAO,CAACP,OAAO,CAAC,CAACQ,GAAG,CAAC,CAAC,CAACC,GAAG,EAAEC,KAAK,CAAC,KAAK,CAACD,GAAG,EAAEb,aAAa,CAACc,KAAK,CAAC,CAAC,CAC1E;IACD,CAAC;EACJ,CAAC;AACF;AAEA,OAAO,SAASC,cAAcA,CAACC,IAA0B,EAAE;EAC1D,OAAO;IACN,MAAMC,OAAOA,CAAA,EAA2B;MACvC,MAAM,CAACC,WAAW,EAAEC,YAAY,EAAEC,OAAO,CAAC,GAAG,MAAMC,OAAO,CAACC,GAAG,CAAC,CAC9DN,IAAI,CAACE,WAAW,CAAC,CAAC,EAClBF,IAAI,CAACG,YAAY,CAAC,CAAC,EACnBH,IAAI,CAACO,MAAM,CAACC,UAAU,CAAC,CAAC,CACxB,CAAC;MAEF,MAAMC,WAAW,GAAGT,IAAI,CAACU,eAAe,CAAC,CAAC;MAC1C,MAAMC,WAA2C,GAAGF,WAAW,EAAEE,WAAW;MAE5E,OAAO;QACNT,WAAW;QACXC,YAAY;QACZS,KAAK,EAAEZ,IAAI,CAACa,YAAY,CAAC,CAAC,CAACjB,GAAG,CAACkB,IAAI,KAAK;UACvCC,EAAE,EAAED,IAAI,CAACE,MAAM;UACfC,cAAc,EAAEH,IAAI,CAACG;QACtB,CAAC,CAAC,CAAC;QACHC,YAAY,EAAEd,OAAO,CAACe,MAAM;QAC5Bf,OAAO,EAAEJ,IAAI,CAACoB,OAAO,GAAG,CAAC,GACrBhB,OAAO,GACRA,OAAO,CAACR,GAAG,CAACV,KAAK,IAAID,cAAc,CAACC,KAAqB,CAAC,CAAC;QAC9DmC,aAAa,EAAErB,IAAI,CAACqB,aAAa,CAAC,CAAC;QACnCX,eAAe,EAAED,WAAW;QAC5BE,WAAW;QACXW,WAAW,EAAEtB,IAAI,CAACuB,KAAK,CAACC,MAAM,CAAC,CAAC;QAChCC,gBAAgB,EAAEzB,IAAI,CAAC0B,YAAY,CAAC,CAAC;QACrCC,UAAU,EAAE3B,IAAI,CAAC4B,GAAG,CAAC;MACtB,CAAC;IACF;EACD,CAAC;AACF","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["engine/adapter.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The metadata codec for a notification's platform data bag.
|
|
5
|
+
*
|
|
6
|
+
* Anchoring, series origin, tags, routing and actions have no engine
|
|
7
|
+
* equivalent, and `getPending` must return them (FR-010) or a consumer cannot
|
|
8
|
+
* diff against intent. They travel as strings in the free-form data bag, which
|
|
9
|
+
* is the one field both platforms carry through unchanged.
|
|
10
|
+
*
|
|
11
|
+
* Shared by the real engine and the fake. When the fake stored requests
|
|
12
|
+
* verbatim it could not lose a field the real engine lost — `actions` never
|
|
13
|
+
* came back from a device, so every reconcile replaced every notification that
|
|
14
|
+
* had them, and the fake-backed tests never saw it.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/** Everything `getPending` reports that only the data bag can carry. */
|
|
18
|
+
|
|
19
|
+
export function packData(request) {
|
|
20
|
+
return {
|
|
21
|
+
__cms_anchoring: request.request.moment.anchoring ?? 'wallClock',
|
|
22
|
+
// The IANA zone, not the tone. Storing the wrong value here does not merely
|
|
23
|
+
// mislabel an entry: the re-anchoring pass feeds it straight to
|
|
24
|
+
// Intl.DateTimeFormat, which throws a hard Hermes error on an invalid zone.
|
|
25
|
+
...(request.anchoringGeneration !== undefined ? {
|
|
26
|
+
__cms_generation: request.anchoringGeneration
|
|
27
|
+
} : {}),
|
|
28
|
+
__cms_tone: request.request.tone,
|
|
29
|
+
__cms_approximate: String(request.approximate),
|
|
30
|
+
__cms_pushCreated: String(request.pushCreated ?? false),
|
|
31
|
+
...(request.seriesId !== undefined ? {
|
|
32
|
+
__cms_series: request.seriesId
|
|
33
|
+
} : {}),
|
|
34
|
+
...(request.request.ownerTag !== undefined ? {
|
|
35
|
+
__cms_owner: request.request.ownerTag
|
|
36
|
+
} : {}),
|
|
37
|
+
...(request.request.groupTag !== undefined ? {
|
|
38
|
+
__cms_group: request.request.groupTag
|
|
39
|
+
} : {}),
|
|
40
|
+
...(request.request.routing !== undefined ? {
|
|
41
|
+
__cms_routing: JSON.stringify(request.request.routing)
|
|
42
|
+
} : {}),
|
|
43
|
+
...(request.request.actions !== undefined ? {
|
|
44
|
+
__cms_actions: JSON.stringify(request.request.actions)
|
|
45
|
+
} : {}),
|
|
46
|
+
// A stop marker's whole payload. It travels here rather than in `ownerTag`
|
|
47
|
+
// or `routing` so it can never collide with a value a consumer owns.
|
|
48
|
+
...(request.repeatStop !== undefined ? {
|
|
49
|
+
__cms_stop_target: request.repeatStop.targetId,
|
|
50
|
+
__cms_stop_due: String(request.repeatStop.dueAt)
|
|
51
|
+
} : {})
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** A JSON field we cannot parse is reported as absent: the notification is still valid. */
|
|
56
|
+
function parseJson(raw) {
|
|
57
|
+
if (typeof raw !== 'string') return undefined;
|
|
58
|
+
try {
|
|
59
|
+
return JSON.parse(raw);
|
|
60
|
+
} catch {
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
export function unpackData(data) {
|
|
65
|
+
const anchoring = data.__cms_anchoring === 'absolute' ? 'absolute' : 'wallClock';
|
|
66
|
+
return {
|
|
67
|
+
anchoring,
|
|
68
|
+
anchoringGeneration: anchoring === 'absolute' ? undefined : data.__cms_generation,
|
|
69
|
+
tone: data.__cms_tone ?? '',
|
|
70
|
+
routing: parseJson(data.__cms_routing),
|
|
71
|
+
actions: parseJson(data.__cms_actions),
|
|
72
|
+
ownerTag: data.__cms_owner,
|
|
73
|
+
groupTag: data.__cms_group,
|
|
74
|
+
seriesId: data.__cms_series,
|
|
75
|
+
mayBeDelayed: data.__cms_approximate === 'true',
|
|
76
|
+
pushCreated: data.__cms_pushCreated === 'true'
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=codec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["packData","request","__cms_anchoring","moment","anchoring","anchoringGeneration","undefined","__cms_generation","__cms_tone","tone","__cms_approximate","String","approximate","__cms_pushCreated","pushCreated","seriesId","__cms_series","ownerTag","__cms_owner","groupTag","__cms_group","routing","__cms_routing","JSON","stringify","actions","__cms_actions","repeatStop","__cms_stop_target","targetId","__cms_stop_due","dueAt","parseJson","raw","parse","unpackData","data","mayBeDelayed"],"sourceRoot":"../../../src","sources":["engine/codec.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA;;AAeA,OAAO,SAASA,QAAQA,CAACC,OAA8B,EAA0B;EAChF,OAAO;IACNC,eAAe,EAAED,OAAO,CAACA,OAAO,CAACE,MAAM,CAACC,SAAS,IAAI,WAAW;IAChE;IACA;IACA;IACA,IAAIH,OAAO,CAACI,mBAAmB,KAAKC,SAAS,GAC1C;MAAEC,gBAAgB,EAAEN,OAAO,CAACI;IAAoB,CAAC,GACjD,CAAC,CAAC,CAAC;IACNG,UAAU,EAAEP,OAAO,CAACA,OAAO,CAACQ,IAAI;IAChCC,iBAAiB,EAAEC,MAAM,CAACV,OAAO,CAACW,WAAW,CAAC;IAC9CC,iBAAiB,EAAEF,MAAM,CAACV,OAAO,CAACa,WAAW,IAAI,KAAK,CAAC;IACvD,IAAIb,OAAO,CAACc,QAAQ,KAAKT,SAAS,GAAG;MAAEU,YAAY,EAAEf,OAAO,CAACc;IAAS,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7E,IAAId,OAAO,CAACA,OAAO,CAACgB,QAAQ,KAAKX,SAAS,GAAG;MAAEY,WAAW,EAAEjB,OAAO,CAACA,OAAO,CAACgB;IAAS,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5F,IAAIhB,OAAO,CAACA,OAAO,CAACkB,QAAQ,KAAKb,SAAS,GAAG;MAAEc,WAAW,EAAEnB,OAAO,CAACA,OAAO,CAACkB;IAAS,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5F,IAAIlB,OAAO,CAACA,OAAO,CAACoB,OAAO,KAAKf,SAAS,GACtC;MAAEgB,aAAa,EAAEC,IAAI,CAACC,SAAS,CAACvB,OAAO,CAACA,OAAO,CAACoB,OAAO;IAAE,CAAC,GAC1D,CAAC,CAAC,CAAC;IACN,IAAIp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CI,WAAW,EAAEsB,IAAI,CAACvB,iBAAiB,KAAK;EACzC,CAAC;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Reading what the engine hands back: pending entries, interactions, deliveries
|
|
5
|
+
* and authorization values, turned into the package's own shapes.
|
|
6
|
+
*
|
|
7
|
+
* Pure functions of the raw value and a clock, so they are testable without an
|
|
8
|
+
* engine and shared by the foreground, background and cold-start paths.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { isRepeatStopId } from "../../repeat/marker.js";
|
|
12
|
+
import { unpackData } from "../codec.js";
|
|
13
|
+
import { EVENT_TYPE_ACTION_PRESS, EVENT_TYPE_DELIVERED, EVENT_TYPE_DISMISSED, EVENT_TYPE_PRESS } from "./module.js";
|
|
14
|
+
const bag = value => value ?? {};
|
|
15
|
+
const dataOf = notification => notification.data ?? {};
|
|
16
|
+
|
|
17
|
+
/** Reads a stop marker back out of a pending entry's data bag, if it is one. */
|
|
18
|
+
export function unpackRepeatStop(id, data) {
|
|
19
|
+
if (!isRepeatStopId(id)) return undefined;
|
|
20
|
+
const targetId = data.__cms_stop_target;
|
|
21
|
+
const dueAt = Number.parseInt(data.__cms_stop_due ?? '', 10);
|
|
22
|
+
if (typeof targetId !== 'string' || !Number.isFinite(dueAt)) return undefined;
|
|
23
|
+
return {
|
|
24
|
+
markerId: id,
|
|
25
|
+
targetId,
|
|
26
|
+
dueAt
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export function unpackEntry(raw, now) {
|
|
30
|
+
const notification = bag(raw.notification);
|
|
31
|
+
const trigger = bag(raw.trigger);
|
|
32
|
+
const id = notification.id;
|
|
33
|
+
if (typeof id !== 'string') return undefined;
|
|
34
|
+
return {
|
|
35
|
+
id,
|
|
36
|
+
resolvedAt: typeof trigger.timestamp === 'number' ? trigger.timestamp : now(),
|
|
37
|
+
content: {
|
|
38
|
+
title: typeof notification.title === 'string' ? notification.title : '',
|
|
39
|
+
body: typeof notification.body === 'string' ? notification.body : '',
|
|
40
|
+
subtitle: typeof notification.subtitle === 'string' ? notification.subtitle : undefined
|
|
41
|
+
},
|
|
42
|
+
...unpackData(dataOf(notification))
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Every stop marker among the engine's pending triggers. */
|
|
47
|
+
export function unpackRepeatStops(raw) {
|
|
48
|
+
const stops = [];
|
|
49
|
+
for (const entry of raw) {
|
|
50
|
+
const notification = bag(entry.notification);
|
|
51
|
+
const id = notification.id;
|
|
52
|
+
if (typeof id !== 'string') continue;
|
|
53
|
+
const stop = unpackRepeatStop(id, dataOf(notification));
|
|
54
|
+
if (stop !== undefined) stops.push(stop);
|
|
55
|
+
}
|
|
56
|
+
return stops;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* An interaction, or undefined for anything that is not one.
|
|
61
|
+
*
|
|
62
|
+
* Only a dismissal or a press is an interaction. Everything else the engine
|
|
63
|
+
* emits on this channel — delivery, trigger creation, channel blocking — is not,
|
|
64
|
+
* and reporting it as one would cancel a notification the user never touched.
|
|
65
|
+
*/
|
|
66
|
+
export function toInteraction(raw, now) {
|
|
67
|
+
const eventType = raw.type;
|
|
68
|
+
if (eventType !== EVENT_TYPE_DISMISSED && eventType !== EVENT_TYPE_PRESS && eventType !== EVENT_TYPE_ACTION_PRESS) {
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
const detail = bag(raw.detail);
|
|
72
|
+
const notification = bag(detail.notification);
|
|
73
|
+
const pressAction = bag(detail.pressAction);
|
|
74
|
+
const id = notification.id;
|
|
75
|
+
if (typeof id !== 'string') return undefined;
|
|
76
|
+
const data = dataOf(notification);
|
|
77
|
+
const actionId = typeof pressAction.id === 'string' ? pressAction.id : undefined;
|
|
78
|
+
// `default` is the engine's own press-action id for tapping the body, so it is
|
|
79
|
+
// a tap rather than a named action.
|
|
80
|
+
const isNamedAction = actionId !== undefined && actionId !== 'default';
|
|
81
|
+
let kind;
|
|
82
|
+
if (eventType === EVENT_TYPE_DISMISSED) {
|
|
83
|
+
kind = 'dismiss';
|
|
84
|
+
} else if (isNamedAction) {
|
|
85
|
+
kind = 'action';
|
|
86
|
+
} else {
|
|
87
|
+
kind = 'tap';
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
kind,
|
|
91
|
+
notificationId: id,
|
|
92
|
+
actionId: isNamedAction ? actionId : undefined,
|
|
93
|
+
inputText: typeof detail.input === 'string' ? detail.input : undefined,
|
|
94
|
+
// The one decoder for the data bag, so routing is parsed the same way here
|
|
95
|
+
// and when reading the pending set back (NOT-18).
|
|
96
|
+
routing: unpackData(data).routing,
|
|
97
|
+
ownerTag: data.__cms_owner,
|
|
98
|
+
occurredAt: now(),
|
|
99
|
+
appState: 'foreground',
|
|
100
|
+
wasBuffered: false
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** A delivery, or undefined for anything that is not one. */
|
|
105
|
+
export function toDelivery(raw, now) {
|
|
106
|
+
if (raw.type !== EVENT_TYPE_DELIVERED) return undefined;
|
|
107
|
+
const notification = bag(bag(raw.detail).notification);
|
|
108
|
+
const id = notification.id;
|
|
109
|
+
if (typeof id !== 'string') return undefined;
|
|
110
|
+
return {
|
|
111
|
+
notificationId: id,
|
|
112
|
+
occurredAt: now(),
|
|
113
|
+
repeatStop: unpackRepeatStop(id, dataOf(notification))
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Maps engine authorization values onto our six-state model.
|
|
119
|
+
*
|
|
120
|
+
* `notAsked` and `denied` must stay distinguishable — being able to read state
|
|
121
|
+
* without prompting is worthless if the two collapse. `provisional` is its own
|
|
122
|
+
* state on both edges, never folded into granted or denied.
|
|
123
|
+
*/
|
|
124
|
+
export function toPermissionState(raw) {
|
|
125
|
+
switch (raw) {
|
|
126
|
+
case 1:
|
|
127
|
+
case 'authorized':
|
|
128
|
+
return 'granted';
|
|
129
|
+
case 2:
|
|
130
|
+
case 'provisional':
|
|
131
|
+
return 'provisional';
|
|
132
|
+
case 0:
|
|
133
|
+
case 'denied':
|
|
134
|
+
return 'denied';
|
|
135
|
+
default:
|
|
136
|
+
return 'notAsked';
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["isRepeatStopId","unpackData","EVENT_TYPE_ACTION_PRESS","EVENT_TYPE_DELIVERED","EVENT_TYPE_DISMISSED","EVENT_TYPE_PRESS","bag","value","dataOf","notification","data","unpackRepeatStop","id","undefined","targetId","__cms_stop_target","dueAt","Number","parseInt","__cms_stop_due","isFinite","markerId","unpackEntry","raw","now","trigger","resolvedAt","timestamp","content","title","body","subtitle","unpackRepeatStops","stops","entry","stop","push","toInteraction","eventType","type","detail","pressAction","actionId","isNamedAction","kind","notificationId","inputText","input","routing","ownerTag","__cms_owner","occurredAt","appState","wasBuffered","toDelivery","repeatStop","toPermissionState"],"sourceRoot":"../../../../src","sources":["engine/notify-kit/events.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SAASA,cAAc,QAAQ,wBAAqB;AAEpD,SAASC,UAAU,QAAQ,aAAU;AACrC,SACCC,uBAAuB,EACvBC,oBAAoB,EACpBC,oBAAoB,EACpBC,gBAAgB,QACV,aAAU;AAIjB,MAAMC,GAAG,GAAIC,KAAc,IAAWA,KAAK,IAAI,CAAC,CAAS;AACzD,MAAMC,MAAM,GAAIC,YAAiB,IAC/BA,YAAY,CAACC,IAAI,IAAI,CAAC,CAA4B;;AAEpD;AACA,OAAO,SAASC,gBAAgBA,CAACC,EAAU,EAAEF,IAA4B,EAA0B;EAClG,IAAI,CAACV,cAAc,CAACY,EAAE,CAAC,EAAE,OAAOC,SAAS;EACzC,MAAMC,QAAQ,GAAGJ,IAA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AK,CAAC;IACN,KAAK,YAAY;MAChB,OAAO,SAAS;IACjB,KAAK,CAAC;IACN,KAAK,aAAa;MACjB,OAAO,aAAa;IACrB,KAAK,CAAC;IACN,KAAK,QAAQ;MACZ,OAAO,QAAQ;IAChB;MACC,OAAO,UAAU;EACnB;AACD","ignoreList":[]}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The slice of `react-native-notify-kit` this package uses, and how it is loaded.
|
|
5
|
+
*
|
|
6
|
+
* Every import of the engine is confined to this file. The module is required
|
|
7
|
+
* lazily so the package loads in Jest and in any environment without the native
|
|
8
|
+
* module; an absent engine is reported through the normal diagnostic path
|
|
9
|
+
* rather than crashing at import time.
|
|
10
|
+
*/
|
|
11
|
+
import { lazyPeer } from '@chipmobilesdk/rn-core';
|
|
12
|
+
import { DIAGNOSTIC_CODES, NotificationError } from "../../contract/errors.js";
|
|
13
|
+
|
|
14
|
+
/** Both platforms bound background execution for a silent payload or background action. */
|
|
15
|
+
export const BACKGROUND_WINDOW_MS = 30_000;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The engine's own enum values, mirrored as literals.
|
|
19
|
+
*
|
|
20
|
+
* These are **numeric** enums in the engine's type definitions, and its native
|
|
21
|
+
* validator rejects the string names — `importance: 'default'` fails with
|
|
22
|
+
* "expected a valid Importance". Mirroring them here rather than importing the
|
|
23
|
+
* enums keeps the engine out of the module graph, which is what lets the
|
|
24
|
+
* package load without the native module present.
|
|
25
|
+
*
|
|
26
|
+
* The package's own `ResolvedTone` deliberately stays platform-neutral strings;
|
|
27
|
+
* translating to the engine's representation is this adapter's job and nobody
|
|
28
|
+
* else's.
|
|
29
|
+
*/
|
|
30
|
+
export const ANDROID_IMPORTANCE = {
|
|
31
|
+
none: 0,
|
|
32
|
+
min: 1,
|
|
33
|
+
low: 2,
|
|
34
|
+
default: 3,
|
|
35
|
+
high: 4
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/** `TriggerType.TIMESTAMP`. */
|
|
39
|
+
export const TRIGGER_TYPE_TIMESTAMP = 0;
|
|
40
|
+
|
|
41
|
+
/** `AlarmType.SET_EXACT_AND_ALLOW_WHILE_IDLE` — exact delivery, survives Doze. */
|
|
42
|
+
export const ALARM_TYPE_EXACT_AND_ALLOW_WHILE_IDLE = 3;
|
|
43
|
+
|
|
44
|
+
/** `AlarmType.SET_AND_ALLOW_WHILE_IDLE` — the approximate degradation of the above. */
|
|
45
|
+
export const ALARM_TYPE_INEXACT_AND_ALLOW_WHILE_IDLE = 1;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* `EventType` values that represent a real user interaction.
|
|
49
|
+
*
|
|
50
|
+
* The engine emits far more than interactions on this channel — `DELIVERED`,
|
|
51
|
+
* `TRIGGER_NOTIFICATION_CREATED`, `CHANNEL_BLOCKED` and others all arrive here.
|
|
52
|
+
* Treating anything that is not a dismissal as a press would report a
|
|
53
|
+
* notification *arriving* while the app is open as the user having tapped it,
|
|
54
|
+
* and the interaction path cancels on tap — so the notification would vanish
|
|
55
|
+
* from the tray in front of the user, unread.
|
|
56
|
+
*/
|
|
57
|
+
export const EVENT_TYPE_DISMISSED = 0;
|
|
58
|
+
export const EVENT_TYPE_PRESS = 1;
|
|
59
|
+
export const EVENT_TYPE_ACTION_PRESS = 2;
|
|
60
|
+
|
|
61
|
+
/** `EventType.DELIVERED` — an arrival, which is emphatically not an interaction. */
|
|
62
|
+
export const EVENT_TYPE_DELIVERED = 3;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* `AndroidCategory.ALARM`, the engine's marking for a time-sensitive alert.
|
|
66
|
+
*
|
|
67
|
+
* A per-notification property, not channel configuration — which is why
|
|
68
|
+
* declaring `timeSensitive` on an existing tone never obliges a version bump.
|
|
69
|
+
*/
|
|
70
|
+
export const ANDROID_CATEGORY_ALARM = 'alarm';
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The channel stop markers are posted on.
|
|
74
|
+
*
|
|
75
|
+
* A marker exists to be delivered and immediately removed, so it is given the
|
|
76
|
+
* quietest configuration the platform offers: minimum importance, no sound, no
|
|
77
|
+
* vibration. Its version is fixed because nothing about it is consumer-declared,
|
|
78
|
+
* so it never migrates.
|
|
79
|
+
*/
|
|
80
|
+
export const MARKER_CHANNEL_ID = 'cms.internal.stop.v1';
|
|
81
|
+
|
|
82
|
+
/** Minimal shape used from the engine, so its full surface never leaks into typing. */
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Drops keys whose value is `undefined`.
|
|
86
|
+
*
|
|
87
|
+
* The engine validates its arguments by key presence, not by value: passing
|
|
88
|
+
* `{ groupId: undefined }` fails with "expected a string value", while omitting
|
|
89
|
+
* the key entirely is accepted. JavaScript treats the two as interchangeable
|
|
90
|
+
* almost everywhere, which is exactly why this is easy to get wrong — and why
|
|
91
|
+
* it only surfaces on a real device, where the native validator runs.
|
|
92
|
+
*/
|
|
93
|
+
export function compact(value) {
|
|
94
|
+
const output = {};
|
|
95
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
96
|
+
if (entry !== undefined) output[key] = entry;
|
|
97
|
+
}
|
|
98
|
+
return output;
|
|
99
|
+
}
|
|
100
|
+
const notifyKit = lazyPeer('react-native-notify-kit', () => {
|
|
101
|
+
// Inside `try`, so Metro bundles an app that leaves this optional peer out.
|
|
102
|
+
try {
|
|
103
|
+
return require('react-native-notify-kit');
|
|
104
|
+
} catch (cause) {
|
|
105
|
+
throw cause;
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
export function loadEngine() {
|
|
109
|
+
return notifyKit.require((_peer, cause) => new NotificationError(DIAGNOSTIC_CODES.PUSH_UNAVAILABLE, 'react-native-notify-kit is not installed or its native module is not linked. Install it as a peer dependency and rebuild the app.', {
|
|
110
|
+
reason: cause instanceof Error ? cause.name : 'unknown'
|
|
111
|
+
})).default;
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["lazyPeer","DIAGNOSTIC_CODES","NotificationError","BACKGROUND_WINDOW_MS","ANDROID_IMPORTANCE","none","min","low","default","high","TRIGGER_TYPE_TIMESTAMP","ALARM_TYPE_EXACT_AND_ALLOW_WHILE_IDLE","ALARM_TYPE_INEXACT_AND_ALLOW_WHILE_IDLE","EVENT_TYPE_DISMISSED","EVENT_TYPE_PRESS","EVENT_TYPE_ACTION_PRESS","EVENT_TYPE_DELIVERED","ANDROID_CATEGORY_ALARM","MARKER_CHANNEL_ID","compact","value","output","key","entry","Object","entries","undefined","notifyKit","require","cause","loadEngine","_peer","PUSH_UNAVAILABLE","reason","Error","name"],"sourceRoot":"../../../../src","sources":["engine/notify-kit/module.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,QAAQ,QAAQ,wBAAwB;AAEjD,SAASC,gBAAgB,EAAEC,iBAAiB,QAAQ,0BAAuB;;AAE3E;AACA,OAAO,MAAMC,oBAAoB,GAAG,MAAM;;AAE1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,kBAAkB,GAAG;EACjCC,IAAI,EAAE,CAAC;EACPC,GAAG,EAAE,CAAC;EACNC,GAAG,EAAE,CAAC;EACNC,OAAO,EAAE,CAAC;EACVC,IAAI,EAAE;AACP,CAAU;;AAEV;AACA,OAAO,MAAMC,sBAAsB,GAAG,CAAC;;AAEvC;AACA,OAAO,MAAMC,qCAAqC,GAAG,CAAC;;AAEtD;AACA,OAAO,MAAMC,uCAAuC,GAAG,CAAC;;AAExD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,oBAAoB,GAAG,CAAC;AACrC,OAAO,MAAMC,gBAAgB,GAAG,CAAC;AACjC,OAAO,MAAMC,uBAAuB,GAAG,CAAC;;AAExC;AACA,OAAO,MAAMC,oBAAo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