@justair/justair-library 7.2.0-alpha.a4979c6 → 7.2.0-alpha.ab385cc

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/dist/index.d.ts CHANGED
@@ -86,10 +86,6 @@ import { AccountNotification } from "./models/userNotifications.js";
86
86
  import { NOTIFICATION_KINDS } from "./models/userNotifications.js";
87
87
  import { NOTIFICATION_CHANNELS } from "./models/userNotifications.js";
88
88
  import { DELIVERY_STATUSES } from "./models/userNotifications.js";
89
- import { dataDownloadSchema } from "./models/dataDownloads.js";
90
- import { DataDownloads } from "./models/dataDownloads.js";
91
- import { AqiDataDownload } from "./models/dataDownloads.js";
92
- import { SampleDataDownload } from "./models/dataDownloads.js";
93
89
  import { PARAMETERS } from "./constants/pollutants.js";
94
90
  import { HEAVY_METALS } from "./constants/pollutants.js";
95
91
  import { ALERT_LEVEL_WEIGHTS } from "./constants/alertLevels.js";
@@ -104,5 +100,5 @@ import { validateQuietHours } from "./utils/quietHours.js";
104
100
  import { getZoneMinutes } from "./utils/quietHours.js";
105
101
  import { isInQuietWindow } from "./utils/quietHours.js";
106
102
  import { resolveQuietHours } from "./utils/quietHours.js";
