@prifina/messaging
Advanced tools
Comparing version 0.0.18 to 0.0.19
@@ -8,3 +8,3 @@ 'use strict'; | ||
var getInfo = function getInfo() { | ||
return ["queryUserAddressBook", "mutationCreateMessage", "subscribeMessagingStatus", "subscribeMessagingData", "mutationCreateTestMessage", "queryGetUnreadMessages", "queryGetMessages", "mutationUpdateMessageStatus"]; | ||
return ["queryUserAddressBook", "mutationCreateMessage", "mutationCreateDataMessage", "subscribeMessagingStatus", "subscribeMessagingData", "mutationCreateTestMessage", "mutationCreateTestDataMessage", "queryGetUnreadMessages", "queryGetMessages", "mutationUpdateMessageStatus"]; | ||
}; | ||
@@ -32,4 +32,6 @@ var getFields = function getFields(query) { | ||
var createMessageMutation = "mutation newMessage($input:MessageInput!) {\n createMessage(input: $input) {\n messageId\n chatId\n createdAt \n result\n receiver\n }\n }"; | ||
var createDataMessageMutation = "mutation newMessage($input:MessageInput!) {\n createDataMessage(input: $input) {\n messageId\n chatId\n createdAt \n result\n receiver\n }\n}"; | ||
var updateMessageStatusMutation = "mutation updateMessage($input:DataObjectInput!) {\n updateMessageStatus(input: $input) \n }"; | ||
var subscribeCreateMessage = "subscription MySubscription($receiver: String!) {\n addMessage(receiver: $receiver) {\n messageId\n chatId\n receiver\n result\n }\n }"; | ||
var subscribeCreateMessage = "subscription msgSubscription($receiver: String!) {\n addMessage(receiver: $receiver) {\n messageId\n chatId\n receiver\n result\n }\n }"; | ||
var subscribeCreateDataMessage = "subscription msgSubscription($receiver: String!) {\n addDataMessage(receiver: $receiver) {\n messageId\n chatId\n receiver\n result\n }\n }"; | ||
@@ -406,5 +408,7 @@ function randomID() { | ||
currentCallbacks[appID][0]({ | ||
messagingStatus: { | ||
cnt: unreadMsgs.length, | ||
lastMessage: new Date(msg.createdAt).toISOString() | ||
addMessage: { | ||
result: { | ||
cnt: unreadMsgs.length, | ||
lastMessage: new Date(msg.createdAt).toISOString() | ||
} | ||
} | ||
@@ -432,11 +436,87 @@ }); | ||
}; | ||
var subscribeMessagingStatus = function subscribeMessagingStatus(_ref7) { | ||
var mutationCreateDataMessage = function mutationCreateDataMessage(_ref7) { | ||
var stage = _ref7.stage, | ||
appID = _ref7.appID, | ||
name = _ref7.name, | ||
createSubscription = _ref7.createSubscription, | ||
variables = _ref7.variables, | ||
uuid = _ref7.uuid; | ||
createMutation = _ref7.createMutation; | ||
_ref7.callbacks; | ||
var uuid = _ref7.uuid, | ||
variables = _ref7.variables; | ||
if (stage === "dev") { | ||
var msg = { | ||
messageId: randomID(), | ||
body: variables.body, | ||
chatId: variables.chatId, | ||
sender: uuid, | ||
receiver: variables.receiver, | ||
createdAt: new Date().getTime() | ||
}; | ||
return Promise.resolve({ | ||
data: { | ||
createDataMessage: msg | ||
} | ||
}); | ||
} else { | ||
variables.sender = uuid; | ||
return createMutation({ | ||
name: name, | ||
mutation: createDataMessageMutation, | ||
variables: { | ||
content: variables | ||
}, | ||
appId: appID | ||
}); | ||
} | ||
}; | ||
var mutationCreateTestDataMessage = function mutationCreateTestDataMessage(_ref8) { | ||
var stage = _ref8.stage, | ||
appID = _ref8.appID, | ||
name = _ref8.name, | ||
createMutation = _ref8.createMutation, | ||
callbacks = _ref8.callbacks, | ||
uuid = _ref8.uuid, | ||
variables = _ref8.variables; | ||
if (stage === "dev") { | ||
var currentCallbacks = callbacks(); | ||
var msg = { | ||
messageId: randomID(), | ||
body: variables.body, | ||
chatId: variables.chatId, | ||
sender: variables.sender, | ||
receiver: uuid, | ||
createdAt: new Date().getTime() | ||
}; | ||
currentCallbacks[appID][0]({ | ||
addDataMessage: { | ||
result: msg | ||
} | ||
}); | ||
return Promise.resolve({ | ||
data: { | ||
createDataMessage: msg | ||
} | ||
}); | ||
} else { | ||
variables.receiver = uuid; | ||
return createMutation({ | ||
name: name, | ||
mutation: createDataMessageMutation, | ||
variables: { | ||
content: variables | ||
}, | ||
appId: appID | ||
}); | ||
} | ||
}; | ||
var subscribeMessagingStatus = function subscribeMessagingStatus(_ref9) { | ||
var stage = _ref9.stage, | ||
appID = _ref9.appID, | ||
name = _ref9.name, | ||
createSubscription = _ref9.createSubscription, | ||
variables = _ref9.variables, | ||
uuid = _ref9.uuid; | ||
if (stage === "dev") { | ||
var msgStatus = localStorage.getItem("prifinaMessagingStatus"); | ||
@@ -464,15 +544,22 @@ var msgSubs = {}; | ||
}; | ||
var subscribeMessagingData = function subscribeMessagingData(_ref8) { | ||
var stage = _ref8.stage; | ||
_ref8.appID; | ||
_ref8.name; | ||
_ref8.createSubscription; | ||
_ref8.variables; | ||
_ref8.uuid; | ||
var subscribeMessagingData = function subscribeMessagingData(_ref10) { | ||
var stage = _ref10.stage, | ||
appID = _ref10.appID, | ||
name = _ref10.name, | ||
createSubscription = _ref10.createSubscription; | ||
_ref10.variables; | ||
var uuid = _ref10.uuid; | ||
if (stage === "dev") { | ||
localStorage.setItem("prifinaMessagingStatus", false); | ||
return Promise.resolve(true); | ||
} else { | ||
console.log("SUBS "); | ||
return createSubscription({ | ||
name: name, | ||
mutation: subscribeCreateDataMessage, | ||
variables: { | ||
receiver: uuid | ||
}, | ||
appId: appID | ||
}); | ||
} | ||
@@ -484,3 +571,5 @@ }; | ||
exports.getModuleName = getModuleName; | ||
exports.mutationCreateDataMessage = mutationCreateDataMessage; | ||
exports.mutationCreateMessage = mutationCreateMessage; | ||
exports.mutationCreateTestDataMessage = mutationCreateTestDataMessage; | ||
exports.mutationCreateTestMessage = mutationCreateTestMessage; | ||
@@ -487,0 +576,0 @@ exports.mutationUpdateMessageStatus = mutationUpdateMessageStatus; |
@@ -11,5 +11,7 @@ 'use strict'; | ||
mutationCreateMessage: Data$1.mutationCreateMessage, | ||
mutationCreateDataMessage: Data$1.mutationCreateDataMessage, | ||
subscribeMessagingStatus: Data$1.subscribeMessagingStatus, | ||
subscribeMessagingData: Data$1.subscribeMessagingData, | ||
mutationCreateTestMessage: Data$1.mutationCreateTestMessage, | ||
mutationCreateTestDataMessage: Data$1.mutationCreateTestDataMessage, | ||
queryGetUnreadMessages: Data$1.queryGetUnreadMessages, | ||
@@ -16,0 +18,0 @@ queryGetMessages: Data$1.queryGetMessages, |
import { typeof as _typeof } from './_virtual/_rollupPluginBabelHelpers.js'; | ||
var getInfo = function getInfo() { | ||
return ["queryUserAddressBook", "mutationCreateMessage", "subscribeMessagingStatus", "subscribeMessagingData", "mutationCreateTestMessage", "queryGetUnreadMessages", "queryGetMessages", "mutationUpdateMessageStatus"]; | ||
return ["queryUserAddressBook", "mutationCreateMessage", "mutationCreateDataMessage", "subscribeMessagingStatus", "subscribeMessagingData", "mutationCreateTestMessage", "mutationCreateTestDataMessage", "queryGetUnreadMessages", "queryGetMessages", "mutationUpdateMessageStatus"]; | ||
}; | ||
@@ -27,4 +27,6 @@ var getFields = function getFields(query) { | ||
var createMessageMutation = "mutation newMessage($input:MessageInput!) {\n createMessage(input: $input) {\n messageId\n chatId\n createdAt \n result\n receiver\n }\n }"; | ||
var createDataMessageMutation = "mutation newMessage($input:MessageInput!) {\n createDataMessage(input: $input) {\n messageId\n chatId\n createdAt \n result\n receiver\n }\n}"; | ||
var updateMessageStatusMutation = "mutation updateMessage($input:DataObjectInput!) {\n updateMessageStatus(input: $input) \n }"; | ||
var subscribeCreateMessage = "subscription MySubscription($receiver: String!) {\n addMessage(receiver: $receiver) {\n messageId\n chatId\n receiver\n result\n }\n }"; | ||
var subscribeCreateMessage = "subscription msgSubscription($receiver: String!) {\n addMessage(receiver: $receiver) {\n messageId\n chatId\n receiver\n result\n }\n }"; | ||
var subscribeCreateDataMessage = "subscription msgSubscription($receiver: String!) {\n addDataMessage(receiver: $receiver) {\n messageId\n chatId\n receiver\n result\n }\n }"; | ||
@@ -401,5 +403,7 @@ function randomID() { | ||
currentCallbacks[appID][0]({ | ||
messagingStatus: { | ||
cnt: unreadMsgs.length, | ||
lastMessage: new Date(msg.createdAt).toISOString() | ||
addMessage: { | ||
result: { | ||
cnt: unreadMsgs.length, | ||
lastMessage: new Date(msg.createdAt).toISOString() | ||
} | ||
} | ||
@@ -427,11 +431,87 @@ }); | ||
}; | ||
var subscribeMessagingStatus = function subscribeMessagingStatus(_ref7) { | ||
var mutationCreateDataMessage = function mutationCreateDataMessage(_ref7) { | ||
var stage = _ref7.stage, | ||
appID = _ref7.appID, | ||
name = _ref7.name, | ||
createSubscription = _ref7.createSubscription, | ||
variables = _ref7.variables, | ||
uuid = _ref7.uuid; | ||
createMutation = _ref7.createMutation; | ||
_ref7.callbacks; | ||
var uuid = _ref7.uuid, | ||
variables = _ref7.variables; | ||
if (stage === "dev") { | ||
var msg = { | ||
messageId: randomID(), | ||
body: variables.body, | ||
chatId: variables.chatId, | ||
sender: uuid, | ||
receiver: variables.receiver, | ||
createdAt: new Date().getTime() | ||
}; | ||
return Promise.resolve({ | ||
data: { | ||
createDataMessage: msg | ||
} | ||
}); | ||
} else { | ||
variables.sender = uuid; | ||
return createMutation({ | ||
name: name, | ||
mutation: createDataMessageMutation, | ||
variables: { | ||
content: variables | ||
}, | ||
appId: appID | ||
}); | ||
} | ||
}; | ||
var mutationCreateTestDataMessage = function mutationCreateTestDataMessage(_ref8) { | ||
var stage = _ref8.stage, | ||
appID = _ref8.appID, | ||
name = _ref8.name, | ||
createMutation = _ref8.createMutation, | ||
callbacks = _ref8.callbacks, | ||
uuid = _ref8.uuid, | ||
variables = _ref8.variables; | ||
if (stage === "dev") { | ||
var currentCallbacks = callbacks(); | ||
var msg = { | ||
messageId: randomID(), | ||
body: variables.body, | ||
chatId: variables.chatId, | ||
sender: variables.sender, | ||
receiver: uuid, | ||
createdAt: new Date().getTime() | ||
}; | ||
currentCallbacks[appID][0]({ | ||
addDataMessage: { | ||
result: msg | ||
} | ||
}); | ||
return Promise.resolve({ | ||
data: { | ||
createDataMessage: msg | ||
} | ||
}); | ||
} else { | ||
variables.receiver = uuid; | ||
return createMutation({ | ||
name: name, | ||
mutation: createDataMessageMutation, | ||
variables: { | ||
content: variables | ||
}, | ||
appId: appID | ||
}); | ||
} | ||
}; | ||
var subscribeMessagingStatus = function subscribeMessagingStatus(_ref9) { | ||
var stage = _ref9.stage, | ||
appID = _ref9.appID, | ||
name = _ref9.name, | ||
createSubscription = _ref9.createSubscription, | ||
variables = _ref9.variables, | ||
uuid = _ref9.uuid; | ||
if (stage === "dev") { | ||
var msgStatus = localStorage.getItem("prifinaMessagingStatus"); | ||
@@ -459,18 +539,25 @@ var msgSubs = {}; | ||
}; | ||
var subscribeMessagingData = function subscribeMessagingData(_ref8) { | ||
var stage = _ref8.stage; | ||
_ref8.appID; | ||
_ref8.name; | ||
_ref8.createSubscription; | ||
_ref8.variables; | ||
_ref8.uuid; | ||
var subscribeMessagingData = function subscribeMessagingData(_ref10) { | ||
var stage = _ref10.stage, | ||
appID = _ref10.appID, | ||
name = _ref10.name, | ||
createSubscription = _ref10.createSubscription; | ||
_ref10.variables; | ||
var uuid = _ref10.uuid; | ||
if (stage === "dev") { | ||
localStorage.setItem("prifinaMessagingStatus", false); | ||
return Promise.resolve(true); | ||
} else { | ||
console.log("SUBS "); | ||
return createSubscription({ | ||
name: name, | ||
mutation: subscribeCreateDataMessage, | ||
variables: { | ||
receiver: uuid | ||
}, | ||
appId: appID | ||
}); | ||
} | ||
}; | ||
export { getFields, getInfo, getModuleName, mutationCreateMessage, mutationCreateTestMessage, mutationUpdateMessageStatus, queryGetMessages, queryGetUnreadMessages, queryUserAddressBook, subscribeMessagingData, subscribeMessagingStatus }; | ||
export { getFields, getInfo, getModuleName, mutationCreateDataMessage, mutationCreateMessage, mutationCreateTestDataMessage, mutationCreateTestMessage, mutationUpdateMessageStatus, queryGetMessages, queryGetUnreadMessages, queryUserAddressBook, subscribeMessagingData, subscribeMessagingStatus }; |
@@ -1,2 +0,2 @@ | ||
import { getModuleName, getInfo, getFields, queryUserAddressBook, mutationCreateMessage, subscribeMessagingStatus, subscribeMessagingData, mutationCreateTestMessage, queryGetUnreadMessages, queryGetMessages, mutationUpdateMessageStatus } from './Data.js'; | ||
import { getModuleName, getInfo, getFields, queryUserAddressBook, mutationCreateMessage, mutationCreateDataMessage, subscribeMessagingStatus, subscribeMessagingData, mutationCreateTestMessage, mutationCreateTestDataMessage, queryGetUnreadMessages, queryGetMessages, mutationUpdateMessageStatus } from './Data.js'; | ||
@@ -9,5 +9,7 @@ var Data = { | ||
mutationCreateMessage: mutationCreateMessage, | ||
mutationCreateDataMessage: mutationCreateDataMessage, | ||
subscribeMessagingStatus: subscribeMessagingStatus, | ||
subscribeMessagingData: subscribeMessagingData, | ||
mutationCreateTestMessage: mutationCreateTestMessage, | ||
mutationCreateTestDataMessage: mutationCreateTestDataMessage, | ||
queryGetUnreadMessages: queryGetUnreadMessages, | ||
@@ -14,0 +16,0 @@ queryGetMessages: queryGetMessages, |
{ | ||
"name": "@prifina/messaging", | ||
"version": "0.0.18", | ||
"version": "0.0.19", | ||
"description": "Prifina Messaging Component", | ||
@@ -58,3 +58,3 @@ "author": "Tero <tero@prifina.com>", | ||
}, | ||
"gitHead": "727275a67435e2dc2af71b508728fea9294a648e" | ||
"gitHead": "7539e0504a1b9969a924add519df717912caab5f" | ||
} |
113
src/Data.js
@@ -5,5 +5,7 @@ export const getInfo = () => { | ||
"mutationCreateMessage", | ||
"mutationCreateDataMessage", | ||
"subscribeMessagingStatus", | ||
"subscribeMessagingData", | ||
"mutationCreateTestMessage", | ||
"mutationCreateTestDataMessage", | ||
"queryGetUnreadMessages", | ||
@@ -58,2 +60,12 @@ "queryGetMessages", | ||
const createDataMessageMutation = `mutation newMessage($input:MessageInput!) { | ||
createDataMessage(input: $input) { | ||
messageId | ||
chatId | ||
createdAt | ||
result | ||
receiver | ||
} | ||
}`; | ||
const updateMessageStatusMutation = `mutation updateMessage($input:DataObjectInput!) { | ||
@@ -63,3 +75,3 @@ updateMessageStatus(input: $input) | ||
const subscribeCreateMessage = `subscription MySubscription($receiver: String!) { | ||
const subscribeCreateMessage = `subscription msgSubscription($receiver: String!) { | ||
addMessage(receiver: $receiver) { | ||
@@ -72,2 +84,11 @@ messageId | ||
}`; | ||
const subscribeCreateDataMessage = `subscription msgSubscription($receiver: String!) { | ||
addDataMessage(receiver: $receiver) { | ||
messageId | ||
chatId | ||
receiver | ||
result | ||
} | ||
}`; | ||
function randomID() { | ||
@@ -419,5 +440,7 @@ let chars = "qwertyuiopasdfghjklzxcvbnm"; | ||
currentCallbacks[appID][0]({ | ||
messagingStatus: { | ||
cnt: unreadMsgs.length, | ||
lastMessage: new Date(msg.createdAt).toISOString(), | ||
addMessage: { | ||
result: { | ||
cnt: unreadMsgs.length, | ||
lastMessage: new Date(msg.createdAt).toISOString(), | ||
}, | ||
}, | ||
@@ -444,2 +467,77 @@ }); | ||
export const mutationCreateDataMessage = ({ | ||
stage, | ||
appID, | ||
name, | ||
createMutation, | ||
callbacks, | ||
uuid, | ||
variables, | ||
}) => { | ||
if (stage === "dev") { | ||
const msg = { | ||
messageId: randomID(), | ||
body: variables.body, | ||
chatId: variables.chatId, | ||
sender: uuid, | ||
receiver: variables.receiver, | ||
createdAt: new Date().getTime(), | ||
}; | ||
return Promise.resolve({ | ||
data: { | ||
createDataMessage: msg, | ||
}, | ||
}); | ||
} else { | ||
variables.sender = uuid; | ||
return createMutation({ | ||
name: name, | ||
mutation: createDataMessageMutation, | ||
variables: { content: variables }, | ||
appId: appID, | ||
}); | ||
} | ||
}; | ||
export const mutationCreateTestDataMessage = ({ | ||
stage, | ||
appID, | ||
name, | ||
createMutation, | ||
callbacks, | ||
uuid, | ||
variables, | ||
}) => { | ||
if (stage === "dev") { | ||
const currentCallbacks = callbacks(); | ||
const msg = { | ||
messageId: randomID(), | ||
body: variables.body, | ||
chatId: variables.chatId, | ||
sender: variables.sender, | ||
receiver: uuid, | ||
createdAt: new Date().getTime(), | ||
}; | ||
currentCallbacks[appID][0]({ | ||
addDataMessage: { result: msg }, | ||
}); | ||
return Promise.resolve({ | ||
data: { | ||
createDataMessage: msg, | ||
}, | ||
}); | ||
} else { | ||
variables.receiver = uuid; | ||
return createMutation({ | ||
name: name, | ||
mutation: createDataMessageMutation, | ||
variables: { content: variables }, | ||
appId: appID, | ||
}); | ||
} | ||
}; | ||
export const subscribeMessagingStatus = ({ | ||
@@ -482,7 +580,12 @@ stage, | ||
if (stage === "dev") { | ||
localStorage.setItem("prifinaMessagingStatus", false); | ||
return Promise.resolve(true); | ||
} else { | ||
console.log("SUBS "); | ||
return createSubscription({ | ||
name: name, | ||
mutation: subscribeCreateDataMessage, | ||
variables: { receiver: uuid }, | ||
appId: appID, | ||
}); | ||
} | ||
}; |
@@ -7,5 +7,7 @@ import { | ||
mutationCreateMessage, | ||
mutationCreateDataMessage, | ||
subscribeMessagingStatus, | ||
subscribeMessagingData, | ||
mutationCreateTestMessage, | ||
mutationCreateTestDataMessage, | ||
queryGetUnreadMessages, | ||
@@ -15,2 +17,3 @@ queryGetMessages, | ||
} from "./Data"; | ||
const Data = { | ||
@@ -22,5 +25,7 @@ getModuleName, | ||
mutationCreateMessage, | ||
mutationCreateDataMessage, | ||
subscribeMessagingStatus, | ||
subscribeMessagingData, | ||
mutationCreateTestMessage, | ||
mutationCreateTestDataMessage, | ||
queryGetUnreadMessages, | ||
@@ -27,0 +32,0 @@ queryGetMessages, |
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
52279
1671