repo_name
string
dataset
string
owner
string
lang
string
func_name
string
code
string
docstring
string
url
string
sha
string
Panora
github_2023
panoratech
typescript
MappersRegistry.registerService
registerService( category_vertical: string, common_object: string, provider_name: string, service: any, ) { const compositeKey = this.createCompositeKey( category_vertical.toLowerCase().trim(), common_object.toLowerCase().trim(), provider_name.toLowerCase().trim(), ); thi...
// Register a service with a composite key
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/@core/@core-services/registries/mappers.registry.ts#L12-L24
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
MappersRegistry.getService
getService( category_vertical: string, common_object: string, provider_name: string, ): any { const compositeKey = this.createCompositeKey( category_vertical.toLowerCase().trim(), common_object.toLowerCase().trim(), provider_name.toLowerCase().trim(), ); const service = this....
// Retrieve a service using the composite key
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/@core/@core-services/registries/mappers.registry.ts#L27-L44
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
MappersRegistry.createCompositeKey
private createCompositeKey( category_vertical: string, common_object: string, provider_name: string, ): string { return `${category_vertical}_${common_object}_${provider_name}`; }
// Utility method to create a consistent key from three strings
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/@core/@core-services/registries/mappers.registry.ts#L47-L53
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
CoreUnification.unify
async unify<T extends UnifySourceType | UnifySourceType[]>({ sourceObject, targetType, providerName, vertical, connectionId, customFieldMappings, extraParams, }: { sourceObject: T; targetType: TargetObject; providerName: string; vertical: string; connectionId: string; /...
/* to fetch data 3rdParties > [Panora] > SaaS */
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/@core/@core-services/unification/core-unification.service.ts#L23-L115
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
CoreUnification.desunify
async desunify<T extends Unified>({ sourceObject, targetType, providerName, vertical, customFieldMappings, connectionId, }: { sourceObject: T; targetType: TargetObject; providerName: string; vertical: string; customFieldMappings?: { slug: string; remote_id: stri...
/* to insert data SaaS > [Panora] > 3rdParties */
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/@core/@core-services/unification/core-unification.service.ts#L123-L206
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
AuthService.generateApiKey
async generateApiKey( projectId: number | string, userId: number | string, ): Promise<{ access_token: string }> { try { const jwtPayload = { sub: userId, project_id: projectId, }; return { access_token: this.jwtService.sign(jwtPayload, { secret: process....
//must be called only if user is logged in
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/@core/auth/auth.service.ts#L317-L335
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
ConnectionsStrategiesService.getConnectionStrategyData
async getConnectionStrategyData( projectId: string, type: string, attributes: string[], ) { const cs = await this.prisma.connection_strategies.findFirst({ where: { id_project: projectId, type: type, }, }); if (!cs) throw new ReferenceError('Connection strategy undef...
// [client_id, client_secret] or [client_id, client_secret, subdomain] or [api_key]
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/@core/connections-strategies/connections-strategies.service.ts#L146-L188
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
AccountingConnectionsService.handleCallBack
async handleCallBack( providerName: string, callbackOpts: CallbackParams, type_strategy: 'oauth2' | 'apikey' | 'basic', ) { try { const serviceName = providerName.toLowerCase(); const service = this.serviceRegistry.getService(serviceName); if (!service) { throw new Referenc...
// this call pass 1. integrationID 2. CustomerId 3. Panora Api Key
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/@core/connections/accounting/services/accounting.connection.service.ts#L43-L82
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
AcceloConnectionService.handleTokenRefresh
async handleTokenRefresh(opts: RefreshParams) { try { const { connectionId, refreshToken, projectId } = opts; const formData = new URLSearchParams({ grant_type: 'refresh_token', refresh_token: this.cryptoService.decrypt(refreshToken), }); //const subdomain = 'panora'; //TODO:...
// It is not required for Accelo as it does not provide refresh_token
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/@core/connections/crm/services/accelo/accelo.service.ts#L193-L235
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
WealthboxConnectionService.passthrough
async passthrough( input: PassthroughInput, connectionId: string, ): Promise<PassthroughResponse> { try { const { headers } = input; const config = await this.constructPassthrough(input, connectionId); const connection = await this.prisma.connections.findUnique({ where: { ...
// todo
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/@core/connections/crm/services/wealthbox/wealthbox.service.ts#L56-L92
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
EcommerceConnectionsService.handleCallBack
async handleCallBack( providerName: string, callbackOpts: CallbackParams, type_strategy: 'oauth2' | 'apikey' | 'basic', ) { try { const serviceName = providerName.toLowerCase(); const service = this.serviceRegistry.getService(serviceName); if (!service) { throw new Referenc...
// this call pass 1. integrationID 2. CustomerId 3. Panora Api Key
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/@core/connections/ecommerce/services/ecommerce.connection.service.ts#L43-L82
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
FilestorageConnectionsService.handleCallBack
async handleCallBack( providerName: string, callbackOpts: CallbackParams, type_strategy: 'oauth2' | 'apikey' | 'basic', ) { try { const serviceName = providerName.toLowerCase(); const service = this.serviceRegistry.getService(serviceName); if (!service) { throw new Referenc...
// this call pass 1. integrationID 2. CustomerId 3. Panora Api Key
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/@core/connections/filestorage/services/filestorage.connection.service.ts#L44-L83
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
MarketingAutomationConnectionsService.handleCallBack
async handleCallBack( providerName: string, callbackOpts: CallbackParams, type_strategy: 'oauth2' | 'apikey' | 'basic', ) { try { const serviceName = providerName.toLowerCase(); const service = this.serviceRegistry.getService(serviceName); if (!service) { throw new Referenc...
// this call pass 1. integrationID 2. CustomerId 3. Panora Api Key
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/@core/connections/marketingautomation/services/marketingautomation.connection.service.ts#L48-L87
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
ProductivityConnectionsService.handleCallBack
async handleCallBack( providerName: string, callbackOpts: CallbackParams, type_strategy: 'oauth2' | 'apikey' | 'basic', ) { try { const serviceName = providerName.toLowerCase(); const service = this.serviceRegistry.getService(serviceName); if (!service) { throw new Referenc...
// this call pass 1. integrationID 2. CustomerId 3. Panora Api Key
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/@core/connections/productivity/services/productivity.connection.service.ts#L43-L82
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
TicketingConnectionsService.handleCallBack
async handleCallBack( providerName: string, callbackOpts: CallbackParams, type_strategy: 'oauth2' | 'apikey' | 'basic', ) { try { const serviceName = providerName.toLowerCase(); const service = this.serviceRegistry.getService(serviceName); if (!service) { throw new Referenc...
// this call pass 1. integrationID 2. CustomerId 3. Panora Api Key
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/@core/connections/ticketing/services/ticketing.connection.service.ts#L44-L83
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
GithubConnectionService.handleTokenRefresh
async handleTokenRefresh(opts: RefreshParams) { return; }
//TODO
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/@core/connections/ticketing/services/github/github.service.ts#L178-L180
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
ProjectConnectorsService.updateProjectConnectors
async updateProjectConnectors( column: string, status: boolean, id_project: string, ) { try { const project = await this.prisma.projects.findFirst({ where: { id_project: id_project, }, }); if (!project) { throw new ReferenceError('Project undefined!...
// it would be used when a new connector is built and needs to be insert inside our tbale
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/@core/project-connectors/project-connectors.service.ts#L13-L54
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
ProjectConnectorsService.getConnectorsByProjectId
async getConnectorsByProjectId(id_project: string) { try { const project = await this.prisma.projects.findFirst({ where: { id_project, }, }); if (!project) { throw new ReferenceError('Project undefined!'); } const res = await this.prisma.connector_se...
/*async createProjectConnectors(data: TypeCustom) { try { const updateData: any = { id_connector_set: uuidv4(), crm_hubspot: data.crm_hubspot, crm_zoho: data.crm_zoho, crm_zendesk: data.crm_zendesk, crm_pipedrive: data.crm_pipedrive, crm_attio: data.crm_attio, ...
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/@core/project-connectors/project-connectors.service.ts#L83-L107
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
CoreSyncService.initialSync
async initialSync(vertical: string, provider: string, linkedUserId: string) { try { switch (vertical) { case ConnectorCategory.Crm: await this.handleCrmSync(provider, linkedUserId); break; case ConnectorCategory.Ticketing: await this.handleTicketingSync(provider, ...
//Initial sync which will execute when connection is successfully established
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/@core/sync/sync.service.ts#L199-L224
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
CoreSyncService.handleAccountingSync
async handleAccountingSync(provider: string, linkedUserId: string) { return; }
// todo
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/@core/sync/sync.service.ts#L227-L229
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
CoreSyncService.getSyncStatus
async getSyncStatus(vertical: string) { try { } catch (error) { throw error; } }
// we must have a sync_jobs table with 7 (verticals) rows, one of each is syncing details
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/@core/sync/sync.service.ts#L548-L553
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
SyncService.kickstartSync
async kickstartSync(id_project?: string) { try { const linkedUsers = await this.prisma.linked_users.findMany({ where: { id_project: id_project, }, }); linkedUsers.map(async (linkedUser) => { try { const providers = ACCOUNTING_PROVIDERS; for (co...
// every 8 hours
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/accounting/account/sync/sync.service.ts#L40-L67
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
SyncService.kickstartSync
async kickstartSync(id_project?: string) { try { const linkedUsers = await this.prisma.linked_users.findMany({ where: { id_project: id_project, }, }); linkedUsers.map(async (linkedUser) => { try { const providers = ACCOUNTING_PROVIDERS; for (co...
// every 8 hours
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/accounting/address/sync/sync.service.ts#L40-L67
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
SyncService.kickstartSync
async kickstartSync(id_project?: string) { try { const linkedUsers = await this.prisma.linked_users.findMany({ where: { id_project: id_project, }, }); linkedUsers.map(async (linkedUser) => { try { const providers = ACCOUNTING_PROVIDERS; for (co...
// every 8 hours
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/accounting/attachment/sync/sync.service.ts#L40-L67
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
SyncService.kickstartSync
async kickstartSync(id_project?: string) { try { const linkedUsers = await this.prisma.linked_users.findMany({ where: { id_project: id_project, }, }); linkedUsers.map(async (linkedUser) => { try { const providers = ACCOUNTING_PROVIDERS; for (co...
// every 8 hours
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/accounting/balancesheet/sync/sync.service.ts#L41-L68
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
SyncService.kickstartSync
async kickstartSync(id_project?: string) { try { const linkedUsers = await this.prisma.linked_users.findMany({ where: { id_project: id_project, }, }); linkedUsers.map(async (linkedUser) => { try { const providers = ACCOUNTING_PROVIDERS; for (co...
// every 8 hours
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/accounting/cashflowstatement/sync/sync.service.ts#L43-L70
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
SyncService.kickstartSync
async kickstartSync(id_project?: string) { try { const linkedUsers = await this.prisma.linked_users.findMany({ where: { id_project: id_project, }, }); linkedUsers.map(async (linkedUser) => { try { const providers = ACCOUNTING_PROVIDERS; for (co...
// every 8 hours
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/accounting/companyinfo/sync/sync.service.ts#L40-L67
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
SyncService.kickstartSync
async kickstartSync(id_project?: string) { try { const linkedUsers = await this.prisma.linked_users.findMany({ where: { id_project: id_project, }, }); linkedUsers.map(async (linkedUser) => { try { const providers = ACCOUNTING_PROVIDERS; for (co...
// every 8 hours
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/accounting/contact/sync/sync.service.ts#L40-L67
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
SyncService.kickstartSync
async kickstartSync(id_project?: string) { try { const linkedUsers = await this.prisma.linked_users.findMany({ where: { id_project: id_project, }, }); linkedUsers.map(async (linkedUser) => { try { const providers = ACCOUNTING_PROVIDERS; for (co...
// every 8 hours
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/accounting/creditnote/sync/sync.service.ts#L40-L67
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
SyncService.kickstartSync
async kickstartSync(id_project?: string) { try { const linkedUsers = await this.prisma.linked_users.findMany({ where: { id_project: id_project, }, }); linkedUsers.map(async (linkedUser) => { try { const providers = ACCOUNTING_PROVIDERS; for (co...
// every 8 hours
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/accounting/expense/sync/sync.service.ts#L43-L70
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
SyncService.kickstartSync
async kickstartSync(id_project?: string) { try { const linkedUsers = await this.prisma.linked_users.findMany({ where: { id_project: id_project, }, }); linkedUsers.map(async (linkedUser) => { try { const providers = ACCOUNTING_PROVIDERS; for (co...
// every 8 hours
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/accounting/incomestatement/sync/sync.service.ts#L40-L67
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
SyncService.kickstartSync
async kickstartSync(id_project?: string) { try { const linkedUsers = await this.prisma.linked_users.findMany({ where: { id_project: id_project, }, }); linkedUsers.map(async (linkedUser) => { try { const providers = ACCOUNTING_PROVIDERS; for (co...
// every 8 hours
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/accounting/invoice/sync/sync.service.ts#L43-L70
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
SyncService.kickstartSync
async kickstartSync(id_project?: string) { try { const linkedUsers = await this.prisma.linked_users.findMany({ where: { id_project: id_project, }, }); linkedUsers.map(async (linkedUser) => { try { const providers = ACCOUNTING_PROVIDERS; for (co...
// every 8 hours
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/accounting/item/sync/sync.service.ts#L40-L67
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
SyncService.kickstartSync
async kickstartSync(id_project?: string) { try { const linkedUsers = await this.prisma.linked_users.findMany({ where: { id_project: id_project, }, }); linkedUsers.map(async (linkedUser) => { try { const providers = ACCOUNTING_PROVIDERS; for (co...
// every 8 hours
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/accounting/journalentry/sync/sync.service.ts#L43-L70
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
SyncService.kickstartSync
async kickstartSync(id_project?: string) { try { const linkedUsers = await this.prisma.linked_users.findMany({ where: { id_project: id_project, }, }); linkedUsers.map(async (linkedUser) => { try { const providers = ACCOUNTING_PROVIDERS; for (co...
// every 8 hours
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/accounting/payment/sync/sync.service.ts#L43-L70
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
SyncService.kickstartSync
async kickstartSync(id_project?: string) { try { const linkedUsers = await this.prisma.linked_users.findMany({ where: { id_project: id_project, }, }); linkedUsers.map(async (linkedUser) => { try { const providers = ACCOUNTING_PROVIDERS; for (co...
// every 8 hours
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/accounting/phonenumber/sync/sync.service.ts#L40-L67
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
SyncService.kickstartSync
async kickstartSync(id_project?: string) { try { const linkedUsers = await this.prisma.linked_users.findMany({ where: { id_project: id_project, }, }); linkedUsers.map(async (linkedUser) => { try { const providers = ACCOUNTING_PROVIDERS; for (co...
// every 8 hours
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/accounting/purchaseorder/sync/sync.service.ts#L43-L70
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
SyncService.kickstartSync
async kickstartSync(id_project?: string) { try { const linkedUsers = await this.prisma.linked_users.findMany({ where: { id_project: id_project, }, }); linkedUsers.map(async (linkedUser) => { try { const providers = ACCOUNTING_PROVIDERS; for (co...
// every 8 hours
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/accounting/taxrate/sync/sync.service.ts#L40-L67
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
SyncService.kickstartSync
async kickstartSync(id_project?: string) { try { const linkedUsers = await this.prisma.linked_users.findMany({ where: { id_project: id_project, }, }); linkedUsers.map(async (linkedUser) => { try { const providers = ACCOUNTING_PROVIDERS; for (co...
// every 8 hours
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/accounting/trackingcategory/sync/sync.service.ts#L40-L67
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
SyncService.kickstartSync
async kickstartSync(id_project?: string) { try { const linkedUsers = await this.prisma.linked_users.findMany({ where: { id_project: id_project, }, }); linkedUsers.map(async (linkedUser) => { try { const providers = ACCOUNTING_PROVIDERS; for (co...
// every 8 hours
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/accounting/transaction/sync/sync.service.ts#L43-L70
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
SyncService.kickstartSync
async kickstartSync(id_project?: string) { try { const linkedUsers = await this.prisma.linked_users.findMany({ where: { id_project: id_project, }, }); linkedUsers.map(async (linkedUser) => { try { const providers = ACCOUNTING_PROVIDERS; for (co...
// every 8 hours
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/accounting/vendorcredit/sync/sync.service.ts#L43-L70
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
Utils.mapTaskPriority
mapTaskPriority(priority?: string): 'HIGH' | 'MEDIUM' | 'LOW' { return priority === 'High' ? 'HIGH' : priority === 'Medium' ? 'MEDIUM' : 'LOW'; }
// not currently in use, but might be in the future
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/crm/@lib/@utils/index.ts#L326-L332
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
SyncService.kickstartSync
async kickstartSync(id_project?: string) { try { const linkedUsers = await this.prisma.linked_users.findMany({ where: { id_project: id_project, }, }); linkedUsers.map(async (linkedUser) => { try { const providers = CRM_PROVIDERS; for (const pro...
// every 8 hours
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/crm/company/sync/sync.service.ts#L42-L69
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
SyncService.syncForLinkedUser
async syncForLinkedUser(param: SyncLinkedUserType) { try { const { integrationId, linkedUserId } = param; const service: ICompanyService = this.serviceRegistry.getService(integrationId); if (!service) { this.logger.log( `No service found in {vertical:crm, commonObject: co...
//todo: HANDLE DATA REMOVED FROM PROVIDER
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/crm/company/sync/sync.service.ts#L72-L92
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
SyncService.kickstartSync
async kickstartSync(id_project?: string) { try { const linkedUsers = await this.prisma.linked_users.findMany({ where: { id_project: id_project, }, }); linkedUsers.map(async (linkedUser) => { try { const providers = CRM_PROVIDERS; for (const pro...
// every 8 hours
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/crm/contact/sync/sync.service.ts#L43-L70
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
SyncService.syncForLinkedUser
async syncForLinkedUser(param: SyncLinkedUserType) { try { const { integrationId, linkedUserId } = param; const service: IContactService = this.serviceRegistry.getService(integrationId); if (!service) { this.logger.log( `No service found in {vertical:crm, commonObject: co...
//todo: HANDLE DATA REMOVED FROM PROVIDER
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/crm/contact/sync/sync.service.ts#L73-L93
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
SyncService.kickstartSync
async kickstartSync(id_project?: string) { try { const linkedUsers = await this.prisma.linked_users.findMany({ where: { id_project: id_project, }, }); linkedUsers.map(async (linkedUser) => { try { const providers = CRM_PROVIDERS; for (const pro...
// every 8 hours
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/crm/deal/sync/sync.service.ts#L40-L67
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
SyncService.syncForLinkedUser
async syncForLinkedUser(param: SyncLinkedUserType) { try { const { integrationId, linkedUserId } = param; const service: IDealService = this.serviceRegistry.getService(integrationId); if (!service) { this.logger.log( `No service found in {vertical:crm, commonObject: deal}...
//todo: HANDLE DATA REMOVED FROM PROVIDER
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/crm/deal/sync/sync.service.ts#L70-L90
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
ZendeskService.addEngagement
async addEngagement( engagementData: ZendeskEngagementInput, linkedUserId: string, engagement_type: string, ): Promise<ApiResponse<ZendeskEngagementOutput>> { try { switch (engagement_type) { case 'CALL': return this.addCall(engagementData, linkedUserId); case 'MEETING'...
//ONLY CALLS FOR ZENDESK
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/crm/engagement/services/zendesk/index.ts#L27-L46
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
SyncService.kickstartSync
async kickstartSync(id_project?: string) { try { const linkedUsers = await this.prisma.linked_users.findMany({ where: { id_project: id_project, }, }); linkedUsers.map(async (linkedUser) => { try { const providers = CRM_PROVIDERS; for (const pro...
// every 8 hours
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/crm/engagement/sync/sync.service.ts#L46-L73
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
SyncService.syncForLinkedUser
async syncForLinkedUser(data: SyncLinkedUserType) { try { const { integrationId, linkedUserId, engagement_type } = data; const service: IEngagementService = this.serviceRegistry.getService(integrationId); if (!service) { this.logger.log( `No service found in {vertical:crm...
// todo engagement type
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/crm/engagement/sync/sync.service.ts#L77-L104
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
SyncService.kickstartSync
async kickstartSync(id_project?: string) { try { const linkedUsers = await this.prisma.linked_users.findMany({ where: { id_project: id_project, }, }); linkedUsers.map(async (linkedUser) => { try { const providers = CRM_PROVIDERS; for (const pro...
// every 8 hours
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/crm/note/sync/sync.service.ts#L46-L73
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
SyncService.syncForLinkedUser
async syncForLinkedUser(param: SyncLinkedUserType) { try { const { integrationId, linkedUserId } = param; const service: INoteService = this.serviceRegistry.getService(integrationId); if (!service) { this.logger.log( `No service found in {vertical:crm, commonObject: note}...
//todo: HANDLE DATA REMOVED FROM PROVIDER
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/crm/note/sync/sync.service.ts#L76-L96
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
SyncService.kickstartSync
async kickstartSync(id_project?: string) { try { const linkedUsers = await this.prisma.linked_users.findMany({ where: { id_project: id_project, }, }); linkedUsers.map(async (linkedUser) => { try { const providers = CRM_PROVIDERS; for (const pro...
// every 8 hours
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/crm/stage/sync/sync.service.ts#L44-L71
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
SyncService.syncForLinkedUser
async syncForLinkedUser(data: SyncLinkedUserType) { try { const { integrationId, linkedUserId, deal_id } = data; const service: IStageService = this.serviceRegistry.getService(integrationId); if (!service) { this.logger.log( `No service found in {vertical:crm, commonObjec...
//todo: HANDLE DATA REMOVED FROM PROVIDER
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/crm/stage/sync/sync.service.ts#L74-L101
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
SyncService.kickstartSync
async kickstartSync(id_project?: string) { try { const linkedUsers = await this.prisma.linked_users.findMany({ where: { id_project: id_project, }, }); linkedUsers.map(async (linkedUser) => { try { const providers = CRM_PROVIDERS; for (const pro...
// every 8 hours
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/crm/task/sync/sync.service.ts#L47-L74
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
SyncService.syncForLinkedUser
async syncForLinkedUser(param: SyncLinkedUserType) { try { const { integrationId, linkedUserId } = param; const service: ITaskService = this.serviceRegistry.getService(integrationId); if (!service) { this.logger.log( `No service found in {vertical:crm, commonObject: task}...
//todo: HANDLE DATA REMOVED FROM PROVIDER
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/crm/task/sync/sync.service.ts#L77-L97
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
SyncService.kickstartSync
async kickstartSync(id_project?: string) { try { const linkedUsers = await this.prisma.linked_users.findMany({ where: { id_project: id_project, }, }); linkedUsers.map(async (linkedUser) => { try { const providers = CRM_PROVIDERS; for (const pro...
// every 8 hours
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/crm/user/sync/sync.service.ts#L46-L73
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
SyncService.syncForLinkedUser
async syncForLinkedUser(param: SyncLinkedUserType) { try { const { integrationId, linkedUserId } = param; const service: IUserService = this.serviceRegistry.getService(integrationId); if (!service) { this.logger.log( `No service found in {vertical:crm, commonObject: user}...
//todo: HANDLE DATA REMOVED FROM PROVIDER
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/crm/user/sync/sync.service.ts#L76-L96
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
SyncService.kickstartSync
async kickstartSync(id_project?: string) { try { const linkedUsers = await this.prisma.linked_users.findMany({ where: { id_project: id_project, }, }); linkedUsers.map(async (linkedUser) => { try { const providers = ECOMMERCE_PROVIDERS; for (con...
// every 8 hours
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/ecommerce/customer/sync/sync.service.ts#L43-L70
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
SyncService.kickstartSync
async kickstartSync(id_project?: string) { try { const linkedUsers = await this.prisma.linked_users.findMany({ where: { id_project: id_project, }, }); linkedUsers.map(async (linkedUser) => { try { const providers = ECOMMERCE_PROVIDERS; for (con...
// every 8 hours
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/ecommerce/fulfillment/sync/sync.service.ts#L42-L69
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
SyncService.kickstartSync
async kickstartSync(id_project?: string) { try { const linkedUsers = await this.prisma.linked_users.findMany({ where: { id_project: id_project, }, }); linkedUsers.map(async (linkedUser) => { try { const providers = ECOMMERCE_PROVIDERS; for (con...
// every 8 hours
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/ecommerce/order/sync/sync.service.ts#L41-L68
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
SyncService.kickstartSync
async kickstartSync(id_project?: string) { try { const linkedUsers = await this.prisma.linked_users.findMany({ where: { id_project: id_project, }, }); linkedUsers.map(async (linkedUser) => { try { const providers = ECOMMERCE_PROVIDERS; for (con...
// every 8 hours
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/ecommerce/product/sync/sync.service.ts#L43-L70
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
OnedriveService.addDrive
async addDrive( driveData: DesunifyReturnType, linkedUserId: string, ): Promise<ApiResponse<OriginalDriveOutput>> { // No API to add drive in OneDrive return { data: null, message: 'Add drive not supported for OneDrive.', statusCode: 501, }; }
/** * Adds a new OneDrive drive. * @param driveData - Drive data to add. * @param linkedUserId - ID of the linked user. * @returns API response with the original drive output. */
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/filestorage/drive/services/onedrive/index.ts#L38-L48
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
OnedriveService.sync
async sync(data: SyncParam): Promise<ApiResponse<OnedriveDriveOutput[]>> { try { const { linkedUserId } = data; const connection = await this.prisma.connections.findFirst({ where: { id_linked_user: linkedUserId, provider_slug: 'onedrive', vertical: 'filestorage', ...
/** * Synchronizes OneDrive drives. * @param data - Synchronization parameters. * @returns API response with an array of OneDrive drive outputs. */
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/filestorage/drive/services/onedrive/index.ts#L55-L95
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
OnedriveService.makeRequestWithRetry
private async makeRequestWithRetry( config: AxiosRequestConfig, ): Promise<AxiosResponse> { let attempts = 0; let backoff: number = this.INITIAL_BACKOFF_MS; while (attempts < this.MAX_RETRIES) { try { const response: AxiosResponse = await axios(config); return response; } ...
/** * Makes an HTTP request with retry logic for handling 500 and 429 errors. * @param config - Axios request configuration. * @returns Axios response. */
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/filestorage/drive/services/onedrive/index.ts#L102-L152
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
OnedriveService.getRetryAfter
private getRetryAfter(retryAfterHeader: string | undefined): number { if (!retryAfterHeader) { return 1; // Default to 1 second if header is missing } const retryAfterSeconds: number = parseInt(retryAfterHeader, 10); return isNaN(retryAfterSeconds) ? 1 : retryAfterSeconds; }
/** * Parses the Retry-After header to determine the wait time. * @param retryAfterHeader - Value of the Retry-After header. * @returns Retry delay in seconds. */
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/filestorage/drive/services/onedrive/index.ts#L159-L166
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
OnedriveService.delay
private delay(ms: number): Promise<void> { return new Promise((resolve) => setTimeout(resolve, ms)); }
/** * Delays execution for the specified duration. * @param ms - Duration in milliseconds. * @returns Promise that resolves after the delay. */
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/filestorage/drive/services/onedrive/index.ts#L173-L175
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
SyncService.kickstartSync
async kickstartSync(id_project?: string) { try { const linkedUsers = await this.prisma.linked_users.findMany({ where: { id_project: id_project, }, }); linkedUsers.map(async (linkedUser) => { try { const providers = FILESTORAGE_PROVIDERS; for (c...
// every 8 hours
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/filestorage/drive/sync/sync.service.ts#L40-L67
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
GoogleDriveService.sync
async sync(data: SyncParam, pageToken?: string) { const { linkedUserId, custom_field_mappings, ingestParams } = data; const connection = await this.prisma.connections.findFirst({ where: { id_linked_user: linkedUserId, provider_slug: 'googledrive', vertical: 'filestorage', }, ...
/** * Syncs files from Google Drive to the local database * @param data - Parameters required for syncing * @param pageToken - Used for continuation of initial sync */
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/filestorage/file/services/googledrive/index.ts#L146-L235
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
GoogleDriveService.getFilesToSyncFromChangesApi
async getFilesToSyncFromChangesApi( drive: ReturnType<typeof google.drive>, connection: any, maxApiCalls = 10, // number of times we use nextPageToken ) { const filesToSync: GoogleDriveFileOutput[] = []; let apiCallCount = 0; let pageToken: string | undefined; let newRemoteCursor: string |...
// For incremental syncs
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/filestorage/file/services/googledrive/index.ts#L238-L285
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
GoogleDriveService.assignDriveIds
private async assignDriveIds( files: GoogleDriveFileOutput[], drive: ReturnType<typeof google.drive>, ): Promise<GoogleDriveFileOutput[]> { const rootDriveId = await this.rateLimitedRequest(() => drive.files .get({ fileId: 'root', fields: 'id', }) .then((r...
/** * Assigns driveId as root to files that don't have one. * @param files Array of Google Drive files. * @param auth OAuth2 client for Google Drive API. * @returns Array of Google Drive files with driveId assigned. */
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/filestorage/file/services/googledrive/index.ts#L376-L394
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
OnedriveService.sync
async sync( data: SyncParam, deltaLink?: string, ): Promise<ApiResponse<OnedriveFileOutput[]>> { try { const { linkedUserId, custom_field_mappings, ingestParams, id_folder } = data; const connection = await this.prisma.connections.findFirst({ where: { id_linked_user:...
// todo: add addFile method
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/filestorage/file/services/onedrive/index.ts#L43-L162
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
OnedriveService.ingestPermissionsForFiles
private async ingestPermissionsForFiles( allFiles: OnedriveFileOutput[], connection: Connection, ): Promise<OnedriveFileOutput[]> { const allPermissions: OnedrivePermissionOutput[] = []; const fileIdToRemotePermissionIdMap: Map<string, string[]> = new Map(); const batchSize = 4; // simultaneous re...
/** * Ingests and assigns permissions for files. * @param allFiles - Array of OnedriveFileOutput to process. * @param connection - The connection object. * @returns The updated array of OnedriveFileOutput with ingested permissions. */
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/filestorage/file/services/onedrive/index.ts#L271-L352
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
OnedriveService.makeRequestWithRetry
private async makeRequestWithRetry( config: AxiosRequestConfig, ): Promise<AxiosResponse> { let attempts = 0; let backoff: number = this.INITIAL_BACKOFF_MS; while (attempts < this.MAX_RETRIES) { try { const response: AxiosResponse = await axios(config); return response; } ...
/** * Makes an HTTP request with rate limit handling using exponential backoff. * @param config - Axios request configuration. * @returns Axios response. */
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/filestorage/file/services/onedrive/index.ts#L486-L560
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
OnedriveService.getRetryAfter
private getRetryAfter(retryAfterHeader: string | undefined): number { if (!retryAfterHeader) { return 1; // Default to 1 second if header is missing } const retryAfterSeconds: number = parseInt(retryAfterHeader, 10); return isNaN(retryAfterSeconds) ? 1 : retryAfterSeconds; }
/** * Parses the Retry-After header to determine the wait time. * @param retryAfterHeader - Value of the Retry-After header. * @returns Retry delay in seconds. */
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/filestorage/file/services/onedrive/index.ts#L567-L574
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
OnedriveService.delay
private delay(ms: number): Promise<void> { return new Promise((resolve) => setTimeout(resolve, ms)); }
/** * Delays execution for the specified duration. * @param ms - Duration in milliseconds. * @returns Promise that resolves after the delay. */
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/filestorage/file/services/onedrive/index.ts#L581-L583
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
SyncService.kickstartSync
async kickstartSync(id_project?: string) { try { const linkedUsers = await this.prisma.linked_users.findMany({ where: { id_project: id_project, }, }); linkedUsers.map(async (linkedUser) => { try { const providers = FILESTORAGE_PROVIDERS; for (c...
// every 8 hours
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/filestorage/file/sync/sync.service.ts#L44-L71
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
fetchFoldersForParent
const fetchFoldersForParent = async ( parentId: string | null = null, driveId: string, ): Promise<GoogleDriveFolderOutput[]> => { const folders: GoogleDriveFolderOutput[] = []; let pageToken: string | null = null; const buildQuery = (parentId: string | null, driveId: string): string =...
// Helper function to fetch folders for a specific parent ID or root
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/filestorage/folder/services/googledrive/index.ts#L182-L232
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
populateFolders
async function populateFolders( parentId: string | null = null, // Parent Folder ID returned by google drive api internalParentId: string | null = null, // Parent Folder ID in panora db level = 0, allFolders: GoogleDriveFolderOutput[] = [], driveId: string, ): Promise<void> { con...
// Recursive function to populate folders level by level
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/filestorage/folder/services/googledrive/index.ts#L235-L265
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
GoogleDriveFolderService.ingestPermissionsForFolders
async ingestPermissionsForFolders( folders: GoogleDriveFolderOutput[], connectionId: string, auth: OAuth2Client, ): Promise<GoogleDriveFolderOutput[]> { if (folders.length === 0) { this.logger.log('No folders provided for ingesting permissions.'); return folders; } try { // ...
/** * Ingests permissions for the provided Google Drive folders into the database. */
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/filestorage/folder/services/googledrive/index.ts#L316-L390
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
GoogleDriveFolderService.getFoldersIncremental
private async getFoldersIncremental( auth: OAuth2Client, connectionId: string, ): Promise<GoogleDriveFolderOutput[]> { try { const drive = google.drive({ version: 'v3', auth }); const driveIds = await this.fetchDriveIds(auth); const modifiedFolders = await this.getModifiedFolders( ...
/** * Retrieves folders that have been modified for each drive using drive's remote_cursor * @param auth OAuth2 client for Google Drive API. * @param connectionId ID of the connection. * @returns Array of Google Drive folders that have been modified. */
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/filestorage/folder/services/googledrive/index.ts#L398-L423
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
GoogleDriveFolderService.assignDriveIds
private async assignDriveIds( folders: GoogleDriveFolderOutput[], auth: OAuth2Client, ): Promise<GoogleDriveFolderOutput[]> { const drive = google.drive({ version: 'v3', auth }); const rootDriveId = await this.executeWithRetry(() => drive.files .get({ fileId: 'root', ...
/** * Assigns driveId as root to folders that don't have one. * @param folders Array of Google Drive folders. * @param auth OAuth2 client for Google Drive API. * @returns Array of Google Drive folders with driveId assigned. */
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/filestorage/folder/services/googledrive/index.ts#L431-L450
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
GoogleDriveFolderService.assignParentIds
private async assignParentIds( folders: GoogleDriveFolderOutput[], connectionId: string, driveIds: string[], drive: any, ): Promise<GoogleDriveFolderOutput[]> { const folderIdToInternalIdMap = new Map<string, string>(); const foldersToSync: GoogleDriveFolderOutput[] = []; let remainingFold...
/** * Assigns parent IDs to folders based on their parents. * Handles circular references and orphaned folders. */
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/filestorage/folder/services/googledrive/index.ts#L456-L521
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
GoogleDriveFolderService.delay
private async delay(ms: number): Promise<void> { return new Promise((resolve) => setTimeout(resolve, ms)); }
/** * Delays execution for a specified amount of time. * @param ms Milliseconds to delay. */
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/filestorage/folder/services/googledrive/index.ts#L712-L714
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
OnedriveService.ingestPermissionsForFolders
private async ingestPermissionsForFolders( allFolders: OnedriveFolderOutput[], connection: Connection, ): Promise<OnedriveFolderOutput[]> { const allPermissions: OnedrivePermissionOutput[] = []; const folderIdToRemotePermissionIdMap: Map<string, string[]> = new Map(); const batchSize = 4; // simul...
/** * Ingests and assigns permissions for folders. * @param allFolders - Array of OneDriveFolderOutput to process. * @param connection - The connection object. * @returns The updated array of OneDriveFolderOutput with ingested permissions. */
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/filestorage/folder/services/onedrive/index.ts#L329-L408
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
OnedriveService.assignParentIds
private async assignParentIds( folders: OnedriveFolderOutput[], connection: Connection, ): Promise<OnedriveFolderOutput[]> { const folderIdToInternalIdMap: Map<string, string> = new Map(); const foldersToSync: OnedriveFolderOutput[] = []; let remainingFolders: OnedriveFolderOutput[] = [...folders]...
/** * Assigns internal parent IDs to OneDrive folders, ensuring proper parent-child relationships. * @param folders - Array of OneDriveFolderOutput to process. * @returns The updated array of OneDriveFolderOutput with assigned internal parent IDs. */
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/filestorage/folder/services/onedrive/index.ts#L464-L522
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
OnedriveService.resolveParentId
private async resolveParentId( parentId: string, idMap: Map<string, string>, connectionId: string, cache: Map<string, string | null>, ): Promise<string | null | undefined> { if (idMap.has(parentId)) { return idMap.get(parentId); } if (parentId === 'root') { return 'root'; ...
/** * Resolves the internal parent ID for a given remote parent ID. * @param parentId - The remote parent folder ID. * @param idMap - Map of remote IDs to internal IDs. * @param connectionId - The connection ID. * @param cache - Cache for parent ID lookups. * @returns The internal parent ID or null if...
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/filestorage/folder/services/onedrive/index.ts#L543-L572
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
OnedriveService.handleUnresolvedFolders
private async handleUnresolvedFolders( pending: OnedriveFolderOutput[], output: OnedriveFolderOutput[], remote_folders: Map<string, OnedriveFolderOutput>, parentLookupCache: Map<string, string | null>, idCache: Map<string, string | null>, connection: Connection, ): Promise<void> { this.log...
/** * Handles folders that couldn't be resolved in the initial pass. * @param pending - Folders still pending resolution. * @param output - Already processed folders. * @param idMap - Map of remote IDs to internal IDs. * @param cache - Cache for parent ID lookups. */
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/filestorage/folder/services/onedrive/index.ts#L581-L662
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
OnedriveService.handleDeletedFolder
async handleDeletedFolder(folderId: string, connection: Connection) { const folder = await this.prisma.fs_folders.findFirst({ where: { id_fs_folder: folderId, id_connection: connection.id_connection, }, select: { remote_was_deleted: true, id_fs_folder: true, ...
/** * Handles the deletion of a folder by marking it and its children as deleted in the database. * @param folderId - The internal ID of the folder to be marked as deleted. * @param connection - The connection object containing the connection details. */
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/filestorage/folder/services/onedrive/index.ts#L669-L695
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
OnedriveService.folderDeletedOnRemote
private async folderDeletedOnRemote( folder: fs_folders, connection: Connection, ) { try { const remoteFolder = await this.makeRequestWithRetry({ timeout: 30000, method: 'get', url: `${connection.account_url}/v1.0/me/drive/items/${folder.remote_id}?$select=id,deleted`, ...
/** * Checks if a folder is deleted on the remote OneDrive service. * @param folder - The folder to check. * @param connection - The connection object containing the connection details. * @returns True if the folder is deleted, false otherwise. */
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/filestorage/folder/services/onedrive/index.ts#L703-L728
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
OnedriveService.getLastSyncTime
private async getLastSyncTime(connectionId: string): Promise<Date | null> { const lastSync = await this.prisma.fs_folders.findFirst({ where: { id_connection: connectionId }, orderBy: { remote_modified_at: { sort: 'desc', nulls: 'last' } }, }); this.logger.log( `Last sync time for connectio...
/** * Gets the last sync time for a connection. * @param connectionId - The ID of the connection. * @returns The last sync time or null if no sync time is found. */
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/filestorage/folder/services/onedrive/index.ts#L735-L744
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
OnedriveService.makeRequestWithRetry
private async makeRequestWithRetry( config: AxiosRequestConfig, ): Promise<AxiosResponse> { let attempts = 0; let backoff: number = this.INITIAL_BACKOFF_MS; while (attempts < this.MAX_RETRIES) { try { const response: AxiosResponse = await axios(config); return response; } ...
/** * Makes an HTTP request with rate limit handling using exponential backoff. * @param config - Axios request configuration. * @returns Axios response. */
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/filestorage/folder/services/onedrive/index.ts#L751-L825
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
OnedriveService.getRetryAfter
private getRetryAfter(retryAfterHeader: string | undefined): number { if (!retryAfterHeader) { return 1; // Default to 1 second if header is missing } const retryAfterSeconds: number = parseInt(retryAfterHeader, 10); return isNaN(retryAfterSeconds) ? 1 : retryAfterSeconds + 0.5; }
/** * Parses the Retry-After header to determine the wait time. * @param retryAfterHeader - Value of the Retry-After header. * @returns Retry delay in seconds. */
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/filestorage/folder/services/onedrive/index.ts#L832-L839
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
OnedriveService.delay
private delay(ms: number): Promise<void> { return new Promise((resolve) => setTimeout(resolve, ms)); }
/** * Delays execution for the specified duration. * @param ms - Duration in milliseconds. * @returns Promise that resolves after the delay. */
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/filestorage/folder/services/onedrive/index.ts#L846-L848
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
SyncService.kickstartSync
async kickstartSync(id_project?: string) { try { const linkedUsers = await this.prisma.linked_users.findMany({ where: { id_project: id_project, }, }); linkedUsers.map(async (linkedUser) => { try { const providers = FILESTORAGE_PROVIDERS; for (c...
// every 8 hours
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/filestorage/folder/sync/sync.service.ts#L41-L68
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
OnedriveService.sync
async sync(data: SyncParam): Promise<ApiResponse<OnedriveGroupOutput[]>> { try { const { linkedUserId } = data; const connection = await this.prisma.connections.findFirst({ where: { id_linked_user: linkedUserId, provider_slug: 'onedrive', vertical: 'filestorage', ...
/** * Synchronizes OneDrive groups. * @param data - Synchronization parameters. * @returns API response with an array of OneDrive group outputs. */
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/filestorage/group/services/onedrive/index.ts#L36-L77
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
OnedriveService.makeRequestWithRetry
private async makeRequestWithRetry( config: AxiosRequestConfig, ): Promise<AxiosResponse> { let attempts = 0; let backoff: number = this.INITIAL_BACKOFF_MS; while (attempts < this.MAX_RETRIES) { try { const response: AxiosResponse = await axios(config); return response; } ...
/** * Makes an HTTP request with retry logic for handling 500 and 429 errors. * @param config - Axios request configuration. * @returns Axios response. */
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/filestorage/group/services/onedrive/index.ts#L136-L186
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
OnedriveService.getRetryAfter
private getRetryAfter(retryAfterHeader: string | undefined): number { if (!retryAfterHeader) { return 1; // Default to 1 second if header is missing } const retryAfterSeconds: number = parseInt(retryAfterHeader, 10); return isNaN(retryAfterSeconds) ? 1 : retryAfterSeconds; }
/** * Parses the Retry-After header to determine the wait time. * @param retryAfterHeader - Value of the Retry-After header. * @returns Retry delay in seconds. */
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/filestorage/group/services/onedrive/index.ts#L193-L200
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2
Panora
github_2023
panoratech
typescript
OnedriveService.delay
private delay(ms: number): Promise<void> { return new Promise((resolve) => setTimeout(resolve, ms)); }
/** * Delays execution for the specified duration. * @param ms - Duration in milliseconds. * @returns Promise that resolves after the delay. */
https://github.com/panoratech/Panora/blob/c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2/packages/api/src/filestorage/group/services/onedrive/index.ts#L207-L209
c6741e9ef154bf215bcd7a6a4cc51522eae7c7f2