107
- export { Database, adminSchema, Admin, configurationsSchema, Configurations, measurementsSchema, Measurements, monitorRequestsSchema, MonitorRequests, monitorsSchema, Monitors, organizationsSchema, Organizations, usersSchema, Users, COOKIE_CONSENT_CATEGORIES, COOKIE_CONSENT_VALUES, validateCookieConsent, eventsSchema, Events, lightMonitorSchema, LightMonitors, monitorSuppliersSchema, MonitorSuppliers, contextsSchema, Contexts, parametersSchema, Parameters, announcementSchema, Announcements, jobsSchema, Jobs, apiKeySchema, ApiKey, UsageMetrics, usageMetricsSchema, Audit, auditSchema, EventsAudit, eventsAuditSchema, MonitorAudit, monitorAuditSchema, parametersEnum, deploymentTypesEnum, AlertsAudit, Alerts, alertsSchema, alertsAuditSchema, Features, featuresSchema, dataCompletenessSchema, DataCompleteness, networkMetricsSchema, NetworkMetrics, rateOfChangeSchema, RateOfChange, changeStreamCheckpointsSchema, ChangeStreamCheckpoints, sitesSchema, Sites, sampleSitesSchema, SampleSites, sampleSiteAuditSchema, SampleSiteAudit, sampleParametersEnum, samplesSchema, Samples, samplesAuditSchema, SamplesAudit, sampleParameterReferenceConcentrations, passwordResetTokenSchema, PasswordResetToken, monitorEpisodesSchema, MonitorEpisode, userNotificationsSchema, UserNotification, AqiAlertNotification, DeviceOfflineNotification, WeeklyDigestNotification, AccountNotification, NOTIFICATION_KINDS, NOTIFICATION_CHANNELS, DELIVERY_STATUSES, dataDownloadSchema, DataDownloads, AqiDataDownload, SampleDataDownload, PARAMETERS, HEAVY_METALS, ALERT_LEVEL_WEIGHTS, getAlertWeight, splitName, DEFAULT_QUIET_HOURS, DEFAULT_TIMEZONE, QUIET_HOURS_ERRORS, isValidTimeString, isValidIANATimezone, validateQuietHours, getZoneMinutes, isInQuietWindow, resolveQuietHours };
103
+ export { Database, adminSchema, Admin, configurationsSchema, Configurations, measurementsSchema, Measurements, monitorRequestsSchema, MonitorRequests, monitorsSchema, Monitors, organizationsSchema, Organizations, usersSchema, Users, COOKIE_CONSENT_CATEGORIES, COOKIE_CONSENT_VALUES, validateCookieConsent, eventsSchema, Events, lightMonitorSchema, LightMonitors, monitorSuppliersSchema, MonitorSuppliers, contextsSchema, Contexts, parametersSchema, Parameters, announcementSchema, Announcements, jobsSchema, Jobs, apiKeySchema, ApiKey, UsageMetrics, usageMetricsSchema, Audit, auditSchema, EventsAudit, eventsAuditSchema, MonitorAudit, monitorAuditSchema, parametersEnum, deploymentTypesEnum, AlertsAudit, Alerts, alertsSchema, alertsAuditSchema, Features, featuresSchema, dataCompletenessSchema, DataCompleteness, networkMetricsSchema, NetworkMetrics, rateOfChangeSchema, RateOfChange, changeStreamCheckpointsSchema, ChangeStreamCheckpoints, sitesSchema, Sites, sampleSitesSchema, SampleSites, sampleSiteAuditSchema, SampleSiteAudit, sampleParametersEnum, samplesSchema, Samples, samplesAuditSchema, SamplesAudit, sampleParameterReferenceConcentrations, passwordResetTokenSchema, PasswordResetToken, monitorEpisodesSchema, MonitorEpisode, userNotificationsSchema, UserNotification, AqiAlertNotification, DeviceOfflineNotification, WeeklyDigestNotification, AccountNotification, NOTIFICATION_KINDS, NOTIFICATION_CHANNELS, DELIVERY_STATUSES, PARAMETERS, HEAVY_METALS, ALERT_LEVEL_WEIGHTS, getAlertWeight, splitName, DEFAULT_QUIET_HOURS, DEFAULT_TIMEZONE, QUIET_HOURS_ERRORS, isValidTimeString, isValidIANATimezone, validateQuietHours, getZoneMinutes, isInQuietWindow, resolveQuietHours };
108
104
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AA6HA;;;iBAEC;yBA7DwB,oBAAoB;qBADxB,gBAAgB;4BAjEF,mBAAmB;sBAAnB,mBAAmB;qCAI/C,4BAA4B;+BAA5B,4BAA4B;mCAM5B,0BAA0B;6BAA1B,0BAA0B;sCAI1B,6BAA6B;gCAA7B,6BAA6B;+BAQ7B,sBAAsB;yBAAtB,sBAAsB;oCACsB,2BAA2B;8BAA3B,2BAA2B;4BAcvE,mBAAmB;sBAAnB,mBAAmB;0CAAnB,mBAAmB;sCAAnB,mBAAmB;sCAAnB,mBAAmB;6BAMnB,oBAAoB;uBAApB,oBAAoB;mCAnBuB,2BAA2B;8BAA3B,2BAA2B;uCAItE,8BAA8B;iCAA9B,8BAA8B;+BACI,sBAAsB;yBAAtB,sBAAsB;iCAClB,wBAAwB;2BAAxB,wBAAwB;mCAcnB,2BAA2B;8BAA3B,2BAA2B;2BAC5C,kBAAkB;qBAAlB,kBAAkB;6BACd,oBAAoB;uBAApB,oBAAoB;6BACR,0BAA0B;mCAA1B,0BAA0B;sBArCpE,0BAA0B;4BAA1B,0BAA0B;4BAiC1B,oBAAoB;kCAApB,oBAAoB;6BArBpB,sBAAsB;mCAAtB,sBAAsB;+B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2B;6BAA3B,2BAA2B;oCAChB,4BAA4B;+BAA5B,4BAA4B;0BAgBtD,sBAAsB;oCAWzC,uBAAuB;iCAAvB,uBAAuB;mCAAvB,uBAAuB;kCAAvB,uBAAuB;oCAAvB,uBAAuB;mCAAvB,uBAAuB;+BAAvB,uBAAuB;gCAAvB,uBAAuB;kCAAvB,uBAAuB"}
@@ -1 +1 @@
1
- {"version":3,"file":"monitors.d.ts","sourceRoot":"","sources":["../../src/models/monitors.js"],"names":[],"mappings":"AA4KA,iCAoJE;AAuIF,2BAA4D;AAlU5D,qCAiCE;AAGF,+BAAwE;AAtKxE,sCAAoD"}
1
+ {"version":3,"file":"monitors.d.ts","sourceRoot":"","sources":["../../src/models/monitors.js"],"names":[],"mappings":"AA4KA,iCAqJE;AAuIF,2BAA4D;AAnU5D,qCAiCE;AAGF,+BAAwE;AAtKxE,sCAAoD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@justair/justair-library",
3
- "version": "7.2.0-alpha.a4979c6",
3
+ "version": "7.2.0-alpha.ab385cc",
4
4
  "description": "JustAir Internal Library",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
package/src/index.js CHANGED
@@ -116,12 +116,6 @@ import {
116
116
  sampleParameterReferenceConcentrations,
117
117
  } from "./models/samples.js";
118
118
  import { passwordResetTokenSchema, PasswordResetToken } from "./models/passwordResetToken.js";
119
- import {
120
- dataDownloadSchema,
121
- DataDownloads,
122
- AqiDataDownload,
123
- SampleDataDownload,
124
- } from "./models/dataDownloads.js";
125
119
 
126
120
  export function createLoggerInstance({ DATADOG_API_KEY, APPLICATION_NAME }) {
127
121
  return new CustomLogger({ DATADOG_API_KEY, APPLICATION_NAME });
@@ -216,11 +210,6 @@ export {
216
210
  NOTIFICATION_KINDS,
217
211
  NOTIFICATION_CHANNELS,
218
212
  DELIVERY_STATUSES,
219
- // Data downloads (JA-3080)
220
- dataDownloadSchema,
221
- DataDownloads,
222
- AqiDataDownload,
223
- SampleDataDownload,
224
213
  // Pollutant constants
225
214
  PARAMETERS,
226
215
  HEAVY_METALS,
@@ -195,6 +195,7 @@ const monitorsSchema = mongoose.Schema(
195
195
  "atmotube",
196
196
  "hobolink",
197
197
  "dasberry",
198
+ "airThings",
198
199
  ],
199
200
  },
200
201
  monitorType: String,
@@ -1,5 +0,0 @@
1
- export const dataDownloadSchema: any;
2
- export const DataDownloads: any;
3
- export const AqiDataDownload: any;
4
- export const SampleDataDownload: any;
5
- //# sourceMappingURL=dataDownloads.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dataDownloads.d.ts","sourceRoot":"","sources":["../../src/models/dataDownloads.js"],"names":[],"mappings":"AAWA,qCAiBE;AAuBF,gCAA0E;AAE1E,kCASE;AAGF,qCASE"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=dataDownloads.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dataDownloads.test.d.ts","sourceRoot":"","sources":["../../../src/models/tests/dataDownloads.test.js"],"names":[],"mappings":""}
@@ -1,78 +0,0 @@
1
- import mongoose from "mongoose";
2
- import { DEFAULT_TIMEZONE } from "../utils/quietHours.js";
3
-
4
- const MAX_RANGE_DAYS = 31;
5
-
6
- // DataDownloads — one doc per data download request (JA-3080). Written by
7
- // JustAirService on download (JA-3081); read by the org-level admin
8
- // communication screen. AQI downloads are monitor-scoped, Sample downloads
9
- // are site-scoped (samples.js keys samples to SampleSites, not Monitors) —
10
- // modeled as discriminators per CLAUDE.md's multi-kind pattern rather than
11
- // a flat schema with a monitorId/siteId pair that's nullable either way.
12
- const dataDownloadSchema = mongoose.Schema(
13
- {
14
- orgId: {
15
- type: mongoose.Types.ObjectId,
16
- ref: "Organizations",
17
- required: [true, "orgId is required"],
18
- },
19
- dateRangeStart: { type: Date, required: [true, "dateRangeStart is required"] },
20
- dateRangeEnd: { type: Date, required: [true, "dateRangeEnd is required"] },
21
- timezone: { type: String, default: DEFAULT_TIMEZONE },
22
- downloadedAt: { type: Date, required: true, default: Date.now },
23
- email: { type: String, trim: true, lowercase: true, default: null },
24
- },
25
- {
26
- timestamps: true,
27
- discriminatorKey: "dataType",
28
- }
29
- );
30
-
31
- // Cross-field rule (quiet-hours shape, CLAUDE.md): end must not precede
32
- // start, and the product rule caps a single download at 31 days of hourly
33
- // data. Lives in pre('validate') so create()/save() can't persist an
34
- // invalid range even if a caller forgets to check.
35
- dataDownloadSchema.pre("validate", async function () {
36
- if (this.dateRangeStart && this.dateRangeEnd) {
37
- if (this.dateRangeEnd < this.dateRangeStart) {
38
- this.invalidate("dateRangeEnd", "dateRangeEnd must not be before dateRangeStart");
39
- } else {
40
- const rangeMs = this.dateRangeEnd - this.dateRangeStart;
41
- const maxRangeMs = MAX_RANGE_DAYS * 24 * 60 * 60 * 1000;
42
- if (rangeMs > maxRangeMs) {
43
- this.invalidate("dateRangeEnd", `date range cannot exceed ${MAX_RANGE_DAYS} days`);
44
- }
45
- }
46
- }
47
- });
48
-
49
- // Org-level admin screen lists a given org's downloads, most recent first.
50
- dataDownloadSchema.index({ orgId: 1, createdAt: -1 });
51
-
52
- const DataDownloads = mongoose.model("DataDownloads", dataDownloadSchema);
53
-
54
- const AqiDataDownload = DataDownloads.discriminator(
55
- "AQI",
56
- new mongoose.Schema({
57
- monitorId: {
58
- type: mongoose.Types.ObjectId,
59
- ref: "Monitors",
60
- required: [true, "monitorId is required"],
61
- },
62
- })
63
- );
64
- AqiDataDownload.schema.index({ monitorId: 1, createdAt: -1 });
65
-
66
- const SampleDataDownload = DataDownloads.discriminator(
67
- "Sample",
68
- new mongoose.Schema({
69
- siteId: {
70
- type: mongoose.Types.ObjectId,
71
- ref: "SampleSites",
72
- required: [true, "siteId is required"],
73
- },
74
- })
75
- );
76
- SampleDataDownload.schema.index({ siteId: 1, createdAt: -1 });
77
-
78
- export { dataDownloadSchema, DataDownloads, AqiDataDownload, SampleDataDownload };