-
Notifications
You must be signed in to change notification settings - Fork 196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add integration with: Webflow (ecommerce) #685
feat: Add integration with: Webflow (ecommerce) #685
Conversation
Qovery can create a Preview Environment for this PR.
This comment has been generated from Qovery AI 🤖.
|
|
|
Caution Review failedThe pull request is closed. WalkthroughWalkthroughThe changes introduce support for the Webflow e-commerce platform across various components of the application. This includes modifications to the database schema, seed data, type definitions, and service implementations to facilitate integration with Webflow. Additionally, connectors and metadata configurations have been updated to activate the Webflow integration, expanding the application's e-commerce capabilities. Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 6
Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Files selected for processing (18)
- packages/api/scripts/init.sql (1 hunks)
- packages/api/scripts/seed.sql (1 hunks)
- packages/api/src/@core/utils/types/original/original.ecommerce.ts (4 hunks)
- packages/api/src/ecommerce/customer/customer.module.ts (2 hunks)
- packages/api/src/ecommerce/customer/services/webflow/index.ts (1 hunks)
- packages/api/src/ecommerce/customer/services/webflow/mappers.ts (1 hunks)
- packages/api/src/ecommerce/customer/services/webflow/types.ts (1 hunks)
- packages/api/src/ecommerce/order/order.module.ts (2 hunks)
- packages/api/src/ecommerce/order/services/webflow/index.ts (1 hunks)
- packages/api/src/ecommerce/order/services/webflow/mappers.ts (1 hunks)
- packages/api/src/ecommerce/order/services/webflow/types.ts (1 hunks)
- packages/api/src/ecommerce/product/product.module.ts (2 hunks)
- packages/api/src/ecommerce/product/services/webflow/index.ts (1 hunks)
- packages/api/src/ecommerce/product/services/webflow/mappers.ts (1 hunks)
- packages/api/src/ecommerce/product/services/webflow/types.ts (1 hunks)
- packages/shared/src/connectors/enum.ts (1 hunks)
- packages/shared/src/connectors/index.ts (1 hunks)
- packages/shared/src/connectors/metadata.ts (1 hunks)
Additional context used
Biome
packages/api/src/ecommerce/customer/services/webflow/index.ts
[error] 57-57: The catch clause that only rethrows the original error is redundant.
These unnecessary catch clauses can be confusing. It is recommended to remove them.
(lint/complexity/noUselessCatch)
packages/api/src/ecommerce/order/services/webflow/index.ts
[error] 55-55: The catch clause that only rethrows the original error is redundant.
These unnecessary catch clauses can be confusing. It is recommended to remove them.
(lint/complexity/noUselessCatch)
packages/api/src/ecommerce/product/services/webflow/index.ts
[error] 61-61: The catch clause that only rethrows the original error is redundant.
These unnecessary catch clauses can be confusing. It is recommended to remove them.
(lint/complexity/noUselessCatch)
[error] 97-97: The catch clause that only rethrows the original error is redundant.
These unnecessary catch clauses can be confusing. It is recommended to remove them.
(lint/complexity/noUselessCatch)
packages/api/src/ecommerce/product/services/webflow/mappers.ts
[error] 49-49: Use Number.parseInt instead of the equivalent global.
ES2015 moved some globals into the Number namespace for consistency.
Safe fix: Use Number.parseInt instead.(lint/style/useNumberNamespace)
Additional comments not posted (36)
packages/shared/src/connectors/index.ts (1)
8-8
: LGTM!The addition of 'webflow' to the
ECOMMERCE_PROVIDERS
constant is approved. It expands the supported ecommerce providers without introducing any issues.packages/shared/src/connectors/enum.ts (1)
14-15
: LGTM!The addition of the
WEBFLOW
enum value to theEcommerceConnectors
enum is approved. It expands the supported ecommerce connectors without introducing any issues and aligns with the change made in theindex.ts
file.packages/api/src/ecommerce/customer/services/webflow/types.ts (1)
1-33
: LGTM! The type definitions align with the Webflow API documentation.The
WebflowCustomerInput
interface,WebflowCustomerOutput
type, and related types and enums are well-defined and match the structure described in the Webflow API documentation.packages/api/scripts/seed.sql (1)
4-7
: LGTM!The code changes are approved. The SQL statement has been updated to include the new
ecom_webflow
column, and the values are consistent across all entries.packages/api/src/ecommerce/product/product.module.ts (1)
15-16
: LGTM!The code changes are approved. The module has been enhanced to support Webflow by importing and providing
WebflowService
andWebflowProductMapper
, following the existing pattern for other e-commerce platforms.Also applies to: 36-37
packages/api/src/ecommerce/customer/customer.module.ts (1)
16-17
: LGTM!The code changes are approved. The module has been enhanced to support Webflow by importing and providing
WebflowService
andWebflowCustomerMapper
, following the existing pattern for other e-commerce platforms.Also applies to: 35-36
packages/api/src/ecommerce/order/order.module.ts (2)
13-14
: LGTM!The code changes are approved.
40-41
: LGTM!The code changes are approved.
packages/api/src/ecommerce/product/services/webflow/types.ts (1)
1-107
: LGTM!The new type definitions for Webflow products are well-structured and comprehensive. They cover the essential properties of products, SKUs, pricing, images, and subscription plans. The interfaces follow a clear naming convention and are well-documented with references to the Webflow API documentation.
The code changes are approved.
packages/api/src/ecommerce/customer/services/webflow/mappers.ts (1)
1-91
: LGTM!The new mapper service for Webflow customers is well-implemented. It follows the dependency injection pattern and is properly registered with the mappers registry. The
unify
method handles both single customer and array of customers, mapping them to the unified customer type using themapSingleCustomerToUnified
method.The code changes are approved.
packages/api/src/ecommerce/product/services/webflow/index.ts (1)
1-100
: LGTM!The new Webflow product service is well-implemented. It properly handles the creation and syncing of products using the Webflow API. The service is decorated with
@Injectable()
and registered with the service registry. TheaddProduct
andsync
methods make the necessary API requests using Axios and decrypt the access token from the database connection.The code changes are approved.
Tools
Biome
[error] 61-61: The catch clause that only rethrows the original error is redundant.
These unnecessary catch clauses can be confusing. It is recommended to remove them.
(lint/complexity/noUselessCatch)
[error] 97-97: The catch clause that only rethrows the original error is redundant.
These unnecessary catch clauses can be confusing. It is recommended to remove them.
(lint/complexity/noUselessCatch)
packages/api/src/@core/utils/types/original/original.ecommerce.ts (6)
69-70
: LGTM!The code changes are approved.
77-78
: LGTM!The code changes are approved.
87-88
: LGTM!The code changes are approved.
106-107
: LGTM!The code changes are approved.
114-115
: LGTM!The code changes are approved.
125-126
: LGTM!The code changes are approved.
packages/api/src/ecommerce/product/services/webflow/mappers.ts (2)
27-66
: LGTM!The code changes are approved.
Tools
Biome
[error] 49-49: Use Number.parseInt instead of the equivalent global.
ES2015 moved some globals into the Number namespace for consistency.
Safe fix: Use Number.parseInt instead.(lint/style/useNumberNamespace)
68-118
: LGTM!The code changes are approved.
packages/api/src/ecommerce/order/services/webflow/mappers.ts (2)
32-52
: LGTM!The code changes are approved.
54-112
: LGTM!The code changes are approved.
packages/api/src/ecommerce/order/services/webflow/types.ts (13)
3-54
: LGTM!The
WebflowOrderInput
interface looks comprehensive and well-structured. The use of thereadonly
modifier for most fields is a good practice to prevent unintended mutations.
56-60
: LGTM!The
Money
interface looks good and captures the essential components of a monetary value.
62-72
: LGTM!The
Address
interface looks comprehensive and caters to different address formats. The inclusion of the optionaljapanType
field for handling Japan-specific addresses is a nice touch.
74-80
: LGTM!The
FileObjectVariant
interface looks good and captures the essential properties of a file object variant.
82-90
: LGTM!The
FileObject
interface looks comprehensive and includes all the essential details of a file object.
92-111
: LGTM!The
PurchasedItem
interface looks comprehensive and captures all the relevant details of a purchased item in an order.
113-122
: LGTM!The
StripeDetails
interface looks good and includes all the necessary Stripe-related details for an order.
124-131
: LGTM!The
PaypalDetails
interface looks good and includes all the necessary PayPal-related details for an order.
133-141
: LGTM!The
StripeCard
interface looks good and captures the essential details of a Stripe card used for payment.
143-152
: LGTM!The
Totals
interface looks good and provides a clear breakdown of the order totals, including subtotal, extras, and the grand total.
154-163
: LGTM!The
DisputeStatus
enum looks comprehensive and covers all the possible statuses of a payment dispute.
175-175
: LGTM!The
WebflowOrderOutput
type alias looks good and provides flexibility for representing partial Webflow order outputs by making all fields ofWebflowOrderInput
optional.
165-173
: Consider adding a few more popular card brands.The
StripeCardBrands
enum looks good and covers the common card brands. However, consider adding a few more popular brands like Discover and JCB for completeness.enum StripeCardBrands { VISA = 'Visa', AMEX = 'American Express', MASTERCARD = 'MasterCard', + DISCOVER = 'Discover', + JCB = 'JCB', UNKNOWN = 'Unknown', }Likely invalid or redundant comment.
packages/api/scripts/init.sql (1)
552-552
: LGTM!The addition of the
ecom_webflow
column to theconnector_sets
table looks good. It enables tracking the integration status or configuration for the Webflow e-commerce platform, enhancing the table's structure to accommodate more diverse e-commerce integrations.packages/shared/src/connectors/metadata.ts (1)
2923-2923
: Verify the readiness and intentionality of enabling the Webflow connector.The change itself to enable the Webflow connector is straightforward. However, it's important to verify that:
- The Webflow integration is fully implemented, tested and ready to be enabled.
- Enabling the connector at this point is intentional and aligns with the PR objectives.
- There are no breaking changes or unintended side-effects of enabling the connector.
To verify the above, please confirm that:
- The Webflow integration has been fully implemented, covering the sync and creation of orders, fulfillments, fulfillment orders, customers and products.
- Comprehensive testing has been done, including end-to-end scenarios, to ensure the integration works as expected.
- Enabling the connector at this stage is a conscious decision and aligns with the goals of this PR.
- Thorough testing has been done to verify there are no breaking changes or unintended side-effects on other parts of the application due to enabling this connector.
// ref: https://docs.developers.webflow.com/data/reference/list-users | ||
|
||
export interface WebflowCustomerInput { | ||
id: string; | ||
isEmailVerified: boolean; | ||
lastUpdated: string; | ||
invitedOn: string; | ||
createdOn: string; | ||
lastLogin: string; | ||
status: 'invited' | 'verified' | 'unverified'; | ||
accessGroups: AccessGroup[]; | ||
data: UserData; | ||
} | ||
|
||
type AccessGroup = { | ||
slug: string; | ||
type: AccessGroupType; | ||
}; | ||
|
||
enum AccessGroupType { | ||
ADMIN = 'admin', // Assigned to the user via API or in the designer | ||
ECOMMERCE = 'ecommerce', // Assigned to the user via an ecommerce purchase | ||
} | ||
|
||
type UserData = { | ||
name: string; | ||
email: string; | ||
acceptPrivacy: boolean; | ||
acceptCommunications: boolean; | ||
[key: string]: any; | ||
}; | ||
|
||
export type WebflowCustomerOutput = Partial<WebflowCustomerInput>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Add JSDoc comments to improve documentation.
Consider adding JSDoc comments to the interfaces, types, and enums to provide more context and improve the documentation of the code.
For example:
/**
* Represents a Webflow customer.
* @see https://docs.developers.webflow.com/data/reference/list-users
*/
export interface WebflowCustomerInput {
// ...
}
/**
* Represents an access group assigned to a Webflow customer.
*/
type AccessGroup = {
// ...
};
/**
* Enum representing the possible types of access groups.
*/
enum AccessGroupType {
// ...
}
/**
* Represents the custom data associated with a Webflow customer.
*/
type UserData = {
// ...
};
/**
* Represents the output type for a Webflow customer.
*/
export type WebflowCustomerOutput = Partial<WebflowCustomerInput>;
import { EncryptionService } from '@@core/@core-services/encryption/encryption.service'; | ||
import { LoggerService } from '@@core/@core-services/logger/logger.service'; | ||
import { PrismaService } from '@@core/@core-services/prisma/prisma.service'; | ||
import { ApiResponse } from '@@core/utils/types'; | ||
import { SyncParam } from '@@core/utils/types/interface'; | ||
import { ICustomerService } from '@ecommerce/customer/types'; | ||
import { Injectable } from '@nestjs/common'; | ||
import { EcommerceObject } from '@panora/shared'; | ||
import axios from 'axios'; | ||
import { ServiceRegistry } from '../registry.service'; | ||
import { WebflowCustomerOutput } from './types'; | ||
|
||
@Injectable() | ||
export class WebflowService implements ICustomerService { | ||
constructor( | ||
private prisma: PrismaService, | ||
private logger: LoggerService, | ||
private cryptoService: EncryptionService, | ||
private registry: ServiceRegistry, | ||
) { | ||
this.logger.setContext( | ||
`${EcommerceObject.customer.toUpperCase()}:${WebflowService.name}`, | ||
); | ||
this.registry.registerService('webflow', this); | ||
} | ||
|
||
async sync(data: SyncParam): Promise<ApiResponse<WebflowCustomerOutput[]>> { | ||
try { | ||
const { linkedUserId } = data; | ||
|
||
const connection = await this.prisma.connections.findFirst({ | ||
where: { | ||
id_linked_user: linkedUserId, | ||
provider_slug: 'webflow', | ||
vertical: 'ecommerce', | ||
}, | ||
}); | ||
|
||
const resp = await axios.get(`${connection.account_url}/users`, { | ||
headers: { | ||
'Content-Type': 'application/json', | ||
authorization: `Bearer ${this.cryptoService.decrypt( | ||
connection.access_token, | ||
)}`, | ||
}, | ||
}); | ||
const customers: WebflowCustomerOutput[] = resp.data.users; | ||
|
||
this.logger.log(`Synced webflow customers !`); | ||
|
||
return { | ||
data: customers, | ||
message: 'Webflow customers retrieved', | ||
statusCode: 200, | ||
}; | ||
} catch (error) { | ||
throw error; | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! But remove the redundant catch clause.
The code changes are approved. However, the catch clause at line 57 is redundant and can be removed.
Apply this diff to remove the redundant catch clause:
- } catch (error) {
- throw error;
- }
+ }
}
}
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
import { EncryptionService } from '@@core/@core-services/encryption/encryption.service'; | |
import { LoggerService } from '@@core/@core-services/logger/logger.service'; | |
import { PrismaService } from '@@core/@core-services/prisma/prisma.service'; | |
import { ApiResponse } from '@@core/utils/types'; | |
import { SyncParam } from '@@core/utils/types/interface'; | |
import { ICustomerService } from '@ecommerce/customer/types'; | |
import { Injectable } from '@nestjs/common'; | |
import { EcommerceObject } from '@panora/shared'; | |
import axios from 'axios'; | |
import { ServiceRegistry } from '../registry.service'; | |
import { WebflowCustomerOutput } from './types'; | |
@Injectable() | |
export class WebflowService implements ICustomerService { | |
constructor( | |
private prisma: PrismaService, | |
private logger: LoggerService, | |
private cryptoService: EncryptionService, | |
private registry: ServiceRegistry, | |
) { | |
this.logger.setContext( | |
`${EcommerceObject.customer.toUpperCase()}:${WebflowService.name}`, | |
); | |
this.registry.registerService('webflow', this); | |
} | |
async sync(data: SyncParam): Promise<ApiResponse<WebflowCustomerOutput[]>> { | |
try { | |
const { linkedUserId } = data; | |
const connection = await this.prisma.connections.findFirst({ | |
where: { | |
id_linked_user: linkedUserId, | |
provider_slug: 'webflow', | |
vertical: 'ecommerce', | |
}, | |
}); | |
const resp = await axios.get(`${connection.account_url}/users`, { | |
headers: { | |
'Content-Type': 'application/json', | |
authorization: `Bearer ${this.cryptoService.decrypt( | |
connection.access_token, | |
)}`, | |
}, | |
}); | |
const customers: WebflowCustomerOutput[] = resp.data.users; | |
this.logger.log(`Synced webflow customers !`); | |
return { | |
data: customers, | |
message: 'Webflow customers retrieved', | |
statusCode: 200, | |
}; | |
} catch (error) { | |
throw error; | |
} | |
} | |
} | |
import { EncryptionService } from '@@core/@core-services/encryption/encryption.service'; | |
import { LoggerService } from '@@core/@core-services/logger/logger.service'; | |
import { PrismaService } from '@@core/@core-services/prisma/prisma.service'; | |
import { ApiResponse } from '@@core/utils/types'; | |
import { SyncParam } from '@@core/utils/types/interface'; | |
import { ICustomerService } from '@ecommerce/customer/types'; | |
import { Injectable } from '@nestjs/common'; | |
import { EcommerceObject } from '@panora/shared'; | |
import axios from 'axios'; | |
import { ServiceRegistry } from '../registry.service'; | |
import { WebflowCustomerOutput } from './types'; | |
@Injectable() | |
export class WebflowService implements ICustomerService { | |
constructor( | |
private prisma: PrismaService, | |
private logger: LoggerService, | |
private cryptoService: EncryptionService, | |
private registry: ServiceRegistry, | |
) { | |
this.logger.setContext( | |
`${EcommerceObject.customer.toUpperCase()}:${WebflowService.name}`, | |
); | |
this.registry.registerService('webflow', this); | |
} | |
async sync(data: SyncParam): Promise<ApiResponse<WebflowCustomerOutput[]>> { | |
const { linkedUserId } = data; | |
const connection = await this.prisma.connections.findFirst({ | |
where: { | |
id_linked_user: linkedUserId, | |
provider_slug: 'webflow', | |
vertical: 'ecommerce', | |
}, | |
}); | |
const resp = await axios.get(`${connection.account_url}/users`, { | |
headers: { | |
'Content-Type': 'application/json', | |
authorization: `Bearer ${this.cryptoService.decrypt( | |
connection.access_token, | |
)}`, | |
}, | |
}); | |
const customers: WebflowCustomerOutput[] = resp.data.users; | |
this.logger.log(`Synced webflow customers !`); | |
return { | |
data: customers, | |
message: 'Webflow customers retrieved', | |
statusCode: 200, | |
}; | |
} | |
} |
Tools
Biome
[error] 57-57: The catch clause that only rethrows the original error is redundant.
These unnecessary catch clauses can be confusing. It is recommended to remove them.
(lint/complexity/noUselessCatch)
import { EncryptionService } from '@@core/@core-services/encryption/encryption.service'; | ||
import { LoggerService } from '@@core/@core-services/logger/logger.service'; | ||
import { PrismaService } from '@@core/@core-services/prisma/prisma.service'; | ||
import { ApiResponse } from '@@core/utils/types'; | ||
import { SyncParam } from '@@core/utils/types/interface'; | ||
import { IOrderService } from '@ecommerce/order/types'; | ||
import { Injectable } from '@nestjs/common'; | ||
import { EcommerceObject } from '@panora/shared'; | ||
import axios from 'axios'; | ||
import { ServiceRegistry } from '../registry.service'; | ||
import { WebflowOrderInput, WebflowOrderOutput } from './types'; | ||
|
||
@Injectable() | ||
export class WebflowService implements IOrderService { | ||
constructor( | ||
private prisma: PrismaService, | ||
private logger: LoggerService, | ||
private cryptoService: EncryptionService, | ||
private registry: ServiceRegistry, | ||
) { | ||
this.logger.setContext( | ||
`${EcommerceObject.order.toUpperCase()}:${WebflowService.name}`, | ||
); | ||
this.registry.registerService('webflow', this); | ||
} | ||
|
||
async sync(data: SyncParam): Promise<ApiResponse<WebflowOrderOutput[]>> { | ||
try { | ||
const connection = await this.prisma.connections.findFirst({ | ||
where: { | ||
id_linked_user: data.linkedUserId, | ||
provider_slug: 'webflow', | ||
vertical: 'ecommerce', | ||
}, | ||
}); | ||
|
||
// ref: https://docs.developers.webflow.com/data/reference/list-orders | ||
const resp = await axios.get(`${connection.account_url}/orders`, { | ||
headers: { | ||
'Content-Type': 'application/json', | ||
Authorization: `Bearer ${this.cryptoService.decrypt( | ||
connection.access_token, | ||
)}`, | ||
}, | ||
}); | ||
const orders: WebflowOrderOutput[] = resp.data.orders; | ||
this.logger.log(`Synced webflow orders !`); | ||
|
||
return { | ||
data: orders, | ||
message: 'Webflow orders retrieved', | ||
statusCode: 200, | ||
}; | ||
} catch (error) { | ||
throw error; | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! But remove the redundant catch clause.
The code changes are approved. However, the catch clause at line 55 is redundant and can be removed.
Apply this diff to remove the redundant catch clause:
- } catch (error) {
- throw error;
- }
+ }
}
}
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
import { EncryptionService } from '@@core/@core-services/encryption/encryption.service'; | |
import { LoggerService } from '@@core/@core-services/logger/logger.service'; | |
import { PrismaService } from '@@core/@core-services/prisma/prisma.service'; | |
import { ApiResponse } from '@@core/utils/types'; | |
import { SyncParam } from '@@core/utils/types/interface'; | |
import { IOrderService } from '@ecommerce/order/types'; | |
import { Injectable } from '@nestjs/common'; | |
import { EcommerceObject } from '@panora/shared'; | |
import axios from 'axios'; | |
import { ServiceRegistry } from '../registry.service'; | |
import { WebflowOrderInput, WebflowOrderOutput } from './types'; | |
@Injectable() | |
export class WebflowService implements IOrderService { | |
constructor( | |
private prisma: PrismaService, | |
private logger: LoggerService, | |
private cryptoService: EncryptionService, | |
private registry: ServiceRegistry, | |
) { | |
this.logger.setContext( | |
`${EcommerceObject.order.toUpperCase()}:${WebflowService.name}`, | |
); | |
this.registry.registerService('webflow', this); | |
} | |
async sync(data: SyncParam): Promise<ApiResponse<WebflowOrderOutput[]>> { | |
try { | |
const connection = await this.prisma.connections.findFirst({ | |
where: { | |
id_linked_user: data.linkedUserId, | |
provider_slug: 'webflow', | |
vertical: 'ecommerce', | |
}, | |
}); | |
// ref: https://docs.developers.webflow.com/data/reference/list-orders | |
const resp = await axios.get(`${connection.account_url}/orders`, { | |
headers: { | |
'Content-Type': 'application/json', | |
Authorization: `Bearer ${this.cryptoService.decrypt( | |
connection.access_token, | |
)}`, | |
}, | |
}); | |
const orders: WebflowOrderOutput[] = resp.data.orders; | |
this.logger.log(`Synced webflow orders !`); | |
return { | |
data: orders, | |
message: 'Webflow orders retrieved', | |
statusCode: 200, | |
}; | |
} catch (error) { | |
throw error; | |
} | |
} | |
} | |
import { EncryptionService } from '@@core/@core-services/encryption/encryption.service'; | |
import { LoggerService } from '@@core/@core-services/logger/logger.service'; | |
import { PrismaService } from '@@core/@core-services/prisma/prisma.service'; | |
import { ApiResponse } from '@@core/utils/types'; | |
import { SyncParam } from '@@core/utils/types/interface'; | |
import { IOrderService } from '@ecommerce/order/types'; | |
import { Injectable } from '@nestjs/common'; | |
import { EcommerceObject } from '@panora/shared'; | |
import axios from 'axios'; | |
import { ServiceRegistry } from '../registry.service'; | |
import { WebflowOrderInput, WebflowOrderOutput } from './types'; | |
@Injectable() | |
export class WebflowService implements IOrderService { | |
constructor( | |
private prisma: PrismaService, | |
private logger: LoggerService, | |
private cryptoService: EncryptionService, | |
private registry: ServiceRegistry, | |
) { | |
this.logger.setContext( | |
`${EcommerceObject.order.toUpperCase()}:${WebflowService.name}`, | |
); | |
this.registry.registerService('webflow', this); | |
} | |
async sync(data: SyncParam): Promise<ApiResponse<WebflowOrderOutput[]>> { | |
const connection = await this.prisma.connections.findFirst({ | |
where: { | |
id_linked_user: data.linkedUserId, | |
provider_slug: 'webflow', | |
vertical: 'ecommerce', | |
}, | |
}); | |
// ref: https://docs.developers.webflow.com/data/reference/list-orders | |
const resp = await axios.get(`${connection.account_url}/orders`, { | |
headers: { | |
'Content-Type': 'application/json', | |
Authorization: `Bearer ${this.cryptoService.decrypt( | |
connection.access_token, | |
)}`, | |
}, | |
}); | |
const orders: WebflowOrderOutput[] = resp.data.orders; | |
this.logger.log(`Synced webflow orders !`); | |
return { | |
data: orders, | |
message: 'Webflow orders retrieved', | |
statusCode: 200, | |
}; | |
} | |
} |
Tools
Biome
[error] 55-55: The catch clause that only rethrows the original error is redundant.
These unnecessary catch clauses can be confusing. It is recommended to remove them.
(lint/complexity/noUselessCatch)
async desunify( | ||
source: UnifiedEcommerceCustomerInput, | ||
customFieldMappings?: { | ||
slug: string; | ||
remote_id: string; | ||
}[], | ||
): Promise<WebflowCustomerInput> { | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reminder: Implement the desunify
method.
The desunify
method is currently not implemented and returns undefined. Please implement the logic to convert from the unified customer type to the Webflow-specific customer type.
Do you want me to generate the implementation for the desunify
method or open a GitHub issue to track this task?
} catch (error) { | ||
throw error; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove redundant catch clauses.
The catch clauses in the addProduct
and sync
methods only rethrow the original error, which is redundant and can be confusing. It is recommended to remove these unnecessary catch clauses.
Apply this diff to remove the redundant catch clauses:
- } catch (error) {
- throw error;
- }
+ }
Also applies to: 96-98
Tools
Biome
[error] 61-61: The catch clause that only rethrows the original error is redundant.
These unnecessary catch clauses can be confusing. It is recommended to remove them.
(lint/complexity/noUselessCatch)
async desunify( | ||
source: UnifiedEcommerceOrderInput, | ||
customFieldMappings?: { | ||
slug: string; | ||
remote_id: string; | ||
}[], | ||
): Promise<WebflowOrderInput> { | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implement the desunify
method.
The desunify
method is not implemented and returns undefined. This may cause issues if the method is called.
Do you want me to generate the implementation for the desunify
method or open a GitHub issue to track this task?
Adding webflow integrating to ecommerce front. Issue #640
Objects
demo: https://drive.google.com/file/d/1QGYlbbgcTYEQIJGtWV0O8DcLO_U0Qcti/view?usp=sharing
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Chores