@justair/justair-library 6.9.0 → 6.10.0-alpha.2b05bf6
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 +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/models/tests/cookieConsent.test.d.ts +2 -0
- package/dist/models/tests/cookieConsent.test.d.ts.map +1 -0
- package/dist/models/users.d.ts +3 -0
- package/dist/models/users.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/index.js +10 -1
- package/src/models/users.js +43 -1
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,9 @@ import { organizationsSchema } from "./models/organizations.js";
|
|
|
18
18
|
import { Organizations } from "./models/organizations.js";
|
|
19
19
|
import { usersSchema } from "./models/users.js";
|
|
20
20
|
import { Users } from "./models/users.js";
|
|
21
|
+
import { COOKIE_CONSENT_CATEGORIES } from "./models/users.js";
|
|
22
|
+
import { COOKIE_CONSENT_VALUES } from "./models/users.js";
|
|
23
|
+
import { validateCookieConsent } from "./models/users.js";
|
|
21
24
|
import { eventsSchema } from "./models/events.js";
|
|
22
25
|
import { Events } from "./models/events.js";
|
|
23
26
|
import { lightMonitorSchema } from "./models/lightmonitors.js";
|
|
@@ -73,5 +76,5 @@ import { sampleParameterReferenceConcentrations } from "./models/samples.js";
|
|
|
73
76
|
import { PARAMETERS } from "./constants/pollutants.js";
|
|
74
77
|
import { HEAVY_METALS } from "./constants/pollutants.js";
|
|
75
78
|
import { splitName } from "./utils/splitName.js";
|
|
76
|
-
export { Database, adminSchema, Admin, configurationsSchema, Configurations, measurementsSchema, Measurements, monitorRequestsSchema, MonitorRequests, monitorsSchema, Monitors, organizationsSchema, Organizations, usersSchema, Users, 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, PARAMETERS, HEAVY_METALS, splitName };
|
|
79
|
+
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, PARAMETERS, HEAVY_METALS, splitName };
|
|
77
80
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[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qB;6BAArB,qBAAqB;uDAArB,qBAAqB;2BAtBa,2BAA2B;6BAA3B,2BAA2B;0BAC1C,sBAAsB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cookieConsent.test.d.ts","sourceRoot":"","sources":["../../../src/models/tests/cookieConsent.test.js"],"names":[],"mappings":""}
|
package/dist/models/users.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../../src/models/users.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../../src/models/users.js"],"names":[],"mappings":"AAqCA,8BAiDE;AAIF,wBAAmD;AAxFnD,iDAA4D;AAC5D,6CAAmD;AAUnD,4DAsBC"}
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -29,7 +29,13 @@ import {
|
|
|
29
29
|
} from "./models/monitorSuppliers.js";
|
|
30
30
|
import { contextsSchema, Contexts } from "./models/contexts.js";
|
|
31
31
|
import { parametersSchema, Parameters } from "./models/parameters.js";
|
|
32
|
-
import {
|
|
32
|
+
import {
|
|
33
|
+
usersSchema,
|
|
34
|
+
Users,
|
|
35
|
+
COOKIE_CONSENT_CATEGORIES,
|
|
36
|
+
COOKIE_CONSENT_VALUES,
|
|
37
|
+
validateCookieConsent,
|
|
38
|
+
} from "./models/users.js";
|
|
33
39
|
import {
|
|
34
40
|
eventsSchema,
|
|
35
41
|
Events,
|
|
@@ -103,6 +109,9 @@ export {
|
|
|
103
109
|
Organizations,
|
|
104
110
|
usersSchema,
|
|
105
111
|
Users,
|
|
112
|
+
COOKIE_CONSENT_CATEGORIES,
|
|
113
|
+
COOKIE_CONSENT_VALUES,
|
|
114
|
+
validateCookieConsent,
|
|
106
115
|
eventsSchema,
|
|
107
116
|
Events,
|
|
108
117
|
lightMonitorSchema,
|
package/src/models/users.js
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
import mongoose from "mongoose";
|
|
2
2
|
|
|
3
|
+
const COOKIE_CONSENT_CATEGORIES = ["analytics_performance"];
|
|
4
|
+
const COOKIE_CONSENT_VALUES = ["accept", "reject"];
|
|
5
|
+
|
|
6
|
+
const cookieConsentSchemaDefinition = COOKIE_CONSENT_CATEGORIES.reduce(
|
|
7
|
+
(definition, category) => {
|
|
8
|
+
definition[category] = { type: String, enum: COOKIE_CONSENT_VALUES };
|
|
9
|
+
return definition;
|
|
10
|
+
},
|
|
11
|
+
{}
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
const validateCookieConsent = (consent) => {
|
|
15
|
+
if (typeof consent !== "object" || consent === null || Array.isArray(consent)) {
|
|
16
|
+
return "cookie_consent must be an object";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const entries = Object.entries(consent);
|
|
20
|
+
if (entries.length === 0) {
|
|
21
|
+
return "cookie_consent must include at least one category";
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
for (const [category, value] of entries) {
|
|
25
|
+
if (!COOKIE_CONSENT_CATEGORIES.includes(category)) {
|
|
26
|
+
return `Unknown cookie consent category: ${category}`;
|
|
27
|
+
}
|
|
28
|
+
if (!COOKIE_CONSENT_VALUES.includes(value)) {
|
|
29
|
+
return `Invalid value for ${category}: must be one of ${COOKIE_CONSENT_VALUES.join(
|
|
30
|
+
", "
|
|
31
|
+
)}`;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return null;
|
|
36
|
+
};
|
|
37
|
+
|
|
3
38
|
const usersSchema = mongoose.Schema(
|
|
4
39
|
{
|
|
5
40
|
name: String,
|
|
@@ -44,6 +79,7 @@ const usersSchema = mongoose.Schema(
|
|
|
44
79
|
],
|
|
45
80
|
default: "Good",
|
|
46
81
|
},
|
|
82
|
+
cookie_consent: cookieConsentSchemaDefinition,
|
|
47
83
|
},
|
|
48
84
|
{
|
|
49
85
|
timestamps: true,
|
|
@@ -54,4 +90,10 @@ usersSchema.index({ phone: 1 });
|
|
|
54
90
|
|
|
55
91
|
const Users = mongoose.model("Users", usersSchema);
|
|
56
92
|
|
|
57
|
-
export {
|
|
93
|
+
export {
|
|
94
|
+
usersSchema,
|
|
95
|
+
Users,
|
|
96
|
+
COOKIE_CONSENT_CATEGORIES,
|
|
97
|
+
COOKIE_CONSENT_VALUES,
|
|
98
|
+
validateCookieConsent,
|
|
99
|
+
};
|