Comparing version 1.0.0-alpha01 to 1.0.0-alpha02
76
index.js
@@ -44,2 +44,65 @@ import { | ||
// src/data/device/DeviceIdDataSource.ts | ||
var deviceIdDataSourceImpl = () => { | ||
const keyForUserId = (userId) => `nabla_device_id_${userId}`; | ||
return { | ||
getStoredDeviceId: (userId) => { | ||
var _a; | ||
return (_a = localStorage.getItem(keyForUserId(userId))) != null ? _a : void 0; | ||
}, | ||
setDeviceId: (deviceId, userId) => { | ||
localStorage.setItem(keyForUserId(userId), deviceId); | ||
} | ||
}; | ||
}; | ||
// src/__generated__/graphql.ts | ||
var RegisterOrUpdateDeviceDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "mutation", "name": { "kind": "Name", "value": "RegisterOrUpdateDevice" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "deviceId" } }, "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "UUID" } } }, { "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "device" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "DeviceInput" } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "registerOrUpdateDevice" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "deviceId" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "deviceId" } } }, { "kind": "Argument", "name": { "kind": "Name", "value": "device" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "device" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "deviceId" } }, { "kind": "Field", "name": { "kind": "Name", "value": "sentry" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "dsn" } }, { "kind": "Field", "name": { "kind": "Name", "value": "env" } }] } }] } }] } }] }; | ||
// src/__generated__/version.ts | ||
var sdkVersionCode = 478; | ||
// src/data/device/DeviceRepositoryImpl.ts | ||
var deviceRepositoryImpl = (apolloClient, deviceIdDataSource, logger) => ({ | ||
async sendDeviceInfoAsync(activeModules, userId) { | ||
var _a; | ||
try { | ||
const gqlModules = activeModules.map((module) => { | ||
let sdkModule; | ||
switch (module) { | ||
case "Messaging": | ||
sdkModule = "MESSAGING" /* Messaging */; | ||
break; | ||
} | ||
return sdkModule; | ||
}); | ||
const response = await apolloClient.mutate({ | ||
mutation: RegisterOrUpdateDeviceDocument, | ||
variables: { | ||
device: { | ||
codeVersion: sdkVersionCode, | ||
deviceModel: navigator.userAgent, | ||
os: "WEB" /* Web */, | ||
osVersion: null, | ||
sdkModules: gqlModules | ||
}, | ||
deviceId: deviceIdDataSource.getStoredDeviceId(userId) | ||
} | ||
}); | ||
const deviceId = (_a = response.data) == null ? void 0 : _a.registerOrUpdateDevice.deviceId; | ||
if (!deviceId) { | ||
throw new ServerError( | ||
"Missing deviceId in RegisterOrUpdateDevice mutation response" | ||
); | ||
} | ||
deviceIdDataSource.setDeviceId(deviceId, userId); | ||
} catch (e) { | ||
logger.warn( | ||
"Unable to identify device. This is not important and will be retried next time the app restarts.", | ||
e | ||
); | ||
} | ||
} | ||
}); | ||
// src/data/apolloMiddlewares.ts | ||
@@ -310,2 +373,3 @@ import { ApolloLink } from "@apollo/client/core"; | ||
__publicField(this, "patientRepository"); | ||
__publicField(this, "deviceRepository"); | ||
__publicField(this, "sessionLocalDataCleaner"); | ||
@@ -413,2 +477,8 @@ __publicField(this, "sessionRepository"); | ||
); | ||
const deviceIdDataSource = deviceIdDataSourceImpl(); | ||
this.deviceRepository = deviceRepositoryImpl( | ||
this.apolloClient, | ||
deviceIdDataSource, | ||
this.logger | ||
); | ||
} | ||
@@ -433,2 +503,8 @@ }; | ||
this.coreContainer.patientRepository.setPatientId(patientId); | ||
if (existingPatientId !== patientId) { | ||
this.coreContainer.deviceRepository.sendDeviceInfoAsync( | ||
["Messaging"], | ||
patientId | ||
); | ||
} | ||
}); | ||
@@ -435,0 +511,0 @@ __publicField(this, "clearCurrentUser", async () => { |
@@ -33,2 +33,3 @@ import { UUID } from 'uuidjs'; | ||
lastMessagePreview?: string; | ||
lastMessage?: Message; | ||
lastModified: Date; | ||
@@ -35,0 +36,0 @@ patientUnreadMessageCount: number; |
@@ -5,9 +5,9 @@ { | ||
"license": "MIT", | ||
"version": "1.0.0-alpha01", | ||
"version": "1.0.0-alpha02", | ||
"dependencies": { | ||
"@apollo/client": "^3.7.7", | ||
"@apollo/client": "^3.7.11", | ||
"await-lock": "^2.2.2", | ||
"graphql": "^16.6.0", | ||
"graphql-ws": "^5.11.3", | ||
"uuidjs": "^5.0.0" | ||
"graphql-ws": "^5.12.1", | ||
"uuidjs": "^5.0.1" | ||
}, | ||
@@ -14,0 +14,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
832242
12
2209
1
28
Updated@apollo/client@^3.7.11
Updatedgraphql-ws@^5.12.1
Updateduuidjs@^5.0.1