@justair/justair-library 7.6.0-alpha.2ec581a → 7.6.0-alpha.887f403
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.
|
@@ -11,7 +11,9 @@ export const VISIBLE_SITE_MONITOR_FILTER: Readonly<{
|
|
|
11
11
|
isPrivate: Readonly<{
|
|
12
12
|
$ne: true;
|
|
13
13
|
}>;
|
|
14
|
-
isActive:
|
|
14
|
+
isActive: Readonly<{
|
|
15
|
+
$ne: false;
|
|
16
|
+
}>;
|
|
15
17
|
}>;
|
|
16
18
|
export function projectSubscribedMonitors(subscribedDevices?: Array<{
|
|
17
19
|
deviceId: import("mongoose").Types.ObjectId;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscribedDevices.d.ts","sourceRoot":"","sources":["../../src/utils/subscribedDevices.js"],"names":[],"mappings":"AA0FA;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"subscribedDevices.d.ts","sourceRoot":"","sources":["../../src/utils/subscribedDevices.js"],"names":[],"mappings":"AA0FA;;;;;;;;GASG;AAyCH;;;;;;;GAGG;AA6LI,8DANI,KAAK,CAAC;IAAE,QAAQ,EAAE,OAAO,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC;IAC1D,UAAU,EAAE,OAAO,6BAA6B,EAAE,UAAU,CAAA;CAAE,CAAC,8BACzD;IAAE,qBAAqB,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,UAAU,EAAE,KAAK,CAAC,QAAQ,EAAE,KAC7E,OAAO,CAAC,KAAK,CAAC,OAAO,UAAU,EAAE,KAAK,CAAC,QAAQ,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC,CAAA;CAAE,GAC9D,OAAO,CAAC,OAAO,UAAU,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CA0BxD;AA0EM,0DAPI,KAAK,CAAC;IAAE,GAAG,EAAE,GAAG,CAAC;IAAC,iBAAiB,CAAC,EAAE,KAAK,CAAC;QAClD,QAAQ,EAAE,OAAO,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC;QAC5C,UAAU,EAAE,OAAO,6BAA6B,EAAE,UAAU,CAAA;KAAE,CAAC,CAAA;CAAE,CAAC,mCAC5D;IAAE,0BAA0B,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,UAAU,EAAE,KAAK,CAAC,QAAQ,EAAE,KAClF,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,UAAU,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAA;CAAE,GACnD,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,UAAU,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAmErE"}
|
package/package.json
CHANGED
|
@@ -116,20 +116,15 @@ export const SUBSCRIBED_DEVICES_ERRORS = Object.freeze({
|
|
|
116
116
|
// "_id",
|
|
117
117
|
// ).lean();
|
|
118
118
|
//
|
|
119
|
-
// `isActive:
|
|
120
|
-
//
|
|
121
|
-
//
|
|
122
|
-
// `
|
|
123
|
-
//
|
|
124
|
-
//
|
|
125
|
-
//
|
|
126
|
-
//
|
|
127
|
-
//
|
|
128
|
-
//
|
|
129
|
-
// So the failure modes are not symmetric and should not be made symmetric.
|
|
130
|
-
// Over-including here means alerting people about a monitor nobody confirmed
|
|
131
|
-
// is live; under-including means one unconfirmed monitor is missing from an
|
|
132
|
-
// audience until someone sets the flag. This predicate takes the second.
|
|
119
|
+
// `isActive: { $ne: false }` for the same reason, one step weaker than it
|
|
120
|
+
// looks: `isActive` is `default: true` and NOT `required` (models/monitors.js),
|
|
121
|
+
// so a monitor written before the field existed carries no key. An exact
|
|
122
|
+
// `isActive: true` match would drop it out of every Site's audience silently —
|
|
123
|
+
// the same class of bug as an exact `isPrivate: false` match, and the two
|
|
124
|
+
// halves of this predicate should fail the same way. Both clauses are
|
|
125
|
+
// deliberately permissive on a missing key: the cost of over-including a stale
|
|
126
|
+
// monitor is a redundant alert, the cost of under-including is a person who
|
|
127
|
+
// stops being alerted at all.
|
|
133
128
|
//
|
|
134
129
|
// `monitorState: "Deployed"` is deliberately NOT here. That is an
|
|
135
130
|
// alerting-eligibility rule, not a visibility rule, and it belongs to the
|
|
@@ -142,11 +137,10 @@ export const SUBSCRIBED_DEVICES_ERRORS = Object.freeze({
|
|
|
142
137
|
// top-level-only freeze still lets a consumer write
|
|
143
138
|
// `VISIBLE_SITE_MONITOR_FILTER.isPrivate.$ne = false` — and because every
|
|
144
139
|
// consumer spreads THIS instance, that one write flips the privacy predicate
|
|
145
|
-
// for the whole process.
|
|
146
|
-
// too, and freeze any operator object a future clause introduces.
|
|
140
|
+
// for the whole process. Freeze each nested operator object too.
|
|
147
141
|
export const VISIBLE_SITE_MONITOR_FILTER = Object.freeze({
|
|
148
142
|
isPrivate: Object.freeze({ $ne: true }),
|
|
149
|
-
isActive:
|
|
143
|
+
isActive: Object.freeze({ $ne: false }),
|
|
150
144
|
});
|
|
151
145
|
|
|
152
146
|
// Dedupe by string form, keep the caller's ObjectId instances. Two equal
|
|
@@ -665,17 +665,15 @@ describe('resolveSubscribedMonitorIdsByUser — rejects what would otherwise fai
|
|
|
665
665
|
});
|
|
666
666
|
|
|
667
667
|
describe('VISIBLE_SITE_MONITOR_FILTER', () => {
|
|
668
|
-
test('
|
|
669
|
-
//
|
|
670
|
-
//
|
|
671
|
-
//
|
|
672
|
-
//
|
|
673
|
-
//
|
|
674
|
-
// assertion stays out. Confirmed product decision — flipping either half
|
|
675
|
-
// is a behaviour change, not a cleanup.
|
|
668
|
+
test('both clauses use $ne, so a document missing the key survives', () => {
|
|
669
|
+
// $ne matches both the negated value and a MISSING key. isPrivate has no
|
|
670
|
+
// key on documents written before it existed; isActive is `default: true`
|
|
671
|
+
// and NOT required (models/monitors.js), so it has the same gap. An exact
|
|
672
|
+
// match on either would drop those monitors out of every Site's audience
|
|
673
|
+
// with no error anywhere.
|
|
676
674
|
expect(VISIBLE_SITE_MONITOR_FILTER).toEqual({
|
|
677
675
|
isPrivate: { $ne: true },
|
|
678
|
-
isActive:
|
|
676
|
+
isActive: { $ne: false },
|
|
679
677
|
});
|
|
680
678
|
});
|
|
681
679
|
|
|
@@ -685,6 +683,7 @@ describe('VISIBLE_SITE_MONITOR_FILTER', () => {
|
|
|
685
683
|
// predicate for every consumer that spreads this instance.
|
|
686
684
|
expect(Object.isFrozen(VISIBLE_SITE_MONITOR_FILTER)).toBe(true);
|
|
687
685
|
expect(Object.isFrozen(VISIBLE_SITE_MONITOR_FILTER.isPrivate)).toBe(true);
|
|
686
|
+
expect(Object.isFrozen(VISIBLE_SITE_MONITOR_FILTER.isActive)).toBe(true);
|
|
688
687
|
});
|
|
689
688
|
|
|
690
689
|
test('a nested write is rejected rather than shared with every consumer', () => {
|