syncCategories.buildActions returns action in the wrong format (array of arrays)
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 45/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- javascript, nodejs
- Lĩnh vực
- api
Hướng nghiên cứu
Bắt đầu tại createSyncCategories và điểm vào buildActions của nó, tái hiện ví dụ cập nhật tên asset được cung cấp. Xác minh rằng kết quả là một mảng phẳng duy nhất chứa các action removeAsset và addAsset, thay vì một mảng các mảng.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Support reference number
Description
const { createSyncCategories } = require('@commercetools/sync-actions')
const syncCategories = createSyncCategories()
const newCategory = {
key: 'category-8accca22-4d57-4692-bee0-483e43502088',
name: {
de: 'Test',
},
slug: {
en: 'category-8accca22-4d57-4692-bee0-483e43502088-slug',
},
assets: [
{
key: 'asset-key-1-4ab57b6d-3a0e-46a3-b9b2-539ce4fde618',
name: {
en: 'asset name - 1',
},
description: {
en: 'asset description - 1',
},
sources: [
{
key: 'source-key-138d0808-f4f4-4fa8-a9de-48d803eec277',
uri: 'https://google.com',
},
],
tags: ['tag-1', 'tag-2'],
},
{
key: 'asset-key-3-551a2305-25cc-4fb3-a79c-fcb272be3b89',
name: {
en: 'asset name - 3',
},
description: {
en: 'asset description - 3',
},
sources: [
{
key: 'source-key-ca27d6c8-5b65-431f-ad65-21bed9abd2a9',
uri: 'https://google.com',
},
],
tags: ['tag-5', 'tag-6'],
},
{
key: 'asset-key-2-986daecf-f793-462f-a598-0ee769af331d',
name: {
en: 'asset name - updated',
},
description: {
en: 'asset description - 2',
},
sources: [
{
key: 'source-key-8ccb652c-6abc-4c6b-bec0-071ca8948106',
uri: 'https://google.com',
},
],
tags: ['tag-3', 'tag-4'],
},
],
orderHint: '0.000017176731611011768329613',
}
const category = {
id: '5cd1b242-9e27-4199-9cc5-f7057c5f988d',
version: 1,
versionModifiedAt: '2024-06-06T11:26:01.104Z',
lastMessageSequenceNumber: 1,
createdAt: '2024-06-06T11:26:01.104Z',
lastModifiedAt: '2024-06-06T11:26:01.104Z',
lastModifiedBy: {
clientId: 'REDACTED',
isPlatformClient: false,
},
createdBy: {
clientId: 'REDACTED',
isPlatformClient: false,
},
key: 'category-8accca22-4d57-4692-bee0-483e43502088',
name: {
en: 'Category 8accca22-4d57-4692-bee0-483e43502088',
},
slug: {
en: 'category-8accca22-4d57-4692-bee0-483e43502088-slug',
},
ancestors: [],
orderHint: '0.000017176731611011768329613',
assets: [
{
id: 'a7112cd1-0e67-4b35-84a3-3ede87d392e7',
sources: [
{
uri: 'https://google.com',
key: 'source-key-138d0808-f4f4-4fa8-a9de-48d803eec277',
},
],
name: {
en: 'asset name - 1',
},
key: 'asset-key-1-4ab57b6d-3a0e-46a3-b9b2-539ce4fde618',
description: {
en: 'asset description - 1',
},
tags: ['tag-1', 'tag-2'],
},
{
id: '4ed62080-ce1e-4f92-93e7-e07e2a6e06bc',
sources: [
{
uri: 'https://google.com',
key: 'source-key-8ccb652c-6abc-4c6b-bec0-071ca8948106',
},
],
name: {
en: 'asset name - 2',
},
key: 'asset-key-2-986daecf-f793-462f-a598-0ee769af331d',
description: {
en: 'asset description - 2',
},
tags: ['tag-3', 'tag-4'],
},
{
id: '38acda20-4722-4d84-8bcd-b7a8dc33f096',
sources: [
{
uri: 'https://google.com',
key: 'source-key-ca27d6c8-5b65-431f-ad65-21bed9abd2a9',
},
],
name: {
en: 'asset name - 3',
},
key: 'asset-key-3-551a2305-25cc-4fb3-a79c-fcb272be3b89',
description: {
en: 'asset description - 3',
},
tags: ['tag-5', 'tag-6'],
},
],
}
const onlyAssetNameChanged = {
...category,
assets: category.assets.map((asset, index) => {
if (index !== 1) return asset
return {
...asset,
name: {
...asset.name,
en: asset.name.en + ' - updated',
},
}
}),
}
const actions = syncCategories.buildActions(onlyAssetNameChanged, category)
console.log(JSON.stringify(actions, null, 2))
Expected Behavior
I expect to get array of actions
[
{
"action": "removeAsset",
"assetId": "4ed62080-ce1e-4f92-93e7-e07e2a6e06bc"
},
{
"action": "addAsset",
"asset": {
"id": "4ed62080-ce1e-4f92-93e7-e07e2a6e06bc",
"sources": [
{
"uri": "https://google.com",
"key": "source-key-8ccb652c-6abc-4c6b-bec0-071ca8948106"
}
],
"name": {
"en": "asset name - 2 - updated"
},
"key": "asset-key-2-986daecf-f793-462f-a598-0ee769af331d",
"description": {
"en": "asset description - 2"
},
"tags": [
"tag-3",
"tag-4"
]
}
}
]
Current Behavior
Currently I get, array of array of actions
[
[
{
"action": "removeAsset",
"assetId": "4ed62080-ce1e-4f92-93e7-e07e2a6e06bc"
},
{
"action": "addAsset",
"asset": {
"id": "4ed62080-ce1e-4f92-93e7-e07e2a6e06bc",
"sources": [
{
"uri": "https://google.com",
"key": "source-key-8ccb652c-6abc-4c6b-bec0-071ca8948106"
}
],
"name": {
"en": "asset name - 2 - updated"
},
"key": "asset-key-2-986daecf-f793-462f-a598-0ee769af331d",
"description": {
"en": "asset description - 2"
},
"tags": [
"tag-3",
"tag-4"
]
}
}
]
]
Context
Possible Solution
- Ngôn ngữ chính
- JavaScript
- Star
- 77
- Fork
- 70
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của commercetools/nodejs
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
commercetools/nodejs#1901 ·
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 55/100
commercetools/nodejs#1891 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
commercetools/nodejs#1889 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
commercetools/nodejs#1884 · 4 reaction ·
-
Unhandled Promise Rejections coming from sdk-middleware-httpCó thể làm lại được @ajimae đã nhận 1201 ngày trước và không có pull request nào đang mở. Đang mởType: Bug
commercetools/nodejs#1858 · 1 bình luận · 1 reaction · 1 người được giao ·
Tất cả issue của commercetools/nodejs
Issue tương tự
-
bug CI breakage triage needed
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
oppia/oppia#27517 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
draftomen enhancement size: S
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
andreagrandi/draftomen#761 ·
-
Remove the stale .eslintignoreĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
HarperFast/harper#2866 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
HarperFast/harper-pro#927 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
anthropics/skills#1897 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày