-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Unleashed - new components #18739
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
base: master
Are you sure you want to change the base?
Unleashed - new components #18739
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
WalkthroughAdds Unleashed Software app client with signed HTTP methods, propDefinitions, and list/get/create/update operations. Introduces actions to create/update/get Sales Orders and Purchase Orders, get Stock On Hand, and create Stock Adjustments and Stock Transfers. Updates package.json with version bump and dependency. Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant Action as Create Order Action
participant App as Unleashed App Client
participant API as Unleashed API
User->>Action: Provide inputs (customer/supplier, lines, tax code, etc.)
Action->>App: getTaxRateFromCode(taxCode)
App->>API: GET /Tax (signed)
API-->>App: Tax rate
Action->>Action: Build lines, compute Subtotal/Tax/Total
Action->>App: createSalesOrder / createPurchaseOrder(data)
App->>API: POST /SalesOrders or /PurchaseOrders (signed)
API-->>App: Created order
App-->>Action: Response
Action-->>User: Summary + response
sequenceDiagram
actor User
participant Action as Update Order Action
participant App as Unleashed App Client
participant API as Unleashed API
User->>Action: Provide orderId and optional overrides
Action->>App: getSalesOrder / getPurchaseOrder(orderId)
App->>API: GET /...Orders/{id} (signed)
API-->>App: Order details
Action->>App: getTaxRateFromCode(order.TaxCode)
App->>API: GET /Tax (signed)
API-->>App: Tax rate
Action->>App: updateSalesOrder / updatePurchaseOrder(orderId, data)
App->>API: PUT /...Orders/{id} (signed)
API-->>App: Updated order
Action-->>User: Summary + response
Estimated code review effort🎯 4 (Complex) | ⏱️ ~75 minutes Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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: 3
🧹 Nitpick comments (6)
components/unleashed_software/actions/get-stock-on-hand/get-stock-on-hand.mjs (1)
23-34
: Consider exposing pagination control to users.The underlying
getStockOnHand
method supports pagination, but this action always uses the default page (1). If stock on hand results for a product can span multiple pages, users have no way to access subsequent pages.Consider adding a
page
prop to allow users to retrieve additional pages:productId: { propDefinition: [ unleashedSoftware, "productId", ], }, + page: { + type: "integer", + label: "Page", + description: "Page number for pagination (default: 1)", + optional: true, + default: 1, + }, }, async run({ $ }) { const response = await this.unleashedSoftware.getStockOnHand({ $, + page: this.page, params: { productId: this.productId, }, });components/unleashed_software/actions/create-stock-adjustment/create-stock-adjustment.mjs (1)
49-72
: Document the single-product limitation or consider supporting multiple products.The implementation only supports adjusting a single product per operation, as
StockAdjustmentLines
contains a hardcoded array with one element. If the Unleashed API supports adjusting multiple products in a single request, consider enhancing this action to accept multiple product adjustments.If you'd like to support multiple products, you could restructure the props to accept an array of product adjustments. Alternatively, if this is intentional, add a note in the description clarifying that only one product can be adjusted per action execution.
components/unleashed_software/unleashed_software.app.mjs (1)
190-197
: Consider optimizing tax rate lookup if the API supports it.The current implementation fetches all taxes to find a matching tax code. While acceptable for small tax lists, this could be optimized if the Unleashed API provides a direct endpoint for looking up a specific tax code.
If optimization is needed and the API supports it, consider adding a direct lookup method. Otherwise, the current implementation is acceptable.
components/unleashed_software/actions/update-sales-order/update-sales-order.mjs (1)
72-72
: Consider handling undefined comments to avoid clearing existing values.The
Comments
field is always included in the update payload, even whenthis.comments
is undefined. This might unintentionally clear existing comments on the sales order.Consider conditionally including comments only when provided:
Warehouse: { Guid: this.warehouseId || salesOrder.Warehouse.Guid, }, - Comments: this.comments, + ...(this.comments !== undefined && { Comments: this.comments }), SubTotal: salesOrder.SubTotal,Alternatively, if clearing comments when not provided is the intended behavior, document this in the action description.
components/unleashed_software/actions/create-stock-transfer/create-stock-transfer.mjs (2)
16-27
: Consider adding explicit labels to distinguish source and destination warehouses.Both
sourceWarehouseId
anddestinationWarehouseId
use the same propDefinition, which will display the same label ("Warehouse ID") in the UI. While the property keys will help differentiate them, adding explicit label overrides would improve clarity.Apply this diff to add explicit labels:
sourceWarehouseId: { + label: "Source Warehouse", propDefinition: [ unleashedSoftware, "warehouseId", ], }, destinationWarehouseId: { + label: "Destination Warehouse", propDefinition: [ unleashedSoftware, "warehouseId", ], },
40-64
: Document the single-product limitation or consider supporting multiple products.The implementation only supports transferring a single product per operation. If the Unleashed API supports transferring multiple products in one request, consider enhancing this action. Otherwise, document in the description that only one product can be transferred per execution.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (11)
components/unleashed_software/actions/create-purchase-order/create-purchase-order.mjs
(1 hunks)components/unleashed_software/actions/create-sales-order/create-sales-order.mjs
(1 hunks)components/unleashed_software/actions/create-stock-adjustment/create-stock-adjustment.mjs
(1 hunks)components/unleashed_software/actions/create-stock-transfer/create-stock-transfer.mjs
(1 hunks)components/unleashed_software/actions/get-purchase-order/get-purchase-order.mjs
(1 hunks)components/unleashed_software/actions/get-sales-order/get-sales-order.mjs
(1 hunks)components/unleashed_software/actions/get-stock-on-hand/get-stock-on-hand.mjs
(1 hunks)components/unleashed_software/actions/update-purchase-order/update-purchase-order.mjs
(1 hunks)components/unleashed_software/actions/update-sales-order/update-sales-order.mjs
(1 hunks)components/unleashed_software/package.json
(2 hunks)components/unleashed_software/unleashed_software.app.mjs
(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (10)
components/unleashed_software/actions/update-purchase-order/update-purchase-order.mjs (3)
components/unleashed_software/actions/create-purchase-order/create-purchase-order.mjs (2)
taxRate
(96-99)response
(117-138)components/unleashed_software/actions/update-sales-order/update-sales-order.mjs (2)
taxRate
(56-59)response
(61-81)components/unleashed_software/actions/get-purchase-order/get-purchase-order.mjs (1)
response
(24-27)
components/unleashed_software/actions/get-sales-order/get-sales-order.mjs (1)
components/unleashed_software/actions/get-purchase-order/get-purchase-order.mjs (1)
response
(24-27)
components/unleashed_software/actions/get-purchase-order/get-purchase-order.mjs (1)
components/unleashed_software/actions/get-sales-order/get-sales-order.mjs (1)
response
(24-27)
components/unleashed_software/unleashed_software.app.mjs (2)
components/unleashed_software/actions/create-purchase-order/create-purchase-order.mjs (1)
products
(71-73)components/unleashed_software/actions/create-sales-order/create-sales-order.mjs (1)
products
(69-71)
components/unleashed_software/actions/create-stock-transfer/create-stock-transfer.mjs (3)
components/unleashed_software/actions/create-purchase-order/create-purchase-order.mjs (1)
response
(117-138)components/unleashed_software/actions/create-sales-order/create-sales-order.mjs (1)
response
(115-136)components/unleashed_software/actions/create-stock-adjustment/create-stock-adjustment.mjs (1)
response
(50-67)
components/unleashed_software/actions/create-sales-order/create-sales-order.mjs (2)
components/unleashed_software/actions/create-purchase-order/create-purchase-order.mjs (9)
i
(66-66)i
(101-101)products
(71-73)lineItems
(94-94)subtotal
(95-95)taxRate
(96-99)lineTotal
(102-102)lineTax
(103-103)response
(117-138)components/unleashed_software/unleashed_software.app.mjs (1)
products
(77-79)
components/unleashed_software/actions/get-stock-on-hand/get-stock-on-hand.mjs (2)
components/unleashed_software/actions/get-purchase-order/get-purchase-order.mjs (1)
response
(24-27)components/unleashed_software/actions/get-sales-order/get-sales-order.mjs (1)
response
(24-27)
components/unleashed_software/actions/create-purchase-order/create-purchase-order.mjs (2)
components/unleashed_software/actions/create-sales-order/create-sales-order.mjs (10)
props
(60-60)i
(64-64)i
(99-99)products
(69-71)lineItems
(92-92)subtotal
(93-93)taxRate
(94-97)lineTotal
(100-100)lineTax
(101-101)response
(115-136)components/unleashed_software/unleashed_software.app.mjs (1)
products
(77-79)
components/unleashed_software/actions/create-stock-adjustment/create-stock-adjustment.mjs (3)
components/unleashed_software/actions/create-purchase-order/create-purchase-order.mjs (1)
response
(117-138)components/unleashed_software/actions/create-sales-order/create-sales-order.mjs (1)
response
(115-136)components/unleashed_software/actions/create-stock-transfer/create-stock-transfer.mjs (1)
response
(41-59)
components/unleashed_software/actions/update-sales-order/update-sales-order.mjs (3)
components/unleashed_software/actions/create-sales-order/create-sales-order.mjs (2)
taxRate
(94-97)response
(115-136)components/unleashed_software/actions/update-purchase-order/update-purchase-order.mjs (2)
taxRate
(61-64)response
(66-89)components/unleashed_software/actions/get-sales-order/get-sales-order.mjs (1)
response
(24-27)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Lint Code Base
- GitHub Check: Publish TypeScript components
- GitHub Check: Verify TypeScript components
🔇 Additional comments (10)
components/unleashed_software/actions/get-stock-on-hand/get-stock-on-hand.mjs (1)
1-22
: LGTM!The action metadata and props are well-structured. The use of propDefinitions for productId ensures consistent UX across actions.
components/unleashed_software/actions/create-stock-adjustment/create-stock-adjustment.mjs (1)
26-48
: LGTM!Props are appropriately defined using propDefinitions for resource selectors.
components/unleashed_software/unleashed_software.app.mjs (5)
1-3
: LGTM!Appropriate imports for API client functionality and request signing.
7-152
: LGTM!PropDefinitions are well-structured with consistent pagination patterns and clear value/label mappings. This provides a good foundation for dynamic resource selection across actions.
154-172
: LGTM!Authentication signature implementation correctly uses HMAC-SHA256 with the API key. Query string building follows standard URLSearchParams patterns.
173-189
: LGTM!The request builder properly constructs authenticated requests with signed headers. The authentication flow matches the Unleashed API requirements.
198-323
: LGTM!API methods follow a consistent and clean pattern. Proper use of HTTP verbs (GET for reads, POST for creates, PUT for updates) and parameter handling throughout.
components/unleashed_software/actions/update-sales-order/update-sales-order.mjs (1)
1-49
: LGTM!Action metadata and props are well-defined. The optional nature of update fields allows for flexible partial updates.
components/unleashed_software/actions/create-stock-transfer/create-stock-transfer.mjs (2)
1-13
: LGTM!Action metadata and annotations are appropriate for a stock transfer creation operation.
40-64
: Implementation looks correct for single-product transfers.The stock transfer logic properly maps the source/destination warehouses and product details to the API payload structure.
components/unleashed_software/actions/create-purchase-order/create-purchase-order.mjs
Show resolved
Hide resolved
components/unleashed_software/actions/create-stock-adjustment/create-stock-adjustment.mjs
Show resolved
Hide resolved
components/unleashed_software/actions/update-sales-order/update-sales-order.mjs
Show resolved
Hide resolved
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.
Hi @michelle0927, LGTM! Ready for QA!
Resolves #6258
Summary by CodeRabbit
New Features
Chores