You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{DeepClient,SerialOperation,Table,}from'@deep-foundation/deeplinks/imports/client';import{Link}from'@deep-foundation/deeplinks/imports/minilinks';async({
deep,data: {newLink: notifyLink, triggeredByLinkId },}: {deep: DeepClient;data: {newLink: Link<number>,triggeredByLinkId: number};})=>{constfirebaseAdmin=awaitimport('firebase-admin');constutil=awaitimport('util');const{ createSerialOperation }=awaitimport('@deep-foundation/deeplinks/imports/gql/index')constlogs: Array<any>=[];constDEFAULT_LOG_DEPTH=3;asyncfunctionmain(){constlog=getNamespacedLogger({namespace: main.name});constnotificationLinkId=notifyLink.from_id!;log({ notificationLinkId })const{data: [notificationLink]}=awaitdeep.select(notificationLinkId)log({ notificationLink })if(!notificationLink.value?.value){thrownewError(`##${notificationLinkId} must have value`)}consttitle=notificationLink.value.value.title;log({ title })if(!title){thrownewError(`Object value of ##${notificationLinkId} must have title property`)}constbody=notificationLink.value.value.body;log({ body })if(!body){thrownewError(`Object value of ##${notificationLinkId} must have body property`)}constdeviceLinkId=notifyLink.to_id;log({ deviceLinkId })constcontainTypeLinkId=awaitdeep.id('@deep-foundation/core','Contain');log({ containTypeLinkId })constserviceAccount=awaitgetServiceAccount({
containTypeLinkId,
triggeredByLinkId,});log({ serviceAccount })constfirebaseApplication=awaitgetFirebaseApplication({
firebaseAdmin,
serviceAccount,});log({ firebaseApplication })constdeviceRegistrationToken=awaitgetDeviceRegistrationToken({
containTypeLinkId,
deviceLinkId,});log({ deviceRegistrationToken })constpushNotificationData={token: deviceRegistrationToken,notification: {title: title,body: body,},};log({ pushNotificationData })awaitfirebaseAdmin.messaging(firebaseApplication).send(pushNotificationData);awaitdeep.insert({type_id: awaitdeep.id(deep.linkId!,'Notified'),in: {data: {type_id: containTypeLinkId,from_id: triggeredByLinkId,},},from_id: notifyLink.id,to_id: deviceLinkId,});firebaseApplication.delete();}asyncfunctiongetServiceAccount({ containTypeLinkId, triggeredByLinkId }){constlog=getNamespacedLogger({namespace: getServiceAccount.name});constserviceAccountTypeLinkId=awaitdeep.id(deep.linkId!,'ServiceAccount');log({ serviceAccountTypeLinkId })constusesServiceAccountTypeLinkId=awaitdeep.id(deep.linkId!,'UsesServiceAccount');log({ usesServiceAccountTypeLinkId })constselectData={_or: [{type_id: serviceAccountTypeLinkId,in: {type_id: containTypeLinkId,from_id: triggeredByLinkId,},},{type_id: usesServiceAccountTypeLinkId,from_id: triggeredByLinkId,},],};const{ data }=awaitdeep.select(selectData);log({ data })if(data.length===0){thrownewError(`Select with data ${JSON.stringify(selectData)} returned empty result`);}letserviceAccountLink;constusesServiceAccountLinks=data.filter((link)=>link.type_id===usesServiceAccountTypeLinkId);if(usesServiceAccountLinks.length>1){thrownewError(`There must be only one link of type ${usesServiceAccountTypeLinkId} and from ${triggeredByLinkId}, instead there are ${usesServiceAccountLinks.map((link)=>`##${link.id}`).join(', ')}`);}elseif(usesServiceAccountLinks.length===1){constusesServiceAccountLink=usesServiceAccountLinks[0];serviceAccountLink=data.find((link)=>link.id===usesServiceAccountLink.to_id);}elseif(usesServiceAccountLinks.length===0){constserviceAccountLinks=data.filter((link)=>link.type_id===serviceAccountTypeLinkId);if(serviceAccountLinks.length>1){thrownewError(`There must be only one link of type ##${serviceAccountTypeLinkId} and contained by ##${triggeredByLinkId}, instead there are ${serviceAccountLinks.map((link)=>`##${link.id}`).join(', ')}`);}elseif(serviceAccountLinks.length===1){serviceAccountLink=serviceAccountLinks[0];}elseif(serviceAccountLinks.length===0){thrownewError(`A link of type ##${serviceAccountTypeLinkId} and contained by ##${triggeredByLinkId} is not found`);}}log({ serviceAccountLink })if(!serviceAccountLink){thrownewError(`A link of type ##${usesServiceAccountTypeLinkId} and from ##${triggeredByLinkId} is not found`);}if(!serviceAccountLink.value?.value){thrownewError(`##${serviceAccountLink.id} must have value`);}constresult=serviceAccountLink.value.value;log({ result })returnresult;}asyncfunctiongetDeviceRegistrationToken({
containTypeLinkId,
deviceLinkId,}){constlog=getNamespacedLogger({namespace: getDeviceRegistrationToken.name});constdeviceRegistrationTokenTypeLinkId=awaitdeep.id(deep.linkId!,'DeviceRegistrationToken');log({ deviceRegistrationTokenTypeLinkId })constselectData={type_id: deviceRegistrationTokenTypeLinkId,in: {type_id: containTypeLinkId,from_id: deviceLinkId,},};log({ selectData })const{data: [deviceRegistrationTokenLink],}=awaitdeep.select(selectData);if(!deviceRegistrationTokenLink){thrownewError(`##${deviceLinkId} must have contained a link of type ##${deviceRegistrationTokenTypeLinkId}. Select with data ${JSON.stringify(selectData)} returned empty result`);}log({ deviceRegistrationTokenLink })if(!deviceRegistrationTokenLink.value?.value){thrownewError(`##${deviceRegistrationTokenLink.id} must have value`);}constresult=deviceRegistrationTokenLink.value.value;log({ result })returnresult;}asyncfunctiongetFirebaseApplication({ firebaseAdmin, serviceAccount }){firebaseAdmin.apps.forEach((app)=>app.delete());returnfirebaseAdmin.initializeApp({credential: firebaseAdmin.credential.cert(serviceAccount),})}functiongetNamespacedLogger({
namespace,
depth =DEFAULT_LOG_DEPTH,}: {namespace: string;depth?: number;}){returnfunction(content: any){constmessage=util.inspect(content,{ depth });logs.push(`${namespace}: ${message}`);};}};
Dist code transpiled by @deep-foundation/tsx package
async({ deep,data: {newLink: notifyLink, triggeredByLinkId },})=>{constfirebaseAdmin=awaitimport('firebase-admin');constutil=awaitimport('util');const{ createSerialOperation }=awaitimport('@deep-foundation/deeplinks/imports/gql/index');constlogs=[];constDEFAULT_LOG_DEPTH=3;asyncfunctionmain(){constlog=getNamespacedLogger({namespace: main.name});constnotificationLinkId=notifyLink.from_id;log({ notificationLinkId });const{data: [notificationLink]}=awaitdeep.select(notificationLinkId);log({ notificationLink });if(!notificationLink.value?.value){thrownewError(`##${notificationLinkId} must have value`);}consttitle=notificationLink.value.value.title;log({ title });if(!title){thrownewError(`Object value of ##${notificationLinkId} must have title property`);}constbody=notificationLink.value.value.body;log({ body });if(!body){thrownewError(`Object value of ##${notificationLinkId} must have body property`);}constdeviceLinkId=notifyLink.to_id;log({ deviceLinkId });constcontainTypeLinkId=awaitdeep.id('@deep-foundation/core','Contain');log({ containTypeLinkId });constserviceAccount=awaitgetServiceAccount({
containTypeLinkId,
triggeredByLinkId,});log({ serviceAccount });constfirebaseApplication=awaitgetFirebaseApplication({
firebaseAdmin,
serviceAccount,});log({ firebaseApplication });constdeviceRegistrationToken=awaitgetDeviceRegistrationToken({
containTypeLinkId,
deviceLinkId,});log({ deviceRegistrationToken });constpushNotificationData={token: deviceRegistrationToken,notification: {title: title,body: body,},};log({ pushNotificationData });awaitfirebaseAdmin.messaging(firebaseApplication).send(pushNotificationData);awaitdeep.insert({type_id: awaitdeep.id(deep.linkId,'Notified'),in: {data: {type_id: containTypeLinkId,from_id: triggeredByLinkId,},},from_id: notifyLink.id,to_id: deviceLinkId,});firebaseApplication.delete();}asyncfunctiongetServiceAccount({ containTypeLinkId, triggeredByLinkId }){constlog=getNamespacedLogger({namespace: getServiceAccount.name});constserviceAccountTypeLinkId=awaitdeep.id(deep.linkId,'ServiceAccount');log({ serviceAccountTypeLinkId });constusesServiceAccountTypeLinkId=awaitdeep.id(deep.linkId,'UsesServiceAccount');log({ usesServiceAccountTypeLinkId });constselectData={_or: [{type_id: serviceAccountTypeLinkId,in: {type_id: containTypeLinkId,from_id: triggeredByLinkId,},},{type_id: usesServiceAccountTypeLinkId,from_id: triggeredByLinkId,},],};const{ data }=awaitdeep.select(selectData);log({ data });if(data.length===0){thrownewError(`Select with data ${JSON.stringify(selectData)} returned empty result`);}letserviceAccountLink;constusesServiceAccountLinks=data.filter((link)=>link.type_id===usesServiceAccountTypeLinkId);if(usesServiceAccountLinks.length>1){thrownewError(`There must be only one link of type ${usesServiceAccountTypeLinkId} and from ${triggeredByLinkId}, instead there are ${usesServiceAccountLinks.map((link)=>`##${link.id}`).join(', ')}`);}elseif(usesServiceAccountLinks.length===1){constusesServiceAccountLink=usesServiceAccountLinks[0];serviceAccountLink=data.find((link)=>link.id===usesServiceAccountLink.to_id);}elseif(usesServiceAccountLinks.length===0){constserviceAccountLinks=data.filter((link)=>link.type_id===serviceAccountTypeLinkId);if(serviceAccountLinks.length>1){thrownewError(`There must be only one link of type ##${serviceAccountTypeLinkId} and contained by ##${triggeredByLinkId}, instead there are ${serviceAccountLinks.map((link)=>`##${link.id}`).join(', ')}`);}elseif(serviceAccountLinks.length===1){serviceAccountLink=serviceAccountLinks[0];}elseif(serviceAccountLinks.length===0){thrownewError(`A link of type ##${serviceAccountTypeLinkId} and contained by ##${triggeredByLinkId} is not found`);}}log({ serviceAccountLink });if(!serviceAccountLink){thrownewError(`A link of type ##${usesServiceAccountTypeLinkId} and from ##${triggeredByLinkId} is not found`);}if(!serviceAccountLink.value?.value){thrownewError(`##${serviceAccountLink.id} must have value`);}constresult=serviceAccountLink.value.value;log({ result });returnresult;}asyncfunctiongetDeviceRegistrationToken({ containTypeLinkId, deviceLinkId,}){constlog=getNamespacedLogger({namespace: getDeviceRegistrationToken.name});constdeviceRegistrationTokenTypeLinkId=awaitdeep.id(deep.linkId,'DeviceRegistrationToken');log({ deviceRegistrationTokenTypeLinkId });constselectData={type_id: deviceRegistrationTokenTypeLinkId,in: {type_id: containTypeLinkId,from_id: deviceLinkId,},};log({ selectData });const{data: [deviceRegistrationTokenLink],}=awaitdeep.select(selectData);if(!deviceRegistrationTokenLink){thrownewError(`##${deviceLinkId} must have contained a link of type ##${deviceRegistrationTokenTypeLinkId}. Select with data ${JSON.stringify(selectData)} returned empty result`);}log({ deviceRegistrationTokenLink });if(!deviceRegistrationTokenLink.value?.value){thrownewError(`##${deviceRegistrationTokenLink.id} must have value`);}constresult=deviceRegistrationTokenLink.value.value;log({ result });returnresult;}asyncfunctiongetFirebaseApplication({ firebaseAdmin, serviceAccount }){firebaseAdmin.apps.forEach((app)=>app.delete());returnfirebaseAdmin.initializeApp({credential: firebaseAdmin.credential.cert(serviceAccount),});}functiongetNamespacedLogger({ namespace, depth =DEFAULT_LOG_DEPTH,}){returnfunction(content){constmessage=util.inspect(content,{ depth });logs.push(`${namespace}: ${message}`);};}};export{};//# sourceMappingURL=module.js.map
Question
Is this the problem of js-docker-isolation-provider or @deep-foundation/tsx package? What should we do? The scariest thing is that I have been using handler code transpiled by that version of tsx package and everything was working. I do not know what is changed the way to brake it
Error
Unexpected token 'export'
Source Code
Dist code transpiled by
@deep-foundation/tsx
packageQuestion
Is this the problem of
js-docker-isolation-provider
or@deep-foundation/tsx
package? What should we do? The scariest thing is that I have been using handler code transpiled by that version of tsx package and everything was working. I do not know what is changed the way to brake itForked from deep-foundation/js-docker-isolation-provider#15 by https://github.com/konard/gh-org-migrator
The text was updated successfully, but these errors were encountered: