@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,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.PAST_TOLERANCE_MS = void 0;
|
|
7
|
+
exports.resolveMoment = resolveMoment;
|
|
8
|
+
exports.validateMoment = validateMoment;
|
|
9
|
+
var _errors = require("../contract/errors.js");
|
|
10
|
+
/**
|
|
11
|
+
* Delivery moment resolution.
|
|
12
|
+
*
|
|
13
|
+
* Two rules, and they are two sides of one decision rather than a threshold:
|
|
14
|
+
* a moment more than the tolerance in the past is a caller error and is
|
|
15
|
+
* refused; a moment a few seconds in the past is a processing delay and is
|
|
16
|
+
* delivered promptly. Both outcomes are reported, so a caller never has to
|
|
17
|
+
* guess which happened.
|
|
18
|
+
*
|
|
19
|
+
* Sixty seconds is long enough to absorb reconciling a large desired set, cold
|
|
20
|
+
* start work, and clock skew, and short enough that a genuinely stale schedule
|
|
21
|
+
* is still caught rather than fired at the user minutes late with no
|
|
22
|
+
* explanation.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
const PAST_TOLERANCE_MS = exports.PAST_TOLERANCE_MS = 60_000;
|
|
26
|
+
/**
|
|
27
|
+
* Classifies a resolved instant against now.
|
|
28
|
+
*
|
|
29
|
+
* Takes an already-anchored instant: anchoring decides *which* instant a moment
|
|
30
|
+
* means, and this decides whether that instant is usable. Keeping them separate
|
|
31
|
+
* is what lets each be tested without the other.
|
|
32
|
+
*/
|
|
33
|
+
function resolveMoment(resolvedAt, now) {
|
|
34
|
+
if (!Number.isFinite(resolvedAt)) {
|
|
35
|
+
throw new _errors.NotificationError(_errors.DIAGNOSTIC_CODES.MOMENT_IN_PAST, 'A delivery moment must be a finite epoch-millisecond timestamp.', {
|
|
36
|
+
received: String(resolvedAt)
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
if (resolvedAt >= now) {
|
|
40
|
+
return {
|
|
41
|
+
kind: 'future',
|
|
42
|
+
at: resolvedAt
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
const lateBy = now - resolvedAt;
|
|
46
|
+
if (lateBy <= PAST_TOLERANCE_MS) {
|
|
47
|
+
return {
|
|
48
|
+
kind: 'immediate',
|
|
49
|
+
at: now,
|
|
50
|
+
lateBy
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
throw new _errors.NotificationError(_errors.DIAGNOSTIC_CODES.MOMENT_IN_PAST, `Delivery moment is ${Math.round(lateBy / 1000)}s in the past, beyond the ${PAST_TOLERANCE_MS / 1000}s tolerance. ` + 'It was not scheduled, because handing it to the platform would fire it immediately without explanation.', {
|
|
54
|
+
lateByMs: lateBy,
|
|
55
|
+
toleranceMs: PAST_TOLERANCE_MS
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Validates the shape of a caller-supplied moment before anchoring resolves it. */
|
|
60
|
+
function validateMoment(moment) {
|
|
61
|
+
if (typeof moment.at !== 'number' || !Number.isFinite(moment.at)) {
|
|
62
|
+
throw new _errors.NotificationError(_errors.DIAGNOSTIC_CODES.MOMENT_IN_PAST, 'A delivery moment must carry a finite epoch-millisecond `at` value.', {
|
|
63
|
+
received: typeof moment.at
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
if (moment.anchoring !== undefined && moment.anchoring !== 'wallClock' && moment.anchoring !== 'absolute') {
|
|
67
|
+
throw new _errors.NotificationError(_errors.DIAGNOSTIC_CODES.MOMENT_IN_PAST, 'Anchoring must be either "wallClock" or "absolute".', {
|
|
68
|
+
received: String(moment.anchoring)
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=resolve-moment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_errors","require","PAST_TOLERANCE_MS","exports","resolveMoment","resolvedAt","now","Number","isFinite","NotificationError","DIAGNOSTIC_CODES","MOMENT_IN_PAST","received","String","kind","at","lateBy","Math","round","lateByMs","toleranceMs","validateMoment","moment","anchoring","undefined"],"sourceRoot":"../../../src","sources":["schedule/resolve-moment.ts"],"mappings":";;;;;;;;AAeA,IAAAA,OAAA,GAAAC,OAAA;AAfA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKO,MAAMC,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,GAAG,MAAM;AAMvC;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,aAAaA,CAACC,UAAkB,EAAEC,GAAW,EAAoB;EAChF,IAAI,CAACC,MAAM,CAACC,QAAQ,CAACH,UAAU,CAAC,EAAE;IACjC,MAAM,IAAII,yBAAiB,CAC1BC,wBAAgB,CAACC,cAAc,EAC/B,iEAAiE,EACjE;MAAEC,QAAQ,EAAEC,MAAM,CAACR,UAAU;IAAE,CAChC,CAAC;EACF;EAEA,IAAIA,UAAU,IAAIC,GAAG,EAAE;IACtB,OAAO;MAAEQ,IAAI,EAAE,QAAQ;MAAEC,EAAE,EAAEV;IAAW,CAAC;EAC1C;EAEA,MAAMW,MAAM,GAAGV,GAAG,GAAGD,UAAU;EAE/B,IAAIW,MAAM,IAAId,iBAAiB,EAAE;IAChC,OAAO;MAAEY,IAAI,EAAE,WAAW;MAAEC,EAAE,EAAET,GAAG;MAAEU;IAAO,CAAC;EAC9C;EAEA,MAAM,IAAIP,yBAAiB,CAC1BC,wBAAgB,CAACC,cAAc,EAC/B,sBAAsBM,IAAI,CAACC,KAAK,CAACF,MAAM,GAAG,IAAI,CAAC,6BAA6Bd,iBAAiB,GAAG,IAAI,eAAe,GAClH,yGAAyG,EAC1G;IAAEiB,QAAQ,EAAEH,MAAM;IAAEI,WAAW,EAAElB;EAAkB,CACpD,CAAC;AACF;;AAEA;AACO,SAASmB,cAAcA,CAACC,MAAsB,EAAQ;EAC5D,IAAI,OAAOA,MAAM,CAACP,EAAE,KAAK,QAAQ,IAAI,CAACR,MAAM,CAACC,QAAQ,CAACc,MAAM,CAACP,EAAE,CAAC,EAAE;IACjE,MAAM,IAAIN,yBAAiB,CAC1BC,wBAAgB,CAACC,cAAc,EAC/B,qEAAqE,EACrE;MAAEC,QAAQ,EAAE,OAAOU,MAAM,CAACP;IAAG,CAC9B,CAAC;EACF;EAEA,IACCO,MAAM,CAACC,SAAS,KAAKC,SAAS,IAC9BF,MAAM,CAACC,SAAS,KAAK,WAAW,IAChCD,MAAM,CAACC,SAAS,KAAK,UAAU,EAC9B;IACD,MAAM,IAAId,yBAAiB,CAC1BC,wBAAgB,CAACC,cAAc,EAC/B,qDAAqD,EACrD;MAAEC,QAAQ,EAAEC,MAAM,CAACS,MAAM,CAACC,SAAS;IAAE,CACtC,CAAC;EACF;AACD","ignoreList":[]}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.CONTENT_LIMITS = void 0;
|
|
7
|
+
exports.byteLength = byteLength;
|
|
8
|
+
exports.validateContent = validateContent;
|
|
9
|
+
var _errors = require("../contract/errors.js");
|
|
10
|
+
/**
|
|
11
|
+
* Content validation.
|
|
12
|
+
*
|
|
13
|
+
* The package passes content through **unchanged** and never truncates it.
|
|
14
|
+
* Display truncation is the platform's decision and differs between them; a
|
|
15
|
+
* library that pre-truncated would be guessing at a rule it does not own, and
|
|
16
|
+
* would corrupt content that would have displayed fine.
|
|
17
|
+
*
|
|
18
|
+
* What it does refuse is content over the platform's hard payload limit, where
|
|
19
|
+
* the alternative is not a shortened notification but a failed or undefined
|
|
20
|
+
* delivery. That is a real error and is reported as one, before any platform
|
|
21
|
+
* call.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Hard payload ceilings.
|
|
26
|
+
*
|
|
27
|
+
* These are *not* display limits. A title longer than a phone shows is fine and
|
|
28
|
+
* is passed through; the README documents where each platform visually
|
|
29
|
+
* truncates so a caller can decide for itself.
|
|
30
|
+
*
|
|
31
|
+
* The total is deliberately lower than the sum of the parts, so it actually
|
|
32
|
+
* binds — a per-field check that can never be exceeded in aggregate would be
|
|
33
|
+
* dead code. It sits under the 4 KB payload budget both platforms enforce,
|
|
34
|
+
* leaving headroom for the routing payload that shares it.
|
|
35
|
+
*/
|
|
36
|
+
const CONTENT_LIMITS = exports.CONTENT_LIMITS = {
|
|
37
|
+
maxTitleBytes: 512,
|
|
38
|
+
maxBodyBytes: 3072,
|
|
39
|
+
maxSubtitleBytes: 512,
|
|
40
|
+
maxTotalBytes: 3584
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/** UTF-8 byte length — the unit the platforms actually bound. */
|
|
44
|
+
function byteLength(value) {
|
|
45
|
+
let bytes = 0;
|
|
46
|
+
for (const char of value) {
|
|
47
|
+
const code = char.codePointAt(0) ?? 0;
|
|
48
|
+
if (code <= 0x7f) bytes += 1;else if (code <= 0x7ff) bytes += 2;else if (code <= 0xffff) bytes += 3;else bytes += 4;
|
|
49
|
+
}
|
|
50
|
+
return bytes;
|
|
51
|
+
}
|
|
52
|
+
function requireString(value, field) {
|
|
53
|
+
if (typeof value !== 'string') {
|
|
54
|
+
throw new _errors.NotificationError(_errors.DIAGNOSTIC_CODES.CONTENT_TOO_LARGE, `Notification content field "${field}" must be a string of resolved display text. The package performs no locale resolution.`, {
|
|
55
|
+
field,
|
|
56
|
+
received: typeof value
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return value;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Validates content and returns it **byte-identical**.
|
|
64
|
+
*
|
|
65
|
+
* The return value is the same object reference where possible, so nothing
|
|
66
|
+
* downstream can mistake this for a transformation step.
|
|
67
|
+
*/
|
|
68
|
+
function validateContent(content) {
|
|
69
|
+
const title = requireString(content.title, 'title');
|
|
70
|
+
const body = requireString(content.body, 'body');
|
|
71
|
+
const subtitle = content.subtitle === undefined ? undefined : requireString(content.subtitle, 'subtitle');
|
|
72
|
+
if (title.length === 0 && body.length === 0) {
|
|
73
|
+
throw new _errors.NotificationError(_errors.DIAGNOSTIC_CODES.CONTENT_TOO_LARGE, 'A notification must carry a title or a body; both were empty.', {
|
|
74
|
+
field: 'title+body'
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
const checks = [['title', title, CONTENT_LIMITS.maxTitleBytes], ['body', body, CONTENT_LIMITS.maxBodyBytes]];
|
|
78
|
+
if (subtitle !== undefined) {
|
|
79
|
+
checks.push(['subtitle', subtitle, CONTENT_LIMITS.maxSubtitleBytes]);
|
|
80
|
+
}
|
|
81
|
+
for (const [field, value, limit] of checks) {
|
|
82
|
+
const size = byteLength(value);
|
|
83
|
+
if (size > limit) {
|
|
84
|
+
throw new _errors.NotificationError(_errors.DIAGNOSTIC_CODES.CONTENT_TOO_LARGE, `Notification "${field}" is ${size} bytes, over the ${limit}-byte platform limit. ` + "It was refused rather than truncated, because the package does not decide where a caller's content should be cut.", {
|
|
85
|
+
field,
|
|
86
|
+
bytes: size,
|
|
87
|
+
limit
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const total = byteLength(title) + byteLength(body) + (subtitle ? byteLength(subtitle) : 0);
|
|
92
|
+
if (total > CONTENT_LIMITS.maxTotalBytes) {
|
|
93
|
+
throw new _errors.NotificationError(_errors.DIAGNOSTIC_CODES.CONTENT_TOO_LARGE, `Notification content totals ${total} bytes, over the ${CONTENT_LIMITS.maxTotalBytes}-byte payload limit.`, {
|
|
94
|
+
field: 'total',
|
|
95
|
+
bytes: total,
|
|
96
|
+
limit: CONTENT_LIMITS.maxTotalBytes
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
return content;
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=validate-content.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_errors","require","CONTENT_LIMITS","exports","maxTitleBytes","maxBodyBytes","maxSubtitleBytes","maxTotalBytes","byteLength","value","bytes","char","code","codePointAt","requireString","field","NotificationError","DIAGNOSTIC_CODES","CONTENT_TOO_LARGE","received","validateContent","content","title","body","subtitle","undefined","length","checks","push","limit","size","total"],"sourceRoot":"../../../src","sources":["schedule/validate-content.ts"],"mappings":"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","ignoreList":[]}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.MAX_IDENTIFIER_LENGTH = void 0;
|
|
7
|
+
exports.isValidIdentifier = isValidIdentifier;
|
|
8
|
+
exports.validateIdentifier = validateIdentifier;
|
|
9
|
+
exports.validateOptionalTag = validateOptionalTag;
|
|
10
|
+
var _errors = require("../contract/errors.js");
|
|
11
|
+
var _marker = require("../repeat/marker.js");
|
|
12
|
+
/**
|
|
13
|
+
* Identifier validation.
|
|
14
|
+
*
|
|
15
|
+
* Identity is the caller's contract: only the caller can derive an identifier
|
|
16
|
+
* reproducibly from its own data, so the package never generates one.
|
|
17
|
+
*
|
|
18
|
+
* The charset is composite-friendly because real derived keys are hierarchical
|
|
19
|
+
* — `task:1234:reminder:2`. A charset that forced encoding of natural keys
|
|
20
|
+
* would work against caller-supplied identity being readable and reproducible,
|
|
21
|
+
* which is most of its value.
|
|
22
|
+
*
|
|
23
|
+
* Nothing is normalized, trimmed, case-folded, or hashed. Two identifiers
|
|
24
|
+
* differing in any character are different identifiers, and the value visible
|
|
25
|
+
* at the platform boundary is exactly what the caller supplied — which is what
|
|
26
|
+
* lets a notification be traced back to the data that produced it.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
const MAX_IDENTIFIER_LENGTH = exports.MAX_IDENTIFIER_LENGTH = 128;
|
|
30
|
+
|
|
31
|
+
/** `A–Z a–z 0–9 . _ - : /` — printable, unambiguous, and safe at every boundary. */
|
|
32
|
+
const IDENTIFIER_PATTERN = /^[A-Za-z0-9._:/-]+$/;
|
|
33
|
+
|
|
34
|
+
/** Reports the first offending character so a failure is actionable without echoing the value. */
|
|
35
|
+
function firstInvalidCharacter(value) {
|
|
36
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
37
|
+
const char = value[index];
|
|
38
|
+
if (!/[A-Za-z0-9._:/-]/.test(char)) {
|
|
39
|
+
return {
|
|
40
|
+
char,
|
|
41
|
+
index
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
const EMPTY_CODE = {
|
|
48
|
+
id: _errors.DIAGNOSTIC_CODES.INVALID_ID_EMPTY,
|
|
49
|
+
ownerTag: _errors.DIAGNOSTIC_CODES.INVALID_OWNER_TAG,
|
|
50
|
+
groupTag: _errors.DIAGNOSTIC_CODES.INVALID_GROUP_TAG,
|
|
51
|
+
seriesId: _errors.DIAGNOSTIC_CODES.INVALID_ID_EMPTY,
|
|
52
|
+
actionId: _errors.DIAGNOSTIC_CODES.INVALID_ID_EMPTY
|
|
53
|
+
};
|
|
54
|
+
const LENGTH_CODE = {
|
|
55
|
+
id: _errors.DIAGNOSTIC_CODES.INVALID_ID_LENGTH,
|
|
56
|
+
ownerTag: _errors.DIAGNOSTIC_CODES.INVALID_OWNER_TAG,
|
|
57
|
+
groupTag: _errors.DIAGNOSTIC_CODES.INVALID_GROUP_TAG,
|
|
58
|
+
seriesId: _errors.DIAGNOSTIC_CODES.INVALID_ID_LENGTH,
|
|
59
|
+
actionId: _errors.DIAGNOSTIC_CODES.INVALID_ID_LENGTH
|
|
60
|
+
};
|
|
61
|
+
const CHARSET_CODE = {
|
|
62
|
+
id: _errors.DIAGNOSTIC_CODES.INVALID_ID_CHARSET,
|
|
63
|
+
ownerTag: _errors.DIAGNOSTIC_CODES.INVALID_OWNER_TAG,
|
|
64
|
+
groupTag: _errors.DIAGNOSTIC_CODES.INVALID_GROUP_TAG,
|
|
65
|
+
seriesId: _errors.DIAGNOSTIC_CODES.INVALID_ID_CHARSET,
|
|
66
|
+
actionId: _errors.DIAGNOSTIC_CODES.INVALID_ID_CHARSET
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Throws a typed error naming the violated rule.
|
|
71
|
+
*
|
|
72
|
+
* The offending character and its position are reported; the value itself never
|
|
73
|
+
* is, because an identifier can carry user data a caller derived it from.
|
|
74
|
+
*/
|
|
75
|
+
function validateIdentifier(value, kind = 'id') {
|
|
76
|
+
if (typeof value !== 'string' || value.length === 0) {
|
|
77
|
+
throw new _errors.NotificationError(EMPTY_CODE[kind], `A ${kind} must be a non-empty string supplied by the caller. The package never generates one.`, {
|
|
78
|
+
kind,
|
|
79
|
+
received: typeof value
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
if (value.length > MAX_IDENTIFIER_LENGTH) {
|
|
83
|
+
throw new _errors.NotificationError(LENGTH_CODE[kind], `A ${kind} must be at most ${MAX_IDENTIFIER_LENGTH} characters.`, {
|
|
84
|
+
kind,
|
|
85
|
+
length: value.length,
|
|
86
|
+
max: MAX_IDENTIFIER_LENGTH
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
if (value.startsWith(_marker.REPEAT_STOP_PREFIX)) {
|
|
90
|
+
// Not a style rule. Repeat expiry cancels markers by identifier, so a
|
|
91
|
+
// consumer identifier that looks like one would be deleted out from under
|
|
92
|
+
// a real notification.
|
|
93
|
+
throw new _errors.NotificationError(CHARSET_CODE[kind], `A ${kind} may not begin with "${_marker.REPEAT_STOP_PREFIX}" — that prefix is reserved for the package's own repeat-expiry markers, which are cancelled automatically.`, {
|
|
94
|
+
kind,
|
|
95
|
+
reservedPrefix: _marker.REPEAT_STOP_PREFIX
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
if (!IDENTIFIER_PATTERN.test(value)) {
|
|
99
|
+
const offender = firstInvalidCharacter(value);
|
|
100
|
+
throw new _errors.NotificationError(CHARSET_CODE[kind], `A ${kind} may contain only A-Z, a-z, 0-9, and the separators . _ - : / — whitespace and control characters are not permitted.`, {
|
|
101
|
+
kind,
|
|
102
|
+
index: offender?.index,
|
|
103
|
+
charCode: offender?.char.charCodeAt(0)
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
return value;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** Non-throwing form, for validating a batch without unwinding on the first failure. */
|
|
110
|
+
function isValidIdentifier(value) {
|
|
111
|
+
// The throwing form is the rule; this one only reports whether it holds, so
|
|
112
|
+
// the two cannot disagree (the reserved marker prefix was missing here).
|
|
113
|
+
try {
|
|
114
|
+
validateIdentifier(value);
|
|
115
|
+
return true;
|
|
116
|
+
} catch {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** Validates an optional tag, returning undefined when absent rather than failing. */
|
|
122
|
+
function validateOptionalTag(value, kind) {
|
|
123
|
+
if (value === undefined) return undefined;
|
|
124
|
+
return validateIdentifier(value, kind);
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=validate-identifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_errors","require","_marker","MAX_IDENTIFIER_LENGTH","exports","IDENTIFIER_PATTERN","firstInvalidCharacter","value","index","length","char","test","undefined","EMPTY_CODE","id","DIAGNOSTIC_CODES","INVALID_ID_EMPTY","ownerTag","INVALID_OWNER_TAG","groupTag","INVALID_GROUP_TAG","seriesId","actionId","LENGTH_CODE","INVALID_ID_LENGTH","CHARSET_CODE","INVALID_ID_CHARSET","validateIdentifier","kind","NotificationError","received","max","startsWith","REPEAT_STOP_PREFIX","reservedPrefix","offender","charCode","charCodeAt","isValidIdentifier","validateOptionalTag"],"sourceRoot":"../../../src","sources":["schedule/validate-identifier.ts"],"mappings":"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","ignoreList":[]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createScheduleWriter = createScheduleWriter;
|
|
7
|
+
var _place = require("../repeat/place.js");
|
|
8
|
+
/**
|
|
9
|
+
* The one door every consumer notification goes through to reach the engine.
|
|
10
|
+
*
|
|
11
|
+
* Scheduler, reconciler, recurrence, re-anchoring and channel re-homing all
|
|
12
|
+
* write notifications. Each used to call `engine.schedule` itself, and the
|
|
13
|
+
* guarantees attached to a write — a repeating alert gets its stop marker, and
|
|
14
|
+
* that marker moves when the notification moves — existed only on the paths
|
|
15
|
+
* that remembered them. A recurring alarm never stopped, and a re-anchored one
|
|
16
|
+
* stopped at the old instant.
|
|
17
|
+
*
|
|
18
|
+
* Validation stays with each caller, because each has its own failure policy:
|
|
19
|
+
* the scheduler throws, reconciliation rejects one entry and carries on, and
|
|
20
|
+
* recurrence validates its template once at registration.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
function createScheduleWriter(engine) {
|
|
24
|
+
return writerOver(engine, (0, _place.createStopPlacement)(engine));
|
|
25
|
+
}
|
|
26
|
+
function writerOver(engine, stops) {
|
|
27
|
+
return {
|
|
28
|
+
async write(input) {
|
|
29
|
+
await engine.schedule(input);
|
|
30
|
+
await stops.sync(input.request.id, input.tone, input.resolvedAt);
|
|
31
|
+
},
|
|
32
|
+
async cancel(id) {
|
|
33
|
+
await engine.cancel(id);
|
|
34
|
+
await stops.release(id);
|
|
35
|
+
},
|
|
36
|
+
releaseStop: targetId => stops.release(targetId),
|
|
37
|
+
async capacity() {
|
|
38
|
+
const capabilities = await engine.getCapabilities();
|
|
39
|
+
return Math.max(0, capabilities.pendingCeiling - (await stops.count()));
|
|
40
|
+
},
|
|
41
|
+
pass: () => writerOver(engine, stops.pass())
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=writer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_place","require","createScheduleWriter","engine","writerOver","createStopPlacement","stops","write","input","schedule","sync","request","id","tone","resolvedAt","cancel","release","releaseStop","targetId","capacity","capabilities","getCapabilities","Math","max","pendingCeiling","count","pass"],"sourceRoot":"../../../src","sources":["schedule/writer.ts"],"mappings":";;;;;;AAgBA,IAAAA,MAAA,GAAAC,OAAA;AAhBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAyBO,SAASC,oBAAoBA,CAACC,MAAiC,EAAkB;EACvF,OAAOC,UAAU,CAACD,MAAM,EAAE,IAAAE,0BAAmB,EAACF,MAAM,CAAC,CAAC;AACvD;AAEA,SAASC,UAAUA,CAACD,MAAiC,EAAEG,KAAoB,EAAkB;EAC5F,OAAO;IACN,MAAMC,KAAKA,CAACC,KAAK,EAAE;MAClB,MAAML,MAAM,CAACM,QAAQ,CAACD,KAAK,CAAC;MAC5B,MAAMF,KAAK,CAACI,IAAI,CAACF,KAAK,CAACG,OAAO,CAACC,EAAE,EAAEJ,KAAK,CAACK,IAAI,EAAEL,KAAK,CAACM,UAAU,CAAC;IACjE,CAAC;IAED,MAAMC,MAAMA,CAACH,EAAE,EAAE;MAChB,MAAMT,MAAM,CAACY,MAAM,CAACH,EAAE,CAAC;MACvB,MAAMN,KAAK,CAACU,OAAO,CAACJ,EAAE,CAAC;IACxB,CAAC;IAEDK,WAAW,EAAEC,QAAQ,IAAIZ,KAAK,CAACU,OAAO,CAACE,QAAQ,CAAC;IAEhD,MAAMC,QAAQA,CAAA,EAAG;MAChB,MAAMC,YAAY,GAAG,MAAMjB,MAAM,CAACkB,eAAe,CAAC,CAAC;MACnD,OAAOC,IAAI,CAACC,GAAG,CAAC,CAAC,EAAEH,YAAY,CAACI,cAAc,IAAI,MAAMlB,KAAK,CAACmB,KAAK,CAAC,CAAC,CAAC,CAAC;IACxE,CAAC;IAEDC,IAAI,EAAEA,CAAA,KAAMtB,UAAU,CAACD,MAAM,EAAEG,KAAK,CAACoB,IAAI,CAAC,CAAC;EAC5C,CAAC;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.COLLECTION_CAPS = void 0;
|
|
7
|
+
exports.evict = evict;
|
|
8
|
+
/**
|
|
9
|
+
* Caps and eviction for the persisted collections.
|
|
10
|
+
*
|
|
11
|
+
* No collection may grow without bound. Eviction is oldest-first and always
|
|
12
|
+
* observable — a silent eviction would turn a bounded guarantee into an
|
|
13
|
+
* unexplained one.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/** Every persisted collection with a size or age bound. */
|
|
17
|
+
const COLLECTION_CAPS = exports.COLLECTION_CAPS = {
|
|
18
|
+
dedupLedger: {
|
|
19
|
+
maxEntries: 500,
|
|
20
|
+
retentionMs: 24 * 60 * 60 * 1000
|
|
21
|
+
},
|
|
22
|
+
interactionBuffer: {
|
|
23
|
+
maxEntries: 50,
|
|
24
|
+
retentionMs: 7 * 24 * 60 * 60 * 1000
|
|
25
|
+
},
|
|
26
|
+
migrationLedger: {
|
|
27
|
+
maxEntries: 20,
|
|
28
|
+
retentionMs: Number.POSITIVE_INFINITY
|
|
29
|
+
},
|
|
30
|
+
seriesLedger: {
|
|
31
|
+
maxEntries: 32,
|
|
32
|
+
retentionMs: Number.POSITIVE_INFINITY
|
|
33
|
+
},
|
|
34
|
+
permissionHistory: {
|
|
35
|
+
maxEntries: 64,
|
|
36
|
+
retentionMs: Number.POSITIVE_INFINITY
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/** Anything stored with a timestamp, which is everything that can age out. */
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Which entries a cap may drop (NOT-16). The migration and series ledgers record
|
|
44
|
+
* live facts: an active channel's applied version, a series' count. Dropping one
|
|
45
|
+
* makes the package treat a migrated tone as new and restart a series from zero,
|
|
46
|
+
* so only retired and exhausted entries go; the rest are kept and reported.
|
|
47
|
+
*/
|
|
48
|
+
const EVICTABLE = {
|
|
49
|
+
migrationLedger: entry => entry.retired === true,
|
|
50
|
+
seriesLedger: entry => entry.exhausted === true
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Applies retention first, then the size cap.
|
|
55
|
+
*
|
|
56
|
+
* Order matters: expiring stale entries before trimming means a burst of new
|
|
57
|
+
* entries does not evict fresh ones while stale ones sit protected by
|
|
58
|
+
* recency ordering.
|
|
59
|
+
*/
|
|
60
|
+
function evict(entries, collection, now) {
|
|
61
|
+
const {
|
|
62
|
+
maxEntries,
|
|
63
|
+
retentionMs
|
|
64
|
+
} = COLLECTION_CAPS[collection];
|
|
65
|
+
const expired = [];
|
|
66
|
+
const live = [];
|
|
67
|
+
for (const entry of entries) {
|
|
68
|
+
if (Number.isFinite(retentionMs) && now - entry.at > retentionMs) {
|
|
69
|
+
expired.push(entry);
|
|
70
|
+
} else {
|
|
71
|
+
live.push(entry);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Oldest first, so the tail is what we keep when trimming.
|
|
76
|
+
live.sort((a, b) => a.at - b.at);
|
|
77
|
+
const evictable = EVICTABLE[collection] ?? (() => true);
|
|
78
|
+
const excess = Math.max(0, live.length - maxEntries);
|
|
79
|
+
const overflow = [];
|
|
80
|
+
for (const entry of live) {
|
|
81
|
+
if (overflow.length === excess) break;
|
|
82
|
+
if (evictable(entry)) overflow.push(entry);
|
|
83
|
+
}
|
|
84
|
+
const dropped = new Set(overflow);
|
|
85
|
+
const kept = overflow.length === 0 ? live : live.filter(entry => !dropped.has(entry));
|
|
86
|
+
let reason = 'none';
|
|
87
|
+
if (expired.length > 0 && overflow.length > 0) {
|
|
88
|
+
reason = 'cap+retention';
|
|
89
|
+
} else if (overflow.length > 0) {
|
|
90
|
+
reason = 'cap';
|
|
91
|
+
} else if (expired.length > 0) {
|
|
92
|
+
reason = 'retention';
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
kept,
|
|
96
|
+
evicted: [...expired, ...overflow],
|
|
97
|
+
reason,
|
|
98
|
+
overCap: Math.max(0, kept.length - maxEntries)
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=caps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["COLLECTION_CAPS","exports","dedupLedger","maxEntries","retentionMs","interactionBuffer","migrationLedger","Number","POSITIVE_INFINITY","seriesLedger","permissionHistory","EVICTABLE","entry","retired","exhausted","evict","entries","collection","now","expired","live","isFinite","at","push","sort","a","b","evictable","excess","Math","max","length","overflow","dropped","Set","kept","filter","has","reason","evicted","overCap"],"sourceRoot":"../../../src","sources":["state/caps.ts"],"mappings":"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","ignoreList":[]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isDuplicate = isDuplicate;
|
|
7
|
+
exports.recordSeen = recordSeen;
|
|
8
|
+
/**
|
|
9
|
+
* The push deduplication ledger.
|
|
10
|
+
*
|
|
11
|
+
* Providers redeliver. The redelivery typically arrives in a **fresh process**,
|
|
12
|
+
* which is precisely why this is persisted rather than held in memory — an
|
|
13
|
+
* in-memory set would forget exactly when it matters.
|
|
14
|
+
*
|
|
15
|
+
* Bounded by cap and retention. A payload redelivered after its entry has aged
|
|
16
|
+
* out is treated as new: that is the documented bound of the guarantee, not a
|
|
17
|
+
* defect.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
function isDuplicate(state, dedupId) {
|
|
21
|
+
return state.read().dedupLedger.some(entry => entry.dedupId === dedupId);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Records a payload as seen.
|
|
26
|
+
*
|
|
27
|
+
* Returns true when it was already known, so a caller can branch on the same
|
|
28
|
+
* read that records it rather than checking twice.
|
|
29
|
+
*/
|
|
30
|
+
function recordSeen(state, dedupId, now, ownerTag) {
|
|
31
|
+
if (isDuplicate(state, dedupId)) return true;
|
|
32
|
+
state.update('dedupLedger', current => [...current, {
|
|
33
|
+
at: now,
|
|
34
|
+
dedupId,
|
|
35
|
+
ownerTag
|
|
36
|
+
}]);
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=dedup-ledger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["isDuplicate","state","dedupId","read","dedupLedger","some","entry","recordSeen","now","ownerTag","update","current","at"],"sourceRoot":"../../../src","sources":["state/dedup-ledger.ts"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIO,SAASA,WAAWA,CAACC,KAAmB,EAAEC,OAAe,EAAW;EAC1E,OAAOD,KAAK,CAACE,IAAI,CAAC,CAAC,CAACC,WAAW,CAACC,IAAI,CAACC,KAAK,IAAIA,KAAK,CAACJ,OAAO,KAAKA,OAAO,CAAC;AACzE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASK,UAAUA,CACzBN,KAAmB,EACnBC,OAAe,EACfM,GAAW,EACXC,QAAiB,EACP;EACV,IAAIT,WAAW,CAACC,KAAK,EAAEC,OAAO,CAAC,EAAE,OAAO,IAAI;EAE5CD,KAAK,CAACS,MAAM,CAAC,aAAa,EAAEC,OAAO,IAAI,CAAC,GAAGA,OAAO,EAAE;IAAEC,EAAE,EAAEJ,GAAG;IAAEN,OAAO;IAAEO;EAAS,CAAC,CAAC,CAAC;EACpF,OAAO,KAAK;AACb","ignoreList":[]}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.buffer = buffer;
|
|
7
|
+
exports.bufferedCount = bufferedCount;
|
|
8
|
+
exports.drain = drain;
|
|
9
|
+
/**
|
|
10
|
+
* The durable interaction buffer.
|
|
11
|
+
*
|
|
12
|
+
* A cold-start tap arrives before any handler exists. Holding it in memory
|
|
13
|
+
* would be enough if the process always survived — but the process is exactly
|
|
14
|
+
* what does not survive a cold start, so the buffer is persisted.
|
|
15
|
+
*
|
|
16
|
+
* This is the one content-bearing thing the package stores: an interaction
|
|
17
|
+
* cannot be delivered without its routing payload. It is evicted the moment it
|
|
18
|
+
* is delivered, and time-limited regardless, so an event nobody ever collects
|
|
19
|
+
* cannot sit on disk forever.
|
|
20
|
+
*
|
|
21
|
+
* Text the user typed into a reply action is never written to disk (NOT-14): it
|
|
22
|
+
* is free text, and the store is not encrypted. It is held in memory beside the
|
|
23
|
+
* buffer, so a handler registered later in the same process still receives it;
|
|
24
|
+
* if the process dies first, the event is delivered without `inputText`.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/** Typed replies, in memory only, per state manager and buffered event id. */
|
|
28
|
+
const typedReplies = new WeakMap();
|
|
29
|
+
function repliesOf(state) {
|
|
30
|
+
let replies = typedReplies.get(state);
|
|
31
|
+
if (!replies) {
|
|
32
|
+
replies = new Map();
|
|
33
|
+
typedReplies.set(state, replies);
|
|
34
|
+
}
|
|
35
|
+
return replies;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Identity for a buffered event, derived so re-buffering cannot duplicate. */
|
|
39
|
+
function bufferedId(event) {
|
|
40
|
+
return `${event.kind}:${event.notificationId}:${event.actionId ?? ''}:${event.occurredAt}`;
|
|
41
|
+
}
|
|
42
|
+
function buffer(state, event) {
|
|
43
|
+
const id = bufferedId(event);
|
|
44
|
+
if (event.inputText !== undefined) {
|
|
45
|
+
repliesOf(state).set(id, event.inputText);
|
|
46
|
+
}
|
|
47
|
+
state.update('interactionBuffer', current => {
|
|
48
|
+
if (current.some(entry => entry.id === id)) return current;
|
|
49
|
+
const entry = {
|
|
50
|
+
at: event.occurredAt,
|
|
51
|
+
id,
|
|
52
|
+
kind: event.kind,
|
|
53
|
+
notificationId: event.notificationId,
|
|
54
|
+
actionId: event.actionId,
|
|
55
|
+
routing: event.routing,
|
|
56
|
+
ownerTag: event.ownerTag
|
|
57
|
+
};
|
|
58
|
+
return [...current, entry];
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Takes every buffered event in occurrence order and clears them.
|
|
64
|
+
*
|
|
65
|
+
* Draining and clearing together is deliberate: delivering an event twice is
|
|
66
|
+
* worse than the alternative, because a consumer that acts on an interaction
|
|
67
|
+
* (marking a task done, sending a reply) would act twice.
|
|
68
|
+
*/
|
|
69
|
+
function drain(state) {
|
|
70
|
+
const buffered = [...state.read().interactionBuffer].sort((a, b) => a.at - b.at);
|
|
71
|
+
if (buffered.length === 0) return [];
|
|
72
|
+
state.update('interactionBuffer', () => []);
|
|
73
|
+
const replies = repliesOf(state);
|
|
74
|
+
return buffered.map(entry => ({
|
|
75
|
+
kind: entry.kind,
|
|
76
|
+
notificationId: entry.notificationId,
|
|
77
|
+
actionId: entry.actionId,
|
|
78
|
+
// A record written before 0.5 may still carry the text on disk; it is
|
|
79
|
+
// delivered once, and the buffer was just cleared.
|
|
80
|
+
inputText: takeReply(replies, entry.id) ?? entry.inputText,
|
|
81
|
+
routing: entry.routing,
|
|
82
|
+
ownerTag: entry.ownerTag,
|
|
83
|
+
occurredAt: entry.at,
|
|
84
|
+
// The state it arrived in is gone; what matters to a consumer is that it
|
|
85
|
+
// waited, which is what `wasBuffered` says.
|
|
86
|
+
appState: 'coldStart',
|
|
87
|
+
wasBuffered: true
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
90
|
+
function bufferedCount(state) {
|
|
91
|
+
return state.read().interactionBuffer.length;
|
|
92
|
+
}
|
|
93
|
+
function takeReply(replies, id) {
|
|
94
|
+
const text = replies.get(id);
|
|
95
|
+
replies.delete(id);
|
|
96
|
+
return text;
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=interaction-buffer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["typedReplies","WeakMap","repliesOf","state","replies","get","Map","set","bufferedId","event","kind","notificationId","actionId","occurredAt","buffer","id","inputText","undefined","update","current","some","entry","at","routing","ownerTag","drain","buffered","read","interactionBuffer","sort","a","b","length","map","takeReply","appState","wasBuffered","bufferedCount","text","delete"],"sourceRoot":"../../../src","sources":["state/interaction-buffer.ts"],"mappings":"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","ignoreList":[]}
|